Thread (47 messages) 47 messages, 5 authors, 2022-01-04

RE: [PATCH v3 13/22] kvm: x86: Intercept #NM for saving IA32_XFD_ERR

From: "Tian, Kevin" <kevin.tian@intel.com>
Date: 2021-12-29 06:50:39
Also in: kvm, linux-kselftest, lkml

From: Tian, Kevin
Sent: Wednesday, December 29, 2021 10:53 AM
quoted
quoted
+	case MSR_IA32_XFD:
+		ret = kvm_set_msr_common(vcpu, msr_info);
+		if (!ret && data) {
+			vcpu->arch.trap_nm = true;
+			vmx_update_exception_bitmap(vcpu);
This is wrong, it fails to clear vcpu->arch.trap_nm and update the bitmap if
the
MSR is cleared.
In concept you are right if just looking at this patch. It's pointless to
trap #NM if guest xfd is cleared.

But here we need think about patch22 which disables write interception
for xfd. With that in consideration we use the 1st non-zero write as the
hint indicating that guest might enable xfd-related usages thus always
trap #NM after this point.

It's not a good ordering, but Paolo wants to put the optimization in the
end of this series. But we do need to put a clear comment here explaining
the always-trap policy.
Given write emulation of XFD is not disabled in this patch, it reads cleaner
to always update exception bitmap according to guest xfd value at this
stage. So we will follow your suggestion here and then change to check
msr bitmap when write emulation is disabled in patch22.

Thanks
Kevin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help