From: Stefan Haberland <sth@linux.ibm.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org,
Jan Hoeppner <hoeppner@linux.ibm.com>,
linux-s390@vger.kernel.org,
Heiko Carstens <heiko.carstens@de.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>
Subject: [PATCH v2 02/10] s390/cio: Provide Endpoint-Security Mode per CU
Date: Thu, 8 Oct 2020 15:13:28 +0200 [thread overview]
Message-ID: <20201008131336.61100-3-sth@linux.ibm.com> (raw)
In-Reply-To: <20201008131336.61100-1-sth@linux.ibm.com>
From: Vineeth Vijayan <vneethv@linux.ibm.com>
Add an interface in the CIO layer to retrieve the information about the
Endpoint-Security Mode (ESM) of the specified CU. The ESM values are
defined as 0-None, 1-Authenticated or 2, 3-Encrypted.
Signed-off-by: Sebastian Ott <sebott@linux.ibm.com>
[vneethv@linux.ibm.com: cleaned-up and modified description]
Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
---
arch/s390/include/asm/cio.h | 1 +
drivers/s390/cio/chsc.c | 83 +++++++++++++++++++++++++++++++++++++
2 files changed, 84 insertions(+)
diff --git a/arch/s390/include/asm/cio.h b/arch/s390/include/asm/cio.h
index b5bfb3123cb1..66e06d0efb72 100644
--- a/arch/s390/include/asm/cio.h
+++ b/arch/s390/include/asm/cio.h
@@ -373,5 +373,6 @@ struct gen_pool *cio_gp_dma_create(struct device *dma_dev, int nr_pages);
int chsc_sstpc(void *page, unsigned int op, u16 ctrl, u64 *clock_delta);
int chsc_sstpi(void *page, void *result, size_t size);
int chsc_sgib(u32 origin);
+int chsc_scud(u16 cu, u64 *esm, u8 *esm_valid);
#endif
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index c314e9495c1b..513fc5748d6e 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -1403,3 +1403,86 @@ int chsc_sgib(u32 origin)
return ret;
}
EXPORT_SYMBOL_GPL(chsc_sgib);
+
+#define SCUD_REQ_LEN 0x10 /* SCUD request block length */
+#define SCUD_REQ_CMD 0x4b /* SCUD Command Code */
+
+struct chse_cudb {
+ u16 flags:8;
+ u16 chp_valid:8;
+ u16 cu;
+ u32 esm_valid:8;
+ u32:24;
+ u8 chpid[8];
+ u32:32;
+ u32:32;
+ u8 esm[8];
+ u32 efla[8];
+} __packed;
+
+struct chsc_scud {
+ struct chsc_header request;
+ u16:4;
+ u16 fmt:4;
+ u16 cssid:8;
+ u16 first_cu;
+ u16:16;
+ u16 last_cu;
+ u32:32;
+ struct chsc_header response;
+ u16:4;
+ u16 fmt_resp:4;
+ u32:24;
+ struct chse_cudb cudb[];
+} __packed;
+
+/**
+ * chsc_scud() - Store control-unit description.
+ * @cu: number of the control-unit
+ * @esm: 8 1-byte endpoint security mode values
+ * @esm_valid: validity mask for @esm
+ *
+ * Interface to retrieve information about the endpoint security
+ * modes for up to 8 paths of a control unit.
+ *
+ * Returns 0 on success.
+ */
+int chsc_scud(u16 cu, u64 *esm, u8 *esm_valid)
+{
+ struct chsc_scud *scud = chsc_page;
+ int ret;
+
+ spin_lock_irq(&chsc_page_lock);
+ memset(chsc_page, 0, PAGE_SIZE);
+ scud->request.length = SCUD_REQ_LEN;
+ scud->request.code = SCUD_REQ_CMD;
+ scud->fmt = 0;
+ scud->cssid = 0;
+ scud->first_cu = cu;
+ scud->last_cu = cu;
+
+ ret = chsc(scud);
+ if (!ret)
+ ret = chsc_error_from_response(scud->response.code);
+
+ if (!ret && (scud->response.length <= 8 || scud->fmt_resp != 0
+ || !(scud->cudb[0].flags & 0x80)
+ || scud->cudb[0].cu != cu)) {
+
+ CIO_MSG_EVENT(2, "chsc: scud failed rc=%04x, L2=%04x "
+ "FMT=%04x, cudb.flags=%02x, cudb.cu=%04x",
+ scud->response.code, scud->response.length,
+ scud->fmt_resp, scud->cudb[0].flags, scud->cudb[0].cu);
+ ret = -EINVAL;
+ }
+
+ if (ret)
+ goto out;
+
+ memcpy(esm, scud->cudb[0].esm, sizeof(*esm));
+ *esm_valid = scud->cudb[0].esm_valid;
+out:
+ spin_unlock_irq(&chsc_page_lock);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(chsc_scud);
--
2.17.1
next prev parent reply other threads:[~2020-10-08 13:13 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-08 13:13 [PATCH v2 00/10] DASD FC endpoint security Stefan Haberland
2020-10-08 13:13 ` [PATCH v2 01/10] s390/cio: Export information about Endpoint-Security Capability Stefan Haberland
2020-10-08 13:13 ` Stefan Haberland [this message]
2020-10-08 13:13 ` [PATCH v2 03/10] s390/cio: Add support for FCES status notification Stefan Haberland
2020-10-08 13:13 ` [PATCH v2 04/10] s390/dasd: Remove unused parameter from dasd_generic_probe() Stefan Haberland
2020-10-08 14:13 ` Cornelia Huck
2020-10-08 13:13 ` [PATCH v2 05/10] s390/dasd: Move duplicate code to separate function Stefan Haberland
2020-10-08 14:16 ` Cornelia Huck
2020-10-08 13:13 ` [PATCH v2 06/10] s390/dasd: Store path configuration data during path handling Stefan Haberland
2020-10-08 14:21 ` Cornelia Huck
2020-10-08 13:13 ` [PATCH v2 07/10] s390/dasd: Fix operational path inconsistency Stefan Haberland
2020-10-08 14:37 ` Cornelia Huck
2020-10-08 13:13 ` [PATCH v2 08/10] s390/dasd: Display FC Endpoint Security information via sysfs Stefan Haberland
2020-10-08 14:43 ` Cornelia Huck
2020-10-08 13:13 ` [PATCH v2 09/10] s390/dasd: Prepare for additional path event handling Stefan Haberland
2020-10-08 14:48 ` Cornelia Huck
2020-10-08 13:13 ` [PATCH v2 10/10] s390/dasd: Process FCES path event notification Stefan Haberland
2020-10-08 14:54 ` Cornelia Huck
2020-10-08 14:56 ` Jan Höppner
2020-10-12 19:06 ` [PATCH v2 00/10] DASD FC endpoint security Stefan Haberland
2020-10-12 19:33 ` Jens Axboe
2020-10-12 19:50 ` Stefan Haberland
2020-10-13 19:40 ` Jens Axboe
2020-10-13 20:15 ` Stefan Haberland
2020-10-14 1:19 ` Jens Axboe
2020-11-10 15:50 ` Stefan Haberland
2020-11-11 16:20 ` Jens Axboe
2020-11-12 13:27 ` Stefan Haberland
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=20201008131336.61100-3-sth@linux.ibm.com \
--to=sth@linux.ibm.com \
--cc=axboe@kernel.dk \
--cc=borntraeger@de.ibm.com \
--cc=gor@linux.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=hoeppner@linux.ibm.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).