[PATCH 11/43] KVM: arm64: gic-v5: Make VPEs valid in vgic_v5_reset()
Sascha Bischoff
Sascha.Bischoff at arm.com
Mon Apr 27 09:09:47 PDT 2026
When resetting VPEs, also mark them as valid in the VM VPE Table. This
is required as it informs the IRS that a specific VPE may be made
resident, and without this the IRS will treat the VPE as invalid.
As part of this change, we also introduce a wrapper around the VPE
doorbells - vgic_v5_send_command(). This takes a struct kvm_vcpu
pointer, and the command to run, and triggers the function bound to
the command via that vcpu's doorbell. This is a convenience function
to simplify the code.
Signed-off-by: Sascha Bischoff <sascha.bischoff at arm.com>
---
arch/arm64/kvm/vgic/vgic-v5.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/arch/arm64/kvm/vgic/vgic-v5.c b/arch/arm64/kvm/vgic/vgic-v5.c
index 0649729f6b834..92bb63b6dd6bb 100644
--- a/arch/arm64/kvm/vgic/vgic-v5.c
+++ b/arch/arm64/kvm/vgic/vgic-v5.c
@@ -518,6 +518,18 @@ static int vgic_v5_irs_vpe_cr0_update(int vm_id, int vpe_id, u32 cr0)
return 0;
}
+static int vgic_v5_send_command(struct kvm_vcpu *vcpu,
+ enum gicv5_vcpu_info_cmd_type type)
+{
+ struct gicv5_cmd_info cmd_info;
+
+ if (!vcpu)
+ return -EINVAL;
+
+ cmd_info.cmd_type = type;
+ return irq_set_vcpu_affinity(vgic_v5_vpe_db(vcpu), &cmd_info);
+}
+
static int vgic_v5_db_set_vcpu_affinity(struct irq_data *data, void *vcpu_info)
{
struct vgic_v5_vm *vm = data->domain->host_data;
@@ -691,6 +703,8 @@ static void vgic_v5_teardown_per_vm_domain(struct vgic_v5_vm *vm)
void vgic_v5_reset(struct kvm_vcpu *vcpu)
{
+ int rc;
+
/*
* We always present 16-bits of ID space to the guest, irrespective of
* the host allowing more.
@@ -702,6 +716,14 @@ void vgic_v5_reset(struct kvm_vcpu *vcpu)
* CPUIF (but potentially fewer in the IRS).
*/
vcpu->arch.vgic_cpu.num_pri_bits = 5;
+
+ /* Make the VPE valid in the VPET */
+ rc = vgic_v5_send_command(vcpu, VPE_MAKE_VALID);
+ if (rc) {
+ /* We can't continue, so mark the VM as dead */
+ kvm_vm_dead(vcpu->kvm);
+ return;
+ }
}
int vgic_v5_init(struct kvm *kvm)
--
2.34.1
More information about the linux-arm-kernel
mailing list