From patchwork Mon Feb 22 05:35:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuai Ruan X-Patchwork-Id: 8371901 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 E389FC0553 for ; Mon, 22 Feb 2016 05:41:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 24571203A9 for ; Mon, 22 Feb 2016 05:41:03 +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 493CC203A1 for ; Mon, 22 Feb 2016 05:41:02 +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 1aXjC8-0005vM-Cw; Mon, 22 Feb 2016 05:38:04 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aXjC6-0005v3-GR for xen-devel@lists.xen.org; Mon, 22 Feb 2016 05:38:02 +0000 Received: from [193.109.254.147] by server-7.bemta-14.messagelabs.com id 29/38-29985-9BE9AC65; Mon, 22 Feb 2016 05:38:01 +0000 X-Env-Sender: shuai.ruan@linux.intel.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1456119478!25258078!3 X-Originating-IP: [134.134.136.65] 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 3371 invoked from network); 22 Feb 2016 05:38:01 -0000 Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by server-3.tower-27.messagelabs.com with SMTP; 22 Feb 2016 05:38:01 -0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 21 Feb 2016 21:38:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,483,1449561600"; d="scan'208";a="750713952" Received: from rs-vmm.bj.intel.com ([10.238.135.71]) by orsmga003.jf.intel.com with ESMTP; 21 Feb 2016 21:37:58 -0800 From: Shuai Ruan To: xen-devel@lists.xen.org Date: Mon, 22 Feb 2016 13:35:20 +0800 Message-Id: <1456119321-10384-3-git-send-email-shuai.ruan@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456119321-10384-1-git-send-email-shuai.ruan@linux.intel.com> References: <1456119321-10384-1-git-send-email-shuai.ruan@linux.intel.com> Cc: wei.liu2@citrix.com, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, jbeulich@suse.com, keir@xen.org Subject: [Xen-devel] [PATCH 2/3] x86/xsaves: fix overwriting between non-lazy/lazy xsave[sc] 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 The offset at which components xsaved by xsave[sc] are not fixed. So when when a save with v->fpu_dirtied set is followed by one with v->fpu_dirtied clear, non-lazy xsave[sc] may overwriting data written by the lazy one. When xsave[sc] is enable, vcpu_xsave_mask will return XSTATE_ALL when v->fpu_dirtied clear and v->arch.nonlazy_xstate_used is set. Signed-off-by: Shuai Ruan --- xen/arch/x86/i387.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/i387.c b/xen/arch/x86/i387.c index 67016c9..e3a7bc0 100644 --- a/xen/arch/x86/i387.c +++ b/xen/arch/x86/i387.c @@ -118,7 +118,7 @@ static inline uint64_t vcpu_xsave_mask(const struct vcpu *v) if ( v->fpu_dirtied ) return v->arch.nonlazy_xstate_used ? XSTATE_ALL : XSTATE_LAZY; - return v->arch.nonlazy_xstate_used ? XSTATE_NONLAZY : 0; + return ( cpu_has_xsaves || cpu_has_xsavec ) ? XSTATE_ALL : XSTATE_NONLAZY; } /* Save x87 extended state */