From patchwork Fri Nov 19 23:06:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 72326 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1FD8CB7113 for ; Sat, 20 Nov 2010 10:08:23 +1100 (EST) Received: from localhost ([127.0.0.1]:60786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJa43-00062C-Rs for incoming@patchwork.ozlabs.org; Fri, 19 Nov 2010 18:08:19 -0500 Received: from [140.186.70.92] (port=36730 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJa2U-0005bh-Vc for qemu-devel@nongnu.org; Fri, 19 Nov 2010 18:06:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJa2T-0008Bf-Qb for qemu-devel@nongnu.org; Fri, 19 Nov 2010 18:06:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58860) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJa2T-0008BH-Hs for qemu-devel@nongnu.org; Fri, 19 Nov 2010 18:06:41 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAJN6dgM011925 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 19 Nov 2010 18:06:40 -0500 Received: from rincewind.home.kraxel.org (vpn1-6-177.ams2.redhat.com [10.36.6.177]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAJN6ctM006837; Fri, 19 Nov 2010 18:06:39 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 4E76145991; Sat, 20 Nov 2010 00:06:37 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Sat, 20 Nov 2010 00:06:37 +0100 Message-Id: <1290207997-3984-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: agraf@suse.de, Gerd Hoffmann Subject: [Qemu-devel] [PATCH] ahci: fix lst+fis mapping X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The ahci map_page() function checks whenever it got a full page mapped. This is wrong. The data structures are much smaller: command list is 1k and fis is 256 bytes. Checking whenever we can access that much bytes without crossing a page border is good enougth. Signed-off-by: Gerd Hoffmann --- hw/ahci.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/ahci.c b/hw/ahci.c index 0ee021e..fdd5572 100644 --- a/hw/ahci.c +++ b/hw/ahci.c @@ -411,16 +411,16 @@ static void ahci_check_irq(AHCIState *s) } } -static void map_page(uint8_t **ptr, uint64_t addr) +static void map_page(uint8_t **ptr, uint64_t addr, uint32_t wanted) { - target_phys_addr_t len = 4096; + target_phys_addr_t len = wanted; if (*ptr) { cpu_physical_memory_unmap(*ptr, 1, len, len); } *ptr = cpu_physical_memory_map(addr, &len, 1); - if (len < 4096) { + if (len < wanted) { *ptr = NULL; } } @@ -435,22 +435,22 @@ static void ahci_port_write(AHCIState *s, int port, int offset, uint32_t val) case PORT_LST_ADDR: pr->lst_addr = val; map_page(&s->dev[port].lst, - ((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr); + ((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024); break; case PORT_LST_ADDR_HI: pr->lst_addr_hi = val; map_page(&s->dev[port].lst, - ((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr); + ((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024); break; case PORT_FIS_ADDR: pr->fis_addr = val; map_page(&s->dev[port].res_fis, - ((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr); + ((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256); break; case PORT_FIS_ADDR_HI: pr->fis_addr_hi = val; map_page(&s->dev[port].res_fis, - ((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr); + ((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256); break; case PORT_IRQ_STAT: pr->irq_stat &= ~val;