Fix a BUG_ON issue
PATCH 1/1 Fix a BUG_ON issue
The 'idx' can equal to the max number of vCPUs, fix it.
--- xen/drivers/passthrough/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/io.c +1 -1
@@ -243,7 +243,7 @@ static struct vcpu *vector_hashing_dest(const struct domain *d,for ( i =0 ; i <= mod; i++ ) { idx =find_next_bit (dest_vcpu_bitmap, d->max_vcpus, idx) +1 ; -BUG_ON (idx >= d->max_vcpus); +BUG_ON (idx > d->max_vcpus); } dest = d->vcpu[idx -1 ];
Signature · 7 lines
2.1.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
xen/drivers/passthrough/io.c static struct vcpu *vector_hashing_dest(const struct domain *d, · line 249
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 29.08.16 at 11:14, <[email protected]> wrote:
xen/drivers/passthrough/io.c +1
-1@@ -243,7 +243,7 @@ static struct vcpu *vector_hashing_dest(const struct domain *d,for ( i =0 ; i <= mod; i++ ) { idx =find_next_bit (dest_vcpu_bitmap, d->max_vcpus, idx) +1 ; -BUG_ON (idx >= d->max_vcpus); +BUG_ON (idx > d->max_vcpus); } dest = d->vcpu[idx -1 ];
Wouldn't it be better to change the code to
unsigned int idx = -1;
for ( i = 0; i <= mod; i++ )
{
idx = find_next_bit(dest_vcpu_bitmap, d->max_vcpus, idx + 1);
BUG_ON(idx >= d->max_vcpus);
}
dest = d->vcpu[idx];or, not utilizing wrapping
unsigned int idx = find_first_bit(dest_vcpu_bitmap, d->max_vcpus);
for ( i = 0; i < mod; i++ )
idx = find_next_bit(dest_vcpu_bitmap, d->max_vcpus, idx + 1);
BUG_ON(idx >= d->max_vcpus);
dest = d->vcpu[idx];Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 25 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, August 29, 2016 7:51 PM
To: Wu, Feng <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Fix aBUG_ONissuexen/drivers/passthrough/io.c static struct vcpu *vector_hashing_dest(const struct
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 29.08.16 at 11:14, <[email protected]> wrote:
xen/drivers/passthrough/io.c +0
-0@@ -243,7 +243,7 @@ static struct vcpu *vector_hashing_dest(const structdomain *d,
xen/drivers/passthrough/io.c static struct vcpu *vector_hashing_dest(const struct domain *d, · line 249
Quoted 8 lines
xen/drivers/passthrough/io.c +1
-1for ( i =0 ; i <= mod; i++ ) { idx =find_next_bit (dest_vcpu_bitmap, d->max_vcpus, idx) +1 ; -BUG_ON (idx >= d->max_vcpus); +BUG_ON (idx > d->max_vcpus); } dest = d->vcpu[idx -1 ];Wouldn't it be better to change the code to
Quoted 9 lines
unsigned int idx = -1;
for ( i = 0; i <= mod; i++ )
{
idx = find_next_bit(dest_vcpu_bitmap, d->max_vcpus, idx + 1);
BUG_ON(idx >= d->max_vcpus);
}
dest = d->vcpu[idx];Thanks for the comments, both are good to me, but I slightly prefer this one. Do I need to send another version?
Thanks,
Feng
Quoted 12 lines
or, not utilizing wrapping
unsigned int idx = find_first_bit(dest_vcpu_bitmap, d->max_vcpus); for ( i = 0; i < mod; i++ ) idx = find_next_bit(dest_vcpu_bitmap, d->max_vcpus, idx + 1); BUG_ON(idx >= d->max_vcpus); dest = d->vcpu[idx];
Quoted 1 line
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 27 lines
Quoted 27 lines
Quoted 1 line · On 30.08.16 at 01:19, <[email protected]> wrote:
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, August 29, 2016 7:51 PMxen/drivers/passthrough/io.c static struct vcpu *vector_hashing_dest(const struct
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 29.08.16 at 11:14, <[email protected]> wrote:
xen/drivers/passthrough/io.c +0
-0@@ -243,7 +243,7 @@ static struct vcpu *vector_hashing_dest(const structdomain *d,
xen/drivers/passthrough/io.c static struct vcpu *vector_hashing_dest(const struct domain *d, · line 249
Quoted 8 lines
xen/drivers/passthrough/io.c +1
-1for ( i =0 ; i <= mod; i++ ) { idx =find_next_bit (dest_vcpu_bitmap, d->max_vcpus, idx) +1 ; -BUG_ON (idx >= d->max_vcpus); +BUG_ON (idx > d->max_vcpus); } dest = d->vcpu[idx -1 ];Wouldn't it be better to change the code to
unsigned int idx = -1; for ( i = 0; i <= mod; i++ ) { idx = find_next_bit(dest_vcpu_bitmap, d->max_vcpus, idx + 1); BUG_ON(idx >= d->max_vcpus); }
Quoted 4 lines
Quoted 1 line
dest = d->vcpu[idx];Thanks for the comments, both are good to me, but I slightly prefer this one. Do I need to send another version?
Not necessarily - can you reason a little about your preference? I particularly dislike the subtraction necessary here:
dest = d->vcpu[idx - 1];
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 37 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Tuesday, August 30, 2016 2:34 PM
To: Wu, Feng <[email protected]>
Cc: [email protected]
Subject: RE: [PATCH] Fix aBUG_ONissueQuoted 7 lines
Quoted 7 lines
Quoted 1 line · On 30.08.16 at 01:19, <[email protected]> wrote:
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, August 29, 2016 7:51 PMxen/drivers/passthrough/io.c static struct vcpu *vector_hashing_dest(const
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 29.08.16 at 11:14, <[email protected]> wrote:
xen/drivers/passthrough/io.c +0
-0@@ -243,7 +243,7 @@ static struct vcpu *vector_hashing_dest(conststruct
Quoted 20 lines
Quoted 20 lines
domain *d,
xen/drivers/passthrough/io.c static struct vcpu *vector_hashing_dest(const struct domain *d, · line 249
Quoted 8 lines
xen/drivers/passthrough/io.c +1
-1for ( i =0 ; i <= mod; i++ ) { idx =find_next_bit (dest_vcpu_bitmap, d->max_vcpus, idx) +1 ; -BUG_ON (idx >= d->max_vcpus); +BUG_ON (idx > d->max_vcpus); } dest = d->vcpu[idx -1 ];Wouldn't it be better to change the code to
unsigned int idx = -1; for ( i = 0; i <= mod; i++ ) { idx = find_next_bit(dest_vcpu_bitmap, d->max_vcpus, idx + 1); BUG_ON(idx >= d->max_vcpus); }
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
dest = d->vcpu[idx];Thanks for the comments, both are good to me, but I slightly prefer this one. Do I need to send another version?
Not necessarily - can you reason a little about your preference? I
Oh, no particular reason, just feel it looks a little simple! :) But I am fine if you prefer the other one.
Thanks,
Feng
Quoted 5 lines
particularly dislike the subtraction necessary here:
dest = d->vcpu[idx - 1];Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel