From patchwork Thu Mar 31 08:57:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuai Ruan X-Patchwork-Id: 8708821 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 93208C0553 for ; Thu, 31 Mar 2016 08:57:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC5F220270 for ; Thu, 31 Mar 2016 08:57:27 +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 3640D20254 for ; Thu, 31 Mar 2016 08:57:26 +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 1alYNX-0000Xb-9L; Thu, 31 Mar 2016 08:54:59 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1alYNV-0000X4-Oi for xen-devel@lists.xen.org; Thu, 31 Mar 2016 08:54:57 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 51/8D-09532-1E5ECF65; Thu, 31 Mar 2016 08:54:57 +0000 X-Env-Sender: shuai.ruan@linux.intel.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1459414494!6674103!3 X-Originating-IP: [134.134.136.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18141 invoked from network); 31 Mar 2016 08:54:56 -0000 Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by server-10.tower-21.messagelabs.com with SMTP; 31 Mar 2016 08:54:56 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 31 Mar 2016 01:54:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,421,1455004800"; d="scan'208";a="76441771" Received: from rs-vmm.bj.intel.com ([10.238.135.55]) by fmsmga004.fm.intel.com with ESMTP; 31 Mar 2016 01:54:55 -0700 From: Shuai Ruan To: xen-devel@lists.xen.org Date: Thu, 31 Mar 2016 16:57:36 +0800 Message-Id: <1459414657-7558-3-git-send-email-shuai.ruan@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1459414657-7558-1-git-send-email-shuai.ruan@linux.intel.com> References: <1459414657-7558-1-git-send-email-shuai.ruan@linux.intel.com> Cc: andrew.cooper3@citrix.com, keir@xen.org, jbeulich@suse.com Subject: [Xen-devel] [PATCH V7 2/3] x86/xsaves: fix two remained issues 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: , MIME-Version: 1.0 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 From: Shuai Ruan 1. get_xsave_addr() will only be called when xsave_area_compressed(xsave) is true. So drop the conditional expression. 2. expand_xsave_states() will memset the area when get NULL from get_xsave_addr(). Signed-off-by: Shuai Ruan Reported-by: ... --- xen/arch/x86/xstate.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c index 8c652bc..f4ea54d 100644 --- a/xen/arch/x86/xstate.c +++ b/xen/arch/x86/xstate.c @@ -164,12 +164,8 @@ static void *get_xsave_addr(struct xsave_struct *xsave, const uint16_t *comp_offsets, unsigned int xfeature_idx) { - if ( !((1ul << xfeature_idx) & xsave->xsave_hdr.xstate_bv) ) - return NULL; - - return (void *)xsave + (xsave_area_compressed(xsave) ? - comp_offsets[xfeature_idx] : - xstate_offsets[xfeature_idx]); + return (1ul << xfeature_idx) & xsave->xsave_hdr.xstate_bv ? + (void *)xsave + comp_offsets[xfeature_idx] : NULL; } void expand_xsave_states(struct vcpu *v, void *dest, unsigned int size) @@ -211,6 +207,8 @@ void expand_xsave_states(struct vcpu *v, void *dest, unsigned int size) ASSERT((xstate_offsets[index] + xstate_sizes[index]) <= size); memcpy(dest + xstate_offsets[index], src, xstate_sizes[index]); } + else + memset(dest + xstate_offsets[index], 0, xstate_sizes[index]); valid &= ~feature; }