From f45b02317d8c8c2c5b4ac87209152af1995348e1 Mon Sep 17 00:00:00 2001 From: jsing Date: Thu, 2 Jan 2014 04:23:57 +0000 Subject: [PATCH] Ensure that we preserve callee-save registers. --- sys/arch/amd64/stand/libsa/random_i386.S | 11 +++++++---- sys/arch/i386/stand/libsa/random_i386.S | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) 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 -- 2.20.1