Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp999739imm; Thu, 31 May 2018 13:15:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJnizZm7bnZ9lqO4XYGPKh2qK326HYQwxBCfIizXQXyu7fkh7muIE20AQuT/e8GK+W6aimf X-Received: by 2002:a17:902:8c95:: with SMTP id t21-v6mr8211838plo.306.1527797734450; Thu, 31 May 2018 13:15:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527797734; cv=none; d=google.com; s=arc-20160816; b=Q4w6Cssw7FPycbJa5AQirsbeP/WEXaPW+FfrGbvps9d7V7jJnp6zohL3Ly1fGxMMgs dCL2dIAheyz7REdS0Mt+FWOq5IzK8vZWyE13PbpAEwE6tkJDqSMI1xR6c+jTVZ/R5xys aa2gJxW2oOC0aTphv0BOeBD576oztFfRLwKvIhYd5JcRj6IfuZsQ5ZC+h0rWFOrwRyAs E7+qsP0y4Ngl62y8+DDa2qI5wXmBPbPoSjMXhyPeNuW/p2DISVoBYjYq6UjpaCoiQwQW uCflfEkQP1xl5Zb2ZteamUkeGzOlPG1tu8BkoIBp1MBrP5vuLYD1x7NNKsqoxq6464th QWMQ== 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=Mkx18MXJKfzTyjrw9RaSKWVYhfhc4XOIJrv4IdKeAPs=; b=wn1FsbVwMDmEs46n31ft2NpjL//EAtOT0/O5JM2wUSgx7dztbI0xVq52Am58a7OhH5 G3WvpikGlcMV5hIvfxSnTgzJr4wt8lRLlnYM3jJ0VWWDe77Y4bAGwowyIGt0satOuSRq HhU9VnSZbR5GrggKKvJf7s2mHbT12CBLIC85hrgaQ8Rd7HtKdczQiEug8ZQlzSKLEKpE Yo+roAkZWOdSdvREzno6PrommcgvwI+0h2Vd1gqccicTtRtM1tocPgNzAbN5jOnwRNoL YCsLj5/FkVRl5jJGYrkk2iannJ4JpT7KOon0XYZvb3gegeNjh82YUdjNipihq8CSa8bo K4Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MoDiistj; 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 u13-v6si36316967plq.161.2018.05.31.13.15.20; Thu, 31 May 2018 13:15:34 -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=MoDiistj; 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 S1754332AbeEaUOV (ORCPT + 99 others); Thu, 31 May 2018 16:14:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:46088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754293AbeEaUOU (ORCPT ); Thu, 31 May 2018 16:14:20 -0400 Received: from mail-wr0-f180.google.com (mail-wr0-f180.google.com [209.85.128.180]) (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 9174B208AE for ; Thu, 31 May 2018 20:14:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527797659; bh=51sVfzT2k9sZQRy/M7NNsf35chU0X4f261H9Ilbe6wY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MoDiistjJVu546GAapoAaCiUEMW8k0xVpaP2B387mAZZ76YMmuDgEQI2IFlyum9Mp zyiBLeSnsI+cD4LjWqHmqVdiIiYJrspet5YQKJuoP34Xy8yQNhZlIl8tVh5fbDEtoF uqQfhztZVTXMj3hhDOq8YUF1psCUNIjYTkxHzD2A= Received: by mail-wr0-f180.google.com with SMTP id y15-v6so34172649wrg.11 for ; Thu, 31 May 2018 13:14:19 -0700 (PDT) X-Gm-Message-State: ALKqPwesLSTGNvb+BWjW8zjJFPbKHzHbnGVdQI6Cv4ffxqzyb20ofO/i Ekf+iONpLUZDOJGkHhYxANHWZHH1M9I5irQPtbNBxg== X-Received: by 2002:adf:b456:: with SMTP id v22-v6mr6242182wrd.67.1527797658057; Thu, 31 May 2018 13:14:18 -0700 (PDT) MIME-Version: 1.0 References: <1527789525-8857-1-git-send-email-chang.seok.bae@intel.com> <1527789525-8857-2-git-send-email-chang.seok.bae@intel.com> In-Reply-To: <1527789525-8857-2-git-send-email-chang.seok.bae@intel.com> From: Andy Lutomirski Date: Thu, 31 May 2018 13:14:06 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V2 01/15] x86/fsgsbase/64: Introduce FS/GS base helper functions To: "Bae, Chang Seok" Cc: Andrew Lutomirski , "H. Peter Anvin" , Thomas Gleixner , 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 Thu, May 31, 2018 at 10:58 AM Chang S. Bae wrote: > > With new helpers, FS/GS base access is centralized. > Eventually, when FSGSBASE instruction enabled, it will > be faster. > > The helpers are used on ptrace APIs (PTRACE_ARCH_PRCTL, > PTRACE_SETREG, PTRACE_GETREG, etc). Idea is to keep > the FS/GS-update mechanism organized. > > Notion of "active" and "inactive" are used to distinguish > GS bases between "kernel" and "user". "inactive" GS base > is the GS base, backed up at kernel entries, of inactive > (user) task's. I'm fine with the code, but the changelog entry is confusing. A bunch of the active helpers don't contain the term "active". > +/* > + * Read/write an (inactive) task's fsbase or gsbase. This returns > + * the value that the FS/GS base would have (if the task were to be > + * resumed). The current task is also supported. > + */ Please change to "Read/write a task's fsbase or gsbase. ... These work on current or on a different non-running task." > + > +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 > + */ > + fsbase = task->thread.fsbase; > + Please put braces around the if and else blocks whenever either of them spans multiple lines. Also, maybe change add a note to the comment and/or the changelog that this is preserving an existing bug and that it's fixed later in the series.