public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: IOAPIC: only access APIC registers one dword at a time
@ 2010-07-02  4:38 Xiao Guangrong
  2010-07-02  7:31 ` Jin Dongming
  0 siblings, 1 reply; 12+ messages in thread
From: Xiao Guangrong @ 2010-07-02  4:38 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, LKML, KVM list

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 |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index 1149c60..f96816f 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -306,14 +306,10 @@ 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);
+		*(u32 *) val = result;
 		break;
+
 	default:
 		printk(KERN_WARNING "ioapic: wrong length %d\n", len);
 	}
@@ -332,7 +328,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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-07-05  8:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-02  4:38 [PATCH] KVM: IOAPIC: only access APIC registers one dword at a time Xiao Guangrong
2010-07-02  7:31 ` Jin Dongming
2010-07-02  7:38   ` Xiao Guangrong
2010-07-02  8:00     ` [PATCH v2] " Xiao Guangrong
2010-07-02 17:42       ` Marcelo Tosatti
2010-07-03  8:20         ` Xiao Guangrong
2010-07-03 10:11       ` Avi Kivity
2010-07-05  3:47         ` Xiao Guangrong
2010-07-05  6:23           ` Gleb Natapov
2010-07-05  7:54           ` Avi Kivity
2010-07-05  7:56             ` Xiao Guangrong
2010-07-05  8:25               ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox