xen: fix initialization of wallclock time for PVHVM on migration
PATCH 1/1 xen: fix initialization of wallclock time for PVHVM on migration
The initial values of the wallclock time in the shared info page are set for PVHVM guests when the hypercall page is initialized, since the hypercall page is not reinitialized on resume, the hypervisor wallclock time is not properly set on resume.
Fix it by forcing an update of the wallclock values when the shared info page is mapped.
---
Since this is a bug fix, I think it is suitable for inclusion in the 4.3 release, and backported to older releases.
--- xen/arch/x86/mm.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
xen/arch/x86/mm.c +8 -0
@@ -4629,6 +4629,14 @@ static int xenmem_add_to_physmap_once(put_gfn (d, gfn);domain_unlock (d); +if ( !rc && xatp->space == XENMAPSPACE_shared_info ) +/* +* Force an update of the wallclock values in the shared info +* page, since in the PVHVM resume path the hypercall page is +* not reinitialized. +*/ +update_domain_wallclock_time (d); +return rc; }
Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Jan Beulich
NAKQuoted 8 lines
Quoted 1 line
Quoted 1 line · Roger Pau Monne
The initial values of the wallclock time in the shared info page are set for PVHVM guests when the hypercall page is initialized, since the hypercall page is not reinitialized on resume, the hypervisor wallclock time is not properly set on resume.
Fix it by forcing an update of the wallclock values when the shared info page is mapped.
NACK - this is a guest side bug. After migration, a guest _has_ to re-init the hypercall page, as it may have got migrated between a VMX and an SVM machine, and the hypercall instructions are different between them.
Jan
Quoted 32 lines
Signed-off-by Roger Pau Monné <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir Fraser <[email protected]>Cc George Dunlap <[email protected]>---
Since this is a bug fix, I think it is suitable for inclusion in the 4.3 release, and backported to older releases.--- xen/arch/x86/mm.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)xen/arch/x86/mm.c +8
-0@@ -4629,6 +4629,14 @@ static int xenmem_add_to_physmap_once(put_gfn (d, gfn);domain_unlock (d); +if ( !rc && xatp->space == XENMAPSPACE_shared_info ) +/* +* Force an update of the wallclock values in the shared info +* page, since in the PVHVM resume path the hypercall page is +* not reinitialized. +*/ +update_domain_wallclock_time (d); +return rc; }Signature · 1 line
1.7.7.5 (Apple Git-26)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Roger Pau Monne
The initial values of the wallclock time in the shared info page are set for PVHVM guests when the hypercall page is initialized, since the hypercall page is not reinitialized on resume, the hypervisor wallclock time is not properly set on resume.
Quoted 7 lines
Quoted 2 lines
Fix it by forcing an update of the wallclock values when the shared info page is mapped.
NACK - this is a guest side bug. After migration, a guest _has_ to re-init the hypercall page, as it may have got migrated between a VMX and an SVM machine, and the hypercall instructions are different between them.
Does migrating from VMX to SVM actually work?
In any case, if Linux does it, then FreeBSD should do it too. (I assume this came up because you're working on the FreeBSD PVHVM port?)
-George
Quoted 11 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 9 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Roger Pau Monne
The initial values of the wallclock time in the shared info page are set for PVHVM guests when the hypercall page is initialized, since the hypercall page is not reinitialized on resume, the hypervisor wallclock time is not properly set on resume.
Fix it by forcing an update of the wallclock values when the shared info page is mapped.
Quoted 6 lines
Quoted 4 lines
NACK - this is a guest side bug. After migration, a guest _has_ to re-init the hypercall page, as it may have got migrated between a VMX and an SVM machine, and the hypercall instructions are different between them.
Does migrating from VMX to SVM actually work?
If you sufficiently feature-restrict both hosts, it should work. At least it was made work years ago iirc (see the sysenter/syscall emulation code in the x86 emulator - the only case where this may be needed is when doing cross vendor migration).
Jan
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 13 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Roger Pau Monne
The initial values of the wallclock time in the shared info page are set for PVHVM guests when the hypercall page is initialized, since the hypercall page is not reinitialized on resume, the hypervisor wallclock time is not properly set on resume.
Fix it by forcing an update of the wallclock values when the shared info page is mapped.
NACK - this is a guest side bug. After migration, a guest _has_ to re-init the hypercall page, as it may have got migrated between a VMX and an SVM machine, and the hypercall instructions are different between them.
Quoted 6 lines
Quoted 1 line
Does migrating from VMX to SVM actually work?
If you sufficiently feature-restrict both hosts, it should work. At least it was made work years ago iirc (see the sysenter/syscall emulation code in the x86 emulator - the only case where this may be needed is when doing cross vendor migration).
Doesn't the presence of that emulation contradict the requirement to reinit the hypercall page?
My recollection is that although it could be made to work the performance would suffer horribly precisely due to this emulation.
Ian.
Quoted 20 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 18 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Roger Pau Monne
The initial values of the wallclock time in the shared info page are set for PVHVM guests when the hypercall page is initialized, since the hypercall page is not reinitialized on resume, the hypervisor wallclock time is not properly set on resume.
Quoted 7 lines
Quoted 2 lines
Fix it by forcing an update of the wallclock values when the shared info page is mapped.
NACK - this is a guest side bug. After migration, a guest _has_ to re-init the hypercall page, as it may have got migrated between a VMX and an SVM machine, and the hypercall instructions are different between them.
Does migrating from VMX to SVM actually work?
Quoted 7 lines
Quoted 4 lines
If you sufficiently feature-restrict both hosts, it should work. At least it was made work years ago iirc (see the sysenter/syscall emulation code in the x86 emulator - the only case where this may be needed is when doing cross vendor migration).
Doesn't the presence of that emulation contradict the requirement to reinit the hypercall page?
Definitely not - the emulation deals with system call instructions, while the hypercall page holds hypercall instructions (which have no emulation anywhere iirc).
Quoted 2 lines
My recollection is that although it could be made to work the performance would suffer horribly precisely due to this emulation.
Performance isn't going to be good, sure. It's more for some kind of emergency I think. Wasn't it Christoph Egger who implemented this? Maybe he recalls more details than I do...
Jan
Quoted 25 lines · Jan Beulich
Quoted 25 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 22 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 9 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Roger Pau Monne
The initial values of the wallclock time in the shared info page are set for PVHVM guests when the hypercall page is initialized, since the hypercall page is not reinitialized on resume, the hypervisor wallclock time is not properly set on resume.
Fix it by forcing an update of the wallclock values when the shared info page is mapped.
Quoted 6 lines
Quoted 4 lines
NACK - this is a guest side bug. After migration, a guest _has_ to re-init the hypercall page, as it may have got migrated between a VMX and an SVM machine, and the hypercall instructions are different between them.
Does migrating from VMX to SVM actually work?
If you sufficiently feature-restrict both hosts, it should work. At least it was made work years ago iirc (see the sysenter/syscall emulation code in the x86 emulator - the only case where this may be needed is when doing cross vendor migration).
Quoted 6 lines
Quoted 2 lines
Doesn't the presence of that emulation contradict the requirement to reinit the hypercall page?
Definitely not - the emulation deals with system call instructions, while the hypercall page holds hypercall instructions (which have no emulation anywhere iirc).
Back at that time, yes migration from VMX to SVM and vice versa gotta work. However, there are always things to consider:
1) Hypervisor side: When the guest OS uses MSRs that do not exist on the destination machine must be emulated.
2) feature-set: Make sure both OS and application do not use instructions (i.e. 3DNow, AVX, etc.) that isn't available on destination side. You can archieve that by either setting cpuid properly or emulate the missing instructions in the hypervisor. The latter one will decrease performance.
Quoted 6 lines
Quoted 2 lines
My recollection is that although it could be made to work the performance would suffer horribly precisely due to this emulation.
Performance isn't going to be good, sure. It's more for some kind of emergency I think. Wasn't it Christoph Egger who implemented this? Maybe he recalls more details than I do...
sysenter/syscall emulation comes into play with 32bit applications in a 64bit guest OS. Yes, performance decreases but how much impact this actually has on the end-user side depends on
a) the syscall itself (i.e. glibc caches the getpid syscall so the performance penality shouldn't even be measureable while other syscalls like read/write may suffer)
b) how often the syscall is actually in use
Christoph
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Roger Pau Monne
The initial values of the wallclock time in the shared info page are set for PVHVM guests when the hypercall page is initialized, since the hypercall page is not reinitialized on resume, the hypervisor wallclock time is not properly set on resume.
Quoted 7 lines
Quoted 2 lines
Fix it by forcing an update of the wallclock values when the shared info page is mapped.
NACK - this is a guest side bug. After migration, a guest _has_ to re-init the hypercall page, as it may have got migrated between a VMX and an SVM machine, and the hypercall instructions are different between them.
AFAICS Linux doesn't seem to re-init the hypercall page, see xen_arch_hvm_post_suspend at arch/x86/xen/suspend.c, but maybe I'm missing something.
Quoted 9 lines · Roger Pau Monné
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Roger Pau Monne
The initial values of the wallclock time in the shared info page are set for PVHVM guests when the hypercall page is initialized, since the hypercall page is not reinitialized on resume, the hypervisor wallclock time is not properly set on resume.
Fix it by forcing an update of the wallclock values when the shared info page is mapped.
Quoted 7 lines
Quoted 4 lines
NACK - this is a guest side bug. After migration, a guest _has_ to re-init the hypercall page, as it may have got migrated between a VMX and an SVM machine, and the hypercall instructions are different between them.
AFAICS Linux doesn't seem to re-init the hypercall page, see
xen_arch_hvm_post_suspendatarch/x86/xen/suspend.c, but maybe I'm missing something.
You are right. It does not re-init. It is the first time I heard that it has to re-init too.
In the past some steps were taken towards re-initing the shared page - that (on PVHVM) flat out died during migration (32-bit). Never figured out why and Olaf didn't have the time to dig in this. (git commit 9d02b43dee0d7fb18dfb13a00915550b1a3daa9f).
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Roger Pau Monné
Quoted 9 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Roger Pau Monne
The initial values of the wallclock time in the shared info page are set for PVHVM guests when the hypercall page is initialized, since the hypercall page is not reinitialized on resume, the hypervisor wallclock time is not properly set on resume.
Fix it by forcing an update of the wallclock values when the shared info page is mapped.
Quoted 8 lines
Quoted 4 lines
NACK - this is a guest side bug. After migration, a guest _has_ to re-init the hypercall page, as it may have got migrated between a VMX and an SVM machine, and the hypercall instructions are different between them.
AFAICS Linux doesn't seem to re-init the hypercall page, see
xen_arch_hvm_post_suspendatarch/x86/xen/suspend.c, but maybe I'm missing something.
I just looked at the unmodified_drivers/ tree, and there this re-init is being done.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Roger Pau Monne
The initial values of the wallclock time in the shared info page are set for PVHVM guests when the hypercall page is initialized, since the hypercall page is not reinitialized on resume, the hypervisor wallclock time is not properly set on resume.
Quoted 7 lines
Quoted 2 lines
Fix it by forcing an update of the wallclock values when the shared info page is mapped.
NACK - this is a guest side bug. After migration, a guest _has_ to re-init the hypercall page, as it may have got migrated between a VMX and an SVM machine, and the hypercall instructions are different between them.
I've re-inited the hypercall page on resume, but the hypervisor wallclock is still 0.
The call to update_domain_wallclock_time in hvm_latch_shinfo_size is gated, and doesn't get called on the resume path. Would it be OK to call update_domain_wallclock_time unconditionally on hvm_hypercall_page_initialise?
Quoted 16 lines
Quoted 1 line
Quoted 1 line · Roger Pau Monné
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Roger Pau Monne
The initial values of the wallclock time in the shared info page are set for PVHVM guests when the hypercall page is initialized, since the hypercall page is not reinitialized on resume, the hypervisor wallclock time is not properly set on resume.
Quoted 7 lines
Quoted 2 lines
Fix it by forcing an update of the wallclock values when the shared info page is mapped.
NACK - this is a guest side bug. After migration, a guest _has_ to re-init the hypercall page, as it may have got migrated between a VMX and an SVM machine, and the hypercall instructions are different between them.
Quoted 5 lines
I've re-inited the hypercall page on resume, but the hypervisor wallclock is still 0.
The call to
update_domain_wallclock_timeinhvm_latch_shinfo_sizeis gated, and doesn't get called on the resume path.
And it really isn't meant to deal with resume anyway. I simply based my original response on your description of the change, which now it looks like was misleading.
Quoted 3 lines
Would it be OK to call
update_domain_wallclock_timeunconditionally onhvm_hypercall_page_initialise?
The primary question is - why is what we have not enough for you? In particular I would expect that the call from arch_set_info_guest() (for vCPU 0) should do what you want. Or wait, this is covering PV only. So yes, with the description change I would then withdraw my NACK - apparently no-one really used the shared info wall clock time in a HVM guest so far (or it going wrong post-resume wasn't noticed).
I would, however, prefer the if() immediately preceding the patch context to be pulled out past the domain_lock()ed region, convert it to switch(), and add your code. That was, eventual other post- processing for the various map spaces has a consistent, easily extensible home.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 5 lines
Would it be OK to call
Quoted 2 lines
update_domain_wallclock_timeunconditionally onhvm_hypercall_page_initialise?
Quoted 8 lines
The primary question is - why is what we have not enough for you? In particular I would expect that the call from
arch_set_info_guest()(for vCPU 0) should do what you want. Or wait, this is covering PV only. So yes, with the description change I would then withdraw my NACK - apparently no-one really used the shared info wall clock time in a HVM guest so far (or it going wrong post-resume wasn't noticed).
It was. Olaf posted a patch that would re-init the shared page for PVHVM guest
(for kexec to work) and it stopped migration on 32-bit guest doing migration.
Olaf and me never got enough time to actually dig in this to figure out why it was
busted :-(
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 12 lines · Jan Beulich
Quoted 3 lines
Would it be OK to call
update_domain_wallclock_timeunconditionally onhvm_hypercall_page_initialise?The primary question is - why is what we have not enough for you? In particular I would expect that the call from
arch_set_info_guest()(for vCPU 0) should do what you want. Or wait, this is covering PV only. So yes, with the description change I would then withdraw my NACK - apparently no-one really used the shared info wall clock time in a HVM guest so far (or it going wrong post-resume wasn't noticed).
Quoted 5 lines
I would, however, prefer the
if()immediately preceding the patch context to be pulled out past the domain_lock()ed region, convert it toswitch(), and add your code. That was, eventual other post- processing for the various map spaces has a consistent, easily extensible home.
I apparently made a fix for this to work on initial boot of a 32-bit PVHVM guest back in September (a change in hvmloader to not zero the wc fields in shared_info). But I agree I now can't see why it works... But it surely does as it was tested to do so by Konrad.
A bit more digging required...
-- Keir
Quoted 20 lines · Keir Fraser
Quoted 12 lines · Jan Beulich
Quoted 3 lines
Would it be OK to call
update_domain_wallclock_timeunconditionally onhvm_hypercall_page_initialise?The primary question is - why is what we have not enough for you? In particular I would expect that the call from
arch_set_info_guest()(for vCPU 0) should do what you want. Or wait, this is covering PV only. So yes, with the description change I would then withdraw my NACK - apparently no-one really used the shared info wall clock time in a HVM guest so far (or it going wrong post-resume wasn't noticed).Quoted 5 lines
I would, however, prefer the
if()immediately preceding the patch context to be pulled out past the domain_lock()ed region, convert it toswitch(), and add your code. That was, eventual other post- processing for the various map spaces has a consistent, easily extensible home.
Quoted 6 lines
I apparently made a fix for this to work on initial boot of a 32-bit PVHVM guest back in September (a change in hvmloader to not zero the wc fields in
shared_info). But I agree I now can't see why it works... But it surely does as it was tested to do so by Konrad.A bit more digging required...
Hmm I can't find any confirmation that my patch actually *did* work. :( I'm sure I remember testing it though!
My suggestion is we do indeed remove the inner if() in latch_shinfo_size(). Ie. Call update_domain_wallclock_time() even if shinfo size has apparently not changed.
We only latch shinfo size on hypercall page initialisation and on setup of the callback irq. They are start-of-day/resume operations, so removing the if() should have no bad side effect that I can see. If nothing else it should make this wallclock-field setup more robust.
-- Keir
Quoted 3 lines
-- Keir
Quoted 32 lines · Keir Fraser
Quoted 20 lines · Keir Fraser
Quoted 12 lines · Jan Beulich
Quoted 3 lines
Would it be OK to call
update_domain_wallclock_timeunconditionally onhvm_hypercall_page_initialise?The primary question is - why is what we have not enough for you? In particular I would expect that the call from
arch_set_info_guest()(for vCPU 0) should do what you want. Or wait, this is covering PV only. So yes, with the description change I would then withdraw my NACK - apparently no-one really used the shared info wall clock time in a HVM guest so far (or it going wrong post-resume wasn't noticed).Quoted 5 lines
I would, however, prefer the
if()immediately preceding the patch context to be pulled out past the domain_lock()ed region, convert it toswitch(), and add your code. That was, eventual other post- processing for the various map spaces has a consistent, easily extensible home.Quoted 6 lines
I apparently made a fix for this to work on initial boot of a 32-bit PVHVM guest back in September (a change in hvmloader to not zero the wc fields in
shared_info). But I agree I now can't see why it works... But it surely does as it was tested to do so by Konrad.A bit more digging required...
Hmm I can't find any confirmation that my patch actually *did* work. :( I'm sure I remember testing it though!
Quoted 8 lines
My suggestion is we do indeed remove the inner
if()inlatch_shinfo_size(). Ie. Callupdate_domain_wallclock_time()even if shinfo size has apparently not changed.We only latch shinfo size on hypercall page initialisation and on setup of the callback irq. They are start-of-day/resume operations, so removing the
if()should have no bad side effect that I can see. If nothing else it should make this wallclock-field setup more robust.
So it would be better to call update_domain_wallclock_time unconditionally on latch_shinfo_size rather than doing it on XENMAPSPACE_shared_info?
Conceptially it makes more sense IMHO to do it in the call to XENMAPSPACE_shared_info.
Quoted 12 lines · Roger Pau Monné
Quoted 11 lines
Hmm I can't find any confirmation that my patch actually *did* work. :( I'm sure I remember testing it though!
My suggestion is we do indeed remove the inner
if()inlatch_shinfo_size(). Ie. Callupdate_domain_wallclock_time()even if shinfo size has apparently not changed.We only latch shinfo size on hypercall page initialisation and on setup of the callback irq. They are start-of-day/resume operations, so removing the
if()should have no bad side effect that I can see. If nothing else it should make this wallclock-field setup more robust.
Quoted 6 lines
So it would be better to call
update_domain_wallclock_timeunconditionally onlatch_shinfo_sizerather than doing it onXENMAPSPACE_shared_info?Conceptially it makes more sense IMHO to do it in the call to
XENMAPSPACE_shared_info.
I would still make the fix in latch_shinfo_size() and perhaps add an extra call to latch_shinfo_size() from the call to XENMAPSPACE_shared_info. But actually I am sure you will find it unnecessary and at this point for Xen 4.3 I think the smallest possible patch wins.
-- Keir
Quoted 18 lines · Keir Fraser
Quoted 16 lines · Roger Pau Monné
Quoted 11 lines
Hmm I can't find any confirmation that my patch actually *did* work. :( I'm sure I remember testing it though!
My suggestion is we do indeed remove the inner
if()inlatch_shinfo_size(). Ie. Callupdate_domain_wallclock_time()even if shinfo size has apparently not changed.We only latch shinfo size on hypercall page initialisation and on setup of the callback irq. They are start-of-day/resume operations, so removing the
if()should have no bad side effect that I can see. If nothing else it should make this wallclock-field setup more robust.So it would be better to call
update_domain_wallclock_timeunconditionally onlatch_shinfo_sizerather than doing it onXENMAPSPACE_shared_info?
Quoted 7 lines
Quoted 2 lines
Conceptially it makes more sense IMHO to do it in the call to
XENMAPSPACE_shared_info.I would still make the fix in
latch_shinfo_size()and perhaps add an extra call tolatch_shinfo_size()from the call toXENMAPSPACE_shared_info. But actually I am sure you will find it unnecessary and at this point for Xen 4.3 I think the smallest possible patch wins.
ACK, will resend the patch.
Quoted 33 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 20 lines · Keir Fraser
Quoted 12 lines · Jan Beulich
Quoted 3 lines
Would it be OK to call
update_domain_wallclock_timeunconditionally onhvm_hypercall_page_initialise?The primary question is - why is what we have not enough for you? In particular I would expect that the call from
arch_set_info_guest()(for vCPU 0) should do what you want. Or wait, this is covering PV only. So yes, with the description change I would then withdraw my NACK - apparently no-one really used the shared info wall clock time in a HVM guest so far (or it going wrong post-resume wasn't noticed).Quoted 5 lines
I would, however, prefer the
if()immediately preceding the patch context to be pulled out past the domain_lock()ed region, convert it toswitch(), and add your code. That was, eventual other post- processing for the various map spaces has a consistent, easily extensible home.Quoted 6 lines
I apparently made a fix for this to work on initial boot of a 32-bit PVHVM guest back in September (a change in hvmloader to not zero the wc fields in
shared_info). But I agree I now can't see why it works... But it surely does as it was tested to do so by Konrad.A bit more digging required...
Hmm I can't find any confirmation that my patch actually *did* work. :( I'm sure I remember testing it though!
Quoted 8 lines
My suggestion is we do indeed remove the inner
if()inlatch_shinfo_size(). Ie. Callupdate_domain_wallclock_time()even if shinfo size has apparently not changed.We only latch shinfo size on hypercall page initialisation and on setup of the callback irq. They are start-of-day/resume operations, so removing the
if()should have no bad side effect that I can see. If nothing else it should make this wallclock-field setup more robust.
I can't see anything bad with this either, so let's go that route if it fixes Roger's problem.
Jan
Quoted 27 lines · Keir Fraser
Quoted 25 lines · Keir Fraser
Quoted 12 lines · Jan Beulich
Quoted 3 lines
Would it be OK to call
update_domain_wallclock_timeunconditionally onhvm_hypercall_page_initialise?The primary question is - why is what we have not enough for you? In particular I would expect that the call from
arch_set_info_guest()(for vCPU 0) should do what you want. Or wait, this is covering PV only. So yes, with the description change I would then withdraw my NACK - apparently no-one really used the shared info wall clock time in a HVM guest so far (or it going wrong post-resume wasn't noticed).Quoted 5 lines
I would, however, prefer the
if()immediately preceding the patch context to be pulled out past the domain_lock()ed region, convert it toswitch(), and add your code. That was, eventual other post- processing for the various map spaces has a consistent, easily extensible home.I apparently made a fix for this to work on initial boot of a 32-bit PVHVM guest back in September (a change in hvmloader to not zero the wc fields in
shared_info). But I agree I now can't see why it works... But it surely does as it was tested to do so by Konrad.
Quoted 4 lines
Quoted 1 line
A bit more digging required...
Hmm I can't find any confirmation that my patch actually *did* work. :( I'm sure I remember testing it though!
I do remember that it did work. The issue was :
Bug 14519356 - SYSTEM TIME DRIFTS DRASTICALLY FOR GUEST WITH UEK2 KERNEL AFTER MIGRATION
Easily reproduced using save.restore.
@ .
@ [root@localhost ~]# uname -a
@ Linux localhost.localdomain 2.6.39-300.7.0.el6uek.i686 #1 SMP Thu Sep 6 @ 12:47:30 EDT 2012 i686 i686 i386 GNU/Linux
@ [root@localhost ~]# date
@ Tue Sep 11 22:38:19 PDT 2012
@ [root@localhost ~]# uptime
@ 09:24:43 up 15590 days, 17:16, 3 users, load average: 2.75, 1.21, 0.47 @ [root@localhost ~]#
@ [root@localhost ~]# date
@ Mon Apr 14 09:24:51 PDT 1919
@ [root@localhost ~]#
So the date went back to 1919.
.. and the reason was the the shared page (which is not re-inited by the kernel) ends up with a large negative delta causing it to go back in time.
Quoted 23 lines
My suggestion is we do indeed remove the inner
if()inlatch_shinfo_size(). Ie. Callupdate_domain_wallclock_time()even if shinfo size has apparently not changed.We only latch shinfo size on hypercall page initialisation and on setup of the callback irq. They are start-of-day/resume operations, so removing the
if()should have no bad side effect that I can see. If nothing else it should make this wallclock-field setup more robust.-- Keir
Quoted 3 lines
-- Keir
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 51 lines · Konrad Rzeszutek Wilk
Quoted 27 lines · Keir Fraser
Quoted 25 lines · Keir Fraser
Quoted 12 lines · Jan Beulich
Quoted 3 lines
Would it be OK to call
update_domain_wallclock_timeunconditionally onhvm_hypercall_page_initialise?The primary question is - why is what we have not enough for you? In particular I would expect that the call from
arch_set_info_guest()(for vCPU 0) should do what you want. Or wait, this is covering PV only. So yes, with the description change I would then withdraw my NACK - apparently no-one really used the shared info wall clock time in a HVM guest so far (or it going wrong post-resume wasn't noticed).Quoted 5 lines
I would, however, prefer the
if()immediately preceding the patch context to be pulled out past the domain_lock()ed region, convert it toswitch(), and add your code. That was, eventual other post- processing for the various map spaces has a consistent, easily extensible home.I apparently made a fix for this to work on initial boot of a 32-bit PVHVM guest back in September (a change in hvmloader to not zero the wc fields in
shared_info). But I agree I now can't see why it works... But it surely does as it was tested to do so by Konrad.Quoted 4 lines
Quoted 1 line
A bit more digging required...
Hmm I can't find any confirmation that my patch actually *did* work. :( I'm sure I remember testing it though!
I do remember that it did work. The issue was :
Bug 14519356 - SYSTEM TIME DRIFTS DRASTICALLY FOR GUEST WITH UEK2 KERNEL AFTER MIGRATIONEasily reproduced using save.restore.
@ .
@ [root@localhost ~]# uname -a
@ Linux localhost.localdomain 2.6.39-300.7.0.el6uek.i686 #1 SMP Thu Sep 6 @ 12:47:30 EDT 2012 i686 i686 i386 GNU/Linux
@ [root@localhost ~]# date
@ Tue Sep 11 22:38:19 PDT 2012
@ [root@localhost ~]# uptime
@ 09:24:43 up 15590 days, 17:16, 3 users, load average: 2.75, 1.21, 0.47 @ [root@localhost ~]#
@ [root@localhost ~]# date
@ Mon Apr 14 09:24:51 PDT 1919
@ [root@localhost ~]#
Quoted 5 lines
So the date went back to 1919.
.. and the reason was the the shared page (which is not re-inited by the kernel) ends up with a large negative delta causing it to go back in time.
What I saw on recent Linux kernels (I think it was 3.9) is that the kernel switches the clocksource from Xen to another available clocksource when it sees an unreasonable drift, so it is not such a big problem with upstream kernels.
Quoted 15 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Roger Pau Monne
The initial values of the wallclock time in the shared info page are set for PVHVM guests when the hypercall page is initialized, since the hypercall page is not reinitialized on resume, the hypervisor wallclock time is not properly set on resume.
Quoted 7 lines
Quoted 2 lines
Fix it by forcing an update of the wallclock values when the shared info page is mapped.
NACK - this is a guest side bug. After migration, a guest _has_ to re-init the hypercall page, as it may have got migrated between a VMX and an SVM machine, and the hypercall instructions are different between them.
Quoted 7 lines
I've re-inited the hypercall page on resume, but the hypervisor wallclock is still 0.
The call to
update_domain_wallclock_timeinhvm_latch_shinfo_sizeis gated, and doesn't get called on the resume path. Would it be OK to callupdate_domain_wallclock_timeunconditionally onhvm_hypercall_page_initialise?
Yes, just posted to confirm this is probably a good fix.
By the by, we also latch_shinfo_size() on setup of HVM_PARAM_CALLBACK_IRQ, and you surely do *that* on PVHVM resume already. So although also re-initialising the hypercall page is also a good idea on the resume path, even guests without that fix should benefit from making the call in latch_shinfo_size() unconditional.
-- Keir