ea222cfe7b006ccf50d477e9512c6dd12932af92
[cascardo/linux.git] / include / asm-x86 / processor.h
1 #ifndef __ASM_X86_PROCESSOR_H
2 #define __ASM_X86_PROCESSOR_H
3
4 #include <asm/processor-flags.h>
5
6 /* Forward declaration, a strange C thing */
7 struct task_struct;
8 struct mm_struct;
9
10 #include <asm/page.h>
11 #include <asm/percpu.h>
12 #include <asm/system.h>
13 #include <asm/percpu.h>
14 #include <linux/cpumask.h>
15 #include <linux/cache.h>
16
17 /*
18  * Default implementation of macro that returns current
19  * instruction pointer ("program counter").
20  */
21 static inline void *current_text_addr(void)
22 {
23         void *pc;
24         asm volatile("mov $1f,%0\n1:":"=r" (pc));
25         return pc;
26 }
27
28 #ifdef CONFIG_X86_VSMP
29 #define ARCH_MIN_TASKALIGN      (1 << INTERNODE_CACHE_SHIFT)
30 #define ARCH_MIN_MMSTRUCT_ALIGN (1 << INTERNODE_CACHE_SHIFT)
31 #else
32 #define ARCH_MIN_TASKALIGN      16
33 #define ARCH_MIN_MMSTRUCT_ALIGN 0
34 #endif
35
36 /*
37  *  CPU type and hardware bug flags. Kept separately for each CPU.
38  *  Members of this structure are referenced in head.S, so think twice
39  *  before touching them. [mj]
40  */
41
42 struct cpuinfo_x86 {
43         __u8    x86;            /* CPU family */
44         __u8    x86_vendor;     /* CPU vendor */
45         __u8    x86_model;
46         __u8    x86_mask;
47 #ifdef CONFIG_X86_32
48         char    wp_works_ok;    /* It doesn't on 386's */
49         char    hlt_works_ok;   /* Problems on some 486Dx4's and old 386's */
50         char    hard_math;
51         char    rfu;
52         char    fdiv_bug;
53         char    f00f_bug;
54         char    coma_bug;
55         char    pad0;
56 #else
57         /* number of 4K pages in DTLB/ITLB combined(in pages)*/
58         int     x86_tlbsize;
59         __u8    x86_virt_bits, x86_phys_bits;
60         /* cpuid returned core id bits */
61         __u8    x86_coreid_bits;
62         /* Max extended CPUID function supported */
63         __u32   extended_cpuid_level;
64 #endif
65         int     cpuid_level;    /* Maximum supported CPUID level, -1=no CPUID */
66         __u32   x86_capability[NCAPINTS];
67         char    x86_vendor_id[16];
68         char    x86_model_id[64];
69         int     x86_cache_size;  /* in KB - valid for CPUS which support this
70                                     call  */
71         int     x86_cache_alignment;    /* In bytes */
72         int     x86_power;
73         unsigned long loops_per_jiffy;
74 #ifdef CONFIG_SMP
75         cpumask_t llc_shared_map;       /* cpus sharing the last level cache */
76 #endif
77         unsigned char x86_max_cores;    /* cpuid returned max cores value */
78         unsigned char apicid;
79         unsigned short x86_clflush_size;
80 #ifdef CONFIG_SMP
81         unsigned char booted_cores;     /* number of cores as seen by OS */
82         __u8 phys_proc_id;              /* Physical processor id. */
83         __u8 cpu_core_id;               /* Core id */
84         __u8 cpu_index;                 /* index into per_cpu list */
85 #endif
86 } __attribute__((__aligned__(SMP_CACHE_BYTES)));
87
88 #define X86_VENDOR_INTEL 0
89 #define X86_VENDOR_CYRIX 1
90 #define X86_VENDOR_AMD 2
91 #define X86_VENDOR_UMC 3
92 #define X86_VENDOR_NEXGEN 4
93 #define X86_VENDOR_CENTAUR 5
94 #define X86_VENDOR_TRANSMETA 7
95 #define X86_VENDOR_NSC 8
96 #define X86_VENDOR_NUM 9
97 #define X86_VENDOR_UNKNOWN 0xff
98
99 /*
100  * capabilities of CPUs
101  */
102 extern struct cpuinfo_x86 boot_cpu_data;
103 extern struct cpuinfo_x86 new_cpu_data;
104 extern struct tss_struct doublefault_tss;
105
106 #ifdef CONFIG_SMP
107 DECLARE_PER_CPU(struct cpuinfo_x86, cpu_info);
108 #define cpu_data(cpu)           per_cpu(cpu_info, cpu)
109 #define current_cpu_data        cpu_data(smp_processor_id())
110 #else
111 #define cpu_data(cpu)           boot_cpu_data
112 #define current_cpu_data        boot_cpu_data
113 #endif
114
115 void cpu_detect(struct cpuinfo_x86 *c);
116
117 extern void identify_cpu(struct cpuinfo_x86 *);
118 extern void identify_boot_cpu(void);
119 extern void identify_secondary_cpu(struct cpuinfo_x86 *);
120 extern void print_cpu_info(struct cpuinfo_x86 *);
121 extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
122 extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
123 extern unsigned short num_cache_leaves;
124
125 #if defined(CONFIG_X86_HT) || defined(CONFIG_X86_64)
126 extern void detect_ht(struct cpuinfo_x86 *c);
127 #else
128 static inline void detect_ht(struct cpuinfo_x86 *c) {}
129 #endif
130
131 static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
132                                          unsigned int *ecx, unsigned int *edx)
133 {
134         /* ecx is often an input as well as an output. */
135         __asm__("cpuid"
136                 : "=a" (*eax),
137                   "=b" (*ebx),
138                   "=c" (*ecx),
139                   "=d" (*edx)
140                 : "0" (*eax), "2" (*ecx));
141 }
142
143 static inline void load_cr3(pgd_t *pgdir)
144 {
145         write_cr3(__pa(pgdir));
146 }
147
148 #ifdef CONFIG_X86_32
149 /* This is the TSS defined by the hardware. */
150 struct x86_hw_tss {
151         unsigned short  back_link, __blh;
152         unsigned long   sp0;
153         unsigned short  ss0, __ss0h;
154         unsigned long   sp1;
155         unsigned short  ss1, __ss1h;    /* ss1 caches MSR_IA32_SYSENTER_CS */
156         unsigned long   sp2;
157         unsigned short  ss2, __ss2h;
158         unsigned long   __cr3;
159         unsigned long   ip;
160         unsigned long   flags;
161         unsigned long   ax, cx, dx, bx;
162         unsigned long   sp, bp, si, di;
163         unsigned short  es, __esh;
164         unsigned short  cs, __csh;
165         unsigned short  ss, __ssh;
166         unsigned short  ds, __dsh;
167         unsigned short  fs, __fsh;
168         unsigned short  gs, __gsh;
169         unsigned short  ldt, __ldth;
170         unsigned short  trace, io_bitmap_base;
171 } __attribute__((packed));
172 #else
173 struct x86_hw_tss {
174         u32 reserved1;
175         u64 sp0;
176         u64 sp1;
177         u64 sp2;
178         u64 reserved2;
179         u64 ist[7];
180         u32 reserved3;
181         u32 reserved4;
182         u16 reserved5;
183         u16 io_bitmap_base;
184 } __attribute__((packed)) ____cacheline_aligned;
185 #endif
186
187 /*
188  * Size of io_bitmap.
189  */
190 #define IO_BITMAP_BITS  65536
191 #define IO_BITMAP_BYTES (IO_BITMAP_BITS/8)
192 #define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))
193 #define IO_BITMAP_OFFSET offsetof(struct tss_struct, io_bitmap)
194 #define INVALID_IO_BITMAP_OFFSET 0x8000
195 #define INVALID_IO_BITMAP_OFFSET_LAZY 0x9000
196
197 struct tss_struct {
198         struct x86_hw_tss x86_tss;
199
200         /*
201          * The extra 1 is there because the CPU will access an
202          * additional byte beyond the end of the IO permission
203          * bitmap. The extra byte must be all 1 bits, and must
204          * be within the limit.
205          */
206         unsigned long   io_bitmap[IO_BITMAP_LONGS + 1];
207         /*
208          * Cache the current maximum and the last task that used the bitmap:
209          */
210         unsigned long io_bitmap_max;
211         struct thread_struct *io_bitmap_owner;
212         /*
213          * pads the TSS to be cacheline-aligned (size is 0x100)
214          */
215         unsigned long __cacheline_filler[35];
216         /*
217          * .. and then another 0x100 bytes for emergency kernel stack
218          */
219         unsigned long stack[64];
220 } __attribute__((packed));
221
222 DECLARE_PER_CPU(struct tss_struct, init_tss);
223
224 /* Save the original ist values for checking stack pointers during debugging */
225 struct orig_ist {
226         unsigned long ist[7];
227 };
228
229 #define MXCSR_DEFAULT           0x1f80
230
231 struct i387_fsave_struct {
232         u32     cwd;
233         u32     swd;
234         u32     twd;
235         u32     fip;
236         u32     fcs;
237         u32     foo;
238         u32     fos;
239         u32     st_space[20];   /* 8*10 bytes for each FP-reg = 80 bytes */
240         u32     status;         /* software status information */
241 };
242
243 struct i387_fxsave_struct {
244         u16     cwd;
245         u16     swd;
246         u16     twd;
247         u16     fop;
248         union {
249                 struct {
250                         u64     rip;
251                         u64     rdp;
252                 };
253                 struct {
254                         u32     fip;
255                         u32     fcs;
256                         u32     foo;
257                         u32     fos;
258                 };
259         };
260         u32     mxcsr;
261         u32     mxcsr_mask;
262         u32     st_space[32];   /* 8*16 bytes for each FP-reg = 128 bytes */
263         u32     xmm_space[64];  /* 16*16 bytes for each XMM-reg = 256 bytes */
264         u32     padding[24];
265 } __attribute__((aligned(16)));
266
267 struct i387_soft_struct {
268         u32     cwd;
269         u32     swd;
270         u32     twd;
271         u32     fip;
272         u32     fcs;
273         u32     foo;
274         u32     fos;
275         u32     st_space[20];   /* 8*10 bytes for each FP-reg = 80 bytes */
276         u8      ftop, changed, lookahead, no_update, rm, alimit;
277         struct info     *info;
278         u32     entry_eip;
279 };
280
281 union i387_union {
282         struct i387_fsave_struct        fsave;
283         struct i387_fxsave_struct       fxsave;
284         struct i387_soft_struct         soft;
285 };
286
287 #ifdef CONFIG_X86_32
288 # include "processor_32.h"
289 #else
290 # include "processor_64.h"
291 #endif
292
293 extern void print_cpu_info(struct cpuinfo_x86 *);
294 extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
295 extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
296 extern unsigned short num_cache_leaves;
297
298 struct thread_struct {
299 /* cached TLS descriptors. */
300         struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
301         unsigned long   sp0;
302         unsigned long   sp;
303 #ifdef CONFIG_X86_32
304         unsigned long   sysenter_cs;
305 #else
306         unsigned long   usersp; /* Copy from PDA */
307         unsigned short  es, ds, fsindex, gsindex;
308 #endif
309         unsigned long   ip;
310         unsigned long   fs;
311         unsigned long   gs;
312 /* Hardware debugging registers */
313         unsigned long   debugreg0;
314         unsigned long   debugreg1;
315         unsigned long   debugreg2;
316         unsigned long   debugreg3;
317         unsigned long   debugreg6;
318         unsigned long   debugreg7;
319 /* fault info */
320         unsigned long   cr2, trap_no, error_code;
321 /* floating point info */
322         union i387_union        i387 __attribute__((aligned(16)));;
323 #ifdef CONFIG_X86_32
324 /* virtual 86 mode info */
325         struct vm86_struct __user *vm86_info;
326         unsigned long           screen_bitmap;
327         unsigned long           v86flags, v86mask, saved_sp0;
328         unsigned int            saved_fs, saved_gs;
329 #endif
330 /* IO permissions */
331         unsigned long   *io_bitmap_ptr;
332         unsigned long   iopl;
333 /* max allowed port in the bitmap, in bytes: */
334         unsigned io_bitmap_max;
335 /* MSR_IA32_DEBUGCTLMSR value to switch in if TIF_DEBUGCTLMSR is set.  */
336         unsigned long   debugctlmsr;
337 /* Debug Store - if not 0 points to a DS Save Area configuration;
338  *               goes into MSR_IA32_DS_AREA */
339         unsigned long   ds_area_msr;
340 };
341
342 static inline unsigned long native_get_debugreg(int regno)
343 {
344         unsigned long val = 0;  /* Damn you, gcc! */
345
346         switch (regno) {
347         case 0:
348                 asm("mov %%db0, %0" :"=r" (val)); break;
349         case 1:
350                 asm("mov %%db1, %0" :"=r" (val)); break;
351         case 2:
352                 asm("mov %%db2, %0" :"=r" (val)); break;
353         case 3:
354                 asm("mov %%db3, %0" :"=r" (val)); break;
355         case 6:
356                 asm("mov %%db6, %0" :"=r" (val)); break;
357         case 7:
358                 asm("mov %%db7, %0" :"=r" (val)); break;
359         default:
360                 BUG();
361         }
362         return val;
363 }
364
365 static inline void native_set_debugreg(int regno, unsigned long value)
366 {
367         switch (regno) {
368         case 0:
369                 asm("mov %0,%%db0"      : /* no output */ :"r" (value));
370                 break;
371         case 1:
372                 asm("mov %0,%%db1"      : /* no output */ :"r" (value));
373                 break;
374         case 2:
375                 asm("mov %0,%%db2"      : /* no output */ :"r" (value));
376                 break;
377         case 3:
378                 asm("mov %0,%%db3"      : /* no output */ :"r" (value));
379                 break;
380         case 6:
381                 asm("mov %0,%%db6"      : /* no output */ :"r" (value));
382                 break;
383         case 7:
384                 asm("mov %0,%%db7"      : /* no output */ :"r" (value));
385                 break;
386         default:
387                 BUG();
388         }
389 }
390
391 /*
392  * Set IOPL bits in EFLAGS from given mask
393  */
394 static inline void native_set_iopl_mask(unsigned mask)
395 {
396 #ifdef CONFIG_X86_32
397         unsigned int reg;
398         __asm__ __volatile__ ("pushfl;"
399                               "popl %0;"
400                               "andl %1, %0;"
401                               "orl %2, %0;"
402                               "pushl %0;"
403                               "popfl"
404                                 : "=&r" (reg)
405                                 : "i" (~X86_EFLAGS_IOPL), "r" (mask));
406 #endif
407 }
408
409 static inline void native_load_sp0(struct tss_struct *tss,
410                                    struct thread_struct *thread)
411 {
412         tss->x86_tss.sp0 = thread->sp0;
413 #ifdef CONFIG_X86_32
414         /* Only happens when SEP is enabled, no need to test "SEP"arately */
415         if (unlikely(tss->x86_tss.ss1 != thread->sysenter_cs)) {
416                 tss->x86_tss.ss1 = thread->sysenter_cs;
417                 wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
418         }
419 #endif
420 }
421
422 #ifdef CONFIG_PARAVIRT
423 #include <asm/paravirt.h>
424 #else
425 #define __cpuid native_cpuid
426 #define paravirt_enabled() 0
427
428 /*
429  * These special macros can be used to get or set a debugging register
430  */
431 #define get_debugreg(var, register)                             \
432         (var) = native_get_debugreg(register)
433 #define set_debugreg(value, register)                           \
434         native_set_debugreg(register, value)
435
436 static inline void load_sp0(struct tss_struct *tss,
437                             struct thread_struct *thread)
438 {
439         native_load_sp0(tss, thread);
440 }
441
442 #define set_iopl_mask native_set_iopl_mask
443 #endif /* CONFIG_PARAVIRT */
444
445 /*
446  * Save the cr4 feature set we're using (ie
447  * Pentium 4MB enable and PPro Global page
448  * enable), so that any CPU's that boot up
449  * after us can get the correct flags.
450  */
451 extern unsigned long mmu_cr4_features;
452
453 static inline void set_in_cr4(unsigned long mask)
454 {
455         unsigned cr4;
456         mmu_cr4_features |= mask;
457         cr4 = read_cr4();
458         cr4 |= mask;
459         write_cr4(cr4);
460 }
461
462 static inline void clear_in_cr4(unsigned long mask)
463 {
464         unsigned cr4;
465         mmu_cr4_features &= ~mask;
466         cr4 = read_cr4();
467         cr4 &= ~mask;
468         write_cr4(cr4);
469 }
470
471 struct microcode_header {
472         unsigned int hdrver;
473         unsigned int rev;
474         unsigned int date;
475         unsigned int sig;
476         unsigned int cksum;
477         unsigned int ldrver;
478         unsigned int pf;
479         unsigned int datasize;
480         unsigned int totalsize;
481         unsigned int reserved[3];
482 };
483
484 struct microcode {
485         struct microcode_header hdr;
486         unsigned int bits[0];
487 };
488
489 typedef struct microcode microcode_t;
490 typedef struct microcode_header microcode_header_t;
491
492 /* microcode format is extended from prescott processors */
493 struct extended_signature {
494         unsigned int sig;
495         unsigned int pf;
496         unsigned int cksum;
497 };
498
499 struct extended_sigtable {
500         unsigned int count;
501         unsigned int cksum;
502         unsigned int reserved[3];
503         struct extended_signature sigs[0];
504 };
505
506 typedef struct {
507         unsigned long seg;
508 } mm_segment_t;
509
510
511 /*
512  * create a kernel thread without removing it from tasklists
513  */
514 extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
515
516 /* Free all resources held by a thread. */
517 extern void release_thread(struct task_struct *);
518
519 /* Prepare to copy thread state - unlazy all lazy status */
520 extern void prepare_to_copy(struct task_struct *tsk);
521
522 unsigned long get_wchan(struct task_struct *p);
523
524 /*
525  * Generic CPUID function
526  * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
527  * resulting in stale register contents being returned.
528  */
529 static inline void cpuid(unsigned int op,
530                          unsigned int *eax, unsigned int *ebx,
531                          unsigned int *ecx, unsigned int *edx)
532 {
533         *eax = op;
534         *ecx = 0;
535         __cpuid(eax, ebx, ecx, edx);
536 }
537
538 /* Some CPUID calls want 'count' to be placed in ecx */
539 static inline void cpuid_count(unsigned int op, int count,
540                                unsigned int *eax, unsigned int *ebx,
541                                unsigned int *ecx, unsigned int *edx)
542 {
543         *eax = op;
544         *ecx = count;
545         __cpuid(eax, ebx, ecx, edx);
546 }
547
548 /*
549  * CPUID functions returning a single datum
550  */
551 static inline unsigned int cpuid_eax(unsigned int op)
552 {
553         unsigned int eax, ebx, ecx, edx;
554
555         cpuid(op, &eax, &ebx, &ecx, &edx);
556         return eax;
557 }
558 static inline unsigned int cpuid_ebx(unsigned int op)
559 {
560         unsigned int eax, ebx, ecx, edx;
561
562         cpuid(op, &eax, &ebx, &ecx, &edx);
563         return ebx;
564 }
565 static inline unsigned int cpuid_ecx(unsigned int op)
566 {
567         unsigned int eax, ebx, ecx, edx;
568
569         cpuid(op, &eax, &ebx, &ecx, &edx);
570         return ecx;
571 }
572 static inline unsigned int cpuid_edx(unsigned int op)
573 {
574         unsigned int eax, ebx, ecx, edx;
575
576         cpuid(op, &eax, &ebx, &ecx, &edx);
577         return edx;
578 }
579
580 /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
581 static inline void rep_nop(void)
582 {
583         __asm__ __volatile__("rep;nop": : :"memory");
584 }
585
586 /* Stop speculative execution */
587 static inline void sync_core(void)
588 {
589         int tmp;
590         asm volatile("cpuid" : "=a" (tmp) : "0" (1)
591                                           : "ebx", "ecx", "edx", "memory");
592 }
593
594 #define cpu_relax()   rep_nop()
595
596 static inline void __monitor(const void *eax, unsigned long ecx,
597                 unsigned long edx)
598 {
599         /* "monitor %eax,%ecx,%edx;" */
600         asm volatile(
601                 ".byte 0x0f,0x01,0xc8;"
602                 : :"a" (eax), "c" (ecx), "d"(edx));
603 }
604
605 static inline void __mwait(unsigned long eax, unsigned long ecx)
606 {
607         /* "mwait %eax,%ecx;" */
608         asm volatile(
609                 ".byte 0x0f,0x01,0xc9;"
610                 : :"a" (eax), "c" (ecx));
611 }
612
613 static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
614 {
615         /* "mwait %eax,%ecx;" */
616         asm volatile(
617                 "sti; .byte 0x0f,0x01,0xc9;"
618                 : :"a" (eax), "c" (ecx));
619 }
620
621 extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx);
622
623 extern int force_mwait;
624
625 extern void select_idle_routine(const struct cpuinfo_x86 *c);
626
627 extern unsigned long boot_option_idle_override;
628
629 extern void enable_sep_cpu(void);
630 extern int sysenter_setup(void);
631
632 /* Defined in head.S */
633 extern struct desc_ptr early_gdt_descr;
634
635 extern void cpu_set_gdt(int);
636 extern void switch_to_new_gdt(void);
637 extern void cpu_init(void);
638 extern void init_gdt(int cpu);
639
640 /* from system description table in BIOS.  Mostly for MCA use, but
641  * others may find it useful. */
642 extern unsigned int machine_id;
643 extern unsigned int machine_submodel_id;
644 extern unsigned int BIOS_revision;
645 extern unsigned int mca_pentium_flag;
646
647 /* Boot loader type from the setup header */
648 extern int bootloader_type;
649
650 extern char ignore_fpu_irq;
651 #define cache_line_size() (boot_cpu_data.x86_cache_alignment)
652
653 /* generic versions from gas */
654 #define GENERIC_NOP1    ".byte 0x90\n"
655 #define GENERIC_NOP2            ".byte 0x89,0xf6\n"
656 #define GENERIC_NOP3        ".byte 0x8d,0x76,0x00\n"
657 #define GENERIC_NOP4        ".byte 0x8d,0x74,0x26,0x00\n"
658 #define GENERIC_NOP5        GENERIC_NOP1 GENERIC_NOP4
659 #define GENERIC_NOP6    ".byte 0x8d,0xb6,0x00,0x00,0x00,0x00\n"
660 #define GENERIC_NOP7    ".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00\n"
661 #define GENERIC_NOP8    GENERIC_NOP1 GENERIC_NOP7
662
663 /* Opteron nops */
664 #define K8_NOP1 GENERIC_NOP1
665 #define K8_NOP2 ".byte 0x66,0x90\n"
666 #define K8_NOP3 ".byte 0x66,0x66,0x90\n"
667 #define K8_NOP4 ".byte 0x66,0x66,0x66,0x90\n"
668 #define K8_NOP5 K8_NOP3 K8_NOP2
669 #define K8_NOP6 K8_NOP3 K8_NOP3
670 #define K8_NOP7 K8_NOP4 K8_NOP3
671 #define K8_NOP8 K8_NOP4 K8_NOP4
672
673 /* K7 nops */
674 /* uses eax dependencies (arbitary choice) */
675 #define K7_NOP1  GENERIC_NOP1
676 #define K7_NOP2 ".byte 0x8b,0xc0\n"
677 #define K7_NOP3 ".byte 0x8d,0x04,0x20\n"
678 #define K7_NOP4 ".byte 0x8d,0x44,0x20,0x00\n"
679 #define K7_NOP5 K7_NOP4 ASM_NOP1
680 #define K7_NOP6 ".byte 0x8d,0x80,0,0,0,0\n"
681 #define K7_NOP7        ".byte 0x8D,0x04,0x05,0,0,0,0\n"
682 #define K7_NOP8        K7_NOP7 ASM_NOP1
683
684 /* P6 nops */
685 /* uses eax dependencies (Intel-recommended choice) */
686 #define P6_NOP1 GENERIC_NOP1
687 #define P6_NOP2 ".byte 0x66,0x90\n"
688 #define P6_NOP3 ".byte 0x0f,0x1f,0x00\n"
689 #define P6_NOP4 ".byte 0x0f,0x1f,0x40,0\n"
690 #define P6_NOP5 ".byte 0x0f,0x1f,0x44,0x00,0\n"
691 #define P6_NOP6 ".byte 0x66,0x0f,0x1f,0x44,0x00,0\n"
692 #define P6_NOP7 ".byte 0x0f,0x1f,0x80,0,0,0,0\n"
693 #define P6_NOP8 ".byte 0x0f,0x1f,0x84,0x00,0,0,0,0\n"
694
695 #ifdef CONFIG_MK7
696 #define ASM_NOP1 K7_NOP1
697 #define ASM_NOP2 K7_NOP2
698 #define ASM_NOP3 K7_NOP3
699 #define ASM_NOP4 K7_NOP4
700 #define ASM_NOP5 K7_NOP5
701 #define ASM_NOP6 K7_NOP6
702 #define ASM_NOP7 K7_NOP7
703 #define ASM_NOP8 K7_NOP8
704 #elif defined(CONFIG_M686) || defined(CONFIG_MPENTIUMII) || \
705       defined(CONFIG_MPENTIUMIII) || defined(CONFIG_MPENTIUMM) || \
706       defined(CONFIG_MCORE2) || defined(CONFIG_PENTIUM4) || \
707       defined(CONFIG_MPSC)
708 #define ASM_NOP1 P6_NOP1
709 #define ASM_NOP2 P6_NOP2
710 #define ASM_NOP3 P6_NOP3
711 #define ASM_NOP4 P6_NOP4
712 #define ASM_NOP5 P6_NOP5
713 #define ASM_NOP6 P6_NOP6
714 #define ASM_NOP7 P6_NOP7
715 #define ASM_NOP8 P6_NOP8
716 #elif defined(CONFIG_MK8) || defined(CONFIG_X86_64)
717 #define ASM_NOP1 K8_NOP1
718 #define ASM_NOP2 K8_NOP2
719 #define ASM_NOP3 K8_NOP3
720 #define ASM_NOP4 K8_NOP4
721 #define ASM_NOP5 K8_NOP5
722 #define ASM_NOP6 K8_NOP6
723 #define ASM_NOP7 K8_NOP7
724 #define ASM_NOP8 K8_NOP8
725 #else
726 #define ASM_NOP1 GENERIC_NOP1
727 #define ASM_NOP2 GENERIC_NOP2
728 #define ASM_NOP3 GENERIC_NOP3
729 #define ASM_NOP4 GENERIC_NOP4
730 #define ASM_NOP5 GENERIC_NOP5
731 #define ASM_NOP6 GENERIC_NOP6
732 #define ASM_NOP7 GENERIC_NOP7
733 #define ASM_NOP8 GENERIC_NOP8
734 #endif
735
736 #define ASM_NOP_MAX 8
737
738 #define HAVE_ARCH_PICK_MMAP_LAYOUT 1
739 #define ARCH_HAS_PREFETCHW
740 #define ARCH_HAS_SPINLOCK_PREFETCH
741
742 #ifdef CONFIG_X86_32
743 #define BASE_PREFETCH   ASM_NOP4
744 #define ARCH_HAS_PREFETCH
745 #else
746 #define BASE_PREFETCH   "prefetcht0 (%1)"
747 #endif
748
749 /* Prefetch instructions for Pentium III and AMD Athlon */
750 /* It's not worth to care about 3dnow! prefetches for the K6
751    because they are microcoded there and very slow.
752    However we don't do prefetches for pre XP Athlons currently
753    That should be fixed. */
754 static inline void prefetch(const void *x)
755 {
756         alternative_input(BASE_PREFETCH,
757                           "prefetchnta (%1)",
758                           X86_FEATURE_XMM,
759                           "r" (x));
760 }
761
762 /* 3dnow! prefetch to get an exclusive cache line. Useful for
763    spinlocks to avoid one state transition in the cache coherency protocol. */
764 static inline void prefetchw(const void *x)
765 {
766         alternative_input(BASE_PREFETCH,
767                           "prefetchw (%1)",
768                           X86_FEATURE_3DNOW,
769                           "r" (x));
770 }
771
772 #define spin_lock_prefetch(x)   prefetchw(x)
773 /* This decides where the kernel will search for a free chunk of vm
774  * space during mmap's.
775  */
776 #define TASK_UNMAPPED_BASE      (PAGE_ALIGN(TASK_SIZE / 3))
777
778 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
779
780 #endif