* [Qemu-devel] [PATCH 0/4] Add aarch64_be-linux-user target
@ 2017-12-19 15:16 Michael Weiser
2017-12-19 15:16 ` [Qemu-devel] [PATCH 1/4] linux-user: Add support for big-endian aarch64 Michael Weiser
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: Michael Weiser @ 2017-12-19 15:16 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Weiser, Riku Voipio, Laurent Vivier
Hello,
below patches add support for big-endian aarch64 to linux-user. Almost
everything is already in place. The patches just set up the CPU flags as
required for big-endianess, add a distinction in uname and make sure the
instructions for the signal trampoline end up in memory little-endian.
Finally, configure is extended to allow building of a
aarch64_be-linux-user target.
With this I am able to run individual aarch64_be binaries as well as
chroot into a full-blown aarch64_be userland using binfmt_misc, running
and compiling things (Gentoo crossdev/native).
Thanks,
Michael
Michael Weiser (4):
linux-user: Add support for big-endian aarch64
linux-user: Add separate aarch64_be uname
linux-user: Fix endianess of aarch64 signal trampoline
configure: Add aarch64_be-linux-user target
configure | 9 +++++----
default-configs/aarch64_be-linux-user.mak | 1 +
linux-user/aarch64/target_syscall.h | 4 ++++
linux-user/main.c | 6 ++++++
linux-user/signal.c | 10 +++++++---
5 files changed, 23 insertions(+), 7 deletions(-)
create mode 100644 default-configs/aarch64_be-linux-user.mak
--
2.15.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 1/4] linux-user: Add support for big-endian aarch64
2017-12-19 15:16 [Qemu-devel] [PATCH 0/4] Add aarch64_be-linux-user target Michael Weiser
@ 2017-12-19 15:16 ` Michael Weiser
2017-12-19 15:16 ` [Qemu-devel] [PATCH 2/4] linux-user: Add separate aarch64_be uname Michael Weiser
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Michael Weiser @ 2017-12-19 15:16 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Weiser, Riku Voipio, Laurent Vivier
Enable big-endian mode for data accesses on aarch64 for big-endian linux
user mode. Activate it for all execution levels as documented by ARM:
Set the SCTLR EE bit for ELs 1 through 3. Additionally set bit E0E in
EL1 to enable it in EL0 as well.
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
---
linux-user/main.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/linux-user/main.c b/linux-user/main.c
index 2fd2a143ed..7ea863260d 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4611,6 +4611,12 @@ int main(int argc, char **argv, char **envp)
}
env->pc = regs->pc;
env->xregs[31] = regs->sp;
+#ifdef TARGET_WORDS_BIGENDIAN
+ env->cp15.sctlr_el[1] |= SCTLR_E0E;
+ for (i = 1; i < 4; ++i) {
+ env->cp15.sctlr_el[i] |= SCTLR_EE;
+ }
+#endif
}
#elif defined(TARGET_ARM)
{
--
2.15.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 2/4] linux-user: Add separate aarch64_be uname
2017-12-19 15:16 [Qemu-devel] [PATCH 0/4] Add aarch64_be-linux-user target Michael Weiser
2017-12-19 15:16 ` [Qemu-devel] [PATCH 1/4] linux-user: Add support for big-endian aarch64 Michael Weiser
@ 2017-12-19 15:16 ` Michael Weiser
2017-12-19 15:16 ` [Qemu-devel] [PATCH 3/4] linux-user: Fix endianess of aarch64 signal trampoline Michael Weiser
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Michael Weiser @ 2017-12-19 15:16 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Weiser, Riku Voipio, Laurent Vivier
Make big-endian aarch64 systems identify as aarch64_be as expected by
big-endian userland and toolchains.
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
---
linux-user/aarch64/target_syscall.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/linux-user/aarch64/target_syscall.h b/linux-user/aarch64/target_syscall.h
index 1b62953eeb..604ab99b14 100644
--- a/linux-user/aarch64/target_syscall.h
+++ b/linux-user/aarch64/target_syscall.h
@@ -8,7 +8,11 @@ struct target_pt_regs {
uint64_t pstate;
};
+#if defined(TARGET_WORDS_BIGENDIAN)
+#define UNAME_MACHINE "aarch64_be"
+#else
#define UNAME_MACHINE "aarch64"
+#endif
#define UNAME_MINIMUM_RELEASE "3.8.0"
#define TARGET_CLONE_BACKWARDS
#define TARGET_MINSIGSTKSZ 2048
--
2.15.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 3/4] linux-user: Fix endianess of aarch64 signal trampoline
2017-12-19 15:16 [Qemu-devel] [PATCH 0/4] Add aarch64_be-linux-user target Michael Weiser
2017-12-19 15:16 ` [Qemu-devel] [PATCH 1/4] linux-user: Add support for big-endian aarch64 Michael Weiser
2017-12-19 15:16 ` [Qemu-devel] [PATCH 2/4] linux-user: Add separate aarch64_be uname Michael Weiser
@ 2017-12-19 15:16 ` Michael Weiser
2017-12-19 15:16 ` [Qemu-devel] [PATCH 4/4] configure: Add aarch64_be-linux-user target Michael Weiser
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Michael Weiser @ 2017-12-19 15:16 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Weiser, Riku Voipio, Laurent Vivier
Since for aarch64 the signal trampoline is synthesized directly into the
signal frame we need to make sure the instructions end up little-endian.
Otherwise the wrong endianness will cause a SIGILL upon return from the
signal handler on big-endian targets.
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
---
linux-user/signal.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index dae14d4a89..eb3638f61b 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -1599,9 +1599,13 @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
if (ka->sa_flags & TARGET_SA_RESTORER) {
return_addr = ka->sa_restorer;
} else {
- /* mov x8,#__NR_rt_sigreturn; svc #0 */
- __put_user(0xd2801168, &frame->tramp[0]);
- __put_user(0xd4000001, &frame->tramp[1]);
+ /*
+ * mov x8,#__NR_rt_sigreturn; svc #0
+ * Since these are instructions they need to be put as little-endian
+ * regardless of target default or current CPU endianness.
+ */
+ __put_user_e(0xd2801168, &frame->tramp[0], le);
+ __put_user_e(0xd4000001, &frame->tramp[1], le);
return_addr = frame_addr + offsetof(struct target_rt_sigframe, tramp);
}
env->xregs[0] = usig;
--
2.15.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 4/4] configure: Add aarch64_be-linux-user target
2017-12-19 15:16 [Qemu-devel] [PATCH 0/4] Add aarch64_be-linux-user target Michael Weiser
` (2 preceding siblings ...)
2017-12-19 15:16 ` [Qemu-devel] [PATCH 3/4] linux-user: Fix endianess of aarch64 signal trampoline Michael Weiser
@ 2017-12-19 15:16 ` Michael Weiser
2017-12-19 16:17 ` [Qemu-devel] [PATCH 0/4] " Laurent Vivier
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Michael Weiser @ 2017-12-19 15:16 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Weiser, Riku Voipio, Laurent Vivier
Add target aarch64_be-linux-user. This allows a qemu-aarch64_be binary
to be built that will run big-endian aarch64 binaries.
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
---
configure | 9 +++++----
default-configs/aarch64_be-linux-user.mak | 1 +
2 files changed, 6 insertions(+), 4 deletions(-)
create mode 100644 default-configs/aarch64_be-linux-user.mak
diff --git a/configure b/configure
index 9c8aa5a98b..03d95340d8 100755
--- a/configure
+++ b/configure
@@ -657,7 +657,7 @@ case "$cpu" in
cpu="arm"
supported_cpu="yes"
;;
- aarch64)
+ aarch64|aarch64_be)
cpu="aarch64"
supported_cpu="yes"
;;
@@ -6345,7 +6345,7 @@ if test "$linux" = "yes" ; then
s390x)
linux_arch=s390
;;
- aarch64)
+ aarch64|aarch64_be)
linux_arch=arm64
;;
mips64)
@@ -6369,7 +6369,7 @@ target_name=$(echo $target | cut -d '-' -f 1)
target_bigendian="no"
case "$target_name" in
- armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
+ armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
target_bigendian=yes
;;
esac
@@ -6424,7 +6424,8 @@ case "$target_name" in
mttcg="yes"
gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
;;
- aarch64)
+ aarch64|aarch64_be)
+ TARGET_ARCH=aarch64
TARGET_BASE_ARCH=arm
bflt="yes"
mttcg="yes"
diff --git a/default-configs/aarch64_be-linux-user.mak b/default-configs/aarch64_be-linux-user.mak
new file mode 100644
index 0000000000..a69d9d2e41
--- /dev/null
+++ b/default-configs/aarch64_be-linux-user.mak
@@ -0,0 +1 @@
+# Default configuration for aarch64_be-linux-user
--
2.15.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 0/4] Add aarch64_be-linux-user target
2017-12-19 15:16 [Qemu-devel] [PATCH 0/4] Add aarch64_be-linux-user target Michael Weiser
` (3 preceding siblings ...)
2017-12-19 15:16 ` [Qemu-devel] [PATCH 4/4] configure: Add aarch64_be-linux-user target Michael Weiser
@ 2017-12-19 16:17 ` Laurent Vivier
2017-12-19 20:15 ` Michael Weiser
2017-12-19 17:00 ` no-reply
2017-12-20 16:52 ` Richard Henderson
6 siblings, 1 reply; 9+ messages in thread
From: Laurent Vivier @ 2017-12-19 16:17 UTC (permalink / raw)
To: Michael Weiser, qemu-devel; +Cc: Riku Voipio
Le 19/12/2017 à 16:16, Michael Weiser a écrit :
> Hello,
>
> below patches add support for big-endian aarch64 to linux-user. Almost
> everything is already in place. The patches just set up the CPU flags as
> required for big-endianess, add a distinction in uname and make sure the
> instructions for the signal trampoline end up in memory little-endian.
> Finally, configure is extended to allow building of a
> aarch64_be-linux-user target.
>
> With this I am able to run individual aarch64_be binaries as well as
> chroot into a full-blown aarch64_be userland using binfmt_misc, running
> and compiling things (Gentoo crossdev/native).
Could you also update scripts/qemu-binfmt-conf.sh for the aarch64_be magic?
Thanks,
Laurent
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 0/4] Add aarch64_be-linux-user target
2017-12-19 15:16 [Qemu-devel] [PATCH 0/4] Add aarch64_be-linux-user target Michael Weiser
` (4 preceding siblings ...)
2017-12-19 16:17 ` [Qemu-devel] [PATCH 0/4] " Laurent Vivier
@ 2017-12-19 17:00 ` no-reply
2017-12-20 16:52 ` Richard Henderson
6 siblings, 0 replies; 9+ messages in thread
From: no-reply @ 2017-12-19 17:00 UTC (permalink / raw)
To: michael.weiser; +Cc: famz, qemu-devel, riku.voipio, laurent
Hi,
This series seems to have some coding style problems. See output below for
more information:
Type: series
Message-id: 20171219151636.5162-1-michael.weiser@gmx.de
Subject: [Qemu-devel] [PATCH 0/4] Add aarch64_be-linux-user target
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))
done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
5ac57ff210 configure: Add aarch64_be-linux-user target
07335652c6 linux-user: Fix endianess of aarch64 signal trampoline
ee4c6e2e72 linux-user: Add separate aarch64_be uname
1b214cd96a linux-user: Add support for big-endian aarch64
=== OUTPUT BEGIN ===
Checking PATCH 1/4: linux-user: Add support for big-endian aarch64...
Checking PATCH 2/4: linux-user: Add separate aarch64_be uname...
Checking PATCH 3/4: linux-user: Fix endianess of aarch64 signal trampoline...
ERROR: code indent should never use tabs
#26: FILE: linux-user/signal.c:1603:
+^I * mov x8,#__NR_rt_sigreturn; svc #0$
ERROR: code indent should never use tabs
#27: FILE: linux-user/signal.c:1604:
+^I * Since these are instructions they need to be put as little-endian$
ERROR: code indent should never use tabs
#28: FILE: linux-user/signal.c:1605:
+^I * regardless of target default or current CPU endianness.$
ERROR: code indent should never use tabs
#29: FILE: linux-user/signal.c:1606:
+^I */$
total: 4 errors, 0 warnings, 16 lines checked
Your patch has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 4/4: configure: Add aarch64_be-linux-user target...
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 0/4] Add aarch64_be-linux-user target
2017-12-19 16:17 ` [Qemu-devel] [PATCH 0/4] " Laurent Vivier
@ 2017-12-19 20:15 ` Michael Weiser
0 siblings, 0 replies; 9+ messages in thread
From: Michael Weiser @ 2017-12-19 20:15 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel, Riku Voipio
Hello Laurent,
On Tue, Dec 19, 2017 at 05:17:35PM +0100, Laurent Vivier wrote:
> > below patches add support for big-endian aarch64 to linux-user. Almost
> Could you also update scripts/qemu-binfmt-conf.sh for the aarch64_be magic?
Done. v2 forthcoming.
--
Bye,
Michael
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 0/4] Add aarch64_be-linux-user target
2017-12-19 15:16 [Qemu-devel] [PATCH 0/4] Add aarch64_be-linux-user target Michael Weiser
` (5 preceding siblings ...)
2017-12-19 17:00 ` no-reply
@ 2017-12-20 16:52 ` Richard Henderson
6 siblings, 0 replies; 9+ messages in thread
From: Richard Henderson @ 2017-12-20 16:52 UTC (permalink / raw)
To: Michael Weiser, qemu-devel; +Cc: Riku Voipio, Laurent Vivier
On 12/19/2017 07:16 AM, Michael Weiser wrote:
> Michael Weiser (4):
> linux-user: Add support for big-endian aarch64
> linux-user: Add separate aarch64_be uname
> linux-user: Fix endianess of aarch64 signal trampoline
> configure: Add aarch64_be-linux-user target
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-12-20 20:48 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-19 15:16 [Qemu-devel] [PATCH 0/4] Add aarch64_be-linux-user target Michael Weiser
2017-12-19 15:16 ` [Qemu-devel] [PATCH 1/4] linux-user: Add support for big-endian aarch64 Michael Weiser
2017-12-19 15:16 ` [Qemu-devel] [PATCH 2/4] linux-user: Add separate aarch64_be uname Michael Weiser
2017-12-19 15:16 ` [Qemu-devel] [PATCH 3/4] linux-user: Fix endianess of aarch64 signal trampoline Michael Weiser
2017-12-19 15:16 ` [Qemu-devel] [PATCH 4/4] configure: Add aarch64_be-linux-user target Michael Weiser
2017-12-19 16:17 ` [Qemu-devel] [PATCH 0/4] " Laurent Vivier
2017-12-19 20:15 ` Michael Weiser
2017-12-19 17:00 ` no-reply
2017-12-20 16:52 ` Richard Henderson
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).