All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Oliver Upton <oupton@kernel.org>
Cc: kvmarm@lists.linux.dev, Marc Zyngier <maz@kernel.org>,
	Joey Gouly <joey.gouly@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>
Subject: Re: [PATCH v3 04/15] KVM: arm64: Teach ptdump about FEAT_XNX permissions
Date: Tue, 25 Nov 2025 10:39:29 -0700	[thread overview]
Message-ID: <20251125173929.GA3256322@ax162> (raw)
In-Reply-To: <20251124190158.177318-5-oupton@kernel.org>

Hi Oliver,

On Mon, Nov 24, 2025 at 11:01:46AM -0800, Oliver Upton wrote:
> Although KVM doesn't make direct use of the feature, guest hypervisors
> can use FEAT_XNX which influences the permissions of the shadow stage-2.
> Update ptdump to separately print the privileged and unprivileged
> execute permissions.
> 
> Signed-off-by: Oliver Upton <oupton@kernel.org>
> ---
>  arch/arm64/kvm/ptdump.c | 35 +++++++++++++++++++++++++++--------
>  1 file changed, 27 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm64/kvm/ptdump.c b/arch/arm64/kvm/ptdump.c
> index dc5acfb00af9..bd722383d0e3 100644
> --- a/arch/arm64/kvm/ptdump.c
> +++ b/arch/arm64/kvm/ptdump.c
> @@ -31,27 +31,46 @@ static const struct ptdump_prot_bits stage2_pte_bits[] = {
>  		.val	= PTE_VALID,
>  		.set	= " ",
>  		.clear	= "F",
> -	}, {
> +	},
> +	{
>  		.mask	= KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R,
>  		.val	= KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R,
>  		.set	= "R",
>  		.clear	= " ",
> -	}, {
> +	},
> +	{
>  		.mask	= KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W,
>  		.val	= KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W,
>  		.set	= "W",
>  		.clear	= " ",
> -	}, {
> +	},
> +	{
>  		.mask	= KVM_PTE_LEAF_ATTR_HI_S2_XN,
> -		.val	= KVM_PTE_LEAF_ATTR_HI_S2_XN,
> -		.set	= "NX",
> -		.clear	= "x ",
> -	}, {
> +		.val	= FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b00),
> +		.set	= "px ux ",
> +	},
> +	{
> +		.mask	= KVM_PTE_LEAF_ATTR_HI_S2_XN,
> +		.val	= FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b01),
> +		.set	= "PXNux ",
> +	},
> +	{
> +		.mask	= KVM_PTE_LEAF_ATTR_HI_S2_XN,
> +		.val	= FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b10),
> +		.set	= "PXNUXN",
> +	},
> +	{
> +		.mask	= KVM_PTE_LEAF_ATTR_HI_S2_XN,
> +		.val	= FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b11),
> +		.set	= "px UXN",
> +	},
> +	{
>  		.mask	= KVM_PTE_LEAF_ATTR_LO_S2_AF,
>  		.val	= KVM_PTE_LEAF_ATTR_LO_S2_AF,
>  		.set	= "AF",
>  		.clear	= "  ",
> -	}, {
> +	},
> +	{
>  		.mask	= PMD_TYPE_MASK,
>  		.val	= PMD_TYPE_SECT,
>  		.set	= "BLK",
> -- 
> 2.47.3
> 

This change as commit 81e9fe5c6f25 ("KVM: arm64: Teach ptdump about
FEAT_XNX permissions") in -next does not build for me.

GCC 15.2.0

  In file included from arch/arm64/include/asm/sysreg.h:1155,
                   from arch/arm64/include/asm/memory.h:219,
                   from arch/arm64/include/asm/thread_info.h:17,
                   from include/linux/thread_info.h:60,
                   from arch/arm64/include/asm/preempt.h:5,
                   from include/linux/preempt.h:79,
                   from include/linux/spinlock.h:56,
                   from include/linux/wait.h:9,
                   from include/linux/wait_bit.h:8,
                   from include/linux/fs.h:7,
                   from include/linux/debugfs.h:15,
                   from arch/arm64/kvm/ptdump.c:9:
  include/linux/bitfield.h:114:9: error: braced-group within expression allowed only inside a function
    114 |         ({                                                              \
        |         ^
  arch/arm64/kvm/ptdump.c:49:27: note: in expansion of macro 'FIELD_PREP'
     49 |                 .val    = FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b00),
        |                           ^~~~~~~~~~
  include/linux/bitfield.h:114:9: error: braced-group within expression allowed only inside a function
    114 |         ({                                                              \
        |         ^
  arch/arm64/kvm/ptdump.c:54:27: note: in expansion of macro 'FIELD_PREP'
     54 |                 .val    = FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b01),
        |                           ^~~~~~~~~~
  include/linux/bitfield.h:114:9: error: braced-group within expression allowed only inside a function
    114 |         ({                                                              \
        |         ^
  arch/arm64/kvm/ptdump.c:59:27: note: in expansion of macro 'FIELD_PREP'
     59 |                 .val    = FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b10),
        |                           ^~~~~~~~~~
  include/linux/bitfield.h:114:9: error: braced-group within expression allowed only inside a function
    114 |         ({                                                              \
        |         ^
  arch/arm64/kvm/ptdump.c:64:27: note: in expansion of macro 'FIELD_PREP'
     64 |                 .val    = FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b11),
        |                           ^~~~~~~~~~

clang 21.1.6:

  arch/arm64/kvm/ptdump.c:49:10: error: statement expression not allowed at file scope
     49 |                 .val    = FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b00),
        |                           ^
  include/linux/bitfield.h:114:2: note: expanded from macro 'FIELD_PREP'
    114 |         ({                                                              \
        |         ^
  arch/arm64/kvm/ptdump.c:54:10: error: statement expression not allowed at file scope
     54 |                 .val    = FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b01),
        |                           ^
  include/linux/bitfield.h:114:2: note: expanded from macro 'FIELD_PREP'
    114 |         ({                                                              \
        |         ^
  arch/arm64/kvm/ptdump.c:59:10: error: statement expression not allowed at file scope
     59 |                 .val    = FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b10),
        |                           ^
  include/linux/bitfield.h:114:2: note: expanded from macro 'FIELD_PREP'
    114 |         ({                                                              \
        |         ^
  arch/arm64/kvm/ptdump.c:64:10: error: statement expression not allowed at file scope
     64 |                 .val    = FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, 0b11),
        |                           ^
  include/linux/bitfield.h:114:2: note: expanded from macro 'FIELD_PREP'
    114 |         ({                                                              \
        |         ^

Cheers,
Nathan

  reply	other threads:[~2025-11-25 17:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-24 19:01 [PATCH v3 00/15] KVM: arm64: nv: Implement FEAT_XNX and FEAT_HAF Oliver Upton
2025-11-24 19:01 ` [PATCH v3 01/15] arm64: Detect FEAT_XNX Oliver Upton
2025-11-24 19:01 ` [PATCH v3 02/15] KVM: arm64: Add support for FEAT_XNX stage-2 permissions Oliver Upton
2025-11-24 19:01 ` [PATCH v3 03/15] KVM: arm64: nv: Forward FEAT_XNX permissions to the shadow stage-2 Oliver Upton
2025-11-24 19:01 ` [PATCH v3 04/15] KVM: arm64: Teach ptdump about FEAT_XNX permissions Oliver Upton
2025-11-25 17:39   ` Nathan Chancellor [this message]
2025-11-24 19:01 ` [PATCH v3 05/15] KVM: arm64: nv: Advertise support for FEAT_XNX Oliver Upton
2025-11-24 19:01 ` [PATCH v3 06/15] KVM: arm64: Call helper for reading descriptors directly Oliver Upton
2025-11-24 19:01 ` [PATCH v3 07/15] KVM: arm64: nv: Stop passing vCPU through void ptr in S2 PTW Oliver Upton
2025-11-24 19:01 ` [PATCH v3 08/15] KVM: arm64: Handle endianness in read helper for emulated PTW Oliver Upton
2025-11-24 19:01 ` [PATCH v3 09/15] KVM: arm64: nv: Use pgtable definitions in stage-2 walk Oliver Upton
2025-11-24 19:01 ` [PATCH v3 10/15] KVM: arm64: Add helper for swapping guest descriptor Oliver Upton
2025-11-24 19:01 ` [PATCH v3 11/15] KVM: arm64: Propagate PTW errors up to AT emulation Oliver Upton
2025-11-24 19:01 ` [PATCH v3 12/15] KVM: arm64: Implement HW access flag management in stage-1 SW PTW Oliver Upton
2025-11-24 19:01 ` [PATCH v3 13/15] KVM: arm64: nv: Implement HW access flag management in stage-2 " Oliver Upton
2025-11-24 19:01 ` [PATCH v3 14/15] KVM: arm64: nv: Expose hardware access flag management to NV guests Oliver Upton
2025-11-24 19:01 ` [PATCH v3 15/15] KVM: arm64: selftests: Add test for AT emulation Oliver Upton
2026-02-28  9:43   ` Zenghui Yu
2026-03-17 12:51     ` Zenghui Yu
2025-11-24 21:25 ` [PATCH v3 00/15] KVM: arm64: nv: Implement FEAT_XNX and FEAT_HAF Marc Zyngier
2025-11-24 22:44 ` Oliver Upton

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=20251125173929.GA3256322@ax162 \
    --to=nathan@kernel.org \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=yuzenghui@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.