arm64 kvm: add a test case for kernel-tls checking
Signed-off-by: Bin Lu <bin.lu@arm.com>
This commit is contained in:
parent
d4d9238c52
commit
4d421f58fe
|
@ -63,6 +63,7 @@ go_test(
|
|||
name = "kvm_test",
|
||||
srcs = [
|
||||
"kvm_amd64_test.go",
|
||||
"kvm_arm64_test.go",
|
||||
"kvm_test.go",
|
||||
"virtual_map_test.go",
|
||||
],
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2020 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build arm64
|
||||
|
||||
package kvm
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/sentry/platform/kvm/testutil"
|
||||
)
|
||||
|
||||
func TestKernelTLS(t *testing.T) {
|
||||
bluepillTest(t, func(c *vCPU) {
|
||||
if !testutil.TLSWorks() {
|
||||
t.Errorf("tls does not work, and it should!")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -23,6 +23,11 @@ import (
|
|||
"gvisor.dev/gvisor/pkg/sentry/arch"
|
||||
)
|
||||
|
||||
// TLSWorks is a tls test.
|
||||
//
|
||||
// It returns true or false.
|
||||
func TLSWorks() bool
|
||||
|
||||
// SetTestTarget sets the rip appropriately.
|
||||
func SetTestTarget(regs *arch.Registers, fn func()) {
|
||||
regs.Pc = uint64(reflect.ValueOf(fn).Pointer())
|
||||
|
|
|
@ -50,6 +50,22 @@ TEXT ·SpinLoop(SB),NOSPLIT,$0
|
|||
start:
|
||||
B start
|
||||
|
||||
TEXT ·TLSWorks(SB),NOSPLIT,$0-8
|
||||
NO_LOCAL_POINTERS
|
||||
MOVD $0x6789, R5
|
||||
MSR R5, TPIDR_EL0
|
||||
MOVD $SYS_GETPID, R8 // getpid
|
||||
SVC
|
||||
MRS TPIDR_EL0, R6
|
||||
CMP R5, R6
|
||||
BNE isNaN
|
||||
MOVD $1, R0
|
||||
MOVD R0, ret+0(FP)
|
||||
RET
|
||||
isNaN:
|
||||
MOVD $0, ret+0(FP)
|
||||
RET
|
||||
|
||||
TEXT ·FloatingPointWorks(SB),NOSPLIT,$0-8
|
||||
NO_LOCAL_POINTERS
|
||||
// gc will touch fpsimd, so we should test it.
|
||||
|
|
Loading…
Reference in New Issue