[PATCH] linux-headers: change the annotation of VFIO_IOMMU_SPAPR_REGISTER_MEMORY in vfio.h
The ioctl(VFIO_IOMMU_MAP_DMA/VFIO_IOMMU_UNMAP_DMA) won't be called in SPAPR machine, which is replaced by VFIO_IOMMU_SPAPR_TCE_CREATE/ VFIO_IOMMU_SPAPR_TCE_REMOVE, so change the description. Signed-off-by: JianChunfu --- linux-headers/linux/vfio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index b4be37b22..20e8e6ae8 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -1764,7 +1764,7 @@ struct vfio_eeh_pe_op { * * Registers user space memory where DMA is allowed. It pins * user pages and does the locked memory accounting so - * subsequent VFIO_IOMMU_MAP_DMA/VFIO_IOMMU_UNMAP_DMA calls + * subsequent VFIO_IOMMU_SPAPR_TCE_CREATE/VFIO_IOMMU_SPAPR_TCE_REMOVE calls * get faster. */ struct vfio_iommu_spapr_register_memory { -- 2.27.0
[RESEND PATCH] target/ppc: Fix the order of kvm_enable judgment about kvmppc_set_interrupt()
It's unnecessary for non-KVM accelerators(TCG, for example), to call this function, so change the order of kvm_enable() judgment. The static inline function that returns -1 directly does not work in TCG's situation. Signed-off-by: jianchunfu --- hw/ppc/ppc.c | 8 ++-- target/ppc/kvm.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index 0e0a3d93c3..3e96b24487 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -58,7 +58,9 @@ void ppc_set_irq(PowerPCCPU *cpu, int irq, int level) if (old_pending != env->pending_interrupts) { ppc_maybe_interrupt(env); -kvmppc_set_interrupt(cpu, irq, level); +if (kvm_enabled()) { +kvmppc_set_interrupt(cpu, irq, level); +} } trace_ppc_irq_set_exit(env, irq, level, env->pending_interrupts, @@ -1465,5 +1467,7 @@ void ppc_irq_reset(PowerPCCPU *cpu) CPUPPCState *env = >env; env->irq_input_state = 0; -kvmppc_set_interrupt(cpu, PPC_INTERRUPT_EXT, 0); +if (kvm_enabled()) { +kvmppc_set_interrupt(cpu, PPC_INTERRUPT_EXT, 0); +} } diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index a8a935e267..11a1fbc244 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -1315,7 +1315,7 @@ int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level) return 0; } -if (!kvm_enabled() || !cap_interrupt_unset) { +if (!cap_interrupt_unset) { return 0; } -- 2.27.0
[PATCH] target/ppc: Fix the order of kvm_enable judgment about kvmppc_set_interrupt()
It's unnecessary for non-KVM accelerators(TCG, for example), to call this function, so change the order of kvm_enable() judgment. The static inline function that returns -1 directly does not work in TCG's situation. Signed-off-by: jianchunfu --- hw/ppc/ppc.c | 8 ++-- target/ppc/kvm.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index 0e0a3d93c3..3e96b24487 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -58,7 +58,9 @@ void ppc_set_irq(PowerPCCPU *cpu, int irq, int level) if (old_pending != env->pending_interrupts) { ppc_maybe_interrupt(env); -kvmppc_set_interrupt(cpu, irq, level); +if (kvm_enabled()) { +kvmppc_set_interrupt(cpu, irq, level); +} } trace_ppc_irq_set_exit(env, irq, level, env->pending_interrupts, @@ -1465,5 +1467,7 @@ void ppc_irq_reset(PowerPCCPU *cpu) CPUPPCState *env = >env; env->irq_input_state = 0; -kvmppc_set_interrupt(cpu, PPC_INTERRUPT_EXT, 0); +if (kvm_enabled()) { +kvmppc_set_interrupt(cpu, PPC_INTERRUPT_EXT, 0); +} } diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index a8a935e267..11a1fbc244 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -1315,7 +1315,7 @@ int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level) return 0; } -if (!kvm_enabled() || !cap_interrupt_unset) { +if (!cap_interrupt_unset) { return 0; } -- 2.27.0
[RFC] libvhost-user: Add report when allocation failures
Add error report when malloc fails of virtqueue element. It's a little pointless to return NULL, wouldn't it be right to report error and exit when malloc fails since it is in a standalone project while not QEMU. Signed-off-by: jianchunfu --- subprojects/libvhost-user/libvhost-user.c | 4 1 file changed, 4 insertions(+) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c index 47d2efc60f..c2bdf0fcc1 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -2551,6 +2551,10 @@ virtqueue_alloc_element(size_t sz, assert(sz >= sizeof(VuVirtqElement)); elem = malloc(out_sg_end); +if (!elem) { +DPRINT("%s: failed to malloc virtqelement\n", __func__); +return NULL; +} elem->out_num = out_num; elem->in_num = in_num; elem->in_sg = (void *)elem + in_sg_ofs; -- 2.18.4
[PATCH] libvhost-user: Handling potential memory allocation failures
Add malloc check of virtqueue element in libvhost-user. Signed-off-by: jianchunfu --- subprojects/libvhost-user/libvhost-user.c | 4 1 file changed, 4 insertions(+) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c index 47d2efc60f..901cd7a2c0 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -2551,6 +2551,10 @@ virtqueue_alloc_element(size_t sz, assert(sz >= sizeof(VuVirtqElement)); elem = malloc(out_sg_end); +if (!elem) { +DPRINT("%s: failed to malloc virtqelement\n", __func__); +exit(0); +} elem->out_num = out_num; elem->in_num = in_num; elem->in_sg = (void *)elem + in_sg_ofs; -- 2.18.4
[PATCH] bochs-display: Modify mismatched return value
Modify the return value of unsigned int to 0. Signed-off-by: jianchunfu --- hw/display/bochs-display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/bochs-display.c b/hw/display/bochs-display.c index 8ed734b195..3bd22b4ea7 100644 --- a/hw/display/bochs-display.c +++ b/hw/display/bochs-display.c @@ -83,7 +83,7 @@ static uint64_t bochs_display_vbe_read(void *ptr, hwaddr addr, } if (index >= ARRAY_SIZE(s->vbe_regs)) { -return -1; +return 0; } return s->vbe_regs[index]; } -- 2.18.4
[PATCH] target/ppc: Add error reporting when opening file fails
Add error reporting before return when opening file fails. Signed-off-by: jianchunfu --- target/ppc/kvm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index dc93b99189..ef9a871411 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -1798,6 +1798,7 @@ static int read_cpuinfo(const char *field, char *value, int len) f = fopen("/proc/cpuinfo", "r"); if (!f) { +fprintf(stderr, "Error opening /proc/cpuinfo: %s\n", strerror(errno)); return -1; } @@ -1906,6 +1907,7 @@ static uint64_t kvmppc_read_int_dt(const char *filename) f = fopen(filename, "rb"); if (!f) { +fprintf(stderr, "Error opening %s: %s\n", filename, strerror(errno)); return -1; } -- 2.18.4
[PATCH] migration/dirtyrate: Replace malloc with g_new
Using macro g_new() to handling potential memory allocation failures in dirtyrate. Signed-off-by: jianchunfu --- migration/dirtyrate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c index aace12a787..0e59aacbb0 100644 --- a/migration/dirtyrate.c +++ b/migration/dirtyrate.c @@ -522,10 +522,10 @@ static void calculate_dirtyrate_dirty_ring(struct DirtyRateConfig config) nvcpu++; } -dirty_pages = malloc(sizeof(*dirty_pages) * nvcpu); +dirty_pages = g_new(DirtyPageRecord, nvcpu); DirtyStat.dirty_ring.nvcpu = nvcpu; -DirtyStat.dirty_ring.rates = malloc(sizeof(DirtyRateVcpu) * nvcpu); +DirtyStat.dirty_ring.rates = g_new(DirtyRateVcpu, nvcpu); dirtyrate_global_dirty_log_start(); -- 2.18.4
[RFC] migration/dirtyrate: check malloc() return
Handling potential memory allocation failures in dirtyrate. Signed-off-by: jianchunfu --- migration/dirtyrate.c | 8 1 file changed, 8 insertions(+) diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c index aace12a787..5dd40f32c8 100644 --- a/migration/dirtyrate.c +++ b/migration/dirtyrate.c @@ -523,9 +523,17 @@ static void calculate_dirtyrate_dirty_ring(struct DirtyRateConfig config) } dirty_pages = malloc(sizeof(*dirty_pages) * nvcpu); +if (!dirty_pages) { +error_report("malloc dirty pages for vcpus failed."); +exit(1); +} DirtyStat.dirty_ring.nvcpu = nvcpu; DirtyStat.dirty_ring.rates = malloc(sizeof(DirtyRateVcpu) * nvcpu); +if (!DirtyStat.dirty_ring.rates) { +error_report("malloc dirty rates for vcpu ring failed."); +exit(1); +} dirtyrate_global_dirty_log_start(); -- 2.18.4