[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] xen/x86: Livepatch: support patching CET-enhanced functions


  • To: David Vrabel <dvrabel@xxxxxxxxxx>, Bjoern Doebel <doebel@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 7 Mar 2022 15:26:24 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ipYBTJyVZYqQIjlvd2AgtoPfdZUZKUxC8m4xSwOfnsw=; b=hUwhyyk5OhqKBIi92PaRj9rof6SaE0tbyhULOZq3sKkWyuO2bW1uAg0DYN2oQcqKFqXs/g+N5hcyxE2ibqOCPkCFnUN24KXAoIaedaZZQ/T0IlOEA3BXwYOcfySF6U2PP06KZXL+PN6Hq8nxXwgmcRlJdp878M0r2u943qpjW+Sqd0a2XRoOJVQ3i3jGDCg5d+RFtX8mxHw4rfOz85gX7y10s1y2933Cssd7IlDXqPCN1reT7fSJ+RU9YKyBvwJR1uC2C1CurTnxkgqsP0+oYqNxr94R6lBkdWD6be5evitpEscEiJSEAjIvaL1JhonP8IY+Hu1eMVmVdpJMMvsd2Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eeBhTDAmEBZu3NI9hHzVRfw5uqLPoNXpcsUQObgDpRKzSwkFf535SwCPdcyy4ChOn09YqpE/0G+opy90M6E8aCUUxL0hrIuQtxG7dmICjk/fA8GHkdg6cRB7sBLNZShYSQbLPrO1jc9vp5lSEQOqk/1qqUeZkboBM8HoyuN525i4O92lUsH4d3GmndxiodtkeQR6hxF31QpSX7wesDazkBLqMGvAJYZLB8ZV1qRv7U7d2aSosrU92gTW2DgoyzNJDAQ2x6NxVzPz9PTy3FaBwhzlU7aHCEd42scAhnVQzWmzZ8m1nXFtjLoZLj5mBpV9r1d2mhbs+42BKN6JPv3RBQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Michael Kurth <mku@xxxxxxxxx>, Martin Pohlack <mpohlack@xxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 07 Mar 2022 14:26:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.