Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch - Add a couple of wrapper functions around STOS and...
details: https://anonhg.NetBSD.org/src/rev/a076eb0aee3c
branches: trunk
changeset: 1010527:a076eb0aee3c
user: ad <ad%NetBSD.org@localhost>
date: Wed May 27 19:33:40 2020 +0000
description:
- Add a couple of wrapper functions around STOS and MOVS and use them to zero
and copy PTEs in preference to memset()/memcpy().
- Remove related SSE / pageidlezero stuff.
diffstat:
sys/arch/amd64/amd64/cpufunc.S | 23 ++++++++++-
sys/arch/amd64/amd64/locore.S | 57 +---------------------------
sys/arch/i386/i386/cpufunc.S | 28 ++++++++++++-
sys/arch/i386/i386/locore.S | 41 +------------------
sys/arch/x86/include/pmap.h | 14 +----
sys/arch/x86/x86/pmap.c | 87 +++++++++++------------------------------
6 files changed, 79 insertions(+), 171 deletions(-)
diffs (truncated from 489 to 300 lines):
diff -r c955ec9c4519 -r a076eb0aee3c sys/arch/amd64/amd64/cpufunc.S
--- a/sys/arch/amd64/amd64/cpufunc.S Wed May 27 19:26:43 2020 +0000
+++ b/sys/arch/amd64/amd64/cpufunc.S Wed May 27 19:33:40 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpufunc.S,v 1.56 2020/05/20 18:52:48 maxv Exp $ */
+/* $NetBSD: cpufunc.S,v 1.57 2020/05/27 19:33:40 ad Exp $ */
/*
* Copyright (c) 1998, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -420,3 +420,24 @@
outl %eax, %dx
ret
END(outl)
+
+ENTRY(x86_stos)
+ pushq %rbp
+ movq %rsp,%rbp
+ movq %rsi,%rax
+ movq %rdx,%rcx
+ rep
+ stosq
+ leave
+ ret
+END(x86_stos)
+
+ENTRY(x86_movs)
+ pushq %rbp
+ movq %rsp,%rbp
+ movq %rdx,%rcx
+ rep
+ movsq
+ leave
+ ret
+END(x86_stos)
diff -r c955ec9c4519 -r a076eb0aee3c sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S Wed May 27 19:26:43 2020 +0000
+++ b/sys/arch/amd64/amd64/locore.S Wed May 27 19:33:40 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.208 2020/05/05 06:32:43 maxv Exp $ */
+/* $NetBSD: locore.S,v 1.209 2020/05/27 19:33:40 ad Exp $ */
/*
* Copyright-o-rama!
@@ -1560,61 +1560,6 @@
END(syscall_sysret)
TEXT_USER_END
-/*
- * bool sse2_idlezero_page(void *pg)
- *
- * Zero a page without polluting the cache. Preemption must be
- * disabled by the caller. Abort if a preemption is pending.
- * Returns true if the page is zeroed, false if not.
- */
-ENTRY(sse2_idlezero_page)
- pushq %rbp
- movq %rsp,%rbp
- movl $(PAGE_SIZE/64), %ecx
- xorq %rax, %rax
- .align 16
-1:
- cmpl $0, CPUVAR(RESCHED)
- jnz 2f
- movnti %rax, 0(%rdi)
- movnti %rax, 8(%rdi)
- movnti %rax, 16(%rdi)
- movnti %rax, 24(%rdi)
- movnti %rax, 32(%rdi)
- movnti %rax, 40(%rdi)
- movnti %rax, 48(%rdi)
- movnti %rax, 56(%rdi)
- addq $64, %rdi
- decl %ecx
- jnz 1b
- sfence
- incl %eax
- popq %rbp
- KMSAN_INIT_RET(1)
- ret
-2:
- sfence
- popq %rbp
- KMSAN_INIT_RET(1)
- ret
-END(sse2_idlezero_page)
-
-/*
- * void pagezero(vaddr_t va)
- *
- * Zero a page.
- */
-ENTRY(pagezero)
- pushq %rbp
- movq %rsp,%rbp
- movq $(PAGE_SIZE / 8),%rcx
- xorq %rax,%rax
- rep
- stosq
- leave
- ret
-END(pagezero)
-
TEXT_USER_BEGIN
/*
diff -r c955ec9c4519 -r a076eb0aee3c sys/arch/i386/i386/cpufunc.S
--- a/sys/arch/i386/i386/cpufunc.S Wed May 27 19:26:43 2020 +0000
+++ b/sys/arch/i386/i386/cpufunc.S Wed May 27 19:33:40 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpufunc.S,v 1.42 2020/05/27 18:47:13 ad Exp $ */
+/* $NetBSD: cpufunc.S,v 1.43 2020/05/27 19:33:40 ad Exp $ */
/*-
* Copyright (c) 1998, 2007, 2020 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
#include <sys/errno.h>
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.42 2020/05/27 18:47:13 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.43 2020/05/27 19:33:40 ad Exp $");
#include "opt_xen.h"
@@ -318,3 +318,27 @@
outl %eax, %dx
ret
END(outl)
+
+ENTRY(x86_stos)
+ pushl %ebp
+ movl %esp,%ebp
+ movl 8(%ebp),%edi
+ movl 12(%ebp),%eax
+ movl 16(%ebp),%ecx
+ rep
+ stosl
+ leave
+ ret
+END(x86_stos)
+
+ENTRY(x86_movs)
+ pushl %ebp
+ movl %esp,%ebp
+ movl 8(%ebp),%edi
+ movl 12(%ebp),%esi
+ movl 16(%ebp),%ecx
+ rep
+ movsl
+ leave
+ ret
+END(x86_stos)
diff -r c955ec9c4519 -r a076eb0aee3c sys/arch/i386/i386/locore.S
--- a/sys/arch/i386/i386/locore.S Wed May 27 19:26:43 2020 +0000
+++ b/sys/arch/i386/i386/locore.S Wed May 27 19:33:40 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.184 2020/05/05 09:07:35 bouyer Exp $ */
+/* $NetBSD: locore.S,v 1.185 2020/05/27 19:33:40 ad Exp $ */
/*
* Copyright-o-rama!
@@ -128,7 +128,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.184 2020/05/05 09:07:35 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.185 2020/05/27 19:33:40 ad Exp $");
#include "opt_copy_symtab.h"
#include "opt_ddb.h"
@@ -1641,43 +1641,6 @@
ret
END(npx586bug1)
-/*
- * void sse2_idlezero_page(void *pg)
- *
- * Zero a page without polluting the cache. Preemption must be
- * disabled by the caller. Abort if a preemption is pending.
- */
-ENTRY(sse2_idlezero_page)
- pushl %ebp
- movl %esp,%ebp
- movl 8(%esp), %edx
- movl $(PAGE_SIZE/32), %ecx
- xorl %eax, %eax
- .align 16
-1:
- cmpl $0, CPUVAR(RESCHED)
- jnz 2f
- movnti %eax, 0(%edx)
- movnti %eax, 4(%edx)
- movnti %eax, 8(%edx)
- movnti %eax, 12(%edx)
- movnti %eax, 16(%edx)
- movnti %eax, 20(%edx)
- movnti %eax, 24(%edx)
- movnti %eax, 28(%edx)
- addl $32, %edx
- decl %ecx
- jnz 1b
- sfence
- incl %eax
- pop %ebp
- ret
-2:
- sfence
- popl %ebp
- ret
-END(sse2_idlezero_page)
-
ENTRY(intrfastexit)
movw TF_GS(%esp),%gs
movw TF_FS(%esp),%fs
diff -r c955ec9c4519 -r a076eb0aee3c sys/arch/x86/include/pmap.h
--- a/sys/arch/x86/include/pmap.h Wed May 27 19:26:43 2020 +0000
+++ b/sys/arch/x86/include/pmap.h Wed May 27 19:33:40 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.121 2020/05/26 10:10:31 bouyer Exp $ */
+/* $NetBSD: pmap.h,v 1.122 2020/05/27 19:33:40 ad Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -431,12 +431,6 @@
#define PMAP_FORK /* turn on pmap_fork interface */
/*
- * Do idle page zero'ing uncached to avoid polluting the cache.
- */
-bool pmap_pageidlezero(paddr_t);
-#define PMAP_PAGEIDLEZERO(pa) pmap_pageidlezero((pa))
-
-/*
* inline functions
*/
@@ -546,7 +540,6 @@
paddr_t vtophys(vaddr_t);
vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, vm_prot_t);
void pmap_cpu_init_late(struct cpu_info *);
-bool sse2_idlezero_page(void *);
#ifdef XENPV
#include <sys/bitops.h>
@@ -617,9 +610,10 @@
#define PMAP_MAP_POOLPAGE(pa) PMAP_DIRECT_MAP((pa))
#define PMAP_UNMAP_POOLPAGE(va) PMAP_DIRECT_UNMAP((va))
-void pagezero(vaddr_t);
+#endif /* __HAVE_DIRECT_MAP */
-#endif /* __HAVE_DIRECT_MAP */
+void x86_stos(void *, long, long);
+void x86_movs(void *, void *, long);
#endif /* _KERNEL */
diff -r c955ec9c4519 -r a076eb0aee3c sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c Wed May 27 19:26:43 2020 +0000
+++ b/sys/arch/x86/x86/pmap.c Wed May 27 19:33:40 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.395 2020/05/27 19:26:43 ad Exp $ */
+/* $NetBSD: pmap.c,v 1.396 2020/05/27 19:33:40 ad Exp $ */
/*
* Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.395 2020/05/27 19:26:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.396 2020/05/27 19:33:40 ad Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@@ -1297,7 +1297,8 @@
xen_dummy_user_pgd = xen_dummy_page - KERNBASE;
/* Zero fill it, the less checks in Xen it requires the better */
- memset((void *)(xen_dummy_user_pgd + KERNBASE), 0, PAGE_SIZE);
+ x86_stos((void *)(xen_dummy_user_pgd + KERNBASE), 0,
+ PAGE_SIZE / sizeof(long));
/* Mark read-only */
HYPERVISOR_update_va_mapping(xen_dummy_user_pgd + KERNBASE,
pmap_pa2pte(xen_dummy_user_pgd) | PTE_P | pmap_pg_nx,
@@ -1546,7 +1547,7 @@
pa = pmap_bootstrap_palloc(1);
*pte = (pa & PTE_FRAME) | pteflags;
pmap_update_pg(tmpva);
- memset((void *)tmpva, 0, PAGE_SIZE);
+ x86_stos((void *)tmpva, 0, PAGE_SIZE / sizeof(long));
L4_BASE[L4e_idx+i] = pa | pteflags | PTE_A;
}
@@ -1560,7 +1561,7 @@
pa = pmap_bootstrap_palloc(1);
*pte = (pa & PTE_FRAME) | pteflags;
pmap_update_pg(tmpva);
- memset((void *)tmpva, 0, PAGE_SIZE);
+ x86_stos((void *)tmpva, 0, PAGE_SIZE / sizeof(long));
Home |
Main Index |
Thread Index |
Old Index