aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2016-12-20 00:48:58 -0500
committerPaul Mackerras <paulus@ozlabs.org>2017-01-31 05:58:59 -0500
commitef1ead0c3b1dfb43d33caa4f50c8d214f86b6bc8 (patch)
tree81528353c21434ac350c476faff6661c904ce7e9
parentccc4df4e2c3825919456c13b153d2a67bbf328dc (diff)
KVM: PPC: Book3S HV: HPT resizing documentation and reserved numbers
This adds a new powerpc-specific KVM_CAP_SPAPR_RESIZE_HPT capability to advertise whether KVM is capable of handling the PAPR extensions for resizing the hashed page table during guest runtime. It also adds definitions for two new VM ioctl()s to implement this extension, and documentation of the same. Note that, HPT resizing is already possible with KVM PR without kernel modification, since the HPT is managed within userspace (qemu). The capability defined here will only be set where an in-kernel implementation of resizing is necessary, i.e. for KVM HV. To determine if the userspace resize implementation can be used, it's necessary to check KVM_CAP_PPC_ALLOC_HTAB. Unfortunately older kernels incorrectly set KVM_CAP_PPC_ALLOC_HTAB even with KVM PR. If userspace it want to support resizing with KVM PR on such kernels, it will need a workaround. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
-rw-r--r--Documentation/virtual/kvm/api.txt95
-rw-r--r--include/uapi/linux/kvm.h11
2 files changed, 106 insertions, 0 deletions
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index aca994a90355..64f217af0416 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -3266,6 +3266,101 @@ The ap_encodings gives the supported page sizes and their AP field
3266encodings, encoded with the AP value in the top 3 bits and the log 3266encodings, encoded with the AP value in the top 3 bits and the log
3267base 2 of the page size in the bottom 6 bits. 3267base 2 of the page size in the bottom 6 bits.
3268 3268
32694.102 KVM_PPC_RESIZE_HPT_PREPARE
3270
3271Capability: KVM_CAP_SPAPR_RESIZE_HPT
3272Architectures: powerpc
3273Type: vm ioctl
3274Parameters: struct kvm_ppc_resize_hpt (in)
3275Returns: 0 on successful completion,
3276 >0 if a new HPT is being prepared, the value is an estimated
3277 number of milliseconds until preparation is complete
3278 -EFAULT if struct kvm_reinject_control cannot be read,
3279 -EINVAL if the supplied shift or flags are invalid
3280 -ENOMEM if unable to allocate the new HPT
3281 -ENOSPC if there was a hash collision when moving existing
3282 HPT entries to the new HPT
3283 -EIO on other error conditions
3284
3285Used to implement the PAPR extension for runtime resizing of a guest's
3286Hashed Page Table (HPT). Specifically this starts, stops or monitors
3287the preparation of a new potential HPT for the guest, essentially
3288implementing the H_RESIZE_HPT_PREPARE hypercall.
3289
3290If called with shift > 0 when there is no pending HPT for the guest,
3291this begins preparation of a new pending HPT of size 2^(shift) bytes.
3292It then returns a positive integer with the estimated number of
3293milliseconds until preparation is complete.
3294
3295If called when there is a pending HPT whose size does not match that
3296requested in the parameters, discards the existing pending HPT and
3297creates a new one as above.
3298
3299If called when there is a pending HPT of the size requested, will:
3300 * If preparation of the pending HPT is already complete, return 0
3301 * If preparation of the pending HPT has failed, return an error
3302 code, then discard the pending HPT.
3303 * If preparation of the pending HPT is still in progress, return an
3304 estimated number of milliseconds until preparation is complete.
3305
3306If called with shift == 0, discards any currently pending HPT and
3307returns 0 (i.e. cancels any in-progress preparation).
3308
3309flags is reserved for future expansion, currently setting any bits in
3310flags will result in an -EINVAL.
3311
3312Normally this will be called repeatedly with the same parameters until
3313it returns <= 0. The first call will initiate preparation, subsequent
3314ones will monitor preparation until it completes or fails.
3315
3316struct kvm_ppc_resize_hpt {
3317 __u64 flags;
3318 __u32 shift;
3319 __u32 pad;
3320};
3321
33224.103 KVM_PPC_RESIZE_HPT_COMMIT
3323
3324Capability: KVM_CAP_SPAPR_RESIZE_HPT
3325Architectures: powerpc
3326Type: vm ioctl
3327Parameters: struct kvm_ppc_resize_hpt (in)
3328Returns: 0 on successful completion,
3329 -EFAULT if struct kvm_reinject_control cannot be read,
3330 -EINVAL if the supplied shift or flags are invalid
3331 -ENXIO is there is no pending HPT, or the pending HPT doesn't
3332 have the requested size
3333 -EBUSY if the pending HPT is not fully prepared
3334 -ENOSPC if there was a hash collision when moving existing
3335 HPT entries to the new HPT
3336 -EIO on other error conditions
3337
3338Used to implement the PAPR extension for runtime resizing of a guest's
3339Hashed Page Table (HPT). Specifically this requests that the guest be
3340transferred to working with the new HPT, essentially implementing the
3341H_RESIZE_HPT_COMMIT hypercall.
3342
3343This should only be called after KVM_PPC_RESIZE_HPT_PREPARE has
3344returned 0 with the same parameters. In other cases
3345KVM_PPC_RESIZE_HPT_COMMIT will return an error (usually -ENXIO or
3346-EBUSY, though others may be possible if the preparation was started,
3347but failed).
3348
3349This will have undefined effects on the guest if it has not already
3350placed itself in a quiescent state where no vcpu will make MMU enabled
3351memory accesses.
3352
3353On succsful completion, the pending HPT will become the guest's active
3354HPT and the previous HPT will be discarded.
3355
3356On failure, the guest will still be operating on its previous HPT.
3357
3358struct kvm_ppc_resize_hpt {
3359 __u64 flags;
3360 __u32 shift;
3361 __u32 pad;
3362};
3363
32695. The kvm_run structure 33645. The kvm_run structure
3270------------------------ 3365------------------------
3271 3366
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index e0035808c814..7964b970b9ad 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -685,6 +685,13 @@ struct kvm_ppc_smmu_info {
685 struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ]; 685 struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
686}; 686};
687 687
688/* for KVM_PPC_RESIZE_HPT_{PREPARE,COMMIT} */
689struct kvm_ppc_resize_hpt {
690 __u64 flags;
691 __u32 shift;
692 __u32 pad;
693};
694
688#define KVMIO 0xAE 695#define KVMIO 0xAE
689 696
690/* machine type bits, to be used as argument to KVM_CREATE_VM */ 697/* machine type bits, to be used as argument to KVM_CREATE_VM */
@@ -871,6 +878,7 @@ struct kvm_ppc_smmu_info {
871#define KVM_CAP_S390_USER_INSTR0 130 878#define KVM_CAP_S390_USER_INSTR0 130
872#define KVM_CAP_MSI_DEVID 131 879#define KVM_CAP_MSI_DEVID 131
873#define KVM_CAP_PPC_HTM 132 880#define KVM_CAP_PPC_HTM 132
881#define KVM_CAP_SPAPR_RESIZE_HPT 133
874#define KVM_CAP_PPC_MMU_RADIX 134 882#define KVM_CAP_PPC_MMU_RADIX 134
875#define KVM_CAP_PPC_MMU_HASH_V3 135 883#define KVM_CAP_PPC_MMU_HASH_V3 135
876 884
@@ -1189,6 +1197,9 @@ struct kvm_s390_ucas_mapping {
1189#define KVM_ARM_SET_DEVICE_ADDR _IOW(KVMIO, 0xab, struct kvm_arm_device_addr) 1197#define KVM_ARM_SET_DEVICE_ADDR _IOW(KVMIO, 0xab, struct kvm_arm_device_addr)
1190/* Available with KVM_CAP_PPC_RTAS */ 1198/* Available with KVM_CAP_PPC_RTAS */
1191#define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO, 0xac, struct kvm_rtas_token_args) 1199#define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO, 0xac, struct kvm_rtas_token_args)
1200/* Available with KVM_CAP_SPAPR_RESIZE_HPT */
1201#define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt)
1202#define KVM_PPC_RESIZE_HPT_COMMIT _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt)
1192/* Available with KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 */ 1203/* Available with KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 */
1193#define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg) 1204#define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg)
1194/* Available with KVM_CAP_PPC_RADIX_MMU */ 1205/* Available with KVM_CAP_PPC_RADIX_MMU */