asm-offsets_32.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SPDX-License-Identifier: GPL-2.0
  2. #ifndef __LINUX_KBUILD_H
  3. # error "Please do not build this file directly, build asm-offsets.c instead"
  4. #endif
  5. #include <asm/ucontext.h>
  6. #define __SYSCALL_I386(nr, sym, qual) [nr] = 1,
  7. static char syscalls[] = {
  8. #include <asm/syscalls_32.h>
  9. };
  10. /* workaround for a warning with -Wmissing-prototypes */
  11. void foo(void);
  12. void foo(void)
  13. {
  14. OFFSET(CPUINFO_x86, cpuinfo_x86, x86);
  15. OFFSET(CPUINFO_x86_vendor, cpuinfo_x86, x86_vendor);
  16. OFFSET(CPUINFO_x86_model, cpuinfo_x86, x86_model);
  17. OFFSET(CPUINFO_x86_stepping, cpuinfo_x86, x86_stepping);
  18. OFFSET(CPUINFO_cpuid_level, cpuinfo_x86, cpuid_level);
  19. OFFSET(CPUINFO_x86_capability, cpuinfo_x86, x86_capability);
  20. OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id);
  21. BLANK();
  22. OFFSET(PT_EBX, pt_regs, bx);
  23. OFFSET(PT_ECX, pt_regs, cx);
  24. OFFSET(PT_EDX, pt_regs, dx);
  25. OFFSET(PT_ESI, pt_regs, si);
  26. OFFSET(PT_EDI, pt_regs, di);
  27. OFFSET(PT_EBP, pt_regs, bp);
  28. OFFSET(PT_EAX, pt_regs, ax);
  29. OFFSET(PT_DS, pt_regs, ds);
  30. OFFSET(PT_ES, pt_regs, es);
  31. OFFSET(PT_FS, pt_regs, fs);
  32. OFFSET(PT_GS, pt_regs, gs);
  33. OFFSET(PT_ORIG_EAX, pt_regs, orig_ax);
  34. OFFSET(PT_EIP, pt_regs, ip);
  35. OFFSET(PT_CS, pt_regs, cs);
  36. OFFSET(PT_EFLAGS, pt_regs, flags);
  37. OFFSET(PT_OLDESP, pt_regs, sp);
  38. OFFSET(PT_OLDSS, pt_regs, ss);
  39. BLANK();
  40. OFFSET(saved_context_gdt_desc, saved_context, gdt_desc);
  41. BLANK();
  42. /*
  43. * Offset from the entry stack to task stack stored in TSS. Kernel entry
  44. * happens on the per-cpu entry-stack, and the asm code switches to the
  45. * task-stack pointer stored in x86_tss.sp1, which is a copy of
  46. * task->thread.sp0 where entry code can find it.
  47. */
  48. DEFINE(TSS_entry2task_stack,
  49. offsetof(struct cpu_entry_area, tss.x86_tss.sp1) -
  50. offsetofend(struct cpu_entry_area, entry_stack_page.stack));
  51. #ifdef CONFIG_STACKPROTECTOR
  52. BLANK();
  53. OFFSET(stack_canary_offset, stack_canary, canary);
  54. #endif
  55. BLANK();
  56. DEFINE(__NR_syscall_max, sizeof(syscalls) - 1);
  57. DEFINE(NR_syscalls, sizeof(syscalls));
  58. }