From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Ostrovsky Subject: [PATCH v6 1/4] xen/libxc: Allow changing max number of hypervisor cpuid leaves Date: Thu, 20 Mar 2014 23:51:48 -0400 Message-ID: <1395373911-4268-2-git-send-email-boris.ostrovsky@oracle.com> References: <1395373911-4268-1-git-send-email-boris.ostrovsky@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1395373911-4268-1-git-send-email-boris.ostrovsky@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: jbeulich@suse.com, keir@xen.org, jun.nakajima@intel.com, eddie.dong@intel.com, ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com Cc: yang.z.zhang@intel.com, andrew.cooper3@citrix.com, boris.ostrovsky@oracle.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Add support for changing max number of hypervisor leaves from configuration file. This number can be specified using xl's standard 'cpuid' option. Only lowest 8 bits of leaf's 0x40000x00 eax register are processed, all others are ignored. Signed-off-by: Boris Ostrovsky --- tools/libxc/xc_cpuid_x86.c | 11 +++++++++++ xen/arch/x86/traps.c | 18 ++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c index bbbf9b8..21ba68b 100644 --- a/tools/libxc/xc_cpuid_x86.c +++ b/tools/libxc/xc_cpuid_x86.c @@ -555,6 +555,17 @@ static int xc_cpuid_policy( { xc_dominfo_t info; + /* + * For hypervisor leaves (0x4000XXXX) only 0x40000x00.EAX[7:0] bits (max + * number of leaves) can be set by user. Hypervisor will enforce this so + * all other bits are don't-care and we can set them to zero. + */ + if ( (input[0] & 0xffff0000) == 0x40000000 ) + { + regs[0] = regs[1] = regs[2] = regs[3] = 0; + return 0; + } + if ( xc_domain_getinfo(xch, domid, 1, &info) == 0 ) return -EINVAL; diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index c462317..65c34f3 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -677,15 +677,21 @@ int cpuid_hypervisor_leaves( uint32_t idx, uint32_t sub_idx, struct domain *d = current->domain; /* Optionally shift out of the way of Viridian architectural leaves. */ uint32_t base = is_viridian_domain(d) ? 0x40000100 : 0x40000000; - uint32_t limit; + uint32_t limit, dummy; idx -= base; + if ( idx > 3 ) + return 0; /* Avoid unnecessary pass through domain_cpuid() */ - /* - * Some Solaris PV drivers fail if max > base + 2. Help them out by - * hiding the PVRDTSCP leaf if PVRDTSCP is disabled. - */ - limit = (d->arch.tsc_mode < TSC_MODE_PVRDTSCP) ? 2 : 3; + /* Number of leaves may be user-specified */ + domain_cpuid(d, base, 0, &limit, &dummy, &dummy, &dummy); + limit &= 0xff; + if ( (limit < 2) || (limit > 3) ) + /* + * Some Solaris PV drivers fail if max > base + 2. Help them out by + * hiding the PVRDTSCP leaf if PVRDTSCP is disabled. + */ + limit = (d->arch.tsc_mode < TSC_MODE_PVRDTSCP) ? 2 : 3; if ( idx > limit ) return 0; -- 1.7.10.4