From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id 9F60A4C6E for ; Thu, 20 Mar 2014 12:01:58 +0100 (CET) Received: from hmsreliant.think-freely.org ([2001:470:8:a08:7aac:c0ff:fec2:933b] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1WQaku-0004WQ-P2; Thu, 20 Mar 2014 07:03:27 -0400 Date: Thu, 20 Mar 2014 07:03:23 -0400 From: Neil Horman To: "H. Peter Anvin" Message-ID: <20140320110323.GA7721@hmsreliant.think-freely.org> References: <1395175414-25232-1-git-send-email-nhorman@tuxdriver.com> <1395240524-412-1-git-send-email-nhorman@tuxdriver.com> <5329BB6E.8080509@zytor.com> <20140320004010.GA20693@neilslaptop.think-freely.org> <532A6CEB.1070106@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <532A6CEB.1070106@zytor.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -2.9 (--) X-Spam-Status: No Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v2] eal: fix up bad asm in rte_cpu_get_features X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Mar 2014 11:01:58 -0000 On Wed, Mar 19, 2014 at 09:22:03PM -0700, H. Peter Anvin wrote: > On 03/19/2014 05:40 PM, Neil Horman wrote: > > So after some discussion with hpa, I need to self NAK this again, apologies for > > the noise. Theres some clean up to be done in this area, and I'm still getting > > a segfault that is in some way related to this code, but I need to dig deeper to > > understand it. > > > > Neil > > I still believe we should add the patch I posted in the previous email; > I should clean it up and put a proper header on it. > I agree, but the fact of the matter is that I'm still getting a segfault very close to these instructions and I dont' understand why yet. I'd hate to just make the problem go away without understanding the reason why. The patch you propose doesn't fix (yet moving the xchgl to its own asm statement does). > This is, if there is actually a need to feed %ebx and %edx into CPUID > (the native instruction is sensitive to %eax and %ecx, but not %ebx or > %edx.) > > For reference, this is a version of CPUID I personally often use: > > struct cpuid { > unsigned int eax, ecx, edx, ebx; > }; > > static inline void cpuid(unsigned int leaf, unsigned int subleaf, > struct cpuid *out) > { > #if defined(__i386__) && defined(__PIC__) So, this is an additional difference and this in fact does make the problem clear up. By applying only this patch: @@ -192,7 +192,7 @@ rte_cpu_get_features(struct cpuid_parameters_t params) { int eax, ebx, ecx, edx; /* registers */ -#ifndef __PIC__ +#if !defined(__PIC__) || !defined(__i386__) asm volatile ("cpuid" /* output */ : "=a" (eax), my build compiles the cpuid instruction branch, not the mov;cpuid; xchgl branch (its an x86_64 build). Is there any reason that x86_64 doesn't need to save the ebx register when running cpuid while building PIE code? Neil