Skip to contentSkip to conversation

x86/HVM: memset CPU context save area

PATCH In review Roger Pau Monne 4 participants 6 messages Jan 19, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>

---
 xen/arch/x86/hvm/hvm.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
xen/arch/x86/hvm/hvm.c +2 -5
index 8f98956..674feea 100644
@@ -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;
Signature · 7 lines
1.9.5 (Apple Git-50.3)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw

El 19/01/16 a les 18.42, Roger Pau Monne ha escrit:

Quoted 6 lines

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.

Forgot to add:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#2 lore raw
In reply to Roger Pau Monne
Quoted 9 lines · Roger Pau Monne

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.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by Andrew Cooper Reviewed-by Boris Ostrovsky Reviewed-by Boris Ostrovsky Reviewed-by Boris Ostrovsky Acked-by Jan Beulich Acked-by Wei Liu
#3 lore raw

[xen-unstable-smoke test] 78539: regressions - FAIL

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

Tests which did not succeed, but are not blocking:

 test-amd64-amd64-libvirt     12 migrate-support-check        fail   never pass
 test-armhf-armhf-xl          12 migrate-support-check        fail   never pass
 test-armhf-armhf-xl          13 saverestore-support-check    fail   never pass

version targeted for testing:
xen eb68c40ba5d0212adc176290f09e4ee133c96e83
baseline version:
xen 162a81abb1c55ff77a3fcc82c7971a766ca122f6

Last test of basis    78522  2016-01-19 13:01:25 Z    0 days
Testing same since    78539  2016-01-19 16:01:48 Z    0 days    1 attempts

------------------------------------------------------------
People who touched revisions under test:
Haozhong Zhang <[email protected]>
Jan Beulich <[email protected]>
Roger Pau Monné <[email protected]>
Wei Liu <[email protected]>

jobs:

 build-amd64                                                  pass
 build-armhf                                                  pass
 build-amd64-libvirt                                          pass
 test-armhf-armhf-xl                                          pass
 test-amd64-amd64-xl-qemuu-debianhvm-i386                     fail
 test-amd64-amd64-libvirt                                     pass

------------------------------------------------------------
sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/logs/logs
images: /home/logs/images

Logs, config files, etc. are available at
http://logs.test-lab.xenproject.org/osstest/logs

Explanation of these reports, and of osstest in general, is at
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README.email;hb=master
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README;hb=master

Test harness code can be found at
http://xenbits.xen.org/gitweb?p=osstest.git;a=summary

Not pushing.

------------------------------------------------------------
commit eb68c40ba5d0212adc176290f09e4ee133c96e83

Author: Roger Pau Monné <[email protected]>
Date:   Tue Jan 19 16:08:39 2016 +0100

x86/HVM: add padding to struct hvm_hw_cpu

So that the size of the structure is the same on 32 and 64bit.

commit 805b7484b85e77b15c68e837b3d7b77053182d37

Author: Haozhong Zhang <[email protected]>
Date:   Tue Jan 19 16:07:59 2016 +0100

svm: remove redundant TSC scaling in svm_set_tsc_offset()

Now every caller passes an already scaled offset to svm_set_tsc_offset(), so it's not necessary to recalculate a scaled TSC offset in svm_set_tsc_offset().

commit eab8a90be723d742d607aff2005ea0ab521bfd6a

Author: Haozhong Zhang <[email protected]>
Date:   Tue Jan 19 16:07:39 2016 +0100

x86/time: scale host TSC in pvclock properly

This patch makes the pvclock return the scaled host TSC and corresponding scaling parameters to HVM domains if guest TSC is not emulated and TSC scaling is enabled.

commit 52fd9a46f6e9eb050a6b402ce3b04fa57907acc5

Author: Haozhong Zhang <[email protected]>
Date:   Tue Jan 19 16:07:15 2016 +0100

x86/hvm: scale host TSC when setting/getting guest TSC

The existing hvm_[set|get]_guest_tsc_fixed() calculate the guest TSC by adding the TSC offset to the host TSC. When the TSC scaling is enabled, the host TSC should be scaled first. This patch adds the scaling logic to those two functions.

commit c2ba8c24f34426c993afa841bf94d933d2461cd9

Author: Roger Pau Monné <[email protected]>
Date:   Tue Jan 19 16:06:31 2016 +0100

elfnotes: check phys_entry against UNSET_ADDR32

And introduce UNSET_ADDR32.

(qemu changes not included)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw

Re: [xen-unstable-smoke test] 78539: regressions - FAIL

El 19/01/16 a les 18.43, osstest service owner ha escrit:

Quoted 8 lines

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 <[email protected]>

Roger.

Applied
#5 lore raw

Re: [xen-unstable-smoke test] 78539: regressions - FAIL [and 3 more messages]

Roger Pau Monne writes ("[Xen-devel] [PATCH] x86/HVM: memset CPU context save area"):

Quoted 6 lines

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.

...

Quoted 1 line

Andrew Cooper writes ("Re: [Xen-devel] [PATCH] x86/HVM: memset CPU context save area"):

Quoted 1 line

Thanks, applied.

Roger Pau Monné writes ("Re: [Xen-devel] [xen-unstable-smoke test] 78539: regressions - FAIL"):

Quoted 10 lines

El 19/01/16 a les 18.43, osstest service owner ha escrit:

Quoted 8 lines

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

Quoted 7 lines

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 <[email protected]>

Thanks for the heads-up.

Ian.