qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] a8749d: memory: Make memory_region_readd_subr


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] a8749d: memory: Make memory_region_readd_subregion() prope...
Date: Tue, 29 Mar 2022 07:17:47 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: a8749d7cc9210ae76bb7032970ad8a208c67a1f2
      
https://github.com/qemu/qemu/commit/a8749d7cc9210ae76bb7032970ad8a208c67a1f2
  Author: David Hildenbrand <david@redhat.com>
  Date:   2022-03-29 (Tue, 29 Mar 2022)

  Changed paths:
    M softmmu/memory.c

  Log Message:
  -----------
  memory: Make memory_region_readd_subregion() properly handle mapped aliases

memory_region_readd_subregion() wants to readd a region by first
removing it and then readding it. For readding, it doesn't use one of
the memory_region_add_*() variants, which is why fail to re-increment the
mr->mapped_via_alias counters, resulting in the
assert(alias->mapped_via_alias >= 0) in memory_region_del_subregion()
triggering the next time we call memory_region_readd_subregion().

Fix it by using memory_region_add_subregion_common() for readding the
region.

Reported-by: Niek Linnenbank <nieklinnenbank@gmail.com>
Fixes: 5ead62185d23 ("memory: Make memory_region_is_mapped() succeed when 
mapped via an alias")
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20220201100940.47788-1-david@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


  Commit: 8cd0e66353018f63322e0dd200b2d31be265f883
      
https://github.com/qemu/qemu/commit/8cd0e66353018f63322e0dd200b2d31be265f883
  Author: WANG Xuerui <xen0n@gentoo.org>
  Date:   2022-03-29 (Tue, 29 Mar 2022)

  Changed paths:
    M target/mips/cpu-param.h

  Log Message:
  -----------
  target/mips: Fix address space range declaration on n32

This bug is probably lurking there for so long, I cannot even git-blame
my way to the commit first introducing it.

Anyway, because n32 is also TARGET_MIPS64, the address space range
cannot be determined by looking at TARGET_MIPS64 alone. Fix this by only
declaring 48-bit address spaces for n64, or the n32 user emulation will
happily hand out memory ranges beyond the 31-bit limit and crash.

Confirmed to make the minimal reproducing example in the linked issue
behave.

Closes: https://gitlab.com/qemu-project/qemu/-/issues/939
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
Signed-off-by: WANG Xuerui <xen0n@gentoo.org>
Tested-by: Andreas K. Huettel <dilfridge@gentoo.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20220328035942.3299661-1-xen0n@gentoo.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


  Commit: 77d119dd335f910c7f953a265726e3753c69a0bb
      
https://github.com/qemu/qemu/commit/77d119dd335f910c7f953a265726e3753c69a0bb
  Author: Andreas K. Hüttel <dilfridge@gentoo.org>
  Date:   2022-03-29 (Tue, 29 Mar 2022)

  Changed paths:
    M scripts/qemu-binfmt-conf.sh

  Log Message:
  -----------
  qemu-binfmt-conf.sh: mips: allow nonzero EI_ABIVERSION, distinguish o32 and 
n32

With the command line flag -mplt and a recent toolchain, ELF binaries
generated by gcc can obtain EI_ABIVERSION=1, which makes, e.g., gcc
three-stage bootstrap in a mips-unknown-linux-gnu qemu-user chroot
fail since the binfmt-misc magic does not match anymore. Also other
values are technically possible. qemu executes these binaries just
fine, so relax the mask for the EI_ABIVERSION byte at offset 0x08.

In addition, extend magic string to distinguish mips o32 and n32 ABI.
This information is given by the EF_MIPS_ABI2 (0x20) bit in the
e_flags field of the ELF header (a 4-byte value at offset 0x24 for
the here applicable ELFCLASS32).

See-also: ace3d65459
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: WANG Xuerui <xen0n@gentoo.org>
Cc: Laurent Vivier <laurent@vivier.eu>
Cc: WANG Xuerui <xen0n@gentoo.org>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Alex Bennee <alex.bennee@linaro.org>
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
Closes: https://gitlab.com/qemu-project/qemu/-/issues/843
Message-Id: <20220328204900.3914990-1-dilfridge@gentoo.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


  Commit: bed1fa2fbe5f004ac4c152119029a8ce0810dc02
      
https://github.com/qemu/qemu/commit/bed1fa2fbe5f004ac4c152119029a8ce0810dc02
  Author: Peter Maydell <peter.maydell@linaro.org>
  Date:   2022-03-29 (Tue, 29 Mar 2022)

  Changed paths:
    M scripts/qemu-binfmt-conf.sh
    M softmmu/memory.c
    M target/mips/cpu-param.h

  Log Message:
  -----------
  Merge tag 'mips-20220329' of https://github.com/philmd/qemu into staging

MIPS patches queue

- ABI fixes (Xuerui, Andreas)
- Memory API alias fix (David)

# gpg: Signature made Tue 29 Mar 2022 11:34:42 BST
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" 
[unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'mips-20220329' of https://github.com/philmd/qemu:
  qemu-binfmt-conf.sh: mips: allow nonzero EI_ABIVERSION, distinguish o32 and 
n32
  target/mips: Fix address space range declaration on n32
  memory: Make memory_region_readd_subregion() properly handle mapped aliases

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Compare: https://github.com/qemu/qemu/compare/27fc9f365d6f...bed1fa2fbe5f



reply via email to

[Prev in Thread] Current Thread [Next in Thread]