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=-14.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 D4360C4338F for ; Wed, 11 Aug 2021 09:36:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B279A60F22 for ; Wed, 11 Aug 2021 09:36:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236709AbhHKJhE (ORCPT ); Wed, 11 Aug 2021 05:37:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:44692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236432AbhHKJhD (ORCPT ); Wed, 11 Aug 2021 05:37:03 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 43B8E60F11; Wed, 11 Aug 2021 09:36:40 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mDkf8-004HVI-5u; Wed, 11 Aug 2021 10:36:38 +0100 Date: Wed, 11 Aug 2021 10:36:37 +0100 Message-ID: <87v94c9vbu.wl-maz@kernel.org> From: Marc Zyngier To: Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: arm64: Restrict IPA size to maximum 48 bits on 4K and 16K page size In-Reply-To: <1628657549-27584-1-git-send-email-anshuman.khandual@arm.com> References: <1628657549-27584-1-git-send-email-anshuman.khandual@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 11 Aug 2021 05:52:29 +0100, Anshuman Khandual wrote: > > Even though ID_AA64MMFR0.PARANGE reports 52 bit PA size support, it cannot > be enabled as guest IPA size on 4K or 16K page size configurations. Hence > kvm_ipa_limit must be restricted to 48 bits. This change achieves required > IPA capping. > > Before the commit c9b69a0cf0b4 ("KVM: arm64: Don't constrain maximum IPA > size based on host configuration"), the problem here would have been just > latent via PHYS_MASK_SHIFT (which earlier in turn capped kvm_ipa_limit), > which remains capped at 48 bits on 4K and 16K configs. > > 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 > Fixes: c9b69a0cf0b4 ("KVM: arm64: Don't constrain maximum IPA size based on host configuration") > Signed-off-by: Anshuman Khandual > --- > This applies on v5.14-rc5 > > arch/arm64/kvm/reset.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c > index 20588220fe66..e66974c4b9d3 100644 > --- a/arch/arm64/kvm/reset.c > +++ b/arch/arm64/kvm/reset.c > @@ -337,6 +337,15 @@ int kvm_set_ipa_limit(void) > return -EINVAL; > } > > + /* > + * IPA size beyond 48 bits could not be supported > + * on either 4K or 16K page size. Hence let's cap > + * it to 48 bits, in case it's reported as larger > + * on the system. > + */ > + if (!IS_ENABLED(CONFIG_ARM64_64K_PAGES)) As per our earlier discussion, please use (PAGE_SIZE != SZ_64K) instead. This is in keeping with the rest of the file. > + parange = min(parange, (unsigned int)ID_AA64MMFR0_PARANGE_48); > + Also, please move it next to the point where we assign parange. > kvm_ipa_limit = id_aa64mmfr0_parange_to_phys_shift(parange); > kvm_info("IPA Size Limit: %d bits%s\n", kvm_ipa_limit, > ((kvm_ipa_limit < KVM_PHYS_SHIFT) ? Thanks, M. -- Without deviation from the norm, progress is not possible.