Received: by 10.213.65.68 with SMTP id h4csp648797imn; Tue, 27 Mar 2018 06:20:07 -0700 (PDT) X-Google-Smtp-Source: AG47ELs8KQ1HkI2Jh9Ymhr0lt5VG7rdcmr78ni7jD0HMGj9HyBlDt1Y8/hUz/gBgYpmKqABhshi/ X-Received: by 2002:a17:902:127:: with SMTP id 36-v6mr45191267plb.194.1522156807393; Tue, 27 Mar 2018 06:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522156807; cv=none; d=google.com; s=arc-20160816; b=XYx52ZhmKItfGHkAClhkwp8oh4iAnELrddFXTjJ8jU1EOx1u9kEChG9kuUfswFzxwC J7Rgku58vWhAUKEkNJvxAS4BsN6tiRvxDQhhokKRs5Cvc7ZrNDm2JP4hVWCT/ZWJZhP7 TOTvMVssI4U54CvO3IIbwlaQDBm+h5m5KQ4N0r6DU9bWx7FKPz5ziRoAmzMUFQAWwgUr 6lXqSMuN9wFhGpWyVPjdONZOhdbky6FrgD/E9Pb4e7MCr8Z9OkS7lsg/5DyJtjtnq/L8 0N+Je+Oa4bsmX3ioWCH5cIzNWYPKAowK8E9izKYg6ANXbwHYJJGu8YLrW1jjYRz94dQA YamA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=LIu5UBRRgufxb/6mCf3S0Z3XeLgedyaTpyQ/aAllbGk=; b=j92ncg5n6RhsT4W9GRWMTSOChlDKya5nOX68felMprXe4sRq3wIGaFyt8ydQsY3bN3 e/hmVtvFpeJZHBqNZLOXuFjQDMBcGPqM91Z8eM04kQuj1egPeVNVSgP6SQc9yOue9GVI S+veSfsRQQXVsbj1hGDoqaoNTJrgqIZwD/0sNx0Hfg4WZ8GjkmiYsu3X1hIw7bzxi0pP dqiP9kURrepLFaj3k2ALmK3726L1avXV/p+bsr7i98kq80VwH9sFhC2SGR6DN101KIdb +bXbgAU9r0Uk3BOMbqrva4hSRuem5HkvkLaJTTPUkruCjVqTr+6BC7K3uXKIC5mHV68L L63w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d187si934330pfc.348.2018.03.27.06.19.52; Tue, 27 Mar 2018 06:20:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752911AbeC0NQz (ORCPT + 99 others); Tue, 27 Mar 2018 09:16:55 -0400 Received: from foss.arm.com ([217.140.101.70]:55194 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752892AbeC0NQv (ORCPT ); Tue, 27 Mar 2018 09:16:51 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C5EB81435; Tue, 27 Mar 2018 06:16:50 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 288DB3F24A; Tue, 27 Mar 2018 06:16:48 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, cdall@kernel.org, marc.zyngier@arm.com, punit.agrawal@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, ard.biesheuvel@linaro.org, peter.maydell@linaro.org, kristina.martsenko@arm.com, mark.rutland@arm.com, Suzuki K Poulose Subject: [PATCH v2 17/17] kvm: arm64: Allow IPA size supported by the system Date: Tue, 27 Mar 2018 14:15:27 +0100 Message-Id: <1522156531-28348-18-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522156531-28348-1-git-send-email-suzuki.poulose@arm.com> References: <1522156531-28348-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org So far we have restricted the IPA size of the VM to the default value (40bits). Now that we can manage the IPA size per VM and support dynamic stage2 page tables, allow VMs to bigger IPA. This is done by setting the IPA limit to the one supported by the hardware and kernel. This patch also moves the check for the default IPA size support to kvm_get_ipa_limit(). Cc: Marc Zyngier Cc: Christoffer Dall Signed-off-by: Suzuki K Poulose --- arch/arm64/include/asm/kvm_host.h | 5 ----- arch/arm64/include/asm/kvm_mmu.h | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 7b0af32..ec61e08 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -402,12 +402,7 @@ int kvm_arm_vcpu_arch_has_attr(struct kvm_vcpu *vcpu, static inline void __cpu_init_stage2(void) { - u32 ps; - kvm_call_hyp(__init_stage2_translation); - ps = id_aa64mmfr0_parange_to_phys_shift(read_sysreg(id_aa64mmfr0_el1)); - WARN_ONCE(ps < 40, - "PARange is %d bits, unsupported configuration!", ps); } /* diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index e86d7f4..6c5f0be 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -414,7 +414,23 @@ static inline u64 kvm_vttbr_baddr_mask(struct kvm *kvm) static inline u32 kvm_get_ipa_limit(void) { - return KVM_PHYS_SHIFT; + unsigned int ipa_max, parange; + + parange = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1) & 0x7; + ipa_max = id_aa64mmfr0_parange_to_phys_shift(parange); + + /* Raise the limit to the default size for backward compatibility */ + if (ipa_max < KVM_PHYS_SHIFT) { + WARN_ONCE(1, + "PARange is %d bits, unsupported configuration!", + ipa_max); + ipa_max = KVM_PHYS_SHIFT; + } + + /* Clamp it to the size supported by the kernel */ + ipa_max = (ipa_max > PHYS_MASK_SHIFT) ? PHYS_MASK_SHIFT : ipa_max; + + return ipa_max; } static inline void kvm_config_stage2(struct kvm *kvm, u8 ipa_shift) -- 2.7.4