Revision 844a5fe219cf472060315971e15cbf97674a3324 authored by Paolo Bonzini on 08 March 2016, 11:13:39 UTC, committed by Paolo Bonzini on 10 March 2016, 10:26:07 UTC
Yes, all of these are needed. :) This is admittedly a bit odd, but kvm-unit-tests access.flat tests this if you run it with "-cpu host" and of course ept=0. KVM runs the guest with CR0.WP=1, so it must handle supervisor writes specially when pte.u=1/pte.w=0/CR0.WP=0. Such writes cause a fault when U=1 and W=0 in the SPTE, but they must succeed because CR0.WP=0. When KVM gets the fault, it sets U=0 and W=1 in the shadow PTE and restarts execution. This will still cause a user write to fault, while supervisor writes will succeed. User reads will fault spuriously now, and KVM will then flip U and W again in the SPTE (U=1, W=0). User reads will be enabled and supervisor writes disabled, going back to the originary situation where supervisor writes fault spuriously. When SMEP is in effect, however, U=0 will enable kernel execution of this page. To avoid this, KVM also sets NX=1 in the shadow PTE together with U=0. If the guest has not enabled NX, the result is a continuous stream of page faults due to the NX bit being reserved. The fix is to force EFER.NX=1 even if the CPU is taking care of the EFER switch. (All machines with SMEP have the CPU_LOAD_IA32_EFER vm-entry control, so they do not use user-return notifiers for EFER---if they did, EFER.NX would be forced to the same value as the host). There is another bug in the reserved bit check, which I've split to a separate patch for easier application to stable kernels. Cc: stable@vger.kernel.org Cc: Andy Lutomirski <luto@amacapital.net> Reviewed-by: Xiao Guangrong <guangrong.xiao@linux.intel.com> Fixes: f6577a5fa15d82217ca73c74cd2dcbc0f6c781dd Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 313f636
File | Mode | Size |
---|---|---|
kasan | ||
Kconfig | -rw-r--r-- | 22.4 KB |
Kconfig.debug | -rw-r--r-- | 1.2 KB |
Makefile | -rw-r--r-- | 2.7 KB |
backing-dev.c | -rw-r--r-- | 26.4 KB |
balloon_compaction.c | -rw-r--r-- | 6.6 KB |
bootmem.c | -rw-r--r-- | 21.0 KB |
cleancache.c | -rw-r--r-- | 9.9 KB |
cma.c | -rw-r--r-- | 12.1 KB |
cma.h | -rw-r--r-- | 515 bytes |
cma_debug.c | -rw-r--r-- | 4.4 KB |
compaction.c | -rw-r--r-- | 48.3 KB |
debug-pagealloc.c | -rw-r--r-- | 2.6 KB |
debug.c | -rw-r--r-- | 6.6 KB |
dmapool.c | -rw-r--r-- | 13.9 KB |
early_ioremap.c | -rw-r--r-- | 6.2 KB |
fadvise.c | -rw-r--r-- | 3.7 KB |
failslab.c | -rw-r--r-- | 1.3 KB |
filemap.c | -rw-r--r-- | 74.1 KB |
frame_vector.c | -rw-r--r-- | 6.2 KB |
frontswap.c | -rw-r--r-- | 14.3 KB |
gup.c | -rw-r--r-- | 41.1 KB |
highmem.c | -rw-r--r-- | 11.8 KB |
huge_memory.c | -rw-r--r-- | 92.9 KB |
hugetlb.c | -rw-r--r-- | 117.9 KB |
hugetlb_cgroup.c | -rw-r--r-- | 10.5 KB |
hwpoison-inject.c | -rw-r--r-- | 3.2 KB |
init-mm.c | -rw-r--r-- | 619 bytes |
internal.h | -rw-r--r-- | 14.4 KB |
interval_tree.c | -rw-r--r-- | 3.1 KB |
kmemcheck.c | -rw-r--r-- | 2.9 KB |
kmemleak-test.c | -rw-r--r-- | 3.2 KB |
kmemleak.c | -rw-r--r-- | 54.5 KB |
ksm.c | -rw-r--r-- | 62.9 KB |
list_lru.c | -rw-r--r-- | 12.6 KB |
maccess.c | -rw-r--r-- | 3.1 KB |
madvise.c | -rw-r--r-- | 18.5 KB |
memblock.c | -rw-r--r-- | 48.6 KB |
memcontrol.c | -rw-r--r-- | 151.7 KB |
memory-failure.c | -rw-r--r-- | 48.9 KB |
memory.c | -rw-r--r-- | 105.9 KB |
memory_hotplug.c | -rw-r--r-- | 53.2 KB |
mempolicy.c | -rw-r--r-- | 71.2 KB |
mempool.c | -rw-r--r-- | 14.0 KB |
memtest.c | -rw-r--r-- | 2.7 KB |
migrate.c | -rw-r--r-- | 47.7 KB |
mincore.c | -rw-r--r-- | 6.7 KB |
mlock.c | -rw-r--r-- | 21.0 KB |
mm_init.c | -rw-r--r-- | 4.9 KB |
mmap.c | -rw-r--r-- | 91.9 KB |
mmu_context.c | -rw-r--r-- | 1.3 KB |
mmu_notifier.c | -rw-r--r-- | 11.7 KB |
mmzone.c | -rw-r--r-- | 2.4 KB |
mprotect.c | -rw-r--r-- | 11.1 KB |
mremap.c | -rw-r--r-- | 15.2 KB |
msync.c | -rw-r--r-- | 2.6 KB |
nobootmem.c | -rw-r--r-- | 11.1 KB |
nommu.c | -rw-r--r-- | 51.9 KB |
oom_kill.c | -rw-r--r-- | 20.8 KB |
page-writeback.c | -rw-r--r-- | 84.0 KB |
page_alloc.c | -rw-r--r-- | 189.7 KB |
page_counter.c | -rw-r--r-- | 4.8 KB |
page_ext.c | -rw-r--r-- | 10.4 KB |
page_idle.c | -rw-r--r-- | 5.4 KB |
page_io.c | -rw-r--r-- | 9.2 KB |
page_isolation.c | -rw-r--r-- | 8.4 KB |
page_owner.c | -rw-r--r-- | 7.1 KB |
pagewalk.c | -rw-r--r-- | 7.5 KB |
percpu-km.c | -rw-r--r-- | 2.8 KB |
percpu-vm.c | -rw-r--r-- | 10.0 KB |
percpu.c | -rw-r--r-- | 65.9 KB |
pgtable-generic.c | -rw-r--r-- | 5.4 KB |
process_vm_access.c | -rw-r--r-- | 9.8 KB |
quicklist.c | -rw-r--r-- | 2.4 KB |
readahead.c | -rw-r--r-- | 15.3 KB |
rmap.c | -rw-r--r-- | 49.9 KB |
shmem.c | -rw-r--r-- | 90.9 KB |
slab.c | -rw-r--r-- | 107.4 KB |
slab.h | -rw-r--r-- | 10.5 KB |
slab_common.c | -rw-r--r-- | 30.0 KB |
slob.c | -rw-r--r-- | 16.0 KB |
slub.c | -rw-r--r-- | 133.0 KB |
sparse-vmemmap.c | -rw-r--r-- | 7.8 KB |
sparse.c | -rw-r--r-- | 20.9 KB |
swap.c | -rw-r--r-- | 26.2 KB |
swap_cgroup.c | -rw-r--r-- | 4.6 KB |
swap_state.c | -rw-r--r-- | 13.1 KB |
swapfile.c | -rw-r--r-- | 77.3 KB |
truncate.c | -rw-r--r-- | 23.9 KB |
userfaultfd.c | -rw-r--r-- | 7.2 KB |
util.c | -rw-r--r-- | 11.4 KB |
vmacache.c | -rw-r--r-- | 3.1 KB |
vmalloc.c | -rw-r--r-- | 68.0 KB |
vmpressure.c | -rw-r--r-- | 12.5 KB |
vmscan.c | -rw-r--r-- | 112.0 KB |
vmstat.c | -rw-r--r-- | 42.4 KB |
workingset.c | -rw-r--r-- | 13.6 KB |
zbud.c | -rw-r--r-- | 18.2 KB |
zpool.c | -rw-r--r-- | 10.0 KB |
zsmalloc.c | -rw-r--r-- | 48.2 KB |
zswap.c | -rw-r--r-- | 32.0 KB |
Computing file changes ...