Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1581693 > unrolled thread

[PATCHv4 0/4] OPAL patches

Started byJon Derrick <jonathan.derrick@intel.com>
First post2017-02-15 22:50 +0100
Last post2017-02-16 15:50 +0100
Articles 5 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCHv4 0/4] OPAL patches Jon Derrick <jonathan.derrick@intel.com> - 2017-02-15 22:50 +0100
    [PATCHv4 4/4] MAINTAINERS: Remove powerpc's opal match Jon Derrick <jonathan.derrick@intel.com> - 2017-02-15 22:50 +0100
      Re: [PATCHv4 4/4] MAINTAINERS: Remove powerpc's opal match Andrew Donnellan <andrew.donnellan@au1.ibm.com> - 2017-02-16 01:00 +0100
    [PATCHv4 2/4] block/sed: Add helper to qualify response tokens Jon Derrick <jonathan.derrick@intel.com> - 2017-02-15 22:50 +0100
      Re: [PATCHv4 2/4] block/sed: Add helper to qualify response tokens Christoph Hellwig <hch@lst.de> - 2017-02-16 15:50 +0100

#1581693 — [PATCHv4 0/4] OPAL patches

FromJon Derrick <jonathan.derrick@intel.com>
Date2017-02-15 22:50 +0100
Subject[PATCHv4 0/4] OPAL patches
Message-ID<tbfCx-5jD-5@gated-at.bofh.it>
Just a couple of fixes for sed-opal to prevent faulty firmware from
allowing us to go off in the weeds, and a helper to remove some
duplicate code.

v3->v4:
uses IS_ERR since tok is embedded in the response buffer and cannot be NULL

v2->v3:
corrected the bad calculation on the response parser check and changed
it to only check the subpacket length

v1->v2:
left tok->len as a size_t
got everyone important on the same email thread

Jon Derrick (4):
  block/sed: Use ssize_t on atom parsers to return errors
  block/sed: Add helper to qualify response tokens
  block/sed: Check received header lengths
  MAINTAINERS: Remove powerpc's opal match

 MAINTAINERS      |   1 -
 block/sed-opal.c | 124 +++++++++++++++++++++++++++----------------------------
 2 files changed, 60 insertions(+), 65 deletions(-)

-- 
1.8.3.1

[toc] | [next] | [standalone]


#1581697 — [PATCHv4 4/4] MAINTAINERS: Remove powerpc's opal match

FromJon Derrick <jonathan.derrick@intel.com>
Date2017-02-15 22:50 +0100
Subject[PATCHv4 4/4] MAINTAINERS: Remove powerpc's opal match
Message-ID<tbfCy-5jD-31@gated-at.bofh.it>
In reply to#1581693
PPC's 'opal' match pattern also matches block/sed-opal.c, where it looks
like the 'arch/powerpc' file pattern should be enough to match powerpc
opal code by itself. Remove the opal regex pattern from powerpc.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
---
 MAINTAINERS | 1 -
 1 file changed, 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index b983b25..430dd02 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7404,7 +7404,6 @@ F:	drivers/pci/hotplug/pnv_php.c
 F:	drivers/pci/hotplug/rpa*
 F:	drivers/scsi/ibmvscsi/
 F:	tools/testing/selftests/powerpc
-N:	opal
 N:	/pmac
 N:	powermac
 N:	powernv
-- 
1.8.3.1

[toc] | [prev] | [next] | [standalone]


#1582058 — Re: [PATCHv4 4/4] MAINTAINERS: Remove powerpc's opal match

FromAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Date2017-02-16 01:00 +0100
SubjectRe: [PATCHv4 4/4] MAINTAINERS: Remove powerpc's opal match
Message-ID<tbhEm-6D9-21@gated-at.bofh.it>
In reply to#1581697
On 16/02/17 08:45, Jon Derrick wrote:
> PPC's 'opal' match pattern also matches block/sed-opal.c, where it looks
> like the 'arch/powerpc' file pattern should be enough to match powerpc
> opal code by itself. Remove the opal regex pattern from powerpc.
>
> Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>

It looks like this change will exclude the following PPC OPAL related files:

drivers/tty/hvc/hvc_opal.c - HYPERVISOR VIRTUAL CONSOLE DRIVER (which 
lists linuxppc-dev as the mailing list, doesn't name a maintainer though)

drivers/i2c/busses/i2c-opal.c - I2C SUBSYSTEM

drivers/rtc/rtc-opal.c - REAL TIME CLOCK (RTC) SUBSYSTEM

Documentation/devicetree/bindings/i2c/i2c-opal.txt - I2C SUBSYSTEM, OPEN 
FIRMWARE AND FLATTENED DEVICE TREE BINDINGS

Documentation/devicetree/bindings/powerpc/opal - OPEN FIRMWARE AND 
FLATTENED DEVICE TREE BINDINGS

Documentation/devicetree/bindings/powerpc/opal/oppanel-opal.txt - OPEN 
FIRMWARE AND FLATTENED DEVICE TREE BINDINGS

Documentation/devicetree/bindings/rtc/rtc-opal.txt - OPEN FIRMWARE AND 
FLATTENED DEVICE TREE BINDINGS, REAL TIME CLOCK (RTC) SUBSYSTEM

Documentation/ABI/stable/sysfs-firmware-opal-elog - no other subsystem

Documentation/ABI/stable/sysfs-firmware-opal-dump - no other subsystem


-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited

[toc] | [prev] | [next] | [standalone]


#1581698 — [PATCHv4 2/4] block/sed: Add helper to qualify response tokens

FromJon Derrick <jonathan.derrick@intel.com>
Date2017-02-15 22:50 +0100
Subject[PATCHv4 2/4] block/sed: Add helper to qualify response tokens
Message-ID<tbfCy-5jD-35@gated-at.bofh.it>
In reply to#1581693
Add helper which verifies the response token is valid and matches the
expected value. Merges token_type and response_get_token.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Reviewed-by: Scott Bauer <scott.bauer@intel.com>
---
 block/sed-opal.c | 61 +++++++++++++++++++++++---------------------------------
 1 file changed, 25 insertions(+), 36 deletions(-)

diff --git a/block/sed-opal.c b/block/sed-opal.c
index 77623ad..00673cf 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -591,48 +591,25 @@ static int cmd_finalize(struct opal_dev *cmd, u32 hsn, u32 tsn)
 	return 0;
 }
 
-static enum opal_response_token token_type(const struct parsed_resp *resp,
-					   int n)
+static const struct opal_resp_tok *response_get_token(
+				const struct parsed_resp *resp,
+				int n)
 {
 	const struct opal_resp_tok *tok;
 
 	if (n >= resp->num) {
 		pr_err("Token number doesn't exist: %d, resp: %d\n",
 		       n, resp->num);
-		return OPAL_DTA_TOKENID_INVALID;
+		return ERR_PTR(-EINVAL);
 	}
 
 	tok = &resp->toks[n];
 	if (tok->len == 0) {
 		pr_err("Token length must be non-zero\n");
-		return OPAL_DTA_TOKENID_INVALID;
+		return ERR_PTR(-EINVAL);
 	}
 
-	return tok->type;
-}
-
-/*
- * This function returns 0 in case of invalid token. One should call
- * token_type() first to find out if the token is valid or not.
- */
-static enum opal_token response_get_token(const struct parsed_resp *resp,
-					  int n)
-{
-	const struct opal_resp_tok *tok;
-
-	if (n >= resp->num) {
-		pr_err("Token number doesn't exist: %d, resp: %d\n",
-		       n, resp->num);
-		return 0;
-	}
-
-	tok = &resp->toks[n];
-	if (tok->len == 0) {
-		pr_err("Token length must be non-zero\n");
-		return 0;
-	}
-
-	return tok->pos[0];
+	return tok;
 }
 
 static ssize_t response_parse_tiny(struct opal_resp_tok *tok,
@@ -851,20 +828,32 @@ static u64 response_get_u64(const struct parsed_resp *resp, int n)
 	return resp->toks[n].stored.u;
 }
 
+static bool response_token_matches(const struct opal_resp_tok *token, u8 match)
+{
+	if (IS_ERR(token) ||
+	    token->type != OPAL_DTA_TOKENID_TOKEN ||
+	    token->pos[0] != match)
+		return false;
+	return true;
+}
+
 static u8 response_status(const struct parsed_resp *resp)
 {
-	if (token_type(resp, 0) == OPAL_DTA_TOKENID_TOKEN &&
-	    response_get_token(resp, 0) == OPAL_ENDOFSESSION) {
+	const struct opal_resp_tok *tok;
+
+	tok = response_get_token(resp, 0);
+	if (response_token_matches(tok, OPAL_ENDOFSESSION))
 		return 0;
-	}
 
 	if (resp->num < 5)
 		return DTAERROR_NO_METHOD_STATUS;
 
-	if (token_type(resp, resp->num - 1) != OPAL_DTA_TOKENID_TOKEN ||
-	    token_type(resp, resp->num - 5) != OPAL_DTA_TOKENID_TOKEN ||
-	    response_get_token(resp, resp->num - 1) != OPAL_ENDLIST ||
-	    response_get_token(resp, resp->num - 5) != OPAL_STARTLIST)
+	tok = response_get_token(resp, resp->num - 5);
+	if (!response_token_matches(tok, OPAL_STARTLIST))
+		return DTAERROR_NO_METHOD_STATUS;
+
+	tok = response_get_token(resp, resp->num - 1);
+	if (!response_token_matches(tok, OPAL_ENDLIST))
 		return DTAERROR_NO_METHOD_STATUS;
 
 	return response_get_u64(resp, resp->num - 4);
-- 
1.8.3.1

[toc] | [prev] | [next] | [standalone]


#1582625 — Re: [PATCHv4 2/4] block/sed: Add helper to qualify response tokens

FromChristoph Hellwig <hch@lst.de>
Date2017-02-16 15:50 +0100
SubjectRe: [PATCHv4 2/4] block/sed: Add helper to qualify response tokens
Message-ID<tbvxD-7yW-9@gated-at.bofh.it>
In reply to#1581698
On Wed, Feb 15, 2017 at 02:45:55PM -0700, Jon Derrick wrote:
> Add helper which verifies the response token is valid and matches the
> expected value. Merges token_type and response_get_token.
> 
> Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
> Reviewed-by: Scott Bauer <scott.bauer@intel.com>

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web