From b2a1129bd9043aee7e946da2fab3bdc8e102b136 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Wed, 3 Feb 2016 11:59:37 +0100 Subject: [PATCH] vbox: support unaligned mmio writes Issue #1863 --- repos/ports/src/virtualbox/iommio.cc | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/repos/ports/src/virtualbox/iommio.cc b/repos/ports/src/virtualbox/iommio.cc index 484baa2d4..b254a7922 100644 --- a/repos/ports/src/virtualbox/iommio.cc +++ b/repos/ports/src/virtualbox/iommio.cc @@ -120,20 +120,15 @@ VMMDECL(VBOXSTRICTRC) IOMMMIOWrite(PVM pVM, PVMCPU, RTGCPHYS GCPhys, */ if (rc == VERR_IOM_NOT_MMIO_RANGE_OWNER) { - /* implement what we need to - extend by need */ - - Assert((GCPhys & 3U) == 0); - Assert(cbValue == 1); + Assert(cbValue <= 4); uint32_t value; + RTGCPHYS aligned = GCPhys & ~0x3U; + rc = guest_memory()->mmio_read(aligned, &value, sizeof(value)); - rc = guest_memory()->mmio_read(GCPhys, &value, sizeof(value)); - Assert(rc == VINF_SUCCESS); - - value &= 0xffffff00; - value |= (u32Value & 0x000000ff); - - rc = guest_memory()->mmio_write(GCPhys, value, sizeof(value)); + uint32_t offset = GCPhys & 0x3; + memcpy(((char *)&value) + offset, &u32Value, cbValue); + rc = guest_memory()->mmio_write(aligned, value, sizeof(value)); } Assert(rc != VERR_IOM_NOT_MMIO_RANGE_OWNER);