Thomas Gleixner | 8d0d37c | 2007-10-11 11:12:08 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Generate definitions needed by assembly language modules. |
| 3 | * This code generates raw asm output which is post-processed |
| 4 | * to extract and format the required data. |
| 5 | */ |
| 6 | |
| 7 | #include <linux/crypto.h> |
| 8 | #include <linux/sched.h> |
| 9 | #include <linux/signal.h> |
| 10 | #include <linux/personality.h> |
| 11 | #include <linux/suspend.h> |
| 12 | #include <asm/ucontext.h> |
Thomas Gleixner | 56cc623 | 2007-10-11 11:12:46 +0200 | [diff] [blame] | 13 | #include "sigframe_32.h" |
Thomas Gleixner | 8d0d37c | 2007-10-11 11:12:08 +0200 | [diff] [blame] | 14 | #include <asm/pgtable.h> |
| 15 | #include <asm/fixmap.h> |
| 16 | #include <asm/processor.h> |
| 17 | #include <asm/thread_info.h> |
Rusty Russell | e5371ac | 2007-10-21 16:41:33 -0700 | [diff] [blame] | 18 | #include <asm/bootparam.h> |
Thomas Gleixner | 8d0d37c | 2007-10-11 11:12:08 +0200 | [diff] [blame] | 19 | #include <asm/elf.h> |
| 20 | |
| 21 | #include <xen/interface/xen.h> |
| 22 | |
| 23 | #ifdef CONFIG_LGUEST_GUEST |
| 24 | #include <linux/lguest.h> |
| 25 | #include "../../../drivers/lguest/lg.h" |
| 26 | #endif |
| 27 | |
| 28 | #define DEFINE(sym, val) \ |
| 29 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) |
| 30 | |
| 31 | #define BLANK() asm volatile("\n->" : : ) |
| 32 | |
| 33 | #define OFFSET(sym, str, mem) \ |
| 34 | DEFINE(sym, offsetof(struct str, mem)); |
| 35 | |
| 36 | /* workaround for a warning with -Wmissing-prototypes */ |
| 37 | void foo(void); |
| 38 | |
| 39 | void foo(void) |
| 40 | { |
Roland McGrath | 108b545 | 2008-01-30 13:30:41 +0100 | [diff] [blame^] | 41 | OFFSET(IA32_SIGCONTEXT_eax, sigcontext, eax); |
| 42 | OFFSET(IA32_SIGCONTEXT_ebx, sigcontext, ebx); |
| 43 | OFFSET(IA32_SIGCONTEXT_ecx, sigcontext, ecx); |
| 44 | OFFSET(IA32_SIGCONTEXT_edx, sigcontext, edx); |
| 45 | OFFSET(IA32_SIGCONTEXT_esi, sigcontext, esi); |
| 46 | OFFSET(IA32_SIGCONTEXT_edi, sigcontext, edi); |
| 47 | OFFSET(IA32_SIGCONTEXT_ebp, sigcontext, ebp); |
| 48 | OFFSET(IA32_SIGCONTEXT_esp, sigcontext, esp); |
| 49 | OFFSET(IA32_SIGCONTEXT_eip, sigcontext, eip); |
Thomas Gleixner | 8d0d37c | 2007-10-11 11:12:08 +0200 | [diff] [blame] | 50 | BLANK(); |
| 51 | |
| 52 | OFFSET(CPUINFO_x86, cpuinfo_x86, x86); |
| 53 | OFFSET(CPUINFO_x86_vendor, cpuinfo_x86, x86_vendor); |
| 54 | OFFSET(CPUINFO_x86_model, cpuinfo_x86, x86_model); |
| 55 | OFFSET(CPUINFO_x86_mask, cpuinfo_x86, x86_mask); |
| 56 | OFFSET(CPUINFO_hard_math, cpuinfo_x86, hard_math); |
| 57 | OFFSET(CPUINFO_cpuid_level, cpuinfo_x86, cpuid_level); |
| 58 | OFFSET(CPUINFO_x86_capability, cpuinfo_x86, x86_capability); |
| 59 | OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id); |
| 60 | BLANK(); |
| 61 | |
| 62 | OFFSET(TI_task, thread_info, task); |
| 63 | OFFSET(TI_exec_domain, thread_info, exec_domain); |
| 64 | OFFSET(TI_flags, thread_info, flags); |
| 65 | OFFSET(TI_status, thread_info, status); |
| 66 | OFFSET(TI_preempt_count, thread_info, preempt_count); |
| 67 | OFFSET(TI_addr_limit, thread_info, addr_limit); |
| 68 | OFFSET(TI_restart_block, thread_info, restart_block); |
| 69 | OFFSET(TI_sysenter_return, thread_info, sysenter_return); |
| 70 | OFFSET(TI_cpu, thread_info, cpu); |
| 71 | BLANK(); |
| 72 | |
| 73 | OFFSET(GDS_size, Xgt_desc_struct, size); |
| 74 | OFFSET(GDS_address, Xgt_desc_struct, address); |
| 75 | OFFSET(GDS_pad, Xgt_desc_struct, pad); |
| 76 | BLANK(); |
| 77 | |
| 78 | OFFSET(PT_EBX, pt_regs, ebx); |
| 79 | OFFSET(PT_ECX, pt_regs, ecx); |
| 80 | OFFSET(PT_EDX, pt_regs, edx); |
| 81 | OFFSET(PT_ESI, pt_regs, esi); |
| 82 | OFFSET(PT_EDI, pt_regs, edi); |
| 83 | OFFSET(PT_EBP, pt_regs, ebp); |
| 84 | OFFSET(PT_EAX, pt_regs, eax); |
| 85 | OFFSET(PT_DS, pt_regs, xds); |
| 86 | OFFSET(PT_ES, pt_regs, xes); |
| 87 | OFFSET(PT_FS, pt_regs, xfs); |
| 88 | OFFSET(PT_ORIG_EAX, pt_regs, orig_eax); |
| 89 | OFFSET(PT_EIP, pt_regs, eip); |
| 90 | OFFSET(PT_CS, pt_regs, xcs); |
| 91 | OFFSET(PT_EFLAGS, pt_regs, eflags); |
| 92 | OFFSET(PT_OLDESP, pt_regs, esp); |
| 93 | OFFSET(PT_OLDSS, pt_regs, xss); |
| 94 | BLANK(); |
| 95 | |
| 96 | OFFSET(EXEC_DOMAIN_handler, exec_domain, handler); |
Roland McGrath | 108b545 | 2008-01-30 13:30:41 +0100 | [diff] [blame^] | 97 | OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe, uc.uc_mcontext); |
Thomas Gleixner | 8d0d37c | 2007-10-11 11:12:08 +0200 | [diff] [blame] | 98 | BLANK(); |
| 99 | |
| 100 | OFFSET(pbe_address, pbe, address); |
| 101 | OFFSET(pbe_orig_address, pbe, orig_address); |
| 102 | OFFSET(pbe_next, pbe, next); |
| 103 | |
| 104 | /* Offset from the sysenter stack to tss.esp0 */ |
| 105 | DEFINE(TSS_sysenter_esp0, offsetof(struct tss_struct, x86_tss.esp0) - |
| 106 | sizeof(struct tss_struct)); |
| 107 | |
| 108 | DEFINE(PAGE_SIZE_asm, PAGE_SIZE); |
| 109 | DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT); |
| 110 | DEFINE(PTRS_PER_PTE, PTRS_PER_PTE); |
| 111 | DEFINE(PTRS_PER_PMD, PTRS_PER_PMD); |
| 112 | DEFINE(PTRS_PER_PGD, PTRS_PER_PGD); |
| 113 | |
| 114 | DEFINE(VDSO_PRELINK_asm, VDSO_PRELINK); |
| 115 | |
| 116 | OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx); |
| 117 | |
| 118 | #ifdef CONFIG_PARAVIRT |
| 119 | BLANK(); |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 120 | OFFSET(PARAVIRT_enabled, pv_info, paravirt_enabled); |
| 121 | OFFSET(PARAVIRT_PATCH_pv_cpu_ops, paravirt_patch_template, pv_cpu_ops); |
| 122 | OFFSET(PARAVIRT_PATCH_pv_irq_ops, paravirt_patch_template, pv_irq_ops); |
| 123 | OFFSET(PV_IRQ_irq_disable, pv_irq_ops, irq_disable); |
| 124 | OFFSET(PV_IRQ_irq_enable, pv_irq_ops, irq_enable); |
| 125 | OFFSET(PV_CPU_iret, pv_cpu_ops, iret); |
Glauber de Oliveira Costa | 6abcd98 | 2008-01-30 13:30:33 +0100 | [diff] [blame] | 126 | OFFSET(PV_CPU_irq_enable_syscall_ret, pv_cpu_ops, irq_enable_syscall_ret); |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 127 | OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0); |
Thomas Gleixner | 8d0d37c | 2007-10-11 11:12:08 +0200 | [diff] [blame] | 128 | #endif |
| 129 | |
| 130 | #ifdef CONFIG_XEN |
| 131 | BLANK(); |
| 132 | OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask); |
| 133 | OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending); |
| 134 | #endif |
| 135 | |
| 136 | #ifdef CONFIG_LGUEST_GUEST |
| 137 | BLANK(); |
| 138 | OFFSET(LGUEST_DATA_irq_enabled, lguest_data, irq_enabled); |
Rusty Russell | 47436aa | 2007-10-22 11:03:36 +1000 | [diff] [blame] | 139 | OFFSET(LGUEST_DATA_pgdir, lguest_data, pgdir); |
Thomas Gleixner | 8d0d37c | 2007-10-11 11:12:08 +0200 | [diff] [blame] | 140 | OFFSET(LGUEST_PAGES_host_gdt_desc, lguest_pages, state.host_gdt_desc); |
| 141 | OFFSET(LGUEST_PAGES_host_idt_desc, lguest_pages, state.host_idt_desc); |
| 142 | OFFSET(LGUEST_PAGES_host_cr3, lguest_pages, state.host_cr3); |
| 143 | OFFSET(LGUEST_PAGES_host_sp, lguest_pages, state.host_sp); |
| 144 | OFFSET(LGUEST_PAGES_guest_gdt_desc, lguest_pages,state.guest_gdt_desc); |
| 145 | OFFSET(LGUEST_PAGES_guest_idt_desc, lguest_pages,state.guest_idt_desc); |
| 146 | OFFSET(LGUEST_PAGES_guest_gdt, lguest_pages, state.guest_gdt); |
| 147 | OFFSET(LGUEST_PAGES_regs_trapnum, lguest_pages, regs.trapnum); |
| 148 | OFFSET(LGUEST_PAGES_regs_errcode, lguest_pages, regs.errcode); |
| 149 | OFFSET(LGUEST_PAGES_regs, lguest_pages, regs); |
| 150 | #endif |
Rusty Russell | e5371ac | 2007-10-21 16:41:33 -0700 | [diff] [blame] | 151 | |
| 152 | BLANK(); |
| 153 | OFFSET(BP_scratch, boot_params, scratch); |
| 154 | OFFSET(BP_loadflags, boot_params, hdr.loadflags); |
| 155 | OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch); |
| 156 | OFFSET(BP_version, boot_params, hdr.version); |
Thomas Gleixner | 8d0d37c | 2007-10-11 11:12:08 +0200 | [diff] [blame] | 157 | } |