Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1031886imm; Wed, 6 Jun 2018 09:25:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIXuB63BhqLtFDiO91V/gmLJC6K9BOHY3SFaGhYig2nYOZmYZOVL5NYs7YF9QAmUJP2q7qI X-Received: by 2002:a17:902:a610:: with SMTP id u16-v6mr3895678plq.195.1528302314682; Wed, 06 Jun 2018 09:25:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528302314; cv=none; d=google.com; s=arc-20160816; b=0XeIkwrmc6BPWxMkLJaQhaTOITv+O68bJMQ5wMIRMIwiWf6qUR2hLEQT1Jd8QcnaWP QSKjaGb1gk/oiHYcOXPXqqJ80hOXbg9Mz6lhV3i5wn5wUoNRcPlwmbJ8/5rP2stNna4J RObB4G9hgZIWnCzI5Rmic70yQ5qd2h9YURfzfjttGmFWaDGbrdGymxIhdq7EVsUX7iR5 HELzX3uBLB6a4CK6NBJp6PiK48j9wRHUBFyUJUW+2R09Jk6fCyB7yQV04AUp/MlQBwDv BzfcH3I1I/9y4riQdtzzK2hkW2/cCeyPYsrE28AHBzlXjyb7ve4miLg77Pizt5pLrGOv T+kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=I/MlyHNcy5szVixpznAoc2L/51/nROAgIAQb2BqCyvg=; b=kgnf4gOMpitlber7tgP0GuHkmXc+IZ+1m6WugdmsJvStd4bET/ukP3tl+4qCN6bEnm iSpPC/Uon9BC/HfVH7gLnoFWqHQeYMcArV/AXM3gHFvmookiSjgqh1UA5rngGlIN9mYp m5SeF/EQM0+uNRpvOKDoYtjaDIiVHO0dp9ZFzEcwqxCjE372B3LgwZiDRZKuvD3PveWj FwUueKOlKikiTXSVAjhh5+WYqjkr08fAQk3vqnGBydEHNc7U4bathDzqoXN6zn/Ej/Oj rsTgPZFTkfMDjjxM0+5SWsauz0xpFg7crh2d/j67MHhTt3fEp+G2UXeoYU/5AvICoK/P fM+w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 67-v6si21618765pgc.64.2018.06.06.09.24.59; Wed, 06 Jun 2018 09:25: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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932945AbeFFQYO (ORCPT + 99 others); Wed, 6 Jun 2018 12:24:14 -0400 Received: from mga17.intel.com ([192.55.52.151]:61010 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753059AbeFFQXe (ORCPT ); Wed, 6 Jun 2018 12:23:34 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2018 09:23:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,483,1520924400"; d="scan'208";a="62323482" Received: from chang-linux-2.sc.intel.com ([10.3.52.139]) by orsmga001.jf.intel.com with ESMTP; 06 Jun 2018 09:23:34 -0700 From: "Chang S. Bae" To: Andy Lutomirski , "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar Cc: Andi Kleen , Dave Hansen , Markus T Metzger , "Ravi V . Shankar" , "Chang S . Bae" , LKML Subject: [PATCH v2 7/8] x86/segments/32: Introduce CPU_NUMBER segment Date: Wed, 6 Jun 2018 09:23:18 -0700 Message-Id: <1528302199-29619-8-git-send-email-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528302199-29619-1-git-send-email-chang.seok.bae@intel.com> References: <1528302199-29619-1-git-send-email-chang.seok.bae@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. %ss is specified than %ds because it is less likely to be changed as 64-bit has %ss defined. Suggested-by: H. Peter Signed-off-by: Chang S. Bae Cc: Andy Lutomirski Cc: Andi Kleen Cc: Dave Hansen Cc: Thomas Gleixner Cc: Ingo Molnar --- arch/x86/include/asm/segment.h | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h index 492e3d1..fca55d7 100644 --- a/arch/x86/include/asm/segment.h +++ b/arch/x86/include/asm/segment.h @@ -77,14 +77,14 @@ * 20 - PNPBIOS support <=== cacheline #6 * 21 - PNPBIOS support * 22 - PNPBIOS support - * 23 - APM BIOS support + * 23 - CPU number * 24 - APM BIOS support <=== cacheline #7 * 25 - APM BIOS support * - * 26 - ESPFIX small SS - * 27 - per-cpu [ offset to per-cpu data area ] - * 28 - stack_canary-20 [ for stack protector ] <=== cacheline #8 - * 29 - unused + * 26 - APM BIOS support + * 27 - ESPFIX small SS + * 28 - per-cpu [ offset to per-cpu data area ] <=== cacheline #8 + * 29 - stack_canary-20 [ for stack protector ] * 30 - unused * 31 - TSS for double fault handler */ @@ -102,11 +102,12 @@ #define GDT_ENTRY_PNPBIOS_DS 20 #define GDT_ENTRY_PNPBIOS_TS1 21 #define GDT_ENTRY_PNPBIOS_TS2 22 -#define GDT_ENTRY_APMBIOS_BASE 23 +#define GDT_ENTRY_CPU_NUMBER 23 +#define GDT_ENTRY_APMBIOS_BASE 24 -#define GDT_ENTRY_ESPFIX_SS 26 -#define GDT_ENTRY_PERCPU 27 -#define GDT_ENTRY_STACK_CANARY 28 +#define GDT_ENTRY_ESPFIX_SS 27 +#define GDT_ENTRY_PERCPU 28 +#define GDT_ENTRY_STACK_CANARY 29 #define GDT_ENTRY_DOUBLEFAULT_TSS 31 @@ -140,6 +141,13 @@ /* another data segment: */ #define PNP_TS2 (GDT_ENTRY_PNPBIOS_TS2*8) +/* + * CPU_NUMBER segment is at '%ss + 80' for the default (flat, initial) + * user space %ss (for 64-bit as well). Using %ss than %ds for less + * likely to be changed as defined in 64-bit too. + */ +#define __CPU_NUMBER_SEG (GDT_ENTRY_CPU_NUMBER*8 + 3) + #ifdef CONFIG_SMP # define __KERNEL_PERCPU (GDT_ENTRY_PERCPU*8) #else @@ -206,6 +214,10 @@ #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8 + 3) #define __USER32_DS __USER_DS #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8 + 3) +/* + * CPU_NUMBER segment at '%ss (USER_DS) + 80', + * like 32-bit for the same reason + */ #define __CPU_NUMBER_SEG (GDT_ENTRY_CPU_NUMBER*8 + 3) #endif -- 2.7.4