Skip to content

Commit d662b66

Browse files
committed
target/i386/kvm: Replace ARRAY_SIZE(msr_handlers) with KVM_MSR_FILTER_MAX_RANGES
kvm_install_msr_filters() uses KVM_MSR_FILTER_MAX_RANGES as the bound when traversing msr_handlers[], while other places still compute the size by ARRAY_SIZE(msr_handlers). In fact, msr_handlers[] is an array with the fixed size KVM_MSR_FILTER_MAX_RANGES, and this has to be true because kvm_install_msr_filters copies from one array to the other. For code consistency, assert that they match and use ARRAY_SIZE(msr_handlers) everywehere. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent d2401a6 commit d662b66

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

target/i386/kvm/kvm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5854,7 +5854,8 @@ static int kvm_install_msr_filters(KVMState *s)
58545854
};
58555855
int i, j = 0;
58565856

5857-
for (i = 0; i < KVM_MSR_FILTER_MAX_RANGES; i++) {
5857+
QEMU_BUILD_BUG_ON(ARRAY_SIZE(msr_handlers) != ARRAY_SIZE(filter.ranges));
5858+
for (i = 0; i < ARRAY_SIZE(msr_handlers); i++) {
58585859
KVMMSRHandlers *handler = &msr_handlers[i];
58595860
if (handler->msr) {
58605861
struct kvm_msr_filter_range *range = &filter.ranges[j++];

0 commit comments

Comments
 (0)