From owner-svn-src-stable-11@freebsd.org Sun Oct 22 08:47:14 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D6E46E4D409; Sun, 22 Oct 2017 08:47:14 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A17558311D; Sun, 22 Oct 2017 08:47:14 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9M8lDVH048298; Sun, 22 Oct 2017 08:47:13 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9M8lDYN048292; Sun, 22 Oct 2017 08:47:13 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201710220847.v9M8lDYN048292@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 22 Oct 2017 08:47:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324855 - in stable/11/sys: amd64/amd64 amd64/include i386/i386 i386/include X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11/sys: amd64/amd64 amd64/include i386/i386 i386/include X-SVN-Commit-Revision: 324855 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Oct 2017 08:47:15 -0000 Author: kib Date: Sun Oct 22 08:47:13 2017 New Revision: 324855 URL: https://svnweb.freebsd.org/changeset/base/324855 Log: MFC r323772, r324302-r324308, r324310, r324313, r324315, r324326, r324330, r324334, r324354-r324355, r324366, r324432-r324433, r324437-r324439: Fixes and improvements for x86 LDT handling. Modified: stable/11/sys/amd64/amd64/sys_machdep.c stable/11/sys/amd64/include/proc.h stable/11/sys/i386/i386/machdep.c stable/11/sys/i386/i386/swtch.s stable/11/sys/i386/i386/sys_machdep.c stable/11/sys/i386/include/md_var.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/sys_machdep.c ============================================================================== --- stable/11/sys/amd64/amd64/sys_machdep.c Sun Oct 22 08:42:01 2017 (r324854) +++ stable/11/sys/amd64/amd64/sys_machdep.c Sun Oct 22 08:47:13 2017 (r324855) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -64,7 +65,7 @@ __FBSDID("$FreeBSD$"); #define MAX_LD 8192 -int max_ldt_segment = 1024; +int max_ldt_segment = 512; SYSCTL_INT(_machdep, OID_AUTO, max_ldt_segment, CTLFLAG_RDTUN, &max_ldt_segment, 0, "Maximum number of allowed LDT segments in the single address space"); @@ -80,11 +81,6 @@ max_ldt_segment_init(void *arg __unused) } SYSINIT(maxldt, SI_SUB_VM_CONF, SI_ORDER_ANY, max_ldt_segment_init, NULL); -#ifdef notyet -#ifdef SMP -static void set_user_ldt_rv(struct vmspace *vmsp); -#endif -#endif static void user_ldt_derefl(struct proc_ldt *pldt); #ifndef _SYS_SYSPROTO_H_ @@ -428,18 +424,14 @@ done: * Update the GDT entry pointing to the LDT to point to the LDT of the * current process. */ -void +static void set_user_ldt(struct mdproc *mdp) { - critical_enter(); *PCPU_GET(ldt) = mdp->md_ldt_sd; lldt(GSEL(GUSERLDT_SEL, SEL_KPL)); - critical_exit(); } -#ifdef notyet -#ifdef SMP static void set_user_ldt_rv(struct vmspace *vmsp) { @@ -451,8 +443,6 @@ set_user_ldt_rv(struct vmspace *vmsp) set_user_ldt(&td->td_proc->p_md); } -#endif -#endif struct proc_ldt * user_ldt_alloc(struct proc *p, int force) @@ -494,11 +484,13 @@ user_ldt_alloc(struct proc *p, int force) sizeof(struct user_segment_descriptor)); user_ldt_derefl(pldt); } + critical_enter(); ssdtosyssd(&sldt, &p->p_md.md_ldt_sd); - atomic_store_rel_ptr((volatile uintptr_t *)&mdp->md_ldt, - (uintptr_t)new_ldt); - if (p == curproc) - set_user_ldt(mdp); + atomic_thread_fence_rel(); + mdp->md_ldt = new_ldt; + critical_exit(); + smp_rendezvous(NULL, (void (*)(void *))set_user_ldt_rv, NULL, + p->p_vmspace); return (mdp->md_ldt); } @@ -516,10 +508,13 @@ user_ldt_free(struct thread *td) return; } + critical_enter(); mdp->md_ldt = NULL; + atomic_thread_fence_rel(); bzero(&mdp->md_ldt_sd, sizeof(mdp->md_ldt_sd)); if (td == curthread) lldt(GSEL(GNULL_SEL, SEL_KPL)); + critical_exit(); user_ldt_deref(pldt); } @@ -550,57 +545,57 @@ user_ldt_deref(struct proc_ldt *pldt) * the OS-specific one. */ int -amd64_get_ldt(td, uap) - struct thread *td; - struct i386_ldt_args *uap; +amd64_get_ldt(struct thread *td, struct i386_ldt_args *uap) { - int error = 0; struct proc_ldt *pldt; - int num; struct user_segment_descriptor *lp; + uint64_t *data; + u_int i, num; + int error; #ifdef DEBUG - printf("amd64_get_ldt: start=%d num=%d descs=%p\n", + printf("amd64_get_ldt: start=%u num=%u descs=%p\n", uap->start, uap->num, (void *)uap->descs); #endif - if ((pldt = td->td_proc->p_md.md_ldt) != NULL) { - lp = &((struct user_segment_descriptor *)(pldt->ldt_base)) - [uap->start]; - num = min(uap->num, max_ldt_segment); - } else - return (EINVAL); - - if ((uap->start > (unsigned int)max_ldt_segment) || - ((unsigned int)num > (unsigned int)max_ldt_segment) || - ((unsigned int)(uap->start + num) > (unsigned int)max_ldt_segment)) - return(EINVAL); - - error = copyout(lp, uap->descs, num * + pldt = td->td_proc->p_md.md_ldt; + if (pldt == NULL || uap->start >= max_ldt_segment || uap->num == 0) { + td->td_retval[0] = 0; + return (0); + } + num = min(uap->num, max_ldt_segment - uap->start); + lp = &((struct user_segment_descriptor *)(pldt->ldt_base))[uap->start]; + data = malloc(num * sizeof(struct user_segment_descriptor), M_TEMP, + M_WAITOK); + mtx_lock(&dt_lock); + for (i = 0; i < num; i++) + data[i] = ((volatile uint64_t *)lp)[i]; + mtx_unlock(&dt_lock); + error = copyout(data, uap->descs, num * sizeof(struct user_segment_descriptor)); - if (!error) + free(data, M_TEMP); + if (error == 0) td->td_retval[0] = num; - - return(error); + return (error); } int -amd64_set_ldt(td, uap, descs) - struct thread *td; - struct i386_ldt_args *uap; - struct user_segment_descriptor *descs; +amd64_set_ldt(struct thread *td, struct i386_ldt_args *uap, + struct user_segment_descriptor *descs) { - int error = 0; - unsigned int largest_ld, i; - struct mdproc *mdp = &td->td_proc->p_md; + struct mdproc *mdp; struct proc_ldt *pldt; struct user_segment_descriptor *dp; struct proc *p; + u_int largest_ld, i; + int error; #ifdef DEBUG - printf("amd64_set_ldt: start=%d num=%d descs=%p\n", + printf("amd64_set_ldt: start=%u num=%u descs=%p\n", uap->start, uap->num, (void *)uap->descs); #endif + mdp = &td->td_proc->p_md; + error = 0; set_pcb_flags(td->td_pcb, PCB_FULL_IRET); p = td->td_proc; @@ -618,10 +613,9 @@ amd64_set_ldt(td, uap, descs) largest_ld = max_ldt_segment; if (largest_ld < uap->start) return (EINVAL); - i = largest_ld - uap->start; mtx_lock(&dt_lock); - bzero(&((struct user_segment_descriptor *)(pldt->ldt_base)) - [uap->start], sizeof(struct user_segment_descriptor) * i); + for (i = uap->start; i < largest_ld; i++) + ((volatile uint64_t *)(pldt->ldt_base))[i] = 0; mtx_unlock(&dt_lock); return (0); } @@ -658,12 +652,7 @@ amd64_set_ldt(td, uap, descs) case SDT_SYSNULL4: case SDT_SYSIGT: case SDT_SYSTGT: - /* I can't think of any reason to allow a user proc - * to create a segment of these types. They are - * for OS use only. - */ return (EACCES); - /*NOTREACHED*/ /* memory segment types */ case SDT_MEMEC: /* memory execute only conforming */ @@ -689,7 +678,6 @@ amd64_set_ldt(td, uap, descs) break; default: return(EINVAL); - /*NOTREACHED*/ } /* Only user (ring-3) descriptors may be present. */ @@ -743,14 +731,18 @@ int amd64_set_ldt_data(struct thread *td, int start, int num, struct user_segment_descriptor *descs) { - struct mdproc *mdp = &td->td_proc->p_md; - struct proc_ldt *pldt = mdp->md_ldt; + struct mdproc *mdp; + struct proc_ldt *pldt; + volatile uint64_t *dst, *src; + int i; mtx_assert(&dt_lock, MA_OWNED); - /* Fill in range */ - bcopy(descs, - &((struct user_segment_descriptor *)(pldt->ldt_base))[start], - num * sizeof(struct user_segment_descriptor)); + mdp = &td->td_proc->p_md; + pldt = mdp->md_ldt; + dst = (volatile uint64_t *)(pldt->ldt_base); + src = (volatile uint64_t *)descs; + for (i = 0; i < num; i++) + dst[start + i] = src[i]; return (0); } Modified: stable/11/sys/amd64/include/proc.h ============================================================================== --- stable/11/sys/amd64/include/proc.h Sun Oct 22 08:42:01 2017 (r324854) +++ stable/11/sys/amd64/include/proc.h Sun Oct 22 08:47:13 2017 (r324855) @@ -88,7 +88,6 @@ struct syscall_args { (char *)&td; \ } while (0) -void set_user_ldt(struct mdproc *); struct proc_ldt *user_ldt_alloc(struct proc *, int); void user_ldt_free(struct thread *); void user_ldt_deref(struct proc_ldt *); Modified: stable/11/sys/i386/i386/machdep.c ============================================================================== --- stable/11/sys/i386/i386/machdep.c Sun Oct 22 08:42:01 2017 (r324854) +++ stable/11/sys/i386/i386/machdep.c Sun Oct 22 08:47:13 2017 (r324855) @@ -1146,6 +1146,15 @@ exec_setregs(struct thread *td, struct image_params *i else mtx_unlock_spin(&dt_lock); + /* + * Reset the fs and gs bases. The values from the old address + * space do not make sense for the new program. In particular, + * gsbase might be the TLS base for the old program but the new + * program has no TLS now. + */ + set_fsbase(td, 0); + set_gsbase(td, 0); + bzero((char *)regs, sizeof(struct trapframe)); regs->tf_eip = imgp->entry_addr; regs->tf_esp = stack; Modified: stable/11/sys/i386/i386/swtch.s ============================================================================== --- stable/11/sys/i386/i386/swtch.s Sun Oct 22 08:42:01 2017 (r324854) +++ stable/11/sys/i386/i386/swtch.s Sun Oct 22 08:47:13 2017 (r324855) @@ -283,6 +283,10 @@ sw1: pushl %edx /* Preserve pointer to pcb. */ addl $P_MD,%eax /* Pointer to mdproc is arg. */ pushl %eax + /* + * Holding dt_lock prevents context switches, so dt_lock cannot + * be held now and set_user_ldt() will not deadlock acquiring it. + */ call set_user_ldt addl $4,%esp popl %edx Modified: stable/11/sys/i386/i386/sys_machdep.c ============================================================================== --- stable/11/sys/i386/i386/sys_machdep.c Sun Oct 22 08:42:01 2017 (r324854) +++ stable/11/sys/i386/i386/sys_machdep.c Sun Oct 22 08:47:13 2017 (r324855) @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -68,10 +69,10 @@ __FBSDID("$FreeBSD$"); #define NULL_LDT_BASE ((caddr_t)NULL) #ifdef SMP -static void set_user_ldt_rv(struct vmspace *vmsp); +static void set_user_ldt_rv(void *arg); #endif static int i386_set_ldt_data(struct thread *, int start, int num, - union descriptor *descs); + union descriptor *descs); static int i386_ldt_grow(struct thread *td, int len); void @@ -90,6 +91,37 @@ fill_based_sd(struct segment_descriptor *sdp, uint32_t sdp->sd_gran = 1; } +/* + * Construct special descriptors for "base" selectors. Store them in + * the PCB for later use by cpu_switch(). Store them in the GDT for + * more immediate use. The GDT entries are part of the current + * context. Callers must load related segment registers to complete + * setting up the current context. + */ +void +set_fsbase(struct thread *td, uint32_t base) +{ + struct segment_descriptor sd; + + fill_based_sd(&sd, base); + critical_enter(); + td->td_pcb->pcb_fsd = sd; + PCPU_GET(fsgs_gdt)[0] = sd; + critical_exit(); +} + +void +set_gsbase(struct thread *td, uint32_t base) +{ + struct segment_descriptor sd; + + fill_based_sd(&sd, base); + critical_enter(); + td->td_pcb->pcb_gsd = sd; + PCPU_GET(fsgs_gdt)[1] = sd; + critical_exit(); +} + #ifndef _SYS_SYSPROTO_H_ struct sysarch_args { int op; @@ -110,7 +142,7 @@ sysarch(td, uap) struct i386_get_xfpustate xfpu; } kargs; uint32_t base; - struct segment_descriptor sd, *sdp; + struct segment_descriptor *sdp; AUDIT_ARG_CMD(uap->op); @@ -155,8 +187,6 @@ sysarch(td, uap) if ((error = copyin(uap->parms, &kargs.largs, sizeof(struct i386_ldt_args))) != 0) return (error); - if (kargs.largs.num > MAX_LD || kargs.largs.num <= 0) - return (EINVAL); break; case I386_GET_XFPUSTATE: if ((error = copyin(uap->parms, &kargs.xfpu, @@ -167,14 +197,15 @@ sysarch(td, uap) break; } - switch(uap->op) { + switch (uap->op) { case I386_GET_LDT: error = i386_get_ldt(td, &kargs.largs); break; case I386_SET_LDT: if (kargs.largs.descs != NULL) { - lp = (union descriptor *)malloc( - kargs.largs.num * sizeof(union descriptor), + if (kargs.largs.num > MAX_LD) + return (EINVAL); + lp = malloc(kargs.largs.num * sizeof(union descriptor), M_TEMP, M_WAITOK); error = copyin(kargs.largs.descs, lp, kargs.largs.num * sizeof(union descriptor)); @@ -206,16 +237,11 @@ sysarch(td, uap) error = copyin(uap->parms, &base, sizeof(base)); if (error == 0) { /* - * Construct a descriptor and store it in the pcb for - * the next context switch. Also store it in the gdt - * so that the load of tf_fs into %fs will activate it - * at return to userland. + * Construct the special descriptor for fsbase + * and arrange for doreti to load its selector + * soon enough. */ - fill_based_sd(&sd, base); - critical_enter(); - td->td_pcb->pcb_fsd = sd; - PCPU_GET(fsgs_gdt)[0] = sd; - critical_exit(); + set_fsbase(td, base); td->td_frame->tf_fs = GSEL(GUFS_SEL, SEL_UPL); } break; @@ -228,15 +254,11 @@ sysarch(td, uap) error = copyin(uap->parms, &base, sizeof(base)); if (error == 0) { /* - * Construct a descriptor and store it in the pcb for - * the next context switch. Also store it in the gdt - * because we have to do a load_gs() right now. + * Construct the special descriptor for gsbase. + * The selector is loaded immediately, since we + * normally only reload %gs on context switches. */ - fill_based_sd(&sd, base); - critical_enter(); - td->td_pcb->pcb_gsd = sd; - PCPU_GET(fsgs_gdt)[1] = sd; - critical_exit(); + set_gsbase(td, base); load_gs(GSEL(GUGS_SEL, SEL_UPL)); } break; @@ -385,41 +407,40 @@ done: * Update the GDT entry pointing to the LDT to point to the LDT of the * current process. Manage dt_lock holding/unholding autonomously. */ -void -set_user_ldt(struct mdproc *mdp) +static void +set_user_ldt_locked(struct mdproc *mdp) { struct proc_ldt *pldt; - int dtlocked; + int gdt_idx; - dtlocked = 0; - if (!mtx_owned(&dt_lock)) { - mtx_lock_spin(&dt_lock); - dtlocked = 1; - } + mtx_assert(&dt_lock, MA_OWNED); pldt = mdp->md_ldt; -#ifdef SMP - gdt[PCPU_GET(cpuid) * NGDT + GUSERLDT_SEL].sd = pldt->ldt_sd; -#else - gdt[GUSERLDT_SEL].sd = pldt->ldt_sd; -#endif + gdt_idx = GUSERLDT_SEL; + gdt_idx += PCPU_GET(cpuid) * NGDT; /* always 0 on UP */ + gdt[gdt_idx].sd = pldt->ldt_sd; lldt(GSEL(GUSERLDT_SEL, SEL_KPL)); PCPU_SET(currentldt, GSEL(GUSERLDT_SEL, SEL_KPL)); - if (dtlocked) - mtx_unlock_spin(&dt_lock); } +void +set_user_ldt(struct mdproc *mdp) +{ + + mtx_lock_spin(&dt_lock); + set_user_ldt_locked(mdp); + mtx_unlock_spin(&dt_lock); +} + #ifdef SMP static void -set_user_ldt_rv(struct vmspace *vmsp) +set_user_ldt_rv(void *arg) { - struct thread *td; + struct proc *p; - td = curthread; - if (vmsp != td->td_proc->p_vmspace) - return; - - set_user_ldt(&td->td_proc->p_md); + p = curproc; + if (arg == p->p_vmspace) + set_user_ldt(&p->p_md); } #endif @@ -433,8 +454,7 @@ user_ldt_alloc(struct mdproc *mdp, int len) mtx_assert(&dt_lock, MA_OWNED); mtx_unlock_spin(&dt_lock); - new_ldt = malloc(sizeof(struct proc_ldt), - M_SUBPROC, M_WAITOK); + new_ldt = malloc(sizeof(struct proc_ldt), M_SUBPROC, M_WAITOK); new_ldt->ldt_len = len = NEW_MAX_LD(len); new_ldt->ldt_base = (caddr_t)kmem_malloc(kernel_arena, @@ -464,10 +484,11 @@ user_ldt_alloc(struct mdproc *mdp, int len) void user_ldt_free(struct thread *td) { - struct mdproc *mdp = &td->td_proc->p_md; + struct mdproc *mdp; struct proc_ldt *pldt; mtx_assert(&dt_lock, MA_OWNED); + mdp = &td->td_proc->p_md; if ((pldt = mdp->md_ldt) == NULL) { mtx_unlock_spin(&dt_lock); return; @@ -503,61 +524,55 @@ user_ldt_deref(struct proc_ldt *pldt) * the OS-specific one. */ int -i386_get_ldt(td, uap) - struct thread *td; - struct i386_ldt_args *uap; +i386_get_ldt(struct thread *td, struct i386_ldt_args *uap) { - int error = 0; struct proc_ldt *pldt; - int nldt, num; - union descriptor *lp; + char *data; + u_int nldt, num; + int error; -#ifdef DEBUG - printf("i386_get_ldt: start=%d num=%d descs=%p\n", +#ifdef DEBUG + printf("i386_get_ldt: start=%u num=%u descs=%p\n", uap->start, uap->num, (void *)uap->descs); #endif + num = min(uap->num, MAX_LD); + data = malloc(num * sizeof(union descriptor), M_TEMP, M_WAITOK); mtx_lock_spin(&dt_lock); - if ((pldt = td->td_proc->p_md.md_ldt) != NULL) { - nldt = pldt->ldt_len; - lp = &((union descriptor *)(pldt->ldt_base))[uap->start]; - mtx_unlock_spin(&dt_lock); - num = min(uap->num, nldt); + pldt = td->td_proc->p_md.md_ldt; + nldt = pldt != NULL ? pldt->ldt_len : nitems(ldt); + if (uap->start >= nldt) { + num = 0; } else { - mtx_unlock_spin(&dt_lock); - nldt = sizeof(ldt)/sizeof(ldt[0]); - num = min(uap->num, nldt); - lp = &ldt[uap->start]; + num = min(num, nldt - uap->start); + bcopy(pldt != NULL ? + &((union descriptor *)(pldt->ldt_base))[uap->start] : + &ldt[uap->start], data, num * sizeof(union descriptor)); } - - if ((uap->start > (unsigned int)nldt) || - ((unsigned int)num > (unsigned int)nldt) || - ((unsigned int)(uap->start + num) > (unsigned int)nldt)) - return(EINVAL); - - error = copyout(lp, uap->descs, num * sizeof(union descriptor)); - if (!error) + mtx_unlock_spin(&dt_lock); + error = copyout(data, uap->descs, num * sizeof(union descriptor)); + if (error == 0) td->td_retval[0] = num; - - return(error); + free(data, M_TEMP); + return (error); } int -i386_set_ldt(td, uap, descs) - struct thread *td; - struct i386_ldt_args *uap; - union descriptor *descs; +i386_set_ldt(struct thread *td, struct i386_ldt_args *uap, + union descriptor *descs) { - int error = 0, i; - int largest_ld; - struct mdproc *mdp = &td->td_proc->p_md; + struct mdproc *mdp; struct proc_ldt *pldt; union descriptor *dp; + u_int largest_ld, i; + int error; -#ifdef DEBUG - printf("i386_set_ldt: start=%d num=%d descs=%p\n", +#ifdef DEBUG + printf("i386_set_ldt: start=%u num=%u descs=%p\n", uap->start, uap->num, (void *)uap->descs); #endif + error = 0; + mdp = &td->td_proc->p_md; if (descs == NULL) { /* Free descriptors */ @@ -569,8 +584,6 @@ i386_set_ldt(td, uap, descs) uap->start = NLDT; uap->num = MAX_LD - NLDT; } - if (uap->num == 0) - return (EINVAL); mtx_lock_spin(&dt_lock); if ((pldt = mdp->md_ldt) == NULL || uap->start >= pldt->ldt_len) { @@ -580,19 +593,18 @@ i386_set_ldt(td, uap, descs) largest_ld = uap->start + uap->num; if (largest_ld > pldt->ldt_len) largest_ld = pldt->ldt_len; - i = largest_ld - uap->start; - bzero(&((union descriptor *)(pldt->ldt_base))[uap->start], - sizeof(union descriptor) * i); + for (i = uap->start; i < largest_ld; i++) + atomic_store_rel_64(&((uint64_t *)(pldt->ldt_base))[i], + 0); mtx_unlock_spin(&dt_lock); return (0); } - if (!(uap->start == LDT_AUTO_ALLOC && uap->num == 1)) { + if (uap->start != LDT_AUTO_ALLOC || uap->num != 1) { /* verify range of descriptors to modify */ largest_ld = uap->start + uap->num; - if (uap->start >= MAX_LD || largest_ld > MAX_LD) { + if (uap->start >= MAX_LD || largest_ld > MAX_LD) return (EINVAL); - } } /* Check descriptors for access violations */ @@ -618,12 +630,7 @@ i386_set_ldt(td, uap, descs) case SDT_SYS386TGT: /* system 386 trap gate */ case SDT_SYS286CGT: /* system 286 call gate */ case SDT_SYS386CGT: /* system 386 call gate */ - /* I can't think of any reason to allow a user proc - * to create a segment of these types. They are - * for OS use only. - */ return (EACCES); - /*NOTREACHED*/ /* memory segment types */ case SDT_MEMEC: /* memory execute only conforming */ @@ -648,12 +655,11 @@ i386_set_ldt(td, uap, descs) case SDT_MEMERA: /* memory execute read accessed */ break; default: - return(EINVAL); - /*NOTREACHED*/ + return (EINVAL); } /* Only user (ring-3) descriptors may be present. */ - if ((dp->sd.sd_p != 0) && (dp->sd.sd_dpl != SEL_UPL)) + if (dp->sd.sd_p != 0 && dp->sd.sd_dpl != SEL_UPL) return (EACCES); } @@ -704,27 +710,37 @@ again: static int i386_set_ldt_data(struct thread *td, int start, int num, - union descriptor *descs) + union descriptor *descs) { - struct mdproc *mdp = &td->td_proc->p_md; - struct proc_ldt *pldt = mdp->md_ldt; + struct mdproc *mdp; + struct proc_ldt *pldt; + uint64_t *dst, *src; + int i; mtx_assert(&dt_lock, MA_OWNED); - /* Fill in range */ - bcopy(descs, - &((union descriptor *)(pldt->ldt_base))[start], - num * sizeof(union descriptor)); + mdp = &td->td_proc->p_md; + pldt = mdp->md_ldt; + dst = (uint64_t *)(pldt->ldt_base); + src = (uint64_t *)descs; + + /* + * Atomic(9) is used only to get 64bit atomic store with + * cmpxchg8b when available. There is no op without release + * semantic. + */ + for (i = 0; i < num; i++) + atomic_store_rel_64(&dst[start + i], src[i]); return (0); } static int i386_ldt_grow(struct thread *td, int len) { - struct mdproc *mdp = &td->td_proc->p_md; + struct mdproc *mdp; struct proc_ldt *new_ldt, *pldt; - caddr_t old_ldt_base = NULL_LDT_BASE; - int old_ldt_len = 0; + caddr_t old_ldt_base; + int old_ldt_len; mtx_assert(&dt_lock, MA_OWNED); @@ -733,6 +749,10 @@ i386_ldt_grow(struct thread *td, int len) if (len < NLDT + 1) len = NLDT + 1; + mdp = &td->td_proc->p_md; + old_ldt_base = NULL_LDT_BASE; + old_ldt_len = 0; + /* Allocate a user ldt. */ if ((pldt = mdp->md_ldt) == NULL || len > pldt->ldt_len) { new_ldt = user_ldt_alloc(mdp, len); @@ -774,10 +794,10 @@ i386_ldt_grow(struct thread *td, int len) * to acquire it. */ mtx_unlock_spin(&dt_lock); - smp_rendezvous(NULL, (void (*)(void *))set_user_ldt_rv, - NULL, td->td_proc->p_vmspace); + smp_rendezvous(NULL, set_user_ldt_rv, NULL, + td->td_proc->p_vmspace); #else - set_user_ldt(&td->td_proc->p_md); + set_user_ldt_locked(&td->td_proc->p_md); mtx_unlock_spin(&dt_lock); #endif if (old_ldt_base != NULL_LDT_BASE) { Modified: stable/11/sys/i386/include/md_var.h ============================================================================== --- stable/11/sys/i386/include/md_var.h Sun Oct 22 08:42:01 2017 (r324854) +++ stable/11/sys/i386/include/md_var.h Sun Oct 22 08:47:13 2017 (r324855) @@ -66,6 +66,8 @@ void init_AMD_Elan_sc520(void); vm_paddr_t kvtop(void *addr); void panicifcpuunsupported(void); void ppro_reenable_apic(void); +void set_fsbase(struct thread *td, uint32_t base); +void set_gsbase(struct thread *td, uint32_t base); void setidt(int idx, alias_for_inthand_t *func, int typ, int dpl, int selec); union savefpu *get_pcb_user_save_td(struct thread *td); union savefpu *get_pcb_user_save_pcb(struct pcb *pcb); From owner-svn-src-stable-11@freebsd.org Mon Oct 23 07:39:06 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 16B32E437F8; Mon, 23 Oct 2017 07:39:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D9E1B65C1C; Mon, 23 Oct 2017 07:39:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9N7d5jt020647; Mon, 23 Oct 2017 07:39:05 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9N7d5AA020646; Mon, 23 Oct 2017 07:39:05 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201710230739.v9N7d5AA020646@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 23 Oct 2017 07:39:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324908 - stable/11/share/man/man4 X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/share/man/man4 X-SVN-Commit-Revision: 324908 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2017 07:39:06 -0000 Author: mav Date: Mon Oct 23 07:39:04 2017 New Revision: 324908 URL: https://svnweb.freebsd.org/changeset/base/324908 Log: MFC r324659: Update details of interface capabilities changed by bridge(4). PR: 221122 Modified: stable/11/share/man/man4/bridge.4 Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/bridge.4 ============================================================================== --- stable/11/share/man/man4/bridge.4 Mon Oct 23 07:30:52 2017 (r324907) +++ stable/11/share/man/man4/bridge.4 Mon Oct 23 07:39:04 2017 (r324908) @@ -35,7 +35,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 27, 2013 +.Dd October 16, 2017 .Dt IF_BRIDGE 4 .Os .Sh NAME @@ -129,8 +129,11 @@ in The MTU of the first member interface to be added is used as the bridge MTU. All additional members are required to have exactly the same value. .Pp -The TXCSUM capability is disabled for any interface added to the bridge, and it -is restored when the interface is removed again. +The TOE, TSO, TXCSUM and TXCSUM6 capabilities on all interfaces added to the +bridge are disabled if any of the interfaces doesn't support/enable them. +The LRO capability is always disabled. +All the capabilities are restored when the interface is removed from bridge. +Changing capabilities in run time may cause NIC reinit and the link flap. .Pp The bridge supports .Dq monitor mode , From owner-svn-src-stable-11@freebsd.org Mon Oct 23 07:41:45 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BBC33E43BEA; Mon, 23 Oct 2017 07:41:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 882AD66167; Mon, 23 Oct 2017 07:41:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9N7fiNY023900; Mon, 23 Oct 2017 07:41:44 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9N7fihe023898; Mon, 23 Oct 2017 07:41:44 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201710230741.v9N7fihe023898@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 23 Oct 2017 07:41:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324909 - stable/11/sys/dev/sound/pci/hda X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/sound/pci/hda X-SVN-Commit-Revision: 324909 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2017 07:41:45 -0000 Author: mav Date: Mon Oct 23 07:41:44 2017 New Revision: 324909 URL: https://svnweb.freebsd.org/changeset/base/324909 Log: MFC r324661: Add Creative vendor ID. Modified: stable/11/sys/dev/sound/pci/hda/hdac.c stable/11/sys/dev/sound/pci/hda/hdac.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/sound/pci/hda/hdac.c ============================================================================== --- stable/11/sys/dev/sound/pci/hda/hdac.c Mon Oct 23 07:39:04 2017 (r324908) +++ stable/11/sys/dev/sound/pci/hda/hdac.c Mon Oct 23 07:41:44 2017 (r324909) @@ -175,6 +175,7 @@ static const struct { { HDA_NVIDIA_ALL, "NVIDIA", 0, 0 }, { HDA_ATI_ALL, "ATI", 0, 0 }, { HDA_AMD_ALL, "AMD", 0, 0 }, + { HDA_CREATIVE_ALL, "Creative", 0, 0 }, { HDA_VIA_ALL, "VIA", 0, 0 }, { HDA_SIS_ALL, "SiS", 0, 0 }, { HDA_ULI_ALL, "ULI", 0, 0 }, Modified: stable/11/sys/dev/sound/pci/hda/hdac.h ============================================================================== --- stable/11/sys/dev/sound/pci/hda/hdac.h Mon Oct 23 07:39:04 2017 (r324908) +++ stable/11/sys/dev/sound/pci/hda/hdac.h Mon Oct 23 07:41:44 2017 (r324909) @@ -150,6 +150,10 @@ #define RDC_VENDORID 0x17f3 #define HDA_RDC_M3010 HDA_MODEL_CONSTRUCT(RDC, 0x3010) +/* Creative */ +#define CREATIVE_VENDORID 0x1102 +#define HDA_CREATIVE_ALL HDA_MODEL_CONSTRUCT(CREATIVE, 0xffff) + /* VIA */ #define VIA_VENDORID 0x1106 #define HDA_VIA_VT82XX HDA_MODEL_CONSTRUCT(VIA, 0x3288) From owner-svn-src-stable-11@freebsd.org Mon Oct 23 08:09:21 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 521C2E44BC2; Mon, 23 Oct 2017 08:09:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2C3BE67211; Mon, 23 Oct 2017 08:09:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9N89Kbp033527; Mon, 23 Oct 2017 08:09:20 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9N89Ks3033525; Mon, 23 Oct 2017 08:09:20 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201710230809.v9N89Ks3033525@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 23 Oct 2017 08:09:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324916 - in stable/11/sys/amd64: amd64 include X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11/sys/amd64: amd64 include X-SVN-Commit-Revision: 324916 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2017 08:09:21 -0000 Author: kib Date: Mon Oct 23 08:09:19 2017 New Revision: 324916 URL: https://svnweb.freebsd.org/changeset/base/324916 Log: MFC r324665: Fix the pv_chunks pc_lru tailq handling in reclaim_pv_chunk(). Modified: stable/11/sys/amd64/amd64/pmap.c stable/11/sys/amd64/include/pmap.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/pmap.c ============================================================================== --- stable/11/sys/amd64/amd64/pmap.c Mon Oct 23 08:06:57 2017 (r324915) +++ stable/11/sys/amd64/amd64/pmap.c Mon Oct 23 08:09:19 2017 (r324916) @@ -2892,11 +2892,11 @@ reclaim_pv_chunk_leave_pmap(pmap_t pmap, pmap_t locked static vm_page_t reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **lockp) { - struct pch new_tail; - struct pv_chunk *pc; + struct pv_chunk *pc, *pc_marker; + struct pv_chunk_header pc_marker_b; struct md_page *pvh; pd_entry_t *pde; - pmap_t pmap; + pmap_t next_pmap, pmap; pt_entry_t *pte, tpte; pt_entry_t PG_G, PG_A, PG_M, PG_RW; pv_entry_t pv; @@ -2913,7 +2913,8 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l m_pc = NULL; PG_G = PG_A = PG_M = PG_RW = 0; SLIST_INIT(&free); - TAILQ_INIT(&new_tail); + bzero(&pc_marker_b, sizeof(pc_marker_b)); + pc_marker = (struct pv_chunk *)&pc_marker_b; /* * A delayed invalidation block should already be active if @@ -2923,30 +2924,52 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l start_di = pmap_not_in_di(); mtx_lock(&pv_chunks_mutex); - while ((pc = TAILQ_FIRST(&pv_chunks)) != NULL && SLIST_EMPTY(&free)) { - TAILQ_REMOVE(&pv_chunks, pc, pc_lru); + TAILQ_INSERT_HEAD(&pv_chunks, pc_marker, pc_lru); + while ((pc = TAILQ_NEXT(pc_marker, pc_lru)) != NULL && + SLIST_EMPTY(&free)) { + next_pmap = pc->pc_pmap; + if (next_pmap == NULL) /* marker */ + goto next_chunk; mtx_unlock(&pv_chunks_mutex); - if (pmap != pc->pc_pmap) { + + /* + * A pv_chunk can only be removed from the pc_lru list + * when both pc_chunks_mutex is owned and the + * corresponding pmap is locked. + */ + if (pmap != next_pmap) { reclaim_pv_chunk_leave_pmap(pmap, locked_pmap, start_di); - pmap = pc->pc_pmap; + pmap = next_pmap; /* Avoid deadlock and lock recursion. */ if (pmap > locked_pmap) { RELEASE_PV_LIST_LOCK(lockp); PMAP_LOCK(pmap); - } else if (pmap != locked_pmap && - !PMAP_TRYLOCK(pmap)) { - pmap = NULL; - TAILQ_INSERT_TAIL(&new_tail, pc, pc_lru); + if (start_di) + pmap_delayed_invl_started(); mtx_lock(&pv_chunks_mutex); continue; - } + } else if (pmap != locked_pmap) { + if (PMAP_TRYLOCK(pmap)) { + if (start_di) + pmap_delayed_invl_started(); + mtx_lock(&pv_chunks_mutex); + continue; + } else { + pmap = NULL; /* pmap is not locked */ + mtx_lock(&pv_chunks_mutex); + pc = TAILQ_NEXT(pc_marker, pc_lru); + if (pc == NULL || + pc->pc_pmap != next_pmap) + continue; + goto next_chunk; + } + } else if (start_di) + pmap_delayed_invl_started(); PG_G = pmap_global_bit(pmap); PG_A = pmap_accessed_bit(pmap); PG_M = pmap_modified_bit(pmap); PG_RW = pmap_rw_bit(pmap); - if (start_di) - pmap_delayed_invl_started(); } /* @@ -2991,9 +3014,8 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l } } if (freed == 0) { - TAILQ_INSERT_TAIL(&new_tail, pc, pc_lru); mtx_lock(&pv_chunks_mutex); - continue; + goto next_chunk; } /* Every freed mapping is for a 4 KB page. */ pmap_resident_count_dec(pmap, freed); @@ -3010,16 +3032,19 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l m_pc = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pc)); dump_drop_page(m_pc->phys_addr); mtx_lock(&pv_chunks_mutex); + TAILQ_REMOVE(&pv_chunks, pc, pc_lru); break; } TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); - TAILQ_INSERT_TAIL(&new_tail, pc, pc_lru); mtx_lock(&pv_chunks_mutex); /* One freed pv entry in locked_pmap is sufficient. */ if (pmap == locked_pmap) break; +next_chunk: + TAILQ_REMOVE(&pv_chunks, pc_marker, pc_lru); + TAILQ_INSERT_AFTER(&pv_chunks, pc, pc_marker, pc_lru); } - TAILQ_CONCAT(&pv_chunks, &new_tail, pc_lru); + TAILQ_REMOVE(&pv_chunks, pc_marker, pc_lru); mtx_unlock(&pv_chunks_mutex); reclaim_pv_chunk_leave_pmap(pmap, locked_pmap, start_di); if (m_pc == NULL && !SLIST_EMPTY(&free)) { Modified: stable/11/sys/amd64/include/pmap.h ============================================================================== --- stable/11/sys/amd64/include/pmap.h Mon Oct 23 08:06:57 2017 (r324915) +++ stable/11/sys/amd64/include/pmap.h Mon Oct 23 08:09:19 2017 (r324916) @@ -366,11 +366,18 @@ typedef struct pv_entry { */ #define _NPCM 3 #define _NPCPV 168 -struct pv_chunk { - pmap_t pc_pmap; - TAILQ_ENTRY(pv_chunk) pc_list; - uint64_t pc_map[_NPCM]; /* bitmap; 1 = free */ +#define PV_CHUNK_HEADER \ + pmap_t pc_pmap; \ + TAILQ_ENTRY(pv_chunk) pc_list; \ + uint64_t pc_map[_NPCM]; /* bitmap; 1 = free */ \ TAILQ_ENTRY(pv_chunk) pc_lru; + +struct pv_chunk_header { + PV_CHUNK_HEADER +}; + +struct pv_chunk { + PV_CHUNK_HEADER struct pv_entry pc_pventry[_NPCPV]; }; From owner-svn-src-stable-11@freebsd.org Mon Oct 23 08:13:24 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 94DEDE44E22; Mon, 23 Oct 2017 08:13:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 59DBC675B2; Mon, 23 Oct 2017 08:13:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9N8DNOJ037516; Mon, 23 Oct 2017 08:13:23 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9N8DNTs037515; Mon, 23 Oct 2017 08:13:23 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201710230813.v9N8DNTs037515@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 23 Oct 2017 08:13:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324917 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 324917 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2017 08:13:24 -0000 Author: kib Date: Mon Oct 23 08:13:23 2017 New Revision: 324917 URL: https://svnweb.freebsd.org/changeset/base/324917 Log: MFC r324669: Style. Modified: stable/11/sys/kern/kern_sig.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_sig.c ============================================================================== --- stable/11/sys/kern/kern_sig.c Mon Oct 23 08:09:19 2017 (r324916) +++ stable/11/sys/kern/kern_sig.c Mon Oct 23 08:13:23 2017 (r324917) @@ -2804,14 +2804,14 @@ issignal(struct thread *td) struct sigacts *ps; struct sigqueue *queue; sigset_t sigpending; - int sig, prop; + int prop, sig, traced; p = td->td_proc; ps = p->p_sigacts; mtx_assert(&ps->ps_mtx, MA_OWNED); PROC_LOCK_ASSERT(p, MA_OWNED); for (;;) { - int traced = (p->p_flag & P_TRACED) || (p->p_stops & S_SIG); + traced = (p->p_flag & P_TRACED) || (p->p_stops & S_SIG); sigpending = td->td_sigqueue.sq_signals; SIGSETOR(sigpending, p->p_sigqueue.sq_signals); @@ -2998,11 +2998,10 @@ thread_stopped(struct proc *p) * from the current set of pending signals. */ int -postsig(sig) - register int sig; +postsig(int sig) { - struct thread *td = curthread; - register struct proc *p = td->td_proc; + struct thread *td; + struct proc *p; struct sigacts *ps; sig_t action; ksiginfo_t ksi; @@ -3010,6 +3009,8 @@ postsig(sig) KASSERT(sig != 0, ("postsig")); + td = curthread; + p = td->td_proc; PROC_LOCK_ASSERT(p, MA_OWNED); ps = p->p_sigacts; mtx_assert(&ps->ps_mtx, MA_OWNED); @@ -3026,7 +3027,7 @@ postsig(sig) ktrpsig(sig, action, td->td_pflags & TDP_OLDMASK ? &td->td_oldsigmask : &td->td_sigmask, ksi.ksi_code); #endif - if (p->p_stops & S_SIG) { + if ((p->p_stops & S_SIG) != 0) { mtx_unlock(&ps->ps_mtx); stopevent(p, S_SIG, sig); mtx_lock(&ps->ps_mtx); From owner-svn-src-stable-11@freebsd.org Mon Oct 23 08:14:42 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 63F11E44EA6; Mon, 23 Oct 2017 08:14:42 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3120F676FC; Mon, 23 Oct 2017 08:14:42 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9N8EfZ8037613; Mon, 23 Oct 2017 08:14:41 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9N8Ef44037612; Mon, 23 Oct 2017 08:14:41 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201710230814.v9N8Ef44037612@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 23 Oct 2017 08:14:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324918 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 324918 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2017 08:14:42 -0000 Author: kib Date: Mon Oct 23 08:14:41 2017 New Revision: 324918 URL: https://svnweb.freebsd.org/changeset/base/324918 Log: MFC r324670: Improve assertion that an ignored or blocked signal is not delivered. Modified: stable/11/sys/kern/kern_sig.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_sig.c ============================================================================== --- stable/11/sys/kern/kern_sig.c Mon Oct 23 08:13:23 2017 (r324917) +++ stable/11/sys/kern/kern_sig.c Mon Oct 23 08:14:41 2017 (r324918) @@ -3045,8 +3045,10 @@ postsig(int sig) /* * If we get here, the signal must be caught. */ - KASSERT(action != SIG_IGN && !SIGISMEMBER(td->td_sigmask, sig), - ("postsig action")); + KASSERT(action != SIG_IGN, ("postsig action %p", action)); + KASSERT(!SIGISMEMBER(td->td_sigmask, sig), + ("postsig action: blocked sig %d", sig)); + /* * Set the new mask value and also defer further * occurrences of this signal. From owner-svn-src-stable-11@freebsd.org Mon Oct 23 18:25:24 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80628E51C9A; Mon, 23 Oct 2017 18:25:24 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 313B67E409; Mon, 23 Oct 2017 18:25:24 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9NIPN9i090214; Mon, 23 Oct 2017 18:25:23 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9NIPLlE090194; Mon, 23 Oct 2017 18:25:21 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201710231825.v9NIPLlE090194@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 23 Oct 2017 18:25:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324932 - in stable/11: lib/libprocstat sys/kern sys/sys usr.bin/gcore usr.bin/procstat X-SVN-Group: stable-11 X-SVN-Commit-Author: bdrewery X-SVN-Commit-Paths: in stable/11: lib/libprocstat sys/kern sys/sys usr.bin/gcore usr.bin/procstat X-SVN-Commit-Revision: 324932 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2017 18:25:24 -0000 Author: bdrewery Date: Mon Oct 23 18:25:21 2017 New Revision: 324932 URL: https://svnweb.freebsd.org/changeset/base/324932 Log: MFC r316286: Add support for capturing 'struct ptrace_lwpinfo' for signals resulting in a process dumping core in the corefile. Direct stable changed: Padding added to struct thread and td_si added to end with explicit bzeroing when forking/initializing a thread to preserve KBI. Added: stable/11/usr.bin/procstat/procstat_ptlwpinfo.c - copied unchanged from r316286, head/usr.bin/procstat/procstat_ptlwpinfo.c Modified: stable/11/lib/libprocstat/Symbol.map stable/11/lib/libprocstat/core.c stable/11/lib/libprocstat/core.h stable/11/lib/libprocstat/libprocstat.c stable/11/lib/libprocstat/libprocstat.h stable/11/sys/kern/imgact_elf.c stable/11/sys/kern/kern_fork.c stable/11/sys/kern/kern_kthread.c stable/11/sys/kern/kern_sig.c stable/11/sys/kern/kern_thr.c stable/11/sys/kern/sys_process.c stable/11/sys/sys/elf_common.h stable/11/sys/sys/proc.h stable/11/usr.bin/gcore/elfcore.c stable/11/usr.bin/procstat/Makefile stable/11/usr.bin/procstat/procstat.1 stable/11/usr.bin/procstat/procstat.c stable/11/usr.bin/procstat/procstat.h Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libprocstat/Symbol.map ============================================================================== --- stable/11/lib/libprocstat/Symbol.map Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/lib/libprocstat/Symbol.map Mon Oct 23 18:25:21 2017 (r324932) @@ -36,3 +36,8 @@ FBSD_1.3 { procstat_getvmmap; procstat_open_core; }; + +FBSD_1.5 { + procstat_freeptlwpinfo; + procstat_getptlwpinfo; +}; Modified: stable/11/lib/libprocstat/core.c ============================================================================== --- stable/11/lib/libprocstat/core.c Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/lib/libprocstat/core.c Mon Oct 23 18:25:21 2017 (r324932) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2013 Mikolaj Golub + * Copyright (c) 2017 Dell EMC * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -56,6 +58,24 @@ struct procstat_core GElf_Phdr pc_phdr; }; +static struct psc_type_info { + unsigned int n_type; + int structsize; +} psc_type_info[PSC_TYPE_MAX] = { + { .n_type = NT_PROCSTAT_PROC, .structsize = sizeof(struct kinfo_proc) }, + { .n_type = NT_PROCSTAT_FILES, .structsize = sizeof(struct kinfo_file) }, + { .n_type = NT_PROCSTAT_VMMAP, .structsize = sizeof(struct kinfo_vmentry) }, + { .n_type = NT_PROCSTAT_GROUPS, .structsize = sizeof(gid_t) }, + { .n_type = NT_PROCSTAT_UMASK, .structsize = sizeof(u_short) }, + { .n_type = NT_PROCSTAT_RLIMIT, .structsize = sizeof(struct rlimit) * RLIM_NLIMITS }, + { .n_type = NT_PROCSTAT_OSREL, .structsize = sizeof(int) }, + { .n_type = NT_PROCSTAT_PSSTRINGS, .structsize = sizeof(vm_offset_t) }, + { .n_type = NT_PROCSTAT_PSSTRINGS, .structsize = sizeof(vm_offset_t) }, + { .n_type = NT_PROCSTAT_PSSTRINGS, .structsize = sizeof(vm_offset_t) }, + { .n_type = NT_PROCSTAT_AUXV, .structsize = sizeof(Elf_Auxinfo) }, + { .n_type = NT_PTLWPINFO, .structsize = sizeof(struct ptrace_lwpinfo) }, +}; + static bool core_offset(struct procstat_core *core, off_t offset); static bool core_read(struct procstat_core *core, void *buf, size_t len); static ssize_t core_read_mem(struct procstat_core *core, void *buf, @@ -154,59 +174,20 @@ procstat_core_get(struct procstat_core *core, enum psc off_t offset, eoffset; vm_offset_t psstrings; void *freebuf; - size_t len; - u_int32_t n_type; - int cstructsize, structsize; + size_t len, curlen; + int cstructsize; char nbuf[8]; assert(core->pc_magic == PROCSTAT_CORE_MAGIC); - switch(type) { - case PSC_TYPE_PROC: - n_type = NT_PROCSTAT_PROC; - structsize = sizeof(struct kinfo_proc); - break; - case PSC_TYPE_FILES: - n_type = NT_PROCSTAT_FILES; - structsize = sizeof(struct kinfo_file); - break; - case PSC_TYPE_VMMAP: - n_type = NT_PROCSTAT_VMMAP; - structsize = sizeof(struct kinfo_vmentry); - break; - case PSC_TYPE_GROUPS: - n_type = NT_PROCSTAT_GROUPS; - structsize = sizeof(gid_t); - break; - case PSC_TYPE_UMASK: - n_type = NT_PROCSTAT_UMASK; - structsize = sizeof(u_short); - break; - case PSC_TYPE_RLIMIT: - n_type = NT_PROCSTAT_RLIMIT; - structsize = sizeof(struct rlimit) * RLIM_NLIMITS; - break; - case PSC_TYPE_OSREL: - n_type = NT_PROCSTAT_OSREL; - structsize = sizeof(int); - break; - case PSC_TYPE_PSSTRINGS: - case PSC_TYPE_ARGV: - case PSC_TYPE_ENVV: - n_type = NT_PROCSTAT_PSSTRINGS; - structsize = sizeof(vm_offset_t); - break; - case PSC_TYPE_AUXV: - n_type = NT_PROCSTAT_AUXV; - structsize = sizeof(Elf_Auxinfo); - break; - default: + if (type >= PSC_TYPE_MAX) { warnx("unknown core stat type: %d", type); return (NULL); } offset = core->pc_phdr.p_offset; eoffset = offset + core->pc_phdr.p_filesz; + curlen = 0; while (offset < eoffset) { if (!core_offset(core, offset)) @@ -220,7 +201,7 @@ procstat_core_get(struct procstat_core *core, enum psc if (nhdr.n_namesz == 0 && nhdr.n_descsz == 0) break; - if (nhdr.n_type != n_type) + if (nhdr.n_type != psc_type_info[type].n_type) continue; if (nhdr.n_namesz != 8) continue; @@ -234,7 +215,7 @@ procstat_core_get(struct procstat_core *core, enum psc } if (!core_read(core, &cstructsize, sizeof(cstructsize))) return (NULL); - if (cstructsize != structsize) { + if (cstructsize != psc_type_info[type].structsize) { warnx("version mismatch"); return (NULL); } @@ -251,7 +232,7 @@ procstat_core_get(struct procstat_core *core, enum psc return (NULL); } } - if (!core_read(core, buf, len)) { + if (!core_read(core, (char *)buf + curlen, len)) { free(freebuf); return (NULL); } @@ -267,11 +248,20 @@ procstat_core_get(struct procstat_core *core, enum psc buf = NULL; free(freebuf); buf = get_args(core, psstrings, type, buf, &len); + } else if (type == PSC_TYPE_PTLWPINFO) { + *lenp -= len; + curlen += len; + continue; } *lenp = len; return (buf); } + if (curlen != 0) { + *lenp = curlen; + return (buf); + } + return (NULL); } @@ -430,4 +420,58 @@ done: *lenp = done; free(argv); return (args); +} + +int +procstat_core_note_count(struct procstat_core *core, enum psc_type type) +{ + Elf_Note nhdr; + off_t offset, eoffset; + int cstructsize; + char nbuf[8]; + int n; + + if (type >= PSC_TYPE_MAX) { + warnx("unknown core stat type: %d", type); + return (0); + } + + offset = core->pc_phdr.p_offset; + eoffset = offset + core->pc_phdr.p_filesz; + + for (n = 0; offset < eoffset; n++) { + if (!core_offset(core, offset)) + return (0); + if (!core_read(core, &nhdr, sizeof(nhdr))) + return (0); + + offset += sizeof(nhdr) + + roundup2(nhdr.n_namesz, sizeof(Elf32_Size)) + + roundup2(nhdr.n_descsz, sizeof(Elf32_Size)); + + if (nhdr.n_namesz == 0 && nhdr.n_descsz == 0) + break; + if (nhdr.n_type != psc_type_info[type].n_type) + continue; + if (nhdr.n_namesz != 8) + continue; + if (!core_read(core, nbuf, sizeof(nbuf))) + return (0); + if (strcmp(nbuf, "FreeBSD") != 0) + continue; + if (nhdr.n_descsz < sizeof(cstructsize)) { + warnx("corrupted core file"); + return (0); + } + if (!core_read(core, &cstructsize, sizeof(cstructsize))) + return (0); + if (cstructsize != psc_type_info[type].structsize) { + warnx("version mismatch"); + return (0); + } + if (nhdr.n_descsz - sizeof(cstructsize) == 0) + return (0); + } + + return (n); } Modified: stable/11/lib/libprocstat/core.h ============================================================================== --- stable/11/lib/libprocstat/core.h Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/lib/libprocstat/core.h Mon Oct 23 18:25:21 2017 (r324932) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2013 Mikolaj Golub + * Copyright (c) 2017 Dell EMC * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,6 +42,8 @@ enum psc_type { PSC_TYPE_ARGV, PSC_TYPE_ENVV, PSC_TYPE_AUXV, + PSC_TYPE_PTLWPINFO, + PSC_TYPE_MAX }; struct procstat_core; @@ -48,6 +51,7 @@ struct procstat_core; void procstat_core_close(struct procstat_core *core); void *procstat_core_get(struct procstat_core *core, enum psc_type type, void * buf, size_t *lenp); +int procstat_core_note_count(struct procstat_core *core, enum psc_type type); struct procstat_core *procstat_core_open(const char *filename); #endif /* !_CORE_H_ */ Modified: stable/11/lib/libprocstat/libprocstat.c ============================================================================== --- stable/11/lib/libprocstat/libprocstat.c Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/lib/libprocstat/libprocstat.c Mon Oct 23 18:25:21 2017 (r324932) @@ -1,4 +1,5 @@ /*- + * Copyright (c) 2017 Dell EMC * Copyright (c) 2009 Stanislav Sedov * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -65,6 +66,7 @@ __FBSDID("$FreeBSD$"); #define _KERNEL #include #include +#include #include #include #include @@ -2467,6 +2469,48 @@ procstat_freeauxv(struct procstat *procstat __unused, { free(auxv); +} + +static struct ptrace_lwpinfo * +procstat_getptlwpinfo_core(struct procstat_core *core, unsigned int *cntp) +{ + void *buf; + struct ptrace_lwpinfo *pl; + unsigned int cnt; + size_t len; + + cnt = procstat_core_note_count(core, PSC_TYPE_PTLWPINFO); + if (cnt == 0) + return (NULL); + + len = cnt * sizeof(*pl); + buf = calloc(1, len); + pl = procstat_core_get(core, PSC_TYPE_PTLWPINFO, buf, &len); + if (pl == NULL) { + free(buf); + return (NULL); + } + *cntp = len / sizeof(*pl); + return (pl); +} + +struct ptrace_lwpinfo * +procstat_getptlwpinfo(struct procstat *procstat, unsigned int *cntp) +{ + switch (procstat->type) { + case PROCSTAT_CORE: + return (procstat_getptlwpinfo_core(procstat->core, cntp)); + default: + warnx("unknown access method: %d", procstat->type); + return (NULL); + } +} + +void +procstat_freeptlwpinfo(struct procstat *procstat __unused, + struct ptrace_lwpinfo *pl) +{ + free(pl); } static struct kinfo_kstack * Modified: stable/11/lib/libprocstat/libprocstat.h ============================================================================== --- stable/11/lib/libprocstat/libprocstat.h Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/lib/libprocstat/libprocstat.h Mon Oct 23 18:25:21 2017 (r324932) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2009 Stanislav Sedov + * Copyright (c) 2017 Dell EMC * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -101,6 +102,7 @@ struct kinfo_kstack; struct kinfo_vmentry; struct procstat; +struct ptrace_lwpinfo; struct rlimit; struct filestat { int fs_type; /* Descriptor type. */ @@ -172,6 +174,8 @@ void procstat_freekstack(struct procstat *procstat, void procstat_freeprocs(struct procstat *procstat, struct kinfo_proc *p); void procstat_freefiles(struct procstat *procstat, struct filestat_list *head); +void procstat_freeptlwpinfo(struct procstat *procstat, + struct ptrace_lwpinfo *pl); void procstat_freevmmap(struct procstat *procstat, struct kinfo_vmentry *vmmap); struct filestat_list *procstat_getfiles(struct procstat *procstat, @@ -196,6 +200,8 @@ char **procstat_getargv(struct procstat *procstat, str Elf_Auxinfo *procstat_getauxv(struct procstat *procstat, struct kinfo_proc *kp, unsigned int *cntp); #endif +struct ptrace_lwpinfo *procstat_getptlwpinfo(struct procstat *procstat, + unsigned int *cntp); char **procstat_getenvv(struct procstat *procstat, struct kinfo_proc *p, size_t nchr); gid_t *procstat_getgroups(struct procstat *procstat, struct kinfo_proc *kp, Modified: stable/11/sys/kern/imgact_elf.c ============================================================================== --- stable/11/sys/kern/imgact_elf.c Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/sys/kern/imgact_elf.c Mon Oct 23 18:25:21 2017 (r324932) @@ -1,4 +1,5 @@ /*- + * Copyright (c) 2017 Dell EMC * Copyright (c) 2000 David O'Brien * Copyright (c) 1995-1996 Søren Schmidt * Copyright (c) 1996 Peter Wemm @@ -52,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1205,6 +1207,7 @@ static void __elfN(note_prpsinfo)(void *, struct sbuf static void __elfN(note_prstatus)(void *, struct sbuf *, size_t *); static void __elfN(note_threadmd)(void *, struct sbuf *, size_t *); static void __elfN(note_thrmisc)(void *, struct sbuf *, size_t *); +static void __elfN(note_ptlwpinfo)(void *, struct sbuf *, size_t *); static void __elfN(note_procstat_auxv)(void *, struct sbuf *, size_t *); static void __elfN(note_procstat_proc)(void *, struct sbuf *, size_t *); static void __elfN(note_procstat_psstrings)(void *, struct sbuf *, size_t *); @@ -1634,6 +1637,8 @@ __elfN(prepare_notes)(struct thread *td, struct note_i __elfN(note_fpregset), thr); size += register_note(list, NT_THRMISC, __elfN(note_thrmisc), thr); + size += register_note(list, NT_PTLWPINFO, + __elfN(note_ptlwpinfo), thr); size += register_note(list, -1, __elfN(note_threadmd), thr); @@ -1993,6 +1998,37 @@ __elfN(note_thrmisc)(void *arg, struct sbuf *sb, size_ sbuf_bcat(sb, &thrmisc, sizeof(thrmisc)); } *sizep = sizeof(thrmisc); +} + +static void +__elfN(note_ptlwpinfo)(void *arg, struct sbuf *sb, size_t *sizep) +{ + struct thread *td; + size_t size; + int structsize; + struct ptrace_lwpinfo pl; + + td = (struct thread *)arg; + size = sizeof(structsize) + sizeof(struct ptrace_lwpinfo); + if (sb != NULL) { + KASSERT(*sizep == size, ("invalid size")); + structsize = sizeof(struct ptrace_lwpinfo); + sbuf_bcat(sb, &structsize, sizeof(structsize)); + bzero(&pl, sizeof(pl)); + pl.pl_lwpid = td->td_tid; + pl.pl_event = PL_EVENT_NONE; + pl.pl_sigmask = td->td_sigmask; + pl.pl_siglist = td->td_siglist; + if (td->td_si.si_signo != 0) { + pl.pl_event = PL_EVENT_SIGNAL; + pl.pl_flags |= PL_FLAG_SI; + pl.pl_siginfo = td->td_si; + } + strcpy(pl.pl_tdname, td->td_name); + /* XXX TODO: supply more information in struct ptrace_lwpinfo*/ + sbuf_bcat(sb, &pl, sizeof(struct ptrace_lwpinfo)); + } + *sizep = size; } /* Modified: stable/11/sys/kern/kern_fork.c ============================================================================== --- stable/11/sys/kern/kern_fork.c Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/sys/kern/kern_fork.c Mon Oct 23 18:25:21 2017 (r324932) @@ -475,6 +475,7 @@ do_fork(struct thread *td, struct fork_req *fr, struct bzero(&td2->td_startzero, __rangeof(struct thread, td_startzero, td_endzero)); td2->td_sleeptimo = 0; + bzero(&td2->td_si, sizeof(td2->td_si)); bcopy(&td->td_startcopy, &td2->td_startcopy, __rangeof(struct thread, td_startcopy, td_endcopy)); Modified: stable/11/sys/kern/kern_kthread.c ============================================================================== --- stable/11/sys/kern/kern_kthread.c Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/sys/kern/kern_kthread.c Mon Oct 23 18:25:21 2017 (r324932) @@ -274,6 +274,7 @@ kthread_add(void (*func)(void *), void *arg, struct pr bzero(&newtd->td_startzero, __rangeof(struct thread, td_startzero, td_endzero)); newtd->td_sleeptimo = 0; + bzero(&newtd->td_si, sizeof(newtd->td_si)); bcopy(&oldtd->td_startcopy, &newtd->td_startcopy, __rangeof(struct thread, td_startcopy, td_endcopy)); newtd->td_sa = oldtd->td_sa; Modified: stable/11/sys/kern/kern_sig.c ============================================================================== --- stable/11/sys/kern/kern_sig.c Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/sys/kern/kern_sig.c Mon Oct 23 18:25:21 2017 (r324932) @@ -1243,6 +1243,19 @@ sys_sigwaitinfo(struct thread *td, struct sigwaitinfo_ return (error); } +static void +proc_td_siginfo_capture(struct thread *td, siginfo_t *si) +{ + struct thread *thr; + + FOREACH_THREAD_IN_PROC(td->td_proc, thr) { + if (thr == td) + thr->td_si = *si; + else + thr->td_si.si_signo = 0; + } +} + int kern_sigtimedwait(struct thread *td, sigset_t waitset, ksiginfo_t *ksi, struct timespec *timeout) @@ -1351,8 +1364,10 @@ kern_sigtimedwait(struct thread *td, sigset_t waitset, ktrpsig(sig, action, &td->td_sigmask, ksi->ksi_code); } #endif - if (sig == SIGKILL) + if (sig == SIGKILL) { + proc_td_siginfo_capture(td, &ksi->ksi_info); sigexit(td, sig); + } } PROC_UNLOCK(p); return (error); @@ -2805,6 +2820,7 @@ issignal(struct thread *td) struct sigqueue *queue; sigset_t sigpending; int prop, sig, traced; + ksiginfo_t ksi; p = td->td_proc; ps = p->p_sigacts; @@ -2860,14 +2876,15 @@ issignal(struct thread *td) * be thrown away. */ queue = &td->td_sigqueue; - td->td_dbgksi.ksi_signo = 0; - if (sigqueue_get(queue, sig, &td->td_dbgksi) == 0) { + ksiginfo_init(&ksi); + if (sigqueue_get(queue, sig, &ksi) == 0) { queue = &p->p_sigqueue; - sigqueue_get(queue, sig, &td->td_dbgksi); + sigqueue_get(queue, sig, &ksi); } + td->td_si = ksi.ksi_info; mtx_unlock(&ps->ps_mtx); - sig = ptracestop(td, sig, &td->td_dbgksi); + sig = ptracestop(td, sig, &ksi); mtx_lock(&ps->ps_mtx); /* @@ -3039,6 +3056,7 @@ postsig(int sig) * the process. (Other cases were ignored above.) */ mtx_unlock(&ps->ps_mtx); + proc_td_siginfo_capture(td, &ksi.ksi_info); sigexit(td, sig); /* NOTREACHED */ } else { Modified: stable/11/sys/kern/kern_thr.c ============================================================================== --- stable/11/sys/kern/kern_thr.c Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/sys/kern/kern_thr.c Mon Oct 23 18:25:21 2017 (r324932) @@ -233,6 +233,7 @@ thread_create(struct thread *td, struct rtprio *rtp, bzero(&newtd->td_startzero, __rangeof(struct thread, td_startzero, td_endzero)); newtd->td_sleeptimo = 0; + bzero(&newtd->td_si, sizeof(newtd->td_si)); bcopy(&td->td_startcopy, &newtd->td_startcopy, __rangeof(struct thread, td_startcopy, td_endcopy)); newtd->td_sa = td->td_sa; Modified: stable/11/sys/kern/sys_process.c ============================================================================== --- stable/11/sys/kern/sys_process.c Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/sys/kern/sys_process.c Mon Oct 23 18:25:21 2017 (r324932) @@ -1335,7 +1335,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, voi pl->pl_flags = 0; if (td2->td_dbgflags & TDB_XSIG) { pl->pl_event = PL_EVENT_SIGNAL; - if (td2->td_dbgksi.ksi_signo != 0 && + if (td2->td_si.si_signo != 0 && #ifdef COMPAT_FREEBSD32 ((!wrap32 && data >= offsetof(struct ptrace_lwpinfo, pl_siginfo) + sizeof(pl->pl_siginfo)) || @@ -1347,7 +1347,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, voi #endif ){ pl->pl_flags |= PL_FLAG_SI; - pl->pl_siginfo = td2->td_dbgksi.ksi_info; + pl->pl_siginfo = td2->td_si; } } if ((pl->pl_flags & PL_FLAG_SI) == 0) Modified: stable/11/sys/sys/elf_common.h ============================================================================== --- stable/11/sys/sys/elf_common.h Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/sys/sys/elf_common.h Mon Oct 23 18:25:21 2017 (r324932) @@ -1,4 +1,5 @@ /*- + * Copyright (c) 2017 Dell EMC * Copyright (c) 2000, 2001, 2008, 2011, David E. O'Brien * Copyright (c) 1998 John D. Polstra. * All rights reserved. @@ -753,6 +754,7 @@ typedef struct { #define NT_PROCSTAT_OSREL 14 /* Procstat osreldate data. */ #define NT_PROCSTAT_PSSTRINGS 15 /* Procstat ps_strings data. */ #define NT_PROCSTAT_AUXV 16 /* Procstat auxv data. */ +#define NT_PTLWPINFO 17 /* Thread ptrace miscellaneous info. */ #define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */ #define NT_X86_XSTATE 0x202 /* x86 XSAVE extended state. */ Modified: stable/11/sys/sys/proc.h ============================================================================== --- stable/11/sys/sys/proc.h Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/sys/sys/proc.h Mon Oct 23 18:25:21 2017 (r324932) @@ -275,7 +275,7 @@ struct thread { char td_name[MAXCOMLEN + 1]; /* (*) Thread name. */ struct file *td_fpop; /* (k) file referencing cdev under op */ int td_dbgflags; /* (c) Userland debugger flags */ - struct ksiginfo td_dbgksi; /* (c) ksi reflected to debugger. */ + uint64_t padding3[14]; int td_ng_outbound; /* (k) Thread entered ng from above. */ struct osd td_osd; /* (k) Object specific data. */ struct vm_map_entry *td_map_def_user; /* (k) Deferred entries. */ @@ -346,6 +346,7 @@ struct thread { #define td_siglist td_sigqueue.sq_signals struct syscall_args td_sa; /* (kx) Syscall parameters. Copied on fork for child tracing. */ + siginfo_t td_si; /* (c) For debugger or core file */ }; struct thread0_storage { Modified: stable/11/usr.bin/gcore/elfcore.c ============================================================================== --- stable/11/usr.bin/gcore/elfcore.c Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/usr.bin/gcore/elfcore.c Mon Oct 23 18:25:21 2017 (r324932) @@ -1,4 +1,5 @@ /*- + * Copyright (c) 2017 Dell EMC * Copyright (c) 2007 Sandvine Incorporated * Copyright (c) 1998 John D. Polstra * All rights reserved. @@ -102,6 +103,7 @@ static void *elf_note_fpregset(void *, size_t *); static void *elf_note_prpsinfo(void *, size_t *); static void *elf_note_prstatus(void *, size_t *); static void *elf_note_thrmisc(void *, size_t *); +static void *elf_note_ptlwpinfo(void *, size_t *); #if defined(__i386__) || defined(__amd64__) static void *elf_note_x86_xstate(void *, size_t *); #endif @@ -358,6 +360,7 @@ elf_putnotes(pid_t pid, struct sbuf *sb, size_t *sizep elf_putnote(NT_PRSTATUS, elf_note_prstatus, tids + i, sb); elf_putnote(NT_FPREGSET, elf_note_fpregset, tids + i, sb); elf_putnote(NT_THRMISC, elf_note_thrmisc, tids + i, sb); + elf_putnote(NT_PTLWPINFO, elf_note_ptlwpinfo, tids + i, sb); #if defined(__i386__) || defined(__amd64__) elf_putnote(NT_X86_XSTATE, elf_note_x86_xstate, tids + i, sb); #endif @@ -659,6 +662,24 @@ elf_note_thrmisc(void *arg, size_t *sizep) *sizep = sizeof(*thrmisc); return (thrmisc); +} + +static void * +elf_note_ptlwpinfo(void *arg, size_t *sizep) +{ + lwpid_t tid; + void *p; + + tid = *(lwpid_t *)arg; + p = calloc(1, sizeof(int) + sizeof(struct ptrace_lwpinfo)); + if (p == NULL) + errx(1, "out of memory"); + *(int *)p = sizeof(struct ptrace_lwpinfo); + ptrace(PT_LWPINFO, tid, + (char *)p + sizeof (int), sizeof(struct ptrace_lwpinfo)); + + *sizep = sizeof(int) + sizeof(struct ptrace_lwpinfo); + return (p); } #if defined(__i386__) || defined(__amd64__) Modified: stable/11/usr.bin/procstat/Makefile ============================================================================== --- stable/11/usr.bin/procstat/Makefile Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/usr.bin/procstat/Makefile Mon Oct 23 18:25:21 2017 (r324932) @@ -13,6 +13,7 @@ SRCS= procstat.c \ procstat_cs.c \ procstat_files.c \ procstat_kstack.c \ + procstat_ptlwpinfo.c \ procstat_rlimit.c \ procstat_rusage.c \ procstat_sigs.c \ Modified: stable/11/usr.bin/procstat/procstat.1 ============================================================================== --- stable/11/usr.bin/procstat/procstat.1 Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/usr.bin/procstat/procstat.1 Mon Oct 23 18:25:21 2017 (r324932) @@ -38,7 +38,7 @@ .Op Fl M Ar core .Op Fl N Ar system .Op Fl w Ar interval -.Op Fl b | c | e | f | i | j | k | l | r | s | S | t | v | x +.Op Fl b | c | e | f | i | j | k | l | L | r | s | S | t | v | x .Op Fl a | Ar pid | Ar core ... .Sh DESCRIPTION The @@ -81,6 +81,8 @@ If the flag is repeated, function offsets as well as f printed. .It Fl l Display resource limits for the process. +.It Fl L +Display LWP info for the process pertaining to it's signal driven exit. .It Fl r Display resource usage information for the process. .It Fl s Modified: stable/11/usr.bin/procstat/procstat.c ============================================================================== --- stable/11/usr.bin/procstat/procstat.c Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/usr.bin/procstat/procstat.c Mon Oct 23 18:25:21 2017 (r324932) @@ -1,6 +1,7 @@ /*- * Copyright (c) 2007, 2011 Robert N. M. Watson * Copyright (c) 2015 Allan Jude + * Copyright (c) 2017 Dell EMC * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,8 +42,8 @@ #include "procstat.h" -static int aflag, bflag, cflag, eflag, fflag, iflag, jflag, kflag, lflag, rflag; -static int sflag, tflag, vflag, xflag, Sflag; +static int aflag, bflag, cflag, eflag, fflag, iflag, jflag, kflag; +static int lflag, Lflag, rflag, sflag, tflag, vflag, xflag, Sflag; int hflag, nflag, Cflag, Hflag; static void @@ -85,6 +86,8 @@ procstat(struct procstat *prstat, struct kinfo_proc *k procstat_kstack(prstat, kipp, kflag); else if (lflag) procstat_rlimit(prstat, kipp); + else if (Lflag) + procstat_ptlwpinfo(prstat); else if (rflag) procstat_rusage(prstat, kipp); else if (sflag) @@ -162,7 +165,7 @@ main(int argc, char *argv[]) argc = xo_parse_args(argc, argv); xocontainer = "basic"; - while ((ch = getopt(argc, argv, "abCcefHhijklM:N:nrSstvw:x")) != -1) { + while ((ch = getopt(argc, argv, "abCcefHhijklLM:N:nrSstvw:x")) != -1) { switch (ch) { case 'C': Cflag++; @@ -224,6 +227,11 @@ main(int argc, char *argv[]) case 'l': lflag++; xocontainer = "rlimit"; + break; + + case 'L': + Lflag++; + xocontainer = "ptlwpinfo"; break; case 'n': Modified: stable/11/usr.bin/procstat/procstat.h ============================================================================== --- stable/11/usr.bin/procstat/procstat.h Mon Oct 23 17:11:18 2017 (r324931) +++ stable/11/usr.bin/procstat/procstat.h Mon Oct 23 18:25:21 2017 (r324932) @@ -1,6 +1,7 @@ /*- * Copyright (c) 2007 Robert N. M. Watson * Copyright (c) 2015 Allan Jude + * Copyright (c) 2017 Dell EMC * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,6 +51,7 @@ void procstat_env(struct procstat *prstat, struct kinf void procstat_files(struct procstat *prstat, struct kinfo_proc *kipp); void procstat_kstack(struct procstat *prstat, struct kinfo_proc *kipp, int kflag); +void procstat_ptlwpinfo(struct procstat *prstat); void procstat_rlimit(struct procstat *prstat, struct kinfo_proc *kipp); void procstat_rusage(struct procstat *prstat, struct kinfo_proc *kipp); void procstat_sigs(struct procstat *prstat, struct kinfo_proc *kipp); Copied: stable/11/usr.bin/procstat/procstat_ptlwpinfo.c (from r316286, head/usr.bin/procstat/procstat_ptlwpinfo.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/usr.bin/procstat/procstat_ptlwpinfo.c Mon Oct 23 18:25:21 2017 (r324932, copy of r316286, head/usr.bin/procstat/procstat_ptlwpinfo.c) @@ -0,0 +1,91 @@ +/*- + * Copyright (c) 2017 Dell EMC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + #include + __FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include + +#include "procstat.h" + +void +procstat_ptlwpinfo(struct procstat *prstat) +{ + struct ptrace_lwpinfo *pl; + unsigned int count, i; + + pl = procstat_getptlwpinfo(prstat, &count); + if (pl == NULL) + return; + + if (!hflag) + xo_emit("{:/%6s %7s %5s %5s %5s %6s %5s} {[:/%d}{:/%s}{]:}" + " {:/%s}\n", + "LWPID", "EVENT", "SIGNO", "CODE", "ERRNO", "PID", "UID", + 2 * sizeof(void *) + 2, "ADDR", "TDNAME"); + + for (i = 0; i < count; i++) { + xo_emit("{:lpwid/%6d} ", pl[i].pl_lwpid); + switch (pl[i].pl_event) { + case PL_EVENT_NONE: + xo_emit("{eq:event/none}{d:event/%7s} ", "none"); + break; + case PL_EVENT_SIGNAL: + xo_emit("{eq:event/signal}{d:event/%7s} ", "signal"); + break; + default: + xo_emit("{eq:event/unknown}{d:event/%7s} ", "?"); + break; + } + if ((pl[i].pl_flags & PL_FLAG_SI) != 0) { + siginfo_t *si; + + si = &pl[i].pl_siginfo; + xo_emit("{:signal_number/%5d} ", si->si_signo); + xo_emit("{:code/%5d} ", si->si_code); + xo_emit("{:signal_errno/%5d} ", si->si_errno); + xo_emit("{:process_id/%6d} ", si->si_pid); + xo_emit("{:user_id/%5d} ", si->si_uid); + xo_emit("{[:/%d}{:address/%p}{]:} ", + 2 * sizeof(void *) + 2, si->si_addr); + } else { + xo_emit("{:signal_number/%5s} ", "-"); + xo_emit("{:code/%5s} ", "-"); + xo_emit("{:signal_errno/%5s} ", "-"); + xo_emit("{:process_id/%6s} ", "-"); + xo_emit("{:user_id/%5s} ", "-"); + xo_emit("{[:/%d}{:address/%s}{]:} ", + 2 * sizeof(void *) + 2, "-"); + } + xo_emit("{:tdname/%s}\n", pl[i].pl_tdname); + } + + procstat_freeptlwpinfo(prstat, pl); +} From owner-svn-src-stable-11@freebsd.org Mon Oct 23 19:00:18 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F2F66E52785; Mon, 23 Oct 2017 19:00:18 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C12F08007A; Mon, 23 Oct 2017 19:00:18 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9NJ0IlM004895; Mon, 23 Oct 2017 19:00:18 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9NJ0H1e004894; Mon, 23 Oct 2017 19:00:17 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201710231900.v9NJ0H1e004894@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 23 Oct 2017 19:00:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324933 - stable/11/sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: bdrewery X-SVN-Commit-Paths: stable/11/sys/sys X-SVN-Commit-Revision: 324933 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2017 19:00:19 -0000 Author: bdrewery Date: Mon Oct 23 19:00:17 2017 New Revision: 324933 URL: https://svnweb.freebsd.org/changeset/base/324933 Log: struct ksiginfo has MD size, so use it as the padding type to avoid the wrong size. This is a direct commit to stable/11 to fix r324932. Spotted by: kib Modified: stable/11/sys/sys/proc.h Modified: stable/11/sys/sys/proc.h ============================================================================== --- stable/11/sys/sys/proc.h Mon Oct 23 18:25:21 2017 (r324932) +++ stable/11/sys/sys/proc.h Mon Oct 23 19:00:17 2017 (r324933) @@ -275,7 +275,7 @@ struct thread { char td_name[MAXCOMLEN + 1]; /* (*) Thread name. */ struct file *td_fpop; /* (k) file referencing cdev under op */ int td_dbgflags; /* (c) Userland debugger flags */ - uint64_t padding3[14]; + struct ksiginfo padding3; int td_ng_outbound; /* (k) Thread entered ng from above. */ struct osd td_osd; /* (k) Object specific data. */ struct vm_map_entry *td_map_def_user; /* (k) Deferred entries. */ From owner-svn-src-stable-11@freebsd.org Mon Oct 23 19:03:38 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2BAD9E52922; Mon, 23 Oct 2017 19:03:38 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E39988046B; Mon, 23 Oct 2017 19:03:37 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9NJ3ajQ008828; Mon, 23 Oct 2017 19:03:36 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9NJ3aMD008827; Mon, 23 Oct 2017 19:03:36 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201710231903.v9NJ3aMD008827@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Mon, 23 Oct 2017 19:03:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324934 - stable/11/sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: bdrewery X-SVN-Commit-Paths: stable/11/sys/sys X-SVN-Commit-Revision: 324934 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2017 19:03:38 -0000 Author: bdrewery Date: Mon Oct 23 19:03:36 2017 New Revision: 324934 URL: https://svnweb.freebsd.org/changeset/base/324934 Log: Fix struct thread padding field names. Direct commit to stable/11. Modified: stable/11/sys/sys/proc.h Modified: stable/11/sys/sys/proc.h ============================================================================== --- stable/11/sys/sys/proc.h Mon Oct 23 19:00:17 2017 (r324933) +++ stable/11/sys/sys/proc.h Mon Oct 23 19:03:36 2017 (r324934) @@ -225,8 +225,8 @@ struct thread { struct umtx_q *td_umtxq; /* (c?) Link for when we're blocked. */ struct vm_domain_policy td_vm_dom_policy; /* (c) current numa domain policy */ lwpid_t td_tid; /* (b) Thread ID. */ - uint64_t padding1[4]; - void *padding2[4]; + uint64_t td_padding1[4]; + void *td_padding2[4]; u_char td_lend_user_pri; /* (t) Lend user pri. */ /* Cleared during fork1() */ @@ -275,7 +275,7 @@ struct thread { char td_name[MAXCOMLEN + 1]; /* (*) Thread name. */ struct file *td_fpop; /* (k) file referencing cdev under op */ int td_dbgflags; /* (c) Userland debugger flags */ - struct ksiginfo padding3; + struct ksiginfo td_padding3; int td_ng_outbound; /* (k) Thread entered ng from above. */ struct osd td_osd; /* (k) Object specific data. */ struct vm_map_entry *td_map_def_user; /* (k) Deferred entries. */ @@ -296,8 +296,8 @@ struct thread { u_char td_pri_class; /* (t) Scheduling class. */ u_char td_user_pri; /* (t) User pri from estcpu and nice. */ u_char td_base_user_pri; /* (t) Base user pri */ - u_int td_padding3; u_int td_padding4; + u_int td_padding5; uintptr_t td_rb_list; /* (k) Robust list head. */ uintptr_t td_rbp_list; /* (k) Robust priv list head. */ uintptr_t td_rb_inact; /* (k) Current in-action mutex loc. */ From owner-svn-src-stable-11@freebsd.org Mon Oct 23 19:15:52 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A4551E52BB8; Mon, 23 Oct 2017 19:15:52 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6FD98809D9; Mon, 23 Oct 2017 19:15:52 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9NJFpP9013178; Mon, 23 Oct 2017 19:15:51 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9NJFpCj013177; Mon, 23 Oct 2017 19:15:51 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201710231915.v9NJFpCj013177@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 23 Oct 2017 19:15:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324935 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 324935 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2017 19:15:52 -0000 Author: kib Date: Mon Oct 23 19:15:51 2017 New Revision: 324935 URL: https://svnweb.freebsd.org/changeset/base/324935 Log: MFC r324671: Re-evaluate thread' signal mask after ptracestop(). Modified: stable/11/sys/kern/kern_sig.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_sig.c ============================================================================== --- stable/11/sys/kern/kern_sig.c Mon Oct 23 19:03:36 2017 (r324934) +++ stable/11/sys/kern/kern_sig.c Mon Oct 23 19:15:51 2017 (r324935) @@ -2888,15 +2888,32 @@ issignal(struct thread *td) mtx_lock(&ps->ps_mtx); /* - * Keep looking if the debugger discarded the signal - * or replaced it with a masked signal. - * - * If the traced bit got turned off, go back up - * to the top to rescan signals. This ensures - * that p_sig* and p_sigact are consistent. + * Keep looking if the debugger discarded or + * replaced the signal. */ - if (sig == 0 || (p->p_flag & P_TRACED) == 0) + if (sig == 0) continue; + + /* + * If the signal became masked, re-queue it. + */ + if (SIGISMEMBER(td->td_sigmask, sig)) { + ksi.ksi_flags |= KSI_HEAD; + sigqueue_add(&p->p_sigqueue, sig, &ksi); + continue; + } + + /* + * If the traced bit got turned off, requeue + * the signal and go back up to the top to + * rescan signals. This ensures that p_sig* + * and p_sigact are consistent. + */ + if ((p->p_flag & P_TRACED) == 0) { + ksi.ksi_flags |= KSI_HEAD; + sigqueue_add(queue, sig, &ksi); + continue; + } } prop = sigprop(sig); From owner-svn-src-stable-11@freebsd.org Mon Oct 23 22:50:38 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C75BEE571CB; Mon, 23 Oct 2017 22:50:38 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8FDD73811; Mon, 23 Oct 2017 22:50:38 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9NMobZX002964; Mon, 23 Oct 2017 22:50:37 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9NMobj6002963; Mon, 23 Oct 2017 22:50:37 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201710232250.v9NMobj6002963@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Mon, 23 Oct 2017 22:50:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324939 - stable/11/usr.sbin/diskinfo X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/11/usr.sbin/diskinfo X-SVN-Commit-Revision: 324939 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2017 22:50:38 -0000 Author: asomers Date: Mon Oct 23 22:50:37 2017 New Revision: 324939 URL: https://svnweb.freebsd.org/changeset/base/324939 Log: MFC r324241: Fix copy/paste error in diskinfo.8 from r320555 Sponsored by: Spectra Logic Corp Modified: stable/11/usr.sbin/diskinfo/diskinfo.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/diskinfo/diskinfo.8 ============================================================================== --- stable/11/usr.sbin/diskinfo/diskinfo.8 Mon Oct 23 21:31:04 2017 (r324938) +++ stable/11/usr.sbin/diskinfo/diskinfo.8 Mon Oct 23 22:50:37 2017 (r324939) @@ -64,7 +64,7 @@ Return the physical path of the disk. This is a string that identifies the physical path to the disk in the storage enclosure. .It Fl s -Return the disk serial number +Return the disk ident, usually the serial number. .It Fl S Perform synchronous random write test (ZFS SLOG test), measuring time required to write data blocks of different size and @@ -82,13 +82,6 @@ with the following fields: device name, sectorsize, me media size in sectors, stripe size, stripe offset, firmware cylinders, firmware heads, and firmware sectors. The last three fields are only present if the information is available. -.It Fl i -Return the disk ident, usually the serial number. -.It Fl p -Return the physical path of the disk. -This is a string that identifies the physical path to the disk in the -storage enclosure. -.El .Sh HISTORY The .Nm From owner-svn-src-stable-11@freebsd.org Tue Oct 24 00:32:22 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0D62BE2FC69; Tue, 24 Oct 2017 00:32:22 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CEABF664C9; Tue, 24 Oct 2017 00:32:21 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9O0WLD8046725; Tue, 24 Oct 2017 00:32:21 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9O0WLtX046724; Tue, 24 Oct 2017 00:32:21 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201710240032.v9O0WLtX046724@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 24 Oct 2017 00:32:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324942 - stable/11/lib/libc/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/lib/libc/sys X-SVN-Commit-Revision: 324942 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Oct 2017 00:32:22 -0000 Author: emaste Date: Tue Oct 24 00:32:20 2017 New Revision: 324942 URL: https://svnweb.freebsd.org/changeset/base/324942 Log: MFC r324683: write.2: correct maximum nbytes size for EINVAL error In FreeBSD 11 and later debug.iosize_max_clamp defaults to 0, and the maximum nbytes count for write(2) is SSIZE_MAX. Update the man page to document this, and mention the sysctl that can be set to obtain the previous behaviour. PR: 196666 Sponsored by: The FreeBSD Foundation Modified: stable/11/lib/libc/sys/write.2 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/sys/write.2 ============================================================================== --- stable/11/lib/libc/sys/write.2 Mon Oct 23 23:12:01 2017 (r324941) +++ stable/11/lib/libc/sys/write.2 Tue Oct 24 00:32:20 2017 (r324942) @@ -28,7 +28,7 @@ .\" @(#)write.2 8.5 (Berkeley) 4/2/94 .\" $FreeBSD$ .\" -.Dd December 15, 2015 +.Dd October 23, 2017 .Dt WRITE 2 .Os .Sh NAME @@ -199,7 +199,12 @@ to enable writing on the disk label area. The value .Fa nbytes is greater than -.Dv INT_MAX . +.Dv SSIZE_MAX +(or greater than +.Dv INT_MAX , +if the sysctl +.Va debug.iosize_max_clamp +is non-zero). .El .Pp In addition, From owner-svn-src-stable-11@freebsd.org Tue Oct 24 00:51:13 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D23DE30182; Tue, 24 Oct 2017 00:51:13 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DDFD366CA0; Tue, 24 Oct 2017 00:51:12 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9O0pCNe053675; Tue, 24 Oct 2017 00:51:12 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9O0pBkp053674; Tue, 24 Oct 2017 00:51:12 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201710240051.v9O0pBkp053674@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Tue, 24 Oct 2017 00:51:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324943 - stable/11/tests/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: bdrewery X-SVN-Commit-Paths: stable/11/tests/sys/kern X-SVN-Commit-Revision: 324943 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Oct 2017 00:51:13 -0000 Author: bdrewery Date: Tue Oct 24 00:51:11 2017 New Revision: 324943 URL: https://svnweb.freebsd.org/changeset/base/324943 Log: MFC r318246,r324566,r324668,r324701: r318246: Add a regression test for r318191. r324566: Fix shadowed variable hidden by WARNS changing to 3 in r313006. r324668: This child is expected to exit on SIGTRAP, don't leave a core behind. r324701: Add a test for r324671 along with some other masked tests. Modified: stable/11/tests/sys/kern/ptrace_test.c Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/kern/ptrace_test.c ============================================================================== --- stable/11/tests/sys/kern/ptrace_test.c Tue Oct 24 00:32:20 2017 (r324942) +++ stable/11/tests/sys/kern/ptrace_test.c Tue Oct 24 00:51:11 2017 (r324943) @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2401,7 +2402,107 @@ ATF_TC_BODY(ptrace__PT_CONTINUE_with_signal_full_sigqu ATF_REQUIRE(errno == ECHILD); } +static sem_t sigusr1_sem; +static int got_usr1; + +static void +sigusr1_sempost_handler(int sig __unused) +{ + + got_usr1++; + CHILD_REQUIRE(sem_post(&sigusr1_sem) == 0); +} + /* + * Verify that even if the signal queue is full for a child process, + * and the signal is masked, a PT_CONTINUE with a signal will not + * result in loss of that signal. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_CONTINUE_with_signal_masked_full_sigqueue); +ATF_TC_BODY(ptrace__PT_CONTINUE_with_signal_masked_full_sigqueue, tc) +{ + struct ptrace_lwpinfo pl; + pid_t fpid, wpid; + int status, err; + int max_pending_per_proc; + size_t len; + int i; + sigset_t sigmask; + + ATF_REQUIRE(signal(SIGUSR2, handler) != SIG_ERR); + ATF_REQUIRE(sem_init(&sigusr1_sem, 0, 0) == 0); + ATF_REQUIRE(signal(SIGUSR1, sigusr1_sempost_handler) != SIG_ERR); + + got_usr1 = 0; + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + CHILD_REQUIRE(sigemptyset(&sigmask) == 0); + CHILD_REQUIRE(sigaddset(&sigmask, SIGUSR1) == 0); + CHILD_REQUIRE(sigprocmask(SIG_BLOCK, &sigmask, NULL) == 0); + + trace_me(); + CHILD_REQUIRE(got_usr1 == 0); + + /* Allow the pending SIGUSR1 in now. */ + CHILD_REQUIRE(sigprocmask(SIG_UNBLOCK, &sigmask, NULL) == 0); + /* Wait to receive the SIGUSR1. */ + do { + err = sem_wait(&sigusr1_sem); + CHILD_REQUIRE(err == 0 || errno == EINTR); + } while (err != 0 && errno == EINTR); + CHILD_REQUIRE(got_usr1 == 1); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + len = sizeof(max_pending_per_proc); + ATF_REQUIRE(sysctlbyname("kern.sigqueue.max_pending_per_proc", + &max_pending_per_proc, &len, NULL, 0) == 0); + + /* Fill the signal queue. */ + for (i = 0; i < max_pending_per_proc; ++i) + ATF_REQUIRE(kill(fpid, SIGUSR2) == 0); + + /* Continue with signal. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, SIGUSR1) == 0); + + /* Collect and ignore all of the SIGUSR2. */ + for (i = 0; i < max_pending_per_proc; ++i) { + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGUSR2); + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + } + + /* Now our PT_CONTINUE'd SIGUSR1 should cause a stop after unmask. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGUSR1); + ATF_REQUIRE(ptrace(PT_LWPINFO, fpid, (caddr_t)&pl, sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_siginfo.si_signo == SIGUSR1); + + /* Continue the child, ignoring the SIGUSR1. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The last wait() should report exit after receiving SIGUSR1. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFEXITED(status)); + ATF_REQUIRE(WEXITSTATUS(status) == 1); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + +/* * Verify that, after stopping due to a signal, that signal can be * replaced with another signal. */ @@ -2466,12 +2567,16 @@ ATF_TC_WITHOUT_HEAD(ptrace__PT_CONTINUE_with_sigtrap_s ATF_TC_BODY(ptrace__PT_CONTINUE_with_sigtrap_system_call_entry, tc) { struct ptrace_lwpinfo pl; + struct rlimit rl; pid_t fpid, wpid; int status; ATF_REQUIRE((fpid = fork()) != -1); if (fpid == 0) { trace_me(); + /* SIGTRAP expected to cause exit on syscall entry. */ + rl.rlim_cur = rl.rlim_max = 0; + ATF_REQUIRE(setrlimit(RLIMIT_CORE, &rl) == 0); getpid(); exit(1); } @@ -2669,15 +2774,6 @@ ATF_TC_BODY(ptrace__PT_CONTINUE_with_signal_kqueue, tc ATF_REQUIRE(errno == ECHILD); } -static sem_t sigusr1_sem; - -static void -sigusr1_sempost_handler(int sig __unused) -{ - - CHILD_REQUIRE(sem_post(&sigusr1_sem) == 0); -} - static void * signal_thread(void *arg) { @@ -2713,6 +2809,148 @@ signal_thread(void *arg) } /* + * Verify that a traced process with blocked signal received the + * signal from kill() once unmasked. + */ +ATF_TC_WITHOUT_HEAD(ptrace__killed_with_sigmask); +ATF_TC_BODY(ptrace__killed_with_sigmask, tc) +{ + struct ptrace_lwpinfo pl; + pid_t fpid, wpid; + int status, err; + sigset_t sigmask; + + ATF_REQUIRE(sem_init(&sigusr1_sem, 0, 0) == 0); + ATF_REQUIRE(signal(SIGUSR1, sigusr1_sempost_handler) != SIG_ERR); + got_usr1 = 0; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + CHILD_REQUIRE(sigemptyset(&sigmask) == 0); + CHILD_REQUIRE(sigaddset(&sigmask, SIGUSR1) == 0); + CHILD_REQUIRE(sigprocmask(SIG_BLOCK, &sigmask, NULL) == 0); + + trace_me(); + CHILD_REQUIRE(got_usr1 == 0); + + /* Allow the pending SIGUSR1 in now. */ + CHILD_REQUIRE(sigprocmask(SIG_UNBLOCK, &sigmask, NULL) == 0); + /* Wait to receive a SIGUSR1. */ + do { + err = sem_wait(&sigusr1_sem); + CHILD_REQUIRE(err == 0 || errno == EINTR); + } while (err != 0 && errno == EINTR); + CHILD_REQUIRE(got_usr1 == 1); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + ATF_REQUIRE(ptrace(PT_LWPINFO, fpid, (caddr_t)&pl, sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_siginfo.si_signo == SIGSTOP); + + /* Send blocked SIGUSR1 which should cause a stop. */ + ATF_REQUIRE(kill(fpid, SIGUSR1) == 0); + + /* Continue the child ignoring the SIGSTOP. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The next wait() should report the kill(SIGUSR1) was received. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGUSR1); + ATF_REQUIRE(ptrace(PT_LWPINFO, fpid, (caddr_t)&pl, sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_siginfo.si_signo == SIGUSR1); + + /* Continue the child, allowing in the SIGUSR1. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, SIGUSR1) == 0); + + /* The last wait() should report normal exit with code 1. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFEXITED(status)); + ATF_REQUIRE(WEXITSTATUS(status) == 1); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + +/* + * Verify that a traced process with blocked signal received the + * signal from PT_CONTINUE once unmasked. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_CONTINUE_with_sigmask); +ATF_TC_BODY(ptrace__PT_CONTINUE_with_sigmask, tc) +{ + struct ptrace_lwpinfo pl; + pid_t fpid, wpid; + int status, err; + sigset_t sigmask; + + ATF_REQUIRE(sem_init(&sigusr1_sem, 0, 0) == 0); + ATF_REQUIRE(signal(SIGUSR1, sigusr1_sempost_handler) != SIG_ERR); + got_usr1 = 0; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + CHILD_REQUIRE(sigemptyset(&sigmask) == 0); + CHILD_REQUIRE(sigaddset(&sigmask, SIGUSR1) == 0); + CHILD_REQUIRE(sigprocmask(SIG_BLOCK, &sigmask, NULL) == 0); + + trace_me(); + CHILD_REQUIRE(got_usr1 == 0); + + /* Allow the pending SIGUSR1 in now. */ + CHILD_REQUIRE(sigprocmask(SIG_UNBLOCK, &sigmask, NULL) == 0); + /* Wait to receive a SIGUSR1. */ + do { + err = sem_wait(&sigusr1_sem); + CHILD_REQUIRE(err == 0 || errno == EINTR); + } while (err != 0 && errno == EINTR); + + CHILD_REQUIRE(got_usr1 == 1); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + ATF_REQUIRE(ptrace(PT_LWPINFO, fpid, (caddr_t)&pl, sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_siginfo.si_signo == SIGSTOP); + + /* Continue the child replacing SIGSTOP with SIGUSR1. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, SIGUSR1) == 0); + + /* The next wait() should report the SIGUSR1 was received. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGUSR1); + ATF_REQUIRE(ptrace(PT_LWPINFO, fpid, (caddr_t)&pl, sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_siginfo.si_signo == SIGUSR1); + + /* Continue the child, ignoring the SIGUSR1. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The last wait() should report normal exit with code 1. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFEXITED(status)); + ATF_REQUIRE(WEXITSTATUS(status) == 1); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + +/* * Verify that if ptrace stops due to a signal but continues with * a different signal that the new signal is routed to a thread * that can accept it, and that that thread is awakened by the signal @@ -3046,6 +3284,99 @@ ATF_TC_BODY(ptrace__event_mask_sigkill_discard, tc) ATF_REQUIRE(errno == ECHILD); } +static void * +flock_thread(void *arg) +{ + int fd; + + fd = *(int *)arg; + (void)flock(fd, LOCK_EX); + (void)flock(fd, LOCK_UN); + return (NULL); +} + +/* + * Verify that PT_ATTACH will suspend threads sleeping in an SBDRY section. + * We rely on the fact that the lockf implementation sets SBDRY before blocking + * on a lock. This is a regression test for r318191. + */ +ATF_TC_WITHOUT_HEAD(ptrace__PT_ATTACH_with_SBDRY_thread); +ATF_TC_BODY(ptrace__PT_ATTACH_with_SBDRY_thread, tc) +{ + pthread_barrier_t barrier; + pthread_barrierattr_t battr; + char tmpfile[64]; + pid_t child, wpid; + int error, fd, i, status; + + ATF_REQUIRE(pthread_barrierattr_init(&battr) == 0); + ATF_REQUIRE(pthread_barrierattr_setpshared(&battr, + PTHREAD_PROCESS_SHARED) == 0); + ATF_REQUIRE(pthread_barrier_init(&barrier, &battr, 2) == 0); + + (void)snprintf(tmpfile, sizeof(tmpfile), "./ptrace.XXXXXX"); + fd = mkstemp(tmpfile); + ATF_REQUIRE(fd >= 0); + + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + pthread_t t[2]; + int cfd; + + error = pthread_barrier_wait(&barrier); + if (error != 0 && error != PTHREAD_BARRIER_SERIAL_THREAD) + _exit(1); + + cfd = open(tmpfile, O_RDONLY); + if (cfd < 0) + _exit(1); + + /* + * We want at least two threads blocked on the file lock since + * the SIGSTOP from PT_ATTACH may kick one of them out of + * sleep. + */ + if (pthread_create(&t[0], NULL, flock_thread, &cfd) != 0) + _exit(1); + if (pthread_create(&t[1], NULL, flock_thread, &cfd) != 0) + _exit(1); + if (pthread_join(t[0], NULL) != 0) + _exit(1); + if (pthread_join(t[1], NULL) != 0) + _exit(1); + _exit(0); + } + + ATF_REQUIRE(flock(fd, LOCK_EX) == 0); + + error = pthread_barrier_wait(&barrier); + ATF_REQUIRE(error == 0 || error == PTHREAD_BARRIER_SERIAL_THREAD); + + /* + * Give the child some time to block. Is there a better way to do this? + */ + sleep(1); + + /* + * Attach and give the child 3 seconds to stop. + */ + ATF_REQUIRE(ptrace(PT_ATTACH, child, NULL, 0) == 0); + for (i = 0; i < 3; i++) { + wpid = waitpid(child, &status, WNOHANG); + if (wpid == child && WIFSTOPPED(status) && + WSTOPSIG(status) == SIGSTOP) + break; + sleep(1); + } + ATF_REQUIRE_MSG(i < 3, "failed to stop child process after PT_ATTACH"); + + ATF_REQUIRE(ptrace(PT_DETACH, child, NULL, 0) == 0); + + ATF_REQUIRE(flock(fd, LOCK_UN) == 0); + ATF_REQUIRE(unlink(tmpfile) == 0); + ATF_REQUIRE(close(fd) == 0); +} + ATF_TP_ADD_TCS(tp) { @@ -3085,14 +3416,18 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_signal_system_call_entry_and_exit); ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_signal_full_sigqueue); + ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_signal_masked_full_sigqueue); ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_change_sig); ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_sigtrap_system_call_entry); ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_signal_mix); ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_signal_kqueue); + ATF_TP_ADD_TC(tp, ptrace__killed_with_sigmask); + ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_sigmask); ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_signal_thread_sigmask); ATF_TP_ADD_TC(tp, ptrace__parent_terminate_with_pending_sigstop1); ATF_TP_ADD_TC(tp, ptrace__parent_terminate_with_pending_sigstop2); ATF_TP_ADD_TC(tp, ptrace__event_mask_sigkill_discard); + ATF_TP_ADD_TC(tp, ptrace__PT_ATTACH_with_SBDRY_thread); return (atf_no_error()); } From owner-svn-src-stable-11@freebsd.org Tue Oct 24 06:49:08 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E33AE42486; Tue, 24 Oct 2017 06:49:08 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3A20972BF8; Tue, 24 Oct 2017 06:49:08 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9O6n77R099329; Tue, 24 Oct 2017 06:49:07 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9O6n72b099327; Tue, 24 Oct 2017 06:49:07 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201710240649.v9O6n72b099327@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Tue, 24 Oct 2017 06:49:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324946 - stable/11/contrib/llvm/lib/Target/AArch64 X-SVN-Group: stable-11 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: stable/11/contrib/llvm/lib/Target/AArch64 X-SVN-Commit-Revision: 324946 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Oct 2017 06:49:08 -0000 Author: dim Date: Tue Oct 24 06:49:06 2017 New Revision: 324946 URL: https://svnweb.freebsd.org/changeset/base/324946 Log: MFC r324826: Pull in r316035 from upstream llvm trunk (by Tim Northover): AArch64: account for possible frame index operand in compares. If the address of a local is used in a comparison, AArch64 can fold the address-calculation into the comparison via "adds". Unfortunately, a couple of places (both hit in this one test) are not ready to deal with that yet and just assume the first source operand is a register. This should fix an assertion failure while building the test suite of www/firefox for AArch64. PR: 223048 Modified: stable/11/contrib/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp stable/11/contrib/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp ============================================================================== --- stable/11/contrib/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp Tue Oct 24 05:41:48 2017 (r324945) +++ stable/11/contrib/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp Tue Oct 24 06:49:06 2017 (r324946) @@ -940,6 +940,12 @@ bool AArch64InstrInfo::areMemAccessesTriviallyDisjoint bool AArch64InstrInfo::analyzeCompare(const MachineInstr &MI, unsigned &SrcReg, unsigned &SrcReg2, int &CmpMask, int &CmpValue) const { + // The first operand can be a frame index where we'd normally expect a + // register. + assert(MI.getNumOperands() >= 2 && "All AArch64 cmps should have 2 operands"); + if (!MI.getOperand(1).isReg()) + return false; + switch (MI.getOpcode()) { default: break; Modified: stable/11/contrib/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp ============================================================================== --- stable/11/contrib/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp Tue Oct 24 05:41:48 2017 (r324945) +++ stable/11/contrib/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp Tue Oct 24 06:49:06 2017 (r324946) @@ -167,6 +167,9 @@ AArch64RedundantCopyElimination::knownRegValInBlock( // CMP is an alias for SUBS with a dead destination register. case AArch64::SUBSWri: case AArch64::SUBSXri: { + // Sometimes the first operand is a FrameIndex. Bail if tht happens. + if (!PredI.getOperand(1).isReg()) + return None; MCPhysReg SrcReg = PredI.getOperand(1).getReg(); // Must not be a symbolic immediate. From owner-svn-src-stable-11@freebsd.org Tue Oct 24 08:56:12 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 580F9E45591; Tue, 24 Oct 2017 08:56:12 +0000 (UTC) (envelope-from jch@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0EDB276537; Tue, 24 Oct 2017 08:56:11 +0000 (UTC) (envelope-from jch@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9O8uBjC052604; Tue, 24 Oct 2017 08:56:11 GMT (envelope-from jch@FreeBSD.org) Received: (from jch@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9O8uBk2052603; Tue, 24 Oct 2017 08:56:11 GMT (envelope-from jch@FreeBSD.org) Message-Id: <201710240856.v9O8uBk2052603@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jch set sender to jch@FreeBSD.org using -f From: Julien Charbon Date: Tue, 24 Oct 2017 08:56:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324948 - stable/11/sys/netinet X-SVN-Group: stable-11 X-SVN-Commit-Author: jch X-SVN-Commit-Paths: stable/11/sys/netinet X-SVN-Commit-Revision: 324948 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Oct 2017 08:56:12 -0000 Author: jch Date: Tue Oct 24 08:56:11 2017 New Revision: 324948 URL: https://svnweb.freebsd.org/changeset/base/324948 Log: MFC r324179, r324193: r324179: Fix an infinite loop in tcp_tw_2msl_scan() when an INP_TIMEWAIT inp has been destroyed before its tcptw with INVARIANTS undefined. This is a symmetric change of r307551: A INP_TIMEWAIT inp should not be destroyed before its tcptw, and INVARIANTS will catch this case. If INVARIANTS is undefined it will emit a log(LOG_ERR) and avoid a hard to debug infinite loop in tcp_tw_2msl_scan(). Reported by: Ben Rubson, hselasky Submitted by: hselasky Tested by: Ben Rubson, jch Sponsored by: Verisign, inc Differential Revision: https://reviews.freebsd.org/D12267 r324193: Forgotten bits in r324179: Include sys/syslog.h if INVARIANTS is not defined Modified: stable/11/sys/netinet/tcp_timewait.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet/tcp_timewait.c ============================================================================== --- stable/11/sys/netinet/tcp_timewait.c Tue Oct 24 08:39:05 2017 (r324947) +++ stable/11/sys/netinet/tcp_timewait.c Tue Oct 24 08:56:11 2017 (r324948) @@ -47,6 +47,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifndef INVARIANTS +#include +#endif #include #include @@ -711,10 +714,29 @@ tcp_tw_2msl_scan(int reuse) INP_WLOCK(inp); tw = intotw(inp); if (in_pcbrele_wlocked(inp)) { - KASSERT(tw == NULL, ("%s: held last inp " - "reference but tw not NULL", __func__)); - INP_INFO_RUNLOCK(&V_tcbinfo); - continue; + if (__predict_true(tw == NULL)) { + INP_INFO_RUNLOCK(&V_tcbinfo); + continue; + } else { + /* This should not happen as in TIMEWAIT + * state the inp should not be destroyed + * before its tcptw. If INVARIANTS is + * defined panic. + */ +#ifdef INVARIANTS + panic("%s: Panic before an infinite " + "loop: INP_TIMEWAIT && (INP_FREED " + "|| inp last reference) && tw != " + "NULL", __func__); +#else + log(LOG_ERR, "%s: Avoid an infinite " + "loop: INP_TIMEWAIT && (INP_FREED " + "|| inp last reference) && tw != " + "NULL", __func__); +#endif + INP_INFO_RUNLOCK(&V_tcbinfo); + break; + } } if (tw == NULL) { From owner-svn-src-stable-11@freebsd.org Tue Oct 24 14:33:39 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE2B1E4F3CB; Tue, 24 Oct 2017 14:33:39 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8978428AC; Tue, 24 Oct 2017 14:33:39 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9OEXckS093830; Tue, 24 Oct 2017 14:33:38 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9OEXcbR093829; Tue, 24 Oct 2017 14:33:38 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201710241433.v9OEXcbR093829@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Tue, 24 Oct 2017 14:33:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324955 - stable/11/usr.sbin/mountd X-SVN-Group: stable-11 X-SVN-Commit-Author: manu X-SVN-Commit-Paths: stable/11/usr.sbin/mountd X-SVN-Commit-Revision: 324955 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Oct 2017 14:33:39 -0000 Author: manu Date: Tue Oct 24 14:33:38 2017 New Revision: 324955 URL: https://svnweb.freebsd.org/changeset/base/324955 Log: MFC r324257-r324258 r324257: mountd: Convert exportlist to SLIST Use SLIST from sys/queue.h instead of homebrew linked list for the exportlist. Reviewed by: bapt, rmacklem Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D12502 r324258: mountd: Convert mountlist to SLIST Use SLIST from sys/queue.h instead of homebrew linked list for mountlist. Reviewed by: bapt, rmacklem Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D12504 Modified: stable/11/usr.sbin/mountd/mountd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/mountd/mountd.c ============================================================================== --- stable/11/usr.sbin/mountd/mountd.c Tue Oct 24 14:28:56 2017 (r324954) +++ stable/11/usr.sbin/mountd/mountd.c Tue Oct 24 14:33:38 2017 (r324955) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -91,9 +92,10 @@ __FBSDID("$FreeBSD$"); * Structures for keeping the mount list and export list */ struct mountlist { - struct mountlist *ml_next; char ml_host[MNTNAMLEN+1]; char ml_dirp[MNTPATHLEN+1]; + + SLIST_ENTRY(mountlist) next; }; struct dirlist { @@ -108,7 +110,6 @@ struct dirlist { #define DP_HOSTSET 0x2 struct exportlist { - struct exportlist *ex_next; struct dirlist *ex_dirl; struct dirlist *ex_defdir; int ex_flag; @@ -119,6 +120,8 @@ struct exportlist { int ex_secflavors[MAXSECFLAVORS]; int ex_defnumsecflavors; int ex_defsecflavors[MAXSECFLAVORS]; + + SLIST_ENTRY(exportlist) entries; }; /* ex_flag bits */ #define EX_LINKED 0x1 @@ -222,8 +225,8 @@ static int xdr_fhs(XDR *, caddr_t); static int xdr_mlist(XDR *, caddr_t); static void terminate(int); -static struct exportlist *exphead; -static struct mountlist *mlhead; +static SLIST_HEAD(, exportlist) exphead = SLIST_HEAD_INITIALIZER(exphead); +static SLIST_HEAD(, mountlist) mlhead = SLIST_HEAD_INITIALIZER(mlhead); static struct grouplist *grphead; static char *exnames_default[2] = { _PATH_EXPORTS, NULL }; static char **exnames; @@ -445,8 +448,6 @@ main(int argc, char **argv) argc -= optind; argv += optind; grphead = (struct grouplist *)NULL; - exphead = (struct exportlist *)NULL; - mlhead = (struct mountlist *)NULL; if (argc > 0) exnames = argv; else @@ -1253,8 +1254,7 @@ xdr_mlist(XDR *xdrsp, caddr_t cp __unused) int false = 0; char *strp; - mlp = mlhead; - while (mlp) { + SLIST_FOREACH(mlp, &mlhead, next) { if (!xdr_bool(xdrsp, &true)) return (0); strp = &mlp->ml_host[0]; @@ -1263,7 +1263,6 @@ xdr_mlist(XDR *xdrsp, caddr_t cp __unused) strp = &mlp->ml_dirp[0]; if (!xdr_string(xdrsp, &strp, MNTPATHLEN)) return (0); - mlp = mlp->ml_next; } if (!xdr_bool(xdrsp, &false)) return (0); @@ -1284,8 +1283,8 @@ xdr_explist_common(XDR *xdrsp, caddr_t cp __unused, in sigemptyset(&sighup_mask); sigaddset(&sighup_mask, SIGHUP); sigprocmask(SIG_BLOCK, &sighup_mask, NULL); - ep = exphead; - while (ep) { + + SLIST_FOREACH(ep, &exphead, entries) { putdef = 0; if (put_exlist(ep->ex_dirl, xdrsp, ep->ex_defdir, &putdef, brief)) @@ -1294,7 +1293,6 @@ xdr_explist_common(XDR *xdrsp, caddr_t cp __unused, in put_exlist(ep->ex_defdir, xdrsp, (struct dirlist *)NULL, &putdef, brief)) goto errout; - ep = ep->ex_next; } sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); if (!xdr_bool(xdrsp, &false)) @@ -1397,9 +1395,8 @@ static FILE *exp_file; static void get_exportlist_one(void) { - struct exportlist *ep, *ep2; + struct exportlist *ep; struct grouplist *grp, *tgrp; - struct exportlist **epp; struct dirlist *dirhead; struct statfs fsb; struct xucred anon; @@ -1676,19 +1673,8 @@ get_exportlist_one(void) } dirhead = (struct dirlist *)NULL; if ((ep->ex_flag & EX_LINKED) == 0) { - ep2 = exphead; - epp = &exphead; + SLIST_INSERT_HEAD(&exphead, ep, entries); - /* - * Insert in the list in alphabetical order. - */ - while (ep2 && strcmp(ep2->ex_fsdir, ep->ex_fsdir) < 0) { - epp = &ep2->ex_next; - ep2 = ep2->ex_next; - } - if (ep2) - ep->ex_next = ep2; - *epp = ep; ep->ex_flag |= EX_LINKED; } nextline: @@ -1730,13 +1716,10 @@ get_exportlist(void) /* * First, get rid of the old list */ - ep = exphead; - while (ep) { - ep2 = ep; - ep = ep->ex_next; - free_exp(ep2); + SLIST_FOREACH_SAFE(ep, &exphead, entries, ep2) { + SLIST_REMOVE(&exphead, ep, exportlist, entries); + free_exp(ep); } - exphead = (struct exportlist *)NULL; grp = grphead; while (grp) { @@ -1918,13 +1901,12 @@ ex_search(fsid_t *fsid) { struct exportlist *ep; - ep = exphead; - while (ep) { + SLIST_FOREACH(ep, &exphead, entries) { if (ep->ex_fs.val[0] == fsid->val[0] && ep->ex_fs.val[1] == fsid->val[1]) return (ep); - ep = ep->ex_next; } + return (ep); } @@ -2962,7 +2944,7 @@ parsecred(char *namelist, struct xucred *cr) static void get_mountlist(void) { - struct mountlist *mlp, **mlpp; + struct mountlist *mlp; char *host, *dirp, *cp; char str[STRSIZ]; FILE *mlfile; @@ -2975,7 +2957,6 @@ get_mountlist(void) return; } } - mlpp = &mlhead; while (fgets(str, STRSIZ, mlfile) != NULL) { cp = str; host = strsep(&cp, " \t\n"); @@ -2989,9 +2970,8 @@ get_mountlist(void) mlp->ml_host[MNTNAMLEN] = '\0'; strncpy(mlp->ml_dirp, dirp, MNTPATHLEN); mlp->ml_dirp[MNTPATHLEN] = '\0'; - mlp->ml_next = (struct mountlist *)NULL; - *mlpp = mlp; - mlpp = &mlp->ml_next; + + SLIST_INSERT_HEAD(&mlhead, mlp, next); } fclose(mlfile); } @@ -2999,23 +2979,16 @@ get_mountlist(void) static void del_mlist(char *hostp, char *dirp) { - struct mountlist *mlp, **mlpp; - struct mountlist *mlp2; + struct mountlist *mlp, *mlp2; FILE *mlfile; int fnd = 0; - mlpp = &mlhead; - mlp = mlhead; - while (mlp) { + SLIST_FOREACH_SAFE(mlp, &mlhead, next, mlp2) { if (!strcmp(mlp->ml_host, hostp) && (!dirp || !strcmp(mlp->ml_dirp, dirp))) { fnd = 1; - mlp2 = mlp; - *mlpp = mlp = mlp->ml_next; - free((caddr_t)mlp2); - } else { - mlpp = &mlp->ml_next; - mlp = mlp->ml_next; + SLIST_REMOVE(&mlhead, mlp, mountlist, next); + free((caddr_t)mlp); } } if (fnd) { @@ -3023,10 +2996,8 @@ del_mlist(char *hostp, char *dirp) syslog(LOG_ERR,"can't update %s", _PATH_RMOUNTLIST); return; } - mlp = mlhead; - while (mlp) { + SLIST_FOREACH(mlp, &mlhead, next) { fprintf(mlfile, "%s %s\n", mlp->ml_host, mlp->ml_dirp); - mlp = mlp->ml_next; } fclose(mlfile); } @@ -3035,17 +3006,14 @@ del_mlist(char *hostp, char *dirp) static void add_mlist(char *hostp, char *dirp) { - struct mountlist *mlp, **mlpp; + struct mountlist *mlp; FILE *mlfile; - mlpp = &mlhead; - mlp = mlhead; - while (mlp) { + SLIST_FOREACH(mlp, &mlhead, next) { if (!strcmp(mlp->ml_host, hostp) && !strcmp(mlp->ml_dirp, dirp)) return; - mlpp = &mlp->ml_next; - mlp = mlp->ml_next; } + mlp = (struct mountlist *)malloc(sizeof (*mlp)); if (mlp == (struct mountlist *)NULL) out_of_mem(); @@ -3053,8 +3021,7 @@ add_mlist(char *hostp, char *dirp) mlp->ml_host[MNTNAMLEN] = '\0'; strncpy(mlp->ml_dirp, dirp, MNTPATHLEN); mlp->ml_dirp[MNTPATHLEN] = '\0'; - mlp->ml_next = (struct mountlist *)NULL; - *mlpp = mlp; + SLIST_INSERT_HEAD(&mlhead, mlp, next); if ((mlfile = fopen(_PATH_RMOUNTLIST, "a")) == NULL) { syslog(LOG_ERR, "can't update %s", _PATH_RMOUNTLIST); return; From owner-svn-src-stable-11@freebsd.org Wed Oct 25 01:07:46 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A85E5E39E28; Wed, 25 Oct 2017 01:07:46 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 844D5777EE; Wed, 25 Oct 2017 01:07:46 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9P17jCQ059176; Wed, 25 Oct 2017 01:07:45 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9P17jWq059175; Wed, 25 Oct 2017 01:07:45 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201710250107.v9P17jWq059175@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 25 Oct 2017 01:07:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324967 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 324967 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Oct 2017 01:07:46 -0000 Author: markj Date: Wed Oct 25 01:07:45 2017 New Revision: 324967 URL: https://svnweb.freebsd.org/changeset/base/324967 Log: MFC r324704: Fix a racy VI_DOOMED check in MNT_VNODE_FOREACH_ALL(). Modified: stable/11/sys/kern/vfs_subr.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/vfs_subr.c ============================================================================== --- stable/11/sys/kern/vfs_subr.c Wed Oct 25 01:07:12 2017 (r324966) +++ stable/11/sys/kern/vfs_subr.c Wed Oct 25 01:07:45 2017 (r324967) @@ -5201,12 +5201,18 @@ __mnt_vnode_next_all(struct vnode **mvp, struct mount kern_yield(PRI_USER); MNT_ILOCK(mp); KASSERT((*mvp)->v_mount == mp, ("marker vnode mount list mismatch")); - vp = TAILQ_NEXT(*mvp, v_nmntvnodes); - while (vp != NULL && (vp->v_type == VMARKER || - (vp->v_iflag & VI_DOOMED) != 0)) - vp = TAILQ_NEXT(vp, v_nmntvnodes); - - /* Check if we are done */ + for (vp = TAILQ_NEXT(*mvp, v_nmntvnodes); vp != NULL; + vp = TAILQ_NEXT(vp, v_nmntvnodes)) { + /* Allow a racy peek at VI_DOOMED to save a lock acquisition. */ + if (vp->v_type == VMARKER || (vp->v_iflag & VI_DOOMED) != 0) + continue; + VI_LOCK(vp); + if ((vp->v_iflag & VI_DOOMED) != 0) { + VI_UNLOCK(vp); + continue; + } + break; + } if (vp == NULL) { __mnt_vnode_markerfree_all(mvp, mp); /* MNT_IUNLOCK(mp); -- done in above function */ @@ -5215,7 +5221,6 @@ __mnt_vnode_next_all(struct vnode **mvp, struct mount } TAILQ_REMOVE(&mp->mnt_nvnodelist, *mvp, v_nmntvnodes); TAILQ_INSERT_AFTER(&mp->mnt_nvnodelist, vp, *mvp, v_nmntvnodes); - VI_LOCK(vp); MNT_IUNLOCK(mp); return (vp); } @@ -5228,14 +5233,20 @@ __mnt_vnode_first_all(struct vnode **mvp, struct mount *mvp = malloc(sizeof(struct vnode), M_VNODE_MARKER, M_WAITOK | M_ZERO); MNT_ILOCK(mp); MNT_REF(mp); + (*mvp)->v_mount = mp; (*mvp)->v_type = VMARKER; - vp = TAILQ_FIRST(&mp->mnt_nvnodelist); - while (vp != NULL && (vp->v_type == VMARKER || - (vp->v_iflag & VI_DOOMED) != 0)) - vp = TAILQ_NEXT(vp, v_nmntvnodes); - - /* Check if we are done */ + TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes) { + /* Allow a racy peek at VI_DOOMED to save a lock acquisition. */ + if (vp->v_type == VMARKER || (vp->v_iflag & VI_DOOMED) != 0) + continue; + VI_LOCK(vp); + if ((vp->v_iflag & VI_DOOMED) != 0) { + VI_UNLOCK(vp); + continue; + } + break; + } if (vp == NULL) { MNT_REL(mp); MNT_IUNLOCK(mp); @@ -5243,13 +5254,10 @@ __mnt_vnode_first_all(struct vnode **mvp, struct mount *mvp = NULL; return (NULL); } - (*mvp)->v_mount = mp; TAILQ_INSERT_AFTER(&mp->mnt_nvnodelist, vp, *mvp, v_nmntvnodes); - VI_LOCK(vp); MNT_IUNLOCK(mp); return (vp); } - void __mnt_vnode_markerfree_all(struct vnode **mvp, struct mount *mp) From owner-svn-src-stable-11@freebsd.org Wed Oct 25 08:13:42 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0E7A1E427B2; Wed, 25 Oct 2017 08:13:42 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DC92728C4; Wed, 25 Oct 2017 08:13:41 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from dhcp-10-248-123-243.eduroam.wireless.private.cam.ac.uk (global-5-144.nat-2.net.cam.ac.uk [131.111.5.144]) by mail.baldwin.cx (Postfix) with ESMTPSA id 0FE3A10A7DB; Wed, 25 Oct 2017 04:13:33 -0400 (EDT) Subject: Re: svn commit: r324932 - in stable/11: lib/libprocstat sys/kern sys/sys usr.bin/gcore usr.bin/procstat To: Bryan Drewery , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org References: <201710231825.v9NIPLlE090194@repo.freebsd.org> From: John Baldwin Message-ID: <91d26f70-8189-a090-45c4-5a532575867a@FreeBSD.org> Date: Wed, 25 Oct 2017 09:13:32 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <201710231825.v9NIPLlE090194@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Wed, 25 Oct 2017 04:13:34 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Oct 2017 08:13:42 -0000 On 10/23/17 7:25 PM, Bryan Drewery wrote: > Author: bdrewery > Date: Mon Oct 23 18:25:21 2017 > New Revision: 324932 > URL: https://svnweb.freebsd.org/changeset/base/324932 > > Log: > MFC r316286: > > Add support for capturing 'struct ptrace_lwpinfo' for signals resulting in a > process dumping core in the corefile. > > Direct stable changed: Padding added to struct thread and td_si added to end > with explicit bzeroing when forking/initializing a thread to preserve KBI. Please merge r320481 as it was a followup fix to this change in HEAD. -- John Baldwin From owner-svn-src-stable-11@freebsd.org Wed Oct 25 14:45:58 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 315CCE4C27C; Wed, 25 Oct 2017 14:45:58 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0AD936FBF9; Wed, 25 Oct 2017 14:45:57 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9PEjvLk000379; Wed, 25 Oct 2017 14:45:57 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9PEjunb000374; Wed, 25 Oct 2017 14:45:56 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201710251445.v9PEjunb000374@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Wed, 25 Oct 2017 14:45:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324973 - in stable/11/cddl/contrib/opensolaris: cmd/zdb cmd/ztest lib/libzpool/common lib/libzpool/common/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in stable/11/cddl/contrib/opensolaris: cmd/zdb cmd/ztest lib/libzpool/common lib/libzpool/common/sys X-SVN-Commit-Revision: 324973 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Oct 2017 14:45:58 -0000 Author: asomers Date: Wed Oct 25 14:45:56 2017 New Revision: 324973 URL: https://svnweb.freebsd.org/changeset/base/324973 Log: MFC r324220: MFV r316858 7280 Allow changing global libzpool variables in zdb 7280 Allow changing global libzpool variables in zdb and ztest through command line illumos/illumos-gate@0e60744c982adecd0a1f146f5637475d07ab1069 https://github.com/illumos/illumos-gate/commit/0e60744c982adecd0a1f146f5637475d07ab1069 https://www.illumos.org/issues/7280 zdb is very handy for diagnosing problems with a pool in a safe and quick way. When a pool is in a bad shape, we often want to disable some fail-safes, or adjust some tunables in order to open them. In the kernel, this is done by changing public variables in mdb. The goal of this feature is to add the same capability to zdb and ztest, so that they can change libzpool tuneables from the command line. Reviewed by: Matthew Ahrens Reviewed by: Dan Kimmel Approved by: Robert Mustacchi Author: Pavel Zakharov Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.8 stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c stable/11/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h stable/11/cddl/contrib/opensolaris/lib/libzpool/common/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.8 ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.8 Wed Oct 25 11:44:46 2017 (r324972) +++ stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.8 Wed Oct 25 14:45:56 2017 (r324973) @@ -33,6 +33,7 @@ .Op Fl U Ar cache .Op Fl I Ar inflight I/Os .Op Fl x Ar dumpdir +.Op Fl o Ar var=value .Ar poolname .Op Ar object ... .Nm @@ -252,6 +253,10 @@ Limit the number of outstanding checksum I/Os to the s The default value is 200. This option affects the performance of the .Fl c option. +.It Fl o Ar var=value +Set the given global libzpool variable to the provided value. The value must be +an unsigned 32-bit integer. Currently only little-endian systems are supported +to avoid accidentally setting the high 32 bits of 64-bit variables. .It Fl P Print numbers in an unscaled form more amenable to parsing, eg. 1000000 rather than 1M. Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Wed Oct 25 11:44:46 2017 (r324972) +++ stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Wed Oct 25 14:45:56 2017 (r324973) @@ -121,7 +121,8 @@ usage(void) { (void) fprintf(stderr, "Usage: %s [-CumMdibcsDvhLXFPAG] [-t txg] [-e [-p path...]] " - "[-U config] [-I inflight I/Os] [-x dumpdir] poolname [object...]\n" + "[-U config] [-I inflight I/Os] [-x dumpdir] [-o var=value] " + "poolname [object...]\n" " %s [-divPA] [-e -p path...] [-U config] dataset " "[object...]\n" " %s -mM [-LXFPA] [-t txg] [-e [-p path...]] [-U config] " @@ -183,6 +184,8 @@ usage(void) "checksumming I/Os [default is 200]\n"); (void) fprintf(stderr, " -G dump zfs_dbgmsg buffer before " "exiting\n"); + (void) fprintf(stderr, " -o = set global " + "variable to an unsigned 32-bit integer value\n"); (void) fprintf(stderr, "Specify an option more than once (e.g. -bb) " "to make only that option verbose\n"); (void) fprintf(stderr, "Default is to dump everything non-verbosely\n"); @@ -3614,7 +3617,7 @@ main(int argc, char **argv) spa_config_path = spa_config_path_env; while ((c = getopt(argc, argv, - "bcdhilmMI:suCDRSAFLXx:evp:t:U:PG")) != -1) { + "bcdhilmMI:suCDRSAFLXx:evp:t:U:PGo:")) != -1) { switch (c) { case 'b': case 'c': @@ -3682,6 +3685,11 @@ main(int argc, char **argv) break; case 'x': vn_dumpdir = optarg; + break; + case 'o': + error = set_global_var(optarg); + if (error != 0) + usage(); break; default: usage(); Modified: stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Wed Oct 25 11:44:46 2017 (r324972) +++ stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Wed Oct 25 14:45:56 2017 (r324973) @@ -583,6 +583,8 @@ usage(boolean_t requested) "\t[-F freezeloops (default: %llu)] max loops in spa_freeze()\n" "\t[-P passtime (default: %llu sec)] time per pass\n" "\t[-B alt_ztest (default: )] alternate ztest path\n" + "\t[-o variable=value] ... set global variable to an unsigned\n" + "\t 32-bit integer value\n" "\t[-h] (print help)\n" "", zo->zo_pool, @@ -618,7 +620,7 @@ process_options(int argc, char **argv) bcopy(&ztest_opts_defaults, zo, sizeof (*zo)); while ((opt = getopt(argc, argv, - "v:s:a:m:r:R:d:t:g:i:k:p:f:VET:P:hF:B:")) != EOF) { + "v:s:a:m:r:R:d:t:g:i:k:p:f:VET:P:hF:B:o:")) != EOF) { value = 0; switch (opt) { case 'v': @@ -704,6 +706,10 @@ process_options(int argc, char **argv) break; case 'B': (void) strlcpy(altdir, optarg, sizeof (altdir)); + break; + case 'o': + if (set_global_var(optarg) != 0) + usage(B_FALSE); break; case 'h': usage(B_TRUE); Modified: stable/11/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h Wed Oct 25 11:44:46 2017 (r324972) +++ stable/11/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h Wed Oct 25 14:45:56 2017 (r324973) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2015 by Delphix. All rights reserved. + * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. */ /* @@ -581,6 +581,7 @@ extern void kernel_fini(void); struct spa; extern void nicenum(uint64_t num, char *buf); extern void show_pool_stats(struct spa *); +extern int set_global_var(char *arg); typedef struct callb_cpr { kmutex_t *cc_lockp; Modified: stable/11/cddl/contrib/opensolaris/lib/libzpool/common/util.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzpool/common/util.c Wed Oct 25 11:44:46 2017 (r324972) +++ stable/11/cddl/contrib/opensolaris/lib/libzpool/common/util.c Wed Oct 25 14:45:56 2017 (r324973) @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016 by Delphix. All rights reserved. */ #include @@ -31,6 +32,7 @@ #include #include #include +#include /* * Routines needed by more than one client of libzpool. @@ -152,4 +154,59 @@ show_pool_stats(spa_t *spa) show_vdev_stats(NULL, ZPOOL_CONFIG_SPARES, nvroot, 0); nvlist_free(config); +} + +/* + * Sets given global variable in libzpool to given unsigned 32-bit value. + * arg: "=" + */ +int +set_global_var(char *arg) +{ + void *zpoolhdl; + char *varname = arg, *varval; + u_longlong_t val; + +#ifndef _LITTLE_ENDIAN + /* + * On big endian systems changing a 64-bit variable would set the high + * 32 bits instead of the low 32 bits, which could cause unexpected + * results. + */ + fprintf(stderr, "Setting global variables is only supported on " + "little-endian systems\n", varname); + return (ENOTSUP); +#endif + if ((varval = strchr(arg, '=')) != NULL) { + *varval = '\0'; + varval++; + val = strtoull(varval, NULL, 0); + if (val > UINT32_MAX) { + fprintf(stderr, "Value for global variable '%s' must " + "be a 32-bit unsigned integer\n", varname); + return (EOVERFLOW); + } + } else { + return (EINVAL); + } + + zpoolhdl = dlopen("libzpool.so", RTLD_LAZY); + if (zpoolhdl != NULL) { + uint32_t *var; + var = dlsym(zpoolhdl, varname); + if (var == NULL) { + fprintf(stderr, "Global variable '%s' does not exist " + "in libzpool.so\n", varname); + return (EINVAL); + } + *var = (uint32_t)val; + + dlclose(zpoolhdl); + } else { + fprintf(stderr, "Failed to open libzpool.so to set global " + "variable\n"); + return (EIO); + } + + return (0); } From owner-svn-src-stable-11@freebsd.org Wed Oct 25 15:11:09 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8E6D3E4CA07; Wed, 25 Oct 2017 15:11:09 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 671A370ABF; Wed, 25 Oct 2017 15:11:09 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9PFB86E010132; Wed, 25 Oct 2017 15:11:08 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9PFB8in010130; Wed, 25 Oct 2017 15:11:08 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201710251511.v9PFB8in010130@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Wed, 25 Oct 2017 15:11:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324974 - stable/11/cddl/contrib/opensolaris/cmd/zdb X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/11/cddl/contrib/opensolaris/cmd/zdb X-SVN-Commit-Revision: 324974 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Oct 2017 15:11:09 -0000 Author: asomers Date: Wed Oct 25 15:11:08 2017 New Revision: 324974 URL: https://svnweb.freebsd.org/changeset/base/324974 Log: MFC r324221: MFV r316861: 6866 zdb -l should return non-zero if it fails to find any label illumos/illumos-gate@64723e361134b2a2c45341334174f9d34002f8d0 https://github.com/illumos/illumos-gate/commit/64723e361134b2a2c45341334174f9d34002f8d0 https://www.illumos.org/issues/6866 Need this for #6865. To be generally more scripting-friendly, overload this issue with adding '-q' option which should skip printing any label information. Reviewed by: Matthew Ahrens Reviewed by: John Kennedy Approved by: Robert Mustacchi Author: Yuri Pankov Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.8 stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.8 ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.8 Wed Oct 25 14:45:56 2017 (r324973) +++ stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.8 Wed Oct 25 15:11:08 2017 (r324974) @@ -15,11 +15,12 @@ .\" Copyright 2012, Richard Lowe. .\" Copyright (c) 2012, Marcelo Araujo . .\" Copyright (c) 2012, 2014 by Delphix. All rights reserved. +.\" Copyright 2016 Nexenta Systems, Inc. .\" All Rights Reserved. .\" .\" $FreeBSD$ .\" -.Dd July 26, 2014 +.Dd October 1, 2017 .Dt ZDB 8 .Os .Sh NAME @@ -27,7 +28,7 @@ .Nd Display zpool debugging and consistency information .Sh SYNOPSIS .Nm -.Op Fl CumdibcsDvhLMXFPA +.Op Fl CmdibcsDvhLMXFPA .Op Fl e Op Fl p Ar path... .Op Fl t Ar txg .Op Fl U Ar cache @@ -64,7 +65,7 @@ .Ar poolname .Nm .Fl l -.Op Fl uA +.Op Fl Aqu .Ar device .Nm .Fl C @@ -156,9 +157,14 @@ dataset. If specified multiple times, display counts of each intent log transaction type. .It Fl l Ar device -Display the vdev labels from the specified device. +Read the vdev labels from the specified device. +Return 0 if a valid label was found, 1 if an error occurred, and 2 if no valid +labels were found. If the .Fl u +option is also specified, also display the uberblocks on this device. +If the +.Fl q option is also specified, also display the uberblocks on this device. .It Fl L Disable leak tracing and the loading of space maps. Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Wed Oct 25 14:45:56 2017 (r324973) +++ stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Wed Oct 25 15:11:08 2017 (r324974) @@ -23,6 +23,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Nexenta Systems, Inc. */ #include @@ -120,7 +121,7 @@ static void usage(void) { (void) fprintf(stderr, - "Usage: %s [-CumMdibcsDvhLXFPAG] [-t txg] [-e [-p path...]] " + "Usage: %s [-CmMdibcsDvhLXFPAG] [-t txg] [-e [-p path...]] " "[-U config] [-I inflight I/Os] [-x dumpdir] [-o var=value] " "poolname [object...]\n" " %s [-divPA] [-e -p path...] [-U config] dataset " @@ -130,7 +131,7 @@ usage(void) " %s -R [-A] [-e [-p path...]] poolname " "vdev:offset:size[:flags]\n" " %s -S [-PA] [-e [-p path...]] [-U config] poolname\n" - " %s -l [-uA] device\n" + " %s -l [-Aqu] device\n" " %s -C [-A] [-U config]\n\n", cmdname, cmdname, cmdname, cmdname, cmdname, cmdname, cmdname); @@ -141,7 +142,6 @@ usage(void) (void) fprintf(stderr, " If object numbers are specified, only " "those objects are dumped\n\n"); (void) fprintf(stderr, " Options to control amount of output:\n"); - (void) fprintf(stderr, " -u uberblock\n"); (void) fprintf(stderr, " -d dataset(s)\n"); (void) fprintf(stderr, " -i intent logs\n"); (void) fprintf(stderr, " -C config (or cachefile if alone)\n"); @@ -155,7 +155,7 @@ usage(void) (void) fprintf(stderr, " -D dedup statistics\n"); (void) fprintf(stderr, " -S simulate dedup to measure effect\n"); (void) fprintf(stderr, " -v verbose (applies to all others)\n"); - (void) fprintf(stderr, " -l dump label contents\n"); + (void) fprintf(stderr, " -l read label contents\n"); (void) fprintf(stderr, " -L disable leak tracking (do not " "load spacemaps)\n"); (void) fprintf(stderr, " -R read and display block from a " @@ -186,6 +186,8 @@ usage(void) "exiting\n"); (void) fprintf(stderr, " -o = set global " "variable to an unsigned 32-bit integer value\n"); + (void) fprintf(stderr, " -q don't print label contents\n"); + (void) fprintf(stderr, " -u uberblock\n"); (void) fprintf(stderr, "Specify an option more than once (e.g. -bb) " "to make only that option verbose\n"); (void) fprintf(stderr, "Default is to dump everything non-verbosely\n"); @@ -2159,84 +2161,94 @@ dump_label_uberblocks(vdev_label_t *lbl, uint64_t ashi } } -static void +static int dump_label(const char *dev) { int fd; vdev_label_t label; - char *path, *buf = label.vl_vdev_phys.vp_nvlist; + char path[MAXPATHLEN]; + char *buf = label.vl_vdev_phys.vp_nvlist; size_t buflen = sizeof (label.vl_vdev_phys.vp_nvlist); struct stat64 statbuf; uint64_t psize, ashift; - int len = strlen(dev) + 1; + boolean_t label_found = B_FALSE; - if (strncmp(dev, ZFS_DISK_ROOTD, strlen(ZFS_DISK_ROOTD)) == 0) { - len++; - path = malloc(len); - (void) snprintf(path, len, "%s%s", ZFS_RDISK_ROOTD, - dev + strlen(ZFS_DISK_ROOTD)); - } else { - path = strdup(dev); - } + (void) strlcpy(path, dev, sizeof (path)); + if (dev[0] == '/') { + if (strncmp(dev, ZFS_DISK_ROOTD, + strlen(ZFS_DISK_ROOTD)) == 0) { + (void) snprintf(path, sizeof (path), "%s%s", + ZFS_RDISK_ROOTD, dev + strlen(ZFS_DISK_ROOTD)); + } + } else if (stat64(path, &statbuf) != 0) { + char *s; - if ((fd = open64(path, O_RDONLY)) < 0) { - (void) printf("cannot open '%s': %s\n", path, strerror(errno)); - free(path); - exit(1); + (void) snprintf(path, sizeof (path), "%s%s", ZFS_RDISK_ROOTD, + dev); + if ((s = strrchr(dev, 's')) == NULL || !isdigit(*(s + 1))) + (void) strlcat(path, "s0", sizeof (path)); } - if (fstat64(fd, &statbuf) != 0) { + if (stat64(path, &statbuf) != 0) { (void) printf("failed to stat '%s': %s\n", path, strerror(errno)); - free(path); - (void) close(fd); exit(1); } if (S_ISBLK(statbuf.st_mode)) { (void) printf("cannot use '%s': character device required\n", path); - free(path); - (void) close(fd); exit(1); } + if ((fd = open64(path, O_RDONLY)) < 0) { + (void) printf("cannot open '%s': %s\n", path, strerror(errno)); + exit(1); + } + psize = statbuf.st_size; psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t)); for (int l = 0; l < VDEV_LABELS; l++) { nvlist_t *config = NULL; - (void) printf("--------------------------------------------\n"); - (void) printf("LABEL %d\n", l); - (void) printf("--------------------------------------------\n"); + if (!dump_opt['q']) { + (void) printf("------------------------------------\n"); + (void) printf("LABEL %d\n", l); + (void) printf("------------------------------------\n"); + } if (pread64(fd, &label, sizeof (label), vdev_label_offset(psize, l, 0)) != sizeof (label)) { - (void) printf("failed to read label %d\n", l); + if (!dump_opt['q']) + (void) printf("failed to read label %d\n", l); continue; } if (nvlist_unpack(buf, buflen, &config, 0) != 0) { - (void) printf("failed to unpack label %d\n", l); + if (!dump_opt['q']) + (void) printf("failed to unpack label %d\n", l); ashift = SPA_MINBLOCKSHIFT; } else { nvlist_t *vdev_tree = NULL; - dump_nvlist(config, 4); + if (!dump_opt['q']) + dump_nvlist(config, 4); if ((nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &vdev_tree) != 0) || (nvlist_lookup_uint64(vdev_tree, ZPOOL_CONFIG_ASHIFT, &ashift) != 0)) ashift = SPA_MINBLOCKSHIFT; nvlist_free(config); + label_found = B_TRUE; } if (dump_opt['u']) dump_label_uberblocks(&label, ashift); } - free(path); (void) close(fd); + + return (label_found ? 0 : 2); } static uint64_t dataset_feature_count[SPA_FEATURES]; @@ -3617,7 +3629,7 @@ main(int argc, char **argv) spa_config_path = spa_config_path_env; while ((c = getopt(argc, argv, - "bcdhilmMI:suCDRSAFLXx:evp:t:U:PGo:")) != -1) { + "bcdhilmMI:suCDRSAFLXx:evp:t:U:PGo:q")) != -1) { switch (c) { case 'b': case 'c': @@ -3643,6 +3655,7 @@ main(int argc, char **argv) case 'X': case 'e': case 'P': + case 'q': dump_opt[c]++; break; case 'I': @@ -3751,10 +3764,8 @@ main(int argc, char **argv) usage(); } - if (dump_opt['l']) { - dump_label(argv[0]); - return (0); - } + if (dump_opt['l']) + return (dump_label(argv[0])); if (dump_opt['X'] || dump_opt['F']) rewind = ZPOOL_DO_REWIND | From owner-svn-src-stable-11@freebsd.org Wed Oct 25 15:15:11 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2769CE4CBF5; Wed, 25 Oct 2017 15:15:11 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E52E970F0B; Wed, 25 Oct 2017 15:15:10 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9PFFAVb013506; Wed, 25 Oct 2017 15:15:10 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9PFFAuh013505; Wed, 25 Oct 2017 15:15:10 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201710251515.v9PFFAuh013505@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Wed, 25 Oct 2017 15:15:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324975 - stable/11/cddl/contrib/opensolaris/cmd/zdb X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/11/cddl/contrib/opensolaris/cmd/zdb X-SVN-Commit-Revision: 324975 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Oct 2017 15:15:11 -0000 Author: asomers Date: Wed Oct 25 15:15:09 2017 New Revision: 324975 URL: https://svnweb.freebsd.org/changeset/base/324975 Log: MFC r324222: MFV r316863: 3871 fix issues introduced by 3604 illumos/illumos-gate@de05b58863498b10283637eb9ac85e92fe85150e https://github.com/illumos/illumos-gate/commit/de05b58863498b10283637eb9ac85e92fe85150e https://www.illumos.org/issues/3871 GCC 4.5.3 on Gentoo Linux did not like a few of the changes made in the issue 3604 patch. It printed an error and a couple of warnings: ../../cmd/zdb/zdb.c: In function 'dump_bpobj': ../../cmd/zdb/zdb.c:1257:3: error: 'for' loop initial declarations are only allowed in C99 mode ../../cmd/zdb/zdb.c:1257:3: note: use option -std=c99 or -std=gnu99 to compile your code ../../cmd/zdb/zdb.c: In function 'dump_deadlist': ../../cmd/zdb/zdb.c:1323:8: warning: too many arguments for format ../../cmd/zdb/zdb.c:1323:8: warning: too many arguments for format Reviewed by: Paul Dagnelie Reviewed by: Matthew Ahrens Reviewed by: Serapheim Dimitropoulos Approved by: Dan McDonald Author: Richard Yao Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Wed Oct 25 15:11:08 2017 (r324974) +++ stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Wed Oct 25 15:15:09 2017 (r324975) @@ -1587,8 +1587,9 @@ dump_deadlist(dsl_deadlist_t *dl) dle = AVL_NEXT(&dl->dl_tree, dle)) { if (dump_opt['d'] >= 5) { char buf[128]; - (void) snprintf(buf, sizeof (buf), "mintxg %llu -> " - "obj %llu", (longlong_t)dle->dle_mintxg, + (void) snprintf(buf, sizeof (buf), + "mintxg %llu -> obj %llu", + (longlong_t)dle->dle_mintxg, (longlong_t)dle->dle_bpobj.bpo_object); dump_full_bpobj(&dle->dle_bpobj, buf, 0); } else { From owner-svn-src-stable-11@freebsd.org Wed Oct 25 15:18:10 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B99F4E4CE1E; Wed, 25 Oct 2017 15:18:10 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 82625711A5; Wed, 25 Oct 2017 15:18:10 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9PFI9Pa013820; Wed, 25 Oct 2017 15:18:09 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9PFI9ZG013819; Wed, 25 Oct 2017 15:18:09 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201710251518.v9PFI9ZG013819@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Wed, 25 Oct 2017 15:18:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324976 - stable/11/cddl/contrib/opensolaris/cmd/zdb X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/11/cddl/contrib/opensolaris/cmd/zdb X-SVN-Commit-Revision: 324976 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Oct 2017 15:18:10 -0000 Author: asomers Date: Wed Oct 25 15:18:09 2017 New Revision: 324976 URL: https://svnweb.freebsd.org/changeset/base/324976 Log: MFC r324223: MFV r319743: 8108 zdb -l fails to read labels 2 and 3 illumos/illumos-gate@22c8b9583d07895c16549075a53668d7bc988cf3 https://github.com/illumos/illumos-gate/commit/22c8b9583d07895c16549075a53668d7bc988cf3 https://www.illumos.org/issues/8108 Reviewed by: Matthew Ahrens Reviewed by: Toomas Soome Reviewed by: Igor Kozhukhov Reviewed by: Andrew Stormont Approved by: Robert Mustacchi Author: Yuri Pankov Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Wed Oct 25 15:15:09 2017 (r324975) +++ stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Wed Oct 25 15:18:09 2017 (r324976) @@ -2186,24 +2186,29 @@ dump_label(const char *dev) (void) snprintf(path, sizeof (path), "%s%s", ZFS_RDISK_ROOTD, dev); - if ((s = strrchr(dev, 's')) == NULL || !isdigit(*(s + 1))) + if (((s = strrchr(dev, 's')) == NULL && + (s = strchr(dev, 'p')) == NULL) || + !isdigit(*(s + 1))) (void) strlcat(path, "s0", sizeof (path)); } - if (stat64(path, &statbuf) != 0) { - (void) printf("failed to stat '%s': %s\n", path, + if ((fd = open64(path, O_RDONLY)) < 0) { + (void) fprintf(stderr, "cannot open '%s': %s\n", path, strerror(errno)); exit(1); } - if (S_ISBLK(statbuf.st_mode)) { - (void) printf("cannot use '%s': character device required\n", - path); + if (fstat64(fd, &statbuf) != 0) { + (void) fprintf(stderr, "failed to stat '%s': %s\n", path, + strerror(errno)); + (void) close(fd); exit(1); } - if ((fd = open64(path, O_RDONLY)) < 0) { - (void) printf("cannot open '%s': %s\n", path, strerror(errno)); + if (S_ISBLK(statbuf.st_mode)) { + (void) fprintf(stderr, + "cannot use '%s': character device required\n", path); + (void) close(fd); exit(1); } From owner-svn-src-stable-11@freebsd.org Wed Oct 25 19:27:13 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BA873E52636; Wed, 25 Oct 2017 19:27:13 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 891CC7F4A2; Wed, 25 Oct 2017 19:27:13 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9PJRCS2021967; Wed, 25 Oct 2017 19:27:12 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9PJRCpg021965; Wed, 25 Oct 2017 19:27:12 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201710251927.v9PJRCpg021965@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Wed, 25 Oct 2017 19:27:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324997 - stable/11/sys/fs/nfs X-SVN-Group: stable-11 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: stable/11/sys/fs/nfs X-SVN-Commit-Revision: 324997 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Oct 2017 19:27:13 -0000 Author: rmacklem Date: Wed Oct 25 19:27:12 2017 New Revision: 324997 URL: https://svnweb.freebsd.org/changeset/base/324997 Log: MFC: r324506 Fix forced dismount when a pNFS mount is hung on a DS. When a "pnfs" NFSv4.1 mount is hung because of an unresponsive DS, a forced dismount wouldn't work, because the RPC socket for the DS was not being closed. This patch fixes this. This will only affect "pnfs" mounts where the pNFS server's DS is unresponsive (crashed or network partitioned or...). Found during testing of the pNFS server. Modified: stable/11/sys/fs/nfs/nfs_commonkrpc.c stable/11/sys/fs/nfs/nfsclstate.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfs/nfs_commonkrpc.c ============================================================================== --- stable/11/sys/fs/nfs/nfs_commonkrpc.c Wed Oct 25 19:21:48 2017 (r324996) +++ stable/11/sys/fs/nfs/nfs_commonkrpc.c Wed Oct 25 19:27:12 2017 (r324997) @@ -1119,9 +1119,29 @@ nfsmout: int newnfs_nmcancelreqs(struct nfsmount *nmp) { + struct nfsclds *dsp; + struct __rpc_client *cl; if (nmp->nm_sockreq.nr_client != NULL) CLNT_CLOSE(nmp->nm_sockreq.nr_client); +lookformore: + NFSLOCKMNT(nmp); + TAILQ_FOREACH(dsp, &nmp->nm_sess, nfsclds_list) { + NFSLOCKDS(dsp); + if (dsp != TAILQ_FIRST(&nmp->nm_sess) && + (dsp->nfsclds_flags & NFSCLDS_CLOSED) == 0 && + dsp->nfsclds_sockp != NULL && + dsp->nfsclds_sockp->nr_client != NULL) { + dsp->nfsclds_flags |= NFSCLDS_CLOSED; + cl = dsp->nfsclds_sockp->nr_client; + NFSUNLOCKDS(dsp); + NFSUNLOCKMNT(nmp); + CLNT_CLOSE(cl); + goto lookformore; + } + NFSUNLOCKDS(dsp); + } + NFSUNLOCKMNT(nmp); return (0); } Modified: stable/11/sys/fs/nfs/nfsclstate.h ============================================================================== --- stable/11/sys/fs/nfs/nfsclstate.h Wed Oct 25 19:21:48 2017 (r324996) +++ stable/11/sys/fs/nfs/nfsclstate.h Wed Oct 25 19:27:12 2017 (r324997) @@ -91,6 +91,7 @@ struct nfsclds { #define NFSCLDS_HASWRITEVERF 0x0001 #define NFSCLDS_MDS 0x0002 #define NFSCLDS_DS 0x0004 +#define NFSCLDS_CLOSED 0x0008 struct nfsclclient { LIST_ENTRY(nfsclclient) nfsc_list; From owner-svn-src-stable-11@freebsd.org Wed Oct 25 22:25:34 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 74F98E55999; Wed, 25 Oct 2017 22:25:34 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 48BCE848F5; Wed, 25 Oct 2017 22:25:34 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9PMPX0h096044; Wed, 25 Oct 2017 22:25:33 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9PMPX1V096039; Wed, 25 Oct 2017 22:25:33 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201710252225.v9PMPX1V096039@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Wed, 25 Oct 2017 22:25:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r325003 - in stable/11: sys/geom sys/sys usr.sbin/diskinfo X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in stable/11: sys/geom sys/sys usr.sbin/diskinfo X-SVN-Commit-Revision: 325003 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Oct 2017 22:25:34 -0000 Author: asomers Date: Wed Oct 25 22:25:32 2017 New Revision: 325003 URL: https://svnweb.freebsd.org/changeset/base/325003 Log: MFC r324281: Display rotation rate and TRIM/UNMAP support in diskinfo(8) Bump __FreeBSD_version due to the expansion of struct diocgattr_arg. Reviewed by: mav, allanjude, imp Relnotes: yes Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D12578 Modified: stable/11/sys/geom/geom_disk.h stable/11/sys/sys/disk.h stable/11/sys/sys/param.h stable/11/usr.sbin/diskinfo/diskinfo.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/geom_disk.h ============================================================================== --- stable/11/sys/geom/geom_disk.h Wed Oct 25 21:46:39 2017 (r325002) +++ stable/11/sys/geom/geom_disk.h Wed Oct 25 22:25:32 2017 (r325003) @@ -37,6 +37,11 @@ #ifndef _GEOM_GEOM_DISK_H_ #define _GEOM_GEOM_DISK_H_ +#define DISK_RR_UNKNOWN 0 +#define DISK_RR_NON_ROTATING 1 +#define DISK_RR_MIN 0x0401 +#define DISK_RR_MAX 0xfffe + #ifdef _KERNEL #include @@ -118,11 +123,6 @@ struct disk { #define DISKFLAG_UNMAPPED_BIO 0x10 #define DISKFLAG_DIRECT_COMPLETION 0x20 #define DISKFLAG_CANZONE 0x80 - -#define DISK_RR_UNKNOWN 0 -#define DISK_RR_NON_ROTATING 1 -#define DISK_RR_MIN 0x0401 -#define DISK_RR_MAX 0xfffe struct disk *disk_alloc(void); void disk_create(struct disk *disk, int version); Modified: stable/11/sys/sys/disk.h ============================================================================== --- stable/11/sys/sys/disk.h Wed Oct 25 21:46:39 2017 (r325002) +++ stable/11/sys/sys/disk.h Wed Oct 25 22:25:32 2017 (r325003) @@ -133,6 +133,7 @@ struct diocgattr_arg { char str[DISK_IDENT_SIZE]; off_t off; int i; + uint16_t u16; } value; }; #define DIOCGATTR _IOWR('d', 142, struct diocgattr_arg) Modified: stable/11/sys/sys/param.h ============================================================================== --- stable/11/sys/sys/param.h Wed Oct 25 21:46:39 2017 (r325002) +++ stable/11/sys/sys/param.h Wed Oct 25 22:25:32 2017 (r325003) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1101505 /* Master, propagated to newvers */ +#define __FreeBSD_version 1101506 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, Modified: stable/11/usr.sbin/diskinfo/diskinfo.c ============================================================================== --- stable/11/usr.sbin/diskinfo/diskinfo.c Wed Oct 25 21:46:39 2017 (r325002) +++ stable/11/usr.sbin/diskinfo/diskinfo.c Wed Oct 25 22:25:32 2017 (r325003) @@ -31,6 +31,7 @@ * $FreeBSD$ */ +#include #include #include #include @@ -42,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -62,9 +64,11 @@ usage(void) static int opt_c, opt_i, opt_p, opt_s, opt_S, opt_t, opt_v, opt_w; +static bool candelete(int fd); static void speeddisk(int fd, off_t mediasize, u_int sectorsize); static void commandtime(int fd, off_t mediasize, u_int sectorsize); static void iopsbench(int fd, off_t mediasize, u_int sectorsize); +static void rotationrate(int fd, char *buf, size_t buflen); static void slogbench(int fd, int isreg, off_t mediasize, u_int sectorsize); static int zonecheck(int fd, uint32_t *zone_mode, char *zone_str, size_t zone_str_len); @@ -78,6 +82,7 @@ main(int argc, char **argv) int i, ch, fd, error, exitval = 0; char tstr[BUFSIZ], ident[DISK_IDENT_SIZE], physpath[MAXPATHLEN]; char zone_desc[64]; + char rrate[64]; struct diocgattr_arg arg; off_t mediasize, stripesize, stripeoffset; u_int sectorsize, fwsectors, fwheads, zoned = 0, isreg; @@ -246,6 +251,10 @@ main(int argc, char **argv) printf("\t%-12s\t# Disk ident.\n", ident); if (ioctl(fd, DIOCGPHYSPATH, physpath) == 0) printf("\t%-12s\t# Physical path\n", physpath); + printf("\t%-12s\t# TRIM/UNMAP support\n", + candelete(fd) ? "Yes" : "No"); + rotationrate(fd, rrate, sizeof(rrate)); + printf("\t%-12s\t# Rotation rate in RPM\n", rrate); if (zoned != 0) printf("\t%-12s\t# Zone Mode\n", zone_desc); } @@ -263,6 +272,39 @@ out: } free(buf); exit (exitval); +} + +static bool +candelete(int fd) +{ + struct diocgattr_arg arg; + + strlcpy(arg.name, "GEOM::candelete", sizeof(arg.name)); + arg.len = sizeof(arg.value.i); + if (ioctl(fd, DIOCGATTR, &arg) == 0) + return (arg.value.i != 0); + else + return (false); +} + +static void +rotationrate(int fd, char *rate, size_t buflen) +{ + struct diocgattr_arg arg; + int ret; + + strlcpy(arg.name, "GEOM::rotation_rate", sizeof(arg.name)); + arg.len = sizeof(arg.value.u16); + + ret = ioctl(fd, DIOCGATTR, &arg); + if (ret < 0 || arg.value.u16 == DISK_RR_UNKNOWN) + snprintf(rate, buflen, "Unknown"); + else if (arg.value.u16 == DISK_RR_NON_ROTATING) + snprintf(rate, buflen, "%d", 0); + else if (arg.value.u16 >= DISK_RR_MIN && arg.value.u16 <= DISK_RR_MAX) + snprintf(rate, buflen, "%d", arg.value.u16); + else + snprintf(rate, buflen, "Invalid"); } static void From owner-svn-src-stable-11@freebsd.org Thu Oct 26 17:45:03 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 019C0E4F416; Thu, 26 Oct 2017 17:45:03 +0000 (UTC) (envelope-from tijl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D0E962FA8; Thu, 26 Oct 2017 17:45:02 +0000 (UTC) (envelope-from tijl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9QHj1eP076378; Thu, 26 Oct 2017 17:45:01 GMT (envelope-from tijl@FreeBSD.org) Received: (from tijl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9QHj1wP076375; Thu, 26 Oct 2017 17:45:01 GMT (envelope-from tijl@FreeBSD.org) Message-Id: <201710261745.v9QHj1wP076375@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tijl set sender to tijl@FreeBSD.org using -f From: Tijl Coosemans Date: Thu, 26 Oct 2017 17:45:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r325015 - in stable/11/sys: compat/linsysfs compat/linux kern X-SVN-Group: stable-11 X-SVN-Commit-Author: tijl X-SVN-Commit-Paths: in stable/11/sys: compat/linsysfs compat/linux kern X-SVN-Commit-Revision: 325015 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Oct 2017 17:45:03 -0000 Author: tijl Date: Thu Oct 26 17:45:01 2017 New Revision: 325015 URL: https://svnweb.freebsd.org/changeset/base/325015 Log: MFC r323692,r323710,r323714,r324628,r324629,r324635,r324636,r324637 Merge Linux emulation changes to support newer Linux libdrm. Modified: stable/11/sys/compat/linsysfs/linsysfs.c stable/11/sys/compat/linux/linux_util.c stable/11/sys/kern/vfs_lookup.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linsysfs/linsysfs.c ============================================================================== --- stable/11/sys/compat/linsysfs/linsysfs.c Thu Oct 26 16:36:27 2017 (r325014) +++ stable/11/sys/compat/linsysfs/linsysfs.c Thu Oct 26 17:45:01 2017 (r325015) @@ -133,20 +133,162 @@ linsysfs_link_scsi_host(PFS_FILL_ARGS) return (0); } +static int +linsysfs_fill_data(PFS_FILL_ARGS) +{ + sbuf_printf(sb, "%s", (char *)pn->pn_data); + return (0); +} + +static int +linsysfs_fill_vendor(PFS_FILL_ARGS) +{ + sbuf_printf(sb, "0x%04x\n", pci_get_vendor((device_t)pn->pn_data)); + return (0); +} + +static int +linsysfs_fill_device(PFS_FILL_ARGS) +{ + sbuf_printf(sb, "0x%04x\n", pci_get_device((device_t)pn->pn_data)); + return (0); +} + +static int +linsysfs_fill_subvendor(PFS_FILL_ARGS) +{ + sbuf_printf(sb, "0x%04x\n", pci_get_subvendor((device_t)pn->pn_data)); + return (0); +} + +static int +linsysfs_fill_subdevice(PFS_FILL_ARGS) +{ + sbuf_printf(sb, "0x%04x\n", pci_get_subdevice((device_t)pn->pn_data)); + return (0); +} + +static int +linsysfs_fill_revid(PFS_FILL_ARGS) +{ + sbuf_printf(sb, "0x%x\n", pci_get_revid((device_t)pn->pn_data)); + return (0); +} + +static int +linsysfs_fill_config(PFS_FILL_ARGS) +{ + uint8_t config[48]; + device_t dev; + uint32_t reg; + + dev = (device_t)pn->pn_data; + bzero(config, sizeof(config)); + reg = pci_get_vendor(dev); + config[0] = reg; + config[1] = reg >> 8; + reg = pci_get_device(dev); + config[2] = reg; + config[3] = reg >> 8; + reg = pci_get_revid(dev); + config[8] = reg; + reg = pci_get_subvendor(dev); + config[44] = reg; + config[45] = reg >> 8; + reg = pci_get_subdevice(dev); + config[46] = reg; + config[47] = reg >> 8; + sbuf_bcat(sb, config, sizeof(config)); + return (0); +} + +/* + * Filler function for PCI uevent file + */ +static int +linsysfs_fill_uevent_pci(PFS_FILL_ARGS) +{ + device_t dev; + + dev = (device_t)pn->pn_data; + sbuf_printf(sb, "DRIVER=%s\nPCI_CLASS=%X\nPCI_ID=%04X:%04X\n" + "PCI_SUBSYS_ID=%04X:%04X\nPCI_SLOT_NAME=%04d:%02x:%02x.%x\n", + linux_driver_get_name_dev(dev), pci_get_class(dev), + pci_get_vendor(dev), pci_get_device(dev), pci_get_subvendor(dev), + pci_get_subdevice(dev), pci_get_domain(dev), pci_get_bus(dev), + pci_get_slot(dev), pci_get_function(dev)); + return (0); +} + +/* + * Filler function for drm uevent file + */ +static int +linsysfs_fill_uevent_drm(PFS_FILL_ARGS) +{ + device_t dev; + int unit; + + dev = (device_t)pn->pn_data; + unit = device_get_unit(dev); + sbuf_printf(sb, + "MAJOR=226\nMINOR=%d\nDEVNAME=dri/card%d\nDEVTYPE=dri_minor\n", + unit, unit); + return (0); +} + +static char * +get_full_pfs_path(struct pfs_node *cur) +{ + char *temp, *path; + + temp = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); + path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); + path[0] = '\0'; + + do { + snprintf(temp, MAXPATHLEN, "%s/%s", cur->pn_name, path); + strlcpy(path, temp, MAXPATHLEN); + cur = cur->pn_parent; + } while (cur->pn_parent != NULL); + + path[strlen(path) - 1] = '\0'; /* remove extra slash */ + free(temp, M_TEMP); + return (path); +} + +/* + * Filler function for symlink from drm char device to PCI device + */ +static int +linsysfs_fill_vgapci(PFS_FILL_ARGS) +{ + char *path; + + path = get_full_pfs_path((struct pfs_node*)pn->pn_data); + sbuf_printf(sb, "../../../%s", path); + free(path, M_TEMP); + return (0); +} + #define PCI_DEV "pci" +#define DRMN_DEV "drmn" static int -linsysfs_run_bus(device_t dev, struct pfs_node *dir, struct pfs_node *scsi, char *path, - char *prefix) +linsysfs_run_bus(device_t dev, struct pfs_node *dir, struct pfs_node *scsi, + struct pfs_node *chardev, struct pfs_node *drm, char *path, char *prefix) { struct scsi_host_queue *scsi_host; - struct pfs_node *sub_dir; - int i, nchildren; + struct pfs_node *sub_dir, *cur_file; + int i, nchildren, error; device_t *children, parent; devclass_t devclass; const char *name = NULL; struct pci_devinfo *dinfo; - char *device, *host, *new_path = path; + char *device, *host, *new_path, *devname; + new_path = path; + devname = malloc(16, M_TEMP, M_WAITOK); + parent = device_get_parent(dev); if (parent) { devclass = device_get_devclass(parent); @@ -171,6 +313,40 @@ linsysfs_run_bus(device_t dev, struct pfs_node *dir, s strcat(new_path, device); dir = pfs_create_dir(dir, device, NULL, NULL, NULL, 0); + cur_file = pfs_create_file(dir, "vendor", + &linsysfs_fill_vendor, NULL, NULL, NULL, + PFS_RD); + cur_file->pn_data = (void*)dev; + cur_file = pfs_create_file(dir, "device", + &linsysfs_fill_device, NULL, NULL, NULL, + PFS_RD); + cur_file->pn_data = (void*)dev; + cur_file = pfs_create_file(dir, + "subsystem_vendor", + &linsysfs_fill_subvendor, NULL, NULL, NULL, + PFS_RD); + cur_file->pn_data = (void*)dev; + cur_file = pfs_create_file(dir, + "subsystem_device", + &linsysfs_fill_subdevice, NULL, NULL, NULL, + PFS_RD); + cur_file->pn_data = (void*)dev; + cur_file = pfs_create_file(dir, "revision", + &linsysfs_fill_revid, NULL, NULL, NULL, + PFS_RD); + cur_file->pn_data = (void*)dev; + cur_file = pfs_create_file(dir, "config", + &linsysfs_fill_config, NULL, NULL, NULL, + PFS_RD); + cur_file->pn_data = (void*)dev; + cur_file = pfs_create_file(dir, "uevent", + &linsysfs_fill_uevent_pci, NULL, NULL, + NULL, PFS_RD); + cur_file->pn_data = (void*)dev; + cur_file = pfs_create_link(dir, "subsystem", + &linsysfs_fill_data, NULL, NULL, NULL, 0); + /* libdrm just checks that the link ends in "/pci" */ + cur_file->pn_data = "/sys/bus/pci"; if (dinfo->cfg.baseclass == PCIC_STORAGE) { /* DJA only make this if needed */ @@ -207,15 +383,51 @@ linsysfs_run_bus(device_t dev, struct pfs_node *dir, s free(host, M_TEMP); } } + + devclass = device_get_devclass(dev); + if (devclass != NULL) + name = devclass_get_name(devclass); + else + name = NULL; + if (name != NULL && strcmp(name, DRMN_DEV) == 0 && + device_get_unit(dev) >= 0) { + dinfo = device_get_ivars(parent); + if (dinfo != NULL && dinfo->cfg.baseclass == PCIC_DISPLAY) { + sprintf(devname, "226:%d", + device_get_unit(dev)); + sub_dir = pfs_create_dir(chardev, + devname, NULL, NULL, NULL, 0); + cur_file = pfs_create_link(sub_dir, + "device", &linsysfs_fill_vgapci, NULL, + NULL, NULL, PFS_RD); + cur_file->pn_data = (void*)dir; + cur_file = pfs_create_file(sub_dir, + "uevent", &linsysfs_fill_uevent_drm, NULL, + NULL, NULL, PFS_RD); + cur_file->pn_data = (void*)dev; + sprintf(devname, "card%d", + device_get_unit(dev)); + sub_dir = pfs_create_dir(drm, + devname, NULL, NULL, NULL, 0); + cur_file = pfs_create_link(sub_dir, + "device", &linsysfs_fill_vgapci, NULL, + NULL, NULL, PFS_RD); + cur_file->pn_data = (void*)dir; + } + } } - device_get_children(dev, &children, &nchildren); - for (i = 0; i < nchildren; i++) { - if (children[i]) - linsysfs_run_bus(children[i], dir, scsi, new_path, prefix); + error = device_get_children(dev, &children, &nchildren); + if (error == 0) { + for (i = 0; i < nchildren; i++) + if (children[i]) + linsysfs_run_bus(children[i], dir, scsi, + chardev, drm, new_path, prefix); + free(children, M_TEMP); } if (new_path != path) free(new_path, M_TEMP); + free(devname, M_TEMP); return (1); } @@ -276,9 +488,12 @@ static int linsysfs_init(PFS_INIT_ARGS) { struct pfs_node *root; + struct pfs_node *class; struct pfs_node *dir, *sys, *cpu; + struct pfs_node *drm; struct pfs_node *pci; struct pfs_node *scsi; + struct pfs_node *devdir, *chardev; devclass_t devclass; device_t dev; @@ -287,13 +502,16 @@ linsysfs_init(PFS_INIT_ARGS) root = pi->pi_root; /* /sys/class/... */ - scsi = pfs_create_dir(root, "class", NULL, NULL, NULL, 0); - scsi = pfs_create_dir(scsi, "scsi_host", NULL, NULL, NULL, 0); + class = pfs_create_dir(root, "class", NULL, NULL, NULL, 0); + scsi = pfs_create_dir(class, "scsi_host", NULL, NULL, NULL, 0); + drm = pfs_create_dir(class, "drm", NULL, NULL, NULL, 0); - /* /sys/devices */ - dir = pfs_create_dir(root, "devices", NULL, NULL, NULL, 0); + /* /sys/dev/... */ + devdir = pfs_create_dir(root, "dev", NULL, NULL, NULL, 0); + chardev = pfs_create_dir(devdir, "char", NULL, NULL, NULL, 0); - /* /sys/devices/pci0000:00 */ + /* /sys/devices/... */ + dir = pfs_create_dir(root, "devices", NULL, NULL, NULL, 0); pci = pfs_create_dir(dir, "pci0000:00", NULL, NULL, NULL, 0); devclass = devclass_find("root"); @@ -302,7 +520,7 @@ linsysfs_init(PFS_INIT_ARGS) } dev = devclass_get_device(devclass, 0); - linsysfs_run_bus(dev, pci, scsi, "/pci0000:00", "0000"); + linsysfs_run_bus(dev, pci, scsi, chardev, drm, "/pci0000:00", "0000"); /* /sys/devices/system */ sys = pfs_create_dir(dir, "system", NULL, NULL, NULL, 0); Modified: stable/11/sys/compat/linux/linux_util.c ============================================================================== --- stable/11/sys/compat/linux/linux_util.c Thu Oct 26 16:36:27 2017 (r325014) +++ stable/11/sys/compat/linux/linux_util.c Thu Oct 26 17:45:01 2017 (r325015) @@ -127,23 +127,51 @@ int linux_driver_get_major_minor(const char *node, int *major, int *minor) { struct device_element *de; + unsigned long devno; + size_t sz; if (node == NULL || major == NULL || minor == NULL) return 1; - if (strlen(node) > strlen("pts/") && - strncmp(node, "pts/", strlen("pts/")) == 0) { - unsigned long devno; - + sz = sizeof("pts/") - 1; + if (strncmp(node, "pts/", sz) == 0 && node[sz] != '\0') { /* * Linux checks major and minors of the slave device * to make sure it's a pty device, so let's make him * believe it is. */ - devno = strtoul(node + strlen("pts/"), NULL, 10); + devno = strtoul(node + sz, NULL, 10); *major = 136 + (devno / 256); *minor = devno % 256; + return (0); + } + sz = sizeof("dri/card") - 1; + if (strncmp(node, "dri/card", sz) == 0 && node[sz] != '\0') { + devno = strtoul(node + sz, NULL, 10); + *major = 226 + (devno / 256); + *minor = devno % 256; + return (0); + } + sz = sizeof("dri/controlD") - 1; + if (strncmp(node, "dri/controlD", sz) == 0 && node[sz] != '\0') { + devno = strtoul(node + sz, NULL, 10); + *major = 226 + (devno / 256); + *minor = devno % 256; + return (0); + } + sz = sizeof("dri/renderD") - 1; + if (strncmp(node, "dri/renderD", sz) == 0 && node[sz] != '\0') { + devno = strtoul(node + sz, NULL, 10); + *major = 226 + (devno / 256); + *minor = devno % 256; + return (0); + } + sz = sizeof("drm/") - 1; + if (strncmp(node, "drm/", sz) == 0 && node[sz] != '\0') { + devno = strtoul(node + sz, NULL, 10); + *major = 226 + (devno / 256); + *minor = devno % 256; return (0); } Modified: stable/11/sys/kern/vfs_lookup.c ============================================================================== --- stable/11/sys/kern/vfs_lookup.c Thu Oct 26 16:36:27 2017 (r325014) +++ stable/11/sys/kern/vfs_lookup.c Thu Oct 26 17:45:01 2017 (r325015) @@ -1390,13 +1390,13 @@ kern_alternate_path(struct thread *td, const char *pre for (cp = &ptr[len] - 1; *cp != '/'; cp--); *cp = '\0'; - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td); + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, buf, td); error = namei(&nd); *cp = '/'; if (error != 0) goto keeporig; } else { - NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td); + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, buf, td); error = namei(&nd); if (error != 0) From owner-svn-src-stable-11@freebsd.org Thu Oct 26 22:19:29 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EDD3FE54390; Thu, 26 Oct 2017 22:19:29 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BA7F56BBA3; Thu, 26 Oct 2017 22:19:29 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9QMJSjs092728; Thu, 26 Oct 2017 22:19:28 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9QMJSpt092727; Thu, 26 Oct 2017 22:19:28 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201710262219.v9QMJSpt092727@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Thu, 26 Oct 2017 22:19:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r325023 - stable/11/sys/dev/sdhci X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/sys/dev/sdhci X-SVN-Commit-Revision: 325023 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Oct 2017 22:19:30 -0000 Author: ian Date: Thu Oct 26 22:19:28 2017 New Revision: 325023 URL: https://svnweb.freebsd.org/changeset/base/325023 Log: MFC r314914: Release all previously allocated resources. Modified: stable/11/sys/dev/sdhci/sdhci_fdt_gpio.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/sdhci/sdhci_fdt_gpio.c ============================================================================== --- stable/11/sys/dev/sdhci/sdhci_fdt_gpio.c Thu Oct 26 20:55:33 2017 (r325022) +++ stable/11/sys/dev/sdhci/sdhci_fdt_gpio.c Thu Oct 26 22:19:28 2017 (r325023) @@ -220,9 +220,14 @@ sdhci_fdt_gpio_teardown(struct sdhci_fdt_gpio *gpio) if (gpio == NULL) return; - if (gpio->cd_ihandler != NULL) { + if (gpio->cd_ihandler != NULL) bus_teardown_intr(gpio->dev, gpio->cd_ires, gpio->cd_ihandler); - } + if (gpio->wp_pin != NULL) + gpio_pin_release(gpio->wp_pin); + if (gpio->cd_pin != NULL) + gpio_pin_release(gpio->cd_pin); + if (gpio->cd_ires != NULL) + bus_release_resource(gpio->dev, SYS_RES_IRQ, 0, gpio->cd_ires); free(gpio, M_DEVBUF); } From owner-svn-src-stable-11@freebsd.org Fri Oct 27 04:38:43 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DDFDCE5B99C; Fri, 27 Oct 2017 04:38:43 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AF061766D7; Fri, 27 Oct 2017 04:38:43 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9R4cgNL050401; Fri, 27 Oct 2017 04:38:42 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9R4cgeR050394; Fri, 27 Oct 2017 04:38:42 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201710270438.v9R4cgeR050394@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Fri, 27 Oct 2017 04:38:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r325029 - in stable/11: sys/compat/freebsd32 sys/kern sys/sys usr.bin/gcore X-SVN-Group: stable-11 X-SVN-Commit-Author: bdrewery X-SVN-Commit-Paths: in stable/11: sys/compat/freebsd32 sys/kern sys/sys usr.bin/gcore X-SVN-Commit-Revision: 325029 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 04:38:44 -0000 Author: bdrewery Date: Fri Oct 27 04:38:42 2017 New Revision: 325029 URL: https://svnweb.freebsd.org/changeset/base/325029 Log: MFC r320481: Store a 32-bit PT_LWPINFO struct for 32-bit process core dumps. Modified: stable/11/sys/compat/freebsd32/freebsd32_signal.h stable/11/sys/kern/imgact_elf.c stable/11/sys/kern/sys_process.c stable/11/sys/sys/ptrace.h stable/11/sys/sys/signal.h stable/11/usr.bin/gcore/elf32core.c stable/11/usr.bin/gcore/elfcore.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/freebsd32/freebsd32_signal.h ============================================================================== --- stable/11/sys/compat/freebsd32/freebsd32_signal.h Fri Oct 27 03:16:19 2017 (r325028) +++ stable/11/sys/compat/freebsd32/freebsd32_signal.h Fri Oct 27 04:38:42 2017 (r325029) @@ -35,44 +35,6 @@ struct sigaltstack32 { int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ }; -union sigval32 { - int sival_int; - u_int32_t sival_ptr; - /* 6.0 compatibility */ - int sigval_int; - u_int32_t sigval_ptr; -}; - -struct siginfo32 { - int si_signo; /* signal number */ - int si_errno; /* errno association */ - int si_code; /* signal code */ - int32_t si_pid; /* sending process */ - u_int32_t si_uid; /* sender's ruid */ - int si_status; /* exit value */ - u_int32_t si_addr; /* faulting instruction */ - union sigval32 si_value; /* signal value */ - union { - struct { - int _trapno;/* machine specific trap code */ - } _fault; - struct { - int _timerid; - int _overrun; - } _timer; - struct { - int _mqd; - } _mesgq; - struct { - int _band; /* band event for SIGPOLL */ - } _poll; /* was this ever used ? */ - struct { - int __spare1__; - int __spare2__[7]; - } __spare__; - } _reason; -}; - struct osigevent32 { int sigev_notify; /* Notification type */ union { Modified: stable/11/sys/kern/imgact_elf.c ============================================================================== --- stable/11/sys/kern/imgact_elf.c Fri Oct 27 03:16:19 2017 (r325028) +++ stable/11/sys/kern/imgact_elf.c Fri Oct 27 04:38:42 2017 (r325029) @@ -1852,6 +1852,7 @@ __elfN(putnote)(struct note_info *ninfo, struct sbuf * #if defined(COMPAT_FREEBSD32) && __ELF_WORD_SIZE == 32 #include +#include typedef struct prstatus32 elf_prstatus_t; typedef struct prpsinfo32 elf_prpsinfo_t; @@ -2006,13 +2007,17 @@ __elfN(note_ptlwpinfo)(void *arg, struct sbuf *sb, siz struct thread *td; size_t size; int structsize; +#if defined(COMPAT_FREEBSD32) && __ELF_WORD_SIZE == 32 + struct ptrace_lwpinfo32 pl; +#else struct ptrace_lwpinfo pl; +#endif td = (struct thread *)arg; - size = sizeof(structsize) + sizeof(struct ptrace_lwpinfo); + size = sizeof(structsize) + sizeof(pl); if (sb != NULL) { KASSERT(*sizep == size, ("invalid size")); - structsize = sizeof(struct ptrace_lwpinfo); + structsize = sizeof(pl); sbuf_bcat(sb, &structsize, sizeof(structsize)); bzero(&pl, sizeof(pl)); pl.pl_lwpid = td->td_tid; @@ -2022,11 +2027,15 @@ __elfN(note_ptlwpinfo)(void *arg, struct sbuf *sb, siz if (td->td_si.si_signo != 0) { pl.pl_event = PL_EVENT_SIGNAL; pl.pl_flags |= PL_FLAG_SI; +#if defined(COMPAT_FREEBSD32) && __ELF_WORD_SIZE == 32 + siginfo_to_siginfo32(&td->td_si, &pl.pl_siginfo); +#else pl.pl_siginfo = td->td_si; +#endif } strcpy(pl.pl_tdname, td->td_name); /* XXX TODO: supply more information in struct ptrace_lwpinfo*/ - sbuf_bcat(sb, &pl, sizeof(struct ptrace_lwpinfo)); + sbuf_bcat(sb, &pl, sizeof(pl)); } *sizep = size; } Modified: stable/11/sys/kern/sys_process.c ============================================================================== --- stable/11/sys/kern/sys_process.c Fri Oct 27 03:16:19 2017 (r325028) +++ stable/11/sys/kern/sys_process.c Fri Oct 27 04:38:42 2017 (r325029) @@ -87,20 +87,6 @@ struct ptrace_vm_entry32 { u_int pve_fsid; uint32_t pve_path; }; - -struct ptrace_lwpinfo32 { - lwpid_t pl_lwpid; /* LWP described. */ - int pl_event; /* Event that stopped the LWP. */ - int pl_flags; /* LWP flags. */ - sigset_t pl_sigmask; /* LWP signal mask */ - sigset_t pl_siglist; /* LWP pending signal */ - struct siginfo32 pl_siginfo; /* siginfo for signal */ - char pl_tdname[MAXCOMLEN + 1]; /* LWP name. */ - pid_t pl_child_pid; /* New child pid */ - u_int pl_syscall_code; - u_int pl_syscall_narg; -}; - #endif /* Modified: stable/11/sys/sys/ptrace.h ============================================================================== --- stable/11/sys/sys/ptrace.h Fri Oct 27 03:16:19 2017 (r325028) +++ stable/11/sys/sys/ptrace.h Fri Oct 27 04:38:42 2017 (r325029) @@ -138,6 +138,21 @@ struct ptrace_lwpinfo { u_int pl_syscall_narg; }; +#if defined(_WANT_LWPINFO32) || (defined(_KERNEL) && defined(__LP64__)) +struct ptrace_lwpinfo32 { + lwpid_t pl_lwpid; /* LWP described. */ + int pl_event; /* Event that stopped the LWP. */ + int pl_flags; /* LWP flags. */ + sigset_t pl_sigmask; /* LWP signal mask */ + sigset_t pl_siglist; /* LWP pending signal */ + struct siginfo32 pl_siginfo; /* siginfo for signal */ + char pl_tdname[MAXCOMLEN + 1]; /* LWP name. */ + pid_t pl_child_pid; /* New child pid */ + u_int pl_syscall_code; + u_int pl_syscall_narg; +}; +#endif + /* Argument structure for PT_VM_ENTRY. */ struct ptrace_vm_entry { int pve_entry; /* Entry number used for iteration. */ Modified: stable/11/sys/sys/signal.h ============================================================================== --- stable/11/sys/sys/signal.h Fri Oct 27 03:16:19 2017 (r325028) +++ stable/11/sys/sys/signal.h Fri Oct 27 04:38:42 2017 (r325029) @@ -174,7 +174,17 @@ union sigval { int sigval_int; void *sigval_ptr; }; + +#if defined(_WANT_LWPINFO32) || (defined(_KERNEL) && defined(__LP64__)) +union sigval32 { + int sival_int; + uint32_t sival_ptr; + /* 6.0 compatibility */ + int sigval_int; + uint32_t sigval_ptr; +}; #endif +#endif #if __POSIX_VISIBLE >= 199309 @@ -255,6 +265,38 @@ typedef struct __siginfo { #define si_overrun _reason._timer._overrun #define si_mqd _reason._mesgq._mqd #define si_band _reason._poll._band + +#if defined(_WANT_LWPINFO32) || (defined(_KERNEL) && defined(__LP64__)) +struct siginfo32 { + int si_signo; /* signal number */ + int si_errno; /* errno association */ + int si_code; /* signal code */ + __pid_t si_pid; /* sending process */ + __uid_t si_uid; /* sender's ruid */ + int si_status; /* exit value */ + uint32_t si_addr; /* faulting instruction */ + union sigval32 si_value; /* signal value */ + union { + struct { + int _trapno;/* machine specific trap code */ + } _fault; + struct { + int _timerid; + int _overrun; + } _timer; + struct { + int _mqd; + } _mesgq; + struct { + int32_t _band; /* band event for SIGPOLL */ + } _poll; /* was this ever used ? */ + struct { + int32_t __spare1__; + int __spare2__[7]; + } __spare__; + } _reason; +}; +#endif /** si_code **/ /* codes for SIGILL */ Modified: stable/11/usr.bin/gcore/elf32core.c ============================================================================== --- stable/11/usr.bin/gcore/elf32core.c Fri Oct 27 03:16:19 2017 (r325028) +++ stable/11/usr.bin/gcore/elf32core.c Fri Oct 27 04:38:42 2017 (r325029) @@ -5,6 +5,7 @@ #define __ELF_WORD_SIZE 32 #define _MACHINE_ELF_WANT_32BIT +#define _WANT_LWPINFO32 #include @@ -46,3 +47,42 @@ elf_convert_fpregset(elfcore_fpregset_t *rd, struct fp #error Unsupported architecture #endif } + +static void +elf_convert_siginfo(struct siginfo32 *sid, siginfo_t *sis) +{ + + bzero(sid, sizeof(*sid)); + sid->si_signo = sis->si_signo; + sid->si_errno = sis->si_errno; + sid->si_code = sis->si_code; + sid->si_pid = sis->si_pid; + sid->si_uid = sis->si_uid; + sid->si_status = sis->si_status; + sid->si_addr = (uintptr_t)sis->si_addr; +#if _BYTE_ORDER == _BIG_ENDIAN + if (sis->si_value.sival_int == 0) + sid->si_value.sival_ptr = (uintptr_t)sis->si_value.sival_ptr; + else +#endif + sid->si_value.sival_int = sis->si_value.sival_int; + sid->si_timerid = sis->si_timerid; + sid->si_overrun = sis->si_overrun; +} + +static void +elf_convert_lwpinfo(struct ptrace_lwpinfo32 *pld, struct ptrace_lwpinfo *pls) +{ + + pld->pl_lwpid = pls->pl_lwpid; + pld->pl_event = pls->pl_event; + pld->pl_flags = pls->pl_flags; + pld->pl_sigmask = pls->pl_sigmask; + pld->pl_siglist = pls->pl_siglist; + elf_convert_siginfo(&pld->pl_siginfo, &pls->pl_siginfo); + memcpy(pld->pl_tdname, pls->pl_tdname, sizeof(pld->pl_tdname)); + pld->pl_child_pid = pls->pl_child_pid; + pld->pl_syscall_code = pls->pl_syscall_code; + pld->pl_syscall_narg = pls->pl_syscall_narg; +} + Modified: stable/11/usr.bin/gcore/elfcore.c ============================================================================== --- stable/11/usr.bin/gcore/elfcore.c Fri Oct 27 03:16:19 2017 (r325028) +++ stable/11/usr.bin/gcore/elfcore.c Fri Oct 27 04:38:42 2017 (r325029) @@ -81,15 +81,20 @@ typedef struct fpreg32 elfcore_fpregset_t; typedef struct reg32 elfcore_gregset_t; typedef struct prpsinfo32 elfcore_prpsinfo_t; typedef struct prstatus32 elfcore_prstatus_t; +typedef struct ptrace_lwpinfo32 elfcore_lwpinfo_t; static void elf_convert_gregset(elfcore_gregset_t *rd, struct reg *rs); static void elf_convert_fpregset(elfcore_fpregset_t *rd, struct fpreg *rs); +static void elf_convert_lwpinfo(struct ptrace_lwpinfo32 *pld, + struct ptrace_lwpinfo *pls); #else typedef fpregset_t elfcore_fpregset_t; typedef gregset_t elfcore_gregset_t; typedef prpsinfo_t elfcore_prpsinfo_t; typedef prstatus_t elfcore_prstatus_t; +typedef struct ptrace_lwpinfo elfcore_lwpinfo_t; #define elf_convert_gregset(d,s) *d = *s #define elf_convert_fpregset(d,s) *d = *s +#define elf_convert_lwpinfo(d,s) *d = *s #endif typedef void* (*notefunc_t)(void *, size_t *); @@ -668,15 +673,18 @@ static void * elf_note_ptlwpinfo(void *arg, size_t *sizep) { lwpid_t tid; + elfcore_lwpinfo_t *elf_info; + struct ptrace_lwpinfo lwpinfo; void *p; tid = *(lwpid_t *)arg; - p = calloc(1, sizeof(int) + sizeof(struct ptrace_lwpinfo)); + p = calloc(1, sizeof(int) + sizeof(elfcore_lwpinfo_t)); if (p == NULL) errx(1, "out of memory"); - *(int *)p = sizeof(struct ptrace_lwpinfo); - ptrace(PT_LWPINFO, tid, - (char *)p + sizeof (int), sizeof(struct ptrace_lwpinfo)); + *(int *)p = sizeof(elfcore_lwpinfo_t); + elf_info = (void *)((int *)p + 1); + ptrace(PT_LWPINFO, tid, (void *)&lwpinfo, sizeof(lwpinfo)); + elf_convert_lwpinfo(elf_info, &lwpinfo); *sizep = sizeof(int) + sizeof(struct ptrace_lwpinfo); return (p); From owner-svn-src-stable-11@freebsd.org Fri Oct 27 08:53:11 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3A722E3C5B9; Fri, 27 Oct 2017 08:53:11 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 01BA38141A; Fri, 27 Oct 2017 08:53:10 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9R8rABr056416; Fri, 27 Oct 2017 08:53:10 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9R8rAJa056415; Fri, 27 Oct 2017 08:53:10 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201710270853.v9R8rAJa056415@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 27 Oct 2017 08:53:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r325033 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 325033 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 08:53:11 -0000 Author: kib Date: Fri Oct 27 08:53:09 2017 New Revision: 325033 URL: https://svnweb.freebsd.org/changeset/base/325033 Log: MFC r324793: In vm_page_free_phys_pglist(), do not take vm_page_queue_free_mtx if there is nothing to do. Modified: stable/11/sys/vm/vm_page.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_page.c ============================================================================== --- stable/11/sys/vm/vm_page.c Fri Oct 27 05:04:29 2017 (r325032) +++ stable/11/sys/vm/vm_page.c Fri Oct 27 08:53:09 2017 (r325033) @@ -2848,6 +2848,8 @@ vm_page_free_phys_pglist(struct pglist *tq) { vm_page_t m; + if (TAILQ_EMPTY(tq)) + return; mtx_lock(&vm_page_queue_free_mtx); TAILQ_FOREACH(m, tq, listq) vm_page_free_phys(m); From owner-svn-src-stable-11@freebsd.org Fri Oct 27 14:22:57 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7DA1AE466E4; Fri, 27 Oct 2017 14:22:57 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4AF436710C; Fri, 27 Oct 2017 14:22:57 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9REMuvf093618; Fri, 27 Oct 2017 14:22:56 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9REMuTF093617; Fri, 27 Oct 2017 14:22:56 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201710271422.v9REMuTF093617@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 27 Oct 2017 14:22:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r325036 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 325036 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 14:22:57 -0000 Author: markj Date: Fri Oct 27 14:22:56 2017 New Revision: 325036 URL: https://svnweb.freebsd.org/changeset/base/325036 Log: MFC r324809: Free the right address range if kmem_back() fails in memguard_alloc(). Modified: stable/11/sys/vm/memguard.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/memguard.c ============================================================================== --- stable/11/sys/vm/memguard.c Fri Oct 27 12:37:22 2017 (r325035) +++ stable/11/sys/vm/memguard.c Fri Oct 27 14:22:56 2017 (r325036) @@ -283,7 +283,7 @@ v2sizev(vm_offset_t va) void * memguard_alloc(unsigned long req_size, int flags) { - vm_offset_t addr; + vm_offset_t addr, origaddr; u_long size_p, size_v; int do_guard, rv; @@ -327,7 +327,7 @@ memguard_alloc(unsigned long req_size, int flags) for (;;) { if (vmem_xalloc(memguard_arena, size_v, 0, 0, 0, memguard_cursor, VMEM_ADDR_MAX, - M_BESTFIT | M_NOWAIT, &addr) == 0) + M_BESTFIT | M_NOWAIT, &origaddr) == 0) break; /* * The map has no space. This may be due to @@ -342,11 +342,12 @@ memguard_alloc(unsigned long req_size, int flags) memguard_wrap++; memguard_cursor = memguard_base; } + addr = origaddr; if (do_guard) addr += PAGE_SIZE; rv = kmem_back(kmem_object, addr, size_p, flags); if (rv != KERN_SUCCESS) { - vmem_xfree(memguard_arena, addr, size_v); + vmem_xfree(memguard_arena, origaddr, size_v); memguard_fail_pgs++; addr = (vm_offset_t)NULL; goto out; From owner-svn-src-stable-11@freebsd.org Fri Oct 27 14:24:36 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6A874E4681E; Fri, 27 Oct 2017 14:24:36 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3798767390; Fri, 27 Oct 2017 14:24:36 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9REOZkV093788; Fri, 27 Oct 2017 14:24:35 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9REOZ1M093787; Fri, 27 Oct 2017 14:24:35 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201710271424.v9REOZ1M093787@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 27 Oct 2017 14:24:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r325038 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 325038 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 14:24:36 -0000 Author: markj Date: Fri Oct 27 14:24:35 2017 New Revision: 325038 URL: https://svnweb.freebsd.org/changeset/base/325038 Log: MFC r324804: Avoid the nbp lookup in the final loop iteration in flushbuflist(). Modified: stable/11/sys/kern/vfs_subr.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/vfs_subr.c ============================================================================== --- stable/11/sys/kern/vfs_subr.c Fri Oct 27 14:23:53 2017 (r325037) +++ stable/11/sys/kern/vfs_subr.c Fri Oct 27 14:24:35 2017 (r325038) @@ -1676,8 +1676,6 @@ flushbuflist(struct bufv *bufv, int flags, struct bufo ((flags & V_ALT) && (bp->b_xflags & BX_ALTDATA) == 0)) { continue; } - lblkno = 0; - xflags = 0; if (nbp != NULL) { lblkno = nbp->b_lblkno; xflags = nbp->b_xflags & (BX_VNDIRTY | BX_VNCLEAN); @@ -1712,6 +1710,8 @@ flushbuflist(struct bufv *bufv, int flags, struct bufo bp->b_flags &= ~B_ASYNC; brelse(bp); BO_LOCK(bo); + if (nbp == NULL) + break; nbp = gbincore(bo, lblkno); if (nbp == NULL || (nbp->b_xflags & (BX_VNDIRTY | BX_VNCLEAN)) != xflags) From owner-svn-src-stable-11@freebsd.org Fri Oct 27 15:33:27 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9B167E4908A; Fri, 27 Oct 2017 15:33:27 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 68F896B27A; Fri, 27 Oct 2017 15:33:27 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9RFXQKj023392; Fri, 27 Oct 2017 15:33:26 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9RFXQ4M023391; Fri, 27 Oct 2017 15:33:26 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201710271533.v9RFXQ4M023391@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 27 Oct 2017 15:33:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r325041 - stable/11/lib/libprocstat X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/lib/libprocstat X-SVN-Commit-Revision: 325041 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 15:33:27 -0000 Author: kib Date: Fri Oct 27 15:33:26 2017 New Revision: 325041 URL: https://svnweb.freebsd.org/changeset/base/325041 Log: MFC r316304 (by tychon): Reorder includes to placate MIPS build. Reported and tested by: David Wolfskill Modified: stable/11/lib/libprocstat/libprocstat.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libprocstat/libprocstat.c ============================================================================== --- stable/11/lib/libprocstat/libprocstat.c Fri Oct 27 14:57:38 2017 (r325040) +++ stable/11/lib/libprocstat/libprocstat.c Fri Oct 27 15:33:26 2017 (r325041) @@ -63,10 +63,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #define _KERNEL #include #include -#include #include #include #include From owner-svn-src-stable-11@freebsd.org Fri Oct 27 16:16:24 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 63189E4B1E6; Fri, 27 Oct 2017 16:16:24 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 342026E59D; Fri, 27 Oct 2017 16:16:24 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (unknown [127.0.1.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by freefall.freebsd.org (Postfix) with ESMTPS id 4F6852404; Fri, 27 Oct 2017 16:16:23 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (localhost [172.31.3.2]) by mail.xzibition.com (Postfix) with ESMTP id 1CBCA94BB; Fri, 27 Oct 2017 16:16:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at mail.xzibition.com Received: from mail.xzibition.com ([172.31.3.2]) by mail.xzibition.com (mail.xzibition.com [172.31.3.2]) (amavisd-new, port 10026) with LMTP id XqGWvJ1asSvK; Fri, 27 Oct 2017 16:16:19 +0000 (UTC) Subject: Re: svn commit: r325041 - stable/11/lib/libprocstat DKIM-Filter: OpenDKIM Filter v2.9.2 mail.xzibition.com 2688894B6 To: Konstantin Belousov , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org References: <201710271533.v9RFXQ4M023391@repo.freebsd.org> From: Bryan Drewery Openpgp: id=F9173CB2C3AAEA7A5C8A1F0935D771BB6E4697CF; url=http://www.shatow.net/bryan/bryan2.asc Organization: FreeBSD Message-ID: Date: Fri, 27 Oct 2017 09:16:13 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <201710271533.v9RFXQ4M023391@repo.freebsd.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="2gUTU5sC5rPkfB8TcpKNBJutSuOQ5EWKa" X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 16:16:24 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --2gUTU5sC5rPkfB8TcpKNBJutSuOQ5EWKa Content-Type: multipart/mixed; boundary="fX3oh2qBlNQFtFse1OVqqkgakkGiuOiAu"; protected-headers="v1" From: Bryan Drewery To: Konstantin Belousov , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Message-ID: Subject: Re: svn commit: r325041 - stable/11/lib/libprocstat References: <201710271533.v9RFXQ4M023391@repo.freebsd.org> In-Reply-To: <201710271533.v9RFXQ4M023391@repo.freebsd.org> --fX3oh2qBlNQFtFse1OVqqkgakkGiuOiAu Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 10/27/2017 8:33 AM, Konstantin Belousov wrote: > Author: kib > Date: Fri Oct 27 15:33:26 2017 > New Revision: 325041 > URL: https://svnweb.freebsd.org/changeset/base/325041 >=20 > Log: > MFC r316304 (by tychon): > Reorder includes to placate MIPS build. > =20 > Reported and tested by: David Wolfskill Thank you. --=20 Regards, Bryan Drewery --fX3oh2qBlNQFtFse1OVqqkgakkGiuOiAu-- --2gUTU5sC5rPkfB8TcpKNBJutSuOQ5EWKa Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBAgAGBQJZ81vTAAoJEDXXcbtuRpfPLWcH/03FRzihENmkH3vRA0tZnUYG 9ix7xNd3xqN5VE+AuxgIOxUGRdOG6gqIBJYacScbGuxWqsvqEQ/XNAtKc6AgOduS f+bCjxEVPue+f45WORlcDzkZaGl5g14vGUm1GzLq08x7hWDCaUFnFhk3dO7vjI15 K97eEKNvhLK1BgtLbKeRYvcGQtAb61+Koj3buNRax5SfCuUmlCW8wPdZqHImxs29 uTnBCLtUslRg++WKkLzm1LQChFIGVbUw1NVMUYVu1+RxQcsFEoF2d6jra58AsDyX P+DYt7FOIi9lb79yNKFuaWvUfrf3e/1GslMd3OhRp25/GfUhWsVj9VrYMBOyBU0= =BfQK -----END PGP SIGNATURE----- --2gUTU5sC5rPkfB8TcpKNBJutSuOQ5EWKa-- From owner-svn-src-stable-11@freebsd.org Fri Oct 27 16:38:35 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C623EE4B8E9; Fri, 27 Oct 2017 16:38:35 +0000 (UTC) (envelope-from mack@macktronics.com) Received: from borg.macktronics.com (gw.macktronics.com [209.181.253.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9E5726F197; Fri, 27 Oct 2017 16:38:34 +0000 (UTC) (envelope-from mack@macktronics.com) Received: from pandora.local (olive.macktronics.com [209.181.253.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by borg.macktronics.com (Postfix) with ESMTPS id 5B595A2D; Fri, 27 Oct 2017 11:38:32 -0500 (CDT) From: Dan Mack To: Bryan Drewery Cc: Konstantin Belousov , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r325041 - stable/11/lib/libprocstat References: <201710271533.v9RFXQ4M023391@repo.freebsd.org> Date: Fri, 27 Oct 2017 11:38:28 -0500 In-Reply-To: (Bryan Drewery's message of "Fri, 27 Oct 2017 09:16:13 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (darwin) MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 16:38:35 -0000 Bryan Drewery writes: > On 10/27/2017 8:33 AM, Konstantin Belousov wrote: >> Author: kib >> Date: Fri Oct 27 15:33:26 2017 >> New Revision: 325041 >> URL: https://svnweb.freebsd.org/changeset/base/325041 >> >> Log: >> MFC r316304 (by tychon): >> Reorder includes to placate MIPS build. >> >> Reported and tested by: David Wolfskill > > Thank you. Seems to have fixed broken amd64 build - commit references a fix for MIPS? Dan From owner-svn-src-stable-11@freebsd.org Fri Oct 27 17:00:44 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5CC4AE4C2F9; Fri, 27 Oct 2017 17:00:44 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DEE687001F; Fri, 27 Oct 2017 17:00:43 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v9RH0cAe039749 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 27 Oct 2017 20:00:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v9RH0cAe039749 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v9RH0cTq039748; Fri, 27 Oct 2017 20:00:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 27 Oct 2017 20:00:38 +0300 From: Konstantin Belousov To: Dan Mack Cc: Bryan Drewery , Konstantin Belousov , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r325041 - stable/11/lib/libprocstat Message-ID: <20171027170038.GI2566@kib.kiev.ua> References: <201710271533.v9RFXQ4M023391@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 17:00:44 -0000 On Fri, Oct 27, 2017 at 11:38:28AM -0500, Dan Mack wrote: > Bryan Drewery writes: > > > On 10/27/2017 8:33 AM, Konstantin Belousov wrote: > >> Author: kib > >> Date: Fri Oct 27 15:33:26 2017 > >> New Revision: 325041 > >> URL: https://svnweb.freebsd.org/changeset/base/325041 > >> > >> Log: > >> MFC r316304 (by tychon): > >> Reorder includes to placate MIPS build. > >> > >> Reported and tested by: David Wolfskill > > > > Thank you. > > Seems to have fixed broken amd64 build - commit references a fix for > MIPS? This was the original commit message. From owner-svn-src-stable-11@freebsd.org Fri Oct 27 17:02:36 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD085E4C60D; Fri, 27 Oct 2017 17:02:36 +0000 (UTC) (envelope-from mack@macktronics.com) Received: from borg.macktronics.com (gw.macktronics.com [209.181.253.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 82ED470480; Fri, 27 Oct 2017 17:02:36 +0000 (UTC) (envelope-from mack@macktronics.com) Received: from pandora.local (olive.macktronics.com [209.181.253.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by borg.macktronics.com (Postfix) with ESMTPS id 9C42AA38; Fri, 27 Oct 2017 12:02:33 -0500 (CDT) From: Dan Mack To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-stable@freebsd.org, svn-src-all@freebsd.org, svn-src-stable-11@freebsd.org, Bryan Drewery , Konstantin Belousov Subject: Re: svn commit: r325041 - stable/11/lib/libprocstat References: <201710271533.v9RFXQ4M023391@repo.freebsd.org> <20171027170038.GI2566@kib.kiev.ua> Date: Fri, 27 Oct 2017 12:02:31 -0500 In-Reply-To: <20171027170038.GI2566@kib.kiev.ua> (Konstantin Belousov's message of "Fri, 27 Oct 2017 20:00:38 +0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (darwin) MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 17:02:36 -0000 Konstantin Belousov writes: > On Fri, Oct 27, 2017 at 11:38:28AM -0500, Dan Mack wrote: >> Bryan Drewery writes: >> >> > On 10/27/2017 8:33 AM, Konstantin Belousov wrote: >> >> Author: kib >> >> Date: Fri Oct 27 15:33:26 2017 >> >> New Revision: 325041 >> >> URL: https://svnweb.freebsd.org/changeset/base/325041 >> >> >> >> Log: >> >> MFC r316304 (by tychon): >> >> Reorder includes to placate MIPS build. >> >> >> >> Reported and tested by: David Wolfskill >> > >> > Thank you. >> >> Seems to have fixed broken amd64 build - commit references a fix for >> MIPS? > > This was the original commit message. Ack - thx! Dan From owner-svn-src-stable-11@freebsd.org Sat Oct 28 07:06:32 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EFCF3E5D8F0; Sat, 28 Oct 2017 07:06:31 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B43C865D64; Sat, 28 Oct 2017 07:06:31 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9S76Uo4013234; Sat, 28 Oct 2017 07:06:30 GMT (envelope-from se@FreeBSD.org) Received: (from se@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9S76UZk013232; Sat, 28 Oct 2017 07:06:30 GMT (envelope-from se@FreeBSD.org) Message-Id: <201710280706.v9S76UZk013232@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: se set sender to se@FreeBSD.org using -f From: Stefan Esser Date: Sat, 28 Oct 2017 07:06:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r325052 - in stable/11/share/man: man5 man8 X-SVN-Group: stable-11 X-SVN-Commit-Author: se X-SVN-Commit-Paths: in stable/11/share/man: man5 man8 X-SVN-Commit-Revision: 325052 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Oct 2017 07:06:32 -0000 Author: se Date: Sat Oct 28 07:06:30 2017 New Revision: 325052 URL: https://svnweb.freebsd.org/changeset/base/325052 Log: MFC 324721: Add references to sysrc(8) to SEE ALSO. MFC 324823: Mention sysrc(8) as scripting interface for config files. Modified: stable/11/share/man/man5/rc.conf.5 stable/11/share/man/man8/rc.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man5/rc.conf.5 ============================================================================== --- stable/11/share/man/man5/rc.conf.5 Sat Oct 28 02:51:27 2017 (r325051) +++ stable/11/share/man/man5/rc.conf.5 Sat Oct 28 07:06:30 2017 (r325052) @@ -64,6 +64,9 @@ is used to override settings in .Pa /etc/rc.conf for historical reasons. .Pp +The sysrc(8) command provides a scripting interface to modify system +config files. +.Pp In addition to .Pa /etc/rc.conf.local you can also place smaller configuration files for each @@ -4666,6 +4669,7 @@ configuration file. .Xr swapon 8 , .Xr sysctl 8 , .Xr syslogd 8 , +.Xr sysrc 8 , .Xr timed 8 , .Xr unbound 8 , .Xr usbconfig 8 , Modified: stable/11/share/man/man8/rc.8 ============================================================================== --- stable/11/share/man/man8/rc.8 Sat Oct 28 02:51:27 2017 (r325051) +++ stable/11/share/man/man8/rc.8 Sat Oct 28 07:06:30 2017 (r325052) @@ -87,6 +87,9 @@ The .Nm rc.d/ directories contain scripts which will be automatically executed at boot time and shutdown time. +.Pp +The sysrc(8) command provides a scripting interface to modify system +config files. .Ss Operation of Nm .Bl -enum .It @@ -557,7 +560,8 @@ is unnecessary, but is often included. .Xr rc.subr 8 , .Xr rcorder 8 , .Xr reboot 8 , -.Xr savecore 8 +.Xr savecore 8 , +.Xr sysrc 8 .Sh HISTORY The .Nm