From: Wei Chen <Wei.Chen@xxxxxxx>
Arm64 entry code passed the base address of device tree
to _libkvmplat_start. We will check the device tree header
and then save the address for further usage.
Signed-off-by: Wei Chen <Wei.Chen@xxxxxxx>
---
plat/kvm/Config.uk | 1 +
plat/kvm/arm/setup.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/plat/kvm/Config.uk b/plat/kvm/Config.uk
index c07f39b..c792ea1 100644
--- a/plat/kvm/Config.uk
+++ b/plat/kvm/Config.uk
@@ -6,6 +6,7 @@ menuconfig PLAT_KVM
select LIBUKALLOC
select LIBUKTIMECONV
select LIBNOLIBC if !HAVE_LIBC
+ select LIBFDT if ARCH_ARM_64
help
Create a Unikraft image that runs as a KVM guest
diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c
index e2ece8e..19a90ae 100644
--- a/plat/kvm/arm/setup.c
+++ b/plat/kvm/arm/setup.c
@@ -18,9 +18,24 @@
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <libfdt.h>
#include <uk/assert.h>
+void *_libkvmplat_dtb;
+
+static void _init_dtb(void *dtb_pointer)
+{
+ int ret;
+
+ if ((ret = fdt_check_header(dtb_pointer)))
+ UK_CRASH("Invalid DTB: %s\n", fdt_strerror(ret));
+
+ _libkvmplat_dtb = dtb_pointer;
+ uk_printd(DLVL_INFO, "Found device tree on: %p\n", dtb_pointer);
+}
+
void _libkvmplat_start(void *dtb_pointer)
{
+ _init_dtb(dtb_pointer);
uk_printd(DLVL_INFO, "Entering from KVM (arm64)...\n");
}