Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1092657imm; Wed, 6 Jun 2018 10:17:09 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKRd4O3KuUKnWm8D+Hegz/Pov1IpYqMW+HIXVEIeKkhCWCBl9LWhNIPsMjS44U4CgVsQX46 X-Received: by 2002:a62:cc51:: with SMTP id a78-v6mr3256836pfg.219.1528305429313; Wed, 06 Jun 2018 10:17:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528305429; cv=none; d=google.com; s=arc-20160816; b=kLn6OyXUPmMBlkQ1J6Cl5PpJdc6Y5QMduBR0puRHdi75KHO7zhq5k6aDFKDOBQSJOt CpIu5u8JSMfeb123cYK4+qKTElqPZbXl4esIWvsC/dLz8l+lvWqKY8CZDoMPmcTaPt1M 6aErRi583ZG6g64MRT4RU5/53YK+93XLSrSau72FgAfH94/bp69iS/f4tVHh70+HroAq ZmygaYDxp0d/Lcpu/QG1P29ffUhypDIybZpaLBB9DywJEHZF13/8Jmle+CdPLiyhB+SM AStkB5R6TlJtVGqqKcpFqNiF20YgjlXlI2lrgPMHzC4ajioonIcxxVZsXr39MrUyIgEk qEZQ== 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=7OBSW6PhTy7BKmSfA20DULoKMw4xK5K3/T3zgFeA4WI=; b=EBobZ6d4afWeDlmI88lv1sHAh3Chzi5yMhig7T24Hj/NLyESuN5PpDwkFc0QSTOxbN 79xqkoC4yaBX2A/SyEhsGUGSj6x/oeHWmxuxpdHm4KjPiHoezzPtn1FdmjScapGGLtwE RZs3ViJ0qftoaTshYD7GYlNSwHLfqE0xYJKwXx+0Uv6F82sIU5JJGVPijbXei7+McPSf 7Q1ioE5T6n5MJKM0tDToG/CfBCSC6aIU1VxT8SNifKQXM8BNdLJDjV1fyByK5a/NfAy9 DkN/PC3efGXoVFGDwDd8RmVfescKCztGD/r+XD3gkrRBf6wlhqdXauCbDJQPfj7x7YSo lZIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=h3JwYInz; 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 32-v6si28442059ple.447.2018.06.06.10.16.54; Wed, 06 Jun 2018 10:17:09 -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=h3JwYInz; 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 S1753753AbeFFRQ3 (ORCPT + 99 others); Wed, 6 Jun 2018 13:16:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:50486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752330AbeFFRQ2 (ORCPT ); Wed, 6 Jun 2018 13:16:28 -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 7C24E2087F for ; Wed, 6 Jun 2018 17:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528305387; bh=dBDVfElBgwOVi3ylYChq8aADXZL1W9KZwULHTIdzO+g=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=h3JwYInzBKWNRSDSFSlfjgZuDYld3TS+OfJoBtGSDkgYrAY84d/tev0X59U2qBir6 DKKGGoMgcrF57NsmJ8GzgA+21OHwtcX1ox7Jn+vdq9lqTY53Yase5mbOjEo6fr34gi EAoTC122jt6RgEM2YCa/v036/Z4v7/YlREx6L1Qs= Received: by mail-wm0-f45.google.com with SMTP id v131-v6so13489922wma.1 for ; Wed, 06 Jun 2018 10:16:27 -0700 (PDT) X-Gm-Message-State: APt69E3+BmoPoyPq8xcMMp9CEZ/d7CdT8A4vtBv5nMycSmrLGNa79AIA 6b++QxiowcO1Gt2yjIA/45AKi4fm+8YqGnTLJVRSoA== X-Received: by 2002:a1c:b947:: with SMTP id j68-v6mr2252530wmf.144.1528305386010; Wed, 06 Jun 2018 10:16:26 -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: <1528302199-29619-8-git-send-email-chang.seok.bae@intel.com> From: Andy Lutomirski Date: Wed, 6 Jun 2018 10:16:14 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 7/8] x86/segments/32: Introduce CPU_NUMBER segment 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 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.)