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; } }