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

From: Tom Lendacky
Date: Mon May 17 2021 - 11:15:35 EST


On 5/17/21 7:33 AM, Joerg Roedel wrote:
> 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.

Ah, good point. I'll add that and send a v2, but I'll wait for further
feedback before sending the next version.

Thanks,
Tom

>
> Regards,
>
> Joerg
>