From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S940087AbdAJRJp (ORCPT ); Tue, 10 Jan 2017 12:09:45 -0500 Received: from mx2.suse.de ([195.135.220.15]:33391 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937000AbdAJRJn (ORCPT ); Tue, 10 Jan 2017 12:09:43 -0500 Date: Tue, 10 Jan 2017 18:09:36 +0100 From: Borislav Petkov To: hpa@zytor.com Cc: linux-tip-commits@vger.kernel.org, tip-bot for Borislav Petkov , mingo@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de Subject: Re: [tip:x86/urgent] x86/CPU: Add native CPUID variants returning a single datum Message-ID: <20170110170936.uvdgvfqr5j5c4ntu@pd.tnic> References: <20170109114147.5082-2-bp@alien8.de> <9724A6CA-1F64-4B4D-BAE4-4116FCE7838D@zytor.com> <20170110090415.46htye4aczidzvh2@pd.tnic> <691CAE2B-2FDC-44CA-8731-D70C91E94320@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <691CAE2B-2FDC-44CA-8731-D70C91E94320@zytor.com> User-Agent: NeoMutt/20161014 (1.7.1) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 10, 2017 at 08:40:39AM -0800, hpa@zytor.com wrote: > You are introducing a new API; makes more sense to do it right from > the start. The only reason not to have a subleaf for the non-native > variants is that they may decay into a function call so there is an > extra cost. The "do it right" is what I'm not sure of. Do you see any use cases for the subleaf != 0 *native* variant at all? Most if not all users of native_cpuid() in the tree set ecx to 0. > C doesn't allow function name overloading ;) (Well, except the C11 > type hacks; to the best of my knowledge that doesn't in any way > support argument *count* overloading.) Grr, I forgot to change the function name. I didn't mean that. >>From looking at it again, what I mean would be ugly too :-) I guess *if* the need arises - and again, I'm really sceptical about it - we should simply add the respective native version of cpuid_count(): /* Some CPUID calls want 'count' to be placed in ecx */ static inline void native_cpuid_count(unsigned int op, int count, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { *eax = op; *ecx = count; native_cpuid(eax, ebx, ecx, edx); } Because this way you have both native and non-native versions nicely comparable wrt arguments and retvals. And there won't be any confusion wrt to "oh, the native version takes different args". This was my main intent wrt the native_cpuid_() versions - to be consistent with the cpuid_() ones. -- Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) --