diff mbox series

[SRU,G,H,1/1] s390/ipl: support NVMe IPL kernel parameters

Message ID 20201102160755.228264-2-frank.heimes@canonical.com
State New
Headers show
Series [SRU,G,H,1/1] s390/ipl: support NVMe IPL kernel parameters | expand

Commit Message

Frank Heimes Nov. 2, 2020, 4:07 p.m. UTC
From: Alexander Egorenkov <egorenar@linux.ibm.com>

BugLink: https://bugs.launchpad.net/bugs/1902179

Enable extracting of extra kernel command-line parameters
from the NVMe IPL block passed by the firmware to the kernel
at boot.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
(cherry picked from commit d9f12e48d08ec08ace574050a838e001e442ee38 linux-next)
Signed-off-by: Frank Heimes <frank.heimes@canonical.com>
---
 arch/s390/boot/ipl_parm.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

Comments

Stefan Bader Nov. 3, 2020, 11:09 a.m. UTC | #1
On 02.11.20 17:07, frank.heimes@canonical.com wrote:
> From: Alexander Egorenkov <egorenar@linux.ibm.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1902179
> 
> Enable extracting of extra kernel command-line parameters
> from the NVMe IPL block passed by the firmware to the kernel
> at boot.
> 
> Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
> Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
> Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
> (cherry picked from commit d9f12e48d08ec08ace574050a838e001e442ee38 linux-next)
> Signed-off-by: Frank Heimes <frank.heimes@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---

Limited to single arch bootup code and positive testing there.

>  arch/s390/boot/ipl_parm.c | 31 +++++++++++++++++++++++--------
>  1 file changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/s390/boot/ipl_parm.c b/arch/s390/boot/ipl_parm.c
> index 8e222a666025..12d1c0c527ee 100644
> --- a/arch/s390/boot/ipl_parm.c
> +++ b/arch/s390/boot/ipl_parm.c
> @@ -70,30 +70,44 @@ static size_t scpdata_length(const u8 *buf, size_t count)
>  static size_t ipl_block_get_ascii_scpdata(char *dest, size_t size,
>  					  const struct ipl_parameter_block *ipb)
>  {
> -	size_t count;
> -	size_t i;
> +	const __u8 *scp_data;
> +	__u32 scp_data_len;
>  	int has_lowercase;
> +	size_t count = 0;
> +	size_t i;
> +
> +	switch (ipb->pb0_hdr.pbt) {
> +	case IPL_PBT_FCP:
> +		scp_data_len = ipb->fcp.scp_data_len;
> +		scp_data = ipb->fcp.scp_data;
> +		break;
> +	case IPL_PBT_NVME:
> +		scp_data_len = ipb->nvme.scp_data_len;
> +		scp_data = ipb->nvme.scp_data;
> +		break;
> +	default:
> +		goto out;
> +	}
>  
> -	count = min(size - 1, scpdata_length(ipb->fcp.scp_data,
> -					     ipb->fcp.scp_data_len));
> +	count = min(size - 1, scpdata_length(scp_data, scp_data_len));
>  	if (!count)
>  		goto out;
>  
>  	has_lowercase = 0;
>  	for (i = 0; i < count; i++) {
> -		if (!isascii(ipb->fcp.scp_data[i])) {
> +		if (!isascii(scp_data[i])) {
>  			count = 0;
>  			goto out;
>  		}
> -		if (!has_lowercase && islower(ipb->fcp.scp_data[i]))
> +		if (!has_lowercase && islower(scp_data[i]))
>  			has_lowercase = 1;
>  	}
>  
>  	if (has_lowercase)
> -		memcpy(dest, ipb->fcp.scp_data, count);
> +		memcpy(dest, scp_data, count);
>  	else
>  		for (i = 0; i < count; i++)
> -			dest[i] = tolower(ipb->fcp.scp_data[i]);
> +			dest[i] = tolower(scp_data[i]);
>  out:
>  	dest[count] = '\0';
>  	return count;
> @@ -115,6 +129,7 @@ static void append_ipl_block_parm(void)
>  			parm, COMMAND_LINE_SIZE - len - 1, &ipl_block);
>  		break;
>  	case IPL_PBT_FCP:
> +	case IPL_PBT_NVME:
>  		rc = ipl_block_get_ascii_scpdata(
>  			parm, COMMAND_LINE_SIZE - len - 1, &ipl_block);
>  		break;
>
Kleber Souza Nov. 4, 2020, 8:36 a.m. UTC | #2
On 02.11.20 17:07, frank.heimes@canonical.com wrote:
> From: Alexander Egorenkov <egorenar@linux.ibm.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1902179
> 
> Enable extracting of extra kernel command-line parameters
> from the NVMe IPL block passed by the firmware to the kernel
> at boot.
> 
> Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
> Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
> Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
> (cherry picked from commit d9f12e48d08ec08ace574050a838e001e442ee38 linux-next)

This commit was already merged into Linus' tree (v5.10-rc1) so the
'linux-next' part can be removed when applying.

> Signed-off-by: Frank Heimes <frank.heimes@canonical.com>

Limited to s390x, clean cherry-pick and with good test results.

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>

> ---
>   arch/s390/boot/ipl_parm.c | 31 +++++++++++++++++++++++--------
>   1 file changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/s390/boot/ipl_parm.c b/arch/s390/boot/ipl_parm.c
> index 8e222a666025..12d1c0c527ee 100644
> --- a/arch/s390/boot/ipl_parm.c
> +++ b/arch/s390/boot/ipl_parm.c
> @@ -70,30 +70,44 @@ static size_t scpdata_length(const u8 *buf, size_t count)
>   static size_t ipl_block_get_ascii_scpdata(char *dest, size_t size,
>   					  const struct ipl_parameter_block *ipb)
>   {
> -	size_t count;
> -	size_t i;
> +	const __u8 *scp_data;
> +	__u32 scp_data_len;
>   	int has_lowercase;
> +	size_t count = 0;
> +	size_t i;
> +
> +	switch (ipb->pb0_hdr.pbt) {
> +	case IPL_PBT_FCP:
> +		scp_data_len = ipb->fcp.scp_data_len;
> +		scp_data = ipb->fcp.scp_data;
> +		break;
> +	case IPL_PBT_NVME:
> +		scp_data_len = ipb->nvme.scp_data_len;
> +		scp_data = ipb->nvme.scp_data;
> +		break;
> +	default:
> +		goto out;
> +	}
>   
> -	count = min(size - 1, scpdata_length(ipb->fcp.scp_data,
> -					     ipb->fcp.scp_data_len));
> +	count = min(size - 1, scpdata_length(scp_data, scp_data_len));
>   	if (!count)
>   		goto out;
>   
>   	has_lowercase = 0;
>   	for (i = 0; i < count; i++) {
> -		if (!isascii(ipb->fcp.scp_data[i])) {
> +		if (!isascii(scp_data[i])) {
>   			count = 0;
>   			goto out;
>   		}
> -		if (!has_lowercase && islower(ipb->fcp.scp_data[i]))
> +		if (!has_lowercase && islower(scp_data[i]))
>   			has_lowercase = 1;
>   	}
>   
>   	if (has_lowercase)
> -		memcpy(dest, ipb->fcp.scp_data, count);
> +		memcpy(dest, scp_data, count);
>   	else
>   		for (i = 0; i < count; i++)
> -			dest[i] = tolower(ipb->fcp.scp_data[i]);
> +			dest[i] = tolower(scp_data[i]);
>   out:
>   	dest[count] = '\0';
>   	return count;
> @@ -115,6 +129,7 @@ static void append_ipl_block_parm(void)
>   			parm, COMMAND_LINE_SIZE - len - 1, &ipl_block);
>   		break;
>   	case IPL_PBT_FCP:
> +	case IPL_PBT_NVME:
>   		rc = ipl_block_get_ascii_scpdata(
>   			parm, COMMAND_LINE_SIZE - len - 1, &ipl_block);
>   		break;
>
Ian May Nov. 4, 2020, 10:39 p.m. UTC | #3
Applied to groovy/master-next
Per Kleber's ack, removed linux-next from cherry pick message.

Thanks,
Ian

On 2020-11-02 17:07:55 , frank.heimes@canonical.com wrote:
> From: Alexander Egorenkov <egorenar@linux.ibm.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1902179
> 
> Enable extracting of extra kernel command-line parameters
> from the NVMe IPL block passed by the firmware to the kernel
> at boot.
> 
> Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
> Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
> Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
> (cherry picked from commit d9f12e48d08ec08ace574050a838e001e442ee38 linux-next)
> Signed-off-by: Frank Heimes <frank.heimes@canonical.com>
> ---
>  arch/s390/boot/ipl_parm.c | 31 +++++++++++++++++++++++--------
>  1 file changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/s390/boot/ipl_parm.c b/arch/s390/boot/ipl_parm.c
> index 8e222a666025..12d1c0c527ee 100644
> --- a/arch/s390/boot/ipl_parm.c
> +++ b/arch/s390/boot/ipl_parm.c
> @@ -70,30 +70,44 @@ static size_t scpdata_length(const u8 *buf, size_t count)
>  static size_t ipl_block_get_ascii_scpdata(char *dest, size_t size,
>  					  const struct ipl_parameter_block *ipb)
>  {
> -	size_t count;
> -	size_t i;
> +	const __u8 *scp_data;
> +	__u32 scp_data_len;
>  	int has_lowercase;
> +	size_t count = 0;
> +	size_t i;
> +
> +	switch (ipb->pb0_hdr.pbt) {
> +	case IPL_PBT_FCP:
> +		scp_data_len = ipb->fcp.scp_data_len;
> +		scp_data = ipb->fcp.scp_data;
> +		break;
> +	case IPL_PBT_NVME:
> +		scp_data_len = ipb->nvme.scp_data_len;
> +		scp_data = ipb->nvme.scp_data;
> +		break;
> +	default:
> +		goto out;
> +	}
>  
> -	count = min(size - 1, scpdata_length(ipb->fcp.scp_data,
> -					     ipb->fcp.scp_data_len));
> +	count = min(size - 1, scpdata_length(scp_data, scp_data_len));
>  	if (!count)
>  		goto out;
>  
>  	has_lowercase = 0;
>  	for (i = 0; i < count; i++) {
> -		if (!isascii(ipb->fcp.scp_data[i])) {
> +		if (!isascii(scp_data[i])) {
>  			count = 0;
>  			goto out;
>  		}
> -		if (!has_lowercase && islower(ipb->fcp.scp_data[i]))
> +		if (!has_lowercase && islower(scp_data[i]))
>  			has_lowercase = 1;
>  	}
>  
>  	if (has_lowercase)
> -		memcpy(dest, ipb->fcp.scp_data, count);
> +		memcpy(dest, scp_data, count);
>  	else
>  		for (i = 0; i < count; i++)
> -			dest[i] = tolower(ipb->fcp.scp_data[i]);
> +			dest[i] = tolower(scp_data[i]);
>  out:
>  	dest[count] = '\0';
>  	return count;
> @@ -115,6 +129,7 @@ static void append_ipl_block_parm(void)
>  			parm, COMMAND_LINE_SIZE - len - 1, &ipl_block);
>  		break;
>  	case IPL_PBT_FCP:
> +	case IPL_PBT_NVME:
>  		rc = ipl_block_get_ascii_scpdata(
>  			parm, COMMAND_LINE_SIZE - len - 1, &ipl_block);
>  		break;
> -- 
> 2.25.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
diff mbox series

Patch

diff --git a/arch/s390/boot/ipl_parm.c b/arch/s390/boot/ipl_parm.c
index 8e222a666025..12d1c0c527ee 100644
--- a/arch/s390/boot/ipl_parm.c
+++ b/arch/s390/boot/ipl_parm.c
@@ -70,30 +70,44 @@  static size_t scpdata_length(const u8 *buf, size_t count)
 static size_t ipl_block_get_ascii_scpdata(char *dest, size_t size,
 					  const struct ipl_parameter_block *ipb)
 {
-	size_t count;
-	size_t i;
+	const __u8 *scp_data;
+	__u32 scp_data_len;
 	int has_lowercase;
+	size_t count = 0;
+	size_t i;
+
+	switch (ipb->pb0_hdr.pbt) {
+	case IPL_PBT_FCP:
+		scp_data_len = ipb->fcp.scp_data_len;
+		scp_data = ipb->fcp.scp_data;
+		break;
+	case IPL_PBT_NVME:
+		scp_data_len = ipb->nvme.scp_data_len;
+		scp_data = ipb->nvme.scp_data;
+		break;
+	default:
+		goto out;
+	}
 
-	count = min(size - 1, scpdata_length(ipb->fcp.scp_data,
-					     ipb->fcp.scp_data_len));
+	count = min(size - 1, scpdata_length(scp_data, scp_data_len));
 	if (!count)
 		goto out;
 
 	has_lowercase = 0;
 	for (i = 0; i < count; i++) {
-		if (!isascii(ipb->fcp.scp_data[i])) {
+		if (!isascii(scp_data[i])) {
 			count = 0;
 			goto out;
 		}
-		if (!has_lowercase && islower(ipb->fcp.scp_data[i]))
+		if (!has_lowercase && islower(scp_data[i]))
 			has_lowercase = 1;
 	}
 
 	if (has_lowercase)
-		memcpy(dest, ipb->fcp.scp_data, count);
+		memcpy(dest, scp_data, count);
 	else
 		for (i = 0; i < count; i++)
-			dest[i] = tolower(ipb->fcp.scp_data[i]);
+			dest[i] = tolower(scp_data[i]);
 out:
 	dest[count] = '\0';
 	return count;
@@ -115,6 +129,7 @@  static void append_ipl_block_parm(void)
 			parm, COMMAND_LINE_SIZE - len - 1, &ipl_block);
 		break;
 	case IPL_PBT_FCP:
+	case IPL_PBT_NVME:
 		rc = ipl_block_get_ascii_scpdata(
 			parm, COMMAND_LINE_SIZE - len - 1, &ipl_block);
 		break;