cregit-Linux how code gets into the kernel

Release 4.14 arch/s390/kernel/os_info.c

Directory: arch/s390/kernel
// SPDX-License-Identifier: GPL-2.0
/*
 * OS info memory interface
 *
 * Copyright IBM Corp. 2012
 * Author(s): Michael Holzheu <holzheu@linux.vnet.ibm.com>
 */


#define KMSG_COMPONENT "os_info"

#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt

#include <linux/crash_dump.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <asm/checksum.h>
#include <asm/lowcore.h>
#include <asm/os_info.h>

/*
 * OS info structure has to be page aligned
 */

static struct os_info os_info __page_aligned_data;

/*
 * Compute checksum over OS info structure
 */

u32 os_info_csum(struct os_info *os_info) { int size = sizeof(*os_info) - offsetof(struct os_info, version_major); return (__force u32)csum_partial(&os_info->version_major, size, 0); }

Contributors

PersonTokensPropCommitsCommitProp
Michael Holzheu4090.91%150.00%
Heiko Carstens49.09%150.00%
Total44100.00%2100.00%

/* * Add crashkernel info to OS info and update checksum */
void os_info_crashkernel_add(unsigned long base, unsigned long size) { os_info.crashkernel_addr = (u64)(unsigned long)base; os_info.crashkernel_size = (u64)(unsigned long)size; os_info.csum = os_info_csum(&os_info); }

Contributors

PersonTokensPropCommitsCommitProp
Michael Holzheu49100.00%1100.00%
Total49100.00%1100.00%

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

Contributors

PersonTokensPropCommitsCommitProp
Michael Holzheu7294.74%150.00%
Heiko Carstens45.26%150.00%
Total76100.00%2100.00%

/* * Initialize OS info struture and set lowcore pointer */
void __init os_info_init(void) { void *ptr = &os_info; os_info.version_major = OS_INFO_VERSION_MAJOR; os_info.version_minor = OS_INFO_VERSION_MINOR; os_info.magic = OS_INFO_MAGIC; os_info.csum = os_info_csum(&os_info); mem_assign_absolute(S390_lowcore.os_info, (unsigned long) ptr); }

Contributors

PersonTokensPropCommitsCommitProp
Michael Holzheu5191.07%150.00%
Heiko Carstens58.93%150.00%
Total56100.00%2100.00%

#ifdef CONFIG_CRASH_DUMP static struct os_info *os_info_old; /* * Allocate and copy OS info entry from oldmem */
static void os_info_old_alloc(int nr, int align) { unsigned long addr, size = 0; char *buf, *buf_align, *msg; u32 csum; addr = os_info_old->entry[nr].addr; if (!addr) { msg = "not available"; goto fail; } size = os_info_old->entry[nr].size; buf = kmalloc(size + align - 1, GFP_KERNEL); if (!buf) { msg = "alloc failed"; goto fail; } buf_align = PTR_ALIGN(buf, align); if (copy_oldmem_kernel(buf_align, (void *) addr, size)) { msg = "copy failed"; goto fail_free; } csum = (__force u32)csum_partial(buf_align, size, 0); if (csum != os_info_old->entry[nr].csum) { msg = "checksum failed"; goto fail_free; } os_info_old->entry[nr].addr = (u64)(unsigned long)buf_align; msg = "copied"; goto out; fail_free: kfree(buf); fail: os_info_old->entry[nr].addr = 0; out: pr_info("entry %i: %s (addr=0x%lx size=%lu)\n", nr, msg, addr, size); }

Contributors

PersonTokensPropCommitsCommitProp
Michael Holzheu22197.79%133.33%
Heiko Carstens41.77%133.33%
Martin Schwidefsky10.44%133.33%
Total226100.00%3100.00%

/* * Initialize os info and os info entries from oldmem */
static void os_info_old_init(void) { static int os_info_init; unsigned long addr; if (os_info_init) return; if (!OLDMEM_BASE) goto fail; if (copy_oldmem_kernel(&addr, &S390_lowcore.os_info, sizeof(addr))) goto fail; if (addr == 0 || addr % PAGE_SIZE) goto fail; os_info_old = kzalloc(sizeof(*os_info_old), GFP_KERNEL); if (!os_info_old) goto fail; if (copy_oldmem_kernel(os_info_old, (void *) addr, sizeof(*os_info_old))) goto fail_free; if (os_info_old->magic != OS_INFO_MAGIC) goto fail_free; if (os_info_old->csum != os_info_csum(os_info_old)) goto fail_free; if (os_info_old->version_major > OS_INFO_VERSION_MAJOR) goto fail_free; os_info_old_alloc(OS_INFO_VMCOREINFO, 1); os_info_old_alloc(OS_INFO_REIPL_BLOCK, 1); pr_info("crashkernel: addr=0x%lx size=%lu\n", (unsigned long) os_info_old->crashkernel_addr, (unsigned long) os_info_old->crashkernel_size); os_info_init = 1; return; fail_free: kfree(os_info_old); fail: os_info_init = 1; os_info_old = NULL; }

Contributors

PersonTokensPropCommitsCommitProp
Michael Holzheu19798.99%150.00%
Martin Schwidefsky21.01%150.00%
Total199100.00%2100.00%

/* * Return pointer to os infor entry and its size */
void *os_info_old_entry(int nr, unsigned long *size) { os_info_old_init(); if (!os_info_old) return NULL; if (!os_info_old->entry[nr].addr) return NULL; *size = (unsigned long) os_info_old->entry[nr].size; return (void *)(unsigned long)os_info_old->entry[nr].addr; }

Contributors

PersonTokensPropCommitsCommitProp
Michael Holzheu74100.00%1100.00%
Total74100.00%1100.00%

#endif

Overall Contributors

PersonTokensPropCommitsCommitProp
Michael Holzheu75696.92%116.67%
Heiko Carstens172.18%233.33%
Martin Schwidefsky30.38%116.67%
David Howells30.38%116.67%
Greg Kroah-Hartman10.13%116.67%
Total780100.00%6100.00%
Directory: arch/s390/kernel
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.