[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/16] target/sh4: Return error if CPUClass::get_phys_page_debug()
From: |
Laurent Vivier |
Subject: |
[PULL 14/16] target/sh4: Return error if CPUClass::get_phys_page_debug() fails |
Date: |
Sat, 15 May 2021 12:03:33 +0200 |
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
If the get_physical_address() call fails, the SH4 get_phys_page_debug()
handler returns an uninitialized address. Instead return -1, which
correspond to "no page found" (see cpu_get_phys_page_debug() doc
string).
This fixes a warning emitted when building with CFLAGS=-O3
(using GCC 10.2.1 20201125):
target/sh4/helper.c: In function ‘superh_cpu_get_phys_page_debug’:
target/sh4/helper.c:446:12: warning: ‘physical’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
446 | return physical;
| ^~~~~~~~
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Message-Id: <20210505161046.1397608-1-f4bug@amsat.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
target/sh4/helper.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/target/sh4/helper.c b/target/sh4/helper.c
index bd8e034f174d..2d622081e85a 100644
--- a/target/sh4/helper.c
+++ b/target/sh4/helper.c
@@ -441,9 +441,12 @@ hwaddr superh_cpu_get_phys_page_debug(CPUState *cs, vaddr
addr)
target_ulong physical;
int prot;
- get_physical_address(&cpu->env, &physical, &prot, addr, MMU_DATA_LOAD);
+ if (get_physical_address(&cpu->env, &physical, &prot, addr, MMU_DATA_LOAD)
+ == MMU_OK) {
+ return physical;
+ }
- return physical;
+ return -1;
}
void cpu_load_tlb(CPUSH4State * env)
--
2.31.1
- [PULL 00/16] Trivial branch for 6.1 patches, Laurent Vivier, 2021/05/15
- [PULL 06/16] qapi: spelling fix (addtional), Laurent Vivier, 2021/05/15
- [PULL 02/16] hw/virtio: Pass virtio_feature_get_config_size() a const argument, Laurent Vivier, 2021/05/15
- [PULL 01/16] backends/tpm: Replace qemu_mutex_lock calls with QEMU_LOCK_GUARD, Laurent Vivier, 2021/05/15
- [PULL 03/16] virtio-blk: Constify VirtIOFeature feature_sizes[], Laurent Vivier, 2021/05/15
- [PULL 04/16] virtio-net: Constify VirtIOFeature feature_sizes[], Laurent Vivier, 2021/05/15
- [PULL 05/16] virtiofsd: Fix check of chown()'s return value, Laurent Vivier, 2021/05/15
- [PULL 10/16] cutils: fix memory leak in get_relocated_path(), Laurent Vivier, 2021/05/15
- [PULL 07/16] hw/gpio/aspeed: spelling fix (addtional), Laurent Vivier, 2021/05/15
- [PULL 11/16] hw/mem/meson: Fix linking sparse-mem device with fuzzer, Laurent Vivier, 2021/05/15
- [PULL 14/16] target/sh4: Return error if CPUClass::get_phys_page_debug() fails,
Laurent Vivier <=
- [PULL 16/16] target/avr: Ignore unimplemented WDR opcode, Laurent Vivier, 2021/05/15
- [PULL 08/16] hw/timer/etraxfs_timer: Convert to 3-phase reset (Resettable interface), Laurent Vivier, 2021/05/15
- [PULL 09/16] hw/rtc/mc146818rtc: Convert to 3-phase reset (Resettable interface), Laurent Vivier, 2021/05/15
- [PULL 13/16] multi-process: Avoid logical AND of mutually exclusive tests, Laurent Vivier, 2021/05/15
- [PULL 12/16] hw/pci-host: Do not build gpex-acpi.c if GPEX is not selected, Laurent Vivier, 2021/05/15
- [PULL 15/16] hw/avr/atmega.c: use the avr51 cpu for atmega1280, Laurent Vivier, 2021/05/15
- Re: [PULL 00/16] Trivial branch for 6.1 patches, Peter Maydell, 2021/05/17