linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Randy Dunlap <rdunlap@infradead.org>,
	Mark Brown <broonie@kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: linux-next: Tree for Sep 18 (objtool)
Date: Mon, 23 Sep 2019 09:16:57 -0500	[thread overview]
Message-ID: <20190923141657.p6kpqro3q4p4umwi@treble> (raw)
In-Reply-To: <20190923133352.GI2332@hirez.programming.kicks-ass.net>

On Mon, Sep 23, 2019 at 03:33:52PM +0200, Peter Zijlstra wrote:
> On Mon, Sep 23, 2019 at 07:49:01AM -0500, Josh Poimboeuf wrote:
> > On Mon, Sep 23, 2019 at 11:20:24AM +0200, Peter Zijlstra wrote:
> > > On Wed, Sep 18, 2019 at 09:04:21PM -0700, Randy Dunlap wrote:
> > > > On 9/18/19 3:10 PM, Mark Brown wrote:
> > > > > Hi all,
> > > > > 
> > > > > Changes since 20190917:
> > > > > 
> > > > 
> > > > on x86_64:
> > > > 
> > > > drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: i915_gem_execbuffer2_ioctl()+0x2fb: call to gen8_canonical_addr() with UACCESS enabled
> > > 
> > > I'm thinking that comes from:
> > > 
> > > 				offset = gen8_canonical_addr(offset & ~UPDATE);
> > > 				if (unlikely(__put_user(offset, &urelocs[r-stack].presumed_offset))) {
> > > 
> > > however, per commit 6ae865615fc4 (and 2a418cf3f5f1) the compiler really
> > > should not be sticking gen8_canonical_addr() after __uaccess_begin().
> > > 
> > > /me puzzled...
> > 
> > I think you're looking at the wrong code.  It has user_access_begin/end
> > around it:
> > 
> > 		if (!user_access_begin(user_exec_list, count * sizeof(*user_exec_list)))
> > 			goto end;
> > 
> > 		for (i = 0; i < args->buffer_count; i++) {
> > 			if (!(exec2_list[i].offset & UPDATE))
> > 				continue;
> > 
> > 			exec2_list[i].offset =
> > 				gen8_canonical_addr(exec2_list[i].offset & PIN_OFFSET_MASK);
> > 			unsafe_put_user(exec2_list[i].offset,
> > 					&user_exec_list[i].offset,
> > 					end_user);
> > 		}
> > end_user:
> > 		user_access_end();
> > 
> 
> Oh, Duh... Yeah, so the alternative to your solution is to do 2 loops.
> Not sure which would be better.

I like your idea better, makes the fix more localized and shrinks the
uaccess window.  Something like so (not even compile tested):

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index b5f6937369ea..406af374f728 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -2847,6 +2847,11 @@ i915_gem_execbuffer2_ioctl(struct drm_device *dev, void *data,
 			u64_to_user_ptr(args->buffers_ptr);
 		unsigned int i;
 
+		for (i = 0; i < args->buffer_count; i++) {
+			exec2_list[i].offset =
+				gen8_canonical_addr(exec2_list[i].offset & PIN_OFFSET_MASK);
+		}
+
 		/* Copy the new buffer offsets back to the user's exec list. */
 		/*
 		 * Note: count * sizeof(*user_exec_list) does not overflow,
@@ -2862,8 +2867,6 @@ i915_gem_execbuffer2_ioctl(struct drm_device *dev, void *data,
 			if (!(exec2_list[i].offset & UPDATE))
 				continue;
 
-			exec2_list[i].offset =
-				gen8_canonical_addr(exec2_list[i].offset & PIN_OFFSET_MASK);
 			unsafe_put_user(exec2_list[i].offset,
 					&user_exec_list[i].offset,
 					end_user);

  reply	other threads:[~2019-09-23 14:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-18 22:10 linux-next: Tree for Sep 18 Mark Brown
2019-09-19  4:04 ` linux-next: Tree for Sep 18 (objtool) Randy Dunlap
2019-09-19 16:51   ` Josh Poimboeuf
2019-09-19 19:21     ` Randy Dunlap
2019-09-19 19:40       ` Josh Poimboeuf
2019-09-19 21:09         ` Randy Dunlap
2019-09-23  9:20   ` Peter Zijlstra
2019-09-23 12:49     ` Josh Poimboeuf
2019-09-23 13:33       ` Peter Zijlstra
2019-09-23 14:16         ` Josh Poimboeuf [this message]
2019-09-23 14:28           ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190923141657.p6kpqro3q4p4umwi@treble \
    --to=jpoimboe@redhat.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).