diff mbox series

[v6,23/51] i386/xen: implement HYPERVISOR_event_channel_op

Message ID 20230110122042.1562155-24-dwmw2@infradead.org
State New
Headers show
Series Xen support under KVM | expand

Commit Message

David Woodhouse Jan. 10, 2023, 12:20 p.m. UTC
From: Joao Martins <joao.m.martins@oracle.com>

Additionally set XEN_INTERFACE_VERSION to most recent in order to
exercise the "new" event_channel_op.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
[dwmw2: Ditch event_channel_op_compat which was never available to HVM guests]
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 target/i386/kvm/xen-emu.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Paul Durrant Jan. 16, 2023, 5:59 p.m. UTC | #1
On 10/01/2023 12:20, David Woodhouse wrote:
> From: Joao Martins <joao.m.martins@oracle.com>
> 
> Additionally set XEN_INTERFACE_VERSION to most recent in order to
> exercise the "new" event_channel_op.
> 
> Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
> [dwmw2: Ditch event_channel_op_compat which was never available to HVM guests]
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
>   target/i386/kvm/xen-emu.c | 22 ++++++++++++++++++++++
>   1 file changed, 22 insertions(+)
> 
> diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c
> index 7803e4a7a7..ff093328d7 100644
> --- a/target/i386/kvm/xen-emu.c
> +++ b/target/i386/kvm/xen-emu.c
> @@ -27,6 +27,7 @@
>   #include "standard-headers/xen/memory.h"
>   #include "standard-headers/xen/hvm/hvm_op.h"
>   #include "standard-headers/xen/vcpu.h"
> +#include "standard-headers/xen/event_channel.h"
>   
>   #include "xen-compat.h"
>   
> @@ -585,6 +586,24 @@ static bool kvm_xen_hcall_vcpu_op(struct kvm_xen_exit *exit, X86CPU *cpu,
>       return true;
>   }
>   
> +static bool kvm_xen_hcall_evtchn_op(struct kvm_xen_exit *exit,
> +                                    int cmd, uint64_t arg)
> +{
> +    int err = -ENOSYS;
> +
> +    switch (cmd) {
> +    case EVTCHNOP_init_control:
> +        err = -ENOSYS;
> +        break;

The commit comment doesn't explain why the above op is singled out for 
this treatment. I assume it is because there is no intention to 
implement FIFO event channels in subsequent patches, but it'd be nice to 
say so here.

   Paul

> +
> +    default:
> +        return false;
> +    }
> +
> +    exit->u.hcall.result = err;
> +    return true;
> +}
> +
>   static int kvm_xen_soft_reset(void)
>   {
>       CPUState *cpu;
> @@ -684,6 +703,9 @@ static bool do_kvm_xen_handle_exit(X86CPU *cpu, struct kvm_xen_exit *exit)
>       case __HYPERVISOR_sched_op:
>           return kvm_xen_hcall_sched_op(exit, cpu, exit->u.hcall.params[0],
>                                         exit->u.hcall.params[1]);
> +    case __HYPERVISOR_event_channel_op:
> +        return kvm_xen_hcall_evtchn_op(exit, exit->u.hcall.params[0],
> +                                       exit->u.hcall.params[1]);
>       case __HYPERVISOR_vcpu_op:
>           return kvm_xen_hcall_vcpu_op(exit, cpu,
>                                        exit->u.hcall.params[0],
David Woodhouse Jan. 16, 2023, 7:54 p.m. UTC | #2
On Mon, 2023-01-16 at 17:59 +0000, Paul Durrant wrote:
> > +
> > +    switch (cmd) {
> > +    case EVTCHNOP_init_control:
> > +        err = -ENOSYS;
> > +        break;
> 
> The commit comment doesn't explain why the above op is singled out for 
> this treatment. I assume it is because there is no intention to 
> implement FIFO event channels in subsequent patches, but it'd be nice to 
> say so here.

Indeed. I added EVTCHNOP_expand_array and EVTCHNOP_set_priority too, while I'm at it.
diff mbox series

Patch

diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c
index 7803e4a7a7..ff093328d7 100644
--- a/target/i386/kvm/xen-emu.c
+++ b/target/i386/kvm/xen-emu.c
@@ -27,6 +27,7 @@ 
 #include "standard-headers/xen/memory.h"
 #include "standard-headers/xen/hvm/hvm_op.h"
 #include "standard-headers/xen/vcpu.h"
+#include "standard-headers/xen/event_channel.h"
 
 #include "xen-compat.h"
 
@@ -585,6 +586,24 @@  static bool kvm_xen_hcall_vcpu_op(struct kvm_xen_exit *exit, X86CPU *cpu,
     return true;
 }
 
+static bool kvm_xen_hcall_evtchn_op(struct kvm_xen_exit *exit,
+                                    int cmd, uint64_t arg)
+{
+    int err = -ENOSYS;
+
+    switch (cmd) {
+    case EVTCHNOP_init_control:
+        err = -ENOSYS;
+        break;
+
+    default:
+        return false;
+    }
+
+    exit->u.hcall.result = err;
+    return true;
+}
+
 static int kvm_xen_soft_reset(void)
 {
     CPUState *cpu;
@@ -684,6 +703,9 @@  static bool do_kvm_xen_handle_exit(X86CPU *cpu, struct kvm_xen_exit *exit)
     case __HYPERVISOR_sched_op:
         return kvm_xen_hcall_sched_op(exit, cpu, exit->u.hcall.params[0],
                                       exit->u.hcall.params[1]);
+    case __HYPERVISOR_event_channel_op:
+        return kvm_xen_hcall_evtchn_op(exit, exit->u.hcall.params[0],
+                                       exit->u.hcall.params[1]);
     case __HYPERVISOR_vcpu_op:
         return kvm_xen_hcall_vcpu_op(exit, cpu,
                                      exit->u.hcall.params[0],