mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
LoongArch: KVM: Replace kvm_err() with kvm_pr_unimpl()
Since guest kernel and ioctl() parameter from user mode is untrusted, there may be noise kernel log output in host hypervisor with abnormal state. Here replace kvm_err() with kvm_pr_unimpl() to reduce this kind of noise kernel log, and there is no function change. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
This commit is contained in:
parent
ab382eae73
commit
9b61ad973c
|
|
@ -252,7 +252,7 @@ int kvm_complete_iocsr_read(struct kvm_vcpu *vcpu, struct kvm_run *run)
|
|||
*gpr = *(s64 *)run->iocsr_io.data;
|
||||
break;
|
||||
default:
|
||||
kvm_err("Bad IOCSR length: %d, addr is 0x%lx\n",
|
||||
kvm_pr_unimpl("Bad IOCSR length: %d, addr is 0x%lx\n",
|
||||
run->iocsr_io.len, vcpu->arch.badv);
|
||||
er = EMULATE_FAIL;
|
||||
break;
|
||||
|
|
@ -326,8 +326,8 @@ static int kvm_trap_handle_gspr(struct kvm_vcpu *vcpu)
|
|||
|
||||
/* Rollback PC only if emulation was unsuccessful */
|
||||
if (er == EMULATE_FAIL) {
|
||||
kvm_err("[%#lx]%s: unsupported gspr instruction 0x%08x\n",
|
||||
curr_pc, __func__, inst.word);
|
||||
kvm_pr_unimpl("[%#lx]%s: unsupported gspr instruction 0x%08x\n",
|
||||
curr_pc, __func__, inst.word);
|
||||
|
||||
kvm_arch_vcpu_dump_regs(vcpu);
|
||||
vcpu->arch.pc = curr_pc;
|
||||
|
|
@ -490,7 +490,7 @@ int kvm_emu_mmio_read(struct kvm_vcpu *vcpu, larch_inst inst)
|
|||
return EMULATE_DO_MMIO;
|
||||
}
|
||||
|
||||
kvm_err("Read not supported Inst=0x%08x @%lx BadVaddr:%#lx\n",
|
||||
kvm_pr_unimpl("Read not supported Inst=0x%08x @%lx BadVaddr:%#lx\n",
|
||||
inst.word, vcpu->arch.pc, vcpu->arch.badv);
|
||||
kvm_arch_vcpu_dump_regs(vcpu);
|
||||
vcpu->mmio_needed = 0;
|
||||
|
|
@ -528,7 +528,7 @@ int kvm_complete_mmio_read(struct kvm_vcpu *vcpu, struct kvm_run *run)
|
|||
*gpr = *(s64 *)run->mmio.data;
|
||||
break;
|
||||
default:
|
||||
kvm_err("Bad MMIO length: %d, addr is 0x%lx\n",
|
||||
kvm_pr_unimpl("Bad MMIO length: %d, addr is 0x%lx\n",
|
||||
run->mmio.len, vcpu->arch.badv);
|
||||
er = EMULATE_FAIL;
|
||||
break;
|
||||
|
|
@ -655,7 +655,7 @@ int kvm_emu_mmio_write(struct kvm_vcpu *vcpu, larch_inst inst)
|
|||
}
|
||||
|
||||
vcpu->arch.pc = curr_pc;
|
||||
kvm_err("Write not supported Inst=0x%08x @%lx BadVaddr:%#lx\n",
|
||||
kvm_pr_unimpl("Write not supported Inst=0x%08x @%lx BadVaddr:%#lx\n",
|
||||
inst.word, vcpu->arch.pc, vcpu->arch.badv);
|
||||
kvm_arch_vcpu_dump_regs(vcpu);
|
||||
/* Rollback PC if emulation was unsuccessful */
|
||||
|
|
@ -747,8 +747,8 @@ static int kvm_handle_fpu_disabled(struct kvm_vcpu *vcpu, int ecode)
|
|||
* treated as a reserved instruction!
|
||||
* If FPU already in use, we shouldn't get this at all.
|
||||
*/
|
||||
if (WARN_ON(vcpu->arch.aux_inuse & KVM_LARCH_FPU)) {
|
||||
kvm_err("%s internal error\n", __func__);
|
||||
if (vcpu->arch.aux_inuse & KVM_LARCH_FPU) {
|
||||
kvm_pr_unimpl("%s internal error\n", __func__);
|
||||
run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
|
||||
return RESUME_HOST;
|
||||
}
|
||||
|
|
@ -942,7 +942,7 @@ static int kvm_fault_ni(struct kvm_vcpu *vcpu, int ecode)
|
|||
/* Fetch the instruction */
|
||||
inst = vcpu->arch.badi;
|
||||
badv = vcpu->arch.badv;
|
||||
kvm_err("ECode: %d PC=%#lx Inst=0x%08x BadVaddr=%#lx ESTAT=%#lx\n",
|
||||
kvm_pr_unimpl("ECode: %d PC=%#lx Inst=0x%08x BadVaddr=%#lx ESTAT=%#lx\n",
|
||||
ecode, vcpu->arch.pc, inst, badv, read_gcsr_estat());
|
||||
kvm_arch_vcpu_dump_regs(vcpu);
|
||||
kvm_queue_exception(vcpu, EXCCODE_INE, 0);
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ static int kvm_dmsintc_ctrl_access(struct kvm_device *dev,
|
|||
}
|
||||
break;
|
||||
default:
|
||||
kvm_err("%s: unknown dmsintc register, addr = %d\n", __func__, addr);
|
||||
kvm_pr_unimpl("%s: unknown dmsintc register, addr = %d\n", __func__, addr);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ static int kvm_dmsintc_set_attr(struct kvm_device *dev,
|
|||
case KVM_DEV_LOONGARCH_DMSINTC_GRP_CTRL:
|
||||
return kvm_dmsintc_ctrl_access(dev, attr, true);
|
||||
default:
|
||||
kvm_err("%s: unknown group (%d)\n", __func__, attr->group);
|
||||
kvm_pr_unimpl("%s: unknown group (%d)\n", __func__, attr->group);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
|
@ -139,13 +139,13 @@ static int kvm_dmsintc_create(struct kvm_device *dev, u32 type)
|
|||
struct loongarch_dmsintc *s;
|
||||
|
||||
if (!dev) {
|
||||
kvm_err("%s: kvm_device ptr is invalid!\n", __func__);
|
||||
kvm_pr_unimpl("%s: kvm_device ptr is invalid!\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
kvm = dev->kvm;
|
||||
if (kvm->arch.dmsintc) {
|
||||
kvm_err("%s: LoongArch DMSINTC has already been created!\n", __func__);
|
||||
kvm_pr_unimpl("%s: LoongArch DMSINTC has already been created!\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static void eiointc_update_irq(struct loongarch_eiointc *s, int irq, int level)
|
|||
cpu = s->sw_coremap[irq];
|
||||
vcpu = kvm_get_vcpu_by_id(s->kvm, cpu);
|
||||
if (unlikely(vcpu == NULL)) {
|
||||
kvm_err("%s: invalid target cpu: %d\n", __func__, cpu);
|
||||
kvm_pr_unimpl("%s: invalid target cpu: %d\n", __func__, cpu);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -169,12 +169,12 @@ static int kvm_eiointc_read(struct kvm_vcpu *vcpu,
|
|||
struct loongarch_eiointc *eiointc = vcpu->kvm->arch.eiointc;
|
||||
|
||||
if (!eiointc) {
|
||||
kvm_err("%s: eiointc irqchip not valid!\n", __func__);
|
||||
kvm_pr_unimpl("%s: eiointc irqchip not valid!\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (addr & (len - 1)) {
|
||||
kvm_err("%s: eiointc not aligned addr %llx len %d\n", __func__, addr, len);
|
||||
kvm_pr_unimpl("%s: eiointc not aligned addr %llx len %d\n", __func__, addr, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -301,12 +301,12 @@ static int kvm_eiointc_write(struct kvm_vcpu *vcpu,
|
|||
struct loongarch_eiointc *eiointc = vcpu->kvm->arch.eiointc;
|
||||
|
||||
if (!eiointc) {
|
||||
kvm_err("%s: eiointc irqchip not valid!\n", __func__);
|
||||
kvm_pr_unimpl("%s: eiointc irqchip not valid!\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (addr & (len - 1)) {
|
||||
kvm_err("%s: eiointc not aligned addr %llx len %d\n", __func__, addr, len);
|
||||
kvm_pr_unimpl("%s: eiointc not aligned addr %llx len %d\n", __func__, addr, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -349,7 +349,7 @@ static int kvm_eiointc_virt_read(struct kvm_vcpu *vcpu,
|
|||
struct loongarch_eiointc *eiointc = vcpu->kvm->arch.eiointc;
|
||||
|
||||
if (!eiointc) {
|
||||
kvm_err("%s: eiointc irqchip not valid!\n", __func__);
|
||||
kvm_pr_unimpl("%s: eiointc irqchip not valid!\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -379,7 +379,7 @@ static int kvm_eiointc_virt_write(struct kvm_vcpu *vcpu,
|
|||
struct loongarch_eiointc *eiointc = vcpu->kvm->arch.eiointc;
|
||||
|
||||
if (!eiointc) {
|
||||
kvm_err("%s: eiointc irqchip not valid!\n", __func__);
|
||||
kvm_pr_unimpl("%s: eiointc irqchip not valid!\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -506,7 +506,7 @@ static int kvm_eiointc_regs_access(struct kvm_device *dev,
|
|||
p = (void *)s->coremap + offset * 4;
|
||||
break;
|
||||
default:
|
||||
kvm_err("%s: unknown eiointc register, addr = %d\n", __func__, addr);
|
||||
kvm_pr_unimpl("%s: unknown eiointc register, addr = %d\n", __func__, addr);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -550,7 +550,7 @@ static int kvm_eiointc_sw_status_access(struct kvm_device *dev,
|
|||
p = &s->status;
|
||||
break;
|
||||
default:
|
||||
kvm_err("%s: unknown eiointc register, addr = %d\n", __func__, addr);
|
||||
kvm_pr_unimpl("%s: unknown eiointc register, addr = %d\n", __func__, addr);
|
||||
return -EINVAL;
|
||||
}
|
||||
spin_lock_irqsave(&s->lock, flags);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ static void ipi_send(struct kvm *kvm, uint64_t data)
|
|||
cpu = ((data & 0xffffffff) >> 16) & 0x3ff;
|
||||
vcpu = kvm_get_vcpu_by_cpuid(kvm, cpu);
|
||||
if (unlikely(vcpu == NULL)) {
|
||||
kvm_err("%s: invalid target cpu: %d\n", __func__, cpu);
|
||||
kvm_pr_unimpl("%s: invalid target cpu: %d\n", __func__, cpu);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ static int mail_send(struct kvm *kvm, uint64_t data)
|
|||
cpu = ((data & 0xffffffff) >> 16) & 0x3ff;
|
||||
vcpu = kvm_get_vcpu_by_cpuid(kvm, cpu);
|
||||
if (unlikely(vcpu == NULL)) {
|
||||
kvm_err("%s: invalid target cpu: %d\n", __func__, cpu);
|
||||
kvm_pr_unimpl("%s: invalid target cpu: %d\n", __func__, cpu);
|
||||
return 0;
|
||||
}
|
||||
mailbox = ((data & 0xffffffff) >> 2) & 0x7;
|
||||
|
|
@ -137,7 +137,7 @@ static int send_ipi_data(struct kvm_vcpu *vcpu, gpa_t addr, uint64_t data)
|
|||
ret = kvm_io_bus_read(vcpu, KVM_IOCSR_BUS, addr, 4, &val);
|
||||
srcu_read_unlock(&vcpu->kvm->srcu, idx);
|
||||
if (unlikely(ret)) {
|
||||
kvm_err("%s: : read data from addr %llx failed\n", __func__, addr);
|
||||
kvm_pr_unimpl("%s: : read data from addr %llx failed\n", __func__, addr);
|
||||
return 0;
|
||||
}
|
||||
/* Construct the mask by scanning the bit 27-30 */
|
||||
|
|
@ -153,7 +153,7 @@ static int send_ipi_data(struct kvm_vcpu *vcpu, gpa_t addr, uint64_t data)
|
|||
ret = kvm_io_bus_write(vcpu, KVM_IOCSR_BUS, addr, 4, &val);
|
||||
srcu_read_unlock(&vcpu->kvm->srcu, idx);
|
||||
if (unlikely(ret))
|
||||
kvm_err("%s: : write data to addr %llx failed\n", __func__, addr);
|
||||
kvm_pr_unimpl("%s: : write data to addr %llx failed\n", __func__, addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ static int any_send(struct kvm *kvm, uint64_t data)
|
|||
cpu = ((data & 0xffffffff) >> 16) & 0x3ff;
|
||||
vcpu = kvm_get_vcpu_by_cpuid(kvm, cpu);
|
||||
if (unlikely(vcpu == NULL)) {
|
||||
kvm_err("%s: invalid target cpu: %d\n", __func__, cpu);
|
||||
kvm_pr_unimpl("%s: invalid target cpu: %d\n", __func__, cpu);
|
||||
return 0;
|
||||
}
|
||||
offset = data & 0xffff;
|
||||
|
|
@ -205,7 +205,7 @@ static int loongarch_ipi_readl(struct kvm_vcpu *vcpu, gpa_t addr, int len, void
|
|||
res = read_mailbox(vcpu, offset, len);
|
||||
break;
|
||||
default:
|
||||
kvm_err("%s: unknown addr: %llx\n", __func__, addr);
|
||||
kvm_pr_unimpl("%s: unknown addr: %llx\n", __func__, addr);
|
||||
break;
|
||||
}
|
||||
*(uint64_t *)val = res;
|
||||
|
|
@ -244,8 +244,8 @@ static int loongarch_ipi_writel(struct kvm_vcpu *vcpu, gpa_t addr, int len, cons
|
|||
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);
|
||||
kvm_pr_unimpl("%s: invalid offset or len: offset = %d, len = %d\n",
|
||||
__func__, offset, len);
|
||||
break;
|
||||
}
|
||||
write_mailbox(vcpu, offset, data, len);
|
||||
|
|
@ -260,7 +260,7 @@ static int loongarch_ipi_writel(struct kvm_vcpu *vcpu, gpa_t addr, int len, cons
|
|||
any_send(vcpu->kvm, data);
|
||||
break;
|
||||
default:
|
||||
kvm_err("%s: unknown addr: %llx\n", __func__, addr);
|
||||
kvm_pr_unimpl("%s: unknown addr: %llx\n", __func__, addr);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ static int kvm_ipi_regs_access(struct kvm_device *dev,
|
|||
|
||||
vcpu = kvm_get_vcpu_by_id(dev->kvm, cpu);
|
||||
if (unlikely(vcpu == NULL)) {
|
||||
kvm_err("%s: invalid target cpu: %d\n", __func__, cpu);
|
||||
kvm_pr_unimpl("%s: invalid target cpu: %d\n", __func__, cpu);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -337,7 +337,7 @@ static int kvm_ipi_regs_access(struct kvm_device *dev,
|
|||
len = 8;
|
||||
break;
|
||||
default:
|
||||
kvm_err("%s: unknown ipi register, addr = %d\n", __func__, addr);
|
||||
kvm_pr_unimpl("%s: unknown ipi register, addr = %d\n", __func__, addr);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -371,7 +371,7 @@ static int kvm_ipi_get_attr(struct kvm_device *dev,
|
|||
case KVM_DEV_LOONGARCH_IPI_GRP_REGS:
|
||||
return kvm_ipi_regs_access(dev, attr, false);
|
||||
default:
|
||||
kvm_err("%s: unknown group (%d)\n", __func__, attr->group);
|
||||
kvm_pr_unimpl("%s: unknown group (%d)\n", __func__, attr->group);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
|
@ -383,7 +383,7 @@ static int kvm_ipi_set_attr(struct kvm_device *dev,
|
|||
case KVM_DEV_LOONGARCH_IPI_GRP_REGS:
|
||||
return kvm_ipi_regs_access(dev, attr, true);
|
||||
default:
|
||||
kvm_err("%s: unknown group (%d)\n", __func__, attr->group);
|
||||
kvm_pr_unimpl("%s: unknown group (%d)\n", __func__, attr->group);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
|
@ -396,13 +396,13 @@ static int kvm_ipi_create(struct kvm_device *dev, u32 type)
|
|||
struct loongarch_ipi *s;
|
||||
|
||||
if (!dev) {
|
||||
kvm_err("%s: kvm_device ptr is invalid!\n", __func__);
|
||||
kvm_pr_unimpl("%s: kvm_device ptr is invalid!\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
kvm = dev->kvm;
|
||||
if (kvm->arch.ipi) {
|
||||
kvm_err("%s: LoongArch IPI has already been created!\n", __func__);
|
||||
kvm_pr_unimpl("%s: LoongArch IPI has already been created!\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -422,7 +422,7 @@ static int kvm_ipi_create(struct kvm_device *dev, u32 type)
|
|||
ret = kvm_io_bus_register_dev(kvm, KVM_IOCSR_BUS, IOCSR_IPI_BASE, IOCSR_IPI_SIZE, device);
|
||||
mutex_unlock(&kvm->slots_lock);
|
||||
if (ret < 0) {
|
||||
kvm_err("%s: Initialize IOCSR dev failed, ret = %d\n", __func__, ret);
|
||||
kvm_pr_unimpl("%s: Initialize IOCSR dev failed, ret = %d\n", __func__, ret);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -151,12 +151,12 @@ static int kvm_pch_pic_read(struct kvm_vcpu *vcpu,
|
|||
struct loongarch_pch_pic *s = vcpu->kvm->arch.pch_pic;
|
||||
|
||||
if (!s) {
|
||||
kvm_err("%s: pch pic irqchip not valid!\n", __func__);
|
||||
kvm_pr_unimpl("%s: pch pic irqchip not valid!\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (addr & (len - 1)) {
|
||||
kvm_err("%s: pch pic not aligned addr %llx len %d\n", __func__, addr, len);
|
||||
kvm_pr_unimpl("%s: pch pic not aligned addr %llx len %d\n", __func__, addr, len);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -250,12 +250,12 @@ static int kvm_pch_pic_write(struct kvm_vcpu *vcpu,
|
|||
struct loongarch_pch_pic *s = vcpu->kvm->arch.pch_pic;
|
||||
|
||||
if (!s) {
|
||||
kvm_err("%s: pch pic irqchip not valid!\n", __func__);
|
||||
kvm_pr_unimpl("%s: pch pic irqchip not valid!\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (addr & (len - 1)) {
|
||||
kvm_err("%s: pch pic not aligned addr %llx len %d\n", __func__, addr, len);
|
||||
kvm_pr_unimpl("%s: pch pic not aligned addr %llx len %d\n", __func__, addr, len);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -390,13 +390,13 @@ static int kvm_pch_pic_set_attr(struct kvm_device *dev,
|
|||
return -EFAULT;
|
||||
|
||||
if (!dev->kvm->arch.pch_pic) {
|
||||
kvm_err("%s: please create pch_pic irqchip first!\n", __func__);
|
||||
kvm_pr_unimpl("%s: pch_pic irqchip not created\n", __func__);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return kvm_pch_pic_init(dev, addr);
|
||||
default:
|
||||
kvm_err("%s: unknown group (%d) attr (%lld)\n", __func__, attr->group,
|
||||
kvm_pr_unimpl("%s: unknown group (%d) attr (%lld)\n", __func__, attr->group,
|
||||
attr->attr);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1476,7 +1476,7 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)
|
|||
else if (intr < 0)
|
||||
kvm_dequeue_irq(vcpu, -intr);
|
||||
else {
|
||||
kvm_err("%s: invalid interrupt ioctl %d\n", __func__, irq->irq);
|
||||
kvm_pr_unimpl("%s: invalid interrupt ioctl %d\n", __func__, irq->irq);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user