Misc fixes for 2023-12-04
The following changes since commit 17dacf7ac9e2f076c15f32a290203f8f571a8800:
Merge tag 'pull-more-8.2-fixes-011223-2' of https://gitlab.com/stsquad/qemu into staging (2023-12-04 08:03:18 -0500)
are available in the Git repository at:
https://github.com/philmd/qemu.git tags/misc-fixes-20231204
for you to fetch changes up to 2e8ed6a970e1842528f34aeb36b387834205c53a:
tests/avocado: mark ReplayKernelNormal.test_mips64el_malta as flaky (2023-12-04 16:21:00 +0100)
----------------------------------------------------------------
Misc fixes for 8.2
- memory: Avoid unaligned accesses (Patrick)
- target/riscv: Fix variable shadowing (Daniel)
- tests/avocado: Update URL, skip flaky test (Alex, Phil)
----------------------------------------------------------------
Alex Bennée (1):
tests/avocado: mark ReplayKernelNormal.test_mips64el_malta as flaky
Daniel Henrique Barboza (1):
target/riscv/kvm: fix shadowing in kvm_riscv_(get|put)_regs_csr
Patrick Venture (1):
system/memory: use ldn_he_p/stn_he_p
Philippe Mathieu-Daudé (1):
tests/avocado: Update yamon-bin-02.22.zip URL
system/memory.c | 32 ++--------------------------- target/riscv/kvm/kvm-cpu.c | 19 ++++++++--------- tests/avocado/machine_mips_malta.py | 5 +++-- tests/avocado/replay_kernel.py | 3 +++ 4 files changed, 17 insertions(+), 42 deletions(-)
Signature · 1 line
2.41.0
[PULL 4/4] tests/avocado: mark ReplayKernelNormal.test_mips64el_malta as flaky
From: Alex Bennée <[email protected]>
I missed this when going through the recent failure logs. I can run the test 30 times without failure locally but it seems to hang pretty reliably on GitLab's CI infra-structure.
Message-ID: <[email protected]>
--- tests/avocado/replay_kernel.py | 3 +++ 1 file changed, 3 insertions(+)
tests/avocado/replay_kernel.py +3 -0
@@ -119,6 +119,8 @@ def test_mips_malta(self): self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5) + # See https://gitlab.com/qemu-project/qemu/-/issues/2013 + @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is unstable on GitLab') def test_mips64el_malta(self): """ This test requires the ar tool to extract "data.tar.gz" from
@@ -134,6 +136,7 @@ def test_mips64el_malta(self): :avocado: tags=arch:mips64el :avocado: tags=machine:malta + :avocado: tags=flaky """ deb_url = ('http://snapshot.debian.org/archive/debian/' '20130217T032700Z/pool/main/l/linux-2.6/'
Signature · 1 line
2.41.0
[PULL 1/4] system/memory: use ldn_he_p/stn_he_p
In reply to Philippe Mathieu-DaudéFrom: Patrick Venture <[email protected]>
Using direct pointer dereferencing can allow for unaligned accesses, which was seen during execution with sanitizers enabled.
Message-ID: <[email protected]>
--- system/memory.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-)
system/memory.c +2 -30
@@ -1339,22 +1339,7 @@ static uint64_t memory_region_ram_device_read(void *opaque, hwaddr addr, unsigned size) {MemoryRegion *mr = opaque; -uint64_t data = (uint64_t )~0 ; - -switch (size) { -case 1 : - data = *(uint8_t *)(mr->ram_block->host + addr); -break ; -case 2 : - data = *(uint16_t *)(mr->ram_block->host + addr); -break ; -case 4 : - data = *(uint32_t *)(mr->ram_block->host + addr); -break ; -case 8 : - data = *(uint64_t *)(mr->ram_block->host + addr); -break ; - } +uint64_t data =ldn_he_p (mr->ram_block->host + addr, size);trace_memory_region_ram_device_read (get_cpu_index (), mr, addr, data, size);
@@ -1368,20 +1353,7 @@ static void memory_region_ram_device_write(void *opaque, hwaddr addr,trace_memory_region_ram_device_write (get_cpu_index (), mr, addr, data, size); -switch (size) { -case 1 : - *(uint8_t *)(mr->ram_block->host + addr) = (uint8_t )data; -break ; -case 2 : - *(uint16_t *)(mr->ram_block->host + addr) = (uint16_t )data; -break ; -case 4 : - *(uint32_t *)(mr->ram_block->host + addr) = (uint32_t )data; -break ; -case 8 : - *(uint64_t *)(mr->ram_block->host + addr) = data; -break ; - } +stn_he_p (mr->ram_block->host + addr, size, data); }static const MemoryRegionOps ram_device_mem_ops = {
Signature · 1 line
2.41.0
[PULL 2/4] target/riscv/kvm: fix shadowing in kvm_riscv_(get|put)_regs_csr
In reply to Philippe Mathieu-DaudéFrom: Daniel Henrique Barboza <[email protected]>
KVM_RISCV_GET_CSR() and KVM_RISCV_SET_CSR() use an 'int ret' variable that is used to do an early 'return' if ret > 0. Both are being called in functions that are also declaring a 'ret' integer, initialized with '0', and this integer is used as return of the function.
The result is that the compiler is less than pleased and is pointing shadowing errors:
../target/riscv/kvm/kvm-cpu.c: In function 'kvm_riscv_get_regs_csr':../target/riscv/kvm/kvm-cpu.c:90:13: error: declaration of 'ret' shadows a previous local [-Werror=shadow=compatible-local]
90 | int ret = kvm_get_one_reg(cs, RISCV_CSR_REG(env, csr), ®); \
| ^~~../target/riscv/kvm/kvm-cpu.c:539:5: note: in expansion of macro 'KVM_RISCV_GET_CSR'
539 | KVM_RISCV_GET_CSR(cs, env, sstatus, env->mstatus);
| ^~~~~~~~~~~~~~~~~
../target/riscv/kvm/kvm-cpu.c:536:9: note: shadowed declaration is here
536 | int ret = 0;
| ^~~../target/riscv/kvm/kvm-cpu.c: In function 'kvm_riscv_put_regs_csr':../target/riscv/kvm/kvm-cpu.c:98:13: error: declaration of 'ret' shadows a previous local [-Werror=shadow=compatible-local]
98 | int ret = kvm_set_one_reg(cs, RISCV_CSR_REG(env, csr), ®); \
| ^~~../target/riscv/kvm/kvm-cpu.c:556:5: note: in expansion of macro 'KVM_RISCV_SET_CSR'
556 | KVM_RISCV_SET_CSR(cs, env, sstatus, env->mstatus);
| ^~~~~~~~~~~~~~~~~
../target/riscv/kvm/kvm-cpu.c:553:9: note: shadowed declaration is here
553 | int ret = 0;
| ^~~The macros are doing early returns for non-zero returns and the local 'ret' variable for both functions is used just to do 'return 0', so remove them from kvm_riscv_get_regs_csr() and kvm_riscv_put_regs_csr() and do a straight 'return 0' in the end.
For good measure let's also rename the 'ret' variables in KVM_RISCV_GET_CSR() and KVM_RISCV_SET_CSR() to '_ret' to make them more resilient to these kind of errors.
Message-ID: <[email protected]>
--- target/riscv/kvm/kvm-cpu.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
target/riscv/kvm/kvm-cpu.c +9 -10
@@ -87,17 +87,17 @@ static uint64_t kvm_riscv_reg_id(CPURISCVState *env, uint64_t type,#define KVM_RISCV_GET_CSR (cs, env, csr, reg) \ do { \ - int ret = kvm_get_one_reg(cs, RISCV_CSR_REG(env, csr), ®); \ - if (ret) { \ - return ret; \ + int _ret = kvm_get_one_reg(cs, RISCV_CSR_REG(env, csr), ®); \ + if (_ret) { \ + return _ret; \ } \ } while (0)#define KVM_RISCV_SET_CSR (cs, env, csr, reg) \ do { \ - int ret = kvm_set_one_reg(cs, RISCV_CSR_REG(env, csr), ®); \ - if (ret) { \ - return ret; \ + int _ret = kvm_set_one_reg(cs, RISCV_CSR_REG(env, csr), ®); \ + if (_ret) { \ + return _ret; \ } \ } while (0)
@@ -533,7 +533,6 @@ static int kvm_riscv_put_regs_core(CPUState *cs)static int kvm_riscv_get_regs_csr (CPUState *cs) { -int ret =0 ;CPURISCVState *env = &RISCV_CPU (cs)->env;KVM_RISCV_GET_CSR (cs, env, sstatus, env->mstatus);
@@ -545,12 +544,12 @@ static int kvm_riscv_get_regs_csr(CPUState *cs)KVM_RISCV_GET_CSR (cs, env, stval, env->stval);KVM_RISCV_GET_CSR (cs, env, sip, env->mip);KVM_RISCV_GET_CSR (cs, env, satp, env->satp); -return ret; + +return 0 ; }static int kvm_riscv_put_regs_csr (CPUState *cs) { -int ret =0 ;CPURISCVState *env = &RISCV_CPU (cs)->env;KVM_RISCV_SET_CSR (cs, env, sstatus, env->mstatus);
@@ -563,7 +562,7 @@ static int kvm_riscv_put_regs_csr(CPUState *cs)KVM_RISCV_SET_CSR (cs, env, sip, env->mip);KVM_RISCV_SET_CSR (cs, env, satp, env->satp); -return ret; +return 0 ; }static int kvm_riscv_get_regs_fp (CPUState *cs)
Signature · 1 line
2.41.0
[PULL 3/4] tests/avocado: Update yamon-bin-02.22.zip URL
In reply to Philippe Mathieu-Daudéhttp://www.imgtec.com/tools/mips-tools/downloads/ redirects to https://mips.com/downloads/yamon-version-02-22/ then points to an invalid path to a s3 bucket. Use the correct path. The site will eventually be fixed.
Message-Id: <[email protected]>
--- tests/avocado/machine_mips_malta.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tests/avocado/machine_mips_malta.py +3 -2
@@ -128,8 +128,9 @@ def test_mips_malta_i6400_framebuffer_logo_8cores(self): class MaltaMachine(QemuSystemTest): def do_test_yamon(self): - rom_url = ('http://www.imgtec.com/tools/mips-tools/downloads/' - 'yamon/yamon-bin-02.22.zip') + rom_url = ('https://s3-eu-west-1.amazonaws.com/' + 'downloads-mips/mips-downloads/' + 'YAMON/yamon-bin-02.22.zip') rom_hash = '8da7ecddbc5312704b8b324341ee238189bde480' zip_path = self.fetch_asset(rom_url, asset_hash=rom_hash)
Signature · 1 line
2.41.0
Stefan Hajnoczi
AppliedApplied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes.