On 8/26/2025 3:37 PM, Huang, Kai wrote: > On Mon, 2025-08-25 at 15:20 +0000, Nikunj A Dadhania wrote: >> 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. > > Could you add some text to explain why this is related to PML? PML works fine without this and the change is not linked to PML. This can go as a separate fix. While working on PML which was using the snp_safe_alloc_page(), Tom had suggested to apply the alignment workaround only on the CPUs without HvInUseWrAllowed. > >> >> Suggested-by: Tom Lendacky <thomas.lendacky@xxxxxxx> >> Signed-off-by: Nikunj A Dadhania <nikunj@xxxxxxx> >> --- >> 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); >> >> /* Regards, Nikunj