|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [V3] x86/xsaves: calculate the xstate_comp_offsets base on xcomp_bv
>>> On 07.03.16 at 11:19, <shuai.ruan@xxxxxxxxxxxxxxx> wrote:
> On Fri, Mar 04, 2016 at 06:56:35AM -0700, Jan Beulich wrote:
>> >>> On 04.03.16 at 12:00, <shuai.ruan@xxxxxxxxxxxxxxx> wrote:
>> > --- a/xen/arch/x86/domctl.c
>> > +++ b/xen/arch/x86/domctl.c
>> > @@ -934,8 +934,14 @@ long arch_do_domctl(
>> > goto vcpuextstate_out;
>> > }
>> >
>> > - expand_xsave_states(v, xsave_area,
>> > - size - 2 * sizeof(uint64_t));
>> > + ret = expand_xsave_states(v, xsave_area,
>> > + size - 2 * sizeof(uint64_t));
>> > + if ( ret )
>> > + {
>> > + xfree(xsave_area);
>> > + vcpu_unpause(v);
>> > + goto vcpuextstate_out;
>> > + }
>>
>> Well, while this is one way to deal with the problem, it's certainly
>> not the most desirable one: We should try to avoid runtime
>> allocations, failures of which then cause other things to fail (in
>> perhaps not very graceful ways). And doing so is pretty simple
>> here, and you even have two options: Either allocate a per-CPU
>> array, or - considering that XCNTXT_MASK has only a limited
>> number of bits set - even use an on-stack array of suitable
>> (compile time determined from XCNTXT_MASK) size. If you
> Thanks.
> I will change it to on-stack array.
> For "size compile time determined from XCNTXT_MASK", hweight64(XCNTXT_MASK)
> can return the num of bits set. But we need to caculte the highest bit set
> in XCNTXT_MASK at compile time, is there any macro can be used here ?
You may want to pull in Linux'es ilog2().
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |