From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web09.10192.1639396574582445049 for ; Mon, 13 Dec 2021 03:56:15 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IJSgniSg; spf=pass (domain: kernel.org, ip: 145.40.68.75, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 27D3CB80D78 for ; Mon, 13 Dec 2021 11:56:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D45A8C34603 for ; Mon, 13 Dec 2021 11:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639396565; bh=lnJ7nIw5UCR5ooJ9kJk7FDu6Sy7NMugubJV4XrDCfKg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=IJSgniSgmdG2MPCEky+l24hq6OJjoeaoNjzHLI+9Rw1D7eYdyQPGyHlBItLcyKhG5 Y2ccNtufItM7Bm+a2Y9bvXp95nWkjuJ4EQ8tr/yMqZ78lWgWb2xOF7Hthf/iOVrfaq Zjo/V2AFP3hOwo67mQnQhOEpf59sznEQ7pcrzBYsOZkx0HWcZDu5x/rBJDsv352mcd bh1UaKivQuu7rJKvwbYeeqveWDLgX3Sysc1EoIWk5DcSfKvapwralzJZWDpw0djuCX 5pTl5DsP8DE/RSEc1XXPsraPcUQ1RHO941BXkkSkLNiLqbpKqB/QwqU7ik3yJrlukA +g/f0Tv778Wig== Received: by mail-oi1-f177.google.com with SMTP id o4so22803874oia.10 for ; Mon, 13 Dec 2021 03:56:05 -0800 (PST) X-Gm-Message-State: AOAM532d+CRlXyRx58aUF/n0vgHdDaBDDT7UzqZ3nXYT9D9M8uIGwBR1 ji5yHKwQFzUBIpvFJ9YzCh00ENlgBw4g7BqVGLM= X-Google-Smtp-Source: ABdhPJwGPepbsTLabNUD361aAtk6TVMAYBWEuGKfAhosg7KGlCqkCQ9IAzOEBus7CSEkOLKJptM/339K8qVxG1x/MQI= X-Received: by 2002:aca:ad95:: with SMTP id w143mr26740922oie.47.1639396565066; Mon, 13 Dec 2021 03:56:05 -0800 (PST) MIME-Version: 1.0 References: <20211208070146.1239368-1-kraxel@redhat.com> <20211208070146.1239368-4-kraxel@redhat.com> In-Reply-To: <20211208070146.1239368-4-kraxel@redhat.com> From: "Ard Biesheuvel" Date: Mon, 13 Dec 2021 12:55:54 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 3/3] RFC: OvmfPkg/PlatformPei: stop using cmos for memory detection To: Gerd Hoffmann Cc: edk2-devel-groups-io , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , Ard Biesheuvel , Pawel Polawski , Jordan Justen , Jiewen Yao Content-Type: text/plain; charset="UTF-8" On Wed, 8 Dec 2021 at 08:02, Gerd Hoffmann wrote: > > Not needed for qemu 1.7 (released in 2013) and newer. > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3593 > Signed-off-by: Gerd Hoffmann Good riddance Acked-by: Ard Biesheuvel > --- > OvmfPkg/PlatformPei/MemDetect.c | 59 +++------------------------------ > 1 file changed, 4 insertions(+), 55 deletions(-) > > diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c > index e0f2caa9cd3c..21b0b9af26a1 100644 > --- a/OvmfPkg/PlatformPei/MemDetect.c > +++ b/OvmfPkg/PlatformPei/MemDetect.c > @@ -37,7 +37,6 @@ Module Name: > #include > > #include "Platform.h" > -#include "Cmos.h" > > UINT8 mPhysMemAddressWidth; > > @@ -315,51 +314,11 @@ GetSystemMemorySizeBelow4gb ( > { > EFI_STATUS Status; > UINT64 LowerMemorySize = 0; > - UINT8 Cmos0x34; > - UINT8 Cmos0x35; > > Status = ScanOrAdd64BitE820Ram (FALSE, &LowerMemorySize, NULL); > - if ((Status == EFI_SUCCESS) && (LowerMemorySize > 0)) { > - return (UINT32)LowerMemorySize; > - } > - > - // > - // CMOS 0x34/0x35 specifies the system memory above 16 MB. > - // * CMOS(0x35) is the high byte > - // * CMOS(0x34) is the low byte > - // * The size is specified in 64kb chunks > - // * Since this is memory above 16MB, the 16MB must be added > - // into the calculation to get the total memory size. > - // > - > - Cmos0x34 = (UINT8)CmosRead8 (0x34); > - Cmos0x35 = (UINT8)CmosRead8 (0x35); > - > - return (UINT32)(((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB); > -} > - > -STATIC > -UINT64 > -GetSystemMemorySizeAbove4gb ( > - ) > -{ > - UINT32 Size; > - UINTN CmosIndex; > - > - // > - // CMOS 0x5b-0x5d specifies the system memory above 4GB MB. > - // * CMOS(0x5d) is the most significant size byte > - // * CMOS(0x5c) is the middle size byte > - // * CMOS(0x5b) is the least significant size byte > - // * The size is specified in 64kb chunks > - // > - > - Size = 0; > - for (CmosIndex = 0x5d; CmosIndex >= 0x5b; CmosIndex--) { > - Size = (UINT32)(Size << 8) + (UINT32)CmosRead8 (CmosIndex); > - } > - > - return LShiftU64 (Size, 16); > + ASSERT_EFI_ERROR (Status); > + ASSERT (LowerMemorySize > 0); > + return (UINT32)LowerMemorySize; > } > > /** > @@ -389,12 +348,9 @@ GetFirstNonAddress ( > // If QEMU presents an E820 map, then get the highest exclusive >=4GB RAM > // address from it. This can express an address >= 4GB+1TB. > // > - // Otherwise, get the flat size of the memory above 4GB from the CMOS (which > - // can only express a size smaller than 1TB), and add it to 4GB. > - // > Status = ScanOrAdd64BitE820Ram (FALSE, NULL, &FirstNonAddress); > if (EFI_ERROR (Status)) { > - FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb (); > + FirstNonAddress = BASE_4GB; > } > > // > @@ -766,7 +722,6 @@ QemuInitializeRam ( > ) > { > UINT64 LowerMemorySize; > - UINT64 UpperMemorySize; > MTRR_SETTINGS MtrrSettings; > EFI_STATUS Status; > > @@ -825,12 +780,6 @@ QemuInitializeRam ( > // memory size read from the CMOS. > // > Status = ScanOrAdd64BitE820Ram (TRUE, NULL, NULL); > - if (EFI_ERROR (Status)) { > - UpperMemorySize = GetSystemMemorySizeAbove4gb (); > - if (UpperMemorySize != 0) { > - AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize); > - } > - } > } > > // > -- > 2.33.1 >