Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3023726img; Mon, 25 Mar 2019 02:04:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxg/n1z+hITt1OTCldEUJ+jB/6Sh9iRp0vRHRx98LaUINFOTowrOKfJ+IZubIV7tqeggqGY X-Received: by 2002:aa7:928d:: with SMTP id j13mr23373030pfa.112.1553504659804; Mon, 25 Mar 2019 02:04:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553504659; cv=none; d=google.com; s=arc-20160816; b=onRmVYiaKh+1VWO0eTiqb9pjNri8Q4I5oG2ejGC1gP0tm4s1PywCswqkom9e05ZIC1 03zWWLZTyO5Msb0Y60z+nOSDe8MskYtc6yktMvRsI7iANK8Ow1ZR5y2KsEQFgPporbAZ kzLeZP244tvgbZ2tpkHt56zQGQzgJ6aH32cOEy5J7Qn6wGBy8QMq2CotB/4JKJ2KWKU3 t1E5FTKj68ebagDucvk7YnxcizBi+nNOZpWNBQOkW0gJrRiUWerT86L9nRqKkVBPEY2/ b5cjmABFjHEEd8K/i2sqw4eXDpKzmJFsqzzM2L6EvdnG0PhyV82rYeSPdZC4ysYzD9zH 6onw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=TstzsaPdOryx7RZrnd2P85WDKZh/r6dLp7B+xKPrnS8=; b=gqOCMW3Loy3Lu4A7ZnJbfMxVSMxWPHnh5n6hfiuHxdseEtqnz+aqook2c05qFNUsAL FE8Kc4notNLYGV9ryHlrzERuq6ttcwZRtM+JUCdhd3rClvuOtD8qmMPOs4FlVvo8549U /F5Mc7LclEgvHXGL6zhfJsfqE0SCL0NhGVSIxvf2eDbcBxKWX2KCIOj8m/zouURnSzZi 4eTV6nboEG1v1PcuposHNQceENYP0YMGBuTK/q0nJe49XXsWKy8QHJJvGNgKos79oCqK tUZi77Dq/F/rLIL3WrnzTsbfvMSc83ZVGx7br6zjHVsZDxqHvT2Ai2Gm+bKkM0+sqFCF 8LUg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8si12901294pgq.424.2019.03.25.02.04.04; Mon, 25 Mar 2019 02:04:19 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730115AbfCYJCq (ORCPT + 99 others); Mon, 25 Mar 2019 05:02:46 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:45037 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726234AbfCYJCp (ORCPT ); Mon, 25 Mar 2019 05:02:45 -0400 Received: from p5492e2fc.dip0.t-ipconnect.de ([84.146.226.252] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1h8LV5-0005pu-PN; Mon, 25 Mar 2019 10:02:35 +0100 Date: Mon, 25 Mar 2019 10:02:35 +0100 (CET) From: Thomas Gleixner To: "Chang S. Bae" cc: Ingo Molnar , Andy Lutomirski , "H . Peter Anvin" , Andi Kleen , Ravi Shankar , LKML , Dave Hansen Subject: Re: [RESEND PATCH v6 07/12] x86/fsgsbase/64: Introduce the FIND_PERCPU_BASE macro In-Reply-To: <1552680405-5265-8-git-send-email-chang.seok.bae@intel.com> Message-ID: References: <1552680405-5265-1-git-send-email-chang.seok.bae@intel.com> <1552680405-5265-8-git-send-email-chang.seok.bae@intel.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 15 Mar 2019, Chang S. Bae wrote: > GSBASE is used to find per-CPU data in the kernel. It's not used to find per cpu data. per cpu data access is using GS based addressing. > But when it is unknown, What is unknown? > the per-CPU base can be found from the per_cpu_offset table with a CPU NR. > The CPU NR is extracted from the limit field of the CPUNODE entry in GDT, > or by the RDPID instruction. > > Also, add the GAS-compatible RDPID macro. > > The new macro will be used on a following patch. So this is yet another changelog which describes the WHAT and not the WHY and lacks any form of sensible context. > diff --git a/arch/x86/include/asm/fsgsbase.h b/arch/x86/include/asm/fsgsbase.h > index aefd53767a5d..5e3dfbe8c1bf 100644 > --- a/arch/x86/include/asm/fsgsbase.h > +++ b/arch/x86/include/asm/fsgsbase.h > @@ -78,6 +78,47 @@ extern void x86_gsbase_write_cpu_inactive(unsigned long gsbase); > > #endif /* CONFIG_X86_64 */ > > +#else /* __ASSEMBLY__ */ > + > +#ifdef CONFIG_X86_64 > + > +#include Is there are good reason why this ASM MACRO maze needs to be in a global visible header. AFAICT this is only used in the entry code. So why can't it be added to the other entry code macros in calling.h or some other sensible place? > +#ifdef CONFIG_SMP > + > +/* > + * CPU/node NR is loaded from the limit (size) field of a special segment > + * descriptor entry in GDT. > + */ > +.macro LOAD_CPU_AND_NODE_SEG_LIMIT reg:req > + movq $__CPUNODE_SEG, \reg > + lsl \reg, \reg > +.endm > + > +/* > + * Fetch the per-CPU GSBASE value for this processor and put it in @reg. > + * We normally use %gs for accessing per-CPU data, but we are setting up > + * %gs here and obviously can not use %gs itself to access per-CPU data. > + */ > +.macro FIND_PERCPU_BASE reg:req This is a complete misnomer. It's not searching for the per cpu base, it's retrieving the per cpu base from a known place. So something like GET_PERCPU_BASE would be appropriate. > + ALTERNATIVE \ > + "LOAD_CPU_AND_NODE_SEG_LIMIT \reg", \ > + "RDPID \reg", \ > + X86_FEATURE_RDPID > + andq $VDSO_CPUNODE_MASK, \reg > + movq __per_cpu_offset(, \reg, 8), \reg > +.endm > diff --git a/arch/x86/include/asm/inst.h b/arch/x86/include/asm/inst.h > index f5a796da07f8..d063841a17e3 100644 > --- a/arch/x86/include/asm/inst.h > +++ b/arch/x86/include/asm/inst.h > @@ -306,6 +306,21 @@ > .endif > MODRM 0xc0 movq_r64_xmm_opd1 movq_r64_xmm_opd2 > .endm > + > +.macro RDPID opd So the update to require binutils >= 2.21 does not cover RDPID? Thanks, tglx