Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C83EAC77B7A for ; Thu, 1 Jun 2023 07:16:42 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.542254.845893 (Exim 4.92) (envelope-from ) id 1q4cXd-0006Fd-0U; Thu, 01 Jun 2023 07:16:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 542254.845893; Thu, 01 Jun 2023 07:16:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q4cXc-0006FW-TS; Thu, 01 Jun 2023 07:16:12 +0000 Received: by outflank-mailman (input) for mailman id 542254; Thu, 01 Jun 2023 07:16:11 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q4cXb-0006FQ-Rz for xen-devel@lists.xenproject.org; Thu, 01 Jun 2023 07:16:11 +0000 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [2a00:1450:4864:20::329]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2dc3f3eb-004c-11ee-b231-6b7b168915f2; Thu, 01 Jun 2023 09:16:08 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3f603ff9c02so5247215e9.2 for ; Thu, 01 Jun 2023 00:16:08 -0700 (PDT) Received: from [192.168.69.115] ([176.176.141.224]) by smtp.gmail.com with ESMTPSA id f15-20020a7bcd0f000000b003f4272c2d0csm1185408wmj.36.2023.06.01.00.16.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Jun 2023 00:16:07 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2dc3f3eb-004c-11ee-b231-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685603768; x=1688195768; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=WxzX/yCNlI8j55zMId0+95rQUKgWabv2ID5tlei60QM=; b=Gen2Cia+8jwTVAFZKVgGWlirQvMrtFyXZ9UoEsuR/bvjDIJOGRMO1lVO1gSIX4316Q +OJNvgZk8IX1ihXqQXwqenIpLkmpItGw5/co228wbljIfirJPEqEEgVld+V61ZA3s5zA Cic5VL9KIipJMomumYYWISL9cGH3jPqHF99y/q15gHBv7D12a5Mw/5ZIymC48Sm9y5sS qkuas5BNYbHlymXURf3sSCAO+av/DtT0fuSx5WKZ/JOXOBF75uwl7oSoOb0rAt2dV4es MGwK0yAJHxO7sI6vCYvZEVfTWDmIkQU2ZD82keOoDRTLpHyLMypa+6jxdJ6OWGPlyBA3 5Bjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685603768; x=1688195768; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WxzX/yCNlI8j55zMId0+95rQUKgWabv2ID5tlei60QM=; b=UMdgTtLjZTNlDx4sj8Zbwr+FJZrLFmSJGOoEhw2YASEHZwBZbHrY7ODFxzecD1C3vZ 4F5FJr/qqyAepd3iJyITfI862l0EQd5GWSnzuLbO88pBAO9FzWdK+Px9ZLvbQ2ugFd0O aP3nEbUsd9aAoFGPADMrFS4sShsWWSvonnXrOvfku5IfD1pl4/ivUUUmZAUXx7VRd6Cz h7cPAfmNSPKfHDEFQh6WuzvQkmiXEWViFnUdaara9DZPRquS305NiKYITkDel8RAdTnx vh2riY+IVNT295tVWuKnUnf8toL90EPWOm2TMieLBN8zMQodEfqv+7qvdie2jyTtayM0 Gqhg== X-Gm-Message-State: AC+VfDwAw/dG6Um71CeTN9GtL8fzxKqLvU6KyCraiNVCRVP7buceQlur m/0ONCWGR2/vZ4mKNwUa5yjyuA== X-Google-Smtp-Source: ACHHUZ4hON2fkLvrpZTHSEtZk4pe9Oj8d4QR+Z+nkJfpLOiDJ009Fgvl5JdUmRVI16HmDclpVVxrAQ== X-Received: by 2002:a7b:c5d4:0:b0:3f6:ffe:9ef1 with SMTP id n20-20020a7bc5d4000000b003f60ffe9ef1mr1110012wmk.36.1685603767760; Thu, 01 Jun 2023 00:16:07 -0700 (PDT) Message-ID: <72ccd4c2-7c60-e015-2322-721d09a8334b@linaro.org> Date: Thu, 1 Jun 2023 09:16:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v2 0/2] net: Update MemReentrancyGuard for NIC Content-Language: en-US To: Akihiko Odaki Cc: Mauro Matteo Cascella , P J P , Alexander Bulekov , Dmitry Fleytman , Beniamino Galvani , Peter Maydell , Strahinja Jankovic , Jason Wang , "Edgar E. Iglesias" , Alistair Francis , Stefan Weil , =?UTF-8?Q?C=c3=a9dric_Le_Goater?= , Andrew Jeffery , Joel Stanley , Richard Henderson , Helge Deller , Sriram Yagnaraman , Thomas Huth , Aleksandar Rikalo , Subbaraya Sundeep , Jan Kiszka , Tyrone Ting , Hao Wu , Max Filippov , Jiri Pirko , Daniel Henrique Barboza , David Gibson , Greg Kurz , Harsh Prateek Bora , Sven Schnelle , "Michael S. Tsirkin" , Stefano Stabellini , Anthony Perard , Paul Durrant , Rob Herring , Gerd Hoffmann , qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, xen-devel@lists.xenproject.org References: <20230601031859.7115-1-akihiko.odaki@daynix.com> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= In-Reply-To: <20230601031859.7115-1-akihiko.odaki@daynix.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/6/23 05:18, Akihiko Odaki wrote: > Recently MemReentrancyGuard was added to DeviceState to record that the > device is engaging in I/O. The network device backend needs to update it > when delivering a packet to a device. > > This implementation follows what bottom half does, but it does not add > a tracepoint for the case that the network device backend started > delivering a packet to a device which is already engaging in I/O. This > is because such reentrancy frequently happens for > qemu_flush_queued_packets() and is insignificant. > > This series consists of two patches. The first patch makes a bulk change to > add a new parameter to qemu_new_nic() and does not contain behavioral changes. > The second patch actually implements MemReentrancyGuard update. /me look at the 'net' API. So the NetReceive* handlers from NetClientInfo process the HW NIC data flow, independently from the CPUs. IIUC MemReentrancyGuard is supposed to protect reentrancy abuse from CPUs. NetReceive* handlers aren't restricted to any particular API, they just consume blob of data. Looking at e1000_receive_iov(), this data is filled into memory using the pci_dma_rw() API. pci_dma_rw() gets the AddressSpace to use calling pci_get_address_space(), which returns PCIDevice::bus_master_as. Then we use the dma_memory_rw(), followed by address_space_rw(). Beh, I fail to see why there is reentrancy checks from this NIC DMA HW path. Maybe the MemoryRegion API isn't the correct place to check for reentrancy abuse and we should do that at the AddressSpace level, keeping DMA ASes clear and only protecting CPU ASes?