linux-bl808/arch/x86/kvm
Hendrik Borghorst a44b331614 KVM: x86/vmx: Do not skip segment attributes if unusable bit is set
When serializing and deserializing kvm_sregs, attributes of the segment
descriptors are stored by user space. For unusable segments,
vmx_segment_access_rights skips all attributes and sets them to 0.

This means we zero out the DPL (Descriptor Privilege Level) for unusable
entries.

Unusable segments are - contrary to their name - usable in 64bit mode and
are used by guests to for example create a linear map through the
NULL selector.

VMENTER checks if SS.DPL is correct depending on the CS segment type.
For types 9 (Execute Only) and 11 (Execute Read), CS.DPL must be equal to
SS.DPL [1].

We have seen real world guests setting CS to a usable segment with DPL=3
and SS to an unusable segment with DPL=3. Once we go through an sregs
get/set cycle, SS.DPL turns to 0. This causes the virtual machine to crash
reproducibly.

This commit changes the attribute logic to always preserve attributes for
unusable segments. According to [2] SS.DPL is always saved on VM exits,
regardless of the unusable bit so user space applications should have saved
the information on serialization correctly.

[3] specifies that besides SS.DPL the rest of the attributes of the
descriptors are undefined after VM entry if unusable bit is set. So, there
should be no harm in setting them all to the previous state.

[1] Intel SDM Vol 3C 26.3.1.2 Checks on Guest Segment Registers
[2] Intel SDM Vol 3C 27.3.2 Saving Segment Registers and Descriptor-Table
Registers
[3] Intel SDM Vol 3C 26.3.2.2 Loading Guest Segment Registers and
Descriptor-Table Registers

Cc: Alexander Graf <graf@amazon.de>
Cc: stable@vger.kernel.org
Signed-off-by: Hendrik Borghorst <hborghor@amazon.de>
Reviewed-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Alexander Graf <graf@amazon.com>
Message-Id: <20221114164823.69555-1-hborghor@amazon.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2023-01-22 04:09:28 -05:00
..
mmu Merge branch 'kvm-late-6.1-fixes' into HEAD 2022-12-28 07:19:14 -05:00
svm KVM: nSVM: clarify recalc_intercepts() wrt CR8 2023-01-09 05:35:21 -05:00
vmx KVM: x86/vmx: Do not skip segment attributes if unusable bit is set 2023-01-22 04:09:28 -05:00
.gitignore
cpuid.c KVM: x86: Do not return host topology information from KVM_GET_SUPPORTED_CPUID 2023-01-09 05:35:21 -05:00
cpuid.h
debugfs.c
emulate.c KVM: x86: move SMM exit to a new file 2022-11-09 12:31:18 -05:00
fpu.h
hyperv.c KVM: x86: hyper-v: Fix 'using uninitialized value' Coverity warning 2022-12-23 12:08:16 -05:00
hyperv.h KVM: nSVM: hyper-v: Enable L2 TLB flush 2022-11-18 12:59:18 -05:00
i8254.c
i8254.h
i8259.c
ioapic.c
ioapic.h
irq.c KVM: x86: remove unnecessary exports 2022-12-02 13:36:44 -05:00
irq.h
irq_comm.c KVM: x86: ioapic: Fix level-triggered EOI and userspace I/OAPIC reconfigure race 2022-12-23 12:07:40 -05:00
Kconfig KVM: allow compiling out SMM support 2022-11-09 12:31:19 -05:00
kvm-asm-offsets.c
kvm_cache_regs.h
kvm_emulate.h KVM: x86: do not define SMM-related constants if SMM disabled 2022-11-09 12:31:21 -05:00
kvm_onhyperv.c
kvm_onhyperv.h
lapic.c KVM: x86: remove unnecessary exports 2022-12-02 13:36:44 -05:00
lapic.h KVM: x86: Simplify kvm_apic_hw_enabled 2022-12-23 12:09:28 -05:00
Makefile
mmu.h
mtrr.c
pmu.c KVM: x86/pmu: Prevent zero period event from being repeatedly released 2022-12-23 12:06:45 -05:00
pmu.h KVM: x86/pmu: Prevent zero period event from being repeatedly released 2022-12-23 12:06:45 -05:00
reverse_cpuid.h ARM64: 2022-12-15 11:12:21 -08:00
smm.c
smm.h
trace.h KVM: x86/xen: Add CPL to Xen hypercall tracepoint 2022-11-28 13:31:01 -05:00
tss.h
x86.c Merge branch 'kvm-late-6.1-fixes' into HEAD 2022-12-28 07:19:14 -05:00
x86.h
xen.c KVM: x86/xen: Avoid deadlock by adding kvm->arch.xen.xen_lock leaf node lock 2023-01-11 17:45:58 -05:00
xen.h KVM: x86/xen: add support for 32-bit guests in SCHEDOP_poll 2022-11-30 19:24:56 +00:00