diff mbox series

[v8,5/6] iommu: tidy up iommu_use_hap_pt() and need_iommu_pt_sync() macros

Message ID 20190902145014.36442-6-paul.durrant@citrix.com (mailing list archive)
State Superseded
Headers show
Series add per-domain IOMMU control | expand

Commit Message

Paul Durrant Sept. 2, 2019, 2:50 p.m. UTC
Thes macros really ought to live in the common xen/iommu.h header rather
then being distributed amongst architecture specific iommu headers and
xen/sched.h. This patch moves them there.

NOTE: Disabling 'sharept' in the command line iommu options should really
      be hard error on ARM (as opposed to just being ignored), so define
      'iommu_hap_pt_share' to be true for ARM then then gate parsing the
      command line option on '#ifndef iommu_hap_pt_share'.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wl@xen.org>
Cc: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>

Previously part of https://lists.xenproject.org/archives/html/xen-devel/2019-07/msg02267.html

v7:
 - Re-work the ARM handling of 'sharept' as suggested by Jan
 - Make sure that need_iommu_pt_sync() always evaluates its argument
---
 xen/drivers/passthrough/iommu.c |  8 +++++++-
 xen/include/asm-arm/iommu.h     |  3 ---
 xen/include/asm-x86/iommu.h     |  4 ----
 xen/include/xen/iommu.h         | 19 ++++++++++++++++++-
 xen/include/xen/sched.h         |  6 ------
 5 files changed, 25 insertions(+), 15 deletions(-)

Comments

Julien Grall Sept. 5, 2019, 7:38 p.m. UTC | #1
Hi Paul,

On 9/2/19 3:50 PM, Paul Durrant wrote:
> Thes macros really ought to live in the common xen/iommu.h header rather
> then being distributed amongst architecture specific iommu headers and
> xen/sched.h. This patch moves them there.
> 
> NOTE: Disabling 'sharept' in the command line iommu options should really
>        be hard error on ARM (as opposed to just being ignored), so define
>        'iommu_hap_pt_share' to be true for ARM then then gate parsing the
>        command line option on '#ifndef iommu_hap_pt_share'.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> ---
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: George Dunlap <George.Dunlap@eu.citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Julien Grall <julien.grall@arm.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Tim Deegan <tim@xen.org>
> Cc: Wei Liu <wl@xen.org>
> Cc: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
> Cc: "Roger Pau Monné" <roger.pau@citrix.com>
> 
> Previously part of https://lists.xenproject.org/archives/html/xen-devel/2019-07/msg02267.html
> 
> v7:
>   - Re-work the ARM handling of 'sharept' as suggested by Jan
>   - Make sure that need_iommu_pt_sync() always evaluates its argument
> ---
>   xen/drivers/passthrough/iommu.c |  8 +++++++-
>   xen/include/asm-arm/iommu.h     |  3 ---
>   xen/include/asm-x86/iommu.h     |  4 ----
>   xen/include/xen/iommu.h         | 19 ++++++++++++++++++-
>   xen/include/xen/sched.h         |  6 ------
>   5 files changed, 25 insertions(+), 15 deletions(-)
> 
> diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
> index 4f71db95ea..aaf3b9fac0 100644
> --- a/xen/drivers/passthrough/iommu.c
> +++ b/xen/drivers/passthrough/iommu.c
> @@ -49,7 +49,11 @@ int8_t __hwdom_initdata iommu_hwdom_reserved = -1;
>    * default until we find a good solution to resolve it.
>    */
>   bool_t __read_mostly iommu_intpost;
> -bool_t __read_mostly iommu_hap_pt_share = 1;
> +
> +#ifndef iommu_hap_pt_share
> +bool __read_mostly iommu_hap_pt_share = true;
> +#endif
> +
>   bool_t __read_mostly iommu_debug;
>   bool_t __read_mostly amd_iommu_perdev_intremap = 1;
>   
> @@ -102,8 +106,10 @@ static int __init parse_iommu_param(const char *s)
>               iommu_hwdom_passthrough = val;
>           else if ( (val = parse_boolean("dom0-strict", s, ss)) >= 0 )
>               iommu_hwdom_strict = val;
> +#ifndef iommu_hap_pt_share
>           else if ( (val = parse_boolean("sharept", s, ss)) >= 0 )
>               iommu_hap_pt_share = val;
> +#endif
>           else
>               rc = -EINVAL;
>   
> diff --git a/xen/include/asm-arm/iommu.h b/xen/include/asm-arm/iommu.h
> index 1577e83d2b..77a94b29eb 100644
> --- a/xen/include/asm-arm/iommu.h
> +++ b/xen/include/asm-arm/iommu.h
> @@ -20,9 +20,6 @@ struct arch_iommu
>       void *priv;
>   };
>   
> -/* Always share P2M Table between the CPU and the IOMMU */
> -#define iommu_use_hap_pt(d) is_iommu_enabled(d)
> -
>   const struct iommu_ops *iommu_get_ops(void);
>   void iommu_set_ops(const struct iommu_ops *ops);
>   
> diff --git a/xen/include/asm-x86/iommu.h b/xen/include/asm-x86/iommu.h
> index 5071afd6a5..85741f7c96 100644
> --- a/xen/include/asm-x86/iommu.h
> +++ b/xen/include/asm-x86/iommu.h
> @@ -86,10 +86,6 @@ struct iommu_init_ops {
>   
>   extern const struct iommu_init_ops *iommu_init_ops;
>   
> -/* Are we using the domain P2M table as its IOMMU pagetable? */
> -#define iommu_use_hap_pt(d) \
> -    (hap_enabled(d) && is_iommu_enabled(d) && iommu_hap_pt_share)
> -
>   void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value);
>   unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg);
>   int iommu_setup_hpet_msi(struct msi_desc *);
> diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
> index 4b6871936c..87f9129b99 100644
> --- a/xen/include/xen/iommu.h
> +++ b/xen/include/xen/iommu.h
> @@ -55,7 +55,13 @@ static inline bool_t dfn_eq(dfn_t x, dfn_t y)
>   extern bool_t iommu_enable, iommu_enabled;
>   extern bool_t force_iommu, iommu_verbose, iommu_igfx;
>   extern bool_t iommu_snoop, iommu_qinval, iommu_intremap, iommu_intpost;
> -extern bool_t iommu_hap_pt_share;
> +
> +#ifdef CONFIG_ARM
> +#define iommu_hap_pt_share true
> +#else
> +extern bool iommu_hap_pt_share;
> +#endif

I don't particularly like #ifdef CONFIG_<ARCH> in common header. How 
about other arch? I can see two solutions:

1) Move the define in asm/iommu.h. This would require to move the 
declaration a bit later and then protect as you did in iommu.c
2) Replace CONFIG_ARM with a new Kconfig selected by Arm only so far.

Cheers,
Paul Durrant Sept. 6, 2019, 7:59 a.m. UTC | #2
> -----Original Message-----
> From: Julien Grall <julien.grall@arm.com>
> Sent: 05 September 2019 20:38
> To: Paul Durrant <Paul.Durrant@citrix.com>; xen-devel@lists.xenproject.org
> Cc: Jan Beulich <jbeulich@suse.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; George Dunlap
> <George.Dunlap@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Konrad Rzeszutek Wilk
> <konrad.wilk@oracle.com>; Stefano Stabellini <sstabellini@kernel.org>; Tim (Xen.org) <tim@xen.org>;
> Wei Liu <wl@xen.org>; Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>; Roger Pau Monne
> <roger.pau@citrix.com>
> Subject: Re: [PATCH v8 5/6] iommu: tidy up iommu_use_hap_pt() and need_iommu_pt_sync() macros
> 
> Hi Paul,
> 
> On 9/2/19 3:50 PM, Paul Durrant wrote:
> > Thes macros really ought to live in the common xen/iommu.h header rather
> > then being distributed amongst architecture specific iommu headers and
> > xen/sched.h. This patch moves them there.
> >
> > NOTE: Disabling 'sharept' in the command line iommu options should really
> >        be hard error on ARM (as opposed to just being ignored), so define
> >        'iommu_hap_pt_share' to be true for ARM then then gate parsing the
> >        command line option on '#ifndef iommu_hap_pt_share'.
> >
> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > Reviewed-by: Jan Beulich <jbeulich@suse.com>
> > ---
> > Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> > Cc: George Dunlap <George.Dunlap@eu.citrix.com>
> > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > Cc: Julien Grall <julien.grall@arm.com>
> > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: Tim Deegan <tim@xen.org>
> > Cc: Wei Liu <wl@xen.org>
> > Cc: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
> > Cc: "Roger Pau Monné" <roger.pau@citrix.com>
> >
> > Previously part of https://lists.xenproject.org/archives/html/xen-devel/2019-07/msg02267.html
> >
> > v7:
> >   - Re-work the ARM handling of 'sharept' as suggested by Jan
> >   - Make sure that need_iommu_pt_sync() always evaluates its argument
> > ---
> >   xen/drivers/passthrough/iommu.c |  8 +++++++-
> >   xen/include/asm-arm/iommu.h     |  3 ---
> >   xen/include/asm-x86/iommu.h     |  4 ----
> >   xen/include/xen/iommu.h         | 19 ++++++++++++++++++-
> >   xen/include/xen/sched.h         |  6 ------
> >   5 files changed, 25 insertions(+), 15 deletions(-)
> >
> > diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
> > index 4f71db95ea..aaf3b9fac0 100644
> > --- a/xen/drivers/passthrough/iommu.c
> > +++ b/xen/drivers/passthrough/iommu.c
> > @@ -49,7 +49,11 @@ int8_t __hwdom_initdata iommu_hwdom_reserved = -1;
> >    * default until we find a good solution to resolve it.
> >    */
> >   bool_t __read_mostly iommu_intpost;
> > -bool_t __read_mostly iommu_hap_pt_share = 1;
> > +
> > +#ifndef iommu_hap_pt_share
> > +bool __read_mostly iommu_hap_pt_share = true;
> > +#endif
> > +
> >   bool_t __read_mostly iommu_debug;
> >   bool_t __read_mostly amd_iommu_perdev_intremap = 1;
> >
> > @@ -102,8 +106,10 @@ static int __init parse_iommu_param(const char *s)
> >               iommu_hwdom_passthrough = val;
> >           else if ( (val = parse_boolean("dom0-strict", s, ss)) >= 0 )
> >               iommu_hwdom_strict = val;
> > +#ifndef iommu_hap_pt_share
> >           else if ( (val = parse_boolean("sharept", s, ss)) >= 0 )
> >               iommu_hap_pt_share = val;
> > +#endif
> >           else
> >               rc = -EINVAL;
> >
> > diff --git a/xen/include/asm-arm/iommu.h b/xen/include/asm-arm/iommu.h
> > index 1577e83d2b..77a94b29eb 100644
> > --- a/xen/include/asm-arm/iommu.h
> > +++ b/xen/include/asm-arm/iommu.h
> > @@ -20,9 +20,6 @@ struct arch_iommu
> >       void *priv;
> >   };
> >
> > -/* Always share P2M Table between the CPU and the IOMMU */
> > -#define iommu_use_hap_pt(d) is_iommu_enabled(d)
> > -
> >   const struct iommu_ops *iommu_get_ops(void);
> >   void iommu_set_ops(const struct iommu_ops *ops);
> >
> > diff --git a/xen/include/asm-x86/iommu.h b/xen/include/asm-x86/iommu.h
> > index 5071afd6a5..85741f7c96 100644
> > --- a/xen/include/asm-x86/iommu.h
> > +++ b/xen/include/asm-x86/iommu.h
> > @@ -86,10 +86,6 @@ struct iommu_init_ops {
> >
> >   extern const struct iommu_init_ops *iommu_init_ops;
> >
> > -/* Are we using the domain P2M table as its IOMMU pagetable? */
> > -#define iommu_use_hap_pt(d) \
> > -    (hap_enabled(d) && is_iommu_enabled(d) && iommu_hap_pt_share)
> > -
> >   void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value);
> >   unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg);
> >   int iommu_setup_hpet_msi(struct msi_desc *);
> > diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
> > index 4b6871936c..87f9129b99 100644
> > --- a/xen/include/xen/iommu.h
> > +++ b/xen/include/xen/iommu.h
> > @@ -55,7 +55,13 @@ static inline bool_t dfn_eq(dfn_t x, dfn_t y)
> >   extern bool_t iommu_enable, iommu_enabled;
> >   extern bool_t force_iommu, iommu_verbose, iommu_igfx;
> >   extern bool_t iommu_snoop, iommu_qinval, iommu_intremap, iommu_intpost;
> > -extern bool_t iommu_hap_pt_share;
> > +
> > +#ifdef CONFIG_ARM
> > +#define iommu_hap_pt_share true
> > +#else
> > +extern bool iommu_hap_pt_share;
> > +#endif
> 
> I don't particularly like #ifdef CONFIG_<ARCH> in common header. How
> about other arch? I can see two solutions:
> 
> 1) Move the define in asm/iommu.h. This would require to move the
> declaration a bit later and then protect as you did in iommu.c
> 2) Replace CONFIG_ARM with a new Kconfig selected by Arm only so far.
> 

I had wondered about a Kconfig but I can't really think of a good name. How about CONFIG_FORCE_PT_SHARE?

  Paul

> Cheers,
> 
> --
> Julien Grall
Julien Grall Sept. 6, 2019, 8:48 a.m. UTC | #3
Hi Paul,

On 9/6/19 8:59 AM, Paul Durrant wrote:
>> -----Original Message-----
>> From: Julien Grall <julien.grall@arm.com>
>> Sent: 05 September 2019 20:38
>> To: Paul Durrant <Paul.Durrant@citrix.com>; xen-devel@lists.xenproject.org
>> Cc: Jan Beulich <jbeulich@suse.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; George Dunlap
>> <George.Dunlap@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Konrad Rzeszutek Wilk
>> <konrad.wilk@oracle.com>; Stefano Stabellini <sstabellini@kernel.org>; Tim (Xen.org) <tim@xen.org>;
>> Wei Liu <wl@xen.org>; Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>; Roger Pau Monne
>> <roger.pau@citrix.com>
>> Subject: Re: [PATCH v8 5/6] iommu: tidy up iommu_use_hap_pt() and need_iommu_pt_sync() macros
>>
>> Hi Paul,
>>
>> On 9/2/19 3:50 PM, Paul Durrant wrote:
>>> Thes macros really ought to live in the common xen/iommu.h header rather
>>> then being distributed amongst architecture specific iommu headers and
>>> xen/sched.h. This patch moves them there.
>>>
>>> NOTE: Disabling 'sharept' in the command line iommu options should really
>>>         be hard error on ARM (as opposed to just being ignored), so define
>>>         'iommu_hap_pt_share' to be true for ARM then then gate parsing the
>>>         command line option on '#ifndef iommu_hap_pt_share'.
>>>
>>> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
>>> Reviewed-by: Jan Beulich <jbeulich@suse.com>
>>> ---
>>> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
>>> Cc: George Dunlap <George.Dunlap@eu.citrix.com>
>>> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
>>> Cc: Julien Grall <julien.grall@arm.com>
>>> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>>> Cc: Stefano Stabellini <sstabellini@kernel.org>
>>> Cc: Tim Deegan <tim@xen.org>
>>> Cc: Wei Liu <wl@xen.org>
>>> Cc: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
>>> Cc: "Roger Pau Monné" <roger.pau@citrix.com>
>>>
>>> Previously part of https://lists.xenproject.org/archives/html/xen-devel/2019-07/msg02267.html
>>>
>>> v7:
>>>    - Re-work the ARM handling of 'sharept' as suggested by Jan
>>>    - Make sure that need_iommu_pt_sync() always evaluates its argument
>>> ---
>>>    xen/drivers/passthrough/iommu.c |  8 +++++++-
>>>    xen/include/asm-arm/iommu.h     |  3 ---
>>>    xen/include/asm-x86/iommu.h     |  4 ----
>>>    xen/include/xen/iommu.h         | 19 ++++++++++++++++++-
>>>    xen/include/xen/sched.h         |  6 ------
>>>    5 files changed, 25 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
>>> index 4f71db95ea..aaf3b9fac0 100644
>>> --- a/xen/drivers/passthrough/iommu.c
>>> +++ b/xen/drivers/passthrough/iommu.c
>>> @@ -49,7 +49,11 @@ int8_t __hwdom_initdata iommu_hwdom_reserved = -1;
>>>     * default until we find a good solution to resolve it.
>>>     */
>>>    bool_t __read_mostly iommu_intpost;
>>> -bool_t __read_mostly iommu_hap_pt_share = 1;
>>> +
>>> +#ifndef iommu_hap_pt_share
>>> +bool __read_mostly iommu_hap_pt_share = true;
>>> +#endif
>>> +
>>>    bool_t __read_mostly iommu_debug;
>>>    bool_t __read_mostly amd_iommu_perdev_intremap = 1;
>>>
>>> @@ -102,8 +106,10 @@ static int __init parse_iommu_param(const char *s)
>>>                iommu_hwdom_passthrough = val;
>>>            else if ( (val = parse_boolean("dom0-strict", s, ss)) >= 0 )
>>>                iommu_hwdom_strict = val;
>>> +#ifndef iommu_hap_pt_share
>>>            else if ( (val = parse_boolean("sharept", s, ss)) >= 0 )
>>>                iommu_hap_pt_share = val;
>>> +#endif
>>>            else
>>>                rc = -EINVAL;
>>>
>>> diff --git a/xen/include/asm-arm/iommu.h b/xen/include/asm-arm/iommu.h
>>> index 1577e83d2b..77a94b29eb 100644
>>> --- a/xen/include/asm-arm/iommu.h
>>> +++ b/xen/include/asm-arm/iommu.h
>>> @@ -20,9 +20,6 @@ struct arch_iommu
>>>        void *priv;
>>>    };
>>>
>>> -/* Always share P2M Table between the CPU and the IOMMU */
>>> -#define iommu_use_hap_pt(d) is_iommu_enabled(d)
>>> -
>>>    const struct iommu_ops *iommu_get_ops(void);
>>>    void iommu_set_ops(const struct iommu_ops *ops);
>>>
>>> diff --git a/xen/include/asm-x86/iommu.h b/xen/include/asm-x86/iommu.h
>>> index 5071afd6a5..85741f7c96 100644
>>> --- a/xen/include/asm-x86/iommu.h
>>> +++ b/xen/include/asm-x86/iommu.h
>>> @@ -86,10 +86,6 @@ struct iommu_init_ops {
>>>
>>>    extern const struct iommu_init_ops *iommu_init_ops;
>>>
>>> -/* Are we using the domain P2M table as its IOMMU pagetable? */
>>> -#define iommu_use_hap_pt(d) \
>>> -    (hap_enabled(d) && is_iommu_enabled(d) && iommu_hap_pt_share)
>>> -
>>>    void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value);
>>>    unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg);
>>>    int iommu_setup_hpet_msi(struct msi_desc *);
>>> diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
>>> index 4b6871936c..87f9129b99 100644
>>> --- a/xen/include/xen/iommu.h
>>> +++ b/xen/include/xen/iommu.h
>>> @@ -55,7 +55,13 @@ static inline bool_t dfn_eq(dfn_t x, dfn_t y)
>>>    extern bool_t iommu_enable, iommu_enabled;
>>>    extern bool_t force_iommu, iommu_verbose, iommu_igfx;
>>>    extern bool_t iommu_snoop, iommu_qinval, iommu_intremap, iommu_intpost;
>>> -extern bool_t iommu_hap_pt_share;
>>> +
>>> +#ifdef CONFIG_ARM
>>> +#define iommu_hap_pt_share true
>>> +#else
>>> +extern bool iommu_hap_pt_share;
>>> +#endif
>>
>> I don't particularly like #ifdef CONFIG_<ARCH> in common header. How
>> about other arch? I can see two solutions:
>>
>> 1) Move the define in asm/iommu.h. This would require to move the
>> declaration a bit later and then protect as you did in iommu.c
>> 2) Replace CONFIG_ARM with a new Kconfig selected by Arm only so far.
>>
> 
> I had wondered about a Kconfig but I can't really think of a good name. How about CONFIG_FORCE_PT_SHARE?

I would add "IOMMU" in the name just to make clear this is related to 
IOMMU. So maybe CONFIG_IOMMU_FORCE_PT_SHARE.

Cheers,
diff mbox series

Patch

diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index 4f71db95ea..aaf3b9fac0 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -49,7 +49,11 @@  int8_t __hwdom_initdata iommu_hwdom_reserved = -1;
  * default until we find a good solution to resolve it.
  */
 bool_t __read_mostly iommu_intpost;
-bool_t __read_mostly iommu_hap_pt_share = 1;
+
+#ifndef iommu_hap_pt_share
+bool __read_mostly iommu_hap_pt_share = true;
+#endif
+
 bool_t __read_mostly iommu_debug;
 bool_t __read_mostly amd_iommu_perdev_intremap = 1;
 
@@ -102,8 +106,10 @@  static int __init parse_iommu_param(const char *s)
             iommu_hwdom_passthrough = val;
         else if ( (val = parse_boolean("dom0-strict", s, ss)) >= 0 )
             iommu_hwdom_strict = val;
+#ifndef iommu_hap_pt_share
         else if ( (val = parse_boolean("sharept", s, ss)) >= 0 )
             iommu_hap_pt_share = val;
+#endif
         else
             rc = -EINVAL;
 
diff --git a/xen/include/asm-arm/iommu.h b/xen/include/asm-arm/iommu.h
index 1577e83d2b..77a94b29eb 100644
--- a/xen/include/asm-arm/iommu.h
+++ b/xen/include/asm-arm/iommu.h
@@ -20,9 +20,6 @@  struct arch_iommu
     void *priv;
 };
 
-/* Always share P2M Table between the CPU and the IOMMU */
-#define iommu_use_hap_pt(d) is_iommu_enabled(d)
-
 const struct iommu_ops *iommu_get_ops(void);
 void iommu_set_ops(const struct iommu_ops *ops);
 
diff --git a/xen/include/asm-x86/iommu.h b/xen/include/asm-x86/iommu.h
index 5071afd6a5..85741f7c96 100644
--- a/xen/include/asm-x86/iommu.h
+++ b/xen/include/asm-x86/iommu.h
@@ -86,10 +86,6 @@  struct iommu_init_ops {
 
 extern const struct iommu_init_ops *iommu_init_ops;
 
-/* Are we using the domain P2M table as its IOMMU pagetable? */
-#define iommu_use_hap_pt(d) \
-    (hap_enabled(d) && is_iommu_enabled(d) && iommu_hap_pt_share)
-
 void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value);
 unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg);
 int iommu_setup_hpet_msi(struct msi_desc *);
diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
index 4b6871936c..87f9129b99 100644
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -55,7 +55,13 @@  static inline bool_t dfn_eq(dfn_t x, dfn_t y)
 extern bool_t iommu_enable, iommu_enabled;
 extern bool_t force_iommu, iommu_verbose, iommu_igfx;
 extern bool_t iommu_snoop, iommu_qinval, iommu_intremap, iommu_intpost;
-extern bool_t iommu_hap_pt_share;
+
+#ifdef CONFIG_ARM
+#define iommu_hap_pt_share true
+#else
+extern bool iommu_hap_pt_share;
+#endif
+
 extern bool_t iommu_debug;
 extern bool_t amd_iommu_perdev_intremap;
 
@@ -268,6 +274,17 @@  struct domain_iommu {
 #define iommu_set_feature(d, f)   set_bit(f, dom_iommu(d)->features)
 #define iommu_clear_feature(d, f) clear_bit(f, dom_iommu(d)->features)
 
+/* Are we using the domain P2M table as its IOMMU pagetable? */
+#define iommu_use_hap_pt(d) \
+    (hap_enabled(d) && is_iommu_enabled(d) && iommu_hap_pt_share)
+
+/* Does the IOMMU pagetable need to be kept synchronized with the P2M */
+#ifdef CONFIG_HAS_PASSTHROUGH
+#define need_iommu_pt_sync(d)     (dom_iommu(d)->need_sync)
+#else
+#define need_iommu_pt_sync(d)     ({ (void)(d); false; })
+#endif
+
 int __must_check iommu_suspend(void);
 void iommu_resume(void);
 void iommu_crash_shutdown(void);
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 3f8ad56655..0b5c106a37 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -965,12 +965,6 @@  static inline bool is_hwdom_pinned_vcpu(const struct vcpu *v)
             cpumask_weight(v->cpu_hard_affinity) == 1);
 }
 
-#ifdef CONFIG_HAS_PASSTHROUGH
-#define need_iommu_pt_sync(d) (dom_iommu(d)->need_sync)
-#else
-#define need_iommu_pt_sync(d) false
-#endif
-
 static inline bool is_vcpu_online(const struct vcpu *v)
 {
     return !test_bit(_VPF_down, &v->pause_flags);