Re: [PATCH] x86/sev-es: Invalidate the GHCB after completing VMGEXIT

From: Joerg Roedel
Date: Mon May 17 2021 - 08:33:55 EST


Hi Tom,

On Fri, May 14, 2021 at 02:12:33PM -0500, Tom Lendacky wrote:
> arch/x86/kernel/sev-shared.c | 1 +
> arch/x86/kernel/sev.c | 37 ++++++++++++++++++------------------
> 2 files changed, 20 insertions(+), 18 deletions(-)

Having this change in one patch is okay. No need to split it up.

> +static __always_inline void sev_es_put_ghcb(struct ghcb_state *state)
> +{
> + struct sev_es_runtime_data *data;
> + struct ghcb *ghcb;
> +
> + data = this_cpu_read(runtime_data);
> + ghcb = &data->ghcb_page;
> +
> + if (state->ghcb) {
> + /* Restore GHCB from Backup */
> + *ghcb = *state->ghcb;
> + data->backup_ghcb_active = false;
> + state->ghcb = NULL;
> + } else {
> + vc_ghcb_invalidate(ghcb);

A comment would be good to explain why the invalidate here is
necessary.

Regards,

Joerg