Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3667017imw; Mon, 18 Jul 2022 12:16:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uoIpoJWG8WCD/MM6tNfCNyyHRH0GfBkgcQ0yC4fxxr9SlO2Q/48PXdrUaloBsPiof+UUPw X-Received: by 2002:a17:90b:3b41:b0:1f0:39eb:62ce with SMTP id ot1-20020a17090b3b4100b001f039eb62cemr33026457pjb.61.1658171781626; Mon, 18 Jul 2022 12:16:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658171781; cv=none; d=google.com; s=arc-20160816; b=PnWyDTkna3Fcsl9Ebosv1FYIZLNDCW+2sGCl52tEaGUdMrKwH+Ea26VoOyNn62IJWv NUfMtpBDQnlhJMLPGDfc47xj/g4DyrefGApmrJqtp+PsoMJfH4M+eBfq6XYUVgjWb/B5 di12e7L0ApMC+37vNKKzD4ahaMGRPpltLHNWTQxJP5fKKDvbqw5srIpwV6MFOfcc9b/o WpNpJMNp0TVGznjniL+3k6B8OJNvQARK1+4A1faePSvCC2FSFS3VwozFN25SzuEaD8Nj d/VRHtFd+DdB7BsAToEBEBAJo3bWtYL59tYQuL066DByeevKKTT69mqElTHISsrgKyod 8CkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=afKbqenpGLounXqvR8fEhHYYL4+7diHe5lEv1lZPTA8=; b=bTzshDxN80e0dZ1h2BhV5A5+L/0Klh0v+tph131D7Oidj5HrrDuEVrmmhu99hM1DcT 5icvNCNaPxvKG9465gjuRqB9/1iZp+ZPxuO6jvaYdUQkEVxbUlYKy63iRCKK8i9D7tvp 9fEN9KRnWFfWzelfod/f2dGQ4ZEabxK4SjTN4zAoorqtq0jcVAsdCdwxh7HNj6HDw/it N3HnHOtDZvWR3xfl/G45oLQne31E6u40IMbc+HuAXz4dWOQX8e0lK0oc3jtNMsNQJVNU YsqYZBgrRtxhdJZq9fjcXKGVhQ9Mb30uoCkQA2rSym0I3s/vSnqD6f4q3ZD/p1uIkBaD 6JYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NYcM9YKA; dkim=neutral (no key) header.i=@linutronix.de header.b=Swrn6KgV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q13-20020a170902eb8d00b0016c527b7060si14123708plg.66.2022.07.18.12.16.06; Mon, 18 Jul 2022 12:16:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NYcM9YKA; dkim=neutral (no key) header.i=@linutronix.de header.b=Swrn6KgV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234042AbiGRSzH (ORCPT + 99 others); Mon, 18 Jul 2022 14:55:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231264AbiGRSzG (ORCPT ); Mon, 18 Jul 2022 14:55:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F20327B36 for ; Mon, 18 Jul 2022 11:55:05 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1658170503; 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: in-reply-to:in-reply-to:references:references; bh=afKbqenpGLounXqvR8fEhHYYL4+7diHe5lEv1lZPTA8=; b=NYcM9YKA6ztrzNJFJAB2E0DhOrCQF1m6NLFmvva5ImQsdDl91CYn4nAPuanFY/bVMIH5V8 gszeECVVfpHSLZgjPG+QLtiz0iHABwLhcD7uuqwgr9nyolLZOTHE/RkrsiMG9/s3l35dbD DoZRQbNydVXkXw3NNlzw1VO0yKGeFKo9uzrv9f3Nvb6eOVwHEdlUMvu904XDHAHV+P5sbl gTylX0qEmLFpKyIcljGK7eICc/AlilWJaOVHaSm1ctAF4b4ds5BbreeqUf8Fj2xkwOEYhh CgtvpMUCsyXz+zOfo8YAlJrqBTyhAkbiHGZvWsjRTJvh5x7teSzJmJeq/m4Cxw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1658170503; 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: in-reply-to:in-reply-to:references:references; bh=afKbqenpGLounXqvR8fEhHYYL4+7diHe5lEv1lZPTA8=; b=Swrn6KgVrXgbbqduXGxdrj5SIsphMNn2+gX+sIqXieSwZxNfItJkERHAogQ7iAWkA7wgqX RAUQYCsRVkxcw/Aw== To: Linus Torvalds Cc: LKML , the arch/x86 maintainers , Tim Chen , Josh Poimboeuf , Andrew Cooper , Pawan Gupta , Johannes Wikner , Alyssa Milburn , Jann Horn , "H.J. Lu" , Joao Moreira , Joseph Nuzman , Steven Rostedt , Juergen Gross , "Peter Zijlstra (Intel)" , Masami Hiramatsu , Alexei Starovoitov , Daniel Borkmann Subject: Re: [patch 1/3] x86/cpu: Remove segment load from switch_to_new_gdt() In-Reply-To: References: <20220716230952.787452088@linutronix.de> <20220718173923.891284477@linutronix.de> Date: Mon, 18 Jul 2022 20:55:03 +0200 Message-ID: <874jzew8s8.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 18 2022 at 11:43, Linus Torvalds wrote: > So I appreciate the added big comments in this code, but looking at this patch: > On Mon, Jul 18, 2022 at 10:52 AM Thomas Gleixner wrote: >> + * For secondary CPUs this is not a problem because they start >> + * already with the direct GDT and the real GSBASE. This invocation >> + * is pointless and will be removed in a subsequent step. >> + */ >> + if (IS_ENABLED(CONFIG_X86_64)) >> + wrmsrl(MSR_GS_BASE, cpu_kernelmode_gs_base(cpu)); >> } > > ... while those comments are nice and all, I do think this retains the > basic insanity of having "switch_to_new_gdt()" do magical things on > x86-64 that don't really match the name. > > So honestly, I'd be happier of that whole > > if (IS_ENABLED(CONFIG_X86_64)) > wrmsrl(MSR_GS_BASE, cpu_kernelmode_gs_base(cpu)); > > was migrated to the callers instead. There aren't *that* many callers. > > I expect that it is then quite possible that several of the call-sites > would go "GS_BASE is already correct here, I can remove this". With the next patch we have only two left. The SMP and the UP case. Let me look whether the UP needs it at all. > But even if every single caller keeps that wrmsrl() around, at least > it wouldn't be hidden behind a function call that has a name that > implies something completely different is happening. > > And no, I don't care *that* deeply, so this is just a suggestion. > > But wouldn't it be nice if this function was actually named by what it > does, rather than by what it used to do back in the i386 days when the > GDT affected the segment bases? Yes. Let me come up with a sensible name. Thanks, tglx