Skip to contentSkip to conversation

powerpc: increase MIN RMA size for CAS negotiation

PATCH Superseded Avnish Chouhan 2 participants 3 messages Mar 12, 2025 – Mar 13, 2025

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 powerpc: increase MIN RMA size for CAS negotiation

Change RMA size from 512 MB to 768 MB which will result
in more memory at boot time for PowerPC. When vTPM, Secure Boot or FADump are enabled on PowerPC, the 512 MB RMA memory is not sufficient for booting. With this 512 MB RMA, GRUB2 runs out of memory and fails to boot the machine. Sometimes even usage of CDROM requires more memory for installation and along with the options mentioned above exhausts the boot memory which results in boot failures. Increasing the RMA size will resolves multiple out of memory issues observed in PowerPC.

Failure details (GRUB2 debugs):

kern/ieee1275/init.c:550: mm requested region of size 8513000, flags 1 kern/ieee1275/init.c:563: Cannot satisfy allocation and retain minimum runtime space kern/ieee1275/init.c:550: mm requested region of size 8513000, flags 0 kern/ieee1275/init.c:563: Cannot satisfy allocation and retain minimum runtime space kern/file.c:215: Closing `/ppc/ppc64/initrd.img' ...
kern/disk.c:297: Closing ieee1275//vdevice/v-scsi@30000067/disk@8300000000000000'... kern/disk.c:311: Closing ieee1275//vdevice/v-scsi@30000067/disk@8300000000000000' succeeded. kern/file.c:225: Closing /ppc/ppc64/initrd.img' failed with 3. kern/file.c:148: Opening /ppc/ppc64/initrd.img' succeeded.
error: ../../grub-core/kern/mm.c:552:out of memory.

---
 grub-core/kern/ieee1275/init.c | 44 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 40 insertions(+), 4 deletions(-)
grub-core/kern/ieee1275/init.c +40 -4
index dfbd0b8..aa3c932 100644
@@ -852,7 +852,7 @@ grub_ieee1275_ibm_cas (void)
     .vec1 = 0x80, /* ignore */
     .vec2_size = 1 + sizeof (struct option_vector2) - 2,
     .vec2 = {
-      0, 0, -1, -1, -1, -1, -1, 512, -1, 0, 48
+      0, 0, -1, -1, -1, -1, -1, 768, -1, 0, 48
     },
     .vec3_size = 2 - 1,
     .vec3 = 0x00e0, /* ask for FP + VMX + DFP but don't halt if unsatisfied */
@@ -889,6 +889,10 @@ grub_claim_heap (void)
 {
   grub_err_t err;
   grub_uint32_t total = HEAP_MAX_SIZE;
+#if defined(__powerpc__)
+  grub_uint32_t ibm_ca_support_reboot = 0;
+  grub_ssize_t actual;
+#endif
 
   err = grub_ieee1275_total_mem (&rmo_top);
 
@@ -901,11 +905,43 @@ grub_claim_heap (void)
     grub_mm_add_region_fn = grub_ieee1275_mm_add_region;
 
 #if defined(__powerpc__)
+  /* Check if it's a CAS reboot with below property. If so, we will skip CAS call */
+  if (grub_ieee1275_get_integer_property (grub_ieee1275_chosen,
+                                          "ibm,client-architecture-support-reboot",
+                                          &ibm_ca_support_reboot,
+                                          sizeof (ibm_ca_support_reboot),
+                                          &actual) >= 0)
+    grub_dprintf ("ieee1275", "ibm,client-architecture-support-reboot: %u\n",
+                  ibm_ca_support_reboot);
+
   if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CAN_TRY_CAS_FOR_MORE_MEMORY))
     {
-      /* if we have an error, don't call CAS, just hope for the best */
-      if (err == GRUB_ERR_NONE && rmo_top < (512 * 1024 * 1024))
-	grub_ieee1275_ibm_cas ();
+      /*
+       * If we have an error, don't call CAS. Just hope for the best.
+       * Along with the above, if the rmo_top is 512 MB or above. We
+       * will skip the CAS call. However, if we call CAS, the rmo_top
+       * will be set to 768 MB via CAS Vector2. But we need to call
+       * CAS with "rmo_top < 512 MB" to avoid the issue on the older
+       * Linux kernel, which still uses rmo_top as 512 MB. If we call
+       * CAS with a condition "rmo_top < 768 MB", it will result in an
+       * issue due to the IBM CAS reboot feature and we won't be able
+       * to boot the newer kernel. Whenever a reboot is detected as
+       * the CAS reboot by GRUB. It will boot the machine with the
+       * last booted kernel by reading the variable "boot-last-label"
+       * which has the info related to the last boot and it's specific
+       * to IBM PowerPC. Due to this, the machine will boot with the
+       * last booted kernel which has rmo_top as 512 MB. Also, if the
+       * reboot is detected as a CAS reboot, the GRUB will skip the CAS
+       * call. As the CAS has already been called earlier, so it is
+       * not required to call CAS even if the other conditions are met.
+       * This condition will prevent a scenario where the machine will
+       * keep doing the CAS calls and change MIN_RMA from 512 to 768 to
+       * 512 to 768 and so on older kernels. Without this check, the
+       * machine will stuck in this mentioned stage forever.
+       * IBM PAPR : https://openpower.foundation/specifications/linuxonpower/
+       */
+      if (!ibm_ca_support_reboot && err == GRUB_ERR_NONE && rmo_top < (512 * 1024 * 1024))
+        grub_ieee1275_ibm_cas ();
     }
 #endif
 
Signature · 7 lines
2.39.3


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#1 lore raw

grub-core/kern/ieee1275/init.c grub_ieee1275_ibm_cas (void)

Quoted 32 lines · Avnish Chouhan

Change RMA size from 512 MB to 768 MB which will result
in more memory at boot time for PowerPC. When vTPM, Secure Boot or FADump are enabled on PowerPC, the 512 MB RMA memory is not sufficient for booting. With this 512 MB RMA, GRUB2 runs out of memory and fails to boot the machine. Sometimes even usage of CDROM requires more memory for installation and along with the options mentioned above exhausts the boot memory which results in boot failures. Increasing the RMA size will resolves multiple out of memory issues observed in PowerPC.

Failure details (GRUB2 debugs):

kern/ieee1275/init.c:550: mm requested region of size 8513000, flags 1 kern/ieee1275/init.c:563: Cannot satisfy allocation and retain minimum runtime space kern/ieee1275/init.c:550: mm requested region of size 8513000, flags 0 kern/ieee1275/init.c:563: Cannot satisfy allocation and retain minimum runtime space kern/file.c:215: Closing `/ppc/ppc64/initrd.img' ...
kern/disk.c:297: Closing ieee1275//vdevice/v-scsi@30000067/disk@8300000000000000'... kern/disk.c:311: Closing ieee1275//vdevice/v-scsi@30000067/disk@8300000000000000' succeeded. kern/file.c:225: Closing /ppc/ppc64/initrd.img' failed with 3. kern/file.c:148: Opening /ppc/ppc64/initrd.img' succeeded.
error: ../../grub-core/kern/mm.c:552:out of memory.

---
 grub-core/kern/ieee1275/init.c | 44 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 40 insertions(+), 4 deletions(-)
grub-core/kern/ieee1275/init.c +0 -0
index dfbd0b8..aa3c932 100644
@@ -852,7 +852,7 @@ grub_ieee1275_ibm_cas (void)

The function is preceded by a comment which is not correct after this patch.

Quoted 20 lines
grub-core/kern/ieee1275/init.c +5 -1
     .vec1 = 0x80, /* ignore */
     .vec2_size = 1 + sizeof (struct option_vector2) - 2,
     .vec2 = {
-      0, 0, -1, -1, -1, -1, -1, 512, -1, 0, 48
+      0, 0, -1, -1, -1, -1, -1, 768, -1, 0, 48
     },
     .vec3_size = 2 - 1,
     .vec3 = 0x00e0, /* ask for FP + VMX + DFP but don't halt if unsatisfied */
@@ -889,6 +889,10 @@ grub_claim_heap (void)
 {
   grub_err_t err;
   grub_uint32_t total = HEAP_MAX_SIZE;
+#if defined(__powerpc__)
+  grub_uint32_t ibm_ca_support_reboot = 0;
+  grub_ssize_t actual;
+#endif
 
   err = grub_ieee1275_total_mem (&rmo_top);
 

grub-core/kern/ieee1275/init.c grub_claim_heap (void) · line 914

Quoted 10 lines
grub-core/kern/ieee1275/init.c +7 -0
@@ -901,11 +905,43 @@ grub_claim_heap (void)
     grub_mm_add_region_fn = grub_ieee1275_mm_add_region;
 
 #if defined(__powerpc__)
+  /* Check if it's a CAS reboot with below property. If so, we will skip CAS call */
+  if (grub_ieee1275_get_integer_property (grub_ieee1275_chosen,
+                                          "ibm,client-architecture-support-reboot",
+                                          &ibm_ca_support_reboot,
+                                          sizeof (ibm_ca_support_reboot),
+                                          &actual) >= 0)
+    grub_dprintf ("ieee1275", "ibm,client-architecture-support-reboot: %u\n",

Even if "%u" is correct please use PRIuGRUB_UINT32_T instead.

Quoted 18 lines
grub-core/kern/ieee1275/init.c +13 -3
+                  ibm_ca_support_reboot);
+
   if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CAN_TRY_CAS_FOR_MORE_MEMORY))
     {
-      /* if we have an error, don't call CAS, just hope for the best */
-      if (err == GRUB_ERR_NONE && rmo_top < (512 * 1024 * 1024))
-	grub_ieee1275_ibm_cas ();
+      /*
+       * If we have an error, don't call CAS. Just hope for the best.
+       * Along with the above, if the rmo_top is 512 MB or above. We
+       * will skip the CAS call. However, if we call CAS, the rmo_top
+       * will be set to 768 MB via CAS Vector2. But we need to call
+       * CAS with "rmo_top < 512 MB" to avoid the issue on the older
+       * Linux kernel, which still uses rmo_top as 512 MB. If we call
+       * CAS with a condition "rmo_top < 768 MB", it will result in an
+       * issue due to the IBM CAS reboot feature and we won't be able
+       * to boot the newer kernel. Whenever a reboot is detected as
+       * the CAS reboot by GRUB. It will boot the machine with the

grub-core/kern/ieee1275/init.c grub_claim_heap (void) · line 939

Quoted 10 lines
grub-core/kern/ieee1275/init.c +10 -0
+       * last booted kernel by reading the variable "boot-last-label"
+       * which has the info related to the last boot and it's specific
+       * to IBM PowerPC. Due to this, the machine will boot with the
+       * last booted kernel which has rmo_top as 512 MB. Also, if the
+       * reboot is detected as a CAS reboot, the GRUB will skip the CAS
+       * call. As the CAS has already been called earlier, so it is
+       * not required to call CAS even if the other conditions are met.
+       * This condition will prevent a scenario where the machine will
+       * keep doing the CAS calls and change MIN_RMA from 512 to 768 to
+       * 512 to 768 and so on older kernels. Without this check, the

It is not entirely clear what changes MIN_RMA back from 768 to 512. I think it should be explained/clarified.

grub-core/kern/ieee1275/init.c grub_claim_heap (void) · line 941

Quoted 2 lines
grub-core/kern/ieee1275/init.c +2 -0
+       * machine will stuck in this mentioned stage forever.
+       * IBM PAPR : https://openpower.foundation/specifications/linuxonpower/

Thank you for adding the link to the spec.

Now the commit message and comment looks much better.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#2 lore raw
Quoted 35 lines · Daniel Kiper
Quoted 34 lines · Avnish Chouhan

Change RMA size from 512 MB to 768 MB which will result
in more memory at boot time for PowerPC. When vTPM, Secure Boot or FADump are enabled on PowerPC, the 512 MB RMA memory is not sufficient for booting. With this 512 MB RMA, GRUB2 runs out of memory and fails to boot the machine. Sometimes even usage of CDROM requires more memory for installation and along with the options mentioned above exhausts the boot memory which results in boot failures. Increasing the RMA size will resolves multiple out of memory issues observed in PowerPC.

Failure details (GRUB2 debugs):

kern/ieee1275/init.c:550: mm requested region of size 8513000, flags
1
kern/ieee1275/init.c:563: Cannot satisfy allocation and retain
minimum runtime space
kern/ieee1275/init.c:550: mm requested region of size 8513000, flags
0
kern/ieee1275/init.c:563: Cannot satisfy allocation and retain
minimum runtime space
kern/file.c:215: Closing `/ppc/ppc64/initrd.img' ... kern/disk.c:297: Closing
`ieee1275//vdevice/v-scsi@30000067/disk@8300000000000000'...
kern/disk.c:311: Closing
`ieee1275//vdevice/v-scsi@30000067/disk@8300000000000000' succeeded.
kern/file.c:225: Closing /ppc/ppc64/initrd.img' failed with 3. kern/file.c:148: Opening /ppc/ppc64/initrd.img' succeeded.
error: ../../grub-core/kern/mm.c:552:out of memory.

---
 grub-core/kern/ieee1275/init.c | 44 
++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 40 insertions(+), 4 deletions(-)
Quoted 7 lines

grub-core/kern/ieee1275/init.c grub_ieee1275_ibm_cas (void)

Quoted 5 lines
grub-core/kern/ieee1275/init.c +0 -0
index dfbd0b8..aa3c932 100644
@@ -852,7 +852,7 @@ grub_ieee1275_ibm_cas (void)

The function is preceded by a comment which is not correct after this patch.

Hi Daniel,
Thank you for your reviews!

I'll change this comment.

Quoted 24 lines
Quoted 24 lines
grub-core/kern/ieee1275/init.c +1 -1
     .vec1 = 0x80, /* ignore */
     .vec2_size = 1 + sizeof (struct option_vector2) - 2,
     .vec2 = {
-      0, 0, -1, -1, -1, -1, -1, 512, -1, 0, 48
+      0, 0, -1, -1, -1, -1, -1, 768, -1, 0, 48
     },
     .vec3_size = 2 - 1,
     .vec3 = 0x00e0, /* ask for FP + VMX + DFP but don't halt if 

unsatisfied */

grub-core/kern/ieee1275/init.c +4 -0
@@ -889,6 +889,10 @@ grub_claim_heap (void)
 {
   grub_err_t err;
   grub_uint32_t total = HEAP_MAX_SIZE;
+#if defined(__powerpc__)
+  grub_uint32_t ibm_ca_support_reboot = 0;
+  grub_ssize_t actual;
+#endif
 
   err = grub_ieee1275_total_mem (&rmo_top);
 
@@ -901,11 +905,43 @@ grub_claim_heap (void)
     grub_mm_add_region_fn = grub_ieee1275_mm_add_region;
 
Quoted 14 lines
Quoted 11 lines
grub-core/kern/ieee1275/init.c +1 -0
 #if defined(__powerpc__)
+  /* Check if it's a CAS reboot with below property. If so, we will 

skip CAS call */

grub-core/kern/ieee1275/init.c +2 -0
+  if (grub_ieee1275_get_integer_property (grub_ieee1275_chosen,
+                                          

"ibm,client-architecture-support-reboot",

grub-core/kern/ieee1275/init.c +2 -0
+                                          &ibm_ca_support_reboot,
+                                          sizeof 

(ibm_ca_support_reboot),

grub-core/kern/ieee1275/init.c +2 -0
+                                          &actual) >= 0)
+    grub_dprintf ("ieee1275", 
Quoted 1 line

"ibm,client-architecture-support-reboot: %u\n",

Even if "%u" is correct please use PRIuGRUB_UINT32_T instead.

Sure, I'll change this!

Quoted 32 lines
Quoted 32 lines
grub-core/kern/ieee1275/init.c +2 -0
+                  ibm_ca_support_reboot);
+
   if (grub_ieee1275_test_flag 

(GRUB_IEEE1275_FLAG_CAN_TRY_CAS_FOR_MORE_MEMORY))

     {

- /* if we have an error, don't call CAS, just hope for the best
*/

grub-core/kern/ieee1275/init.c +8 -2
-      if (err == GRUB_ERR_NONE && rmo_top < (512 * 1024 * 1024))
-	grub_ieee1275_ibm_cas ();
+      /*
+       * If we have an error, don't call CAS. Just hope for the best.
+       * Along with the above, if the rmo_top is 512 MB or above. We
+       * will skip the CAS call. However, if we call CAS, the rmo_top
+       * will be set to 768 MB via CAS Vector2. But we need to call
+       * CAS with "rmo_top < 512 MB" to avoid the issue on the older
+       * Linux kernel, which still uses rmo_top as 512 MB. If we call
+       * CAS with a condition "rmo_top < 768 MB", it will result in 

an

grub-core/kern/ieee1275/init.c +5 -0
+       * issue due to the IBM CAS reboot feature and we won't be able
+       * to boot the newer kernel. Whenever a reboot is detected as
+       * the CAS reboot by GRUB. It will boot the machine with the
+       * last booted kernel by reading the variable "boot-last-label"
+       * which has the info related to the last boot and it's 

specific

grub-core/kern/ieee1275/init.c +3 -0
+       * to IBM PowerPC. Due to this, the machine will boot with the
+       * last booted kernel which has rmo_top as 512 MB. Also, if the
+       * reboot is detected as a CAS reboot, the GRUB will skip the 

CAS

grub-core/kern/ieee1275/init.c +2 -0
+       * call. As the CAS has already been called earlier, so it is
+       * not required to call CAS even if the other conditions are 

met.

Quoted 8 lines
Quoted 5 lines

+ * This condition will prevent a scenario where the machine
will
+ * keep doing the CAS calls and change MIN_RMA from 512 to 768
to
+ * 512 to 768 and so on older kernels. Without this check, the

It is not entirely clear what changes MIN_RMA back from 768 to 512. I think it should be explained/clarified.

Sure, I'll explain this as suggested!

Quoted 10 lines
Quoted 4 lines
grub-core/kern/ieee1275/init.c +2 -0
+       * machine will stuck in this mentioned stage forever.
+       * IBM PAPR : 

https://openpower.foundation/specifications/linuxonpower/

Thank you for adding the link to the spec.

Now the commit message and comment looks much better.

Daniel

Regards,
Avnish Chouhan

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel