cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

crash_core.h (3465B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2#ifndef LINUX_CRASH_CORE_H
      3#define LINUX_CRASH_CORE_H
      4
      5#include <linux/linkage.h>
      6#include <linux/elfcore.h>
      7#include <linux/elf.h>
      8
      9#define CRASH_CORE_NOTE_NAME	   "CORE"
     10#define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
     11#define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(CRASH_CORE_NOTE_NAME), 4)
     12#define CRASH_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
     13
     14/*
     15 * The per-cpu notes area is a list of notes terminated by a "NULL"
     16 * note header.  For kdump, the code in vmcore.c runs in the context
     17 * of the second kernel to combine them into one note.
     18 */
     19#define CRASH_CORE_NOTE_BYTES	   ((CRASH_CORE_NOTE_HEAD_BYTES * 2) +	\
     20				     CRASH_CORE_NOTE_NAME_BYTES +	\
     21				     CRASH_CORE_NOTE_DESC_BYTES)
     22
     23#define VMCOREINFO_BYTES	   PAGE_SIZE
     24#define VMCOREINFO_NOTE_NAME	   "VMCOREINFO"
     25#define VMCOREINFO_NOTE_NAME_BYTES ALIGN(sizeof(VMCOREINFO_NOTE_NAME), 4)
     26#define VMCOREINFO_NOTE_SIZE	   ((CRASH_CORE_NOTE_HEAD_BYTES * 2) +	\
     27				     VMCOREINFO_NOTE_NAME_BYTES +	\
     28				     VMCOREINFO_BYTES)
     29
     30typedef u32 note_buf_t[CRASH_CORE_NOTE_BYTES/4];
     31
     32void crash_update_vmcoreinfo_safecopy(void *ptr);
     33void crash_save_vmcoreinfo(void);
     34void arch_crash_save_vmcoreinfo(void);
     35__printf(1, 2)
     36void vmcoreinfo_append_str(const char *fmt, ...);
     37phys_addr_t paddr_vmcoreinfo_note(void);
     38
     39#define VMCOREINFO_OSRELEASE(value) \
     40	vmcoreinfo_append_str("OSRELEASE=%s\n", value)
     41#define VMCOREINFO_BUILD_ID()						\
     42	({								\
     43		static_assert(sizeof(vmlinux_build_id) == 20);		\
     44		vmcoreinfo_append_str("BUILD-ID=%20phN\n", vmlinux_build_id); \
     45	})
     46
     47#define VMCOREINFO_PAGESIZE(value) \
     48	vmcoreinfo_append_str("PAGESIZE=%ld\n", value)
     49#define VMCOREINFO_SYMBOL(name) \
     50	vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name)
     51#define VMCOREINFO_SYMBOL_ARRAY(name) \
     52	vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)name)
     53#define VMCOREINFO_SIZE(name) \
     54	vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \
     55			      (unsigned long)sizeof(name))
     56#define VMCOREINFO_STRUCT_SIZE(name) \
     57	vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \
     58			      (unsigned long)sizeof(struct name))
     59#define VMCOREINFO_OFFSET(name, field) \
     60	vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \
     61			      (unsigned long)offsetof(struct name, field))
     62#define VMCOREINFO_TYPE_OFFSET(name, field) \
     63	vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \
     64			      (unsigned long)offsetof(name, field))
     65#define VMCOREINFO_LENGTH(name, value) \
     66	vmcoreinfo_append_str("LENGTH(%s)=%lu\n", #name, (unsigned long)value)
     67#define VMCOREINFO_NUMBER(name) \
     68	vmcoreinfo_append_str("NUMBER(%s)=%ld\n", #name, (long)name)
     69#define VMCOREINFO_CONFIG(name) \
     70	vmcoreinfo_append_str("CONFIG_%s=y\n", #name)
     71
     72extern unsigned char *vmcoreinfo_data;
     73extern size_t vmcoreinfo_size;
     74extern u32 *vmcoreinfo_note;
     75
     76Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type,
     77			  void *data, size_t data_len);
     78void final_note(Elf_Word *buf);
     79
     80int __init parse_crashkernel(char *cmdline, unsigned long long system_ram,
     81		unsigned long long *crash_size, unsigned long long *crash_base);
     82int parse_crashkernel_high(char *cmdline, unsigned long long system_ram,
     83		unsigned long long *crash_size, unsigned long long *crash_base);
     84int parse_crashkernel_low(char *cmdline, unsigned long long system_ram,
     85		unsigned long long *crash_size, unsigned long long *crash_base);
     86
     87#endif /* LINUX_CRASH_CORE_H */