Message ID | 20250120174033.308518-18-clement.mathieu--drif@eviden.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org> 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 D27DBC02182 for <qemu-devel@archiver.kernel.org>; Mon, 20 Jan 2025 17:42:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tZvn7-0005P1-Nj; Mon, 20 Jan 2025 12:42:25 -0500 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 <clement.mathieu--drif@eviden.com>) id 1tZvmi-0004n6-BE for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:42:00 -0500 Received: from smarthost1.eviden.com ([80.78.11.82]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <clement.mathieu--drif@eviden.com>) id 1tZvmg-0000aZ-L4 for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:42:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394918; x=1768930918; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=5x886T3s2t0SJOfZjFtnvyt81lof+n12kWsM8oHoRLo=; b=Mf1xky4WVrFEQZ4KhDiXlmFS/YlNk88ohNrMBdTJkM66iffSgrb1gBhq 0DRCQwX+beUwXkg/ekDL2EtiVpcRZNHYt6N77EZmzQHcbe7ZjNlLKj5k6 wRIkP8+MQFHUoX5qBtNq2PPAItCRBclJ4H4p8UixUlDSqE0J+lhL2eG6J 2QFVSjdgr9Hi9KwoPHlUFewE801edu5mTnV9Z8txyynYRGYTIzjGz85A0 pes1er/ERC7/A6KvvZrEQl5b/Hfq1SkT+v3PPDExhMb4ZR6nEP1v74XFJ Jur11+zLZmLeItIo9kBZZf57MgA73AmoQjcPZmH/xfpRIEzLaY4vktOBQ A==; X-CSE-ConnectionGUID: 5V8nMTQVTDeiRYny7q9QNg== X-CSE-MsgGUID: bq+3+fYsRCml9xsIiC5Fqw== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="29133406" X-MGA-submission: MDGKnAO0RElry2rBfSfDCDFDmDHYrk+dO1AEFaFtvMC6rcKPS94LRtu4Us075ROGM8LjOASbibjE4HrKDoYaU/kMTk1ANnvg/v47B1GNyWUWUoyMEemQvMaHS4dk9L8ebF5cyWMnuZe3ILmgySq/Mb41IXlrQSsAj4r2RMVxQOqyfw== Received: from mail-am6eur05lp2106.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.106]) by smarthost1.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:57 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TixZPlByYgaEkRRtw2y5iHNdqcGuRSP3EFvOQwgOQaT0OxIXlrknYxLJjPnoJvwr2FWLZtVr+YkIv0CuC6A6S/CkKg3rjnT74VY/bsCG7vTfpWUmEbJuVTC8p0pzAi8qUNKOPM3CnPRGejrG4fvwmyfBgwn1TmN30lEewHwazoZDnqp3XV+oR5fKOIGHG5lwlEd3jJRy6+q3DMBMSYVx4FTCeqgkBo513q233bai4byTp9xYdF5kM7c3XqRTPhvAfNCbPnSGFiSRT5IUQh7aEdQrar3T6ReZLoOyQaza722Ux63QvmCTC2KOpWVSpjRx2h6+TiMWiELKL28j7Sxg6Q== 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=XEm+kcr1XmCknek/aj1wwABq0rrHY6adgLyODzgqi/k=; b=d9NbuQ1nWKr52n+nXREwORPwfaonybJzYOE+uboIoAaQ1WCB/NoXE4oVagxx4W91LsI62H4XQPxwnqLtffp//0Q1ZxHwhPjn/NuJ7D45VI8d4xKs6Nw9ZRPWTUrGAEiBXAFgCLDctyVDB5uNBW/irg+/XHQxHY7OfEmNg+H3z177ae8tSA390/QxH9JJHM/nnswue2p/lATFSvAdKLrQXcB8/5JdtRzRr7t18EmTqGPuwzQ7/+w1aIsabaOClSyZr6z9O952jtAAdCN3W8siNpSwwHJQi+ByvXQiYAkj+ugzPYUZt7niojxxgIzktZnA7J2daktFw8ZhkRAOfq5dUg== 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=XEm+kcr1XmCknek/aj1wwABq0rrHY6adgLyODzgqi/k=; b=s3e5J3WbB54wo7ivFZsrBhJ6EwEiwa4B3JCw9Jt/l1BPY8EjGLL54nxe3IgIoBecDbVTGF+IRiapjRMu/vlGpAbH7uNI8INwlnSDbGOMa/d24alyHfh2M0u2/UF8uKUO4MNoVxNE9zrsHqhgHWX8nu7l2hk27tR/9wySiq9UaHcAXf3p8WsXMTZAV6c8lv619W7mfRjTT4bDvxlcU70esVlfEMX2JZs3pZE4YC7DLLxuF0qAmrfmYmt/h09+0o0yqKcjeHlRuWc3UEldY1jGIRQRjmGp2hv/hn9Vq5X8WRlE4FYtwkEsN7jExtoYpL4yrKKSDxzp807AztcHMhqLpg== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by DBBPR07MB7548.eurprd07.prod.outlook.com (2603:10a6:10:1eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Mon, 20 Jan 2025 17:41:56 +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.8356.020; Mon, 20 Jan 2025 17:41:56 +0000 From: CLEMENT MATHIEU--DRIF <clement.mathieu--drif@eviden.com> To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org> CC: "jasowang@redhat.com" <jasowang@redhat.com>, "zhenzhong.duan@intel.com" <zhenzhong.duan@intel.com>, "kevin.tian@intel.com" <kevin.tian@intel.com>, "yi.l.liu@intel.com" <yi.l.liu@intel.com>, "joao.m.martins@oracle.com" <joao.m.martins@oracle.com>, "peterx@redhat.com" <peterx@redhat.com>, "mst@redhat.com" <mst@redhat.com>, "tjeznach@rivosinc.com" <tjeznach@rivosinc.com>, "minwoo.im@samsung.com" <minwoo.im@samsung.com>, CLEMENT MATHIEU--DRIF <clement.mathieu--drif@eviden.com> Subject: [PATCH v2 17/19] intel_iommu: Set address mask when a translation fails and adjust W permission Thread-Topic: [PATCH v2 17/19] intel_iommu: Set address mask when a translation fails and adjust W permission Thread-Index: AQHba2KZ83QXp1EEake+3IoV4qOa7A== Date: Mon, 20 Jan 2025 17:41:56 +0000 Message-ID: <20250120174033.308518-18-clement.mathieu--drif@eviden.com> References: <20250120174033.308518-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20250120174033.308518-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_|DBBPR07MB7548:EE_ x-ms-office365-filtering-correlation-id: f4b0278e-48c8-4d9e-0db5-08dd3979bbe5 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?HCZ5BuUGlUvcA/9b7lUUZs3U35?= =?iso-8859-1?q?WnTn8TeEMwfwM0Mh4heXGfKVAbfHVAI/p+I/zObTGN0L9kHP8xoEso9XsWrR?= =?iso-8859-1?q?5s2CiTrKjfbMtBa0g47CBvEhQx933vb+9OQ+lr36FnZLOwWjhsyzlQsWxRjW?= =?iso-8859-1?q?q/dMEbdq1sXaQw1apqDKVfGiDE67uD2rMd+PFzfJvDqN3aTXS5azu691iyqS?= =?iso-8859-1?q?xzf7tysak+G9FJULBV1VGpOxQ5LMpDCAdp3QWTy320jQXEFCWl4BnQshZyGG?= =?iso-8859-1?q?X1Q1+CbQ4bZod+3cc3xl7ybal822u1GY1JsBfeKjVDwLZgXUDm39SffoYsye?= =?iso-8859-1?q?ZrZo08tvwPAmBONEBOUqKbkd/LUA2FWNI4x1QuRpItIz/TLdZWWMzrZNsbE8?= =?iso-8859-1?q?9RtXOVniWp9h0gucYNe/vM29j8UAu+/fR95V5qkJC8j8GYbee7POIhfPllYO?= =?iso-8859-1?q?LVo40iC6Ts5/Oa4Pfsi1ZM3wRRzzfF7L/5BH01FOPOAkfJ1h1Gk4Zr7/Wpdb?= =?iso-8859-1?q?BdU3xSu8ZjDeSbX7a7YELNUhZONcpjYi5RKh81xZq0FslA5m7wbTXF15dHN6?= =?iso-8859-1?q?G/zLGfn0MwlgI2WZfNOC6/X9H7IMYJ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?iso-8859-1?q?YGHmCZ?= 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:(13230040)(1800799024)(366016)(7416014)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?pJP+cjzXYwTbKTj2eif5uDR?= =?iso-8859-1?q?hpXvrSApGlG8MfcXPG617m5lcDUmpu7ctOtH1nrFqwglDAST4qD6qNAo+FDL?= =?iso-8859-1?q?Rz4+GzdtbVTxYywcfmgIFS0lhVddgjmiNRvfWFLewcpd7mie1xxSu9kZPkI6?= =?iso-8859-1?q?NJ1b7LezoFauhpECYfNTYTMl+xCYXEe82BzhtaIxvq/0xsAmnveMA78NVH1C?= =?iso-8859-1?q?FcJDPKfz6EChX+mZVyyR0O7tYnUT8FFffo4PN4RiLeCscYf4rceMHk8x9faR?= =?iso-8859-1?q?w/DP1piLiEIwUWshAfSHRWUzsiEu4RFtA5CrRifrZ5pvGvrP5/WywGc+sAHC?= =?iso-8859-1?q?5v0x/rlJeJoigQYh3FqRowehEoVv4nwmHH3gpQIpm6wyup7vAKiuaNatuuLu?= =?iso-8859-1?q?AnoEKQe9LnL6ZLJiPPkZ6+0jSTCd7NMRjDpbMOkiQQ8ZJA1FMOEjIh52Uqt5?= =?iso-8859-1?q?CGJi7QvU2u0nMCkC5QSugzDAsQYQZg/hV8gDY+XbaL7EDThXqmLIIogUg3xO?= =?iso-8859-1?q?QRZEkovSJKtLLFU5LOn13bUl5g+R4GC+/n6D+KqipnqVhpGzBUqP4nuk39hh?= =?iso-8859-1?q?6hq1fdtjB/2MXv/HKF4QlnLDNUIL/olrZOQl2lRwKHpYNCEu14DqiAmcP5PI?= =?iso-8859-1?q?fu8kXweLxLWQkCm/24HVyOTFT1lp1qjLXOsXGGAuy2Z6YA+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?q?4wvPZa2C8O/0b/BI3U3AjQX9YAG8BxCTRWzrS4b0wJQ2k3SzaT4GHAitQ677?= =?iso-8859-1?q?oO0RAVUhuBhOx1kWwlVvuuaQXbP31CSpnxZB/DIYC4StOQ0DSP8rzUOopww4?= =?iso-8859-1?q?=3D?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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: f4b0278e-48c8-4d9e-0db5-08dd3979bbe5 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:56.2209 (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: tCGtV56eV0QeGxZSGWA0VMJ4iBHD/ztWCMEU7AikzqaAJLMofjIOw2nnVdH4P7muCb7MUxu9SKCpxv7ER+rxYN/cLCxDryydbK4+aKxFpXw95s7fff0cFEJDzHLzG02D X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 Received-SPF: pass client-ip=80.78.11.82; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost1.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, RCVD_IN_MSPIKE_H2=-0.036, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org |
Series |
intel_iommu: Add ATS support
|
expand
|
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 021834c41f..530b75a9a3 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2100,7 +2100,8 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus, uint8_t bus_num = pci_bus_num(bus); VTDContextCacheEntry *cc_entry; uint64_t pte, page_mask; - uint32_t level, pasid = vtd_as->pasid; + uint32_t level = UINT32_MAX; + uint32_t pasid = vtd_as->pasid; uint16_t source_id = PCI_BUILD_BDF(bus_num, devfn); int ret_fr; bool is_fpd_set = false; @@ -2259,14 +2260,19 @@ out: entry->iova = addr & page_mask; entry->translated_addr = vtd_get_pte_addr(pte, s->aw_bits) & page_mask; entry->addr_mask = ~page_mask; - entry->perm = access_flags; + entry->perm = (is_write ? access_flags : (access_flags & (~IOMMU_WO))); return true; error: vtd_iommu_unlock(s); entry->iova = 0; entry->translated_addr = 0; - entry->addr_mask = 0; + /* + * Set the mask for ATS (the range must be present even when the + * translation fails : PCIe rev 5 10.2.3.5) + */ + entry->addr_mask = (level != UINT32_MAX) ? + (~vtd_pt_level_page_mask(level)) : (~VTD_PAGE_MASK_4K); entry->perm = IOMMU_NONE; return false; }