From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail03.groups.io (mail03.groups.io [45.79.227.220]) by spool.mail.gandi.net (Postfix) with ESMTPS id DAB3FAC14A0 for ; Fri, 12 Apr 2024 14:34:17 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=kNKM/529VES/CdqEVFd+GwyISo9ObMLQojTnfdRK3FI=; c=relaxed/simple; d=groups.io; h=Received-SPF:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:NoDisclaimer:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240206; t=1712932456; v=1; b=uHHk81nUjq1MJR1JDG4PbXMnZqdRhn8KVs55zU5V4vGqLZfbrmlQ1SYaRoF6rt3Id+b/6m6S t/vL7YzESMwybQ5PqfQo8FH/h5X37zhgfbTENoTl+tdJfjkDGRJlqjydK+X7SQPso8VZozvZmO4 A9mHhiZmxkqAkmTDrQjWTEntrdDtGlsbWsk1RB/BSMzwsJurzzWILP+Yk1Jc0I4fTH4Sbv2qgac KEwydCv53pxfev9IeS9fIifFxaW7zBkMSLAknfCzxxmqNHnv9UNRKaegXPoLozwayF2q3t4j9G1 6fQWhC3/+o75LFNNW/I8QYF8ICgt5VEC1S01+T/5wWMLg== X-Received: by 127.0.0.2 with SMTP id 7TPSYY7687511xx1fQKrllT1; Fri, 12 Apr 2024 07:34:16 -0700 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.79]) by mx.groups.io with SMTP id smtpd.web11.47972.1712932446909430832 for ; Fri, 12 Apr 2024 07:34:07 -0700 X-Received: from AS9PR06CA0657.eurprd06.prod.outlook.com (2603:10a6:20b:46f::29) by VE1PR08MB5776.eurprd08.prod.outlook.com (2603:10a6:800:1ac::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 12 Apr 2024 14:33:55 +0000 X-Received: from AMS0EPF000001B7.eurprd05.prod.outlook.com (2603:10a6:20b:46f:cafe::96) by AS9PR06CA0657.outlook.office365.com (2603:10a6:20b:46f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.19 via Frontend Transport; Fri, 12 Apr 2024 14:33:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AMS0EPF000001B7.mail.protection.outlook.com (10.167.16.171) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 14:33:55 +0000 X-Received: ("Tessian outbound f1e9a43166b5:v313"); Fri, 12 Apr 2024 14:33:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 99aa121e49fdb477 X-CR-MTA-TID: 64aa7808 X-Received: from 9f9b7d0ac9d1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id E8F949AA-ABB0-40ED-BAA2-70B890A48B5F.1; Fri, 12 Apr 2024 14:33:48 +0000 X-Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9f9b7d0ac9d1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Apr 2024 14:33:48 +0000 X-Received: from DB7PR03CA0084.eurprd03.prod.outlook.com (2603:10a6:10:72::25) by VI0PR08MB10509.eurprd08.prod.outlook.com (2603:10a6:800:1b9::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Fri, 12 Apr 2024 14:33:45 +0000 X-Received: from DU2PEPF00028D02.eurprd03.prod.outlook.com (2603:10a6:10:72:cafe::75) by DB7PR03CA0084.outlook.office365.com (2603:10a6:10:72::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.26 via Frontend Transport; Fri, 12 Apr 2024 14:33:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C X-Received: from nebula.arm.com (40.67.248.234) by DU2PEPF00028D02.mail.protection.outlook.com (10.167.242.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 14:33:44 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 12 Apr 2024 14:33:40 +0000 X-Received: from E114225.Arm.com (10.1.196.56) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 12 Apr 2024 14:33:39 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , Gerd Hoffmann Subject: [edk2-devel] [PATCH v2 28/45] MdePkg: Warn if AArch64 RNDR instruction is not supported Date: Fri, 12 Apr 2024 15:33:05 +0100 Message-ID: <20240412143322.5244-29-sami.mujawar@arm.com> In-Reply-To: <20240412143322.5244-1-sami.mujawar@arm.com> References: <20240412143322.5244-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DU2PEPF00028D02:EE_|VI0PR08MB10509:EE_|AMS0EPF000001B7:EE_|VE1PR08MB5776:EE_ X-MS-Office365-Filtering-Correlation-Id: e15d8035-c905-4b45-6394-08dc5afd953b x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: /i+1Lha6oPGfIBEyn6v/DKPs8XZcBeIvrrIDYjcgEf9XUWxT8YpojFwFB/KQrzTiquykcZSGeylNyq+inTv71O06OUMZHKMQ2Q6gYuZiRYnYmSGbohRTyZ4JH7/aRX47f6bZ1wBuXoKJeOPbVC9jFvveoLSfOv05b/cFinvIHRw7h4Xwns+TZ2dM9FRb+YKmJ+IoIAe53e0QGALQQLTWP4fQoTh3yQL1b26pqqMiUKpp3Iv62Ydf085LFQQR+x2NvA3IAJRqJRUm5htRS0pGQ2P/Dc/bzlvjuE+xkHKcLxI42CQoYYN7ZwQJkoUj4GPWKw7QVor41fOFzZ5bTIpbkQc4Pse/Iwf4nPVy+24S2mtAovbMG3BT8dz8zY5ZknFAsk/Q7XuhyK+C6svk5By7Tui7HLZZYpL5Roen2VMSqG/MXrvW0AIATpS8JkrutBEfnhMD6BSZduEMc68eTRJdt5IZIMi6+PXRW4+4pUOO+OfWGUQ/wonO2kTlT4uBqrzdO5fRcUm9Dy+NZUu9HuH+Qs9cEaNU2NQsisVtoPZFB7tkChFKgZl695jp/ysibmZ4xxstNDqZMywRFIid1FAA45eQrMIARHvwk0GBPgQqDm6d8X78VUAvitXOJZ3wRdCIUcRhdAM4VyrQe4LC0Fy8rrE0NDpB+v4oQe9OhjA7IooPcVMwXqrHF8vUlJaaDSV93FXiCBMZeuVBU7rX3He7Makk7oBDuaDH8hOwy+B5pgmGOvXhqq3THtKn5YWMul/b X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(82310400014)(376005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR08MB10509 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS0EPF000001B7.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 0e1fbb5c-17c9-4354-5da2-08dc5afd8ecf X-Microsoft-Antispam-Message-Info: CwPyZJ2dqmyumC5gZ3R+iM9ANkyQSsRCmLkR0IdU7RcBYbYxKxgja+Wd2Vk6n+RkUSO0kozq+QRlZWn36iLcHXh0itY7b9W6B0EB5L7uZky1c9BAFCNpeo/VPx5feR5Z2fNJ5PmcGBWJ04nHkRGCOrRkL7/aDyF0bbNjmOpTYawTmpr9P3m1uRG7nBh+UMDODOIdV5wl1l0U86b7EJ7nrhHceIYCFxDFPEeiJWv4Fpdnt2pMWqF8wOAlCoaRECNPDzZyVMfVaew1hbXEzqClGipofuQ3zDJo2rtKwBHPcwiwq6eZJlguqKEDyZGfiuz6Ys1VFIN6qRpS+eCFnrJiMop0JvLpArJGmaRDufM2bmvBQIr1Sbjp2SLBYrXdv9+f9l3F/BPjeBbqthTOiNpzhzBksYj+C3PYKXz4efA4Byn4CQ99x0msRzB2pEj/O6mmRUZ+MwuDgw627z7DxHLdemB2D59t6DrUaVDPrPfRxZihBQugN9jn/14fB0ZEd+bGsQEmI2ndj5Pvmbffxyug/xb0PKbxWCvzpZlk0z08SowAmsdKbq4LCtSuD77xIffbXXvJp665+z7Eh+EBSvZrxaD4ykny2FuKnzzAM8IJo5CF38vqqZ55UUTGwLMWGMRmFDxvSK1vln2bolinPmlgiFZmQYSgNgUqepXj991Lfa1G0WC1DOC8KTsIEMNxOV4XMdYxV3aC3Y29yyRML3V83jT155JUrZp+HZWfDbRNGNHULlQi0ZMOs7ebMKssFNgg X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 14:33:55.6065 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e15d8035-c905-4b45-6394-08dc5afd953b X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001B7.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5776 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Fri, 12 Apr 2024 07:34:07 -0700 Resent-From: sami.mujawar@arm.com Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: N9zaMcOYXTgd4ZZckxHthLOPx7686176AA= Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=uHHk81nU; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.227.220 as permitted sender) smtp.mailfrom=bounce@groups.io The BaseRngLib library constructor for AArch64 asserts if the RNDR instruction is not supported by the CPU. This approach to warn about the unsupported instruction may be suitable for the host platform firmware. However, for a guest firmware the only mechanism to discover the supported RNG interface is by probing the processor feature registers. The guest firmware may therefore assume that RNDR instruction is supported and if the probe fails, fall back to an alternate RNG source, e.g. Virtio RNG. Therefore, replace the assert with a warning message to allow the guest firmware to progress. Note: - If RNDR instruction is not supported, the GetRandomNumberXXX functions will return FALSE to indicate that the random number generation has failed. It is expected that the calling function checks the status and handles this error appropriately. - This change should not have any side effect as the behaviour will be similar to that of release builds where the asserts would be removed. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Gerd Hoffmann Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Sami Mujawar --- MdePkg/Library/BaseRngLib/AArch64/Rndr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MdePkg/Library/BaseRngLib/AArch64/Rndr.c b/MdePkg/Library/BaseRngLib/AArch64/Rndr.c index d39db62153eed415151e7a27a5931231febd20d3..dc41eea8fbfd7d18bca24e2ebe1cdc56b4eb8d81 100644 --- a/MdePkg/Library/BaseRngLib/AArch64/Rndr.c +++ b/MdePkg/Library/BaseRngLib/AArch64/Rndr.c @@ -49,10 +49,14 @@ BaseRngLibConstructor ( // Determine RNDR support by examining bits 63:60 of the ISAR0 register returned by // MSR. A non-zero value indicates that the processor supports the RNDR instruction. // - Isar0 = ArmReadIdIsar0 (); - ASSERT ((Isar0 & RNDR_MASK) != 0); - + Isar0 = ArmReadIdIsar0 (); mRndrSupported = ((Isar0 & RNDR_MASK) != 0); + if (!mRndrSupported) { + DEBUG (( + DEBUG_WARN, + "WARNING: BaseRngLib: RNDR instruction not supported by the processor.\n" + )); + } return EFI_SUCCESS; } -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117701): https://edk2.groups.io/g/devel/message/117701 Mute This Topic: https://groups.io/mt/105483444/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-