[XEN][PATCH 6/8] xen/arm64: constify is_32/64bit_domain() macro for CONFIG_ARM64_AARCH32=n

Grygorii Strashko posted 8 patches 3 months, 1 week ago
[XEN][PATCH 6/8] xen/arm64: constify is_32/64bit_domain() macro for CONFIG_ARM64_AARCH32=n
Posted by Grygorii Strashko 3 months, 1 week ago
From: Grygorii Strashko <grygorii_strashko@epam.com>

Constify is_32/64bit_domain() macro for the case CONFIG_ARM64_AARCH32=n and
so allow compiler to opt out Aarch32 specific code.

(CONFIG_ARM64_AARCH32=y)
Before:
   text	   data	    bss	    dec	    hex	filename
 855232	 322404	 270880	1448516	 161a44	xen-syms

(CONFIG_ARM64_AARCH32=n, CONFIG_EXPERT=y)
After:
   text	   data	    bss	    dec	    hex	filename
 851568	 322404	 270880	1444852	 160bf4	xen-syms
diff: −3664 (dec)

Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
---
 xen/arch/arm/include/asm/arm64/domain.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/xen/arch/arm/include/asm/arm64/domain.h b/xen/arch/arm/include/asm/arm64/domain.h
index 18402ae3ca0d..a014ab9967ac 100644
--- a/xen/arch/arm/include/asm/arm64/domain.h
+++ b/xen/arch/arm/include/asm/arm64/domain.h
@@ -12,14 +12,22 @@ struct kernel_info;
  *
  * @d: pointer to the domain structure
  */
+#if defined(CONFIG_ARM64_AARCH32)
 #define is_32bit_domain(d) ((d)->arch.type == DOMAIN_32BIT)
+#else
+#define is_32bit_domain(d) (false)
+#endif /* CONFIG_ARM64_AARCH32 */
 
 /*
  * Returns true if guest execution state is AArch64
  *
  * @d: pointer to the domain structure
  */
+#if defined(CONFIG_ARM64_AARCH32)
 #define is_64bit_domain(d) ((d)->arch.type == DOMAIN_64BIT)
+#else
+#define is_64bit_domain(d) (true)
+#endif /* CONFIG_ARM64_AARCH32 */
 
 /*
  * Set guest execution state to AArch64 (EL1) for selected vcpu
-- 
2.34.1
Re: [XEN][PATCH 6/8] xen/arm64: constify is_32/64bit_domain() macro for CONFIG_ARM64_AARCH32=n
Posted by Andrew Cooper 3 months, 1 week ago
On 23/07/2025 8:58 am, Grygorii Strashko wrote:
> diff --git a/xen/arch/arm/include/asm/arm64/domain.h b/xen/arch/arm/include/asm/arm64/domain.h
> index 18402ae3ca0d..a014ab9967ac 100644
> --- a/xen/arch/arm/include/asm/arm64/domain.h
> +++ b/xen/arch/arm/include/asm/arm64/domain.h
> @@ -12,14 +12,22 @@ struct kernel_info;
>   *
>   * @d: pointer to the domain structure
>   */
> +#if defined(CONFIG_ARM64_AARCH32)
>  #define is_32bit_domain(d) ((d)->arch.type == DOMAIN_32BIT)
> +#else
> +#define is_32bit_domain(d) (false)
> +#endif /* CONFIG_ARM64_AARCH32 */

There's no need to make two separate definitions.  Use IS_ENABLED(). 
(This also fixes the evaluation of d problem you've introduced.)

IS_ENABLED(CONFIG_ARM64_AARCH32) && (d)->arch.type == DOMAIN_32BIT

>  
>  /*
>   * Returns true if guest execution state is AArch64
>   *
>   * @d: pointer to the domain structure
>   */
> +#if defined(CONFIG_ARM64_AARCH32)
>  #define is_64bit_domain(d) ((d)->arch.type == DOMAIN_64BIT)
> +#else
> +#define is_64bit_domain(d) (true)
> +#endif /* CONFIG_ARM64_AARCH32 */

!IS_ENABLED(CONFIG_ARM64_AARCH32) || (d)->arch.type == DOMAIN_64BIT

~Andrew