]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/common: Implement method to dynamically assign `SIPI Vector`
authorSergiu Moga <sergiu.moga@protonmail.com>
Mon, 15 May 2023 05:32:57 +0000 (08:32 +0300)
committerUnikraft <monkey@unikraft.io>
Fri, 11 Aug 2023 10:18:45 +0000 (10:18 +0000)
Add an inline function that simply allocates a reserved memory region
meant for the `SIPI Vector`. If this function fails we wouldn"t have
been able to do this properly with the old way anyway (hardcoded
`SIPI Vector` at `0x8000`).

This should only be called after the memory region list has been
fully built and coalesced.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #848

plat/common/include/uk/plat/common/memory.h

index 08ad19d3af992696484b50705860a205f149e21a..121f88ae11456c3621c5579fbd46f6010f31cd87 100644 (file)
@@ -36,6 +36,7 @@
 #include <uk/config.h>
 #include <uk/assert.h>
 #include <uk/essentials.h>
+#include <uk/arch/paging.h>
 #include <uk/arch/types.h>
 #include <uk/plat/memory.h>
 
@@ -136,6 +137,36 @@ ukplat_memregion_list_insert_legacy_hi_mem(struct ukplat_memregion_list *list)
 
        return ukplat_memregion_list_insert(list, &mrd);
 }
+
+#if defined(CONFIG_HAVE_SMP)
+extern void *x86_start16_begin[];
+extern void *x86_start16_end[];
+extern __uptr x86_start16_addr; /* target address */
+
+static inline int
+ukplat_memregion_alloc_sipi_vect(void)
+{
+       __sz len;
+
+       len = (__sz)((__uptr)x86_start16_end - (__uptr)x86_start16_begin);
+       len = PAGE_ALIGN_UP(len);
+       x86_start16_addr = (__uptr)ukplat_memregion_alloc(len,
+                                                         UKPLAT_MEMRT_RESERVED,
+                                                         UKPLAT_MEMRF_READ  |
+                                                         UKPLAT_MEMRF_WRITE |
+                                                         UKPLAT_MEMRF_MAP);
+       if (unlikely(!x86_start16_addr || x86_start16_addr >= X86_HI_MEM_START))
+               return -ENOMEM;
+
+       return 0;
+}
+#else
+static inline int
+ukplat_memregion_alloc_sipi_vect(void)
+{
+       return 0;
+}
+#endif
 #endif
 
 /**