All of lore.kernel.org
 help / color / mirror / Atom feed
* [XEN][PATCH v2 1/4] x86: hvm: dm: factor out compat code under ifdefs
  2025-11-19 19:30 [XEN][PATCH v2 0/4] x86: pvh: allow to disable 32-bit (COMPAT) interface support Grygorii Strashko
@ 2025-11-19 19:30 ` Grygorii Strashko
  2025-11-19 19:30 ` [XEN][PATCH v2 3/4] x86: hvm: factor out COMPAT " Grygorii Strashko
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Grygorii Strashko @ 2025-11-19 19:30 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Grygorii Strashko, Jan Beulich, Andrew Cooper,
	Roger Pau Monné, Stefano Stabellini, Alejandro Vallejo,
	Jason Andryuk

From: Grygorii Strashko <grygorii_strashko@epam.com>

Factor out COMPAT HVM DM code under ifdefs in preparation for making HVM
COMPAT code optional.

Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
---
changes in v2:
 - no changes

 xen/arch/x86/hvm/dm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
index 3b53471af0d9..f6dd1634428a 100644
--- a/xen/arch/x86/hvm/dm.c
+++ b/xen/arch/x86/hvm/dm.c
@@ -623,6 +623,7 @@ int dm_op(const struct dmop_args *op_args)
     return rc;
 }
 
+#ifdef CONFIG_COMPAT
 #include <compat/hvm/dm_op.h>
 
 CHECK_dm_op_create_ioreq_server;
@@ -680,6 +681,7 @@ int compat_dm_op(
 
     return rc;
 }
+#endif /* CONFIG_COMPAT */
 
 /*
  * Local variables:
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [XEN][PATCH v2 0/4] x86: pvh: allow to disable 32-bit (COMPAT) interface support
@ 2025-11-19 19:30 Grygorii Strashko
  2025-11-19 19:30 ` [XEN][PATCH v2 1/4] x86: hvm: dm: factor out compat code under ifdefs Grygorii Strashko
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Grygorii Strashko @ 2025-11-19 19:30 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Grygorii Strashko, Jan Beulich, Andrew Cooper,
	Roger Pau Monné, Anthony PERARD, Michal Orzel, Julien Grall,
	Stefano Stabellini

From: Grygorii Strashko <grygorii_strashko@epam.com>

Hi

This series introduces possibility to disable 32-bit (COMPAT) interface support
in the following case:
      - Only PVH domains are used
      - Guests (OS) are started by using direct Direct Kernel Boot
      - Guests (OS) are 64-bit and Guest early boot code, which is running not
        in 64-bit mode, does not access Xen interfaces
        (hypercalls, shared_info, ..)

If above criterias are met the COMPAT HVM interface become unreachable and can be disabled.
Coverage reports analyze and adding guard (debug) exceptions in hvm_hypercall/hvm_do_multicall_call
and hvm_latch_shinfo_size() confirm that COMPAT HVM interface is unused for safety use-case.

Changes in v2 described in each patch:
- patch "x86: constify has_32bit_shinfo() if !CONFIG_COMPAT" squashed in patch 2.

v1:
 https://patchwork.kernel.org/project/xen-devel/cover/20251111175413.3540690-1-grygorii_strashko@epam.com/

Grygorii Strashko (4):
  x86: hvm: dm: factor out compat code under ifdefs
  x86: hvm: compat: introduce is_hcall_compat() helper
  x86: hvm: factor out COMPAT code under ifdefs
  x86: pvh: allow to disable 32-bit interface support

 xen/arch/x86/hvm/Kconfig          | 19 ++++++++++++++++++-
 xen/arch/x86/hvm/dm.c             |  2 ++
 xen/arch/x86/hvm/hvm.c            | 24 ++++++++++++++++++++----
 xen/arch/x86/hvm/hypercall.c      | 22 +++++++++++++++++-----
 xen/arch/x86/hypercall.c          |  6 +-----
 xen/arch/x86/include/asm/domain.h |  9 +++++++--
 xen/common/kernel.c               |  2 +-
 xen/include/hypercall-defs.c      |  9 +++++++--
 xen/include/xen/sched.h           |  9 +++++++++
 9 files changed, 82 insertions(+), 20 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [XEN][PATCH v2 3/4] x86: hvm: factor out COMPAT code under ifdefs
  2025-11-19 19:30 [XEN][PATCH v2 0/4] x86: pvh: allow to disable 32-bit (COMPAT) interface support Grygorii Strashko
  2025-11-19 19:30 ` [XEN][PATCH v2 1/4] x86: hvm: dm: factor out compat code under ifdefs Grygorii Strashko
@ 2025-11-19 19:30 ` Grygorii Strashko
  2025-12-02 19:26   ` Jason Andryuk
  2025-12-04 18:47   ` Grygorii Strashko
  2025-11-19 19:30 ` [XEN][PATCH v2 2/4] x86: hvm: compat: introduce is_hcall_compat() helper Grygorii Strashko
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 14+ messages in thread
From: Grygorii Strashko @ 2025-11-19 19:30 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Grygorii Strashko, Jan Beulich, Andrew Cooper,
	Roger Pau Monné, Anthony PERARD, Michal Orzel, Julien Grall,
	Stefano Stabellini, Alejandro Vallejo, Jason Andryuk,
	Jürgen Groß

From: Grygorii Strashko <grygorii_strashko@epam.com>

Factor out COMPAT HVM code under ifdefs in preparation for making HVM
COMPAT code optional.

- hypercall-defs.c updated to always provide compat declaration for:
physdev_op, grant_table_op, grant_table_op. This reduces number of COMPAT
ifdefs in HVM code and lets compiler DCE do the job.

- Only 64-bit shinfo is supported with COMPAT=n, so struct
arch_domain->has_32bit_shinfo field is moved under COMPAT ifdef and
has_32bit_shinfo() is updated to account for COMPAT=n.

Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
---
changes in v2:
- update hypercall-defs.c to always provide compat declaration for:
  physdev_op, grant_table_op, grant_table_op
- move struct arch_domain->has_32bit_shinfo is moved under COMPAT ifdef
- return hvm_hypercall()
- use ASSERT_UNREACHABLE() in hvm_do_multicall_call()
- constify has_32bit_shinfo() for COMPAT=n

 xen/arch/x86/hvm/hvm.c            | 16 ++++++++++++++++
 xen/arch/x86/hvm/hypercall.c      | 13 +++++++++++++
 xen/arch/x86/include/asm/domain.h |  9 +++++++--
 xen/include/hypercall-defs.c      |  9 +++++++--
 4 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 0fd3f95b6e0e..19524cb7a914 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -69,7 +69,9 @@
 #include <public/version.h>
 #include <public/vm_event.h>
 
+#ifdef CONFIG_COMPAT
 #include <compat/hvm/hvm_op.h>
+#endif
 
 bool __read_mostly hvm_enabled;
 
@@ -1255,6 +1257,7 @@ static int cf_check hvm_save_cpu_xsave_states(
     return 0;
 }
 
+#ifdef CONFIG_COMPAT
 /*
  * Structure layout conformity checks, documenting correctness of the cast in
  * the invocation of validate_xstate() below.
@@ -1267,6 +1270,7 @@ CHECK_FIELD_(struct, xsave_hdr, xcomp_bv);
 CHECK_FIELD_(struct, xsave_hdr, reserved);
 #undef compat_xsave_hdr
 #undef xen_xsave_hdr
+#endif /* CONFIG_COMPAT */
 
 static int cf_check hvm_load_cpu_xsave_states(
     struct domain *d, hvm_domain_context_t *h)
@@ -3991,8 +3995,14 @@ static void hvm_latch_shinfo_size(struct domain *d)
      */
     if ( current->domain == d )
     {
+#ifdef CONFIG_COMPAT
+        /*
+         * Only 64-bit shinfo is supported when COMPAT 32-bit hypercalls
+         * interface is disabled
+         */
         d->arch.has_32bit_shinfo =
             hvm_guest_x86_mode(current) != X86_MODE_64BIT;
+#endif
 
         /*
          * Make sure that the timebase in the shared info structure is correct.
@@ -4965,6 +4975,7 @@ static int do_altp2m_op(
 #endif /* CONFIG_ALTP2M */
 }
 
+#ifdef CONFIG_COMPAT
 DEFINE_XEN_GUEST_HANDLE(compat_hvm_altp2m_op_t);
 
 /*
@@ -4992,10 +5003,12 @@ DEFINE_XEN_GUEST_HANDLE(compat_hvm_altp2m_op_t);
 
 CHECK_hvm_altp2m_op;
 CHECK_hvm_altp2m_set_mem_access_multi;
+#endif /* CONFIG_COMPAT */
 
 static int compat_altp2m_op(
     XEN_GUEST_HANDLE_PARAM(void) arg)
 {
+#ifdef CONFIG_COMPAT
     int rc = 0;
     struct compat_hvm_altp2m_op a;
     union
@@ -5063,6 +5076,9 @@ static int compat_altp2m_op(
     }
 
     return rc;
+#else
+    return -EOPNOTSUPP;
+#endif /* CONFIG_COMPAT */
 }
 
 static int hvmop_get_mem_type(
diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c
index 52cae1d15312..1ee0193b69af 100644
--- a/xen/arch/x86/hvm/hypercall.c
+++ b/xen/arch/x86/hvm/hypercall.c
@@ -170,6 +170,7 @@ int hvm_hypercall(struct cpu_user_regs *regs)
         HVM_DBG_LOG(DBG_LEVEL_HCALL, "hcall%lu(%x, %x, %x, %x, %x)", eax,
                     regs->ebx, regs->ecx, regs->edx, regs->esi, regs->edi);
 
+#ifdef CONFIG_COMPAT
         curr->hcall_compat = true;
         call_handlers_hvm32(eax, regs->eax, regs->ebx, regs->ecx, regs->edx,
                             regs->esi, regs->edi);
@@ -177,6 +178,9 @@ int hvm_hypercall(struct cpu_user_regs *regs)
 
         if ( !curr->hcall_preempted && regs->eax != -ENOSYS )
             clobber_regs(regs, eax, hvm, 32);
+#else
+        regs->eax = -ENOSYS;
+#endif
     }
 
     hvmemul_cache_restore(curr, token);
@@ -207,10 +211,19 @@ enum mc_disposition hvm_do_multicall_call(struct mc_state *state)
     }
     else
     {
+#ifdef CONFIG_COMPAT
         struct compat_multicall_entry *call = &state->compat_call;
 
         call_handlers_hvm32(call->op, call->result, call->args[0], call->args[1],
                             call->args[2], call->args[3], call->args[4]);
+#else
+        /*
+         * code should never reach here in case !CONFIG_COMPAT as any
+         * 32-bit hypercall should bail out earlier from hvm_hypercall()
+         * with -EOPNOTSUPP
+         */
+        ASSERT_UNREACHABLE();
+#endif
     }
 
     return !hvm_get_cpl(curr) ? mc_continue : mc_preempt;
diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h
index 5df8c7825333..0005f4450931 100644
--- a/xen/arch/x86/include/asm/domain.h
+++ b/xen/arch/x86/include/asm/domain.h
@@ -12,8 +12,11 @@
 #include <public/vcpu.h>
 #include <public/hvm/hvm_info_table.h>
 
-#define has_32bit_shinfo(d)    ((d)->arch.has_32bit_shinfo)
-
+#ifdef CONFIG_COMPAT
+#define has_32bit_shinfo(d) ((d)->arch.has_32bit_shinfo)
+#else
+#define has_32bit_shinfo(d) ((void)(d), false)
+#endif
 /*
  * Set to true if either the global vector-type callback or per-vCPU
  * LAPIC vectors are used. Assume all vCPUs will use
@@ -365,8 +368,10 @@ struct arch_domain
     /* NB. protected by d->event_lock and by irq_desc[irq].lock */
     struct radix_tree_root irq_pirq;
 
+#ifdef CONFIG_COMPAT
     /* Is shared-info page in 32-bit format? */
     bool has_32bit_shinfo;
+#endif
 
     /* Is PHYSDEVOP_eoi to automatically unmask the event channel? */
     bool auto_unmask;
diff --git a/xen/include/hypercall-defs.c b/xen/include/hypercall-defs.c
index cef08eeec1b8..08c01153ac56 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
@@ -104,10 +106,10 @@ defhandle: trap_info_compat_t
 defhandle: physdev_op_compat_t
 #endif
 
-prefix: do PREFIX_hvm PREFIX_compat PREFIX_do_arm
+prefix: do PREFIX_hvm PREFIX_compat_always PREFIX_do_arm
 physdev_op(int cmd, void *arg)
 
-prefix: do PREFIX_hvm PREFIX_compat
+prefix: do PREFIX_hvm PREFIX_compat_always
 #if defined(CONFIG_GRANT_TABLE) || defined(CONFIG_PV_SHIM)
 grant_table_op(unsigned int cmd, void *uop, unsigned int count)
 #endif
@@ -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 /* CONFIG_COMPAT */
+prefix: PREFIX_compat_always
+memory_op(unsigned int cmd, void *arg)
 #endif /* CONFIG_COMPAT */
 
 #if defined(CONFIG_PV) || defined(CONFIG_ARM)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [XEN][PATCH v2 2/4] x86: hvm: compat: introduce is_hcall_compat() helper
  2025-11-19 19:30 [XEN][PATCH v2 0/4] x86: pvh: allow to disable 32-bit (COMPAT) interface support Grygorii Strashko
  2025-11-19 19:30 ` [XEN][PATCH v2 1/4] x86: hvm: dm: factor out compat code under ifdefs Grygorii Strashko
  2025-11-19 19:30 ` [XEN][PATCH v2 3/4] x86: hvm: factor out COMPAT " Grygorii Strashko
@ 2025-11-19 19:30 ` Grygorii Strashko
  2025-12-02 18:41   ` Jason Andryuk
  2025-11-19 19:30 ` [XEN][PATCH v2 4/4] x86: pvh: allow to disable 32-bit interface support Grygorii Strashko
  2025-12-18 16:20 ` [XEN][PATCH v2 0/4] x86: pvh: allow to disable 32-bit (COMPAT) " Grygorii Strashko
  4 siblings, 1 reply; 14+ messages in thread
From: Grygorii Strashko @ 2025-11-19 19:30 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Grygorii Strashko, Jan Beulich, Andrew Cooper,
	Roger Pau Monné, Anthony PERARD, Michal Orzel, Julien Grall,
	Stefano Stabellini, Alejandro Vallejo, Jason Andryuk

From: Grygorii Strashko <grygorii_strashko@epam.com>

Introduce is_hcall_compat() helper and use it instead of direct access to
struct vcpu->hcall_compat field in preparation for making HVM COMPAT code
optional. The vcpu->hcall_compat field is under CONFIG_COMPAT ifdefs
already.

Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
---
changes in v2:
- change to bool is_hcall_compat(void)

 xen/arch/x86/hvm/hvm.c       | 8 ++++----
 xen/arch/x86/hvm/hypercall.c | 9 ++++-----
 xen/arch/x86/hypercall.c     | 6 +-----
 xen/common/kernel.c          | 2 +-
 xen/include/xen/sched.h      | 9 +++++++++
 5 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 0ff242d4a0d6..0fd3f95b6e0e 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3500,7 +3500,7 @@ unsigned int copy_to_user_hvm(void *to, const void *from, unsigned int len)
 {
     int rc;
 
-    if ( current->hcall_compat && is_compat_arg_xlat_range(to, len) )
+    if ( is_hcall_compat() && is_compat_arg_xlat_range(to, len) )
     {
         memcpy(to, from, len);
         return 0;
@@ -3514,7 +3514,7 @@ unsigned int clear_user_hvm(void *to, unsigned int len)
 {
     int rc;
 
-    if ( current->hcall_compat && is_compat_arg_xlat_range(to, len) )
+    if ( is_hcall_compat() && is_compat_arg_xlat_range(to, len) )
     {
         memset(to, 0x00, len);
         return 0;
@@ -3529,7 +3529,7 @@ unsigned int copy_from_user_hvm(void *to, const void *from, unsigned int len)
 {
     int rc;
 
-    if ( current->hcall_compat && is_compat_arg_xlat_range(from, len) )
+    if ( is_hcall_compat() && is_compat_arg_xlat_range(from, len) )
     {
         memcpy(to, from, len);
         return 0;
@@ -5214,7 +5214,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
 
     case HVMOP_altp2m:
-        rc = current->hcall_compat ? compat_altp2m_op(arg) : do_altp2m_op(arg);
+        rc = is_hcall_compat() ? compat_altp2m_op(arg) : do_altp2m_op(arg);
         break;
 
     default:
diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c
index b254b3e2f7d6..52cae1d15312 100644
--- a/xen/arch/x86/hvm/hypercall.c
+++ b/xen/arch/x86/hvm/hypercall.c
@@ -29,7 +29,7 @@ long hvm_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         return -ENOSYS;
     }
 
-    if ( !current->hcall_compat )
+    if ( !is_hcall_compat() )
         rc = do_memory_op(cmd, arg);
     else
         rc = compat_memory_op(cmd, arg);
@@ -57,7 +57,7 @@ long hvm_grant_table_op(
         return -ENOSYS;
     }
 
-    if ( !current->hcall_compat )
+    if ( !is_hcall_compat() )
         return do_grant_table_op(cmd, uop, count);
     else
         return compat_grant_table_op(cmd, uop, count);
@@ -66,8 +66,7 @@ long hvm_grant_table_op(
 
 long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
 {
-    const struct vcpu *curr = current;
-    const struct domain *currd = curr->domain;
+    const struct domain *currd = current->domain;
 
     switch ( cmd )
     {
@@ -96,7 +95,7 @@ long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         return -ENOSYS;
     }
 
-    if ( !curr->hcall_compat )
+    if ( !is_hcall_compat() )
         return do_physdev_op(cmd, arg);
     else
         return compat_physdev_op(cmd, arg);
diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c
index dc0a90ca0915..5d1ac906fd37 100644
--- a/xen/arch/x86/hypercall.c
+++ b/xen/arch/x86/hypercall.c
@@ -53,11 +53,7 @@ unsigned long hypercall_create_continuation(
 
         regs->rax = op;
 
-#ifdef CONFIG_COMPAT
-        if ( !curr->hcall_compat )
-#else
-        if ( true )
-#endif
+        if ( !is_hcall_compat() )
         {
             for ( i = 0; *p != '\0'; i++ )
             {
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index e6979352e100..3ff06e315f57 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -615,7 +615,7 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         const struct vcpu *curr = current;
 
 #ifdef CONFIG_COMPAT
-        if ( curr->hcall_compat )
+        if ( is_hcall_compat() )
         {
             compat_platform_parameters_t params = {
                 .virt_start = is_pv_vcpu(curr)
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 02bdc256ce37..ed6fdeeda9f9 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -311,6 +311,15 @@ struct vcpu
 #endif
 };
 
+static inline bool is_hcall_compat(void)
+{
+#ifdef CONFIG_COMPAT
+    return current->hcall_compat;
+#else
+    return false;
+#endif /* CONFIG_COMPAT */
+}
+
 struct sched_unit {
     struct domain         *domain;
     struct vcpu           *vcpu_list;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [XEN][PATCH v2 4/4] x86: pvh: allow to disable 32-bit interface support
  2025-11-19 19:30 [XEN][PATCH v2 0/4] x86: pvh: allow to disable 32-bit (COMPAT) interface support Grygorii Strashko
                   ` (2 preceding siblings ...)
  2025-11-19 19:30 ` [XEN][PATCH v2 2/4] x86: hvm: compat: introduce is_hcall_compat() helper Grygorii Strashko
@ 2025-11-19 19:30 ` Grygorii Strashko
  2025-12-02 19:56   ` Jason Andryuk
  2025-12-18 16:20 ` [XEN][PATCH v2 0/4] x86: pvh: allow to disable 32-bit (COMPAT) " Grygorii Strashko
  4 siblings, 1 reply; 14+ messages in thread
From: Grygorii Strashko @ 2025-11-19 19:30 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Grygorii Strashko, Jan Beulich, Andrew Cooper,
	Roger Pau Monné, Stefano Stabellini, Alejandro Vallejo,
	Jason Andryuk

From: Grygorii Strashko <grygorii_strashko@epam.com>

For x86 Xen safety certification only PVH Gusts are selected to be allowed
which are started by using direct Direct Kernel Boot only. There is also an
assumption that x86 Guest's (OS) early boot code (which is running not in
64-bit mode) does not access Xen interfaces (hypercalls, shared_info, ..).

In this case the Xen HVM 32-bit COMPAT interface become unused and leaves
gaps in terms of coverage.

Hence now all prerequisite changes are in place, introduce a
CONFIG_HVM_COMPAT option through which HVM(PVH) 32-bit interface support on
64-bit Xen can be disabled.

By default, CONFIG_HVM_COMPAT is ("y") enabled and accessible only in
EXPERT mode.

Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
---
changes in v2:
- fix format and move above HVM_FEP

 xen/arch/x86/hvm/Kconfig | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/Kconfig b/xen/arch/x86/hvm/Kconfig
index c323d767e77c..88090f5b3965 100644
--- a/xen/arch/x86/hvm/Kconfig
+++ b/xen/arch/x86/hvm/Kconfig
@@ -2,7 +2,6 @@ menuconfig HVM
 	bool "HVM support"
 	depends on !PV_SHIM_EXCLUSIVE
 	default !PV_SHIM
-	select COMPAT
 	select IOREQ_SERVER
 	select MEM_ACCESS_ALWAYS_ON
 	help
@@ -35,6 +34,24 @@ config INTEL_VMX
 	  If your system includes a processor with Intel VT-x support, say Y.
 	  If in doubt, say Y.
 
+config HVM_COMPAT
+	bool "HVM 32-bit hypercalls interface support" if EXPERT
+	select COMPAT
+	default y
+	help
+	  The HVM 32-bit interface must be enabled for HVM domains to be able to
+	  make hypercalls in 32bit mode. Non-PVH domains unconditionally need this
+	  option so that hvmloader may issue hypercalls in 32bit mode.
+
+	  The HVM 32-bit interface can be disabled if:
+	  - Only PVH domains are used
+	  - Guests (OS) are started by using direct Direct Kernel Boot
+	  - Guests (OS) are 64-bit and Guest early boot code, which is running not
+	    in 64-bit mode, does not access Xen interfaces
+	    (hypercalls, shared_info, ..)
+
+	  If unsure, say Y.
+
 config HVM_FEP
 	bool "HVM Forced Emulation Prefix support (UNSUPPORTED)" if UNSUPPORTED
 	default DEBUG
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [XEN][PATCH v2 2/4] x86: hvm: compat: introduce is_hcall_compat() helper
  2025-11-19 19:30 ` [XEN][PATCH v2 2/4] x86: hvm: compat: introduce is_hcall_compat() helper Grygorii Strashko
@ 2025-12-02 18:41   ` Jason Andryuk
  0 siblings, 0 replies; 14+ messages in thread
From: Jason Andryuk @ 2025-12-02 18:41 UTC (permalink / raw)
  To: Grygorii Strashko, xen-devel@lists.xenproject.org
  Cc: Jan Beulich, Andrew Cooper, Roger Pau Monné, Anthony PERARD,
	Michal Orzel, Julien Grall, Stefano Stabellini, Alejandro Vallejo

On 2025-11-19 14:30, Grygorii Strashko wrote:
> From: Grygorii Strashko <grygorii_strashko@epam.com>
> 
> Introduce is_hcall_compat() helper and use it instead of direct access to
> struct vcpu->hcall_compat field in preparation for making HVM COMPAT code
> optional. The vcpu->hcall_compat field is under CONFIG_COMPAT ifdefs
> already.
> 
> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>

> diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
> index 02bdc256ce37..ed6fdeeda9f9 100644
> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -311,6 +311,15 @@ struct vcpu
>   #endif
>   };
>   
> +static inline bool is_hcall_compat(void)
> +{
> +#ifdef CONFIG_COMPAT
> +    return current->hcall_compat;
> +#else
> +    return false;
> +#endif /* CONFIG_COMPAT */
> +}
> +

is_hcall_compat() matches the hcall_compat field, so I am okay with this.

Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>

However, is_compat_hcall() might be a slightly better name for the 
helper.  For me at least, I think of these as "compat hypercalls", so 
that ordering reads a little more naturally for me.  It's not a big 
deal, but I figured I'd mention it in case others have an opinion.

Thanks,
Jason


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [XEN][PATCH v2 3/4] x86: hvm: factor out COMPAT code under ifdefs
  2025-11-19 19:30 ` [XEN][PATCH v2 3/4] x86: hvm: factor out COMPAT " Grygorii Strashko
@ 2025-12-02 19:26   ` Jason Andryuk
  2025-12-04 18:39     ` Grygorii Strashko
  2025-12-04 18:47   ` Grygorii Strashko
  1 sibling, 1 reply; 14+ messages in thread
From: Jason Andryuk @ 2025-12-02 19:26 UTC (permalink / raw)
  To: Grygorii Strashko, xen-devel@lists.xenproject.org
  Cc: Jan Beulich, Andrew Cooper, Roger Pau Monné, Anthony PERARD,
	Michal Orzel, Julien Grall, Stefano Stabellini, Alejandro Vallejo,
	Jürgen Groß

On 2025-11-19 14:30, Grygorii Strashko wrote:
> From: Grygorii Strashko <grygorii_strashko@epam.com>
> 
> Factor out COMPAT HVM code under ifdefs in preparation for making HVM
> COMPAT code optional.
> 
> - hypercall-defs.c updated to always provide compat declaration for:
> physdev_op, grant_table_op, grant_table_op. This reduces number of COMPAT
> ifdefs in HVM code and lets compiler DCE do the job.
> 
> - Only 64-bit shinfo is supported with COMPAT=n, so struct
> arch_domain->has_32bit_shinfo field is moved under COMPAT ifdef and
> has_32bit_shinfo() is updated to account for COMPAT=n.
> 
> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>

> diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h
> index 5df8c7825333..0005f4450931 100644
> --- a/xen/arch/x86/include/asm/domain.h
> +++ b/xen/arch/x86/include/asm/domain.h
> @@ -12,8 +12,11 @@
>   #include <public/vcpu.h>
>   #include <public/hvm/hvm_info_table.h>
>   
> -#define has_32bit_shinfo(d)    ((d)->arch.has_32bit_shinfo)
> -
> +#ifdef CONFIG_COMPAT
> +#define has_32bit_shinfo(d) ((d)->arch.has_32bit_shinfo)
> +#else
> +#define has_32bit_shinfo(d) ((void)(d), false)

(void)(d) is to avoid an any potential unreferenced 'd' messages?

Just using false builds for me, but your way is a little more robust.

> +#endif
>   /*
>    * Set to true if either the global vector-type callback or per-vCPU
>    * LAPIC vectors are used. Assume all vCPUs will use
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>

Regards,
Jason


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [XEN][PATCH v2 4/4] x86: pvh: allow to disable 32-bit interface support
  2025-11-19 19:30 ` [XEN][PATCH v2 4/4] x86: pvh: allow to disable 32-bit interface support Grygorii Strashko
@ 2025-12-02 19:56   ` Jason Andryuk
  0 siblings, 0 replies; 14+ messages in thread
From: Jason Andryuk @ 2025-12-02 19:56 UTC (permalink / raw)
  To: Grygorii Strashko, xen-devel@lists.xenproject.org
  Cc: Jan Beulich, Andrew Cooper, Roger Pau Monné,
	Stefano Stabellini, Alejandro Vallejo

On 2025-11-19 14:30, Grygorii Strashko wrote:
> From: Grygorii Strashko <grygorii_strashko@epam.com>
> 
> For x86 Xen safety certification only PVH Gusts are selected to be allowed

s/Gusts/Guests/

> which are started by using direct Direct Kernel Boot only. There is also an

s/direct Direct/direct/

> assumption that x86 Guest's (OS) early boot code (which is running not in
> 64-bit mode) does not access Xen interfaces (hypercalls, shared_info, ..).
> 
> In this case the Xen HVM 32-bit COMPAT interface become unused and leaves
> gaps in terms of coverage.
> 
> Hence now all prerequisite changes are in place, introduce a
> CONFIG_HVM_COMPAT option through which HVM(PVH) 32-bit interface support on
> 64-bit Xen can be disabled.
> 
> By default, CONFIG_HVM_COMPAT is ("y") enabled and accessible only in
> EXPERT mode.
> 
> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
> ---
> changes in v2:
> - fix format and move above HVM_FEP
> 
>   xen/arch/x86/hvm/Kconfig | 19 ++++++++++++++++++-
>   1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/x86/hvm/Kconfig b/xen/arch/x86/hvm/Kconfig
> index c323d767e77c..88090f5b3965 100644
> --- a/xen/arch/x86/hvm/Kconfig
> +++ b/xen/arch/x86/hvm/Kconfig
> @@ -2,7 +2,6 @@ menuconfig HVM
>   	bool "HVM support"
>   	depends on !PV_SHIM_EXCLUSIVE
>   	default !PV_SHIM
> -	select COMPAT
>   	select IOREQ_SERVER
>   	select MEM_ACCESS_ALWAYS_ON
>   	help
> @@ -35,6 +34,24 @@ config INTEL_VMX
>   	  If your system includes a processor with Intel VT-x support, say Y.
>   	  If in doubt, say Y.
>   
> +config HVM_COMPAT
> +	bool "HVM 32-bit hypercalls interface support" if EXPERT

Maybe "HVM 32-bit compat hypercall support" to get "compat" in the 
user-visible text?

> +	select COMPAT
> +	default y
> +	help
> +	  The HVM 32-bit interface must be enabled for HVM domains to be able to
> +	  make hypercalls in 32bit mode. Non-PVH domains unconditionally need this
> +	  option so that hvmloader may issue hypercalls in 32bit mode.
> +
> +	  The HVM 32-bit interface can be disabled if:
> +	  - Only PVH domains are used
> +	  - Guests (OS) are started by using direct Direct Kernel Boot
> +	  - Guests (OS) are 64-bit and Guest early boot code, which is running not
> +	    in 64-bit mode, does not access Xen interfaces
> +	    (hypercalls, shared_info, ..)
> +
> +	  If unsure, say Y.
> +

Maybe something like:
"""
Support HVM hypercalls from 32-bit code.  Hypercalls from 64-bit code 
are always supported.

Disabling 32-bit compat hypercalls reduces the hypervisor binary size. 
HVM guests require the 32-bit hvmloader, so they cannot run with this 
disabled.  i.e. Xen will only run 64-bit PVH guests with this disabled.

If unsure, say Y.
"""

While what you wrote is correct, I tried to rephrase to highlight the 
the implications.

Regards,
Jason

>   config HVM_FEP
>   	bool "HVM Forced Emulation Prefix support (UNSUPPORTED)" if UNSUPPORTED
>   	default DEBUG



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [XEN][PATCH v2 3/4] x86: hvm: factor out COMPAT code under ifdefs
  2025-12-02 19:26   ` Jason Andryuk
@ 2025-12-04 18:39     ` Grygorii Strashko
  0 siblings, 0 replies; 14+ messages in thread
From: Grygorii Strashko @ 2025-12-04 18:39 UTC (permalink / raw)
  To: Jason Andryuk, xen-devel@lists.xenproject.org, Andrew Cooper
  Cc: Jan Beulich, Andrew Cooper, Roger Pau Monné, Anthony PERARD,
	Michal Orzel, Julien Grall, Stefano Stabellini, Alejandro Vallejo,
	Jürgen Groß



On 02.12.25 21:26, Jason Andryuk wrote:
> On 2025-11-19 14:30, Grygorii Strashko wrote:
>> From: Grygorii Strashko <grygorii_strashko@epam.com>
>>
>> Factor out COMPAT HVM code under ifdefs in preparation for making HVM
>> COMPAT code optional.
>>
>> - hypercall-defs.c updated to always provide compat declaration for:
>> physdev_op, grant_table_op, grant_table_op. This reduces number of COMPAT
>> ifdefs in HVM code and lets compiler DCE do the job.
>>
>> - Only 64-bit shinfo is supported with COMPAT=n, so struct
>> arch_domain->has_32bit_shinfo field is moved under COMPAT ifdef and
>> has_32bit_shinfo() is updated to account for COMPAT=n.
>>
>> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
> 
>> diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h
>> index 5df8c7825333..0005f4450931 100644
>> --- a/xen/arch/x86/include/asm/domain.h
>> +++ b/xen/arch/x86/include/asm/domain.h
>> @@ -12,8 +12,11 @@
>>   #include <public/vcpu.h>
>>   #include <public/hvm/hvm_info_table.h>
>> -#define has_32bit_shinfo(d)    ((d)->arch.has_32bit_shinfo)
>> -
>> +#ifdef CONFIG_COMPAT
>> +#define has_32bit_shinfo(d) ((d)->arch.has_32bit_shinfo)
>> +#else
>> +#define has_32bit_shinfo(d) ((void)(d), false)
> 
> (void)(d) is to avoid an any potential unreferenced 'd' messages?

It's a generic request to have macro arguments evaluated consistently.

> 
> Just using false builds for me, but your way is a little more robust.
> 
>> +#endif
>>   /*
>>    * Set to true if either the global vector-type callback or per-vCPU
>>    * LAPIC vectors are used. Assume all vCPUs will use
> Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
> 
> Regards,
> Jason

-- 
Best regards,
-grygorii



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [XEN][PATCH v2 3/4] x86: hvm: factor out COMPAT code under ifdefs
  2025-11-19 19:30 ` [XEN][PATCH v2 3/4] x86: hvm: factor out COMPAT " Grygorii Strashko
  2025-12-02 19:26   ` Jason Andryuk
@ 2025-12-04 18:47   ` Grygorii Strashko
  2025-12-18 16:47     ` Jürgen Groß
  1 sibling, 1 reply; 14+ messages in thread
From: Grygorii Strashko @ 2025-12-04 18:47 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org, Jürgen Groß,
	Juergen Gross
  Cc: Jan Beulich, Andrew Cooper, Roger Pau Monné, Anthony PERARD,
	Michal Orzel, Julien Grall, Stefano Stabellini, Alejandro Vallejo,
	Jason Andryuk

Hi Jürgen,

Would it be possible for you to take a look at hypercall-defs.c changes?

On 19.11.25 21:30, Grygorii Strashko wrote:
> From: Grygorii Strashko <grygorii_strashko@epam.com>
> 
> Factor out COMPAT HVM code under ifdefs in preparation for making HVM
> COMPAT code optional.
> 
> - hypercall-defs.c updated to always provide compat declaration for:
> physdev_op, grant_table_op, grant_table_op. This reduces number of COMPAT
> ifdefs in HVM code and lets compiler DCE do the job.
> 
> - Only 64-bit shinfo is supported with COMPAT=n, so struct
> arch_domain->has_32bit_shinfo field is moved under COMPAT ifdef and
> has_32bit_shinfo() is updated to account for COMPAT=n.
> 
> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
> ---
> changes in v2:
> - update hypercall-defs.c to always provide compat declaration for:
>    physdev_op, grant_table_op, grant_table_op
> - move struct arch_domain->has_32bit_shinfo is moved under COMPAT ifdef
> - return hvm_hypercall()
> - use ASSERT_UNREACHABLE() in hvm_do_multicall_call()
> - constify has_32bit_shinfo() for COMPAT=n
> 
>   xen/arch/x86/hvm/hvm.c            | 16 ++++++++++++++++
>   xen/arch/x86/hvm/hypercall.c      | 13 +++++++++++++
>   xen/arch/x86/include/asm/domain.h |  9 +++++++--
>   xen/include/hypercall-defs.c      |  9 +++++++--
>   4 files changed, 43 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index 0fd3f95b6e0e..19524cb7a914 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -69,7 +69,9 @@
>   #include <public/version.h>
>   #include <public/vm_event.h>
>   
> +#ifdef CONFIG_COMPAT
>   #include <compat/hvm/hvm_op.h>
> +#endif
>   
>   bool __read_mostly hvm_enabled;
>   
> @@ -1255,6 +1257,7 @@ static int cf_check hvm_save_cpu_xsave_states(
>       return 0;
>   }
>   
> +#ifdef CONFIG_COMPAT
>   /*
>    * Structure layout conformity checks, documenting correctness of the cast in
>    * the invocation of validate_xstate() below.
> @@ -1267,6 +1270,7 @@ CHECK_FIELD_(struct, xsave_hdr, xcomp_bv);
>   CHECK_FIELD_(struct, xsave_hdr, reserved);
>   #undef compat_xsave_hdr
>   #undef xen_xsave_hdr
> +#endif /* CONFIG_COMPAT */
>   
>   static int cf_check hvm_load_cpu_xsave_states(
>       struct domain *d, hvm_domain_context_t *h)
> @@ -3991,8 +3995,14 @@ static void hvm_latch_shinfo_size(struct domain *d)
>        */
>       if ( current->domain == d )
>       {
> +#ifdef CONFIG_COMPAT
> +        /*
> +         * Only 64-bit shinfo is supported when COMPAT 32-bit hypercalls
> +         * interface is disabled
> +         */
>           d->arch.has_32bit_shinfo =
>               hvm_guest_x86_mode(current) != X86_MODE_64BIT;
> +#endif
>   
>           /*
>            * Make sure that the timebase in the shared info structure is correct.
> @@ -4965,6 +4975,7 @@ static int do_altp2m_op(
>   #endif /* CONFIG_ALTP2M */
>   }
>   
> +#ifdef CONFIG_COMPAT
>   DEFINE_XEN_GUEST_HANDLE(compat_hvm_altp2m_op_t);
>   
>   /*
> @@ -4992,10 +5003,12 @@ DEFINE_XEN_GUEST_HANDLE(compat_hvm_altp2m_op_t);
>   
>   CHECK_hvm_altp2m_op;
>   CHECK_hvm_altp2m_set_mem_access_multi;
> +#endif /* CONFIG_COMPAT */
>   
>   static int compat_altp2m_op(
>       XEN_GUEST_HANDLE_PARAM(void) arg)
>   {
> +#ifdef CONFIG_COMPAT
>       int rc = 0;
>       struct compat_hvm_altp2m_op a;
>       union
> @@ -5063,6 +5076,9 @@ static int compat_altp2m_op(
>       }
>   
>       return rc;
> +#else
> +    return -EOPNOTSUPP;
> +#endif /* CONFIG_COMPAT */
>   }
>   
>   static int hvmop_get_mem_type(
> diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c
> index 52cae1d15312..1ee0193b69af 100644
> --- a/xen/arch/x86/hvm/hypercall.c
> +++ b/xen/arch/x86/hvm/hypercall.c
> @@ -170,6 +170,7 @@ int hvm_hypercall(struct cpu_user_regs *regs)
>           HVM_DBG_LOG(DBG_LEVEL_HCALL, "hcall%lu(%x, %x, %x, %x, %x)", eax,
>                       regs->ebx, regs->ecx, regs->edx, regs->esi, regs->edi);
>   
> +#ifdef CONFIG_COMPAT
>           curr->hcall_compat = true;
>           call_handlers_hvm32(eax, regs->eax, regs->ebx, regs->ecx, regs->edx,
>                               regs->esi, regs->edi);
> @@ -177,6 +178,9 @@ int hvm_hypercall(struct cpu_user_regs *regs)
>   
>           if ( !curr->hcall_preempted && regs->eax != -ENOSYS )
>               clobber_regs(regs, eax, hvm, 32);
> +#else
> +        regs->eax = -ENOSYS;
> +#endif
>       }
>   
>       hvmemul_cache_restore(curr, token);
> @@ -207,10 +211,19 @@ enum mc_disposition hvm_do_multicall_call(struct mc_state *state)
>       }
>       else
>       {
> +#ifdef CONFIG_COMPAT
>           struct compat_multicall_entry *call = &state->compat_call;
>   
>           call_handlers_hvm32(call->op, call->result, call->args[0], call->args[1],
>                               call->args[2], call->args[3], call->args[4]);
> +#else
> +        /*
> +         * code should never reach here in case !CONFIG_COMPAT as any
> +         * 32-bit hypercall should bail out earlier from hvm_hypercall()
> +         * with -EOPNOTSUPP
> +         */
> +        ASSERT_UNREACHABLE();
> +#endif
>       }
>   
>       return !hvm_get_cpl(curr) ? mc_continue : mc_preempt;
> diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h
> index 5df8c7825333..0005f4450931 100644
> --- a/xen/arch/x86/include/asm/domain.h
> +++ b/xen/arch/x86/include/asm/domain.h
> @@ -12,8 +12,11 @@
>   #include <public/vcpu.h>
>   #include <public/hvm/hvm_info_table.h>
>   
> -#define has_32bit_shinfo(d)    ((d)->arch.has_32bit_shinfo)
> -
> +#ifdef CONFIG_COMPAT
> +#define has_32bit_shinfo(d) ((d)->arch.has_32bit_shinfo)
> +#else
> +#define has_32bit_shinfo(d) ((void)(d), false)
> +#endif
>   /*
>    * Set to true if either the global vector-type callback or per-vCPU
>    * LAPIC vectors are used. Assume all vCPUs will use
> @@ -365,8 +368,10 @@ struct arch_domain
>       /* NB. protected by d->event_lock and by irq_desc[irq].lock */
>       struct radix_tree_root irq_pirq;
>   
> +#ifdef CONFIG_COMPAT
>       /* Is shared-info page in 32-bit format? */
>       bool has_32bit_shinfo;
> +#endif
>   
>       /* Is PHYSDEVOP_eoi to automatically unmask the event channel? */
>       bool auto_unmask;
> diff --git a/xen/include/hypercall-defs.c b/xen/include/hypercall-defs.c
> index cef08eeec1b8..08c01153ac56 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
> @@ -104,10 +106,10 @@ defhandle: trap_info_compat_t
>   defhandle: physdev_op_compat_t
>   #endif
>   
> -prefix: do PREFIX_hvm PREFIX_compat PREFIX_do_arm
> +prefix: do PREFIX_hvm PREFIX_compat_always PREFIX_do_arm
>   physdev_op(int cmd, void *arg)
>   
> -prefix: do PREFIX_hvm PREFIX_compat
> +prefix: do PREFIX_hvm PREFIX_compat_always
>   #if defined(CONFIG_GRANT_TABLE) || defined(CONFIG_PV_SHIM)
>   grant_table_op(unsigned int cmd, void *uop, unsigned int count)
>   #endif
> @@ -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 /* CONFIG_COMPAT */
> +prefix: PREFIX_compat_always
> +memory_op(unsigned int cmd, void *arg)
>   #endif /* CONFIG_COMPAT */
>   
>   #if defined(CONFIG_PV) || defined(CONFIG_ARM)

-- 
Best regards,
-grygorii



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [XEN][PATCH v2 0/4] x86: pvh: allow to disable 32-bit (COMPAT) interface support
  2025-11-19 19:30 [XEN][PATCH v2 0/4] x86: pvh: allow to disable 32-bit (COMPAT) interface support Grygorii Strashko
                   ` (3 preceding siblings ...)
  2025-11-19 19:30 ` [XEN][PATCH v2 4/4] x86: pvh: allow to disable 32-bit interface support Grygorii Strashko
@ 2025-12-18 16:20 ` Grygorii Strashko
  2025-12-18 16:33   ` Jan Beulich
  4 siblings, 1 reply; 14+ messages in thread
From: Grygorii Strashko @ 2025-12-18 16:20 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Jan Beulich, Andrew Cooper, Roger Pau Monné, Anthony PERARD,
	Michal Orzel, Julien Grall, Stefano Stabellini

Hi All,

I'm planning to send v3 - so would be appreciated for any other comments.

On 19.11.25 21:30, Grygorii Strashko wrote:
> From: Grygorii Strashko <grygorii_strashko@epam.com>
> 
> Hi
> 
> This series introduces possibility to disable 32-bit (COMPAT) interface support
> in the following case:
>        - Only PVH domains are used
>        - Guests (OS) are started by using direct Direct Kernel Boot
>        - Guests (OS) are 64-bit and Guest early boot code, which is running not
>          in 64-bit mode, does not access Xen interfaces
>          (hypercalls, shared_info, ..)
> 
> If above criterias are met the COMPAT HVM interface become unreachable and can be disabled.
> Coverage reports analyze and adding guard (debug) exceptions in hvm_hypercall/hvm_do_multicall_call
> and hvm_latch_shinfo_size() confirm that COMPAT HVM interface is unused for safety use-case.
> 
> Changes in v2 described in each patch:
> - patch "x86: constify has_32bit_shinfo() if !CONFIG_COMPAT" squashed in patch 2.
> 
> v1:
>   https://patchwork.kernel.org/project/xen-devel/cover/20251111175413.3540690-1-grygorii_strashko@epam.com/
> 
> Grygorii Strashko (4):
>    x86: hvm: dm: factor out compat code under ifdefs
>    x86: hvm: compat: introduce is_hcall_compat() helper
>    x86: hvm: factor out COMPAT code under ifdefs
>    x86: pvh: allow to disable 32-bit interface support
> 
>   xen/arch/x86/hvm/Kconfig          | 19 ++++++++++++++++++-
>   xen/arch/x86/hvm/dm.c             |  2 ++
>   xen/arch/x86/hvm/hvm.c            | 24 ++++++++++++++++++++----
>   xen/arch/x86/hvm/hypercall.c      | 22 +++++++++++++++++-----
>   xen/arch/x86/hypercall.c          |  6 +-----
>   xen/arch/x86/include/asm/domain.h |  9 +++++++--
>   xen/common/kernel.c               |  2 +-
>   xen/include/hypercall-defs.c      |  9 +++++++--
>   xen/include/xen/sched.h           |  9 +++++++++
>   9 files changed, 82 insertions(+), 20 deletions(-)
> 

-- 
Best regards,
-grygorii



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [XEN][PATCH v2 0/4] x86: pvh: allow to disable 32-bit (COMPAT) interface support
  2025-12-18 16:20 ` [XEN][PATCH v2 0/4] x86: pvh: allow to disable 32-bit (COMPAT) " Grygorii Strashko
@ 2025-12-18 16:33   ` Jan Beulich
  2025-12-19  0:33     ` Stefano Stabellini
  0 siblings, 1 reply; 14+ messages in thread
From: Jan Beulich @ 2025-12-18 16:33 UTC (permalink / raw)
  To: Grygorii Strashko, Andrew Cooper
  Cc: Roger Pau Monné, Anthony PERARD, Michal Orzel, Julien Grall,
	Stefano Stabellini, xen-devel@lists.xenproject.org

On 18.12.2025 17:20, Grygorii Strashko wrote:
> I'm planning to send v3 - so would be appreciated for any other comments.

Andrew,

could you please write down the outline of what you described verbally the
other day, to scope the extent to which we may want to take changes here?

Thanks, Jan

> On 19.11.25 21:30, Grygorii Strashko wrote:
>> From: Grygorii Strashko <grygorii_strashko@epam.com>
>>
>> Hi
>>
>> This series introduces possibility to disable 32-bit (COMPAT) interface support
>> in the following case:
>>        - Only PVH domains are used
>>        - Guests (OS) are started by using direct Direct Kernel Boot
>>        - Guests (OS) are 64-bit and Guest early boot code, which is running not
>>          in 64-bit mode, does not access Xen interfaces
>>          (hypercalls, shared_info, ..)
>>
>> If above criterias are met the COMPAT HVM interface become unreachable and can be disabled.
>> Coverage reports analyze and adding guard (debug) exceptions in hvm_hypercall/hvm_do_multicall_call
>> and hvm_latch_shinfo_size() confirm that COMPAT HVM interface is unused for safety use-case.
>>
>> Changes in v2 described in each patch:
>> - patch "x86: constify has_32bit_shinfo() if !CONFIG_COMPAT" squashed in patch 2.
>>
>> v1:
>>   https://patchwork.kernel.org/project/xen-devel/cover/20251111175413.3540690-1-grygorii_strashko@epam.com/
>>
>> Grygorii Strashko (4):
>>    x86: hvm: dm: factor out compat code under ifdefs
>>    x86: hvm: compat: introduce is_hcall_compat() helper
>>    x86: hvm: factor out COMPAT code under ifdefs
>>    x86: pvh: allow to disable 32-bit interface support
>>
>>   xen/arch/x86/hvm/Kconfig          | 19 ++++++++++++++++++-
>>   xen/arch/x86/hvm/dm.c             |  2 ++
>>   xen/arch/x86/hvm/hvm.c            | 24 ++++++++++++++++++++----
>>   xen/arch/x86/hvm/hypercall.c      | 22 +++++++++++++++++-----
>>   xen/arch/x86/hypercall.c          |  6 +-----
>>   xen/arch/x86/include/asm/domain.h |  9 +++++++--
>>   xen/common/kernel.c               |  2 +-
>>   xen/include/hypercall-defs.c      |  9 +++++++--
>>   xen/include/xen/sched.h           |  9 +++++++++
>>   9 files changed, 82 insertions(+), 20 deletions(-)
>>
> 



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [XEN][PATCH v2 3/4] x86: hvm: factor out COMPAT code under ifdefs
  2025-12-04 18:47   ` Grygorii Strashko
@ 2025-12-18 16:47     ` Jürgen Groß
  0 siblings, 0 replies; 14+ messages in thread
From: Jürgen Groß @ 2025-12-18 16:47 UTC (permalink / raw)
  To: Grygorii Strashko, xen-devel@lists.xenproject.org
  Cc: Jan Beulich, Andrew Cooper, Roger Pau Monné, Anthony PERARD,
	Michal Orzel, Julien Grall, Stefano Stabellini, Alejandro Vallejo,
	Jason Andryuk


[-- Attachment #1.1.1: Type: text/plain, Size: 924 bytes --]

On 04.12.25 19:47, Grygorii Strashko wrote:
> Hi Jürgen,
> 
> Would it be possible for you to take a look at hypercall-defs.c changes?
> 
> On 19.11.25 21:30, Grygorii Strashko wrote:
>> From: Grygorii Strashko <grygorii_strashko@epam.com>
>>
>> Factor out COMPAT HVM code under ifdefs in preparation for making HVM
>> COMPAT code optional.
>>
>> - hypercall-defs.c updated to always provide compat declaration for:
>> physdev_op, grant_table_op, grant_table_op. This reduces number of COMPAT
>> ifdefs in HVM code and lets compiler DCE do the job.
>>
>> - Only 64-bit shinfo is supported with COMPAT=n, so struct
>> arch_domain->has_32bit_shinfo field is moved under COMPAT ifdef and
>> has_32bit_shinfo() is updated to account for COMPAT=n.
>>
>> Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>

Reviewed-by: Juergen Gross <jgross@suse.com> # xen/include/hypercall-defs.c


Juergen

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [XEN][PATCH v2 0/4] x86: pvh: allow to disable 32-bit (COMPAT) interface support
  2025-12-18 16:33   ` Jan Beulich
@ 2025-12-19  0:33     ` Stefano Stabellini
  0 siblings, 0 replies; 14+ messages in thread
From: Stefano Stabellini @ 2025-12-19  0:33 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Grygorii Strashko, Andrew Cooper, Roger Pau Monné,
	Anthony PERARD, Michal Orzel, Julien Grall, Stefano Stabellini,
	xen-devel@lists.xenproject.org

On Thu, 18 Dec 2025, Jan Beulich wrote:
> On 18.12.2025 17:20, Grygorii Strashko wrote:
> > I'm planning to send v3 - so would be appreciated for any other comments.
> 
> Andrew,
> 
> could you please write down the outline of what you described verbally the
> other day, to scope the extent to which we may want to take changes here?

I am not Andrew, but I just wanted to take the opportunity to write down
my recollection, letting Andrew chime in as needed of course.

We would make it possible to remove the compat code itself and compat
hypercall entries. This would be acceptable right away.

When it comes to 32-bit code intermixed with 64-bit code, we would have
to look at it on a case by case basis.


 
> > On 19.11.25 21:30, Grygorii Strashko wrote:
> >> From: Grygorii Strashko <grygorii_strashko@epam.com>
> >>
> >> Hi
> >>
> >> This series introduces possibility to disable 32-bit (COMPAT) interface support
> >> in the following case:
> >>        - Only PVH domains are used
> >>        - Guests (OS) are started by using direct Direct Kernel Boot
> >>        - Guests (OS) are 64-bit and Guest early boot code, which is running not
> >>          in 64-bit mode, does not access Xen interfaces
> >>          (hypercalls, shared_info, ..)
> >>
> >> If above criterias are met the COMPAT HVM interface become unreachable and can be disabled.
> >> Coverage reports analyze and adding guard (debug) exceptions in hvm_hypercall/hvm_do_multicall_call
> >> and hvm_latch_shinfo_size() confirm that COMPAT HVM interface is unused for safety use-case.
> >>
> >> Changes in v2 described in each patch:
> >> - patch "x86: constify has_32bit_shinfo() if !CONFIG_COMPAT" squashed in patch 2.
> >>
> >> v1:
> >>   https://patchwork.kernel.org/project/xen-devel/cover/20251111175413.3540690-1-grygorii_strashko@epam.com/
> >>
> >> Grygorii Strashko (4):
> >>    x86: hvm: dm: factor out compat code under ifdefs
> >>    x86: hvm: compat: introduce is_hcall_compat() helper
> >>    x86: hvm: factor out COMPAT code under ifdefs
> >>    x86: pvh: allow to disable 32-bit interface support
> >>
> >>   xen/arch/x86/hvm/Kconfig          | 19 ++++++++++++++++++-
> >>   xen/arch/x86/hvm/dm.c             |  2 ++
> >>   xen/arch/x86/hvm/hvm.c            | 24 ++++++++++++++++++++----
> >>   xen/arch/x86/hvm/hypercall.c      | 22 +++++++++++++++++-----
> >>   xen/arch/x86/hypercall.c          |  6 +-----
> >>   xen/arch/x86/include/asm/domain.h |  9 +++++++--
> >>   xen/common/kernel.c               |  2 +-
> >>   xen/include/hypercall-defs.c      |  9 +++++++--
> >>   xen/include/xen/sched.h           |  9 +++++++++
> >>   9 files changed, 82 insertions(+), 20 deletions(-)
> >>
> > 
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-12-19  0:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-19 19:30 [XEN][PATCH v2 0/4] x86: pvh: allow to disable 32-bit (COMPAT) interface support Grygorii Strashko
2025-11-19 19:30 ` [XEN][PATCH v2 1/4] x86: hvm: dm: factor out compat code under ifdefs Grygorii Strashko
2025-11-19 19:30 ` [XEN][PATCH v2 3/4] x86: hvm: factor out COMPAT " Grygorii Strashko
2025-12-02 19:26   ` Jason Andryuk
2025-12-04 18:39     ` Grygorii Strashko
2025-12-04 18:47   ` Grygorii Strashko
2025-12-18 16:47     ` Jürgen Groß
2025-11-19 19:30 ` [XEN][PATCH v2 2/4] x86: hvm: compat: introduce is_hcall_compat() helper Grygorii Strashko
2025-12-02 18:41   ` Jason Andryuk
2025-11-19 19:30 ` [XEN][PATCH v2 4/4] x86: pvh: allow to disable 32-bit interface support Grygorii Strashko
2025-12-02 19:56   ` Jason Andryuk
2025-12-18 16:20 ` [XEN][PATCH v2 0/4] x86: pvh: allow to disable 32-bit (COMPAT) " Grygorii Strashko
2025-12-18 16:33   ` Jan Beulich
2025-12-19  0:33     ` Stefano Stabellini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.