Hi all,
this patch series introduces Xen support to arch/arm64.
As you can see from the following patches, there is very little arm64
specific code here, basically only one assembly file
(arch/arm64/xen/hypercall.S).
Everything else is common with Xen for ARMv7, in particular the code
under arch/arm/xen (enlighten.c and the stubs in grant-table.c) and most
of the header files under arch/arm/include/asm/xen (hypercall.h,
hypervisor.h, interface.h, page.h) can be reused as-is.
Changes in v4:
- build the entire directory arch/arm/xen under arch/arm64;
- add the arm64 hypercall wrappers to arch/arm/xen/hypercall.S.
Stefano Stabellini (6):
      arm/xen: define xen_remap as ioremap_cached
      arm64/xen: introduce asm/xen header files on arm64
      arm64/xen: implement ioremap_cached on arm64
      arm64/xen: use XEN_IO_PROTO_ABI_ARM on ARM64
      arm64/xen: introduce CONFIG_XEN on ARM64
      MAINTAINERS: add myself as arm64/xen maintainer
 MAINTAINERS                             |    7 ++
 arch/arm/include/asm/xen/page.h         |    3 +-
 arch/arm/xen/hypercall.S                |   98 ++++++++++++++++++++-----------
 arch/arm64/Kconfig                      |   10 +++
 arch/arm64/Makefile                     |    1 +
 arch/arm64/include/asm/hypervisor.h     |    6 ++
 arch/arm64/include/asm/io.h             |    2 +
 arch/arm64/include/asm/sync_bitops.h    |   26 ++++++++
 arch/arm64/include/asm/xen/events.h     |   21 +++++++
 arch/arm64/include/asm/xen/hypercall.h  |    1 +
 arch/arm64/include/asm/xen/hypervisor.h |    1 +
 arch/arm64/include/asm/xen/interface.h  |    1 +
 arch/arm64/include/asm/xen/page.h       |    1 +
 include/xen/interface/io/protocols.h    |    2 +-
 14 files changed, 143 insertions(+), 37 deletions(-)
 create mode 100644 arch/arm64/include/asm/hypervisor.h
 create mode 100644 arch/arm64/include/asm/sync_bitops.h
 create mode 100644 arch/arm64/include/asm/xen/events.h
 create mode 100644 arch/arm64/include/asm/xen/hypercall.h
 create mode 100644 arch/arm64/include/asm/xen/hypervisor.h
 create mode 100644 arch/arm64/include/asm/xen/interface.h
 create mode 100644 arch/arm64/include/asm/xen/page.h
git://git.kernel.org/pub/scm/linux/kernel/git/sstabellini/xen.git xen-arm64-4
- Stefano
Stefano Stabellini
2013-Jun-05  17:02 UTC
[PATCH v4 1/6] arm/xen: define xen_remap as ioremap_cached
Define xen_remap as ioremap_cache (MT_MEMORY and MT_DEVICE_CACHED end up having the same AttrIndx encoding). Remove include asm/mach/map.h, not unneeded. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> --- arch/arm/include/asm/xen/page.h | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/xen/page.h b/arch/arm/include/asm/xen/page.h index 30cdacb..359a7b5 100644 --- a/arch/arm/include/asm/xen/page.h +++ b/arch/arm/include/asm/xen/page.h @@ -1,7 +1,6 @@ #ifndef _ASM_ARM_XEN_PAGE_H #define _ASM_ARM_XEN_PAGE_H -#include <asm/mach/map.h> #include <asm/page.h> #include <asm/pgtable.h> @@ -88,6 +87,6 @@ static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn) return __set_phys_to_machine(pfn, mfn); } -#define xen_remap(cookie, size) __arm_ioremap((cookie), (size), MT_MEMORY); +#define xen_remap(cookie, size) ioremap_cached((cookie), (size)); #endif /* _ASM_ARM_XEN_PAGE_H */ -- 1.7.2.5
Stefano Stabellini
2013-Jun-05  17:02 UTC
[PATCH v4 2/6] arm64/xen: introduce asm/xen header files on arm64
asm/xen/hypercall.h, asm/xen/hypervisor.h, asm/xen/interface.h and
asm/xen/page.h are identical so to avoid code duplication we are just
including the original arm header files here.
asm/xen/events.h is slightly different, so introduce a different file
here (use xchg to implement xchg_xen_ulong and pass regs->pstate to
raw_irqs_disabled_flags).
Also introduce asm/hypervisor.h and asm/sync_bitops.h.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Change in v2:
- add all the required headers in this patch, by including the original
  arch/arm headers when possible to avoid code duplication;
- use xchg to implement xchg_xen_ulong.
---
 arch/arm64/include/asm/hypervisor.h     |    6 ++++++
 arch/arm64/include/asm/sync_bitops.h    |   26 ++++++++++++++++++++++++++
 arch/arm64/include/asm/xen/events.h     |   21 +++++++++++++++++++++
 arch/arm64/include/asm/xen/hypercall.h  |    1 +
 arch/arm64/include/asm/xen/hypervisor.h |    1 +
 arch/arm64/include/asm/xen/interface.h  |    1 +
 arch/arm64/include/asm/xen/page.h       |    1 +
 7 files changed, 57 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm64/include/asm/hypervisor.h
 create mode 100644 arch/arm64/include/asm/sync_bitops.h
 create mode 100644 arch/arm64/include/asm/xen/events.h
 create mode 100644 arch/arm64/include/asm/xen/hypercall.h
 create mode 100644 arch/arm64/include/asm/xen/hypervisor.h
 create mode 100644 arch/arm64/include/asm/xen/interface.h
 create mode 100644 arch/arm64/include/asm/xen/page.h
diff --git a/arch/arm64/include/asm/hypervisor.h
b/arch/arm64/include/asm/hypervisor.h
new file mode 100644
index 0000000..d2c7904
--- /dev/null
+++ b/arch/arm64/include/asm/hypervisor.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_ARM64_HYPERVISOR_H
+#define _ASM_ARM64_HYPERVISOR_H
+
+#include <asm/xen/hypervisor.h>
+
+#endif
diff --git a/arch/arm64/include/asm/sync_bitops.h
b/arch/arm64/include/asm/sync_bitops.h
new file mode 100644
index 0000000..8da0bf4
--- /dev/null
+++ b/arch/arm64/include/asm/sync_bitops.h
@@ -0,0 +1,26 @@
+#ifndef __ASM_SYNC_BITOPS_H__
+#define __ASM_SYNC_BITOPS_H__
+
+#include <asm/bitops.h>
+#include <asm/cmpxchg.h>
+
+/* sync_bitops functions are equivalent to the SMP implementation of the
+ * original functions, independently from CONFIG_SMP being defined.
+ *
+ * We need them because _set_bit etc are not SMP safe if !CONFIG_SMP. But
+ * under Xen you might be communicating with a completely external entity
+ * who might be on another CPU (e.g. two uniprocessor guests communicating
+ * via event channels and grant tables). So we need a variant of the bit
+ * ops which are SMP safe even on a UP kernel.
+ */
+
+#define sync_set_bit(nr, p)            set_bit(nr, p)
+#define sync_clear_bit(nr, p)          clear_bit(nr, p)
+#define sync_change_bit(nr, p)         change_bit(nr, p)
+#define sync_test_and_set_bit(nr, p)   test_and_set_bit(nr, p)
+#define sync_test_and_clear_bit(nr, p) test_and_clear_bit(nr, p)
+#define sync_test_and_change_bit(nr, p)        test_and_change_bit(nr, p)
+#define sync_test_bit(nr, addr)                test_bit(nr, addr)
+#define sync_cmpxchg                   cmpxchg
+
+#endif
diff --git a/arch/arm64/include/asm/xen/events.h
b/arch/arm64/include/asm/xen/events.h
new file mode 100644
index 0000000..8655321
--- /dev/null
+++ b/arch/arm64/include/asm/xen/events.h
@@ -0,0 +1,21 @@
+#ifndef _ASM_ARM64_XEN_EVENTS_H
+#define _ASM_ARM64_XEN_EVENTS_H
+
+#include <asm/ptrace.h>
+#include <asm/atomic.h>
+
+enum ipi_vector {
+	XEN_PLACEHOLDER_VECTOR,
+
+	/* Xen IPIs go here */
+	XEN_NR_IPIS,
+};
+
+static inline int xen_irqs_disabled(struct pt_regs *regs)
+{
+	return raw_irqs_disabled_flags((unsigned long) regs->pstate);
+}
+
+#define xchg_xen_ulong(ptr, val) xchg((ptr), (val))
+
+#endif /* _ASM_ARM64_XEN_EVENTS_H */
diff --git a/arch/arm64/include/asm/xen/hypercall.h
b/arch/arm64/include/asm/xen/hypercall.h
new file mode 100644
index 0000000..74b0c42
--- /dev/null
+++ b/arch/arm64/include/asm/xen/hypercall.h
@@ -0,0 +1 @@
+#include <../../arm/include/asm/xen/hypercall.h>
diff --git a/arch/arm64/include/asm/xen/hypervisor.h
b/arch/arm64/include/asm/xen/hypervisor.h
new file mode 100644
index 0000000..f263da8
--- /dev/null
+++ b/arch/arm64/include/asm/xen/hypervisor.h
@@ -0,0 +1 @@
+#include <../../arm/include/asm/xen/hypervisor.h>
diff --git a/arch/arm64/include/asm/xen/interface.h
b/arch/arm64/include/asm/xen/interface.h
new file mode 100644
index 0000000..44457ae
--- /dev/null
+++ b/arch/arm64/include/asm/xen/interface.h
@@ -0,0 +1 @@
+#include <../../arm/include/asm/xen/interface.h>
diff --git a/arch/arm64/include/asm/xen/page.h
b/arch/arm64/include/asm/xen/page.h
new file mode 100644
index 0000000..bed87ec
--- /dev/null
+++ b/arch/arm64/include/asm/xen/page.h
@@ -0,0 +1 @@
+#include <../../arm/include/asm/xen/page.h>
-- 
1.7.2.5
Stefano Stabellini
2013-Jun-05  17:02 UTC
[PATCH v4 3/6] arm64/xen: implement ioremap_cached on arm64
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> --- arch/arm64/include/asm/io.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index 2e12258..1d12f89 100644 --- a/arch/arm64/include/asm/io.h +++ b/arch/arm64/include/asm/io.h @@ -228,10 +228,12 @@ extern void __iounmap(volatile void __iomem *addr); #define PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_DIRTY) #define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_DEVICE_nGnRE)) #define PROT_NORMAL_NC (PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL_NC)) +#define PROT_NORMAL (PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL)) #define ioremap(addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRE)) #define ioremap_nocache(addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRE)) #define ioremap_wc(addr, size) __ioremap((addr), (size), __pgprot(PROT_NORMAL_NC)) +#define ioremap_cached(addr, size) __ioremap((addr), (size), __pgprot(PROT_NORMAL)) #define iounmap __iounmap #define PROT_SECT_DEFAULT (PMD_TYPE_SECT | PMD_SECT_AF) -- 1.7.2.5
Stefano Stabellini
2013-Jun-05  17:02 UTC
[PATCH v4 4/6] arm64/xen: use XEN_IO_PROTO_ABI_ARM on ARM64
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- include/xen/interface/io/protocols.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/xen/interface/io/protocols.h b/include/xen/interface/io/protocols.h index 0eafaf2..056744b 100644 --- a/include/xen/interface/io/protocols.h +++ b/include/xen/interface/io/protocols.h @@ -15,7 +15,7 @@ # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_IA64 #elif defined(__powerpc64__) # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_POWERPC64 -#elif defined(__arm__) +#elif defined(__arm__) || defined(__aarch64__) # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_ARM #else # error arch fixup needed here -- 1.7.2.5
Stefano Stabellini
2013-Jun-05  17:02 UTC
[PATCH v4 5/6] arm64/xen: introduce CONFIG_XEN on ARM64
Introduce CONFIG_XEN on ARM64, compile arch/arm/xen under arch/arm64.
Add the ARMv8 specific hypercall wrappers to arch/arm/xen/hypercall.S.
Align few lines in hypercall.S since we are at it.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Changes in v2:
- remove depends on !GENERIC_ATOMIC64;
- compile enlighten.c and grant_table.c from arch/arm directly;
- fix the privcmd implementation: according to the aarch64 procedure
call ABI the first 7 parameters are passed on registers so we don''t
need
to push/pop anything.
Changes in v3:
- update comment to reflect the actual hypercall calling convention.
Changes in v4:
- build the entire arch/arm/xen directory under arch/arm64, ifdef
hypercall.S appropriately.
---
 arch/arm/xen/hypercall.S |   98 ++++++++++++++++++++++++++++++----------------
 arch/arm64/Kconfig       |   10 +++++
 arch/arm64/Makefile      |    1 +
 3 files changed, 75 insertions(+), 34 deletions(-)
diff --git a/arch/arm/xen/hypercall.S b/arch/arm/xen/hypercall.S
index 199cb2d..114b356 100644
--- a/arch/arm/xen/hypercall.S
+++ b/arch/arm/xen/hypercall.S
@@ -31,51 +31,93 @@
  */
 
 /*
- * The Xen hypercall calling convention is very similar to the ARM
- * procedure calling convention: the first paramter is passed in r0, the
- * second in r1, the third in r2 and the fourth in r3. Considering that
- * Xen hypercalls have 5 arguments at most, the fifth paramter is passed
- * in r4, differently from the procedure calling convention of using the
- * stack for that case.
+ * The Xen hypercall calling convention is very similar to the ARM/ARM64
+ * procedure calling convention: the first paramter is passed in r0/x0,
+ * the second in r1/x1, the third in r2/x2 and the fourth in r3/x3.
+ * Considering that Xen hypercalls have 5 arguments at most, the fifth
+ * paramter is always passed in r4/x4, differently from the ARM
+ * procedure calling convention of using the stack for that case.
  *
- * The hypercall number is passed in r12.
+ * The hypercall number is passed in r12/x16.
  *
- * The return value is in r0.
+ * The return value is in r0/x0.
  *
- * The hvc ISS is required to be 0xEA1, that is the Xen specific ARM
- * hypercall tag.
+ * The hvc ISS is required to be 0xEA1, that is the Xen specific
+ * ARM/ARM64 hypercall tag.
  */
 
 #include <linux/linkage.h>
 #include <asm/assembler.h>
-#include <asm/opcodes-virt.h>
 #include <xen/interface/xen.h>
 
 
 #define XEN_IMM 0xEA1
 
+
+#ifdef CONFIG_ARM
+
+#include <asm/opcodes-virt.h>
+
+ENTRY(privcmd_call)
+	stmdb sp!, {r4}
+	mov r12, r0
+	mov r0, r1
+	mov r1, r2
+	mov r2, r3
+	ldr r3, [sp, #8]
+	ldr r4, [sp, #4]
+	__HVC(XEN_IMM)
+	ldm sp!, {r4}
+	mov pc, lr
+ENDPROC(privcmd_call);
+
 #define HYPERCALL_SIMPLE(hypercall)		\
 ENTRY(HYPERVISOR_##hypercall)			\
 	mov r12, #__HYPERVISOR_##hypercall;	\
-	__HVC(XEN_IMM);						\
-	mov pc, lr;							\
+	__HVC(XEN_IMM);				\
+	mov pc, lr;				\
+ENDPROC(HYPERVISOR_##hypercall)
+
+#define HYPERCALL5(hypercall)			\
+ENTRY(HYPERVISOR_##hypercall)			\
+	stmdb sp!, {r4}				\
+	ldr r4, [sp, #4]			\
+	mov r12, #__HYPERVISOR_##hypercall;	\
+	__HVC(XEN_IMM);				\
+	ldm sp!, {r4}				\
+	mov pc, lr				\
 ENDPROC(HYPERVISOR_##hypercall)
 
+#else /* ARM64 specific code below */
+
+ENTRY(privcmd_call)
+	mov x16, x0
+	mov x0, x1
+	mov x1, x2
+	mov x2, x3
+	mov x3, x4
+	mov x4, x5
+	hvc XEN_IMM
+	ret
+ENDPROC(privcmd_call);
+
+#define HYPERCALL_SIMPLE(hypercall)		\
+ENTRY(HYPERVISOR_##hypercall)			\
+	mov x16, #__HYPERVISOR_##hypercall;	\
+	hvc XEN_IMM;				\
+	ret;					\
+ENDPROC(HYPERVISOR_##hypercall)
+
+#define HYPERCALL5 HYPERCALL_SIMPLE
+#endif
+
+
 #define HYPERCALL0 HYPERCALL_SIMPLE
 #define HYPERCALL1 HYPERCALL_SIMPLE
 #define HYPERCALL2 HYPERCALL_SIMPLE
 #define HYPERCALL3 HYPERCALL_SIMPLE
 #define HYPERCALL4 HYPERCALL_SIMPLE
 
-#define HYPERCALL5(hypercall)			\
-ENTRY(HYPERVISOR_##hypercall)			\
-	stmdb sp!, {r4}						\
-	ldr r4, [sp, #4]					\
-	mov r12, #__HYPERVISOR_##hypercall;	\
-	__HVC(XEN_IMM);						\
-	ldm sp!, {r4}						\
-	mov pc, lr							\
-ENDPROC(HYPERVISOR_##hypercall)
 
                 .text
 
@@ -89,15 +131,3 @@ HYPERCALL2(memory_op);
 HYPERCALL2(physdev_op);
 HYPERCALL3(vcpu_op);
 
-ENTRY(privcmd_call)
-	stmdb sp!, {r4}
-	mov r12, r0
-	mov r0, r1
-	mov r1, r2
-	mov r2, r3
-	ldr r3, [sp, #8]
-	ldr r4, [sp, #4]
-	__HVC(XEN_IMM)
-	ldm sp!, {r4}
-	mov pc, lr
-ENDPROC(privcmd_call);
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 56b3f6d..b5d6ada 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -182,6 +182,16 @@ config HW_PERF_EVENTS
 
 source "mm/Kconfig"
 
+config XEN_DOM0
+	def_bool y
+	depends on XEN
+
+config XEN
+	bool "Xen guest support on ARM64 (EXPERIMENTAL)"
+	depends on ARM64 && OF
+	help
+	  Say Y if you want to run Linux in a Virtual Machine on Xen on ARM64.
+
 endmenu
 
 menu "Boot options"
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index c95c5cb..4b298aa 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -37,6 +37,7 @@ TEXT_OFFSET := 0x00080000
 export	TEXT_OFFSET GZFLAGS
 
 core-y		+= arch/arm64/kernel/ arch/arm64/mm/
+core-$(CONFIG_XEN)	+= arch/arm/xen/
 libs-y		:= arch/arm64/lib/ $(libs-y)
 libs-y		+= $(LIBGCC)
 
-- 
1.7.2.5
Stefano Stabellini
2013-Jun-05  17:02 UTC
[PATCH v4 6/6] MAINTAINERS: add myself as arm64/xen maintainer
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> --- MAINTAINERS | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index fd3a495..95a6a51 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9096,6 +9096,13 @@ S: Supported F: arch/arm/xen/ F: arch/arm/include/asm/xen/ +XEN HYPERVISOR ARM64 +M: Stefano Stabellini <stefano.stabellini@eu.citrix.com> +L: xen-devel@lists.xensource.com (moderated for non-subscribers) +S: Supported +F: arch/arm64/xen/ +F: arch/arm64/include/asm/xen/ + XEN NETWORK BACKEND DRIVER M: Ian Campbell <ian.campbell@citrix.com> L: xen-devel@lists.xensource.com (moderated for non-subscribers) -- 1.7.2.5
Ian Campbell
2013-Jun-06  09:03 UTC
Re: [Xen-devel] [PATCH v4 5/6] arm64/xen: introduce CONFIG_XEN on ARM64
On Wed, 2013-06-05 at 18:02 +0100, Stefano Stabellini wrote:> Changes in v4: > - build the entire arch/arm/xen directory under arch/arm64, ifdef > hypercall.S appropriately.This is probably the best (or equal first) of a bunch of bad options :-/> + * The Xen hypercall calling convention is very similar to the ARM/ARM64 > + * procedure calling convention: the first paramter is passed in r0/x0,"parameter"> + * the second in r1/x1, the third in r2/x2 and the fourth in r3/x3. > + * Considering that Xen hypercalls have 5 arguments at most, the fifth > + * paramter is always passed in r4/x4, differently from the ARM > + * procedure calling convention of using the stack for that case.and "parameter" again. Strictly speaking the fifth argument handling only differs from the 32-bit PCS, not the 64-bit one. Splitting hairs a bit there. If you fix the typo and clarify the fifth argument or not as you wish: Acked-by: Ian Campbell <ian.campbell@citrix.com> Ian.
Catalin Marinas
2013-Jun-06  09:27 UTC
Re: [Xen-devel] [PATCH v4 5/6] arm64/xen: introduce CONFIG_XEN on ARM64
On Thu, Jun 06, 2013 at 10:03:39AM +0100, Ian Campbell wrote:> On Wed, 2013-06-05 at 18:02 +0100, Stefano Stabellini wrote: > > + * the second in r1/x1, the third in r2/x2 and the fourth in r3/x3. > > + * Considering that Xen hypercalls have 5 arguments at most, the fifth > > + * paramter is always passed in r4/x4, differently from the ARM > > + * procedure calling convention of using the stack for that case. > > and "parameter" again. > > Strictly speaking the fifth argument handling only differs from the > 32-bit PCS, not the 64-bit one. Splitting hairs a bit there.I agree, just add "the fifth in x4" without "differently from ...", it''s not relevant. You can also remove references to r? registers, they are only called x?. -- Catalin
Ian Campbell
2013-Jun-06  09:29 UTC
Re: [Xen-devel] [PATCH v4 5/6] arm64/xen: introduce CONFIG_XEN on ARM64
On Thu, 2013-06-06 at 10:27 +0100, Catalin Marinas wrote:> On Thu, Jun 06, 2013 at 10:03:39AM +0100, Ian Campbell wrote: > > On Wed, 2013-06-05 at 18:02 +0100, Stefano Stabellini wrote: > > > + * the second in r1/x1, the third in r2/x2 and the fourth in r3/x3. > > > + * Considering that Xen hypercalls have 5 arguments at most, the fifth > > > + * paramter is always passed in r4/x4, differently from the ARM > > > + * procedure calling convention of using the stack for that case. > > > > and "parameter" again. > > > > Strictly speaking the fifth argument handling only differs from the > > 32-bit PCS, not the 64-bit one. Splitting hairs a bit there. > > I agree, just add "the fifth in x4" without "differently from ...", it''s > not relevant.Works for me.> You can also remove references to r? registers, they are only called x?.This is documenting both the Aarch32 and AArch64 conventions. Ian.
Catalin Marinas
2013-Jun-06  14:25 UTC
Re: [PATCH v4 5/6] arm64/xen: introduce CONFIG_XEN on ARM64
On Wed, Jun 05, 2013 at 06:02:06PM +0100, Stefano Stabellini wrote:> diff --git a/arch/arm/xen/hypercall.S b/arch/arm/xen/hypercall.S > index 199cb2d..114b356 100644 > --- a/arch/arm/xen/hypercall.S > +++ b/arch/arm/xen/hypercall.S > @@ -31,51 +31,93 @@ > */ > > /* > - * The Xen hypercall calling convention is very similar to the ARM > - * procedure calling convention: the first paramter is passed in r0, the > - * second in r1, the third in r2 and the fourth in r3. Considering that > - * Xen hypercalls have 5 arguments at most, the fifth paramter is passed > - * in r4, differently from the procedure calling convention of using the > - * stack for that case. > + * The Xen hypercall calling convention is very similar to the ARM/ARM64 > + * procedure calling convention: the first paramter is passed in r0/x0, > + * the second in r1/x1, the third in r2/x2 and the fourth in r3/x3. > + * Considering that Xen hypercalls have 5 arguments at most, the fifth > + * paramter is always passed in r4/x4, differently from the ARM > + * procedure calling convention of using the stack for that case. > * > - * The hypercall number is passed in r12. > + * The hypercall number is passed in r12/x16. > * > - * The return value is in r0. > + * The return value is in r0/x0. > * > - * The hvc ISS is required to be 0xEA1, that is the Xen specific ARM > - * hypercall tag. > + * The hvc ISS is required to be 0xEA1, that is the Xen specific > + * ARM/ARM64 hypercall tag. > */ > > #include <linux/linkage.h> > #include <asm/assembler.h> > -#include <asm/opcodes-virt.h> > #include <xen/interface/xen.h> > > > #define XEN_IMM 0xEA1 > > + > +#ifdef CONFIG_ARM > + > +#include <asm/opcodes-virt.h> > + > +ENTRY(privcmd_call) > + stmdb sp!, {r4} > + mov r12, r0 > + mov r0, r1 > + mov r1, r2 > + mov r2, r3 > + ldr r3, [sp, #8] > + ldr r4, [sp, #4] > + __HVC(XEN_IMM) > + ldm sp!, {r4} > + mov pc, lr > +ENDPROC(privcmd_call); > + > #define HYPERCALL_SIMPLE(hypercall) \ > ENTRY(HYPERVISOR_##hypercall) \ > mov r12, #__HYPERVISOR_##hypercall; \ > - __HVC(XEN_IMM); \ > - mov pc, lr; \ > + __HVC(XEN_IMM); \ > + mov pc, lr; \ > +ENDPROC(HYPERVISOR_##hypercall) > + > +#define HYPERCALL5(hypercall) \ > +ENTRY(HYPERVISOR_##hypercall) \ > + stmdb sp!, {r4} \ > + ldr r4, [sp, #4] \ > + mov r12, #__HYPERVISOR_##hypercall; \ > + __HVC(XEN_IMM); \ > + ldm sp!, {r4} \ > + mov pc, lr \ > ENDPROC(HYPERVISOR_##hypercall) > > +#else /* ARM64 specific code below */ > + > +ENTRY(privcmd_call) > + mov x16, x0 > + mov x0, x1 > + mov x1, x2 > + mov x2, x3 > + mov x3, x4 > + mov x4, x5 > + hvc XEN_IMM > + ret > +ENDPROC(privcmd_call);Ah, thanks to Ian for pointing out, I missed the fact that you merged the hypercall.S files. Please don''t. It''s a different assembly syntax. -- Catalin