From: Grygorii Strashko <grygorii_strashko@epam.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Grygorii Strashko" <grygorii_strashko@epam.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Michal Orzel" <michal.orzel@amd.com>,
"Julien Grall" <julien@xen.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Alejandro Vallejo" <alejandro.garciavallejo@amd.com>,
"Jason Andryuk" <jason.andryuk@amd.com>
Subject: [XEN][PATCH v2 2/4] x86: hvm: compat: introduce is_hcall_compat() helper
Date: Wed, 19 Nov 2025 19:30:09 +0000 [thread overview]
Message-ID: <20251119192916.1009549-3-grygorii_strashko@epam.com> (raw)
In-Reply-To: <20251119192916.1009549-1-grygorii_strashko@epam.com>
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
next prev parent reply other threads:[~2025-11-19 19:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2025-12-02 18:41 ` [XEN][PATCH v2 2/4] x86: hvm: compat: introduce is_hcall_compat() helper Jason Andryuk
2025-11-19 19:30 ` [XEN][PATCH v2 3/4] x86: hvm: factor out COMPAT code under ifdefs 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 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251119192916.1009549-3-grygorii_strashko@epam.com \
--to=grygorii_strashko@epam.com \
--cc=alejandro.garciavallejo@amd.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=jason.andryuk@amd.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.