From: Mats Petersson <mats.petersson@citrix.com>
To: xen-devel@lists.xen.org
Subject: Re: How to get a few MSR values from userspace?
Date: Fri, 21 Dec 2012 13:16:12 +0000 [thread overview]
Message-ID: <50D4611C.6030206@citrix.com> (raw)
In-Reply-To: <50D459D3.4040101@gmail.com>
On 21/12/12 12:45, Razvan Cojocaru wrote:
> Hello,
>
> I need access to some MSR values that are not currently being saved in
> struct hvm_hw_cpu. Among them are MSR_IA32_MC0_CTL, MSR_IA32_MISC_ENABLE
> and MSR_IA32_ENERGY_PERF_BIAS.
>
> The way I'm approaching this that I'll patch xen/arch/x86/hvm/vmx/vmx.c
> and xen/arch/x86/hvm/svm/svm.c, and add this in vmx_save_cpu_state() and
> svm_save_cpu_state(), respectively:
>
> hvm_msr_read_intercept(MSR_IA32_MC0_CTL, &data->msr_mc0_ctl);
>
> and so on, for the other registers (after adding the msr_mc0_ctl member
> to struct hvm_hw_cpu, of course). I would also have to do the reverse
> operation (using hvm_msr_write_intercept()) in vmx_load_cpu_state().
>
> My questions:
>
> 1. Does it seem architecturally sound to perform the described
> modifications? Can I use hvm_msr_xxx_intercept() for both the VMX and
> the SVM code?
>
> 2. It seems repetitive to have duplicated code in both
> vmx_save_cpu_state() and svm_save_cpu_state(), does it make more sense
> to have it like that anyway (in case, for example, the SVM way to
> retrieve that register could change in the future)?
>
> 3. Do I need to do additional things so that I won't break anything else?
>
> 4. Is there a better way to achieve what I'm after?
>
> Thanks,
> Razvan Cojocaru
>
I'm not sure I understand what you are trying to achieve (nor am I
convinced I know how to help you, but if I don't understand the question
suffiiciently, I certainly can't advice you on what you can/should do or
can't/shouldn't do), but what MSR's are we talking about - the guest
MSR's or the host MSR's?
In general, Xen is responsible for "real" Machine Check interrupts
(correctible ones), and will then forward this information to the guest
if it has enabled MCE in it's code (via the MCE_SOFTIRQ).
Normally, reading MSR's in usermode is not allowed on bare-metal, so not
sure why you expect this to work in the guest (or Dom0) on top of Xen.
But maybe you don't actually mean userspace as opposed to "kernel mode"?
--
Mats
next prev parent reply other threads:[~2012-12-21 13:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-21 12:45 How to get a few MSR values from userspace? Razvan Cojocaru
2012-12-21 13:16 ` Mats Petersson [this message]
2012-12-21 13:26 ` Razvan Cojocaru
2012-12-21 13:53 ` Jan Beulich
2012-12-21 14:08 ` Razvan Cojocaru
2012-12-21 14:39 ` Mats Petersson
2012-12-21 16:01 ` 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=50D4611C.6030206@citrix.com \
--to=mats.petersson@citrix.com \
--cc=xen-devel@lists.xen.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.