powerpc/pseries - bugfixes/cleanups for PLPKS driver
cover powerpc/pseries - bugfixes/cleanups for PLPKS driver
This patchset fixes some bugs and does some cleanups.
Nayna Jain (6):
powerpc/pseries: fix the object owners enum value in plpks driver powerpc/pseries: Fix the H_CALL error code in PLPKS driver powerpc/pseries: Return -EIO instead of -EINTR for H_ABORTED error powerpc/pseries: cleanup error logs in plpks driver powerpc/pseries: replace kmalloc with kzalloc in PLPKS driver powerpc/pseries: fix plpks_read_var() code for different consumers
arch/powerpc/include/asm/hvcall.h | 3 +- arch/powerpc/platforms/pseries/plpks.c | 50 ++++++++++++-------------- arch/powerpc/platforms/pseries/plpks.h | 2 +- 3 files changed, 24 insertions(+), 31 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/6 powerpc/pseries: fix the object owners enum value in plpks driver
OS_VAR_LINUX enum in PLPKS driver should be 0x02 instead of 0x01.
--- arch/powerpc/platforms/pseries/plpks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/pseries/plpks.h +1 -1
@@ -17,7 +17,7 @@#define WORLDREADABLE 0x08000000#define SIGNEDUPDATE 0x01000000 -#define PLPKS_VAR_LINUX 0x01 +#define PLPKS_VAR_LINUX 0x02#define PLPKS_VAR_COMMON 0x04struct plpks_var {
Signature · 1 line
2.31.1
Re: [PATCH 1/6] powerpc/pseries: fix the object owners enum value in plpks driver
Quoted 1 line · Nayna Jain
OS_VAR_LINUXenum in PLPKS driver should be0x02instead of0x01.
This should be PLPKS_VAR_LINUX. And it's a macro, not an enum.
The new value does indeed match the (currently IBM internal) specification - 0x01 is AIX.
Quoted 4 lines
Fixes 2454a7af0f2a ("powerpc/pseries: define driver for PlatformKeyStore")
Signed-off-by Nayna Jain <[email protected]>
Should be noted that at present, this macro isn't used anywhere - it is used in a future series.
Quoted 18 lines
---
arch/powerpc/platforms/pseries/plpks.h | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/platforms/pseries/plpks.h +0
-0@@ -17,7 +17,7 @@ #define WORLDREADABLE 0x08000000 #define SIGNEDUPDATE 0x01000000arch/powerpc/platforms/pseries/plpks.h +1
-1-#define PLPKS_VAR_LINUX 0x01 +#define PLPKS_VAR_LINUX 0x02#define PLPKS_VAR_COMMON 0x04
structplpks_var{
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited
PATCH 2/6 powerpc/pseries: Fix the H_CALL error code in PLPKS driver
In reply to Nayna JainPAPR Spec defines H_P1 actually as H_PARAMETER and maps H_ABORTED to a different numerical value.
Fix the error codes as per PAPR Specification.
--- arch/powerpc/include/asm/hvcall.h | 3 +-- arch/powerpc/platforms/pseries/plpks.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/hvcall.h +1 -2
@@ -79,7 +79,7 @@#define H_NOT_ENOUGH_RESOURCES -44#define H_R_STATE -45#define H_RESCINDED -46 -#define H_P1 -54 +#define H_ABORTED -54#define H_P2 -55#define H_P3 -56#define H_P4 -57
@@ -100,7 +100,6 @@#define H_COP_HW -74#define H_STATE -75#define H_IN_USE -77 -#define H_ABORTED -78#define H_UNSUPPORTED_FLAG_START -256#define H_UNSUPPORTED_FLAG_END -511#define H_MULTI_THREADS_ACTIVE -9005
arch/powerpc/platforms/pseries/plpks.c +1 -1
@@ -75,7 +75,7 @@ static int pseries_status_to_err(int rc)case H_FUNCTION : err = -ENXIO ;break ; -case H_P1 : +case H_PARAMETER :case H_P2 :case H_P3 :case H_P4 :
Signature · 1 line
2.31.1
Re: [PATCH 2/6] powerpc/pseries: Fix the H_CALL error code in PLPKS driver
Quoted 8 lines · Nayna Jain
PAPR Spec defines
H_P1actually asH_PARAMETERand mapsH_ABORTEDto a different numerical value.Fix the error codes as per PAPR Specification.
Fixes 2454a7af0f2a ("powerpc/pseries: define driver for PlatformKeyStore")
Signed-off-by Nayna Jain <[email protected]>
This does indeed match my understanding of the PAPR spec.
Quoted 41 lines
---
arch/powerpc/include/asm/hvcall.h | 3 +--
arch/powerpc/platforms/pseries/plpks.c | 2 +-2 files changed, 2 insertions(+), 3 deletions(-)arch/powerpc/include/asm/hvcall.h +1
-2@@ -79,7 +79,7 @@ #define H_NOT_ENOUGH_RESOURCES -44 #define H_R_STATE -45 #define H_RESCINDED -46 -#define H_P1 -54 +#define H_ABORTED -54 #define H_P2 -55 #define H_P3 -56 #define H_P4 -57@@ -100,7 +100,6 @@ #define H_COP_HW -74 #define H_STATE -75 #define H_IN_USE -77 -#define H_ABORTED -78 #define H_UNSUPPORTED_FLAG_START -256 #define H_UNSUPPORTED_FLAG_END -511 #define H_MULTI_THREADS_ACTIVE -9005arch/powerpc/platforms/pseries/plpks.c +0
-0@@ -75,7 +75,7 @@ static int pseries_status_to_err(int rc)case
H_FUNCTION:
err =-ENXIO;
break;
- caseH_P1:
+ caseH_PARAMETER:
caseH_P2:
caseH_P3:
caseH_P4:
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited
PATCH 3/6 powerpc/pseries: Return -EIO instead of -EINTR for H_ABORTED error
In reply to Nayna JainSome commands for eg. "cat" might continue to retry on encountering EINTR. This is not expected for original error code H_ABORTED.
Map H_ABORTED to more relevant Linux error code EIO.
--- arch/powerpc/platforms/pseries/plpks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/pseries/plpks.c +1 -1
@@ -111,7 +111,7 @@ static int pseries_status_to_err(int rc) err = -EEXIST ;break ;case H_ABORTED : - err = -EINTR ; + err = -EIO ;break ;default : err = -EINVAL ;
Signature · 1 line
2.31.1
Re: [PATCH 3/6] powerpc/pseries: Return -EIO instead of -EINTR for H_ABORTED error
Quoted 8 lines · Nayna Jain
Some commands for eg. "cat" might continue to retry on encountering EINTR. This is not expected for original error code
H_ABORTED.Map
H_ABORTEDto more relevant Linux error code EIO.Fixes 2454a7af0f2a ("powerpc/pseries: define driver for PlatformKeyStore")
Signed-off-by Nayna Jain <[email protected]>
The interface spec states that, for PKS-related hcalls, H_Aborted means "error occurred processing request" rather than something that would specifically map to EINTR, so I think EIO is appropriate here.
Quoted 18 lines
---
arch/powerpc/platforms/pseries/plpks.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/platforms/pseries/plpks.c +0
-0@@ -111,7 +111,7 @@ static int pseries_status_to_err(int rc) err = -EEXIST; break;case
H_ABORTED:
- err =-EINTR;
+ err =-EIO;
break;
default:
err =-EINVAL;
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited
PATCH 4/6 powerpc/pseries: cleanup error logs in plpks driver
In reply to Nayna JainLogging H_CALL return codes in PLPKS driver are easy to confuse with Linux error codes.
Let the caller of the function log the converted linux error code.
--- arch/powerpc/platforms/pseries/plpks.c | 10 ---------- 1 file changed, 10 deletions(-)
arch/powerpc/platforms/pseries/plpks.c +0 -10
@@ -312,10 +312,6 @@ int plpks_write_var(struct plpks_var var)if (!rc) rc =plpks_confirm_object_flushed (label, auth); -if (rc) -pr_err ("Failed to write variable %s for component %s with error %d\n" , - var.name, var.component, rc); - rc =pseries_status_to_err (rc);kfree (label); out:
@@ -350,10 +346,6 @@ int plpks_remove_var(char *component, u8 varos, struct plpks_var_name vname)if (!rc) rc =plpks_confirm_object_flushed (label, auth); -if (rc) -pr_err ("Failed to remove variable %s for component %s with error %d\n" , - vname.name, component, rc); - rc =pseries_status_to_err (rc);kfree (label); out:
@@ -395,8 +387,6 @@ static int plpks_read_var(u8 consumer, struct plpks_var *var) maxobjsize);if (rc !=H_SUCCESS ) { -pr_err ("Failed to read variable %s for component %s with error %d\n" , - var->name, var->component, rc); rc =pseries_status_to_err (rc); goto out_free_output; }
Signature · 1 line
2.31.1
PATCH 5/6 powerpc/pseries: replace kmalloc with kzalloc in PLPKS driver
In reply to Nayna JainReplace kmalloc with kzalloc in construct_auth() function to default initialize structure with zeroes.
--- arch/powerpc/platforms/pseries/plpks.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/powerpc/platforms/pseries/plpks.c +2 -6
@@ -162,19 +162,15 @@ static struct plpks_auth *construct_auth(u8 consumer)if (consumer >PKS_OS_OWNER )return ERR_PTR (-EINVAL ); - auth =kmalloc (struct_size (auth, password, maxpwsize),GFP_KERNEL ); + auth =kzalloc (struct_size (auth, password, maxpwsize),GFP_KERNEL );if (!auth)return ERR_PTR (-ENOMEM ); auth->version =1 ; auth->consumer = consumer; - auth->rsvd0 =0 ; - auth->rsvd1 =0 ; -if (consumer ==PKS_FW_OWNER || consumer ==PKS_BOOTLOADER_OWNER ) { - auth->passwordlength =0 ; +if (consumer ==PKS_FW_OWNER || consumer ==PKS_BOOTLOADER_OWNER )return auth; - }memcpy (auth->password, ospassword, ospasswordlength);
Signature · 1 line
2.31.1
Re: [PATCH 5/6] powerpc/pseries: replace kmalloc with kzalloc in PLPKS driver
Quoted 4 lines · Nayna Jain
Replace kmalloc with kzalloc in
construct_auth()function to default initialize structure with zeroes.Signed-off-by Nayna Jain <[email protected]>
This seems sensible.
Quoted 32 lines
---
arch/powerpc/platforms/pseries/plpks.c | 8 ++------1 file changed, 2 insertions(+), 6 deletions(-)arch/powerpc/platforms/pseries/plpks.c +0
-0@@ -162,19 +162,15 @@ static struct plpks_auth *construct_auth(u8 consumer) if (consumer > PKS_OS_OWNER) return ERR_PTR(-EINVAL);
- auth =kmalloc(struct_size(auth, password, maxpwsize), GFP_KERNEL);
+ auth =kzalloc(struct_size(auth, password, maxpwsize), GFP_KERNEL);
if (!auth)
returnERR_PTR(-ENOMEM);
auth->version = 1;
auth->consumer = consumer;
- auth->rsvd0 = 0;
- auth->rsvd1 = 0;
- if (consumer ==PKS_FW_OWNER|| consumer ==PKS_BOOTLOADER_OWNER) {
- auth->passwordlength = 0;
+ if (consumer ==PKS_FW_OWNER|| consumer ==PKS_BOOTLOADER_OWNER)
Quoted 2 lines
return auth;
- }
This bit seems spurious.
Quoted 3 lines
memcpy(auth->password, ospassword, ospasswordlength);
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited
PATCH 6/6 powerpc/pseries: fix plpks_read_var() code for different consumers
In reply to Nayna JainEven though plpks_read_var() is currently called to read variables owned by different consumers, it internally supports only OS consumer.
Fix plpks_read_var() to handle different consumers correctly.
--- arch/powerpc/platforms/pseries/plpks.c | 28 +++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-)
arch/powerpc/platforms/pseries/plpks.c +18 -10
@@ -354,22 +354,24 @@ static int plpks_read_var(u8 consumer, struct plpks_var *var) {unsigned long retbuf[PLPAR_HCALL_BUFSIZE ] = {0 };struct plpks_auth *auth; -struct label *label; +struct label *label =NULL ;u8 *output;int rc;if (var->namelen >MAX_NAME_SIZE )return -EINVAL ; - auth =construct_auth (PKS_OS_OWNER ); + auth =construct_auth (consumer);if (IS_ERR (auth))return PTR_ERR (auth); - label =construct_label (var->component, var->os, var->name, - var->namelen); -if (IS_ERR (label)) { - rc =PTR_ERR (label); - goto out_free_auth; +if (consumer ==PKS_OS_OWNER ) { + label =construct_label (var->component, var->os, var->name, + var->namelen); +if (IS_ERR (label)) { + rc =PTR_ERR (label); + goto out_free_auth; + } } output =kzalloc (maxobjsize,GFP_KERNEL );
@@ -378,9 +380,15 @@ static int plpks_read_var(u8 consumer, struct plpks_var *var) goto out_free_label; } - rc =plpar_hcall (H_PKS_READ_OBJECT , retbuf,virt_to_phys (auth), -virt_to_phys (label), label->size,virt_to_phys (output), - maxobjsize); +if (consumer ==PKS_OS_OWNER ) + rc =plpar_hcall (H_PKS_READ_OBJECT , retbuf,virt_to_phys (auth), +virt_to_phys (label), label->size,virt_to_phys (output), + maxobjsize); +else + rc =plpar_hcall (H_PKS_READ_OBJECT , retbuf,virt_to_phys (auth), +virt_to_phys (var->name), var->namelen,virt_to_phys (output), + maxobjsize); +if (rc !=H_SUCCESS ) { rc =pseries_status_to_err (rc);
Signature · 1 line
2.31.1
Michael Ellerman
AppliedQuoted 11 lines · Nayna Jain
This patchset fixes some bugs and does some cleanups.
Nayna Jain (6):
powerpc/pseries: fix the object owners enum value in plpks driver powerpc/pseries: Fix theH_CALLerror code in PLPKS driver powerpc/pseries: Return-EIOinstead of-EINTRforH_ABORTEDerror powerpc/pseries: cleanup error logs in plpks driver powerpc/pseries: replace kmalloc with kzalloc in PLPKS driver powerpc/pseries: fixplpks_read_var()code for different consumers[...]
Applied to powerpc/next.
[1/6] powerpc/pseries: fix the object owners enum value in plpks driver
https://git.kernel.org/powerpc/c/2330757e0be0acad88852e211dcd6106390a729b [2/6] powerpc/pseries: Fix the H_CALL error code in PLPKS driver https://git.kernel.org/powerpc/c/af223e1728c448073d1e12fe464bf344310edeba [3/6] powerpc/pseries: Return -EIO instead of -EINTR for H_ABORTED error https://git.kernel.org/powerpc/c/bb8e4c7cb759b90a04f2e94056b50288ff46a0ed [4/6] powerpc/pseries: cleanup error logs in plpks driver https://git.kernel.org/powerpc/c/8888ea772972323362660e9a1339175294664a6c [5/6] powerpc/pseries: replace kmalloc with kzalloc in PLPKS driver https://git.kernel.org/powerpc/c/212dd5cfbee7815f3c665a51c501701edb881599 [6/6] powerpc/pseries: fix plpks_read_var() code for different consumers https://git.kernel.org/powerpc/c/1f622f3f80cbf8999ff5955a2fcfbd801a1f32e0
cheers