[PATCH 1/5] pc-bios/s390-ccw: Allow to select a different pxelinux.cfg entry via loadparm

Thomas Huth posted 5 patches 4 months, 1 week ago
Maintainers: Thomas Huth <thuth@redhat.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Jared Rossi <jrossi@linux.ibm.com>, Zhuoying Cai <zycai@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>
There is a newer version of this series
[PATCH 1/5] pc-bios/s390-ccw: Allow to select a different pxelinux.cfg entry via loadparm
Posted by Thomas Huth 4 months, 1 week ago
From: Thomas Huth <thuth@redhat.com>

Since we're linking the network booting code into the main firmware
binary nowadays, we can support the "loadparm" parameter now quite
easily for pxelinux.cfg config files that contain multiple entries.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 pc-bios/s390-ccw/netmain.c | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c
index 719a547ada0..024b4419ef6 100644
--- a/pc-bios/s390-ccw/netmain.c
+++ b/pc-bios/s390-ccw/netmain.c
@@ -332,6 +332,28 @@ static int load_kernel_with_initrd(filename_ip_t *fn_ip,
     return rc;
 }
 
+static int net_select_and_load_kernel(filename_ip_t *fn_ip,
+                                      int num_ent, int selected,
+                                      struct pl_cfg_entry *entries)
+{
+    unsigned int loadparm = get_loadparm_index();
+
+    if (num_ent <= 0) {
+        return -1;
+    }
+
+    if (loadparm > num_ent) {
+        printf("Error: loadparm is set to entry #%d, but there are only "
+               "%d entries in the pxelinux.cfg file!\n"
+               "Using default entry now instead.\n",
+               loadparm, num_ent);
+    } else if (loadparm > 0) {
+        selected = loadparm - 1;
+    }
+
+    return load_kernel_with_initrd(fn_ip, &entries[selected]);
+}
+
 #define MAX_PXELINUX_ENTRIES 16
 
 static int net_try_pxelinux_cfg(filename_ip_t *fn_ip)
@@ -343,11 +365,8 @@ static int net_try_pxelinux_cfg(filename_ip_t *fn_ip)
                                       DEFAULT_TFTP_RETRIES,
                                       cfgbuf, sizeof(cfgbuf),
                                       entries, MAX_PXELINUX_ENTRIES, &def_ent);
-    if (num_ent > 0) {
-        return load_kernel_with_initrd(fn_ip, &entries[def_ent]);
-    }
 
-    return -1;
+    return net_select_and_load_kernel(fn_ip, num_ent, def_ent, entries);
 }
 
 /**
@@ -433,10 +452,8 @@ static int net_try_direct_tftp_load(filename_ip_t *fn_ip)
 
             num_ent = pxelinux_parse_cfg(cfgbuf, sizeof(cfgbuf), entries,
                                          MAX_PXELINUX_ENTRIES, &def_ent);
-            if (num_ent <= 0) {
-                return -1;
-            }
-            return load_kernel_with_initrd(fn_ip, &entries[def_ent]);
+            return net_select_and_load_kernel(fn_ip, num_ent, def_ent,
+                                              entries);
         }
     }
 
-- 
2.50.0
Re: [PATCH 1/5] pc-bios/s390-ccw: Allow to select a different pxelinux.cfg entry via loadparm
Posted by Jared Rossi 4 months, 1 week ago

On 7/8/25 8:56 AM, Thomas Huth wrote:
> From: Thomas Huth <thuth@redhat.com>
>
> Since we're linking the network booting code into the main firmware
> binary nowadays, we can support the "loadparm" parameter now quite
> easily for pxelinux.cfg config files that contain multiple entries.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   pc-bios/s390-ccw/netmain.c | 33 +++++++++++++++++++++++++--------
>   1 file changed, 25 insertions(+), 8 deletions(-)
>
> diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c
> index 719a547ada0..024b4419ef6 100644
> --- a/pc-bios/s390-ccw/netmain.c
> +++ b/pc-bios/s390-ccw/netmain.c
> @@ -332,6 +332,28 @@ static int load_kernel_with_initrd(filename_ip_t *fn_ip,
>       return rc;
>   }
>   
> +static int net_select_and_load_kernel(filename_ip_t *fn_ip,
> +                                      int num_ent, int selected,
> +                                      struct pl_cfg_entry *entries)
> +{
> +    unsigned int loadparm = get_loadparm_index();
> +
> +    if (num_ent <= 0) {
> +        return -1;
> +    }
> +
> +    if (loadparm > num_ent) {
> +        printf("Error: loadparm is set to entry #%d, but there are only "
> +               "%d entries in the pxelinux.cfg file!\n"
> +               "Using default entry now instead.\n",
> +               loadparm, num_ent);
Commit 64fa0de established that the IPL should abort on any loadparm 
misconfiguration, therefore I think this should result in a fatal error 
rather than using the default.

> +    } else if (loadparm > 0) {
> +        selected = loadparm - 1;
> +    }
> +
> +    return load_kernel_with_initrd(fn_ip, &entries[selected]);
> +}
> +
>   #define MAX_PXELINUX_ENTRIES 16
>   
>   static int net_try_pxelinux_cfg(filename_ip_t *fn_ip)
> @@ -343,11 +365,8 @@ static int net_try_pxelinux_cfg(filename_ip_t *fn_ip)
>                                         DEFAULT_TFTP_RETRIES,
>                                         cfgbuf, sizeof(cfgbuf),
>                                         entries, MAX_PXELINUX_ENTRIES, &def_ent);
> -    if (num_ent > 0) {
> -        return load_kernel_with_initrd(fn_ip, &entries[def_ent]);
> -    }
>   
> -    return -1;
> +    return net_select_and_load_kernel(fn_ip, num_ent, def_ent, entries);
>   }
>   
>   /**
> @@ -433,10 +452,8 @@ static int net_try_direct_tftp_load(filename_ip_t *fn_ip)
>   
>               num_ent = pxelinux_parse_cfg(cfgbuf, sizeof(cfgbuf), entries,
>                                            MAX_PXELINUX_ENTRIES, &def_ent);
> -            if (num_ent <= 0) {
> -                return -1;
> -            }
> -            return load_kernel_with_initrd(fn_ip, &entries[def_ent]);
> +            return net_select_and_load_kernel(fn_ip, num_ent, def_ent,
> +                                              entries);
>           }
>       }
>
Re: [PATCH 1/5] pc-bios/s390-ccw: Allow to select a different pxelinux.cfg entry via loadparm
Posted by Thomas Huth 4 months, 1 week ago
On 08/07/2025 15.13, Jared Rossi wrote:
> 
> 
> On 7/8/25 8:56 AM, Thomas Huth wrote:
>> From: Thomas Huth <thuth@redhat.com>
>>
>> Since we're linking the network booting code into the main firmware
>> binary nowadays, we can support the "loadparm" parameter now quite
>> easily for pxelinux.cfg config files that contain multiple entries.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>   pc-bios/s390-ccw/netmain.c | 33 +++++++++++++++++++++++++--------
>>   1 file changed, 25 insertions(+), 8 deletions(-)
>>
>> diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c
>> index 719a547ada0..024b4419ef6 100644
>> --- a/pc-bios/s390-ccw/netmain.c
>> +++ b/pc-bios/s390-ccw/netmain.c
>> @@ -332,6 +332,28 @@ static int load_kernel_with_initrd(filename_ip_t *fn_ip,
>>       return rc;
>>   }
>> +static int net_select_and_load_kernel(filename_ip_t *fn_ip,
>> +                                      int num_ent, int selected,
>> +                                      struct pl_cfg_entry *entries)
>> +{
>> +    unsigned int loadparm = get_loadparm_index();
>> +
>> +    if (num_ent <= 0) {
>> +        return -1;
>> +    }
>> +
>> +    if (loadparm > num_ent) {
>> +        printf("Error: loadparm is set to entry #%d, but there are only "
>> +               "%d entries in the pxelinux.cfg file!\n"
>> +               "Using default entry now instead.\n",
>> +               loadparm, num_ent);
> Commit 64fa0de established that the IPL should abort on any loadparm 
> misconfiguration, therefore I think this should result in a fatal error 
> rather than using the default.

Ah, right, I already forgot that, thanks for the reminder! I'll change it in 
v2 accordingly.

  Thomas