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

Re: [PATCH] x86/p2m-pt: fix p2m_flags_to_access()


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 7 Sep 2021 13:22:52 +0100
  • 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=/89I8PoBYdPweDDXpJU0m/Tu0Qc273nHKnykOHY2riw=; b=N0p9uIBL7STgRCbOjYw/pHLAtSpUvn6pbcTopk8jytCsOGy9eaR06igKBPy49OcC4BOGi4v8s9+BzFSfQQO+hH5R+ZBHdVfsucUDWlTS/uM3wVZpoQ0a0N9JiiV9xJ1eaaLtv3plBYoinR22Oo36082Jcg3+n7PJ/Xm0fDQQqWruxff0Z2jN8GKcyOx8+R3yJkaXJZjr0NR040I64rq9Lc26qYiZP87q6MxjyioT8/k3SGPvKIianSC99Gg7Srcw/6q29mrqaSpy1w6jQFsWSA6PQrmAcx9NCFNBSKZrfdRXZoMMAGAVynR/roUSWBhxCjZILOMDAKwMlnzyTeVefg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DbrTKVl9PF8CCdv0X86WEEyyYY2eoAwUGvtPdhggnbJcDTWb60btkCZJjq+/Hm5N0tPU6+F67ML7X3iZ+kTCA1A8WSz1zXFiyN0C9Nwp+gviBh3sh2KiLHwnN1CP6FRVKUYYl580W+rAkry7DJecJa7+0H9KtiedWZe92eCu4uGtC95ZK1YLAptv4TmBiJKEWWVMBC39yE25xvLy/9dhaW4kBtuqpwpXG2Xxgo+iPHoAzS39BHkW1wvn48jisU5BzYVCT9JTd9PrOM/2MyO/4/oXwfvXSlRZKF5fjYQFm91j6P+HbPr/HrdU5JYSR5NLmIOuuYjX+wRnsFncPZ/2jg==
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>
  • Delivery-date: Tue, 07 Sep 2021 12:23:14 +0000
  • Ironport-hdrordr: A9a23:cl9QIq4XmHu+TJSn5gPXwAzXdLJyesId70hD6qkQc3Fom62j5q WTdZEgvyMc5wx/ZJhNo7690cq7MBHhHPxOgbX5VI3KNGXbUQOTR72KhrGSoAEIdReeygZcv5 0QCZSXCrfLfCVHZRCR2njFLz4iquP3j5xBnY3lvhNQpZkBUdAZ0+9+YDzrdXFedU19KrcSMo GT3cZDryrIQwVtUizqbkN1OdQqvrfw5evbXSI=
  • Ironport-sdr: jgCqq3dw9YpX5Uz6TmLwID2hGPT3wGsY+Pt9XkCfIKmBQxY58vc/UY1hXkCel8SlXLI+jyvYjr fDbl43hkqy8WusXCZv1e8B2uWDyAbKJY2xovtQa/iShlEybzgKCgbfOZl1lvVoDmhtcc5Ol7Dw 4RS3dfKc73sbZnzxjmNGapy9gLedzhKh8v8j6w/ZAgFN8ivoII0DV/PCaN07HpT/Q3DyV+krS1 toxYM7aL2XCogcS4mzA9iYmhhkABxUkUws9ItiHWlq9CWzUGJSP2CFIVM4y1+yVkbHTFaGtJdq 2aHIxuc+i8PIxfecMaP6rIBZ
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 02/09/2021 08:01, Jan Beulich wrote:
> The initial if() was inverted, invalidating all output from this
> function. Which in turn means the mirroring of P2M mappings into the
> IOMMU didn't always work as intended: Mappings may have got updated when
> there was no need to. There would not have been too few (un)mappings;
> what saves us is that alongside the flags comparison MFNs also get
> compared, with non-present entries always having an MFN of 0 or
> INVALID_MFN while present entries always have MFNs different from these
> two (0 in the table also meant to cover INVALID_MFN):
>
> OLD                                   NEW
> P W   access  MFN                     P W     access  MFN
> 0 0   r       0                       0 0     n       0
> 0 1   rw      0                       0 1     n       0
> 1 0   n       non-0                   1 0     r       non-0
> 1 1   n       non-0                   1 1     rw      non-0
>
> present <-> non-present transitions are fine because the MFNs differ.
> present -> present transitions as well as non-present -> non-present
> ones are potentially causing too many map/unmap operations, but never
> too few, because in that case old (bogus) and new access differ.
>
> Fixes: d1bb6c97c31e ("IOMMU: also pass p2m_access_t to p2m_get_iommu_flags())
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

>
> --- a/xen/arch/x86/mm/p2m-pt.c
> +++ b/xen/arch/x86/mm/p2m-pt.c
> @@ -548,7 +548,7 @@ int p2m_pt_handle_deferred_changes(uint6
>  /* Reconstruct a fake p2m_access_t from stored PTE flags. */
>  static p2m_access_t p2m_flags_to_access(unsigned int flags)
>  {
> -    if ( flags & _PAGE_PRESENT )
> +    if ( !(flags & _PAGE_PRESENT) )
>          return p2m_access_n;
>  
>      /* No need to look at _PAGE_NX for now. */
>




 


Rackspace

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