From patchwork Sat Apr 20 14:51:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10910345 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 70ADD922 for ; Sat, 20 Apr 2019 14:55:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FB6F2869B for ; Sat, 20 Apr 2019 14:55:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 539FB287AA; Sat, 20 Apr 2019 14:55:33 +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 10B7F2869B for ; Sat, 20 Apr 2019 14:55:33 +0000 (UTC) Received: from localhost ([127.0.0.1]:42200 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHrOu-0003Cz-CF for patchwork-qemu-devel@patchwork.kernel.org; Sat, 20 Apr 2019 10:55:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHrNj-000254-IU for qemu-devel@nongnu.org; Sat, 20 Apr 2019 10:54:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHrL5-00019K-V0 for qemu-devel@nongnu.org; Sat, 20 Apr 2019 10:51:36 -0400 Received: from m12-13.163.com ([220.181.12.13]:58198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHrL5-00015r-AN for qemu-devel@nongnu.org; Sat, 20 Apr 2019 10:51:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=iRFD+zpf5l7TX1uoBr 2sBdhb6Xv5dDZq2CEa09rVSBg=; b=Yug5j48Kud/PNejOT9DYHAUVTrdjhp8Tiz 6+s+L/qNUJPFrDdUIyv0IfpcW85bWQwI+lq08XM+ALeG9dwi4c96TpFibpMi5xkt za2Dq6c6wyfHQZgYcgC6PT3qJ0AhyNE/qEIcHV1CeVJ86cTdscmkwci12bnORr5m hAnSlX6Rk= Received: from localhost.localdomain (unknown [183.159.69.175]) by smtp9 (Coremail) with SMTP id DcCowABXKKbvMbtc5Pi_Ag--.9861S3; Sat, 20 Apr 2019 22:51:29 +0800 (CST) From: Li Qiang To: jslaby@suse.cz, pbonzini@redhat.com Date: Sat, 20 Apr 2019 07:51:18 -0700 Message-Id: <20190420145120.122847-2-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190420145120.122847-1-liq3ea@163.com> References: <20190420145120.122847-1-liq3ea@163.com> X-CM-TRANSID: DcCowABXKKbvMbtc5Pi_Ag--.9861S3 X-Coremail-Antispam: 1Uf129KBjvdXoWruFyfZF15Wr4kKr43AF18Zrb_yoW3tFX_Xw 1xKFZ7GrW5XFyayF90q3W5uryxW3yrAF1rCrs3Gr43Ja4fGr98Z3s2qrnxXr47Gw47Kwn5 AaykZFy5trnFgjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUjsqXJUUUUU== X-Originating-IP: [183.159.69.175] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbiKRGcbVXlqu9vFQAAsG X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.13 Subject: [Qemu-devel] [PATCH 1/3] edu: mmio: set 'max_access_size' to 8 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: Li Qiang , liq3ea@gmail.com, qemu-devel@nongnu.org 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 said, the MMIO area can be accessed by 8 bytes. However currently the 'max_access_size' is not so the MMIO access dispatch can only access 4 bytes one time. This patch fixes this to respect the spec. Notice: here the 'min_access_size' is not a must, I set this for completement. Signed-off-by: Li Qiang --- 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 Sat Apr 20 14:51:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10910343 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 880E317EE for ; Sat, 20 Apr 2019 14:55:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79932284D4 for ; Sat, 20 Apr 2019 14:55:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CD6F2869B; Sat, 20 Apr 2019 14:55:28 +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 1D947286D3 for ; Sat, 20 Apr 2019 14:55:28 +0000 (UTC) Received: from localhost ([127.0.0.1]:42197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHrOp-00036O-6W for patchwork-qemu-devel@patchwork.kernel.org; Sat, 20 Apr 2019 10:55:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHrNi-0002DZ-MC for qemu-devel@nongnu.org; Sat, 20 Apr 2019 10:54:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHrL5-00019P-VJ for qemu-devel@nongnu.org; Sat, 20 Apr 2019 10:51:37 -0400 Received: from m12-13.163.com ([220.181.12.13]:58274) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHrL5-000169-9s for qemu-devel@nongnu.org; Sat, 20 Apr 2019 10:51:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=nto7dRdt8+6HlFMrTC L4RjigEIgC4k8QVhUb2RlYSSc=; b=UqKDrQFmctzTyKnTzenjoP1bx3Ou6Jd5os mqwqu69+WvOkY7e42YYz2VNfczDeR66eDz/y2fELufZS8eSEIbbM7j8w9+dywRjo TVqPuN+RKeuU7v4EIGKqQNyqKgxO5+lusFTSBnK1YGM8c9pNElcmPLxVa9SDxEhp vjqQr3hog= Received: from localhost.localdomain (unknown [183.159.69.175]) by smtp9 (Coremail) with SMTP id DcCowABXKKbvMbtc5Pi_Ag--.9861S4; Sat, 20 Apr 2019 22:51:30 +0800 (CST) From: Li Qiang To: jslaby@suse.cz, pbonzini@redhat.com Date: Sat, 20 Apr 2019 07:51:19 -0700 Message-Id: <20190420145120.122847-3-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190420145120.122847-1-liq3ea@163.com> References: <20190420145120.122847-1-liq3ea@163.com> X-CM-TRANSID: DcCowABXKKbvMbtc5Pi_Ag--.9861S4 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjxUx1CJUUUUU X-Originating-IP: [183.159.69.175] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbBaxKcbVetu+ZtOAAAs6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.13 Subject: [Qemu-devel] [PATCH 2/3] edu: mmio: allow mmio read dispatch accept 8 bytes 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: Li Qiang , liq3ea@gmail.com, qemu-devel@nongnu.org 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 said when address >= 0x80, the MMIO area can be accessed by 8 bytes. Signed-off-by: Li Qiang --- hw/misc/edu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/misc/edu.c b/hw/misc/edu.c index 65fc32b928..4018dddcb8 100644 --- a/hw/misc/edu.c +++ b/hw/misc/edu.c @@ -189,6 +189,10 @@ static uint64_t edu_mmio_read(void *opaque, hwaddr addr, unsigned size) return val; } + if (addr >= 0x80 && size != 4 && size != 8) { + return val; + } + switch (addr) { case 0x00: val = 0x010000edu; From patchwork Sat Apr 20 14:51:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10910347 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 4E77B13B5 for ; Sat, 20 Apr 2019 14:57:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35BB02887B for ; Sat, 20 Apr 2019 14:57:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2918728B75; Sat, 20 Apr 2019 14:57:25 +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 EC2CF2887B for ; Sat, 20 Apr 2019 14:57:23 +0000 (UTC) Received: from localhost ([127.0.0.1]:42220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHrQh-0004jO-7c for patchwork-qemu-devel@patchwork.kernel.org; Sat, 20 Apr 2019 10:57:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHrNi-0002CZ-Sk for qemu-devel@nongnu.org; Sat, 20 Apr 2019 10:54:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHrL6-00019W-3A for qemu-devel@nongnu.org; Sat, 20 Apr 2019 10:51:36 -0400 Received: from m12-13.163.com ([220.181.12.13]:58461) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHrL5-00018V-0M for qemu-devel@nongnu.org; Sat, 20 Apr 2019 10:51:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=lgkdDMul6cYmcPejZ/ UePeaPFgmTCIP83JKHfVUUsqY=; b=kyvqRbox3EZxQNuPmuCchOwtfyFf4Vpg0r a4gDyAH1HtCHqrt/QbOKrwUJGPuPydf/jLUyCNuSfiovJ/anVDuTRdiRCwzpuCCX a6WFDmg7lCAx+eWbj2qjsZsXrov5I0b8pwPzRI/d2WPKAE7neI3dwAtxOF1nho8s SO9XE2fr0= Received: from localhost.localdomain (unknown [183.159.69.175]) by smtp9 (Coremail) with SMTP id DcCowABXKKbvMbtc5Pi_Ag--.9861S5; Sat, 20 Apr 2019 22:51:33 +0800 (CST) From: Li Qiang To: jslaby@suse.cz, pbonzini@redhat.com Date: Sat, 20 Apr 2019 07:51:20 -0700 Message-Id: <20190420145120.122847-4-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190420145120.122847-1-liq3ea@163.com> References: <20190420145120.122847-1-liq3ea@163.com> X-CM-TRANSID: DcCowABXKKbvMbtc5Pi_Ag--.9861S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7tF43CF1UGr48KryDXF1rXrb_yoW8CrW7p3 45Grn3XF4FgFyfJ34Yyw4DXrn5GrnxtFWrK348CrsY9ay5WFs7CryDC34I9ryxWrySyr13 uFZYgF43uF4IvrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j7TmfUUUUU= X-Originating-IP: [183.159.69.175] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbiFBWcbVaD0UGUEwAAsy X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.13 Subject: [Qemu-devel] [PATCH 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: Li Qiang , liq3ea@gmail.com, qemu-devel@nongnu.org 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 is dma_addr_t, it is uint64_t in x64 platform. Change these usage from uint32_to uint64_t to avoid trancation. Signed-off-by: Li Qiang --- hw/misc/edu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/misc/edu.c b/hw/misc/edu.c index 4018dddcb8..b93a679adf 100644 --- a/hw/misc/edu.c +++ b/hw/misc/edu.c @@ -98,23 +98,23 @@ 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%.8lx-0x%.8lx out of bounds (0x%.8lx-0x%.8lx)!", addr, end1 - 1, start, end2 - 1); } @@ -139,13 +139,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),