From nobody Thu Apr 16 15:12:15 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4fxM1r2Rq5z6Zpt9 for ; Thu, 16 Apr 2026 15:12:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fxM1q4c8tz4MnV for ; Thu, 16 Apr 2026 15:12:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776352335; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mpuWHL8pijT8LluR3ITrfdb2DUfqFzrvF3o1PubNtDQ=; b=Zcc+vl/8n6PhLqIvfEbCNHTlJJ5bT4mZhQnfORT+VO/JtgjBFaFSwbSZTJ7Ignu1QKSvPm J2G+LeKMnhKXSUc6iVzCvYh/wSv28/lMkwRc3aI2Gss1PeQcVqV4E5EGHQ68/gd8JQhVSg b/No522pzomNH3AlvRJBz0gdYOS/vEwjElgB2S/uwNlLP5slqWP4RzrPfAcmFw8wwvN4uY PD0u+3hkX5D5YWNq1j/rKTYj8YDQnBsLTZEUiaSlf1k7ewSr7TtmVFLb5a4j+BjzKXGyts nVSr4DJErziTy3q/LzC5uZdgKWXFtFoA2V37aM7uD1LhlBqR8AcVxvmMAh8vvQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776352335; a=rsa-sha256; cv=none; b=GAyyd+tOJSKjfBGi46aAUYxRVp1PrQjZWqesaVoVkg8Cl4HzEbZZPhOMiPssw3kjm6THPj HQ6IPgiau559/iM4TMBKFK/xOGvMX+1zR8mTKT3rUFugmQjt3tYJXSgwlL4dp1HyCmqPk8 PBFfSkBGbnKGBN6nwUZD1Dwyki4RLmW/TNf0kWHwNO39ie7WerT50yS6Brqb7zl2ajM36g UzseNVQwbMtyZ5qbOlcfFc99KPlHNAMzuk7KPaUsEMzhDh9ga3yo9nMLFjZkJB35DobxE4 /OS3udfE3+a/bXFyr3NTkcuMoa4+MifVrxaq9trnsWOJCC5QcntPwAFiEDLvWg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776352335; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mpuWHL8pijT8LluR3ITrfdb2DUfqFzrvF3o1PubNtDQ=; b=gSgiwpZaywPxosSG0g2ZmiIeQzWwD+MbPqA5wIgkXm9WbefC8Bt80jdbc0HS1BbbmXRxbT NUfYX0o0uEFK1IFpS1koyPt01GKMEvb1grBjbGp1mGJIA+XsC2rUGY7iRaTMJjOXkx2KyJ LQYvMixEYZLdpIfCtoO2vDNLO48q5sE09Iz3RO1KOuLjzh+P2QlOZ1zGTN1P/nt+glr+Jf zXIbunEeMApcHu4zVaXS2POaWB+aetZnXiETt672tSPKSBYMNQqzyM3hetOFOCagX3wLqE iwz0oKuuUY7/ji/RQ+DwTnyAKxorkaG2CJLXYN111ByP3xyLiPzUeThEJKYs+A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fxM1q3jl2z1C7w for ; Thu, 16 Apr 2026 15:12:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1dfcf by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 16 Apr 2026 15:12:15 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: David Woodhouse From: Colin Percival Subject: git: e77e112a3e20 - stable/14 - bhyve: Support and advertise 15-bit MSI Extended Destination ID List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: e77e112a3e2084918befee20645e6dcc81dea07b Auto-Submitted: auto-generated Date: Thu, 16 Apr 2026 15:12:15 +0000 Message-Id: <69e0fc4f.1dfcf.5969c047@gitrepo.freebsd.org> The branch stable/14 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=e77e112a3e2084918befee20645e6dcc81dea07b commit e77e112a3e2084918befee20645e6dcc81dea07b Author: David Woodhouse AuthorDate: 2025-07-31 07:33:54 +0000 Commit: Colin Percival CommitDate: 2026-04-16 15:11:41 +0000 bhyve: Support and advertise 15-bit MSI Extended Destination ID To support guests with more than 255 vCPUs, allow bits 5-11 of the MSI address to be used as additional destination ID bits. This is compatible with Hyper-V, KVM and Xen's implementation of the same enlightenment, as documented at http://david.woodhou.se/ExtDestId.pdf Reviewed by: kib Pull Request: https://github.com/freebsd/freebsd-src/pull/1797 Signed-off-by: David Woodhouse (cherry picked from commit 4322d597453d63d638675b8612d7aaabd65dcadd) --- sys/amd64/vmm/io/vioapic.c | 9 +++++++++ sys/amd64/vmm/vmm_lapic.c | 5 +++++ sys/amd64/vmm/x86.c | 2 +- sys/x86/include/apicreg.h | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/sys/amd64/vmm/io/vioapic.c b/sys/amd64/vmm/io/vioapic.c index e1503b6a699b..539cd41478c3 100644 --- a/sys/amd64/vmm/io/vioapic.c +++ b/sys/amd64/vmm/io/vioapic.c @@ -129,6 +129,15 @@ vioapic_send_intr(struct vioapic *vioapic, int pin) vector = low & IOART_INTVEC; dest = high >> APIC_ID_SHIFT; + /* + * Ideally we'd just call lapic_intr_msi() here with the + * constructed MSI instead of interpreting it for ourselves. + * But until/unless we support emulated IOMMUs with interrupt + * remapping, interpretation is simple. We just need to mask + * in the Extended Destination ID bits for the 15-bit + * enlightenment (http://david.woodhou.se/ExtDestId.pdf) + */ + dest |= ((high & APIC_EXT_ID_MASK) >> APIC_EXT_ID_SHIFT) << 8; vlapic_deliver_intr(vioapic->vm, level, dest, phys, delmode, vector); } diff --git a/sys/amd64/vmm/vmm_lapic.c b/sys/amd64/vmm/vmm_lapic.c index c4217bd00792..2fc927a4f7aa 100644 --- a/sys/amd64/vmm/vmm_lapic.c +++ b/sys/amd64/vmm/vmm_lapic.c @@ -115,6 +115,11 @@ lapic_intr_msi(struct vm *vm, uint64_t addr, uint64_t msg) * physical otherwise. */ dest = (addr >> 12) & 0xff; + /* + * Extended Destination ID support uses bits 5-11 of the address: + * http://david.woodhou.se/ExtDestId.pdf + */ + dest |= ((addr >> 5) & 0x7f) << 8; phys = ((addr & (MSI_X86_ADDR_RH | MSI_X86_ADDR_LOG)) != (MSI_X86_ADDR_RH | MSI_X86_ADDR_LOG)); delmode = msg & APIC_DELMODE_MASK; diff --git a/sys/amd64/vmm/x86.c b/sys/amd64/vmm/x86.c index eea334562784..8afd213e3824 100644 --- a/sys/amd64/vmm/x86.c +++ b/sys/amd64/vmm/x86.c @@ -616,7 +616,7 @@ x86_emulate_cpuid(struct vcpu *vcpu, uint64_t *rax, uint64_t *rbx, break; case CPUID_BHYVE_FEATURES: - regs[0] = 0; /* No features to advertise yet */ + regs[0] = CPUID_BHYVE_FEAT_EXT_DEST_ID; regs[1] = 0; regs[2] = 0; regs[3] = 0; diff --git a/sys/x86/include/apicreg.h b/sys/x86/include/apicreg.h index d610d7f11a1c..1252647fbab3 100644 --- a/sys/x86/include/apicreg.h +++ b/sys/x86/include/apicreg.h @@ -296,6 +296,8 @@ typedef struct IOAPIC ioapic_t; /* constants relating to APIC ID registers */ #define APIC_ID_MASK 0xff000000 #define APIC_ID_SHIFT 24 +#define APIC_EXT_ID_MASK 0x00fe0000 +#define APIC_EXT_ID_SHIFT 17 #define APIC_ID_CLUSTER 0xf0 #define APIC_ID_CLUSTER_ID 0x0f #define APIC_MAX_CLUSTER 0xe