[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: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 15 Sep 2021 10:16:41 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=xtYTEz4egySuYKDee2kzOyxpiadVw/pEzzeIm62TtmQ=; b=nD8sVxD1d9jNVf5LHVFJTvf8jS7NVBWXGRAj5eixHl3PllU01B9SrG94+lUys7aWFQbO9hgosqp7erwdjrD5DDy+Hpu7e0rW2cCoEFJFVKPAIG1l1xRDWiDy+/e/XtNYzcYJVok42HdCDL9M3nJcxe1PjJbSfhsf+3S2PEeuJD6FzFgqqy8MWgfn2bMbyRaFj8U1OuOtdAOKCNXkt7avAT/6qbbelxZ4p+K2ujwC0+m+1rEM3QLmALkqyaa/njiALu2MKnlX391XrPeoSUWHRMIhFrE3eFRuS9Ng9FVpShcITEtZghaaGH4q1GuvlTb+CLrIbwb8kRu7cYG8bKuf2w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NneLDN7yQzu0YqIqW2FH7NtgM3BIZdAYCuVH8uc2XTl7cuOIVvk5WtFTsA6KHbCAlYzGrkUobP8b9OD3cx2+TDjeyj8N5Ug3Vn4gZHu60rhC6BO4X0MQCyPCfcQyk+9mXDb/UTXxGckjZsOyMQWNuXz9tMCePUOi7RiwyVcTIIYFsXsxyub6Mp7bZaJ7FjEUOPAOf/EQcp3qnSA/aoGaXi541fV0H6ens77vkj24hap8r0HogpiBNK9fPRsrXIFqUiTVANSq/6VHt+axmp0s+Byn+1TkglVdmx5TTqkyxlkhAWs/g3/mrc/UGnIqepVSTMbKMSSefuODgKdFGo6izQ==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=suse.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:17:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.)

I've also meanwhile realized that it was a different form of short
circuiting that I had been thinking about before: XENMAPSPACE_gmfn's
idx == gpfn.

Jan




 


Rackspace

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