From mboxrd@z Thu Jan 1 00:00:00 1970 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 2C86FC3DA79 for ; Mon, 15 Jan 2024 07:41:50 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:CC:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8xu2O139MqMQ5/sdNQzEnWsDYvDxXeiunFSQQ9edhKs=; b=o3FarSFY0XU7k0fiFKM/YFS2/R NEXhjHUF4urCvGQlaxQVSoYsjRCpd4sUb1SOAYUNvHS35BYNV0zVli4TUllZlj9j3tzRbSnzs4kul 54jFe+EIL7g2p1Ldl8+v99daJCjemR0UVpg5yG+qSRfjCmm/xpHoUPP3LOxo6W0L67Sf1+Qh0FDN0 GhBHgtQrC8pi9X/ie2hXOoWTC9TWeM7cmIFXNfM/OtmDf4MofyjEDx5n350c8d7/tPl3dFvx5Un40 D1k2+Ln0MhUOVI3u7dQyyUOOHQdRqfavAF8RA5N0w1KgVcn3DmMXPi8v3r86pitp4hlCSdaCiXjVc krTj2/lQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rPHb2-0087rk-0O; Mon, 15 Jan 2024 07:41:24 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rPHay-0087p2-0E for linux-arm-kernel@lists.infradead.org; Mon, 15 Jan 2024 07:41:22 +0000 Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4TD3vd5TZLz1Q7tp; Mon, 15 Jan 2024 15:40:13 +0800 (CST) Received: from kwepemm600007.china.huawei.com (unknown [7.193.23.208]) by mail.maildlp.com (Postfix) with ESMTPS id 71D8718006D; Mon, 15 Jan 2024 15:41:04 +0800 (CST) Received: from [10.174.185.179] (10.174.185.179) by kwepemm600007.china.huawei.com (7.193.23.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 15 Jan 2024 15:41:03 +0800 Subject: Re: [PATCH v1] KVM: arm64: selftests: Handle feature fields with nonzero minimum value correctly To: Jing Zhang CC: KVM , KVMARM , ARMLinux , Marc Zyngier , Oliver Upton , Paolo Bonzini , James Morse , Suzuki K Poulose , Itaru Kitayama References: <20240109165622.4104387-1-jingzhangos@google.com> From: Zenghui Yu Message-ID: <05e504bb-9aec-6026-1ea8-bca59ad439bf@huawei.com> Date: Mon, 15 Jan 2024 15:41:02 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20240109165622.4104387-1-jingzhangos@google.com> Content-Language: en-US X-Originating-IP: [10.174.185.179] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600007.china.huawei.com (7.193.23.208) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240114_234120_322265_1866E113 X-CRM114-Status: GOOD ( 17.91 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Jing, On 2024/1/10 0:56, Jing Zhang wrote: > There are some feature fields with nonzero minimum valid value. Make > sure get_safe_value() won't return invalid field values for them. > Also fix a bug that wrongly uses the feature bits type as the feature > bits sign causing all fields as signed in the get_safe_value() and > get_invalid_value(). > > Fixes: 54a9ea73527d ("KVM: arm64: selftests: Test for setting ID register from usersapce") > Reported-by: Zenghui Yu > Reported-by: Itaru Kitayama > Signed-off-by: Jing Zhang > --- > .../selftests/kvm/aarch64/set_id_regs.c | 20 +++++++++++++++---- > 1 file changed, 16 insertions(+), 4 deletions(-) > > diff --git a/tools/testing/selftests/kvm/aarch64/set_id_regs.c b/tools/testing/selftests/kvm/aarch64/set_id_regs.c > index bac05210b539..f17454dc6d9e 100644 > --- a/tools/testing/selftests/kvm/aarch64/set_id_regs.c > +++ b/tools/testing/selftests/kvm/aarch64/set_id_regs.c > @@ -224,13 +224,20 @@ uint64_t get_safe_value(const struct reg_ftr_bits *ftr_bits, uint64_t ftr) > { > uint64_t ftr_max = GENMASK_ULL(ARM64_FEATURE_FIELD_BITS - 1, 0); > > - if (ftr_bits->type == FTR_UNSIGNED) { > + if (ftr_bits->sign == FTR_UNSIGNED) { > switch (ftr_bits->type) { > case FTR_EXACT: > ftr = ftr_bits->safe_val; > break; > case FTR_LOWER_SAFE: > - if (ftr > 0) > + uint64_t min_safe = 0; > + > + if (!strcmp(ftr_bits->name, "ID_AA64DFR0_EL1_DebugVer")) > + min_safe = ID_AA64DFR0_EL1_DebugVer_IMP; > + else if (!strcmp(ftr_bits->name, "ID_DFR0_EL1_CopDbg")) > + min_safe = ID_DFR0_EL1_CopDbg_Armv8; > + > + if (ftr > min_safe) As I mentioned in my previous reply, there is a compilation error with gcc-10.3.1. | aarch64/set_id_regs.c: In function 'get_safe_value': | aarch64/set_id_regs.c:233:4: error: a label can only be part of a statement and a declaration is not a statement | 233 | uint64_t min_safe = 0; | | ^~~~~~~~ | aarch64/set_id_regs.c:262:4: error: a label can only be part of a statement and a declaration is not a statement | 262 | uint64_t min_safe = 0; | | ^~~~~~~~ Please fix it. Zenghui _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel