diff options
author | Paul Mackerras <paulus@samba.org> | 2012-05-03 22:32:53 -0400 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2012-05-30 05:43:10 -0400 |
commit | 32fad281c0680ed0ccade7dda85a2121cf9b1d06 (patch) | |
tree | 03d86216a00dcb2faca0ec8312e6ebcf57fa7d12 /Documentation/virtual | |
parent | 2e1ae9c07df5956ebab19144aa0da58ea37c9f69 (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.txt | 36 |
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 | |||
1930 | PTE's RPN field (ie, it needs to be shifted left by 12 to OR it | 1930 | PTE's RPN field (ie, it needs to be shifted left by 12 to OR it |
1931 | into the hash PTE second double word). | 1931 | into the hash PTE second double word). |
1932 | 1932 | ||
1933 | |||
1934 | 4.75 KVM_PPC_ALLOCATE_HTAB | ||
1935 | |||
1936 | Capability: KVM_CAP_PPC_ALLOC_HTAB | ||
1937 | Architectures: powerpc | ||
1938 | Type: vm ioctl | ||
1939 | Parameters: Pointer to u32 containing hash table order (in/out) | ||
1940 | Returns: 0 on success, -1 on error | ||
1941 | |||
1942 | This requests the host kernel to allocate an MMU hash table for a | ||
1943 | guest using the PAPR paravirtualization interface. This only does | ||
1944 | anything if the kernel is configured to use the Book 3S HV style of | ||
1945 | virtualization. Otherwise the capability doesn't exist and the ioctl | ||
1946 | returns an ENOTTY error. The rest of this description assumes Book 3S | ||
1947 | HV. | ||
1948 | |||
1949 | There must be no vcpus running when this ioctl is called; if there | ||
1950 | are, it will do nothing and return an EBUSY error. | ||
1951 | |||
1952 | The parameter is a pointer to a 32-bit unsigned integer variable | ||
1953 | containing the order (log base 2) of the desired size of the hash | ||
1954 | table, which must be between 18 and 46. On successful return from the | ||
1955 | ioctl, it will have been updated with the order of the hash table that | ||
1956 | was allocated. | ||
1957 | |||
1958 | If 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 | ||
1960 | default-sized hash table (16 MB). | ||
1961 | |||
1962 | If this ioctl is called when a hash table has already been allocated, | ||
1963 | the kernel will clear out the existing hash table (zero all HPTEs) and | ||
1964 | return the hash table order in the parameter. (If the guest is using | ||
1965 | the virtualized real-mode area (VRMA) facility, the kernel will | ||
1966 | re-create the VMRA HPTEs on the next KVM_RUN of any vcpu.) | ||
1967 | |||
1968 | |||
1933 | 5. The kvm_run structure | 1969 | 5. The kvm_run structure |
1934 | ------------------------ | 1970 | ------------------------ |
1935 | 1971 | ||