From patchwork Wed Jul 11 11:29:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10519443 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F379B603D7 for ; Wed, 11 Jul 2018 11:30:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 023E128C90 for ; Wed, 11 Jul 2018 11:30:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E488728D4C; Wed, 11 Jul 2018 11:30:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66DA428B62 for ; Wed, 11 Jul 2018 11:30:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 11DD66B0274; Wed, 11 Jul 2018 07:30:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0D0D46B0278; Wed, 11 Jul 2018 07:30:11 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E93A46B027B; Wed, 11 Jul 2018 07:30:10 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id 744EE6B0274 for ; Wed, 11 Jul 2018 07:30:10 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id p5-v6so1426686edh.16 for ; Wed, 11 Jul 2018 04:30:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=QuAuFLy7E8XR8NrGDE5nDgjn6lj51MpwINLeAvdPink=; b=lRDSEhBzsBJwAUc6UPRcaeE1nPKckPmRPVK72QT4vGgi4VxuWr1j9yfZVAqZkcMZ2n 6BYNgEf1bvBMKlKodrQFZT+kzYuodQMlG8XnSZwwW9t0saGczWa1PVdyTqjK0TEWcy/q ENWuCgvd/UkWH269IL34ixuF78EQcjnq9m4eis4bBBc7ADNlOS4lo0TSnY+IQGzofota BhxkqoSyip8bpHkXobT8bHu6eULfrUJ19l70MoNcZ8tpCCNm0hREFEcNJ8WDfqkOc1vE vEWfFI7zMXAZwmndqxbldhg0U6QRPLOQMHYElXegAIuF4srnDCzTH1I7+afgCif4KEe8 oEQA== X-Gm-Message-State: AOUpUlHZH0chU9GZOEBT2UnjdjWu+H3Uahcjb66FJropAY+SWtBUtYFI GBhTpe/zowEKfcCDv/GL3r9BQecVWW/Q5wKiETmvga9Bag+1OgJxI0+pObtKWO4jY0TcGHXPs7W lrRQylQIsTAF9DuSIP78fNKYAJDbu1ymkvdtXRSyzkpZOObAqD7tNXXqD/yUjetPjPw== X-Received: by 2002:a50:e146:: with SMTP id i6-v6mr16704767edl.204.1531308610008; Wed, 11 Jul 2018 04:30:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeuvRP9giuAaeGkr/LJyG/Nhk3w4q0dkn83M8nz3Y+S41jU7c/lcy6ZkwBsArg9OUHxJz4M X-Received: by 2002:a50:e146:: with SMTP id i6-v6mr16704730edl.204.1531308609319; Wed, 11 Jul 2018 04:30:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531308609; cv=none; d=google.com; s=arc-20160816; b=RTOmFaxOxz30M4o57LZ/wH4MJcAe5kh3N7f60LLqWIp0N2l+fmmAAZo0FmqLYRrngZ W32P2g6r1T9/fhq9wgGC/o+RE7h/KDoceGYqHcE+3S/Vu+biMnvyy3PsO3eveTFwG1Wo WVV2xKONigWfOXDa6K7G6HhVKhLC09x58+JXzNBS9pCoi0AN8H/GvwOOxEO+0rgsuPus CEtknZr60HDfYIC0xpRcwy/SExMlRa1hrmwadONtjiSA+OcXSv0kAs+2Yq4r2FTDsTA/ 5DAbumzs0SZlrfTcfUsJ+U1BJjBOcIWtsrPCbxUmRbTlW0JL2qZKWCYqWXmM3AA5APAA QbXA== 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=QuAuFLy7E8XR8NrGDE5nDgjn6lj51MpwINLeAvdPink=; b=W/gcE3HbMCOdN+5Ah8jQc7tjlHOlndqCnJakQIjJNrjI+Zfg2SfdRQef8fcZ3L+cba uzI9aVonJcuICKnrFZQndSXB6p5//4F4ZWGPzQQXmiz+fZGCuosdKjAcbeBd7Q+qsh/0 ht7BvJCykcyxpU7JDNadGuezxv8pHJSItPE/fHQrpL11dQXSA7Pz/3q5tgQco+06Ub65 6F9+6QAYOAnL3kLrKR7tTjawEr1/5zfqnTN4TxGSaNwojfyRVYG43JUIGrKSIiv0xRMO zvis4D3sSfEsXecTmnqf8BiuqRYW1r/ny4Aj1Mo1YAkANZtiYxkWDMAs6540fQbgoVSB dRIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b="qBVW4/fT"; 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 Received: from theia.8bytes.org (8bytes.org. [81.169.241.247]) by mx.google.com with ESMTPS id p63-v6si6811641edp.313.2018.07.11.04.30.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 04:30:09 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) client-ip=81.169.241.247; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b="qBVW4/fT"; 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 Received: by theia.8bytes.org (Postfix, from userid 1000) id 9CCA07CA; Wed, 11 Jul 2018 13:30:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1531308601; bh=4sJGIEqWbet42hjnTspgKKb65j2w9h1k8PwVqGlOHaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qBVW4/fTxw+nSd+7K92h02uPz8th7kCyxEzcDyDA3Vxd7UfEWO+dsUFpBf03LHxmn gn6/sA1MBWHtRzOK2szZUgKhDHyVnZ/9TKjQWNgPANhP5wGV2xgJFeCQqY/q5ZUgYS xd2jk+KnsmG+Kvqddl84+6AiJA09s7tV670TAuEL2BawfbdR/IVYzNNn5UzBxaJDoj 4JTnFoDLm+xGyBlsEcVbiyRJCYNfTF433IdsijkuCiphrtn4q3KeGLWE8Hlz+xhPFO oPCK2ddlYBeE5bc9HGB/Hdvivph1c0BmTGkWhQLQRgEyQr4tSIdYQvJCu1hTkgfMns K0MfTjc1nTcqQ== 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/39] x86/32: Use tss.sp1 as cpu_current_top_of_stack Date: Wed, 11 Jul 2018 13:29:19 +0200 Message-Id: <1531308586-29340-13-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531308586-29340-1-git-send-email-joro@8bytes.org> References: <1531308586-29340-1-git-send-email-joro@8bytes.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 cfd29ee..2c18b33 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -365,12 +365,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 2ff2a30..c000889 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h @@ -207,9 +207,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 43a927e..712ce04 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1598,10 +1598,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_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 04bbf93..2eecb8a 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -288,12 +288,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)