Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp717399imm; Tue, 5 Jun 2018 03:23:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJDQ9Vj6Yzt7UI9Wqh7p+9fUAkKdMrexCO1Q+1T8eUVTZp0s6KkTXDsbpB7xOnahy9tCIh7 X-Received: by 2002:a17:902:5ac8:: with SMTP id g8-v6mr20063517plm.221.1528194197159; Tue, 05 Jun 2018 03:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528194197; cv=none; d=google.com; s=arc-20160816; b=IdVh94j7yRfdl3zzahKIzYVWr9zn3cCiXiigw5T2zIJ4TSmTmkUG2m9clSc4vzWWbz k8lPULj3TjUOefYwkUzqsIfgG3hVHqsFobG0IPG1MMdkUTv+m4ZQoXTMZUUhmsOn6IxK QdQ63xOc6FGL59lMtfYruk+0sstwoniYgOs/+e3wTIz1p+0Yyb3NNBq70EWhM/eAN29X Sd31lXhiNdFBE/JjxMCrYlljhWNpitfReIzniRrt/Om55fb7N+yO3cvbRtsO9WkgEjYg eC4pYzZ7Lq6+1vbBhERh9nHSVy6BbqmQoiL/TsHEnKeQiarHj8pabGnjj0tAwISJjC00 jQsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature:arc-authentication-results; bh=GSdLhg6OPFzO1G3J2klJ3HDKW3O2bKufi1Zo0MQ6D74=; b=DMVY4BKq1zUeXSrco220P3KLyKxF0JvhnQj7tDeujH46zXwymjZ8VT0bDCsYYMkSlp sq3srCfatfFMEdAVejbscOKfPiBlWly6IxwcFfytTOk2wkv611Dh1NSM7pq4z8e4nIyM 4zee97sWtVtSgnrMdZjGigTPvHq6P7l2sJcKjDPQ9ieFblTqE+N5E4Bswr6uUI0Zb942 vSSZcuCgU5LqW/r0Al2QmU7yuO92Qp2QOIDCL2Cq/92Jxh3tHAQK/KINGQhe/ArKijrO cq+f2G7Jv8SrDKTHU6MHCfU6QnQeMN/U+S2fQvAts/XtUBb8fCc9ArRmYnreJLTkPUg2 XcQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Wy6eeQyE; 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 z14-v6si10653659pgz.264.2018.06.05.03.23.02; Tue, 05 Jun 2018 03:23:17 -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=Wy6eeQyE; 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 S1751619AbeFEKWi (ORCPT + 99 others); Tue, 5 Jun 2018 06:22:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:58256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751442AbeFEKWh (ORCPT ); Tue, 5 Jun 2018 06:22:37 -0400 Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com [209.85.128.181]) (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 102BF20896 for ; Tue, 5 Jun 2018 10:22:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528194157; bh=M91D/nn1nb5OU9eVJAiLJ7Hkt8rHtEIsWsP5BZBbEBE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Wy6eeQyEq93ZcHP4/IOmnbbnXR0dR9LcCiQ3A5JwnZ6EXaPUdX6rG9FhZ9+21MOhO fjKgNDStfKtv0HH15GHoXfvqznnPVLE2mBEQr1tBikoAI7FOPjRHOiCCNnR5ooykuq xIxL7e43JsasieVNibJflG0jxrC/yqzKOF9A9BVo= Received: by mail-wr0-f181.google.com with SMTP id f16-v6so1800541wrm.3 for ; Tue, 05 Jun 2018 03:22:36 -0700 (PDT) X-Gm-Message-State: ALKqPwdnl+VJF4n5bKjsu/pf98SvOtPRVbKyHsgyM53D2oii1wO3Oldo /UsYrpS5RvMayfAxpHqvNWZaag3eJ2zAGvlxCBwLmg== X-Received: by 2002:adf:85ec:: with SMTP id 41-v6mr19119630wru.120.1528194155463; Tue, 05 Jun 2018 03:22:35 -0700 (PDT) MIME-Version: 1.0 References: <1528140269-26205-1-git-send-email-chang.seok.bae@intel.com> <1528140269-26205-7-git-send-email-chang.seok.bae@intel.com> <8a41304a-3517-003a-badf-1ba8f7ababe4@nextfour.com> <51587908-9652-6a8e-0e01-f387e3ae5852@zytor.com> In-Reply-To: <51587908-9652-6a8e-0e01-f387e3ae5852@zytor.com> From: Andy Lutomirski Date: Tue, 5 Jun 2018 03:22:22 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 6/6] x86/vdso: Move out the CPU number store To: "H. Peter Anvin" Cc: =?UTF-8?Q?Mika_Penttil=C3=A4?= , "Bae, Chang Seok" , Andrew Lutomirski , Thomas Gleixner , Ingo Molnar , Andi Kleen , Dave Hansen , "Metzger, Markus T" , "Ravi V. Shankar" , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 4, 2018 at 10:36 PM H. Peter Anvin wrote: > > On 06/04/18 20:57, Mika Penttil=C3=A4 wrote: > > > > This won't work on X86-32 because it actually uses the segment limit wi= th fs: access. So there > > is a reason why the lsl based method is X86-64 only. > > > > > > Why does that matter in any shape, way, or form? The LSL instruction > doesn't touch any of the segment registers, it just uses a segment > selector number. > > > > I see... we have a VERY unfortunate name collision: the x86-64 > GDT_ENTRY_PERC_PU and the i386 GDT_ENTRY_PERCPU are in fact two > completely different things, with the latter being the actual percpu > offset used by the kernel. > > So yes, this patch is wrong, because the naming of the x86-64 segment is > insane especially in the proximity of the -- it should be something > like GDT_ENTRY_CPU_NUMBER. > > Unfortunately we probably can't use the same GDT entry on x86-32 and > x86-64, because entry 15 (selector 0x7b) is USER_DS, which is something > we really don't want to screw with. This means i386 programs that > execute LSL directly for whatever reason will have to understand the > difference, but most of the other segment numbers differ as well, > including user space %cs (USER_CS/USER32_CS) and %ds/%es/%ss (USER_DS). > Perhaps we could bump down segments 23-28 by one and put it as 23, that > way the CPU_NUMBER segment would always be at %ss+80 for the default > (flat, initial) user space %ss. (We want to specify using %ss rather > than %ds, because it is less likely to be changed and because 64 bits, > too, have %ss defined, but not %ds.) > > > > Rename the x86-64 segment to CPU_NUMBER, fixing the naming conflict. Yes, agreed. Probably as its own patch *before* the rest of this cleanup. > Add 1 to GDT entry numbers 23-28 for i386 (all of these are > kernel-internal segments and so have no impact on user space). > Add i386 CPU_NUMBER equivalent to x86-64 at GDT entry 23. > Document the above relationship between segments. Sure, but also as a standalone patch, please. > > OK, everyone? > > -hpa