From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D32ADC2BD09 for ; Wed, 3 Jul 2024 14:36:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D3A56B0098; Wed, 3 Jul 2024 10:36:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 683BB6B0099; Wed, 3 Jul 2024 10:36:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54C476B009A; Wed, 3 Jul 2024 10:36:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 336166B0098 for ; Wed, 3 Jul 2024 10:36:32 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D55668041D for ; Wed, 3 Jul 2024 14:36:31 +0000 (UTC) X-FDA: 82298692182.11.FA32315 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id F10A020028 for ; Wed, 3 Jul 2024 14:36:29 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=XedO6SOC; spf=pass (imf03.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720017378; a=rsa-sha256; cv=none; b=VOuvSGX3eIHS1toEGhw7BIw72Jp8/gl7lri+OQyznIxiSsH0EHhrdTax8C3WHue50vGla+ zWG6DJhZn6WcobQVt9nAHEka2owScR+fpjkmrVW4q0cYTsF5OOC+gRsHUACDPu5wPMrES4 WRo+M75f4dvoyR3hKh1J0h5+mZRvB8A= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=XedO6SOC; spf=pass (imf03.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720017378; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=F8pQEg7I4gHPDwgOUTTSbC9aT23YfLiVBiIPQTjQDdY=; b=eU8O/9CsWesv2qP4Ovf52n9YoGnWWQ4ETU0s2jfIM9HJJBq5dGNHDuuyUOtl93LSh2npe9 DvcNeBS0ZWr7WIHXebEMCtWrBQu1Doxa0A+fgmZdFOX0o2omF7FdAe9R58HJd4s/KEgSNX ladbVf3lLnekrvDcVu4Gez7lJ8GG594= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BB70662278; Wed, 3 Jul 2024 14:36:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72812C2BD10; Wed, 3 Jul 2024 14:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1720017388; bh=0FRQ/R/L7Gbr+E5NMPB583fDoSDZ+fMcFqkwqezzyfk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XedO6SOC064WlD2AAR0roKkRMad5NWj+aUN3DQmnvW/HYoyZmxgXCAzgtENP6rlhI 85KCzyuwI7Fb/du6Ne9/B2/MTPHqnCOALJxyz3ST1/fVmJDyqFIYNZcs/af/Sk4g6K MI7YjtLkcJMsJPUlPk464hFjVNW3y8eHxn7/GYb0= Date: Wed, 3 Jul 2024 16:36:25 +0200 From: Greg Kroah-Hartman To: Roman Kagan Cc: linux-kernel@vger.kernel.org, Shuah Khan , Dragan Cvetic , Fares Mehanna , Alexander Graf , Derek Kiernan , linux-kselftest@vger.kernel.org, nh-open-source@amazon.com, linux-mm@kvack.org, David Woodhouse , Andrew Morton , Arnd Bergmann Subject: Re: [PATCH RFC 3/3] drivers/misc: add test driver and selftest for proclocal allocator Message-ID: <2024070305-dining-giggly-587b@gregkh> References: <20240621201501.1059948-1-rkagan@amazon.de> <20240621201501.1059948-4-rkagan@amazon.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240621201501.1059948-4-rkagan@amazon.de> X-Stat-Signature: mb7jn8i661bhaaz7f6qbsndu8w8urcsr X-Rspamd-Queue-Id: F10A020028 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1720017389-646107 X-HE-Meta: U2FsdGVkX1/sjZNcHCJwEx4mPbuK1BYC9EB/WihiaIOgb802odIq2Ud74Bw06BcUAeg2tRk0lUOUjZW4hExlNuSiVg/SnQgFp5+qoLBAa4g13GxVtn7yDK5HLfcLDmlkQo1jApngDxC6ogR8bAnwyizwbDbRsBrqOy8+kp/DBhyXUJk6Ld8Wyps7F3m7f8X1jjbHSn8+i5cV+y+tRmppLc0kswZoOjuWyq75LeGfiRH4D5ZJEtN2f/+xPC5aeRLBXtItbpK4YqJrvRwgE1e6TmcT6v1uWvGULCME6RNpfrHpuz4m5eyK13Vdl0T8t6xm7y7VCGKwNfSVqxSExb2j1b41aKnjxMsCmEJfRiVQNUQrezZlZwyApH4lyVtKL09VtmMhpnxb3TBsJMG6n8aKtdvmRjtn5W4OLS1jOcCutnmyNNxDN9HSecQy8coHIRA8KANjgXuRUyaS1P5bvY07jO3DIJIWJ7rdkFT9eHy4pWFLxnbaJ4vN8YkvFdfzOzR7ZxwUa1A504OSd4VJkWyHLsJcilq8sSb4Mgr3DfxV1UXbzniROVBKzXLMXM7OVtVw4nDVoLWDIOooC9q6G3QZwOFtUzCuOwOdlAN3o6p3B3JZqPv9EN6gDugwLNtPzyh2iGFloPc27WKSc7EdrhQtOKFKCWnQssnucO/um75O8dlR1QHCC0vBmPwhz5UtGOGwMjCS74yKGH2T3N2ZSug2mgeHbECGGab/cieZnmBmUQKrtWq9+A5tn6OHYl+T6cLPe2YA0OLxrZkNKsKKekpFU9s3Nqc8cqjE5GGo88lcD61n5BJjb18MJQdgVy4COZSnIQgYmKtOf95i1Ikh7axRo2Fnc1VBB7/UYNe9X6UTJfGpAT8QY8ZVXv+W2ogwH1hrT7xRKB6yOGvx6OI3wXDKEHcL+2pcfzOTkHYP1vgoQpcU7xz5L66ORdS0czfXXfR1pBBIFWemQsgFk3ySpVx QzPvZ7ye Ru1YRnxp/T5lmid9SLtJv1pHjJdr0I+g2vRCZfRQcTuV1ILYeeLnrf1E1wLXQ3S0dmNLRTYsy0L2tbCe7WRz2hgJzVSTaY8m/7jLY6SZIH1giUibiB5V40+JR7Or+hHj4bMFqbWE9LnG6ah0EZqNiTbUxcgUF/nssGSTDSqcgdcxb/OzfLuZfxVSLX9vRh0C2BOLxvBu0m9hJxgflu4+wK7ZyhlgOI/NfLLE7Vv/FOdTkWgzveHveX9Bn4LS4zOBU7noW/yepoQKrk+Y5m2NMO2sJXTb650YWV6U95SB0gbo84a83/hf89sHNHCfn0XrUF5HjXPRgR4iP1n69vfthh2TI5XEnjkYMuStznNRlfBU5E4kgfh8zzymyy+gWJw2pwKsF X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Jun 21, 2024 at 10:15:01PM +0200, Roman Kagan wrote: > Introduce a simple driver for functional and stress testing of proclocal > kernel allocator. The driver exposes a device node /dev/proclocal-test, > which allows userland programs to request creation of proclocal areas > and to obtain their addresses as seen by the kernel, and in addition to > read and write kernel memory at arbitrary address content (simplified > /dev/kmem good enough to access proclocal allocations under selftest > responsibility). > > The driver is not meant for use with production kernels, as it exposes > internal kernel pointers and data. Then you MUST taint the kernel and throw up huge warnings whenever it is loaded, otherwise distros will build this in and end up running it. > > Also add a basic selftest that uses this driver. > > Signed-off-by: Roman Kagan > --- > drivers/misc/Makefile | 1 + > tools/testing/selftests/proclocal/Makefile | 6 + > drivers/misc/proclocal-test.c | 200 ++++++++++++++++++ > .../selftests/proclocal/proclocal-test.c | 150 +++++++++++++ > drivers/misc/Kconfig | 15 ++ > tools/testing/selftests/proclocal/.gitignore | 1 + > 6 files changed, 373 insertions(+) > create mode 100644 tools/testing/selftests/proclocal/Makefile > create mode 100644 drivers/misc/proclocal-test.c > create mode 100644 tools/testing/selftests/proclocal/proclocal-test.c > create mode 100644 tools/testing/selftests/proclocal/.gitignore > > diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile > index 153a3f4837e8..33c244cee92d 100644 > --- a/drivers/misc/Makefile > +++ b/drivers/misc/Makefile > @@ -69,3 +69,4 @@ obj-$(CONFIG_TMR_INJECT) += xilinx_tmr_inject.o > obj-$(CONFIG_TPS6594_ESM) += tps6594-esm.o > obj-$(CONFIG_TPS6594_PFSM) += tps6594-pfsm.o > obj-$(CONFIG_NSM) += nsm.o > +obj-$(CONFIG_PROCLOCAL_TEST) += proclocal-test.o > diff --git a/tools/testing/selftests/proclocal/Makefile b/tools/testing/selftests/proclocal/Makefile > new file mode 100644 > index 000000000000..b93baecee762 > --- /dev/null > +++ b/tools/testing/selftests/proclocal/Makefile > @@ -0,0 +1,6 @@ > +# SPDX-License-Identifier: GPL-2.0 > + > +TEST_GEN_PROGS := proclocal-test > +CFLAGS += -O2 -g -Wall $(KHDR_INCLUDES) > + > +include ../lib.mk > diff --git a/drivers/misc/proclocal-test.c b/drivers/misc/proclocal-test.c > new file mode 100644 > index 000000000000..9b3d0ed9b2f9 > --- /dev/null > +++ b/drivers/misc/proclocal-test.c > @@ -0,0 +1,200 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* Copyright (C) 2024 Amazon.com, Inc. or its affiliates. All rights reserved. > + * Author: Roman Kagan > + * > + * test driver for proclocal memory allocator > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +struct proclocal_test_alloc { > + u64 size; > + u64 ptr; This structure is not defined properly to cross the user/kernel boundry :( > +}; > + > +#define PROCLOCAL_TEST_ALLOC _IOWR('A', 0x10, struct proclocal_test_alloc) ioctl definitions belong in a .h file for userspace to be able to see them. > + > +#define BOUNCE_BUF_SIZE PAGE_SIZE Then why not just use PAGE_SIZE everywhere? Less characters and we all know what that is. Stopped reviewing here, sorry. greg k-h