From mboxrd@z Thu Jan 1 00:00:00 1970 From: Razvan Cojocaru Subject: How to get a few MSR values from userspace? Date: Fri, 21 Dec 2012 14:45:07 +0200 Message-ID: <50D459D3.4040101@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org 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