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

Re: [PATCH v2] xen/x86: guest_access: optimize raw_x_guest() for PV and HVM combinations


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Fri, 7 Nov 2025 12:20:44 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=1ArRui7xmU0Fi7LEisehBujPu4Ubs2/KCh502Cj/GlU=; b=WyoSl4pgcnlA599wLn9kmGxWfLmfysSLeEkjzor06QyT2sBqgtDdlcRUUgv/hirjiWY8I/6WJD75KiWksWHt2I9Tmbbc0JGQkJn1WZqK7FvQStLuxcq1C6umcOnCIObo0P8kmMSwgTtvrHcIigYIIiNTUyR+mpm/yzQza9b1y106jLuRKlKKtyeA6QQOZFok20ZNmjcaiqXsc+ei715xJvRfSHnBmTXSauQ9VZPdcVQLrvcGPbMOYC2jeS6/l3SqybR+nA7AECOHYQo/vXHDWptlXi2PWo69uwNVoNm89xwWYFAtmKroVZPRXOuG6doxnHwW2VhKkhAFC8TnrwXWpA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=unq6TPvezPS4OYjjjNDH0Jb6ESJf8qzlZbShbIbAGVSfRy/scmfNBruBNkgBHho0VXfqz3HwfjtIUK2KXzBHguHyRSAH9pGJhHWGhMOugwmKGBZrSkVoAhBfG60ITJcQNMtO6Qj4OUDI8kN1tPHfPH87WB6NAMLB7d7PXrt296v4w7Ff2UuUBZSi4Fbg3QWubxpYNKOiZTPYeZAcf9cYp0u7M8cE5+yawQr/r12ItPN9LSTPsdDO0epGcLhR7Znvu3K/n9KdzUQ/yQl5mgqRJR4uzsoWCE+HlNI6J3XJsNCjwkhKyIT9wjRRo5SAD2hMZCbzhLJS/rr2J19HRxcAhA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Fri, 07 Nov 2025 10:20:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>



On 07.11.25 08:52, Jan Beulich wrote:
On 06.11.2025 23:26, Grygorii Strashko wrote:
From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>

Xen uses below pattern for raw_x_guest() functions:

define raw_copy_to_guest(dst, src, len)        \
     (is_hvm_vcpu(current) ?                     \
      copy_to_user_hvm((dst), (src), (len)) :    \
      copy_to_guest_pv(dst, src, len))

This pattern works depending on CONFIG_PV/CONFIG_HVM as:
- PV=y and HVM=y
   Proper guest access function is selected depending on domain type.
- PV=y and HVM=n
   Only PV domains are possible. is_hvm_domain/vcpu() will constify to "false"
   and compiler will optimize code and skip HVM specific part.
- PV=n and HVM=y
   Only HVM domains are possible. is_hvm_domain/vcpu() will not be constified.
   No PV specific code will be optimized by compiler.
- PV=n and HVM=n
   No guests should possible. The code will still follow PV path.

Rework raw_x_guest() code to use static inline functions which account for
above PV/HVM possible configurations with main intention to optimize code
for (PV=n and HVM=y) case.

For the case (PV=n and HVM=n) return "len" value indicating a failure (no
guests should be possible in this case, which means no access to guest
memory should ever happen).

Finally build arch/x86/usercopy.c only for PV=y.

The measured (bloat-o-meter) improvement for (PV=n and HVM=y) case is:
   add/remove: 2/9 grow/shrink: 2/90 up/down: 1678/-32560 (-30882)
   Total: Before=1937092, After=1906210, chg -1.59%

Signed-off-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
[teddy.astie@xxxxxxxxxx: Suggested to use static inline functions vs macro 
combinations]
Suggested-by: Teddy Astie <teddy.astie@xxxxxxxxxx>

Just one formal request for now: Please send patches To: the list, with 
individuals
on Cc: as necessary.

Sure, sorry.

--
Best regards,
-grygorii




 


Rackspace

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