From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80195C43381 for ; Mon, 8 Feb 2021 20:38:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1FF0064E6E for ; Mon, 8 Feb 2021 20:38:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234030AbhBHUiM (ORCPT ); Mon, 8 Feb 2021 15:38:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236146AbhBHTVv (ORCPT ); Mon, 8 Feb 2021 14:21:51 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC1FBC061788 for ; Mon, 8 Feb 2021 11:21:08 -0800 (PST) Received: from zn.tnic (p200300ec2f073f00132389f64ded89c1.dip0.t-ipconnect.de [IPv6:2003:ec:2f07:3f00:1323:89f6:4ded:89c1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 564261EC0516; Mon, 8 Feb 2021 20:21:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1612812067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=4c9RhzPbwN8HS3XfQ2Z1I8RZIi0JC8xqn8Lcka/rU64=; b=Kv3JtNGzM3ucgPQ00jQDkS8CYaKY8hL3yNXGcmS7nazBAFDYNGP4Z1699dAXAg/zPm+mpN mECxYEldKRNIv5VSWlL7PS+FHjCh1HK+lEqxmiDVARjt/mp96rODm3V3xtfo3K7umLE3fY Z51txNE/TRbY3OYvojUc3WBqwVltI2A= Date: Mon, 8 Feb 2021 20:21:09 +0100 From: Borislav Petkov To: Lai Jiangshan Cc: linux-kernel@vger.kernel.org, Lai Jiangshan , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , x86@kernel.org, "H. Peter Anvin" , Dave Hansen , Peter Zijlstra , Al Viro , Vincenzo Frascino , Joerg Roedel , Ricardo Neri , Reinette Chatre , Andrew Morton , Gabriel Krisman Bertazi , Kees Cook , Frederic Weisbecker , Jens Axboe , Arvind Sankar , Brian Gerst , Ard Biesheuvel , Andi Kleen , Mike Rapoport , Mike Hommey , Mark Gross , Fenghua Yu , Tony Luck , Anthony Steinhauser , Jay Lang , "Chang S. Bae" Subject: Re: [PATCH V3 2/6] x86_32: use percpu instead of offset-calculation to get thread.sp0 when SWITCH_TO_KERNEL_STACK Message-ID: <20210208192109.GH18227@zn.tnic> References: <20210127163231.12709-1-jiangshanlai@gmail.com> <20210127163231.12709-3-jiangshanlai@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210127163231.12709-3-jiangshanlai@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 28, 2021 at 12:32:18AM +0800, Lai Jiangshan wrote: > From: Lai Jiangshan > > TSS_entry2task_stack is used to refer to tss.sp1 which is stored the value > of thread.sp0. "... which is a copy of thread.sp0." > > At the code where TSS_entry2task_stack is used in SWITCH_TO_KERNEL_STACK, "TSS_entry2task_stack is used in SWITCH_TO_KERNEL_STACK and CR3 is already... " > the CR3 is already kernel CR3 and kernel segments is loaded. > > So we can directly use the percpu to get tss.sp1(thread.sp0) instead of Who's "we"? > the complex offset-calculation. > > Signed-off-by: Lai Jiangshan > --- > arch/x86/entry/entry_32.S | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S > index df8c017e6161..3b4d1a63d1f0 100644 > --- a/arch/x86/entry/entry_32.S > +++ b/arch/x86/entry/entry_32.S > @@ -465,16 +465,11 @@ > cmpl $SIZEOF_entry_stack, %ecx > jae .Lend_\@ > > - /* Load stack pointer into %esi and %edi */ > + /* Load stack pointer into %esi */ > movl %esp, %esi > - movl %esi, %edi > - > - /* Move %edi to the top of the entry stack */ > - andl $(MASK_entry_stack), %edi > - addl $(SIZEOF_entry_stack), %edi > > /* Load top of task-stack into %edi */ > - movl TSS_entry2task_stack(%edi), %edi > + movl PER_CPU_VAR(cpu_tss_rw + TSS_sp1), %edi > > /* Special case - entry from kernel mode via entry stack */ > #ifdef CONFIG_VM86 > -- The change itself looks ok. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette