From nobody Tue Feb 10 01:43:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=julian.vetter@vates.tech; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1770636892; cv=none; d=zohomail.com; s=zohoarc; b=NFz8LfWgeGvSG8ZgENcoJkyxVHKm7OuWlPMBfSgXF+h23GIMJ4eZkVN5wr8fmhz6L9DEuIjLpzz8kG66eJ00unrQkoSuYKyOw6X3zascpWCQcJohi1DrWSqjIzThhIvVyIiwSSNjexUNQTO3miDgRxyfHyxirqsFz91Sk+I6ybY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770636892; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=z+5bID8B4TwdHcS855x2tQYEC5yCWNBE+4Tk0xW2DB0=; b=jQMEjBeEKaN2V8Z99uHS7LL0q4y+qHYaIVotoG5SRY/0KEm0IwTbFPchymjF+EAsZnDDfqF3VTC4Ys0Ltv+lC582Gj6R2xA/7TUU85sB/IlaBNQtmV56Jv4kXlpxQ+BzKLbvZPLoh2C84vvhMDswrYaJXppj+HdeLwaBbE9R9AY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=julian.vetter@vates.tech; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1770636892625276.54620331114825; Mon, 9 Feb 2026 03:34:52 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1225264.1531728 (Exim 4.92) (envelope-from ) id 1vpPX9-0007nq-Ic; Mon, 09 Feb 2026 11:34:27 +0000 Received: by outflank-mailman (output) from mailman id 1225264.1531728; Mon, 09 Feb 2026 11:34:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vpPX9-0007nj-FM; Mon, 09 Feb 2026 11:34:27 +0000 Received: by outflank-mailman (input) for mailman id 1225264; Mon, 09 Feb 2026 11:34:25 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vpPX7-0007nc-P7 for xen-devel@lists.xenproject.org; Mon, 09 Feb 2026 11:34:25 +0000 Received: from mail177-22.suw61.mandrillapp.com (mail177-22.suw61.mandrillapp.com [198.2.177.22]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4592c962-05ab-11f1-9ccf-f158ae23cfc8; Mon, 09 Feb 2026 12:34:19 +0100 (CET) Received: from pmta14.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail177-22.suw61.mandrillapp.com (Mailchimp) with ESMTP id 4f8jJp3Y8czGlspFT for ; Mon, 9 Feb 2026 11:34:18 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id bdcf0703707f407d99f9ec1d35fae8ed; Mon, 09 Feb 2026 11:34:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4592c962-05ab-11f1-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1770636858; x=1770906858; bh=z+5bID8B4TwdHcS855x2tQYEC5yCWNBE+4Tk0xW2DB0=; h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version: Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From; b=GsUGkxNoEbItShzNz3FNY3wdo3I3QGhdDrVe7uIxiPkydzK/5cQIMWYR3UJMYYnQN dJtd2GN1SQaN0h2HuMZNqYKvqUTHgjwRLGrLduznCJruqgCzfkcRQCxbA2HPMY/h3w +5mcoA7cCxaIa9zJvbB4tww/r05lLFNFP6AN4Av3sdL+1bCWrgDRZplmW2CvBqQaXH dyBm49VCBBNJlrJs+/Aa96chqZoczbVlz2NSwsxj5ZJEhl3LQdQCt+iIh5QsWBeGPZ IwajwqP+7KIaXlZkVfs6Nbyj4BoLmZUF2Fn4ykgxJ6YfxxF5cTshFsUp6d/uTabG9j dYzhwhtjpKK+g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1770636858; x=1770897358; i=julian.vetter@vates.tech; bh=z+5bID8B4TwdHcS855x2tQYEC5yCWNBE+4Tk0xW2DB0=; h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version: Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From; b=tckZcawuk7VX8DLCwfV0lS8GkXe5JThP7mb5BI9tWb3r8L2KuZhcxRB9gfF5ywbmz 41q2vCmg+qznch+DGOIGa1qChf6ncvbJCJjq5KHRW07egICynDOUdfsvcQQHzYSqoz vmULI/QAoydiw5gMMW9aU32R+K1LIEajaZ8TUMZg9B7vcR1RCCGio96mSL2IzmSJw8 Lq7UADMWzIEw0L7jFB2kAJsixe731KkwudU4iCIga6AEy4UrwI3ywVkGdzOGecV3qP ssTNgfEozCmv9niAYtlFJq2AsUNlG1IWl4qMMMJ0kjxhdEJEhU+A75kDcCdhB8dWJx qTct4eWf17zfg== From: "Julian Vetter" Subject: =?utf-8?Q?[PATCH]=20x86/hvm:=20Advertise=20and=20support=20extended=20destination=20IDs=20for=20MSI/IO-APIC?= X-Mailer: git-send-email 2.51.0 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1770636857446 To: xen-devel@lists.xenproject.org Cc: "Jan Beulich" , "Andrew Cooper" , "=?utf-8?Q?Roger=20Pau=20Monn=C3=A9?=" , "Julian Vetter" Message-Id: <20260209113412.2603088-1-julian.vetter@vates.tech> X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.bdcf0703707f407d99f9ec1d35fae8ed?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20260209:md Date: Mon, 09 Feb 2026 11:34:18 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity julian.vetter@vates.tech) (identity @mandrillapp.com) X-ZM-MESSAGEID: 1770636896210154100 Content-Type: text/plain; charset="utf-8" x2APIC guests with more than 128 vCPUs have APIC IDs above 255, but MSI addresses and IO-APIC RTEs only provide an 8-bit destination field. Without extended destination ID support, Linux limits the maximum usable APIC ID to 255, refusing to bring up vCPUs beyond that limit. So, advertise XEN_HVM_CPUID_EXT_DEST_ID in the HVM hypervisor CPUID leaf, signalling that guests may use MSI address bits 11:5 and IO-APIC RTE bits 55:49 as additional high destination ID bits. This expands the destination ID from 8 to 15 bits. Signed-off-by: Julian Vetter --- xen/arch/x86/cpuid.c | 9 +++++++++ xen/arch/x86/hvm/irq.c | 11 ++++++++++- xen/arch/x86/hvm/vioapic.c | 2 +- xen/arch/x86/hvm/vmsi.c | 4 ++-- xen/arch/x86/include/asm/hvm/hvm.h | 4 ++-- xen/arch/x86/include/asm/hvm/vioapic.h | 13 +++++++++++++ xen/arch/x86/include/asm/msi.h | 3 +++ 7 files changed, 40 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index d85be20d86..fb17c71d74 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -148,6 +148,15 @@ static void cpuid_hypervisor_leaves(const struct vcpu = *v, uint32_t leaf, res->a |=3D XEN_HVM_CPUID_DOMID_PRESENT; res->c =3D d->domain_id; =20 + /* + * Advertise extended destination ID support. This allows guests t= o use + * bits 11:5 of the MSI address and bits 55:49 of the IO-APIC RTE = for + * additional destination ID bits, expanding the addressable APIC = ID + * range from 8 to 15 bits. This is required for x2APIC guests with + * APIC IDs > 255. + */ + res->a |=3D XEN_HVM_CPUID_EXT_DEST_ID; + /* * Per-vCPU event channel upcalls are implemented and work * correctly with PIRQs routed over event channels. diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c index 5f64361113..2cc14d37d4 100644 --- a/xen/arch/x86/hvm/irq.c +++ b/xen/arch/x86/hvm/irq.c @@ -374,7 +374,16 @@ int hvm_set_pci_link_route(struct domain *d, u8 link, = u8 isa_irq) int hvm_inject_msi(struct domain *d, uint64_t addr, uint32_t data) { uint32_t tmp =3D (uint32_t) addr; - uint8_t dest =3D (tmp & MSI_ADDR_DEST_ID_MASK) >> MSI_ADDR_DEST_ID_SH= IFT; + /* + * Standard MSI destination: address bits 19:12 (8 bits). + * Extended MSI destination: address bits 11:5 (7 more bits). + * When XEN_HVM_CPUID_EXT_DEST_ID is advertised, the guest may use + * bits 11:5 for high destination ID bits, expanding to 15 bits total. + * For legacy guests these bits are 0, so this is backwards-compatible. + */ + uint32_t dest =3D + (((tmp & MSI_ADDR_EXT_DEST_ID_MASK) >> MSI_ADDR_EXT_DEST_ID_SHIFT)= << 8) | + ((tmp & MSI_ADDR_DEST_ID_MASK) >> MSI_ADDR_DEST_ID_SHIFT); uint8_t dest_mode =3D !!(tmp & MSI_ADDR_DESTMODE_MASK); uint8_t delivery_mode =3D (data & MSI_DATA_DELIVERY_MODE_MASK) >> MSI_DATA_DELIVERY_MODE_SHIFT; diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c index 7c725f9e47..263b1bd5cb 100644 --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -411,7 +411,7 @@ static void ioapic_inj_irq( =20 static void vioapic_deliver(struct hvm_vioapic *vioapic, unsigned int pin) { - uint16_t dest =3D vioapic->redirtbl[pin].fields.dest_id; + uint32_t dest =3D VIOAPIC_RTE_DEST(vioapic->redirtbl[pin].bits); uint8_t dest_mode =3D vioapic->redirtbl[pin].fields.dest_mode; uint8_t delivery_mode =3D vioapic->redirtbl[pin].fields.delivery_mode; uint8_t vector =3D vioapic->redirtbl[pin].fields.vector; diff --git a/xen/arch/x86/hvm/vmsi.c b/xen/arch/x86/hvm/vmsi.c index 27b1f089e2..dca191b4f1 100644 --- a/xen/arch/x86/hvm/vmsi.c +++ b/xen/arch/x86/hvm/vmsi.c @@ -66,7 +66,7 @@ static void vmsi_inj_irq( =20 int vmsi_deliver( struct domain *d, int vector, - uint8_t dest, uint8_t dest_mode, + uint32_t dest, uint8_t dest_mode, uint8_t delivery_mode, uint8_t trig_mode) { struct vlapic *target; @@ -125,7 +125,7 @@ void vmsi_deliver_pirq(struct domain *d, const struct h= vm_pirq_dpci *pirq_dpci) } =20 /* Return value, -1 : multi-dests, non-negative value: dest_vcpu_id */ -int hvm_girq_dest_2_vcpu_id(struct domain *d, uint8_t dest, uint8_t dest_m= ode) +int hvm_girq_dest_2_vcpu_id(struct domain *d, uint32_t dest, uint8_t dest_= mode) { int dest_vcpu_id =3D -1, w =3D 0; struct vcpu *v; diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/= hvm/hvm.h index 7d9774df59..11256d5e67 100644 --- a/xen/arch/x86/include/asm/hvm/hvm.h +++ b/xen/arch/x86/include/asm/hvm/hvm.h @@ -295,11 +295,11 @@ uint64_t hvm_get_guest_time_fixed(const struct vcpu *= v, uint64_t at_tsc); =20 int vmsi_deliver( struct domain *d, int vector, - uint8_t dest, uint8_t dest_mode, + uint32_t dest, uint8_t dest_mode, uint8_t delivery_mode, uint8_t trig_mode); struct hvm_pirq_dpci; void vmsi_deliver_pirq(struct domain *d, const struct hvm_pirq_dpci *pirq_= dpci); -int hvm_girq_dest_2_vcpu_id(struct domain *d, uint8_t dest, uint8_t dest_m= ode); +int hvm_girq_dest_2_vcpu_id(struct domain *d, uint32_t dest, uint8_t dest_= mode); =20 enum hvm_intblk hvm_interrupt_blocked(struct vcpu *v, struct hvm_intack intack); diff --git a/xen/arch/x86/include/asm/hvm/vioapic.h b/xen/arch/x86/include/= asm/hvm/vioapic.h index 68af6dce79..b49eb348d5 100644 --- a/xen/arch/x86/include/asm/hvm/vioapic.h +++ b/xen/arch/x86/include/asm/hvm/vioapic.h @@ -32,6 +32,19 @@ #define VIOAPIC_EDGE_TRIG 0 #define VIOAPIC_LEVEL_TRIG 1 =20 +/* + * Extract the destination ID from a 64-bit IO-APIC RTE, including the + * extended bits (55:49) used when XEN_HVM_CPUID_EXT_DEST_ID is advertised. + */ +#define IO_APIC_REDIR_DEST_SHIFT 56 +#define IO_APIC_REDIR_DEST_MASK 0xffULL +#define IO_APIC_REDIR_EXT_DEST_SHIFT 49 +#define IO_APIC_REDIR_EXT_DEST_MASK 0x7fULL + +#define VIOAPIC_RTE_DEST(rte) \ + ((((rte) >> IO_APIC_REDIR_DEST_SHIFT) & IO_APIC_REDIR_DEST_MASK) | \ + (((rte) >> IO_APIC_REDIR_EXT_DEST_SHIFT) & IO_APIC_REDIR_EXT_DEST_MAS= K) << 8) + #define VIOAPIC_DEFAULT_BASE_ADDRESS 0xfec00000U #define VIOAPIC_MEM_LENGTH 0x100 =20 diff --git a/xen/arch/x86/include/asm/msi.h b/xen/arch/x86/include/asm/msi.h index 00059d4a3a..b7a132e5b5 100644 --- a/xen/arch/x86/include/asm/msi.h +++ b/xen/arch/x86/include/asm/msi.h @@ -54,6 +54,9 @@ #define MSI_ADDR_DEST_ID_MASK 0x00ff000 #define MSI_ADDR_DEST_ID(dest) (((dest) << MSI_ADDR_DEST_ID_SHIFT) & MSI= _ADDR_DEST_ID_MASK) =20 +#define MSI_ADDR_EXT_DEST_ID_SHIFT 5 +#define MSI_ADDR_EXT_DEST_ID_MASK 0x0000fe0 + /* MAX fixed pages reserved for mapping MSIX tables. */ #define FIX_MSIX_MAX_PAGES 512 =20 --=20 2.51.0 -- Julian Vetter | Vates Hypervisor & Kernel Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech