aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/virtual/kvm
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2011-06-28 20:25:44 -0400
committerAvi Kivity <avi@redhat.com>2011-07-12 06:16:57 -0400
commitaa04b4cc5be64b4fb9ef4e0fdf2418e2f4737fb2 (patch)
tree97a3ff14e43424e28a27e0f3be088649818c1b76 /Documentation/virtual/kvm
parent371fefd6f2dc46668e00871930dde613b88d4bde (diff)
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>
Diffstat (limited to 'Documentation/virtual/kvm')
-rw-r--r--Documentation/virtual/kvm/api.txt32
1 files changed, 32 insertions, 0 deletions
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index 681871311d3e..b0e4b9cd6a66 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -1398,6 +1398,38 @@ the entries written by kernel-handled H_PUT_TCE calls, and also lets
1398userspace update the TCE table directly which is useful in some 1398userspace update the TCE table directly which is useful in some
1399circumstances. 1399circumstances.
1400 1400
14014.63 KVM_ALLOCATE_RMA
1402
1403Capability: KVM_CAP_PPC_RMA
1404Architectures: powerpc
1405Type: vm ioctl
1406Parameters: struct kvm_allocate_rma (out)
1407Returns: file descriptor for mapping the allocated RMA
1408
1409This allocates a Real Mode Area (RMA) from the pool allocated at boot
1410time by the kernel. An RMA is a physically-contiguous, aligned region
1411of memory used on older POWER processors to provide the memory which
1412will be accessed by real-mode (MMU off) accesses in a KVM guest.
1413POWER processors support a set of sizes for the RMA that usually
1414includes 64MB, 128MB, 256MB and some larger powers of two.
1415
1416/* for KVM_ALLOCATE_RMA */
1417struct kvm_allocate_rma {
1418 __u64 rma_size;
1419};
1420
1421The return value is a file descriptor which can be passed to mmap(2)
1422to map the allocated RMA into userspace. The mapped area can then be
1423passed to the KVM_SET_USER_MEMORY_REGION ioctl to establish it as the
1424RMA for a virtual machine. The size of the RMA in bytes (which is
1425fixed at host kernel boot time) is returned in the rma_size field of
1426the argument structure.
1427
1428The KVM_CAP_PPC_RMA capability is 1 or 2 if the KVM_ALLOCATE_RMA ioctl
1429is supported; 2 if the processor requires all virtual machines to have
1430an RMA, or 1 if the processor can use an RMA but doesn't require it,
1431because it supports the Virtual RMA (VRMA) facility.
1432
14015. The kvm_run structure 14335. The kvm_run structure
1402 1434
1403Application code obtains a pointer to the kvm_run structure by 1435Application code obtains a pointer to the kvm_run structure by