x86/mm/encrypt: Simplify sme_populate_pgd() and sme_populate_pgd_large()
authorKirill A. Shutemov <[email protected]>
Wed, 31 Jan 2018 13:54:03 +0000 (16:54 +0300)
committerIngo Molnar <[email protected]>
Tue, 13 Feb 2018 14:59:49 +0000 (15:59 +0100)
commitaad983913d77af2c3394f29b88d7bb75ebd7d172
treea370c866e1356cf54e14ce98badde98d96973841
parent1cd9c22fee3ac21db52a0997d08cf2f065d2c0c0
x86/mm/encrypt: Simplify sme_populate_pgd() and sme_populate_pgd_large()

sme_populate_pgd() and sme_populate_pgd_large() operate on the identity
mapping, which means they want virtual addresses to be equal to physical
one, without PAGE_OFFSET shift.

We also need to avoid paravirtualization call there.

Getting this done is tricky. We cannot use usual page table helpers.
It forces us to open-code a lot of things. It makes code ugly and hard
to modify.

We can get it work with the page table helpers, but it requires few
preprocessor tricks.

  - Define __pa() and __va() to be compatible with identity mapping.

  - Undef CONFIG_PARAVIRT and CONFIG_PARAVIRT_SPINLOCKS before including
    any file. This way we can avoid paravirtualization calls.

Now we can user normal page table helpers just fine.

Tested-by: Tom Lendacky <[email protected]>
Signed-off-by: Kirill A. Shutemov <[email protected]>
Reviewed-by: Tom Lendacky <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
arch/x86/mm/mem_encrypt_identity.c