From patchwork Fri Oct 7 23:41:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13001546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68267C433F5 for ; Fri, 7 Oct 2022 23:43:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6etnAaaIfqHxp9pqelTp2h0dpjiNoMVbKlTUQ4BtACg=; b=z+Iqj/0A3jpetG fif+nah697SaCx/uRb7yREknSxuh/wzFU1O7tx5VDvBMaz7K5qN0kRyXnXgrsABkpPjVkNjiwhRP+ Ir0x6w0LcS6eM2BLcj1ay0nC1H+KUgw/joqeeTQUu9NTwAS7BmnRA5EMp/TMeVYX3q9EbeZ6c6cjA pPQd6ioPom1Iv1lm3krmnQRKSieqYp+vxuQvlSPWbtQ1pkbgDJQs49pKcCtyRwtV+ObJjNZsQkQER y+30mqKOqMBRJUta7XzQ6Sd92oaH7cnVD7NP0eCfaE2XWuV7HkCbrReSKBow6QD8Vk/jdDlbcdneI fui0nDDbm6O2fkOo5v7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogwyo-00Azbw-D7; Fri, 07 Oct 2022 23:42:10 +0000 Received: from out2.migadu.com ([2001:41d0:2:aacc::]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogwyl-00AzYd-59 for linux-arm-kernel@lists.infradead.org; Fri, 07 Oct 2022 23:42:08 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1665186125; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fjIY8Z7YBr3tmYx5/J94Gtuu4yXPtVK1vVDelCV7rfM=; b=RRZ1MHA3Nh1TCHzLNqbw+h/vkuxo5bVDd1gceq0cYuPZFFz+v5VEizaEEFxwJE7+Ax5pCA IEhXq07EqokEJVf+pg9ZH5ZoIwUbjzm7kT4kWFdMgiAX5CZOZAVzuo/yiUi9odTiO2euk2 NQxb6rR55bdhXTn6a5TwNkrMYRAYerI= From: Oliver Upton To: Marc Zyngier , James Morse , Alexandru Elisei Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Ricardo Koller , David Matlack , Quentin Perret , kvmarm@lists.linux.dev, Oliver Upton Subject: [PATCH v3 1/2] KVM: arm64: Work out supported block level at compile time Date: Fri, 7 Oct 2022 23:41:50 +0000 Message-Id: <20221007234151.461779-2-oliver.upton@linux.dev> In-Reply-To: <20221007234151.461779-1-oliver.upton@linux.dev> References: <20221007234151.461779-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221007_164207_696002_90AF71E8 X-CRM114-Status: UNSURE ( 8.92 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Work out the minimum page table level where KVM supports block mappings at compile time. While at it, rewrite the comment around supported block mappings to directly describe what KVM supports instead of phrasing in terms of what it does not. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 1b098bd4cd37..3252eb50ecfe 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -13,6 +13,18 @@ #define KVM_PGTABLE_MAX_LEVELS 4U +/* + * The largest supported block sizes for KVM (no 52-bit PA support): + * - 4K (level 1): 1GB + * - 16K (level 2): 32MB + * - 64K (level 2): 512MB + */ +#ifdef CONFIG_ARM64_4K_PAGES +#define KVM_PGTABLE_MIN_BLOCK_LEVEL 1U +#else +#define KVM_PGTABLE_MIN_BLOCK_LEVEL 2U +#endif + static inline u64 kvm_get_parange(u64 mmfr0) { u64 parange = cpuid_feature_extract_unsigned_field(mmfr0, @@ -58,11 +70,7 @@ static inline u64 kvm_granule_size(u32 level) static inline bool kvm_level_supports_block_mapping(u32 level) { - /* - * Reject invalid block mappings and don't bother with 4TB mappings for - * 52-bit PAs. - */ - return !(level == 0 || (PAGE_SIZE != SZ_4K && level == 1)); + return level >= KVM_PGTABLE_MIN_BLOCK_LEVEL; } /**