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

Re: [XEN][PATCH 3/5] x86: hvm: factor out compat code under ifdefs


  • To: Jürgen Groß <jgross@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Wed, 19 Nov 2025 13:48:14 +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=9hUTUz8FbAyVfJ3OBFEcwaMmc8+lTI2NZUk0/bO2tA0=; b=clfvgUU53SwHbLUqgyISHsb1/sTUqH2CEzx6QnLVz1KOkiXTdHDakwRW1ZjZsk/rN+z5p6slrGSA1vmpBHWdE4qLj+l6mNrGS2nwT0UKvlaUZY4iGLfGe1Bdk9Wg22dBQ5Du4XOP0dVaVuNBBcSZ4MBhlC/n5CQYnH7nA5eeGCHxcNjQ1RD9gtNaEOAs+qt2Zdu1afkhOu44VfafREECaWAccosvSSqQ1jU658r4RrHHKbYyZmefTSwfhQWhpv+UVQp9UilpLPzK8QvZp1AGGBGcGGrNOqEz4wFhGwwlQxXEspo+glfJv2mRRTrWTukjSHTfyRJ0Zb6WWp9cZ4to+Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wFwS/G3JNKaI1BzslE7XofNbn4FfjP1rlVPGkYp+NqBnTfzP252cp8ibqJnjT604B7wVUqvZjLqy1bbFfLC1RhgST1tFBLgLRSfKLZncYk7ll4Ltd+X1iGEgIQHl2fU3t6/+AaMLPf/uDDKmSyVWgfLgdLlicAnqMtUB3b46nLM2G1QjOFV9071qaiQ6xFzLJyF4W5kgbAnlydCvq+t33aV+/aeOFn+/eAN5udQGUheRxNAOpEoMNasIt/es8sfBBrmGgfl9ooWihk0sA29N/u0sKt1qjdByHXjfeu5iAeIIwVt84b3D+ouySoanOqamhEDFKkmD8PQ+nttw0J5aOQ==
  • 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>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 19 Nov 2025 11:48:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Jürgen,

On 13.11.25 17:43, Jürgen Groß wrote:
On 13.11.25 16:32, Grygorii Strashko wrote:
Hi Jürgen,

On 13.11.25 16:46, Juergen Gross wrote:
On 13.11.25 15:39, Jürgen Groß wrote:
On 13.11.25 14:23, Jan Beulich wrote:
On 13.11.2025 14:18, Grygorii Strashko wrote:
On 13.11.25 14:30, Jan Beulich wrote:
On 11.11.2025 18:54, Grygorii Strashko wrote:
--- a/xen/arch/x86/hvm/hypercall.c
+++ b/xen/arch/x86/hvm/hypercall.c
@@ -29,10 +29,12 @@ long hvm_memory_op(unsigned long cmd, 
XEN_GUEST_HANDLE_PARAM(void) arg)
           return -ENOSYS;
       }
-    if ( !vcpu_is_hcall_compat(current) )
-        rc = do_memory_op(cmd, arg);
-    else
+#ifdef CONFIG_COMPAT
+    if ( vcpu_is_hcall_compat(current) )
           rc = compat_memory_op(cmd, arg);
+    else
+#endif
+        rc = do_memory_op(cmd, arg);

Why would this be needed when vcpu_is_hcall_compat() already honors 
CONFIG_COMPAT?
(Same question then applies elsewhere, of course.)

This I do not like by myself, but I was not able to find other options :(

hypercall-defs.h is autogenerated and it's the only one place where functions
declarations like do_x_op() are appeared or disappeared.
So build is failing without ifdefs as compiler can't find compat_memory_op()
declaration.

Oh, I see; I hadn't thought of that aspect. I wonder if we wouldn't better take
care of that in the machinery there. Cc-ing Jürgen, who did introduce this
originally. Maybe he has concrete arguments against us doing so.

No arguments against it.

You probably will need a new Prefix defined (e.g. compat_always) and set it via

#define PREFIX_compat_always compat

unconditionally. Then it should be possible to have

Prefix: compat_always
memory_op(...)

outside of #ifdefs and drop the memory_op() in the #ifdef CONFIG_COMPAT section.

Oh, this might be wrong, as this will break the PV32 memory_op() hypercall.

You need to keep the current memory_op() in the #ifdef CONFIG_COMPAT section
and move the compat_always stuff into an #else part of the CONFIG_COMPAT.


This should result in the compat_memory_op() prototype to be always available.
Having no related function should be no problem due to DCO in case CONFIG_COMPAT
isn't defined.

Smth like this, right?

diff --git a/xen/include/hypercall-defs.c b/xen/include/hypercall-defs.c
index 338d7afe3048..e85943320bd2 100644
--- a/xen/include/hypercall-defs.c
+++ b/xen/include/hypercall-defs.c
@@ -80,6 +80,8 @@ rettype: compat int
  #define PREFIX_compat
  #endif

+#define PREFIX_compat_always compat
+
  #ifdef CONFIG_ARM
  #define PREFIX_dep dep
  #define PREFIX_do_arm do_arm
@@ -156,6 +158,9 @@ platform_op(compat_platform_op_t *u_xenpf_op)
  #ifdef CONFIG_KEXEC
  kexec_op(unsigned int op, void *uarg)
  #endif
+#else
+prefix: PREFIX_compat_always

This should be:

+prefix: compat_always

Unfortunately, ^ is not working it generates
long compat_always_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) 
arg);

My version works "prefix: PREFIX_compat_always"

--
Best regards,
-grygorii




 


Rackspace

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