mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-21 05:02:24 +00:00
hv: refine coding style for ucode.c
- reduce exit points for 'acrn_update_ucode()' function. Tracked-On: #2095 Signed-off-by: Yonghua Huang <yonghua.huang@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
927c5172fa
commit
03262a96cf
@ -34,7 +34,7 @@ static inline size_t get_ucode_data_size(const struct ucode_header *uhdr)
|
|||||||
|
|
||||||
void acrn_update_ucode(struct acrn_vcpu *vcpu, uint64_t v)
|
void acrn_update_ucode(struct acrn_vcpu *vcpu, uint64_t v)
|
||||||
{
|
{
|
||||||
uint64_t gva, fault_addr;
|
uint64_t gva, fault_addr = 0UL;
|
||||||
struct ucode_header uhdr;
|
struct ucode_header uhdr;
|
||||||
size_t data_size;
|
size_t data_size;
|
||||||
int32_t err;
|
int32_t err;
|
||||||
@ -50,18 +50,12 @@ void acrn_update_ucode(struct acrn_vcpu *vcpu, uint64_t v)
|
|||||||
if (err == -EFAULT) {
|
if (err == -EFAULT) {
|
||||||
vcpu_inject_pf(vcpu, fault_addr, err_code);
|
vcpu_inject_pf(vcpu, fault_addr, err_code);
|
||||||
}
|
}
|
||||||
spinlock_release(µ_code_lock);
|
} else {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data_size = get_ucode_data_size(&uhdr) + sizeof(struct ucode_header);
|
data_size = get_ucode_data_size(&uhdr) + sizeof(struct ucode_header);
|
||||||
if (data_size > MICRO_CODE_SIZE_MAX) {
|
if (data_size > MICRO_CODE_SIZE_MAX) {
|
||||||
pr_err("The size of microcode is greater than 0x%x",
|
pr_err("The size of microcode is greater than 0x%x",
|
||||||
MICRO_CODE_SIZE_MAX);
|
MICRO_CODE_SIZE_MAX);
|
||||||
spinlock_release(µ_code_lock);
|
} else {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
err_code = 0U;
|
err_code = 0U;
|
||||||
err = copy_from_gva(vcpu, micro_code, gva, data_size, &err_code,
|
err = copy_from_gva(vcpu, micro_code, gva, data_size, &err_code,
|
||||||
&fault_addr);
|
&fault_addr);
|
||||||
@ -69,12 +63,12 @@ void acrn_update_ucode(struct acrn_vcpu *vcpu, uint64_t v)
|
|||||||
if (err == -EFAULT) {
|
if (err == -EFAULT) {
|
||||||
vcpu_inject_pf(vcpu, fault_addr, err_code);
|
vcpu_inject_pf(vcpu, fault_addr, err_code);
|
||||||
}
|
}
|
||||||
spinlock_release(µ_code_lock);
|
} else {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
msr_write(MSR_IA32_BIOS_UPDT_TRIG,
|
msr_write(MSR_IA32_BIOS_UPDT_TRIG,
|
||||||
(uint64_t)micro_code + sizeof(struct ucode_header));
|
(uint64_t)micro_code + sizeof(struct ucode_header));
|
||||||
(void)get_microcode_version();
|
(void)get_microcode_version();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
spinlock_release(µ_code_lock);
|
spinlock_release(µ_code_lock);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user