Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pstore/ram: Move internal definitions out of kernel-wide include

Most of the details of the ram backend are entirely internal to the
backend itself. Leave only what is needed to instantiate a ram backend
in the kernel-wide header.

Cc: Anton Vorontsov <anton@enomsg.org>
Cc: Colin Cross <ccross@android.com>
Cc: Tony Luck <tony.luck@intel.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-and-tested-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Link: https://lore.kernel.org/r/20221011200112.731334-4-keescook@chromium.org

+102 -101
+2 -1
fs/pstore/ram.c
··· 18 18 #include <linux/platform_device.h> 19 19 #include <linux/slab.h> 20 20 #include <linux/compiler.h> 21 - #include <linux/pstore_ram.h> 22 21 #include <linux/of.h> 23 22 #include <linux/of_address.h> 23 + 24 24 #include "internal.h" 25 + #include "ram_internal.h" 25 26 26 27 #define RAMOOPS_KERNMSG_HDR "====" 27 28 #define MIN_MEM_SIZE 4096UL
+2 -1
fs/pstore/ram_core.c
··· 13 13 #include <linux/kernel.h> 14 14 #include <linux/list.h> 15 15 #include <linux/memblock.h> 16 - #include <linux/pstore_ram.h> 17 16 #include <linux/rslib.h> 18 17 #include <linux/slab.h> 19 18 #include <linux/uaccess.h> 20 19 #include <linux/vmalloc.h> 21 20 #include <asm/page.h> 21 + 22 + #include "ram_internal.h" 22 23 23 24 /** 24 25 * struct persistent_ram_buffer - persistent circular RAM buffer
+98
fs/pstore/ram_internal.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Copyright (C) 2010 Marco Stornelli <marco.stornelli@gmail.com> 4 + * Copyright (C) 2011 Kees Cook <keescook@chromium.org> 5 + * Copyright (C) 2011 Google, Inc. 6 + */ 7 + 8 + #include <linux/pstore_ram.h> 9 + 10 + /* 11 + * Choose whether access to the RAM zone requires locking or not. If a zone 12 + * can be written to from different CPUs like with ftrace for example, then 13 + * PRZ_FLAG_NO_LOCK is used. For all other cases, locking is required. 14 + */ 15 + #define PRZ_FLAG_NO_LOCK BIT(0) 16 + /* 17 + * If a PRZ should only have a single-boot lifetime, this marks it as 18 + * getting wiped after its contents get copied out after boot. 19 + */ 20 + #define PRZ_FLAG_ZAP_OLD BIT(1) 21 + 22 + /** 23 + * struct persistent_ram_zone - Details of a persistent RAM zone (PRZ) 24 + * used as a pstore backend 25 + * 26 + * @paddr: physical address of the mapped RAM area 27 + * @size: size of mapping 28 + * @label: unique name of this PRZ 29 + * @type: frontend type for this PRZ 30 + * @flags: holds PRZ_FLAGS_* bits 31 + * 32 + * @buffer_lock: 33 + * locks access to @buffer "size" bytes and "start" offset 34 + * @buffer: 35 + * pointer to actual RAM area managed by this PRZ 36 + * @buffer_size: 37 + * bytes in @buffer->data (not including any trailing ECC bytes) 38 + * 39 + * @par_buffer: 40 + * pointer into @buffer->data containing ECC bytes for @buffer->data 41 + * @par_header: 42 + * pointer into @buffer->data containing ECC bytes for @buffer header 43 + * (i.e. all fields up to @data) 44 + * @rs_decoder: 45 + * RSLIB instance for doing ECC calculations 46 + * @corrected_bytes: 47 + * ECC corrected bytes accounting since boot 48 + * @bad_blocks: 49 + * ECC uncorrectable bytes accounting since boot 50 + * @ecc_info: 51 + * ECC configuration details 52 + * 53 + * @old_log: 54 + * saved copy of @buffer->data prior to most recent wipe 55 + * @old_log_size: 56 + * bytes contained in @old_log 57 + * 58 + */ 59 + struct persistent_ram_zone { 60 + phys_addr_t paddr; 61 + size_t size; 62 + void *vaddr; 63 + char *label; 64 + enum pstore_type_id type; 65 + u32 flags; 66 + 67 + raw_spinlock_t buffer_lock; 68 + struct persistent_ram_buffer *buffer; 69 + size_t buffer_size; 70 + 71 + char *par_buffer; 72 + char *par_header; 73 + struct rs_control *rs_decoder; 74 + int corrected_bytes; 75 + int bad_blocks; 76 + struct persistent_ram_ecc_info ecc_info; 77 + 78 + char *old_log; 79 + size_t old_log_size; 80 + }; 81 + 82 + struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size, 83 + u32 sig, struct persistent_ram_ecc_info *ecc_info, 84 + unsigned int memtype, u32 flags, char *label); 85 + void persistent_ram_free(struct persistent_ram_zone *prz); 86 + void persistent_ram_zap(struct persistent_ram_zone *prz); 87 + 88 + int persistent_ram_write(struct persistent_ram_zone *prz, const void *s, 89 + unsigned int count); 90 + int persistent_ram_write_user(struct persistent_ram_zone *prz, 91 + const void __user *s, unsigned int count); 92 + 93 + void persistent_ram_save_old(struct persistent_ram_zone *prz); 94 + size_t persistent_ram_old_size(struct persistent_ram_zone *prz); 95 + void *persistent_ram_old(struct persistent_ram_zone *prz); 96 + void persistent_ram_free_old(struct persistent_ram_zone *prz); 97 + ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz, 98 + char *str, size_t len);
-99
include/linux/pstore_ram.h
··· 8 8 #ifndef __LINUX_PSTORE_RAM_H__ 9 9 #define __LINUX_PSTORE_RAM_H__ 10 10 11 - #include <linux/compiler.h> 12 - #include <linux/device.h> 13 - #include <linux/init.h> 14 - #include <linux/kernel.h> 15 - #include <linux/list.h> 16 11 #include <linux/pstore.h> 17 - #include <linux/types.h> 18 - 19 - /* 20 - * Choose whether access to the RAM zone requires locking or not. If a zone 21 - * can be written to from different CPUs like with ftrace for example, then 22 - * PRZ_FLAG_NO_LOCK is used. For all other cases, locking is required. 23 - */ 24 - #define PRZ_FLAG_NO_LOCK BIT(0) 25 - /* 26 - * If a PRZ should only have a single-boot lifetime, this marks it as 27 - * getting wiped after its contents get copied out after boot. 28 - */ 29 - #define PRZ_FLAG_ZAP_OLD BIT(1) 30 - 31 - struct persistent_ram_buffer; 32 - struct rs_control; 33 12 34 13 struct persistent_ram_ecc_info { 35 14 int block_size; ··· 17 38 int poly; 18 39 uint16_t *par; 19 40 }; 20 - 21 - /** 22 - * struct persistent_ram_zone - Details of a persistent RAM zone (PRZ) 23 - * used as a pstore backend 24 - * 25 - * @paddr: physical address of the mapped RAM area 26 - * @size: size of mapping 27 - * @label: unique name of this PRZ 28 - * @type: frontend type for this PRZ 29 - * @flags: holds PRZ_FLAGS_* bits 30 - * 31 - * @buffer_lock: 32 - * locks access to @buffer "size" bytes and "start" offset 33 - * @buffer: 34 - * pointer to actual RAM area managed by this PRZ 35 - * @buffer_size: 36 - * bytes in @buffer->data (not including any trailing ECC bytes) 37 - * 38 - * @par_buffer: 39 - * pointer into @buffer->data containing ECC bytes for @buffer->data 40 - * @par_header: 41 - * pointer into @buffer->data containing ECC bytes for @buffer header 42 - * (i.e. all fields up to @data) 43 - * @rs_decoder: 44 - * RSLIB instance for doing ECC calculations 45 - * @corrected_bytes: 46 - * ECC corrected bytes accounting since boot 47 - * @bad_blocks: 48 - * ECC uncorrectable bytes accounting since boot 49 - * @ecc_info: 50 - * ECC configuration details 51 - * 52 - * @old_log: 53 - * saved copy of @buffer->data prior to most recent wipe 54 - * @old_log_size: 55 - * bytes contained in @old_log 56 - * 57 - */ 58 - struct persistent_ram_zone { 59 - phys_addr_t paddr; 60 - size_t size; 61 - void *vaddr; 62 - char *label; 63 - enum pstore_type_id type; 64 - u32 flags; 65 - 66 - raw_spinlock_t buffer_lock; 67 - struct persistent_ram_buffer *buffer; 68 - size_t buffer_size; 69 - 70 - char *par_buffer; 71 - char *par_header; 72 - struct rs_control *rs_decoder; 73 - int corrected_bytes; 74 - int bad_blocks; 75 - struct persistent_ram_ecc_info ecc_info; 76 - 77 - char *old_log; 78 - size_t old_log_size; 79 - }; 80 - 81 - struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size, 82 - u32 sig, struct persistent_ram_ecc_info *ecc_info, 83 - unsigned int memtype, u32 flags, char *label); 84 - void persistent_ram_free(struct persistent_ram_zone *prz); 85 - void persistent_ram_zap(struct persistent_ram_zone *prz); 86 - 87 - int persistent_ram_write(struct persistent_ram_zone *prz, const void *s, 88 - unsigned int count); 89 - int persistent_ram_write_user(struct persistent_ram_zone *prz, 90 - const void __user *s, unsigned int count); 91 - 92 - void persistent_ram_save_old(struct persistent_ram_zone *prz); 93 - size_t persistent_ram_old_size(struct persistent_ram_zone *prz); 94 - void *persistent_ram_old(struct persistent_ram_zone *prz); 95 - void persistent_ram_free_old(struct persistent_ram_zone *prz); 96 - ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz, 97 - char *str, size_t len); 98 41 99 42 /* 100 43 * Ramoops platform data