linux/arch/powerpc/kvm
Paul Mackerras caaa4c804f KVM: PPC: Book3S HV: Fix physical address calculations
This fixes a bug in kvmppc_do_h_enter() where the physical address
for a page can be calculated incorrectly if transparent huge pages
(THP) are active.  Until THP came along, it was true that if we
encountered a large (16M) page in kvmppc_do_h_enter(), then the
associated memslot must be 16M aligned for both its guest physical
address and the userspace address, and the physical address
calculations in kvmppc_do_h_enter() assumed that.  With THP, that
is no longer true.

In the case where we are using MMU notifiers and the page size that
we get from the Linux page tables is larger than the page being mapped
by the guest, we need to fill in some low-order bits of the physical
address.  Without THP, these bits would be the same in the guest
physical address (gpa) and the host virtual address (hva).  With THP,
they can be different, and we need to use the bits from hva rather
than gpa.

In the case where we are not using MMU notifiers, the host physical
address we get from the memslot->arch.slot_phys[] array already
includes the low-order bits down to the PAGE_SIZE level, even if
we are using large pages.  Thus we can simplify the calculation in
this case to just add in the remaining bits in the case where
PAGE_SIZE is 64k and the guest is mapping a 4k page.

The same bug exists in kvmppc_book3s_hv_page_fault().  The basic fix
is to use psize (the page size from the HPTE) rather than pte_size
(the page size from the Linux PTE) when updating the HPTE low word
in r.  That means that pfn needs to be computed to PAGE_SIZE
granularity even if the Linux PTE is a huge page PTE.  That can be
arranged simply by doing the page_to_pfn() before setting page to
the head of the compound page.  If psize is less than PAGE_SIZE,
then we need to make sure we only update the bits from PAGE_SIZE
upwards, in order not to lose any sub-page offset bits in r.
On the other hand, if psize is greater than PAGE_SIZE, we need to
make sure we don't bring in non-zero low order bits in pfn, hence
we mask (pfn << PAGE_SHIFT) with ~(psize - 1).

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2013-11-18 22:36:09 +01:00
..
44x.c kvm: powerpc: book3s: Allow the HV and PR selection per virtual machine 2013-10-17 18:42:36 +02:00
44x_emulate.c kvm: powerpc: Add kvmppc_ops callback 2013-10-17 15:24:26 +02:00
44x_tlb.c kvm: powerpc: Add kvmppc_ops callback 2013-10-17 15:24:26 +02:00
44x_tlb.h
book3s.c kvm: powerpc: book3s: drop is_hv_enabled 2013-10-17 18:43:34 +02:00
book3s.h kvm: powerpc: book3s: Allow the HV and PR selection per virtual machine 2013-10-17 18:42:36 +02:00
book3s_32_mmu.c KVM: PPC: Book3S PR: Better handling of host-side read-only pages 2013-10-17 14:49:35 +02:00
book3s_32_mmu_host.c kvm: powerpc: Add kvmppc_ops callback 2013-10-17 15:24:26 +02:00
book3s_32_sr.S
book3s_64_mmu.c KVM: PPC: Book3S PR: Better handling of host-side read-only pages 2013-10-17 14:49:35 +02:00
book3s_64_mmu_host.c kvm: powerpc: book3s: pr: move PR related tracepoints to a separate header 2013-10-17 15:36:22 +02:00
book3s_64_mmu_hv.c KVM: PPC: Book3S HV: Fix physical address calculations 2013-11-18 22:36:09 +01:00
book3s_64_slb.S powerpc: Fix little endian lppaca, slb_shadow and dtl_entry 2013-08-14 15:33:35 +10:00
book3s_64_vio.c ppc: kvm: use anon_inode_getfd() with O_CLOEXEC flag 2013-08-26 13:19:56 +03:00
book3s_64_vio_hv.c kvm: powerpc: book3s: move book3s_64_vio_hv.c into the main kernel binary 2013-10-17 15:17:25 +02:00
book3s_emulate.c kvm: powerpc: book3s: Support building HV and PR KVM as module 2013-10-17 15:45:35 +02:00
book3s_exports.c kvm: powerpc: book3s: Add a new config variable CONFIG_KVM_BOOK3S_HV_POSSIBLE 2013-10-17 15:18:28 +02:00
book3s_hv.c kvm: powerpc: book3s: drop is_hv_enabled 2013-10-17 18:43:34 +02:00
book3s_hv_builtin.c powerpc/kvm: Contiguous memory allocator based RMA allocation 2013-07-08 16:20:20 +02:00
book3s_hv_cma.c powerpc/kvm: Use 256K chunk to track both RMA and hash page table allocation. 2013-07-08 16:21:13 +02:00
book3s_hv_cma.h powerpc/kvm: Use 256K chunk to track both RMA and hash page table allocation. 2013-07-08 16:21:13 +02:00
book3s_hv_interrupts.S kvm: powerpc: book3s: remove kvmppc_handler_highmem label 2013-10-17 15:15:56 +02:00
book3s_hv_ras.c KVM: PPC: Book3S HV: Fix compilation without CONFIG_PPC_POWERNV 2013-01-06 14:02:00 +01:00
book3s_hv_rm_mmu.c KVM: PPC: Book3S HV: Fix physical address calculations 2013-11-18 22:36:09 +01:00
book3s_hv_rm_xics.c KVM: PPC: Book3S HV: Add support for real mode ICP in XICS emulation 2013-04-26 20:27:32 +02:00
book3s_hv_rmhandlers.S Merge branch 'kvm-ppc-queue' of git://github.com/agraf/linux-2.6 into queue 2013-11-04 10:20:57 +02:00
book3s_interrupts.S kvm: powerpc: Add kvmppc_ops callback 2013-10-17 15:24:26 +02:00
book3s_mmu_hpte.c kvm: powerpc: book3s: pr: move PR related tracepoints to a separate header 2013-10-17 15:36:22 +02:00
book3s_paired_singles.c
book3s_pr.c Here are the 3.13 KVM changes. There was a lot of work on the PPC 2013-11-15 13:51:36 +09:00
book3s_pr_papr.c KVM: PPC: Book3S PR: Make HPT accesses and updates SMP-safe 2013-10-17 14:45:04 +02:00
book3s_rmhandlers.S KVM: PPC: Book3S: Move skip-interrupt handlers to common code 2013-10-17 14:49:35 +02:00
book3s_rtas.c kvm: powerpc: book3s: Support building HV and PR KVM as module 2013-10-17 15:45:35 +02:00
book3s_segment.S kvm: powerpc: book3s: Cleanup interrupt handling code 2013-10-17 15:26:31 +02:00
book3s_xics.c kvm: powerpc: book3s: drop is_hv_enabled 2013-10-17 18:43:34 +02:00
book3s_xics.h KVM: PPC: Book3S: Add API for in-kernel XICS emulation 2013-05-02 15:28:36 +02:00
booke.c Here are the 3.13 KVM changes. There was a lot of work on the PPC 2013-11-15 13:51:36 +09:00
booke.h kvm: powerpc: Add kvmppc_ops callback 2013-10-17 15:24:26 +02:00
booke_emulate.c KVM: PPC: BookE: Emulate mfspr on EPR 2013-01-10 13:42:30 +01:00
booke_interrupts.S KVM: PPC: booke: Added debug handler 2013-03-22 01:21:09 +01:00
bookehv_interrupts.S KVM: PPC: bookehv64: Add support for interrupt handling 2012-12-06 01:34:11 +01:00
e500.c kvm: powerpc: book3s: Allow the HV and PR selection per virtual machine 2013-10-17 18:42:36 +02:00
e500.h kvm: powerpc: allow guest control "G" attribute in mas2 2013-10-17 14:49:37 +02:00
e500_emulate.c kvm: powerpc: Add kvmppc_ops callback 2013-10-17 15:24:26 +02:00
e500_mmu.c kvm: powerpc: booke: Move booke related tracepoints to separate header 2013-10-17 15:37:16 +02:00
e500_mmu_host.c Merge branch 'kvm-ppc-queue' of git://github.com/agraf/linux-2.6 into queue 2013-11-04 10:20:57 +02:00
e500_mmu_host.h KVM: PPC: E500: Make clear_tlb_refs and clear_tlb1_bitmap static 2013-01-24 19:23:33 +01:00
e500mc.c kvm: powerpc: book3s: Allow the HV and PR selection per virtual machine 2013-10-17 18:42:36 +02:00
emulate.c kvm: powerpc: book3s: Allow the HV and PR selection per virtual machine 2013-10-17 18:42:36 +02:00
fpu.S
irq.h KVM: PPC: Book3S: Add API for in-kernel XICS emulation 2013-05-02 15:28:36 +02:00
Kconfig Here are the 3.13 KVM changes. There was a lot of work on the PPC 2013-11-15 13:51:36 +09:00
Makefile kvm: powerpc: book3s: Support building HV and PR KVM as module 2013-10-17 15:45:35 +02:00
mpic.c kvm/ppc/mpic: fix missing unlock in set_base_addr() 2013-05-02 15:28:35 +02:00
powerpc.c kvm: powerpc: book3s: drop is_hv_enabled 2013-10-17 18:43:34 +02:00
timing.c
timing.h
trace.h kvm: powerpc: booke: Move booke related tracepoints to separate header 2013-10-17 15:37:16 +02:00
trace_booke.h kvm: powerpc: booke: Move booke related tracepoints to separate header 2013-10-17 15:37:16 +02:00
trace_pr.h kvm: powerpc: book3s: pr: move PR related tracepoints to a separate header 2013-10-17 15:36:22 +02:00