From: jsing Date: Thu, 2 Jan 2014 04:23:57 +0000 (+0000) Subject: Ensure that we preserve callee-save registers. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f45b02317d8c8c2c5b4ac87209152af1995348e1;p=openbsd Ensure that we preserve callee-save registers. --- diff --git a/sys/arch/amd64/stand/libsa/random_i386.S b/sys/arch/amd64/stand/libsa/random_i386.S index e53e548e729..03c2f21a3be 100644 --- a/sys/arch/amd64/stand/libsa/random_i386.S +++ b/sys/arch/amd64/stand/libsa/random_i386.S @@ -20,6 +20,8 @@ #include ENTRY(mdrandom) + pushal + // See if we have CPU identification. pushfl popl %eax @@ -50,8 +52,8 @@ ENTRY(mdrandom) movl $0, %ecx cpuid - movl 4(%esp), %ebx - movl 8(%esp), %edx + movl 36(%esp), %ebx + movl 40(%esp), %edx shrl $2, %edx shll $2, %edx xorl %edi, %edi @@ -68,7 +70,7 @@ userand: addl $4, %edi cmpl %edi, %edx jne userand - ret + jmp done usetsc: rdtsc // Populates edx:eax. @@ -77,7 +79,8 @@ usetsc: addl $4, %edi cmpl %edi, %ecx jne usetsc - ret + jmp done done: + popal ret diff --git a/sys/arch/i386/stand/libsa/random_i386.S b/sys/arch/i386/stand/libsa/random_i386.S index e53e548e729..03c2f21a3be 100644 --- a/sys/arch/i386/stand/libsa/random_i386.S +++ b/sys/arch/i386/stand/libsa/random_i386.S @@ -20,6 +20,8 @@ #include ENTRY(mdrandom) + pushal + // See if we have CPU identification. pushfl popl %eax @@ -50,8 +52,8 @@ ENTRY(mdrandom) movl $0, %ecx cpuid - movl 4(%esp), %ebx - movl 8(%esp), %edx + movl 36(%esp), %ebx + movl 40(%esp), %edx shrl $2, %edx shll $2, %edx xorl %edi, %edi @@ -68,7 +70,7 @@ userand: addl $4, %edi cmpl %edi, %edx jne userand - ret + jmp done usetsc: rdtsc // Populates edx:eax. @@ -77,7 +79,8 @@ usetsc: addl $4, %edi cmpl %edi, %ecx jne usetsc - ret + jmp done done: + popal ret