Add support for Xen access to vmport
cover Add support for Xen access to vmport
Note: to use this with Xen either a version of:
[Qemu-devel] [PATCH] -machine vmport=off: Allow disabling of VMWare ioport emulation
or
Quoted 1 line
From
f70663d9fb86914144ba340b6186cb1e67ac6eecMon Sep 17 00:00:00 2001
From: Don Slutz <[email protected]>
Date: Fri, 26 Sep 2014 08:11:39 -0400
Subject: [PATCH 1/2] hack: force enable vmport
--- hw/i386/pc_piix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc_piix.c +1 -1
@@ -234,7 +234,7 @@ static void pc_init1(MachineState *machine,pc_vga_init (isa_bus, pci_enabled ? pci_bus :NULL );/* init basic PC hardware */ -pc_basic_device_init (isa_bus, gsi, &rtc_state, &floppy,xen_enabled (), +pc_basic_device_init (isa_bus, gsi, &rtc_state, &floppy, false,0x4 );pc_nic_init (isa_bus, pci_bus);
Signature · 21 lines
1.8.4 needs to be done to QEMU. And the Xen RFC patch: [RFC][PATCH 1/1] Add IOREQ_TYPE_VMWARE_PORT needs to be done to Xen. Don Slutz (1): xen-hvm.c: Add support for Xen access to vmport hw/misc/vmport.c | 32 ++++++++++++++++++++------------ include/hw/xen/xen.h | 6 ++++++ vl.c | 1 + xen-hvm.c | 38 ++++++++++++++++++++++++++++++++++++-- 4 files changed, 63 insertions(+), 14 deletions(-) -- 1.8.4
PATCH 1/1 xen-hvm.c: Add support for Xen access to vmport
This adds synchronisation of the vcpu registers
between Xen and QEMU.
--- hw/misc/vmport.c | 32 ++++++++++++++++++++------------ include/hw/xen/xen.h | 6 ++++++ vl.c | 1 + xen-hvm.c | 38 ++++++++++++++++++++++++++++++++++++-- 4 files changed, 63 insertions(+), 14 deletions(-)
hw/misc/vmport.c +20 -12
@@ -26,6 +26,7 @@#include "hw/i386/pc.h" #include "sysemu/kvm.h" #include "hw/qdev.h" +#include "hw/xen/xen.h" //#define VMPORT_DEBUG
@@ -49,6 +50,16 @@ typedef struct VMPortStatestatic VMPortState *port_state; +static CPUX86State *vmport_get_env (CPUState *cs) +{ +X86CPU *cpu =X86_CPU (cs); + +if (xen_enabled ()) { +return xen_vmport_env (); + } +return &cpu->env; +} +void vmport_register (unsigned char command,VMPortReadFunc *func,void *opaque) {if (command >=VMPORT_ENTRIES )
@@ -63,8 +74,7 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr addr, {VMPortState *s = opaque;CPUState *cs = current_cpu; -X86CPU *cpu =X86_CPU (cs); -CPUX86State *env = &cpu->env; +CPUX86State *env =vmport_get_env (cs);unsigned char command;uint32_t eax;
@@ -91,32 +101,31 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr addr,static void vmport_ioport_write (void *opaque,hwaddr addr,uint64_t val,unsigned size) { -X86CPU *cpu =X86_CPU (current_cpu); +CPUX86State *env =vmport_get_env (current_cpu); - cpu->env.regs[R_EAX ] =vmport_ioport_read (opaque, addr,4 ); + env->regs[R_EAX ] =vmport_ioport_read (opaque, addr,4 ); }static uint32_t vmport_cmd_get_version (void *opaque,uint32_t addr) { -X86CPU *cpu =X86_CPU (current_cpu); +CPUX86State *env =vmport_get_env (current_cpu); - cpu->env.regs[R_EBX ] =VMPORT_MAGIC ; + env->regs[R_EBX ] =VMPORT_MAGIC ;return 6 ; }static uint32_t vmport_cmd_ram_size (void *opaque,uint32_t addr) { -X86CPU *cpu =X86_CPU (current_cpu); +CPUX86State *env =vmport_get_env (current_cpu); - cpu->env.regs[R_EBX ] =0x1177 ; + env->regs[R_EBX ] =0x1177 ;return ram_size; }/* vmmouse helpers */ void vmmouse_get_data (uint32_t *data) { -X86CPU *cpu =X86_CPU (current_cpu); -CPUX86State *env = &cpu->env; +CPUX86State *env =vmport_get_env (current_cpu); data[0 ] = env->regs[R_EAX ]; data[1 ] = env->regs[R_EBX ]; data[2 ] = env->regs[R_ECX ]; data[3 ] = env->regs[R_EDX ];
@@ -125,8 +134,7 @@ void vmmouse_get_data(uint32_t *data)void vmmouse_set_data (const uint32_t *data) { -X86CPU *cpu =X86_CPU (current_cpu); -CPUX86State *env = &cpu->env; +CPUX86State *env =vmport_get_env (current_cpu); env->regs[R_EAX ] = data[0 ]; env->regs[R_EBX ] = data[1 ]; env->regs[R_ECX ] = data[2 ]; env->regs[R_EDX ] = data[3 ];
include/hw/xen/xen.h +6 -0
@@ -22,12 +22,18 @@ extern uint32_t xen_domid;extern enum xen_mode xen_mode;extern bool xen_allowed; +extern void *xen_opaque_env;static inline bool xen_enabled (void ) {return xen_allowed; } +static inline void *xen_vmport_env (void ) +{ +return xen_opaque_env; +} +int xen_pci_slot_get_pirq (PCIDevice *pci_dev,int irq_num);void xen_piix3_set_irq (void *opaque,int irq_num,int level);void xen_piix_pci_write_config_client (uint32_t address,uint32_t val,int len);
vl.c +1 -0
@@ -215,6 +215,7 @@ static NotifierList machine_init_done_notifiers =static bool tcg_allowed = true;bool xen_allowed;uint32_t xen_domid; +void *xen_opaque_env;enum xen_mode xen_mode =XEN_EMULATE ;static int tcg_tb_size;
xen-hvm.c +36 -2
@@ -857,14 +857,48 @@ static void cpu_handle_ioreq(void *opaque)handle_buffered_iopage (state);if (req) { +#ifdef IOREQ_TYPE_VMWARE_PORT +if (req->type ==IOREQ_TYPE_VMWARE_PORT ) { +CPUX86State *env; +ioreq_t fake_req = { + .type =IOREQ_TYPE_PIO , + .addr = (uint16_t )req->size, + .size =4 , + .dir =IOREQ_READ , + .df =0 , + .data_is_ptr =0 , + }; +if (!xen_opaque_env) { + xen_opaque_env =g_malloc (sizeof (CPUX86State)); + } + env = xen_opaque_env; + env->regs[R_EAX ] = (uint32_t )(req->addr >>32 ); + env->regs[R_EBX ] = (uint32_t )(req->addr); + env->regs[R_ECX ] = req->count; + env->regs[R_EDX ] = req->size; + env->regs[R_ESI ] = (uint32_t )(req->data >>32 ); + env->regs[R_EDI ] = (uint32_t )(req->data); +handle_ioreq (&fake_req); + req->addr = ((uint64_t )fake_req.data <<32 ) | + (uint32_t )env->regs[R_EBX ]; + req->count = env->regs[R_ECX ]; + req->size = env->regs[R_EDX ]; + req->data = ((uint64_t )env->regs[R_ESI ] <<32 ) | + (uint32_t )env->regs[R_EDI ]; + }else { +handle_ioreq (req); + } +#else handle_ioreq (req); +#endif if (req->state !=STATE_IOREQ_INPROCESS ) {fprintf (stderr,"Badness in I/O request ... not in service?!: " "%x, ptr: %x, port: %" PRIx64", " -"data: %" PRIx64", count: %" FMT_ioreq_size", size: %" FMT_ioreq_size"\n" , +"data: %" PRIx64", count: %" FMT_ioreq_size +", size: %" FMT_ioreq_size", type: %" FMT_ioreq_size"\n" , req->state, req->data_is_ptr, req->addr, - req->data, req->count, req->size); + req->data, req->count, req->size, req->type);destroy_hvm_domain (false);return ; }
Signature · 1 line
1.8.4
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Quoted 4 lines · Don Slutz
This adds synchronisation of the vcpu registers
between Xen and QEMU.Signed-off-by Don Slutz <[email protected]>
Could you instead plug into the existing cpu_synchronize_registers() framework and just implement register synchronization for the Xen side, just like it's been done for KVM? :)
Alex
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Il 29/09/2014 10:12, Alexander Graf ha scritto:
Quoted 3 lines
Could you instead plug into the existing
cpu_synchronize_registers()framework and just implement register synchronization for the Xen side, just like it's been done for KVM? :)
No, because here it's Xen that sends out the register contents. With KVM, it's QEMU that requests the register contents.
Paolo
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Quoted 7 lines · Paolo Bonzini
Il 29/09/2014 10:12, Alexander Graf ha scritto:
Quoted 3 lines
Could you instead plug into the existing
cpu_synchronize_registers()framework and just implement register synchronization for the Xen side, just like it's been done for KVM? :)No, because here it's Xen that sends out the register contents. With KVM, it's QEMU that requests the register contents.
So? We could still reuse the same infrastructure:
cpu_handle_ioreq()
{
... if (req->type == IOPORT_REGISTERS_SYNCHRONIZED) {
cpu->xen_vcpu_dirty = true;
synchronize_xen_to_env(xenptr, cpu);
}
handle_ioreq();
if (req->type == IOPORT_REGISTERS_SYNCHRONIZED) {
cpu->xen_vcpu_dirty = false;
synchronize_env_to_xen(xenptr, cpu);
}
...}
void xen_cpu_synchronize_state(CPUState *cpu)
{
assert(cpu->xen_vcpu_dirty);
}Then no changes to the vmport code would be necessary and this problems where some code path wants to do direct access to registers automatically tells us that things are broken.
Alex
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Il 29/09/2014 13:53, Alexander Graf ha scritto:
Quoted 20 lines
cpu_handle_ioreq() { ...if (req->type == IOPORT_REGISTERS_SYNCHRONIZED) { cpu->xen_vcpu_dirty = true; synchronize_xen_to_env(xenptr, cpu); } handle_ioreq(); if (req->type == IOPORT_REGISTERS_SYNCHRONIZED) { cpu->xen_vcpu_dirty = false; synchronize_env_to_xen(xenptr, cpu); } ...}
Quoted 8 lines
void xen_cpu_synchronize_state(CPUState *cpu) { assert(cpu->xen_vcpu_dirty); }Then no changes to the vmport code would be necessary and this problems where some code path wants to do direct access to registers automatically tells us that things are broken.
Yeah, that would be possible. You do not even need synchronize_state, it seems to me that it introduces more complication for little gain.
Paolo
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Quoted 26 lines · Paolo Bonzini
Il 29/09/2014 13:53, Alexander Graf ha scritto:
Quoted 25 lines
cpu_handle_ioreq() { ...if (req->type == IOPORT_REGISTERS_SYNCHRONIZED) { cpu->xen_vcpu_dirty = true; synchronize_xen_to_env(xenptr, cpu); } handle_ioreq(); if (req->type == IOPORT_REGISTERS_SYNCHRONIZED) { cpu->xen_vcpu_dirty = false; synchronize_env_to_xen(xenptr, cpu); } ...}
void xen_cpu_synchronize_state(CPUState *cpu) { assert(cpu->xen_vcpu_dirty); }
Quoted 6 lines
Quoted 3 lines
Then no changes to the vmport code would be necessary and this problems where some code path wants to do direct access to registers automatically tells us that things are broken.
Yeah, that would be possible. You do not even need
synchronize_state, it seems to me that it introduces more complication for little gain.
Well, it makes all accels behave the same and keep information always at a single entity (the env struct). I don't think the vmport code should have knowledge of a xen env struct.
Alex
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Il 29/09/2014 14:57, Alexander Graf ha scritto:
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Yeah, that would be possible. You do not even need
synchronize_state, it seems to me that it introduces more complication for little gain.Well, it makes all accels behave the same and keep information always at a single entity (the env struct). I don't think the vmport code should have knowledge of a xen env struct.
Yes, we agree on that. In fact the right CPU is already stored in send_vcpu of XenIOState.
Paolo
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Quoted 8 lines · Paolo Bonzini
Il 29/09/2014 14:57, Alexander Graf ha scritto:
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Yeah, that would be possible. You do not even need
synchronize_state, it seems to me that it introduces more complication for little gain.Well, it makes all accels behave the same and keep information always at a single entity (the env struct). I don't think the vmport code should have knowledge of a xen env struct.
Yes, we agree on that. In fact the right CPU is already stored in
send_vcpuof XenIOState.
I did reply up the thread because the info is missing here.
Basically current_cpu is NULL here, and I think that no CPU objects have been created for Xen. So there is no VCPU object to select.
-Don Slutz
Quoted 1 line
Paolo
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Il 30/09/2014 03:05, Don Slutz ha scritto:
Quoted 3 lines
Basically
current_cpuis NULL here, and I think that no CPU objects have been created for Xen. So there is no VCPU object to select.
CPU objects are created for Xen HVM, though not for PV.
You would have to visit the list of CPUs and fill in an array in XenIOState (e.g. "X86CPU **cpu_by_ioreq_id" array in XenIOState). Then you can set
current_cpu = state->cpu_by_ioreq_id[state->send_vcpu];
handle_ioreq(req);
current_cpu = NULL;in cpu_handle_ioreq.
Paolo
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
In reply to Alexander GrafQuoted 11 lines · Alexander Graf
Quoted 6 lines · Paolo Bonzini
Il 29/09/2014 10:12, Alexander Graf ha scritto:
Quoted 3 lines
Could you instead plug into the existing
cpu_synchronize_registers()framework and just implement register synchronization for the Xen side, just like it's been done for KVM? :)No, because here it's Xen that sends out the register contents. With KVM, it's QEMU that requests the register contents.
So? We could still reuse the same infrastructure:
Quoted 6 lines
cpu_handle_ioreq() { ...if (req->type == IOPORT_REGISTERS_SYNCHRONIZED) { cpu->xen_vcpu_dirty = true;
I am assuming that you mean something like:
X86CPU *cpu = X86_CPU(current_cpu);
cpu->xen_vcpu_dirty = true;because cpu is not defined here. And this has a major issue because current_cpu is NULL for Xen, so you have added a SIGSEGV.
If you are trying to say "lets build a CPUState state object here and set current_cpu to it, and then set the xen_vcpu_dirty" then yes that could be done. Adding all the code to build a CPUState state object and X86CPUClass object correctly just to use the code in vmport.c looked to me to be a lot of work for little benefit.
If you want to go with not adding the objects, I could change to having a "xen X86CPU" that I set current_cpu to and then back to NULL when done. That (I think) would drop all changes to vmport.c
Quoted 13 lines
synchronize_xen_to_env(xenptr, cpu); } handle_ioreq(); if (req->type == IOPORT_REGISTERS_SYNCHRONIZED) { cpu->xen_vcpu_dirty = false; synchronize_env_to_xen(xenptr, cpu); } ...}
Quoted 8 lines
void xen_cpu_synchronize_state(CPUState *cpu) { assert(cpu->xen_vcpu_dirty); }Then no changes to the vmport code would be necessary and this problems where some code path wants to do direct access to registers automatically tells us that things are broken.
The SIGSEGV already does this.
-Don Slutz
Quoted 2 lines
Alex
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
In reply to Don SlutzQuoted 4 lines · Don Slutz
This adds synchronisation of the vcpu registers
between Xen and QEMU.Signed-off-by Don Slutz <[email protected]>
[...]
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 860
Quoted 9 lines
xen-hvm.c +1
-0@@ -857,14 +857,48 @@ static void cpu_handle_ioreq(void *opaque)handle_buffered_iopage (state);if (req) { +#ifdef IOREQ_TYPE_VMWARE_PORT
Is there any reason to #ifdef this code?
Couldn't we just always build it in QEMU?
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 861
Quoted 1 line
xen-hvm.c +1
-0+if (req->type ==IOREQ_TYPE_VMWARE_PORT ) {
I think it would make more sense to check for IOREQ_TYPE_VMWARE_PORT from within handle_ioreq.
Quoted 16 lines
xen-hvm.c +16
-0+CPUX86State *env; +ioreq_t fake_req = { + .type =IOREQ_TYPE_PIO , + .addr = (uint16_t )req->size, + .size =4 , + .dir =IOREQ_READ , + .df =0 , + .data_is_ptr =0 , + }; +if (!xen_opaque_env) { + xen_opaque_env =g_malloc (sizeof (CPUX86State)); + } + env = xen_opaque_env; + env->regs[R_EAX ] = (uint32_t )(req->addr >>32 ); + env->regs[R_EBX ] = (uint32_t )(req->addr); + env->regs[R_ECX ] = req->count;
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 887
Quoted 10 lines
xen-hvm.c +10
-0+ env->regs[R_EDX ] = req->size; + env->regs[R_ESI ] = (uint32_t )(req->data >>32 ); + env->regs[R_EDI ] = (uint32_t )(req->data); +handle_ioreq (&fake_req); + req->addr = ((uint64_t )fake_req.data <<32 ) | + (uint32_t )env->regs[R_EBX ]; + req->count = env->regs[R_ECX ]; + req->size = env->regs[R_EDX ]; + req->data = ((uint64_t )env->regs[R_ESI ] <<32 ) | + (uint32_t )env->regs[R_EDI ];
This code could be moved to a separate helper function called by handle_ioreq.
Quoted 6 lines
xen-hvm.c +5
-0+ } else { +handle_ioreq (req); + } +#else handle_ioreq (req); +#endif
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Quoted 22 lines · Stefano Stabellini
Quoted 4 lines · Don Slutz
This adds synchronisation of the vcpu registers
between Xen and QEMU.Signed-off-by Don Slutz <[email protected]>[...]
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 860
Quoted 9 lines
xen-hvm.c +1
-0@@ -857,14 +857,48 @@ static void cpu_handle_ioreq(void *opaque)handle_buffered_iopage (state);if (req) { +#ifdef IOREQ_TYPE_VMWARE_PORT Is there any reason to #ifdef this code?
Couldn't we just always build it in QEMU?
Quoted 15 lines
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 861
Quoted 1 line
xen-hvm.c +1
-0+if (req->type ==IOREQ_TYPE_VMWARE_PORT ) {I think it would make more sense to check for
IOREQ_TYPE_VMWARE_PORTfrom withinhandle_ioreq.Quoted 9 lines
xen-hvm.c +9
-0+CPUX86State *env; +ioreq_t fake_req = { + .type =IOREQ_TYPE_PIO , + .addr = (uint16_t )req->size, + .size =4 , + .dir =IOREQ_READ , + .df =0 , + .data_is_ptr =0 , + };
Why do you need a fake req?
Couldn't Xen send the real req instead? If any case you should spend a few more words on why you are doing this.
Quoted 29 lines
Quoted 7 lines
xen-hvm.c +7
-0+if (!xen_opaque_env) { + xen_opaque_env =g_malloc (sizeof (CPUX86State)); + } + env = xen_opaque_env; + env->regs[R_EAX ] = (uint32_t )(req->addr >>32 ); + env->regs[R_EBX ] = (uint32_t )(req->addr); + env->regs[R_ECX ] = req->count;xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 887
Quoted 10 lines
xen-hvm.c +10
-0+ env->regs[R_EDX ] = req->size; + env->regs[R_ESI ] = (uint32_t )(req->data >>32 ); + env->regs[R_EDI ] = (uint32_t )(req->data); +handle_ioreq (&fake_req); + req->addr = ((uint64_t )fake_req.data <<32 ) | + (uint32_t )env->regs[R_EBX ]; + req->count = env->regs[R_ECX ]; + req->size = env->regs[R_EDX ]; + req->data = ((uint64_t )env->regs[R_ESI ] <<32 ) | + (uint32_t )env->regs[R_EDI ];This code could be moved to a separate helper function called by
handle_ioreq.Quoted 6 lines
xen-hvm.c +5
-0+ } else { +handle_ioreq (req); + } +#else handle_ioreq (req); +#endif
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Quoted 14 lines · Stefano Stabellini
Quoted 13 lines · Stefano Stabellini
Quoted 4 lines · Don Slutz
This adds synchronisation of the vcpu registers
between Xen and QEMU.Signed-off-by Don Slutz <[email protected]>[...]
Quoted 6 lines
xen-hvm.c +0
-0@@ -857,14 +857,48 @@ static void cpu_handle_ioreq(void *opaque)
Quoted 5 lines
Quoted 5 lines
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 860
Quoted 3 lines
xen-hvm.c +1
-0handle_buffered_iopage (state);if (req) { +#ifdef IOREQ_TYPE_VMWARE_PORT Is there any reason to #ifdef this code?
Couldn't we just always build it in QEMU?
This allows QEMU 2.2 (or later) to build on a system that has Xen 4.5 or earlier installed; and work.
Quoted 5 lines
Quoted 5 lines
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 861
Quoted 2 lines
xen-hvm.c +1
-0+if (req->type ==IOREQ_TYPE_VMWARE_PORT ) {I think it would make more sense to check for
IOREQ_TYPE_VMWARE_PORTfrom withinhandle_ioreq.
Ok, I can move it.
Quoted 10 lines
Quoted 9 lines
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 870
Quoted 9 lines
xen-hvm.c +9
-0+CPUX86State *env; +ioreq_t fake_req = { + .type =IOREQ_TYPE_PIO , + .addr = (uint16_t )req->size, + .size =4 , + .dir =IOREQ_READ , + .df =0 , + .data_is_ptr =0 , + };Why do you need a fake req?
To transport the 6 VCPU registers (only 32bits of them) that vmport.c needs to do it's work.
Quoted 1 line
Couldn't Xen send the real req instead?
Yes, but then a 2nd exchange between QEMU and Xen would be needed
to fetch the 6 VCPU registers. The ways I know of to fetch the VCPU registers from Xen, all need many cycles to do their work and return a lot of data that is not needed.
The other option that I have considered was to extend the ioreq_t type to have room for these registers, but that reduces by almost half the maximum number of VCPUs that are supported (They all live on 1 page).
Quoted 3 lines
If any case you should spend a
few more words on why you are doing this.
Sure. Will add some form of the above as part of the commit message.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
xen-hvm.c +17
-0+if (!xen_opaque_env) { + xen_opaque_env =g_malloc (sizeof (CPUX86State)); + } + env = xen_opaque_env; + env->regs[R_EAX ] = (uint32_t )(req->addr >>32 ); + env->regs[R_EBX ] = (uint32_t )(req->addr); + env->regs[R_ECX ] = req->count; + env->regs[R_EDX ] = req->size; + env->regs[R_ESI ] = (uint32_t )(req->data >>32 ); + env->regs[R_EDI ] = (uint32_t )(req->data); +handle_ioreq (&fake_req); + req->addr = ((uint64_t )fake_req.data <<32 ) | + (uint32_t )env->regs[R_EBX ]; + req->count = env->regs[R_ECX ]; + req->size = env->regs[R_EDX ]; + req->data = ((uint64_t )env->regs[R_ESI ] <<32 ) | + (uint32_t )env->regs[R_EDI ];
Quoted 3 lines
Quoted 3 lines
This code could be moved to a separate helper function called by
handle_ioreq.
Ok.
-Don Slutz
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
xen-hvm.c +5
-0+ } else { +handle_ioreq (req); + } +#else handle_ioreq (req); +#endif
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Quoted 20 lines · Don Slutz
Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Stefano Stabellini
Quoted 4 lines · Don Slutz
This adds synchronisation of the vcpu registers
between Xen and QEMU.Signed-off-by Don Slutz <[email protected]>[...]
Quoted 10 lines
Quoted 10 lines
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 859
Quoted 8 lines
xen-hvm.c +1
-0@@ -857,14 +857,48 @@ static void cpu_handle_ioreq(void *opaque)handle_buffered_iopage (state);if (req) { +#ifdef IOREQ_TYPE_VMWARE_PORT Is there any reason to #ifdef this code?
Couldn't we just always build it in QEMU?
Quoted 2 lines
This allows QEMU 2.2 (or later) to build on a system that has Xen 4.5 or earlier installed; and work.
I would rather remove the #ifdef from here and add any necessary compatibility stuff to include/hw/xen/xen_common.h.
Quoted 24 lines
Quoted 4 lines
Quoted 4 lines
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 861
Quoted 1 line
xen-hvm.c +1
-0+if (req->type ==IOREQ_TYPE_VMWARE_PORT ) {I think it would make more sense to check for
IOREQ_TYPE_VMWARE_PORTfrom withinhandle_ioreq.Ok, I can move it.
Quoted 10 lines
Quoted 9 lines
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 870
Quoted 9 lines
xen-hvm.c +9
-0+CPUX86State *env; +ioreq_t fake_req = { + .type =IOREQ_TYPE_PIO , + .addr = (uint16_t )req->size, + .size =4 , + .dir =IOREQ_READ , + .df =0 , + .data_is_ptr =0 , + };Why do you need a fake req?
To transport the 6 VCPU registers (only 32bits of them) that
vmport.cneeds to do it's work.Quoted 1 line
Couldn't Xen send the real req instead?
Quoted 8 lines
Yes, but then a 2nd exchange between QEMU and Xen would be needed to fetch the 6 VCPU registers. The ways I know of to fetch the VCPU registers from Xen, all need many cycles to do their work and return
a lot of data that is not needed.The other option that I have considered was to extend the
ioreq_ttype to have room for these registers, but that reduces by almost half the maximum number of VCPUs that are supported (They all live on 1 page).
Urgh. Now that I understand the patch better is think it's horrible, no offense :-)
Why don't you add another new ioreq type to send out the vcpu state? Something like IOREQ_TYPE_VCPU_SYNC_REGS? You could send it to QEMU before IOREQ_TYPE_VMWARE_PORT. Actually this solution looks very imilar to Alex's suggestion.
Quoted 38 lines
Quoted 3 lines
If any case you should spend a
few more words on why you are doing this.Sure. Will add some form of the above as part of the commit message.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
xen-hvm.c +17
-0+if (!xen_opaque_env) { + xen_opaque_env =g_malloc (sizeof (CPUX86State)); + } + env = xen_opaque_env; + env->regs[R_EAX ] = (uint32_t )(req->addr >>32 ); + env->regs[R_EBX ] = (uint32_t )(req->addr); + env->regs[R_ECX ] = req->count; + env->regs[R_EDX ] = req->size; + env->regs[R_ESI ] = (uint32_t )(req->data >>32 ); + env->regs[R_EDI ] = (uint32_t )(req->data); +handle_ioreq (&fake_req); + req->addr = ((uint64_t )fake_req.data <<32 ) | + (uint32_t )env->regs[R_EBX ]; + req->count = env->regs[R_ECX ]; + req->size = env->regs[R_EDX ]; + req->data = ((uint64_t )env->regs[R_ESI ] <<32 ) | + (uint32_t )env->regs[R_EDI ];Quoted 3 lines
Quoted 3 lines
This code could be moved to a separate helper function called by
handle_ioreq.Ok.
-Don Slutz
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
xen-hvm.c +5
-0+ } else { +handle_ioreq (req); + } +#else handle_ioreq (req); +#endif
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Quoted 20 lines · Stefano Stabellini
Quoted 19 lines · Don Slutz
Quoted 18 lines · Stefano Stabellini
Quoted 17 lines · Stefano Stabellini
Quoted 4 lines · Don Slutz
This adds synchronisation of the vcpu registers
between Xen and QEMU.Signed-off-by Don Slutz <[email protected]>[...]
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 859
Quoted 8 lines
xen-hvm.c +1
-0@@ -857,14 +857,48 @@ static void cpu_handle_ioreq(void *opaque)handle_buffered_iopage (state);if (req) { +#ifdef IOREQ_TYPE_VMWARE_PORT Is there any reason to #ifdef this code?
Couldn't we just always build it in QEMU?
Quoted 5 lines
Quoted 2 lines
This allows QEMU 2.2 (or later) to build on a system that has Xen 4.5 or earlier installed; and work.
I would rather remove the #ifdef from here and add any necessary compatibility stuff to
include/hw/xen/xen_common.h.
Ok, will do.
Quoted 26 lines
Quoted 26 lines
Quoted 4 lines
Quoted 4 lines
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 861
Quoted 1 line
xen-hvm.c +1
-0+if (req->type ==IOREQ_TYPE_VMWARE_PORT ) {I think it would make more sense to check for
IOREQ_TYPE_VMWARE_PORTfrom withinhandle_ioreq.Ok, I can move it.
Quoted 10 lines
Quoted 9 lines
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 870
Quoted 9 lines
xen-hvm.c +9
-0+CPUX86State *env; +ioreq_t fake_req = { + .type =IOREQ_TYPE_PIO , + .addr = (uint16_t )req->size, + .size =4 , + .dir =IOREQ_READ , + .df =0 , + .data_is_ptr =0 , + };Why do you need a fake req?
To transport the 6 VCPU registers (only 32bits of them) that
vmport.cneeds to do it's work.Quoted 1 line
Couldn't Xen send the real req instead?
Yes, but then a 2nd exchange between QEMU and Xen would be needed to fetch the 6 VCPU registers. The ways I know of to fetch the VCPU registers from Xen, all need many cycles to do their work and return
a lot of data that is not needed.
Quoted 5 lines
Quoted 3 lines
The other option that I have considered was to extend the
ioreq_ttype to have room for these registers, but that reduces by almost half the maximum number of VCPUs that are supported (They all live on 1 page).Urgh. Now that I understand the patch better is think it's horrible, no offense :-)
None taken.
Quoted 5 lines
Why don't you add another new ioreq type to send out the vcpu state? Something like
IOREQ_TYPE_VCPU_SYNC_REGS? You could send it to QEMU beforeIOREQ_TYPE_VMWARE_PORT. Actually this solution looks very imilar to Alex's suggestion.
I can, it is just slower. This would require 2 new types. 1 for regs to QEMU, 1 for regs from QEMU. So instead of 1 round trip (Xen to QEMU to Xen), you now have 3 (Xen to QEMU (regs to QEMU) to Xen, Xen to QEMU (PIO) to Xen, Xen to QEMU (regs from QEMU) to Xen).
-Don Slutz
Quoted 35 lines
Quoted 35 lines
Quoted 3 lines
If any case you should spend a
few more words on why you are doing this.Sure. Will add some form of the above as part of the commit message.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
xen-hvm.c +17
-0+if (!xen_opaque_env) { + xen_opaque_env =g_malloc (sizeof (CPUX86State)); + } + env = xen_opaque_env; + env->regs[R_EAX ] = (uint32_t )(req->addr >>32 ); + env->regs[R_EBX ] = (uint32_t )(req->addr); + env->regs[R_ECX ] = req->count; + env->regs[R_EDX ] = req->size; + env->regs[R_ESI ] = (uint32_t )(req->data >>32 ); + env->regs[R_EDI ] = (uint32_t )(req->data); +handle_ioreq (&fake_req); + req->addr = ((uint64_t )fake_req.data <<32 ) | + (uint32_t )env->regs[R_EBX ]; + req->count = env->regs[R_ECX ]; + req->size = env->regs[R_EDX ]; + req->data = ((uint64_t )env->regs[R_ESI ] <<32 ) | + (uint32_t )env->regs[R_EDI ];Quoted 3 lines
Quoted 3 lines
This code could be moved to a separate helper function called by
handle_ioreq.Ok.
-Don Slutz
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
xen-hvm.c +5
-0+ } else { +handle_ioreq (req); + } +#else handle_ioreq (req); +#endif
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Quoted 69 lines · Donald Christopher
Quoted 20 lines · Stefano Stabellini
Quoted 19 lines · Don Slutz
Quoted 18 lines · Stefano Stabellini
Quoted 17 lines · Stefano Stabellini
Quoted 4 lines · Don Slutz
This adds synchronisation of the vcpu registers
between Xen and QEMU.Signed-off-by Don Slutz <[email protected]>[...]
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 859
Quoted 8 lines
xen-hvm.c +1
-0@@ -857,14 +857,48 @@ static void cpu_handle_ioreq(void *opaque)handle_buffered_iopage (state);if (req) { +#ifdef IOREQ_TYPE_VMWARE_PORT Is there any reason to #ifdef this code?
Couldn't we just always build it in QEMU?Quoted 5 lines
Quoted 2 lines
This allows QEMU 2.2 (or later) to build on a system that has Xen 4.5 or earlier installed; and work.
I would rather remove the #ifdef from here and add any necessary compatibility stuff to
include/hw/xen/xen_common.h.Ok, will do.
Quoted 26 lines
Quoted 26 lines
Quoted 4 lines
Quoted 4 lines
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 861
Quoted 1 line
xen-hvm.c +1
-0+if (req->type ==IOREQ_TYPE_VMWARE_PORT ) {I think it would make more sense to check for
IOREQ_TYPE_VMWARE_PORTfrom withinhandle_ioreq.Ok, I can move it.
Quoted 10 lines
Quoted 9 lines
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 870
Quoted 9 lines
xen-hvm.c +9
-0+CPUX86State *env; +ioreq_t fake_req = { + .type =IOREQ_TYPE_PIO , + .addr = (uint16_t )req->size, + .size =4 , + .dir =IOREQ_READ , + .df =0 , + .data_is_ptr =0 , + };Why do you need a fake req?
To transport the 6 VCPU registers (only 32bits of them) that
vmport.cneeds to do it's work.Quoted 1 line
Couldn't Xen send the real req instead?
Yes, but then a 2nd exchange between QEMU and Xen would be needed to fetch the 6 VCPU registers. The ways I know of to fetch the VCPU registers from Xen, all need many cycles to do their work and return
a lot of data that is not needed.Quoted 5 lines
Quoted 3 lines
The other option that I have considered was to extend the
ioreq_ttype to have room for these registers, but that reduces by almost half the maximum number of VCPUs that are supported (They all live on 1 page).Urgh. Now that I understand the patch better is think it's horrible, no offense :-)
None taken.
Quoted 5 lines
Why don't you add another new ioreq type to send out the vcpu state? Something like
IOREQ_TYPE_VCPU_SYNC_REGS? You could send it to QEMU beforeIOREQ_TYPE_VMWARE_PORT. Actually this solution looks very imilar to Alex's suggestion.
Quoted 4 lines
I can, it is just slower. This would require 2 new types. 1 for regs to QEMU, 1 for regs from QEMU. So instead of 1 round trip (Xen to QEMU to Xen), you now have 3 (Xen to QEMU (regs to QEMU) to Xen, Xen to QEMU (PIO) to Xen, Xen to QEMU (regs from QEMU) to Xen).
This is not an high performance device, is it?
In any case I agree it would be better to avoid it.
I wonder if we could send both ioreqs at once from Xen and back from QEMU. Or maybe append the registers to IOREQ_TYPE_VMWARE_PORT, changing the size of ioreq_t only for this ioreq type.
Another maybe simpler possibility would be introducing a union in ioreq_t with the registers.
Anything would be OK for me but I would like to see the registers being passes explicitely by Xen rather than "hiding" them into other ioreq fields.
Quoted 36 lines
Quoted 35 lines
Quoted 35 lines
Quoted 3 lines
If any case you should spend a
few more words on why you are doing this.Sure. Will add some form of the above as part of the commit message.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
xen-hvm.c +17
-0+if (!xen_opaque_env) { + xen_opaque_env =g_malloc (sizeof (CPUX86State)); + } + env = xen_opaque_env; + env->regs[R_EAX ] = (uint32_t )(req->addr >>32 ); + env->regs[R_EBX ] = (uint32_t )(req->addr); + env->regs[R_ECX ] = req->count; + env->regs[R_EDX ] = req->size; + env->regs[R_ESI ] = (uint32_t )(req->data >>32 ); + env->regs[R_EDI ] = (uint32_t )(req->data); +handle_ioreq (&fake_req); + req->addr = ((uint64_t )fake_req.data <<32 ) | + (uint32_t )env->regs[R_EBX ]; + req->count = env->regs[R_ECX ]; + req->size = env->regs[R_EDX ]; + req->data = ((uint64_t )env->regs[R_ESI ] <<32 ) | + (uint32_t )env->regs[R_EDI ];Quoted 3 lines
Quoted 3 lines
This code could be moved to a separate helper function called by
handle_ioreq.Ok.
-Don Slutz
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
xen-hvm.c +5
-0+ } else { +handle_ioreq (req); + } +#else handle_ioreq (req); +#endif
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Quoted 67 lines · Stefano Stabellini
Quoted 66 lines · Donald Christopher
Quoted 20 lines · Stefano Stabellini
Quoted 19 lines · Don Slutz
Quoted 18 lines · Stefano Stabellini
Quoted 17 lines · Stefano Stabellini
Quoted 4 lines · Don Slutz
This adds synchronisation of the vcpu registers
between Xen and QEMU.Signed-off-by Don Slutz <[email protected]>[...]
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 859
Quoted 8 lines
xen-hvm.c +1
-0@@ -857,14 +857,48 @@ static void cpu_handle_ioreq(void *opaque)handle_buffered_iopage (state);if (req) { +#ifdef IOREQ_TYPE_VMWARE_PORT Is there any reason to #ifdef this code?
Couldn't we just always build it in QEMU?Quoted 5 lines
Quoted 2 lines
This allows QEMU 2.2 (or later) to build on a system that has Xen 4.5 or earlier installed; and work.
I would rather remove the #ifdef from here and add any necessary compatibility stuff to
include/hw/xen/xen_common.h.Ok, will do.
Quoted 26 lines
Quoted 26 lines
Quoted 4 lines
Quoted 4 lines
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 860
Quoted 1 line
xen-hvm.c +1
-0+if (req->type ==IOREQ_TYPE_VMWARE_PORT ) {I think it would make more sense to check for
IOREQ_TYPE_VMWARE_PORTfrom withinhandle_ioreq.Ok, I can move it.
Quoted 10 lines
Quoted 9 lines
xen-hvm.c static void cpu_handle_ioreq(void *opaque) · line 869
Quoted 9 lines
xen-hvm.c +9
-0+CPUX86State *env; +ioreq_t fake_req = { + .type =IOREQ_TYPE_PIO , + .addr = (uint16_t )req->size, + .size =4 , + .dir =IOREQ_READ , + .df =0 , + .data_is_ptr =0 , + };Why do you need a fake req?
To transport the 6 VCPU registers (only 32bits of them) that
vmport.cneeds to do it's work.Quoted 1 line
Couldn't Xen send the real req instead?
Yes, but then a 2nd exchange between QEMU and Xen would be needed to fetch the 6 VCPU registers. The ways I know of to fetch the VCPU registers from Xen, all need many cycles to do their work and return
a lot of data that is not needed.Quoted 5 lines
Quoted 3 lines
The other option that I have considered was to extend the
ioreq_ttype to have room for these registers, but that reduces by almost half the maximum number of VCPUs that are supported (They all live on 1 page).Urgh. Now that I understand the patch better is think it's horrible, no offense :-)
None taken.
Quoted 5 lines
Why don't you add another new ioreq type to send out the vcpu state? Something like
IOREQ_TYPE_VCPU_SYNC_REGS? You could send it to QEMU beforeIOREQ_TYPE_VMWARE_PORT. Actually this solution looks very imilar to Alex's suggestion.
Quoted 5 lines
Quoted 4 lines
I can, it is just slower. This would require 2 new types. 1 for regs to QEMU, 1 for regs from QEMU. So instead of 1 round trip (Xen to QEMU to Xen), you now have 3 (Xen to QEMU (regs to QEMU) to Xen, Xen to QEMU (PIO) to Xen, Xen to QEMU (regs from QEMU) to Xen).
This is not an high performance device, is it?
Depends on how you view mouse device speed.
Quoted 4 lines
In any case I agree it would be better to avoid it.
I wonder if we could send both ioreqs at once from Xen and back from QEMU. Or maybe append the registers toIOREQ_TYPE_VMWARE_PORT, changing the size ofioreq_tonly for this ioreq type.
No idea how do do this since this is an array in a shared page.
Quoted 6 lines
Another maybe simpler possibility would be introducing a union in
ioreq_twith the registers.
Anything would be OK for me but I would like to see the registers being passes explicitely by Xen rather than "hiding" them into other ioreq fields.
I considered a union, but this can be a issue with older QEMU and newer Xen. Since it appears that you care, I will add a new struct for this. The problem is that it is a "union" and so must match on the common fields.
-Don Slutz
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 3 lines
If any case you should spend a
few more words on why you are doing this.Sure. Will add some form of the above as part of the commit message.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
xen-hvm.c +17
-0+if (!xen_opaque_env) { + xen_opaque_env =g_malloc (sizeof (CPUX86State)); + } + env = xen_opaque_env; + env->regs[R_EAX ] = (uint32_t )(req->addr >>32 ); + env->regs[R_EBX ] = (uint32_t )(req->addr); + env->regs[R_ECX ] = req->count; + env->regs[R_EDX ] = req->size; + env->regs[R_ESI ] = (uint32_t )(req->data >>32 ); + env->regs[R_EDI ] = (uint32_t )(req->data); +handle_ioreq (&fake_req); + req->addr = ((uint64_t )fake_req.data <<32 ) | + (uint32_t )env->regs[R_EBX ]; + req->count = env->regs[R_ECX ]; + req->size = env->regs[R_EDX ]; + req->data = ((uint64_t )env->regs[R_ESI ] <<32 ) | + (uint32_t )env->regs[R_EDI ];Quoted 3 lines
Quoted 3 lines
This code could be moved to a separate helper function called by
handle_ioreq.Ok.
-Don Slutz
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
xen-hvm.c +5
-0+ } else { +handle_ioreq (req); + } +#else handle_ioreq (req); +#endif
Re: [Qemu-devel] [Xen-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
In reply to Stefano StabelliniQuoted 3 lines · Stefano Stabellini
I wonder if we could send both ioreqs at once from Xen and back from QEMU. Or maybe append the registers to
IOREQ_TYPE_VMWARE_PORT, changing the size ofioreq_tonly for this ioreq type.
Random idea: Why new add a IOREQ_TYPE_FULL_STATE which would be issued for these ports and let qemu decode the fact that it is vmware internally? That might be a more generically useful interface in the future?
WRT to fitting all the register state in the current sized request, you could declare that this new thing takes multiple slots.
Also, I may be wrong, but I thought most IOREQs were synchronous so only one slot was ever used? The buffered ioreq stuff has a separate ring (or uses a different part of the page, or something). I might be talking nonsense here though ;-)
Ian.
Re: [Qemu-devel] [Xen-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
Quoted 10 lines · Ian Campbell
Quoted 3 lines · Stefano Stabellini
I wonder if we could send both ioreqs at once from Xen and back from QEMU. Or maybe append the registers to
IOREQ_TYPE_VMWARE_PORT, changing the size ofioreq_tonly for this ioreq type.Random idea: Why new add a
IOREQ_TYPE_FULL_STATEwhich would be issued for these ports and let qemu decode the fact that it is vmware internally? That might be a more generically useful interface in the future?
Quoted 7 lines
WRT to fitting all the register state in the current sized request, you could declare that this new thing takes multiple slots.
Also, I may be wrong, but I thought most IOREQs were synchronous so only one slot was ever used? The buffered ioreq stuff has a separate ring (or uses a different part of the page, or something). I might be talking nonsense here though ;-)
There really isn't a concept of "CPU associated with an IOREQ" outside of two very special cases, LAPIC emulation and vmport. LAPIC emulation really belongs closer to the CPU and given V-APIC, it's gotten moved into hardware anyway. vmport is just a hack VMware made.
I think it's better to think of it as a VMware specific hypercall and terminate the IOREQ within the hypervisor. Passing a decoded version of the request to QEMU is fine but passing the full CPU state as part of an IOREQ_TYPE_FULL_STATE is not very useful. It's just an IOREQ_TYPE_VMPORT with more information than is needed.
Regards,
Anthony Liguori
Quoted 8 lines
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH 1/1] xen-hvm.c: Add support for Xen access to vmport
In reply to Stefano StabelliniQuoted 95 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stefano Stabellini
Sent: 01 October 2014 10:20
To: Slutz, Donald Christopher
Cc: [email protected]; Stefano Stabellini; Markus Armbruster; Marcel Apfelbaum; Alexander Graf; [email protected]; Michael S. Tsirkin; Anthony Liguori; Andreas Färber
Subject: Re: [Qemu-devel] [PATCH 1/1]xen-hvm.c: Add support for Xen access to vmportQuoted 8 lines · Donald Christopher
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Don Slutz
Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Stefano Stabellini
Quoted 3 lines · Don Slutz
This adds synchronisation of the vcpu registers
between Xen and QEMU.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Signed-off-by Don Slutz <[email protected]>[...]
xen-hvm.c static void cpu_handle_ioreq(void
Quoted 5 lines
xen-hvm.c +0
-0@@ -857,14 +857,48 @@ static void cpu_handle_ioreq(void*opaque)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
xen-hvm.c static void cpu_handle_ioreq(void · line 859
Quoted 3 lines
xen-hvm.c +1
-0handle_buffered_iopage (state);if (req) { +#ifdef IOREQ_TYPE_VMWARE_PORT Is there any reason to #ifdef this code?
Couldn't we just always build it in QEMU?Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
This allows QEMU 2.2 (or later) to build on a system that has Xen 4.5 or earlier installed; and work.
I would rather remove the #ifdef from here and add any necessary compatibility stuff to
include/hw/xen/xen_common.h.Ok, will do.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
xen-hvm.c static void cpu_handle_ioreq(void · line 860
Quoted 1 line
xen-hvm.c +1
-0+if (req->type ==IOREQ_TYPE_VMWARE_PORT ) {I think it would make more sense to check for
IOREQ_TYPE_VMWARE_PORTQuoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
Quoted 2 lines
from within
handle_ioreq.Ok, I can move it.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
xen-hvm.c +9
-0+CPUX86State *env; +ioreq_t fake_req = { + .type =IOREQ_TYPE_PIO , + .addr = (uint16_t )req->size, + .size =4 , + .dir =IOREQ_READ , + .df =0 , + .data_is_ptr =0 , + };Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Why do you need a fake req?
To transport the 6 VCPU registers (only 32bits of them) that
vmport.cneeds to do it's work.Quoted 1 line
Couldn't Xen send the real req instead?
Yes, but then a 2nd exchange between QEMU and Xen would be
needed
Quoted 1 line
Quoted 1 line
Quoted 1 line
to fetch the 6 VCPU registers. The ways I know of to fetch the VCPU
registers
Quoted 13 lines
Quoted 8 lines
Quoted 6 lines
from Xen, all need many cycles to do their work and return a lot of data that is not needed.
The other option that I have considered was to extend the
ioreq_ttype to have room for these registers, but that reduces by almost half the maximum number of VCPUs that are supported (They all live on 1 page).Urgh. Now that I understand the patch better is think it's horrible, no offense :-)
None taken.
Quoted 2 lines
Why don't you add another new ioreq type to send out the vcpu state? Something like
IOREQ_TYPE_VCPU_SYNC_REGS? You could send it toQEMU
Quoted 1 line
Quoted 1 line
before
IOREQ_TYPE_VMWARE_PORT. Actually this solution looks veryimilar
Quoted 7 lines
Quoted 2 lines
to Alex's suggestion.
I can, it is just slower. This would require 2 new types. 1 for regs to QEMU, 1 for regs from QEMU. So instead of 1 round trip (Xen to QEMU to Xen), you now have 3 (Xen to QEMU (regs to QEMU) to Xen, Xen to QEMU (PIO) to Xen, Xen to QEMU (regs from QEMU) to Xen).
This is not an high performance device, is it?
Quoted 11 lines
In any case I agree it would be better to avoid it.
I wonder if we could send both ioreqs at once from Xen and back from QEMU. Or maybe append the registers toIOREQ_TYPE_VMWARE_PORT, changing
the size ofioreq_tonly for this ioreq type.
Another maybe simpler possibility would be introducing a union inioreq_twith the registers.
Anything would be OK for me but I would like to see the registers being passes explicitely by Xen rather than "hiding" them into other ioreq fields.
Changing the size of ioreq_t would be a bit of a nightmare: The structs are laid out in an array indexed by vcpu and shared by QEMU and Xen.
Paul
Quoted 37 lines
Quoted 37 lines
Quoted 36 lines
Quoted 36 lines
Quoted 4 lines
If any case you should spend a
few more words on why you are doing this.Sure. Will add some form of the above as part of the commit message.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
xen-hvm.c +17
-0+if (!xen_opaque_env) { + xen_opaque_env =g_malloc (sizeof (CPUX86State)); + } + env = xen_opaque_env; + env->regs[R_EAX ] = (uint32_t )(req->addr >>32 ); + env->regs[R_EBX ] = (uint32_t )(req->addr); + env->regs[R_ECX ] = req->count; + env->regs[R_EDX ] = req->size; + env->regs[R_ESI ] = (uint32_t )(req->data >>32 ); + env->regs[R_EDI ] = (uint32_t )(req->data); +handle_ioreq (&fake_req); + req->addr = ((uint64_t )fake_req.data <<32 ) | + (uint32_t )env->regs[R_EBX ]; + req->count = env->regs[R_ECX ]; + req->size = env->regs[R_EDX ]; + req->data = ((uint64_t )env->regs[R_ESI ] <<32 ) | + (uint32_t )env->regs[R_EDI ];Quoted 3 lines
Quoted 3 lines
This code could be moved to a separate helper function called by
handle_ioreq.Ok.
-Don Slutz
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
xen-hvm.c +5
-0+ } else { +handle_ioreq (req); + } +#else handle_ioreq (req); +#endif