Received: by 2002:a05:6622:f08:0:0:0:0 with SMTP id l8csp4482058ivc; Tue, 3 Nov 2020 13:11:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwm9Uj+aJXRllBhL8dKofHsD+p5S+poMkDl50C90W0/gorPXvAgsl77L1viPXGmjODZ0Ol X-Received: by 2002:a17:906:7797:: with SMTP id s23mr21110529ejm.312.1604437881454; Tue, 03 Nov 2020 13:11:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604437881; cv=none; d=google.com; s=arc-20160816; b=EgKc3uz8KTPANWPjqnFvrpt0UjFtTpJ5eMroE+BNbFWHOAszOTKWlt80Q7BppCIECV EcoEqSC96l6XZri+v7xg2lxcFy6MgpVlETPZYJTuEeJ7Fc3EUWNx7kXHYE3GqC8b1S2c aI+yM/gAPl+HbARX5d/XlfOBaaS5lW5LZUb/RfpuhKDw4KW8/d71VMJ02bKhRMIkZRlp ZI9WBQkraydll/Z27UDrjNlCtnvXEHP5m+xXBajjqIBgu2XISGBbvfXVIZXCdzmZIllD Jn6Wmy4Qja/OXsCHCb+qYBAcjse+NvrODpFTuvfYOcCovbps65aHK4+6WgJ3nUaYoN1h knpw== 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=lv5olltlN2i2gomcqUw/l613SzEM74wWcwQqzfkZ9R0=; b=VpKLkz0ohHhAX7ZqGqA4KO7oAujXzCZKhgeVHWcDHabDzOemKhOnIrQ225A5lSEgfW cb2IvJzcDBwNAHas9TkGhTRezF4w1U4z4MTyK3hwyCgNgJqYeqiCufvcRcH0DoztNNgR T4DHMFTCeGr7j3JTPWiZpO8O0ZZB8k+jy1R3EXo7kYiH+nGjbvoHH8tP502p0eyLlF2t ZgXsGQVwrPuh1lkGiB74bA6lZMOhOCq2xEpNP73FPN+7Mcdnt6L37uzNYYW98ovHDhCe h/ouXpfM24vPEhRYsKE8gyO+OE3/oPWX31QPuBPO+W+Cyxo5aFkVKJjVUqtoAXhOXAQ2 +72A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="QO/Cf3qG"; 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 z11si16987ejf.614.2020.11.03.13.10.58; Tue, 03 Nov 2020 13:11:21 -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="QO/Cf3qG"; 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 S2388325AbgKCVHn (ORCPT + 99 others); Tue, 3 Nov 2020 16:07:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:46806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387713AbgKCVHe (ORCPT ); Tue, 3 Nov 2020 16:07:34 -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 C39D5205ED; Tue, 3 Nov 2020 21:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437653; bh=meQGU+Dc9opYhlt5EJnOOsM+a8QIzL5ih28tiIo6tRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QO/Cf3qGT4m2IEXplFGFxi0ESoBH/gJ8E1D76mF/CcAJ+mVmyJqi71gfLNwhXTM7s Mt7decz7Bz5WBJi8Gql5Jt7jao7k76EI+sGY/ZSM25Vr2qTkhMup2DBLq1+wJ+rx+Y 8ZL4VosCwKjqxhPU7eObZHsIeIbNWWdx+eEXtB5E= 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 4.19 166/191] drm/amdgpu: dont map BO in reserved region Date: Tue, 3 Nov 2020 21:37:38 +0100 Message-Id: <20201103203247.995012228@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@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 @@ -563,6 +563,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) { @@ -583,6 +584,15 @@ int amdgpu_gem_va_ioctl(struct drm_devic args->va_address &= AMDGPU_VA_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);