Skip to content

Commit f55ce5a

Browse files
ankita-nvoupton
authored andcommitted
KVM: arm64: Expose new KVM cap for cacheable PFNMAP
Introduce a new KVM capability to expose to the userspace whether cacheable mapping of PFNMAP is supported. The ability to safely do the cacheable mapping of PFNMAP is contingent on S2FWB and ARM64_HAS_CACHE_DIC. S2FWB allows KVM to avoid flushing the D cache, ARM64_HAS_CACHE_DIC allows KVM to avoid flushing the icache and turns icache_inval_pou() into a NOP. The cap would be false if those requirements are missing and is checked by making use of kvm_arch_supports_cacheable_pfnmap. This capability would allow userspace to discover the support. It could for instance be used by userspace to prevent live-migration across FWB and non-FWB hosts. CC: Catalin Marinas <[email protected]> CC: Jason Gunthorpe <[email protected]> CC: Oliver Upton <[email protected]> CC: David Hildenbrand <[email protected]> Suggested-by: Marc Zyngier <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Tested-by: Donald Dutile <[email protected]> Signed-off-by: Ankit Agrawal <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 0c67288 commit f55ce5a

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

Documentation/virt/kvm/api.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8585,7 +8585,7 @@ ENOSYS for the others.
85858585
When enabled, KVM will exit to userspace with KVM_EXIT_SYSTEM_EVENT of
85868586
type KVM_SYSTEM_EVENT_SUSPEND to process the guest suspend request.
85878587

8588-
7.37 KVM_CAP_ARM_WRITABLE_IMP_ID_REGS
8588+
7.42 KVM_CAP_ARM_WRITABLE_IMP_ID_REGS
85898589
-------------------------------------
85908590

85918591
:Architectures: arm64
@@ -8614,6 +8614,17 @@ given VM.
86148614
When this capability is enabled, KVM resets the VCPU when setting
86158615
MP_STATE_INIT_RECEIVED through IOCTL. The original MP_STATE is preserved.
86168616

8617+
7.43 KVM_CAP_ARM_CACHEABLE_PFNMAP_SUPPORTED
8618+
-------------------------------------------
8619+
8620+
:Architectures: arm64
8621+
:Target: VM
8622+
:Parameters: None
8623+
8624+
This capability indicate to the userspace whether a PFNMAP memory region
8625+
can be safely mapped as cacheable. This relies on the presence of
8626+
force write back (FWB) feature support on the hardware.
8627+
86178628
8. Other capabilities.
86188629
======================
86198630

arch/arm64/kvm/arm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,13 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
408408
case KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES:
409409
r = BIT(0);
410410
break;
411+
case KVM_CAP_ARM_CACHEABLE_PFNMAP_SUPPORTED:
412+
if (!kvm)
413+
r = -EINVAL;
414+
else
415+
r = kvm_supports_cacheable_pfnmap();
416+
break;
417+
411418
default:
412419
r = 0;
413420
}

include/uapi/linux/kvm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,7 @@ struct kvm_enable_cap {
956956
#define KVM_CAP_ARM_EL2 240
957957
#define KVM_CAP_ARM_EL2_E2H0 241
958958
#define KVM_CAP_RISCV_MP_STATE_RESET 242
959+
#define KVM_CAP_ARM_CACHEABLE_PFNMAP_SUPPORTED 243
959960

960961
struct kvm_irq_routing_irqchip {
961962
__u32 irqchip;

0 commit comments

Comments
 (0)