From: Xiang Chen chenxiang66@hisilicon.com
Patch#1 fix one soc bug with vPE schedule for gicv4.0 Patch#2 fix another soc bug with inaccurate pending status for gicv4.1
Kunkun Jiang (1): irqchip: gicv3: Add workaround for hip09 erratum 162200806
Xiang Chen (1): irqchip: gicv3: Add workaround for hip09 erratum 162200803
Documentation/arch/arm64/silicon-errata.rst | 4 +++ arch/arm64/Kconfig | 21 +++++++++++ arch/arm64/configs/openeuler_defconfig | 2 ++ arch/arm64/kvm/vgic/vgic-init.c | 1 + arch/arm64/kvm/vgic/vgic-mmio-v3.c | 4 +++ arch/arm64/kvm/vgic/vgic-mmio.c | 17 +++++++++ arch/arm64/kvm/vgic/vgic-mmio.h | 3 ++ drivers/irqchip/irq-gic-v3.c | 40 +++++++++++++++++++++ include/kvm/arm_vgic.h | 1 + include/linux/irqchip/arm-gic-v3.h | 2 ++ include/linux/irqchip/arm-vgic-info.h | 1 + 11 files changed, 96 insertions(+)
From: Xiang Chen chenxiang66@hisilicon.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9KBKD
------------------------------------------------------------------
For gicv4.0 of hip09, it has a soc bug with vPE schedule: when multiple vPEs are sending vpe schedule/deschedule commands concurrently and repeatly, some vPE schedule command may not be scheduled, and it will cause the command timeout. To avoid the issue, limit the number of vLPI to 4096 for virtual machine.
Signed-off-by: Xiang Chen chenxiang66@hisilicon.com --- Documentation/arch/arm64/silicon-errata.rst | 2 ++ arch/arm64/Kconfig | 11 +++++++++++ arch/arm64/configs/openeuler_defconfig | 1 + arch/arm64/kvm/vgic/vgic-init.c | 1 + arch/arm64/kvm/vgic/vgic-mmio-v3.c | 4 ++++ arch/arm64/kvm/vgic/vgic-mmio.h | 2 ++ drivers/irqchip/irq-gic-v3.c | 22 +++++++++++++++++++++ include/kvm/arm_vgic.h | 1 + include/linux/irqchip/arm-gic-v3.h | 2 ++ include/linux/irqchip/arm-vgic-info.h | 1 + 10 files changed, 47 insertions(+)
diff --git a/Documentation/arch/arm64/silicon-errata.rst b/Documentation/arch/arm64/silicon-errata.rst index 11645181d7f2..1b1c5b8d90a9 100644 --- a/Documentation/arch/arm64/silicon-errata.rst +++ b/Documentation/arch/arm64/silicon-errata.rst @@ -213,6 +213,8 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | Hisilicon | SMMUv3 | #162100602 | HISILICON_ERRATUM_162100602 | +----------------+-----------------+-----------------+-----------------------------+ +| Hisilicon | Hip09 | #162200803 | HISILICON_ERRATUM_162200803 | ++----------------+-----------------+-----------------+-----------------------------+ | Qualcomm Tech. | Kryo/Falkor v1 | E1003 | QCOM_FALKOR_ERRATUM_1003 | +----------------+-----------------+-----------------+-----------------------------+ | Qualcomm Tech. | Kryo/Falkor v1 | E1009 | QCOM_FALKOR_ERRATUM_1009 | diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 890461d3f5e5..3bfee070e863 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1236,6 +1236,17 @@ config HISILICON_ERRATUM_162102203
If unsure, say N.
+config HISILICON_ERRATUM_162200803 + bool "Hisilicon erratum 162200803" + default y + help + When multiple vPEs are sending vPE schedule/de-schedule commands + concurrently and repeatedly, some vPE schedule command may be not + scheduled, which causes the command timeout. + Limit the number of vLPI to 4096 for virtual machine. + + If unsure, say Y. + config QCOM_FALKOR_ERRATUM_1003 bool "Falkor E1003: Incorrect translation due to ASID change" default y diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index e0ffdeb0481b..b38681daeabc 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -434,6 +434,7 @@ CONFIG_HISILICON_ERRATUM_162102203=y # CONFIG_HISILICON_ERRATUM_1980005 is not set CONFIG_HISILICON_ERRATUM_162100801=y CONFIG_HISILICON_ERRATUM_162100602=y +CONFIG_HISILICON_ERRATUM_162200803=y CONFIG_QCOM_FALKOR_ERRATUM_1003=y CONFIG_QCOM_FALKOR_ERRATUM_1009=y CONFIG_QCOM_QDF2400_ERRATUM_0065=y diff --git a/arch/arm64/kvm/vgic/vgic-init.c b/arch/arm64/kvm/vgic/vgic-init.c index 0d9d71dc338e..a8590ca54ad2 100644 --- a/arch/arm64/kvm/vgic/vgic-init.c +++ b/arch/arm64/kvm/vgic/vgic-init.c @@ -615,6 +615,7 @@ int kvm_vgic_hyp_init(void) kvm_vgic_global_state.no_hw_deactivation = true; }
+ kvm_vgic_global_state.flags = gic_kvm_info->flags; switch (gic_kvm_info->type) { case GIC_V2: ret = vgic_v2_probe(gic_kvm_info); diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v3.c b/arch/arm64/kvm/vgic/vgic-mmio-v3.c index 3dd779cae09f..09db8c8f8d44 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c @@ -83,6 +83,10 @@ static unsigned long vgic_mmio_read_v3_misc(struct kvm_vcpu *vcpu, if (vgic_has_its(vcpu->kvm)) { value |= (INTERRUPT_ID_BITS_ITS - 1) << 19; value |= GICD_TYPER_LPIS; + /* Limit the number of vlpis to 4096 */ + if (kvm_vgic_global_state.flags & FLAGS_WORKAROUND_HIP09_ERRATUM_162200803) + value |= 11 << GICD_TYPER_NUM_LPIS_SHIFT; + } else { value |= (INTERRUPT_ID_BITS_SPIS - 1) << 19; } diff --git a/arch/arm64/kvm/vgic/vgic-mmio.h b/arch/arm64/kvm/vgic/vgic-mmio.h index 5b490a4dfa5e..55f49933e304 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio.h +++ b/arch/arm64/kvm/vgic/vgic-mmio.h @@ -5,6 +5,8 @@ #ifndef __KVM_ARM_VGIC_MMIO_H__ #define __KVM_ARM_VGIC_MMIO_H__
+#define FLAGS_WORKAROUND_HIP09_ERRATUM_162200803 (1ULL << 4) + struct vgic_register_region { unsigned int reg_offset; unsigned int len; diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 8bb42ac8fb2a..2ef910e14ac0 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -41,6 +41,7 @@ #define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1) #define FLAGS_WORKAROUND_MTK_GICR_SAVE (1ULL << 2) #define FLAGS_WORKAROUND_ASR_ERRATUM_8601001 (1ULL << 3) +#define FLAGS_WORKAROUND_HIP09_ERRATUM_162200803 (1ULL << 4)
#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1)
@@ -1962,6 +1963,15 @@ static bool rd_set_non_coherent(void *data) return true; }
+static bool gic_enable_quirk_hip09_162200803(void *data) +{ + struct gic_chip_data *d = data; + + d->flags |= FLAGS_WORKAROUND_HIP09_ERRATUM_162200803; + + return true; +} + static const struct gic_quirk gic_quirks[] = { { .desc = "GICv3: Qualcomm MSM8996 broken firmware", @@ -2033,6 +2043,14 @@ static const struct gic_quirk gic_quirks[] = { .property = "dma-noncoherent", .init = rd_set_non_coherent, }, +#ifdef CONFIG_HISILICON_ERRATUM_162200803 + { + .desc = "GICv3: HIP09 erratum 162200803", + .iidr = 0x01050736, + .mask = 0xffffffff, + .init = gic_enable_quirk_hip09_162200803, + }, +#endif { } }; @@ -2344,6 +2362,8 @@ static void __init gic_of_setup_kvm_info(struct device_node *node) #ifdef CONFIG_VIRT_VTIMER_IRQ_BYPASS gic_v3_kvm_info.has_vtimer = gic_data.rdists.has_vtimer; #endif + if (gic_v3_kvm_info.has_v4) + gic_v3_kvm_info.flags = gic_data.flags; vgic_set_kvm_info(&gic_v3_kvm_info); }
@@ -2696,6 +2716,8 @@ static void __init gic_acpi_setup_kvm_info(void) #ifdef CONFIG_VIRT_VTIMER_IRQ_BYPASS gic_v3_kvm_info.has_vtimer = gic_data.rdists.has_vtimer; #endif + if (gic_v3_kvm_info.has_v4) + gic_v3_kvm_info.flags = gic_data.flags; vgic_set_kvm_info(&gic_v3_kvm_info); }
diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index 0cbcf4e06761..0b734d6f3d21 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -126,6 +126,7 @@ struct vgic_global { struct static_key_false gicv3_cpuif;
u32 ich_vtr_el2; + u64 flags; };
extern struct vgic_global kvm_vgic_global_state; diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index 7a91ec9e2afd..ccf464326be7 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -81,6 +81,8 @@ #define GICD_CTLR_ENABLE_SS_G1 (1U << 1) #define GICD_CTLR_ENABLE_SS_G0 (1U << 0)
+#define GICD_TYPER_NUM_LPIS_SHIFT 11 + #define GICD_TYPER_RSS (1U << 26) #define GICD_TYPER_LPIS (1U << 17) #define GICD_TYPER_MBIS (1U << 16) diff --git a/include/linux/irqchip/arm-vgic-info.h b/include/linux/irqchip/arm-vgic-info.h index aa2e9eaa9ad9..eb358cea426d 100644 --- a/include/linux/irqchip/arm-vgic-info.h +++ b/include/linux/irqchip/arm-vgic-info.h @@ -38,6 +38,7 @@ struct gic_kvm_info { /* vtimer irqbypass support */ bool has_vtimer; #endif + u64 flags; /* Deactivation impared, subpar stuff */ bool no_hw_deactivation; };
From: Kunkun Jiang jiangkunkun@huawei.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9KBKD
-------------------------------------------------------------
For gicv4.1 of hip09, it has a soc bug with the status of vpe pending is inaccurate, so read the pending status from memory to fix the issue.
Signed-off-by: Kunkun Jiang jiangkunkun@huawei.com Signed-off-by: Xiang Chen chenxiang66@hisilicon.com --- Documentation/arch/arm64/silicon-errata.rst | 2 ++ arch/arm64/Kconfig | 10 ++++++++++ arch/arm64/configs/openeuler_defconfig | 1 + arch/arm64/kvm/vgic/vgic-mmio.c | 17 +++++++++++++++++ arch/arm64/kvm/vgic/vgic-mmio.h | 1 + drivers/irqchip/irq-gic-v3.c | 18 ++++++++++++++++++ 6 files changed, 49 insertions(+)
diff --git a/Documentation/arch/arm64/silicon-errata.rst b/Documentation/arch/arm64/silicon-errata.rst index 1b1c5b8d90a9..17c636068603 100644 --- a/Documentation/arch/arm64/silicon-errata.rst +++ b/Documentation/arch/arm64/silicon-errata.rst @@ -215,6 +215,8 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | Hisilicon | Hip09 | #162200803 | HISILICON_ERRATUM_162200803 | +----------------+-----------------+-----------------+-----------------------------+ +| Hisilicon | Hip09 | #162200806 | HISILICON_ERRATUM_162200806 | ++----------------+-----------------+-----------------+-----------------------------+ | Qualcomm Tech. | Kryo/Falkor v1 | E1003 | QCOM_FALKOR_ERRATUM_1003 | +----------------+-----------------+-----------------+-----------------------------+ | Qualcomm Tech. | Kryo/Falkor v1 | E1009 | QCOM_FALKOR_ERRATUM_1009 | diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 3bfee070e863..d09dc7a9818f 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1247,6 +1247,16 @@ config HISILICON_ERRATUM_162200803
If unsure, say Y.
+config HISILICON_ERRATUM_162200806 + bool "Hisilicon erratum 162200806" + default y + help + For gicv4.1 of hip09, it has a soc bug with the status of + vpe pending is inaccurate, so read the pending status from + memory to fix the issue. + + If unsure, say Y. + config QCOM_FALKOR_ERRATUM_1003 bool "Falkor E1003: Incorrect translation due to ASID change" default y diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index b38681daeabc..8a78dda28ce8 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -435,6 +435,7 @@ CONFIG_HISILICON_ERRATUM_162102203=y CONFIG_HISILICON_ERRATUM_162100801=y CONFIG_HISILICON_ERRATUM_162100602=y CONFIG_HISILICON_ERRATUM_162200803=y +CONFIG_HISILICON_ERRATUM_162200806=y CONFIG_QCOM_FALKOR_ERRATUM_1003=y CONFIG_QCOM_FALKOR_ERRATUM_1009=y CONFIG_QCOM_QDF2400_ERRATUM_0065=y diff --git a/arch/arm64/kvm/vgic/vgic-mmio.c b/arch/arm64/kvm/vgic/vgic-mmio.c index 59b81e5ce1d8..56549ee4313c 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio.c +++ b/arch/arm64/kvm/vgic/vgic-mmio.c @@ -228,6 +228,7 @@ int vgic_uaccess_write_cenable(struct kvm_vcpu *vcpu, return 0; }
+#define VIRTUAL_SGI_PENDING_OFFSET 0x3F0 static unsigned long __read_pending(struct kvm_vcpu *vcpu, gpa_t addr, unsigned int len, bool is_user) @@ -235,6 +236,7 @@ static unsigned long __read_pending(struct kvm_vcpu *vcpu, u32 intid = VGIC_ADDR_TO_INTID(addr, 1); u32 value = 0; int i; + struct its_vpe *vpe = &vcpu->arch.vgic_cpu.vgic_v3.its_vpe;
/* Loop over all IRQs affected by this read */ for (i = 0; i < len * 8; i++) { @@ -255,6 +257,21 @@ static unsigned long __read_pending(struct kvm_vcpu *vcpu, if (vgic_direct_sgi_or_ppi(irq)) { int err;
+ if (irq->hw && vgic_irq_is_sgi(irq->intid) && + (kvm_vgic_global_state.flags & + FLAGS_WORKAROUND_HIP09_ERRATUM_162200806)) { + void *va; + u8 *ptr; + int mask; + bool is_pending; + + mask = BIT(irq->intid % BITS_PER_BYTE); + va = page_address(vpe->vpt_page); + ptr = va + VIRTUAL_SGI_PENDING_OFFSET + + irq->intid / BITS_PER_BYTE; + is_pending = *ptr & mask; + } + val = false; err = irq_get_irqchip_state(irq->host_irq, IRQCHIP_STATE_PENDING, diff --git a/arch/arm64/kvm/vgic/vgic-mmio.h b/arch/arm64/kvm/vgic/vgic-mmio.h index 55f49933e304..0477ec95e96c 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio.h +++ b/arch/arm64/kvm/vgic/vgic-mmio.h @@ -6,6 +6,7 @@ #define __KVM_ARM_VGIC_MMIO_H__
#define FLAGS_WORKAROUND_HIP09_ERRATUM_162200803 (1ULL << 4) +#define FLAGS_WORKAROUND_HIP09_ERRATUM_162200806 (1ULL << 5)
struct vgic_register_region { unsigned int reg_offset; diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 2ef910e14ac0..c8d2878d73d3 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -42,6 +42,7 @@ #define FLAGS_WORKAROUND_MTK_GICR_SAVE (1ULL << 2) #define FLAGS_WORKAROUND_ASR_ERRATUM_8601001 (1ULL << 3) #define FLAGS_WORKAROUND_HIP09_ERRATUM_162200803 (1ULL << 4) +#define FLAGS_WORKAROUND_HIP09_ERRATUM_162200806 (1ULL << 5)
#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1)
@@ -1972,6 +1973,15 @@ static bool gic_enable_quirk_hip09_162200803(void *data) return true; }
+static bool gic_enable_quirk_hip09_162200806(void *data) +{ + struct gic_chip_data *d = data; + + d->flags |= FLAGS_WORKAROUND_HIP09_ERRATUM_162200806; + + return true; +} + static const struct gic_quirk gic_quirks[] = { { .desc = "GICv3: Qualcomm MSM8996 broken firmware", @@ -2050,6 +2060,14 @@ static const struct gic_quirk gic_quirks[] = { .mask = 0xffffffff, .init = gic_enable_quirk_hip09_162200803, }, +#endif +#ifdef CONFIG_HISILICON_ERRATUM_162200806 + { + .desc = "GICv3: HIP09 erratum 162200806", + .iidr = 0x01050736, + .mask = 0xffffffff, + .init = gic_enable_quirk_hip09_162200806, + }, #endif { }
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/6750 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/O...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/6750 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/O...