LoongArch: KVM: Return directly when IPI address is not aligned

When IPI address is not aligned with its access size, it should return
directly in read/write operations, rather than only print a message with
WARN_ON_ONCE(). The method is the same with in kernel EIOINTC and PCHPIC
operations.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
This commit is contained in:
Bibo Mao 2026-08-10 12:21:57 +08:00 committed by Huacai Chen
parent a068c37c71
commit 5af8b70f56

View File

@ -181,8 +181,13 @@ static int loongarch_ipi_readl(struct kvm_vcpu *vcpu, gpa_t addr, int len, void
uint32_t offset;
uint64_t res = 0;
offset = (uint32_t)(addr & 0x1ff);
WARN_ON_ONCE(offset & (len - 1));
if (addr & (len - 1)) {
*(uint64_t *)val = res;
kvm_pr_unimpl("%s: ipi not aligned addr %llx len %d\n", __func__, addr, len);
return 0;
}
offset = addr - IOCSR_IPI_BASE;
switch (offset) {
case IOCSR_IPI_STATUS:
@ -199,11 +204,6 @@ static int loongarch_ipi_readl(struct kvm_vcpu *vcpu, gpa_t addr, int len, void
case IOCSR_IPI_CLEAR:
break;
case IOCSR_IPI_BUF_20 ... IOCSR_IPI_BUF_38 + 7:
if (offset + len > IOCSR_IPI_BUF_38 + 8) {
kvm_err("%s: invalid offset or len: offset = %d, len = %d\n",
__func__, offset, len);
break;
}
res = read_mailbox(vcpu, offset, len);
break;
default:
@ -222,8 +222,12 @@ static int loongarch_ipi_writel(struct kvm_vcpu *vcpu, gpa_t addr, int len, cons
data = *(uint64_t *)val;
offset = (uint32_t)(addr & 0x1ff);
WARN_ON_ONCE(offset & (len - 1));
if (addr & (len - 1)) {
kvm_pr_unimpl("%s: ipi not aligned addr %llx len %d\n", __func__, addr, len);
return 0;
}
offset = addr - IOCSR_IPI_BASE;
switch (offset) {
case IOCSR_IPI_STATUS: