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

Re: [PATCH for-4.18 v2] x86/pvh: fix identity mapping of low 1MB


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Henry Wang <Henry.Wang@xxxxxxx>
  • Date: Fri, 13 Oct 2023 09:17:31 +0000
  • Accept-language: zh-CN, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.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=1WTD5AERBcG88HvphDJ5e61yx+2QMCF7n5OIbUV0jXg=; b=n5Go1PXKoBBbtxqtdmnnCZuf7BXLn2AnNxspX/7VxTKkzMERA8gnmmJd7UDZmTIxHOhLq2afZKy990J6tya23+OmgzjXtx9blohdQAHWUyABz6aR8dQLxwKg33J6XMqPzO1oPw7pH7/Itwhd19qQYlsLTBSYnjrKrpy0kYxM3dnl1C4gIf1OzzOXD1eO0H2ktQ1jirCMPkGM987ncLyOswrGJ0Iqa1rJlAuNZ21nyCiOCHzuM8IJNWvZ5M2YmacZ5g7oF4080+1XyLc+B8I32HBpp3cM4sq3ZBMkCE2U/Fdqw9ZeLJYlGdoGra+LUg/P183NIPEFXLTbYeRNWUSirw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CFhWGDTIK8XwS1DZTEbk3FXc+WFrs0IASWCv0qGPGu3i56Dm9vzyYQewgWR2wOv8YSmvQycwhYL4iipAep1nzy6JBB2dSywoney4pFQ3ry0umYq9LT49F756NegcZKswaZaIK30LcFkAgYYU18tneaAQ4bGGnCUXT/s49wjwy7s1hhH/OZvw/R6I3nDraO+K7Ruw/QpOHgYpuo9/hAgiH3SmC3XuRi4ndliDYNs2yMvj0Yjo1qq7AahHTbi3GWTcxlSjTY0HGm4/gLfTYNY/7dIek5saoKK/VlFhACoJ9hrjuGSZrQQirfTJMsNb55Ot2kTb1qwzWi7+WSQWv+UDsQ==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Fri, 13 Oct 2023 09:17:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHZ/bNI9rurnZMB2EitKmMnzqD0o7BHcLkA
  • Thread-topic: [PATCH for-4.18 v2] x86/pvh: fix identity mapping of low 1MB

Hi Roger,

> On Oct 13, 2023, at 16:56, Roger Pau Monne <roger.pau@xxxxxxxxxx> wrote:
> 
> 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 which happens to be missing RMRR/IVMD ranges
> describing E820 reserved regions in the low 1MB would transiently trigger 
> IOMMU
> faults until the p2m is populated by the PVH dom0 builder:
> 
> 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
> 
> Those errors have been observed on the osstest pinot{0,1} boxes (AMD Fam15h
> Opteron(tm) Processor 3350 HE).
> 
> 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 that
> range (like it already does for reserved regions elsewhere).
> 
> 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>

Release-acked-by: Henry Wang <Henry.Wang@xxxxxxx>

Kind regards,
Henry

> ---
> Changes since v1:
> - Reword commit message.
> ---
> xen/arch/x86/hvm/dom0_build.c       | 22 ----------------------
> xen/drivers/passthrough/x86/iommu.c |  8 +-------
> 2 files changed, 1 insertion(+), 29 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
> index bc0e290db612..979db7d1ec4d 100644
> --- a/xen/arch/x86/hvm/dom0_build.c
> +++ b/xen/arch/x86/hvm/dom0_build.c
> @@ -449,28 +449,6 @@ static int __init pvh_populate_p2m(struct domain *d)
>         }
>     }
> 
> -    /* Non-RAM regions of space below 1MB get identity mapped. */
> -    for ( i = rc = 0; i < MB1_PAGES; ++i )
> -    {
> -        p2m_type_t p2mt;
> -        mfn_t mfn = get_gfn_query(d, i, &p2mt);
> -
> -        if ( mfn_eq(mfn, INVALID_MFN) )
> -            rc = set_mmio_p2m_entry(d, _gfn(i), _mfn(i), PAGE_ORDER_4K);
> -        else
> -            /*
> -             * If the p2m entry is already set it must belong to a RMRR and
> -             * already be identity mapped, or be a RAM region.
> -             */
> -            ASSERT(p2mt == p2m_ram_rw || mfn_eq(mfn, _mfn(i)));
> -        put_gfn(d, i);
> -        if ( rc )
> -        {
> -            printk("Failed to identity map PFN %x: %d\n", i, rc);
> -            return rc;
> -        }
> -    }
> -
>     if ( cpu_has_vmx && paging_mode_hap(d) && !vmx_unrestricted_guest(v) )
>     {
>         /*
> diff --git a/xen/drivers/passthrough/x86/iommu.c 
> b/xen/drivers/passthrough/x86/iommu.c
> index c85549ccad6e..857dccb6a465 100644
> --- a/xen/drivers/passthrough/x86/iommu.c
> +++ b/xen/drivers/passthrough/x86/iommu.c
> @@ -400,13 +400,7 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain *d)
>     max_pfn = (GB(4) >> PAGE_SHIFT) - 1;
>     top = max(max_pdx, pfn_to_pdx(max_pfn) + 1);
> 
> -    /*
> -     * First Mb will get mapped in one go by pvh_populate_p2m(). Avoid
> -     * setting up potentially conflicting mappings here.
> -     */
> -    start = paging_mode_translate(d) ? PFN_DOWN(MB(1)) : 0;
> -
> -    for ( i = pfn_to_pdx(start), count = 0; i < top; )
> +    for ( i = 0, start = 0, count = 0; i < top; )
>     {
>         unsigned long pfn = pdx_to_pfn(i);
>         unsigned int perms = hwdom_iommu_map(d, pfn, max_pfn);
> -- 
> 2.42.0
> 


 


Rackspace

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