linux/arch/x86
Sean Christopherson 496cf984a6 KVM: x86: Manually calculate reserved bits when loading PDPTRS
commit 16cfacc808 upstream.

Manually generate the PDPTR reserved bit mask when explicitly loading
PDPTRs.  The reserved bits that are being tracked by the MMU reflect the
current paging mode, which is unlikely to be PAE paging in the vast
majority of flows that use load_pdptrs(), e.g. CR0 and CR4 emulation,
__set_sregs(), etc...  This can cause KVM to incorrectly signal a bad
PDPTR, or more likely, miss a reserved bit check and subsequently fail
a VM-Enter due to a bad VMCS.GUEST_PDPTR.

Add a one off helper to generate the reserved bits instead of sharing
code across the MMU's calculations and the PDPTR emulation.  The PDPTR
reserved bits are basically set in stone, and pushing a helper into
the MMU's calculation adds unnecessary complexity without improving
readability.

Oppurtunistically fix/update the comment for load_pdptrs().

Note, the buggy commit also introduced a deliberate functional change,
"Also remove bit 5-6 from rsvd_bits_mask per latest SDM.", which was
effectively (and correctly) reverted by commit cd9ae5fe47 ("KVM: x86:
Fix page-tables reserved bits").  A bit of SDM archaeology shows that
the SDM from late 2008 had a bug (likely a copy+paste error) where it
listed bits 6:5 as AVL and A for PDPTEs used for 4k entries but reserved
for 2mb entries.  I.e. the SDM contradicted itself, and bits 6:5 are and
always have been reserved.

Fixes: 20c466b561 ("KVM: Use rsvd_bits_mask in load_pdptrs()")
Cc: stable@vger.kernel.org
Cc: Nadav Amit <nadav.amit@gmail.com>
Reported-by: Doug Reiland <doug.reiland@intel.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-10-05 13:10:05 +02:00
..
boot x86/boot/compressed/64: Fix missing initialization in find_trampoline_placement() 2019-09-10 10:33:53 +01:00
configs
crypto crypto: x86/crct10dif-pcl - fix use via crypto_shash_digest() 2019-05-22 07:37:37 +02:00
entry x86/entry/64: Use JMP instead of JMPQ 2019-08-06 19:06:58 +02:00
events perf/x86/amd/ibs: Fix sample bias for dispatched micro-ops 2019-09-21 07:17:07 +02:00
hyperv x86/hyper-v: Fix overflow bug in fill_gva_list() 2019-09-21 07:17:13 +02:00
ia32 x86/ia32: Fix ia32_restore_sigcontext() AC leak 2019-05-31 06:46:27 -07:00
include x86/cpu: Add Tiger Lake to Intel family 2019-10-05 13:09:55 +02:00
kernel x86/apic/vector: Warn when vector space exhaustion breaks affinity 2019-10-05 13:09:51 +02:00
kvm KVM: x86: Manually calculate reserved bits when loading PDPTRS 2019-10-05 13:10:05 +02:00
lib x86/lib/cpu: Address missing prototypes warning 2019-08-29 08:28:45 +02:00
math-emu x86: math-emu: Hide clang warnings for 16-bit overflow 2019-08-06 19:06:51 +02:00
mm x86/mm/pti: Handle unaligned address gracefully in pti_clone_pagetable() 2019-10-05 13:09:52 +02:00
net bpf, x64: fix stack layout of JITed bpf code 2019-07-14 08:11:12 +02:00
oprofile
pci x86/PCI: Fix PCI IRQ routing table memory leak 2019-06-15 11:54:07 +02:00
platform x86/cpu: Sanitize FAM6_ATOM naming 2019-05-14 19:17:53 +02:00
power x86/CPU/AMD: Clear RDRAND CPUID bit on AMD family 15h/16h 2019-08-29 08:28:53 +02:00
purgatory x86/purgatory: Change compiler flags from -mcmodel=kernel to -mcmodel=large to fix kexec relocation errors 2019-09-19 09:09:35 +02:00
ras
realmode x86/realmode: Don't leak the trampoline kernel address 2019-05-04 09:20:21 +02:00
tools x86/relocs: Add __end_rodata_aligned to S_REL 2018-08-09 20:42:07 +02:00
um um: Drop own definition of PTRACE_SYSEMU/_SINGLESTEP 2018-11-21 09:19:16 +01:00
video
xen xen/pv: Fix a boot up hang revealed by int3 self test 2019-08-06 19:06:52 +02:00
.gitignore
Kbuild
Kconfig x86/smp: Enforce CONFIG_HOTPLUG_CPU when SMP=y 2019-04-03 06:26:29 +02:00
Kconfig.cpu
Kconfig.debug Kconfig: consolidate the "Kernel hacking" menu 2018-08-02 08:06:48 +09:00
Makefile x86/build: Add -Wnoaddress-of-packed-member to REALMODE_CFLAGS, to silence GCC9 build warning 2019-09-19 09:09:41 +02:00
Makefile_32.cpu
Makefile.um kbuild: rename LDFLAGS to KBUILD_LDFLAGS 2018-08-24 08:22:08 +09:00