Fix sme_populate_pgd() to update page flags if the PMD/PTE entry
already exists.

Signed-off-by: Brijesh Singh <brijesh.si...@amd.com>
Reviewed-by: Tom Lendacky <thomas.lenda...@amd.com>
Cc: Tom Lendacky <thomas.lenda...@amd.com>
Cc: k...@vger.kernel.org
Cc: Thomas Gleixner <t...@linutronix.de>
Cc: Borislav Petkov <b...@suse.de>
Cc: "H. Peter Anvin" <h...@zytor.com>
Cc: linux-kernel@vger.kernel.org
Cc: Paolo Bonzini <pbonz...@redhat.com>
Cc: Sean Christopherson <sean.j.christopher...@intel.com>
Cc: k...@vger.kernel.org
Cc: "Radim Krčmář" <rkrc...@redhat.com>
---
 arch/x86/mm/mem_encrypt_identity.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/x86/mm/mem_encrypt_identity.c 
b/arch/x86/mm/mem_encrypt_identity.c
index 92265d3..7659e65 100644
--- a/arch/x86/mm/mem_encrypt_identity.c
+++ b/arch/x86/mm/mem_encrypt_identity.c
@@ -154,9 +154,6 @@ static void __init sme_populate_pgd_large(struct 
sme_populate_pgd_data *ppd)
                return;
 
        pmd = pmd_offset(pud, ppd->vaddr);
-       if (pmd_large(*pmd))
-               return;
-
        set_pmd(pmd, __pmd(ppd->paddr | ppd->pmd_flags));
 }
 
@@ -182,8 +179,7 @@ static void __init sme_populate_pgd(struct 
sme_populate_pgd_data *ppd)
                return;
 
        pte = pte_offset_map(pmd, ppd->vaddr);
-       if (pte_none(*pte))
-               set_pte(pte, __pte(ppd->paddr | ppd->pte_flags));
+       set_pte(pte, __pte(ppd->paddr | ppd->pte_flags));
 }
 
 static void __init __sme_map_range_pmd(struct sme_populate_pgd_data *ppd)
-- 
2.7.4

Reply via email to