nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone
c6c771
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
c6c771
From: Daniel Axtens <dja@axtens.net>
c6c771
Date: Fri, 8 Apr 2022 12:35:28 +1000
c6c771
Subject: [PATCH] powerpc: do CAS in a more compatible way
c6c771
c6c771
I wrongly assumed that the most compatible way to perform CAS
c6c771
negotiation was to only set the minimum number of vectors required
c6c771
to ask for more memory. It turns out that this messes up booting
c6c771
if the minimum VP capacity would be less than the default 10% in
c6c771
vector 4.
c6c771
c6c771
Linux configures the minimum capacity to be 1%, so copy it for that
c6c771
and for vector 3 which we now need to specify as well.
c6c771
c6c771
Signed-off-by: Daniel Axtens <dja@axtens.net>
c6c771
(cherry picked from commit e6f02ad4e75cd995a8ee2954d28949c415b6cbfe)
c6c771
(cherry picked from commit 9f825ebc319c56ca503741e6dc1a0f27ff36fe2d)
c6c771
---
c6c771
 grub-core/kern/ieee1275/init.c | 54 ++++++++++++++++++++++++------------------
c6c771
 1 file changed, 31 insertions(+), 23 deletions(-)
c6c771
c6c771
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
c6c771
index adf4bd5a88..1414695cc6 100644
c6c771
--- a/grub-core/kern/ieee1275/init.c
c6c771
+++ b/grub-core/kern/ieee1275/init.c
c6c771
@@ -294,33 +294,37 @@ grub_ieee1275_total_mem (grub_uint64_t *total)
c6c771
 
c6c771
 /* Based on linux - arch/powerpc/kernel/prom_init.c */
c6c771
 struct option_vector2 {
c6c771
-	grub_uint8_t byte1;
c6c771
-	grub_uint16_t reserved;
c6c771
-	grub_uint32_t real_base;
c6c771
-	grub_uint32_t real_size;
c6c771
-	grub_uint32_t virt_base;
c6c771
-	grub_uint32_t virt_size;
c6c771
-	grub_uint32_t load_base;
c6c771
-	grub_uint32_t min_rma;
c6c771
-	grub_uint32_t min_load;
c6c771
-	grub_uint8_t min_rma_percent;
c6c771
-	grub_uint8_t max_pft_size;
c6c771
+  grub_uint8_t byte1;
c6c771
+  grub_uint16_t reserved;
c6c771
+  grub_uint32_t real_base;
c6c771
+  grub_uint32_t real_size;
c6c771
+  grub_uint32_t virt_base;
c6c771
+  grub_uint32_t virt_size;
c6c771
+  grub_uint32_t load_base;
c6c771
+  grub_uint32_t min_rma;
c6c771
+  grub_uint32_t min_load;
c6c771
+  grub_uint8_t min_rma_percent;
c6c771
+  grub_uint8_t max_pft_size;
c6c771
 } __attribute__((packed));
c6c771
 
c6c771
 struct pvr_entry {
c6c771
-	  grub_uint32_t mask;
c6c771
-	  grub_uint32_t entry;
c6c771
+  grub_uint32_t mask;
c6c771
+  grub_uint32_t entry;
c6c771
 };
c6c771
 
c6c771
 struct cas_vector {
c6c771
-    struct {
c6c771
-      struct pvr_entry terminal;
c6c771
-    } pvr_list;
c6c771
-    grub_uint8_t num_vecs;
c6c771
-    grub_uint8_t vec1_size;
c6c771
-    grub_uint8_t vec1;
c6c771
-    grub_uint8_t vec2_size;
c6c771
-    struct option_vector2 vec2;
c6c771
+  struct {
c6c771
+    struct pvr_entry terminal;
c6c771
+  } pvr_list;
c6c771
+  grub_uint8_t num_vecs;
c6c771
+  grub_uint8_t vec1_size;
c6c771
+  grub_uint8_t vec1;
c6c771
+  grub_uint8_t vec2_size;
c6c771
+  struct option_vector2 vec2;
c6c771
+  grub_uint8_t vec3_size;
c6c771
+  grub_uint16_t vec3;
c6c771
+  grub_uint8_t vec4_size;
c6c771
+  grub_uint16_t vec4;
c6c771
 } __attribute__((packed));
c6c771
 
c6c771
 /* Call ibm,client-architecture-support to try to get more RMA.
c6c771
@@ -341,13 +345,17 @@ grub_ieee1275_ibm_cas (void)
c6c771
   } args;
c6c771
   struct cas_vector vector = {
c6c771
     .pvr_list = { { 0x00000000, 0xffffffff } }, /* any processor */
c6c771
-    .num_vecs = 2 - 1,
c6c771
+    .num_vecs = 4 - 1,
c6c771
     .vec1_size = 0,
c6c771
     .vec1 = 0x80, /* ignore */
c6c771
     .vec2_size = 1 + sizeof(struct option_vector2) - 2,
c6c771
     .vec2 = {
c6c771
       0, 0, -1, -1, -1, -1, -1, 512, -1, 0, 48
c6c771
     },
c6c771
+    .vec3_size = 2 - 1,
c6c771
+    .vec3 = 0x00e0, // ask for FP + VMX + DFP but don't halt if unsatisfied
c6c771
+    .vec4_size = 2 - 1,
c6c771
+    .vec4 = 0x0001, // set required minimum capacity % to the lowest value
c6c771
   };
c6c771
 
c6c771
   INIT_IEEE1275_COMMON (&args.common, "call-method", 3, 2);
c6c771
@@ -360,7 +368,7 @@ grub_ieee1275_ibm_cas (void)
c6c771
   args.ihandle = root;
c6c771
   args.cas_addr = (grub_ieee1275_cell_t)&vector;
c6c771
 
c6c771
-  grub_printf("Calling ibm,client-architecture-support...");
c6c771
+  grub_printf("Calling ibm,client-architecture-support from grub...");
c6c771
   IEEE1275_CALL_ENTRY_FN (&args);
c6c771
   grub_printf("done\n");
c6c771