arch/arm64/kvm/ptdump.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
The attribute masks and test values in the ptdump code are meant for
individual attributes, however for stage-2 ptdump we included PTE_VALID
while testing for R, W, X, and AF. This led to some confusion and the
flipped output for the executable attribute.
Remove PTE_VALID from all attribute masks and values so that each test
matches only the relevant bits.
Additionally, the executable attribute printing is updated to align with
stage-1 ptdump, printing "NX" for non-executable regions and "x " for
executable ones.
Suggested-by: Anshuman Khandual <anshuman.khandual@arm.com>
Suggested-by: Mark Rutland <mark.rutland@arm.com>
Suggested-by: Sebastian Ene <sebastianene@google.com>
Signed-off-by: Wei-Lin Chang <r09922117@csie.ntu.edu.tw>
---
Tested on QEMU.
Changes in v2, thanks to those listed in the Suggested-by tags:
- remove PTE_VALID from .mask and .val
- make executable attribute output format identical to stage-1 ptdump
- Link to v1: https://lore.kernel.org/kvmarm/20250802104021.3076621-1-r09922117@csie.ntu.edu.tw/
---
arch/arm64/kvm/ptdump.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/arch/arm64/kvm/ptdump.c b/arch/arm64/kvm/ptdump.c
index 098416d7e5c25..dc5acfb00af91 100644
--- a/arch/arm64/kvm/ptdump.c
+++ b/arch/arm64/kvm/ptdump.c
@@ -32,23 +32,23 @@ static const struct ptdump_prot_bits stage2_pte_bits[] = {
.set = " ",
.clear = "F",
}, {
- .mask = KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R | PTE_VALID,
- .val = KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R | PTE_VALID,
+ .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 | PTE_VALID,
- .val = KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W | PTE_VALID,
+ .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 | PTE_VALID,
- .val = PTE_VALID,
- .set = " ",
- .clear = "X",
+ .mask = KVM_PTE_LEAF_ATTR_HI_S2_XN,
+ .val = KVM_PTE_LEAF_ATTR_HI_S2_XN,
+ .set = "NX",
+ .clear = "x ",
}, {
- .mask = KVM_PTE_LEAF_ATTR_LO_S2_AF | PTE_VALID,
- .val = KVM_PTE_LEAF_ATTR_LO_S2_AF | PTE_VALID,
+ .mask = KVM_PTE_LEAF_ATTR_LO_S2_AF,
+ .val = KVM_PTE_LEAF_ATTR_LO_S2_AF,
.set = "AF",
.clear = " ",
}, {
--
2.50.1
On Sat, 09 Aug 2025 21:53:56 +0800, Wei-Lin Chang wrote:
> The attribute masks and test values in the ptdump code are meant for
> individual attributes, however for stage-2 ptdump we included PTE_VALID
> while testing for R, W, X, and AF. This led to some confusion and the
> flipped output for the executable attribute.
>
> Remove PTE_VALID from all attribute masks and values so that each test
> matches only the relevant bits.
>
> [...]
Applied to next, thanks!
[1/1] KVM: arm64: ptdump: Don't test PTE_VALID alongside other attributes
commit: 8673e5b22e1e114213d3ca74f415034aed45e528
Cheers,
M.
--
Without deviation from the norm, progress is not possible.
On Sat, Aug 09, 2025 at 09:53:56PM +0800, Wei-Lin Chang wrote: > The attribute masks and test values in the ptdump code are meant for > individual attributes, however for stage-2 ptdump we included PTE_VALID > while testing for R, W, X, and AF. This led to some confusion and the > flipped output for the executable attribute. > > Remove PTE_VALID from all attribute masks and values so that each test > matches only the relevant bits. > > Additionally, the executable attribute printing is updated to align with > stage-1 ptdump, printing "NX" for non-executable regions and "x " for > executable ones. > > Suggested-by: Anshuman Khandual <anshuman.khandual@arm.com> > Suggested-by: Mark Rutland <mark.rutland@arm.com> > Suggested-by: Sebastian Ene <sebastianene@google.com> > Signed-off-by: Wei-Lin Chang <r09922117@csie.ntu.edu.tw> > --- > Tested on QEMU. > > Changes in v2, thanks to those listed in the Suggested-by tags: > - remove PTE_VALID from .mask and .val > - make executable attribute output format identical to stage-1 ptdump > - Link to v1: https://lore.kernel.org/kvmarm/20250802104021.3076621-1-r09922117@csie.ntu.edu.tw/ > --- > arch/arm64/kvm/ptdump.c | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) Acked-by: Will Deacon <will@kernel.org> I assume Oliver or Marc will pick this up via the kvmarm tree. Cheers, Will
On 09/08/25 7:23 PM, Wei-Lin Chang wrote:
> The attribute masks and test values in the ptdump code are meant for
> individual attributes, however for stage-2 ptdump we included PTE_VALID
> while testing for R, W, X, and AF. This led to some confusion and the
> flipped output for the executable attribute.
>
> Remove PTE_VALID from all attribute masks and values so that each test
> matches only the relevant bits.
>
> Additionally, the executable attribute printing is updated to align with
> stage-1 ptdump, printing "NX" for non-executable regions and "x " for
> executable ones.
>
> Suggested-by: Anshuman Khandual <anshuman.khandual@arm.com>
> Suggested-by: Mark Rutland <mark.rutland@arm.com>
> Suggested-by: Sebastian Ene <sebastianene@google.com>
> Signed-off-by: Wei-Lin Chang <r09922117@csie.ntu.edu.tw>
> ---
> Tested on QEMU.
>
> Changes in v2, thanks to those listed in the Suggested-by tags:
> - remove PTE_VALID from .mask and .val
> - make executable attribute output format identical to stage-1 ptdump
> - Link to v1: https://lore.kernel.org/kvmarm/20250802104021.3076621-1-r09922117@csie.ntu.edu.tw/
> ---
> arch/arm64/kvm/ptdump.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/arch/arm64/kvm/ptdump.c b/arch/arm64/kvm/ptdump.c
> index 098416d7e5c25..dc5acfb00af91 100644
> --- a/arch/arm64/kvm/ptdump.c
> +++ b/arch/arm64/kvm/ptdump.c
> @@ -32,23 +32,23 @@ static const struct ptdump_prot_bits stage2_pte_bits[] = {
> .set = " ",
> .clear = "F",
> }, {
> - .mask = KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R | PTE_VALID,
> - .val = KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R | PTE_VALID,
> + .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 | PTE_VALID,
> - .val = KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W | PTE_VALID,
> + .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 | PTE_VALID,
> - .val = PTE_VALID,
> - .set = " ",
> - .clear = "X",
> + .mask = KVM_PTE_LEAF_ATTR_HI_S2_XN,
> + .val = KVM_PTE_LEAF_ATTR_HI_S2_XN,
> + .set = "NX",
> + .clear = "x ",
> }, {
> - .mask = KVM_PTE_LEAF_ATTR_LO_S2_AF | PTE_VALID,
> - .val = KVM_PTE_LEAF_ATTR_LO_S2_AF | PTE_VALID,
> + .mask = KVM_PTE_LEAF_ATTR_LO_S2_AF,
> + .val = KVM_PTE_LEAF_ATTR_LO_S2_AF,
> .set = "AF",
> .clear = " ",
> }, {
LGTM and consistent with Stage-1.
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
© 2016 - 2026 Red Hat, Inc.