From patchwork Wed Mar 20 14:51:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10863097 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EBCE71575 for ; Thu, 21 Mar 2019 08:25:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D237529F21 for ; Thu, 21 Mar 2019 08:25:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5D0A29F81; Thu, 21 Mar 2019 08:25:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7820029F21 for ; Thu, 21 Mar 2019 08:25:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4E25B6E03E; Thu, 21 Mar 2019 08:24:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8EB8B89F6B for ; Wed, 20 Mar 2019 14:52:40 +0000 (UTC) Received: by mail-qt1-x849.google.com with SMTP id n10so2671326qtk.9 for ; Wed, 20 Mar 2019 07:52:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=wXdkYKKqhy/PeP38eGiAHfinlz29ywOf5m6iUAAWrE8=; b=kj989LkubpI+rIcnvz6tSF28z3XyeOzt8LGLY7BkFDHQQmdlOADQP9hCt/S/31T/wb RwXDKO3Kr1YMu/yKj5356wtSBNn8yUkuqIHPF1TqrzCNc1ZmmQrhVVhiinAvXI3+l4yF KbfXpVOtOyAq6F3oTz8+hkzTXvSAr1MXQJqR7q1dC7KktcvJdSF4bvoxnpHIHdDUieWD ocrlkV8KdifssuvCyro0zvIHyfKxfzO53/keNzLBXlMRGKRiWStu2Vwl4h02nUrEYc4C KzPqpNPghzExBP2rPCi1KlEJK9SLlqCftCgiac6gJgAzGk0IvGM7rAjT3lNWq6JBgO3d WZtA== X-Gm-Message-State: APjAAAV5qT5wLCfFlU+VsDW+U4XQbRw9go9b6ryenoWKM0TFLDxeucbf PCshd8lkEaYSzRQcyarTPazdQ6bSqrsQ3nLs X-Google-Smtp-Source: APXvYqy01Tx4GR4P4j18wQEAClBXiiOkZilRtlYP4igDQPOGQlXjkic5cCk6gARehYogarcGTwIZa5tD2bxwI8+V X-Received: by 2002:a37:a783:: with SMTP id q125mr10967339qke.56.1553093559661; Wed, 20 Mar 2019 07:52:39 -0700 (PDT) Date: Wed, 20 Mar 2019 15:51:31 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog Subject: [PATCH v13 17/20] media/v4l2-core, arm64: untag user pointers in videobuf_dma_contig_user_get From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , Vincenzo Frascino , Eric Dumazet , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo , Alex Deucher , " =?utf-8?q?Christian_K=C3=B6ni?= =?utf-8?q?g?= " , "David (ChunMing) Zhou" , Yishai Hadas , Mauro Carvalho Chehab , Jens Wiklander , Alex Williamson , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailman-Approved-At: Thu, 21 Mar 2019 08:23:39 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=wXdkYKKqhy/PeP38eGiAHfinlz29ywOf5m6iUAAWrE8=; b=vGvcqQl8zr5X3WM6Pnd+j7ESVWistQw68FAbZfGNeDxL4YYPJ+4OqqvXW7UJbff64S SyCyuCgR8FsxykYFHxZWggo7wmmKHcIn/zY2gfqkitnlkwmk5EXExr6QbsvFWToOM+WL QCPwgzhfuDbLfbS3Fig3TlGkfXqXtVQtp9TzZy8I9KwzBEdSIeS5Q5WHsyncfNZu/5vS Hr5mn91x0XP2yZ8L2TzmgWuRJtVdl+Dl6mGsDyEaHoP98pICbmRz6fkWzF4gQ2C8Nz5C XyxbkVWlsM3lV1CHfezqLixEZRPiaqZkNbdh+E/dJkMt88Sw8raDDkXlf+wmKYTUA72K gOgg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Brodsky , Chintan Pandya , Jacob Bramley , Ruben Ayrapetyan , Szabolcs Nagy , Andrey Konovalov , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Luc Van Oostenryck , Dave Martin , Evgeniy Stepanov Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch is a part of a series that extends arm64 kernel ABI to allow to pass tagged user pointers (with the top byte set to something else other than 0x00) as syscall arguments. videobuf_dma_contig_user_get() uses provided user pointers for vma lookups, which can only by done with untagged pointers. Untag the pointers in this function. Signed-off-by: Andrey Konovalov --- drivers/media/v4l2-core/videobuf-dma-contig.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf-dma-contig.c b/drivers/media/v4l2-core/videobuf-dma-contig.c index e1bf50df4c70..8a1ddd146b17 100644 --- a/drivers/media/v4l2-core/videobuf-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf-dma-contig.c @@ -160,6 +160,7 @@ static void videobuf_dma_contig_user_put(struct videobuf_dma_contig_memory *mem) static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, struct videobuf_buffer *vb) { + unsigned long untagged_baddr = untagged_addr(vb->baddr); struct mm_struct *mm = current->mm; struct vm_area_struct *vma; unsigned long prev_pfn, this_pfn; @@ -167,22 +168,22 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, unsigned int offset; int ret; - offset = vb->baddr & ~PAGE_MASK; + offset = untagged_baddr & ~PAGE_MASK; mem->size = PAGE_ALIGN(vb->size + offset); ret = -EINVAL; down_read(&mm->mmap_sem); - vma = find_vma(mm, vb->baddr); + vma = find_vma(mm, untagged_baddr); if (!vma) goto out_up; - if ((vb->baddr + mem->size) > vma->vm_end) + if ((untagged_baddr + mem->size) > vma->vm_end) goto out_up; pages_done = 0; prev_pfn = 0; /* kill warning */ - user_address = vb->baddr; + user_address = untagged_baddr; while (pages_done < (mem->size >> PAGE_SHIFT)) { ret = follow_pfn(vma, user_address, &this_pfn);