git: ecdcad6516c9 - main - xen: remove CONFIG_XEN_COMPAT, purge Xen 3.0 compatibility

From: Roger Pau Monné <royger_at_FreeBSD.org>
Date: Fri, 14 Apr 2023 14:00:51 UTC
The branch main has been updated by royger:

URL: https://cgit.FreeBSD.org/src/commit/?id=ecdcad6516c9a911a701e362f23a9d2643a6d7d0

commit ecdcad6516c9a911a701e362f23a9d2643a6d7d0
Author:     Elliott Mitchell <ehem+freebsd@m5p.com>
AuthorDate: 2022-03-27 22:10:24 +0000
Commit:     Roger Pau Monné <royger@FreeBSD.org>
CommitDate: 2023-04-14 13:58:48 +0000

    xen: remove CONFIG_XEN_COMPAT, purge Xen 3.0 compatibility
    
    This overlaps the purpose of __XEN_INTERFACE_VERSION__.  Remove Xen 3.0.2
    compatibility.  __XEN_INTERFACE_VERSION__ has compatibility to Xen 3.2.8
    enabled.  As Xen 3.3 was released almost 15 years ago, it seems unlikely
    anyone hasn't updated.
    
    Reviewed by: royger
---
 sys/amd64/include/xen/hypercall.h | 58 ++-------------------------------------
 sys/i386/include/xen/hypercall.h  | 54 +++---------------------------------
 sys/xen/hypervisor.h              | 10 +------
 3 files changed, 8 insertions(+), 114 deletions(-)

diff --git a/sys/amd64/include/xen/hypercall.h b/sys/amd64/include/xen/hypercall.h
index 60da390ef4c6..c561d1b84bd6 100644
--- a/sys/amd64/include/xen/hypercall.h
+++ b/sys/amd64/include/xen/hypercall.h
@@ -49,8 +49,6 @@ extern char *hypercall_page;
 
 #define __STR(x) #x
 #define STR(x) __STR(x)
-#define	ENOXENSYS	38
-#define CONFIG_XEN_COMPAT	0x030002
 #define __must_check
 
 #define HYPERCALL_STR(name)					\
@@ -212,13 +210,6 @@ HYPERVISOR_fpu_taskswitch(
 	return _hypercall1(int, fpu_taskswitch, set);
 }
 
-static inline int __must_check
-HYPERVISOR_sched_op_compat(
-	int cmd, unsigned long arg)
-{
-	return _hypercall2(int, sched_op_compat, cmd, arg);
-}
-
 static inline int __must_check
 HYPERVISOR_sched_op(
 	int cmd, void *arg)
@@ -287,19 +278,7 @@ static inline int __must_check
 HYPERVISOR_event_channel_op(
 	int cmd, void *arg)
 {
-	int rc = _hypercall2(int, event_channel_op, cmd, arg);
-
-#if CONFIG_XEN_COMPAT <= 0x030002
-	if (__predict_false(rc == -ENOXENSYS)) {
-		struct evtchn_op op;
-		op.cmd = cmd;
-		memcpy(&op.u, arg, sizeof(op.u));
-		rc = _hypercall1(int, event_channel_op_compat, &op);
-		memcpy(arg, &op.u, sizeof(op.u));
-	}
-#endif
-
-	return rc;
+	return _hypercall2(int, event_channel_op, cmd, arg);
 }
 
 static inline int __must_check
@@ -320,19 +299,7 @@ static inline int __must_check
 HYPERVISOR_physdev_op(
 	int cmd, void *arg)
 {
-	int rc = _hypercall2(int, physdev_op, cmd, arg);
-
-#if CONFIG_XEN_COMPAT <= 0x030002
-	if (__predict_false(rc == -ENOXENSYS)) {
-		struct physdev_op op;
-		op.cmd = cmd;
-		memcpy(&op.u, arg, sizeof(op.u));
-		rc = _hypercall1(int, physdev_op_compat, &op);
-		memcpy(arg, &op.u, sizeof(op.u));
-	}
-#endif
-
-	return rc;
+	return _hypercall2(int, physdev_op, cmd, arg);
 }
 
 static inline int __must_check
@@ -379,35 +346,16 @@ HYPERVISOR_suspend(
 		.reason = SHUTDOWN_suspend
 	};
 
-	int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
+	return _hypercall3(int, sched_op, SCHEDOP_shutdown,
 			     &sched_shutdown, srec);
-
-#if CONFIG_XEN_COMPAT <= 0x030002
-	if (rc == -ENOXENSYS)
-		rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
-				 SHUTDOWN_suspend, srec);
-#endif
-
-	return rc;
 }
 
-#if CONFIG_XEN_COMPAT <= 0x030002
-static inline int
-HYPERVISOR_nmi_op(
-	unsigned long op, void *arg)
-{
-	return _hypercall2(int, nmi_op, op, arg);
-}
-#endif
-
-#ifndef CONFIG_XEN
 static inline unsigned long __must_check
 HYPERVISOR_hvm_op(
     int op, void *arg)
 {
     return _hypercall2(unsigned long, hvm_op, op, arg);
 }
-#endif
 
 static inline int __must_check
 HYPERVISOR_callback_op(
diff --git a/sys/i386/include/xen/hypercall.h b/sys/i386/include/xen/hypercall.h
index f1757e8becaf..ff96cb93157c 100644
--- a/sys/i386/include/xen/hypercall.h
+++ b/sys/i386/include/xen/hypercall.h
@@ -38,8 +38,6 @@ extern char *hypercall_page;
 
 #define __STR(x) #x
 #define STR(x) __STR(x)
-#define	ENOXENSYS	38
-#define CONFIG_XEN_COMPAT	0x030002
 
 #define HYPERCALL_STR(name)                                     \
         "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
@@ -190,13 +188,6 @@ HYPERVISOR_fpu_taskswitch(
 	return _hypercall1(int, fpu_taskswitch, set);
 }
 
-static inline int 
-HYPERVISOR_sched_op_compat(
-	int cmd, unsigned long arg)
-{
-	return _hypercall2(int, sched_op_compat, cmd, arg);
-}
-
 static inline int
 HYPERVISOR_sched_op(
 	int cmd, void *arg)
@@ -273,18 +264,7 @@ static inline int
 HYPERVISOR_event_channel_op(
 	int cmd, void *arg)
 {
-	int rc = _hypercall2(int, event_channel_op, cmd, arg);
-
-#if CONFIG_XEN_COMPAT <= 0x030002
-	if (__predict_false(rc == -ENOXENSYS)) {
-		struct evtchn_op op;
-		op.cmd = cmd;
-		memcpy(&op.u, arg, sizeof(op.u));
-		rc = _hypercall1(int, event_channel_op_compat, &op);
-		memcpy(arg, &op.u, sizeof(op.u));
-	}
-#endif
-	return (rc);
+	return _hypercall2(int, event_channel_op, cmd, arg);
 }
 
 static inline int
@@ -305,17 +285,7 @@ static inline int
 HYPERVISOR_physdev_op(
 	int cmd, void *arg)
 {
-	int rc = _hypercall2(int, physdev_op, cmd, arg);
-#if CONFIG_XEN_COMPAT <= 0x030002
-	if (__predict_false(rc == -ENOXENSYS)) {
-		struct physdev_op op;
-		op.cmd = cmd;
-		memcpy(&op.u, arg, sizeof(op.u));
-		rc = _hypercall1(int, physdev_op_compat, &op);
-		memcpy(arg, &op.u, sizeof(op.u));
-	}
-#endif
-	return (rc);
+	return _hypercall2(int, physdev_op, cmd, arg);
 }
 
 static inline int
@@ -359,24 +329,10 @@ HYPERVISOR_suspend(
 	struct sched_shutdown sched_shutdown = {
 		.reason = SHUTDOWN_suspend
 	};
-	int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
-			   &sched_shutdown, srec);
-#if CONFIG_XEN_COMPAT <= 0x030002
-	if (rc == -ENOXENSYS)
-		rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
-				 SHUTDOWN_suspend, srec);
-#endif	
-	return (rc);
-}
 
-#if CONFIG_XEN_COMPAT <= 0x030002
-static inline int
-HYPERVISOR_nmi_op(
-        unsigned long op, void *arg)
-{
-        return _hypercall2(int, nmi_op, op, arg);
+	return _hypercall3(int, sched_op, SCHEDOP_shutdown,
+			   &sched_shutdown, srec);
 }
-#endif
 
 static inline int
 HYPERVISOR_callback_op(
@@ -385,14 +341,12 @@ HYPERVISOR_callback_op(
         return _hypercall2(int, callback_op, cmd, arg);
 }
 
-#ifndef CONFIG_XEN
 static inline unsigned long
 HYPERVISOR_hvm_op(
     int op, void *arg)
 {
     return _hypercall2(unsigned long, hvm_op, op, arg);
 }
-#endif
 
 static inline int
 HYPERVISOR_xenoprof_op(
diff --git a/sys/xen/hypervisor.h b/sys/xen/hypervisor.h
index 4e79423c3a8e..96e42ce9a14b 100644
--- a/sys/xen/hypervisor.h
+++ b/sys/xen/hypervisor.h
@@ -32,13 +32,8 @@ HYPERVISOR_console_write(const char *str, int count)
 static inline int
 HYPERVISOR_yield(void)
 {
-        int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
 
-#if CONFIG_XEN_COMPAT <= 0x030002
-	if (rc == -ENOXENSYS)
-		rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
-#endif
-        return (rc);
+	return (HYPERVISOR_sched_op(SCHEDOP_yield, NULL));
 }
 
 static inline void 
@@ -49,9 +44,6 @@ HYPERVISOR_shutdown(unsigned int reason)
 	};
 
 	HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
-#if CONFIG_XEN_COMPAT <= 0x030002
-	HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
-#endif
 }
 
 #endif /* __XEN_HYPERVISOR_H__ */