All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]mini-os: Using new hypercall interfaces
@ 2006-11-22 14:48 Dietmar Hahn
  2006-11-22 22:12 ` Grzegorz Milos
  0 siblings, 1 reply; 4+ messages in thread
From: Dietmar Hahn @ 2006-11-22 14:48 UTC (permalink / raw)
  To: Grzegorz Milos; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 209 bytes --]

Hi,

this patch switches to the newer interfaces for
HYPERVISOR_sched_op() and HYPERVISOR_event_channel_op().
I testet it only on x86_32 because I have no x86_64 machine!
Please have a look!
Thanks.

Dietmar.

[-- Attachment #2: mini-os_hypercall.patch --]
[-- Type: text/x-diff, Size: 4404 bytes --]

# HG changeset patch
# User dietmar.hahn@fujitsu-siemens.com
# Date 1164206513 -3600
# Node ID 74abfaeeb7ba15d7ca366c814c412d1ccc594532
# Parent  1ef9954a26686b35b946d889726d4d35c283c2a0
Switched to new interfaces HYPERVISOR_sched_op() and
HYPERVISOR_event_channel_op().

Signed-off-by: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>


diff -r 1ef9954a2668 -r 74abfaeeb7ba extras/mini-os/events.c
--- a/extras/mini-os/events.c	Wed Nov 22 09:51:20 2006 +0000
+++ b/extras/mini-os/events.c	Wed Nov 22 15:41:53 2006 +0100
@@ -88,18 +88,18 @@ void unbind_evtchn(evtchn_port_t port )
 
 int bind_virq(uint32_t virq, evtchn_handler_t handler, void *data)
 {
-	evtchn_bind_virq_t op;
-
-	/* Try to bind the virq to a port */
-	op.virq = virq;
-	op.vcpu = smp_processor_id();
-
-	if ( HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &op) != 0 )
+	struct evtchn_bind_virq send =
+	{
+		.virq = virq,
+		.vcpu = smp_processor_id()
+	};
+	if(HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &send) != 0)
 	{
 		printk("Failed to bind virtual IRQ %d\n", virq);
 		return 1;
-    }
-    bind_evtchn(op.port, handler, data);
+	}
+	bind_evtchn(send.port, handler, NULL);
+
 	return 0;
 }
 
diff -r 1ef9954a2668 -r 74abfaeeb7ba extras/mini-os/include/x86/x86_32/hypercall-x86_32.h
--- a/extras/mini-os/include/x86/x86_32/hypercall-x86_32.h	Wed Nov 22 09:51:20 2006 +0000
+++ b/extras/mini-os/include/x86/x86_32/hypercall-x86_32.h	Wed Nov 22 15:41:53 2006 +0100
@@ -165,9 +165,16 @@ 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, unsigned long arg)
+	int cmd, void *arg)
 {
 	return _hypercall2(int, sched_op, cmd, arg);
 }
@@ -238,9 +245,21 @@ HYPERVISOR_update_va_mapping(
 
 static inline int
 HYPERVISOR_event_channel_op(
-	int cmd, void *op)
-{
-	return _hypercall2(int, event_channel_op, cmd, op);
+	int cmd, void *arg)
+{
+	int rc = _hypercall2(int, event_channel_op, cmd, arg);
+
+#ifdef CONFIG_XEN_COMPAT_030002
+	if (unlikely(rc == -ENOSYS)) {
+		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;
 }
 
 static inline int
diff -r 1ef9954a2668 -r 74abfaeeb7ba extras/mini-os/include/x86/x86_64/hypercall-x86_64.h
--- a/extras/mini-os/include/x86/x86_64/hypercall-x86_64.h	Wed Nov 22 09:51:20 2006 +0000
+++ b/extras/mini-os/include/x86/x86_64/hypercall-x86_64.h	Wed Nov 22 15:41:53 2006 +0100
@@ -170,8 +170,15 @@ HYPERVISOR_fpu_taskswitch(
 }
 
 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, unsigned long arg)
+	int cmd, void *arg)
 {
 	return _hypercall2(int, sched_op, cmd, arg);
 }
@@ -235,9 +242,21 @@ HYPERVISOR_update_va_mapping(
 
 static inline int
 HYPERVISOR_event_channel_op(
-       int cmd, void *op)
-{
-    return _hypercall2(int, event_channel_op, cmd, op);
+	int cmd, void *arg)
+{
+	int rc = _hypercall2(int, event_channel_op, cmd, arg);
+
+#ifdef CONFIG_XEN_COMPAT_030002
+	if (unlikely(rc == -ENOSYS)) {
+		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;
 }
 
 static inline int
diff -r 1ef9954a2668 -r 74abfaeeb7ba extras/mini-os/kernel.c
--- a/extras/mini-os/kernel.c	Wed Nov 22 09:51:20 2006 +0000
+++ b/extras/mini-os/kernel.c	Wed Nov 22 15:41:53 2006 +0100
@@ -28,6 +28,7 @@
  */
 
 #include <os.h>
+#include <errno.h>
 #include <hypervisor.h>
 #include <mm.h>
 #include <events.h>
@@ -159,5 +160,14 @@ void do_exit(void)
 void do_exit(void)
 {
     printk("Do_exit called!\n");
-    for ( ;; ) HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
+    for( ;; )
+    {
+        struct sched_shutdown sched_shutdown = { .reason = SHUTDOWN_crash };
+        HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+        int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+        if(rc == -ENOSYS)
+        {
+            HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, SHUTDOWN_crash);
+        }
+    }
 }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

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

* Re: [PATCH]mini-os: Using new hypercall interfaces
  2006-11-22 14:48 [PATCH]mini-os: Using new hypercall interfaces Dietmar Hahn
@ 2006-11-22 22:12 ` Grzegorz Milos
  2006-11-23  8:09   ` Dietmar Hahn
  0 siblings, 1 reply; 4+ messages in thread
From: Grzegorz Milos @ 2006-11-22 22:12 UTC (permalink / raw)
  To: Dietmar Hahn; +Cc: xen-devel

You've dropped 'data' from bind_evtchn() call in your changes to 
events.c. That breaks our API, where event handler gets void* to some 
piece of data supplied when binding a channel. It looks to me that no 
changes to events.c are required whatsoever.

Apart of that everything looks fine. Could you resend the patch?

Cheers
Gregor

Dietmar Hahn wrote:
> Hi,
> 
> this patch switches to the newer interfaces for
> HYPERVISOR_sched_op() and HYPERVISOR_event_channel_op().
> I testet it only on x86_32 because I have no x86_64 machine!
> Please have a look!
> Thanks.
> 
> Dietmar.
> 
> 
> ------------------------------------------------------------------------
> 
> # HG changeset patch
> # User dietmar.hahn@fujitsu-siemens.com
> # Date 1164206513 -3600
> # Node ID 74abfaeeb7ba15d7ca366c814c412d1ccc594532
> # Parent  1ef9954a26686b35b946d889726d4d35c283c2a0
> Switched to new interfaces HYPERVISOR_sched_op() and
> HYPERVISOR_event_channel_op().
> 
> Signed-off-by: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
> 
> 
> diff -r 1ef9954a2668 -r 74abfaeeb7ba extras/mini-os/events.c
> --- a/extras/mini-os/events.c	Wed Nov 22 09:51:20 2006 +0000
> +++ b/extras/mini-os/events.c	Wed Nov 22 15:41:53 2006 +0100
> @@ -88,18 +88,18 @@ void unbind_evtchn(evtchn_port_t port )
>  
>  int bind_virq(uint32_t virq, evtchn_handler_t handler, void *data)
>  {
> -	evtchn_bind_virq_t op;
> -
> -	/* Try to bind the virq to a port */
> -	op.virq = virq;
> -	op.vcpu = smp_processor_id();
> -
> -	if ( HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &op) != 0 )
> +	struct evtchn_bind_virq send =
> +	{
> +		.virq = virq,
> +		.vcpu = smp_processor_id()
> +	};
> +	if(HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &send) != 0)
>  	{
>  		printk("Failed to bind virtual IRQ %d\n", virq);
>  		return 1;
> -    }
> -    bind_evtchn(op.port, handler, data);
> +	}
> +	bind_evtchn(send.port, handler, NULL);
> +
>  	return 0;
>  }
>  
> diff -r 1ef9954a2668 -r 74abfaeeb7ba extras/mini-os/include/x86/x86_32/hypercall-x86_32.h
> --- a/extras/mini-os/include/x86/x86_32/hypercall-x86_32.h	Wed Nov 22 09:51:20 2006 +0000
> +++ b/extras/mini-os/include/x86/x86_32/hypercall-x86_32.h	Wed Nov 22 15:41:53 2006 +0100
> @@ -165,9 +165,16 @@ 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, unsigned long arg)
> +	int cmd, void *arg)
>  {
>  	return _hypercall2(int, sched_op, cmd, arg);
>  }
> @@ -238,9 +245,21 @@ HYPERVISOR_update_va_mapping(
>  
>  static inline int
>  HYPERVISOR_event_channel_op(
> -	int cmd, void *op)
> -{
> -	return _hypercall2(int, event_channel_op, cmd, op);
> +	int cmd, void *arg)
> +{
> +	int rc = _hypercall2(int, event_channel_op, cmd, arg);
> +
> +#ifdef CONFIG_XEN_COMPAT_030002
> +	if (unlikely(rc == -ENOSYS)) {
> +		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;
>  }
>  
>  static inline int
> diff -r 1ef9954a2668 -r 74abfaeeb7ba extras/mini-os/include/x86/x86_64/hypercall-x86_64.h
> --- a/extras/mini-os/include/x86/x86_64/hypercall-x86_64.h	Wed Nov 22 09:51:20 2006 +0000
> +++ b/extras/mini-os/include/x86/x86_64/hypercall-x86_64.h	Wed Nov 22 15:41:53 2006 +0100
> @@ -170,8 +170,15 @@ HYPERVISOR_fpu_taskswitch(
>  }
>  
>  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, unsigned long arg)
> +	int cmd, void *arg)
>  {
>  	return _hypercall2(int, sched_op, cmd, arg);
>  }
> @@ -235,9 +242,21 @@ HYPERVISOR_update_va_mapping(
>  
>  static inline int
>  HYPERVISOR_event_channel_op(
> -       int cmd, void *op)
> -{
> -    return _hypercall2(int, event_channel_op, cmd, op);
> +	int cmd, void *arg)
> +{
> +	int rc = _hypercall2(int, event_channel_op, cmd, arg);
> +
> +#ifdef CONFIG_XEN_COMPAT_030002
> +	if (unlikely(rc == -ENOSYS)) {
> +		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;
>  }
>  
>  static inline int
> diff -r 1ef9954a2668 -r 74abfaeeb7ba extras/mini-os/kernel.c
> --- a/extras/mini-os/kernel.c	Wed Nov 22 09:51:20 2006 +0000
> +++ b/extras/mini-os/kernel.c	Wed Nov 22 15:41:53 2006 +0100
> @@ -28,6 +28,7 @@
>   */
>  
>  #include <os.h>
> +#include <errno.h>
>  #include <hypervisor.h>
>  #include <mm.h>
>  #include <events.h>
> @@ -159,5 +160,14 @@ void do_exit(void)
>  void do_exit(void)
>  {
>      printk("Do_exit called!\n");
> -    for ( ;; ) HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
> +    for( ;; )
> +    {
> +        struct sched_shutdown sched_shutdown = { .reason = SHUTDOWN_crash };
> +        HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
> +        int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
> +        if(rc == -ENOSYS)
> +        {
> +            HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, SHUTDOWN_crash);
> +        }
> +    }
>  }

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

* Re: [PATCH]mini-os: Using new hypercall interfaces
  2006-11-22 22:12 ` Grzegorz Milos
@ 2006-11-23  8:09   ` Dietmar Hahn
  2006-11-24 17:22     ` Grzegorz Milos
  0 siblings, 1 reply; 4+ messages in thread
From: Dietmar Hahn @ 2006-11-23  8:09 UTC (permalink / raw)
  To: Grzegorz Milos; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 458 bytes --]

Hi Gregor,

> You've dropped 'data' from bind_evtchn() call in your changes to
> events.c. That breaks our API, where event handler gets void* to some
> piece of data supplied when binding a channel. It looks to me that no
> changes to events.c are required whatsoever.
Sorry, my fault. I overlooked last changes to the 
HYPERVISOR_event_channel_op() hypercall :-(.
I resend the patch only with the changed hypercall HYPERVISOR_sched_op().
Thanks.

Dietmar.

[-- Attachment #2: mini-os_hypercall.patch --]
[-- Type: text/x-diff, Size: 1760 bytes --]

# HG changeset patch
# User dietmar.hahn@fujitsu-siemens.com
# Date 1164268700 -3600
# Node ID 85056d526e1496d0f3a2449b51e4ba6a2361baec
# Parent  2ef0f17a9af9b6b3b2f76460e0f9da5112c0bd79
Switched to new interface for HYPERVISOR_sched_op().

Signed-off-by: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>

diff -r 2ef0f17a9af9 -r 85056d526e14 extras/mini-os/include/x86/x86_32/hypercall-x86_32.h
--- a/extras/mini-os/include/x86/x86_32/hypercall-x86_32.h	Wed Nov 22 18:36:48 2006 +0000
+++ b/extras/mini-os/include/x86/x86_32/hypercall-x86_32.h	Thu Nov 23 08:58:20 2006 +0100
@@ -167,7 +167,7 @@ HYPERVISOR_fpu_taskswitch(
 
 static inline int
 HYPERVISOR_sched_op(
-	int cmd, unsigned long arg)
+	int cmd, void *arg)
 {
 	return _hypercall2(int, sched_op, cmd, arg);
 }
diff -r 2ef0f17a9af9 -r 85056d526e14 extras/mini-os/include/x86/x86_64/hypercall-x86_64.h
--- a/extras/mini-os/include/x86/x86_64/hypercall-x86_64.h	Wed Nov 22 18:36:48 2006 +0000
+++ b/extras/mini-os/include/x86/x86_64/hypercall-x86_64.h	Thu Nov 23 08:58:20 2006 +0100
@@ -171,7 +171,7 @@ HYPERVISOR_fpu_taskswitch(
 
 static inline int
 HYPERVISOR_sched_op(
-	int cmd, unsigned long arg)
+	int cmd, void *arg)
 {
 	return _hypercall2(int, sched_op, cmd, arg);
 }
diff -r 2ef0f17a9af9 -r 85056d526e14 extras/mini-os/kernel.c
--- a/extras/mini-os/kernel.c	Wed Nov 22 18:36:48 2006 +0000
+++ b/extras/mini-os/kernel.c	Thu Nov 23 08:58:20 2006 +0100
@@ -159,5 +159,9 @@ void do_exit(void)
 void do_exit(void)
 {
     printk("Do_exit called!\n");
-    for ( ;; ) HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
+    for( ;; )
+    {
+        struct sched_shutdown sched_shutdown = { .reason = SHUTDOWN_crash };
+        HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+    }
 }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

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

* Re: [PATCH]mini-os: Using new hypercall interfaces
  2006-11-23  8:09   ` Dietmar Hahn
@ 2006-11-24 17:22     ` Grzegorz Milos
  0 siblings, 0 replies; 4+ messages in thread
From: Grzegorz Milos @ 2006-11-24 17:22 UTC (permalink / raw)
  To: Dietmar Hahn; +Cc: xen-devel

This patch looks all fine. Tested on both 32 and 64 bit machines.

Keir could you apply please.

Thanks.
Grerog

Dietmar Hahn wrote:
> Hi Gregor,
> 
>> You've dropped 'data' from bind_evtchn() call in your changes to
>> events.c. That breaks our API, where event handler gets void* to some
>> piece of data supplied when binding a channel. It looks to me that no
>> changes to events.c are required whatsoever.
> Sorry, my fault. I overlooked last changes to the 
> HYPERVISOR_event_channel_op() hypercall :-(.
> I resend the patch only with the changed hypercall HYPERVISOR_sched_op().
> Thanks.
> 
> Dietmar.
> 
> 
> ------------------------------------------------------------------------
> 
> # HG changeset patch
> # User dietmar.hahn@fujitsu-siemens.com
> # Date 1164268700 -3600
> # Node ID 85056d526e1496d0f3a2449b51e4ba6a2361baec
> # Parent  2ef0f17a9af9b6b3b2f76460e0f9da5112c0bd79
> Switched to new interface for HYPERVISOR_sched_op().
> 
> Signed-off-by: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
> 
> diff -r 2ef0f17a9af9 -r 85056d526e14 extras/mini-os/include/x86/x86_32/hypercall-x86_32.h
> --- a/extras/mini-os/include/x86/x86_32/hypercall-x86_32.h	Wed Nov 22 18:36:48 2006 +0000
> +++ b/extras/mini-os/include/x86/x86_32/hypercall-x86_32.h	Thu Nov 23 08:58:20 2006 +0100
> @@ -167,7 +167,7 @@ HYPERVISOR_fpu_taskswitch(
>  
>  static inline int
>  HYPERVISOR_sched_op(
> -	int cmd, unsigned long arg)
> +	int cmd, void *arg)
>  {
>  	return _hypercall2(int, sched_op, cmd, arg);
>  }
> diff -r 2ef0f17a9af9 -r 85056d526e14 extras/mini-os/include/x86/x86_64/hypercall-x86_64.h
> --- a/extras/mini-os/include/x86/x86_64/hypercall-x86_64.h	Wed Nov 22 18:36:48 2006 +0000
> +++ b/extras/mini-os/include/x86/x86_64/hypercall-x86_64.h	Thu Nov 23 08:58:20 2006 +0100
> @@ -171,7 +171,7 @@ HYPERVISOR_fpu_taskswitch(
>  
>  static inline int
>  HYPERVISOR_sched_op(
> -	int cmd, unsigned long arg)
> +	int cmd, void *arg)
>  {
>  	return _hypercall2(int, sched_op, cmd, arg);
>  }
> diff -r 2ef0f17a9af9 -r 85056d526e14 extras/mini-os/kernel.c
> --- a/extras/mini-os/kernel.c	Wed Nov 22 18:36:48 2006 +0000
> +++ b/extras/mini-os/kernel.c	Thu Nov 23 08:58:20 2006 +0100
> @@ -159,5 +159,9 @@ void do_exit(void)
>  void do_exit(void)
>  {
>      printk("Do_exit called!\n");
> -    for ( ;; ) HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
> +    for( ;; )
> +    {
> +        struct sched_shutdown sched_shutdown = { .reason = SHUTDOWN_crash };
> +        HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
> +    }
>  }

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

end of thread, other threads:[~2006-11-24 17:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-22 14:48 [PATCH]mini-os: Using new hypercall interfaces Dietmar Hahn
2006-11-22 22:12 ` Grzegorz Milos
2006-11-23  8:09   ` Dietmar Hahn
2006-11-24 17:22     ` Grzegorz Milos

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.