Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1167888AbcKAHtm (ORCPT ); Tue, 1 Nov 2016 03:49:42 -0400 Received: from mga06.intel.com ([134.134.136.31]:1833 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1167783AbcKAHtk (ORCPT ); Tue, 1 Nov 2016 03:49:40 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,579,1473145200"; d="scan'208";a="186214546" Date: Tue, 1 Nov 2016 15:48:50 +0800 From: He Chen To: Paolo Bonzini Cc: Borislav Petkov , "Luc, Piotr" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "tglx@linutronix.de" , "x86@kernel.org" , "hpa@zytor.com" , "mingo@redhat.com" , "Kang, Luwei" , "rkrcmar@redhat.com" Subject: Re: [PATCH] x86/cpuid: expose AVX512_4VNNIW and AVX512_4FMAPS features to kvm guest Message-ID: <20161101074850.GA11430@he> References: <20161028122123.24i3synevehn6r3p@pd.tnic> <425702906.9319122.1477743677017.JavaMail.zimbra@redhat.com> <1477905033.32008.5.camel@intel.com> <20161031095312.dzv3rj2fqgjjsy7w@pd.tnic> <1477908811.32008.20.camel@intel.com> <20161031103050.k7b2l64blhmv33mw@pd.tnic> <48ef617f-c438-cfcf-6f0c-1eb3b59820ff@redhat.com> <20161031110549.ukajhnawxw6mftor@pd.tnic> <6cb0bdc3-69f6-1c17-5576-82fbe42e5457@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6cb0bdc3-69f6-1c17-5576-82fbe42e5457@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1257 Lines: 48 On Mon, Oct 31, 2016 at 12:41:32PM +0100, Paolo Bonzini wrote: > > > On 31/10/2016 12:05, Borislav Petkov wrote: > > On Mon, Oct 31, 2016 at 11:47:48AM +0100, Paolo Bonzini wrote: > >> The information is all in arch/x86/kernel/cpu/scattered.c's cpuid_bits > >> array. Borislav, would it be okay to export the cpuid_regs enum? > > > > Yeah, and kill the duplicated one in arch/x86/events/intel/pt.c too > > please, while at it. > > > > I'd still put it all in arch/x86/kernel/cpu/scattered.c so that it is > > close-by and call it from outside. > > Good. Chen, are you going to do this? > Sure. Before sending a patch, let me check if my understanding is right... I will add a helper in scattered.c like: unsigned int get_scattered_cpuid_features(unsigned int level, unsigned int sub_leaf, enum cpuid_regs reg) { u32 val = 0; const struct cpuid_bit *cb; for (cb = cpuid_bits; cb->feature; cb++) { if (reg == cb->reg && level == cb->level && sub_leaf == cb->sub_leaf && boot_cpu_has(cb->feature)) val |= cb->bit; } return val; } And, when KVM wants to mask out features, it can be called outside like: entry->edx &= kvm_cpuid_7_0_edx_x86_features; entry->edx &= get_scatterd_cpuid_features(7, 0, CR_EDX); Thanks, -He