From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 933867803CD for ; Wed, 14 Aug 2024 03:24:24 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=C293M+Gc8PhKUeL2/oorwXN+8nKEnQWn5wOnT6Xmsjk=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20240206; t=1723605864; v=1; b=AGzQVnP+9q4jdoF2wDKFob5tjh6fZe7M0zHuJB/9GNyRKWxLKZptjHezaZT85k40eSzaOrGG uO2ZRJ14PHIHgWBOqh49zY+FIUqhCj977U5z2yJA9DGj5mx11dVmsI8DFsyMfCYhtmHsDM//KNx 2vyyNXyWN8aUhT47q88zLqSrI3HxkMmUFMU8zmbWwQj5UsrYz2BowJT5YeQMjDs+fiPyes6oz8K 6FHGZXPg43FsMFRPqQmBkCw7bGdduBlcBoFh30aojDFyCsM0FHWvLQAR8oubwMk6P6ckRyb1X/a 4VpbTi0JjHZ/Ya88NKnv3Hwdk1ngGhDzvKHVq1pU6PxUA== X-Received: by 127.0.0.2 with SMTP id ovaJYY7687511xO3H6Fx0OPn; Tue, 13 Aug 2024 20:24:22 -0700 X-Received: from BN1PR04CU002.outbound.protection.outlook.com (BN1PR04CU002.outbound.protection.outlook.com [52.101.56.131]) by mx.groups.io with SMTP id smtpd.web10.89754.1723605861908182944 for ; Tue, 13 Aug 2024 20:24:22 -0700 X-Received: from PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) by PH0PR01MB6357.prod.exchangelabs.com (2603:10b6:510:1a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.17; Wed, 14 Aug 2024 03:24:19 +0000 X-Received: from PH0PR01MB7287.prod.exchangelabs.com ([fe80::fc79:e629:93aa:8b8f]) by PH0PR01MB7287.prod.exchangelabs.com ([fe80::fc79:e629:93aa:8b8f%3]) with mapi id 15.20.7875.016; Wed, 14 Aug 2024 03:24:19 +0000 From: "Nhi Pham via groups.io" To: devel@edk2.groups.io CC: quic_llindhol@quicinc.com, chuong@os.amperecomputing.com, rebecca@os.amperecomputing.com, nhi@os.amperecomputing.com Subject: [edk2-devel] [PATCH 1/1] AmpereAltraPkg/FlashLib: Fix kernel crash if not call SetVirtualAddressMap() Date: Wed, 14 Aug 2024 10:22:42 +0700 Message-ID: <20240814032242.2353572-1-nhi@os.amperecomputing.com> X-ClientProxiedBy: KL1PR0401CA0036.apcprd04.prod.outlook.com (2603:1096:820:e::23) To PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR01MB7287:EE_|PH0PR01MB6357:EE_ X-MS-Office365-Filtering-Correlation-Id: 290c2dc6-48ac-4da5-fdfc-08dcbc10956c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3gU57qxi2i+ek9KErsKUKGwpq/L/SnND94PHAvisbUE5R+BOBAKXVOzj5eUh?= =?us-ascii?Q?RSrVX+fuAfRa1tjGXoiCPHIiTKPZ7W4+12oONQz0FThgT3n7MGxxcdMCbrUa?= =?us-ascii?Q?qW7uU0MIV+dsB+XL73Vzyp5AtxwR5RugmyzjwZ34HqYIy26o9jtHz4jpjldU?= =?us-ascii?Q?j2I8mWzvIsxPaGsRMOh9noT0FBus9f1uUDB8Vbao81zYEd7V7xrHBgRB81lL?= =?us-ascii?Q?OMUWKzDknWoRERwOGTgqYsNzn3CjBhGYpAM12DfchgGbdAc5OaEIr+31lnUS?= =?us-ascii?Q?JrYRH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0u7Q9xtqZW8ADdu+KnaBCeOI?= =?us-ascii?Q?z/f6ITAIdGzePoozvbmEXRDXwrlTXdnC/vvTkzazT9ZBQXsYUxL4jvMLgbli?= =?us-ascii?Q?cpzKkDyZPOHctkb+hq17ajWndZVaizYirjZ3Ljn3+otTDI64nYL2Amw9S8q7?= =?us-ascii?Q?UO/9/ItRhqqB/ziymBbnXCU2O1Hzpk8LB7+zL+sxw38xk48ZqlBQGpQolzKF?= =?us-ascii?Q?8A0LKT6p1iq+jyWczQhnjvhv6Lm0DEey5ZpSSvVGk07Yq1dCBg=3D=3D?= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4/AGIbZphKiEvrHQ2bDeBTdrUP+MPFPxQJaMBIvIRubsSKz55QtzXd2wjPXr?= =?us-ascii?Q?DQCQXud88DKa/2Ri4Qa9R+5IrvC+uiCfnhyUUdxTg7FqB+0hL3zzdWC56XZI?= =?us-ascii?Q?jDYifJm3YukNVRBP3TAnSHlRMJFthAx169hM7Iac7MX1y8U5QW9K7w4Jrzhh?= =?us-ascii?Q?vxrPYchvx8yF2UhA+kK3Nv++BZC5vWS8P6+tS6VBkOl/Bg3bBb4MVJYxjU1l?= =?us-ascii?Q?vVSs4L11krFxHAY7v0okDeO52vApL1z/BSWI+nkCfse6Fae3S4qe9pxFpij8?= =?us-ascii?Q?l5J0DzH//s2kEKF1hu9kSd5y8ohEH1DFucDkOPnZdDl9A/sOBVMvn0xXbwne?= =?us-ascii?Q?cnqki8UEePOfmiu69UntRdo5Sgi57oRP19sY+srlgRZWXnJ8UAnUI+BVDKtC?= =?us-ascii?Q?NVVh67jKGydqvFzB0G8fH2VfaGdDtK3jTrXKDFppaarDEOi2JSzoWqofAjdX?= =?us-ascii?Q?HaIE5ZxY8PV8AsplNGDat/a9JM4zTCZ+KK83MyaVVtJ0DPnKtypY2wbMIYzr?= =?us-ascii?Q?rEteW/FKRO8VIhlpOiBXnNPr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=?us-ascii?Q?Q5+++S1+Om1JX141omI5zgzoGFf7Jj1ZwESNDWVTu1aqwlEgLb4uXG1jlvgF?= =?us-ascii?Q?VKKTtqfLT/WnQ1hv3TWOyHPB2km/sJhbx+84o5lhkfV8Yt4q7ETAlgFUacCG?= =?us-ascii?Q?HglEHt20o2UWBy/bv46++CVHbSuXFWhypi01fgPUDSg5J26KIWqcZ7QlQoNG?= =?us-ascii?Q?jJyYKDUh3LZVNEnsEUaDq5U=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 290c2dc6-48ac-4da5-fdfc-08dcbc10956c X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7287.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2024 03:24:19.5012 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mAbKzcvOWx3sTWhelp4DlnhcZOG9C8uqk7jDPN/Dr7env3+MvV1tTy/Od/FQEd8oZAPmiboJ5yEGSwbpyKUdOojpQT9i8dQ4CnUEfXqvz+k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR01MB6357 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: Tue, 13 Aug 2024 20:24:22 -0700 Resent-From: nhi@os.amperecomputing.com Reply-To: devel@edk2.groups.io,nhi@os.amperecomputing.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 0S9F2I7oFGg3mZSQeg7Gln6Vx7686176AA= Content-Transfer-Encoding: quoted-printable 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=AGzQVnP+; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io From: Chuong Tran OS kernel with greater than or equal to 48-bit VA space avoids EFI's SetVirtualAddressMap() runtime service on Arm64 and simply uses the 1:1 address mapping that UEFI used at booting. However, AmpereAltraPkg's RuntimeFlashLib replies on function call SetVirtualAddressMap() to determine whether it is in boot time or run-time. If SetVirtualAddressMap() has not been called prior, it causes the kernel crash. This patch fixes that issue by removing the separation between UEFI boot time and run-time in RuntimeFlashLib. Signed-off-by: Nhi Pham --- Silicon/Ampere/AmpereAltraPkg/Library/FlashLib/FlashLibCommon.c | 11 +++-= ------- Silicon/Ampere/AmpereAltraPkg/Library/FlashLib/RuntimeFlashLib.c | 2 -- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Silicon/Ampere/AmpereAltraPkg/Library/FlashLib/FlashLibCommon.= c b/Silicon/Ampere/AmpereAltraPkg/Library/FlashLib/FlashLibCommon.c index 83695c857a11..0b000c2aad46 100644 --- a/Silicon/Ampere/AmpereAltraPkg/Library/FlashLib/FlashLibCommon.c +++ b/Silicon/Ampere/AmpereAltraPkg/Library/FlashLib/FlashLibCommon.c @@ -15,7 +15,6 @@ =20 #include "FlashLibCommon.h" =20 -BOOLEAN gFlashLibRuntime =3D FALSE; UINT8 *gFlashLibPhysicalBuffer; UINT8 *gFlashLibVirtualBuffer; =20 @@ -34,13 +33,9 @@ ConvertToPhysicalBuffer ( IN UINT32 Size ) { - if (gFlashLibRuntime) { - ASSERT (VirtualPtr !=3D NULL); - CopyMem (gFlashLibVirtualBuffer, VirtualPtr, Size); - return gFlashLibPhysicalBuffer; - } - - return VirtualPtr; + ASSERT (VirtualPtr !=3D NULL); + CopyMem (gFlashLibVirtualBuffer, VirtualPtr, Size); + return gFlashLibPhysicalBuffer; } =20 /** diff --git a/Silicon/Ampere/AmpereAltraPkg/Library/FlashLib/RuntimeFlashLib= .c b/Silicon/Ampere/AmpereAltraPkg/Library/FlashLib/RuntimeFlashLib.c index 2dcd13e08146..14cef8e17ece 100644 --- a/Silicon/Ampere/AmpereAltraPkg/Library/FlashLib/RuntimeFlashLib.c +++ b/Silicon/Ampere/AmpereAltraPkg/Library/FlashLib/RuntimeFlashLib.c @@ -35,8 +35,6 @@ FlashLibAddressChangeEvent ( { gRT->ConvertPointer (0x0, (VOID **)&gFlashLibVirtualBuffer); gRT->ConvertPointer (0x0, (VOID **)&mMmCommunicationProtocol); - - gFlashLibRuntime =3D TRUE; } =20 /** --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#120334): https://edk2.groups.io/g/devel/message/120334 Mute This Topic: https://groups.io/mt/107889187/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-