ia64/xen-unstable

view xen/arch/x86/x86_64/asm-offsets.c @ 16185:42d8dadb5864

x86: Allow NMI callback CS to be specified via set_trap_table()
hypercall.
Based on a patch by Jan Beulich.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Mon Oct 22 13:04:32 2007 +0100 (2007-10-22)
parents ec3b23d8d544
children aeebd173c3fa
line source
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 */
7 #include <xen/config.h>
8 #include <xen/perfc.h>
9 #include <xen/sched.h>
10 #ifdef CONFIG_COMPAT
11 #include <compat/xen.h>
12 #endif
13 #include <asm/fixmap.h>
14 #include <asm/hardirq.h>
16 #define DEFINE(_sym, _val) \
17 __asm__ __volatile__ ( "\n->" #_sym " %0 " #_val : : "i" (_val) )
18 #define BLANK() \
19 __asm__ __volatile__ ( "\n->" : : )
20 #define OFFSET(_sym, _str, _mem) \
21 DEFINE(_sym, offsetof(_str, _mem));
23 /* base-2 logarithm */
24 #define __L2(_x) (((_x) & 0x00000002) ? 1 : 0)
25 #define __L4(_x) (((_x) & 0x0000000c) ? ( 2 + __L2( (_x)>> 2)) : __L2( _x))
26 #define __L8(_x) (((_x) & 0x000000f0) ? ( 4 + __L4( (_x)>> 4)) : __L4( _x))
27 #define __L16(_x) (((_x) & 0x0000ff00) ? ( 8 + __L8( (_x)>> 8)) : __L8( _x))
28 #define LOG_2(_x) (((_x) & 0xffff0000) ? (16 + __L16((_x)>>16)) : __L16(_x))
30 void __dummy__(void)
31 {
32 OFFSET(UREGS_r15, struct cpu_user_regs, r15);
33 OFFSET(UREGS_r14, struct cpu_user_regs, r14);
34 OFFSET(UREGS_r13, struct cpu_user_regs, r13);
35 OFFSET(UREGS_r12, struct cpu_user_regs, r12);
36 OFFSET(UREGS_rbp, struct cpu_user_regs, rbp);
37 OFFSET(UREGS_rbx, struct cpu_user_regs, rbx);
38 OFFSET(UREGS_r11, struct cpu_user_regs, r11);
39 OFFSET(UREGS_r10, struct cpu_user_regs, r10);
40 OFFSET(UREGS_r9, struct cpu_user_regs, r9);
41 OFFSET(UREGS_r8, struct cpu_user_regs, r8);
42 OFFSET(UREGS_rax, struct cpu_user_regs, rax);
43 OFFSET(UREGS_rcx, struct cpu_user_regs, rcx);
44 OFFSET(UREGS_rdx, struct cpu_user_regs, rdx);
45 OFFSET(UREGS_rsi, struct cpu_user_regs, rsi);
46 OFFSET(UREGS_rdi, struct cpu_user_regs, rdi);
47 OFFSET(UREGS_error_code, struct cpu_user_regs, error_code);
48 OFFSET(UREGS_entry_vector, struct cpu_user_regs, entry_vector);
49 OFFSET(UREGS_rip, struct cpu_user_regs, rip);
50 OFFSET(UREGS_cs, struct cpu_user_regs, cs);
51 OFFSET(UREGS_eflags, struct cpu_user_regs, eflags);
52 OFFSET(UREGS_rsp, struct cpu_user_regs, rsp);
53 OFFSET(UREGS_ss, struct cpu_user_regs, ss);
54 OFFSET(UREGS_kernel_sizeof, struct cpu_user_regs, es);
55 DEFINE(UREGS_user_sizeof, sizeof(struct cpu_user_regs));
56 BLANK();
58 OFFSET(VCPU_processor, struct vcpu, processor);
59 OFFSET(VCPU_domain, struct vcpu, domain);
60 OFFSET(VCPU_vcpu_info, struct vcpu, vcpu_info);
61 OFFSET(VCPU_trap_bounce, struct vcpu, arch.trap_bounce);
62 OFFSET(VCPU_int80_bounce, struct vcpu, arch.int80_bounce);
63 OFFSET(VCPU_thread_flags, struct vcpu, arch.flags);
64 OFFSET(VCPU_event_addr, struct vcpu,
65 arch.guest_context.event_callback_eip);
66 OFFSET(VCPU_event_sel, struct vcpu,
67 arch.guest_context.event_callback_cs);
68 OFFSET(VCPU_failsafe_addr, struct vcpu,
69 arch.guest_context.failsafe_callback_eip);
70 OFFSET(VCPU_failsafe_sel, struct vcpu,
71 arch.guest_context.failsafe_callback_cs);
72 OFFSET(VCPU_syscall_addr, struct vcpu,
73 arch.guest_context.syscall_callback_eip);
74 OFFSET(VCPU_kernel_sp, struct vcpu, arch.guest_context.kernel_sp);
75 OFFSET(VCPU_kernel_ss, struct vcpu, arch.guest_context.kernel_ss);
76 OFFSET(VCPU_guest_context_flags, struct vcpu, arch.guest_context.flags);
77 OFFSET(VCPU_arch_guest_fpu_ctxt, struct vcpu, arch.guest_context.fpu_ctxt);
78 OFFSET(VCPU_nmi_cs, struct vcpu,
79 arch.guest_context.trap_ctxt[TRAP_nmi].cs);
80 OFFSET(VCPU_nmi_addr, struct vcpu,
81 arch.guest_context.trap_ctxt[TRAP_nmi].address);
82 OFFSET(VCPU_nmi_pending, struct vcpu, nmi_pending);
83 OFFSET(VCPU_nmi_masked, struct vcpu, nmi_masked);
84 DEFINE(_VGCF_failsafe_disables_events, _VGCF_failsafe_disables_events);
85 DEFINE(_VGCF_syscall_disables_events, _VGCF_syscall_disables_events);
86 BLANK();
88 OFFSET(VCPU_svm_vmcb_pa, struct vcpu, arch.hvm_svm.vmcb_pa);
89 OFFSET(VCPU_svm_vmcb, struct vcpu, arch.hvm_svm.vmcb);
90 OFFSET(VCPU_svm_vmcb_in_sync, struct vcpu, arch.hvm_svm.vmcb_in_sync);
91 BLANK();
93 OFFSET(VCPU_vmx_launched, struct vcpu, arch.hvm_vmx.launched);
94 OFFSET(VCPU_hvm_guest_cr2, struct vcpu, arch.hvm_vcpu.guest_cr[2]);
95 BLANK();
97 OFFSET(DOMAIN_is_32bit_pv, struct domain, arch.is_32bit_pv);
98 BLANK();
100 OFFSET(VMCB_rax, struct vmcb_struct, rax);
101 OFFSET(VMCB_rip, struct vmcb_struct, rip);
102 OFFSET(VMCB_rsp, struct vmcb_struct, rsp);
103 OFFSET(VMCB_rflags, struct vmcb_struct, rflags);
104 BLANK();
106 OFFSET(VCPUINFO_upcall_pending, struct vcpu_info, evtchn_upcall_pending);
107 OFFSET(VCPUINFO_upcall_mask, struct vcpu_info, evtchn_upcall_mask);
108 BLANK();
110 #ifdef CONFIG_COMPAT
111 OFFSET(COMPAT_VCPUINFO_upcall_pending, struct compat_vcpu_info, evtchn_upcall_pending);
112 OFFSET(COMPAT_VCPUINFO_upcall_mask, struct compat_vcpu_info, evtchn_upcall_mask);
113 BLANK();
114 #endif
116 OFFSET(CPUINFO_current_vcpu, struct cpu_info, current_vcpu);
117 DEFINE(CPUINFO_sizeof, sizeof(struct cpu_info));
118 BLANK();
120 OFFSET(TRAPBOUNCE_error_code, struct trap_bounce, error_code);
121 OFFSET(TRAPBOUNCE_flags, struct trap_bounce, flags);
122 OFFSET(TRAPBOUNCE_cs, struct trap_bounce, cs);
123 OFFSET(TRAPBOUNCE_eip, struct trap_bounce, eip);
124 BLANK();
126 #if PERF_COUNTERS
127 DEFINE(PERFC_hypercalls, PERFC_hypercalls);
128 DEFINE(PERFC_exceptions, PERFC_exceptions);
129 BLANK();
130 #endif
132 DEFINE(IRQSTAT_shift, LOG_2(sizeof(irq_cpustat_t)));
133 }