[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-4.17] x86/efi: don't translate EFI memory map MMIO regions to e820 RESERVED


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 4 Oct 2022 11:27:50 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=n3uBSVoH60hyNSYLt3+BFe7B7dZcfaz0za/QaNp2PLA=; b=ASxLIHVANZ8Hj3uVLzjnQjIls8Nh5LgBfOZy1mHmoxCfVth1fRBT7VGpi7TJTLqw/+4Tlw6BsEkCVtl4EXpMffDlAGrXsBj7TGgx3f2igGtdzVGOj9Xgfd8wR5fSQpwZ1tOxOtY4pQAMc2/AavWiV+QxtJhsFG17WaJCpnYhTYY/GIJmcxmL4dF2D78e9D+tEH5MgkgDplP2E3pajga+Yo9O2gicCjY5HVPPq529mE/41g1q3+Pb2DtBjU3JZM0Yz6ILYCT7dEW983twvJChVMeQLDc4vT1+o1csYbUqZeXqMKs4qHmScdeymjT4Cq0S25kED6dPrjYBknsbWuxNEg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vc+Gfv3tTnnWWyXuhnH9MCtWZ4J7GA/brrkA6lMLxpqV469rJUQ6DvZg12cqIIIVpbTOCl49l8/gM+e91r/rPMQaGFXp7sGxv6mqY5SaF1CScbhy2agTxPxNfLwKR/LfKFsx9P+7sxZq5omh4BgEaOYEl/619IYWKRKzDGMUUa1Y5k/byNIlemcEJmwi88aQczPMuOzCRTW5cPXUsy7i0tTJfn3bI+yCIj7F2FQmjxlp728Xt6Qr2BxT3LyH+uOa7lcgwUP2Bc+53/67cjbeHwodzX/huonUHwzCd4sVIo8T2VmP1d+JGPo4uHaZmZyRLI9EZEFGVeHNea834ASFig==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 04 Oct 2022 09:28:05 +0000
  • Ironport-data: A9a23:LnCJFa9orFjFQnDtDnxqDrVtTnXEuO9mBUUsXf3CRtIx9vdXhiku+b6FwMMm01cbdD4nL4WkTyrq7CIW0Lia/gCEpxFf6gdzjOyjA48YN1ttKIZdiutTTevj5JCBkghgV2aCNbdIgO0glQHaKmmcqCaJuxeMyGvwrgP7KjQnWG3t7bMytgbFGiEu1Vn3Tmww9NrOrYw9pYXchlFBrDJ3wCsXiJyObUcMnYHllmda/o3uZe7pYF/tSQRqY2078NBETISUXA8z2Cq9exV+BmAo3eG4ffIb21oOxTka+S0y+Y0sSCQ1qEHjNKTwS2PtwTD1gKcyFWo4gpUOX3JbGytwCTt8/a6ududX/Z56lC4XgmNsaUKtYLBHylvCLDW5WAU0Y1InbIjRB3A0rQQBH2QTeJ5e9amLBFr6Ekwe73IJsWYEHGhAJaB5rg3c9RfsP7oDxIUXEcSYL5rabC6ZduYrIKrRs0Iou949Ur5FD1ZCZJ65q8/mYRTdHC2wkk1FeSfz6NfXKlo+JilULNvYi4p6EyWhU6BaQYpEscXjZwEDIDpXjP84+6dNilUZba9wFs/vg/BIKLh1jIBkBWxMIKveSaPmWpPqGTjDN266B9/wLmaCeeQt2EqG0rlkQW65+hrPEUQeMxvmtATNNQVlmhvQSsL0YBE3rTQBIBd9HEGuVF0Tn399KL2xlczUEAY7qs7ZDZx6e2VJnrDOQjD7AeCqc7b/9p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Dntz4vlu1gzhSWUhY5jlwKiQ9u6vVDeQlU+t79ANjgsiooFrBJ6IkrOvhSgNzqlyuRJ/7hcKsfxfwJldLwhEFyh6/6y9sieu7j9KHLgiV300HPLrz48d+dlCm2pBGoiEHmS1ebH4pRdP4z0SlggSZ+uNYFaaTkpM7mbUDHAOmE/ExnmlEeACGRjgOx9DunAE8OD5/FhgGWn9+Zpaole4vQSMUJkZ9seuSDNDLzJG0MGL4uA79ZI0HzCFbGLkWl5S0UbeIYTFBvM4Ol3Xhrs3ANrqywank58esSSAosGm3px/cQkyAeBGgzCTiIj8MMCM0xv3ez8rCewXZ9b8OajXvysr0SEpveykRqJy88cUo2mSObXXwt1AVFgirGOnOpLTZqK9yVSxtuMwvh/fhXsDqzf6M69+C6q96AkcM2TQCdSgfr5pNflEbSf9gGkoSV3rLKPhBAsQF/86AlqjIMWsHUaeCFAAexYeG+rqABCLyAyJZnlDG2+2Auq7bdbF9Wv/f0l5InuQvsdeRSaehLvzTnI/8UeP4Ldh0VttKw62+Q=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Oct 04, 2022 at 11:01:18AM +0200, Jan Beulich wrote:
> On 30.09.2022 16:17, Roger Pau Monne wrote:
> > The EFI memory map contains two memory types (EfiMemoryMappedIO and
> > EfiMemoryMappedIOPortSpace) used to describe IO memory areas of
> > devices used by EFI.
> > 
> > The current parsing of the EFI memory map was translating
> > EfiMemoryMappedIO and EfiMemoryMappedIOPortSpace to E820_RESERVED on
> > x86.  This is an issue because device MMIO regions (BARs) should not
> > be positioned on reserved regions.  Any BARs positioned on non-hole
> > areas of the memory map will cause is_memory_hole() to return false,
> > which would then cause memory decoding to be disabled for such device.
> > This leads to EFI firmware malfunctions when using runtime services.
> > 
> > The system under which this was observed has:
> > 
> > EFI memory map:
> > [...]
> >  00000fd000000-00000fe7fffff type=11 attr=800000000000100d
> > [...]
> > 0000:00:1f.5 disabled: BAR [0xfe010, 0xfe010] overlaps with memory map
> > 
> > The device behind this BAR is:
> > 
> > 00:1f.5 Serial bus controller [0c80]: Intel Corporation Lewisburg SPI 
> > Controller (rev 09)
> >     Subsystem: Super Micro Computer Inc Device 091c
> >     Flags: fast devsel
> >     Memory at fe010000 (32-bit, non-prefetchable) [size=4K]well
> > 
> > For the record, the symptom observed in that machine was a hard freeze
> > when attempting to set an EFI variable (XEN_EFI_set_variable).
> > 
> > Fix by not adding regions with type EfiMemoryMappedIO or
> > EfiMemoryMappedIOPortSpace to the e820 memory map, that allows BARs to
> > be positioned there.
> > 
> > Fixes: 75cc460a1b ('xen/pci: detect when BARs are not suitably positioned')
> > Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> 
> In the best case this is moving us from one way of being wrong to another:
> So far we wrongly include BARs in E820_RESERVED (_if_ they can be
> legitimately covered by a EfiMemoryMappedIO region in the first place,
> which I'm not sure is actually permitted - iirc just like E820_RESERVED
> may not be used for BARs, this memory type also may not be), whereas with
> your change we would no longer report non-BAR MMIO space (chipset specific
> ranges for example) as reserved. In fact I think the example you provide
> is at least partly due to bogus firmware behavior: The BAR is put in space
> normally used for firmware specific memory (MMIO) ranges. I think firmware
> should either assign the BAR differently or exclude the range from the
> memory map.

Hm, I'm not sure the example is bogus, how would firmware request a BAR
to be mapped for run time services to access it otherwise if it's not
using EfiMemoryMappedIO?

Not adding the BAR to the memory map in any way would mean the OS is
free to not map it for runtime services to access.

> I guess instead we want to handle the example you give by a firmware quirk
> workaround.

I'm unconvinced we need a quirk for this. AFAICT such usage of
EfiMemoryMappedIO doesn't go against the UEFI spec, and hence we need
to handle it without requiring specific firmware quirks.

> > ---
> > I don't understand the definition of EfiMemoryMappedIOPortSpace:
> > 
> > "System memory-mapped IO region that is used to translate memory
> > cycles to IO cycles by the processor."
> 
> That's something (only?) IA-64 used, where kind of as a "replacement" for
> x86 I/O port accesses equivalents thereof were provided (iirc 4 ports
> per page) via MMIO accesses. It is this compatibility MMIO space which is
> marked this way. Such ranges should never be seen on (current) x86.

I've heard the Arm guys speak about something similar.

There's a clarification note in newer versions of the UEFI spec:

"Note: There is only one region of type EfiMemoryMappedIoPortSpace
defined in the architecture for Itanium-based platforms. As a result,
there should be one and only one region of type
EfiMemoryMappedIoPortSpace in the EFI memory map of an Itanium-based
platform."

> > But given its name I would assume it's also likely used to mark ranges
> > in use by PCI device BARs.
> > 
> > It would also be interesting to forward this information to dom0, so
> > it doesn't attempt to move the BARs of this device(s) around, or else
> > issues will arise.
> 
> None of this is device specific. There's simply (typically) one MMIO
> range covering the entire 64k or I/O port space.

So this translation region won't be in a BAR of a host bridge for
example?

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.