From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mx.groups.io with SMTP id smtpd.web11.23625.1633429691768876841 for ; Tue, 05 Oct 2021 03:28:11 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fbiOGAxY; spf=pass (domain: kernel.org, ip: 198.145.29.99, mailfrom: ardb@kernel.org) Received: by mail.kernel.org (Postfix) with ESMTPSA id A4E9561528 for ; Tue, 5 Oct 2021 10:28:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633429689; bh=Su9N+Chobki+HCU2NmXGvHq548Y4eIQEkBtj1kkFCAM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=fbiOGAxYLUpkw855HXpjRTfOy+Yu95UoM4Ju4ZL0uiJKRo/qQdA0Ij4lE6E4fB2Fu Z8E6wzxLiRk6ImmxcHwUYYT1M27DN8B9DoEFtex5psz4z8USay5jJX/NC6aaw2HJSd m/PsBLyccAzkjJeXu2T4tT9tcy4jN/v6K6PudLOLQRifujScUbaLUgsA0FZf06tX8K QuI9b1fN9gGgJCbDkpuqr5kTDKSYdzcBgfxWP1nM0X8W//ZZLAxplotV88nuC1MJ4W sZmrNeWFa8lWhHazFV/x2NvvKw/TK+UYDhV5DItGKiEQnasDMGc8v3Mi120ZUaglg/ JHDpqbCz162cw== Received: by mail-ot1-f51.google.com with SMTP id c6-20020a9d2786000000b005471981d559so25196631otb.5 for ; Tue, 05 Oct 2021 03:28:09 -0700 (PDT) X-Gm-Message-State: AOAM5330cHW0fLOZ/Qo9jSYn90E3DmeCPHEHdpV+i9t/IxcNWG1uIsrk uWq5gC4qZ9mEIyIJvb2Sv+o44cnkZA0WXJ1lzSQ= X-Google-Smtp-Source: ABdhPJyJidRfFGKSY8r+i8Vo5Uqk3yR+b5mwDZSq4XvuvdEIEt42kiA9+IfoEpuJSTlwtonwDBZkDQ6gUWXdcIajjBo= X-Received: by 2002:a9d:63c7:: with SMTP id e7mr13526711otl.30.1633429688950; Tue, 05 Oct 2021 03:28:08 -0700 (PDT) MIME-Version: 1.0 References: <20210908090119.2378189-1-kraxel@redhat.com> <20210908090119.2378189-12-kraxel@redhat.com> <20210908110646.zuvhetarmi2bvszb@leviathan> <20210908113351.ken5secnrkot4dde@sirius.home.kraxel.org> <20210908115415.457jrctnokke3n6u@leviathan> <20210909105823.d4e5yafgpzc6atm6@sirius.home.kraxel.org> In-Reply-To: <20210909105823.d4e5yafgpzc6atm6@sirius.home.kraxel.org> From: "Ard Biesheuvel" Date: Tue, 5 Oct 2021 12:27:57 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 11/19] OvmfPkg/Microvm: PlatformPei/MemDetect tweaks To: Gerd Hoffmann Cc: Leif Lindholm , edk2-devel-groups-io , Jiewen Yao , =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= , Michael D Kinney , Andrew Fish , Jordan Justen , Julien Grall , Anthony Perard , Ard Biesheuvel , Stefan Berger Content-Type: text/plain; charset="UTF-8" On Thu, 9 Sept 2021 at 12:58, Gerd Hoffmann wrote: > > > > Sure. Suggestions? Add a Pcd and set it in Microvm.dsc? > > > Or is there some better way? > > > > It's all a question of how much we want to overengineer things :) > > > > I'm tempted to suggest a balanced version would be adding > > GCC: *_*_*_CC_FLAGS = -D PLATFORM_IS_MICROVM > > to [BuildOptions] in the .dsc, and test for that. > > How about the approach below? > I am going to go with the original patch. All the workarounds seem rather intrusive, and there is nothing wrong with probing the config space and concluding that nothing is there if the response has all bits set to 1. And to be pedantic, the reason 0xffff is an invalid device ID is because it cannot be distinguished from a failed read. So we are not checking whether the device exists and has an invalid device ID, we are checking whether there's anything there to begin with. > take care, > Gerd > > commit 2d48e3eba022ba92eadcbad2c55e10ed281631c2 > Author: Gerd Hoffmann > Date: Tue Jun 1 12:38:38 2021 +0200 > > OvmfPkg/Microvm: PlatformPei/MemDetect tweaks > > Set mHostBridgeDevId to MICROVM_PSEUDO_DEVICE_ID using a > compile time switch. > > Skip host bridge setup on microvm. > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3599 > Signed-off-by: Gerd Hoffmann > Acked-by: Jiewen Yao > > diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc > index 019b50de7d8f..a000c195d866 100644 > --- a/OvmfPkg/Microvm/MicrovmX64.dsc > +++ b/OvmfPkg/Microvm/MicrovmX64.dsc > @@ -73,6 +73,9 @@ [Defines] > !endif > > [BuildOptions] > + GCC:*_*_*_CC_FLAGS = -DPLATFORM_IS_MICROVM > + INTEL:*_*_*_CC_FLAGS = /D PLATFORM_IS_MICROVM > + MSFT:*_*_*_CC_FLAGS = /D PLATFORM_IS_MICROVM > GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG > INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG > MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG > diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c > index 2c2c4641ec8a..8125644bc91a 100644 > --- a/OvmfPkg/PlatformPei/MemDetect.c > +++ b/OvmfPkg/PlatformPei/MemDetect.c > @@ -15,6 +15,7 @@ Module Name: > // > #include > #include > +#include > #include > #include > #include > @@ -135,6 +136,10 @@ QemuUc32BaseInitialization ( > UINT32 LowerMemorySize; > UINT32 Uc32Size; > > + if (mHostBridgeDevId == MICROVM_PSEUDO_DEVICE_ID) { > + return; > + } > + > if (mHostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) { > // > // On q35, the 32-bit area that we'll mark as UC, through variable MTRRs, > diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c > index d3a20122a2ea..ed93d11c8ac6 100644 > --- a/OvmfPkg/PlatformPei/Platform.c > +++ b/OvmfPkg/PlatformPei/Platform.c > @@ -31,6 +31,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -714,7 +715,11 @@ InitializePlatform ( > // > // Query Host Bridge DID > // > +#ifdef PLATFORM_IS_MICROVM > + mHostBridgeDevId = MICROVM_PSEUDO_DEVICE_ID; > +#else > mHostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID); > +#endif > > MaxCpuCountInitialization (); > >