[MINI-OS PATCH 03/19] mini-os: grants: support populated grant table at boot

Juergen Gross posted 19 patches 4 months ago
There is a newer version of this series
[MINI-OS PATCH 03/19] mini-os: grants: support populated grant table at boot
Posted by Juergen Gross 4 months ago
When kexec-ing into a new kernel, the grant table might still have
active grants. Support that by not adding populated grant entries to
the list of free grant entries.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 gnttab.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gnttab.c b/gnttab.c
index 8168ed5d..5b04ab01 100644
--- a/gnttab.c
+++ b/gnttab.c
@@ -183,11 +183,13 @@ init_gnttab(void)
 #ifdef GNT_DEBUG
     memset(inuse, 1, sizeof(inuse));
 #endif
-    for (i = NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++)
-        put_free_entry(i);
 
     gnttab_table = arch_init_gnttab(NR_GRANT_FRAMES);
     printk("gnttab_table mapped at %p.\n", gnttab_table);
+
+    for (i = NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++)
+        if (gnttab_table[i].flags == 0)
+            put_free_entry(i);
 }
 
 void
-- 
2.43.0
Re: [MINI-OS PATCH 03/19] mini-os: grants: support populated grant table at boot
Posted by Jason Andryuk 3 months, 3 weeks ago
On 2025-07-02 04:12, Juergen Gross wrote:
> When kexec-ing into a new kernel, the grant table might still have
> active grants. Support that by not adding populated grant entries to
> the list of free grant entries.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>