From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SF2i8-0000GN-OC for qemu-devel@nongnu.org; Tue, 03 Apr 2012 08:19:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SF2i5-0004MX-JN for qemu-devel@nongnu.org; Tue, 03 Apr 2012 08:19:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37629) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SF2i5-0004K2-B5 for qemu-devel@nongnu.org; Tue, 03 Apr 2012 08:19:41 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q33CJdxm032060 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 3 Apr 2012 08:19:39 -0400 From: Hans de Goede Date: Tue, 3 Apr 2012 14:21:47 +0200 Message-Id: <1333455707-3534-1-git-send-email-hdegoede@redhat.com> Subject: [Qemu-devel] [PATCH] usb-ehci: Ensure frindex writes leave a valid frindex value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: Hans de Goede , qemu-devel@nongnu.org frindex is a 14 bits counter, so bits 31-14 should always be 0, and after the commit titled "usb-ehci: frindex always is a 14 bits counter" we rely on frindex always being a multiple of 8. I've not seen this in practice, but theoretically a guest can write a value >= 0x4000 or a value which is not a multiple of 8 value to frindex, this patch ensures that things will still work when that happens. Signed-off-by: Hans de Goede --- hw/usb/hcd-ehci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 64b58e3..8865b4e 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -1102,6 +1102,10 @@ static void ehci_mem_writel(void *ptr, target_phys_addr_t addr, uint32_t val) val &= USBINTR_MASK; break; + case FRINDEX: + val &= 0x00003ff8; /* frindex is 14bits and always a multiple of 8 */ + break; + case CONFIGFLAG: val &= 0x1; if (val) { -- 1.7.9.3