From patchwork Wed Dec 30 15:29:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iskren Chernev X-Patchwork-Id: 11993287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0159C433E6 for ; Wed, 30 Dec 2020 15:30:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D20B21D94 for ; Wed, 30 Dec 2020 15:30:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726524AbgL3Pap (ORCPT ); Wed, 30 Dec 2020 10:30:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726520AbgL3Pap (ORCPT ); Wed, 30 Dec 2020 10:30:45 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A61F2C061799; Wed, 30 Dec 2020 07:30:04 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id dk8so15758024edb.1; Wed, 30 Dec 2020 07:30:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=34sdCTMrNUObLPeLZuPMjVUhdN1zCiYujY6a/wW1ipc=; b=bt3oJcCNtOW3cWrm50FMG+rjfDl+IXCXWBtd5YDNz+/SbYjQYkue7+pUezRIOa0hTW HhcYTecp87p8ebxL7RLEOQ8bp9vtbe+L/TInVLvKKx7G77cG/ZHA4IP4wQB3pwnTsRj4 KDkEkNH8gwFXCJoqhLcTD1KhHYoRW9VJ9avTV/mg1B9d4lwacnrJly4NyIbhDV2i8Eoq 0oM+DR9ZHpVy1yRH+7rYrt5o47uSe8m3Rb4Snn0kY0fp5y+zUC6pDBWi0zL5PFtOFVe5 tJhoPsmlPYZkY+QchldNivTAAvAp7ODD+tiUG35Wtol/D4mr+3244lX8TeMHm+yMUG4L AJYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=34sdCTMrNUObLPeLZuPMjVUhdN1zCiYujY6a/wW1ipc=; b=A+3dzLbFQXTOebCU/aIPNlQn5K60TLptaHVwqL5lihhyMdAtLKkztdsPgOAb5hzNwD XgQWHXfXP/Gqi/qkiCn643z68LdeRdgG5on15Hf7ysyOF8+ex9d23mGyj31B8s+8znyy 3EnIsyhn0LheYV8fIlS6us6hUNjWmrntGk/ZMAbMOt4B99gMF6YkJtdxzUmUXW+AYD7W efRGz8oQ2GTioeKYgsY/O0XuAqO/tjGt/juUnnmDErvPhBgy74nbYEKCT7T4L2TsGmn8 2GzX/6A+TSCu8FWsbgVBg95xmeJk/Y/I8y7Wh8DQIhBF5S0LQzFmC9MekgsCirDVELip VAwA== X-Gm-Message-State: AOAM532VXKnCYS5it/6MzixKv99paHP42pW4O8zomEugteC1TCATUnr/ 4cr0oDBbxvYTN8s+wo6tp0g= X-Google-Smtp-Source: ABdhPJwK7Gav6N/d5gKjfxc10ZINhRcsguTBCZmmG/0yuTe6suMA2Y19hrEBCWuQP4axLFc51DDVCg== X-Received: by 2002:a50:c315:: with SMTP id a21mr51111550edb.50.1609342203425; Wed, 30 Dec 2020 07:30:03 -0800 (PST) Received: from localhost (178-169-161-196.razgrad.ddns.bulsat.com. [178.169.161.196]) by smtp.gmail.com with ESMTPSA id r7sm31630588edh.86.2020.12.30.07.30.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 30 Dec 2020 07:30:02 -0800 (PST) From: Iskren Chernev To: Rob Clark Cc: Akhil P Oommen , Bjorn Andersson , Brian Masney , Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Iskren Chernev , Jonathan Marek , Jordan Crouse , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Paul , Sharat Masetty , Shawn Guo , Wambui Karuga , ~postmarketos/upstreaming@lists.sr.ht, Craig Tatlor Subject: [PATCH 1/2] drm/msm: Call msm_init_vram before binding the gpu Date: Wed, 30 Dec 2020 17:29:42 +0200 Message-Id: <20201230152944.3635488-1-iskren.chernev@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Craig Tatlor vram.size is needed when binding a gpu without an iommu and is defined in msm_init_vram(), so run that before binding it. Signed-off-by: Craig Tatlor Reviewed-by: Brian Masney Tested-by: Alexey Minnekhanov --- drivers/gpu/drm/msm/msm_drv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) base-commit: d7a03a44a5e93f39ece70ec75d25c6088caa0fdb prerequisite-patch-id: aba6f684932cab35d98457c21e4ff7a5ac75c753 prerequisite-patch-id: 4884d57df1bd197896b69e115d9002d6c26ae2e2 diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 535a0263ceeb4..108c405e03dd9 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -457,14 +457,14 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv) drm_mode_config_init(ddev); - /* Bind all our sub-components: */ - ret = component_bind_all(dev, ddev); + ret = msm_init_vram(ddev); if (ret) goto err_destroy_mdss; - ret = msm_init_vram(ddev); + /* Bind all our sub-components: */ + ret = component_bind_all(dev, ddev); if (ret) - goto err_msm_uninit; + goto err_destroy_mdss; dma_set_max_seg_size(dev, UINT_MAX); From patchwork Wed Dec 30 15:29:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iskren Chernev X-Patchwork-Id: 11993289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2494C433DB for ; Wed, 30 Dec 2020 15:31:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81DF821D94 for ; Wed, 30 Dec 2020 15:31:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726203AbgL3PbO (ORCPT ); Wed, 30 Dec 2020 10:31:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726168AbgL3PbN (ORCPT ); Wed, 30 Dec 2020 10:31:13 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28298C06179B; Wed, 30 Dec 2020 07:30:33 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id dk8so15759422edb.1; Wed, 30 Dec 2020 07:30:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GpHHXsZUYQJKAsXY+fqmwPRImq5uvJodDxQThHKttC8=; b=uHIwWiQAgZJcuQerW7aZxpUYvAFOTwmZvcXoZiU49CUjjuA1rz+nOdAJEHkixngy/d DsQZPLJV7kupiV7lpp0NWXiS703qBfxVdzMtFIzpHyEcr6u+PVS4o8Fg0v89I9ylqmy0 GYL53UmVqN4xU3ZSbBLljt5TlDbhTuunuf7Czmz+s3yDW1p0XKcxRQM4ilaFq32NB2Qu NT1/sDY8saKYA0vLYexCb9SRLSKgXw3krKcevilTqBeDf7x2L0fUV3XaE/hFXBqOFcZA o1xR38gcWm29F7RUgOB8ozoWQzgae+yHxRe0HaHmA7vRDXgKo9sIJrr8kfyXlumRHzq5 A5lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GpHHXsZUYQJKAsXY+fqmwPRImq5uvJodDxQThHKttC8=; b=ts+0WL0Gr1RcD2yS73LpePtJ7m5DNbz+XWDy89TWQhlC5YbnKw6Tv9zIw44EMPtzc7 u+dD7Q6HXeoVaiDjNY6Ts6rWrSj0KjN2WYbIgAxxL0FvS6okk24FSyLmgubuMqat04k/ d+3dYi6aTO1VsIOxdpdPJ0sHOXhldu0VYcFndsgQYhmx1HkGmX1SmQltx8WLjGDjlUgs mpa2YoYkTrVBZfs5ELfPxMQrvIJwJc101CNx3TjUd32UpXo0VLxNE7NFSKzvqQ3o2rB8 ITW4YFLV/xIP/riivJyXfP5srJWIhwlJteb4R5UQ7uXlk9YLawodAAzkRdZuh9ZoWI55 MDEQ== X-Gm-Message-State: AOAM531yWgFxT1+dpr4kbRcmzqLyhChz1Mtwvo8pDZoKAHR8DfmYKaY6 EIzZOEPYXS5FALW2fdw7zbQ= X-Google-Smtp-Source: ABdhPJw23n3T+Ct/p+WPbtT9gStbrEMVVfK/XXEV42wVlsRLVTv/eR7cudEWmcjCEz6apzplIZfyMw== X-Received: by 2002:a50:b282:: with SMTP id p2mr52859676edd.210.1609342231950; Wed, 30 Dec 2020 07:30:31 -0800 (PST) Received: from localhost (178-169-161-196.razgrad.ddns.bulsat.com. [178.169.161.196]) by smtp.gmail.com with ESMTPSA id bo20sm38664655edb.1.2020.12.30.07.30.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 30 Dec 2020 07:30:31 -0800 (PST) From: Iskren Chernev To: Rob Clark Cc: Akhil P Oommen , Bjorn Andersson , Brian Masney , Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Iskren Chernev , Jonathan Marek , Jordan Crouse , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Paul , Sharat Masetty , Shawn Guo , Wambui Karuga , ~postmarketos/upstreaming@lists.sr.ht Subject: [PATCH 2/2] drm/msm: Add modparam to allow vram carveout Date: Wed, 30 Dec 2020 17:29:43 +0200 Message-Id: <20201230152944.3635488-2-iskren.chernev@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201230152944.3635488-1-iskren.chernev@gmail.com> References: <20201230152944.3635488-1-iskren.chernev@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Using the GPU with a VRAM Carveout is a security vulnerability. Nevertheless it is sometimes required, especially when no IOMMU implementation is available for a certain platform. Signed-off-by: Iskren Chernev --- drivers/gpu/drm/msm/adreno/a2xx_gpu.c | 6 ++++-- drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 6 ++++-- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 6 ++++-- drivers/gpu/drm/msm/adreno/adreno_device.c | 4 ++++ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 1 + 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c index 7e82c41a85f1a..bdc989183c648 100644 --- a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c @@ -534,8 +534,10 @@ struct msm_gpu *a2xx_gpu_init(struct drm_device *dev) if (!gpu->aspace) { dev_err(dev->dev, "No memory protection without MMU\n"); - ret = -ENXIO; - goto fail; + if (!allow_vram_carveout) { + ret = -ENXIO; + goto fail; + } } return gpu; diff --git a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c index 93da6683a8661..4534633fe7cdb 100644 --- a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c @@ -564,8 +564,10 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev) * implement a cmdstream validator. */ DRM_DEV_ERROR(dev->dev, "No memory protection without IOMMU\n"); - ret = -ENXIO; - goto fail; + if (!allow_vram_carveout) { + ret = -ENXIO; + goto fail; + } } icc_path = devm_of_icc_get(&pdev->dev, "gfx-mem"); diff --git a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c index c0be3a0f36b2c..82bebb40234de 100644 --- a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c @@ -692,8 +692,10 @@ struct msm_gpu *a4xx_gpu_init(struct drm_device *dev) * implement a cmdstream validator. */ DRM_DEV_ERROR(dev->dev, "No memory protection without IOMMU\n"); - ret = -ENXIO; - goto fail; + if (!allow_vram_carveout) { + ret = -ENXIO; + goto fail; + } } icc_path = devm_of_icc_get(&pdev->dev, "gfx-mem"); diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c index 87c8b033ad1a6..12e75ba360f95 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c @@ -18,6 +18,10 @@ bool snapshot_debugbus = false; MODULE_PARM_DESC(snapshot_debugbus, "Include debugbus sections in GPU devcoredump (if not fused off)"); module_param_named(snapshot_debugbus, snapshot_debugbus, bool, 0600); +bool allow_vram_carveout = false; +MODULE_PARM_DESC(allow_vram_carveout, "Allow using VRAM Carveout, in place of IOMMU"); +module_param_named(allow_vram_carveout, allow_vram_carveout, bool, 0600); + static const struct adreno_info gpulist[] = { { .rev = ADRENO_REV(2, 0, 0, 0), diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h b/drivers/gpu/drm/msm/adreno/adreno_gpu.h index c3775f79525a7..fe5444a1482ae 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h @@ -18,6 +18,7 @@ #include "adreno_pm4.xml.h" extern bool snapshot_debugbus; +extern bool allow_vram_carveout; enum { ADRENO_FW_PM4 = 0,