Re: [PATCH v12 2/3] x86/sev: Change snp_guest_issue_request's fw_err

From: Borislav Petkov
Date: Sat Jan 21 2023 - 12:05:37 EST


On Fri, Jan 20, 2023 at 09:48:55PM +0000, Dionna Glaze wrote:
> The GHCB specification declares that the firmware error value for a
> guest request will be stored in the lower 32 bits of EXIT_INFO_2.
> The upper 32 bits are for the VMM's own error code. The fw_err argument
> is thus a misnomer, and callers will need access to all 64 bits.
>
> The type of unsigned long also causes problems, since sw_exit_info2 is
> u64 (unsigned long long) vs the argument's unsigned long*. This type
> is changed for issuing the guest request. The ioctl command struct's
> error field is passed directly instead of a local variable, since an
> incomplete guest request may not set the error code, and uninitialized
> stack memory would be written back to user space.
>
> The firmware might not even be called, so the call is bookended with
> the no firmware call error and clearing the error.
>
> Since the "fw_err" field is really exitinfo2 split into the upper bits'
> vmm error code and lower bits' firmware error code, sev-guest.h is
> updated to represent the 64 bit value as a union.
>
> Cc: Tom Lendacky <Thomas.Lendacky@xxxxxxx>
> Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> Cc: Joerg Roedel <jroedel@xxxxxxx>
> Cc: Peter Gonda <pgonda@xxxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Borislav Petkov <Borislav.Petkov@xxxxxxx>
> Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
> Cc: Venu Busireddy <venu.busireddy@xxxxxxxxxx>
> Cc: Michael Roth <michael.roth@xxxxxxx>
> Cc: "Kirill A. Shutemov" <kirill@xxxxxxxxxxxxx>
> Cc: Michael Sterritt <sterritt@xxxxxxxxxx>
>
> Fixes: d5af44dde546 ("x86/sev: Provide support for SNP guest request NAEs")
> Reviewed-by: Tom Lendacky <Thomas.Lendacky@xxxxxxx>

> Reviewed-by: Borislav Petkov <Borislav.Petkov@xxxxxxx>

Please don't add tags you haven't received. Especially a Reviewed-by. Have a
look here what they mean, if unsure:

Documentation/process/submitting-patches.rst

I've removed it - you don't have to resend just because of that.

Thx.

--
Regards/Gruss,
Boris.

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