All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/3] MIPS patches for 2022-03-29
@ 2022-03-29 10:36 Philippe Mathieu-Daudé
  2022-03-29 10:36 ` [PULL 1/3] memory: Make memory_region_readd_subregion() properly handle mapped aliases Philippe Mathieu-Daudé
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-29 10:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: Aleksandar Rikalo, Aurelien Jarno, Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

The following changes since commit 27fc9f365d6f60ff86c2e2be57289bb47a2be882:

  Merge tag 'pull-ppc-20220326' of https://github.com/legoater/qemu into staging (2022-03-28 10:16:33 +0100)

are available in the Git repository at:

  https://github.com/philmd/qemu.git tags/mips-20220329

for you to fetch changes up to 77d119dd335f910c7f953a265726e3753c69a0bb:

  qemu-binfmt-conf.sh: mips: allow nonzero EI_ABIVERSION, distinguish o32 and n32 (2022-03-29 00:51:55 +0200)

----------------------------------------------------------------
MIPS patches queue

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

----------------------------------------------------------------

Andreas K. Hüttel (1):
  qemu-binfmt-conf.sh: mips: allow nonzero EI_ABIVERSION, distinguish
    o32 and n32

David Hildenbrand (1):
  memory: Make memory_region_readd_subregion() properly handle mapped
    aliases

WANG Xuerui (1):
  target/mips: Fix address space range declaration on n32

 scripts/qemu-binfmt-conf.sh | 20 ++++++++++----------
 softmmu/memory.c            |  3 +--
 target/mips/cpu-param.h     |  2 +-
 3 files changed, 12 insertions(+), 13 deletions(-)

-- 
2.35.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PULL 1/3] memory: Make memory_region_readd_subregion() properly handle mapped aliases
  2022-03-29 10:36 [PULL 0/3] MIPS patches for 2022-03-29 Philippe Mathieu-Daudé
@ 2022-03-29 10:36 ` Philippe Mathieu-Daudé
  2022-03-29 10:36 ` [PULL 2/3] target/mips: Fix address space range declaration on n32 Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-29 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Aleksandar Rikalo, David Hildenbrand, Philippe Mathieu-Daudé,
	Niek Linnenbank, Peter Xu, Paolo Bonzini, Aurelien Jarno

From: David Hildenbrand <david@redhat.com>

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>
---
 softmmu/memory.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/softmmu/memory.c b/softmmu/memory.c
index 8060c6de78..bfa5d5178c 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -2626,8 +2626,7 @@ static void memory_region_readd_subregion(MemoryRegion *mr)
         memory_region_transaction_begin();
         memory_region_ref(mr);
         memory_region_del_subregion(container, mr);
-        mr->container = container;
-        memory_region_update_container_subregions(mr);
+        memory_region_add_subregion_common(container, mr->addr, mr);
         memory_region_unref(mr);
         memory_region_transaction_commit();
     }
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PULL 2/3] target/mips: Fix address space range declaration on n32
  2022-03-29 10:36 [PULL 0/3] MIPS patches for 2022-03-29 Philippe Mathieu-Daudé
  2022-03-29 10:36 ` [PULL 1/3] memory: Make memory_region_readd_subregion() properly handle mapped aliases Philippe Mathieu-Daudé
@ 2022-03-29 10:36 ` Philippe Mathieu-Daudé
  2022-03-29 10:36 ` [PULL 3/3] qemu-binfmt-conf.sh: mips: allow nonzero EI_ABIVERSION, distinguish o32 and n32 Philippe Mathieu-Daudé
  2022-03-29 14:17 ` [PULL 0/3] MIPS patches for 2022-03-29 Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-29 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Aleksandar Rikalo, Richard Henderson, Andreas K . Huettel,
	Philippe Mathieu-Daudé,
	WANG Xuerui, Aurelien Jarno

From: WANG Xuerui <xen0n@gentoo.org>

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>
---
 target/mips/cpu-param.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/mips/cpu-param.h b/target/mips/cpu-param.h
index 9c4a6ea45e..1aebd01df9 100644
--- a/target/mips/cpu-param.h
+++ b/target/mips/cpu-param.h
@@ -12,7 +12,7 @@
 #else
 # define TARGET_LONG_BITS 32
 #endif
-#ifdef TARGET_MIPS64
+#ifdef TARGET_ABI_MIPSN64
 #define TARGET_PHYS_ADDR_SPACE_BITS 48
 #define TARGET_VIRT_ADDR_SPACE_BITS 48
 #else
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PULL 3/3] qemu-binfmt-conf.sh: mips: allow nonzero EI_ABIVERSION, distinguish o32 and n32
  2022-03-29 10:36 [PULL 0/3] MIPS patches for 2022-03-29 Philippe Mathieu-Daudé
  2022-03-29 10:36 ` [PULL 1/3] memory: Make memory_region_readd_subregion() properly handle mapped aliases Philippe Mathieu-Daudé
  2022-03-29 10:36 ` [PULL 2/3] target/mips: Fix address space range declaration on n32 Philippe Mathieu-Daudé
@ 2022-03-29 10:36 ` Philippe Mathieu-Daudé
  2022-03-29 14:17 ` [PULL 0/3] MIPS patches for 2022-03-29 Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-29 10:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Aleksandar Rikalo, Richard Henderson, Andreas K. Hüttel,
	Philippe Mathieu-Daudé,
	Laurent Vivier, WANG Xuerui, Alex Bennee, Aurelien Jarno

From: Andreas K. Hüttel <dilfridge@gentoo.org>

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>
---
 scripts/qemu-binfmt-conf.sh | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
index e9bfeb94d3..9cb723f443 100755
--- a/scripts/qemu-binfmt-conf.sh
+++ b/scripts/qemu-binfmt-conf.sh
@@ -60,28 +60,28 @@ m68k_family=m68k
 
 # FIXME: We could use the other endianness on a MIPS host.
 
-mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+mips_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20'
 mips_family=mips
 
-mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+mipsel_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00'
 mipsel_family=mips
 
-mipsn32_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-mipsn32_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+mipsn32_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20'
+mipsn32_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20'
 mipsn32_family=mips
 
-mipsn32el_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-mipsn32el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+mipsn32el_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00'
+mipsn32el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00'
 mipsn32el_family=mips
 
 mips64_magic='\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-mips64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+mips64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
 mips64_family=mips
 
 mips64el_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
 mips64el_family=mips
 
 sh4_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00'
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PULL 0/3] MIPS patches for 2022-03-29
  2022-03-29 10:36 [PULL 0/3] MIPS patches for 2022-03-29 Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2022-03-29 10:36 ` [PULL 3/3] qemu-binfmt-conf.sh: mips: allow nonzero EI_ABIVERSION, distinguish o32 and n32 Philippe Mathieu-Daudé
@ 2022-03-29 14:17 ` Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2022-03-29 14:17 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Aleksandar Rikalo, qemu-devel, Aurelien Jarno,
	Philippe Mathieu-Daudé

On Tue, 29 Mar 2022 at 11:40, Philippe Mathieu-Daudé
<philippe.mathieu.daude@gmail.com> wrote:
>
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> The following changes since commit 27fc9f365d6f60ff86c2e2be57289bb47a2be882:
>
>   Merge tag 'pull-ppc-20220326' of https://github.com/legoater/qemu into staging (2022-03-28 10:16:33 +0100)
>
> are available in the Git repository at:
>
>   https://github.com/philmd/qemu.git tags/mips-20220329
>
> for you to fetch changes up to 77d119dd335f910c7f953a265726e3753c69a0bb:
>
>   qemu-binfmt-conf.sh: mips: allow nonzero EI_ABIVERSION, distinguish o32 and n32 (2022-03-29 00:51:55 +0200)
>
> ----------------------------------------------------------------
> MIPS patches queue
>
> - ABI fixes (Xuerui, Andreas)
> - Memory API alias fix (David)
>
> ----------------------------------------------------------------
>
> Andreas K. Hüttel (1):
>   qemu-binfmt-conf.sh: mips: allow nonzero EI_ABIVERSION, distinguish
>     o32 and n32
>
> David Hildenbrand (1):
>   memory: Make memory_region_readd_subregion() properly handle mapped
>     aliases
>
> WANG Xuerui (1):
>   target/mips: Fix address space range declaration on n32
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/7.0
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-29 14:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 10:36 [PULL 0/3] MIPS patches for 2022-03-29 Philippe Mathieu-Daudé
2022-03-29 10:36 ` [PULL 1/3] memory: Make memory_region_readd_subregion() properly handle mapped aliases Philippe Mathieu-Daudé
2022-03-29 10:36 ` [PULL 2/3] target/mips: Fix address space range declaration on n32 Philippe Mathieu-Daudé
2022-03-29 10:36 ` [PULL 3/3] qemu-binfmt-conf.sh: mips: allow nonzero EI_ABIVERSION, distinguish o32 and n32 Philippe Mathieu-Daudé
2022-03-29 14:17 ` [PULL 0/3] MIPS patches for 2022-03-29 Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.