Re: [PATCH] virt/coco/sev-guest: Initialize err in handle_guest_request

From: Peter Gonda
Date: Thu Oct 27 2022 - 10:16:31 EST


On Thu, Oct 27, 2022 at 3:45 AM Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> On Wed, Oct 19, 2022 at 12:58:12PM -0700, Dionna Amalie Glaze wrote:
> > fw_err = 0xff doesn't make sense to me actually. It's not a documented
> > code that the firmware was never called.
> > Still, we can simply pass fw_err to snp_issue_guest_request rather
> > than an unsigned long err, since a null pointer results in an -EINVAL.

Yes this was not what my comments on the patch series intended.

On the host side we have `psp_ret = -1` inside of
__sev_platform_init_locked(). I think defining SEV_RET_NO_FW_CALL as
UINT32_MAX and moving to make all values of psp_ret where the psp is
not yet called would help callers understand errors more clearly.

>
> Yes, pls do that. Such I/O function args are always a PITA anyway.
>
> In retrospect, that handle_guest_request() with gazillion args should
> have been made to take a struct as a single argument and populate it as
> it operates.
>
> The callers then would look at it and decide what to do.
>
> Looking at the callers, they all take members of struct
> snp_guest_request_ioctl and pass them in. A first step in cleaning that
> up could be to simply pass that struct snp_guest_request_ioctl pointer
> instead...
>
> Oh well, in case folks feel bored. :-)

Ah, good idea. If I have some spare cycles.

>
> Thx.
>
> --
> Regards/Gruss,
> Boris.
>
> https://people.kernel.org/tglx/notes-about-netiquette