Skip to contentSkip to conversation

Adding new user mode target ppc64le-linux-user

PATCH In review Doug Kwan 4 participants 15 messages May 10, 2014 – May 13, 2014

lore
Share & tools
lore

Doug Kwan

author
#0 lore raw

v2 cover Adding new user mode target ppc64le-linux-user

Hi

I have made changes based on comments to the previous set of pathces.

1. Target name is now ppc64le-linux-user.
2. I used a memop mask to avoid generating redundant byteswap pairs that cancel out each other. This is suggested by Peter Maydell.
3. There is code to handle machine name correctly in uname.

This is not mean to be final though. Tom Musta of IBM kindly offered to help me with this. So I am handling over this set of patches. Tom will continue from this version.

Thanks for all the comments and suggestions so far.

-Doug

Doug Kwan (3):
linux-user: Support little-endian PPC64 in user mode.
PPC: Allow little-endian user mode.
Add a new user mode target for little-endian PPC64.

 configure                              |   6 ++
 default-configs/ppc64le-linux-user.mak |   1 +
 include/elf.h                          |   5 ++
 linux-user/elfload.c                   |  17 +++-
 linux-user/uname.c                     |   6 ++
 target-ppc/mem_helper.c                |  25 +++++-
 target-ppc/translate.c                 | 150 +++++++++++++--------------------
 target-ppc/translate_init.c            |   9 ++
 8 files changed, 122 insertions(+), 97 deletions(-)
 create mode 100644 default-configs/ppc64le-linux-user.mak
Signature · 1 line
1.9.1.423.g4596e3a
author
#1 lore raw

PATCH v2 1/3 linux-user: Support little-endian PPC64 in user mode.

Look at ELF header to determin ABI version on PPC64. This is required for executing the first instruction correctly. Also print correct machine name in uname() system call.

---
 include/elf.h        |  5 +++++
 linux-user/elfload.c | 17 +++++++++++++++--
 linux-user/uname.c   |  6 ++++++
 3 files changed, 26 insertions(+), 2 deletions(-)
include/elf.h +5 -0
index 1599ab2..f9f1675 100644
@@ -561,6 +561,11 @@ typedef struct {
 #define SHF_ALPHA_GPREL		0x10000000
 
 
+/* PowerPC specific definitions.  */
+
+/* Processor specific flags for the ELF header e_flags field.  */
+#define EF_PPC64_ABI		0x3
+
 /* PowerPC relocations defined by the ABIs */
 #define R_PPC_NONE		0
 #define R_PPC_ADDR32		1	/* 32bit absolute address */
linux-user/elfload.c +15 -2
index 995f999..b96d64a 100644
@@ -777,12 +777,18 @@ static uint32_t get_elf_hwcap(void)
         NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC);        \
     } while (0)
 
+static inline uint32_t get_ppc64_abi(struct image_info *infop);
+
 static inline void init_thread(struct target_pt_regs *_regs, struct image_info *infop)
 {
     _regs->gpr[1] = infop->start_stack;
 #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
-    _regs->gpr[2] = ldq_raw(infop->entry + 8) + infop->load_bias;
-    infop->entry = ldq_raw(infop->entry) + infop->load_bias;
+    if (get_ppc64_abi(infop) < 2) {
+      _regs->gpr[2] = ldq_raw(infop->entry + 8) + infop->load_bias;
+      infop->entry = ldq_raw(infop->entry) + infop->load_bias;
+    } else {
+      _regs->gpr[12] = infop->entry;  /* r12 set to global entry address */
+    }
 #endif
     _regs->nip = infop->entry;
 }
@@ -1152,6 +1158,13 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i
 
 #include "elf.h"
 
+#ifdef TARGET_PPC
+static inline uint32_t get_ppc64_abi(struct image_info *infop)
+{
+  return infop->elf_flags & EF_PPC64_ABI;
+}
+#endif
+
 struct exec
 {
     unsigned int a_info;   /* Use macros N_MAGIC, etc for access */
linux-user/uname.c +6 -0
index f5d4c66..cb1f9a3 100644
@@ -65,6 +65,12 @@ const char *cpu_to_uname_machine(void *cpu_env)
         return "i586";
     }
     return "i686";
+#elif defined(TARGET_PPC64)
+#ifdef TARGET_WORDS_BIGENDIAN
+    return UNAME_MACHINE;
+#else
+    return UNAME_MACHINE "le";
+#endif
 #else
     /* default is #define-d in each arch/ subdir */
     return UNAME_MACHINE;
Signature · 1 line
1.9.1.423.g4596e3a
author
#9 lore raw

PATCH v2 3/3 Add a new user mode target for little-endian PPC64.

In reply to Doug Kwan
---
 configure                              | 6 ++++++
 default-configs/ppc64le-linux-user.mak | 1 +
 2 files changed, 7 insertions(+)
 create mode 100644 default-configs/ppc64le-linux-user.mak
configure +6 -0
index 46bc0c9..5f0926b 100755
@@ -4912,6 +4912,12 @@ case "$target_name" in
     TARGET_ABI_DIR=ppc
     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
   ;;
+  ppc64le)
+    TARGET_ARCH=ppc64
+    TARGET_BASE_ARCH=ppc
+    TARGET_ABI_DIR=ppc
+    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
+  ;;
   ppc64abi32)
     TARGET_ARCH=ppc64
     TARGET_BASE_ARCH=ppc
default-configs/ppc64le-linux-user.mak new file +1 -0
new file mode 100644
index 0000000..6948225
@@ -0,0 +1 @@
+# Default configuration for ppc64el-linux-user
Signature · 1 line
1.9.1.423.g4596e3a
author
#4 lore raw

PATCH v2 2/3 PPC: Allow little-endian user mode.

In reply to Doug Kwan

This allow running PPC64 little-endian in user mode if target is configured that way. In PPC64 LE user mode we set MSR.LE during initialization. Overhaul handling of byteswapping in code generation and mem helpers.

---
 target-ppc/mem_helper.c     |  25 ++++++--
 target-ppc/translate.c      | 150 +++++++++++++++++---------------------------
 target-ppc/translate_init.c |   9 +++
 3 files changed, 89 insertions(+), 95 deletions(-)
target-ppc/mem_helper.c +21 -4
index f35ed03..0112821 100644
@@ -28,6 +28,14 @@
 
 //#define DEBUG_OP
 
+static inline bool needs_byteswap(const CPUPPCState *env) {
+#if defined(TARGET_WORDS_BIGENDIAN)
+  return msr_le;
+#else
+  return !msr_le;
+#endif
+}
+
 /*****************************************************************************/
 /* Memory load and stores */
 
@@ -47,7 +55,7 @@ static inline target_ulong addr_add(CPUPPCState *env, target_ulong addr,
 void helper_lmw(CPUPPCState *env, target_ulong addr, uint32_t reg)
 {
     for (; reg < 32; reg++) {
-        if (msr_le) {
+        if (needs_byteswap(env)) {
             env->gpr[reg] = bswap32(cpu_ldl_data(env, addr));
         } else {
             env->gpr[reg] = cpu_ldl_data(env, addr);
@@ -59,7 +67,7 @@ void helper_lmw(CPUPPCState *env, target_ulong addr, uint32_t reg)
 void helper_stmw(CPUPPCState *env, target_ulong addr, uint32_t reg)
 {
     for (; reg < 32; reg++) {
-        if (msr_le) {
+        if (needs_byteswap(env)) {
             cpu_stl_data(env, addr, bswap32((uint32_t)env->gpr[reg]));
         } else {
             cpu_stl_data(env, addr, (uint32_t)env->gpr[reg]);
@@ -202,6 +210,11 @@ target_ulong helper_lscbx(CPUPPCState *env, target_ulong addr, uint32_t reg,
 #define LO_IDX 0
 #endif
 
+/* We use msr_le to determine index ordering in a vector.  However,
+   byteswapping is not simply controlled by msr_le.  We also need to take
+   into account endianness of the target.  This is done for the little-endian
+   PPC64 user-mode target. */ 
+
 #define LVE(name, access, swap, element)                        \
     void helper_##name(CPUPPCState *env, ppc_avr_t *r,          \
                        target_ulong addr)                       \
@@ -210,9 +223,11 @@ target_ulong helper_lscbx(CPUPPCState *env, target_ulong addr, uint32_t reg,
         int adjust = HI_IDX*(n_elems - 1);                      \
         int sh = sizeof(r->element[0]) >> 1;                    \
         int index = (addr & 0xf) >> sh;                         \
-                                                                \
         if (msr_le) {                                           \
             index = n_elems - index - 1;                        \
+        }                                                       \
+                                                                \
+        if (needs_byteswap(env)) {                              \
             r->element[LO_IDX ? index : (adjust - index)] =     \
                 swap(access(env, addr));                        \
         } else {                                                \
@@ -235,9 +250,11 @@ LVE(lvewx, cpu_ldl_data, bswap32, u32)
         int adjust = HI_IDX * (n_elems - 1);                            \
         int sh = sizeof(r->element[0]) >> 1;                            \
         int index = (addr & 0xf) >> sh;                                 \
-                                                                        \
         if (msr_le) {                                                   \
             index = n_elems - index - 1;                                \
+        }                                                               \
+                                                                        \
+        if (needs_byteswap(env)) {                                      \
             access(env, addr, swap(r->element[LO_IDX ? index :          \
                                               (adjust - index)]));      \
         } else {                                                        \
target-ppc/translate.c +59 -91

303 lines not on this page · raw message

target-ppc/translate_init.c +9 -0
index 4d94015..84381ae 100644
@@ -8418,6 +8418,9 @@ static void ppc_cpu_reset(CPUState *s)
     msr |= (target_ulong)1 << MSR_VR; /* Allow altivec usage */
     msr |= (target_ulong)1 << MSR_SPE; /* Allow SPE usage */
     msr |= (target_ulong)1 << MSR_PR;
+#if !defined(TARGET_WORDS_BIGENDIAN)
+    msr |= (target_ulong)1 << MSR_LE; /* Little-endian user mode */
+#endif
 #endif
 
 #if defined(TARGET_PPC64)
@@ -8461,6 +8464,12 @@ static void ppc_cpu_reset(CPUState *s)
 
     /* Flush all TLBs */
     tlb_flush(s, 1);
+
+#if defined(CONFIG_USER_ONLY) && !defined(TARGET_WORDS_BIGENDIAN)
+    if (!msr_le) {
+        cpu_abort(CPU(cpu), "Cannot set QEMU to little-endian user mode\n");
+    }
+#endif
 }
 
 static void ppc_cpu_initfn(Object *obj)
Signature · 1 line
1.9.1.423.g4596e3a
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/3] linux-user: Support little-endian PPC64 in user mode.

In reply to Doug Kwan
Quoted 7 lines · Doug Kwan
linux-user/uname.c +0 -0
index f5d4c66..cb1f9a3 100644
@@ -65,6 +65,12 @@ const char *cpu_to_uname_machine(void *cpu_env)
         return "i586";
     }

linux-user/uname.c const char *cpu_to_uname_machine(void *cpu_env) · line 76

Quoted 10 lines
linux-user/uname.c +6 -0
     return "i686";
+#elif defined(TARGET_PPC64)
+#ifdef TARGET_WORDS_BIGENDIAN
+    return UNAME_MACHINE;
+#else
+    return UNAME_MACHINE "le";
+#endif
 #else
     /* default is #define-d in each arch/ subdir */
     return UNAME_MACHINE;

I think it would be nicer just to define UNAME_MACHINE correctly in linux-user/ppc/syscall.h. We should restrict the per-CPU ifdefs in uname.c to just those CPUs which need to pick the uname based on runtime CPU features.

thanks
-- PMM

Reviewed-by on v2 3/3
#10 lore raw

Re: [Qemu-devel] [PATCH v2 3/3] Add a new user mode target for little-endian PPC64.

In reply to Doug Kwan
Quoted 30 lines · Doug Kwan
---
 configure                              | 6 ++++++
 default-configs/ppc64le-linux-user.mak | 1 +
 2 files changed, 7 insertions(+)
 create mode 100644 default-configs/ppc64le-linux-user.mak
configure +6 -0
index 46bc0c9..5f0926b 100755
@@ -4912,6 +4912,12 @@ case "$target_name" in
     TARGET_ABI_DIR=ppc
     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
   ;;
+  ppc64le)
+    TARGET_ARCH=ppc64
+    TARGET_BASE_ARCH=ppc
+    TARGET_ABI_DIR=ppc
+    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
+  ;;
   ppc64abi32)
     TARGET_ARCH=ppc64
     TARGET_BASE_ARCH=ppc
default-configs/ppc64le-linux-user.mak new file +0 -0
new file mode 100644
index 0000000..6948225

default-configs/ppc64le-linux-user.mak line 1

Quoted 1 line
default-configs/ppc64le-linux-user.mak new file +1 -0
@@ -0,0 +1 @@
+# Default configuration for ppc64el-linux-user

You forgot to change this "el" to "le". Otherwise

thanks
-- PMM

#3 lore raw

Re: [Qemu-devel] [PATCH v2 1/3] linux-user: Support little-endian PPC64 in user mode.

In reply to Doug Kwan
Quoted 1 line · Doug Kwan

Look at ELF header to determin ABI version on PPC64. This is required

typo: "determine".

Quoted 2 lines

for executing the first instruction correctly. Also print correct machine name in uname() system call.

thanks
-- PMM

#5 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] PPC: Allow little-endian user mode.

In reply to Doug Kwan
Quoted 3 lines · Doug Kwan

This allow running PPC64 little-endian in user mode if target is configured that way. In PPC64 LE user mode we set MSR.LE during initialization. Overhaul handling of byteswapping in code generation and mem helpers.

This looks pretty good to me (I'll let a ppc person do the detailed review). One thing I did spot:

Outside target-ppc/, the other place we do memory accesses is linux-user/main.c:do_store_exclusive(). get_user_u32() and friends will honour TARGET_WORDS_BIGENDIAN, but the 128 bit store exclusive is done with two accesses. The system-emulation mode code handles the LE case by flipping around the register values, so I think the linux-user code will need to do a similar thing.

thanks
-- PMM

#11 lore raw

Re: [Qemu-devel] [PATCH v2 3/3] Add a new user mode target for little-endian PPC64.

In reply to Doug Kwan
Quoted 31 lines · Doug Kwan
---
 configure                              | 6 ++++++
 default-configs/ppc64le-linux-user.mak | 1 +
 2 files changed, 7 insertions(+)
 create mode 100644 default-configs/ppc64le-linux-user.mak
configure +6 -0
index 46bc0c9..5f0926b 100755
@@ -4912,6 +4912,12 @@ case "$target_name" in
     TARGET_ABI_DIR=ppc
     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
   ;;
+  ppc64le)
+    TARGET_ARCH=ppc64
+    TARGET_BASE_ARCH=ppc
+    TARGET_ABI_DIR=ppc
+    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
+  ;;
   ppc64abi32)
     TARGET_ARCH=ppc64
     TARGET_BASE_ARCH=ppc
default-configs/ppc64le-linux-user.mak new file +0 -0
new file mode 100644
index 0000000..6948225

default-configs/ppc64le-linux-user.mak line 1

Quoted 1 line
default-configs/ppc64le-linux-user.mak new file +1 -0
@@ -0,0 +1 @@
+# Default configuration for ppc64el-linux-user

Now that Alex has taken the decimal floating point into his ppc-next tree, we will also want to do this, which will trigger building of the decimal floating point library code:

default-configs/ppc64le-linux-user.mak +1 -0
index 6948225..dacbcab 100644
@@ -1 +1,2 @@
 # Default configuration for ppc64el-linux-user
+CONFIG_LIBDECNUMBER=y

I will change this (along with the "el" remnant") in V3.

#12 lore raw

Re: [Qemu-devel] [PATCH v2 3/3] Add a new user mode target for little-endian PPC64.

Quoted 55 lines · Tom Musta
Quoted 12 lines · Doug Kwan
---
 configure                              | 6 ++++++
 default-configs/ppc64le-linux-user.mak | 1 +
 2 files changed, 7 insertions(+)
 create mode 100644 default-configs/ppc64le-linux-user.mak
configure +0 -0
index 46bc0c9..5f0926b 100755

configure case "$target_name" in · line 4913

Quoted 2 lines
configure +0 -0
@@ -4912,6 +4912,12 @@ case "$target_name" in
     TARGET_ABI_DIR=ppc
     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml

power-spe.xml"

configure case "$target_name" in · line 4919

Quoted 6 lines
configure +5 -0
   ;;
+  ppc64le)
+    TARGET_ARCH=ppc64
+    TARGET_BASE_ARCH=ppc
+    TARGET_ABI_DIR=ppc
+    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml

power-spe.xml"

Review

Quoted 5 lines
configure +1 -0
+  ;;
   ppc64abi32)
     TARGET_ARCH=ppc64
     TARGET_BASE_ARCH=ppc
(quoted diff) +0 -0

b/default-configs/ppc64le-linux-user.mak

default-configs/ppc64le-linux-user.mak line 1

Quoted 7 lines

new file mode 100644
index 0000000..6948225

default-configs/ppc64le-linux-user.mak new file +1 -0
@@ -0,0 +1 @@
+# Default configuration for ppc64el-linux-user

Now that Alex has taken the decimal floating point into his ppc-next tree, we will also want to
do this, which will trigger building of the decimal floating point library code:

default-configs/ppc64le-linux-user.mak +1 -0
index 6948225..dacbcab 100644
@@ -1 +1,2 @@
 # Default configuration for ppc64el-linux-user
+CONFIG_LIBDECNUMBER=y

I will change this (along with the "el" remnant") in V3.

Thank you for taking care of this.

#6 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] PPC: Allow little-endian user mode.

In reply to Doug Kwan
Quoted 11 lines · Doug Kwan

This allow running PPC64 little-endian in user mode if target is configured that way. In PPC64 LE user mode we set MSR.LE during initialization. Overhaul handling of byteswapping in code generation and mem helpers.

---
  target-ppc/mem_helper.c     |  25 ++++++--
  target-ppc/translate.c      | 150 +++++++++++++++++---------------------------
  target-ppc/translate_init.c |   9 +++
  3 files changed, 89 insertions(+), 95 deletions(-)

[...]

Quoted 15 lines
target-ppc/translate_init.c +3 -0
index 4d94015..84381ae 100644
@@ -8418,6 +8418,9 @@ static void ppc_cpu_reset(CPUState *s)
      msr |= (target_ulong)1 << MSR_VR; /* Allow altivec usage */
      msr |= (target_ulong)1 << MSR_SPE; /* Allow SPE usage */
      msr |= (target_ulong)1 << MSR_PR;
+#if !defined(TARGET_WORDS_BIGENDIAN)
+    msr |= (target_ulong)1 << MSR_LE; /* Little-endian user mode */
+#endif
  #endif
 
  #if defined(TARGET_PPC64)

target-ppc/translate_init.c static void ppc_cpu_reset(CPUState *s) · line 8470

Quoted 7 lines
target-ppc/translate_init.c +4 -0
@@ -8461,6 +8464,12 @@ static void ppc_cpu_reset(CPUState *s)
 
      /* Flush all TLBs */
      tlb_flush(s, 1);
+
+#if defined(CONFIG_USER_ONLY) && !defined(TARGET_WORDS_BIGENDIAN)
+    if (!msr_le) {
+        cpu_abort(CPU(cpu), "Cannot set QEMU to little-endian user mode\n");

We don't have this check the other way around, so why do we need it here? How do you ever get to this?

Alex

#13 lore raw
In reply to Doug Kwan
Quoted 9 lines · Doug Kwan

Hi

I have made changes based on comments to the previous set of pathces.

1. Target name is now ppc64le-linux-user.
2. I used a memop mask to avoid generating redundant byteswap pairs that cancel out each other. This is suggested by Peter Maydell.
3. There is code to handle machine name correctly in uname.

Quoted 5 lines

This is not mean to be final though. Tom Musta of IBM kindly offered to help me with this. So I am handling over this set of patches. Tom will continue from this version.

Thanks for all the comments and suggestions so far.

I like the patch set for the most part. I guess in v3 it will be ready for inclusion :).

Alex

#7 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] PPC: Allow little-endian user mode.

In reply to Alexander Graf
Quoted 47 lines · Alexander Graf
Quoted 5 lines · Doug Kwan

This allow running PPC64 little-endian in user mode if target is configured
that way. In PPC64 LE user mode we set MSR.LE during initialization. Overhaul handling of byteswapping in code generation and mem helpers.

Quoted 9 lines
---
  target-ppc/mem_helper.c     |  25 ++++++--
  target-ppc/translate.c      | 150 +++++++++++++++++-------------
--------------
  target-ppc/translate_init.c |   9 +++
  3 files changed, 89 insertions(+), 95 deletions(-)

[...]

diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c

Quoted 13 lines

index 4d94015..84381ae 100644

target-ppc/translate_init.c +3 -0
@@ -8418,6 +8418,9 @@ static void ppc_cpu_reset(CPUState *s)
      msr |= (target_ulong)1 << MSR_VR; /* Allow altivec usage */
      msr |= (target_ulong)1 << MSR_SPE; /* Allow SPE usage */
      msr |= (target_ulong)1 << MSR_PR;
+#if !defined(TARGET_WORDS_BIGENDIAN)
+    msr |= (target_ulong)1 << MSR_LE; /* Little-endian user mode */
+#endif
  #endif
    #if defined(TARGET_PPC64)

target-ppc/translate_init.c static void ppc_cpu_reset(CPUState *s) · line 8471

Quoted 8 lines
target-ppc/translate_init.c +4 -0
@@ -8461,6 +8464,12 @@ static void ppc_cpu_reset(CPUState *s)
        /* Flush all TLBs */
      tlb_flush(s, 1);
+
+#if defined(CONFIG_USER_ONLY) && !defined(TARGET_WORDS_BIGENDIAN)
+    if (!msr_le) {
+        cpu_abort(CPU(cpu), "Cannot set QEMU to little-endian user
 mode\n");
 

We don't have this check the other way around, so why do we need it here? How do you ever get to this?

Quoted 3 lines

Alex

I am just being paranoid as I am new to this code base. The reason why

this is asymmetric because the PPC targets are big-endian by default and I don't know if all CPUs support setting msr.le. If someone specifies a CPU that does not support little-endian mode, I want to stop qemu early with an error. The check can be removed if it is redundant.

#8 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] PPC: Allow little-endian user mode.

Quoted 59 lines · Doug Kwan (關振德)

On Tue, May 13, 2014 at 12:05 AM, Alexander Graf <[email protected] <mailto:[email protected]>> wrote:

    On 10.05.14 11:16, Doug Kwan wrote:

        This allow running PPC64 little-endian in user mode if target
        is configured
        that way.  In PPC64 LE user mode we set MSR.LE during
        initialization.
        Overhaul handling of byteswapping in code generation and mem
        helpers.

        Signed-off-by: Doug Kwan <[email protected]
        <mailto:[email protected]>>
        ---
          target-ppc/mem_helper.c     |  25 ++++++--
          target-ppc/translate.c      | 150
        +++++++++++++++++---------------------------
          target-ppc/translate_init.c |   9 +++
          3 files changed, 89 insertions(+), 95 deletions(-)


    [...]


        diff --git a/target-ppc/translate_init.c
        b/target-ppc/translate_init.c
        index 4d94015..84381ae 100644
        --- a/target-ppc/translate_init.c
        +++ b/target-ppc/translate_init.c
        @@ -8418,6 +8418,9 @@ static void ppc_cpu_reset(CPUState *s)
              msr |= (target_ulong)1 << MSR_VR; /* Allow altivec usage */
              msr |= (target_ulong)1 << MSR_SPE; /* Allow SPE usage */
              msr |= (target_ulong)1 << MSR_PR;
        +#if !defined(TARGET_WORDS_BIGENDIAN)
        +    msr |= (target_ulong)1 << MSR_LE; /* Little-endian user
        mode */
        +#endif
          #endif
            #if defined(TARGET_PPC64)
        @@ -8461,6 +8464,12 @@ static void ppc_cpu_reset(CPUState *s)
                /* Flush all TLBs */
              tlb_flush(s, 1);
        +
        +#if defined(CONFIG_USER_ONLY) && !defined(TARGET_WORDS_BIGENDIAN)
        +    if (!msr_le) {
        +        cpu_abort(CPU(cpu), "Cannot set QEMU to little-endian
        user mode\n");


    We don't have this check the other way around, so why do we need
    it here? How do you ever get to this?


    Alex
Quoted 1 line

I am just being paranoid as I am new to this code base. The reason why this is asymmetric because the PPC targets are big-endian by default and I don't know if all CPUs support setting msr.le. If someone specifies a CPU that does not support little-endian mode, I want to stop qemu early with an error. The check can be removed if it is redundant.

Well, all CPUs that Linux supports with LE today also support the MSR_LE bit. If anyone would ever want to do an e500 LE port things would become messy, as LE is a TLB property there, so we don't have a generic bit to look at.

I think we just drop this check. If the user passes in an incompatible CPU it's his own fault :).

Alex

#14 lore raw
In reply to Alexander Graf
Quoted 15 lines · Alexander Graf
Quoted 13 lines · Doug Kwan

Hi

I have made changes based on comments to the previous set of pathces.

1. Target name is now ppc64le-linux-user.
2. I used a memop mask to avoid generating redundant byteswap pairs that cancel out each other. This is suggested by Peter Maydell.
3. There is code to handle machine name correctly in uname.

This is not mean to be final though. Tom Musta of IBM kindly offered to help me with this. So I am handling over this set of patches. Tom will continue from this version.

Quoted 8 lines
Quoted 1 line

Thanks for all the comments and suggestions so far.

I like the patch set for the most part. I guess in v3 it will be ready for inclusion :).

Alex

Doug & I have agreed that I will take these the rest of the way. I am still testing in a few
environments that are different from Doug's and may have a few additions.

Also, Peter suggested that LTP be run ... I am going to look into this but as a follow-on effort to these patches.