|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 2/2] xen/x86: Livepatch: support patching CET-enhanced functions
On 07.03.2022 15:21, David Vrabel wrote:
> On 07/03/2022 14:03, Jan Beulich wrote:
>> On 07.03.2022 12:53, Bjoern Doebel wrote:
>>> @@ -104,18 +122,36 @@ void noinline arch_livepatch_revive(void)
>>>
>>> int arch_livepatch_verify_func(const struct livepatch_func *func)
>>> {
>>> + BUILD_BUG_ON(sizeof(struct x86_livepatch_meta) !=
>>> LIVEPATCH_OPAQUE_SIZE);
>>> +
>>> /* If NOPing.. */
>>> if ( !func->new_addr )
>>> {
>>> + struct x86_livepatch_meta *lp;
>>> +
>>> + lp = (struct x86_livepatch_meta *)func->opaque;
>>> /* Only do up to maximum amount we can put in the ->opaque. */
>>> - if ( func->new_size > sizeof(func->opaque) )
>>> + if ( func->new_size > sizeof(lp->instruction) )
>>> return -EOPNOTSUPP;
>>>
>>> if ( func->old_size < func->new_size )
>>> return -EINVAL;
>>> }
>>
>> I continue to be concerned of the new local variable causing compiler
>> warnings. With the adjustment made compared to v1, the specific
>> warning would have changed, and we're now liable to see set-but-never-
>> used ones.
>
> Linux has a sizeof_field() macro for this sort of use.
>
> /**
> * sizeof_field() - Report the size of a struct field in bytes
> *
> * @TYPE: The structure containing the field of interest
> * @MEMBER: The field to return the size of
> */
> #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))
Oh, I should have thought of this. Iirc it was Paul who did pull in
this one, so it should be readily available.
Thanks for pointing out,
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |