diff mbox series

[4/5] x86/HVM: slightly improve CMPXCHG16B emulation

Message ID dccd655c-2a9c-4e11-9889-53e80ff10fc2@suse.com (mailing list archive)
State Superseded
Headers show
Series x86/HVM: emulation (MMIO) improvements | expand

Commit Message

Jan Beulich Sept. 4, 2024, 1:29 p.m. UTC
Using hvmemul_linear_mmio_write() directly (as fallback when mapping the
memory operand isn't possible) won't work properly when the access
crosses a RAM/MMIO boundary. Use linear_write() instead, which splits at
such boundaries as necessary.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Comments

Andrew Cooper Sept. 6, 2024, 6:01 p.m. UTC | #1
On 04/09/2024 2:29 pm, Jan Beulich wrote:
> Using hvmemul_linear_mmio_write() directly (as fallback when mapping the
> memory operand isn't possible) won't work properly when the access
> crosses a RAM/MMIO boundary. Use linear_write() instead, which splits at
> such boundaries as necessary.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox series

Patch

--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -1645,10 +1645,8 @@  static int cf_check hvmemul_cmpxchg(
 {
     struct hvm_emulate_ctxt *hvmemul_ctxt =
         container_of(ctxt, struct hvm_emulate_ctxt, ctxt);
-    struct vcpu *curr = current;
     unsigned long addr;
     uint32_t pfec = PFEC_page_present | PFEC_write_access;
-    struct hvm_vcpu_io *hvio = &curr->arch.hvm.hvm_io;
     int rc;
     void *mapping = NULL;
 
@@ -1672,10 +1670,7 @@  static int cf_check hvmemul_cmpxchg(
     if ( !mapping )
     {
         /* Fix this in case the guest is really relying on r-m-w atomicity. */
-        return hvmemul_linear_mmio_write(addr, bytes, p_new, pfec,
-                                         hvmemul_ctxt, addr,
-                                         hvio->mmio_access.write_access &&
-                                         hvio->mmio_gla == (addr & PAGE_MASK));
+        return linear_write(addr, bytes, p_new, pfec, hvmemul_ctxt);
     }
 
     switch ( bytes )