From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web12.3453.1616466302208670330 for ; Mon, 22 Mar 2021 19:25:02 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=UxEEiago; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=0716d7117b=abner.chang@hpe.com) Received: from pps.filterd (m0150244.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12N2Iahx000783; Tue, 23 Mar 2021 02:24:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pps0720; bh=vqMSOcEUmVeEVPx/pm5HmBFkCfGfU8d+O3iE2A21H+I=; b=UxEEiagoIGfeyZVINGpHwljiueD+6R76jJzaQVuhUOhqgth0ICSRcRkCqG134VNKbSHF 8a2OjB1AgW9PVo32XJ11hw7TZNnzSajuf33sghUAuXCY5T37iHxZn/rSLw7xTWfNM08E Gci8jz+nC8Morjq2nz7QbuDf5BOx5dgqZqCtuVgHFWOuuYDrfME3giRLPxneib9rbEWj xwOY2cT2rClyunlo7IYrem5M9ECDFdf5ET4EShKynovG0f8D05OsT16Ko5uzN24ZyuEd ZSgA+zN/jhX6KrPHusUkaJfIrIteng32qhBrfd3yPeHCb77V5AO+dk2oFAp54mz756cx qA== Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0b-002e3701.pphosted.com with ESMTP id 37d9q4j4rj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Mar 2021 02:24:53 +0000 Received: from G2W6311.americas.hpqcorp.net (g2w6311.austin.hp.com [16.197.64.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g2t2352.austin.hpe.com (Postfix) with ESMTPS id C4B0963; Tue, 23 Mar 2021 02:24:52 +0000 (UTC) Received: from G9W8676.americas.hpqcorp.net (16.220.49.23) by G2W6311.americas.hpqcorp.net (16.197.64.53) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 Mar 2021 02:24:52 +0000 Received: from G4W10204.americas.hpqcorp.net (2002:10cf:5210::10cf:5210) by G9W8676.americas.hpqcorp.net (2002:10dc:3117::10dc:3117) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 Mar 2021 02:24:52 +0000 Received: from NAM04-BN3-obe.outbound.protection.outlook.com (15.241.52.13) by G4W10204.americas.hpqcorp.net (16.207.82.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Tue, 23 Mar 2021 02:24:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gP562f0c7Uuev9dC60TmLdxjFB8MG9rA9tZzOh4Xp8xTFHxMInAz2PlZn3fOcc34E5xjIBaurGmUcUutZyD+UMOhp8cv38Ud/A46BM4LdyDjWStz9fzxCMiv6QG4hyvNI8xju5G4rv7WSfIbY/BDOQDFE2tqISdITP3iY3+0HIfPFxSlfZE6FdQUMFY5f4FMXEoRDBdHwwkL4LEQspaUcX3+tvw/kE2Fq4tH7T0ZPrgXPky9Roi0e+yo1d4K5v96P2DjnsSqlKXXSqnot/Pba6km3+dI4g+vmjFm2XAkOEO2+e+oRUc7BW7gYp6OSV6S/JfxwpR4Yg6wmUwNib/0Qg== 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-SenderADCheck; bh=UVJ+t9Wwgw/S/VLKZP9d+st776VJZUO8OkFB2Yso+OE=; b=YQzPudhj3mBCGlVsR2WUlA+nd8w/GZAWPfTFnbm1RF/m/OpKYHcdPBztTUChDgAmMaB1vSyjZjrcnOaMKiaD0b/b3bb0PZGKAujItACkIPV1Z3OqhtblZCL2Jv/y5p0eKBL2eLSN4yJsbxiIs055VKgWA11SO4Ln+4ITellzrEJfFtt9yyX5LaGclRk4g+OPB58Ux83iPvIfc0kjPV1Uafk/sZuC/JCdZGG/HrEA+phcw9Pl57KlJK4twqPqYOcvzd41Dq5Z+945pM+WRljGSQuP11eSylenrh8mggI2vnYZ30/nR1pRbYfWi+krn9GdiLmGz0jF20S0SYRUIDaaww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Received: from CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7508::16) by CS1PR8401MB0901.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:750f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.18; Tue, 23 Mar 2021 02:24:49 +0000 Received: from CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM ([fe80::28f5:3e45:17cf:9231]) by CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM ([fe80::28f5:3e45:17cf:9231%10]) with mapi id 15.20.3955.027; Tue, 23 Mar 2021 02:24:49 +0000 From: "Abner Chang" To: "devel@edk2.groups.io" , "dandan.bi@intel.com" CC: Michael D Kinney , Liming Gao , Zhiguang Liu Subject: Re: [edk2-devel] [patch V2 01/29] MdePkg: Add RegisterFilterLib class and NULL instance Thread-Topic: [edk2-devel] [patch V2 01/29] MdePkg: Add RegisterFilterLib class and NULL instance Thread-Index: AQHXHvLXYK3AH3/PRE23n07y6prE7qqQ2Vlg Date: Tue, 23 Mar 2021 02:24:49 +0000 Message-ID: References: <20210322080941.6780-1-dandan.bi@intel.com> <20210322080941.6780-2-dandan.bi@intel.com> In-Reply-To: <20210322080941.6780-2-dandan.bi@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=hpe.com; x-originating-ip: [2001:b011:4005:1a8a:7162:8d4a:624a:d800] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 84c03057-452b-4a44-2f93-08d8eda2d5bf x-ms-traffictypediagnostic: CS1PR8401MB0901: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:293; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: LTgghxggEAQ9ZH18VlfaMRFA4lZ3lY+eL/Yh4NEz8oT1znajDT9Lf7N5zxWBmua2XSGI9kfhOyRDytlN2MECvxLN+qa5BDpulOcEttVTJSDwIMb+oS/SWPhakJww47HxidTYtgzCnzwBSnqEZdyAlnCoh5NA9JUOp0eSMQdFfgwYgSdOcgSc+uvUpQDeYDA+uRZ/iiXGlHUvb8Wzqe7auqEop5v5SNj3g24imM9UfbXIs1gAd4+CKoya1CvHee7VAkCWXDBA3b5niYUSqVCilIJwTiIZYE/s53JYzFATOGqesex4q0X2tpVaoPP6GUFrnNab2hrxGGy+17HQ7gQE/Qer7F0DoDazajB5QH7yN4/IMT+H6rz5i/LSpD4CCZ9/NGlf/TxkbXj5s3QzMgaHWfNZEX1Sob04QWFVaWM6gUotOU9xHgqiE6BV6sAB0qN1+2KASBvEzVn0BTWyyGW2Y3R3Rzp2rVOpD55p3zQAgYKfZ+HbJBuuyAXRDBUbT/gSltl0ehYb8j2Vb3BPzj6UYSic1p9TQ/2gRRuUoYJ8zD8jDnOe8N1WHuIl5633aXFXK/W8yjbDueVjc85sc1kVx5Jh4vkEjLgPC9MPmvBezz7rQOreu9QKKnY/oZaLiwGtnwrosqdjThaydNYiwhOoo/oqOw/wHEN6+/0xbqKSYnSxeQ1rbOgQMIGprKTvOh38yhm4oJA0WB+NrK9CePonS6/EE/V6pEfEvJb+HGnrx/+GbtH0INtm8Kur/imdGTow x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(39860400002)(376002)(136003)(396003)(366004)(346002)(71200400001)(5660300002)(8676002)(4326008)(66476007)(55016002)(8936002)(19627235002)(52536014)(86362001)(64756008)(66946007)(76116006)(30864003)(66556008)(7696005)(38100700001)(478600001)(33656002)(54906003)(9686003)(966005)(2906002)(83380400001)(66446008)(6506007)(110136005)(316002)(186003)(53546011)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?oQdXVXXIoES9V6yfNqfbRafjAN+W02HHo6LDScFZZb1+CgLpl9+KFvGMTJXq?= =?us-ascii?Q?eXPxmHtKxWjzJa1vhsdwDDTZIbrWuEPj/9fqy2msx5z0x2gePiAOjbwi6R4s?= =?us-ascii?Q?M0Yxjh5Clhz67mAbuol11yJ/ndMEW2Lm8O8m1I51uuxb4VOaMrbnoon16HCF?= =?us-ascii?Q?qLGICXqXZVnpt58REbDcoFg79LexeOTgSCTNJGzz05JPYZhrBN9AbRMENWvM?= =?us-ascii?Q?6P+5q4TgDS4vbeWn3UltbH0gQqMyB3DA8I7luA8Xk29NevU9v/288MxL7CR8?= =?us-ascii?Q?uZumdYMKnp5+Hlbxzp4kAAcEMmhPzwFKiKPlmjwra3jEjV6s1ceZ1gv3BdhC?= =?us-ascii?Q?glUy0UzYGBIy39lVl0UrgXP7lATBj39yFgerjygVHL2GUJpx+wPf0k6jblTd?= =?us-ascii?Q?H57BUmlJLMndC/zon96DzGoZrYcMZYTv33OWiWC1cTLbZ1IGfNHKor6vb5KJ?= =?us-ascii?Q?8qOJqbUNYON4O/Yj3UUK2ikxNkQEYa8mEKfbnfIjb5LWTExFIYCB5tmkufqM?= =?us-ascii?Q?hAM/QXN+dcXzTZGEBLTsZk9u0XVS+1yJtqy1HQQCHN1Mm+zte6hnRUFkQ9Zq?= =?us-ascii?Q?WeEZtv+Vit59741J4ySYgzcviLjcLQgaKiNni8yzQJkh/WzWIhzUhdfuq5oQ?= =?us-ascii?Q?Y35DFBAkgShfFhEBgEtBcwkdLEmZqyuPJiZrSlm0FvFEeZhpO9Fks1FWUX+9?= =?us-ascii?Q?JNodUWVELdBmajOU2sVbrSc6Ie4lxYqCA22mEUg8OwqDUK73M38FNrpStl7w?= =?us-ascii?Q?IjDT8soK2diZzosQxaZl1+xdobdu2fnKriGcGflnLTntHDArbCSTvLQV/MNJ?= =?us-ascii?Q?Zl4H/2PQrGWr4D3BtnAwzJOq6ZyUDVlZ+7DB9ReQFM/BSDK1GwHEdEjMs2Xt?= =?us-ascii?Q?kZWOPTZF6gZlgJNK7N5j5XLF60pzv4aXiDIQjXpMuLDGCZoSXTPMAp6lA9JI?= =?us-ascii?Q?nIW6xalOLP/BHMJ+cn0cjhrpqBobkhhQ18Kb9qhkJrpGvQwWkatMz92R4Bne?= =?us-ascii?Q?VpV8ZAQXPrV5hAePkRCjA9hCXiKJWZBfeYikdjkQbitAG9za/p8xVHimHjwX?= =?us-ascii?Q?tB8UPED5hqYtd4xBEQJD+0aD6/VQsqWMLQ7Ctlv024Fp2um1FtoZbgnbZFr/?= =?us-ascii?Q?AAGrUAD/eWNMeRTTZWUQIXMa9MDenz3JDCoeIS6U6Wl5u/CEJH88/EzM0ysp?= =?us-ascii?Q?lJl3BFsE5i3ZxIMWya2Ulx20mWthzdhdBh6nPlXwhSjB64coGTkzdjZ2E5Rm?= =?us-ascii?Q?CLGWaBzHOZr7Cxzq3cffcMX/r2dIYTLrUJTPw2vb+5gE6MioirIKDi8bidhW?= =?us-ascii?Q?SX8AwHqge0cIaQ2bfx/RdgX+VxkEzvOrPKFksQiraiqu0PTeWhaXBAzTnlnl?= =?us-ascii?Q?XkO1Ufa0u0XNe4BohXAcXkuSfUzR?= x-ms-exchange-transport-forked: True X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 84c03057-452b-4a44-2f93-08d8eda2d5bf X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Mar 2021 02:24:49.8047 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: s5Smt73SP8olOVik++yFabYHpCAH5svwWYpGiQoO2ZWPgxDiNEs3SYLzXIvZ1wPGO4MlK02ySE/LM0E1NdZx1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR8401MB0901 X-OriginatorOrg: hpe.com X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-03-22_12:2021-03-22,2021-03-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 clxscore=1015 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103230013 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Abner Chang Thanks for adding description of return values. > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > Dandan Bi > Sent: Monday, March 22, 2021 4:09 PM > To: devel@edk2.groups.io > Cc: Michael D Kinney ; Liming Gao > ; Zhiguang Liu > Subject: [edk2-devel] [patch V2 01/29] MdePkg: Add RegisterFilterLib cla= ss > and NULL instance >=20 > REF: INVALID URI REMOVED > 3A__bugzilla.tianocore.org_show-5Fbug.cgi-3Fid- > 3D3246&d=3DDwIBAg&c=3DC5b8zRQO1miGmBeVZ2LFWg&r=3D_SN6FZBN4Vgi4Ulks > kz6qU3NYRO03nHp9P7Z5q59A3E&m=3D0EinCfro8QrVJOUHqC9SQrGFKTLw_fpn > ApwpgZrJTFI&s=3DfInsRu_7K_UxMpaoSvL_C5dtlLIZ8c8g12wuPvHoi-4&e=3D >=20 > 1. Add a new library class (RegisterFilterLib) to filter > and trace port IO/MMIO/MSR access. > 2. Add a NULL instance (RegisterFilterLibNull) can be used > to keep current behavior. >=20 > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Zhiguang Liu > Signed-off-by: Dandan Bi > --- > MdePkg/Include/Library/RegisterFilterLib.h | 243 ++++++++++++++++ > .../RegisterFilterLibNull.c | 271 ++++++++++++++++++ > .../RegisterFilterLibNull.inf | 23 ++ > .../RegisterFilterLibNull.uni | 13 + > MdePkg/MdePkg.dec | 7 +- > MdePkg/MdePkg.dsc | 4 +- > 6 files changed, 559 insertions(+), 2 deletions(-) > create mode 100644 MdePkg/Include/Library/RegisterFilterLib.h > create mode 100644 > MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.c > create mode 100644 > MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf > create mode 100644 > MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.uni >=20 > diff --git a/MdePkg/Include/Library/RegisterFilterLib.h > b/MdePkg/Include/Library/RegisterFilterLib.h > new file mode 100644 > index 0000000000..c4402da7d8 > --- /dev/null > +++ b/MdePkg/Include/Library/RegisterFilterLib.h > @@ -0,0 +1,243 @@ > +/** @file > + Public include file for the Port IO/MMIO/MSR RegisterFilterLib. > + > +Copyright (c) 2021, Intel Corporation. All rights reserved.
> + > +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef REGISTER_FILTER_LIB_H_ > +#define REGISTER_FILTER_LIB_H_ > + > +typedef enum { > + FilterWidth8, > + FilterWidth16, > + FilterWidth32, > + FilterWidth64 > +} FILTER_IO_WIDTH; > + > +/** > + Filter IO read operation before read IO port. > + It is used to filter IO read operation. > + > + It will return the flag to decide whether require read real IO port. > + It can be used for emulation environment. > + > + @param[in] Width Signifies the width of the I/O operation. > + @param[in] Address The base address of the I/O operation. > + @param[in] Buffer The destination buffer to store the results= . > + > + @retval TRUE Need to excute the IO read. > + @retval FALSE Skip the IO read. > + > +**/ > +BOOLEAN > +EFIAPI > +FilterBeforeIoRead ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN OUT VOID *Buffer > + ); > + > +/** > + Trace IO read operation after read IO port. > + It is used to trace IO operation. > + > + @param[in] Width Signifies the width of the I/O operation. > + @param[in] Address The base address of the I/O operation. > + @param[in] Buffer The destination buffer to store the results= . > + > +**/ > +VOID > +EFIAPI > +FilterAfterIoRead ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN VOID *Buffer > + ); > +/** > + Filter IO Write operation before wirte IO port. > + It is used to filter IO operation. > + > + It will return the flag to decide whether require read write IO port. > + It can be used for emulation environment. > + > + @param[in] Width Signifies the width of the I/O operation. > + @param[in] Address The base address of the I/O operation. > + @param[in] Buffer The source buffer from which to BeforeWrite= data. > + > + @retval TRUE Need to excute the IO write. > + @retval FALSE Skip the IO write. > + > +**/ > +BOOLEAN > +EFIAPI > +FilterBeforeIoWrite ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN VOID *Buffer > + ); > + > + /** > + Trace IO Write operation after wirte IO port. > + It is used to trace IO operation. > + > + @param[in] Width Signifies the width of the I/O operation. > + @param[in] Address The base address of the I/O operation. > + @param[in] Buffer The source buffer from which to BeforeWrite= data. > + > +**/ > +VOID > +EFIAPI > +FilterAfterIoWrite ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN VOID *Buffer > + ); > + > +/** > + Filter memory IO before Read operation. > + > + It will return the flag to decide whether require read real MMIO. > + It can be used for emulation environment. > + > + @param[in] Width Signifies the width of the memory I/O opera= tion. > + @param[in] Address The base address of the memory I/O operatio= n. > + @param[in] Buffer The destination buffer to store the results= . > + > + @retval TRUE Need to excute the MMIO read. > + @retval FALSE Skip the MMIO read. > + > +**/ > +BOOLEAN > +EFIAPI > +FilterBeforeMmIoRead ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN OUT VOID *Buffer > + ); > + > +/** > + Tracer memory IO after read operation > + > + @param[in] Width Signifies the width of the memory I/O opera= tion. > + @param[in] Address The base address of the memory I/O operatio= n. > + @param[in] Buffer The destination buffer to store the results= . > + > +**/ > +VOID > +EFIAPI > +FilterAfterMmIoRead ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN VOID *Buffer > + ); > + > +/** > + Filter memory IO before write operation > + > + It will return the flag to decide whether require wirte real MMIO. > + It can be used for emulation environment. > + > + @param[in] Width Signifies the width of the memory I/O opera= tion. > + @param[in] Address The base address of the memory I/O operatio= n. > + @param[in] Buffer The source buffer from which to BeforeWrite= data. > + > + @retval TRUE Need to excute the MMIO write. > + @retval FALSE Skip the MMIO write. > + > +**/ > +BOOLEAN > +EFIAPI > +FilterBeforeMmIoWrite ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN VOID *Buffer > + ); > + > +/** > + Tracer memory IO after write operation > + > + @param[in] Width Signifies the width of the memory I/O opera= tion. > + @param[in] Address The base address of the memory I/O operatio= n. > + @param[in] Buffer The source buffer from which to BeforeWrite= data. > + > +**/ > +VOID > +EFIAPI > +FilterAfterMmIoWrite ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN VOID *Buffer > + ); > + > +/** > + Filter MSR before read operation. > + > + It will return the flag to decide whether require read real MSR. > + It can be used for emulation environment. > + > + @param Index The 8-bit Machine Specific Register= index to > BeforeWrite. > + @param Value The 64-bit value to BeforeRead from= the > Machine Specific Register. > + > + @retval TRUE Need to excute the MSR read. > + @retval FALSE Skip the MSR read. > + > +**/ > +BOOLEAN > +EFIAPI > +FilterBeforeMsrRead ( > + IN UINT32 Index, > + IN OUT UINT64 *Value > + ); > + > +/** > + Trace MSR after read operation > + > + @param Index The 8-bit Machine Specific Register= index to > BeforeWrite. > + @param Value The 64-bit value to BeforeRead from= the > Machine Specific Register. > + > +**/ > +VOID > +EFIAPI > +FilterAfterMsrRead ( > + IN UINT32 Index, > + IN UINT64 *Value > + ); > + > +/** > + Filter MSR before write operation > + > + It will return the flag to decide whether require write real MSR. > + It can be used for emulation environment. > + > + @param Index The 8-bit Machine Specific Register= index to > BeforeWrite. > + @param Value The 64-bit value to BeforeWrite to = the Machine > Specific Register. > + > + @retval TRUE Need to excute the MSR write. > + @retval FALSE Skip the MSR write. > + > +**/ > +BOOLEAN > +EFIAPI > +FilterBeforeMsrWrite ( > + IN UINT32 Index, > + IN UINT64 *Value > + ); > + > +/** > + Trace MSR after write operation > + > + @param Index The 8-bit Machine Specific Register= index to > BeforeWrite. > + @param Value The 64-bit value to BeforeWrite to = the Machine > Specific Register. > + > +**/ > +VOID > +EFIAPI > +FilterAfterMsrWrite ( > + IN UINT32 Index, > + IN UINT64 *Value > + ); > + > +#endif // REGISTER_FILTER_LIB_H_ > diff --git a/MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.= c > b/MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.c > new file mode 100644 > index 0000000000..7150f1ed5f > --- /dev/null > +++ b/MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.c > @@ -0,0 +1,271 @@ > +/** @file > + Null instance of RegisterFilterLib. > + > + Copyright (c) 2021 Intel Corporation. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > + > +/** > + Filter IO read operation before read IO port. > + It is used to filter IO read operation. > + > + It will return the flag to decide whether require read real IO port. > + It can be used for emulation environment. > + > + @param[in] Width Signifies the width of the I/O operation. > + @param[in] Address The base address of the I/O operation. > + @param[in,out] Buffer The destination buffer to store the results= . > + > + @retval TRUE Need to excute the IO read. > + @retval FALSE Skip the IO read. > + > +**/ > +BOOLEAN > +EFIAPI > +FilterBeforeIoRead ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN OUT VOID *Buffer > + ) > +{ > + return TRUE; > +} > + > +/** > + Trace IO read operation after read IO port. > + It is used to trace IO operation. > + > + @param[in] Width Signifies the width of the I/O operation. > + @param[in] Address The base address of the I/O operation. > + @param[in] Buffer The destination buffer to store the results= . > + > +**/ > +VOID > +EFIAPI > +FilterAfterIoRead ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN VOID *Buffer > + ) > +{ > + return; > +} > + > +/** > + Filter IO Write operation before wirte IO port. > + It is used to filter IO operation. > + > + It will return the flag to decide whether require read write IO port. > + It can be used for emulation environment. > + > + @param[in] Width Signifies the width of the I/O operation. > + @param[in] Address The base address of the I/O operation. > + @param[in] Buffer The source buffer from which to write data. > + > + @retval TRUE Need to excute the IO write. > + @retval FALSE Skip the IO write. > + > +**/ > +BOOLEAN > +EFIAPI > +FilterBeforeIoWrite ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN VOID *Buffer > + ) > +{ > + return TRUE; > +} > + > + /** > + Trace IO Write operation after wirte IO port. > + It is used to trace IO operation. > + > + @param[in] Width Signifies the width of the I/O operation. > + @param[in] Address The base address of the I/O operation. > + @param[in] Buffer The source buffer from which to Write data. > + > +**/ > +VOID > +EFIAPI > +FilterAfterIoWrite ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN VOID *Buffer > + ) > +{ > + return; > +} > + > +/** > + Filter memory IO before Read operation. > + > + It will return the flag to decide whether require read real MMIO. > + It can be used for emulation environment. > + > + @param[in] Width Signifies the width of the memory I/O opera= tion. > + @param[in] Address The base address of the memory I/O operatio= n. > + @param[in,out] Buffer The destination buffer to store the results= . > + > + @retval TRUE Need to excute the MMIO read. > + @retval FALSE Skip the MMIO read. > + > +**/ > +BOOLEAN > +EFIAPI > +FilterBeforeMmIoRead ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN OUT VOID *Buffer > + ) > +{ > + return TRUE; > +} > + > +/** > + Tracer memory IO after read operation. > + > + @param[in] Width Signifies the width of the memory I/O opera= tion. > + @param[in] Address The base address of the memory I/O operatio= n. > + @param[in] Buffer The destination buffer to store the results= . > + > +**/ > +VOID > +EFIAPI > +FilterAfterMmIoRead ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN VOID *Buffer > + ) > +{ > + return; > +} > + > +/** > + Filter memory IO before write operation. > + > + It will return the flag to decide whether require wirte real MMIO. > + It can be used for emulation environment. > + > + @param[in] Width Signifies the width of the memory I/O opera= tion. > + @param[in] Address The base address of the memory I/O operatio= n. > + @param[in] Buffer The source buffer from which to write data. > + > + @retval TRUE Need to excute the MMIO write. > + @retval FALSE Skip the MMIO write. > + > +**/ > +BOOLEAN > +EFIAPI > +FilterBeforeMmIoWrite ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN VOID *Buffer > + ) > +{ > + return TRUE; > +} > + > +/** > + Tracer memory IO after write operation. > + > + @param[in] Width Signifies the width of the memory I/O opera= tion. > + @param[in] Address The base address of the memory I/O operatio= n. > + @param[in] Buffer The source buffer from which to write data. > + > +**/ > +VOID > +EFIAPI > +FilterAfterMmIoWrite ( > + IN FILTER_IO_WIDTH Width, > + IN UINTN Address, > + IN VOID *Buffer > + ) > +{ > + return; > +} > + > +/** > + Filter MSR before read operation. > + > + It will return the flag to decide whether require read real MSR. > + It can be used for emulation environment. > + > + @param Index The Register index of the MSR. > + @param Value Point to the data will be read from= the MSR. > + > + @retval TRUE Need to excute the MSR read. > + @retval FALSE Skip the MSR read. > + > +**/ > +BOOLEAN > +EFIAPI > +FilterBeforeMsrRead ( > + IN UINT32 Index, > + IN OUT UINT64 *Value > + ) > +{ > + return TRUE; > +} > + > +/** > + Trace MSR after read operation. > + > + @param Index The Register index of the MSR. > + @param Value Point to the data has been be read = from the MSR. > + > +**/ > +VOID > +EFIAPI > +FilterAfterMsrRead ( > + IN UINT32 Index, > + IN UINT64 *Value > + ) > +{ > + return; > +} > + > +/** > + Filter MSR before write operation. > + > + It will return the flag to decide whether require write real MSR. > + It can be used for emulation environment. > + > + @param Index The Register index of the MSR. > + @param Value Point to the data want to be writte= n to the MSR. > + > + @retval TRUE Need to excute the MSR write. > + @retval FALSE Skip the MSR write. > + > +**/ > +BOOLEAN > +EFIAPI > +FilterBeforeMsrWrite ( > + IN UINT32 Index, > + IN UINT64 *Value > + ) > +{ > + return TRUE; > +} > + > +/** > + Trace MSR after write operation. > + > + @param Index The Register index of the MSR. > + @param Value Point to the data has been be writt= en to the MSR. > + > +**/ > +VOID > +EFIAPI > +FilterAfterMsrWrite ( > + IN UINT32 Index, > + IN UINT64 *Value > + ) > +{ > + return; > +} > + > diff --git a/MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.= inf > b/MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf > new file mode 100644 > index 0000000000..a7fc7497ed > --- /dev/null > +++ b/MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf > @@ -0,0 +1,23 @@ > +## @file > +# Null instance of RegisterFilterLib. > +# > +# Copyright (c) 2021, Intel Corporation. All rights reserved.
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D FilterLibNull > + MODULE_UNI_FILE =3D FilterLibNull.uni > + FILE_GUID =3D 9F555194-A410-4AD6-B3FC-53F6E10FA7= 93 > + MODULE_TYPE =3D BASE > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D RegisterFilterLib > + > +[Sources] > + RegisterFilterLibNull.c > + > +[Packages] > + MdePkg/MdePkg.dec > diff --git a/MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.= uni > b/MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.uni > new file mode 100644 > index 0000000000..ed64c7e63d > --- /dev/null > +++ b/MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.uni > @@ -0,0 +1,13 @@ > +// /** @file > +// Null instance of RegisterFilterLib. > +// > +// Copyright (c) 2021, Intel Corporation. All rights reserved.
> +// > +// SPDX-License-Identifier: BSD-2-Clause-Patent > +// > +// **/ > + > + > +#string STR_MODULE_ABSTRACT #language en-US "Null instance= of > RegisterFilterLib." > +#string STR_MODULE_DESCRIPTION #language en-US "Null instance= of > RegisterFilterLib." > + > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec > index 1d2637acc2..65de5c4052 100644 > --- a/MdePkg/MdePkg.dec > +++ b/MdePkg/MdePkg.dec > @@ -2,11 +2,11 @@ > # This Package provides all definitions, library classes and libraries = instances. > # > # It also provides the definitions(including PPIs/PROTOCOLs/GUIDs) of > # EFI1.10/UEFI2.7/PI1.7 and some Industry Standards. > # > -# Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved. > +# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved. > # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved. > # (C) Copyright 2016 - 2020 Hewlett Packard Enterprise Development LP > # > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > @@ -260,10 +260,15 @@ [LibraryClasses] > ## @libraryclass This library provides an interface to request non-= MMRAM > pages to be mapped > # or unblocked from inside MM environment. > # > MmUnblockMemoryLib|Include/Library/MmUnblockMemoryLib.h >=20 > + ## @libraryclass This library provides interfances to filter and tr= ace port > IO/MMIO/MSR access. > + # > + # > + RegisterFilterLib|Include/Library/RegisterFilterLib.h > + > [LibraryClasses.IA32, LibraryClasses.X64] > ## @libraryclass Abstracts both S/W SMI generation and detection. > ## > SmmLib|Include/Library/SmmLib.h >=20 > diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc > index 79629e3f93..be89e28eef 100644 > --- a/MdePkg/MdePkg.dsc > +++ b/MdePkg/MdePkg.dsc > @@ -1,9 +1,9 @@ > ## @file > # EFI/PI MdePkg Package > # > -# Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved. > +# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved. > # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved. > # (C) Copyright 2020 Hewlett Packard Enterprise Development LP
> # > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > @@ -125,10 +125,12 @@ [Components] >=20 > MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib. > inf >=20 >=20 > MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntry > Point.inf >=20 > MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTab > leLib.inf >=20 > + MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf > + > [Components.IA32, Components.X64, Components.ARM, > Components.AARCH64] > # > # Add UEFI Target Based Unit Tests > # > MdePkg/Test/UnitTest/Library/BaseLib/BaseLibUnitTestsUefi.inf > -- > 2.18.0.windows.1 >=20 >=20 >=20 >=20 >=20