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

Re: [PATCH v2] x86/p2m: fix xenmem_add_to_physmap_one double page removal


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 15 Sep 2021 10:44:54 +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; bh=QYj6oQaFjDX2lnu9xCgHFKYYTC1RRp4yRVSQUssYdMQ=; b=lgAt53q1U/Nb/0mf6ZGo/8lzHSZZjPe4vM0SipFhTz14kEi+P5ycoGozEN9r1pSaJuCCRR72KY4xdm30SMPS0Kgtwb2RsIiliKzrKaqHeV+J7WQRk/0NpAYDlC7hrR9/BaNjbxlqswYbXLBP+L6G7hvgaWqQA2QKvFmYM+JySFQHkmlcuxZT8SjG+XBBVwIlaehlRzXW4XhCPxtwWe3j7/VyHNo3WgA8ZnTMGveQ7b18QOxgAwCTPhlkdjrl4vNsG0L0YvWI6rRjYLJFg13uUQsQgZ7DfF52sPiLTXAF2XrIZqL5QqE4JArHfoHibqkNNClE1Cfhm5Ihyt2PHp1gKA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LbvsJ7enWwaavjjULKBD7idImaK3WPB0tOVRhALCCoCWwoQ7RlkNJ8j/KGhPT9B3hyfQkVz7C2h881bBhPKaHNI/yKpCP4ZSQZIEQTDfuI5B3cIsNn4zEKS27xW1naSmp4NHpmrMD4yEdaejuXb0VMJ44cxO3C1ZzuvEFxviIX/0P2TJcMPvrK9W9le1EndHVCUyCUuilf5WifkAk2tFSufOG4D/9wLoblxnJLfkGU+A+IJUtlyOaK6U6trJoIVGqlsalaqYRctfp/CpDTUAXpHD4dc8po7pYvnV3RGHB30wOZZiGwC0KExftr37eZV7nrfYXYgwtmsfBAYhcR2pug==
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 15 Sep 2021 08:45:17 +0000
  • Ironport-data: A9a23:tlr1ZqDdqOialxVW/xfkw5YqxClBgxIJ4kV8jS/XYbTApGsq0TdTn DMfUWvTP6vYZzOmfY91O9vk8RsOuJTTyYNlQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMo/u1Si6FatANl1ElvU2zbue6WLOs1hxZH1c+EX9w0E87wYbVv6Yz6TSHK1LV0 T/Ni5W31G+Ng1aY5UpNtspvADs21BjDkGtwUm4WPJinj3eH/5UhN7oNJLnZEpfNatI88thW5 Qr05OrREmvxp3/BAz4++1rxWhVirrX6ZWBihpfKMkQLb9crSiEai84G2PQghUh/ojqLpMB72 dl2uJnuYy4uZ7X1uLgmakwNe81+FfUuFL7vJHG+tYqYzlHccmuqyPJrZK00FdRGoKAtWzgIr KFGbmBWBvyAr7veLLaTUO5ji95lNMD2FIgepmth3XfSCvNOrZXrHv+RuIUDhW1YasZmE+mHa tFGOAdTXAnFQSNwFnk0BbMPg7L97pX4W2IB8w/EzUYt2EDDwQo03LXzPd79ft2RWd4Tjkuev njB/WnyHlcdLtP34SWB2mKhgKnIhyyTcIAYGaC89/VqqEaO3WFVAxoTPWZXutHg1BT4AYgGb RVJpGx+9sDe6XBHUPHUUB+DsHSVsiURXoR6Oupj8DitlpHttlPx6nc/ctJRVDA3nJZoHmV3h wDWwYqB6S9H6+LOGCnEnluAhXbrY3FEczVaDcMRZVZdu7HeTJcPYgUjpzqJOJW8iMH8URr0y iqDx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o9pxT3P/s0MFKCsCggtUcbh/slgGrToJ8XKDqhkF4nMifrHIR1P XcqRYpOMp+r1vXY2GOuBPonzLt1T4/gkWSgWOwsD/Gm4jUVTg6A81OicZyaR3C8Xctu9l6ze Ziw3+Zn4A/N2KBoA3No/zzEz16nEu9pnQv1cQJiWZEbIcYYLhN6aQC4UJuFosaFi6S0vFnLA BXNrCf2B9qSyLeU5iA1VMfhOBEH05DUCtue3Jy+fB8iFNt7TdEJ0hx/r1Xop5PzuN6d3Hoj9 60RpiAr4s+PPP+W5gNctvpcfHHeVAlfii8RV56AW6XX53vaEi94aIe3t0OlZaXkdozvcIPpK g=
  • Ironport-sdr: 1Q8r67l/Ojve8Ys2or7LqILnPrtt/pRDoFpAiIZnkhK+yT2QsYbvIxgS1M501+BEJlmBi7xk7i HPjA0tnjlBVHUx9ooVbfWTKPSjqFcoH/POcdHPVT3QXyxFoyfM5sCWUpN+pPQ6Upu4Gn3Owy5y oiZA212eAkPCGq7Fg4Hc5l3fTnfYk79Wap2/8xtxkZG4xHP4vT0pkBHro9NBTuQdn5crtjSfiG c36y5yi+YF5bLsRTBg0iKIfR2+874ceXlOgDNmx2iCfejbmgob5cpZIPS5tkbkOkEKx0nq5t/W Z2lZVQCsJ6TVskKt0QcWTmQG
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Sep 15, 2021 at 10:16:41AM +0200, Jan Beulich wrote:
> On 15.09.2021 10:03, Roger Pau Monne wrote:
> > If the new gfn matches the previous one (ie: gpfn == old_gpfn)
> > xenmem_add_to_physmap_one will issue a duplicated call to
> > guest_physmap_remove_page with the same guest frame number, because
> > the get_gpfn_from_mfn call has been moved by commit f8582da041 to be
> > performed before the original page is removed. This leads to the
> > second guest_physmap_remove_page failing, which was not the case
> > before commit f8582da041.
> > 
> > Add a shortcut to skip modifying the p2m if the mapping is already as
> > requested.
> 
> I've meanwhile had further thoughts here - not sure in how far they
> affect what to do (including whether to go back to v1, with the
> description's 1st paragraph adjusted as per above):
> 
> > --- a/xen/arch/x86/mm/p2m.c
> > +++ b/xen/arch/x86/mm/p2m.c
> > @@ -2799,6 +2799,13 @@ int xenmem_add_to_physmap_one(
> >          goto put_all;
> >      }
> >  
> > +    if ( gfn_eq(_gfn(old_gpfn), gpfn) )
> > +    {
> > +        /* Nothing to do, mapping is already as requested. */
> > +        ASSERT(mfn_eq(prev_mfn, mfn));
> > +        goto put_all;
> > +    }
> 
> The mapping may not be "already as requested" because of p2m type or
> p2m access. Thoughts? (At the very least the new check would likely
> want to move after the p2m_mmio_direct one.)

Is the type really relevant for the caller? If the mapping is already
setup as requested, I don't think it makes sense to return -EPERM if
the type is mmio. I'm also unsure whether we can get into that state
in the first place.

I'm unsure regarding the access, I would say changing the access type
should be done by other means rather that replying on
xenmem_add_to_physmap.

v1 was indeed more similar to the previous behavior IMO, so it's
likely a safer approach.

Thanks, Roger.



 


Rackspace

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