Skip to content

Commit

Permalink
s390/os_info: Introduce value entries
Browse files Browse the repository at this point in the history
Introduce entries that do not reference any data in memory,
but rather provide values. Set the size of such entries to
zero and do not compute checksum for them, since there is no
data which integrity needs to be checked. The integrity of
the value entries itself is still covered by the os_info
checksum.

Reserve the lowest unused entry index OS_INFO_RESERVED for
future use - presumably for the number of entries present.
That could later be used by user level tools. The existing
tools would not notice any difference.

Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
  • Loading branch information
Alexander Gordeev committed Apr 17, 2024
1 parent 5fb50fa commit 8870279
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
19 changes: 15 additions & 4 deletions arch/s390/include/asm/os_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
#define OS_INFO_VMCOREINFO 0
#define OS_INFO_REIPL_BLOCK 1
#define OS_INFO_FLAGS_ENTRY 2
#define OS_INFO_RESERVED 3

#define OS_INFO_FLAG_REIPL_CLEAR (1UL << 0)

struct os_info_entry {
u64 addr;
union {
u64 addr;
u64 val;
};
u64 size;
u32 csum;
} __packed;
Expand All @@ -33,17 +37,24 @@ struct os_info {
u16 version_minor;
u64 crashkernel_addr;
u64 crashkernel_size;
struct os_info_entry entry[3];
u8 reserved[4004];
struct os_info_entry entry[4];
u8 reserved[3984];
} __packed;

void os_info_init(void);
void os_info_entry_add(int nr, void *ptr, u64 len);
void os_info_entry_add_data(int nr, void *ptr, u64 len);
void os_info_entry_add_val(int nr, u64 val);
void os_info_crashkernel_add(unsigned long base, unsigned long size);
u32 os_info_csum(struct os_info *os_info);

#ifdef CONFIG_CRASH_DUMP
void *os_info_old_entry(int nr, unsigned long *size);
static inline unsigned long os_info_old_value(int nr)
{
unsigned long size;

return (unsigned long)os_info_old_entry(nr, &size);
}
#else
static inline void *os_info_old_entry(int nr, unsigned long *size)
{
Expand Down
6 changes: 3 additions & 3 deletions arch/s390/kernel/ipl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1209,8 +1209,8 @@ static struct attribute_group reipl_nss_attr_group = {

void set_os_info_reipl_block(void)
{
os_info_entry_add(OS_INFO_REIPL_BLOCK, reipl_block_actual,
reipl_block_actual->hdr.len);
os_info_entry_add_data(OS_INFO_REIPL_BLOCK, reipl_block_actual,
reipl_block_actual->hdr.len);
}

/* reipl type */
Expand Down Expand Up @@ -1940,7 +1940,7 @@ static void dump_reipl_run(struct shutdown_trigger *trigger)
reipl_type == IPL_TYPE_NSS ||
reipl_type == IPL_TYPE_UNKNOWN)
os_info_flags |= OS_INFO_FLAG_REIPL_CLEAR;
os_info_entry_add(OS_INFO_FLAGS_ENTRY, &os_info_flags, sizeof(os_info_flags));
os_info_entry_add_data(OS_INFO_FLAGS_ENTRY, &os_info_flags, sizeof(os_info_flags));
csum = (__force unsigned int)cksm(reipl_block_actual, reipl_block_actual->hdr.len, 0);
abs_lc = get_abs_lowcore();
abs_lc->ipib = __pa(reipl_block_actual);
Expand Down
15 changes: 13 additions & 2 deletions arch/s390/kernel/os_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,27 @@ void os_info_crashkernel_add(unsigned long base, unsigned long size)
}

/*
* Add OS info entry and update checksum
* Add OS info data entry and update checksum
*/
void os_info_entry_add(int nr, void *ptr, u64 size)
void os_info_entry_add_data(int nr, void *ptr, u64 size)
{
os_info.entry[nr].addr = __pa(ptr);
os_info.entry[nr].size = size;
os_info.entry[nr].csum = (__force u32)cksm(ptr, size, 0);
os_info.csum = os_info_csum(&os_info);
}

/*
* Add OS info value entry and update checksum
*/
void os_info_entry_add_val(int nr, u64 value)
{
os_info.entry[nr].val = value;
os_info.entry[nr].size = 0;
os_info.entry[nr].csum = 0;
os_info.csum = os_info_csum(&os_info);
}

/*
* Initialize OS info structure and set lowcore pointer
*/
Expand Down

0 comments on commit 8870279

Please sign in to comment.