Skip to content

Commit 104fa47

Browse files
Avnish Chouhanlsandov1
Avnish Chouhan
authored andcommitted
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. Signed-off-by: Avnish Chouhan <[email protected]>
1 parent 3fdbfff commit 104fa47

File tree

1 file changed

+46
-5
lines changed

1 file changed

+46
-5
lines changed

grub-core/kern/ieee1275/init.c

+46-5
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ struct cas_vector
737737

738738
/*
739739
* Call ibm,client-architecture-support to try to get more RMA.
740-
* We ask for 512MB which should be enough to verify a distro kernel.
740+
* We ask for 768MB which should be enough to verify a distro kernel.
741741
* We ignore most errors: if we don't succeed we'll proceed with whatever
742742
* memory we have.
743743
*/
@@ -809,7 +809,7 @@ grub_ieee1275_ibm_cas (void)
809809
.vec1 = 0x80, /* ignore */
810810
.vec2_size = 1 + sizeof (struct option_vector2) - 2,
811811
.vec2 = {
812-
0, 0, -1, -1, -1, -1, -1, 512, -1, 0, 48
812+
0, 0, -1, -1, -1, -1, -1, 768, -1, 0, 48
813813
},
814814
.vec3_size = 2 - 1,
815815
.vec3 = 0x00e0, /* ask for FP + VMX + DFP but don't halt if unsatisfied */
@@ -846,6 +846,10 @@ grub_claim_heap (void)
846846
{
847847
grub_err_t err;
848848
grub_uint32_t total = HEAP_MAX_SIZE;
849+
#if defined(__powerpc__)
850+
grub_uint32_t ibm_ca_support_reboot = 0;
851+
grub_ssize_t actual;
852+
#endif
849853

850854
err = grub_ieee1275_total_mem (&rmo_top);
851855

@@ -858,11 +862,48 @@ grub_claim_heap (void)
858862
grub_mm_add_region_fn = grub_ieee1275_mm_add_region;
859863

860864
#if defined(__powerpc__)
865+
/* Check if it's a CAS reboot with below property. If so, we will skip CAS call */
866+
if (grub_ieee1275_get_integer_property (grub_ieee1275_chosen,
867+
"ibm,client-architecture-support-reboot",
868+
&ibm_ca_support_reboot,
869+
sizeof (ibm_ca_support_reboot),
870+
&actual) >= 0)
871+
grub_dprintf ("ieee1275", "ibm,client-architecture-support-reboot: %" PRIuGRUB_UINT32_T "\n",
872+
ibm_ca_support_reboot);
873+
861874
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CAN_TRY_CAS_FOR_MORE_MEMORY))
862875
{
863-
/* if we have an error, don't call CAS, just hope for the best */
864-
if (err == GRUB_ERR_NONE && rmo_top < (512 * 1024 * 1024))
865-
grub_ieee1275_ibm_cas ();
876+
/*
877+
* If we have an error, don't call CAS. Just hope for the best.
878+
* Along with the above, if the rmo_top is 512 MB or above. We
879+
* will skip the CAS call. However, if we call CAS, the rmo_top
880+
* will be set to 768 MB via CAS Vector2. But we need to call
881+
* CAS with "rmo_top < 512 MB" to avoid the issue on the older
882+
* Linux kernel, which still uses rmo_top as 512 MB. If we call
883+
* CAS with a condition "rmo_top < 768 MB", it will result in an
884+
* issue due to the IBM CAS reboot feature and we won't be able
885+
* to boot the newer kernel. Whenever a reboot is detected as
886+
* the CAS reboot by GRUB. It will boot the machine with the
887+
* last booted kernel by reading the variable "boot-last-label"
888+
* which has the info related to the last boot and it's specific
889+
* to IBM PowerPC. Due to this, the machine will boot with the
890+
* last booted kernel which has rmo_top as 512 MB. Also, if the
891+
* reboot is detected as a CAS reboot, the GRUB will skip the CAS
892+
* call. As the CAS has already been called earlier, so it is
893+
* not required to call CAS even if the other conditions are met.
894+
* This condition will also prevent a scenario where the machine
895+
* get stuck in the CAS reboot loop while booting. A machine with
896+
* an older kernel, having option_vector2 MIN_RMA as 512 MB in
897+
* Linux prom_init.c and GRUB uses "rmo_top < 768 MB" condition
898+
* for calling CAS. Due to their respective conditions, linux
899+
* CAS and GRUB CAS will keep doing the CAS calls and change
900+
* the MIN_RMA from 768(changed by GRUB) to 512(changed by Linux)
901+
* to 768(changed by GRUB) to 512(changed by Linux) and so on,
902+
* and the machine will stuck in this CAS reboot loop forever.
903+
* IBM PAPR : https://openpower.foundation/specifications/linuxonpower/
904+
*/
905+
if (!ibm_ca_support_reboot && err == GRUB_ERR_NONE && rmo_top < (512 * 1024 * 1024))
906+
grub_ieee1275_ibm_cas ();
866907
}
867908
#endif
868909

0 commit comments

Comments
 (0)