From patchwork Mon Jan 20 17:41:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13945430 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 9F811C02182 for ; Mon, 20 Jan 2025 17:43:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tZvmp-0004zr-8n; Mon, 20 Jan 2025 12:42:07 -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 ) id 1tZvmj-0004rI-G6 for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:42:01 -0500 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 1tZvmh-0000c8-OY for qemu-devel@nongnu.org; Mon, 20 Jan 2025 12:42:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1737394920; x=1768930920; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=UgB59vyp3H3Jn7V5ztZldIZgHg8c5PO3izwVPJX5VW0=; b=aCwWwJPCkL09quRP5mCnZ0r8d6kClwvahYLAW0qROKfBFO456RG5RkZw WL5d+QHHfLoQcDltud83MJvhlwPDwmwjIiny4f56IjfCpjayAjGKB/9Jy j5+PXyTRSc+m8w75H2TKFtvEqma8NPwRG5q6u63LQCnEGLwiRwHAvDCz4 DcNSjdxZkbTbBV6wnGd6JMJXNdeR0BunWdHxFAmiaf8EFxZ7WUPs203sx q86xSQnMbWfkL9o9XleXTY9tCsiy+9Q5Y1delSKN9iBSw6WYG4K+4Z2X5 3YRIS6s7g7uKwOQu0OjxX5HKsx3PSvqP/Qq63iIIyMVCtTRGd6QtAkU7g Q==; X-CSE-ConnectionGUID: 0JOv/0Y4TPyWPCZfQCs9TA== X-CSE-MsgGUID: UtrTgLj6Qca4SueB8bJU/A== X-IronPort-AV: E=Sophos;i="6.13,219,1732575600"; d="scan'208";a="30291723" X-MGA-submission: MDEJ4Wc6wyL4sE8+RShbBIHvVrnE8P6itHe7K0W2Ut+8/SnwWC9GURbfTBLJA8jbAQVjDRDh3Owu/BTPtM47zox2SH3mDhDYWPGj4E5HHiuEUixT47IxsOKvV+TBAgLRbQexVTk9YNbx/HM9oBbnMuTuY5Owr8GYV+Myr2Uaz0mu+A== Received: from mail-am6eur05lp2108.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.108]) by smarthost4.eviden.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Jan 2025 18:41:58 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WwEOEpatIMFx6ztVt14EXGNEPCzcjb79EhlWgua2OtBqIr4ABIZrcNNMOinV/LIjlhuoHeHvUBMZfvYpIXactZWwofNuxS2Nfub01Xemof45VSPwPEu/OsgKyRG9ibE/wDhzNiw5bRBPll4gFIpGVNTWK6XY3rWhNu/uVR+mqzbk3EQsMtlGChtnAyGhlSRrb9xeLpz2QbMW+fBgMDZDrVK33PbWAQQ6OYVQCe/onJiJhQJJYXjjO7GUkL8Aj8CPtrn+w6HMvBlxjE5hqFpEeT3Yx0ID9sQzxfjVY1AptWdV7iqar7QQSmxgCV/YVqiw53/bKYDEsZMFncWG33vhGA== 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=x3aoXB9xnRHA18HBbamlCYkaq59Z3CUVOBuKGlxl1II=; b=nAEteMkza4pNzM4IuD1A0iU+zNcGmDQOe7ICmL52REEBiOAGD8cqmmNFYziz5OOwhJ7F08lFWSVIitoTR5JgPddmYjdHfMO3KHQ8NCdpfrHQcVOzsVqOdPEKNGTsFKbKnTo7x/9IMmGGHah4FZBD3hjFNBZZiEtk5pHXkjKq6+TGH2ubJNj7WxeHp/yi2EmWGgipCIB0mlBwHVfGz0UEE6WcZsgjc6xM31Oc5NRbPW1Vfr5smUyPo0pBRFPnQQOtrmh2lu/hKU5Ec1QVTPnj4aQs4KOyEi45hAjIdiSkWDGs82aid7qSWfunsqsUtO2/DtOknnGHh25HNCALm0l7uw== 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=x3aoXB9xnRHA18HBbamlCYkaq59Z3CUVOBuKGlxl1II=; b=sG2a4mi73Vb0Ek3TouQ1JIf+wX1gamZMXE+KGkSqBGET6K7PQpgL/YuhvsJvQ4ZdwD2burRaW8XwyYwruesBFe/YdEaB7Hr7n/WoJTyVA7f1rGdLdCn0fOkVs6AIunmqFA51Ivf/kAZhGiMNWBFKU8moU4IFBlpJfTCjK5V6y3vAqj0/pRKpNCblwF7f5W2W4UdZZH4Y8BGcWfCNi9uONOh6j2oW+P9OkumVHjmGqaujLY3s7wmzsigO6MIyDYYgG90SQtZUuReqUFbPlsyI74AMCatdpwHIDQcHVhZMrWCxDQh4OBuUpHHpqImYOMwQ0axuJ/OyOg6NY8MWMqtvnQ== 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:57 +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:57 +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" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v2 18/19] intel_iommu: Return page walk level even when the translation fails Thread-Topic: [PATCH v2 18/19] intel_iommu: Return page walk level even when the translation fails Thread-Index: AQHba2KZIdJ9XQWqrU+jq7FbQLTqYw== Date: Mon, 20 Jan 2025 17:41:57 +0000 Message-ID: <20250120174033.308518-19-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: 6c90f56a-4787-4deb-fbca-08dd3979bc6c 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?ntWV250InIe9rqfHqVgKei+mhf?= =?iso-8859-1?q?7kFn5iLLecRN8otN9wnphpphYJTFtuKBXIjpo/Q3DhXWH4Zr5MdJ1YK00lLb?= =?iso-8859-1?q?vn8EzHWKu7Mbf9GNl3QH+BgcYj+uMBrccGKOLbQsVEwMldNsWyvGzvXxtMGA?= =?iso-8859-1?q?EZq5eZYtCDo/93csUp5uon4pfvNFVHSfZiMQ/lsJm7ja+eaAPuZA3DvlXM6E?= =?iso-8859-1?q?sf0FiVA0UzqN8F5aUgyJY4MfsStZeF/cmABVr0SXGBwIR6mT2jmLg1zKCXuX?= =?iso-8859-1?q?RlLSecJ2HeY8h/J87wsqkuTO2ByuVvbF+53bjqKiOF+hmk2jpg2W2br0XBId?= =?iso-8859-1?q?TDL0BAQmCjWjg8FhJBpIlac7oa7kZEyiYVZB4xr3F402ItvyQZzkSNmm9gQm?= =?iso-8859-1?q?WP40Xrs1bl87o6s1nLgChjaOhVcyV73NHmGOkUPH8EiUnYSW9552BrlIryfT?= =?iso-8859-1?q?GOzqo8qKvBvsb7vSRLFrNr5GqX5n+Gljj7TgVPRoV8LnxnjP3H+CJiOi/OxN?= =?iso-8859-1?q?SpR5k6AjUjYqlK8DHK1GfOu8cjBM/MCiZxB+UWdrZ3e4PQYXirw9mdQp4/c/?= =?iso-8859-1?q?cmOg7u+UvFsKxBJiX1sYY/binOD2gDOEGzIf7Vaa/capyzJGggEFSP6Oz7Te?= =?iso-8859-1?q?7s3SNhDE/CAwEbz1anrhKnucBzIlIntz9B4kYFEYX4kjswqzuPg1x+EXs4id?= =?iso-8859-1?q?Oe3mO1aL+WDTdU2svZBuoFIcdXi7HOMqZ7R3jn0LNB8yCRZeawBTWcoTQZYO?= =?iso-8859-1?q?8ZYvCS23U7zIQklv0EaWxM18Sol0ZJ8XAyXO5ogWeid9HmB9sDqkNX70Krk+?= =?iso-8859-1?q?cgQBtXJQyohQkbtgEkrHdV/gZULwUclDO47f9bftQ2WjXoWR57YAkK08gqge?= =?iso-8859-1?q?2b2LmiuPOZxm/y0wfU+kCbxfL7ZVUkQwqAMv3CblWeWJblQ4K+zcujgklAVB?= =?iso-8859-1?q?GDMldA5zJnOGvOZhU9y7E7ovFS2CgF94+7x0//G8HFX4KWQCcckv1jfR5SMT?= =?iso-8859-1?q?Yu2RMqBCqpgyqZqike3CFGGC5FvRu3RJDYTEWDy/HBHmDj5C2FLrJkBqS04m?= =?iso-8859-1?q?wffqj6MVtu1BsNBJhVmFTRQyv2PlKQ/K3OMPa3ylv8SnF1o4eGEFTi9joEIj?= =?iso-8859-1?q?8Sm21Cw18Unx5gX4xXXeZvJqomZRb/QRuQtheRZM3T62s0Aq1INfnJ0u5W75?= =?iso-8859-1?q?eRdfBBb2C1lg7r1s3pEgN+VvG3zg6irzRU/IEgJbeteNTD3pCmvAZOmecQIb?= =?iso-8859-1?q?jUYQvv5KYvsXJsBTMciMLWAfhRk6hXHgnzQ6YEUYTH0Uc1HeWK35QELDeHtP?= =?iso-8859-1?q?RSRB4yzkzjH0nynEbOj2HeQ3vTtdyiHk6oq/kH42wkOOSAfxGBcXVJKCo/Lv?= =?iso-8859-1?q?GHlmyHHqlTi1a7yE29pNGs3Yfz6Lwpxb3NUdLcnp5xXVeyXQOjlXwHZMIKcy?= =?iso-8859-1?q?uFOs6edPY4mZtIoFYEjfrx1oi1M/egStwqcjTzgbv/boQXddonzEKm0hEXKz?= =?iso-8859-1?q?venPpH?= 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?nJ2mPoDiv+daiZkJOiYiqfS?= =?iso-8859-1?q?p/XPInGfVl//2FEsuU+/6qdDrLx4o8/bWhtL8SOf038J7IVvgnJiXyes54QL?= =?iso-8859-1?q?VNkIwrbyWXwyzmgdub/7Lrj5E6via3nIYJDcsi1PkBREufDii29GgZezpg28?= =?iso-8859-1?q?54fgMftQFFIIZG3Qa7f0CsPFSOKpsZGh5sSOWjosRz8wyRCeqhNaO6KvqwWw?= =?iso-8859-1?q?1S/92dHvkXu3fI1xNO/1qYECiUt7AMRJEV3ljfQvp5MXZjOACRC1Q92s8pgW?= =?iso-8859-1?q?ttFFJQFzvKuCYmy+rbnS30wwWPG/g7mmsvjAKFGscMzP0Ls69etYVNnvTVHC?= =?iso-8859-1?q?3/V0iw6z06lA0pNMwh9S2xBiu8LJ3RJ8SU3/vXRjnxGNMw0n8wJWbyZQ77Jc?= =?iso-8859-1?q?RzR5PthVwqd6Y/+7kECGN3t2K/UbqetolZZwUrn5Pya9N1n9OEUBN+xNYFHk?= =?iso-8859-1?q?StJ7NOCP63j+HHe2oef3NNmKJfzcw8kDOJtPNeszb6GQb2KWXE9OXw9Ve0rb?= =?iso-8859-1?q?dBf5lg8oToCk1aePZ27Ytd0kRH/iorLzSmlIpuAw/FJXbCmRgMvqlno6Zgf1?= =?iso-8859-1?q?ANXOveVrh1TUETt5MEJf5y1uORf+0Sn59bIyVYlwrzYSN4p4LlUB38dnp7tz?= =?iso-8859-1?q?6S5eozHV0mWxmZFkqPsmbtT3OLZ+SKTC+cqqNqj+xa+KwKrrdSTxBl+cSau9?= =?iso-8859-1?q?aqhAqp0oJvobN+Ckq72uJpsqsrelQlVHNoXDEhpiygaF4RnoBRFpGl/D9Uab?= =?iso-8859-1?q?2MtfQ11xKdnEEQi5xWNbxvulwABEF6ImXhLTAdXF91kuCKSmoRQTz91nAYch?= =?iso-8859-1?q?uFgSsHkclxaJcBO4I3VolPy0BUGcdjnAC6R9aT/kvHzAff/ofyoA5u5rBK9K?= =?iso-8859-1?q?I5Tl7Bxn2SSvUeXarwUsYsoGvVReUog5bPf5Sc/LkEG+XJ0c5M72+2Awi4K3?= =?iso-8859-1?q?DNp60P9yEa9wTDaGd0D+OuKdI+ioANUUqIFNskbq/YWdwKUn0s3RFxbVTvYn?= =?iso-8859-1?q?mDhRyiHmFxan83Lk6Wdj9bi3rR9EgSAAqaBPcCDmsCUvQ+w0PX2UgvwlCN/P?= =?iso-8859-1?q?7oi7FhN0W5f/JyxrhwyYRGqSysOOW494ul7pQGg0HVceuTL7Bed5hSc88sKo?= =?iso-8859-1?q?uE7Fp3LwyvkEfqCQUoPb3BwIhHpHG2JtCbg5LV2n2nufNzrM2RZAIBq7pisk?= =?iso-8859-1?q?cXXfprAyVkLvOZoBAPzF+j+y7s5qnMblqHYhi0pb+N/eCno3AvAhAvReLQ4w?= =?iso-8859-1?q?mKnSQf+VU6uKaD++U8lzCz5gftUaSYRzVdU7kXYoRCeSye2AjwJFYgcVeokI?= =?iso-8859-1?q?Ln45OBPlwrW1FGfquxSJqZsN/dr0KaPpYTVWK+zR0Az3HIWTZf5oSIMcE5AJ?= =?iso-8859-1?q?AUURxuvg2zeDQUGfBmIjQF7jXUcv/Fiu/oJi2ZIeiGYf3mUgjEba3vDnJXV+?= =?iso-8859-1?q?DwgGGizN0JGC9NYkxY/G1cuWac6Whcg4UzjI6hOD4CFfAJyi6YVXvg2LlDpa?= =?iso-8859-1?q?T8nkESIaaS1mqRxxU0t7t85dauxu1wz7WNksaXoVWfc3sAjr3d5R6NKlCQSF?= =?iso-8859-1?q?fXaMtjD0+exkzFOGOF6BNUZmP3OYmtbpv9JRhEs4FpI0NobZZzwhcMCio/E4?= =?iso-8859-1?q?6ZzRqts860iNhLVn+Ne4fgFRzYy51sxDm9OHidcZJZqjf0yirsRlqvVVcENM?= =?iso-8859-1?q?=3D?= 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: 6c90f56a-4787-4deb-fbca-08dd3979bc6c X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jan 2025 17:41:57.1050 (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: 5ErH0fGvVuliYHbgOHiUic24Bp9OL1zuieSbGFnu9KKpCm7kt9HLuCR89dqDmK3g3mfGjz4Dm8RQ29f4zuvtIT6tGXUSVyci628to5uQmDdOjL/AJMhJb5ysxAjjtYpd X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7548 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, 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: 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: Clement Mathieu--Drif We use this information in vtd_do_iommu_translate to populate the IOMMUTLBEntry and indicate the correct page mask. This prevents ATS devices from sending many useless translation requests when a megapage or gigapage iova is not mapped to a physical address. Signed-off-by: Clement Mathieu--Drif --- hw/i386/intel_iommu.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 530b75a9a3..3c31dc1047 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1995,9 +1995,9 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VTDContextEntry *ce, uint32_t pasid) { dma_addr_t addr = vtd_get_iova_pgtbl_base(s, ce, pasid); - uint32_t level = vtd_get_iova_level(s, ce, pasid); uint32_t offset; uint64_t flpte, flag_ad = VTD_FL_A; + *flpte_level = vtd_get_iova_level(s, ce, pasid); if (!vtd_iova_fl_check_canonical(s, iova, ce, pasid)) { error_report_once("%s: detected non canonical IOVA (iova=0x%" PRIx64 "," @@ -2006,11 +2006,11 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VTDContextEntry *ce, } while (true) { - offset = vtd_iova_level_offset(iova, level); + offset = vtd_iova_level_offset(iova, *flpte_level); flpte = vtd_get_pte(addr, offset); if (flpte == (uint64_t)-1) { - if (level == vtd_get_iova_level(s, ce, pasid)) { + if (*flpte_level == vtd_get_iova_level(s, ce, pasid)) { /* Invalid programming of pasid-entry */ return -VTD_FR_PASID_ENTRY_FSPTPTR_INV; } else { @@ -2036,15 +2036,15 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VTDContextEntry *ce, if (is_write && !(flpte & VTD_FL_RW)) { return -VTD_FR_SM_WRITE; } - if (vtd_flpte_nonzero_rsvd(flpte, level)) { + if (vtd_flpte_nonzero_rsvd(flpte, *flpte_level)) { error_report_once("%s: detected flpte reserved non-zero " "iova=0x%" PRIx64 ", level=0x%" PRIx32 "flpte=0x%" PRIx64 ", pasid=0x%" PRIX32 ")", - __func__, iova, level, flpte, pasid); + __func__, iova, *flpte_level, flpte, pasid); return -VTD_FR_FS_PAGING_ENTRY_RSVD; } - if (vtd_is_last_pte(flpte, level) && is_write) { + if (vtd_is_last_pte(flpte, *flpte_level) && is_write) { flag_ad |= VTD_FL_D; } @@ -2052,14 +2052,13 @@ static int vtd_iova_to_flpte(IntelIOMMUState *s, VTDContextEntry *ce, return -VTD_FR_FS_BIT_UPDATE_FAILED; } - if (vtd_is_last_pte(flpte, level)) { + if (vtd_is_last_pte(flpte, *flpte_level)) { *flptep = flpte; - *flpte_level = level; return 0; } addr = vtd_get_pte_addr(flpte, aw_bits); - level--; + (*flpte_level)--; } }