mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 16:44:58 +02:00
KVM: x86: hyper-v: Use guard() instead of mutex_lock() to simplify code
Use guard(mutex) instead of mutex_lock/mutex_unlock pair to simplify the error handling when setting up the TSC page for a Hyper-V guest. No functional change intended. Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com> Link: https://lore.kernel.org/r/20250901131604.646415-1-liaoyuanhong@vivo.com [sean: tweak changelog] Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
4319fa120f
commit
cbd860293d
|
|
@ -1168,15 +1168,15 @@ void kvm_hv_setup_tsc_page(struct kvm *kvm,
|
|||
BUILD_BUG_ON(sizeof(tsc_seq) != sizeof(hv->tsc_ref.tsc_sequence));
|
||||
BUILD_BUG_ON(offsetof(struct ms_hyperv_tsc_page, tsc_sequence) != 0);
|
||||
|
||||
mutex_lock(&hv->hv_lock);
|
||||
guard(mutex)(&hv->hv_lock);
|
||||
|
||||
if (hv->hv_tsc_page_status == HV_TSC_PAGE_BROKEN ||
|
||||
hv->hv_tsc_page_status == HV_TSC_PAGE_SET ||
|
||||
hv->hv_tsc_page_status == HV_TSC_PAGE_UNSET)
|
||||
goto out_unlock;
|
||||
return;
|
||||
|
||||
if (!(hv->hv_tsc_page & HV_X64_MSR_TSC_REFERENCE_ENABLE))
|
||||
goto out_unlock;
|
||||
return;
|
||||
|
||||
gfn = hv->hv_tsc_page >> HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT;
|
||||
/*
|
||||
|
|
@ -1192,7 +1192,7 @@ void kvm_hv_setup_tsc_page(struct kvm *kvm,
|
|||
goto out_err;
|
||||
|
||||
hv->hv_tsc_page_status = HV_TSC_PAGE_SET;
|
||||
goto out_unlock;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1228,12 +1228,10 @@ void kvm_hv_setup_tsc_page(struct kvm *kvm,
|
|||
goto out_err;
|
||||
|
||||
hv->hv_tsc_page_status = HV_TSC_PAGE_SET;
|
||||
goto out_unlock;
|
||||
return;
|
||||
|
||||
out_err:
|
||||
hv->hv_tsc_page_status = HV_TSC_PAGE_BROKEN;
|
||||
out_unlock:
|
||||
mutex_unlock(&hv->hv_lock);
|
||||
}
|
||||
|
||||
void kvm_hv_request_tsc_page_update(struct kvm *kvm)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user