Received: by 10.192.165.148 with SMTP id m20csp3577791imm; Mon, 23 Apr 2018 08:49:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Fd2lnzyOrOJLm4Uyr5NmEhsKCYteYesrlfldBBZ/TGMMuIxKPA/N7TpPiyyNxWmQfJqeq X-Received: by 2002:a17:902:5785:: with SMTP id l5-v6mr20872067pli.379.1524498587075; Mon, 23 Apr 2018 08:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524498587; cv=none; d=google.com; s=arc-20160816; b=mxey8deYN7eR5PBecSZrGhCgU761yZzNL4aBHIr/Ze4468YRnMr7rozaR3fTncewgU cN4j3jjP5Yarxu52T+cMDLIUBv+JDmDym7q7RVwoI3z+cZJDEW57y9kK8lFGfAY2xRKl HocOCcsHfm1NdYL4D670C24jgf+dnSZAslk4sW3yNrN16ghmZgvgQfRr67ngx2UiEE/U h3pqmkcfelZioM1GO6Cs0r//ClL7oj4yu/+vRShBUxglQk3v02VUcuGTfOW32E+NF5kt fyHGRCWk0th3i2gIolLCcebFcK4YmbYULDiyVfK8spfgCzcXA22SHyjuwk1J2hTrnMi6 jUww== 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=oOuKC7JhFHBF2ZWVaEZG92J8LI0SKRJqDxYwgOGnUdg=; b=C/quc0lAmEkv0romgrmtskXOacUCx7cACdPbh0gdFI8Gq5Nn/J4AaZSj1Iv1EnofcX C8eKap42JdjezVRXwrghZ3R90pmCVHzb+4z6wfpTyWyDl5AKlpP2zcAtzAvzGPHbcpVr PUpAR/88jmazze1/b7UwChYD6+9lUliJ11iFcXda/TEIWlG97DN9mstifU5euwGkbw+F ZskUizr/ruhia3Sc4Mcdly39FwGZYqoYJOI8tEwiwV+oNFREVaP5566ztc7ujX6rLMOb gaepZtByGzixqE/nA+sunEF2iRz2WkaDsjsXwjZU9oDPhziPipW3xIA2HQ133A6hwjkH VyGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=B2tiJFJA; 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 o30-v6si8371892pli.64.2018.04.23.08.49.32; Mon, 23 Apr 2018 08:49:47 -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=B2tiJFJA; 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 S1755946AbeDWPsP (ORCPT + 99 others); Mon, 23 Apr 2018 11:48:15 -0400 Received: from 8bytes.org ([81.169.241.247]:60618 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755574AbeDWPry (ORCPT ); Mon, 23 Apr 2018 11:47:54 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id E555978B; Mon, 23 Apr 2018 17:47:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1524498464; bh=M8Q8ExfOVfYhHy5Clr3+nR5f/zoTIOyBID1GW0rYFR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B2tiJFJAG/20bLLu7Lx85fGGm35WJt55/EZMR3WrC26ZmMiVb7lxOAyBblXHGBWWH znhtGGO0PQLbFgIYibKgoZfExG5efyFPSu8Es6JbdsuI+CR9RztH8C4mhbS/31dFrH 92bRBZQSlJIaFefoAz6LKBpz3izrhMJ99CLrgCLMFvFWyCJMYsBx6QwYIX+9OaFjYt 83gE8Cwtyq6rVoIMznl3z0jwyr96ZkVLC1EhFBcMDzS+VXSrjEJfRgTp14n/Uph7BF 0EQF557ttWE05E0Nz5GCxXq17xt+nEnPm3EThTm9H0pg4ewjeER3ZxXlW9rrc7wz1Y TaT/jaUqrCp1g== 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/37] x86/32: Use tss.sp1 as cpu_current_top_of_stack Date: Mon, 23 Apr 2018 17:47:15 +0200 Message-Id: <1524498460-25530-13-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524498460-25530-1-git-send-email-joro@8bytes.org> References: <1524498460-25530-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 21a1149..d65e852 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