x86/HVM: alter completion-needed checking
authorJan Beulich <jbeulich@suse.com>
Tue, 26 Jun 2018 06:47:17 +0000 (08:47 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 26 Jun 2018 06:47:17 +0000 (08:47 +0200)
The function only looks at the ioreq_t, so pass it a pointer to just
that. Also use it in hvmemul_do_io().

Suggested-by: Paul Durrant <paul.durrant@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
xen/arch/x86/hvm/emulate.c
xen/arch/x86/hvm/io.c
xen/arch/x86/hvm/ioreq.c
xen/arch/x86/hvm/vmx/realmode.c
xen/include/asm-x86/hvm/vcpu.h

index 7ecee12ffc353c1767de11c9affe723ecbce8e6c..b83727b7df1f2720834db0c7f690d36b60c87597 100644 (file)
@@ -282,11 +282,7 @@ static int hvmemul_do_io(
             rc = hvm_send_ioreq(s, &p, 0);
             if ( rc != X86EMUL_RETRY || currd->is_shutting_down )
                 vio->io_req.state = STATE_IOREQ_NONE;
-            /*
-             * This effectively is !hvm_vcpu_io_need_completion(vio), slightly
-             * optimized and using local variables we have available.
-             */
-            else if ( data_is_addr || (!is_mmio && dir == IOREQ_WRITE) )
+            else if ( !hvm_ioreq_needs_completion(&vio->io_req) )
                 rc = X86EMUL_OKAY;
         }
         break;
@@ -2278,7 +2274,7 @@ static int _hvm_emulate_one(struct hvm_emulate_ctxt *hvmemul_ctxt,
     if ( rc == X86EMUL_OKAY && vio->mmio_retry )
         rc = X86EMUL_RETRY;
 
-    if ( !hvm_vcpu_io_need_completion(vio) )
+    if ( !hvm_ioreq_needs_completion(&vio->io_req) )
     {
         vio->mmio_cache_count = 0;
         vio->mmio_insn_bytes = 0;
index 9af5e3fee6320346f6381b622c07971668a9f90e..bf4d8748d3c741cb2b2fb6daafa39a3e8121ed9e 100644 (file)
@@ -89,7 +89,7 @@ bool hvm_emulate_one_insn(hvm_emulate_validate_t *validate, const char *descr)
 
     rc = hvm_emulate_one(&ctxt);
 
-    if ( hvm_vcpu_io_need_completion(vio) )
+    if ( hvm_ioreq_needs_completion(&vio->io_req) )
         vio->io_completion = HVMIO_mmio_completion;
     else
         vio->mmio_access = (struct npfec){};
@@ -142,7 +142,7 @@ bool handle_pio(uint16_t port, unsigned int size, int dir)
 
     rc = hvmemul_do_pio_buffer(port, size, dir, &data);
 
-    if ( hvm_vcpu_io_need_completion(vio) )
+    if ( hvm_ioreq_needs_completion(&vio->io_req) )
         vio->io_completion = HVMIO_pio_completion;
 
     switch ( rc )
index ebada7225b1f356fbd4857a78bbffb3474c3e096..7c515b3ef7516fb91560407fe9ac48538358015d 100644 (file)
@@ -110,15 +110,15 @@ bool hvm_io_pending(struct vcpu *v)
 static void hvm_io_assist(struct hvm_ioreq_vcpu *sv, uint64_t data)
 {
     struct vcpu *v = sv->vcpu;
-    struct hvm_vcpu_io *vio = &v->arch.hvm_vcpu.hvm_io;
+    ioreq_t *ioreq = &v->arch.hvm_vcpu.hvm_io.io_req;
 
-    if ( hvm_vcpu_io_need_completion(vio) )
+    if ( hvm_ioreq_needs_completion(ioreq) )
     {
-        vio->io_req.state = STATE_IORESP_READY;
-        vio->io_req.data = data;
+        ioreq->state = STATE_IORESP_READY;
+        ioreq->data = data;
     }
     else
-        vio->io_req.state = STATE_IOREQ_NONE;
+        ioreq->state = STATE_IOREQ_NONE;
 
     msix_write_completion(v);
     vcpu_end_shutdown_deferral(v);
index 11211c8cd897a87d2d86a3ce3d9e9c4804c45e67..b20d8c4e292aed631b9eaf7c8e3d5e6290cdb177 100644 (file)
@@ -103,7 +103,7 @@ void vmx_realmode_emulate_one(struct hvm_emulate_ctxt *hvmemul_ctxt)
 
     rc = hvm_emulate_one(hvmemul_ctxt);
 
-    if ( hvm_vcpu_io_need_completion(vio) )
+    if ( hvm_ioreq_needs_completion(&vio->io_req) )
         vio->io_completion = HVMIO_realmode_completion;
 
     if ( rc == X86EMUL_UNHANDLEABLE )
index fad7b66cca59c19e1ddf661004a7c7aa68000f21..86b4ee27e1f1ccd3fe63ce0888d165a7f6bed5c0 100644 (file)
@@ -91,12 +91,11 @@ struct hvm_vcpu_io {
     const struct g2m_ioport *g2m_ioport;
 };
 
-static inline bool hvm_vcpu_io_need_completion(const struct hvm_vcpu_io *vio)
+static inline bool hvm_ioreq_needs_completion(const ioreq_t *ioreq)
 {
-    return (vio->io_req.state == STATE_IOREQ_READY) &&
-           !vio->io_req.data_is_ptr &&
-           (vio->io_req.type != IOREQ_TYPE_PIO ||
-            vio->io_req.dir != IOREQ_WRITE);
+    return ioreq->state == STATE_IOREQ_READY &&
+           !ioreq->data_is_ptr &&
+           (ioreq->type != IOREQ_TYPE_PIO || ioreq->dir != IOREQ_WRITE);
 }
 
 struct nestedvcpu {