diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2020-05-25 14:58:03 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2020-05-25 14:58:03 +0000 |
commit | ff3f064107f9b8aa872ca0a5986c2d7ec1ea1e24 (patch) | |
tree | 7f8740dca55e0810daf6f2e8f320a64ce3bd471b /sys/arch | |
parent | 00d3e4ac379d76d6fdaacb288af1b76a4c4ed326 (diff) |
Adjust mdrandom() to also return 0 for success, -1 for failure
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/stand/libsa/random_amd64.S | 6 | ||||
-rw-r--r-- | sys/arch/amd64/stand/libsa/random_i386.S | 6 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/random_i386.S | 6 |
3 files changed, 15 insertions, 3 deletions
diff --git a/sys/arch/amd64/stand/libsa/random_amd64.S b/sys/arch/amd64/stand/libsa/random_amd64.S index e2b0766fc2b..7c12659ae55 100644 --- a/sys/arch/amd64/stand/libsa/random_amd64.S +++ b/sys/arch/amd64/stand/libsa/random_amd64.S @@ -1,4 +1,4 @@ -/* $OpenBSD: random_amd64.S,v 1.5 2016/02/12 21:36:33 naddy Exp $ */ +/* $OpenBSD: random_amd64.S,v 1.6 2020/05/25 14:58:01 deraadt Exp $ */ /* * Copyright (c) 2013 Joel Sing <jsing@openbsd.org> @@ -40,6 +40,7 @@ ENTRY(mdrandom) push %rcx popf and $PSL_ID, %eax + movq $-1, %rax jz done // CPUID leaf = 1, subleaf = 0 @@ -59,6 +60,7 @@ ENTRY(mdrandom) and $CPUID_TSC, %eax // See if we have rdtsc. jnz usetsc + movq $-1, %rax jmp done userand: @@ -69,6 +71,7 @@ userand: incq %rdi cmpq %rdi, %rdx jne 1b + movq $0, %rax jmp done usetsc: @@ -99,6 +102,7 @@ usetsc: incq %rdi cmpq %rdi, %rcx jne usetsc + movq $0, %rax jmp done done: diff --git a/sys/arch/amd64/stand/libsa/random_i386.S b/sys/arch/amd64/stand/libsa/random_i386.S index 5e28b40d8d0..36bf82e34bc 100644 --- a/sys/arch/amd64/stand/libsa/random_i386.S +++ b/sys/arch/amd64/stand/libsa/random_i386.S @@ -1,4 +1,4 @@ -/* $OpenBSD: random_i386.S,v 1.10 2016/02/12 21:36:33 naddy Exp $ */ +/* $OpenBSD: random_i386.S,v 1.11 2020/05/25 14:58:01 deraadt Exp $ */ /* * Copyright (c) 2013 Joel Sing <jsing@openbsd.org> @@ -40,6 +40,7 @@ ENTRY(mdrandom) pushl %ecx popfl andl $PSL_ID, %eax + movl $-1, %eax jz done // CPUID leaf = 1, subleaf = 0 @@ -59,6 +60,7 @@ ENTRY(mdrandom) andl $CPUID_TSC, %eax // See if we have rdtsc. jnz usetsc + movl $-1, %eax jmp done userand: @@ -69,6 +71,7 @@ userand: incl %edi cmpl %edi, %edx jne 1b + movl $0, %eax jmp done usetsc: @@ -99,6 +102,7 @@ usetsc: incl %edi cmpl %edi, %ecx jne usetsc + movl $0, %eax jmp done done: diff --git a/sys/arch/i386/stand/libsa/random_i386.S b/sys/arch/i386/stand/libsa/random_i386.S index fb1de133be3..df97b0bd747 100644 --- a/sys/arch/i386/stand/libsa/random_i386.S +++ b/sys/arch/i386/stand/libsa/random_i386.S @@ -1,4 +1,4 @@ -/* $OpenBSD: random_i386.S,v 1.10 2016/02/12 21:36:33 naddy Exp $ */ +/* $OpenBSD: random_i386.S,v 1.11 2020/05/25 14:58:02 deraadt Exp $ */ /* * Copyright (c) 2013 Joel Sing <jsing@openbsd.org> @@ -40,6 +40,7 @@ ENTRY(mdrandom) pushl %ecx popfl andl $PSL_ID, %eax + movl $-1, %eax jz done // CPUID leaf = 1, subleaf = 0 @@ -59,6 +60,7 @@ ENTRY(mdrandom) andl $CPUID_TSC, %eax // See if we have rdtsc. jnz usetsc + movl $-1, %eax jmp done userand: @@ -69,6 +71,7 @@ userand: incl %edi cmpl %edi, %edx jne 1b + movl $0, %eax jmp done usetsc: @@ -99,6 +102,7 @@ usetsc: incl %edi cmpl %edi, %ecx jne usetsc + movl $0, %eax jmp done done: |