From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.9590.1642755197908530037 for ; Fri, 21 Jan 2022 00:53:18 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=lMB9WqBG; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: jenny.huang@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642755197; x=1674291197; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=T9xHPTI0+PVOCnL0VIaRt5kW9PqPZ5IpgcSyaVHFN2E=; b=lMB9WqBG8aIdrn0sn1yt0zQFJcENrjfXfmjbUg1RkjbSOj3Zkvc+8kH7 oFRegCP07Pe61imix73RNgUN33KZS6kSd9W2/Z0P4sYsudldEtVIsLrUW BTENsSTA/0/Np3TlgEbgoIiAFg0fYCiB6GWKwAefJv7/AdmM2OXv+wFrN w2fwMaV8EH651fXwF0Imu7hAJXg6/jCYQpsuK+Tp9o2mGQ6Vud9hAsjZi siuiS6yz4dTSLchXFBg1D2CGbNZDa/MSLprPy8NGhnZzZ2lsaWftlTXjg 4MLnJu4g2NPdASoNO2XdiFd/qlXHh4EpXhCv+QMzUHdKcT36ep1lIWlgD Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10233"; a="225584827" X-IronPort-AV: E=Sophos;i="5.88,304,1635231600"; d="scan'208";a="225584827" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2022 00:51:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,304,1635231600"; d="scan'208";a="493775761" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga002.jf.intel.com with ESMTP; 21 Jan 2022 00:51:48 -0800 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Fri, 21 Jan 2022 00:51:47 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Fri, 21 Jan 2022 00:51:47 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Fri, 21 Jan 2022 00:51:47 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JdzY+tCKuNgTKCX1iUAtOpDrPhUmNAozDEnEMkmch63YlI1E59imWFnP5iVSx5DU7QDQVmEXGQHDjbX7DnxDfpUKriHCN9wwGl18f6CMJtuwmPaimNPNIwMBlD9ZyoM/mlCl66yqrA77bN1UfLS+jBOXqCHnzkQtj8zOnArjQuy4gddbM5KpISCeNKp2zy313szBLuCKvV0bNzKhqxeTHhKTv3ooC83tHfIj9JRaLZbaggPjs5M1RVwuo0Td/b+OBcbNWqojBT9a81MFyaE3HUf1fbxd2MlDUg/Twx4SzsR3uj11SN9OYVC3PWK2kmQPmnTIt7i+aIZGykNNFG1JNg== 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=BqAogE82ACCT8hV2mNccDttOCHvljSdUaEo2aQieIyg=; b=RCtCWWqIopULKQTV54QAmSR7xkzj6h4TwwsUoHulIfo5AFj9sqI/D+WgvTx1dg+ASrbrz/f5N8iveY3e9fnBD8zpKjvh9vnDecTrASbfkAdd99NAgbEx/+dbMy05R5oIbDHlV3spnU7gbjNNQEKhl3yfQlarN4JBzlWhSJvY/0a6B8zs5OfkGT57Rd3vCba5VsdpOMp6oUswzfxEQ6G0SuOn2+spzuQgaYfKEd8LMcfhvhpzIdbyhGutGqBBqWqEZ0hm60/M1CnUDZk45uX31MRCQNffzDNBXD3t+eNBWtkMjtwZBadJpNu5bfi3GzGl57wcLpWLGK0Ag5QxWAuQ6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from DM6PR11MB4627.namprd11.prod.outlook.com (2603:10b6:5:2a2::19) by BN6PR11MB4178.namprd11.prod.outlook.com (2603:10b6:405:84::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Fri, 21 Jan 2022 08:51:45 +0000 Received: from DM6PR11MB4627.namprd11.prod.outlook.com ([fe80::d48a:c41e:cdea:8e58]) by DM6PR11MB4627.namprd11.prod.outlook.com ([fe80::d48a:c41e:cdea:8e58%5]) with mapi id 15.20.4909.010; Fri, 21 Jan 2022 08:51:45 +0000 From: "Huang, Jenny" To: "Sheng, W" , "devel@edk2.groups.io" CC: "Ni, Ray" , "Chaganty, Rangasai V" , "Kowalewski, Robert" Subject: Re: [PATCH v5 3/4] IntelSiliconPkg/VTd: Support VTd Abort DMA Mode Thread-Topic: [PATCH v5 3/4] IntelSiliconPkg/VTd: Support VTd Abort DMA Mode Thread-Index: AQHYDEOAGn7tz3hhSkaQ6JDa9ETsZqxtL3KQ Date: Fri, 21 Jan 2022 08:51:45 +0000 Message-ID: References: <20220118081433.15620-1-w.sheng@intel.com> <20220118081433.15620-4-w.sheng@intel.com> In-Reply-To: <20220118081433.15620-4-w.sheng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.6.200.16 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5ce658c8-fc5b-4b9b-014c-08d9dcbb4104 x-ms-traffictypediagnostic: BN6PR11MB4178:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ggy0vkkQ6QXexoDYXPBbB3g90553PixGxY1ZMac+ysjzq0bFcTe4YzNdf/syqQ1p8/KWk+CmsTql/RYVletqPW0lIo7HxAdRZYMg0XJSy3b62AKnP0umtneZtyeVoNpnc7TYNaSQKsqzdQ9TOsDquVqK8wM/y5X4t9TIz5CWqD6aOQ5JLB6NFpz8A4aZfOfweUbvwnNEc1vhfiRoQG9a39nfB6nbpTvG0GsoWRY2AqEUt/m0klcjKmP4I5dPnKdIxjgilQ3Aaj0CGrPUpGp3FUsa0nqZ2ZchNaMQuNHigNOM3576kl1W4pX/x1mpKBmL8xU/+2Ulm8+cnoLo3PhcsgOIa1S6Lx4GwR70X/Wtc5b2add5ySbrnma6sdiZ9F6Qv8ojVBgdvWmSA98Cp6Be+qlHctTB4nHTdyqUidoAMHHhUZBLfRbqPSjJbwGIHu5eZWipnfFbZlwxn5icVVCTUzj60iYwe7AVQIoSqcNfSlQ++e5kW6gmkkD9v6dJbbx376CzUITk69quJ4gkisePP9qAmvK+b4kEOQe7dvkZa21tsj6gvLuu/TUz2azyQf4l0DhZu8An/C0LSzYIRfmtySwAwOuoBSlbBzcpxcDyhGmi2OHdz/kGvP9klKpTXYbRWai1Kq75Yel5XGXkx2NYbfwtKCfckxGE+qVLbQCAgJtaiSPrWB5zFneu1ElGqp5LAa1YPdtGH30w4XoImIUw6witHyGWDLMIwSKSXdmwyqziW1Y0zGZVc7ixHW+JLn0UwxVO/C2BMH7gWjQPq3v1CMQLbZLohkNM9rx2Cj4svGQ= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB4627.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(76116006)(6506007)(53546011)(110136005)(186003)(26005)(38070700005)(4326008)(316002)(5660300002)(508600001)(33656002)(66946007)(7696005)(107886003)(54906003)(66556008)(64756008)(966005)(66446008)(66476007)(52536014)(122000001)(55016003)(2906002)(83380400001)(9686003)(38100700002)(86362001)(8676002)(71200400001)(8936002)(82960400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?5aMibxXyVPZafTcm4uPFJQMWln+NK+fBe+Of7KiycXHSSscRFCV5khmD8kB8?= =?us-ascii?Q?m+4KrQI34FlyJcfREpB6d7PeP6+N6RFhzahMNilJH4+H5nGAFgk/KnZr471k?= =?us-ascii?Q?cpVU/4j/rgPk8D8kOfF9zNr0QIaVDJ8e3qbxqXRB71uB/E/DdSTPNVJNYKxq?= =?us-ascii?Q?6SGIKZwnzPJ+WAz9rxkYPyGq9BFcbJNRfZVyISWxYJAwFY9jAn6MrZSYVX3m?= =?us-ascii?Q?yDkE39Fj18qpk7ypKE0Ad9/SCIPYwWkChCPSGt3WnDsLn9f2N3UPHklrXqbI?= =?us-ascii?Q?/ON+HxdMi8AdO8HC/VreGrmKoGIfiXb79yFoXvlgqkpMBllesJBt/idfBadi?= =?us-ascii?Q?KFBzZODhpUYJBxsMyUDXZslnXJkSWSE+aZbWCles9OtUn6ihOeQACUrKFVqi?= =?us-ascii?Q?id1M0Z+4optqWA9TpU33JzxTxCmauN2N3ODKLdbn/LDg9TtQ/ceLd2pM1x+l?= =?us-ascii?Q?JAdPLnw85LtovW5lvOqSKcHN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Q?wgIoaslauSn94eICvA2/5ThAXCHrtFWfYLbx88f2lD2Ib6XrlQh/Kb1xXM6m?= =?us-ascii?Q?cnUmZPDPqQsn7tRtdQT/pZ5plWYukT/GR0Gq762oPvcgXa7Dal66DgFB0woR?= =?us-ascii?Q?8NeIRKrGc1glTP2aizkXPShuTcS2/e2BvWx9ZWMfj6FSlKhH7GiGdtrcI+kY?= =?us-ascii?Q?7gtl4fOeaM2WBj6JTg2Abhme7vZeM79qtbBcg7gkZ6DUaovPFLaEcvhTIynf?= =?us-ascii?Q?PSUf94JN3b5NqwiryOqONKM=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4627.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ce658c8-fc5b-4b9b-014c-08d9dcbb4104 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:51:45.6339 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: iXdsOwDbP40Sa4X/ao/6xYPaTUBfnY2F/bLuKXhV7bdC0L87IvuX3M7kwNnUuVtNxDF7ohQqKSU0QfS54S4+Ww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB4178 Return-Path: jenny.huang@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jenny Huang -----Original Message----- From: Sheng, W =20 Sent: Tuesday, January 18, 2022 4:15 PM To: devel@edk2.groups.io Cc: Ni, Ray ; Chaganty, Rangasai V ; Huang, Jenny ; Kowalewski, Robert Subject: [PATCH v5 3/4] IntelSiliconPkg/VTd: Support VTd Abort DMA Mode If VTd ECAP_REG.ADMS bit is set, abort DMA mode is supported. When VTd Abort DMA Mode is enabled, hardware will abort all DMA operations= without the need to set up a root-table with each entry marked as not-pre= sent. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3766 Cc: Ray Ni Cc: Rangasai V Chaganty Cc: Jenny Huang Cc: Robert Kowalewski Reviewed-by: Jenny Huang Signed-off-by: Sheng Wei --- .../Feature/VTd/IntelVTdDmarPei/IntelVTdDmar.c | 43 +++++++++++++-----= ---- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDmarPei/Inte= lVTdDmar.c b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDmarPei/Inte= lVTdDmar.c index 87ce9716..63397a1a 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDmarPei/IntelVTdDma= r.c +++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDmarPei/IntelVTd +++ Dmar.c @@ -384,7 +384,7 @@ InvalidateIOTLB ( Enable DMAR translation inpre-mem phase. =20 @param[in] VtdUnitBaseAddress The base address of the VTd engine. - @param[in] RootEntryTable The address of the VTd RootEntryTable. + @param[in] RtaddrRegValue The value of RTADDR_REG. =20 @retval EFI_SUCCESS DMAR translation is enabled. @retval EFI_DEVICE_ERROR DMAR translation is not enabled. @@ -392,15 +392,15 @@ InvalidateIOTLB ( EFI_STATUS EnableDmarPreMem ( IN UINTN VtdUnitBaseAddress, - IN UINTN RootEntryTable + IN UINTN RtaddrRegValue ) { UINT32 Reg32; =20 DEBUG ((DEBUG_INFO, ">>>>>>EnableDmarPreMem() for engine [%x] \n", VtdUn= itBaseAddress)); =20 - DEBUG ((DEBUG_INFO, "RootEntryTable 0x%x \n", RootEntryTable)); - MmioWrite64 (VtdUnitBaseAddress + R_RTADDR_REG, (UINT64) (UINTN) RootEnt= ryTable); + DEBUG ((DEBUG_INFO, "RTADDR_REG : 0x%x \n", RtaddrRegValue)); + MmioWrite64 (VtdUnitBaseAddress + R_RTADDR_REG, (UINT64)=20 + RtaddrRegValue); =20 Reg32 =3D MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG); MmioWrite32 (VtdUnitBaseAddress + R_GCMD_REG, Reg32 | B_GMCD_REG_SRTP); = @@ -662,18 +662,6 @@ EnableVTdTranslationProtectionAll ( =20 DEBUG ((DEBUG_INFO, "EnableVTdTranslationProtectionAll - 0x%lx\n", Engin= eMask)); =20 - Status =3D PeiServicesLocatePpi ( - &gEdkiiVTdNullRootEntryTableGuid, - 0, - NULL, - (VOID **)&RootEntryTable - ); - if (EFI_ERROR(Status)) { - DEBUG ((DEBUG_ERROR, "Locate Null Root Entry Table Ppi Failed : %r\n",= Status)); - ASSERT (FALSE); - return; - } - for (Index =3D 0; Index < VTdInfo->VTdEngineCount; Index++) { if ((EngineMask & LShiftU64(1, Index)) =3D=3D 0) { continue; @@ -686,7 +674,28 @@ EnableVTdTranslationProtectionAll ( VTdInfo->VtdUnitInfo[Index].ECapReg.Uint64 =3D MmioRead64 (VTdInfo->Vt= dUnitInfo[Index].VtdUnitBaseAddress + R_ECAP_REG); DumpVtdECapRegs (&VTdInfo->VtdUnitInfo[Index].ECapReg); =20 - EnableDmarPreMem (VTdInfo->VtdUnitInfo[Index].VtdUnitBaseAddress, (UIN= TN) *RootEntryTable); + if (VTdInfo->VtdUnitInfo[Index].ECapReg.Bits.ADMS =3D=3D 1) { + // + // Use Abort DMA Mode + // + Status =3D EnableDmarPreMem (VTdInfo->VtdUnitInfo[Index].VtdUnitBase= Address, V_RTADDR_REG_TTM_ADM); + } else { + // + // Use Null Root Entry Table + // + Status =3D PeiServicesLocatePpi ( + &gEdkiiVTdNullRootEntryTableGuid, + 0, + NULL, + (VOID **)&RootEntryTable + ); + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_ERROR, "Locate Null Root Entry Table Ppi Failed : %r= \n", Status)); + ASSERT (FALSE); + return; + } + EnableDmarPreMem (VTdInfo->VtdUnitInfo[Index].VtdUnitBaseAddress, (U= INTN) *RootEntryTable); + } } =20 return; -- 2.16.2.windows.1