Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1005215ybn; Wed, 2 Oct 2019 09:25:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyk/NwgQJ6cDVuiAgfJ+7SzFyzazN1itzePe7eKyddGZwqYD0Xt+bM7SbRSCLMEO6UnwZe+ X-Received: by 2002:aa7:c759:: with SMTP id c25mr4696377eds.15.1570033538118; Wed, 02 Oct 2019 09:25:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570033538; cv=none; d=google.com; s=arc-20160816; b=E5EX46QnkTwSSDdY+wjBj7gB6099usoKpWuMkYVaN4nrtKCLtGSTwxMmB1QD0PcMFi mu6LOCX8iG3EEXgWS1BE0vrroTQYmYSTGMPr+KBIEJotzIskoYPMOYkxWl41+8KPw0fl x/UnMyWicV8ER7IPsTUkw7FSK0CCcGzp2fMm0Wner3dSQMldbnZwTot3Pvj7Iju78Y2l PEmHg5yw6+hKEWr7pesV54P+CR18Cxn12hSlCXT/ahrmZaGoDow+4lAUhknC0469C8ni AGlqPs5XIB+6ZHWDBls9o2BiJd9Q3Da45I9+8E84BUWzenWZ/4xcbz1j/mae+RHNj86k 9Uhg== 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=4kWTv8uy7Xjd8MG1RSKWzHzfl+KGU38aEw2sTY5T/zk=; b=i5aHKoN/yyYYNuf/aWx8/AtNc/XsXyPb46BuGgGOBihp1pYf5oDEeNh1hGpyX8Jxam yXvhgbw3yhcAWQKfPJnNRZoUxI+F8xYGIMJcgPNDyhPV6mQEGDzeOOtZTSRLya0Vz+eE sCtKBQBghb9VeODyI8lTmtVjUubd0Fs2qSLvDRHCzBBUXXZbjCY9tz8JGn7MKKZT3TcL 8qlzNjgfObH9Hg7S6/yYlWBUNsqAo5yYc/kPkNu5mJN2VSDgkGHdc4yyX/o21CKOXlok nIJdqO6I8Bzyhj8L7Wn76K5aA6H8609sO7dHXFg1sjNxTcCqSwlMGnHhlpqFgqZSvNMk bMbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=XFviAKnN; 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 z7si10927834ejr.99.2019.10.02.09.25.13; Wed, 02 Oct 2019 09:25:38 -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=XFviAKnN; 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 S1727800AbfJBQSW (ORCPT + 99 others); Wed, 2 Oct 2019 12:18:22 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:41038 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727587AbfJBQSV (ORCPT ); Wed, 2 Oct 2019 12:18:21 -0400 Received: by mail-lf1-f65.google.com with SMTP id r2so13155567lfn.8 for ; Wed, 02 Oct 2019 09:18:20 -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=4kWTv8uy7Xjd8MG1RSKWzHzfl+KGU38aEw2sTY5T/zk=; b=XFviAKnNPYVdwLybnDMJSofAk9B+tDsGC+Is6RsS+KbpKkP4nLHfXvDX03lMzL4wiE sHXStboZMp+wVdKPKWfhj9+FMBNn+Ea+pV3j+Kl4FLqBd8Gg03/WqA6pHECAtcfOdW7t KMk+23X85zEuL7tYhL9WszRK2HmlA+ZG+Hp2zCuSgPJrZrJgHWp1WymOR5M6nIYxHJn1 K3QO3MlhUE+ioB7F5SfWqqbymPvjgvx6PUOnGsHTVZtXqov8Lj5yRsMGcBhvg23hIJxc 0rcwqXf26uuaPWXUSHCoOPwcqrsv/sWUZFTlANrQOUbNreYEoRMfBAF6fJCmEKPziRt5 0/7Q== 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=4kWTv8uy7Xjd8MG1RSKWzHzfl+KGU38aEw2sTY5T/zk=; b=gEL4qnkQ0SzMM4POE+Aq6vWclVqx55X4+LxPoAF5TlTECgSMvrhcGRUEra4OdGbjS4 RvIHm75m+gYbGztOQa2e8KXmUm8ch/G3DxEYslsqmBAjJA5rqRIkeOJIUnTnAk6RIy8S IePgHnk9IgEjSKzMshlDO+/icwWsZRXIaFvHG3XItVmhpomPKAT0oUINmCKtfA2TZACk BqsBsUV7nvJkreVnRyq+sHWCD7EOJRkbjFG2iyUR+142+snsgXnuEuDeWIo8krgaYbVJ 3bgTH/3Zmzj2HclDJKy0/4Mg/NjB1FxaxXqiue/SobRB/tbxL+vO/8JhUG/mFbMTS2Up dblg== X-Gm-Message-State: APjAAAXQR8KPScNgjA3oC+ZTOuXbWIxqVBL9b2Swm68JZuAoHONyBbO6 Bp6wHKi0mpT3dJMJe+sk6QyVvab6gCNCr3mrEJE9wMWK X-Received: by 2002:ac2:5e9e:: with SMTP id b30mr2845606lfq.5.1570033099333; Wed, 02 Oct 2019 09:18:19 -0700 (PDT) MIME-Version: 1.0 References: <1569954770-11477-1-git-send-email-alan.mikhak@sifive.com> <20191002142731.GC17152@ziepe.ca> In-Reply-To: <20191002142731.GC17152@ziepe.ca> From: Alan Mikhak Date: Wed, 2 Oct 2019 09:18:08 -0700 Message-ID: Subject: Re: [PATCH] scatterlist: Comment on pages for sg_set_page() 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, thellstrom@vmware.com, galpress@amazon.com, 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 Wed, Oct 2, 2019 at 7:27 AM Jason Gunthorpe wrote: > > On Tue, Oct 01, 2019 at 11:32:50AM -0700, Alan Mikhak wrote: > > From: Alan Mikhak > > > > Update the description of sg_set_page() to communicate current > > requirements for the page pointer parameter. > > > > Signed-off-by: Alan Mikhak > > include/linux/scatterlist.h | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h > > index 6eec50fb36c8..6dda865893aa 100644 > > +++ b/include/linux/scatterlist.h > > @@ -112,6 +112,12 @@ static inline void sg_assign_page(struct scatterlist *sg, struct page *page) > > * of the page pointer. See sg_page() for looking up the page belonging > > * to an sg entry. > > * > > + * Scatterlist currently expects the page parameter to be a pointer to > > + * a page that is backed by a page struct. > > + * > > + * Page pointers derived from addresses obtained from ioremap() are > > + * currently not supported since they require use of iomem safe memcpy. > > + * > > **/ > > static inline void sg_set_page(struct scatterlist *sg, struct page *page, > > unsigned int len, unsigned int offset) > > It seems a bit weird to have a comment explaining that 'struct page > *page' must actually be a valid pointer. Of course it must. > > Computing a 'struct page *' to something that doesn't actually have a > struct page is simply a bug in whoever did that. > > Code should never be interchanging ioremap results with the struct > page* world. > > Jason Agreed. Should scatterlist API sg_set_page() check the page pointer to prevent such usage that could crash the system? Is it still reasonable to at least tell the programmer what is not allowed by adding a comment in the description? Alan