From patchwork Mon Jul 8 11:39:54 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: 13726443 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 B4ADEC3271E for ; Mon, 8 Jul 2024 11:41:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQmjO-0004O1-AP; Mon, 08 Jul 2024 07:40:30 -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 1sQmj6-0003x4-UD for qemu-devel@nongnu.org; Mon, 08 Jul 2024 07:40:13 -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 1sQmiv-0007ru-2R for qemu-devel@nongnu.org; Mon, 08 Jul 2024 07:40:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1720438801; x=1751974801; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=hVh5soF1sbHB0PJ604yENPnseV6Ov4o/X3k1Zl3qdXU=; b=TWZkvPXcuqc5p/iVCmIpIpBx+PsSzyctJZAIbTKyZllW0sqXIWwHbdnq TeBq3+n5eDgHB55LI2+w6ozGP3WOAeFS6m8zzWis7aHhlfche13D/6LkG B3C9tRGl+pA8kUW1540NCGcerTE6qraimzAVtSa1CbOnudbFjeOGW6YpE SVVGMA5p1GngaeFJPu4kuYvjlrzRwvSmtWB9h/2mKn7MHyGtK+WJjq+2c nD4UByXeJcm2kwIJ3F3lpo2e6xkuEf/5AQGPbfCDLlX23Kc3rc/IF6NDA Q7FEvkpvSIKEz/o/IBHI4ZGeDTPUDS3+waJ7bG2i2kSWRDYExlaqTKaBT g==; X-IronPort-AV: E=Sophos;i="6.09,191,1716242400"; d="scan'208";a="16088415" X-MGA-submission: MDFAqD+/7YTWuWa8Ao4O1OoCaN49GNglfsbPirOs6tkaG/U9KBFGAuRK0XcXjLR6Kh7UL2EP3Tp261Dm05SwwxM/zUfwWCsqYXbILs7FW9IhPvVGRSYbTS6OqDK9PtwrxNVOKZH1Ve4burjLtzEa6MnMrRq9vFtjJHBWLthZbrFnKg== Received: from mail-vi1eur03lp2105.outbound.protection.outlook.com (HELO EUR03-VI1-obe.outbound.protection.outlook.com) ([104.47.30.105]) by smarthost2.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2024 13:39:56 +0200 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CFUmfmElNTxIm9dEnaCgZ9LixdOLaGvdmpRuAXaedfTfCBbwHlRKfdhQOwyCt5gPaxDpO9ou1wDsCHqzNaJR7LviAS5LgGbds1ybTP5Z0CVBEg4Yan9RnCDH2LAFBz9Vx1PwssXbfb+Sl718uCuqaZIhRQKKhXmCo6vU8iXr2fp0hgVMbEluJ/EwKJkJPI4h2TmPpLmGAEX0Vt/TV4XRWRbeIB6xiQ7sa2N6xm4QeA6K+XwrSIgvq1rEZRgHR/xm1PL+K0nqTE8QGmLwpCQ2hilseIr618OqPoOAey7W2G8y4mkup0vv2bwdamr7oRGqbdTdG2DV4ESyJCurWMfyDQ== 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=hVh5soF1sbHB0PJ604yENPnseV6Ov4o/X3k1Zl3qdXU=; b=k3bfaldWrJUtMHlr/EAGbZe8s207dIOC0nM0Wh5jaAx0Ma2HtleEoxCWIco93OLJsSV06GSa7LUp9hSA5RalSf7KEI/Fu8vCKbM2nW/+PkEhjjxwiHqOz6Cs2pqMYdzKLs+5EXtu3DY6gh1O9tjeWSBRQJ9asI6UV6sff0QErF3M3nhhhLkPp08/MmgYumOVmsmNr1KrYMDEWo9oyT+mc7FqU5ZJOzvMO8++In1Wdk8ayJJqHxoT3TPXo0D1EKc6jbmhWj0IkmsEMq7Wgr5BfyjCMYUbX8WSYPX46YSIq+6pJKr+uv1Ek+jq5ckeoYo/x4coyO2f7S/POYKHiIlZsQ== 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=hVh5soF1sbHB0PJ604yENPnseV6Ov4o/X3k1Zl3qdXU=; b=AqR0fxLuLUbZoeSvqyd/ObYWNuIftjX0sHOUgYEPiqfBXL+5MrpTqpt5h4DQz7WM6Dy5180SjQkFn8E4U61P2i76whnSJloOmkkr8kDk4A987c34oqXFQsPlJMs8bo1SiizGv+paGzbFtBAkuo4y5ApZrxkufs/M0P2JXbwcScNBj4QMOtXMuT51+KjCWH5vsiOdqzHpfGDS/7fXpyvuzCYCpDqf+pdvrDhnN6xLagLD6qJhgN2cBAC2WHLuOO7DHBgVPGWSrZ0wLRNmVdZLJqLEfutKVInYDTBHX7PupBOcxgGaGKjsDlS5DfJgorHCDXA7iH0pbLtUWJLpPYhp4g== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS8PR07MB7400.eurprd07.prod.outlook.com (2603:10a6:20b:2a4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.18; Mon, 8 Jul 2024 11:39:55 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%4]) with mapi id 15.20.7762.016; Mon, 8 Jul 2024 11:39:55 +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 v5 3/4] intel_iommu: fix type of the mask field in VTDIOTLBPageInvInfo Thread-Topic: [PATCH v5 3/4] intel_iommu: fix type of the mask field in VTDIOTLBPageInvInfo Thread-Index: AQHa0SuNYymPsQHFfky5WnjMRsYUBA== Date: Mon, 8 Jul 2024 11:39:54 +0000 Message-ID: <20240708113908.19535-4-clement.mathieu--drif@eviden.com> References: <20240708113908.19535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20240708113908.19535-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_|AS8PR07MB7400:EE_ x-ms-office365-filtering-correlation-id: a59437e5-7193-42b2-b31b-08dc9f42b00c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?pqWRHhweOmfVqjaCYCHRwaryZ4FAbME?= =?utf-8?q?QjKRvp3OWjmhowf00s3ctdVa1a5VxHmooS5E7BtbDPP+T1m07D9UDLFxG+zYJsEXq?= =?utf-8?q?vlKePUzZcBbiCjEHl/VKJT0OIOS/JaKK2Ensk3DNGEyRGGiRF15yMsWuAJp2ANpti?= =?utf-8?q?prtK+GF004OB8jIk1lR4zTPFLiXgVMTwSz/J21kJ8wJmSFiFx/6ayhqBqadBiK8hU?= =?utf-8?q?PQd9aCQ1y5+wLDLwt6dWL6ps3z6QkZEdp3+/9KPrb3OE4vk1vpwLpeMIJHtg6mhs7?= =?utf-8?q?Qla4CyrZjy8YqQB8PcST1YXVONHJRNTVc7KE46nBaU4gieXKX+/BmkLQBDhjaZd/z?= =?utf-8?q?qYLd8zG7gpTMF0WQsZU7eABIoEhvGZBw02WDS+okNgxct//v+AT6uYlW+ATXYLoV1?= =?utf-8?q?dClIITYg+pbHWqrm4yhHMefQWWmT6JTVriOUhLB6E7nLhHAbOUvFI7VGf9TVY2IUZ?= =?utf-8?q?ZRxupR8w5AAE/QLkSddatZ8CWkw7RHkQpumW4cX7cKija+wfFF+XUxldOUGFfbH85?= =?utf-8?q?vPSNjqv/8HMe/u8fR4WS8Zxfdg/xzMmd10MABvXCLs4CNmv9Wfm3HRgNZz+ssfaT3?= =?utf-8?q?IHBzRMMcxxLJY06QDzlIwI0ux5xXfm192jQlyDwfJt9WaH3plNNkhaf/QHTq4l6vA?= =?utf-8?q?Xb+oexY483MLRLWgw0GyFsUpvZ6lDD+CX684kgNuA9saB0UsrKTKPPrW/V52Rdyw6?= =?utf-8?q?6xAVh5LB4CoxvSHPw5JLvNXVK45nYk4pgZ0cJHLW1lraN6gQawhUaHEApzeu0c37T?= =?utf-8?q?2IOXQ4rqko0drKPKLO18x83wV7yuM0jxgxd/ex3U08R2Azz52x9uVLMOuVu24qIta?= =?utf-8?q?6YiKopZYCBT1xBycRywnXM7VoRann/eKm+dMnh93QbOkpeNwqd+PpMAjVElLjW6N0?= =?utf-8?q?TlDslaxcg4xbIHMYU0tHlmmd4tSwz1IAo1/QPDXSGUocgz6I8PJEtsVFZEFARY20O?= =?utf-8?q?l34tbOxVTVot2tFQyBsMDfKZJvUKUA5l5ghK/ezH2kVkb/OMuR2Xl7aOH7YDA6Isq?= =?utf-8?q?9s1JYZmXFfm1037a7H3mJBTiqeKXBAMDbriiJ0hDJ09q2HHLzL5Ht8BoJ3MS57a1U?= =?utf-8?q?KYj1d9v7M8COp7BuoZWe/V/3J7avayVS+rdHwbS7ow/1uZrYjhN80AWoeZNcrCFeI?= =?utf-8?q?dAsGsFKd7bqNgH15rxx8SOp2/zzrsY3ZJMxN8AwnGUOhgWrGO5xAdGFb1rYd0gJrt?= =?utf-8?q?TBjknfT/v1nIIM0sRlbe2MyVQQBHmoOLNPOxZnNCcLSkneksLWHviiQRDqtCTNRaP?= =?utf-8?q?YfnhrHkImD7qytD+ukN1lfUTL/pwUpP+9sIA4Zq1RHrSRB1Ok7ubySYZXFL5dTzKt?= =?utf-8?q?Ti93omVstAoFzxGzkDQxOAvt4eMbStUyqg=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:(13230040)(366016)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?tzZGdDfKDONhGfCADt7IVHxgWNld?= =?utf-8?q?K6qW+0KsGiBfvUWLCsVYPHfN9qa9gXnYyhItYzXcSd6Rwfg0yxL5O2DaiuoIQVR9z?= =?utf-8?q?SmowKxTjxtKtDguiRtIV8JWrlKiNDTMtvvDyNXW2laws7inhNSjtC8FZKTHvdE1nW?= =?utf-8?q?cEUTZPcU455KCGEJ/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Q/F7JQxm9S2ixJG2MPKOs7NegUc02hOfpquGOOp?= =?utf-8?q?GO8RlXHifAvvCxNwi07OdwlB+R49kL2VBQW5n/yBIIxtO5xOJES4ff0D7svMsM7Yn?= =?utf-8?q?OFDdNeuCHa9ARUno/oBfj4FQGY6M7cNUMupxAPPjcC2CtjdJKB4hAKQ7Bg4Kz2cBK?= =?utf-8?q?1G88PJVdGJZy1r9wk002hpXgofSQgFgVGWCpUbg89iadITAfUu8YHup26AOaeyIya?= =?utf-8?q?lXom+Cs2B0RFmlpEEuY6kW5Zwo4pyJMb4EXii6B8wGmnMFDcazDrV2sWWola+nQTI?= =?utf-8?q?T6uEbQPAzgMTjXLYm+F0+M1iojH2bqUOYwXCgtaRUH9imYO6d0YLdSH6XXZNrpA9w?= =?utf-8?q?gZm12SdX2rRsj6jEXLXcTq0P2XjqucP7sffmQCzDZnOzYkmeChN8uPOrCPODMyNoD?= =?utf-8?q?Yf8yeQ9j0U+3PK+vYp8gR7UTNenZm9cbmroC99mxSTiec8rqg/I0wklIaz+MEGVeP?= =?utf-8?q?NSLEWy3ZFHDO3sfU9M9tjH9DqnMT8y9n5BWdhZg9r0QsyIi4ncNvSYE=3D?= Content-ID: <335F543A0BD124458A581B97CC6CBA0B@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: a59437e5-7193-42b2-b31b-08dc9f42b00c X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jul 2024 11:39:54.9477 (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: 3lxipbX/oFtypJYJU3vQGThxZYW/naPd/r5tN+PkJqzZ9u4cQAWISZw14G4Q7agHIPuduSWCQJytOKOQH/6hxqsxiuacwj5WRGmy+fVRJbXVxX+HK5HaLUon2ZchEkRW X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7400 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 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 The mask we are trying to store into VTDIOTLBPageInvInfo.mask might not fit in an uint8_t. Use uint64_t to avoid overflows. Per the below code, it can overflow as am can be larger than 8 according to the CH 6.5.2.3 IOTLB Invalidate. And you may want a fix tag as well. info.mask = ~((1 << am) - 1); CH 6.5.2.3 IOTLB Invalidate Address Mask (AM): For page-selective-within-domain invalidations, the Address Mask specifies the number of low order bits of the ADDR field that must be masked for the invalidation operation. This field enables software to request invalidation of contiguous mappings for size-aligned regions. Refer to Table 19 for encodings of this field. When invalidating a large-page translation, software must use the appropriate Address Mask value (0 for 4KByte page, 9 for 2-MByte page, and 18 for 1-GByte page). Hardware implementations report the maximum supported address mask value through the Capability register. Signed-off-by: Clément Mathieu--Drif Reviewed-by: Minwoo Im --- hw/i386/intel_iommu_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index faea23e8d6..5f32c36943 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -436,7 +436,7 @@ struct VTDIOTLBPageInvInfo { uint16_t domain_id; uint32_t pasid; uint64_t addr; - uint8_t mask; + uint64_t mask; }; typedef struct VTDIOTLBPageInvInfo VTDIOTLBPageInvInfo;