From 9ec9a7a59769927ad1f5662f78a52031cb9cd758 Mon Sep 17 00:00:00 2001 From: Qin Long Date: Fri, 4 Nov 2016 15:31:28 +0800 Subject: [PATCH] MdePkg/BaseLib: Add one wrapper on RdRand access for parameter check. Add one wrapper implementation over assembly RdRand access to check possible NULL parameter, for better alignment with comment description. Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long Reviewed-by: Liming Gao --- MdePkg/Library/BaseLib/BaseLib.inf | 2 + MdePkg/Library/BaseLib/BaseLibInternals.h | 48 +++++++++++++- MdePkg/Library/BaseLib/Ia32/RdRand.S | 20 +++--- MdePkg/Library/BaseLib/Ia32/RdRand.asm | 20 +++--- MdePkg/Library/BaseLib/Ia32/RdRand.nasm | 20 +++--- MdePkg/Library/BaseLib/X64/RdRand.S | 20 +++--- MdePkg/Library/BaseLib/X64/RdRand.asm | 20 +++--- MdePkg/Library/BaseLib/X64/RdRand.nasm | 20 +++--- MdePkg/Library/BaseLib/X86RdRand.c | 79 +++++++++++++++++++++++ 9 files changed, 188 insertions(+), 61 deletions(-) create mode 100644 MdePkg/Library/BaseLib/X86RdRand.c diff --git a/MdePkg/Library/BaseLib/BaseLib.inf b/MdePkg/Library/BaseLib/BaseLib.inf index 1ffe870e7e..320ac457ea 100644 --- a/MdePkg/Library/BaseLib/BaseLib.inf +++ b/MdePkg/Library/BaseLib/BaseLib.inf @@ -428,6 +428,7 @@ X86EnablePaging32.c X86DisablePaging64.c X86DisablePaging32.c + X86RdRand.c [Sources.X64] X64/Thunk16.nasm @@ -752,6 +753,7 @@ X86EnablePaging32.c X86DisablePaging64.c X86DisablePaging32.c + X86RdRand.c X64/GccInline.c | GCC X64/Thunk16.S | XCODE X64/SwitchStack.nasm| GCC diff --git a/MdePkg/Library/BaseLib/BaseLibInternals.h b/MdePkg/Library/BaseLib/BaseLibInternals.h index fe416a0c38..a8f712b1ad 100644 --- a/MdePkg/Library/BaseLib/BaseLibInternals.h +++ b/MdePkg/Library/BaseLib/BaseLibInternals.h @@ -1,7 +1,7 @@ /** @file Declaration of internal functions in BaseLib. - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -728,6 +728,52 @@ InternalX86DisablePaging64 ( IN UINT32 NewStack ); +/** + Generates a 16-bit random number through RDRAND instruction. + + @param[out] Rand Buffer pointer to store the random result. + + @retval TRUE RDRAND call was successful. + @retval FALSE Failed attempts to call RDRAND. + + **/ +BOOLEAN +EFIAPI +InternalX86RdRand16 ( + OUT UINT16 *Rand + ); + +/** + Generates a 32-bit random number through RDRAND instruction. + + @param[out] Rand Buffer pointer to store the random result. + + @retval TRUE RDRAND call was successful. + @retval FALSE Failed attempts to call RDRAND. + +**/ +BOOLEAN +EFIAPI +InternalX86RdRand32 ( + OUT UINT32 *Rand + ); + +/** + Generates a 64-bit random number through RDRAND instruction. + + + @param[out] Rand Buffer pointer to store the random result. + + @retval TRUE RDRAND call was successful. + @retval FALSE Failed attempts to call RDRAND. + +**/ +BOOLEAN +EFIAPI +InternalX86RdRand64 ( + OUT UINT64 *Rand + ); + #elif defined (MDE_CPU_IPF) // diff --git a/MdePkg/Library/BaseLib/Ia32/RdRand.S b/MdePkg/Library/BaseLib/Ia32/RdRand.S index 503f65a721..d00075afe7 100644 --- a/MdePkg/Library/BaseLib/Ia32/RdRand.S +++ b/MdePkg/Library/BaseLib/Ia32/RdRand.S @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ ; -# Copyright (c) 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -24,10 +24,10 @@ // Generates a 16 bit random number through RDRAND instruction. // Return TRUE if Rand generated successfully, or FALSE if not. // -// BOOLEAN EFIAPI AsmRdRand16 (UINT16 *Rand); +// BOOLEAN EFIAPI InternalX86RdRand16 (UINT16 *Rand); //------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(AsmRdRand16) -ASM_PFX(AsmRdRand16): +ASM_GLOBAL ASM_PFX(InternalX86RdRand16) +ASM_PFX(InternalX86RdRand16): .byte 0x0f, 0xc7, 0xf0 // rdrand r16: "0f c7 /6 ModRM:r/m(w)" jc rn16_ok // jmp if CF=1 xor %eax, %eax // reg=0 if CF=0 @@ -42,10 +42,10 @@ rn16_ok: // Generates a 32 bit random number through RDRAND instruction. // Return TRUE if Rand generated successfully, or FALSE if not. // -// BOOLEAN EFIAPI AsmRdRand32 (UINT32 *Rand); +// BOOLEAN EFIAPI InternalX86RdRand32 (UINT32 *Rand); //------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(AsmRdRand32) -ASM_PFX(AsmRdRand32): +ASM_GLOBAL ASM_PFX(InternalX86RdRand32) +ASM_PFX(InternalX86RdRand32): .byte 0x0f, 0xc7, 0xf0 // rdrand r32: "0f c7 /6 ModRM:r/m(w)" jc rn32_ok // jmp if CF=1 xor %eax, %eax // reg=0 if CF=0 @@ -60,10 +60,10 @@ rn32_ok: // Generates a 64 bit random number through RDRAND instruction. // Return TRUE if Rand generated successfully, or FALSE if not. // -// BOOLEAN EFIAPI AsmRdRand64 (UINT64 *Rand); +// BOOLEAN EFIAPI InternalX86RdRand64 (UINT64 *Rand); //------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(AsmRdRand64) -ASM_PFX(AsmRdRand64): +ASM_GLOBAL ASM_PFX(InternalX86RdRand64) +ASM_PFX(InternalX86RdRand64): .byte 0x0f, 0xc7, 0xf0 // rdrand r32: "0f c7 /6 ModRM:r/m(w)" jnc rn64_ret // jmp if CF=0 mov 0x4(%esp), %edx diff --git a/MdePkg/Library/BaseLib/Ia32/RdRand.asm b/MdePkg/Library/BaseLib/Ia32/RdRand.asm index 21349b0918..cb4e811098 100644 --- a/MdePkg/Library/BaseLib/Ia32/RdRand.asm +++ b/MdePkg/Library/BaseLib/Ia32/RdRand.asm @@ -1,6 +1,6 @@ ;------------------------------------------------------------------------------ ; -; Copyright (c) 2015, Intel Corporation. All rights reserved.
+; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at @@ -30,9 +30,9 @@ ; Generates a 16 bit random number through RDRAND instruction. ; Return TRUE if Rand generated successfully, or FALSE if not. ; -; BOOLEAN EFIAPI AsmRdRand16 (UINT16 *Rand); +; BOOLEAN EFIAPI InternalX86RdRand16 (UINT16 *Rand); ;------------------------------------------------------------------------------ -AsmRdRand16 PROC +InternalX86RdRand16 PROC ; rdrand ax ; generate a 16 bit RN into ax ; CF=1 if RN generated ok, otherwise CF=0 db 0fh, 0c7h, 0f0h ; rdrand r16: "0f c7 /6 ModRM:r/m(w)" @@ -44,15 +44,15 @@ rn16_ok: mov [edx], ax mov eax, 1 ret -AsmRdRand16 ENDP +InternalX86RdRand16 ENDP ;------------------------------------------------------------------------------ ; Generates a 32 bit random number through RDRAND instruction. ; Return TRUE if Rand generated successfully, or FALSE if not. ; -; BOOLEAN EFIAPI AsmRdRand32 (UINT32 *Rand); +; BOOLEAN EFIAPI InternalX86RdRand32 (UINT32 *Rand); ;------------------------------------------------------------------------------ -AsmRdRand32 PROC +InternalX86RdRand32 PROC ; rdrand eax ; generate a 32 bit RN into eax ; CF=1 if RN generated ok, otherwise CF=0 db 0fh, 0c7h, 0f0h ; rdrand r32: "0f c7 /6 ModRM:r/m(w)" @@ -64,15 +64,15 @@ rn32_ok: mov [edx], eax mov eax, 1 ret -AsmRdRand32 ENDP +InternalX86RdRand32 ENDP ;------------------------------------------------------------------------------ ; Generates a 64 bit random number through RDRAND instruction. ; Return TRUE if Rand generated successfully, or FALSE if not. ; -; BOOLEAN EFIAPI AsmRdRand64 (UINT64 *Rand); +; BOOLEAN EFIAPI InternalX86RdRand64 (UINT64 *Rand); ;------------------------------------------------------------------------------ -AsmRdRand64 PROC +InternalX86RdRand64 PROC ; rdrand eax ; generate a 32 bit RN into eax ; CF=1 if RN generated ok, otherwise CF=0 db 0fh, 0c7h, 0f0h ; rdrand r32: "0f c7 /6 ModRM:r/m(w)" @@ -89,6 +89,6 @@ AsmRdRand64 PROC rn64_ret: xor eax, eax ret ; return with failure status -AsmRdRand64 ENDP +InternalX86RdRand64 ENDP END diff --git a/MdePkg/Library/BaseLib/Ia32/RdRand.nasm b/MdePkg/Library/BaseLib/Ia32/RdRand.nasm index 1365dfcdbb..64e8cdbda4 100644 --- a/MdePkg/Library/BaseLib/Ia32/RdRand.nasm +++ b/MdePkg/Library/BaseLib/Ia32/RdRand.nasm @@ -1,6 +1,6 @@ ;------------------------------------------------------------------------------ ; -; Copyright (c) 2015, Intel Corporation. All rights reserved.
+; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at @@ -27,10 +27,10 @@ SECTION .text ; Generates a 16 bit random number through RDRAND instruction. ; Return TRUE if Rand generated successfully, or FALSE if not. ; -; BOOLEAN EFIAPI AsmRdRand16 (UINT16 *Rand); +; BOOLEAN EFIAPI InternalX86RdRand16 (UINT16 *Rand); ;------------------------------------------------------------------------------ -global ASM_PFX(AsmRdRand16) -ASM_PFX(AsmRdRand16): +global ASM_PFX(InternalX86RdRand16) +ASM_PFX(InternalX86RdRand16): ; rdrand ax ; generate a 16 bit RN into ax ; CF=1 if RN generated ok, otherwise CF=0 db 0xf, 0xc7, 0xf0 ; rdrand r16: "0f c7 /6 ModRM:r/m(w)" @@ -47,10 +47,10 @@ rn16_ok: ; Generates a 32 bit random number through RDRAND instruction. ; Return TRUE if Rand generated successfully, or FALSE if not. ; -; BOOLEAN EFIAPI AsmRdRand32 (UINT32 *Rand); +; BOOLEAN EFIAPI InternalX86RdRand32 (UINT32 *Rand); ;------------------------------------------------------------------------------ -global ASM_PFX(AsmRdRand32) -ASM_PFX(AsmRdRand32): +global ASM_PFX(InternalX86RdRand32) +ASM_PFX(InternalX86RdRand32): ; rdrand eax ; generate a 32 bit RN into eax ; CF=1 if RN generated ok, otherwise CF=0 db 0xf, 0xc7, 0xf0 ; rdrand r32: "0f c7 /6 ModRM:r/m(w)" @@ -67,10 +67,10 @@ rn32_ok: ; Generates a 64 bit random number through RDRAND instruction. ; Return TRUE if Rand generated successfully, or FALSE if not. ; -; BOOLEAN EFIAPI AsmRdRand64 (UINT64 *Rand); +; BOOLEAN EFIAPI InternalX86RdRand64 (UINT64 *Rand); ;------------------------------------------------------------------------------ -global ASM_PFX(AsmRdRand64) -ASM_PFX(AsmRdRand64): +global ASM_PFX(InternalX86RdRand64) +ASM_PFX(InternalX86RdRand64): ; rdrand eax ; generate a 32 bit RN into eax ; CF=1 if RN generated ok, otherwise CF=0 db 0xf, 0xc7, 0xf0 ; rdrand r32: "0f c7 /6 ModRM:r/m(w)" diff --git a/MdePkg/Library/BaseLib/X64/RdRand.S b/MdePkg/Library/BaseLib/X64/RdRand.S index 49b50e6901..55724c0868 100644 --- a/MdePkg/Library/BaseLib/X64/RdRand.S +++ b/MdePkg/Library/BaseLib/X64/RdRand.S @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ ; -# Copyright (c) 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -24,10 +24,10 @@ // Generates a 16 bit random number through RDRAND instruction. // Return TRUE if Rand generated successfully, or FALSE if not. // -// BOOLEAN EFIAPI AsmRdRand16 (UINT16 *Rand); +// BOOLEAN EFIAPI InternalX86RdRand16 (UINT16 *Rand); //------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(AsmRdRand16) -ASM_PFX(AsmRdRand16): +ASM_GLOBAL ASM_PFX(InternalX86RdRand16) +ASM_PFX(InternalX86RdRand16): .byte 0x0f, 0xc7, 0xf0 // rdrand r16: "0f c7 /6 ModRM:r/m(w)" jc rn16_ok // jmp if CF=1 xor %rax, %rax // reg=0 if CF=0 @@ -41,10 +41,10 @@ rn16_ok: // Generates a 32 bit random number through RDRAND instruction. // Return TRUE if Rand generated successfully, or FALSE if not. // -// BOOLEAN EFIAPI AsmRdRand32 (UINT32 *Rand); +// BOOLEAN EFIAPI InternalX86RdRand32 (UINT32 *Rand); //------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(AsmRdRand32) -ASM_PFX(AsmRdRand32): +ASM_GLOBAL ASM_PFX(InternalX86RdRand32) +ASM_PFX(InternalX86RdRand32): .byte 0x0f, 0xc7, 0xf0 // rdrand r32: "0f c7 /6 ModRM:r/m(w)" jc rn32_ok // jmp if CF=1 xor %rax, %rax // reg=0 if CF=0 @@ -58,10 +58,10 @@ rn32_ok: // Generates a 64 bit random number through RDRAND instruction. // Return TRUE if Rand generated successfully, or FALSE if not. // -// BOOLEAN EFIAPI AsmRdRand64 (UINT64 *Rand); +// BOOLEAN EFIAPI InternalX86RdRand64 (UINT64 *Rand); //------------------------------------------------------------------------------ -ASM_GLOBAL ASM_PFX(AsmRdRand64) -ASM_PFX(AsmRdRand64): +ASM_GLOBAL ASM_PFX(InternalX86RdRand64) +ASM_PFX(InternalX86RdRand64): .byte 0x48, 0x0f, 0xc7, 0xf0 // rdrand r64: "REX.W + 0f c7 /6 ModRM:r/m(w)" jc rn64_ok // jmp if CF=1 xor %rax, %rax // reg=0 if CF=0 diff --git a/MdePkg/Library/BaseLib/X64/RdRand.asm b/MdePkg/Library/BaseLib/X64/RdRand.asm index 370cdb607a..8e2074e2d5 100644 --- a/MdePkg/Library/BaseLib/X64/RdRand.asm +++ b/MdePkg/Library/BaseLib/X64/RdRand.asm @@ -1,6 +1,6 @@ ;------------------------------------------------------------------------------ ; -; Copyright (c) 2015, Intel Corporation. All rights reserved.
+; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at @@ -27,9 +27,9 @@ ; Generates a 16 bit random number through RDRAND instruction. ; Return TRUE if Rand generated successfully, or FALSE if not. ; -; BOOLEAN EFIAPI AsmRdRand16 (UINT16 *Rand); +; BOOLEAN EFIAPI InternalX86RdRand16 (UINT16 *Rand); ;------------------------------------------------------------------------------ -AsmRdRand16 PROC +InternalX86RdRand16 PROC ; rdrand ax ; generate a 16 bit RN into eax, ; CF=1 if RN generated ok, otherwise CF=0 db 0fh, 0c7h, 0f0h ; rdrand r16: "0f c7 /6 ModRM:r/m(w)" @@ -40,15 +40,15 @@ rn16_ok: mov [rcx], ax mov rax, 1 ret -AsmRdRand16 ENDP +InternalX86RdRand16 ENDP ;------------------------------------------------------------------------------ ; Generates a 32 bit random number through RDRAND instruction. ; Return TRUE if Rand generated successfully, or FALSE if not. ; -; BOOLEAN EFIAPI AsmRdRand32 (UINT32 *Rand); +; BOOLEAN EFIAPI InternalX86RdRand32 (UINT32 *Rand); ;------------------------------------------------------------------------------ -AsmRdRand32 PROC +InternalX86RdRand32 PROC ; rdrand eax ; generate a 32 bit RN into eax, ; CF=1 if RN generated ok, otherwise CF=0 db 0fh, 0c7h, 0f0h ; rdrand r32: "0f c7 /6 ModRM:r/m(w)" @@ -59,15 +59,15 @@ rn32_ok: mov [rcx], eax mov rax, 1 ret -AsmRdRand32 ENDP +InternalX86RdRand32 ENDP ;------------------------------------------------------------------------------ ; Generates a 64 bit random number through one RDRAND instruction. ; Return TRUE if Rand generated successfully, or FALSE if not. ; -; BOOLEAN EFIAPI AsmRdRand64 (UINT64 *Random); +; BOOLEAN EFIAPI InternalX86RdRand64 (UINT64 *Random); ;------------------------------------------------------------------------------ -AsmRdRand64 PROC +InternalX86RdRand64 PROC ; rdrand rax ; generate a 64 bit RN into rax, ; CF=1 if RN generated ok, otherwise CF=0 db 048h, 0fh, 0c7h, 0f0h ; rdrand r64: "REX.W + 0f c7 /6 ModRM:r/m(w)" @@ -78,6 +78,6 @@ rn64_ok: mov [rcx], rax mov rax, 1 ret -AsmRdRand64 ENDP +InternalX86RdRand64 ENDP END diff --git a/MdePkg/Library/BaseLib/X64/RdRand.nasm b/MdePkg/Library/BaseLib/X64/RdRand.nasm index f6d83a3a10..b9050d287b 100644 --- a/MdePkg/Library/BaseLib/X64/RdRand.nasm +++ b/MdePkg/Library/BaseLib/X64/RdRand.nasm @@ -1,6 +1,6 @@ ;------------------------------------------------------------------------------ ; -; Copyright (c) 2015, Intel Corporation. All rights reserved.
+; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at @@ -28,10 +28,10 @@ ; Generates a 16 bit random number through RDRAND instruction. ; Return TRUE if Rand generated successfully, or FALSE if not. ; -; BOOLEAN EFIAPI AsmRdRand16 (UINT16 *Rand); +; BOOLEAN EFIAPI InternalX86RdRand16 (UINT16 *Rand); ;------------------------------------------------------------------------------ -global ASM_PFX(AsmRdRand16) -ASM_PFX(AsmRdRand16): +global ASM_PFX(InternalX86RdRand16) +ASM_PFX(InternalX86RdRand16): ; rdrand ax ; generate a 16 bit RN into eax, ; CF=1 if RN generated ok, otherwise CF=0 db 0xf, 0xc7, 0xf0 ; rdrand r16: "0f c7 /6 ModRM:r/m(w)" @@ -47,10 +47,10 @@ rn16_ok: ; Generates a 32 bit random number through RDRAND instruction. ; Return TRUE if Rand generated successfully, or FALSE if not. ; -; BOOLEAN EFIAPI AsmRdRand32 (UINT32 *Rand); +; BOOLEAN EFIAPI InternalX86RdRand32 (UINT32 *Rand); ;------------------------------------------------------------------------------ -global ASM_PFX(AsmRdRand32) -ASM_PFX(AsmRdRand32): +global ASM_PFX(InternalX86RdRand32) +ASM_PFX(InternalX86RdRand32): ; rdrand eax ; generate a 32 bit RN into eax, ; CF=1 if RN generated ok, otherwise CF=0 db 0xf, 0xc7, 0xf0 ; rdrand r32: "0f c7 /6 ModRM:r/m(w)" @@ -66,10 +66,10 @@ rn32_ok: ; Generates a 64 bit random number through one RDRAND instruction. ; Return TRUE if Rand generated successfully, or FALSE if not. ; -; BOOLEAN EFIAPI AsmRdRand64 (UINT64 *Random); +; BOOLEAN EFIAPI InternalX86RdRand64 (UINT64 *Random); ;------------------------------------------------------------------------------ -global ASM_PFX(AsmRdRand64) -ASM_PFX(AsmRdRand64): +global ASM_PFX(InternalX86RdRand64) +ASM_PFX(InternalX86RdRand64): ; rdrand rax ; generate a 64 bit RN into rax, ; CF=1 if RN generated ok, otherwise CF=0 db 0x48, 0xf, 0xc7, 0xf0 ; rdrand r64: "REX.W + 0f c7 /6 ModRM:r/m(w)" diff --git a/MdePkg/Library/BaseLib/X86RdRand.c b/MdePkg/Library/BaseLib/X86RdRand.c new file mode 100644 index 0000000000..36d5457b48 --- /dev/null +++ b/MdePkg/Library/BaseLib/X86RdRand.c @@ -0,0 +1,79 @@ +/** @file + IA-32/x64 AsmRdRandxx() + Generates random number through CPU RdRand instruction. + + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "BaseLibInternals.h" + +/** + Generates a 16-bit random number through RDRAND instruction. + + if Rand is NULL, then ASSERT(). + + @param[out] Rand Buffer pointer to store the random result. + + @retval TRUE RDRAND call was successful. + @retval FALSE Failed attempts to call RDRAND. + + **/ +BOOLEAN +EFIAPI +AsmRdRand16 ( + OUT UINT16 *Rand + ) +{ + ASSERT (Rand != NULL); + return InternalX86RdRand16 (Rand); +} + +/** + Generates a 32-bit random number through RDRAND instruction. + + if Rand is NULL, then ASSERT(). + + @param[out] Rand Buffer pointer to store the random result. + + @retval TRUE RDRAND call was successful. + @retval FALSE Failed attempts to call RDRAND. + +**/ +BOOLEAN +EFIAPI +AsmRdRand32 ( + OUT UINT32 *Rand + ) +{ + ASSERT (Rand != NULL); + return InternalX86RdRand32 (Rand); +} + +/** + Generates a 64-bit random number through RDRAND instruction. + + if Rand is NULL, then ASSERT(). + + @param[out] Rand Buffer pointer to store the random result. + + @retval TRUE RDRAND call was successful. + @retval FALSE Failed attempts to call RDRAND. + +**/ +BOOLEAN +EFIAPI +AsmRdRand64 ( + OUT UINT64 *Rand + ) +{ + ASSERT (Rand != NULL); + return InternalX86RdRand64 (Rand); +} -- 2.39.2