[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2] psr: fix bug which may cause crash
On 29.11.2019 02:41, Yi Sun wrote: > On 19-11-28 12:25:44, Jan Beulich wrote: >> On 28.11.2019 11:18, Yi Sun wrote: >>> --- a/xen/arch/x86/psr.c >>> +++ b/xen/arch/x86/psr.c >>> @@ -1271,7 +1271,8 @@ static void do_write_psr_msrs(void *data) >>> >>> for ( j = 0; j < cos_num; j++, index++ ) >>> { >>> - if ( feat->cos_reg_val[cos * cos_num + j] != info->val[index] ) >>> + if ( cos <= feat->cos_max && >>> + feat->cos_reg_val[cos * cos_num + j] != info->val[index] ) >> >> The description is indeed much better now, thanks. However, >> as indicated in reply to v1, this extra (and at the first glance >> unmotivated) bounds check wants to be accompanied by a brief but > > I will add the comment. > >> precise comment. Furthermore with the loop bounded by a local >> variable, why not >> >> cos_num = min(props->cos_num, feat->cos_max + 1); >> >> a few lines up from here (again suitable commented)? >> > cos_num is a different thing with the number of COS registers. The > meaning of it is "COS registers number that feature uses for one COS > ID". E.g. MBA/CAT cos_num is always 1. But CDP cos_num is 2 because it > uses 2 COS registers for one COS ID. Oh, right, I got confused. The cos <= feat->cos_max is entirely loop invariant. Hence the loop shouldn't even be entered, i.e. you want to add a conditional ahead of it. Jan _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |