From patchwork Tue May 21 08:24:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10953149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7048616C1 for ; Tue, 21 May 2019 08:24:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62AD7289B3 for ; Tue, 21 May 2019 08:24:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5710F289B2; Tue, 21 May 2019 08:24:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 11FB1289B0 for ; Tue, 21 May 2019 08:24:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 77D5C891C2; Tue, 21 May 2019 08:24:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-eopbgr780051.outbound.protection.outlook.com [40.107.78.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F487891C2 for ; Tue, 21 May 2019 08:24:22 +0000 (UTC) Received: from MN2PR05MB6141.namprd05.prod.outlook.com (20.178.241.217) by MN2PR05MB6383.namprd05.prod.outlook.com (20.178.245.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1922.13; Tue, 21 May 2019 08:24:20 +0000 Received: from MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::c19e:e8f8:b151:9ad]) by MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::c19e:e8f8:b151:9ad%6]) with mapi id 15.20.1922.013; Tue, 21 May 2019 08:24:20 +0000 From: Thomas Hellstrom To: "dri-devel@lists.freedesktop.org" Subject: [PATCH 1/6] drm/vmwgfx: Don't send drm sysfs hotplug events on initial master set Thread-Topic: [PATCH 1/6] drm/vmwgfx: Don't send drm sysfs hotplug events on initial master set Thread-Index: AQHVD66WB8FhPxysTkevBEDoHQXT2g== Date: Tue, 21 May 2019 08:24:20 +0000 Message-ID: <20190521082345.27286-1-thellstrom@vmware.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To MN2PR05MB6141.namprd05.prod.outlook.com (2603:10b6:208:c7::25) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [155.4.205.35] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3916b6a4-4501-461d-7e40-08d6ddc5b8b4 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:MN2PR05MB6383; x-ms-traffictypediagnostic: MN2PR05MB6383: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2512; x-forefront-prvs: 0044C17179 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(39860400002)(366004)(346002)(376002)(189003)(199004)(52116002)(3846002)(2501003)(71190400001)(71200400001)(6116002)(316002)(102836004)(99286004)(2906002)(6506007)(386003)(68736007)(256004)(14444005)(14454004)(66946007)(73956011)(66476007)(66556008)(64756008)(66446008)(478600001)(54906003)(305945005)(6512007)(36756003)(66066001)(26005)(7736002)(5640700003)(6436002)(81166006)(6916009)(1076003)(25786009)(186003)(8676002)(6486002)(4744005)(81156014)(86362001)(50226002)(8936002)(4326008)(2616005)(107886003)(5660300002)(486006)(53936002)(2351001)(476003); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR05MB6383; H:MN2PR05MB6141.namprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: mftSggKJbOGyidAMiUYrS4/UZ8y9IvSWcCLgonWSB1p44PcSdPMnKEVgAqJ8O2tPJzJTK5kUA9K+wjhTWc11dStNpy59hnRUCii5IYOFZVDPcTZIGPLOev30EyNnt1umQkP/qcitAKKJKF3NDdmGbOq+ZNJRjggfWZS4TUauFXme3U6vEYy5mhHqQ0EAAXp6bRA3eSpyDYKRz62WH8NxfmIe4qmSxOJz8c3lh26HK9fTMGweoalITqmCIq7gsEYqdlzhKp61Q76ty6e+ThhaC+6pX+TQ7YkYdfQZwyhXk7O27fF1OcFmzZH6Cc4x3S4wlz5pIsm8cVu/gwsyP68gTdBZIrM0Bhp8tCTyK9mFOP54E4/xGIMGB3RCzmfqPv7rCg28A0ual733m7BfmBUp6N0mahPpIlKkJhCx4KUqRFg= MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3916b6a4-4501-461d-7e40-08d6ddc5b8b4 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2019 08:24:20.1953 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: thellstrom@vmware.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR05MB6383 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qwKp7MBQrobFVMA6UrLVzIXuUlK7fyuxYdOSASmRVVE=; b=tONd3NOCPHX+JcFH8MPLKRDq0u899q8Mf+r41QMB8f4a1oVBulEGP90RdY/ijYLd+L1S1LR0c7/didObknsgFMX166BRT6PzmryRineWsk3ZhoT3FtgclJEwDCo8xBf4ZzPXm8btJDc7NYl4xL1vkp/dX8WkmUZMB6ZFwlvRzIk= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=thellstrom@vmware.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Hellstrom , Deepak Singh Rawat , "stable@vger.kernel.org" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This may confuse user-space clients like plymouth that opens a drm file descriptor as a result of a hotplug event and then generates a new event... Cc: Fixes: 5ea1734827bb ("drm/vmwgfx: Send a hotplug event at master_set") Signed-off-by: Thomas Hellstrom Reviewed-by: Deepak Rawat --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index bf6c3500d363..4ff11a0077e1 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -1239,7 +1239,13 @@ static int vmw_master_set(struct drm_device *dev, } dev_priv->active_master = vmaster; - drm_sysfs_hotplug_event(dev); + + /* + * Inform a new master that the layout may have changed while + * it was gone. + */ + if (!from_open) + drm_sysfs_hotplug_event(dev); return 0; } From patchwork Tue May 21 08:24:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10953151 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E4F40924 for ; Tue, 21 May 2019 08:24:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D492D289B0 for ; Tue, 21 May 2019 08:24:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8C63289B2; Tue, 21 May 2019 08:24:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 84256289B0 for ; Tue, 21 May 2019 08:24:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AEB728922A; Tue, 21 May 2019 08:24:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-dm3nam05on060c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe51::60c]) by gabe.freedesktop.org (Postfix) with ESMTPS id D2C7C8922A for ; Tue, 21 May 2019 08:24:38 +0000 (UTC) Received: from MN2PR05MB6141.namprd05.prod.outlook.com (20.178.241.217) by MN2PR05MB6384.namprd05.prod.outlook.com (20.178.246.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1922.12; Tue, 21 May 2019 08:24:36 +0000 Received: from MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::c19e:e8f8:b151:9ad]) by MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::c19e:e8f8:b151:9ad%6]) with mapi id 15.20.1922.013; Tue, 21 May 2019 08:24:36 +0000 From: Thomas Hellstrom To: "dri-devel@lists.freedesktop.org" Subject: [PATCH 2/6] drm/vmwgfx: Fix user space handle equal to zero Thread-Topic: [PATCH 2/6] drm/vmwgfx: Fix user space handle equal to zero Thread-Index: AQHVD66ftHwFBaQDdEyTGRRTD/XPiw== Date: Tue, 21 May 2019 08:24:35 +0000 Message-ID: <20190521082345.27286-2-thellstrom@vmware.com> References: <20190521082345.27286-1-thellstrom@vmware.com> In-Reply-To: <20190521082345.27286-1-thellstrom@vmware.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To MN2PR05MB6141.namprd05.prod.outlook.com (2603:10b6:208:c7::25) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [155.4.205.35] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e26a61c5-e307-4fa0-ea80-08d6ddc5c217 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:MN2PR05MB6384; x-ms-traffictypediagnostic: MN2PR05MB6384: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:451; x-forefront-prvs: 0044C17179 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(136003)(396003)(376002)(346002)(39860400002)(199004)(189003)(25786009)(6116002)(8676002)(305945005)(14454004)(5660300002)(3846002)(476003)(54906003)(11346002)(81156014)(26005)(486006)(81166006)(256004)(14444005)(68736007)(76176011)(71200400001)(8936002)(7736002)(6916009)(1076003)(478600001)(2616005)(446003)(71190400001)(66476007)(66556008)(64756008)(66446008)(73956011)(36756003)(6512007)(86362001)(66946007)(2906002)(66066001)(186003)(53936002)(52116002)(50226002)(316002)(4326008)(2501003)(102836004)(386003)(6506007)(99286004)(5640700003)(6436002)(2351001)(107886003)(6486002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR05MB6384; H:MN2PR05MB6141.namprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: X7LKVtQ9Gpxyr8XHc3GT7zR0OAMPSrUgvB7sgYiEdFdyGHSk5fbHrIABtGBya3axGT7UtUCKb3SSPLbTfPO5UXiY/8j/F8JsMRGm9TxvGGGi0ET+2PNA0eECgsc7wBD4v8D4fEUwv435PYDF4xCZtso5+AwEVV2UNtGb/S7kgThU0tToY8+/c+eHCcOa9JoduomYH5Cjn24X0hK/f/+BnEA2UGnkmkPPuGa2RlIOSnSPGdksNWE2q+G9dhmZ/l+LdRWn9IISFuF/7LrmYTOaX+SHeDlg1VP1YxeGyOoCPDBm/77HwkF3Co++RY3OhmILkYCvbuqQ3jmhJBhifPkYYUmzadJM7MZxQSESb2SaNkcWmoiJcSwZf/0bKpD/xX2CqTY+4mVeKoJJ0NKJF9DkaStPVw6J7ReV/bE9/+qpgWM= MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: e26a61c5-e307-4fa0-ea80-08d6ddc5c217 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2019 08:24:35.8144 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: thellstrom@vmware.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR05MB6384 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F0lBf2kzOrCa93YAZyWALHyZOdYDTzgC7hcgVZ2GMlQ=; b=sRzi0RAP6INqn9xQH5zF+lTT3hzHz3X++J1VwbKEucgtMvyIScCeX78rU2/rjHMtwi4YVhDynOAWxVNDQ1bVPnewmxUWlkHakWWMsQuVq0C8VXXyG9Z9T+xP+brV2ABw50XDwQ1c8i8ppfc56oIADYuX1NXc3ytJmIGZDMGItrU= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=thellstrom@vmware.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Hellstrom , Deepak Singh Rawat , "stable@vger.kernel.org" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP User-space handles equal to zero are interpreted as uninitialized or illegal by some drm systems (most notably kms). This means that a dumb buffer or surface with a zero user-space handle can never be used as a kms frame-buffer. Cc: Fixes: c7eae62666ad ("drm/vmwgfx: Make the object handles idr-generated") Signed-off-by: Thomas Hellstrom Reviewed-by: Deepak Rawat --- drivers/gpu/drm/vmwgfx/ttm_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/ttm_object.c b/drivers/gpu/drm/vmwgfx/ttm_object.c index 36990b80e790..16077785ad47 100644 --- a/drivers/gpu/drm/vmwgfx/ttm_object.c +++ b/drivers/gpu/drm/vmwgfx/ttm_object.c @@ -174,7 +174,7 @@ int ttm_base_object_init(struct ttm_object_file *tfile, kref_init(&base->refcount); idr_preload(GFP_KERNEL); spin_lock(&tdev->object_lock); - ret = idr_alloc(&tdev->idr, base, 0, 0, GFP_NOWAIT); + ret = idr_alloc(&tdev->idr, base, 1, 0, GFP_NOWAIT); spin_unlock(&tdev->object_lock); idr_preload_end(); if (ret < 0) From patchwork Tue May 21 08:24:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10953153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 32273924 for ; Tue, 21 May 2019 08:24:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21452289A7 for ; Tue, 21 May 2019 08:24:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15BE9289B2; Tue, 21 May 2019 08:24:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B8251289A7 for ; Tue, 21 May 2019 08:24:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 03D3189248; Tue, 21 May 2019 08:24:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730089.outbound.protection.outlook.com [40.107.73.89]) by gabe.freedesktop.org (Postfix) with ESMTPS id 41DE289248 for ; Tue, 21 May 2019 08:24:50 +0000 (UTC) Received: from MN2PR05MB6141.namprd05.prod.outlook.com (20.178.241.217) by MN2PR05MB6384.namprd05.prod.outlook.com (20.178.246.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1922.12; Tue, 21 May 2019 08:24:46 +0000 Received: from MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::c19e:e8f8:b151:9ad]) by MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::c19e:e8f8:b151:9ad%6]) with mapi id 15.20.1922.013; Tue, 21 May 2019 08:24:46 +0000 From: Thomas Hellstrom To: "dri-devel@lists.freedesktop.org" Subject: [PATCH 3/6] drm/vmwgfx: Fix compat mode shader operation Thread-Topic: [PATCH 3/6] drm/vmwgfx: Fix compat mode shader operation Thread-Index: AQHVD66lqs5OTMEjPUWqDBC8yJKr3Q== Date: Tue, 21 May 2019 08:24:45 +0000 Message-ID: <20190521082345.27286-3-thellstrom@vmware.com> References: <20190521082345.27286-1-thellstrom@vmware.com> In-Reply-To: <20190521082345.27286-1-thellstrom@vmware.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To MN2PR05MB6141.namprd05.prod.outlook.com (2603:10b6:208:c7::25) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [155.4.205.35] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b015e473-01eb-4be1-e0b7-08d6ddc5c812 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:MN2PR05MB6384; x-ms-traffictypediagnostic: MN2PR05MB6384: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:163; x-forefront-prvs: 0044C17179 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(136003)(396003)(376002)(346002)(39860400002)(199004)(189003)(25786009)(6116002)(8676002)(305945005)(14454004)(5660300002)(3846002)(476003)(54906003)(11346002)(81156014)(26005)(486006)(81166006)(256004)(68736007)(76176011)(71200400001)(8936002)(7736002)(6916009)(1076003)(478600001)(2616005)(446003)(71190400001)(66476007)(66556008)(64756008)(66446008)(73956011)(36756003)(6512007)(86362001)(66946007)(2906002)(66066001)(186003)(53936002)(52116002)(50226002)(316002)(4326008)(2501003)(102836004)(386003)(6506007)(99286004)(5640700003)(6436002)(2351001)(107886003)(6486002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR05MB6384; H:MN2PR05MB6141.namprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: AwFgDY/l6xSg99lF14vuSL1RpQRHEElxO668UGCBFsmVrEF7YTXBKElJbBT2nfLPN79zkcLv5ZsnvitcCo6EutGbUcCYa9I3ponGphEhFfTqJ40BIuoNF5vi6dryEec9svzbidvGcWvN/nRMAct/5GwkDjP0SQWqq4VBvLUNub/tBND3vm6F0e6cxh3dpKRsk+qzn09x+ctayoYPzVKhug3gJFIVFgyK0eeaoWDorGKBdyKSOdOKnDuyfe6IVUgSTF6Ixs7rtQfS86V2s8cDhoEJHUjih6rGPBCAXCyj5uc4PkPIVjoDomLEZKYzrdmx5OF7/IUbC5EcycD2U2ZKaBgbW4gXNWsaG6cAijLXFR56UwXxCH6bCOCjRpljRLtP7EpOy3yf7n5kB/hK2m2kI5PPZrzc/xWWUEqVjHnLkZ8= MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: b015e473-01eb-4be1-e0b7-08d6ddc5c812 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2019 08:24:45.8787 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: thellstrom@vmware.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR05MB6384 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hvmOXxnNgFe5e/MlRqO9VH2k2WmWXw7/Xp7LCA2YCcE=; b=vEFV0km9y44MQ6CgCpkvewFzQZ7jZvtO1ra4p2Bdc54OLhgA4267JcK43JyqH0bIKYF9Ddcqpk0Or+ilpzTG/Gikj+ykwa3Wbpkoa/+E+NXUt0FtT9Bm2tKGLkRf0I6QzTsdBZbSrwBWscEgJijyxHbp8iuvY6cKdjWQU2YnxvM= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=thellstrom@vmware.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Hellstrom , Brian Paul , "stable@vger.kernel.org" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP In compat mode, we allowed host-backed user-space with guest-backed kernel / device. In this mode, set shader commands was broken since no relocations were emitted. Fix this. Cc: Fixes: e8c66efbfe3a ("drm/vmwgfx: Make user resource lookups reference-free during validation") Signed-off-by: Thomas Hellstrom Reviewed-by: Brian Paul --- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index 2ff7ba04d8c8..315f9efce765 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c @@ -2010,6 +2010,11 @@ static int vmw_cmd_set_shader(struct vmw_private *dev_priv, return 0; if (cmd->body.shid != SVGA3D_INVALID_ID) { + /* + * This is the compat shader path - Per device guest-backed + * shaders, but user-space thinks it's per context host- + * backed shaders. + */ res = vmw_shader_lookup(vmw_context_res_man(ctx), cmd->body.shid, cmd->body.type); if (!IS_ERR(res)) { @@ -2017,6 +2022,14 @@ static int vmw_cmd_set_shader(struct vmw_private *dev_priv, VMW_RES_DIRTY_NONE); if (unlikely(ret != 0)) return ret; + + ret = vmw_resource_relocation_add + (sw_context, res, + vmw_ptr_diff(sw_context->buf_start, + &cmd->body.shid), + vmw_res_rel_normal); + if (unlikely(ret != 0)) + return ret; } } From patchwork Tue May 21 08:24:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10953155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB946924 for ; Tue, 21 May 2019 08:24:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC5EC289B1 for ; Tue, 21 May 2019 08:24:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0A94289B5; Tue, 21 May 2019 08:24:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5F778289B3 for ; Tue, 21 May 2019 08:24:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9E11689254; Tue, 21 May 2019 08:24:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-CO1-obe.outbound.protection.outlook.com (mail-eopbgr720041.outbound.protection.outlook.com [40.107.72.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 57A6C89254 for ; Tue, 21 May 2019 08:24:55 +0000 (UTC) Received: from MN2PR05MB6141.namprd05.prod.outlook.com (20.178.241.217) by MN2PR05MB6384.namprd05.prod.outlook.com (20.178.246.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1922.12; Tue, 21 May 2019 08:24:53 +0000 Received: from MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::c19e:e8f8:b151:9ad]) by MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::c19e:e8f8:b151:9ad%6]) with mapi id 15.20.1922.013; Tue, 21 May 2019 08:24:53 +0000 From: Thomas Hellstrom To: "dri-devel@lists.freedesktop.org" Subject: [PATCH 4/6] drm/vmwgfx: Use the dma scatter-gather iterator to get dma addresses Thread-Topic: [PATCH 4/6] drm/vmwgfx: Use the dma scatter-gather iterator to get dma addresses Thread-Index: AQHVD66qNal7EytNE0eNifRrrUqBPw== Date: Tue, 21 May 2019 08:24:53 +0000 Message-ID: <20190521082345.27286-4-thellstrom@vmware.com> References: <20190521082345.27286-1-thellstrom@vmware.com> In-Reply-To: <20190521082345.27286-1-thellstrom@vmware.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To MN2PR05MB6141.namprd05.prod.outlook.com (2603:10b6:208:c7::25) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [155.4.205.35] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: fdd66728-616b-4b97-d0f3-08d6ddc5ccaa x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:MN2PR05MB6384; x-ms-traffictypediagnostic: MN2PR05MB6384: x-ms-exchange-purlcount: 1 x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:626; x-forefront-prvs: 0044C17179 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(136003)(396003)(376002)(346002)(39860400002)(199004)(189003)(25786009)(6116002)(8676002)(305945005)(14454004)(5660300002)(3846002)(476003)(54906003)(11346002)(81156014)(26005)(486006)(81166006)(256004)(14444005)(68736007)(76176011)(71200400001)(8936002)(7736002)(6916009)(1076003)(478600001)(2616005)(446003)(71190400001)(966005)(66476007)(66556008)(64756008)(66446008)(73956011)(36756003)(6512007)(86362001)(6306002)(66946007)(2906002)(66066001)(186003)(53936002)(52116002)(50226002)(316002)(4326008)(2501003)(102836004)(386003)(6506007)(99286004)(5640700003)(6436002)(2351001)(6486002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR05MB6384; H:MN2PR05MB6141.namprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: eWeJAu9lzbEfx3GXFBRfjFaPTbZTye4X9SBzSfvB3nmtbwkbpqY5hwMVP78Eeo96u04eOrZLY5gb0FUoj6CPLpMoTuvaGYcEc7bU3D4H6eVD2WwQYwJ/1O09RvMmuGX082p6zXFGSHWjGskMRLGLf4xYgxEiwPXkiaUL3Qm75F4hQKMUcVrS0aohxgaJfHhugkVyu5KARFgYoBULfzix/jwY2NCLHLHHvR1UEeEtIkXBHcWkSbjSdkXgkeniUbnZ8OQbAgHqHAMuvtUko7CtoPOaULVfo27MlWsAqGkhCHDcQFwPJ5EZ96LRPJRXk1+LLdcxZvU++vH/8ecMn+GLBRbbOsO6pZ815uFXQ7hnEHi1uQ+Q6J3BvOj6kZIVIIsQDVRML4sr+qBuTw3qk228WgjkyZy8alcGVRPSlD21F6s= MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: fdd66728-616b-4b97-d0f3-08d6ddc5ccaa X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2019 08:24:53.5274 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: thellstrom@vmware.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR05MB6384 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UAJ06D/I1tJ/ruTVuxS/vHUc6uZG/+76HwmMu9uR+Xc=; b=xyFDzAOJwQTnPl68F8Xgw2NpAfDaDAR8Jdq+9eWyTCNWcnMruoKfx4ly2tC0Lib4BWvKV6tz45pevfOmgmh/dRF3X3Ug+uCWbc/s0kX/dNiZ4P6ip9a5p1L60v8r9FgqJJUcYR6kH/W9y6IAACgudxLYWFh+xZU2f1vY0Y7npko= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=thellstrom@vmware.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Hellstrom , Jason Gunthorpe Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use struct sg_dma_page_iter in favour struct of sg_page_iter, which fairly recently was declared useless for obtaining dma addresses. With a struct sg_dma_page_iter we can't call sg_page_iter_page() so when the page is needed, use the same page lookup mechanism as for the non-sg dma modes instead of calling sg_dma_page_iter. Note, the fixes tag doesn't really point to a commit introducing a failure / regression, but rather to a commit that implemented a simple workaround for this problem. Cc: Jason Gunthorpe Fixes: d901b2760dc6 ("lib/scatterlist: Provide a DMA page iterator") Signed-off-by: Thomas Hellstrom Reviewed-by: Jason Gunthorpe --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 27 ++++++---------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 96983c47fb40..366dcfc1f9bb 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h @@ -296,7 +296,7 @@ struct vmw_sg_table { struct vmw_piter { struct page **pages; const dma_addr_t *addrs; - struct sg_page_iter iter; + struct sg_dma_page_iter iter; unsigned long i; unsigned long num_pages; bool (*next)(struct vmw_piter *); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c index a3357ff7540d..a6ea75b58a83 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c @@ -266,7 +266,9 @@ static bool __vmw_piter_non_sg_next(struct vmw_piter *viter) static bool __vmw_piter_sg_next(struct vmw_piter *viter) { - return __sg_page_iter_next(&viter->iter); + bool ret = __vmw_piter_non_sg_next(viter); + + return __sg_page_iter_dma_next(&viter->iter) && ret; } @@ -284,12 +286,6 @@ static struct page *__vmw_piter_non_sg_page(struct vmw_piter *viter) return viter->pages[viter->i]; } -static struct page *__vmw_piter_sg_page(struct vmw_piter *viter) -{ - return sg_page_iter_page(&viter->iter); -} - - /** * Helper functions to return the DMA address of the current page. * @@ -311,13 +307,7 @@ static dma_addr_t __vmw_piter_dma_addr(struct vmw_piter *viter) static dma_addr_t __vmw_piter_sg_addr(struct vmw_piter *viter) { - /* - * FIXME: This driver wrongly mixes DMA and CPU SG list iteration and - * needs revision. See - * https://lore.kernel.org/lkml/20190104223531.GA1705@ziepe.ca/ - */ - return sg_page_iter_dma_address( - container_of(&viter->iter, struct sg_dma_page_iter, base)); + return sg_page_iter_dma_address(&viter->iter); } @@ -336,26 +326,23 @@ void vmw_piter_start(struct vmw_piter *viter, const struct vmw_sg_table *vsgt, { viter->i = p_offset - 1; viter->num_pages = vsgt->num_pages; + viter->page = &__vmw_piter_non_sg_page; + viter->pages = vsgt->pages; switch (vsgt->mode) { case vmw_dma_phys: viter->next = &__vmw_piter_non_sg_next; viter->dma_address = &__vmw_piter_phys_addr; - viter->page = &__vmw_piter_non_sg_page; - viter->pages = vsgt->pages; break; case vmw_dma_alloc_coherent: viter->next = &__vmw_piter_non_sg_next; viter->dma_address = &__vmw_piter_dma_addr; - viter->page = &__vmw_piter_non_sg_page; viter->addrs = vsgt->addrs; - viter->pages = vsgt->pages; break; case vmw_dma_map_populate: case vmw_dma_map_bind: viter->next = &__vmw_piter_sg_next; viter->dma_address = &__vmw_piter_sg_addr; - viter->page = &__vmw_piter_sg_page; - __sg_page_iter_start(&viter->iter, vsgt->sgt->sgl, + __sg_page_iter_start(&viter->iter.base, vsgt->sgt->sgl, vsgt->sgt->orig_nents, p_offset); break; default: From patchwork Tue May 21 08:25:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10953157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BA33924 for ; Tue, 21 May 2019 08:25:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F027B2880B for ; Tue, 21 May 2019 08:25:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E447A28879; Tue, 21 May 2019 08:25:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 99F822880B for ; Tue, 21 May 2019 08:25:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B2968925F; Tue, 21 May 2019 08:25:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730063.outbound.protection.outlook.com [40.107.73.63]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7FC168925F for ; Tue, 21 May 2019 08:25:03 +0000 (UTC) Received: from MN2PR05MB6141.namprd05.prod.outlook.com (20.178.241.217) by MN2PR05MB6384.namprd05.prod.outlook.com (20.178.246.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1922.12; Tue, 21 May 2019 08:25:01 +0000 Received: from MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::c19e:e8f8:b151:9ad]) by MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::c19e:e8f8:b151:9ad%6]) with mapi id 15.20.1922.013; Tue, 21 May 2019 08:25:01 +0000 From: Thomas Hellstrom To: "dri-devel@lists.freedesktop.org" Subject: [PATCH 5/6] drm/vmwgfx: NULL pointer dereference from vmw_cmd_dx_view_define() Thread-Topic: [PATCH 5/6] drm/vmwgfx: NULL pointer dereference from vmw_cmd_dx_view_define() Thread-Index: AQHVD66vMx659dgbLkCRMkI5Y/UGAg== Date: Tue, 21 May 2019 08:25:01 +0000 Message-ID: <20190521082345.27286-5-thellstrom@vmware.com> References: <20190521082345.27286-1-thellstrom@vmware.com> In-Reply-To: <20190521082345.27286-1-thellstrom@vmware.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To MN2PR05MB6141.namprd05.prod.outlook.com (2603:10b6:208:c7::25) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [155.4.205.35] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8e580b37-bb83-4a6b-bd4b-08d6ddc5d13b x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:MN2PR05MB6384; x-ms-traffictypediagnostic: MN2PR05MB6384: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:765; x-forefront-prvs: 0044C17179 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(366004)(136003)(396003)(376002)(346002)(39860400002)(199004)(189003)(25786009)(6116002)(8676002)(305945005)(14454004)(5660300002)(3846002)(476003)(54906003)(11346002)(81156014)(26005)(486006)(81166006)(256004)(68736007)(76176011)(71200400001)(8936002)(7736002)(6916009)(1076003)(478600001)(2616005)(446003)(71190400001)(66476007)(66556008)(64756008)(66446008)(73956011)(36756003)(6512007)(86362001)(66946007)(2906002)(66066001)(186003)(53936002)(52116002)(50226002)(316002)(4326008)(2501003)(102836004)(386003)(6506007)(99286004)(5640700003)(6436002)(2351001)(107886003)(6486002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR05MB6384; H:MN2PR05MB6141.namprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: LY+BeyGKqj8Ay1+6S1TERchrjOpD0uNDKl7EA2GWXqT4vjSRtg0dQ09rAyV+jpbIR55CBTiSOFcvN9JzcVNImxyO9+TJSmMKjLF3ToXYGV0SS4M6Flt4qUPfVfBuwJo0A0lXf7AAvtnozvEnIC87jwA8oSBVhqgVfn7MOA34jIjeu5//g7ZV6uFnZ4fuRwFIb0jRJLvPpvIs3TpkLSkzV4fjnwdTgFKX369KOVE1dadQY7yAtdb9yi7ZEVKcdPJEJ7sEYakOz3lb8PVY2i7XXGguGiLSySVGRCRmn2PnnBQc5Xm4oTIkSyo/IvSBOPNzkd7mlea5RKP068Oy/M45kmnP+kEIheFsy3PiyGzw8/up9jW3Aa+iM8+R/6nndCja7vow249L7BJy3udIgaEciJqm72xaUyAgQnKGTQ5sMts= MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e580b37-bb83-4a6b-bd4b-08d6ddc5d13b X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2019 08:25:01.3250 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: thellstrom@vmware.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR05MB6384 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GABHx8R42T9goBZkKnieCdLu7mt10L9I2fFPKfU7Y7Y=; b=gZBr978a03Has6HpYQXV5cKhPq4C1fA/WhSqo5EGzkWoQwcI2SveONACofqpyvG4CZqgyfe7TE9B1RbgLSHu0fosozCQF1U0+MXc5wsOkDManegd0ed4bPUNSot9E01OPVFBOvcNDr8pxmDw8JzOOKNx+9mmKc5SYSAmnhtHxR4= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=thellstrom@vmware.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Murray McAllister , Thomas Hellstrom , "stable@vger.kernel.org" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Murray McAllister If SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEW is called with a surface ID of SVGA3D_INVALID_ID, the srf struct will remain NULL after vmw_cmd_res_check(), leading to a null pointer dereference in vmw_view_add(). Cc: Fixes: d80efd5cb3de ("drm/vmwgfx: Initial DX support") Signed-off-by: Murray McAllister Reviewed-by: Thomas Hellstrom Signed-off-by: Thomas Hellstrom --- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index 315f9efce765..b4c7553d2814 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c @@ -2427,6 +2427,10 @@ static int vmw_cmd_dx_view_define(struct vmw_private *dev_priv, return -EINVAL; cmd = container_of(header, typeof(*cmd), header); + if (unlikely(cmd->sid == SVGA3D_INVALID_ID)) { + VMW_DEBUG_USER("Invalid surface id.\n"); + return -EINVAL; + } ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, VMW_RES_DIRTY_NONE, user_surface_converter, &cmd->sid, &srf); From patchwork Tue May 21 08:25:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10953159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4476B924 for ; Tue, 21 May 2019 08:25:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35BE3205A4 for ; Tue, 21 May 2019 08:25:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 29EB62880B; Tue, 21 May 2019 08:25:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D797828841 for ; Tue, 21 May 2019 08:25:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DBB3F891C2; Tue, 21 May 2019 08:25:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-dm3nam05on0628.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe51::628]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5B92B891C2 for ; Tue, 21 May 2019 08:25:07 +0000 (UTC) Received: from MN2PR05MB6141.namprd05.prod.outlook.com (20.178.241.217) by MN2PR05MB6384.namprd05.prod.outlook.com (20.178.246.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1922.12; Tue, 21 May 2019 08:25:05 +0000 Received: from MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::c19e:e8f8:b151:9ad]) by MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::c19e:e8f8:b151:9ad%6]) with mapi id 15.20.1922.013; Tue, 21 May 2019 08:25:05 +0000 From: Thomas Hellstrom To: "dri-devel@lists.freedesktop.org" Subject: [PATCH 6/6] drm/vmwgfx: integer underflow in vmw_cmd_dx_set_shader() leading to an invalid read Thread-Topic: [PATCH 6/6] drm/vmwgfx: integer underflow in vmw_cmd_dx_set_shader() leading to an invalid read Thread-Index: AQHVD66xyjyjvStMIUOjtPqDr9K8bw== Date: Tue, 21 May 2019 08:25:05 +0000 Message-ID: <20190521082345.27286-6-thellstrom@vmware.com> References: <20190521082345.27286-1-thellstrom@vmware.com> In-Reply-To: <20190521082345.27286-1-thellstrom@vmware.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To MN2PR05MB6141.namprd05.prod.outlook.com (2603:10b6:208:c7::25) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [155.4.205.35] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2a34fde9-80ea-481a-5841-08d6ddc5d385 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:MN2PR05MB6384; x-ms-traffictypediagnostic: MN2PR05MB6384: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3044; x-forefront-prvs: 0044C17179 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(136003)(396003)(376002)(346002)(39860400002)(199004)(189003)(25786009)(6116002)(8676002)(305945005)(14454004)(5660300002)(3846002)(476003)(54906003)(11346002)(81156014)(26005)(486006)(81166006)(256004)(14444005)(68736007)(76176011)(71200400001)(8936002)(7736002)(6916009)(1076003)(478600001)(2616005)(446003)(71190400001)(66476007)(66556008)(64756008)(66446008)(73956011)(36756003)(6512007)(86362001)(66946007)(2906002)(66066001)(186003)(53936002)(52116002)(50226002)(316002)(4326008)(2501003)(102836004)(386003)(6506007)(99286004)(5640700003)(6436002)(2351001)(107886003)(6486002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR05MB6384; H:MN2PR05MB6141.namprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: sOyVqlotRN14VebJm8ZawPg/YnOKe6MKBRfNcHUnUvh4Ja/tdA70A2wuhlaKu4IwkCR8gg+UBt2cLyhFv+b9ArSkZXlg9YqTzaaZy6qcNpsRRtaaq7iBFpk2TiAWiDgL8yyGCp6qmaouPOLrCtFZIg/upONlHeZ2bvtj7BwunPAzkDwcENBC2B/27iavHzDJ++ysBseknR0arCp2TypngRQb2JFwmN/CX1gY9drxUgIgH8SC7GrC8BpXMLjrSBbS8WuNj9dJ7SGEnDo+zwkDCymlgIg6veWpkoaSISe114PS710+caEcJBARmTcHay3L+aAwsmKNUrkV2pPZgqQpziCvUPrO5VC8opbyTyCHI3WN71WNyhS4+V2TNPs53RD4upuDGcgYqnl/GdOM9CldzcyxXScGXHHJsK13zxt5tbU= MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a34fde9-80ea-481a-5841-08d6ddc5d385 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2019 08:25:05.0578 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: thellstrom@vmware.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR05MB6384 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yU/e3nnsYZKhs5ZFwWRintMu6fsB820PHLUcXUtlbPs=; b=b+ny0b+oTz1aWnMh0lnazd8wZilY7K+rSrk3r2+MWSgg0F/mLIpCTEfJ8D42iFf0UhpOrcwUcNmSdbWVXIjm03uxxIhy4ArfZ9DKXqm2sN6Prsh//LlAbOiECltlkd8/rezlzuVZW7JAHkGguaf0MlPRcC7TuLHotNLzuYKV7RQ= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=thellstrom@vmware.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Murray McAllister , Thomas Hellstrom , "stable@vger.kernel.org" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Murray McAllister If SVGA_3D_CMD_DX_SET_SHADER is called with a shader ID of SVGA3D_INVALID_ID, and a shader type of SVGA3D_SHADERTYPE_INVALID, the calculated binding.shader_slot will be 4294967295, leading to an out-of-bounds read in vmw_binding_loc() when the offset is calculated. Cc: Fixes: d80efd5cb3de ("drm/vmwgfx: Initial DX support") Signed-off-by: Murray McAllister Reviewed-by: Thomas Hellstrom Signed-off-by: Thomas Hellstrom --- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index b4c7553d2814..33533d126277 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c @@ -2206,7 +2206,8 @@ static int vmw_cmd_dx_set_shader(struct vmw_private *dev_priv, cmd = container_of(header, typeof(*cmd), header); - if (cmd->body.type >= SVGA3D_SHADERTYPE_DX10_MAX) { + if (cmd->body.type >= SVGA3D_SHADERTYPE_DX10_MAX || + cmd->body.type < SVGA3D_SHADERTYPE_MIN) { VMW_DEBUG_USER("Illegal shader type %u.\n", (unsigned int) cmd->body.type); return -EINVAL;