CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: msaitoh Date: Tue May 12 06:32:05 UTC 2020 Modified Files: src/sys/arch/x86/x86: cpu.c identcpu_subr.c Log Message: Don't use TSC freq value from CPUID if calibration works. - When it's the first call of cpu_get_tsc_freq() the HPET is not initialized, so try to use CPUID to get TSC freq. - If it's the 2nd call, don't use CPUID. Instead, print the difference between the calibrated value and CPUID's value if the verbose mode is set. To generate a diff of this commit: cvs rdiff -u -r1.190 -r1.191 src/sys/arch/x86/x86/cpu.c cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/x86/identcpu_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/cpu.c diff -u src/sys/arch/x86/x86/cpu.c:1.190 src/sys/arch/x86/x86/cpu.c:1.191 --- src/sys/arch/x86/x86/cpu.c:1.190 Fri May 8 22:01:55 2020 +++ src/sys/arch/x86/x86/cpu.c Tue May 12 06:32:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.190 2020/05/08 22:01:55 ad Exp $ */ +/* $NetBSD: cpu.c,v 1.191 2020/05/12 06:32:05 msaitoh Exp $ */ /* * Copyright (c) 2000-2020 NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.190 2020/05/08 22:01:55 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.191 2020/05/12 06:32:05 msaitoh Exp $"); #include "opt_ddb.h" #include "opt_mpbios.h" /* for MPDEBUG */ @@ -1320,11 +1320,19 @@ cpu_shutdown(device_t dv, int how) void cpu_get_tsc_freq(struct cpu_info *ci) { - uint64_t freq = 0, t0, t1; + uint64_t freq = 0, freq_from_cpuid, t0, t1; int64_t overhead; if ((ci->ci_flags & CPUF_PRIMARY) != 0 && cpu_hascounter()) { - freq = cpu_tsc_freq_cpuid(ci); + /* + * If it's the first call of this function, try to get TSC + * freq from CPUID by calling cpu_tsc_freq_cpuid(). + * The function also set lapic_per_second variable if it's + * known. This is required for Intel's Comet Lake and newer + * processors to set LAPIC timer correctly. + */ + if (ci->ci_data.cpu_cc_freq == 0) + freq = freq_from_cpuid = cpu_tsc_freq_cpuid(ci); #if NHPET > 0 if (freq == 0) freq = hpet_tsc_freq(); @@ -1352,6 +1360,13 @@ cpu_get_tsc_freq(struct cpu_info *ci) t1 = cpu_counter(); freq = (t1 - t0 - overhead) * 10; } + if (ci->ci_data.cpu_cc_freq != 0) { + freq_from_cpuid = cpu_tsc_freq_cpuid(ci); + if ((freq_from_cpuid != 0) + && (freq != freq_from_cpuid)) +aprint_verbose_dev(ci->ci_dev, "TSC freq " +"calibrated %" PRIu64 " Hz\n", freq); + } } else { freq = cpu_info_primary.ci_data.cpu_cc_freq; } Index: src/sys/arch/x86/x86/identcpu_subr.c diff -u src/sys/arch/x86/x86/identcpu_subr.c:1.3 src/sys/arch/x86/x86/identcpu_subr.c:1.4 --- src/sys/arch/x86/x86/identcpu_subr.c:1.3 Sat Apr 25 15:26:18 2020 +++ src/sys/arch/x86/x86/identcpu_subr.c Tue May 12 06:32:05 2020 @@ -33,7 +33,7 @@ * See src/usr.sbin/cpuctl/{Makefile, arch/i386.c}). */ #include -__KERNEL_RCSID(0, "$NetBSD: identcpu_subr.c,v 1.3 2020/04/25 15:26:18 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: identcpu_subr.c,v 1.4 2020/05/12 06:32:05 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "lapic.h" @@ -139,8 +139,8 @@ cpu_tsc_freq_cpuid(struct cpu_info *ci) #endif } if (freq != 0) - aprint_verbose_dev(ci->ci_dev, "TSC freq %" PRIu64 " Hz\n", - freq); + aprint_verbose_dev(ci->ci_dev, "TSC freq CPUID %" PRIu64 + " Hz\n", freq); return freq; }
CVS commit: src/usr.sbin/sysinst
Module Name:src Committed By: martin Date: Tue May 12 06:23:07 UTC 2020 Modified Files: src/usr.sbin/sysinst: bsddisklabel.c Log Message: Minor tweak to previous: when forcing a /usr partition just to have an arbitrary extendable partition, still use its default size initially. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/sysinst/bsddisklabel.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/sysinst/bsddisklabel.c diff -u src/usr.sbin/sysinst/bsddisklabel.c:1.41 src/usr.sbin/sysinst/bsddisklabel.c:1.42 --- src/usr.sbin/sysinst/bsddisklabel.c:1.41 Mon May 11 17:40:50 2020 +++ src/usr.sbin/sysinst/bsddisklabel.c Tue May 12 06:23:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bsddisklabel.c,v 1.41 2020/05/11 17:40:50 martin Exp $ */ +/* $NetBSD: bsddisklabel.c,v 1.42 2020/05/12 06:23:07 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -1147,7 +1147,8 @@ fill_defaults(struct partition_usage_set wanted->infos[usr].size = wanted->infos[root].size - wanted->infos[root].limit; if (wanted->infos[usr].size <= 0) -wanted->infos[usr].size = 1; +wanted->infos[usr].size = max(1, +wanted->infos[usr].def_size); wanted->infos[root].size = wanted->infos[root].limit; if (wanted->infos[root].flags & PUIFLAG_EXTEND) {
CVS commit: src/sys/dev/pci
Module Name:src Committed By: jakllsch Date: Mon May 11 23:47:45 UTC 2020 Modified Files: src/sys/dev/pci: if_msk.c Log Message: msk(4): ack Status BMU IRQ only if we're (apparently) caught up with it Possibility for acking an unprocessed Status BMU IRQ still exists, and remains handled by the watchdog. Nevertheless this should reduce the likelyhood that path is taken. To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/sys/dev/pci/if_msk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_msk.c diff -u src/sys/dev/pci/if_msk.c:1.112 src/sys/dev/pci/if_msk.c:1.113 --- src/sys/dev/pci/if_msk.c:1.112 Mon May 11 19:17:46 2020 +++ src/sys/dev/pci/if_msk.c Mon May 11 23:47:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_msk.c,v 1.112 2020/05/11 19:17:46 jakllsch Exp $ */ +/* $NetBSD: if_msk.c,v 1.113 2020/05/11 23:47:45 jakllsch Exp $ */ /* $OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $ */ /* @@ -52,7 +52,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.112 2020/05/11 19:17:46 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.113 2020/05/11 23:47:45 jakllsch Exp $"); #include #include @@ -2277,6 +2277,7 @@ msk_intr(void *xsc) struct ifnet *ifp0 = NULL, *ifp1 = NULL; uint32_t status; struct msk_status_desc *cur_st; + bool retried = false; status = CSR_READ_4(sc, SK_Y2_ISSR2); if (status == 0x) @@ -2303,6 +2304,7 @@ msk_intr(void *xsc) msk_intr_yukon(sc_if1); } +again: MSK_CDSTSYNC(sc, sc->sk_status_idx, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); cur_st = &sc->sk_status_ring[sc->sk_status_idx]; @@ -2336,8 +2338,11 @@ msk_intr(void *xsc) cur_st = &sc->sk_status_ring[sc->sk_status_idx]; } - if (status & SK_Y2_IMR_BMU) { + if (CSR_READ_2(sc, SK_STAT_BMU_PUTIDX) == sc->sk_status_idx) { CSR_WRITE_4(sc, SK_STAT_BMU_CSR, SK_STAT_BMU_IRQ_CLEAR); + } else if (!retried) { + retried = true; + goto again; } CSR_WRITE_4(sc, SK_Y2_ICR, 2);
CVS commit: src
Module Name:src Committed By: yhardy Date: Mon May 11 21:51:25 UTC 2020 Modified Files: src/distrib/sets/lists/debug: md.amd64 src/distrib/sets/lists/tests: md.amd64 src/tests/lib/libi386: Makefile Log Message: Fix the build for MKCOMPAT=no. The t_user_ldt test needs the i386 compat library which is only built when MKCOMPAT=yes. To generate a diff of this commit: cvs rdiff -u -r1.108 -r1.109 src/distrib/sets/lists/debug/md.amd64 cvs rdiff -u -r1.10 -r1.11 src/distrib/sets/lists/tests/md.amd64 cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libi386/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/debug/md.amd64 diff -u src/distrib/sets/lists/debug/md.amd64:1.108 src/distrib/sets/lists/debug/md.amd64:1.109 --- src/distrib/sets/lists/debug/md.amd64:1.108 Sun Apr 26 09:08:40 2020 +++ src/distrib/sets/lists/debug/md.amd64 Mon May 11 21:51:25 2020 @@ -1,4 +1,4 @@ -# $NetBSD: md.amd64,v 1.108 2020/04/26 09:08:40 maxv Exp $ +# $NetBSD: md.amd64,v 1.109 2020/05/11 21:51:25 yhardy Exp $ ./usr/lib/i386/12.202++_g.a comp-c-debuglib debuglib,compat,12.202xx ./usr/lib/i386/libi386_g.a comp-c-debuglib debuglib,compat ./usr/lib/i386/libiberty_g.a comp-obsolete obsolete @@ -25,7 +25,7 @@ ./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_wait6.debug tests-obsolete obsolete ./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_waitid.debug tests-obsolete obsolete ./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_waitpid.debug tests-obsolete obsolete -./usr/libdata/debug/usr/tests/lib/libi386/t_user_ldt.debug tests-lib-debug debug,atf +./usr/libdata/debug/usr/tests/lib/libi386/t_user_ldt.debug tests-lib-debug debug,atf,compat ./usr/libdata/debug/usr/tests/lib/libnvmm/h_io_assist.debug tests-lib-debug debug,atf ./usr/libdata/debug/usr/tests/lib/libnvmm/h_mem_assist.debug tests-lib-debug debug,atf ./usr/libdata/debug/usr/tests/modules/t_x86_pte.debug tests-sys-debug debug,atf Index: src/distrib/sets/lists/tests/md.amd64 diff -u src/distrib/sets/lists/tests/md.amd64:1.10 src/distrib/sets/lists/tests/md.amd64:1.11 --- src/distrib/sets/lists/tests/md.amd64:1.10 Tue Apr 28 13:43:45 2020 +++ src/distrib/sets/lists/tests/md.amd64 Mon May 11 21:51:25 2020 @@ -1,4 +1,4 @@ -# $NetBSD: md.amd64,v 1.10 2020/04/28 13:43:45 rjs Exp $ +# $NetBSD: md.amd64,v 1.11 2020/05/11 21:51:25 yhardy Exp $ ./usr/tests/kernel/arch/x86/Atffile tests-obsolete obsolete ./usr/tests/kernel/arch/x86/Kyuafile tests-obsolete obsolete ./usr/tests/kernel/arch/x86/t_ptrace_wait tests-obsolete obsolete @@ -7,7 +7,7 @@ ./usr/tests/kernel/arch/x86/t_ptrace_wait6 tests-obsolete obsolete ./usr/tests/kernel/arch/x86/t_ptrace_waitid tests-obsolete obsolete ./usr/tests/kernel/arch/x86/t_ptrace_waitpid tests-obsolete obsolete -./usr/tests/lib/libi386/t_user_ldt tests-lib-tests compattestfile,atf +./usr/tests/lib/libi386/t_user_ldt tests-lib-tests compattestfile,atf,compat ./usr/tests/lib/libnvmm/h_io_assist tests-lib-tests compattestfile,atf ./usr/tests/lib/libnvmm/t_io_assist tests-lib-tests compattestfile,atf ./usr/tests/lib/libnvmm/h_mem_assist tests-lib-tests compattestfile,atf Index: src/tests/lib/libi386/Makefile diff -u src/tests/lib/libi386/Makefile:1.3 src/tests/lib/libi386/Makefile:1.4 --- src/tests/lib/libi386/Makefile:1.3 Mon Apr 20 12:08:08 2020 +++ src/tests/lib/libi386/Makefile Mon May 11 21:51:25 2020 @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.3 2020/04/20 12:08:08 joerg Exp $ +# $NetBSD: Makefile,v 1.4 2020/05/11 21:51:25 yhardy Exp $ .include TESTSDIR= ${TESTSBASE}/lib/libi386 -.if ${MACHINE} == "amd64" +.if ${MACHINE} == "amd64" && ${MKCOMPAT} == "yes" SHLIBINSTALLDIR= /usr/lib/i386 COPTS+= -m32 LDFLAGS+= -m32
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Mon May 11 21:40:12 UTC 2020 Modified Files: src/sys/kern: subr_cprng.c Log Message: Remove cprng initialization order hack. cprng_init now runs early enough that the hack should no longer be needed to address PR port-arm32/55252. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/kern/subr_cprng.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_cprng.c diff -u src/sys/kern/subr_cprng.c:1.39 src/sys/kern/subr_cprng.c:1.40 --- src/sys/kern/subr_cprng.c:1.39 Mon May 11 21:38:54 2020 +++ src/sys/kern/subr_cprng.c Mon May 11 21:40:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_cprng.c,v 1.39 2020/05/11 21:38:54 riastradh Exp $ */ +/* $NetBSD: subr_cprng.c,v 1.40 2020/05/11 21:40:12 riastradh Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -52,7 +52,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.39 2020/05/11 21:38:54 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.40 2020/05/11 21:40:12 riastradh Exp $"); #include #include @@ -102,7 +102,6 @@ struct cprng_strong *kern_cprng __read_m struct cprng_strong *user_cprng __read_mostly; /* IPL_NONE */ static struct sysctllog *cprng_sysctllog __read_mostly; -static bool cprng_initialized __read_mostly = false; void cprng_init(void) @@ -129,9 +128,6 @@ cprng_init(void) CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_INT /*lie*/, "arandom", SYSCTL_DESCR("Independent uniform random bytes, up to 256 bytes"), sysctl_kern_arandom, 0, NULL, 0, CTL_KERN, KERN_ARND, CTL_EOL); - - /* Ready to go. */ - cprng_initialized = true; } /* @@ -281,25 +277,6 @@ cprng_strong(struct cprng_strong *cprng, int s; /* - * Some device drivers try to use cprng_strong in attach during - * autoconf, e.g. to randomly generate MAC addresses, before we - * percpu is available -- percpu is not available until after - * CPUs have been detected during autoconf. We should make - * percpu available sooner, but for now this works around it. - */ - if (__predict_false(!cprng_initialized)) { - struct nist_hash_drbg drbg; - entropy_extract(seed, sizeof seed, 0); - if (__predict_false(nist_hash_drbg_instantiate(&drbg, - seed, sizeof seed, NULL, 0, NULL, 0))) - panic("nist_hash_drbg_instantiate"); - if (__predict_false(nist_hash_drbg_generate(&drbg, buf, len, - NULL, 0))) - panic("nist_hash_drbg_generate"); - return len; - } - - /* * Verify maximum request length. Caller should really limit * their requests to 32 bytes to avoid spending much time with * preemption disabled -- use the 32 bytes to seed a private
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Mon May 11 21:38:54 UTC 2020 Modified Files: src/sys/kern: init_main.c subr_cprng.c Log Message: Move cprng_init before configure. This makes it available to device drivers, e.g. to generate MAC addresses at random, without initialization order hacks. Requires a minor initialization hack for cpu_name(primary cpu) early on, since that doesn't get set until mi_cpu_attach which may not run until the middle of configure. But this hack is less bad than other initialization order hacks. To generate a diff of this commit: cvs rdiff -u -r1.524 -r1.525 src/sys/kern/init_main.c cvs rdiff -u -r1.38 -r1.39 src/sys/kern/subr_cprng.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/init_main.c diff -u src/sys/kern/init_main.c:1.524 src/sys/kern/init_main.c:1.525 --- src/sys/kern/init_main.c:1.524 Thu Apr 30 03:28:18 2020 +++ src/sys/kern/init_main.c Mon May 11 21:38:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.524 2020/04/30 03:28:18 riastradh Exp $ */ +/* $NetBSD: init_main.c,v 1.525 2020/05/11 21:38:54 riastradh Exp $ */ /*- * Copyright (c) 2008, 2009, 2019 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.524 2020/04/30 03:28:18 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.525 2020/05/11 21:38:54 riastradh Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -395,6 +395,8 @@ main(void) */ rnd_init(); /* initialize entropy pool */ + cprng_init(); /* initialize cryptographic PRNG */ + /* Initialize process and pgrp structures. */ procinit(); lwpinit(); @@ -529,8 +531,6 @@ main(void) /* Configure the system hardware. This will enable interrupts. */ configure(); - cprng_init(); /* initialize cryptographic PRNG */ - /* Once all CPUs are detected, initialize the per-CPU cprng_fast. */ cprng_fast_init(); Index: src/sys/kern/subr_cprng.c diff -u src/sys/kern/subr_cprng.c:1.38 src/sys/kern/subr_cprng.c:1.39 --- src/sys/kern/subr_cprng.c:1.38 Mon May 11 17:27:48 2020 +++ src/sys/kern/subr_cprng.c Mon May 11 21:38:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_cprng.c,v 1.38 2020/05/11 17:27:48 riastradh Exp $ */ +/* $NetBSD: subr_cprng.c,v 1.39 2020/05/11 21:38:54 riastradh Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -52,7 +52,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.38 2020/05/11 17:27:48 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.39 2020/05/11 21:38:54 riastradh Exp $"); #include #include @@ -217,6 +217,7 @@ cprng_init_cpu(void *ptr, void *cookie, { struct cprng_cpu *cc = ptr; const char *name = cookie; + const char *cpuname; uint8_t zero[NIST_HASH_DRBG_SEEDLEN_BYTES] = {0}; char namebuf[64]; /* XXX size? */ @@ -246,10 +247,12 @@ cprng_init_cpu(void *ptr, void *cookie, panic("nist_hash_drbg_instantiate"); /* Attach the event counters. */ + /* XXX ci_cpuname may not be initialized early enough. */ + cpuname = ci->ci_cpuname[0] == '\0' ? "cpu0" : ci->ci_cpuname; evcnt_attach_dynamic(&cc->cc_evcnt->intr, EVCNT_TYPE_MISC, NULL, - ci->ci_cpuname, "cprng_strong intr"); + cpuname, "cprng_strong intr"); evcnt_attach_dynamic(&cc->cc_evcnt->reseed, EVCNT_TYPE_MISC, NULL, - ci->ci_cpuname, "cprng_strong reseed"); + cpuname, "cprng_strong reseed"); /* Set the epoch uninitialized so we reseed on first use. */ cc->cc_epoch = 0;
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Mon May 11 21:37:31 UTC 2020 Modified Files: src/sys/kern: subr_percpu.c Log Message: Teach percpu to run constructors on CPU attach. This should make percpu work reliably for things like cprng_strong much earlier -- not just after all CPUs have been detected. This is also necessary (though not on its own sufficient) for CPU hotplug. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/kern/subr_percpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_percpu.c diff -u src/sys/kern/subr_percpu.c:1.24 src/sys/kern/subr_percpu.c:1.25 --- src/sys/kern/subr_percpu.c:1.24 Fri Feb 7 11:55:22 2020 +++ src/sys/kern/subr_percpu.c Mon May 11 21:37:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_percpu.c,v 1.24 2020/02/07 11:55:22 thorpej Exp $ */ +/* $NetBSD: subr_percpu.c,v 1.25 2020/05/11 21:37:31 riastradh Exp $ */ /*- * Copyright (c)2007,2008 YAMAMOTO Takashi, @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_percpu.c,v 1.24 2020/02/07 11:55:22 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_percpu.c,v 1.25 2020/05/11 21:37:31 riastradh Exp $"); #include #include @@ -50,8 +50,10 @@ __KERNEL_RCSID(0, "$NetBSD: subr_percpu. struct percpu { unsigned pc_offset; size_t pc_size; + percpu_callback_t pc_ctor; percpu_callback_t pc_dtor; void *pc_cookie; + LIST_ENTRY(percpu) pc_list; }; static krwlock_t percpu_swap_lock __cacheline_aligned; @@ -59,6 +61,9 @@ static vmem_t * percpu_offset_arena __r static struct { kmutex_t lock; unsigned int nextoff; + LIST_HEAD(, percpu) ctor_list; + struct lwp *busy; + kcondvar_t cv; } percpu_allocation __cacheline_aligned; static percpu_cpu_t * @@ -217,6 +222,9 @@ percpu_init(void) rw_init(&percpu_swap_lock); mutex_init(&percpu_allocation.lock, MUTEX_DEFAULT, IPL_NONE); percpu_allocation.nextoff = PERCPU_QUANTUM_SIZE; + LIST_INIT(&percpu_allocation.ctor_list); + percpu_allocation.busy = NULL; + cv_init(&percpu_allocation.cv, "percpu"); percpu_offset_arena = vmem_xcreate("percpu", 0, 0, PERCPU_QUANTUM_SIZE, percpu_backend_alloc, NULL, NULL, PERCPU_QCACHE_MAX, VM_SLEEP, @@ -227,18 +235,50 @@ percpu_init(void) * percpu_init_cpu: cpu initialization * * => should be called before the cpu appears on the list for CPU_INFO_FOREACH. + * => may be called for static CPUs afterward (typically just primary CPU) */ void percpu_init_cpu(struct cpu_info *ci) { percpu_cpu_t * const pcc = cpu_percpu(ci); + struct percpu *pc; size_t size = percpu_allocation.nextoff; /* XXX racy */ ASSERT_SLEEPABLE(); + + /* + * For the primary CPU, prior percpu_create may have already + * triggered allocation, so there's nothing more for us to do + * here. + */ + if (pcc->pcc_size) + return; + KASSERT(pcc->pcc_data == NULL); + + /* + * Otherwise, allocate storage and, while the constructor list + * is locked, run constructors for all percpus on this CPU. + */ pcc->pcc_size = size; if (size) { pcc->pcc_data = kmem_zalloc(pcc->pcc_size, KM_SLEEP); + mutex_enter(&percpu_allocation.lock); + while (percpu_allocation.busy) + cv_wait(&percpu_allocation.cv, + &percpu_allocation.lock); + percpu_allocation.busy = curlwp; + LIST_FOREACH(pc, &percpu_allocation.ctor_list, pc_list) { + KASSERT(pc->pc_ctor); + mutex_exit(&percpu_allocation.lock); + (*pc->pc_ctor)((char *)pcc->pcc_data + pc->pc_offset, + pc->pc_cookie, ci); + mutex_enter(&percpu_allocation.lock); + } + KASSERT(percpu_allocation.busy == curlwp); + percpu_allocation.busy = NULL; + cv_broadcast(&percpu_allocation.cv); + mutex_exit(&percpu_allocation.lock); } } @@ -281,6 +321,7 @@ percpu_create(size_t size, percpu_callba pc = kmem_alloc(sizeof(*pc), KM_SLEEP); pc->pc_offset = offset; pc->pc_size = size; + pc->pc_ctor = ctor; pc->pc_dtor = dtor; pc->pc_cookie = cookie; @@ -289,6 +330,22 @@ percpu_create(size_t size, percpu_callba struct cpu_info *ci; void *buf; + /* + * Wait until nobody is using the list of percpus with + * constructors. + */ + mutex_enter(&percpu_allocation.lock); + while (percpu_allocation.busy) + cv_wait(&percpu_allocation.cv, + &percpu_allocation.lock); + percpu_allocation.busy = curlwp; + mutex_exit(&percpu_allocation.lock); + + /* + * Run the constructor for all CPUs. We use a + * temporary buffer wo that we need not hold the + * percpu_swap_lock while running the constructor. + */ buf = kmem_alloc(size, KM_SLEEP); for (CPU_INFO_FOREACH(cii, ci)) { memset(buf, 0, size); @@ -299,6 +356,19 @@ percpu_create(size_t size, percpu_callba } explicit_memset(buf, 0, size); kmem_free(buf, size); + + /* + * Insert the percpu into the list of percpus with + * constructors. We are now done using the list, so it + * is safe for concurrent percpu_create or
CVS commit: src/tests/lib/libc/sys
Module Name:src Committed By: kamil Date: Mon May 11 21:18:11 UTC 2020 Modified Files: src/tests/lib/libc/sys: t_ptrace_clone_wait.h Log Message: Fix potential race in ptrace(2) clone(2) tests Instead of comparing old and new signal mask, just after the cloning operation, check whether the expected signal is still masked and in another test whether it is still ignored. Catch up after t_ptrace_fork_wait.h r. 1.2. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_ptrace_clone_wait.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/sys/t_ptrace_clone_wait.h diff -u src/tests/lib/libc/sys/t_ptrace_clone_wait.h:1.2 src/tests/lib/libc/sys/t_ptrace_clone_wait.h:1.3 --- src/tests/lib/libc/sys/t_ptrace_clone_wait.h:1.2 Mon May 4 22:24:31 2020 +++ src/tests/lib/libc/sys/t_ptrace_clone_wait.h Mon May 11 21:18:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ptrace_clone_wait.h,v 1.2 2020/05/04 22:24:31 kamil Exp $ */ +/* $NetBSD: t_ptrace_clone_wait.h,v 1.3 2020/05/11 21:18:11 kamil Exp $ */ /*- * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc. @@ -414,11 +414,8 @@ clone_body2(int flags, bool masked, bool FORKEE_ASSERT_EQ(sysctl(name, namelen, &kp, &len, NULL, 0), 0); - if (masked) - kp_sigmask = kp.p_sigmask; - - if (ignored) - kp_sigignore = kp.p_sigignore; + kp_sigmask = kp.p_sigmask; + kp_sigignore = kp.p_sigignore; DPRINTF("Set PTRACE_FORK | PTRACE_VFORK | PTRACE_VFORK_DONE in " "EVENT_MASK for the child %d\n", child); @@ -451,8 +448,8 @@ clone_body2(int flags, bool masked, bool kp.p_sigmask.__bits[0], kp.p_sigmask.__bits[1], kp.p_sigmask.__bits[2], kp.p_sigmask.__bits[3]); - ATF_REQUIRE(!memcmp(&kp_sigmask, &kp.p_sigmask, - sizeof(kp_sigmask))); + ATF_REQUIRE(sigismember((sigset_t *)&kp.p_sigmask, + SIGTRAP)); } if (ignored) { @@ -468,8 +465,8 @@ clone_body2(int flags, bool masked, bool kp.p_sigignore.__bits[0], kp.p_sigignore.__bits[1], kp.p_sigignore.__bits[2], kp.p_sigignore.__bits[3]); - ATF_REQUIRE(!memcmp(&kp_sigignore, &kp.p_sigignore, - sizeof(kp_sigignore))); + ATF_REQUIRE(sigismember((sigset_t *)&kp.p_sigignore, + SIGTRAP)); } SYSCALL_REQUIRE( @@ -510,8 +507,8 @@ clone_body2(int flags, bool masked, bool kp.p_sigmask.__bits[0], kp.p_sigmask.__bits[1], kp.p_sigmask.__bits[2], kp.p_sigmask.__bits[3]); - ATF_REQUIRE(!memcmp(&kp_sigmask, &kp.p_sigmask, - sizeof(kp_sigmask))); + ATF_REQUIRE(sigismember((sigset_t *)&kp.p_sigmask, + SIGTRAP)); } if (ignored) { @@ -527,8 +524,8 @@ clone_body2(int flags, bool masked, bool kp.p_sigignore.__bits[0], kp.p_sigignore.__bits[1], kp.p_sigignore.__bits[2], kp.p_sigignore.__bits[3]); - ATF_REQUIRE(!memcmp(&kp_sigignore, &kp.p_sigignore, - sizeof(kp_sigignore))); + ATF_REQUIRE(sigismember((sigset_t *)&kp.p_sigignore, + SIGTRAP)); } SYSCALL_REQUIRE(
CVS commit: src/tests/lib/libc/sys
Module Name:src Committed By: kamil Date: Mon May 11 20:58:48 UTC 2020 Modified Files: src/tests/lib/libc/sys: t_ptrace_fork_wait.h Log Message: Fix race in fork_singalmasked ELF RTLD after rtld.c r. 1.204 introduced locking that wraps the fork syscall. This locking changes signal mask of the calling process during the forking process. Instead of comparing old and new signal mask, just after the forking operation, check whether the expected signal is still masked and in another test whether it is still ignored. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_ptrace_fork_wait.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/sys/t_ptrace_fork_wait.h diff -u src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.1 src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.2 --- src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.1 Mon May 4 22:34:22 2020 +++ src/tests/lib/libc/sys/t_ptrace_fork_wait.h Mon May 11 20:58:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ptrace_fork_wait.h,v 1.1 2020/05/04 22:34:22 kamil Exp $ */ +/* $NetBSD: t_ptrace_fork_wait.h,v 1.2 2020/05/11 20:58:48 kamil Exp $ */ /*- * Copyright (c) 2016, 2017, 2018, 2020 The NetBSD Foundation, Inc. @@ -1318,11 +1318,8 @@ fork2_body(const char *fn, bool masked, FORKEE_ASSERT_EQ(sysctl(name, namelen, &kp, &len, NULL, 0), 0); - if (masked) - kp_sigmask = kp.p_sigmask; - - if (ignored) - kp_sigignore = kp.p_sigignore; + kp_sigmask = kp.p_sigmask; + kp_sigignore = kp.p_sigignore; DPRINTF("Set 0%s%s%s%s in EVENT_MASK for the child %d\n", strcmp(fn, "spawn") == 0 ? "|PTRACE_POSIX_SPAWN" : "", @@ -1368,8 +1365,8 @@ fork2_body(const char *fn, bool masked, kp.p_sigmask.__bits[0], kp.p_sigmask.__bits[1], kp.p_sigmask.__bits[2], kp.p_sigmask.__bits[3]); - ATF_REQUIRE(!memcmp(&kp_sigmask, &kp.p_sigmask, - sizeof(kp_sigmask))); + ATF_REQUIRE(sigismember((sigset_t *)&kp.p_sigmask, + SIGTRAP)); } if (ignored) { @@ -1385,8 +1382,8 @@ fork2_body(const char *fn, bool masked, kp.p_sigignore.__bits[0], kp.p_sigignore.__bits[1], kp.p_sigignore.__bits[2], kp.p_sigignore.__bits[3]); - ATF_REQUIRE(!memcmp(&kp_sigignore, &kp.p_sigignore, - sizeof(kp_sigignore))); + ATF_REQUIRE(sigismember((sigset_t *)&kp.p_sigignore, + SIGTRAP)); } SYSCALL_REQUIRE( @@ -1431,8 +1428,8 @@ fork2_body(const char *fn, bool masked, kp.p_sigmask.__bits[0], kp.p_sigmask.__bits[1], kp.p_sigmask.__bits[2], kp.p_sigmask.__bits[3]); - ATF_REQUIRE(!memcmp(&kp_sigmask, &kp.p_sigmask, - sizeof(kp_sigmask))); + ATF_REQUIRE(sigismember((sigset_t *)&kp.p_sigmask, + SIGTRAP)); } if (ignored) { @@ -1448,8 +1445,8 @@ fork2_body(const char *fn, bool masked, kp.p_sigignore.__bits[0], kp.p_sigignore.__bits[1], kp.p_sigignore.__bits[2], kp.p_sigignore.__bits[3]); - ATF_REQUIRE(!memcmp(&kp_sigignore, &kp.p_sigignore, - sizeof(kp_sigignore))); + ATF_REQUIRE(sigismember((sigset_t *)&kp.p_sigignore, + SIGTRAP)); } SYSCALL_REQUIRE( @@ -1510,8 +1507,8 @@ fork2_body(const char *fn, bool masked, kp.p_sigmask.__bits[0], kp.p_sigmask.__bits[1], kp.p_sigmask.__bits[2], kp.p_sigmask.__bits[3]); - ATF_REQUIRE(!memcmp(&kp_sigmask, &kp.p_sigmask, - sizeof(kp_sigmask))); + ATF_REQUIRE(sigismember((sigset_t *)&kp.p_sigmask, + SIGTRAP)); } if (ignored) { @@ -1527,8 +1524,8 @@ fork2_body(const char *fn, bool masked, kp.p_sigignore.__bits[0], kp.p_sigignore.__bits[1], kp.p_sigignore.__bits[2], kp.p_sigignore.__bits[3]); - ATF_REQUIRE(!memcmp(&kp_sigignore, &kp.p_sigignore, - sizeof(kp_sigignore))); + ATF_REQUIRE(sigismember((sigset_t *)&kp.p_sigignore, + SIGTRAP)); } SYSCALL_REQUIRE(
CVS commit: src/sys/secmodel
Module Name:src Committed By: alnsn Date: Mon May 11 19:36:40 UTC 2020 Modified Files: src/sys/secmodel/securelevel: secmodel_securelevel.c src/sys/secmodel/suser: secmodel_suser.c Log Message: KAUTH_MACHDEP_SVS_DISABLE is deprecated. sysctl machdep.svs.enabled can't be changed anymore at runtime because it's now a boot option. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 \ src/sys/secmodel/securelevel/secmodel_securelevel.c cvs rdiff -u -r1.52 -r1.53 src/sys/secmodel/suser/secmodel_suser.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/secmodel/securelevel/secmodel_securelevel.c diff -u src/sys/secmodel/securelevel/secmodel_securelevel.c:1.34 src/sys/secmodel/securelevel/secmodel_securelevel.c:1.35 --- src/sys/secmodel/securelevel/secmodel_securelevel.c:1.34 Mon Mar 16 21:20:12 2020 +++ src/sys/secmodel/securelevel/secmodel_securelevel.c Mon May 11 19:36:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: secmodel_securelevel.c,v 1.34 2020/03/16 21:20:12 pgoyette Exp $ */ +/* $NetBSD: secmodel_securelevel.c,v 1.35 2020/05/11 19:36:39 alnsn Exp $ */ /*- * Copyright (c) 2006 Elad Efrat * All rights reserved. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: secmodel_securelevel.c,v 1.34 2020/03/16 21:20:12 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: secmodel_securelevel.c,v 1.35 2020/05/11 19:36:39 alnsn Exp $"); #ifdef _KERNEL_OPT #include "opt_insecure.h" @@ -480,6 +480,7 @@ secmodel_securelevel_machdep_cb(kauth_cr break; case KAUTH_MACHDEP_SVS_DISABLE: + /* Deprecated. */ if (securelevel > 0) result = KAUTH_RESULT_DENY; break; Index: src/sys/secmodel/suser/secmodel_suser.c diff -u src/sys/secmodel/suser/secmodel_suser.c:1.52 src/sys/secmodel/suser/secmodel_suser.c:1.53 --- src/sys/secmodel/suser/secmodel_suser.c:1.52 Mon Mar 16 21:20:12 2020 +++ src/sys/secmodel/suser/secmodel_suser.c Mon May 11 19:36:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: secmodel_suser.c,v 1.52 2020/03/16 21:20:12 pgoyette Exp $ */ +/* $NetBSD: secmodel_suser.c,v 1.53 2020/05/11 19:36:40 alnsn Exp $ */ /*- * Copyright (c) 2006 Elad Efrat * All rights reserved. @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.52 2020/03/16 21:20:12 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: secmodel_suser.c,v 1.53 2020/05/11 19:36:40 alnsn Exp $"); #include #include @@ -847,6 +847,7 @@ secmodel_suser_machdep_cb(kauth_cred_t c case KAUTH_MACHDEP_UNMANAGEDMEM: case KAUTH_MACHDEP_PXG: case KAUTH_MACHDEP_SVS_DISABLE: + /* Deprecated. */ if (isroot) result = KAUTH_RESULT_ALLOW; break;
CVS commit: src/sys/dev/pci
Module Name:src Committed By: jakllsch Date: Mon May 11 19:17:46 UTC 2020 Modified Files: src/sys/dev/pci: if_msk.c Log Message: msk(4): simplify interrupt return value creation This also corrects a problem where we would not claim we handled an interrupt that was ours. To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/sys/dev/pci/if_msk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_msk.c diff -u src/sys/dev/pci/if_msk.c:1.111 src/sys/dev/pci/if_msk.c:1.112 --- src/sys/dev/pci/if_msk.c:1.111 Mon May 11 18:49:04 2020 +++ src/sys/dev/pci/if_msk.c Mon May 11 19:17:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_msk.c,v 1.111 2020/05/11 18:49:04 jakllsch Exp $ */ +/* $NetBSD: if_msk.c,v 1.112 2020/05/11 19:17:46 jakllsch Exp $ */ /* $OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $ */ /* @@ -52,7 +52,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.111 2020/05/11 18:49:04 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.112 2020/05/11 19:17:46 jakllsch Exp $"); #include #include @@ -2275,7 +2275,6 @@ msk_intr(void *xsc) struct sk_if_softc *sc_if0 = sc->sk_if[SK_PORT_A]; struct sk_if_softc *sc_if1 = sc->sk_if[SK_PORT_B]; struct ifnet *ifp0 = NULL, *ifp1 = NULL; - int claimed = 0; uint32_t status; struct msk_status_desc *cur_st; @@ -2339,7 +2338,6 @@ msk_intr(void *xsc) if (status & SK_Y2_IMR_BMU) { CSR_WRITE_4(sc, SK_STAT_BMU_CSR, SK_STAT_BMU_IRQ_CLEAR); - claimed = 1; } CSR_WRITE_4(sc, SK_Y2_ICR, 2); @@ -2355,7 +2353,7 @@ msk_intr(void *xsc) if (sc->sk_int_mod_pending) msk_update_int_mod(sc, 1); - return claimed; + return (status & sc->sk_intrmask) != 0; } static void
CVS commit: src/sys/dev/pci
Module Name:src Committed By: jakllsch Date: Mon May 11 18:49:05 UTC 2020 Modified Files: src/sys/dev/pci: if_msk.c Log Message: msk(4): moderate no interrupts globally The global interrupt moderator on mskc(4) is mostly redundant with the Status Unit's tx and rx interrupt coalescing for our purpouses Revisits interrupt moderation change in 1.108. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/sys/dev/pci/if_msk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_msk.c diff -u src/sys/dev/pci/if_msk.c:1.110 src/sys/dev/pci/if_msk.c:1.111 --- src/sys/dev/pci/if_msk.c:1.110 Fri May 8 14:56:49 2020 +++ src/sys/dev/pci/if_msk.c Mon May 11 18:49:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_msk.c,v 1.110 2020/05/08 14:56:49 jakllsch Exp $ */ +/* $NetBSD: if_msk.c,v 1.111 2020/05/11 18:49:04 jakllsch Exp $ */ /* $OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $ */ /* @@ -52,7 +52,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.110 2020/05/08 14:56:49 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.111 2020/05/11 18:49:04 jakllsch Exp $"); #include #include @@ -860,7 +860,7 @@ msk_update_int_mod(struct sk_softc *sc, aprint_verbose_dev(sc->sk_dev, "interrupt moderation is %d us\n", sc->sk_int_mod); sk_win_write_4(sc, SK_IMTIMERINIT, SK_IM_USECS(sc->sk_int_mod)); - sk_win_write_4(sc, SK_IMMR, SK_Y2_IMR_BMU); + sk_win_write_4(sc, SK_IMMR, 0); /* moderate no interrupts */ sk_win_write_1(sc, SK_IMTIMERCTL, SK_IMCTL_START); sc->sk_int_mod_pending = 0; }
CVS commit: src/sys/arch/sparc/sparc
Module Name:src Committed By: kamil Date: Mon May 11 18:38:27 UTC 2020 Modified Files: src/sys/arch/sparc/sparc: process_machdep.c Log Message: Reject setting unaligned Program Counter Patch taken from OpenBSD. Tested in qemu. Fixes PR port-sparc/54734 by Andreas Gustafsson To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc/sparc/process_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc/sparc/process_machdep.c diff -u src/sys/arch/sparc/sparc/process_machdep.c:1.19 src/sys/arch/sparc/sparc/process_machdep.c:1.20 --- src/sys/arch/sparc/sparc/process_machdep.c:1.19 Fri Dec 30 17:54:43 2016 +++ src/sys/arch/sparc/sparc/process_machdep.c Mon May 11 18:38:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: process_machdep.c,v 1.19 2016/12/30 17:54:43 christos Exp $ */ +/* $NetBSD: process_machdep.c,v 1.20 2020/05/11 18:38:26 kamil Exp $ */ /* * Copyright (c) 1993 The Regents of the University of California. @@ -95,7 +95,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.19 2016/12/30 17:54:43 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.20 2020/05/11 18:38:26 kamil Exp $"); #include #include @@ -122,6 +122,9 @@ process_write_regs(struct lwp *l, const { int psr = l->l_md.md_tf->tf_psr & ~PSR_ICC; + if (((regs->r_pc | regs->r_npc) & 0x03) != 0) + return EINVAL; + memcpy(l->l_md.md_tf, regs, sizeof(*regs)); l->l_md.md_tf->tf_psr = psr | (regs->r_psr & PSR_ICC); return 0; @@ -140,6 +143,9 @@ int process_set_pc(struct lwp *l, void *addr) { + if (((u_int)addr & 0x03) != 0) + return EINVAL; + l->l_md.md_tf->tf_pc = (u_int)addr; l->l_md.md_tf->tf_npc = (u_int)addr + 4; return 0;
CVS commit: src/sys/arch/sparc64/conf
Module Name:src Committed By: jdc Date: Mon May 11 18:29:59 UTC 2020 Modified Files: src/sys/arch/sparc64/conf: GENERIC Log Message: Add "wb at ebus" and sdmmc, ld for the SD card reader on SPARCle. To generate a diff of this commit: cvs rdiff -u -r1.226 -r1.227 src/sys/arch/sparc64/conf/GENERIC Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc64/conf/GENERIC diff -u src/sys/arch/sparc64/conf/GENERIC:1.226 src/sys/arch/sparc64/conf/GENERIC:1.227 --- src/sys/arch/sparc64/conf/GENERIC:1.226 Sat Mar 28 08:35:36 2020 +++ src/sys/arch/sparc64/conf/GENERIC Mon May 11 18:29:59 2020 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.226 2020/03/28 08:35:36 isaki Exp $ +# $NetBSD: GENERIC,v 1.227 2020/05/11 18:29:59 jdc Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/sparc64/conf/std.sparc64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.226 $" +#ident "GENERIC-$Revision: 1.227 $" maxusers 64 @@ -281,6 +281,11 @@ options PMS_SYNAPTICS_TOUCHPAD # Enable wskbd* at pckbd? console ? wsmouse* at pms? mux 0 +## Tadpole SPARCle SD card +wb* at ebus? # Winbond W83L518D SD/MMC reader +sdmmc* at wb? +ld* at sdmmc? + ## Magma Serial/Parallel driver (not tested) #magma* at sbus? slot ? offset ? #mtty* at magma?
CVS commit: src/usr.sbin/sysinst
Module Name:src Committed By: martin Date: Mon May 11 17:40:50 UTC 2020 Modified Files: src/usr.sbin/sysinst: bsddisklabel.c Log Message: When extending a partition (to fill the total disk size) do respect size limits. Do not suggest a size limited partition for extension by default. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/sysinst/bsddisklabel.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/sysinst/bsddisklabel.c diff -u src/usr.sbin/sysinst/bsddisklabel.c:1.40 src/usr.sbin/sysinst/bsddisklabel.c:1.41 --- src/usr.sbin/sysinst/bsddisklabel.c:1.40 Mon May 11 15:27:41 2020 +++ src/usr.sbin/sysinst/bsddisklabel.c Mon May 11 17:40:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bsddisklabel.c,v 1.40 2020/05/11 15:27:41 martin Exp $ */ +/* $NetBSD: bsddisklabel.c,v 1.41 2020/05/11 17:40:50 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -1131,15 +1131,23 @@ fill_defaults(struct partition_usage_set dump_space = roundup(dump_space, align); if (free_space > dump_space*2) dump_space *= 2; - if (free_space > dump_space) + if (free_space > dump_space) { wanted->infos[root].size += dump_space; + free_space -= dump_space; + } } if (wanted->infos[root].limit > 0 && - wanted->infos[root].size > wanted->infos[root].limit) { + (wanted->infos[root].cur_start + wanted->infos[root].size > + wanted->infos[root].limit || + (wanted->infos[root].flags & PUIFLAG_EXTEND && + (wanted->infos[root].cur_start + wanted->infos[root].size + + free_space > wanted->infos[root].limit { if (usr >= wanted->num && def_usr < wanted->num) { usr = def_usr; wanted->infos[usr].size = wanted->infos[root].size - wanted->infos[root].limit; + if (wanted->infos[usr].size <= 0) +wanted->infos[usr].size = 1; wanted->infos[root].size = wanted->infos[root].limit; if (wanted->infos[root].flags & PUIFLAG_EXTEND) { @@ -1364,10 +1372,20 @@ apply_settings_to_partitions(struct pm_d /* * Expand the pool partition (or shrink, if we overran), + * but check size limits. */ - if (exp_ndx < wanted->num) - wanted->infos[exp_ndx].size += - parts->free_space - planned_space; + if (exp_ndx < wanted->num) { + if (wanted->infos[exp_ndx].limit > 0 && + (wanted->infos[exp_ndx].size + parts->free_space + - planned_space) > wanted->infos[exp_ndx].limit) { + wanted->infos[exp_ndx].size = + wanted->infos[exp_ndx].limit + - wanted->infos[exp_ndx].cur_start; + } else { + wanted->infos[exp_ndx].size += + parts->free_space - planned_space; + } + } /* * Now it gets tricky: we want the wanted partitions in order
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Mon May 11 17:27:48 UTC 2020 Modified Files: src/sys/kern: subr_cprng.c Log Message: Work around early calls to cprng_strong. The bottleneck here is getting percpu_create to work early enough. We should really fix that, but for now, this workaround will serve. Should fix PR port-arm32/55252. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/kern/subr_cprng.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_cprng.c diff -u src/sys/kern/subr_cprng.c:1.37 src/sys/kern/subr_cprng.c:1.38 --- src/sys/kern/subr_cprng.c:1.37 Thu Apr 30 17:36:06 2020 +++ src/sys/kern/subr_cprng.c Mon May 11 17:27:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_cprng.c,v 1.37 2020/04/30 17:36:06 nia Exp $ */ +/* $NetBSD: subr_cprng.c,v 1.38 2020/05/11 17:27:48 riastradh Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -52,7 +52,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.37 2020/04/30 17:36:06 nia Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.38 2020/05/11 17:27:48 riastradh Exp $"); #include #include @@ -102,6 +102,7 @@ struct cprng_strong *kern_cprng __read_m struct cprng_strong *user_cprng __read_mostly; /* IPL_NONE */ static struct sysctllog *cprng_sysctllog __read_mostly; +static bool cprng_initialized __read_mostly = false; void cprng_init(void) @@ -128,6 +129,9 @@ cprng_init(void) CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_INT /*lie*/, "arandom", SYSCTL_DESCR("Independent uniform random bytes, up to 256 bytes"), sysctl_kern_arandom, 0, NULL, 0, CTL_KERN, KERN_ARND, CTL_EOL); + + /* Ready to go. */ + cprng_initialized = true; } /* @@ -274,6 +278,25 @@ cprng_strong(struct cprng_strong *cprng, int s; /* + * Some device drivers try to use cprng_strong in attach during + * autoconf, e.g. to randomly generate MAC addresses, before we + * percpu is available -- percpu is not available until after + * CPUs have been detected during autoconf. We should make + * percpu available sooner, but for now this works around it. + */ + if (__predict_false(!cprng_initialized)) { + struct nist_hash_drbg drbg; + entropy_extract(seed, sizeof seed, 0); + if (__predict_false(nist_hash_drbg_instantiate(&drbg, + seed, sizeof seed, NULL, 0, NULL, 0))) + panic("nist_hash_drbg_instantiate"); + if (__predict_false(nist_hash_drbg_generate(&drbg, buf, len, + NULL, 0))) + panic("nist_hash_drbg_generate"); + return len; + } + + /* * Verify maximum request length. Caller should really limit * their requests to 32 bytes to avoid spending much time with * preemption disabled -- use the 32 bytes to seed a private
CVS commit: src/sys/arch/sparc64
Module Name:src Committed By: jdc Date: Mon May 11 15:56:15 UTC 2020 Modified Files: src/sys/arch/sparc64/conf: files.sparc64 Added Files: src/sys/arch/sparc64/dev: wb_ebus.c Log Message: Add an ebus frontend for the Winbond W83l518D SD card reader as found on Tadpole SPARCLE latops. To generate a diff of this commit: cvs rdiff -u -r1.158 -r1.159 src/sys/arch/sparc64/conf/files.sparc64 cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/dev/wb_ebus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc64/conf/files.sparc64 diff -u src/sys/arch/sparc64/conf/files.sparc64:1.158 src/sys/arch/sparc64/conf/files.sparc64:1.159 --- src/sys/arch/sparc64/conf/files.sparc64:1.158 Sun Jan 27 02:08:38 2019 +++ src/sys/arch/sparc64/conf/files.sparc64 Mon May 11 15:56:15 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.sparc64,v 1.158 2019/01/27 02:08:38 pgoyette Exp $ +# $NetBSD: files.sparc64,v 1.159 2020/05/11 15:56:15 jdc Exp $ # @(#)files.sparc64 8.1 (Berkeley) 7/19/93 # sparc64-specific configuration info @@ -140,6 +140,10 @@ file arch/sparc64/dev/fdc.c fdc | fd n attach audiocs at ebus with audiocs_ebus file dev/ebus/cs4231_ebus.c audiocs_ebus +include "dev/sdmmc/files.sdmmc" +attach wb at ebus with wb_ebus +file arch/sparc64/dev/wb_ebus.c wb_ebus + # PCMCIA bus (references fdc) include "dev/pcmcia/files.pcmcia" Added files: Index: src/sys/arch/sparc64/dev/wb_ebus.c diff -u /dev/null src/sys/arch/sparc64/dev/wb_ebus.c:1.1 --- /dev/null Mon May 11 15:56:15 2020 +++ src/sys/arch/sparc64/dev/wb_ebus.c Mon May 11 15:56:15 2020 @@ -0,0 +1,86 @@ +/* $NetBSD: wb_ebus.c,v 1.1 2020/05/11 15:56:15 jdc Exp $ */ + +/* + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Julian Coleman. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: wb_ebus.c,v 1.1 2020/05/11 15:56:15 jdc Exp $"); + +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +static int wb_ebus_match(device_t, cfdata_t , void *); +static void wb_ebus_attach(device_t, device_t, void *); + +CFATTACH_DECL_NEW(wb_ebus, sizeof(struct wb_softc), + wb_ebus_match, wb_ebus_attach, NULL, NULL); + +static int +wb_ebus_match(device_t parent, cfdata_t match, void *aux) +{ + struct ebus_attach_args *ea = aux; + + return (strcmp(ea->ea_name, "TAD,wb-sdcard") == 0); +} + +static void +wb_ebus_attach(device_t parent, device_t self, void *aux) +{ + struct wb_softc *sc = device_private(self); + struct ebus_attach_args *ea = aux; + + sc->wb_dev = self; + + if (bus_space_map(ea->ea_bustag, EBUS_ADDR_FROM_REG(&ea->ea_reg[0]), + ea->ea_reg[0].size, 0, &sc->wb_ioh) == 0) + sc->wb_iot = ea->ea_bustag; + else { + aprint_error(": can't map register space\n"); +return; + } + + bus_intr_establish(sc->wb_iot, ea->ea_intr[0], IPL_BIO, wb_intr, sc); + + aprint_normal("\n"); + + sc->wb_type = WB_DEVNO_SD; + sc->wb_quirks = WB_QUIRK_1BIT; /* 4bit bus width always fails */ + wb_attach(sc); +}
CVS commit: src/usr.sbin/sysinst
Module Name:src Committed By: martin Date: Mon May 11 15:27:41 UTC 2020 Modified Files: src/usr.sbin/sysinst: bsddisklabel.c Log Message: Redo the root-size-limit check again after we grew the root partition for kernel dumps. Auto-enable the /usr partition if it overflows. For all non-root partitions, default to FFSv2. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/sysinst/bsddisklabel.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/sysinst/bsddisklabel.c diff -u src/usr.sbin/sysinst/bsddisklabel.c:1.39 src/usr.sbin/sysinst/bsddisklabel.c:1.40 --- src/usr.sbin/sysinst/bsddisklabel.c:1.39 Thu Feb 6 20:17:04 2020 +++ src/usr.sbin/sysinst/bsddisklabel.c Mon May 11 15:27:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bsddisklabel.c,v 1.39 2020/02/06 20:17:04 martin Exp $ */ +/* $NetBSD: bsddisklabel.c,v 1.40 2020/05/11 15:27:41 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -143,8 +143,10 @@ default_parts_init[] = { .type = PT_root, .mount = "/tmp", .fs_type = FS_MFS, .flags = PUIFLG_JUST_MOUNTPOINT }, #endif - { .def_size = DEFUSRSIZE*(MEG/512), .mount = "/usr", .type = PT_root }, - { .def_size = DEFVARSIZE*(MEG/512), .mount = "/var", .type = PT_root }, + { .def_size = DEFUSRSIZE*(MEG/512), .mount = "/usr", .type = PT_root, + .fs_type = FS_BSDFFS, .fs_version = 2 }, + { .def_size = DEFVARSIZE*(MEG/512), .mount = "/var", .type = PT_root, + .fs_type = FS_BSDFFS, .fs_version = 2 }, }; static const char size_separator[] = @@ -1100,7 +1102,7 @@ fill_defaults(struct partition_usage_set if (usr < wanted->num) required += wanted->infos[usr].size; else if (def_usr < wanted->num) - required += wanted->infos[def_usr].def_size; + required += wanted->infos[def_usr].def_size; free_space -= required; for (i = 0; i < wanted->num; i++) { if (i == root || i == usr) @@ -1132,6 +1134,31 @@ fill_defaults(struct partition_usage_set if (free_space > dump_space) wanted->infos[root].size += dump_space; } + if (wanted->infos[root].limit > 0 && + wanted->infos[root].size > wanted->infos[root].limit) { + if (usr >= wanted->num && def_usr < wanted->num) { + usr = def_usr; + wanted->infos[usr].size = wanted->infos[root].size + - wanted->infos[root].limit; + wanted->infos[root].size = + wanted->infos[root].limit; + if (wanted->infos[root].flags & PUIFLAG_EXTEND) { +wanted->infos[root].flags &= ~PUIFLAG_EXTEND; +wanted->infos[usr].flags |= PUIFLAG_EXTEND; + } + } else if (usr < wanted->num) { + /* move space from root to usr */ + daddr_t spill = wanted->infos[root].size - + wanted->infos[root].limit; + spill = roundup(spill, align); + wanted->infos[root].size = + wanted->infos[root].limit; + wanted->infos[usr].size = spill; + } else { + wanted->infos[root].size = + wanted->infos[root].limit; + } + } } /*
CVS commit: src/sys/arch
Module Name:src Committed By: joerg Date: Mon May 11 15:15:15 UTC 2020 Modified Files: src/sys/arch/amd64/conf: Makefile.amd64 src/sys/arch/i386/conf: Makefile.i386 Log Message: Fix GCC flags for Spectre mitigation to really only apply to GCC. To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/sys/arch/amd64/conf/Makefile.amd64 cvs rdiff -u -r1.195 -r1.196 src/sys/arch/i386/conf/Makefile.i386 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/conf/Makefile.amd64 diff -u src/sys/arch/amd64/conf/Makefile.amd64:1.84 src/sys/arch/amd64/conf/Makefile.amd64:1.85 --- src/sys/arch/amd64/conf/Makefile.amd64:1.84 Sat Apr 25 15:26:16 2020 +++ src/sys/arch/amd64/conf/Makefile.amd64 Mon May 11 15:15:15 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.amd64,v 1.84 2020/04/25 15:26:16 bouyer Exp $ +# $NetBSD: Makefile.amd64,v 1.85 2020/05/11 15:15:15 joerg Exp $ # Makefile for NetBSD # @@ -44,9 +44,9 @@ CFLAGS+= -msoft-float # For gcc we might need this, but other compilers barf # CFLAGS+= -mno-fp-ret-in-387 -.if ${SPECTRE_V2_GCC_MITIGATION:U0} > 0 && ${HAVE_GCC:U0} > 0 -CFLAGS+= -mindirect-branch=thunk-inline -CFLAGS+= -mindirect-branch-register +.if ${SPECTRE_V2_GCC_MITIGATION:U0} > 0 +CFLAGS+= ${${ACTIVE_CC} == "gcc" :? -mindirect-branch=thunk :} +CFLAGS+= ${${ACTIVE_CC} == "gcc" :? -mindirect-branch-register :} .endif .if ${KASAN:U0} > 0 Index: src/sys/arch/i386/conf/Makefile.i386 diff -u src/sys/arch/i386/conf/Makefile.i386:1.195 src/sys/arch/i386/conf/Makefile.i386:1.196 --- src/sys/arch/i386/conf/Makefile.i386:1.195 Sat Apr 25 15:26:16 2020 +++ src/sys/arch/i386/conf/Makefile.i386 Mon May 11 15:15:15 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.i386,v 1.195 2020/04/25 15:26:16 bouyer Exp $ +# $NetBSD: Makefile.i386,v 1.196 2020/05/11 15:15:15 joerg Exp $ # Makefile for NetBSD # @@ -40,9 +40,9 @@ CFLAGS+= -msoft-float ## no-sse implies no-sse2 but not no-avx CFLAGS+= -mno-mmx -mno-sse -mno-avx -.if ${SPECTRE_V2_GCC_MITIGATION:U0} > 0 && ${HAVE_GCC:U0} > 0 -CFLAGS+= -mindirect-branch=thunk -CFLAGS+= -mindirect-branch-register +.if ${SPECTRE_V2_GCC_MITIGATION:U0} > 0 +CFLAGS+= ${${ACTIVE_CC} == "gcc" :? -mindirect-branch=thunk :} +CFLAGS+= ${${ACTIVE_CC} == "gcc" :? -mindirect-branch-register :} .endif EXTRA_INCLUDES= -I$S/external/mit/xen-include-public/dist/
CVS commit: src/sys/dev/ic
Module Name:src Committed By: jdc Date: Mon May 11 14:55:20 UTC 2020 Modified Files: src/sys/dev/ic: w83l518d.c w83l518d_sdmmc.c w83l518dvar.h Log Message: Make the driver endian-independent. Add a quirk so that the bus front end can specify 1-bit only mode. Remove unused isa includes. Change the error returned for unsupported opcodes to ENOTSUP, so that we can pass this back to sdmmc_mem, where it's handled since r1.72 of src/sys/dev/sdmmc/sdmmc_mem.c To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/w83l518d.c \ src/sys/dev/ic/w83l518dvar.h cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/w83l518d_sdmmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/w83l518d.c diff -u src/sys/dev/ic/w83l518d.c:1.2 src/sys/dev/ic/w83l518d.c:1.3 --- src/sys/dev/ic/w83l518d.c:1.2 Thu Aug 19 14:58:22 2010 +++ src/sys/dev/ic/w83l518d.c Mon May 11 14:55:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: w83l518d.c,v 1.2 2010/08/19 14:58:22 jmcneill Exp $ */ +/* $NetBSD: w83l518d.c,v 1.3 2020/05/11 14:55:20 jdc Exp $ */ /* * Copyright (c) 2009 Jared D. McNeill @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: w83l518d.c,v 1.2 2010/08/19 14:58:22 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: w83l518d.c,v 1.3 2020/05/11 14:55:20 jdc Exp $"); #include #include @@ -39,9 +39,6 @@ __KERNEL_RCSID(0, "$NetBSD: w83l518d.c,v #include -#include -#include - #include #include #include Index: src/sys/dev/ic/w83l518dvar.h diff -u src/sys/dev/ic/w83l518dvar.h:1.2 src/sys/dev/ic/w83l518dvar.h:1.3 --- src/sys/dev/ic/w83l518dvar.h:1.2 Thu Aug 19 14:58:22 2010 +++ src/sys/dev/ic/w83l518dvar.h Mon May 11 14:55:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: w83l518dvar.h,v 1.2 2010/08/19 14:58:22 jmcneill Exp $ */ +/* $NetBSD: w83l518dvar.h,v 1.3 2020/05/11 14:55:20 jdc Exp $ */ /* * Copyright (c) 2009 Jared D. McNeill @@ -44,6 +44,10 @@ struct wb_softc { uint8_t wb_sdmmc_clk; uint8_t wb_sdmmc_intsts; callout_t wb_sdmmc_callout; + + /* quirks */ +#define WB_QUIRK_1BIT (1U << 0) + int wb_quirks; }; void wb_attach(struct wb_softc *); Index: src/sys/dev/ic/w83l518d_sdmmc.c diff -u src/sys/dev/ic/w83l518d_sdmmc.c:1.3 src/sys/dev/ic/w83l518d_sdmmc.c:1.4 --- src/sys/dev/ic/w83l518d_sdmmc.c:1.3 Thu Oct 7 12:06:09 2010 +++ src/sys/dev/ic/w83l518d_sdmmc.c Mon May 11 14:55:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: w83l518d_sdmmc.c,v 1.3 2010/10/07 12:06:09 kiyohara Exp $ */ +/* $NetBSD: w83l518d_sdmmc.c,v 1.4 2020/05/11 14:55:20 jdc Exp $ */ /* * Copyright (c) 2009 Jared D. McNeill @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: w83l518d_sdmmc.c,v 1.3 2010/10/07 12:06:09 kiyohara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: w83l518d_sdmmc.c,v 1.4 2020/05/11 14:55:20 jdc Exp $"); #include #include @@ -43,9 +43,6 @@ __KERNEL_RCSID(0, "$NetBSD: w83l518d_sdm #include #include -#include -#include - #include #include #include @@ -185,7 +182,8 @@ wb_sdmmc_attach(struct wb_softc *wb) saa.saa_sch = wb; saa.saa_clkmin = 375; saa.saa_clkmax = 24000; - saa.saa_caps = SMC_CAPS_4BIT_MODE; + if (!ISSET(wb->wb_quirks, WB_QUIRK_1BIT)) + saa.saa_caps = SMC_CAPS_4BIT_MODE; wb->wb_sdmmc_dev = config_found(wb->wb_dev, &saa, NULL); } @@ -268,7 +266,7 @@ wb_sdmmc_write_protect(sdmmc_chipset_han static int wb_sdmmc_bus_power(sdmmc_chipset_handle_t sch, uint32_t ocr) { - REPORT(sch, "TRACE: sdmmc/bus_power(wb, ocr=%d)\n", ocr); + REPORT(sch, "TRACE: sdmmc/bus_power(wb, ocr=%x)\n", ocr); return 0; } @@ -334,10 +332,19 @@ wb_sdmmc_rsp_read_long(struct wb_softc * } for (i = 12; i >= 0; i -= 4) { +#if BYTE_ORDER == LITTLE_ENDIAN p[3] = wb_idx_read(wb, WB_INDEX_RESP(i + 0)); p[2] = wb_idx_read(wb, WB_INDEX_RESP(i + 1)); p[1] = wb_idx_read(wb, WB_INDEX_RESP(i + 2)); p[0] = wb_idx_read(wb, WB_INDEX_RESP(i + 3)); +#else + p[0] = wb_idx_read(wb, WB_INDEX_RESP(i + 0)); + p[1] = wb_idx_read(wb, WB_INDEX_RESP(i + 1)); + p[2] = wb_idx_read(wb, WB_INDEX_RESP(i + 2)); + p[3] = wb_idx_read(wb, WB_INDEX_RESP(i + 3)); +#endif + REPORT(wb, "TRACE: sdmmc/read_long (%d) 0x%08x\n", + (12 - i) / 4, cmd->c_resp[(12 - i) / 4]); p += 4; } } @@ -352,10 +359,19 @@ wb_sdmmc_rsp_read_short(struct wb_softc return; } +#if BYTE_ORDER == LITTLE_ENDIAN p[3] = wb_idx_read(wb, WB_INDEX_RESP(12)); p[2] = wb_idx_read(wb, WB_INDEX_RESP(13)); p[1] = wb_idx_read(wb, WB_INDEX_RESP(14)); p[0] = wb_idx_read(wb, WB_INDEX_RESP(15)); +#else + p[0] = wb_idx_read(wb, WB_INDEX_RESP(12)); + p[1] = wb_idx_read(wb, WB_INDEX_RESP(13)); + p[2] = wb_idx_read(wb, WB_INDEX_RESP(14)); + p[3] = wb_idx_read(wb, WB_INDEX_RESP(15)); +#endif + REPORT(wb, "TRACE: sdmmc/read_short 0x%08x\n", + cmd->c_resp[0]); } static int @@ -430,8 +446,9 @@ wb_sdmmc_exec_command(sdmmc_chipset_hand int s; REPORT(wb, "TRACE: sdmmc/exec_command(wb, cmd) " -
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kre Date: Mon May 11 14:54:34 UTC 2020 Modified Files: src/lib/libc/gen: posix_spawnp.c Log Message: Do as the manual says, and use _PATH_DEFPATH if PATH is not present in the environment rather than simply turning into posix_spawn() in that case. Also, we cannot use strtok() to parse PATH, the semantics don't fit the API. Borrow the guts of execvp for the PATH search. We still simply check for a file with 'x' permission, and assume that one will do, whatever it is, which isn't really correct, but ... To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libc/gen/posix_spawnp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/posix_spawnp.c diff -u src/lib/libc/gen/posix_spawnp.c:1.3 src/lib/libc/gen/posix_spawnp.c:1.4 --- src/lib/libc/gen/posix_spawnp.c:1.3 Thu Jan 4 20:57:29 2018 +++ src/lib/libc/gen/posix_spawnp.c Mon May 11 14:54:34 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: posix_spawnp.c,v 1.3 2018/01/04 20:57:29 kamil Exp $ */ +/* $NetBSD: posix_spawnp.c,v 1.4 2020/05/11 14:54:34 kre Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -31,17 +31,19 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: posix_spawnp.c,v 1.3 2018/01/04 20:57:29 kamil Exp $"); +__RCSID("$NetBSD: posix_spawnp.c,v 1.4 2020/05/11 14:54:34 kre Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" +#include +#include +#include +#include #include -#include #include -#include +#include #include -#include int posix_spawnp(pid_t * __restrict pid, const char * __restrict file, @@ -49,31 +51,91 @@ int posix_spawnp(pid_t * __restrict pid, const posix_spawnattr_t * __restrict sa, char * const *__restrict cav, char * const *__restrict env) { - char fpath[FILENAME_MAX], *last, *p; - char *path; + char fpath[FILENAME_MAX]; + const char *path, *p; + size_t lp, ln; + int err; + + _DIAGASSERT(file != NULL); /* - * If there is a / in the filename, or no PATH environment variable - * set, fall straight through to posix_spawn(). + * If there is a / in the name, fall straight through to posix_spawn(). */ - if (strchr(file, '/') != NULL || (path = getenv("PATH")) == NULL) + if (strchr(file, '/') != NULL) return posix_spawn(pid, file, fa, sa, cav, env); - path = strdup(path); - if (path == NULL) - return ENOMEM; + /* Get the path we're searching. */ + if ((path = getenv("PATH")) == NULL) + path = _PATH_DEFPATH; /* * Find an executable image with the given name in the PATH */ - for (p = strtok_r(path, ":", &last); p; - p = strtok_r(NULL, ":", &last)) { - snprintf(fpath, sizeof fpath, "%s/%s", p, file); - fpath[FILENAME_MAX-1] = 0; + + ln = strlen(file); + err = 0; + do { + /* Find the end of this path element. */ + for (p = path; *path != 0 && *path != ':'; path++) + continue; + /* + * It's a SHELL path -- double, leading and trailing colons + * mean the current directory. + */ + if (p == path) { + p = "."; + lp = 1; + } else + lp = (size_t)(path - p); + + /* + * Once we gain chdir/fchdir file actions, this will need + * serious work, as we must treat "." relative to the + * target of the (final) chdir performed. + * + * Fortunately, that day is yet to come. + */ + + /* + * If the path is too long complain. This is a possible + * security issue; given a way to make the path too long + * the user may execute the wrong program. + */ + if (lp + ln + 2 > sizeof(fpath)) { + (void)write(STDERR_FILENO, "posix_spawnp: ", 14); + (void)write(STDERR_FILENO, p, lp); + (void)write(STDERR_FILENO, ": path too long\n", 16); + continue; + } + memcpy(fpath, p, lp); + fpath[lp] = '/'; + memcpy(fpath + lp + 1, file, ln); + fpath[lp + ln + 1] = '\0'; + + /* + * It would be nice (much better) to try posix_spawn() + * here, using the current fpath as the filename, but + * there's no guarantee that it is safe to execute it + * twice (the file actions may screw us) so that we + * cannot do. This test is weak, barely even adequate. + * but unless we are forced into making posix_spawmp() + * become a system call (with PATH as an arg, or an array + * of possible paths to try, based upon PATH and file) + * we really have no better method. + */ if (access(fpath, X_OK) == 0) break; - } - free(path); + + if (err == 0) + err = errno; + + fpath[0] = '\0'; + + + } while (*path++ == ':'); /* Otherwise, *path was NUL */ + + if (fpath[0] == '\0') + return err; /* * Use posix_spawn() with the found binary
CVS commit: src/sys/arch/aarch64/aarch64
Module Name:src Committed By: riastradh Date: Mon May 11 14:44:16 UTC 2020 Modified Files: src/sys/arch/aarch64/aarch64: cpu.c Log Message: Add support for the ARMv8.5-RNG CPU random number generator. We use the RNDRRS system register. I made the following two wild-arse guesses about the architecture of real implementations, which might not exist yet: 1. There's only one physical source per CPU package, so not worth attaching one per core. 2. Like other CPU RNGs -- RDSEED, VIA C3 -- this probably gives about half a bit of entropy per bit of data (although perhaps we should say zero and revisit this once it arrives on real silicon). Tested in qemu as well as I can, using `-cpu max' (which doesn't get to userland for unrelated reasons). This uses the numeric notation `mrs %0, s3_3_c2_c4_1' for the rndrrs system register instead of the more legible `mrs %0, rndrrs' as suggested in the ARMv8.5 ARM. Why? - clang doesn't like `mrs %0, rndrrs' for reasons unclear to me. - gas only likes it with `.arch armv8.5-a+rng', but there's no clear way to keep that scoped; the `.set push/pop' stack that would be an obvious choice for this works only on mips. - gcc supports __attribute__((target("arch=..."))) on functions, but the version we use doesn't yet know about armv8.5-a+rng. Later on, we should replace this by a target attribute and the more obvious `mrs %0, rndrrs' notation. ok nick To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/arch/aarch64/aarch64/cpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/aarch64/cpu.c diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.44 src/sys/arch/aarch64/aarch64/cpu.c:1.45 --- src/sys/arch/aarch64/aarch64/cpu.c:1.44 Sun May 10 21:41:19 2020 +++ src/sys/arch/aarch64/aarch64/cpu.c Mon May 11 14:44:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.44 2020/05/10 21:41:19 riastradh Exp $ */ +/* $NetBSD: cpu.c,v 1.45 2020/05/11 14:44:16 riastradh Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.44 2020/05/10 21:41:19 riastradh Exp $"); +__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.45 2020/05/11 14:44:16 riastradh Exp $"); #include "locators.h" #include "opt_arm_debug.h" @@ -40,6 +40,7 @@ __KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.44 #include #include #include +#include #include #include @@ -68,6 +69,7 @@ static void cpu_identify2(device_t self, static void cpu_init_counter(struct cpu_info *); static void cpu_setup_id(struct cpu_info *); static void cpu_setup_sysctl(device_t, struct cpu_info *); +static void cpu_setup_rng(device_t, struct cpu_info *); #ifdef MULTIPROCESSOR #define NCPUINFO MAXCPUS @@ -153,6 +155,7 @@ cpu_attach(device_t dv, cpuid_t id) cpu_init_counter(ci); cpu_setup_sysctl(dv, ci); + cpu_setup_rng(dv, ci); } struct cpuidtab { @@ -502,6 +505,72 @@ cpu_setup_sysctl(device_t dv, struct cpu CTL_CREATE, CTL_EOL); } +static struct krndsource rndrrs_source; + +static void +rndrrs_get(size_t nbytes, void *cookie) +{ + /* Entropy bits per data byte, wild-arse guess. */ + const unsigned bpb = 4; + size_t nbits = nbytes*NBBY; + uint64_t x; + int error; + + while (nbits) { + /* + * x := random 64-bit sample + * error := Z bit, set to 1 if sample is bad + * + * XXX This should be done by marking the function + * __attribute__((target("arch=armv8.5-a+rng"))) and + * using `mrs %0, rndrrs', but: + * + * (a) the version of gcc we use doesn't support that, + * and + * (b) clang doesn't seem to like `rndrrs' itself. + * + * So we use the numeric encoding for now. + */ + __asm __volatile("" + "mrs %0, s3_3_c2_c4_1\n" + "cset %w1, eq" + : "=r"(x), "=r"(error)); + if (error) + break; + rnd_add_data_sync(&rndrrs_source, &x, sizeof(x), + bpb*sizeof(x)); + nbits -= MIN(nbits, bpb*sizeof(x)); + } + + explicit_memset(&x, 0, sizeof x); +} + +/* + * setup the RNDRRS entropy source + */ +static void +cpu_setup_rng(device_t dv, struct cpu_info *ci) +{ + struct aarch64_sysctl_cpu_id *id = &ci->ci_id; + + /* Probably shared between cores. */ + if (!CPU_IS_PRIMARY(ci)) + return; + + /* Verify that it is supported. */ + switch (__SHIFTOUT(id->ac_aa64isar0, ID_AA64ISAR0_EL1_RNDR)) { + case ID_AA64ISAR0_EL1_RNDR_RNDRRS: + break; + default: + return; + } + + /* Attach it. */ + rndsource_setcb(&rndrrs_source, rndrrs_get, NULL); + rnd_attach_source(&rndrrs_source, "rndrrs", RND_TYPE_RNG, + RND_FLAG_DEFAULT|RND_FLAG_HASCB); +} + #ifdef MULTIPROCESSOR void cpu_hatch(struct cpu_info *ci)
CVS commit: src/usr.bin/calendar/calendars
Module Name:src Committed By: pgoyette Date: Mon May 11 12:42:58 UTC 2020 Modified Files: src/usr.bin/calendar/calendars: calendar.birthday Log Message: Fix typo To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/usr.bin/calendar/calendars/calendar.birthday Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/calendar/calendars/calendar.birthday diff -u src/usr.bin/calendar/calendars/calendar.birthday:1.41 src/usr.bin/calendar/calendars/calendar.birthday:1.42 --- src/usr.bin/calendar/calendars/calendar.birthday:1.41 Sat Feb 22 23:17:59 2020 +++ src/usr.bin/calendar/calendars/calendar.birthday Mon May 11 12:42:58 2020 @@ -138,7 +138,7 @@ 05/10 William Robert "Bert" Sutherland was born in Hastings, Nebraska, 1936 05/11 Douglas Adams died, 2001 05/11 Johnny Appleseed born, 1768 -05/11 Richard Philips Feynman was born is Queens, New York, 1918 +05/11 Richard Philips Feynman was born in Queens, New York, 1918 05/12 Florence Nightingale born in Florence, Italy, 1820 05/13 Arthur S. Sullivan born, 1842 05/15 Mike Oldfield born in Essex, England, 1953
CVS commit: src/tests/lib/libc/sys
Module Name:src Committed By: kamil Date: Mon May 11 12:17:57 UTC 2020 Modified Files: src/tests/lib/libc/sys: t_ptrace_register_wait.h Log Message: Simplify previous Emit SIGKILL without a loop and without checking for exact process status once it is collected. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_ptrace_register_wait.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/sys/t_ptrace_register_wait.h diff -u src/tests/lib/libc/sys/t_ptrace_register_wait.h:1.2 src/tests/lib/libc/sys/t_ptrace_register_wait.h:1.3 --- src/tests/lib/libc/sys/t_ptrace_register_wait.h:1.2 Mon May 11 11:03:15 2020 +++ src/tests/lib/libc/sys/t_ptrace_register_wait.h Mon May 11 12:17:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ptrace_register_wait.h,v 1.2 2020/05/11 11:03:15 kamil Exp $ */ +/* $NetBSD: t_ptrace_register_wait.h,v 1.3 2020/05/11 12:17:57 kamil Exp $ */ /*- * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc. @@ -136,19 +136,13 @@ access_regs(const char *regset, const ch if (strstr(aux, "unaligned") != NULL) { DPRINTF("Before resuming the child process where it left off " "and without signal to be sent\n"); - for (;;) { - errno = 0; - if (ptrace(PT_KILL, child, NULL, 0) == 0) -break; - ATF_REQUIRE_EQ(errno, ESRCH); - } + + ptrace(PT_KILL, child, NULL, 0); DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); - validate_status_signaled(status, SIGKILL, 0); - DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
CVS commit: src/tests/lib/libc/sys
Module Name:src Committed By: kamil Date: Mon May 11 11:03:15 UTC 2020 Modified Files: src/tests/lib/libc/sys: t_ptrace_register_wait.h Log Message: Do not fail when trying to kill a dying process A dying process can disappear for a while. Rather than aborting, retry sending SIGKILL to it. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_ptrace_register_wait.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/sys/t_ptrace_register_wait.h diff -u src/tests/lib/libc/sys/t_ptrace_register_wait.h:1.1 src/tests/lib/libc/sys/t_ptrace_register_wait.h:1.2 --- src/tests/lib/libc/sys/t_ptrace_register_wait.h:1.1 Mon May 4 20:55:48 2020 +++ src/tests/lib/libc/sys/t_ptrace_register_wait.h Mon May 11 11:03:15 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ptrace_register_wait.h,v 1.1 2020/05/04 20:55:48 kamil Exp $ */ +/* $NetBSD: t_ptrace_register_wait.h,v 1.2 2020/05/11 11:03:15 kamil Exp $ */ /*- * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc. @@ -136,7 +136,12 @@ access_regs(const char *regset, const ch if (strstr(aux, "unaligned") != NULL) { DPRINTF("Before resuming the child process where it left off " "and without signal to be sent\n"); - SYSCALL_REQUIRE(ptrace(PT_KILL, child, NULL, 0) != -1); + for (;;) { + errno = 0; + if (ptrace(PT_KILL, child, NULL, 0) == 0) +break; + ATF_REQUIRE_EQ(errno, ESRCH); + } DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME); TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0),
CVS commit: src/doc
Module Name:src Committed By: skrll Date: Mon May 11 10:34:37 UTC 2020 Modified Files: src/doc: CHANGES Log Message: Note hppa modules default To generate a diff of this commit: cvs rdiff -u -r1.2685 -r1.2686 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2685 src/doc/CHANGES:1.2686 --- src/doc/CHANGES:1.2685 Mon May 4 16:21:23 2020 +++ src/doc/CHANGES Mon May 11 10:34:37 2020 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2685 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2686 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -192,3 +192,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0: xennet(4): add support for feature-sg & jumbo frames [jdolecek 20200430] xvif(4): add support for feature-sg & jumbo frames [jdolecek 20200503] xen: Support MSI for XenPV [jdolecek 20200504] + hppa: Enable modules in GENERIC by default. [skrll 20200511]
CVS commit: src/sys/arch/hppa/conf
Module Name:src Committed By: skrll Date: Mon May 11 10:23:37 UTC 2020 Modified Files: src/sys/arch/hppa/conf: GENERIC Log Message: Enable modules To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/arch/hppa/conf/GENERIC Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/hppa/conf/GENERIC diff -u src/sys/arch/hppa/conf/GENERIC:1.32 src/sys/arch/hppa/conf/GENERIC:1.33 --- src/sys/arch/hppa/conf/GENERIC:1.32 Wed Jan 29 18:39:02 2020 +++ src/sys/arch/hppa/conf/GENERIC Mon May 11 10:23:36 2020 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.32 2020/01/29 18:39:02 maya Exp $ +# $NetBSD: GENERIC,v 1.33 2020/05/11 10:23:36 skrll Exp $ # # GENERIC machine description file # @@ -23,7 +23,7 @@ include "arch/hppa/conf/std.hppa" options INCLUDE_CONFIG_FILE # embed config file in kernel binary options SYSCTL_INCLUDE_DESCR # Include sysctl descriptions in kernel -#ident "GENERIC-$Revision: 1.32 $" +#ident "GENERIC-$Revision: 1.33 $" maxusers 32 # estimated number of users @@ -57,6 +57,9 @@ options SYSVMSG # System V-like messag options SYSVSEM # System V-like semaphores options SYSVSHM # System V-like memory sharing +options MODULAR # new style module(7) framework +options MODULAR_DEFAULT_AUTOLOAD + options USERCONF # userconf(4) support # Alternate buffer queue strategies for better responsiveness under high
CVS commit: src/share/mk
Module Name:src Committed By: skrll Date: Mon May 11 10:21:24 UTC 2020 Modified Files: src/share/mk: bsd.kmodule.mk Log Message: Update the list of hppa options to build working kernel modules. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/share/mk/bsd.kmodule.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/mk/bsd.kmodule.mk diff -u src/share/mk/bsd.kmodule.mk:1.67 src/share/mk/bsd.kmodule.mk:1.68 --- src/share/mk/bsd.kmodule.mk:1.67 Sat May 2 09:15:30 2020 +++ src/share/mk/bsd.kmodule.mk Mon May 11 10:21:24 2020 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.kmodule.mk,v 1.67 2020/05/02 09:15:30 rin Exp $ +# $NetBSD: bsd.kmodule.mk,v 1.68 2020/05/11 10:21:24 skrll Exp $ # We are not building this with PIE MKPIE=no @@ -47,7 +47,7 @@ CFLAGS+= -march=armv8-a+nofp+nosimd .elif ${MACHINE_CPU} == "arm" CFLAGS+= -fno-common -fno-unwind-tables .elif ${MACHINE_CPU} == "hppa" -CFLAGS+= -mlong-calls +CFLAGS+= -mlong-calls -mno-space-regs -mfast-indirect-calls .elif ${MACHINE_CPU} == "powerpc" CFLAGS+= ${${ACTIVE_CC} == "gcc":? -mlongcall :} .elif ${MACHINE_CPU} == "vax"
CVS commit: src/sys/dev/sdmmc
Module Name:src Committed By: jdc Date: Mon May 11 09:51:47 UTC 2020 Modified Files: src/sys/dev/sdmmc: sdmmc_mem.c Log Message: If the controller doesn't support switch func (opcode 6) then skip setting this but continue with other settings. This allows us to use a card, albeit at a lower speed. To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/dev/sdmmc/sdmmc_mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sdmmc/sdmmc_mem.c diff -u src/sys/dev/sdmmc/sdmmc_mem.c:1.71 src/sys/dev/sdmmc/sdmmc_mem.c:1.72 --- src/sys/dev/sdmmc/sdmmc_mem.c:1.71 Sat Jan 4 22:28:26 2020 +++ src/sys/dev/sdmmc/sdmmc_mem.c Mon May 11 09:51:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_mem.c,v 1.71 2020/01/04 22:28:26 mlelstv Exp $ */ +/* $NetBSD: sdmmc_mem.c,v 1.72 2020/05/11 09:51:47 jdc Exp $ */ /* $OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $ */ /* @@ -45,7 +45,7 @@ /* Routines for SD/MMC memory cards. */ #include -__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.71 2020/01/04 22:28:26 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.72 2020/05/11 09:51:47 jdc Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -833,9 +833,14 @@ sdmmc_mem_sd_init(struct sdmmc_softc *sc DPRINTF(("%s: switch func mode 0\n", SDMMCDEVNAME(sc))); error = sdmmc_mem_sd_switch(sf, 0, 1, 0, &status); if (error) { - aprint_error_dev(sc->sc_dev, - "switch func mode 0 failed\n"); - return error; + if (error == ENOTSUP) { +/* Not supported by controller */ +goto skipswitchfuncs; + } else { +aprint_error_dev(sc->sc_dev, +"switch func mode 0 failed\n"); +return error; + } } support_func = SFUNC_STATUS_GROUP(&status, 1); @@ -887,6 +892,7 @@ sdmmc_mem_sd_init(struct sdmmc_softc *sc delay(25); } } +skipswitchfuncs: /* update bus clock */ if (sc->sc_busclk > sf->csd.tran_speed)