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=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 54C60C433DB for ; Mon, 11 Jan 2021 16:14:54 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (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 C82E122A84 for ; Mon, 11 Jan 2021 16:14:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C82E122A84 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 7D1808643F; Mon, 11 Jan 2021 16:14:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t31p6a9dBJIb; Mon, 11 Jan 2021 16:14:52 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 8D7C485DA4; Mon, 11 Jan 2021 16:14:52 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 676BBC088B; Mon, 11 Jan 2021 16:14:52 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5B54BC013A for ; Mon, 11 Jan 2021 16:14:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 3978E21515 for ; Mon, 11 Jan 2021 16:14:51 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XPFZjaI5PfYU for ; Mon, 11 Jan 2021 16:14:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by silver.osuosl.org (Postfix) with ESMTPS id BB6B721514 for ; Mon, 11 Jan 2021 16:14:48 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id C8DFE2247F; Mon, 11 Jan 2021 16:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610381688; bh=vU6H120stfuOQ5pc95UICs91NrCA+KFQFAToskWyZpA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hoSh/oB7ljXzyLCi+dfAntUXnizW2+IZJheAzTKPcGNh23wFUFYgQUhq27SIW4LDx OY+DaAU2Jf/Ag6O/o111G7gj+To6ZlXDCHNfiy9FXxnQIwrlhfXWQJ/7M6PxWi8m98 BNG+d/x4LtbzR9WHiAzpZNbY9j+SgRuaJV4Xaf3c= Date: Mon, 11 Jan 2021 17:15:59 +0100 From: Greg KH To: Marc Orr Subject: Re: [PATCH] dma: mark unmapped DMA scatter/gather invalid Message-ID: References: <20210111154335.23388-1-marcorr@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210111154335.23388-1-marcorr@google.com> Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, iommu@lists.linux-foundation.org, robin.murphy@arm.com, hch@lst.de, jxgao@google.com 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Mon, Jan 11, 2021 at 07:43:35AM -0800, Marc Orr wrote: > This patch updates dma_direct_unmap_sg() to mark each scatter/gather > entry invalid, after it's unmapped. This fixes two issues: > > 1. It makes the unmapping code able to tolerate a double unmap. > 2. It prevents the NVMe driver from erroneously treating an unmapped DMA > address as mapped. > > The bug that motivated this patch was the following sequence, which > occurred within the NVMe driver, with the kernel flag `swiotlb=force`. > > * NVMe driver calls dma_direct_map_sg() > * dma_direct_map_sg() fails part way through the scatter gather/list > * dma_direct_map_sg() calls dma_direct_unmap_sg() to unmap any entries > succeeded. > * NVMe driver calls dma_direct_unmap_sg(), redundantly, leading to a > double unmap, which is a bug. > > With this patch, a hadoop workload running on a cluster of three AMD > SEV VMs, is able to succeed. Without the patch, the hadoop workload > suffers application-level and even VM-level failures. > > Tested-by: Jianxiong Gao > Tested-by: Marc Orr > Reviewed-by: Jianxiong Gao > Signed-off-by: Marc Orr > --- > kernel/dma/direct.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly. _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 0F37AC433E0 for ; Mon, 11 Jan 2021 16:15:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1FFD22AAD for ; Mon, 11 Jan 2021 16:15:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388670AbhAKQP3 (ORCPT ); Mon, 11 Jan 2021 11:15:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:47312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730621AbhAKQP2 (ORCPT ); Mon, 11 Jan 2021 11:15:28 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C8DFE2247F; Mon, 11 Jan 2021 16:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610381688; bh=vU6H120stfuOQ5pc95UICs91NrCA+KFQFAToskWyZpA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hoSh/oB7ljXzyLCi+dfAntUXnizW2+IZJheAzTKPcGNh23wFUFYgQUhq27SIW4LDx OY+DaAU2Jf/Ag6O/o111G7gj+To6ZlXDCHNfiy9FXxnQIwrlhfXWQJ/7M6PxWi8m98 BNG+d/x4LtbzR9WHiAzpZNbY9j+SgRuaJV4Xaf3c= Date: Mon, 11 Jan 2021 17:15:59 +0100 From: Greg KH To: Marc Orr Cc: hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com, jxgao@google.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] dma: mark unmapped DMA scatter/gather invalid Message-ID: References: <20210111154335.23388-1-marcorr@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210111154335.23388-1-marcorr@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 11, 2021 at 07:43:35AM -0800, Marc Orr wrote: > This patch updates dma_direct_unmap_sg() to mark each scatter/gather > entry invalid, after it's unmapped. This fixes two issues: > > 1. It makes the unmapping code able to tolerate a double unmap. > 2. It prevents the NVMe driver from erroneously treating an unmapped DMA > address as mapped. > > The bug that motivated this patch was the following sequence, which > occurred within the NVMe driver, with the kernel flag `swiotlb=force`. > > * NVMe driver calls dma_direct_map_sg() > * dma_direct_map_sg() fails part way through the scatter gather/list > * dma_direct_map_sg() calls dma_direct_unmap_sg() to unmap any entries > succeeded. > * NVMe driver calls dma_direct_unmap_sg(), redundantly, leading to a > double unmap, which is a bug. > > With this patch, a hadoop workload running on a cluster of three AMD > SEV VMs, is able to succeed. Without the patch, the hadoop workload > suffers application-level and even VM-level failures. > > Tested-by: Jianxiong Gao > Tested-by: Marc Orr > Reviewed-by: Jianxiong Gao > Signed-off-by: Marc Orr > --- > kernel/dma/direct.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly.