Tom Lendacky
2020-Apr-14 20:04 UTC
[PATCH 40/70] x86/sev-es: Setup per-cpu GHCBs for the runtime handler
On 4/14/20 2:03 PM, Mike Stunes wrote:> On Mar 19, 2020, at 2:13 AM, Joerg Roedel <joro at 8bytes.org> wrote: >> >> From: Tom Lendacky <thomas.lendacky at amd.com> >> >> The runtime handler needs a GHCB per CPU. Set them up and map them >> unencrypted. >> >> Signed-off-by: Tom Lendacky <thomas.lendacky at amd.com> >> Signed-off-by: Joerg Roedel <jroedel at suse.de> >> --- >> arch/x86/include/asm/mem_encrypt.h | 2 ++ >> arch/x86/kernel/sev-es.c | 28 +++++++++++++++++++++++++++- >> arch/x86/kernel/traps.c | 3 +++ >> 3 files changed, 32 insertions(+), 1 deletion(-) >> >> diff --git a/arch/x86/kernel/sev-es.c b/arch/x86/kernel/sev-es.c >> index c17980e8db78..4bf5286310a0 100644 >> --- a/arch/x86/kernel/sev-es.c >> +++ b/arch/x86/kernel/sev-es.c >> @@ -197,6 +203,26 @@ static bool __init sev_es_setup_ghcb(void) >> return true; >> } >> >> +void sev_es_init_ghcbs(void) >> +{ >> + int cpu; >> + >> + if (!sev_es_active()) >> + return; >> + >> + /* Allocate GHCB pages */ >> + ghcb_page = __alloc_percpu(sizeof(struct ghcb), PAGE_SIZE); >> + >> + /* Initialize per-cpu GHCB pages */ >> + for_each_possible_cpu(cpu) { >> + struct ghcb *ghcb = (struct ghcb *)per_cpu_ptr(ghcb_page, cpu); >> + >> + set_memory_decrypted((unsigned long)ghcb, >> + sizeof(*ghcb) >> PAGE_SHIFT); >> + memset(ghcb, 0, sizeof(*ghcb)); >> + } >> +} >> + > > set_memory_decrypted needs to check the return value. I see it > consistently return ENOMEM. I've traced that back to split_large_page > in arch/x86/mm/pat/set_memory.c.At that point the guest won't be able to communicate with the hypervisor, too. Maybe we should BUG() here to terminate further processing? Thanks, Tom>
Dave Hansen
2020-Apr-14 20:12 UTC
[PATCH 40/70] x86/sev-es: Setup per-cpu GHCBs for the runtime handler
On 4/14/20 1:04 PM, Tom Lendacky wrote:>> set_memory_decrypted needs to check the return value. I see it >> consistently return ENOMEM. I've traced that back to split_large_page >> in arch/x86/mm/pat/set_memory.c. > > At that point the guest won't be able to communicate with the > hypervisor, too. Maybe we should BUG() here to terminate further > processing?Escalating an -ENOMEM into a crashed kernel seems a bit extreme. Granted, the guest may be in an unrecoverable state, but the host doesn't need to be too.
Tom Lendacky
2020-Apr-14 20:16 UTC
[PATCH 40/70] x86/sev-es: Setup per-cpu GHCBs for the runtime handler
On 4/14/20 3:12 PM, Dave Hansen wrote:> On 4/14/20 1:04 PM, Tom Lendacky wrote: >>> set_memory_decrypted needs to check the return value. I see it >>> consistently return ENOMEM. I've traced that back to split_large_page >>> in arch/x86/mm/pat/set_memory.c. >> >> At that point the guest won't be able to communicate with the >> hypervisor, too. Maybe we should BUG() here to terminate further >> processing? > > Escalating an -ENOMEM into a crashed kernel seems a bit extreme. > Granted, the guest may be in an unrecoverable state, but the host > doesn't need to be too. >The host wouldn't be. This only happens in a guest, so it would be just causing the guest kernel to panic early in the boot. Thanks, Tom
Joerg Roedel
2020-Apr-15 15:54 UTC
[PATCH 40/70] x86/sev-es: Setup per-cpu GHCBs for the runtime handler
On Tue, Apr 14, 2020 at 03:04:42PM -0500, Tom Lendacky wrote:> At that point the guest won't be able to communicate with the hypervisor, > too. Maybe we should BUG() here to terminate further processing?We could talk to the hypervisor, there is still the boot-GHCB in the bss-decrypted section. But there is nothing that could be done here anyway besides terminating the guest. Regards, Joerg
Seemingly Similar Threads
- [PATCH 40/70] x86/sev-es: Setup per-cpu GHCBs for the runtime handler
- [PATCH 40/70] x86/sev-es: Setup per-cpu GHCBs for the runtime handler
- [PATCH 35/62] x86/sev-es: Setup per-cpu GHCBs for the runtime handler
- [PATCH v7 41/72] x86/sev-es: Setup per-cpu GHCBs for the runtime handler
- [PATCH v3 43/75] x86/sev-es: Setup per-cpu GHCBs for the runtime handler