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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCACEC433EF for ; Tue, 8 Feb 2022 14:19:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377951AbiBHOTe (ORCPT ); Tue, 8 Feb 2022 09:19:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351022AbiBHOT3 (ORCPT ); Tue, 8 Feb 2022 09:19:29 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6259C03FECE; Tue, 8 Feb 2022 06:19:28 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id v13-20020a17090ac90d00b001b87bc106bdso2160396pjt.4; Tue, 08 Feb 2022 06:19:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=wxTG+XyoVyvm3qwt67A3uD8d+hQFZ2NnOQ/flBE0K98=; b=Dcro/51npE6vWkDlp954rF9hqbFflacWu4JiIGGktclCeAmxm93szVWwkjci8bhdFJ 36QJEAczLxpsK0jwHsOuPvdjL2WToJgY8N6aGnUP+w9Gj9WgMP5r0XsFE9yIv4NdnMlu qfYKz8q0A1LMRLC/dRdGUw94ANm9VgfZC+Ljakagf8CsKcv5Occ3rxLsAfjrGm5Uy37D 8lAMM00gBwsDDMrFyNMhI0YpEesWLlk2gvmGPe4Dpra7S+uucD57GJ1CAmsaN5RruBio nabdG4q6UQb6hkdxr08YJY9bZObUVDCuO/tlaF1Q2MuUGuo1A8N5HpVqWPXRQDqMcRkJ f2pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=wxTG+XyoVyvm3qwt67A3uD8d+hQFZ2NnOQ/flBE0K98=; b=qngM5bA7epZ885Qrq3ETHaNVBYqRZyQoMHOYTSD0yEcf99oxFirkqyXn3oTQ8gEEwd BA74DUSlvpd6A9r5FlGeVcH8IgPL73VGw1DK36/iajZGk3x7KLgY4jno630APGGR5cRz h+IEoAbioc34Y6rI+aP/499ZZ6REILdGD1nDUR5JO7Wi93Oeam9SlowRjU53uF6SUZMA 0Xk2Lrvip/mjibTDB/sovxMNHo1F1F9m/ZyWnGDnERPseZsa3T/CSbxDV3Ik5JllMuN5 hUwU9IMZr6PT/k0Yb763NI8LcNERFYbVHkaa/f4aLbPu0YdSHzbilKSLX608PuHO21Du YoXA== X-Gm-Message-State: AOAM5300+RO+6W3HS9hqynu3/TxGpn/9PXzBvmthTJOp/9bKdErQmd1Y WOXNXZpJ3SSdQS2X7ZIgwsIxa/Xtuw+pGBQ8 X-Google-Smtp-Source: ABdhPJz67xSgge/ra2Q7eUO/CH9AuwGGYdwz22g+8hA50Wkv9TgPYjVaIUTlf8RdSMiEj29u5mBg6A== X-Received: by 2002:a17:903:120e:: with SMTP id l14mr4691979plh.124.1644329968221; Tue, 08 Feb 2022 06:19:28 -0800 (PST) Received: from ?IPV6:2404:f801:10:102:8000::f381? ([2404:f801:8050:1:c1::f381]) by smtp.gmail.com with ESMTPSA id f15sm16713478pfv.189.2022.02.08.06.19.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Feb 2022 06:19:27 -0800 (PST) Message-ID: <6ee926b0-5579-bb9b-da94-51d793a3d782@gmail.com> Date: Tue, 8 Feb 2022 22:19:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] Netvsc: Call hv_unmap_memory() in the netvsc_device_remove() Content-Language: en-US To: "Michael Kelley (LINUX)" , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , "wei.liu@kernel.org" , Dexuan Cui , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "x86@kernel.org" , "hpa@zytor.com" , "davem@davemloft.net" , "kuba@kernel.org" , "hch@infradead.org" , "m.szyprowski@samsung.com" , "robin.murphy@arm.com" Cc: Tianyu Lan , "iommu@lists.linux-foundation.org" , "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" References: <20220201163211.467423-1-ltykernel@gmail.com> From: Tianyu Lan In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/3/2022 1:05 AM, Michael Kelley (LINUX) wrote: > From: Tianyu Lan Sent: Tuesday, February 1, 2022 8:32 AM >> netvsc_device_remove() calls vunmap() inside which should not be >> called in the interrupt context. Current code calls hv_unmap_memory() >> in the free_netvsc_device() which is rcu callback and maybe called >> in the interrupt context. This will trigger BUG_ON(in_interrupt()) >> in the vunmap(). Fix it via moving hv_unmap_memory() to netvsc_device_ >> remove(). > I think this change can fail to call hv_unmap_memory() in an error case. > > If netvsc_init_buf() fails after hv_map_memory() succeeds for the receive > buffer or for the send buffer, no corresponding hv_unmap_memory() will > be done. The failure in netvsc_init_buf() will cause netvsc_connect_vsp() > to fail, so netvsc_add_device() will "goto close" where free_netvsc_device() > will be called. But free_netvsc_device() no longer calls hv_unmap_memory(), > so it won't ever happen. netvsc_device_remove() is never called in this case > because netvsc_add_device() failed. > Hi Michael: Thanks for your review. Nice catch and will fix in the next version. 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 Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 27BD5C4332F for ; Tue, 8 Feb 2022 14:19:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id B202160ED9; Tue, 8 Feb 2022 14:19:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eVuA5zkdVauH; Tue, 8 Feb 2022 14:19:32 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 8430B607B0; Tue, 8 Feb 2022 14:19:31 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 43BC7C001A; Tue, 8 Feb 2022 14:19:31 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id A504DC000B for ; Tue, 8 Feb 2022 14:19:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 7F1D781B23 for ; Tue, 8 Feb 2022 14:19:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wtymNg1yJ12A for ; Tue, 8 Feb 2022 14:19:29 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by smtp1.osuosl.org (Postfix) with ESMTPS id 086A781B7B for ; Tue, 8 Feb 2022 14:19:28 +0000 (UTC) Received: by mail-pj1-x1030.google.com with SMTP id qe15so6904139pjb.3 for ; Tue, 08 Feb 2022 06:19:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=wxTG+XyoVyvm3qwt67A3uD8d+hQFZ2NnOQ/flBE0K98=; b=Dcro/51npE6vWkDlp954rF9hqbFflacWu4JiIGGktclCeAmxm93szVWwkjci8bhdFJ 36QJEAczLxpsK0jwHsOuPvdjL2WToJgY8N6aGnUP+w9Gj9WgMP5r0XsFE9yIv4NdnMlu qfYKz8q0A1LMRLC/dRdGUw94ANm9VgfZC+Ljakagf8CsKcv5Occ3rxLsAfjrGm5Uy37D 8lAMM00gBwsDDMrFyNMhI0YpEesWLlk2gvmGPe4Dpra7S+uucD57GJ1CAmsaN5RruBio nabdG4q6UQb6hkdxr08YJY9bZObUVDCuO/tlaF1Q2MuUGuo1A8N5HpVqWPXRQDqMcRkJ f2pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=wxTG+XyoVyvm3qwt67A3uD8d+hQFZ2NnOQ/flBE0K98=; b=MiLoa5tV+Qwgs2P1An6PHCqoLU1Et111hvwo4MznLFyyG3HxfYZwNxVCsu5Jt3nOOv x4s2/TR8DhaUUaWfog9gXJw9FopigYr4+tSi2McQe9wvtVcGb0OzkEiCnjH1AINXlxW6 6d9dBiMoSGRN808spJlFj0tpsba5nrK+IRfCFfkYuAzbvrAL29Va6gJQkJTHXb+/epv6 8s+VqtsdfaO+Cx+U69KlDo6maJ1T8ct5D/6HUAIswpNzgUeTgnuzHYJWJl+ICV/3v9h7 o8BIKMW1Hpwely7lBK8J53nqHOkVsylTzNblBaFVJCs00co4OfJQKCLvEQfEfzeCwSVj ohvg== X-Gm-Message-State: AOAM532YPj8DmnIVyoyjvSzSlA9RFeY6tOTgtbnvxIt0BBU5rmqevJ5M L+InKmH7PFxARYZfkH7k3LI= X-Google-Smtp-Source: ABdhPJz67xSgge/ra2Q7eUO/CH9AuwGGYdwz22g+8hA50Wkv9TgPYjVaIUTlf8RdSMiEj29u5mBg6A== X-Received: by 2002:a17:903:120e:: with SMTP id l14mr4691979plh.124.1644329968221; Tue, 08 Feb 2022 06:19:28 -0800 (PST) Received: from ?IPV6:2404:f801:10:102:8000::f381? ([2404:f801:8050:1:c1::f381]) by smtp.gmail.com with ESMTPSA id f15sm16713478pfv.189.2022.02.08.06.19.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Feb 2022 06:19:27 -0800 (PST) Message-ID: <6ee926b0-5579-bb9b-da94-51d793a3d782@gmail.com> Date: Tue, 8 Feb 2022 22:19:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] Netvsc: Call hv_unmap_memory() in the netvsc_device_remove() Content-Language: en-US To: "Michael Kelley (LINUX)" , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , "wei.liu@kernel.org" , Dexuan Cui , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "x86@kernel.org" , "hpa@zytor.com" , "davem@davemloft.net" , "kuba@kernel.org" , "hch@infradead.org" , "m.szyprowski@samsung.com" , "robin.murphy@arm.com" References: <20220201163211.467423-1-ltykernel@gmail.com> From: Tianyu Lan In-Reply-To: Cc: "netdev@vger.kernel.org" , "iommu@lists.linux-foundation.org" , Tianyu Lan , "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On 2/3/2022 1:05 AM, Michael Kelley (LINUX) wrote: > From: Tianyu Lan Sent: Tuesday, February 1, 2022 8:32 AM >> netvsc_device_remove() calls vunmap() inside which should not be >> called in the interrupt context. Current code calls hv_unmap_memory() >> in the free_netvsc_device() which is rcu callback and maybe called >> in the interrupt context. This will trigger BUG_ON(in_interrupt()) >> in the vunmap(). Fix it via moving hv_unmap_memory() to netvsc_device_ >> remove(). > I think this change can fail to call hv_unmap_memory() in an error case. > > If netvsc_init_buf() fails after hv_map_memory() succeeds for the receive > buffer or for the send buffer, no corresponding hv_unmap_memory() will > be done. The failure in netvsc_init_buf() will cause netvsc_connect_vsp() > to fail, so netvsc_add_device() will "goto close" where free_netvsc_device() > will be called. But free_netvsc_device() no longer calls hv_unmap_memory(), > so it won't ever happen. netvsc_device_remove() is never called in this case > because netvsc_add_device() failed. > Hi Michael: Thanks for your review. Nice catch and will fix in the next version. _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu