From nobody Sat Feb 7 04:02:17 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1748547137; cv=none; d=zohomail.com; s=zohoarc; b=NM6W+Ozbv3pPD7X/9rlFr5kM1atQA42xhWXmV6wtJKX3DaPIe7jvVIos0SkAzIoXusgHl0pm+vKgddRMAt/aZUPcNtzoSmZkoXLoajHefZQqh9mb7KHBeuBwrFZEAj9lzdUNTkL4T32TB/v/MM9H/gc37QyV8n3h5JMSik6fI4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748547137; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1vbh1uDB13yiD152yJ62wuX9AEeqoGKtdJ12LOns2iY=; b=l21x4Jx6oz68SDGVbdE7rk/oUO+hH1pwD43y0jEsLJbcQy5S0PwSy8FUCLtSoaPsOKhNaF3lKVGdmlJiiVTVXxVpHjULzyJJJ3CKKKdhsPu+/7lSwnNqc7+uBxrtXpjAtTLsxx4Y7aH7QYoXlqZaViBG7VC78yvSZta/FKEDMkY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748547137430293.5304243117272; Thu, 29 May 2025 12:32:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKixh-0001gU-F8; Thu, 29 May 2025 15:30:46 -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 1uKixZ-0001Nx-TD for qemu-devel@nongnu.org; Thu, 29 May 2025 15:30:38 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKixV-0001FA-TJ for qemu-devel@nongnu.org; Thu, 29 May 2025 15:30:35 -0400 Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54TGfsUR031396; Thu, 29 May 2025 19:30:28 GMT Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 46v33n0ypp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 May 2025 19:30:28 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 54TJO1VW019272; Thu, 29 May 2025 19:30:27 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 46u4jccs0q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 May 2025 19:30:27 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 54TJUOVB005039; Thu, 29 May 2025 19:30:26 GMT Received: from alaljimee5bm-ol9-20250405.osdevelopmeniad.oraclevcn.com (alaljimee5bm-ol9-20250405.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.254.235]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 46u4jccrx6-4; Thu, 29 May 2025 19:30:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=1vbh1 uDB13yiD152yJ62wuX9AEeqoGKtdJ12LOns2iY=; b=pISBjBmwWF0wq9HZIoEhU iICvQXQXv3H8l2bBQCBDzK67V1B6wjiN6Vsb+OyGJAugvrXfoiEAX1gy/QnSnVXK Zh9ulCOg/tTEU0jT7MN2JynJRfXhcO6PL/eE8WDNo8YkcpIygL+lxdYqzODiHvd8 e4VIl5z+5vyHtd/s3+ZAIQN6cZdBvqoIbM6dnbkCP5QZ/25VaivRKWjdolTx5uJ6 NRw7RL6JTMOSBaFXH9VIGLDLZDr7nU2hfOkxDVTnXRNycVV9QVTbPwD43vNh1DBI mkUCIzK+J3afN4ouWxmu6Jzs44FFHRdAPS1Z2wpC4cpmubFJKn5Ppe7420uAKW2Q Q== From: Alejandro Jimenez To: qemu-devel@nongnu.org Cc: mst@redhat.com, pbonzini@redhat.com, mjt@tls.msk.ru, marcel.apfelbaum@gmail.com, richard.henderson@linaro.org, eduardo@habkost.net, vasant.hegde@amd.com, suravee.suthikulpanit@amd.com, santosh.shukla@amd.com, sarunkod@amd.com, brijesh.singh@amd.com, joao.m.martins@oracle.com, boris.ostrovsky@oracle.com, alejandro.j.jimenez@oracle.com Subject: [PATCH v3 3/7] amd_iommu: Update bitmasks representing DTE reserved fields Date: Thu, 29 May 2025 19:30:19 +0000 Message-ID: <20250529193023.3590780-4-alejandro.j.jimenez@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250529193023.3590780-1-alejandro.j.jimenez@oracle.com> References: <20250529193023.3590780-1-alejandro.j.jimenez@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-29_09,2025-05-29_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 bulkscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2505160000 definitions=main-2505290190 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTI5MDE5MCBTYWx0ZWRfX12frAUbUhcAt YUfJCubxxJYxlWwyxEepz7nL8t+SspdW9X0+/ftiuGaLm6ZYXoSo3D+rsKkD4wIUDNUoyxF6xDf 3PCuLM1M9g3seCG00iVqwwBZnAdqQWXrjrN4EkGtE1Td4RRGIdqEaeLCcGas0onMHQ8erkeT7Iz 93XISuMSxxIR6EnPeYJt7sC5wi+UlIl+Tz8bnCV0mJ9Ib1YIWUDmNBeWzvhkzk4Wo+8HFapxjB/ jM75nSFaGa22mbj08y5FnJLThtAJFZb2AyCKZL/gyNn9FAiTHW7SNzKS1HZZzfbD3wFG0LA/+b9 koqnRUGfyGhAhpdKfSh+qVmJ7bzDqM2byATEsXdIILux4aaOdamRyjtNwlPADTrSDB9ZYkbAbej lADuZ9Tn4Q5bfwFOAx/+JgXXtqPhyEqDeWxNFMAeKz6LVXYG7KllQxE1lTzCeA2FfDorfiJi X-Proofpoint-GUID: _id8dPMMUfYizwNjdpat4MzmhRuM_nUg X-Authority-Analysis: v=2.4 cv=aO/wqa9m c=1 sm=1 tr=0 ts=6838b5d4 b=1 cx=c_pps a=zPCbziy225d3KhSqZt3L1A==:117 a=zPCbziy225d3KhSqZt3L1A==:17 a=dt9VzEwgFbYA:10 a=69wJf7TsAAAA:8 a=yPCof4ZbAAAA:8 a=zd2uoN0lAAAA:8 a=4jmliWysXe4-JJ31YZsA:9 a=Fg1AiH1G6rFz08G2ETeA:22 cc=ntf awl=host:13206 X-Proofpoint-ORIG-GUID: _id8dPMMUfYizwNjdpat4MzmhRuM_nUg Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=alejandro.j.jimenez@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.499, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1748547139364116600 Content-Type: text/plain; charset="utf-8" The DTE validation method verifies that all bits in reserved DTE fields are unset. Update them according to the latest definition available in AMD I/O Virtualization Technology (IOMMU) Specification - Section 2.2.2.1 Device Table Entry Format. Remove the magic numbers and use a macro helper to generate bitmasks covering the specified ranges for better legibility. Note that some reserved fields specify that events are generated when they contain non-zero bits, or checks are skipped under certain configurations. This change only updates the reserved masks, checks for special conditions are not yet implemented. Cc: qemu-stable@nongnu.org Signed-off-by: Alejandro Jimenez Reviewed-by: Vasant Hegde --- hw/i386/amd_iommu.c | 7 ++++--- hw/i386/amd_iommu.h | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 55202eb9ef7d6..cc47ba9249990 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -848,9 +848,10 @@ static inline uint64_t amdvi_get_perms(uint64_t entry) static bool amdvi_validate_dte(AMDVIState *s, uint16_t devid, uint64_t *dte) { - if ((dte[0] & AMDVI_DTE_LOWER_QUAD_RESERVED) - || (dte[1] & AMDVI_DTE_MIDDLE_QUAD_RESERVED) - || (dte[2] & AMDVI_DTE_UPPER_QUAD_RESERVED) || dte[3]) { + if ((dte[0] & AMDVI_DTE_QUAD0_RESERVED) || + (dte[1] & AMDVI_DTE_QUAD1_RESERVED) || + (dte[2] & AMDVI_DTE_QUAD2_RESERVED) || + (dte[3] & AMDVI_DTE_QUAD3_RESERVED)) { amdvi_log_illegaldevtab_error(s, devid, s->devtab + devid * AMDVI_DEVTAB_ENTRY_SIZE, 0); diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 75a01eff468f5..45a997af861e6 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -25,6 +25,8 @@ #include "hw/i386/x86-iommu.h" #include "qom/object.h" =20 +#define GENMASK64(h, l) (((~0ULL) >> (63 - (h) + (l))) << (l)) + /* Capability registers */ #define AMDVI_CAPAB_BAR_LOW 0x04 #define AMDVI_CAPAB_BAR_HIGH 0x08 @@ -162,9 +164,10 @@ #define AMDVI_FEATURE_PC (1ULL << 9) /* Perf counters = */ =20 /* reserved DTE bits */ -#define AMDVI_DTE_LOWER_QUAD_RESERVED 0x80300000000000fc -#define AMDVI_DTE_MIDDLE_QUAD_RESERVED 0x0000000000000100 -#define AMDVI_DTE_UPPER_QUAD_RESERVED 0x08f0000000000000 +#define AMDVI_DTE_QUAD0_RESERVED (GENMASK64(6, 2) | GENMASK64(63, 6= 3)) +#define AMDVI_DTE_QUAD1_RESERVED 0 +#define AMDVI_DTE_QUAD2_RESERVED GENMASK64(53, 52) +#define AMDVI_DTE_QUAD3_RESERVED (GENMASK64(14, 0) | GENMASK64(53, = 48)) =20 /* AMDVI paging mode */ #define AMDVI_GATS_MODE (2ULL << 12) --=20 2.43.5