From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88ACDC4338F for ; Tue, 10 Aug 2021 15:18:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A24960527 for ; Tue, 10 Aug 2021 15:18:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241560AbhHJPTM (ORCPT ); Tue, 10 Aug 2021 11:19:12 -0400 Received: from foss.arm.com ([217.140.110.172]:57866 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239937AbhHJPTL (ORCPT ); Tue, 10 Aug 2021 11:19:11 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F14001FB; Tue, 10 Aug 2021 08:18:48 -0700 (PDT) Received: from [10.163.67.89] (unknown [10.163.67.89]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA9403F718; Tue, 10 Aug 2021 08:18:45 -0700 (PDT) Subject: Re: [PATCH 5/5] KVM: arm64: Define KVM_PHYS_SHIFT_MIN To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org References: <1628578961-29097-1-git-send-email-anshuman.khandual@arm.com> <1628578961-29097-6-git-send-email-anshuman.khandual@arm.com> <2dbeb2c329cfeb1ee9a7331683cdbc97@kernel.org> From: Anshuman Khandual Message-ID: <43c5ffa3-b3c5-9154-72b5-811eeb9ece8f@arm.com> Date: Tue, 10 Aug 2021 20:49:38 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <2dbeb2c329cfeb1ee9a7331683cdbc97@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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-kernel@lists.infradead.org >> Cc: kvmarm@lists.cs.columbia.edu >> Cc: linux-kernel@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.