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

Re: [PATCH v2 4/5] xen/version: Fold build_id handling into xenver_varbuf_op()


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Mon, 16 Jan 2023 22:14:37 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=4Blw27gjCINtwT9t9bU6ZoWRv4DCoUYKhqngNd1B9rc=; b=JZde02OJhUE8DtwgXL5BsK1d7Ds2wE7X7rNUfJW5YR0SYX8hE4tEYByb8HyA5LCAaPocv5Rikz1eKYkUv9v5W/yrUEFPWVDL3CshW0ry90OAHo8lIuhP6wrJdjOdBz5otiJkUXHog+QFVyTfhgPylUS5YRFtvmR3Nw+W98+LQ5LpEmlUqnbXSga9wnBXcwRQQ99URuSTspjfglELUbd7oK0bx3WW+h8dKMqSHrHRp3Y8MtC1DdnFNu+FJPOIo+gbLiVL0DE8+hia10SAJGfBFDWRn03PUW3jBnWb3Bs6JSO1QP/GQ5tlfrxuL6cobQ2kGSpoF0VhLRtEnXbtwZZoBQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UL51MTPQcZapoyPOwi5FoWduWTSswy5zEOOBiqiJLg1F+r1Rtc/ydDwFY3px57ttLKy7iXfVMtcOKAQ3+pr9Bwrp4CaKoFXXitm1libifo6e4ocEkxAZi7joLCKq0YjME52dLTivky5sT4tA5+DrxRh6SORBY7huZhafe0WPjzERWSJf1+RUTWMllsHfqHrwf8obot/o8qxBgNjcQJkQLomlbGqcW+VRke4b80gMNepdRSTmZDWhYtmNUziWneTWvAUb4lUL7iP0eTXoUfLi2j7f62O37zmE5TeSIdtZUSDUed6Z2ccWAC0voLO2kPrhjg6I9BNuA46zT4xhffpXPw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: George Dunlap <George.Dunlap@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 16 Jan 2023 22:14:57 +0000
  • Ironport-data: A9a23:6bKBIalvKDN6M56H5lVUyuLo5gxLJ0RdPkR7XQ2eYbSJt1+Wr1Gzt xIdXWjTafqNZWr0Kdh2Pdjl9kMEuZbWz99nTFQ+qn0zEyMWpZLJC+rCIxarNUt+DCFhoGFPt JxCN4aafKjYaleG+39B55C49SEUOZmgH+a6U6icf3grHmeIcQ954Tp7gek1n4V0ttawBgKJq LvartbWfVSowFaYCEpNg064gE4p7auaVA8w5ARkPqgS5QGGzRH5MbpETU2PByqgKmVrNrbSq 9brlNmR4m7f9hExPdKp+p6TnpoiG+O60aCm0xK6aoD66vRwjnVaPpUTbZLwXXx/mTSR9+2d/ f0W3XCGpaXFCYWX8AgVe0Ew/yiTpsSq8pefSZS0mZT7I0Er7xIAahihZa07FdRwxwp5PY1B3 aAIERAuLUCFu+G/2by8Rsc3r5wFEOC+aevzulk4pd3YJdAPZMmZBo/stZpf1jp2gd1SF/HDY cZfcSBocBnLfxxIPBEQFY46m+CrwHL4dlW0qnrM/fZxvzeVkVE3iea9WDbWUoXiqcF9t0CUv G/ZuU/+BQkXLoe3wjuZ6HO8wOTImEsXXapDTu3mra462TV/wEQTDBhHfhjkmcCgqV+ZfOx7F 0oI8S8X+P1aGEuDC4OVsweDiHyOswMYWtFQO/Yn8wzLwa3Riy6CHXQNRDNFbN0gtec1SCYs2 1vPmMnmbRRwtJWFRHTb8a2bxRuwJCwUIGkqdSICCwwf7LHLsIw1yx7CUNtnOKq0lcHuXyH9x SiQqyozjKlVitQEv5hX5njCijOo45LPHgg841yNWnr/t10pIom4e4av9F7Xq+5aK5qURUWAu 35CnNWC6OcJDteGkynlrPgxIYxFLs2taFX06WOD1bF4n9hx0xZPpbxt3Qw=
  • Ironport-hdrordr: A9a23:/Fw+Iqs2/AqPuC5VqUq5BkKA7skDGNV00zEX/kB9WHVpm62j9v xG+c5w6faaslkssR0b9OxoW5PqfZq0z/cc3WB7B9mftWfd1FeVEA==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZJ6P7YcGbTGh3kUuVUrqx0/v8ha6hO92AgABksoA=
  • Thread-topic: [PATCH v2 4/5] xen/version: Fold build_id handling into xenver_varbuf_op()

On 16/01/2023 4:14 pm, Jan Beulich wrote:
> On 14.01.2023 00:08, Andrew Cooper wrote:
>> struct xen_build_id and struct xen_varbuf are identical from an ABI point of
>> view, so XENVER_build_id can reuse xenver_varbuf_op() rather than having it's
>> own almost identical copy of the logic.
>>
>> No functional change.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

Thanks.

>> --- a/xen/common/kernel.c
>> +++ b/xen/common/kernel.c
>> @@ -476,9 +476,22 @@ static long xenver_varbuf_op(int cmd, 
>> XEN_GUEST_HANDLE_PARAM(void) arg)
>>      struct xen_varbuf user_str;
>>      const char *str = NULL;
>>      size_t sz;
>> +    int rc;
> Why is this declared here, yet ...
>
>>      switch ( cmd )
>>      {
>> +    case XENVER_build_id:
>> +    {
>> +        unsigned int local_sz;
> ... this declared here?

Because rc is more likely to be used outside in the future, and...

>  Both could live in switch()'s scope,

... this would have to be reverted tree-wide to use
trivial-initialisation hardening, which we absolutely should be doing by
default already.


I was sorely tempted to correct xen_build_id() to use size_t, but I
don't have time to correct everything which is wrong here.  That can
wait until later clean-up.

Alternatively, this is a pattern we have in quite a few places,
returning a {ptr, sz} pair.  All architectures we compile for (and even
x86 32bit given a suitable code-gen flag) are capable of returning at
least 2 GPRs worth of data (ARM can do 4), so switching to some kind of

struct pair {
    void *ptr;
    size_t sz;
};

return value would improve the code generation (and performance for that
matter) across the board by avoiding unnecessary spills of
pointers/sizes/secondary error information to the stack.

The wins for hvm get/set_segment_register() modest bug absolutely
worthwhile (and I notice I still haven't got those patches published. 
/sigh).

>> +        rc = xen_build_id((const void **)&str, &local_sz);
>> +        if ( rc )
>> +            return rc;
>> +
>> +        sz = local_sz;
>> +        goto have_len;
> Personally I certainly dislike "goto" in general, and I thought the
> common grounds were to permit its use in error handling (only).

That's not written in CODING_STYLE, nor has it (to my knowledge) ever
been an expressed view on xen-devel.

I don't use goto's gratuitously, and this one isn't.  Just try and write
this patch without a goto and then judge which version is cleaner/easier
to follow.

~Andrew

 


Rackspace

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