From nobody Sat Jul 25 22:03:05 2026 Received: from PH0PR06CU001.outbound.protection.outlook.com (mail-westus3azon11011021.outbound.protection.outlook.com [40.107.208.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5DB83128B8; Mon, 13 Jul 2026 10:51:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.208.21 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783939906; cv=fail; b=MdM7VJvmc3WOc0xE4BD2ldnL6XXqzNKT7tUVGoavVht8AkpxOHZ4Qb9YTon792KGzS2WQEB1xtCamC2u07vy0db4ImetAFNaoY4EMZ0VIpjzgcoZUOf1WFbP84zRJUERjXIgAzRX1STTJx5BOu5hudw/zwUkGM4ly67Dl2+TQPg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783939906; c=relaxed/simple; bh=ZE979SgzSzdHK5lbCapTAp8pbiKIAeJ+cVFtBVRaPNg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AlE2gnDKibkfbUEugb2gqOhcJaFmYxhmxbaycDP9adneiSb+yPz0odO52L109EWRqTN34aUb1JJ0dsMowbwcylWfqe8Jw09omytH60OKAadj2Kx4hYYblLHV/B6QTeGQebGnNp9N+TZJym3tdG7mi4/boOVEaHxYpY2JQRmy1c8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=fEEsiGxo; arc=fail smtp.client-ip=40.107.208.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="fEEsiGxo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KyAZnydfZvfaJCBtAq8cKC9+Dqu6zvSLvAnVTk/aJhvm2ziqMEHImDtuB/JgqEa34ShEl9n8liHgRnxRW88xM0ZyS8fqNZERCw0dSQZ6CYdQEowd6bZ/n23NYKao52bJlPgiwEnoquab1IsD7Iza7Ll8YqXZhF2y8vKWrqv24R+Zua1iB0q97grxRzlcJR52QILeEzrqgtaRBFCFhRTXz9fbU6FYKXUDiRBMPvq5zrU6X7PHYmBFiYbhXzmBVSDssiHUrd1bm5NKBZ5JkibRPcU4azUAaJEwj4GjhOcd1zpzvvIF/7weW2uAkP9ZzJr1rETcamr0mMSwvH28//XFrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ULMfi1SWiL1o2gTbPNEx0v44HaGwVufumEMzMjOeR8U=; b=IzyXB2udr8nCdnB+gX1lPoNexYaoalr/h8EMJsIdT3X9vY0fVHqDW/AVY3sOi+9rhu+PdYYSV5HZ/2pgif30gF3fnDfyTnyVpXw+djyNdR7xn6iN7497rhOeUq1VTHLYzv4Svy3gzF8CdIZvL2nyexiQkNiZY648NUKHCRxyvQtjkDenh3tCHSqQCzPJsjCOUAJNrFweVqmuvYjAPuW087HnykemWC9gWto91LUzvrI5f5T9Bm9Uq6aGcuwQ0G9/+5syn1GNkZOyKhaC1i7ahyhilFSHS1w3E17Z7ywo4vK8d18EOKpc2pqP9K9hdNBLNzk21ULQQUcTSFBiLMKyYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ULMfi1SWiL1o2gTbPNEx0v44HaGwVufumEMzMjOeR8U=; b=fEEsiGxoT8LwzLMPKOh8YVADapuVXitStzh1zHFB+I2aIJBooqdZLsRkeZdGGIdQiy289/lpgyUYMJj6j3b7hRZuI2DH41PQGSbvLNAf8qlEU60Eg/JXMzAhbAso+G0SaBAadgN8riAJxNOWIM770/QZcOHvPwuNAV5XDMCQwTg= Received: from CH0PR03CA0102.namprd03.prod.outlook.com (2603:10b6:610:cd::17) by DS2PR12MB9797.namprd12.prod.outlook.com (2603:10b6:8:2ba::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.18; Mon, 13 Jul 2026 10:51:34 +0000 Received: from CH1PEPF0000A349.namprd04.prod.outlook.com (2603:10b6:610:cd:cafe::16) by CH0PR03CA0102.outlook.office365.com (2603:10b6:610:cd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.19 via Frontend Transport; Mon, 13 Jul 2026 10:51:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH1PEPF0000A349.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.9 via Frontend Transport; Mon, 13 Jul 2026 10:51:33 +0000 Received: from BLR-L1-SARUNKOD.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Mon, 13 Jul 2026 05:51:26 -0500 From: Sairaj Kodilkar To: "Borislav Petkov (AMD)" , "H. Peter Anvin" , "Joerg Roedel (AMD)" , "Paul E. McKenney" , Andrew Morton , Dapeng Mi , Dave Hansen , "Eric Biggers" , Feng Tang , "Ingo Molnar" , Jakub Kicinski , Jonathan Corbet , Li RongQing , Marco Elver , Paolo Bonzini , Randy Dunlap , Robin Murphy , Sairaj Kodilkar , Sean Christopherson , Shuah Khan , Suravee Suthikulpanit , Thomas Gleixner , "Vasant Hegde" , Will Deacon , , , , , Subject: [RFC PATCH v3 1/6] iommu/amd: KVM: SVM: Rename cpu to apicid in IOMMU interface Date: Mon, 13 Jul 2026 16:20:28 +0530 Message-ID: <20260713105033.15405-2-sarunkod@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260713105033.15405-1-sarunkod@amd.com> References: <20260713105033.15405-1-sarunkod@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A349:EE_|DS2PR12MB9797:EE_ X-MS-Office365-Filtering-Correlation-Id: 17061b1d-00db-486c-b582-08dee0ccb48d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|1800799024|82310400026|23010399003|7416014|376014|22082099003|18002099003|11063799006|56012099006|921020; X-Microsoft-Antispam-Message-Info: giMU6f4qt0p1uoMgGKglddSbdZoYuh/TeyG2qnA8DDlqXaS4KhPJHaWMqJoF29cPTM6VtM+8fsJvzqQoZAlToRBoJ67alY06k1I9i80VYeLR8gP+gLg0PeCZMgscfOAuLbfNtJ6F4t62HmIDXsRz5lg1+mtYGFGRwLbaWOScsxFVJqGMcE6KbyEihl+rhfZ0djdw9FoJHCz9OXUdJ8uG2HIAGd1ks4ArlOXKczuJUlkz5nmXu/s0vRzS02Dq6vSdoPB/jDXAzCM2KnHYWIzukSqLC/lNitn6ObNoXH2+2gr0LTgfXaNOzIikyMM4673BUFru6UHTecfBZu5UK2cB0hxYUj6+fXceN1abkOV4cs4GDB/pme6clLSzOGpv4PBn8uJH/+/CCQz10bQw2yRqxl8L/vGN8CwtLuPrvRbj3xfFdCkPL93bhyv93afKTh5VniFEO46e8p2D/ebRCZHfCzCTjKW99QIs2jyiMesu8ZlIJ9Bn9V8wwUiTjnng3mDBA1qFn+W9UgSp0HlBp5Y1yjhOyuilgUifFlcEI26rNPAyqAAkixMOXKKpU4LHiybEvHVTLRr9xiwtwPnnOxxMITPrifd/aOvrLP76KLLLz7qVXHz440dhT2xCRwg65SSv4qlQOiiCGXPSIVd367E6bQ40L3Bx0k9w9ZV5PWFAHlUg4Bg+mMvj+pTccKP9RjqN2v5V4aaJxP0Lq/kskfU//PU21242fUylvWDy0W6qDwQywEyuA8THuWfvFAli4bb+ X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(1800799024)(82310400026)(23010399003)(7416014)(376014)(22082099003)(18002099003)(11063799006)(56012099006)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nR9P07yFVlxbLvF+P+bqy2JtI9qmAWOicG7KLBTQ6aLK8oAULHuKDa6KmwhW3UdGkNySRCtPK6NA9ZX2A/twDtL/TfFpk+wGkewyUyo3xD6kFk6agG0FenZEmpdZbnjlH83YU8IBzhBaPt42xVPlB6DLoU7Oy8NL0MZxDyrlTrV7pDt15bn7xm3wivP4lhePC1Lx+8T8ke1U+Iz7Sqmt7ElEprIA2STlMFd3t3fJfeKmGH3YyvGQWN/45XvM6eQ8DlOxre/xm88pMm1+ODQN+BsMn27bw6k/6XKR1MKl+0gdGLDDQQwruceo+krdw7GpB7ajfaXmqdaDxLTvXAeRe5JLSyX4mYVcuWr1ME/7J7hVHwjLo3ajtjPTMaSva4teE9/A6i1KggjsnMYv2+ntDSzrZpGshEqr2qDlTkpb6X8gL8FXrgj/31O4vX3rvgfv X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2026 10:51:33.9996 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17061b1d-00db-486c-b582-08dee0ccb48d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000A349.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS2PR12MB9797 Content-Type: text/plain; charset="utf-8" The cpu field passed from SVM to the AMD IOMMU driver does not hold a linux CPU number. It carries the host physical APIC ID used to program the IRTE Destination field when the target vCPU is running (IRTE[IsRun] =3D 1). Rename the field to apicid everywhere in the IOMMU interface so the name matches the hardware semantics. No functional change is intended. Signed-off-by: Sairaj Kodilkar --- arch/x86/include/asm/irq_remapping.h | 2 +- arch/x86/kvm/svm/avic.c | 12 +++++----- drivers/iommu/amd/iommu.c | 35 ++++++++++++++-------------- include/linux/amd-iommu.h | 8 +++---- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/arch/x86/include/asm/irq_remapping.h b/arch/x86/include/asm/ir= q_remapping.h index 37b94f484ef3..263f4df429d8 100644 --- a/arch/x86/include/asm/irq_remapping.h +++ b/arch/x86/include/asm/irq_remapping.h @@ -35,7 +35,7 @@ struct amd_iommu_pi_data { u64 vapic_addr; /* Physical address of the vCPU's vAPIC. */ u32 ga_tag; u32 vector; /* Guest vector of the interrupt */ - int cpu; + int apicid; bool ga_log_intr; bool is_guest_mode; void *ir_data; diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c index cdd5a6dc646f..bccc5d7ed207 100644 --- a/arch/x86/kvm/svm/avic.c +++ b/arch/x86/kvm/svm/avic.c @@ -949,9 +949,9 @@ int avic_pi_update_irte(struct kvm_kernel_irqfd *irqfd,= struct kvm *kvm, */ entry =3D svm->avic_physical_id_entry; if (entry & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK) { - pi_data.cpu =3D entry & AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK; + pi_data.apicid =3D entry & AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK; } else { - pi_data.cpu =3D -1; + pi_data.apicid =3D -1; pi_data.ga_log_intr =3D entry & AVIC_PHYSICAL_ID_ENTRY_GA_LOG_INTR; } =20 @@ -1004,7 +1004,7 @@ enum avic_vcpu_action { AVIC_START_BLOCKING =3D BIT(1), }; =20 -static void avic_update_iommu_vcpu_affinity(struct kvm_vcpu *vcpu, int cpu, +static void avic_update_iommu_vcpu_affinity(struct kvm_vcpu *vcpu, int api= cid, enum avic_vcpu_action action) { bool ga_log_intr =3D (action & AVIC_START_BLOCKING); @@ -1024,9 +1024,9 @@ static void avic_update_iommu_vcpu_affinity(struct kv= m_vcpu *vcpu, int cpu, void *data =3D irqfd->irq_bypass_data; =20 if (!(action & AVIC_TOGGLE_ON_OFF)) - WARN_ON_ONCE(amd_iommu_update_ga(data, cpu, ga_log_intr)); - else if (cpu >=3D 0) - WARN_ON_ONCE(amd_iommu_activate_guest_mode(data, cpu, ga_log_intr)); + WARN_ON_ONCE(amd_iommu_update_ga(data, apicid, ga_log_intr)); + else if (apicid >=3D 0) + WARN_ON_ONCE(amd_iommu_activate_guest_mode(data, apicid, ga_log_intr)); else WARN_ON_ONCE(amd_iommu_deactivate_guest_mode(data)); } diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 57dc8fabc7d9..c0cf7799c56e 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -3959,14 +3959,14 @@ static const struct irq_domain_ops amd_ir_domain_op= s =3D { .deactivate =3D irq_remapping_deactivate, }; =20 -static void __amd_iommu_update_ga(struct irte_ga *entry, int cpu, +static void __amd_iommu_update_ga(struct irte_ga *entry, int apicid, bool ga_log_intr) { - if (cpu >=3D 0) { + if (apicid >=3D 0) { entry->lo.fields_vapic.destination =3D - APICID_TO_IRTE_DEST_LO(cpu); + APICID_TO_IRTE_DEST_LO(apicid); entry->hi.fields.destination =3D - APICID_TO_IRTE_DEST_HI(cpu); + APICID_TO_IRTE_DEST_HI(apicid); entry->lo.fields_vapic.is_run =3D true; entry->lo.fields_vapic.ga_log_intr =3D false; } else { @@ -3979,20 +3979,21 @@ static void __amd_iommu_update_ga(struct irte_ga *e= ntry, int cpu, * Update the pCPU information for an IRTE that is configured to post IRQs= to * a vCPU, without issuing an IOMMU invalidation for the IRTE. * - * If the vCPU is associated with a pCPU (@cpu >=3D 0), configure the Dest= ination - * with the pCPU's APIC ID, set IsRun, and clear GALogIntr. If the vCPU i= sn't - * associated with a pCPU (@cpu < 0), clear IsRun and set/clear GALogIntr = based - * on input from the caller (e.g. KVM only requests GALogIntr when the vCP= U is - * blocking and requires a notification wake event). I.e. treat vCPUs tha= t are - * associated with a pCPU as running. This API is intended to be used whe= n a - * vCPU is scheduled in/out (or stops running for any reason), to do a fast - * update of IsRun, GALogIntr, and (conditionally) Destination. + * If the vCPU is associated with a pCPU (@apicid >=3D 0), configure the + * Destination with the pCPU's APIC ID, set IsRun, and clear GALogIntr. I= f the + * vCPU isn't associated with a pCPU (@apicid < 0), clear IsRun and set/cl= ear + * GALogIntr based on input from the caller (e.g. KVM only requests GALogI= ntr + * when the vCPU is blocking and requires a notification wake event). I.e. + * treat vCPUs that are associated with a pCPU as running. This API is + * intended to be used when a vCPU is scheduled in/out (or stops running f= or + * any reason), to do a fast update of IsRun, GALogIntr, and (conditionall= y) + * Destination. * * Per the IOMMU spec, the Destination, IsRun, and GATag fields are not ca= ched * and thus don't require an invalidation to ensure the IOMMU consumes fre= sh * information. */ -int amd_iommu_update_ga(void *data, int cpu, bool ga_log_intr) +int amd_iommu_update_ga(void *data, int apicid, bool ga_log_intr) { struct amd_ir_data *ir_data =3D (struct amd_ir_data *)data; struct irte_ga *entry =3D (struct irte_ga *) ir_data->entry; @@ -4006,14 +4007,14 @@ int amd_iommu_update_ga(void *data, int cpu, bool g= a_log_intr) if (!ir_data->iommu) return -ENODEV; =20 - __amd_iommu_update_ga(entry, cpu, ga_log_intr); + __amd_iommu_update_ga(entry, apicid, ga_log_intr); =20 return __modify_irte_ga(ir_data->iommu, ir_data->irq_2_irte.devid, ir_data->irq_2_irte.index, entry); } EXPORT_SYMBOL(amd_iommu_update_ga); =20 -int amd_iommu_activate_guest_mode(void *data, int cpu, bool ga_log_intr) +int amd_iommu_activate_guest_mode(void *data, int apicid, bool ga_log_intr) { struct amd_ir_data *ir_data =3D (struct amd_ir_data *)data; struct irte_ga *entry =3D (struct irte_ga *) ir_data->entry; @@ -4036,7 +4037,7 @@ int amd_iommu_activate_guest_mode(void *data, int cpu= , bool ga_log_intr) entry->hi.fields.vector =3D ir_data->ga_vector; entry->lo.fields_vapic.ga_tag =3D ir_data->ga_tag; =20 - __amd_iommu_update_ga(entry, cpu, ga_log_intr); + __amd_iommu_update_ga(entry, apicid, ga_log_intr); =20 return modify_irte_ga(ir_data->iommu, ir_data->irq_2_irte.devid, ir_data->irq_2_irte.index, entry); @@ -4107,7 +4108,7 @@ static int amd_ir_set_vcpu_affinity(struct irq_data *= data, void *info) ir_data->ga_vector =3D pi_data->vector; ir_data->ga_tag =3D pi_data->ga_tag; if (pi_data->is_guest_mode) - ret =3D amd_iommu_activate_guest_mode(ir_data, pi_data->cpu, + ret =3D amd_iommu_activate_guest_mode(ir_data, pi_data->apicid, pi_data->ga_log_intr); else ret =3D amd_iommu_deactivate_guest_mode(ir_data); diff --git a/include/linux/amd-iommu.h b/include/linux/amd-iommu.h index edcee9f5335a..2c6232aefafa 100644 --- a/include/linux/amd-iommu.h +++ b/include/linux/amd-iommu.h @@ -30,8 +30,8 @@ static inline void amd_iommu_detect(void) { } /* IOMMU AVIC Function */ extern int amd_iommu_register_ga_log_notifier(int (*notifier)(u32)); =20 -extern int amd_iommu_update_ga(void *data, int cpu, bool ga_log_intr); -extern int amd_iommu_activate_guest_mode(void *data, int cpu, bool ga_log_= intr); +extern int amd_iommu_update_ga(void *data, int apicid, bool ga_log_intr); +extern int amd_iommu_activate_guest_mode(void *data, int apicid, bool ga_l= og_intr); extern int amd_iommu_deactivate_guest_mode(void *data); =20 #else /* defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) */ @@ -42,12 +42,12 @@ amd_iommu_register_ga_log_notifier(int (*notifier)(u32)) return 0; } =20 -static inline int amd_iommu_update_ga(void *data, int cpu, bool ga_log_int= r) +static inline int amd_iommu_update_ga(void *data, int apicid, bool ga_log_= intr) { return 0; } =20 -static inline int amd_iommu_activate_guest_mode(void *data, int cpu, bool = ga_log_intr) +static inline int amd_iommu_activate_guest_mode(void *data, int apicid, bo= ol ga_log_intr) { return 0; } --=20 2.34.1 From nobody Sat Jul 25 22:03:05 2026 Received: from BN8PR05CU002.outbound.protection.outlook.com (mail-eastus2azon11011008.outbound.protection.outlook.com [52.101.57.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B9523E9C0D; Mon, 13 Jul 2026 10:52:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.57.8 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783939930; cv=fail; b=aJ7TlUp8ub/NtfVf8VqqbQhEoOJgDXh/wF1p+s/1ygp3LRYnYbNlNFKj5+uPeO6wEtzNI8kUIUBVfLSH43CGww11yE/mXC2e4xCcqGsfsWWmpzps/95YaCWmGV0D9hlSWQ6xuZvPKtJC/w0DuSynjcbX1SnGr994yJioFyVU2a4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783939930; c=relaxed/simple; bh=uOXnSKyqgtrjvsbbQakzGKckmFagyPCw2mFq74i8x1w=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EJ6gmKOBwTdMV1WqORoN6q1nu2IKf09dkQk1nn0s9Pj5ln/7Y/LUxYfZBHWKwGqd+37ly+vKBheWf7/K1yNeanV70LecVMesbmUFTUthc4i3nT8i08+pHrSUIN1R5ro2AyMBVg6WT2e4W76+YJ3gu8l1VCOprYEjhcigwmiQ5z0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=C4M2FdaU; arc=fail smtp.client-ip=52.101.57.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="C4M2FdaU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lG8XYHrUetvvYADeaYEtyN87UwUAPub47+ZTt0yvKN6cMf7SNoiEY7nTG4WeWWVc8vTKc81FxvwmMxXORgIfyNf3QXCyXfQbI0U5re9A5pVEzGJGWd2J1Alc9N/8/TB5SXOOSCty5V3oniS0uZA26sGnsmzoq4JoLUuu3al8VHNCfiHQ/10SmHAGH2oCbfuY3mIMcFp74ngrgbEfhKE7Mj73xcdqjqmuYZFUeU3jMAgrVsqM8Fk91XoyDDT0dvRHL6xt6m23N5Zk6fOckf6Isv/U33PUW8fpTS/c+tBgjY4Bo7ZxXMNTMk5rVxJroKkgE5Xbvoa4c+qXgjzn3zGY0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1Aybnibe4u1nOdKKGbqYcGv/r3je/m+vlyy9hvom/bs=; b=hEscM//0wPXkbBQeAuMPrLsnunw10boEdMK4Q3oqgC3wFx8Zqenf5rySnydPhR2vSQUl5PVkwWSx0OJ882+QPVh+bbDMEGSG7qZDB4vtnCS7SpRQ7SBJDWaoFp0HBQsrHrkOiFxxEAqmBBXsEYPJQ+fW2PD6bCkLTBumZinricacpqkcUYBdlknngskpkie82U1BoMdWx6KHYMY52M70hp35QBXQZ+XuD7Lp4bBwLodLx+/xP0Xcb97pK/fDb1515o/E7xLbrZQDiFaXhwBHi5jxhNrGZubvdyPDW6GUAbInWvlR0L623A3oeH6lUUu3N7KQwmWp3adFvYw3uMrfVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1Aybnibe4u1nOdKKGbqYcGv/r3je/m+vlyy9hvom/bs=; b=C4M2FdaUlcbspn5wu95Z/PlVUK8lhBxv4g7/0r7BgpFDlC1MNCwKRdj/MqyZYWv50QK1q21nLdjqfzq9b3z+ssjCeq9rFeOMRo00H56PsOedkiYsIImg88SK2mo/cFmuBYO7o17a6JWqJC9ybipYMz/y2H6unGA5+zWpWvjUVGg= Received: from CH0PR03CA0094.namprd03.prod.outlook.com (2603:10b6:610:cd::9) by DSVPR12MB999283.namprd12.prod.outlook.com (2603:10b6:8:41c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.19; Mon, 13 Jul 2026 10:52:00 +0000 Received: from CH1PEPF0000A34C.namprd04.prod.outlook.com (2603:10b6:610:cd:cafe::8d) by CH0PR03CA0094.outlook.office365.com (2603:10b6:610:cd::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.202.19 via Frontend Transport; Mon, 13 Jul 2026 10:52:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH1PEPF0000A34C.mail.protection.outlook.com (10.167.244.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.9 via Frontend Transport; Mon, 13 Jul 2026 10:52:00 +0000 Received: from BLR-L1-SARUNKOD.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Mon, 13 Jul 2026 05:51:52 -0500 From: Sairaj Kodilkar To: "Borislav Petkov (AMD)" , "H. Peter Anvin" , "Joerg Roedel (AMD)" , "Paul E. McKenney" , Andrew Morton , Dapeng Mi , Dave Hansen , "Eric Biggers" , Feng Tang , "Ingo Molnar" , Jakub Kicinski , Jonathan Corbet , Li RongQing , Marco Elver , Paolo Bonzini , Randy Dunlap , Robin Murphy , Sairaj Kodilkar , Sean Christopherson , Shuah Khan , Suravee Suthikulpanit , Thomas Gleixner , "Vasant Hegde" , Will Deacon , , , , , Subject: [RFC PATCH v3 2/6] iommu/amd: KVM: SVM: Rename ga_log_intr to wakeup_intr in IOMMU interface Date: Mon, 13 Jul 2026 16:20:29 +0530 Message-ID: <20260713105033.15405-3-sarunkod@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260713105033.15405-1-sarunkod@amd.com> References: <20260713105033.15405-1-sarunkod@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A34C:EE_|DSVPR12MB999283:EE_ X-MS-Office365-Filtering-Correlation-Id: a7756fe9-7a4f-4371-d694-08dee0ccc437 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|23010399003|376014|7416014|82310400026|1800799024|921020|56012099006|11063799006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: Z89uihurH5BjukQwUscZ0WihPsMx9kxbVIq761a4OStccFfoxURgo0njk7l8M91c7h6yqpOjYhGz+MERTaV5BpIQrmzpRWAAvtqt1hBAsAarajaG765Kuwd0zoNRLED7rSXbUZ/jVmzHgaby1exk9FPtC0sH+MyeXFcyNPqWdoZixUQ/0H2O+4E6XAJMXacOm6GGytxvudaGuWr1ZWkQNkFiwmw1a9teNgSi8Y4z5+dF+3T3hyOF73f1Qr1cWnfBagm3Qvsmbb/rb7B1TyqxehqBPRfLVZ+N4WZlDWfNtLaA+O5rD1Nmxx76qiNxWVNUr81DkXqy6tLfvepwecoi0CrImKVolGa0fByOPQZSN7r25OTxT07BRjmcBYwGyeZAc3dHWeosJebV/cIKeomHTYXKwVZtHM0D3aTYmuu14HKDgV0g6DFKWCmp5N6v4/8mb90RD87kgyh4WGuEdhn/cnT0t3rqsKr5fgPBSeL3+zEWLd4sLFfU4D9k7Doy3T8GVYWNUwditHf4jSjH9/faGsqH7s/4cFo4k5NUK8yTPd0+oPZje6tfZ6AOmpGcDo2I/1rzCloxtjzPkyzzSvvZWSrW2fn5T+RTAgrZ6LW7Bb5bQNpg90GSzTNjxdchjUdmjf2YxOBjzpIGeES5kYM10usGQaHrKIgZjtm3ovNMh04pRus50K3T5BoZoox9IeOtlAjhd7xTVJstkGmxwcMcFMXBy+EOTUPbDb6o/FfG/vvqXLw92oGILDDSGQ0X7rtF X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(23010399003)(376014)(7416014)(82310400026)(1800799024)(921020)(56012099006)(11063799006)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UgxP4Mui2mNsf0FMz+tlgz4LXZyQAMJzaUFAR6TtgvuWP9wZ82eVKRuf0eKzm8EYii6h28F5LT7n9xFuIR2eOSz+PFadGCO+2uSfhLt+d8/mo36yyYJ8zQ2e4ENlwKx57WxYJWsEovrlBDM6gumiyCkLLli3cV9daqRhlk0KUiGHu+Ifb28aThWq5au0LRkr/BzhlUx0zp4fWLte6uNDQX8AX9lx9ssPTkBLG+v2nQAjXrWW+IWY8XDJs15o6ruPljnFwhWVhidvEhD5M0NnHSZQEVD2xDPiQqZvd1FTmmjcwiUGjCuLNAU5vqSunFEEgdtHnbmHJF3AxQ5KpjctzWgryp4ANuvlHOLh/xCVwIXMJx8V8mvAr6gK6QBoPRMx1ZdRVyJGnYIa0lJE7L2O+XIZbNmBf284dDYD22gy0LjZr8u3p9UP6mcZVT1msrO+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2026 10:52:00.2803 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7756fe9-7a4f-4371-d694-08dee0ccc437 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000A34C.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DSVPR12MB999283 Content-Type: text/plain; charset="utf-8" When AVIC is enabled, device interrupts are posted into the guest virtual APIC backing page regardless of vCPU running state. When the vCPU is not running, KVM may additionally need the IOMMU to notify the host so the vCPU can be woken, historically via the GA log mechanism. The existing ga_log_intr name is tied to one specific hardware mechanism. Guest APIC Physical Processor Interrupt (GAPPI) provides an alternative host-notification path when the vCPU is not running, i.e., IRTE[IsRun] =3D = 0. The KVM-side intent is the same in both cases: request host wakeup notification while the vCPU is blocked. Rename ga_log_intr to wakeup_intr in the IOMMU API to describe KVM's intent rather than a single hardware knob. The IOMMU driver still maps wakeup_intr to IRTE[GALogIntr] in this patch; GAPPI support is added in following patches. Similarly rename the synthetic AVIC physical ID table shadow bit from AVIC_PHYSICAL_ID_ENTRY_GA_LOG_INTR to AVIC_PHYSICAL_ID_ENTRY_WAKEUP_INTR. No functional change is intended. Signed-off-by: Sairaj Kodilkar --- arch/x86/include/asm/irq_remapping.h | 2 +- arch/x86/include/asm/svm.h | 9 +++++---- arch/x86/kvm/svm/avic.c | 26 +++++++++++++------------- drivers/iommu/amd/iommu.c | 16 ++++++++-------- include/linux/amd-iommu.h | 8 ++++---- 5 files changed, 31 insertions(+), 30 deletions(-) diff --git a/arch/x86/include/asm/irq_remapping.h b/arch/x86/include/asm/ir= q_remapping.h index 263f4df429d8..789e3e154600 100644 --- a/arch/x86/include/asm/irq_remapping.h +++ b/arch/x86/include/asm/irq_remapping.h @@ -36,7 +36,7 @@ struct amd_iommu_pi_data { u32 ga_tag; u32 vector; /* Guest vector of the interrupt */ int apicid; - bool ga_log_intr; + bool wakeup_intr; bool is_guest_mode; void *ir_data; }; diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index bcfeb5e7c0ed..add8b7274cc2 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -259,11 +259,12 @@ struct __attribute__ ((__packed__)) vmcb_control_area= { #define AVIC_LOGICAL_ID_ENTRY_VALID_MASK (1 << 31) =20 /* - * GA_LOG_INTR is a synthetic flag that's never propagated to hardware-vis= ible - * tables. GA_LOG_INTR is set if the vCPU needs device posted IRQs to gen= erate - * GA log interrupts to wake the vCPU (because it's blocking or about to b= lock). + * WAKEUP_INTR is a synthetic flag that's never propagated to hardware-vis= ible + * tables. WAKEUP_INTR is set if the vCPU needs device posted IRQs to gen= erate + * GA log/GAPPI interrupts to wake the vCPU (because it's blocking or abou= t to + * block). */ -#define AVIC_PHYSICAL_ID_ENTRY_GA_LOG_INTR BIT_ULL(61) +#define AVIC_PHYSICAL_ID_ENTRY_WAKEUP_INTR BIT_ULL(61) =20 #define AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK GENMASK_ULL(11, 0) #define AVIC_PHYSICAL_ID_ENTRY_BACKING_PAGE_MASK GENMASK_ULL(51, 12) diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c index bccc5d7ed207..8e87a7f2f64f 100644 --- a/arch/x86/kvm/svm/avic.c +++ b/arch/x86/kvm/svm/avic.c @@ -952,7 +952,7 @@ int avic_pi_update_irte(struct kvm_kernel_irqfd *irqfd,= struct kvm *kvm, pi_data.apicid =3D entry & AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK; } else { pi_data.apicid =3D -1; - pi_data.ga_log_intr =3D entry & AVIC_PHYSICAL_ID_ENTRY_GA_LOG_INTR; + pi_data.wakeup_intr =3D entry & AVIC_PHYSICAL_ID_ENTRY_WAKEUP_INTR; } =20 ret =3D irq_set_vcpu_affinity(host_irq, &pi_data); @@ -991,15 +991,15 @@ enum avic_vcpu_action { * No unique action is required to deal with a vCPU that stops/starts * running. A vCPU that starts running by definition stops blocking as * well, and a vCPU that stops running can't have been blocking, i.e. - * doesn't need to toggle GALogIntr. + * doesn't need to toggle host wakeup notification. */ AVIC_START_RUNNING =3D 0, AVIC_STOP_RUNNING =3D 0, =20 /* - * When a vCPU starts blocking, KVM needs to set the GALogIntr flag - * int all associated IRTEs so that KVM can wake the vCPU if an IRQ is - * sent to the vCPU. + * When a vCPU starts blocking, KVM needs to request host wakeup + * notification in all associated IRTEs so that KVM can wake the vCPU + * if an IRQ is sent to the vCPU. */ AVIC_START_BLOCKING =3D BIT(1), }; @@ -1007,7 +1007,7 @@ enum avic_vcpu_action { static void avic_update_iommu_vcpu_affinity(struct kvm_vcpu *vcpu, int api= cid, enum avic_vcpu_action action) { - bool ga_log_intr =3D (action & AVIC_START_BLOCKING); + bool wakeup_intr =3D (action & AVIC_START_BLOCKING); struct vcpu_svm *svm =3D to_svm(vcpu); struct kvm_kernel_irqfd *irqfd; =20 @@ -1024,9 +1024,9 @@ static void avic_update_iommu_vcpu_affinity(struct kv= m_vcpu *vcpu, int apicid, void *data =3D irqfd->irq_bypass_data; =20 if (!(action & AVIC_TOGGLE_ON_OFF)) - WARN_ON_ONCE(amd_iommu_update_ga(data, apicid, ga_log_intr)); + WARN_ON_ONCE(amd_iommu_update_ga(data, apicid, wakeup_intr)); else if (apicid >=3D 0) - WARN_ON_ONCE(amd_iommu_activate_guest_mode(data, apicid, ga_log_intr)); + WARN_ON_ONCE(amd_iommu_activate_guest_mode(data, apicid, wakeup_intr)); else WARN_ON_ONCE(amd_iommu_deactivate_guest_mode(data)); } @@ -1063,7 +1063,7 @@ static void __avic_vcpu_load(struct kvm_vcpu *vcpu, i= nt cpu, WARN_ON_ONCE(entry & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK); =20 entry &=3D ~(AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK | - AVIC_PHYSICAL_ID_ENTRY_GA_LOG_INTR); + AVIC_PHYSICAL_ID_ENTRY_WAKEUP_INTR); entry |=3D (h_physical_id & AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK); entry |=3D AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK; =20 @@ -1125,7 +1125,7 @@ static void __avic_vcpu_put(struct kvm_vcpu *vcpu, en= um avic_vcpu_action action) =20 avic_update_iommu_vcpu_affinity(vcpu, -1, action); =20 - WARN_ON_ONCE(entry & AVIC_PHYSICAL_ID_ENTRY_GA_LOG_INTR); + WARN_ON_ONCE(entry & AVIC_PHYSICAL_ID_ENTRY_WAKEUP_INTR); =20 /* * Keep the previous APIC ID in the entry so that a rogue doorbell from @@ -1137,11 +1137,11 @@ static void __avic_vcpu_put(struct kvm_vcpu *vcpu, = enum avic_vcpu_action action) WRITE_ONCE(kvm_svm->avic_physical_id_table[vcpu->vcpu_id], entry); =20 /* - * Note! Don't set AVIC_PHYSICAL_ID_ENTRY_GA_LOG_INTR in the table as + * Note! Don't set AVIC_PHYSICAL_ID_ENTRY_WAKEUP_INTR in the table as * it's a synthetic flag that usurps an unused should-be-zero bit. */ if (action & AVIC_START_BLOCKING) - entry |=3D AVIC_PHYSICAL_ID_ENTRY_GA_LOG_INTR; + entry |=3D AVIC_PHYSICAL_ID_ENTRY_WAKEUP_INTR; =20 svm->avic_physical_id_entry =3D entry; =20 @@ -1173,7 +1173,7 @@ void avic_vcpu_put(struct kvm_vcpu *vcpu) * The vCPU was preempted while blocking, ensure its IRTEs are * configured to generate GA Log Interrupts. */ - if (!(WARN_ON_ONCE(!(entry & AVIC_PHYSICAL_ID_ENTRY_GA_LOG_INTR)))) + if (!(WARN_ON_ONCE(!(entry & AVIC_PHYSICAL_ID_ENTRY_WAKEUP_INTR)))) return; } =20 diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index c0cf7799c56e..1284f37e44c7 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -3960,7 +3960,7 @@ static const struct irq_domain_ops amd_ir_domain_ops = =3D { }; =20 static void __amd_iommu_update_ga(struct irte_ga *entry, int apicid, - bool ga_log_intr) + bool wakeup_intr) { if (apicid >=3D 0) { entry->lo.fields_vapic.destination =3D @@ -3971,7 +3971,7 @@ static void __amd_iommu_update_ga(struct irte_ga *ent= ry, int apicid, entry->lo.fields_vapic.ga_log_intr =3D false; } else { entry->lo.fields_vapic.is_run =3D false; - entry->lo.fields_vapic.ga_log_intr =3D ga_log_intr; + entry->lo.fields_vapic.ga_log_intr =3D wakeup_intr; } } =20 @@ -3982,7 +3982,7 @@ static void __amd_iommu_update_ga(struct irte_ga *ent= ry, int apicid, * If the vCPU is associated with a pCPU (@apicid >=3D 0), configure the * Destination with the pCPU's APIC ID, set IsRun, and clear GALogIntr. I= f the * vCPU isn't associated with a pCPU (@apicid < 0), clear IsRun and set/cl= ear - * GALogIntr based on input from the caller (e.g. KVM only requests GALogI= ntr + * GALogIntr based on input from the caller (e.g. KVM only requests wakeup= _intr * when the vCPU is blocking and requires a notification wake event). I.e. * treat vCPUs that are associated with a pCPU as running. This API is * intended to be used when a vCPU is scheduled in/out (or stops running f= or @@ -3993,7 +3993,7 @@ static void __amd_iommu_update_ga(struct irte_ga *ent= ry, int apicid, * and thus don't require an invalidation to ensure the IOMMU consumes fre= sh * information. */ -int amd_iommu_update_ga(void *data, int apicid, bool ga_log_intr) +int amd_iommu_update_ga(void *data, int apicid, bool wakeup_intr) { struct amd_ir_data *ir_data =3D (struct amd_ir_data *)data; struct irte_ga *entry =3D (struct irte_ga *) ir_data->entry; @@ -4007,14 +4007,14 @@ int amd_iommu_update_ga(void *data, int apicid, boo= l ga_log_intr) if (!ir_data->iommu) return -ENODEV; =20 - __amd_iommu_update_ga(entry, apicid, ga_log_intr); + __amd_iommu_update_ga(entry, apicid, wakeup_intr); =20 return __modify_irte_ga(ir_data->iommu, ir_data->irq_2_irte.devid, ir_data->irq_2_irte.index, entry); } EXPORT_SYMBOL(amd_iommu_update_ga); =20 -int amd_iommu_activate_guest_mode(void *data, int apicid, bool ga_log_intr) +int amd_iommu_activate_guest_mode(void *data, int apicid, bool wakeup_intr) { struct amd_ir_data *ir_data =3D (struct amd_ir_data *)data; struct irte_ga *entry =3D (struct irte_ga *) ir_data->entry; @@ -4037,7 +4037,7 @@ int amd_iommu_activate_guest_mode(void *data, int api= cid, bool ga_log_intr) entry->hi.fields.vector =3D ir_data->ga_vector; entry->lo.fields_vapic.ga_tag =3D ir_data->ga_tag; =20 - __amd_iommu_update_ga(entry, apicid, ga_log_intr); + __amd_iommu_update_ga(entry, apicid, wakeup_intr); =20 return modify_irte_ga(ir_data->iommu, ir_data->irq_2_irte.devid, ir_data->irq_2_irte.index, entry); @@ -4109,7 +4109,7 @@ static int amd_ir_set_vcpu_affinity(struct irq_data *= data, void *info) ir_data->ga_tag =3D pi_data->ga_tag; if (pi_data->is_guest_mode) ret =3D amd_iommu_activate_guest_mode(ir_data, pi_data->apicid, - pi_data->ga_log_intr); + pi_data->wakeup_intr); else ret =3D amd_iommu_deactivate_guest_mode(ir_data); } else { diff --git a/include/linux/amd-iommu.h b/include/linux/amd-iommu.h index 2c6232aefafa..e20c909edc56 100644 --- a/include/linux/amd-iommu.h +++ b/include/linux/amd-iommu.h @@ -30,8 +30,8 @@ static inline void amd_iommu_detect(void) { } /* IOMMU AVIC Function */ extern int amd_iommu_register_ga_log_notifier(int (*notifier)(u32)); =20 -extern int amd_iommu_update_ga(void *data, int apicid, bool ga_log_intr); -extern int amd_iommu_activate_guest_mode(void *data, int apicid, bool ga_l= og_intr); +extern int amd_iommu_update_ga(void *data, int apicid, bool wakeup_intr); +extern int amd_iommu_activate_guest_mode(void *data, int apicid, bool wake= up_intr); extern int amd_iommu_deactivate_guest_mode(void *data); =20 #else /* defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) */ @@ -42,12 +42,12 @@ amd_iommu_register_ga_log_notifier(int (*notifier)(u32)) return 0; } =20 -static inline int amd_iommu_update_ga(void *data, int apicid, bool ga_log_= intr) +static inline int amd_iommu_update_ga(void *data, int apicid, bool wakeup_= intr) { return 0; } =20 -static inline int amd_iommu_activate_guest_mode(void *data, int apicid, bo= ol ga_log_intr) +static inline int amd_iommu_activate_guest_mode(void *data, int apicid, bo= ol wakeup_intr) { return 0; } --=20 2.34.1 From nobody Sat Jul 25 22:03:05 2026 Received: from PH0PR06CU001.outbound.protection.outlook.com (mail-westus3azon11011044.outbound.protection.outlook.com [40.107.208.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 940BD3E6DD2; Mon, 13 Jul 2026 10:52:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.208.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783939957; cv=fail; b=czydlSGm9hhrfUwJyRz4sSOK/BDuEqfcRMBlthA1fbJ2Nk+0PHaFdQbgjZA56SEkODK0Q0XBTs4IPMCGuvGKvvfMSMKaEMnMz3fHVaodEkl4b2wimc8jzvdKRRr1PDFzsm6jFsKn26asBcePZI65eBHSFCL6qi4XjuR5QRvcEKI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783939957; c=relaxed/simple; bh=Jka5b2D+GVzr4xCyUpo6JnXbJPLBQu4rDxHDv5kfXXg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cmEmmFJAmxOHs7vOwj/f1kfazP8Hyx0IPtEq/XbEelN/CBQBxIR1euaZsDg3fZRtdeWCRIR+0PH+isJdM8ER0AjfElw7cIU+eQFvwlCSjqb31ov7EZwzPxjK/VVHGbLkRdyMMem/uLBhS/2BVgHIu7ptvUrpFGqY5T03zc+d124= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=o0sqAcHg; arc=fail smtp.client-ip=40.107.208.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="o0sqAcHg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fgl3kSbStKs8bjlm/4wGOweQ1kXuf27R9M6WfToOAyu/9leFj2VSgDxDnc2StB8gz2OHyLxSGvcJnyj+hmXYhfmjR6MUxfHHXAxIRzghu24r85rB268z20JcLKMN0Lq3OFbdyun5JYxYewHruoRFX3A/PzPgmve5Vk5tM5w9BbeHqhx8CQ90kQW/qy98K3qcjqeEdfyJcGl7rMKZ2n+wBGsp6FOkKL3FALHAvdulG4+dAuYDF3IPCILgvc67Ze/+26SwOkhoK05Es3Cf4mSbJKXz50ggbhhemFWEKR5M4dRDNPj+kkmmMVVVJPUG6kRXY8dtZpROJQuuPXx28xn4rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Fl9B6nrSMzh+1g9/H128efocsy/zMtuil9FfIZIXy30=; b=scxSKcYJ1KzKyVON890gumtDubOCYMsLZzXVIBeQ50BUH+LDCdYA8cVQ5QYynFR6ne/OxZxSweoubpAMhvFUo60RySS7UElfl4tYF6m29B2k/+YIKY8ALUz1OMdhwwg4dfBAKAc5AqyueXv0qoTO33KbHpiVit3WvMa59Xgh+yo+heXgP6QsUEATC1I1ZvR0obFQ+YafKtv5PSetFK5pl/zSE1bh6b/HsNjqAmpUxe3XCpgkCg3i74HNfO3axo8t1Xqfxh/Y0MQShNqBlTn/PAeJXghdf2C7/gAZQc5dVq603rZcjlzo1EGLRZxlR1ehtu2ZkUGv/qQfHHHIL43czA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fl9B6nrSMzh+1g9/H128efocsy/zMtuil9FfIZIXy30=; b=o0sqAcHgBAKl4pii/oqTN53jVIZJi9r2px7twzTN4RFjMsI3qYjL/Rr7WJvBu/Wt9KFf9wWtpZ/A//3sbkuKNdJ+5hUAivbuf0agW0g1J5reFObm7HWYeUTl9ONK78OUijB+3MkaNjZh7WmCFGSty3ObB7NbVkWe37OzSIiQqEM= Received: from CH2PR03CA0029.namprd03.prod.outlook.com (2603:10b6:610:59::39) by PH7PR12MB6442.namprd12.prod.outlook.com (2603:10b6:510:1fa::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.18; Mon, 13 Jul 2026 10:52:22 +0000 Received: from CH1PEPF0000A348.namprd04.prod.outlook.com (2603:10b6:610:59:cafe::9c) by CH2PR03CA0029.outlook.office365.com (2603:10b6:610:59::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.19 via Frontend Transport; Mon, 13 Jul 2026 10:52:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH1PEPF0000A348.mail.protection.outlook.com (10.167.244.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.9 via Frontend Transport; Mon, 13 Jul 2026 10:52:21 +0000 Received: from BLR-L1-SARUNKOD.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Mon, 13 Jul 2026 05:52:13 -0500 From: Sairaj Kodilkar To: "Borislav Petkov (AMD)" , "H. Peter Anvin" , "Joerg Roedel (AMD)" , "Paul E. McKenney" , Andrew Morton , Dapeng Mi , Dave Hansen , "Eric Biggers" , Feng Tang , "Ingo Molnar" , Jakub Kicinski , Jonathan Corbet , Li RongQing , Marco Elver , Paolo Bonzini , Randy Dunlap , Robin Murphy , Sairaj Kodilkar , Sean Christopherson , Shuah Khan , Suravee Suthikulpanit , Thomas Gleixner , "Vasant Hegde" , Will Deacon , , , , , Subject: [RFC PATCH v3 3/6] iommu/amd: KVM: SVM: Add explicit vCPU running state to IOMMU interface Date: Mon, 13 Jul 2026 16:20:30 +0530 Message-ID: <20260713105033.15405-4-sarunkod@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260713105033.15405-1-sarunkod@amd.com> References: <20260713105033.15405-1-sarunkod@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A348:EE_|PH7PR12MB6442:EE_ X-MS-Office365-Filtering-Correlation-Id: deff4bb8-7b8c-4a50-c995-08dee0ccd0d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|82310400026|23010399003|7416014|376014|18002099003|22082099003|56012099006|11063799006|921020; X-Microsoft-Antispam-Message-Info: PyboclhpgLlZusg98kxEnGdRXCSHujGY3OF9kkke4cK84cRZn9BUqPsLwMnStV3BVZqQKosFBjvkdzgnSAPOXJJ1b2GvLit1m6bpj2FLrRSboOxNQ6tg32cEk11UVyvOJrRb8JtN/AfkE/H3CM1APcN8zqAH5Rtk8hL7Q4kSH5lvvSgTRDs45dOnVrr2C89SjXLylc2DUAuRalzwAL/j5w8l2ubta/45czU+HAaY94XbCZVKr831uQ6TQGDf+BjMQvQCZYaf4Y52M6VNm/pSQcAXFXIA+zi7i2jAswmm1LA6Q1ZlGcUfrEiw/HvBSJ5IGddb9KtXuKIf50EwTmNhbLibchqB4u4Lme+PHITLzgiLCt0YnfOF8tD/hlgeUPRK1Pqv/ElzD/LfnqJcR4SNvF0EZDNmN7DgYbAQ9kKCQSvMlYoH70x/cY71xJK1wXxBVAUzug7wdbHXBNE7/IHt9Mf1ucSIWgXCobfieeMtnVAdeeKWKtKwg7keDq+SOaGowWYH7k9/u9/iWDFD5edK9Uaj38HKqd5iVjwc7nRN1MFG/nKUSBEARl7Kc5RTTMdvyJ2BKxEDnClyfXxVXvYs1SZvca9QdMZHdSAnThdtjLwBjrsXsxmICx6haO/Ho2y1yLS3SsRHSnxJGWzp/alz9/sIU6CdVRq87xxkolbpfALn9nxrv5F5jS3qyaWgrHu2bYhECsV2A2HvapYeCzWbooAtdZE5lUQRMn7EQFdqzW2xDsMIe4bkjwzNzhE8oz8W X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(82310400026)(23010399003)(7416014)(376014)(18002099003)(22082099003)(56012099006)(11063799006)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jyckrBYFrEAzqQf06/0WP+07EvbBPf3EPWJWkYQsJdEv+AZs23lwjpKvRNT0kFEySMMipv5DrfYv+zeW9uIWWbivP/E7o5KkF5iAByqzGginuNrQXTo79mEe/KK2cEoydq+ubnkxwvuj7R2rpTiu+eg0ZCEfzhfV18lzgXPctF1GbTa+TSzxHnDGXTijOP9ZYC0aypsQfms2+bVACm4H6C9vsqjUtXRV3DPOLKS5xApq+2v29Qeb8Orl1sia4gJFpnR2bADCgCGESFgxLkJlhjDUNsR14LLAaWzqzLVdCWBPlRj3ffV4NQqErXptNvSGWbqyqCNwqmt02fWP9N3x9XumP2QiHrBfKwa1zROQC79meWnwtu4qOa+LpiqPblxN60v9OalooK+vLNm/TfItq8YiIpUuFuBJTyBULg6TsGjpJYqqzYRGDNYJ8NeN38BA X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2026 10:52:21.4204 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: deff4bb8-7b8c-4a50-c995-08dee0ccd0d1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000A348.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6442 Content-Type: text/plain; charset="utf-8" Guest APIC Physical Processor Interrupt (GAPPI) is an AMD IOMMU mechanism for notifying the host when a device interrupt targets a non-running vCPU (IRTE[IsRun] =3D 0). Unlike the GA log path, GAPPI delivers a physical APIC interrupt directly to the host CPU described by IRTE[Destination], with the vector carried in IRTE[GATag], while still posting the interrupt into the guest virtual APIC backing page as usual. In GAPPI mode, the IOMMU delivers the notification to the host CPU using the physical APIC ID in IRTE[Destination] and the vector in IRTE[GATag]. KVM must therefore supply a valid apicid even when the vCPU is not running. The prior interface inferred running state from apicid: apicid >=3D 0 meant running and apicid =3D=3D -1 meant not running. That encoding breaks once apicid carries the GAPPI destination while the vCPU is not running; the IOMMU driver can no longer derive vCPU running state from apicid alone and needs an explicit indication from KVM. Add an explicit is_running indication to the IOMMU interface so that SVM can pass vCPU running state to the IOMMU. No functional change is intended. Signed-off-by: Sairaj Kodilkar --- arch/x86/include/asm/irq_remapping.h | 1 + arch/x86/kvm/svm/avic.c | 10 +++++++--- drivers/iommu/amd/iommu.c | 26 +++++++++++++------------- include/linux/amd-iommu.h | 12 ++++++++---- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/arch/x86/include/asm/irq_remapping.h b/arch/x86/include/asm/ir= q_remapping.h index 789e3e154600..af0cdfa32c44 100644 --- a/arch/x86/include/asm/irq_remapping.h +++ b/arch/x86/include/asm/irq_remapping.h @@ -37,6 +37,7 @@ struct amd_iommu_pi_data { u32 vector; /* Guest vector of the interrupt */ int apicid; bool wakeup_intr; + bool is_running; bool is_guest_mode; void *ir_data; }; diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c index 8e87a7f2f64f..3b2d92a58709 100644 --- a/arch/x86/kvm/svm/avic.c +++ b/arch/x86/kvm/svm/avic.c @@ -950,9 +950,11 @@ int avic_pi_update_irte(struct kvm_kernel_irqfd *irqfd= , struct kvm *kvm, entry =3D svm->avic_physical_id_entry; if (entry & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK) { pi_data.apicid =3D entry & AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK; + pi_data.is_running =3D true; } else { pi_data.apicid =3D -1; pi_data.wakeup_intr =3D entry & AVIC_PHYSICAL_ID_ENTRY_WAKEUP_INTR; + pi_data.is_running =3D false; } =20 ret =3D irq_set_vcpu_affinity(host_irq, &pi_data); @@ -1008,6 +1010,7 @@ static void avic_update_iommu_vcpu_affinity(struct kv= m_vcpu *vcpu, int apicid, enum avic_vcpu_action action) { bool wakeup_intr =3D (action & AVIC_START_BLOCKING); + bool is_running =3D apicid >=3D 0; struct vcpu_svm *svm =3D to_svm(vcpu); struct kvm_kernel_irqfd *irqfd; =20 @@ -1024,9 +1027,10 @@ static void avic_update_iommu_vcpu_affinity(struct k= vm_vcpu *vcpu, int apicid, void *data =3D irqfd->irq_bypass_data; =20 if (!(action & AVIC_TOGGLE_ON_OFF)) - WARN_ON_ONCE(amd_iommu_update_ga(data, apicid, wakeup_intr)); - else if (apicid >=3D 0) - WARN_ON_ONCE(amd_iommu_activate_guest_mode(data, apicid, wakeup_intr)); + WARN_ON_ONCE(amd_iommu_update_ga(data, apicid, wakeup_intr, is_running)= ); + else if (is_running) + WARN_ON_ONCE(amd_iommu_activate_guest_mode(data, apicid, wakeup_intr, + is_running)); else WARN_ON_ONCE(amd_iommu_deactivate_guest_mode(data)); } diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 1284f37e44c7..91405e71b3c3 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -3960,9 +3960,9 @@ static const struct irq_domain_ops amd_ir_domain_ops = =3D { }; =20 static void __amd_iommu_update_ga(struct irte_ga *entry, int apicid, - bool wakeup_intr) + bool wakeup_intr, bool is_running) { - if (apicid >=3D 0) { + if (is_running) { entry->lo.fields_vapic.destination =3D APICID_TO_IRTE_DEST_LO(apicid); entry->hi.fields.destination =3D @@ -3979,12 +3979,11 @@ static void __amd_iommu_update_ga(struct irte_ga *e= ntry, int apicid, * Update the pCPU information for an IRTE that is configured to post IRQs= to * a vCPU, without issuing an IOMMU invalidation for the IRTE. * - * If the vCPU is associated with a pCPU (@apicid >=3D 0), configure the - * Destination with the pCPU's APIC ID, set IsRun, and clear GALogIntr. I= f the - * vCPU isn't associated with a pCPU (@apicid < 0), clear IsRun and set/cl= ear - * GALogIntr based on input from the caller (e.g. KVM only requests wakeup= _intr - * when the vCPU is blocking and requires a notification wake event). I.e. - * treat vCPUs that are associated with a pCPU as running. This API is + * If the vCPU is scheduled to run on pCPU (@is_running =3D 1), configure = the + * Destination with the pCPU's APIC ID, set IsRun, and clear GALogIntr. If= the + * vCPU is scheduled out (@is_running =3D 0), clear IsRun and set/clear GA= LogIntr + * based on input from the caller (e.g. KVM only requests wakeup_intr when= the + * vCPU is blocking and requires a notification wake event). This API is * intended to be used when a vCPU is scheduled in/out (or stops running f= or * any reason), to do a fast update of IsRun, GALogIntr, and (conditionall= y) * Destination. @@ -3993,7 +3992,7 @@ static void __amd_iommu_update_ga(struct irte_ga *ent= ry, int apicid, * and thus don't require an invalidation to ensure the IOMMU consumes fre= sh * information. */ -int amd_iommu_update_ga(void *data, int apicid, bool wakeup_intr) +int amd_iommu_update_ga(void *data, int apicid, bool wakeup_intr, bool is_= running) { struct amd_ir_data *ir_data =3D (struct amd_ir_data *)data; struct irte_ga *entry =3D (struct irte_ga *) ir_data->entry; @@ -4007,14 +4006,14 @@ int amd_iommu_update_ga(void *data, int apicid, boo= l wakeup_intr) if (!ir_data->iommu) return -ENODEV; =20 - __amd_iommu_update_ga(entry, apicid, wakeup_intr); + __amd_iommu_update_ga(entry, apicid, wakeup_intr, is_running); =20 return __modify_irte_ga(ir_data->iommu, ir_data->irq_2_irte.devid, ir_data->irq_2_irte.index, entry); } EXPORT_SYMBOL(amd_iommu_update_ga); =20 -int amd_iommu_activate_guest_mode(void *data, int apicid, bool wakeup_intr) +int amd_iommu_activate_guest_mode(void *data, int apicid, bool wakeup_intr= , bool is_running) { struct amd_ir_data *ir_data =3D (struct amd_ir_data *)data; struct irte_ga *entry =3D (struct irte_ga *) ir_data->entry; @@ -4037,7 +4036,7 @@ int amd_iommu_activate_guest_mode(void *data, int api= cid, bool wakeup_intr) entry->hi.fields.vector =3D ir_data->ga_vector; entry->lo.fields_vapic.ga_tag =3D ir_data->ga_tag; =20 - __amd_iommu_update_ga(entry, apicid, wakeup_intr); + __amd_iommu_update_ga(entry, apicid, wakeup_intr, is_running); =20 return modify_irte_ga(ir_data->iommu, ir_data->irq_2_irte.devid, ir_data->irq_2_irte.index, entry); @@ -4109,7 +4108,8 @@ static int amd_ir_set_vcpu_affinity(struct irq_data *= data, void *info) ir_data->ga_tag =3D pi_data->ga_tag; if (pi_data->is_guest_mode) ret =3D amd_iommu_activate_guest_mode(ir_data, pi_data->apicid, - pi_data->wakeup_intr); + pi_data->wakeup_intr, + pi_data->is_running); else ret =3D amd_iommu_deactivate_guest_mode(ir_data); } else { diff --git a/include/linux/amd-iommu.h b/include/linux/amd-iommu.h index e20c909edc56..e962ad511d04 100644 --- a/include/linux/amd-iommu.h +++ b/include/linux/amd-iommu.h @@ -30,8 +30,10 @@ static inline void amd_iommu_detect(void) { } /* IOMMU AVIC Function */ extern int amd_iommu_register_ga_log_notifier(int (*notifier)(u32)); =20 -extern int amd_iommu_update_ga(void *data, int apicid, bool wakeup_intr); -extern int amd_iommu_activate_guest_mode(void *data, int apicid, bool wake= up_intr); +extern int amd_iommu_update_ga(void *data, int apicid, bool wakeup_intr, + bool is_running); +extern int amd_iommu_activate_guest_mode(void *data, int apicid, bool wake= up_intr, + bool is_running); extern int amd_iommu_deactivate_guest_mode(void *data); =20 #else /* defined(CONFIG_AMD_IOMMU) && defined(CONFIG_IRQ_REMAP) */ @@ -42,12 +44,14 @@ amd_iommu_register_ga_log_notifier(int (*notifier)(u32)) return 0; } =20 -static inline int amd_iommu_update_ga(void *data, int apicid, bool wakeup_= intr) +static inline int amd_iommu_update_ga(void *data, int apicid, bool wakeup_= intr, + bool is_running) { return 0; } =20 -static inline int amd_iommu_activate_guest_mode(void *data, int apicid, bo= ol wakeup_intr) +static inline int amd_iommu_activate_guest_mode(void *data, int apicid, bo= ol wakeup_intr, + bool is_running) { return 0; } --=20 2.34.1 From nobody Sat Jul 25 22:03:05 2026 Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012025.outbound.protection.outlook.com [40.107.209.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B88E0367B7B; Mon, 13 Jul 2026 10:52:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.209.25 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783939978; cv=fail; b=ooXOumHtyKB35kbsLJI8j8LYBi3QW3Q8KwAwFBrl6p1H9ZYjH0SG6sWa/e77+j+k0bL78oJTR+j5Bn4c+ab6MIG24YVJS1Z1q9xZT76Q4bLmXhD+/Uqacw8LOAML6RWbwreUGFYD06vp/dnM6BIvGjbX/LmVWKL8Ukjc+Wh5bUE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783939978; c=relaxed/simple; bh=sJ6LG8nKOw7dk378+ogBlpnR1Fy5tm6bhAaupTUoPIw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h+h0elJpMV9CyjJ0h53VbTXZh/V+Y8hAUjsLN7Tv+/kFHg2qzyBYiMwrnDfacJsuQLG751ChQlIakTTJ8aKD0pXrWT3Xe5eCylfPGzclHCWGpMkInvTYGBgsoz90yKd/zxXOQBzXwBRFi92LyX63chffN1P73AQYJ1UwEZmNqgQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=TobWfDy9; arc=fail smtp.client-ip=40.107.209.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="TobWfDy9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fvUjeBWciew/+PLI/ktDzk0/VOEy5H9daU52RlbjgkGMePYg7zOlXFBsrrzL4TB7xXoiLkD6tq9PcjvBoVkkKfpA82giySFnrOT4VKeZmjC2MoesHmsPCkfvjX6aDCEH1pLVZ6G7Eqbvy0cF0xEU8i3FayAkHbWMRossJOL+6ipCvv0mhtOfDEL/gQ4NkQe988grXtrGnyU2kXUsOw97FMlOPE4BIjNEENfqeNsKIAgFkKiLaPnBoxc6oWzrMGDl5jQGFFhfQMrJiXbvmL/7h4GPxC106qhmg1Ktc9xlBTvJJpf+HoYs5zBSWNyUGluAWbxKnbbM83a08MJdQZspKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JBrQ8f5qVH0zwy/a2Zvs6licIQ2zKMB6DUz6mgCKhmA=; b=Dp7IBtL5unJ9qv5OLdpRA2qzpD0fqKgyCkudM49tgWxNAdMU4qS4v17QIASBgJrpfLNK0yXJMZUEt8K4eifoks4RsJ0IcSTKYXClrR7ezcgucBjpqGndHd2TCBKEmp13f9bKpSnAztgQgbxICbksmpMc76wnOODZCeiW9W47182JyvML4mxeahQO/wrrK5uJ1st6L1Q3w6BKGgSuzuW+2kf9NA1TMRWu/rgcZEldq1iTQ+QiS/nfEXHXjUEeSTdiYgzMrmkuvlPyYVvzDbT7SFbmMREkn6jTlMclhziiM6DtjVq8SLrkuQvY6uP0LOnuzrrasrfRaLLW6lh7rXkW1w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JBrQ8f5qVH0zwy/a2Zvs6licIQ2zKMB6DUz6mgCKhmA=; b=TobWfDy911apsaK9dvunu0BYGwhBFegzkC3a8Tg9IuNKTsdWL/rbBiRfQlz6TwWskL6xGxZJn5T8I5NSNWE3RC5LYHkQ+omTCWTZLe3VXWV3qi4jA09HfTO1PZQXjmhFsztX1JBK2onmmTM9CJCEoztmcn+TsX4TqQYa2sRO5Z0= Received: from CH2PR02CA0014.namprd02.prod.outlook.com (2603:10b6:610:4e::24) by BL1PR12MB5874.namprd12.prod.outlook.com (2603:10b6:208:396::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.18; Mon, 13 Jul 2026 10:52:47 +0000 Received: from CH1PEPF0000A34A.namprd04.prod.outlook.com (2603:10b6:610:4e:cafe::ad) by CH2PR02CA0014.outlook.office365.com (2603:10b6:610:4e::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.202.19 via Frontend Transport; Mon, 13 Jul 2026 10:52:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH1PEPF0000A34A.mail.protection.outlook.com (10.167.244.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.9 via Frontend Transport; Mon, 13 Jul 2026 10:52:47 +0000 Received: from BLR-L1-SARUNKOD.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Mon, 13 Jul 2026 05:52:39 -0500 From: Sairaj Kodilkar To: "Borislav Petkov (AMD)" , "H. Peter Anvin" , "Joerg Roedel (AMD)" , "Paul E. McKenney" , Andrew Morton , Dapeng Mi , Dave Hansen , "Eric Biggers" , Feng Tang , "Ingo Molnar" , Jakub Kicinski , Jonathan Corbet , Li RongQing , Marco Elver , Paolo Bonzini , Randy Dunlap , Robin Murphy , Sairaj Kodilkar , Sean Christopherson , Shuah Khan , Suravee Suthikulpanit , Thomas Gleixner , "Vasant Hegde" , Will Deacon , , , , , Subject: [RFC PATCH v3 4/6] iommu/amd: Program guest-mode IRTEs for GAPPI wakeup when IRTE[IsRun] = 0 Date: Mon, 13 Jul 2026 16:20:31 +0530 Message-ID: <20260713105033.15405-5-sarunkod@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260713105033.15405-1-sarunkod@amd.com> References: <20260713105033.15405-1-sarunkod@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A34A:EE_|BL1PR12MB5874:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b998913-0078-40d5-0bc4-08dee0cce05a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|82310400026|23010399003|7416014|376014|18002099003|22082099003|56012099006|11063799006|13003099007|921020; X-Microsoft-Antispam-Message-Info: RYkDBMAyP9+IZ00gX9CTFwVzqB7Cga9hK/4K70xQYoAc4QYKOi8oO3HGj1T/iiG1gBmBv64s8A30o9VV7CZKY/bVulFjpv14nJsHAemY4CfmbGrZH/7egpyvj/bfKLjzbGphHn0W5exxvKGROlImo1CoQ54xMsX2yAEF76NwAlOwvbyrGNYEuVUy5Y91pJKyW3Cfvpmm8zGQYlofPbTn/YDIr1UohJJLMNMfr8BwgNQegp2k2cOEHItpCS+rfkY48aIQHrpuZ7oQSW1rUa+ub/vMwn7uNfsUjPwMHZRxQW6RvLvPYVeRwxq4scAE798vJzFcMuz8FZhaDc4FweVoTRHnsw10S6UxMVeBgGb42YB3ZebX6ej8MvIdDbmDcD9nlP6gm1FVEUE+cc0mxz61PXFf7Bd+GfDbT9TDuhTbqwsaWCatEYoHfoBlwI93ILbpT8SrnT08+bLALUy3L7ITQw3HLqQ2HzoJWAp5BIk6deP0m1iWxfvWmslKO/noy2/UB9rIsW2GuxXV2UnIIESdvC6A1TlM5aLYpA1s4H+wA7qEap3SoXKnGiWhvnafsFrbM9QFNiF8iHJWOG5zKQ6yKF9U5iAH2P4QtNvWKJNgJhHdDV4Vi/FNGQJJ+pNcg8auXRPzRyL7ckjP70mqmwXPdwxMDG6sDIe03+sov7NY76yHPzREj9B5i8ZGYVrKuMcogftXpEHRWErVSvg6PWBqqUDA1GhvdaaGXBcxEjJ6C0qgvHWGC456JMWD08tIAfmO X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(82310400026)(23010399003)(7416014)(376014)(18002099003)(22082099003)(56012099006)(11063799006)(13003099007)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y1Pdlgexjla3aiFBrE7OfaNCcfx7d6QOwO1Pz4HtscYihSZYLotyb0cfJNTOZvKnj2smsHm5RMWmxO5GgWj0HUHS6XEmSC1ga+1G3XOH7IEjwGCieeojOtOt77v6JtJBKUvqx9FpgBqADACVd0C4759oz2VHSzH/htC4HYyuGJF5OfLWCRMcNKja/CDd/yLANQDR+fKSQfGHyn2beiIkmIRrzjRY3tQ4RLARNQHNWzLD7mwwNhCclnDnrt6zlwaKvZ7unC096mi/9J07RQrE6gKWP2wwhLzv/Y0zTaeW8Vdy5TiFdKCto3mc6BYzSigP46HTfJotwyl1es08JF1jiHTkD4GVf9zhyCgkAZMAsbb1Jff1gOkOBn6SaXOz5nQCCOj6SAiGZH0M2hTGsGx/oDu6f7zP/CVxNbvVTbq+memLTicGeaC6FMX3BVwTFbfH X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2026 10:52:47.4808 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b998913-0078-40d5-0bc4-08dee0cce05a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000A34A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5874 Content-Type: text/plain; charset="utf-8" Guest APIC Physical Processor Interrupt (GAPPI) is an alternative to the GA log for notifying the host when a device interrupt targets a non-running vCPU (IRTE[IsRun] =3D 0). Per the AMD IOMMU specification [1] (section 2.2.5.4), with GAPPI enabled the IOMMU delivers a physical APIC interrupt to the CPU described by IRTE[Destination], using IRTE[GATag][7:0] as the vector, while still updating the guest vAPIC backing page IRR as usual. The AMD IOMMU also allows suppressing GAPPI interrupts using the IRTE[GAPPIDis] bit when the GAPPIDisSup feature is available in extended feature register 2. The AMD IOMMU driver sets this bit when the wakeup_intr flag is not set by KVM. Note: amd_iommu_gappi is currently false; a later patch enables it via the kernel command line. [1] https://docs.amd.com/v/u/en-US/48882_3.11_IOMMU_PUB Signed-off-by: Sairaj Kodilkar --- drivers/iommu/amd/amd_iommu.h | 1 + drivers/iommu/amd/amd_iommu_types.h | 4 +++- drivers/iommu/amd/init.c | 3 +++ drivers/iommu/amd/iommu.c | 30 +++++++++++++++++++---------- include/linux/amd-iommu.h | 1 + 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h index 834d8fabfba3..044179cab12e 100644 --- a/drivers/iommu/amd/amd_iommu.h +++ b/drivers/iommu/amd/amd_iommu.h @@ -41,6 +41,7 @@ int amd_iommu_enable(void); void amd_iommu_disable(void); int amd_iommu_reenable(int mode); int amd_iommu_enable_faulting(unsigned int cpu); +extern bool amd_iommu_gappi; extern int amd_iommu_guest_ir; extern enum protection_domain_mode amd_iommu_pgtable; extern int amd_iommu_gpt_level; diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_io= mmu_types.h index f9f718087893..26d7a9796e64 100644 --- a/drivers/iommu/amd/amd_iommu_types.h +++ b/drivers/iommu/amd/amd_iommu_types.h @@ -113,6 +113,7 @@ /* Extended Feature 2 Bits */ #define FEATURE_SEVSNPIO_SUP BIT_ULL(1) #define FEATURE_GCR3TRPMODE BIT_ULL(3) +#define FEATURE_GAPPIDISSUP BIT_ULL(4) #define FEATURE_SNPAVICSUP GENMASK_ULL(7, 5) #define FEATURE_SNPAVICSUP_GAM(x) \ (FIELD_GET(FEATURE_SNPAVICSUP, x) =3D=3D 0x1) @@ -1004,7 +1005,8 @@ union irte_ga_lo { no_fault : 1, /* ------ */ ga_log_intr : 1, - rsvd1 : 3, + rsvd1 : 2, + gappi_dis : 1, is_run : 1, /* ------ */ guest_mode : 1, diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index 3bdb380d23e9..2e1889f8a9e4 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -160,6 +160,9 @@ u8 amd_iommu_hpt_level; /* Guest page table level */ int amd_iommu_gpt_level =3D PAGE_MODE_4_LEVEL; =20 +bool amd_iommu_gappi; +EXPORT_SYMBOL(amd_iommu_gappi); + int amd_iommu_guest_ir =3D AMD_IOMMU_GUEST_IR_VAPIC; static int amd_iommu_xt_mode =3D IRQ_REMAP_XAPIC_MODE; =20 diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 91405e71b3c3..7eebf4745a67 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -3970,8 +3970,18 @@ static void __amd_iommu_update_ga(struct irte_ga *en= try, int apicid, entry->lo.fields_vapic.is_run =3D true; entry->lo.fields_vapic.ga_log_intr =3D false; } else { - entry->lo.fields_vapic.is_run =3D false; - entry->lo.fields_vapic.ga_log_intr =3D wakeup_intr; + if (amd_iommu_gappi) { + entry->lo.fields_vapic.gappi_dis =3D !wakeup_intr && + check_feature2(FEATURE_GAPPIDISSUP); + entry->lo.fields_vapic.is_run =3D false; + entry->lo.fields_vapic.destination =3D + APICID_TO_IRTE_DEST_LO(apicid); + entry->hi.fields.destination =3D + APICID_TO_IRTE_DEST_HI(apicid); + } else { + entry->lo.fields_vapic.is_run =3D false; + entry->lo.fields_vapic.ga_log_intr =3D wakeup_intr; + } } } =20 @@ -3982,15 +3992,15 @@ static void __amd_iommu_update_ga(struct irte_ga *e= ntry, int apicid, * If the vCPU is scheduled to run on pCPU (@is_running =3D 1), configure = the * Destination with the pCPU's APIC ID, set IsRun, and clear GALogIntr. If= the * vCPU is scheduled out (@is_running =3D 0), clear IsRun and set/clear GA= LogIntr - * based on input from the caller (e.g. KVM only requests wakeup_intr when= the - * vCPU is blocking and requires a notification wake event). This API is - * intended to be used when a vCPU is scheduled in/out (or stops running f= or - * any reason), to do a fast update of IsRun, GALogIntr, and (conditionall= y) - * Destination. + * and GAPPIDis based on input from the caller (e.g. KVM only requests + * wakeup_intr when the vCPU is blocking and requires a notification wake + * event). This API is intended to be used when a vCPU is scheduled in/out= (or + * stops running for any reason), to do a fast update of IsRun, GALogIntr, + * GAPPIDis and (conditionally) Destination. * - * Per the IOMMU spec, the Destination, IsRun, and GATag fields are not ca= ched - * and thus don't require an invalidation to ensure the IOMMU consumes fre= sh - * information. + * Per the IOMMU spec, the Destination, IsRun, GATag and GAPPIDis fields a= re + * not cached and thus don't require an invalidation to ensure the IOMMU + * consumes fresh information. */ int amd_iommu_update_ga(void *data, int apicid, bool wakeup_intr, bool is_= running) { diff --git a/include/linux/amd-iommu.h b/include/linux/amd-iommu.h index e962ad511d04..729d82c4e09e 100644 --- a/include/linux/amd-iommu.h +++ b/include/linux/amd-iommu.h @@ -80,4 +80,5 @@ static inline int amd_iommu_snp_disable(void) { return 0;= } static inline bool amd_iommu_sev_tio_supported(void) { return false; } #endif =20 +extern bool amd_iommu_gappi; #endif /* _ASM_X86_AMD_IOMMU_H */ --=20 2.34.1 From nobody Sat Jul 25 22:03:05 2026 Received: from PH0PR06CU001.outbound.protection.outlook.com (mail-westus3azon11011055.outbound.protection.outlook.com [40.107.208.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2234E3128B8; Mon, 13 Jul 2026 10:53:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.208.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783939997; cv=fail; b=gepKhtXA/B5k82C3KRWjd3eaHoerS0pwEVsE2HDdPAWyHMHiXWEpu2JLWA9eyA5J8sN28HcDRa1SzorVERTqUmHYjI44hi1t4BaVmjeKo/zg/Fj0vCoVxlvwi4W+Kw6UFEcoEbdLIxBoKbz7AhVxkUYo8rLwqDYcwOLM3eeSu1o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783939997; c=relaxed/simple; bh=2RknE0V1t2Tck3AVBV20kOzj+kxVV+QxZ0z46xzRtqw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m9/9v/uYcV60vpuMdzdizFC7hC4Zl7uJJvBZ8yjW0LRZqbjH5y7fvm0xdeJT3QdL9J2fg6UkfYAIXx9vAQX2+aCWhy0ies3HjOv13S0KH5ar56pQTs6nNaDLRwCEapYtALYEsl98vdwHhR8kaw0NQ1wRqPtputcM8xx+F7ASORs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=HkpSoBLT; arc=fail smtp.client-ip=40.107.208.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="HkpSoBLT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ulvMaQn6MIwvEgBsTmDjnSIz+fs1OzuIBeBOKg/1kgNuhnQ03DVcUHxm8tzPcQ2psOohtrxLrYButLqlgBvpYImUlWqe7z9gY/MFwjMSMeRl79mwI2K/v/MJR8Th0gVzhyEL2cQ/mOZjyZTGFyWSeG1R1RgH6nZ+X0xQTv2KlJaG2nj/2VpbsHYqsjgY1BH9NYKQXn5cpZgxmJsNi3N0dn/02WFw8jX3oXJS2DgJ3Sn+6Bl4yMwWj6GH/7dCHVn/XR1Y+J/PTQeO2XRo26lcroDbRglo/P2sKmN5TisXgonZDfLxyDGwocqh8laq/OjZcQ1jXhxcYY5ii+DBCkvoGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=prVdIE7RYavQpOCnFT8FHpWoyQ8JUh5EULEg7d8CXeI=; b=xJwptNrqIfp0cVYRd4K84OBR4+FkI3iccW5DfERQOPfsVQTFbX4eHqKdNrzK7kmb5lMplw9kwrE8cPIveuHOlun1lIlJG4uWejxuaOW8eMQYnmajCv6z3/wlVZJwdly+i6I33yVJR/ES+pPDAKBb258NH1EQSyZCVNsMGQaliATRgGlULgEoI7edHvllQWTxS9+bL2m4bxG3r5CiJmYid1JcC1c9/kwysLlvV/kccqq+97Qc5bcqTPXoc6sxMY/vXAnj7M3oJm/V7wyTLDWxThR9ed09FFYqUTn4Rd/9I9rKVUGnyX9RkxDltRuX4MapSIHDLhJj5AaXXDv1gg2xuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=prVdIE7RYavQpOCnFT8FHpWoyQ8JUh5EULEg7d8CXeI=; b=HkpSoBLTRm0AnvKDkh1sRux+pq1mJvQ+f4jPxOjifn6kA/Y/jlNFelMAxL2Cs9N6nfQTP67RbCaAdW5cOPWIewpVO8UTiwf7lKhNzAdXSfuVY2NPplteCKR6iJcjAUV7+NRNSkCUzkLi+qHx1gmSgxbA65XvYh61jdhjd5h2sCc= Received: from CH0PR03CA0107.namprd03.prod.outlook.com (2603:10b6:610:cd::22) by LV3PR12MB9187.namprd12.prod.outlook.com (2603:10b6:408:194::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.10; Mon, 13 Jul 2026 10:53:09 +0000 Received: from CH1PEPF0000A349.namprd04.prod.outlook.com (2603:10b6:610:cd:cafe::e) by CH0PR03CA0107.outlook.office365.com (2603:10b6:610:cd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.19 via Frontend Transport; Mon, 13 Jul 2026 10:53:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH1PEPF0000A349.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.9 via Frontend Transport; Mon, 13 Jul 2026 10:53:08 +0000 Received: from BLR-L1-SARUNKOD.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Mon, 13 Jul 2026 05:53:00 -0500 From: Sairaj Kodilkar To: "Borislav Petkov (AMD)" , "H. Peter Anvin" , "Joerg Roedel (AMD)" , "Paul E. McKenney" , Andrew Morton , Dapeng Mi , Dave Hansen , "Eric Biggers" , Feng Tang , "Ingo Molnar" , Jakub Kicinski , Jonathan Corbet , Li RongQing , Marco Elver , Paolo Bonzini , Randy Dunlap , Robin Murphy , Sairaj Kodilkar , Sean Christopherson , Shuah Khan , Suravee Suthikulpanit , Thomas Gleixner , "Vasant Hegde" , Will Deacon , , , , , Subject: [RFC PATCH v3 5/6] KVM: SVM: Add support for AMD IOMMU Guest APIC Physical Processor Interrupt (GAPPI) Date: Mon, 13 Jul 2026 16:20:32 +0530 Message-ID: <20260713105033.15405-6-sarunkod@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260713105033.15405-1-sarunkod@amd.com> References: <20260713105033.15405-1-sarunkod@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A349:EE_|LV3PR12MB9187:EE_ X-MS-Office365-Filtering-Correlation-Id: ced53cfa-0b8c-40db-fd09-08dee0cced1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|82310400026|7416014|36860700016|1800799024|376014|921020|22082099003|18002099003|5023799004|11063799006|56012099006; X-Microsoft-Antispam-Message-Info: I7+7s7U2PUO6WQ54MRKECmZdo9CWc8weZm/YWB8fJdawfHonEQCXilIKpXKb2avW9P01wpRJDw4kDuUPYmSYattksjvaJPDT3kUCiBsH/YxQj/03opKPf396NceGmDeheA2f5f6QScZImB+ogBG2qtfBqve7STxIhNx1lLL4m1bs4kdNxCZB83SfEV6Q6I9pEaPxQUWxDR3VKl+GhAiUMZV3PWjANrNY2r2xiP63qsfhWXFZEUhzI+INe3b9XSA4UVcjdGuK166qZ+YHiV0xjrm8gaP3EODFtlvA9Jl3m9/Ie1LXItr2rtjxXduauBVw8MqqKWMuN9q4STzODX7ehswYwtp3e0df437pyOKYfrO+lRYZ1vtNI6+9OFmOWvvMX7SUCwiYv/Jp7WBBaFSmvvRrJiPfx+k2ZfoLw4zQ+LRqXPMKPHejeMM1wRLGRo1OBLz6ujuFPsN9otEB5lfgOGAMs6sUTVOfQxD9Iv8dq3FpxwXufp2asFir/EipWRvaEIMhaEPPKUpTELm7orHhvUW99uyCu3Xh6H49XaPut5hqBPEuK64gkSYqZltuz5kfjq62L6ITZ/Ca6Yqxg45ifjwWIgjZY2g+5wdWafYncpI6zbiijGkaNSLeR60LpbunUGPc1WaBOZf7cbkhGWKunt45OkaWEt8NuinjXswA+ZbReVycRlNl9g4/jLKrth1S1TgYmGwGXyfiW4yCef/7P7B1FXy/ZGHXpbpHspX1njEtgdfDj/oNC44il2JQS+C9 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(23010399003)(82310400026)(7416014)(36860700016)(1800799024)(376014)(921020)(22082099003)(18002099003)(5023799004)(11063799006)(56012099006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TOtIE9TlFXcv1g7S1TbWOEHC1FXReaBsNsAXjWyziJaf5XxyiLnnpC2wccdxDBHMjo7r3XQcBPnzfn1HeRQEjA25y/jZSvhko+mg+r0bYy7/r6H8qV590BlMlBGM+6QCh9BrAXTs8eFxPar0lLBZA0sZo0zTYQiId8/z1O+zfO325AK8IiKhmIqjL/qzvCLItQOTIVqzEUY/4HnQTkdrkx3FN9YW6QsybvpD9gK85N9lwBKAxsnkoI/w4dLKW33t4BL11jPdJ1Wp/dRQl+iU2S2HQf/Be1vwmQxbbK83o7dllZb5MOcUgAcGTTdRNhJWRuFGW3UCQ0gpcFm3Fj50y3ru9J9yEZpZrAeg/D6e5HK8t8Hqa6tJs99r0LaZKTPcLZQ8QS+cz0r5t5ezMb0g7w98JfvgyCHEWDepAuOUbO6Y7x6a8w+cZIw314X0k3PR X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2026 10:53:08.8751 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ced53cfa-0b8c-40db-fd09-08dee0cced1a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000A349.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9187 Content-Type: text/plain; charset="utf-8" With AVIC guest-mode interrupt remapping, device interrupts are posted into the guest vAPIC backing page by the IOMMU. When the vCPU is not running (IRTE[IsRun] =3D 0), KVM must still be notified to schedule it. The legacy path uses the GA log. GAPPI (Guest APIC Physical Processor Interrupt) is an alternative to the GA log mechanism provided by the AMD IOMMU. With GAPPI enabled, the IOMMU still updates the vAPIC backing page IRR, but the host wakeup notification is delivered as a physical APIC interrupt to IRTE[Destination], using IRTE[GATag][7:0] as the vector (POSTED_INTR_WAKEUP_VECTOR). SVM follows the Intel posted-interrupt wakeup model. Each pCPU maintains a list of blocked vCPUs that may be woken by a GAPPI delivery to that CPU. When a vCPU blocks while waiting for an interrupt, SVM enqueues it on the wakeup list of the pCPU on which it was previously running and passes that same pCPU's physical APIC ID to the IOMMU to program IRTE[Destination]. The rationale is that the vCPU is likely to run again on the same pCPU, which is common when vCPUs are pinned; targeting GAPPI notifications there reduces unnecessary VMEXITs from GAPPI deliveries on other CPUs. SVM registers the GAPPI handler via kvm_set_posted_intr_wakeup_handler(). On delivery, it walks the local vCPU list and wakes vCPUs with a pending IRR. All GAPPI logic is gated on amd_iommu_gappi. Without it, KVM and the IOMMU falls back to the legacy GA log mechanism for vCPU wakeup. Signed-off-by: Sairaj Kodilkar --- arch/x86/kvm/svm/avic.c | 135 +++++++++++++++++++++++++++++++++++----- arch/x86/kvm/svm/svm.c | 2 + arch/x86/kvm/svm/svm.h | 5 ++ 3 files changed, 128 insertions(+), 14 deletions(-) diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c index 3b2d92a58709..982a5988532f 100644 --- a/arch/x86/kvm/svm/avic.c +++ b/arch/x86/kvm/svm/avic.c @@ -63,6 +63,9 @@ ga_tag; \ }) =20 +static DEFINE_PER_CPU(struct list_head, gappi_vcpu_wakeup_list); +static DEFINE_PER_CPU(raw_spinlock_t, gappi_vcpu_wakeup_list_lock); + static_assert(__AVIC_GATAG(AVIC_VM_ID_MASK, AVIC_VCPU_IDX_MASK) =3D=3D -1u= ); =20 #define AVIC_AUTO_MODE -1 @@ -874,6 +877,9 @@ int avic_init_vcpu(struct vcpu_svm *svm) INIT_LIST_HEAD(&svm->ir_list); raw_spin_lock_init(&svm->ir_list_lock); =20 + INIT_LIST_HEAD(&svm->gappi_vcpu_wakeup_list); + svm->gappi_cpu =3D -1; + if (!enable_apicv || !irqchip_in_kernel(vcpu->kvm)) return 0; =20 @@ -886,6 +892,42 @@ int avic_init_vcpu(struct vcpu_svm *svm) return ret; } =20 +static void avic_add_vcpu_to_gappi_wakeup_list(struct vcpu_svm *svm, int c= pu) +{ + struct list_head *wakeup_list; + raw_spinlock_t *spinlock; + + if (WARN_ON(unlikely(cpu < 0))) + return; + + wakeup_list =3D &per_cpu(gappi_vcpu_wakeup_list, cpu); + spinlock =3D &per_cpu(gappi_vcpu_wakeup_list_lock, cpu); + guard(raw_spinlock_irqsave)(spinlock); + if (list_empty(&svm->gappi_vcpu_wakeup_list)) + list_add_tail(&svm->gappi_vcpu_wakeup_list, wakeup_list); +} + +static void avic_remove_vcpu_from_gappi_wakeup_list(struct vcpu_svm *svm, = int cpu) +{ + raw_spinlock_t *spinlock; + + if (WARN_ON(unlikely(cpu < 0))) + return; + + spinlock =3D &per_cpu(gappi_vcpu_wakeup_list_lock, cpu); + guard(raw_spinlock_irqsave)(spinlock); + if (!list_empty(&svm->gappi_vcpu_wakeup_list)) + list_del_init(&svm->gappi_vcpu_wakeup_list); +} + +void avic_destroy_vcpu(struct vcpu_svm *svm) +{ + if (svm->gappi_cpu !=3D -1 && amd_iommu_gappi) { + avic_remove_vcpu_from_gappi_wakeup_list(svm, svm->gappi_cpu); + svm->gappi_cpu =3D -1; + } +} + void avic_apicv_post_state_restore(struct kvm_vcpu *vcpu) { avic_handle_dfr_update(vcpu); @@ -896,13 +938,18 @@ static void svm_ir_list_del(struct kvm_kernel_irqfd *= irqfd) { struct kvm_vcpu *vcpu =3D irqfd->irq_bypass_vcpu; unsigned long flags; + struct vcpu_svm *svm; =20 if (!vcpu) return; =20 - raw_spin_lock_irqsave(&to_svm(vcpu)->ir_list_lock, flags); + svm =3D to_svm(vcpu); + + raw_spin_lock_irqsave(&svm->ir_list_lock, flags); list_del(&irqfd->vcpu_list); - raw_spin_unlock_irqrestore(&to_svm(vcpu)->ir_list_lock, flags); + if (amd_iommu_gappi && list_empty(&svm->ir_list)) + avic_remove_vcpu_from_gappi_wakeup_list(svm, svm->gappi_cpu); + raw_spin_unlock_irqrestore(&svm->ir_list_lock, flags); } =20 int avic_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm, @@ -923,8 +970,6 @@ int avic_pi_update_irte(struct kvm_kernel_irqfd *irqfd,= struct kvm *kvm, * if AVIC is enabled/uninhibited in the future. */ struct amd_iommu_pi_data pi_data =3D { - .ga_tag =3D AVIC_GATAG(to_kvm_svm(kvm)->avic_vm_id, - vcpu->vcpu_idx), .is_guest_mode =3D kvm_vcpu_apicv_active(vcpu), .vapic_addr =3D avic_get_backing_page_address(to_svm(vcpu)), .vector =3D vector, @@ -932,6 +977,7 @@ int avic_pi_update_irte(struct kvm_kernel_irqfd *irqfd,= struct kvm *kvm, struct vcpu_svm *svm =3D to_svm(vcpu); u64 entry; int ret; + bool is_vcpu_waiting =3D false; =20 /* * Prevent the vCPU from being scheduled out or migrated until @@ -947,6 +993,12 @@ int avic_pi_update_irte(struct kvm_kernel_irqfd *irqfd= , struct kvm *kvm, * scheduled out, KVM will update the pCPU info when the vCPU * is awakened and/or scheduled in. See also avic_vcpu_load(). */ + if (amd_iommu_gappi) + pi_data.ga_tag =3D POSTED_INTR_WAKEUP_VECTOR; + else + pi_data.ga_tag =3D AVIC_GATAG(to_kvm_svm(kvm)->avic_vm_id, + vcpu->vcpu_idx); + entry =3D svm->avic_physical_id_entry; if (entry & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK) { pi_data.apicid =3D entry & AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK; @@ -955,11 +1007,19 @@ int avic_pi_update_irte(struct kvm_kernel_irqfd *irq= fd, struct kvm *kvm, pi_data.apicid =3D -1; pi_data.wakeup_intr =3D entry & AVIC_PHYSICAL_ID_ENTRY_WAKEUP_INTR; pi_data.is_running =3D false; + + if (amd_iommu_gappi) { + pi_data.apicid =3D kvm_cpu_get_apicid(svm->gappi_cpu); + if (list_empty(&svm->ir_list)) { + avic_add_vcpu_to_gappi_wakeup_list(svm, svm->gappi_cpu); + is_vcpu_waiting =3D true; + } + } } =20 ret =3D irq_set_vcpu_affinity(host_irq, &pi_data); if (ret) - return ret; + goto gappi_err_out; =20 /* * Revert to legacy mode if the IOMMU didn't provide metadata @@ -968,12 +1028,17 @@ int avic_pi_update_irte(struct kvm_kernel_irqfd *irq= fd, struct kvm *kvm, */ if (WARN_ON_ONCE(!pi_data.ir_data)) { irq_set_vcpu_affinity(host_irq, NULL); - return -EIO; + ret =3D -EIO; + goto gappi_err_out; } =20 irqfd->irq_bypass_data =3D pi_data.ir_data; list_add(&irqfd->vcpu_list, &svm->ir_list); return 0; +gappi_err_out: + if (is_vcpu_waiting) + avic_remove_vcpu_from_gappi_wakeup_list(svm, svm->gappi_cpu); + return ret; } return irq_set_vcpu_affinity(host_irq, NULL); } @@ -1007,7 +1072,7 @@ enum avic_vcpu_action { }; =20 static void avic_update_iommu_vcpu_affinity(struct kvm_vcpu *vcpu, int api= cid, - enum avic_vcpu_action action) + int cpu, enum avic_vcpu_action action) { bool wakeup_intr =3D (action & AVIC_START_BLOCKING); bool is_running =3D apicid >=3D 0; @@ -1018,10 +1083,27 @@ static void avic_update_iommu_vcpu_affinity(struct = kvm_vcpu *vcpu, int apicid, =20 /* * Here, we go through the per-vcpu ir_list to update all existing - * interrupt remapping table entry targeting this vcpu. + * interrupt remapping table entries targeting this vcpu. */ - if (list_empty(&svm->ir_list)) + if (list_empty(&svm->ir_list)) { + if (amd_iommu_gappi && cpu >=3D 0) + svm->gappi_cpu =3D cpu; return; + } + + if (is_running && amd_iommu_gappi) { + if (svm->gappi_cpu !=3D -1) + /* + * Handle initial state when vCPU is loaded for the + * first time without any IRQ affinity. + */ + avic_remove_vcpu_from_gappi_wakeup_list(svm, svm->gappi_cpu); + + svm->gappi_cpu =3D cpu; /* Store cpu number as target for GAPPI */ + } else if (amd_iommu_gappi) { + apicid =3D kvm_cpu_get_apicid(svm->gappi_cpu); + avic_add_vcpu_to_gappi_wakeup_list(svm, svm->gappi_cpu); + } =20 list_for_each_entry(irqfd, &svm->ir_list, vcpu_list) { void *data =3D irqfd->irq_bypass_data; @@ -1084,7 +1166,7 @@ static void __avic_vcpu_load(struct kvm_vcpu *vcpu, i= nt cpu, =20 WRITE_ONCE(kvm_svm->avic_physical_id_table[vcpu->vcpu_id], entry); =20 - avic_update_iommu_vcpu_affinity(vcpu, h_physical_id, action); + avic_update_iommu_vcpu_affinity(vcpu, h_physical_id, cpu, action); =20 raw_spin_unlock_irqrestore(&svm->ir_list_lock, flags); } @@ -1127,7 +1209,7 @@ static void __avic_vcpu_put(struct kvm_vcpu *vcpu, en= um avic_vcpu_action action) */ raw_spin_lock_irqsave(&svm->ir_list_lock, flags); =20 - avic_update_iommu_vcpu_affinity(vcpu, -1, action); + avic_update_iommu_vcpu_affinity(vcpu, -1, -1, action); =20 WARN_ON_ONCE(entry & AVIC_PHYSICAL_ID_ENTRY_WAKEUP_INTR); =20 @@ -1175,7 +1257,7 @@ void avic_vcpu_put(struct kvm_vcpu *vcpu) =20 /* * The vCPU was preempted while blocking, ensure its IRTEs are - * configured to generate GA Log Interrupts. + * configured to request host wakeup notification. */ if (!(WARN_ON_ONCE(!(entry & AVIC_PHYSICAL_ID_ENTRY_WAKEUP_INTR)))) return; @@ -1300,6 +1382,21 @@ static bool __init avic_want_avic_enabled(void) return true; } =20 +static void avic_gappi_wakeup_handler(void) +{ + int cpu =3D smp_processor_id(); + struct list_head *vcpu_wakeup_list =3D &per_cpu(gappi_vcpu_wakeup_list, c= pu); + raw_spinlock_t *spinlock =3D &per_cpu(gappi_vcpu_wakeup_list_lock, cpu); + struct vcpu_svm *svm; + + raw_spin_lock(spinlock); + list_for_each_entry(svm, vcpu_wakeup_list, gappi_vcpu_wakeup_list) { + if (kvm_lapic_find_highest_irr(&svm->vcpu) >=3D 0) + kvm_vcpu_wake_up(&svm->vcpu); + } + raw_spin_unlock(spinlock); +} + /* * Note: * - The module param avic enable both xAPIC and x2APIC mode. @@ -1308,12 +1405,18 @@ static bool __init avic_want_avic_enabled(void) */ bool __init avic_hardware_setup(void) { + int cpu; avic =3D avic_want_avic_enabled(); if (!avic) return false; =20 pr_info("AVIC enabled\n"); =20 + for_each_possible_cpu(cpu) { + INIT_LIST_HEAD(&per_cpu(gappi_vcpu_wakeup_list, cpu)); + raw_spin_lock_init(&per_cpu(gappi_vcpu_wakeup_list_lock, cpu)); + } + /* AVIC is a prerequisite for x2AVIC. */ x2avic_enabled =3D boot_cpu_has(X86_FEATURE_X2AVIC); if (x2avic_enabled) { @@ -1337,12 +1440,16 @@ bool __init avic_hardware_setup(void) enable_ipiv =3D false; =20 amd_iommu_register_ga_log_notifier(&avic_ga_log_notifier); + kvm_set_posted_intr_wakeup_handler(&avic_gappi_wakeup_handler); =20 return true; } =20 void avic_hardware_unsetup(void) { - if (avic) - amd_iommu_register_ga_log_notifier(NULL); + if (!avic) + return; + + amd_iommu_register_ga_log_notifier(NULL); + kvm_set_posted_intr_wakeup_handler(NULL); } diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index e02a38da5296..b687133f8528 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1356,6 +1356,8 @@ static void svm_vcpu_free(struct kvm_vcpu *vcpu) =20 WARN_ON_ONCE(!list_empty(&svm->ir_list)); =20 + avic_destroy_vcpu(svm); + svm_leave_nested(vcpu); svm_free_nested(svm); =20 diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 5137416be593..47d5bb5d7103 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -362,6 +362,10 @@ struct vcpu_svm { =20 /* Guest GIF value, used when vGIF is not enabled */ bool guest_gif; + + /* GAPPI related fields */ + struct list_head gappi_vcpu_wakeup_list; + int gappi_cpu; }; =20 struct svm_cpu_data { @@ -909,6 +913,7 @@ void avic_init_vmcb(struct vcpu_svm *svm, struct vmcb *= vmcb); int avic_incomplete_ipi_interception(struct kvm_vcpu *vcpu); int avic_unaccelerated_access_interception(struct kvm_vcpu *vcpu); int avic_init_vcpu(struct vcpu_svm *svm); +void avic_destroy_vcpu(struct vcpu_svm *svm); void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu); void avic_vcpu_put(struct kvm_vcpu *vcpu); void avic_apicv_post_state_restore(struct kvm_vcpu *vcpu); --=20 2.34.1 From nobody Sat Jul 25 22:03:05 2026 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011048.outbound.protection.outlook.com [40.93.194.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 805FA3E5EF0; Mon, 13 Jul 2026 10:53:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783940028; cv=fail; b=lnsAmBHJDUAj2dawli5mbphUniK69/bSYL18TiZb0TvQ1fsX/nLCNic8YD/CDY8Po4dOqc9uP5D6xS/fAyNzOwM9fozd3H9Ndy7VIIU4WQt50e9BkKpJpfou/Iz1ls07UlOu/FmYRNU7vfuuxOs4VE3XgGZoZTHk6Pcf3b2u0/8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783940028; c=relaxed/simple; bh=uEi3ji5dluimcoNoQP9l8t1CfTc7qhRl/xWxTjln4nU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sRu2EoLHSFDT7wEgwaw1fWqpEqPw80MZZIl7vpzRbNj5FqAz7k4KkwvSe/zIMryRxgkBMW23byyWmi/EODJjzn0Na5FCRNHLLqrlkF2/mSBjhI0c9SyPO7UryjpAS7TagqpcrxMEAq/iW/Of4X1/siqkma7TetTCan+wQYqZlWQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=XlUhVIOO; arc=fail smtp.client-ip=40.93.194.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="XlUhVIOO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=X0X9otaB6AbIrOxuVDegIDaDyUcZT4Rdd0Fy8Hm6yUvhcQ4KoeBmNYNPKnApre+TgRxQ+is0oKYgTp5Ni4UJSxOpchOCy94o/TYo/yAsdwTcESjsSsweh4En8hA1FGTXx1vA4Ry/GVkhQnIs1bnqCYphVUTxWF3fWC8FBoRBV8QP9x2jDMGIM86Iae2QbcAGTFpyCV6rrlZQatztIAJ4ticIQiQKnwxd+JBHiRiwlQGcTbHAh0qVHzfq8MWSgUlx2Bdm21CdywlFUzZjcUnlfSwHNBbqTPMIgVQKJzQDeCFmw9fSIyixmXpotrAKkKksN9A89cE+SSQjdt6kRz166A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Y90PFNwCxmnOAvATsCZRv4I8sXwVAU+UatV0P9JETno=; b=k2sfL4ywbBgOSyJphdoqPilRtvPJ5Z9LLPss/T9uxJ5QYCHRvWNIdRN63eylqz32IExvHhhfP3Pm0MzfLLV736qOCbO4v0hW6MQnXFBHVgWHxLWtSD67AoOhW0czWXrvwPNMjb9DRRJ4jZC2SAGCiPsxhxJiat2cZFl1yEzuuoBMa/pX27Rcf4XfKx90iTOWpuiRQPhDkSN+ax3wTEBeCU1cVopkticKjnXT2rPWw8BEiYL7fEuQDHpn3nDKFQSmTVePoBy/TaFFcFDY1ksxhxDDSreYWFufpCr/onbmceTZrvV4q2zfVLHwOjgwkHsBPTeqXZdUULn/Z4D4C1MSLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y90PFNwCxmnOAvATsCZRv4I8sXwVAU+UatV0P9JETno=; b=XlUhVIOOw/FWAvVglBP+6uN83F4PU5k6pFTG/9gYQvmxONKbz8xg7cgW5oQhi/6ucqtfv+Y9Xw8TVE8vkB74vmpL4dyWMeoN8yqNYtqeoSGbbFo9qaPAfczMwrBFkMMes1Sl6FuICaC64cXNkUDu3BVLW5iBY0wDdBX/QeLeq7o= Received: from CH2PR02CA0006.namprd02.prod.outlook.com (2603:10b6:610:4e::16) by SJ0PR12MB7067.namprd12.prod.outlook.com (2603:10b6:a03:4ae::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.19; Mon, 13 Jul 2026 10:53:35 +0000 Received: from CH1PEPF0000A34B.namprd04.prod.outlook.com (2603:10b6:610:4e:cafe::a8) by CH2PR02CA0006.outlook.office365.com (2603:10b6:610:4e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.19 via Frontend Transport; Mon, 13 Jul 2026 10:53:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH1PEPF0000A34B.mail.protection.outlook.com (10.167.244.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.9 via Frontend Transport; Mon, 13 Jul 2026 10:53:35 +0000 Received: from BLR-L1-SARUNKOD.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Mon, 13 Jul 2026 05:53:27 -0500 From: Sairaj Kodilkar To: "Borislav Petkov (AMD)" , "H. Peter Anvin" , "Joerg Roedel (AMD)" , "Paul E. McKenney" , Andrew Morton , Dapeng Mi , Dave Hansen , "Eric Biggers" , Feng Tang , "Ingo Molnar" , Jakub Kicinski , Jonathan Corbet , Li RongQing , Marco Elver , Paolo Bonzini , Randy Dunlap , Robin Murphy , Sairaj Kodilkar , Sean Christopherson , Shuah Khan , Suravee Suthikulpanit , Thomas Gleixner , "Vasant Hegde" , Will Deacon , , , , , Subject: [RFC PATCH v3 6/6] iommu/amd: Provide kernel command line option to enable GAPPI Date: Mon, 13 Jul 2026 16:20:33 +0530 Message-ID: <20260713105033.15405-7-sarunkod@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260713105033.15405-1-sarunkod@amd.com> References: <20260713105033.15405-1-sarunkod@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A34B:EE_|SJ0PR12MB7067:EE_ X-MS-Office365-Filtering-Correlation-Id: 7abb90a5-b7b2-45d3-d082-08dee0ccfcda X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|376014|7416014|82310400026|23010399003|921020|22082099003|18002099003|3023799007|6133799003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: wgBF7xlA6BfBI6PRaDY2/upLfJFaHuvqMqKvgRAV2yNyiCmL+8ihY9/50wLqyDzDW+9QZKykG5EcrET5D2NXbX8Z4HOwnbPF3InOLE/1AuZMLVqKC7+X3ifunJDYP+C6kij7pVCG5LTnAskfKHXqeQxEPZuJN+FvHewoSZ/VYo9BYu684u0jthmgrJSJaDtzwlp73UtPVSz+TkDcA3R8ivXdRMxuAw+NRX0rrNMEAlibbXNYHTfshfjvVNrZfuGXFpnRMZJxAjV1hR6TIc/q4TkEZ6o2dv7NnaDQakBuwgvKZ7I2pWra5URLvtcWQFI59ZwsxayuphjQjS5joziocw6THfLidOTiiqMTLAOZKnrlYPpq/ookkhnIkQjK1hg0MG5G7i22Bt6U3S97dH1pE0cnxaIWfQZba3qaCuJ1+lwNKKIbWjIxCP5yki7tFbxbZ+0+FBRwBdtUey0HIRP5J3pY0KyRkt+g08Pt1ZD/E9YSD0rUb7KNmuAwMxXlUYtQ1s0K6mUIcq642RCNgH1WJYBGJeEg3wMW2QX2Tel+sCljcvvFHvQjBkloSqDRspPLyUAu0N73Ru5scnicPDu5nyw47u66W04gVzhAgrZVqOQ2udvw02LY8j4opp224K9jiTH947ckUBcczfKFysdpOBLFiXHZgVpqY4HMl7jekJP7FvAVqQzfHDETyrd1aYWpqukBg39BtqGRtNwI301ZixnjQp/uPVQce4RZGSRXKtYzVVoyEo3iOcjFszQSVRht X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(376014)(7416014)(82310400026)(23010399003)(921020)(22082099003)(18002099003)(3023799007)(6133799003)(56012099006)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5uF28teRZrOB6FCsSKbK9fPwiSCW/Bz4MhFHtGFgmI7mQ0s9h3a+F4KIaV1EUeUiHjIj6L9C1CWsKVkohc8qk+0e2zJt4g1bIv+jwEUlMvowjsIwMWgTGv6hXBrnGuN6JYZ/R5/C6J4PFMmiH1dJHLEwNBWT8/Xb5LPUqOKQg8j01MhAxBbSlhd4FouSXPEJJVSEk+DVLRvNQ49Z+purodbRNG3qN0vFAFpwzYHbs4CReVdM8FhRJj3E5NtscyDkUgHRo8pm8N2pyCcheREptkRFRo0YfjA+YlJaSli2h4Y0Ruf7nN/O/J2drl8hUcNoff+Cv2i8nNAOOIPfNN9xksJm+IkIEfi9b5WsnYkgYHXOlk4JTdH/BQMSNwQVVtkfp13B3SuK+M+s6L5LdwxqkIYSXRiftbuuu0gFQwprjzHDy22drzxgg78QCM0PkTse X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2026 10:53:35.2992 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7abb90a5-b7b2-45d3-d082-08dee0ccfcda X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000A34B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7067 Content-Type: text/plain; charset="utf-8" Enable GAPPI when the IOMMU GAPPISup extended feature bit is set and the kernel is booted with the amd_iommu=3Dgappi kernel parameter. Document the option in Documentation/admin-guide/kernel-parameters.txt. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Sairaj Kodilkar --- .../admin-guide/kernel-parameters.txt | 3 +- drivers/iommu/amd/amd_iommu_types.h | 2 ++ drivers/iommu/amd/init.c | 28 +++++++++++++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 97007f4f69d4..d27f10cbb004 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -455,7 +455,8 @@ Kernel parameters to 4 KiB. v2_pgsizes_only - Limit page-sizes used for v1 page-tables to 4KiB/2Mib/1GiB. - + gappi - Use GAPPI instead of GALOG for vCPU + wakeup notification. =20 amd_iommu_dump=3D [HW,X86-64] Enable AMD IOMMU driver option to dump the ACPI table diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_io= mmu_types.h index 26d7a9796e64..de0b23306944 100644 --- a/drivers/iommu/amd/amd_iommu_types.h +++ b/drivers/iommu/amd/amd_iommu_types.h @@ -94,6 +94,7 @@ #define FEATURE_X2APIC BIT_ULL(2) #define FEATURE_NX BIT_ULL(3) #define FEATURE_GT BIT_ULL(4) +#define FEATURE_GAPPI BIT_ULL(5) #define FEATURE_IA BIT_ULL(6) #define FEATURE_GA BIT_ULL(7) #define FEATURE_HE BIT_ULL(8) @@ -191,6 +192,7 @@ #define CONTROL_EPH_EN 45 #define CONTROL_XT_EN 50 #define CONTROL_INTCAPXT_EN 51 +#define CONTROL_GAPPI_EN 55 #define CONTROL_GCR3TRPMODE 58 #define CONTROL_IRTCACHEDIS 59 #define CONTROL_SNPAVIC_EN 61 diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index 2e1889f8a9e4..7d2b1c24f6ec 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -465,6 +465,9 @@ static void iommu_disable(struct amd_iommu *iommu) iommu_feature_disable(iommu, CONTROL_GALOG_EN); iommu_feature_disable(iommu, CONTROL_GAINT_EN); =20 + /* Disable IOMMU GAPPI */ + iommu_feature_disable(iommu, CONTROL_GAPPI_EN); + /* Disable IOMMU PPR logging */ iommu_feature_disable(iommu, CONTROL_PPRLOG_EN); iommu_feature_disable(iommu, CONTROL_PPRINT_EN); @@ -2999,6 +3002,13 @@ static void enable_iommus_vapic(void) struct amd_iommu *iommu; =20 for_each_iommu(iommu) { + /* + * Disable GAPPI, do not check amd_iommu_gappi as it may be + * false in new kexec kernel even though previous kernel has + * enabled it. + */ + iommu_feature_disable(iommu, CONTROL_GAPPI_EN); + /* * Disable GALog if already running. It could have been enabled * in the previous boot before kdump. @@ -3038,10 +3048,19 @@ static void enable_iommus_vapic(void) return; } =20 + if (amd_iommu_gappi && + !(check_feature(FEATURE_GAPPI) && + AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))) { + pr_warn("GAPPI is not supported.\n"); + amd_iommu_gappi =3D false; + } + /* Enabling GAM and SNPAVIC support */ for_each_iommu(iommu) { - if (iommu_init_ga_log(iommu) || - iommu_ga_log_enable(iommu)) + if (amd_iommu_gappi) + iommu_feature_enable(iommu, CONTROL_GAPPI_EN); + else if (iommu_init_ga_log(iommu) || + iommu_ga_log_enable(iommu)) return; =20 iommu_feature_enable(iommu, CONTROL_GAM_EN); @@ -3050,7 +3069,8 @@ static void enable_iommus_vapic(void) } =20 amd_iommu_irq_ops.capability |=3D (1 << IRQ_POSTING_CAP); - pr_info("Virtual APIC enabled\n"); + pr_info("Virtual APIC enabled with %s\n", + amd_iommu_gappi ? "GAPPI" : "GALOG"); #endif } =20 @@ -3741,6 +3761,8 @@ static int __init parse_amd_iommu_options(char *str) } else if (strncmp(str, "v2_pgsizes_only", 15) =3D=3D 0) { pr_info("Restricting V1 page-sizes to 4KiB/2MiB/1GiB"); amd_iommu_pgsize_bitmap =3D AMD_IOMMU_PGSIZES_V2; + } else if (strncmp(str, "gappi", 5) =3D=3D 0) { + amd_iommu_gappi =3D true; } else { pr_notice("Unknown option - '%s'\n", str); } --=20 2.34.1