From patchwork Mon Feb 22 21:02:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 8383371 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E17D49F7C9 for ; Mon, 22 Feb 2016 21:05:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E8479205D1 for ; Mon, 22 Feb 2016 21:05:43 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EB0EE205CA for ; Mon, 22 Feb 2016 21:05:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aXxcy-00010q-2i; Mon, 22 Feb 2016 21:02:44 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aXxcw-00010l-Qm for xen-devel@lists.xen.org; Mon, 22 Feb 2016 21:02:42 +0000 Received: from [85.158.137.68] by server-15.bemta-3.messagelabs.com id CA/99-03172-1777BC65; Mon, 22 Feb 2016 21:02:41 +0000 X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1456174959!24158460!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13057 invoked from network); 22 Feb 2016 21:02:41 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-12.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 22 Feb 2016 21:02:41 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u1ML2bk1004217 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Feb 2016 21:02:37 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u1ML2apa008786 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 22 Feb 2016 21:02:37 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u1ML2and027172; Mon, 22 Feb 2016 21:02:36 GMT Received: from localhost.localdomain (/89.181.88.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 22 Feb 2016 13:02:36 -0800 From: Joao Martins To: xen-devel@lists.xen.org Date: Mon, 22 Feb 2016 21:02:07 +0000 Message-Id: <1456174934-22973-2-git-send-email-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456174934-22973-1-git-send-email-joao.m.martins@oracle.com> References: <1456174934-22973-1-git-send-email-joao.m.martins@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Cc: Wei Liu , Ian Campbell , Stefano Stabellini , Andrew Cooper , Ian Jackson , Jan Beulich , Keir Fraser , Joao Martins Subject: [Xen-devel] [PATCH RFC 1/8] x86/hvm: set initial apicid to vcpu_id X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the initial_apicid is set vcpu_id * 2 which makes it difficult for the toolstack to manage how is the topology seen by the guest. Instead of forcing procpkg and proccount to be VCPUID * 2, instead we set it to max vcpuid on proccount to max_vcpu_id + 1 (logical number of logical cores) and procpkg to max_vcpu_id (max cores minus 1) Signed-off-by: Joao Martins --- CC: Ian Jackson CC: Stefano Stabellini CC: Ian Campbell CC: Wei Liu CC: Keir Fraser CC: Jan Beulich CC: Andrew Cooper --- tools/libxc/xc_cpuid_x86.c | 18 +++++++++++++----- xen/arch/x86/hvm/hvm.c | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c index c142595..aa1d679 100644 --- a/tools/libxc/xc_cpuid_x86.c +++ b/tools/libxc/xc_cpuid_x86.c @@ -45,6 +45,7 @@ struct cpuid_domain_info bool hvm; bool pvh; uint64_t xfeature_mask; + uint32_t max_vcpu_id; /* PV-only information. */ bool pv64; @@ -102,6 +103,7 @@ static int get_cpuid_domain_info(xc_interface *xch, domid_t domid, info->hvm = di.hvm; info->pvh = di.pvh; + info->max_vcpu_id = di.max_vcpu_id; /* Get xstate information. */ domctl.cmd = XEN_DOMCTL_getvcpuextstate; @@ -245,10 +247,16 @@ static void intel_xc_cpuid_policy(xc_interface *xch, case 0x00000004: /* * EAX[31:26] is Maximum Cores Per Package (minus one). - * Update to reflect vLAPIC_ID = vCPU_ID * 2. */ - regs[0] = (((regs[0] & 0x7c000000u) << 1) | 0x04000000u | - (regs[0] & 0x3ffu)); + { + unsigned int procpkg = 0; + if ( info->hvm ) + procpkg = info->max_vcpu_id << 26; + else + procpkg = (regs[0] & 0x7c000000u) << 1; + + regs[0] = (procpkg | 0x04000000u | (regs[0] & 0x3ffu)); + } regs[3] &= 0x3ffu; break; @@ -353,9 +361,9 @@ static void xc_cpuid_hvm_policy(xc_interface *xch, case 0x00000001: /* * EBX[23:16] is Maximum Logical Processors Per Package. - * Update to reflect vLAPIC_ID = vCPU_ID * 2. */ - regs[1] = (regs[1] & 0x0000ffffu) | ((regs[1] & 0x007f0000u) << 1); + regs[1] = (regs[1] & 0x0000ffffu) | + (((info->max_vcpu_id + 1) << 16)); regs[2] &= (bitmaskof(X86_FEATURE_XMM3) | bitmaskof(X86_FEATURE_PCLMULQDQ) | diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index fe382ce..d45e7a9 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4633,7 +4633,7 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx, case 0x1: /* Fix up VLAPIC details. */ *ebx &= 0x00FFFFFFu; - *ebx |= (v->vcpu_id * 2) << 24; + *ebx |= (v->vcpu_id) << 24; if ( vlapic_hw_disabled(vcpu_vlapic(v)) ) __clear_bit(X86_FEATURE_APIC & 31, edx);