Re: [PATCH v19 06/20] KVM: arm64: Refactor the vcpu_load to allow for VM specific callbacks
From: Suzuki K Poulose
Date: Tue Sep 22 2026 - 18:09:29 EST
On 22/09/2026 20:57, Jonathan Cameron wrote:
On Sun, 20 Sep 2026 22:28:31 +0100
Suzuki K Poulose <suzuki.poulose@xxxxxxx> wrote:
To keep the VCPU load/put handling cleaner with the different kinds of VM
types, we are about to introduce VM specific callbacks to do just the right
thing. In preparation for that, make some refactoring to add the change
easier.
No functional changes intended. Based on a work by Marc Zyngier.
Reviewed-by: Gavin Shan <gshan@xxxxxxxxxx>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
Trivial stuff inline + maybe one blob that should be in previous patch?
...
+
+static void vcpu_set_wfx_traps(struct kvm_vcpu *vcpu)
+{
+ if (kvm_vcpu_should_clear_twe(vcpu))
+ vcpu->arch.hcr_el2 &= ~HCR_TWE;
+ else
+ vcpu->arch.hcr_el2 |= HCR_TWE;
+
+ if (kvm_vcpu_should_clear_twi(vcpu))
+ vcpu->arch.hcr_el2 &= ~HCR_TWI;
+ else
+ vcpu->arch.hcr_el2 |= HCR_TWI;
You could use FIELD_MODIFY() for these but maybe not worth it.
...
@@ -772,7 +782,7 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
kvm_call_hyp_nvhe(__pkvm_vcpu_put);
/* __pkvm_vcpu_put implies a sync of the state */
- if (!kvm_vm_is_protected(vcpu->kvm))
+ if (kvm_vm_is_unprotected_pkvm(vcpu->kvm))
vcpu_set_flag(vcpu, PKVM_HOST_STATE_DIRTY);
Why in this patch?
I have moved it to the patch where we introduce the VM flavors, thanks!
Suzuki
}