From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AIpwx491Aejze0Qt1aBDn/luMdYeE3Y10r2y/G+qgU8TIn4KpC9SNv0dHLvgjNJuo7FU3Oda+MjO ARC-Seal: i=1; a=rsa-sha256; t=1523892343; cv=none; d=google.com; s=arc-20160816; b=yO+Pc7+pDrwG6I2D5S+LhjHGxCAqXudft5J1ngzj+JSQ/j7fe4J3+pgAXtplZKTPax tP6V0B3wGcFFGgl+5C/AzzQKEw3CSI//6KqhHhRBiBtFI4UBa2nU2+pB/3kt/CH3V4Tx IuPPha7TnMntLnqMH0ydb3QBSsjBePK8U7KQHOzL2/uJltGCebfVvSaakFx7fUhErq5L cjMTA4r9u4IXZrVF6nHDq40J2REY1Ex15dJR+Oqw6HZn8Ri7BMyB9shtXASTfMOxxphN Z02VBh1rn6XQZpgkuXGUVmua71Hc+UdjOiS5J+o3DUbXI2R63F3mV5B/X6UMn2gqtzry zS2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=XdXGQd0N0vAPaE2m6Oem9PQaW/jFOcs9xnrj+CAP6J0=; b=vl+y/Eqh9hTV1YS71IwOqg73Y0YHx7KrgnbcZOcmpr7SzliQXOcB9NIWnfpFH01JOh Bq0V24pKP4M+o68NxRFFnT4plctCeRYZVd7ThF7MUiHXpBLsPkfsgzilQHEVXVcObe8C KVrlCoQE630bju2vCh61M9yUPVG3u0Pqdm0j2sEzXp4ZX5jdPr6c/5bGX9kUrycHwrMH V2vfAzQ8yGKu0QFgpWJd5R2Y9KcNWW6B/+ypslTuoYV4MmDUd0hne/ksDJmSmbNXA0pR FfLKczAf5W9bvIdzdvt1aMWR+OHOjTvPAo2KUUQkq0FRN62iX39qdRbYlEn+uk+EDnz6 wr4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=RHqLvUQV; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=RHqLvUQV; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org From: Joerg Roedel To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andy Lutomirski , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , aliguori@amazon.com, daniel.gruss@iaik.tugraz.at, hughd@google.com, keescook@google.com, Andrea Arcangeli , Waiman Long , Pavel Machek , "David H . Gutteridge" , jroedel@suse.de, joro@8bytes.org Subject: [PATCH 12/35] x86/32: Use tss.sp1 as cpu_current_top_of_stack Date: Mon, 16 Apr 2018 17:25:00 +0200 Message-Id: <1523892323-14741-13-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523892323-14741-1-git-send-email-joro@8bytes.org> References: <1523892323-14741-1-git-send-email-joro@8bytes.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1597916938831451692?= X-GMAIL-MSGID: =?utf-8?q?1597916938831451692?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: From: Joerg Roedel Now that we store the task-stack in tss.sp1 we can also use it as cpu_current_top_of_stack. This unifies the handling with x86-64. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/processor.h | 4 ---- arch/x86/include/asm/thread_info.h | 2 -- arch/x86/kernel/cpu/common.c | 4 ---- arch/x86/kernel/process_32.c | 6 ------ 4 files changed, 16 deletions(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 4fa4206..3894f63 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -374,12 +374,8 @@ DECLARE_PER_CPU_PAGE_ALIGNED(struct tss_struct, cpu_tss_rw); #define __KERNEL_TSS_LIMIT \ (IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1) -#ifdef CONFIG_X86_32 -DECLARE_PER_CPU(unsigned long, cpu_current_top_of_stack); -#else /* The RO copy can't be accessed with this_cpu_xyz(), so use the RW copy. */ #define cpu_current_top_of_stack cpu_tss_rw.x86_tss.sp1 -#endif /* * Save the original ist values for checking stack pointers during debugging diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index a5d9521..943c673 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h @@ -205,9 +205,7 @@ static inline int arch_within_stack_frames(const void * const stack, #else /* !__ASSEMBLY__ */ -#ifdef CONFIG_X86_64 # define cpu_current_top_of_stack (cpu_tss_rw + TSS_sp1) -#endif #endif diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 311e988..2d67ad0 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1512,10 +1512,6 @@ EXPORT_PER_CPU_SYMBOL(__preempt_count); * the top of the kernel stack. Use an extra percpu variable to track the * top of the kernel stack directly. */ -DEFINE_PER_CPU(unsigned long, cpu_current_top_of_stack) = - (unsigned long)&init_thread_union + THREAD_SIZE; -EXPORT_PER_CPU_SYMBOL(cpu_current_top_of_stack); - #ifdef CONFIG_CC_STACKPROTECTOR DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary); #endif diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index 3f3a8c6..8c29fd5 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -290,12 +290,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) update_sp0(next_p); refresh_sysenter_cs(next); this_cpu_write(cpu_current_top_of_stack, task_top_of_stack(next_p)); - /* - * TODO: Find a way to let cpu_current_top_of_stack point to - * cpu_tss_rw.x86_tss.sp1. Doing so now results in stack corruption with - * iret exceptions. - */ - this_cpu_write(cpu_tss_rw.x86_tss.sp1, next_p->thread.sp0); /* * Restore %gs if needed (which is common) -- 2.7.4