mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 20:54:03 +02:00
KVM: x86/xen: Consolidate checks on Xen vCPU ID for singleshot timer hypercalls
Hoist the checks on the Xen vCPU ID when handling set_singleshot_timer and stop_singleshot_timer hypercalls out of their individual if-statements, so that both checks on the ID are in common code. kvm_xen_hcall_vcpu_op() is already doubly committed to handling only singleshot timer hypercalls, and even if that were to change in the future, the function could simply be renamed and turned into a helper specifically for timer hypercalls. Opportunistically add a comment to explain why the check exists; the code looks rather nonsensical without the knowledge that @vcpu_id is a common param for all per-vCPU hypercalls. No functional change intended. Reviewed-by: David Woodhouse <dwmw@amazon.co.uk> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Link: https://patch.msgid.link/20260630225619.511632-6-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
e4ffb0ceb9
commit
32d7943e51
|
|
@ -1614,12 +1614,18 @@ static bool kvm_xen_hcall_vcpu_op(struct kvm_vcpu *vcpu, bool longmode, int cmd,
|
|||
if (!kvm_xen_timer_enabled(vcpu))
|
||||
return false;
|
||||
|
||||
if (cmd == VCPUOP_set_singleshot_timer) {
|
||||
if (vcpu->arch.xen.vcpu_id != vcpu_id) {
|
||||
*r = -EINVAL;
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
* Reject the hypercall if the guest is trying to start/stop the timer
|
||||
* for a different vCPU. Xen per-vCPU hypercalls take a target vCPU as
|
||||
* a common parameter, as all per-vCPU hypercalls *except* single-shot
|
||||
* timer updates can be cross-vCPU.
|
||||
*/
|
||||
if (vcpu->arch.xen.vcpu_id != vcpu_id) {
|
||||
*r = -EINVAL;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cmd == VCPUOP_set_singleshot_timer) {
|
||||
/*
|
||||
* The only difference for 32-bit compat is the 4 bytes of
|
||||
* padding after the interesting part of the structure. So
|
||||
|
|
@ -1644,10 +1650,6 @@ static bool kvm_xen_hcall_vcpu_op(struct kvm_vcpu *vcpu, bool longmode, int cmd,
|
|||
|
||||
kvm_xen_start_timer(vcpu, oneshot.timeout_abs_ns, false);
|
||||
} else {
|
||||
if (vcpu->arch.xen.vcpu_id != vcpu_id) {
|
||||
*r = -EINVAL;
|
||||
return true;
|
||||
}
|
||||
kvm_xen_stop_timer(vcpu);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user