From: "Gerd Hoffmann" <kraxel@redhat.com>
To: Laszlo Ersek <lersek@redhat.com>
Cc: devel@edk2.groups.io, Pawel Polawski <ppolawsk@redhat.com>,
Jiewen Yao <jiewen.yao@intel.com>,
Oliver Steffen <osteffen@redhat.com>,
Jordan Justen <jordan.l.justen@intel.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>
Subject: Re: [PATCH v2 2/4] OvmfPkg/PlatformInitLib: Add PlatformGetLowMemoryCB
Date: Wed, 11 Jan 2023 16:23:41 +0100 [thread overview]
Message-ID: <20230111152341.d3p6iy5pml7shfvk@sirius.home.kraxel.org> (raw)
In-Reply-To: <4ace3789-7192-0c53-b4b2-f62f907176d0@redhat.com>
> > root@fedora ~# cat /proc/iomem
> > [ ... ]
> > 7ebfe000-7effffff : System RAM
> > 7f000000-7fffffff : Reserved
> > 80000000-afffffff : PCI Bus 0000:00
> > b0000000-bfffffff : PCI MMCONFIG 0000 [bus 00-ff]
> > b0000000-bfffffff : Reserved
> > b0000000-bfffffff : pnp 00:04
> > c0000000-febfffff : PCI Bus 0000:00
> > [ ... ]
> > root@fedora ~# cat /proc/mtrr
> > reg00: base=0x080000000 ( 2048MB), size= 2048MB, count=1: uncachable
> > reg01: base=0x800000000 (32768MB), size=32768MB, count=1: uncachable
>
> Ugh, what? :)
>
> I was about to point out a contradiction between (a) the following from
> commit 2a0bd3bffc80:
>
> + // Newer qemu with gigabyte aligned memory,
> + // 32-bit pci mmio window is 2G -> 4G then.
>
> and (b) your confirmation that the PCIEXBAR location does not change.
> Namely, I was about to point out that PCIEXBAR -- *config space*
> expressed as MMIO -- would then overlap the 32-bit MMIO aperture, the
> one that's assignable to BARs as MMIO space.
>
> But then your /proc/iomem quote actually confirms this is what happens
> in practice -- and apparently works??? In Linux anyways?
>
> FWIW I don't see how this is safe with regard to the firmware. Even if
> QEMU is capable of generating a set of discontiguous resource
> descriptors in the DSDT / _CRS, and Linux is capable of dealing with
> that, I don't understand how the firmware does it.
It doesn't. It still operates with the 0xc0000000+ range as 32bit mmio
window. Which is why the 80000000-afffffff range is unused. Linux
could map hotplug device resources there, but that's it.
> > Bus: 0 - FF Translation=0
> > Io: 6000 - FFFF Translation=0
> > Mem: C0000000 - FBFFFFFF Translation=0
> > MemAbove4G: 800000000 - FFFFFFFFF Translation=0
> > PMem: FFFFFFFFFFFFFFFF - 0 Translation=0
> > PMemAbove4G: FFFFFFFFFFFFFFFF - 0 Translation=0
>
> Note "Mem: C0000000 - FBFFFFFF Translation=0".
Yes.
> Therefore, I also don't understand where the requirement comes (from
> Linux? where?) that the firmware mark the "gap" between 2048 MB and
> 2816 MB as uncached. The firmware does not use it for anything, so why
> does the Linux kernel do? And if the Linux kernel does, then why does
> it not reprogram the MTRRs as well?
Some test case complained because the 80000000-afffffff range is io
address space (according to /proc/iomem) but not tagged as uncachable
in mtrr registers.
> The commit message from commit 2a0bd3bffc80 states, "Which effectively
> makes the 32-bit pci mmio window start at 0x80000000".
.. according to the guest os view because qemu generates _CRS resources
with 80000000-afffffff included.
> I'm precisely after that "effectively" adverb here: placing the 32-bit
> MMIO aperture at 2048 MB is not *at all* what the firmware does.
Yes.
> I've filed a new TianoCore BZ about clarifying the comments please:
>
> https://bugzilla.tianocore.org/show_bug.cgi?id=4289
OK.
> > With gigabyte-alignment being the common case these days it might make
> > sense to place the MMCONFIG area at 0xe0000000 instead ...
>
> I feel really unsafe about complicating this code even further.
I think it should actually simplify things. All the inconsistencies we
have (as you outlined above) due to the hole punching and edk2
supporting only a single range for 32bit mmio should go away, and we
will have less address space layout differences between q35 and pc.
We'll set LowMemory -> 4G to UC via mtrr (both pc and q35)
We'll use LowMemory -> 0xFBFFFFFF (pc) or
LowMemory -> 0xdfffffff (q35) as 32bit mmio window.
We'll use 0xe0000000 -> 0xeffffffff for mmconfig (q35 only).
Qemu will add 0xf0000000 -> 0xFBFFFFFF to the PCI bus _CRS so
linux could use it but the firmware wouldn't do anything with
it (q35 only).
take care,
Gerd
next prev parent reply other threads:[~2023-01-11 15:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-10 8:21 [PATCH v2 0/4] OvmfPkg: check 64bit mmio window for resource conflicts Gerd Hoffmann
2023-01-10 8:21 ` [PATCH v2 1/4] OvmfPkg/PlatformInitLib: Add PlatformScanE820 and GetFirstNonAddressCB Gerd Hoffmann
2023-01-10 15:41 ` Laszlo Ersek
2023-01-10 8:21 ` [PATCH v2 2/4] OvmfPkg/PlatformInitLib: Add PlatformGetLowMemoryCB Gerd Hoffmann
2023-01-10 16:53 ` Laszlo Ersek
2023-01-11 7:29 ` Gerd Hoffmann
2023-01-11 13:56 ` Laszlo Ersek
2023-01-11 15:23 ` Gerd Hoffmann [this message]
2023-01-12 11:09 ` Laszlo Ersek
2023-01-12 14:03 ` Gerd Hoffmann
2023-01-12 15:44 ` Laszlo Ersek
2023-01-10 8:21 ` [PATCH v2 3/4] OvmfPkg/PlatformInitLib: Add PlatformAddHobCB Gerd Hoffmann
2023-01-10 17:42 ` Laszlo Ersek
2023-01-11 8:06 ` Gerd Hoffmann
2023-01-11 14:08 ` Laszlo Ersek
2023-01-10 8:21 ` [PATCH v2 4/4] OvmfPkg/PlatformInitLib: Add PlatformReservationConflictCB Gerd Hoffmann
2023-01-10 17:55 ` Laszlo Ersek
2023-01-11 8:26 ` Gerd Hoffmann
2023-01-12 10:36 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230111152341.d3p6iy5pml7shfvk@sirius.home.kraxel.org \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox