From: Dmytro Maluka <dmaluka@chromium.org>
To: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Mathias Krause <minipli@grsecurity.net>,
kvm@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
Vineeth Pillai <vineeth@bitbyteword.org>,
Chuanxiao Dong <chuanxiao.dong@intel.com>,
Aashish Sharma <aashish@aashishsharma.net>,
Grzegorz Jaszczyk <jaszczyk@chromium.org>,
Dmytro Maluka <dmaluka@chromium.org>
Subject: [PATCH v2 0/4] KVM: x86: Fix off-by-one in max_vcpu_ids bounds checks
Date: Fri, 31 Jul 2026 15:08:41 +0000 [thread overview]
Message-ID: <20260731150846.1728164-1-dmaluka@chromium.org> (raw)
max_vcpu_ids and KVM_CAP_MAX_VCPU_ID are exclusive, i.e. the maximum
allowed vcpu_id value is max_vcpu_ids minus one, not max_vcpu_ids.
Fix the sanity checks for KVM_SET_BOOT_CPU_ID and KVM_CAP_MAX_VCPU_ID
and the selftests for them (added in series [1]) to fail when
bsp_vcpu_id is incorrectly set to max_vcpu_ids, not to a value below
max_vcpu_ids.
Also clarify that in the documentation of KVM_CAP_MAX_VCPU_ID, in an
attempt to make this a bit less confusing.
v1 -> v2:
Split selftest fix into two patches, to avoid interim breakage of tests.
[1] https://lore.kernel.org/all/20240614202859.3597745-1-minipli@grsecurity.net/
Dmytro Maluka (4):
KVM: selftests: Fix treating KVM_CAP_MAX_VCPU_ID as inclusive
KVM: x86: Fix off-by-one in max_vcpu_ids bounds checks
KVM: selftests: Improve bsp_vcpu_id and max_vcpu_ids out-of-bound
tests
Documentation: KVM: Clarify that KVM_CAP_MAX_VCPU_ID is exclusive
Documentation/virt/kvm/api.rst | 13 ++++++++-----
arch/x86/kvm/x86.c | 6 +++---
.../selftests/kvm/x86/max_vcpuid_cap_test.c | 17 ++++++++++-------
.../testing/selftests/kvm/x86/set_boot_cpu_id.c | 4 ++--
4 files changed, 23 insertions(+), 17 deletions(-)
--
2.55.0.508.g3f0d502094-goog
next reply other threads:[~2026-07-31 15:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 15:08 Dmytro Maluka [this message]
2026-07-31 15:08 ` [PATCH v2 1/4] KVM: selftests: Fix treating KVM_CAP_MAX_VCPU_ID as inclusive Dmytro Maluka
2026-07-31 15:08 ` [PATCH v2 2/4] KVM: x86: Fix off-by-one in max_vcpu_ids bounds checks Dmytro Maluka
2026-07-31 15:08 ` [PATCH v2 3/4] KVM: selftests: Improve bsp_vcpu_id and max_vcpu_ids out-of-bound tests Dmytro Maluka
2026-07-31 15:08 ` [PATCH v2 4/4] Documentation: KVM: Clarify that KVM_CAP_MAX_VCPU_ID is exclusive Dmytro Maluka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260731150846.1728164-1-dmaluka@chromium.org \
--to=dmaluka@chromium.org \
--cc=aashish@aashishsharma.net \
--cc=chuanxiao.dong@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=jaszczyk@chromium.org \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=minipli@grsecurity.net \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vineeth@bitbyteword.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox