From 8bf8814ab1aba0243127bcada19414dddbfe9e51 Mon Sep 17 00:00:00 2001 From: Bibo Mao Date: Fri, 6 Jun 2025 14:30:21 +0800 Subject: hw/intc/loongarch_extioi: Add kernel irqchip realize function Function kvm_extioi_realize() is added if kvm_irqchip_in_kernel is set. It is to create and initialize ExtIOI device in kernel mode. Reviewed-by: Song Gao Signed-off-by: Bibo Mao Message-ID: <20250606063033.2557365-2-maobibo@loongson.cn> Signed-off-by: Song Gao --- include/hw/intc/loongarch_extioi.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/hw') diff --git a/include/hw/intc/loongarch_extioi.h b/include/hw/intc/loongarch_extioi.h index 4a6ae90..69565e1 100644 --- a/include/hw/intc/loongarch_extioi.h +++ b/include/hw/intc/loongarch_extioi.h @@ -15,6 +15,7 @@ OBJECT_DECLARE_TYPE(LoongArchExtIOIState, LoongArchExtIOIClass, LOONGARCH_EXTIOI struct LoongArchExtIOIState { LoongArchExtIOICommonState parent_obj; + int dev_fd; }; struct LoongArchExtIOIClass { @@ -25,4 +26,6 @@ struct LoongArchExtIOIClass { ResettablePhases parent_phases; }; +void kvm_extioi_realize(DeviceState *dev, Error **errp); + #endif /* LOONGARCH_EXTIOI_H */ -- cgit v1.1 From 228c5413fb50ab43644689f4959c3ef1ef7571ea Mon Sep 17 00:00:00 2001 From: Bibo Mao Date: Fri, 6 Jun 2025 14:30:22 +0800 Subject: hw/intc/loongarch_extioi: Add kernel irqchip save and restore function Add save and store funtction if kvm_irqchip_in_kernel() return true, it is to get and set ExtIOI irqchip state from KVM kernel. Reviewed-by: Song Gao Signed-off-by: Bibo Mao Message-ID: <20250606063033.2557365-3-maobibo@loongson.cn> Signed-off-by: Song Gao --- include/hw/intc/loongarch_extioi.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/hw') diff --git a/include/hw/intc/loongarch_extioi.h b/include/hw/intc/loongarch_extioi.h index 69565e1..9be1d73 100644 --- a/include/hw/intc/loongarch_extioi.h +++ b/include/hw/intc/loongarch_extioi.h @@ -27,5 +27,7 @@ struct LoongArchExtIOIClass { }; void kvm_extioi_realize(DeviceState *dev, Error **errp); +int kvm_extioi_get(void *opaque); +int kvm_extioi_put(void *opaque, int version_id); #endif /* LOONGARCH_EXTIOI_H */ -- cgit v1.1 From 412f655566bfadfe85d6f52a7e4420b418f261c3 Mon Sep 17 00:00:00 2001 From: Bibo Mao Date: Fri, 6 Jun 2025 14:30:23 +0800 Subject: hw/intc/loongarch_ipi: Add kernel irqchip realize function Function kvm_ipi_realize() is added if kvm_irqchip_in_kernel() return true. It is to create and initialize IPI device in kernel mode. Reviewed-by: Song Gao Signed-off-by: Bibo Mao Message-ID: <20250606063033.2557365-4-maobibo@loongson.cn> Signed-off-by: Song Gao --- include/hw/intc/loongarch_ipi.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/hw') diff --git a/include/hw/intc/loongarch_ipi.h b/include/hw/intc/loongarch_ipi.h index a7c6bf8..608cd09 100644 --- a/include/hw/intc/loongarch_ipi.h +++ b/include/hw/intc/loongarch_ipi.h @@ -16,6 +16,7 @@ OBJECT_DECLARE_TYPE(LoongarchIPIState, LoongarchIPIClass, LOONGARCH_IPI) struct LoongarchIPIState { LoongsonIPICommonState parent_obj; + int dev_fd; }; struct LoongarchIPIClass { @@ -24,4 +25,6 @@ struct LoongarchIPIClass { ResettablePhases parent_phases; }; +void kvm_ipi_realize(DeviceState *dev, Error **errp); + #endif -- cgit v1.1 From 14be318c952ce2c29f2a69204a23c0008f779a3f Mon Sep 17 00:00:00 2001 From: Bibo Mao Date: Fri, 6 Jun 2025 14:30:24 +0800 Subject: hw/intc/loongson_ipi: Add load and save interface with ipi_common class Add pre_save and post_load interfaces with ipi_common class, here only framework ipi_common adds these interfaces. The defailed implementation is LoongArchIPI child device in later. Reviewed-by: Song Gao Signed-off-by: Bibo Mao Message-ID: <20250606063033.2557365-5-maobibo@loongson.cn> Signed-off-by: Song Gao --- include/hw/intc/loongson_ipi_common.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/hw') diff --git a/include/hw/intc/loongson_ipi_common.h b/include/hw/intc/loongson_ipi_common.h index b587f9c..e58ce2a 100644 --- a/include/hw/intc/loongson_ipi_common.h +++ b/include/hw/intc/loongson_ipi_common.h @@ -48,6 +48,8 @@ struct LoongsonIPICommonClass { AddressSpace *(*get_iocsr_as)(CPUState *cpu); int (*cpu_by_arch_id)(LoongsonIPICommonState *lics, int64_t id, int *index, CPUState **pcs); + int (*pre_save)(void *opaque); + int (*post_load)(void *opaque, int version_id); }; MemTxResult loongson_ipi_core_readl(void *opaque, hwaddr addr, uint64_t *data, -- cgit v1.1 From f936caa315750406f50feb1ac9c93770b47ebe96 Mon Sep 17 00:00:00 2001 From: Bibo Mao Date: Fri, 6 Jun 2025 14:30:25 +0800 Subject: hw/intc/loongarch_ipi: Add kernel irqchip save and restore function Add save and store funtction if kvm_irqchip_in_kernel() return true, it is to get and set IPI irqchip state from KVM kernel. Reviewed-by: Song Gao Signed-off-by: Bibo Mao Message-ID: <20250606063033.2557365-6-maobibo@loongson.cn> Signed-off-by: Song Gao --- include/hw/intc/loongarch_ipi.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/hw') diff --git a/include/hw/intc/loongarch_ipi.h b/include/hw/intc/loongarch_ipi.h index 608cd09..5175a6b 100644 --- a/include/hw/intc/loongarch_ipi.h +++ b/include/hw/intc/loongarch_ipi.h @@ -26,5 +26,7 @@ struct LoongarchIPIClass { }; void kvm_ipi_realize(DeviceState *dev, Error **errp); +int kvm_ipi_get(void *opaque); +int kvm_ipi_put(void *opaque, int version_id); #endif -- cgit v1.1 From b758e28974614a15e70fbc983e28fe77852564ee Mon Sep 17 00:00:00 2001 From: Bibo Mao Date: Fri, 6 Jun 2025 14:30:27 +0800 Subject: hw/intc/loongarch_pch: Add kernel irqchip realize function Function kvm_pic_realize() is added if kvm_irqchip_in_kernel() return true. It is to notify KVM kernel to create and initialize PCH PCI device in kernel mode. Reviewed-by: Song Gao Signed-off-by: Bibo Mao Message-ID: <20250606063033.2557365-8-maobibo@loongson.cn> Signed-off-by: Song Gao --- include/hw/intc/loongarch_pch_pic.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/hw') diff --git a/include/hw/intc/loongarch_pch_pic.h b/include/hw/intc/loongarch_pch_pic.h index 839a59a..4b52f11 100644 --- a/include/hw/intc/loongarch_pch_pic.h +++ b/include/hw/intc/loongarch_pch_pic.h @@ -16,6 +16,7 @@ OBJECT_DECLARE_TYPE(LoongarchPICState, LoongarchPICClass, LOONGARCH_PIC) struct LoongarchPICState { LoongArchPICCommonState parent_obj; + int dev_fd; }; struct LoongarchPICClass { @@ -25,4 +26,6 @@ struct LoongarchPICClass { ResettablePhases parent_phases; }; +void kvm_pic_realize(DeviceState *dev, Error **errp); + #endif /* HW_LOONGARCH_PCH_PIC_H */ -- cgit v1.1 From 11a04c9f40ac479f68139f6801da314591e67ae1 Mon Sep 17 00:00:00 2001 From: Bibo Mao Date: Fri, 6 Jun 2025 14:30:28 +0800 Subject: hw/intc/loongarch_pch: Add kernel irqchip save and restore function Add save and store funtction if kvm_irqchip_in_kernel() return true, it is to get and set PCH PCI irqchip state from KVM kernel. Reviewed-by: Song Gao Signed-off-by: Bibo Mao Message-ID: <20250606063033.2557365-9-maobibo@loongson.cn> Signed-off-by: Song Gao --- include/hw/intc/loongarch_pch_pic.h | 2 ++ include/hw/intc/loongarch_pic_common.h | 1 + 2 files changed, 3 insertions(+) (limited to 'include/hw') diff --git a/include/hw/intc/loongarch_pch_pic.h b/include/hw/intc/loongarch_pch_pic.h index 4b52f11..a46b6f8 100644 --- a/include/hw/intc/loongarch_pch_pic.h +++ b/include/hw/intc/loongarch_pch_pic.h @@ -27,5 +27,7 @@ struct LoongarchPICClass { }; void kvm_pic_realize(DeviceState *dev, Error **errp); +int kvm_pic_get(void *opaque); +int kvm_pic_put(void *opaque, int version_id); #endif /* HW_LOONGARCH_PCH_PIC_H */ diff --git a/include/hw/intc/loongarch_pic_common.h b/include/hw/intc/loongarch_pic_common.h index 9349a05..f774c97 100644 --- a/include/hw/intc/loongarch_pic_common.h +++ b/include/hw/intc/loongarch_pic_common.h @@ -23,6 +23,7 @@ #define PCH_PIC_ROUTE_ENTRY_END 0x13f #define PCH_PIC_HTMSI_VEC 0x200 #define PCH_PIC_HTMSI_VEC_END 0x23f +#define PCH_PIC_INT_REQUEST 0x380 #define PCH_PIC_INT_STATUS 0x3a0 #define PCH_PIC_INT_POL 0x3e0 -- cgit v1.1