Re: [RFC v1 6/6] crypto/ccp: Implement SNP firmware live update

From: Maxwell Doose

Date: Mon May 04 2026 - 14:43:53 EST


On Mon, May 4, 2026 at 8:57 AM Tycho Andersen <tycho@xxxxxxxxxx> wrote:
> On Sat, May 02, 2026 at 10:18:42PM -0500, Maxwell Doose wrote:
> > On Thu Apr 30, 2026 at 11:07 AM CDT, Tycho Andersen wrote:
[snip]
> > > + old_major = sev->api_major;
> > > + old_minor = sev->api_minor;
> > > + old_build = sev->build;
> > > +
> > > + mutex_lock(&sev_cmd_mutex);
> > >
> >
> > Why not guard(mutex)()? You used it earlier in
> > sev_firmware_reinit_if_shutdown().
>
> Because this code calls some functions, including
> sev_firmware_reinit_if_shutdown(), that take the lock again. We could
> use scoped_guard() I suppose, I can look at that for v2.
>

Sorry, I should've clarified in my email, I meant why not use the RAII
patterns in cleanup.h like before. Like you said, scoped_guard() is
likely the logical way forward if there's some functions that acquire
the same lock.

> It may be useful to do a larger series where we re-think when the
> locks are acquired here. It seems like only grabbing them at the top
> level entrypoints: ioctl, platform init, firmware update, etc. and
> putting lockdep asserts in all the helpers in the file might be
> cleaner generally.

That's also probably a good idea.

best regards,
maxwell



>
> Tycho