From nobody Mon Feb 9 00:04:51 2026 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EADC217651 for ; Mon, 17 Feb 2025 10:17:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787470; cv=none; b=qLIQ54lLEEG/5dLBLyC2qdgIJObE5WwGRFxfm/VkmQI2I2hJHQVDY/VoFqg4LBXyI/Wa6j+SBZTNSK9necPnBJDatSWieTLxVYPxCJC7Jqo6mS/0IDY5dfGpCuFKOsiNp6X08DizW9KN0cEnqtpmPv3YGCjKQFUAzBx4E45y68k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787470; c=relaxed/simple; bh=/cVyc1rh86otJZ3wkWGcQ4N27XkUc752xM+g69NmlEo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cWtRuWC+fJnZ330bCeCM87yzzqK2WVyZHLtS130bpUubZ1tV2HdSTzJthd7443LzPRZw47RmEvItAAUFK27NRQpwsOi6nGBTX5lbGXADvLYBKrZZ4geiN/N1VjFS7ALJUIZ0N5GQ8TWxGUASPp8+oAEhuzjKzHge/vuX8Ow+DJE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=zwToEZ5d; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zwToEZ5d" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-abb8d63b447so124198766b.0 for ; Mon, 17 Feb 2025 02:17:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739787467; x=1740392267; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/6BYtQ0vagWpucItzriIw7qjC34OuqzM5CfNcTita1Q=; b=zwToEZ5diBI6TG5Yp7XbbbcR8h7sfZJNrVqOlFEIdGyENZ8PjZXze1+6sJggc62EOr +VPtaoacD1FTJcjXLTiyHjCLUYDKQePfaCWicY2V5fp8RDpkbfjl0HfJlQxLw8BOYxuX w8RBwdAozE7aGJRV7v2aIyP9hMGjjsJtUoGIQfnNCMKvcc2/PzDeEAowEd0+znlUNglJ hQ1FxOnc7YyFsAansc328Do7loPvoCDgdDS+uCz986oKumrg7P+lp6jvyYlAo7KD4fvX s8cZuyYhZr++xg4iRb4qK0UlNJXpUvINFjPT1YuJvN6m6EvN0fXvmgvnBFhbF+ibEghd J1WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739787467; x=1740392267; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/6BYtQ0vagWpucItzriIw7qjC34OuqzM5CfNcTita1Q=; b=CbsRApNJZPUk17QuUVcpJmwYedXgVFU57ROca7mNeQaWTF1QWVnIMmo7oxrRDD3yVW ED/tF89G86FXZd32lpKDKGyjgPYGFP+CyKmRb2fmTqIW2405McI1a4YhRA1SkMG+Ohcu Y4YyTqmcWbhaeQ/AeWdGCunwh93i3PzVJDibPrZxI21A64wORXnB5z/T9tg1ZAas7b7j rA7xHHjUEEdd1+wxJDJeDkw71I55nGv8i7dHS5IUtBQkkmovsCdNs49EMxuxhk4CRe1i n/QBG/8kGhAbHJRS3CvZS71bKsjtiYzyC5+0h+2EACxd4aL4xUgV9N4NFb52e976LeUI o24g== X-Gm-Message-State: AOJu0YzS1CzYyoJ/So+4LEaTuy5c/Zm3B67Ji8qGdwiWy5QbxnFavvjM BLruQGgc++e5Q3IomC5l/V+DJJQ0jP1AGwAzLIebe0kK6GkcmYCkHEQCtQKLnmY= X-Gm-Gg: ASbGncsZzHvgJiMapco20HqCAlo3RRnSOliGGRAN480fcnVa+09p3CRcj7Y29Y6XlF9 BeLyinkmaN94KBaJKdqXQNnr8L+N44Wm1dFtRuFrUt2scb0cXcT88RtgkZLjSwNGz1gfg25i6QX 3OX+RzeSFGbMZoySgiPxCgeNCz72P69paxZTZ+f240d/brEVnhC+n1fMoWTgi2AveDJ8f63knWh eUlZdJ24kOYbOuU9Qp8IZzXkYB3dtITwdbhmdem6qPMEgdtt+ywigWggssMu1Nk3aQ5oYHVvEQh ZIOM6DJok39WoLH7pkWW7wCc X-Google-Smtp-Source: AGHT+IFgDnivD1OBw8RBeqZ1T3wvlR/UtXkBn7pRJ5OfcJBMf9SgRGM/cdk3Igb/07dwRLGbAITBVQ== X-Received: by 2002:a17:907:1c85:b0:abb:6ea6:161 with SMTP id a640c23a62f3a-abb70e4e28cmr925547666b.56.1739787466832; Mon, 17 Feb 2025 02:17:46 -0800 (PST) Received: from eugen-station.. ([82.76.24.202]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb8b1767e8sm308583266b.174.2025.02.17.02.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2025 02:17:46 -0800 (PST) From: Eugen Hristev To: linux-arm-msm@vger.kernel.org, linux-hardening@vger.kernel.org, kees@kernel.org Cc: linux-kernel@vger.kernel.org, johannes@sipsolutions.net, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, andersson@kernel.org, konradybcio@kernel.org, tony.luck@intel.com, gpiccoli@igalia.com, pmladek@suse.com, rostedt@goodmis.org, john.ogness@linutronix.de, senozhatsky@chromium.org, quic_mojha@quicinc.com, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Eugen Hristev Subject: [RFC][PATCH 01/10] pstore/zone: move pstore_device_info into zone header Date: Mon, 17 Feb 2025 12:16:57 +0200 Message-ID: <20250217101706.2104498-2-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250217101706.2104498-1-eugen.hristev@linaro.org> References: <20250217101706.2104498-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Struct pstore_device_info is used in pstore/zone, and it's not really connected to anything related to pstore/blk. To further improve on the pstore zone and allow other types of drivers to connect, it is logical to have this struct into pstore_zone.h file. Signed-off-by: Eugen Hristev --- include/linux/pstore_blk.h | 14 -------------- include/linux/pstore_zone.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/linux/pstore_blk.h b/include/linux/pstore_blk.h index 924ca07aafbd..d0c8fb40c46c 100644 --- a/include/linux/pstore_blk.h +++ b/include/linux/pstore_blk.h @@ -7,20 +7,6 @@ #include #include =20 -/** - * struct pstore_device_info - back-end pstore/blk driver structure. - * - * @flags: Refer to macro starting with PSTORE_FLAGS defined in - * linux/pstore.h. It means what front-ends this device support. - * Zero means all backends for compatible. - * @zone: The struct pstore_zone_info details. - * - */ -struct pstore_device_info { - unsigned int flags; - struct pstore_zone_info zone; -}; - int register_pstore_device(struct pstore_device_info *dev); void unregister_pstore_device(struct pstore_device_info *dev); =20 diff --git a/include/linux/pstore_zone.h b/include/linux/pstore_zone.h index 1e35eaa33e5e..284364234162 100644 --- a/include/linux/pstore_zone.h +++ b/include/linux/pstore_zone.h @@ -54,6 +54,20 @@ struct pstore_zone_info { pstore_zone_write_op panic_write; }; =20 +/** + * struct pstore_device_info - back-end pstore device driver structure. + * + * @flags: Refer to macro starting with PSTORE_FLAGS defined in + * linux/pstore.h. It means what front-ends this device support. + * Zero means all backends for compatible. + * @zone: The struct pstore_zone_info details. + * + */ +struct pstore_device_info { + unsigned int flags; + struct pstore_zone_info zone; +}; + extern int register_pstore_zone(struct pstore_zone_info *info); extern void unregister_pstore_zone(struct pstore_zone_info *info); =20 --=20 2.43.0 From nobody Mon Feb 9 00:04:51 2026 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2540221767B for ; Mon, 17 Feb 2025 10:17:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787472; cv=none; b=Sv7EtnHep3FM8/yIIwd7nd//HaSdJ0uWZMoA7XdXkg5Xv34b5Ep5aInVS/5hy00rIzsIT7dwyDqTFmTF2o40ZiugNZ1e6SEqWeCRtb7JkH0q62p1y3kKw0gEKfeSti8t8sZ9zz94bLnCShPNqGNEnh6W6/Y0xGFhIOZb1ix+FCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787472; c=relaxed/simple; bh=1hkKPUWrxq7K5LZ+JEA021QIrfwfKcgoOdedz+W5Q9Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EtvxsSNFeOZZ22EXfNLFbVSbkFv2YE9YgBAj3HjqhMW+D7zXDysU43jD5tPAAufemNVsrHiKxGSSYdgYAP83ngZf24d/IYMOFnBzn0/iT2Sa8u7umh7R0LHXS/P1dTi67eX81+5p+Da4cRwGclj+aDwFewG1AFR7D/nnKYbRCIk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=OO3VBxZd; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OO3VBxZd" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-abba1b74586so89116266b.2 for ; Mon, 17 Feb 2025 02:17:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739787468; x=1740392268; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UO0IV1Fa2w4jRN2VF1J5DC4vESX9Rcd9+LGQ+k/6XZk=; b=OO3VBxZd2S8Aj8r1yxFIR8d5NhbGf1AJ2aOLJ0kLtZRSLbhB1k99nuC/RsU9mzdfIz UG/xoi5Y/PsG04GKdC85Hs4CtQGEiuhUGl62pEK87rBcZ3BfGK/UX4FWB5FvqC6X4CAM yegjLcNhdxx78BoqFgMiDF1jVQ8GME9UbnbbUiWnaWyMJEQhOD951NbFE8x+E/L9BGJY AI316Ot9PtKkLIdC/pTG/U8tX5CR0lQfirAhevjpiGF66fevZ0bihC4B7ybMGeKsm7xJ DfoAj3kFeWgV+h94BRlhi+jp1lFxkbOCl41ux4MtXnELW9+XTtOkMejD7DPIeHa81s9r ZYLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739787468; x=1740392268; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UO0IV1Fa2w4jRN2VF1J5DC4vESX9Rcd9+LGQ+k/6XZk=; b=RdGlwedTufabmg1Ig7YL5oBLey9HWVIJC3ZN6cyVUzh7ePCoXeSfUYqdLKgmpFpBkL ewg7p/jFGCz4w1bfjZaovkPfurQszmIg8j0yCcTxfczKR3UnE9Ro8TMEaYpxOnkG0R4H r6nI4OzKRWj5EsRks0T0AgpW0MWPv1/6Wp+qD1B3k/dychifzOgO0lC/NAJax7DC5zkU jCFU7bj8wpO87xUMBLEVi1eG37uGApdf1ZcKW4ukbBZHWf3MeE8Yw5LBo63JwkYmzX+N 4DlSDLKN73QgmsRKisibHoKbcmaW7IFABrv7gUZS6LQOIIrgL/FQ9hc7dT0uQT0Ks9wj FLPw== X-Gm-Message-State: AOJu0YyIj3SAR5na7cWIdpyQHOzsbTYGPWkVK5v9rbIe0ypbRkoZS5p4 U7Wzw2vJ9F14UpNQqq1DytCW57KSn/o1f1oZnLPvnqrb4gC4PDSB48UpRNvOvWc= X-Gm-Gg: ASbGnct9cm1KlCwxm2HR+isn0b6TU6Q8JtShFmIDyAV8xJmO0GluwiyPejr979E0UDt KoqZbe6hphzrZLHf3JS5CDztfqUdnmIdMoRhICuyDsCvQ1xSjacVW0WuPO8Jh1gjvlU0QAKc6IO INYvJ/K/Jka+sFmBXc2kulFtSDYRmmDRzc9iJKoA9GozDKUrb4jPC5c9gVOKxbi987yQm/r2Ujh plrQgyeFJZ5r5jHST6se2gAfqjaIXjjoBdT8YMbGW6oj2SxdCKS/26CAuRfJRe01YJ4IGKOCW5h HRyeJvKRCAi+1kzb5lFMcguk X-Google-Smtp-Source: AGHT+IFeqQRmHtufh/hnET9/WDBmQ08tktpUPlNNW2f16K2ts13CoRF9gAnCjQkfdJKdSGt+WA/5Ug== X-Received: by 2002:a17:906:3290:b0:ab7:d179:2496 with SMTP id a640c23a62f3a-abb70a791dcmr775286966b.6.1739787468349; Mon, 17 Feb 2025 02:17:48 -0800 (PST) Received: from eugen-station.. ([82.76.24.202]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb8b1767e8sm308583266b.174.2025.02.17.02.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2025 02:17:48 -0800 (PST) From: Eugen Hristev To: linux-arm-msm@vger.kernel.org, linux-hardening@vger.kernel.org, kees@kernel.org Cc: linux-kernel@vger.kernel.org, johannes@sipsolutions.net, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, andersson@kernel.org, konradybcio@kernel.org, tony.luck@intel.com, gpiccoli@igalia.com, pmladek@suse.com, rostedt@goodmis.org, john.ogness@linutronix.de, senozhatsky@chromium.org, quic_mojha@quicinc.com, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Eugen Hristev Subject: [RFC][PATCH 02/10] pstore/smem: add new pstore/smem type of pstore Date: Mon, 17 Feb 2025 12:16:58 +0200 Message-ID: <20250217101706.2104498-3-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250217101706.2104498-1-eugen.hristev@linaro.org> References: <20250217101706.2104498-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add shared memory type of pstore. Signed-off-by: Eugen Hristev --- fs/pstore/Kconfig | 13 ++++ fs/pstore/Makefile | 3 + fs/pstore/smem.c | 115 ++++++++++++++++++++++++++++++++++++ include/linux/pstore_smem.h | 9 +++ 4 files changed, 140 insertions(+) create mode 100644 fs/pstore/smem.c create mode 100644 include/linux/pstore_smem.h diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig index 3acc38600cd1..84f87edf9b8f 100644 --- a/fs/pstore/Kconfig +++ b/fs/pstore/Kconfig @@ -81,6 +81,19 @@ config PSTORE_RAM =20 For more information, see Documentation/admin-guide/ramoops.rst. =20 +config PSTORE_SMEM + tristate "Log panic/oops to a shared memory buffer" + depends on PSTORE + select PSTORE_ZONE + help + This enables panic and oops messages to be logged to memory + that is shared between different hardware blocks in the system. + This shared memory can be a static ram, a part of dynamic RAM, + a dedicated cache or memory area specific for crash dumps, + or even a memory on an attached device. + + if unsure, say N. + config PSTORE_ZONE tristate depends on PSTORE diff --git a/fs/pstore/Makefile b/fs/pstore/Makefile index c270467aeece..f2a314ca03a0 100644 --- a/fs/pstore/Makefile +++ b/fs/pstore/Makefile @@ -18,3 +18,6 @@ obj-$(CONFIG_PSTORE_ZONE) +=3D pstore_zone.o =20 pstore_blk-objs +=3D blk.o obj-$(CONFIG_PSTORE_BLK) +=3D pstore_blk.o + +pstore_smem-objs +=3D smem.o +obj-$(CONFIG_PSTORE_SMEM) +=3D pstore_smem.o diff --git a/fs/pstore/smem.c b/fs/pstore/smem.c new file mode 100644 index 000000000000..9eedd7df5446 --- /dev/null +++ b/fs/pstore/smem.c @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Implements pstore backend driver for shared memory devices, + * using the pstore/zone API. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * All globals must only be accessed under the pstore_smem_lock + * during the register/unregister functions. + */ +static DEFINE_MUTEX(pstore_smem_lock); +static struct pstore_device_info *pstore_device_info; + +static int __register_pstore_device(struct pstore_device_info *dev) +{ + int ret; + + lockdep_assert_held(&pstore_smem_lock); + + if (!dev) { + pr_err("NULL device info\n"); + return -EINVAL; + } + if (!dev->zone.total_size) { + pr_err("zero sized device\n"); + return -EINVAL; + } + if (!dev->zone.read) { + pr_err("no read handler for device\n"); + return -EINVAL; + } + if (!dev->zone.write) { + pr_err("no write handler for device\n"); + return -EINVAL; + } + + /* someone already registered before */ + if (pstore_device_info) + return -EBUSY; + + /* zero means not limit on which backends to attempt to store. */ + if (!dev->flags) + dev->flags =3D UINT_MAX; + + /* Initialize required zone ownership details. */ + dev->zone.name =3D KBUILD_MODNAME; + dev->zone.owner =3D THIS_MODULE; + + ret =3D register_pstore_zone(&dev->zone); + if (ret =3D=3D 0) + pstore_device_info =3D dev; + + return ret; +} +/** + * register_pstore_smem_device() - register smem device to pstore + * + * @dev: smem device information + * + * Return: + * * 0 - OK + * * Others - some error. + */ +int register_pstore_smem_device(struct pstore_device_info *dev) +{ + int ret; + + mutex_lock(&pstore_smem_lock); + ret =3D __register_pstore_device(dev); + mutex_unlock(&pstore_smem_lock); + + return ret; +} +EXPORT_SYMBOL_GPL(register_pstore_smem_device); + +static void __unregister_pstore_device(struct pstore_device_info *dev) +{ + lockdep_assert_held(&pstore_smem_lock); + if (pstore_device_info && pstore_device_info =3D=3D dev) { + unregister_pstore_zone(&dev->zone); + pstore_device_info =3D NULL; + } +} + +/** + * unregister_pstore_smem_device() - unregister smem device from pstore + * + * @dev: smem device information + */ +void unregister_pstore_smem_device(struct pstore_device_info *dev) +{ + mutex_lock(&pstore_smem_lock); + __unregister_pstore_device(dev); + mutex_unlock(&pstore_smem_lock); +} +EXPORT_SYMBOL_GPL(unregister_pstore_smem_device); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Eugen Hristev "); +MODULE_DESCRIPTION("pstore backend for smem devices"); diff --git a/include/linux/pstore_smem.h b/include/linux/pstore_smem.h new file mode 100644 index 000000000000..f0ad23e117c4 --- /dev/null +++ b/include/linux/pstore_smem.h @@ -0,0 +1,9 @@ +#ifndef PSTORE_SMEM_H +#define PSTORE_SMEM_H + +#include + +int register_pstore_smem_device(struct pstore_device_info *dev); +void unregister_pstore_smem_device(struct pstore_device_info *dev); + +#endif --=20 2.43.0 From nobody Mon Feb 9 00:04:51 2026 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCEF6216394 for ; Mon, 17 Feb 2025 10:17:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787473; cv=none; b=S3VneiU8+XqMKKa+W6l6aZ8q5KRvFG8mHc1Px2nZGe+ZRbRhPWA1qHGq5QMLotJPHiK8SOpHt0oxK5fmLwyj/2cHTP93drt5jYJCSiyud5+5ms+6ixHqxpMdqe2B5K3hm6SuHJjBWcTnUtPcObUtyjFoXPMmp01H0Rt3Z1Aio28= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787473; c=relaxed/simple; bh=eFWO0XMyikPo+vVZcTF2JAqlcgoQWkxVrK0g2v9jJKI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gH8rQd6VgANnSfhq/i+hkrHoWVQVz49skG/RABAaySovGkiBkNtFkcGe6151l8Pjyy+OiRs27pkTq9zvC8yk2vIkhqoEKIiTujC2HwIfY6Aj5d139EHi9YgzBbSlscYGoyxk6NM80E2cj0UO/uen3yFOuaYWHkqhlXpklPEhiAI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=zPwTTUmy; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zPwTTUmy" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-abb8e405640so160924866b.0 for ; Mon, 17 Feb 2025 02:17:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739787470; x=1740392270; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wXzcU5MFpNvV+1Iapr36hDkhqv8Rk3kBwf8g/lXGurs=; b=zPwTTUmyqxl8VMtjBdDo5Z0YJvwXoHjP2sQO66sKway7vNYc9urrz8FNQAlzj/uzx7 Pbp9TmHC85rN1Fk99yTi73gziiFWdU3MykNYvfvIsvRJs286tb7fCHJgPPO7JTJ1/s1B 9L5Zfr04QeGGLYb+p2/NmgrbuXJqEocRQ8NGtCasqnEYnhVg/Y8EdfR821SzYnqz5SgA 7zdTgWnWBsUKj4sQOFApoImt828PARcfnVGbem6mpTi/msqZTRcei0sDndEN8NhOgoXk WOhDW2TF0UjhciJkoBZy5eZq3PGzZZ5Lja+R/AK83o1k6w1+WSR1z5iT+SfZQqCQhCc4 1XZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739787470; x=1740392270; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wXzcU5MFpNvV+1Iapr36hDkhqv8Rk3kBwf8g/lXGurs=; b=Jw2/8eQz1AhKWbTSCvQPi8eRTFwT+54Uvm69+iccC3XKOXmMSjFFJacAcdPKFkq7SU +/vP7gecDq1c8t1xtteufB3Zvy9G6REEu7qGUZd+o4Zx5VfbXTlXGFhsO1tryY1PdlqP e7Nt8uH/7Zs2mzOsW5iRxrLOgsbY0adM/UDPoVIsErBIEASO5Ic2+GAAZA6wDRLf9ZMM RsSDPu/zvWQC1TtW89TZfhPY8YfMQ6aDXTyiNlYJ/Us1ZRy+X5VzfIiNNEPVUqP6q57/ FMSB3dyRG/jHICowwfMQj3/SFCnD/h4XhYcx4MsBT1Pycilsz7vu1wTsTTxckYNpJxeK slkA== X-Gm-Message-State: AOJu0Yx93BEFzFkbD6Fnk9LYJXMltQivl911OP28dbKEu9wB0aygxWYt 18do46vEAw42f895KZvw6AZUqxR0yrcKJ3rMujjrCE7wMTBZn/pzQ4BuCXmDn36XSGMTaxfc3/O tfkY= X-Gm-Gg: ASbGnctF49TW55vdvtZWEQY60DLPt1IFVlqZLCRiBaCwHk2u7x4StoNkTgxrZELTIOo 8WyehJj2Dg78eo1KTDxAYfnz0pAsEV88mhVlWDWsyqmd2UTljjmH61bb7saSfgceRuFMPdtEusF 6zX96ytVjmrigOxbhe1m5PQJYJabimby6d2n1R1h1dXfoyksJ2ZMr/2HtPnliksDzjlREFW0tJ0 Z6cTKIgdk4K8lLdH6RGl6DN6ra1kTkb1Hc84jVyiSkNJ1rgpiD59thoPzWvJG59q4lzGs/Se3W8 2vClFpmPmiX3FPl3SQnOVPhh X-Google-Smtp-Source: AGHT+IFlpcMLdWWAy879FRRX8kAbYx+cTtUPfK71e6uWIwxDjhZr04LaUoJwILHRa7T4Dh47h6Jv7g== X-Received: by 2002:a17:907:d27:b0:aba:5f40:7f2e with SMTP id a640c23a62f3a-abb70d95048mr848206466b.45.1739787470024; Mon, 17 Feb 2025 02:17:50 -0800 (PST) Received: from eugen-station.. ([82.76.24.202]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb8b1767e8sm308583266b.174.2025.02.17.02.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2025 02:17:49 -0800 (PST) From: Eugen Hristev To: linux-arm-msm@vger.kernel.org, linux-hardening@vger.kernel.org, kees@kernel.org Cc: linux-kernel@vger.kernel.org, johannes@sipsolutions.net, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, andersson@kernel.org, konradybcio@kernel.org, tony.luck@intel.com, gpiccoli@igalia.com, pmladek@suse.com, rostedt@goodmis.org, john.ogness@linutronix.de, senozhatsky@chromium.org, quic_mojha@quicinc.com, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Eugen Hristev Subject: [RFC][PATCH 03/10] pstore/zone: introduce directly mapped zones Date: Mon, 17 Feb 2025 12:16:59 +0200 Message-ID: <20250217101706.2104498-4-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250217101706.2104498-1-eugen.hristev@linaro.org> References: <20250217101706.2104498-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Directly mapped zones have a different semantic from usual pstore zones. Such zones use a pointer to data in their buffer struct, instead of keeping the buffer locally. The data pointer and size is then passed to the backend for further use. Having a different semantics, backends supporting only these do not offer read/write ops, and only new register_dmr and unregister_dmr ops. Ofcourse, a backend could support both classic zones and directly mapped. Directly mapped zones have the advantage of not being passed through in the event of a crashed, but rather at registration time. Signed-off-by: Eugen Hristev --- fs/pstore/platform.c | 1 + fs/pstore/smem.c | 6 ++--- fs/pstore/zone.c | 45 ++++++++++++++++++++++++++++--------- include/linux/pstore.h | 4 ++++ include/linux/pstore_zone.h | 3 +++ 5 files changed, 45 insertions(+), 14 deletions(-) diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index f56b066ab80c..e20e60b88727 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -51,6 +51,7 @@ static const char * const pstore_type_names[] =3D { "powerpc-common", "pmsg", "powerpc-opal", + "directly-mapped", }; =20 static int pstore_new_entry; diff --git a/fs/pstore/smem.c b/fs/pstore/smem.c index 9eedd7df5446..684ecc20cae5 100644 --- a/fs/pstore/smem.c +++ b/fs/pstore/smem.c @@ -36,15 +36,15 @@ static int __register_pstore_device(struct pstore_devic= e_info *dev) pr_err("NULL device info\n"); return -EINVAL; } - if (!dev->zone.total_size) { + if (!dev->zone.total_size && !dev->zone.dmapped_cnt) { pr_err("zero sized device\n"); return -EINVAL; } - if (!dev->zone.read) { + if (!dev->zone.read && !dev->zone.dmapped_cnt) { pr_err("no read handler for device\n"); return -EINVAL; } - if (!dev->zone.write) { + if (!dev->zone.write && !dev->zone.dmapped_cnt) { pr_err("no write handler for device\n"); return -EINVAL; } diff --git a/fs/pstore/zone.c b/fs/pstore/zone.c index 5fa2fa2e7aa7..affa4370208c 100644 --- a/fs/pstore/zone.c +++ b/fs/pstore/zone.c @@ -113,6 +113,7 @@ struct psz_context { struct pstore_zone *ppsz; struct pstore_zone *cpsz; struct pstore_zone **fpszs; + struct pstore_zone **dmszs; unsigned int kmsg_max_cnt; unsigned int kmsg_read_cnt; unsigned int kmsg_write_cnt; @@ -120,6 +121,7 @@ struct psz_context { unsigned int console_read_cnt; unsigned int ftrace_max_cnt; unsigned int ftrace_read_cnt; + unsigned int dmapped_max_cnt; /* * These counters should be calculated during recovery. * It records the oops/panic times after crashes rather than boots. @@ -1148,6 +1150,8 @@ static void psz_free_all_zones(struct psz_context *cx= t) psz_free_zone(&cxt->cpsz); if (cxt->fpszs) psz_free_zones(&cxt->fpszs, &cxt->ftrace_max_cnt); + if (cxt->dmszs) + psz_free_zones(&cxt->dmszs, &cxt->dmapped_max_cnt); } =20 static struct pstore_zone *psz_init_zone(enum pstore_type_id type, @@ -1160,9 +1164,9 @@ static struct pstore_zone *psz_init_zone(enum pstore_= type_id type, if (!size) return NULL; =20 - if (*off + size > info->total_size) { - pr_err("no room for %s (0x%zx@0x%llx over 0x%lx)\n", - name, size, *off, info->total_size); + if (*off + size > info->total_size && type !=3D PSTORE_TYPE_DMAPPED) { + pr_err("no room for %s type %d (0x%zx@0x%llx over 0x%lx)\n", + name, type, size, *off, info->total_size); return ERR_PTR(-ENOMEM); } =20 @@ -1170,7 +1174,8 @@ static struct pstore_zone *psz_init_zone(enum pstore_= type_id type, if (!zone) return ERR_PTR(-ENOMEM); =20 - zone->buffer =3D kmalloc(size, GFP_KERNEL); + zone->buffer =3D kmalloc(type =3D=3D PSTORE_TYPE_DMAPPED ? + sizeof(struct psz_buffer) : size, GFP_KERNEL); if (!zone->buffer) { kfree(zone); return ERR_PTR(-ENOMEM); @@ -1179,7 +1184,10 @@ static struct pstore_zone *psz_init_zone(enum pstore= _type_id type, zone->off =3D *off; zone->name =3D name; zone->type =3D type; - zone->buffer_size =3D size - sizeof(struct psz_buffer); + if (zone->type =3D=3D PSTORE_TYPE_DMAPPED) + zone->buffer_size =3D 0; + else + zone->buffer_size =3D size - sizeof(struct psz_buffer); zone->buffer->sig =3D type ^ PSZ_SIG; zone->oldbuf =3D NULL; atomic_set(&zone->dirty, 0); @@ -1188,8 +1196,9 @@ static struct pstore_zone *psz_init_zone(enum pstore_= type_id type, =20 *off +=3D size; =20 - pr_debug("pszone %s: off 0x%llx, %zu header, %zu data\n", zone->name, - zone->off, sizeof(*zone->buffer), zone->buffer_size); + pr_debug("pszone %s: off 0x%llx, %zu header, %zu data %s\n", zone->name, + zone->off, sizeof(*zone->buffer), zone->buffer_size, + zone->type =3D=3D PSTORE_TYPE_DMAPPED ? " dmapped " : ""); return zone; } =20 @@ -1206,7 +1215,7 @@ static struct pstore_zone **psz_init_zones(enum pstor= e_type_id type, if (!total_size || !record_size) return NULL; =20 - if (*off + total_size > info->total_size) { + if (*off + total_size > info->total_size && type !=3D PSTORE_TYPE_DMAPPED= ) { pr_err("no room for zones %s (0x%zx@0x%llx over 0x%lx)\n", name, total_size, *off, info->total_size); return ERR_PTR(-ENOMEM); @@ -1245,6 +1254,15 @@ static int psz_alloc_zones(struct psz_context *cxt) int err; size_t off_size =3D 0; =20 + cxt->dmszs =3D psz_init_zones(PSTORE_TYPE_DMAPPED, &off, + info->dmapped_cnt, + 1, &cxt->dmapped_max_cnt); + if (IS_ERR(cxt->dmszs)) { + err =3D PTR_ERR(cxt->dmszs); + cxt->dmszs =3D NULL; + goto free_out; + } + off_size +=3D info->pmsg_size; cxt->ppsz =3D psz_init_zone(PSTORE_TYPE_PMSG, &off, info->pmsg_size); if (IS_ERR(cxt->ppsz)) { @@ -1302,7 +1320,7 @@ int register_pstore_zone(struct pstore_zone_info *inf= o) int err =3D -EINVAL; struct psz_context *cxt =3D &pstore_zone_cxt; =20 - if (info->total_size < 4096) { + if (info->total_size < 4096 && !info->dmapped_cnt) { pr_warn("total_size must be >=3D 4096\n"); return -EINVAL; } @@ -1312,7 +1330,7 @@ int register_pstore_zone(struct pstore_zone_info *inf= o) } =20 if (!info->kmsg_size && !info->pmsg_size && !info->console_size && - !info->ftrace_size) { + !info->ftrace_size && !info->dmapped_cnt) { pr_warn("at least one record size must be non-zero\n"); return -EINVAL; } @@ -1345,7 +1363,7 @@ int register_pstore_zone(struct pstore_zone_info *inf= o) * if no @read, pstore may mount failed. * if no @write, pstore do not support to remove record file. */ - if (!info->read || !info->write) { + if (!info->dmapped_cnt && (!info->read || !info->write)) { pr_err("no valid general read/write interface\n"); return -EINVAL; } @@ -1365,6 +1383,7 @@ int register_pstore_zone(struct pstore_zone_info *inf= o) pr_debug("\tpmsg size : %ld Bytes\n", info->pmsg_size); pr_debug("\tconsole size : %ld Bytes\n", info->console_size); pr_debug("\tftrace size : %ld Bytes\n", info->ftrace_size); + pr_debug("\tdmapped areas : %ld\n", info->dmapped_cnt); =20 err =3D psz_alloc_zones(cxt); if (err) { @@ -1406,6 +1425,10 @@ int register_pstore_zone(struct pstore_zone_info *in= fo) cxt->pstore.flags |=3D PSTORE_FLAGS_FTRACE; pr_cont(" ftrace"); } + if (info->dmapped_cnt) { + cxt->pstore.flags |=3D PSTORE_FLAGS_DMAPPED; + pr_cont(" dmapped"); + } pr_cont("\n"); =20 err =3D pstore_register(&cxt->pstore); diff --git a/include/linux/pstore.h b/include/linux/pstore.h index fed601053c51..8360d94c96b6 100644 --- a/include/linux/pstore.h +++ b/include/linux/pstore.h @@ -39,6 +39,7 @@ enum pstore_type_id { PSTORE_TYPE_PMSG =3D 7, PSTORE_TYPE_PPC_OPAL =3D 8, =20 + PSTORE_TYPE_DMAPPED =3D 9, /* End of the list */ PSTORE_TYPE_MAX }; @@ -199,6 +200,8 @@ struct pstore_info { int (*write_user)(struct pstore_record *record, const char __user *buf); int (*erase)(struct pstore_record *record); + int (*register_dmr)(struct pstore_record *record); + int (*unregister_dmr)(struct pstore_record *record); }; =20 /* Supported frontends */ @@ -206,6 +209,7 @@ struct pstore_info { #define PSTORE_FLAGS_CONSOLE BIT(1) #define PSTORE_FLAGS_FTRACE BIT(2) #define PSTORE_FLAGS_PMSG BIT(3) +#define PSTORE_FLAGS_DMAPPED BIT(4) =20 extern int pstore_register(struct pstore_info *); extern void pstore_unregister(struct pstore_info *); diff --git a/include/linux/pstore_zone.h b/include/linux/pstore_zone.h index 284364234162..a74d0cc75577 100644 --- a/include/linux/pstore_zone.h +++ b/include/linux/pstore_zone.h @@ -48,10 +48,13 @@ struct pstore_zone_info { unsigned long pmsg_size; unsigned long console_size; unsigned long ftrace_size; + unsigned long dmapped_cnt; pstore_zone_read_op read; pstore_zone_write_op write; pstore_zone_erase_op erase; pstore_zone_write_op panic_write; + int (*register_dmr)(char *, int, void *, size_t); + int (*unregister_dmr)(void *, size_t); }; =20 /** --=20 2.43.0 From nobody Mon Feb 9 00:04:51 2026 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 703F8218584 for ; Mon, 17 Feb 2025 10:17:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787476; cv=none; b=OTsO3IhXEbVdD5CDkQNlT8X5mFRfXPzgha210wEwLM1GIjPXQvgDJQLUnFprQSr+Mcb45OO2ZafoffBRC/6jFjUxCrLN/bISffPYe/Pe1nr3p8MSJHe3HeijT0h7v5UTRq9lTaoGxCAvsUpvdt6SxYN0PsqESXQs2BMahc3J1zo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787476; c=relaxed/simple; bh=qZuC7gqK3WcrD0D+coZGKMDI2mB55tzfLWIMdlAFyjg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Oom1akNfAN1Zt9Ms26NZ/j4ct3/tnPXqEjqcvxBRXfR7xvYyWxUmAKicbVfHkwHNBqZVUPUSQq30M+gWMBAJO4yhLkGS7nqTBOGd0bsEh89APIBNg3AKrvLlYexEvl2Fd/ODi9t42OfWHVjzreYk5e7qV6wY1jmOuQI51LQj9Pw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=qf+kVBpn; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qf+kVBpn" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-38de1a5f039so3987048f8f.2 for ; Mon, 17 Feb 2025 02:17:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739787472; x=1740392272; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QifBQ/xg2RCUDrB4vfDq4gu1LJ6B/77pKMAfIESueUs=; b=qf+kVBpncy34FC7bO2z9mojDXe9X2yIqPsq6y76Q6r26W8QXO9H8rhGDTTuNDZbrbB /aaEvTV2uznjRgon9i0sGXZ2ttSgXWO/3XRKNVFY0UxqYgpIbC7SEqYFJwBbFmZ02yb/ sTV/CyVcHAN1PlMfXQz6Hde2ieMhan2p428sE4LMGiudGAiFuI3/dz7XMMNxxHXsWpAL 0kGu0XEKlUOm0bu19yNYc7RLyB3BToZsKVe2897M4uZm5q567NaxUGXlMh0hpyl60QQp XnA1VKUlitlYVluh8UHZV8CCpvpTjTNoFRcfL47xM8phYHgocNZpDMq/2JsAhzA9G64H QxfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739787472; x=1740392272; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QifBQ/xg2RCUDrB4vfDq4gu1LJ6B/77pKMAfIESueUs=; b=pOp1oVDfSYyBa/lxnVp+OXNHkbuKPBOw9zZ2qz/NJOe4ryXB1wWl/JYl/Dn8VXqS8Y xAXTf2XGzCDqeUzSMIRjRaH7ENMCiB3AEm9Vl12lWLcCrN8IM3qtQWJM8k60E8QOlgzx 4C1jwg79HqsEjNQfUVeqyMt1gBzaOL5bthCl/V5kH31lcKvKjIidei6OGbz85ZqYPI/+ 1Gtk1tD/vFi0yrC/FJee/ms16HHhsf8KPRYi7ST6p7y/5Ic1Hw7IVt3AVMlTsz7aS0Hl QWQm+SzjmItxHwFZVstHEtM6dzjZmrGmlcCA8S417t/3WlxoqapP1tGBqvdbngfTL44r rYmg== X-Gm-Message-State: AOJu0YxbA5CtjvlSKx/zKcg+3UtD3DdZGIeDm4SZatNYx98TwxNqI+cF iR3RvCxQ2ux7k/Asjk6iVgfyh+k3BkYB+zEK4U0k0kttgg73iTY2fPaTNmMRMnM= X-Gm-Gg: ASbGnct/MUYy7u4pZaChha0LI8srII9DCxl+YOAaGBXTi8O7xptUUsWjP1HqZ+omdDi bJpTdqBMPQnPYDl+IGsw+uFiC7Ea4bYm53/vgQPXoIjD5VI4iPVlBSA8khwwV0pD3n2mnF1LKbG x2phrAdgEbEbS+YWV2A+t6Dc8p9aNDGYnN4fvod2l/geEjZWIyqHVuXCaOL2uvA2Y/mZQVipEGp tkTebqTlqRtbLrjbYYuV6YaYig5rl54/DSWdAdNPlsNMmIDCH/XI7PBtUQ1iSqzJ9rWkY113xGQ hkzNK+3uwmGov/uopbPYnaip X-Google-Smtp-Source: AGHT+IHXaznwSyo3YbfYL/R4+3M72WRvyCNEfigOhBxj8g1XzyEDxhWvwflhOeb8uHLrPz5EryyeQA== X-Received: by 2002:a5d:5f4a:0:b0:38f:4244:68cb with SMTP id ffacd0b85a97d-38f42446bfbmr3184326f8f.12.1739787471737; Mon, 17 Feb 2025 02:17:51 -0800 (PST) Received: from eugen-station.. ([82.76.24.202]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb8b1767e8sm308583266b.174.2025.02.17.02.17.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2025 02:17:51 -0800 (PST) From: Eugen Hristev To: linux-arm-msm@vger.kernel.org, linux-hardening@vger.kernel.org, kees@kernel.org Cc: linux-kernel@vger.kernel.org, johannes@sipsolutions.net, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, andersson@kernel.org, konradybcio@kernel.org, tony.luck@intel.com, gpiccoli@igalia.com, pmladek@suse.com, rostedt@goodmis.org, john.ogness@linutronix.de, senozhatsky@chromium.org, quic_mojha@quicinc.com, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Eugen Hristev Subject: [RFC][PATCH 04/10] qcom: smem: add pstore smem backend Date: Mon, 17 Feb 2025 12:17:00 +0200 Message-ID: <20250217101706.2104498-5-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250217101706.2104498-1-eugen.hristev@linaro.org> References: <20250217101706.2104498-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for pstore smem backend in the qcom smem driver. This backend resorts to minidump regions behind the scenes. Co-developed-by: Mukesh Ojha Signed-off-by: Eugen Hristev --- drivers/soc/qcom/Kconfig | 9 + drivers/soc/qcom/Makefile | 6 +- drivers/soc/qcom/smem_md.c | 306 +++++++++++++++++++++++++++++++++ drivers/soc/qcom/smem_pstore.c | 112 ++++++++++++ include/linux/soc/qcom/smem.h | 43 +++++ 5 files changed, 474 insertions(+), 2 deletions(-) create mode 100644 drivers/soc/qcom/smem_md.c create mode 100644 drivers/soc/qcom/smem_pstore.c diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 58e63cf0036b..e1c71f713c05 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -180,6 +180,15 @@ config QCOM_SMEM The driver provides an interface to items in a heap shared among all processors in a Qualcomm platform. =20 +config QCOM_SMEM_PSTORE + bool "Qualcomm Shared Memory(SMEM) Pstore backend" + depends on QCOM_SMEM + select PSTORE + select PSTORE_SMEM + help + Say y here to enable the shared memory driver to register itself + as a pstore backend. + config QCOM_SMD_RPM tristate "Qualcomm Resource Power Manager (RPM) over SMD" depends on ARCH_QCOM || COMPILE_TEST diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index acbca2ab5cc2..304b031ed70e 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -23,8 +23,10 @@ obj-$(CONFIG_QCOM_RPMH) +=3D qcom_rpmh.o qcom_rpmh-y +=3D rpmh-rsc.o qcom_rpmh-y +=3D rpmh.o obj-$(CONFIG_QCOM_SMD_RPM) +=3D rpm-proc.o smd-rpm.o -obj-$(CONFIG_QCOM_SMEM) +=3D smem.o -obj-$(CONFIG_QCOM_SMEM_STATE) +=3D smem_state.o +obj-$(CONFIG_QCOM_SMEM) +=3D qcom_smem.o +qcom_smem-y +=3D smem.o +qcom_smem-$(CONFIG_QCOM_SMEM_PSTORE) +=3D smem_pstore.o smem_md.o +obj-$(CONFIG_QCOM_SMEM_STATE) +=3D smem_state.o CFLAGS_smp2p.o :=3D -I$(src) obj-$(CONFIG_QCOM_SMP2P) +=3D smp2p.o obj-$(CONFIG_QCOM_SMSM) +=3D smsm.o diff --git a/drivers/soc/qcom/smem_md.c b/drivers/soc/qcom/smem_md.c new file mode 100644 index 000000000000..2b665ecc5695 --- /dev/null +++ b/drivers/soc/qcom/smem_md.c @@ -0,0 +1,306 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_NUM_ENTRIES 201 +#define MAX_STRTBL_SIZE (MAX_NUM_ENTRIES * MAX_REGION_NAME_LENGTH) + +#define MAX_NUM_OF_SS 10 +#define MAX_REGION_NAME_LENGTH 16 +#define SBL_MINIDUMP_SMEM_ID 602 +#define MINIDUMP_REGION_VALID ('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' <= < 0) +#define MINIDUMP_SS_ENCR_DONE ('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' <= < 0) +#define MINIDUMP_SS_ENABLED ('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << = 0) +#define MINIDUMP_REGION_INVALID ('I' << 24 | 'N' << 16 | 'V' << 8 | 'A'= << 0) +#define MINIDUMP_REGION_INIT ('I' << 24 | 'N' << 16 | 'I' << 8 | 'T' <<= 0) +#define MINIDUMP_REGION_NOINIT 0 + +#define MINIDUMP_SS_ENCR_REQ (0 << 24 | 'Y' << 16 | 'E' << 8 | 'S' << 0) +#define MINIDUMP_SS_ENCR_NOTREQ (0 << 24 | 0 << 16 | 'N' << 8 | 'R' << = 0) +#define MINIDUMP_SS_ENCR_START ('S' << 24 | 'T' << 16 | 'R' << 8 | 'T' = << 0) + +#define MINIDUMP_APSS_DESC 0 + +/** + * struct minidump - Minidump driver data information + * @apss_data: APSS driver data + * @md_lock: Lock to protect access to APSS minidump table + */ +struct minidump { + struct device *dev; + struct minidump_ss_data *apss_data; + struct mutex md_lock; +}; + +/** + * struct minidump_region - Minidump region + * @name : Name of the region to be dumped + * @seq_num: : Use to differentiate regions with same name. + * @valid : This entry to be dumped (if set to 1) + * @address : Physical address of region to be dumped + * @size : Size of the region + */ +struct minidump_region { + char name[MAX_REGION_NAME_LENGTH]; + __le32 seq_num; + __le32 valid; + __le64 address; + __le64 size; +}; + +/** + * struct minidump_subsystem - Subsystem's SMEM Table of content + * @status : Subsystem toc init status + * @enabled : if set to 1, this region would be copied during coredump + * @encryption_status: Encryption status for this subsystem + * @encryption_required : Decides to encrypt the subsystem regions or not + * @region_count : Number of regions added in this subsystem toc + * @regions_baseptr : regions base pointer of the subsystem + */ +struct minidump_subsystem { + __le32 status; + __le32 enabled; + __le32 encryption_status; + __le32 encryption_required; + __le32 region_count; + __le64 regions_baseptr; +}; + +/** + * struct minidump_global_toc - Global Table of Content + * @status : Global Minidump init status + * @md_revision : Minidump revision + * @enabled : Minidump enable status + * @subsystems : Array of subsystems toc + */ +struct minidump_global_toc { + __le32 status; + __le32 md_revision; + __le32 enabled; + struct minidump_subsystem subsystems[MAX_NUM_OF_SS]; +}; +/** + * struct minidump_ss_data - Minidump subsystem private data + * @md_ss_toc: Application Subsystem TOC pointer + * @md_regions: Application Subsystem region base pointer + */ +struct minidump_ss_data { + struct minidump_subsystem *md_ss_toc; + struct minidump_region *md_regions; +}; + +static struct minidump *md; + +static void qcom_md_add_region(const struct qcom_minidump_region *region) +{ + struct minidump_subsystem *mdss_toc =3D md->apss_data->md_ss_toc; + struct minidump_region *mdr; + unsigned int region_cnt; + + region_cnt =3D le32_to_cpu(mdss_toc->region_count); + mdr =3D &md->apss_data->md_regions[region_cnt]; + strscpy(mdr->name, region->name, sizeof(mdr->name)); + mdr->address =3D cpu_to_le64(region->phys_addr); + mdr->size =3D cpu_to_le64(region->size); + mdr->valid =3D cpu_to_le32(MINIDUMP_REGION_VALID); + region_cnt++; + mdss_toc->region_count =3D cpu_to_le32(region_cnt); +} + +static int qcom_md_get_region_index(struct minidump_ss_data *mdss_data, + const struct qcom_minidump_region *region) +{ + struct minidump_subsystem *mdss_toc =3D mdss_data->md_ss_toc; + struct minidump_region *mdr; + unsigned int i; + unsigned int count; + + count =3D le32_to_cpu(mdss_toc->region_count); + for (i =3D 0; i < count; i++) { + mdr =3D &mdss_data->md_regions[i]; + if (!strcmp(mdr->name, region->name)) + return i; + } + + return -ENOENT; +} + +static int qcom_md_region_unregister(const struct qcom_minidump_region *re= gion) +{ + struct minidump_ss_data *mdss_data =3D md->apss_data; + struct minidump_subsystem *mdss_toc =3D mdss_data->md_ss_toc; + struct minidump_region *mdr; + unsigned int region_cnt; + unsigned int idx; + int ret; + + ret =3D qcom_md_get_region_index(mdss_data, region); + if (ret < 0) { + dev_err(md->dev, "%s region is not present\n", region->name); + return ret; + } + + idx =3D ret; + mdr =3D &mdss_data->md_regions[0]; + region_cnt =3D le32_to_cpu(mdss_toc->region_count); + /* + * Left shift all the regions exist after this removed region + * index by 1 to fill the gap and zero out the last region + * present at the end. + */ + memmove(&mdr[idx], &mdr[idx + 1], (region_cnt - idx - 1) * sizeof(*mdr)); + memset(&mdr[region_cnt - 1], 0, sizeof(*mdr)); + region_cnt--; + mdss_toc->region_count =3D cpu_to_le32(region_cnt); + + return 0; +} + +static int qcom_md_region_register(const struct qcom_minidump_region *regi= on) +{ + struct minidump_ss_data *mdss_data =3D md->apss_data; + struct minidump_subsystem *mdss_toc =3D mdss_data->md_ss_toc; + unsigned int num_region; + int ret; + + ret =3D qcom_md_get_region_index(mdss_data, region); + if (ret >=3D 0) { + dev_info(md->dev, "%s region is already registered\n", region->name); + return -EEXIST; + } + + /* Check if there is a room for a new entry */ + num_region =3D le32_to_cpu(mdss_toc->region_count); + if (num_region >=3D MAX_NUM_ENTRIES) { + dev_err(md->dev, "maximum region limit %u reached\n", num_region); + return -ENOSPC; + } + + qcom_md_add_region(region); + + return 0; +} + +static bool qcom_minidump_valid_region(const struct qcom_minidump_region *= region) +{ + return region && + strnlen(region->name, MINIDUMP_MAX_NAME_LENGTH) < MINIDUMP_MAX_NAME_LENG= TH && + region->virt_addr && + region->size && + IS_ALIGNED(region->size, 4); +} + +/** + * qcom_minidump_region_register() - Register region in APSS Minidump tabl= e. + * @region: minidump region. + * + * Return: On success, it returns 0 and negative error value on failure. + */ +int qcom_minidump_region_register(const struct qcom_minidump_region *regio= n) +{ + int ret; + + if (!qcom_minidump_valid_region(region)) + return -EINVAL; + + mutex_lock(&md->md_lock); + ret =3D qcom_md_region_register(region); + + mutex_unlock(&md->md_lock); + return ret; +} + +/** + * qcom_minidump_region_unregister() - Unregister region from APSS Minidum= p table. + * @region: minidump region. + * + * Return: On success, it returns 0 and negative error value on failure. + */ +int qcom_minidump_region_unregister(const struct qcom_minidump_region *reg= ion) +{ + int ret; + + if (!qcom_minidump_valid_region(region)) + return -EINVAL; + + mutex_lock(&md->md_lock); + ret =3D qcom_md_region_unregister(region); + + mutex_unlock(&md->md_lock); + return ret; +} + + +static int qcom_apss_md_table_init(struct minidump_subsystem *mdss_toc) +{ + struct minidump_ss_data *mdss_data; + + mdss_data =3D devm_kzalloc(md->dev, sizeof(*mdss_data), GFP_KERNEL); + if (!mdss_data) + return -ENOMEM; + + mdss_data->md_ss_toc =3D mdss_toc; + mdss_data->md_regions =3D devm_kcalloc(md->dev, MAX_NUM_ENTRIES, + sizeof(*mdss_data->md_regions), + GFP_KERNEL); + if (!mdss_data->md_regions) + return -ENOMEM; + + mdss_toc =3D mdss_data->md_ss_toc; + mdss_toc->regions_baseptr =3D cpu_to_le64(virt_to_phys(mdss_data->md_regi= ons)); + mdss_toc->enabled =3D cpu_to_le32(MINIDUMP_SS_ENABLED); + mdss_toc->status =3D cpu_to_le32(1); + mdss_toc->region_count =3D cpu_to_le32(0); + + /* Tell bootloader not to encrypt the regions of this subsystem */ + mdss_toc->encryption_status =3D cpu_to_le32(MINIDUMP_SS_ENCR_DONE); + mdss_toc->encryption_required =3D cpu_to_le32(MINIDUMP_SS_ENCR_NOTREQ); + + md->apss_data =3D mdss_data; + + return 0; +} + +int qcom_smem_md_init(struct device *dev) +{ + struct minidump_global_toc *mdgtoc; + size_t size; + int ret; + + md =3D devm_kzalloc(dev, sizeof(*md), GFP_KERNEL); + + md->dev =3D dev; + + mdgtoc =3D qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, &size); + if (IS_ERR(mdgtoc)) { + ret =3D PTR_ERR(mdgtoc); + dev_err(md->dev, "Couldn't find minidump smem item %d\n", ret); + } + + if (size < sizeof(*mdgtoc) || !mdgtoc->status) { + ret =3D -EINVAL; + dev_err(md->dev, "minidump table is not initialized %d\n", ret); + } + + mutex_init(&md->md_lock); + + ret =3D qcom_apss_md_table_init(&mdgtoc->subsystems[MINIDUMP_APSS_DESC]); + if (ret) + dev_err(md->dev, "apss minidump initialization failed %d\n", ret); + return ret; +} diff --git a/drivers/soc/qcom/smem_pstore.c b/drivers/soc/qcom/smem_pstore.c new file mode 100644 index 000000000000..a322a320e435 --- /dev/null +++ b/drivers/soc/qcom/smem_pstore.c @@ -0,0 +1,112 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static LIST_HEAD(apss_md_rlist); +struct md_region_list { + struct qcom_minidump_region md_region; + struct list_head list; +}; + +static struct qcom_smem_pstore_context { + struct pstore_device_info dev; +} oops_ctx; + +static int register_smem_region(const char *name, int id, void *vaddr, + phys_addr_t paddr, size_t size) +{ + struct qcom_minidump_region *md_region; + int ret; + + struct md_region_list *mdr_list =3D + kzalloc(sizeof(*mdr_list), GFP_KERNEL); + if (!mdr_list) + return -ENOMEM; + md_region =3D &mdr_list->md_region; + + scnprintf(md_region->name, sizeof(md_region->name), "K%d%.8s", id, name); + md_region->virt_addr =3D vaddr; + md_region->phys_addr =3D paddr; + md_region->size =3D size; + ret =3D qcom_minidump_region_register(md_region); + if (ret < 0) { + pr_err("failed to register region in minidump: err: %d\n", ret); + return ret; + } + + list_add(&mdr_list->list, &apss_md_rlist); + return 0; +} + +static int unregister_smem_region(void *vaddr, + phys_addr_t paddr, size_t size) +{ + int ret =3D -ENOENT; + struct md_region_list *mdr_list; + struct md_region_list *tmp; + + list_for_each_entry_safe(mdr_list, tmp, &apss_md_rlist, list) { + struct qcom_minidump_region *region; + + region =3D &mdr_list->md_region; + if (region->virt_addr =3D=3D vaddr) { + ret =3D qcom_minidump_region_unregister(region); + list_del(&mdr_list->list); + goto unregister_smem_region_exit; + } + } + +unregister_smem_region_exit: + pr_err("failed to unregister region in minidump: err: %d\n", ret); + + return ret; +} + +static int qcom_smem_register_dmr(char *name, int id, void *area, size_t s= ize) +{ + return register_smem_region(name, id, area, virt_to_phys(area), size); +} + +static int qcom_smem_unregister_dmr(void *area, size_t size) +{ + return unregister_smem_region(area, virt_to_phys(area), size); +} + +int qcom_register_pstore_smem(struct device *dev) +{ + int ret; + + struct qcom_smem_pstore_context *ctx =3D &oops_ctx; + + ctx->dev.flags =3D PSTORE_FLAGS_DMAPPED; + ctx->dev.zone.register_dmr =3D qcom_smem_register_dmr; + ctx->dev.zone.unregister_dmr =3D qcom_smem_unregister_dmr; + ctx->dev.zone.dmapped_cnt =3D 2; + + ret =3D register_pstore_smem_device(&ctx->dev); + if (ret) + dev_warn(dev, "Could not register pstore smem device."); + + return 0; +} + +void qcom_unregister_pstore_smem(void) +{ + struct qcom_smem_pstore_context *ctx =3D &oops_ctx; + + unregister_pstore_smem_device(&ctx->dev); +} diff --git a/include/linux/soc/qcom/smem.h b/include/linux/soc/qcom/smem.h index f946e3beca21..376822f13a4f 100644 --- a/include/linux/soc/qcom/smem.h +++ b/include/linux/soc/qcom/smem.h @@ -17,4 +17,47 @@ int qcom_smem_get_feature_code(u32 *code); =20 int qcom_smem_bust_hwspin_lock_by_host(unsigned int host); =20 +#ifdef CONFIG_QCOM_SMEM_PSTORE +int qcom_register_pstore_smem(struct device *dev); +void qcom_unregister_pstore_smem(void); + +#define MINIDUMP_MAX_NAME_LENGTH 12 + +/** + * struct qcom_minidump_region - Minidump region information + * + * @name: Minidump region name + * @virt_addr: Virtual address of the entry. + * @phys_addr: Physical address of the entry to dump. + * @size: Number of bytes to dump from @address location, + * and it should be 4 byte aligned. + */ +struct qcom_minidump_region { + char name[MINIDUMP_MAX_NAME_LENGTH]; + void *virt_addr; + phys_addr_t phys_addr; + size_t size; +}; + +int qcom_minidump_region_unregister(const struct qcom_minidump_region *reg= ion); +int qcom_minidump_region_register(const struct qcom_minidump_region *regio= n); + +int qcom_smem_md_init(struct device *dev); + +#else + +static inline int qcom_register_pstore_smem(struct device *dev) +{ + return 0; +} + +static inline void qcom_unregister_pstore_smem(void) +{ +} + +static inline int qcom_smem_md_init(struct device *dev) +{ + return 0; +} +#endif #endif --=20 2.43.0 From nobody Mon Feb 9 00:04:51 2026 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F3342185BD for ; Mon, 17 Feb 2025 10:17:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787477; cv=none; b=aKswjHjBvgmQ/+8yHIkg3ZmyLOAoXboAF/lZDFAZWJ21BZNQbDL1CPk84Hb/O2U1G5WtlQIVTDraBoo++k9J0Z6YtTpO64IpLpZ2YdNUOReYjRXcubL9PXMY5bR/VfIxKxxReK1zYq4JYAGaRKuTA0UXlbuGrG4pLfsWggzuvCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787477; c=relaxed/simple; bh=u5QzLaMGCFkT6QzP4xgn658e+DtF0u9SlOsNS3Z0kwo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=vFKKikvs9OaSV+9MiJgWvc7YCHQn+z9JXa2nHeBlku48J0yGXTQ2HhhvS3nDLpbLeVYK46p2puWosjVgtQ+jIJzPukY/PgQUvEExiaUW7liC4cYpFsrnI0eCJhLgTFWCkf60s+0X79iBis8PMOK6MCbIsiaRoaBOA2oGkN/sv6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=j2d+EPkL; arc=none smtp.client-ip=209.85.208.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="j2d+EPkL" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-5deb956aa5eso5952911a12.2 for ; Mon, 17 Feb 2025 02:17:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739787473; x=1740392273; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o2yIlVyyOPbQ4NJXMaimxxzGIHYKCdR1oZZmLPUjNQg=; b=j2d+EPkLrDxgowwfi3qhRIjWh3BxHHmKPmoHbK4IV0P+8SGyo9EQQIWVd48uMfhqS2 f7Kz649HjUrXieGFnC479UXFrUu+YnIyAMN19eow9Jt/CWSOaDI5q7QgaypOuGFvakVj IFUM8iH1DOXSw7fnVuEb3SLDWRIwpqdC8Q6DxK8YhJlXYqUredVfSnlAbNIHAxT6zE9/ dxoFpS41YZoz/wQvNEJ0+O3/zoHPLvDLvAkVLtp3vsj4KlnJK5Hb6yH8t7BTRSbJqtss srGGj2DXfBDjZU+Jq9/y3ESE3izbGb6LWueJAgyQz481kIm/3rXeciXfjbcIbLNLtVdm 7Ygw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739787473; x=1740392273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o2yIlVyyOPbQ4NJXMaimxxzGIHYKCdR1oZZmLPUjNQg=; b=L1mRpri6IXm64AI9yfMMgh+8Jj2cDfLo7cojoyXQWKZyrZ6az09KL+JNR/du92zl1N /6An2q/INtIg5Gqqbby83Y9C1/HiRz2DikO4l7Bgg9ToyIFr87tP/J3lrrJpNeI5AiTR LJaOiAYTCG82SUu//YBH726UGV/iR29M0VPsZpAJmCyxYpsbQC6w3Nu2HOi5Eno5bBoX jrbPIIAWncSREpV2Ux/aTJ9cDkMXgXxVZtDPqvZSBkrC6zjvlqqeeq2L0BQbKlYuJA/s QBXK/1ltOC+oL0tUaGjTin6aYUGUk35P/FBU6HHsegC5pJt5JdENeuhRC0/i8updxXPC yxKg== X-Gm-Message-State: AOJu0YzuIE8vjAFcFpEseYxmlCziyeI90K4aFgqUyPRsYhVQeUPKX8CW kJDTJgPCIxgR8ZykOQX3oKVjTqFINqUG00SzFoie9lar5TFBSjz3W1Nivh086xbnjA7sbbXD+eV mzzc= X-Gm-Gg: ASbGncujflI9h30WWnlpR/dqnC/2NPr1aJvMJNh8CGljNKvhqfx8bV4wfiQerDR9+Ab DH+EXEaeaBNkBwuV678TwZWbC1SSHAFHykCb2nEVrdvfvMWZTDxFI5LDQPRue+pq25HuFgkByFW u8cDCRnUxv3S7i+lJSZUJt+0sRj7Nm9rs65ZL9qjU/J8cjq5jMAwkDwFff9V7b7t2XCp3lw7WfX F6SUVm6h5P7rc6K6ENvoGFe5xEYvODmDL1EsI+w4h1AkCPWgXB+GsapjljQWJoq+kajBCZQ0le3 cSYDL8ImHxl6E3ZQvEC/kO7O X-Google-Smtp-Source: AGHT+IGpx0/whONuJWGo4HwkqVqYsCJmEUhrUJNrzL9FCk0mF7dow3SMs9U25x2XZBwWQZmzKpeEtw== X-Received: by 2002:a05:6402:5107:b0:5dc:ea7e:8c56 with SMTP id 4fb4d7f45d1cf-5e036139d68mr21109346a12.22.1739787473355; Mon, 17 Feb 2025 02:17:53 -0800 (PST) Received: from eugen-station.. ([82.76.24.202]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb8b1767e8sm308583266b.174.2025.02.17.02.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2025 02:17:53 -0800 (PST) From: Eugen Hristev To: linux-arm-msm@vger.kernel.org, linux-hardening@vger.kernel.org, kees@kernel.org Cc: linux-kernel@vger.kernel.org, johannes@sipsolutions.net, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, andersson@kernel.org, konradybcio@kernel.org, tony.luck@intel.com, gpiccoli@igalia.com, pmladek@suse.com, rostedt@goodmis.org, john.ogness@linutronix.de, senozhatsky@chromium.org, quic_mojha@quicinc.com, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Eugen Hristev Subject: [RFC][PATCH 05/10] pstore: implement core area registration Date: Mon, 17 Feb 2025 12:17:01 +0200 Message-ID: <20250217101706.2104498-6-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250217101706.2104498-1-eugen.hristev@linaro.org> References: <20250217101706.2104498-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Implement core area registration mechanism. Implement directly mapped zone corespoding to core areas. Signed-off-by: Eugen Hristev --- fs/pstore/platform.c | 67 ++++++++++++++++++++++++++++++++++++ fs/pstore/zone.c | 77 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pstore.h | 16 +++++++++ 3 files changed, 160 insertions(+) diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index e20e60b88727..32448d9dd316 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -68,6 +68,7 @@ static DECLARE_WORK(pstore_work, pstore_dowork); * the filesystem mount/unmount routines. */ static DEFINE_MUTEX(psinfo_lock); +static DEFINE_MUTEX(ps_dmr_lock); struct pstore_info *psinfo; =20 static char *backend; @@ -99,6 +100,12 @@ MODULE_PARM_DESC(kmsg_bytes, "amount of kernel log to s= napshot (in bytes)"); =20 static void *compress_workspace; =20 +static LIST_HEAD(rec_list); +struct rec_list_t { + struct pstore_record rec; + struct list_head list; +}; + /* * Compression is only used for dmesg output, which consists of low-entropy * ASCII text, and so we can assume worst-case 60%. @@ -271,6 +278,66 @@ void pstore_record_init(struct pstore_record *record, record->time =3D ns_to_timespec64(ktime_get_real_fast_ns()); } =20 +int pstore_register_core_area(const char *handle, void *area, size_t size) +{ + struct rec_list_t *rec_element =3D kzalloc(sizeof (*rec_element), GFP_KER= NEL); + struct pstore_record *record =3D &rec_element->rec; + int ret; + + if (!psinfo || !psinfo->register_dmr) { + pr_err("No pstore available ! Bailing out.\n"); + return -EAGAIN; + } + + pstore_record_init(record, psinfo); + record->type =3D PSTORE_TYPE_DMAPPED; + record->buf =3D area; + record->size =3D size; + + if (handle) { + record->priv =3D kmalloc(8, GFP_KERNEL); + strncpy(record->priv, handle, 8); + } + + mutex_lock(&ps_dmr_lock); + + ret =3D psinfo->register_dmr(record); + if (!ret) + list_add(&rec_element->list, &rec_list); + + mutex_unlock(&ps_dmr_lock); + return ret; +} +EXPORT_SYMBOL_GPL(pstore_register_core_area); + +int pstore_unregister_core_area(const char *handle, void *area, size_t siz= e) +{ + struct rec_list_t *rec_element, *tmp; + int ret; + + if (!psinfo || !psinfo->unregister_dmr) + return -EAGAIN; + + mutex_lock(&ps_dmr_lock); + list_for_each_entry_safe(rec_element, tmp, &rec_list, list) { + struct pstore_record *record; + + record =3D &rec_element->rec; + + if (record->buf =3D=3D area) { + ret =3D psinfo->unregister_dmr(record); + list_del(&rec_element->list); + mutex_unlock(&ps_dmr_lock); + return 0; + } + } + + mutex_unlock(&ps_dmr_lock); + return 0; + +} +EXPORT_SYMBOL_GPL(pstore_unregister_core_area); + /* * callback from kmsg_dump. Save as much as we can (up to kmsg_bytes) from= the * end of the buffer. diff --git a/fs/pstore/zone.c b/fs/pstore/zone.c index affa4370208c..f9e2dc4252ea 100644 --- a/fs/pstore/zone.c +++ b/fs/pstore/zone.c @@ -35,6 +35,7 @@ struct psz_buffer { uint32_t sig; atomic_t datalen; atomic_t start; + void *data_ptr; uint8_t data[]; }; =20 @@ -822,6 +823,38 @@ static int notrace psz_kmsg_write(struct psz_context *= cxt, return 0; } =20 +static int notrace psz_register_dmr_record(struct pstore_zone *zone, + struct pstore_record *record) +{ + struct pstore_zone_info *info =3D pstore_zone_cxt.pstore_zone_info; + int ret; + + if (!info->register_dmr) + return -ENOTSUPP; + + zone->buffer->data_ptr =3D record->buf; + atomic_set(&zone->buffer->datalen, record->size); + + ret =3D info->register_dmr(record->priv, record->id, record->buf, + record->size); + if (!ret) + atomic_set(&zone->dirty, true); + return ret; +} + +static int psz_unregister_dmr_zone(struct pstore_zone *zone) +{ + struct pstore_zone_info *info =3D pstore_zone_cxt.pstore_zone_info; + if (!info->unregister_dmr) + return -ENOTSUPP; + + info->unregister_dmr(zone->buffer->data_ptr, + atomic_read(&zone->buffer->datalen)); + + atomic_set(&zone->dirty, false); + return 0; +} + static int notrace psz_record_write(struct pstore_zone *zone, struct pstore_record *record) { @@ -906,6 +939,48 @@ static int notrace psz_pstore_write(struct pstore_reco= rd *record) } } =20 +static int pstore_unregister_dmr(struct pstore_record *record) +{ + struct psz_context *cxt =3D record->psi->data; + int c =3D 0; + + if (!cxt->dmszs) + return -ENODEV; + + while (c < cxt->dmapped_max_cnt) { + if (!atomic_read(&cxt->dmszs[c]->dirty)) + continue; + + if (cxt->dmszs[c]->buffer->data_ptr =3D=3D record->buf) + return psz_unregister_dmr_zone(cxt->dmszs[c]); + c++; + } + + return -ENOENT; +} + +static int pstore_register_dmr(struct pstore_record *record) +{ + struct psz_context *cxt =3D record->psi->data; + int c =3D 0; + + if (!cxt->dmszs) + return -ENODEV; + + while (c < cxt->dmapped_max_cnt) { + if (!atomic_read(&cxt->dmszs[c]->dirty)) + break; + c++; + } + + if (c =3D=3D cxt->dmapped_max_cnt) + return -ENOSPC; + + record->id =3D c; + + return psz_register_dmr_record(cxt->dmszs[c], record); +} + static struct pstore_zone *psz_read_next_zone(struct psz_context *cxt) { struct pstore_zone *zone =3D NULL; @@ -1110,6 +1185,8 @@ static struct psz_context pstore_zone_cxt =3D { .read =3D psz_pstore_read, .write =3D psz_pstore_write, .erase =3D psz_pstore_erase, + .register_dmr =3D pstore_register_dmr, + .unregister_dmr =3D pstore_unregister_dmr, }, }; =20 diff --git a/include/linux/pstore.h b/include/linux/pstore.h index 8360d94c96b6..85f3f964b268 100644 --- a/include/linux/pstore.h +++ b/include/linux/pstore.h @@ -290,4 +290,20 @@ pstore_ftrace_write_timestamp(struct pstore_ftrace_rec= ord *rec, u64 val) } #endif =20 +#ifdef CONFIG_PSTORE +int pstore_register_core_area(const char *handle, void *area, size_t size); +int pstore_unregister_core_area(const char *handle, void *area, size_t siz= e); +#else +static inline int pstore_register_core_area(const char *handle, void *area, + size_t size) +{ + return 0; +} +static inline int pstore_unregister_core_area(const char *handle, void *ar= ea, + size_t size) +{ + return 0; +} +#endif + #endif /*_LINUX_PSTORE_H*/ --=20 2.43.0 From nobody Mon Feb 9 00:04:51 2026 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9D89218AA8 for ; Mon, 17 Feb 2025 10:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787479; cv=none; b=YzPk1idapfJkbrpUMmol15Bawh9KxlSig5L+5T2GfmIkpCK2nH0FGPIeRyABWyNmG/UvMEjq7DJ5UmPbeNe6r5kHbdHzsZv8ejKagoyd3O/4BtkkwxNNdgktjYyD8gi4MiN6ZXmToZl1q1Wki6UxE5L07UG7HgXoBjzzPVwInQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787479; c=relaxed/simple; bh=aIDoW7X3UEqmkRU5fd1ed1f7Yb48yUxmvjsG6JEXMy4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jaQnn4XnTUJALsWxb8C2SvRgo+GuotS0TB4edC3TroUKNBCNLgyy9Dqs4IF45d8TgqqZuxPAWzxuMZUAHgj1sVNnGfBDg/TQgq5WbhBQO/5lEK4tyB8Y4lXfzPJHoutbZuTPHsdZk6i1xb9gv6HHVduCLgOPtbZsQC1ckpS2IPw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=o8twVDZo; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="o8twVDZo" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-abb79af88afso297712066b.1 for ; Mon, 17 Feb 2025 02:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739787475; x=1740392275; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pjqSIaqjo22M/fJ6WrzBYInBLUW49xWtc11H9nbdufw=; b=o8twVDZojukUFWL3S8iI2AP6UXMtrVpRVaVZH5UvvmTEpXcZO1UpLxeF/YDscsxnCB S+jjnSTM2IasEld2rvi7OfFnTKUwwPSYqTk+coYyqOpzyHziSAl9zl9ev9M3FstDb+5+ 6cErzq/sJAhoxcjpkzUqzAsC7sjlrUrsgoclQu4UtPVOQaI9hsjGQJM+gNY4bjgXnNXq 520EfVxXrR3v4tW+oAMjlHcgqhXKdqfbFznB/CwuROHoYjyRM1beA6qm27iN4iy2tif0 Bs/ZBIll+F39RX/vEk+4u5isoI7LTWYnz8UsU8QLOJSPKMibWBQMwpbEJxaN1dZnHue9 wutA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739787475; x=1740392275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pjqSIaqjo22M/fJ6WrzBYInBLUW49xWtc11H9nbdufw=; b=mzUyerHnxoUgO6RFq57jTXE26UJf66kwZ0pWY3G25jx0cmGcgWnhfWLzLmfqh1aOEo uJndS8+hVR8FdV+bpgXEWPuAIZvKiig+8OVl/ax9MtqB4viED6OHQ5q9t9XmIp4go0Ev MI8ekmVVNQH7FnUPiI8umtyB2FRCdiygwdUqjXKYrz0dvd9IgYzTW3jpiM29GsBItl2A Oyk1+8nNmWT3ca24dRl765AThexE0Q3aSubX1wZIpFtt2i4WxycSD5ImgRlGneBScHHc 05iPWW7HsbvGZiA19itzbKQYngoyH8z8W1odTVdw5qUcR4aSpvBCIF0a9hyc37rG0fsu WxtA== X-Gm-Message-State: AOJu0YyoI87zylb7oDJfh548jH9TeKpg/EMhjpUwYGWx3iHg1gxOHjm+ Pu5MJG5sCWofFprMnztQlcUrlX8OzS3A/cfXXpZc0IhMb6ODzvgsLXKpsV07R9s= X-Gm-Gg: ASbGncurNa/US5wO16ckNSVObLPSnaAxbK2+jecsoAaFI0RIMoK2Ojvvlhg4OUA69CW 7IInXvnFQkQczdNdP4sapOz7HdEHM2LR3uq7wX1JVpZmhUrq89L0V5Wagnj9/gB52lWGia9EScJ XEUPmgVABCSrgN75v/ucPkE+ua+ayOY1se33x4hIp+yY5URtITAl3Yc9ch+ICLU7fC7YIp1sIBr MYtzXkh1p6fyYPvu+lguJI+UY5lmOO2NB+B69K2aquSK6qkRPV+08DaE7jaZtCOD3GmtB/iiWIO q1iWO06R4XTgzGkQbp7Jrs90 X-Google-Smtp-Source: AGHT+IFlDyIupv/Dc3O4C3y1gwzt/272w46jucKO95aSvrTTvzjMkzKCPNIWu+2421TQveFqhl50lg== X-Received: by 2002:a17:907:26ce:b0:ab7:b878:e8bc with SMTP id a640c23a62f3a-abb70de288cmr1064938866b.38.1739787474939; Mon, 17 Feb 2025 02:17:54 -0800 (PST) Received: from eugen-station.. ([82.76.24.202]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb8b1767e8sm308583266b.174.2025.02.17.02.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2025 02:17:54 -0800 (PST) From: Eugen Hristev To: linux-arm-msm@vger.kernel.org, linux-hardening@vger.kernel.org, kees@kernel.org Cc: linux-kernel@vger.kernel.org, johannes@sipsolutions.net, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, andersson@kernel.org, konradybcio@kernel.org, tony.luck@intel.com, gpiccoli@igalia.com, pmladek@suse.com, rostedt@goodmis.org, john.ogness@linutronix.de, senozhatsky@chromium.org, quic_mojha@quicinc.com, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Eugen Hristev Subject: [RFC][PATCH 06/10] qcom: smem: enable smem pstore backend Date: Mon, 17 Feb 2025 12:17:02 +0200 Message-ID: <20250217101706.2104498-7-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250217101706.2104498-1-eugen.hristev@linaro.org> References: <20250217101706.2104498-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Enable smem pstore backend that registers regions into the minidump table. Signed-off-by: Eugen Hristev --- drivers/soc/qcom/smem.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 592819701809..f4d2646fcc0b 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -1236,11 +1236,21 @@ static int qcom_smem_probe(struct platform_device *= pdev) if (IS_ERR(smem->socinfo)) dev_dbg(&pdev->dev, "failed to register socinfo device\n"); =20 + ret =3D qcom_smem_md_init(&pdev->dev); + if (ret) + dev_info(&pdev->dev, "smem minidump backend init failed\n"); + + ret =3D qcom_register_pstore_smem(&pdev->dev); + if (ret) + dev_info(&pdev->dev, "smem pstore backend registration failed\n"); + return 0; } =20 static void qcom_smem_remove(struct platform_device *pdev) { + qcom_unregister_pstore_smem(); + platform_device_unregister(__smem->socinfo); =20 hwspin_lock_free(__smem->hwlock); --=20 2.43.0 From nobody Mon Feb 9 00:04:51 2026 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67254218AC1 for ; Mon, 17 Feb 2025 10:17:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787480; cv=none; b=t+e6DXrQnjxK3LGfncreHbN1rqAps0BkpiLgL8D40qjrXnkWXh6p1ilmreub6iDdWKiWvdc9wk0U8ReO0/Sovj0uItL7kXPLzCj5Uyfqt0SoeqfPdtYzq2D6bkFuS6rxAEU8ViJeQhBbSBwVat4z3NZuiVz4bcsmhaBwu0ZOu6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787480; c=relaxed/simple; bh=61J2pu5l3ndGn9woBnkjvneIE/RD9R+0X2yrx5ajIWM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NPTEsYOs1hWLSjWznf6D9Wdiu3/uC8R18/uOQOpV9L+BLLHdMvNKjdzcZEui39+cGODHyPwFnNZSPDOXNG6g6Q1dUb1kTwHuV7316Ism28V6gtq1Y+z2SJhEKWuBtd6kdP1sr9ffZ6kNAFekRNNckSgzQaqZ7CFGkzyUOIponU0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ZsEMpFNt; arc=none smtp.client-ip=209.85.208.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZsEMpFNt" Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-5de63846e56so8072862a12.1 for ; Mon, 17 Feb 2025 02:17:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739787477; x=1740392277; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ldGwrx2cT3RoWK8xQPpncYSf7C74wmzaVDctYgnNzT8=; b=ZsEMpFNtgC8tqQQhhiNG9KGHmENdgB4rAu9TzSfsY1MSvj3kXgq+zR+OVmeyE23lfY hIOT3cC2fIbGcc3Hzbf1dVsmey8oQxNt9XMXlNncyUSDe1Rvj2UouxOZ4iGlTzGRBfoC pZksizHBgwUvweaz535oIlBw/CTWRn9nfeek0P3NytAJ/ck1PqSOG75pFOD7fYRIh3gG O6nwqs5eEGWqJfIuGCDSIw9uRuAMXV92lTqoOVNC9s8i3VuzuxUFB+lS3gs5+9o1ecq/ Leib4/k/6UMbNc6yq9iTHWf3RDatAVe5pYDPb+fGwOIwr77wjdmuRPqiVrJlBvBC5gUk uP5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739787477; x=1740392277; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ldGwrx2cT3RoWK8xQPpncYSf7C74wmzaVDctYgnNzT8=; b=G8TkH6x08/Lqoyn0Xph0iCrmD4kI/EXsMm7bCIgzfalbWbBbcEDHqswUqtT/r28scK Wu7hpDsj8wkZWieusWYNTxJoQez/T+l+KqlmgNOu7D+07kqnccvp3ZgXUu9VaaHOsHcf K1w0vXALk8KS3OWk+/ad3tB+s6VxWW33+NojSBHgL++kJBUcY0vyESPm1OiEogEjkDSc suct4wmIPQ3gGpeA9yIcRNZ+n1S2/OMMRwvkInPyrqoX/cXeAkCRifZPtzsSVoJXQyB3 Emvch201+KQfjm/Mpdu6mS/9iiJUvsLCyamGwaUTk2G5VbWQMLCPKFZuR9QLXuZdNKd/ RT6Q== X-Gm-Message-State: AOJu0YxN++EXerBwuuHltMO/pDECpKkIM4PD/zSai1qd4jsA/CCjtvjC AJ94C33Tf4NbOpiO/PL5Tbqw6FQW0ajUQp9YwVKR5pp9YCC4Hnj9aX2R6bT4tWjTRf8Dc9OWgaS ZGBQ= X-Gm-Gg: ASbGnctw4n2e68RUeIO72pMN5xU4VRkInCyaMwFfHu1VvSlP05f8k51FTUxfYFgzSjj ajrk1q1izi0zBMAhrAh+vll/8HBJM5Q+vX35eUCqP7bPW9tDwi4VMN++2502XM2cA6DHuW38u0R 6Ccz9aSgNzMgU8rqWKKh1BIHrAxZUfHjWu7TWqczv5Pg9BSagI2FuXZN9L6OigFSRyAUBhlXChB uLikWT3L1mieNMYD2KRauin6MH2DkjF1GRc/z/GHpff+gkQuPr0RiZIWVotu0fRgPkD2Ebj2xgj 7BXoYAnlhECXMoJDQB2uHWo2 X-Google-Smtp-Source: AGHT+IGLJ6wBq1Q2Otx2cXUsLqwI686ZT/K4uXqflhPHhYRM3ByDKMZpdTFQUXVBYhqRHLkwN7a7fQ== X-Received: by 2002:a17:907:78b:b0:ab7:c115:68fd with SMTP id a640c23a62f3a-abb70e61a23mr916824766b.53.1739787476706; Mon, 17 Feb 2025 02:17:56 -0800 (PST) Received: from eugen-station.. ([82.76.24.202]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb8b1767e8sm308583266b.174.2025.02.17.02.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2025 02:17:56 -0800 (PST) From: Eugen Hristev To: linux-arm-msm@vger.kernel.org, linux-hardening@vger.kernel.org, kees@kernel.org Cc: linux-kernel@vger.kernel.org, johannes@sipsolutions.net, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, andersson@kernel.org, konradybcio@kernel.org, tony.luck@intel.com, gpiccoli@igalia.com, pmladek@suse.com, rostedt@goodmis.org, john.ogness@linutronix.de, senozhatsky@chromium.org, quic_mojha@quicinc.com, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Eugen Hristev Subject: [RFC][PATCH 07/10] printk: export symbols for buffer address and length functions Date: Mon, 17 Feb 2025 12:17:03 +0200 Message-ID: <20250217101706.2104498-8-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250217101706.2104498-1-eugen.hristev@linaro.org> References: <20250217101706.2104498-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" log_buf_addr_get() and log_buf_len_get() can be reused in another module, export the symbols. Signed-off-by: Eugen Hristev --- kernel/printk/printk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 07668433644b..022947f9b61d 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -588,12 +588,14 @@ char *log_buf_addr_get(void) { return log_buf; } +EXPORT_SYMBOL_GPL(log_buf_addr_get); =20 /* Return log buffer size */ u32 log_buf_len_get(void) { return log_buf_len; } +EXPORT_SYMBOL_GPL(log_buf_len_get); =20 /* * Define how much of the log buffer we could take at maximum. The value --=20 2.43.0 From nobody Mon Feb 9 00:04:51 2026 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EA60218EB3 for ; Mon, 17 Feb 2025 10:17:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787482; cv=none; b=al1MYBa+FF8SOOrcN/9/DsjpAgyehWFH66DljtUn1woI6+phyzBz871N0p8IZDMdSR8XEFRK8IBWkaXlwTziD/E+nVS82l1girj/i7gusxqAMYJ7NuYVlwx1IlB8j5WQqoBiUYm9c9WSSSub7sesHoLUiapSGAS+A1DHa1sR30s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787482; c=relaxed/simple; bh=6JLAQiXiBCTaZy1rpRUfOhG9JvPaEfv2VkDTKVoBVm8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uBZeDJECGRnrsc00cPkLZDW7hl2bPEoQbvKdbpdqbziOGOyre02kvssTtWy8N0q62QjtZkf0LggB3f4b2JgtvtqFP2cRrissCBTnoggMiCI4XDBIDJZqItK4zNNT+eePzWGrXEBFbK2f7JDb4d97gmSjfw+Q639I3BIbCQr3gvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=sCKS6Tup; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sCKS6Tup" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-abb90c20baeso145531666b.1 for ; Mon, 17 Feb 2025 02:17:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739787478; x=1740392278; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6Td102jvjcyxJvAztEsXWW/VUH0CMT8UhqkeVVK6uLU=; b=sCKS6Tuprl/dYZRp9WH3Ijo33jFNfIf/A37scAt5+zGyFA1t+uzX6VWzy2Up4AaaEP rIvRcQHGHZUbwSR5zhg8CbBGfkP8xJVOgV+XG1iaPVUnt7bdlbMIbxu+7E6hkJL95owb 4jakP3fTtCzUU08ui5gj3dUUZZlN8wqCS5xLsI68ZmyXObdD7fTiC/hzaqC5Pv835ARc x8umw/067y4wYYJOzbupwclrgqd2DynTVu1X/79YPj9TaEfcK1DI+qPy5it45oOXHoZD mQtENqCGQBZA4XZq0gV7F4UhlOqLU8UzNB+97CT4YxhBJyvf6M6TYMK+6+1uqR+Cauag 9xjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739787478; x=1740392278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6Td102jvjcyxJvAztEsXWW/VUH0CMT8UhqkeVVK6uLU=; b=ADtUuS88G9OZt5qoq7SXYXG0EDZx/1wRLswfxEZumcdo9TUNB0YLSz+8ssHYoDR2w6 iNm7D/HjzKvSZ+Ku93QU86Wvc5Pg5vxGrVdqzwhZzx+xoWWMS1FGuPyaELEEX3vGT8NN drFPvTcDCEw9BWK3iKDoxjn2HIWo0dsDpeyxpg5y6GTAbkgOs1Neeb1xhuvKhgt4VKxY 6yZd/As20LoT0zti3bK4f6BAh15heXNySCN3Xgcx39na7YJvMqGWHkCbsKy42OmgKzMf MLiP0FYvkPoqFAOBPWt1kkheM72Sz5gXuhdGLLZAnkhRm2KbkP65rxQefhZrlf1Gqxc8 OuRQ== X-Gm-Message-State: AOJu0YzwWSn8NPreWuOJfwbOQKdlUic+qnZ8jqU6VX8BHme2XWqs+kl5 hz8Hi7oh3oU+rSherNx2848BJpAyeiXBr3oSpKiLox1nNdnuRBG7rSQzetcqXvA= X-Gm-Gg: ASbGncsL62rx/2FIM1eycQTJpnPJAXBjMO6bhmDTYT0Gt3CnJMl9gO9eJqNZf70Ag3S CJhNUODc8gtkLmNS8RPJldklOmDAvZY1ZFDoBGKBt1enJ8P+QoTG2EwVLT3bnFjkZg3B7pBPrbk wXDhAsh4aFrIopfYmepKBd4tNIs2dPohKE3/18icyx8AyDZ6Jt5jHlCiEOftgIA6J4TkXqzg/qb qUYvbC/ph7QJgRpt3I3yaLUPGn0Ipo0H3iNCONlwg3Icqe7tIybKrqtry3CPALwvDL7gzb1uod+ EH1JAvUcCqNtQN63Q4Ka9vIz X-Google-Smtp-Source: AGHT+IHY65P+Xz4TNjemyphPqqQ9+ru/mohlrB5vFIKJf/R1MNkDOblIAzwWX9YVxAvz0IWpeGk+4w== X-Received: by 2002:a17:907:7752:b0:aa6:79fa:b47d with SMTP id a640c23a62f3a-abb7091cedcmr752835166b.1.1739787478322; Mon, 17 Feb 2025 02:17:58 -0800 (PST) Received: from eugen-station.. ([82.76.24.202]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb8b1767e8sm308583266b.174.2025.02.17.02.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2025 02:17:57 -0800 (PST) From: Eugen Hristev To: linux-arm-msm@vger.kernel.org, linux-hardening@vger.kernel.org, kees@kernel.org Cc: linux-kernel@vger.kernel.org, johannes@sipsolutions.net, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, andersson@kernel.org, konradybcio@kernel.org, tony.luck@intel.com, gpiccoli@igalia.com, pmladek@suse.com, rostedt@goodmis.org, john.ogness@linutronix.de, senozhatsky@chromium.org, quic_mojha@quicinc.com, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Eugen Hristev Subject: [RFC][PATCH 08/10] pstore: register kmsg into directly mapped zones if available Date: Mon, 17 Feb 2025 12:17:04 +0200 Message-ID: <20250217101706.2104498-9-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250217101706.2104498-1-eugen.hristev@linaro.org> References: <20250217101706.2104498-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If dmapped zones are available, register the log buffer into one zone. Signed-off-by: Eugen Hristev --- fs/pstore/platform.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 32448d9dd316..9a5c1d6d5031 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -452,11 +452,22 @@ static void pstore_register_kmsg(void) kmsg_dump_register(&pstore_dumper); } =20 +static int pstore_register_kmsg_dmapped(void) +{ + return pstore_register_core_area("dmesg", log_buf_addr_get(), + log_buf_len_get()); +} + static void pstore_unregister_kmsg(void) { kmsg_dump_unregister(&pstore_dumper); } =20 +static int pstore_unregister_kmsg_dmapped(void) +{ + return pstore_unregister_core_area("dmesg", log_buf_addr_get(), + log_buf_len_get()); +} #ifdef CONFIG_PSTORE_CONSOLE static void pstore_console_write(struct console *con, const char *s, unsig= ned c) { @@ -582,6 +593,9 @@ int pstore_register(struct pstore_info *psi) pstore_dumper.max_reason =3D psinfo->max_reason; pstore_register_kmsg(); } + if (psi->flags & PSTORE_FLAGS_DMAPPED) + if (pstore_register_kmsg_dmapped()) + pr_warn("Registering kmsg as dmapped failed.\n"); if (psi->flags & PSTORE_FLAGS_CONSOLE) pstore_register_console(); if (psi->flags & PSTORE_FLAGS_FTRACE) @@ -628,6 +642,8 @@ void pstore_unregister(struct pstore_info *psi) pstore_unregister_console(); if (psi->flags & PSTORE_FLAGS_DMESG) pstore_unregister_kmsg(); + if (psi->flags & PSTORE_FLAGS_DMAPPED) + pstore_unregister_kmsg_dmapped(); =20 /* Stop timer and make sure all work has finished. */ del_timer_sync(&pstore_timer); --=20 2.43.0 From nobody Mon Feb 9 00:04:51 2026 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81EAC219A89 for ; Mon, 17 Feb 2025 10:18:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787483; cv=none; b=CQWkjG6x8e3LOqFVRGBRKRwuQE+H5EwhCZTLxQajMK5ClcdTcTRdXh1hnZ2eGpP0Yu2VcdhIY5dfae8TMH16TmYjxvtnX/Ey01/LGPdM/V4p3wqICrd2k9x9x33QElmMyhzh2A45aj3mDUGEl0z+rd0MnNMlC0KVogZnJK/WSrY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787483; c=relaxed/simple; bh=CNpLokpmqxK7vPDH6UkXrNYj7YYXuynUbdaQ5h4wAQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OHY6C0R+UTgwmRw+a1q5eR7xPc1tZMhZ/YacOuqJ1iDJyx2tMmjH4Fd4zmQtu0lnaBFP2WqQZqkHXZjsQZGJZKcQrl/Yj6sPZbkCBhtrHfOiuGnSmsaP3liQdRl2od53xLFIEsU8LdQ88Dpr0WJixLgBwmhz/6exVHDy/Yk3AAY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=pc5mzDyn; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pc5mzDyn" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-abb86beea8cso248946566b.1 for ; Mon, 17 Feb 2025 02:18:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739787480; x=1740392280; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S3eOW8UrFuxRaUp3//DxYdvLP38s+Fnhi3jsogW/ejs=; b=pc5mzDyniinfOd1in2GkaK0Fp6HaIaDEwOduwxetcvHN0BwowymNhe2d8ZXcIUFabD NaWeA9L56HLnDC0QH2nS6DY82hXS4E400Oj1CjDMUv+UvEmbtvo4igP8AVNrFyLpXTZg OPHYeJylTyP6DysKSlW+dorkAFVZxO08qw8bf40jFxlC18WV2kSBO9WXO0oe/ycKpDdn L9VjlOhks7Y4pKKRCyc8gh+gy2UVMUIhUvTNz0DcbfLvSbQZfEi0dtVvwQF4UUex/1aE 6n/XgZr/kUMSADmZglzQCFoRmhjkGL9YpXZTriUxVYb2G5a8cMbJ8ulQvbiu/yFBgi8S ad8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739787480; x=1740392280; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S3eOW8UrFuxRaUp3//DxYdvLP38s+Fnhi3jsogW/ejs=; b=rQLxUGmutOxZvVfps2+URUNTNoRGWPG9qgYImqRNcoPDg8EoNLCTYK/itdgB7zyIas kaMe5am1prRUCv9xL+Vaq6EebxJz2jrhEJdsIVDsw/RPnyRzTHME4yFEfDdBt1K0qTee RQwODyOmlHt4gPzp23WqRhnij6oaTBxq65wEE1WqhgLeSko30KDaqBl0yl4pouV86Fmu tljJb47T3mlXkRgkdI5HTsa15br7R2KnJkqFn5RICzldkdZfXpCjAPOPp+fLVq+PhCyI 5PGC5v4cpvPhV9oG5swgVdYyUxx4+yAqyqGwlycTTTHBknTst6deZFlVjyKTmHQDI9bT 1EFA== X-Gm-Message-State: AOJu0YyZvluzBUHbn53UTzi5Fe7MYyJtmI6OxMQAg3KFR3X+CXOgGa6D BEES26Im0CZbID4pmqeefsnwd2sxUdn+iNfw2Xrl5NgscrMaXs5EnzNUMDoz2+w= X-Gm-Gg: ASbGnctlmfICwTC8oTM8E28lQlUtYaFS2v03LnP+G7+hCaOCwJCQKep+E20adtQtTkA xRUlC0N/IpZ5U5AkGD4AppEeKNA7H690+eERJxNt08ZAIDRGJMSkLtFUw/Df/HwgantSbxlmBsP huj3hlv//F4ZLeMf3w+jBgf6qrH0YthSJffzSV89AZjMfBhdXfLiLU/qhQZwqa0eiVLWLpO22a1 aFWU24/F8mrilw7i3BuACLkJ8qPUie6Soqj/kGbjvTHf4RQzPU1K0mvMyEqqLeg7HEAoBjWlWxq WD4i+0V4i0p3FfU0L64E0o/W X-Google-Smtp-Source: AGHT+IFMyTV+7dHiqvFGQ0qFOxy54cnyzBe3bzzybDkILWKhJuv8kUgpRDn4pTMEScsdo+ewcWeQ8g== X-Received: by 2002:a17:907:7f27:b0:ab2:da92:d0bc with SMTP id a640c23a62f3a-abb70c01ecemr899083166b.3.1739787479826; Mon, 17 Feb 2025 02:17:59 -0800 (PST) Received: from eugen-station.. ([82.76.24.202]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb8b1767e8sm308583266b.174.2025.02.17.02.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2025 02:17:59 -0800 (PST) From: Eugen Hristev To: linux-arm-msm@vger.kernel.org, linux-hardening@vger.kernel.org, kees@kernel.org Cc: linux-kernel@vger.kernel.org, johannes@sipsolutions.net, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, andersson@kernel.org, konradybcio@kernel.org, tony.luck@intel.com, gpiccoli@igalia.com, pmladek@suse.com, rostedt@goodmis.org, john.ogness@linutronix.de, senozhatsky@chromium.org, quic_mojha@quicinc.com, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Eugen Hristev Subject: [RFC][PATCH 09/10] devcoredump: add devcd_{un}register_core_area API Date: Mon, 17 Feb 2025 12:17:05 +0200 Message-ID: <20250217101706.2104498-10-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250217101706.2104498-1-eugen.hristev@linaro.org> References: <20250217101706.2104498-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add API for registering device core area for saving into pstore. Signed-off-by: Eugen Hristev --- drivers/base/devcoredump.c | 13 +++++++++++++ include/linux/devcoredump.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/drivers/base/devcoredump.c b/drivers/base/devcoredump.c index 2a0e0b2fdb98..2cf17b148c5a 100644 --- a/drivers/base/devcoredump.c +++ b/drivers/base/devcoredump.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -76,6 +77,18 @@ static struct devcd_entry *dev_to_devcd(struct device *d= ev) return container_of(dev, struct devcd_entry, devcd_dev); } =20 +int devcd_register_core_area(struct device *dev, void *area, size_t size) +{ + return pstore_register_core_area(dev->driver->name, area, size); +} +EXPORT_SYMBOL_GPL(devcd_register_core_area); + +int devcd_unregister_core_area(struct device *dev, void *area, size_t size) +{ + return pstore_unregister_core_area(dev->driver->name, area, size); +} +EXPORT_SYMBOL_GPL(devcd_unregister_core_area); + static void devcd_dev_release(struct device *dev) { struct devcd_entry *devcd =3D dev_to_devcd(dev); diff --git a/include/linux/devcoredump.h b/include/linux/devcoredump.h index 377892604ff4..9d80e4ac91ff 100644 --- a/include/linux/devcoredump.h +++ b/include/linux/devcoredump.h @@ -69,6 +69,9 @@ void dev_coredumpsg(struct device *dev, struct scatterlis= t *table, size_t datalen, gfp_t gfp); =20 void dev_coredump_put(struct device *dev); + +int devcd_register_core_area(struct device *, void *, size_t); +int devcd_unregister_core_area(struct device *, void *, size_t); #else static inline void dev_coredumpv(struct device *dev, void *data, size_t datalen, gfp_t gfp) --=20 2.43.0 From nobody Mon Feb 9 00:04:51 2026 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3907021A42B for ; Mon, 17 Feb 2025 10:18:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787485; cv=none; b=an9NeU5Va7L1x1zQO/MPd9NpAePB0BoW+ewdGcu4UjTzdFpseeMx5f9KwCHt+LqCfBLtd+QRKM7PQoVA//DDNPA4ondAsxXyltA5ne5MTXh7q2erSbDFfCvZJw4CghCGvRjyj402AeAdy3RfA1EgwUBt4vQ6EYD1p8dFmjmp+6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787485; c=relaxed/simple; bh=H1Q/+IWyWi+vB9ilQ6BLrSUry9GYCCCUwBI0kz8T7RA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZCgVQhANoUolWwD8DLrMb4cG/l5Dzclh4N9J4xk0WX1Z3phPSuz2mzcunobikVnTzi+om7ZkIoZToGhWwpUfalPkq8Rk2XimWYSjvWWRK1UhZdBgh8LtHK7HaxIjfOUIegSB1qdjwLOGTR0ZgQ3/VgHQ9edhCfi/OI53tj3QrII= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=j6jcOYWM; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="j6jcOYWM" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-abb705e7662so333250766b.0 for ; Mon, 17 Feb 2025 02:18:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739787481; x=1740392281; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bOx/QjhnUzr5iZf43d5r89IsS2FOdAlXvdjY2fxKvfY=; b=j6jcOYWMI+xBtGufFxtNgFXkcWHfBITO7ir/tJj4DdFAtVlkTQO72/L3+0sCKJg0xH BwfZtRHLBchmHXbktX6cEsV0ganx0LddNHdEsnEQEpLgnE1JOD4lnHLVAyCNv4mawObA V1njXv86+puXsxF1HH18+YIDGe8IgNsyi0Gy/l82d5LdYIrnVUAdwovpfisz01eMyMS6 FwYQ1kAsHuS8KtNfIF/tQsMWDJsFk39noEwsiyenNvp8qhKy2p/NLVg7uokL4nt1rftN /ZXUlSoxGUYPWictch6imohZ8QbTXB4x3a6HvU6wuEbXbwXXqwIIYn4C+yIQ3fTjiG48 A3eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739787481; x=1740392281; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bOx/QjhnUzr5iZf43d5r89IsS2FOdAlXvdjY2fxKvfY=; b=IdwXNmz5hXztss5v+YObyhv2w7I9NvcZKGZy/DlwGx0U+ZENVLtsT5q+zknwP4Pkfn BHkBqSgZFEReaoSCDkhZtnlmpO+Mintacpw4L9hj7p/Jg/DWAi4JwUvhrhjytI1q09Up ozcnzRZztJzo7/Oy4pHVHLPPrEEyxOL4/qGQHTGstvyMBfdL/7exgB/DyMObpEk/HBHS IV5DRb3vDU18XouwwDOMu0VyfITaPp/aQB0/W8vxUhfGfCm71fbLLBcXFSuSW8CckKAM 43SCL05GetgSAmFlTZ9fMKX3HynoeB83dvPVpJFeb2GQjjP+VgybN/pWnb6atRs3pIVc Smxg== X-Gm-Message-State: AOJu0YzKkvtl9XvmWXN05Lr8d/KpntGIF7d8Fld+yz7q14LNLa4DAPr9 0KpQTVGKlXPcNB3cbNqKDzY3xnOx+VBftxDP1YLMz+f92m//klSf3A2AoFtf+ko= X-Gm-Gg: ASbGnctbDN8bRbkSGzewYSs5JDfz/gWsiYPIOcTGe82pPlZrYmnb75bUBLDu/zmPywg HDt+bYDmn2JRa4LiED9LFe3QvN6D4KouBid+cYAjKoYuCwDXdZc7KvWnMq5WUCbfQhsZx2mZe8I g+0q3P6pPrMUWJVLMBae1iom0GjbzHIfzbHKhzTC3O7wT27J7suoEW08rBEEdwXBaVcmtWy2+jv a/6MOARByKKHKTM12A2f9ej36FXem+T/nYqMvRCH4FVdxnsSG9wI4KMx1B+uPgc9fHHj4yLyUPK G6aVGt0snAuSz0jEdpW8LgKJ X-Google-Smtp-Source: AGHT+IEyhYoBsYp2nsZUxaNrWoEJIkJcEzeW3uR5U89aJyr/W0mS2FbZhC0xUYWaFE0athJ0Fx91Xg== X-Received: by 2002:a17:906:4fd0:b0:ab6:fe30:f49e with SMTP id a640c23a62f3a-abb70cd5108mr714909166b.28.1739787481314; Mon, 17 Feb 2025 02:18:01 -0800 (PST) Received: from eugen-station.. ([82.76.24.202]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-abb8b1767e8sm308583266b.174.2025.02.17.02.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2025 02:18:01 -0800 (PST) From: Eugen Hristev To: linux-arm-msm@vger.kernel.org, linux-hardening@vger.kernel.org, kees@kernel.org Cc: linux-kernel@vger.kernel.org, johannes@sipsolutions.net, gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org, andersson@kernel.org, konradybcio@kernel.org, tony.luck@intel.com, gpiccoli@igalia.com, pmladek@suse.com, rostedt@goodmis.org, john.ogness@linutronix.de, senozhatsky@chromium.org, quic_mojha@quicinc.com, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Eugen Hristev Subject: [RFC][PATCH 10/10] rng: qcom_rng: EXAMPLE: registering dev structure Date: Mon, 17 Feb 2025 12:17:06 +0200 Message-ID: <20250217101706.2104498-11-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250217101706.2104498-1-eugen.hristev@linaro.org> References: <20250217101706.2104498-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Proof of concept on how devcd register core area works. Signed-off-by: Eugen Hristev --- drivers/crypto/qcom-rng.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c index 0685ba122e8a..a1509609f50c 100644 --- a/drivers/crypto/qcom-rng.c +++ b/drivers/crypto/qcom-rng.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -32,11 +33,13 @@ #define QCOM_TRNG_QUALITY 1024 =20 struct qcom_rng { + char start[10]; struct mutex lock; void __iomem *base; struct clk *clk; struct hwrng hwrng; struct qcom_rng_match_data *match_data; + char end[10]; }; =20 struct qcom_rng_ctx { @@ -192,6 +195,10 @@ static int qcom_rng_probe(struct platform_device *pdev) if (IS_ERR(rng->base)) return PTR_ERR(rng->base); =20 + /* Setting some markers to easily recognize them afterwards */ + strcpy(rng->start, "MD_RNG_ST"); + strcpy(rng->end, "MD_RNG_en"); + rng->clk =3D devm_clk_get_optional(&pdev->dev, "core"); if (IS_ERR(rng->clk)) return PTR_ERR(rng->clk); @@ -218,6 +225,8 @@ static int qcom_rng_probe(struct platform_device *pdev) } } =20 + devcd_register_core_area(&pdev->dev, rng, sizeof(*rng)); + return ret; fail: crypto_unregister_rng(&qcom_rng_alg); @@ -228,6 +237,8 @@ static void qcom_rng_remove(struct platform_device *pde= v) { crypto_unregister_rng(&qcom_rng_alg); =20 + devcd_unregister_core_area(&pdev->dev, qcom_rng_dev, + sizeof(*qcom_rng_dev)); qcom_rng_dev =3D NULL; } =20 --=20 2.43.0