On 13.05.14 09:30, Doug Kwan (關振德) wrote:
On Tue, May 13, 2014 at 12:05 AM, Alexander Graf <ag...@suse.de
<mailto:ag...@suse.de>> 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 <dougk...@google.com
<mailto:dougk...@google.com>>
---
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
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