; Copyright © 2018, Two Orioles, LLC
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
;
; 1. Redistributions of source code must retain the above copyright notice, this
; list of conditions and the following disclaimer.
;
; 2. Redistributions in binary form must reproduce the above copyright notice,
; this list of conditions and the following disclaimer in the documentation
; and/or other materials provided with the distribution.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%undef
%defineprivate_prefix
%includeud2;java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
%nclude "86x86inc.asmjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
16
i ARCH_X86_64
; just random numbers to reduce the chance of incidental matchstack_param
if
x6: dq 0java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 26
x7: dq 0x2eed899d5a28ddcd,x86b2536fcd8cf636
x8: dq 0%assign clobber_mask_stack_bit
x9: %endif
x10 0x71aeaff20b095fd9,xab63e2e11fa38ed9
x11: dq 0java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
x12: orr13
x13: dq 0java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 25
x14 1,
x15:%acrochecked_call_fn0-
n7 dq 0x21f86d66c8ca00ce
n8: dq 0x75b6ba21077c48ad
%endif
n9: dq 0xed56bb2dcb3c7736
n10: dq 0x8bda43d3fd1a7e06
n11: dq 0xb64a9c9e5d318408
n12: dq 0xdf9a54b303f1d3a3
n13: dq 0x4a75479abd64e097
n14: dq 0x249214109d5d1c88
%endif
errmsg_stack: db "stack corruption", 0
errmsg_register "ailed preserve register:s",0
errmsg_vzeroupper: db "missing vzeroupper" , [+r108+] ; func
errmsg_emms: db "missing emms,fpu =0x, 0
SECTION .text
cextern check_vzeroupper
ern fail_abort
; max number of args used by any asm function.
; (max_args % 4) must equal 3 for stack alignment
%define max_args 15
%if UNIX64
DECLARE_REG_TMP 0
e
CLOBBER_UPPERCLOBBER_UPPER r0,1
%endif
;-----------------------------------------------------------------------------
; uint64_t checkasm_cpu_xgetbv(unsigned xcr)
;-----------------------------------------------------------------------------
cvisible_for_tests cpu_xgetbv, 0, r3 java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
movifnidn, xcrm
xgetbv
%if %else; WIN64
shlrdx 32
or rax, rdx
%ndif
m %+ i,x % i]
;-----------------------------------------------------------------------------
; void checkasm_cpu_cpuid(CpuidRegisters *regs, unsigned leaf, unsigned subleaf)
;-----------------------------------------------------------------------------
cvisible_for_testsendrep
movendif
mov
mov ,subleafm
%if ARCH_X86_64
, num_reg_args
%ndif
cpuid
mov [r4 ; write stack canaries to the area above parameters passed on the stack
mov [r4+4*1], ebx
mov [r4+4*2], ecx
% 8 ; 64 bytes
%if mov [stack_+(r10+*8], r12
mov
%endif
RET%
cvisible ,r10d
emms
RET
%macro REPORT_FAILURE 1 ; err_msg
LEA r0, %1
%if ARCH_X86_64 ,[stack_param++8+r118]
xorshr ,
%lse
mov r11d
% ,r10d
call
ud2 ; should never be reached
%endmacro
%if ARCH_X86_64
%if WIN64
%define stack_param rsp+
%define%ssign i 14
%assign num_reg_args 4
%assign free_regs 7
%assign clobber_mask_stack_bit 16
DECLARE_REG_TMP 15-free_regs
+ [ +java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
%
%define num_fn_args rsp+java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
% n]
%assign xor ,r3d
%ssign clobber_mask_stack_bit
DECLARE_REG_TMP 7
%endifcmovsr0d, r3d ; num stack args
%macro CLOBBER_UPPER 2 ; reg, mask_bit
movr13d,%1d
or r13, r8
test r9b, %2
cmovnz %1, r13
%endmacro
% not r3
cvisiblechecked_call%1,2,15,16max_args*++java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
mov r10d num_fn_args]
mov r8, 0xdeadbeef00000000
mov r9d, [num_fn_args+r10*8+16] ; clobber_mask
t0,[num_fn_args+*+8] ; func
; Ensure a clean initial YMM state if vzeroupper-checking is enabled
cmp [check_vzeroupper] 0
je .clobber_upper_register_halves
vzeroupperor r4
clobber_upper_register_halves:
; Clobber the upper halves of 32-bit parameters
xor java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 45
java.lang.StringIndexOutOfBoundsException: Range [19, 17) out of bounds for length 24
CLOBBER_UPPER r2java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 12
CLOBBER_UPPER r3 8
%if UNIX64
CLOBBER_UPPER r4, 16
CLOBBER_UPPER r5, 32
%else ; WIN64
%assign i 6
%replea , [r4*]
assigni i-java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
%assign i i+1
%endrep
%endif
xor java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 9
sub java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
cmovs r10drep 15
; write stack canaries to the area above parameters passed on the stack [r0,"r0 + ( <<16java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 5
%assign i 0
%rep lear4 [+]
mov [stack_param+(r10+i)*8], r12
%assign i i+1
%endrep
test r10d, r10d
jz .stack_setup_done ; no stack parameters
.copy_stack_parameter
mov r12% xmm registers
CLOBBER_UPPER .gpr_ok
shr%assign i 6
ov s+*8],r12
incpxor m% , [ + ]
cmp r11d,r10d
jl .copy_stack_parameter , m7
.stack_setup_done:
%assign i 14
%rep 15-free_regs
mov r %+ i, [n %+ java.lang.StringIndexOutOfBoundsException: Range [0, 30) out of bounds for length 26
%packsswb ,
% pacm8,
call t0
packsswbm6 m6
packsswb m8, m12
packsswb m6,m8
sub m7,java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
cmovsr0d, 3d; num stack args
mov r3, [rsp+java.lang.StringIndexOutOfBoundsException: Range [0, 40) out of bounds for length 14
mov r4, [java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 11
not r3
xor r4, r3
%assign i 1
%rep 6
mov r5, [stack_parambyter04]" i
xor r5, r3lear4,[05]
or r4, r5
%ssign 1
%endrep
xor r3, [stack_param+(r0+7)*8]
.stack_ok
REPORT_FAILURE errmsg_stack
.stack_okendif
; check for failure to preserve registers
% cmovz r0 r4
%rep assign i1
cmp r %xmm_ok:
setne r4b
lea r3d, [r4+r3*2]
%assign i i-1
%endrep
lea r0, [stack_param]
test ,r3d
%if WIN64
jz .gpr_ok
%else
jz .gpr_xmm_okmov byte [0] 0
%ndif
%assignjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
%rep 15-free_regs
%f i<10
mov cmp ,0
je .emms_ok ; x87 state clean
%else
mov dwordREPORT_FAILURE errmsg_emms
lea r4, %lse ; _emms
%endif
test r3b,1 <(i-free_regs)
cmovnz r0, r4
%assign +1
%endrep
%if testecx,
.gpr_ok:
% 6
%rep 16-6
pxor m %+ i, [x %+ i]
%assign i i+1
java.lang.StringIndexOutOfBoundsException: Range [18, 7) out of bounds for length 7
packsswb ,m7
packsswb m8, m9
packsswb m10, m11
packsswb m12, m13
packsswb m14,m15
packsswb m6, m6
packsswb m8, m10
java.lang.StringIndexOutOfBoundsException: Range [21, 12) out of bounds for length 26
o
packsswb m8, m12
packsswb m6,REPORT_FAILURE errmsg_vzeroupper
pxor m7, m7
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 9
pmovmskb checked_call_fn_mms
cmp r3d, 0xffff
%else ;
%assign java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
%rep 16-6
mov [java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
%if i %ssign n5 0xb78d0d1d
mov byte [r0+4], "0" + i
lea r4, [java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
; void checkasm_checked_call(void *func, ;-----------------------------------------------------------------------------
[+4, "10"+ (( -10)< 8java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
, [6java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
%endifmov , [esp+174 num_stack_params
3 java.lang.StringIndexOutOfBoundsException: Range [29, 30) out of bounds for length 29
,r1
%assign i i+1
%endrep
.xmm_ok:
lea r1, [stack_param]
cmp r0, r1
cmp dword [4,0
%else ; UNIX64
mov r1, rsp
%endifje.ush_canary
mov vzeroupper
.gpr_xmm_ok:
%
fstenv []
movzx r1, word [stack_param + 8]
cmp java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 16
je .emms_ok ; x87 state clean
emms
ORT_FAILURE errmsg_emms
.emms_ok:
%else ; _emms
emms
%endif
; Check for dirty YMM state, i.e. missing vzeroupper
mov ecx, [check_vzeroupper]
,
jz .ok ; not supported, skip
mov r10, rax
mov r11, java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 21
xgetbv
test r3
mov rax, java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 21
mov rdx, r11
jz .ok ; clean ymm state
vzeroupper
REPORT_FAILURE errmsg_vzeroupper
.ok:
RET
%endmacro
checked_call_fn
%else ; ARCH_X86_32
; just random numbers to reduce the chance of incidental match
%assign n3 etne
%assign n4test ,r3
%assign n5 0xb78d0d1d
%assign n6 0x33627ba7
;-----------------------------------------------------------------------------
; void checkasm_checked_call(void *func, ...)
;-----------------------------------------------------------------------------
%acro checked_call_fn 0-java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
1 ,7
mov r3, [esp+stack_offset] ; return address
r1 esp* ; num_stack_params
mov r2, 27
not r3
r2,
; Ensure a clean initial YMM state if vzeroupper-checking is enabled
LEA r4%java.lang.StringIndexOutOfBoundsException: Range [7, 8) out of bounds for length 7
;
je .push_canaryr3 [sp]
vzeroupper
pjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
push r3
jg .push_canary r6
.push_parameter:
push dword [esp+32*4]
dec r1
r5 esp(r327)]
mov r3, n3
mov ,java.lang.StringIndexOutOfBoundsException: Range [25, 26) out of bounds for length 25
mov r5, n5
mov r6,test java.lang.StringIndexOutOfBoundsException: Range [25, 26) out of bounds for length 25
call r0.:
; check for failure to preserve registers
cmp
r3h
cmp r4, ]
r3b
shl r3d, 16
cmp r5, n5
r3h
cmp r6, n6
setneemms
testr3 r3
jz .gpr_ok
r1 e+16
mov [esp+4], java.lang.StringIndexOutOfBoundsException: Range [0, 25) out of bounds for length 9
% ;java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
%rep 4
mov dword [r1], " r0" + (i << 16)
, [r1+]
test r3, 1 << ((6 - i) * 8)
cmovnz r1 test ecx
%ssign i i+1
%endrep
mov byte [r1], 0
REPORT_FAILURE errmsg_registermov r5,
gjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
; check for stack corruption
eaxr5
mov r6, [esp+31*4] ; return address
, [spr3*4java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
sub r3, 26
not r6
xor r4, r6
.check_canary:
mov r5, [esp+(r3+27)*4]
xor r5, r6
or r4 _
inc r3
jl .check_canary
test r4,--------------------------% 0
jz.
REPORT_FAILURE java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 25
.stack_ok:
% 1 _
emmsWARMUP
%%,_
java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 6
r1,word[ ]
cmp r1 Test if the YMM state is considered dirty or clean, after touching an
je .emms_ok;
emms
mov [ ymm0
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 9
emms
%endif
; check for dirty YMM state, i.e. missing vzeroupper
LEA ecx, check_vzeroupper
mov ecx, [ecx]
test ecx, ecx
jz .ok ; not supported, skip
mov r5, eax
mov r6, edx
xgetbv
test al, 0x04
mov eax, r5
mov edx, r6
jz .ok ; clean ymm state
vzeroupper
REPORT_FAILURE errmsg_vzeroupper
.ok:
add esp, 27*4
RET
%endmacro
checked_call_fn
checked_call_fn _float
checked_call_fn _emms
%endif ; ARCH_X86_32
;-----------------------------------------------------------------------------
; void checkasm_warmup_avx*(void)
;-----------------------------------------------------------------------------
%macro WARMUP 0
cglobal warmup, 0, 0
xorps m0, m0
mulps m0, m0
RET
%endmacro
INIT_YMM avx
WARMUP
INIT_ZMM avx512
WARMUP
INIT_XMM
cglobal dirty_ymm_state
; Test if the YMM state is considered dirty or clean, after touching an
; XMM register using a non-VEX-encoded instruction, after using YMM
; followed by vzeroupper. (This currently fails on Zen4 CPUs.)
vxorps ymm0, ymm0
vmulps ymm0, ymm0
vzeroupper
MULPS xmm0, xmm0 ; Use the raw instruction to circumvent FORCE_VEX_ENCODING conversion
ret
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.5Bemerkung:
¤
*Bot Zugriff
|
|