On 1/12/21 5:09 AM, Maxim Levitsky wrote:
On Tue, 2021-01-12 at 00:37 -0600, Wei Huang wrote:
From: Bandan Das <bsd@xxxxxxxxxx>
While running VM related instructions (VMRUN/VMSAVE/VMLOAD), some AMD
CPUs check EAX against reserved memory regions (e.g. SMM memory on host)
before checking VMCB's instruction intercept. If EAX falls into such
memory areas, #GP is triggered before VMEXIT. This causes problem under
nested virtualization. To solve this problem, KVM needs to trap #GP and
check the instructions triggering #GP. For VM execution instructions,
KVM emulates these instructions; otherwise it re-injects #GP back to
guest VMs.
Signed-off-by: Bandan Das <bsd@xxxxxxxxxx>
Co-developed-by: Wei Huang <wei.huang2@xxxxxxx>
Signed-off-by: Wei Huang <wei.huang2@xxxxxxx>
This is the ultimate fix for this bug that I had in mind,
but I didn't dare to develop it, thinking it won't be accepted
due to the added complexity.
From a cursory look this look all right, and I will review
and test this either today or tomorrow.
My tests mainly relied on the kvm-unit-test you developed (thanks BTW),
on machines w/ and w/o CPUID_0x8000000A_EDX[28]=1. Both cases passed.