[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] x86: move {clear_,copy_,scrub-}page.S to arch-specific library



commit ebddf34aab74c0427ceceab2e81b2be113d5feb2
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Dec 17 09:04:01 2025 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Dec 17 09:04:01 2025 +0100

    x86: move {clear_,copy_,scrub-}page.S to arch-specific library
    
    These are pretty similar to the standard library memset() / memcpy().
    
    Switch to building scrub-page.S unconditionally; the linker will simply
    not pick it up when not needed.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/Makefile         |  3 ---
 xen/arch/x86/clear_page.S     | 60 -----------------------------------------
 xen/arch/x86/copy_page.S      | 62 -------------------------------------------
 xen/arch/x86/lib/Makefile     |  3 +++
 xen/arch/x86/lib/clear-page.S | 60 +++++++++++++++++++++++++++++++++++++++++
 xen/arch/x86/lib/copy-page.S  | 62 +++++++++++++++++++++++++++++++++++++++++++
 xen/arch/x86/lib/scrub-page.S | 38 ++++++++++++++++++++++++++
 xen/arch/x86/scrub-page.S     | 38 --------------------------
 8 files changed, 163 insertions(+), 163 deletions(-)

diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 43117c88e5..1fc651146f 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -17,8 +17,6 @@ obj-y += apic.o
 obj-y += bhb-thunk.o
 obj-y += bitops.o
 obj-bin-y += bzimage.init.o
-obj-bin-y += clear_page.o
-obj-bin-y += copy_page.o
 obj-y += cpu-policy.o
 obj-y += cpuid.o
 obj-$(CONFIG_PV) += compat.o
@@ -57,7 +55,6 @@ obj-y += pci.o
 obj-y += physdev.o
 obj-$(CONFIG_COMPAT) += x86_64/physdev.o
 obj-$(CONFIG_X86_PSR) += psr.o
-obj-bin-$(CONFIG_DEBUG) += scrub-page.o
 obj-y += setup.o
 obj-y += shutdown.o
 obj-y += smp.o
diff --git a/xen/arch/x86/clear_page.S b/xen/arch/x86/clear_page.S
deleted file mode 100644
index 517685711d..0000000000
--- a/xen/arch/x86/clear_page.S
+++ /dev/null
@@ -1,60 +0,0 @@
-        .file __FILE__
-
-#include <xen/linkage.h>
-
-#include <asm/asm_defns.h>
-#include <asm/page.h>
-
-        .macro clear_page_sse2
-        mov     $PAGE_SIZE/32, %ecx
-        xor     %eax,%eax
-
-0:      movnti  %rax,   (%rdi)
-        movnti  %rax,  8(%rdi)
-        movnti  %rax, 16(%rdi)
-        movnti  %rax, 24(%rdi)
-        add     $32, %rdi
-        sub     $1, %ecx
-        jnz     0b
-
-        sfence
-        RET
-        .endm
-
-        .macro clear_page_clzero
-        mov     %rdi, %rax
-        mov     $PAGE_SIZE/64, %ecx
-        .globl clear_page_clzero_post_count
-clear_page_clzero_post_count:
-
-0:      clzero
-        sub     $-64, %rax
-        .globl clear_page_clzero_post_neg_size
-clear_page_clzero_post_neg_size:
-        sub     $1, %ecx
-        jnz     0b
-
-        sfence
-        RET
-        .endm
-
-FUNC(clear_page_cold)
-        ALTERNATIVE clear_page_sse2, clear_page_clzero, X86_FEATURE_CLZERO
-END(clear_page_cold)
-
-        .macro clear_page_stosb
-        mov     $PAGE_SIZE, %ecx
-        xor     %eax,%eax
-        rep stosb
-        .endm
-
-        .macro clear_page_stosq
-        mov     $PAGE_SIZE/8, %ecx
-        xor     %eax, %eax
-        rep stosq
-        .endm
-
-FUNC(clear_page_hot)
-        ALTERNATIVE clear_page_stosq, clear_page_stosb, X86_FEATURE_ERMS
-        RET
-END(clear_page_hot)
diff --git a/xen/arch/x86/copy_page.S b/xen/arch/x86/copy_page.S
deleted file mode 100644
index 0e09f0824a..0000000000
--- a/xen/arch/x86/copy_page.S
+++ /dev/null
@@ -1,62 +0,0 @@
-        .file __FILE__
-
-#include <xen/linkage.h>
-
-#include <asm/asm_defns.h>
-#include <asm/page.h>
-
-#define src_reg %rsi
-#define dst_reg %rdi
-#define WORD_SIZE 8
-#define tmp1_reg %r8
-#define tmp2_reg %r9
-#define tmp3_reg %r10
-#define tmp4_reg %r11
-
-FUNC(copy_page_cold)
-        mov     $PAGE_SIZE/(4*WORD_SIZE)-3, %ecx
-
-        prefetchnta 2*4*WORD_SIZE(src_reg)
-        mov     (src_reg), tmp1_reg
-        mov     WORD_SIZE(src_reg), tmp2_reg
-        mov     2*WORD_SIZE(src_reg), tmp3_reg
-        mov     3*WORD_SIZE(src_reg), tmp4_reg
-
-0:      prefetchnta 3*4*WORD_SIZE(src_reg)
-1:      add     $4*WORD_SIZE, src_reg
-        movnti  tmp1_reg, (dst_reg)
-        mov     (src_reg), tmp1_reg
-        dec     %ecx
-        movnti  tmp2_reg, WORD_SIZE(dst_reg)
-        mov     WORD_SIZE(src_reg), tmp2_reg
-        movnti  tmp3_reg, 2*WORD_SIZE(dst_reg)
-        mov     2*WORD_SIZE(src_reg), tmp3_reg
-        movnti  tmp4_reg, 3*WORD_SIZE(dst_reg)
-        lea     4*WORD_SIZE(dst_reg), dst_reg
-        mov     3*WORD_SIZE(src_reg), tmp4_reg
-        jg      0b
-        jpe     1b
-
-        movnti  tmp1_reg, (dst_reg)
-        movnti  tmp2_reg, WORD_SIZE(dst_reg)
-        movnti  tmp3_reg, 2*WORD_SIZE(dst_reg)
-        movnti  tmp4_reg, 3*WORD_SIZE(dst_reg)
-
-        sfence
-        RET
-END(copy_page_cold)
-
-        .macro copy_page_movsb
-        mov     $PAGE_SIZE, %ecx
-        rep movsb
-        .endm
-
-        .macro copy_page_movsq
-        mov     $PAGE_SIZE/8, %ecx
-        rep movsq
-        .endm
-
-FUNC(copy_page_hot)
-        ALTERNATIVE copy_page_movsq, copy_page_movsb, X86_FEATURE_ERMS
-        RET
-END(copy_page_hot)
diff --git a/xen/arch/x86/lib/Makefile b/xen/arch/x86/lib/Makefile
index a5169f5e19..b9a65c662a 100644
--- a/xen/arch/x86/lib/Makefile
+++ b/xen/arch/x86/lib/Makefile
@@ -1,5 +1,8 @@
+lib-y += clear-page.o
 lib-y += copy-guest.o
+lib-y += copy-page.o
 lib-y += copy-unsafe.o
 lib-y += generic-hweightl.o
 lib-y += memcpy.o
 lib-y += memset.o
+lib-y += scrub-page.o
diff --git a/xen/arch/x86/lib/clear-page.S b/xen/arch/x86/lib/clear-page.S
new file mode 100644
index 0000000000..517685711d
--- /dev/null
+++ b/xen/arch/x86/lib/clear-page.S
@@ -0,0 +1,60 @@
+        .file __FILE__
+
+#include <xen/linkage.h>
+
+#include <asm/asm_defns.h>
+#include <asm/page.h>
+
+        .macro clear_page_sse2
+        mov     $PAGE_SIZE/32, %ecx
+        xor     %eax,%eax
+
+0:      movnti  %rax,   (%rdi)
+        movnti  %rax,  8(%rdi)
+        movnti  %rax, 16(%rdi)
+        movnti  %rax, 24(%rdi)
+        add     $32, %rdi
+        sub     $1, %ecx
+        jnz     0b
+
+        sfence
+        RET
+        .endm
+
+        .macro clear_page_clzero
+        mov     %rdi, %rax
+        mov     $PAGE_SIZE/64, %ecx
+        .globl clear_page_clzero_post_count
+clear_page_clzero_post_count:
+
+0:      clzero
+        sub     $-64, %rax
+        .globl clear_page_clzero_post_neg_size
+clear_page_clzero_post_neg_size:
+        sub     $1, %ecx
+        jnz     0b
+
+        sfence
+        RET
+        .endm
+
+FUNC(clear_page_cold)
+        ALTERNATIVE clear_page_sse2, clear_page_clzero, X86_FEATURE_CLZERO
+END(clear_page_cold)
+
+        .macro clear_page_stosb
+        mov     $PAGE_SIZE, %ecx
+        xor     %eax,%eax
+        rep stosb
+        .endm
+
+        .macro clear_page_stosq
+        mov     $PAGE_SIZE/8, %ecx
+        xor     %eax, %eax
+        rep stosq
+        .endm
+
+FUNC(clear_page_hot)
+        ALTERNATIVE clear_page_stosq, clear_page_stosb, X86_FEATURE_ERMS
+        RET
+END(clear_page_hot)
diff --git a/xen/arch/x86/lib/copy-page.S b/xen/arch/x86/lib/copy-page.S
new file mode 100644
index 0000000000..0e09f0824a
--- /dev/null
+++ b/xen/arch/x86/lib/copy-page.S
@@ -0,0 +1,62 @@
+        .file __FILE__
+
+#include <xen/linkage.h>
+
+#include <asm/asm_defns.h>
+#include <asm/page.h>
+
+#define src_reg %rsi
+#define dst_reg %rdi
+#define WORD_SIZE 8
+#define tmp1_reg %r8
+#define tmp2_reg %r9
+#define tmp3_reg %r10
+#define tmp4_reg %r11
+
+FUNC(copy_page_cold)
+        mov     $PAGE_SIZE/(4*WORD_SIZE)-3, %ecx
+
+        prefetchnta 2*4*WORD_SIZE(src_reg)
+        mov     (src_reg), tmp1_reg
+        mov     WORD_SIZE(src_reg), tmp2_reg
+        mov     2*WORD_SIZE(src_reg), tmp3_reg
+        mov     3*WORD_SIZE(src_reg), tmp4_reg
+
+0:      prefetchnta 3*4*WORD_SIZE(src_reg)
+1:      add     $4*WORD_SIZE, src_reg
+        movnti  tmp1_reg, (dst_reg)
+        mov     (src_reg), tmp1_reg
+        dec     %ecx
+        movnti  tmp2_reg, WORD_SIZE(dst_reg)
+        mov     WORD_SIZE(src_reg), tmp2_reg
+        movnti  tmp3_reg, 2*WORD_SIZE(dst_reg)
+        mov     2*WORD_SIZE(src_reg), tmp3_reg
+        movnti  tmp4_reg, 3*WORD_SIZE(dst_reg)
+        lea     4*WORD_SIZE(dst_reg), dst_reg
+        mov     3*WORD_SIZE(src_reg), tmp4_reg
+        jg      0b
+        jpe     1b
+
+        movnti  tmp1_reg, (dst_reg)
+        movnti  tmp2_reg, WORD_SIZE(dst_reg)
+        movnti  tmp3_reg, 2*WORD_SIZE(dst_reg)
+        movnti  tmp4_reg, 3*WORD_SIZE(dst_reg)
+
+        sfence
+        RET
+END(copy_page_cold)
+
+        .macro copy_page_movsb
+        mov     $PAGE_SIZE, %ecx
+        rep movsb
+        .endm
+
+        .macro copy_page_movsq
+        mov     $PAGE_SIZE/8, %ecx
+        rep movsq
+        .endm
+
+FUNC(copy_page_hot)
+        ALTERNATIVE copy_page_movsq, copy_page_movsb, X86_FEATURE_ERMS
+        RET
+END(copy_page_hot)
diff --git a/xen/arch/x86/lib/scrub-page.S b/xen/arch/x86/lib/scrub-page.S
new file mode 100644
index 0000000000..efdcdab974
--- /dev/null
+++ b/xen/arch/x86/lib/scrub-page.S
@@ -0,0 +1,38 @@
+        .file __FILE__
+
+#include <asm/asm_defns.h>
+#include <xen/page-size.h>
+#include <xen/scrub.h>
+
+FUNC(scrub_page_cold)
+        mov     $PAGE_SIZE/32, %ecx
+        mov     $SCRUB_PATTERN, %rax
+
+0:      movnti  %rax,   (%rdi)
+        movnti  %rax,  8(%rdi)
+        movnti  %rax, 16(%rdi)
+        movnti  %rax, 24(%rdi)
+        add     $32, %rdi
+        sub     $1, %ecx
+        jnz     0b
+
+        sfence
+        RET
+END(scrub_page_cold)
+
+        .macro scrub_page_stosb
+        mov     $PAGE_SIZE, %ecx
+        mov     $SCRUB_BYTE_PATTERN, %eax
+        rep stosb
+        .endm
+
+        .macro scrub_page_stosq
+        mov     $PAGE_SIZE/8, %ecx
+        mov     $SCRUB_PATTERN, %rax
+        rep stosq
+        .endm
+
+FUNC(scrub_page_hot)
+        ALTERNATIVE scrub_page_stosq, scrub_page_stosb, X86_FEATURE_ERMS
+        RET
+END(scrub_page_hot)
diff --git a/xen/arch/x86/scrub-page.S b/xen/arch/x86/scrub-page.S
deleted file mode 100644
index efdcdab974..0000000000
--- a/xen/arch/x86/scrub-page.S
+++ /dev/null
@@ -1,38 +0,0 @@
-        .file __FILE__
-
-#include <asm/asm_defns.h>
-#include <xen/page-size.h>
-#include <xen/scrub.h>
-
-FUNC(scrub_page_cold)
-        mov     $PAGE_SIZE/32, %ecx
-        mov     $SCRUB_PATTERN, %rax
-
-0:      movnti  %rax,   (%rdi)
-        movnti  %rax,  8(%rdi)
-        movnti  %rax, 16(%rdi)
-        movnti  %rax, 24(%rdi)
-        add     $32, %rdi
-        sub     $1, %ecx
-        jnz     0b
-
-        sfence
-        RET
-END(scrub_page_cold)
-
-        .macro scrub_page_stosb
-        mov     $PAGE_SIZE, %ecx
-        mov     $SCRUB_BYTE_PATTERN, %eax
-        rep stosb
-        .endm
-
-        .macro scrub_page_stosq
-        mov     $PAGE_SIZE/8, %ecx
-        mov     $SCRUB_PATTERN, %rax
-        rep stosq
-        .endm
-
-FUNC(scrub_page_hot)
-        ALTERNATIVE scrub_page_stosq, scrub_page_stosb, X86_FEATURE_ERMS
-        RET
-END(scrub_page_hot)
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.