I added code in the hypervisor to manipulate MSR. Here is my code in emulate_privileged_op() in the Xen hypervisor: .... // for WRMSR case MSR_P4_IQ_PERFCTR0: case MSR_P4_IQ_CCCR0: case MSR_P4_CRU_ESCR0: case MSR_P4_IQ_PERFCTR2: case MSR_P4_IQ_CCCR2: case MSR_P4_CRU_ESCR1: wrmsr_safe(regs->ecx, eax, edx); break; ...... // for RDMSR case MSR_P4_IQ_PERFCTR0: case MSR_P4_IQ_CCCR0: case MSR_P4_CRU_ESCR0: case MSR_P4_IQ_PERFCTR2: case MSR_P4_IQ_CCCR2: case MSR_P4_CRU_ESCR1: printk("the_cs = 0x%x\n", the_cs); __asm__ volatile( "mov %%cs, %0\n" :"=r"(the_cs) : ); printk("the_cs = 0x%x\n", the_cs); rdmsr_safe(regs->ecx, regs->eax, regs->edx); break; The wrmsr_safe() and rdmsr_safe() trigger a general protection fault, and the value read from the msr is 0. But I printed out the cs descriptor, and found the CPL is 0. Why there is a general protection fault here? How can I fix this? thanks, long _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
I first used wrmsr_safe() to write a non-zero value into the msr (MSR_P4_IQ_PERFCTR0), and then read the msr by rdmsr_safe(). But zero is read. long On Fri, Oct 8, 2010 at 4:42 PM, Long Wang <longwang.longwang@gmail.com> wrote:> I added code in the hypervisor to manipulate MSR. Here is my code in > emulate_privileged_op() in the Xen hypervisor: > > .... > // for WRMSR > case MSR_P4_IQ_PERFCTR0: > case MSR_P4_IQ_CCCR0: > case MSR_P4_CRU_ESCR0: > case MSR_P4_IQ_PERFCTR2: > case MSR_P4_IQ_CCCR2: > case MSR_P4_CRU_ESCR1: > wrmsr_safe(regs->ecx, eax, edx); > break; > ...... > // for RDMSR > case MSR_P4_IQ_PERFCTR0: > case MSR_P4_IQ_CCCR0: > case MSR_P4_CRU_ESCR0: > case MSR_P4_IQ_PERFCTR2: > case MSR_P4_IQ_CCCR2: > case MSR_P4_CRU_ESCR1: > printk("the_cs = 0x%x\n", the_cs); > __asm__ volatile( > "mov %%cs, %0\n" > :"=r"(the_cs) > : > ); > printk("the_cs = 0x%x\n", the_cs); > rdmsr_safe(regs->ecx, regs->eax, regs->edx); > break; > > > The wrmsr_safe() and rdmsr_safe() trigger a general protection fault, > and the value read from the msr is 0. But I printed out the cs > descriptor, and found the CPL is 0. Why there is a general protection > fault here? How can I fix this? > > thanks, > long >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
I added code in the hypervisor to manipulate MSR. Here is my code in emulate_privileged_op() in the Xen hypervisor: .... // for WRMSR case MSR_P4_IQ_PERFCTR0: case MSR_P4_IQ_CCCR0: case MSR_P4_CRU_ESCR0: case MSR_P4_IQ_PERFCTR2: case MSR_P4_IQ_CCCR2: case MSR_P4_CRU_ESCR1: wrmsr_safe(regs->ecx, eax, edx); break; ...... // for RDMSR case MSR_P4_IQ_PERFCTR0: case MSR_P4_IQ_CCCR0: case MSR_P4_CRU_ESCR0: case MSR_P4_IQ_PERFCTR2: case MSR_P4_IQ_CCCR2: case MSR_P4_CRU_ESCR1: printk("the_cs = 0x%x\n", the_cs); __asm__ volatile( "mov %%cs, %0\n" :"=r"(the_cs) : ); printk("the_cs = 0x%x\n", the_cs); rdmsr_safe(regs->ecx, regs->eax, regs->edx); break; The wrmsr_safe() and rdmsr_safe() trigger a general protection fault, and the value read from the msr is 0. But I printed out the cs descriptor, and found the CPL is 0. Why there is a general protection fault here? How can I fix this? thanks, long _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jiang, Yunhong
2010-Oct-11 00:38 UTC
RE: [Xen-devel] Re: problem in using MSR in the hypervisor
Are the MSRs invalid in the system? Invalid here means reserved or unimplemented MSR. Thanks --jyh>-----Original Message----- >From: xen-devel-bounces@lists.xensource.com >[mailto:xen-devel-bounces@lists.xensource.com] On Behalf Of Long Wang >Sent: Sunday, October 10, 2010 3:26 AM >To: xen-devel@lists.xensource.com >Subject: [Xen-devel] Re: problem in using MSR in the hypervisor > >I added code in the hypervisor to manipulate MSR. Here is my code in >emulate_privileged_op() in the Xen hypervisor: > >.... > // for WRMSR > case MSR_P4_IQ_PERFCTR0: > case MSR_P4_IQ_CCCR0: > case MSR_P4_CRU_ESCR0: > case MSR_P4_IQ_PERFCTR2: > case MSR_P4_IQ_CCCR2: > case MSR_P4_CRU_ESCR1: > wrmsr_safe(regs->ecx, eax, edx); > break; >...... > // for RDMSR > case MSR_P4_IQ_PERFCTR0: > case MSR_P4_IQ_CCCR0: > case MSR_P4_CRU_ESCR0: > case MSR_P4_IQ_PERFCTR2: > case MSR_P4_IQ_CCCR2: > case MSR_P4_CRU_ESCR1: > printk("the_cs = 0x%x\n", the_cs); > __asm__ volatile( > "mov %%cs, %0\n" > :"=r"(the_cs) > : > ); > printk("the_cs = 0x%x\n", the_cs); > rdmsr_safe(regs->ecx, regs->eax, regs->edx); > break; > > >The wrmsr_safe() and rdmsr_safe() trigger a general protection fault, >and the value read from the msr is 0. But I printed out the cs >descriptor, and found the CPL is 0. Why there is a general protection >fault here? How can I fix this? > > >thanks, >long > >_______________________________________________ >Xen-devel mailing list >Xen-devel@lists.xensource.com >http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel