Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1228833imm; Wed, 6 Jun 2018 12:30:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIjaKdQ+MFKJ0V7xjWLCtCmkPYZQb1vkjZ7UM8w7CggsViWj34VZ6jPAat9BBGU8aSPSB+f X-Received: by 2002:a65:6047:: with SMTP id b7-v6mr3633686pgv.241.1528313414400; Wed, 06 Jun 2018 12:30:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528313414; cv=none; d=google.com; s=arc-20160816; b=iWCDsAF2MLU11nm9NJjenc/b6Ic5a96OKSz+4vBVWel65N2S54U+RicZHa5Jgg75vH ujSBs48pE5UJsAdeXtAp/kaKAPt/OvtJMS0csnUjAjW2hF+DtDDEiRyWhBu/7LvCW9mN TMfCgTB24ZyYiQ4TMrQAFe1mvJXUiSSG6fCbVbFGcz3zCpzR9oxaaR1KONV/+Ts1HUi0 ofY/B7k4etJ0Bsq1rSWnTBXlrcfSratikMnqCqWADpk23NlUD5/c8wuuqfRENi2xr+We T3LlJRPqFCk4FWUd9iBpyfdVgowIyIRfRlvIBIjbHJwaxvnFt3nrIC20A9/VCV8jAnKp kEWg== 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=/3c73Wm/Aj/WeYk+lS/rwJxoRXYlyBB4p53hUaaLfdk=; b=VKdfhmwZ/49ztX2Gz2HXuwsBktfsdS35J8Z+otuJTqDL+0ykcoghy0IumWXUAr304u nVsl3IFsdVruZpFLPG0WKhGo7Z+E0nKs4f4Pwxd8t83uADOw3W5DfE+KugyXEDbh82SO fG6pQ5hZJuD/T7yO5OWuCZ7rbRbGCPY/7l9av3WIGbwPzwiSKlLaLrszVU/VqA+tDc7I CdvD4mlBL37nVbWx4OhnX8NSaw5yQrZQSkU39xAocJKBVLC50iacDTsFAsqHaJSacRxU PM7jELPcHFQqNerj7VIT4ELwtq3YiVYUvaDxpgePxSkyvPKeNCRiV22vRsPbl8hiCcbM ghxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lCcLjMfJ; 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 v26-v6si23823515pgc.416.2018.06.06.12.29.59; Wed, 06 Jun 2018 12:30:14 -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=lCcLjMfJ; 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 S1752578AbeFFTYv (ORCPT + 99 others); Wed, 6 Jun 2018 15:24:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:48340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752228AbeFFTYu (ORCPT ); Wed, 6 Jun 2018 15:24:50 -0400 Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) (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 73FED2077B for ; Wed, 6 Jun 2018 19:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528313089; bh=Bf7ibN+4bHu/sL4J/ZD8lW7oA+LPHpQWmWePPO+KJbs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=lCcLjMfJB8RyeCJfdLBvj1Myp5eUkSUVZ6TgfuJXrmzn9EVoQhGKbY3Ije/BGcdwY a0l34s8138mCHsluqQd/A3VYHnyGQKre3fV2jvk3R0laPAlqfVFAmdZHx8JgFmLg5o 0f/k2kRy76U3grYe6ErtMnyewkuzsLR5ZSPcvfio= Received: by mail-wm0-f45.google.com with SMTP id o13-v6so13489950wmf.4 for ; Wed, 06 Jun 2018 12:24:49 -0700 (PDT) X-Gm-Message-State: APt69E2qt/OgD1wQuuWr+Bv1NHLoGTb0knKRbkV2wkz9uJyMw2TQIFAt YPQG+nWqd+p0YO2KzFcPKY+iK71v0ORVIXJ3CyuvZw== X-Received: by 2002:a1c:4a9d:: with SMTP id n29-v6mr2432143wmi.46.1528313088003; Wed, 06 Jun 2018 12:24:48 -0700 (PDT) MIME-Version: 1.0 References: <1528302199-29619-1-git-send-email-chang.seok.bae@intel.com> <1528302199-29619-8-git-send-email-chang.seok.bae@intel.com> In-Reply-To: From: Andy Lutomirski Date: Wed, 6 Jun 2018 12:24:36 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 7/8] x86/segments/32: Introduce CPU_NUMBER segment To: Brian Gerst Cc: Andrew Lutomirski , "Bae, Chang Seok" , "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 Wed, Jun 6, 2018 at 12:07 PM Brian Gerst wrote: > > On Wed, Jun 6, 2018 at 1:16 PM, Andy Lutomirski wrote: > > On Wed, Jun 6, 2018 at 9:23 AM Chang S. Bae wrote: > >> > >> The new entry will be equivalent to that of x86-64 which > >> stores CPU number. The entry is placed in segment 23 in GDT > >> by bumping down 23-28 by one, which are all kernel-internal > >> segments and so have no impact on user space. > >> > >> CPU_NUMBER segment will always be at '%ss (USER_DS) + 80' > >> for the default (flat, initial) user space %ss. > > > > No, it won't :( This is because, on Xen PV, user code very frequently > > sees a different, Xen-supplied "flat" SS value. This is definitely > > true right now on 64-bit, and I'm reasonably confident it's also the > > case on 32-bit. > > > > As it stands, as far as I can tell, we don't have a "cpu number" > > segment on 32-bit kernels. I see no compelling reason to add one, and > > we should definitely not add one as part of the FSGSBASE series. I > > think the right solution is to rename the 64-bit segment to > > "CPU_NUMBER" and then have the rearrangement of the initialization > > code as a followup patch. The goal is to make the patches > > individually reviewable. As it stands, this patch adds some #defines > > without making them work, which is extra confusing. > > > > Given how many times we screwed it up, I really want the patch that > > moves the initialization of the 64-bit CPU number to be obviously > > correct and to avoid changing the sematics of anything except the > > actual CPU number fields during boot. > > > > So NAK to this patch, at least as part of the FSGSBASE series. > > > > (My apologies -- a bunch of this is because I along with everyone else > > misunderstood the existing code.) > > The sole purpose of this segment is for the getcpu() function in the > VDSO. No other userspace code can rely on its presence or location. > Agreed. But this means that no code whatsoever should use it on a 32-bit kernel, so let's not add support.\