From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"George Dunlap" <george.dunlap@citrix.com>,
"Ian Jackson" <iwj@xenproject.org>,
"Julien Grall" <julien@xen.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH v2 2/3] x86: slim down hypercall handling when !PV32
Date: Tue, 6 Apr 2021 16:01:41 +0200 [thread overview]
Message-ID: <d85736e6-bca9-de3a-328d-d727c327dbda@suse.com> (raw)
In-Reply-To: <bf79f745-078b-071d-cf01-dfede456041a@suse.com>
In such a build various of the compat handlers aren't needed. Don't
reference them from the hypercall table, and compile out those which
aren't needed for HVM. Also compile out switch_compat(), which has no
purpose in such a build.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: New.
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -17,7 +17,8 @@ obj-bin-y += bzimage.init.o
obj-bin-y += clear_page.o
obj-bin-y += copy_page.o
obj-y += cpuid.o
-obj-$(CONFIG_PV) += compat.o x86_64/compat.o
+obj-$(CONFIG_PV) += compat.o
+obj-$(CONFIG_PV32) += x86_64/compat.o
obj-$(CONFIG_KEXEC) += crash.o
obj-$(CONFIG_GDBSX) += debug.o
obj-y += delay.o
--- a/xen/arch/x86/hvm/hypercall.c
+++ b/xen/arch/x86/hvm/hypercall.c
@@ -121,7 +121,9 @@ static long hvm_physdev_op(int cmd, XEN_
#define do_arch_1 paging_domctl_continuation
-static const hypercall_table_t hvm_hypercall_table[] = {
+static const struct {
+ hypercall_fn_t *native, *compat;
+} hvm_hypercall_table[] = {
HVM_CALL(memory_op),
#ifdef CONFIG_GRANT_TABLE
HVM_CALL(grant_table_op),
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4498,7 +4498,9 @@ long do_update_va_mapping_otherdomain(un
return rc;
}
+#endif /* CONFIG_PV */
+#ifdef CONFIG_PV32
int compat_update_va_mapping(unsigned int va, uint32_t lo, uint32_t hi,
unsigned int flags)
{
@@ -4533,7 +4535,7 @@ int compat_update_va_mapping_otherdomain
return rc;
}
-#endif /* CONFIG_PV */
+#endif /* CONFIG_PV32 */
typedef struct e820entry e820entry_t;
DEFINE_XEN_GUEST_HANDLE(e820entry_t);
--- a/xen/arch/x86/pv/callback.c
+++ b/xen/arch/x86/pv/callback.c
@@ -19,12 +19,11 @@
#include <xen/event.h>
#include <xen/hypercall.h>
#include <xen/guest_access.h>
-#include <compat/callback.h>
-#include <compat/nmi.h>
#include <asm/shared.h>
#include <public/callback.h>
+#include <public/nmi.h>
static int register_guest_nmi_callback(unsigned long address)
{
@@ -203,6 +202,11 @@ long do_set_callbacks(unsigned long even
return 0;
}
+#ifdef CONFIG_PV32
+
+#include <compat/callback.h>
+#include <compat/nmi.h>
+
static long compat_register_guest_callback(struct compat_callback_register *reg)
{
long ret = 0;
@@ -343,6 +347,8 @@ long compat_set_callbacks(unsigned long
return 0;
}
+#endif /* CONFIG_PV32 */
+
long do_set_trap_table(XEN_GUEST_HANDLE_PARAM(const_trap_info_t) traps)
{
struct trap_info cur;
@@ -388,6 +394,7 @@ long do_set_trap_table(XEN_GUEST_HANDLE_
return rc;
}
+#ifdef CONFIG_PV32
int compat_set_trap_table(XEN_GUEST_HANDLE(trap_info_compat_t) traps)
{
struct vcpu *curr = current;
@@ -429,6 +436,7 @@ int compat_set_trap_table(XEN_GUEST_HAND
return rc;
}
+#endif
long do_nmi_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
{
@@ -455,6 +463,7 @@ long do_nmi_op(unsigned int cmd, XEN_GUE
return rc;
}
+#ifdef CONFIG_PV32
int compat_nmi_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
{
struct compat_nmi_callback cb;
@@ -479,6 +488,7 @@ int compat_nmi_op(unsigned int cmd, XEN_
return rc;
}
+#endif
/*
* Local variables:
--- a/xen/arch/x86/pv/descriptor-tables.c
+++ b/xen/arch/x86/pv/descriptor-tables.c
@@ -149,6 +149,8 @@ long do_set_gdt(XEN_GUEST_HANDLE_PARAM(x
return ret;
}
+#ifdef CONFIG_PV32
+
int compat_set_gdt(XEN_GUEST_HANDLE_PARAM(uint) frame_list,
unsigned int entries)
{
@@ -185,6 +187,18 @@ int compat_set_gdt(XEN_GUEST_HANDLE_PARA
return ret;
}
+int compat_update_descriptor(uint32_t pa_lo, uint32_t pa_hi,
+ uint32_t desc_lo, uint32_t desc_hi)
+{
+ seg_desc_t d;
+
+ d.raw = ((uint64_t)desc_hi << 32) | desc_lo;
+
+ return do_update_descriptor(pa_lo | ((uint64_t)pa_hi << 32), d);
+}
+
+#endif /* CONFIG_PV32 */
+
static bool check_descriptor(const struct domain *dom, seg_desc_t *d)
{
unsigned int a = d->a, b = d->b, cs, dpl;
@@ -334,16 +348,6 @@ long do_update_descriptor(uint64_t gaddr
return ret;
}
-int compat_update_descriptor(uint32_t pa_lo, uint32_t pa_hi,
- uint32_t desc_lo, uint32_t desc_hi)
-{
- seg_desc_t d;
-
- d.raw = ((uint64_t)desc_hi << 32) | desc_lo;
-
- return do_update_descriptor(pa_lo | ((uint64_t)pa_hi << 32), d);
-}
-
/*
* Local variables:
* mode: C
--- a/xen/arch/x86/pv/domain.c
+++ b/xen/arch/x86/pv/domain.c
@@ -212,6 +212,7 @@ unsigned long pv_make_cr4(const struct v
return cr4;
}
+#ifdef CONFIG_PV32
int switch_compat(struct domain *d)
{
struct vcpu *v;
@@ -256,6 +257,7 @@ int switch_compat(struct domain *d)
return rc;
}
+#endif
static int pv_create_gdt_ldt_l1tab(struct vcpu *v)
{
--- a/xen/arch/x86/pv/hypercall.c
+++ b/xen/arch/x86/pv/hypercall.c
@@ -25,12 +25,18 @@
#include <xen/trace.h>
#include <irq_vectors.h>
+#ifdef CONFIG_PV32
#define HYPERCALL(x) \
[ __HYPERVISOR_ ## x ] = { (hypercall_fn_t *) do_ ## x, \
(hypercall_fn_t *) do_ ## x }
#define COMPAT_CALL(x) \
[ __HYPERVISOR_ ## x ] = { (hypercall_fn_t *) do_ ## x, \
(hypercall_fn_t *) compat_ ## x }
+#else
+#define HYPERCALL(x) \
+ [ __HYPERVISOR_ ## x ] = { (hypercall_fn_t *) do_ ## x }
+#define COMPAT_CALL(x) HYPERCALL(x)
+#endif
#define do_arch_1 paging_domctl_continuation
@@ -176,6 +182,7 @@ void pv_hypercall(struct cpu_user_regs *
}
#endif
}
+#ifdef CONFIG_PV32
else
{
unsigned int ebx = regs->ebx;
@@ -225,6 +232,7 @@ void pv_hypercall(struct cpu_user_regs *
}
#endif
}
+#endif /* CONFIG_PV32 */
/*
* PV guests use SYSCALL or INT $0x82 to make a hypercall, both of which
@@ -255,7 +263,7 @@ enum mc_disposition arch_do_multicall_ca
else
call->result = -ENOSYS;
}
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_PV32
else
{
struct compat_multicall_entry *call = &state->compat_call;
--- a/xen/arch/x86/pv/iret.c
+++ b/xen/arch/x86/pv/iret.c
@@ -104,6 +104,7 @@ unsigned long do_iret(void)
return 0;
}
+#ifdef CONFIG_PV32
unsigned int compat_iret(void)
{
struct cpu_user_regs *regs = guest_cpu_user_regs();
@@ -223,6 +224,7 @@ unsigned int compat_iret(void)
*/
return regs->eax;
}
+#endif
/*
* Local variables:
--- a/xen/arch/x86/pv/shim.c
+++ b/xen/arch/x86/pv/shim.c
@@ -255,13 +255,17 @@ void __init pv_shim_setup_dom(struct dom
*/
rw_pv_hypercall_table = __va(__pa(pv_hypercall_table));
rw_pv_hypercall_table[__HYPERVISOR_event_channel_op].native =
- rw_pv_hypercall_table[__HYPERVISOR_event_channel_op].compat =
(hypercall_fn_t *)pv_shim_event_channel_op;
-
rw_pv_hypercall_table[__HYPERVISOR_grant_table_op].native =
- rw_pv_hypercall_table[__HYPERVISOR_grant_table_op].compat =
(hypercall_fn_t *)pv_shim_grant_table_op;
+#ifdef CONFIG_PV32
+ rw_pv_hypercall_table[__HYPERVISOR_event_channel_op].compat =
+ (hypercall_fn_t *)pv_shim_event_channel_op;
+ rw_pv_hypercall_table[__HYPERVISOR_grant_table_op].compat =
+ (hypercall_fn_t *)pv_shim_grant_table_op;
+#endif
+
guest = d;
/*
--- a/xen/include/asm-x86/compat.h
+++ b/xen/include/asm-x86/compat.h
@@ -6,3 +6,11 @@
typedef uint32_t compat_ptr_t;
typedef unsigned long full_ptr_t;
+
+struct domain;
+#ifdef CONFIG_PV32
+int switch_compat(struct domain *);
+#else
+#include <xen/errno.h>
+static inline int switch_compat(struct domain *d) { return -EOPNOTSUPP; }
+#endif
--- a/xen/include/asm-x86/hypercall.h
+++ b/xen/include/asm-x86/hypercall.h
@@ -16,7 +16,10 @@ typedef unsigned long hypercall_fn_t(
unsigned long, unsigned long, unsigned long);
typedef struct {
- hypercall_fn_t *native, *compat;
+ hypercall_fn_t *native;
+#ifdef CONFIG_PV32
+ hypercall_fn_t *compat;
+#endif
} hypercall_table_t;
typedef struct {
--- a/xen/include/xen/compat.h
+++ b/xen/include/xen/compat.h
@@ -227,9 +227,6 @@ void xlat_start_info(struct start_info *
struct vcpu_runstate_info;
void xlat_vcpu_runstate_info(struct vcpu_runstate_info *);
-struct domain;
-int switch_compat(struct domain *);
-
#else
#define compat_handle_is_null(hnd) 0
next prev parent reply other threads:[~2021-04-06 14:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-06 13:58 [PATCH v2 0/3] x86: asm-offsets.h and !PV32 adjustments Jan Beulich
2021-04-06 14:01 ` [PATCH v2 1/3] x86: don't build unused entry code when !PV32 Jan Beulich
2021-04-06 16:56 ` Wei Liu
2021-04-06 14:01 ` Jan Beulich [this message]
2021-04-06 16:59 ` [PATCH v2 2/3] x86: slim down hypercall handling " Wei Liu
2021-04-06 14:02 ` [PATCH v2 3/3] x86: avoid building COMPAT code when !HVM && !PV32 Jan Beulich
2021-04-06 17:03 ` Wei Liu
2021-04-08 10:02 ` Jan Beulich
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=d85736e6-bca9-de3a-328d-d727c327dbda@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=iwj@xenproject.org \
--cc=julien@xen.org \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).