From patchwork Mon Apr 22 14:11:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10911095 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 884B014DB for ; Mon, 22 Apr 2019 14:30:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79EF026E16 for ; Mon, 22 Apr 2019 14:30:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E23927F17; Mon, 22 Apr 2019 14:30:11 +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 11E1D26E16 for ; Mon, 22 Apr 2019 14:30:10 +0000 (UTC) Received: from localhost ([127.0.0.1]:38108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIZxS-0000fg-76 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 22 Apr 2019 10:30:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIZwF-0007um-Q5 for qemu-devel@nongnu.org; Mon, 22 Apr 2019 10:28:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIZgs-0005Ld-S8 for qemu-devel@nongnu.org; Mon, 22 Apr 2019 10:13:03 -0400 Received: from m12-12.163.com ([220.181.12.12]:59543) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIZgs-0005Kp-8C for qemu-devel@nongnu.org; Mon, 22 Apr 2019 10:13:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=TAkAEQslBT4X+Y5eAh 5OCFU79u6ALGBYynB4L5pLfks=; b=ToT4qNoBSUnsG2QmkIen2Kbf9sJ1t6//kl RwjLLvl3BjMm2LbhjQvrGUCBDr+iPjIxwAj1tn3GP4ncSNR1UE90PP0AC+jNsEUu nlICqGmLy75a0URFJxHl6d9FjHd80F/nyXHBN9R5qO8h82FeKnZSiANP+bOAqMj9 Vo5JQSiMY= Received: from localhost.localdomain (unknown [183.159.69.175]) by smtp8 (Coremail) with SMTP id DMCowACXUzO0y71cvQ2cBg--.39054S3; Mon, 22 Apr 2019 22:12:07 +0800 (CST) From: Li Qiang To: jslaby@suse.cz, pbonzini@redhat.com Date: Mon, 22 Apr 2019 07:11:54 -0700 Message-Id: <20190422141156.15746-2-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190422141156.15746-1-liq3ea@163.com> References: <20190422141156.15746-1-liq3ea@163.com> X-CM-TRANSID: DMCowACXUzO0y71cvQ2cBg--.39054S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrZF4xJFWUXF4UurW3Kr4rKrg_yoW3urg_Jw 1xGFZ7urW5Wry3AF9YqF13ur1xW3yrAFn5uFnagr4fJa4rCF98Z3sagrnxXw47Gw1fCwn5 ZaykZFy5Kr9rWjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUjxnY3UUUUU== X-Originating-IP: [183.159.69.175] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbiKReebVXlqxQeaQAAs1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.12 Subject: [Qemu-devel] [PATCH v3 1/3] edu: mmio: allow 64-bit access 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: philmd@redhat.com, liq3ea@gmail.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 edu spec says the MMIO area can be accessed by 64-bit. However currently the 'max_access_size' is not so the MMIO access dispatch can only access 32-bit one time. This patch fixes this to respect the spec. Signed-off-by: Li Qiang Reviewed-by: Philippe Mathieu-Daude --- hw/misc/edu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/misc/edu.c b/hw/misc/edu.c index 91af452c9e..65fc32b928 100644 --- a/hw/misc/edu.c +++ b/hw/misc/edu.c @@ -289,6 +289,15 @@ static const MemoryRegionOps edu_mmio_ops = { .read = edu_mmio_read, .write = edu_mmio_write, .endianness = DEVICE_NATIVE_ENDIAN, + .valid = { + .min_access_size = 4, + .max_access_size = 8, + }, + .impl = { + .min_access_size = 4, + .max_access_size = 8, + }, + }; /* From patchwork Mon Apr 22 14:11:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10911097 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 A415C1515 for ; Mon, 22 Apr 2019 14:31:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95B8E285C9 for ; Mon, 22 Apr 2019 14:31:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89DA52862C; Mon, 22 Apr 2019 14:31:39 +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 2DC95285C9 for ; Mon, 22 Apr 2019 14:31:39 +0000 (UTC) Received: from localhost ([127.0.0.1]:38140 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIZys-00026a-IP for patchwork-qemu-devel@patchwork.kernel.org; Mon, 22 Apr 2019 10:31:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIZwF-0007vk-TN for qemu-devel@nongnu.org; Mon, 22 Apr 2019 10:28:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIZgs-0005LK-6y for qemu-devel@nongnu.org; Mon, 22 Apr 2019 10:13:02 -0400 Received: from m12-12.163.com ([220.181.12.12]:58458) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIZgr-0005J2-J8 for qemu-devel@nongnu.org; Mon, 22 Apr 2019 10:13:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=ocpxbx74syTndxPAzj CBgtsjTGrKulmkE9I+7Wjy7y8=; b=jEblY0WWsbJd32TqMq9FfXfXlz1M/C5uFR zkcq0fcoxGYEvBPn0zxxKR4sSciaciZ4TdNDg+3PkkwYQogI+G3nfzoqNH43cR7c ttpfalnQaQojET6OkgIx4fIZvt28FDzTyL/PeJuV8UPjtBC9kb48cP+VkBcPv2UC vSxul3U4w= Received: from localhost.localdomain (unknown [183.159.69.175]) by smtp8 (Coremail) with SMTP id DMCowACXUzO0y71cvQ2cBg--.39054S4; Mon, 22 Apr 2019 22:12:08 +0800 (CST) From: Li Qiang To: jslaby@suse.cz, pbonzini@redhat.com Date: Mon, 22 Apr 2019 07:11:55 -0700 Message-Id: <20190422141156.15746-3-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190422141156.15746-1-liq3ea@163.com> References: <20190422141156.15746-1-liq3ea@163.com> X-CM-TRANSID: DMCowACXUzO0y71cvQ2cBg--.39054S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrJryrCw15Zr4UAr13CryxAFb_yoWxArc_X3 yjka93ZrWq9Fyak3WqvFn5Zr17tw4rZrZxZw4Iqrs7ArZ0krWrA34v9FnrGr4SqrZxWryU Z3yDuF92kr9IgjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU8t5r7UUUUU== X-Originating-IP: [183.159.69.175] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbitByebVSIbq8CGwAAsf X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.12 Subject: [Qemu-devel] [PATCH v3 2/3] edu: mmio: allow 64-bit access in read dispatch 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: philmd@redhat.com, liq3ea@gmail.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 edu spec says when address >= 0x80, the MMIO area can be accessed by 64-bit. Signed-off-by: Li Qiang Reviewed-by: Philippe Mathieu-Daude --- Change since v2: Fix an error per Phillippe's advice hw/misc/edu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/misc/edu.c b/hw/misc/edu.c index 65fc32b928..33de05141f 100644 --- a/hw/misc/edu.c +++ b/hw/misc/edu.c @@ -185,7 +185,11 @@ static uint64_t edu_mmio_read(void *opaque, hwaddr addr, unsigned size) EduState *edu = opaque; uint64_t val = ~0ULL; - if (size != 4) { + if (addr < 0x80 && size != 4) { + return val; + } + + if (addr >= 0x80 && size != 4 && size != 8) { return val; } From patchwork Mon Apr 22 14:11:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10911093 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 843B014DB for ; Mon, 22 Apr 2019 14:30:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6715026E16 for ; Mon, 22 Apr 2019 14:30:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 539FA27F17; Mon, 22 Apr 2019 14:30:08 +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 AEF7D26E16 for ; Mon, 22 Apr 2019 14:30:07 +0000 (UTC) Received: from localhost ([127.0.0.1]:38093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIZxO-0000c0-Ft for patchwork-qemu-devel@patchwork.kernel.org; Mon, 22 Apr 2019 10:30:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIZwG-0007oA-4j for qemu-devel@nongnu.org; Mon, 22 Apr 2019 10:28:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIZgr-0005L0-8k for qemu-devel@nongnu.org; Mon, 22 Apr 2019 10:13:02 -0400 Received: from m12-12.163.com ([220.181.12.12]:59099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIZgq-0005KQ-N3 for qemu-devel@nongnu.org; Mon, 22 Apr 2019 10:13:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=nQoqn/+2UWQM9V3Ss/ BbafTfJ2pjBYmf2/7+vVlg1QY=; b=PgiY9KHRLJmHcLrUlMs7YVFzl7fPqTNX/V y++oU1siE0qaDHal2BH8Rj++h57b3zifDkKrdQsSCDM4CtWQU2yqkkSgXgkU/2dp yuZMkbMblwieb+PR6Sqba2j2NRJWvIdgZAGt6BhP3vYr+eFneSoXqzpgnEHBJ2rP E3tvuZxy4= Received: from localhost.localdomain (unknown [183.159.69.175]) by smtp8 (Coremail) with SMTP id DMCowACXUzO0y71cvQ2cBg--.39054S5; Mon, 22 Apr 2019 22:12:10 +0800 (CST) From: Li Qiang To: jslaby@suse.cz, pbonzini@redhat.com Date: Mon, 22 Apr 2019 07:11:56 -0700 Message-Id: <20190422141156.15746-4-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190422141156.15746-1-liq3ea@163.com> References: <20190422141156.15746-1-liq3ea@163.com> X-CM-TRANSID: DMCowACXUzO0y71cvQ2cBg--.39054S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7uF45WF15KFWxuryrur4kZwb_yoW8ZF13p3 45Grs3XF4FgFyfJryUAw4DXF1rGrn5tFWrK3yUCrsY9ayrWFs7CFyUA342vrWxWryIvF13 uFZYvF43uF4xZrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jOJ5rUUUUU= X-Originating-IP: [183.159.69.175] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbiKRqebVXlqxQejgAAsf X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.12 Subject: [Qemu-devel] [PATCH v3 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: philmd@redhat.com, liq3ea@gmail.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-Daude --- hw/misc/edu.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/misc/edu.c b/hw/misc/edu.c index 33de05141f..401ada74af 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, +static void edu_check_range(uint64_t addr, uint64_t size1, uint64_t start, uint32_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),