blob: 670c3c311289b185cd3fc3a2f12c64bc31a3cc4c [file] [log] [blame]
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +02001/*
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>
Harvey Harrison123a6342008-02-08 12:10:00 -080013#include "sigframe.h"
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +020014#include <asm/pgtable.h>
15#include <asm/fixmap.h>
16#include <asm/processor.h>
17#include <asm/thread_info.h>
Rusty Russelle5371ac2007-10-21 16:41:33 -070018#include <asm/bootparam.h>
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +020019#include <asm/elf.h>
20
21#include <xen/interface/xen.h>
22
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +020023#include <linux/lguest.h>
24#include "../../../drivers/lguest/lg.h"
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +020025
26#define DEFINE(sym, val) \
27 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
28
29#define BLANK() asm volatile("\n->" : : )
30
31#define OFFSET(sym, str, mem) \
32 DEFINE(sym, offsetof(struct str, mem));
33
34/* workaround for a warning with -Wmissing-prototypes */
35void foo(void);
36
37void foo(void)
38{
H. Peter Anvin742fa542008-01-30 13:30:56 +010039 OFFSET(IA32_SIGCONTEXT_ax, sigcontext, ax);
40 OFFSET(IA32_SIGCONTEXT_bx, sigcontext, bx);
41 OFFSET(IA32_SIGCONTEXT_cx, sigcontext, cx);
42 OFFSET(IA32_SIGCONTEXT_dx, sigcontext, dx);
43 OFFSET(IA32_SIGCONTEXT_si, sigcontext, si);
44 OFFSET(IA32_SIGCONTEXT_di, sigcontext, di);
45 OFFSET(IA32_SIGCONTEXT_bp, sigcontext, bp);
46 OFFSET(IA32_SIGCONTEXT_sp, sigcontext, sp);
47 OFFSET(IA32_SIGCONTEXT_ip, sigcontext, ip);
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +020048 BLANK();
49
50 OFFSET(CPUINFO_x86, cpuinfo_x86, x86);
51 OFFSET(CPUINFO_x86_vendor, cpuinfo_x86, x86_vendor);
52 OFFSET(CPUINFO_x86_model, cpuinfo_x86, x86_model);
53 OFFSET(CPUINFO_x86_mask, cpuinfo_x86, x86_mask);
54 OFFSET(CPUINFO_hard_math, cpuinfo_x86, hard_math);
55 OFFSET(CPUINFO_cpuid_level, cpuinfo_x86, cpuid_level);
56 OFFSET(CPUINFO_x86_capability, cpuinfo_x86, x86_capability);
57 OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id);
58 BLANK();
59
60 OFFSET(TI_task, thread_info, task);
61 OFFSET(TI_exec_domain, thread_info, exec_domain);
62 OFFSET(TI_flags, thread_info, flags);
63 OFFSET(TI_status, thread_info, status);
64 OFFSET(TI_preempt_count, thread_info, preempt_count);
65 OFFSET(TI_addr_limit, thread_info, addr_limit);
66 OFFSET(TI_restart_block, thread_info, restart_block);
67 OFFSET(TI_sysenter_return, thread_info, sysenter_return);
68 OFFSET(TI_cpu, thread_info, cpu);
69 BLANK();
70
Glauber de Oliveira Costa6b68f012008-01-30 13:31:12 +010071 OFFSET(GDS_size, desc_ptr, size);
72 OFFSET(GDS_address, desc_ptr, address);
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +020073 BLANK();
74
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010075 OFFSET(PT_EBX, pt_regs, bx);
76 OFFSET(PT_ECX, pt_regs, cx);
77 OFFSET(PT_EDX, pt_regs, dx);
78 OFFSET(PT_ESI, pt_regs, si);
79 OFFSET(PT_EDI, pt_regs, di);
80 OFFSET(PT_EBP, pt_regs, bp);
81 OFFSET(PT_EAX, pt_regs, ax);
82 OFFSET(PT_DS, pt_regs, ds);
83 OFFSET(PT_ES, pt_regs, es);
84 OFFSET(PT_FS, pt_regs, fs);
85 OFFSET(PT_ORIG_EAX, pt_regs, orig_ax);
86 OFFSET(PT_EIP, pt_regs, ip);
87 OFFSET(PT_CS, pt_regs, cs);
88 OFFSET(PT_EFLAGS, pt_regs, flags);
89 OFFSET(PT_OLDESP, pt_regs, sp);
90 OFFSET(PT_OLDSS, pt_regs, ss);
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +020091 BLANK();
92
93 OFFSET(EXEC_DOMAIN_handler, exec_domain, handler);
Roland McGrath108b5452008-01-30 13:30:41 +010094 OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe, uc.uc_mcontext);
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +020095 BLANK();
96
97 OFFSET(pbe_address, pbe, address);
98 OFFSET(pbe_orig_address, pbe, orig_address);
99 OFFSET(pbe_next, pbe, next);
100
H. Peter Anvinfaca6222008-01-30 13:31:02 +0100101 /* Offset from the sysenter stack to tss.sp0 */
102 DEFINE(TSS_sysenter_sp0, offsetof(struct tss_struct, x86_tss.sp0) -
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +0200103 sizeof(struct tss_struct));
104
105 DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
106 DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
107 DEFINE(PTRS_PER_PTE, PTRS_PER_PTE);
108 DEFINE(PTRS_PER_PMD, PTRS_PER_PMD);
109 DEFINE(PTRS_PER_PGD, PTRS_PER_PGD);
110
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +0200111 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
112
113#ifdef CONFIG_PARAVIRT
114 BLANK();
Jeremy Fitzhardinge93b1eab2007-10-16 11:51:29 -0700115 OFFSET(PARAVIRT_enabled, pv_info, paravirt_enabled);
116 OFFSET(PARAVIRT_PATCH_pv_cpu_ops, paravirt_patch_template, pv_cpu_ops);
117 OFFSET(PARAVIRT_PATCH_pv_irq_ops, paravirt_patch_template, pv_irq_ops);
118 OFFSET(PV_IRQ_irq_disable, pv_irq_ops, irq_disable);
119 OFFSET(PV_IRQ_irq_enable, pv_irq_ops, irq_enable);
120 OFFSET(PV_CPU_iret, pv_cpu_ops, iret);
Glauber de Oliveira Costa6abcd982008-01-30 13:30:33 +0100121 OFFSET(PV_CPU_irq_enable_syscall_ret, pv_cpu_ops, irq_enable_syscall_ret);
Jeremy Fitzhardinge93b1eab2007-10-16 11:51:29 -0700122 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +0200123#endif
124
125#ifdef CONFIG_XEN
126 BLANK();
127 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
128 OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending);
129#endif
130
Tony Breedsdb342d22008-02-19 08:16:03 +0100131#if defined(CONFIG_LGUEST) || defined(CONFIG_LGUEST_GUEST) || defined(CONFIG_LGUEST_MODULE)
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +0200132 BLANK();
133 OFFSET(LGUEST_DATA_irq_enabled, lguest_data, irq_enabled);
Rusty Russell47436aa2007-10-22 11:03:36 +1000134 OFFSET(LGUEST_DATA_pgdir, lguest_data, pgdir);
Rusty Russellf6c540c2008-02-04 07:11:10 +1100135
Rusty Russellf6c540c2008-02-04 07:11:10 +1100136 BLANK();
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +0200137 OFFSET(LGUEST_PAGES_host_gdt_desc, lguest_pages, state.host_gdt_desc);
138 OFFSET(LGUEST_PAGES_host_idt_desc, lguest_pages, state.host_idt_desc);
139 OFFSET(LGUEST_PAGES_host_cr3, lguest_pages, state.host_cr3);
140 OFFSET(LGUEST_PAGES_host_sp, lguest_pages, state.host_sp);
141 OFFSET(LGUEST_PAGES_guest_gdt_desc, lguest_pages,state.guest_gdt_desc);
142 OFFSET(LGUEST_PAGES_guest_idt_desc, lguest_pages,state.guest_idt_desc);
143 OFFSET(LGUEST_PAGES_guest_gdt, lguest_pages, state.guest_gdt);
144 OFFSET(LGUEST_PAGES_regs_trapnum, lguest_pages, regs.trapnum);
145 OFFSET(LGUEST_PAGES_regs_errcode, lguest_pages, regs.errcode);
146 OFFSET(LGUEST_PAGES_regs, lguest_pages, regs);
147#endif
Rusty Russelle5371ac2007-10-21 16:41:33 -0700148
149 BLANK();
150 OFFSET(BP_scratch, boot_params, scratch);
151 OFFSET(BP_loadflags, boot_params, hdr.loadflags);
152 OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch);
153 OFFSET(BP_version, boot_params, hdr.version);
Thomas Gleixner8d0d37c2007-10-11 11:12:08 +0200154}