Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1795334pxy; Thu, 6 May 2021 16:30:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOzk1UdqK0cHEWgDRhzjmS1FNVsxNhQvMPgKfpCZVHGkrv/VobaNMYZRoFA/jIN/GYTIpv X-Received: by 2002:a62:1b88:0:b029:1fb:d3d0:343a with SMTP id b130-20020a621b880000b02901fbd3d0343amr7382349pfb.76.1620343831073; Thu, 06 May 2021 16:30:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620343831; cv=none; d=google.com; s=arc-20160816; b=Vz08Kj2J+RcNAcrc6aoVL9kBkTZ1Im+MysDX6yK7AA4xcEwaEfXgo26K+4H9CLJYfK 6gVIvna6rKICRpMz4kASc3vZ5LkzMegvhnMCfQXBMAUt4j81ZEbf4mlwwVgJDTjQW2pU /K+0KLUDYIFjVgpNonteX1+1EhBM4TKi3wJHRtokjIeV9tLWQF4/d2EICKmKwMwxK1Ou IcppGR3gk1LQBFVlktMAfJKGNhBVupXfon6wzi0HVJqg7T9/mC0HXn5ridR7gz8Y4f2w 6UTQCECXG7iCCw2gchMrU4TlKxQWGJ56mSTdvCKcLGRCzg3aILErPHihSC80ygaMCmbU ALcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=aHUZroXXSSE8C8nyEfvC/P0qZw4OJlK/iOkVXIWzGGs=; b=0ENzXlDtSC+ATHlxYdL8SWgQVDylz7nvWEjiJl7qqjKrYRjjS7UMJy156G0IONQWVr Brgx5odPZoQU882WjrMqFFhleZO/kt4Y/7HrsOggbS2J0carya8Ap/wFAiPlaDeVc52T SJcvr9twURpm0HiRDtynS34FpImOY6nEoWjlR2pRPT2ytH0orBqid7SiUNypEE73rhKl 213sackg6dJiv+9AuxsCUB1cWVUD2MIPKVEdoEw2HL9oWBDjdWutYePWU0xLr/DzeFc4 eCpOi8LC7msfwkySk3kh0L2JsoVkIyGmiDaKaBbkiUoM70+jwgl07/q1kWOGI8IpTwft Z8Nw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f9si4730460pge.329.2021.05.06.16.30.18; Thu, 06 May 2021 16:30:31 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236165AbhEFQzh (ORCPT + 99 others); Thu, 6 May 2021 12:55:37 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:17591 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236169AbhEFQzg (ORCPT ); Thu, 6 May 2021 12:55:36 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FbfkT4f4Vz1BHvj; Fri, 7 May 2021 00:52:01 +0800 (CST) Received: from A2006125610.china.huawei.com (10.47.85.115) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Fri, 7 May 2021 00:54:27 +0800 From: Shameer Kolothum To: , , CC: , , , , , , , Subject: [RFC PATCH 1/3] arch/arm64: Introduce a capability to tell whether 16-bit VMID is available Date: Thu, 6 May 2021 17:52:30 +0100 Message-ID: <20210506165232.1969-2-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20210506165232.1969-1-shameerali.kolothum.thodi@huawei.com> References: <20210506165232.1969-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.47.85.115] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julien Grall At the moment, the function kvm_get_vmid_bits() is looking up for the sanitized value of ID_AA64MMFR1_EL1 and extract the information regarding the number of VMID bits supported. This is fine as the function is mainly used during VMID roll-over. New use in a follow-up patch will require the function to be called a every context switch so we want the function to be more efficient. A new capability is introduced to tell whether 16-bit VMID is available. Signed-off-by: Julien Grall Signed-off-by: Shameer Kolothum --- arch/arm64/include/asm/cpucaps.h | 3 ++- arch/arm64/include/asm/kvm_mmu.h | 4 +--- arch/arm64/kernel/cpufeature.c | 9 +++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/cpucaps.h b/arch/arm64/include/asm/cpucaps.h index c40f2490cd7b..acb92da5c254 100644 --- a/arch/arm64/include/asm/cpucaps.h +++ b/arch/arm64/include/asm/cpucaps.h @@ -67,7 +67,8 @@ #define ARM64_HAS_LDAPR 59 #define ARM64_KVM_PROTECTED_MODE 60 #define ARM64_WORKAROUND_NVIDIA_CARMEL_CNP 61 +#define ARM64_HAS_16BIT_VMID 62 -#define ARM64_NCAPS 62 +#define ARM64_NCAPS 63 #endif /* __ASM_CPUCAPS_H */ diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index 90873851f677..c3080966ef83 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -213,9 +213,7 @@ void kvm_toggle_cache(struct kvm_vcpu *vcpu, bool was_enabled); static inline unsigned int kvm_get_vmid_bits(void) { - int reg = read_sanitised_ftr_reg(SYS_ID_AA64MMFR1_EL1); - - return get_vmid_bits(reg); + return cpus_have_const_cap(ARM64_HAS_16BIT_VMID) ? 16 : 8; } /* diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index e5281e1c8f1d..ff956fb2f712 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -2203,6 +2203,15 @@ static const struct arm64_cpu_capabilities arm64_features[] = { .matches = has_cpuid_feature, .min_field_value = 1, }, + { + .capability = ARM64_HAS_16BIT_VMID, + .type = ARM64_CPUCAP_SYSTEM_FEATURE, + .sys_reg = SYS_ID_AA64MMFR1_EL1, + .field_pos = ID_AA64MMFR1_VMIDBITS_SHIFT, + .sign = FTR_UNSIGNED, + .min_field_value = ID_AA64MMFR1_VMIDBITS_16, + .matches = has_cpuid_feature, + }, {}, }; -- 2.17.1