Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3811233imm; Mon, 17 Sep 2018 03:43:02 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY3Cpb3oAsgY0whmlewHT6CVr4RxDVxEfqoRl2xs7L8gyWZ5DYqJEp+Y6Tgd4SSsP7Kr/6E X-Received: by 2002:a17:902:900c:: with SMTP id a12-v6mr8390481plp.104.1537180982177; Mon, 17 Sep 2018 03:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537180982; cv=none; d=google.com; s=arc-20160816; b=qbzqnca/ocrDf/iy5sop1KkgMc4J14WnZp4Pli2bG6CEmuXXduIpTLlwZz3q0YvAof P1ibXIH0Ec+P2FGF28Y0FQeTUAxMw0v3JRvNXIRFS5bocR50teioDzmybIxCR9nDfvKv CJc3QT5rIiPHbO4sGv7mKpuwmOni0NrsSBmojLX8q/WEazNGV3Koz7t7aR4X5VAmnJb1 yfNytvouWodTEvoqmangEV9IyPIB/R6nSWOreZVF1uSrmIz6wYYzVk0fZVhsN4eD9u4G F7MAVWJuT1AB5dcxA2rKlgaSe/cCDHYfcXqTSlRoe7TqZvpMxEgEjSpldQZFpETt976J Mp9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=TLe7pFFm3CpDD8z8kFTvj202Igu6UYpiI03UhCBAtJA=; b=mSPqVBBnQoinyekAovdYhW2obl09Tzd66XzN1Qnc4Otv/e8vlfRBakE7ArcqFl6OBR g64bakp64zD4rWC19KwDuoOuiVyk8OZBsY33q0sI3kwT8Lk4FBpegw01CmDnDD3xGo3Q y52gdlv3HG1ygP+O+uJKhUMPpT01odYUBkQnzYBfQjLtKaZA8G1VLOPGaH8e2CU2kUJz BM5d/VFCyXwmOrIkOIUDIaa0UP5uZn8JJZi9BhQGZvoz7O5hK6gz1lbXx4ADPCMqs8qz iO3sOh1k/e1a23Cns5Y/wEiE47iJA978HgxMiIlaWFBZ0Y9hPz8Nt6ECClkS2JRFlL2N /dZA== 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 w133-v6si14850570pfd.313.2018.09.17.03.42.46; Mon, 17 Sep 2018 03:43:02 -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 S1728211AbeIQQJW (ORCPT + 99 others); Mon, 17 Sep 2018 12:09:22 -0400 Received: from foss.arm.com ([217.140.101.70]:56462 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728115AbeIQQJV (ORCPT ); Mon, 17 Sep 2018 12:09:21 -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 CCAC015BF; Mon, 17 Sep 2018 03:42:33 -0700 (PDT) Received: from en101.Emea.Arm.com (en101.emea.arm.com [10.4.13.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 51D793F5BD; Mon, 17 Sep 2018 03:42:31 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, marc.zyngier@arm.com, cdall@kernel.org, eric.auger@redhat.com, pbonzini@redhat.com, rkrcmar@redhat.com, will.deacon@arm.com, catalin.marinas@arm.com, james.morse@arm.com, dave.martin@arm.com, julien.grall@arm.com, linux-kernel@vger.kernel.org, suzuki.poulose@arm.com Subject: [PATCH v5 04/18] arm64: Add a helper for PARange to physical shift conversion Date: Mon, 17 Sep 2018 11:41:26 +0100 Message-Id: <20180917104144.19188-5-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180917104144.19188-1-suzuki.poulose@arm.com> References: <20180917104144.19188-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On arm64, ID_AA64MMFR0_EL1.PARange encodes the maximum Physical Address range supported by the CPU. Add a helper to decode this to actual physical shift. If we hit an unallocated value, return the maximum range supported by the kernel. This will be used by KVM to set the VTCR_EL2.T0SZ, as it is about to move its place. Having this helper keeps the code movement cleaner. Cc: Catalin Marinas Cc: Marc Zyngier Cc: James Morse Cc: Christoffer Dall Reviewed-by: Eric Auger Signed-off-by: Suzuki K Poulose --- Changes since V4: - Add a comment on the result for unknown values. --- arch/arm64/include/asm/cpufeature.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 1717ba1db35d..072cc1c970c2 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -530,6 +530,26 @@ void arm64_set_ssbd_mitigation(bool state); static inline void arm64_set_ssbd_mitigation(bool state) {} #endif +static inline u32 id_aa64mmfr0_parange_to_phys_shift(int parange) +{ + switch (parange) { + case 0: return 32; + case 1: return 36; + case 2: return 40; + case 3: return 42; + case 4: return 44; + case 5: return 48; + case 6: return 52; + /* + * A future PE could use a value unknown to the kernel. + * However, by the "D10.1.4 Principles of the ID scheme + * for fields in ID registers", ARM DDI 0487C.a, any new + * value is guaranteed to be higher than what we know already. + * As a safe limit, we return the limit supported by the kernel. + */ + default: return CONFIG_ARM64_PA_BITS; + } +} #endif /* __ASSEMBLY__ */ #endif -- 2.19.0