diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-07-20 19:11:20 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-07-20 19:11:20 +0000 |
commit | 02b4889106d6c4fe2b9d931c2525d6a55994e2e8 (patch) | |
tree | 3826e3f322bc7b6533f9fb6081b7eae8ebf94153 | |
parent | 566c23a60eea4c61e29501356ada685b3b027493 (diff) | |
parent | 7ced03b3831983e35cb25ad0a9d5632ea322f9a4 (diff) |
Merge release-20210712.0-28-g7ced03b38 (automated)
-rw-r--r-- | pkg/ring0/kernel_amd64.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/pkg/ring0/kernel_amd64.go b/pkg/ring0/kernel_amd64.go index b5c4a39e3..a04b60b08 100644 --- a/pkg/ring0/kernel_amd64.go +++ b/pkg/ring0/kernel_amd64.go @@ -19,6 +19,7 @@ package ring0 import ( "encoding/binary" "reflect" + "sync" "gvisor.dev/gvisor/pkg/hostarch" "gvisor.dev/gvisor/pkg/sentry/arch" @@ -30,6 +31,8 @@ func HaltAndWriteFSBase(regs *arch.Registers) // init initializes architecture-specific state. func (k *Kernel) init(maxCPUs int) { + initSentryXCR0() + entrySize := reflect.TypeOf(kernelEntry{}).Size() var ( entries []kernelEntry @@ -257,7 +260,16 @@ func (c *CPU) SwitchToUser(switchOpts SwitchOpts) (vector Vector) { return } -var sentryXCR0 = xgetbv(0) +var ( + sentryXCR0 uintptr + sentryXCR0Once sync.Once +) + +// initSentryXCR0 saves a value of XCR0 in the host mode. It is used to +// initialize XCR0 of guest vCPU-s. +func initSentryXCR0() { + sentryXCR0Once.Do(func() { sentryXCR0 = xgetbv(0) }) +} // startGo is the CPU entrypoint. // |