From patchwork Wed Jan 13 07:30:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 8022871 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 E66D6BEEE5 for ; Wed, 13 Jan 2016 07:34:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC7922041A for ; Wed, 13 Jan 2016 07:34: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 AE74120328 for ; Wed, 13 Jan 2016 07:34: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 1aJFtO-0004w2-8Q; Wed, 13 Jan 2016 07:30:54 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aJFtL-0004vx-UI for xen-devel@lists.xenproject.org; Wed, 13 Jan 2016 07:30:52 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id D9/AE-09708-B2DF5965; Wed, 13 Jan 2016 07:30:51 +0000 X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-8.tower-21.messagelabs.com!1452670248!9778345!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10067 invoked from network); 13 Jan 2016 07:30:49 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-8.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 13 Jan 2016 07:30:49 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Wed, 13 Jan 2016 00:30:47 -0700 Message-Id: <56960B3602000078000C62AC@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Wed, 13 Jan 2016 00:30:46 -0700 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Cc: Andrew Cooper , Keir Fraser , Shuai Ruan Subject: [Xen-devel] [PATCH v2] x86/xsave: simplify xcomp_bv initialization 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 This simplifies a number of pointless conditionals: Bits 0 and 1 of xcomp_bv don't matter anyway, and as long as none of bits 2..62 are set, setting bit 63 is pointless too unless XSAVES is in use. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- v2: Retain setting of bit 63 on XSAVES-capable systems. x86/xsave: simplify xcomp_bv initialization This simplifies a number of pointless conditionals: Bits 0 and 1 of xcomp_bv don't matter anyway, and as long as none of bits 2..62 are set, setting bit 63 is pointless too unless XSAVES is in use. Signed-off-by: Jan Beulich --- v2: Retain setting of bit 63 on XSAVES-capable systems. --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -922,9 +922,8 @@ int arch_set_info_guest( if ( v->arch.xsave_area ) { v->arch.xsave_area->xsave_hdr.xstate_bv = XSTATE_FP_SSE; - if ( cpu_has_xsaves || cpu_has_xsavec ) - v->arch.xsave_area->xsave_hdr.xcomp_bv = XSTATE_FP_SSE | - XSTATE_COMPACTION_ENABLED; + v->arch.xsave_area->xsave_hdr.xcomp_bv = + cpu_has_xsaves ? XSTATE_COMPACTION_ENABLED : 0; } } else if ( v->arch.xsave_area ) --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -2094,9 +2094,8 @@ static int hvm_load_cpu_ctxt(struct doma memcpy(v->arch.xsave_area, ctxt.fpu_regs, sizeof(ctxt.fpu_regs)); xsave_area->xsave_hdr.xstate_bv = XSTATE_FP_SSE; - if ( cpu_has_xsaves || cpu_has_xsavec ) - xsave_area->xsave_hdr.xcomp_bv = XSTATE_FP_SSE | - XSTATE_COMPACTION_ENABLED; + xsave_area->xsave_hdr.xcomp_bv = + cpu_has_xsaves ? XSTATE_COMPACTION_ENABLED : 0; } else memcpy(v->arch.fpu_ctxt, ctxt.fpu_regs, sizeof(ctxt.fpu_regs)); @@ -5455,9 +5454,8 @@ void hvm_vcpu_reset_state(struct vcpu *v if ( v->arch.xsave_area ) { v->arch.xsave_area->xsave_hdr.xstate_bv = XSTATE_FP; - if ( cpu_has_xsaves || cpu_has_xsavec ) - v->arch.xsave_area->xsave_hdr.xcomp_bv = XSTATE_FP | - XSTATE_COMPACTION_ENABLED; + v->arch.xsave_area->xsave_hdr.xcomp_bv = + cpu_has_xsaves ? XSTATE_COMPACTION_ENABLED : 0; } v->arch.vgc_flags = VGCF_online; --- a/xen/arch/x86/i387.c +++ b/xen/arch/x86/i387.c @@ -272,7 +272,7 @@ int vcpu_init_fpu(struct vcpu *v) if ( v->arch.xsave_area ) { v->arch.fpu_ctxt = &v->arch.xsave_area->fpu_sse; - if ( cpu_has_xsaves || cpu_has_xsavec ) + if ( cpu_has_xsaves ) v->arch.xsave_area->xsave_hdr.xcomp_bv = XSTATE_COMPACTION_ENABLED; } else --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -922,9 +922,8 @@ int arch_set_info_guest( if ( v->arch.xsave_area ) { v->arch.xsave_area->xsave_hdr.xstate_bv = XSTATE_FP_SSE; - if ( cpu_has_xsaves || cpu_has_xsavec ) - v->arch.xsave_area->xsave_hdr.xcomp_bv = XSTATE_FP_SSE | - XSTATE_COMPACTION_ENABLED; + v->arch.xsave_area->xsave_hdr.xcomp_bv = + cpu_has_xsaves ? XSTATE_COMPACTION_ENABLED : 0; } } else if ( v->arch.xsave_area ) --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -2094,9 +2094,8 @@ static int hvm_load_cpu_ctxt(struct doma memcpy(v->arch.xsave_area, ctxt.fpu_regs, sizeof(ctxt.fpu_regs)); xsave_area->xsave_hdr.xstate_bv = XSTATE_FP_SSE; - if ( cpu_has_xsaves || cpu_has_xsavec ) - xsave_area->xsave_hdr.xcomp_bv = XSTATE_FP_SSE | - XSTATE_COMPACTION_ENABLED; + xsave_area->xsave_hdr.xcomp_bv = + cpu_has_xsaves ? XSTATE_COMPACTION_ENABLED : 0; } else memcpy(v->arch.fpu_ctxt, ctxt.fpu_regs, sizeof(ctxt.fpu_regs)); @@ -5455,9 +5454,8 @@ void hvm_vcpu_reset_state(struct vcpu *v if ( v->arch.xsave_area ) { v->arch.xsave_area->xsave_hdr.xstate_bv = XSTATE_FP; - if ( cpu_has_xsaves || cpu_has_xsavec ) - v->arch.xsave_area->xsave_hdr.xcomp_bv = XSTATE_FP | - XSTATE_COMPACTION_ENABLED; + v->arch.xsave_area->xsave_hdr.xcomp_bv = + cpu_has_xsaves ? XSTATE_COMPACTION_ENABLED : 0; } v->arch.vgc_flags = VGCF_online; --- a/xen/arch/x86/i387.c +++ b/xen/arch/x86/i387.c @@ -272,7 +272,7 @@ int vcpu_init_fpu(struct vcpu *v) if ( v->arch.xsave_area ) { v->arch.fpu_ctxt = &v->arch.xsave_area->fpu_sse; - if ( cpu_has_xsaves || cpu_has_xsavec ) + if ( cpu_has_xsaves ) v->arch.xsave_area->xsave_hdr.xcomp_bv = XSTATE_COMPACTION_ENABLED; } else