Messages in this thread Patch in this message | | | Date | Fri, 02 Jul 2010 16:00:12 +0800 | From | Xiao Guangrong <> | Subject | [PATCH v2] KVM: IOAPIC: only access APIC registers one dword at a time |
| |
The IOAPIC spec says:
When accessing these registers, accesses must be done one dword at a time. For example, software should never access byte 2 from the Data register before accessing bytes 0 and 1. The hardware will not attempt to recover from a bad programming model in this case.
So, this patch removes other width access
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> --- virt/kvm/ioapic.c | 20 +++++++------------- 1 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index 1149c60..6610d11 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c @@ -288,6 +288,11 @@ static int ioapic_mmio_read(struct kvm_io_device *this, gpa_t addr, int len, ioapic_debug("addr %lx\n", (unsigned long)addr); ASSERT(!(addr & 0xf)); /* check alignment */ + if (len != 4) { + printk(KERN_WARNING "ioapic: wrong length %d\n", len); + return 0; + } + addr &= 0xff; spin_lock(&ioapic->lock); switch (addr) { @@ -305,18 +310,7 @@ static int ioapic_mmio_read(struct kvm_io_device *this, gpa_t addr, int len, } spin_unlock(&ioapic->lock); - switch (len) { - case 8: - *(u64 *) val = result; - break; - case 1: - case 2: - case 4: - memcpy(val, (char *)&result, len); - break; - default: - printk(KERN_WARNING "ioapic: wrong length %d\n", len); - } + *(u32 *) val = result; return 0; } @@ -332,7 +326,7 @@ static int ioapic_mmio_write(struct kvm_io_device *this, gpa_t addr, int len, (void*)addr, len, val); ASSERT(!(addr & 0xf)); /* check alignment */ - if (len == 4 || len == 8) + if (len == 4) data = *(u32 *) val; else { printk(KERN_WARNING "ioapic: Unsupported size %d\n", len); -- 1.6.1.2
| |