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

Re: [PATCH v2 2/5] xen/version: Calculate xen_capabilities_info once at boot


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Mon, 16 Jan 2023 20:52:59 +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=iDL1zluBrBcTcbxS6RUN8p9kDjFJHfxxR9EVb4tVrEk=; b=NZvH+qXxOp1hl8rVwYAKwh2U9cr19Utiev+zyGbeuTLPYMXYW2vYgFFaVyKr90wTWycymmv4/ugQhFMOFSmb8MuDAawZ4Cllabha3iQ67u6VzsoXjmzdJuFIa2PJDqZmc19LJWz4blm1Z1yWH12GUP/i+e2hmwoItdbaf+psacApiHOsk1BV814wxccQTDT7LejsL+gwh6uGQDIhPpuNhyHawwfRqYH/NT00fNhvKvHvO68IkJbmCdB9zFdDAzQEyrZIQkKfoNn5CLOGUt9YsWaQBFbWTgY+QRBIN8crMzBaWysmQBdl/8OZ7k7RV5FizGjgOfB6mbPMpwjKP4gnmw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J9spva7YyCwqYmB5pRtVYLj4B00KTjrGhUP8b0t2vlZdnsogbSTSehMsaKZsXxV3j4aI3+7HtuGe9JZy0NgZsus8I1ao2Q5fg8JhsUk8Es3U9E5iFgaGaj3wylWCDXAaNAWeNZjnsPgsOGMXmuWc0/WBoqJn7Ol6brRYz6DB7I5kgDv8RpIsEo13LyFELJIEZHGzBKtrv7zuC1CtLSyqeNhUIbrDKPRJINlihWpS6kdVvCdrsGArgim6t/tlqd2ZR+l3QYpNJzmcsbOHdafEKJCPgwP5noQlI8yCZAeUiOdMdF4RyirnPQEkl9TB+AoPsmeLfg77cmJYYhndUq9Faw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 16 Jan 2023 20:53:13 +0000
  • Ironport-data: A9a23:/zuYE6Pp9mEBqqbvrR0llsFynXyQoLVcMsEvi/4bfWQNrUomgTNRy jAfWT+GP6uDYmf1eYgkYIy+/EwDuZeAzoBlGwto+SlhQUwRpJueD7x1DKtS0wC6dZSfER09v 63yTvGacajYm1eF/k/F3oDJ9CU6jufQA+KmU4YoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGj9Suv3rRC9H5qyo42tB5wJmP5ingXeF/5UrJMNHTU2OByOQrrl8RoaSW +vFxbelyWLVlz9F5gSNy+uTnuUiG9Y+DCDW4pZkc/HKbitq/0Te5p0TJvsEAXq7vh3S9zxHJ HehgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/ZqAJGpfh66wGMa04AWEX0r8rPl1u1 9E+ERkqXxOvgefq/pOLZfY506zPLOGzVG8ekldJ6GiBSNMZG9XESaiM4sJE1jAtgMwIBezZe 8cSdTtoalLHfgFLPVAUTpk5mY9EhFGmK2Ee9A3T+PdxujCJpOBy+OGF3N79U9qGX8hK2G2fo XrL5T/RCRAGLt2PjzGC9xpAg8eexnmqCNpIT9VU8NZUoUOQz34SUCRVdneK8dKcjnKlVuNAf hl8Fi0G6PJaGFaQZtv3UgC8oXWElgUBQNcWGOo/gCmSzoLE7gDfAXILJhZac8AvvsIyQT0s1 3eKksnvCDgpt6eaIVqf67OVoDWaKSUTa2gYakcscwwB5NXypZApuTjGRN1jDa2dg8X8HHf7x DXihCIznakJhMgHkaCy50nagimEr4LMCAUy423/Tm+jqw90eoOhT4ip8kTAq+ZNKp6DSVuMt 2RCnNKRhN3iFrmInS2JBeASRreg4q/dNCWG2AY1WZ486z6q5nivO5hK5y1zL1toNcBCfiL1Z EjUukVa45o70GaWUJKbqrmZU6wCpZUM3/y8PhwIRrKiuqRMSTI=
  • Ironport-hdrordr: A9a23:ZWfzXqP28Hq/P8BcTs+jsMiBIKoaSvp037BL7SxMoHluGfBw+P rAoB1273HJYVQqOE3I6OrgBEDoexq1n/NICOIqTNSftWfdyQ6VBbAnwYz+wyDxXw3Sn9QtsZ uIqpIOauHNMQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZJ6P9a3SW6Dw/uUGcS4ObfuDLQK6hNfQAgABTzIA=
  • Thread-topic: [PATCH v2 2/5] xen/version: Calculate xen_capabilities_info once at boot

On 16/01/2023 3:53 pm, Jan Beulich wrote:
> On 14.01.2023 00:08, Andrew Cooper wrote:
>> The arch_get_xen_caps() infrastructure is horribly inefficient, for something
>> that is constant after features have been resolved on boot.
>>
>> Every instance used snprintf() to format constants into a string (which gets
>> shorter when %d gets resolved!), which gets double buffered on the stack.
>>
>> Switch to using string literals with the "3.0" inserted - these numbers
>> haven't changed in 18 years (The Xen 3.0 release was Dec 5th 2005).
>>
>> Use initcalls to format the data into xen_cap_info, which is deliberately not
>> of type xen_capabilities_info_t because a 1k array is a silly overhead for
>> storing a maximum of 77 chars (the x86 version) and isn't liable to need any
>> more space in the forseeable future.
> So I was wondering if once we arrived at the new ABI (and hence the 3.0 one
> is properly legacy) we shouldn't declare Xen 5.0 and then also mark the new
> ABI's availability here by a string including "5.0" where at present we
> expose (only) "3.0".

"the new ABI" is is still two things.

The one part is changes to the in-guest ABI which does make it GPA based
(for HVM), but this does need to be broadly backwards compatible.  This
ABI string lives in the PV guest elfnotes (and is ultimately the thing
that distinguishes PV32pae vs PV64), but nowhere interesting for HVM
guests as far as I can see (furthermore, the 3 variations of hvm-3.0-
are bogus.

xen-3.0-x86_64la57 would probably be the least invasive way to extend PV
support to 5-level paging.

The other part is a stable tools API/ABI.  This can have any kind of
interface we choose, and frankly there are better interfaces than this
stringly typed one.


"xen-3.0" is even hardcoded in libelf.  I can't foresee a good reason to
bump 3 -> 5 and break all current PV guests.

>> If Xen had strncpy(), then the hunk in do_xen_version() could read:
>>
>>   if ( deny )
>>      memset(info, 0, sizeof(info));
>>   else
>>      strncpy(info, xen_cap_info, sizeof(info));
>>
>> to avoid double processing the start of the buffer, but given the ABI (must
>> write 1k chars into the guest), I cannot see any way of taking info off the
>> stack without some kind of strncpy_to_guest() API.
> How about using clear_guest() for the 1k range, then copy_to_guest() for
> merely the string? Plus - are we even required to clear the buffer past
> the nul terminator?

Well, we have previously always copied 1k bytes.  But this is always
been a NUL terminated API of a string persuasion, so I find it hard to
believe that any caller cares beyond the NUL.

Because of safe_strcpy(), xen_cap_info is guaranteed to be NUL
terminated, so if we don't care about padding the buffer with extra
zeroes, we don't even need the clear_guest().

Also, similar reasoning would apply to XENVER_cmdline which is typically
rather less than 1k in length (at least it's not on the stack, but it is
still an excessive copy).

~Andrew

 


Rackspace

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