[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 5/7] target/loongarch: Avoid bits shift exceeding width of bool ty
From: |
Song Gao |
Subject: |
[PULL 5/7] target/loongarch: Avoid bits shift exceeding width of bool type |
Date: |
Sun, 29 Sep 2024 16:17:22 +0800 |
From: Bibo Mao <maobibo@loongson.cn>
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>
Message-Id: <20240914064645.2099169-1-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
---
target/loongarch/arch_dump.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
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(¬e, 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]);
--
2.34.1
- [PULL 4/7] target/loongarch: Support QMP dump-guest-memory, (continued)
- [PULL 4/7] target/loongarch: Support QMP dump-guest-memory, Song Gao, 2024/09/12
- [PULL 3/7] target/loongarch/kvm: Add vCPU reset function, Song Gao, 2024/09/12
- [PULL 2/7] hw/loongarch: Remove default enable with VIRTIO_VGA device, Song Gao, 2024/09/12
- [PULL 6/7] hw/loongarch: virt: pass random seed to fdt, Song Gao, 2024/09/12
- [PULL 7/7] hw/loongarch: Add acpi SPCR table support, Song Gao, 2024/09/12
- [PULL 5/7] hw/loongarch: virt: support up to 4 serial ports, Song Gao, 2024/09/12
- Re: [PULL 0/7] loongarch-to-apply queue, Peter Maydell, 2024/09/13
- [PULL 0/7] loongarch-to-apply queue, Song Gao, 2024/09/29
- [PULL 1/7] acpi: ged: Add macro for acpi sleep control register, Song Gao, 2024/09/29
- [PULL 7/7] hw/loongarch/fw_cfg: Build in common_ss[], Song Gao, 2024/09/29
- [PULL 5/7] target/loongarch: Avoid bits shift exceeding width of bool type,
Song Gao <=
- [PULL 2/7] hw/loongarch/virt: Add FDT table support with acpi ged pm register, Song Gao, 2024/09/29
- [PULL 3/7] hw/loongarch/boot: Refactor EFI booting protocol generation, Song Gao, 2024/09/29
- [PULL 4/7] hw/loongarch/boot: Rework boot code generation, Song Gao, 2024/09/29
- [PULL 6/7] hw/loongarch/virt: Remove unnecessary 'cpu.h' inclusion, Song Gao, 2024/09/29
- Re: [PULL 0/7] loongarch-to-apply queue, Peter Maydell, 2024/09/30