From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08AE2C433DF for ; Mon, 25 May 2020 09:15:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D40E22073B for ; Mon, 25 May 2020 09:15:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D40E22073B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ilande.co.uk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jd9Ci-0005x1-WA for qemu-devel@archiver.kernel.org; Mon, 25 May 2020 05:15:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jd9Bo-0005XG-63 for qemu-devel@nongnu.org; Mon, 25 May 2020 05:14:32 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:50304 helo=mail.default.ilande.uk0.bigv.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jd9Bm-0003FH-SC for qemu-devel@nongnu.org; Mon, 25 May 2020 05:14:31 -0400 Received: from host109-156-104-24.range109-156.btcentralplus.com ([109.156.104.24] helo=[192.168.1.65]) by mail.default.ilande.uk0.bigv.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jd9Bl-0000Ng-O6; Mon, 25 May 2020 10:14:30 +0100 To: Bug 1880355 <1880355@bugs.launchpad.net>, qemu-devel@nongnu.org References: <159029353528.907.11982786579949073896.malonedeb@chaenomeles.canonical.com> From: Mark Cave-Ayland Autocrypt: addr=mark.cave-ayland@ilande.co.uk; keydata= mQENBFQJuzwBCADAYvxrwUh1p/PvUlNFwKosVtVHHplgWi5p29t58QlOUkceZG0DBYSNqk93 3JzBTbtd4JfFcSupo6MNNOrCzdCbCjZ64ik8ycaUOSzK2tKbeQLEXzXoaDL1Y7vuVO7nL9bG E5Ru3wkhCFc7SkoypIoAUqz8EtiB6T89/D9TDEyjdXUacc53R5gu8wEWiMg5MQQuGwzbQy9n PFI+mXC7AaEUqBVc2lBQVpAYXkN0EyqNNT12UfDLdxaxaFpUAE2pCa2LTyo5vn5hEW+i3VdN PkmjyPvL6DdY03fvC01PyY8zaw+UI94QqjlrDisHpUH40IUPpC/NB0LwzL2aQOMkzT2NABEB AAG0ME1hcmsgQ2F2ZS1BeWxhbmQgPG1hcmsuY2F2ZS1heWxhbmRAaWxhbmRlLmNvLnVrPokB OAQTAQIAIgUCVAm7PAIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQW8LFb64PMh9f NAgAuc3ObOEY8NbZko72AGrg2tWKdybcMVITxmcor4hb9155o/OWcA4IDbeATR6cfiDL/oxU mcmtXVgPqOwtW3NYAKr5g/FrZZ3uluQ2mtNYAyTFeALy8YF7N3yhs7LOcpbFP7tEbkSzoXNG z8iYMiYtKwttt40WaheWuRs0ZOLbs6yoczZBDhna3Nj0LA3GpeJKlaV03O4umjKJgACP1c/q T2Pkg+FCBHHFP454+waqojHp4OCBo6HyK+8I4wJRa9Z0EFqXIu8lTDYoggeX0Xd6bWeCFHK3 DhD0/Xi/kegSW33unsp8oVcM4kcFxTkpBgj39dB4KwAUznhTJR0zUHf63LkBDQRUCbs8AQgA y7kyevA4bpetM/EjtuqQX4U05MBhEz/2SFkX6IaGtTG2NNw5wbcAfhOIuNNBYbw6ExuaJ3um 2uLseHnudmvN4VSJ5Hfbd8rhqoMmmO71szgT/ZD9MEe2KHzBdmhmhxJdp+zQNivy215j6H27 14mbC2dia7ktwP1rxPIX1OOfQwPuqlkmYPuVwZP19S4EYnCELOrnJ0m56tZLn5Zj+1jZX9Co YbNLMa28qsktYJ4oU4jtn6V79H+/zpERZAHmH40IRXdR3hA+Ye7iC/ZpWzT2VSDlPbGY9Yja Sp7w2347L5G+LLbAfaVoejHlfy/msPeehUcuKjAdBLoEhSPYzzdvEQARAQABiQEfBBgBAgAJ BQJUCbs8AhsMAAoJEFvCxW+uDzIfabYIAJXmBepHJpvCPiMNEQJNJ2ZSzSjhic84LTMWMbJ+ opQgr5cb8SPQyyb508fc8b4uD8ejlF/cdbbBNktp3BXsHlO5BrmcABgxSP8HYYNsX0n9kERv NMToU0oiBuAaX7O/0K9+BW+3+PGMwiu5ml0cwDqljxfVN0dUBZnQ8kZpLsY+WDrIHmQWjtH+ Ir6VauZs5Gp25XLrL6bh/SL8aK0BX6y79m5nhfKI1/6qtzHAjtMAjqy8ChPvOqVVVqmGUzFg KPsrrIoklWcYHXPyMLj9afispPVR8e0tMKvxzFBWzrWX1mzljbBlnV2n8BIwVXWNbgwpHSsj imgcU9TTGC5qd9g= Message-ID: <7c926f3c-2097-fb27-a552-0933bcf9ec4d@ilande.co.uk> Date: Mon, 25 May 2020 10:14:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 109.156.104.24 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: Re: [Bug 1880355] [NEW] Length restrictions for fw_cfg_dma_transfer? X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.uk0.bigv.io) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.uk0.bigv.io X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 24/05/2020 14:40, Peter Maydell wrote: > On Sun, 24 May 2020 at 11:30, Philippe Mathieu-Daudé wrote: >> It looks to me a normal behavior for a DMA device. DMA devices have a >> different address space view than the CPUs. >> Also note the fw_cfg is a generic device, not restricted to the x86 arch. > > In an ideal world all our DMA devices would use some kind of common > framework or design pattern so they didn't hog all the CPU > and/or spend minutes with the BQL held if the guest requests > an enormous-sized DMA. In practice many of them just have > a simple "loop until the DMA transfer is complete" implementation... One of the problems with the PPC Mac DBDMA emulation is that the controller is effectively a mini-CPU that runs its own programs for transferring data to/from memory. Currently this is done as a QEMU BH which means for larger transfers the emulated CPU can be paused for a not insignificant amount of time until the program performing the transfer finishes. I've always wondered if this should be running in a separate thread to reduce its impact. ATB, Mark. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79491C433E0 for ; Mon, 25 May 2020 09:21:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4C7712071A for ; Mon, 25 May 2020 09:21:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C7712071A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bugs.launchpad.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jd9IW-0000gj-GK for qemu-devel@archiver.kernel.org; Mon, 25 May 2020 05:21:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jd9Hj-000077-UP for qemu-devel@nongnu.org; Mon, 25 May 2020 05:20:39 -0400 Received: from indium.canonical.com ([91.189.90.7]:39788) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jd9Hi-0004C4-Gd for qemu-devel@nongnu.org; Mon, 25 May 2020 05:20:39 -0400 Received: from loganberry.canonical.com ([91.189.90.37]) by indium.canonical.com with esmtp (Exim 4.86_2 #2 (Debian)) id 1jd9Hg-0004Er-Ki for ; Mon, 25 May 2020 09:20:36 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 7045A2E807E for ; Mon, 25 May 2020 09:20:36 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Date: Mon, 25 May 2020 09:14:27 -0000 From: Mark Cave-Ayland <1880355@bugs.launchpad.net> To: qemu-devel@nongnu.org X-Launchpad-Notification-Type: bug X-Launchpad-Bug: product=qemu; status=New; importance=Undecided; assignee=None; X-Launchpad-Bug-Information-Type: Public X-Launchpad-Bug-Private: no X-Launchpad-Bug-Security-Vulnerability: no X-Launchpad-Bug-Commenters: a1xndr mark-cave-ayland philmd pmaydell X-Launchpad-Bug-Reporter: Alexander Bulekov (a1xndr) X-Launchpad-Bug-Modifier: Mark Cave-Ayland (mark-cave-ayland) References: <159029353528.907.11982786579949073896.malonedeb@chaenomeles.canonical.com> Message-ID: <7c926f3c-2097-fb27-a552-0933bcf9ec4d@ilande.co.uk> Subject: Re: [Bug 1880355] [NEW] Length restrictions for fw_cfg_dma_transfer? X-Launchpad-Message-Rationale: Subscriber (QEMU) @qemu-devel-ml X-Launchpad-Message-For: qemu-devel-ml Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="1f7bc749b40714a4cc10f5e4d787118a78037035"; Instance="production-secrets-lazr.conf" X-Launchpad-Hash: b9b991838aad7959be045b8efad0fc759ca1ef9a Received-SPF: none client-ip=91.189.90.7; envelope-from=bounces@canonical.com; helo=indium.canonical.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/25 02:00:57 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -65 X-Spam_score: -6.6 X-Spam_bar: ------ X-Spam_report: (-6.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Bug 1880355 <1880355@bugs.launchpad.net> Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Message-ID: <20200525091427.dq7m4df5fOhgdCiC5OGNCNukkw_LEL4taiYJL-3JyPw@z> On 24/05/2020 14:40, Peter Maydell wrote: > On Sun, 24 May 2020 at 11:30, Philippe Mathieu-Daud=C3=A9 wrote: >> It looks to me a normal behavior for a DMA device. DMA devices have a >> different address space view than the CPUs. >> Also note the fw_cfg is a generic device, not restricted to the x86 arch. > = > In an ideal world all our DMA devices would use some kind of common > framework or design pattern so they didn't hog all the CPU > and/or spend minutes with the BQL held if the guest requests > an enormous-sized DMA. In practice many of them just have > a simple "loop until the DMA transfer is complete" implementation... One of the problems with the PPC Mac DBDMA emulation is that the controller= is effectively a mini-CPU that runs its own programs for transferring data to/= from memory. Currently this is done as a QEMU BH which means for larger transfers the em= ulated CPU can be paused for a not insignificant amount of time until the program perf= orming the transfer finishes. I've always wondered if this should be running in a sepa= rate thread to reduce its impact. ATB, Mark. -- = You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1880355 Title: Length restrictions for fw_cfg_dma_transfer? Status in QEMU: New Bug description: For me, this takes close to 3 minutes at 100% CPU: echo "outl 0x518 0x9596ffff" | ./i386-softmmu/qemu-system-i386 -M q35 -m = 32 -nographic -accel qtest -monitor none -serial none -qtest stdio #0 phys_page_find (d=3D0x606000035d80, addr=3D136728041144404) at /exec.= c:338 #1 address_space_lookup_region (d=3D0x606000035d80, addr=3D1367280411444= 04, resolve_subpage=3Dtrue) at /exec.c:363 #2 address_space_translate_internal (d=3D0x606000035d80, addr=3D13672804= 1144404, xlat=3D0x7fff1fc0d070, plen=3D0x7fff1fc0d090, resolve_subpage=3Dtr= ue) at /exec.c:382 #3 flatview_do_translate (fv=3D0x606000035d20, addr=3D136728041144404, x= lat=3D0x7fff1fc0d070, plen_out=3D0x7fff1fc0d090, page_mask_out=3D0x0, is_wr= ite=3Dtrue, is_mmio=3Dtrue, target_as=3D0x7fff1fc0ce10, attrs=3D...) pment/qemu/exec.c:520 #4 flatview_translate (fv=3D0x606000035d20, addr=3D136728041144404, xlat= =3D0x7fff1fc0d070, plen=3D0x7fff1fc0d090, is_write=3Dtrue, attrs=3D...) at = /exec.c:586 #5 flatview_write_continue (fv=3D0x606000035d20, addr=3D136728041144404,= attrs=3D..., ptr=3D0x7fff1fc0d660, len=3D172, addr1=3D136728041144400, l= =3D172, mr=3D0x557fd54e77e0 ) pment/qemu/exec.c:3160 #6 flatview_write (fv=3D0x606000035d20, addr=3D136728041144064, attrs=3D= ..., buf=3D0x7fff1fc0d660, len=3D512) at /exec.c:3177 #7 address_space_write (as=3D0x557fd54e7a00 , addr= =3D136728041144064, attrs=3D..., buf=3D0x7fff1fc0d660, len=3D512) at /exec.= c:3271 #8 dma_memory_set (as=3D0x557fd54e7a00 , addr=3D13= 6728041144064, c=3D0 '\000', len=3D1378422272) at /dma-helpers.c:31 #9 fw_cfg_dma_transfer (s=3D0x61a000001e80) at /hw/nvram/fw_cfg.c:400 #10 fw_cfg_dma_mem_write (opaque=3D0x61a000001e80, addr=3D4, value=3D4294= 940309, size=3D4) at /hw/nvram/fw_cfg.c:467 #11 memory_region_write_accessor (mr=3D0x61a000002200, addr=3D4, value=3D= 0x7fff1fc0e3d0, size=3D4, shift=3D0, mask=3D4294967295, attrs=3D...) at /me= mory.c:483 #12 access_with_adjusted_size (addr=3D4, value=3D0x7fff1fc0e3d0, size=3D4= , access_size_min=3D1, access_size_max=3D8, access_fn=3D0x557fd2288c80 , mr=3D0x61a000002200, attrs=3D...) pment/qemu/memory.c:539 #13 memory_region_dispatch_write (mr=3D0x61a000002200, addr=3D4, data=3D4= 294940309, op=3DMO_32, attrs=3D...) at /memory.c:1476 #14 flatview_write_continue (fv=3D0x606000035f00, addr=3D1304, attrs=3D..= ., ptr=3D0x7fff1fc0ec40, len=3D4, addr1=3D4, l=3D4, mr=3D0x61a000002200) at= /exec.c:3137 #15 flatview_write (fv=3D0x606000035f00, addr=3D1304, attrs=3D..., buf=3D= 0x7fff1fc0ec40, len=3D4) at /exec.c:3177 #16 address_space_write (as=3D0x557fd54e7bc0 , addr=3D1= 304, attrs=3D..., buf=3D0x7fff1fc0ec40, len=3D4) at /exec.c:3271 = It looks like fw_cfg_dma_transfer gets the address(136728041144064) and l= ength(1378422272) for the read from the value provided as input 4294940309 = (0xFFFF9695) which lands in pcbios. Should there be any limits on the lengt= h of guest-memory that fw_cfg should populate? Found by libfuzzer To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1880355/+subscriptions