From patchwork Wed Sep 25 13:45:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 11160731 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7044C924 for ; Wed, 25 Sep 2019 13:45:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 57F272146E for ; Wed, 25 Sep 2019 13:45:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 57F272146E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E8FD96EBCE; Wed, 25 Sep 2019 13:45:47 +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-eopbgr730053.outbound.protection.outlook.com [40.107.73.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9BB8D6EBCA; Wed, 25 Sep 2019 13:45:45 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UX8VHZcBVrk3c3j0JhefltDRsViSZXM5tUqWAFTWE6mmY0snaQHNHc3N8c/GralHnX1H80/6CTDf0DQs2Tp/BLZkRgnsrSiZa7YHXOn6Agh4mNm0JnOUSdw7imDkbyVRBBsjiokt0N8+vZFwkrGy0n67G0XItA11q0hSWlpTHeX0FqKyJYOJQjtMpcX1LuunwWjyC8vmAngIvEyXNUSeEnEM0dsvlkef0lDdsVZ6Uav8PQHo6cMvmjl3xQ4hndBpfMnm8CXvJa3JSmUUVB+z/q9Abs4/uTB+Z7XI7ywIt8Ma2JIOtQ5/G3SfNT2dp4/1o0uEFFCpdYwdRoBP08yQ4A== 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=/rOya0AF4FSBiumuaycpfz+1FkTp0kfeBO1CGsL/DDA=; b=gNP3JQP7zpbyUM9xKG4EfHnq/CuskdP+VCdMiCf9lihgJI5+xU/wV9v/Tgt8MK1UY/U4lWXtLlDPb7plrLMFwT0lJuXuPIZE2i60FVhrW1VvYBBMRkBfbWyXsWj4NpOwYCXzrq/qam0PcDnaM3rAXPFphokMGnv4FZVRsYQsTlDiy5Jnsc5Vd1UEaPJafXhf9ZuTk/iTEV/Z7thRj6m5C+X+/8X8UgNCpgowySnsEFDdbZRWVIz370p76hGfihr3QlN9+6WjwLg28Nu5A0oaauuU1WP+sq12cm0SglfXUJh9gQ43wX2ME58ked5fMiM+km/pc82qsKtu9wJjEp8OHQ== 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 MN2PR12MB3309.namprd12.prod.outlook.com (20.179.83.157) by MN2PR12MB4304.namprd12.prod.outlook.com (10.255.224.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 25 Sep 2019 13:45:42 +0000 Received: from MN2PR12MB3309.namprd12.prod.outlook.com ([fe80::e105:cd24:c71d:c38d]) by MN2PR12MB3309.namprd12.prod.outlook.com ([fe80::e105:cd24:c71d:c38d%4]) with mapi id 15.20.2305.016; Wed, 25 Sep 2019 13:45:42 +0000 From: "Huang, Ray" To: "amd-gfx@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" , "Deucher, Alexander" Subject: [PATCH v2 10/11] drm/amdgpu: job is secure iff CS is secure (v3) Thread-Topic: [PATCH v2 10/11] drm/amdgpu: job is secure iff CS is secure (v3) Thread-Index: AQHVc6eGQ8fsYXuB3USvmI2hDudFAQ== Date: Wed, 25 Sep 2019 13:45:42 +0000 Message-ID: <1569419090-5304-11-git-send-email-ray.huang@amd.com> References: <1569419090-5304-1-git-send-email-ray.huang@amd.com> In-Reply-To: <1569419090-5304-1-git-send-email-ray.huang@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [180.167.199.189] x-clientproxiedby: HK2PR02CA0186.apcprd02.prod.outlook.com (2603:1096:201:21::22) To MN2PR12MB3309.namprd12.prod.outlook.com (2603:10b6:208:106::29) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 15a13e70-585d-4718-f56c-08d741bea853 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR12MB4304; x-ms-traffictypediagnostic: MN2PR12MB4304: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-forefront-prvs: 01713B2841 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(136003)(376002)(346002)(396003)(366004)(189003)(199004)(86362001)(8936002)(305945005)(2501003)(50226002)(6636002)(256004)(6486002)(6116002)(3846002)(6436002)(6512007)(2906002)(4326008)(66066001)(102836004)(26005)(186003)(52116002)(76176011)(486006)(476003)(2616005)(11346002)(66946007)(66476007)(66556008)(64756008)(66446008)(446003)(99286004)(5660300002)(81156014)(6506007)(81166006)(450100002)(25786009)(36756003)(316002)(478600001)(386003)(8676002)(71190400001)(71200400001)(110136005)(54906003)(7736002)(14454004); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR12MB4304; H:MN2PR12MB3309.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: SeDfoS+Qn8LBbjrkODdnxsmx0cD+oavHWEClYhHwyRAvonA9nXrJ+iI0wg5NLzpAyA+XAenWczpMCwg5EQtESIzSIoIO/42ekkIDPdDN9hE0LQ3jTazLcQbHuzDWzTBFV7BPSZpredbpr3VEqQJWARO8HpfqJvdlov890npCg2DOsLj7AqjYqYbA9BbSciXOctbByrjnudasuUcYcxD2G+s5OQMnsfap/kh8Tavij57sF+uX99Oo5WqW2biJVRdb9TgdJobE06XU6KAmmEiZ7vKuErA4BWreE2OZO1I66qhLN3o3XbucZhub1a6Pw5zsctq/owkSouQOTxQd6aXtNcaByA+0V6JU4yN1AdHy8sr2mxBhfEblX8IpL2eG9IgBrIbldn5KbJM6aCUBvBabIzXAR8WlfQtmOZ2l+DUOY+8= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15a13e70-585d-4718-f56c-08d741bea853 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Sep 2019 13:45:42.3218 (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: p7JO7XmlX9dK12m8ighMO251vjscunZcYdHlTZcywODhW+VFh7xSmoqed6xKv4aLKZ9urt3FDYSHQ8w/F7k+hw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4304 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/rOya0AF4FSBiumuaycpfz+1FkTp0kfeBO1CGsL/DDA=; b=qpg99ES79TE9a7PNrWGGP392cIvf7ZLMCMGgS+Y41cf81iq1m8hGw4XcIlFxtVcoq4e1FIdB8A0p+5PcU6YkhBIHcQDXDw28q/XMVk50+C6XMxzne6lNA5JG8VujIJtf4po1xT/9CHePBwpg5PM128/d0LTJqMrTJncq0PpUx/E= X-Mailman-Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ray.Huang@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: , Cc: "Tuikov, Luben" , "Huang, Ray" , "Koenig, Christian" , "Liu, Aaron" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Mark a job as secure, if and only if the command submission flag has the secure flag set. v2: fix the null job pointer while in vmid 0 submission. v3: Context --> Command submission. Signed-off-by: Huang Rui Co-developed-by: Luben Tuikov Signed-off-by: Luben Tuikov Reviewed-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 8 +++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 51f3db0..0077bb3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -1252,8 +1252,14 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, p->ctx->preamble_presented = true; } - cs->out.handle = seq; + /* The command submission (cs) is a union, so an assignment to + * 'out' is destructive to the cs (at least the first 8 + * bytes). For this reason, inquire about the flags before the + * assignment to 'out'. + */ + job->secure = cs->in.flags & AMDGPU_CS_FLAGS_SECURE; job->uf_sequence = seq; + cs->out.handle = seq; amdgpu_job_free_resources(job); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c index e1dc229..cb9b650 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c @@ -210,7 +210,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, if (job && ring->funcs->emit_cntxcntl) { status |= job->preamble_status; status |= job->preemption_status; - amdgpu_ring_emit_cntxcntl(ring, status, false); + amdgpu_ring_emit_cntxcntl(ring, status, job->secure); } for (i = 0; i < num_ibs; ++i) { @@ -229,7 +229,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, } if (ring->funcs->emit_tmz) - amdgpu_ring_emit_tmz(ring, false, false); + amdgpu_ring_emit_tmz(ring, false, job ? job->secure : false); #ifdef CONFIG_X86_64 if (!(adev->flags & AMD_IS_APU)) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h index dc7ee93..aa0e375 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h @@ -63,6 +63,8 @@ struct amdgpu_job { uint64_t uf_addr; uint64_t uf_sequence; + /* the job is due to a secure command submission */ + bool secure; }; int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,