Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2371878pxb; Mon, 20 Sep 2021 20:29:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwK6/dixLN6Dr4kow1tem2dFETHhrEvLcQhuydbtA94VTWXuCImaj655xVMpgpLjQJlPBC X-Received: by 2002:a17:906:7fc4:: with SMTP id r4mr33685322ejs.75.1632194986155; Mon, 20 Sep 2021 20:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632194986; cv=none; d=google.com; s=arc-20160816; b=A0aQ1IBmUMJSfAClhixE29y/6ZQUqxCWXQSVqwXGiSXU1jQp6Sr6Pgko209me6HjzV 63Es3Rj8wBpCs1TzfXS0se53phtck4LREpBFKg26d8l3yT1frT+lERTopFjl7gzdRfzG Wbi6F9rYbxnDC2s9Fc4U/ynMW0yR9uUYD3u3J7Qww/TWt0y6Ubfsj2yN8jpddkLHjf6B NSsaelY3ptGwsEF3VpA8lSBhpq7veJ3taihhtbg4WuBDF2CFIOYXuiAf2DKUvoTlQOrQ qSVPKdjFOwzfM0HJXnZ+sqDF20R0HFD7WH+RmkUx+11tYJeMP0zijEpxtzANCzza8hL5 BnvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pTpe29VYZsqcqk/1Jyx5hic3+UiOVMfnPDnal4yZ8Is=; b=mfUK2kwB39jy6h9x+ORzcnmqRAIKBw5DwSi5gL358TGDY0aTZF5dq9F77g35wtJjHN Cc6vTZb8fvOkRqfYJnnlaBtqiIWjERKe5jWHlMkPbRnB9kyMOMajvYOGYBJiR6yjQUy6 x8ddzc9ljD1aL4TfCxbPChosSNtDfJQ3muZ9UmZGlAjbBbz1XTmen96cAEVOlDBgBkuc sZe/GHT5GMgFWWSiVG0r7fzR2lzYbQakzdVeSNzo0czlU4YJejoBAA7Mh1A2s5cGWMVi YhL8wWLNi7uguJ32WGTCql9OekY0XSQEozk8y+9x+BnmgAwNO+QTJmU481O6QQYPVlj5 tvoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Sj/8i3yK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jy11si19144834ejc.732.2021.09.20.20.29.22; Mon, 20 Sep 2021 20:29:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Sj/8i3yK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384924AbhITStU (ORCPT + 99 others); Mon, 20 Sep 2021 14:49:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:33538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384097AbhITSqc (ORCPT ); Mon, 20 Sep 2021 14:46:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 27A766335C; Mon, 20 Sep 2021 17:33:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632159213; bh=CR846wXXXHl/Ng8G88sA14qia9OWfF1CL4/79f+daRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sj/8i3yKeaZ3/Re7XqH4Mjpd3N1Ux+fZgKS0DP1PmUh3W7jF5KdNmVPALncZcTHxi 4e2R3HoO6cWU+F0z3wnFnA0o/6Mv77mu3QTb4BBEPqoyeYwvt0foxTOq5zR+eekusg P204089QZ+FWIwK8lrgvTRBmIHGsAH11ZlWHz+20= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Anshuman Khandual , Sasha Levin Subject: [PATCH 5.14 127/168] KVM: arm64: Restrict IPA size to maximum 48 bits on 4K and 16K page size Date: Mon, 20 Sep 2021 18:44:25 +0200 Message-Id: <20210920163925.839290093@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163921.633181900@linuxfoundation.org> References: <20210920163921.633181900@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anshuman Khandual [ Upstream commit 5e5df9571c319fb107d7a523cc96fcc99961ee70 ] 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 Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/1628680275-16578-1-git-send-email-anshuman.khandual@arm.com Signed-off-by: Sasha Levin --- arch/arm64/kvm/reset.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index cba7872d69a8..78d4bd897fbc 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -317,6 +317,14 @@ int kvm_set_ipa_limit(void) mmfr0 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1); parange = cpuid_feature_extract_unsigned_field(mmfr0, ID_AA64MMFR0_PARANGE_SHIFT); + /* + * 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 (PAGE_SIZE != SZ_64K) + parange = min(parange, (unsigned int)ID_AA64MMFR0_PARANGE_48); /* * Check with ARMv8.5-GTG that our PAGE_SIZE is supported at -- 2.30.2