From patchwork Tue May 21 13:11:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13669446 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 74C64C25B74 for ; Tue, 21 May 2024 13:15:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9PIE-0000Tq-7k; Tue, 21 May 2024 09:12:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9PHZ-0007kT-GX for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:58 -0400 Received: from smarthost4.eviden.com ([80.78.11.85]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9PHW-0001an-HI for qemu-devel@nongnu.org; Tue, 21 May 2024 09:11:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1716297114; x=1747833114; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=F9597oN4TImrsU5O420IR4+7xZpXTaUNA2KVmchYngs=; b=GUr+7l3HIkFKwoAa1OjYF8Ezs14F6OVIOpkeLEJvdQD9qJyXMHFGI9kb ucewf97aJ8IMGYj2kgrcTSiP9HeItOk/cY+9oSoHzwfo6ra05zvzSQTpI Z2z03HvaXcaA8f8O6n8xaPr4FFoP3IaCrzT1uxpbvhe2SvDE8TTFRlNF+ QJOwt+dWdSr7PqFwEPK35ZrYc2slCiPMXINEdVRUSuOCgGIJ86a2Apayk JOMeM280ySLYAmxLelI2NUBcIUmPN+HtQuS6sQbPftzVl45h0L2o1OU4Y MIJxmh1FdMokwQI69E1yay+Cnsf6MGDm/Vc6rIEM6OJT3ruEKY06DFHA5 w==; X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="13061511" X-MGA-submission: MDHgTBEcqe9PCFFeD7O+RCuGI/MhRbsSodYDDEPfm+Xbt8xtA6pspqnXJt1s2j7dSb8bBS42m6BkAwGrDZhGDczf3KRdzwz3qRTZUGljqD/ERg5ygW/REjZ2HV71eTOGgTa/UqzeWg24FvkGYVy6ojN+sGsYnzlVTVXj/MeZctvpQg== Received: from mail-dbaeur03lp2168.outbound.protection.outlook.com (HELO EUR03-DBA-obe.outbound.protection.outlook.com) ([104.47.51.168]) by smarthost4.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 15:11:50 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iBY4kLXqi2x1kwk0PWr7Zdga7gGtTXx+6ve8+Z60JVf+7hE/uYjsOo7O5mCXeugjBiHwZIHrddOr8/B6R1772GsCVjUaAgFCReXWxgtrb4N0gC9hpMw3qIqZemY5yENaIOFPNWgtk0OftvqKxE0e5F4O0+0zj7IekxEZFtDzzYhf9RFEgVOzBeVn350BUzoC9zJoBrQJs6YQT5Fh0rcZIDBITmTGfn4+0Bl6cD0Ddbs4dSrTKDGMC/s91B0Rb0gHcmd9SZIuAxsZp5YJdtIdPzdFXa4ldMu9ezrNUSWQI+zT/mDCXrUPqztQ+GuzpnC6ryHALpYp+VB+8omVlSFM6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=F9597oN4TImrsU5O420IR4+7xZpXTaUNA2KVmchYngs=; b=ZIHIlT/UTmq72PnO2P15Iof4OtcKdZ/KCFCaCPu5ue9CD1+1jYL3zdKKESwfEGt4o4vbIGCgnbrsrYy2J1/OE70iG6J5+ZB1IZg2rgkbDMbWICCveoj9sKNQlU4LE7u45mwi7eb6BbVm3frpru7zTmt9xAFoUq+I9xYjeZpyJoD2qonbPA99/hhz/L6+P4KjpxKIgdDA60O6UNX3kKqLULoR+3CAW/bPaKl3Xd1ZOr/r5tkOASFmwJ4d7BLIr54FfnRSOqkmnpUBxALsLAL2hrFn/fFO1h5YRtDr8GEq6Cyze1+kSA94klRhdb8/e6uGuNYR4K97DO24gzVa6njXUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DB8PR07MB6249.eurprd07.prod.outlook.com (2603:10a6:10:140::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.27; Tue, 21 May 2024 13:11:49 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.7587.035; Tue, 21 May 2024 13:11:49 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH ats_vtd 16/22] intel_iommu: fill the PASID field when creating an instance of IOMMUTLBEntry Thread-Topic: [PATCH ats_vtd 16/22] intel_iommu: fill the PASID field when creating an instance of IOMMUTLBEntry Thread-Index: AQHaq4BwdWnqJ2m6gkm86Rsix4ClAA== Date: Tue, 21 May 2024 13:11:49 +0000 Message-ID: <20240521130946.117849-17-clement.mathieu--drif@eviden.com> References: <20240521130946.117849-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20240521130946.117849-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|DB8PR07MB6249:EE_ x-ms-office365-filtering-correlation-id: 90b40d72-9a25-4326-7053-08dc79979314 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230031|366007|1800799015|376005|38070700009; x-microsoft-antispam-message-info: =?utf-8?q?YNjU2uhJfOW3zdCgwtTyeVOLr2SI60N?= =?utf-8?q?n17jMSEN/qXA018/k2JUcmxVGbalBCcWeY7Jty+8tGA4u6O9g92slKg8uK2ua5kPo?= =?utf-8?q?3+QfRdkWl0SokvIAb2ec+3dEFpDIFbnzHlcu4VZhufLSj9OP37cTTDYO6S6/mp8/d?= =?utf-8?q?N94OdHeruXGScT0uVz2r1nzqWZW+PwF23ltfpn3crnUqvhc01Mc1UFF/SmhmLYkcL?= =?utf-8?q?6yTIbTCMch+lhM7y4uuDFX+G4/0oH5gTVB9Fmh/rSgnLWZe0QDvN7UTD8+CJG0DUH?= =?utf-8?q?Jok+VrLLM9dB7p/v6KI9bTLr1B1/u+LNpOD3NpdoPe1enuAUVoUYRQvfjvxVRKk1K?= =?utf-8?q?c76zPdvdgqN2QTQDt1tMOHCnOdhDPNGr10m4b22TQ+HG556Axkgbrt6s/Gy0cPZuR?= =?ut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jLPe9H8Wpd39fNF7ddK4N3nmfag=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(1800799015)(376005)(38070700009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?NXjducJOl4Il2BuQVPHK5IFfKkvS?= =?utf-8?q?F/vcJ4EtTXc0dfQqjXcsrxhABtNZXxqTHuSVDXEHLrlLyWsGHKEylC8kwTvgJtna5?= =?utf-8?q?wCVUw3beJXgIhh5jG5t0Eo9rwYXI5hmt4vdVyMBZGGCsj/gr94nt41JP1Kw41ewlu?= =?utf-8?q?Pa0tmHBearzuRhMHQj9TcfsSMBnMgajIse4mnxrekpzmUmJyDf1AqHtlLsTaOm3aa?= =?utf-8?q?qYi9prU6721JErBLy/oVGy7g7avTP6LNv7Y5TaOg8+UE98Fieij42U7PzFuu3a38W?= =?utf-8?q?GLN+h6+AZJ+AzyoMtE3Pz3Ekwm0W5eohE/5X6+dik87uHtEPEkhDbyfqJKwxXDeyK?= =?utf-8?q?jEGnGcX4lXcE0XVJBn9sI9lChzILRsGSnQ7TMEzbd7IGor+hHpTt5/xgKSjiyuNLH?= =?utf-8?q?9LmHZNsU4Jdh6Zp3jgDsJlILQeQlCJa+mtpFcE49869RigyoVK2bJGtz73e/40RS5?= =?utf-8?q?KGe/vXgtZMIYrpmUUE2uDpVCh/Z97Z5dtZq61miCb4TTG7eNsWgeOmcCcu12eMEdG?= =?utf-8?q?JKVeuYT6ZgR7G9t0hV927bSxcc8Shvf1s5bp/VMcgA8QRhLXq7GY9mihkWvFNi72t?= =?utf-8?q?Fzx+acoQSVfx4zmx4A8z55xnSsTFPgCKkL2ZOq+bi/N84tCfNyDufYMxo96eNhDD9?= =?utf-8?q?BoxUgYPx8iPCULp/ve8n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RcLZ6LUR3aPRs2Sz5vfPyFDOnlDUgzrrLiYI=3D?= Content-ID: <12D940B8BED9454AA5FAC6F3C26FA2BE@eurprd07.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: eviden.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM8PR07MB7602.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90b40d72-9a25-4326-7053-08dc79979314 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2024 13:11:49.4174 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7d1c7785-2d8a-437d-b842-1ed5d8fbe00a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ny3WKEyqcowag4vLq5X2BSYhBS39ZI65jiPi0CCFlb5ZwLRWuxZ//l9RctFjIZNh91cMIRL2ycoanOzrsWGnE5kcIoAKmP0XY4PyRlGni9EENI4tyzD2Dr2qpmXc0Vet X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6249 Received-SPF: pass client-ip=80.78.11.85; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost4.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Clément Mathieu--Drif --- hw/i386/intel_iommu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index a42938aacd..f08c3e8f00 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2187,6 +2187,9 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus, vtd_iommu_lock(s); + /* fill the pasid before getting rid2pasid */ + entry->pasid = pasid; + cc_entry = &vtd_as->context_cache_entry; /* Try to fetch pte form IOTLB, we don't need RID2PASID logic */ @@ -2304,6 +2307,7 @@ out: entry->translated_addr = vtd_get_pte_addr(pte, s->aw_bits) & page_mask; entry->addr_mask = ~page_mask; entry->perm = access_flags; + /* pasid already set */ return true; error: @@ -2312,6 +2316,7 @@ error: entry->translated_addr = 0; entry->addr_mask = 0; entry->perm = IOMMU_NONE; + entry->pasid = PCI_NO_PASID; return false; } @@ -3673,6 +3678,7 @@ static void vtd_piotlb_page_invalidate(IntelIOMMUState *s, uint16_t domain_id, event.entry.target_as = &address_space_memory; event.entry.iova = addr; event.entry.perm = IOMMU_NONE; + event.entry.pasid = pasid; event.entry.addr_mask = size - 1; event.entry.translated_addr = 0; memory_region_notify_iommu(&vtd_as->iommu, 0, event); @@ -4320,6 +4326,7 @@ static void do_invalidate_device_tlb(VTDAddressSpace *vtd_dev_as, event.entry.iova = addr; event.entry.perm = IOMMU_NONE; event.entry.translated_addr = 0; + event.entry.pasid = vtd_dev_as->pasid; memory_region_notify_iommu(&vtd_dev_as->iommu, 0, event); } @@ -4896,6 +4903,7 @@ static IOMMUTLBEntry vtd_iommu_translate(IOMMUMemoryRegion *iommu, hwaddr addr, IOMMUTLBEntry iotlb = { /* We'll fill in the rest later. */ .target_as = &address_space_memory, + .pasid = vtd_as->pasid, }; bool success; @@ -4908,6 +4916,7 @@ static IOMMUTLBEntry vtd_iommu_translate(IOMMUMemoryRegion *iommu, hwaddr addr, iotlb.translated_addr = addr & VTD_PAGE_MASK_4K; iotlb.addr_mask = ~VTD_PAGE_MASK_4K; iotlb.perm = IOMMU_RW; + iotlb.pasid = PCI_NO_PASID; success = true; }