Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8627393ybn; Tue, 1 Oct 2019 10:47:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqyD7SuDaPT+XxgsRXhifk92vnvShCwXqRY6eHdtdQktXoNkdKiU00SgbWLBTDLBNnhpuWBy X-Received: by 2002:a05:6402:356:: with SMTP id r22mr26646340edw.254.1569952059918; Tue, 01 Oct 2019 10:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569952059; cv=none; d=google.com; s=arc-20160816; b=BgCBPi16e4UMbZ7TjsnD99k58veaQEMa5WS67tA05Lnx3C5y+G/FsVUvQaDcY76y0X Q0CfS+drYPRsA6bxya/s3JsMshXlyrQPJ8pSHJeB6Z9oPcgJGjaOZTYs8zkNtl/ZYeUM Hn5DJM2OZd5pVrYWqCqbXBv87NrzyyGXxcGeOpJf5muPum7yHRABL0tX28FgWNdrZM+5 5Lthqwn/4decqoWrQ7bcz9CeV4IavIDIYD647J2jsLArhZsNxS98yBJeOeNhXbBLqHc/ m6IwuNWVo9nH1xmNObc5tXuXTZcXJtJjdFcB3oopAGBRDYuEfllqel9KfEKlo9wff86G TkeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nFxvzQ868XnHaCbPvW/MGK7d5M5xYPEHW1JZKRblTE4=; b=CjGTiq5ciOf5830vR3H7ukHPMPuZD0lgybjCSO5FhdnlW7qntalhHlc7GFdqXaxj9M X5kba2Kui8stKNY4QWo086aEif0rPZ1KIfRQBQnx6dYMdPhxaoEYM21MXkmJ2+YTdifW px7pFYgdEkmBHDF3blEilwcinvLhuHhdWHP+HOJiYAejkRgpwsG5YC6UrphItIKwH26R +vZIW5ZJkUH56zIRSc68ul+xtkBahYeGtTBYU1K+UBNEoJPt0DLlojBekBGdPvtyUTEI IMJHKMi8k1KGKLVsrUyovRBIxZrWLevyq7uGH73Fiy909g52MYjYWuFgBzdrwX6RtBMV 43Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=fLi7Mwz4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v27si9365228ejb.182.2019.10.01.10.47.15; Tue, 01 Oct 2019 10:47:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=fLi7Mwz4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729689AbfJARqf (ORCPT + 99 others); Tue, 1 Oct 2019 13:46:35 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:44285 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726096AbfJARqf (ORCPT ); Tue, 1 Oct 2019 13:46:35 -0400 Received: by mail-lf1-f67.google.com with SMTP id q11so10562809lfc.11 for ; Tue, 01 Oct 2019 10:46:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nFxvzQ868XnHaCbPvW/MGK7d5M5xYPEHW1JZKRblTE4=; b=fLi7Mwz4uSSLCO81FntkOs5IGkwiPM3NHkCP+7Rl7Etd3mbuSZCy4JCTYBlwtPvJ7a yXOOWH+Jja9PT8cCaSsLl7V7nPe0jd7CcicTB5NMx+rHe+sEAhl7mjLJOx0li9+zl6zB eMRcw9s01k46/gg8JvAvP/XrqwDCSV+Mai83OFeIBI0N8FHznKkJrUqmewaf9bhCedd3 Vga1/puh1H8HbGHm0ov8SJVuGTnTDxdMTCKycKF7Sgj0EYQW18FVt+Cl4RBArnGTPMWB L+nQjjt7ThpRh27oerCtp6c9V+gEPZUkuvcV/h0n4zSuQBn6ghlQQ3plaGlsB4rUj4LD 3GZA== 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=nFxvzQ868XnHaCbPvW/MGK7d5M5xYPEHW1JZKRblTE4=; b=XwFqQ7HOrNBfRfTZsLnN+m65GvjEvwfF4j/xi9AMCsj0tBjmVR1NYphqAnR4UlrGU8 8/AnKXxMAYQSlQFUQFZTOqAGWMh0VQ2/89sQm8LCzB+sZjkgxsYEjwoyWcAmo0ySyx3+ UX9CypKuU0qYRZB03u8yQ6ez4nop64hrWzJM63IqnPYCT27st16jRfljk/kZeHlpihny qnVy6nfduN18EaxbYGR176PBiqt1tRpZYHVY5Y3GMZ7M1wqvZz8aQog40URz96t+LTba HZOohGJvy8uA6ugYVP/HetCKT24JsIqfYQISEzhp2mooY45fqPFh49SytVdbzBM3lk/S k3ow== X-Gm-Message-State: APjAAAUzCBBq6gLCjKgZE3PmhykCFPliEZBT8zJ6IoeTbfqYEoGC7tPa cOfG3bVv/l4Ky0g1o9a1+kbZH+0Htsq+Ba+hBl7Tsg== X-Received: by 2002:a19:8a0b:: with SMTP id m11mr15781955lfd.4.1569951991954; Tue, 01 Oct 2019 10:46:31 -0700 (PDT) MIME-Version: 1.0 References: <1569885755-10947-1-git-send-email-alan.mikhak@sifive.com> <20191001121623.GA22532@ziepe.ca> <20191001171220.GF22532@ziepe.ca> <20191001174358.GG22532@ziepe.ca> In-Reply-To: <20191001174358.GG22532@ziepe.ca> From: Alan Mikhak Date: Tue, 1 Oct 2019 10:46:21 -0700 Message-ID: Subject: Re: [PATCH] scatterlist: Validate page before calling PageSlab() To: Jason Gunthorpe Cc: linux-kernel@vger.kernel.org, martin.petersen@oracle.com, alexios.zavras@intel.com, ming.lei@redhat.com, gregkh@linuxfoundation.org, tglx@linutronix.de, christophe.leroy@c-s.fr, Palmer Dabbelt , Paul Walmsley Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 1, 2019 at 10:44 AM Jason Gunthorpe wrote: > > On Tue, Oct 01, 2019 at 10:26:38AM -0700, Alan Mikhak wrote: > > > > > Cost of adding page structs to a large PCI I/O address range can be > > > > quite substantial. Allowing PCI I/O pages without page structs may be > > > > desirable. Perhaps it is worth considering this cost. > > > > > > This is generally agreed, but nobody has figured out a solution. > > > > > > > Scatterlist has no problem doing its memcpy() from pages without a > > > > page struct that were obtained from ioremap(). It is only at > > > > > > Calling memcpy on pointers from ioremap is very much not allowed. Code > > > has to use the iomem safe memcpy. > > > > Is it in the realm of possible to add support for such PCI I/O pages > > to scatterlist? Perhaps some solution is possible by adding a new > > function, say sg_set_iomem_page(), and a new SG_MITER_IOMEM flag that > > tells scatterlist to use iomem safe memcpy functions when the page is > > not backed by page struct because it was obtained from ioremap(). This > > flag can also be used at sg_miter_stop() to not call PageSlab() or > > flush_kernel_dcache_page(). > > People have tried many different things so far, it is more comple than > just the copy functions as there is also sg_page to worry about. > > > If supporting PCI I/O pages is not possible, would it be possible to > > check for invalid page pointers in sg_set_page() and communicate the > > requirement for a page struct backing in its description? > > Clarifying the comments seems reasonable to me. > > Jason Thanks Jason. I'll submit a patch to communicate the requirement in the description of sg_set_page(). Alan