From patchwork Fri Dec 5 08:47:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 5442871 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 10C70BEEA8 for ; Fri, 5 Dec 2014 08:47:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4324D202B8 for ; Fri, 5 Dec 2014 08:47:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 10F9020034 for ; Fri, 5 Dec 2014 08:47:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C4EB76E520; Fri, 5 Dec 2014 00:47:53 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0142.outbound.protection.outlook.com [157.56.111.142]) by gabe.freedesktop.org (Postfix) with ESMTP id A7DF96E50A for ; Fri, 5 Dec 2014 00:47:51 -0800 (PST) Received: from BN1PR02CA0014.namprd02.prod.outlook.com (10.141.56.14) by CO1PR02MB207.namprd02.prod.outlook.com (10.242.165.145) with Microsoft SMTP Server (TLS) id 15.1.31.17; Fri, 5 Dec 2014 08:47:49 +0000 Received: from BY2FFO11FD021.protection.gbl (2a01:111:f400:7c0c::170) by BN1PR02CA0014.outlook.office365.com (2a01:111:e400:2a::14) with Microsoft SMTP Server (TLS) id 15.1.31.17 via Frontend Transport; Fri, 5 Dec 2014 08:47:48 +0000 Received: from atltwp02.amd.com (165.204.84.222) by BY2FFO11FD021.mail.protection.outlook.com (10.1.15.210) with Microsoft SMTP Server id 15.1.26.17 via Frontend Transport; Fri, 5 Dec 2014 08:47:47 +0000 X-WSS-ID: 0NG3PRH-08-6SY-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 2E085D1603B; Fri, 5 Dec 2014 02:47:41 -0600 (CST) Received: from SATLEXDAG05.amd.com (10.181.40.11) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 5 Dec 2014 02:48:30 -0600 Received: from odedg-kaveri.amd.com (10.180.168.240) by satlexdag05.amd.com (10.181.40.11) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 5 Dec 2014 03:47:43 -0500 From: Oded Gabbay To: , Subject: [PATCH] amdkfd: Disable support for 32-bit user processes Date: Fri, 5 Dec 2014 10:47:36 +0200 Message-ID: <1417769256-6790-1-git-send-email-oded.gabbay@amd.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(428002)(189002)(199003)(86362001)(53416004)(4396001)(77096005)(50226001)(68736005)(105586002)(33646002)(50466002)(36756003)(106466001)(92566001)(46102003)(89996001)(87936001)(84676001)(31966008)(19580405001)(48376002)(50986999)(99396003)(229853001)(64706001)(21056001)(47776003)(20776003)(101416001)(97736003)(19580395003)(62966003)(107046002)(77156002)(120916001); DIR:OUT; SFP:1102; SCL:1; SRVR:CO1PR02MB207; H:atltwp02.amd.com; FPR:; SPF:None; MLV:sfv; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:CO1PR02MB207; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601002); SRVR:CO1PR02MB207; X-Forefront-PRVS: 04163EF38A Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=Oded.Gabbay@amd.com; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:CO1PR02MB207; X-OriginatorOrg: amd4.onmicrosoft.com Cc: alexander.deucher@amd.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch checks if the process that opens the /dev/kfd device is 32-bit process. If so, it returns -EPERM and prints a warning message in dmesg. This is done to prevent 32-bit user processes from using amdkfd, and hence, HSA features. AMD's HSA userspace stack will also support only 64-bit processes on Linux. Signed-off-by: Oded Gabbay --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index 102cd36..4f7b275 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -102,15 +102,26 @@ struct device *kfd_chardev(void) static int kfd_open(struct inode *inode, struct file *filep) { struct kfd_process *process; + bool is_32bit_user_mode; if (iminor(inode) != 0) return -ENODEV; + is_32bit_user_mode = is_compat_task(); + + if (is_32bit_user_mode == true) { + dev_warn(kfd_device, + "Process %d (32-bit) failed to open /dev/kfd\n" + "32-bit processes are not supported by amdkfd\n", + current->pid); + return -EPERM; + } + process = kfd_create_process(current); if (IS_ERR(process)) return PTR_ERR(process); - process->is_32bit_user_mode = is_compat_task(); + process->is_32bit_user_mode = is_32bit_user_mode; dev_dbg(kfd_device, "process %d opened, compat mode (32 bit) - %d\n", process->pasid, process->is_32bit_user_mode);