kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH v4 0/2] powerpc: add little-endian support
@ 2016-03-01  9:35 Laurent Vivier
  2016-03-01  9:35 ` [kvm-unit-tests PATCH v4 1/2] powerpc: add asm/ppc_asm.h Laurent Vivier
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Laurent Vivier @ 2016-03-01  9:35 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-v4

v4: remove duplicate exit in configure
    add RTAS_MSR_MASK in asm/rtas.h and use it in cstart64.S

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                 | 10 ++++++++++
 lib/powerpc/asm/ppc_asm.h | 33 +++++++++++++++++++++++++++++++++
 lib/powerpc/asm/rtas.h    |  6 ++++++
 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 +++++++++++++++++--------------
 8 files changed, 84 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] 5+ messages in thread

* [kvm-unit-tests PATCH v4 1/2] powerpc: add asm/ppc_asm.h
  2016-03-01  9:35 [kvm-unit-tests PATCH v4 0/2] powerpc: add little-endian support Laurent Vivier
@ 2016-03-01  9:35 ` Laurent Vivier
  2016-03-01  9:35 ` [kvm-unit-tests PATCH v4 2/2] powerpc: select endianness Laurent Vivier
  2016-03-01 21:08 ` [kvm-unit-tests PATCH v4 0/2] powerpc: add little-endian support Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2016-03-01  9:35 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>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Thomas Huth <thuth@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] 5+ messages in thread

* [kvm-unit-tests PATCH v4 2/2] powerpc: select endianness
  2016-03-01  9:35 [kvm-unit-tests PATCH v4 0/2] powerpc: add little-endian support Laurent Vivier
  2016-03-01  9:35 ` [kvm-unit-tests PATCH v4 1/2] powerpc: add asm/ppc_asm.h Laurent Vivier
@ 2016-03-01  9:35 ` Laurent Vivier
  2016-03-01 10:55   ` Andrew Jones
  2016-03-01 21:08 ` [kvm-unit-tests PATCH v4 0/2] powerpc: add little-endian support Paolo Bonzini
  2 siblings, 1 reply; 5+ messages in thread
From: Laurent Vivier @ 2016-03-01  9:35 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>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 configure                 | 10 ++++++++++
 lib/powerpc/asm/ppc_asm.h | 19 +++++++++++++++++++
 lib/powerpc/asm/rtas.h    |  6 ++++++
 lib/ppc64/asm/io.h        |  8 ++++++++
 powerpc/Makefile.common   |  3 ++-
 powerpc/Makefile.ppc64    |  9 +++++++--
 powerpc/cstart64.S        | 20 ++++++++++++++++----
 7 files changed, 68 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index a685cca..958321d 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,10 @@ 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
+    fi
 else
     testdir=$arch
 fi
@@ -139,4 +148,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/powerpc/asm/rtas.h b/lib/powerpc/asm/rtas.h
index 522225b..9012a1e 100644
--- a/lib/powerpc/asm/rtas.h
+++ b/lib/powerpc/asm/rtas.h
@@ -5,6 +5,9 @@
  *
  * This work is licensed under the terms of the GNU LGPL, version 2.
  */
+
+#ifndef __ASSEMBLY__
+
 #include <libcflat.h>
 
 #define RTAS_UNKNOWN_SERVICE	(-1)
@@ -22,5 +25,8 @@ extern int rtas_token(const char *service);
 extern int rtas_call(int token, int nargs, int nret, int *outputs, ...);
 
 extern void rtas_power_off(void);
+#endif /* __ASSEMBLY__ */
+
+#define RTAS_MSR_MASK 0xfffffffffffffffe
 
 #endif /* _ASMPOWERPC_RTAS_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=256 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..c87e3d6 100644
--- a/powerpc/cstart64.S
+++ b/powerpc/cstart64.S
@@ -8,6 +8,7 @@
 #define __ASSEMBLY__
 #include <asm/hcall.h>
 #include <asm/ppc_asm.h>
+#include <asm/rtas.h>
 
 .section .init
 
@@ -16,6 +17,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 +86,22 @@ 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
+	LOAD_REG_IMMEDIATE(r9, RTAS_MSR_MASK)
+	and	r11, r11, r9
+	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] 5+ messages in thread

* Re: [kvm-unit-tests PATCH v4 2/2] powerpc: select endianness
  2016-03-01  9:35 ` [kvm-unit-tests PATCH v4 2/2] powerpc: select endianness Laurent Vivier
@ 2016-03-01 10:55   ` Andrew Jones
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Jones @ 2016-03-01 10:55 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: kvm, kvm-ppc, thuth, dgibson, agraf, pbonzini

On Tue, Mar 01, 2016 at 10:35:30AM +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>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> ---
>  configure                 | 10 ++++++++++
>  lib/powerpc/asm/ppc_asm.h | 19 +++++++++++++++++++
>  lib/powerpc/asm/rtas.h    |  6 ++++++
>  lib/ppc64/asm/io.h        |  8 ++++++++
>  powerpc/Makefile.common   |  3 ++-
>  powerpc/Makefile.ppc64    |  9 +++++++--
>  powerpc/cstart64.S        | 20 ++++++++++++++++----
>  7 files changed, 68 insertions(+), 7 deletions(-)
> 
> diff --git a/configure b/configure
> index a685cca..958321d 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,10 @@ 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
> +    fi
>  else
>      testdir=$arch
>  fi
> @@ -139,4 +148,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/powerpc/asm/rtas.h b/lib/powerpc/asm/rtas.h
> index 522225b..9012a1e 100644
> --- a/lib/powerpc/asm/rtas.h
> +++ b/lib/powerpc/asm/rtas.h
> @@ -5,6 +5,9 @@
>   *
>   * This work is licensed under the terms of the GNU LGPL, version 2.
>   */
> +
> +#ifndef __ASSEMBLY__
> +
>  #include <libcflat.h>
>  
>  #define RTAS_UNKNOWN_SERVICE	(-1)
> @@ -22,5 +25,8 @@ extern int rtas_token(const char *service);
>  extern int rtas_call(int token, int nargs, int nret, int *outputs, ...);
>  
>  extern void rtas_power_off(void);
> +#endif /* __ASSEMBLY__ */
> +
> +#define RTAS_MSR_MASK 0xfffffffffffffffe

I probably would have defined this in terms of MSR_LE, i.e.

#define MSR_LE (_AC(1,UL) << 0)
#define RTAS_MSR_MASK (~MSR_LE)

Although, we'll likely want more of Linux's
arch/powerpc/include/asm/reg.h as unit tests are written,
so we'll end up creating our own asm/reg.h at some point.
When that's done, then MSR_LE will be defined there, rather
than in asm/rtas.h. So either way, we'll have to change this
define later, and thus I guess it's OK for now.

>  
>  #endif /* _ASMPOWERPC_RTAS_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=256 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..c87e3d6 100644
> --- a/powerpc/cstart64.S
> +++ b/powerpc/cstart64.S
> @@ -8,6 +8,7 @@
>  #define __ASSEMBLY__
>  #include <asm/hcall.h>
>  #include <asm/ppc_asm.h>
> +#include <asm/rtas.h>
>  
>  .section .init
>  
> @@ -16,6 +17,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 +86,22 @@ 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
> +	LOAD_REG_IMMEDIATE(r9, RTAS_MSR_MASK)
> +	and	r11, r11, r9
> +	mtsrr0	r10
> +	mtsrr1	r11
> +	rfid
> +	b       .
> +
> +rtas_return_loc:
> +	FIXUP_ENDIAN
>  	ld	r0, 16(r1)
>  	mtlr	r0
>  	blr
> -- 
> 2.5.0
>

Reviewed-by: Andrew Jones <drjones@redhat.com> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [kvm-unit-tests PATCH v4 0/2] powerpc: add little-endian support
  2016-03-01  9:35 [kvm-unit-tests PATCH v4 0/2] powerpc: add little-endian support Laurent Vivier
  2016-03-01  9:35 ` [kvm-unit-tests PATCH v4 1/2] powerpc: add asm/ppc_asm.h Laurent Vivier
  2016-03-01  9:35 ` [kvm-unit-tests PATCH v4 2/2] powerpc: select endianness Laurent Vivier
@ 2016-03-01 21:08 ` Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2016-03-01 21:08 UTC (permalink / raw)
  To: Laurent Vivier, kvm, kvm-ppc; +Cc: drjones, thuth, dgibson, agraf



On 01/03/2016 10:35, Laurent Vivier wrote:
> 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-v4
> 
> v4: remove duplicate exit in configure
>     add RTAS_MSR_MASK in asm/rtas.h and use it in cstart64.S
> 
> 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                 | 10 ++++++++++
>  lib/powerpc/asm/ppc_asm.h | 33 +++++++++++++++++++++++++++++++++
>  lib/powerpc/asm/rtas.h    |  6 ++++++
>  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 +++++++++++++++++--------------
>  8 files changed, 84 insertions(+), 17 deletions(-)
>  create mode 100644 lib/powerpc/asm/ppc_asm.h
>  create mode 100644 lib/ppc64/asm/ppc_asm.h
> 

Looks good, will push tomorrow.

Paolo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-03-01 21:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-01  9:35 [kvm-unit-tests PATCH v4 0/2] powerpc: add little-endian support Laurent Vivier
2016-03-01  9:35 ` [kvm-unit-tests PATCH v4 1/2] powerpc: add asm/ppc_asm.h Laurent Vivier
2016-03-01  9:35 ` [kvm-unit-tests PATCH v4 2/2] powerpc: select endianness Laurent Vivier
2016-03-01 10:55   ` Andrew Jones
2016-03-01 21:08 ` [kvm-unit-tests PATCH v4 0/2] powerpc: add little-endian support Paolo Bonzini

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).