2 * Copyright (c) 2003 Peter Wemm.
3 * Copyright (c) 1993 The Regents of the University of California.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the University nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <machine/asmacros.h>
36 #include <machine/specialreg.h>
37 #include <machine/pmap.h>
46 movq $PAGE_SIZE/8,%rcx
65 * pagecopy(%rdi=from, %rsi=to)
69 movq $PAGE_SIZE/8,%rcx
87 * The loop takes 29 bytes. Ensure that it doesn't cross a 32-byte
92 movnti %rax,(%rdi,%rdx)
93 movnti %rax,8(%rdi,%rdx)
94 movnti %rax,16(%rdi,%rdx)
95 movnti %rax,24(%rdi,%rdx)
104 * memcmpy(b1, b2, len)
116 movzbl (%rdi,%rcx,1),%eax
117 movzbl (%rsi,%rcx,1),%r8d
123 movzbl (%rdi,%rcx,1),%eax
124 movzbl (%rsi,%rcx,1),%r8d
130 movzbl (%rdi,%rcx,1),%eax
131 movzbl (%rsi,%rcx,1),%r8d
137 movzbl (%rdi,%rcx,1),%eax
138 movzbl (%rsi,%rcx,1),%r8d
198 * memmove(dst, src, cnt)
200 * Adapted from bcopy written by:
201 * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
210 cmpq %rcx,%r8 /* overlapping && src < dst? */
215 shrq $3,%rcx /* copy by 64-bit words */
219 andq $7,%rcx /* any bytes left? */
232 addq %rcx,%rdi /* copy backwards */
237 andq $7,%rcx /* any fractional bytes? */
242 movq %rdx,%rcx /* copy remainder by 32-bit words */
260 cmpq %rcx,%r8 /* overlapping && src < dst? */
269 addq %rcx,%rdi /* copy backwards */
282 * memcpy(dst, src, len)
285 * Note: memcpy does not support overlapping copies
293 shrq $3,%rcx /* copy by 64-bit words */
297 andq $7,%rcx /* any bytes left? */
320 * memset(dst, c, len)
328 movabs $0x0101010101010101,%rax
362 /* fillw(pat, base, cnt) */
363 /* %rdi,%rsi, %rdx */
375 /*****************************************************************************/
376 /* copyout and fubyte family */
377 /*****************************************************************************/
379 * Access user memory from inside the kernel. These routines should be
380 * the only places that do this.
382 * These routines set curpcb->pcb_onfault for the time they execute. When a
383 * protection violation occurs inside the functions, the trap handler
384 * returns to *curpcb->pcb_onfault instead of the function.
387 .macro SMAP_DISABLE smap
394 .macro SMAP_ENABLE smap
401 * copyout(from_kernel, to_user, len)
404 .macro COPYOUT smap erms
406 movq PCPU(CURPCB),%r9
407 /* Trap entry clears PSL.AC */
408 movq $copy_fault,PCB_ONFAULT(%r9)
409 testq %rdx,%rdx /* anything to do? */
413 * Check explicitly for non-user addresses. If 486 write protection
414 * is being used, this check is essential because we are in kernel
415 * mode so the h/w does not provide any protection against writing
420 * First, prevent address wrapping.
426 * XXX STOP USING VM_MAXUSER_ADDRESS.
427 * It is an end address, not a max, so every time it is used correctly it
428 * looks like there is an off by one error, and of course it caused an off
429 * by one error in several places.
431 movq $VM_MAXUSER_ADDRESS,%rcx
436 /* bcopy(%rsi, %rdi, %rdx) */
451 movq %rax,PCB_ONFAULT(%r9)
461 movq %rax,PCB_ONFAULT(%r9)
466 ENTRY(copyout_nosmap_std)
467 COPYOUT smap=0 erms=0
468 END(copyout_nosmap_std)
470 ENTRY(copyout_smap_std)
471 COPYOUT smap=1 erms=0
472 END(copyout_smap_std)
474 ENTRY(copyout_nosmap_erms)
475 COPYOUT smap=0 erms=1
476 END(copyout_nosmap_erms)
478 ENTRY(copyout_smap_erms)
479 COPYOUT smap=1 erms=1
480 END(copyout_smap_erms)
483 * copyin(from_user, to_kernel, len)
486 .macro COPYIN smap erms
488 movq PCPU(CURPCB),%r9
489 movq $copy_fault,PCB_ONFAULT(%r9)
490 testq %rdx,%rdx /* anything to do? */
494 * make sure address is valid
499 movq $VM_MAXUSER_ADDRESS,%rcx
511 shrq $3,%rcx /* copy longword-wise */
515 andb $7,%cl /* copy remaining bytes */
519 movq %rax,PCB_ONFAULT(%r9)
530 movq %rax,PCB_ONFAULT(%r9)
535 ENTRY(copyin_nosmap_std)
537 END(copyin_nosmap_std)
539 ENTRY(copyin_smap_std)
543 ENTRY(copyin_nosmap_erms)
545 END(copyin_nosmap_erms)
547 ENTRY(copyin_smap_erms)
549 END(copyin_smap_erms)
553 movq PCPU(CURPCB),%rdx
554 movq $0,PCB_ONFAULT(%rdx)
560 * casueword32. Compare and set user integer. Returns -1 on fault,
561 * 0 if access was successful. Old value is written to *oldp.
562 * dst = %rdi, old = %esi, oldp = %rdx, new = %ecx
564 ENTRY(casueword32_nosmap)
566 movq PCPU(CURPCB),%r8
567 movq $fusufault,PCB_ONFAULT(%r8)
569 movq $VM_MAXUSER_ADDRESS-4,%rax
570 cmpq %rax,%rdi /* verify address is valid */
573 movl %esi,%eax /* old */
577 cmpxchgl %ecx,(%rdi) /* new = %ecx */
580 * The old value is in %eax. If the store succeeded it will be the
581 * value we expected (old) from before the store, otherwise it will
582 * be the current value. Save %eax into %esi to prepare the return
587 movq %rax,PCB_ONFAULT(%r8)
590 * Access the oldp after the pcb_onfault is cleared, to correctly
591 * catch corrupted pointer.
593 movl %esi,(%rdx) /* oldp = %rdx */
596 END(casueword32_nosmap)
598 ENTRY(casueword32_smap)
600 movq PCPU(CURPCB),%r8
601 movq $fusufault,PCB_ONFAULT(%r8)
603 movq $VM_MAXUSER_ADDRESS-4,%rax
604 cmpq %rax,%rdi /* verify address is valid */
607 movl %esi,%eax /* old */
612 cmpxchgl %ecx,(%rdi) /* new = %ecx */
616 * The old value is in %eax. If the store succeeded it will be the
617 * value we expected (old) from before the store, otherwise it will
618 * be the current value. Save %eax into %esi to prepare the return
623 movq %rax,PCB_ONFAULT(%r8)
626 * Access the oldp after the pcb_onfault is cleared, to correctly
627 * catch corrupted pointer.
629 movl %esi,(%rdx) /* oldp = %rdx */
632 END(casueword32_smap)
635 * casueword. Compare and set user long. Returns -1 on fault,
636 * 0 if access was successful. Old value is written to *oldp.
637 * dst = %rdi, old = %rsi, oldp = %rdx, new = %rcx
639 ENTRY(casueword_nosmap)
641 movq PCPU(CURPCB),%r8
642 movq $fusufault,PCB_ONFAULT(%r8)
644 movq $VM_MAXUSER_ADDRESS-4,%rax
645 cmpq %rax,%rdi /* verify address is valid */
648 movq %rsi,%rax /* old */
652 cmpxchgq %rcx,(%rdi) /* new = %rcx */
655 * The old value is in %rax. If the store succeeded it will be the
656 * value we expected (old) from before the store, otherwise it will
657 * be the current value.
661 movq %rax,PCB_ONFAULT(%r8)
665 END(casueword_nosmap)
667 ENTRY(casueword_smap)
669 movq PCPU(CURPCB),%r8
670 movq $fusufault,PCB_ONFAULT(%r8)
672 movq $VM_MAXUSER_ADDRESS-4,%rax
673 cmpq %rax,%rdi /* verify address is valid */
676 movq %rsi,%rax /* old */
681 cmpxchgq %rcx,(%rdi) /* new = %rcx */
685 * The old value is in %rax. If the store succeeded it will be the
686 * value we expected (old) from before the store, otherwise it will
687 * be the current value.
691 movq %rax,PCB_ONFAULT(%r8)
698 * Fetch (load) a 64-bit word, a 32-bit word, a 16-bit word, or an 8-bit
699 * byte from user memory.
700 * addr = %rdi, valp = %rsi
703 ENTRY(fueword_nosmap)
705 movq PCPU(CURPCB),%rcx
706 movq $fusufault,PCB_ONFAULT(%rcx)
708 movq $VM_MAXUSER_ADDRESS-8,%rax
709 cmpq %rax,%rdi /* verify address is valid */
714 movq %rax,PCB_ONFAULT(%rcx)
722 movq PCPU(CURPCB),%rcx
723 movq $fusufault,PCB_ONFAULT(%rcx)
725 movq $VM_MAXUSER_ADDRESS-8,%rax
726 cmpq %rax,%rdi /* verify address is valid */
733 movq %rax,PCB_ONFAULT(%rcx)
739 ENTRY(fueword32_nosmap)
741 movq PCPU(CURPCB),%rcx
742 movq $fusufault,PCB_ONFAULT(%rcx)
744 movq $VM_MAXUSER_ADDRESS-4,%rax
745 cmpq %rax,%rdi /* verify address is valid */
750 movq %rax,PCB_ONFAULT(%rcx)
754 END(fueword32_nosmap)
756 ENTRY(fueword32_smap)
758 movq PCPU(CURPCB),%rcx
759 movq $fusufault,PCB_ONFAULT(%rcx)
761 movq $VM_MAXUSER_ADDRESS-4,%rax
762 cmpq %rax,%rdi /* verify address is valid */
769 movq %rax,PCB_ONFAULT(%rcx)
775 ENTRY(fuword16_nosmap)
777 movq PCPU(CURPCB),%rcx
778 movq $fusufault,PCB_ONFAULT(%rcx)
780 movq $VM_MAXUSER_ADDRESS-2,%rax
785 movq $0,PCB_ONFAULT(%rcx)
792 movq PCPU(CURPCB),%rcx
793 movq $fusufault,PCB_ONFAULT(%rcx)
795 movq $VM_MAXUSER_ADDRESS-2,%rax
802 movq $0,PCB_ONFAULT(%rcx)
809 movq PCPU(CURPCB),%rcx
810 movq $fusufault,PCB_ONFAULT(%rcx)
812 movq $VM_MAXUSER_ADDRESS-1,%rax
817 movq $0,PCB_ONFAULT(%rcx)
824 movq PCPU(CURPCB),%rcx
825 movq $fusufault,PCB_ONFAULT(%rcx)
827 movq $VM_MAXUSER_ADDRESS-1,%rax
834 movq $0,PCB_ONFAULT(%rcx)
840 * Store a 64-bit word, a 32-bit word, a 16-bit word, or an 8-bit byte to
842 * addr = %rdi, value = %rsi
846 movq PCPU(CURPCB),%rcx
847 movq $fusufault,PCB_ONFAULT(%rcx)
849 movq $VM_MAXUSER_ADDRESS-8,%rax
850 cmpq %rax,%rdi /* verify address validity */
855 movq PCPU(CURPCB),%rcx
856 movq %rax,PCB_ONFAULT(%rcx)
863 movq PCPU(CURPCB),%rcx
864 movq $fusufault,PCB_ONFAULT(%rcx)
866 movq $VM_MAXUSER_ADDRESS-8,%rax
867 cmpq %rax,%rdi /* verify address validity */
874 movq PCPU(CURPCB),%rcx
875 movq %rax,PCB_ONFAULT(%rcx)
880 ENTRY(suword32_nosmap)
882 movq PCPU(CURPCB),%rcx
883 movq $fusufault,PCB_ONFAULT(%rcx)
885 movq $VM_MAXUSER_ADDRESS-4,%rax
886 cmpq %rax,%rdi /* verify address validity */
891 movq PCPU(CURPCB),%rcx
892 movq %rax,PCB_ONFAULT(%rcx)
899 movq PCPU(CURPCB),%rcx
900 movq $fusufault,PCB_ONFAULT(%rcx)
902 movq $VM_MAXUSER_ADDRESS-4,%rax
903 cmpq %rax,%rdi /* verify address validity */
910 movq PCPU(CURPCB),%rcx
911 movq %rax,PCB_ONFAULT(%rcx)
916 ENTRY(suword16_nosmap)
918 movq PCPU(CURPCB),%rcx
919 movq $fusufault,PCB_ONFAULT(%rcx)
921 movq $VM_MAXUSER_ADDRESS-2,%rax
922 cmpq %rax,%rdi /* verify address validity */
927 movq PCPU(CURPCB),%rcx /* restore trashed register */
928 movq %rax,PCB_ONFAULT(%rcx)
935 movq PCPU(CURPCB),%rcx
936 movq $fusufault,PCB_ONFAULT(%rcx)
938 movq $VM_MAXUSER_ADDRESS-2,%rax
939 cmpq %rax,%rdi /* verify address validity */
946 movq PCPU(CURPCB),%rcx /* restore trashed register */
947 movq %rax,PCB_ONFAULT(%rcx)
954 movq PCPU(CURPCB),%rcx
955 movq $fusufault,PCB_ONFAULT(%rcx)
957 movq $VM_MAXUSER_ADDRESS-1,%rax
958 cmpq %rax,%rdi /* verify address validity */
964 movq PCPU(CURPCB),%rcx /* restore trashed register */
965 movq %rax,PCB_ONFAULT(%rcx)
972 movq PCPU(CURPCB),%rcx
973 movq $fusufault,PCB_ONFAULT(%rcx)
975 movq $VM_MAXUSER_ADDRESS-1,%rax
976 cmpq %rax,%rdi /* verify address validity */
984 movq PCPU(CURPCB),%rcx /* restore trashed register */
985 movq %rax,PCB_ONFAULT(%rcx)
991 /* Fault entry clears PSL.AC */
993 movq PCPU(CURPCB),%rcx
995 movq %rax,PCB_ONFAULT(%rcx)
1001 * copyinstr(from, to, maxlen, int *lencopied)
1002 * %rdi, %rsi, %rdx, %rcx
1004 * copy a string from 'from' to 'to', stop when a 0 character is reached.
1005 * return ENAMETOOLONG if string is longer than maxlen, and
1006 * EFAULT on protection violations. If lencopied is non-zero,
1007 * return the actual length in *lencopied.
1009 ENTRY(copyinstr_nosmap)
1011 movq %rdx,%r8 /* %r8 = maxlen */
1012 movq %rcx,%r9 /* %r9 = *len */
1013 xchgq %rdi,%rsi /* %rdi = from, %rsi = to */
1014 movq PCPU(CURPCB),%rcx
1015 movq $cpystrflt,PCB_ONFAULT(%rcx)
1017 movq $VM_MAXUSER_ADDRESS,%rax
1019 /* make sure 'from' is within bounds */
1023 /* restrict maxlen to <= VM_MAXUSER_ADDRESS-from */
1033 jz copyinstr_toolong
1041 END(copyinstr_nosmap)
1043 ENTRY(copyinstr_smap)
1045 movq %rdx,%r8 /* %r8 = maxlen */
1046 movq %rcx,%r9 /* %r9 = *len */
1047 xchgq %rdi,%rsi /* %rdi = from, %rsi = to */
1048 movq PCPU(CURPCB),%rcx
1049 movq $cpystrflt,PCB_ONFAULT(%rcx)
1051 movq $VM_MAXUSER_ADDRESS,%rax
1053 /* make sure 'from' is within bounds */
1059 /* restrict maxlen to <= VM_MAXUSER_ADDRESS-from */
1069 jz copyinstr_toolong_smap
1079 /* Success -- 0 byte reached */
1084 /* set *lencopied and return %eax */
1085 movq PCPU(CURPCB),%rcx
1086 movq $0,PCB_ONFAULT(%rcx)
1095 /* Fault entry clears PSL.AC */
1100 copyinstr_toolong_smap:
1103 /* rdx is zero - return ENAMETOOLONG or EFAULT */
1104 movq $VM_MAXUSER_ADDRESS,%rax
1107 movq $ENAMETOOLONG,%rax
1113 * copystr(from, to, maxlen, int *lencopied)
1114 * %rdi, %rsi, %rdx, %rcx
1118 movq %rdx,%r8 /* %r8 = maxlen */
1130 /* Success -- 0 byte reached */
1135 /* rdx is zero -- return ENAMETOOLONG */
1136 movq $ENAMETOOLONG,%rax
1142 /* set *lencopied and return %rax */
1151 * Handling of special amd64 registers and descriptor tables etc
1153 /* void lgdt(struct region_descriptor *rdp); */
1155 /* reload the descriptor table */
1158 /* flush the prefetch q */
1165 movl %eax,%fs /* Beware, use wrmsr to set 64 bit base */
1169 /* reload code selector by turning return into intersegmental return */
1177 /*****************************************************************************/
1178 /* setjump, longjump */
1179 /*****************************************************************************/
1182 movq %rbx,0(%rdi) /* save rbx */
1183 movq %rsp,8(%rdi) /* save rsp */
1184 movq %rbp,16(%rdi) /* save rbp */
1185 movq %r12,24(%rdi) /* save r12 */
1186 movq %r13,32(%rdi) /* save r13 */
1187 movq %r14,40(%rdi) /* save r14 */
1188 movq %r15,48(%rdi) /* save r15 */
1189 movq 0(%rsp),%rdx /* get rta */
1190 movq %rdx,56(%rdi) /* save rip */
1191 xorl %eax,%eax /* return(0); */
1196 movq 0(%rdi),%rbx /* restore rbx */
1197 movq 8(%rdi),%rsp /* restore rsp */
1198 movq 16(%rdi),%rbp /* restore rbp */
1199 movq 24(%rdi),%r12 /* restore r12 */
1200 movq 32(%rdi),%r13 /* restore r13 */
1201 movq 40(%rdi),%r14 /* restore r14 */
1202 movq 48(%rdi),%r15 /* restore r15 */
1203 movq 56(%rdi),%rdx /* get rta */
1204 movq %rdx,0(%rsp) /* put in return frame */
1205 xorl %eax,%eax /* return(1); */
1211 * Support for reading MSRs in the safe manner. (Instead of panic on #gp,
1215 /* int rdmsr_safe(u_int msr, uint64_t *data) */
1217 movq PCPU(CURPCB),%r8
1218 movq $msr_onfault,PCB_ONFAULT(%r8)
1220 rdmsr /* Read MSR pointed by %ecx. Returns
1221 hi byte in edx, lo in %eax */
1222 salq $32,%rdx /* sign-shift %rdx left */
1223 movl %eax,%eax /* zero-extend %eax -> %rax */
1227 movq %rax,PCB_ONFAULT(%r8)
1232 * Support for writing MSRs in the safe manner. (Instead of panic on #gp,
1236 /* int wrmsr_safe(u_int msr, uint64_t data) */
1238 movq PCPU(CURPCB),%r8
1239 movq $msr_onfault,PCB_ONFAULT(%r8)
1244 wrmsr /* Write MSR pointed by %ecx. Accepts
1245 hi byte in edx, lo in %eax. */
1247 movq %rax,PCB_ONFAULT(%r8)
1252 * MSR operations fault handler
1256 movq $0,PCB_ONFAULT(%r8)
1262 * void pmap_pti_pcid_invalidate(uint64_t ucr3, uint64_t kcr3);
1263 * Invalidates address space addressed by ucr3, then returns to kcr3.
1264 * Done in assembler to ensure no other memory accesses happen while
1268 ENTRY(pmap_pti_pcid_invalidate)
1271 movq %rdi,%cr3 /* to user page table */
1272 movq %rsi,%cr3 /* back to kernel */
1277 * void pmap_pti_pcid_invlpg(uint64_t ucr3, uint64_t kcr3, vm_offset_t va);
1278 * Invalidates virtual address va in address space ucr3, then returns to kcr3.
1281 ENTRY(pmap_pti_pcid_invlpg)
1284 movq %rdi,%cr3 /* to user page table */
1286 movq %rsi,%cr3 /* back to kernel */
1291 * void pmap_pti_pcid_invlrng(uint64_t ucr3, uint64_t kcr3, vm_offset_t sva,
1293 * Invalidates virtual addresses between sva and eva in address space ucr3,
1294 * then returns to kcr3.
1297 ENTRY(pmap_pti_pcid_invlrng)
1300 movq %rdi,%cr3 /* to user page table */
1302 addq $PAGE_SIZE,%rdx
1305 movq %rsi,%cr3 /* back to kernel */
1310 .macro ibrs_seq_label l
1313 .macro ibrs_call_label l
1316 .macro ibrs_seq count
1319 ibrs_call_label %(ll)
1321 ibrs_seq_label %(ll)
1327 /* all callers already saved %rax, %rdx, and %rcx */
1328 ENTRY(handle_ibrs_entry)
1329 cmpb $0,hw_ibrs_active(%rip)
1331 movl $MSR_IA32_SPEC_CTRL,%ecx
1333 orl $(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax
1334 orl $(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32,%edx
1336 movb $1,PCPU(IBPB_SET)
1337 testl $CPUID_STDEXT_SMEP,cpu_stdext_feature(%rip)
1341 END(handle_ibrs_entry)
1343 ENTRY(handle_ibrs_exit)
1344 cmpb $0,PCPU(IBPB_SET)
1346 movl $MSR_IA32_SPEC_CTRL,%ecx
1348 andl $~(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax
1349 andl $~((IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32),%edx
1351 movb $0,PCPU(IBPB_SET)
1353 END(handle_ibrs_exit)
1355 /* registers-neutral version, but needs stack */
1356 ENTRY(handle_ibrs_exit_rs)
1357 cmpb $0,PCPU(IBPB_SET)
1362 movl $MSR_IA32_SPEC_CTRL,%ecx
1364 andl $~(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax
1365 andl $~((IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32),%edx
1370 movb $0,PCPU(IBPB_SET)
1372 END(handle_ibrs_exit_rs)
1377 * Flush L1D cache. Load enough of the data from the kernel text
1378 * to flush existing L1D content.
1380 * N.B. The function does not follow ABI calling conventions, it corrupts %rbx.
1381 * The vmm.ko caller expects that only %rax, %rdx, %rbx, %rcx, %r9, and %rflags
1382 * registers are clobbered. The NMI handler caller only needs %r13 preserved.
1385 #define L1D_FLUSH_SIZE (64 * 1024)
1387 movq $-L1D_FLUSH_SIZE, %rcx
1389 * pass 1: Preload TLB.
1390 * Kernel text is mapped using superpages. TLB preload is
1391 * done for the benefit of older CPUs which split 2M page
1392 * into 4k TLB entries.
1394 1: movb L1D_FLUSH_SIZE(%r9, %rcx), %al
1395 addq $PAGE_SIZE, %rcx
1399 movq $-L1D_FLUSH_SIZE, %rcx
1400 /* pass 2: Read each cache line. */
1401 2: movb L1D_FLUSH_SIZE(%r9, %rcx), %al
1406 #undef L1D_FLUSH_SIZE