arch/s390/kernel/nmi.c
Source file repositories/reference/linux-study-clean/arch/s390/kernel/nmi.c
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/kernel/nmi.c- Extension
.c- Size
- 14373 bytes
- Lines
- 515
- Domain
- Architecture Layer
- Bucket
- arch/s390
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel_stat.hlinux/utsname.hlinux/cpufeature.hlinux/init.hlinux/errno.hlinux/entry-common.hlinux/hardirq.hlinux/log2.hlinux/kprobes.hlinux/kmemleak.hlinux/time.hlinux/module.hlinux/sched/signal.hlinux/kvm_host.hasm/entry-percpu.hasm/lowcore.hasm/ctlreg.hasm/fpu.hasm/smp.hasm/stp.hasm/cputime.hasm/nmi.hasm/crw.hasm/asm-offsets.hasm/pai.hasm/vtime.h
Detected Declarations
struct mcck_structfunction nmi_needs_mcesafunction nmi_alloc_mcesa_earlyfunction nmi_alloc_mcesafunction nmi_free_mcesafunction nmi_print_infofunction s390_handle_damagefunction s390_handle_mcckfunction ctl_clear_bitfunction nmi_registers_validfunction s390_backup_mcck_infofunction s390_do_machine_checkfunction machine_check_init
Annotated Snippet
struct mcck_struct {
unsigned int kill_task : 1;
unsigned int channel_report : 1;
unsigned int warning : 1;
unsigned int stp_queue : 1;
unsigned long mcck_code;
};
static DEFINE_PER_CPU(struct mcck_struct, cpu_mcck);
static inline int nmi_needs_mcesa(void)
{
return cpu_has_vx() || cpu_has_gs();
}
/*
* The initial machine check extended save area for the boot CPU.
* It will be replaced on the boot CPU reinit with an allocated
* structure. The structure is required for machine check happening
* early in the boot process.
*/
static struct mcesa boot_mcesa __aligned(MCESA_MAX_SIZE);
void __init nmi_alloc_mcesa_early(u64 *mcesad)
{
if (!nmi_needs_mcesa())
return;
*mcesad = __pa(&boot_mcesa);
if (cpu_has_gs())
*mcesad |= ilog2(MCESA_MAX_SIZE);
}
int nmi_alloc_mcesa(u64 *mcesad)
{
unsigned long size;
void *origin;
*mcesad = 0;
if (!nmi_needs_mcesa())
return 0;
size = cpu_has_gs() ? MCESA_MAX_SIZE : MCESA_MIN_SIZE;
origin = kmalloc(size, GFP_KERNEL);
if (!origin)
return -ENOMEM;
/* The pointer is stored with mcesa_bits ORed in */
kmemleak_not_leak(origin);
*mcesad = __pa(origin);
if (cpu_has_gs())
*mcesad |= ilog2(MCESA_MAX_SIZE);
return 0;
}
void nmi_free_mcesa(u64 *mcesad)
{
if (!nmi_needs_mcesa())
return;
kfree(__va(*mcesad & MCESA_ORIGIN_MASK));
}
static __always_inline char *nmi_puts(char *dest, const char *src)
{
while (*src)
*dest++ = *src++;
*dest = 0;
return dest;
}
static __always_inline char *u64_to_hex(char *dest, u64 val)
{
int i, num;
for (i = 1; i <= 16; i++) {
num = (val >> (64 - 4 * i)) & 0xf;
if (num >= 10)
*dest++ = 'A' + num - 10;
else
*dest++ = '0' + num;
}
*dest = 0;
return dest;
}
static notrace void nmi_print_info(void)
{
struct lowcore *lc = get_lowcore();
char message[100];
char *ptr;
int i;
ptr = nmi_puts(message, "Unrecoverable machine check, code: ");
Annotation
- Immediate include surface: `linux/kernel_stat.h`, `linux/utsname.h`, `linux/cpufeature.h`, `linux/init.h`, `linux/errno.h`, `linux/entry-common.h`, `linux/hardirq.h`, `linux/log2.h`.
- Detected declarations: `struct mcck_struct`, `function nmi_needs_mcesa`, `function nmi_alloc_mcesa_early`, `function nmi_alloc_mcesa`, `function nmi_free_mcesa`, `function nmi_print_info`, `function s390_handle_damage`, `function s390_handle_mcck`, `function ctl_clear_bit`, `function nmi_registers_valid`.
- Atlas domain: Architecture Layer / arch/s390.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.