Index | Thread | Search

From:
Jonathan Gray <jsg@jsg.id.au>
Subject:
Re: psp(4): Automatically load SEV firmware 3/3
To:
tech@openbsd.org
Date:
Sat, 26 Oct 2024 07:37:24 +1100

Download raw body.

Thread
On Fri, Oct 25, 2024 at 03:51:11PM +0200, Hans-Jörg Höxer wrote:
> Hi,
> 
> and the actual firmware loading.
> 
> Take care,
> HJ.
> ---------------------------------------------------------------
> commit 9c4c3b5c92581546d9d0c1dda8e463715eeb5306
> Author: Hans-Joerg Hoexer <hshoexer@genua.de>
> Date:   Tue Oct 1 18:49:01 2024 +0200
> 
>     psp(4): Automatically load SEV firmware
>     
>     When opening /dev/psp for the first time, load the SEV firmware.
>     The firmware files will be provided as ports package.  The relevant
>     firmware file is determined by CPU family and model (ci_family and
>     ci_model).
>     
>     If no firmware files are installed or the right file could be
>     determined, the PSP will be initialized using the on-chip firmware.
> 
> diff --git a/sys/dev/ic/psp.c b/sys/dev/ic/psp.c
> index 92459c9e06f..4836f3f69a5 100644
> --- a/sys/dev/ic/psp.c
> +++ b/sys/dev/ic/psp.c
> @@ -21,6 +21,7 @@
>  #include <sys/device.h>
>  #include <sys/pledge.h>
>  #include <sys/rwlock.h>
> +#include <sys/malloc.h>
>  
>  #include <machine/bus.h>
>  
> @@ -58,6 +59,11 @@ struct psp_softc {
>  
>  	uint32_t		sc_flags;
>  #define PSPF_INITIALIZED	0x1
> +#define PSPF_UCODELOADED	0x2
> +#define PSPF_NOUCODE		0x4
> +
> +	u_char			*sc_ucodebuf;
> +	size_t			sc_ucodelen;
>  };
>  
>  int	psp_get_pstatus(struct psp_softc *, struct psp_platform_status *);
> @@ -65,6 +71,7 @@ int	psp_init(struct psp_softc *, struct psp_init *);
>  int	psp_reinit(struct psp_softc *);
>  int	psp_match(struct device *, void *, void *);
>  void	psp_attach(struct device *, struct device *, void *);
> +void	psp_load_ucode(struct psp_softc *);
>  
>  struct cfdriver psp_cd = {
>  	NULL, "psp", DV_DULL
> @@ -705,6 +712,10 @@ pspopen(dev_t dev, int flag, int mode, struct proc *p)
>  	if (sc == NULL)
>  		return (ENXIO);
>  
> +#ifndef SMALL_KERNEL
> +	psp_load_ucode(sc);
> +#endif

why #ifndef SMALL_KERNEL?  psp(4) is only in GENERIC