qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: gaosong <gaosong@loongson.cn>
To: Bibo Mao <maobibo@loongson.cn>
Cc: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [PATCH v2] target/loongarch: Avoid bits shift exceeding width of bool type
Date: Sun, 29 Sep 2024 15:42:40 +0800	[thread overview]
Message-ID: <950b2879-26b7-ad4b-a0f6-b448d3c3f268@loongson.cn> (raw)
In-Reply-To: <20240914064645.2099169-1-maobibo@loongson.cn>

在 2024/9/14 下午2:46, Bibo Mao 写道:
> Variable env->cf[i] is defined as bool type, it is treated as int type
> with shift operation. However the max possible width is 56 for the shift
> operation, exceeding the width of int type. And there is existing api
> read_fcc() which is converted to u64 type with bitwise shift, it can be
> used to dump fp registers into coredump note segment.
>
> Resolves: Coverity CID 1561133
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/loongarch/arch_dump.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)
Applied to loongarch-next.

Thanks.
Song Gao
> diff --git a/target/loongarch/arch_dump.c b/target/loongarch/arch_dump.c
> index 4986db970e..d9e1120333 100644
> --- a/target/loongarch/arch_dump.c
> +++ b/target/loongarch/arch_dump.c
> @@ -97,11 +97,7 @@ static int loongarch_write_elf64_fprpreg(WriteCoreDumpFunction f,
>   
>       loongarch_note_init(&note, s, "CORE", 5, NT_PRFPREG, sizeof(note.fpu));
>       note.fpu.fcsr = cpu_to_dump64(s, env->fcsr0);
> -
> -    for (i = 0; i < 8; i++) {
> -        note.fpu.fcc |= env->cf[i] << (8 * i);
> -    }
> -    note.fpu.fcc = cpu_to_dump64(s, note.fpu.fcc);
> +    note.fpu.fcc = cpu_to_dump64(s, read_fcc(env));
>   
>       for (i = 0; i < 32; ++i) {
>           note.fpu.fpr[i] = cpu_to_dump64(s, env->fpr[i].vreg.UD[0]);
>
> base-commit: 28ae3179fc52d2e4d870b635c4a412aab99759e7



      reply	other threads:[~2024-09-29  7:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-14  6:46 [PATCH v2] target/loongarch: Avoid bits shift exceeding width of bool type Bibo Mao
2024-09-29  7:42 ` gaosong [this message]

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=950b2879-26b7-ad4b-a0f6-b448d3c3f268@loongson.cn \
    --to=gaosong@loongson.cn \
    --cc=maobibo@loongson.cn \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /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;
as well as URLs for NNTP newsgroup(s).