Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2662313yba; Mon, 6 May 2019 09:34:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyc4MDwddWIiIRg2o/PmbF/43Kax/dQjswb9KW9H3uAfWJQYFs1SdTDvojph3o5Q4+sgAqi X-Received: by 2002:a63:c14:: with SMTP id b20mr32752463pgl.163.1557160451301; Mon, 06 May 2019 09:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557160451; cv=none; d=google.com; s=arc-20160816; b=Bdwd6y6Afh7kVCqpQOeNF21N+TsHEOxTX14BeFGBhc51wzVoTk6O/1Tt+6jMgCoyHZ aVgIasXZLAmL+NsxAyOuoQpiTLV03mf2hCNzcx7FHGfT9F88+R+dNY2xotLy+NBS2n3q FsZTXG/o7DQPXQW81xRkATsLOOMU9NqnqLIaQbOuXtMqqTIpyTnv1gbK7pBR/xzIogl1 fW0lPgnCAp4pqYUXt9u0C7g+3NvK0w6ahPB2EGC/LgWsS/LK0guksQ6h8/RGT44BDBTl 9Se2hEXne/gUd1LCzNCmdaISXLAv/1dvWlRVz797h+qKU+V+u8AZCxKyWe4D6JrfINw3 iDbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=djVJuNgpi4hl4AvZn47gmwsvHOuvfT3jzvA6F10IO5w=; b=YbPK7mCWGm0PEsbhScq+PzZZBLjMLhBYz0DZ2YB64QsZ3BTyJ4Yaq0gZWMVGSTKBm1 i9Sbn6iHtqnQFJZ5zce28CVwTSw0GDcgbmmFnYM6Tboh92zFFUwbWwHBbaSnkDS5jkSB Kkfsf7yK/SxWsv8DRcMylrOvUZujZnSBKIBswNhWn00cZ58y3H13bCsLFd2Lsk6Vih26 CCUU8cVR1PUEj1GFQiGZZcE+J4vx/EAwPyxFAilRX0RNG794m4p3MGnaHX1hA25TGUeT WGmi+0BV2D6uosTDb7YREZ3gbiAYhG+pA0N5emckLzd5PA/uU+eeU98dghCLrK9HBkFr 6xYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fxyQnlZp; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a187si14969435pgc.385.2019.05.06.09.33.55; Mon, 06 May 2019 09:34:11 -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=@google.com header.s=20161025 header.b=fxyQnlZp; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727197AbfEFQbn (ORCPT + 99 others); Mon, 6 May 2019 12:31:43 -0400 Received: from mail-yw1-f73.google.com ([209.85.161.73]:45441 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727203AbfEFQbm (ORCPT ); Mon, 6 May 2019 12:31:42 -0400 Received: by mail-yw1-f73.google.com with SMTP id 11so26238161ywt.12 for ; Mon, 06 May 2019 09:31:41 -0700 (PDT) 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=djVJuNgpi4hl4AvZn47gmwsvHOuvfT3jzvA6F10IO5w=; b=fxyQnlZpVUSYjQyqKRvVjTFbSpnAaN40vHoDyTt86Wr9XkiWv6H47O5fV6+YfqSjKb ya9LAHunO5tkq38NxGwIBHRUa8t3xRmbLIMp/Ei/Ay4bKwx0V2sP2cpbt1VZJxkDe/I+ 9QcnUwoNsbvRkE6TQ1eqETcSj1FHDhcRF+86nS+29Dm7yx2+fQzWUL/UiXGimZGBqjEk x92RLHdIO29i4yL8cPFFrUa5OfqGP4F8w4+T2ndS2TLCjkCTICe9DBa54uexWvxllQFG iUS8CZcMLYnxYz/mG/GVZOcto/nPYEof7WD9aPSyYBI6CjVI7kE5mMY0QntuPkboh2oc AONw== 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=djVJuNgpi4hl4AvZn47gmwsvHOuvfT3jzvA6F10IO5w=; b=p5SGlPzkduN4sQgtIjmm0qR3bNM/LDWs606qW4gUGQsBp0RbRJBe+1DkEFERBiHfQT luW0mtVxnWeahFLDt19wS3BTo+fLkuUYDGMXKu5EUG4JYPmWDiQvTD6OOTLLvAoyRBfe HMAo4rydRNM/gqJ6X6Oe0+N+n9jcO+jdzoG0hQnJHIqfJME+3YNstnoYrJh1l+GmldA1 cl+L0tnGfTq5cLJuLgV4TcYWJeEgcwi8qIB34yQj+77hBuJ16g/kbhpMjj+v6+GmY1vd peI8Gs6ugC9gO4/iC4C0tm42qV4gkzi5WORirsdPpK0sHeDKm1FQayWVslWv47LsP5O2 edNg== X-Gm-Message-State: APjAAAXNwkpu3VuR9onVzkAEKVDgyYndkAQPb/ReB3AeCW32ca+q4gWs ZQU/NLRu4rTiKnoGwmd6KibG0XToL99r19Kw X-Received: by 2002:a0d:e60d:: with SMTP id p13mr8305580ywe.155.1557160301102; Mon, 06 May 2019 09:31:41 -0700 (PDT) Date: Mon, 6 May 2019 18:30:57 +0200 In-Reply-To: Message-Id: <84676a97cec129eb7a10559ceae2bec526160ad6.1557160186.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog Subject: [PATCH v15 11/17] drm/amdgpu, arm64: untag user pointers From: Andrey Konovalov To: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@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 Cc: Catalin Marinas , Vincenzo Frascino , Will Deacon , Mark Rutland , Andrew Morton , Greg Kroah-Hartman , Kees Cook , Yishai Hadas , Felix Kuehling , Alexander Deucher , Christian Koenig , Mauro Carvalho Chehab , Jens Wiklander , Alex Williamson , Leon Romanovsky , Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Robin Murphy , Luc Van Oostenryck , Dave Martin , Kevin Brodsky , Szabolcs Nagy , Andrey Konovalov , Kuehling@google.com 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 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. In amdgpu_gem_userptr_ioctl() and amdgpu_amdkfd_gpuvm.c/init_user_pages() an MMU notifier is set up with a (tagged) userspace pointer. The untagged address should be used so that MMU notifiers for the untagged address get correctly matched up with the right BO. This patch untag user pointers in amdgpu_gem_userptr_ioctl() for the GEM case and in amdgpu_amdkfd_gpuvm_ alloc_memory_of_gpu() for the KFD case. This also makes sure that an untagged pointer is passed to amdgpu_ttm_tt_get_user_pages(), which uses it for vma lookups. Suggested-by: Kuehling, Felix Signed-off-by: Andrey Konovalov --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 1921dec3df7a..20cac44ed449 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -1121,7 +1121,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( alloc_flags = 0; if (!offset || !*offset) return -EINVAL; - user_addr = *offset; + user_addr = untagged_addr(*offset); } else if (flags & ALLOC_MEM_FLAGS_DOORBELL) { domain = AMDGPU_GEM_DOMAIN_GTT; alloc_domain = AMDGPU_GEM_DOMAIN_CPU; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index d21dd2f369da..985cb82b2aa6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -286,6 +286,8 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data, uint32_t handle; int r; + args->addr = untagged_addr(args->addr); + if (offset_in_page(args->addr | args->size)) return -EINVAL; -- 2.21.0.1020.gf2820cf01a-goog