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=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 10AD3C07E95 for ; Tue, 13 Jul 2021 23:54:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E67386100C for ; Tue, 13 Jul 2021 23:54:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237033AbhGMX5I (ORCPT ); Tue, 13 Jul 2021 19:57:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235437AbhGMX5H (ORCPT ); Tue, 13 Jul 2021 19:57:07 -0400 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 396C3C0613DD for ; Tue, 13 Jul 2021 16:54:16 -0700 (PDT) Received: by mail-qk1-x735.google.com with SMTP id 23so2260876qke.0 for ; Tue, 13 Jul 2021 16:54:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=psNqCrBwCGRPV0GMx0UJi9q1GTstXYN3y24OgE9aFHA=; b=nAn1ZBctObW5/4rzcwbWcXacQkKZzr+xNKjOPvXZEJkFWoXKOXpGusecOIwp2Bkkg8 gQx0KPcNl3VanNIuObMwevvxTyfI3v5ASEzsLaWrlzElfTAv2KwigogKaIDDqyk38nTU 21v2QUakO9PeQqSV/k9mHvzbQmbPMvbgbHCedUgtf8szFThAeyNt6Q3ek3wTC6RZEUhl p37zswHknxz2+J7q4tV+WF/DUblIwzz73KSWFvdWA5MatZv4P5NRdAihrggZKv4IBWl5 mwqZuMZZS6cpQPBZL17XvkhZOGLnGW81B9ErVPSttvz6F20wjdSYJm+vC9ceHZQq20qv wjTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=psNqCrBwCGRPV0GMx0UJi9q1GTstXYN3y24OgE9aFHA=; b=bnvV+eAwaYMu1qyD4lfAAMU0KykWZa7OoteqdLJoZ/B685WSMGOcv5ihK8aP5ARzV7 LaafgvulCt8Q36eb1hckHxTGkyphrn4XZy8ZEcIooibJv6iAmbwN/pp1iHI03ZkWFizK ejA8vWA+ynci4VYUqL21Qw0VU3FWuQKBKgCXgG90UkGVHp7nqTsctaguswuSOvkZdjdU mjtSscnA4UL3yd6FjpeeGPVYt0qwT5pR2sa8YHp09dZSzS6BS439PPKQaqOqMGj9CKS5 Vu+6oXObCohBkEBYzc5wZbaAAoLaG6Z5TbHDovbgLZJ5JMv6pIO3Q97V502piGuBTNtc jvKg== X-Gm-Message-State: AOAM5314mdbYw2Ly2sSPJtCt3BrFPuAHm/e+0Z8rFhdxdkJq8ayWiWE6 waltK19RC+ms/6NI+6fIq60= X-Google-Smtp-Source: ABdhPJy9aRtw6TRboqtQn9nRqg1AhyGHGFH4KJheCNecEuLTHHQvQx/DiTyi4lhZrGrHwKCG81Niug== X-Received: by 2002:a05:620a:709:: with SMTP id 9mr6857281qkc.493.1626220455313; Tue, 13 Jul 2021 16:54:15 -0700 (PDT) Received: from fedora ([130.44.160.152]) by smtp.gmail.com with ESMTPSA id l4sm206872qkd.77.2021.07.13.16.54.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 16:54:14 -0700 (PDT) Sender: Konrad Rzeszutek Wilk Date: Tue, 13 Jul 2021 19:54:12 -0400 From: Konrad Rzeszutek Wilk To: Dominique Martinet Cc: Konrad Rzeszutek Wilk , linux-kernel@vger.kernel.org, Bumyong Lee , iommu@lists.linux-foundation.org, Chanho Park , Robin Murphy , Christoph Hellwig Subject: Re: [PATCH] swiotlb: add overflow checks to swiotlb_bounce Message-ID: References: <20210707051254.2121603-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210707051254.2121603-1-dominique.martinet@atmark-techno.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 07, 2021 at 02:12:54PM +0900, Dominique Martinet wrote: > This is a follow-up on 5f89468e2f06 ("swiotlb: manipulate orig_addr > when tlb_addr has offset") which fixed unaligned dma mappings, > making sure the following overflows are caught: > > - offset of the start of the slot within the device bigger than > requested address' offset, in other words if the base address > given in swiotlb_tbl_map_single to create the mapping (orig_addr) > was after the requested address for the sync (tlb_offset) in the > same block: > > |------------------------------------------| block > <----------------------------> mapped part of the block > ^ > orig_addr > ^ > invalid tlb_addr for sync > > - if the resulting offset was bigger than the allocation size > this one could happen if the mapping was not until the end. e.g. > > |------------------------------------------| block > <---------------------> mapped part of the block > ^ ^ > orig_addr invalid tlb_addr > > Both should never happen so print a warning and bail out without trying > to adjust the sizes/offsets: the first one could try to sync from > orig_addr to whatever is left of the requested size, but the later > really has nothing to sync there... > > Signed-off-by: Dominique Martinet > Cc: Konrad Rzeszutek Wilk > Cc: Bumyong Lee > Cc: Chanho Park > Cc: Christoph Hellwig > --- > > Hi Konrad, > > here's the follow up for the swiotlb/caamjr regression I had promissed. Awesome! > It doesn't really change anything, and I confirmed I don't hit either of > the warnings on our board, but it's probably best to have as either > could really happen. :nods: I put it in the devel/for-linus-5.14 and linux-next. Thank you! 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=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_RED 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 34A9AC07E95 for ; Tue, 13 Jul 2021 23:54:23 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 992D761369 for ; Tue, 13 Jul 2021 23:54:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 992D761369 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=darnok.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 smtp3.osuosl.org (Postfix) with ESMTP id 5F87560795; Tue, 13 Jul 2021 23:54:22 +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 sXvNzt_A0Nid; Tue, 13 Jul 2021 23:54:21 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 530726071C; Tue, 13 Jul 2021 23:54:21 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 14D33C001A; Tue, 13 Jul 2021 23:54:21 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id B5907C000E for ; Tue, 13 Jul 2021 23:54:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 8E83460724 for ; Tue, 13 Jul 2021 23:54:18 +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 p12GpJRpQy0x for ; Tue, 13 Jul 2021 23:54:16 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by smtp3.osuosl.org (Postfix) with ESMTPS id 88A146071C for ; Tue, 13 Jul 2021 23:54:16 +0000 (UTC) Received: by mail-qk1-x732.google.com with SMTP id s6so20681821qkc.8 for ; Tue, 13 Jul 2021 16:54:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=psNqCrBwCGRPV0GMx0UJi9q1GTstXYN3y24OgE9aFHA=; b=nAn1ZBctObW5/4rzcwbWcXacQkKZzr+xNKjOPvXZEJkFWoXKOXpGusecOIwp2Bkkg8 gQx0KPcNl3VanNIuObMwevvxTyfI3v5ASEzsLaWrlzElfTAv2KwigogKaIDDqyk38nTU 21v2QUakO9PeQqSV/k9mHvzbQmbPMvbgbHCedUgtf8szFThAeyNt6Q3ek3wTC6RZEUhl p37zswHknxz2+J7q4tV+WF/DUblIwzz73KSWFvdWA5MatZv4P5NRdAihrggZKv4IBWl5 mwqZuMZZS6cpQPBZL17XvkhZOGLnGW81B9ErVPSttvz6F20wjdSYJm+vC9ceHZQq20qv wjTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=psNqCrBwCGRPV0GMx0UJi9q1GTstXYN3y24OgE9aFHA=; b=WOysubyColVJmqVibsvG5C1Q2nKsjVNDWLAY55ZXr+tiNdK7x7A4VkNefgS6RXBfq0 RucU42yNMM4XnJ8OU/+g79e9KhSQQTKByVgWXyE5WEesJYKt99fp+Nyu88AAsR4TfMPz G2aFVa73oaZPmD7zb6hmA4og83QR02mTqpTtS5H0xRoSik4zd+v8/TeUnTWVipUixYT5 6glnIjqO3gJ5oM/2t4cdmF/qX5o5B76FEggmbNNNmXw2YM4lPGu7nLb97kBqguMoHOsp iymhj3aBRSrGn81t3a8D40cLHKTt8G15u19jYiDCuWQGRy+yySkkBOYvGL9h1SA9Yao4 RLWA== X-Gm-Message-State: AOAM530EPQnSla3jylNJ9o8ioXeja5bq2r3WM+e1jn1m6dmU/ITj58yc qN4PdJNp04Bpybc4hHne+CY= X-Google-Smtp-Source: ABdhPJy9aRtw6TRboqtQn9nRqg1AhyGHGFH4KJheCNecEuLTHHQvQx/DiTyi4lhZrGrHwKCG81Niug== X-Received: by 2002:a05:620a:709:: with SMTP id 9mr6857281qkc.493.1626220455313; Tue, 13 Jul 2021 16:54:15 -0700 (PDT) Received: from fedora ([130.44.160.152]) by smtp.gmail.com with ESMTPSA id l4sm206872qkd.77.2021.07.13.16.54.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 16:54:14 -0700 (PDT) Date: Tue, 13 Jul 2021 19:54:12 -0400 From: Konrad Rzeszutek Wilk To: Dominique Martinet Subject: Re: [PATCH] swiotlb: add overflow checks to swiotlb_bounce Message-ID: References: <20210707051254.2121603-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210707051254.2121603-1-dominique.martinet@atmark-techno.com> Cc: Konrad Rzeszutek Wilk , linux-kernel@vger.kernel.org, Bumyong Lee , iommu@lists.linux-foundation.org, Chanho Park , Robin Murphy , Christoph Hellwig 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 Wed, Jul 07, 2021 at 02:12:54PM +0900, Dominique Martinet wrote: > This is a follow-up on 5f89468e2f06 ("swiotlb: manipulate orig_addr > when tlb_addr has offset") which fixed unaligned dma mappings, > making sure the following overflows are caught: > > - offset of the start of the slot within the device bigger than > requested address' offset, in other words if the base address > given in swiotlb_tbl_map_single to create the mapping (orig_addr) > was after the requested address for the sync (tlb_offset) in the > same block: > > |------------------------------------------| block > <----------------------------> mapped part of the block > ^ > orig_addr > ^ > invalid tlb_addr for sync > > - if the resulting offset was bigger than the allocation size > this one could happen if the mapping was not until the end. e.g. > > |------------------------------------------| block > <---------------------> mapped part of the block > ^ ^ > orig_addr invalid tlb_addr > > Both should never happen so print a warning and bail out without trying > to adjust the sizes/offsets: the first one could try to sync from > orig_addr to whatever is left of the requested size, but the later > really has nothing to sync there... > > Signed-off-by: Dominique Martinet > Cc: Konrad Rzeszutek Wilk > Cc: Bumyong Lee > Cc: Chanho Park > Cc: Christoph Hellwig > --- > > Hi Konrad, > > here's the follow up for the swiotlb/caamjr regression I had promissed. Awesome! > It doesn't really change anything, and I confirmed I don't hit either of > the warnings on our board, but it's probably best to have as either > could really happen. :nods: I put it in the devel/for-linus-5.14 and linux-next. Thank you! _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu