x86/hvm: Don't ignore unknown MSRs in the migration stream
PATCH 1/1 x86/hvm: Don't ignore unknown MSRs in the migration stream
Doing so amounts to silent state corruption, and must be avoided.
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>
CC: Boris Ostrovsky <[email protected]>
CC: Suravee Suthikulpanit <[email protected]>
CC: Julien Grall <[email protected]>
This wants backporting to all stable trees, so should also be considered for inclusion into 4.10 at this point.
--- xen/arch/x86/hvm/svm/svm.c | 2 +- xen/arch/x86/hvm/vmx/vmx.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/svm/svm.c +1 -1
@@ -450,7 +450,7 @@ static int svm_load_msr(struct vcpu *v, struct hvm_msr *ctxt)break ;default : -continue ; + err = -ENXIO ; }if ( err )break ;
xen/arch/x86/hvm/vmx/vmx.c +2 -1
@@ -954,8 +954,9 @@ static int vmx_load_msr(struct vcpu *v, struct hvm_msr *ctxt)else err = -ENXIO ;break ; +default : -continue ; + err = -ENXIO ; }if ( err )break ;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 3 lines · Andrew Cooper
Doing so amounts to silent state corruption, and must be avoided.
Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 16.11.17 at 20:15, <[email protected]> wrote:
Doing so amounts to silent state corruption, and must be avoided.
I think a little more explanation is needed on why the current code is insufficient. Note specifically this
for ( i = 0; !err && i < ctxt->count; ++i )
{
switch ( ctxt->msr[i].index )
{
default:
if ( !ctxt->msr[i]._rsvd )
err = -ENXIO;
break;
}
}in hvm_load_cpu_msrs(), intended to give vendor code a first shot, but allowing for vendor independent MSRs to be handled here.
xen/arch/x86/hvm/svm/svm.c static int svm_load_msr(struct vcpu *v, struct hvm_msr *ctxt) · line 454
Quoted 9 lines
xen/arch/x86/hvm/svm/svm.c +1
-1@@ -450,7 +450,7 @@ static int svm_load_msr(struct vcpu *v, struct hvm_msr *ctxt)break ;default : -continue ; + err = -ENXIO ; }
If the change was nevertheless needed, please add break statements here (and in VMX code as well), despite this currently being the last label in the switch() block.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 16 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 16.11.17 at 20:15, <[email protected]> wrote:
Doing so amounts to silent state corruption, and must be avoided.
I think a little more explanation is needed on why the current code is insufficient. Note specifically this
for ( i = 0; !err && i < ctxt->count; ++i ) { switch ( ctxt->msr[i].index ) { default: if ( !ctxt->msr[i]._rsvd ) err = -ENXIO; break; } }
Quoted 3 lines
in
hvm_load_cpu_msrs(), intended to give vendor code a first shot, but allowing for vendor independent MSRs to be handled here.
That is sufficiently subtle and non-obvious that I'm still having a hard time convincing myself that its correct. Also, this use of _rsvd really should be document.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 20.11.17 at 15:10, <[email protected]> wrote:
Quoted 16 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 16.11.17 at 20:15, <[email protected]> wrote:
Doing so amounts to silent state corruption, and must be avoided.
I think a little more explanation is needed on why the current code is insufficient. Note specifically this
for ( i = 0; !err && i < ctxt->count; ++i ) { switch ( ctxt->msr[i].index ) { default: if ( !ctxt->msr[i]._rsvd ) err = -ENXIO; break; } }
Quoted 7 lines
Quoted 3 lines
in
hvm_load_cpu_msrs(), intended to give vendor code a first shot, but allowing for vendor independent MSRs to be handled here.That is sufficiently subtle and non-obvious that I'm still having a hard time convincing myself that its correct. Also, this use of
_rsvdreally should be document.
Well, from an abstract pov I agree. The field being defined in the public interface though, I don't see a good place where to document that - its point of declaration certainly isn't the right one in such a case, as the public interface should not document implementation details.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 15 lines
From: Andrew Cooper [mailto:[email protected]]
Sent: Friday, November 17, 2017 3:16 AMDoing so amounts to silent state corruption, and must be avoided.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>
CC: Boris Ostrovsky <[email protected]>
CC: Suravee Suthikulpanit <[email protected]>
CC: Julien Grall <[email protected]>
Quoted 2 lines
This wants backporting to all stable trees, so should also be considered for inclusion into 4.10 at this point.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel