Minor ring0 interface cleanup.
- Remove unused methods. - Provide declaration for asm function. PiperOrigin-RevId: 200146850 Change-Id: Ic455c96ffe0d2e78ef15f824eb65d7de705b054a
This commit is contained in:
parent
1397a413b4
commit
41f766893a
|
@ -40,7 +40,7 @@ type machine struct {
|
|||
nextSlot uint32
|
||||
|
||||
// kernel is the set of global structures.
|
||||
kernel *ring0.Kernel
|
||||
kernel ring0.Kernel
|
||||
|
||||
// mappingCache is used for mapPhysical.
|
||||
mappingCache sync.Map
|
||||
|
@ -135,7 +135,7 @@ func newMachine(vm int, vCPUs int) (*machine, error) {
|
|||
// issues when you've got > n active threads.)
|
||||
vCPUs = n
|
||||
}
|
||||
m.kernel = ring0.New(ring0.KernelOpts{
|
||||
m.kernel.Init(ring0.KernelOpts{
|
||||
PageTables: pagetables.New(newAllocator()),
|
||||
})
|
||||
|
||||
|
@ -158,7 +158,7 @@ func newMachine(vm int, vCPUs int) (*machine, error) {
|
|||
fd: int(fd),
|
||||
machine: m,
|
||||
}
|
||||
c.CPU.Init(m.kernel)
|
||||
c.CPU.Init(&m.kernel)
|
||||
c.CPU.KernelSyscall = bluepillSyscall
|
||||
c.CPU.KernelException = bluepillException
|
||||
m.vCPUs[uint64(-id)] = c // See above.
|
||||
|
|
|
@ -14,27 +14,13 @@
|
|||
|
||||
package ring0
|
||||
|
||||
// New creates a new kernel.
|
||||
// Init initializes a new kernel.
|
||||
//
|
||||
// N.B. that constraints on KernelOpts must be satisfied.
|
||||
//
|
||||
// Init must have been called.
|
||||
func New(opts KernelOpts) *Kernel {
|
||||
k := new(Kernel)
|
||||
//go:nosplit
|
||||
func (k *Kernel) Init(opts KernelOpts) {
|
||||
k.init(opts)
|
||||
return k
|
||||
}
|
||||
|
||||
// NewCPU creates a new CPU associated with this Kernel.
|
||||
//
|
||||
// Note that execution of the new CPU must begin at Start, with constraints as
|
||||
// documented. Initialization is not completed by this method alone.
|
||||
//
|
||||
// See also Init.
|
||||
func (k *Kernel) NewCPU() *CPU {
|
||||
c := new(CPU)
|
||||
c.Init(k)
|
||||
return c
|
||||
}
|
||||
|
||||
// Halt halts execution.
|
||||
|
@ -56,8 +42,7 @@ func defaultSyscall() { Halt() }
|
|||
//go:nosplit
|
||||
func defaultException(Vector) { Halt() }
|
||||
|
||||
// Init allows the initialization of a CPU from a kernel without allocation.
|
||||
// The same constraints as NewCPU apply.
|
||||
// Init initializes a new CPU.
|
||||
//
|
||||
// Init allows embedding in other objects.
|
||||
func (c *CPU) Init(k *Kernel) {
|
||||
|
|
|
@ -64,6 +64,9 @@ func wrgsmsr(addr uintptr)
|
|||
// writeCR3 writes the CR3 value.
|
||||
func writeCR3(phys uintptr)
|
||||
|
||||
// readCR3 reads the current CR3 value.
|
||||
func readCR3() uintptr
|
||||
|
||||
// readCR2 reads the current CR2 value.
|
||||
func readCR2() uintptr
|
||||
|
||||
|
|
Loading…
Reference in New Issue