From patchwork Mon Feb 17 10:16:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 866223 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 CA124217654 for ; Mon, 17 Feb 2025 10:17:48 +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=1739787470; cv=none; b=LuoFRu07eBGTpgeiHdvfjT45s0XBrB7QG8RGeJG6pt0ey5sLreOwdGoINAWl2adEtHxDxAi/w5ymWpDtVnh5L7IY03KODHE2dMY78UOUEA3IuBPvHxs+u+mUs6vodT4Bd6rYPZ52wS4p43itiRzLrUH8wcTDqYJZd+7n91ddRUU= 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.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="zwToEZ5d" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-abb8d63b447so124198966b.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=wvDmSFd6NJNCfCLX8HyIt0R2CL7P1ioJ59tSxaIAoTzVluwJJMy2Tk8kvz/DHaOy8r OzLItmWieB5DbmE4wAsKn6hlm/T035JDc2EBSLjJgUI2LABypkaLW2wOcdQny/vtCS2d 1jDqkpz+zzAKWgmgricQ4GirqHd76PDW9mrofKXGuRII1FAbTBf+E43TIOFHTuoAFtN1 zT+e6UlXJoseVOqsa0+QlmwNykusxec+uV2pqaJWVR1GwdJL4wOTuc4lmNoR3vHdn6MY mLahbs6/kMeWcTFKoVvCfGi5rOPot+UPY8cIcEJ6v2VxRlXUeFB7xhOTqydnm4EimFVk 8AbA== X-Gm-Message-State: AOJu0YxZ0YCh1j4mGFg6qYWQ0gSWN8WzHsLwxO+U1kjyuW8nzMLRhCMb kRYyYVt0d6P6UEIqoK1QX04zh7Xn4vgA1Kl7haIR1/ozrZwpMMtg2UA2VX0CT8cSa46XzvUuVeu nyHM= X-Gm-Gg: ASbGnctxbUTotlFA/0mjeu0tohAoYRwIBQ4nK/F+Fj/GQ/6g3VLmO5dobIL46/ZcETV X0ZXuy+tVisnr9VAK8o+L251AsUvVprERLhmFpzKcaQYslbPkfQV2e0MfDGfnCvbYD6bdyen0fS DExP8ig1JeBSk3IgQCeRJGVNPEs3t4cfgVxF4Ysj53Ul1Fkk49ANQLnYQa8RoZ5AxNy3ZVoSJ/Q 1n91sgaJOh+NSxwCI6C9XtyGq7Q+ALoo5WlHICQH0UsYtLZH+DR4nJrxtfWHI1mG9pUWbcHnumC IlTOggw/AWdhhYiHOMO9/8RR 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-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 -/** - * 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); 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; }; +/** + * 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); From patchwork Mon Feb 17 10:16:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 866222 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 D817221773C for ; Mon, 17 Feb 2025 10:17:51 +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=1739787474; cv=none; b=q0aJWgATzB3dTo3LftsTAEhbDld43Yg18fyy4GlSEglxK1ZU2boa7x5nMSWvuUTAf7V1NU76+Uoc6x7MXdUVlvOcCSargluirZne4xFnVx0F2arNDLFhhjFsAjLNCr9MHyEgRa/cCe4JLygPDZgf3NzVfolQkQXEbyeEG//gRGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787474; c=relaxed/simple; bh=eFWO0XMyikPo+vVZcTF2JAqlcgoQWkxVrK0g2v9jJKI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DUxwY4ZPmTZhrlhJQUzyq0TINNvBdEjUL4snC371a/ilnM+/8c5GakD03dlfK4ZPnhEfxM6xbjT50eQnLwRIM6dxL87B0MSfZ6nhqAck6NQYt/EUI6G74b1qdKZgFWe3d9xVPPnZNSV9+OOQ+nMlwsTJysd8wbQMNMNAYMxlhbE= 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.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="zPwTTUmy" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-abb90c20baeso145509166b.1 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=qLG+OYYXxTq/nmkH5Vu/Yj6LU2BFPdNHWBdcJXcj7MpFbKEaHKql9el4/Kqe3ovS4i oGz0Wda6woHDUqcBDdWKfsuyPpCt1e448WufU5XKh2pgaizq2MeYvjQlrrHAmGx6sQYq kiJqucmeBtnta2kZ6d9c6Ahih6KsX7lzxQostMH6iCrrUPElp7yaSYV7JMHJC8EfqFNx CbGhhM6uI9nbxwaoUaDeAze9fUMzrllZ8bncTySs4D5KaSusjCnAhcmPHnS8+jVynQBa 24P7pAPRWyFZV7ZOamtadcs+3yTUZanIvgdwFoLi9E91OjjRPryikvQ0sSbTrpPwfKl8 km9A== X-Gm-Message-State: AOJu0YwBEyVw4+jZCQEmmdBchmGuRCMD0O694AJ6FR/kZt3VHr6s+kQ5 eFG7J8R7ED7GIbXebpPbAchk0ndQxTjPJFKT9soI5D8QSDJgOMqE86u1FO/RB/ibvlWuGy4W+TP Gih8= X-Gm-Gg: ASbGncvPUXyRTDdOl+vrKBGqlZTqb6c5nkldwO7r0U+PqG+PEen9rTwoegFdNxaqNAp 8f+EcA0O1GFRgv3AloVo/DGtmulKXqLVVG56N0oE+52BcXWcS77mL5Ex9Af5d2RkODwgqElZlV5 F4No6HC7MAB5PVjLxrh0YASGPci59kuOYBD7NIO7yPcLbwxuou2+exK2e33rUmVBOK68yZ1u6sg 4eDq16fbdmYxInPN3Tl+/yzDSc8w+ugCyVOYBfMoNW2aPQQZSsCzcUQMRYgSebg+MhXz6FKBzIa O/DJXQD5nSTSqAp/e42ZSC1y 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-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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[] = { "powerpc-common", "pmsg", "powerpc-opal", + "directly-mapped", }; 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_device_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 *cxt) 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); } 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; - 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 != 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); } @@ -1170,7 +1174,8 @@ static struct pstore_zone *psz_init_zone(enum pstore_type_id type, if (!zone) return ERR_PTR(-ENOMEM); - zone->buffer = kmalloc(size, GFP_KERNEL); + zone->buffer = kmalloc(type == 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 = *off; zone->name = name; zone->type = type; - zone->buffer_size = size - sizeof(struct psz_buffer); + if (zone->type == PSTORE_TYPE_DMAPPED) + zone->buffer_size = 0; + else + zone->buffer_size = size - sizeof(struct psz_buffer); zone->buffer->sig = type ^ PSZ_SIG; zone->oldbuf = NULL; atomic_set(&zone->dirty, 0); @@ -1188,8 +1196,9 @@ static struct pstore_zone *psz_init_zone(enum pstore_type_id type, *off += size; - 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 == PSTORE_TYPE_DMAPPED ? " dmapped " : ""); return zone; } @@ -1206,7 +1215,7 @@ static struct pstore_zone **psz_init_zones(enum pstore_type_id type, if (!total_size || !record_size) return NULL; - if (*off + total_size > info->total_size) { + if (*off + total_size > info->total_size && type != 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 = 0; + cxt->dmszs = psz_init_zones(PSTORE_TYPE_DMAPPED, &off, + info->dmapped_cnt, + 1, &cxt->dmapped_max_cnt); + if (IS_ERR(cxt->dmszs)) { + err = PTR_ERR(cxt->dmszs); + cxt->dmszs = NULL; + goto free_out; + } + off_size += info->pmsg_size; cxt->ppsz = 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 *info) int err = -EINVAL; struct psz_context *cxt = &pstore_zone_cxt; - if (info->total_size < 4096) { + if (info->total_size < 4096 && !info->dmapped_cnt) { pr_warn("total_size must be >= 4096\n"); return -EINVAL; } @@ -1312,7 +1330,7 @@ int register_pstore_zone(struct pstore_zone_info *info) } 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 *info) * 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 *info) 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); err = psz_alloc_zones(cxt); if (err) { @@ -1406,6 +1425,10 @@ int register_pstore_zone(struct pstore_zone_info *info) cxt->pstore.flags |= PSTORE_FLAGS_FTRACE; pr_cont(" ftrace"); } + if (info->dmapped_cnt) { + cxt->pstore.flags |= PSTORE_FLAGS_DMAPPED; + pr_cont(" dmapped"); + } pr_cont("\n"); err = 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 = 7, PSTORE_TYPE_PPC_OPAL = 8, + PSTORE_TYPE_DMAPPED = 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); }; /* 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) 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); }; /** From patchwork Mon Feb 17 10:17:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 866221 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.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 39E0421882B for ; Mon, 17 Feb 2025 10:17:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787477; cv=none; b=bMwC9gv6vneK9YkHvzWXgwXMrIXWyCMQuEoVrQP4iUPCWa7REEzWN4ZZA4EwRXCML4CDueMJa1+5/DN2Mwohqxso2fHn/wJnDPeHml0pkErrcxApnXR1Dy972B7AmwMVHQ5dD/mVfjm6y9WAnMCYjVIkwIgLGpHxPlYEPfeuVWk= 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.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="j2d+EPkL" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-5e033c2f106so2920766a12.3 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=UQflhRClgvP6YumQUu/JL8/OYZIltVk0/4tqbb5nlZesSB8vXkWAepcfErW2ymVtSB 7Iiu9DQp5WtLRlMPWm3m6AAfMCZp+XhbGnokAwaJ7WLQiClCjldXKz2GERlVVG1Fm2WT ZtV5antt/Vp1aHFXkFNvrS1UE4ppdBRffSGb38gPpTidbIxMEubN1d/2MwjFrEBlRNvJ tn8kC7bOz6yr2DF+aoLJbm0tCHZKWDJR9SdKk2evmS+R4TBfmSmw/SBXuOLYjEhZ5Ldd 6pD86P9xQgbR5BTVmR/F4fssUYvkPU+P2xXNUDC8kAKG6JwtLrJU5sKIAUrlIHdX/wSg hAog== X-Gm-Message-State: AOJu0Yxms2DZ6CU7b/qkrMRfJ/DpuE5kxP/B5WI85Lup68J5RSdbLdQl njL8ftSl4fB2qjh4GnN+a6As7N5wrSKqQ/2vJKTq5fzRjpF/Vyt2+yyeUAQeuL99RRfUsAjrZfK LQj8= X-Gm-Gg: ASbGncsovu2brJRWBB4DIdfTZxKiuRKd/8IZ7MzaiOFMZnLxHrwtliAkbY2rlAK0oEd 9MhSH+bhezUYtzy5Wb1p6UZNnp4I6TUVj4iQWJajrlU331G2u5AuZX1WUSz+jsya4gzVm+Y88U3 tDRDlzr+Ctw+dxxRTF1T+baIl61dK/mAEkpCKS4OMSDIr3tEaMCayilXYkh/nbfSGuKDzP1Da2I REFg9pkWNu8o3rK2PqIBGHPeeFiQpF7uDRnVgIS+mAonwNqIwFv2jg9t1MkMtAQE1Oha96qNMNH MAuiRjZkSCtDu8fooxEPD+Vb 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-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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; static char *backend; @@ -99,6 +100,12 @@ MODULE_PARM_DESC(kmsg_bytes, "amount of kernel log to snapshot (in bytes)"); static void *compress_workspace; +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 = ns_to_timespec64(ktime_get_real_fast_ns()); } +int pstore_register_core_area(const char *handle, void *area, size_t size) +{ + struct rec_list_t *rec_element = kzalloc(sizeof (*rec_element), GFP_KERNEL); + struct pstore_record *record = &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 = PSTORE_TYPE_DMAPPED; + record->buf = area; + record->size = size; + + if (handle) { + record->priv = kmalloc(8, GFP_KERNEL); + strncpy(record->priv, handle, 8); + } + + mutex_lock(&ps_dmr_lock); + + ret = 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 size) +{ + 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 = &rec_element->rec; + + if (record->buf == area) { + ret = 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[]; }; @@ -822,6 +823,38 @@ static int notrace psz_kmsg_write(struct psz_context *cxt, return 0; } +static int notrace psz_register_dmr_record(struct pstore_zone *zone, + struct pstore_record *record) +{ + struct pstore_zone_info *info = pstore_zone_cxt.pstore_zone_info; + int ret; + + if (!info->register_dmr) + return -ENOTSUPP; + + zone->buffer->data_ptr = record->buf; + atomic_set(&zone->buffer->datalen, record->size); + + ret = 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 = 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_record *record) } } +static int pstore_unregister_dmr(struct pstore_record *record) +{ + struct psz_context *cxt = record->psi->data; + int c = 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 == 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 = record->psi->data; + int c = 0; + + if (!cxt->dmszs) + return -ENODEV; + + while (c < cxt->dmapped_max_cnt) { + if (!atomic_read(&cxt->dmszs[c]->dirty)) + break; + c++; + } + + if (c == cxt->dmapped_max_cnt) + return -ENOSPC; + + record->id = 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 = NULL; @@ -1110,6 +1185,8 @@ static struct psz_context pstore_zone_cxt = { .read = psz_pstore_read, .write = psz_pstore_write, .erase = psz_pstore_erase, + .register_dmr = pstore_register_dmr, + .unregister_dmr = pstore_unregister_dmr, }, }; 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_record *rec, u64 val) } #endif +#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 size); +#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 *area, + size_t size) +{ + return 0; +} +#endif + #endif /*_LINUX_PSTORE_H*/ From patchwork Mon Feb 17 10:17:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 866220 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 55843218AC8 for ; Mon, 17 Feb 2025 10:17:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787480; cv=none; b=ZEoEN2MNTUlBVwvv/m7p43NwgFkZYL/xVkvG28YCDPn48zDMyBuq7AynEaQ6kvfSYM3xrxCyYC3+BraTmPKR4BQ6PbyPfnw1zoekPeAH6/dDq7SZ0NDQoxVqxlHHkvwgiAOUpC5JEf+vPNql8iBKM0bZPyu4XmEg+UMedF0oeGg= 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.218.54 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-ej1-f54.google.com with SMTP id a640c23a62f3a-abb79af88afso297716466b.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=XkZK6E+crbOhhWBD2X9cNDc0tj2Bt8m8CFOZ7sYGk1hBgD7L0bjJIh3/6zbcD8AXz9 vbqZdhYJ5owc3Abu+bZH+PMxNqrmwBOcIPpbUQJYtzjeKRKUpVCigAUWYTKjiAY2D4h8 q7glDIfHYkvNWGAAtC50M716v3IjVoA18BMA7hlEhb5J022wgLT7zzTg2XgxXCMEmgSr S2ADofo8Fwrr4vwpIvj7zhpfOvG7JR4ATHn4wfgCJlxvT+GOBxNh+AE+ntR59AbOeXng guLA6/YoY6EHsi9+wM4nTuAbhEka6HE3J59kT2rtZ7ubGpfRRGT2dtM4A4xAEm8a7J6j FeBg== X-Gm-Message-State: AOJu0YwZWfiTZbb8gEEYWwmp009fyk4cxe2BTZKGbZSYl9QUapp5d5JJ H7GAV7NJOsrY80qXOaY3LiugrSLkbEZemuT04SRA+zvnv4/YKYYw9LvcPU4hgAFTO9U6DAawIdm UMxk= X-Gm-Gg: ASbGncv476KZln3z4gevf1WSsjag/mtkBxRVflgKlOOd/NGIu5xA+20mXrzmpe9HW0S K+Jghylw5bMt+z1X6SyXi0dWxxubHZlrBZ/Ozw7Ul4Ydhq3DvI261A3ARrQD/ZRc8Atrf4qZrxu DacLkOdWdyOCgldm6ugmRNvDQ+77mHrXPcbO+xnJhPd45pu/21clWQgjHbZLJDXNo7KK81B5ZhT 83Jk9YgIb722u/V5QwXBd6cLglY019el8Ea0chlQLI1BRVbpGjLVj0iiPbdbAa6pd8LVfzGmm0n 40ljjg3+26+YJY9rVZ+uB7wx 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-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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); /* Return log buffer size */ u32 log_buf_len_get(void) { return log_buf_len; } +EXPORT_SYMBOL_GPL(log_buf_len_get); /* * Define how much of the log buffer we could take at maximum. The value From patchwork Mon Feb 17 10:17:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 866219 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 902AD219A8B for ; Mon, 17 Feb 2025 10:18:01 +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=1739787484; cv=none; b=CwSuvbs8YxAmSicSlD2nUuDB7NJ8PqwN1WGntIXV36uEeBM34OB+Cu7RP6y/Se+gApKg3a5pMEmkT9m4d0Q9h+MoGHVpM88d6KJ9MUnFGVXum1auobmTcRZK9T9BBCZcRJ/3sQtD8DlR5Ei2QAXIW4gVRa3psaX7k0TjT2rSrp4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739787484; c=relaxed/simple; bh=CNpLokpmqxK7vPDH6UkXrNYj7YYXuynUbdaQ5h4wAQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E9tFN8913Fh8T7qekLrmkFxL8+qq+NGALX6YzmpRjJha/9qVxSgoDocNX7o5t6ccdI+rWtauxY5Iuw1hgshs39nKQ5HCXatjGRXSmT69XA4d4Spls+fBUJ90wIxJQwtIL/rvqlSwwyjX2tLnAthDluIoxy6913/fFmZkbjHWKYU= 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.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="pc5mzDyn" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-aaf0f1adef8so838880366b.3 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=pfpK7zjQxQxqxdWPsaCTSwgzVDeA3xTLbk+LeqTIbjdUAiqWBvtGx/3TN9Iffqgmt6 i6SDddHvgClUOgXo89zJ4yZH93y+G3v6YQzNMyjeoFnh0xJc5qg1mgoRRwBthzATRQmb XR6Rj8kmeEisWgP5vF4xf3YGorvTl1XfWncAcGSAYEYCHzPi1CZaKkKx0eBs3DEXub+y s7LeNjLJhmCB1cJh2UOxCgSfpOz4SK0thfSe9aGKX7sbxhe7ojGF+B1+AVD3mYeOEBoM k9lswLDrBA07dpC5AG1Mv3Y3sEyhWdQoQkAhHfWGUN5pXmTzRuVW+Nbfm8TspcMnuRrL C3hg== X-Gm-Message-State: AOJu0YyMiWHVM3pnBtBKdMRB4FhejXyvJyVDUL4qpWnDBpzMTgeep3q4 P1CYonVHti7Kiu7TFSW/feG8Va2S+DnJDdRcO4qToa07Q2isEgKze5omUeKT8KWGx1uEnusivM8 Pmb4= X-Gm-Gg: ASbGncvwvXaww2tUPdZvJO4BLajXJRJokekQKfkoGva+a1MijiNlq3Lm1R8NGa8ljQX s4LOyNfJKRWvz4bYdX0hUwse1jvwTMia3XEFuZQtCdK60I1XwzcpEbif6H3s5XDy68G4Ma9RENO VAQYG757eMWfpF1zsxoRZ7STEtdcPjQrV5IkjUBlT+X5MPKKV7CXQVMb39envQjDK9g0tgAAqyd stbsplWHHE/pV4ilLJtGvo5aQVDlxo8ySVbEwwbH3yUUFFBCp2y9GTontHih9ToRpeI5af2G+jR W3vWJiJjo4kUALGQDhpIUswi 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-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 *dev) return container_of(dev, struct devcd_entry, devcd_dev); } +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 = 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 scatterlist *table, size_t datalen, gfp_t gfp); 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)