From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id D4EE2941A00 for ; Thu, 28 Mar 2024 13:19:27 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=aqJ14tI54YMuXiLcRW6UPMlbiRfTXkfmTFzKAB+MglM=; c=relaxed/simple; d=groups.io; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Disposition; s=20240206; t=1711631966; v=1; b=qJ9OZJ4soRUyb88XD8xQa2yL2o+qG2uFw+ziDmVjD3EYmrBvPTGAkHBgQ/BJR6F7lb36zPVt Wvmz32ZixezetYmjFmh6gXDs0BJj/6GXUj9xYr/Ml59RbaxY7qrJXz8HcVGgw9Y93c/aC1G+lUK ybqrBCPkt0NL+6hlSZSN0oDVHSdzDiBvreEAmFg569jjIV8s0uLDboYAf8UpFFWAsHUscpvaeI1 x6V+weS7wNOvj18Yd4MXM0rGJub5rY+sqdMGwqnxC9Ybz4DFwl+OgnxYYTa0uDS5w3apePLpdJH pXpTJcUgny8ANVMhLDzUsCNdjqNWb9zx2HBKOv02skFaw== X-Received: by 127.0.0.2 with SMTP id snmDYY7687511xJmnGtRucTR; Thu, 28 Mar 2024 06:19:26 -0700 X-Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by mx.groups.io with SMTP id smtpd.web10.15839.1711631965673641115 for ; Thu, 28 Mar 2024 06:19:25 -0700 X-Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42SAVP0E014375; Thu, 28 Mar 2024 13:19:25 GMT X-Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4u213g30-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 13:19:25 +0000 (GMT) X-Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42SDIqFi013980 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 13:18:52 GMT X-Received: from qc-i7.hemma.eciton.net (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 28 Mar 2024 06:18:50 -0700 Date: Thu, 28 Mar 2024 13:18:47 +0000 From: "Leif Lindholm" To: Xiong Yining CC: , , , , Subject: Re: [edk2-devel] [PATCH v4 1/1] SbsaQemu: add memory space for the high memory nodes Message-ID: References: <20240327140143.3802632-1-xiongyining1480@phytium.com.cn> <20240327140143.3802632-2-xiongyining1480@phytium.com.cn> MIME-Version: 1.0 In-Reply-To: <20240327140143.3802632-2-xiongyining1480@phytium.com.cn> X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-ORIG-GUID: Xj9tBrwYdsOckP64fc7XKriTLlhgs75A X-Proofpoint-GUID: Xj9tBrwYdsOckP64fc7XKriTLlhgs75A 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: Thu, 28 Mar 2024 06:19:25 -0700 Reply-To: devel@edk2.groups.io,quic_llindhol@quicinc.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: XF3vR5RRWTbVM3tZJ3l3mRu7x7686176AA= Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=qJ9OZJ4s; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=quicinc.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On Wed, Mar 27, 2024 at 14:01:43 +0000, Xiong Yining wrote: > To support more memory nodes, we refer to the implement of > "OvmfPkg/Fdt/HighMemDxe" to add memory space for the high memory nodes > except the first one. "HighMem" doesn't really make sense outside x86. But I also don't want to delay merging this any furtner because of arguing about names. There are a few stule things below that I will fix up before pushing though: > Signed-off-by: Xiong Yining > Signed-off-by: Chen Baozi Drop additional Signed-off-by, as discussed on other set. > Tested-by: Marcin Juszkiewicz > --- > Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 1 + > Platform/Qemu/SbsaQemu/SbsaQemu.fdf | 1 + > .../SbsaQemuHighMemDxe/SbsaQemuHighMemDxe.inf | 45 ++++++ > .../SbsaQemuHighMemDxe/SbsaQemuHighMemDxe.c | 134 ++++++++++++++++++ > 4 files changed, 181 insertions(+) > create mode 100644 Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuHighMemDxe/SbsaQemuHighMemDxe.inf > create mode 100644 Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuHighMemDxe/SbsaQemuHighMemDxe.c > > diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc > index 3b936f6e6386..22017792bad2 100644 > --- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc > +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc > @@ -671,6 +671,7 @@ DEFINE NETWORK_HTTP_BOOT_ENABLE = FALSE > ArmPkg/Drivers/TimerDxe/TimerDxe.inf > OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf > MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf > + Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuHighMemDxe/SbsaQemuHighMemDxe.inf > > # > # FAT filesystem + GPT/MBR partitioning > diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.fdf b/Platform/Qemu/SbsaQemu/SbsaQemu.fdf > index 6fcfd25faaeb..b35f42e11aa4 100644 > --- a/Platform/Qemu/SbsaQemu/SbsaQemu.fdf > +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.fdf > @@ -161,6 +161,7 @@ READ_LOCK_STATUS = TRUE > > INF MdeModulePkg/Core/Dxe/DxeMain.inf > INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > + INF Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuHighMemDxe/SbsaQemuHighMemDxe.inf > > # > # PI DXE Drivers producing Architectural Protocols (EFI Services) > diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuHighMemDxe/SbsaQemuHighMemDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuHighMemDxe/SbsaQemuHighMemDxe.inf > new file mode 100644 > index 000000000000..304f47392298 > --- /dev/null > +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuHighMemDxe/SbsaQemuHighMemDxe.inf > @@ -0,0 +1,45 @@ > +## @file > +# High memory node enumeration DXE driver for SbsaQemu > +# > +# Copyright (c) 2023, Linaro Ltd. All rights reserved. > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION = 0x00010005 > + BASE_NAME = SbsaQemuHighMemDxe > + FILE_GUID = 9E749C5E-C282-32F8-7CC3-E5A3DDE15329 > + MODULE_TYPE = DXE_DRIVER > + VERSION_STRING = 1.0 > + > + ENTRY_POINT = InitializeHighMemDxe > + > +[Sources] > + SbsaQemuHighMemDxe.c > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + ArmPkg/ArmPkg.dec > + Silicon/Qemu/SbsaQemu/SbsaQemu.dec Sort these alphabetically. > + > +[LibraryClasses] > + BaseLib > + DebugLib > + DxeServicesTableLib > + PcdLib > + UefiBootServicesTableLib > + UefiDriverEntryPoint > + HardwareInfoLib Sort these alphabetically. > + > +[Protocols] > + gEfiCpuArchProtocolGuid ## CONSUMES > + > +[Pcd] > + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy > + gArmTokenSpaceGuid.PcdSystemMemoryBase Sort these alphabetically. > + > +[Depex] > + gEfiCpuArchProtocolGuid > diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuHighMemDxe/SbsaQemuHighMemDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuHighMemDxe/SbsaQemuHighMemDxe.c > new file mode 100644 > index 000000000000..004a8c0cf654 > --- /dev/null > +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuHighMemDxe/SbsaQemuHighMemDxe.c > @@ -0,0 +1,134 @@ > +/** @file > +* High memory node enumeration DXE driver for SbsaQemu > +* Virtual Machines > +* > +* Copyright (c) 2023, Linaro Ltd. All rights reserved. > +* > +* SPDX-License-Identifier: BSD-2-Clause-Patent > +* > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +EFI_STATUS > +EFIAPI > +InitializeHighMemDxe ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_CPU_ARCH_PROTOCOL *Cpu; > + EFI_STATUS Status; > + UINT32 NumMemNodes; > + UINT32 index; Renamed "index" to "Index" to follow coding style. With that: Reviewed-by: Leif Lindholm Pushed as 6105ecb0aa06. Thanks! / Leif > + UINT64 CurBase; > + UINT64 CurSize; > + UINT64 Attributes; > + MemoryInfo MemInfo; > + EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor; > + > + Status = gBS->LocateProtocol ( > + &gEfiCpuArchProtocolGuid, > + NULL, > + (VOID **)&Cpu > + ); > + ASSERT_EFI_ERROR (Status); > + > + // > + // Check for memory node and add the memory spaces except the lowest one > + // > + NumMemNodes = GetMemNodeCount(); > + for (index = 0; index < NumMemNodes; index++){ > + GetMemInfo(index, &MemInfo); > + CurBase = MemInfo.AddressBase; > + CurSize = MemInfo.AddressSize; > + > + if (CurBase > PcdGet64 (PcdSystemMemoryBase)) { > + Status = gDS->GetMemorySpaceDescriptor (CurBase, &GcdDescriptor); > + if (EFI_ERROR (Status)) { > + DEBUG (( > + DEBUG_WARN, > + "%a: Region 0x%lx - 0x%lx not found in the GCD memory space map\n", > + __func__, > + CurBase, > + CurBase + CurSize - 1 > + )); > + continue; > + } > + > + if (GcdDescriptor.GcdMemoryType == EfiGcdMemoryTypeNonExistent) { > + Status = gDS->AddMemorySpace ( > + EfiGcdMemoryTypeSystemMemory, > + CurBase, > + CurSize, > + EFI_MEMORY_WB > + ); > + > + if (EFI_ERROR (Status)) { > + DEBUG (( > + DEBUG_ERROR, > + "%a: Failed to add System RAM @ 0x%lx - 0x%lx (%r)\n", > + __func__, > + CurBase, > + CurBase + CurSize - 1, > + Status > + )); > + continue; > + } > + > + Status = gDS->SetMemorySpaceAttributes ( > + CurBase, > + CurSize, > + EFI_MEMORY_WB > + ); > + if (EFI_ERROR (Status)) { > + DEBUG (( > + DEBUG_WARN, > + "%a: gDS->SetMemorySpaceAttributes() failed on region 0x%lx - 0x%lx (%r)\n", > + __func__, > + CurBase, > + CurBase + CurSize - 1, > + Status > + )); > + } > + > + Attributes = EFI_MEMORY_WB; > + if ((PcdGet64 (PcdDxeNxMemoryProtectionPolicy) & > + (1U << (UINT32)EfiConventionalMemory)) != 0) > + { > + Attributes |= EFI_MEMORY_XP; > + } > + > + Status = Cpu->SetMemoryAttributes (Cpu, CurBase, CurSize, Attributes); > + > + if (EFI_ERROR (Status)) { > + DEBUG (( > + DEBUG_ERROR, > + "%a: Failed to set System RAM @ 0x%lx - 0x%lx attribute (%r)\n", > + __func__, > + CurBase, > + CurBase + CurSize - 1, > + Status > + )); > + } else { > + DEBUG (( > + DEBUG_INFO, > + "%a: Add System RAM @ 0x%lx - 0x%lx\n", > + __func__, > + CurBase, > + CurBase + CurSize - 1 > + )); > + } > + } > + } > + } > + > + return EFI_SUCCESS; > +} > -- > 2.34.1 > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117210): https://edk2.groups.io/g/devel/message/117210 Mute This Topic: https://groups.io/mt/105177586/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-