processor.h (95a0c7c2d6cfde3fb5fdb713428ed0df4d6bdd58) processor.h (f5caf621ee357279e759c0911daf6d55c7d36f03)
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 */
7struct task_struct;
8struct mm_struct;

--- 8 unchanged lines hidden (view full) ---

17#include <asm/page.h>
18#include <asm/pgtable_types.h>
19#include <asm/percpu.h>
20#include <asm/msr.h>
21#include <asm/desc_defs.h>
22#include <asm/nops.h>
23#include <asm/special_insns.h>
24#include <asm/fpu/types.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 */
7struct task_struct;
8struct mm_struct;

--- 8 unchanged lines hidden (view full) ---

17#include <asm/page.h>
18#include <asm/pgtable_types.h>
19#include <asm/percpu.h>
20#include <asm/msr.h>
21#include <asm/desc_defs.h>
22#include <asm/nops.h>
23#include <asm/special_insns.h>
24#include <asm/fpu/types.h>
25#include <asm/unwind_hints.h>
25
26#include <linux/personality.h>
27#include <linux/cache.h>
28#include <linux/threads.h>
29#include <linux/math64.h>
30#include <linux/err.h>
31#include <linux/irqflags.h>
26
27#include <linux/personality.h>
28#include <linux/cache.h>
29#include <linux/threads.h>
30#include <linux/math64.h>
31#include <linux/err.h>
32#include <linux/irqflags.h>
33#include <linux/mem_encrypt.h>
32
33/*
34 * We handle most unaligned accesses in hardware. On the other hand
35 * unaligned DMA can be quite expensive on some Nehalem processors.
36 *
37 * Based on this we disable the IP header alignment in network drivers.
38 */
39#define NET_IP_ALIGN 0

--- 194 unchanged lines hidden (view full) ---

234/*
235 * Friendlier CR3 helpers.
236 */
237static inline unsigned long read_cr3_pa(void)
238{
239 return __read_cr3() & CR3_ADDR_MASK;
240}
241
34
35/*
36 * We handle most unaligned accesses in hardware. On the other hand
37 * unaligned DMA can be quite expensive on some Nehalem processors.
38 *
39 * Based on this we disable the IP header alignment in network drivers.
40 */
41#define NET_IP_ALIGN 0

--- 194 unchanged lines hidden (view full) ---

236/*
237 * Friendlier CR3 helpers.
238 */
239static inline unsigned long read_cr3_pa(void)
240{
241 return __read_cr3() & CR3_ADDR_MASK;
242}
243
244static inline unsigned long native_read_cr3_pa(void)
245{
246 return __native_read_cr3() & CR3_ADDR_MASK;
247}
248
242static inline void load_cr3(pgd_t *pgdir)
243{
249static inline void load_cr3(pgd_t *pgdir)
250{
244 write_cr3(__pa(pgdir));
251 write_cr3(__sme_pa(pgdir));
245}
246
247#ifdef CONFIG_X86_32
248/* This is the TSS defined by the hardware. */
249struct x86_hw_tss {
250 unsigned short back_link, __blh;
251 unsigned long sp0;
252 unsigned short ss0, __ss0h;

--- 403 unchanged lines hidden (view full) ---

656 * a bit more than 2x slower than the fastest options) and that
657 * it unmasks NMIs. The "push %cs" is needed because, in
658 * paravirtual environments, __KERNEL_CS may not be a valid CS
659 * value when we do IRET directly.
660 *
661 * In case NMI unmasking or performance ever becomes a problem,
662 * the next best option appears to be MOV-to-CR2 and an
663 * unconditional jump. That sequence also works on all CPUs,
252}
253
254#ifdef CONFIG_X86_32
255/* This is the TSS defined by the hardware. */
256struct x86_hw_tss {
257 unsigned short back_link, __blh;
258 unsigned long sp0;
259 unsigned short ss0, __ss0h;

--- 403 unchanged lines hidden (view full) ---

663 * a bit more than 2x slower than the fastest options) and that
664 * it unmasks NMIs. The "push %cs" is needed because, in
665 * paravirtual environments, __KERNEL_CS may not be a valid CS
666 * value when we do IRET directly.
667 *
668 * In case NMI unmasking or performance ever becomes a problem,
669 * the next best option appears to be MOV-to-CR2 and an
670 * unconditional jump. That sequence also works on all CPUs,
664 * but it will fault at CPL3 (i.e. Xen PV and lguest).
671 * but it will fault at CPL3 (i.e. Xen PV).
665 *
666 * CPUID is the conventional way, but it's nasty: it doesn't
667 * exist on some 486-like CPUs, and it usually exits to a
668 * hypervisor.
669 *
670 * Like all of Linux's memory ordering operations, this is a
671 * compiler barrier as well.
672 */
672 *
673 * CPUID is the conventional way, but it's nasty: it doesn't
674 * exist on some 486-like CPUs, and it usually exits to a
675 * hypervisor.
676 *
677 * Like all of Linux's memory ordering operations, this is a
678 * compiler barrier as well.
679 */
673 register void *__sp asm(_ASM_SP);
674
675#ifdef CONFIG_X86_32
676 asm volatile (
677 "pushfl\n\t"
678 "pushl %%cs\n\t"
679 "pushl $1f\n\t"
680 "iret\n\t"
681 "1:"
680#ifdef CONFIG_X86_32
681 asm volatile (
682 "pushfl\n\t"
683 "pushl %%cs\n\t"
684 "pushl $1f\n\t"
685 "iret\n\t"
686 "1:"
682 : "+r" (__sp) : : "memory");
687 : ASM_CALL_CONSTRAINT : : "memory");
683#else
684 unsigned int tmp;
685
686 asm volatile (
688#else
689 unsigned int tmp;
690
691 asm volatile (
692 UNWIND_HINT_SAVE
687 "mov %%ss, %0\n\t"
688 "pushq %q0\n\t"
689 "pushq %%rsp\n\t"
690 "addq $8, (%%rsp)\n\t"
691 "pushfq\n\t"
692 "mov %%cs, %0\n\t"
693 "pushq %q0\n\t"
694 "pushq $1f\n\t"
695 "iretq\n\t"
693 "mov %%ss, %0\n\t"
694 "pushq %q0\n\t"
695 "pushq %%rsp\n\t"
696 "addq $8, (%%rsp)\n\t"
697 "pushfq\n\t"
698 "mov %%cs, %0\n\t"
699 "pushq %q0\n\t"
700 "pushq $1f\n\t"
701 "iretq\n\t"
702 UNWIND_HINT_RESTORE
696 "1:"
703 "1:"
697 : "=&r" (tmp), "+r" (__sp) : : "cc", "memory");
704 : "=&r" (tmp), ASM_CALL_CONSTRAINT : : "cc", "memory");
698#endif
699}
700
701extern void select_idle_routine(const struct cpuinfo_x86 *c);
702extern void amd_e400_c1e_apic_setup(void);
703
704extern unsigned long boot_option_idle_override;
705

--- 91 unchanged lines hidden (view full) ---

797 TOP_OF_KERNEL_STACK_PADDING)
798
799#ifdef CONFIG_X86_32
800/*
801 * User space process size: 3GB (default).
802 */
803#define IA32_PAGE_OFFSET PAGE_OFFSET
804#define TASK_SIZE PAGE_OFFSET
705#endif
706}
707
708extern void select_idle_routine(const struct cpuinfo_x86 *c);
709extern void amd_e400_c1e_apic_setup(void);
710
711extern unsigned long boot_option_idle_override;
712

--- 91 unchanged lines hidden (view full) ---

804 TOP_OF_KERNEL_STACK_PADDING)
805
806#ifdef CONFIG_X86_32
807/*
808 * User space process size: 3GB (default).
809 */
810#define IA32_PAGE_OFFSET PAGE_OFFSET
811#define TASK_SIZE PAGE_OFFSET
812#define TASK_SIZE_LOW TASK_SIZE
805#define TASK_SIZE_MAX TASK_SIZE
813#define TASK_SIZE_MAX TASK_SIZE
814#define DEFAULT_MAP_WINDOW TASK_SIZE
806#define STACK_TOP TASK_SIZE
807#define STACK_TOP_MAX STACK_TOP
808
809#define INIT_THREAD { \
810 .sp0 = TOP_OF_INIT_STACK, \
811 .sysenter_cs = __KERNEL_CS, \
812 .io_bitmap_ptr = NULL, \
813 .addr_limit = KERNEL_DS, \

--- 23 unchanged lines hidden (view full) ---

837 * User space process size. 47bits minus one guard page. The guard
838 * page is necessary on Intel CPUs: if a SYSCALL instruction is at
839 * the highest possible canonical userspace address, then that
840 * syscall will enter the kernel with a non-canonical return
841 * address, and SYSRET will explode dangerously. We avoid this
842 * particular problem by preventing anything from being mapped
843 * at the maximum canonical address.
844 */
815#define STACK_TOP TASK_SIZE
816#define STACK_TOP_MAX STACK_TOP
817
818#define INIT_THREAD { \
819 .sp0 = TOP_OF_INIT_STACK, \
820 .sysenter_cs = __KERNEL_CS, \
821 .io_bitmap_ptr = NULL, \
822 .addr_limit = KERNEL_DS, \

--- 23 unchanged lines hidden (view full) ---

846 * User space process size. 47bits minus one guard page. The guard
847 * page is necessary on Intel CPUs: if a SYSCALL instruction is at
848 * the highest possible canonical userspace address, then that
849 * syscall will enter the kernel with a non-canonical return
850 * address, and SYSRET will explode dangerously. We avoid this
851 * particular problem by preventing anything from being mapped
852 * at the maximum canonical address.
853 */
845#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
854#define TASK_SIZE_MAX ((1UL << __VIRTUAL_MASK_SHIFT) - PAGE_SIZE)
846
855
856#define DEFAULT_MAP_WINDOW ((1UL << 47) - PAGE_SIZE)
857
847/* This decides where the kernel will search for a free chunk of vm
848 * space during mmap's.
849 */
850#define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
851 0xc0000000 : 0xFFFFe000)
852
858/* This decides where the kernel will search for a free chunk of vm
859 * space during mmap's.
860 */
861#define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
862 0xc0000000 : 0xFFFFe000)
863
864#define TASK_SIZE_LOW (test_thread_flag(TIF_ADDR32) ? \
865 IA32_PAGE_OFFSET : DEFAULT_MAP_WINDOW)
853#define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
854 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
855#define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, TIF_ADDR32)) ? \
856 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
857
866#define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
867 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
868#define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, TIF_ADDR32)) ? \
869 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
870
858#define STACK_TOP TASK_SIZE
871#define STACK_TOP TASK_SIZE_LOW
859#define STACK_TOP_MAX TASK_SIZE_MAX
860
861#define INIT_THREAD { \
862 .sp0 = TOP_OF_INIT_STACK, \
863 .addr_limit = KERNEL_DS, \
864}
865
866#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.sp0 - 1)

--- 4 unchanged lines hidden (view full) ---

871extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
872 unsigned long new_sp);
873
874/*
875 * This decides where the kernel will search for a free chunk of vm
876 * space during mmap's.
877 */
878#define __TASK_UNMAPPED_BASE(task_size) (PAGE_ALIGN(task_size / 3))
872#define STACK_TOP_MAX TASK_SIZE_MAX
873
874#define INIT_THREAD { \
875 .sp0 = TOP_OF_INIT_STACK, \
876 .addr_limit = KERNEL_DS, \
877}
878
879#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.sp0 - 1)

--- 4 unchanged lines hidden (view full) ---

884extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
885 unsigned long new_sp);
886
887/*
888 * This decides where the kernel will search for a free chunk of vm
889 * space during mmap's.
890 */
891#define __TASK_UNMAPPED_BASE(task_size) (PAGE_ALIGN(task_size / 3))
879#define TASK_UNMAPPED_BASE __TASK_UNMAPPED_BASE(TASK_SIZE)
892#define TASK_UNMAPPED_BASE __TASK_UNMAPPED_BASE(TASK_SIZE_LOW)
880
881#define KSTK_EIP(task) (task_pt_regs(task)->ip)
882
883/* Get/set a process' ability to use the timestamp counter instruction */
884#define GET_TSC_CTL(adr) get_tsc_mode((adr))
885#define SET_TSC_CTL(val) set_tsc_mode((val))
886
887extern int get_tsc_mode(unsigned long adr);

--- 58 unchanged lines hidden ---
893
894#define KSTK_EIP(task) (task_pt_regs(task)->ip)
895
896/* Get/set a process' ability to use the timestamp counter instruction */
897#define GET_TSC_CTL(adr) get_tsc_mode((adr))
898#define SET_TSC_CTL(val) set_tsc_mode((val))
899
900extern int get_tsc_mode(unsigned long adr);

--- 58 unchanged lines hidden ---