From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CE9B3BB109 for ; Thu, 25 Jun 2026 22:36:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782426992; cv=none; b=TaDNddF9W/nM6hb+zyYFn62pAxm3s+1nQsPXFu5k+mdrqAjVLV4Jw9fUgdekmu8QVtqS3/XnilG8zC9wVIaZ8MKqP8V/P0z7Q/ikDldkcvDN6vso9FGMaxMagxACd5vQ0hcnGFliOIfW6hjSMN2dUDBPPpjhXmkhtbDFBhD87eo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782426992; c=relaxed/simple; bh=8HxPBU9SZPjdBMrZy4CVoqrwUO5xu5o2avqHHSOyEMU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=R99CiLS+JkDsCbux7KnS+8BWCNg7oqieMKeNw2e0CNF+y5edtT2lsbeaR3HixzQnd2pEbzWPAXa4pOSlvkqKaies6nayKxDJezbuf6C9O7XGalHrJVlqnvJo2ESIOb3lVRTM7UpHHXROpeavVsiAGhJVQhBTl7S3qUqgL0grPWo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=RAkEilYc; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RAkEilYc" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-37cc07f3e36so382067a91.2 for ; Thu, 25 Jun 2026 15:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782426990; x=1783031790; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=OmCzffinlUA5U4j9SV2YuKuYabtz/0IJql9W8lgHC5g=; b=RAkEilYcvRjJa12S6JCFYxUPVT4/Pg6MnwN/96W7yF2R81OFE8m4IGN0PjxQ/NGtOl ESaBwgASdXx9QzB3wCdSOg0rq5BZhxeTmrEO5B8Z2NPFBeHcbiMAGD2+WWzpKci4tQ59 5M8k99eSej1xL4oB54ouLjdI19ahB8eFsW83jqrEYktybxusFufXXZxiWXuEVxRQvwnB yQY9jxh6LHamO+FvDJ78fMAYK6DhpUJkb4/oeS3n8VBXIWqUMmCppzPHR75q1sZkQDMi Cj0WbjU5rDmpm5fUw9Jyl7ty/9KSl5wIEy2Pqd49cNmAyLP7Mv0PRxSI3pTnYeN29AQW tpCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782426990; x=1783031790; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OmCzffinlUA5U4j9SV2YuKuYabtz/0IJql9W8lgHC5g=; b=hiRZwEbAjkVnr7of237MM9rpS01y1nUNcQJfEgfRhGgy4CQja/SCExBB2FBmKcCEfi 4NdT+2WozEQvQ1Uh5qkUkcxRPW6e1HTL4rmEJG8VmI6bm3YxPK8y7cEpqs0bVUle1jN2 LmW9K+pLBrftUZjLR9oGuIy+qM+m2WXEUzOCFUI79U+pt3ewv9OWXdIMIZJ2qCg1D+25 ZSayAZfGHtjGLKr+rvO8lVp/ecrZGHMkyThiKIaBvk/Mkomb34LIlk2TcHsmambYJkdj osChmAj4hWAcwjWHMQ+oqdv5r1HEbhwNzFjKggdhzWIE/4T1OYvAEBHzORyY5nrV7PUb pKwg== X-Forwarded-Encrypted: i=1; AHgh+Rp0RNSzRuO6Kn+9ZdpSls1G+rMw5LzAS+GHkmZwUhdP6zf0etz4Vho6CDYJAiD47K2NU6ubh+CGgui/t2M=@vger.kernel.org X-Gm-Message-State: AOJu0YwQvJNH1zmEZQ6RneXafnwPPn46CfQvpUf4CI1hezw4jGdIqY2Q ixLvnf/8d4SVMUZABuzvFmmOUcgLGgtTM/sRynjPNi7o38DzJiFqm/Q1WedrcYTHGWWxf9hbJgv F52KpcA== X-Received: from pgbaz13.prod.google.com ([2002:a05:6a02:4d:b0:c8b:6fd:f93f]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:270d:b0:37d:d204:d14d with SMTP id 98e67ed59e1d1-37dfa1c70b7mr4442374a91.6.1782426990409; Thu, 25 Jun 2026 15:36:30 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 25 Jun 2026 15:36:18 -0700 In-Reply-To: <20260625223623.3376478-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260625223623.3376478-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.rc0.799.gd6f94ed593-goog Message-ID: <20260625223623.3376478-6-seanjc@google.com> Subject: [PATCH v3 05/10] KVM: x86/xen: Consolidate checks on Xen vCPU ID for singleshot timer hypercalls From: Sean Christopherson To: Vitaly Kuznetsov , Sean Christopherson , Paolo Bonzini , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+5b32c49cd8f005e65654@syzkaller.appspotmail.com, syzbot+5d2b94b77112148d1744@syzkaller.appspotmail.com Content-Type: text/plain; charset="UTF-8" Hoist the checks on the Xen vCPU ID when handling set_singleshot_timer and stop_singleshot_timer hypercalls out of their individual case-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. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/xen.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c index 27c1aeeab8af..db10f12d10cf 100644 --- a/arch/x86/kvm/xen.c +++ b/arch/x86/kvm/xen.c @@ -1614,13 +1614,13 @@ static bool kvm_xen_hcall_vcpu_op(struct kvm_vcpu *vcpu, bool longmode, int cmd, if (vcpu->arch.xen.vcpu_id == XEN_VCPU_ID_INVALID) return false; + if (vcpu->arch.xen.vcpu_id != vcpu_id) { + *r = -EINVAL; + return true; + } + switch (cmd) { case VCPUOP_set_singleshot_timer: - if (vcpu->arch.xen.vcpu_id != vcpu_id) { - *r = -EINVAL; - return true; - } - /* * The only difference for 32-bit compat is the 4 bytes of * padding after the interesting part of the structure. So @@ -1648,10 +1648,6 @@ static bool kvm_xen_hcall_vcpu_op(struct kvm_vcpu *vcpu, bool longmode, int cmd, return true; case VCPUOP_stop_singleshot_timer: - if (vcpu->arch.xen.vcpu_id != vcpu_id) { - *r = -EINVAL; - return true; - } kvm_xen_stop_timer(vcpu); *r = 0; return true; -- 2.55.0.rc0.799.gd6f94ed593-goog