mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-11-26 21:04:48 +00:00
hv: multi-arch: move {arch_}get_random_value to random.c
Tracked-On: #8834 Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com> Reviewed-by: Fei Li <fei1.li@intel.com> Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
committed by
acrnsi-robot
parent
0e0f673458
commit
0222bb0fc1
@@ -52,6 +52,7 @@ ASFLAGS += -m64 -nostdinc -nostdlib
|
||||
|
||||
# library componment
|
||||
LIB_C_SRCS += arch/x86/lib/memory.c
|
||||
LIB_C_SRCS += arch/x86/lib/random.c
|
||||
|
||||
# retpoline support
|
||||
ifeq (true, $(shell [ $(GCC_MAJOR) -eq 7 ] && [ $(GCC_MINOR) -ge 3 ] && echo true))
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <asm/cpufeatures.h>
|
||||
#include <asm/cpu_caps.h>
|
||||
#include <per_cpu.h>
|
||||
#include <random.h>
|
||||
#include <asm/init.h>
|
||||
#include <asm/guest/vm.h>
|
||||
#include <asm/guest/vmcs.h>
|
||||
|
||||
20
hypervisor/arch/x86/lib/random.c
Normal file
20
hypervisor/arch/x86/lib/random.c
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <types.h>
|
||||
|
||||
uint64_t arch_get_random_value(void)
|
||||
{
|
||||
uint64_t random;
|
||||
|
||||
asm volatile ("1: rdrand %%rax\n"
|
||||
"jnc 1b\n"
|
||||
"mov %%rax, %0\n"
|
||||
: "=r"(random)
|
||||
:
|
||||
:"%rax");
|
||||
return random;
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <asm/cpu_caps.h>
|
||||
#include <asm/security.h>
|
||||
#include <logmsg.h>
|
||||
#include <random.h>
|
||||
|
||||
static bool skip_l1dfl_vmentry;
|
||||
static bool cpu_md_clear;
|
||||
@@ -198,19 +199,6 @@ void cpu_internal_buffers_clear(void)
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t get_random_value(void)
|
||||
{
|
||||
uint64_t random;
|
||||
|
||||
asm volatile ("1: rdrand %%rax\n"
|
||||
"jnc 1b\n"
|
||||
"mov %%rax, %0\n"
|
||||
: "=r"(random)
|
||||
:
|
||||
:"%rax");
|
||||
return random;
|
||||
}
|
||||
|
||||
#ifdef STACK_PROTECTOR
|
||||
void set_fs_base(void)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,6 @@ void cpu_l1d_flush(void);
|
||||
bool check_cpu_security_cap(void);
|
||||
void cpu_internal_buffers_clear(void);
|
||||
bool is_ept_force_4k_ipage(void);
|
||||
uint64_t get_random_value(void);
|
||||
void disable_rrsba(void);
|
||||
|
||||
#ifdef STACK_PROTECTOR
|
||||
|
||||
17
hypervisor/include/common/random.h
Normal file
17
hypervisor/include/common/random.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef COMMON_RANDOM_H
|
||||
#define COMMON_RANDOM_H
|
||||
|
||||
uint64_t arch_get_random_value(void);
|
||||
|
||||
static inline uint64_t get_random_value(void)
|
||||
{
|
||||
return arch_get_random_value();
|
||||
}
|
||||
|
||||
#endif /* COMMON_RANDOM_H */
|
||||
Reference in New Issue
Block a user