|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v1 08/28] x86/hvm: avic: add AVIC_INCOMP_IPI VMEXIT handler
On 05.11.2026 02:33, dmukhin@xxxxxxxx wrote:
> @@ -235,6 +236,120 @@ void svm_avic_vmcb_destroy(struct vcpu *v)
> vmcb->avic_vapic_bar = 0;
> }
>
> +/*
> + * Handle the AVIC_INCOMP_IPI #VMEXIT when AVIC is enabled.
> + *
> + * The hardware generates this fault when an IPI could not be delivered to
> + * all targeted guest virtual processors because at least one guest virtual
> + * processor was not allocated to a physical core at the time.
> + */
> +void svm_avic_vmexit_incomp_ipi(struct cpu_user_regs *regs)
> +{
> + struct vcpu *v = current;
> + struct domain *d = v->domain;
> + struct svm_vcpu *sv = &v->arch.hvm.svm;
> + const struct vmcb_struct *vmcb = sv->vmcb;
> + uint32_t icrh = vmcb->exitinfo1 >> 32;
> + uint32_t icrl = vmcb->exitinfo1;
> + uint32_t id = vmcb->exitinfo2 >> 32;
> + uint32_t index = vmcb->exitinfo2 & 0x1FFU;
0x1ffU please, to have the U better stand out.
> + if ( id >= AVIC_IPI_FAILURE_MAX )
> + {
> + domain_crash(
> + d, "%pv: AVIC: Unknown IPI interception (exitinfo1=%#"PRIx64"
> exitinfo2=%#"PRIx64")\n",
> + v, vmcb->exitinfo1, vmcb->exitinfo2);
> + return;
> + }
Why can this code not live in the default: case further down?
> + BUG_ON(sv->avic_physical_id == NULL);
> +
> + switch ( id )
> + {
> + case AVIC_IPI_FAILURE_INVALID_INT_TYPE:
> + /*
> + * AVIC hardware handles the delivery of IPIs when the specified
> + * Message Type is Fixed (also known as fixed delivery mode) and the
> + * Trigger Mode is edge-triggered. The hardware also supports self
> and
> + * broadcast delivery modes specified via the Destination
> + * Shorthand(DSH) field of the ICRL. Logical and physical APIC ID
> + * formats are supported. All other IPI types cause a #VMEXIT, which
> + * needs to emulated.
> + */
> + gprintk(XENLOG_ERR,
> + "%pv: AVIC: Invalid IPI type (icr=%#08x:%08x, idx=%u)"
> + " avic_physical_id=%#"PRIx64"\n",
> + v, icrh, icrl, index, ACCESS_ONCE(*sv->avic_physical_id));
> +
> + vlapic_reg_write(v, APIC_ICR2, icrh);
> + vlapic_reg_write(v, APIC_ICR, icrl);
Is this legitimate in x2APIC mode? Also, if this is what you introduce
vlapic_reg_write() for, wouldn't this better be a dedicated ICR writing
helper anyway?
> --- a/xen/arch/x86/hvm/svm/vmcb.h
> +++ b/xen/arch/x86/hvm/svm/vmcb.h
> @@ -291,6 +291,13 @@ enum VMEXIT_EXITCODE
> VMEXIT_BUS_LOCK = 165, /* 0xa5 */
> /* Remember to also update VMEXIT_NPF_PERFC! */
> VMEXIT_NPF = 1024, /* 0x400, nested paging fault */
> +
> + /*
> + * AMD64 Architecture Programmer's Manual Volume 2: System Programming
> + * Table 15-22. Guest vAPIC Register Access Behavior
> + */
> + VMEXIT_AVIC_INCOMP_IPI = 1025, /* 0x401 */
> +
> /* Remember to also update SVM_PERF_EXIT_REASON_SIZE! */
> VMEXIT_INVALID = -1
Please pay attention to the pre-existing comments here.
> --- a/xen/arch/x86/include/asm/hvm/svm-types.h
> +++ b/xen/arch/x86/include/asm/hvm/svm-types.h
> @@ -25,6 +25,16 @@ struct svm_domain {
> uint64_t *avic_physical_id_table;
> };
>
> +/* AVIC_INCOMP_IPI #VMEXIT reason. */
> +enum avic_ipi_failure_cause {
> + AVIC_IPI_FAILURE_INVALID_INT_TYPE = 0,
> + AVIC_IPI_FAILURE_TARGET_NOT_RUNNING = 1,
> + AVIC_IPI_FAILURE_INVALID_TARGET = 2,
> + AVIC_IPI_FAILURE_INVALID_BACKING_PAGE = 3,
> + AVIC_IPI_FAILURE_INVALID_IPI_VECTOR = 4,
> + AVIC_IPI_FAILURE_MAX,
As per the comment towards the top, this last one shouldn't be needed
(or else it's mis-named). I also don't see why for the others explicit
values would need assigning.
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |