x86/msr: add log messages to MSR state load error paths
PATCH 1/1 x86/msr: add log messages to MSR state load error paths
Some error paths in the MSR state loading logic don't contain error messages, which makes debugging them quite hard without adding extra patches to print the information.
Add two new log messages to the MSR state load path that print information about the entry that failed to load.
No functional change intended.
--- xen/arch/x86/hvm/hvm.c | 9 +++++++++ 1 file changed, 9 insertions(+)
xen/arch/x86/hvm/hvm.c +9 -0
@@ -1598,10 +1598,19 @@ static int cf_check hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h) rc =guest_wrmsr (v, ctxt->msr[i].index, ctxt->msr[i].val);if ( rc !=X86EMUL_OKAY ) + { +printk (XENLOG_G_ERR +"HVM%d.%d load MSR %#x with value %#lx failed: %d\n" , + d->domain_id, vcpuid, ctxt->msr[i].index, + ctxt->msr[i].val, rc);return -ENXIO ; + }break ;default : +printk (XENLOG_G_ERR +"HVM%d.%d attempted load of unhandled MSR %#x\n" , + d->domain_id, vcpuid, ctxt->msr[i].index);return -ENXIO ; } }
Signature · 1 line
2.46.0
Quoted 4 lines · Roger Pau Monne
Some error paths in the MSR state loading logic don't contain error messages, which makes debugging them quite hard without adding extra patches to print the information.
Quoted 8 lines
Add two new log messages to the MSR state load path that print information about the entry that failed to load.
No functional change intended.
Signed-off-by Roger Pau Monné <[email protected]>--- xen/arch/x86/hvm/hvm.c | 9 +++++++++
Can we fix the PV side at the same time too?
Quoted 7 lines
1 file changed, 9 insertions(+)xen/arch/x86/hvm/hvm.c +0
-0
xen/arch/x86/hvm/hvm.c static int cf_check hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h) · line 1605
Quoted 8 lines
xen/arch/x86/hvm/hvm.c +5
-0@@ -1598,10 +1598,19 @@ static int cf_check hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h) rc =guest_wrmsr (v, ctxt->msr[i].index, ctxt->msr[i].val);if ( rc !=X86EMUL_OKAY ) + { +printk (XENLOG_G_ERR +"HVM%d.%d load MSR %#x with value %#lx failed: %d\n" , + d->domain_id, vcpuid, ctxt->msr[i].index, + ctxt->msr[i].val, rc);
Just %pv please. I don't want to propagate the (occasionally ambiguous) HVM%d form.
Also, rc may not be great to render. It's an X86EMUL_*, not an errno.
And saying that, we have a discontinuity between PV and HVM. PV translates !OKAY into -EINVAL, whereas HVM translates into -ENXIO. /sigh
~Andrew
Quoted 8 lines · Andrew Cooper
Quoted 7 lines · Roger Pau Monne
Some error paths in the MSR state loading logic don't contain error messages, which makes debugging them quite hard without adding extra patches to print the information.
Add two new log messages to the MSR state load path that print information about the entry that failed to load.
Quoted 7 lines
Quoted 5 lines
No functional change intended.
Signed-off-by Roger Pau Monné <[email protected]>--- xen/arch/x86/hvm/hvm.c | 9 +++++++++Can we fix the PV side at the same time too?
Sure, I think that would be XEN_DOMCTL_set_vcpu_msrs?
I've noticed that such hypercall doesn't return an error if the MSR is not handled by Xen (there's no default case returning an error in the switch that processes the entries to load).
Quoted 9 lines
Quoted 9 lines
1 file changed, 9 insertions(+)xen/arch/x86/hvm/hvm.c +0
-0@@ -1598,10 +1598,19 @@ static int cf_check hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h) rc =guest_wrmsr (v, ctxt->msr[i].index, ctxt->msr[i].val);
Quoted 9 lines
xen/arch/x86/hvm/hvm.c static int cf_check hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h) · line 1605
Quoted 6 lines
xen/arch/x86/hvm/hvm.c +5
-0if ( rc !=X86EMUL_OKAY ) + { +printk (XENLOG_G_ERR +"HVM%d.%d load MSR %#x with value %#lx failed: %d\n" , + d->domain_id, vcpuid, ctxt->msr[i].index, + ctxt->msr[i].val, rc);Just %pv please. I don't want to propagate the (occasionally ambiguous) HVM%d form.
I also wanted to use %pv here, but it will get out of sync (style-wise) with the rest of messages of the HVM context loading logic? IOW: my preference would be to switch all in one go.
Quoted 1 line
Also, rc may not be great to render. It's an X86EMUL_*, not an errno.
Yeah, I know, but at the end it's a message for someone that knows how to debug the code, so if the error code it's X86EMUL_ based it's at least bet than not printing it.
Quoted 2 lines
And saying that, we have a discontinuity between PV and HVM. PV translates !OKAY into
-EINVAL, whereas HVM translates into -ENXIO. /sigh
Hm, great, one thing at a time.
Thanks, Roger.
Quoted 15 lines · Roger Pau Monné
Quoted 14 lines · Andrew Cooper
Quoted 12 lines · Roger Pau Monne
Some error paths in the MSR state loading logic don't contain error messages, which makes debugging them quite hard without adding extra patches to print the information.
Add two new log messages to the MSR state load path that print information about the entry that failed to load.
No functional change intended.
Signed-off-by Roger Pau Monné <[email protected]>--- xen/arch/x86/hvm/hvm.c | 9 +++++++++
Quoted 7 lines
Quoted 1 line
Can we fix the PV side at the same time too?
Sure, I think that would be
XEN_DOMCTL_set_vcpu_msrs?I've noticed that such hypercall doesn't return an error if the MSR is not handled by Xen (there's no default case returning an error in the switch that processes the entries to load).
I see
ret = -EINVAL;
...
switch ( msr.index )
{
...
if ( guest_wrmsr(v, msr.index, msr.value) != X86EMUL_OKAY )
break;
continue;
}
break;which to me means we'll return -EINVAL both when handling an MSR fails (1st "break") and when encountering an unhandled MSR (2nd "break").
Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +0
-0@@ -1598,10 +1598,19 @@ static int cf_check hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h) rc =guest_wrmsr (v, ctxt->msr[i].index, ctxt->msr[i].val);Quoted 9 lines
xen/arch/x86/hvm/hvm.c static int cf_check hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h) · line 1605
Quoted 6 lines
xen/arch/x86/hvm/hvm.c +5
-0if ( rc !=X86EMUL_OKAY ) + { +printk (XENLOG_G_ERR +"HVM%d.%d load MSR %#x with value %#lx failed: %d\n" , + d->domain_id, vcpuid, ctxt->msr[i].index, + ctxt->msr[i].val, rc);Just %pv please. I don't want to propagate the (occasionally ambiguous) HVM%d form.
Quoted 3 lines
I also wanted to use %pv here, but it will get out of sync (style-wise) with the rest of messages of the HVM context loading logic? IOW: my preference would be to switch all in one go.
I deliberately started using %pv when touching hvm_save() somewhat recently. So there is some inconsistency right now anyway, and I guess we'll want to move to the new form as we touch code in this area.
Jan
Quoted 37 lines · Jan Beulich
Quoted 15 lines · Roger Pau Monné
Quoted 14 lines · Andrew Cooper
Quoted 12 lines · Roger Pau Monne
Some error paths in the MSR state loading logic don't contain error messages, which makes debugging them quite hard without adding extra patches to print the information.
Add two new log messages to the MSR state load path that print information about the entry that failed to load.
No functional change intended.
Signed-off-by Roger Pau Monné <[email protected]>--- xen/arch/x86/hvm/hvm.c | 9 +++++++++Quoted 7 lines
Quoted 1 line
Can we fix the PV side at the same time too?
Sure, I think that would be
XEN_DOMCTL_set_vcpu_msrs?I've noticed that such hypercall doesn't return an error if the MSR is not handled by Xen (there's no default case returning an error in the switch that processes the entries to load).
I see
ret = -EINVAL; ... switch ( msr.index ) { ... if ( guest_wrmsr(v, msr.index, msr.value) != X86EMUL_OKAY ) break; continue; } break;
Quoted 2 lines
which to me means we'll return
-EINVALboth when handling an MSR fails (1st "break") and when encountering an unhandled MSR (2nd "break").
Oh, I see, I was expecting a construct similar to the one used in hvm_load_cpu_msrs() and didn't spot that continue. The logic there is very obfuscated IMO.
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
xen/arch/x86/hvm/hvm.c static int cf_check hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h) · line 1605
Quoted 11 lines
xen/arch/x86/hvm/hvm.c +5
-0@@ -1598,10 +1598,19 @@ static int cf_check hvm_load_cpu_msrs(struct domain *d, hvm_domain_context_t *h) rc =guest_wrmsr (v, ctxt->msr[i].index, ctxt->msr[i].val);if ( rc !=X86EMUL_OKAY ) + { +printk (XENLOG_G_ERR +"HVM%d.%d load MSR %#x with value %#lx failed: %d\n" , + d->domain_id, vcpuid, ctxt->msr[i].index, + ctxt->msr[i].val, rc);Just %pv please. I don't want to propagate the (occasionally ambiguous) HVM%d form.
Quoted 7 lines
Quoted 3 lines
I also wanted to use %pv here, but it will get out of sync (style-wise) with the rest of messages of the HVM context loading logic? IOW: my preference would be to switch all in one go.
I deliberately started using %pv when touching
hvm_save()somewhat recently. So there is some inconsistency right now anyway, and I guess we'll want to move to the new form as we touch code in this area.
Ack, will adjust to use "HVM %pv" then.
Thanks, Roger.