[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: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 16 Jan 2023 16:53:04 +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=zq5dcdvsUgQl8t7WqSJGZgZE/1yIwBnvejIvXnI0TBg=; b=DnV51OHOF4DcI5JKiHjSG+qG5rhgkL6/iQpZjyb+lb44ZmHWkY7fRuZ17bvU4pzqEUVTFcUvJCiSVfwqqgrE2/ZdAVu/zPQNzy2Dp/mzjlM/fdg0K24QcrxyGgKFQxn5Gm1jXcDh0BfXUY5iEjMLDsk0y4e0+NTKQnhH0D0Ot2IIrMwv8P3yDewYPOrlalDhE0J4m+H+JukHWPwKneXHyKwZb7Y/TC4Lr5TSS+Uf+ROz7YpXJ+0fHTohV05SzRx6tKH3l1UDIxJTP8bkLCBqUMKFXebL6Uhp6Iq5oCshwriwYcTI9be+w4PHVx7c5qYpFgJjexHeLf2kIpnLIBcWJQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VyJwOnjpW3Exilt7MJCaz62/10owZ7zMpUqlHlCwEPprWaMFJCSmu+3SQ32/R+pXrvGsV2NbzIefClnMmbfgOhND9W92PqKKlcFVhf6bEAJeiplblmatnxeDhuEx7KzTqeob/mJOGUcnNNTlPGBsIDHfYqTGcZ2Ksjgl8g6mL7NUfW0ZWFqJp9pA83FcQJvzTJdpWqFI7r2QTKgADbFybw+TL8iEdBlkEG9ketOFfV1vJ0Rtfl5Fb4KwAuvDUodVcJhmSLuWiCe5Arr1qTMX8C3SxDVnssGZ075Mo0D6/nMTyi6L4Gbv5cDsw7idu67n5Nyiyf9mE8u0UeK8dQWWBg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <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 15:53:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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".

> 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?

Jan



 


Rackspace

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