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

Re: [PATCH] x86/pvh: fix identity mapping of low 1MB


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 13 Oct 2023 10:39:06 +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=WAz2JN0rYbUVd5x3P19thJgrMi56GH+1plfczujJ+hI=; b=Mw+n542qc7H/Zab0Jf4/WAyEBr62hzLMJYh1O/TFbeXm/6F9cAw2qHZPh2sJZ3q/z6GTef6HLYq+N+KctC8RIaKHqs5gdOq8CptuH7JbMyw3KUdIj2Y3P0l9zMGMp5sdNZ/gurMOmhEXDkU/2uOYuTmyRkKc9CLySXUo7jGZxlfzG0aSFtYPmZwdaOR+2MEYF30giZgYp+AOECp6psVVGkNQnPlzVF61AWsyTHURLUOnMdIRECMdYEhMhUXiHhC0k7spC70MX94GAZVxRQPKL30AbH0Cb9p4dJWRf34H/xp5UkU4So0PRX8QgAthCJxekJAe9UvnxtsGEhI9pcf8ZA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jme79cMo7mnheU5TtbBif1Zc9VAkmXCE/xNKHF2rOc29Gk4To5uJyHfjJk0NfmefNkUCT06Ec/0To4QC404KhdwB2HtX7ZFalgWJoWbwPNVXjFNtp/nnv4aosr4kQ0IJDGgqRkaDtZ9I6hfaCx6r1NeuzVY8wdo/RvLwhUyauGXUWXxNH7TJnFsvFLG3FKavLkWVDc1eyWnz48/en5UqJ4PLCiXHJqaeRLSaN9f1s9Fse6jcHIhwdHxkBB5Nob0EL5Hi2vxQzso9C+BlcqggeHgNYwVrmvkXfYSk67bxEBi1nfsvQt5pm1j7zF+BdrNPjsZ5XFmsyITY70YBgvlkRA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Henry Wang <Henry.Wang@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 13 Oct 2023 08:39:41 +0000
  • Ironport-data: A9a23:p2bNX684ze4HpGt3nYWVDrUDvX+TJUtcMsCJ2f8bNWPcYEJGY0x3z 2AcXWDSOP+NMGKmc98gPo6z9BwAuMKDnd83Ggs6rSs8E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjVAOK6UKidYnwZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ird7ks01BjOkGlA5AdnPakQ5Aa2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDkkR+ PNIAQkodSqyrPDmzK6pdK4zidsaeZyD0IM34hmMzBn/JNN/GdXvZvuP4tVVmjAtmspJAPDSI dIDbiZiZwjBZBsJPUoLDJU5n6GjgXyXnz9w8QrJ4/ZopTWDilUpidABM/KMEjCObd9SkUuC4 HrP4kzyAw0ANczZwj2Amp6prraVwXukBdNDTtVU8NZV2HyR5TUzESE/C2Piouv60kSvUdBmf hl8Fi0G6PJaGFaQZsnwWVi0rWCJujYYWsFMCKsq5QeV0K3W7g2FQG8eQVZpSNEgrt5wejUs2 XeAhdavDjtq2JWXQ3+A8rafrRupJDMYa2QFYEcsUg8t89Tl5oYpgXryos1LFae0ipj5HG/2y jXT9Cwm3exL1IgMyrmx+k3Bj3S0vJ/VQwUp5wLRGGW48gd+Y43jbIutgbTG0ct9wE+iZgHpl BA5dwK2sLhm4U2l/MBVfNgwIQ==
  • Ironport-hdrordr: A9a23:aamtXah1CwN9qkM5DEIEwNJZLHBQXgcji2hC6mlwRA09TyVXrb HWoB19726PtN9xYgBapTnkAsO9qBznhPxICOUqTNCftWrdyQ+VxeNZnOjfKlTbckWUltK1vZ 0AT0EUMqyJMbEVt7ed3OB6KbodKRu8nZyAtKPxyXFiSA0vTbph4Qd/AgPeP0VqSGB9dP8E/V anifavbgDPRUgq
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Oct 12, 2023 at 12:48:20AM +0800, Andrew Cooper wrote:
> On 11/10/2023 11:37 pm, Roger Pau Monne wrote:
> > The mapping of memory regions below the 1MB mark was all done by the PVH 
> > dom0
> > builder code, thus completely avoiding that region in the arch-specific 
> > IOMMU
> > hardware domain initialization code.
> 
> This took a while to parse.  I think it would be clearer to say "builder
> code, causing the region to be avoided by the arch ..."

Yes, that's likely better, so:

"The mapping of memory regions below the 1MB mark was all done by the PVH dom0
builder code, causing the region to be avoided by the arch specific IOMMU
hardware domain initialization code."

> >   That lead to the IOMMU being enabled
> > without reserved regions in the low 1MB identity mapped in the p2m for PVH
> > hardware domains.  Firmware with missing RMRR/IVMD ranges that would 
> > otherwise
> > be located in the low 1MB would transiently trigger IOMMU faults until the 
> > p2m
> > is populated by the PVH dom0 builder:
> 
> "Firmware which happens to be missing RMRR/IVMD ranges describing E820
> reserved regions in the low 1MB would ..." ?

Will adjust.

> > AMD-Vi: IO_PAGE_FAULT: 0000:00:13.1 d0 addr 00000000000eb380 flags 0x20 RW
> > AMD-Vi: IO_PAGE_FAULT: 0000:00:13.1 d0 addr 00000000000eb340 flags 0
> > AMD-Vi: IO_PAGE_FAULT: 0000:00:13.2 d0 addr 00000000000ea1c0 flags 0
> > AMD-Vi: IO_PAGE_FAULT: 0000:00:14.5 d0 addr 00000000000eb480 flags 0x20 RW
> > AMD-Vi: IO_PAGE_FAULT: 0000:00:12.0 d0 addr 00000000000eb080 flags 0x20 RW
> > AMD-Vi: IO_PAGE_FAULT: 0000:00:14.5 d0 addr 00000000000eb400 flags 0
> > AMD-Vi: IO_PAGE_FAULT: 0000:00:12.0 d0 addr 00000000000eb040 flags 0
> >
> > Mostly remove the special handling of the low 1MB done by the PVH dom0 
> > builder,
> > leaving just the data copy between RAM regions.  Otherwise rely on the IOMMU
> > arch init code to create any identity mappings for reserved regions in such
> > range (like it already does for all reserved regions).
> 
> "in such ranges", or in this case "in that range" would be better.  Also
> "for reserved regions elsewhere" IMO.
> 
> Just to confirm, we're saying our default treatment of identity mapping
> e820 reserved regions into the IOMMU is masking (or not) a missing
> RMRR/IVMD entry?

Yes, the provided tables are missing (some?) IVMD region(s) for the
USB devices (the 0xea and 0xeb pages at least, possibly others).  We
identity map reserved regions in the memory map for dom0 in order to
cover up for missing RMRR/IVMD regions, because it's quite common.

> >
> > Note there's a small difference in behavior, as holes in the low 1MB will no
> > longer be identity mapped to the p2m.
> >
> > Fixes: 6b4f6a31ace1 ('x86/PVH: de-duplicate mappings for first Mb of Dom0 
> > memory')
> > Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> 
> I suppose you intended to mark this for 4.18 as you CC'd Henry, and also
> send it for x86 (CC added)?

I didn't run add_maintainer on it, sorry.

> I'm tempted to commit it based on the diffstat alone.  How do we still
> have so much junk code like this lying around breaking things...
> 
> Anyway - it's a clear improvement.

I've got further improvements in this area, but not 4.18 material,
will try to post them soon anyway.

> But a question first.  Is this from debugging the XSA-442 fallout?  If
> so, it's probably worth mentioning the hardware we saw this on (which
> IIRC was fairly old AMD), and that XSA-442 unmasked a pre-existing bug. 
> And we think it's USB/PS2 emulation?

Yeah, can add this all.  It is triggered by pinot{0,1} which is AMD
Fam15h (AMD Opteron(tm) Processor 3350 HE).

Thanks, Roger.



 


Rackspace

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