20 Commits
Author SHA1 Message Date
Jamie LiuandgVisor bot aecf514158 Don't XSAVE PKRU state.
We don't implement any of the `pkey_*` syscalls, so applications can't use
protection keys.

Updates #10087

PiperOrigin-RevId: 611287272
2024-02-28 17:47:27 -08:00
Jamie LiuandgVisor bot 59a057980d Minor FPU save/restore fixes.
- Use the correct instruction in safecopy.checkXstate(). Before this CL:

```
TEXT pkg/sentry/arch/fpu/fpu.initX86FPState.abi0(SB)
  ...
  fpu_amd64.s:78        0x7661b2                480fae2f                XRSTOR64 0(DI)

TEXT pkg/safecopy/safecopy.checkXstate.abi0(SB)
  ...
  xrstor_amd64.s:54     0x7648a0                0fae2f                  XRSTOR 0(DI)
```

I'm not sure what the actual difference between XRSTOR and XRSTOR64 is, but
Linux is careful to use XRSTOR64 (arch/x86/kernel/fpu/xstate.h:XRSTOR,
REX_PREFIX) so it probably matters.

- When an AfterLoad callback fails, log the error message before the failing
  object, since the latter can be huge and prevent the error message from being
  logged.

- Include additional information in the error message emitted by
  fpu.State.AfterLoad().

PiperOrigin-RevId: 605534648
2024-02-08 23:11:09 -08:00
Konstantin BogomolovandgVisor bot bb84006816 Fixup AMX workaround for ptrace.
SETREGSET/GETREGSET expect AMX portions of fpstate to always be used.
For this reason we need to allocate enough memory for this to happen,
even if we never populate the AMX portions within initX86FPState.

PiperOrigin-RevId: 599702181
2024-01-18 20:12:31 -08:00
Konstantin BogomolovandgVisor bot e9bdc76c02 Exclude AMX extended state from being xsave/xrstor'd.
For now we are going to completely disable using AMX, so we will
always subtract extended state size reserved from AMX from the rest
of the extended state size, and hardcode the AMX XCR0 bits to be
always off.

Fixes #9750.

PiperOrigin-RevId: 599302059
2024-01-17 15:11:03 -08:00
prof awk 4d30f2c9ef use new clear builtin to clear bufs 2023-11-27 19:43:25 +02:00
Andrei VaginandgVisor bot 4adc33ad0d fpu: avoid user stack corruptions
When we reserve space for an FPU state in a signal frame, we need to use
the size of the current fpu state. The kernel cpuid can report a smaller size.

On restore, we need to read the size of an fpu state from a signal frame.
After S/R, it can't be different from the current fpu size.

PiperOrigin-RevId: 546972243
2023-07-10 13:54:12 -07:00
Andrei VaginandgVisor bot 3431cd4bff fpu: verify that a restored fpu state can be loaded by xrstor
PiperOrigin-RevId: 538886033
2023-06-08 14:14:53 -07:00
Andrei VaginandgVisor bot ea84ec9a17 kvm: add the extended state information into fpu states
Otherwise, rt_sigreturn rejects it.

PiperOrigin-RevId: 537445737
2023-06-02 17:18:20 -07:00
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Adin ScannellandgVisor bot be86ca7d22 Fix assembly declarations.
PiperOrigin-RevId: 511648708
2023-02-22 18:14:26 -08:00
Ayush RanjanandgVisor bot f6ed4523dc Reformat codebase.
PiperOrigin-RevId: 449358041
2022-05-17 17:48:35 -07:00
Jamie LiuandgVisor bot 44644d9c19 Save/restore floating point state in amd64 signal frames.
PiperOrigin-RevId: 429178859
2022-02-16 17:23:40 -08:00
Adin ScannellandgVisor bot 266cabd008 Refactor CPUID to allow for use in KVM and ring0.
Updates #5039

PiperOrigin-RevId: 421696994
2022-01-13 17:24:28 -08:00
Jamie LiuandgVisor bot b4de26d6b1 Don't use reflection in fpu.alignedBytes.
reflect.ValueOf takes an interface{}, so when passed a slice the compiler emits
a call to runtime.convTslice to heap-allocate a copy of the slice header.

PiperOrigin-RevId: 394310052
2021-09-01 14:07:57 -07:00
Jamie LiuandgVisor bot 1ad3822200 Add go:build directives as required by Go 1.17's gofmt.
PiperOrigin-RevId: 385894869
2021-07-20 16:28:45 -07:00
Zach KoopmansandgVisor bot e3fdd15932 [syserror] Update syserror to linuxerr for more errors.
Update the following from syserror to the linuxerr equivalent:
EEXIST
EFAULT
ENOTDIR
ENOTTY
EOPNOTSUPP
ERANGE
ESRCH

PiperOrigin-RevId: 384329869
2021-07-12 15:26:20 -07:00
Andrei Vagin eb9b8e53a3 platform/kvm/x86: restore mxcsr when switching from guest to sentry
Goruntime sets mxcsr once and never changes it.

Reported-by: syzbot+ec55cea6e57ec083b7a6@syzkaller.appspotmail.com
Fixes: #5754
2021-04-01 13:28:15 -07:00
Zach KoopmansandgVisor bot 8a2f7e716d [syserror] Split usermem package
Split usermem package to help remove syserror dependency in go_marshal.
New hostarch package contains code not dependent on syserror.

PiperOrigin-RevId: 365651233
2021-03-29 13:30:21 -07:00
Howard Zhang a01fc7108f Fix nogo test error
Signed-off-by: Howard Zhang <howard.zhang@arm.com>
2021-03-25 17:39:28 +08:00
Andrei VaginandgVisor bot 56a9a13976 Move the code that manages floating-point state to a separate package
This change is inspired by Adin's cl/355256448.

PiperOrigin-RevId: 364695931
2021-03-23 18:46:37 -07:00