Skip unneeded VMENTRY & VMEXIT
cover Skip unneeded VMENTRY & VMEXIT
Using a new enough QEMU that has:
commit 7665d6ba98e20fb05c420de947c1750fd47e5c07
Author: Paul Durrant <[email protected]> Date: Tue Jan 20 11:06:19 2015 +0000
Xen: Use the ioreq-server API when available
means that hvmloader and the guest will do pci config accesses that will not be sent to QEMU. However hvm_complete_assist_req() (which is the routine that does the work) returns a 1 which hvm_send_assist_req() returns to the caller which means that the request was sent to QEMU and need to be waited for.
This is not the case. hvm_complete_assist_req() has called on hvm_io_assist() which has changed the io_state from HVMIO_awaiting_completion to HVMIO_completed if needed. But hvmemul_do_io() thinks that it needs to wait on the IOREQ_READ case, and returns X86EMUL_RETRY.
[PATCH 1/5] DEBUG: xentrace: Add debug of HANDLE_PIO
-- No need to apply
[PATCH 2/5] xentrace: Adjust IOPORT & MMIO format
-- Simple bugfix. xentrace_format is not converting these correctly
[PATCH 3/5] hvmemul_do_io: If the send to the ioreq server failed do
-- Simple bugfix. Do the same thing as when hvm_has_dm() returns
a zero.
[PATCH 4/5] hvm_complete_assist_req: We should not be able to get
-- This ASSERT was sugested by Paul Durrant. Since I was in the
file, just add it.
[PATCH 5/5] hvm_complete_assist_req: Tell caller we failed to send
-- The real fix. Does depend on [PATCH 3/5] hvmemul_do_io: If the send ...
Here is the before xentrace output using the "[PATCH 1/5] DEBUG:
xentrace: Add debug of HANDLE_PIO" (which I do not expect to be applied. It is first because that is the order you need to use to reproduce the xentrace output):
CPU0 685992932190 (+ 2292) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU0 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 5 ret = 0 ] CPU0 685992934938 (+ 2748) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU0 685992935526 (+ 588) VMENTRY CPU0 685992937650 (+ 2124) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU0 0 (+ 0) IOPORT_READ [ port = 0x0cfe, data = 0x00000000 ] CPU0 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 1 ] CPU0 685992940248 (+ 2598) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU0 685992940968 (+ 720) VMENTRY
And after:
CPU2 1028654638584 (+ 2388) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU2 0 (+ 0) IOPORT_READ [ port = 0x0cfe, data = 0xffffffff ] CPU2 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 1 ] CPU2 1028654641932 (+ 3348) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU2 1028654642586 (+ 654) VMENTRY
Don Slutz (5):
DEBUG: xentrace: Add debug of HANDLE_PIO
xentrace: Adjust IOPORT & MMIO format
hvmemul_do_io: If the send to the ioreq server failed do not retry.
hvm_complete_assist_req: We should not be able to get here on
IOREQ_TYPE_PCI_CONFIG
hvm_complete_assist_req: Tell caller we failed to send
tools/xentrace/formats | 10 ++++++---- xen/arch/x86/hvm/emulate.c | 4 ++++ xen/arch/x86/hvm/hvm.c | 3 ++- xen/arch/x86/hvm/io.c | 4 ++++ xen/include/asm-x86/hvm/trace.h | 2 +- xen/include/public/trace.h | 2 ++ 6 files changed, 19 insertions(+), 6 deletions(-)
Signature · 1 line
1.8.4
PATCH 1/5 DEBUG: xentrace: Add debug of HANDLE_PIO
This is not needed. However I provide it as it is used to generate data in the cover letter.
--- tools/xentrace/formats | 2 ++ xen/arch/x86/hvm/io.c | 4 ++++ xen/include/asm-x86/hvm/trace.h | 2 +- xen/include/public/trace.h | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-)
tools/xentrace/formats +2 -0
@@ -80,6 +80,8 @@ 0x00082021 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) NPF [ gpa = 0x%(2)08x%(1)08x mfn = 0x%(4)08x%(3)08x qual = 0x%(5)04x p2mt = 0x%(6)04x ] 0x00082023 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) TRAP [ vector = 0x%(1)02x ] +0x00082040 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) HANDLE_PIO [ port = 0x%(1)04x size = %(2)d dir = %(3)d io_state = %(4)d ret = %(5)d ] + 0x0010f001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) page_grant_map [ domid = %(1)d ] 0x0010f002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) page_grant_unmap [ domid = %(1)d ] 0x0010f003 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) page_grant_transfer [ domid = %(1)d ]
xen/arch/x86/hvm/io.c +4 -0
@@ -155,7 +155,10 @@ int handle_pio(uint16_t port, unsigned int size, int dir)break ;case X86EMUL_RETRY :if ( vio->io_state != HVMIO_awaiting_completion ) + { +HVMTRACE_5D (HANDLE_PIO , port, size, dir, vio->io_state,0 );return 0 ; + }/* Completion in hvm_io_assist() with no re-emulation required. */ ASSERT (dir ==IOREQ_READ ); vio->io_state = HVMIO_handle_pio_awaiting_completion;
@@ -166,6 +169,7 @@ int handle_pio(uint16_t port, unsigned int size, int dir)break ; } +HVMTRACE_5D (HANDLE_PIO , port, size, dir, vio->io_state,1 );return 1 ; }
xen/include/asm-x86/hvm/trace.h +1 -1
@@ -54,7 +54,7 @@#define DO_TRC_HVM_TRAP DEFAULT_HVM_MISC#define DO_TRC_HVM_TRAP_DEBUG DEFAULT_HVM_MISC#define DO_TRC_HVM_VLAPIC DEFAULT_HVM_MISC - +#define DO_TRC_HVM_HANDLE_PIO DEFAULT_HVM_MISC#define TRC_PAR_LONG (par) ((par)&0xFFFFFFFF),((par)>>32)
xen/include/public/trace.h +2 -0
@@ -228,6 +228,8 @@#define TRC_HVM_TRAP_DEBUG (TRC_HVM_HANDLER + 0x24)#define TRC_HVM_VLAPIC (TRC_HVM_HANDLER + 0x25) +#define TRC_HVM_HANDLE_PIO (TRC_HVM_HANDLER + 0x40) +#define TRC_HVM_IOPORT_WRITE (TRC_HVM_HANDLER + 0x216)#define TRC_HVM_IOMEM_WRITE (TRC_HVM_HANDLER + 0x217)
Signature · 1 line
1.8.4
PATCH 2/5 xentrace: Adjust IOPORT & MMIO format
In reply to Don SlutzThe 1st item is not data, but the port (address).
The 2nd item is the data.
--- tools/xentrace/formats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/xentrace/formats +4 -4
@@ -68,10 +68,10 @@ 0x00082014 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) INVLPG [ is invlpga? = %(1)d, virt = 0x%(2)08x ] 0x00082114 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) INVLPG [ is invlpga? = %(1)d, virt = 0x%(3)08x%(2)08x ] 0x00082015 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) MCE -0x00082016 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) IOPORT_READ [ data = 0x%(1)04x ] -0x00082216 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) IOPORT_WRITE [ data = 0x%(1)04x ] -0x00082017 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) MMIO_READ [ data = 0x%(1)04x ] -0x00082217 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) MMIO_WRITE [ data = 0x%(1)04x ] +0x00082016 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) IOPORT_READ [ port = 0x%(1)04x, data = 0x%(2)08x ] +0x00082216 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) IOPORT_WRITE [ port = 0x%(1)04x, data = 0x%(2)08x ] +0x00082017 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) MMIO_READ [ port = 0x%(1)08x, data = 0x%(2)08x ] +0x00082217 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) MMIO_WRITE [ port = 0x%(1)08x, data = 0x%(2)08x ] 0x00082018 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) CLTS 0x00082019 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) LMSW [ value = 0x%(1)08x ] 0x00082119 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) LMSW [ value = 0x%(2)08x%(1)08x ]
Signature · 1 line
1.8.4
PATCH 3/5 hvmemul_do_io: If the send to the ioreq server failed do not retry.
In reply to Don SlutzI.E. do just what no backing DM does.
--- xen/arch/x86/hvm/emulate.c | 4 ++++ 1 file changed, 4 insertions(+)
xen/arch/x86/hvm/emulate.c +4 -0
@@ -228,7 +228,11 @@ static int hvmemul_do_io( { rc =X86EMUL_RETRY ;if ( !hvm_send_assist_req (&p) ) + { +/* Since the send failed, do not retry */ + rc =X86EMUL_OKAY ; vio->io_state = HVMIO_none; + }else if ( p_data ==NULL ) rc =X86EMUL_OKAY ; }
Signature · 1 line
1.8.4
Re: [PATCH 3/5] hvmemul_do_io: If the send to the ioreq server failed do not retry.
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 01:52, <[email protected]> wrote:
I.E. do just what no backing DM does.
_If_ this is correct, the if() modified here should be folded with the one a few lines up. But looking at the description of the commit that introduced this (bac0999325 "x86 hvm: Do not incorrectly retire an instruction emulation...", almost immediately modified by f20f3c8ece "x86 hvm: On failed hvm_send_assist_req(), io emulation...") I doubt this is really what we want, or at the very least your change description should explain what was wrong with the original commit.
Jan
Quoted 16 lines
xen/arch/x86/hvm/emulate.c +4
-0@@ -228,7 +228,11 @@ static int hvmemul_do_io( { rc =X86EMUL_RETRY ;if ( !hvm_send_assist_req (&p) ) + { +/* Since the send failed, do not retry */ + rc =X86EMUL_OKAY ; vio->io_state = HVMIO_none; + }else if ( p_data ==NULL ) rc =X86EMUL_OKAY ; }Signature · 1 line
1.8.4
Re: [PATCH 3/5] hvmemul_do_io: If the send to the ioreq server failed do not retry.
Quoted 5 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 01:52, <[email protected]> wrote:
I.E. do just what no backing DM does.
_If_ this is correct, the
if()modified here should be folded with the one a few lines up.
Ok, will fold with the one a few lines up. As expected without this change the guest will hang (more details below).
Quoted 7 lines
But looking at the description of the commit that introduced this (
bac0999325"x86 hvm: Do not incorrectly retire an instruction emulation...", almost immediately modified byf20f3c8ece"x86 hvm: On failedhvm_send_assist_req(), io emulation...") I doubt this is really what we want, or at the very least your change description should explain what was wrong with the original commit.
Looking at these 2 commits, it looks to me like I need to handle these cases also. So it looks like having hvm_send_assist_req() return an int 0, 1, & 2 is the simpler way. V2 on the way soon.
Which is the better codding style:
1) Add #defines for the return values?
2) Just use numbers?
3) Invert the sense 0 means worked, 1 is shutdown_deferral or domain_crash, 2 is hvm_complete_assist_req()?
I.E. (for just adding 2):
xen/arch/x86/hvm/emulate.c +12 -3
@@ -227,10 +227,19 @@ static int hvmemul_do_io(else { rc =X86EMUL_RETRY ; -if ( !hvm_send_assist_req (&p) ) - vio->io_state = HVMIO_none; -else if ( p_data ==NULL ) +switch (hvm_send_assist_req (&p) ) + { +case 2 : rc =X86EMUL_OKAY ; +/* fall through */ +case 0 : + vio->io_state = HVMIO_none; +break ; +case 1 : +if ( p_data ==NULL ) + rc =X86EMUL_OKAY ; +break ; + } }
???
I would think it would be good for the code using hvm_has_dm() to also call on hvm_complete_assist_req(). hvm_has_dm() is a subset of the cases that hvm_select_ioreq_server() checks for.
Based on this, I think it would be better to remove the call on hvm_has_dm() instead of adding a call to hvm_complete_assist_req().
-Don SlutzP.S. Details for hang:
Using:
static bool_t hvm_complete_assist_req(ioreq_t *p) {
+ HVMTRACE_1D(COMPLETE_ASSIST, p->type);
...
):
I get the trace:
CPU1 745455716325 (+ 1362) VMEXIT [ exitcode = 0x0000001e, rIP
= 0x00101581 ]
CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455717846 (+ 1521) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455718209 (+ 363) VMENTRY CPU1 745455719568 (+ 1359) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455721083 (+ 1515) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455721422 (+ 339) VMENTRY CPU1 745455722781 (+ 1359) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455724299 (+ 1518) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455724656 (+ 357) VMENTRY CPU1 745455726009 (+ 1353) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455727539 (+ 1530) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455727899 (+ 360) VMENTRY CPU1 745455729276 (+ 1377) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455730803 (+ 1527) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455731163 (+ 360) VMENTRY CPU1 745455732525 (+ 1362) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1
io_state = 0 ret = 0 ]
CPU1 745455734049 (+ 1524) vlapic_accept_pic_intr [ i8259_target =
1, accept_pic_int = 1 ]
CPU1 745455734385 (+ 336) VMENTRY
...
Quoted 21 lines
Jan
Quoted 16 lines
xen/arch/x86/hvm/emulate.c +4
-0@@ -228,7 +228,11 @@ static int hvmemul_do_io( { rc =X86EMUL_RETRY ;if ( !hvm_send_assist_req (&p) ) + { +/* Since the send failed, do not retry */ + rc =X86EMUL_OKAY ; vio->io_state = HVMIO_none; + }else if ( p_data ==NULL ) rc =X86EMUL_OKAY ; }Signature · 1 line
1.8.4
Re: [PATCH 3/5] hvmemul_do_io: If the send to the ioreq server failed do not retry.
Quoted 19 lines · Don Slutz
Quoted 5 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 01:52, <[email protected]> wrote:
I.E. do just what no backing DM does.
_If_ this is correct, the
if()modified here should be folded with the one a few lines up.Ok, will fold with the one a few lines up. As expected without this change the guest will hang (more details below).
Quoted 7 lines
But looking at the description of the commit that introduced this (
bac0999325"x86 hvm: Do not incorrectly retire an instruction emulation...", almost immediately modified byf20f3c8ece"x86 hvm: On failedhvm_send_assist_req(), io emulation...") I doubt this is really what we want, or at the very least your change description should explain what was wrong with the original commit.
Quoted 4 lines
Looking at these 2 commits, it looks to me like I need to handle these cases also. So it looks like having
hvm_send_assist_req()return an int 0, 1, & 2 is the simpler way. V2 on the way soon.
Soon after sending this, I came up with a 2nd way for fix. Change hvm_has_dm() to use hvm_select_ioreq_server(). Then the correct answer will be found, and so will not retry.
To avoid 2 calls to hvm_select_ioreq_server(), it makes
snes to me to return s. Also adding a call to hvm_complete_assist_req() would help. So based on all this is is a possible v2:
commit 24eb5a839427ba80c1adf16ab656c19729f906be
Author: Don Slutz <[email protected]> Date: Fri Jan 30 13:54:43 2015 -0500
fixup use of hvm_send_assist_req
xen/arch/x86/hvm/emulate.c +6 -2
@@ -218,8 +218,11 @@ static int hvmemul_do_io( vio->io_state = HVMIO_handle_mmio_awaiting_completion;break ;case X86EMUL_UNHANDLEABLE : + { +void *s =hvm_has_dm (curr->domain, &p); +/* If there is no backing DM, just ignore accesses */ -if ( !hvm_has_dm (curr->domain) ) +if ( !s ) { rc =X86EMUL_OKAY ; vio->io_state = HVMIO_none;
@@ -227,11 +230,12 @@ static int hvmemul_do_io(else { rc =X86EMUL_RETRY ; -if ( !hvm_send_assist_req (&p) ) +if ( !hvm_send_assist_req (s, &p) ) vio->io_state = HVMIO_none;else if ( p_data ==NULL ) rc =X86EMUL_OKAY ; } + }break ;default :BUG ();
xen/arch/x86/hvm/hvm.c +38 -2
@@ -2507,9 +2507,45 @@ int hvm_buffered_io_send(ioreq_t *p)return 1 ; } -bool_t hvm_has_dm (struct domain *d) +static bool_t hvm_complete_assist_req (ioreq_t *p) { -return !list_empty (&d->arch.hvm_domain.ioreq_server.list); +HVMTRACE_1D (COMPLETE_ASSIST , p->type); +ASSERT (p->type !=IOREQ_TYPE_PCI_CONFIG ); +switch ( p->type ) + { +case IOREQ_TYPE_COPY : +case IOREQ_TYPE_PIO : +if ( p->dir ==IOREQ_READ ) + { +if ( !p->data_is_ptr ) + p->data = ~0ul ; +else + { +int i, step = p->df ? -p->size : p->size; +uint32_t data = ~0 ; + +for ( i =0 ; i < p->count; i++ ) +hvm_copy_to_guest_phys (p->data + step * i, &data, + p->size); + } + } +/* FALLTHRU */ +default : + p->state =STATE_IORESP_READY ; +hvm_io_assist (p); +break ; + } + +return 1 ; +} + +void *hvm_has_dm (struct domain *d,ioreq_t *p) +{ +struct hvm_ioreq_server *s =hvm_select_ioreq_server (d, p); + +if ( !s ) +hvm_complete_assist_req (p); +return (void *)s; } bool_t hvm_send_assist_req_to_ioreq_server(struct hvm_ioreq_server *s,
@@ -2571,44 +2607,15 @@ bool_t
hvm_send_assist_req_to_ioreq_server(struct hvm_ioreq_server *s,
return 0;
}
-static bool_t hvm_complete_assist_req(ioreq_t *p) -{
- HVMTRACE_1D(COMPLETE_ASSIST, p->type);
- ASSERT(p->type != IOREQ_TYPE_PCI_CONFIG);
- switch ( p->type )
- {
- case IOREQ_TYPE_COPY:
- case IOREQ_TYPE_PIO:- if ( p->dir == IOREQ_READ )
- {
- if ( !p->data_is_ptr )
- p->data = ~0ul;
- else
- {
- int i, step = p->df ? -p->size : p->size;
- uint32_t data = ~0;
-
- for ( i = 0; i < p->count; i++ )
- hvm_copy_to_guest_phys(p->data + step * i, &data,
- p->size);
- }
- }
- /* FALLTHRU */
- default:
- p->state = STATE_IORESP_READY; - hvm_io_assist(p); - break;
- }
-
- return 0; /* implicitly bins the i/o operation */
-}
-
-bool_t hvm_send_assist_req(ioreq_t *p)
+bool_t hvm_send_assist_req(void *vs, ioreq_t *p)
{
- struct hvm_ioreq_server *s =hvm_select_ioreq_server(current->domain, p);
+ struct hvm_ioreq_server *s = vs;
if ( !s )
- return hvm_complete_assist_req(p);
+ {
+ hvm_complete_assist_req(p);
+ return 1;
+ }
return hvm_send_assist_req_to_ioreq_server(s, p);
}
xen/include/asm-x86/hvm/hvm.h +2 -2
@@ -228,7 +228,7 @@ int hvm_vcpu_cacheattr_init(struct vcpu *v);void hvm_vcpu_cacheattr_destroy (struct vcpu *v);void hvm_vcpu_reset_state (struct vcpu *v,uint16_t cs,uint16_t ip); -bool_t hvm_send_assist_req (ioreq_t *p); +bool_t hvm_send_assist_req (void *s,ioreq_t *p);void hvm_broadcast_assist_req (ioreq_t *p);void hvm_get_guest_pat (struct vcpu *v,u64 *guest_pat);
@@ -359,7 +359,7 @@ void hvm_hypervisor_cpuid_leaf(uint32_t sub_idx,void hvm_cpuid (unsigned int input,unsigned int *eax,unsigned int *ebx,unsigned int *ecx,unsigned int *edx);void hvm_migrate_timers (struct vcpu *v); -bool_t hvm_has_dm (struct domain *d); +void *hvm_has_dm (struct domain *d,ioreq_t *p);bool_t hvm_io_pending (struct vcpu *v);void hvm_do_resume (struct vcpu *v);void hvm_migrate_pirqs (struct vcpu *v);
-Don Slutz
Quoted 135 lines
Which is the better codding style:
1) Add #defines for the return values?
2) Just use numbers?
3) Invert the sense 0 means worked, 1 isshutdown_deferralordomain_crash, 2 ishvm_complete_assist_req()?I.E. (for just adding 2):
xen/arch/x86/hvm/emulate.c +12
-3@@ -227,10 +227,19 @@ static int hvmemul_do_io(else { rc =X86EMUL_RETRY ; -if ( !hvm_send_assist_req (&p) ) - vio->io_state = HVMIO_none; -else if ( p_data ==NULL ) +switch (hvm_send_assist_req (&p) ) + { +case 2 : rc =X86EMUL_OKAY ; +/* fall through */ +case 0 : + vio->io_state = HVMIO_none; +break ; +case 1 : +if ( p_data ==NULL ) + rc =X86EMUL_OKAY ; +break ; + } }???
I would think it would be good for the code using
hvm_has_dm()to also call onhvm_complete_assist_req().hvm_has_dm()is a subset of the cases thathvm_select_ioreq_server()checks for.Based on this, I think it would be better to remove the call on
hvm_has_dm()instead of adding a call tohvm_complete_assist_req().-Don Slutz
P.S. Details for hang:Using:
static
bool_thvm_complete_assist_req(ioreq_t *p){
+HVMTRACE_1D(COMPLETE_ASSIST, p->type);
...
):I get the trace:
CPU1 745455716325 (+ 1362) VMEXIT [ exitcode =
0x0000001e, rIP
=0x00101581]CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455717846 (+ 1521) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455718209 (+ 363) VMENTRY CPU1 745455719568 (+ 1359) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455721083 (+ 1515) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455721422 (+ 339) VMENTRY CPU1 745455722781 (+ 1359) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455724299 (+ 1518) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455724656 (+ 357) VMENTRY CPU1 745455726009 (+ 1353) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455727539 (+ 1530) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455727899 (+ 360) VMENTRY CPU1 745455729276 (+ 1377) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455730803 (+ 1527) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455731163 (+ 360) VMENTRY CPU1 745455732525 (+ 1362) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1
io_state= 0 ret = 0 ]
CPU1 745455734049 (+ 1524)vlapic_accept_pic_intr[i8259_target=
1,accept_pic_int= 1 ]
CPU1 745455734385 (+ 336) VMENTRY
...Quoted 21 lines
Jan
Quoted 16 lines
xen/arch/x86/hvm/emulate.c +4
-0@@ -228,7 +228,11 @@ static int hvmemul_do_io( { rc =X86EMUL_RETRY ;if ( !hvm_send_assist_req (&p) ) + { +/* Since the send failed, do not retry */ + rc =X86EMUL_OKAY ; vio->io_state = HVMIO_none; + }else if ( p_data ==NULL ) rc =X86EMUL_OKAY ; }Signature · 1 line
1.8.4
Re: [PATCH 3/5] hvmemul_do_io: If the send to the ioreq server failed do not retry.
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 20:19, <[email protected]> wrote:
Soon after sending this, I came up with a 2nd way for fix. Change
hvm_has_dm()to usehvm_select_ioreq_server(). Then the correct answer will be found, and so will not retry.To avoid 2 calls to
hvm_select_ioreq_server(), it makes
snes to me to return s. Also adding a call tohvm_complete_assist_req()would help. So based on all this is is a possible v2:
Looks reasonable (awaiting Paul's opinion though) except for mechanical aspects:
Quoted 31 lines
xen/arch/x86/hvm/hvm.c +22
-2@@ -2507,9 +2507,45 @@ int hvm_buffered_io_send(ioreq_t *p)return 1 ; } -bool_t hvm_has_dm (struct domain *d) +static bool_t hvm_complete_assist_req (ioreq_t *p) { -return !list_empty (&d->arch.hvm_domain.ioreq_server.list); +HVMTRACE_1D (COMPLETE_ASSIST , p->type); +ASSERT (p->type !=IOREQ_TYPE_PCI_CONFIG ); +switch ( p->type ) + { +case IOREQ_TYPE_COPY : +case IOREQ_TYPE_PIO : +if ( p->dir ==IOREQ_READ ) + { +if ( !p->data_is_ptr ) + p->data = ~0ul ; +else + { +int i, step = p->df ? -p->size : p->size; +uint32_t data = ~0 ; + +for ( i =0 ; i < p->count; i++ ) +hvm_copy_to_guest_phys (p->data + step * i, &data, + p->size); + } + } +/* FALLTHRU */
xen/arch/x86/hvm/hvm.c int hvm_buffered_io_send(ioreq_t *p) · line 2542
Quoted 10 lines
xen/arch/x86/hvm/hvm.c +10
-0+default : + p->state =STATE_IORESP_READY ; +hvm_io_assist (p); +break ; + } + +return 1 ; +} + +void *hvm_has_dm (struct domain *d,ioreq_t *p)
I can't see why this needs to return void * instead of a properly typed pointer.
Quoted 25 lines
xen/arch/x86/hvm/hvm.c +0
-21@@ -2571,44 +2607,15 @@ bool_t hvm_send_assist_req_to_ioreq_server(struct hvm_ioreq_server *s,return 0 ; } -static bool_t hvm_complete_assist_req (ioreq_t *p) -{ -HVMTRACE_1D (COMPLETE_ASSIST , p->type); -ASSERT (p->type !=IOREQ_TYPE_PCI_CONFIG ); -switch ( p->type ) - { -case IOREQ_TYPE_COPY : -case IOREQ_TYPE_PIO : -if ( p->dir ==IOREQ_READ ) - { -if ( !p->data_is_ptr ) - p->data = ~0ul ; -else - { -int i, step = p->df ? -p->size : p->size; -uint32_t data = ~0 ; - -for ( i =0 ; i < p->count; i++ ) -hvm_copy_to_guest_phys (p->data + step * i, &data, - p->size); - }
xen/arch/x86/hvm/hvm.c bool_t hvm_send_assist_req_to_ioreq_server(struct hvm_ioreq_server *s, · line 2604
Quoted 10 lines
xen/arch/x86/hvm/hvm.c +0
-10- } -/* FALLTHRU */ -default : - p->state =STATE_IORESP_READY ; -hvm_io_assist (p); -break ; - } - -return 0 ;/* implicitly bins the i/o operation */ -}
Moving hvm_has_dm() down here would make the patch smaller and hence quite a bit easier to review (as one doesn't need to manually check the differences between the much larger added/removed pieces of code.
Jan
Re: [PATCH 3/5] hvmemul_do_io: If the send to the ioreq server failed do not retry.
Quoted 21 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 20:19, <[email protected]> wrote:
Soon after sending this, I came up with a 2nd way for fix. Change
hvm_has_dm()to usehvm_select_ioreq_server(). Then the correct answer will be found, and so will not retry.To avoid 2 calls to
hvm_select_ioreq_server(), it makes
snes to me to return s. Also adding a call tohvm_complete_assist_req()would help. So based on all this is is a possible v2:Looks reasonable (awaiting Paul's opinion though) except for mechanical aspects:
Quoted 9 lines
xen/arch/x86/hvm/hvm.c +1
-1@@ -2507,9 +2507,45 @@ int hvm_buffered_io_send(ioreq_t *p)return 1 ; } -bool_t hvm_has_dm (struct domain *d) +static bool_t hvm_complete_assist_req (ioreq_t *p) {
...
Quoted 7 lines
xen/arch/x86/hvm/hvm.c int hvm_buffered_io_send(ioreq_t *p) · line 2542
Quoted 3 lines
xen/arch/x86/hvm/hvm.c +3
-0+} + +void *hvm_has_dm (struct domain *d,ioreq_t *p)I can't see why this needs to return void * instead of a properly typed pointer.
Using "struct hvm_ioreq_server *s" did not build:
In file included from /home/don/xen-master/xen/include/asm/hvm/irq.h:26:0,
from /home/don/xen-master/xen/include/asm/hvm/vpt.h:32,
from /home/don/xen-master/xen/include/asm/hvm/vlapic.h:27,
from /home/don/xen-master/xen/include/asm/hvm/vcpu.h:25,
from /home/don/xen-master/xen/include/asm/domain.h:7,
from /home/don/xen-master/xen/include/xen/domain.h:6,
from /home/don/xen-master/xen/include/xen/sched.h:10,
from x86_64/asm-offsets.c:10:/home/don/xen-master/xen/include/asm/hvm/hvm.h:231:35: error: 'struct hvm_ioreq_server' declared inside parameter list [-Werror] /home/don/xen-master/xen/include/asm/hvm/hvm.h:231:35: error: its scope is only this definition or declaration, which is probably not what you want [-Werror]
cc1: all warnings being treated as errors
So I went with void * to check the that the code would pass my unit testing.
No clue why I did not say:
+struct hvm_ioreq_server;
+bool_t hvm_send_assist_req(struct hvm_ioreq_server *s, ioreq_t *p);
Unless I hear otherwise, this is the way I will go.
Quoted 6 lines
Quoted 6 lines
xen/arch/x86/hvm/hvm.c +0
-2@@ -2571,44 +2607,15 @@ bool_t hvm_send_assist_req_to_ioreq_server(struct hvm_ioreq_server *s,return 0 ; } -static bool_t hvm_complete_assist_req (ioreq_t *p) -{
...
Quoted 8 lines
xen/arch/x86/hvm/hvm.c
Quoted 2 lines
xen/arch/x86/hvm/hvm.c +0
-2-return 0 ;/* implicitly bins the i/o operation */ -}Moving
hvm_has_dm()down here would make the patch smaller and hence quite a bit easier to review (as one doesn't need to manually check the differences between the much larger added/removed pieces of code.
Will do.
-Don Slutz
Quoted 2 lines
Jan
Re: [PATCH 3/5] hvmemul_do_io: If the send to the ioreq server failed do not retry.
In reply to Don SlutzQuoted 34 lines
-----Original Message-----
From: Don Slutz [mailto:[email protected]]
Sent: 30 January 2015 19:19
To: Don Slutz; Jan Beulich; Paul Durrant
Cc: Andrew Cooper; Ian Campbell; Wei Liu; George Dunlap; Ian Jackson; Stefano Stabellini; [email protected]; Keir (Xen.org)
Subject: Re: [PATCH 3/5]hvmemul_do_io: If the send to the ioreq server failed do not retry.Quoted 19 lines · Don Slutz
Quoted 5 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 01:52, <[email protected]> wrote:
I.E. do just what no backing DM does.
_If_ this is correct, the
if()modified here should be folded with the one a few lines up.Ok, will fold with the one a few lines up. As expected without this change the guest will hang (more details below).
Quoted 7 lines
But looking at the description of the commit that introduced this (
bac0999325"x86 hvm: Do not incorrectly retire an instruction emulation...", almost immediately modified byf20f3c8ece"x86 hvm: On failedhvm_send_assist_req(), io emulation...") I doubt this is really what we want, or at the very least your change description should explain what was wrong with the original commit.Quoted 4 lines
Looking at these 2 commits, it looks to me like I need to handle these cases also. So it looks like having
hvm_send_assist_req()return an int 0, 1, & 2 is the simpler way. V2 on the way soon.
Quoted 8 lines
Soon after sending this, I came up with a 2nd way for fix. Change
hvm_has_dm()to usehvm_select_ioreq_server(). Then the correct answer will be found, and so will not retry.To avoid 2 calls to
hvm_select_ioreq_server(), it makes
snes to me to return s. Also adding a call tohvm_complete_assist_req()would help. So based on all this is is a possible v2:
Yes, I think this approach does make a lot of sense.
Quoted 45 lines
commit
24eb5a839427ba80c1adf16ab656c19729f906beAuthor: Don Slutz <[email protected]> Date: Fri Jan 30 13:54:43 2015 -0500fixup use of
hvm_send_assist_reqSigned-off-by Don Slutz <[email protected]>xen/arch/x86/hvm/emulate.c +6
-2@@ -218,8 +218,11 @@ static int hvmemul_do_io( vio->io_state = HVMIO_handle_mmio_awaiting_completion;break ;case X86EMUL_UNHANDLEABLE : + { +void *s =hvm_has_dm (curr->domain, &p); +/* If there is no backing DM, just ignore accesses */ -if ( !hvm_has_dm (curr->domain) ) +if ( !s ) { rc =X86EMUL_OKAY ; vio->io_state = HVMIO_none;@@ -227,11 +230,12 @@ static int hvmemul_do_io(else { rc =X86EMUL_RETRY ; -if ( !hvm_send_assist_req (&p) ) +if ( !hvm_send_assist_req (s, &p) ) vio->io_state = HVMIO_none;else if ( p_data ==NULL ) rc =X86EMUL_OKAY ; } + }break ;default :BUG ();xen/arch/x86/hvm/hvm.c +0
-0
xen/arch/x86/hvm/hvm.c int hvm_buffered_io_send(ioreq_t *p) · line 2510
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +1
-1@@ -2507,9 +2507,45 @@ int hvm_buffered_io_send(ioreq_t *p)return 1 ; } -bool_t hvm_has_dm (struct domain *d) +static bool_t hvm_complete_assist_req (ioreq_t *p)
You'll need to change this to a void return as Jan requested.
Quoted 28 lines
xen/arch/x86/hvm/hvm.c +26
-1{ -return !list_empty (&d->arch.hvm_domain.ioreq_server.list); +HVMTRACE_1D (COMPLETE_ASSIST , p->type); +ASSERT (p->type !=IOREQ_TYPE_PCI_CONFIG ); +switch ( p->type ) + { +case IOREQ_TYPE_COPY : +case IOREQ_TYPE_PIO : +if ( p->dir ==IOREQ_READ ) + { +if ( !p->data_is_ptr ) + p->data = ~0ul ; +else + { +int i, step = p->df ? -p->size : p->size; +uint32_t data = ~0 ; + +for ( i =0 ; i < p->count; i++ ) +hvm_copy_to_guest_phys (p->data + step * i, &data, + p->size); + } + } +/* FALLTHRU */ +default : + p->state =STATE_IORESP_READY ; +hvm_io_assist (p); +break ; + }
xen/arch/x86/hvm/hvm.c int hvm_buffered_io_send(ioreq_t *p) · line 2547
Quoted 10 lines
xen/arch/x86/hvm/hvm.c +10
-0+ +return 1 ; +} + +void *hvm_has_dm (struct domain *d,ioreq_t *p) +{ +struct hvm_ioreq_server *s =hvm_select_ioreq_server (d, p); + +if ( !s ) +hvm_complete_assist_req (p);
If you're going to complete the I/O here then...
Quoted 39 lines
xen/arch/x86/hvm/hvm.c +1
-30+return (void *)s; } bool_t hvm_send_assist_req_to_ioreq_server(struct hvm_ioreq_server *s,@@ -2571,44 +2607,15 @@ bool_t hvm_send_assist_req_to_ioreq_server(struct hvm_ioreq_server *s, return 0; } -static bool_t hvm_complete_assist_req (ioreq_t *p) -{ -HVMTRACE_1D (COMPLETE_ASSIST , p->type); -ASSERT (p->type !=IOREQ_TYPE_PCI_CONFIG ); -switch ( p->type ) - { -case IOREQ_TYPE_COPY : -case IOREQ_TYPE_PIO : -if ( p->dir ==IOREQ_READ ) - { -if ( !p->data_is_ptr ) - p->data = ~0ul ; -else - { -int i, step = p->df ? -p->size : p->size; -uint32_t data = ~0 ; - -for ( i =0 ; i < p->count; i++ ) -hvm_copy_to_guest_phys (p->data + step * i, &data, - p->size); - } - } -/* FALLTHRU */ -default : - p->state =STATE_IORESP_READY ; -hvm_io_assist (p); -break ; - } - -return 0 ;/* implicitly bins the i/o operation */
xen/arch/x86/hvm/hvm.c bool_t · line 2616
Quoted 10 lines
xen/arch/x86/hvm/hvm.c +2
-4-} - -bool_t hvm_send_assist_req (ioreq_t *p) +bool_t hvm_send_assist_req (void *vs,ioreq_t *p) { -struct hvm_ioreq_server *s =hvm_select_ioreq_server (current->domain, p); +struct hvm_ioreq_server *s = vs;if ( !s )
... I think you can ASSERT(s) here, as you should never get here if an ioreq server was chosen.
xen/arch/x86/hvm/hvm.c int hvm_buffered_io_send(ioreq_t *p) · line 2540
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +4
-1-return hvm_complete_assist_req (p); + { +hvm_complete_assist_req (p); +return 1 ; + }
So, this function basically collapses down to just this call:
Quoted 3 lines
xen/arch/x86/hvm/hvm.c +0
-0return hvm_send_assist_req_to_ioreq_server (s, p);}
Paul
Quoted 164 lines
xen/include/asm- renamed from xen/include/asm-x86/hvm/hvm.h +0
-0
x86/hvm/hvm.h
index e3d2d9a..1923842 100644xen/include/asm-x86/hvm/hvm.h +2
-2@@ -228,7 +228,7 @@ int hvm_vcpu_cacheattr_init(struct vcpu *v);void hvm_vcpu_cacheattr_destroy (struct vcpu *v);void hvm_vcpu_reset_state (struct vcpu *v,uint16_t cs,uint16_t ip); -bool_t hvm_send_assist_req (ioreq_t *p); +bool_t hvm_send_assist_req (void *s,ioreq_t *p);void hvm_broadcast_assist_req (ioreq_t *p);void hvm_get_guest_pat (struct vcpu *v,u64 *guest_pat);@@ -359,7 +359,7 @@ void hvm_hypervisor_cpuid_leaf(uint32_t sub_idx,void hvm_cpuid (unsigned int input,unsigned int *eax,unsigned int *ebx,unsigned int *ecx,unsigned int *edx);void hvm_migrate_timers (struct vcpu *v); -bool_t hvm_has_dm (struct domain *d); +void *hvm_has_dm (struct domain *d,ioreq_t *p);bool_t hvm_io_pending (struct vcpu *v);void hvm_do_resume (struct vcpu *v);void hvm_migrate_pirqs (struct vcpu *v);-Don Slutz
Quoted 135 lines
Which is the better codding style:
1) Add #defines for the return values?
2) Just use numbers?
3) Invert the sense 0 means worked, 1 isshutdown_deferralordomain_crash, 2 ishvm_complete_assist_req()?I.E. (for just adding 2):
xen/arch/x86/hvm/emulate.c +12
-3@@ -227,10 +227,19 @@ static int hvmemul_do_io(else { rc =X86EMUL_RETRY ; -if ( !hvm_send_assist_req (&p) ) - vio->io_state = HVMIO_none; -else if ( p_data ==NULL ) +switch (hvm_send_assist_req (&p) ) + { +case 2 : rc =X86EMUL_OKAY ; +/* fall through */ +case 0 : + vio->io_state = HVMIO_none; +break ; +case 1 : +if ( p_data ==NULL ) + rc =X86EMUL_OKAY ; +break ; + } }???
I would think it would be good for the code using
hvm_has_dm()to also call onhvm_complete_assist_req().hvm_has_dm()is a subset of the cases thathvm_select_ioreq_server()checks for.Based on this, I think it would be better to remove the call on
hvm_has_dm()instead of adding a call tohvm_complete_assist_req().-Don Slutz
P.S. Details for hang:Using:
static
bool_thvm_complete_assist_req(ioreq_t *p){
+HVMTRACE_1D(COMPLETE_ASSIST, p->type);
...
):I get the trace:
CPU1 745455716325 (+ 1362) VMEXIT [ exitcode =
0x0000001e, rIP
=0x00101581]CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455717846 (+ 1521) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455718209 (+ 363) VMENTRY CPU1 745455719568 (+ 1359) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455721083 (+ 1515) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455721422 (+ 339) VMENTRY CPU1 745455722781 (+ 1359) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455724299 (+ 1518) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455724656 (+ 357) VMENTRY CPU1 745455726009 (+ 1353) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455727539 (+ 1530) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455727899 (+ 360) VMENTRY CPU1 745455729276 (+ 1377) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 io_state = 0 ret = 0 ] CPU1 745455730803 (+ 1527) vlapic_accept_pic_intr [ i8259_target = 1, accept_pic_int = 1 ] CPU1 745455731163 (+ 360) VMENTRY CPU1 745455732525 (+ 1362) VMEXIT [ exitcode = 0x0000001e, rIP = 0x00101581 ] CPU1 0 (+ 0) COMPLETE_ASSIST [ type = 0 ] CPU1 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1
io_state= 0 ret = 0 ]
CPU1 745455734049 (+ 1524)vlapic_accept_pic_intr[i8259_target=
1,accept_pic_int= 1 ]
CPU1 745455734385 (+ 336) VMENTRY
...Quoted 21 lines
Jan
Quoted 16 lines
xen/arch/x86/hvm/emulate.c +4
-1@@ -228,7 +228,11 @@ static int hvmemul_do_io( { rc =X86EMUL_RETRY ;if ( !hvm_send_assist_req (&p) ) + { +/* Since the send failed, do not retry */ + rc =X86EMUL_OKAY ; vio->io_state = HVMIO_none; + }else if ( p_data ==NULL ) rc =X86EMUL_OKAY ; } --1.8.4
Re: [PATCH 3/5] hvmemul_do_io: If the send to the ioreq server failed do not retry.
Quoted 8 lines
Quoted 8 lines
Quoted 1 line · On 02.02.15 at 10:51, <[email protected]> wrote:
From: Don Slutz [mailto:[email protected]]
xen/arch/x86/hvm/hvm.c +0
-0@@ -2507,9 +2507,45 @@ int hvm_buffered_io_send(ioreq_t *p)return 1 ; }
Quoted 4 lines
xen/arch/x86/hvm/hvm.c int hvm_buffered_io_send(ioreq_t *p) · line 2510
Quoted 2 lines
xen/arch/x86/hvm/hvm.c +1
-1-bool_t hvm_has_dm (struct domain *d) +static bool_t hvm_complete_assist_req (ioreq_t *p)You'll need to change this to a void return as Jan requested.
I don't think I did.
Jan
Re: [PATCH 3/5] hvmemul_do_io: If the send to the ioreq server failed do not retry.
Quoted 17 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 02 February 2015 10:04
To: Paul Durrant; Don Slutz
Cc: Andrew Cooper; George Dunlap; Ian Campbell; Ian Jackson; Stefano Stabellini; Wei Liu; [email protected]; Keir (Xen.org)
Subject: RE: [PATCH 3/5]hvmemul_do_io: If the send to the ioreq server failed do not retry.Quoted 8 lines
Quoted 8 lines
Quoted 1 line · On 02.02.15 at 10:51, <[email protected]> wrote:
From: Don Slutz [mailto:[email protected]]
xen/arch/x86/hvm/hvm.c +0
-0@@ -2507,9 +2507,45 @@ int hvm_buffered_io_send(ioreq_t *p)return 1 ; }
Quoted 7 lines
Quoted 4 lines
xen/arch/x86/hvm/hvm.c int hvm_buffered_io_send(ioreq_t *p) · line 2510
Quoted 2 lines
xen/arch/x86/hvm/hvm.c +1
-1-bool_t hvm_has_dm (struct domain *d) +static bool_t hvm_complete_assist_req (ioreq_t *p)You'll need to change this to a void return as Jan requested.
I don't think I did.
Oh, sorry. I thought you suggested that the constant return of 1 from hvm_complete_assist_req() was a bad idea.
Paul
Quoted 1 line
Jan
Re: [PATCH 3/5] hvmemul_do_io: If the send to the ioreq server failed do not retry.
Quoted 23 lines
Quoted 23 lines
Quoted 1 line · On 02.02.15 at 11:06, <[email protected]> wrote:
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 02 February 2015 10:04
To: Paul Durrant; Don Slutz
Cc: Andrew Cooper; George Dunlap; Ian Campbell; Ian Jackson; Stefano Stabellini; Wei Liu; [email protected]; Keir (Xen.org)
Subject: RE: [PATCH 3/5]hvmemul_do_io: If the send to the ioreq server failed do not retry.Quoted 12 lines
xen/arch/x86/hvm/hvm.c int hvm_buffered_io_send(ioreq_t *p) · line 2510
Quoted 10 lines
Quoted 1 line · On 02.02.15 at 10:51, <[email protected]> wrote:
From: Don Slutz [mailto:[email protected]]
xen/arch/x86/hvm/hvm.c +1
-1@@ -2507,9 +2507,45 @@ int hvm_buffered_io_send(ioreq_t *p)return 1 ; } -bool_t hvm_has_dm (struct domain *d) +static bool_t hvm_complete_assist_req (ioreq_t *p)You'll need to change this to a void return as Jan requested.
Quoted 4 lines
Quoted 1 line
I don't think I did.
Oh, sorry. I thought you suggested that the constant return of 1 from
hvm_complete_assist_req()was a bad idea.
Oh, I see, but that was in another thread, and I really suggested to remove the function altogether (folding it back into its only caller).
Jan
Re: [PATCH 3/5] hvmemul_do_io: If the send to the ioreq server failed do not retry.
Quoted 23 lines · Jan Beulich
Quoted 23 lines
Quoted 23 lines
Quoted 1 line · On 02.02.15 at 11:06, <[email protected]> wrote:
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 02 February 2015 10:04
To: Paul Durrant; Don Slutz
Cc: Andrew Cooper; George Dunlap; Ian Campbell; Ian Jackson; Stefano Stabellini; Wei Liu; [email protected]; Keir (Xen.org)
Subject: RE: [PATCH 3/5]hvmemul_do_io: If the send to the ioreq server failed do not retry.Quoted 12 lines
xen/arch/x86/hvm/hvm.c int hvm_buffered_io_send(ioreq_t *p) · line 2510
Quoted 10 lines
Quoted 1 line · On 02.02.15 at 10:51, <[email protected]> wrote:
From: Don Slutz [mailto:[email protected]]
xen/arch/x86/hvm/hvm.c +1
-1@@ -2507,9 +2507,45 @@ int hvm_buffered_io_send(ioreq_t *p)return 1 ; } -bool_t hvm_has_dm (struct domain *d) +static bool_t hvm_complete_assist_req (ioreq_t *p)You'll need to change this to a void return as Jan requested.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
I don't think I did.
Oh, sorry. I thought you suggested that the constant return of 1 from
hvm_complete_assist_req()was a bad idea.Oh, I see, but that was in another thread, and I really suggested to remove the function altogether (folding it back into its only caller).
I was planing to also do this. This is why the code was not in patch form.
-Don Slutz
Quoted 2 lines
Jan
Re: [PATCH 3/5] hvmemul_do_io: If the send to the ioreq server failed do not retry.
In reply to Don SlutzQuoted 21 lines
-----Original Message-----
From: Don Slutz [mailto:[email protected]]
Sent: 30 January 2015 00:52
To: [email protected]
Cc: Andrew Cooper; George Dunlap; Ian Campbell; Ian Jackson; Jan Beulich; Keir (Xen.org); Stefano Stabellini; Wei Liu; Paul Durrant; Don Slutz
Subject: [PATCH 3/5]hvmemul_do_io: If the send to the ioreq server failed do not retry.I.E. do just what no backing DM does.
Signed-off-by Don Slutz <[email protected]>--- xen/arch/x86/hvm/emulate.c | 4 ++++ 1 file changed, 4 insertions(+)xen/arch/x86/hvm/emulate.c +0
-0
xen/arch/x86/hvm/emulate.c static int hvmemul_do_io( · line 233
Quoted 6 lines
xen/arch/x86/hvm/emulate.c +3
-0@@ -228,7 +228,11 @@ static int hvmemul_do_io( { rc =X86EMUL_RETRY ;if ( !hvm_send_assist_req (&p) ) + { +/* Since the send failed, do not retry */ + rc =X86EMUL_OKAY ;
I guess this is probably ok. It's a bit moot though as the only circumstance under which hvm_send_assist_req() will return 0 AFAICT, domain_crash() will have been called, or the vcpu is shutting down.
Paul
Quoted 7 lines
xen/arch/x86/hvm/emulate.c +1
-1vio->io_state = HVMIO_none; + }else if ( p_data ==NULL ) rc =X86EMUL_OKAY ; } --1.8.4
Re: [PATCH 3/5] hvmemul_do_io: If the send to the ioreq server failed do not retry.
Quoted 16 lines · Paul Durrant
Quoted 16 lines
-----Original Message-----
From: Don Slutz [mailto:[email protected]]
Sent: 30 January 2015 00:52
To: [email protected]
Cc: Andrew Cooper; George Dunlap; Ian Campbell; Ian Jackson; Jan Beulich; Keir (Xen.org); Stefano Stabellini; Wei Liu; Paul Durrant; Don Slutz
Subject: [PATCH 3/5]hvmemul_do_io: If the send to the ioreq server failed do not retry.I.E. do just what no backing DM does.
Signed-off-by Don Slutz <[email protected]>--- xen/arch/x86/hvm/emulate.c | 4 ++++ 1 file changed, 4 insertions(+)
Quoted 14 lines
xen/arch/x86/hvm/emulate.c static int hvmemul_do_io( · line 233
Quoted 11 lines
xen/arch/x86/hvm/emulate.c +3
-0@@ -228,7 +228,11 @@ static int hvmemul_do_io( { rc =X86EMUL_RETRY ;if ( !hvm_send_assist_req (&p) ) + { +/* Since the send failed, do not retry */ + rc =X86EMUL_OKAY ;I guess this is probably ok. It's a bit moot though as the only circumstance under which
hvm_send_assist_req()will return 0 AFAICT,domain_crash()will have been called, or the vcpu is shutting down.
Turns out this is not ok. Jan pointed out that for guest suspend to work correctly, you need to retry.
-Don Slutz
Quoted 10 lines
Paul
Quoted 7 lines
xen/arch/x86/hvm/emulate.c +1
-1vio->io_state = HVMIO_none; + }else if ( p_data ==NULL ) rc =X86EMUL_OKAY ; } --1.8.4
PATCH 4/5 hvm_complete_assist_req: We should not be able to get here on IOREQ_TYPE_PCI_CONFIG
In reply to Don Slutz--- xen/arch/x86/hvm/hvm.c | 1 + 1 file changed, 1 insertion(+)
xen/arch/x86/hvm/hvm.c +1 -0
@@ -2573,6 +2573,7 @@ bool_t hvm_send_assist_req_to_ioreq_server(struct hvm_ioreq_server *s,static bool_t hvm_complete_assist_req (ioreq_t *p) { +ASSERT (p->type !=IOREQ_TYPE_PCI_CONFIG );switch ( p->type ) {case IOREQ_TYPE_COPY :
Signature · 1 line
1.8.4
Re: [PATCH 4/5] hvm_complete_assist_req: We should not be able to get here on IOREQ_TYPE_PCI_CONFIG
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 30.01.15 at 01:52, <[email protected]> wrote:
According to your 0/5
?
Jan
Quoted 20 lines
Signed-off-by Don Slutz <[email protected]>--- xen/arch/x86/hvm/hvm.c | 1 + 1 file changed, 1 insertion(+)xen/arch/x86/hvm/hvm.c +1
-0@@ -2573,6 +2573,7 @@ bool_t hvm_send_assist_req_to_ioreq_server(structhvm_ioreq_server *s, static bool_t hvm_complete_assist_req(ioreq_t *p) { + ASSERT(p->type != IOREQ_TYPE_PCI_CONFIG);switch ( p->type ) {case
IOREQ_TYPE_COPY:Signature · 1 line
1.8.4
Re: [PATCH 4/5] hvm_complete_assist_req: We should not be able to get here on IOREQ_TYPE_PCI_CONFIG
Quoted 4 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 30.01.15 at 01:52, <[email protected]> wrote:
According to your 0/5
Suggested-by Paul Durrant <[email protected]>?
Yes, added.
-Don Slutz
Quoted 25 lines
Jan
Quoted 20 lines
Quoted 20 lines
Signed-off-by Don Slutz <[email protected]>--- xen/arch/x86/hvm/hvm.c | 1 + 1 file changed, 1 insertion(+)xen/arch/x86/hvm/hvm.c +1
-0@@ -2573,6 +2573,7 @@ bool_t hvm_send_assist_req_to_ioreq_server(structhvm_ioreq_server *s, static bool_t hvm_complete_assist_req(ioreq_t *p) { + ASSERT(p->type != IOREQ_TYPE_PCI_CONFIG);switch ( p->type ) {case
IOREQ_TYPE_COPY:Signature · 1 line
1.8.4
PATCH 5/5 hvm_complete_assist_req: Tell caller we failed to send
In reply to Don SlutzThis saves a VMENTRY and a VMEXIT since we not longer retry the ioport read.
hvmemul_do_io() will retry in order to complete an ioport read when hvm_send_assist_req() is successful.
--- xen/arch/x86/hvm/hvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/hvm.c +1 -1
@@ -2599,7 +2599,7 @@ static bool_t hvm_complete_assist_req(ioreq_t *p)break ; } -return 1 ; +return 0 ;/* implicitly bins the i/o operation */ }bool_t hvm_send_assist_req (ioreq_t *p)
Signature · 1 line
1.8.4
Re: [PATCH 5/5] hvm_complete_assist_req: Tell caller we failed to send
xen/arch/x86/hvm/hvm.c static bool_t hvm_complete_assist_req(ioreq_t *p) · line 2603
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 01:52, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +1
-1@@ -2599,7 +2599,7 @@ static bool_t hvm_complete_assist_req(ioreq_t *p)break ; } -return 1 ; +return 0 ;/* implicitly bins the i/o operation */ }
This change points out that having hvm_complete_assist_req() be a separate function yet having only a single caller, and it returning non-void with only a single possible return value isn't the best arrangement. I think this should be brought back into hvm_send_assist_req(), by inverting the if() condition there. Unless there are intentions for it to have another caller, but in that case it should still be made return void, with the caller choosing what to return.
Jan
Re: [PATCH 5/5] hvm_complete_assist_req: Tell caller we failed to send
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 01:52, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +0
-0@@ -2599,7 +2599,7 @@ static bool_t hvm_complete_assist_req(ioreq_t *p)break ; }
Quoted 13 lines
xen/arch/x86/hvm/hvm.c static bool_t hvm_complete_assist_req(ioreq_t *p) · line 2603
Quoted 3 lines
xen/arch/x86/hvm/hvm.c +1
-1-return 1 ; +return 0 ;/* implicitly bins the i/o operation */ }This change points out that having
hvm_complete_assist_req()be a separate function yet having only a single caller, and it returning non-void with only a single possible return value isn't the best arrangement. I think this should be brought back intohvm_send_assist_req(), by inverting theif()condition there. Unless there are intentions for it to have another caller, but in that case it should still be made return void, with the caller choosing what to return.
Sounds good to me will do.
-Don Slutz
Quoted 2 lines
Jan
Re: [PATCH 5/5] hvm_complete_assist_req: Tell caller we failed to send
In reply to Don SlutzQuoted 8 lines
-----Original Message-----
From: Don Slutz [mailto:[email protected]]
Sent: 30 January 2015 00:53
To: [email protected]
Cc: Andrew Cooper; George Dunlap; Ian Campbell; Ian Jackson; Jan Beulich; Keir (Xen.org); Stefano Stabellini; Wei Liu; Paul Durrant; Don Slutz
Subject: [PATCH 5/5]hvm_complete_assist_req: Tell caller we failed to send
Quoted 7 lines
This saves a VMENTRY and a VMEXIT since we not longer retry the ioport read.
hvmemul_do_io()will retry in order to complete an ioport read whenhvm_send_assist_req()is successful.Signed-off-by Don Slutz <[email protected]>
It seems like this change should be folded into patch 3? I think the two changes only make sense in combination.
Paul
Quoted 19 lines
--- xen/arch/x86/hvm/hvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/x86/hvm/hvm.c +1
-2@@ -2599,7 +2599,7 @@ static bool_t hvm_complete_assist_req(ioreq_t *p)break ; } -return 1 ; +return 0 ;/* implicitly bins the i/o operation */ }bool_t hvm_send_assist_req (ioreq_t *p) --1.8.4
Re: [PATCH 5/5] hvm_complete_assist_req: Tell caller we failed to send
Quoted 11 lines · Paul Durrant
Quoted 11 lines
-----Original Message-----
From: Don Slutz [mailto:[email protected]]
Sent: 30 January 2015 00:53
To: [email protected]
Cc: Andrew Cooper; George Dunlap; Ian Campbell; Ian Jackson; Jan Beulich; Keir (Xen.org); Stefano Stabellini; Wei Liu; Paul Durrant; Don Slutz
Subject: [PATCH 5/5]hvm_complete_assist_req: Tell caller we failed to sendThis saves a VMENTRY and a VMEXIT since we not longer retry the ioport read.
Quoted 7 lines
Quoted 4 lines
hvmemul_do_io()will retry in order to complete an ioport read whenhvm_send_assist_req()is successful.Signed-off-by Don Slutz <[email protected]>It seems like this change should be folded into patch 3? I think the two changes only make sense in combination.
Happy to do so.
-Don Slutz
Quoted 22 lines
Paul
Quoted 19 lines
--- xen/arch/x86/hvm/hvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/x86/hvm/hvm.c +1
-2@@ -2599,7 +2599,7 @@ static bool_t hvm_complete_assist_req(ioreq_t *p)break ; } -return 1 ; +return 0 ;/* implicitly bins the i/o operation */ }bool_t hvm_send_assist_req (ioreq_t *p) --1.8.4
Re: [PATCH 5/5] hvm_complete_assist_req: Tell caller we failed to send
In reply to Don SlutzQuoted 24 lines
-----Original Message-----
From: Don Slutz [mailto:[email protected]]
Sent: 30 January 2015 00:53
To: [email protected]
Cc: Andrew Cooper; George Dunlap; Ian Campbell; Ian Jackson; Jan Beulich; Keir (Xen.org); Stefano Stabellini; Wei Liu; Paul Durrant; Don Slutz
Subject: [PATCH 5/5]hvm_complete_assist_req: Tell caller we failed to sendThis saves a VMENTRY and a VMEXIT since we not longer retry the ioport read.
hvmemul_do_io()will retry in order to complete an ioport read whenhvm_send_assist_req()is successful.Signed-off-by Don Slutz <[email protected]>--- xen/arch/x86/hvm/hvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/x86/hvm/hvm.c +0
-0
xen/arch/x86/hvm/hvm.c static bool_t hvm_complete_assist_req(ioreq_t *p) · line 2602
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +1
-1@@ -2599,7 +2599,7 @@ static bool_t hvm_complete_assist_req(ioreq_t *p)break ; } -return 1 ; +return 0 ;/* implicitly bins the i/o operation */
Actually that comment is not right. The operation is not binned; it's just already been done.
Paul
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +0
-1}bool_t hvm_send_assist_req (ioreq_t *p) --1.8.4
Re: [PATCH 5/5] hvm_complete_assist_req: Tell caller we failed to send
Quoted 27 lines · Paul Durrant
Quoted 27 lines
-----Original Message-----
From: Don Slutz [mailto:[email protected]]
Sent: 30 January 2015 00:53
To: [email protected]
Cc: Andrew Cooper; George Dunlap; Ian Campbell; Ian Jackson; Jan Beulich; Keir (Xen.org); Stefano Stabellini; Wei Liu; Paul Durrant; Don Slutz
Subject: [PATCH 5/5]hvm_complete_assist_req: Tell caller we failed to sendThis saves a VMENTRY and a VMEXIT since we not longer retry the ioport read.
hvmemul_do_io()will retry in order to complete an ioport read whenhvm_send_assist_req()is successful.Signed-off-by Don Slutz <[email protected]>--- xen/arch/x86/hvm/hvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/x86/hvm/hvm.c +0
-0@@ -2599,7 +2599,7 @@ static bool_t hvm_complete_assist_req(ioreq_t *p)break ; }
Quoted 5 lines
xen/arch/x86/hvm/hvm.c static bool_t hvm_complete_assist_req(ioreq_t *p) · line 2602
Quoted 2 lines
xen/arch/x86/hvm/hvm.c +1
-1-return 1 ; +return 0 ;/* implicitly bins the i/o operation */ Actually that comment is not right. The operation is not binned; it's just already been done.
Will adjust, I expect the return to go away.
-Don Slutz
Quoted 8 lines
Paul
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +0
-1}bool_t hvm_send_assist_req (ioreq_t *p) --1.8.4