From patchwork Mon May 16 16:59:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9104751 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 C1EDC9F1D3 for ; Mon, 16 May 2016 17:02:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 02AC12025A for ; Mon, 16 May 2016 17:02:06 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 244B3202A1 for ; Mon, 16 May 2016 17:02:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b2Lrr-0000wq-Rh; Mon, 16 May 2016 16:59:43 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b2Lrq-0000wk-Rw for xen-devel@lists.xen.org; Mon, 16 May 2016 16:59:42 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 8F/B7-18833-E7CF9375; Mon, 16 May 2016 16:59:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsXitHSDvW7tH8t wg1dPdC2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ox9C++wFUzhr/jS28nWwLiFp4uRk0NCwF9i U1sXM4jNJqAvsfvFJyYQW0RAXeJ0x0VWEJtZIE+i8+NHdhBbWMBH4uDKBWBxFgFViWNn14LV8 wp4SMyY08QCMVNO4vzxn2AzhQTUJK71X2KHqBGUODnzCQvETAmJgy9eMEPUc0vcPj2VeQIjzy wkZbOQlC1gZFrFqF6cWlSWWqRrpJdUlJmeUZKbmJmja2hgppebWlycmJ6ak5hUrJecn7uJERg iDECwg3HZX6dDjJIcTEqivDHfLcOF+JLyUyozEosz4otKc1KLDzHKcHAoSfCW/AbKCRalpqdW pGXmAIMVJi3BwaMkwlsJkuYtLkjMLc5Mh0idYlSUEud1BEkIgCQySvPg2mARcolRVkqYlxHoE CGegtSi3MwSVPlXjOIcjErCvE0gU3gy80rgpr8CWswEtHiCmQXI4pJEhJRUA2OW2FJDFvVNu8 ViVBa/uuH2aanfXPaTyw2DYw12tuwSmJaS1hF732COVl48w82LbU+X/2HScjpw488Cs9Vdmz8 tEHTW2aj1q6l0bZfUtZf3GW/M+cXdzDTHSb/kRnwQS4mv7+FDLnIaF/aWhgvIcJjpbdl2Xjg4 v7Xe1PpPiITWP2FG+0+q1kosxRmJhlrMRcWJADXEzkWLAgAA X-Env-Sender: prvs=937ea055c=Andrew.Cooper3@citrix.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1463417979!14373470!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30141 invoked from network); 16 May 2016 16:59:41 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-14.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 16 May 2016 16:59:41 -0000 X-IronPort-AV: E=Sophos;i="5.24,627,1454976000"; d="scan'208";a="361306370" From: Andrew Cooper To: Xen-devel Date: Mon, 16 May 2016 17:59:15 +0100 Message-ID: <1463417955-4258-1-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-DLP: MIA2 Cc: Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH] x86/cpuid: Avoid unconditionally clobbering ITSC for guests X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" 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 In general, Invariant TSC is not a feature which can be advertised to guests, because it cannot be guaranteed across migrate. domain_cpuid() goes so far as to deliberately clobber the feature flag under a number of circumstances. Because ITSC is absent from the static {pv,hvm}_featureset masks, c/s b648feff "xen/x86: Improvements to in-hypervisor cpuid sanity checks" caused ITSC to be unconditionally masked out. As an interim solution, include the hosts idea of ITSC along with the static {pv,hvm}_featureset when restricting the guests view of features. This causes the hardware domain, and VMs explicitly configured with ITSC and no-migrate to be offered ITSC (subject to hardware availability). Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu --- xen/arch/x86/hvm/hvm.c | 3 ++- xen/arch/x86/traps.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 7492030..5040a5c 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -3509,7 +3509,8 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx, break; case 0x80000007: - *edx &= hvm_featureset[FEATURESET_e7d]; + *edx &= (hvm_featureset[FEATURESET_e7d] | + (host_featureset[FEATURESET_e7d] & cpufeat_mask(X86_FEATURE_ITSC))); break; case 0x80000008: diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 0052ab8..1ef8401 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1142,7 +1142,8 @@ void pv_cpuid(struct cpu_user_regs *regs) break; case 0x80000007: - d &= pv_featureset[FEATURESET_e7d]; + d &= (pv_featureset[FEATURESET_e7d] | + (host_featureset[FEATURESET_e7d] & cpufeat_mask(X86_FEATURE_ITSC))); break; case 0x80000008: