From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.4871.1658400483400037415 for ; Thu, 21 Jul 2022 03:48:03 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=ZCHGoLM/; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: jiewen.yao@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658400483; x=1689936483; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=EE33Z2ocNcMCs4Ma5TJtOUFFk9sW35RLu1oPJ2OJ/8M=; b=ZCHGoLM/YemdKQpfd7Wyux2IcS41zsRfKXI+7pkQJMum11gFO+JSqRPW 5WVLo3wgkfT97cwUtDHckEka6ZGLD6nAh92ggF99v2Vt8YKalOGqezVTl 3gZTtdguUF1EgxEtkWCkdjUpPbS7RPYV2Y8WDxQhK5+H6BHNOUdlaon5T wkU1/ySs3ZsXD0OTkCJuCqRXGqvmnsHBEtIbmR7kwuVtCesCbBQNKj1pc eDk9Z3iYx6cYwq9jVG/T39rUTxMon50ZpK+RjSQV58uGrIcrJsxLPBLJn JiY6P3xF02ZDIRW8OfhfPkNzMiwws7waZDOiT4AlAuhSLQA5haf5RRPZQ A==; X-IronPort-AV: E=McAfee;i="6400,9594,10414"; a="270042891" X-IronPort-AV: E=Sophos;i="5.92,289,1650956400"; d="scan'208";a="270042891" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2022 03:47:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,289,1650956400"; d="scan'208";a="598418432" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga002.jf.intel.com with ESMTP; 21 Jul 2022 03:47:54 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 21 Jul 2022 03:47:54 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 21 Jul 2022 03:47:53 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Thu, 21 Jul 2022 03:47:53 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.172) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Thu, 21 Jul 2022 03:47:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YKv3bLppz/ZVook8r3lFy9Ur8x9yZRrbeijc6oBK3VvolQQ6qzlrs1I9CChIJ2VBjbwjh4pnbTYEBfnz3mLvrELhSOr2O5CEpEzaxRv5e3xnIU4neb0yWy1fFqjh5hNSGq+dU8e2zXjFrj1dC1up2NZgYgsSVtpX5LnOMwViT/fubeHVaionIh52nRzfvy6g69nN/mUjy60k0zvHMBFYJjoXfqq9CsX0QA8Ivmlt0rf1/0AYl/femT9FKhCMw8wLmmliwUqU3ReDeXeDWXxuq7MNFx4eFwx45Z3/9tH5S+xnWfcSunSddJ/6n9n6Slo6GLJfuVaaCxmiNs6blwV0BA== 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=4qV1Ni2Oqpk8Bdcs0Ye0b6bglAk0MtT+bFkfdnJGDGw=; b=HcrWK1Cn+RESzNgPgFTqG/Ki2XdBhyWIZVeLlwo51SMSwGTc9KoZFMU4j4/hUsfCU+jubocv3ccWGobyHfk4Nx6y2+zqwj+9XQh0OZCh1juNHXkPWye4HWBbiOIX6Cf/tXoson4r/kFHrlBQg4fZpRab1n5DxQSfSv4ioDvl+R+V2zJRKfKDuq1bxM3BXuBiCm0IkIv179eU+u9BsiSuBq3oiHzk2hYVkNa8ZP8WZiCA3n+9CoEujJwhtwLWo7ViXJYytW+IFaJeZpLO7NYezJt9qno8n4Di8eBUjGNFID/tMJLP2lOAGKJ1lSCTu/M1YTNgB5qC6Bvu2fRLmplLSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MW4PR11MB5872.namprd11.prod.outlook.com (2603:10b6:303:169::14) by MW5PR11MB5858.namprd11.prod.outlook.com (2603:10b6:303:193::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18; Thu, 21 Jul 2022 10:47:45 +0000 Received: from MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::fd61:b244:d8fb:ab1d]) by MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::fd61:b244:d8fb:ab1d%5]) with mapi id 15.20.5458.018; Thu, 21 Jul 2022 10:47:45 +0000 From: "Yao, Jiewen" To: "Pierre.Gondois@arm.com" , "devel@edk2.groups.io" CC: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , "Kinney, Michael D" , "Gao, Liming" , "Wang, Jian J" Subject: Re: [PATCH v3 20/21] SecurityPkg/RngDxe: Add Arm support of RngDxe Thread-Topic: [PATCH v3 20/21] SecurityPkg/RngDxe: Add Arm support of RngDxe Thread-Index: AQHYi8mnXxed5LYyt0m5DH0/IHZkh62Ixq6w Date: Thu, 21 Jul 2022 10:47:45 +0000 Message-ID: References: <20220629150241.2597898-1-Pierre.Gondois@arm.com> <20220629150241.2597898-29-Pierre.Gondois@arm.com> In-Reply-To: <20220629150241.2597898-29-Pierre.Gondois@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.6.500.17 dlp-product: dlpe-windows dlp-reaction: no-action 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: badfac92-2c49-4d0e-685c-08da6b06724c x-ms-traffictypediagnostic: MW5PR11MB5858:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0GwaqhuTBou0/PAgLENCyTb6K+7B9HEu3oWWJnSksWBBnHciffUFD4AMwpCcTJpGua//SBRKB+IwIca/vEYviGiKYA6mwnqgJJ/vGRnFIarYjgTIebYastsYEJWzNtQMKrTJJKBq3mzRu+eKNz8H5oUe8AR8CKcmT5VaDpDo5iW3N4aTphu+eVlBKE4f3EyCJ/kIuxobngm2fmUUe4ZNI+2DewXZWJTPY/mD3LSvFGm7H85cyGXIb6FETxg/ksWgyWoG860F6dhk6VT1FpRXk6OBY1nzw0JedlDIAKD4N2L6hdKiJDaiSs+zFcUYNLy59Pprgicjpe+4s97YPFqC8JF+A5gYlWjD9SE8l+2Lw7qBJfZQxZsYlRrp0yjDeWu4PrUTcPM3spJCWNK6nCK5Ry1dbBhqcrwUyq5dGhA4cRV1q7/NCK0y5jNkWIruiMgTDh8qqDfBlcq64pzRf5W3kcFQvqZTG9NgqsI1zdQaexweN+f8zOl/ns3qxzdw2FG5Wsc+HEzJwR5L3EaIMs5vyoFAjQziUKQdWfKekAoe9ME/BgHfL75njiOUHlTOo4LyTED3Qf9mxeyfWlMugiwO2LtKlgsGn6G4iH8WgLGlmOmTKyNJ3I2QY1nMbcgzTsbyFYxpD+72S0ZFeySUDg8TIUfleul857gcwHcQkjZtYuXLCcMiTPN5AyR2YwS5jObiHAfQ0PGtpERrDH6H5wQjHPkooHpd5WA2ZKFFTbmNFJpLJANxomXvFN6M8vKDIyTHx6EknrZ5UfcrnICPQoMp+iGkH0SIVe2C+8q7F9vN4oMeA7J9vElywzidn04w8ogUXi8wzI0ocfquB/Riq6LKuQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR11MB5872.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(346002)(376002)(39860400002)(366004)(396003)(136003)(82960400001)(478600001)(8936002)(54906003)(5660300002)(38100700002)(52536014)(110136005)(38070700005)(6506007)(316002)(86362001)(33656002)(64756008)(66946007)(76116006)(66446008)(4326008)(186003)(66476007)(71200400001)(8676002)(66556008)(7696005)(107886003)(83380400001)(9686003)(26005)(53546011)(55016003)(2906002)(122000001)(41300700001)(15650500001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?sl5rCfiO+Ny8Yt503djdyJBEVfDxfqhxIppe4Nm0J10+miWv1UgwFR1FkumY?= =?us-ascii?Q?EsfsVyuJ7yoKH3UkRnM/pjLhrFdsvdnnXvjKTh1jftcjq7c9BqhqdhcoWMXX?= =?us-ascii?Q?4nZYzTIjZCoPNZEUpHnnuLiKbB1KLSadx5C68Nn2pLSrCQAFMefMdHY+Ir0B?= =?us-ascii?Q?sLhUguAk+HUFBkgGMXsFRxZCkAbDamiDJamKvzC8iTRzIkD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y7dnMHLlna6/mtk3c06hDBCT6B6CzmMvFv/8SACi0LVtNMQ+AB3Zk?= =?us-ascii?Q?F+cxbqxC9JIM1gKeWhcdYzbzUVVng8oS6sNA3Lq3NHwHyDbaB3qnyK5jO/D0?= =?us-ascii?Q?ZUCUH8KSVdbXO8R3LVzmSGjHYRjglvxoVGnoGmV4w9NGjc4W0CV5Jt9kxUA7?= =?us-ascii?Q?yRcwnH4XO8Y7INu2kpOwDhTpVY6/BlMLwZE072rTEVzTtoSsxMCUwbn0TU7O?= =?us-ascii?Q?n80NnS1K5a2EbMjxYXccBlma2yX2VdQVSg6noToZ700n9CETGWkx63/4ZYVu?= =?us-ascii?Q?ZWx47fA+D43ebKh2qDtdboDaiRetjeOY+hXv68WkPtmzuIkM2LRqvVACNez9?= =?us-ascii?Q?6r+so3PAd2xQclt3hm4gABVatXEeMCpAoZs49S7V+/hY4lczx5Gp4trdrtha?= =?us-ascii?Q?dzOEAW6+M+1m/JR3a3te8DTwd5OqD0rhaidSuYXm2kRtI2THM5OeDntpEbAQ?= =?us-ascii?Q?kXoIqGu5GvLYdjzcQpY1oYINm5fddry9g86p6UJU?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5872.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: badfac92-2c49-4d0e-685c-08da6b06724c X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jul 2022 10:47:45.7776 (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: 7GddiKV9FBh8dLVTtytsrnmXf/kntcHopI9jnrXOo+cS+xS0hwrZDVdwIHwdoXLMo1DKVO2joUxqiThZQZyV8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR11MB5858 Return-Path: jiewen.yao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > + #ifdef MDE_CPU_AARCH64 > + // Check FEAT_RNG before advertising PcdCpuRngSupportedAlgorithm. > + if (ArmHasRngExt ()) { Usually, we don't prefer use "#ifdef" in a common code. Instead, the general pattern is to define Architecture specific directory, = and move architecture specific doe there. Thank you Yao Jiewen > -----Original Message----- > From: Pierre.Gondois@arm.com > Sent: Wednesday, June 29, 2022 11:03 PM > To: devel@edk2.groups.io > Cc: Sami Mujawar ; Leif Lindholm > ; Ard Biesheuvel ; > Rebecca Cran ; Kinney, Michael D > ; Gao, Liming ; Yao= , > Jiewen ; Wang, Jian J > Subject: [PATCH v3 20/21] SecurityPkg/RngDxe: Add Arm support of RngDxe >=20 > From: Pierre Gondois >=20 > Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) >=20 > Add RngDxe support for Arm. This implementation uses the TrngLib > to support the RawAlgorithm and doens't support the RNDR instruction. >=20 > Signed-off-by: Pierre Gondois > --- > SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c | 8 ++++++-- > SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf | 9 ++++++--- > SecurityPkg/SecurityPkg.dsc | 2 +- > 3 files changed, 13 insertions(+), 6 deletions(-) >=20 > diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c > b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c > index ffa32a29dc6a..4775252d30b6 100644 > --- a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c > +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c > @@ -22,6 +22,7 @@ >=20 > **/ >=20 > +#include > #include > #include > #include > @@ -55,8 +56,9 @@ RngInitAvailableAlgoArray ( > UINT16 MajorRevision; > UINT16 MinorRevision; >=20 > - // Check RngGetBytes() before advertising PcdCpuRngSupportedAlgorithm. > - if (!EFI_ERROR (RngGetBytes (sizeof (Rand), (UINT8 *)&Rand))) { > + #ifdef MDE_CPU_AARCH64 > + // Check FEAT_RNG before advertising PcdCpuRngSupportedAlgorithm. > + if (ArmHasRngExt ()) { > CopyMem ( > &mAvailableAlgoArray[mAvailableAlgoArrayCount], > PcdGetPtr (PcdCpuRngSupportedAlgorithm), > @@ -75,6 +77,8 @@ RngInitAvailableAlgoArray ( > DEBUG_CODE_END (); > } >=20 > + #endif > + > // Raw algorithm (Trng) > if (!EFI_ERROR (GetTrngVersion (&MajorRevision, &MinorRevision))) { > CopyMem ( > diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf > b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf > index d2d0ff9ebb98..599a3085102d 100644 > --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf > +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf > @@ -27,7 +27,7 @@ [Defines] > # > # The following information is for reference only and not required by th= e build > tools. > # > -# VALID_ARCHITECTURES =3D IA32 X64 AARCH64 > +# VALID_ARCHITECTURES =3D IA32 X64 AARCH64 ARM > # >=20 > [Sources.common] > @@ -40,7 +40,7 @@ [Sources.IA32, Sources.X64] > Rand/AesCore.c > Rand/AesCore.h >=20 > -[Sources.AARCH64] > +[Sources.AARCH64, Sources.ARM] > ArmRngDxe.c > ArmTrng.c >=20 > @@ -49,6 +49,9 @@ [Packages] > MdePkg/MdePkg.dec > SecurityPkg/SecurityPkg.dec >=20 > +[Packages.AARCH64, Packages.ARM] > + ArmPkg/ArmPkg.dec > + > [LibraryClasses] > UefiLib > UefiBootServicesTableLib > @@ -58,7 +61,7 @@ [LibraryClasses] > TimerLib > RngLib >=20 > -[LibraryClasses.AARCH64] > +[LibraryClasses.AARCH64, LibraryClasses.ARM] > TrngLib >=20 > [Guids] > diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc > index 490076542a33..882d639489ea 100644 > --- a/SecurityPkg/SecurityPkg.dsc > +++ b/SecurityPkg/SecurityPkg.dsc > @@ -292,7 +292,7 @@ [Components.IA32, Components.X64, > Components.ARM, Components.AARCH64] > SecurityPkg/EnrollFromDefaultKeysApp/EnrollFromDefaultKeysApp.inf >=20 > SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefa > ultKeysDxe.inf >=20 > -[Components.IA32, Components.X64, Components.AARCH64] > +[Components.IA32, Components.X64, Components.AARCH64, > Components.ARM] > # > # Random Number Generator > # > -- > 2.25.1