From patchwork Tue Jan 19 17:42:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 8064321 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 1BEE0BEEE5 for ; Tue, 19 Jan 2016 17:46:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B064204EB for ; Tue, 19 Jan 2016 17:46:04 +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 7842A2046F for ; Tue, 19 Jan 2016 17:46:03 +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 1aLaJ6-0003D2-Cz; Tue, 19 Jan 2016 17:43:04 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aLaJ5-0003Cx-8P for xen-devel@lists.xenproject.org; Tue, 19 Jan 2016 17:43:03 +0000 Received: from [193.109.254.147] by server-9.bemta-14.messagelabs.com id D5/14-13475-6A57E965; Tue, 19 Jan 2016 17:43:02 +0000 X-Env-Sender: prvs=8197794ea=roger.pau@citrix.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1453225380!17972847!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 32569 invoked from network); 19 Jan 2016 17:43:01 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-10.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 19 Jan 2016 17:43:01 -0000 X-IronPort-AV: E=Sophos;i="5.22,318,1449532800"; d="scan'208";a="326219681" From: Roger Pau Monne To: Date: Tue, 19 Jan 2016 18:42:53 +0100 Message-ID: <1453225373-81485-1-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 1.9.5 (Apple Git-50.3) MIME-Version: 1.0 X-DLP: MIA2 Cc: Andrew Cooper , Jan Beulich , Roger Pau Monne Subject: [Xen-devel] [PATCH] x86/HVM: memset CPU context save area 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 In order to prevent leaking data in the padding field. Also remove the memset done to the fpu_regs in case of no FPU context present, since it's already taken care by the memset of the whole CPU context structure. The same applies to setting ctxt.flags to 0 in case there's no FPU context. Signed-off-by: Roger Pau Monné Reported-by: Jan Beulich Reviewed-by: Andrew Cooper --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/hvm/hvm.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 8f98956..674feea 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1732,6 +1732,8 @@ static int hvm_save_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) if ( v->pause_flags & VPF_down ) continue; + memset(&ctxt, 0, sizeof(ctxt)); + /* Architecture-specific vmcs/vmcb bits */ hvm_funcs.save_cpu_ctxt(v, &ctxt); @@ -1798,11 +1800,6 @@ static int hvm_save_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) memcpy(ctxt.fpu_regs, v->arch.fpu_ctxt, sizeof(ctxt.fpu_regs)); ctxt.flags = XEN_X86_FPU_INITIALISED; } - else - { - memset(ctxt.fpu_regs, 0, sizeof(ctxt.fpu_regs)); - ctxt.flags = 0; - } ctxt.rax = v->arch.user_regs.eax; ctxt.rbx = v->arch.user_regs.ebx;