From: Paolo Bonzini <pbonzini@redhat.com>
To: Rik van Riel <riel@surriel.com>
Cc: kernel-team@fb.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, "Radim Krčmář" <rkrcmar@redhat.com>
Subject: Re: [PATCH] kvm: change KVM_REQUEST_MASK to reflect vcpu.requests size
Date: Tue, 21 May 2019 20:28:36 +0200 [thread overview]
Message-ID: <ae5402e2-b748-b144-c1ea-715357529621@redhat.com> (raw)
In-Reply-To: <20190521132200.2b45c029@imladris.surriel.com>
On 21/05/19 19:22, Rik van Riel wrote:
> The code using KVM_REQUEST_MASK uses a pattern reminiscent of a bitmask:
>
> set_bit(req & KVM_REQUEST_MASK, &vcpu->requests);
>
> However, the first argument passed to set_bit, test_bit, and clear_bit
> is a bit number, not a bitmask. That means the current definition would
> allow users of kvm_make_request to overflow the vcpu.requests bitmask,
> and is confusing to developers examining the code.
This is true, but the meaning of the masking is that bits above 7 define
extra things to do when sending a request (wait for acknowledge, kick
the recipient CPU). The fact that the "request number" field is 8 bits
rather than 5 or 6 is just an implementation detail.
If you change it to BITS_PER_LONG-1, the obvious way to read the code
would be that requests 0, 64, 128 are all valid and map to the same request.
Paolo
> Redefine KVM_REQUEST_MASK to reflect the number of bits that actually
> fit inside an unsigned long, and add a comment explaining set_bit and
> friends take bit numbers, not a bitmask.
prev parent reply other threads:[~2019-05-21 18:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-21 17:22 Rik van Riel
2019-05-21 18:28 ` Paolo Bonzini [this message]
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=ae5402e2-b748-b144-c1ea-715357529621@redhat.com \
--to=pbonzini@redhat.com \
--cc=kernel-team@fb.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=riel@surriel.com \
--cc=rkrcmar@redhat.com \
/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
all inboxes | Powered by JetHome®