From patchwork Mon Jun 3 05:59:50 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: 13683279 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 36D3EC25B75 for ; Mon, 3 Jun 2024 06:03:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sE0jn-0006of-BT; Mon, 03 Jun 2024 02:00:07 -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 1sE0ji-0006kP-1C for qemu-devel@nongnu.org; Mon, 03 Jun 2024 02:00:03 -0400 Received: from smarthost2.eviden.com ([80.78.11.83]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sE0je-00072M-OW for qemu-devel@nongnu.org; Mon, 03 Jun 2024 02:00:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1717394399; x=1748930399; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=+TK6Zle7ulmJBALlSA1cDnHgI2mELoDDS5fd5A1y8gs=; b=JNyOITLC0bZ+QTJ+l03gofKKYHBCA/Tjvgsykmvwwc/dYKZcn9xLxSZo 5zJrplUU3+qs/zuOTHyqQyiVxUmt9EvKrYkESxN3ps2IIc62eVKNjAXYQ lnLoq0jHUNb4kwGB1Z9nFAHVGD8G0CYqNKMVj1HbQIH1OwG6kxxvbMtNm EJkupvf/Nrlm7LxILB8TavGo9E50g+Vns4NxsTSiTlPRUiDUE10OM+t+Y I/MNPUNxuPNjdx7EEsXiXNjvR5XqA4+dRfvCG3By2jIYvm5nsLSS1k4TS sMRMASv7hhZjhKugUDcK8bIw9O+Xf6RzATONMguMQwRG/Gups3AlqOQ0N Q==; X-IronPort-AV: E=Sophos;i="6.08,210,1712613600"; d="scan'208";a="13763250" X-MGA-submission: MDGgMixguMerjGSqACX2X+IceTYMDiJGIqif+Q3u+lMLNyNRURuoF0d1J5IbktCy2nxRfZXjBCqODzQB1+/9d8VRgbrEw+1Y56/b8BzJBuXTCFEIvpLiGfyLymiIhjkZuwNjIK9APNX6zm0qmCtpeoc68rZHSvFDVhMGzl2nxnNbOQ== Received: from mail-he1eur01lp2051.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) ([104.47.0.51]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 07:59:54 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YtJlj6X3Kj7KHifMbMtP+ngMwfpLuf+ZtOiB5wnVemqXqudE0pp0JE0pCFkI6vF1f/61RdDmqYjwPGnBaJsy96klGspqf1cmEJZTLQmLoL0lLOx1z4I1hM+DLIevEoESmD+5Re7JCoSB3YCrlZ3dtIpeGCOef8/dz7/DNKNB9rVPoPNuACOtBW4jVtvhLObmO8K+HjZ9Wag0kotu+9ii8LYWZuyHcZiHBoDEP00gdJcN2dc5l1M1K6cWsEquWDxnigO3irE4Pw79YRH91yJISlz15khmtFL58JncY1nbR+2hRUCdXVye6Ski96xEhGs6qLFfE9WKObTSs0o/GOI2rg== 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=+TK6Zle7ulmJBALlSA1cDnHgI2mELoDDS5fd5A1y8gs=; b=T0d77YRi/PJJVvcWxfo2jGOlAYp0edqVlh7D3M3rJPgni1WUzUgMZLxVoEGeqwupSG/6gFNxnlynizSJk6wM/UQfqO2RzqsHmqTApzMcomFb2IdFzDhrypKRRNozKvDQGzH68J0UNXF+Gv9lG3rcaT7YgeZ7tlbcp/QIovfbttai2clUuJMQk86uBetsxGcL637eC6uc1ZYv+8edFiKCoWxoOZZqcGB5agrLYrKVI3MdLpLh756si2T6NfW8rxGvwMs9tXMO0v5bsEAbfxSjf71b4LNHbxNDNkwJSPdf4UpWxK/l8XkzAorXDpxu37kNnD6bZr3MVDmoTX8kLnO7LA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+TK6Zle7ulmJBALlSA1cDnHgI2mELoDDS5fd5A1y8gs=; b=QA+t+cJcWJbTgvjg+FWc9Z821Td57b0LO2kXL76pbzO97ybXKT8jOQE8Pt0/+RzV2KtNaI3+jxYR1uX0ZsnKLOKpsrmveX5ishqjDZ7TCdFtFb5NlT/sFmibUuxYaBYB4SZvyM9G4lU7cKe0jL86eW59GkEVkb1PwOroAwyGy/3PbHNWfqbjvpVlpKeyYZB+F453sGzWvnRO2G4FdRS+pTRpnUNyCV+AJjGeEGVkTkLrgCMude9JOG3oefUPoO7BTyb6Kvs9CNUHmhcs3+RB2C5xFQeeO8MDxp6wUK9mP9DXPrsbxv7Zq0ZQoQbYDKd5gzHWpazXqyq8uPpaH78vbA== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by VI1PR07MB6238.eurprd07.prod.outlook.com (2603:10a6:800:136::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Mon, 3 Jun 2024 05:59:51 +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.7633.021; Mon, 3 Jun 2024 05:59:51 +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" , "mst@redhat.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH ats_vtd v5 16/22] intel_iommu: fill the PASID field when creating an instance of IOMMUTLBEntry Thread-Topic: [PATCH ats_vtd v5 16/22] intel_iommu: fill the PASID field when creating an instance of IOMMUTLBEntry Thread-Index: AQHatXs/2Kth/K+aAEGM/Noyd0IfWQ== Date: Mon, 3 Jun 2024 05:59:50 +0000 Message-ID: <20240603055917.18735-17-clement.mathieu--drif@eviden.com> References: <20240603055917.18735-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20240603055917.18735-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_|VI1PR07MB6238:EE_ x-ms-office365-filtering-correlation-id: 7fbee4b7-c0b5-4672-2239-08dc839261de x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230031|376005|366007|1800799015|38070700009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tbHf/cz4xUSb2QSJCJn8TtWCHdmKainY+QLFRPKDl6ljpERV5IMWSz?= =?utf-8?q?WCBf2f6QqHsagj/vnsu9wsz8G3njumZzgjClhxh7/PCN4FbfVdcesGrc96o2Fi6Rc?= =?utf-8?q?ds8O1pNyIk9xdqVPrL+6VPGrpIvdrpW5j9rd8tb4j3YQzpICfsZ0gYicOHxVqzxKq?= =?utf-8?q?aNSPTrl6UtaU/DJ0mMWMNQDMKS5V8ATUvZJ3UWP3U9e9jstfgadGyI29JFgNZa3wy?= =?utf-8?q?UIxNC4AoDEg34MRm3FVPqCGfBdkgbkhFmBlNVpaXo1SKksE7rJFdr0PEpbPDlp0xk?= =?utf-8?q?Q0TJ6phNd7V5tgYdItYy7KyxjfwJBD9RmjNNMRHSh0EeTIa9MKnj79T234GaUM4NB?= =?utf-8?q?z2pk876HKey8nc/pfCW3RqcECyjfZKkZL628rcut9AODTEyEeplqFh1mYAOt1KvFG?= =?utf-8?q?RM/y9VxAK/oAXhmUG3d4YtIKvH3e+5bcWCg=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)(376005)(366007)(1800799015)(38070700009); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?nBDXc1eiTnv1o0XbhSBGNmJuS1D5?= =?utf-8?q?wfhGwqffkayaZYtY+Vwrv+KnyGnhN6TcOkbeVWVfEwZCFVSygKr65/t1Ha+y5Q40x?= =?utf-8?q?shtq5WNCJz0hGYs+gywDvrFmJaUV+/caFIY33kye9bazze8NaHGfNbBfDaSZdgB6c?= =?utf-8?q?r030iURVGBfXHXO96sDtgLjM2AQmBiZuvrnT7UjCVmetTX36PbZlN3bJukth12+rw?= =?utf-8?q?A6xGRL2Pohd05ZVbLjAdvxv0wIusDS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lCmi0SgAXot+5wIASFY65daAKkzL9?= =?utf-8?q?jl849e9XzFw0feKOyKaGUwvQLADpmYcx1XEMGch5RCHtDaUf4E1hn8blsMtQ8+ei7?= =?utf-8?q?+ZklVB1WCSQ017QehdVvMJ4UgMvjqa7N3L5fxiCrFiAAIshp0PsGI09cBMsKVBd/h?= =?utf-8?q?ug6DzQPLM32MgTc9fMkt+UH6y9CkN80Mt9kywL6U+YwutZh0unA3tIPr8f0a2AzLW?= =?utf-8?q?60spiNCRXDzShGmiSkqVntFybkj9e7HZ3n9z0z+t2tZJy45AYmtA8N9KkgKbnsVgQ?= =?utf-8?q?bszqcSIcWCIpU33uTJClPzlbHMw5g2QK4KhBDIGfFIW+DD/Ct95hJhNiwsl3YQsUk?= =?utf-8?q?r8zhzlCKgFEUwT1YiLZWB1SQNtPhOkEexAoIHZHEItLHut9LXZ1v1J8CioI3A+dj3?= =?utf-8?q?uAMUhGlM2zjEzeSXi3WTAT8Z+IK81LyIohDnubiTKYJ0VI0ma7CClWo=3D?= Content-ID: <75FDCE7FCD68974EB147B07684E386D3@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: 7fbee4b7-c0b5-4672-2239-08dc839261de X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jun 2024 05:59:50.9736 (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: t34jhuhY3EBOzJzT+sibbaNyxgFyteWcy8wOzizkDvu49sKdCtPrZWQY9LKf48cCLrqNQbawJWQ6c4KZCODYhC+pksesYx+yWi85yt0WpHSBjaMRlwWSOmPXX3Goi+6I X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB6238 Received-SPF: pass client-ip=80.78.11.83; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost2.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Clément Mathieu--Drif 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 d607562de2..0f3bd5978e 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; }