aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/virtual
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2012-05-03 22:32:53 -0400
committerAlexander Graf <agraf@suse.de>2012-05-30 05:43:10 -0400
commit32fad281c0680ed0ccade7dda85a2121cf9b1d06 (patch)
tree03d86216a00dcb2faca0ec8312e6ebcf57fa7d12 /Documentation/virtual
parent2e1ae9c07df5956ebab19144aa0da58ea37c9f69 (diff)
KVM: PPC: Book3S HV: Make the guest hash table size configurable
This adds a new ioctl to enable userspace to control the size of the guest hashed page table (HPT) and to clear it out when resetting the guest. The KVM_PPC_ALLOCATE_HTAB ioctl is a VM ioctl and takes as its parameter a pointer to a u32 containing the desired order of the HPT (log base 2 of the size in bytes), which is updated on successful return to the actual order of the HPT which was allocated. There must be no vcpus running at the time of this ioctl. To enforce this, we now keep a count of the number of vcpus running in kvm->arch.vcpus_running. If the ioctl is called when a HPT has already been allocated, we don't reallocate the HPT but just clear it out. We first clear the kvm->arch.rma_setup_done flag, which has two effects: (a) since we hold the kvm->lock mutex, it will prevent any vcpus from starting to run until we're done, and (b) it means that the first vcpu to run after we're done will re-establish the VRMA if necessary. If userspace doesn't call this ioctl before running the first vcpu, the kernel will allocate a default-sized HPT at that point. We do it then rather than when creating the VM, as the code did previously, so that userspace has a chance to do the ioctl if it wants. When allocating the HPT, we can allocate either from the kernel page allocator, or from the preallocated pool. If userspace is asking for a different size from the preallocated HPTs, we first try to allocate using the kernel page allocator. Then we try to allocate from the preallocated pool, and then if that fails, we try allocating decreasing sizes from the kernel page allocator, down to the minimum size allowed (256kB). Note that the kernel page allocator limits allocations to 1 << CONFIG_FORCE_MAX_ZONEORDER pages, which by default corresponds to 16MB (on 64-bit powerpc, at least). Signed-off-by: Paul Mackerras <paulus@samba.org> [agraf: fix module compilation] Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'Documentation/virtual')
-rw-r--r--Documentation/virtual/kvm/api.txt36
1 files changed, 36 insertions, 0 deletions
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index 930126698a0f..310fe508d9cd 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -1930,6 +1930,42 @@ The "pte_enc" field provides a value that can OR'ed into the hash
1930PTE's RPN field (ie, it needs to be shifted left by 12 to OR it 1930PTE's RPN field (ie, it needs to be shifted left by 12 to OR it
1931into the hash PTE second double word). 1931into the hash PTE second double word).
1932 1932
1933
19344.75 KVM_PPC_ALLOCATE_HTAB
1935
1936Capability: KVM_CAP_PPC_ALLOC_HTAB
1937Architectures: powerpc
1938Type: vm ioctl
1939Parameters: Pointer to u32 containing hash table order (in/out)
1940Returns: 0 on success, -1 on error
1941
1942This requests the host kernel to allocate an MMU hash table for a
1943guest using the PAPR paravirtualization interface. This only does
1944anything if the kernel is configured to use the Book 3S HV style of
1945virtualization. Otherwise the capability doesn't exist and the ioctl
1946returns an ENOTTY error. The rest of this description assumes Book 3S
1947HV.
1948
1949There must be no vcpus running when this ioctl is called; if there
1950are, it will do nothing and return an EBUSY error.
1951
1952The parameter is a pointer to a 32-bit unsigned integer variable
1953containing the order (log base 2) of the desired size of the hash
1954table, which must be between 18 and 46. On successful return from the
1955ioctl, it will have been updated with the order of the hash table that
1956was allocated.
1957
1958If no hash table has been allocated when any vcpu is asked to run
1959(with the KVM_RUN ioctl), the host kernel will allocate a
1960default-sized hash table (16 MB).
1961
1962If this ioctl is called when a hash table has already been allocated,
1963the kernel will clear out the existing hash table (zero all HPTEs) and
1964return the hash table order in the parameter. (If the guest is using
1965the virtualized real-mode area (VRMA) facility, the kernel will
1966re-create the VMRA HPTEs on the next KVM_RUN of any vcpu.)
1967
1968
19335. The kvm_run structure 19695. The kvm_run structure
1934------------------------ 1970------------------------
1935 1971