Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Zenghui Yu <yuzenghui@huawei.com>
To: Jing Zhang <jingzhangos@google.com>
Cc: KVM <kvm@vger.kernel.org>, KVMARM <kvmarm@lists.linux.dev>,
	ARMLinux <linux-arm-kernel@lists.infradead.org>,
	Marc Zyngier <maz@kernel.org>,
	Oliver Upton <oliver.upton@linux.dev>,
	Paolo Bonzini <pbonzini@redhat.com>,
	James Morse <james.morse@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Itaru Kitayama <itaru.kitayama@linux.dev>
Subject: Re: [PATCH v1] KVM: arm64: selftests: Handle feature fields with nonzero minimum value correctly
Date: Mon, 15 Jan 2024 15:41:02 +0800	[thread overview]
Message-ID: <05e504bb-9aec-6026-1ea8-bca59ad439bf@huawei.com> (raw)
In-Reply-To: <20240109165622.4104387-1-jingzhangos@google.com>

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 <yuzenghui@huawei.com>
> Reported-by: Itaru Kitayama <itaru.kitayama@linux.dev>
> Signed-off-by: Jing Zhang <jingzhangos@google.com>
> ---
>  .../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

  parent reply	other threads:[~2024-01-15  7:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-09 16:56 [PATCH v1] KVM: arm64: selftests: Handle feature fields with nonzero minimum value correctly Jing Zhang
2024-01-09 22:27 ` Itaru Kitayama
2024-01-15  7:41 ` Zenghui Yu [this message]
2024-01-15 21:49   ` Jing Zhang
2024-01-15  9:34 ` Suzuki K Poulose
2024-01-15 21:53   ` Jing Zhang
  -- strict thread matches above, loose matches on Subject: below --
2024-01-15 22:02 Jing Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=05e504bb-9aec-6026-1ea8-bca59ad439bf@huawei.com \
    --to=yuzenghui@huawei.com \
    --cc=itaru.kitayama@linux.dev \
    --cc=james.morse@arm.com \
    --cc=jingzhangos@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=suzuki.poulose@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox