From patchwork Thu Nov 3 14:51:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 14925 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp581758wru; Thu, 3 Nov 2022 07:56:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6HT9tpLO4Go/h0G/o5DOOoYfgy8dsFlgen2GT01OHh9FT8P+QncMrg4clpS94yenwA6yrn X-Received: by 2002:a17:906:3b48:b0:7ad:fa67:1daa with SMTP id h8-20020a1709063b4800b007adfa671daamr10826394ejf.653.1667487365449; Thu, 03 Nov 2022 07:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667487365; cv=none; d=google.com; s=arc-20160816; b=N8K8yedSrOlKSqdrc8Q/kGKTbxNM6AFXz3JIPVhmJGzia4KrBokPBKgzfG8zHVZ0d2 XhFKxG48+hIYy2gCu5QX0BL1E2T7n/jkMO1A2XOraZQxM34Ks32GKPzr4rOHZnTv2YNH yIlvP9it4VbwO+HLHBsANkLz5lEK31NZFDitK0jBqkmFkQmL7KYA+IF4LAZDNxqxtd5f f2pKCcU9CqwSzpA88dEd7kQ5Qun8a1HowcmdHD5TTn9JqXvkpk/6yED0unjHKrIvFEPc ZelcTaNqjx11bNwLSQKOrnCW+ke9DUWVVw3aNyK/Lda50ebvV/Yy2ihPDmGfKyTKDsWt KYjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=7l0akenZY8eJcAbXnz3OOqm4unmQOrWF3mk/oUeZ5j4=; b=Qhst4v6A+brjS7MCAC8r0NwrvRR6gL5k6Ok9E3jGLkjdoo7pjj5ge8nrr+dGiLAMYV vj4vMCe856fRSw/Ruijec/QCXNz7dXkT/sbxfkf8VTazc/1DxdQa9skwu2yumCYyRLdT 7TvFgDVJ2GMlCVdBNUF/nWoek1e9lFel6AK08ZlLDkSien1GQz2GQ/s9tuizb567RcLh mtsAdYf9Hnsa9C21Wntcp0ONzhKqhdJH3Pc16gHnd3BoN+1bbsNdXk/5Tm9JV7QdTySi xkx0QaMASm31xhBlM5LTfHc2rFdcqId1MxdXqbU2nUC5ZvwCy8GCGyizkWLoir+18pU6 TyGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=JyRr6wkp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw16-20020a1709066a1000b00780a3097d20si1612010ejc.180.2022.11.03.07.55.41; Thu, 03 Nov 2022 07:56:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=JyRr6wkp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231834AbiKCOwH (ORCPT + 99 others); Thu, 3 Nov 2022 10:52:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231776AbiKCOvr (ORCPT ); Thu, 3 Nov 2022 10:51:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F3C918B30; Thu, 3 Nov 2022 07:51:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 10DE5B828B4; Thu, 3 Nov 2022 14:51:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AC02C43143; Thu, 3 Nov 2022 14:51:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667487103; bh=1ynZM90FVuDLUm6Ak2G09DB3URFnKUrvlsBGn1ucYXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JyRr6wkpdyrB+4wxOYn8KaoaZBO7VBziswzVB1HZ1YrOkxCzbS5gSVYEDEKL0/NM/ tv+O6T4EKN1qyE+TuPm/P3bSTS75P5h5qczWaX//RCbAZqGfFXwhpl2ci3+fVYscM9 MjUcHB8WrhDFP6HvOvgMvUy4LMlX8TDzd+duVGS2fWp0jrY2wlF01O9Bye7eerkqFp WKff862tjqqjsnsVuZlb+8G27tDnTM3V5XjA8V5a+oYeFsYnHvz4wgXN4O4N7sMryA GeQgiIPWXkz4q29z8ZFVGRZxAvIPooFutsGc4Kww5k+VrVbAuMJvIhXTUBVeTPSO1d DEnKH2009KERQ== Received: from mchehab by mail.kernel.org with local (Exim 4.96) (envelope-from ) id 1oqbZE-0076bD-0V; Thu, 03 Nov 2022 14:51:40 +0000 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , =?utf-8?q?Christian_K=C3=B6n?= =?utf-8?q?ig?= , "Daniel Latypov" , "Isabella Basso" , =?utf-8?q?Micha=C5=82_Winiarski?= , =?utf-8?q?T?= =?utf-8?q?homas_Hellstr=C3=B6m?= , Daniel Vetter , David Airlie , Jani Nikula , Joonas Lahtinen , Matt Roper , Matthew Auld , Rodrigo Vivi , Tvrtko Ursulin , dri-devel@lists.freedesktop.org, igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, skhan@linuxfoundation.org Subject: [PATCH RFC v2 8/8] drm/i915: check if current->mm is not NULL Date: Thu, 3 Nov 2022 14:51:38 +0000 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748487231792368699?= X-GMAIL-MSGID: =?utf-8?q?1748487231792368699?= The mmap tests require mm in order to work. Failing to do that will cause a crash: [ 316.820722] BUG: kernel NULL pointer dereference, address: 00000000000000e8 [ 316.822517] #PF: supervisor write access in kernel mode [ 316.823430] #PF: error_code(0x0002) - not-present page [ 316.824390] PGD 0 P4D 0 [ 316.825357] Oops: 0002 [#1] PREEMPT SMP NOPTI [ 316.826350] CPU: 0 PID: 1517 Comm: kunit_try_catch Tainted: G U N 6.1.0-rc2-drm-266703e6f163+ #14 [ 316.827503] Hardware name: Intel Corporation Tiger Lake Client Platform/TigerLake Y LPDDR4x T4 Crb, BIOS TGLSFWI1.R00.3243.A01.2006102133 06/10/2020 [ 316.828633] RIP: 0010:down_write_killable+0x50/0x110 [ 316.829756] Code: 24 10 45 31 c9 31 c9 41 b8 01 00 00 00 31 d2 31 f6 48 89 ef e8 e1 74 4a ff bf 01 00 00 00 e8 87 d6 46 ff 31 c0 ba 01 00 00 00 48 0f b1 13 0f 94 c0 5a 84 c0 74 62 8b 05 49 12 e4 00 85 c0 74 [ 316.830896] RSP: 0018:ffffc90001eabc58 EFLAGS: 00010246 [ 316.832008] RAX: 0000000000000000 RBX: 00000000000000e8 RCX: 0000000000000000 [ 316.833141] RDX: 0000000000000001 RSI: ffffffff81c94fc9 RDI: ffffffff81c94fc9 [ 316.834195] RBP: 0000000000000158 R08: 0000000000000001 R09: 0000000000000000 [ 316.835231] R10: 0000000000000000 R11: ffff8883a13350b8 R12: 0000000000000002 [ 316.836259] R13: 0000000000000001 R14: 0000000000100000 R15: 00000000000000e8 [ 316.837237] FS: 0000000000000000(0000) GS:ffff8883a3800000(0000) knlGS:0000000000000000 [ 316.838214] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 316.839190] CR2: 00000000000000e8 CR3: 0000000002812003 CR4: 0000000000770ef0 [ 316.840147] PKRU: 55555554 [ 316.841099] Call Trace: [ 316.842047] [ 316.842990] ? vm_mmap_pgoff+0x78/0x150 [ 316.843936] vm_mmap_pgoff+0x78/0x150 [ 316.844884] igt_mmap_offset+0x178/0x1b9 [i915] [ 316.846119] __igt_mmap+0xfe/0x680 [i915] Unfortunately, when KUnit module runs, it doesn't create an user context, causing mmap tests to fail. Signed-off-by: Mauro Carvalho Chehab --- To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover. See [PATCH RFC v2 0/8] at: https://lore.kernel.org/all/cover.1667486144.git.mchehab@kernel.org/ drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c index add5ae56cd89..2c5f93e946b5 100644 --- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c +++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c @@ -1845,6 +1845,11 @@ int i915_gem_mman_live_selftests(struct drm_i915_private *i915) SUBTEST(igt_mmap_gpu), }; + if (!current->mm) { + pr_err("Test called without an user context!\n"); + return -EINVAL; + } + return i915_live_subtests(tests, i915); } EXPORT_SYMBOL_NS_GPL(i915_gem_mman_live_selftests, I915_SELFTEST);