* [kvm-unit-tests PATCH v3 0/2] powerpc: add little-endian support
@ 2016-02-29 17:49 Laurent Vivier
2016-02-29 17:49 ` [kvm-unit-tests PATCH v3 1/2] powerpc: add asm/ppc_asm.h Laurent Vivier
2016-02-29 17:49 ` [kvm-unit-tests PATCH v3 2/2] powerpc: select endianness Laurent Vivier
0 siblings, 2 replies; 9+ messages in thread
From: Laurent Vivier @ 2016-02-29 17:49 UTC (permalink / raw)
To: kvm, kvm-ppc; +Cc: drjones, thuth, dgibson, agraf, pbonzini, Laurent Vivier
It allows to build and use little-endian kvm-unit-tests on
big and little endian hosts.
The series is also available from:
https://github.com/vivier/kvm-unit-tests/commits/ppc64/endianness-v3
v3: rebase on master
rename RETURN_FROM_BE to FIXUP_ENDIAN
remove B_BE
restore Makefie.$(ARCH)
compile boot_rom.elf only with "-mbig-endian" C flag
force to use "--endian" with ppc64
add a patch to create ppc_asm.h (and move some code)
v2: replace FIXUP_ENDIAN from linux by a home made version
(B_BE and RETURN_FROM_BE)
Laurent Vivier (2):
powerpc: add asm/ppc_asm.h
powerpc: select endianness
configure | 11 +++++++++++
lib/powerpc/asm/ppc_asm.h | 33 +++++++++++++++++++++++++++++++++
lib/ppc64/asm/io.h | 8 ++++++++
lib/ppc64/asm/ppc_asm.h | 1 +
powerpc/Makefile.common | 3 ++-
powerpc/Makefile.ppc64 | 9 +++++++--
powerpc/cstart64.S | 31 +++++++++++++++++--------------
7 files changed, 79 insertions(+), 17 deletions(-)
create mode 100644 lib/powerpc/asm/ppc_asm.h
create mode 100644 lib/ppc64/asm/ppc_asm.h
--
2.5.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [kvm-unit-tests PATCH v3 1/2] powerpc: add asm/ppc_asm.h
2016-02-29 17:49 [kvm-unit-tests PATCH v3 0/2] powerpc: add little-endian support Laurent Vivier
@ 2016-02-29 17:49 ` Laurent Vivier
2016-02-29 18:56 ` Andrew Jones
2016-03-01 8:30 ` Thomas Huth
2016-02-29 17:49 ` [kvm-unit-tests PATCH v3 2/2] powerpc: select endianness Laurent Vivier
1 sibling, 2 replies; 9+ messages in thread
From: Laurent Vivier @ 2016-02-29 17:49 UTC (permalink / raw)
To: kvm, kvm-ppc; +Cc: drjones, thuth, dgibson, agraf, pbonzini, Laurent Vivier
Move LOAD_REG_IMMEDIATE() and LOAD_REG_ADDR()
from cstart64.S to ppc_asm.h
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
lib/powerpc/asm/ppc_asm.h | 14 ++++++++++++++
lib/ppc64/asm/ppc_asm.h | 1 +
powerpc/cstart64.S | 11 +----------
3 files changed, 16 insertions(+), 10 deletions(-)
create mode 100644 lib/powerpc/asm/ppc_asm.h
create mode 100644 lib/ppc64/asm/ppc_asm.h
diff --git a/lib/powerpc/asm/ppc_asm.h b/lib/powerpc/asm/ppc_asm.h
new file mode 100644
index 0000000..f63bb72
--- /dev/null
+++ b/lib/powerpc/asm/ppc_asm.h
@@ -0,0 +1,14 @@
+#ifndef _ASMPOWERPC_PPC_ASM_H
+#define _ASMPOWERPC_PPC_ASM_H
+
+#define LOAD_REG_IMMEDIATE(reg,expr) \
+ lis reg,(expr)@highest; \
+ ori reg,reg,(expr)@higher; \
+ rldicr reg,reg,32,31; \
+ oris reg,reg,(expr)@h; \
+ ori reg,reg,(expr)@l;
+
+#define LOAD_REG_ADDR(reg,name) \
+ ld reg,name@got(r2)
+
+#endif /* _ASMPOWERPC_PPC_ASM_H */
diff --git a/lib/ppc64/asm/ppc_asm.h b/lib/ppc64/asm/ppc_asm.h
new file mode 100644
index 0000000..e3929ee
--- /dev/null
+++ b/lib/ppc64/asm/ppc_asm.h
@@ -0,0 +1 @@
+#include "../../powerpc/asm/ppc_asm.h"
diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
index 4693ba1..6072597 100644
--- a/powerpc/cstart64.S
+++ b/powerpc/cstart64.S
@@ -7,16 +7,7 @@
*/
#define __ASSEMBLY__
#include <asm/hcall.h>
-
-#define LOAD_REG_IMMEDIATE(reg,expr) \
- lis reg,(expr)@highest; \
- ori reg,reg,(expr)@higher; \
- rldicr reg,reg,32,31; \
- oris reg,reg,(expr)@h; \
- ori reg,reg,(expr)@l;
-
-#define LOAD_REG_ADDR(reg,name) \
- ld reg,name@got(r2)
+#include <asm/ppc_asm.h>
.section .init
--
2.5.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [kvm-unit-tests PATCH v3 2/2] powerpc: select endianness
2016-02-29 17:49 [kvm-unit-tests PATCH v3 0/2] powerpc: add little-endian support Laurent Vivier
2016-02-29 17:49 ` [kvm-unit-tests PATCH v3 1/2] powerpc: add asm/ppc_asm.h Laurent Vivier
@ 2016-02-29 17:49 ` Laurent Vivier
2016-02-29 19:44 ` Andrew Jones
2016-03-01 8:40 ` Thomas Huth
1 sibling, 2 replies; 9+ messages in thread
From: Laurent Vivier @ 2016-02-29 17:49 UTC (permalink / raw)
To: kvm, kvm-ppc; +Cc: drjones, thuth, dgibson, agraf, pbonzini, Laurent Vivier
This patch allows to build tests for ppc64 little endian target
(ppc64le) on big and little endian hosts.
We add a new parameter to configure to select the endianness of the
tests (--endian=little or --endian=big).
I have built and tested big and little endian tests on a little
endian host, a big endian host, with kvm_hv and kvm_pr, and on
x86_64 with ppc64 as a TCG target.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
configure | 11 +++++++++++
lib/powerpc/asm/ppc_asm.h | 19 +++++++++++++++++++
lib/ppc64/asm/io.h | 8 ++++++++
powerpc/Makefile.common | 3 ++-
powerpc/Makefile.ppc64 | 9 +++++++--
powerpc/cstart64.S | 20 ++++++++++++++++----
6 files changed, 63 insertions(+), 7 deletions(-)
diff --git a/configure b/configure
index a685cca..90e39d4 100755
--- a/configure
+++ b/configure
@@ -10,6 +10,7 @@ ar=ar
arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/'`
host=$arch
cross_prefix+endian=""
usage() {
cat <<-EOF
@@ -23,6 +24,7 @@ usage() {
--ld=LD ld linker to use ($ld)
--prefix=PREFIX where to install things ($prefix)
--kerneldir=DIR kernel build directory for kvm.h ($kerneldir)
+ --endian=ENDIAN endianness to compile for (little or big, ppc64 only)
EOF
exit 1
}
@@ -50,6 +52,9 @@ while [[ "$1" = -* ]]; do
--cross-prefix)
cross_prefix="$arg"
;;
+ --endian)
+ endian="$arg"
+ ;;
--cc)
cc="$arg"
;;
@@ -84,6 +89,11 @@ elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
elif [ "$arch" = "ppc64" ]; then
testdir=powerpc
firmware="$testdir/boot_rom.bin"
+ if [ "$endian" != "little" ] && [ "$endian" != "big" ]; then
+ echo "You must provide endianness (big or little)!"
+ usage
+ exit 1
+ fi
else
testdir=$arch
fi
@@ -139,4 +149,5 @@ AR=$cross_prefix$ar
API=$api
TEST_DIR=$testdir
FIRMWARE=$firmware
+ENDIAN=$endian
EOF
diff --git a/lib/powerpc/asm/ppc_asm.h b/lib/powerpc/asm/ppc_asm.h
index f63bb72..f18100e 100644
--- a/lib/powerpc/asm/ppc_asm.h
+++ b/lib/powerpc/asm/ppc_asm.h
@@ -11,4 +11,23 @@
#define LOAD_REG_ADDR(reg,name) \
ld reg,name@got(r2)
+#if __BYTE_ORDER__ = __ORDER_BIG_ENDIAN__
+
+#define FIXUP_ENDIAN
+
+#elif __BYTE_ORDER__ = __ORDER_LITTLE_ENDIAN__
+
+#define FIXUP_ENDIAN \
+ .long 0x05000048; /* bl . + 4 */ \
+ .long 0xa602487d; /* mflr r10 */ \
+ .long 0x20004a39; /* addi r10,r10,32 */ \
+ .long 0xa600607d; /* mfmsr r11 */ \
+ .long 0x01006b69; /* xori r11,r11,1 */ \
+ .long 0xa6035a7d; /* mtsrr0 r10 */ \
+ .long 0xa6037b7d; /* mtsrr1 r11 */ \
+ .long 0x2400004c; /* rfid */ \
+ .long 0x00000048; /* b . */ \
+
+#endif /* __BYTE_ORDER__ */
+
#endif /* _ASMPOWERPC_PPC_ASM_H */
diff --git a/lib/ppc64/asm/io.h b/lib/ppc64/asm/io.h
index c0801d4..4f2c31b 100644
--- a/lib/ppc64/asm/io.h
+++ b/lib/ppc64/asm/io.h
@@ -1,5 +1,13 @@
#ifndef _ASMPPC64_IO_H_
#define _ASMPPC64_IO_H_
+
+#if __BYTE_ORDER__ = __ORDER_LITTLE_ENDIAN__
+#define __cpu_is_be() (0)
+#elif __BYTE_ORDER__ = __ORDER_BIG_ENDIAN__
#define __cpu_is_be() (1)
+#else
+#error Undefined byte order
+#endif
+
#include <asm-generic/io.h>
#endif
diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index cc27ac8..b526668 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -11,7 +11,6 @@ all: $(TEST_DIR)/boot_rom.bin test_cases
##################################################################
-CFLAGS += $(arch_CFLAGS)
CFLAGS += -std=gnu99
CFLAGS += -ffreestanding
CFLAGS += -Wextra
@@ -32,6 +31,7 @@ cflatobjs += lib/powerpc/setup.o
cflatobjs += lib/powerpc/rtas.o
FLATLIBS = $(libcflat) $(LIBFDT_archive)
+%.elf: CFLAGS += $(arch_CFLAGS)
%.elf: LDFLAGS = $(arch_LDFLAGS) -nostdlib -pie
%.elf: %.o $(FLATLIBS) powerpc/flat.lds
$(LD) $(LDFLAGS) -o $@ \
@@ -48,6 +48,7 @@ $(TEST_DIR)/boot_rom.bin: $(TEST_DIR)/boot_rom.elf
dd if=/dev/zero of=$@ bs%6 count=1
$(OBJCOPY) -O binary $^ >(cat - >>$@)
+$(TEST_DIR)/boot_rom.elf: CFLAGS = -mbig-endian
$(TEST_DIR)/boot_rom.elf: $(TEST_DIR)/boot_rom.o
$(LD) -EB -nostdlib -Ttext=0x100 --entry=start --build-id=none -o $@ $<
diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
index 2df44d4..3da3a83 100644
--- a/powerpc/Makefile.ppc64
+++ b/powerpc/Makefile.ppc64
@@ -5,8 +5,13 @@
#
bits = 64
-arch_CFLAGS = -mbig-endian
-arch_LDFLAGS = -EB
+ifeq ($(ENDIAN),little)
+ arch_CFLAGS = -mlittle-endian
+ arch_LDFLAGS = -EL
+else
+ arch_CFLAGS = -mbig-endian
+ arch_LDFLAGS = -EB
+endif
cstart.o = $(TEST_DIR)/cstart64.o
reloc.o = $(TEST_DIR)/reloc64.o
diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
index 6072597..62078a4 100644
--- a/powerpc/cstart64.S
+++ b/powerpc/cstart64.S
@@ -16,6 +16,7 @@
*/
.globl start
start:
+ FIXUP_ENDIAN
/*
* We were loaded at QEMU's kernel load address, but we're not
* allowed to link there due to how QEMU deals with linker VMAs,
@@ -84,12 +85,23 @@ halt:
enter_rtas:
mflr r0
std r0, 16(r1)
+
+ LOAD_REG_ADDR(r10, rtas_return_loc)
+ mtlr r10
LOAD_REG_ADDR(r11, rtas_entry)
ld r10, 0(r11)
-//FIXME: change this bctrl to an rtas-prep, rfid, rtas-return sequence
- mtctr r10
- nop
- bctrl
+
+ mfmsr r11
+#if __BYTE_ORDER__ = __ORDER_LITTLE_ENDIAN__
+ xori r11,r11,1
+#endif
+ mtsrr0 r10
+ mtsrr1 r11
+ rfid
+ b .
+
+rtas_return_loc:
+ FIXUP_ENDIAN
ld r0, 16(r1)
mtlr r0
blr
--
2.5.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [kvm-unit-tests PATCH v3 1/2] powerpc: add asm/ppc_asm.h
2016-02-29 17:49 ` [kvm-unit-tests PATCH v3 1/2] powerpc: add asm/ppc_asm.h Laurent Vivier
@ 2016-02-29 18:56 ` Andrew Jones
2016-03-01 8:30 ` Thomas Huth
1 sibling, 0 replies; 9+ messages in thread
From: Andrew Jones @ 2016-02-29 18:56 UTC (permalink / raw)
To: Laurent Vivier; +Cc: kvm, kvm-ppc, thuth, dgibson, agraf, pbonzini
On Mon, Feb 29, 2016 at 06:49:05PM +0100, Laurent Vivier wrote:
> Move LOAD_REG_IMMEDIATE() and LOAD_REG_ADDR()
> from cstart64.S to ppc_asm.h
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [kvm-unit-tests PATCH v3 2/2] powerpc: select endianness
2016-02-29 17:49 ` [kvm-unit-tests PATCH v3 2/2] powerpc: select endianness Laurent Vivier
@ 2016-02-29 19:44 ` Andrew Jones
2016-03-01 8:12 ` Laurent Vivier
2016-03-01 8:40 ` Thomas Huth
1 sibling, 1 reply; 9+ messages in thread
From: Andrew Jones @ 2016-02-29 19:44 UTC (permalink / raw)
To: Laurent Vivier; +Cc: kvm, kvm-ppc, thuth, dgibson, agraf, pbonzini
On Mon, Feb 29, 2016 at 06:49:06PM +0100, Laurent Vivier wrote:
> This patch allows to build tests for ppc64 little endian target
> (ppc64le) on big and little endian hosts.
>
> We add a new parameter to configure to select the endianness of the
> tests (--endian=little or --endian=big).
>
> I have built and tested big and little endian tests on a little
> endian host, a big endian host, with kvm_hv and kvm_pr, and on
> x86_64 with ppc64 as a TCG target.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> configure | 11 +++++++++++
> lib/powerpc/asm/ppc_asm.h | 19 +++++++++++++++++++
> lib/ppc64/asm/io.h | 8 ++++++++
> powerpc/Makefile.common | 3 ++-
> powerpc/Makefile.ppc64 | 9 +++++++--
> powerpc/cstart64.S | 20 ++++++++++++++++----
> 6 files changed, 63 insertions(+), 7 deletions(-)
>
> diff --git a/configure b/configure
> index a685cca..90e39d4 100755
> --- a/configure
> +++ b/configure
> @@ -10,6 +10,7 @@ ar=ar
> arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/'`
> host=$arch
> cross_prefix> +endian=""
>
> usage() {
> cat <<-EOF
> @@ -23,6 +24,7 @@ usage() {
> --ld=LD ld linker to use ($ld)
> --prefix=PREFIX where to install things ($prefix)
> --kerneldir=DIR kernel build directory for kvm.h ($kerneldir)
> + --endian=ENDIAN endianness to compile for (little or big, ppc64 only)
> EOF
> exit 1
> }
> @@ -50,6 +52,9 @@ while [[ "$1" = -* ]]; do
> --cross-prefix)
> cross_prefix="$arg"
> ;;
> + --endian)
> + endian="$arg"
> + ;;
> --cc)
> cc="$arg"
> ;;
> @@ -84,6 +89,11 @@ elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
> elif [ "$arch" = "ppc64" ]; then
> testdir=powerpc
> firmware="$testdir/boot_rom.bin"
> + if [ "$endian" != "little" ] && [ "$endian" != "big" ]; then
> + echo "You must provide endianness (big or little)!"
> + usage
> + exit 1
redundant 'exit 1', usage() already has one in it
> + fi
> else
> testdir=$arch
> fi
> @@ -139,4 +149,5 @@ AR=$cross_prefix$ar
> API=$api
> TEST_DIR=$testdir
> FIRMWARE=$firmware
> +ENDIAN=$endian
> EOF
> diff --git a/lib/powerpc/asm/ppc_asm.h b/lib/powerpc/asm/ppc_asm.h
> index f63bb72..f18100e 100644
> --- a/lib/powerpc/asm/ppc_asm.h
> +++ b/lib/powerpc/asm/ppc_asm.h
> @@ -11,4 +11,23 @@
> #define LOAD_REG_ADDR(reg,name) \
> ld reg,name@got(r2)
>
> +#if __BYTE_ORDER__ = __ORDER_BIG_ENDIAN__
> +
> +#define FIXUP_ENDIAN
> +
> +#elif __BYTE_ORDER__ = __ORDER_LITTLE_ENDIAN__
> +
> +#define FIXUP_ENDIAN \
> + .long 0x05000048; /* bl . + 4 */ \
> + .long 0xa602487d; /* mflr r10 */ \
> + .long 0x20004a39; /* addi r10,r10,32 */ \
> + .long 0xa600607d; /* mfmsr r11 */ \
> + .long 0x01006b69; /* xori r11,r11,1 */ \
> + .long 0xa6035a7d; /* mtsrr0 r10 */ \
> + .long 0xa6037b7d; /* mtsrr1 r11 */ \
> + .long 0x2400004c; /* rfid */ \
> + .long 0x00000048; /* b . */ \
> +
> +#endif /* __BYTE_ORDER__ */
> +
> #endif /* _ASMPOWERPC_PPC_ASM_H */
> diff --git a/lib/ppc64/asm/io.h b/lib/ppc64/asm/io.h
> index c0801d4..4f2c31b 100644
> --- a/lib/ppc64/asm/io.h
> +++ b/lib/ppc64/asm/io.h
> @@ -1,5 +1,13 @@
> #ifndef _ASMPPC64_IO_H_
> #define _ASMPPC64_IO_H_
> +
> +#if __BYTE_ORDER__ = __ORDER_LITTLE_ENDIAN__
> +#define __cpu_is_be() (0)
> +#elif __BYTE_ORDER__ = __ORDER_BIG_ENDIAN__
> #define __cpu_is_be() (1)
> +#else
> +#error Undefined byte order
> +#endif
> +
> #include <asm-generic/io.h>
> #endif
> diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
> index cc27ac8..b526668 100644
> --- a/powerpc/Makefile.common
> +++ b/powerpc/Makefile.common
> @@ -11,7 +11,6 @@ all: $(TEST_DIR)/boot_rom.bin test_cases
>
> ##################################################################
>
> -CFLAGS += $(arch_CFLAGS)
> CFLAGS += -std=gnu99
> CFLAGS += -ffreestanding
> CFLAGS += -Wextra
> @@ -32,6 +31,7 @@ cflatobjs += lib/powerpc/setup.o
> cflatobjs += lib/powerpc/rtas.o
>
> FLATLIBS = $(libcflat) $(LIBFDT_archive)
> +%.elf: CFLAGS += $(arch_CFLAGS)
> %.elf: LDFLAGS = $(arch_LDFLAGS) -nostdlib -pie
> %.elf: %.o $(FLATLIBS) powerpc/flat.lds
> $(LD) $(LDFLAGS) -o $@ \
> @@ -48,6 +48,7 @@ $(TEST_DIR)/boot_rom.bin: $(TEST_DIR)/boot_rom.elf
> dd if=/dev/zero of=$@ bs%6 count=1
> $(OBJCOPY) -O binary $^ >(cat - >>$@)
>
> +$(TEST_DIR)/boot_rom.elf: CFLAGS = -mbig-endian
> $(TEST_DIR)/boot_rom.elf: $(TEST_DIR)/boot_rom.o
> $(LD) -EB -nostdlib -Ttext=0x100 --entry=start --build-id=none -o $@ $<
>
> diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
> index 2df44d4..3da3a83 100644
> --- a/powerpc/Makefile.ppc64
> +++ b/powerpc/Makefile.ppc64
> @@ -5,8 +5,13 @@
> #
> bits = 64
>
> -arch_CFLAGS = -mbig-endian
> -arch_LDFLAGS = -EB
> +ifeq ($(ENDIAN),little)
> + arch_CFLAGS = -mlittle-endian
> + arch_LDFLAGS = -EL
> +else
> + arch_CFLAGS = -mbig-endian
> + arch_LDFLAGS = -EB
> +endif
>
> cstart.o = $(TEST_DIR)/cstart64.o
> reloc.o = $(TEST_DIR)/reloc64.o
> diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
> index 6072597..62078a4 100644
> --- a/powerpc/cstart64.S
> +++ b/powerpc/cstart64.S
> @@ -16,6 +16,7 @@
> */
> .globl start
> start:
> + FIXUP_ENDIAN
> /*
> * We were loaded at QEMU's kernel load address, but we're not
> * allowed to link there due to how QEMU deals with linker VMAs,
> @@ -84,12 +85,23 @@ halt:
> enter_rtas:
> mflr r0
> std r0, 16(r1)
> +
> + LOAD_REG_ADDR(r10, rtas_return_loc)
> + mtlr r10
> LOAD_REG_ADDR(r11, rtas_entry)
> ld r10, 0(r11)
> -//FIXME: change this bctrl to an rtas-prep, rfid, rtas-return sequence
> - mtctr r10
> - nop
> - bctrl
> +
> + mfmsr r11
> +#if __BYTE_ORDER__ = __ORDER_LITTLE_ENDIAN__
> + xori r11,r11,1
> +#endif
We can avoid the #if.
LOAD_REG_IMMEDIATE(r9, RTAS_MSR_MASK)
and r11, r11, r9
Right now we'll define RTAS_MSR_MASK to the boring value of
0xfffffffffffffffe, but presumably that'll change some day.
> + mtsrr0 r10
> + mtsrr1 r11
> + rfid
> + b .
> +
> +rtas_return_loc:
> + FIXUP_ENDIAN
> ld r0, 16(r1)
> mtlr r0
> blr
> --
> 2.5.0
Thanks,
drew
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [kvm-unit-tests PATCH v3 2/2] powerpc: select endianness
2016-02-29 19:44 ` Andrew Jones
@ 2016-03-01 8:12 ` Laurent Vivier
0 siblings, 0 replies; 9+ messages in thread
From: Laurent Vivier @ 2016-03-01 8:12 UTC (permalink / raw)
To: Andrew Jones; +Cc: kvm, kvm-ppc, thuth, dgibson, agraf, pbonzini
On 29/02/2016 20:44, Andrew Jones wrote:
> On Mon, Feb 29, 2016 at 06:49:06PM +0100, Laurent Vivier wrote:
>> This patch allows to build tests for ppc64 little endian target
>> (ppc64le) on big and little endian hosts.
>>
>> We add a new parameter to configure to select the endianness of the
>> tests (--endian=little or --endian=big).
>>
>> I have built and tested big and little endian tests on a little
>> endian host, a big endian host, with kvm_hv and kvm_pr, and on
>> x86_64 with ppc64 as a TCG target.
>>
>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
>> ---
>> configure | 11 +++++++++++
>> lib/powerpc/asm/ppc_asm.h | 19 +++++++++++++++++++
>> lib/ppc64/asm/io.h | 8 ++++++++
>> powerpc/Makefile.common | 3 ++-
>> powerpc/Makefile.ppc64 | 9 +++++++--
>> powerpc/cstart64.S | 20 ++++++++++++++++----
>> 6 files changed, 63 insertions(+), 7 deletions(-)
>>
>> diff --git a/configure b/configure
>> index a685cca..90e39d4 100755
>> --- a/configure
>> +++ b/configure
>> @@ -10,6 +10,7 @@ ar=ar
>> arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/'`
>> host=$arch
>> cross_prefix>> +endian=""
>>
>> usage() {
>> cat <<-EOF
>> @@ -23,6 +24,7 @@ usage() {
>> --ld=LD ld linker to use ($ld)
>> --prefix=PREFIX where to install things ($prefix)
>> --kerneldir=DIR kernel build directory for kvm.h ($kerneldir)
>> + --endian=ENDIAN endianness to compile for (little or big, ppc64 only)
>> EOF
>> exit 1
>> }
>> @@ -50,6 +52,9 @@ while [[ "$1" = -* ]]; do
>> --cross-prefix)
>> cross_prefix="$arg"
>> ;;
>> + --endian)
>> + endian="$arg"
>> + ;;
>> --cc)
>> cc="$arg"
>> ;;
>> @@ -84,6 +89,11 @@ elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
>> elif [ "$arch" = "ppc64" ]; then
>> testdir=powerpc
>> firmware="$testdir/boot_rom.bin"
>> + if [ "$endian" != "little" ] && [ "$endian" != "big" ]; then
>> + echo "You must provide endianness (big or little)!"
>> + usage
>> + exit 1
>
> redundant 'exit 1', usage() already has one in it
OK
>
>> + fi
>> else
>> testdir=$arch
>> fi
>> @@ -139,4 +149,5 @@ AR=$cross_prefix$ar
>> API=$api
>> TEST_DIR=$testdir
>> FIRMWARE=$firmware
>> +ENDIAN=$endian
>> EOF
>> diff --git a/lib/powerpc/asm/ppc_asm.h b/lib/powerpc/asm/ppc_asm.h
>> index f63bb72..f18100e 100644
>> --- a/lib/powerpc/asm/ppc_asm.h
>> +++ b/lib/powerpc/asm/ppc_asm.h
>> @@ -11,4 +11,23 @@
>> #define LOAD_REG_ADDR(reg,name) \
>> ld reg,name@got(r2)
>>
>> +#if __BYTE_ORDER__ = __ORDER_BIG_ENDIAN__
>> +
>> +#define FIXUP_ENDIAN
>> +
>> +#elif __BYTE_ORDER__ = __ORDER_LITTLE_ENDIAN__
>> +
>> +#define FIXUP_ENDIAN \
>> + .long 0x05000048; /* bl . + 4 */ \
>> + .long 0xa602487d; /* mflr r10 */ \
>> + .long 0x20004a39; /* addi r10,r10,32 */ \
>> + .long 0xa600607d; /* mfmsr r11 */ \
>> + .long 0x01006b69; /* xori r11,r11,1 */ \
>> + .long 0xa6035a7d; /* mtsrr0 r10 */ \
>> + .long 0xa6037b7d; /* mtsrr1 r11 */ \
>> + .long 0x2400004c; /* rfid */ \
>> + .long 0x00000048; /* b . */ \
>> +
>> +#endif /* __BYTE_ORDER__ */
>> +
>> #endif /* _ASMPOWERPC_PPC_ASM_H */
>> diff --git a/lib/ppc64/asm/io.h b/lib/ppc64/asm/io.h
>> index c0801d4..4f2c31b 100644
>> --- a/lib/ppc64/asm/io.h
>> +++ b/lib/ppc64/asm/io.h
>> @@ -1,5 +1,13 @@
>> #ifndef _ASMPPC64_IO_H_
>> #define _ASMPPC64_IO_H_
>> +
>> +#if __BYTE_ORDER__ = __ORDER_LITTLE_ENDIAN__
>> +#define __cpu_is_be() (0)
>> +#elif __BYTE_ORDER__ = __ORDER_BIG_ENDIAN__
>> #define __cpu_is_be() (1)
>> +#else
>> +#error Undefined byte order
>> +#endif
>> +
>> #include <asm-generic/io.h>
>> #endif
>> diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
>> index cc27ac8..b526668 100644
>> --- a/powerpc/Makefile.common
>> +++ b/powerpc/Makefile.common
>> @@ -11,7 +11,6 @@ all: $(TEST_DIR)/boot_rom.bin test_cases
>>
>> ##################################################################
>>
>> -CFLAGS += $(arch_CFLAGS)
>> CFLAGS += -std=gnu99
>> CFLAGS += -ffreestanding
>> CFLAGS += -Wextra
>> @@ -32,6 +31,7 @@ cflatobjs += lib/powerpc/setup.o
>> cflatobjs += lib/powerpc/rtas.o
>>
>> FLATLIBS = $(libcflat) $(LIBFDT_archive)
>> +%.elf: CFLAGS += $(arch_CFLAGS)
>> %.elf: LDFLAGS = $(arch_LDFLAGS) -nostdlib -pie
>> %.elf: %.o $(FLATLIBS) powerpc/flat.lds
>> $(LD) $(LDFLAGS) -o $@ \
>> @@ -48,6 +48,7 @@ $(TEST_DIR)/boot_rom.bin: $(TEST_DIR)/boot_rom.elf
>> dd if=/dev/zero of=$@ bs%6 count=1
>> $(OBJCOPY) -O binary $^ >(cat - >>$@)
>>
>> +$(TEST_DIR)/boot_rom.elf: CFLAGS = -mbig-endian
>> $(TEST_DIR)/boot_rom.elf: $(TEST_DIR)/boot_rom.o
>> $(LD) -EB -nostdlib -Ttext=0x100 --entry=start --build-id=none -o $@ $<
>>
>> diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64
>> index 2df44d4..3da3a83 100644
>> --- a/powerpc/Makefile.ppc64
>> +++ b/powerpc/Makefile.ppc64
>> @@ -5,8 +5,13 @@
>> #
>> bits = 64
>>
>> -arch_CFLAGS = -mbig-endian
>> -arch_LDFLAGS = -EB
>> +ifeq ($(ENDIAN),little)
>> + arch_CFLAGS = -mlittle-endian
>> + arch_LDFLAGS = -EL
>> +else
>> + arch_CFLAGS = -mbig-endian
>> + arch_LDFLAGS = -EB
>> +endif
>>
>> cstart.o = $(TEST_DIR)/cstart64.o
>> reloc.o = $(TEST_DIR)/reloc64.o
>> diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
>> index 6072597..62078a4 100644
>> --- a/powerpc/cstart64.S
>> +++ b/powerpc/cstart64.S
>> @@ -16,6 +16,7 @@
>> */
>> .globl start
>> start:
>> + FIXUP_ENDIAN
>> /*
>> * We were loaded at QEMU's kernel load address, but we're not
>> * allowed to link there due to how QEMU deals with linker VMAs,
>> @@ -84,12 +85,23 @@ halt:
>> enter_rtas:
>> mflr r0
>> std r0, 16(r1)
>> +
>> + LOAD_REG_ADDR(r10, rtas_return_loc)
>> + mtlr r10
>> LOAD_REG_ADDR(r11, rtas_entry)
>> ld r10, 0(r11)
>> -//FIXME: change this bctrl to an rtas-prep, rfid, rtas-return sequence
>> - mtctr r10
>> - nop
>> - bctrl
>> +
>> + mfmsr r11
>> +#if __BYTE_ORDER__ = __ORDER_LITTLE_ENDIAN__
>> + xori r11,r11,1
>> +#endif
>
> We can avoid the #if.
>
> LOAD_REG_IMMEDIATE(r9, RTAS_MSR_MASK)
> and r11, r11, r9
>
> Right now we'll define RTAS_MSR_MASK to the boring value of
> 0xfffffffffffffffe, but presumably that'll change some day.
OK
>> + mtsrr0 r10
>> + mtsrr1 r11
>> + rfid
>> + b .
>> +
>> +rtas_return_loc:
>> + FIXUP_ENDIAN
>> ld r0, 16(r1)
>> mtlr r0
>> blr
>> --
>> 2.5.0
>
> Thanks,
> drew
>
Thanks,
Laurent
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [kvm-unit-tests PATCH v3 1/2] powerpc: add asm/ppc_asm.h
2016-02-29 17:49 ` [kvm-unit-tests PATCH v3 1/2] powerpc: add asm/ppc_asm.h Laurent Vivier
2016-02-29 18:56 ` Andrew Jones
@ 2016-03-01 8:30 ` Thomas Huth
1 sibling, 0 replies; 9+ messages in thread
From: Thomas Huth @ 2016-03-01 8:30 UTC (permalink / raw)
To: Laurent Vivier, kvm, kvm-ppc; +Cc: drjones, dgibson, agraf, pbonzini
On 29.02.2016 18:49, Laurent Vivier wrote:
> Move LOAD_REG_IMMEDIATE() and LOAD_REG_ADDR()
> from cstart64.S to ppc_asm.h
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> lib/powerpc/asm/ppc_asm.h | 14 ++++++++++++++
> lib/ppc64/asm/ppc_asm.h | 1 +
> powerpc/cstart64.S | 11 +----------
> 3 files changed, 16 insertions(+), 10 deletions(-)
> create mode 100644 lib/powerpc/asm/ppc_asm.h
> create mode 100644 lib/ppc64/asm/ppc_asm.h
>
> diff --git a/lib/powerpc/asm/ppc_asm.h b/lib/powerpc/asm/ppc_asm.h
> new file mode 100644
> index 0000000..f63bb72
> --- /dev/null
> +++ b/lib/powerpc/asm/ppc_asm.h
> @@ -0,0 +1,14 @@
> +#ifndef _ASMPOWERPC_PPC_ASM_H
> +#define _ASMPOWERPC_PPC_ASM_H
> +
> +#define LOAD_REG_IMMEDIATE(reg,expr) \
> + lis reg,(expr)@highest; \
> + ori reg,reg,(expr)@higher; \
> + rldicr reg,reg,32,31; \
> + oris reg,reg,(expr)@h; \
> + ori reg,reg,(expr)@l;
> +
> +#define LOAD_REG_ADDR(reg,name) \
> + ld reg,name@got(r2)
> +
> +#endif /* _ASMPOWERPC_PPC_ASM_H */
> diff --git a/lib/ppc64/asm/ppc_asm.h b/lib/ppc64/asm/ppc_asm.h
> new file mode 100644
> index 0000000..e3929ee
> --- /dev/null
> +++ b/lib/ppc64/asm/ppc_asm.h
> @@ -0,0 +1 @@
> +#include "../../powerpc/asm/ppc_asm.h"
> diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S
> index 4693ba1..6072597 100644
> --- a/powerpc/cstart64.S
> +++ b/powerpc/cstart64.S
> @@ -7,16 +7,7 @@
> */
> #define __ASSEMBLY__
> #include <asm/hcall.h>
> -
> -#define LOAD_REG_IMMEDIATE(reg,expr) \
> - lis reg,(expr)@highest; \
> - ori reg,reg,(expr)@higher; \
> - rldicr reg,reg,32,31; \
> - oris reg,reg,(expr)@h; \
> - ori reg,reg,(expr)@l;
> -
> -#define LOAD_REG_ADDR(reg,name) \
> - ld reg,name@got(r2)
> +#include <asm/ppc_asm.h>
>
> .section .init
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [kvm-unit-tests PATCH v3 2/2] powerpc: select endianness
2016-02-29 17:49 ` [kvm-unit-tests PATCH v3 2/2] powerpc: select endianness Laurent Vivier
2016-02-29 19:44 ` Andrew Jones
@ 2016-03-01 8:40 ` Thomas Huth
2016-03-01 8:54 ` Laurent Vivier
1 sibling, 1 reply; 9+ messages in thread
From: Thomas Huth @ 2016-03-01 8:40 UTC (permalink / raw)
To: Laurent Vivier, kvm, kvm-ppc; +Cc: drjones, dgibson, agraf, pbonzini
On 29.02.2016 18:49, Laurent Vivier wrote:
> This patch allows to build tests for ppc64 little endian target
> (ppc64le) on big and little endian hosts.
>
> We add a new parameter to configure to select the endianness of the
> tests (--endian=little or --endian=big).
>
> I have built and tested big and little endian tests on a little
> endian host, a big endian host, with kvm_hv and kvm_pr, and on
> x86_64 with ppc64 as a TCG target.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> configure | 11 +++++++++++
> lib/powerpc/asm/ppc_asm.h | 19 +++++++++++++++++++
> lib/ppc64/asm/io.h | 8 ++++++++
> powerpc/Makefile.common | 3 ++-
> powerpc/Makefile.ppc64 | 9 +++++++--
> powerpc/cstart64.S | 20 ++++++++++++++++----
> 6 files changed, 63 insertions(+), 7 deletions(-)
Patch looks fine to me, so when you fixed the two little things that
Andrew mentioned, feel free to add my Reviewed-by.
Thomas
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [kvm-unit-tests PATCH v3 2/2] powerpc: select endianness
2016-03-01 8:40 ` Thomas Huth
@ 2016-03-01 8:54 ` Laurent Vivier
0 siblings, 0 replies; 9+ messages in thread
From: Laurent Vivier @ 2016-03-01 8:54 UTC (permalink / raw)
To: Thomas Huth, kvm, kvm-ppc; +Cc: drjones, dgibson, agraf, pbonzini
On 01/03/2016 09:40, Thomas Huth wrote:
> On 29.02.2016 18:49, Laurent Vivier wrote:
>> This patch allows to build tests for ppc64 little endian target
>> (ppc64le) on big and little endian hosts.
>>
>> We add a new parameter to configure to select the endianness of the
>> tests (--endian=little or --endian=big).
>>
>> I have built and tested big and little endian tests on a little
>> endian host, a big endian host, with kvm_hv and kvm_pr, and on
>> x86_64 with ppc64 as a TCG target.
>>
>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
>> ---
>> configure | 11 +++++++++++
>> lib/powerpc/asm/ppc_asm.h | 19 +++++++++++++++++++
>> lib/ppc64/asm/io.h | 8 ++++++++
>> powerpc/Makefile.common | 3 ++-
>> powerpc/Makefile.ppc64 | 9 +++++++--
>> powerpc/cstart64.S | 20 ++++++++++++++++----
>> 6 files changed, 63 insertions(+), 7 deletions(-)
>
> Patch looks fine to me, so when you fixed the two little things that
> Andrew mentioned, feel free to add my Reviewed-by.
Thanks Thomas, I will.
Laurent
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-03-01 8:54 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-29 17:49 [kvm-unit-tests PATCH v3 0/2] powerpc: add little-endian support Laurent Vivier
2016-02-29 17:49 ` [kvm-unit-tests PATCH v3 1/2] powerpc: add asm/ppc_asm.h Laurent Vivier
2016-02-29 18:56 ` Andrew Jones
2016-03-01 8:30 ` Thomas Huth
2016-02-29 17:49 ` [kvm-unit-tests PATCH v3 2/2] powerpc: select endianness Laurent Vivier
2016-02-29 19:44 ` Andrew Jones
2016-03-01 8:12 ` Laurent Vivier
2016-03-01 8:40 ` Thomas Huth
2016-03-01 8:54 ` Laurent Vivier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox