From patchwork Fri Jul 19 22:02:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 11050659 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 8CC7513BD for ; Fri, 19 Jul 2019 22:02:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E96828560 for ; Fri, 19 Jul 2019 22:02:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73418289CB; Fri, 19 Jul 2019 22:02:12 +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=-3.7 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_WEB 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 EA3C1289C9 for ; Fri, 19 Jul 2019 22:02:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 738596E86B; Fri, 19 Jul 2019 22:02:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-eopbgr740045.outbound.protection.outlook.com [40.107.74.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 56CB56E86B; Fri, 19 Jul 2019 22:02:06 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QJ4oUdsZIi+RvYiyP0E7gZsMGgf8ZSsMqPZ0vi1ado0LzUOHc/1ILz3i3GDJTQekZ9rev42kr7VDtaVRV2k0I7Ta0zSus7N6fc8F0eNyeROQGjtelc90Phh8WNz+hIlmtmFS2eecX/0skxeqAH+oPeE8mWav+CKCtPf0LNjsD28wLEzm1VEl+VZYTubzOGqAoHUcWIdPlLBXa+keGjYUo+KUgM0spGj+Rq2CY4522iAYySVMFl2IftFGBuNEaTgijT1nBknX2nnkmbqvwOdCim+IcMorvh85nHMzXcwMqb4dmQ4m407DNdz06FCmBjmouOfFPVoDhP48La6joGl4Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=83MMwuE9+92blTxMIYf/+fn9NS9u89ZzE/gsK11hPmI=; b=BsdNjO0QuaClNZ9HHcuOi4bmvbfMbxrzaBmG9NGfd2/bcAQXvAEbQdNFozChfy9xuwP6ZvhdPHS0cqLjuxY0YdxXzjTrNZ/V8ikpphcFIj/jNmivAJ2iA7G+wN7euZVLIr2d/r8PLLSjekso9s12gQKyp/Tgi02pVy0hv5q0ri/SBhwuCiTuq30ROXgAjb7Q4eD6uLkHNbNTUpxq1pWlvKuXtGZucKLbs4OdZH15ghOZRLnWci+IKNE1awL7x4xywIqyqoiuYJRfH+/43pKujHfutNW6HM2piKcfNgwqyUjAJyf9qM5HcIDM+3K7I6MElMXZ4iW2UbmJ9gwS9MgDLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=amd.com;dmarc=pass action=none header.from=amd.com;dkim=pass header.d=amd.com;arc=none Received: from DM6PR12MB3947.namprd12.prod.outlook.com (10.255.174.156) by DM6PR12MB3915.namprd12.prod.outlook.com (10.255.174.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2094.15; Fri, 19 Jul 2019 22:02:04 +0000 Received: from DM6PR12MB3947.namprd12.prod.outlook.com ([fe80::91a2:f9e7:8c86:f927]) by DM6PR12MB3947.namprd12.prod.outlook.com ([fe80::91a2:f9e7:8c86:f927%7]) with mapi id 15.20.2073.012; Fri, 19 Jul 2019 22:02:04 +0000 From: "Kuehling, Felix" To: "amd-gfx@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" Subject: [PATCH 1/4] drm/amdgpu: Add flag to wipe VRAM on release Thread-Topic: [PATCH 1/4] drm/amdgpu: Add flag to wipe VRAM on release Thread-Index: AQHVPn2ZtZE9HUndj0OxbiHrj2Wtag== Date: Fri, 19 Jul 2019 22:02:04 +0000 Message-ID: <20190719220140.18968-1-Felix.Kuehling@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [165.204.55.251] x-mailer: git-send-email 2.17.1 x-clientproxiedby: YTXPR0101CA0061.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::38) To DM6PR12MB3947.namprd12.prod.outlook.com (2603:10b6:5:1cb::28) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cf208565-9304-494f-8d99-08d70c94bbab x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM6PR12MB3915; x-ms-traffictypediagnostic: DM6PR12MB3915: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 01039C93E4 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(136003)(396003)(346002)(376002)(366004)(189003)(199004)(66446008)(66556008)(66476007)(66946007)(5660300002)(66066001)(64756008)(478600001)(53936002)(25786009)(7736002)(305945005)(256004)(6436002)(486006)(86362001)(6486002)(52116002)(450100002)(476003)(50226002)(68736007)(186003)(8676002)(2616005)(1076003)(14454004)(6506007)(4744005)(102836004)(2906002)(99286004)(2501003)(386003)(36756003)(71200400001)(71190400001)(6512007)(26005)(81156014)(6116002)(3846002)(8936002)(110136005)(81166006)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB3915; H:DM6PR12MB3947.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: St3h5f3/yFkt9HD8dbLQ8LcgwKgwtyJkpqLAKhzWPf9S0U8egWmvhHhOrHmDZufkOBT//4fwGz3senqga73TQ+FoGrTfUJafGawiSrefXKtGcJ0O91jBZYZLt4Eln+pVneVW343ZC/2mezHRe3YtfwxXJ9ZfLwVileI7zYRxddRc+uk5VX0P5oxsIOFijSg2z2yZMgZr9r4JoswuyxTavWpEZpWFAeuPBnO6SeRFgx27BXRHgMf/d/Tx/vv0cWy0zS9kHcwZ7kUqAAkNOhTTUPCBe19tOIvHQOZXzgciLPm5ghyD0Cxjj6QPldTZ6aJOLCQFtng8sPgLF7A2xku0UbLFrbeXoyREm0JAxqh8hwmby50bsHrEm1peYkgGsXnXIcFUP31pdnsGcS8XO6J9GMe35rn7pOpgdhDLm7X8vpo= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf208565-9304-494f-8d99-08d70c94bbab X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2019 22:02:04.1718 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: fkuehlin@amd.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3915 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=83MMwuE9+92blTxMIYf/+fn9NS9u89ZzE/gsK11hPmI=; b=EH1JVi2N64P9TZjv/PPVmjn0OR4Pa4Zg/PJ7Rg1jHuE0CEmrBCaf0X5Bn/axO8SOZCfq9GXWyaOrRPUQnY5O9fLixX/7kGkcJnWyUiRwafk9q7MDtTQzLp/VbZU4j7rL03FoArBhQiVz1hf0GLUXoacp2T8s6JtvQI5qig4dwkI= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Felix.Kuehling@amd.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This memory allocation flag will be used to indicate BOs containing sensitive data that should not be leaked to other processes. Signed-off-by: Felix Kuehling --- include/uapi/drm/amdgpu_drm.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h index d49571dab2a1..ca97b6802275 100644 --- a/include/uapi/drm/amdgpu_drm.h +++ b/include/uapi/drm/amdgpu_drm.h @@ -131,6 +131,10 @@ extern "C" { * for the second page onward should be set to NC. */ #define AMDGPU_GEM_CREATE_MQD_GFX9 (1 << 8) +/* Flag that BO may contain sensitive data that must be wiped before + * releasing the memory + */ +#define AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE (1 << 9) struct drm_amdgpu_gem_create_in { /** the requested memory size */ From patchwork Fri Jul 19 22:02:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 11050661 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 6119213BD for ; Fri, 19 Jul 2019 22:02:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51781285F1 for ; Fri, 19 Jul 2019 22:02:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45804289D2; Fri, 19 Jul 2019 22:02:15 +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=-3.7 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_WEB 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 EDF63289CC for ; Fri, 19 Jul 2019 22:02:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E84286E870; Fri, 19 Jul 2019 22:02:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-eopbgr740045.outbound.protection.outlook.com [40.107.74.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id AB7EF6E86C; Fri, 19 Jul 2019 22:02:06 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Enfo9SPFxpOicGZxvaYDaO94SmJtQE9FXFL6EuoJRJHz/85gKDx/RKYbrQ8i49Vijf9NlesNtJI91A25bkHzOEglKPeVKRqR+CBlXqb///0vWMIB8NG8Vzybv2dgP1pHjMouDH0N01SeE2JDd6gtDmGqWkoWItzHH91dqYJYox2KgkBXorcfcTjA9+Hp8fHA89qltF9TrQHeRUj80H38+FHrjhqU4ag7X9hK4QHZc2ITgwcW4hJbxu/S0XhnqrTTDxU4ZhB3KlO9B8xcWAHzJBX8ilOD77Bitysf7YxdQ0JnMdAJ1f9rECW92TNZS1NjOCvlImSzL/HBhzAVjPTjww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DYz163Iy4mzaY2gFboYtP1ZoRqm4ctg7xFA9N5x/UPo=; b=Hu0CNoSan3NN8IKDLpn2HHE4N5jp8U804aEtIKOE1bhsSYyl4GU0TWoIM2IYFAL1fYNbvO4ooBBwlKIAUrflkac08NPDWyAwfjT/JtK1z8GDPmyAceVHxSQvU5hszIwDHkA2kWDLHif79+/hlmAmWhqTT+Vq+LEMrkuMzvoSe+YVmq4saSaH35kT5E1Euh/jgev0DxsZaMXtAeM3ZS/yk41YbHF12ppq2jIp3iYJPsdjduG1pSpKdxw+HiXdKOgsxaFN5wME+zrfs4lGr2oBFyVB1bnI8tYbTG/oya5NQc9NiskoWZ6hpcShWDuKv65ORbFA7GQzp+FFP+XUfgfCvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=amd.com;dmarc=pass action=none header.from=amd.com;dkim=pass header.d=amd.com;arc=none Received: from DM6PR12MB3947.namprd12.prod.outlook.com (10.255.174.156) by DM6PR12MB3915.namprd12.prod.outlook.com (10.255.174.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2094.15; Fri, 19 Jul 2019 22:02:05 +0000 Received: from DM6PR12MB3947.namprd12.prod.outlook.com ([fe80::91a2:f9e7:8c86:f927]) by DM6PR12MB3947.namprd12.prod.outlook.com ([fe80::91a2:f9e7:8c86:f927%7]) with mapi id 15.20.2073.012; Fri, 19 Jul 2019 22:02:05 +0000 From: "Kuehling, Felix" To: "amd-gfx@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" Subject: [PATCH 2/4] drm/amdgpu: Mark KFD VRAM allocations for wipe on release Thread-Topic: [PATCH 2/4] drm/amdgpu: Mark KFD VRAM allocations for wipe on release Thread-Index: AQHVPn2ZHovwIJLpEk6qAugRNCow1Q== Date: Fri, 19 Jul 2019 22:02:04 +0000 Message-ID: <20190719220140.18968-2-Felix.Kuehling@amd.com> References: <20190719220140.18968-1-Felix.Kuehling@amd.com> In-Reply-To: <20190719220140.18968-1-Felix.Kuehling@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [165.204.55.251] x-mailer: git-send-email 2.17.1 x-clientproxiedby: YTXPR0101CA0061.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::38) To DM6PR12MB3947.namprd12.prod.outlook.com (2603:10b6:5:1cb::28) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b7c8f80c-424f-4a46-435f-08d70c94bbef x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM6PR12MB3915; x-ms-traffictypediagnostic: DM6PR12MB3915: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 01039C93E4 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(136003)(396003)(346002)(376002)(366004)(189003)(199004)(66446008)(66556008)(66476007)(66946007)(5660300002)(66066001)(64756008)(478600001)(53936002)(25786009)(7736002)(305945005)(256004)(14444005)(6436002)(486006)(86362001)(6486002)(52116002)(76176011)(450100002)(476003)(50226002)(68736007)(186003)(8676002)(2616005)(1076003)(14454004)(6506007)(102836004)(11346002)(446003)(2906002)(99286004)(2501003)(386003)(36756003)(71200400001)(71190400001)(6512007)(26005)(81156014)(6116002)(3846002)(8936002)(110136005)(81166006)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB3915; H:DM6PR12MB3947.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Gj9wpxyOML5g9GwdZ4X5l/qYfnHuhcTnOxP/JiHIc6nvrNj6ztbPyBM+4cbNGjuhYTkCxDJBoX4vmOFzpCvRE3v7HN1aLwSfKb7Fgj0XDrCkxNNUa29IIBWlDi/dZIW0G9FHVvuYwyrfEozjSL3ezLoEvXLM0gPbnbbSOUplbqUtAG8bsvsaJEuDYahYVwFLE7hcUAudcGbtNtxiSZhdO/oY9FJ9fcLkJL41OSaiTqh2cvEaAQgnD/hp0q6Oln50I5RNIjsDaSHYpFx6C1jVmFQzED4qBxjwxlKwPA40DqBkrRmuLWMaTa6qqxFM3c1LemaL8hn4l2YLsZTqWZyXmm5zfNMu7SVgEKcqp/zQ/C0p4Db1jadeQnHUOTwn/vKDdGD7gupDOVMbl8pfsLllg3PkAryafal2U3DDZAUWrVE= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7c8f80c-424f-4a46-435f-08d70c94bbef X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2019 22:02:04.7055 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: fkuehlin@amd.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3915 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DYz163Iy4mzaY2gFboYtP1ZoRqm4ctg7xFA9N5x/UPo=; b=DgUpZrXVeEJHwuFs0Ga7MXD7bd90tBkB5O6Qkci6Cj6wzlUgVtLR9Ty4U0jNz+/W0QToSerxEUOrEi96C5JOmKsD+Khk4fr5sSaG1OaQBPYh1r+t3v1kjj8WhPeebLhtPQKBjQtVGfSCvGgHoVCx9bq7G2Mav7FlduEP0UKWPvU= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Felix.Kuehling@amd.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Memory used by KFD applications can contain sensitive information that should not be leaked to other processes. The current approach to prevent leaks is to clear VRAM at allocation time. This is not effective because memory can be reused in other ways without being cleared. Synchronously clearing memory on the allocation path also carries a significant performance penalty. Stop clearing memory at allocation time. Instead mark the memory for wipe on release. Signed-off-by: Felix Kuehling --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index f5ecf28eb37c..2db6e498c069 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -1089,7 +1089,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( */ if (flags & ALLOC_MEM_FLAGS_VRAM) { domain = alloc_domain = AMDGPU_GEM_DOMAIN_VRAM; - alloc_flags = AMDGPU_GEM_CREATE_VRAM_CLEARED; + alloc_flags = AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE; alloc_flags |= (flags & ALLOC_MEM_FLAGS_PUBLIC) ? AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED : AMDGPU_GEM_CREATE_NO_CPU_ACCESS; From patchwork Fri Jul 19 22:02:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 11050663 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 28FF7138D for ; Fri, 19 Jul 2019 22:02:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B0F02873E for ; Fri, 19 Jul 2019 22:02:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F75C289CC; Fri, 19 Jul 2019 22:02:17 +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=-3.7 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_WEB 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 BB4DA2873E for ; Fri, 19 Jul 2019 22:02:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 764416E872; Fri, 19 Jul 2019 22:02:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-eopbgr740045.outbound.protection.outlook.com [40.107.74.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0BEB66E86B; Fri, 19 Jul 2019 22:02:07 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LKW6tr8wVKS2UiIuuCQpk/TiZyeFQwWqFeb1CkQlC5IJIbjkfeV6fz95TWFyDITPOzcymOgVP29NmgPSFFNMqRiZcRNEw2u9UG7zeThJ2k8VkoGYerwB83w+jijrGOARyVVNUoDrBptULdW2FO0hwIzkhjU9o3urfN3l5cyWIfECWnDt2PIFry151R7VyVMAPgS86OkDJ5vTCJK3/kD9iirnGSxsxMJkkWEECegcm08ZD70nMap19LBBqykWfWylUc95fmtfYTK+Worm0m4aZbdsRBkETl3xltNwhl9AQMlPfH0XIXCEMFXzuhiD+H4qkAXJQTZ7Z/F4bsJgH2LK5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4FwOILOlrBvqJLknF7lig/bNDv35Zf2YXs3eje1W5fc=; b=dCao3Xa7TotXHP0tyxmZ9p8XnOdlyHiqwtBaMjyi9zvlXzZcbpXtba+Qcq/enF6NmBgFZD7TrVVEMhbO2w6/KxtMhvjoaf/djwJhHctPe/zMV7adcUciFmrnqWuMAVMicOhHeb3LVDrSS3Ma/d02kE6ghPvOwuPQ4rl/1VgaipeR/7M9jxFte5QfNxvpPz+LzNgePZVCfNiUF/2WCZ36IwvOhd2/R/NRX24Nxf+7o8irFCabK+n+u1v1HDn2s3tDNAhVUU1mIiVwV3RxyffHTQOBacmGeJqFaGTeJVDFvvY/zag4mL5f2DCRNkQ8sQgjUhp34CRxJi3aEsvgG1idPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=amd.com;dmarc=pass action=none header.from=amd.com;dkim=pass header.d=amd.com;arc=none Received: from DM6PR12MB3947.namprd12.prod.outlook.com (10.255.174.156) by DM6PR12MB3915.namprd12.prod.outlook.com (10.255.174.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2094.15; Fri, 19 Jul 2019 22:02:05 +0000 Received: from DM6PR12MB3947.namprd12.prod.outlook.com ([fe80::91a2:f9e7:8c86:f927]) by DM6PR12MB3947.namprd12.prod.outlook.com ([fe80::91a2:f9e7:8c86:f927%7]) with mapi id 15.20.2073.012; Fri, 19 Jul 2019 22:02:05 +0000 From: "Kuehling, Felix" To: "amd-gfx@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" Subject: [PATCH 3/4] drm/ttm: Add release_notify callback to ttm_bo_driver Thread-Topic: [PATCH 3/4] drm/ttm: Add release_notify callback to ttm_bo_driver Thread-Index: AQHVPn2Z90vw1Ah1BEWOH9I1DqRQVQ== Date: Fri, 19 Jul 2019 22:02:05 +0000 Message-ID: <20190719220140.18968-3-Felix.Kuehling@amd.com> References: <20190719220140.18968-1-Felix.Kuehling@amd.com> In-Reply-To: <20190719220140.18968-1-Felix.Kuehling@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [165.204.55.251] x-mailer: git-send-email 2.17.1 x-clientproxiedby: YTXPR0101CA0061.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::38) To DM6PR12MB3947.namprd12.prod.outlook.com (2603:10b6:5:1cb::28) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 06737b02-7cf8-4451-273a-08d70c94bc4a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM6PR12MB3915; x-ms-traffictypediagnostic: DM6PR12MB3915: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 01039C93E4 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(136003)(396003)(346002)(376002)(366004)(189003)(199004)(66446008)(66556008)(66476007)(66946007)(5660300002)(66066001)(64756008)(478600001)(53936002)(25786009)(7736002)(305945005)(256004)(14444005)(6436002)(486006)(86362001)(6486002)(52116002)(76176011)(450100002)(476003)(50226002)(68736007)(186003)(8676002)(2616005)(1076003)(14454004)(6506007)(102836004)(11346002)(446003)(2906002)(99286004)(2501003)(386003)(36756003)(71200400001)(71190400001)(6512007)(26005)(81156014)(6116002)(3846002)(8936002)(110136005)(81166006)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB3915; H:DM6PR12MB3947.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: TxQEmr4pPrdkBxQzqoscF8yWC2WpHT3aiKmf86Ba/1oPslEZVDdr4rKG+1iXYIKTDnSzDxi/gR8LE3WG7lH+RBacJAnO7q12GuALp49czP9xcQvpb4L1aW8OpV2joYQYX0ZI1Wnum6uSziAFNbKcXo4cBemUlZ94OE16UYpPwD9cgUsIgsnzPNs7lAm+E05r57MV7TiarTuwoa2orTHTgiZRU4n1FDGIvJYGC86Q/4DfK8NKcs9ew2+ywZG6isoGuYgcVcRDN0blGco1v3MjQZuTBMnRAF2CCLa79JptbLra09WqddkUY2fHs3GXoJVlxc8vfRAfb7VlXcibbhnaTtemZe7+fkc31A1sHHxZv4o+IV80zTIsYapjtbVjJxAeRPRnh2c70+OHJuSbEuqeP7Okez2aiANLu0vxfqCB7UE= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06737b02-7cf8-4451-273a-08d70c94bc4a X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2019 22:02:05.2012 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: fkuehlin@amd.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3915 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4FwOILOlrBvqJLknF7lig/bNDv35Zf2YXs3eje1W5fc=; b=uLcMt99bzD0Rb2jhoShMqd+GMzrvDkEBYfb4n6wShYQdLGwYN/WDu+iD21OQLcstZne9+rURqciSejwVyU6+0DrckvJuTcTk9shdAhjgaFhNfGokZ17STJ172QE/CdQn9TQbk+JptyhE4hjbZV72tLkjcjgoa2c3do8Djb3AEmU= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Felix.Kuehling@amd.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This notifies the driver that a BO is about to be released. Releasing a BO also invokes the move_notify callback from ttm_bo_cleanup_memtype_use, but that happens too late for anything that would add fences to the BO and require a delayed delete. Signed-off-by: Felix Kuehling --- drivers/gpu/drm/ttm/ttm_bo.c | 3 +++ include/drm/ttm/ttm_bo_driver.h | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 58c403eda04e..2070e8a57ed8 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -671,6 +671,9 @@ static void ttm_bo_release(struct kref *kref) struct ttm_bo_device *bdev = bo->bdev; struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type]; + if (bo->bdev->driver->release_notify) + bo->bdev->driver->release_notify(bo); + drm_vma_offset_remove(&bdev->vma_manager, &bo->vma_node); ttm_mem_io_lock(man, false); ttm_mem_io_free_vm(bo); diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index c9b8ba492f24..d69121c43e58 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -390,6 +390,16 @@ struct ttm_bo_driver { * notify driver that a BO was deleted from LRU. */ void (*del_from_lru_notify)(struct ttm_buffer_object *bo); + + /** + * Notify the driver that we're about to release a BO + * + * @bo: BO that is about to be released + * + * Gives the driver a chance to do any cleanup, including + * adding fences that may force a delayed delete + */ + void (*release_notify)(struct ttm_buffer_object *bo); }; /** From patchwork Fri Jul 19 22:02:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 11050665 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 B0736138D for ; Fri, 19 Jul 2019 22:02:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F2D428720 for ; Fri, 19 Jul 2019 22:02:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91638289CB; Fri, 19 Jul 2019 22:02:19 +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=-3.7 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_WEB 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 1E87E289CB for ; Fri, 19 Jul 2019 22:02:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 325176E874; Fri, 19 Jul 2019 22:02:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-eopbgr740045.outbound.protection.outlook.com [40.107.74.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 617BB6E86D; Fri, 19 Jul 2019 22:02:07 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gm77quz7izuksIViLzYN2Fugg2fH0JS96V8cTlf1x5ilzXosI4DutvXOKOnN2vMVStTqd4W6cEw7egeGSxVADwlHuderYJs4WEk/IIKEFeS9oiBBzlEmlwaXIrfJ/ET4+UggLstvJ6oziyLNEbneGx1aS7d1o6Q2LBJv+Jit8Pv9YFc7+xaMljTD0/5C6CV70rjO+rmVFeyL4CUbxiL0nYFA9f1wmlOUI/M3K1oZBXF7/ul6e4HNIwHmov6+P05awTMp6avtkO6r79JoK7NharEkHfrGd3U8L9+t6Hl5BsPhbDA2FbLkBhy49tSg5zGWFuMnCYfh4zmJ+2OB4Dos8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Jj9yxyHiQUUC7LycZcDOVMILX5OR2l3ZJvbYp6maJGk=; b=NbrI88crucR659C4DVMSTIafqd46bC6QNqC/k5nXVf7niuPQMxg7RgV7wPEwFwJ/M0cTVC4/pfd/WcGh3yStMJfkKxo6GnVu7iHx25hjHJz1oucPiCEb0eu/WnLJO2FiwVz7yf/tJAfkLL+/D1mDGYFL5S97hZ0BKULt3pUR0FRXaFx1ED87iLJCqzTC1RTXAysUG7CLWzuWjkt+y7NBVhmI4IShmTTPYfbHLVsUJDEJYaSB2BpJ91Yi5AZuh729OCekU6tBsX5+2l9mCg+qr33JsgOkGiY1nUGZlmlHSklw1sNoM/JStfqq2ztTnq3gNQKRbKSk0dHBsGD/Y7EyCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=amd.com;dmarc=pass action=none header.from=amd.com;dkim=pass header.d=amd.com;arc=none Received: from DM6PR12MB3947.namprd12.prod.outlook.com (10.255.174.156) by DM6PR12MB3915.namprd12.prod.outlook.com (10.255.174.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2094.15; Fri, 19 Jul 2019 22:02:06 +0000 Received: from DM6PR12MB3947.namprd12.prod.outlook.com ([fe80::91a2:f9e7:8c86:f927]) by DM6PR12MB3947.namprd12.prod.outlook.com ([fe80::91a2:f9e7:8c86:f927%7]) with mapi id 15.20.2073.012; Fri, 19 Jul 2019 22:02:06 +0000 From: "Kuehling, Felix" To: "amd-gfx@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" Subject: [PATCH 4/4] drm/amdgpu: Implement VRAM wipe on release Thread-Topic: [PATCH 4/4] drm/amdgpu: Implement VRAM wipe on release Thread-Index: AQHVPn2auNq+4mwrDEihQFxyGHm+0g== Date: Fri, 19 Jul 2019 22:02:05 +0000 Message-ID: <20190719220140.18968-4-Felix.Kuehling@amd.com> References: <20190719220140.18968-1-Felix.Kuehling@amd.com> In-Reply-To: <20190719220140.18968-1-Felix.Kuehling@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [165.204.55.251] x-mailer: git-send-email 2.17.1 x-clientproxiedby: YTXPR0101CA0061.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:1::38) To DM6PR12MB3947.namprd12.prod.outlook.com (2603:10b6:5:1cb::28) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 349c3af6-b793-4f0c-32c1-08d70c94bc9c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM6PR12MB3915; x-ms-traffictypediagnostic: DM6PR12MB3915: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 01039C93E4 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(136003)(396003)(346002)(376002)(366004)(189003)(199004)(66446008)(66556008)(66476007)(66946007)(5660300002)(66066001)(64756008)(478600001)(53936002)(25786009)(7736002)(305945005)(256004)(14444005)(5024004)(6436002)(486006)(86362001)(6486002)(52116002)(76176011)(450100002)(476003)(50226002)(68736007)(186003)(8676002)(2616005)(1076003)(14454004)(6506007)(102836004)(11346002)(446003)(2906002)(99286004)(2501003)(386003)(36756003)(71200400001)(71190400001)(6512007)(26005)(81156014)(6116002)(3846002)(8936002)(110136005)(81166006)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB3915; H:DM6PR12MB3947.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Hzlq0uxyCQieOiOnRTZRs6lEEcfR4VGteVKOESGl3lKtPdltzmKXALwmLQwvZImmEccTmC20aLz6XZwrVnX+4cpWw0euZmuk16QD49JIaHfcXL5SQ8lEFrxNNW9tkBff4HF344ZPpIbTZN2xwWwKLQLJzTG6ZXwpWRKs4sY8wW7avbXaZD9p92i/sWui+o5HJ3QmcmJIKm8VE4t9NFbG51JPP1kHz4rBOwI+WMgndbF30U1Fr5DB4yi7qTqJuiCQEgONqdO5m4bIrM37XGLDvJtGBa1LFd0R2UmuEy+dtLjOAEiKS0ZR3UoRyFP4ay13trfraL7wnohLaDLkwzShscSsqFGhuwcqQPuXfphBlAiTBf5Pu4hDt7lyZr+ivy0l78gkVvkFLEuidguUHtE3PmUq6K8QI7no+XftnzWqnU4= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 349c3af6-b793-4f0c-32c1-08d70c94bc9c X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2019 22:02:05.7269 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: fkuehlin@amd.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3915 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Jj9yxyHiQUUC7LycZcDOVMILX5OR2l3ZJvbYp6maJGk=; b=TFTsFuj5QfsUp6F4y8wBQoMUVkcu6E+5q4FJeaUIqtr+vhcViaG5G0NMzEBpiftwvx3704pUuP14hfn1kBOoXp35wXEKCbgvsQPrpyuoN39RdhAkcYe8J9YUcPY3uSyLU/WjHAAgzA7TJWAvZnI1TWBqcvt98hPdnptxzC8+5/o= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Felix.Kuehling@amd.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Wipe VRAM memory containing sensitive data when moving or releasing BOs. Clearing the memory is pipelined to minimize any impact on subsequent memory allocation latency. Use of a poison value should help debug future use-after-free bugs. When moving BOs, the existing ttm_bo_pipelined_move ensures that the memory won't be reused before being wiped. When releasing BOs, the BO is fenced with the memory fill operation, which results in queuing the BO for a delayed delete. v2: Move amdgpu_amdkfd_unreserve_memory_limit into amdgpu_bo_release_notify so that KFD can use memory that's still being cleared in the background Signed-off-by: Felix Kuehling --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 39 ++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 17 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 2 ++ 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 989b7b55cb2e..f95f7a6509cc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -80,9 +80,6 @@ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo) if (bo->pin_count > 0) amdgpu_bo_subtract_pin_size(bo); - if (bo->kfd_bo) - amdgpu_amdkfd_unreserve_memory_limit(bo); - amdgpu_bo_kunmap(bo); if (bo->gem_base.import_attach) @@ -1211,6 +1208,42 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, trace_amdgpu_bo_move(abo, new_mem->mem_type, old_mem->mem_type); } +/** + * amdgpu_bo_move_notify - notification about a BO being released + * @bo: pointer to a buffer object + * + * Wipes VRAM buffers whose contents should not be leaked before the + * memory is released. + */ +void amdgpu_bo_release_notify(struct ttm_buffer_object *bo) +{ + struct dma_fence *fence = NULL; + struct amdgpu_bo *abo; + int r; + + if (!amdgpu_bo_is_amdgpu_bo(bo)) + return; + + abo = ttm_to_amdgpu_bo(bo); + + if (abo->kfd_bo) + amdgpu_amdkfd_unreserve_memory_limit(abo); + + if (bo->mem.mem_type != TTM_PL_VRAM || !bo->mem.mm_node || + !(abo->flags & AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE)) + return; + + reservation_object_lock(bo->resv, NULL); + + r = amdgpu_fill_buffer(abo, AMDGPU_POISON, bo->resv, &fence); + if (!WARN_ON(r)) { + amdgpu_bo_fence(abo, fence, false); + dma_fence_put(fence); + } + + reservation_object_unlock(bo->resv); +} + /** * amdgpu_bo_fault_reserve_notify - notification about a memory fault * @bo: pointer to a buffer object diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index d60593cc436e..e302384fe003 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h @@ -265,6 +265,7 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer, void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, bool evict, struct ttm_mem_reg *new_mem); +void amdgpu_bo_release_notify(struct ttm_buffer_object *bo); int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo); void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence, bool shared); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index eca2321e7a97..801f912a8578 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -439,6 +439,22 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, if (r) goto error; + /* clear the space being freed */ + if (old_mem->mem_type == TTM_PL_VRAM && + (ttm_to_amdgpu_bo(bo)->flags & + AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE)) { + struct dma_fence *wipe_fence = NULL; + + r = amdgpu_fill_buffer(ttm_to_amdgpu_bo(bo), AMDGPU_POISON, + NULL, &wipe_fence); + if (r) { + goto error; + } else if (wipe_fence) { + dma_fence_put(fence); + fence = wipe_fence; + } + } + /* Always block for VM page tables before committing the new location */ if (bo->type == ttm_bo_type_kernel) r = ttm_bo_move_accel_cleanup(bo, fence, true, new_mem); @@ -1594,6 +1610,7 @@ static struct ttm_bo_driver amdgpu_bo_driver = { .move = &amdgpu_bo_move, .verify_access = &amdgpu_verify_access, .move_notify = &amdgpu_bo_move_notify, + .release_notify = &amdgpu_bo_release_notify, .fault_reserve_notify = &amdgpu_bo_fault_reserve_notify, .io_mem_reserve = &amdgpu_ttm_io_mem_reserve, .io_mem_free = &amdgpu_ttm_io_mem_free, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index caa76c693700..bccb8c49e597 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h @@ -38,6 +38,8 @@ #define AMDGPU_GTT_MAX_TRANSFER_SIZE 512 #define AMDGPU_GTT_NUM_TRANSFER_WINDOWS 2 +#define AMDGPU_POISON 0xd0bed0be + struct amdgpu_mman { struct ttm_bo_device bdev; bool mem_global_referenced;