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

Re: [PATCH 2/2] xen/x86/pvh: copy ACPI tables to Dom0 instead of mapping


  • To: Xenia Ragiadakou <xenia.ragiadakou@xxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 18 May 2023 13:44:01 +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=qTUiPJ4aaci7VUDmEZj1uJHBr208SvM+4RyxcdBpU9E=; b=lt2FILQSN2sVXSWU8JlJQ+Sa1gObxX0CBzX2HIgARExkWgkjefGMHp1Q0Gf/DMSUmZcEJp8DNWyYq6IXI2gbYINPnwTFtsBYjNuSSv+TS+wHISDlLhxsz1mblXBCIFxwM7eQP4aUntQjBTl3TQ0ZFLsNOIzt1y26cooKJo7Ren6QUgIjteeOy0IRZOnja5y6LNA6SbANlzW7/eYqkv9jufvHCPNLgkQE3CAPGc315K8MEn6CJi7f3Dc7hUnycpepC1mtPY9qReyNevhdGGFqR/AO6WujbI62R5TQHLH2Z3i/687Az3ilgyP3HYid1wFTp38Z8YR4Y0xOp/QKDYRwZQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iQi/l2gQ0i/Z1uY8IBqc3PvKEfqJPIB9e+UCs0SpjiyalWaZW1BkTPiDn1DjDjobxKtlIEaqbitsaITPAPDIYJaPJATmti32gGOtWC+PpOhM56v4Wz25qs3oE0hsIayeNKmCudiTv8PYU5fp7/ZozWxEVUValO7qIZnY7LxEfIiYzBkCBCXgy9bU9yFhpOyYj8AKOvUPxppRtZ3dw0ui/D+/FY/3rMhID0QTGMOeabyu86ROs9uQ7KScCT3CyRq0VIOgAQoQ8dsqTa4d9tj7xQqcPgPq6INKDLBwZ3kkd757BAW3SdDbFDK0B3Nxl7RHFmWC3gbFwoxrPzwFsi6r5w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Stefano Stabellini <stefano.stabellini@xxxxxxx>, andrew.cooper3@xxxxxxxxxx
  • Delivery-date: Thu, 18 May 2023 11:44:33 +0000
  • Ironport-data: A9a23:z91DC6NvE5AQ19HvrR1FlsFynXyQoLVcMsEvi/4bfWQNrUon3jYBy jRNWz+FPvneZmWkKthwO9+/pEhQuZLUyYBqTwto+SlhQUwRpJueD7x1DKtS0wC6dZSfER09v 63yTvGacajYm1eF/k/F3oDJ9CU6jufQAOKnUoYoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGj9SuvPrRC9H5qyo42tF5wxmP5ingXeF/5UrJMNHTU2OByOQrrl8RoaSW +vFxbelyWLVlz9F5gSNy+uTnuUiG9Y+DCDW4pZkc/HKbitq/0Te5p0TJvsEAXq7vh3S9zxHJ HehgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/ZqAJGpfh66wGMa04AWEX0uZIAk9p+ dMAExsmVU6s3OL1x62eWOY506zPLOGzVG8ekldJ6GmFSNMZG9XESaiM4sJE1jAtgMwIBezZe 8cSdTtoalLHfgFLPVAUTpk5mY9EhFGmK2Ee9A3T+vFxujePpOBy+OGF3N79YNuFSN8Thk+Fj mnH4374ElcRM9n3JT+tqyr93b6VwH+rMG4UPOWT9q5Qmkys/Us0BS08ZRilpKO3slHrDrqzL GRRoELCt5Ma5EGtT9C7RRS3oXeItx0bRvJZFuF84waIooLW6QuEAmkPThZadccr8sQxQFQCz USVltnkAThutry9Sn+H8LqQ6zSoNkA9PWIEICMJUwYBy93iu50oyALCSM55F6y4hcGzHiv/q xiRsCUwjrMUy9UX3q+2+VTGhTOEr53FCAUy423qsnmN6wp4YMugeNau4F2DsfJYdt/GEh+Go WQOnNWY4KYWF5aRmSeRQeILWra0+/KCNz6aillqd3U8ywmQF7eYVdg4yFlDyI1Ba67opReBj JfvhD5s
  • Ironport-hdrordr: A9a23:kRLQPKsdJ+JYObWN4E2+BSI07skDedV00zEX/kB9WHVpm62j5q aTdZEgvyMc5wxhOk3I9erhBEDjewK4yXcF2/hzAV7KZmCP0wqVxepZnO/fKlPbakrDHy1muZ uIsZISNDQ9NzdHZA/BjjWFLw==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, May 18, 2023 at 02:36:41PM +0300, Xenia Ragiadakou wrote:
> 
> On 18/5/23 12:31, Roger Pau Monné wrote:
> > On Thu, May 18, 2023 at 10:24:10AM +0300, Xenia Ragiadakou wrote:
> > > On 15/5/23 17:17, Jan Beulich wrote:
> > > > On 13.05.2023 03:17, Stefano Stabellini wrote:
> > > > > From: Stefano Stabellini <stefano.stabellini@xxxxxxx>
> > > > > 
> > > > > Mapping the ACPI tables to Dom0 PVH 1:1 leads to memory corruptions of
> > > > > the tables in the guest. Instead, copy the tables to Dom0.
> > > > Do you really mean "in the guest" (i.e. from Xen's perspective, i.e.
> > > > ignoring that when running on qemu it is kind of a guest itself)?
> > > > 
> > > > I also consider the statement too broad anyway: Various people have
> > > > run PVH Dom0 without running into such an issue, so it's clearly not
> > > > just "leads to".
> > > In my opinion the issue is broader.
> > > 
> > > In pvh_setup_acpi(), the code adding the ACPI tables to dom0 memory map 
> > > does
> > > not check the return value of pvh_add_mem_range(). If there is an overlap
> > > and the overlapping region is marked as E820_ACPI, it maps not just the
> > > allowed tables but the entire overlapping range ,
> > But that's the indented behavior: all ACPI regions will be mapped into
> > the dom0 physmap, the filtering of the tables exposed to dom0 is done
> > in the XSDT, but not in by filtering the mapped regions.  Note this
> > won't be effective anyway, as the minimal granularity of physmap
> > entries is 4k, so multiple tables could live in the same 4K region.
> > Also Xen cannot parse dynamic tables (SSDT) or execute methods, and
> > hence doesn't know exactly which memory will be used.
> Thanks a lot for the explanation. I checked more carefully the code and it's
> true that xen does not aim to restrict dom0 access to ACPI tables. I got
> confused by the name of the function pvh_acpi_table_allowed.
> > 
> > Xen relies on the firmware to have the ACPI tables in ACPI, NVS or
> > RESERVED regions in order for them to be mapped into the gust physmap.
> > The call to pvh_add_mem_range() in pvh_setup_acpi() is just an attempt
> > to workaround broken systems that have tables placed in memory map
> > holes, and hence ignoring the return value is fine.
> In pvh_setup_acpi(), xen identity maps E820_ACPI and E820_NVS ranges to
> dom0. Why it does not do the same for E820_RESERVED, since ACPI tables may
> also lie there and since it does not know which memory will be used?

So far I at least wasn't considering that ACPI tables could reside in
RESERVED regions.  Given the behavior exposed by QEMU I think we need
to move the mapping of RESERVED regions from arch_iommu_hwdom_init()
into pvh_populate_p2m() for PVH dom0, thus rendering
arch_iommu_hwdom_init() PV-only.

> > > while if the overlapping
> > > range is marked as E820_RESERVED, it does not map the tables at all (the
> > > issue that Stefano saw with qemu). Since dom0 memory map is initialized
> > > based on the native one, the code adding the ACPI table memory ranges will
> > > naturally fall into one of the two cases above.
> > Xen does map them, but that's done in arch_iommu_hwdom_init() which get
> > short-circuited by the usage of dom0-iommu=none in your example.  See
> > my reply to Stefano about moving such mappings into pvh_populate_p2m().
> Indeed, if dom0-iommu=none is removed from the xen cmdline and qemu is
> configured with an iommu, the issue is not triggered. Because
> arch_iommu_hwdom_init() identity maps to dom0 at least the first 4G, right?

For PVH dom0 only reserved regions are identity mapped into the
physmap.

Thanks, Roger.



 


Rackspace

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