When HvInUseWrAllowed (CPUID 8000001F EAX[30]) is supported, the CPU allows hypervisor writes to in-use pages without RMP violations, making the 2MB alignment workaround unnecessary. Check for this capability to avoid the allocation overhead when it's not needed. Suggested-by: Tom Lendacky Signed-off-by: Nikunj A Dadhania --- arch/x86/kvm/svm/sev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 2fbdebf79fbb..c5477efc90b9 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -4666,7 +4666,8 @@ struct page *snp_safe_alloc_page_node(int node, gfp_t gfp) unsigned long pfn; struct page *p; - if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP)) + if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP) || + cpu_feature_enabled(X86_FEATURE_HV_INUSE_WR_ALLOWED)) return alloc_pages_node(node, gfp | __GFP_ZERO, 0); /* -- 2.43.0