diff mbox

[Xen-devel,v2,15/17] xen: arm64: optimised clear_page

Message ID 1395841133-2223-15-git-send-email-ian.campbell@citrix.com
State New
Headers show

Commit Message

Ian Campbell March 26, 2014, 1:38 p.m. UTC
Taken from Linux v3.14-rc7.

The clear_page header now needs to be within the !__ASSEMBLY__

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 xen/arch/arm/arm64/lib/Makefile     |    1 +
 xen/arch/arm/arm64/lib/clear_page.S |   36 +++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/page.h          |    9 +++++++--
 3 files changed, 44 insertions(+), 2 deletions(-)
 create mode 100644 xen/arch/arm/arm64/lib/clear_page.S

Comments

Julien Grall March 26, 2014, 2:16 p.m. UTC | #1
Hi Ian,

On 03/26/2014 01:38 PM, Ian Campbell wrote:
> Taken from Linux v3.14-rc7.
> 
> The clear_page header now needs to be within the !__ASSEMBLY__
> 
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> ---

[..]

> +
> +#ifdef CONFIG_ARM_32
> +#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
> +#else
> +extern void clear_page(void *to);
> +#endif
> +

I would prefer if you move the defined in arm{32,64}/page.h.

Regards,
diff mbox

Patch

diff --git a/xen/arch/arm/arm64/lib/Makefile b/xen/arch/arm/arm64/lib/Makefile
index 9f3b236..b895afa 100644
--- a/xen/arch/arm/arm64/lib/Makefile
+++ b/xen/arch/arm/arm64/lib/Makefile
@@ -1,3 +1,4 @@ 
 obj-y += memcpy.o memmove.o memset.o memchr.o
+obj-y += clear_page.o
 obj-y += bitops.o find_next_bit.o
 obj-y += strchr.o strrchr.o
diff --git a/xen/arch/arm/arm64/lib/clear_page.S b/xen/arch/arm/arm64/lib/clear_page.S
new file mode 100644
index 0000000..8d5cadb
--- /dev/null
+++ b/xen/arch/arm/arm64/lib/clear_page.S
@@ -0,0 +1,36 @@ 
+/*
+ * Copyright (C) 2012 ARM Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <xen/config.h>
+
+/*
+ * Clear page @dest
+ *
+ * Parameters:
+ *	x0 - dest
+ */
+ENTRY(clear_page)
+	mrs	x1, dczid_el0
+	and	w1, w1, #0xf
+	mov	x2, #4
+	lsl	x1, x2, x1
+
+1:	dc	zva, x0
+	add	x0, x0, x1
+	tst	x0, #(PAGE_SIZE - 1)
+	b.ne	1b
+	ret
+ENDPROC(clear_page)
diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h
index d18ec2a..e880ae8 100644
--- a/xen/include/asm-arm/page.h
+++ b/xen/include/asm-arm/page.h
@@ -341,6 +341,13 @@  static inline int gva_to_ipa(vaddr_t va, paddr_t *paddr)
 /* Bits in the PAR returned by va_to_par */
 #define PAR_FAULT 0x1
 
+
+#ifdef CONFIG_ARM_32
+#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
+#else
+extern void clear_page(void *to);
+#endif
+
 #endif /* __ASSEMBLY__ */
 
 /*
@@ -382,8 +389,6 @@  static inline int gva_to_ipa(vaddr_t va, paddr_t *paddr)
 #define third_table_offset(va)  TABLE_OFFSET(third_linear_offset(va))
 #define zeroeth_table_offset(va)  TABLE_OFFSET(zeroeth_linear_offset(va))
 
-#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
-
 #define PAGE_ALIGN(x) (((x) + PAGE_SIZE - 1) & PAGE_MASK)
 
 #endif /* __ARM_PAGE_H__ */