qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: "YunQiang Su" <syq@debian.org>,
	"Riku Voipio" <riku.voipio@iki.fi>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Aaron Sierra" <asierra@xes-inc.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Laurent Vivier" <laurent@vivier.eu>
Subject: [Qemu-devel] [PATCH 3/3] linux-user: MIPS set cpu to r6 CPU if binary is R6
Date: Sat, 13 Jan 2018 15:48:47 +0100	[thread overview]
Message-ID: <20180113144847.8403-4-laurent@vivier.eu> (raw)
In-Reply-To: <20180113144847.8403-1-laurent@vivier.eu>

From: YunQiang Su <syq@debian.org>

So here we need to detect the version of binaries and set
cpu_model for it.

[lv: original patch modified to move code into get_cpu_model()]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---

Notes:
    YunQiang Su, please add your Signed-off-by that was
    missing in your original patch.

 include/elf.h     |  4 ++++
 linux-user/main.c | 10 ++++++++++
 2 files changed, 14 insertions(+)

diff --git a/include/elf.h b/include/elf.h
index e8a515ce3d..f2104809b1 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -40,6 +40,10 @@ typedef int64_t  Elf64_Sxword;
 #define EF_MIPS_ARCH_5		0x40000000	/* -mips5 code.  */
 #define EF_MIPS_ARCH_32		0x50000000	/* MIPS32 code.  */
 #define EF_MIPS_ARCH_64		0x60000000	/* MIPS64 code.  */
+#define EF_MIPS_ARCH_32R2       0x70000000      /* MIPS32r2 code.  */
+#define EF_MIPS_ARCH_64R2       0x80000000      /* MIPS64r2 code.  */
+#define EF_MIPS_ARCH_32R6       0x90000000      /* MIPS32r6 code.  */
+#define EF_MIPS_ARCH_64R6       0xa0000000      /* MIPS64r6 code.  */
 
 /* The ABI of a file. */
 #define EF_MIPS_ABI_O32		0x00001000	/* O32 ABI.  */
diff --git a/linux-user/main.c b/linux-user/main.c
index 2fc2267fd4..3229ef079e 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4285,9 +4285,19 @@ static const char *get_cpu_model(int fd)
     return "Fujitsu MB86904";
 #endif
 #elif defined(TARGET_MIPS)
+    int ret;
+    uint32_t eflags;
+
+    ret = get_elf_eflags(fd, &eflags);
 #if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64)
+    if (ret == 0 && (eflags & EF_MIPS_ARCH_64R6) != 0) {
+        return "I6400";
+    }
     return "5KEf";
 #else
+    if (ret == 0 && (eflags & EF_MIPS_ARCH_32R6) != 0) {
+        return "mips32r6-generic";
+    }
     return "24Kf";
 #endif
 #elif defined TARGET_OPENRISC
-- 
2.14.3

  parent reply	other threads:[~2018-01-13 14:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-13 14:48 [Qemu-devel] [PATCH 0/3] linux-user: select CPU type according ELF header values Laurent Vivier
2018-01-13 14:48 ` [Qemu-devel] [PATCH 1/3] linux-user: introduce functions to detect CPU type Laurent Vivier
2018-01-15 22:04   ` Richard Henderson
2018-01-16 14:13     ` Laurent Vivier
2018-01-16 15:54       ` Richard Henderson
2018-01-16 16:56         ` Laurent Vivier
2018-01-13 14:48 ` [Qemu-devel] [PATCH 2/3] linux-user, m68k: select CPU according to ELF header values Laurent Vivier
2018-01-13 14:48 ` Laurent Vivier [this message]
2018-01-17  2:26   ` [Qemu-devel] [PATCH 3/3] linux-user: MIPS set cpu to r6 CPU if binary is R6 YunQiang Su
2018-01-17  7:44     ` Laurent Vivier
2018-01-24  8:24     ` Laurent Vivier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180113144847.8403-4-laurent@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=asierra@xes-inc.com \
    --cc=f4bug@amsat.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=riku.voipio@iki.fi \
    --cc=syq@debian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).