Projectname
large_stringclasses
15 values
Filepath
large_stringlengths
4
106
⌀
Function
large_stringlengths
11
3.45k
Label
list
Linux Kernel
arch/um/os-Linux/irq.c
int os_epoll_triggered(int index, int events) { return epoll_events[index].events & events; }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/irq.c
int os_del_epoll_fd(int fd) { struct epoll_event event; int result; result = epoll_ctl(epollfd, EPOLL_CTL_DEL, fd, &event); return result; }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/irq.c
void os_set_ioignore(void) { signal(SIGIO, SIG_IGN); }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/main.c
static void last_ditch_exit(int sig) { uml_cleanup(); exit(1); }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/main.c
static void install_fatal_handler(int sig) { struct sigaction action; sigemptyset(&action.sa_mask); /* * ... including the signal being handled, plus we want the * handler reset to the default behavior, so that if an exit * handler is hanging for some reason, the UML will just die * after this signa...
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/main.c
int __init main(int argc, char **argv, char **envp) { char **new_argv; int ret, i, err; set_stklim(); setup_env_path(); setsid(); new_argv = malloc((argc + 1) * sizeof(char *)); if (new_argv == NULL) { perror("Mallocing argv"); exit(1); } for (i = 0; i < argc; i++) { new_argv[i] = strd...
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/mem.c
void kasan_map_memory(void *start, size_t len) { if (mmap(start, len, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, -1, 0) == MAP_FAILED) { os_info("Couldn't allocate shadow memory: %s\n.", strerror(errno)); exit(1); } }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/mem.c
int __init create_mem_file(unsigned long long len) { int err, fd; fd = create_tmp_file(len); err = os_set_exec_close(fd); if (err < 0) { errno = -err; perror("exec_close"); } return fd; }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/process.c
int os_map_memory(void *virt, int fd, unsigned long long off, unsigned long len, int r, int w, int x) { void *loc; int prot; prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) | (x ? PROT_EXEC : 0); loc = mmap64((void *)virt, len, prot, MAP_SHARED | MAP_FIXED, fd, off); if (loc == MAP_FAIL...
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/registers.c
int restore_pid_registers(int pid, struct uml_pt_regs *regs) { int err; err = ptrace(PTRACE_SETREGS, pid, 0, regs->gp); if (err < 0) return -errno; return 0; }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/sigio.c
static void update_thread(void) { unsigned long flags; int n; char c; flags = um_set_signals_trace(0); CATCH_EINTR(n = write(sigio_private[0], &c, sizeof(c))); if (n != sizeof(c)) { printk(UM_KERN_ERR "update_thread : write failed, err = %d\n", errno); goto fail; } CATCH_EINTR(n = read(sigio_p...
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/sigio.c
int __ignore_sigio_fd(int fd) { struct pollfd *p; int err, i, n = 0; if (write_sigio_pid == -1) return -EIO; for (i = 0; i < current_poll.used; i++) { if (current_poll.poll[i].fd == fd) break; } if (i == current_poll.used) return -ENOENT; err = need_poll(&next_poll, current_poll.used ...
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/sigio.c
static struct pollfd *setup_initial_poll(int fd) { struct pollfd *p; p = uml_kmalloc(sizeof(struct pollfd), UM_GFP_KERNEL); if (p == NULL) { printk(UM_KERN_ERR "setup_initial_poll : failed to allocate " "poll\n"); return NULL; } *p = ((struct pollfd){.fd = fd, .events = POLLIN...
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/sigio.c
static int async_pty(int master, int slave) { int flags; flags = fcntl(master, F_GETFL); if (flags < 0) return -errno; if ((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) || (fcntl(master, F_SETOWN, os_getpid()) < 0)) return -errno; if ((fcntl(slave, F_SETFL, flags | O_NONBLOCK) <...
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/signal.c
void sig_handler(int sig, struct siginfo *si, mcontext_t *mc) { int enabled = signals_enabled; if ((signals_blocked || !enabled) && (sig == SIGIO)) { if (!signals_blocked && time_travel_mode == TT_MODE_EXTERNAL) sigio_run_timetravel_handlers(); else signals_pending |= SIGIO_MASK; return; ...
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/signal.c
static void timer_real_alarm_handler(mcontext_t *mc) { struct uml_pt_regs regs; if (mc != NULL) get_regs_from_mc(&regs, mc); else memset(&regs, 0, sizeof(regs)); timer_handler(SIGALRM, NULL, &regs); }
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/signal.c
void deliver_alarm(void) { timer_alarm_handler(SIGALRM, NULL, NULL); }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/signal.c
void mark_sigio_pending(void) { signals_pending |= SIGIO_MASK; }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/signal.c
void block_signals_hard(void) { if (signals_blocked) return; signals_blocked = 1; barrier(); }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/skas/mem.c
static inline unsigned long *check_init_stack(struct mm_id *mm_idp, unsigned long *stack) { if (stack == NULL) { stack = (unsigned long *)mm_idp->stack + 2; *stack = 0; } return stack; }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/skas/mem.c
long run_syscall_stub(struct mm_id *mm_idp, int syscall, unsigned long *args, long expected, void **addr, int done) { unsigned long *stack = check_init_stack(mm_idp, *addr); *stack += sizeof(long); stack += *stack / sizeof(long); *stack++ = syscall; *stack++ = args[0]; *stack++ = ar...
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/skas/mem.c
int unmap(struct mm_id *mm_idp, unsigned long addr, unsigned long len, int done, void **data) { int ret; unsigned long args[] = {(unsigned long)addr, len, 0, 0, 0, 0}; ret = run_syscall_stub(mm_idp, __NR_munmap, args, 0, data, done); return ret; }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/skas/process.c
static const char *ptrace_reg_name(int idx) { #define R(n) \ case HOST_##n: \ return #n switch (idx) { #ifdef __x86_64__ R(BX); R(CX); R(DI); R(SI); R(DX); R(...
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/skas/process.c
static int ptrace_dump_regs(int pid) { unsigned long regs[MAX_REG_NR]; int i; if (ptrace(PTRACE_GETREGS, pid, 0, regs) < 0) return -errno; printk(UM_KERN_ERR "Stub registers -\n"); for (i = 0; i < ARRAY_SIZE(regs); i++) { const char *regname = ptrace_reg_name(i); printk(UM_KERN_ERR "\t%s\t(%2d)...
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/skas/process.c
static void handle_trap(int pid, struct uml_pt_regs *regs, int local_using_sysemu) { int err, status; if ((UPT_IP(regs) >= STUB_START) && (UPT_IP(regs) < STUB_END)) fatal_sigsegv(); if (!local_using_sysemu) { err = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET, __NR_getpid); ...
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/skas/process.c
static int userspace_tramp(void *stack) { void *addr; int fd; unsigned long long offset; ptrace(PTRACE_TRACEME, 0, 0, 0); signal(SIGTERM, SIG_DFL); signal(SIGWINCH, SIG_IGN); fd = phys_mapping(uml_to_phys(__syscall_stub_start), &offset); addr = mmap64((void *)STUB_CODE, UM_KERN_PAGE_SIZE, PROT_EXEC, ...
[ 1, 1 ]
Linux Kernel
arch/um/os-Linux/skas/process.c
static int __init init_thread_regs(void) { get_safe_registers(thread_regs, thread_fp_regs); thread_regs[REGS_IP_INDEX] = STUB_CODE + (unsigned long)stub_clone_handler - (unsigned long)__syscall_stub_start; thread_regs[REGS_SP_INDEX] = STUB_DATA + UM_KERN_PAGE_SIZE - sizeof(void *);...
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/skas/process.c
void new_thread(void *stack, jmp_buf *buf, void (*handler)(void)) { (*buf)[0].JB_IP = (unsigned long)handler; (*buf)[0].JB_SP = (unsigned long)stack + UM_THREAD_SIZE - sizeof(void *); }
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/skas/process.c
void switch_threads(jmp_buf *me, jmp_buf *you) { if (UML_SETJMP(me) == 0) UML_LONGJMP(you, 1); }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/start_up.c
static void ptrace_child(void) { int ret; int pid = os_getpid(), ppid = getppid(); int sc_result; if (change_sig(SIGWINCH, 0) < 0 || ptrace(PTRACE_TRACEME, 0, 0, 0) < 0) { perror("ptrace"); kill(pid, SIGKILL); } kill(pid, SIGSTOP); /* * This syscall will be intercepted by the parent. Don't c...
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/start_up.c
static void fatal(char *fmt, ...) { va_list list; va_start(list, fmt); vfprintf(stderr, fmt, list); va_end(list); exit(1); }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/start_up.c
static int __init nosysemu_cmd_param(char *str, int *add) { force_sysemu_disabled = 1; return 0; }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/start_up.c
static void __init check_coredump_limit(void) { struct rlimit lim; int err = getrlimit(RLIMIT_CORE, &lim); if (err) { perror("Getting core dump limit"); return; } os_info("Core dump limits :\n\tsoft - "); if (lim.rlim_cur == RLIM_INFINITY) os_info("NONE\n"); else os_info("%llu\n", (unsi...
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/start_up.c
void __init get_host_cpu_features(void (*flags_helper_func)(char *line), void (*cache_helper_func)(char *line)) { FILE *cpuinfo; char *line = NULL; size_t len = 0; int done_parsing = 0; cpuinfo = fopen("/proc/cpuinfo", "r"); if (cpuinfo == NULL) { os_info("Failed to g...
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/start_up.c
int __init parse_iomem(char *str, int *add) { struct iomem_region *new; struct stat64 buf; char *file, *driver; int fd, size; driver = str; file = strchr(str, ','); if (file == NULL) { os_warn("parse_iomem : failed to parse iomem\n"); goto out; } *file = '\0'; file++; fd = open(file, O_R...
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/time.c
static inline long long timespec_to_ns(const struct timespec *ts) { return ((long long)ts->tv_sec * UM_NSEC_PER_SEC) + ts->tv_nsec; }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/tty.c
int get_pty(void) { struct grantpt_info info; int fd, err; fd = open("/dev/ptmx", O_RDWR); if (fd < 0) { err = -errno; printk(UM_KERN_ERR "get_pty : Couldn't open /dev/ptmx - " "err = %d\n", errno); return err; } info.fd = fd; initial_thread_cb(grantpt_cb, ...
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/umid.c
static void __init create_pid_file(void) { char pid[sizeof("nnnnnnnnn")], *file; int fd, n; n = strlen(uml_dir) + UMID_LEN + sizeof("/pid"); file = malloc(n); if (!file) return; if (umid_file_name("pid", file, n)) goto out; fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0644); if (fd < 0) { ...
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/umid.c
int __init set_umid(char *name) { if (strlen(name) > UMID_LEN - 1) return -E2BIG; strlcpy(umid, name, sizeof(umid)); return 0; }
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/util.c
int raw(int fd) { struct termios tt; int err; CATCH_EINTR(err = tcgetattr(fd, &tt)); if (err < 0) return -errno; cfmakeraw(&tt); CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt)); if (err < 0) return -errno; /* * XXX tcsetattr could have applied only some changes * (and cfmakeraw() is a...
[ 0, 1 ]
Linux Kernel
arch/um/os-Linux/util.c
void setup_machinename(char *machine_out) { struct utsname host; uname(&host); #ifdef UML_CONFIG_UML_X86 #ifndef UML_CONFIG_64BIT if (!strcmp(host.machine, "x86_64")) { strcpy(machine_out, "i686"); return; } #else if (!strcmp(host.machine, "i686")) { strcpy(machine_out, "x86_64"); return; ...
[ 1, 0 ]
Linux Kernel
arch/um/os-Linux/util.c
void os_fix_helper_signals(void) { signal(SIGWINCH, SIG_IGN); signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); }
[ 0, 0 ]
Linux Kernel
arch/um/os-Linux/util.c
static int __init quiet_cmd_param(char *str, int *add) { quiet_info = 1; return 0; }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/a20.c
static int empty_8042(void) { u8 status; int loops = MAX_8042_LOOPS; int ffs = MAX_8042_FF; while (loops--) { io_delay(); status = inb(0x64); if (status == 0xff) { if (!--ffs) return -1; /* Assume no KBC present */ } if (status & 1) { /* Read and discard input data */ ...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/a20.c
static void enable_a20_fast(void) { u8 port_a; port_a = inb(0x92); port_a |= 0x02; /* Enable A20 */ port_a &= ~0x01; /* Do not reset machine */ outb(port_a, 0x92); } /* * Actual routine to enable A20; return 0 on ok, -1 on failure */
[ 1, 0 ]
Linux Kernel
arch/x86/boot/apm.c
int query_apm_bios(void) { struct biosregs ireg, oreg; initregs(&ireg); ireg.ah = 0x53; intcall(0x15, &ireg, &oreg); if (oreg.flags & X86_EFLAGS_CF) return -1; /* No APM BIOS */ if (oreg.bx != 0x504d) /* "PM" signature */ return -1; if (!(oreg.cx & 0x02)) /* 32 bits supported? */ return -1...
[ 1, 0 ]
Linux Kernel
arch/x86/boot/boot.h
static inline u16 fs(void) { u16 seg; asm volatile("movw %%fs,%0" : "=rm"(seg)); return seg; }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/boot.h
static inline u8 rdfs8(addr_t addr) { u8 *ptr = (u8 *)absolute_pointer(addr); u8 v; asm volatile("movb %%fs:%1,%0" : "=q"(v) : "m"(*ptr)); return v; }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/boot.h
static inline void wrfs32(u32 v, addr_t addr) { u32 *ptr = (u32 *)absolute_pointer(addr); asm volatile("movl %1,%%fs:%0" : "+m"(*ptr) : "ri"(v)); }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/boot.h
static inline char *__get_heap(size_t s, size_t a, size_t n) { char *tmp; HEAP = (char *)(((size_t)HEAP + (a - 1)) & ~(a - 1)); tmp = HEAP; HEAP += s * n; return tmp; } #define GET_HEAP(type, n) \ ((type *)__get_heap(sizeof(type), __alignof__(type), (n))...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/boot.h
static inline bool heap_free(size_t n) { return (int)(heap_end - HEAP) >= (int)n; }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/cmdline.c
int __cmdline_find_option_bool(unsigned long cmdline_ptr, const char *option) { addr_t cptr; char c; int pos = 0, wstart = 0; const char *opptr = NULL; enum { st_wordstart, st_wordcmp, /* Comparing this word */ st_wordskip, /* Miscompare, skip */ } state = st_wordstart; if (!cmdline_ptr) ...
[ 1, 0 ]
Linux Kernel
arch/x86/boot/compressed/acpi.c
int count_immovable_mem_regions(void) { unsigned long table_addr, table_end, table; struct acpi_subtable_header *sub_table; struct acpi_table_header *table_header; char arg[MAX_ACPI_ARG_LENGTH]; int num = 0; if (cmdline_find_option("acpi", arg, sizeof(arg)) == 3 && !strncmp(arg, "off", 3)) return...
[ 1, 0 ]
Linux Kernel
arch/x86/boot/compressed/cpuflags.c
bool has_cpuflag(int flag) { get_cpuflags(); return test_bit(flag, cpu.flags); }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/efi.c
unsigned long efi_get_system_table(struct boot_params *bp) { unsigned long sys_tbl_pa; struct efi_info *ei; enum efi_type et; ei = &bp->efi_info; #ifdef CONFIG_X86_64 sys_tbl_pa = ei->efi_systab | ((__u64)ei->efi_systab_hi << 32); #else sys_tbl_pa = ei->efi_systab; #endif if (!sys_tbl_pa) { debug_put...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/efi.c
int efi_get_conf_table(struct boot_params *bp, unsigned long *cfg_tbl_pa, unsigned int *cfg_tbl_len) { unsigned long sys_tbl_pa; enum efi_type et; int ret; if (!cfg_tbl_pa || !cfg_tbl_len) return -EINVAL; sys_tbl_pa = efi_get_system_table(bp); if (!sys_tbl_pa) return -EINVAL...
[ 1, 0 ]
Linux Kernel
arch/x86/boot/compressed/error.c
void warn(char *m) { error_putstr("\n\n"); error_putstr(m); error_putstr("\n\n"); }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/error.c
void error(char *m) { warn(m); error_putstr(" -- System halted"); while (1) asm("hlt"); }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/ident_map_64.c
void kernel_add_identity_map(unsigned long start, unsigned long end) { int ret; start = round_down(start, PMD_SIZE); end = round_up(end, PMD_SIZE); if (start >= end) return; /* Build the mapping. */ ret = kernel_ident_mapping_init(&mapping_info, (pgd_t *)top_level_pgt, start, ...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/ident_map_64.c
static pte_t *split_large_pmd(struct x86_mapping_info *info, pmd_t *pmdp, unsigned long __address) { unsigned long page_flags; unsigned long address; pte_t *pte; pmd_t pmd; int i; pte = (pte_t *)info->alloc_pgt_page(info->context); if (!pte) return NULL; address = __a...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/ident_map_64.c
static void clflush_page(unsigned long address) { unsigned int flush_size; char *cl, *start, *end; flush_size = 64; start = (char *)(address & PAGE_MASK); end = start + PAGE_SIZE; /* * First make sure there are no pending writes on the cache-lines to * flush. */ asm volatile("mfence" : : : "mem...
[ 1, 0 ]
Linux Kernel
arch/x86/boot/compressed/ident_map_64.c
static int set_clr_page_flags(struct x86_mapping_info *info, unsigned long address, pteval_t set, pteval_t clr) { pgd_t *pgdp = (pgd_t *)top_level_pgt; p4d_t *p4dp; pud_t *pudp; pmd_t *pmdp; pte_t *ptep, pte; asm volatile("mov %[address], %%r9" ::...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/ident_map_64.c
int set_page_decrypted(unsigned long address) { return set_clr_page_flags(&mapping_info, address, 0, _PAGE_ENC); }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/ident_map_64.c
void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code) { unsigned long address = native_read_cr2(); unsigned long end; bool ghcb_fault; ghcb_fault = sev_es_check_ghcb_fault(address); address &= PMD_MASK; end = address + PMD_SIZE; if (error_code & (X86_PF_PROT | X86_PF_USER | X86_PF_RSV...
[ 1, 0 ]
Linux Kernel
arch/x86/boot/compressed/idt_64.c
static void set_idt_entry(int vector, void (*handler)(void)) { unsigned long address = (unsigned long)handler; gate_desc entry; memset(&entry, 0, sizeof(entry)); entry.offset_low = (u16)(address & 0xffff); entry.segment = __KERNEL_CS; entry.bits.type = GATE_TRAP; entry.bits.p = 1; entry.offset_middle...
[ 1, 0 ]
Linux Kernel
arch/x86/boot/compressed/idt_64.c
void load_stage1_idt(void) { boot_idt_desc.address = (unsigned long)boot_idt; if (IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT)) set_idt_entry(X86_TRAP_VC, boot_stage1_vc); load_boot_idt(&boot_idt_desc); }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/idt_64.c
void load_stage2_idt(void) { boot_idt_desc.address = (unsigned long)boot_idt; set_idt_entry(X86_TRAP_PF, boot_page_fault); #ifdef CONFIG_AMD_MEM_ENCRYPT set_idt_entry(X86_TRAP_VC, boot_stage2_vc); #endif load_boot_idt(&boot_idt_desc); }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/kaslr.c
static unsigned long get_boot_seed(void) { unsigned long hash = 0; hash = rotate_xor(hash, build_str, sizeof(build_str)); hash = rotate_xor(hash, boot_params, sizeof(*boot_params)); return hash; } #define KASLR_COMPRESSED_BOOT #include "../../lib/kaslr.c" #define MAX_MEMMAP_REGIONS 4
[ 1, 0 ]
Linux Kernel
arch/x86/boot/compressed/kaslr.c
static bool mem_overlaps(struct mem_vector *one, struct mem_vector *two) { if (one->start + one->size <= two->start) return false; /* Item one is entirely after item two. */ if (one->start >= two->start + two->size) return false; return true; }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/kaslr.c
static int parse_memmap(char *p, u64 *start, u64 *size, enum parse_mode mode) { char *oldp; if (!p) return -EINVAL; if (!strncmp(p, "exactmap", 8)) return -EINVAL; oldp = p; *size = memparse(p, &p); if (p == oldp) return -EINVAL; switch (*p) { case '#': case '$': case '!': *start...
[ 1, 0 ]
Linux Kernel
arch/x86/boot/compressed/kaslr.c
static u64 slots_fetch_random(void) { unsigned long slot; unsigned int i; if (slot_max == 0) return 0; slot = kaslr_get_random_long("Physical") % slot_max; for (i = 0; i < slot_area_index; i++) { if (slot >= slot_areas[i].num) { slot -= slot_areas[i].num; continue; } return slot...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/kaslr.c
static void __process_mem_region(struct mem_vector *entry, unsigned long minimum, unsigned long image_size) { struct mem_vector region, overlap; u64 region_end; region.start = max_t(u64, entry->start, minimum); region_end = min(entry->start + en...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/kaslr.c
static bool process_mem_region(struct mem_vector *region, unsigned long minimum, unsigned long image_size) { int i; if (!num_immovable_mem) { __process_mem_region(region, minimum, image_size); if (slot_area_index == MAX_SLOT_AREA) { debug_putstr("Aborted e820/efi memma...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/kaslr.c
static inline bool process_efi_entries(unsigned long minimum, unsigned long image_size) { return false; } #endif
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/kaslr.c
static void process_e820_entries(unsigned long minimum, unsigned long image_size) { int i; struct mem_vector region; struct boot_e820_entry *entry; for (i = 0; i < boot_params->e820_entries; i++) { entry = &boot_params->e820_table[i]; /* Skip non-RAM entries. */ if ...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/kaslr.c
static unsigned long find_random_phys_addr(unsigned long minimum, unsigned long image_size) { u64 phys_addr; /* Bail out early if it's impossible to succeed. */ if (minimum + image_size > mem_limit) return 0; /* Check if we had too many memmaps. */ if (memmap_t...
[ 1, 0 ]
Linux Kernel
arch/x86/boot/compressed/misc.c
static void scroll(void) { int i; memmove(vidmem, vidmem + cols * 2, (lines - 1) * cols * 2); for (i = (lines - 1) * cols * 2; i < lines * cols * 2; i += 2) vidmem[i] = ' '; }
[ 1, 0 ]
Linux Kernel
arch/x86/boot/compressed/misc.c
static void parse_elf(void *output) { #ifdef CONFIG_X86_64 Elf64_Ehdr ehdr; Elf64_Phdr *phdrs, *phdr; #else Elf32_Ehdr ehdr; Elf32_Phdr *phdrs, *phdr; #endif void *dest; int i; memcpy(&ehdr, output, sizeof(ehdr)); if (ehdr.e_ident[EI_MAG0] != ELFMAG0 || ehdr.e_ident[EI_MAG1] != ELFMAG1 || ehdr.e_...
[ 1, 0 ]
Linux Kernel
arch/x86/boot/compressed/misc.h
static inline int efi_get_conf_table(struct boot_params *bp, unsigned long *cfg_tbl_pa, unsigned int *cfg_tbl_len) { return -ENOENT; }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/mkpiggy.c
int main(int argc, char *argv[]) { uint32_t olen; long ilen; FILE *f = NULL; int retval = 1; if (argc < 2) { fprintf(stderr, "Usage: %s compressed_file\n", argv[0]); goto bail; } f = fopen(argv[1], "r"); if (!f) { perror(argv[1]); goto bail; } if (fseek(f, -4L, SEEK_END)) { pe...
[ 1, 0 ]
Linux Kernel
arch/x86/boot/compressed/sev.c
static inline u64 sev_es_rd_ghcb_msr(void) { struct msr m; boot_rdmsr(MSR_AMD64_SEV_ES_GHCB, &m); return m.q; }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/sev.c
static inline bool sev_snp_enabled(void) { return sev_status & MSR_AMD64_SEV_SNP_ENABLED; }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/sev.c
void snp_set_page_private(unsigned long paddr) { __page_state_change(paddr, SNP_PAGE_STATE_PRIVATE); }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/sev.c
void sev_es_shutdown_ghcb(void) { if (!boot_ghcb) return; if (!sev_es_check_cpu_features()) error("SEV-ES CPU Features missing."); if (set_page_encrypted((unsigned long)&boot_ghcb_page)) error("Can't map GHCB page encrypted"); /* * GHCB page is mapped encrypted again and flushed from the cache...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/sev.c
bool sev_es_check_ghcb_fault(unsigned long address) { return ((address & PAGE_MASK) == (unsigned long)&boot_ghcb_page); }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/tdx.c
static inline void tdx_outb(u8 value, u16 port) { tdx_io_out(1, port, value); }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/compressed/tdx.h
static inline void early_tdx_detect(void) {};
[ 0, 0 ]
Linux Kernel
arch/x86/boot/cpucheck.c
int check_knl_erratum(void) { if (!is_intel() || cpu.family != 6 || cpu.model != INTEL_FAM6_XEON_PHI_KNL) return 0; /* * This erratum affects the Accessed/Dirty bits, and can * cause stray bits to be set in !Present PTEs. We have * enough bits in our 64-bit PTEs (which we have on real * 64-bit mo...
[ 1, 0 ]
Linux Kernel
arch/x86/boot/cpuflags.c
void cpuid_count(u32 id, u32 count, u32 *a, u32 *b, u32 *c, u32 *d) { asm volatile("cpuid" : "=a"(*a), "=b"(*b), "=c"(*c), "=d"(*d) : "0"(id), "2"(count)); }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/cpuflags.c
void get_cpuflags(void) { u32 max_intel_level, max_amd_level; u32 tfms; u32 ignored; if (loaded_flags) return; loaded_flags = true; if (has_fpu()) set_bit(X86_FEATURE_FPU, cpu.flags); if (has_eflag(X86_EFLAGS_ID)) { cpuid(0x0, &max_intel_level, &cpu_vendor[0], &cpu_vendor[2], &cp...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/early_serial_console.c
void console_init(void) { parse_earlyprintk(); if (!early_serial_base) parse_console_uart8250(); }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/edd.c
static u32 read_mbr_sig(u8 devno, struct edd_info *ei, u32 *mbrsig) { int sector_size; char *mbrbuf_ptr, *mbrbuf_end; u32 buf_base, mbr_base; extern char _end[]; u16 mbr_magic; sector_size = ei->params.bytes_per_sector; if (!sector_size) sector_size = 512; /* Produce a naturally aligned buffer on ...
[ 1, 0 ]
Linux Kernel
arch/x86/boot/edd.c
static int get_edd_info(u8 devno, struct edd_info *ei) { struct biosregs ireg, oreg; memset(ei, 0, sizeof(*ei)); initregs(&ireg); ireg.ah = 0x41; ireg.bx = EDDMAGIC1; ireg.dl = devno; intcall(0x13, &ireg, &oreg); if (oreg.eflags & X86_EFLAGS_CF) return -1; /* No extended information */ if (ore...
[ 1, 0 ]
Linux Kernel
arch/x86/boot/main.c
static void keyboard_init(void) { struct biosregs ireg, oreg; initregs(&ireg); ireg.ah = 0x02; intcall(0x16, &ireg, &oreg); boot_params.kbd_status = oreg.al; ireg.ax = 0x0305; /* Set keyboard repeat rate */ intcall(0x16, &ireg, NULL); }
[ 1, 0 ]
Linux Kernel
arch/x86/boot/main.c
void main(void) { init_default_io_ops(); copy_boot_params(); /* Initialize the early-boot console */ console_init(); if (cmdline_find_option_bool("debug")) puts("early console in setup code\n"); /* End of heap check */ init_heap(); /* Make sure we have all the proper CPU support */ if (validat...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/memory.c
void detect_memory(void) { detect_memory_e820(); detect_memory_e801(); detect_memory_88(); }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/mkcpustr.c
int main(void) { int i, j; const char *str; printf("static const char x86_cap_strs[] =\n"); for (i = 0; i < NCAPINTS; i++) { for (j = 0; j < 32; j++) { str = x86_cap_flags[i * 32 + j]; if (i == NCAPINTS - 1 && j == 31) { if (!str) str = ""; printf("\t\"\\x%02x\\x%02...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/pm.c
static void reset_coprocessor(void) { outb(0, 0xf0); io_delay(); outb(0, 0xf1); io_delay(); }
[ 0, 0 ]
Linux Kernel
arch/x86/boot/pm.c
void go_to_protected_mode(void) { realmode_switch_hook(); /* Enable the A20 gate */ if (enable_a20()) { puts("A20 gate not responding, unable to boot...\n"); die(); } /* Reset coprocessor (IGNNE#) */ reset_coprocessor(); /* Mask all interrupts in the PIC */ mask_all_interrupts(); /* Actua...
[ 0, 0 ]
Linux Kernel
arch/x86/boot/printf.c
int printf(const char *fmt, ...) { char printf_buf[1024]; va_list args; int printed; va_start(args, fmt); printed = vsprintf(printf_buf, fmt, args); va_end(args); puts(printf_buf); return printed; }
[ 1, 0 ]