From: Zhao Liu <zhao1.liu@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>
Cc: qemu-devel@nongnu.org, Zhao Liu <zhao1.liu@intel.com>,
Zide Chen <zide.chen@intel.com>
Subject: [PATCH] target/i386/kvm: Replace KVM_MSR_FILTER_MAX_RANGES with ARRAY_SIZE(msr_handlers)
Date: Wed, 8 Jan 2025 23:19:46 +0800 [thread overview]
Message-ID: <20250108151946.1379591-1-zhao1.liu@intel.com> (raw)
kvm_install_msr_filters() uses KVM_MSR_FILTER_MAX_RANGES as the bound
when traversing msr_handlers[], while other places compute the size by
ARRAY_SIZE(msr_handlers).
In fact, msr_handlers[] is an array with the fixed size
KVM_MSR_FILTER_MAX_RANGES, so there is no difference between the two
ways.
For the code consistency, use ARRAY_SIZE(msr_handlers) uniformly instead
of KVM_MSR_FILTER_MAX_RANGES.
Suggested-by: Zide Chen <zide.chen@intel.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
Changelog:
* Addressed Paolo's comment [1] to choose ARRAY_SIZE(msr_handlers).
[1]: https://lore.kernel.org/qemu-devel/5463356b-827f-4c9f-a76e-02cd580fe885@redhat.com/
---
target/i386/kvm/kvm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 2f66e63b880a..7424a3f5cf48 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -5851,7 +5851,7 @@ static bool kvm_install_msr_filters(KVMState *s)
};
int r, i, j = 0;
- for (i = 0; i < KVM_MSR_FILTER_MAX_RANGES; i++) {
+ for (i = 0; i < ARRAY_SIZE(msr_handlers); i++) {
KVMMSRHandlers *handler = &msr_handlers[i];
if (handler->msr) {
struct kvm_msr_filter_range *range = &filter.ranges[j++];
--
2.34.1
reply other threads:[~2025-01-08 15:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250108151946.1379591-1-zhao1.liu@intel.com \
--to=zhao1.liu@intel.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zide.chen@intel.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;
as well as URLs for NNTP newsgroup(s).