linux/arch/powerpc/kvm
Paul Mackerras aa04b4cc5b KVM: PPC: Allocate RMAs (Real Mode Areas) at boot for use by guests
This adds infrastructure which will be needed to allow book3s_hv KVM to
run on older POWER processors, including PPC970, which don't support
the Virtual Real Mode Area (VRMA) facility, but only the Real Mode
Offset (RMO) facility.  These processors require a physically
contiguous, aligned area of memory for each guest.  When the guest does
an access in real mode (MMU off), the address is compared against a
limit value, and if it is lower, the address is ORed with an offset
value (from the Real Mode Offset Register (RMOR)) and the result becomes
the real address for the access.  The size of the RMA has to be one of
a set of supported values, which usually includes 64MB, 128MB, 256MB
and some larger powers of 2.

Since we are unlikely to be able to allocate 64MB or more of physically
contiguous memory after the kernel has been running for a while, we
allocate a pool of RMAs at boot time using the bootmem allocator.  The
size and number of the RMAs can be set using the kvm_rma_size=xx and
kvm_rma_count=xx kernel command line options.

KVM exports a new capability, KVM_CAP_PPC_RMA, to signal the availability
of the pool of preallocated RMAs.  The capability value is 1 if the
processor can use an RMA but doesn't require one (because it supports
the VRMA facility), or 2 if the processor requires an RMA for each guest.

This adds a new ioctl, KVM_ALLOCATE_RMA, which allocates an RMA from the
pool and returns a file descriptor which can be used to map the RMA.  It
also returns the size of the RMA in the argument structure.

Having an RMA means we will get multiple KMV_SET_USER_MEMORY_REGION
ioctl calls from userspace.  To cope with this, we now preallocate the
kvm->arch.ram_pginfo array when the VM is created with a size sufficient
for up to 64GB of guest memory.  Subsequently we will get rid of this
array and use memory associated with each memslot instead.

This moves most of the code that translates the user addresses into
host pfns (page frame numbers) out of kvmppc_prepare_vrma up one level
to kvmppc_core_prepare_memory_region.  Also, instead of having to look
up the VMA for each page in order to check the page size, we now check
that the pages we get are compound pages of 16MB.  However, if we are
adding memory that is mapped to an RMA, we don't bother with calling
get_user_pages_fast and instead just offset from the base pfn for the
RMA.

Typically the RMA gets added after vcpus are created, which makes it
inconvenient to have the LPCR (logical partition control register) value
in the vcpu->arch struct, since the LPCR controls whether the processor
uses RMA or VRMA for the guest.  This moves the LPCR value into the
kvm->arch struct and arranges for the MER (mediated external request)
bit, which is the only bit that varies between vcpus, to be set in
assembly code when going into the guest if there is a pending external
interrupt request.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-07-12 13:16:57 +03:00
..
44x_emulate.c KVM: PPC: fix exit accounting for SPRs, tlbwe, tlbsx 2011-05-22 08:47:47 -04:00
44x_tlb.c KVM: PPC: e500: Add shadow PID support 2011-07-12 13:16:39 +03:00
44x_tlb.h KVM: ppc: rename 44x MMU functions used in booke.c 2009-03-24 11:02:56 +02:00
44x.c KVM: PPC: booke: add sregs support 2011-05-22 08:47:53 -04:00
book3s_32_mmu_host.c KVM: PPC: Implement correct SID mapping on Book3s_32 2010-10-24 10:52:15 +02:00
book3s_32_mmu.c KVM: PPC: Put segment registers in shared page 2010-10-24 10:52:11 +02:00
book3s_32_sr.S KVM: PPC: Add SR swapping code 2010-05-17 12:18:17 +03:00
book3s_64_mmu_host.c KVM: PPC: Implement correct SID mapping on Book3s_32 2010-10-24 10:52:15 +02:00
book3s_64_mmu_hv.c KVM: PPC: Allocate RMAs (Real Mode Areas) at boot for use by guests 2011-07-12 13:16:57 +03:00
book3s_64_mmu.c KVM: PPC: Move fields between struct kvm_vcpu_arch and kvmppc_vcpu_book3s 2011-07-12 13:16:46 +03:00
book3s_64_slb.S KVM: PPC: Make SLB switching code the new segment framework 2010-05-17 12:18:38 +03:00
book3s_64_vio_hv.c KVM: PPC: Accelerate H_PUT_TCE by implementing it in real mode 2011-07-12 13:16:56 +03:00
book3s_emulate.c KVM: PPC: Move BAT handling code into spr handler 2010-10-24 10:52:10 +02:00
book3s_exports.c KVM: PPC: Add support for Book3S processors in hypervisor mode 2011-07-12 13:16:54 +03:00
book3s_hv_builtin.c KVM: PPC: Allocate RMAs (Real Mode Areas) at boot for use by guests 2011-07-12 13:16:57 +03:00
book3s_hv_interrupts.S KVM: PPC: Add support for Book3S processors in hypervisor mode 2011-07-12 13:16:54 +03:00
book3s_hv_rm_mmu.c KVM: PPC: Handle some PAPR hcalls in the kernel 2011-07-12 13:16:55 +03:00
book3s_hv_rmhandlers.S KVM: PPC: Allocate RMAs (Real Mode Areas) at boot for use by guests 2011-07-12 13:16:57 +03:00
book3s_hv.c KVM: PPC: Allocate RMAs (Real Mode Areas) at boot for use by guests 2011-07-12 13:16:57 +03:00
book3s_interrupts.S KVM: PPC: Split host-state fields out of kvmppc_book3s_shadow_vcpu 2011-07-12 13:16:53 +03:00
book3s_mmu_hpte.c KVM: PPC: Move fields between struct kvm_vcpu_arch and kvmppc_vcpu_book3s 2011-07-12 13:16:46 +03:00
book3s_paired_singles.c Merge branch 'kvm-updates/2.6.37' of git://git.kernel.org/pub/scm/virt/kvm/kvm 2010-10-24 12:47:25 -07:00
book3s_pr.c KVM: PPC: Move guest enter/exit down into subarch-specific code 2011-07-12 13:16:51 +03:00
book3s_rmhandlers.S KVM: PPC: Split host-state fields out of kvmppc_book3s_shadow_vcpu 2011-07-12 13:16:53 +03:00
book3s_segment.S KVM: PPC: Add support for Book3S processors in hypervisor mode 2011-07-12 13:16:54 +03:00
book3s.c KVM: PPC: Deliver program interrupts right away instead of queueing them 2011-07-12 13:16:49 +03:00
booke_emulate.c KVM: PPC: Convert SRR0 and SRR1 to shared page 2010-10-24 10:50:45 +02:00
booke_interrupts.S KVM: PPC: e500: Add shadow PID support 2011-07-12 13:16:39 +03:00
booke.c KVM: PPC: Move guest enter/exit down into subarch-specific code 2011-07-12 13:16:51 +03:00
booke.h KVM: PPC: e500: Add shadow PID support 2011-07-12 13:16:39 +03:00
e500_emulate.c KVM: PPC: e500: Add shadow PID support 2011-07-12 13:16:39 +03:00
e500_tlb.c KVM: PPC: e500: Don't search over the entire TLB0. 2011-07-12 13:16:40 +03:00
e500_tlb.h KVM: PPC: e500: Add shadow PID support 2011-07-12 13:16:39 +03:00
e500.c KVM: PPC: e500: Save/restore SPE state 2011-07-12 13:16:32 +03:00
emulate.c KVM: PPC: booke: add sregs support 2011-05-22 08:47:53 -04:00
fpu.S powerpc: Remove fpscr use from [kvm_]cvt_{fd,df} 2010-09-02 14:07:32 +10:00
Kconfig KVM: PPC: Add support for Book3S processors in hypervisor mode 2011-07-12 13:16:54 +03:00
Makefile KVM: PPC: Allocate RMAs (Real Mode Areas) at boot for use by guests 2011-07-12 13:16:57 +03:00
powerpc.c KVM: PPC: Allocate RMAs (Real Mode Areas) at boot for use by guests 2011-07-12 13:16:57 +03:00
timing.c KVM: PPC: fix partial application of "exit timing in ticks" 2011-07-12 13:16:28 +03:00
timing.h KVM: powerpc: Fix BUILD_BUG_ON condition 2009-12-03 09:32:22 +02:00
trace.h KVM: PPC: Add support for Book3S processors in hypervisor mode 2011-07-12 13:16:54 +03:00