Path: blob/master/arch/um/sys-x86_64/shared/sysdep/system.h
10820 views
#ifndef _ASM_X86_SYSTEM_H_1#define _ASM_X86_SYSTEM_H_23#include <asm/asm.h>4#include <asm/segment.h>5#include <asm/cpufeature.h>6#include <asm/cmpxchg.h>7#include <asm/nops.h>89#include <linux/kernel.h>10#include <linux/irqflags.h>1112/* entries in ARCH_DLINFO: */13#ifdef CONFIG_IA32_EMULATION14# define AT_VECTOR_SIZE_ARCH 215#else16# define AT_VECTOR_SIZE_ARCH 117#endif1819extern unsigned long arch_align_stack(unsigned long sp);2021void default_idle(void);2223/*24* Force strict CPU ordering.25* And yes, this is required on UP too when we're talking26* to devices.27*/28#ifdef CONFIG_X86_3229/*30* Some non-Intel clones support out of order store. wmb() ceases to be a31* nop for these.32*/33#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)34#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2)35#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM)36#else37#define mb() asm volatile("mfence":::"memory")38#define rmb() asm volatile("lfence":::"memory")39#define wmb() asm volatile("sfence" ::: "memory")40#endif4142/**43* read_barrier_depends - Flush all pending reads that subsequents reads44* depend on.45*46* No data-dependent reads from memory-like regions are ever reordered47* over this barrier. All reads preceding this primitive are guaranteed48* to access memory (but not necessarily other CPUs' caches) before any49* reads following this primitive that depend on the data return by50* any of the preceding reads. This primitive is much lighter weight than51* rmb() on most CPUs, and is never heavier weight than is52* rmb().53*54* These ordering constraints are respected by both the local CPU55* and the compiler.56*57* Ordering is not guaranteed by anything other than these primitives,58* not even by data dependencies. See the documentation for59* memory_barrier() for examples and URLs to more information.60*61* For example, the following code would force ordering (the initial62* value of "a" is zero, "b" is one, and "p" is "&a"):63*64* <programlisting>65* CPU 0 CPU 166*67* b = 2;68* memory_barrier();69* p = &b; q = p;70* read_barrier_depends();71* d = *q;72* </programlisting>73*74* because the read of "*q" depends on the read of "p" and these75* two reads are separated by a read_barrier_depends(). However,76* the following code, with the same initial values for "a" and "b":77*78* <programlisting>79* CPU 0 CPU 180*81* a = 2;82* memory_barrier();83* b = 3; y = b;84* read_barrier_depends();85* x = a;86* </programlisting>87*88* does not enforce ordering, since there is no data dependency between89* the read of "a" and the read of "b". Therefore, on some CPUs, such90* as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()91* in cases like this where there are no data dependencies.92**/9394#define read_barrier_depends() do { } while (0)9596#ifdef CONFIG_SMP97#define smp_mb() mb()98#ifdef CONFIG_X86_PPRO_FENCE99# define smp_rmb() rmb()100#else101# define smp_rmb() barrier()102#endif103#ifdef CONFIG_X86_OOSTORE104# define smp_wmb() wmb()105#else106# define smp_wmb() barrier()107#endif108#define smp_read_barrier_depends() read_barrier_depends()109#define set_mb(var, value) do { (void)xchg(&var, value); } while (0)110#else111#define smp_mb() barrier()112#define smp_rmb() barrier()113#define smp_wmb() barrier()114#define smp_read_barrier_depends() do { } while (0)115#define set_mb(var, value) do { var = value; barrier(); } while (0)116#endif117118/*119* Stop RDTSC speculation. This is needed when you need to use RDTSC120* (or get_cycles or vread that possibly accesses the TSC) in a defined121* code region.122*123* (Could use an alternative three way for this if there was one.)124*/125static inline void rdtsc_barrier(void)126{127alternative(ASM_NOP3, "mfence", X86_FEATURE_MFENCE_RDTSC);128alternative(ASM_NOP3, "lfence", X86_FEATURE_LFENCE_RDTSC);129}130131#endif132133134