Re: [PATCH v4 3/3] modversions: treat symbol CRCs as 32 bit quantities on 64 bit archs
On 19 January 2017 at 17:24, Linus Torvalds wrote: > On Thu, Jan 19, 2017 at 1:22 AM, Ard Biesheuvel > wrote: >>> >>> Your genksyms.c change is not exactly obvious. I looked at it, and my >>> brain just shut down. Why both the >>> >>> LONG(0x%08lx); >>> >>> _and_ the >>> >>> "%s__crc_%s = 0x%08lx;\n" >>> >>> in the linker script? I'm sure there's a good reason, but I'd like to >>> see a more explicit explanation fo what the generated linker script >>> does and what the rules are. >> >> This is simply because modpost still uses the value of the symbol >> rather than the value it points to to generate the /other/ side of the >> comparison (i.e., Module.symvers etc) > > Ahh, now that you explained it, it was obvious. Thanks. > > But yes, I don't think we want that "both belt and suspenders" > approach, so your updated patch that does things just one way is I > think the right way. > >> I will look into updating modpost to dereference the symbol as well, >> and update the RFC patch accordingly. > > Yes, so your updated patch looks good to me. > > I think our old "symbol with an absolute value" model was simpler > conceptually, but given the existing absolute (sic) braindamage of > linkers, I think your latest patch is probably the way to go. > OK. > If for no other reason than the fact that it doesn't depend on > something that clearly nobody else uses, and even the linker people > were confused about. > > So I think the slightly more complex model of relative offsets is the > simpler one in the end if it means that we don't have to have > completely insane workarounds for linker damage. > > But maybe somebody else wants to pipe up. Preferably somebody who > doesn't hate the symversions code as much as I do by now, and actually > _uses_ it ;) > I am not crazy about it either: I am simply trying to get rid of the ~10,000 pointless relocations in the arm64 KASLR kernel rather than having to rely on the dodgy code that 'repairs' the CRCs at runtime. I have noticed one slight snag though: the ARM module loader currently has no support for the R_ARM_REL32 relocations that are emitted by the relative references in the kcrctabs. I looked at other arches, x86, ia64, s390, power and arm64, and those all seem to be fully equipped in this regard, but it would be good if we could get some coverage for this code on other architectures to find out which ones need to have this support added as well. Thanks, Ard.
[PATCH] powerpc/pasemi/nemo: Fix low memory values for boot.
Commit 5c0484e25ec0 ('powerpc: Endian safe trampoline') added a macro 'FIXUP_ENDIAN' to head_64.S. The CFE on Nemo has a bug that shows up when this is included, the system hangs right after printing the initial memory map, before the CPU's are started. Clearing the long long at addr 8 has been shown to fix this, so add an initalisation to head_64.S so the system will boot. Signed-off-by: Darren Stevens --- diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S index 1dc5eae..032b317 100644 --- a/arch/powerpc/kernel/head_64.S +++ b/arch/powerpc/kernel/head_64.S @@ -79,6 +79,13 @@ _GLOBAL(__start) /* NOP this out unconditionally */ BEGIN_FTR_SECTION FIXUP_ENDIAN +#ifdef CONFIG_PPC_PASEMI_NEMO + /* +* Zero address 8 so Nemo will boot +*/ + li r0,0 + std 0,8(0) +#endif b __start_initialization_multiplatform END_FTR_SECTION(0, 1)
[PATCH v2] powerpc/pasemi: Remove hardcoded bus numbers on smbus
The pasemi smbus controller uses PCI_FUNC(dev->devfn) to define which number bus to attach to, however this fails when something else is probed first, for example an ATI Radeon graphics card will claim 9 or 10 busses, including the ones the pasemi wants. Patch the driver to call i2c_add_adapter rather than i2c_add_numbered_adapter. Signed-off-by: Darren Stevens --- v2 - remove unnecessary smbus->adapter.nr initialisation. diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c index df1dbc9..05847fd 100644 --- a/drivers/i2c/busses/i2c-pasemi.c +++ b/drivers/i2c/busses/i2c-pasemi.c @@ -365,7 +365,6 @@ static int pasemi_smb_probe(struct pci_dev *dev, smbus->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; smbus->adapter.algo = &smbus_algorithm; smbus->adapter.algo_data = smbus; - smbus->adapter.nr = PCI_FUNC(dev->devfn); /* set up the sysfs linkage to our parent device */ smbus->adapter.dev.parent = &dev->dev; @@ -373,7 +372,7 @@ static int pasemi_smb_probe(struct pci_dev *dev, reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR | (CLK_100K_DIV & CTL_CLK_M))); - error = i2c_add_numbered_adapter(&smbus->adapter); + error = i2c_add_adapter(&smbus->adapter); if (error) goto out_release_region;
[RFT PATCH v3] modversions: redefine kcrctab entries as relative CRC pointers
The modversion symbol CRCs are emitted as ELF symbols, which allows us to easily populate the kcrctab sections by relying on the linker to associate each kcrctab slot with the correct value. This has a couple of downsides: - On architectures that support runtime relocation, a R__RELATIVE relocation entry is emitted for each CRC value, which identifies it as a quantity that requires fixing up based on the actual runtime load offset of the kernel. This results in corrupted CRCs unless we explicitly undo the fixup (and this is currently being handled in the core module code), - On 64 bit architectures, such runtime relocation entries take up 24 bytes of __init space each, resulting in a x8 overhead in [uncompressed] kernel size for CRCs, - The use of ELF symbols to represent other things than virtual addresses is poorly supported (and mostly untested) in GNU binutils. So avoid these issues by redefining the kcrctab entries as signed relative offsets pointing to the actual CRC value stored elsewhere in the kernel image (or in the module). This removes all the ELF hackery involving symbols and relocations, at the expense of 4 additional bytes of space per CRC on 32-bit architectures. (On 64-bit architectures, each 8 byte CRC symbol reference is replaced by a 4 byte relative offset and the 4 byte CRC value elsewhere in the image) Note that this mostly reverts commit d4703aefdbc8 ("module: handle ppc64 relocating kcrctabs when CONFIG_RELOCATABLE=y") Signed-off-by: Ard Biesheuvel --- v3: emit CRCs into .rodata rather than .rodata.modver, given that the latter will be emitted with read-write permissions, making the CRCs end up in a writable module segment. (The vmlinux linker fold the modpost fix to ensure that the section address is only substracted from the symbol address when the ELF object in question is fully linked (i.e., ET_DYN or ET_EXEC, and not ET_REL) v2: update modpost as well, so that genksyms no longer has to emit symbols for both the actual CRC value and the reference to where it is stored in the image arch/powerpc/include/asm/module.h | 4 -- arch/powerpc/kernel/module_64.c | 8 include/asm-generic/export.h | 7 +-- include/linux/export.h| 9 ++-- include/linux/module.h| 14 +++--- kernel/module.c | 50 +--- scripts/genksyms/genksyms.c | 4 +- scripts/kallsyms.c| 12 + scripts/mod/modpost.c | 10 +++- 9 files changed, 59 insertions(+), 59 deletions(-) diff --git a/arch/powerpc/include/asm/module.h b/arch/powerpc/include/asm/module.h index cc12c61ef315..53885512b8d3 100644 --- a/arch/powerpc/include/asm/module.h +++ b/arch/powerpc/include/asm/module.h @@ -90,9 +90,5 @@ static inline int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sec } #endif -#if defined(CONFIG_MODVERSIONS) && defined(CONFIG_PPC64) -#define ARCH_RELOCATES_KCRCTAB -#define reloc_start PHYSICAL_START -#endif #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_MODULE_H */ diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c index bb1807184bad..0b0f89685b67 100644 --- a/arch/powerpc/kernel/module_64.c +++ b/arch/powerpc/kernel/module_64.c @@ -286,14 +286,6 @@ static void dedotify_versions(struct modversion_info *vers, for (end = (void *)vers + size; vers < end; vers++) if (vers->name[0] == '.') { memmove(vers->name, vers->name+1, strlen(vers->name)); -#ifdef ARCH_RELOCATES_KCRCTAB - /* The TOC symbol has no CRC computed. To avoid CRC -* check failing, we must force it to the expected -* value (see CRC check in module.c). -*/ - if (!strcmp(vers->name, "TOC.")) - vers->crc = -(unsigned long)reloc_start; -#endif } } diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h index 63554e9f6e0c..ce63ea1a60c2 100644 --- a/include/asm-generic/export.h +++ b/include/asm-generic/export.h @@ -9,18 +9,15 @@ #ifndef KSYM_ALIGN #define KSYM_ALIGN 8 #endif -#ifndef KCRC_ALIGN -#define KCRC_ALIGN 8 -#endif #else #define __put .long #ifndef KSYM_ALIGN #define KSYM_ALIGN 4 #endif +#endif #ifndef KCRC_ALIGN #define KCRC_ALIGN 4 #endif -#endif #ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX #define KSYM(name) _##name @@ -52,7 +49,7 @@ KSYM(__kstrtab_\name): .section ___kcrctab\sec+\name,"a" .balign KCRC_ALIGN KSYM(__kcrctab_\name): - __put KSYM(__crc_\name) + .long KSYM(__crc_\name) - . .weak KSYM(__crc_\name) .previous #endif diff --git a/include/linux/export.h b/include/linux/export.h index 2a0f61fbc731..efe0ce1c363a 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -44,11 +44,10 @@ extern struct module __this_module; /* Mark the CRC weak since genk
[PATCH 00/11] PowerPC-KVM: Fine-tuning for some function implementations
From: Markus Elfring Date: Fri, 20 Jan 2017 19:07:21 +0100 Some update suggestions were taken into account from static source code analysis. Markus Elfring (11): Move assignments for the variable "err" in kvm_htab_write() Improve a size determination in kvmppc_alloc_hpt() Move error code assignments in two functions Use common error handling code in kvmppc_clr_passthru_irq() Adjust nine checks for null pointers Use kcalloc() in kvmppc_alloc_host_rm_ops() Improve size determinations in five functions Use seq_puts() in xics_debug_show() Improve a size determination in two functions Use kcalloc() in e500_mmu_host_init() Return directly after a failed copy_from_user() in two functions arch/powerpc/kvm/book3s_64_mmu_hv.c | 26 +++-- arch/powerpc/kvm/book3s_hv.c| 73 +++-- arch/powerpc/kvm/book3s_xics.c | 7 ++-- arch/powerpc/kvm/e500_mmu_host.c| 5 +-- arch/powerpc/kvm/powerpc.c | 48 ++-- 5 files changed, 75 insertions(+), 84 deletions(-) -- 2.11.0
[PATCH 01/11] KVM: PPC: Book3S HV: Move assignments for the variable "err" in kvm_htab_write()
From: Markus Elfring Date: Thu, 19 Jan 2017 22:45:56 +0100 * A local variable was set to an error code in five cases before a concrete error situation was detected. Thus move the corresponding assignments into if branches to indicate a software failure there. This issue was detected by using the Coccinelle software. * Delete two zero assignments which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- arch/powerpc/kvm/book3s_64_mmu_hv.c | 24 +--- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c index b795dd1ac2ef..dc34729e4ad0 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c @@ -1399,22 +1399,23 @@ static ssize_t kvm_htab_write(struct file *file, const char __user *buf, err = 0; for (nb = 0; nb + sizeof(hdr) <= count; ) { - err = -EFAULT; - if (__copy_from_user(&hdr, buf, sizeof(hdr))) + if (__copy_from_user(&hdr, buf, sizeof(hdr))) { + err = -EFAULT; break; + } - err = 0; if (nb + hdr.n_valid * HPTE_SIZE > count) break; nb += sizeof(hdr); buf += sizeof(hdr); - err = -EINVAL; i = hdr.index; if (i >= kvm->arch.hpt_npte || - i + hdr.n_valid + hdr.n_invalid > kvm->arch.hpt_npte) + i + hdr.n_valid + hdr.n_invalid > kvm->arch.hpt_npte) { + err = -EINVAL; break; + } hptp = (__be64 *)(kvm->arch.hpt_virt + (i * HPTE_SIZE)); lbuf = (unsigned long __user *)buf; @@ -1422,26 +1423,28 @@ static ssize_t kvm_htab_write(struct file *file, const char __user *buf, __be64 hpte_v; __be64 hpte_r; - err = -EFAULT; if (__get_user(hpte_v, lbuf) || - __get_user(hpte_r, lbuf + 1)) + __get_user(hpte_r, lbuf + 1)) { + err = -EFAULT; goto out; + } v = be64_to_cpu(hpte_v); r = be64_to_cpu(hpte_r); - err = -EINVAL; - if (!(v & HPTE_V_VALID)) + if (!(v & HPTE_V_VALID)) { + err = -EINVAL; goto out; + } lbuf += 2; nb += HPTE_SIZE; if (be64_to_cpu(hptp[0]) & (HPTE_V_VALID | HPTE_V_ABSENT)) kvmppc_do_h_remove(kvm, 0, i, 0, tmp); - err = -EIO; ret = kvmppc_virtmode_do_h_enter(kvm, H_EXACT, i, v, r, tmp); if (ret != H_SUCCESS) { pr_err("kvm_htab_write ret %ld i=%ld v=%lx " "r=%lx\n", ret, i, v, r); + err = -EIO; goto out; } if (!hpte_setup && is_vrma_hpte(v)) { @@ -1465,7 +1468,6 @@ static ssize_t kvm_htab_write(struct file *file, const char __user *buf, ++i; hptp += 2; } - err = 0; } out: -- 2.11.0
[PATCH 02/11] KVM: PPC: Book3S HV: Improve a size determination in kvmppc_alloc_hpt()
From: Markus Elfring Date: Fri, 20 Jan 2017 10:00:13 +0100 Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- arch/powerpc/kvm/book3s_64_mmu_hv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c index dc34729e4ad0..4655f27e0518 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c @@ -91,7 +91,7 @@ long kvmppc_alloc_hpt(struct kvm *kvm, u32 *htab_orderp) atomic64_set(&kvm->arch.mmio_update, 0); /* Allocate reverse map array */ - rev = vmalloc(sizeof(struct revmap_entry) * kvm->arch.hpt_npte); + rev = vmalloc(sizeof(*rev) * kvm->arch.hpt_npte); if (!rev) { pr_err("kvmppc_alloc_hpt: Couldn't alloc reverse map array\n"); goto out_freehpt; -- 2.11.0
[PATCH 03/11] KVM: PPC: Book3S HV: Move error code assignments in two functions
From: Markus Elfring Date: Fri, 20 Jan 2017 10:30:26 +0100 A local variable was set to an error code in a few cases before a concrete error situation was detected. Thus move the corresponding assignments into if branches to indicate a software failure there. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- arch/powerpc/kvm/book3s_hv.c | 25 +++-- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 8dcbe37a4dac..a93e1c4445da 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -2967,15 +2967,17 @@ static int kvm_vm_ioctl_get_dirty_log_hv(struct kvm *kvm, mutex_lock(&kvm->slots_lock); - r = -EINVAL; - if (log->slot >= KVM_USER_MEM_SLOTS) + if (log->slot >= KVM_USER_MEM_SLOTS) { + r = -EINVAL; goto out; + } slots = kvm_memslots(kvm); memslot = id_to_memslot(slots, log->slot); - r = -ENOENT; - if (!memslot->dirty_bitmap) + if (!memslot->dirty_bitmap) { + r = -ENOENT; goto out; + } n = kvm_dirty_bitmap_bytes(memslot); memset(memslot->dirty_bitmap, 0, n); @@ -2984,9 +2986,10 @@ static int kvm_vm_ioctl_get_dirty_log_hv(struct kvm *kvm, if (r) goto out; - r = -EFAULT; - if (copy_to_user(log->dirty_bitmap, memslot->dirty_bitmap, n)) + if (copy_to_user(log->dirty_bitmap, memslot->dirty_bitmap, n)) { + r = -EFAULT; goto out; + } r = 0; out: @@ -3127,9 +3130,10 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu) memslot = gfn_to_memslot(kvm, 0); /* We must have some memory at 0 by now */ - err = -EINVAL; - if (!memslot || (memslot->flags & KVM_MEMSLOT_INVALID)) + if (!memslot || (memslot->flags & KVM_MEMSLOT_INVALID)) { + err = -EINVAL; goto out_srcu; + } /* Look up the VMA for the start of this memory slot */ hva = memslot->userspace_addr; @@ -3144,10 +3148,11 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu) up_read(¤t->mm->mmap_sem); /* We can handle 4k, 64k or 16M pages in the VRMA */ - err = -EINVAL; if (!(psize == 0x1000 || psize == 0x1 || - psize == 0x100)) + psize == 0x100)) { + err = -EINVAL; goto out_srcu; + } senc = slb_pgsize_encoding(psize); kvm->arch.vrma_slb_v = senc | SLB_VSID_B_1T | -- 2.11.0
[PATCH 04/11] KVM: PPC: Book3S HV: Use common error handling code in kvmppc_clr_passthru_irq()
From: Markus Elfring Date: Fri, 20 Jan 2017 11:00:08 +0100 Add a jump target so that a bit of exception handling can be better reused at the end of this function. Signed-off-by: Markus Elfring --- arch/powerpc/kvm/book3s_hv.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index a93e1c4445da..cfc7699d05df 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -3509,11 +3509,9 @@ static int kvmppc_clr_passthru_irq(struct kvm *kvm, int host_irq, int guest_gsi) return -EIO; mutex_lock(&kvm->lock); + if (!kvm->arch.pimap) + goto unlock; - if (kvm->arch.pimap == NULL) { - mutex_unlock(&kvm->lock); - return 0; - } pimap = kvm->arch.pimap; for (i = 0; i < pimap->n_mapped; i++) { @@ -3535,7 +3533,7 @@ static int kvmppc_clr_passthru_irq(struct kvm *kvm, int host_irq, int guest_gsi) * We don't free this structure even when the count goes to * zero. The structure is freed when we destroy the VM. */ - +unlock: mutex_unlock(&kvm->lock); return 0; } -- 2.11.0
[PATCH 05/11] KVM: PPC: Book3S HV: Adjust nine checks for null pointers
From: Markus Elfring Date: Fri, 20 Jan 2017 11:25:48 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script "checkpatch.pl" pointed information out like the following. Comparison to NULL could be written … Thus fix affected source code places. Signed-off-by: Markus Elfring --- arch/powerpc/kvm/book3s_hv.c | 19 +-- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index cfc7699d05df..3122998f6a32 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -458,7 +458,7 @@ static unsigned long do_h_register_vpa(struct kvm_vcpu *vcpu, /* convert logical addr to kernel addr and read length */ va = kvmppc_pin_guest_page(kvm, vpa, &nb); - if (va == NULL) + if (!va) return H_PARAMETER; if (subfunc == H_VPA_REG_VPA) len = be16_to_cpu(((struct reg_vpa *)va)->length.hword); @@ -1591,8 +1591,7 @@ static struct kvmppc_vcore *kvmppc_vcore_create(struct kvm *kvm, int core) struct kvmppc_vcore *vcore; vcore = kzalloc(sizeof(struct kvmppc_vcore), GFP_KERNEL); - - if (vcore == NULL) + if (!vcore) return NULL; spin_lock_init(&vcore->lock); @@ -2221,7 +2220,7 @@ static void collect_piggybacks(struct core_info *cip, int target_threads) prepare_threads(pvc); if (!pvc->n_runnable) { list_del_init(&pvc->preempt_list); - if (pvc->runner == NULL) { + if (!pvc->runner) { pvc->vcore_state = VCORE_INACTIVE; kvmppc_core_end_stolen(pvc); } @@ -2287,7 +2286,7 @@ static void post_guest_process(struct kvmppc_vcore *vc, bool is_master) } else { vc->vcore_state = VCORE_INACTIVE; } - if (vc->n_runnable > 0 && vc->runner == NULL) { + if (vc->n_runnable > 0 && !vc->runner) { /* make sure there's a candidate runner awake */ i = -1; vcpu = next_runnable_thread(vc, &i); @@ -2786,7 +2785,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) while (vcpu->arch.state == KVMPPC_VCPU_RUNNABLE && !signal_pending(current)) { - if (vc->vcore_state == VCORE_PREEMPT && vc->runner == NULL) + if (vc->vcore_state == VCORE_PREEMPT && !vc->runner) kvmppc_vcore_end_preempt(vc); if (vc->vcore_state != VCORE_INACTIVE) { @@ -2833,7 +2832,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) vc->vcore_state == VCORE_PIGGYBACK)) kvmppc_wait_for_exec(vc, vcpu, TASK_UNINTERRUPTIBLE); - if (vc->vcore_state == VCORE_PREEMPT && vc->runner == NULL) + if (vc->vcore_state == VCORE_PREEMPT && !vc->runner) kvmppc_vcore_end_preempt(vc); if (vcpu->arch.state == KVMPPC_VCPU_RUNNABLE) { @@ -3203,7 +3202,7 @@ void kvmppc_alloc_host_rm_ops(void) int size; /* Not the first time here ? */ - if (kvmppc_host_rm_ops_hv != NULL) + if (kvmppc_host_rm_ops_hv) return; ops = kzalloc(sizeof(struct kvmppc_host_rm_ops), GFP_KERNEL); @@ -3430,10 +3429,10 @@ static int kvmppc_set_passthru_irq(struct kvm *kvm, int host_irq, int guest_gsi) mutex_lock(&kvm->lock); pimap = kvm->arch.pimap; - if (pimap == NULL) { + if (!pimap) { /* First call, allocate structure to hold IRQ map */ pimap = kvmppc_alloc_pimap(); - if (pimap == NULL) { + if (!pimap) { mutex_unlock(&kvm->lock); return -ENOMEM; } -- 2.11.0
[PATCH 06/11] KVM: PPC: Book3S HV: Use kcalloc() in kvmppc_alloc_host_rm_ops()
From: Markus Elfring Date: Fri, 20 Jan 2017 16:20:43 +0100 * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. * Delete the local variable "size" which became unnecessary with this refactoring. * Replace the specification of a data structure by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- arch/powerpc/kvm/book3s_hv.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 3122998f6a32..596201b3f22e 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -3199,7 +3199,6 @@ void kvmppc_alloc_host_rm_ops(void) struct kvmppc_host_rm_ops *ops; unsigned long l_ops; int cpu, core; - int size; /* Not the first time here ? */ if (kvmppc_host_rm_ops_hv) @@ -3209,9 +3208,9 @@ void kvmppc_alloc_host_rm_ops(void) if (!ops) return; - size = cpu_nr_cores() * sizeof(struct kvmppc_host_rm_core); - ops->rm_core = kzalloc(size, GFP_KERNEL); - + ops->rm_core = kcalloc(cpu_nr_cores(), + sizeof(*ops->rm_core), + GFP_KERNEL); if (!ops->rm_core) { kfree(ops); return; -- 2.11.0
[PATCH 07/11] KVM: PPC: Book3S HV: Improve size determinations in five functions
From: Markus Elfring Date: Fri, 20 Jan 2017 16:23:30 +0100 Replace the specification of data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- arch/powerpc/kvm/book3s_hv.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 596201b3f22e..9b7a5a8c9e4b 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -655,7 +655,7 @@ static void kvmppc_create_dtl_entry(struct kvm_vcpu *vcpu, spin_unlock_irq(&vcpu->arch.tbacct_lock); if (!dt || !vpa) return; - memset(dt, 0, sizeof(struct dtl_entry)); + memset(dt, 0, sizeof(*dt)); dt->dispatch_reason = 7; dt->processor_id = cpu_to_be16(vc->pcpu + vcpu->arch.ptid); dt->timebase = cpu_to_be64(now + vc->tb_offset); @@ -1073,7 +1073,7 @@ static int kvm_arch_vcpu_ioctl_get_sregs_hv(struct kvm_vcpu *vcpu, { int i; - memset(sregs, 0, sizeof(struct kvm_sregs)); + memset(sregs, 0, sizeof(*sregs)); sregs->pvr = vcpu->arch.pvr; for (i = 0; i < vcpu->arch.slb_max; i++) { sregs->u.s.ppc64.slb[i].slbe = vcpu->arch.slb[i].orige; @@ -1590,7 +1590,7 @@ static struct kvmppc_vcore *kvmppc_vcore_create(struct kvm *kvm, int core) { struct kvmppc_vcore *vcore; - vcore = kzalloc(sizeof(struct kvmppc_vcore), GFP_KERNEL); + vcore = kzalloc(sizeof(*vcore), GFP_KERNEL); if (!vcore) return NULL; @@ -3204,7 +3204,7 @@ void kvmppc_alloc_host_rm_ops(void) if (kvmppc_host_rm_ops_hv) return; - ops = kzalloc(sizeof(struct kvmppc_host_rm_ops), GFP_KERNEL); + ops = kzalloc(sizeof(*ops), GFP_KERNEL); if (!ops) return; @@ -3713,13 +3713,13 @@ static int kvm_init_subcore_bitmap(void) continue; sibling_subcore_state = - kmalloc_node(sizeof(struct sibling_subcore_state), - GFP_KERNEL, node); + kmalloc_node(sizeof(*sibling_subcore_state), GFP_KERNEL, +node); if (!sibling_subcore_state) return -ENOMEM; memset(sibling_subcore_state, 0, - sizeof(struct sibling_subcore_state)); + sizeof(*sibling_subcore_state)); for (j = 0; j < threads_per_core; j++) { int cpu = first_cpu + j; -- 2.11.0
[PATCH 08/11] KVM: PPC: Book3S: Use seq_puts() in xics_debug_show()
From: Markus Elfring Date: Fri, 20 Jan 2017 16:26:51 +0100 A string which did not contain data format specifications should be put into a sequence. Thus use the corresponding function "seq_puts". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- arch/powerpc/kvm/book3s_xics.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/book3s_xics.c b/arch/powerpc/kvm/book3s_xics.c index 3bdc639157c1..3740f9efcf06 100644 --- a/arch/powerpc/kvm/book3s_xics.c +++ b/arch/powerpc/kvm/book3s_xics.c @@ -934,8 +934,7 @@ static int xics_debug_show(struct seq_file *m, void *private) t_reject = 0; xics_debugfs_irqmap(m, kvm->arch.pimap); - - seq_printf(m, "=\nICP state\n=\n"); + seq_puts(m, "=\nICP state\n=\n"); kvm_for_each_vcpu(i, vcpu, kvm) { struct kvmppc_icp *icp = vcpu->arch.icp; -- 2.11.0
Re: [PATCH 36/37] ARM: DRA7: clockdomain: Change the CLKTRCTRL of CM_PCIE_CLKSTCTRL to SW_WKUP
* Kishon Vijay Abraham I [170115 22:06]: > Hi Tony, > > On Friday 13 January 2017 10:45 PM, Tony Lindgren wrote: > > * Kishon Vijay Abraham I [170112 02:35]: > >> The PCIe programming sequence in TRM suggests CLKSTCTRL of PCIe should > >> be set to SW_WKUP. There are no issues when CLKSTCTRL is set to HW_AUTO > >> in RC mode. However in EP mode, the host system is not able to access the > >> MEMSPACE and setting the CLKSTCTRL to SW_WKUP fixes it. > > > > I guess ideally in the long run we would set this dynamically based on > > the selected mode, right? > > The programming sequence mentioned in the TRM w.r.t clock programming is same > for both host mode or device mode. Though we never faced any issues in host > mode when HW_AUTO is set, it's better to follow TRM recommended settings IMHO. OK best to merge this with the whole series: Acked-by: Tony Lindgren
[PATCH 09/11] KVM: PPC: Book3S: Improve a size determination in two functions
From: Markus Elfring Date: Fri, 20 Jan 2017 16:28:43 +0100 Replace the specification of data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- arch/powerpc/kvm/book3s_xics.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/book3s_xics.c b/arch/powerpc/kvm/book3s_xics.c index 3740f9efcf06..d45c1b59b70a 100644 --- a/arch/powerpc/kvm/book3s_xics.c +++ b/arch/powerpc/kvm/book3s_xics.c @@ -1032,7 +1032,7 @@ static struct kvmppc_ics *kvmppc_xics_create_ics(struct kvm *kvm, goto out; /* Create the ICS */ - ics = kzalloc(sizeof(struct kvmppc_ics), GFP_KERNEL); + ics = kzalloc(*ics), GFP_KERNEL); if (!ics) goto out; @@ -1064,7 +1064,7 @@ int kvmppc_xics_create_icp(struct kvm_vcpu *vcpu, unsigned long server_num) if (kvmppc_xics_find_server(vcpu->kvm, server_num)) return -EEXIST; - icp = kzalloc(sizeof(struct kvmppc_icp), GFP_KERNEL); + icp = kzalloc(sizeof(*icp), GFP_KERNEL); if (!icp) return -ENOMEM; -- 2.11.0
[PATCH 10/11] KVM: PPC: e500: Use kcalloc() in e500_mmu_host_init()
From: Markus Elfring Date: Fri, 20 Jan 2017 16:30:18 +0100 * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. * Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- arch/powerpc/kvm/e500_mmu_host.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c index b0333cc737dd..a1af2f445988 100644 --- a/arch/powerpc/kvm/e500_mmu_host.c +++ b/arch/powerpc/kvm/e500_mmu_host.c @@ -797,9 +797,8 @@ int e500_mmu_host_init(struct kvmppc_vcpu_e500 *vcpu_e500) host_tlb_params[0].sets = host_tlb_params[0].entries / host_tlb_params[0].ways; host_tlb_params[1].sets = 1; - - vcpu_e500->h2g_tlb1_rmap = kzalloc(sizeof(unsigned int) * - host_tlb_params[1].entries, + vcpu_e500->h2g_tlb1_rmap = kcalloc(host_tlb_params[1].entries, + sizeof(*vcpu_e500->h2g_tlb1_rmap), GFP_KERNEL); if (!vcpu_e500->h2g_tlb1_rmap) return -EINVAL; -- 2.11.0
Re: [PATCH 37/37] ARM: dts: DRA7: Add pcie1 dt node for EP mode
* Kishon Vijay Abraham I [170112 02:34]: > Add pcie1 dt node in order for the controller to operate in > endpoint mode. However since none of the dra7 based boards have > slots configured to operate in endpoint mode, keep EP mode > disabled. Can this be merged separately later on without breaking anything? Regards, Tony
[PATCH 11/11] KVM: PPC: Return directly after a failed copy_from_user() in two functions
From: Markus Elfring Date: Fri, 20 Jan 2017 18:00:35 +0100 * Return directly after a call of the function "copy_from_user" (or two other checks) failed in a case block. This issue was detected by using the Coccinelle software. * Delete the jump label "out" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- arch/powerpc/kvm/powerpc.c | 48 ++ 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index efd1183a6b16..7083a680f5fb 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -1256,19 +1256,19 @@ long kvm_arch_vcpu_ioctl(struct file *filp, switch (ioctl) { case KVM_INTERRUPT: { struct kvm_interrupt irq; - r = -EFAULT; + if (copy_from_user(&irq, argp, sizeof(irq))) - goto out; + return -EFAULT; r = kvm_vcpu_ioctl_interrupt(vcpu, &irq); - goto out; + break; } case KVM_ENABLE_CAP: { struct kvm_enable_cap cap; - r = -EFAULT; + if (copy_from_user(&cap, argp, sizeof(cap))) - goto out; + return -EFAULT; r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap); break; } @@ -1277,9 +1277,9 @@ long kvm_arch_vcpu_ioctl(struct file *filp, case KVM_GET_ONE_REG: { struct kvm_one_reg reg; - r = -EFAULT; + if (copy_from_user(®, argp, sizeof(reg))) - goto out; + return -EFAULT; if (ioctl == KVM_SET_ONE_REG) r = kvm_vcpu_ioctl_set_one_reg(vcpu, ®); else @@ -1290,9 +1290,9 @@ long kvm_arch_vcpu_ioctl(struct file *filp, #if defined(CONFIG_KVM_E500V2) || defined(CONFIG_KVM_E500MC) case KVM_DIRTY_TLB: { struct kvm_dirty_tlb dirty; - r = -EFAULT; + if (copy_from_user(&dirty, argp, sizeof(dirty))) - goto out; + return -EFAULT; r = kvm_vcpu_ioctl_dirty_tlb(vcpu, &dirty); break; } @@ -1300,8 +1300,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp, default: r = -EINVAL; } - -out: return r; } @@ -1405,19 +1403,16 @@ long kvm_arch_vm_ioctl(struct file *filp, struct kvm_ppc_pvinfo pvinfo; memset(&pvinfo, 0, sizeof(pvinfo)); r = kvm_vm_ioctl_get_pvinfo(&pvinfo); - if (copy_to_user(argp, &pvinfo, sizeof(pvinfo))) { - r = -EFAULT; - goto out; - } - + if (copy_to_user(argp, &pvinfo, sizeof(pvinfo))) + return -EFAULT; break; } case KVM_ENABLE_CAP: { struct kvm_enable_cap cap; - r = -EFAULT; + if (copy_from_user(&cap, argp, sizeof(cap))) - goto out; + return -EFAULT; r = kvm_vm_ioctl_enable_cap(kvm, &cap); break; } @@ -1425,23 +1420,19 @@ long kvm_arch_vm_ioctl(struct file *filp, case KVM_CREATE_SPAPR_TCE_64: { struct kvm_create_spapr_tce_64 create_tce_64; - r = -EFAULT; if (copy_from_user(&create_tce_64, argp, sizeof(create_tce_64))) - goto out; - if (create_tce_64.flags) { - r = -EINVAL; - goto out; - } + return -EFAULT; + if (create_tce_64.flags) + return -EINVAL; r = kvm_vm_ioctl_create_spapr_tce(kvm, &create_tce_64); - goto out; + break; } case KVM_CREATE_SPAPR_TCE: { struct kvm_create_spapr_tce create_tce; struct kvm_create_spapr_tce_64 create_tce_64; - r = -EFAULT; if (copy_from_user(&create_tce, argp, sizeof(create_tce))) - goto out; + return -EFAULT; create_tce_64.liobn = create_tce.liobn; create_tce_64.page_shift = IOMMU_PAGE_SHIFT_4K; @@ -1450,7 +1441,7 @@ long kvm_arch_vm_ioctl(struct file *filp, IOMMU_PAGE_SHIFT_4K; create_tce_64.flags = 0; r = kvm_vm_ioctl_create_spapr_tce(kvm, &create_tce_64); - goto out; + break; } case KVM_PPC_GET_SMMU_INFO: { struct kvm_ppc_smmu_info info; @@ -1477,7 +1468,6 @@ long kvm_arch_vm_ioctl(struct file *filp, r = -ENOTTY; #endif } -
Re: [PATCH v8 2/3] PCI: Make sure the driver could get correct BAR size from pci_resource_len()
Hi Yongji, [auto build test WARNING on pci/next] [also build test WARNING on v4.10-rc4 next-20170120] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Yongji-Xie/PCI-Ignore-requested-alignment-for-IOV-BARs/20170121-031322 base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next config: i386-defconfig (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=i386 All warnings (new ones prefixed by >>): In file included from drivers/ata/ata_piix.c:88:0: drivers/ata/ata_piix.c: In function 'piix_init_sidpr': >> include/linux/pci.h:1648:44: warning: comparison between 'enum ' >> and 'enum ' [-Wenum-compare] #define pci_resource_end(dev, bar) (((bar) > PCI_ROM_RESOURCE) ? \ ^ >> include/linux/pci.h:1655:4: note: in expansion of macro 'pci_resource_end' pci_resource_end((dev), (bar)) == \ ^~~~ >> drivers/ata/ata_piix.c:1471:6: note: in expansion of macro 'pci_resource_len' pci_resource_len(pdev, PIIX_SIDPR_BAR) != PIIX_SIDPR_LEN) ^~~~ >> include/linux/pci.h:1648:44: warning: comparison between 'enum ' >> and 'enum ' [-Wenum-compare] #define pci_resource_end(dev, bar) (((bar) > PCI_ROM_RESOURCE) ? \ ^ include/linux/pci.h:1658:4: note: in expansion of macro 'pci_resource_end' (pci_resource_end((dev), (bar)) - \ ^~~~ >> drivers/ata/ata_piix.c:1471:6: note: in expansion of macro 'pci_resource_len' pci_resource_len(pdev, PIIX_SIDPR_BAR) != PIIX_SIDPR_LEN) ^~~~ vim +1648 include/linux/pci.h 1642 #define pci_root_bus_fwnode(bus)NULL 1643 #endif 1644 1645 /* these helpers provide future and backwards compatibility 1646 * for accessing popular PCI BAR info */ 1647 #define pci_resource_start(dev, bar)((dev)->resource[(bar)].start) > 1648 #define pci_resource_end(dev, bar) (((bar) > PCI_ROM_RESOURCE) ? > \ 1649 (dev)->resource[(bar)].end : \ 1650 ((dev)->resource[(bar)].end - \ 1651 (dev)->res_addsize[(bar)])) 1652 #define pci_resource_flags(dev, bar)((dev)->resource[(bar)].flags) 1653 #define pci_resource_len(dev,bar) \ 1654 ((pci_resource_start((dev), (bar)) == 0 && \ > 1655pci_resource_end((dev), (bar)) == \ 1656pci_resource_start((dev), (bar))) ? 0 : \ 1657 \ 1658 (pci_resource_end((dev), (bar)) - \ --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH] powerpc/pasemi/nemo: Fix low memory values for boot.
On Fri, Jan 20, 2017 at 05:46:13PM +, Darren Stevens wrote: > --- a/arch/powerpc/kernel/head_64.S > +++ b/arch/powerpc/kernel/head_64.S > @@ -79,6 +79,13 @@ _GLOBAL(__start) > /* NOP this out unconditionally */ > BEGIN_FTR_SECTION > FIXUP_ENDIAN > +#ifdef CONFIG_PPC_PASEMI_NEMO > + /* > +* Zero address 8 so Nemo will boot > +*/ > + li r0,0 > + std 0,8(0) > +#endif std r0,8(0) for clarity? Segher
Re: [PATCH v8 2/3] PCI: Make sure the driver could get correct BAR size from pci_resource_len()
Hi Yongji, [auto build test WARNING on pci/next] [also build test WARNING on v4.10-rc4 next-20170120] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Yongji-Xie/PCI-Ignore-requested-alignment-for-IOV-BARs/20170121-031322 base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next config: x86_64-kexec (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All warnings (new ones prefixed by >>): In file included from drivers/ata/sata_sis.c:35:0: drivers/ata/sata_sis.c: In function 'sis_init_one': include/linux/pci.h:1648:44: warning: comparison between 'enum ' and 'enum ' [-Wenum-compare] #define pci_resource_end(dev, bar) (((bar) > PCI_ROM_RESOURCE) ? \ ^ include/linux/pci.h:1655:4: note: in expansion of macro 'pci_resource_end' pci_resource_end((dev), (bar)) == \ ^~~~ >> drivers/ata/sata_sis.c:223:8: note: in expansion of macro 'pci_resource_len' (pci_resource_len(pdev, SIS_SCR_PCI_BAR) < 128))) { ^~~~ include/linux/pci.h:1648:44: warning: comparison between 'enum ' and 'enum ' [-Wenum-compare] #define pci_resource_end(dev, bar) (((bar) > PCI_ROM_RESOURCE) ? \ ^ include/linux/pci.h:1658:4: note: in expansion of macro 'pci_resource_end' (pci_resource_end((dev), (bar)) - \ ^~~~ >> drivers/ata/sata_sis.c:223:8: note: in expansion of macro 'pci_resource_len' (pci_resource_len(pdev, SIS_SCR_PCI_BAR) < 128))) { ^~~~ vim +/pci_resource_len +223 drivers/ata/sata_sis.c af36d7f0 drivers/scsi/sata_sis.c Jeff Garzik 2005-08-28 29 * Hardware documentation available under NDA. ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 30 * ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 31 */ ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 32 ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 33 #include ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 34 #include ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 @35 #include ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 36 #include ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 37 #include ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 38 #include a9524a76 drivers/scsi/sata_sis.c Jeff Garzik 2005-10-30 39 #include ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 40 #include ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 41 #include 4bb64fb9 drivers/ata/sata_sis.c Alan Cox 2007-02-16 42 #include "sis.h" ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 43 ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 44 #define DRV_NAME"sata_sis" 2a3103ce drivers/ata/sata_sis.c Jeff Garzik 2007-08-31 45 #define DRV_VERSION "1.0" ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 46 ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 47 enum { ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 48 sis_180 = 0, ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 49 SIS_SCR_PCI_BAR = 5, ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 50 ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 51 /* PCI configuration registers */ ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 52 SIS_GENCTL = 0x54, /* IDE General Control register */ ^1da177e drivers/scsi/sata_sis.c Linus Torvalds2005-04-16 53 SIS_SCR_BASE= 0xc0, /* sata0 phy SCR registers */ f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 54 SIS180_SATA1_OFS= 0x10, /* offset from sata0->sata1 phy regs */ f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 55 SIS182_SATA1_OFS= 0x20, /* offset from sata0->sata1 phy regs */ f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 56 SIS_PMR = 0x90, /* port mapping register */ f2c853bc drivers/scsi/sata_sis.c Arnaud Patard 2005-09-07 57 SIS_PMR_COMBINED= 0x30, ^1da177e drivers/scsi/sata_s
Re: powerpc/nvram: Move an assignment for the variable "ret" in dev_nvram_write()
On 01/19/2017 11:08 PM, SF Markus Elfring wrote: >> I think you really could have squashed patches 1-3 into a single patch >> that returns directly after any failure. > > Thanks for your constructive feedback. > > I have got software development concerns around such patch squashing. > > >> At this point you might as well remove that label and move the kfree(tmp) >> call up >> and return directly after the failure and at the nvram_write() call site >> doing away completely with the "ret" variable. > > Your idea might look nice at first glance. But I would interpret the previous > implementation of the discussed function in the way that the memory which was > dynamically allocated here should always (not only in the failure case) be > released > before returning here. You are correct. I did muck that part up. However, I do still believe it is cleaner to squash your three patches together. There is no functional change here and it is clearer in a single patch that you are modifying the function to return directly in the simple error cases. -Tyrel > > Would you really like to change the life time for this “temporary” data item? > > Regards, > Markus >
[PATCH v3 03/37] treewide: Consolidate set_dma_ops() implementations
Now that all set_dma_ops() implementations are identical (ignoring BUG_ON() statements), remove the architecture specific definitions and add a definition in . Signed-off-by: Bart Van Assche Cc: Benjamin Herrenschmidt Cc: Chris Metcalf Cc: David Woodhouse Cc: linux-a...@vger.kernel.org Cc: linux-arm-ker...@lists.infradead.org Cc: linux-ker...@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: Paul Mackerras Cc: Russell King --- arch/arm/include/asm/dma-mapping.h | 6 -- arch/powerpc/include/asm/dma-mapping.h | 5 - arch/tile/include/asm/dma-mapping.h| 5 - include/linux/dma-mapping.h| 5 + 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index 312f4d0564d6..c7432d647e53 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h @@ -31,12 +31,6 @@ static inline const struct dma_map_ops *get_dma_ops(struct device *dev) return __generic_dma_ops(dev); } -static inline void set_dma_ops(struct device *dev, const struct dma_map_ops *ops) -{ - BUG_ON(!dev); - dev->dma_ops = ops; -} - #define HAVE_ARCH_DMA_SUPPORTED 1 extern int dma_supported(struct device *dev, u64 mask); diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index 59fbd4abcbf8..8275603ba4d5 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -91,11 +91,6 @@ static inline const struct dma_map_ops *get_dma_ops(struct device *dev) return dev->dma_ops; } -static inline void set_dma_ops(struct device *dev, const struct dma_map_ops *ops) -{ - dev->dma_ops = ops; -} - /* * get_dma_offset() * diff --git a/arch/tile/include/asm/dma-mapping.h b/arch/tile/include/asm/dma-mapping.h index c0620697eaad..2562995a6ac9 100644 --- a/arch/tile/include/asm/dma-mapping.h +++ b/arch/tile/include/asm/dma-mapping.h @@ -59,11 +59,6 @@ static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) static inline void dma_mark_clean(void *addr, size_t size) {} -static inline void set_dma_ops(struct device *dev, const struct dma_map_ops *ops) -{ - dev->dma_ops = ops; -} - static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) { if (!dev->dma_mask) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index f1da68b82c63..e97f23e8b2d9 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -164,6 +164,11 @@ int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma, #ifdef CONFIG_HAS_DMA #include +static inline void set_dma_ops(struct device *dev, + const struct dma_map_ops *dma_ops) +{ + dev->dma_ops = dma_ops; +} #else /* * Define the dma api to allow compilation but not linking of -- 2.11.0
BUILD_BUG_ON(!__builtin_constant_p(feature)) breaks bcc trace tool
Hi, We added: BUILD_BUG_ON(!__builtin_constant_p(feature)) to cpu_has_feature() and mmu_has_feature() in order to catch usage issues (such as cpu_has_feature(cpu_has_feature(X)). Unfortunately LLVM isn't smart enough to resolve this, and it errors out. I work around it in my clang/LLVM builds of the kernel, but I have just discovered that it causes a lot of issues for the bcc (eBPF) trace tool (which uses LLVM). How should we work around this? Wrap the checks in !clang perhaps? Anton
Re: [PATCH 09/11] KVM: PPC: Book3S: Improve a size determination in two functions
Hi Markus, [auto build test ERROR on next-20170119] [also build test ERROR on v4.10-rc4] [cannot apply to v4.9-rc8 v4.9-rc7 v4.9-rc6] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/SF-Markus-Elfring/PowerPC-KVM-Fine-tuning-for-some-function-implementations/20170121-121537 config: powerpc-allmodconfig (attached as .config) compiler: powerpc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=powerpc All errors (new ones prefixed by >>): arch/powerpc/kvm/book3s_xics.c: In function 'kvmppc_xics_create_ics': >> arch/powerpc/kvm/book3s_xics.c:1035:16: error: incompatible type for >> argument 1 of 'kzalloc' ics = kzalloc(*ics), GFP_KERNEL); ^ In file included from include/linux/kvm_host.h:21:0, from arch/powerpc/kvm/book3s_xics.c:11: include/linux/slab.h:634:21: note: expected 'size_t {aka long unsigned int}' but argument is of type 'struct kvmppc_ics' static inline void *kzalloc(size_t size, gfp_t flags) ^~~ >> arch/powerpc/kvm/book3s_xics.c:1035:8: error: too few arguments to function >> 'kzalloc' ics = kzalloc(*ics), GFP_KERNEL); ^~~ In file included from include/linux/kvm_host.h:21:0, from arch/powerpc/kvm/book3s_xics.c:11: include/linux/slab.h:634:21: note: declared here static inline void *kzalloc(size_t size, gfp_t flags) ^~~ arch/powerpc/kvm/book3s_xics.c:1035:21: warning: left-hand operand of comma expression has no effect [-Wunused-value] ics = kzalloc(*ics), GFP_KERNEL); ^ arch/powerpc/kvm/book3s_xics.c:1035:21: warning: statement with no effect [-Wunused-value] >> arch/powerpc/kvm/book3s_xics.c:1035:33: error: expected ';' before ')' token ics = kzalloc(*ics), GFP_KERNEL); ^ >> arch/powerpc/kvm/book3s_xics.c:1035:33: error: expected statement before ')' >> token vim +/kzalloc +1035 arch/powerpc/kvm/book3s_xics.c 1029 1030 /* ICS already exists - somebody else got here first */ 1031 if (xics->ics[icsid]) 1032 goto out; 1033 1034 /* Create the ICS */ > 1035 ics = kzalloc(*ics), GFP_KERNEL); 1036 if (!ics) 1037 goto out; 1038 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH 09/11] KVM: PPC: Book3S: Improve a size determination in two functions
Hi Markus, [auto build test ERROR on next-20170119] [also build test ERROR on v4.10-rc4] [cannot apply to v4.9-rc8 v4.9-rc7 v4.9-rc6] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/SF-Markus-Elfring/PowerPC-KVM-Fine-tuning-for-some-function-implementations/20170121-121537 config: powerpc-defconfig (attached as .config) compiler: powerpc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=powerpc All errors (new ones prefixed by >>): arch/powerpc/kvm/book3s_xics.c: In function 'kvmppc_xics_create_ics': arch/powerpc/kvm/book3s_xics.c:1035:16: error: incompatible type for argument 1 of 'kzalloc' ics = kzalloc(*ics), GFP_KERNEL); ^ In file included from include/linux/kvm_host.h:21:0, from arch/powerpc/kvm/book3s_xics.c:11: include/linux/slab.h:634:21: note: expected 'size_t {aka long unsigned int}' but argument is of type 'struct kvmppc_ics' static inline void *kzalloc(size_t size, gfp_t flags) ^~~ arch/powerpc/kvm/book3s_xics.c:1035:8: error: too few arguments to function 'kzalloc' ics = kzalloc(*ics), GFP_KERNEL); ^~~ In file included from include/linux/kvm_host.h:21:0, from arch/powerpc/kvm/book3s_xics.c:11: include/linux/slab.h:634:21: note: declared here static inline void *kzalloc(size_t size, gfp_t flags) ^~~ >> arch/powerpc/kvm/book3s_xics.c:1035:21: error: left-hand operand of comma >> expression has no effect [-Werror=unused-value] ics = kzalloc(*ics), GFP_KERNEL); ^ >> arch/powerpc/kvm/book3s_xics.c:1035:21: error: statement with no effect >> [-Werror=unused-value] arch/powerpc/kvm/book3s_xics.c:1035:33: error: expected ';' before ')' token ics = kzalloc(*ics), GFP_KERNEL); ^ arch/powerpc/kvm/book3s_xics.c:1035:33: error: expected statement before ')' token cc1: all warnings being treated as errors vim +1035 arch/powerpc/kvm/book3s_xics.c 1029 1030 /* ICS already exists - somebody else got here first */ 1031 if (xics->ics[icsid]) 1032 goto out; 1033 1034 /* Create the ICS */ > 1035 ics = kzalloc(*ics), GFP_KERNEL); 1036 if (!ics) 1037 goto out; 1038 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip