From patchwork Tue Feb 23 11:05:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Vrabel X-Patchwork-Id: 8390821 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C23CAC0554 for ; Tue, 23 Feb 2016 11:08:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C98802034F for ; Tue, 23 Feb 2016 11:08:21 +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 CF00C202EC for ; Tue, 23 Feb 2016 11:08:20 +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 1aYAmt-00086W-Q5; Tue, 23 Feb 2016 11:05:51 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aYAms-00085r-W3 for xen-devel@lists.xenproject.org; Tue, 23 Feb 2016 11:05:51 +0000 Received: from [85.158.139.211] by server-14.bemta-5.messagelabs.com id 9B/73-02992-E0D3CC65; Tue, 23 Feb 2016 11:05:50 +0000 X-Env-Sender: prvs=854db9b9a=david.vrabel@citrix.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1456225546!9889527!3 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: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 880 invoked from network); 23 Feb 2016 11:05:49 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-16.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 23 Feb 2016 11:05:49 -0000 X-IronPort-AV: E=Sophos;i="5.22,488,1449532800"; d="scan'208";a="340180724" From: David Vrabel To: Date: Tue, 23 Feb 2016 11:05:39 +0000 Message-ID: <1456225539-9162-4-git-send-email-david.vrabel@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456225539-9162-1-git-send-email-david.vrabel@citrix.com> References: <1456225539-9162-1-git-send-email-david.vrabel@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Andrew Cooper , David Vrabel , Jan Beulich Subject: [Xen-devel] [PATCHv2 3/3] x86/hvm: add HVM_PARAM_X87_FIP_WIDTH 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: , 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 The HVM parameter HVM_PARAM_X87_FIP_WIDTH to allow tools and the guest to adjust the width of the FIP/FDP registers to be saved/restored by the hypervisor. This is in case the hypervisor hueristics do not do the right thing. Add this parameter to the set saved during domain save/migrate. Signed-off-by: David Vrabel Reviewed-by: Andrew Cooper Acked-by: Wei Liu --- tools/libxc/xc_sr_save_x86_hvm.c | 1 + xen/arch/x86/hvm/hvm.c | 13 +++++++++++++ xen/include/public/hvm/params.h | 24 +++++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xc_sr_save_x86_hvm.c index e347b3b..ba50a43 100644 --- a/tools/libxc/xc_sr_save_x86_hvm.c +++ b/tools/libxc/xc_sr_save_x86_hvm.c @@ -76,6 +76,7 @@ static int write_hvm_params(struct xc_sr_context *ctx) HVM_PARAM_VM_GENERATION_ID_ADDR, HVM_PARAM_IOREQ_SERVER_PFN, HVM_PARAM_NR_IOREQ_SERVER_PAGES, + HVM_PARAM_X87_FIP_WIDTH, }; xc_interface *xch = ctx->xch; diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index fe382ce..3583c9e 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -6027,6 +6027,7 @@ static int hvm_allow_set_param(struct domain *d, case HVM_PARAM_VM_GENERATION_ID_ADDR: case HVM_PARAM_STORE_EVTCHN: case HVM_PARAM_CONSOLE_EVTCHN: + case HVM_PARAM_X87_FIP_WIDTH: break; /* * The following parameters must not be set by the guest @@ -6222,6 +6223,14 @@ static int hvmop_set_param( break; } + case HVM_PARAM_X87_FIP_WIDTH: + if ( a.value != 0 && a.value != 4 && a.value != 8 ) + { + rc = -EINVAL; + break; + } + d->arch.x87_fip_width = a.value; + break; } if ( rc != 0 ) @@ -6258,6 +6267,7 @@ static int hvm_allow_get_param(struct domain *d, case HVM_PARAM_CONSOLE_PFN: case HVM_PARAM_CONSOLE_EVTCHN: case HVM_PARAM_ALTP2M: + case HVM_PARAM_X87_FIP_WIDTH: break; /* * The following parameters must not be read by the guest @@ -6307,6 +6317,9 @@ static int hvmop_get_param( case HVM_PARAM_ACPI_S_STATE: a.value = d->arch.hvm_domain.is_s3_suspended ? 3 : 0; break; + case HVM_PARAM_X87_FIP_WIDTH: + a.value = d->arch.x87_fip_width; + break; case HVM_PARAM_IOREQ_PFN: case HVM_PARAM_BUFIOREQ_PFN: case HVM_PARAM_BUFIOREQ_EVTCHN: diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h index 81f9451..73d4718 100644 --- a/xen/include/public/hvm/params.h +++ b/xen/include/public/hvm/params.h @@ -210,6 +210,28 @@ /* Boolean: Enable altp2m */ #define HVM_PARAM_ALTP2M 35 -#define HVM_NR_PARAMS 36 +/* + * Size of the x87 FPU FIP/FDP registers that the hypervisor needs to + * save/restore. This is a workaround for a hardware limitation that + * does not allow the full FIP/FDP and FCS/FDS to be restored. + * + * Valid values are: + * + * 8: save/restore 64-bit FIP/FDP and clear FCS/FDS (default if CPU + * has FPCSDS feature). + * + * 4: save/restore 32-bit FIP/FDP, FCS/FDS, and clear upper 32-bits of + * FIP/FDP. + * + * 0: allow hypervisor to choose based on the value of FIP/FDP + * (default if CPU does not have FPCSDS). + * + * If FPCSDS (bit 13 in CPUID leaf 0x7, subleaf 0x0) is set, the CPU + * never saves FCS/FDS and this parameter should be left at the + * default of 8. + */ +#define HVM_PARAM_X87_FIP_WIDTH 36 + +#define HVM_NR_PARAMS 37 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */