From patchwork Thu Nov 19 14:41:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11917869 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 A089BC63798 for ; Thu, 19 Nov 2020 15:02:49 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 0D92F246DE for ; Thu, 19 Nov 2020 15:02:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0B+22qPu"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="vjpM66Eh"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="ELbdBqB1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D92F246DE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cvC9Lc7tnD0mJtxfjRy9Xup5qSOrsbgtrNKybbYak/Y=; b=0B+22qPuM9dwf9TgCUa2so3hn kDWhRp0GlRw2OR8MBo03axo77ru+7N7sXv63PkS4BYlVKkxMG0gP9kT5eHmH3R7g0+Q8vE6g7fkam AZe8VSw7GayUCV8RV6/TFckfiqAo9KgQjywXOwN/HfGpfiNRWURwVw98emFku2c6LJ4PEXVo5bYM/ Z82ER+uEQ5KTfJuSu+TThDmkHxnuIWnbHUzOsjPkxAm6z+wo9ufRXXMTkRpMAqqXk6nJxYr6pyM79 ts8fwzuDtfTHyD66QalYGEUgJrl4mjQb08EfsDQOLTdJf3NLNCpjre1qqLrUzH5crsVKAOUzBPJ3w OgjUnFMHQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kflRr-0008TI-O8; Thu, 19 Nov 2020 15:02:11 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kflRa-0008K3-Fb for linux-arm-kernel@merlin.infradead.org; Thu, 19 Nov 2020 15:01:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=BPpebch13YhiVnp0IIh0dviRE5BWGvg35r91rkcoUQ8=; b=vjpM66EhPXHcq1lroVvnrwodn7 wO7uVDVsyN4YMXm7djbFiA1l95b2kxWa10JKbH+CcHLTznH3h9F31dOuOwoat15TI05a8J5E4I58Y 9ptILAmFq+NjHon1cKtZI783bKU/MwXdYmCOKg+q5mGKaHw7Ih7/QaxUXaLVyzxHPEKfTnCT3mCnr PDJAKC2gQE5LOCJDjTHjooIq6KZ8JzTXvkvn2AIgVVYILlaLoelpfelxa8UumyNfQHj4GZu6Y/ofM GxqNJwtnUrgfGsRuLkFFOYK305eh4MsCBPrqax4ivJUCTyjAggzVk5oVStkGF/CdFJXLkKU1A/mAk UEn2sTVw==; Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfl8U-0000Df-Nx for linux-arm-kernel@lists.infradead.org; Thu, 19 Nov 2020 14:42:14 +0000 Received: by mail-wm1-x341.google.com with SMTP id a186so4632012wme.1 for ; Thu, 19 Nov 2020 06:42:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BPpebch13YhiVnp0IIh0dviRE5BWGvg35r91rkcoUQ8=; b=ELbdBqB1EG22+DBZ236+jEYDLfaFG6cJxXjlIUTtjFkWJvA2aVBEoWS6IWrzxkmMsM CKByNISsBPBMATDUKMI7TEyj+1CLhDXRFwJA6/fSlSU1BhAJ2SWX+N/6DB9tHtFqLkw5 FshKvlR41ZRkC2VvtrUC1WkZ8BWFL13fuLpBM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BPpebch13YhiVnp0IIh0dviRE5BWGvg35r91rkcoUQ8=; b=ECM09eSJvOA/RE8L24dSiyezMlgzJXANus6ru+tEbn2PP7NsUKLs/uILc1GHI8mot9 4MZaZMsjtjYqt+0awMlz4ClePVcmp4lLKX3hSMyL6xpzpMLm9wsFzcR4ALHk5RKT3zcD vnJih0u3sRQEy9P7eEbUe1OMRumKyFpB7lSsLvqbi8vHIGKwViH3unVGgD6xALtfpjzm 6CqPWDlDqzAD16m3iqHn1/RtNmDF3Nfc1kgCk0l4LhqFly5FgTidN3Mqh07x3OQjPCFH 0oy0jzPb3gCTKlOjeP4exDjQvFB576zaq4lDSneFub0Enkan6qZBzAlxCkj620O3/5pR kwaA== X-Gm-Message-State: AOAM530RblvVIg7MpvUzDLxd5VhddEAy8Uxlf8nKM6iIzJcbqO/6JEYV 9wGZh5m6OcwUOTM2EnBpgTxGZw== X-Google-Smtp-Source: ABdhPJzMPF18M0N+DMnBEmqMSs9nBuEKzZXNbWRMjp078DW1AZEBSH3uKLChga62boFb4JqdftRhGA== X-Received: by 2002:a1c:1c3:: with SMTP id 186mr4901772wmb.39.1605796925671; Thu, 19 Nov 2020 06:42:05 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id x63sm51292wmb.48.2020.11.19.06.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 06:42:04 -0800 (PST) From: Daniel Vetter To: DRI Development , LKML Subject: [PATCH v6 09/17] media/videbuf1|2: Mark follow_pfn usage as unsafe Date: Thu, 19 Nov 2020 15:41:38 +0100 Message-Id: <20201119144146.1045202-10-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201119144146.1045202-1-daniel.vetter@ffwll.ch> References: <20201119144146.1045202-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201119_144211_264055_9FFA554B X-CRM114-Status: GOOD ( 20.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Kara , kvm@vger.kernel.org, Daniel Vetter , linux-mm@kvack.org, Daniel Vetter , Michel Lespinasse , Marek Szyprowski , linux-samsung-soc@vger.kernel.org, Daniel Jordan , Jason Gunthorpe , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, Kees Cook , Pawel Osciak , John Hubbard , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Dan Williams , Laurent Dufour , Vlastimil Babka , Tomasz Figa , Kyungmin Park , Andrew Morton Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The media model assumes that buffers are all preallocated, so that when a media pipeline is running we never miss a deadline because the buffers aren't allocated or available. This means we cannot fix the v4l follow_pfn usage through mmu_notifier, without breaking how this all works. The only real fix is to deprecate userptr support for VM_IO | VM_PFNMAP mappings and tell everyone to cut over to dma-buf memory sharing for zerocopy. userptr for normal memory will keep working as-is, this only affects the zerocopy userptr usage enabled in 50ac952d2263 ("[media] videobuf2-dma-sg: Support io userptr operations on io memory"). Acked-by: Tomasz Figa Signed-off-by: Daniel Vetter Cc: Jason Gunthorpe Cc: Kees Cook Cc: Dan Williams Cc: Andrew Morton Cc: John Hubbard Cc: Jérôme Glisse Cc: Jan Kara Cc: Dan Williams Cc: linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-samsung-soc@vger.kernel.org Cc: linux-media@vger.kernel.org Cc: Pawel Osciak Cc: Marek Szyprowski Cc: Kyungmin Park Cc: Tomasz Figa Cc: Laurent Dufour Cc: Vlastimil Babka Cc: Daniel Jordan Cc: Michel Lespinasse Signed-off-by: Daniel Vetter Acked-by: Hans Verkuil --- v3: - Reference the commit that enabled the zerocopy userptr use case to make it abundandtly clear that this patch only affects that, and not normal memory userptr. The old commit message already explained that normal memory userptr is unaffected, but I guess that was not clear enough. --- drivers/media/common/videobuf2/frame_vector.c | 2 +- drivers/media/v4l2-core/videobuf-dma-contig.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/common/videobuf2/frame_vector.c b/drivers/media/common/videobuf2/frame_vector.c index a0e65481a201..1a82ec13ea00 100644 --- a/drivers/media/common/videobuf2/frame_vector.c +++ b/drivers/media/common/videobuf2/frame_vector.c @@ -70,7 +70,7 @@ int get_vaddr_frames(unsigned long start, unsigned int nr_frames, break; while (ret < nr_frames && start + PAGE_SIZE <= vma->vm_end) { - err = follow_pfn(vma, start, &nums[ret]); + err = unsafe_follow_pfn(vma, start, &nums[ret]); if (err) { if (ret == 0) ret = err; diff --git a/drivers/media/v4l2-core/videobuf-dma-contig.c b/drivers/media/v4l2-core/videobuf-dma-contig.c index 52312ce2ba05..821c4a76ab96 100644 --- a/drivers/media/v4l2-core/videobuf-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf-dma-contig.c @@ -183,7 +183,7 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, user_address = untagged_baddr; while (pages_done < (mem->size >> PAGE_SHIFT)) { - ret = follow_pfn(vma, user_address, &this_pfn); + ret = unsafe_follow_pfn(vma, user_address, &this_pfn); if (ret) break;