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

Re: [PATCH] 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 09:50:39 +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=5W6DN5j2PLL8WQ1KBd6ZY06LmsFB+DZCdaeQe9CMJAE=; b=Z+oowZrbZDuZLJud6z58dJY77NWEFa/3OU0ABy7qQ8NWNrsdFoczsCqg4/fhX7gqxs8qHw3CK75id19iVGKtlSEXxsX0nF6lTQx0M9fYb/480w6IF74Of575BFzDCpfugYNHYtZZow/pCWgRYAEH2TX2/MHAVdWvSPTznlu0MNvsOhJgaB0QrJtBdPX1BgEBR5m2Uex4v9ZcKiBYJCt6tZo0w4huV3AbcCyLPBso5pcMS0wIQ7/yv6enCoSOYQD0h1TeA34uIAlrsrKJFjFemfjoGxaPapAR0SYxKdmYPfHbexkXHvOYWdLxKrAFyzdbLXRWRCkN0n5j/zQeXvdQhQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kbu/hLyaA7s+UP3oXCDkiDrrwmEuPuDQtpEvZJ6xtbvtFoZH7lCbu7sSXyKL+TSz9XxBWoFgSGWRLFSNyWjNB4FRiBqD3GYHlzPIVg5EWukKFX1zDSX3UPHJFolkzsFkliLWKwEz/oE6R73/z0iPoK00CTV0IQwPnzwQTDjt1IKkc+ILZj3q9K7qK/i6/50RqRbCnXLVr9qqegEaP8kuUGaQY5Fgxo048IoQbZmYgnX/IOUCtrNRT4X0/TGAFFWbEyUNkQhcWCvDKDemICcxdd8M7yf8y9qhufnyDh6AWGOivcLAMSrYsXgVy3opcHyB2i8ErXb7OO8TPzWGL0fKpg==
  • Authentication-results: esa1.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 07:51:06 +0000
  • Ironport-data: A9a23:5/0Mva6zZ62rqkrl3QpuUQxRtAbAchMFZxGqfqrLsTDasY5as4F+v jAaDTuOaPuOZmChLdwgO9/i9U8B7JWAx4VqHVRkr3gwHi5G8cbLO4+Ufxz6V8+wwmwvb67FA +E2MISowBUcFyeEzvuV3zyIQUBUjclkfJKlYAL/En03FVIMpBsJ00o5wrZo29Mw27BVPivW0 T/Mi5yHULOa82Yc3lI8s8pvfzs24ZweEBtB1rAPTagjUG32zhH5P7pGTU2FFFPqQ5E8IwKPb 72rIIdVXI/u10xF5tuNyt4Xe6CRK1LYFVDmZnF+A8BOjvXez8CbP2lS2Pc0MC9qZzu1c99Zl /BJp5erZ1kTAajcqsgMAl4fVDt7BPgTkFPHCSDXXc27ykTHdz3nwul0DVFwNoodkgp1KTgQr 7pCcmlLN03dwbLtqF64YrAEasALNs7kMZlZonh95TrYEewnUdbIRKCiCdpwgWxp2JweTa62i 8wxNSExZUr4bD90KloLCLMBoPuUoVu4SmgNwL6SjfVuuDWCpOBr65D9PdyQdtGUSMF9mkeDu nmA72n/GgsdNtGU1XyC6H3ErvDLtTP2XsQVDrLQ3vxgjUCXx2cTIAYLTlb9qv684nNSQPoGd RZSoHB36/Fvqgr7FbERQiFUvlbbmxoOUMF+TdcF7RG/5ruFpEHeHG09G2sphMMdiCMmedA7/ gbXxIq0VGMw7uT9pWG1rejP/GjrUcQBBSpbP3ZVE1FdizX2iNxr1nryosBf/LlZZzEfMQr5x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F2on+8ZvzU H11yjCoomzufCyzRHRk0fV8pRtgdPkjv9OHtaFhMQ5IijlziyoeINicbufuy1dmpDj1H8a1P 335zswNcV67H3cOkmzvBvWwgHllA0j7nfzoGXoyEfLkIjcfnYXGsBBjYVWfl/y8Ew7puxx16 pNwiawq4dXJQmoplW92/H4EzVR0makq3srluAey1ZFV5EFVbNXpYsDuGtIDZY7Gj7g4oxPKp ghMCjl3ocUTbqmVQGagoE2q+bcG0jbXy32DXTqg/blkwS/xxtCvg8lLM92pAZ3yHtycegC2w xoWp4Y4Y2mdfVmHp6VMt1xNvdfOla9MS4kD1jiU2gPNJt3c04l+KSHq4nc2omRCeg1Jd0J6d L8bG8=
  • Ironport-sdr: RMhcBG6rE2+MJHp3oUswB2K9suNxkGEWPj8FNTZLEDEx+XLAQssuHTUSxJXjRakQQNNlIJW6SD JlPLWpWMVo+IxpY9fOxkzfJ7n/bW5CS0tC2uTe1vW6SAb4WEm3/U+z8ROd9/Lift3XtQ/iiS69 iNExidkDaO9cjYPoG8yX8O31dXOxkBRbMDWHbfGwaTgwDxIXP7cR7gGK9HUfdJ8ClpMv8ABrSt zl2ipgFiUggWoz89Na+lbEUL5JJM2GVqpnzk6fS1TBDwomgOoa7xR8C2tbci7gSO8EeFH9J9US ZCIVqpKchgkUQEyXoLQT3Lsw
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Sep 14, 2021 at 04:32:53PM +0200, Jan Beulich wrote:
> On 14.09.2021 15:34, Roger Pau Monne wrote:
> > If the new gfn matches the previous one (ie: gfn == old_gpfn)
> 
> It took me a while to realize that you probably mean "gpfn" here.

Indeed. The variable names could probably do with some disambiguation.

> > xenmem_add_to_physmap_one will issue a duplicated call to
> > guest_physmap_remove_page with the same gfn, because the
> 
> Considering the local variable of this name, may I suggest to
> upper-case GFN in this case?
> 
> > 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.
> > 
> > Fix this by adding a check that prevents a second call to
> > guest_physmap_remove_page if the previous one has already removed the
> > backing page from that gfn.
> 
> Same here (if this remains; see below).
> 
> > --- a/xen/arch/x86/mm/p2m.c
> > +++ b/xen/arch/x86/mm/p2m.c
> > @@ -2813,7 +2813,7 @@ int xenmem_add_to_physmap_one(
> >      }
> >  
> >      /* Unmap from old location, if any. */
> > -    if ( !rc && old_gpfn != INVALID_M2P_ENTRY )
> > +    if ( !rc && old_gpfn != INVALID_M2P_ENTRY && !gfn_eq(_gfn(old_gpfn), 
> > gpfn) )
> >          rc = guest_physmap_remove_page(d, _gfn(old_gpfn), mfn, 
> > PAGE_ORDER_4K);
> >  
> >      /* Map at new location. */
> > 
> 
> It feels unbalanced to suppress the remove, but keep the add in
> this case.

Well, there's a remove further up which is not skipped.

> Wouldn't we be better off skipping both, or short-
> circuiting the effective no-op even earlier? I recall considering
> to install a shortcut, but it didn't seem worth it. But now that
> you've found actual breakage, perhaps this need reconsidering.

Sure, just didn't think this corner case was worth adding a short
circuit. Let me send v2 with that approach if that's what you
prefer.

Thanks, Roger.



 


Rackspace

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