svn commit: r365652 - in head/sys: sys x86/x86
Author: jah Date: Sat Sep 12 07:04:00 2020 New Revision: 365652 URL: https://svnweb.freebsd.org/changeset/base/365652 Log: amd64: prevent KCSan false positives on LAPIC mapping For configurations without x2APIC support (guests, older hardware), the global LAPIC MMIO mapping will trigger false-positive KCSan reports as it will appear that multiple CPUs are concurrently reading and writing the same address. This isn't actually true, as the underlying physical access will be performed on the local CPU's APIC. Additionally, because LAPIC access can happen during event timer configuration, the resulting KCSan printf can produce a panic due to attempted recursion on event timer resources. Add a __nosanitizethread preprocessor define to prevent the compiler from inserting TSan hooks, and apply it to the x86 LAPIC accessors. PR: 249149 Reported by: gbe Reviewed by: andrew, kib Tested by:gbe Differential Revision:https://reviews.freebsd.org/D26354 Modified: head/sys/sys/cdefs.h head/sys/x86/x86/local_apic.c Modified: head/sys/sys/cdefs.h == --- head/sys/sys/cdefs.hSat Sep 12 01:55:07 2020(r365651) +++ head/sys/sys/cdefs.hSat Sep 12 07:04:00 2020(r365652) @@ -880,8 +880,10 @@ */ #if __has_attribute(no_sanitize) && defined(__clang__) #define __nosanitizeaddress__attribute__((no_sanitize("address"))) +#define __nosanitizethread __attribute__((no_sanitize("thread"))) #else #define __nosanitizeaddress +#define __nosanitizethread #endif /* Guard variables and structure members by lock. */ Modified: head/sys/x86/x86/local_apic.c == --- head/sys/x86/x86/local_apic.c Sat Sep 12 01:55:07 2020 (r365651) +++ head/sys/x86/x86/local_apic.c Sat Sep 12 07:04:00 2020 (r365652) @@ -215,7 +215,17 @@ SYSCTL_INT(_hw_apic, OID_AUTO, timer_tsc_deadline, CTL static void lapic_calibrate_initcount(struct lapic *la); static void lapic_calibrate_deadline(struct lapic *la); -static uint32_t +/* + * Use __nosanitizethread to exempt the LAPIC I/O accessors from KCSan + * instrumentation. Otherwise, if x2APIC is not available, use of the global + * lapic_map will generate a KCSan false positive. While the mapping is + * shared among all CPUs, the physical access will always take place on the + * local CPU's APIC, so there isn't in fact a race here. Furthermore, the + * KCSan warning printf can cause a panic if issued during LAPIC access, + * due to attempted recursive use of event timer resources. + */ + +static uint32_t __nosanitizethread lapic_read32(enum LAPIC_REGISTERS reg) { uint32_t res; @@ -228,7 +238,7 @@ lapic_read32(enum LAPIC_REGISTERS reg) return (res); } -static void +static void __nosanitizethread lapic_write32(enum LAPIC_REGISTERS reg, uint32_t val) { @@ -241,7 +251,7 @@ lapic_write32(enum LAPIC_REGISTERS reg, uint32_t val) } } -static void +static void __nosanitizethread lapic_write32_nofence(enum LAPIC_REGISTERS reg, uint32_t val) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r364239 - head/sys/kern
Author: jah Date: Fri Aug 14 21:37:38 2020 New Revision: 364239 URL: https://svnweb.freebsd.org/changeset/base/364239 Log: kenv: avoid sleepable alloc for integer tunables Avoid performing a potentially-blocking malloc for kenv lookups that will only perform non-destructive integer conversions on the returned buffer. Instead, perform the strtoq() in-place with the kenv lock held. While here, factor the logic around kenv_lock acquire and release into kenv_acquire() and kenv_release(), and use these functions for some light cleanup. Collapse getenv_string_buffer() into kern_getenv(), as the former no longer has any other callers and the only additional task performed by the latter is a WITNESS check that hasn't been useful since r362231. PR: 248250 Reported by: gbe Reviewed by: mjg Tested by:gbe Differential Revision:https://reviews.freebsd.org/D26010 Modified: head/sys/kern/kern_environment.c Modified: head/sys/kern/kern_environment.c == --- head/sys/kern/kern_environment.cFri Aug 14 21:29:56 2020 (r364238) +++ head/sys/kern/kern_environment.cFri Aug 14 21:37:38 2020 (r364239) @@ -59,6 +59,9 @@ __FBSDID("$FreeBSD$"); static char *_getenv_dynamic_locked(const char *name, int *idx); static char *_getenv_dynamic(const char *name, int *idx); +static char *kenv_acquire(const char *name); +static void kenv_release(const char *buf); + static MALLOC_DEFINE(M_KENV, "kenv", "kernel environment"); #define KENV_SIZE 512 /* Maximum number of environment strings */ @@ -88,8 +91,6 @@ bool dynamic_kenv; #define KENV_CHECK if (!dynamic_kenv) \ panic("%s: called before SI_SUB_KMEM", __func__) -static char*getenv_string_buffer(const char *); - int sys_kenv(td, uap) struct thread *td; @@ -482,16 +483,24 @@ _getenv_static(const char *name) char * kern_getenv(const char *name) { - char *ret; + char *cp, *ret; + int len; if (dynamic_kenv) { - ret = getenv_string_buffer(name); - if (ret == NULL) { - WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, - "getenv"); + len = KENV_MNAMELEN + 1 + kenv_mvallen + 1; + ret = uma_zalloc(kenv_zone, M_WAITOK | M_ZERO); + mtx_lock(_lock); + cp = _getenv_dynamic(name, NULL); + if (cp != NULL) + strlcpy(ret, cp, len); + mtx_unlock(_lock); + if (cp == NULL) { + uma_zfree(kenv_zone, ret); + ret = NULL; } } else ret = _getenv_static(name); + return (ret); } @@ -503,12 +512,9 @@ testenv(const char *name) { char *cp; - if (dynamic_kenv) { - mtx_lock(_lock); - cp = _getenv_dynamic(name, NULL); - mtx_unlock(_lock); - } else - cp = _getenv_static(name); + cp = kenv_acquire(name); + kenv_release(cp); + if (cp != NULL) return (1); return (0); @@ -615,30 +621,33 @@ kern_unsetenv(const char *name) } /* - * Return a buffer containing the string value from an environment variable + * Return the internal kenv buffer for the variable name, if it exists. + * If the dynamic kenv is initialized and the name is present, return + * with kenv_lock held. */ static char * -getenv_string_buffer(const char *name) +kenv_acquire(const char *name) { - char *cp, *ret; - int len; + char *value; if (dynamic_kenv) { - len = KENV_MNAMELEN + 1 + kenv_mvallen + 1; - ret = uma_zalloc(kenv_zone, M_WAITOK | M_ZERO); mtx_lock(_lock); - cp = _getenv_dynamic(name, NULL); - if (cp != NULL) - strlcpy(ret, cp, len); - mtx_unlock(_lock); - if (cp == NULL) { - uma_zfree(kenv_zone, ret); - ret = NULL; - } + value = _getenv_dynamic(name, NULL); + if (value == NULL) + mtx_unlock(_lock); + return (value); } else - ret = _getenv_static(name); + return (_getenv_static(name)); +} - return (ret); +/* + * Undo a previous kenv_acquire() operation + */ +static void +kenv_release(const char *buf) +{ + if ((buf != NULL) && dynamic_kenv) + mtx_unlock(_lock); } /* @@ -649,17 +658,13 @@ getenv_string(const char *name, char *data, int size) { char *cp; - if (dynamic_kenv) { - mtx_lock(_lock); - cp = _getenv_dynamic(name, NULL); - if (cp != NULL) - strlcpy(data, cp, size); -
svn commit: r363784 - head/sys/dev/vt
Author: jah Date: Sun Aug 2 20:18:37 2020 New Revision: 363784 URL: https://svnweb.freebsd.org/changeset/base/363784 Log: vt(4): CONS_HISTORY/CONS_CLRHIST should operate on issuing terminal Currently the CONS_HISTORY and CONS_CLRHIST ioctls modify the state of the active terminal instead of the terminal against which the ioctl was issued. Because of the way vidcontrol(1) works, these are the same in most cases. But a poorly-timed window switch can make them differ. This is reproducible by issuing e.g. 'vidcontrol -s 2 && vidcontrol -C' to switch from vty 1 to vty 2; teken will reset the cursor position on vty 1 but vt(4) will clear the history buffer of vty 2, producing an interesting state of affairs. Differential Revision:https://reviews.freebsd.org/D25564 Modified: head/sys/dev/vt/vt_core.c Modified: head/sys/dev/vt/vt_core.c == --- head/sys/dev/vt/vt_core.c Sun Aug 2 20:03:23 2020(r363783) +++ head/sys/dev/vt/vt_core.c Sun Aug 2 20:18:37 2020(r363784) @@ -454,7 +454,7 @@ vt_window_postswitch(struct vt_window *vw) return (0); } -/* vt_late_window_switch will done VT switching for regular case. */ +/* vt_late_window_switch will do VT switching for regular case. */ static int vt_late_window_switch(struct vt_window *vw) { @@ -2326,12 +2326,11 @@ skip_thunk: case CONS_HISTORY: if (*(int *)data < 0) return EINVAL; - if (*(int *)data != vd->vd_curwindow->vw_buf.vb_history_size) - vtbuf_sethistory_size(>vd_curwindow->vw_buf, - *(int *)data); + if (*(int *)data != vw->vw_buf.vb_history_size) + vtbuf_sethistory_size(>vw_buf, *(int *)data); return (0); case CONS_CLRHIST: - vtbuf_clearhistory(>vd_curwindow->vw_buf); + vtbuf_clearhistory(>vw_buf); /* * Invalidate the entire visible window; it is not guaranteed * that this operation will be immediately followed by a scroll @@ -2339,9 +2338,11 @@ skip_thunk: * to remain visible. */ VT_LOCK(vd); - vd->vd_flags |= VDF_INVALID; + if (vw == vd->vd_curwindow) { + vd->vd_flags |= VDF_INVALID; + vt_resume_flush_timer(vw, 0); + } VT_UNLOCK(vd); - vt_resume_flush_timer(vd->vd_curwindow, 0); return (0); case CONS_GET: /* XXX */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361741 - head/sys/x86/x86
Author: jah Date: Wed Jun 3 00:16:36 2020 New Revision: 361741 URL: https://svnweb.freebsd.org/changeset/base/361741 Log: Remove unnecessary WITNESS check in x86 bus_dma When I did some bus_dma cleanup in r320528, I brought forward some sketchy WITNESS checks from the prior x86 busdma wrappers, instead of recognizing them as technical debt and just dropping them. Two of these were removed in r346351 and r346851, but one remains in bounce_bus_dmamem_alloc(). This check could be constrained to only apply in the BUS_DMA_NOWAIT case, but it's cleaner to simply remove it and rely on the checks already present in the sleepable allocation paths used by this function. While here, remove another unnecessary witness check in bus_dma_tag_create (the tag is always allocated with M_NOWAIT), and fix a couple of typos. Reported by: cem Reviewed by: kib, cem MFC after:1 week Differential Revision:https://reviews.freebsd.org/D25107 Modified: head/sys/x86/x86/busdma_bounce.c head/sys/x86/x86/busdma_machdep.c Modified: head/sys/x86/x86/busdma_bounce.c == --- head/sys/x86/x86/busdma_bounce.cTue Jun 2 22:57:13 2020 (r361740) +++ head/sys/x86/x86/busdma_bounce.cWed Jun 3 00:16:36 2020 (r361741) @@ -407,8 +407,6 @@ bounce_bus_dmamem_alloc(bus_dma_tag_t dmat, void** vad vm_memattr_t attr; int mflags; - WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "%s", __func__); - if (flags & BUS_DMA_NOWAIT) mflags = M_NOWAIT; else @@ -492,7 +490,7 @@ bounce_bus_dmamem_alloc(bus_dma_tag_t dmat, void** vad } /* - * Free a piece of memory and it's allociated dmamap, that was allocated + * Free a piece of memory and its associated dmamap, that was allocated * via bus_dmamem_alloc. Make the same choice for free/contigfree. */ static void Modified: head/sys/x86/x86/busdma_machdep.c == --- head/sys/x86/x86/busdma_machdep.c Tue Jun 2 22:57:13 2020 (r361740) +++ head/sys/x86/x86/busdma_machdep.c Wed Jun 3 00:16:36 2020 (r361741) @@ -223,8 +223,6 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t al struct bus_dma_tag_common *tc; int error; - WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "%s", __func__); - if (parent == NULL) { error = bus_dma_bounce_impl.tag_create(parent, alignment, boundary, lowaddr, highaddr, filter, filterarg, maxsize, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361719 - in head/sys: dev/vt kern
Author: jah Date: Tue Jun 2 01:21:48 2020 New Revision: 361719 URL: https://svnweb.freebsd.org/changeset/base/361719 Log: vt(4): reset scrollback and cursor position after clearing history buffer r361601 implemented basic support for cleaing the console history buffer. But after clearing the history buffer, it's not especially useful to be able to scroll back through that buffer, or for the cursor position to remain at (very likely) the bottom of the screen. PR: 224436 Reviewed by: emaste Differential Revision:https://reviews.freebsd.org/D25079 Modified: head/sys/dev/vt/vt_buf.c head/sys/dev/vt/vt_core.c head/sys/kern/subr_terminal.c Modified: head/sys/dev/vt/vt_buf.c == --- head/sys/dev/vt/vt_buf.cTue Jun 2 01:04:49 2020(r361718) +++ head/sys/dev/vt/vt_buf.cTue Jun 2 01:21:48 2020(r361719) @@ -433,17 +433,22 @@ vtbuf_do_clearhistory(struct vt_buf *vb) vtbuf_do_fill(vb, , VTBUF_SPACE_CHAR(ch)); } -void -vtbuf_init_early(struct vt_buf *vb) +static void +vtbuf_reset_scrollback(struct vt_buf *vb) { - vb->vb_flags |= VBF_CURSOR; vb->vb_roffset = 0; vb->vb_curroffset = 0; vb->vb_mark_start.tp_row = 0; vb->vb_mark_start.tp_col = 0; vb->vb_mark_end.tp_row = 0; vb->vb_mark_end.tp_col = 0; +} +void +vtbuf_init_early(struct vt_buf *vb) +{ + vb->vb_flags |= VBF_CURSOR; + vtbuf_reset_scrollback(vb); vtbuf_init_rows(vb); vtbuf_do_clearhistory(vb); vtbuf_make_undirty(vb); @@ -477,6 +482,8 @@ vtbuf_clearhistory(struct vt_buf *vb) { VTBUF_LOCK(vb); vtbuf_do_clearhistory(vb); + vtbuf_reset_scrollback(vb); + vb->vb_flags &= ~VBF_HISTORY_FULL; VTBUF_UNLOCK(vb); } Modified: head/sys/dev/vt/vt_core.c == --- head/sys/dev/vt/vt_core.c Tue Jun 2 01:04:49 2020(r361718) +++ head/sys/dev/vt/vt_core.c Tue Jun 2 01:21:48 2020(r361719) @@ -2332,6 +2332,16 @@ skip_thunk: return (0); case CONS_CLRHIST: vtbuf_clearhistory(>vd_curwindow->vw_buf); + /* +* Invalidate the entire visible window; it is not guaranteed +* that this operation will be immediately followed by a scroll +* event, so it would otherwise be possible for prior artifacts +* to remain visible. +*/ + VT_LOCK(vd); + vd->vd_flags |= VDF_INVALID; + VT_UNLOCK(vd); + vt_resume_flush_timer(vd->vd_curwindow, 0); return (0); case CONS_GET: /* XXX */ Modified: head/sys/kern/subr_terminal.c == --- head/sys/kern/subr_terminal.c Tue Jun 2 01:04:49 2020 (r361718) +++ head/sys/kern/subr_terminal.c Tue Jun 2 01:21:48 2020 (r361719) @@ -480,6 +480,16 @@ termtty_ioctl(struct tty *tp, u_long cmd, caddr_t data tty_unlock(tp); error = tm->tm_class->tc_ioctl(tm, cmd, data, td); tty_lock(tp); + if ((error == 0) && (cmd == CONS_CLRHIST)) { + /* +* Scrollback history has been successfully cleared, +* so reset the cursor position to the top left of the screen. +*/ + teken_pos_t p; + p.tp_row = 0; + p.tp_col = 0; + teken_set_cursor(>tm_emulator, ); + } return (error); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r361601 - head/sys/dev/vt
Author: jah Date: Thu May 28 21:22:30 2020 New Revision: 361601 URL: https://svnweb.freebsd.org/changeset/base/361601 Log: vt(4): Add support for `vidcontrol -C' Extract scrollback buffer initialization into a common routine, used both during vt(4) init and in handling the CONS_CLRHIST ioctl. PR: 224436 Reviewed by: emaste Differential Revision:https://reviews.freebsd.org/D24815 Modified: head/sys/dev/vt/vt.h head/sys/dev/vt/vt_buf.c head/sys/dev/vt/vt_core.c Modified: head/sys/dev/vt/vt.h == --- head/sys/dev/vt/vt.hThu May 28 21:19:44 2020(r361600) +++ head/sys/dev/vt/vt.hThu May 28 21:22:30 2020(r361601) @@ -231,6 +231,7 @@ void vtbuf_scroll_mode(struct vt_buf *vb, int yes); void vtbuf_dirty(struct vt_buf *vb, const term_rect_t *area); void vtbuf_undirty(struct vt_buf *, term_rect_t *); void vtbuf_sethistory_size(struct vt_buf *, unsigned int); +void vtbuf_clearhistory(struct vt_buf *); int vtbuf_iscursor(const struct vt_buf *vb, int row, int col); void vtbuf_cursor_visibility(struct vt_buf *, int); #ifndef SC_NO_CUTPASTE Modified: head/sys/dev/vt/vt_buf.c == --- head/sys/dev/vt/vt_buf.cThu May 28 21:19:44 2020(r361600) +++ head/sys/dev/vt/vt_buf.cThu May 28 21:22:30 2020(r361601) @@ -416,13 +416,26 @@ vtbuf_init_rows(struct vt_buf *vb) vb->vb_rows[r] = >vb_buffer[r * vb->vb_scr_size.tp_col]; } -void -vtbuf_init_early(struct vt_buf *vb) +static void +vtbuf_do_clearhistory(struct vt_buf *vb) { term_rect_t rect; const teken_attr_t *a; - term_char_t c; + term_char_t ch; + a = teken_get_curattr(>vb_terminal->tm_emulator); + ch = TCOLOR_FG(a->ta_fgcolor) | TCOLOR_BG(a->ta_bgcolor); + + rect.tr_begin.tp_row = rect.tr_begin.tp_col = 0; + rect.tr_end.tp_col = vb->vb_scr_size.tp_col; + rect.tr_end.tp_row = vb->vb_history_size; + + vtbuf_do_fill(vb, , VTBUF_SPACE_CHAR(ch)); +} + +void +vtbuf_init_early(struct vt_buf *vb) +{ vb->vb_flags |= VBF_CURSOR; vb->vb_roffset = 0; vb->vb_curroffset = 0; @@ -432,14 +445,7 @@ vtbuf_init_early(struct vt_buf *vb) vb->vb_mark_end.tp_col = 0; vtbuf_init_rows(vb); - rect.tr_begin.tp_row = rect.tr_begin.tp_col = 0; - rect.tr_end.tp_col = vb->vb_scr_size.tp_col; - rect.tr_end.tp_row = vb->vb_history_size; - - a = teken_get_curattr(>vb_terminal->tm_emulator); - c = TCOLOR_FG((term_char_t)a->ta_fgcolor) | - TCOLOR_BG((term_char_t)a->ta_bgcolor); - vtbuf_do_fill(vb, , VTBUF_SPACE_CHAR(c)); + vtbuf_do_clearhistory(vb); vtbuf_make_undirty(vb); if ((vb->vb_flags & VBF_MTX_INIT) == 0) { mtx_init(>vb_lock, "vtbuf", NULL, MTX_SPIN); @@ -464,6 +470,14 @@ vtbuf_init(struct vt_buf *vb, const term_pos_t *p) } vtbuf_init_early(vb); +} + +void +vtbuf_clearhistory(struct vt_buf *vb) +{ + VTBUF_LOCK(vb); + vtbuf_do_clearhistory(vb); + VTBUF_UNLOCK(vb); } void Modified: head/sys/dev/vt/vt_core.c == --- head/sys/dev/vt/vt_core.c Thu May 28 21:19:44 2020(r361600) +++ head/sys/dev/vt/vt_core.c Thu May 28 21:22:30 2020(r361601) @@ -2329,7 +2329,10 @@ skip_thunk: if (*(int *)data != vd->vd_curwindow->vw_buf.vb_history_size) vtbuf_sethistory_size(>vd_curwindow->vw_buf, *(int *)data); - return 0; + return (0); + case CONS_CLRHIST: + vtbuf_clearhistory(>vd_curwindow->vw_buf); + return (0); case CONS_GET: /* XXX */ *(int *)data = M_CG640x480; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r360368 - stable/12/usr.sbin/config
Author: jah Date: Mon Apr 27 05:35:26 2020 New Revision: 360368 URL: https://svnweb.freebsd.org/changeset/base/360368 Log: MFC r359815: config(8): use sbuf to manage line buffers Modified: stable/12/usr.sbin/config/main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/config/main.c == --- stable/12/usr.sbin/config/main.cMon Apr 27 05:27:39 2020 (r360367) +++ stable/12/usr.sbin/config/main.cMon Apr 27 05:35:26 2020 (r360368) @@ -113,6 +113,8 @@ struct hdr_list { struct hdr_list *h_next; } *htab; +static struct sbuf *line_buf = NULL; + /* * Config builds a set of files for building a UNIX * system given a description of the desired system. @@ -304,6 +306,29 @@ usage(void) exit(EX_USAGE); } +static void +init_line_buf(void) +{ + if (line_buf == NULL) { + line_buf = sbuf_new(NULL, NULL, 80, SBUF_AUTOEXTEND); + if (line_buf == NULL) { + errx(EXIT_FAILURE, "failed to allocate line buffer"); + } + } else { + sbuf_clear(line_buf); + } +} + +static char * +get_line_buf(void) +{ + if (sbuf_finish(line_buf) != 0) { + errx(EXIT_FAILURE, "failed to generate line buffer, " + "partial line = %s", sbuf_data(line_buf)); + } + return sbuf_data(line_buf); +} + /* * get_word * returns EOF on end of file @@ -313,11 +338,10 @@ usage(void) char * get_word(FILE *fp) { - static char line[160]; int ch; - char *cp; int escaped_nl = 0; + init_line_buf(); begin: while ((ch = getc(fp)) != EOF) if (ch != ' ' && ch != '\t') @@ -336,29 +360,20 @@ begin: else return (NULL); } - cp = line; - *cp++ = ch; + sbuf_putc(line_buf, ch); /* Negation operator is a word by itself. */ if (ch == '!') { - *cp = 0; - return (line); + return get_line_buf(); } - while ((ch = getc(fp)) != EOF && cp < line + sizeof(line)) { + while ((ch = getc(fp)) != EOF) { if (isspace(ch)) break; - *cp++ = ch; + sbuf_putc(line_buf, ch); } - if (cp >= line + sizeof(line)) { - line[sizeof(line) - 1] = '\0'; - fprintf(stderr, "config: attempted overflow, partial line: `%s'", - line); - exit(2); - } - *cp = 0; if (ch == EOF) return ((char *)EOF); (void) ungetc(ch, fp); - return (line); + return (get_line_buf()); } /* @@ -369,11 +384,10 @@ begin: char * get_quoted_word(FILE *fp) { - static char line[512]; int ch; - char *cp; int escaped_nl = 0; + init_line_buf(); begin: while ((ch = getc(fp)) != EOF) if (ch != ' ' && ch != '\t') @@ -392,7 +406,6 @@ begin: else return (NULL); } - cp = line; if (ch == '"' || ch == '\'') { int quote = ch; @@ -401,9 +414,8 @@ begin: if (ch == quote && !escaped_nl) break; if (ch == '\n' && !escaped_nl) { - *cp = 0; printf("config: missing quote reading `%s'\n", - line); + get_line_buf()); exit(2); } if (ch == '\\' && !escaped_nl) { @@ -411,38 +423,23 @@ begin: continue; } if (ch != quote && escaped_nl) - *cp++ = '\\'; - if (cp >= line + sizeof(line)) { - line[sizeof(line) - 1] = '\0'; - printf( - "config: line buffer overflow reading partial line `%s'\n", - line); - exit(2); - } - *cp++ = ch; + sbuf_putc(line_buf, '\\'); + sbuf_putc(line_buf, ch); escaped_nl = 0; } } else { - *cp++ = ch; - while ((ch = getc(fp)) != EOF && cp < line + sizeof(line)) { + sbuf_putc(line_buf, ch); + while ((ch = getc(fp)) != EOF) { if (isspace(ch)) break; - *cp++ = ch; + sbuf_putc(line_buf, ch); } - if (cp
svn commit: r359815 - head/usr.sbin/config
Author: jah Date: Sun Apr 12 02:42:42 2020 New Revision: 359815 URL: https://svnweb.freebsd.org/changeset/base/359815 Log: config(8): use sbuf to manage line buffers PR: 245476 Reported by: kevans Reviewed by: imp, kevans MFC after:1 week Differential Revision:https://reviews.freebsd.org/D24373 Modified: head/usr.sbin/config/main.c Modified: head/usr.sbin/config/main.c == --- head/usr.sbin/config/main.c Sun Apr 12 01:03:13 2020(r359814) +++ head/usr.sbin/config/main.c Sun Apr 12 02:42:42 2020(r359815) @@ -113,6 +113,8 @@ struct hdr_list { struct hdr_list *h_next; } *htab; +static struct sbuf *line_buf = NULL; + /* * Config builds a set of files for building a UNIX * system given a description of the desired system. @@ -313,6 +315,29 @@ usage(void) exit(EX_USAGE); } +static void +init_line_buf(void) +{ + if (line_buf == NULL) { + line_buf = sbuf_new(NULL, NULL, 80, SBUF_AUTOEXTEND); + if (line_buf == NULL) { + errx(EXIT_FAILURE, "failed to allocate line buffer"); + } + } else { + sbuf_clear(line_buf); + } +} + +static char * +get_line_buf(void) +{ + if (sbuf_finish(line_buf) != 0) { + errx(EXIT_FAILURE, "failed to generate line buffer, " + "partial line = %s", sbuf_data(line_buf)); + } + return sbuf_data(line_buf); +} + /* * get_word * returns EOF on end of file @@ -322,11 +347,10 @@ usage(void) char * get_word(FILE *fp) { - static char line[160]; int ch; - char *cp; int escaped_nl = 0; + init_line_buf(); begin: while ((ch = getc(fp)) != EOF) if (ch != ' ' && ch != '\t') @@ -345,29 +369,20 @@ begin: else return (NULL); } - cp = line; - *cp++ = ch; + sbuf_putc(line_buf, ch); /* Negation operator is a word by itself. */ if (ch == '!') { - *cp = 0; - return (line); + return get_line_buf(); } - while ((ch = getc(fp)) != EOF && cp < line + sizeof(line)) { + while ((ch = getc(fp)) != EOF) { if (isspace(ch)) break; - *cp++ = ch; + sbuf_putc(line_buf, ch); } - if (cp >= line + sizeof(line)) { - line[sizeof(line) - 1] = '\0'; - fprintf(stderr, "config: attempted overflow, partial line: `%s'", - line); - exit(2); - } - *cp = 0; if (ch == EOF) return ((char *)EOF); (void) ungetc(ch, fp); - return (line); + return (get_line_buf()); } /* @@ -378,11 +393,10 @@ begin: char * get_quoted_word(FILE *fp) { - static char line[512]; int ch; - char *cp; int escaped_nl = 0; + init_line_buf(); begin: while ((ch = getc(fp)) != EOF) if (ch != ' ' && ch != '\t') @@ -401,7 +415,6 @@ begin: else return (NULL); } - cp = line; if (ch == '"' || ch == '\'') { int quote = ch; @@ -410,9 +423,8 @@ begin: if (ch == quote && !escaped_nl) break; if (ch == '\n' && !escaped_nl) { - *cp = 0; printf("config: missing quote reading `%s'\n", - line); + get_line_buf()); exit(2); } if (ch == '\\' && !escaped_nl) { @@ -420,38 +432,23 @@ begin: continue; } if (ch != quote && escaped_nl) - *cp++ = '\\'; - if (cp >= line + sizeof(line)) { - line[sizeof(line) - 1] = '\0'; - printf( - "config: line buffer overflow reading partial line `%s'\n", - line); - exit(2); - } - *cp++ = ch; + sbuf_putc(line_buf, '\\'); + sbuf_putc(line_buf, ch); escaped_nl = 0; } } else { - *cp++ = ch; - while ((ch = getc(fp)) != EOF && cp < line + sizeof(line)) { + sbuf_putc(line_buf, ch); + while ((ch = getc(fp)) != EOF) { if (isspace(ch)) break; - *cp++ = ch; +
svn commit: r359794 - stable/12/sys/kern
Author: jah Date: Sat Apr 11 05:12:38 2020 New Revision: 359794 URL: https://svnweb.freebsd.org/changeset/base/359794 Log: MFC r359501: deadlkres: include thread name in panic messages Modified: stable/12/sys/kern/kern_clock.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/kern_clock.c == --- stable/12/sys/kern/kern_clock.c Sat Apr 11 00:17:55 2020 (r359793) +++ stable/12/sys/kern/kern_clock.c Sat Apr 11 05:12:38 2020 (r359794) @@ -204,8 +204,9 @@ deadlres_td_on_lock(struct proc *p, struct thread *td, * Accordingly with provided thresholds, this thread is stuck * for too long on a turnstile. */ - panic("%s: possible deadlock detected for %p, " - "blocked for %d ticks\n", __func__, td, tticks); + panic("%s: possible deadlock detected for %p (%s), " + "blocked for %d ticks\n", __func__, + td, sched_tdname(td), tticks); } static void @@ -238,8 +239,9 @@ deadlres_td_sleep_q(struct proc *p, struct thread *td, if (!strcmp(blessed[i], td->td_wmesg)) return; - panic("%s: possible deadlock detected for %p, " - "blocked for %d ticks\n", __func__, td, tticks); + panic("%s: possible deadlock detected for %p (%s), " + "blocked for %d ticks\n", __func__, + td, sched_tdname(td), tticks); } } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359628 - head/sys/security/mac
Author: jah Date: Sat Apr 4 04:03:10 2020 New Revision: 359628 URL: https://svnweb.freebsd.org/changeset/base/359628 Log: mac_policy: Remove mac_policy_sx This lock was made unnecessary by the addition of mac_policy_rms in r356120. Reviewed by: mjg, kib Differential Revision:https://reviews.freebsd.org/D24283 Modified: head/sys/security/mac/mac_framework.c Modified: head/sys/security/mac/mac_framework.c == --- head/sys/security/mac/mac_framework.c Sat Apr 4 00:56:56 2020 (r359627) +++ head/sys/security/mac/mac_framework.c Sat Apr 4 04:03:10 2020 (r359628) @@ -184,7 +184,7 @@ MALLOC_DEFINE(M_MACTEMP, "mactemp", "MAC temporary lab * The dynamic policy list is protected by two locks: modifying the list * requires both locks to be held exclusively. One of the locks, * mac_policy_rm, is acquired over policy entry points that will never sleep; - * the other, mac_policy_sx, is acquire over policy entry points that may + * the other, mac_policy_rms, is acquired over policy entry points that may * sleep. The former category will be used when kernel locks may be held * over calls to the MAC Framework, during network processing in ithreads, * etc. The latter will tend to involve potentially blocking memory @@ -192,8 +192,7 @@ MALLOC_DEFINE(M_MACTEMP, "mactemp", "MAC temporary lab */ #ifndef MAC_STATIC static struct rmlock mac_policy_rm;/* Non-sleeping entry points. */ -static struct sx mac_policy_sx;/* Sleeping entry points. */ -static struct rmslock mac_policy_rms; +static struct rmslock mac_policy_rms; /* Sleeping entry points. */ #endif struct mac_policy_list_head mac_policy_list; @@ -266,7 +265,6 @@ mac_policy_xlock(void) if (!mac_late) return; - sx_xlock(_policy_sx); rms_wlock(_policy_rms); rm_wlock(_policy_rm); #endif @@ -282,7 +280,6 @@ mac_policy_xunlock(void) rm_wunlock(_policy_rm); rms_wunlock(_policy_rms); - sx_xunlock(_policy_sx); #endif } @@ -294,8 +291,7 @@ mac_policy_xlock_assert(void) if (!mac_late) return; - /* XXXRW: rm_assert(_policy_rm, RA_WLOCKED); */ - sx_assert(_policy_sx, SA_XLOCKED); + rm_assert(_policy_rm, RA_WLOCKED); #endif } @@ -313,7 +309,6 @@ mac_init(void) #ifndef MAC_STATIC rm_init_flags(_policy_rm, "mac_policy_rm", RM_NOWITNESS | RM_RECURSE); - sx_init_flags(_policy_sx, "mac_policy_sx", SX_NOWITNESS); rms_init(_policy_rms, "mac_policy_rms"); #endif } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r359501 - head/sys/kern
Author: jah Date: Wed Apr 1 04:51:39 2020 New Revision: 359501 URL: https://svnweb.freebsd.org/changeset/base/359501 Log: deadlkres: include thread name in panic messages Reviewed by: markj MFC after:1 week Differential Revision:https://reviews.freebsd.org/D24235 Modified: head/sys/kern/kern_clock.c Modified: head/sys/kern/kern_clock.c == --- head/sys/kern/kern_clock.c Wed Apr 1 03:27:47 2020(r359500) +++ head/sys/kern/kern_clock.c Wed Apr 1 04:51:39 2020(r359501) @@ -205,8 +205,9 @@ deadlres_td_on_lock(struct proc *p, struct thread *td, * Accordingly with provided thresholds, this thread is stuck * for too long on a turnstile. */ - panic("%s: possible deadlock detected for %p, " - "blocked for %d ticks\n", __func__, td, tticks); + panic("%s: possible deadlock detected for %p (%s), " + "blocked for %d ticks\n", __func__, + td, sched_tdname(td), tticks); } static void @@ -239,8 +240,9 @@ deadlres_td_sleep_q(struct proc *p, struct thread *td, if (!strcmp(blessed[i], td->td_wmesg)) return; - panic("%s: possible deadlock detected for %p, " - "blocked for %d ticks\n", __func__, td, tticks); + panic("%s: possible deadlock detected for %p (%s), " + "blocked for %d ticks\n", __func__, + td, sched_tdname(td), tticks); } } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r357110 - in head/sys: kern sys
Author: jah Date: Sat Jan 25 08:57:26 2020 New Revision: 357110 URL: https://svnweb.freebsd.org/changeset/base/357110 Log: Implement cycle-detecting garbage collector for AF_UNIX sockets The existing AF_UNIX socket garbage collector destroys any socket which may potentially be in a cycle, as indicated by its file reference count being equal to its enqueue count. However, this can produce false positives for in-flight sockets which aren't part of a cycle but are part of one or more SCM_RIGHTS mssages and which have been closed on the sending side. If the garbage collector happens to run at exactly the wrong time, destruction of these sockets will render them unusable on the receiving side, such that no previously-written data may be read. This change rewrites the garbage collector to precisely detect cycles: 1. The existing check of msgcount==f_count is still used to determine whether the socket is potentially in a cycle. 2. The socket is now placed on a local "dead list", which is used to reduce iteration time (and therefore contention on the global unp_link_rwlock). 3. The first pass through the dead list removes each potentially-dead socket's outgoing references from the graph of potentially-dead sockets, using a gc-specific copy of the original reference count. 4. The second series of passes through the dead list removes from the list any socket whose remaining gc refcount is non-zero, as this indicates the socket is actually accessible outside of any possible cycle. Iteration is repeated until no further sockets are removed from the dead list. 5. Sockets remaining in the dead list are destroyed as before. PR: 227285 Submitted by: jan.kokemuel...@gmail.com (prior version) Reviewed by: markj Differential Revision:https://reviews.freebsd.org/D23142 Modified: head/sys/kern/uipc_usrreq.c head/sys/sys/unpcb.h Modified: head/sys/kern/uipc_usrreq.c == --- head/sys/kern/uipc_usrreq.c Sat Jan 25 05:52:31 2020(r357109) +++ head/sys/kern/uipc_usrreq.c Sat Jan 25 08:57:26 2020(r357110) @@ -260,7 +260,7 @@ static struct mtx unp_defers_lock; #defineUNP_LINK_LOCK_INIT()rw_init(_link_rwlock, \ "unp_link_rwlock") -#defineUNP_LINK_LOCK_ASSERT() rw_assert(_link_rwlock, \ +#defineUNP_LINK_LOCK_ASSERT() rw_assert(_link_rwlock, \ RA_LOCKED) #defineUNP_LINK_UNLOCK_ASSERT()rw_assert(_link_rwlock, \ RA_UNLOCKED) @@ -778,6 +778,8 @@ uipc_detach(struct socket *so) UNP_LINK_WLOCK(); LIST_REMOVE(unp, unp_link); + if (unp->unp_gcflag & UNPGC_DEAD) + LIST_REMOVE(unp, unp_dead); unp->unp_gencnt = ++unp_gencnt; --unp_count; UNP_LINK_WUNLOCK(); @@ -2481,50 +2483,61 @@ unp_externalize_fp(struct file *fp) * synchronization. */ static int unp_marked; -static int unp_unreachable; static void -unp_accessable(struct filedescent **fdep, int fdcount) +unp_remove_dead_ref(struct filedescent **fdep, int fdcount) { struct unpcb *unp; struct file *fp; int i; + /* +* This function can only be called from the gc task. +*/ + KASSERT(taskqueue_member(taskqueue_thread, curthread) != 0, + ("%s: not on gc callout", __func__)); + UNP_LINK_LOCK_ASSERT(); + for (i = 0; i < fdcount; i++) { fp = fdep[i]->fde_file; if ((unp = fptounp(fp)) == NULL) continue; - if (unp->unp_gcflag & UNPGC_REF) + if ((unp->unp_gcflag & UNPGC_DEAD) == 0) continue; - unp->unp_gcflag &= ~UNPGC_DEAD; - unp->unp_gcflag |= UNPGC_REF; - unp_marked++; + unp->unp_gcrefs--; } } static void -unp_gc_process(struct unpcb *unp) +unp_restore_undead_ref(struct filedescent **fdep, int fdcount) { - struct socket *so, *soa; + struct unpcb *unp; struct file *fp; + int i; - /* Already processed. */ - if (unp->unp_gcflag & UNPGC_SCANNED) - return; - fp = unp->unp_file; - /* -* Check for a socket potentially in a cycle. It must be in a -* queue as indicated by msgcount, and this must equal the file -* reference count. Note that when msgcount is 0 the file is NULL. +* This function can only be called from the gc task. */ - if ((unp->unp_gcflag & UNPGC_REF) == 0 && fp && - unp->unp_msgcount != 0 && fp->f_count == unp->unp_msgcount) { - unp->unp_gcflag |= UNPGC_DEAD; - unp_unreachable++; -
svn commit: r352434 - in head/sys/mips: include mips
Author: jah Date: Tue Sep 17 03:39:31 2019 New Revision: 352434 URL: https://svnweb.freebsd.org/changeset/base/352434 Log: mips: move support for temporary mappings above KSEG0 to per-CPU data This is derived from similar work done in r310481 for i386 and r312610 for armv6/armv7. Additionally, use a critical section to keep the thread pinned for per-CPU operations instead of completely disabling local interrupts. No objections from: adrian, jmallett, imp Differential Revision:https://reviews.freebsd.org/D18593 Modified: head/sys/mips/include/pcpu.h head/sys/mips/mips/pmap.c Modified: head/sys/mips/include/pcpu.h == --- head/sys/mips/include/pcpu.hTue Sep 17 02:53:59 2019 (r352433) +++ head/sys/mips/include/pcpu.hTue Sep 17 03:39:31 2019 (r352434) @@ -51,7 +51,13 @@ #else #definePCPU_MD_MIPS32_FIELDS \ PCPU_MD_COMMON_FIELDS \ - char__pad[125] + pt_entry_t *pc_cmap1_ptep; /* PTE for copy window 1 KVA */ \ + pt_entry_t *pc_cmap2_ptep; /* PTE for copy window 2 KVA */ \ + vm_offset_t pc_cmap1_addr; /* KVA page for copy window 1 */ \ + vm_offset_t pc_cmap2_addr; /* KVA page for copy window 2 */ \ + vm_offset_t pc_qmap_addr; /* KVA page for temporary mappings */ \ + pt_entry_t *pc_qmap_ptep; /* PTE for temporary mapping KVA */ \ + char__pad[101] #endif #ifdef __mips_n64 Modified: head/sys/mips/mips/pmap.c == --- head/sys/mips/mips/pmap.c Tue Sep 17 02:53:59 2019(r352433) +++ head/sys/mips/mips/pmap.c Tue Sep 17 03:39:31 2019(r352434) @@ -138,6 +138,8 @@ pd_entry_t *kernel_segmap; vm_offset_t virtual_avail; /* VA of first avail page (after kernel bss) */ vm_offset_t virtual_end; /* VA of last avail page (end of kernel AS) */ +static int need_local_mappings; + static int nkpt; unsigned pmap_max_asid;/* max ASID supported by the system */ @@ -187,104 +189,96 @@ static void pmap_invalidate_range_action(void *arg); static void pmap_update_page_action(void *arg); #ifndef __mips_n64 + +static vm_offset_t crashdumpva; + /* - * This structure is for high memory (memory above 512Meg in 32 bit) support. + * These functions are for high memory (memory above 512Meg in 32 bit) support. * The highmem area does not have a KSEG0 mapping, and we need a mechanism to * do temporary per-CPU mappings for pmap_zero_page, pmap_copy_page etc. * * At bootup, we reserve 2 virtual pages per CPU for mapping highmem pages. To * access a highmem physical address on a CPU, we map the physical address to - * the reserved virtual address for the CPU in the kernel pagetable. This is - * done with interrupts disabled(although a spinlock and sched_pin would be - * sufficient). + * the reserved virtual address for the CPU in the kernel pagetable. */ -struct local_sysmaps { - vm_offset_t base; - uint32_tsaved_intr; - uint16_tvalid1, valid2; -}; -static struct local_sysmaps sysmap_lmem[MAXCPU]; +static void +pmap_init_reserved_pages(void) +{ + struct pcpu *pc; + vm_offset_t pages; + int i; + + if (need_local_mappings == 0) + return; + + CPU_FOREACH(i) { + pc = pcpu_find(i); + /* +* Skip if the mapping has already been initialized, +* i.e. this is the BSP. +*/ + if (pc->pc_cmap1_addr != 0) + continue; + pages = kva_alloc(PAGE_SIZE * 3); + if (pages == 0) + panic("%s: unable to allocate KVA", __func__); + pc->pc_cmap1_ptep = pmap_pte(kernel_pmap, pages); + pc->pc_cmap2_ptep = pmap_pte(kernel_pmap, pages + PAGE_SIZE); + pc->pc_qmap_ptep = + pmap_pte(kernel_pmap, pages + (PAGE_SIZE * 2)); + pc->pc_cmap1_addr = pages; + pc->pc_cmap2_addr = pages + PAGE_SIZE; + pc->pc_qmap_addr = pages + (PAGE_SIZE * 2); + } +} +SYSINIT(rpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_reserved_pages, NULL); + static __inline void pmap_alloc_lmem_map(void) { - int i; - - for (i = 0; i < MAXCPU; i++) { - sysmap_lmem[i].base = virtual_avail; - virtual_avail += PAGE_SIZE * 2; - sysmap_lmem[i].valid1 = sysmap_lmem[i].valid2 = 0; - } + PCPU_SET(cmap1_addr, virtual_avail); + PCPU_SET(cmap2_addr, virtual_avail + PAGE_SIZE); + PCPU_SET(cmap1_ptep, pmap_pte(kernel_pmap, virtual_avail)); +
svn commit: r346019 - stable/12/sys/compat/freebsd32
Author: jah Date: Sun Apr 7 19:02:33 2019 New Revision: 346019 URL: https://svnweb.freebsd.org/changeset/base/346019 Log: MFC r345741: freebsd32: fix padding of computed control message length for recvmsg() Each control message region must be aligned on a 4-byte boundary on 32-bit architectures. The 32-bit compat shim for recvmsg() gets the actual layout right, but doesn't pad the payload length when computing msg_controllen for the output message header. If a control message contains an unaligned payload, such as the 1-byte TTL field in the example attached to PR 236737, this can produce control message payload boundaries that extend beyond the boundary reported by msg_controllen. PR: 236737 Modified: stable/12/sys/compat/freebsd32/freebsd32_misc.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/compat/freebsd32/freebsd32_misc.c == --- stable/12/sys/compat/freebsd32/freebsd32_misc.c Sun Apr 7 18:39:55 2019(r346018) +++ stable/12/sys/compat/freebsd32/freebsd32_misc.c Sun Apr 7 19:02:33 2019(r346019) @@ -1183,8 +1183,8 @@ freebsd32_copy_msg_out(struct msghdr *msg, struct mbuf cm = NULL; } - msg->msg_controllen += FREEBSD32_ALIGN(sizeof(*cm)) + - datalen_out; + msg->msg_controllen += + FREEBSD32_CMSG_SPACE(datalen_out); } } if (len == 0 && m != NULL) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r346020 - stable/11/sys/compat/freebsd32
Author: jah Date: Sun Apr 7 19:08:07 2019 New Revision: 346020 URL: https://svnweb.freebsd.org/changeset/base/346020 Log: MFC r345741: freebsd32: fix padding of computed control message length for recvmsg() Each control message region must be aligned on a 4-byte boundary on 32-bit architectures. The 32-bit compat shim for recvmsg() gets the actual layout right, but doesn't pad the payload length when computing msg_controllen for the output message header. If a control message contains an unaligned payload, such as the 1-byte TTL field in the example attached to PR 236737, this can produce control message payload boundaries that extend beyond the boundary reported by msg_controllen. PR: 236737 Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c == --- stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Apr 7 19:02:33 2019(r346019) +++ stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Apr 7 19:08:07 2019(r346020) @@ -1035,8 +1035,8 @@ freebsd32_copy_msg_out(struct msghdr *msg, struct mbuf cm = NULL; } - msg->msg_controllen += FREEBSD32_ALIGN(sizeof(*cm)) + - datalen_out; + msg->msg_controllen += + FREEBSD32_CMSG_SPACE(datalen_out); } } if (len == 0 && m != NULL) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r345741 - head/sys/compat/freebsd32
Author: jah Date: Sat Mar 30 23:43:58 2019 New Revision: 345741 URL: https://svnweb.freebsd.org/changeset/base/345741 Log: freebsd32: fix padding of computed control message length for recvmsg() Each control message region must be aligned on a 4-byte boundary on 32-bit architectures. The 32-bit compat shim for recvmsg() gets the actual layout right, but doesn't pad the payload length when computing msg_controllen for the output message header. If a control message contains an unaligned payload, such as the 1-byte TTL field in the example attached to PR 236737, this can produce control message payload boundaries that extend beyond the boundary reported by msg_controllen. PR: 236737 Reported by: Yuval Pavel Zholkover Reviewed by: markj MFC after:1 week Differential Revision:https://reviews.freebsd.org/D19768 Modified: head/sys/compat/freebsd32/freebsd32_misc.c Modified: head/sys/compat/freebsd32/freebsd32_misc.c == --- head/sys/compat/freebsd32/freebsd32_misc.c Sat Mar 30 21:04:08 2019 (r345740) +++ head/sys/compat/freebsd32/freebsd32_misc.c Sat Mar 30 23:43:58 2019 (r345741) @@ -1160,8 +1160,8 @@ freebsd32_copy_msg_out(struct msghdr *msg, struct mbuf cm = NULL; } - msg->msg_controllen += FREEBSD32_ALIGN(sizeof(*cm)) + - datalen_out; + msg->msg_controllen += + FREEBSD32_CMSG_SPACE(datalen_out); } } if (len == 0 && m != NULL) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r346020 - stable/11/sys/compat/freebsd32
Author: jah Date: Sun Apr 7 19:08:07 2019 New Revision: 346020 URL: https://svnweb.freebsd.org/changeset/base/346020 Log: MFC r345741: freebsd32: fix padding of computed control message length for recvmsg() Each control message region must be aligned on a 4-byte boundary on 32-bit architectures. The 32-bit compat shim for recvmsg() gets the actual layout right, but doesn't pad the payload length when computing msg_controllen for the output message header. If a control message contains an unaligned payload, such as the 1-byte TTL field in the example attached to PR 236737, this can produce control message payload boundaries that extend beyond the boundary reported by msg_controllen. PR: 236737 Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/freebsd32/freebsd32_misc.c == --- stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Apr 7 19:02:33 2019(r346019) +++ stable/11/sys/compat/freebsd32/freebsd32_misc.c Sun Apr 7 19:08:07 2019(r346020) @@ -1035,8 +1035,8 @@ freebsd32_copy_msg_out(struct msghdr *msg, struct mbuf cm = NULL; } - msg->msg_controllen += FREEBSD32_ALIGN(sizeof(*cm)) + - datalen_out; + msg->msg_controllen += + FREEBSD32_CMSG_SPACE(datalen_out); } } if (len == 0 && m != NULL) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r346019 - stable/12/sys/compat/freebsd32
Author: jah Date: Sun Apr 7 19:02:33 2019 New Revision: 346019 URL: https://svnweb.freebsd.org/changeset/base/346019 Log: MFC r345741: freebsd32: fix padding of computed control message length for recvmsg() Each control message region must be aligned on a 4-byte boundary on 32-bit architectures. The 32-bit compat shim for recvmsg() gets the actual layout right, but doesn't pad the payload length when computing msg_controllen for the output message header. If a control message contains an unaligned payload, such as the 1-byte TTL field in the example attached to PR 236737, this can produce control message payload boundaries that extend beyond the boundary reported by msg_controllen. PR: 236737 Modified: stable/12/sys/compat/freebsd32/freebsd32_misc.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/compat/freebsd32/freebsd32_misc.c == --- stable/12/sys/compat/freebsd32/freebsd32_misc.c Sun Apr 7 18:39:55 2019(r346018) +++ stable/12/sys/compat/freebsd32/freebsd32_misc.c Sun Apr 7 19:02:33 2019(r346019) @@ -1183,8 +1183,8 @@ freebsd32_copy_msg_out(struct msghdr *msg, struct mbuf cm = NULL; } - msg->msg_controllen += FREEBSD32_ALIGN(sizeof(*cm)) + - datalen_out; + msg->msg_controllen += + FREEBSD32_CMSG_SPACE(datalen_out); } } if (len == 0 && m != NULL) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r345741 - head/sys/compat/freebsd32
Author: jah Date: Sat Mar 30 23:43:58 2019 New Revision: 345741 URL: https://svnweb.freebsd.org/changeset/base/345741 Log: freebsd32: fix padding of computed control message length for recvmsg() Each control message region must be aligned on a 4-byte boundary on 32-bit architectures. The 32-bit compat shim for recvmsg() gets the actual layout right, but doesn't pad the payload length when computing msg_controllen for the output message header. If a control message contains an unaligned payload, such as the 1-byte TTL field in the example attached to PR 236737, this can produce control message payload boundaries that extend beyond the boundary reported by msg_controllen. PR: 236737 Reported by: Yuval Pavel Zholkover Reviewed by: markj MFC after:1 week Differential Revision:https://reviews.freebsd.org/D19768 Modified: head/sys/compat/freebsd32/freebsd32_misc.c Modified: head/sys/compat/freebsd32/freebsd32_misc.c == --- head/sys/compat/freebsd32/freebsd32_misc.c Sat Mar 30 21:04:08 2019 (r345740) +++ head/sys/compat/freebsd32/freebsd32_misc.c Sat Mar 30 23:43:58 2019 (r345741) @@ -1160,8 +1160,8 @@ freebsd32_copy_msg_out(struct msghdr *msg, struct mbuf cm = NULL; } - msg->msg_controllen += FREEBSD32_ALIGN(sizeof(*cm)) + - datalen_out; + msg->msg_controllen += + FREEBSD32_CMSG_SPACE(datalen_out); } } if (len == 0 && m != NULL) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r345240 - stable/12/sys/ufs/ffs
Author: jah Date: Sun Mar 17 06:05:19 2019 New Revision: 345240 URL: https://svnweb.freebsd.org/changeset/base/345240 Log: MFC r344562: FFS: allow sendfile(2) to work with block sizes greater than the page size Implement ffs_getpages_async(), which when possible calls the asynchronous flavor of the generic pager's getpages function. When the underlying block size is larger than the system page size, however, it will invoke the (synchronous) buffer cache pager, followed by a call to the client completion routine. This retains true asynchronous completion in the most common (block size <= page size) case, which is important for the performance of the new sendfile(2). The behavior in the larger block size case mirrors the default implementation of VOP_GETPAGES_ASYNC, which most other filesystems use anyway as they do not override the getpages_async method. PR: 235708 Modified: stable/12/sys/ufs/ffs/ffs_vnops.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/ufs/ffs/ffs_vnops.c == --- stable/12/sys/ufs/ffs/ffs_vnops.c Sun Mar 17 04:33:17 2019 (r345239) +++ stable/12/sys/ufs/ffs/ffs_vnops.c Sun Mar 17 06:05:19 2019 (r345240) @@ -111,6 +111,7 @@ extern int ffs_rawread(struct vnode *vp, struct uio *u static vop_fdatasync_t ffs_fdatasync; static vop_fsync_t ffs_fsync; static vop_getpages_t ffs_getpages; +static vop_getpages_async_tffs_getpages_async; static vop_lock1_t ffs_lock; static vop_read_t ffs_read; static vop_write_t ffs_write; @@ -132,7 +133,7 @@ struct vop_vector ffs_vnodeops1 = { .vop_fsync =ffs_fsync, .vop_fdatasync =ffs_fdatasync, .vop_getpages = ffs_getpages, - .vop_getpages_async = vnode_pager_local_getpages_async, + .vop_getpages_async = ffs_getpages_async, .vop_lock1 =ffs_lock, .vop_read = ffs_read, .vop_reallocblks = ffs_reallocblks, @@ -154,7 +155,7 @@ struct vop_vector ffs_vnodeops2 = { .vop_fsync =ffs_fsync, .vop_fdatasync =ffs_fdatasync, .vop_getpages = ffs_getpages, - .vop_getpages_async = vnode_pager_local_getpages_async, + .vop_getpages_async = ffs_getpages_async, .vop_lock1 =ffs_lock, .vop_read = ffs_read, .vop_reallocblks = ffs_reallocblks, @@ -1742,3 +1743,25 @@ ffs_getpages(struct vop_getpages_args *ap) return (vfs_bio_getpages(vp, ap->a_m, ap->a_count, ap->a_rbehind, ap->a_rahead, ffs_gbp_getblkno, ffs_gbp_getblksz)); } + +static int +ffs_getpages_async(struct vop_getpages_async_args *ap) +{ + struct vnode *vp; + struct ufsmount *um; + int error; + + vp = ap->a_vp; + um = VFSTOUFS(vp->v_mount); + + if (um->um_devvp->v_bufobj.bo_bsize <= PAGE_SIZE) + return (vnode_pager_generic_getpages(vp, ap->a_m, ap->a_count, + ap->a_rbehind, ap->a_rahead, ap->a_iodone, ap->a_arg)); + + error = vfs_bio_getpages(vp, ap->a_m, ap->a_count, ap->a_rbehind, + ap->a_rahead, ffs_gbp_getblkno, ffs_gbp_getblksz); + ap->a_iodone(ap->a_arg, ap->a_m, ap->a_count, error); + + return (error); +} + ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r344792 - stable/12/sys/vm
Author: jah Date: Tue Mar 5 08:33:14 2019 New Revision: 344792 URL: https://svnweb.freebsd.org/changeset/base/344792 Log: MFC r344561: Fix incorrect assertion in vnode_pager_generic_getpages() Modified: stable/12/sys/vm/vnode_pager.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/vm/vnode_pager.c == --- stable/12/sys/vm/vnode_pager.c Tue Mar 5 04:16:50 2019 (r344791) +++ stable/12/sys/vm/vnode_pager.c Tue Mar 5 08:33:14 2019 (r344792) @@ -774,7 +774,7 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page KASSERT(foff < object->un_pager.vnp.vnp_size, ("%s: page %p offset beyond vp %p size", __func__, m[0], vp)); - KASSERT(count <= sizeof(bp->b_pages), + KASSERT(count <= nitems(bp->b_pages), ("%s: requested %d pages", __func__, count)); /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r344562 - head/sys/ufs/ffs
Author: jah Date: Tue Feb 26 04:56:10 2019 New Revision: 344562 URL: https://svnweb.freebsd.org/changeset/base/344562 Log: FFS: allow sendfile(2) to work with block sizes greater than the page size Implement ffs_getpages_async(), which when possible calls the asynchronous flavor of the generic pager's getpages function. When the underlying block size is larger than the system page size, however, it will invoke the (synchronous) buffer cache pager, followed by a call to the client completion routine. This retains true asynchronous completion in the most common (block size <= page size) case, which is important for the performance of the new sendfile(2). The behavior in the larger block size case mirrors the default implementation of VOP_GETPAGES_ASYNC, which most other filesystems use anyway as they do not override the getpages_async method. PR: 235708 Reported by: pho Reviewed by: kib, glebius MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D19340 Modified: head/sys/ufs/ffs/ffs_vnops.c Modified: head/sys/ufs/ffs/ffs_vnops.c == --- head/sys/ufs/ffs/ffs_vnops.cTue Feb 26 04:50:46 2019 (r344561) +++ head/sys/ufs/ffs/ffs_vnops.cTue Feb 26 04:56:10 2019 (r344562) @@ -111,6 +111,7 @@ extern int ffs_rawread(struct vnode *vp, struct uio *u static vop_fdatasync_t ffs_fdatasync; static vop_fsync_t ffs_fsync; static vop_getpages_t ffs_getpages; +static vop_getpages_async_tffs_getpages_async; static vop_lock1_t ffs_lock; static vop_read_t ffs_read; static vop_write_t ffs_write; @@ -132,7 +133,7 @@ struct vop_vector ffs_vnodeops1 = { .vop_fsync =ffs_fsync, .vop_fdatasync =ffs_fdatasync, .vop_getpages = ffs_getpages, - .vop_getpages_async = vnode_pager_local_getpages_async, + .vop_getpages_async = ffs_getpages_async, .vop_lock1 =ffs_lock, .vop_read = ffs_read, .vop_reallocblks = ffs_reallocblks, @@ -154,7 +155,7 @@ struct vop_vector ffs_vnodeops2 = { .vop_fsync =ffs_fsync, .vop_fdatasync =ffs_fdatasync, .vop_getpages = ffs_getpages, - .vop_getpages_async = vnode_pager_local_getpages_async, + .vop_getpages_async = ffs_getpages_async, .vop_lock1 =ffs_lock, .vop_read = ffs_read, .vop_reallocblks = ffs_reallocblks, @@ -1742,3 +1743,25 @@ ffs_getpages(struct vop_getpages_args *ap) return (vfs_bio_getpages(vp, ap->a_m, ap->a_count, ap->a_rbehind, ap->a_rahead, ffs_gbp_getblkno, ffs_gbp_getblksz)); } + +static int +ffs_getpages_async(struct vop_getpages_async_args *ap) +{ + struct vnode *vp; + struct ufsmount *um; + int error; + + vp = ap->a_vp; + um = VFSTOUFS(vp->v_mount); + + if (um->um_devvp->v_bufobj.bo_bsize <= PAGE_SIZE) + return (vnode_pager_generic_getpages(vp, ap->a_m, ap->a_count, + ap->a_rbehind, ap->a_rahead, ap->a_iodone, ap->a_arg)); + + error = vfs_bio_getpages(vp, ap->a_m, ap->a_count, ap->a_rbehind, + ap->a_rahead, ffs_gbp_getblkno, ffs_gbp_getblksz); + ap->a_iodone(ap->a_arg, ap->a_m, ap->a_count, error); + + return (error); +} + ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r344561 - head/sys/vm
Author: jah Date: Tue Feb 26 04:50:46 2019 New Revision: 344561 URL: https://svnweb.freebsd.org/changeset/base/344561 Log: Fix incorrect assertion in vnode_pager_generic_getpages() Reviewed by: kib, glebius MFC after:1 week Modified: head/sys/vm/vnode_pager.c Modified: head/sys/vm/vnode_pager.c == --- head/sys/vm/vnode_pager.c Tue Feb 26 03:37:12 2019(r344560) +++ head/sys/vm/vnode_pager.c Tue Feb 26 04:50:46 2019(r344561) @@ -793,7 +793,7 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page KASSERT(foff < object->un_pager.vnp.vnp_size, ("%s: page %p offset beyond vp %p size", __func__, m[0], vp)); - KASSERT(count <= sizeof(bp->b_pages), + KASSERT(count <= nitems(bp->b_pages), ("%s: requested %d pages", __func__, count)); /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r344422 - stable/12/lib/libcasper/services/cap_syslog
Author: jah Date: Thu Feb 21 06:40:15 2019 New Revision: 344422 URL: https://svnweb.freebsd.org/changeset/base/344422 Log: MFC r343827: r342089 changed cap_syslog(3) to preserve the stdio descriptors inherited from its parent so that LOG_PERROR would work. However, this caused dhclient(8)'s stdio streams to remain open across daemonization, breaking the ability to capture its foreground output as done in netconfig_ipv4. Fix this by reverting r341692 and instead passing the parent's stderr descriptor as an argument to cap_openlog() only when LOG_PERROR is specified in logopt. PR: 234514 Modified: stable/12/lib/libcasper/services/cap_syslog/cap_syslog.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libcasper/services/cap_syslog/cap_syslog.c == --- stable/12/lib/libcasper/services/cap_syslog/cap_syslog.cThu Feb 21 06:02:51 2019(r344421) +++ stable/12/lib/libcasper/services/cap_syslog/cap_syslog.cThu Feb 21 06:40:15 2019(r344422) @@ -88,6 +88,9 @@ cap_openlog(cap_channel_t *chan, const char *ident, in } nvlist_add_number(nvl, "logopt", logopt); nvlist_add_number(nvl, "facility", facility); + if (logopt & LOG_PERROR) { + nvlist_add_descriptor(nvl, "stderr", STDERR_FILENO); + } nvl = cap_xfer_nvlist(chan, nvl); if (nvl == NULL) { return; @@ -131,6 +134,7 @@ cap_setlogmask(cap_channel_t *chan, int maskpri) */ static char *LogTag; +static int prev_stderr = -1; static void slog_vsyslog(const nvlist_t *limits __unused, const nvlist_t *nvlin, @@ -146,6 +150,8 @@ slog_openlog(const nvlist_t *limits __unused, const nv nvlist_t *nvlout __unused) { const char *ident; + uint64_t logopt; + int stderr_fd; ident = dnvlist_get_string(nvlin, "ident", NULL); if (ident != NULL) { @@ -153,8 +159,19 @@ slog_openlog(const nvlist_t *limits __unused, const nv LogTag = strdup(ident); } - openlog(LogTag, nvlist_get_number(nvlin, "logopt"), - nvlist_get_number(nvlin, "facility")); + logopt = nvlist_get_number(nvlin, "logopt"); + if (logopt & LOG_PERROR) { + stderr_fd = dnvlist_get_descriptor(nvlin, "stderr", -1); + if (prev_stderr == -1) + prev_stderr = dup(STDERR_FILENO); + if (prev_stderr != -1) + (void)dup2(stderr_fd, STDERR_FILENO); + } else if (prev_stderr != -1) { + (void)dup2(prev_stderr, STDERR_FILENO); + close(prev_stderr); + prev_stderr = -1; + } + openlog(LogTag, logopt, nvlist_get_number(nvlin, "facility")); } static void @@ -166,6 +183,12 @@ slog_closelog(const nvlist_t *limits __unused, const n free(LogTag); LogTag = NULL; + + if (prev_stderr != -1) { + (void)dup2(prev_stderr, STDERR_FILENO); + close(prev_stderr); + prev_stderr = -1; + } } static void @@ -198,4 +221,4 @@ syslog_command(const char *cmd, const nvlist_t *limits return (0); } -CREATE_SERVICE("system.syslog", NULL, syslog_command, CASPER_SERVICE_STDIO); +CREATE_SERVICE("system.syslog", NULL, syslog_command, 0); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r343827 - head/lib/libcasper/services/cap_syslog
Author: jah Date: Wed Feb 6 04:36:28 2019 New Revision: 343827 URL: https://svnweb.freebsd.org/changeset/base/343827 Log: r341692 changed cap_syslog(3) to preserve the stdio descriptors inherited from its parent so that LOG_PERROR would work. However, this caused dhclient(8)'s stdio streams to remain open across daemonization, breaking the ability to capture its foreground output as done in netconfig_ipv4. Fix this by reverting r341692 and instead passing the parent's stderr descriptor as an argument to cap_openlog() only when LOG_PERROR is specified in logopt. PR: 234514 Suggested by: markj Reported by: Shawn Webb Reviewed by: markj, oshogbo MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D18989 Modified: head/lib/libcasper/services/cap_syslog/cap_syslog.c Modified: head/lib/libcasper/services/cap_syslog/cap_syslog.c == --- head/lib/libcasper/services/cap_syslog/cap_syslog.c Wed Feb 6 04:00:37 2019(r343826) +++ head/lib/libcasper/services/cap_syslog/cap_syslog.c Wed Feb 6 04:36:28 2019(r343827) @@ -88,6 +88,9 @@ cap_openlog(cap_channel_t *chan, const char *ident, in } nvlist_add_number(nvl, "logopt", logopt); nvlist_add_number(nvl, "facility", facility); + if (logopt & LOG_PERROR) { + nvlist_add_descriptor(nvl, "stderr", STDERR_FILENO); + } nvl = cap_xfer_nvlist(chan, nvl); if (nvl == NULL) { return; @@ -131,6 +134,7 @@ cap_setlogmask(cap_channel_t *chan, int maskpri) */ static char *LogTag; +static int prev_stderr = -1; static void slog_vsyslog(const nvlist_t *limits __unused, const nvlist_t *nvlin, @@ -146,6 +150,8 @@ slog_openlog(const nvlist_t *limits __unused, const nv nvlist_t *nvlout __unused) { const char *ident; + uint64_t logopt; + int stderr_fd; ident = dnvlist_get_string(nvlin, "ident", NULL); if (ident != NULL) { @@ -153,8 +159,19 @@ slog_openlog(const nvlist_t *limits __unused, const nv LogTag = strdup(ident); } - openlog(LogTag, nvlist_get_number(nvlin, "logopt"), - nvlist_get_number(nvlin, "facility")); + logopt = nvlist_get_number(nvlin, "logopt"); + if (logopt & LOG_PERROR) { + stderr_fd = dnvlist_get_descriptor(nvlin, "stderr", -1); + if (prev_stderr == -1) + prev_stderr = dup(STDERR_FILENO); + if (prev_stderr != -1) + (void)dup2(stderr_fd, STDERR_FILENO); + } else if (prev_stderr != -1) { + (void)dup2(prev_stderr, STDERR_FILENO); + close(prev_stderr); + prev_stderr = -1; + } + openlog(LogTag, logopt, nvlist_get_number(nvlin, "facility")); } static void @@ -166,6 +183,12 @@ slog_closelog(const nvlist_t *limits __unused, const n free(LogTag); LogTag = NULL; + + if (prev_stderr != -1) { + (void)dup2(prev_stderr, STDERR_FILENO); + close(prev_stderr); + prev_stderr = -1; + } } static void @@ -198,4 +221,4 @@ syslog_command(const char *cmd, const nvlist_t *limits return (0); } -CREATE_SERVICE("system.syslog", NULL, syslog_command, CASPER_SERVICE_STDIO); +CREATE_SERVICE("system.syslog", NULL, syslog_command, 0); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r343254 - stable/12/sys/kern
Author: jah Date: Mon Jan 21 08:24:49 2019 New Revision: 343254 URL: https://svnweb.freebsd.org/changeset/base/343254 Log: MFC r343005: Handle SIGIO for listening sockets r319722 separated struct socket and parts of the socket I/O path into listening-socket-specific and dataflow-socket-specific pieces. Listening socket connection notifications are now handled by solisten_wakeup() instead of sowakeup(), but solisten_wakeup() does not currently post SIGIO to the owning process. PR: 234258 Modified: stable/12/sys/kern/uipc_socket.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/uipc_socket.c == --- stable/12/sys/kern/uipc_socket.cMon Jan 21 07:44:46 2019 (r343253) +++ stable/12/sys/kern/uipc_socket.cMon Jan 21 08:24:49 2019 (r343254) @@ -886,6 +886,8 @@ solisten_wakeup(struct socket *sol) } SOLISTEN_UNLOCK(sol); wakeup_one(>sol_comp); + if ((sol->so_state & SS_ASYNC) && sol->so_sigio != NULL) + pgsigio(>so_sigio, SIGIO, 0); } /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r343005 - head/sys/kern
Author: jah Date: Sun Jan 13 20:33:54 2019 New Revision: 343005 URL: https://svnweb.freebsd.org/changeset/base/343005 Log: Handle SIGIO for listening sockets r319722 separated struct socket and parts of the socket I/O path into listening-socket-specific and dataflow-socket-specific pieces. Listening socket connection notifications are now handled by solisten_wakeup() instead of sowakeup(), but solisten_wakeup() does not currently post SIGIO to the owning process. PR: 234258 Reported by: Kenneth Adelman MFC after:1 week Differential Revision:https://reviews.freebsd.org/D18664 Modified: head/sys/kern/uipc_socket.c Modified: head/sys/kern/uipc_socket.c == --- head/sys/kern/uipc_socket.c Sun Jan 13 19:49:46 2019(r343004) +++ head/sys/kern/uipc_socket.c Sun Jan 13 20:33:54 2019(r343005) @@ -886,6 +886,8 @@ solisten_wakeup(struct socket *sol) } SOLISTEN_UNLOCK(sol); wakeup_one(>sol_comp); + if ((sol->so_state & SS_ASYNC) && sol->so_sigio != NULL) + pgsigio(>so_sigio, SIGIO, 0); } /* ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r336155 - stable/11/sys/conf
Author: jah Date: Tue Jul 10 01:06:43 2018 New Revision: 336155 URL: https://svnweb.freebsd.org/changeset/base/336155 Log: MFC r328489, r329232, r331836 r328489: Remove system makefile path directives from env passed to PORTS_MODULES step Previously, MAKESYSPATH as well as '-m' directives in MAKEFLAGS would cause any port rebuilt during the PORTS_MODULES stage to consume system makefiles from $(SRCROOT)/share/mk instead of those installed under /usr/share/mk. For kernel modules that need to build against an updated src tree this makes sense; less so for or any userspace library or utility the port may also happen to install. Before 11.0, this probably didn't matter much in practice. But the addition of src.libnames.mk under $(SRCROOT)/share/mk in 11.0 breaks any consumer of bsd.prog.mk and DPADD/LDADD during PORTS_MODULES. Address the build breakage by removing MAKESYSPATH and any occurrence of '-m' from MAKEFLAGS in the environment created for the port build. Instead set SYSDIR so that any kmod built by the port will still consume conf/kmod.mk from the updated src tree, assuming it uses r329232 (by bdrewery): ports modules: Don't leak AUTO_OBJ changes into the port builds. This came about when r328489 made ports modules builds no longer use the in-tree share/mk files, but didn't cleanup MAKEOBJDIR from the environment. This fixes "Variable OBJTOP is recursive". r331836: Remove MK_AUTO_OBJ from env passed to PORTS_MODULES This fixes a failure to resolve object file paths seen when buildkernel (which sets MK_AUTO_OBJ=yes) and installkernel (which sets MK_AUTO_OBJ=no) are run as separate steps. r329232 partially fixed this scenario by removing MAKEOBJDIR, but it seems the AUTO_OBJ setting also needs to be on the same page for the build and install steps. Modified: stable/11/sys/conf/kern.post.mk Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/kern.post.mk == --- stable/11/sys/conf/kern.post.mk Tue Jul 10 00:36:37 2018 (r336154) +++ stable/11/sys/conf/kern.post.mk Tue Jul 10 01:06:43 2018 (r336155) @@ -69,6 +69,11 @@ PORTSMODULESENV=\ -u CC \ -u CXX \ -u CPP \ + -u MAKESYSPATH \ + -u MK_AUTO_OBJ \ + -u MAKEOBJDIR \ + MAKEFLAGS="${MAKEFLAGS:M*:tW:S/^-m /-m_/g:S/ -m / -m_/g:tw:N-m_*:NMK_AUTO_OBJ=*}" \ + SYSDIR=${SYSDIR} \ PATH=${PATH}:${LOCALBASE}/bin:${LOCALBASE}/sbin \ SRC_BASE=${SRC_BASE} \ OSVERSION=${OSRELDATE} \ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r331836 - head/sys/conf
Author: jah Date: Sat Mar 31 05:17:12 2018 New Revision: 331836 URL: https://svnweb.freebsd.org/changeset/base/331836 Log: Remove MK_AUTO_OBJ from env passed to PORTS_MODULES This fixes a failure to resolve object file paths seen when buildkernel (which sets MK_AUTO_OBJ=yes) and installkernel (which sets MK_AUTO_OBJ=no) are run as separate steps. r329232 partially fixed this scenario by removing MAKEOBJDIR, but it seems the AUTO_OBJ setting also needs to be on the same page for the build and install steps. Reviewed by: bdrewery MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D14143 Modified: head/sys/conf/kern.post.mk Modified: head/sys/conf/kern.post.mk == --- head/sys/conf/kern.post.mk Sat Mar 31 01:37:14 2018(r331835) +++ head/sys/conf/kern.post.mk Sat Mar 31 05:17:12 2018(r331836) @@ -70,8 +70,9 @@ PORTSMODULESENV=\ -u CXX \ -u CPP \ -u MAKESYSPATH \ + -u MK_AUTO_OBJ \ -u MAKEOBJDIR \ - MAKEFLAGS="${MAKEFLAGS:M*:tW:S/^-m /-m_/g:S/ -m / -m_/g:tw:N-m_*}" \ + MAKEFLAGS="${MAKEFLAGS:M*:tW:S/^-m /-m_/g:S/ -m / -m_/g:tw:N-m_*:NMK_AUTO_OBJ=*}" \ SYSDIR=${SYSDIR} \ PATH=${PATH}:${LOCALBASE}/bin:${LOCALBASE}/sbin \ SRC_BASE=${SRC_BASE} \ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r328489 - head/sys/conf
Author: jah Date: Sat Jan 27 20:13:36 2018 New Revision: 328489 URL: https://svnweb.freebsd.org/changeset/base/328489 Log: Remove system makefile path directives from env passed to PORTS_MODULES step Previously, MAKESYSPATH as well as '-m' directives in MAKEFLAGS would cause any port rebuilt during the PORTS_MODULES stage to consume system makefiles from $(SRCROOT)/share/mk instead of those installed under /usr/share/mk. For kernel modules that need to build against an updated src tree this makes sense; less so for or any userspace library or utility the port may also happen to install. Before 11.0, this probably didn't matter much in practice. But the addition of src.libnames.mk under $(SRCROOT)/share/mk in 11.0 breaks any consumer of bsd.prog.mk and DPADD/LDADD during PORTS_MODULES. Address the build breakage by removing MAKESYSPATH and any occurrence of '-m' from MAKEFLAGS in the environment created for the port build. Instead set SYSDIR so that any kmod built by the port will still consume conf/kmod.mk from the updated src tree, assuming it uses Reviewed by: bdrewery MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D13053 Modified: head/sys/conf/kern.post.mk Modified: head/sys/conf/kern.post.mk == --- head/sys/conf/kern.post.mk Sat Jan 27 19:23:42 2018(r328488) +++ head/sys/conf/kern.post.mk Sat Jan 27 20:13:36 2018(r328489) @@ -69,6 +69,9 @@ PORTSMODULESENV=\ -u CC \ -u CXX \ -u CPP \ + -u MAKESYSPATH \ + MAKEFLAGS="${MAKEFLAGS:M*:tW:S/^-m /-m_/g:S/ -m / -m_/g:tw:N-m_*}" \ + SYSDIR=${SYSDIR} \ PATH=${PATH}:${LOCALBASE}/bin:${LOCALBASE}/sbin \ SRC_BASE=${SRC_BASE} \ OSVERSION=${OSRELDATE} \ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r321835 - head/usr.bin/calendar/calendars
Author: jah Date: Tue Aug 1 01:39:54 2017 New Revision: 321835 URL: https://svnweb.freebsd.org/changeset/base/321835 Log: Add myself to FreeBSD calendar Requested by: mckusick Modified: head/usr.bin/calendar/calendars/calendar.freebsd Modified: head/usr.bin/calendar/calendars/calendar.freebsd == --- head/usr.bin/calendar/calendars/calendar.freebsdTue Aug 1 01:35:23 2017(r321834) +++ head/usr.bin/calendar/calendars/calendar.freebsdTue Aug 1 01:39:54 2017(r321835) @@ -290,6 +290,7 @@ 08/19 Chin-San Huang <chin...@freebsd.org> born in Yi-Lan, Taiwan, Republic of China, 1979 08/19 Pav Lucistnik <p...@freebsd.org> born in Kutna Hora, Czech Republic, 1980 08/20 Michael Heffner <mi...@freebsd.org> born in Cleona, Pennsylvania, United States, 1981 +08/21 Jason A. Harmening <j...@freebsd.org> born in Fort Wayne, Indiana, United States, 1981 08/24 Mark Linimon <lini...@freebsd.org> born in Houston, Texas, United States, 1955 08/24 Alexander Botero-Lowry <ale...@freebsd.org> died in San Francisco, California, United States, 2012 08/25 Beech Rintoul <be...@freebsd.org> born in Oakland, California, United States, 1952 ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r320545 - head/sys/sys
Author: jah Date: Sat Jul 1 15:58:57 2017 New Revision: 320545 URL: https://svnweb.freebsd.org/changeset/base/320545 Log: Bump __FreeBSD_version due to r320528, cleanup and inlining of bus_dmamap* functions. Reported by: David WolfskillModified: head/sys/sys/param.h Modified: head/sys/sys/param.h == --- head/sys/sys/param.hSat Jul 1 13:25:06 2017(r320544) +++ head/sys/sys/param.hSat Jul 1 15:58:57 2017(r320545) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1200036 /* Master, propagated to newvers */ +#define __FreeBSD_version 1200037 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r320528 - in head/sys: amd64/include arm/arm arm/include arm64/arm64 arm64/include dev/aac dev/aacraid dev/bnxt dev/cxgb dev/cxgb/ulp/iw_cxgb dev/hyperv/storvsc dev/mfi dev/tsec dev/xdm...
Author: jah Date: Sat Jul 1 05:35:29 2017 New Revision: 320528 URL: https://svnweb.freebsd.org/changeset/base/320528 Log: Clean up MD pollution of bus_dma.h: --Remove special-case handling of sparc64 bus_dmamap* functions. Replace with a more generic mechanism that allows MD busdma implementations to generate inline mapping functions by defining WANT_INLINE_DMAMAP in . This is currently useful for sparc64, x86, and arm64, which all implement non-load dmamap operations as simple wrappers around map objects which may be bus- or device-specific. --Remove NULL-checked bus_dmamap macros. Implement the equivalent NULL checks in the inlined x86 implementation. For non-x86 platforms, these checks are a minor pessimization as those platforms do not currently allow NULL maps. NULL maps were originally allowed on arm64, which appears to have been the motivation behind adding arm[64]-specific barriers to bus_dma.h, but that support was removed in r299463. --Simplify the internal interface used by the bus_dmamap_load* variants and move it to bus_dma_internal.h --Fix some drivers that directly include sys/bus_dma.h despite the recommendations of bus_dma(9) Reviewed by: kib (previous revision), marius Differential Revision:https://reviews.freebsd.org/D10729 Added: head/sys/sys/bus_dma_internal.h (contents, props changed) head/sys/x86/include/bus_dma.h (contents, props changed) Modified: head/sys/amd64/include/bus_dma.h head/sys/arm/arm/busdma_machdep-v4.c head/sys/arm/arm/busdma_machdep-v6.c head/sys/arm/include/bus_dma.h head/sys/arm64/arm64/busdma_machdep.c head/sys/arm64/include/bus_dma.h head/sys/arm64/include/bus_dma_impl.h head/sys/dev/aac/aac.c head/sys/dev/aacraid/aacraid.c head/sys/dev/bnxt/bnxt.h head/sys/dev/cxgb/cxgb_adapter.h head/sys/dev/cxgb/cxgb_main.c head/sys/dev/cxgb/cxgb_sge.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cq.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_dbg.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_ev.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_hal.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_mem.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_qp.c head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_resource.c head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c head/sys/dev/mfi/mfi.c head/sys/dev/mfi/mfi_cam.c head/sys/dev/tsec/if_tsec.c head/sys/dev/xdma/xdma.c head/sys/dev/xen/blkfront/blkfront.c head/sys/i386/include/bus_dma.h head/sys/mips/include/bus_dma.h head/sys/mips/mips/busdma_machdep.c head/sys/net/iflib.h head/sys/powerpc/include/bus_dma.h head/sys/powerpc/powerpc/busdma_machdep.c head/sys/riscv/include/bus_dma.h head/sys/riscv/riscv/busdma_machdep.c head/sys/sparc64/include/bus_dma.h head/sys/sys/bus_dma.h head/sys/x86/include/busdma_impl.h head/sys/x86/iommu/busdma_dmar.c head/sys/x86/x86/busdma_bounce.c head/sys/x86/x86/busdma_machdep.c Modified: head/sys/amd64/include/bus_dma.h == --- head/sys/amd64/include/bus_dma.hSat Jul 1 05:27:40 2017 (r320527) +++ head/sys/amd64/include/bus_dma.hSat Jul 1 05:35:29 2017 (r320528) @@ -29,6 +29,6 @@ #ifndef _AMD64_BUS_DMA_H_ #define _AMD64_BUS_DMA_H_ -#include +#include #endif /* _AMD64_BUS_DMA_H_ */ Modified: head/sys/arm/arm/busdma_machdep-v4.c == --- head/sys/arm/arm/busdma_machdep-v4.cSat Jul 1 05:27:40 2017 (r320527) +++ head/sys/arm/arm/busdma_machdep-v4.cSat Jul 1 05:35:29 2017 (r320528) @@ -1008,7 +1008,7 @@ _bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t * Did we fit? */ if (buflen != 0) { - _bus_dmamap_unload(dmat, map); + bus_dmamap_unload(dmat, map); return (EFBIG); /* XXX better return value here? */ } return (0); @@ -1129,14 +1129,14 @@ cleanup: * Did we fit? */ if (buflen != 0) { - _bus_dmamap_unload(dmat, map); + bus_dmamap_unload(dmat, map); return (EFBIG); /* XXX better return value here? */ } return (0); } void -__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map, struct memdesc *mem, +_bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map, struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg) { @@ -1161,7 +1161,7 @@ _bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t * Release the mapping held by map. */ void -_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map) +bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map) { struct bounce_page *bpage; struct bounce_zone *bz; @@
svn commit: r313930 - in head/sys: amd64/include kern mips/include mips/mips net powerpc/include sparc64/include
Author: jah Date: Sun Feb 19 02:03:09 2017 New Revision: 313930 URL: https://svnweb.freebsd.org/changeset/base/313930 Log: Bring back r313037, with fixes for mips: Implement get_pcpu() for amd64/sparc64/mips/powerpc, and use it to replace pcpu_find(curcpu) in MI code. Reviewed by: andreast, kan, lidl Tested by:lidl(mips, sparc64), andreast(powerpc) Differential Revision:https://reviews.freebsd.org/D9587 Modified: head/sys/amd64/include/pcpu.h head/sys/kern/kern_rmlock.c head/sys/mips/include/pcpu.h head/sys/mips/mips/machdep.c head/sys/net/netisr.c head/sys/powerpc/include/cpufunc.h head/sys/powerpc/include/pcpu.h head/sys/sparc64/include/pcpu.h Modified: head/sys/amd64/include/pcpu.h == --- head/sys/amd64/include/pcpu.h Sat Feb 18 22:13:28 2017 (r313929) +++ head/sys/amd64/include/pcpu.h Sun Feb 19 02:03:09 2017 (r313930) @@ -78,6 +78,7 @@ extern struct pcpu *pcpup; +#defineget_pcpu() (pcpup) #definePCPU_GET(member)(pcpup->pc_ ## member) #definePCPU_ADD(member, val) (pcpup->pc_ ## member += (val)) #definePCPU_INC(member)PCPU_ADD(member, 1) @@ -203,6 +204,15 @@ extern struct pcpu *pcpup; } \ } +#defineget_pcpu() __extension__ ({ \ + struct pcpu *__pc; \ + \ + __asm __volatile("movq %%gs:%1,%0" \ + : "=r" (__pc) \ + : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace; \ + __pc; \ +}) + #definePCPU_GET(member)__PCPU_GET(pc_ ## member) #definePCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val) #definePCPU_INC(member)__PCPU_INC(pc_ ## member) Modified: head/sys/kern/kern_rmlock.c == --- head/sys/kern/kern_rmlock.c Sat Feb 18 22:13:28 2017(r313929) +++ head/sys/kern/kern_rmlock.c Sun Feb 19 02:03:09 2017(r313930) @@ -156,7 +156,7 @@ unlock_rm(struct lock_object *lock) */ critical_enter(); td = curthread; - pc = pcpu_find(curcpu); + pc = get_pcpu(); for (queue = pc->pc_rm_queue.rmq_next; queue != >pc_rm_queue; queue = queue->rmq_next) { tracker = (struct rm_priotracker *)queue; @@ -258,7 +258,7 @@ rm_cleanIPI(void *arg) struct rmlock *rm = arg; struct rm_priotracker *tracker; struct rm_queue *queue; - pc = pcpu_find(curcpu); + pc = get_pcpu(); for (queue = pc->pc_rm_queue.rmq_next; queue != >pc_rm_queue; queue = queue->rmq_next) { @@ -355,7 +355,7 @@ _rm_rlock_hard(struct rmlock *rm, struct struct pcpu *pc; critical_enter(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); /* Check if we just need to do a proper critical_exit. */ if (!CPU_ISSET(pc->pc_cpuid, >rm_writecpus)) { @@ -416,7 +416,7 @@ _rm_rlock_hard(struct rmlock *rm, struct } critical_enter(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); CPU_CLR(pc->pc_cpuid, >rm_writecpus); rm_tracker_add(pc, tracker); sched_pin(); @@ -641,7 +641,7 @@ _rm_rlock_debug(struct rmlock *rm, struc #ifdef INVARIANTS if (!(rm->lock_object.lo_flags & LO_RECURSABLE) && !trylock) { critical_enter(); - KASSERT(rm_trackers_present(pcpu_find(curcpu), rm, + KASSERT(rm_trackers_present(get_pcpu(), rm, curthread) == 0, ("rm_rlock: recursed on non-recursive rmlock %s @ %s:%d\n", rm->lock_object.lo_name, file, line)); @@ -771,7 +771,7 @@ _rm_assert(const struct rmlock *rm, int } critical_enter(); - count = rm_trackers_present(pcpu_find(curcpu), rm, curthread); + count = rm_trackers_present(get_pcpu(), rm, curthread); critical_exit(); if (count == 0) @@ -797,7 +797,7 @@ _rm_assert(const struct rmlock *rm, int rm->lock_object.lo_name, file, line); critical_enter(); - count = rm_trackers_present(pcpu_find(curcpu), rm, curthread); + count = rm_trackers_present(get_pcpu(), rm, curthread); critical_exit(); if (count != 0) Modified: head/sys/mips/include/pcpu.h
svn commit: r313862 - in stable/11/sys/i386: i386 include
Author: jah Date: Fri Feb 17 07:08:37 2017 New Revision: 313862 URL: https://svnweb.freebsd.org/changeset/base/313862 Log: MFC r312952: Implement get_pcpu() for i386 and use it to replace pcpu_find(curcpu) in the i386 pmap. The curcpu macro loads the per-cpu data pointer as its first step, so the remaining steps of pcpu_find(curcpu) are circular. Modified: stable/11/sys/i386/i386/pmap.c stable/11/sys/i386/include/pcpu.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/i386/i386/pmap.c == --- stable/11/sys/i386/i386/pmap.c Fri Feb 17 06:49:54 2017 (r313861) +++ stable/11/sys/i386/i386/pmap.c Fri Feb 17 07:08:37 2017 (r313862) @@ -441,7 +441,7 @@ pmap_bootstrap(vm_paddr_t firstaddr) * CMAP1/CMAP2 are used for zeroing and copying pages. * CMAP3 is used for the idle process page zeroing. */ - pc = pcpu_find(curcpu); + pc = get_pcpu(); mtx_init(>pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF); SYSMAP(caddr_t, pc->pc_cmap_pte1, pc->pc_cmap_addr1, 1) SYSMAP(caddr_t, pc->pc_cmap_pte2, pc->pc_cmap_addr2, 1) @@ -4253,7 +4253,7 @@ pmap_zero_page(vm_page_t m) struct pcpu *pc; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(>pc_cmap_lock); if (*cmap_pte2) @@ -4286,7 +4286,7 @@ pmap_zero_page_area(vm_page_t m, int off struct pcpu *pc; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(>pc_cmap_lock); if (*cmap_pte2) @@ -4337,7 +4337,7 @@ pmap_copy_page(vm_page_t src, vm_page_t struct pcpu *pc; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte1 = pc->pc_cmap_pte1; cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(>pc_cmap_lock); @@ -4372,7 +4372,7 @@ pmap_copy_pages(vm_page_t ma[], vm_offse int cnt; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte1 = pc->pc_cmap_pte1; cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(>pc_cmap_lock); @@ -5368,7 +5368,7 @@ pmap_flush_page(vm_page_t m) useclflushopt = (cpu_stdext_feature & CPUID_STDEXT_CLFLUSHOPT) != 0; if (useclflushopt || (cpu_feature & CPUID_CLFSH) != 0) { sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(>pc_cmap_lock); if (*cmap_pte2) Modified: stable/11/sys/i386/include/pcpu.h == --- stable/11/sys/i386/include/pcpu.h Fri Feb 17 06:49:54 2017 (r313861) +++ stable/11/sys/i386/include/pcpu.h Fri Feb 17 07:08:37 2017 (r313862) @@ -76,6 +76,7 @@ extern struct pcpu *pcpup; +#defineget_pcpu() (pcpup) #definePCPU_GET(member)(pcpup->pc_ ## member) #definePCPU_ADD(member, val) (pcpup->pc_ ## member += (val)) #definePCPU_INC(member)PCPU_ADD(member, 1) @@ -196,6 +197,15 @@ extern struct pcpu *pcpup; } \ } while (0) +#defineget_pcpu() __extension__ ({ \ + struct pcpu *__pc; \ + \ + __asm __volatile("movl %%fs:%1,%0" \ + : "=r" (__pc) \ + : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace; \ + __pc; \ +}) + #definePCPU_GET(member)__PCPU_GET(pc_ ## member) #definePCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val) #definePCPU_INC(member)__PCPU_INC(pc_ ## member) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r313766 - in stable/11/sys/arm: arm include
Author: jah Date: Wed Feb 15 10:35:46 2017 New Revision: 313766 URL: https://svnweb.freebsd.org/changeset/base/313766 Log: MFC r312610, r312792 r312610: Like r310481 for i386, move the objects used to create temporary mappings for armv6 pmap zero and copy operations to the MD PCPU region. Change sysmap initialization to only allocate KVA pages for CPUs that are actually present. While here, collapse CMAP3 into CMAP2 (their use was mutually exclusive anyway) and "recover" some space in PCPU padding that has always been available due to 64-byte cacheline padding. r312792: Further cleanup of per-CPU armv6 pmap data: - Replace pcpu_find(curcpu) with get_pcpu(), which is much more direct. - Remove armv4 pcpu fields which I added in r286296 but never needed to use. - armv6 pc_qmap_addr was leftover from the old armv6 pmap implementation. Rename it and put it to use in the new one. Modified: stable/11/sys/arm/arm/pmap-v6.c stable/11/sys/arm/include/pcpu.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/arm/pmap-v6.c == --- stable/11/sys/arm/arm/pmap-v6.c Wed Feb 15 09:18:08 2017 (r313765) +++ stable/11/sys/arm/arm/pmap-v6.c Wed Feb 15 10:35:46 2017 (r313766) @@ -110,11 +110,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef SMP -#include -#else -#include -#endif #ifdef DDB #include @@ -296,16 +291,6 @@ vm_paddr_t first_managed_pa; /* * All those kernel PT submaps that BSD is so fond of */ -struct sysmaps { - struct mtx lock; - pt2_entry_t *CMAP1; - pt2_entry_t *CMAP2; - pt2_entry_t *CMAP3; - caddr_t CADDR1; - caddr_t CADDR2; - caddr_t CADDR3; -}; -static struct sysmaps sysmaps_pcpu[MAXCPU]; static pt2_entry_t *CMAP3; static caddr_t CADDR3; caddr_t _tmppt = 0; @@ -1135,8 +1120,7 @@ void pmap_bootstrap(vm_offset_t firstaddr) { pt2_entry_t *unused __unused; - struct sysmaps *sysmaps; - u_int i; + struct pcpu *pc; /* * Initialize the kernel pmap (which is statically allocated). @@ -1175,16 +1159,14 @@ pmap_bootstrap(vm_offset_t firstaddr) /* * Local CMAP1/CMAP2 are used for zeroing and copying pages. -* Local CMAP3 is used for data cache cleaning. +* Local CMAP2 is also used for data cache cleaning. * Global CMAP3 is used for the idle process page zeroing. */ - for (i = 0; i < MAXCPU; i++) { - sysmaps = _pcpu[i]; - mtx_init(>lock, "SYSMAPS", NULL, MTX_DEF); - SYSMAP(caddr_t, sysmaps->CMAP1, sysmaps->CADDR1, 1); - SYSMAP(caddr_t, sysmaps->CMAP2, sysmaps->CADDR2, 1); - SYSMAP(caddr_t, sysmaps->CMAP3, sysmaps->CADDR3, 1); - } + pc = get_pcpu(); + mtx_init(>pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF); + SYSMAP(caddr_t, pc->pc_cmap1_pte2p, pc->pc_cmap1_addr, 1); + SYSMAP(caddr_t, pc->pc_cmap2_pte2p, pc->pc_cmap2_addr, 1); + SYSMAP(vm_offset_t, pc->pc_qmap_pte2p, pc->pc_qmap_addr, 1); SYSMAP(caddr_t, CMAP3, CADDR3, 1); /* @@ -1218,19 +1200,33 @@ pmap_bootstrap(vm_offset_t firstaddr) } static void -pmap_init_qpages(void) +pmap_init_reserved_pages(void) { struct pcpu *pc; + vm_offset_t pages; int i; CPU_FOREACH(i) { pc = pcpu_find(i); - pc->pc_qmap_addr = kva_alloc(PAGE_SIZE); - if (pc->pc_qmap_addr == 0) + /* +* Skip if the mapping has already been initialized, +* i.e. this is the BSP. +*/ + if (pc->pc_cmap1_addr != 0) + continue; + mtx_init(>pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF); + pages = kva_alloc(PAGE_SIZE * 3); + if (pages == 0) panic("%s: unable to allocate KVA", __func__); + pc->pc_cmap1_pte2p = pt2map_entry(pages); + pc->pc_cmap2_pte2p = pt2map_entry(pages + PAGE_SIZE); + pc->pc_qmap_pte2p = pt2map_entry(pages + (PAGE_SIZE * 2)); + pc->pc_cmap1_addr = (caddr_t)pages; + pc->pc_cmap2_addr = (caddr_t)(pages + PAGE_SIZE); + pc->pc_qmap_addr = pages + (PAGE_SIZE * 2); } } -SYSINIT(qpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_qpages, NULL); +SYSINIT(rpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_reserved_pages, NULL); /* * The function can already be use in second initialization stage. @@ -1581,8 +1577,9 @@ pagezero(void *page) static __inline vm_paddr_t pmap_pt2pg_zero(vm_page_t m) { + pt2_entry_t *cmap2_pte2p; vm_paddr_t pa; - struct sysmaps *sysmaps; + struct pcpu *pc; pa = VM_PAGE_TO_PHYS(m); @@ -1591,20 +1588,27 @@
svn commit: r313193 - in head/sys: amd64/include kern mips/include net powerpc/include sparc64/include
Author: jah Date: Sat Feb 4 06:24:49 2017 New Revision: 313193 URL: https://svnweb.freebsd.org/changeset/base/313193 Log: Revert r313037 The switch to get_pcpu() in MI code seems to cause hangs on MIPS. Back out until we can get a better idea of what's happening there. Reported by: kan, lidl Modified: head/sys/amd64/include/pcpu.h head/sys/kern/kern_rmlock.c head/sys/mips/include/pcpu.h head/sys/net/netisr.c head/sys/powerpc/include/cpufunc.h head/sys/powerpc/include/pcpu.h head/sys/sparc64/include/pcpu.h Modified: head/sys/amd64/include/pcpu.h == --- head/sys/amd64/include/pcpu.h Sat Feb 4 06:12:48 2017 (r313192) +++ head/sys/amd64/include/pcpu.h Sat Feb 4 06:24:49 2017 (r313193) @@ -78,7 +78,6 @@ extern struct pcpu *pcpup; -#defineget_pcpu() (pcpup) #definePCPU_GET(member)(pcpup->pc_ ## member) #definePCPU_ADD(member, val) (pcpup->pc_ ## member += (val)) #definePCPU_INC(member)PCPU_ADD(member, 1) @@ -204,15 +203,6 @@ extern struct pcpu *pcpup; } \ } -#defineget_pcpu() __extension__ ({ \ - struct pcpu *__pc; \ - \ - __asm __volatile("movq %%gs:%1,%0" \ - : "=r" (__pc) \ - : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace; \ - __pc; \ -}) - #definePCPU_GET(member)__PCPU_GET(pc_ ## member) #definePCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val) #definePCPU_INC(member)__PCPU_INC(pc_ ## member) Modified: head/sys/kern/kern_rmlock.c == --- head/sys/kern/kern_rmlock.c Sat Feb 4 06:12:48 2017(r313192) +++ head/sys/kern/kern_rmlock.c Sat Feb 4 06:24:49 2017(r313193) @@ -156,7 +156,7 @@ unlock_rm(struct lock_object *lock) */ critical_enter(); td = curthread; - pc = get_pcpu(); + pc = pcpu_find(curcpu); for (queue = pc->pc_rm_queue.rmq_next; queue != >pc_rm_queue; queue = queue->rmq_next) { tracker = (struct rm_priotracker *)queue; @@ -258,7 +258,7 @@ rm_cleanIPI(void *arg) struct rmlock *rm = arg; struct rm_priotracker *tracker; struct rm_queue *queue; - pc = get_pcpu(); + pc = pcpu_find(curcpu); for (queue = pc->pc_rm_queue.rmq_next; queue != >pc_rm_queue; queue = queue->rmq_next) { @@ -355,7 +355,7 @@ _rm_rlock_hard(struct rmlock *rm, struct struct pcpu *pc; critical_enter(); - pc = get_pcpu(); + pc = pcpu_find(curcpu); /* Check if we just need to do a proper critical_exit. */ if (!CPU_ISSET(pc->pc_cpuid, >rm_writecpus)) { @@ -416,7 +416,7 @@ _rm_rlock_hard(struct rmlock *rm, struct } critical_enter(); - pc = get_pcpu(); + pc = pcpu_find(curcpu); CPU_CLR(pc->pc_cpuid, >rm_writecpus); rm_tracker_add(pc, tracker); sched_pin(); @@ -641,7 +641,7 @@ _rm_rlock_debug(struct rmlock *rm, struc #ifdef INVARIANTS if (!(rm->lock_object.lo_flags & LO_RECURSABLE) && !trylock) { critical_enter(); - KASSERT(rm_trackers_present(get_pcpu(), rm, + KASSERT(rm_trackers_present(pcpu_find(curcpu), rm, curthread) == 0, ("rm_rlock: recursed on non-recursive rmlock %s @ %s:%d\n", rm->lock_object.lo_name, file, line)); @@ -771,7 +771,7 @@ _rm_assert(const struct rmlock *rm, int } critical_enter(); - count = rm_trackers_present(get_pcpu(), rm, curthread); + count = rm_trackers_present(pcpu_find(curcpu), rm, curthread); critical_exit(); if (count == 0) @@ -797,7 +797,7 @@ _rm_assert(const struct rmlock *rm, int rm->lock_object.lo_name, file, line); critical_enter(); - count = rm_trackers_present(get_pcpu(), rm, curthread); + count = rm_trackers_present(pcpu_find(curcpu), rm, curthread); critical_exit(); if (count != 0) Modified: head/sys/mips/include/pcpu.h == --- head/sys/mips/include/pcpu.hSat Feb 4 06:12:48 2017 (r313192) +++ head/sys/mips/include/pcpu.hSat Feb 4 06:24:49 2017
svn commit: r313037 - in head/sys: amd64/include kern mips/include net powerpc/include sparc64/include
Author: jah Date: Wed Feb 1 03:32:49 2017 New Revision: 313037 URL: https://svnweb.freebsd.org/changeset/base/313037 Log: Implement get_pcpu() for the remaining architectures and use it to replace pcpu_find(curcpu) in MI code. Modified: head/sys/amd64/include/pcpu.h head/sys/kern/kern_rmlock.c head/sys/mips/include/pcpu.h head/sys/net/netisr.c head/sys/powerpc/include/cpufunc.h head/sys/powerpc/include/pcpu.h head/sys/sparc64/include/pcpu.h Modified: head/sys/amd64/include/pcpu.h == --- head/sys/amd64/include/pcpu.h Wed Feb 1 03:29:13 2017 (r313036) +++ head/sys/amd64/include/pcpu.h Wed Feb 1 03:32:49 2017 (r313037) @@ -78,6 +78,7 @@ extern struct pcpu *pcpup; +#defineget_pcpu() (pcpup) #definePCPU_GET(member)(pcpup->pc_ ## member) #definePCPU_ADD(member, val) (pcpup->pc_ ## member += (val)) #definePCPU_INC(member)PCPU_ADD(member, 1) @@ -203,6 +204,15 @@ extern struct pcpu *pcpup; } \ } +#defineget_pcpu() __extension__ ({ \ + struct pcpu *__pc; \ + \ + __asm __volatile("movq %%gs:%1,%0" \ + : "=r" (__pc) \ + : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace; \ + __pc; \ +}) + #definePCPU_GET(member)__PCPU_GET(pc_ ## member) #definePCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val) #definePCPU_INC(member)__PCPU_INC(pc_ ## member) Modified: head/sys/kern/kern_rmlock.c == --- head/sys/kern/kern_rmlock.c Wed Feb 1 03:29:13 2017(r313036) +++ head/sys/kern/kern_rmlock.c Wed Feb 1 03:32:49 2017(r313037) @@ -156,7 +156,7 @@ unlock_rm(struct lock_object *lock) */ critical_enter(); td = curthread; - pc = pcpu_find(curcpu); + pc = get_pcpu(); for (queue = pc->pc_rm_queue.rmq_next; queue != >pc_rm_queue; queue = queue->rmq_next) { tracker = (struct rm_priotracker *)queue; @@ -258,7 +258,7 @@ rm_cleanIPI(void *arg) struct rmlock *rm = arg; struct rm_priotracker *tracker; struct rm_queue *queue; - pc = pcpu_find(curcpu); + pc = get_pcpu(); for (queue = pc->pc_rm_queue.rmq_next; queue != >pc_rm_queue; queue = queue->rmq_next) { @@ -355,7 +355,7 @@ _rm_rlock_hard(struct rmlock *rm, struct struct pcpu *pc; critical_enter(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); /* Check if we just need to do a proper critical_exit. */ if (!CPU_ISSET(pc->pc_cpuid, >rm_writecpus)) { @@ -416,7 +416,7 @@ _rm_rlock_hard(struct rmlock *rm, struct } critical_enter(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); CPU_CLR(pc->pc_cpuid, >rm_writecpus); rm_tracker_add(pc, tracker); sched_pin(); @@ -641,7 +641,7 @@ _rm_rlock_debug(struct rmlock *rm, struc #ifdef INVARIANTS if (!(rm->lock_object.lo_flags & LO_RECURSABLE) && !trylock) { critical_enter(); - KASSERT(rm_trackers_present(pcpu_find(curcpu), rm, + KASSERT(rm_trackers_present(get_pcpu(), rm, curthread) == 0, ("rm_rlock: recursed on non-recursive rmlock %s @ %s:%d\n", rm->lock_object.lo_name, file, line)); @@ -771,7 +771,7 @@ _rm_assert(const struct rmlock *rm, int } critical_enter(); - count = rm_trackers_present(pcpu_find(curcpu), rm, curthread); + count = rm_trackers_present(get_pcpu(), rm, curthread); critical_exit(); if (count == 0) @@ -797,7 +797,7 @@ _rm_assert(const struct rmlock *rm, int rm->lock_object.lo_name, file, line); critical_enter(); - count = rm_trackers_present(pcpu_find(curcpu), rm, curthread); + count = rm_trackers_present(get_pcpu(), rm, curthread); critical_exit(); if (count != 0) Modified: head/sys/mips/include/pcpu.h == --- head/sys/mips/include/pcpu.hWed Feb 1 03:29:13 2017 (r313036) +++ head/sys/mips/include/pcpu.hWed Feb 1 03:32:49 2017 (r313037) @@ -65,6 +65,7 @@ extern char pcpu_space[MAXCPU][PAGE_SIZE
svn commit: r312952 - in head/sys/i386: i386 include
Author: jah Date: Sun Jan 29 16:54:55 2017 New Revision: 312952 URL: https://svnweb.freebsd.org/changeset/base/312952 Log: Implement get_pcpu() for i386 and use it to replace pcpu_find(curcpu) in the i386 pmap. The curcpu macro loads the per-cpu data pointer as its first step, so the remaining steps of pcpu_find(curcpu) are circular. get_pcpu() is already implemented for arm, arm64, and risc-v. My plan is to implement it for the remaining architectures and use it to replace several instances of pcpu_find(curcpu) in MI code. Reviewed by: kib MFC after:1 week Differential Revision:https://reviews.freebsd.org/D9370 Modified: head/sys/i386/i386/pmap.c head/sys/i386/include/pcpu.h Modified: head/sys/i386/i386/pmap.c == --- head/sys/i386/i386/pmap.c Sun Jan 29 14:29:02 2017(r312951) +++ head/sys/i386/i386/pmap.c Sun Jan 29 16:54:55 2017(r312952) @@ -440,7 +440,7 @@ pmap_bootstrap(vm_paddr_t firstaddr) * CMAP1/CMAP2 are used for zeroing and copying pages. * CMAP3 is used for the boot-time memory test. */ - pc = pcpu_find(curcpu); + pc = get_pcpu(); mtx_init(>pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF); SYSMAP(caddr_t, pc->pc_cmap_pte1, pc->pc_cmap_addr1, 1) SYSMAP(caddr_t, pc->pc_cmap_pte2, pc->pc_cmap_addr2, 1) @@ -4206,7 +4206,7 @@ pmap_zero_page(vm_page_t m) struct pcpu *pc; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(>pc_cmap_lock); if (*cmap_pte2) @@ -4237,7 +4237,7 @@ pmap_zero_page_area(vm_page_t m, int off struct pcpu *pc; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(>pc_cmap_lock); if (*cmap_pte2) @@ -4264,7 +4264,7 @@ pmap_copy_page(vm_page_t src, vm_page_t struct pcpu *pc; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte1 = pc->pc_cmap_pte1; cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(>pc_cmap_lock); @@ -4299,7 +4299,7 @@ pmap_copy_pages(vm_page_t ma[], vm_offse int cnt; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte1 = pc->pc_cmap_pte1; cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(>pc_cmap_lock); @@ -5288,7 +5288,7 @@ pmap_flush_page(vm_page_t m) useclflushopt = (cpu_stdext_feature & CPUID_STDEXT_CLFLUSHOPT) != 0; if (useclflushopt || (cpu_feature & CPUID_CLFSH) != 0) { sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap_pte2 = pc->pc_cmap_pte2; mtx_lock(>pc_cmap_lock); if (*cmap_pte2) Modified: head/sys/i386/include/pcpu.h == --- head/sys/i386/include/pcpu.hSun Jan 29 14:29:02 2017 (r312951) +++ head/sys/i386/include/pcpu.hSun Jan 29 16:54:55 2017 (r312952) @@ -76,6 +76,7 @@ extern struct pcpu *pcpup; +#defineget_pcpu() (pcpup) #definePCPU_GET(member)(pcpup->pc_ ## member) #definePCPU_ADD(member, val) (pcpup->pc_ ## member += (val)) #definePCPU_INC(member)PCPU_ADD(member, 1) @@ -196,6 +197,15 @@ extern struct pcpu *pcpup; } \ } while (0) +#defineget_pcpu() __extension__ ({ \ + struct pcpu *__pc; \ + \ + __asm __volatile("movl %%fs:%1,%0" \ + : "=r" (__pc) \ + : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace; \ + __pc; \ +}) + #definePCPU_GET(member)__PCPU_GET(pc_ ## member) #definePCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val) #definePCPU_INC(member)__PCPU_INC(pc_ ## member) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r312792 - in head/sys/arm: arm include
Author: jah Date: Thu Jan 26 05:23:33 2017 New Revision: 312792 URL: https://svnweb.freebsd.org/changeset/base/312792 Log: Further cleanup of per-CPU armv6 pmap data: - Replace pcpu_find(curcpu) with get_pcpu(), which is much more direct. - Remove armv4 pcpu fields which I added in r286296 but never needed to use. - armv6 pc_qmap_addr was leftover from the old armv6 pmap implementation. Rename it and put it to use in the new one. Noted by: skra Reviewed by: skra MFC after:1 week Differential Revision:https://reviews.freebsd.org/D9312 Modified: head/sys/arm/arm/pmap-v6.c head/sys/arm/include/pcpu.h Modified: head/sys/arm/arm/pmap-v6.c == --- head/sys/arm/arm/pmap-v6.c Thu Jan 26 04:51:48 2017(r312791) +++ head/sys/arm/arm/pmap-v6.c Thu Jan 26 05:23:33 2017(r312792) @@ -1160,11 +1160,11 @@ pmap_bootstrap(vm_offset_t firstaddr) * Local CMAP1/CMAP2 are used for zeroing and copying pages. * Local CMAP2 is also used for data cache cleaning. */ - pc = pcpu_find(curcpu); + pc = get_pcpu(); mtx_init(>pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF); SYSMAP(caddr_t, pc->pc_cmap1_pte2p, pc->pc_cmap1_addr, 1); SYSMAP(caddr_t, pc->pc_cmap2_pte2p, pc->pc_cmap2_addr, 1); - SYSMAP(vm_offset_t, unused, pc->pc_qmap_addr, 1); + SYSMAP(vm_offset_t, pc->pc_qmap_pte2p, pc->pc_qmap_addr, 1); /* * Crashdump maps. @@ -1217,6 +1217,7 @@ pmap_init_reserved_pages(void) panic("%s: unable to allocate KVA", __func__); pc->pc_cmap1_pte2p = pt2map_entry(pages); pc->pc_cmap2_pte2p = pt2map_entry(pages + PAGE_SIZE); + pc->pc_qmap_pte2p = pt2map_entry(pages + (PAGE_SIZE * 2)); pc->pc_cmap1_addr = (caddr_t)pages; pc->pc_cmap2_addr = (caddr_t)(pages + PAGE_SIZE); pc->pc_qmap_addr = pages + (PAGE_SIZE * 2); @@ -1584,7 +1585,7 @@ pmap_pt2pg_zero(vm_page_t m) * to sync it even if the sync is only DSB. */ sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap2_pte2p = pc->pc_cmap2_pte2p; mtx_lock(>pc_cmap_lock); if (pte2_load(cmap2_pte2p) != 0) @@ -5661,7 +5662,7 @@ pmap_page_set_memattr(vm_page_t m, vm_me if (ma != oma) { pa = VM_PAGE_TO_PHYS(m); sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap2_pte2p = pc->pc_cmap2_pte2p; mtx_lock(>pc_cmap_lock); if (pte2_load(cmap2_pte2p) != 0) @@ -5754,7 +5755,7 @@ pmap_zero_page(vm_page_t m) struct pcpu *pc; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap2_pte2p = pc->pc_cmap2_pte2p; mtx_lock(>pc_cmap_lock); if (pte2_load(cmap2_pte2p) != 0) @@ -5781,7 +5782,7 @@ pmap_zero_page_area(vm_page_t m, int off struct pcpu *pc; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap2_pte2p = pc->pc_cmap2_pte2p; mtx_lock(>pc_cmap_lock); if (pte2_load(cmap2_pte2p) != 0) @@ -5811,7 +5812,7 @@ pmap_copy_page(vm_page_t src, vm_page_t struct pcpu *pc; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap1_pte2p = pc->pc_cmap1_pte2p; cmap2_pte2p = pc->pc_cmap2_pte2p; mtx_lock(>pc_cmap_lock); @@ -5846,7 +5847,7 @@ pmap_copy_pages(vm_page_t ma[], vm_offse int cnt; sched_pin(); - pc = pcpu_find(curcpu); + pc = get_pcpu(); cmap1_pte2p = pc->pc_cmap1_pte2p; cmap2_pte2p = pc->pc_cmap2_pte2p; mtx_lock(>pc_cmap_lock); @@ -5885,34 +5886,34 @@ pmap_copy_pages(vm_page_t ma[], vm_offse vm_offset_t pmap_quick_enter_page(vm_page_t m) { + struct pcpu *pc; pt2_entry_t *pte2p; - vm_offset_t qmap_addr; critical_enter(); - qmap_addr = PCPU_GET(qmap_addr); - pte2p = pt2map_entry(qmap_addr); + pc = get_pcpu(); + pte2p = pc->pc_qmap_pte2p; KASSERT(pte2_load(pte2p) == 0, ("%s: PTE2 busy", __func__)); pte2_store(pte2p, PTE2_KERN_NG(VM_PAGE_TO_PHYS(m), PTE2_AP_KRW, vm_page_pte2_attr(m))); - return (qmap_addr); + return (pc->pc_qmap_addr); } void pmap_quick_remove_page(vm_offset_t addr) { + struct pcpu *pc; pt2_entry_t *pte2p; - vm_offset_t qmap_addr; - qmap_addr = PCPU_GET(qmap_addr); - pte2p = pt2map_entry(qmap_addr); + pc = get_pcpu(); + pte2p = pc->pc_qmap_pte2p; - KASSERT(addr == qmap_addr, ("%s: invalid address", __func__)); + KASSERT(addr == pc->pc_qmap_addr, ("%s: invalid address", __func__)); KASSERT(pte2_load(pte2p) != 0, ("%s: PTE2 not in use", __func__));
svn commit: r312610 - in head/sys/arm: arm include
Author: jah Date: Sun Jan 22 00:46:04 2017 New Revision: 312610 URL: https://svnweb.freebsd.org/changeset/base/312610 Log: Like r310481 for i386, move the objects used to create temporary mappings for armv6 pmap zero and copy operations to the MD PCPU region. Change sysmap initialization to only allocate KVA pages for CPUs that are actually present. While here, collapse CMAP3 into CMAP2 (their use was mutually exclusive anyway) and "recover" some space in PCPU padding that has always been available due to 64-byte cacheline padding. Reviewed by: skra MFC after:1 week Differential Revision:https://reviews.freebsd.org/D9172 Modified: head/sys/arm/arm/pmap-v6.c head/sys/arm/include/pcpu.h Modified: head/sys/arm/arm/pmap-v6.c == --- head/sys/arm/arm/pmap-v6.c Sat Jan 21 23:35:54 2017(r312609) +++ head/sys/arm/arm/pmap-v6.c Sun Jan 22 00:46:04 2017(r312610) @@ -110,11 +110,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef SMP -#include -#else -#include -#endif #ifdef DDB #include @@ -296,16 +291,6 @@ vm_paddr_t first_managed_pa; /* * All those kernel PT submaps that BSD is so fond of */ -struct sysmaps { - struct mtx lock; - pt2_entry_t *CMAP1; - pt2_entry_t *CMAP2; - pt2_entry_t *CMAP3; - caddr_t CADDR1; - caddr_t CADDR2; - caddr_t CADDR3; -}; -static struct sysmaps sysmaps_pcpu[MAXCPU]; caddr_t _tmppt = 0; struct msgbuf *msgbufp = NULL; /* XXX move it to machdep.c */ @@ -1134,8 +1119,7 @@ void pmap_bootstrap(vm_offset_t firstaddr) { pt2_entry_t *unused __unused; - struct sysmaps *sysmaps; - u_int i; + struct pcpu *pc; /* * Initialize the kernel pmap (which is statically allocated). @@ -1174,15 +1158,13 @@ pmap_bootstrap(vm_offset_t firstaddr) /* * Local CMAP1/CMAP2 are used for zeroing and copying pages. -* Local CMAP3 is used for data cache cleaning. +* Local CMAP2 is also used for data cache cleaning. */ - for (i = 0; i < MAXCPU; i++) { - sysmaps = _pcpu[i]; - mtx_init(>lock, "SYSMAPS", NULL, MTX_DEF); - SYSMAP(caddr_t, sysmaps->CMAP1, sysmaps->CADDR1, 1); - SYSMAP(caddr_t, sysmaps->CMAP2, sysmaps->CADDR2, 1); - SYSMAP(caddr_t, sysmaps->CMAP3, sysmaps->CADDR3, 1); - } + pc = pcpu_find(curcpu); + mtx_init(>pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF); + SYSMAP(caddr_t, pc->pc_cmap1_pte2p, pc->pc_cmap1_addr, 1); + SYSMAP(caddr_t, pc->pc_cmap2_pte2p, pc->pc_cmap2_addr, 1); + SYSMAP(vm_offset_t, unused, pc->pc_qmap_addr, 1); /* * Crashdump maps. @@ -1215,19 +1197,32 @@ pmap_bootstrap(vm_offset_t firstaddr) } static void -pmap_init_qpages(void) +pmap_init_reserved_pages(void) { struct pcpu *pc; + vm_offset_t pages; int i; CPU_FOREACH(i) { pc = pcpu_find(i); - pc->pc_qmap_addr = kva_alloc(PAGE_SIZE); - if (pc->pc_qmap_addr == 0) + /* +* Skip if the mapping has already been initialized, +* i.e. this is the BSP. +*/ + if (pc->pc_cmap1_addr != 0) + continue; + mtx_init(>pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF); + pages = kva_alloc(PAGE_SIZE * 3); + if (pages == 0) panic("%s: unable to allocate KVA", __func__); + pc->pc_cmap1_pte2p = pt2map_entry(pages); + pc->pc_cmap2_pte2p = pt2map_entry(pages + PAGE_SIZE); + pc->pc_cmap1_addr = (caddr_t)pages; + pc->pc_cmap2_addr = (caddr_t)(pages + PAGE_SIZE); + pc->pc_qmap_addr = pages + (PAGE_SIZE * 2); } } -SYSINIT(qpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_qpages, NULL); +SYSINIT(rpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_reserved_pages, NULL); /* * The function can already be use in second initialization stage. @@ -1578,8 +1573,9 @@ pagezero(void *page) static __inline vm_paddr_t pmap_pt2pg_zero(vm_page_t m) { + pt2_entry_t *cmap2_pte2p; vm_paddr_t pa; - struct sysmaps *sysmaps; + struct pcpu *pc; pa = VM_PAGE_TO_PHYS(m); @@ -1588,20 +1584,27 @@ pmap_pt2pg_zero(vm_page_t m) * to sync it even if the sync is only DSB. */ sched_pin(); - sysmaps = _pcpu[PCPU_GET(cpuid)]; - mtx_lock(>lock); - if (pte2_load(sysmaps->CMAP2) != 0) + pc = pcpu_find(curcpu); + cmap2_pte2p = pc->pc_cmap2_pte2p; + mtx_lock(>pc_cmap_lock); + if (pte2_load(cmap2_pte2p) != 0) panic("%s: CMAP2 busy", __func__); - pte2_store(sysmaps->CMAP2, PTE2_KERN_NG(pa, PTE2_AP_KRW, + pte2_store(cmap2_pte2p,
svn commit: r312561 - stable/11/sys/i386/i386
Author: jah Date: Sat Jan 21 06:48:52 2017 New Revision: 312561 URL: https://svnweb.freebsd.org/changeset/base/312561 Log: MFC r312153, r312191 r312153: For i386 temporary mappings, unpin the thread before releasing the cmap lock. Releasing the lock first may result in the thread being immediately rescheduled and bound to the same CPU, only to unpin itself upon resuming execution. Noted by: skra (in review for armv6 equivalent) r312191: Add comment explaining relative order of sched_unpin() and mtx_unlock(). Suggested by: alc Modified: stable/11/sys/i386/i386/pmap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/i386/i386/pmap.c == --- stable/11/sys/i386/i386/pmap.c Fri Jan 20 22:41:16 2017 (r312560) +++ stable/11/sys/i386/i386/pmap.c Sat Jan 21 06:48:52 2017 (r312561) @@ -4231,8 +4231,14 @@ pmap_zero_page(vm_page_t m) invlcaddr(pc->pc_cmap_addr2); pagezero(pc->pc_cmap_addr2); *cmap_pte2 = 0; - mtx_unlock(>pc_cmap_lock); + + /* +* Unpin the thread before releasing the lock. Otherwise the thread +* could be rescheduled while still bound to the current CPU, only +* to unpin itself immediately upon resuming execution. +*/ sched_unpin(); + mtx_unlock(>pc_cmap_lock); } /* @@ -4261,8 +4267,8 @@ pmap_zero_page_area(vm_page_t m, int off else bzero(pc->pc_cmap_addr2 + off, size); *cmap_pte2 = 0; - mtx_unlock(>pc_cmap_lock); sched_unpin(); + mtx_unlock(>pc_cmap_lock); } /* @@ -4316,8 +4322,8 @@ pmap_copy_page(vm_page_t src, vm_page_t bcopy(pc->pc_cmap_addr1, pc->pc_cmap_addr2, PAGE_SIZE); *cmap_pte1 = 0; *cmap_pte2 = 0; - mtx_unlock(>pc_cmap_lock); sched_unpin(); + mtx_unlock(>pc_cmap_lock); } int unmapped_buf_allowed = 1; @@ -4364,8 +4370,8 @@ pmap_copy_pages(vm_page_t ma[], vm_offse } *cmap_pte1 = 0; *cmap_pte2 = 0; - mtx_unlock(>pc_cmap_lock); sched_unpin(); + mtx_unlock(>pc_cmap_lock); } /* @@ -5349,8 +5355,8 @@ pmap_flush_page(vm_page_t m) if (useclflushopt || cpu_vendor_id != CPU_VENDOR_INTEL) mfence(); *cmap_pte2 = 0; - mtx_unlock(>pc_cmap_lock); sched_unpin(); + mtx_unlock(>pc_cmap_lock); } else pmap_invalidate_cache(); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r312191 - head/sys/i386/i386
Author: jah Date: Sat Jan 14 19:35:36 2017 New Revision: 312191 URL: https://svnweb.freebsd.org/changeset/base/312191 Log: Add comment explaining relative order of sched_unpin() and mtx_unlock(). Suggested by: alc MFC after:1 week Modified: head/sys/i386/i386/pmap.c Modified: head/sys/i386/i386/pmap.c == --- head/sys/i386/i386/pmap.c Sat Jan 14 18:04:12 2017(r312190) +++ head/sys/i386/i386/pmap.c Sat Jan 14 19:35:36 2017(r312191) @@ -4216,6 +4216,12 @@ pmap_zero_page(vm_page_t m) invlcaddr(pc->pc_cmap_addr2); pagezero(pc->pc_cmap_addr2); *cmap_pte2 = 0; + + /* +* Unpin the thread before releasing the lock. Otherwise the thread +* could be rescheduled while still bound to the current CPU, only +* to unpin itself immediately upon resuming execution. +*/ sched_unpin(); mtx_unlock(>pc_cmap_lock); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r312153 - head/sys/i386/i386
Author: jah Date: Sat Jan 14 09:56:01 2017 New Revision: 312153 URL: https://svnweb.freebsd.org/changeset/base/312153 Log: For i386 temporary mappings, unpin the thread before releasing the cmap lock. Releasing the lock first may result in the thread being immediately rescheduled and bound to the same CPU, only to unpin itself upon resuming execution. Noted by: skra (in review for armv6 equivalent) MFC after:1 week Modified: head/sys/i386/i386/pmap.c Modified: head/sys/i386/i386/pmap.c == --- head/sys/i386/i386/pmap.c Sat Jan 14 09:47:06 2017(r312152) +++ head/sys/i386/i386/pmap.c Sat Jan 14 09:56:01 2017(r312153) @@ -4216,8 +4216,8 @@ pmap_zero_page(vm_page_t m) invlcaddr(pc->pc_cmap_addr2); pagezero(pc->pc_cmap_addr2); *cmap_pte2 = 0; - mtx_unlock(>pc_cmap_lock); sched_unpin(); + mtx_unlock(>pc_cmap_lock); } /* @@ -4244,8 +4244,8 @@ pmap_zero_page_area(vm_page_t m, int off else bzero(pc->pc_cmap_addr2 + off, size); *cmap_pte2 = 0; - mtx_unlock(>pc_cmap_lock); sched_unpin(); + mtx_unlock(>pc_cmap_lock); } /* @@ -4275,8 +4275,8 @@ pmap_copy_page(vm_page_t src, vm_page_t bcopy(pc->pc_cmap_addr1, pc->pc_cmap_addr2, PAGE_SIZE); *cmap_pte1 = 0; *cmap_pte2 = 0; - mtx_unlock(>pc_cmap_lock); sched_unpin(); + mtx_unlock(>pc_cmap_lock); } int unmapped_buf_allowed = 1; @@ -4323,8 +4323,8 @@ pmap_copy_pages(vm_page_t ma[], vm_offse } *cmap_pte1 = 0; *cmap_pte2 = 0; - mtx_unlock(>pc_cmap_lock); sched_unpin(); + mtx_unlock(>pc_cmap_lock); } /* @@ -5310,8 +5310,8 @@ pmap_flush_page(vm_page_t m) if (useclflushopt || cpu_vendor_id != CPU_VENDOR_INTEL) mfence(); *cmap_pte2 = 0; - mtx_unlock(>pc_cmap_lock); sched_unpin(); + mtx_unlock(>pc_cmap_lock); } else pmap_invalidate_cache(); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r311653 - in stable/11/sys/i386: i386 include
Author: jah Date: Sat Jan 7 18:54:57 2017 New Revision: 311653 URL: https://svnweb.freebsd.org/changeset/base/311653 Log: MFC r310481: Move the objects used to create temporary mappings for i386 pmap zero and copy operations to the MD PCPU region. Change sysmap initialization to only allocate KVA pages for CPUs that are actually present. As a minor optimization, this also prevents false sharing between adjacent sysmap objects since the pcpu struct is already cacheline-aligned. While here, move pc_qmap_addr initialization for the BSP into pmap_bootstrap(), which allows use of pmap_quick* functions during early boot. Reviewed by: kib Differential Revision:https://reviews.freebsd.org/D8833 Modified: stable/11/sys/i386/i386/pmap.c stable/11/sys/i386/include/pcpu.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/i386/i386/pmap.c == --- stable/11/sys/i386/i386/pmap.c Sat Jan 7 17:37:39 2017 (r311652) +++ stable/11/sys/i386/i386/pmap.c Sat Jan 7 18:54:57 2017 (r311653) @@ -257,14 +257,6 @@ vm_offset_t pv_vafree; /* freelist sto /* * All those kernel PT submaps that BSD is so fond of */ -struct sysmaps { - struct mtx lock; - pt_entry_t *CMAP1; - pt_entry_t *CMAP2; - caddr_t CADDR1; - caddr_t CADDR2; -}; -static struct sysmaps sysmaps_pcpu[MAXCPU]; pt_entry_t *CMAP3; static pd_entry_t *KPTD; caddr_t ptvmmap = 0; @@ -380,7 +372,7 @@ pmap_bootstrap(vm_paddr_t firstaddr) { vm_offset_t va; pt_entry_t *pte, *unused; - struct sysmaps *sysmaps; + struct pcpu *pc; int i; /* @@ -442,16 +434,19 @@ pmap_bootstrap(vm_paddr_t firstaddr) va = virtual_avail; pte = vtopte(va); + /* +* Initialize temporary map objects on the current CPU for use +* during early boot. * CMAP1/CMAP2 are used for zeroing and copying pages. * CMAP3 is used for the idle process page zeroing. */ - for (i = 0; i < MAXCPU; i++) { - sysmaps = _pcpu[i]; - mtx_init(>lock, "SYSMAPS", NULL, MTX_DEF); - SYSMAP(caddr_t, sysmaps->CMAP1, sysmaps->CADDR1, 1) - SYSMAP(caddr_t, sysmaps->CMAP2, sysmaps->CADDR2, 1) - } + pc = pcpu_find(curcpu); + mtx_init(>pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF); + SYSMAP(caddr_t, pc->pc_cmap_pte1, pc->pc_cmap_addr1, 1) + SYSMAP(caddr_t, pc->pc_cmap_pte2, pc->pc_cmap_addr2, 1) + SYSMAP(vm_offset_t, pte, pc->pc_qmap_addr, 1) + SYSMAP(caddr_t, CMAP3, CADDR3, 1) /* @@ -521,20 +516,33 @@ pmap_bootstrap(vm_paddr_t firstaddr) } static void -pmap_init_qpages(void) +pmap_init_reserved_pages(void) { struct pcpu *pc; + vm_offset_t pages; int i; CPU_FOREACH(i) { pc = pcpu_find(i); - pc->pc_qmap_addr = kva_alloc(PAGE_SIZE); - if (pc->pc_qmap_addr == 0) - panic("pmap_init_qpages: unable to allocate KVA"); + /* +* Skip if the mapping has already been initialized, +* i.e. this is the BSP. +*/ + if (pc->pc_cmap_addr1 != 0) + continue; + mtx_init(>pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF); + pages = kva_alloc(PAGE_SIZE * 3); + if (pages == 0) + panic("%s: unable to allocate KVA", __func__); + pc->pc_cmap_pte1 = vtopte(pages); + pc->pc_cmap_pte2 = vtopte(pages + PAGE_SIZE); + pc->pc_cmap_addr1 = (caddr_t)pages; + pc->pc_cmap_addr2 = (caddr_t)(pages + PAGE_SIZE); + pc->pc_qmap_addr = pages + (PAGE_SIZE * 2); } } - -SYSINIT(qpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_qpages, NULL); + +SYSINIT(rpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_reserved_pages, NULL); /* * Setup the PAT MSR. @@ -4209,20 +4217,22 @@ pagezero(void *page) void pmap_zero_page(vm_page_t m) { - struct sysmaps *sysmaps; + pt_entry_t *cmap_pte2; + struct pcpu *pc; - sysmaps = _pcpu[PCPU_GET(cpuid)]; - mtx_lock(>lock); - if (*sysmaps->CMAP2) - panic("pmap_zero_page: CMAP2 busy"); sched_pin(); - *sysmaps->CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | + pc = pcpu_find(curcpu); + cmap_pte2 = pc->pc_cmap_pte2; + mtx_lock(>pc_cmap_lock); + if (*cmap_pte2) + panic("pmap_zero_page: CMAP2 busy"); + *cmap_pte2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | pmap_cache_bits(m->md.pat_mode, 0); - invlcaddr(sysmaps->CADDR2); - pagezero(sysmaps->CADDR2); - *sysmaps->CMAP2 = 0; + invlcaddr(pc->pc_cmap_addr2); +
svn commit: r310481 - in head/sys/i386: i386 include
Author: jah Date: Fri Dec 23 15:14:56 2016 New Revision: 310481 URL: https://svnweb.freebsd.org/changeset/base/310481 Log: Move the objects used to create temporary mappings for i386 pmap zero and copy operations to the MD PCPU region. Change sysmap initialization to only allocate KVA pages for CPUs that are actually present. As a minor optimization, this also prevents false sharing between adjacent sysmap objects since the pcpu struct is already cacheline-aligned. While here, move pc_qmap_addr initialization for the BSP into pmap_bootstrap(), which allows use of pmap_quick* functions during early boot. Reviewed by: kib MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D8833 Modified: head/sys/i386/i386/pmap.c head/sys/i386/include/pcpu.h Modified: head/sys/i386/i386/pmap.c == --- head/sys/i386/i386/pmap.c Fri Dec 23 15:05:41 2016(r310480) +++ head/sys/i386/i386/pmap.c Fri Dec 23 15:14:56 2016(r310481) @@ -257,14 +257,6 @@ vm_offset_t pv_vafree; /* freelist sto /* * All those kernel PT submaps that BSD is so fond of */ -struct sysmaps { - struct mtx lock; - pt_entry_t *CMAP1; - pt_entry_t *CMAP2; - caddr_t CADDR1; - caddr_t CADDR2; -}; -static struct sysmaps sysmaps_pcpu[MAXCPU]; pt_entry_t *CMAP3; static pd_entry_t *KPTD; caddr_t ptvmmap = 0; @@ -379,7 +371,7 @@ pmap_bootstrap(vm_paddr_t firstaddr) { vm_offset_t va; pt_entry_t *pte, *unused; - struct sysmaps *sysmaps; + struct pcpu *pc; int i; /* @@ -441,16 +433,19 @@ pmap_bootstrap(vm_paddr_t firstaddr) va = virtual_avail; pte = vtopte(va); + /* +* Initialize temporary map objects on the current CPU for use +* during early boot. * CMAP1/CMAP2 are used for zeroing and copying pages. * CMAP3 is used for the boot-time memory test. */ - for (i = 0; i < MAXCPU; i++) { - sysmaps = _pcpu[i]; - mtx_init(>lock, "SYSMAPS", NULL, MTX_DEF); - SYSMAP(caddr_t, sysmaps->CMAP1, sysmaps->CADDR1, 1) - SYSMAP(caddr_t, sysmaps->CMAP2, sysmaps->CADDR2, 1) - } + pc = pcpu_find(curcpu); + mtx_init(>pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF); + SYSMAP(caddr_t, pc->pc_cmap_pte1, pc->pc_cmap_addr1, 1) + SYSMAP(caddr_t, pc->pc_cmap_pte2, pc->pc_cmap_addr2, 1) + SYSMAP(vm_offset_t, pte, pc->pc_qmap_addr, 1) + SYSMAP(caddr_t, CMAP3, CADDR3, 1); /* @@ -520,20 +515,33 @@ pmap_bootstrap(vm_paddr_t firstaddr) } static void -pmap_init_qpages(void) +pmap_init_reserved_pages(void) { struct pcpu *pc; + vm_offset_t pages; int i; CPU_FOREACH(i) { pc = pcpu_find(i); - pc->pc_qmap_addr = kva_alloc(PAGE_SIZE); - if (pc->pc_qmap_addr == 0) - panic("pmap_init_qpages: unable to allocate KVA"); + /* +* Skip if the mapping has already been initialized, +* i.e. this is the BSP. +*/ + if (pc->pc_cmap_addr1 != 0) + continue; + mtx_init(>pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF); + pages = kva_alloc(PAGE_SIZE * 3); + if (pages == 0) + panic("%s: unable to allocate KVA", __func__); + pc->pc_cmap_pte1 = vtopte(pages); + pc->pc_cmap_pte2 = vtopte(pages + PAGE_SIZE); + pc->pc_cmap_addr1 = (caddr_t)pages; + pc->pc_cmap_addr2 = (caddr_t)(pages + PAGE_SIZE); + pc->pc_qmap_addr = pages + (PAGE_SIZE * 2); } } - -SYSINIT(qpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_qpages, NULL); + +SYSINIT(rpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_reserved_pages, NULL); /* * Setup the PAT MSR. @@ -4194,20 +4202,22 @@ pagezero(void *page) void pmap_zero_page(vm_page_t m) { - struct sysmaps *sysmaps; + pt_entry_t *cmap_pte2; + struct pcpu *pc; - sysmaps = _pcpu[PCPU_GET(cpuid)]; - mtx_lock(>lock); - if (*sysmaps->CMAP2) - panic("pmap_zero_page: CMAP2 busy"); sched_pin(); - *sysmaps->CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | + pc = pcpu_find(curcpu); + cmap_pte2 = pc->pc_cmap_pte2; + mtx_lock(>pc_cmap_lock); + if (*cmap_pte2) + panic("pmap_zero_page: CMAP2 busy"); + *cmap_pte2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | pmap_cache_bits(m->md.pat_mode, 0); - invlcaddr(sysmaps->CADDR2); - pagezero(sysmaps->CADDR2); - *sysmaps->CMAP2 = 0; + invlcaddr(pc->pc_cmap_addr2); + pagezero(pc->pc_cmap_addr2); + *cmap_pte2 = 0; + mtx_unlock(>pc_cmap_lock);
svn commit: r303814 - head/sys/powerpc/powerpc
Author: jah Date: Sun Aug 7 15:50:08 2016 New Revision: 303814 URL: https://svnweb.freebsd.org/changeset/base/303814 Log: powerpc busdma: Use pmap_quick_enter_page()/pmap_quick_remove_page() to handle bouncing of unmapped buffers. Also treat userspace buffers as unmapped, to avoid borrowing the UVA for copies. This allows sync'ing userspace buffers outside the context of the owning process, and sync'ing bounced maps in non-sleepable contexts. This change is equivalent to r286787 for x86. Reviewed by: jhibbits Differential Revision:https://reviews.freebsd.org/D3989 Modified: head/sys/powerpc/powerpc/busdma_machdep.c Modified: head/sys/powerpc/powerpc/busdma_machdep.c == --- head/sys/powerpc/powerpc/busdma_machdep.c Sun Aug 7 12:51:13 2016 (r303813) +++ head/sys/powerpc/powerpc/busdma_machdep.c Sun Aug 7 15:50:08 2016 (r303814) @@ -87,7 +87,8 @@ struct bounce_page { vm_offset_t vaddr; /* kva of bounce buffer */ bus_addr_t busaddr;/* Physical address */ vm_offset_t datavaddr; /* kva of client data */ - bus_addr_t dataaddr; /* client physical address */ + vm_page_t datapage; /* physical page of client data */ + vm_offset_t dataoffs; /* page offset of client data */ bus_size_t datacount; /* client data count */ STAILQ_ENTRY(bounce_page) links; }; @@ -585,7 +586,8 @@ _bus_dmamap_count_phys(bus_dma_tag_t dma while (buflen != 0) { sgsize = MIN(buflen, dmat->maxsegsz); if (run_filter(dmat, curaddr) != 0) { - sgsize = MIN(sgsize, PAGE_SIZE); + sgsize = MIN(sgsize, + PAGE_SIZE - (curaddr & PAGE_MASK)); map->pagesneeded++; } curaddr += sgsize; @@ -736,7 +738,7 @@ _bus_dmamap_load_phys(bus_dma_tag_t dmat curaddr = buf; sgsize = MIN(buflen, dmat->maxsegsz); if (map->pagesneeded != 0 && run_filter(dmat, curaddr)) { - sgsize = MIN(sgsize, PAGE_SIZE); + sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK)); curaddr = add_bounce_page(dmat, map, 0, curaddr, sgsize); } @@ -779,7 +781,7 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dm { bus_size_t sgsize; bus_addr_t curaddr; - vm_offset_t vaddr; + vm_offset_t kvaddr, vaddr; int error; if (segs == NULL) @@ -802,20 +804,23 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dm /* * Get the physical address for this segment. */ - if (pmap == kernel_pmap) + if (pmap == kernel_pmap) { curaddr = pmap_kextract(vaddr); - else + kvaddr = vaddr; + } else { curaddr = pmap_extract(pmap, vaddr); + kvaddr = 0; + } /* * Compute the segment size, and adjust counts. */ max_sgsize = MIN(buflen, dmat->maxsegsz); - sgsize = PAGE_SIZE - ((vm_offset_t)curaddr & PAGE_MASK); + sgsize = PAGE_SIZE - (curaddr & PAGE_MASK); if (map->pagesneeded != 0 && run_filter(dmat, curaddr)) { sgsize = roundup2(sgsize, dmat->alignment); sgsize = MIN(sgsize, max_sgsize); - curaddr = add_bounce_page(dmat, map, vaddr, curaddr, + curaddr = add_bounce_page(dmat, map, kvaddr, curaddr, sgsize); } else { sgsize = MIN(sgsize, max_sgsize); @@ -893,8 +898,10 @@ void _bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op) { struct bounce_page *bpage; + vm_offset_t datavaddr, tempvaddr; if ((bpage = STAILQ_FIRST(>bpages)) != NULL) { + /* * Handle data bouncing. We might also * want to add support for invalidating @@ -905,14 +912,20 @@ _bus_dmamap_sync(bus_dma_tag_t dmat, bus if (op & BUS_DMASYNC_PREWRITE) { while (bpage != NULL) { - if (bpage->datavaddr != 0) - bcopy((void *)bpage->datavaddr, - (void *)bpage->vaddr, - bpage->datacount); - else - physcopyout(bpage->dataaddr, -
svn commit: r300948 - stable/10/sys/dev/iicbus
Author: jah Date: Sun May 29 07:14:51 2016 New Revision: 300948 URL: https://svnweb.freebsd.org/changeset/base/300948 Log: MFC r300258: iic_rdwr_data->nmsgs is uint32_t, so limit the allowable number of messages to prevent memory exhaustion and short allocations on 32-bit systems. Since iicrdwr is intended to be a workalike of a Linux i2c-dev call, use the same limit of 42 that Linux uses. Also check the return value of copyin(9) to prevent unnecessary allocation in the failure case. Modified: stable/10/sys/dev/iicbus/iic.c stable/10/sys/dev/iicbus/iic.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/iicbus/iic.c == --- stable/10/sys/dev/iicbus/iic.c Sun May 29 07:01:12 2016 (r300947) +++ stable/10/sys/dev/iicbus/iic.c Sun May 29 07:14:51 2016 (r300948) @@ -299,9 +299,16 @@ iicrdwr(struct iic_cdevpriv *priv, struc parent = device_get_parent(iicdev); error = 0; + if (d->nmsgs > IIC_RDRW_MAX_MSGS) + return (EINVAL); + buf = malloc(sizeof(*d->msgs) * d->nmsgs, M_IIC, M_WAITOK); error = copyin(d->msgs, buf, sizeof(*d->msgs) * d->nmsgs); + if (error != 0) { + free(buf, M_IIC); + return (error); + } /* Alloc kernel buffers for userland data, copyin write data */ usrbufs = malloc(sizeof(void *) * d->nmsgs, M_IIC, M_WAITOK | M_ZERO); @@ -317,6 +324,8 @@ iicrdwr(struct iic_cdevpriv *priv, struc m->buf = NULL; if (error != 0) continue; + + /* m->len is uint16_t, so allocation size is capped at 64K. */ m->buf = malloc(m->len, M_IIC, M_WAITOK); if (!(m->flags & IIC_M_RD)) error = copyin(usrbufs[i], m->buf, m->len); Modified: stable/10/sys/dev/iicbus/iic.h == --- stable/10/sys/dev/iicbus/iic.h Sun May 29 07:01:12 2016 (r300947) +++ stable/10/sys/dev/iicbus/iic.h Sun May 29 07:14:51 2016 (r300948) @@ -56,6 +56,8 @@ struct iic_rdwr_data { uint32_t nmsgs; }; +#define IIC_RDRW_MAX_MSGS 42 + #define I2CSTART _IOW('i', 1, struct iiccmd) /* start condition */ #define I2CSTOP_IO('i', 2) /* stop condition */ #define I2CRSTCARD _IOW('i', 3, struct iiccmd) /* reset the card */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r300258 - head/sys/dev/iicbus
Author: jah Date: Fri May 20 03:03:04 2016 New Revision: 300258 URL: https://svnweb.freebsd.org/changeset/base/300258 Log: iic_rdwr_data->nmsgs is uint32_t, so limit the allowable number of messages to prevent memory exhaustion and short allocations on 32-bit systems. Since iicrdwr is intended to be a workalike of a Linux i2c-dev call, use the same limit of 42 that Linux uses. Also check the return value of copyin(9) to prevent unnecessary allocation in the failure case. Submitted by: ngie Reviewed by: kib MFC after:1 week Differential Revision:https://reviews.freebsd.org/D5155 Modified: head/sys/dev/iicbus/iic.c head/sys/dev/iicbus/iic.h Modified: head/sys/dev/iicbus/iic.c == --- head/sys/dev/iicbus/iic.c Fri May 20 01:41:47 2016(r300257) +++ head/sys/dev/iicbus/iic.c Fri May 20 03:03:04 2016(r300258) @@ -300,9 +300,16 @@ iicrdwr(struct iic_cdevpriv *priv, struc parent = device_get_parent(iicdev); error = 0; + if (d->nmsgs > IIC_RDRW_MAX_MSGS) + return (EINVAL); + buf = malloc(sizeof(*d->msgs) * d->nmsgs, M_IIC, M_WAITOK); error = copyin(d->msgs, buf, sizeof(*d->msgs) * d->nmsgs); + if (error != 0) { + free(buf, M_IIC); + return (error); + } /* Alloc kernel buffers for userland data, copyin write data */ usrbufs = malloc(sizeof(void *) * d->nmsgs, M_IIC, M_WAITOK | M_ZERO); @@ -318,6 +325,8 @@ iicrdwr(struct iic_cdevpriv *priv, struc m->buf = NULL; if (error != 0) continue; + + /* m->len is uint16_t, so allocation size is capped at 64K. */ m->buf = malloc(m->len, M_IIC, M_WAITOK); if (!(m->flags & IIC_M_RD)) error = copyin(usrbufs[i], m->buf, m->len); Modified: head/sys/dev/iicbus/iic.h == --- head/sys/dev/iicbus/iic.h Fri May 20 01:41:47 2016(r300257) +++ head/sys/dev/iicbus/iic.h Fri May 20 03:03:04 2016(r300258) @@ -56,6 +56,8 @@ struct iic_rdwr_data { uint32_t nmsgs; }; +#define IIC_RDRW_MAX_MSGS 42 + #define I2CSTART _IOW('i', 1, struct iiccmd) /* start condition */ #define I2CSTOP_IO('i', 2) /* stop condition */ #define I2CRSTCARD _IOW('i', 3, struct iiccmd) /* reset the card */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r290120 - in head/sys/arm: arm include
Author: jah Date: Wed Oct 28 21:17:38 2015 New Revision: 290120 URL: https://svnweb.freebsd.org/changeset/base/290120 Log: Retire pmap_dmap_iscurrent(). It is only a wrapper around pmap_is_current(), and is no longer called. Modified: head/sys/arm/arm/pmap-v6-new.c head/sys/arm/arm/pmap-v6.c head/sys/arm/include/pmap-v6.h head/sys/arm/include/pmap.h Modified: head/sys/arm/arm/pmap-v6-new.c == --- head/sys/arm/arm/pmap-v6-new.c Wed Oct 28 19:11:06 2015 (r290119) +++ head/sys/arm/arm/pmap-v6-new.c Wed Oct 28 21:17:38 2015 (r290120) @@ -5947,13 +5947,6 @@ pmap_activate(struct thread *td) critical_exit(); } -int -pmap_dmap_iscurrent(pmap_t pmap) -{ - - return (pmap_is_current(pmap)); -} - /* * Perform the pmap work for mincore. */ Modified: head/sys/arm/arm/pmap-v6.c == --- head/sys/arm/arm/pmap-v6.c Wed Oct 28 19:11:06 2015(r290119) +++ head/sys/arm/arm/pmap-v6.c Wed Oct 28 21:17:38 2015(r290120) @@ -5398,12 +5398,6 @@ pmap_map_chunk(vm_offset_t l1pt, vm_offs } -int -pmap_dmap_iscurrent(pmap_t pmap) -{ - return(pmap_is_current(pmap)); -} - void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma) { Modified: head/sys/arm/include/pmap-v6.h == --- head/sys/arm/include/pmap-v6.h Wed Oct 28 19:11:06 2015 (r290119) +++ head/sys/arm/include/pmap-v6.h Wed Oct 28 21:17:38 2015 (r290120) @@ -265,11 +265,6 @@ void pmap_devmap_bootstrap(const struct #definePMAP_DOMAIN_KERNEL 0 /* The kernel uses domain #0 */ /* - * sys/arm/arm/busdma_machdep-v6.c - */ -int pmap_dmap_iscurrent(pmap_t pmap); - -/* * sys/arm/arm/cpufunc.c */ void pmap_pte_init_mmu_v6(void); Modified: head/sys/arm/include/pmap.h == --- head/sys/arm/include/pmap.h Wed Oct 28 19:11:06 2015(r290119) +++ head/sys/arm/include/pmap.h Wed Oct 28 21:17:38 2015(r290120) @@ -277,7 +277,6 @@ void pmap_map_entry(vm_offset_t l1pt, vm_offset_t va, vm_offset_t pa, int prot, int cache); int pmap_fault_fixup(pmap_t, vm_offset_t, vm_prot_t, int); -int pmap_dmap_iscurrent(pmap_t pmap); /* * Definitions for MMU domains ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r289826 - head/sys/vm
Author: jah Date: Fri Oct 23 12:06:06 2015 New Revision: 289826 URL: https://svnweb.freebsd.org/changeset/base/289826 Log: Fix capitalization Modified: head/sys/vm/vm_page.h Modified: head/sys/vm/vm_page.h == --- head/sys/vm/vm_page.h Fri Oct 23 12:03:25 2015(r289825) +++ head/sys/vm/vm_page.h Fri Oct 23 12:06:06 2015(r289826) @@ -376,7 +376,7 @@ extern long first_page; /* first physi #define VM_PAGE_TO_PHYS(entry) ((entry)->phys_addr) /* - * PHYS_TO_VM_PAGE() Returns the vm_page_t object that represents a memory + * PHYS_TO_VM_PAGE() returns the vm_page_t object that represents a memory * page to which the given physical address belongs. The correct vm_page_t * object is returned for addresses that are not page-aligned. */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r289825 - in head/sys: arm/arm arm64/arm64 vm x86/x86
Author: jah Date: Fri Oct 23 12:03:25 2015 New Revision: 289825 URL: https://svnweb.freebsd.org/changeset/base/289825 Log: Remove unclear comment about address truncation in busdma. Add (hopefully much clearer) comment at declaration of PHYS_TO_VM_PAGE(). Noted by: avg Modified: head/sys/arm/arm/busdma_machdep-v6.c head/sys/arm/arm/busdma_machdep.c head/sys/arm64/arm64/busdma_bounce.c head/sys/vm/vm_page.h head/sys/x86/x86/busdma_bounce.c Modified: head/sys/arm/arm/busdma_machdep-v6.c == --- head/sys/arm/arm/busdma_machdep-v6.cFri Oct 23 11:45:38 2015 (r289824) +++ head/sys/arm/arm/busdma_machdep-v6.cFri Oct 23 12:03:25 2015 (r289825) @@ -1089,10 +1089,6 @@ _bus_dmamap_load_phys(bus_dma_tag_t dmat sl++; sl->vaddr = 0; sl->datacount = sgsize; - /* -* PHYS_TO_VM_PAGE() will truncate -* unaligned addresses. -*/ sl->pages = PHYS_TO_VM_PAGE(curaddr); sl->dataoffs = curaddr & PAGE_MASK; } else @@ -1214,10 +1210,6 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dm sl++; sl->vaddr = kvaddr; sl->datacount = sgsize; - /* -* PHYS_TO_VM_PAGE() will truncate -* unaligned addresses. -*/ sl->pages = PHYS_TO_VM_PAGE(curaddr); sl->dataoffs = curaddr & PAGE_MASK; } else @@ -1687,7 +1679,6 @@ add_bounce_page(bus_dma_tag_t dmat, bus_ bpage->busaddr |= addr & PAGE_MASK; } bpage->datavaddr = vaddr; - /* PHYS_TO_VM_PAGE() will truncate unaligned addresses. */ bpage->datapage = PHYS_TO_VM_PAGE(addr); bpage->dataoffs = addr & PAGE_MASK; bpage->datacount = size; Modified: head/sys/arm/arm/busdma_machdep.c == --- head/sys/arm/arm/busdma_machdep.c Fri Oct 23 11:45:38 2015 (r289824) +++ head/sys/arm/arm/busdma_machdep.c Fri Oct 23 12:03:25 2015 (r289825) @@ -993,10 +993,6 @@ _bus_dmamap_load_phys(bus_dma_tag_t dmat sl++; sl->vaddr = 0; sl->datacount = sgsize; - /* -* PHYS_TO_VM_PAGE() will truncate -* unaligned addresses. -*/ sl->pages = PHYS_TO_VM_PAGE(curaddr); sl->dataoffs = curaddr & PAGE_MASK; } else @@ -1108,10 +1104,6 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dm sl++; sl->vaddr = kvaddr; sl->datacount = sgsize; - /* -* PHYS_TO_VM_PAGE() will truncate -* unaligned addresses. -*/ sl->pages = PHYS_TO_VM_PAGE(curaddr); sl->dataoffs = curaddr & PAGE_MASK; } else @@ -1541,7 +1533,6 @@ add_bounce_page(bus_dma_tag_t dmat, bus_ bpage->busaddr |= addr & PAGE_MASK; } bpage->datavaddr = vaddr; - /* PHYS_TO_VM_PAGE() will truncate unaligned addresses. */ bpage->datapage = PHYS_TO_VM_PAGE(addr); bpage->dataoffs = addr & PAGE_MASK; bpage->datacount = size; Modified: head/sys/arm64/arm64/busdma_bounce.c == --- head/sys/arm64/arm64/busdma_bounce.cFri Oct 23 11:45:38 2015 (r289824) +++ head/sys/arm64/arm64/busdma_bounce.cFri Oct 23 12:03:25 2015 (r289825) @@ -1009,7 +1009,6 @@ add_bounce_page(bus_dma_tag_t dmat, bus_ bpage->busaddr |= addr & PAGE_MASK; } bpage->datavaddr = vaddr; - /* PHYS_TO_VM_PAGE() will truncate unaligned addresses. */ bpage->datapage = PHYS_TO_VM_PAGE(addr); bpage->dataoffs = addr & PAGE_MASK; bpage->datacount = size; Modified: head/sys/vm/vm_page.h == --- head/sys/vm/vm_page.h Fri Oct 23 11:45:38 2015(r289824) +++ head/sys/vm/vm_page.h Fri Oct 23 12:03:25 2015(r289825) @@ -375,6 +375,11 @@
svn commit: r289759 - in head/sys/arm: arm include
Author: jah Date: Thu Oct 22 16:38:01 2015 New Revision: 289759 URL: https://svnweb.freebsd.org/changeset/base/289759 Log: Use pmap_quick* functions in armv6 busdma, for bounce buffers and cache maintenance. This makes it safe to sync buffers that have no VA mapping associated with the busdma map, but may have other mappings, possibly on different CPUs. This also makes it safe to sync unmapped bounce buffers in non-sleepable thread contexts. Similar to r286787 for x86, this treats userspace buffers the same as unmapped buffers and no longer borrows the UVA for sync operations. Submitted by: Svatopluk Kraus(earlier revision) Tested by:Svatopluk Kraus Differential Revision:https://reviews.freebsd.org/D3869 Modified: head/sys/arm/arm/busdma_machdep-v6.c head/sys/arm/include/cpu-v6.h Modified: head/sys/arm/arm/busdma_machdep-v6.c == --- head/sys/arm/arm/busdma_machdep-v6.cThu Oct 22 15:42:53 2015 (r289758) +++ head/sys/arm/arm/busdma_machdep-v6.cThu Oct 22 16:38:01 2015 (r289759) @@ -61,7 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include #define MAX_BPAGES 64 @@ -104,14 +104,16 @@ struct bounce_page { vm_offset_t vaddr; /* kva of bounce buffer */ bus_addr_t busaddr;/* Physical address */ vm_offset_t datavaddr; /* kva of client data */ - bus_addr_t dataaddr; /* client physical address */ + vm_page_t datapage; /* physical page of client data */ + vm_offset_t dataoffs; /* page offset of client data */ bus_size_t datacount; /* client data count */ STAILQ_ENTRY(bounce_page) links; }; struct sync_list { vm_offset_t vaddr; /* kva of client data */ - bus_addr_t busaddr;/* client physical address */ + vm_page_t pages; /* starting page of client data */ + vm_offset_t dataoffs; /* page offset of client data */ bus_size_t datacount; /* client data count */ }; @@ -181,7 +183,6 @@ struct bus_dmamap { intpagesreserved; bus_dma_tag_t dmat; struct memdesc mem; - pmap_t pmap; bus_dmamap_callback_t *callback; void *callback_arg; int flags; @@ -206,12 +207,14 @@ static bus_addr_t add_bounce_page(bus_dm vm_offset_t vaddr, bus_addr_t addr, bus_size_t size); static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage); -static void _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, -void *buf, bus_size_t buflen, int flags); +static void _bus_dmamap_count_pages(bus_dma_tag_t dmat, pmap_t pmap, +bus_dmamap_t map, void *buf, bus_size_t buflen, int flags); static void _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf, bus_size_t buflen, int flags); static int _bus_dmamap_reserve_pages(bus_dma_tag_t dmat, bus_dmamap_t map, int flags); +static void dma_preread_safe(vm_offset_t va, vm_paddr_t pa, vm_size_t size); +static void dma_dcache_sync(struct sync_list *sl, bus_dmasync_op_t op); static busdma_bufalloc_t coherent_allocator; /* Cache of coherent buffers */ static busdma_bufalloc_t standard_allocator; /* Cache of standard buffers */ @@ -896,7 +899,8 @@ _bus_dmamap_count_phys(bus_dma_tag_t dma while (buflen != 0) { sgsize = MIN(buflen, dmat->maxsegsz); if (must_bounce(dmat, map, curaddr, sgsize) != 0) { - sgsize = MIN(sgsize, PAGE_SIZE); + sgsize = MIN(sgsize, + PAGE_SIZE - (curaddr & PAGE_MASK)); map->pagesneeded++; } curaddr += sgsize; @@ -907,7 +911,7 @@ _bus_dmamap_count_phys(bus_dma_tag_t dma } static void -_bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, +_bus_dmamap_count_pages(bus_dma_tag_t dmat, pmap_t pmap, bus_dmamap_t map, void *buf, bus_size_t buflen, int flags) { vm_offset_t vaddr; @@ -927,10 +931,10 @@ _bus_dmamap_count_pages(bus_dma_tag_t dm vendaddr = (vm_offset_t)buf + buflen; while (vaddr < vendaddr) { - if (__predict_true(map->pmap == kernel_pmap)) + if (__predict_true(pmap == kernel_pmap)) paddr = pmap_kextract(vaddr); else - paddr = pmap_extract(map->pmap, vaddr); + paddr = pmap_extract(pmap, vaddr); if
svn commit: r289717 - head/sys/arm64/arm64
Author: jah Date: Wed Oct 21 19:44:20 2015 New Revision: 289717 URL: https://svnweb.freebsd.org/changeset/base/289717 Log: Use pmap_quick* functions in arm64 busdma to make bounce buffer synchronization more flexible and avoid borrowing UVAs for userspace buffers. This is mostly equivalent to r286785 and r286787 for x86. Differential Revision:https://reviews.freebsd.org/D3870 Modified: head/sys/arm64/arm64/busdma_bounce.c Modified: head/sys/arm64/arm64/busdma_bounce.c == --- head/sys/arm64/arm64/busdma_bounce.cWed Oct 21 19:24:20 2015 (r289716) +++ head/sys/arm64/arm64/busdma_bounce.cWed Oct 21 19:44:20 2015 (r289717) @@ -78,7 +78,8 @@ struct bounce_page { vm_offset_t vaddr; /* kva of bounce buffer */ bus_addr_t busaddr;/* Physical address */ vm_offset_t datavaddr; /* kva of client data */ - bus_addr_t dataaddr; /* client physical address */ + vm_page_t datapage; /* physical page of client data */ + vm_offset_t dataoffs; /* page offset of client data */ bus_size_t datacount; /* client data count */ STAILQ_ENTRY(bounce_page) links; }; @@ -478,7 +479,8 @@ _bus_dmamap_count_phys(bus_dma_tag_t dma while (buflen != 0) { sgsize = MIN(buflen, dmat->common.maxsegsz); if (bus_dma_run_filter(>common, curaddr)) { - sgsize = MIN(sgsize, PAGE_SIZE); + sgsize = MIN(sgsize, + PAGE_SIZE - (curaddr & PAGE_MASK)); map->pagesneeded++; } curaddr += sgsize; @@ -632,7 +634,7 @@ bounce_bus_dmamap_load_phys(bus_dma_tag_ if (((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) && map->pagesneeded != 0 && bus_dma_run_filter(>common, curaddr)) { - sgsize = MIN(sgsize, PAGE_SIZE); + sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK)); curaddr = add_bounce_page(dmat, map, 0, curaddr, sgsize); } @@ -661,7 +663,7 @@ bounce_bus_dmamap_load_buffer(bus_dma_ta { bus_size_t sgsize, max_sgsize; bus_addr_t curaddr; - vm_offset_t vaddr; + vm_offset_t kvaddr, vaddr; int error; if (map == NULL) @@ -684,22 +686,25 @@ bounce_bus_dmamap_load_buffer(bus_dma_ta /* * Get the physical address for this segment. */ - if (pmap == kernel_pmap) + if (pmap == kernel_pmap) { curaddr = pmap_kextract(vaddr); - else + kvaddr = vaddr; + } else { curaddr = pmap_extract(pmap, vaddr); + kvaddr = 0; + } /* * Compute the segment size, and adjust counts. */ max_sgsize = MIN(buflen, dmat->common.maxsegsz); - sgsize = PAGE_SIZE - ((vm_offset_t)curaddr & PAGE_MASK); + sgsize = PAGE_SIZE - (curaddr & PAGE_MASK); if (((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) && map->pagesneeded != 0 && bus_dma_run_filter(>common, curaddr)) { sgsize = roundup2(sgsize, dmat->common.alignment); sgsize = MIN(sgsize, max_sgsize); - curaddr = add_bounce_page(dmat, map, vaddr, curaddr, + curaddr = add_bounce_page(dmat, map, kvaddr, curaddr, sgsize); } else { sgsize = MIN(sgsize, max_sgsize); @@ -760,6 +765,10 @@ bounce_bus_dmamap_sync(bus_dma_tag_t dma bus_dmasync_op_t op) { struct bounce_page *bpage; + vm_offset_t datavaddr, tempvaddr; + + if ((bpage = STAILQ_FIRST(>bpages)) == NULL) + return; /* * XXX ARM64TODO: @@ -768,47 +777,47 @@ bounce_bus_dmamap_sync(bus_dma_tag_t dma * added to this function. */ - if ((bpage = STAILQ_FIRST(>bpages)) != NULL) { - /* -* Handle data bouncing. We might also -* want to add support for invalidating -* the caches on broken hardware -*/ - CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x op 0x%x " - "performing bounce", __func__, dmat, - dmat->common.flags, op); - - if ((op & BUS_DMASYNC_PREWRITE) != 0) { - while (bpage != NULL) { - if (bpage->datavaddr != 0) { -
svn commit: r289675 - head/sys/arm/arm
Author: jah Date: Wed Oct 21 04:53:34 2015 New Revision: 289675 URL: https://svnweb.freebsd.org/changeset/base/289675 Log: Use pmap_quick* for out-of-context bounce buffers and (limited) cache maintenance of unmapped buffers in armv5 busdma. Tested by:Mattia RossiDifferential Revision:https://reviews.freebsd.org/D3522 Modified: head/sys/arm/arm/busdma_machdep.c Modified: head/sys/arm/arm/busdma_machdep.c == --- head/sys/arm/arm/busdma_machdep.c Wed Oct 21 02:50:22 2015 (r289674) +++ head/sys/arm/arm/busdma_machdep.c Wed Oct 21 04:53:34 2015 (r289675) @@ -124,14 +124,16 @@ struct bounce_page { vm_offset_t vaddr; /* kva of bounce buffer */ bus_addr_t busaddr;/* Physical address */ vm_offset_t datavaddr; /* kva of client data */ - bus_addr_t dataaddr; /* client physical address */ + vm_page_t datapage; /* physical page of client data */ + vm_offset_t dataoffs; /* page offset of client data */ bus_size_t datacount; /* client data count */ STAILQ_ENTRY(bounce_page) links; }; struct sync_list { - vm_offset_t vaddr; /* kva of bounce buffer */ - bus_addr_t busaddr;/* Physical address */ + vm_offset_t vaddr; /* kva of client data */ + vm_page_t pages; /* starting page of client data */ + vm_offset_t dataoffs; /* page offset of client data */ bus_size_t datacount; /* client data count */ }; @@ -197,6 +199,8 @@ static bus_addr_t add_bounce_page(bus_dm vm_offset_t vaddr, bus_addr_t addr, bus_size_t size); static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage); +static void bus_dmamap_sync_sl(struct sync_list *sl, bus_dmasync_op_t op, + int bufaligned); /* Default tag, as most drivers provide no parent tag. */ bus_dma_tag_t arm_root_dma_tag; @@ -819,7 +823,8 @@ _bus_dmamap_count_phys(bus_dma_tag_t dma while (buflen != 0) { sgsize = MIN(buflen, dmat->maxsegsz); if (run_filter(dmat, curaddr) != 0) { - sgsize = MIN(sgsize, PAGE_SIZE); + sgsize = MIN(sgsize, + PAGE_SIZE - (curaddr & PAGE_MASK)); map->pagesneeded++; } curaddr += sgsize; @@ -949,8 +954,10 @@ int _bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf, bus_size_t buflen, int flags, bus_dma_segment_t *segs, int *segp) { + struct sync_list *sl; bus_size_t sgsize; bus_addr_t curaddr; + bus_addr_t sl_end = 0; int error; if (segs == NULL) @@ -965,14 +972,35 @@ _bus_dmamap_load_phys(bus_dma_tag_t dmat } } + sl = map->slist + map->sync_count - 1; + while (buflen > 0) { curaddr = buf; sgsize = MIN(buflen, dmat->maxsegsz); if (((dmat->flags & BUS_DMA_COULD_BOUNCE) != 0) && map->pagesneeded != 0 && run_filter(dmat, curaddr)) { - sgsize = MIN(sgsize, PAGE_SIZE); + sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK)); curaddr = add_bounce_page(dmat, map, 0, curaddr, sgsize); + } else { + if (map->sync_count > 0) + sl_end = VM_PAGE_TO_PHYS(sl->pages) + + sl->dataoffs + sl->datacount; + + if (map->sync_count == 0 || curaddr != sl_end) { + if (++map->sync_count > dmat->nsegments) + break; + sl++; + sl->vaddr = 0; + sl->datacount = sgsize; + /* +* PHYS_TO_VM_PAGE() will truncate +* unaligned addresses. +*/ + sl->pages = PHYS_TO_VM_PAGE(curaddr); + sl->dataoffs = curaddr & PAGE_MASK; + } else + sl->datacount += sgsize; } sgsize = _bus_dmamap_addseg(dmat, map, curaddr, sgsize, segs, segp); @@ -1013,8 +1041,11 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dm { bus_size_t sgsize; bus_addr_t curaddr; + bus_addr_t sl_pend = 0; struct sync_list *sl; +
svn commit: r289457 - head/sys/x86/x86
Author: jah Date: Sat Oct 17 14:58:55 2015 New Revision: 289457 URL: https://svnweb.freebsd.org/changeset/base/289457 Log: Don't page-align the physical address when calling PHYS_TO_VM_PAGE(). Mbusdma_bounce.c Modified: head/sys/x86/x86/busdma_bounce.c Modified: head/sys/x86/x86/busdma_bounce.c == --- head/sys/x86/x86/busdma_bounce.cSat Oct 17 14:48:39 2015 (r289456) +++ head/sys/x86/x86/busdma_bounce.cSat Oct 17 14:58:55 2015 (r289457) @@ -1006,7 +1006,8 @@ add_bounce_page(bus_dma_tag_t dmat, bus_ bpage->busaddr |= addr & PAGE_MASK; } bpage->datavaddr = vaddr; - bpage->datapage = PHYS_TO_VM_PAGE(addr & ~PAGE_MASK); + /* PHYS_TO_VM_PAGE() will truncate unaligned addresses. */ + bpage->datapage = PHYS_TO_VM_PAGE(addr); bpage->dataoffs = addr & PAGE_MASK; bpage->datacount = size; STAILQ_INSERT_TAIL(&(map->bpages), bpage, links); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r289202 - head/sys/x86/x86
Author: jah Date: Tue Oct 13 02:17:56 2015 New Revision: 289202 URL: https://svnweb.freebsd.org/changeset/base/289202 Log: Ensure the client regions for unmapped bounce buffers created through bus_dmamap_load_phys() do not span multiple pages. This is already done for mapped buffers. While here, stop casting bus_addr_t to vm_offset_t. Modified: head/sys/x86/x86/busdma_bounce.c Modified: head/sys/x86/x86/busdma_bounce.c == --- head/sys/x86/x86/busdma_bounce.cTue Oct 13 01:04:38 2015 (r289201) +++ head/sys/x86/x86/busdma_bounce.cTue Oct 13 02:17:56 2015 (r289202) @@ -476,7 +476,8 @@ _bus_dmamap_count_phys(bus_dma_tag_t dma while (buflen != 0) { sgsize = MIN(buflen, dmat->common.maxsegsz); if (bus_dma_run_filter(>common, curaddr)) { - sgsize = MIN(sgsize, PAGE_SIZE); + sgsize = MIN(sgsize, + PAGE_SIZE - (curaddr & PAGE_MASK)); map->pagesneeded++; } curaddr += sgsize; @@ -630,7 +631,7 @@ bounce_bus_dmamap_load_phys(bus_dma_tag_ if (((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) && map->pagesneeded != 0 && bus_dma_run_filter(>common, curaddr)) { - sgsize = MIN(sgsize, PAGE_SIZE); + sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK)); curaddr = add_bounce_page(dmat, map, 0, curaddr, sgsize); } @@ -694,7 +695,7 @@ bounce_bus_dmamap_load_buffer(bus_dma_ta * Compute the segment size, and adjust counts. */ max_sgsize = MIN(buflen, dmat->common.maxsegsz); - sgsize = PAGE_SIZE - ((vm_offset_t)curaddr & PAGE_MASK); + sgsize = PAGE_SIZE - (curaddr & PAGE_MASK); if (((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) && map->pagesneeded != 0 && bus_dma_run_filter(>common, curaddr)) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r286851 - head/sys/arm/arm
Author: jah Date: Mon Aug 17 18:28:40 2015 New Revision: 286851 URL: https://svnweb.freebsd.org/changeset/base/286851 Log: Some cleanups to make the style of pmap_quick_enter_page() and pmap_quick_remove_page() in arm/pmap-v6-new.c more consistent with the rest of the file. Submitted by: Svatopluk Kraus onw...@gmail.com Approved by: kib (mentor) Modified: head/sys/arm/arm/pmap-v6-new.c Modified: head/sys/arm/arm/pmap-v6-new.c == --- head/sys/arm/arm/pmap-v6-new.c Mon Aug 17 18:21:18 2015 (r286850) +++ head/sys/arm/arm/pmap-v6-new.c Mon Aug 17 18:28:40 2015 (r286851) @@ -1166,10 +1166,9 @@ pmap_init_qpages(void) pc = pcpu_find(i); pc-pc_qmap_addr = kva_alloc(PAGE_SIZE); if (pc-pc_qmap_addr == 0) - panic(pmap_init_qpages: unable to allocate KVA); + panic(%s: unable to allocate KVA, __func__); } } - SYSINIT(qpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_qpages, NULL); /* @@ -5728,18 +5727,17 @@ pmap_copy_pages(vm_page_t ma[], vm_offse vm_offset_t pmap_quick_enter_page(vm_page_t m) { - pt2_entry_t *pte; - vm_offset_t qmap_addr; + pt2_entry_t *pte2p; + vm_offset_t qmap_addr; critical_enter(); - qmap_addr = PCPU_GET(qmap_addr); - pte = pt2map_entry(qmap_addr); + pte2p = pt2map_entry(qmap_addr); - KASSERT(*pte == 0, (pmap_quick_enter_page: PTE busy)); + KASSERT(pte2_load(pte2p) == 0, (%s: PTE2 busy, __func__)); - pte2_store(pte, PTE2_KERN_NG(VM_PAGE_TO_PHYS(m), - PTE2_AP_KRW, pmap_page_get_memattr(m))); + pte2_store(pte2p, PTE2_KERN_NG(VM_PAGE_TO_PHYS(m), PTE2_AP_KRW, + pmap_page_get_memattr(m))); tlb_flush_local(qmap_addr); return (qmap_addr); @@ -5748,16 +5746,16 @@ pmap_quick_enter_page(vm_page_t m) void pmap_quick_remove_page(vm_offset_t addr) { - pt2_entry_t *pte; + pt2_entry_t *pte2p; vm_offset_t qmap_addr; qmap_addr = PCPU_GET(qmap_addr); - pte = pt2map_entry(qmap_addr); + pte2p = pt2map_entry(qmap_addr); - KASSERT(addr == qmap_addr, (pmap_quick_remove_page: invalid address)); - KASSERT(*pte != 0, (pmap_quick_remove_page: PTE not in use)); + KASSERT(addr == qmap_addr, (%s: invalid address, __func__)); + KASSERT(pte2_load(pte2p) != 0, (%s: PTE2 not in use, __func__)); - pte2_clear(pte); + pte2_clear(pte2p); critical_exit(); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r286787 - head/sys/x86/x86
Author: jah Date: Fri Aug 14 20:08:16 2015 New Revision: 286787 URL: https://svnweb.freebsd.org/changeset/base/286787 Log: Use pmap_quick_enter_page() to handle bouncing of unmapped buffers in the x86 busdma_bounce implementation. Also treat user buffers as unmapped. This allows two things: 1. Sync'ing bounced maps in non-sleepable contexts. The physcopy* calls previously used could sleep on sf_buf operations in some cases. 2. Sync'ing user buffers outside the context of the owning process Approved by: kib (mentor) Modified: head/sys/x86/x86/busdma_bounce.c Modified: head/sys/x86/x86/busdma_bounce.c == --- head/sys/x86/x86/busdma_bounce.cFri Aug 14 18:38:39 2015 (r286786) +++ head/sys/x86/x86/busdma_bounce.cFri Aug 14 20:08:16 2015 (r286787) @@ -79,7 +79,8 @@ struct bounce_page { vm_offset_t vaddr; /* kva of bounce buffer */ bus_addr_t busaddr;/* Physical address */ vm_offset_t datavaddr; /* kva of client data */ - bus_addr_t dataaddr; /* client physical address */ + vm_page_t datapage; /* physical page of client data */ + vm_offset_t dataoffs; /* page offset of client data */ bus_size_t datacount; /* client data count */ STAILQ_ENTRY(bounce_page) links; }; @@ -658,7 +659,7 @@ bounce_bus_dmamap_load_buffer(bus_dma_ta { bus_size_t sgsize, max_sgsize; bus_addr_t curaddr; - vm_offset_t vaddr; + vm_offset_t kvaddr, vaddr; int error; if (map == NULL) @@ -681,10 +682,13 @@ bounce_bus_dmamap_load_buffer(bus_dma_ta /* * Get the physical address for this segment. */ - if (pmap == kernel_pmap) + if (pmap == kernel_pmap) { curaddr = pmap_kextract(vaddr); - else + kvaddr = vaddr; + } else { curaddr = pmap_extract(pmap, vaddr); + kvaddr = 0; + } /* * Compute the segment size, and adjust counts. @@ -696,7 +700,7 @@ bounce_bus_dmamap_load_buffer(bus_dma_ta bus_dma_run_filter(dmat-common, curaddr)) { sgsize = roundup2(sgsize, dmat-common.alignment); sgsize = MIN(sgsize, max_sgsize); - curaddr = add_bounce_page(dmat, map, vaddr, curaddr, + curaddr = add_bounce_page(dmat, map, kvaddr, curaddr, sgsize); } else { sgsize = MIN(sgsize, max_sgsize); @@ -757,6 +761,7 @@ bounce_bus_dmamap_sync(bus_dma_tag_t dma bus_dmasync_op_t op) { struct bounce_page *bpage; + vm_offset_t datavaddr, tempvaddr; if ((bpage = STAILQ_FIRST(map-bpages)) == NULL) return; @@ -770,13 +775,19 @@ bounce_bus_dmamap_sync(bus_dma_tag_t dma if ((op BUS_DMASYNC_PREWRITE) != 0) { while (bpage != NULL) { - if (bpage-datavaddr != 0) { - bcopy((void *)bpage-datavaddr, - (void *)bpage-vaddr, bpage-datacount); - } else { - physcopyout(bpage-dataaddr, - (void *)bpage-vaddr, bpage-datacount); + tempvaddr = 0; + datavaddr = bpage-datavaddr; + if (datavaddr == 0) { + tempvaddr = + pmap_quick_enter_page(bpage-datapage); + datavaddr = tempvaddr | bpage-dataoffs; } + + bcopy((void *)datavaddr, + (void *)bpage-vaddr, bpage-datacount); + + if (tempvaddr != 0) + pmap_quick_remove_page(tempvaddr); bpage = STAILQ_NEXT(bpage, links); } dmat-bounce_zone-total_bounced++; @@ -784,14 +795,19 @@ bounce_bus_dmamap_sync(bus_dma_tag_t dma if ((op BUS_DMASYNC_POSTREAD) != 0) { while (bpage != NULL) { - if (bpage-datavaddr != 0) { - bcopy((void *)bpage-vaddr, - (void *)bpage-datavaddr, - bpage-datacount); - } else { - physcopyin((void *)bpage-vaddr, - bpage-dataaddr, bpage-datacount); + tempvaddr = 0; + datavaddr = bpage-datavaddr; + if (datavaddr == 0) { + tempvaddr = +
svn commit: r286785 - head/sys/x86/x86
Author: jah Date: Fri Aug 14 18:01:40 2015 New Revision: 286785 URL: https://svnweb.freebsd.org/changeset/base/286785 Log: Reformat x86 bounce buffer synchronization code to reduce indentation. No functional change. Approved by: kib (mentor) Modified: head/sys/x86/x86/busdma_bounce.c Modified: head/sys/x86/x86/busdma_bounce.c == --- head/sys/x86/x86/busdma_bounce.cFri Aug 14 17:49:03 2015 (r286784) +++ head/sys/x86/x86/busdma_bounce.cFri Aug 14 18:01:40 2015 (r286785) @@ -758,47 +758,43 @@ bounce_bus_dmamap_sync(bus_dma_tag_t dma { struct bounce_page *bpage; - if ((bpage = STAILQ_FIRST(map-bpages)) != NULL) { - /* -* Handle data bouncing. We might also -* want to add support for invalidating -* the caches on broken hardware -*/ - CTR4(KTR_BUSDMA, %s: tag %p tag flags 0x%x op 0x%x - performing bounce, __func__, dmat, - dmat-common.flags, op); - - if ((op BUS_DMASYNC_PREWRITE) != 0) { - while (bpage != NULL) { - if (bpage-datavaddr != 0) { - bcopy((void *)bpage-datavaddr, - (void *)bpage-vaddr, - bpage-datacount); - } else { - physcopyout(bpage-dataaddr, - (void *)bpage-vaddr, - bpage-datacount); - } - bpage = STAILQ_NEXT(bpage, links); + if ((bpage = STAILQ_FIRST(map-bpages)) == NULL) + return; + + /* +* Handle data bouncing. We might also want to add support for +* invalidating the caches on broken hardware. +*/ + CTR4(KTR_BUSDMA, %s: tag %p tag flags 0x%x op 0x%x + performing bounce, __func__, dmat, dmat-common.flags, op); + + if ((op BUS_DMASYNC_PREWRITE) != 0) { + while (bpage != NULL) { + if (bpage-datavaddr != 0) { + bcopy((void *)bpage-datavaddr, + (void *)bpage-vaddr, bpage-datacount); + } else { + physcopyout(bpage-dataaddr, + (void *)bpage-vaddr, bpage-datacount); } - dmat-bounce_zone-total_bounced++; + bpage = STAILQ_NEXT(bpage, links); } + dmat-bounce_zone-total_bounced++; + } - if ((op BUS_DMASYNC_POSTREAD) != 0) { - while (bpage != NULL) { - if (bpage-datavaddr != 0) { - bcopy((void *)bpage-vaddr, - (void *)bpage-datavaddr, - bpage-datacount); - } else { - physcopyin((void *)bpage-vaddr, - bpage-dataaddr, - bpage-datacount); - } - bpage = STAILQ_NEXT(bpage, links); + if ((op BUS_DMASYNC_POSTREAD) != 0) { + while (bpage != NULL) { + if (bpage-datavaddr != 0) { + bcopy((void *)bpage-vaddr, + (void *)bpage-datavaddr, + bpage-datacount); + } else { + physcopyin((void *)bpage-vaddr, + bpage-dataaddr, bpage-datacount); } - dmat-bounce_zone-total_bounced++; + bpage = STAILQ_NEXT(bpage, links); } + dmat-bounce_zone-total_bounced++; } } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r286411 - head/share/man/man9
Author: jah Date: Fri Aug 7 12:13:15 2015 New Revision: 286411 URL: https://svnweb.freebsd.org/changeset/base/286411 Log: Create man page for pmap_quick_enter_page(9) and pmap_quick_remove_page(9) Reviewed by: kib, brueffer, wblock Approved by: kib (mentor) Differential Revision:https://reviews.freebsd.org/D3312 Added: head/share/man/man9/pmap_quick_enter_page.9 (contents, props changed) Modified: head/share/man/man9/Makefile head/share/man/man9/pmap.9 Modified: head/share/man/man9/Makefile == --- head/share/man/man9/MakefileFri Aug 7 11:43:14 2015 (r286410) +++ head/share/man/man9/MakefileFri Aug 7 12:13:15 2015 (r286411) @@ -223,6 +223,7 @@ MAN=accept_filter.9 \ pmap_pinit.9 \ pmap_protect.9 \ pmap_qenter.9 \ + pmap_quick_enter_page.9 \ pmap_release.9 \ pmap_remove.9 \ pmap_resident_count.9 \ @@ -1265,6 +1266,7 @@ MLINKS+=pmap_is_modified.9 pmap_ts_refer MLINKS+=pmap_pinit.9 pmap_pinit0.9 \ pmap_pinit.9 pmap_pinit2.9 MLINKS+=pmap_qenter.9 pmap_qremove.9 +MLINKS+=pmap_quick_enter_page.9 pmap_quick_remove_page.9 MLINKS+=pmap_remove.9 pmap_remove_all.9 \ pmap_remove.9 pmap_remove_pages.9 MLINKS+=pmap_resident_count.9 pmap_wired_count.9 Modified: head/share/man/man9/pmap.9 == --- head/share/man/man9/pmap.9 Fri Aug 7 11:43:14 2015(r286410) +++ head/share/man/man9/pmap.9 Fri Aug 7 12:13:15 2015(r286411) @@ -111,6 +111,8 @@ operation. .Xr pmap_protect 9 , .Xr pmap_qenter 9 , .Xr pmap_qremove 9 , +.Xr pmap_quick_enter_page 9 , +.Xr pmap_quick_remove_page 9 , .Xr pmap_release 9 , .Xr pmap_remove 9 , .Xr pmap_remove_all 9 , Added: head/share/man/man9/pmap_quick_enter_page.9 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man9/pmap_quick_enter_page.9 Fri Aug 7 12:13:15 2015 (r286411) @@ -0,0 +1,103 @@ +.\ +.\ Copyright (c) 2015 Jason A. Harmening j...@freebsd.org +.\ All rights reserved. +.\ +.\ Redistribution and use in source and binary forms, with or without +.\ modification, are permitted provided that the following conditions +.\ are met: +.\ 1. Redistributions of source code must retain the above copyright +.\notice, this list of conditions and the following disclaimer. +.\ 2. Redistributions in binary form must reproduce the above copyright +.\notice, this list of conditions and the following disclaimer in the +.\documentation and/or other materials provided with the distribution. +.\ +.\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\ SUCH DAMAGE. +.\ +.\ $FreeBSD$ +.\ +.Dd August 6, 2015 +.Dt PMAP_QUICK_ENTER_PAGE 9 +.Os +.Sh NAME +.Nm pmap_quick_enter_page , +.Nm pmap_quick_remove_page +.Nd manage fast, single-page kernel address space mappings +.Sh SYNOPSIS +.In sys/param.h +.In vm/vm.h +.In vm/pmap.h +.Ft vm_offset_t +.Fn pmap_quick_enter_page vm_page_t m +.Ft void +.Fn pmap_quick_remove_page vm_offset_t kva +.Sh DESCRIPTION +The +.Fn pmap_quick_enter_page +function accepts a single page +.Fa m , +and enters this page into a preallocated address in kernel virtual +address (KVA) space. +This function is intended for temporary mappings that will only +be used for a very short period, for example a copy operation on +the page contents. +.Pp +The +.Fn pmap_quick_remove_page +function removes a mapping previously created by +.Fn pmap_quick_enter_page +at +.Fa kva , +making the KVA frame used by +.Fn pmap_quick_enter_page +available for reuse. +.Pp +On many architectures, +.Fn pmap_quick_enter_page +uses a per-CPU pageframe. +In those cases, it must disable preemption on the local CPU. +The corresponding call to +.Fn pmap_quick_remove_page +then re-enables preemption. +It is therefore not safe for machine-independent code to sleep +or perform locking operations while holding these mappings. +Current implementations only guarantee the availability of a single +page for the calling thread, so calls to +.Fn pmap_quick_enter_page +must not be nested
svn commit: r286313 - head/sys/vm
Author: jah Date: Wed Aug 5 10:48:32 2015 New Revision: 286313 URL: https://svnweb.freebsd.org/changeset/base/286313 Log: Properly sort the function declarations added in r286296 Submitted by: alc Approved by: kib (mentor) Modified: head/sys/vm/pmap.h Modified: head/sys/vm/pmap.h == --- head/sys/vm/pmap.h Wed Aug 5 08:18:05 2015(r286312) +++ head/sys/vm/pmap.h Wed Aug 5 10:48:32 2015(r286313) @@ -141,6 +141,8 @@ void pmap_pinit0(pmap_t); voidpmap_protect(pmap_t, vm_offset_t, vm_offset_t, vm_prot_t); voidpmap_qenter(vm_offset_t, vm_page_t *, int); voidpmap_qremove(vm_offset_t, int); +vm_offset_t pmap_quick_enter_page(vm_page_t); +voidpmap_quick_remove_page(vm_offset_t); voidpmap_release(pmap_t); voidpmap_remove(pmap_t, vm_offset_t, vm_offset_t); voidpmap_remove_all(vm_page_t m); @@ -152,8 +154,6 @@ void pmap_unwire(pmap_t pmap, vm_offse voidpmap_zero_page(vm_page_t); voidpmap_zero_page_area(vm_page_t, int off, int size); voidpmap_zero_page_idle(vm_page_t); -vm_offset_t pmap_quick_enter_page(vm_page_t); -voidpmap_quick_remove_page(vm_offset_t); #definepmap_resident_count(pm) ((pm)-pm_stats.resident_count) #definepmap_wired_count(pm)((pm)-pm_stats.wired_count) ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r286296 - in head/sys: amd64/amd64 arm/arm arm/include arm64/arm64 i386/i386 i386/include mips/mips powerpc/aim powerpc/booke powerpc/include powerpc/powerpc sparc64/include sparc64/spa...
Author: jah Date: Tue Aug 4 19:46:13 2015 New Revision: 286296 URL: https://svnweb.freebsd.org/changeset/base/286296 Log: Add two new pmap functions: vm_offset_t pmap_quick_enter_page(vm_page_t m) void pmap_quick_remove_page(vm_offset_t kva) These will create and destroy a temporary, CPU-local KVA mapping of a specified page. Guarantees: --Will not sleep and will not fail. --Safe to call under a non-sleepable lock or from an ithread Restrictions: --Not guaranteed to be safe to call from an interrupt filter or under a spin mutex on all platforms --Current implementation does not guarantee more than one page of mapping space across all platforms. MI code should not make nested calls to pmap_quick_enter_page. --MI code should not perform locking while holding onto a mapping created by pmap_quick_enter_page The idea is to use this in busdma, for bounce buffer copies as well as virtually-indexed cache maintenance on mips and arm. NOTE: the non-i386, non-amd64 implementations of these functions still need review and testing. Reviewed by: kib Approved by: kib (mentor) Differential Revision:http://reviews.freebsd.org/D3013 Modified: head/sys/amd64/amd64/pmap.c head/sys/arm/arm/pmap-v6-new.c head/sys/arm/arm/pmap-v6.c head/sys/arm/arm/pmap.c head/sys/arm/include/pcpu.h head/sys/arm64/arm64/pmap.c head/sys/i386/i386/pmap.c head/sys/i386/include/pcpu.h head/sys/mips/mips/pmap.c head/sys/powerpc/aim/mmu_oea.c head/sys/powerpc/aim/mmu_oea64.c head/sys/powerpc/booke/pmap.c head/sys/powerpc/include/pcpu.h head/sys/powerpc/powerpc/mmu_if.m head/sys/powerpc/powerpc/pmap_dispatch.c head/sys/sparc64/include/pcpu.h head/sys/sparc64/sparc64/pmap.c head/sys/vm/pmap.h Modified: head/sys/amd64/amd64/pmap.c == --- head/sys/amd64/amd64/pmap.c Tue Aug 4 19:43:48 2015(r286295) +++ head/sys/amd64/amd64/pmap.c Tue Aug 4 19:46:13 2015(r286296) @@ -6940,6 +6940,18 @@ pmap_unmap_io_transient(vm_page_t page[] } } +vm_offset_t +pmap_quick_enter_page(vm_page_t m) +{ + + return (PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m))); +} + +void +pmap_quick_remove_page(vm_offset_t addr) +{ +} + #include opt_ddb.h #ifdef DDB #include ddb/ddb.h Modified: head/sys/arm/arm/pmap-v6-new.c == --- head/sys/arm/arm/pmap-v6-new.c Tue Aug 4 19:43:48 2015 (r286295) +++ head/sys/arm/arm/pmap-v6-new.c Tue Aug 4 19:46:13 2015 (r286296) @@ -1156,6 +1156,22 @@ pmap_bootstrap(vm_offset_t firstaddr) virtual_end = vm_max_kernel_address; } +static void +pmap_init_qpages(void) +{ + struct pcpu *pc; + int i; + + CPU_FOREACH(i) { + pc = pcpu_find(i); + pc-pc_qmap_addr = kva_alloc(PAGE_SIZE); + if (pc-pc_qmap_addr == 0) + panic(pmap_init_qpages: unable to allocate KVA); + } +} + +SYSINIT(qpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_qpages, NULL); + /* * The function can already be use in second initialization stage. * As such, the function DOES NOT call pmap_growkernel() where PT2 @@ -5709,6 +5725,42 @@ pmap_copy_pages(vm_page_t ma[], vm_offse mtx_unlock(sysmaps-lock); } +vm_offset_t +pmap_quick_enter_page(vm_page_t m) +{ + pt2_entry_t *pte; + vm_offset_t qmap_addr; + + critical_enter(); + + qmap_addr = PCPU_GET(qmap_addr); + pte = pt2map_entry(qmap_addr); + + KASSERT(*pte == 0, (pmap_quick_enter_page: PTE busy)); + + pte2_store(pte, PTE2_KERN_NG(VM_PAGE_TO_PHYS(m), + PTE2_AP_KRW, pmap_page_get_memattr(m))); + tlb_flush_local(qmap_addr); + + return (qmap_addr); +} + +void +pmap_quick_remove_page(vm_offset_t addr) +{ + pt2_entry_t *pte; + vm_offset_t qmap_addr; + + qmap_addr = PCPU_GET(qmap_addr); + pte = pt2map_entry(qmap_addr); + + KASSERT(addr == qmap_addr, (pmap_quick_remove_page: invalid address)); + KASSERT(*pte != 0, (pmap_quick_remove_page: PTE not in use)); + + pte2_clear(pte); + critical_exit(); +} + /* * Copy the range specified by src_addr/len * from the source map to the range dst_addr/len Modified: head/sys/arm/arm/pmap-v6.c == --- head/sys/arm/arm/pmap-v6.c Tue Aug 4 19:43:48 2015(r286295) +++ head/sys/arm/arm/pmap-v6.c Tue Aug 4 19:46:13 2015(r286296) @@ -1979,6 +1979,7 @@ pmap_bootstrap(vm_offset_t firstaddr, st pmap_set_pcb_pagedir(kernel_pmap, thread0.td_pcb); } + /*** * Pmap allocation/deallocation routines. ***/ @@ -2306,6 +2307,31 @@ pmap_remove_pages(pmap_t pmap) PMAP_UNLOCK(pmap); }
svn commit: r282966 - head/share/man/man4
Author: jah Date: Fri May 15 12:28:17 2015 New Revision: 282966 URL: https://svnweb.freebsd.org/changeset/base/282966 Log: Update iic(4) man page to reflect recent changes Differential Revision:https://reviews.freebsd.org/D2461 Reviewed by: wblock Approved by: kib (mentor) Modified: head/share/man/man4/iic.4 Modified: head/share/man/man4/iic.4 == --- head/share/man/man4/iic.4 Fri May 15 12:19:45 2015(r282965) +++ head/share/man/man4/iic.4 Fri May 15 12:28:17 2015(r282966) @@ -54,10 +54,12 @@ element to the bus. The .Va slave element consists of a 7-bit address and a read/write bit -(i.e., 7-bit address 1 | r/w). -If the read/write bit is set a read operation is initiated, if the read/write -bit is cleared a write operation is initiated. +(that is, a 7-bit address 1 | r/w). +A read operation is initiated when the read/write bit is set, or a write +operation when it is cleared. All other elements are ignored. +If successful, the file descriptor receives exclusive +ownership of the underlying iicbus instance. .It Dv I2CRPTSTART .Pq Vt struct iiccmd Sends the repeated start condition to the slave specified by the @@ -66,19 +68,33 @@ element to the bus. The slave address should be specified as in .Dv I2CSTART . All other elements are ignored. +.Dv I2CSTART +must have previously been issued on the same file descriptor. .It Dv I2CSTOP No argument is passed. Sends the stop condition to the bus. -This terminates the current transaction. +If +.Dv I2CSTART +was previously issued on the file descriptor, the current transaction is +terminated and exclusive ownership of the underlying iicbus instance is +released. +Otherwise, no action is performed. .It Dv I2CRSTCARD .Pq Vt struct iiccmd Resets the bus. The argument is completely ignored. +This command does not require +.Dv I2CSTART +to have been previously issued on the file descriptor. +If it was previously issued, exclusive ownership of the underlying iicbus +instance is released. .It Dv I2CWRITE .Pq Vt struct iiccmd Writes data to the .Xr iicbus 4 . -The bus should already be started. +The bus must already be started by a previous +.Dv I2CSTART +on the file descriptor. The .Va slave element is ignored. @@ -96,7 +112,9 @@ element is a pointer to the data to writ .Pq Vt struct iiccmd Reads data from the .Xr iicbus 4 . -The bus should already be started. +The bus must already be started by a previous +.Dv I2CSTART +on the file descriptor. The .Va slave element is ignored. @@ -116,6 +134,15 @@ Short reads on the bus produce undefined Generic read/write interface. Allows for an arbitrary number of commands to be sent to an arbitrary number of devices on the bus. +Any previous transaction started by +.Dv I2CSTART +must be terminated by +.Dv I2CSTOP +or +.Dv I2CRSTCARD +before +.Dv I2CRDWR +can be issued on the same file descriptor. A read transfer is specified if .Dv IIC_M_RD is set in @@ -138,6 +165,17 @@ element is a buffer for that data. This ioctl is intended to be .Tn Linux compatible. +.It Dv I2CSADDR +.Pq Vt uint8_t +Associate the specified address with the file descriptor for use by +subsequent +.Xr read 2 +or +.Xr write 2 +calls. +The argument is an 8-bit address (that is, a 7-bit address 1). +The read/write bit in the least-significant position is ignored. +Any subsequent read or write operation will set or clear that bit as needed. .El .Pp The following data structures are defined in @@ -156,7 +194,10 @@ struct iic_msg { uint16_tslave; uint16_tflags; -#define IIC_M_RD 0x0001 /* read vs write */ +#defineIIC_M_WR0 /* Fake flag for write */ +#defineIIC_M_RD0x0001 /* read vs write */ +#defineIIC_M_NOSTOP0x0002 /* do not send a I2C stop after message */ +#defineIIC_M_NOSTART 0x0004 /* do not send a I2C start before message */ uint16_tlen;/* msg length */ uint8_t * buf; }; @@ -167,15 +208,37 @@ struct iic_rdwr_data { }; .Ed .Pp -It is also possible to use read/write routines, then I2C start/stop handshake is -managed by the -.Xr iicbus 4 -system. -However, the address used for the read/write routines is the one -passed to last +It is also possible to use +.Xr read 2 +or +.Xr write 2 , +in which case the I2C start/stop handshake is managed by +.Xr iicbus 4 . +The address used for the read/write operation is the one passed to the most +recent .Dv I2CSTART .Xr ioctl 2 -to this device. +or +.Dv I2CSADDR +.Xr ioctl 2 +on the open +.Pa /dev/iic? +file descriptor. +Closing the file descriptor clears any addressing state established by a +previous +.Dv I2CSTART +or +.Dv I2CSADDR , +stops any transaction established by a not-yet-terminated +.Dv I2CSTART , +and releases iicbus ownership. +Because addressing state is stored on a per-file-descriptor basis, it is
svn commit: r282969 - head/share/man/man4
Author: jah Date: Fri May 15 13:04:14 2015 New Revision: 282969 URL: https://svnweb.freebsd.org/changeset/base/282969 Log: Bump date for iic.4 Modified: head/share/man/man4/iic.4 Modified: head/share/man/man4/iic.4 == --- head/share/man/man4/iic.4 Fri May 15 12:35:18 2015(r282968) +++ head/share/man/man4/iic.4 Fri May 15 13:04:14 2015(r282969) @@ -25,7 +25,7 @@ .\ .\ $FreeBSD$ .\ -.Dd June 24, 2014 +.Dd May 15, 2015 .Dt IIC 4 .Os .Sh NAME ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r281828 - head/sys/dev/iicbus
Author: jah Date: Tue Apr 21 11:50:31 2015 New Revision: 281828 URL: https://svnweb.freebsd.org/changeset/base/281828 Log: Fix numerous issues in iic(4) and iicbus(4): --Allow multiple open iic fds by storing addressing state in cdevpriv --Fix, as much as possible, the baked-in race conditions in the iic ioctl interface by requesting bus ownership on I2CSTART, releasing it on I2CSTOP/I2CRSTCARD, and requiring bus ownership by the current cdevpriv to use the I/O ioctls --Reduce internal iic buffer size and remove 1K read/write limit by iteratively calling iicbus_read/iicbus_write --Eliminate dynamic allocation in I2CWRITE/I2CREAD --Move handling of I2CRDWR to separate function and improve error handling --Add new I2CSADDR ioctl to store address in current cdevpriv so that I2CSTART is not needed for read(2)/write(2) to work --Redesign iicbus_request_bus() and iicbus_release_bus(): --iicbus_request_bus() no longer falls through if the bus is already owned by the requesting device. Multiple threads on the same device may want exclusive access. Also, iicbus_release_bus() was never device-recursive anyway. --Previously, if IICBUS_CALLBACK failed in iicbus_release_bus(), but the following iicbus_poll() call succeeded, IICBUS_CALLBACK would not be issued again --Do not hold iicbus mtx during IICBUS_CALLBACK call. There are several drivers that may sleep in IICBUS_CALLBACK, if IIC_WAIT is passed. --Do not loop in iicbus_request_bus if IICBUS_CALLBACK returns EWOULDBLOCK; instead pass that to the caller so that it can retry if so desired. Differential Revision:https://reviews.freebsd.org/D2140 Reviewed by: imp, jhb, loos Approved by: kib (mentor) Modified: head/sys/dev/iicbus/iic.c head/sys/dev/iicbus/iic.h head/sys/dev/iicbus/iicbus_if.m head/sys/dev/iicbus/iiconf.c Modified: head/sys/dev/iicbus/iic.c == --- head/sys/dev/iicbus/iic.c Tue Apr 21 11:29:07 2015(r281827) +++ head/sys/dev/iicbus/iic.c Tue Apr 21 11:50:31 2015(r281828) @@ -37,6 +37,7 @@ #include sys/sx.h #include sys/systm.h #include sys/uio.h +#include sys/errno.h #include dev/iicbus/iiconf.h #include dev/iicbus/iicbus.h @@ -44,28 +45,32 @@ #include iicbus_if.h -#define BUFSIZE 1024 - struct iic_softc { - device_t sc_dev; - u_char sc_addr; /* 7 bit address on iicbus */ - int sc_count; /* 0 if device opened */ - - char sc_buffer[BUFSIZE];/* output buffer */ - char sc_inbuf[BUFSIZE]; /* input buffer */ - struct cdev *sc_devnode; - struct sx sc_lock; }; -#defineIIC_LOCK(sc)sx_xlock((sc)-sc_lock) -#defineIIC_UNLOCK(sc) sx_xunlock((sc)-sc_lock) +struct iic_cdevpriv { + struct sx lock; + struct iic_softc *sc; + bool started; + uint8_t addr; +}; + + +#defineIIC_LOCK(cdp) sx_xlock((cdp)-lock) +#defineIIC_UNLOCK(cdp) sx_xunlock((cdp)-lock) + +static MALLOC_DEFINE(M_IIC, iic, I2C device data); static int iic_probe(device_t); static int iic_attach(device_t); static int iic_detach(device_t); static void iic_identify(driver_t *driver, device_t parent); +static void iicdtor(void *data); +static int iicuio_move(struct iic_cdevpriv *priv, struct uio *uio, int last); +static int iicuio(struct cdev *dev, struct uio *uio, int ioflag); +static int iicrdwr(struct iic_cdevpriv *priv, struct iic_rdwr_data *d, int flags); static devclass_t iic_devclass; @@ -89,18 +94,13 @@ static driver_t iic_driver = { }; static d_open_tiicopen; -static d_close_t iicclose; -static d_write_t iicwrite; -static d_read_tiicread; static d_ioctl_t iicioctl; static struct cdevsw iic_cdevsw = { .d_version =D_VERSION, - .d_flags = D_TRACKCLOSE, .d_open = iicopen, - .d_close = iicclose, - .d_read = iicread, - .d_write = iicwrite, + .d_read = iicuio, + .d_write = iicuio, .d_ioctl = iicioctl, .d_name = iic, }; @@ -127,16 +127,15 @@ iic_probe(device_t dev) static int iic_attach(device_t dev) { - struct iic_softc *sc = (struct iic_softc *)device_get_softc(dev); + struct iic_softc *sc; + sc = device_get_softc(dev); sc-sc_dev = dev; - sx_init(sc-sc_lock, iic); sc-sc_devnode = make_dev(iic_cdevsw, device_get_unit(dev), UID_ROOT, GID_WHEEL, 0600, iic%d, device_get_unit(dev)); if (sc-sc_devnode == NULL) { device_printf(dev, failed to create character device\n); - sx_destroy(sc-sc_lock); return (ENXIO); } sc-sc_devnode-si_drv1 = sc; @@ -147,11 +146,12
svn commit: r280352 - stable/9/sys/dev/drm2
Author: jah Date: Sun Mar 22 18:31:28 2015 New Revision: 280352 URL: https://svnweb.freebsd.org/changeset/base/280352 Log: MFC r279919: Using parent DMA tag in drm_pci_alloc(). This can allow drm2 devices to work with Intel DMAR enabled for the system, as long as DMAR is disabled for the drm2 device. Reviewed by: kib (mentor) Modified: stable/9/sys/dev/drm2/drm_pci.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/drm2/drm_pci.c == --- stable/9/sys/dev/drm2/drm_pci.c Sun Mar 22 18:17:55 2015 (r280351) +++ stable/9/sys/dev/drm2/drm_pci.c Sun Mar 22 18:31:28 2015 (r280352) @@ -76,7 +76,9 @@ drm_pci_alloc(struct drm_device *dev, si if (mtx_owned(dev-dma_lock)) DRM_ERROR(called while holding dma_lock\n); - ret = bus_dma_tag_create(NULL, align, 0, /* tag, align, boundary */ + ret = bus_dma_tag_create( + bus_get_dma_tag(dev-device), /* parent */ + align, 0, /* align, boundary */ maxaddr, BUS_SPACE_MAXADDR, /* lowaddr, highaddr */ NULL, NULL, /* filtfunc, filtfuncargs */ size, 1, size, /* maxsize, nsegs, maxsegsize */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r280353 - stable/10/sys/dev/drm2
Author: jah Date: Sun Mar 22 18:32:37 2015 New Revision: 280353 URL: https://svnweb.freebsd.org/changeset/base/280353 Log: MFC r279919: Using parent DMA tag in drm_pci_alloc(). This can allow drm2 devices to work with Intel DMAR enabled for the system, as long as DMAR is disabled for the drm2 device. Reviewed by: kib (mentor) Modified: stable/10/sys/dev/drm2/drm_pci.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/drm2/drm_pci.c == --- stable/10/sys/dev/drm2/drm_pci.cSun Mar 22 18:31:28 2015 (r280352) +++ stable/10/sys/dev/drm2/drm_pci.cSun Mar 22 18:32:37 2015 (r280353) @@ -76,7 +76,9 @@ drm_pci_alloc(struct drm_device *dev, si if (mtx_owned(dev-dma_lock)) DRM_ERROR(called while holding dma_lock\n); - ret = bus_dma_tag_create(NULL, align, 0, /* tag, align, boundary */ + ret = bus_dma_tag_create( + bus_get_dma_tag(dev-device), /* parent */ + align, 0, /* align, boundary */ maxaddr, BUS_SPACE_MAXADDR, /* lowaddr, highaddr */ NULL, NULL, /* filtfunc, filtfuncargs */ size, 1, size, /* maxsize, nsegs, maxsegsize */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r279919 - head/sys/dev/drm2
Author: jah Date: Thu Mar 12 14:18:36 2015 New Revision: 279919 URL: https://svnweb.freebsd.org/changeset/base/279919 Log: Using parent DMA tag in drm_pci_alloc(). This can allow drm2 devices to work with Intel DMAR enabled for the system, as long as DMAR is disabled for the drm2 device. Approved by: kib (mentor) MFC after:1 week Modified: head/sys/dev/drm2/drm_pci.c Modified: head/sys/dev/drm2/drm_pci.c == --- head/sys/dev/drm2/drm_pci.c Thu Mar 12 13:40:02 2015(r279918) +++ head/sys/dev/drm2/drm_pci.c Thu Mar 12 14:18:36 2015(r279919) @@ -76,7 +76,9 @@ drm_pci_alloc(struct drm_device *dev, si if (mtx_owned(dev-dma_lock)) DRM_ERROR(called while holding dma_lock\n); - ret = bus_dma_tag_create(NULL, align, 0, /* tag, align, boundary */ + ret = bus_dma_tag_create( + bus_get_dma_tag(dev-device), /* parent */ + align, 0, /* align, boundary */ maxaddr, BUS_SPACE_MAXADDR, /* lowaddr, highaddr */ NULL, NULL, /* filtfunc, filtfuncargs */ size, 1, size, /* maxsize, nsegs, maxsegsize */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r279884 - head/share/misc
Author: jah Date: Wed Mar 11 12:57:07 2015 New Revision: 279884 URL: https://svnweb.freebsd.org/changeset/base/279884 Log: Adding myself (jah) to committers-src.dot Approved by: kib (mentor) Modified: head/share/misc/committers-src.dot Modified: head/share/misc/committers-src.dot == --- head/share/misc/committers-src.dot Wed Mar 11 11:17:09 2015 (r279883) +++ head/share/misc/committers-src.dot Wed Mar 11 12:57:07 2015 (r279884) @@ -178,6 +178,7 @@ ian [label=Ian Lepore\n...@freebsd.org\ iedowse [label=Ian Dowse\niedo...@freebsd.org\n2000/12/01] imp [label=Warner Losh\n...@freebsd.org\n1996/09/20] ivoras [label=Ivan Voras\nivo...@freebsd.org\n2008/06/10] +jah [label=Jason A. Harmening\n...@freebsd.org\n2015/03/08] jamie [label=Jamie Gritton\nja...@freebsd.org\n2009/01/28] jasone [label=Jason Evans\njas...@freebsd.org\n1999/03/03] jceel [label=Jakub Klama\njc...@freebsd.org\n2011/09/25] @@ -549,6 +550,7 @@ ken - slm kib - ae kib - dchagin kib - gjb +kib - jah kib - jlh kib - jpaetzel kib - lulf ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org