Received: by 10.192.165.156 with SMTP id m28csp777548imm; Mon, 16 Apr 2018 08:33:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+118QjBSCCrLl8c46nAxlTuq6SLvQ9IS4TJG1MEtkjGMf3APcMZ48mibJ/E6C+GkDo6dsf X-Received: by 10.99.109.195 with SMTP id i186mr1312790pgc.403.1523892823231; Mon, 16 Apr 2018 08:33:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523892823; cv=none; d=google.com; s=arc-20160816; b=Bdq0gNjgZugnS0YTr5CRs+EVzgBoN8uoKVBNmWwDm6+QguxObp8JpEH4JGurWuAGdm zXzUmi64xAE8jqTlTuqXyOVuPJc4VXo9pyE15KHkk0UxfY3iEGocq7dzuLljH/qtUR0M RITd8I8Q9X36O+9JF0U7UTQfqiqvJQ66GuswHaVYDxvCmLOJ0U8rrobM1K2fAZ313R+W RZRizO97egSQtebnWF/touP/Wa3Dv56pGM/xn2ViEDcGg9c1K6KuYzL0ai5clQkCwrfG eKsgfdXwY4MBxyZerrBm2pxYcuqtq0jiHb/GbEao2/mY2OnzfKLUBm4TPRxAwZpiDIv2 t9eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=XdXGQd0N0vAPaE2m6Oem9PQaW/jFOcs9xnrj+CAP6J0=; b=iF5mp0CQ4tVBkRBtDr8tS2AHXB/D28000I16UEuAWPEbXqtUAT0eBYEn+HrLcVmExX c/AMsZunzhvc5dzwsjy7Fyntq5IGbzCSSy6RGNtjpgZwoVtZb0uDNgKB8oM2e1TB7UXF 2pdoDhhOpvQc2DFxuIBXhU2/tBHg4rkYtNWUYfKpq1uX+7e6hyiMMxgIbjpE8wkJREaF 7yRY5aXpQA3Q1ZDSNZG9ISE39E0Hy+MYin2KVWh8tGLViZkCsZ33q36bEcN0O2c1rFhb bl/W6RQhIA1faAz7bpUzo3d2+lp93aCer35Ly0sFHG/m5GBdnkXFktmRfjFK37p/6ym2 PqnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=RHqLvUQV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o32-v6si12271992pld.435.2018.04.16.08.33.29; Mon, 16 Apr 2018 08:33:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=RHqLvUQV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752947AbeDPPZt (ORCPT + 99 others); Mon, 16 Apr 2018 11:25:49 -0400 Received: from 8bytes.org ([81.169.241.247]:36120 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752876AbeDPPZo (ORCPT ); Mon, 16 Apr 2018 11:25:44 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 64839628; Mon, 16 Apr 2018 17:25:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1523892338; bh=CKtoZf8sRoPTdv0FrlKLfoDxZZYY88h9vkszUfSRQe4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RHqLvUQVzCiTFVdbp+PbIicR4EVr4J29c9kqEnh2wkF7/rSXX1WfJTFRS1aZKxxW7 KXCJy0c9GiZOJgyVLRZGgVwLpCANERAjbvjqa7IdM17GgFDC/y3BUYk5JG6dD44SBb bx8lPL5VvynbJc9ZsXUxB8iGJmeg7wWmmEAdtqoKqWKyShvPqhMo1t5KC+5vcaZy3z j6UlfHLicsjVyassTjhiQC++DMiChCoQcPi80ff2onVvvsY15gTP1oHvA+h8ZBy6LX SsHd1nF4g1um7a5xnuHl+NNNKm+yBthGJfSmyThzneYQB9TmSHpUZg2d4OOgZwijkf MuFiJ+O3IxHoA== 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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