XSA-60 - how to get back to a sane state
All,
Jinsong's patches having been in for nearly a month now, but not being in a shape that would make releasing in 4.4 or backporting to the older trees desirable, we need to come to a conclusion on which way to go. Currently it looks like we have three options, but of course I'll be happy to see other (better!) ones proposed.
1) Stay with what we have.
2) Revert 86d60e85 ("VMX: flush cache when vmentry back to UC guest") in its entirety plus, perhaps, the change 62652c00 ("VMX:
fix cr0.cd handling") did to vmx_ctxt_switch_to().
3) Apply the attached patch that Andrew and I have been putting together, with the caveat that it's still incomplete (see below).
The latter two are based on the observation that the amount of cache flushing we do with what is in the master tree right now is more than what we did prior to that patch series but still insufficient. Hence the revert would get us back to the earlier state (and obviously eliminate the performance problems that were observed when doing too eager flushing), whereas applying the extra 5th patch would get us closer to a proper solution.
The problem with that new patch is it's - as said - still incomplete, yet setting ->arch.hvm_vcpu.hypervisor_access_uc_hvm_memory for all writes through map_domain_page_global() mappings would get rather ugly:
- guest_walk_tables() (accumulating set_ad_bits() results)
- all writes through vcpu_info()
- event_fifo.c would need this scattered around
- hvm_load_segment_selector()'s setting of the accessed bit
- hvm_task_switch()'s handling of the busy bit
- all the nested HVM code's writes through ->nv_vvmcx
Plus the performance effects of it aren't really known yet (all we do know is that the too eager "flush always prior to VM entry" is causing unacceptable stalls).
Otoh we have had no reports that the lack of proper cache flushing actually caused any problems, and hence reverting the partial flushing introduced isn't likely to push new problems onto people. Yet if, ever, such a problem would surface, it can be expected to be very hard to diagnose.
Please, everyone having an opinion here - voice it.
Thanks, Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 17 lines · Jan Beulich
All,
Jinsong's patches having been in for nearly a month now, but not being in a shape that would make releasing in 4.4 or backporting to the older trees desirable, we need to come to a conclusion on which way to go. Currently it looks like we have three options, but of course I'll be happy to see other (better!) ones proposed.
1) Stay with what we have.
2) Revert
86d60e85("VMX: flush cache when vmentry back to UC guest") in its entirety plus, perhaps, the change62652c00("VMX:
fix cr0.cd handling") did tovmx_ctxt_switch_to().3) Apply the attached patch that Andrew and I have been putting together, with the caveat that it's still incomplete (see below).
Quoted 8 lines
The latter two are based on the observation that the amount of cache flushing we do with what is in the master tree right now is more than what we did prior to that patch series but still insufficient. Hence the revert would get us back to the earlier state (and obviously eliminate the performance problems that were observed when doing too eager flushing), whereas applying the extra 5th patch would get us closer to a proper solution.
What's missing is a description of the pros and cons of 1 and 2. Do you have any links to threads describing the problem?
-George
Quoted 27 lines · George Dunlap
Quoted 17 lines · Jan Beulich
All,
Jinsong's patches having been in for nearly a month now, but not being in a shape that would make releasing in 4.4 or backporting to the older trees desirable, we need to come to a conclusion on which way to go. Currently it looks like we have three options, but of course I'll be happy to see other (better!) ones proposed.
1) Stay with what we have.
2) Revert
86d60e85("VMX: flush cache when vmentry back to UC guest") in its entirety plus, perhaps, the change62652c00("VMX:
fix cr0.cd handling") did tovmx_ctxt_switch_to().3) Apply the attached patch that Andrew and I have been putting together, with the caveat that it's still incomplete (see below).
Quoted 8 lines
The latter two are based on the observation that the amount of cache flushing we do with what is in the master tree right now is more than what we did prior to that patch series but still insufficient. Hence the revert would get us back to the earlier state (and obviously eliminate the performance problems that were observed when doing too eager flushing), whereas applying the extra 5th patch would get us closer to a proper solution.
Quoted 5 lines
What's missing is a description of the pros and cons of 1 and 2. Do you have any links to threads describing the problem?
-George
1) has the basic XSA-60 fixes and some wbinvd()s, which are a significant performance issue and insufficient to completely fix the problem at hand. As a result, 1) is the worst possible option to stay with as far as Xen is concerned (irrespective of the upcoming 4.4 release).
2) will revert us back to the basic XSA-60 with none of the wbinvd()s, which fixes the security issue and is no worse than before in terms of a correctness-in-the-case-of-uncachable-hvm-domains point of view.
3) as-is is still insufficient to fix the problem in 1), and would currently result in a further performance regression.
FWIW, my vote is for option 2) which will ease the current performance regression, in favor of allowing us time to come up with a proper solution to the pre-existing problem of Xen and Qemu mappings of a UC domain's memory.
~Andrew
Quoted 47 lines · Andrew Cooper
Quoted 27 lines · George Dunlap
Quoted 17 lines · Jan Beulich
All,
Jinsong's patches having been in for nearly a month now, but not being in a shape that would make releasing in 4.4 or backporting to the older trees desirable, we need to come to a conclusion on which way to go. Currently it looks like we have three options, but of course I'll be happy to see other (better!) ones proposed.
1) Stay with what we have.
2) Revert
86d60e85("VMX: flush cache when vmentry back to UC guest") in its entirety plus, perhaps, the change62652c00("VMX:
fix cr0.cd handling") did tovmx_ctxt_switch_to().3) Apply the attached patch that Andrew and I have been putting together, with the caveat that it's still incomplete (see below).
Quoted 8 lines
The latter two are based on the observation that the amount of cache flushing we do with what is in the master tree right now is more than what we did prior to that patch series but still insufficient. Hence the revert would get us back to the earlier state (and obviously eliminate the performance problems that were observed when doing too eager flushing), whereas applying the extra 5th patch would get us closer to a proper solution.
Quoted 5 lines
What's missing is a description of the pros and cons of 1 and 2. Do you have any links to threads describing the problem?
-George
1) has the basic XSA-60 fixes and some wbinvd()s, which are a significant performance issue and insufficient to completely fix the problem at hand. As a result, 1) is the worst possible option to stay with as far as Xen is concerned (irrespective of the upcoming 4.4 release).
2) will revert us back to the basic XSA-60 with none of the wbinvd()s, which fixes the security issue and is no worse than before in terms of a correctness-in-the-case-of-uncachable-hvm-domains point of view.
3) as-is is still insufficient to fix the problem in 1), and would currently result in a further performance regression.
Quoted 6 lines
FWIW, my vote is for option 2) which will ease the current performance regression, in favor of allowing us time to come up with a proper solution to the pre-existing problem of Xen and Qemu mappings of a UC domain's memory.
~Andrew
I also vote option 2, but only revert 86d60e85, keeping 62652c00 (wbinvd at vmx_ctxt_switch_to) since it's used to avoid being polluted when vcpu migrate to another cpu.
Thanks,
Jinsong
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Jinsong
I also vote option 2, but only revert
86d60e85, keeping62652c00(wbinvd atvmx_ctxt_switch_to) since it's used to avoid being polluted when vcpu migrate to another cpu.
Please explain this in more detail. Both Andrew and I are concerned about this extra, but pretty pointless (without being done so too in other cases) wbinvd(). In particular you'd have to explain what its counterpart was in the code prior to your four patch XSA-60 series.
Jan
Quoted 11 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Jinsong
I also vote option 2, but only revert
86d60e85, keeping62652c00(wbinvd atvmx_ctxt_switch_to) since it's used to avoid being polluted when vcpu migrate to another cpu.Please explain this in more detail. Both Andrew and I are concerned about this extra, but pretty pointless (without being done so too in other cases)
wbinvd(). In particular you'd have to explain what its counterpart was in the code prior to your four patch XSA-60 series.Jan
The wbinvd at vmx_ctxt_switch_to is for case like
1. vcpu runs at cpu A, flushing cache at vmx_handle_cd;
2. then the vcpu may switch out and migrate to cpu B;
3. historically cpu B may has cacheline polluted; so when the vcpu is scheduled to cpu B, we need flush cache.
Thanks,
Jinsong
Quoted 12 lines
Quoted 1 line
Quoted 1 line · Jinsong
Quoted 9 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Jinsong
I also vote option 2, but only revert
86d60e85, keeping62652c00(wbinvd atvmx_ctxt_switch_to) since it's used to avoid being polluted when vcpu migrate to another cpu.Please explain this in more detail. Both Andrew and I are concerned about this extra, but pretty pointless (without being done so too in other cases)
wbinvd(). In particular you'd have to explain what its counterpart was in the code prior to your four patch XSA-60 series.
Quoted 5 lines
The wbinvd at
vmx_ctxt_switch_tois for case like
1. vcpu runs at cpu A, flushing cache atvmx_handle_cd;
2. then the vcpu may switch out and migrate to cpu B;
3. historically cpu B may has cacheline polluted; so when the vcpu is scheduled to cpu B, we need flush cache.
But you didn't clarify whether/how this case was taken care of _before_ your XSA-60 patches.
Jan
Quoted 12 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · Jinsong
Quoted 9 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Jinsong
I also vote option 2, but only revert
86d60e85, keeping62652c00(wbinvd atvmx_ctxt_switch_to) since it's used to avoid being polluted when vcpu migrate to another cpu.Please explain this in more detail. Both Andrew and I are concerned about this extra, but pretty pointless (without being done so too in other cases)
wbinvd(). In particular you'd have to explain what its counterpart was in the code prior to your four patch XSA-60 series.
Quoted 8 lines
Quoted 5 lines
The wbinvd at
vmx_ctxt_switch_tois for case like
1. vcpu runs at cpu A, flushing cache atvmx_handle_cd;
2. then the vcpu may switch out and migrate to cpu B;
3. historically cpu B may has cacheline polluted; so when the vcpu is scheduled to cpu B, we need flush cache.But you didn't clarify whether/how this case was taken care of _before_ your XSA-60 patches.
Is this still about guests doing wbinvd? As Jan said, there is no point in doing wbinvd piecemeal: if it's not 100% reliable (to the best of our knowledge), then the more unreliable the better really.
-George
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · Jinsong
Quoted 10 lines · Jan Beulich
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
On 03.12.13 at 04:06, "Liu, Jinsong" <[email protected]> wrote:
I also vote option 2, but only revert
86d60e85, keeping62652c00(wbinvd atvmx_ctxt_switch_to) since it's used to avoid being polluted when vcpu migrate to another cpu.Please explain this in more detail. Both Andrew and I are concerned about this extra, but pretty pointless (without being done so too in other cases)
wbinvd(). In particular you'd have to explain what its counterpart was in the code prior to your four patch XSA-60 series.
Quoted 9 lines
Quoted 5 lines
The wbinvd at
vmx_ctxt_switch_tois for case like
1. vcpu runs at cpu A, flushing cache atvmx_handle_cd;
2. then the vcpu may switch out and migrate to cpu B;
3. historically cpu B may has cacheline polluted; so when the vcpu is scheduled to cpu B, we need flush cache.But you didn't clarify whether/how this case was taken care of _before_ your XSA-60 patches.
I didn't understand your question. What do you mean by 'before my XSA-60 patches'?
Thanks,
Jinsong
Quoted 21 lines
Quoted 1 line
Quoted 1 line · Jinsong
Quoted 19 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · Jinsong
Quoted 10 lines · Jan Beulich
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
On 03.12.13 at 04:06, "Liu, Jinsong" <[email protected]> wrote:
I also vote option 2, but only revert
86d60e85, keeping62652c00(wbinvd atvmx_ctxt_switch_to) since it's used to avoid being polluted when vcpu migrate to another cpu.Please explain this in more detail. Both Andrew and I are concerned about this extra, but pretty pointless (without being done so too in other cases)
wbinvd(). In particular you'd have to explain what its counterpart was in the code prior to your four patch XSA-60 series.The wbinvd at
vmx_ctxt_switch_tois for case like
1. vcpu runs at cpu A, flushing cache atvmx_handle_cd;
2. then the vcpu may switch out and migrate to cpu B;
3. historically cpu B may has cacheline polluted; so when the vcpu is scheduled to cpu B, we need flush cache.
Quoted 6 lines
Quoted 3 lines
But you didn't clarify whether/how this case was taken care of _before_ your XSA-60 patches.
I didn't understand your question. What do you mean by 'before my XSA-60 patches'?
Before your 4 patch series was applied (e.g. consider plain 4.3.1) - how was the situation taken care of that your change to vmx_ctxt_switch_to() is intended to deal with?
Jan
Quoted 18 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · Jinsong
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · Jinsong
Quoted 9 lines · Jan Beulich
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
On 03.12.13 at 04:06, "Liu, Jinsong" <[email protected]> wrote:
I also vote option 2, but only revert
86d60e85, keeping62652c00(wbinvd atvmx_ctxt_switch_to) since it's used to avoid being polluted when vcpu migrate to another cpu.Please explain this in more detail. Both Andrew and I are concerned about this extra, but pretty pointless (without being done so too in other cases)
wbinvd(). In particular you'd have to explain what its counterpart was in the code prior to your four patch XSA-60 series.The wbinvd at
vmx_ctxt_switch_tois for case like
1. vcpu runs at cpu A, flushing cache atvmx_handle_cd;
2. then the vcpu may switch out and migrate to cpu B;
3. historically cpu B may has cacheline polluted; so when the vcpu is scheduled to cpu B, we need flush cache.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
But you didn't clarify whether/how this case was taken care of _before_ your XSA-60 patches.
I didn't understand your question. What do you mean by 'before my XSA-60 patches'?
Before your 4 patch series was applied (e.g. consider plain 4.3.1) - how was the situation taken care of that your change to
vmx_ctxt_switch_to()is intended to deal with?
It sounds like Jan is saying: We would only consider a patch that would fix regressions in functionality caused by the 4-patch XSA-60 series. Was there the possibility for cacheline pollution in the scenario you describe above before XSA-60 was fixed? If not, then this is a regression and we might consider a patch to restore that functionality. If there was the possibility of the above scenario before the XSA-60 series, then it's not a regression; and therefore probably not something we want to accept at this point.
Do I understand you properly, Jan?
-George
Quoted 38 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 18 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · Jinsong
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · Jinsong
Quoted 9 lines · Jan Beulich
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
On 03.12.13 at 04:06, "Liu, Jinsong" <[email protected]> wrote:
I also vote option 2, but only revert
86d60e85, keeping62652c00(wbinvd atvmx_ctxt_switch_to) since it's used to avoid being polluted when vcpu migrate to another cpu.Please explain this in more detail. Both Andrew and I are concerned about this extra, but pretty pointless (without being done so too in other cases)
wbinvd(). In particular you'd have to explain what its counterpart was in the code prior to your four patch XSA-60 series.The wbinvd at
vmx_ctxt_switch_tois for case like
1. vcpu runs at cpu A, flushing cache atvmx_handle_cd;
2. then the vcpu may switch out and migrate to cpu B;
3. historically cpu B may has cacheline polluted; so when the vcpu is scheduled to cpu B, we need flush cache.Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
But you didn't clarify whether/how this case was taken care of _before_ your XSA-60 patches.
I didn't understand your question. What do you mean by 'before my XSA-60 patches'?
Before your 4 patch series was applied (e.g. consider plain 4.3.1) - how was the situation taken care of that your change to
vmx_ctxt_switch_to()is intended to deal with?It sounds like Jan is saying: We would only consider a patch that would fix regressions in functionality caused by the 4-patch XSA-60 series. Was there the possibility for cacheline pollution in the scenario you describe above before XSA-60 was fixed? If not, then this is a regression and we might consider a patch to restore that functionality. If there was the possibility of the above scenario before the XSA-60 series, then it's not a regression; and therefore probably not something we want to accept at this point.
Quoted 1 line
Do I understand you properly, Jan?
Yes, thanks for wording it in yet another way.
Jan
Quoted 27 lines · Jan Beulich
Quoted 27 lines
Quoted 1 line
Quoted 1 line · Jinsong
Quoted 24 lines · Jan Beulich
Quoted 15 lines
Quoted 2 lines
Quoted 2 lines
On 03.12.13 at 15:30, "Liu, Jinsong" <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
On 03.12.13 at 04:06, "Liu, Jinsong" <[email protected]> wrote:
I also vote option 2, but only revert
86d60e85, keeping62652c00(wbinvd atvmx_ctxt_switch_to) since it's used to avoid being polluted when vcpu migrate to another cpu.Please explain this in more detail. Both Andrew and I are concerned about this extra, but pretty pointless (without being done so too in other cases)
wbinvd(). In particular you'd have to explain what its counterpart was in the code prior to your four patch XSA-60 series.Quoted 5 lines
The wbinvd at
vmx_ctxt_switch_tois for case like
1. vcpu runs at cpu A, flushing cache atvmx_handle_cd;
2. then the vcpu may switch out and migrate to cpu B;
3. historically cpu B may has cacheline polluted; so when the vcpu is scheduled to cpu B, we need flush cache.But you didn't clarify whether/how this case was taken care of _before_ your XSA-60 patches.
Quoted 7 lines
Quoted 2 lines
I didn't understand your question. What do you mean by 'before my XSA-60 patches'?
Before your 4 patch series was applied (e.g. consider plain 4.3.1) - how was the situation taken care of that your change to
vmx_ctxt_switch_to()is intended to deal with?
Before my 4 patches (in fact before the 3rd patch 62652c00), Xen just didn't take care of the case. Notice that wbinvd at vmx_ctxt_switch_to is for a corner case (when uc mode).
Thanks,
Jinsong
Quoted 5 lines
Quoted 1 line
Quoted 1 line · Jinsong
Before my 4 patches (in fact before the 3rd patch
62652c00), Xen just didn't take care of the case.
Notice that wbinvd atvmx_ctxt_switch_tois for a corner case (when uc mode).
That's what my thinking was. And hence the intention to revert it as being incomplete anyway. Once we find a need to do the flushing, we'd need to bite the bullet and fix all of the possible cases, not just some of them.
Are we on the same page now?
Jan
Quoted 10 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Jinsong
Before my 4 patches (in fact before the 3rd patch
62652c00), Xen just didn't take care of the case. Notice that wbinvd atvmx_ctxt_switch_tois for a corner case (when uc mode).That's what my thinking was. And hence the intention to revert it as being incomplete anyway. Once we find a need to do the flushing, we'd need to bite the bullet and fix all of the possible cases, not just some of them.
Quoted 4 lines
Are we on the same page now?
From this point, yes. I don't insist keeping that wbinvd.
Thanks,
Jinsong
Quoted 5 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
1) has the basic XSA-60 fixes and some wbinvd()s, which are a significant performance issue and insufficient to completely fix the problem at hand. As a result, 1) is the worst possible option to stay with as far as Xen is concerned (irrespective of the upcoming 4.4 release).
I should add that another aspect here is the current inconsistency of the code: In a few places we give the appearance of taking care of the required flushing, but we don't really do so everywhere, so whoever is going to read the code in close detail will rightfully say "this can't be correct". Whereas if we revert the wbinvd()s we're at least back to a consistent (even if theoretically broken) state.
Quoted 3 lines
2) will revert us back to the basic XSA-60 with none of the wbinvd()s, which fixes the security issue and is no worse than before in terms of a correctness-in-the-case-of-uncachable-hvm-domains point of view.
And keep in mind that at present we have no knowledge of guests actually needing to run with caching disabled - to only known use case is that of the guest setting its MTRRs (where the specification requires caching to be disabled, but the OS [as well as correctness] doesn't really require that).
Quoted 2 lines
3) as-is is still insufficient to fix the problem in 1), and would currently result in a further performance regression.
Hmm, I'm not sure about the performance regression: During the sole known usage (see above) there shouldn't be any guest memory writes, and hence the "needs-flushing" flag should rarely if ever get set.
Quoted 4 lines
FWIW, my vote is for option 2) which will ease the current performance regression, in favor of allowing us time to come up with a proper solution to the pre-existing problem of Xen and Qemu mappings of a UC domain's memory.
Agreed - my preference too is 2 over 3 over 1.
Jan