hv: refine coding style for ucode.c
- reduce exit points for 'acrn_update_ucode()' function.
Acked-by: Eddie Dong
@@ -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)
{
- uint64_t gva, fault_addr;
+ uint64_t gva, fault_addr = 0UL;
struct ucode_header uhdr;
size_t data_size;
int32_t err;
@@ -50,18 +50,12 @@ void acrn_update_ucode(struct acrn_vcpu *vcpu, uint64_t v)
if (err == -EFAULT) {
vcpu_inject_pf(vcpu, fault_addr, err_code);
}
- spinlock_release(&micro_code_lock);
- return;
- }
-
+ } else {
data_size = get_ucode_data_size(&uhdr) + sizeof(struct ucode_header);
if (data_size > MICRO_CODE_SIZE_MAX) {
pr_err("The size of microcode is greater than 0x%x",
MICRO_CODE_SIZE_MAX);
- spinlock_release(&micro_code_lock);
- return;
- }
-
+ } else {
err_code = 0U;
err = copy_from_gva(vcpu, micro_code, gva, data_size, &err_code,
&fault_addr);
@@ -69,12 +63,12 @@ void acrn_update_ucode(struct acrn_vcpu *vcpu, uint64_t v)
if (err == -EFAULT) {
vcpu_inject_pf(vcpu, fault_addr, err_code);
}
- spinlock_release(&micro_code_lock);
- return;
- }
-
+ } else {
msr_write(MSR_IA32_BIOS_UPDT_TRIG,
(uint64_t)micro_code + sizeof(struct ucode_header));
(void)get_microcode_version();
+ }
+ }
+ }
spinlock_release(&micro_code_lock);
}
