From patchwork Fri May 10 16:43:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 1098221 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=163.com header.i=@163.com header.b="atMpWE9N"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 450wzr04TPz9s3Z for ; Sat, 11 May 2019 02:44:56 +1000 (AEST) Received: from localhost ([127.0.0.1]:46617 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP8dh-0004cO-VK for incoming@patchwork.ozlabs.org; Fri, 10 May 2019 12:44:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP8cz-0004ap-Oa for qemu-devel@nongnu.org; Fri, 10 May 2019 12:44:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hP8cx-0002TZ-Qa for qemu-devel@nongnu.org; Fri, 10 May 2019 12:44:09 -0400 Received: from m12-13.163.com ([220.181.12.13]:46005) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP8cu-0002Qe-3W for qemu-devel@nongnu.org; Fri, 10 May 2019 12:44:06 -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=atMpWE9NfCa8GoiKHkpZLj3h32797ZQ9sW 6agk9hgaE/9EmqvsxVGa2INuti9qYWMxKEoB3KF2WECkLxW+hFR0r8BlooLusLDr QiJxntXA75xFnCi9m2hg1ijoaJFBx4sD4NEa+4ufoHZCpMKO1Z2cPgl3IWNXj0UH icba3fSGQ= Received: from localhost.localdomain (unknown [183.159.64.133]) by smtp9 (Coremail) with SMTP id DcCowAB3fTFLqtVcVYWnCg--.3399S3; Sat, 11 May 2019 00:44:00 +0800 (CST) From: Li Qiang To: pbonzini@redhat.com, jslaby@suse.cz Date: Fri, 10 May 2019 09:43:47 -0700 Message-Id: <20190510164349.81507-2-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--.3399S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrZF4xJFWUXF4UurW3Kr4rKrg_yoW3urg_Jw 1xGFZ7urW5Wry3AF9YqF13ur1xW3yrAFn5uFnagr4fJa4rCF98Z3sagrnxXw47Gw1fCwn5 ZaykZFy5Kr9rWjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUUVMNUUUUUU== X-Originating-IP: [183.159.64.133] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbBZhCwbVaD1aHioAAAsI X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.13 Subject: [Qemu-devel] [PATCH v4 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: liq3ea@gmail.com, philmd@redhat.com, qemu-devel@nongnu.org, Li Qiang Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Fri May 10 16:43:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 1098222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=163.com header.i=@163.com header.b="KcMN8NL/"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 450x012CwVz9sB8 for ; Sat, 11 May 2019 02:45:05 +1000 (AEST) Received: from localhost ([127.0.0.1]:46619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP8dr-0004jQ-7I for incoming@patchwork.ozlabs.org; Fri, 10 May 2019 12:45:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP8d6-0004gO-Gl for qemu-devel@nongnu.org; Fri, 10 May 2019 12:44:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hP8d5-0002Wj-Fl for qemu-devel@nongnu.org; Fri, 10 May 2019 12:44:16 -0400 Received: from m12-13.163.com ([220.181.12.13]:46138) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP8cx-0002Se-WA for qemu-devel@nongnu.org; Fri, 10 May 2019 12:44:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=QIasgmbFmQFh6heCmI oYYkbFdxWLVq+R+/WMqUG2ufw=; b=KcMN8NL/TEWg1qIbJjkXqrvWFqEdoC/lrA SPE8vMTrBcYanSqHa3xy5tPsHxILnCobWNE0UBWVg5XnM9Ro5ZRex7tZIW+3Lcz1 xiBLKxHniMsQSFte3sd7QJHNE3OrJDpnyyNdDxrflbKC9qtBPhQY7L9VO6LCBn38 F+1CfZih0= Received: from localhost.localdomain (unknown [183.159.64.133]) by smtp9 (Coremail) with SMTP id DcCowAB3fTFLqtVcVYWnCg--.3399S4; Sat, 11 May 2019 00:44:01 +0800 (CST) From: Li Qiang To: pbonzini@redhat.com, jslaby@suse.cz Date: Fri, 10 May 2019 09:43:48 -0700 Message-Id: <20190510164349.81507-3-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--.3399S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrZFWrCw18XrWDAw1fGw4rZrb_yoWxAwc_A3 y0ka9rZFWDKFy3CF12vFnxZr1UJw4rZryfua1Iqrs7ArZ8CrW8A34vgFnrGw47XrZxury8 Z3yDZFyvkr9IgjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU8-18DUUUUU== X-Originating-IP: [183.159.64.133] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbBLxGwbVUMJPd5SAAAsY X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.13 Subject: [Qemu-devel] [PATCH v4 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: liq3ea@gmail.com, philmd@redhat.com, qemu-devel@nongnu.org, Li Qiang Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 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: 1098225 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=163.com header.i=@163.com header.b="gvgXbDqQ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 450x8r6tVFz9sB8 for ; Sat, 11 May 2019 02:52:44 +1000 (AEST) Received: from localhost ([127.0.0.1]:46800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP8lG-00035u-MS for incoming@patchwork.ozlabs.org; Fri, 10 May 2019 12:52:42 -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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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),