From patchwork Fri May 10 16:43:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10939269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79AFE76 for ; Fri, 10 May 2019 16:53:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A7BB2899C for ; Fri, 10 May 2019 16:53:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E62F28B8A; Fri, 10 May 2019 16:53:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 002BD2899C for ; Fri, 10 May 2019 16:53:11 +0000 (UTC) Received: from localhost ([127.0.0.1]:46815 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP8lj-0004wG-AO for patchwork-qemu-devel@patchwork.kernel.org; Fri, 10 May 2019 12:53:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP8d1-0004c7-KR for qemu-devel@nongnu.org; Fri, 10 May 2019 12:44:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hP8cz-0002U4-KH for qemu-devel@nongnu.org; Fri, 10 May 2019 12:44:11 -0400 Received: from m12-13.163.com ([220.181.12.13]:46185) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP8cw-0002S2-1x for qemu-devel@nongnu.org; Fri, 10 May 2019 12:44:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=bD784GuXCTHvAqf9FL z4k1N7zeMg3+JJ22MHAx8bcDQ=; b=gvgXbDqQJ88U/EfOciI8Ua4IWLZPhNd0Ws PiNDCS75OV/F8BM7HN3MKYyOoigE6MKf8r01SYMNcJca9oC24nYTPbybMlGWlzwt qLqMez8wumAWg7X9wsN7arm1rFQ4jyC055wQJwlMHp2c234AN0DyogFa1YXOxbmu 93cAp1/oc= Received: from localhost.localdomain (unknown [183.159.64.133]) by smtp9 (Coremail) with SMTP id DcCowAB3fTFLqtVcVYWnCg--.3399S5; Sat, 11 May 2019 00:44:02 +0800 (CST) From: Li Qiang To: pbonzini@redhat.com, jslaby@suse.cz Date: Fri, 10 May 2019 09:43:49 -0700 Message-Id: <20190510164349.81507-4-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510164349.81507-1-liq3ea@163.com> References: <20190510164349.81507-1-liq3ea@163.com> X-CM-TRANSID: DcCowAB3fTFLqtVcVYWnCg--.3399S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7uF45WF15KFWxury7Xr1UKFg_yoW8ZFW5p3 45Grn3XF4FgFyfJry5Aw4DXr1rGrn5tF4rK3y8CrsY9ayrXFs7CFyUJ3429rWxW34Ivr13 uFZYqF43uF4xZrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j4wZ7UUUUU= X-Originating-IP: [183.159.64.133] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbiFBKwbVaD0qDHjwAAs0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.13 Subject: [Qemu-devel] [PATCH v4 3/3] edu: uses uint64_t in dma operation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: liq3ea@gmail.com, philmd@redhat.com, qemu-devel@nongnu.org, Li Qiang Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The dma related variable dma.dst/src/cnt is dma_addr_t, it is uint64_t in x64 platform. Change these usage from uint32_to uint64_t to avoid trancation in edu_dma_timer. Signed-off-by: Li Qiang Reviewed-by: Philippe Mathieu-Daudé --- Change since v3: Change 'size2' para of 'edu_check_range' to 64-bits. hw/misc/edu.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/misc/edu.c b/hw/misc/edu.c index 33de05141f..19e5545e2c 100644 --- a/hw/misc/edu.c +++ b/hw/misc/edu.c @@ -98,23 +98,24 @@ static void edu_lower_irq(EduState *edu, uint32_t val) } } -static bool within(uint32_t addr, uint32_t start, uint32_t end) +static bool within(uint64_t addr, uint64_t start, uint64_t end) { return start <= addr && addr < end; } -static void edu_check_range(uint32_t addr, uint32_t size1, uint32_t start, - uint32_t size2) +static void edu_check_range(uint64_t addr, uint64_t size1, uint64_t start, + uint64_t size2) { - uint32_t end1 = addr + size1; - uint32_t end2 = start + size2; + uint64_t end1 = addr + size1; + uint64_t end2 = start + size2; if (within(addr, start, end2) && end1 > addr && within(end1, start, end2)) { return; } - hw_error("EDU: DMA range 0x%.8x-0x%.8x out of bounds (0x%.8x-0x%.8x)!", + hw_error("EDU: DMA range 0x%016"PRIx64"-0x%016"PRIx64 + " out of bounds (0x%016"PRIx64"-0x%016"PRIx64")!", addr, end1 - 1, start, end2 - 1); } @@ -139,13 +140,13 @@ static void edu_dma_timer(void *opaque) } if (EDU_DMA_DIR(edu->dma.cmd) == EDU_DMA_FROM_PCI) { - uint32_t dst = edu->dma.dst; + uint64_t dst = edu->dma.dst; edu_check_range(dst, edu->dma.cnt, DMA_START, DMA_SIZE); dst -= DMA_START; pci_dma_read(&edu->pdev, edu_clamp_addr(edu, edu->dma.src), edu->dma_buf + dst, edu->dma.cnt); } else { - uint32_t src = edu->dma.src; + uint64_t src = edu->dma.src; edu_check_range(src, edu->dma.cnt, DMA_START, DMA_SIZE); src -= DMA_START; pci_dma_write(&edu->pdev, edu_clamp_addr(edu, edu->dma.dst),