github.com/wencode/hack@v0.2.9/mmap/flush_amd64.s (about) 1 #include "textflag.h" 2 3 // func flush_cache(addr, size uintptr) 4 // http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf 5 // page: 7-12 6 TEXT ·flush_cache(SB),NOSPLIT,$0 7 XORQ CX, CX 8 MOVQ addr+0(FP), R9 9 MOVQ size+8(FP), SI 10 11 //MFENCE - OBSOLETE with CLFLUSH 12 LOOP: 13 //CLFLUSH (CX)(R9) 14 BYTE $0x41; BYTE $0x0f; BYTE $0xae; BYTE $0x3c; BYTE $0x09 15 16 ADDQ $64, CX 17 CMPQ CX, SI 18 JL LOOP 19 //MFENCE - OBSOLETE with CLFLUSH 20 RET 21 22 // func flush_cache(addr, size uintptr) 23 // http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf 24 // page: 7-12 25 TEXT ·flush_cache_opt(SB),NOSPLIT,$0 26 XORQ CX, CX 27 MOVQ addr+0(FP), R9 28 MOVQ size+8(FP), SI 29 30 SFENCE 31 LOOP: 32 //CLFLUSHOPT (CX)(R9) 33 BYTE $0x41; BYTE $0x66; BYTE $0x0f; BYTE $0xae; BYTE $0x3c; BYTE $0x09 34 35 ADDQ $64, CX 36 CMPQ CX, SI 37 JL LOOP 38 SFENCE 39 RET 40