Commit Graph

154 Commits

Author SHA1 Message Date
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
gVisor bot 18d41cf153 Merge pull request #1963 from xiaobo55x:kvm_common
PiperOrigin-RevId: 299405855
2020-03-06 12:05:30 -08:00
gVisor bot 56c4272568 Merge pull request #1946 from xiaobo55x:dieTramp
PiperOrigin-RevId: 299405663
2020-03-06 12:01:23 -08:00
Andrei Vagin 277a0d5a1f platform/ptrace: don't call probeSeccomp on arm64
The support of PTRACE_SYSEMU on arm64 was added in the 5.3 kernel,
so we can be sure that the current version is higher that 5.3.

And this change moves vsyscall seccomp rules to the arch specific file,
because vsyscall isn't supported on arm64.

PiperOrigin-RevId: 298696493
2020-03-03 14:35:42 -08:00
Andrei Vagin 837cf62551 pcids.go isn't arch-specific
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-28 14:34:13 -08:00
Bin Lu 5f0e8e6239 Prepare the vcpu environment for sentry on Arm64
Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-02-27 01:19:28 -05:00
gVisor bot 6ddeb35ed4 Merge pull request #1912 from lubinszARM:pr_kvm_build
PiperOrigin-RevId: 297492004
2020-02-26 19:09:45 -08:00
Haibo Xu 73201f4c57 Code Clean: Move arch independent codes to common file in kvm pkg.
Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: Iefbdf53e8e8d6d23ae75d8a2ff0d2a6e71f414d8
2020-02-26 01:51:31 +00:00
gVisor bot 813b1b0486 Merge pull request #1271 from lubinszARM:pr_ring0_1
PiperOrigin-RevId: 297230721
2020-02-25 16:24:43 -08:00
Adin Scannell 98b693e61b Don't acquire contended lock with the OS thread locked.
Fixes #1049

PiperOrigin-RevId: 297175164
2020-02-25 12:22:29 -08:00
Haibo Xu 93e0c37529 Enable bluepill dieTrampoline operation on arm64.
Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: I9e1bf2513c23bdd8c387e5b3c874c6ad3ca9aab0
2020-02-25 01:50:58 +00:00
Bin Lu de68e1d8c4 Code Clean:Move getUserRegisters into dieArchSetup() and other small changes.
Consistent with QEMU, getUserRegisters() should be an arch-specific
function. So, it should be called in dieArchSetup().

With this patch and the pagetable/pcid patch, the kvm modules on Arm64 can be
built successfully.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-02-20 06:43:27 +00:00
gVisor bot fae3de21af ring0/pagetables: fix typo
PiperOrigin-RevId: 295770717
2020-02-18 10:50:46 -08:00
Bin Lu ebaf29abeb passed the kvm test case of "TestKernelSyscall" on Arm64
For kvm test case "TestKernelSyscall",
redpill/syscall(-1) in guest kernel level will be trapped in el1_svc.
And in el1_svc, we use mmio_exit to leave the guest.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-02-14 02:04:44 -05:00
Bin Lu 6adbdfe232 supporting sError in guest kernel on Arm64
For test case 'TestBounce', we use KVM_SET_VCPU_EVENTS to trigger sError
to leave guest.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-01-29 07:50:38 -05:00
Adin Scannell 0e2f1b7abd Update package locations.
Because the abi will depend on the core types for marshalling (usermem,
context, safemem, safecopy), these need to be flattened from the sentry
directory. These packages contain no sentry-specific details.

PiperOrigin-RevId: 291811289
2020-01-27 15:31:32 -08:00
Adin Scannell 90ec596166 Fix licenses.
The preferred Copyright holder is "The gVisor Authors".

PiperOrigin-RevId: 291786657
2020-01-27 13:23:57 -08:00
Adin Scannell d29e59af9f Standardize on tools directory.
PiperOrigin-RevId: 291745021
2020-01-27 12:21:00 -08:00
Michael Pratt 7a79715504 Check for EINTR from KVM_CREATE_VM
The kernel may return EINTR from:

kvm_create_vm
  kvm_init_mmu_notifier
    mmu_notifier_register
      do_mmu_notifier_register
        mm_take_all_locks

Go 1.14's preemptive scheduling signals make hitting this much more likely.

PiperOrigin-RevId: 291212669
2020-01-23 11:49:02 -08:00
gVisor bot b3405a719c Merge pull request #1275 from lubinszARM:pr_ring0_5
PiperOrigin-RevId: 290839263
2020-01-21 16:09:25 -08:00
gVisor bot 16694ad2ba Merge pull request #1274 from lubinszARM:pr_ring0_4
PiperOrigin-RevId: 290811598
2020-01-21 13:56:48 -08:00
gVisor bot fea1ce655d Merge pull request #1272 from lubinszARM:pr_ring0_2
PiperOrigin-RevId: 290113719
2020-01-16 11:56:09 -08:00
gVisor bot 2ebd21478e Merge pull request #1540 from laijs:fix-PCIDs
PiperOrigin-RevId: 289925133
2020-01-15 13:48:51 -08:00
Ian Gudger 27500d529f New sync package.
* Rename syncutil to sync.
* Add aliases to sync types.
* Replace existing usage of standard library sync package.

This will make it easier to swap out synchronization primitives. For example,
this will allow us to use primitives from github.com/sasha-s/go-deadlock to
check for lock ordering violations.

Updates #1472

PiperOrigin-RevId: 289033387
2020-01-09 22:02:24 -08:00
Lai Jiangshan fdfa05ff2c Avoid panic when c.PCIDs is nil
When PCID is disabled, there would throw a panic
when dropPageTables() access to c.PCID without check.

Signed-off-by: Lai Jiangshan <eag0628@gmail.com>
2020-01-09 09:18:33 +00:00
gVisor bot bb96f52576 Merge pull request #1273 from lubinszARM:pr_ring_3
PiperOrigin-RevId: 288743614
2020-01-08 11:48:34 -08:00
Andrei Vagin 17c18241cd platform/syscall: use syscall + int3 to execute a system call in a stub process
Right now, we need to call ptrace(PTRACE_SYSCALL) and wait() twice to execute
one system call in a stub process. With these changes, we will need to call
ptrace + wait only once.

In addition, this allows to workaround the kernel bug when a stub process
doesn't stop on syscall-exit-stop and starts executing the next system call.

Reported-by: syzbot+37143cafa8dc3b5008ee@syzkaller.appspotmail.com
PiperOrigin-RevId: 288393029
2020-01-06 15:54:53 -08:00
gVisor bot 5b9034cc18 Merge pull request #1461 from xiaobo55x:ptrace_sysemu
PiperOrigin-RevId: 287225250
2019-12-26 14:19:34 -08:00
gVisor bot 7b5a59d503 Merge pull request #1460 from lubinszARM:pr_clean_code1
PiperOrigin-RevId: 287221280
2019-12-26 13:42:39 -08:00
Bin Lu 7b83d21856 slight changes to ring0&pagetables for Arm64
There are 2 jobs have been finished in this patch:
1, a comment was added to explain the purpose of the extra NOPs in Vectors().
2, some merge errors were fixed.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2019-12-24 10:50:11 +08:00
Haibo Xu b6e31aadaa Replace syscall.PTRACE_SYSEMU with unix.PTRACE_SYSEMU
Linux PTRACE_SYSEMU support on arm64 was merged to mainline from
V5.3, and the corresponding support in go also enabled recently.

Since the "syscall" package is locked down from go 1.4, so the ptrace
PTRACE_SYSEMU definition can't be added to package "syscall" on arm64.
According to the golang community, updates required by new systems or
versions should use the corresponding package in the golang.org/x/sys
repository instead(https://golang.org/pkg/syscall/).

Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: I2f917bb2be62f990c3e158e2bb99e094ea03f751
2019-12-23 06:42:03 +00:00
gVisor bot 98e8246ad1 Merge pull request #890 from lubinszARM:pr_phyap
PiperOrigin-RevId: 286299056
2019-12-18 17:37:30 -08:00
gVisor bot ac3b3bb40e Merge pull request #1322 from lubinszARM:pr_vfp_ring0
PiperOrigin-RevId: 286259750
2019-12-18 14:52:35 -08:00
Bin Lu eb868be743 supporting lazy-fpsimd in guest on Arm64
Several jobs were finished in this patch:
1, provide functions to get/set fpcr/fpsr/vregs
2, support lazy-fpsimd-context-switch in el1

Signed-off-by: Bin Lu <bin.lu@arm.com>
2019-12-18 16:45:15 +08:00
Michael Pratt 91f1ac7319 Mark enableCpuidFault nosplit
This is called after fork, so it must be nosplit.

Updates #1408

PiperOrigin-RevId: 286053054
2019-12-17 14:18:54 -08:00
gVisor bot e416724fb3 Merge pull request #1321 from lubinszARM:pr_testutils_vfp
PiperOrigin-RevId: 286042427
2019-12-17 13:10:50 -08:00
lubinszARM 6b42453039 enable kvm to support arm64
There are 4 jobs were finished in this package:
  	1, Virtual machine initialization.
	2, Bluepill implementation.
	3, Move ring0.Vectors() into the address with 11-bits alignment.
	4, Basic support for "SwitchToUser".
Signed-off-by: Bin Lu <bin.lu@arm.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gvisor/pull/919 from lubinszARM:pr_kvm eedea52db451bf62722759009a9f14c54a69c55f
PiperOrigin-RevId: 285501256
2019-12-13 17:11:23 -08:00
Bin Lu 70b68bb058 Add a floating test case for Arm64
Signed-off-by: Bin Lu <bin.lu@arm.com>
2019-12-04 16:28:28 +08:00
Haibo Xu 03760e5623 platform/ptrace: make some operations arch specific
Make the patchSignalInfo/cpuid faulting/initial thread seccomp rules
operations architecture dependent.

Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: Iaf692dbe3700d2e01168ec2f1b4beeda9136fd62
2019-12-03 07:17:34 +00:00
Bin Lu 3f0e91b004 passed the kvm test case of "TestApplicationFault" on Arm64 platform
For test case "TestApplicationFault",
Memory-fault in guest user level will be trapped in el0_da.
And in el0_da, we use mmio_exit to leave the KVM guest.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2019-11-26 16:00:00 +08:00
Bin Lu 3e00624806 passed the kvm test case of "TestApplicationSyscall" on Arm64 platform
For test case "TestApplicationSyscall",
Syscall in guest user level will be trapped in el0_svc.
And in el0_svc, we use mmio_exit to leave the KVM guest for now.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2019-11-26 15:57:15 +08:00
Bin Lu e710f65401 Prepare the vcpu environment for a container application
Mainly 2 jobs were finished in this patch:
    1, context switching for a container application:
        a, R0-R30 b, pc\pstate\sp_el0 c, pagetable_el0 for container application
       This job can help us to pass the following test cases:
       "TestApplicationSyscall", "TestApplicationFault"
    2, checking pagetable_el0 is empty
       This job can help us to pass the following test case: "TestInvalidate"

Signed-off-by: Bin Lu <bin.lu@arm.com>
2019-11-26 15:53:30 +08:00
Bin Lu e91c1675cd passed the kvm test case of "TestKernelFault" on Arm64 platform
Signed-off-by: Bin Lu <bin.lu@arm.com>
2019-11-26 15:32:55 +08:00
lubinszARM 07635d20d4 enable ring0/pagetables to support arm64
Signed-off-by: Bin Lu <bin.lu@arm.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gvisor/pull/891 from lubinszARM:pr_pagetable 2385de75a8662af3ab1ae289dd74dd0e5dcfaf66
PiperOrigin-RevId: 282013224
2019-11-22 12:05:35 -08:00
Andrei Vagin 26b3341b9a platform/ptrace: use host.GetCPU instead of the getcpu syscall
This should save ~200ns from switchToApp (on ptrace too). // mpratt

PiperOrigin-RevId: 281159895
2019-11-18 14:56:49 -08:00
gVisor bot 07f9041187 Merge pull request #918 from lubinszARM:pr_ring0
PiperOrigin-RevId: 279840214
2019-11-11 16:15:12 -08:00
Andrei Vagin f7dbddaf77 platform/kvm: calll sigtimedwait with zero timeout
sigtimedwait is used to check pending signals and
it should not block.

PiperOrigin-RevId: 277777269
2019-10-31 12:29:04 -07:00
lubinszARM ca933329fa support using KVM_MEM_READONLY for arm64 regions
On Arm platform, "setMemoryRegion" has extra permission checks.
In virt/kvm/arm/mmu.c: kvm_arch_prepare_memory_region()
      ....
      if (writable && !(vma->vm_flags & VM_WRITE)) {
             ret = -EPERM;
             break;
       }
        ....
So, for Arm platform, the "flags" for kvm_memory_region is required.
And on x86 platform, the "flags" can be always set as '0'.

Signed-off-by: Bin Lu <bin.lu@arm.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gvisor/pull/810 from lubinszARM:pr_setregion 8c99b19cfb0c859c6630a1cfff951db65fcf87ac
PiperOrigin-RevId: 277602603
2019-10-30 15:53:31 -07:00