Message ID | 20221209095612.689243-16-dwmw2@infradead.org |
---|---|
State | New |
Headers | show |
Series | Xen HVM support under KVM | expand |
On 09/12/2022 09:56, David Woodhouse wrote: > From: Joao Martins <joao.m.martins@oracle.com> > > This is simply when guest tries to register a vcpu_info > and since vcpu_info placement is optional in the minimum ABI > therefore we can just fail with -ENOSYS > > Signed-off-by: Joao Martins <joao.m.martins@oracle.com> > Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> > --- > target/i386/xen.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/target/i386/xen.c b/target/i386/xen.c > index 2847b4f864..9d1daadee1 100644 > --- a/target/i386/xen.c > +++ b/target/i386/xen.c > @@ -19,6 +19,7 @@ > #include "standard-headers/xen/version.h" > #include "standard-headers/xen/memory.h" > #include "standard-headers/xen/hvm/hvm_op.h" > +#include "standard-headers/xen/vcpu.h" > > static int kvm_gva_rw(CPUState *cs, uint64_t gva, void *_buf, size_t sz, > bool is_write) > @@ -194,6 +195,25 @@ static bool kvm_xen_hcall_hvm_op(struct kvm_xen_exit *exit, > } > } > > +static bool kvm_xen_hcall_vcpu_op(struct kvm_xen_exit *exit, X86CPU *cpu, > + int cmd, int vcpu_id, uint64_t arg) > +{ > + int err; > + > + switch (cmd) { > + case VCPUOP_register_vcpu_info: > + /* no vcpu info placement for now */ > + err = -ENOSYS; Again, should this patch be deferred until we actually implement something useful here? I.e. folding it into the subsequent patch? It's not like the boilerplate is massive. Paul
On Mon, 2022-12-12 at 14:51 +0000, Paul Durrant wrote: > Again, should this patch be deferred until we actually implement > something useful here? I.e. folding it into the subsequent patch? It's > not like the boilerplate is massive. That's how Joao did it; it seems sane enough to do bite-sized pieces so I didn't change it. As I've been through and rebased/reworked it all about ten times so far, it's been useful for it to be in small chunks.
diff --git a/target/i386/xen.c b/target/i386/xen.c index 2847b4f864..9d1daadee1 100644 --- a/target/i386/xen.c +++ b/target/i386/xen.c @@ -19,6 +19,7 @@ #include "standard-headers/xen/version.h" #include "standard-headers/xen/memory.h" #include "standard-headers/xen/hvm/hvm_op.h" +#include "standard-headers/xen/vcpu.h" static int kvm_gva_rw(CPUState *cs, uint64_t gva, void *_buf, size_t sz, bool is_write) @@ -194,6 +195,25 @@ static bool kvm_xen_hcall_hvm_op(struct kvm_xen_exit *exit, } } +static bool kvm_xen_hcall_vcpu_op(struct kvm_xen_exit *exit, X86CPU *cpu, + int cmd, int vcpu_id, uint64_t arg) +{ + int err; + + switch (cmd) { + case VCPUOP_register_vcpu_info: + /* no vcpu info placement for now */ + err = -ENOSYS; + break; + + default: + return false; + } + + exit->u.hcall.result = err; + return true; +} + static bool __kvm_xen_handle_exit(X86CPU *cpu, struct kvm_xen_exit *exit) { uint16_t code = exit->u.hcall.input; @@ -204,6 +224,11 @@ static bool __kvm_xen_handle_exit(X86CPU *cpu, struct kvm_xen_exit *exit) } switch (code) { + case __HYPERVISOR_vcpu_op: + return kvm_xen_hcall_vcpu_op(exit, cpu, + exit->u.hcall.params[0], + exit->u.hcall.params[1], + exit->u.hcall.params[2]); case __HYPERVISOR_hvm_op: return kvm_xen_hcall_hvm_op(exit, exit->u.hcall.params[0], exit->u.hcall.params[1]);