On 4/17/2023 3:24 PM, Chao Gao wrote:
On Tue, Apr 04, 2023 at 09:09:20PM +0800, Binbin Wu wrote:
/* Page table builder macros common to shadow (host) PTEs and guest PTEs. */
+#define __PT_BASE_ADDR_MASK (((1ULL << 52) - 1) & ~(u64)(PAGE_SIZE-1))
This is an open-coded(). So, you'd better use GENMASK_ULL() here.
Here basically is a code move and rename from PT_BASE_ADDR_MASK to
__PT_BASE_ADDR_MASK.
I didn't change the original code, but if it is preferred to use
GENMASK_ULL()
in kernel/KVM, I can change it as following:
#define __PT_BASE_ADDR_MASK GENMASK_ULL(51, 12)
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1260,7 +1260,7 @@ int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
* stuff CR3, e.g. for RSM emulation, and there is no guarantee that
* the current vCPU mode is accurate.
*/
- if (kvm_vcpu_is_illegal_gpa(vcpu, cr3))
+ if (!kvm_vcpu_is_legal_cr3(vcpu, cr3))
I prefer to modify the call sites in SVM nested code to use the new
function. Although this change does not affect functionality, it
provides a clear distinction between CR3 checks and GPA checks.
Make sense, will do it.