jonomango / hv

Lightweight Intel VT-x Hypervisor.
MIT License
387 stars 78 forks source link

Why Host_CR3 not set __readcr3() #39

Closed 1034063174 closed 1 year ago

1034063174 commented 1 year ago

hi, I'm learning about vt and trying to understand what each line of code in your code means, but I see that your VMCS_HOST_CR3 is different from what I've seen from other codes other people code is __vmx_vmwrite(VMCS_HOST_CR3, __readcr3());

You alloc a new memory ,I don't understand why this is done。Can you give me some reference directions?

jonomango commented 1 year ago

Yes, those hypervisors are sharing their page-tables with the guest, which is a bad idea. Sharing any state with the guest is bad in general since it gives them control over your hypervisor. For example, page-table trashing is only possible if you share the same page-tables as the guest... it is better to make your own.