Commit c34bbc2c authored by Bibo Mao's avatar Bibo Mao Committed by Huacai Chen
Browse files

LoongArch: KVM: Fix interrupt route update with EIOINTC



With function eiointc_update_sw_coremap(), there is forced assignment
like val = *(u64 *)pvalue. Parameter pvalue may be pointer to char type
or others, there is problem with forced assignment with u64 type.

Here the detailed value is passed rather address pointer.

Cc: stable@vger.kernel.org
Fixes: 3956a52b ("LoongArch: KVM: Add EIOINTC read and write functions")
Signed-off-by: default avatarBibo Mao <maobibo@loongson.cn>
Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
parent 9159c5e7
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -66,10 +66,9 @@ static void eiointc_update_irq(struct loongarch_eiointc *s, int irq, int level)
}

static inline void eiointc_update_sw_coremap(struct loongarch_eiointc *s,
					int irq, void *pvalue, u32 len, bool notify)
					int irq, u64 val, u32 len, bool notify)
{
	int i, cpu;
	u64 val = *(u64 *)pvalue;

	for (i = 0; i < len; i++) {
		cpu = val & 0xff;
@@ -403,7 +402,7 @@ static int loongarch_eiointc_writeb(struct kvm_vcpu *vcpu,
		irq = offset - EIOINTC_COREMAP_START;
		index = irq;
		s->coremap.reg_u8[index] = data;
		eiointc_update_sw_coremap(s, irq, (void *)&data, sizeof(data), true);
		eiointc_update_sw_coremap(s, irq, data, sizeof(data), true);
		break;
	default:
		ret = -EINVAL;
@@ -488,7 +487,7 @@ static int loongarch_eiointc_writew(struct kvm_vcpu *vcpu,
		irq = offset - EIOINTC_COREMAP_START;
		index = irq >> 1;
		s->coremap.reg_u16[index] = data;
		eiointc_update_sw_coremap(s, irq, (void *)&data, sizeof(data), true);
		eiointc_update_sw_coremap(s, irq, data, sizeof(data), true);
		break;
	default:
		ret = -EINVAL;
@@ -573,7 +572,7 @@ static int loongarch_eiointc_writel(struct kvm_vcpu *vcpu,
		irq = offset - EIOINTC_COREMAP_START;
		index = irq >> 2;
		s->coremap.reg_u32[index] = data;
		eiointc_update_sw_coremap(s, irq, (void *)&data, sizeof(data), true);
		eiointc_update_sw_coremap(s, irq, data, sizeof(data), true);
		break;
	default:
		ret = -EINVAL;
@@ -658,7 +657,7 @@ static int loongarch_eiointc_writeq(struct kvm_vcpu *vcpu,
		irq = offset - EIOINTC_COREMAP_START;
		index = irq >> 3;
		s->coremap.reg_u64[index] = data;
		eiointc_update_sw_coremap(s, irq, (void *)&data, sizeof(data), true);
		eiointc_update_sw_coremap(s, irq, data, sizeof(data), true);
		break;
	default:
		ret = -EINVAL;
@@ -816,7 +815,7 @@ static int kvm_eiointc_ctrl_access(struct kvm_device *dev,
		for (i = 0; i < (EIOINTC_IRQS / 4); i++) {
			start_irq = i * 4;
			eiointc_update_sw_coremap(s, start_irq,
					(void *)&s->coremap.reg_u32[i], sizeof(u32), false);
					s->coremap.reg_u32[i], sizeof(u32), false);
		}
		break;
	default: