Commit Graph

202 Commits

Author SHA1 Message Date
Bin Lu 6d68834779 arm64:place an SB sequence following an ERET instruction
Some CPUs(eg: ampere-emag) can speculate past an ERET instruction and potentially perform
speculative accesses to memory before processing the exception return.
Since the register state is often controlled by a lower privilege level
at the point of an ERET, this could potentially be used as part of a
side-channel attack.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-09-10 02:47:13 -04:00
Jamie Liu f3172c3a11 Don't sched_setaffinity in ptrace platform.
PiperOrigin-RevId: 330777900
2020-09-09 12:48:57 -07:00
gVisor bot a4b1c6f5a4 Merge pull request #3742 from lubinszARM:pr_n1_1
PiperOrigin-RevId: 328639254
2020-08-26 17:10:16 -07:00
Adin Scannell 983a55aa06 Support stdlib analyzers with nogo.
This immediately revealed an escape analysis violation (!), where
the sync.Map was being used in a context that escapes were not
allowed. This is a relatively minor fix and is included.

PiperOrigin-RevId: 328611237
2020-08-26 14:42:35 -07:00
Bin Lu 57bfbed1d6 Device major number greater than 2 digits in /proc/self/maps on arm64 N1 machine
Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-08-24 22:41:01 -04:00
Michael Pratt ab6c474210 Bump build constraints to 1.17
This enables pre-release testing with 1.16. The intention is to replace these
with a nogo check before the next release.

PiperOrigin-RevId: 328193911
2020-08-24 12:58:39 -07:00
Michael Pratt 129018ab3d Consistent precondition formatting
Our "Preconditions:" blocks are very useful to determine the input invariants,
but they are bit inconsistent throughout the codebase, which makes them harder
to read (particularly cases with 5+ conditions in a single paragraph).

I've reformatted all of the cases to fit in simple rules:

1. Cases with a single condition are placed on a single line.
2. Cases with multiple conditions are placed in a bulleted list.

This format has been added to the style guide.

I've also mentioned "Postconditions:", though those are much less frequently
used, and all uses already match this style.

PiperOrigin-RevId: 327687465
2020-08-20 13:32:24 -07:00
Bin Lu 05d742ede4 Running hello-world on Thunderx2 with kvm
Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-08-12 05:37:27 -04:00
Andrei Vagin 13a8ae81b2 Add context.FullStateChanged()
It indicates that the Sentry has changed the state of the thread and
next calls of PullFullState() has to do nothing.

PiperOrigin-RevId: 325567415
2020-08-07 22:49:55 -07:00
gVisor bot 8f6d576afe Merge pull request #3069 from lubinszARM:pr_serr_injection2
PiperOrigin-RevId: 325546308
2020-08-07 18:32:25 -07:00
Andrei Vagin 25798f214c Add callbacks to support lazy loading/restoring thread states
PiperOrigin-RevId: 324748508
2020-08-03 22:08:25 -07:00
gVisor bot d5b31458aa Merge pull request #3300 from lubinszARM:pr_fpsimd_usr
PiperOrigin-RevId: 324309862
2020-07-31 16:48:24 -07:00
gVisor bot 6a4bcbdb28 Merge pull request #3448 from lubinszARM:pr_tls_tests
PiperOrigin-RevId: 324127810
2020-07-30 18:44:17 -07:00
gVisor bot c9515dcca3 Merge pull request #3028 from lubinszARM:pr_kvm_hello1
PiperOrigin-RevId: 324125938
2020-07-30 18:29:32 -07:00
Bin Lu bb25c9611b add usr-tls test cases for Arm64
Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-07-30 03:44:23 -04:00
Bin Lu cd1149eef3 supporting sError injection step 2 on Arm64
I disabled DAIF(DEBUG, sError, IRQ, FIQ) in guest kernel mode,
and enabled them in guest user mode.
So, I can make sure all DAIF-s come from guest user mode,
and then the case 'TestBounceStress' can passed on Arm64.

Test steps:
 1, cd pkg/sentry/platform/kvm
 2, bazel test kvm_test --strip=never --test_output=streamed

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-07-30 03:24:35 -04:00
Bin Lu 267f48ebe2 load/store user fpsimd on Arm64
full context switch: add fpsimd load/store support to container
application.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-07-29 09:42:07 -04:00
gVisor bot b0eafc7454 Merge pull request #3201 from lubinszARM:pr_sys64_2
PiperOrigin-RevId: 323456118
2020-07-27 15:46:33 -07:00
gVisor bot 1b2006083c Merge pull request #3299 from lubinszARM:pr_asid
PiperOrigin-RevId: 323455097
2020-07-27 15:44:30 -07:00
Andrei Vagin f347a578b7 Move platform.File in memmap
The subsequent systrap changes will need to import memmap from
the platform package.

PiperOrigin-RevId: 323409486
2020-07-27 11:59:10 -07:00
Bin Lu 14087485bd updated the functions to distinguish IA/DA for Arm64
We need to correctly distinguish instruction_abort/data_abort for
mem_abort@Arm64.
So, EC/WNR/FSC in esr_el1 should be checked.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-07-26 23:35:18 -04:00
Bin Lu ced5863c49 allow guest user applications read CNTVCT_EL0/CNTFRQ_EL0
At present, when doing syscall_kvm test, we need to
enable the function of ESR_ELx_SYS64_ISS_SYS_CNTVCT/ESR_ELx_SYS64_ISS_SYS_CNTFRQ to
successfully pass the test.

I set CNTKCTL_EL1.EL0VCTEN==1/CNTKCTL_EL1.EL0PCTEN==1, so that the related cases can passed.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-07-26 22:25:27 -04:00
lubinszARM 4eb3c8c7e5 kvm-tls-2:add the preservation of user-TLS in the Arm64 kvm platform
This patch load/save TLS for the container application.

Related issue: full context-switch supporting for Arm64 #1238

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gvisor/pull/2761 from lubinszARM:pr_tls_2 cb5dbca1c9c3f378002406da7a58887f9b5032b3
PiperOrigin-RevId: 322887044
2020-07-23 16:08:16 -07:00
Bin Lu 8c9156fed6 add asid support to Arm64
Support the operation of asid, so that I can optimize tlb performance
by combining with nG.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-07-20 01:09:00 -04:00
gVisor bot c5d827d110 Merge pull request #3200 from lubinszARM:pr_kvm_ut_1
PiperOrigin-RevId: 321060717
2020-07-13 16:49:20 -07:00
Bin Lu feb867bb83 Split the kvm ut test cases to correspond to different platforms
Split the kvm ut test cases to pass unit-tests on Arm64.
    I will add the tls and full-context test cases for Arm64 later.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-07-10 03:13:13 -04:00
Bin Lu 49f38dee10 allow guest user applications read ctr_el0 on Arm64
At present, when doing syscall_kvm test, we need to
enable the function of ESR_ELx_SYS64_ISS_SYS_CTR_READ to
successfully pass the test.

I set SCTLR_EL1.UCT==1, so that the related cases can passed.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-07-03 00:08:39 -04:00
Bin Lu 4232be8480 support sError injection in kvm module on Arm64
There are 3 types of asynchronous exceptions on Arm64: sError, IRQ, FIQ.
In this case, we use the sError injection method in bluepillHandler to force the guest to quit.
So that the test case of "TestBounce" can be passed on Arm64.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-06-16 22:50:14 -04:00
gVisor bot b436b9717e Merge pull request #2711 from lubinszARM:pr_mmio
PiperOrigin-RevId: 315812219
2020-06-10 18:51:41 -07:00
Bin Lu b792cc1ca9 minor change in kvm module for Arm64
Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-06-09 05:42:41 -04:00
Adin Scannell 527d08f6af Add +checkescape annotations to kvm/ring0.
This analysis also catches a potential bug, which is a split on mapPhysical.
This would have led to potential guest-exit during Mapping (although this
would have been handled by the now-unecessary retryInGuest loop).

PiperOrigin-RevId: 315025106
2020-06-05 17:25:28 -07:00
gVisor bot 288a1ca6f0 Merge pull request #2689 from lubinszARM:pr_prot_none
PiperOrigin-RevId: 314186752
2020-06-01 13:02:14 -07:00
Michael Pratt 65569cfca0 Update Go version build tags
None of the dependencies have changed in 1.15. It may be possible to simplify
some of the wrappers in rawfile following 1.13, but that can come in a later
change.

PiperOrigin-RevId: 313863264
2020-05-29 15:44:07 -07:00
Bin Lu a534b2c652 adding the VM-Exit method for Arm64
On amd64, it uses 'HLT' to leave the guest.
 Unlike amd64, arm64 can only uses mmio_exit/psci to leave the guest.

 So, I designed the HYPERCALL_VMEXIT to be compatible with amd64/arm64.

 To keep it simple, I used the address of exception table as the
 MMIO base address, so that I can trigger a MMIO-EXIT by forcibly writing this space.
 Then, in host user space, I can calculate this address to find out
 which hypercall.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-05-17 22:28:39 -04:00
Bin Lu 5fa480a877 PROT_NONE should be specially treated in the step of mapPhysical
It's a workaround to treat PROT_NONE as RDONLY temporarily.

TODO(gvisor.dev/issue/2686): PROT_NONE should be specially treated.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-05-13 04:40:28 -04:00
Bin Lu a19c8f0b92 adding the methods to get/set TLS for Arm64 kvm platform
Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-05-13 04:23:35 -04:00
Rahat Mahmood 3c67754663 Enable automated marshalling for signals and the arch package.
PiperOrigin-RevId: 308472331
2020-04-25 23:56:04 -07:00
gVisor bot 10725475c3 Merge pull request #1707 from lubinszARM:pr_lazy_fpsimd_2
PiperOrigin-RevId: 308347744
2020-04-24 16:23:16 -07:00
Andrei Vagin 0c586946ea Specify a memory file in platform.New().
PiperOrigin-RevId: 307941984
2020-04-22 17:50:10 -07:00
gVisor bot ea9bb1c4ea Merge pull request #2235 from xiaobo55x:pcid
PiperOrigin-RevId: 307166482
2020-04-17 22:24:14 -07:00
gVisor bot e1959f58dc Merge pull request #2321 from lubinszARM:pr_nogo
PiperOrigin-RevId: 306300032
2020-04-13 13:41:45 -07:00
Bin Lu ab54d4f496 remove nogo exemption for machine_arm64_unsafe.go
Minimize the use of unsafe.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-04-09 03:54:58 -04:00
Haibo Xu b574c715a7 Move pagetables.limitPCID to arch-specific file.
X86 provide 12 bits for PCID while arm64 support
8/16 bits ASID.

Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: I0bd9236e44e6b6c4c88eb6e9adc5ac27b918bf6c
2020-04-08 09:50:03 +08:00
Adin Scannell 4e6a1a5adb Automated rollback of changelist 303799678
PiperOrigin-RevId: 304221302
2020-04-01 11:06:26 -07:00
Michael Pratt db7917556a Fix 386 build tags
The build tag for 32-bit x86 is 386, not i386.

Updates #2298

PiperOrigin-RevId: 304206373
2020-04-01 10:00:03 -07:00
Adin Scannell 3fac85da95 kvm: handle exit reasons even under EINTR.
In the case of other signals (preemption), inject a normal bounce and
defer the signal until the vCPU has been returned from guest mode.

PiperOrigin-RevId: 303799678
2020-03-30 12:37:57 -07:00
gVisor bot 7aa388ce74 Merge pull request #1986 from lubinszARM:pr_ring0_clean_1
PiperOrigin-RevId: 303105826
2020-03-26 08:49:12 -07:00
Andrei Vagin 22d89ef5cb Import "unsafe" in bluepill_arm64_unsafe.go
This fixes a compile time error:
pkg/sentry/platform/kvm/bluepill_arm64_unsafe.go:45:35: undefined: unsafe

PiperOrigin-RevId: 300375687
2020-03-11 12:01:46 -07:00
Haibo Xu c04958e2fa Enable thread local storage support on arm64.
Linux use the task.thread.uw.tp_value field to store the
TLS pointer on arm64 platform, and we use a similar way
in gvisor to store it in the arch/State struct.

Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: Ie76b5c6d109bc27ccfd594008a96753806db7764
2020-03-09 01:04:55 +00:00
Andrei Vagin bf87da89d3
Merge branch 'master' into pr_lazy_fpsimd_2 2020-03-06 21:12:32 -08:00