[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86/nSVM: Save L2's CR4 on #VMEXIT, not Xen's



>> On 23.09.2026 11:51, Lin Liu wrote:
>> --- a/xen/arch/x86/hvm/svm/nestedsvm.c
>> +++ b/xen/arch/x86/hvm/svm/nestedsvm.c
>> @@ -1082,7 +1082,7 @@ nsvm_vmcb_prepare4vmexit(struct vcpu *v, struct 
>> cpu_user_regs *regs)
>>      ns_vmcb->_efer = n2vmcb->_efer;
>>  
>>      /* CRn */
>> -    ns_vmcb->_cr4 = n2vmcb->_cr4;
>> +    ns_vmcb->_cr4 = v->arch.hvm.guest_cr[4];
>>      ns_vmcb->_cr0 = n2vmcb->_cr0;
>
>In addition to mirroring the change to CR0 and EFER, doesn't CR2 also
>need handling the same way? Effectively the inverse direction of anything
>respective that nsvm_vmcb_prepare4vmrun() does?
>
>Jan

CR2 is different, it store the page fault address on #PF.
If #PF happens, xen as hardware emulator, should write back the CR2 as part of
guest state area. so copy from n2vmcb is the right behavior.

I will raise v2 to update all other CRs and EFER.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.