/* * We handle most unaligned accesses in hardware. On the other hand * unaligned DMA can be quite expensive on some Nehalem processors. * * Based on this we disable the IP header alignment in network drivers.
*/ #define NET_IP_ALIGN 0
#define HBP_NUM 4
/* * These alignment constraints are for performance in the vSMP case, * but in the task_struct case we must also meet hardware imposed * alignment requirements of the FPU state:
*/ #ifdef CONFIG_X86_VSMP # define ARCH_MIN_TASKALIGN (1 << INTERNODE_CACHE_SHIFT) # define ARCH_MIN_MMSTRUCT_ALIGN (1 << INTERNODE_CACHE_SHIFT) #else # define ARCH_MIN_TASKALIGN __alignof__(union fpregs_state) # define ARCH_MIN_MMSTRUCT_ALIGN 0 #endif
struct cpuinfo_x86 { union { /* * The particular ordering (low-to-high) of (vendor, * family, model) is done in case range of models, like * it is usually done on AMD, need to be compared.
*/ struct {
__u8 x86_model; /* CPU family */
__u8 x86; /* CPU vendor */
__u8 x86_vendor;
__u8 x86_reserved;
}; /* combined vendor, family, model */
__u32 x86_vfm;
};
__u8 x86_stepping; #ifdef CONFIG_X86_64 /* Number of 4K pages in DTLB/ITLB combined(in pages): */ int x86_tlbsize; #endif #ifdef CONFIG_X86_VMX_FEATURE_NAMES
__u32 vmx_capability[NVMXINTS]; #endif
__u8 x86_virt_bits;
__u8 x86_phys_bits; /* Max extended CPUID function supported: */
__u32 extended_cpuid_level; /* Maximum supported CPUID level, -1=no CPUID: */ int cpuid_level; /* * Align to size of unsigned long because the x86_capability array * is passed to bitops which require the alignment. Use unnamed * union to enforce the array is aligned to size of unsigned long.
*/ union {
__u32 x86_capability[NCAPINTS + NBUGINTS]; unsignedlong x86_capability_alignment;
}; char x86_vendor_id[16]; char x86_model_id[64]; struct cpuinfo_topology topo; /* in KB - valid for CPUS which support this call: */ unsignedint x86_cache_size; int x86_cache_alignment; /* In bytes */ /* Cache QoS architectural values, valid only on the BSP: */ int x86_cache_max_rmid; /* max index */ int x86_cache_occ_scale; /* scale to bytes */ int x86_cache_mbm_width_offset; int x86_power; unsignedlong loops_per_jiffy; /* protected processor identification number */
u64 ppin;
u16 x86_clflush_size; /* number of cores as seen by the OS: */
u16 booted_cores; /* Index into per_cpu list: */
u16 cpu_index; /* Is SMT active on this core? */ bool smt_active;
u32 microcode; /* Address space bits used by the cache internally */
u8 x86_cache_bits; unsigned initialized : 1;
} __randomize_layout;
/* * Note that while the legacy 'TSS' name comes from 'Task State Segment', * on modern x86 CPUs the TSS also holds information important to 64-bit mode, * unrelated to the task-switch mechanism:
*/ #ifdef CONFIG_X86_32 /* This is the TSS defined by the hardware. */ struct x86_hw_tss { unsignedshort back_link, __blh; unsignedlong sp0; unsignedshort ss0, __ss0h; unsignedlong sp1;
/* * We don't use ring 1, so ss1 is a convenient scratch space in * the same cacheline as sp0. We use ss1 to cache the value in * MSR_IA32_SYSENTER_CS. When we context switch * MSR_IA32_SYSENTER_CS, we first check if the new value being * written matches ss1, and, if it's not, then we wrmsr the new * value and update ss1. * * The only reason we context switch MSR_IA32_SYSENTER_CS is * that we set it to zero in vm86 tasks to avoid corrupting the * stack if we were to go through the sysenter path from vm86 * mode.
*/ unsignedshort ss1; /* MSR_IA32_SYSENTER_CS */
/* * Since Linux does not use ring 2, the 'sp2' slot is unused by * hardware. entry_SYSCALL_64 uses it as scratch space to stash * the user RSP value.
*/
u64 sp2;
#ifdef CONFIG_X86_IOPL_IOPERM /* * sizeof(unsigned long) coming from an extra "long" at the end of the * iobitmap. The limit is inclusive, i.e. the last valid byte.
*/ # define __KERNEL_TSS_LIMIT \
(IO_BITMAP_OFFSET_VALID_ALL + IO_BITMAP_BYTES + \ sizeof(unsignedlong) - 1) #else # define __KERNEL_TSS_LIMIT \
(offsetof(struct tss_struct, x86_tss) + sizeof(struct x86_hw_tss) - 1) #endif
/* Base offset outside of TSS_LIMIT so unpriviledged IO causes #GP */ #define IO_BITMAP_OFFSET_INVALID (__KERNEL_TSS_LIMIT + 1)
/* * All IO bitmap related data stored in the TSS:
*/ struct x86_io_bitmap { /* The sequence number of the last active bitmap. */
u64 prev_sequence;
/* * Store the dirty size of the last io bitmap offender. The next * one will have to do the cleanup as the switch out to a non io * bitmap user will just set x86_tss.io_bitmap_base to a value * outside of the TSS limit. So for sane tasks there is no need to * actually touch the io_bitmap at all.
*/ unsignedint prev_max;
/* * The extra 1 is there because the CPU will access an * additional byte beyond the end of the IO permission * bitmap. The extra byte must be all 1 bits, and must * be within the limit.
*/ unsignedlong bitmap[IO_BITMAP_LONGS + 1];
/* * Special I/O bitmap to emulate IOPL(3). All bytes zero, * except the additional byte at the end.
*/ unsignedlong mapall[IO_BITMAP_LONGS + 1];
};
struct tss_struct { /* * The fixed hardware portion. This must not cross a page boundary * at risk of violating the SDM's advice and potentially triggering * errata.
*/ struct x86_hw_tss x86_tss;
DECLARE_PER_CPU_CACHE_HOT(unsignedlong, cpu_current_top_of_stack); /* const-qualified alias provided by the linker. */
DECLARE_PER_CPU_CACHE_HOT(constunsignedlong __percpu_seg_override,
const_cpu_current_top_of_stack);
#ifdef CONFIG_X86_64 unsignedlong fsbase; unsignedlong gsbase; #else /* * XXX: this could presumably be unsigned short. Alternatively, * 32-bit kernels could be taught to use fsindex instead.
*/ unsignedlong fs; unsignedlong gs; #endif
/* Save middle states of ptrace breakpoints */ struct perf_event *ptrace_bps[HBP_NUM]; /* Debug status used for traps, single steps, etc... */ unsignedlong virtual_dr6; /* Keep track of the exact dr7 value set by the user */ unsignedlong ptrace_dr7; /* Fault info: */ unsignedlong cr2; unsignedlong trap_nr; unsignedlong error_code; #ifdef CONFIG_VM86 /* Virtual 86 mode info */ struct vm86 *vm86; #endif /* IO permissions: */ struct io_bitmap *io_bitmap;
/* * IOPL. Privilege level dependent I/O permission which is * emulated via the I/O bitmap to prevent user space from disabling * interrupts.
*/ unsignedlong iopl_emul;
unsignedint iopl_warn:1;
/* * Protection Keys Register for Userspace. Loaded immediately on * context switch. Store it in thread_struct to avoid a lookup in * the tasks's FPU xstate buffer. This value is only valid when a * task is scheduled out. For 'current' the authoritative source of * PKRU is the hardware itself.
*/
u32 pkru;
static __always_inline unsignedlong current_top_of_stack(void)
{ /* * We can't read directly from tss.sp0: sp0 on x86_32 is special in * and around vm86 mode and sp0 on x86_64 is special because of the * entry trampoline.
*/ if (IS_ENABLED(CONFIG_USE_X86_SEG_SUPPORT)) return this_cpu_read_const(const_cpu_current_top_of_stack);
/* * Prefetch instructions for Pentium III (+) and AMD Athlon (+) * * It's not worth to care about 3dnow prefetches for the K6 * because they are microcoded there and very slow.
*/ staticinlinevoid prefetch(constvoid *x)
{
alternative_input(BASE_PREFETCH, "prefetchnta %1",
X86_FEATURE_XMM, "m" (*(constchar *)x));
}
/* * 3dnow prefetch to get an exclusive cache line. * Useful for spinlocks to avoid one state transition in the * cache coherency protocol:
*/ static __always_inline void prefetchw(constvoid *x)
{
alternative_input(BASE_PREFETCH, "prefetchw %1",
X86_FEATURE_3DNOWPREFETCH, "m" (*(constchar *)x));
}
/* * This decides where the kernel will search for a free chunk of vm * space during mmap's.
*/ #define __TASK_UNMAPPED_BASE(task_size) (PAGE_ALIGN(task_size / 3)) #define TASK_UNMAPPED_BASE __TASK_UNMAPPED_BASE(TASK_SIZE_LOW)
/* Get/set a process' ability to use the timestamp counter instruction */ #define GET_TSC_CTL(adr) get_tsc_mode((adr)) #define SET_TSC_CTL(val) set_tsc_mode((val))
#ifdef CONFIG_CPU_SUP_AMD /* * Issue a DIV 0/1 insn to clear any division data from previous DIV * operations.
*/ static __always_inline void amd_clear_divider(void)
{ asmvolatile(ALTERNATIVE("", "div %2\n\t", X86_BUG_DIV0)
:: "a" (0), "d" (0), "r" (1));
}
/* * Make previous memory operations globally visible before * a WRMSR. * * MFENCE makes writes visible, but only affects load/store * instructions. WRMSR is unfortunately not a load/store * instruction and is unaffected by MFENCE. The LFENCE ensures * that the WRMSR is not reordered. * * Most WRMSRs are full serializing instructions themselves and * do not require this barrier. This is only required for the * IA32_TSC_DEADLINE and X2APIC MSRs.
*/ staticinlinevoid weak_wrmsr_fence(void)
{
alternative("mfence; lfence", "", ALT_NOT(X86_FEATURE_APIC_MSRS_FENCE));
}
#endif/* _ASM_X86_PROCESSOR_H */
Messung V0.5
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.