Re: [PATCH 5/5] KVM: arm64: Define KVM_PHYS_SHIFT_MIN
On 2021-08-10 16:19, Anshuman Khandual wrote: On 8/10/21 6:59 PM, Marc Zyngier wrote: On 2021-08-10 08:02, Anshuman Khandual wrote: Drop the hard coded value for the minimum IPA range i.e 32 bit. Instead define a macro KVM_PHYS_SHIFT_MIN which improves the code readability. Cc: Marc Zyngier Cc: James Morse Cc: Alexandru Elisei Cc: Suzuki K Poulose Cc: Catalin Marinas Cc: Will Deacon Cc: linux-arm-ker...@lists.infradead.org Cc: kvmarm@lists.cs.columbia.edu Cc: linux-ker...@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/arm64/include/asm/kvm_mmu.h | 3 ++- arch/arm64/kvm/reset.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index b52c5c4b9a3d..716f999818d9 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -141,7 +141,8 @@ static __always_inline unsigned long __kern_hyp_va(unsigned long v) * We currently support using a VM-specified IPA size. For backward * compatibility, the default IPA size is fixed to 40bits. */ -#define KVM_PHYS_SHIFT (40) +#define KVM_PHYS_SHIFT (40) +#define KVM_PHYS_SHIFT_MIN (32) #define kvm_phys_shift(kvm) VTCR_EL2_IPA(kvm->arch.vtcr) #define kvm_phys_size(kvm) (_AC(1, ULL) << kvm_phys_shift(kvm)) diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index cba7872d69a8..8dc8b4b9de37 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -369,7 +369,7 @@ int kvm_arm_setup_stage2(struct kvm *kvm, unsigned long type) phys_shift = KVM_VM_TYPE_ARM_IPA_SIZE(type); if (phys_shift) { if (phys_shift > kvm_ipa_limit || - phys_shift < 32) + phys_shift < KVM_PHYS_SHIFT_MIN) return -EINVAL; } else { phys_shift = KVM_PHYS_SHIFT; This is not a KVM property, but an architectural one. If you Architectural property which suggest the minimum physical address shift supported on a platform, as indicated via ID_AA64MMFR0.PARANGE = 0x0 ? That's the one. M. -- Jazz is not dead. It just smells funny... ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 5/5] KVM: arm64: Define KVM_PHYS_SHIFT_MIN
On 8/10/21 6:59 PM, Marc Zyngier wrote: > On 2021-08-10 08:02, Anshuman Khandual wrote: >> Drop the hard coded value for the minimum IPA range i.e 32 bit. Instead >> define a macro KVM_PHYS_SHIFT_MIN which improves the code readability. >> >> Cc: Marc Zyngier >> Cc: James Morse >> Cc: Alexandru Elisei >> Cc: Suzuki K Poulose >> Cc: Catalin Marinas >> Cc: Will Deacon >> Cc: linux-arm-ker...@lists.infradead.org >> Cc: kvmarm@lists.cs.columbia.edu >> Cc: linux-ker...@vger.kernel.org >> Signed-off-by: Anshuman Khandual >> --- >> arch/arm64/include/asm/kvm_mmu.h | 3 ++- >> arch/arm64/kvm/reset.c | 2 +- >> 2 files changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/arch/arm64/include/asm/kvm_mmu.h >> b/arch/arm64/include/asm/kvm_mmu.h >> index b52c5c4b9a3d..716f999818d9 100644 >> --- a/arch/arm64/include/asm/kvm_mmu.h >> +++ b/arch/arm64/include/asm/kvm_mmu.h >> @@ -141,7 +141,8 @@ static __always_inline unsigned long >> __kern_hyp_va(unsigned long v) >> * We currently support using a VM-specified IPA size. For backward >> * compatibility, the default IPA size is fixed to 40bits. >> */ >> -#define KVM_PHYS_SHIFT (40) >> +#define KVM_PHYS_SHIFT (40) >> +#define KVM_PHYS_SHIFT_MIN (32) >> >> #define kvm_phys_shift(kvm) VTCR_EL2_IPA(kvm->arch.vtcr) >> #define kvm_phys_size(kvm) (_AC(1, ULL) << kvm_phys_shift(kvm)) >> diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c >> index cba7872d69a8..8dc8b4b9de37 100644 >> --- a/arch/arm64/kvm/reset.c >> +++ b/arch/arm64/kvm/reset.c >> @@ -369,7 +369,7 @@ int kvm_arm_setup_stage2(struct kvm *kvm, unsigned >> long type) >> phys_shift = KVM_VM_TYPE_ARM_IPA_SIZE(type); >> if (phys_shift) { >> if (phys_shift > kvm_ipa_limit || >> - phys_shift < 32) >> + phys_shift < KVM_PHYS_SHIFT_MIN) >> return -EINVAL; >> } else { >> phys_shift = KVM_PHYS_SHIFT; > > This is not a KVM property, but an architectural one. If you Architectural property which suggest the minimum physical address shift supported on a platform, as indicated via ID_AA64MMFR0.PARANGE = 0x0 ? > want to replace it with something more readable, please > make it global to the whole of arm64 (ARM64_MIN_PARANGE?). Sure, will do. ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 5/5] KVM: arm64: Define KVM_PHYS_SHIFT_MIN
On 2021-08-10 08:02, Anshuman Khandual wrote: Drop the hard coded value for the minimum IPA range i.e 32 bit. Instead define a macro KVM_PHYS_SHIFT_MIN which improves the code readability. Cc: Marc Zyngier Cc: James Morse Cc: Alexandru Elisei Cc: Suzuki K Poulose Cc: Catalin Marinas Cc: Will Deacon Cc: linux-arm-ker...@lists.infradead.org Cc: kvmarm@lists.cs.columbia.edu Cc: linux-ker...@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/arm64/include/asm/kvm_mmu.h | 3 ++- arch/arm64/kvm/reset.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index b52c5c4b9a3d..716f999818d9 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -141,7 +141,8 @@ static __always_inline unsigned long __kern_hyp_va(unsigned long v) * We currently support using a VM-specified IPA size. For backward * compatibility, the default IPA size is fixed to 40bits. */ -#define KVM_PHYS_SHIFT (40) +#define KVM_PHYS_SHIFT (40) +#define KVM_PHYS_SHIFT_MIN (32) #define kvm_phys_shift(kvm)VTCR_EL2_IPA(kvm->arch.vtcr) #define kvm_phys_size(kvm) (_AC(1, ULL) << kvm_phys_shift(kvm)) diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index cba7872d69a8..8dc8b4b9de37 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -369,7 +369,7 @@ int kvm_arm_setup_stage2(struct kvm *kvm, unsigned long type) phys_shift = KVM_VM_TYPE_ARM_IPA_SIZE(type); if (phys_shift) { if (phys_shift > kvm_ipa_limit || - phys_shift < 32) + phys_shift < KVM_PHYS_SHIFT_MIN) return -EINVAL; } else { phys_shift = KVM_PHYS_SHIFT; This is not a KVM property, but an architectural one. If you want to replace it with something more readable, please make it global to the whole of arm64 (ARM64_MIN_PARANGE?). Thanks, M. -- Jazz is not dead. It just smells funny... ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
[PATCH 5/5] KVM: arm64: Define KVM_PHYS_SHIFT_MIN
Drop the hard coded value for the minimum IPA range i.e 32 bit. Instead define a macro KVM_PHYS_SHIFT_MIN which improves the code readability. Cc: Marc Zyngier Cc: James Morse Cc: Alexandru Elisei Cc: Suzuki K Poulose Cc: Catalin Marinas Cc: Will Deacon Cc: linux-arm-ker...@lists.infradead.org Cc: kvmarm@lists.cs.columbia.edu Cc: linux-ker...@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/arm64/include/asm/kvm_mmu.h | 3 ++- arch/arm64/kvm/reset.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index b52c5c4b9a3d..716f999818d9 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -141,7 +141,8 @@ static __always_inline unsigned long __kern_hyp_va(unsigned long v) * We currently support using a VM-specified IPA size. For backward * compatibility, the default IPA size is fixed to 40bits. */ -#define KVM_PHYS_SHIFT (40) +#define KVM_PHYS_SHIFT (40) +#define KVM_PHYS_SHIFT_MIN (32) #define kvm_phys_shift(kvm)VTCR_EL2_IPA(kvm->arch.vtcr) #define kvm_phys_size(kvm) (_AC(1, ULL) << kvm_phys_shift(kvm)) diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index cba7872d69a8..8dc8b4b9de37 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -369,7 +369,7 @@ int kvm_arm_setup_stage2(struct kvm *kvm, unsigned long type) phys_shift = KVM_VM_TYPE_ARM_IPA_SIZE(type); if (phys_shift) { if (phys_shift > kvm_ipa_limit || - phys_shift < 32) + phys_shift < KVM_PHYS_SHIFT_MIN) return -EINVAL; } else { phys_shift = KVM_PHYS_SHIFT; -- 2.20.1 ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm