ia64/xen-unstable

view xen/include/asm-x86/processor.h @ 19848:5839491bbf20

[IA64] replace MAX_VCPUS with d->max_vcpus where necessary.

don't use MAX_VCPUS, and use vcpu::max_vcpus.
The changeset of 2f9e1348aa98 introduced max_vcpus to allow more vcpus
per guest. This patch is ia64 counter part.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Mon Jun 29 11:26:05 2009 +0900 (2009-06-29)
parents 67a0ffade665
children
line source
2 /* Portions are: Copyright (c) 1994 Linus Torvalds */
4 #ifndef __ASM_X86_PROCESSOR_H
5 #define __ASM_X86_PROCESSOR_H
7 #ifndef __ASSEMBLY__
8 #include <xen/config.h>
9 #include <xen/cache.h>
10 #include <xen/types.h>
11 #include <xen/smp.h>
12 #include <xen/percpu.h>
13 #include <public/xen.h>
14 #include <asm/types.h>
15 #include <asm/cpufeature.h>
16 #include <asm/desc.h>
17 #endif
19 /*
20 * CPU vendor IDs
21 */
22 #define X86_VENDOR_INTEL 0
23 #define X86_VENDOR_CYRIX 1
24 #define X86_VENDOR_AMD 2
25 #define X86_VENDOR_UMC 3
26 #define X86_VENDOR_NEXGEN 4
27 #define X86_VENDOR_CENTAUR 5
28 #define X86_VENDOR_RISE 6
29 #define X86_VENDOR_TRANSMETA 7
30 #define X86_VENDOR_NSC 8
31 #define X86_VENDOR_NUM 9
32 #define X86_VENDOR_UNKNOWN 0xff
34 /*
35 * EFLAGS bits
36 */
37 #define X86_EFLAGS_CF 0x00000001 /* Carry Flag */
38 #define X86_EFLAGS_PF 0x00000004 /* Parity Flag */
39 #define X86_EFLAGS_AF 0x00000010 /* Auxillary carry Flag */
40 #define X86_EFLAGS_ZF 0x00000040 /* Zero Flag */
41 #define X86_EFLAGS_SF 0x00000080 /* Sign Flag */
42 #define X86_EFLAGS_TF 0x00000100 /* Trap Flag */
43 #define X86_EFLAGS_IF 0x00000200 /* Interrupt Flag */
44 #define X86_EFLAGS_DF 0x00000400 /* Direction Flag */
45 #define X86_EFLAGS_OF 0x00000800 /* Overflow Flag */
46 #define X86_EFLAGS_IOPL 0x00003000 /* IOPL mask */
47 #define X86_EFLAGS_NT 0x00004000 /* Nested Task */
48 #define X86_EFLAGS_RF 0x00010000 /* Resume Flag */
49 #define X86_EFLAGS_VM 0x00020000 /* Virtual Mode */
50 #define X86_EFLAGS_AC 0x00040000 /* Alignment Check */
51 #define X86_EFLAGS_VIF 0x00080000 /* Virtual Interrupt Flag */
52 #define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */
53 #define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */
55 /*
56 * Intel CPU flags in CR0
57 */
58 #define X86_CR0_PE 0x00000001 /* Enable Protected Mode (RW) */
59 #define X86_CR0_MP 0x00000002 /* Monitor Coprocessor (RW) */
60 #define X86_CR0_EM 0x00000004 /* Require FPU Emulation (RO) */
61 #define X86_CR0_TS 0x00000008 /* Task Switched (RW) */
62 #define X86_CR0_ET 0x00000010 /* Extension type (RO) */
63 #define X86_CR0_NE 0x00000020 /* Numeric Error Reporting (RW) */
64 #define X86_CR0_WP 0x00010000 /* Supervisor Write Protect (RW) */
65 #define X86_CR0_AM 0x00040000 /* Alignment Checking (RW) */
66 #define X86_CR0_NW 0x20000000 /* Not Write-Through (RW) */
67 #define X86_CR0_CD 0x40000000 /* Cache Disable (RW) */
68 #define X86_CR0_PG 0x80000000 /* Paging (RW) */
70 /*
71 * Intel CPU features in CR4
72 */
73 #define X86_CR4_VME 0x0001 /* enable vm86 extensions */
74 #define X86_CR4_PVI 0x0002 /* virtual interrupts flag enable */
75 #define X86_CR4_TSD 0x0004 /* disable time stamp at ipl 3 */
76 #define X86_CR4_DE 0x0008 /* enable debugging extensions */
77 #define X86_CR4_PSE 0x0010 /* enable page size extensions */
78 #define X86_CR4_PAE 0x0020 /* enable physical address extensions */
79 #define X86_CR4_MCE 0x0040 /* Machine check enable */
80 #define X86_CR4_PGE 0x0080 /* enable global pages */
81 #define X86_CR4_PCE 0x0100 /* enable performance counters at ipl 3 */
82 #define X86_CR4_OSFXSR 0x0200 /* enable fast FPU save and restore */
83 #define X86_CR4_OSXMMEXCPT 0x0400 /* enable unmasked SSE exceptions */
84 #define X86_CR4_VMXE 0x2000 /* enable VMX */
85 #define X86_CR4_SMXE 0x4000 /* enable SMX */
87 /*
88 * Trap/fault mnemonics.
89 */
90 #define TRAP_divide_error 0
91 #define TRAP_debug 1
92 #define TRAP_nmi 2
93 #define TRAP_int3 3
94 #define TRAP_overflow 4
95 #define TRAP_bounds 5
96 #define TRAP_invalid_op 6
97 #define TRAP_no_device 7
98 #define TRAP_double_fault 8
99 #define TRAP_copro_seg 9
100 #define TRAP_invalid_tss 10
101 #define TRAP_no_segment 11
102 #define TRAP_stack_error 12
103 #define TRAP_gp_fault 13
104 #define TRAP_page_fault 14
105 #define TRAP_spurious_int 15
106 #define TRAP_copro_error 16
107 #define TRAP_alignment_check 17
108 #define TRAP_machine_check 18
109 #define TRAP_simd_error 19
111 /* Set for entry via SYSCALL. Informs return code to use SYSRETQ not IRETQ. */
112 /* NB. Same as VGCF_in_syscall. No bits in common with any other TRAP_ defn. */
113 #define TRAP_syscall 256
115 /* Boolean return code: the reason for a fault has been fixed. */
116 #define EXCRET_fault_fixed 1
118 /* 'trap_bounce' flags values */
119 #define TBF_EXCEPTION 1
120 #define TBF_EXCEPTION_ERRCODE 2
121 #define TBF_INTERRUPT 8
122 #define TBF_FAILSAFE 16
124 /* 'arch_vcpu' flags values */
125 #define _TF_kernel_mode 0
126 #define TF_kernel_mode (1<<_TF_kernel_mode)
128 /* #PF error code values. */
129 #define PFEC_page_present (1U<<0)
130 #define PFEC_write_access (1U<<1)
131 #define PFEC_user_mode (1U<<2)
132 #define PFEC_reserved_bit (1U<<3)
133 #define PFEC_insn_fetch (1U<<4)
135 #ifndef __ASSEMBLY__
137 struct domain;
138 struct vcpu;
140 /*
141 * Default implementation of macro that returns current
142 * instruction pointer ("program counter").
143 */
144 #ifdef __x86_64__
145 #define current_text_addr() ({ \
146 void *pc; \
147 asm ( "leaq 1f(%%rip),%0\n1:" : "=r" (pc) ); \
148 pc; \
149 })
150 #else
151 #define current_text_addr() ({ \
152 void *pc; \
153 asm ( "movl $1f,%0\n1:" : "=g" (pc) ); \
154 pc; \
155 })
156 #endif
158 struct cpuinfo_x86 {
159 __u8 x86; /* CPU family */
160 __u8 x86_vendor; /* CPU vendor */
161 __u8 x86_model;
162 __u8 x86_mask;
163 int cpuid_level; /* Maximum supported CPUID level, -1=no CPUID */
164 unsigned int x86_capability[NCAPINTS];
165 char x86_vendor_id[16];
166 char x86_model_id[64];
167 int x86_cache_size; /* in KB - valid for CPUS which support this call */
168 int x86_cache_alignment; /* In bytes */
169 int x86_power;
170 __u32 x86_max_cores; /* cpuid returned max cores value */
171 __u32 booted_cores; /* number of cores as seen by OS */
172 __u32 x86_num_siblings; /* cpuid logical cpus per chip value */
173 __u32 apicid;
174 unsigned short x86_clflush_size;
175 } __cacheline_aligned;
177 /*
178 * capabilities of CPUs
179 */
181 extern struct cpuinfo_x86 boot_cpu_data;
183 #ifdef CONFIG_SMP
184 extern struct cpuinfo_x86 cpu_data[];
185 #define current_cpu_data cpu_data[smp_processor_id()]
186 #else
187 #define cpu_data (&boot_cpu_data)
188 #define current_cpu_data boot_cpu_data
189 #endif
191 extern u64 host_pat;
192 extern int phys_proc_id[NR_CPUS];
193 extern int cpu_core_id[NR_CPUS];
195 extern void identify_cpu(struct cpuinfo_x86 *);
196 extern void setup_clear_cpu_cap(unsigned int);
197 extern void print_cpu_info(struct cpuinfo_x86 *);
198 extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
199 extern void dodgy_tsc(void);
201 #ifdef CONFIG_X86_HT
202 extern void detect_ht(struct cpuinfo_x86 *c);
203 #else
204 static always_inline void detect_ht(struct cpuinfo_x86 *c) {}
205 #endif
207 #define cpu_to_core(_cpu) (cpu_core_id[_cpu])
208 #define cpu_to_socket(_cpu) (phys_proc_id[_cpu])
210 /*
211 * Generic CPUID function
212 * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
213 * resulting in stale register contents being returned.
214 */
215 #define cpuid(_op,_eax,_ebx,_ecx,_edx) \
216 asm ( "cpuid" \
217 : "=a" (*(int *)(_eax)), \
218 "=b" (*(int *)(_ebx)), \
219 "=c" (*(int *)(_ecx)), \
220 "=d" (*(int *)(_edx)) \
221 : "0" (_op), "2" (0) )
223 /* Some CPUID calls want 'count' to be placed in ecx */
224 static inline void cpuid_count(
225 int op,
226 int count,
227 unsigned int *eax,
228 unsigned int *ebx,
229 unsigned int *ecx,
230 unsigned int *edx)
231 {
232 asm ( "cpuid"
233 : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
234 : "0" (op), "c" (count) );
235 }
237 /*
238 * CPUID functions returning a single datum
239 */
240 static always_inline unsigned int cpuid_eax(unsigned int op)
241 {
242 unsigned int eax;
244 asm ( "cpuid"
245 : "=a" (eax)
246 : "0" (op)
247 : "bx", "cx", "dx" );
248 return eax;
249 }
251 static always_inline unsigned int cpuid_ebx(unsigned int op)
252 {
253 unsigned int eax, ebx;
255 asm ( "cpuid"
256 : "=a" (eax), "=b" (ebx)
257 : "0" (op)
258 : "cx", "dx" );
259 return ebx;
260 }
262 static always_inline unsigned int cpuid_ecx(unsigned int op)
263 {
264 unsigned int eax, ecx;
266 asm ( "cpuid"
267 : "=a" (eax), "=c" (ecx)
268 : "0" (op)
269 : "bx", "dx" );
270 return ecx;
271 }
273 static always_inline unsigned int cpuid_edx(unsigned int op)
274 {
275 unsigned int eax, edx;
277 asm ( "cpuid"
278 : "=a" (eax), "=d" (edx)
279 : "0" (op)
280 : "bx", "cx" );
281 return edx;
282 }
284 static inline unsigned long read_cr0(void)
285 {
286 unsigned long cr0;
287 asm volatile ( "mov %%cr0,%0\n\t" : "=r" (cr0) );
288 return cr0;
289 }
291 static inline void write_cr0(unsigned long val)
292 {
293 asm volatile ( "mov %0,%%cr0" : : "r" ((unsigned long)val) );
294 }
296 static inline unsigned long read_cr2(void)
297 {
298 unsigned long cr2;
299 asm volatile ( "mov %%cr2,%0\n\t" : "=r" (cr2) );
300 return cr2;
301 }
303 DECLARE_PER_CPU(unsigned long, cr4);
305 static inline unsigned long read_cr4(void)
306 {
307 return this_cpu(cr4);
308 }
310 static inline void write_cr4(unsigned long val)
311 {
312 this_cpu(cr4) = val;
313 asm volatile ( "mov %0,%%cr4" : : "r" (val) );
314 }
316 /* Clear and set 'TS' bit respectively */
317 static inline void clts(void)
318 {
319 asm volatile ( "clts" );
320 }
322 static inline void stts(void)
323 {
324 write_cr0(X86_CR0_TS|read_cr0());
325 }
327 /*
328 * Save the cr4 feature set we're using (ie
329 * Pentium 4MB enable and PPro Global page
330 * enable), so that any CPU's that boot up
331 * after us can get the correct flags.
332 */
333 extern unsigned long mmu_cr4_features;
335 static always_inline void set_in_cr4 (unsigned long mask)
336 {
337 mmu_cr4_features |= mask;
338 write_cr4(read_cr4() | mask);
339 }
341 static always_inline void clear_in_cr4 (unsigned long mask)
342 {
343 mmu_cr4_features &= ~mask;
344 write_cr4(read_cr4() & ~mask);
345 }
347 /*
348 * NSC/Cyrix CPU configuration register indexes
349 */
351 #define CX86_PCR0 0x20
352 #define CX86_GCR 0xb8
353 #define CX86_CCR0 0xc0
354 #define CX86_CCR1 0xc1
355 #define CX86_CCR2 0xc2
356 #define CX86_CCR3 0xc3
357 #define CX86_CCR4 0xe8
358 #define CX86_CCR5 0xe9
359 #define CX86_CCR6 0xea
360 #define CX86_CCR7 0xeb
361 #define CX86_PCR1 0xf0
362 #define CX86_DIR0 0xfe
363 #define CX86_DIR1 0xff
364 #define CX86_ARR_BASE 0xc4
365 #define CX86_RCR_BASE 0xdc
367 /*
368 * NSC/Cyrix CPU indexed register access macros
369 */
371 #define getCx86(reg) ({ outb((reg), 0x22); inb(0x23); })
373 #define setCx86(reg, data) do { \
374 outb((reg), 0x22); \
375 outb((data), 0x23); \
376 } while (0)
378 /* Stop speculative execution */
379 static inline void sync_core(void)
380 {
381 int tmp;
382 asm volatile (
383 "cpuid"
384 : "=a" (tmp)
385 : "0" (1)
386 : "ebx","ecx","edx","memory" );
387 }
389 static always_inline void __monitor(const void *eax, unsigned long ecx,
390 unsigned long edx)
391 {
392 /* "monitor %eax,%ecx,%edx;" */
393 asm volatile (
394 ".byte 0x0f,0x01,0xc8;"
395 : : "a" (eax), "c" (ecx), "d"(edx) );
396 }
398 static always_inline void __mwait(unsigned long eax, unsigned long ecx)
399 {
400 /* "mwait %eax,%ecx;" */
401 asm volatile (
402 ".byte 0x0f,0x01,0xc9;"
403 : : "a" (eax), "c" (ecx) );
404 }
406 #define IOBMP_BYTES 8192
407 #define IOBMP_INVALID_OFFSET 0x8000
409 struct tss_struct {
410 unsigned short back_link,__blh;
411 #ifdef __x86_64__
412 union { u64 rsp0, esp0; };
413 union { u64 rsp1, esp1; };
414 union { u64 rsp2, esp2; };
415 u64 reserved1;
416 u64 ist[7];
417 u64 reserved2;
418 u16 reserved3;
419 #else
420 u32 esp0;
421 u16 ss0,__ss0h;
422 u32 esp1;
423 u16 ss1,__ss1h;
424 u32 esp2;
425 u16 ss2,__ss2h;
426 u32 __cr3;
427 u32 eip;
428 u32 eflags;
429 u32 eax,ecx,edx,ebx;
430 u32 esp;
431 u32 ebp;
432 u32 esi;
433 u32 edi;
434 u16 es, __esh;
435 u16 cs, __csh;
436 u16 ss, __ssh;
437 u16 ds, __dsh;
438 u16 fs, __fsh;
439 u16 gs, __gsh;
440 u16 ldt, __ldth;
441 u16 trace;
442 #endif
443 u16 bitmap;
444 /* Pads the TSS to be cacheline-aligned (total size is 0x80). */
445 u8 __cacheline_filler[24];
446 } __cacheline_aligned __attribute__((packed));
448 #ifdef __x86_64__
449 # define IST_DF 1UL
450 # define IST_NMI 2UL
451 # define IST_MCE 3UL
452 # define IST_MAX 3UL
453 #endif
455 #define IDT_ENTRIES 256
456 extern idt_entry_t idt_table[];
457 extern idt_entry_t *idt_tables[];
459 extern struct tss_struct init_tss[NR_CPUS];
461 extern void init_int80_direct_trap(struct vcpu *v);
463 #if defined(CONFIG_X86_32)
465 #define set_int80_direct_trap(_ed) \
466 (memcpy(idt_tables[(_ed)->processor] + 0x80, \
467 &((_ed)->arch.int80_desc), 8))
469 #else
471 #define set_int80_direct_trap(_ed) ((void)0)
473 #endif
475 extern int gpf_emulate_4gb(struct cpu_user_regs *regs);
477 extern void write_ptbase(struct vcpu *v);
479 void destroy_gdt(struct vcpu *d);
480 long set_gdt(struct vcpu *d,
481 unsigned long *frames,
482 unsigned int entries);
484 #define write_debugreg(reg, val) do { \
485 unsigned long __val = val; \
486 asm volatile ( "mov %0,%%db" #reg : : "r" (__val) ); \
487 } while (0)
488 #define read_debugreg(reg) ({ \
489 unsigned long __val; \
490 asm volatile ( "mov %%db" #reg ",%0" : "=r" (__val) ); \
491 __val; \
492 })
493 long set_debugreg(struct vcpu *p, int reg, unsigned long value);
495 /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
496 static always_inline void rep_nop(void)
497 {
498 asm volatile ( "rep;nop" : : : "memory" );
499 }
501 #define cpu_relax() rep_nop()
503 /* Prefetch instructions for Pentium III and AMD Athlon */
504 #ifdef CONFIG_MPENTIUMIII
506 #define ARCH_HAS_PREFETCH
507 extern always_inline void prefetch(const void *x)
508 {
509 asm volatile ( "prefetchnta (%0)" : : "r"(x) );
510 }
512 #elif CONFIG_X86_USE_3DNOW
514 #define ARCH_HAS_PREFETCH
515 #define ARCH_HAS_PREFETCHW
516 #define ARCH_HAS_SPINLOCK_PREFETCH
518 extern always_inline void prefetch(const void *x)
519 {
520 asm volatile ( "prefetch (%0)" : : "r"(x) );
521 }
523 extern always_inline void prefetchw(const void *x)
524 {
525 asm volatile ( "prefetchw (%0)" : : "r"(x) );
526 }
527 #define spin_lock_prefetch(x) prefetchw(x)
529 #endif
531 void show_stack(struct cpu_user_regs *regs);
532 void show_stack_overflow(unsigned int cpu, unsigned long esp);
533 void show_registers(struct cpu_user_regs *regs);
534 void show_execution_state(struct cpu_user_regs *regs);
535 void show_page_walk(unsigned long addr);
536 asmlinkage void fatal_trap(int trapnr, struct cpu_user_regs *regs);
538 #ifdef CONFIG_COMPAT
539 void compat_show_guest_stack(struct vcpu *, struct cpu_user_regs *, int lines);
540 #else
541 #define compat_show_guest_stack(vcpu, regs, lines) ((void)0)
542 #endif
544 extern void mtrr_ap_init(void);
545 extern void mtrr_bp_init(void);
547 void mcheck_init(struct cpuinfo_x86 *c);
548 asmlinkage void do_machine_check(struct cpu_user_regs *regs);
549 void cpu_mcheck_distribute_cmci(void);
550 void cpu_mcheck_disable(void);
552 int cpuid_hypervisor_leaves(
553 uint32_t idx, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);
554 int rdmsr_hypervisor_regs(
555 uint32_t idx, uint32_t *eax, uint32_t *edx);
556 int wrmsr_hypervisor_regs(
557 uint32_t idx, uint32_t eax, uint32_t edx);
559 int microcode_update(XEN_GUEST_HANDLE(const_void), unsigned long len);
560 int microcode_resume_cpu(int cpu);
562 #endif /* !__ASSEMBLY__ */
564 #endif /* __ASM_X86_PROCESSOR_H */
566 /*
567 * Local variables:
568 * mode: C
569 * c-set-style: "BSD"
570 * c-basic-offset: 4
571 * tab-width: 4
572 * indent-tabs-mode: nil
573 * End:
574 */