mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-02 16:30:12 +00:00
hv: coding style: refine find_vcpuid_entry
1) add local_find_vcpuid_entry to find whether a cpuid leaf exist in vcpuid cache entries. 2) find_vcpuid_entry will return the found entry if local_find_vcpuid_entry return is not null. Otherwise, call local_find_vcpuid_entry again when necessary. In this case, there could eliminate recursion in find_vcpuid_entry. Tracked-On: #861 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
parent
58d2a418d5
commit
a56abee9ff
@ -6,13 +6,12 @@
|
|||||||
|
|
||||||
#include <hypervisor.h>
|
#include <hypervisor.h>
|
||||||
|
|
||||||
static inline struct vcpuid_entry *find_vcpuid_entry(const struct acrn_vcpu *vcpu,
|
static inline struct vcpuid_entry *local_find_vcpuid_entry(const struct acrn_vcpu *vcpu,
|
||||||
uint32_t leaf_arg, uint32_t subleaf)
|
uint32_t leaf, uint32_t subleaf)
|
||||||
{
|
{
|
||||||
uint32_t i = 0U, nr, half;
|
uint32_t i = 0U, nr, half;
|
||||||
struct vcpuid_entry *entry = NULL;
|
struct vcpuid_entry *entry = NULL;
|
||||||
struct acrn_vm *vm = vcpu->vm;
|
struct acrn_vm *vm = vcpu->vm;
|
||||||
uint32_t leaf = leaf_arg;
|
|
||||||
|
|
||||||
nr = vm->vcpuid_entry_nr;
|
nr = vm->vcpuid_entry_nr;
|
||||||
half = nr >> 1U;
|
half = nr >> 1U;
|
||||||
@ -38,8 +37,19 @@ static inline struct vcpuid_entry *find_vcpuid_entry(const struct acrn_vcpu *vcp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct vcpuid_entry *find_vcpuid_entry(const struct acrn_vcpu *vcpu,
|
||||||
|
uint32_t leaf_arg, uint32_t subleaf)
|
||||||
|
{
|
||||||
|
struct vcpuid_entry *entry;
|
||||||
|
uint32_t leaf = leaf_arg;
|
||||||
|
|
||||||
|
entry = local_find_vcpuid_entry(vcpu, leaf, subleaf);
|
||||||
if (entry == NULL) {
|
if (entry == NULL) {
|
||||||
uint32_t limit;
|
uint32_t limit;
|
||||||
|
struct acrn_vm *vm = vcpu->vm;
|
||||||
|
|
||||||
if ((leaf & 0x80000000U) != 0U) {
|
if ((leaf & 0x80000000U) != 0U) {
|
||||||
limit = vm->vcpuid_xlevel;
|
limit = vm->vcpuid_xlevel;
|
||||||
@ -55,7 +65,7 @@ static inline struct vcpuid_entry *find_vcpuid_entry(const struct acrn_vcpu *vcp
|
|||||||
* CPUID)
|
* CPUID)
|
||||||
*/
|
*/
|
||||||
leaf = vm->vcpuid_level;
|
leaf = vm->vcpuid_level;
|
||||||
return find_vcpuid_entry(vcpu, leaf, subleaf);
|
entry = local_find_vcpuid_entry(vcpu, leaf, subleaf);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user