[PATCH V2 3/3] x86/efi: Use efi_switch_mm() rather than manually twiddling with %cr3

2017-08-28 Thread Sai Praneeth Prakhya
From: Sai Praneeth Use helper function (efi_switch_mm()) to switch to/from efi_mm. We switch to efi_mm before calling 1. efi_set_virtual_address_map() and 2. Invoking any efi_runtime_service() Likewise, we need to switch back to previous mm (mm context stolen by efi_mm) after the above calls ret

[PATCH V2 1/3] efi: Use efi_mm in x86 as well as ARM

2017-08-28 Thread Sai Praneeth Prakhya
From: Sai Praneeth Presently, only ARM uses mm_struct to manage efi page tables and efi runtime region mappings. As this is the preferred approach, let's make this data structure common across architectures. Specially, for x86, using this data structure improves code maintainability and readabili

[PATCH V2 2/3] x86/efi: Replace efi_pgd with efi_mm.pgd

2017-08-28 Thread Sai Praneeth Prakhya
From: Sai Praneeth Since the previous patch added support for efi_mm, let's handle efi_pgd through efi_mm and remove global variable efi_pgd. Signed-off-by: Sai Praneeth Prakhya Cc: Lee, Chun-Yi Cc: Borislav Petkov Cc: Tony Luck Cc: Andy Lutomirski Cc: Michael S. Tsirkin Cc: Ricardo Neri

[PATCH V2 0/3] Use mm_struct and switch_mm() instead of manually

2017-08-28 Thread Sai Praneeth Prakhya
From: Sai Praneeth Presently, in x86, to invoke any efi function like efi_set_virtual_address_map() or any efi_runtime_service() the code path typically involves read_cr3() (save previous pgd), write_cr3() (write efi_pgd) and calling efi function. Likewise after returning from efi function the co

Re: [RFC Part1 PATCH v3 15/17] x86: Add support for changing memory encryption attribute in early boot

2017-08-28 Thread Brijesh Singh
Hi Boris, On 8/28/17 5:51 AM, Borislav Petkov wrote: [..] > +static int __init early_set_memory_enc_dec(resource_size_t paddr, >> + unsigned long size, bool enc) >> +{ >> +unsigned long vaddr, vaddr_end, vaddr_next; >> +unsigned long psize, pmask; >

Re: [RFC Part1 PATCH v3 15/17] x86: Add support for changing memory encryption attribute in early boot

2017-08-28 Thread Borislav Petkov
On Mon, Jul 24, 2017 at 02:07:55PM -0500, Brijesh Singh wrote: > Some KVM-specific custom MSRs shares the guest physical address with s/shares/share/ > hypervisor. "the hypervisor." > When SEV is active, the shared physical address must be mapped > with encryption attribute cleared so that both