1
0
Fork 0
alistair23-linux/arch
Paul Mackerras 93b159b466 KVM: PPC: Book3S PR: Better handling of host-side read-only pages
Currently we request write access to all pages that get mapped into the
guest, even if the guest is only loading from the page.  This reduces
the effectiveness of KSM because it means that we unshare every page we
access.  Also, we always set the changed (C) bit in the guest HPTE if
it allows writing, even for a guest load.

This fixes both these problems.  We pass an 'iswrite' flag to the
mmu.xlate() functions and to kvmppc_mmu_map_page() to indicate whether
the access is a load or a store.  The mmu.xlate() functions now only
set C for stores.  kvmppc_gfn_to_pfn() now calls gfn_to_pfn_prot()
instead of gfn_to_pfn() so that it can indicate whether we need write
access to the page, and get back a 'writable' flag to indicate whether
the page is writable or not.  If that 'writable' flag is clear, we then
make the host HPTE read-only even if the guest HPTE allowed writing.

This means that we can get a protection fault when the guest writes to a
page that it has mapped read-write but which is read-only on the host
side (perhaps due to KSM having merged the page).  Thus we now call
kvmppc_handle_pagefault() for protection faults as well as HPTE not found
faults.  In kvmppc_handle_pagefault(), if the access was allowed by the
guest HPTE and we thus need to install a new host HPTE, we then need to
remove the old host HPTE if there is one.  This is done with a new
function, kvmppc_mmu_unmap_page(), which uses kvmppc_mmu_pte_vflush() to
find and remove the old host HPTE.

Since the memslot-related functions require the KVM SRCU read lock to
be held, this adds srcu_read_lock/unlock pairs around the calls to
kvmppc_handle_pagefault().

Finally, this changes kvmppc_mmu_book3s_32_xlate_pte() to not ignore
guest HPTEs that don't permit access, and to return -EPERM for accesses
that are not permitted by the page protections.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2013-10-17 14:49:35 +02:00
..
alpha Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
arc Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
arm Updates for KVM/ARM including cpu=host and Cortex-A7 support 2013-10-16 15:30:32 +03:00
arm64 Updates for KVM/ARM including cpu=host and Cortex-A7 support 2013-10-16 15:30:32 +03:00
avr32 Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
blackfin Merge branch 'genirq' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2013-09-13 07:31:38 -07:00
c6x Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
cris Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
frv Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
h8300 Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
hexagon Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
ia64 KVM: ia64: Get rid of KVM_HPAGE defines 2013-10-14 10:12:09 +03:00
m32r Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
m68k Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
metag Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
microblaze Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
mips KVM: mips: Get rid of KVM_HPAGE defines 2013-10-14 10:12:08 +03:00
mn10300 Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
openrisc Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
parisc Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
powerpc KVM: PPC: Book3S PR: Better handling of host-side read-only pages 2013-10-17 14:49:35 +02:00
s390 KVM: s390: Get rid of KVM_HPAGE defines 2013-10-14 10:12:13 +03:00
score Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
sh Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
sparc Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
tile tile: remove stray blank space 2013-09-16 15:47:32 -04:00
um Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
unicore32 Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
x86 KVM: Drop FOLL_GET in GUP when doing async page fault 2013-10-15 13:43:37 +03:00
xtensa Xtensa patchset for v3.12 2013-09-13 10:57:48 -07:00
.gitignore
Kconfig microblaze: fix clone syscall 2013-08-13 17:57:48 -07:00