]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: Rename pkvm.enabled to pkvm.is_protected
authorFuad Tabba <tabba@google.com>
Tue, 9 Sep 2025 07:24:29 +0000 (08:24 +0100)
committerMarc Zyngier <maz@kernel.org>
Mon, 15 Sep 2025 09:46:55 +0000 (10:46 +0100)
The 'pkvm.enabled' field in struct kvm_protected_vm is confusingly
named. Its purpose is to indicate whether a VM is a _protected_ VM under
pKVM, and not whether the VM itself is enabled or running.

For a non-protected VM, the VM can be fully active and running, yet this
field would be false. This ambiguity can lead to incorrect assumptions
about the VM's operational state and makes the code harder to reason
about.

Rename the field to 'is_protected' to make it unambiguous that the flag
tracks the protected status of the VM.

No functional change intended.

Reviewed-by: Kunwu Chan <kunwu.chan@linux.dev>
Signed-off-by: Fuad Tabba <tabba@google.com>
Reviewed-by: Kunwu Chan <chentao@kylinos.cn>
Tested-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/include/asm/kvm_host.h
arch/arm64/kvm/hyp/nvhe/pkvm.c

index 2f2394cce24edf7e1002d3c68b087cf5d9ede41a..a4289c2f13f53dbd7400de10234b4fc2981c1e93 100644 (file)
@@ -252,7 +252,7 @@ struct kvm_protected_vm {
        pkvm_handle_t handle;
        struct kvm_hyp_memcache teardown_mc;
        struct kvm_hyp_memcache stage2_teardown_mc;
-       bool enabled;
+       bool is_protected;
 };
 
 struct kvm_mpidr_data {
@@ -1548,7 +1548,7 @@ struct kvm *kvm_arch_alloc_vm(void);
 
 #define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLBS_RANGE
 
-#define kvm_vm_is_protected(kvm)       (is_protected_kvm_enabled() && (kvm)->arch.pkvm.enabled)
+#define kvm_vm_is_protected(kvm)       (is_protected_kvm_enabled() && (kvm)->arch.pkvm.is_protected)
 
 #define vcpu_is_protected(vcpu)                kvm_vm_is_protected((vcpu)->kvm)
 
index 338505cb0171ba13937483436cff68786f1afb7f..6198c1d27b5bd73c1a592e867130446c7add9254 100644 (file)
@@ -406,7 +406,7 @@ static void init_pkvm_hyp_vm(struct kvm *host_kvm, struct pkvm_hyp_vm *hyp_vm,
        hyp_vm->host_kvm = host_kvm;
        hyp_vm->kvm.created_vcpus = nr_vcpus;
        hyp_vm->kvm.arch.mmu.vtcr = host_mmu.arch.mmu.vtcr;
-       hyp_vm->kvm.arch.pkvm.enabled = READ_ONCE(host_kvm->arch.pkvm.enabled);
+       hyp_vm->kvm.arch.pkvm.is_protected = READ_ONCE(host_kvm->arch.pkvm.is_protected);
        hyp_vm->kvm.arch.flags = 0;
        pkvm_init_features_from_host(hyp_vm, host_kvm);
 }