[PATCH v7 23/51] i386/xen: implement HYPERVISOR_event_channel_op

David Woodhouse posted 51 patches 3 years ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Stefano Stabellini <sstabellini@kernel.org>, Anthony Perard <anthony.perard@citrix.com>, Paul Durrant <paul@xen.org>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Thomas Huth <thuth@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Markus Armbruster <armbru@redhat.com>, Eric Blake <eblake@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
[PATCH v7 23/51] i386/xen: implement HYPERVISOR_event_channel_op
Posted by David Woodhouse 3 years ago
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 | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c
index b0ff03dbeb..686e5dfd38 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,27 @@ 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:
+	case EVTCHNOP_expand_array:
+	case EVTCHNOP_set_priority:
+        /* We do not support FIFO channels at this point */
+        err = -ENOSYS;
+        break;
+
+    default:
+        return false;
+    }
+
+    exit->u.hcall.result = err;
+    return true;
+}
+
 static int kvm_xen_soft_reset(void)
 {
     CPUState *cpu;
@@ -685,6 +707,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],
-- 
2.39.0
Re: [PATCH v7 23/51] i386/xen: implement HYPERVISOR_event_channel_op
Posted by Paul Durrant 3 years ago
On 16/01/2023 21:57, 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 | 25 +++++++++++++++++++++++++
>   1 file changed, 25 insertions(+)

Reviewed-by: Paul Durrant <paul@xen.org>

... with one observation...

> 
> diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c
> index b0ff03dbeb..686e5dfd38 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,27 @@ 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:
> +	case EVTCHNOP_expand_array:
> +	case EVTCHNOP_set_priority:

Indentation looks wrong here.

> +        /* We do not support FIFO channels at this point */
> +        err = -ENOSYS;
> +        break;
> +
> +    default:
> +        return false;
> +    }
> +
> +    exit->u.hcall.result = err;
> +    return true;
> +}
Re: [PATCH v7 23/51] i386/xen: implement HYPERVISOR_event_channel_op
Posted by David Woodhouse 3 years ago

On 17 January 2023 09:53:00 GMT, Paul Durrant <xadimgnik@gmail.com> wrote:
>On 16/01/2023 21:57, 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 | 25 +++++++++++++++++++++++++
>>   1 file changed, 25 insertions(+)
>
>Reviewed-by: Paul Durrant <paul@xen.org>
>
>... with one observation...
>
>> 
>> diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c
>> index b0ff03dbeb..686e5dfd38 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,27 @@ 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:
>> +	case EVTCHNOP_expand_array:
>> +	case EVTCHNOP_set_priority:
>
>Indentation looks wrong here.

Oops.. Cut and paste from code which uses tabs. :)

I think that comment about XEN_INTERFACE_VERSION may want to change too; didn't I shift that elsewhere so it didn't have to move around in the header cleanups that come later?

Will fix, ta.