Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp722184ybz; Fri, 17 Apr 2020 08:53:39 -0700 (PDT) X-Google-Smtp-Source: APiQypITuO7KA58n4EY+LMrpjCo8lphuaUbBTQ0uiHA42sLgWiOunODQxjdXYoSIvm4v4+0vvi2I X-Received: by 2002:a05:6402:b99:: with SMTP id cf25mr3624919edb.372.1587138819545; Fri, 17 Apr 2020 08:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587138819; cv=none; d=google.com; s=arc-20160816; b=h3SIy9N9X5nOBuXXa+NhGMJSITvR9WHPswDwxqfky4+GpMowhGffk6kVxp82pSTL53 ncGYeEFkupn9iMw87YG82zn+eU1Wd9GaHF1umA9NPTsx7bEvgBhFsk3zEPjDIzaFPerX rbfy3fGg/LTNmstRewOE8JKrVOwwMPxogjxnGP6AFkfmuroBdSXU2ppe60/kfoQqC/nP lIXj97t33mZd3FxHT8MmWXep27FZoz+m0/w+Gy2+/UJyo9OR5nYrZ2/Z323aetsPLDWD P9Fj0d6ZYUmA8Cry82oURWx4WdccLG19XOE3OvHWlLOE9fDsDLsZGNPJhbXnU4P08lFf Nh2Q== 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; bh=MGlM12DXqyCXn+1/O9xLj9OaVnacb7TAA8Dtim1LYrI=; b=f6JCb6EepZuAeIyHTpO0iXeCOOyHWhTa2a1EsGo42wzhcCwGzzkrVVW09toCvr8Nxb hnCE77oVK8D/utOMoyA/53u2AjehKuSJCOJD+27ZkLpg4t0Yg/s5c/wXCoBDjyJVyS+7 nEJeSsQ8gIEgdzwCtmIuaB6OeD9fQz2Xq7EZafxGF/4PnA7sEhasgAl/Kkuoi1XHLtuy +Q6My/fwtBFaIOP66lhUU1UiYFBDF08xcQGK5PRV6i2V676VRhdh9gNoa3C17XolR80l pe3NffqYG6U/Agp/cp2/OcF832F+dgKt0eKStfRwBN8uEPmzEI4AMT0J/wjCIcHBKCel /j+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M1euMgXI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id y25si2611125edi.578.2020.04.17.08.53.16; Fri, 17 Apr 2020 08:53:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M1euMgXI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1729311AbgDQPwV (ORCPT + 99 others); Fri, 17 Apr 2020 11:52:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:59230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726385AbgDQPwU (ORCPT ); Fri, 17 Apr 2020 11:52:20 -0400 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 8ED9D22243 for ; Fri, 17 Apr 2020 15:52:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587138739; bh=/J+nb8RRN8uQr4miJ5pXtTRPZ6bHsl9bOvRY95IOH8k=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=M1euMgXIjdbZtfUU9lO3yb/qDhVdNTU6nouCORvCQAtvZlhG4qWJ6Dcg7tgsA9rUb r0QC8zGC+IsVeohCgk1u8LSk3UMt/B+e/KL7jHoh8JSXqAvYtxBqUcew5ye/OIae2e VASO1gWCMbCO/9dSMt1qItYRsgY9vW3c2yLitLJE= Received: by mail-wm1-f53.google.com with SMTP id g12so3516816wmh.3 for ; Fri, 17 Apr 2020 08:52:19 -0700 (PDT) X-Gm-Message-State: AGi0PuY6FrhPqkR8iQZvPJvqklF1b4gIYoOYqlXL+6/LqQ2xsgXEbMqD Bf8RvqpxF8lQRErAK+otl3UbHHzVP0olwyK2QLtRbw== X-Received: by 2002:a1c:4186:: with SMTP id o128mr3987095wma.21.1587138737993; Fri, 17 Apr 2020 08:52:17 -0700 (PDT) MIME-Version: 1.0 References: <1570212969-21888-1-git-send-email-chang.seok.bae@intel.com> <20191115191200.GD22747@tassilo.jf.intel.com> <29FD6626-4347-4B79-A027-52E44C7FDE55@intel.com> <20200413200336.GA11216@sasha-vm> <20200414003205.GF397326@tassilo.jf.intel.com> <20200417133021.GT1068@sasha-vm> In-Reply-To: <20200417133021.GT1068@sasha-vm> From: Andy Lutomirski Date: Fri, 17 Apr 2020 08:52:06 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v9 00/17] Enable FSGSBASE instructions To: Sasha Levin Cc: Andi Kleen , "Bae, Chang Seok" , Andy Lutomirski , "Metzger, Markus T" , "hpa@zytor.com" , Thomas Gleixner , "bp@alien8.de" , "Hansen, Dave" , "Luck, Tony" , Pedro Alves , Simon Marchi , "Shankar, Ravi V" , "linux-kernel@vger.kernel.org" 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 tip-On Fri, Apr 17, 2020 at 6:30 AM Sasha Levin wrote: > > On Mon, Apr 13, 2020 at 05:32:05PM -0700, Andi Kleen wrote: > >> Is my attempt at understanding the current situation correct? > > > >Yes. > > > >Nothing breaks, and it's a nice improvement for context switch > >performance, in NMI/PMU performance, and also gives user space two free > >registers to play around with. > > Thomas, Andy, > > Could you list your outstanding objections to this patchset? I know it > might be rehashing stuff you've already mentioned in this thread but I > think that there's a disconnect between folks and it'll help with > restarting everything. > My outstanding objections are: 1. The previous submission was broken. This should obviously be fixed. 2. The issues documented here need to be addressed: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=56f2ab41b652251f336a0f471b1033afeaedd161 3. Adding FSGSBASE fundamentally changes the user ABI, and the changes will be observable. This means that something could break, especially in the case where ptrace is in use and the tracee uses the new instructions. The old behavior cannot sanely be preserved with FSGSBASE enabled. This isn't a showstopper, but whoever resubmits this thing needs to document what changes and what use cases might break. I'm hopeful that the only thing that will break is actual human beings using a tool like gdb to manually poke at the registers. This is fine -- the behavior of the registers is different and human beings debugging need to be aware of this. But the existing automated stuff that gdb, lldb, etc do needs to continue working. This especially includes using gdb to force the tracee to call a function, e.g. 'p function()'. 4. The exising ptrace API does not provide a sane way to ask what the base value associated with a selector would be. This means that, under the natural way to make FSGSBASE and ptrace work together (e.g. as implemented in the previous submission), the tracer has no good way to emulate 'MOV [whatever], %gs' in the tracee. Now maybe no one cares about #4. I certainly have the impression that the *gdb developers* don't care. But gdb isn't exactly a good example of a piece of software that tries to work correctly when dealing with unusual software. Maybe other things like rr will care more. It might be nice to avoid a situation where a piece of careful software (like rr?) can support kernel 5.y, but breaks in 5.y+1 because of FSGSBASE, and only starts working again in 5.y+3 because we added the ptrace API that's needed. So maybe the first version should have a PTRACE_LOAD_SEGMENT that sticks a selector in FS or GS and changes the base accordingly, even if no current userspace has spoken up and said they need it. And a selftest. --Andy