Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp804251pxb; Tue, 3 Nov 2020 13:01:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxlADDV++TNQ3xtESKk1h0T+Au2xs0NSuKLXPctqy7DWWpPPk7VfvJI20gxbwbE7lLr/L4 X-Received: by 2002:aa7:cc14:: with SMTP id q20mr17433530edt.242.1604437280766; Tue, 03 Nov 2020 13:01:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604437280; cv=none; d=google.com; s=arc-20160816; b=oOC+osfYiSYC8mnmEalnXoIotmgxBz9AClbF5Ed3He3GK6QNxvOUhHd7ejnx3Rlav6 j+WkIUCXThQHeXBd1RD3KoBqjjAiljVlLlD/Itdh9Ppr1gKJsUZxCqF5AG2DDDx2nLCP l2NrfdKRfLNklD8sFKZhMj3PY0R4ONXBw4BD4YStS7By9hbLV8Py89pVFxgc67lBO98L tBK9y7rDCcAGmFPqrrisvTwPJ0EFGaRk9cYQRPCYQVy+Jm5b1aUsE/u7KZFy4SJ54Wbu X2fJZ2inxI9nUHmyfuAlXv2NItHFFSsD1PX273Ai3XKyqK7zAwr5Y0b7SKJVKnqIXiiT G6pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xke/JpkYuSY21MazZ57fgehU1yJblKyUGT9PskSxd2A=; b=MHg6lLYMz3t6EVGOn33zaPEE31BzU6CAh9tUoeWHAo1QzAI7n3Hy3fyZgslM/tfrLK L5FEntWa9uK6v09H/vsqh3idX3TPHUOUMj1NXNqHaAI4A7jJUk8ELmHe61pp/ku1IXFH oQce3XXr8P90MscSFDVO+uo2OqKVptzEuzW7zWJP8sBs41nq+VzlEromp8A+U3C1b8Hr Ac1e8xbHX149HG1FMaGbCh1D5VsRJm9AG2pE/y9klKLqPM990sFDLf/t2cMRbLoRE2G3 PNXjjqS8yQZhp4BQXKRhRqr/pr5BDDH44vCEEhKIY5Nwm4YEfNb6Ca9lgN+pqj3MhFO5 Amjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gymT07bB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o7si1681ejb.91.2020.11.03.13.00.57; Tue, 03 Nov 2020 13:01:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gymT07bB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733134AbgKCU7j (ORCPT + 99 others); Tue, 3 Nov 2020 15:59:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:34850 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733131AbgKCU7h (ORCPT ); Tue, 3 Nov 2020 15:59:37 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7698C22226; Tue, 3 Nov 2020 20:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437176; bh=VW88ndNLQDY3Jw6GS6rXn7R8A0D0yNip1vbmQ5W7x4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gymT07bBKNEG62ZpK0pk/YdQl0tmtHa2Ra9fm5xSAKVlh9ERRAVeB3lDALdZ2uso8 l2SdvahtN+YWIqjqTW8ubQf5uGpqa5eoQ4ui8CLEnrNXLiknVzMutYl0E4Ww8wyh/v 2+IpURxy0qvFLNScr7bn6W2ChdXOK+Ahlu89tuzc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Christian=20K=C3=B6nig?= , Madhav Chauhan , Alex Deucher Subject: [PATCH 5.4 179/214] drm/amdgpu: dont map BO in reserved region Date: Tue, 3 Nov 2020 21:37:07 +0100 Message-Id: <20201103203307.499486671@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Madhav Chauhan commit c4aa8dff6091cc9536aeb255e544b0b4ba29faf4 upstream. 2MB area is reserved at top inside VM. Suggested-by: Christian König Signed-off-by: Madhav Chauhan Reviewed-by: Christian König Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -561,6 +561,7 @@ int amdgpu_gem_va_ioctl(struct drm_devic struct ww_acquire_ctx ticket; struct list_head list, duplicates; uint64_t va_flags; + uint64_t vm_size; int r = 0; if (args->va_address < AMDGPU_VA_RESERVED_SIZE) { @@ -581,6 +582,15 @@ int amdgpu_gem_va_ioctl(struct drm_devic args->va_address &= AMDGPU_GMC_HOLE_MASK; + vm_size = adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE; + vm_size -= AMDGPU_VA_RESERVED_SIZE; + if (args->va_address + args->map_size > vm_size) { + dev_dbg(&dev->pdev->dev, + "va_address 0x%llx is in top reserved area 0x%llx\n", + args->va_address + args->map_size, vm_size); + return -EINVAL; + } + if ((args->flags & ~valid_flags) && (args->flags & ~prt_flags)) { dev_dbg(&dev->pdev->dev, "invalid flags combination 0x%08X\n", args->flags);