From fbebc30bf2bd948fb437a99a720471b3bb24efb9 Mon Sep 17 00:00:00 2001 From: Michalis Pappas Date: Tue, 19 Sep 2023 16:50:33 +0200 Subject: [PATCH] plat/kvm: Adapt KVM to the new uk_intctlr API Update KVM setup to use the new uk_intctlr API. Update the config to define HAVE_INTCTLR and enable the default controller driver depending on the VMM and architecture. Notice: Picking individual commits in this PR will break the build. Signed-off-by: Michalis Pappas Reviewed-by: Marco Schlumpp Reviewed-by: Sergiu Moga Approved-by: Razvan Deaconescu GitHub-Closes: #1103 --- plat/kvm/Config.uk | 8 +++++--- plat/kvm/arm/setup.c | 13 ++++++++----- plat/kvm/x86/setup.c | 4 +++- plat/kvm/x86/time.c | 4 ++-- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/plat/kvm/Config.uk b/plat/kvm/Config.uk index e23bd7c6e..c21c9db85 100644 --- a/plat/kvm/Config.uk +++ b/plat/kvm/Config.uk @@ -10,7 +10,9 @@ menuconfig PLAT_KVM select ELF64_TO_32 if ARCH_X86_64 select LIBUKRELOC if OPTIMIZE_PIE select LIBUKOFW if ARCH_ARM_64 - select LIBUKINTCTLR if ARCH_X86_64 + select HAVE_INTCTLR + select HAVE_APIC if ARCH_X86_64 + select LIBUKINTCTLR_XPIC if ARCH_X86_64 imply LIBUKBUS_PLATFORM if ARCH_ARM_64 imply LIBVIRTIO_9P if LIBUK9P imply LIBVIRTIO_NET if LIBUKNETDEV @@ -93,7 +95,7 @@ choice config KVM_VMM_QEMU bool "QEMU" - imply LIBUKINTCTLR_GICV2 + imply LIBUKINTCTLR_GICV2 if ARCH_ARM_64 select HAVE_PCI select HAVE_MMIO @@ -101,7 +103,7 @@ config KVM_VMM_FIRECRACKER bool "Firecracker" select KVM_BOOT_PROTO_LXBOOT select HAVE_MMIO - imply LIBUKINTCTLR_GICV3 + imply LIBUKINTCTLR_GICV3 if ARCH_ARM_64 depends on ARCH_X86_64 || ARCH_ARM_64 endchoice diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c index a0e92e883..e9602baa4 100644 --- a/plat/kvm/arm/setup.c +++ b/plat/kvm/arm/setup.c @@ -200,10 +200,6 @@ void __no_pauth _ukplat_entry(struct ukplat_bootinfo *bi) UK_CRASH("Could not initialize MTE (%d)\n", rc); #endif /* CONFIG_HAVE_MEMTAG */ -#ifdef CONFIG_RTC_PL031 - /* Initialize RTC */ - pl031_init_rtc(fdt); -#endif /* CONFIG_RTC_PL031 */ #if defined(CONFIG_UKPLAT_ACPI) rc = acpi_init(); @@ -212,7 +208,9 @@ void __no_pauth _ukplat_entry(struct ukplat_bootinfo *bi) #endif /* CONFIG_UKPLAT_ACPI */ /* Initialize interrupt controller */ - intctrl_init(); + rc = uk_intctlr_probe(); + if (unlikely(rc)) + UK_CRASH("Could not initialize the IRQ controller: %d\n", rc); /* Initialize logical boot CPU */ rc = lcpu_init(lcpu_get_bsp()); @@ -231,6 +229,11 @@ void __no_pauth _ukplat_entry(struct ukplat_bootinfo *bi) if (unlikely(rc < 0)) UK_CRASH("Failed to get PSCI method: %d.\n", rc); +#if CONFIG_RTC_PL031 + /* Initialize RTC */ + pl031_init_rtc(fdt); +#endif /* CONFIG_RTC_PL031 */ + /* * Switch away from the bootstrap stack as early as possible. */ diff --git a/plat/kvm/x86/setup.c b/plat/kvm/x86/setup.c index 7da9481c1..e6b8ec72e 100644 --- a/plat/kvm/x86/setup.c +++ b/plat/kvm/x86/setup.c @@ -86,7 +86,9 @@ void _ukplat_entry(struct lcpu *lcpu, struct ukplat_bootinfo *bi) UK_CRASH("Bootstrap processor init failed: %d\n", rc); /* Initialize IRQ controller */ - intctrl_init(); + rc = uk_intctlr_probe(); + if (unlikely(rc)) + UK_CRASH("Interrupt controller init failed: %d\n", rc); /* Initialize command line */ rc = cmdline_init(bi); diff --git a/plat/kvm/x86/time.c b/plat/kvm/x86/time.c index aa3866dae..b5b113c50 100644 --- a/plat/kvm/x86/time.c +++ b/plat/kvm/x86/time.c @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include @@ -71,7 +71,7 @@ void ukplat_time_init(void) { int rc; - rc = ukplat_irq_register(0, timer_handler, NULL); + rc = uk_intctlr_irq_register(0, timer_handler, NULL); if (rc < 0) UK_CRASH("Failed to register timer interrupt handler\n"); -- 2.39.5