From 379f2cf1f7265c830cc60ed2e5a624877fa610cf Mon Sep 17 00:00:00 2001 From: Chris Guikema Date: Wed, 26 Oct 2022 21:20:21 -0400 Subject: [PATCH] vm_arm: use gic path to find phandle This commit defines the gic path for each platform, which is used to parse the device tree to find the gic phandle, instead of relying on the user to provide the correct value. Signed-off-by: Chris Guikema --- .../VM_Arm/plat_include/exynos5410/plat/vmlinux.h | 2 +- .../VM_Arm/plat_include/exynos5422/plat/vmlinux.h | 2 +- .../VM_Arm/plat_include/odroidc2/plat/vmlinux.h | 2 +- .../VM_Arm/plat_include/qemu-arm-virt/plat/vmlinux.h | 2 +- components/VM_Arm/plat_include/tk1/plat/vmlinux.h | 2 +- components/VM_Arm/plat_include/tx1/plat/vmlinux.h | 2 +- components/VM_Arm/plat_include/tx2/plat/vmlinux.h | 2 +- components/VM_Arm/src/main.c | 12 +++++++++++- 8 files changed, 18 insertions(+), 8 deletions(-) diff --git a/components/VM_Arm/plat_include/exynos5410/plat/vmlinux.h b/components/VM_Arm/plat_include/exynos5410/plat/vmlinux.h index f724eaaa..3d97146a 100644 --- a/components/VM_Arm/plat_include/exynos5410/plat/vmlinux.h +++ b/components/VM_Arm/plat_include/exynos5410/plat/vmlinux.h @@ -10,7 +10,7 @@ #define VUSB_NINDEX 5 #define VUSB_NBADGE 0x123 #define IRQ_SPI_OFFSET 32 -#define GIC_IRQ_PHANDLE 0x1 +#define GIC_NODE_PATH "/soc/interrupt-controller@10481000" #define LINUX_RAM_BASE 0x40000000 #define LINUX_RAM_PADDR_BASE LINUX_RAM_BASE diff --git a/components/VM_Arm/plat_include/exynos5422/plat/vmlinux.h b/components/VM_Arm/plat_include/exynos5422/plat/vmlinux.h index 71f1ccae..c221b49d 100644 --- a/components/VM_Arm/plat_include/exynos5422/plat/vmlinux.h +++ b/components/VM_Arm/plat_include/exynos5422/plat/vmlinux.h @@ -14,7 +14,7 @@ #define INITRD_ADDR (DTB_ADDR - INITRD_MAX_SIZE) //0x4D700000 #define IRQ_SPI_OFFSET 32 -#define GIC_IRQ_PHANDLE 0x1 +#define GIC_NODE_PATH "/soc/interrupt-controller@10481000" static const int linux_pt_irqs[] = { }; diff --git a/components/VM_Arm/plat_include/odroidc2/plat/vmlinux.h b/components/VM_Arm/plat_include/odroidc2/plat/vmlinux.h index ca6701db..bc0148f7 100644 --- a/components/VM_Arm/plat_include/odroidc2/plat/vmlinux.h +++ b/components/VM_Arm/plat_include/odroidc2/plat/vmlinux.h @@ -6,7 +6,7 @@ #pragma once #define IRQ_SPI_OFFSET 32 -#define GIC_IRQ_PHANDLE 0x01 +#define GIC_NODE_PATH "/interrupt-controller@c4301000" static const int linux_pt_irqs[] = {}; diff --git a/components/VM_Arm/plat_include/qemu-arm-virt/plat/vmlinux.h b/components/VM_Arm/plat_include/qemu-arm-virt/plat/vmlinux.h index e8ec49e1..9527975c 100644 --- a/components/VM_Arm/plat_include/qemu-arm-virt/plat/vmlinux.h +++ b/components/VM_Arm/plat_include/qemu-arm-virt/plat/vmlinux.h @@ -15,7 +15,7 @@ #define INITRD_ADDR (DTB_ADDR - INITRD_MAX_SIZE) //0x4D700000 #define IRQ_SPI_OFFSET 32 -#define GIC_IRQ_PHANDLE 0x8001 +#define GIC_NODE_PATH "/intc@8000000" static const int linux_pt_irqs[] = {}; diff --git a/components/VM_Arm/plat_include/tk1/plat/vmlinux.h b/components/VM_Arm/plat_include/tk1/plat/vmlinux.h index a4b50da5..f9523d72 100644 --- a/components/VM_Arm/plat_include/tk1/plat/vmlinux.h +++ b/components/VM_Arm/plat_include/tk1/plat/vmlinux.h @@ -173,7 +173,7 @@ static const int free_plat_interrupts[] = { -1 }; #define DTB_ADDR (LINUX_RAM_BASE + 0x02000000) #define INITRD_MAX_SIZE 0x1900000 //25 MB #define INITRD_ADDR (DTB_ADDR - INITRD_MAX_SIZE) //0x80700000 -#define GIC_IRQ_PHANDLE 0x1 +#define GIC_NODE_PATH "/interrupt-controller@50041000" static const char *plat_keep_device_and_disable[] = { "/gpu@0,57000000", diff --git a/components/VM_Arm/plat_include/tx1/plat/vmlinux.h b/components/VM_Arm/plat_include/tx1/plat/vmlinux.h index fe0b11af..52b36170 100644 --- a/components/VM_Arm/plat_include/tx1/plat/vmlinux.h +++ b/components/VM_Arm/plat_include/tx1/plat/vmlinux.h @@ -222,7 +222,7 @@ static const int free_plat_interrupts[] = { -1 }; #define DTB_ADDR (LINUX_RAM_BASE + 0x02000000) #define INITRD_MAX_SIZE 0x1900000 //25 MB #define INITRD_ADDR (DTB_ADDR - INITRD_MAX_SIZE) //0x80700000 -#define GIC_IRQ_PHANDLE 0x1 +#define GIC_NODE_PATH "/interrupt-controller@50041000" static const char *plat_keep_devices[] = { "/interrupt-controller@50041000", diff --git a/components/VM_Arm/plat_include/tx2/plat/vmlinux.h b/components/VM_Arm/plat_include/tx2/plat/vmlinux.h index 4964043f..ae4b9124 100644 --- a/components/VM_Arm/plat_include/tx2/plat/vmlinux.h +++ b/components/VM_Arm/plat_include/tx2/plat/vmlinux.h @@ -164,7 +164,7 @@ static const int free_plat_interrupts[] = { 220 + GIC_LIC_INTID_BASE }; #define DTB_ADDR (LINUX_RAM_BASE + 0x01000000) #define INITRD_MAX_SIZE 0x1900000 //25 MB #define INITRD_ADDR (DTB_ADDR - INITRD_MAX_SIZE) //0x80700000 -#define GIC_IRQ_PHANDLE 0x1 +#define GIC_NODE_PATH "/interrupt-controller@3881000" static const char *plat_keep_devices[] = { "/arm-pmu", diff --git a/components/VM_Arm/src/main.c b/components/VM_Arm/src/main.c index 5b09f82c..e577d0bd 100644 --- a/components/VM_Arm/src/main.c +++ b/components/VM_Arm/src/main.c @@ -802,7 +802,17 @@ static int generate_fdt(vm_t *vm, void *fdt_ori, void *gen_fdt, int buf_size, si } if (config_set(CONFIG_VM_PCI_SUPPORT)) { - err = fdt_generate_vpci_node(vm, pci, gen_fdt, GIC_IRQ_PHANDLE); + int gic_offset = fdt_path_offset(fdt_ori, GIC_NODE_PATH); + if (gic_offset < 0) { + ZF_LOGE("Failed to find gic node from path: %s", GIC_NODE_PATH); + return -1; + } + int gic_phandle = fdt_get_phandle(fdt_ori, gic_offset); + if (0 == gic_phandle) { + ZF_LOGE("Failed to find phandle in gic node"); + return -1; + } + err = fdt_generate_vpci_node(vm, pci, gen_fdt, gic_phandle); if (err) { ZF_LOGE("Couldn't generate vpci_node (%d)\n", err); return -1;