Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp944879imm; Fri, 22 Jun 2018 07:54:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI+TjllBiipMCgxo6Eb+sadm2DtfsYeBRZrc6D9I5ayW8mpuMNTy1v7qhhqZLZv7u8He5Zh X-Received: by 2002:a62:e005:: with SMTP id f5-v6mr2149831pfh.88.1529679261824; Fri, 22 Jun 2018 07:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529679261; cv=none; d=google.com; s=arc-20160816; b=otJrwbPbwUTWCww1rLPBtO4T+ZqgnIe0qQ9zlIXQnloEYVd9E8TvRXUTUjKy65dPz0 z4BrKOGIAeqOBDMM0i7i7rcScPy2JFowgUzVXpcrVVYvJxDz9Skv+upigsCIrXl4HxhU g0bq5EK0eoBtGyATOX8htU8yj/w8LOAS2SB//R3AOyBS6ruWMIToi7INfDs0agEFhOZn pDYrQP2hn60srk8/s+WydR8HghdURPdB+o7bBe/wAhf41QCJ30MrY5qzIot4BxUbq6n3 hahyQSg0/k5PLWSRLb0nHW9x4V6lqDb+EBZ4oF8iH7rKOvok0+jao2kH4RaSjMkfE9Af LdPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=QZYCwniButzmf3SLuwTrqLYwpgNSF/mi95XEbQQyug0=; b=Q6kolB98WjeJZ4jQOlhSxpdRGdn094dqLMCdA9Vs8cq683xgfZlXHKYRyj1UkWyXG+ sWB9B5aYv/IQm+4VYc5ayj09xF0NBR0Gq8q0T6uB0/yiOdxObxWg9T/WwtqSnBbeohSx 7dcWurg4BfYLJhLrQ9Cjmv0pAVjLijCFQvVLOD1MV/2+CaaDWOIqVBPYFFesZKkkFJ0M lwjgZWSUC3bLRS3d1Gfbwa5Q7kmR+Nh+Yrmd4d6n51LwuSSYZe9sZTtFm/uyt6f0JM90 GNoUEuFyqP5YlhYzXfJ5VvkCE7i94rqXGXj4C0A1SORYH75ABqeFuVAqCUF+eZWWFsuv yGCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hDXulHkB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o123-v6si6221412pga.20.2018.06.22.07.54.07; Fri, 22 Jun 2018 07:54:21 -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=pass header.i=@kernel.org header.s=default header.b=hDXulHkB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933583AbeFVOvo (ORCPT + 99 others); Fri, 22 Jun 2018 10:51:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:47862 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933812AbeFVOus (ORCPT ); Fri, 22 Jun 2018 10:50:48 -0400 Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 54FA32440A for ; Fri, 22 Jun 2018 14:50:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529679047; bh=NT3wZPBKZ91kirKmpMfjlBzD3k73dcr+ipFFlnqM8yY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=hDXulHkBwKnPJJHaSfIiVjcPpU6iHoiWUWj6FlLz0cCZN7ELkgpp2Jq1LX6UO+N5p JCqAlOfHoDrQS1xSOncVt+aGkHgJud5vwiNfqE3SJPhQpfnTvTFlHgrS9f5zZRQqkj MEKysvAyn6UicHJlaPEurJungGzCiyvLb3AvZDCg= Received: by mail-wm0-f48.google.com with SMTP id 69-v6so2933330wmf.3 for ; Fri, 22 Jun 2018 07:50:47 -0700 (PDT) X-Gm-Message-State: APt69E1t8c4IyYDwHVN2KpL4f11AXLCYEhdQ9MWZ7m/Yb7k6lbbBwsOQ kTZVG9y3f2e27SFpaF5aqzpjKDRu+SbgehcNKamjOw== X-Received: by 2002:a1c:f902:: with SMTP id x2-v6mr1868057wmh.116.1529679045882; Fri, 22 Jun 2018 07:50:45 -0700 (PDT) MIME-Version: 1.0 References: <1529536506-26237-1-git-send-email-chang.seok.bae@intel.com> <1529536506-26237-2-git-send-email-chang.seok.bae@intel.com> In-Reply-To: From: Andy Lutomirski Date: Fri, 22 Jun 2018 07:50:34 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 1/7] x86/fsgsbase/64: Introduce FS/GS base helper functions To: Thomas Gleixner Cc: "Bae, Chang Seok" , Andrew Lutomirski , "H. Peter Anvin" , Ingo Molnar , Andi Kleen , Dave Hansen , "Metzger, Markus T" , "Ravi V. Shankar" , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 22, 2018 at 7:28 AM Thomas Gleixner wrote: > > On Wed, 20 Jun 2018, Chang S. Bae wrote: > > +void write_fsbase(unsigned long fsbase) > > +{ > > + /* set the selector to 0 to not confuse __switch_to */ > > 'to not confuse __switch_to' is not that helpful of a comment as it > requires to stare into __switch_to to figure out what might get confused > there. Please write it out why this needs to be done in technical terms. > > > + loadseg(FS, 0); > > + wrmsrl(MSR_FS_BASE, fsbase); > > +} > > + > > +void write_inactive_gsbase(unsigned long gsbase) > > +{ > > + /* set the selector to 0 to not confuse __switch_to */ > > Ditto > > > + loadseg(GS, 0); > > + wrmsrl(MSR_KERNEL_GS_BASE, gsbase); > > +} > > + > > +unsigned long read_task_fsbase(struct task_struct *task) > > +{ > > + unsigned long fsbase; > > + > > + if (task == current) { > > + fsbase = read_fsbase(); > > + } else { > > + /* > > + * XXX: This will not behave as expected if called > > + * if fsindex != 0. This preserves an existing bug > > + * that will be fixed. > > I'm late to this party, but let me ask the obvious question: > > Why is the existing bug not fixed as the first patch in the series? IIRC that was how I did it in the old version of this code. I think it did it because it was less messy to fix the bug after cleaning up the code, but I could be remembering wrong.