All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: "Michal Suchánek" <msuchanek@suse.de>
Cc: Nathan Chancellor <nathan@kernel.org>,
	gjoyce@linux.vnet.ibm.com, axboe@kernel.dk, nayna@linux.ibm.com,
	linux-block@vger.kernel.org, jarkko@kernel.org,
	keyrings@vger.kernel.org, jonathan.derrick@linux.dev,
	brking@linux.vnet.ibm.com, akpm@linux-foundation.org,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v7 3/3 RESEND] powerpc/pseries: PLPKS SED Opal keystore support
Date: Thu, 14 Sep 2023 21:58:09 +1000	[thread overview]
Message-ID: <874jjx7yr2.fsf@mail.lhotse> (raw)
In-Reply-To: <20230914103400.GX8826@kitsune.suse.cz>

Michal Suchánek <msuchanek@suse.de> writes:
> Hello,
>
> On Thu, Sep 14, 2023 at 02:13:32PM +1000, Michael Ellerman wrote:
>> Nathan Chancellor <nathan@kernel.org> writes:
>> > Hi Greg,
>> >
>> > On Fri, Sep 08, 2023 at 10:30:56AM -0500, gjoyce@linux.vnet.ibm.com wrote:
>> >> From: Greg Joyce <gjoyce@linux.vnet.ibm.com>
>> >>
>> >> Define operations for SED Opal to read/write keys
>> >> from POWER LPAR Platform KeyStore(PLPKS). This allows
>> >> non-volatile storage of SED Opal keys.
>> >>
>> >> Signed-off-by: Greg Joyce <gjoyce@linux.vnet.ibm.com>
>> >> Reviewed-by: Jonathan Derrick <jonathan.derrick@linux.dev>
>> >> Reviewed-by: Hannes Reinecke <hare@suse.de>
>> >
>> > After this change in -next as commit 9f2c7411ada9 ("powerpc/pseries:
>> > PLPKS SED Opal keystore support"), I see the following crash when
>> > booting some distribution configurations, such as OpenSUSE's [1] (the
>> > rootfs is available at [2] if necessary):
>> 
>> Thanks for testing Nathan.
>> 
>> The code needs to check plpks_is_available() somewhere, before calling
>> the plpks routines.
>
> would this fixup do it?
>
> I don't really see any other place to plug the check with the current
> code structure.
 
I think the plpks_sed code should call plpks_is_available() once at init
time and cache the result.

Otherwise it's will be doing an extra hcall (in _plpks_get_config()) for
every call, which would be wasteful. 

cheers

> diff --git a/arch/powerpc/platforms/pseries/plpks_sed_ops.c b/arch/powerpc/platforms/pseries/plpks_sed_ops.c
> index c1d08075e850..f8038d998eae 100644
> --- a/arch/powerpc/platforms/pseries/plpks_sed_ops.c
> +++ b/arch/powerpc/platforms/pseries/plpks_sed_ops.c
> @@ -64,6 +64,9 @@ int sed_read_key(char *keyname, char *key, u_int *keylen)
>  	int ret;
>  	u_int len;
>  
> +	if (!plpks_is_available())
> +		return -ENODEV;
> +
>  	plpks_init_var(&var, keyname);
>  	var.data = (u8 *)&data;
>  	var.datalen = sizeof(data);
> @@ -89,6 +92,9 @@ int sed_write_key(char *keyname, char *key, u_int keylen)
>  	struct plpks_sed_object_data data;
>  	struct plpks_var_name vname;
>  
> +	if (!plpks_is_available())
> +		return -ENODEV;
> +
>  	plpks_init_var(&var, keyname);
>  
>  	var.datalen = sizeof(struct plpks_sed_object_data);
> -- 
> 2.41.0

WARNING: multiple messages have this Message-ID (diff)
From: Michael Ellerman <mpe@ellerman.id.au>
To: "Michal Suchánek" <msuchanek@suse.de>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org,
	gjoyce@linux.vnet.ibm.com, nayna@linux.ibm.com,
	Nathan Chancellor <nathan@kernel.org>,
	jarkko@kernel.org, keyrings@vger.kernel.org,
	jonathan.derrick@linux.dev, brking@linux.vnet.ibm.com,
	akpm@linux-foundation.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v7 3/3 RESEND] powerpc/pseries: PLPKS SED Opal keystore support
Date: Thu, 14 Sep 2023 21:58:09 +1000	[thread overview]
Message-ID: <874jjx7yr2.fsf@mail.lhotse> (raw)
In-Reply-To: <20230914103400.GX8826@kitsune.suse.cz>

Michal Suchánek <msuchanek@suse.de> writes:
> Hello,
>
> On Thu, Sep 14, 2023 at 02:13:32PM +1000, Michael Ellerman wrote:
>> Nathan Chancellor <nathan@kernel.org> writes:
>> > Hi Greg,
>> >
>> > On Fri, Sep 08, 2023 at 10:30:56AM -0500, gjoyce@linux.vnet.ibm.com wrote:
>> >> From: Greg Joyce <gjoyce@linux.vnet.ibm.com>
>> >>
>> >> Define operations for SED Opal to read/write keys
>> >> from POWER LPAR Platform KeyStore(PLPKS). This allows
>> >> non-volatile storage of SED Opal keys.
>> >>
>> >> Signed-off-by: Greg Joyce <gjoyce@linux.vnet.ibm.com>
>> >> Reviewed-by: Jonathan Derrick <jonathan.derrick@linux.dev>
>> >> Reviewed-by: Hannes Reinecke <hare@suse.de>
>> >
>> > After this change in -next as commit 9f2c7411ada9 ("powerpc/pseries:
>> > PLPKS SED Opal keystore support"), I see the following crash when
>> > booting some distribution configurations, such as OpenSUSE's [1] (the
>> > rootfs is available at [2] if necessary):
>> 
>> Thanks for testing Nathan.
>> 
>> The code needs to check plpks_is_available() somewhere, before calling
>> the plpks routines.
>
> would this fixup do it?
>
> I don't really see any other place to plug the check with the current
> code structure.
 
I think the plpks_sed code should call plpks_is_available() once at init
time and cache the result.

Otherwise it's will be doing an extra hcall (in _plpks_get_config()) for
every call, which would be wasteful. 

cheers

> diff --git a/arch/powerpc/platforms/pseries/plpks_sed_ops.c b/arch/powerpc/platforms/pseries/plpks_sed_ops.c
> index c1d08075e850..f8038d998eae 100644
> --- a/arch/powerpc/platforms/pseries/plpks_sed_ops.c
> +++ b/arch/powerpc/platforms/pseries/plpks_sed_ops.c
> @@ -64,6 +64,9 @@ int sed_read_key(char *keyname, char *key, u_int *keylen)
>  	int ret;
>  	u_int len;
>  
> +	if (!plpks_is_available())
> +		return -ENODEV;
> +
>  	plpks_init_var(&var, keyname);
>  	var.data = (u8 *)&data;
>  	var.datalen = sizeof(data);
> @@ -89,6 +92,9 @@ int sed_write_key(char *keyname, char *key, u_int keylen)
>  	struct plpks_sed_object_data data;
>  	struct plpks_var_name vname;
>  
> +	if (!plpks_is_available())
> +		return -ENODEV;
> +
>  	plpks_init_var(&var, keyname);
>  
>  	var.datalen = sizeof(struct plpks_sed_object_data);
> -- 
> 2.41.0

  reply	other threads:[~2023-09-14 11:58 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08 15:30 [PATCH v7 0/3 RESEND] generic and PowerPC SED Opal keystore gjoyce
2023-09-08 15:30 ` gjoyce
2023-09-08 15:30 ` [PATCH v7 1/3 RESEND] block:sed-opal: " gjoyce
2023-09-08 15:30   ` gjoyce
2023-09-13 16:56   ` Nathan Chancellor
2023-09-13 16:56     ` Nathan Chancellor
2023-09-13 20:49     ` Nick Desaulniers
2023-09-13 20:49       ` Nick Desaulniers
2023-09-13 21:33       ` Nathan Chancellor
2023-09-13 21:33         ` Nathan Chancellor
2023-09-27 20:25       ` Greg Joyce
2023-09-27 20:25         ` Greg Joyce
2023-09-27 20:30         ` Nick Desaulniers
2023-09-27 20:30           ` Nick Desaulniers
2023-09-08 15:30 ` [PATCH v7 2/3 RESEND] block: sed-opal: keystore access for SED Opal keys gjoyce
2023-09-08 15:30   ` gjoyce
2023-09-08 15:30 ` [PATCH v7 3/3 RESEND] powerpc/pseries: PLPKS SED Opal keystore support gjoyce
2023-09-08 15:30   ` gjoyce
2023-09-13 18:59   ` Nathan Chancellor
2023-09-13 18:59     ` Nathan Chancellor
2023-09-13 19:15     ` Jens Axboe
2023-09-13 19:15       ` Jens Axboe
2023-09-27 16:26       ` Greg Joyce
2023-09-27 16:26         ` Greg Joyce
2023-09-14  4:13     ` Michael Ellerman
2023-09-14 10:34       ` Michal Suchánek
2023-09-14 10:34         ` Michal Suchánek
2023-09-14 11:58         ` Michael Ellerman [this message]
2023-09-14 11:58           ` Michael Ellerman
2023-09-08 18:38 ` [PATCH v7 0/3 RESEND] generic and PowerPC SED Opal keystore Jens Axboe
2023-09-08 18:38   ` Jens Axboe
2023-09-11 22:19 ` Jens Axboe
2023-09-11 22:19   ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2023-07-21 21:19 gjoyce
2023-07-21 21:19 ` [PATCH v7 3/3 RESEND] powerpc/pseries: PLPKS SED Opal keystore support gjoyce
2023-07-21 21:19   ` gjoyce
2023-08-17  5:45   ` Hannes Reinecke
2023-08-17  5:45     ` Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874jjx7yr2.fsf@mail.lhotse \
    --to=mpe@ellerman.id.au \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=brking@linux.vnet.ibm.com \
    --cc=gjoyce@linux.vnet.ibm.com \
    --cc=jarkko@kernel.org \
    --cc=jonathan.derrick@linux.dev \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=msuchanek@suse.de \
    --cc=nathan@kernel.org \
    --cc=nayna@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.