Re: [PATCH] arm64/cpufeature: Add ID_AA64MMFR0_PARANGE_MASK

From: Marc Zyngier
Date: Tue May 12 2020 - 06:40:03 EST


Anshuman,

On 2020-05-12 03:13, Anshuman Khandual wrote:
This replaces multiple open encoding (0x7) with ID_AA64MMFR0_PARANGE_MASK
thus cleaning the clutter. It modifies an existing ID_AA64MMFR0 helper and
introduces a new one i.e id_aa64mmfr0_iparange() and id_aa64mmfr0_parange()
respectively.

Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
Cc: Will Deacon <will@xxxxxxxxxx>
Cc: Marc Zyngier <maz@xxxxxxxxxx>
Cc: James Morse <james.morse@xxxxxxx>
Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: kvmarm@xxxxxxxxxxxxxxxxxxxxx

Signed-off-by: Anshuman Khandual <anshuman.khandual@xxxxxxx>
---
This applies after (https://patchwork.kernel.org/patch/11541893/).

arch/arm64/include/asm/cpufeature.h | 11 ++++++++++-
arch/arm64/kernel/cpufeature.c | 5 ++---
arch/arm64/kvm/reset.c | 9 +++++----
3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/include/asm/cpufeature.h
b/arch/arm64/include/asm/cpufeature.h
index 1291ad5a9ccb..320cfc5b6025 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -706,8 +706,17 @@ void arm64_set_ssbd_mitigation(bool state);

extern int do_emulate_mrs(struct pt_regs *regs, u32 sys_reg, u32 rt);

-static inline u32 id_aa64mmfr0_parange_to_phys_shift(int parange)
+#define ID_AA64MMFR0_PARANGE_MASK 0x7

I still disagree with this 7. Per the letter of the architecture, it
is wrong and should be 0xf, just like any other property described
in an ID register.

+
+static inline u32 id_aa64mmfr0_parange(u64 mmfr0)
{
+ return mmfr0 & ID_AA64MMFR0_PARANGE_MASK;
+}
+
+static inline u32 id_aa64mmfr0_iparange(u64 mmfr0)

There is also no such thing as an IPA range in the architecture.
Everything is PA. The only thing that actually describe an IPA
range is what KVM makes of it.

Overall, this patch confuses me more than anything else. I'd rather
you fix ID_AA64MMFR0_PARANGE_MASK to have the right value and be
done with it.

M.
--
Jazz is not dead. It just smells funny...