diff mbox

x86/HVM: memset CPU context save area

Message ID 1453225373-81485-1-git-send-email-roger.pau@citrix.com
State New, archived
Headers show

Commit Message

Roger Pau Monné Jan. 19, 2016, 5:42 p.m. UTC
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é <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/hvm/hvm.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Roger Pau Monné Jan. 19, 2016, 5:44 p.m. UTC | #1
El 19/01/16 a les 18.42, Roger Pau Monne ha escrit:
> 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é <roger.pau@citrix.com>

Forgot to add:

Reported-by: Jan Beulich <jbeulich@suse.com>
Andrew Cooper Jan. 19, 2016, 6:21 p.m. UTC | #2
On 19/01/16 17:42, Roger Pau Monne wrote:
> 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é <roger.pau@citrix.com>
> ---
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Ian Jackson Jan. 19, 2016, 6:34 p.m. UTC | #3
Roger Pau Monne writes ("[Xen-devel] [PATCH] x86/HVM: memset CPU context save area"):
> 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é <roger.pau@citrix.com>
...
> Reported-by: Jan Beulich <jbeulich@suse.com>

Andrew Cooper writes ("Re: [Xen-devel] [PATCH] x86/HVM: memset CPU context save area"):
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Thanks, applied.

Roger Pau Monné writes ("Re: [Xen-devel] [xen-unstable-smoke test] 78539: regressions - FAIL"):
> El 19/01/16 a les 18.43, osstest service owner ha escrit:
> > flight 78539 xen-unstable-smoke real [real]
> > http://logs.test-lab.xenproject.org/osstest/logs/78539/
> > 
> > Regressions :-(
> > 
> > Tests which did not succeed and are blocking,
> > including tests which could not be run:
> >  test-amd64-amd64-xl-qemuu-debianhvm-i386 12 guest-saverestore fail REGR. vs. 78522
> 
> This is my fault:
> 
> Jan 19 16:49:13.681214 (XEN) HVM3 restore: CPU 0
> Jan 19 16:49:36.461176 (XEN) HVM3 restore: failed to load entry 2/0
> 
> It should be fixed by
> <1453225373-81485-1-git-send-email-roger.pau@citrix.com>

Thanks for the heads-up.

Ian.
diff mbox

Patch

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;