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
205 * Register state at entry is supposed to be as follows:
210 * The macro possibly clobbers the above and: rcx, r8.
211 * It does not clobber rax, r10 nor r11.
213 .macro MEMMOVE erms overlap begin end
218 cmpq %rcx,%r8 /* overlapping && src < dst? */
300 shrq $3,%rcx /* copy by 64-bit words */
304 andb $7,%cl /* any bytes left? */
399 andq $7,%rcx /* any fractional bytes? */
404 movq %rdx,%rcx /* copy remainder by 32-bit words */
428 MEMMOVE erms=0 overlap=1 begin=MEMMOVE_BEGIN end=MEMMOVE_END
432 MEMMOVE erms=1 overlap=1 begin=MEMMOVE_BEGIN end=MEMMOVE_END
436 * memcpy(dst, src, len)
439 * Note: memcpy does not support overlapping copies
442 MEMMOVE erms=0 overlap=0 begin=MEMMOVE_BEGIN end=MEMMOVE_END
446 MEMMOVE erms=1 overlap=0 begin=MEMMOVE_BEGIN end=MEMMOVE_END
450 * memset(dst, c, len)
458 movabs $0x0101010101010101,%rax
541 /* fillw(pat, base, cnt) */
542 /* %rdi,%rsi, %rdx */
554 /*****************************************************************************/
555 /* copyout and fubyte family */
556 /*****************************************************************************/
558 * Access user memory from inside the kernel. These routines should be
559 * the only places that do this.
561 * These routines set curpcb->pcb_onfault for the time they execute. When a
562 * protection violation occurs inside the functions, the trap handler
563 * returns to *curpcb->pcb_onfault instead of the function.
566 .macro SMAP_DISABLE smap
573 .macro SMAP_ENABLE smap
580 * copyout(from_kernel, to_user, len)
583 .macro COPYOUT smap erms
585 movq PCPU(CURPCB),%r9
586 movq $copy_fault,PCB_ONFAULT(%r9)
589 * Check explicitly for non-user addresses. If 486 write protection
590 * is being used, this check is essential because we are in kernel
591 * mode so the h/w does not provide any protection against writing
596 * First, prevent address wrapping.
602 * XXX STOP USING VM_MAXUSER_ADDRESS.
603 * It is an end address, not a max, so every time it is used correctly it
604 * looks like there is an off by one error, and of course it caused an off
605 * by one error in several places.
607 movq $VM_MAXUSER_ADDRESS,%rcx
612 * Set up arguments for rep movs*.
620 * Set return value to zero. Remaining failure mode goes through
636 movq %rax,PCB_ONFAULT(%r9)
646 movq %rax,PCB_ONFAULT(%r9)
651 ENTRY(copyout_nosmap_std)
652 COPYOUT smap=0 erms=0
653 END(copyout_nosmap_std)
655 ENTRY(copyout_smap_std)
656 COPYOUT smap=1 erms=0
657 END(copyout_smap_std)
659 ENTRY(copyout_nosmap_erms)
660 COPYOUT smap=0 erms=1
661 END(copyout_nosmap_erms)
663 ENTRY(copyout_smap_erms)
664 COPYOUT smap=1 erms=1
665 END(copyout_smap_erms)
668 * copyin(from_user, to_kernel, len)
671 .macro COPYIN smap erms
673 movq PCPU(CURPCB),%r9
674 movq $copy_fault,PCB_ONFAULT(%r9)
677 * make sure address is valid
682 movq $VM_MAXUSER_ADDRESS,%rcx
697 shrq $3,%rcx /* copy longword-wise */
701 andb $7,%cl /* copy remaining bytes */
704 movq %rax,PCB_ONFAULT(%r9)
714 movq %rax,PCB_ONFAULT(%r9)
719 ENTRY(copyin_nosmap_std)
721 END(copyin_nosmap_std)
723 ENTRY(copyin_smap_std)
727 ENTRY(copyin_nosmap_erms)
729 END(copyin_nosmap_erms)
731 ENTRY(copyin_smap_erms)
733 END(copyin_smap_erms)
736 /* Trap entry clears PSL.AC */
738 movq $0,PCB_ONFAULT(%r9)
744 * casueword32. Compare and set user integer. Returns -1 on fault,
745 * 0 if access was successful. Old value is written to *oldp.
746 * dst = %rdi, old = %esi, oldp = %rdx, new = %ecx
748 ENTRY(casueword32_nosmap)
750 movq PCPU(CURPCB),%r8
751 movq $fusufault,PCB_ONFAULT(%r8)
753 movq $VM_MAXUSER_ADDRESS-4,%rax
754 cmpq %rax,%rdi /* verify address is valid */
757 movl %esi,%eax /* old */
761 cmpxchgl %ecx,(%rdi) /* new = %ecx */
764 * The old value is in %eax. If the store succeeded it will be the
765 * value we expected (old) from before the store, otherwise it will
766 * be the current value. Save %eax into %esi to prepare the return
771 movq %rax,PCB_ONFAULT(%r8)
774 * Access the oldp after the pcb_onfault is cleared, to correctly
775 * catch corrupted pointer.
777 movl %esi,(%rdx) /* oldp = %rdx */
780 END(casueword32_nosmap)
782 ENTRY(casueword32_smap)
784 movq PCPU(CURPCB),%r8
785 movq $fusufault,PCB_ONFAULT(%r8)
787 movq $VM_MAXUSER_ADDRESS-4,%rax
788 cmpq %rax,%rdi /* verify address is valid */
791 movl %esi,%eax /* old */
796 cmpxchgl %ecx,(%rdi) /* new = %ecx */
800 * The old value is in %eax. If the store succeeded it will be the
801 * value we expected (old) from before the store, otherwise it will
802 * be the current value. Save %eax into %esi to prepare the return
807 movq %rax,PCB_ONFAULT(%r8)
810 * Access the oldp after the pcb_onfault is cleared, to correctly
811 * catch corrupted pointer.
813 movl %esi,(%rdx) /* oldp = %rdx */
816 END(casueword32_smap)
819 * casueword. Compare and set user long. Returns -1 on fault,
820 * 0 if access was successful. Old value is written to *oldp.
821 * dst = %rdi, old = %rsi, oldp = %rdx, new = %rcx
823 ENTRY(casueword_nosmap)
825 movq PCPU(CURPCB),%r8
826 movq $fusufault,PCB_ONFAULT(%r8)
828 movq $VM_MAXUSER_ADDRESS-4,%rax
829 cmpq %rax,%rdi /* verify address is valid */
832 movq %rsi,%rax /* old */
836 cmpxchgq %rcx,(%rdi) /* new = %rcx */
839 * The old value is in %rax. If the store succeeded it will be the
840 * value we expected (old) from before the store, otherwise it will
841 * be the current value.
845 movq %rax,PCB_ONFAULT(%r8)
849 END(casueword_nosmap)
851 ENTRY(casueword_smap)
853 movq PCPU(CURPCB),%r8
854 movq $fusufault,PCB_ONFAULT(%r8)
856 movq $VM_MAXUSER_ADDRESS-4,%rax
857 cmpq %rax,%rdi /* verify address is valid */
860 movq %rsi,%rax /* old */
865 cmpxchgq %rcx,(%rdi) /* new = %rcx */
869 * The old value is in %rax. If the store succeeded it will be the
870 * value we expected (old) from before the store, otherwise it will
871 * be the current value.
875 movq %rax,PCB_ONFAULT(%r8)
882 * Fetch (load) a 64-bit word, a 32-bit word, a 16-bit word, or an 8-bit
883 * byte from user memory.
884 * addr = %rdi, valp = %rsi
887 ENTRY(fueword_nosmap)
889 movq PCPU(CURPCB),%rcx
890 movq $fusufault,PCB_ONFAULT(%rcx)
892 movq $VM_MAXUSER_ADDRESS-8,%rax
893 cmpq %rax,%rdi /* verify address is valid */
898 movq %rax,PCB_ONFAULT(%rcx)
906 movq PCPU(CURPCB),%rcx
907 movq $fusufault,PCB_ONFAULT(%rcx)
909 movq $VM_MAXUSER_ADDRESS-8,%rax
910 cmpq %rax,%rdi /* verify address is valid */
917 movq %rax,PCB_ONFAULT(%rcx)
923 ENTRY(fueword32_nosmap)
925 movq PCPU(CURPCB),%rcx
926 movq $fusufault,PCB_ONFAULT(%rcx)
928 movq $VM_MAXUSER_ADDRESS-4,%rax
929 cmpq %rax,%rdi /* verify address is valid */
934 movq %rax,PCB_ONFAULT(%rcx)
938 END(fueword32_nosmap)
940 ENTRY(fueword32_smap)
942 movq PCPU(CURPCB),%rcx
943 movq $fusufault,PCB_ONFAULT(%rcx)
945 movq $VM_MAXUSER_ADDRESS-4,%rax
946 cmpq %rax,%rdi /* verify address is valid */
953 movq %rax,PCB_ONFAULT(%rcx)
959 ENTRY(fuword16_nosmap)
961 movq PCPU(CURPCB),%rcx
962 movq $fusufault,PCB_ONFAULT(%rcx)
964 movq $VM_MAXUSER_ADDRESS-2,%rax
969 movq $0,PCB_ONFAULT(%rcx)
976 movq PCPU(CURPCB),%rcx
977 movq $fusufault,PCB_ONFAULT(%rcx)
979 movq $VM_MAXUSER_ADDRESS-2,%rax
986 movq $0,PCB_ONFAULT(%rcx)
993 movq PCPU(CURPCB),%rcx
994 movq $fusufault,PCB_ONFAULT(%rcx)
996 movq $VM_MAXUSER_ADDRESS-1,%rax
1001 movq $0,PCB_ONFAULT(%rcx)
1008 movq PCPU(CURPCB),%rcx
1009 movq $fusufault,PCB_ONFAULT(%rcx)
1011 movq $VM_MAXUSER_ADDRESS-1,%rax
1018 movq $0,PCB_ONFAULT(%rcx)
1024 * Store a 64-bit word, a 32-bit word, a 16-bit word, or an 8-bit byte to
1026 * addr = %rdi, value = %rsi
1028 ENTRY(suword_nosmap)
1030 movq PCPU(CURPCB),%rcx
1031 movq $fusufault,PCB_ONFAULT(%rcx)
1033 movq $VM_MAXUSER_ADDRESS-8,%rax
1034 cmpq %rax,%rdi /* verify address validity */
1039 movq PCPU(CURPCB),%rcx
1040 movq %rax,PCB_ONFAULT(%rcx)
1047 movq PCPU(CURPCB),%rcx
1048 movq $fusufault,PCB_ONFAULT(%rcx)
1050 movq $VM_MAXUSER_ADDRESS-8,%rax
1051 cmpq %rax,%rdi /* verify address validity */
1058 movq PCPU(CURPCB),%rcx
1059 movq %rax,PCB_ONFAULT(%rcx)
1064 ENTRY(suword32_nosmap)
1066 movq PCPU(CURPCB),%rcx
1067 movq $fusufault,PCB_ONFAULT(%rcx)
1069 movq $VM_MAXUSER_ADDRESS-4,%rax
1070 cmpq %rax,%rdi /* verify address validity */
1075 movq PCPU(CURPCB),%rcx
1076 movq %rax,PCB_ONFAULT(%rcx)
1079 END(suword32_nosmap)
1081 ENTRY(suword32_smap)
1083 movq PCPU(CURPCB),%rcx
1084 movq $fusufault,PCB_ONFAULT(%rcx)
1086 movq $VM_MAXUSER_ADDRESS-4,%rax
1087 cmpq %rax,%rdi /* verify address validity */
1094 movq PCPU(CURPCB),%rcx
1095 movq %rax,PCB_ONFAULT(%rcx)
1100 ENTRY(suword16_nosmap)
1102 movq PCPU(CURPCB),%rcx
1103 movq $fusufault,PCB_ONFAULT(%rcx)
1105 movq $VM_MAXUSER_ADDRESS-2,%rax
1106 cmpq %rax,%rdi /* verify address validity */
1111 movq PCPU(CURPCB),%rcx /* restore trashed register */
1112 movq %rax,PCB_ONFAULT(%rcx)
1115 END(suword16_nosmap)
1117 ENTRY(suword16_smap)
1119 movq PCPU(CURPCB),%rcx
1120 movq $fusufault,PCB_ONFAULT(%rcx)
1122 movq $VM_MAXUSER_ADDRESS-2,%rax
1123 cmpq %rax,%rdi /* verify address validity */
1130 movq PCPU(CURPCB),%rcx /* restore trashed register */
1131 movq %rax,PCB_ONFAULT(%rcx)
1136 ENTRY(subyte_nosmap)
1138 movq PCPU(CURPCB),%rcx
1139 movq $fusufault,PCB_ONFAULT(%rcx)
1141 movq $VM_MAXUSER_ADDRESS-1,%rax
1142 cmpq %rax,%rdi /* verify address validity */
1148 movq PCPU(CURPCB),%rcx /* restore trashed register */
1149 movq %rax,PCB_ONFAULT(%rcx)
1156 movq PCPU(CURPCB),%rcx
1157 movq $fusufault,PCB_ONFAULT(%rcx)
1159 movq $VM_MAXUSER_ADDRESS-1,%rax
1160 cmpq %rax,%rdi /* verify address validity */
1168 movq PCPU(CURPCB),%rcx /* restore trashed register */
1169 movq %rax,PCB_ONFAULT(%rcx)
1175 /* Fault entry clears PSL.AC */
1177 movq PCPU(CURPCB),%rcx
1179 movq %rax,PCB_ONFAULT(%rcx)
1185 * copyinstr(from, to, maxlen, int *lencopied)
1186 * %rdi, %rsi, %rdx, %rcx
1188 * copy a string from 'from' to 'to', stop when a 0 character is reached.
1189 * return ENAMETOOLONG if string is longer than maxlen, and
1190 * EFAULT on protection violations. If lencopied is non-zero,
1191 * return the actual length in *lencopied.
1193 .macro COPYINSTR smap
1195 movq %rdx,%r8 /* %r8 = maxlen */
1196 movq PCPU(CURPCB),%r9
1197 movq $cpystrflt,PCB_ONFAULT(%r9)
1199 movq $VM_MAXUSER_ADDRESS,%rax
1201 /* make sure 'from' is within bounds */
1207 /* restrict maxlen to <= VM_MAXUSER_ADDRESS-from */
1215 jz copyinstr_toolong
1217 jz copyinstr_toolong_smap
1229 /* Success -- 0 byte reached */
1233 /* set *lencopied and return %eax */
1234 movq %rax,PCB_ONFAULT(%r9)
1251 ENTRY(copyinstr_nosmap)
1253 END(copyinstr_nosmap)
1255 ENTRY(copyinstr_smap)
1260 /* Fault entry clears PSL.AC */
1263 /* set *lencopied and return %eax */
1264 movq $0,PCB_ONFAULT(%r9)
1274 copyinstr_toolong_smap:
1277 /* rdx is zero - return ENAMETOOLONG or EFAULT */
1278 movq $VM_MAXUSER_ADDRESS,%rax
1281 movl $ENAMETOOLONG,%eax
1285 * copystr(from, to, maxlen, int *lencopied)
1286 * %rdi, %rsi, %rdx, %rcx
1290 movq %rdx,%r8 /* %r8 = maxlen */
1303 /* Success -- 0 byte reached */
1309 /* set *lencopied and return %rax */
1316 /* rdx is zero -- return ENAMETOOLONG */
1317 movl $ENAMETOOLONG,%eax
1322 * Handling of special amd64 registers and descriptor tables etc
1324 /* void lgdt(struct region_descriptor *rdp); */
1326 /* reload the descriptor table */
1329 /* flush the prefetch q */
1336 movl %eax,%fs /* Beware, use wrmsr to set 64 bit base */
1340 /* reload code selector by turning return into intersegmental return */
1348 /*****************************************************************************/
1349 /* setjump, longjump */
1350 /*****************************************************************************/
1353 movq %rbx,0(%rdi) /* save rbx */
1354 movq %rsp,8(%rdi) /* save rsp */
1355 movq %rbp,16(%rdi) /* save rbp */
1356 movq %r12,24(%rdi) /* save r12 */
1357 movq %r13,32(%rdi) /* save r13 */
1358 movq %r14,40(%rdi) /* save r14 */
1359 movq %r15,48(%rdi) /* save r15 */
1360 movq 0(%rsp),%rdx /* get rta */
1361 movq %rdx,56(%rdi) /* save rip */
1362 xorl %eax,%eax /* return(0); */
1367 movq 0(%rdi),%rbx /* restore rbx */
1368 movq 8(%rdi),%rsp /* restore rsp */
1369 movq 16(%rdi),%rbp /* restore rbp */
1370 movq 24(%rdi),%r12 /* restore r12 */
1371 movq 32(%rdi),%r13 /* restore r13 */
1372 movq 40(%rdi),%r14 /* restore r14 */
1373 movq 48(%rdi),%r15 /* restore r15 */
1374 movq 56(%rdi),%rdx /* get rta */
1375 movq %rdx,0(%rsp) /* put in return frame */
1376 xorl %eax,%eax /* return(1); */
1382 * Support for reading MSRs in the safe manner. (Instead of panic on #gp,
1386 /* int rdmsr_safe(u_int msr, uint64_t *data) */
1388 movq PCPU(CURPCB),%r8
1389 movq $msr_onfault,PCB_ONFAULT(%r8)
1391 rdmsr /* Read MSR pointed by %ecx. Returns
1392 hi byte in edx, lo in %eax */
1393 salq $32,%rdx /* sign-shift %rdx left */
1394 movl %eax,%eax /* zero-extend %eax -> %rax */
1398 movq %rax,PCB_ONFAULT(%r8)
1403 * Support for writing MSRs in the safe manner. (Instead of panic on #gp,
1407 /* int wrmsr_safe(u_int msr, uint64_t data) */
1409 movq PCPU(CURPCB),%r8
1410 movq $msr_onfault,PCB_ONFAULT(%r8)
1415 wrmsr /* Write MSR pointed by %ecx. Accepts
1416 hi byte in edx, lo in %eax. */
1418 movq %rax,PCB_ONFAULT(%r8)
1423 * MSR operations fault handler
1427 movq $0,PCB_ONFAULT(%r8)
1433 * void pmap_pti_pcid_invalidate(uint64_t ucr3, uint64_t kcr3);
1434 * Invalidates address space addressed by ucr3, then returns to kcr3.
1435 * Done in assembler to ensure no other memory accesses happen while
1439 ENTRY(pmap_pti_pcid_invalidate)
1442 movq %rdi,%cr3 /* to user page table */
1443 movq %rsi,%cr3 /* back to kernel */
1448 * void pmap_pti_pcid_invlpg(uint64_t ucr3, uint64_t kcr3, vm_offset_t va);
1449 * Invalidates virtual address va in address space ucr3, then returns to kcr3.
1452 ENTRY(pmap_pti_pcid_invlpg)
1455 movq %rdi,%cr3 /* to user page table */
1457 movq %rsi,%cr3 /* back to kernel */
1462 * void pmap_pti_pcid_invlrng(uint64_t ucr3, uint64_t kcr3, vm_offset_t sva,
1464 * Invalidates virtual addresses between sva and eva in address space ucr3,
1465 * then returns to kcr3.
1468 ENTRY(pmap_pti_pcid_invlrng)
1471 movq %rdi,%cr3 /* to user page table */
1473 addq $PAGE_SIZE,%rdx
1476 movq %rsi,%cr3 /* back to kernel */
1481 .macro ibrs_seq_label l
1484 .macro ibrs_call_label l
1487 .macro ibrs_seq count
1490 ibrs_call_label %(ll)
1492 ibrs_seq_label %(ll)
1498 /* all callers already saved %rax, %rdx, and %rcx */
1499 ENTRY(handle_ibrs_entry)
1500 cmpb $0,hw_ibrs_active(%rip)
1502 movl $MSR_IA32_SPEC_CTRL,%ecx
1504 orl $(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax
1505 orl $(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32,%edx
1507 movb $1,PCPU(IBPB_SET)
1508 testl $CPUID_STDEXT_SMEP,cpu_stdext_feature(%rip)
1512 END(handle_ibrs_entry)
1514 ENTRY(handle_ibrs_exit)
1515 cmpb $0,PCPU(IBPB_SET)
1517 movl $MSR_IA32_SPEC_CTRL,%ecx
1519 andl $~(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax
1520 andl $~((IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32),%edx
1522 movb $0,PCPU(IBPB_SET)
1524 END(handle_ibrs_exit)
1526 /* registers-neutral version, but needs stack */
1527 ENTRY(handle_ibrs_exit_rs)
1528 cmpb $0,PCPU(IBPB_SET)
1533 movl $MSR_IA32_SPEC_CTRL,%ecx
1535 andl $~(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax
1536 andl $~((IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32),%edx
1541 movb $0,PCPU(IBPB_SET)
1543 END(handle_ibrs_exit_rs)
1548 * Flush L1D cache. Load enough of the data from the kernel text
1549 * to flush existing L1D content.
1551 * N.B. The function does not follow ABI calling conventions, it corrupts %rbx.
1552 * The vmm.ko caller expects that only %rax, %rdx, %rbx, %rcx, %r9, and %rflags
1553 * registers are clobbered. The NMI handler caller only needs %r13 preserved.
1556 #define L1D_FLUSH_SIZE (64 * 1024)
1558 movq $-L1D_FLUSH_SIZE, %rcx
1560 * pass 1: Preload TLB.
1561 * Kernel text is mapped using superpages. TLB preload is
1562 * done for the benefit of older CPUs which split 2M page
1563 * into 4k TLB entries.
1565 1: movb L1D_FLUSH_SIZE(%r9, %rcx), %al
1566 addq $PAGE_SIZE, %rcx
1570 movq $-L1D_FLUSH_SIZE, %rcx
1571 /* pass 2: Read each cache line. */
1572 2: movb L1D_FLUSH_SIZE(%r9, %rcx), %al
1577 #undef L1D_FLUSH_SIZE