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=-2.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 82102C433B4 for ; Tue, 18 May 2021 15:01:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 04ABC6100C for ; Tue, 18 May 2021 15:01:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04ABC6100C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3FE288E003B; Tue, 18 May 2021 11:01:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3AEEE8E002F; Tue, 18 May 2021 11:01:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2293E8E003B; Tue, 18 May 2021 11:01:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0070.hostedemail.com [216.40.44.70]) by kanga.kvack.org (Postfix) with ESMTP id E11A08E002F for ; Tue, 18 May 2021 11:01:06 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 69DA6181AF5EA for ; Tue, 18 May 2021 15:01:06 +0000 (UTC) X-FDA: 78154664532.03.0C8A239 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) by imf14.hostedemail.com (Postfix) with ESMTP id AE0FFC00F79F for ; Tue, 18 May 2021 15:01:02 +0000 (UTC) Received: by mail-qv1-f43.google.com with SMTP id eb9so5066561qvb.6 for ; Tue, 18 May 2021 08:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kE/TYN77XS7xS5hsC3gM6u7JF175laQK+WTnSTDxZKE=; b=SYzZ7gdw6M7DKu4lfJl64L8/O3oF1EP5Cz6ffVWZP/ToyPhYvn3P1V4ai3yN4NFPX0 SDupjVyVcOSI6qYyFZ0K8qCEu+vrGUu2xMFr0y9AfNruXD7mUybnfeOKuloS6mwh2WD0 /U33jloGVrn5Q/c42J4A0SUsPGI0zT68rEpefTpNIpVv3O6C5iWqJghe2eH5Kff5RADA /WMpHAalSTTm44LE0jz9Oz5eJaLLSxSSZ1LAcngAAv1X8UDJWHgaIOAXsx+1JCvxgKYr w7uPEOO9nenpvm+hcfrusf7SI3nZ/EI1bw9GTOTXfd2ROuv9pEu+4mAVLr/XDpJqEZVN GzVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kE/TYN77XS7xS5hsC3gM6u7JF175laQK+WTnSTDxZKE=; b=fzc7eKjfBwFZxkB3Qrz/8kby67e2MSxEb/gC0EI9j6XmeS/SOMKNqbbLuvoOV9t/7U KN2UkdAMovQoE9i8/rKhUtTN236VlQELIB29jzGp9mA01CktQx92NuF4buuNQC180zzF LOK+fsYNDnOUSeZ8Rm/AI8kNZoYzF7QW0BjYw9W/6FqJrf5nVRWf5epRaMbgrVvpMaDI kfAXs9Eu4es08PCgBZHH9hvCmmA9l0NEug/2zqj2xQb2LO8HUtb22rjwghUKVAkS7Caw IBmnbkJVfnxfTklWfWJ5tHRl0z17C+YAY0AovNO1fFhn23+FjFuOiUMTPxQe1gSU6d7V 97yA== X-Gm-Message-State: AOAM531Mo4iKO3LDemC+jCJkIbd0smDvAJgvc7pgxxvl1h8SBLCtlV7I 5M9VQjgCg0bKlP16d5Tuk3Q+q+taCggHcAC+eyY= X-Google-Smtp-Source: ABdhPJz2hQNarssvJBe1pan0qA1TFUCaePTPwAruUq5jstWfe6l7qkN+WVv7//kBN1b/uhwG8FK/5UmlrFj+MB5ni8M= X-Received: by 2002:a0c:e40e:: with SMTP id o14mr6041377qvl.30.1621350063191; Tue, 18 May 2021 08:01:03 -0700 (PDT) MIME-Version: 1.0 References: <20210326055505.1424432-1-hch@lst.de> <20210326055505.1424432-5-hch@lst.de> <87pmxqiry6.fsf@depni.sinp.msu.ru> <20210517123716.GD15150@lst.de> <87lf8dik15.fsf@depni.sinp.msu.ru> <20210517131137.GA19451@lst.de> <20210518132155.GB2617@lst.de> In-Reply-To: <20210518132155.GB2617@lst.de> From: Matthew Auld Date: Tue, 18 May 2021 16:00:36 +0100 Message-ID: Subject: Re: [Intel-gfx] [PATCH 4/4] i915: fix remap_io_sg to verify the pgprot To: Christoph Hellwig Cc: Serge Belyshev , Peter Zijlstra , Daniel Vetter , Intel Graphics Development , Chris Wilson , linux-mm@kvack.org, ML dri-devel , Andrew Morton , Joonas Lahtinen Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: AE0FFC00F79F Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=SYzZ7gdw; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of matthewwilliamauld@gmail.com designates 209.85.219.43 as permitted sender) smtp.mailfrom=matthewwilliamauld@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: e4o8wzaq9i6j78fx41kcqj5z1buwmmxg X-HE-Tag: 1621350062-193569 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 18 May 2021 at 14:21, Christoph Hellwig wrote: > > On Mon, May 17, 2021 at 06:06:44PM +0100, Matthew Auld wrote: > > > Looks like it is caused by the validation failure then. Which means the > > > existing code is doing something wrong in its choice of the page > > > protection bit. I really need help from the i915 maintainers here.. > > > > AFAIK there are two users of remap_io_sg, the first is our shmem > > objects(see i915_gem_shmem.c), and for these we support UC, WC, and WB > > mmap modes for userspace. The other user is device local-memory > > objects(VRAM), and for this one we have an actual io_mapping which is > > allocated as WC, and IIRC this should only be mapped as WC for the > > mmap mode, but normal userspace can't hit this path yet. > > The only caller in current mainline is vm_fault_cpu in i915_gem_mman.c. > Is that device local? The vm_fault_cpu covers both device local and shmem objects. > > > What do we need to do here? It sounds like shmem backed objects are > > allocated as WB for the pages underneath, but i915 allows mapping them > > as UC/WC which trips up this track_pfn thing? > > To me the warnings looks like system memory is mapped with the wrong > permissions, yes. If you want to map it as UC/WC the right set_memory_* > needs to be used on the kernel mapping as well to ensure that the > attributes don't conflict. AFAIK mmap_offset also supports multiple active mmap modes for a given object, so set_memory_* should still work here?