xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Paul Durrant <Paul.Durrant@citrix.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Jan Beulich <jbeulich@suse.com>, Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH 3/4] x86/iommu: reorder conditions used in the inclusive iommu mappings
Date: Tue, 31 Jul 2018 07:29:20 +0000	[thread overview]
Message-ID: <3054fb6d40b94040804ee44d7dbc77dc@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <20180727153149.25094-4-roger.pau@citrix.com>

> -----Original Message-----
> From: Xen-devel [mailto:xen-devel-bounces@lists.xenproject.org] On Behalf
> Of Roger Pau Monne
> Sent: 27 July 2018 16:32
> To: xen-devel@lists.xenproject.org
> Cc: Jan Beulich <jbeulich@suse.com>; Roger Pau Monne
> <roger.pau@citrix.com>
> Subject: [Xen-devel] [PATCH 3/4] x86/iommu: reorder conditions used in the
> inclusive iommu mappings
> 
> In order to place all the map conditions in a single if ... else
> conditional.
> 
> No functional change.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> Cc: Jan Beulich <jbeulich@suse.com>
> ---
>  xen/drivers/passthrough/x86/iommu.c | 23 ++++++++++-------------
>  1 file changed, 10 insertions(+), 13 deletions(-)
> 
> diff --git a/xen/drivers/passthrough/x86/iommu.c
> b/xen/drivers/passthrough/x86/iommu.c
> index ba0bbd9a15..24cc591aa5 100644
> --- a/xen/drivers/passthrough/x86/iommu.c
> +++ b/xen/drivers/passthrough/x86/iommu.c
> @@ -158,19 +158,9 @@ void __hwdom_init arch_iommu_hwdom_init(struct
> domain *d)
>           * regions. When set, the inclusive mapping additionally maps in
>           * every pfn up to 4GB except those that fall in unusable ranges.
>           */
> -        if ( pfn > max_pfn && !mfn_valid(_mfn(pfn)) )
> -            continue;
> -
> -        if ( iommu_inclusive && pfn <= max_pfn )
> -            map = !page_is_ram_type(pfn, RAM_TYPE_UNUSABLE);
> -        else
> -            map = page_is_ram_type(pfn, RAM_TYPE_CONVENTIONAL);
> -
> -        if ( !map )
> -            continue;
> -
> -        /* Exclude Xen bits */
> -        if ( xen_in_range(pfn) )
> +        if ( (pfn > max_pfn && !mfn_valid(_mfn(pfn))) ||
> +             /* Exclude Xen bits */
> +             xen_in_range(pfn) )
>              continue;
> 
>          /*
> @@ -179,6 +169,13 @@ void __hwdom_init arch_iommu_hwdom_init(struct
> domain *d)
>           */
>          if ( iommu_dom0_strict &&
>               page_is_ram_type(pfn, RAM_TYPE_CONVENTIONAL) )
> +            map = false;
> +        else if ( iommu_inclusive && pfn <= max_pfn )
> +            map = !page_is_ram_type(pfn, RAM_TYPE_UNUSABLE);
> +        else
> +            map = page_is_ram_type(pfn, RAM_TYPE_CONVENTIONAL);
> +

Maybe better as...

If ( page_is_ram_type(pfn, RAM_TYPE_CONVENTIONAL) )
  map = !iommu_dom0_strict;
else if ( !page_is_ram_type(pfn, RAM_TYPE_UNUSABLE) )
  map = (iommu_inclusive && pfn <= max_pfn);
else
  map = false; 

(I think that logic is correct).

  Paul

> +        if ( !map )
>              continue;
> 
>          tmp = 1 << (PAGE_SHIFT - PAGE_SHIFT_4K);
> --
> 2.18.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-07-31  7:29 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-27 15:31 [PATCH 0/4] x86/iommu: PVH Dom0 workarounds for missing RMRR/IRSV entries Roger Pau Monne
2018-07-27 15:31 ` [PATCH 1/4] iommu: remove unneeded return from iommu_hwdom_init Roger Pau Monne
2018-07-31  7:19   ` Paul Durrant
2018-07-27 15:31 ` [PATCH 2/4] iommu: generalize iommu_inclusive_mapping Roger Pau Monne
2018-07-31  7:18   ` Paul Durrant
2018-07-31  8:16     ` Roger Pau Monné
2018-07-31  8:27       ` Paul Durrant
2018-07-31  8:33         ` Roger Pau Monné
2018-07-31  8:37           ` Paul Durrant
2018-07-31  8:49             ` Jan Beulich
2018-07-31  9:05               ` Roger Pau Monné
2018-07-31  9:14                 ` Jan Beulich
2018-07-31  9:34                   ` Roger Pau Monné
2018-07-31  9:37                     ` Paul Durrant
2018-07-31  9:41                     ` Jan Beulich
2018-07-31  9:45                       ` Paul Durrant
2018-07-31  8:45         ` Jan Beulich
2018-07-31 14:39   ` Jan Beulich
2018-07-31 15:33     ` Roger Pau Monné
2018-08-01  8:20       ` Jan Beulich
2018-08-01  8:32         ` Andrew Cooper
2018-08-01  9:10           ` Jan Beulich
2018-08-01  9:20             ` Andrew Cooper
2018-08-01  9:59               ` Jan Beulich
2018-08-01 10:25                 ` Andrew Cooper
2018-08-01  8:33         ` Paul Durrant
2018-08-01  9:11           ` Jan Beulich
2018-08-02  6:53           ` Tian, Kevin
2018-08-01  8:47         ` Roger Pau Monné
2018-07-27 15:31 ` [PATCH 3/4] x86/iommu: reorder conditions used in the inclusive iommu mappings Roger Pau Monne
2018-07-31  7:29   ` Paul Durrant [this message]
2018-07-31  8:26     ` Roger Pau Monné
2018-07-27 15:31 ` [PATCH 4/4] x86/iommu: add PVH support to the inclusive options Roger Pau Monne
2018-07-31  7:36   ` Paul Durrant
2018-07-31  8:28     ` Roger Pau Monné
2018-07-31 14:52   ` Jan Beulich
2018-07-31 15:15     ` Roger Pau Monné
2018-07-31 15:27       ` Roger Pau Monné
2018-07-31 15:34         ` Jan Beulich
2018-07-31 15:33       ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3054fb6d40b94040804ee44d7dbc77dc@AMSPEX02CL03.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).