From patchwork Tue Apr 3 12:21:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 150417 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 672C0B6FE7 for ; Tue, 3 Apr 2012 22:19:58 +1000 (EST) Received: from localhost ([::1]:48138 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SF2iK-0000IU-8N for incoming@patchwork.ozlabs.org; Tue, 03 Apr 2012 08:19:56 -0400 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 Received: from shalem.localdomain.com (vpn1-7-152.ams2.redhat.com [10.36.7.152]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q33CJcng016340; Tue, 3 Apr 2012 08:19:38 -0400 From: Hans de Goede To: Gerd Hoffmann Date: Tue, 3 Apr 2012 14:21:47 +0200 Message-Id: <1333455707-3534-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Hans de Goede , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] usb-ehci: Ensure frindex writes leave a valid frindex value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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 Acked-by: Alon Levy Reviewed-by: Alon Levy --- 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) {