svn commit: r344507 - head/sys/dev/flash
Author: ian Date: Mon Feb 25 03:29:12 2019 New Revision: 344507 URL: https://svnweb.freebsd.org/changeset/base/344507 Log: Switch to using config_intrhook_oneshot(). That allows the error handling in the delayed attach to use early returns, which allows reducing the level of indentation. So all in all, what looks like a lot of changes is really no change in behavior, mostly just moving whitespace around. Modified: head/sys/dev/flash/at45d.c Modified: head/sys/dev/flash/at45d.c == --- head/sys/dev/flash/at45d.c Sun Feb 24 23:16:33 2019(r344506) +++ head/sys/dev/flash/at45d.c Mon Feb 25 03:29:12 2019(r344507) @@ -78,7 +78,6 @@ struct at45d_softc struct mtx sc_mtx; struct disk *disk; struct proc *p; - struct intr_config_hook config_intrhook; device_tdev; u_int taskstate; uint16_tpagecount; @@ -229,13 +228,7 @@ at45d_attach(device_t dev) sc->dev = dev; AT45D_LOCK_INIT(sc); - /* We'll see what kind of flash we have later... */ - sc->config_intrhook.ich_func = at45d_delayed_attach; - sc->config_intrhook.ich_arg = sc; - if (config_intrhook_establish(>config_intrhook) != 0) { - device_printf(dev, "config_intrhook_establish failed\n"); - return (ENOMEM); - } + config_intrhook_oneshot(at45d_delayed_attach, sc); return (0); } @@ -285,51 +278,52 @@ at45d_delayed_attach(void *xsc) ident = NULL; jedec = 0; - if (at45d_wait_ready(sc->dev, ) != 0) + if (at45d_wait_ready(sc->dev, ) != 0) { device_printf(sc->dev, "Error waiting for device-ready.\n"); - else if (at45d_get_mfg_info(sc->dev, buf) != 0) + return; + } + if (at45d_get_mfg_info(sc->dev, buf) != 0) { device_printf(sc->dev, "Failed to get ID.\n"); - else { - jedec = buf[0] << 16 | buf[1] << 8 | buf[2]; - for (i = 0; i < nitems(at45d_flash_devices); i++) { - if (at45d_flash_devices[i].jedec == jedec) { - ident = _flash_devices[i]; - break; - } + return; + } + + jedec = buf[0] << 16 | buf[1] << 8 | buf[2]; + for (i = 0; i < nitems(at45d_flash_devices); i++) { + if (at45d_flash_devices[i].jedec == jedec) { + ident = _flash_devices[i]; + break; } } - if (ident == NULL) + if (ident == NULL) { device_printf(sc->dev, "JEDEC 0x%x not in list.\n", jedec); - else { - sc->pagecount = ident->pagecount; - sc->pageoffset = ident->pageoffset; - if (ident->pagesize2n != 0 && (status & 0x01) != 0) { - sc->pageoffset -= 1; - pagesize = ident->pagesize2n; - } else - pagesize = ident->pagesize; - sc->pagesize = pagesize; - - sc->disk = disk_alloc(); - sc->disk->d_open = at45d_open; - sc->disk->d_close = at45d_close; - sc->disk->d_strategy = at45d_strategy; - sc->disk->d_name = "flash/spi"; - sc->disk->d_drv1 = sc; - sc->disk->d_maxsize = DFLTPHYS; - sc->disk->d_sectorsize = pagesize; - sc->disk->d_mediasize = pagesize * ident->pagecount; - sc->disk->d_unit = device_get_unit(sc->dev); - disk_create(sc->disk, DISK_VERSION); - bioq_init(>bio_queue); - kproc_create(_task, sc, >p, 0, 0, - "task: at45d flash"); - sc->taskstate = TSTATE_RUNNING; - device_printf(sc->dev, "%s, %d bytes per page, %d pages\n", - ident->name, pagesize, ident->pagecount); + return; } - config_intrhook_disestablish(>config_intrhook); + sc->pagecount = ident->pagecount; + sc->pageoffset = ident->pageoffset; + if (ident->pagesize2n != 0 && (status & 0x01) != 0) { + sc->pageoffset -= 1; + pagesize = ident->pagesize2n; + } else + pagesize = ident->pagesize; + sc->pagesize = pagesize; + + sc->disk = disk_alloc(); + sc->disk->d_open = at45d_open; + sc->disk->d_close = at45d_close; + sc->disk->d_strategy = at45d_strategy; + sc->disk->d_name = "flash/spi"; + sc->disk->d_drv1 = sc; + sc->disk->d_maxsize = DFLTPHYS; + sc->disk->d_sectorsize = pagesize; + sc->disk->d_mediasize = pagesize * ident->pagecount; + sc->disk->d_unit = device_get_unit(sc->dev); + disk_create(sc->disk,
svn commit: r344505 - head/sys/dev/flash
Author: ian Date: Sun Feb 24 23:08:53 2019 New Revision: 344505 URL: https://svnweb.freebsd.org/changeset/base/344505 Log: Add a functional detach() implementation to make module unloading possible. Modified: head/sys/dev/flash/at45d.c Modified: head/sys/dev/flash/at45d.c == --- head/sys/dev/flash/at45d.c Sun Feb 24 22:49:56 2019(r344504) +++ head/sys/dev/flash/at45d.c Sun Feb 24 23:08:53 2019(r344505) @@ -65,11 +65,16 @@ struct at45d_softc struct proc *p; struct intr_config_hook config_intrhook; device_tdev; + u_int taskstate; uint16_tpagecount; uint16_tpageoffset; uint16_tpagesize; }; +#defineTSTATE_STOPPED 0 +#defineTSTATE_STOPPING 1 +#defineTSTATE_RUNNING 2 + #defineAT45D_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) #defineAT45D_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) #defineAT45D_LOCK_INIT(_sc) \ @@ -209,8 +214,33 @@ at45d_attach(device_t dev) static int at45d_detach(device_t dev) { + struct at45d_softc *sc; + int err; - return (EBUSY) /* XXX */; + sc = device_get_softc(dev); + err = 0; + + AT45D_LOCK(sc); + if (sc->taskstate == TSTATE_RUNNING) { + sc->taskstate = TSTATE_STOPPING; + wakeup(sc); + while (err == 0 && sc->taskstate != TSTATE_STOPPED) { + err = msleep(sc, >sc_mtx, 0, "at45dt", hz * 3); + if (err != 0) { + sc->taskstate = TSTATE_RUNNING; + device_printf(sc->dev, + "Failed to stop queue task\n"); + } + } + } + AT45D_UNLOCK(sc); + + if (err == 0 && sc->taskstate == TSTATE_STOPPED) { + disk_destroy(sc->disk); + bioq_flush(>bio_queue, NULL, ENXIO); + AT45D_LOCK_DESTROY(sc); + } + return (err); } static void @@ -266,6 +296,7 @@ at45d_delayed_attach(void *xsc) bioq_init(>bio_queue); kproc_create(_task, sc, >p, 0, 0, "task: at45d flash"); + sc->taskstate = TSTATE_RUNNING; device_printf(sc->dev, "%s, %d bytes per page, %d pages\n", ident->name, pagesize, ident->pagecount); } @@ -324,6 +355,12 @@ at45d_task(void *arg) for (;;) { AT45D_LOCK(sc); do { + if (sc->taskstate == TSTATE_STOPPING) { + sc->taskstate = TSTATE_STOPPED; + AT45D_UNLOCK(sc); + wakeup(sc); + kproc_exit(0); + } bp = bioq_takefirst(>bio_queue); if (bp == NULL) msleep(sc, >sc_mtx, PRIBIO, "jobqueue", 0); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r344504 - head/sys/netinet
Author: bz Date: Sun Feb 24 22:49:56 2019 New Revision: 344504 URL: https://svnweb.freebsd.org/changeset/base/344504 Log: Make arp code return (more) errors. arprequest() is a void function and in case of error we simply return without any feedback. In case of any local operation or *if_output() failing no feedback is send up the stack for the packet which triggered the arp request to be sent. arpresolve_full() has three pre-canned possible errors returned (if we have not yet sent enough arp requests or if we tried often enough without success) otherwise "no error" is returned. Make arprequest() an "internal" function arprequest_internal() which does return a possible error to the caller. Preserve arprequest() as a void wrapper function for external consumers. In arpresolve_full() add an extra error checking. Use the arprequest_internal() function and only return an error if non of the three ones (mentioend above) are already set. This will return possible errors all the way up the stack and allows functions and programs to react on the send errors rather than leaving them in the dark. Also they might get more detailed feedback of why packets cannot be sent and they will receive it quicker. Reviewed by: karels, hselasky Differential Revision:https://reviews.freebsd.org/D18904 Modified: head/sys/netinet/if_ether.c Modified: head/sys/netinet/if_ether.c == --- head/sys/netinet/if_ether.c Sun Feb 24 21:22:16 2019(r344503) +++ head/sys/netinet/if_ether.c Sun Feb 24 22:49:56 2019(r344504) @@ -341,8 +341,8 @@ arp_fillheader(struct ifnet *ifp, struct arphdr *ah, i * - arp header target ip address * - arp header source ethernet address */ -void -arprequest(struct ifnet *ifp, const struct in_addr *sip, +static int +arprequest_internal(struct ifnet *ifp, const struct in_addr *sip, const struct in_addr *tip, u_char *enaddr) { struct mbuf *m; @@ -383,14 +383,14 @@ arprequest(struct ifnet *ifp, const struct in_addr *si NET_EPOCH_EXIT(et); if (sip == NULL) { printf("%s: cannot find matching address\n", __func__); - return; + return (EADDRNOTAVAIL); } } if (enaddr == NULL) enaddr = carpaddr ? carpaddr : (u_char *)IF_LLADDR(ifp); if ((m = m_gethdr(M_NOWAIT, MT_DATA)) == NULL) - return; + return (ENOMEM); m->m_len = sizeof(*ah) + 2 * sizeof(struct in_addr) + 2 * ifp->if_addrlen; m->m_pkthdr.len = m->m_len; @@ -417,7 +417,7 @@ arprequest(struct ifnet *ifp, const struct in_addr *si if (error != 0 && error != EAFNOSUPPORT) { ARP_LOG(LOG_ERR, "Failed to calculate ARP header on %s: %d\n", if_name(ifp), error); - return; + return (error); } ro.ro_prepend = linkhdr; @@ -426,11 +426,22 @@ arprequest(struct ifnet *ifp, const struct in_addr *si m->m_flags |= M_BCAST; m_clrprotoflags(m); /* Avoid confusing lower layers. */ - (*ifp->if_output)(ifp, m, , ); + error = (*ifp->if_output)(ifp, m, , ); ARPSTAT_INC(txrequests); + if (error) + ARP_LOG(LOG_DEBUG, "Failed to send ARP packet on %s: %d\n", + if_name(ifp), error); + return (error); } +void +arprequest(struct ifnet *ifp, const struct in_addr *sip, +const struct in_addr *tip, u_char *enaddr) +{ + (void) arprequest_internal(ifp, sip, tip, enaddr); +} + /* * Resolve an IP address into an ethernet address - heavy version. * Used internally by arpresolve(). @@ -557,7 +568,7 @@ arpresolve_full(struct ifnet *ifp, int is_gw, int flag error = is_gw != 0 ? EHOSTUNREACH : EHOSTDOWN; if (renew) { - int canceled; + int canceled, e; LLE_ADDREF(la); la->la_expire = time_uptime; @@ -567,7 +578,13 @@ arpresolve_full(struct ifnet *ifp, int is_gw, int flag LLE_REMREF(la); la->la_asked++; LLE_WUNLOCK(la); - arprequest(ifp, NULL, (dst)->sin_addr, NULL); + e = arprequest_internal(ifp, NULL, (dst)->sin_addr, NULL); + /* +* Only overwrite 'error' in case of error; in case of success +* the proper return value was already set above. +*/ + if (e != 0) + return (e); return (error); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r344495 - head/sys/dev/evdev
Author: wulf Date: Sun Feb 24 19:31:42 2019 New Revision: 344495 URL: https://svnweb.freebsd.org/changeset/base/344495 Log: Fix build when EVDEV_SUPPORT is option disabled after r344494 MFC with: 344494 Modified: head/sys/dev/evdev/evdev.c Modified: head/sys/dev/evdev/evdev.c == --- head/sys/dev/evdev/evdev.c Sun Feb 24 18:47:04 2019(r344494) +++ head/sys/dev/evdev/evdev.c Sun Feb 24 19:31:42 2019(r344495) @@ -69,16 +69,16 @@ MALLOC_DEFINE(M_EVDEV, "evdev", "evdev memory"); int evdev_rcpt_mask = EVDEV_RCPT_SYSMOUSE | EVDEV_RCPT_KBDMUX; int evdev_sysmouse_t_axis = 0; -#ifdef EVDEV_SUPPORT SYSCTL_NODE(_kern, OID_AUTO, evdev, CTLFLAG_RW, 0, "Evdev args"); +#ifdef EVDEV_SUPPORT SYSCTL_INT(_kern_evdev, OID_AUTO, rcpt_mask, CTLFLAG_RW, _rcpt_mask, 0, "Who is receiving events: bit0 - sysmouse, bit1 - kbdmux, " "bit2 - mouse hardware, bit3 - keyboard hardware"); SYSCTL_INT(_kern_evdev, OID_AUTO, sysmouse_t_axis, CTLFLAG_RW, _sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm"); +#endif SYSCTL_NODE(_kern_evdev, OID_AUTO, input, CTLFLAG_RD, 0, "Evdev input devices"); -#endif static void evdev_start_repeat(struct evdev_dev *, uint16_t); static void evdev_stop_repeat(struct evdev_dev *); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r344506 - head/sys/dev/flash
Author: ian Date: Sun Feb 24 23:16:33 2019 New Revision: 344506 URL: https://svnweb.freebsd.org/changeset/base/344506 Log: Add support for probing/attaching on FDT-based systems. Modified: head/sys/dev/flash/at45d.c Modified: head/sys/dev/flash/at45d.c == --- head/sys/dev/flash/at45d.c Sun Feb 24 23:08:53 2019(r344505) +++ head/sys/dev/flash/at45d.c Sun Feb 24 23:16:33 2019(r344506) @@ -47,6 +47,21 @@ __FBSDID("$FreeBSD$"); #include #include "spibus_if.h" +#include "opt_platform.h" + +#ifdef FDT +#include +#include +#include + +static struct ofw_compat_data compat_data[] = { + { "atmel,at45", 1 }, + { "atmel,dataflash",1 }, + { NULL, 0 }, +}; +SPIBUS_PNP_INFO(compat_data); +#endif + struct at45d_flash_ident { const char *name; @@ -187,9 +202,22 @@ at45d_wait_ready(device_t dev, uint8_t *status) static int at45d_probe(device_t dev) { + int rv; +#ifdef FDT + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + + rv = BUS_PROBE_DEFAULT; +#else + rv = BUS_PROBE_NOWILDCARD; +#endif + device_set_desc(dev, "AT45D Flash Family"); - return (0); + return (rv); } static int ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r344503 - head/contrib/llvm/lib/Target/X86
Author: dim Date: Sun Feb 24 21:22:16 2019 New Revision: 344503 URL: https://svnweb.freebsd.org/changeset/base/344503 Log: Pull in r354756 from upstream llvm trunk (by Craig Topper): [X86] Fix tls variable lowering issue with large code model Summary: The problem here is the lowering for tls variable. Below is the DAG for the code. SelectionDAG has 11 nodes: t0: ch = EntryToken t8: i64,ch = load<(load 8 from `i8 addrspace(257)* null`, addrspace 257)> t0, Constant:i64<0>, undef:i64 t10: i64 = X86ISD::WrapperRIP TargetGlobalTLSAddress:i64 0 [TF=10] t11: i64,ch = load<(load 8 from got)> t0, t10, undef:i64 t12: i64 = add t8, t11 t4: i32,ch = load<(dereferenceable load 4 from @x)> t0, t12, undef:i64 t6: ch = CopyToReg t0, Register:i32 %0, t4 And when mcmodel is large, below instruction can NOT be folded. t10: i64 = X86ISD::WrapperRIP TargetGlobalTLSAddress:i64 0 [TF=10] t11: i64,ch = load<(load 8 from got)> t0, t10, undef:i64 So "t11: i64,ch = load<(load 8 from got)> t0, t10, undef:i64" is lowered to " Morphed node: t11: i64,ch = MOV64rm t10, TargetConstant:i8<1>, Register:i64 $noreg, TargetConstant:i32<0>, Register:i32 $noreg, t0" When llvm start to lower "t10: i64 = X86ISD::WrapperRIP TargetGlobalTLSAddress:i64 0 [TF=10]", it fails. The patch is to fold the load and X86ISD::WrapperRIP. Fixes PR26906 Patch by LuoYuanke Reviewers: craig.topper, rnk, annita.zhang, wxiao3 Reviewed By: rnk Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58336 This should fix "fatal error: error in backend: Cannot select" messages when compiling functions using -mcmodel=large. Reported by: phk PR: 233143 MFC after:3 days Modified: head/contrib/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp Modified: head/contrib/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp == --- head/contrib/llvm/lib/Target/X86/X86ISelDAGToDAG.cppSun Feb 24 21:05:13 2019(r344502) +++ head/contrib/llvm/lib/Target/X86/X86ISelDAGToDAG.cppSun Feb 24 21:22:16 2019(r344503) @@ -989,15 +989,23 @@ bool X86DAGToDAGISel::matchWrapper(SDValue N, X86ISelA if (AM.hasSymbolicDisplacement()) return true; + bool IsRIPRelTLS = false; bool IsRIPRel = N.getOpcode() == X86ISD::WrapperRIP; + if (IsRIPRel) { +SDValue Val = N.getOperand(0); +if (Val.getOpcode() == ISD::TargetGlobalTLSAddress) + IsRIPRelTLS = true; + } - // We can't use an addressing mode in the 64-bit large code model. In the - // medium code model, we use can use an mode when RIP wrappers are present. - // That signifies access to globals that are known to be "near", such as the - // GOT itself. + // We can't use an addressing mode in the 64-bit large code model. + // Global TLS addressing is an exception. In the medium code model, + // we use can use a mode when RIP wrappers are present. + // That signifies access to globals that are known to be "near", + // such as the GOT itself. CodeModel::Model M = TM.getCodeModel(); if (Subtarget->is64Bit() && - (M == CodeModel::Large || (M == CodeModel::Medium && !IsRIPRel))) + ((M == CodeModel::Large && !IsRIPRelTLS) || + (M == CodeModel::Medium && !IsRIPRel))) return true; // Base and index reg must be 0 in order to use %rip as base. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r344502 - in head/bin/sh: . tests/execution
Author: jilles Date: Sun Feb 24 21:05:13 2019 New Revision: 344502 URL: https://svnweb.freebsd.org/changeset/base/344502 Log: sh: Add set -o pipefail The pipefail option allows checking the exit status of all commands in a pipeline more easily, at a limited cost of complexity in sh itself. It works similarly to the option in bash, ksh93 and mksh. Like ksh93 and unlike bash and mksh, the state of the option is saved when a pipeline is started. Therefore, even in the case of commands like A | B & a later change of the option does not change the exit status, the same way (A | B) & works. Since SIGPIPE is not handled specially, more work in the script is required for a proper exit status for pipelines containing commands such as head that may terminate successfully without reading all input. This can be something like ( cmd1 r=$? if [ "$r" -gt 128 ] && [ "$(kill -l "$r")" = PIPE ]; then exit 0 else exit "$r" fi ) | head PR: 224270 Relnotes: yes Added: head/bin/sh/tests/execution/pipefail1.0 (contents, props changed) head/bin/sh/tests/execution/pipefail2.42 (contents, props changed) head/bin/sh/tests/execution/pipefail3.42 (contents, props changed) head/bin/sh/tests/execution/pipefail4.42 (contents, props changed) head/bin/sh/tests/execution/pipefail5.42 (contents, props changed) head/bin/sh/tests/execution/pipefail6.42 (contents, props changed) head/bin/sh/tests/execution/pipefail7.0 (contents, props changed) Modified: head/bin/sh/jobs.c head/bin/sh/options.h head/bin/sh/sh.1 head/bin/sh/tests/execution/Makefile Modified: head/bin/sh/jobs.c == --- head/bin/sh/jobs.c Sun Feb 24 20:55:00 2019(r344501) +++ head/bin/sh/jobs.c Sun Feb 24 21:05:13 2019(r344502) @@ -105,6 +105,7 @@ struct job { char changed; /* true if status has changed */ char foreground;/* true if running in the foreground */ char remembered;/* true if $! referenced */ + char pipefail; /* pass any non-zero status */ #if JOBS char jobctl;/* job running under job control */ struct job *next; /* job used after this one */ @@ -144,6 +145,7 @@ static void setcurjob(struct job *); static void deljob(struct job *); static struct job *getcurjob(struct job *); #endif +static int getjobstatus(const struct job *); static void printjobcmd(struct job *); static void showjob(struct job *, int); @@ -341,6 +343,20 @@ jobscmd(int argc __unused, char *argv[] __unused) return (0); } +static int getjobstatus(const struct job *jp) +{ + int i, status; + + if (!jp->pipefail) + return (jp->ps[jp->nprocs - 1].status); + for (i = jp->nprocs - 1; i >= 0; i--) { + status = jp->ps[i].status; + if (status != 0) + return (status); + } + return (0); +} + static void printjobcmd(struct job *jp) { @@ -377,7 +393,7 @@ showjob(struct job *jp, int mode) } #endif coredump = ""; - status = jp->ps[jp->nprocs - 1].status; + status = getjobstatus(jp); if (jp->state == 0) { statestr = "Running"; #if JOBS @@ -556,7 +572,7 @@ waitcmdloop(struct job *job) do { if (job != NULL) { if (job->state == JOBDONE) { - status = job->ps[job->nprocs - 1].status; + status = getjobstatus(job); if (WIFEXITED(status)) retval = WEXITSTATUS(status); else @@ -781,6 +797,7 @@ makejob(union node *node __unused, int nprocs) jp->nprocs = 0; jp->foreground = 0; jp->remembered = 0; + jp->pipefail = pipefailflag; #if JOBS jp->jobctl = jobctl; jp->next = NULL; @@ -1076,7 +1093,7 @@ waitforjob(struct job *jp, int *signaled) if (jp->state == JOBSTOPPED) setcurjob(jp); #endif - status = jp->ps[jp->nprocs - 1].status; + status = getjobstatus(jp); if (signaled != NULL) *signaled = WIFSIGNALED(status); /* convert to 8 bits */ Modified: head/bin/sh/options.h == --- head/bin/sh/options.h Sun Feb 24 20:55:00 2019(r344501) +++ head/bin/sh/options.h Sun Feb 24 21:05:13 2019(r344502) @@ -67,9 +67,10 @@ struct shparam { #definePflag optval[17] #definehflag optval[18] #definenologflag optval[19] +#definepipefailflag optval[20] #define NSHORTOPTS 19 -#define NOPTS 20 +#define NOPTS 21 extern char
svn commit: r344494 - in head: sbin/sysctl sys/dev/evdev
Author: wulf Date: Sun Feb 24 18:47:04 2019 New Revision: 344494 URL: https://svnweb.freebsd.org/changeset/base/344494 Log: evdev: export event device properties through sysctl interface A big security advantage of Wayland is not allowing applications to read input devices all the time. Having /dev/input/* accessible to the user account subverts this advantage. libudev-devd was opening the evdev devices to detect their types (mouse, keyboard, touchpad, etc). This don't work if /dev/input/* is inaccessible. With the kernel exposing this information as sysctls (kern.evdev.input.*), we can work w/o /dev/input/* access, preserving the Wayland security model. Submitted by: Greg V Reviewed by: wulf, imp MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D18694 Modified: head/sbin/sysctl/sysctl.c head/sys/dev/evdev/evdev.c head/sys/dev/evdev/evdev_private.h Modified: head/sbin/sysctl/sysctl.c == --- head/sbin/sysctl/sysctl.c Sun Feb 24 17:23:55 2019(r344493) +++ head/sbin/sysctl/sysctl.c Sun Feb 24 18:47:04 2019(r344494) @@ -49,6 +49,7 @@ static const char rcsid[] = #include #include #include +#include #ifdef __amd64__ #include @@ -680,6 +681,22 @@ S_vmtotal(size_t l2, void *p) return (0); } +static int +S_input_id(size_t l2, void *p) +{ + struct input_id *id = p; + + if (l2 != sizeof(*id)) { + warnx("S_input_id %zu != %zu", l2, sizeof(*id)); + return (1); + } + + printf("{ bustype = 0x%04x, vendor = 0x%04x, " + "product = 0x%04x, version = 0x%04x }", + id->bustype, id->vendor, id->product, id->version); + return (0); +} + #ifdef __amd64__ static int S_efi_map(size_t l2, void *p) @@ -983,6 +1000,8 @@ show_var(int *oid, int nlen) func = S_loadavg; else if (strcmp(fmt, "S,vmtotal") == 0) func = S_vmtotal; + else if (strcmp(fmt, "S,input_id") == 0) + func = S_input_id; #ifdef __amd64__ else if (strcmp(fmt, "S,efi_map_header") == 0) func = S_efi_map; Modified: head/sys/dev/evdev/evdev.c == --- head/sys/dev/evdev/evdev.c Sun Feb 24 17:23:55 2019(r344493) +++ head/sys/dev/evdev/evdev.c Sun Feb 24 18:47:04 2019(r344494) @@ -76,6 +76,8 @@ SYSCTL_INT(_kern_evdev, OID_AUTO, rcpt_mask, CTLFLAG_R "bit2 - mouse hardware, bit3 - keyboard hardware"); SYSCTL_INT(_kern_evdev, OID_AUTO, sysmouse_t_axis, CTLFLAG_RW, _sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm"); +SYSCTL_NODE(_kern_evdev, OID_AUTO, input, CTLFLAG_RD, 0, +"Evdev input devices"); #endif static void evdev_start_repeat(struct evdev_dev *, uint16_t); @@ -196,6 +198,87 @@ evdev_estimate_report_size(struct evdev_dev *evdev) return (size); } +static void +evdev_sysctl_create(struct evdev_dev *evdev) +{ + struct sysctl_oid *ev_sysctl_tree; + char ev_unit_str[8]; + + snprintf(ev_unit_str, sizeof(ev_unit_str), "%d", evdev->ev_unit); + sysctl_ctx_init(>ev_sysctl_ctx); + + ev_sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(>ev_sysctl_ctx, + SYSCTL_STATIC_CHILDREN(_kern_evdev_input), OID_AUTO, + ev_unit_str, CTLFLAG_RD, NULL, "", "device index"); + + SYSCTL_ADD_STRING(>ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "name", CTLFLAG_RD, + evdev->ev_name, 0, + "Input device name"); + + SYSCTL_ADD_STRUCT(>ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "id", CTLFLAG_RD, + >ev_id, input_id, + "Input device identification"); + + /* ioctl returns ENOENT if phys is not set. sysctl returns "" here */ + SYSCTL_ADD_STRING(>ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "phys", CTLFLAG_RD, + evdev->ev_shortname, 0, + "Input device short name"); + + /* ioctl returns ENOENT if uniq is not set. sysctl returns "" here */ + SYSCTL_ADD_STRING(>ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "uniq", CTLFLAG_RD, + evdev->ev_serial, 0, + "Input device unique number"); + + SYSCTL_ADD_OPAQUE(>ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "props", CTLFLAG_RD, + evdev->ev_prop_flags, sizeof(evdev->ev_prop_flags), "", + "Input device properties"); + + SYSCTL_ADD_OPAQUE(>ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "type_bits", CTLFLAG_RD, + evdev->ev_type_flags, sizeof(evdev->ev_type_flags), "", + "Input device supported events types"); + + SYSCTL_ADD_OPAQUE(>ev_sysctl_ctx, +
svn commit: r344493 - head/sys/netpfil/pf
Author: kp Date: Sun Feb 24 17:23:55 2019 New Revision: 344493 URL: https://svnweb.freebsd.org/changeset/base/344493 Log: pf: Small performance tweak Because fetching a counter is a rather expansive function we should use counter_u64_fetch() in pf_state_expires() only when necessary. A "rdr pass" rule should not cause more effort than separate "rdr" and "pass" rules. For rules with adaptive timeout values the call of counter_u64_fetch() should be accepted, but otherwise not. From the man page: The adaptive timeout values can be defined both globally and for each rule. When used on a per-rule basis, the values relate to the number of states created by the rule, otherwise to the total number of states. This handling of adaptive timeouts is done in pf_state_expires(). The calculation needs three values: start, end and states. 1. Normal rules "pass .." without adaptive setting meaning "start = 0" runs in the else-section and therefore takes "start" and "end" from the global default settings and sets "states" to pf_status.states (= total number of states). 2. Special rules like "pass .. keep state (adaptive.start 500 adaptive.end 1000)" have start != 0, run in the if-section and take "start" and "end" from the rule and set "states" to the number of states created by their rule using counter_u64_fetch(). Thats all ok, but there is a third case without special handling in the above code snippet: 3. All "rdr/nat pass .." statements use together the pf_default_rule. Therefore we have "start != 0" in this case and we run the if-section but we better should run the else-section in this case and do not fetch the counter of the pf_default_rule but take the total number of states. Submitted by: Andreas Longwitz MFC after:2 weeks Modified: head/sys/netpfil/pf/pf.c Modified: head/sys/netpfil/pf/pf.c == --- head/sys/netpfil/pf/pf.cSun Feb 24 14:20:47 2019(r344492) +++ head/sys/netpfil/pf/pf.cSun Feb 24 17:23:55 2019(r344493) @@ -1564,7 +1564,7 @@ pf_state_expires(const struct pf_state *state) if (!timeout) timeout = V_pf_default_rule.timeout[state->timeout]; start = state->rule.ptr->timeout[PFTM_ADAPTIVE_START]; - if (start) { + if (start && state->rule.ptr != _pf_default_rule) { end = state->rule.ptr->timeout[PFTM_ADAPTIVE_END]; states = counter_u64_fetch(state->rule.ptr->states_cur); } else { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r344492 - head/share/man/man5
Author: 0mp (ports committer) Date: Sun Feb 24 14:20:47 2019 New Revision: 344492 URL: https://svnweb.freebsd.org/changeset/base/344492 Log: style.mdoc.5: Fix a typo Reviewed by: eadler Approved by: eadler (doc) Approved by: krion (mentor, implicit), mat (mentor, implicit) Differential Revision:https://reviews.freebsd.org/D19328 Modified: head/share/man/man5/style.mdoc.5 Modified: head/share/man/man5/style.mdoc.5 == --- head/share/man/man5/style.mdoc.5Sun Feb 24 03:41:05 2019 (r344491) +++ head/share/man/man5/style.mdoc.5Sun Feb 24 14:20:47 2019 (r344492) @@ -203,7 +203,7 @@ macro is usually not necessary. .It Use .Sy \ -instead of: +instead of .Sy \ for .Xr sysctl 8 ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r344491 - head/usr.sbin/syslogd
Author: ume Date: Sun Feb 24 03:41:05 2019 New Revision: 344491 URL: https://svnweb.freebsd.org/changeset/base/344491 Log: An IPv6 address matching should be fixed. Specifying an IPv6 address by the -a option was broken since r309933. Reported by: "O. Hartmann" MFC after:1 week Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c == --- head/usr.sbin/syslogd/syslogd.c Sun Feb 24 01:56:35 2019 (r344490) +++ head/usr.sbin/syslogd/syslogd.c Sun Feb 24 03:41:05 2019 (r344491) @@ -3202,8 +3202,8 @@ validate(struct sockaddr *sa, const char *hname) dprintf("rejected in rule %d due to scope mismatch.\n", i); continue; } - if (IN6_ARE_MASKED_ADDR_EQUAL(>sin6_addr, - >sin6_addr, >sin6_addr) != 0) { + if (!IN6_ARE_MASKED_ADDR_EQUAL(>sin6_addr, + >sin6_addr, >sin6_addr)) { dprintf("rejected in rule %d due to IP mismatch.\n", i); continue; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"