From patchwork Wed Sep 25 14:38:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 11160853 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 B2377112B for ; Wed, 25 Sep 2019 14:38:21 +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 8AA802146E for ; Wed, 25 Sep 2019 14:38:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8AA802146E 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 CC0296EBD6; Wed, 25 Sep 2019 14:38:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-eopbgr760089.outbound.protection.outlook.com [40.107.76.89]) by gabe.freedesktop.org (Postfix) with ESMTPS id D63B06EBD6; Wed, 25 Sep 2019 14:38:19 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l1tO0GbTsHpKgT6Uwe8FtyDx2fP8LBFeQDPENNqoCGCTQ6Kn0fIuhWGyszPe4PoLZG3XQKYT8wsbwJ3sztiCuImQckSmj4OElRiA46mFKlpqHAiHZkhhg2AswyEl4oCegZyZzo36wiZr+ZUADsyLEouZQdUmFf8oUZEnaSXkTsGfI3iMSemrhW13ajXl9Lnq2RF6m03Jwl8URg4qilR0WufQyJoPo3o49Cpn0HZJg3XR8AVInP9JDFjBM3tj9s2QZP9LZ7dQjUxp3YBBt0NgK1QX5O++8a9zOcKqGZFJcZlKDQHggsHYUGB0FSMmjVjrVGd4LzqYxqiTy+zauBQVAQ== 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=MrxMXaqJuSRJYiB/VyAticY06ABINF5WXuOvXN3Ggsc=; b=UGjDeoNjavyf8+1RRebNMSJLwbzXhQiWn9jFKVaE84ESoPhYDJPLH2Kk1hb312OPT9ONNiw2Pj+kLjYYE8p6VPicEEI2Z35nKtAoDr2ho1P05i6WgGvD7a68HC3D6K4U3s2MAdK9Y7iMJy77VY6aBay5h59z100ZbTasBubAPEq+EhJYYWvJuz/Gc2FJR6TA5OG491ZY4e37AQWFc0UkDtIx1QfUlARF5ccxGwVfBaX2JHGxRrVBg+whrk4A8cwaGLEhrbjpsEMeksaoFqrTd0fKWMe5kt+OPeTSZdckUj5wF4e3uq276rk9owrORU5L+dZ8dKnxDZ48USvUHHE2sg== 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 MN2PR12MB3630.namprd12.prod.outlook.com (20.178.243.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.25; Wed, 25 Sep 2019 14:38:17 +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 14:38:17 +0000 From: "Huang, Ray" To: "amd-gfx@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" , "Deucher, Alexander" Subject: [PATCH v3 10/11] drm/amdgpu: job is secure iff CS is secure (v4) Thread-Topic: [PATCH v3 10/11] drm/amdgpu: job is secure iff CS is secure (v4) Thread-Index: AQHVc67eAOP3HjJHn0i9QUAnxAttaw== Date: Wed, 25 Sep 2019 14:38:17 +0000 Message-ID: <1569422279-6609-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: HK0P153CA0037.APCP153.PROD.OUTLOOK.COM (2603:1096:203:17::25) 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: 80bbe05c-b655-4031-1793-08d741c600fd 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:MN2PR12MB3630; x-ms-traffictypediagnostic: MN2PR12MB3630: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-forefront-prvs: 01713B2841 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(136003)(376002)(396003)(366004)(346002)(189003)(199004)(64756008)(6486002)(486006)(2616005)(66556008)(476003)(8936002)(66446008)(6116002)(81156014)(71190400001)(2501003)(8676002)(36756003)(50226002)(6506007)(99286004)(386003)(26005)(52116002)(102836004)(478600001)(3846002)(86362001)(2906002)(305945005)(256004)(81166006)(66476007)(7736002)(5660300002)(186003)(4326008)(6512007)(6636002)(71200400001)(14454004)(25786009)(110136005)(54906003)(450100002)(66946007)(316002)(6436002)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR12MB3630; 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: yuLoQeUBUZQRizfqrELmWS0chfYsx36H7lRsi1531fJUpWOgeQhkx3wzGvuFMcAcv4aQi4c15guQzWsRg0bYpGtj2ucE2G/w6pS9TqD1WIL/F7X4gzNvSTLOd43RKPih9ZtX9u89J0fJkDzAWi8mv5/r0jcM+TsrkTmFnUT8ec9rcGO46B1LltvtPT91wr6N8GSITciVSq2SIvf/uIgvrV8t5UjN4iFpot76ONJNRwMc6GSnewRc5EjKxj/M6E3Jhs6yESoLZtvW5XEGWpMJP+PCp8lwh3T2qsHUsLe8VmeOdS/nrbIypypyB3a3CzwFrXfJQrJIMpWs4MC1IhhTmqzVczcjYB9HQm9A6njRT5xJttj1yR2TrbGCZjVcCyUlO8TPPIkO2p5OtVinYw+4BJEVkM0mhLdZn0TlXdOOgAM= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80bbe05c-b655-4031-1793-08d741c600fd X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Sep 2019 14:38:17.5099 (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: Qtf1rhwmxiHOv6wIsQBQFa0JV1PW4Jvk0l0zaRgLsypwmhRhghcwWgCUtUPKTSDLDtf0x2oZHolLX0lnTWpHmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3630 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=MrxMXaqJuSRJYiB/VyAticY06ABINF5WXuOvXN3Ggsc=; b=qPgpNKXGUj2uvebWpyA26sjFsavzgQorJntRiZBIQbxyJ4ao8nGnyfe7/UvDsvM8Q3m7EtfT64fM891uDRnrmQXxNWJPTPjKPH10ofAHePwmX/LJMqxDuLEsCnigW8OvhKzpO61dcQ+eocuXV5BXJa52CaJhoqQZE1dAhn79MpA= 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. v4: filling cs parser with cs->in.flags 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.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 11 ++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 2 ++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 697e8e5..fd60695 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -485,6 +485,9 @@ struct amdgpu_cs_parser { uint64_t bytes_moved; uint64_t bytes_moved_vis; + /* secure cs */ + bool is_secure; + /* user fence */ struct amdgpu_bo_list_entry uf_entry; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 51f3db0..9038dc1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -133,6 +133,14 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, union drm_amdgpu_cs goto free_chunk; } + /** + * 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'. + */ + p->is_secure = cs->in.flags & AMDGPU_CS_FLAGS_SECURE; + /* get chunks */ chunk_array_user = u64_to_user_ptr(cs->in.chunks); if (copy_from_user(chunk_array, chunk_array_user, @@ -1252,8 +1260,9 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, p->ctx->preamble_presented = true; } - cs->out.handle = seq; + job->secure = p->is_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,