From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Roger Pau Monne <roger.pau@citrix.com>,
Jan Beulich <jbeulich@suse.com>,
Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [PATCH v2] x86/msr: add log messages to MSR state load error paths
Date: Tue, 8 Oct 2024 10:37:56 +0200 [thread overview]
Message-ID: <20241008083756.72829-2-roger.pau@citrix.com> (raw)
In-Reply-To: <20241008083756.72829-1-roger.pau@citrix.com>
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, for both PV and HVM.
While there also adjust XEN_DOMCTL_set_vcpu_msrs to return -ENXIO in case the
MSR is unhandled or can't be loaded, so it matches the error code used by HVM
MSR loading (and it's less ambiguous than -EINVAL).
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v1:
- Add messages to PV MSR loading.
- Return -ENXIO from PV loading path also.
- Do not print the return code from guest_wrmsr(), it's not specially helpful
given the current logic, as it will always be X86EMUL_EXCEPTION in case of
failure.
---
xen/arch/x86/domctl.c | 8 ++++++++
xen/arch/x86/hvm/hvm.c | 7 +++++++
2 files changed, 15 insertions(+)
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 96d816cf1a7d..f76de5be9437 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1166,6 +1166,7 @@ long arch_do_domctl(
if ( msr.reserved )
break;
+ ret = -ENXIO;
switch ( msr.index )
{
case MSR_SPEC_CTRL:
@@ -1174,9 +1175,16 @@ long arch_do_domctl(
case MSR_AMD64_DR0_ADDRESS_MASK:
case MSR_AMD64_DR1_ADDRESS_MASK ... MSR_AMD64_DR3_ADDRESS_MASK:
if ( guest_wrmsr(v, msr.index, msr.value) != X86EMUL_OKAY )
+ {
+ printk(XENLOG_G_ERR
+ "%pv load MSR %#x with value %#lx failed\n",
+ v, msr.index, msr.value);
break;
+ }
continue;
}
+ printk(XENLOG_G_ERR "%pv attempted load of unhandled MSR %#x\n",
+ v, msr.index);
break;
}
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 69a25571db8d..200f0a414138 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -1598,10 +1598,17 @@ 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 %pv load MSR %#x with value %#lx failed\n",
+ v, ctxt->msr[i].index, ctxt->msr[i].val);
return -ENXIO;
+ }
break;
default:
+ printk(XENLOG_G_ERR "HVM %pv attempted load of unhandled MSR %#x\n",
+ v, ctxt->msr[i].index);
return -ENXIO;
}
}
--
2.46.0
next prev parent reply other threads:[~2024-10-08 8:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-08 8:37 [PATCH] x86/domctl: fix maximum number of MSRs in XEN_DOMCTL_{get,set}_vcpu_msrs Roger Pau Monne
2024-10-08 8:37 ` Roger Pau Monne [this message]
2024-10-08 9:00 ` [PATCH v2] x86/msr: add log messages to MSR state load error paths Roger Pau Monné
2024-10-08 8:42 ` [PATCH] x86/domctl: fix maximum number of MSRs in XEN_DOMCTL_{get,set}_vcpu_msrs Jan Beulich
-- strict thread matches above, loose matches on Subject: below --
2024-10-08 8:39 [PATCH v2] x86/msr: add log messages to MSR state load error paths Roger Pau Monne
2024-10-08 12:41 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241008083756.72829-2-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.