From nobody Fri Mar 13 00:18:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+113772+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113772+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1705086971; cv=none; d=zohomail.com; s=zohoarc; b=gtlwVGkjGw4KTNG7JaiilSo7/SOyz49HfJrKeszysUu8poUUBhUSbbBzUUPNL95p0QswMgK+BjxBIkj9eo/c81Hwxirmxw860AIoHkUo21IQsD5wOowp1sGF+C/tx1x6UukMMgnLwbtSh49M1y2MrcegABlD3pGbAGYedETkEfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705086971; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=88tWhRrga+3RSyt/y//mcUakqGYLPTxRaG2cb/vPY9M=; b=A9Q/5aBIchdBRifu/fAJFmLKKilxVUiyJjNmXWN75DwGixNS5fXlD+MVq8YxORO06lu5hUTJmSgLc1Z0eketjlZn9Obx7xkPIb6gvgqlLVUrfZ2HHUGJdfqBzLD0DdNtCOmlqr+0Ul/WQfvIBH7PuNRldHWH4O9yx/1G339cAtk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113772+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1705086971177230.6671366374593; Fri, 12 Jan 2024 11:16:11 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=afB4VN+pd7IlMoF0Y8x6e1jsPuY8TVwQKO+j5jvH+Sw=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1705086970; v=1; b=k7a6B3rsZh4Ywj7KLZEUu+XMb8ysTIj8CUXs+jnYH2rCSLeeuKDtskdE+D+T5tX0JdUeW/wH tOJQ7Xn0GaidmR5t5ZThzuMjYDzNd3osQjWkI+jplD/zcqLOSGM/HW8FsOOEtqo73DvyqNeGLMy yz0qE3tCKXRrbi21tSYSwmQI= X-Received: by 127.0.0.2 with SMTP id AWHHYY1788612xA42nvT4DSM; Fri, 12 Jan 2024 11:16:10 -0800 X-Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) by mx.groups.io with SMTP id smtpd.web10.15591.1705084313250214215 for ; Fri, 12 Jan 2024 10:31:53 -0800 X-Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-598a5448ef5so1481988eaf.0 for ; Fri, 12 Jan 2024 10:31:53 -0800 (PST) X-Gm-Message-State: RhHlhZm2EshAI9djJLmUiNBZx1787277AA= X-Google-Smtp-Source: AGHT+IEf817M19aB2kaf75VFO/mmVC/vBQwBiA8Xq3q00RhVQtjfCwx+0DCQmZwzDnmo0L3tsJwbEQ== X-Received: by 2002:a05:6358:f1c:b0:175:643d:75ef with SMTP id b28-20020a0563580f1c00b00175643d75efmr1681961rwj.4.1705084312256; Fri, 12 Jan 2024 10:31:52 -0800 (PST) X-Received: from dev-hypervisor-01.hsd1.ca.comcast.net ([2601:645:8001:5750::6d3b]) by smtp.googlemail.com with ESMTPSA id w67-20020a626246000000b006d6b91c6eb6sm3699243pfb.13.2024.01.12.10.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 10:31:52 -0800 (PST) From: "Thomas Barrett" To: devel@edk2.groups.io Cc: Thomas Barrett , Anatol Belski , Ard Biesheuvel , Gerd Hoffmann , Jianyong Wu , Jiewen Yao , Laszlo Ersek , Rob Bradford Subject: [edk2-devel] [PATCH v3 1/3] OvmfPkg: Add CloudHv support to PlatformScanE820 utility function. Date: Fri, 12 Jan 2024 18:31:42 +0000 Message-Id: In-Reply-To: References: MIME-Version: 1.0 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 Reply-To: devel@edk2.groups.io,tbarrett1200@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1705086972225100069 Content-Type: text/plain; charset="utf-8" From: Thomas Barrett The PlatformScanE820 utility function is not currently compatible with CloudHv since it relies on the prescence of the "etc/e820" QemuFwCfg file. Update the PlatformScanE820 to iterate through the PVH e820 entries when running on a CloudHv guest. Cc: Anatol Belski Cc: Ard Biesheuvel Cc: Gerd Hoffmann Cc: Jianyong Wu Cc: Jiewen Yao Cc: Laszlo Ersek Cc: Rob Bradford Signed-off-by: Thomas Barrett --- OvmfPkg/Library/PlatformInitLib/MemDetect.c | 95 ++++++++++++++------- 1 file changed, 65 insertions(+), 30 deletions(-) diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/= PlatformInitLib/MemDetect.c index 662e7e85bb..76a9dc9211 100644 --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c @@ -248,6 +248,67 @@ PlatformReservationConflictCB ( PlatformInfoHob->PcdPciMmio64Base =3D NewBase; } =20 +/** + Returns PVH memmap + @param Entries Pointer to PVH memmap + @param Count Number of entries + @return EFI_STATUS +**/ +EFI_STATUS +GetPvhMemmapEntries ( + struct hvm_memmap_table_entry **Entries, + UINT32 *Count + ) +{ + UINT32 *PVHResetVectorData; + struct hvm_start_info *pvh_start_info; + + PVHResetVectorData =3D (VOID *)(UINTN)PcdGet32 (PcdXenPvhStartOfDayStruc= tPtr); + if (PVHResetVectorData =3D=3D 0) { + return EFI_NOT_FOUND; + } + + pvh_start_info =3D (struct hvm_start_info *)(UINTN)PVHResetVectorData[0]; + + *Entries =3D (struct hvm_memmap_table_entry *)(UINTN)pvh_start_info->mem= map_paddr; + *Count =3D pvh_start_info->memmap_entries; + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +PlatformScanE820Pvh ( + IN E820_SCAN_CALLBACK Callback, + IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob + ) +{ + struct hvm_memmap_table_entry *Memmap; + UINT32 MemmapEntriesCount; + struct hvm_memmap_table_entry *Entry; + EFI_E820_ENTRY64 E820Entry; + EFI_STATUS Status; + UINT32 Loop; + + Status =3D GetPvhMemmapEntries (&Memmap, &MemmapEntriesCount); + if (EFI_ERROR (Status)) { + return Status; + } + + for (Loop =3D 0; Loop < MemmapEntriesCount; Loop++) { + Entry =3D Memmap + Loop; + + if (Entry->type =3D=3D XEN_HVM_MEMMAP_TYPE_RAM) { + E820Entry.BaseAddr =3D Entry->addr; + E820Entry.Length =3D Entry->size; + E820Entry.Type =3D Entry->type; + Callback (&E820Entry, PlatformInfoHob); + } + } + + return EFI_SUCCESS; +} + /** Iterate over the entries in QEMU's fw_cfg E820 RAM map, call the passed callback for each entry. @@ -279,6 +340,10 @@ PlatformScanE820 ( EFI_E820_ENTRY64 E820Entry; UINTN Processed; =20 + if (PlatformInfoHob->HostBridgeDevId =3D=3D CLOUDHV_DEVICE_ID) { + return PlatformScanE820Pvh (Callback, PlatformInfoHob); + } + Status =3D QemuFwCfgFindFile ("etc/e820", &FwCfgItem, &FwCfgSize); if (EFI_ERROR (Status)) { return Status; @@ -297,36 +362,6 @@ PlatformScanE820 ( return EFI_SUCCESS; } =20 -/** - Returns PVH memmap - - @param Entries Pointer to PVH memmap - @param Count Number of entries - - @return EFI_STATUS -**/ -EFI_STATUS -GetPvhMemmapEntries ( - struct hvm_memmap_table_entry **Entries, - UINT32 *Count - ) -{ - UINT32 *PVHResetVectorData; - struct hvm_start_info *pvh_start_info; - - PVHResetVectorData =3D (VOID *)(UINTN)PcdGet32 (PcdXenPvhStartOfDayStruc= tPtr); - if (PVHResetVectorData =3D=3D 0) { - return EFI_NOT_FOUND; - } - - pvh_start_info =3D (struct hvm_start_info *)(UINTN)PVHResetVectorData[0]; - - *Entries =3D (struct hvm_memmap_table_entry *)(UINTN)pvh_start_info->mem= map_paddr; - *Count =3D pvh_start_info->memmap_entries; - - return EFI_SUCCESS; -} - STATIC UINT64 GetHighestSystemMemoryAddressFromPvhMemmap ( --=20 2.34.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 (#113772): https://edk2.groups.io/g/devel/message/113772 Mute This Topic: https://groups.io/mt/103689731/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-