Bug 211467
Summary: | Regression affecting 32->64 bit SYSENTER on AMD | ||
---|---|---|---|
Product: | Virtualization | Reporter: | jonny5532 (jonny) |
Component: | kvm | Assignee: | virtualization_kvm |
Status: | RESOLVED IMPLEMENTED | ||
Severity: | normal | CC: | seanjc |
Priority: | P1 | ||
Hardware: | x86-64 | ||
OS: | Linux | ||
Kernel Version: | all since 5.8-rc1 | Subsystem: | |
Regression: | Yes | Bisected commit-id: | |
Attachments: |
Simple patch which appears to fix it
Patch with whitespace fix and SOB |
Description
jonny5532
2021-01-29 20:50:12 UTC
Created attachment 294993 [details]
Simple patch which appears to fix it
This patch stops my VM crashing without removing the truncation.
It is based on the assumption that a SYSENTER which changes the CS flags to long mode (if applicable) should also change the ctxt->mode to PROT64. I don't know if that is correct (or safe) though.
LOL, this is awesome. Presumably you're also exposing an Intel CPU model to the guest, otherwise KVM would inject a #UD on SYSENTER instead of emulating. Anyways, hilarity aside, your patch looks correct as Intel CPUs unconditionally transition to 64-bit mode on SYSENTER from compatibility mode. Want to send a formal patch? If you're not set up to send a patch, I'd be happy to write a changelog if you want to provide a Signed-off-by. Created attachment 295027 [details]
Patch with whitespace fix and SOB
Thanks for confirming, here's the same patch again without the missing newline and with my SOB tacked on the bottom. I am indeed not set up for sending patches so would appreciate it if you could do that bit.
I had a look through emulate.c to see if I could foresee any unintended side effects - it seems that SYSEXIT already handles the potential transition back from 64->32 bits.
I do note that some of the transitions to PROT64 are wrapped in "#ifdef CONFIG_X86_64 ... #endif", for example in em_syscall. However that looks pretty dubious in itself - if em_syscall gets run with the guest in long mode, on a 32 bit kernel, then it'll just fail to update the EIP but carry on regardless. Probably an unlikely scenario however (KVM on AMD has only ever worked on 64 bit procs as I understand).
Running a 64-bit guest with a 32-bit host kernel is firmly unsupported, emulator issues are but one of many things that would completely break. I am now running with 5.11 (which contains the fix) and it seems to be working fine now. Thanks all! |