Re: [PATCH v21 10/23] KVM: arm64: Add VM specific callback for S2 MMU operations

From: Suzuki K Poulose

Date: Sat Oct 03 2026 - 11:30:32 EST


On 03/10/2026 10:01, Marc Zyngier wrote:
On Thu, 01 Oct 2026 22:06:50 +0100,
Suzuki K Poulose <suzuki.poulose@xxxxxxx> wrote:

Add VM type specific S2 MMU operation backends which can be initialized per
VM flavor, to keep the handling cleaner.

Reviewed-by: Jonathan Cameron <jonathan.cameron@xxxxxxxxxxxxxxxx>
Tested-by: Gavin Shan <gshan@xxxxxxxxxx>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
---
Changes since v19:
- Add a blank line in kvm_arch_flush_remote_tlbs()


struct kvm_s2_mmu {
struct kvm_vmid vmid;
@@ -332,6 +345,8 @@ struct kvm_arch {
*/
u64 fgu[__NR_FGT_GROUP_IDS__];
+ const struct kvm_vm_s2_ops *vm_s2_ops;
+

If you're touching this patch, can you please move this pointer next
to the vcpu_ops pointer?

Sure, I will do that.

+
+static const struct kvm_vm_s2_ops protected_pkvm_vm_s2_ops = {
+ .vm_flush_remote_tlbs = pkvm_flush_remote_tlbs,
+ .vm_flush_remote_tlbs_range = pkvm_flush_remote_tlbs_range,
+ /*
+ * Not supported for Protected VMs under pKVM
+ * .vm_age_gfn
+ * .vm_test_age_gfn
+ * .vm_stage2_unmap_range
+ */

I really think we should have *something* here that returns
"unsupported", and avoid NULL-checks in the dispatchers.

Ack


+};
+
+static const struct kvm_vm_s2_ops pkvm_vm_s2_ops = {
+ .vm_flush_remote_tlbs = pkvm_flush_remote_tlbs,
+ .vm_flush_remote_tlbs_range = pkvm_flush_remote_tlbs_range,
+ .vm_age_gfn = kvm_vm_age_gfn,
+ .vm_test_age_gfn = kvm_vm_test_age_gfn,
+ .vm_stage2_unmap_range = kvm_vm_stage2_unmap_range,

and since we have this: can we get rid of the KVM_PGT_FN() hack?

Ack, I will give it a go.


+#define KVM_VM_S2_OPS(flavor, ops) \
+ [flavor] = ops
+static const struct kvm_vm_s2_ops *arm64_vm_s2_ops[] = {
+ KVM_VM_S2_OPS(VM_VHE, &kvm_default_vm_s2_ops),
+ KVM_VM_S2_OPS(VM_NVHE, &kvm_default_vm_s2_ops),
+ KVM_VM_S2_OPS(VM_PKVM, &pkvm_vm_s2_ops),
+ KVM_VM_S2_OPS(VM_PROTECTED_PKVM, &protected_pkvm_vm_s2_ops),

nit: move the '&' into the macro.

Ack.

Suzuki