All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Revert "elf: Relax MIPS' elf_check_arch() to accept EM_NANOMIPS too"
@ 2021-11-01 11:48 Philippe Mathieu-Daudé
  2021-11-01 17:51 ` Richard Henderson
  2021-11-01 21:40 ` Vince Del Vecchio
  0 siblings, 2 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-01 11:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: Aleksandar Rikalo, Richard Henderson, Laurent Vivier,
	Philippe Mathieu-Daudé,
	Petar Jovanovic, Aurelien Jarno

Per the "P32 Porting Guide" (rev 1.2) [1], chapter 2:

  p32 ABI Overview
  ----------------

  The Application Binary Interface, or ABI, is the set of rules
  that all binaries must follow in order to run on a nanoMIPS
  system. This includes, for example, object file format,
  instruction set, data layout, subroutine calling convention,
  and system call numbers. The ABI is one part of the mechanism
  that maintains binary compatibility across all nanoMIPS platforms.

  p32 improves on o32 to provide an ABI that is efficient in both
  code density and performance. p32 is required for the nanoMIPS
  architecture.

So far QEMU only support the MIPS o32 / n32 / n64 ABIs. The p32 ABI
is not implemented, therefore we can not run any nanoMIPS binary.

Revert commit f72541f3a59 ("elf: Relax MIPS' elf_check_arch() to
accept EM_NANOMIPS too").

See also the "ELF ABI Supplement" [2].

[1] http://codescape.mips.com/components/toolchain/nanomips/2019.03-01/docs/MIPS_nanoMIPS_p32_ABI_Porting_Guide_01_02_DN00184.pdf
[2] http://codescape.mips.com/components/toolchain/nanomips/2019.03-01/docs/MIPS_nanoMIPS_ABI_supplement_01_03_DN00179.pdf

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 linux-user/elfload.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index f9b82616920..5da8c02d082 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -925,8 +925,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en
 #endif
 #define ELF_ARCH    EM_MIPS
 
-#define elf_check_arch(x) ((x) == EM_MIPS || (x) == EM_NANOMIPS)
-
 #ifdef TARGET_ABI_MIPSN32
 #define elf_check_abi(x) ((x) & EF_MIPS_ABI2)
 #else
-- 
2.31.1



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

* Re: [PATCH] Revert "elf: Relax MIPS' elf_check_arch() to accept EM_NANOMIPS too"
  2021-11-01 11:48 [PATCH] Revert "elf: Relax MIPS' elf_check_arch() to accept EM_NANOMIPS too" Philippe Mathieu-Daudé
@ 2021-11-01 17:51 ` Richard Henderson
  2021-11-01 21:40 ` Vince Del Vecchio
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2021-11-01 17:51 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Aleksandar Rikalo, Laurent Vivier, Aurelien Jarno, Petar Jovanovic

On 11/1/21 7:48 AM, Philippe Mathieu-Daudé wrote:
> Per the "P32 Porting Guide" (rev 1.2) [1], chapter 2:
> 
>    p32 ABI Overview
>    ----------------
> 
>    The Application Binary Interface, or ABI, is the set of rules
>    that all binaries must follow in order to run on a nanoMIPS
>    system. This includes, for example, object file format,
>    instruction set, data layout, subroutine calling convention,
>    and system call numbers. The ABI is one part of the mechanism
>    that maintains binary compatibility across all nanoMIPS platforms.
> 
>    p32 improves on o32 to provide an ABI that is efficient in both
>    code density and performance. p32 is required for the nanoMIPS
>    architecture.
> 
> So far QEMU only support the MIPS o32 / n32 / n64 ABIs. The p32 ABI
> is not implemented, therefore we can not run any nanoMIPS binary.
> 
> Revert commit f72541f3a59 ("elf: Relax MIPS' elf_check_arch() to
> accept EM_NANOMIPS too").
> 
> See also the "ELF ABI Supplement" [2].
> 
> [1]http://codescape.mips.com/components/toolchain/nanomips/2019.03-01/docs/MIPS_nanoMIPS_p32_ABI_Porting_Guide_01_02_DN00184.pdf
> [2]http://codescape.mips.com/components/toolchain/nanomips/2019.03-01/docs/MIPS_nanoMIPS_ABI_supplement_01_03_DN00179.pdf
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   linux-user/elfload.c | 2 --
>   1 file changed, 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


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

* RE: [PATCH] Revert "elf: Relax MIPS' elf_check_arch() to accept EM_NANOMIPS too"
  2021-11-01 11:48 [PATCH] Revert "elf: Relax MIPS' elf_check_arch() to accept EM_NANOMIPS too" Philippe Mathieu-Daudé
  2021-11-01 17:51 ` Richard Henderson
@ 2021-11-01 21:40 ` Vince Del Vecchio
  2021-11-01 22:04   ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 5+ messages in thread
From: Vince Del Vecchio @ 2021-11-01 21:40 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Aleksandar Rikalo, Richard Henderson, Laurent Vivier,
	Aurelien Jarno, Petar Jovanovic

[-- Attachment #1: Type: text/html, Size: 5119 bytes --]

[-- Attachment #2: Type: text/plain, Size: 2777 bytes --]

Philippe said:

> So far QEMU only support the MIPS o32 / n32 / n64 ABIs. The p32 ABI is not implemented, therefore we can not run any nanoMIPS binary.

We use it internally to run nanoMIPS binaries every day.  I had thought everything relevant was completed and upstreamed, but perhaps there is a gap somewhere.  Let us investigate a little and get back to you.

Were you trying to run a bare metal executable or was it linux?

-Vince

-----Original Message-----
From: Qemu-devel <qemu-devel-bounces+vince.delvecchio=mediatek.com@nongnu.org> On Behalf Of Philippe Mathieu-Daudé
Sent: Monday, November 1, 2021 7:48 AM
To: qemu-devel@nongnu.org
Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>; Richard Henderson <richard.henderson@linaro.org>; Laurent Vivier <laurent@vivier.eu>; Philippe Mathieu-Daudé <f4bug@amsat.org>; Petar Jovanovic <petar.jovanovic@syrmia.com>; Aurelien Jarno <aurelien@aurel32.net>
Subject: [PATCH] Revert "elf: Relax MIPS' elf_check_arch() to accept EM_NANOMIPS too"

Per the "P32 Porting Guide" (rev 1.2) [1], chapter 2:

  p32 ABI Overview
  ----------------

  The Application Binary Interface, or ABI, is the set of rules
  that all binaries must follow in order to run on a nanoMIPS
  system. This includes, for example, object file format,
  instruction set, data layout, subroutine calling convention,
  and system call numbers. The ABI is one part of the mechanism
  that maintains binary compatibility across all nanoMIPS platforms.

  p32 improves on o32 to provide an ABI that is efficient in both
  code density and performance. p32 is required for the nanoMIPS
  architecture.

So far QEMU only support the MIPS o32 / n32 / n64 ABIs. The p32 ABI is not implemented, therefore we can not run any nanoMIPS binary.

Revert commit f72541f3a59 ("elf: Relax MIPS' elf_check_arch() to accept EM_NANOMIPS too").

See also the "ELF ABI Supplement" [2].

[1] http://codescape.mips.com/components/toolchain/nanomips/2019.03-01/docs/MIPS_nanoMIPS_p32_ABI_Porting_Guide_01_02_DN00184.pdf
[2] http://codescape.mips.com/components/toolchain/nanomips/2019.03-01/docs/MIPS_nanoMIPS_ABI_supplement_01_03_DN00179.pdf

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 linux-user/elfload.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f9b82616920..5da8c02d082 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -925,8 +925,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en  #endif
 #define ELF_ARCH    EM_MIPS
 
-#define elf_check_arch(x) ((x) == EM_MIPS || (x) == EM_NANOMIPS)
-
 #ifdef TARGET_ABI_MIPSN32
 #define elf_check_abi(x) ((x) & EF_MIPS_ABI2)  #else
--
2.31.1



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

* Re: [PATCH] Revert "elf: Relax MIPS' elf_check_arch() to accept EM_NANOMIPS too"
  2021-11-01 21:40 ` Vince Del Vecchio
@ 2021-11-01 22:04   ` Philippe Mathieu-Daudé
  2021-11-02 13:34     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-01 22:04 UTC (permalink / raw)
  To: Vince Del Vecchio, qemu-devel
  Cc: Aleksandar Rikalo, Richard Henderson, Laurent Vivier,
	Aurelien Jarno, Petar Jovanovic

On 11/1/21 22:40, Vince Del Vecchio wrote:
> Philippe said:
> 
>> So far QEMU only support the MIPS o32 / n32 / n64 ABIs. The p32 ABI is not implemented, therefore we can not run any nanoMIPS binary.
> 
> We use it internally to run nanoMIPS binaries every day.  I had thought everything relevant was completed and upstreamed, but perhaps there is a gap somewhere.  Let us investigate a little and get back to you.

I could wait few days until QEMU hard freeze and queue this patch as a
bug fix, but I doubt there is much you can do in that time frame, since
tomorrow is the soft freeze deadline.

Here I am simply changing the code to reject p32 binaries to avoid
users to waste their time trying to run a nanoMIPS binary. I am not
removing any of the nanoMIPS emulation code.

> Were you trying to run a bare metal executable or was it linux?

While I tested both toolchains (bare metal and musl/linux), here I am
only referring to the musl/linux one, since it is related to user-mode
emulation (files under linux-user/ directory).

The system emulation part is left unchanged (you can still boot a
nanoMIPS kernel if you select the proper CPU type).

> -----Original Message-----
> From: Qemu-devel <qemu-devel-bounces+vince.delvecchio=mediatek.com@nongnu.org> On Behalf Of Philippe Mathieu-Daudé
> Sent: Monday, November 1, 2021 7:48 AM
> To: qemu-devel@nongnu.org
> Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>; Richard Henderson <richard.henderson@linaro.org>; Laurent Vivier <laurent@vivier.eu>; Philippe Mathieu-Daudé <f4bug@amsat.org>; Petar Jovanovic <petar.jovanovic@syrmia.com>; Aurelien Jarno <aurelien@aurel32.net>
> Subject: [PATCH] Revert "elf: Relax MIPS' elf_check_arch() to accept EM_NANOMIPS too"
> 
> Per the "P32 Porting Guide" (rev 1.2) [1], chapter 2:
> 
>   p32 ABI Overview
>   ----------------
> 
>   The Application Binary Interface, or ABI, is the set of rules
>   that all binaries must follow in order to run on a nanoMIPS
>   system. This includes, for example, object file format,
>   instruction set, data layout, subroutine calling convention,
>   and system call numbers. The ABI is one part of the mechanism
>   that maintains binary compatibility across all nanoMIPS platforms.
> 
>   p32 improves on o32 to provide an ABI that is efficient in both
>   code density and performance. p32 is required for the nanoMIPS
>   architecture.
> 
> So far QEMU only support the MIPS o32 / n32 / n64 ABIs. The p32 ABI is not implemented, therefore we can not run any nanoMIPS binary.
> 
> Revert commit f72541f3a59 ("elf: Relax MIPS' elf_check_arch() to accept EM_NANOMIPS too").
> 
> See also the "ELF ABI Supplement" [2].
> 
> [1] http://codescape.mips.com/components/toolchain/nanomips/2019.03-01/docs/MIPS_nanoMIPS_p32_ABI_Porting_Guide_01_02_DN00184.pdf
> [2] http://codescape.mips.com/components/toolchain/nanomips/2019.03-01/docs/MIPS_nanoMIPS_ABI_supplement_01_03_DN00179.pdf
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  linux-user/elfload.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f9b82616920..5da8c02d082 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -925,8 +925,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en  #endif
>  #define ELF_ARCH    EM_MIPS
>  
> -#define elf_check_arch(x) ((x) == EM_MIPS || (x) == EM_NANOMIPS)
> -
>  #ifdef TARGET_ABI_MIPSN32
>  #define elf_check_abi(x) ((x) & EF_MIPS_ABI2)  #else
> --
> 2.31.1


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

* Re: [PATCH] Revert "elf: Relax MIPS' elf_check_arch() to accept EM_NANOMIPS too"
  2021-11-01 22:04   ` Philippe Mathieu-Daudé
@ 2021-11-02 13:34     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-02 13:34 UTC (permalink / raw)
  To: Vince Del Vecchio, qemu-devel
  Cc: Aleksandar Rikalo, Richard Henderson, Laurent Vivier,
	Aurelien Jarno, Petar Jovanovic

On 11/1/21 23:04, Philippe Mathieu-Daudé wrote:
> On 11/1/21 22:40, Vince Del Vecchio wrote:
>> Philippe said:
>>
>>> So far QEMU only support the MIPS o32 / n32 / n64 ABIs. The p32 ABI is not implemented, therefore we can not run any nanoMIPS binary.
>>
>> We use it internally to run nanoMIPS binaries every day.  I had thought everything relevant was completed and upstreamed, but perhaps there is a gap somewhere.  Let us investigate a little and get back to you.
> 
> I could wait few days until QEMU hard freeze and queue this patch as a
> bug fix, but I doubt there is much you can do in that time frame, since
> tomorrow is the soft freeze deadline.
> 
> Here I am simply changing the code to reject p32 binaries to avoid
> users to waste their time trying to run a nanoMIPS binary. I am not
> removing any of the nanoMIPS emulation code.

Patch queued to mips-next.


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

end of thread, other threads:[~2021-11-02 13:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-01 11:48 [PATCH] Revert "elf: Relax MIPS' elf_check_arch() to accept EM_NANOMIPS too" Philippe Mathieu-Daudé
2021-11-01 17:51 ` Richard Henderson
2021-11-01 21:40 ` Vince Del Vecchio
2021-11-01 22:04   ` Philippe Mathieu-Daudé
2021-11-02 13:34     ` Philippe Mathieu-Daudé

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.