From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=113.46.200.216 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795074770; b=CaakKwbX3GuVHLE8xr3ESRf4OjzKeZrg+/of27OhSQ9gQYdikfgrPLdV/8zlI3pmpNth 5/+8wmEQxciyuylfXvXiG8lPaPQu3x8xyfjX79AF+fZTW+St82lnqhV4atxZ0sr3xIE4W vLRZzbS2NN94eCzoiRTWR6iS6gnExEBShOr+fKPYqEej6tI5RUjFbb+UW/3T9pcKswB73 s2QGCGHYHGbdfu7594EAke77OqpWDelxcu1Nf/VQjlNbI7s35IQqtfq9JGG5d4le3LEME rp6oKVEs5Zjek9IGHdxT4z1PdxHsEKQs5WFbnbA6RJ0JpwI35sJ3m0981UiKrnBw3zA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795074770; h=DMARC-Filter:dkim-signature:Received:Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:CC:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding:X-Originating-IP: X-ClientProxiedBy; bh=XDGSq+NYY9XzLBrI14hyUS/fB+/Exw2w2j7dzo+fazs=; b=FTslMrBt3oRvocUtMc3GH966ewmBTv1I6vU+nKQiGkcz7x1P0DJPLWcqJ85m5XPQL+8b LqRCuEPcqRDUGT03ccSWrlhcTXpRyVybrc+8FwtrTpFde2BOSA3dp7I32GUqkBsHCwkrq 9YbbqZX3W7Q46NraEqxxkXhCigpQiGOtWbBjSGVfaGjR79FgpqQIOmPY4jWwuwGSrZv1k 2kEXK+G6VGauuXWiZ50kXFcfxbz/djwfogOkYr9lvTrsCscunV+MRcq59K1GyqBIhc9Fw b0k3l22KeqtiMtpmvNXI776gbkmYBKvznix7OCdpM7XJJh62A54SoWboPPzailqS3UQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=LCSdGyGP; arc=none smtp.remote-ip=113.46.200.216 Received: from canpmsgout01.his.huawei.com (canpmsgout01.his.huawei.com [113.46.200.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 169F4606A324; Thu, 19 Nov 2026 07:52:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 169F4606A324 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=LCSdGyGP dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=XDGSq+NYY9XzLBrI14hyUS/fB+/Exw2w2j7dzo+fazs=; b=LCSdGyGPdamq0ZtVH+kQdHhms9IgZI22Kjo79DM7xUImrxVEK+DP8tfMlYQ5/G9pKXP//eJpt hiHyy9nA5IKmAKkHxPR9kSEkq3RilXY3DPsQUifasfgYSS15KqerDXrYYPbjxP+UQ9aehn1f8Gu fSS+3VMnGKoM25dNCsLD0so= Received: from mail.maildlp.com (unknown [172.19.162.140]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4jVVzd5Ky2z1T4Fr; Thu, 19 Nov 2026 15:51:57 +0800 (CST) Received: from kwepemr100010.china.huawei.com (unknown [7.202.195.125]) by mail.maildlp.com (Postfix) with ESMTPS id C976C203AB; Thu, 19 Nov 2026 15:52:38 +0800 (CST) Received: from [10.67.120.103] (10.67.120.103) by kwepemr100010.china.huawei.com (7.202.195.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Thu, 19 Nov 2026 15:52:37 +0800 Message-ID: Date: Thu, 19 Nov 2026 15:52:37 +0800 X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 06/15] KVM: arm64: Add support for FEAT_HDBSS To: Leonardo Bras CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , References: <20260929103655.85107-1-zhengtian10@huawei.com> <20260929103655.85107-7-zhengtian10@huawei.com> From: Tian Zheng In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemr100010.china.huawei.com (7.202.195.125) On 10/30/2026 10:15 PM, Leonardo Bras wrote: > On Fri, Oct 30, 2026 at 10:53:57AM +0800, Tian Zheng wrote: >> >> >> On 10/27/2026 2:12 AM, Leonardo Bras wrote: >>> On Tue, Sep 29, 2026 at 06:36:46PM +0800, Tian Zheng wrote: >>>> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c >>>> index 32102c3912fa..12fa37328dd2 100644 >>>> --- a/arch/arm64/kernel/cpufeature.c >>>> +++ b/arch/arm64/kernel/cpufeature.c >>>> @@ -2158,6 +2158,11 @@ static bool hvhe_possible(const struct arm64_cpu_capabilities *entry, >>>> return arm64_test_sw_feature_override(ARM64_SW_FEATURE_OVERRIDE_HVHE); >>>> } >>>> >>>> +static bool has_vhe_hdbss(const struct arm64_cpu_capabilities *entry, int scope) >>>> +{ >>>> + return is_kernel_in_hyp_mode() && has_cpuid_feature(entry, scope); >>>> +} >>>> + >>> >> >> Hi leo, >> >>> IIUC you run this on every cpu in the system, to make sure it's matching >>> the feature. Is there any chance the kernel is in EL2 only on some of the >>> cpus here? >>> >> >> It's impossible for the system to have only some CPUs in EL2 and others >> not. >> >>> If not, maybe we can run it on system_supports_hdbss() instead, which would >>> be easier for the user to understand it only runs in EL2, on top of not >>> needing the above. >>> >> >> However, The question is whether a cap should mean "this system can use >> the feature" or "this hardware supports the feature". If the cap only >> tracks hardware support, users may be confused when the hardware >> supports HDBSS but the system runs in nVHE mode — they would mistakenly >> believe they can use the feature. >> >> So I think we should keep is_kernel_in_hyp_mode() in has_vhe_hdbss(), >> and add a comment in system_supports_hdbss() explaining this. >> >> Does that work for you? Looking forward to your reply. > > Well, > That's just my personal view of this: > > If we have a function called "has_hdbss" it should only report if the > system has the feature available. > > On the "system_supports_*" we have to figure out if the system itself > supports the feature, which checks the feature bits itself and could mean > checking for other features being there, such as hyp_mode. > > What do you think? > > Thx, > Leo Hi Leo, Sorry for the slow reply. I've been looking into how other cpufeatures are configured on arm64, on and off, and that's why it took a while. My reading is that detected: HDBSS should mean "this system can use HDBSS", not just "the silicon has it". Several caps already add conditions beyond the ID bits. CNP returns false for kdump and under ARM64_WORKAROUND_DISABLE_CNP, NV and pKVM match on kvm_get_mode(), and can_trap_icv_dir_el1() starts with is_hyp_mode_available(). So in practice a SYSTEM_FEATURE cap answers "can this kernel use it on this system". HDBSS is EL2-only (HDBSSBR_EL2/HDBSSPROD_EL2, VTCR_EL2.HDBSS), implemented only under hyp/vhe, and used only by KVM, so "the hardware is there" is not the same as "this kernel can use it". That is why I'd keep the gate in has_vhe_hdbss() rather than moving it to the consumer. I'd be interested to hear how you see it. Thanks, Tian