Re: [PATCH v3 43/75] x86/sev-es: Setup per-cpu GHCBs for the runtime handler

From: Borislav Petkov
Date: Fri May 22 2020 - 04:33:37 EST


On Tue, Apr 28, 2020 at 05:16:53PM +0200, Joerg Roedel wrote:
> @@ -198,6 +210,48 @@ static bool __init sev_es_setup_ghcb(void)
> return true;
> }
>
> +static void __init sev_es_alloc_runtime_data(int cpu)
> +{
> + struct sev_es_runtime_data *data;
> +
> + data = memblock_alloc(sizeof(*data), PAGE_SIZE);
> + if (!data)
> + panic("Can't allocate SEV-ES runtime data");
> +
> + per_cpu(runtime_data, cpu) = data;
> +}
> +
> +static void __init sev_es_init_ghcb(int cpu)

Since those are static functions, I'd drop the "sev_es_" prefix from the
name for better readability. Because otherwise the whole file is a sea
of "sev_es_"-prefixed identifiers which you need to read until the end
to know what they are.

> +{
> + struct sev_es_runtime_data *data;
> + int err;
> +
> + data = per_cpu(runtime_data, cpu);
> +
> + err = early_set_memory_decrypted((unsigned long)&data->ghcb_page,
> + sizeof(data->ghcb_page));
> + if (err)
> + panic("Can not map GHCBs unencrypted");

"Error mapping ..."

> +
> + memset(&data->ghcb_page, 0, sizeof(data->ghcb_page));
> +}

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette