From 8a477d48e0f20a7a16d9f0bfda4e3f9689cf473d Mon Sep 17 00:00:00 2001 From: Mikolaj Golub Date: Sat, 26 Apr 2014 08:05:16 +0000 Subject: [PATCH 01/67] Define startup order the same way as it is in dummynet. --- sys/netpfil/ipfw/ip_fw_nat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/ipfw/ip_fw_nat.c b/sys/netpfil/ipfw/ip_fw_nat.c index 427a55e46f6..54507bab948 100644 --- a/sys/netpfil/ipfw/ip_fw_nat.c +++ b/sys/netpfil/ipfw/ip_fw_nat.c @@ -676,8 +676,8 @@ static moduledata_t ipfw_nat_mod = { }; /* Define startup order. */ -#define IPFW_NAT_SI_SUB_FIREWALL (SI_SUB_PROTO_IFATTACHDOMAIN + 1) -#define IPFW_NAT_MODEVENT_ORDER (SI_ORDER_ANY - 255) +#define IPFW_NAT_SI_SUB_FIREWALL SI_SUB_PROTO_IFATTACHDOMAIN +#define IPFW_NAT_MODEVENT_ORDER (SI_ORDER_ANY - 128) /* after ipfw */ #define IPFW_NAT_MODULE_ORDER (IPFW_NAT_MODEVENT_ORDER + 1) #define IPFW_NAT_VNET_ORDER (IPFW_NAT_MODEVENT_ORDER + 2) From 5280a314787806c5c19e63cfd8200b5c25b3fd77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Sat, 26 Apr 2014 11:50:25 +0000 Subject: [PATCH 02/67] r261913 broke DES passwords, because the only way they could work, since they don't have an easily recognizable signature, was if they were the default. This commit rewrites crypt_set_format(3) etc to address this: - Use a pointer instead of an index to identify the default format. This pointer is initialized at compile time to point to the first first element in the list of supported formats, eliminating the need for crypt_setdefault(). Using a pointer also simplifies iterating through the list. - Associate DES with the magic string "_", which takes care of the Extended DES format. - Finally, as a special case, if the salt does not match any known magic string but matches ^[./0-9A-Za-z]{13}$, it is assumed to be a DES password and is passed on to crypt_des(). MFC after: 1 week --- lib/libcrypt/crypt.c | 133 ++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 77 deletions(-) diff --git a/lib/libcrypt/crypt.c b/lib/libcrypt/crypt.c index ec4c7d0953c..040fdc1b90a 100644 --- a/lib/libcrypt/crypt.c +++ b/lib/libcrypt/crypt.c @@ -1,6 +1,7 @@ -/* - * Copyright (c) 1999 - * Mark Murray. All rights reserved. +/*- + * Copyright (c) 1999 Mark Murray + * Copyright (c) 2014 Dag-Erling Smørgrav + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,110 +29,88 @@ __FBSDID("$FreeBSD$"); #include -#include + #include +#include #include + #include "crypt.h" -static const struct { +/* + * List of supported crypt(3) formats. The first element in the list will + * be the default. + */ +static const struct crypt_format { const char *const name; char *(*const func)(const char *, const char *); const char *const magic; -} crypt_types[] = { -#ifdef HAS_DES - { - "des", - crypt_des, - NULL - }, -#endif - { - "md5", - crypt_md5, - "$1$" - }, +} crypt_formats[] = { + /* default format */ + { "sha512", crypt_sha512, "$6$" }, + + /* other supported formats */ + { "md5", crypt_md5, "$1$" }, #ifdef HAS_BLOWFISH - { - "blf", - crypt_blowfish, - "$2" - }, + { "blf", crypt_blowfish, "$2" }, #endif - { - "nth", - crypt_nthash, - "$3$" - }, - { - "sha256", - crypt_sha256, - "$5$" - }, - { - "sha512", - crypt_sha512, - "$6$" - }, - { - NULL, - NULL, - NULL - } + { "nth", crypt_nthash, "$3$" }, + { "sha256", crypt_sha256, "$5$" }, +#ifdef HAS_DES + { "des", crypt_des, "_" }, +#endif + + /* sentinel */ + { NULL, NULL, NULL } }; -#define CRYPT_DEFAULT "sha512" +static const struct crypt_format *crypt_format = &crypt_formats[0]; -static int crypt_type = -1; - -static void -crypt_setdefault(void) -{ - size_t i; - - if (crypt_type != -1) - return; - for (i = 0; i < sizeof(crypt_types) / sizeof(crypt_types[0]) - 1; i++) { - if (strcmp(CRYPT_DEFAULT, crypt_types[i].name) == 0) { - crypt_type = (int)i; - return; - } - } - crypt_type = 0; -} +#define DES_SALT_ALPHABET \ + "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" +/* + * Returns the name of the currently selected format. + */ const char * crypt_get_format(void) { - crypt_setdefault(); - return (crypt_types[crypt_type].name); + return (crypt_format->name); } +/* + * Selects the format to use for subsequent crypt(3) invocations. + */ int -crypt_set_format(const char *type) +crypt_set_format(const char *format) { - size_t i; + const struct crypt_format *cf; - crypt_setdefault(); - for (i = 0; i < sizeof(crypt_types) / sizeof(crypt_types[0]) - 1; i++) { - if (strcmp(type, crypt_types[i].name) == 0) { - crypt_type = (int)i; + for (cf = crypt_formats; cf->name != NULL; ++cf) { + if (strcasecmp(cf->name, format) == 0) { + crypt_format = cf; return (1); } } return (0); } +/* + * Hash the given password with the given salt. If the salt begins with a + * magic string (e.g. "$6$" for sha512), the corresponding format is used; + * otherwise, the currently selected format is used. + */ char * crypt(const char *passwd, const char *salt) { - size_t i; + const struct crypt_format *cf; - crypt_setdefault(); - for (i = 0; i < sizeof(crypt_types) / sizeof(crypt_types[0]) - 1; i++) { - if (crypt_types[i].magic != NULL && strncmp(salt, - crypt_types[i].magic, strlen(crypt_types[i].magic)) == 0) - return (crypt_types[i].func(passwd, salt)); - } - return (crypt_types[crypt_type].func(passwd, salt)); + for (cf = crypt_formats; cf->name != NULL; ++cf) + if (cf->magic != NULL && strstr(salt, cf->magic) == salt) + return (cf->func(passwd, salt)); +#ifdef HAS_DES + if (strlen(salt) == 13 && strspn(salt, DES_SALT_ALPHABET) == 13) + return (crypt_des(passwd, salt)); +#endif + return (crypt_format->func(passwd, salt)); } From 87a6395ab836e37546c12056c405722e2f96e93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Sat, 26 Apr 2014 12:16:40 +0000 Subject: [PATCH 03/67] Note that the bug was fixed, and when. --- tools/regression/vfs/trailing_slash.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/regression/vfs/trailing_slash.t b/tools/regression/vfs/trailing_slash.t index b4e9339e79f..b1b8523e93e 100755 --- a/tools/regression/vfs/trailing_slash.t +++ b/tools/regression/vfs/trailing_slash.t @@ -3,7 +3,7 @@ # $FreeBSD$ # # Tests vfs_lookup()'s handling of trailing slashes for symlinks that -# point to files. See kern/21768 +# point to files. See kern/21768 for details. Fixed in r193028. # testfile="/tmp/testfile-$$" From 612032773ab46764a296cd6a4b779a591809b77c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Sat, 26 Apr 2014 12:18:17 +0000 Subject: [PATCH 04/67] Add sysctl OIDs showing the actual size and capacity of the swap zone. MFC after: 1 week --- sys/vm/swap_pager.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 661b2b6af2e..4745ee6d385 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -164,6 +164,12 @@ static int overcommit = 0; SYSCTL_INT(_vm, OID_AUTO, overcommit, CTLFLAG_RW, &overcommit, 0, "Configure virtual memory overcommit behavior. See tuning(7) " "for details."); +static unsigned long swzone; +SYSCTL_ULONG(_vm, OID_AUTO, swzone, CTLFLAG_RD, &swzone, 0, + "Actual size of swap metadata zone"); +static unsigned long swap_maxpages; +SYSCTL_ULONG(_vm, OID_AUTO, swap_maxpages, CTLFLAG_RD, &swap_maxpages, 0, + "Maximum amount of swap supported"); /* bits from overcommit */ #define SWAP_RESERVE_FORCE_ON (1 << 0) @@ -506,7 +512,7 @@ swap_pager_init(void) void swap_pager_swap_init(void) { - int n, n2; + unsigned long n, n2; /* * Number of in-transit swap bp operations. Don't @@ -542,7 +548,7 @@ swap_pager_swap_init(void) /* * Initialize our zone. Right now I'm just guessing on the number * we need based on the number of pages in the system. Each swblock - * can hold 16 pages, so this is probably overkill. This reservation + * can hold 32 pages, so this is probably overkill. This reservation * is typically limited to around 32MB by default. */ n = vm_cnt.v_page_count / 2; @@ -563,7 +569,9 @@ swap_pager_swap_init(void) n -= ((n + 2) / 3); } while (n > 0); if (n2 != n) - printf("Swap zone entries reduced from %d to %d.\n", n2, n); + printf("Swap zone entries reduced from %lu to %lu.\n", n2, n); + swap_maxpages = n * SWAP_META_PAGES; + swzone = n * sizeof(struct swblock); n2 = n; /* From b69ced8d8c13d96fc35a9d0153db4fa26ae5541d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Sat, 26 Apr 2014 13:05:56 +0000 Subject: [PATCH 05/67] date(1): Add "-R" flag to use RFC 2822 date and time output format As stated in the man page, this is equivalent to use "%a, %d %b %Y %T %z" as the output format while LC_TIME is set to the "C" locale. This is compatible with date(1) from the GNU core utilities. --- bin/date/date.1 | 14 ++++++++++++-- bin/date/date.c | 24 ++++++++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/bin/date/date.1 b/bin/date/date.1 index d1cbb445710..a4eddd1896d 100644 --- a/bin/date/date.1 +++ b/bin/date/date.1 @@ -40,7 +40,7 @@ .Nd display or set date and time .Sh SYNOPSIS .Nm -.Op Fl ju +.Op Fl jRu .Op Fl r Ar seconds .Oo .Fl v @@ -58,7 +58,7 @@ .Ar MM Op Ar .ss .Sm on .Nm -.Op Fl jnu +.Op Fl jnRu .Fl f Ar input_fmt new_date .Op Cm + Ns Ar output_fmt .Nm @@ -130,6 +130,16 @@ The .Fl n option suppresses this behavior and causes the time to be set only on the current machine. +.It Fl R +Use RFC 2822 date and time output format. This is equivalent to use +.Dq Li %a, %d %b %Y \&%T %z +as +.Ar output_fmt +while +.Ev LC_TIME +is set to the +.Dq C +locale . .It Fl r Ar seconds Print the date and time represented by .Ar seconds , diff --git a/bin/date/date.c b/bin/date/date.c index 58a9afb0d0f..2c09848a151 100644 --- a/bin/date/date.c +++ b/bin/date/date.c @@ -69,12 +69,14 @@ static void setthetime(const char *, const char *, int, int); static void badformat(void); static void usage(void); +static const char *rfc2822_format = "%a, %d %b %Y %T %z"; + int main(int argc, char *argv[]) { struct timezone tz; int ch, rflag; - int jflag, nflag; + int jflag, nflag, Rflag; const char *format; char buf[1024]; char *endptr, *fmt; @@ -89,9 +91,9 @@ main(int argc, char *argv[]) (void) setlocale(LC_TIME, ""); tz.tz_dsttime = tz.tz_minuteswest = 0; rflag = 0; - jflag = nflag = 0; + jflag = nflag = Rflag = 0; set_timezone = 0; - while ((ch = getopt(argc, argv, "d:f:jnr:t:uv:")) != -1) + while ((ch = getopt(argc, argv, "d:f:jnRr:t:uv:")) != -1) switch((char)ch) { case 'd': /* daylight savings time */ tz.tz_dsttime = strtol(optarg, &endptr, 10) ? 1 : 0; @@ -108,6 +110,9 @@ main(int argc, char *argv[]) case 'n': /* don't set network */ nflag = 1; break; + case 'R': /* RFC 2822 datetime format */ + Rflag = 1; + break; case 'r': /* user specified seconds */ rflag = 1; tval = strtoq(optarg, &tmp, 0); @@ -145,6 +150,9 @@ main(int argc, char *argv[]) format = "%+"; + if (Rflag) + format = rfc2822_format; + /* allow the operands in any order */ if (*argv && **argv == '+') { format = *argv + 1; @@ -169,6 +177,14 @@ main(int argc, char *argv[]) usage(); } vary_destroy(v); + + if (format == rfc2822_format) + /* + * When using RFC 2822 datetime format, don't honor the + * locale. + */ + setlocale(LC_TIME, "C"); + (void)strftime(buf, sizeof(buf), format, <); (void)printf("%s\n", buf); if (fflush(stdout)) @@ -301,7 +317,7 @@ static void usage(void) { (void)fprintf(stderr, "%s\n%s\n", - "usage: date [-jnu] [-d dst] [-r seconds] [-t west] " + "usage: date [-jnRu] [-d dst] [-r seconds] [-t west] " "[-v[+|-]val[ymwdHMS]] ... ", " " "[-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]"); From 169050a03083ef1708b9d186d21d9e72b2d659fc Mon Sep 17 00:00:00 2001 From: Mark Murray Date: Sat, 26 Apr 2014 13:21:28 +0000 Subject: [PATCH 06/67] Correctly set the sysctl format to Alphanumeric, rather than letting it default. Approved by: security-officer(des) --- sys/dev/random/random_adaptors.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/random/random_adaptors.c b/sys/dev/random/random_adaptors.c index 4f5ad2c1ebe..aa6db7b7494 100644 --- a/sys/dev/random/random_adaptors.c +++ b/sys/dev/random/random_adaptors.c @@ -220,12 +220,12 @@ random_adaptors_init(void *unused) SYSCTL_PROC(_kern_random, OID_AUTO, adaptors, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, - NULL, 0, random_sysctl_adaptors_handler, "", + NULL, 0, random_sysctl_adaptors_handler, "A", "Random Number Generator adaptors"); SYSCTL_PROC(_kern_random, OID_AUTO, active_adaptor, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, - NULL, 0, random_sysctl_active_adaptor_handler, "", + NULL, 0, random_sysctl_active_adaptor_handler, "A", "Active Random Number Generator Adaptor"); sx_init(&adaptors_lock, "random_adaptors"); From 2fd66cdd227f4d72efa79558fe0da2d579d5ba6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Sat, 26 Apr 2014 13:53:04 +0000 Subject: [PATCH 07/67] date(1): Forgot to update manpage date in r264968 MFC after: 1 week MFC with: 264968 --- bin/date/date.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/date/date.1 b/bin/date/date.1 index a4eddd1896d..5e9e6648d6d 100644 --- a/bin/date/date.1 +++ b/bin/date/date.1 @@ -32,7 +32,7 @@ .\" @(#)date.1 8.3 (Berkeley) 4/28/95 .\" $FreeBSD$ .\" -.Dd June 3, 2010 +.Dd April 26, 2014 .Dt DATE 1 .Os .Sh NAME From 11a4d354a2e13e6066a9ca9dfb09147ace9dec9b Mon Sep 17 00:00:00 2001 From: Kevin Lo Date: Sat, 26 Apr 2014 14:39:58 +0000 Subject: [PATCH 08/67] Initialize rssi variable. --- sys/dev/usb/wlan/if_urtwn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/dev/usb/wlan/if_urtwn.c b/sys/dev/usb/wlan/if_urtwn.c index 925717505b6..7f69f9617e3 100644 --- a/sys/dev/usb/wlan/if_urtwn.c +++ b/sys/dev/usb/wlan/if_urtwn.c @@ -1738,6 +1738,7 @@ urtwn_r88e_get_rssi(struct urtwn_softc *sc, int rate, void *physt) uint8_t cck_agc_rpt, lna_idx, vga_idx; int8_t rssi; + rssi = 0; if (rate <= 3) { cck = (struct r88e_rx_cck *)physt; cck_agc_rpt = cck->agc_rpt; From 36d55f0f9d7b69cc1cfeeb28830ac445c44ad3ed Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Sat, 26 Apr 2014 14:52:03 +0000 Subject: [PATCH 09/67] Unify sa_equal() macro usage. MFC after: 2 weeks --- sys/net/if.c | 3 --- sys/net/route.c | 4 ---- sys/net/route.h | 4 ++++ sys/net/rtsock.c | 2 -- sys/netinet6/ip6_input.c | 3 --- 5 files changed, 4 insertions(+), 12 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index aa44b786362..585269a2c93 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1550,9 +1550,6 @@ ifa_switch_loopback_route(struct ifaddr *ifa, struct sockaddr *sa, int fib) * to perform a different comparison. */ -#define sa_equal(a1, a2) \ - (bcmp((a1), (a2), ((a1))->sa_len) == 0) - #define sa_dl_equal(a1, a2) \ ((((struct sockaddr_dl *)(a1))->sdl_len == \ ((struct sockaddr_dl *)(a2))->sdl_len) && \ diff --git a/sys/net/route.c b/sys/net/route.c index f2df0803be5..623772a479e 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -125,10 +125,6 @@ VNET_DEFINE(int, rttrash); /* routes not in table but not freed */ #define V_rttrash VNET(rttrash) -/* compare two sockaddr structures */ -#define sa_equal(a1, a2) (((a1)->sa_len == (a2)->sa_len) && \ - (bcmp((a1), (a2), (a1)->sa_len) == 0)) - /* * Convert a 'struct radix_node *' to a 'struct rtentry *'. * The operation can be done safely (in this code) because a diff --git a/sys/net/route.h b/sys/net/route.h index 4ac3458dd3a..913828a5ccc 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -275,6 +275,10 @@ struct rt_addrinfo { sizeof(long) : \ 1 + ( (((struct sockaddr *)(sa))->sa_len - 1) | (sizeof(long) - 1) ) ) +#define sa_equal(a, b) ( \ + (((struct sockaddr *)(a))->sa_len == ((struct sockaddr *)(b))->sa_len) && \ + (bcmp((a), (b), ((struct sockaddr *)(b))->sa_len) == 0)) + #ifdef _KERNEL #define RT_LINK_IS_UP(ifp) (!((ifp)->if_capabilities & IFCAP_LINKSTATE) \ diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 13aa050ac81..02f44d6fd21 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -517,7 +517,6 @@ rtm_get_jailed(struct rt_addrinfo *info, struct ifnet *ifp, static int route_output(struct mbuf *m, struct socket *so) { -#define sa_equal(a1, a2) (bcmp((a1), (a2), (a1)->sa_len) == 0) struct rt_msghdr *rtm = NULL; struct rtentry *rt = NULL; struct radix_node_head *rnh; @@ -960,7 +959,6 @@ route_output(struct mbuf *m, struct socket *so) Free(rtm); } return (error); -#undef sa_equal } static void diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index 239c95052df..a33341d8f0c 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -695,8 +695,6 @@ ip6_input(struct mbuf *m) int bad; bad = 1; -#define sa_equal(a1, a2) \ - (bcmp((a1), (a2), ((a1))->sin6_len) == 0) IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != dst6.sin6_family) @@ -706,7 +704,6 @@ ip6_input(struct mbuf *m) } KASSERT(ifa != NULL, ("%s: ifa not found for lle %p", __func__, lle)); -#undef sa_equal ia6 = (struct in6_ifaddr *)ifa; if (!(ia6->ia6_flags & IN6_IFF_NOTREADY)) { From 4b29ef64b216bb0a81a8567f87e1be4cfd34a9ea Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Sat, 26 Apr 2014 16:12:39 +0000 Subject: [PATCH 10/67] Remove sa_equal() definition since it is already defined in net/route.h. Noted by: ian MFC after: 2 weeks --- usr.sbin/ifmcstat/ifmcstat.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/usr.sbin/ifmcstat/ifmcstat.c b/usr.sbin/ifmcstat/ifmcstat.c index b1ae171a7d6..9f5187761be 100644 --- a/usr.sbin/ifmcstat/ifmcstat.c +++ b/usr.sbin/ifmcstat/ifmcstat.c @@ -116,9 +116,6 @@ int Kflag = 0; #endif int vflag = 0; -#define sa_equal(a1, a2) \ - (bcmp((a1), (a2), ((a1))->sa_len) == 0) - #define sa_dl_equal(a1, a2) \ ((((struct sockaddr_dl *)(a1))->sdl_len == \ ((struct sockaddr_dl *)(a2))->sdl_len) && \ From e9bee2c689b78173a301e31349573ecf809afeec Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sat, 26 Apr 2014 16:34:22 +0000 Subject: [PATCH 11/67] Add generation of an EFI filesystem to hold boot1.efi. This is a near-exact copy of the code from boot1.chrp again. The resulting image is installed to /boot/boot1.efifat. If dd'ed to an 800K "efi" partition, it should result in a bootable system. --- sys/boot/amd64/boot1.efi/Makefile | 16 ++++++- sys/boot/amd64/boot1.efi/Makefile.fat | 3 ++ sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu | 22 ++++++++++ sys/boot/amd64/boot1.efi/generate-fat.sh | 54 ++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 sys/boot/amd64/boot1.efi/Makefile.fat create mode 100644 sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu create mode 100755 sys/boot/amd64/boot1.efi/generate-fat.sh diff --git a/sys/boot/amd64/boot1.efi/Makefile b/sys/boot/amd64/boot1.efi/Makefile index 55752a23ea9..641861ed00a 100644 --- a/sys/boot/amd64/boot1.efi/Makefile +++ b/sys/boot/amd64/boot1.efi/Makefile @@ -26,7 +26,7 @@ CFLAGS+= -I${.CURDIR}/../../.. .PATH: ${.CURDIR}/../efi ${.CURDIR}/../../common CFLAGS+= -I${.CURDIR}/../../common -FILES= boot1.efi +FILES= boot1.efi boot1.efifat FILESMODE_boot1.efi= ${BINMODE} LDSCRIPT= ${.CURDIR}/../efi/ldscript.${MACHINE_CPUARCH} @@ -57,6 +57,20 @@ CFLAGS+= -I${.CURDIR}/../../common boot1.o: ${.CURDIR}/../../common/ufsread.c +# The following inserts out objects into a template FAT file system +# created by generate-fat.sh + +.include "${.CURDIR}/Makefile.fat" + +boot1.efifat: boot1.efi + echo ${.OBJDIR} + uudecode ${.CURDIR}/fat.tmpl.bz2.uu + mv fat.tmpl.bz2 ${.TARGET}.bz2 + bzip2 -f -d ${.TARGET}.bz2 + dd if=boot1.efi of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc + +CLEANFILES= boot1.efifat + .endif # ${COMPILER_TYPE} != "gcc" .include diff --git a/sys/boot/amd64/boot1.efi/Makefile.fat b/sys/boot/amd64/boot1.efi/Makefile.fat new file mode 100644 index 00000000000..324481e1a31 --- /dev/null +++ b/sys/boot/amd64/boot1.efi/Makefile.fat @@ -0,0 +1,3 @@ +# This file autogenerated by generate-fat.sh - DO NOT EDIT +# $FreeBSD$ +BOOT1_OFFSET=0x2d diff --git a/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu b/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu new file mode 100644 index 00000000000..2af42444810 --- /dev/null +++ b/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu @@ -0,0 +1,22 @@ +FAT template boot filesystem created by generate-fat.sh +DO NOT EDIT +$FreeBSD$ +begin 644 fat.tmpl.bz2 +M0EIH.3%!62936?1V`!$`&J7____[ZZKJJ_^N_ZO^Z_^[ON_\`4`00!0$#$$" +M0D)$6&(IZC3RGZH\B&$,U&AH#)B:,$8TAF@@]0T>IZF&A +M&GZID,1IZFAMO%FPGL0"(QIZV"3_!`$@N(@`DD$?C&$["`)`!)$6@#\HOB42 +M0`"2(X0FGX1#L"`'7E,'#-'HM!'QUD0\R,?9U,6ZE8F,Y6*L<9S<6PH)"%_" +MX'_PL4A),QB"(`B(=14*-"8,(QCG.(2$A(1J'010CB&R$(0B00FPP(0A"$)E +M#`A"$(1]LB&!"$(0B4&1#`A"$(14W<9J.:&A@8&!@8'`Z$(D(02@^L=UL>:+ +MBG:Q5+4&'[/P4@D2?M<,E!0&YBF8+],4^%$`4*%$N9MF:Z29-_VG2G7<$LJ-44RST& +MB53YE@H%(G5G$.FU;=L[DQVA]"(V4B1+%BP%.A<-10-%#R#NKR='@\'#"_'U +M'I36ZT:8QIN*3E$:HZIZRJ?$Y1L&<1'C)G(=8,E.L(KU<9X=%/NX.6\=@^IW +M\-PC$B&I"T\!(VI3"K!X:\%.01Y#X/83[SH.J*H5BH:ILFV1'X/D/V1$W6'\ +MFY>YE:*(I!.X@'D>H_(PY'(W1+B;:,Y?H8Y%(Q')!>DDE;\J1-DRXJJ/O(1@ +M'X/24=!+/V8S1)B(R:UE"0&&1:PUS(1`!$04``++GZ/8(CE5P1P8?^7QB[DB +(G"A(>CL`"(`` +` +end diff --git a/sys/boot/amd64/boot1.efi/generate-fat.sh b/sys/boot/amd64/boot1.efi/generate-fat.sh new file mode 100755 index 00000000000..eafd3e00dfe --- /dev/null +++ b/sys/boot/amd64/boot1.efi/generate-fat.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +# This script generates the dummy FAT filesystem used for the EFI boot +# blocks. It uses newfs_msdos to generate a template filesystem with the +# relevant interesting files. These are then found by grep, and the offsets +# written to a Makefile snippet. +# +# Because it requires root, and because it is overkill, we do not +# do this as part of the normal build. If makefs(8) grows workable FAT +# support, this should be revisited. + +# $FreeBSD$ + +FAT_SIZE=1600 #Size in 512-byte blocks of the produced image + +BOOT1_SIZE=64k + +# Generate 800K FAT image +OUTPUT_FILE=fat.tmpl + +dd if=/dev/zero of=$OUTPUT_FILE bs=512 count=$FAT_SIZE +DEVICE=`mdconfig -a -f $OUTPUT_FILE` +newfs_msdos -F 12 $DEVICE +mkdir stub +mount -t msdosfs /dev/$DEVICE stub + +# Create and bless a directory for the boot loader +mkdir -p stub/efi/boot + +# Make a dummy file for boot1 +echo 'Boot1 START' | dd of=stub/efi/boot/BOOTx64.efi cbs=$BOOT1_SIZE count=1 conv=block + +umount stub +mdconfig -d -u $DEVICE +rmdir stub + +# Locate the offsets of the two fake files +BOOT1_OFFSET=$(hd $OUTPUT_FILE | grep 'Boot1 START' | cut -f 1 -d ' ') + +# Convert to numbers of blocks +BOOT1_OFFSET=$(echo 0x$BOOT1_OFFSET | awk '{printf("%x\n",$1/512);}') + +echo '# This file autogenerated by generate-fat.sh - DO NOT EDIT' > Makefile.fat +echo '# $FreeBSD$' >> Makefile.fat +echo "BOOT1_OFFSET=0x$BOOT1_OFFSET" >> Makefile.fat + +bzip2 $OUTPUT_FILE +echo 'FAT template boot filesystem created by generate-fat.sh' > $OUTPUT_FILE.bz2.uu +echo 'DO NOT EDIT' >> $OUTPUT_FILE.bz2.uu +echo '$FreeBSD$' >> $OUTPUT_FILE.bz2.uu + +uuencode $OUTPUT_FILE.bz2 $OUTPUT_FILE.bz2 >> $OUTPUT_FILE.bz2.uu +rm $OUTPUT_FILE.bz2 + From cf58751a44ab54d16fdd26400c5165a54042047e Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Sat, 26 Apr 2014 16:46:33 +0000 Subject: [PATCH 12/67] Use "hash" value in rtalloc_mpath_fib() instead of RTF_ANNOUNCE flag. Hashing method is the same as in in6_src.c. (Probably we need better one). MFC after: 2 weeks --- sys/netinet6/nd6_nbr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index dc877aae733..09751968431 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -242,7 +242,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len) /* Always use the default FIB. */ #ifdef RADIX_MPATH - rtalloc_mpath_fib((struct route *)&ro, RTF_ANNOUNCE, + rtalloc_mpath_fib((struct route *)&ro, ntohl(taddr6.s6_addr32[3]), RT_DEFAULT_FIB); #else in6_rtalloc(&ro, RT_DEFAULT_FIB); From a7fa939bb3564122505b0b6b66fdf00e13bffe01 Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Sat, 26 Apr 2014 16:48:09 +0000 Subject: [PATCH 13/67] Stop calling imx51_ccm_foo() clock functions from imx6 code. Instead define a few imx_ccm_foo() functions that are implemented by the imx51 or imx6 ccm code. Of course, the imx6 ccm code is still more a wish than reality, so for now its implementations just return hard-coded numbers. --- sys/arm/freescale/imx/imx51_ccm.c | 28 +++++++++++++ sys/arm/freescale/imx/imx6_ccm.c | 54 +++++++++++++++----------- sys/arm/freescale/imx/imx6_usbphy.c | 2 +- sys/arm/freescale/imx/imx_ccmvar.h | 54 ++++++++++++++++++++++++++ sys/arm/freescale/imx/imx_gpt.c | 6 +-- sys/arm/freescale/imx/imx_machdep.h | 16 -------- sys/arm/freescale/imx/imx_nop_usbphy.c | 2 +- sys/arm/freescale/imx/imx_sdhci.c | 9 +---- sys/dev/usb/controller/ehci_imx.c | 2 +- 9 files changed, 122 insertions(+), 51 deletions(-) create mode 100644 sys/arm/freescale/imx/imx_ccmvar.h diff --git a/sys/arm/freescale/imx/imx51_ccm.c b/sys/arm/freescale/imx/imx51_ccm.c index 61fdfdc75b3..e0043644ad0 100644 --- a/sys/arm/freescale/imx/imx51_ccm.c +++ b/sys/arm/freescale/imx/imx51_ccm.c @@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #define IMXCCMDEBUG @@ -552,3 +553,30 @@ imx_ccm_usbphy_enable(device_t dev) } } +uint32_t +imx_ccm_ipg_hz(void) +{ + + return (imx51_get_clock(IMX51CLK_IPG_CLK_ROOT)); +} + +uint32_t +imx_ccm_sdhci_hz(void) +{ + + return (imx51_get_clock(IMX51CLK_ESDHC1_CLK_ROOT)); +} + +uint32_t +imx_ccm_perclk_hz(void) +{ + + return (imx51_get_clock(IMX51CLK_PERCLK_ROOT)); +} + +uint32_t +imx_ccm_uart_hz(void) +{ + + return (imx51_get_clock(IMX51CLK_UART_CLK_ROOT)); +} diff --git a/sys/arm/freescale/imx/imx6_ccm.c b/sys/arm/freescale/imx/imx6_ccm.c index 2ed301f435c..132c31c3a79 100644 --- a/sys/arm/freescale/imx/imx6_ccm.c +++ b/sys/arm/freescale/imx/imx6_ccm.c @@ -45,13 +45,15 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include +#include +#include - -/* XXX temp kludge for imx51_get_clock. */ -#include -#include +#ifndef CCGR_CLK_MODE_ALWAYS +#define CCGR_CLK_MODE_OFF 0 +#define CCGR_CLK_MODE_RUNMODE 1 +#define CCGR_CLK_MODE_ALWAYS 3 +#endif struct ccm_softc { device_t dev; @@ -208,24 +210,32 @@ imx_ccm_usbphy_enable(device_t _phydev) #endif } - - - - -// XXX Fix this. This has to be here for other code to link, -// but it doesn't have to return anything useful for imx6 right now. -u_int -imx51_get_clock(enum imx51_clock clk) +uint32_t +imx_ccm_ipg_hz(void) { - switch (clk) - { - case IMX51CLK_IPG_CLK_ROOT: - return 66000000; - default: - printf("imx51_get_clock() on imx6 doesn't know about clock %d\n", clk); - break; - } - return 0; + + return (66000000); +} + +uint32_t +imx_ccm_perclk_hz(void) +{ + + return (66000000); +} + +uint32_t +imx_ccm_sdhci_hz(void) +{ + + return (200000000); +} + +uint32_t +imx_ccm_uart_hz(void) +{ + + return (80000000); } static device_method_t ccm_methods[] = { diff --git a/sys/arm/freescale/imx/imx6_usbphy.c b/sys/arm/freescale/imx/imx6_usbphy.c index 7f3e362a563..a338737a63d 100644 --- a/sys/arm/freescale/imx/imx6_usbphy.c +++ b/sys/arm/freescale/imx/imx6_usbphy.c @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include #include #include diff --git a/sys/arm/freescale/imx/imx_ccmvar.h b/sys/arm/freescale/imx/imx_ccmvar.h new file mode 100644 index 00000000000..bb41a026851 --- /dev/null +++ b/sys/arm/freescale/imx/imx_ccmvar.h @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 2014 Ian Lepore + * 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$ + */ + +#ifndef IMX_CCMVAR_H +#define IMX_CCMVAR_H + +/* + * We need a clock management system that works across unrelated SoCs and + * devices. For now, to keep imx development moving, define some barebones + * functionality that can be shared within the imx family by having each SoC + * implement functions with a common name. + * + * The usb enable functions are best-effort. They turn on the usb otg, host, + * and phy clocks in a SoC-specific manner, but it may take a lot more than that + * to make usb work on a given board. In particular, it can require specific + * pinmux setup of gpio pins connected to external phy parts, voltage regulators + * and overcurrent detectors, and so on. On such boards, u-boot or other early + * board setup code has to handle those things. + */ + +uint32_t imx_ccm_ipg_hz(void); +uint32_t imx_ccm_perclk_hz(void); +uint32_t imx_ccm_sdhci_hz(void); +uint32_t imx_ccm_uart_hz(void); + +void imx_ccm_usb_enable(device_t _usbdev); +void imx_ccm_usbphy_enable(device_t _phydev); + +#endif diff --git a/sys/arm/freescale/imx/imx_gpt.c b/sys/arm/freescale/imx/imx_gpt.c index 73bc8ece31f..abbb1409996 100644 --- a/sys/arm/freescale/imx/imx_gpt.c +++ b/sys/arm/freescale/imx/imx_gpt.c @@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #define WRITE4(_sc, _r, _v) \ bus_space_write_4((_sc)->sc_iot, (_sc)->sc_ioh, (_r), (_v)) @@ -164,10 +164,10 @@ imx_gpt_attach(device_t dev) basefreq = 32768; break; case GPT_CR_CLKSRC_IPG: - basefreq = imx51_get_clock(IMX51CLK_IPG_CLK_ROOT); + basefreq = imx_ccm_ipg_hz(); break; case GPT_CR_CLKSRC_IPG_HIGH: - basefreq = imx51_get_clock(IMX51CLK_IPG_CLK_ROOT) * 2; + basefreq = imx_ccm_ipg_hz() * 2; break; case GPT_CR_CLKSRC_24M: ctlreg |= GPT_CR_24MEN; diff --git a/sys/arm/freescale/imx/imx_machdep.h b/sys/arm/freescale/imx/imx_machdep.h index b78f0da288b..6909e51504b 100644 --- a/sys/arm/freescale/imx/imx_machdep.h +++ b/sys/arm/freescale/imx/imx_machdep.h @@ -56,21 +56,5 @@ void imx_wdog_cpu_reset(vm_offset_t _wdcr_phys) __attribute__((__noreturn__)); u_int imx_soc_type(void); u_int imx_soc_family(void); -/* - * We need a clock management system that works across unrelated SoCs and - * devices. For now, to keep imx development moving, define some barebones - * functionality that can be shared within the imx family by having each SoC - * implement functions with a common name. - * - * The usb enable functions are best-effort. They turn on the usb otg, host, - * and phy clocks in a SoC-specific manner, but it may take a lot more than that - * to make usb work on a given board. In particular, it can require specific - * pinmux setup of gpio pins connected to external phy parts, voltage regulators - * and overcurrent detectors, and so on. On such boards, u-boot or other early - * board setup code has to handle those things. - */ -void imx_ccm_usb_enable(device_t _usbdev); -void imx_ccm_usbphy_enable(device_t _phydev); - #endif diff --git a/sys/arm/freescale/imx/imx_nop_usbphy.c b/sys/arm/freescale/imx/imx_nop_usbphy.c index 38473dd7696..49bebfcd573 100644 --- a/sys/arm/freescale/imx/imx_nop_usbphy.c +++ b/sys/arm/freescale/imx/imx_nop_usbphy.c @@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include /* * Table of supported FDT compat strings. diff --git a/sys/arm/freescale/imx/imx_sdhci.c b/sys/arm/freescale/imx/imx_sdhci.c index 2e3d1a5b5b0..a476cb75cee 100644 --- a/sys/arm/freescale/imx/imx_sdhci.c +++ b/sys/arm/freescale/imx/imx_sdhci.c @@ -52,7 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include #include @@ -723,12 +723,7 @@ imx_sdhci_attach(device_t dev) */ WR4(sc, SDHC_WTMK_LVL, 0x08800880); - /* XXX get imx6 clock frequency from CCM */ - if (sc->hwtype == HWTYPE_USDHC) { - sc->baseclk_hz = 200000000; - } else if (sc->hwtype == HWTYPE_ESDHC) { - sc->baseclk_hz = imx51_get_clock(IMX51CLK_PERCLK_ROOT); - } + sc->baseclk_hz = imx_ccm_sdhci_hz(); /* * If the slot is flagged with the non-removable property, set our flag diff --git a/sys/dev/usb/controller/ehci_imx.c b/sys/dev/usb/controller/ehci_imx.c index d40f18d8c42..b36e7e65aca 100644 --- a/sys/dev/usb/controller/ehci_imx.c +++ b/sys/dev/usb/controller/ehci_imx.c @@ -60,7 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include "opt_platform.h" From 6b446ed5ab83d741d3d20d896b0fb67bb952f647 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sat, 26 Apr 2014 16:55:38 +0000 Subject: [PATCH 14/67] Add EFI support to the installer. This requires that the kernel provide a sysctl to determine what firmware is in use. This sysctl does not exist yet, so the following blocks are in front of the wheels: - I've provisionally called this "hw.platform" after the equivalent thing on PPC - The logic to check the sysctl is short-circuited to always choose BIOS. There's a comment in the top of the file about how to turn this off. If IA64 acquired a boot1.efifat-like thing (probably with very few modifications), the same code could be adapted there. --- usr.sbin/bsdinstall/partedit/gpart_ops.c | 9 +-- usr.sbin/bsdinstall/partedit/partedit.h | 9 +-- .../bsdinstall/partedit/partedit_generic.c | 5 ++ usr.sbin/bsdinstall/partedit/partedit_pc98.c | 5 ++ .../bsdinstall/partedit/partedit_powerpc.c | 5 ++ .../bsdinstall/partedit/partedit_sparc64.c | 5 ++ usr.sbin/bsdinstall/partedit/partedit_x86.c | 64 ++++++++++++++++--- 7 files changed, 85 insertions(+), 17 deletions(-) diff --git a/usr.sbin/bsdinstall/partedit/gpart_ops.c b/usr.sbin/bsdinstall/partedit/gpart_ops.c index 289ac98043b..27feb577e82 100644 --- a/usr.sbin/bsdinstall/partedit/gpart_ops.c +++ b/usr.sbin/bsdinstall/partedit/gpart_ops.c @@ -584,7 +584,7 @@ set_default_part_metadata(const char *name, const char *scheme, if (strcmp(type, "freebsd-swap") == 0) mountpoint = "none"; - if (strcmp(type, "freebsd-boot") == 0) + if (strcmp(type, bootpart_type(scheme)) == 0) md->bootcode = 1; /* VTOC8 needs partcode in UFS partitions */ @@ -949,7 +949,8 @@ gpart_create(struct gprovider *pp, char *default_type, char *default_size, LIST_FOREACH(gc, &pp->lg_config, lg_config) if (strcmp(gc->lg_name, "type") == 0) break; - if (gc != NULL && strcmp(gc->lg_val, "freebsd-boot") == 0) + if (gc != NULL && strcmp(gc->lg_val, + bootpart_type(scheme)) == 0) break; } @@ -971,7 +972,7 @@ gpart_create(struct gprovider *pp, char *default_type, char *default_size, gctl_ro_param(r, "arg0", -1, geom->lg_name); gctl_ro_param(r, "flags", -1, GPART_FLAGS); gctl_ro_param(r, "verb", -1, "add"); - gctl_ro_param(r, "type", -1, "freebsd-boot"); + gctl_ro_param(r, "type", -1, bootpart_type(scheme)); snprintf(sizestr, sizeof(sizestr), "%jd", bootpart_size(scheme) / sector); gctl_ro_param(r, "size", -1, sizestr); @@ -1031,7 +1032,7 @@ gpart_create(struct gprovider *pp, char *default_type, char *default_size, gctl_issue(r); /* Error usually expected and non-fatal */ gctl_free(r); - if (strcmp(items[0].text, "freebsd-boot") == 0) + if (strcmp(items[0].text, bootpart_type(scheme)) == 0) get_part_metadata(newpartname, 1)->bootcode = 1; else if (strcmp(items[0].text, "freebsd") == 0) gpart_partition(newpartname, "BSD"); diff --git a/usr.sbin/bsdinstall/partedit/partedit.h b/usr.sbin/bsdinstall/partedit/partedit.h index 121e3a2b4e4..32e3a36f374 100644 --- a/usr.sbin/bsdinstall/partedit/partedit.h +++ b/usr.sbin/bsdinstall/partedit/partedit.h @@ -74,9 +74,10 @@ void set_default_part_metadata(const char *name, const char *scheme, /* machine-dependent bootability checks */ const char *default_scheme(void); -int is_scheme_bootable(const char *part_type); -size_t bootpart_size(const char *part_type); -const char *bootcode_path(const char *part_type); -const char *partcode_path(const char *part_type); +int is_scheme_bootable(const char *scheme); +size_t bootpart_size(const char *scheme); +const char *bootpart_type(const char *scheme); +const char *bootcode_path(const char *scheme); +const char *partcode_path(const char *scheme); #endif diff --git a/usr.sbin/bsdinstall/partedit/partedit_generic.c b/usr.sbin/bsdinstall/partedit/partedit_generic.c index 96faafabcf5..8498a78ffcb 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_generic.c +++ b/usr.sbin/bsdinstall/partedit/partedit_generic.c @@ -57,6 +57,11 @@ bootpart_size(const char *part_type) { return (0); } +const char * +bootpart_type(const char *scheme) { + return ("freebsd-boot"); +} + const char * bootcode_path(const char *part_type) { return (NULL); diff --git a/usr.sbin/bsdinstall/partedit/partedit_pc98.c b/usr.sbin/bsdinstall/partedit/partedit_pc98.c index ec438f69ffd..dd075a1af7f 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_pc98.c +++ b/usr.sbin/bsdinstall/partedit/partedit_pc98.c @@ -51,6 +51,11 @@ bootpart_size(const char *part_type) { return (0); } +const char * +bootpart_type(const char *scheme) { + return ("freebsd-boot"); +} + const char * bootcode_path(const char *part_type) { if (strcmp(part_type, "PC98") == 0) diff --git a/usr.sbin/bsdinstall/partedit/partedit_powerpc.c b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c index 06129c7cf67..4fa2e0530e2 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_powerpc.c +++ b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c @@ -73,6 +73,11 @@ bootpart_size(const char *part_type) { return (0); } +const char * +bootpart_type(const char *scheme) { + return ("freebsd-boot"); +} + const char * bootcode_path(const char *part_type) { return (NULL); diff --git a/usr.sbin/bsdinstall/partedit/partedit_sparc64.c b/usr.sbin/bsdinstall/partedit/partedit_sparc64.c index b8ee052a817..8232c550c60 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_sparc64.c +++ b/usr.sbin/bsdinstall/partedit/partedit_sparc64.c @@ -49,6 +49,11 @@ bootpart_size(const char *part_type) { return (0); } +const char * +bootpart_type(const char *scheme) { + return ("freebsd-boot"); +} + const char * bootcode_path(const char *part_type) { return (NULL); diff --git a/usr.sbin/bsdinstall/partedit/partedit_x86.c b/usr.sbin/bsdinstall/partedit/partedit_x86.c index a03a7a7b4c2..c9eda5d746f 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_x86.c +++ b/usr.sbin/bsdinstall/partedit/partedit_x86.c @@ -26,10 +26,15 @@ * $FreeBSD$ */ +#include +#include #include #include "partedit.h" +static char platform[255] = "BIOS"; /* XXX once sysctl exists, make this an empty string */ +static const char *platform_sysctl = "hw.platform"; + const char * default_scheme(void) { return ("GPT"); @@ -37,27 +42,60 @@ default_scheme(void) { int is_scheme_bootable(const char *part_type) { - if (strcmp(part_type, "BSD") == 0) - return (1); + size_t platlen = sizeof(platform); + if (strlen(platform) == 0) + sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); + if (strcmp(part_type, "GPT") == 0) return (1); - if (strcmp(part_type, "MBR") == 0) - return (1); + if (strcmp(platform, "BIOS") == 0) { + if (strcmp(part_type, "BSD") == 0) + return (1); + if (strcmp(part_type, "MBR") == 0) + return (1); + } return (0); } size_t -bootpart_size(const char *part_type) { - if (strcmp(part_type, "GPT") == 0) - return (64*1024); +bootpart_size(const char *scheme) { + size_t platlen = sizeof(platform); + if (strlen(platform) == 0) + sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); /* No partcode except for GPT */ + if (strcmp(scheme, "GPT") != 0) + return (0); + + if (strcmp(platform, "BIOS") == 0) + return (64*1024); + else + return (800*1024); + return (0); } +const char * +bootpart_type(const char *scheme) { + size_t platlen = sizeof(platform); + if (strlen(platform) == 0) + sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); + + if (strcmp(platform, "EFI") == 0) + return ("efi"); + + return ("freebsd-boot"); +} + const char * bootcode_path(const char *part_type) { + size_t platlen = sizeof(platform); + if (strlen(platform) == 0) + sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); + if (strcmp(platform, "EFI") == 0) + return (NULL); + if (strcmp(part_type, "GPT") == 0) return ("/boot/pmbr"); if (strcmp(part_type, "MBR") == 0) @@ -70,8 +108,16 @@ bootcode_path(const char *part_type) { const char * partcode_path(const char *part_type) { - if (strcmp(part_type, "GPT") == 0) - return ("/boot/gptboot"); + size_t platlen = sizeof(platform); + if (strlen(platform) == 0) + sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); + + if (strcmp(part_type, "GPT") == 0) { + if (strcmp(platform, "EFI") == 0) + return ("/boot/boot1.efifat"); + else + return ("/boot/gptboot"); + } /* No partcode except for GPT */ return (NULL); From 845b7c7bf6f0e46a1aacbf6313c02798daf33372 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sat, 26 Apr 2014 16:58:35 +0000 Subject: [PATCH 15/67] make_dtb.sh is designed to be used in a kernel build environment where MACHINE is defined to the target's value, not the host's value. However, in Makefile.inc1, it is still defined to be the host's value. Make the makedtb target work by expanding TARGET in the existance test, and passing MACHINE=$TARGET in the call to make_dtb.sh --- Makefile.inc1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index d4fb4e989c6..c9ad941b0fe 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1833,7 +1833,7 @@ builddtb: echo "ERROR: FDT_DTS_FILE must be specified!"; \ exit 1; \ fi; \ - if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${MACHINE}/${FDT_DTS_FILE} ]; then \ + if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${TARGET}/${FDT_DTS_FILE} ]; then \ echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \ exist!"; \ exit 1; \ @@ -1843,6 +1843,7 @@ builddtb: directory"; \ fi @PATH=${TMPPATH} \ + MACHINE=${TARGET} \ ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \ ${FDT_DTS_FILE} \ ${DTBOUTPUTPATH}/`basename ${FDT_DTS_FILE} .dts` From 8f6580d808f4ba5a8738f70b91faf58ffb9c4c9b Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sat, 26 Apr 2014 17:51:41 +0000 Subject: [PATCH 16/67] Apparently this is supposed to be FAT32, not FAT12. --- sys/boot/amd64/boot1.efi/Makefile.fat | 2 +- sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu | 35 +++++++++++++----------- sys/boot/amd64/boot1.efi/generate-fat.sh | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/sys/boot/amd64/boot1.efi/Makefile.fat b/sys/boot/amd64/boot1.efi/Makefile.fat index 324481e1a31..6005781fad3 100644 --- a/sys/boot/amd64/boot1.efi/Makefile.fat +++ b/sys/boot/amd64/boot1.efi/Makefile.fat @@ -1,3 +1,3 @@ # This file autogenerated by generate-fat.sh - DO NOT EDIT # $FreeBSD$ -BOOT1_OFFSET=0x2d +BOOT1_OFFSET=0x3b diff --git a/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu b/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu index 2af42444810..2dafbf5bd24 100644 --- a/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu +++ b/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu @@ -2,21 +2,24 @@ FAT template boot filesystem created by generate-fat.sh DO NOT EDIT $FreeBSD$ begin 644 fat.tmpl.bz2 -M0EIH.3%!62936?1V`!$`&J7____[ZZKJJ_^N_ZO^Z_^[ON_\`4`00!0$#$$" -M0D)$6&(IZC3RGZH\B&$,U&AH#)B:,$8TAF@@]0T>IZF&A -M&GZID,1IZFAMO%FPGL0"(QIZV"3_!`$@N(@`DD$?C&$["`)`!)$6@#\HOB42 -M0`"2(X0FGX1#L"`'7E,'#-'HM!'QUD0\R,?9U,6ZE8F,Y6*L<9S<6PH)"%_" -MX'_PL4A),QB"(`B(=14*-"8,(QCG.(2$A(1J'010CB&R$(0B00FPP(0A"$)E -M#`A"$(1]LB&!"$(0B4&1#`A"$(14W<9J.:&A@8&!@8'`Z$(D(02@^L=UL>:+ -MBG:Q5+4&'[/P4@D2?M<,E!0&YBF8+],4^%$`4*%$N9MF:Z29-_VG2G7<$LJ-44RST& -MB53YE@H%(G5G$.FU;=L[DQVA]"(V4B1+%BP%.A<-10-%#R#NKR='@\'#"_'U -M'I36ZT:8QIN*3E$:HZIZRJ?$Y1L&<1'C)G(=8,E.L(KU<9X=%/NX.6\=@^IW -M\-PC$B&I"T\!(VI3"K!X:\%.01Y#X/83[SH.J*H5BH:ILFV1'X/D/V1$W6'\ -MFY>YE:*(I!.X@'D>H_(PY'(W1+B;:,Y?H8Y%(Q')!>DDE;\J1-DRXJJ/O(1@ -M'X/24=!+/V8S1)B(R:UE"0&&1:PUS(1`!$04``++GZ/8(CE5P1P8?^7QB[DB -(G"A(>CL`"(`` +M0EIH.3%!6293620F1 +MIH#31H--/48U#0--&":#0`80&@TT,@`-&FF"&F@'J::&U/34NO5O]KH&,P3D +M9TC0KV+%M5^)$Y=$D2(S=*LB`@R"#`))MDFE$%&-NDVQ;AN6'M4LC-TEV[;Q +MO4PF6^32;0F_3B==]9YV`]#!83TL-$>IZWL>U[G#?8XC[6LXKC..Y"]R7 +MW+2`DCI_O6(CB*@F:HXU$D_U22''VTEI>J0$D<5XJTGX,_@%TB=+22<.G#2] +M8%U/0HF\H&"DJE]1'D[:R*HAO::Y1KJ51.W[.PJD;.AF*B305`)(Y*D=,J3E +M*C32FALJLNYU!J@"Z_P%2`,'![YLW>M2IC2`:`CEJ&T49+FZ_ +M1LE?,Y33\]9\*FD5,=K=4NCB[FR1Y"F3ZC%OGB-9C3?UV/,;:Y_5*B>JJ2SV +M'4VCKU)D*&.INFX6:M1L6Q:1HC>J9JLU)CN\93G:R2HF-)RY."9[:-NSFY;)AW3_&>YC +MGE^RL\!$JAO6TM%S=C+LRM7_XNY(IPH2!. Date: Sat, 26 Apr 2014 17:56:39 +0000 Subject: [PATCH 17/67] The freescale imx uart driver works for the whole i.MX family, so rename the header file to not have "5xx" in the name. --- sys/dev/uart/uart_dev_imx.c | 2 +- sys/dev/uart/{uart_dev_imx5xx.h => uart_dev_imx.h} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename sys/dev/uart/{uart_dev_imx5xx.h => uart_dev_imx.h} (100%) diff --git a/sys/dev/uart/uart_dev_imx.c b/sys/dev/uart/uart_dev_imx.c index 97409224ad5..79ea0cc24fd 100644 --- a/sys/dev/uart/uart_dev_imx.c +++ b/sys/dev/uart/uart_dev_imx.c @@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include "uart_if.h" /* diff --git a/sys/dev/uart/uart_dev_imx5xx.h b/sys/dev/uart/uart_dev_imx.h similarity index 100% rename from sys/dev/uart/uart_dev_imx5xx.h rename to sys/dev/uart/uart_dev_imx.h From 269aedcff535b918bd804a51a23324a147f5a29c Mon Sep 17 00:00:00 2001 From: Andreas Tobler Date: Sat, 26 Apr 2014 19:30:04 +0000 Subject: [PATCH 18/67] Fix gcc build, initialize off variable. --- sys/dev/usb/wlan/if_urtwn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/dev/usb/wlan/if_urtwn.c b/sys/dev/usb/wlan/if_urtwn.c index 7f69f9617e3..f6bea414a92 100644 --- a/sys/dev/usb/wlan/if_urtwn.c +++ b/sys/dev/usb/wlan/if_urtwn.c @@ -1302,6 +1302,7 @@ urtwn_r88e_read_rom(struct urtwn_softc *sc) uint8_t off, msk, tmp; int i; + off = 0; urtwn_efuse_switch_power(sc); /* Read full ROM image. */ From 2d40ec16a885b952a407ecef3902dae848facfc6 Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Sat, 26 Apr 2014 20:03:04 +0000 Subject: [PATCH 19/67] Flesh out imx_uart_init() so that we're not relying on u-boot to init the hardware (meaning uarts other than the console will work). --- sys/dev/uart/uart_dev_imx.c | 75 ++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/sys/dev/uart/uart_dev_imx.c b/sys/dev/uart/uart_dev_imx.c index 79ea0cc24fd..350c0546776 100644 --- a/sys/dev/uart/uart_dev_imx.c +++ b/sys/dev/uart/uart_dev_imx.c @@ -43,10 +43,11 @@ __FBSDID("$FreeBSD$"); #include #include #include - #include - #include "uart_if.h" + +#include + /* * Low-level UART interface. */ @@ -66,6 +67,22 @@ static struct uart_ops uart_imx_uart_ops = { .getc = imx_uart_getc, }; +#if 0 /* Handy when debugging. */ +static void +dumpregs(struct uart_bas *bas, const char * msg) +{ + + if (!bootverbose) + return; + printf("%s bsh 0x%08lx UCR1 0x%08x UCR2 0x%08x " + "UCR3 0x%08x UCR4 0x%08x USR1 0x%08x USR2 0x%08x\n", + msg, bas->bsh, + GETREG(bas, REG(UCR1)), GETREG(bas, REG(UCR2)), + GETREG(bas, REG(UCR3)), GETREG(bas, REG(UCR4)), + GETREG(bas, REG(USR1)), GETREG(bas, REG(USR2))); +} +#endif + static int imx_uart_probe(struct uart_bas *bas) { @@ -77,7 +94,59 @@ static void imx_uart_init(struct uart_bas *bas, int baudrate, int databits, int stopbits, int parity) { + uint32_t baseclk, reg; + /* Enable the device and the RX/TX channels. */ + SET(bas, REG(UCR1), FLD(UCR1, UARTEN)); + SET(bas, REG(UCR2), FLD(UCR2, RXEN) | FLD(UCR2, TXEN)); + + if (databits == 7) + DIS(bas, UCR2, WS); + else + ENA(bas, UCR2, WS); + + if (stopbits == 2) + ENA(bas, UCR2, STPB); + else + DIS(bas, UCR2, STPB); + + switch (parity) { + case UART_PARITY_ODD: + DIS(bas, UCR2, PROE); + ENA(bas, UCR2, PREN); + break; + case UART_PARITY_EVEN: + ENA(bas, UCR2, PROE); + ENA(bas, UCR2, PREN); + break; + case UART_PARITY_MARK: + case UART_PARITY_SPACE: + /* FALLTHROUGH: Hardware doesn't support mark/space. */ + case UART_PARITY_NONE: + default: + DIS(bas, UCR2, PREN); + break; + } + + /* + * The hardware has an extremely flexible baud clock: it allows setting + * both the numerator and denominator of the divider, as well as a + * separate pre-divider. We simplify that problem by assuming a + * pre-divider and numerator of one because our base clock is so fast we + * can reach virtually any reasonable speed with a simple divisor. The + * numerator value actually includes the 16x over-sampling; the register + * value is the numerator-1, so we have a hard-coded 15. Note that a + * quirk of the hardware requires that both UBIR and UBMR be set back to + * back in order for the change to take effect. + */ + if (baudrate > 0) { + baseclk = imx_ccm_uart_hz(); + reg = GETREG(bas, REG(UFCR)); + reg = (reg & ~IMXUART_UFCR_RFDIV_MASK) | IMXUART_UFCR_RFDIV_DIV1; + SETREG(bas, REG(UFCR), reg); + SETREG(bas, REG(UBIR), 15); + SETREG(bas, REG(UBMR), (baseclk / baudrate) - 1); + } } static void @@ -218,6 +287,8 @@ imx_uart_bus_attach(struct uart_softc *sc) DIS(bas, UCR3, RI); DIS(bas, UCR3, DCD); DIS(bas, UCR3, DTRDEN); + ENA(bas, UCR2, IRTS); + ENA(bas, UCR3, RXDMUXSEL); /* ACK all interrupts */ SETREG(bas, REG(USR1), 0xffff); From 60ad8150c70129a8d15b955d4dc9b1ef833520c2 Mon Sep 17 00:00:00 2001 From: Scott Long Date: Sat, 26 Apr 2014 20:27:54 +0000 Subject: [PATCH 20/67] Retire smp_active. It was racey and caused demonstrated problems with the cpufreq code. Replace its use with smp_started. There's at least one userland tool that still looks at the kern.smp.active sysctl, so preserve it but point it to smp_started as well. Discussed with: peter, jhb MFC after: 3 days Obtained from: Netflix --- sys/amd64/amd64/mp_machdep.c | 1 - sys/amd64/amd64/vm_machdep.c | 2 +- sys/arm/arm/mp_machdep.c | 1 - sys/i386/i386/mp_machdep.c | 1 - sys/i386/i386/vm_machdep.c | 2 +- sys/i386/xen/mp_machdep.c | 1 - sys/ia64/ia64/mp_machdep.c | 2 +- sys/kern/kern_cpu.c | 2 +- sys/kern/subr_smp.c | 20 +++++++++++++++++--- sys/mips/mips/mp_machdep.c | 1 - sys/powerpc/powerpc/mp_machdep.c | 2 +- sys/sparc64/sparc64/mp_machdep.c | 1 - sys/sys/smp.h | 3 +-- 13 files changed, 23 insertions(+), 16 deletions(-) diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index afc1bef7a7d..f6981b97a7c 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -771,7 +771,6 @@ init_secondary(void) if (smp_cpus == mp_ncpus) { /* enable IPI's, tlb shootdown, freezes etc */ atomic_store_rel_int(&smp_started, 1); - smp_active = 1; /* historic */ } /* diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index bc7b3114fe1..3483815eb9d 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -597,7 +597,7 @@ cpu_reset() cpuset_t map; u_int cnt; - if (smp_active) { + if (smp_started) { map = all_cpus; CPU_CLR(PCPU_GET(cpuid), &map); CPU_NAND(&map, &stopped_cpus); diff --git a/sys/arm/arm/mp_machdep.c b/sys/arm/arm/mp_machdep.c index 0d6a0fcafc0..fd275feabe7 100644 --- a/sys/arm/arm/mp_machdep.c +++ b/sys/arm/arm/mp_machdep.c @@ -219,7 +219,6 @@ init_secondary(int cpu) if (smp_cpus == mp_ncpus) { /* enable IPI's, tlb shootdown, freezes etc */ atomic_store_rel_int(&smp_started, 1); - smp_active = 1; } mtx_unlock_spin(&ap_boot_mtx); diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index 53ac6dffbf3..222e8e286c5 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -805,7 +805,6 @@ init_secondary(void) if (smp_cpus == mp_ncpus) { /* enable IPI's, tlb shootdown, freezes etc */ atomic_store_rel_int(&smp_started, 1); - smp_active = 1; /* historic */ } mtx_unlock_spin(&ap_boot_mtx); diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index 3562954ac5d..78cc9c91958 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -619,7 +619,7 @@ cpu_reset() cpuset_t map; u_int cnt; - if (smp_active) { + if (smp_started) { map = all_cpus; CPU_CLR(PCPU_GET(cpuid), &map); CPU_NAND(&map, &stopped_cpus); diff --git a/sys/i386/xen/mp_machdep.c b/sys/i386/xen/mp_machdep.c index 1bc6572f7ab..165b319bd6a 100644 --- a/sys/i386/xen/mp_machdep.c +++ b/sys/i386/xen/mp_machdep.c @@ -655,7 +655,6 @@ init_secondary(void) if (smp_cpus == mp_ncpus) { /* enable IPI's, tlb shootdown, freezes etc */ atomic_store_rel_int(&smp_started, 1); - smp_active = 1; /* historic */ } mtx_unlock_spin(&ap_boot_mtx); diff --git a/sys/ia64/ia64/mp_machdep.c b/sys/ia64/ia64/mp_machdep.c index 39fcca18d41..4e7ffb835e2 100644 --- a/sys/ia64/ia64/mp_machdep.c +++ b/sys/ia64/ia64/mp_machdep.c @@ -475,7 +475,7 @@ cpu_mp_unleash(void *dummy) mp_ncpus, cpus, smp_cpus); } - smp_active = 1; + /* XXX Atomic set operation? */ smp_started = 1; /* diff --git a/sys/kern/kern_cpu.c b/sys/kern/kern_cpu.c index 6df4d3f12e1..b0de2a23f89 100644 --- a/sys/kern/kern_cpu.c +++ b/sys/kern/kern_cpu.c @@ -268,7 +268,7 @@ cf_set_method(device_t dev, const struct cf_level *level, int priority) * switching the main CPU. XXXTODO: Need to think more about how to * handle having different CPUs at different frequencies. */ - if (mp_ncpus > 1 && !smp_active) { + if (mp_ncpus > 1 && !smp_started) { device_printf(dev, "rejecting change, SMP not started yet\n"); error = ENXIO; goto out; diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 5425a4504df..122fc4c5fed 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -59,6 +59,9 @@ cpuset_t logical_cpus_mask; void (*cpustop_restartfunc)(void); #endif + +static int sysctl_kern_smp_active(SYSCTL_HANDLER_ARGS); + /* This is used in modules that need to work in both SMP and UP. */ cpuset_t all_cpus; @@ -78,9 +81,8 @@ SYSCTL_INT(_kern_smp, OID_AUTO, maxid, CTLFLAG_RD|CTLFLAG_CAPRD, &mp_maxid, 0, SYSCTL_INT(_kern_smp, OID_AUTO, maxcpus, CTLFLAG_RD|CTLFLAG_CAPRD, &mp_maxcpus, 0, "Max number of CPUs that the system was compiled for."); -int smp_active = 0; /* are the APs allowed to run? */ -SYSCTL_INT(_kern_smp, OID_AUTO, active, CTLFLAG_RW, &smp_active, 0, - "Number of Auxillary Processors (APs) that were successfully started"); +SYSCTL_PROC(_kern_smp, OID_AUTO, active, CTLFLAG_RD | CTLTYPE_INT, NULL, 0, + sysctl_kern_smp_active, "I", "Indicates system is running in SMP mode"); int smp_disabled = 0; /* has smp been disabled? */ SYSCTL_INT(_kern_smp, OID_AUTO, disabled, CTLFLAG_RDTUN|CTLFLAG_CAPRD, @@ -831,3 +833,15 @@ quiesce_all_cpus(const char *wmesg, int prio) return quiesce_cpus(all_cpus, wmesg, prio); } + +/* Extra care is taken with this sysctl because the data type is volatile */ +static int +sysctl_kern_smp_active(SYSCTL_HANDLER_ARGS) +{ + int error, active; + + active = smp_started; + error = SYSCTL_OUT(req, &active, sizeof(active)); + return (error); +} + diff --git a/sys/mips/mips/mp_machdep.c b/sys/mips/mips/mp_machdep.c index 2a6bbb4be35..9f989091e07 100644 --- a/sys/mips/mips/mp_machdep.c +++ b/sys/mips/mips/mp_machdep.c @@ -317,7 +317,6 @@ smp_init_secondary(u_int32_t cpuid) if (smp_cpus == mp_ncpus) { atomic_store_rel_int(&smp_started, 1); - smp_active = 1; } mtx_unlock_spin(&ap_boot_mtx); diff --git a/sys/powerpc/powerpc/mp_machdep.c b/sys/powerpc/powerpc/mp_machdep.c index 772cd5eec67..555daf17489 100644 --- a/sys/powerpc/powerpc/mp_machdep.c +++ b/sys/powerpc/powerpc/mp_machdep.c @@ -267,7 +267,7 @@ cpu_mp_unleash(void *dummy) /* Let the APs get into the scheduler */ DELAY(10000); - smp_active = 1; + /* XXX Atomic set operation? */ smp_started = 1; } diff --git a/sys/sparc64/sparc64/mp_machdep.c b/sys/sparc64/sparc64/mp_machdep.c index 8d2282ebdb4..0f977b3e392 100644 --- a/sys/sparc64/sparc64/mp_machdep.c +++ b/sys/sparc64/sparc64/mp_machdep.c @@ -291,7 +291,6 @@ cpu_mp_start(void) KASSERT(!isjbus || mp_ncpus <= IDR_JALAPENO_MAX_BN_PAIRS, ("%s: can only IPI a maximum of %d JBus-CPUs", __func__, IDR_JALAPENO_MAX_BN_PAIRS)); - smp_active = 1; } static void diff --git a/sys/sys/smp.h b/sys/sys/smp.h index fed12bfb7a5..42cb8df058c 100644 --- a/sys/sys/smp.h +++ b/sys/sys/smp.h @@ -71,7 +71,6 @@ struct cpu_group *smp_topo_2level(int l2share, int l2count, int l1share, struct cpu_group *smp_topo_find(struct cpu_group *top, int cpu); extern void (*cpustop_restartfunc)(void); -extern int smp_active; extern int smp_cpus; extern volatile cpuset_t started_cpus; extern volatile cpuset_t stopped_cpus; @@ -141,7 +140,7 @@ cpu_next(int i) * cpu_mp_start() will be called so that MP can be enabled. This function * should do things such as startup secondary processors. It should also * setup mp_ncpus, all_cpus, and smp_cpus. It should also ensure that - * smp_active and smp_started are initialized at the appropriate time. + * smp_started is initialized at the appropriate time. * Once cpu_mp_start() returns, machine independent MP startup code will be * executed and a simple message will be output to the console. Finally, * cpu_mp_announce() will be called so that machine dependent messages about From 49d0a4c3ffaf1669b63d34f9cf80e0815258b05f Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Sat, 26 Apr 2014 20:27:58 +0000 Subject: [PATCH 21/67] Reword a comment block a bit; no functional changes. --- sys/dev/uart/uart_dev_imx.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sys/dev/uart/uart_dev_imx.c b/sys/dev/uart/uart_dev_imx.c index 350c0546776..43338febb6c 100644 --- a/sys/dev/uart/uart_dev_imx.c +++ b/sys/dev/uart/uart_dev_imx.c @@ -131,13 +131,14 @@ imx_uart_init(struct uart_bas *bas, int baudrate, int databits, /* * The hardware has an extremely flexible baud clock: it allows setting * both the numerator and denominator of the divider, as well as a - * separate pre-divider. We simplify that problem by assuming a - * pre-divider and numerator of one because our base clock is so fast we - * can reach virtually any reasonable speed with a simple divisor. The - * numerator value actually includes the 16x over-sampling; the register - * value is the numerator-1, so we have a hard-coded 15. Note that a - * quirk of the hardware requires that both UBIR and UBMR be set back to - * back in order for the change to take effect. + * separate pre-divider. We simplify the problem of coming up with a + * workable pair of numbers by assuming a pre-divider and numerator of + * one because our base clock is so fast we can reach virtually any + * reasonable speed with a simple divisor. The numerator value actually + * includes the 16x over-sampling (so a value of 16 means divide by 1); + * the register value is the numerator-1, so we have a hard-coded 15. + * Note that a quirk of the hardware requires that both UBIR and UBMR be + * set back to back in order for the change to take effect. */ if (baudrate > 0) { baseclk = imx_ccm_uart_hz(); From c77462dd646e86d2fe4e5b0bc647e0761a22c376 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Sat, 26 Apr 2014 21:03:41 +0000 Subject: [PATCH 22/67] Decouple RTM_CHANGE from RTM_GET handling in rtsock.c:route_output(). RTM_CHANGE is now handled inside route.c:rtrequest1_fib() as it should be. Note change change handler is a separate function rtrequest1_fib_change(). MFC after: 1 month --- sys/net/route.c | 95 +++++++++++++++++++++++++ sys/net/rtsock.c | 177 ++++++++++++++--------------------------------- 2 files changed, 147 insertions(+), 125 deletions(-) diff --git a/sys/net/route.c b/sys/net/route.c index 623772a479e..fb24500a708 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -140,6 +140,9 @@ VNET_DEFINE(int, rttrash); /* routes not in table but not freed */ static VNET_DEFINE(uma_zone_t, rtzone); /* Routing table UMA zone. */ #define V_rtzone VNET(rtzone) +static int rtrequest1_fib_change(struct radix_node_head *, struct rt_addrinfo *, + struct rtentry **, u_int); + /* * handler for net.my_fibnum */ @@ -1408,6 +1411,9 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, } RT_UNLOCK(rt); break; + case RTM_CHANGE: + error = rtrequest1_fib_change(rnh, info, ret_nrt, fibnum); + break; default: error = EOPNOTSUPP; } @@ -1425,6 +1431,95 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, #undef ifpaddr #undef flags +#define senderr(e) { error = e; goto bad; } +static int +rtrequest1_fib_change(struct radix_node_head *rnh, struct rt_addrinfo *info, + struct rtentry **ret_nrt, u_int fibnum) +{ + struct rtentry *rt = NULL; + int error = 0; + int free_ifa = 0; + + rt = (struct rtentry *)rnh->rnh_lookup(info->rti_info[RTAX_DST], + info->rti_info[RTAX_NETMASK], rnh); + + if (rt == NULL) + return (ESRCH); + +#ifdef RADIX_MPATH + /* + * If we got multipath routes, + * we require users to specify a matching RTAX_GATEWAY. + */ + if (rn_mpath_capable(rnh)) { + rt = rt_mpath_matchgate(rt, info->rti_info[RTAX_GATEWAY]); + if (rt == NULL) + return (ESRCH); + } +#endif + + RT_LOCK(rt); + + /* + * New gateway could require new ifaddr, ifp; + * flags may also be different; ifp may be specified + * by ll sockaddr when protocol address is ambiguous + */ + if (((rt->rt_flags & RTF_GATEWAY) && + info->rti_info[RTAX_GATEWAY] != NULL) || + info->rti_info[RTAX_IFP] != NULL || + (info->rti_info[RTAX_IFA] != NULL && + !sa_equal(info->rti_info[RTAX_IFA], rt->rt_ifa->ifa_addr))) { + + error = rt_getifa_fib(info, fibnum); + if (info->rti_ifa != NULL) + free_ifa = 1; + + if (error != 0) + senderr(error); + } + + /* Check if outgoing interface has changed */ + if (info->rti_ifa != NULL && info->rti_ifa != rt->rt_ifa && + rt->rt_ifa != NULL && rt->rt_ifa->ifa_rtrequest != NULL) { + rt->rt_ifa->ifa_rtrequest(RTM_DELETE, rt, info); + ifa_free(rt->rt_ifa); + } + /* Update gateway address */ + if (info->rti_info[RTAX_GATEWAY] != NULL) { + error = rt_setgate(rt, rt_key(rt), info->rti_info[RTAX_GATEWAY]); + if (error != 0) + senderr(error); + + rt->rt_flags &= ~RTF_GATEWAY; + rt->rt_flags |= (RTF_GATEWAY & info->rti_flags); + } + + if (info->rti_ifa != NULL && info->rti_ifa != rt->rt_ifa) { + ifa_ref(info->rti_ifa); + rt->rt_ifa = info->rti_ifa; + rt->rt_ifp = info->rti_ifp; + } + /* Allow some flags to be toggled on change. */ + rt->rt_flags &= ~RTF_FMASK; + rt->rt_flags |= info->rti_flags & RTF_FMASK; + + if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest != NULL) + rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, info); + + if (ret_nrt) { + *ret_nrt = rt; + RT_ADDREF(rt); + } +bad: + RT_UNLOCK(rt); + if (free_ifa != 0) + ifa_free(info->rti_ifa); + return (error); +} +#undef senderr + + int rt_setgate(struct rtentry *rt, struct sockaddr *dst, struct sockaddr *gate) { diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 02f44d6fd21..502ceeaabe0 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -621,6 +621,7 @@ route_output(struct mbuf *m, struct socket *so) struct rtentry *saved_nrt; case RTM_ADD: + case RTM_CHANGE: if (info.rti_info[RTAX_GATEWAY] == NULL) senderr(EINVAL); saved_nrt = NULL; @@ -635,9 +636,9 @@ route_output(struct mbuf *m, struct socket *so) #endif break; } - error = rtrequest1_fib(RTM_ADD, &info, &saved_nrt, + error = rtrequest1_fib(rtm->rtm_type, &info, &saved_nrt, so->so_fibnum); - if (error == 0 && saved_nrt) { + if (error == 0 && saved_nrt != NULL) { #ifdef INET6 rti_need_deembed = (V_deembed_scopeid) ? 1 : 0; #endif @@ -676,8 +677,6 @@ route_output(struct mbuf *m, struct socket *so) break; case RTM_GET: - case RTM_CHANGE: - case RTM_LOCK: rnh = rt_tables_get_rnh(so->so_fibnum, info.rti_info[RTAX_DST]->sa_family); if (rnh == NULL) @@ -757,133 +756,61 @@ route_output(struct mbuf *m, struct socket *so) RT_ADDREF(rt); RADIX_NODE_HEAD_RUNLOCK(rnh); - switch(rtm->rtm_type) { - - case RTM_GET: - report: - RT_LOCK_ASSERT(rt); - if ((rt->rt_flags & RTF_HOST) == 0 - ? jailed_without_vnet(curthread->td_ucred) - : prison_if(curthread->td_ucred, - rt_key(rt)) != 0) { - RT_UNLOCK(rt); - senderr(ESRCH); - } - info.rti_info[RTAX_DST] = rt_key(rt); - info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; - info.rti_info[RTAX_NETMASK] = rt_mask(rt); - info.rti_info[RTAX_GENMASK] = 0; - if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) { - ifp = rt->rt_ifp; - if (ifp) { - info.rti_info[RTAX_IFP] = - ifp->if_addr->ifa_addr; - error = rtm_get_jailed(&info, ifp, rt, - &saun, curthread->td_ucred); - if (error != 0) { - RT_UNLOCK(rt); - senderr(error); - } - if (ifp->if_flags & IFF_POINTOPOINT) - info.rti_info[RTAX_BRD] = - rt->rt_ifa->ifa_dstaddr; - rtm->rtm_index = ifp->if_index; - } else { - info.rti_info[RTAX_IFP] = NULL; - info.rti_info[RTAX_IFA] = NULL; - } - } else if ((ifp = rt->rt_ifp) != NULL) { - rtm->rtm_index = ifp->if_index; - } - len = rt_msg2(rtm->rtm_type, &info, NULL, NULL); - if (len > rtm->rtm_msglen) { - struct rt_msghdr *new_rtm; - R_Malloc(new_rtm, struct rt_msghdr *, len); - if (new_rtm == NULL) { - RT_UNLOCK(rt); - senderr(ENOBUFS); - } - bcopy(rtm, new_rtm, rtm->rtm_msglen); - Free(rtm); rtm = new_rtm; - } - (void)rt_msg2(rtm->rtm_type, &info, (caddr_t)rtm, NULL); - if (rt->rt_flags & RTF_GWFLAG_COMPAT) - rtm->rtm_flags = RTF_GATEWAY | - (rt->rt_flags & ~RTF_GWFLAG_COMPAT); - else - rtm->rtm_flags = rt->rt_flags; - rt_getmetrics(rt, &rtm->rtm_rmx); - rtm->rtm_addrs = info.rti_addrs; - break; - - case RTM_CHANGE: - /* - * New gateway could require new ifaddr, ifp; - * flags may also be different; ifp may be specified - * by ll sockaddr when protocol address is ambiguous - */ - if (((rt->rt_flags & RTF_GATEWAY) && - info.rti_info[RTAX_GATEWAY] != NULL) || - info.rti_info[RTAX_IFP] != NULL || - (info.rti_info[RTAX_IFA] != NULL && - !sa_equal(info.rti_info[RTAX_IFA], - rt->rt_ifa->ifa_addr))) { - RT_UNLOCK(rt); - RADIX_NODE_HEAD_LOCK(rnh); - error = rt_getifa_fib(&info, rt->rt_fibnum); - /* - * XXXRW: Really we should release this - * reference later, but this maintains - * historical behavior. - */ - if (info.rti_ifa != NULL) - ifa_free(info.rti_ifa); - RADIX_NODE_HEAD_UNLOCK(rnh); - if (error != 0) - senderr(error); - RT_LOCK(rt); - } - if (info.rti_ifa != NULL && - info.rti_ifa != rt->rt_ifa && - rt->rt_ifa != NULL && - rt->rt_ifa->ifa_rtrequest != NULL) { - rt->rt_ifa->ifa_rtrequest(RTM_DELETE, rt, - &info); - ifa_free(rt->rt_ifa); - } - if (info.rti_info[RTAX_GATEWAY] != NULL) { - RT_UNLOCK(rt); - RADIX_NODE_HEAD_LOCK(rnh); - RT_LOCK(rt); - - error = rt_setgate(rt, rt_key(rt), - info.rti_info[RTAX_GATEWAY]); - RADIX_NODE_HEAD_UNLOCK(rnh); +report: + RT_LOCK_ASSERT(rt); + if ((rt->rt_flags & RTF_HOST) == 0 + ? jailed_without_vnet(curthread->td_ucred) + : prison_if(curthread->td_ucred, + rt_key(rt)) != 0) { + RT_UNLOCK(rt); + senderr(ESRCH); + } + info.rti_info[RTAX_DST] = rt_key(rt); + info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; + info.rti_info[RTAX_NETMASK] = rt_mask(rt); + info.rti_info[RTAX_GENMASK] = 0; + if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) { + ifp = rt->rt_ifp; + if (ifp) { + info.rti_info[RTAX_IFP] = + ifp->if_addr->ifa_addr; + error = rtm_get_jailed(&info, ifp, rt, + &saun, curthread->td_ucred); if (error != 0) { RT_UNLOCK(rt); senderr(error); } - rt->rt_flags &= ~RTF_GATEWAY; - rt->rt_flags |= (RTF_GATEWAY & info.rti_flags); + if (ifp->if_flags & IFF_POINTOPOINT) + info.rti_info[RTAX_BRD] = + rt->rt_ifa->ifa_dstaddr; + rtm->rtm_index = ifp->if_index; + } else { + info.rti_info[RTAX_IFP] = NULL; + info.rti_info[RTAX_IFA] = NULL; } - if (info.rti_ifa != NULL && - info.rti_ifa != rt->rt_ifa) { - ifa_ref(info.rti_ifa); - rt->rt_ifa = info.rti_ifa; - rt->rt_ifp = info.rti_ifp; - } - /* Allow some flags to be toggled on change. */ - rt->rt_flags = (rt->rt_flags & ~RTF_FMASK) | - (rtm->rtm_flags & RTF_FMASK); - rt_setmetrics(rtm, rt); - rtm->rtm_index = rt->rt_ifp->if_index; - if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest) - rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, &info); - /* FALLTHROUGH */ - case RTM_LOCK: - /* We don't support locks anymore */ - break; + } else if ((ifp = rt->rt_ifp) != NULL) { + rtm->rtm_index = ifp->if_index; } + len = rt_msg2(rtm->rtm_type, &info, NULL, NULL); + if (len > rtm->rtm_msglen) { + struct rt_msghdr *new_rtm; + R_Malloc(new_rtm, struct rt_msghdr *, len); + if (new_rtm == NULL) { + RT_UNLOCK(rt); + senderr(ENOBUFS); + } + bcopy(rtm, new_rtm, rtm->rtm_msglen); + Free(rtm); rtm = new_rtm; + } + (void)rt_msg2(rtm->rtm_type, &info, (caddr_t)rtm, NULL); + if (rt->rt_flags & RTF_GWFLAG_COMPAT) + rtm->rtm_flags = RTF_GATEWAY | + (rt->rt_flags & ~RTF_GWFLAG_COMPAT); + else + rtm->rtm_flags = rt->rt_flags; + rt_getmetrics(rt, &rtm->rtm_rmx); + rtm->rtm_addrs = info.rti_addrs; + RT_UNLOCK(rt); break; From 773aa0533bcfe7bf343375524290ab0151024a60 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Sat, 26 Apr 2014 22:32:04 +0000 Subject: [PATCH 23/67] Determine fibnum once in the beginning of route_output(). MFC after: 1 month --- sys/net/rtsock.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 502ceeaabe0..9a32969f0cc 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -526,7 +526,7 @@ route_output(struct mbuf *m, struct socket *so) struct sockaddr_in6 *sin6; int i, rti_need_deembed = 0; #endif - int len, error = 0; + int len, error = 0, fibnum; struct ifnet *ifp = NULL; union sockaddr_union saun; sa_family_t saf = AF_UNSPEC; @@ -582,6 +582,8 @@ route_output(struct mbuf *m, struct socket *so) senderr(error); } + fibnum = so->so_fibnum; + /* * The given gateway address may be an interface address. * For example, issuing a "route change" command on a route @@ -596,7 +598,7 @@ route_output(struct mbuf *m, struct socket *so) bzero(&gw_ro, sizeof(gw_ro)); gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY]; - rtalloc_ign_fib(&gw_ro, 0, so->so_fibnum); + rtalloc_ign_fib(&gw_ro, 0, fibnum); /* * A host route through the loopback interface is * installed for each interface adddress. In pre 8.0 @@ -637,7 +639,7 @@ route_output(struct mbuf *m, struct socket *so) break; } error = rtrequest1_fib(rtm->rtm_type, &info, &saved_nrt, - so->so_fibnum); + fibnum); if (error == 0 && saved_nrt != NULL) { #ifdef INET6 rti_need_deembed = (V_deembed_scopeid) ? 1 : 0; @@ -663,8 +665,7 @@ route_output(struct mbuf *m, struct socket *so) #endif break; } - error = rtrequest1_fib(RTM_DELETE, &info, &saved_nrt, - so->so_fibnum); + error = rtrequest1_fib(RTM_DELETE, &info, &saved_nrt, fibnum); if (error == 0) { RT_LOCK(saved_nrt); rt = saved_nrt; @@ -677,8 +678,7 @@ route_output(struct mbuf *m, struct socket *so) break; case RTM_GET: - rnh = rt_tables_get_rnh(so->so_fibnum, - info.rti_info[RTAX_DST]->sa_family); + rnh = rt_tables_get_rnh(fibnum, saf); if (rnh == NULL) senderr(EAFNOSUPPORT); @@ -867,7 +867,7 @@ route_output(struct mbuf *m, struct socket *so) m_adj(m, rtm->rtm_msglen - m->m_pkthdr.len); } if (m) { - M_SETFIB(m, so->so_fibnum); + M_SETFIB(m, fibnum); m->m_flags |= RTS_FILTER_FIB; if (rp) { /* From 63c9389af68a39e2963850a801120facacf31866 Mon Sep 17 00:00:00 2001 From: Neel Natu Date: Sat, 26 Apr 2014 22:37:56 +0000 Subject: [PATCH 24/67] A VMCS is always inactive when it exits the vmx_run() loop. Remove redundant code and the misleading comment that suggest otherwise. Reviewed by: grehan@ --- sys/amd64/vmm/intel/vmx.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c index 662bbc78c28..286eba93616 100644 --- a/sys/amd64/vmm/intel/vmx.c +++ b/sys/amd64/vmm/intel/vmx.c @@ -2234,7 +2234,7 @@ vmx_run(void *arg, int vcpu, register_t startrip, pmap_t pmap, static void vmx_vmcleanup(void *arg) { - int i, error; + int i; struct vmx *vmx = arg; if (apic_access_virtualization(vmx, 0)) @@ -2243,13 +2243,6 @@ vmx_vmcleanup(void *arg) for (i = 0; i < VM_MAXCPU; i++) vpid_free(vmx->state[i].vpid); - /* - * XXXSMP we also need to clear the VMCS active on the other vcpus. - */ - error = vmclear(&vmx->vmcs[0]); - if (error != 0) - panic("vmx_vmcleanup: vmclear error %d on vcpu 0", error); - free(vmx, M_VMX); return; From f59c6cb0fca8da22bbcebaf0aa733d6c3ef85473 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Sat, 26 Apr 2014 22:42:21 +0000 Subject: [PATCH 25/67] Remove useless `register' declarations. MFC after: 1 month --- sys/net/route.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/net/route.c b/sys/net/route.c index fb24500a708..0feadb8f7f7 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -725,7 +725,7 @@ struct ifaddr * ifa_ifwithroute_fib(int flags, struct sockaddr *dst, struct sockaddr *gateway, u_int fibnum) { - register struct ifaddr *ifa; + struct ifaddr *ifa; int not_found = 0; if ((flags & RTF_GATEWAY) == 0) { @@ -1041,7 +1041,7 @@ rn_mpath_update(int req, struct rt_addrinfo *info, * a matching RTAX_GATEWAY. */ struct rtentry *rt, *rto = NULL; - register struct radix_node *rn; + struct radix_node *rn; int error = 0; rn = rnh->rnh_lookup(dst, netmask, rnh); @@ -1143,12 +1143,12 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, u_int fibnum) { int error = 0, needlock = 0; - register struct rtentry *rt; + struct rtentry *rt; #ifdef FLOWTABLE - register struct rtentry *rt0; + struct rtentry *rt0; #endif - register struct radix_node *rn; - register struct radix_node_head *rnh; + struct radix_node *rn; + struct radix_node_head *rnh; struct ifaddr *ifa; struct sockaddr *ndst; struct sockaddr_storage mdst; @@ -1571,9 +1571,9 @@ rt_setgate(struct rtentry *rt, struct sockaddr *dst, struct sockaddr *gate) void rt_maskedcopy(struct sockaddr *src, struct sockaddr *dst, struct sockaddr *netmask) { - register u_char *cp1 = (u_char *)src; - register u_char *cp2 = (u_char *)dst; - register u_char *cp3 = (u_char *)netmask; + u_char *cp1 = (u_char *)src; + u_char *cp2 = (u_char *)dst; + u_char *cp3 = (u_char *)netmask; u_char *cplim = cp2 + *cp3; u_char *cplim2 = cp2 + *cp1; From 75c95895f5da8cbbdc8b647d906f05ed4167a342 Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Sat, 26 Apr 2014 23:09:01 +0000 Subject: [PATCH 26/67] Call cpu_icache_sync_range() rather than sync_all since we know the range and flushing the entire icache is needlessly expensive. --- sys/arm/include/kdb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/arm/include/kdb.h b/sys/arm/include/kdb.h index 2f0b0877e28..b04cd581aad 100644 --- a/sys/arm/include/kdb.h +++ b/sys/arm/include/kdb.h @@ -49,7 +49,7 @@ static __inline void kdb_cpu_sync_icache(unsigned char *addr, size_t size) { - cpu_icache_sync_all(); + cpu_icache_sync_range((vm_offset_t)addr, size); } static __inline void From daa963252e6cb4d7afd342db7a523300db22782c Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Sat, 26 Apr 2014 23:22:49 +0000 Subject: [PATCH 27/67] Use logical rather than bitwise OR in if() expression. --- sys/net80211/ieee80211_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c index 7ae4f9d235e..2798d8089b8 100644 --- a/sys/net80211/ieee80211_ioctl.c +++ b/sys/net80211/ieee80211_ioctl.c @@ -602,7 +602,7 @@ ieee80211_ioctl_getcurchan(struct ieee80211vap *vap, struct ieee80211req *ireq) * in use. When in RUN state report the vap-specific channel. * Otherwise return curchan. */ - if (vap->iv_state == IEEE80211_S_RUN | vap->iv_state == IEEE80211_S_SLEEP) + if (vap->iv_state == IEEE80211_S_RUN || vap->iv_state == IEEE80211_S_SLEEP) c = vap->iv_bss->ni_chan; else c = ic->ic_curchan; From be583ba69d8d915a1be043656fbcbc7018a28ae6 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 27 Apr 2014 00:40:18 +0000 Subject: [PATCH 28/67] Make a dual-boot BIOS/UEFI memstick image. Testing required before this gets renamed make-memstick.sh. --- release/amd64/make-uefi-memstick.sh | 58 +++++++---------------------- 1 file changed, 13 insertions(+), 45 deletions(-) diff --git a/release/amd64/make-uefi-memstick.sh b/release/amd64/make-uefi-memstick.sh index dcbdd75345c..d9145a5312e 100755 --- a/release/amd64/make-uefi-memstick.sh +++ b/release/amd64/make-uefi-memstick.sh @@ -1,12 +1,9 @@ #!/bin/sh # -# This script generates a "memstick image" for UEFI-capable systems. -# -# Prerequisites: -# - 'make release' -# - KERNCONF *must* be VT (or vt_efifb(4) compiled into the kernel) -# -# Note: This only works for amd64, because i386 lacks the EFI boot bits. +# This script generates a "memstick image" (image that can be copied to a +# USB memory stick) from a directory tree. Note that the script does not +# clean up after itself very well for error conditions on purpose so the +# problem can be diagnosed (full filesystem most likely but ...). # # Usage: make-memstick.sh # @@ -31,43 +28,14 @@ if [ -e ${2} ]; then exit 1 fi -dirsize=$(du -shLm ${1} | awk '{print $1}') -dirsize=$(( $(( $(( ${dirsize} + 256 )) * 1024 * 1024 )) )) -truncate -s ${dirsize} ${2} +echo '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab +makefs -B little -o label=FreeBSD_Install ${2}.part ${1} +if [ $? -ne 0 ]; then + echo "makefs failed" + exit 1 +fi +rm ${1}/etc/fstab -unit=$(mdconfig -a -t vnode -f ${2}) -gpart create -s mbr /dev/${unit} -gpart add -t '!0xEF' -s 32M /dev/${unit} -gpart add -t freebsd /dev/${unit} -gpart set -a active -i 2 /dev/${unit} -gpart bootcode -b ${1}/boot/boot0 /dev/${unit} -gpart create -s bsd -n 20 /dev/${unit}s2 -gpart add -t freebsd-ufs /dev/${unit}s2 -gpart bootcode -b ${1}/boot/boot /dev/${unit}s2 -newfs_msdos /dev/${unit}s1 -newfs -L rootfs /dev/${unit}s2a -mkdir -p ${1}/mnt -mount -t msdosfs /dev/${unit}s1 ${1}/mnt -mkdir -p ${1}/mnt/efi/boot -cp -p ${1}/boot/boot1.efi ${1}/mnt/efi/boot/BOOTx64.efi - -while ! umount ${1}/mnt; do - sleep 1 -done - -mkdir -p mnt -mount /dev/${unit}s2a mnt -tar -cf - -C ${1} . | tar -xf - -C mnt -echo "/dev/ufs/rootfs / ufs ro,noatime 1 1" > mnt/etc/fstab - -while ! umount mnt; do - sleep 1 -done - -# Default boot selection to MBR so systems that do not support UEFI -# do not fail to boot without human interaction. -boot0cfg -s 2 /dev/${unit} - -mdconfig -d -u ${unit} -rmdir mnt +mkimg -s gpt -b ${1}/boot/pmbr -p freebsd-boot:=${1}/boot/gptboot -p efi:=${1}/boot/boot1.efifat -p freebsd-ufs:=${2}.part -o ${2} +rm ${2}.part From 1c6c63fc6a7e5f593eef0fbaabc4406f56332b84 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 27 Apr 2014 00:45:08 +0000 Subject: [PATCH 29/67] Revert to FAT12. This file system is apparently too small for FAT32, even if the old (pre r264889) newfs_msdos allowed it. And FAT12 seems to work perfectly well. --- sys/boot/amd64/boot1.efi/Makefile.fat | 2 +- sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu | 34 +++++++++++------------- sys/boot/amd64/boot1.efi/generate-fat.sh | 2 +- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/sys/boot/amd64/boot1.efi/Makefile.fat b/sys/boot/amd64/boot1.efi/Makefile.fat index 6005781fad3..324481e1a31 100644 --- a/sys/boot/amd64/boot1.efi/Makefile.fat +++ b/sys/boot/amd64/boot1.efi/Makefile.fat @@ -1,3 +1,3 @@ # This file autogenerated by generate-fat.sh - DO NOT EDIT # $FreeBSD$ -BOOT1_OFFSET=0x3b +BOOT1_OFFSET=0x2d diff --git a/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu b/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu index 2dafbf5bd24..52ed67a468c 100644 --- a/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu +++ b/sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu @@ -2,24 +2,20 @@ FAT template boot filesystem created by generate-fat.sh DO NOT EDIT $FreeBSD$ begin 644 fat.tmpl.bz2 -M0EIH.3%!6293620F1 -MIH#31H--/48U#0--&":#0`80&@TT,@`-&FF"&F@'J::&U/34NO5O]KH&,P3D -M9TC0KV+%M5^)$Y=$D2(S=*LB`@R"#`))MDFE$%&-NDVQ;AN6'M4LC-TEV[;Q -MO4PF6^32;0F_3B==]9YV`]#!83TL-$>IZWL>U[G#?8XC[6LXKC..Y"]R7 -MW+2`DCI_O6(CB*@F:HXU$D_U22''VTEI>J0$D<5XJTGX,_@%TB=+22<.G#2] -M8%U/0HF\H&"DJE]1'D[:R*HAO::Y1KJ51.W[.PJD;.AF*B305`)(Y*D=,J3E -M*C32FALJLNYU!J@"Z_P%2`,'![YLW>M2IC2`:`CEJ&T49+FZ_ -M1LE?,Y33\]9\*FD5,=K=4NCB[FR1Y"F3ZC%OGB-9C3?UV/,;:Y_5*B>JJ2SV -M'4VCKU)D*&.INFX6:M1L6Q:1HC>J9JLU)CN\93G:R2HF-)RY."9[:-NSFY;)AW3_&>YC -MGE^RL\!$JAO6TM%S=C+LRM7_XNY(IPH2!.H:`81HT#)D!H-#U`T#31IH-&(``R8$9_I)6[MY/, +M(H=/()+4&!(3V0"20C3J5$L5@2`219,"T6JI,@0"2*2\=LAD6=>N6(8QSW'U+N42P^'5X@7X``23=EA``#Z,O)^-VTX@ +M`+E!=,&6PV11C:*D8K#^<%FTG-%!@PR72@\ZU0BF1Y] +MF-FPGL2L>4QCU&O/>89^#H$6^<;&WKC9W52KUX."CM6+GD;(=1!MUD,,?Y[] +MTLAG0];,:B^]M%BH0J1":_C-*2I9R3AS#,&0>$RCY'T/R?HR!?'5$MILQ:!" +M+;10A*!&^<(_/8>D8 Date: Sun, 27 Apr 2014 00:46:01 +0000 Subject: [PATCH 30/67] Provide a proper armv7 implementation of icache_sync_all rather than using armv7_idcache_wbinv_all, because wbinv_all doesn't broadcast the operation to other cores. In elf_cpu_load_file() use icache_sync_all() and explain why it's needed (and why other sync operations aren't). As part of doing this, all callers of cpu_icache_sync_all() were inspected to ensure they weren't relying on the old side effect of doing a wbinv_all along with the icache work. --- sys/arm/arm/cpufunc.c | 2 +- sys/arm/arm/cpufunc_asm_armv7.S | 7 +++++++ sys/arm/arm/elf_machdep.c | 16 +++++++++++++--- sys/arm/include/cpufunc.h | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/sys/arm/arm/cpufunc.c b/sys/arm/arm/cpufunc.c index 7f178a4eed0..3d29d713a66 100644 --- a/sys/arm/arm/cpufunc.c +++ b/sys/arm/arm/cpufunc.c @@ -769,7 +769,7 @@ struct cpu_functions cortexa_cpufuncs = { /* Cache operations */ - armv7_idcache_wbinv_all, /* icache_sync_all */ + armv7_icache_sync_all, /* icache_sync_all */ armv7_icache_sync_range, /* icache_sync_range */ armv7_dcache_wbinv_all, /* dcache_wbinv_all */ diff --git a/sys/arm/arm/cpufunc_asm_armv7.S b/sys/arm/arm/cpufunc_asm_armv7.S index af5c39e2a87..507c5323d71 100644 --- a/sys/arm/arm/cpufunc_asm_armv7.S +++ b/sys/arm/arm/cpufunc_asm_armv7.S @@ -250,6 +250,13 @@ ENTRY(armv7_idcache_wbinv_range) RET END(armv7_idcache_wbinv_range) +ENTRY_NP(armv7_icache_sync_all) + mcr p15, 0, r0, c7, c1, 0 /* Invalidate all I cache to PoU Inner Shareable */ + isb /* instruction synchronization barrier */ + dsb /* data synchronization barrier */ + RET +END(armv7_icache_sync_all) + ENTRY_NP(armv7_icache_sync_range) ldr ip, .Larmv7_line_size .Larmv7_sync_next: diff --git a/sys/arm/arm/elf_machdep.c b/sys/arm/arm/elf_machdep.c index 6aec18be042..8ef9bd444c9 100644 --- a/sys/arm/arm/elf_machdep.c +++ b/sys/arm/arm/elf_machdep.c @@ -220,9 +220,19 @@ int elf_cpu_load_file(linker_file_t lf __unused) { - cpu_idcache_wbinv_all(); - cpu_l2cache_wbinv_all(); - cpu_tlb_flushID(); + /* + * The pmap code does not do an icache sync upon establishing executable + * mappings in the kernel pmap. It's an optimization based on the fact + * that kernel memory allocations always have EXECUTABLE protection even + * when the memory isn't going to hold executable code. The only time + * kernel memory holding instructions does need a sync is after loading + * a kernel module, and that's when this function gets called. Normal + * data cache maintenance has already been done by the IO code, and TLB + * maintenance has been done by the pmap code, so all we have to do here + * is invalidate the instruction cache (which also invalidates the + * branch predictor cache on platforms that have one). + */ + cpu_icache_sync_all(); return (0); } diff --git a/sys/arm/include/cpufunc.h b/sys/arm/include/cpufunc.h index 49c08a3a45f..6251e2c85a6 100644 --- a/sys/arm/include/cpufunc.h +++ b/sys/arm/include/cpufunc.h @@ -411,6 +411,7 @@ void armv6_idcache_wbinv_range (vm_offset_t, vm_size_t); void armv7_setttb (u_int); void armv7_tlb_flushID (void); void armv7_tlb_flushID_SE (u_int); +void armv7_icache_sync_all (); void armv7_icache_sync_range (vm_offset_t, vm_size_t); void armv7_idcache_wbinv_range (vm_offset_t, vm_size_t); void armv7_idcache_inv_all (void); From 457b8af283b08525c6a5b8541bc41ea420c6581c Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 27 Apr 2014 01:06:02 +0000 Subject: [PATCH 31/67] Add script to setup bootable CD ISOs for both BIOS and EFI systems. Tested and working on QEMU. Actually using this script as the regular image generator, like with the memstick one, will require that the kernel support EFI too. In particular, the following two things are required: 1. vt(9) be the default console driver 2. vt_efifb and vt_vga be able to coexist usefully in the same kernel One other note here is that this requires newfs_msdos and mdconfig, which is really ugly. NetBSD's makefs at least seems to support FAT now. If that actually works, it should be imported and we can get rid of the mdconfig mess. --- release/amd64/mkisoimages-uefi.sh | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 release/amd64/mkisoimages-uefi.sh diff --git a/release/amd64/mkisoimages-uefi.sh b/release/amd64/mkisoimages-uefi.sh new file mode 100644 index 00000000000..2b89d89cda2 --- /dev/null +++ b/release/amd64/mkisoimages-uefi.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# +# Module: mkisoimages.sh +# Author: Jordan K Hubbard +# Date: 22 June 2001 +# +# $FreeBSD$ +# +# This script is used by release/Makefile to build the (optional) ISO images +# for a FreeBSD release. It is considered architecture dependent since each +# platform has a slightly unique way of making bootable CDs. This script +# is also allowed to generate any number of images since that is more of +# publishing decision than anything else. +# +# Usage: +# +# mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir] +# +# Where -b is passed if the ISO image should be made "bootable" by +# whatever standards this architecture supports (may be unsupported), +# image-label is the ISO image label, image-name is the filename of the +# resulting ISO image, base-bits-dir contains the image contents and +# extra-bits-dir, if provided, contains additional files to be merged +# into base-bits-dir as part of making the image. + +if [ "x$1" = "x-b" ]; then + # This is highly x86-centric and will be used directly below. + bootable="-o bootimage=i386;$4/boot/cdboot -o no-emul-boot" + + # Make EFI system partition (should be done with makefs in the future) + dd if=/dev/zero of=efiboot.img bs=4k count=100 + device=`mdconfig -a -t vnode -f efiboot.img` + newfs_msdos -F 12 -m 0xf8 /dev/$device + mkdir efi + mount -t msdosfs /dev/$device efi + mkdir -p efi/efi/boot + cp ${4}/boot/loader.efi efi/efi/boot/bootx64.efi + umount efi + rmdir efi + mdconfig -d -u $device + bootable="-o bootimage=i386;efiboot.img -o no-emul-boot $bootable" + + shift +else + bootable="" +fi + +if [ $# -lt 3 ]; then + echo Usage: $0 '[-b] image-label image-name base-bits-dir [extra-bits-dir]' + exit 1 +fi + +LABEL=`echo $1 | tr '[:lower:]' '[:upper:]'`; shift +NAME=$1; shift + +publisher="The FreeBSD Project. http://www.FreeBSD.org/" +echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab +makefs -t cd9660 $bootable -o rockridge -o label=$LABEL -o publisher="$publisher" $NAME $* +rm $1/etc/fstab +rm -f efiboot.img From 7ff9cf1d06a81d6d3342e957fe6c1d30c2bd945c Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 27 Apr 2014 02:19:53 +0000 Subject: [PATCH 32/67] Disable vga if EFI framebuffer present. vt(9) should handle this internally based on efifb's higher priority, but it doesn't, and this at least lets us build a kernel that boots on both BIOS and EFI systems for now. --- sys/dev/vt/hw/vga/vga.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys/dev/vt/hw/vga/vga.c b/sys/dev/vt/hw/vga/vga.c index 13c640a2add..b54210a50be 100644 --- a/sys/dev/vt/hw/vga/vga.c +++ b/sys/dev/vt/hw/vga/vga.c @@ -45,8 +45,10 @@ __FBSDID("$FreeBSD$"); #if defined(__amd64__) || defined(__i386__) #include #include +#include #include #include +#include #endif /* __amd64__ || __i386__ */ struct vga_softc { @@ -636,6 +638,19 @@ vga_init(struct vt_device *vd) struct vga_softc *sc = vd->vd_softc; int textmode = 0; +#if defined(__amd64__) || defined(__i386__) + /* Disable if EFI framebuffer present. Should be handled by priority + * logic in vt(9), but this will do for now. XXX */ + + caddr_t kmdp, efifb; + kmdp = preload_search_by_type("elf kernel"); + if (kmdp == NULL) + kmdp = preload_search_by_type("elf64 kernel"); + efifb = preload_search_info(kmdp, MODINFO_METADATA | MODINFOMD_EFI_FB); + if (efifb != NULL) + return (CN_DEAD); +#endif + #if defined(__amd64__) || defined(__i386__) sc->vga_fb_tag = X86_BUS_SPACE_MEM; sc->vga_fb_handle = KERNBASE + VGA_MEM_BASE; From f5d9a6964dffc3c86c3d95370518c8d8078d655a Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Sun, 27 Apr 2014 02:20:09 +0000 Subject: [PATCH 33/67] Move up fibnum to ensure it is always defined. Found by: ian MFC with: r264987 --- sys/net/rtsock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 9a32969f0cc..626dc8fbab1 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -531,6 +531,8 @@ route_output(struct mbuf *m, struct socket *so) union sockaddr_union saun; sa_family_t saf = AF_UNSPEC; + fibnum = so->so_fibnum; + #define senderr(e) { error = e; goto flush;} if (m == NULL || ((m->m_len < sizeof(long)) && (m = m_pullup(m, sizeof(long))) == NULL)) @@ -582,8 +584,6 @@ route_output(struct mbuf *m, struct socket *so) senderr(error); } - fibnum = so->so_fibnum; - /* * The given gateway address may be an interface address. * For example, issuing a "route change" command on a route From b2d52f78cf0c31e6aeba06bbfb0ee90c11010934 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 27 Apr 2014 02:20:51 +0000 Subject: [PATCH 34/67] Increase the maximum framebuffer size to more reasonable values reflecting the high-resolution boot consoles present on Open Firmware and EFI systems. --- sys/dev/vt/vt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h index 9445cc939cf..caab70908fd 100644 --- a/sys/dev/vt/vt.h +++ b/sys/dev/vt/vt.h @@ -337,10 +337,10 @@ void vt_upgrade(struct vt_device *vd); #define PIXEL_HEIGHT(h) ((h) / 16) #ifndef VT_FB_DEFAULT_WIDTH -#define VT_FB_DEFAULT_WIDTH 640 +#define VT_FB_DEFAULT_WIDTH 2048 #endif #ifndef VT_FB_DEFAULT_HEIGHT -#define VT_FB_DEFAULT_HEIGHT 480 +#define VT_FB_DEFAULT_HEIGHT 1200 #endif #define VT_CONSDEV_DECLARE(driver, width, height, softc) \ From 8bcbebe74123d7cf0f23ea7d43d3e58d20a40fd9 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 27 Apr 2014 02:22:21 +0000 Subject: [PATCH 35/67] Add vt_efifb to VT kernel configuration now that that actually works. This kernel will now boot on both BIOS and EFI systems without modification. Equivalent functionality in GENERIC requires making vt(9) the default console driver, which is probably appropriate at this point. --- sys/amd64/conf/VT | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/amd64/conf/VT b/sys/amd64/conf/VT index 7d0547f1145..c11f1afa442 100644 --- a/sys/amd64/conf/VT +++ b/sys/amd64/conf/VT @@ -12,3 +12,4 @@ nodevice vga device vt device vt_vga +device vt_efifb From bacc56cc08463406c5817cd8f8155e5d25584309 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 27 Apr 2014 02:28:32 +0000 Subject: [PATCH 36/67] Don't need this now. VT does the same thing, but better. Submitted by: gjb --- sys/amd64/conf/UEFI | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 sys/amd64/conf/UEFI diff --git a/sys/amd64/conf/UEFI b/sys/amd64/conf/UEFI deleted file mode 100644 index a06909776be..00000000000 --- a/sys/amd64/conf/UEFI +++ /dev/null @@ -1,11 +0,0 @@ -# VT -- kernel config using the vt(9) system console instead of legacy syscons -# -# For more information see https://wiki.freebsd.org/Newcons -# -# $FreeBSD$ - -include VT -ident UEFI - -nodevice vt_vga -device vt_efifb From 4c74acf76abe86b39a7f2c1a4eda939b82f1448a Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sun, 27 Apr 2014 05:19:01 +0000 Subject: [PATCH 37/67] When vm_fault_copy_entry() is called from vm_map_protect() for a wired entry and performs the upgrade of the entry permissions from read-only to read-write, we must allow to search for the source pages in the backing object, like we do in the case of forking the read-only wired entry. For the fork case, the behaviour is allowed by src_readonly boolean, which in fact is only used to assert that read-write case provides all source pages in the top-level object. Eliminate the src_readonly variable. Allow for the copy loop to look into the backing objects, add explicit asserts to ensure that only read-only and upgrade case actually does. Expand comments. Change the panic call into assert. Reported by: markj Tested by: markj, pho (previous version) Reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/vm/vm_fault.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index ba7692c2af5..3faf28b0407 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -1240,7 +1240,7 @@ vm_fault_copy_entry(vm_map_t dst_map, vm_map_t src_map, vm_offset_t vaddr; vm_page_t dst_m; vm_page_t src_m; - boolean_t src_readonly, upgrade; + boolean_t upgrade; #ifdef lint src_map++; @@ -1250,7 +1250,6 @@ vm_fault_copy_entry(vm_map_t dst_map, vm_map_t src_map, src_object = src_entry->object.vm_object; src_pindex = OFF_TO_IDX(src_entry->offset); - src_readonly = (src_entry->protection & VM_PROT_WRITE) == 0; /* * Create the top-level object for the destination entry. (Doesn't @@ -1321,25 +1320,33 @@ vm_fault_copy_entry(vm_map_t dst_map, vm_map_t src_map, /* * Find the page in the source object, and copy it in. - * (Because the source is wired down, the page will be in - * memory.) + * Because the source is wired down, the page will be + * in memory. */ VM_OBJECT_RLOCK(src_object); object = src_object; pindex = src_pindex + dst_pindex; while ((src_m = vm_page_lookup(object, pindex)) == NULL && - src_readonly && (backing_object = object->backing_object) != NULL) { /* - * Allow fallback to backing objects if we are reading. + * Unless the source mapping is read-only or + * it is presently being upgraded from + * read-only, the first object in the shadow + * chain should provide all of the pages. In + * other words, this loop body should never be + * executed when the source mapping is already + * read/write. */ + KASSERT((src_entry->protection & VM_PROT_WRITE) == 0 || + upgrade, + ("vm_fault_copy_entry: main object missing page")); + VM_OBJECT_RLOCK(backing_object); pindex += OFF_TO_IDX(object->backing_object_offset); VM_OBJECT_RUNLOCK(object); object = backing_object; } - if (src_m == NULL) - panic("vm_fault_copy_wired: page missing"); + KASSERT(src_m != NULL, ("vm_fault_copy_entry: page missing")); pmap_copy_page(src_m, dst_m); VM_OBJECT_RUNLOCK(object); dst_m->valid = VM_PAGE_BITS_ALL; From a9e285b047fc4c45290714f2008e9c5fe24d7dbf Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sun, 27 Apr 2014 05:28:14 +0000 Subject: [PATCH 38/67] Fix order of libthr and libc in the global dso list for sshd, by explicitely linking main binary with -lpthread. Before, libthr appeared in the list due to dependency of one of the kerberos libs. Due to the change in ld(1) behaviour of not copying NEEDED entries from direct dependencies into the link results, the order becomes reversed. The libthr must appear before libc to properly interpose libc symbols and provide working rtld locks implementation. The symptom was sshd hanging on rtld bind lock during nested symbol binding from a signal handler. Approved by: des (openssh maintainer) Sponsored by: The FreeBSD Foundation MFC after: 1 week --- secure/usr.sbin/sshd/Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/secure/usr.sbin/sshd/Makefile b/secure/usr.sbin/sshd/Makefile index 4f730a9d196..e1c71a3eab9 100644 --- a/secure/usr.sbin/sshd/Makefile +++ b/secure/usr.sbin/sshd/Makefile @@ -57,6 +57,16 @@ CFLAGS+= -DNONE_CIPHER_ENABLED DPADD+= ${LIBCRYPT} ${LIBCRYPTO} ${LIBZ} LDADD+= -lcrypt -lcrypto -lz +# Fix the order of NEEDED entries for libthr and libc. The libthr +# needs to interpose libc symbols, leaving the libthr loading as +# dependency of krb causes reversed order and broken interposing. Put +# the threading library last on the linker command line, just before +# the -lc added by a compiler driver. +.if ${MK_KERBEROS_SUPPORT} != "no" +DPADD+= ${LIBPTHREAD} +LDADD+= -lpthread +.endif + .if defined(LOCALBASE) CFLAGS+= -DXAUTH_PATH=\"${LOCALBASE}/bin/xauth\" .endif From dc74dde71eccbb6fafa6351038c6b5b1048abdc1 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sun, 27 Apr 2014 05:37:01 +0000 Subject: [PATCH 39/67] Same as it was done in r263878 for invlrng_handler(), fix order of checks for special pcid values in invlpg_pcid_handler(). Forst check for special values, and only then do PCID-specific page invalidation. Minor fix to the style compliance, declare local variable at the function start. Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/amd64/amd64/mp_machdep.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index f6981b97a7c..484fc061e00 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -1566,6 +1566,7 @@ invlpg_handler(void) void invlpg_pcid_handler(void) { + uint64_t cr3; #ifdef COUNT_XINVLTLB_HITS xhits_pg[PCPU_GET(cpuid)]++; #endif /* COUNT_XINVLTLB_HITS */ @@ -1573,15 +1574,13 @@ invlpg_pcid_handler(void) (*ipi_invlpg_counts[PCPU_GET(cpuid)])++; #endif /* COUNT_IPIS */ - if (invpcid_works) { - invpcid(&smp_tlb_invpcid, INVPCID_ADDR); + if (smp_tlb_invpcid.pcid == (uint64_t)-1) { + invltlb_globpcid(); } else if (smp_tlb_invpcid.pcid == 0) { invlpg(smp_tlb_invpcid.addr); - } else if (smp_tlb_invpcid.pcid == (uint64_t)-1) { - invltlb_globpcid(); + } else if (invpcid_works) { + invpcid(&smp_tlb_invpcid, INVPCID_ADDR); } else { - uint64_t cr3; - /* * PCID supported, but INVPCID is not. * Temporarily switch to the target address From 2277c5e5e228579e1951ee71ec60bbefe8842c36 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Sun, 27 Apr 2014 09:49:35 +0000 Subject: [PATCH 40/67] Do not delay freeing rtm. Bandaid added in r227061 is not needed since r227061, MFC after: 1 month --- sys/net/rtsock.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 626dc8fbab1..45ba6fd52a9 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -842,7 +842,7 @@ route_output(struct mbuf *m, struct socket *so) /* There is another listener, so construct message */ rp = sotorawcb(so); } - if (rtm) { + if (rtm != NULL) { #ifdef INET6 if (rti_need_deembed) { /* sin6_scope_id is recovered before sending rtm. */ @@ -865,6 +865,7 @@ route_output(struct mbuf *m, struct socket *so) m = NULL; } else if (m->m_pkthdr.len > rtm->rtm_msglen) m_adj(m, rtm->rtm_msglen - m->m_pkthdr.len); + Free(rtm); } if (m) { M_SETFIB(m, fibnum); @@ -881,9 +882,6 @@ route_output(struct mbuf *m, struct socket *so) } else rt_dispatch(m, saf); } - /* info.rti_info[RTAX_DST] (used above) can point inside of rtm */ - if (rtm) - Free(rtm); } return (error); } From 92c227af54baf380eff446012b76d6b810e49ec3 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Sun, 27 Apr 2014 10:20:37 +0000 Subject: [PATCH 41/67] Cleanup route_output() a bit. MFC after: 1 month --- sys/net/rtsock.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 45ba6fd52a9..674f81d3a5e 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -530,6 +530,7 @@ route_output(struct mbuf *m, struct socket *so) struct ifnet *ifp = NULL; union sockaddr_union saun; sa_family_t saf = AF_UNSPEC; + struct rawcb *rp = NULL; fibnum = so->so_fibnum; @@ -819,22 +820,14 @@ route_output(struct mbuf *m, struct socket *so) } flush: - if (rtm) { - if (error) - rtm->rtm_errno = error; - else - rtm->rtm_flags |= RTF_DONE; - } - if (rt) /* XXX can this be true? */ + if (rt != NULL) RTFREE(rt); - { - struct rawcb *rp = NULL; /* * Check to see if we don't want our own messages. */ if ((so->so_options & SO_USELOOPBACK) == 0) { if (V_route_cb.any_count <= 1) { - if (rtm) + if (rtm != NULL) Free(rtm); m_freem(m); return (error); @@ -842,6 +835,7 @@ route_output(struct mbuf *m, struct socket *so) /* There is another listener, so construct message */ rp = sotorawcb(so); } + if (rtm != NULL) { #ifdef INET6 if (rti_need_deembed) { @@ -859,6 +853,11 @@ route_output(struct mbuf *m, struct socket *so) } } #endif + if (error != 0) + rtm->rtm_errno = error; + else + rtm->rtm_flags |= RTF_DONE; + m_copyback(m, 0, rtm->rtm_msglen, (caddr_t)rtm); if (m->m_pkthdr.len < rtm->rtm_msglen) { m_freem(m); @@ -867,7 +866,7 @@ route_output(struct mbuf *m, struct socket *so) m_adj(m, rtm->rtm_msglen - m->m_pkthdr.len); Free(rtm); } - if (m) { + if (m != NULL) { M_SETFIB(m, fibnum); m->m_flags |= RTS_FILTER_FIB; if (rp) { @@ -882,7 +881,7 @@ route_output(struct mbuf *m, struct socket *so) } else rt_dispatch(m, saf); } - } + return (error); } From f1fcb55271ca244ca43ebedacfba83cb201f28c6 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Sun, 27 Apr 2014 10:43:48 +0000 Subject: [PATCH 42/67] Remove useless zeroing of RTAX_DST on error. Cleanup a bit. MFC after: 1 month --- sys/net/rtsock.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 674f81d3a5e..ecb31a6dbfa 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -542,32 +542,38 @@ route_output(struct mbuf *m, struct socket *so) panic("route_output"); len = m->m_pkthdr.len; if (len < sizeof(*rtm) || - len != mtod(m, struct rt_msghdr *)->rtm_msglen) { - info.rti_info[RTAX_DST] = NULL; + len != mtod(m, struct rt_msghdr *)->rtm_msglen) senderr(EINVAL); - } + R_Malloc(rtm, struct rt_msghdr *, len); - if (rtm == NULL) { - info.rti_info[RTAX_DST] = NULL; + if (rtm == NULL) senderr(ENOBUFS); - } m_copydata(m, 0, len, (caddr_t)rtm); + bzero(&info, sizeof(info)); + if (rtm->rtm_version != RTM_VERSION) { - info.rti_info[RTAX_DST] = NULL; + /* Do not touch message since format is unknown */ + Free(rtm); + rtm = NULL; senderr(EPROTONOSUPPORT); } + + /* + * Starting from here, it is possible + * to alter original message and insert + * caller PID and error value. + */ + rtm->rtm_pid = curproc->p_pid; - bzero(&info, sizeof(info)); info.rti_addrs = rtm->rtm_addrs; /* * rt_xaddrs() performs s6_addr[2] := sin6_scope_id for AF_INET6 * link-local address because rtrequest requires addresses with * embedded scope id. */ - if (rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info)) { - info.rti_info[RTAX_DST] = NULL; + if (rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info)) senderr(EINVAL); - } + info.rti_flags = rtm->rtm_flags; if (info.rti_info[RTAX_DST] == NULL || info.rti_info[RTAX_DST]->sa_family >= AF_MAX || From 628a40b5c47ab2c479935d3b5ede16f77f99c1da Mon Sep 17 00:00:00 2001 From: Luiz Otavio O Souza Date: Sun, 27 Apr 2014 12:11:00 +0000 Subject: [PATCH 43/67] Fix the gpio-specifier decoding by respecting the GPIO controller's #gpio-cells property. Add a new ofw_bus method (OFW_BUS_MAP_GPIOS()) that allows the GPIO controller to implement its own mapping to deal with gpio-specifiers, allowing the decoding of gpio-specifiers to be controller specific. The default ofw_bus_map_gpios() decodes the linux standard (#gpio-cells = <2>) and the FreeBSD standard (#gpio-cells = <3>). It pass the gpio-specifier flag field to the children as an ivar variable so they can act upon. --- sys/dev/gpio/gpiobusvar.h | 9 ++- sys/dev/gpio/ofw_gpiobus.c | 126 +++++++++++++++++++++++++++---------- sys/dev/ofw/ofw_bus.h | 8 +++ sys/dev/ofw/ofw_bus_if.m | 30 ++++++++- 4 files changed, 138 insertions(+), 35 deletions(-) diff --git a/sys/dev/gpio/gpiobusvar.h b/sys/dev/gpio/gpiobusvar.h index 94ae1adad60..3d387107762 100644 --- a/sys/dev/gpio/gpiobusvar.h +++ b/sys/dev/gpio/gpiobusvar.h @@ -60,17 +60,22 @@ struct gpiobus_softc int *sc_pins_mapped; /* mark mapped pins */ }; - struct gpiobus_ivar { uint32_t npins; /* pins total */ + uint32_t *flags; /* pins flags */ uint32_t *pins; /* pins map */ }; -void gpiobus_print_pins(struct gpiobus_ivar *); #ifdef FDT +struct ofw_gpiobus_devinfo { + struct gpiobus_ivar opd_dinfo; + struct ofw_bus_devinfo opd_obdinfo; +}; + device_t ofw_gpiobus_add_fdt_child(device_t, phandle_t); #endif +void gpiobus_print_pins(struct gpiobus_ivar *); extern driver_t gpiobus_driver; diff --git a/sys/dev/gpio/ofw_gpiobus.c b/sys/dev/gpio/ofw_gpiobus.c index 7641b56da76..f4eb37df96a 100644 --- a/sys/dev/gpio/ofw_gpiobus.c +++ b/sys/dev/gpio/ofw_gpiobus.c @@ -47,11 +47,6 @@ __FBSDID("$FreeBSD$"); #include "gpio_if.h" #include "gpiobus_if.h" -struct ofw_gpiobus_devinfo { - struct gpiobus_ivar opd_dinfo; - struct ofw_bus_devinfo opd_obdinfo; -}; - static int ofw_gpiobus_parse_gpios(struct gpiobus_softc *, struct gpiobus_ivar *, phandle_t); static struct ofw_gpiobus_devinfo *ofw_gpiobus_setup_devinfo(device_t, @@ -82,11 +77,38 @@ ofw_gpiobus_add_fdt_child(device_t bus, phandle_t child) return (childdev); } +static int +ofw_gpiobus_alloc_ivars(struct gpiobus_ivar *dinfo) +{ + + /* Allocate pins and flags memory. */ + dinfo->pins = malloc(sizeof(uint32_t) * dinfo->npins, M_DEVBUF, + M_NOWAIT | M_ZERO); + if (dinfo->pins == NULL) + return (ENOMEM); + dinfo->flags = malloc(sizeof(uint32_t) * dinfo->npins, M_DEVBUF, + M_NOWAIT | M_ZERO); + if (dinfo->flags == NULL) { + free(dinfo->pins, M_DEVBUF); + return (ENOMEM); + } + + return (0); +} + +static void +ofw_gpiobus_free_ivars(struct gpiobus_ivar *dinfo) +{ + + free(dinfo->flags, M_DEVBUF); + free(dinfo->pins, M_DEVBUF); +} + static int ofw_gpiobus_parse_gpios(struct gpiobus_softc *sc, struct gpiobus_ivar *dinfo, phandle_t child) { - int i, len; + int cells, i, j, len; pcell_t *gpios; phandle_t gpio; @@ -102,44 +124,81 @@ ofw_gpiobus_parse_gpios(struct gpiobus_softc *sc, struct gpiobus_ivar *dinfo, } /* - * Each 'gpios' entry must contain 4 pcells. - * The first one is the GPIO controller phandler. - * Then the last three are the GPIO pin, the GPIO pin direction and - * the GPIO pin flags. + * The gpio-specifier is controller independent, but the first pcell + * has the reference to the GPIO controller phandler. + * One the first pass we count the number of encoded gpio-specifiers. */ - if ((len / sizeof(pcell_t)) % 4) { + i = 0; + len /= sizeof(pcell_t); + while (i < len) { + /* Allow NULL specifiers. */ + if (gpios[i] == 0) { + dinfo->npins++; + i++; + continue; + } + gpio = OF_xref_phandle(gpios[i]); + /* Verify if we're attaching to the correct GPIO controller. */ + if (!OF_hasprop(gpio, "gpio-controller") || + gpio != ofw_bus_get_node(sc->sc_dev)) { + free(gpios, M_DEVBUF); + return (EINVAL); + } + /* Read gpio-cells property for this GPIO controller. */ + if (OF_getencprop(gpio, "#gpio-cells", &cells, + sizeof(cells)) < 0) { + free(gpios, M_DEVBUF); + return (EINVAL); + } + dinfo->npins++; + i += cells + 1; + } + + if (dinfo->npins == 0) { free(gpios, M_DEVBUF); return (EINVAL); } - dinfo->npins = len / (sizeof(pcell_t) * 4); - dinfo->pins = malloc(sizeof(uint32_t) * dinfo->npins, M_DEVBUF, - M_NOWAIT | M_ZERO); - if (dinfo->pins == NULL) { + + /* Allocate the child resources. */ + if (ofw_gpiobus_alloc_ivars(dinfo) != 0) { free(gpios, M_DEVBUF); return (ENOMEM); } - for (i = 0; i < dinfo->npins; i++) { + /* Decode the gpio specifier on the second pass. */ + i = 0; + j = 0; + while (i < len) { + /* Allow NULL specifiers. */ + if (gpios[i] == 0) { + i++; + j++; + continue; + } - /* Verify if we're attaching to the correct gpio controller. */ - gpio = OF_xref_phandle(gpios[i * 4 + 0]); - if (!OF_hasprop(gpio, "gpio-controller") || - gpio != ofw_bus_get_node(sc->sc_dev)) { - free(dinfo->pins, M_DEVBUF); + gpio = OF_xref_phandle(gpios[i]); + /* Read gpio-cells property for this GPIO controller. */ + if (OF_getencprop(gpio, "#gpio-cells", &cells, + sizeof(cells)) < 0) { + ofw_gpiobus_free_ivars(dinfo); free(gpios, M_DEVBUF); return (EINVAL); } - /* Get the GPIO pin number. */ - dinfo->pins[i] = gpios[i * 4 + 1]; - /* gpios[i * 4 + 2] - GPIO pin direction */ - /* gpios[i * 4 + 3] - GPIO pin flags */ + /* Get the GPIO pin number and flags. */ + if (ofw_bus_map_gpios(sc->sc_dev, child, gpio, cells, + &gpios[i + 1], &dinfo->pins[j], &dinfo->flags[j]) != 0) { + ofw_gpiobus_free_ivars(dinfo); + free(gpios, M_DEVBUF); + return (EINVAL); + } - if (dinfo->pins[i] > sc->sc_npins) { + /* Consistency check. */ + if (dinfo->pins[j] > sc->sc_npins) { device_printf(sc->sc_busdev, "invalid pin %d, max: %d\n", - dinfo->pins[i], sc->sc_npins - 1); - free(dinfo->pins, M_DEVBUF); + dinfo->pins[j], sc->sc_npins - 1); + ofw_gpiobus_free_ivars(dinfo); free(gpios, M_DEVBUF); return (EINVAL); } @@ -147,15 +206,18 @@ ofw_gpiobus_parse_gpios(struct gpiobus_softc *sc, struct gpiobus_ivar *dinfo, /* * Mark pin as mapped and give warning if it's already mapped. */ - if (sc->sc_pins_mapped[dinfo->pins[i]]) { + if (sc->sc_pins_mapped[dinfo->pins[j]]) { device_printf(sc->sc_busdev, "warning: pin %d is already mapped\n", - dinfo->pins[i]); - free(dinfo->pins, M_DEVBUF); + dinfo->pins[j]); + ofw_gpiobus_free_ivars(dinfo); free(gpios, M_DEVBUF); return (EINVAL); } - sc->sc_pins_mapped[dinfo->pins[i]] = 1; + sc->sc_pins_mapped[dinfo->pins[j]] = 1; + + i += cells + 1; + j++; } free(gpios, M_DEVBUF); diff --git a/sys/dev/ofw/ofw_bus.h b/sys/dev/ofw/ofw_bus.h index f7c72958d55..7f0e50e7f34 100644 --- a/sys/dev/ofw/ofw_bus.h +++ b/sys/dev/ofw/ofw_bus.h @@ -76,4 +76,12 @@ ofw_bus_map_intr(device_t dev, phandle_t iparent, int icells, pcell_t *intr) return (OFW_BUS_MAP_INTR(dev, dev, iparent, icells, intr)); } +static __inline int +ofw_bus_map_gpios(device_t bus, phandle_t dev, phandle_t gparent, int gcells, + pcell_t *gpios, uint32_t *pin, uint32_t *flags) +{ + return (OFW_BUS_MAP_GPIOS(bus, dev, gparent, gcells, gpios, pin, + flags)); +} + #endif /* !_DEV_OFW_OFW_BUS_H_ */ diff --git a/sys/dev/ofw/ofw_bus_if.m b/sys/dev/ofw/ofw_bus_if.m index 6486e966695..86c98761815 100644 --- a/sys/dev/ofw/ofw_bus_if.m +++ b/sys/dev/ofw/ofw_bus_if.m @@ -58,6 +58,7 @@ CODE { static ofw_bus_get_node_t ofw_bus_default_get_node; static ofw_bus_get_type_t ofw_bus_default_get_type; static ofw_bus_map_intr_t ofw_bus_default_map_intr; + static ofw_bus_map_gpios_t ofw_bus_default_map_gpios; static const struct ofw_bus_devinfo * ofw_bus_default_get_devinfo(device_t bus, device_t dev) @@ -113,6 +114,24 @@ CODE { /* If that fails, then assume a one-domain system */ return (interrupt[0]); } + + int + ofw_bus_default_map_gpios(device_t bus, phandle_t dev, + phandle_t gparent, int gcells, pcell_t *gpios, uint32_t *pin, + uint32_t *flags) + { + /* Propagate up the bus hierarchy until someone handles it. */ + if (device_get_parent(bus) != NULL) + return OFW_BUS_MAP_GPIOS(device_get_parent(bus), dev, + gparent, gcells, gpios, pin, flags); + + /* If that fails, then assume the FreeBSD defaults. */ + *pin = gpios[0]; + if (gcells == 2 || gcells == 3) + *flags = gpios[gcells - 1]; + + return (0); + } }; # Get the ofw_bus_devinfo struct for the device dev on the bus. Used for bus @@ -170,4 +189,13 @@ METHOD int map_intr { pcell_t *interrupt; } DEFAULT ofw_bus_default_map_intr; - +# Map the GPIO controller specific gpio-specifier to GPIO pin and flags. +METHOD int map_gpios { + device_t bus; + phandle_t dev; + phandle_t gparent; + int gcells; + pcell_t *gpios; + uint32_t *pin; + uint32_t *flags; +} DEFAULT ofw_bus_default_map_gpios; From 8376edae84ecef921c235a8dcb934de5098b92b4 Mon Sep 17 00:00:00 2001 From: Luiz Otavio O Souza Date: Sun, 27 Apr 2014 13:10:51 +0000 Subject: [PATCH 44/67] Revert r258678. Make the led gpio-specifier match again the #gpio-cells settings from the GPIO controller, which i had broken in r258678. Restore the active-low flag. --- sys/boot/fdt/dts/arm/rpi.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/boot/fdt/dts/arm/rpi.dts b/sys/boot/fdt/dts/arm/rpi.dts index 445d1ea8949..58ceaa42dcf 100644 --- a/sys/boot/fdt/dts/arm/rpi.dts +++ b/sys/boot/fdt/dts/arm/rpi.dts @@ -316,7 +316,7 @@ ok { label = "ok"; - gpios = <&gpio 16 2 0>; + gpios = <&gpio 16 1>; /* Don't change this - it configures * how the led driver determines if From b6a0a32b5841a6947dd4698e9d89110eda010a50 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Sun, 27 Apr 2014 15:14:59 +0000 Subject: [PATCH 45/67] Report boot method (BIOS/UEFI) via sysctl machdep.bootmethod Sponsored by: The FreeBSD Foundation --- sys/amd64/amd64/machdep.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 9675a045cce..cc2b581b624 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -1526,6 +1526,10 @@ add_efi_map_entries(struct efi_map_header *efihdr, vm_paddr_t *physmap, } } +static char bootmethod[16] = ""; +SYSCTL_STRING(_machdep, OID_AUTO, bootmethod, CTLFLAG_RD, bootmethod, 0, + "System firmware boot method"); + static void native_parse_memmap(caddr_t kmdp, vm_paddr_t *physmap, int *physmap_idx) { @@ -1550,9 +1554,11 @@ native_parse_memmap(caddr_t kmdp, vm_paddr_t *physmap, int *physmap_idx) if (efihdr != NULL) { add_efi_map_entries(efihdr, physmap, physmap_idx); + strlcpy(bootmethod, "UEFI", sizeof(bootmethod)); } else { size = *((u_int32_t *)smap - 1); bios_add_smap_entries(smap, size, physmap, physmap_idx); + strlcpy(bootmethod, "BIOS", sizeof(bootmethod)); } } From 8237c62b5ddd99f6ad935464a8ce2a8941c1980f Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sun, 27 Apr 2014 15:41:44 +0000 Subject: [PATCH 46/67] Setting the IMOD value below 0x3F8 can cause IRQ lockups in the Intel LynxPoint USB 3.0 controllers found in MacBookPro 2013's. MFC after: 2 days Tested by: Huang Wen Hui --- sys/dev/usb/controller/xhci.c | 6 +++++- sys/dev/usb/controller/xhci.h | 1 + sys/dev/usb/controller/xhci_pci.c | 1 + sys/dev/usb/controller/xhcireg.h | 3 ++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index 2764207bf7f..5092cc96272 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -495,8 +495,12 @@ xhci_start_controller(struct xhci_softc *sc) XWRITE4(sc, runt, XHCI_ERSTSZ(0), XHCI_ERSTS_SET(temp)); + /* Check if we should use the default IMOD value */ + if (sc->sc_imod_default == 0) + sc->sc_imod_default = XHCI_IMOD_DEFAULT; + /* Setup interrupt rate */ - XWRITE4(sc, runt, XHCI_IMOD(0), XHCI_IMOD_DEFAULT); + XWRITE4(sc, runt, XHCI_IMOD(0), sc->sc_imod_default); usbd_get_page(&sc->sc_hw.root_pc, 0, &buf_res); diff --git a/sys/dev/usb/controller/xhci.h b/sys/dev/usb/controller/xhci.h index c63632b0b44..b000e4f11dd 100644 --- a/sys/dev/usb/controller/xhci.h +++ b/sys/dev/usb/controller/xhci.h @@ -481,6 +481,7 @@ struct xhci_softc { uint16_t sc_erst_max; uint16_t sc_event_idx; uint16_t sc_command_idx; + uint16_t sc_imod_default; uint8_t sc_event_ccs; uint8_t sc_command_ccs; diff --git a/sys/dev/usb/controller/xhci_pci.c b/sys/dev/usb/controller/xhci_pci.c index 7e03b191e12..dc5a6e9dd44 100644 --- a/sys/dev/usb/controller/xhci_pci.c +++ b/sys/dev/usb/controller/xhci_pci.c @@ -242,6 +242,7 @@ xhci_pci_attach(device_t self) case 0x1e318086: /* Panther Point */ case 0x8c318086: /* Lynx Point */ sc->sc_port_route = &xhci_pci_port_route; + sc->sc_imod_default = XHCI_IMOD_DEFAULT_LP; break; default: break; diff --git a/sys/dev/usb/controller/xhcireg.h b/sys/dev/usb/controller/xhcireg.h index a130f65b92e..bd1d635cff7 100644 --- a/sys/dev/usb/controller/xhcireg.h +++ b/sys/dev/usb/controller/xhcireg.h @@ -166,7 +166,8 @@ #define XHCI_IMOD_IVAL_SET(x) (((x) & 0xFFFF) << 0) /* 250ns unit */ #define XHCI_IMOD_ICNT_GET(x) (((x) >> 16) & 0xFFFF) /* 250ns unit */ #define XHCI_IMOD_ICNT_SET(x) (((x) & 0xFFFF) << 16) /* 250ns unit */ -#define XHCI_IMOD_DEFAULT 0x000001F4U /* 8000 IRQ/second */ +#define XHCI_IMOD_DEFAULT 0x000001F4U /* 8000 IRQs/second */ +#define XHCI_IMOD_DEFAULT_LP 0x000003F8U /* 4000 IRQs/second - LynxPoint */ #define XHCI_ERSTSZ(n) (0x0028 + (0x20 * (n))) /* XHCI event ring segment table size */ #define XHCI_ERSTS_GET(x) ((x) & 0xFFFF) #define XHCI_ERSTS_SET(x) ((x) & 0xFFFF) From 235591a57877afc897e766518947fa6cca10125d Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 27 Apr 2014 15:58:07 +0000 Subject: [PATCH 47/67] Finish connecting up installer UEFI support. If the kernel was booted using EFI, set up the disks for an EFI system. If booted from BIOS/CSM, set up for BIOS. --- usr.sbin/bsdinstall/partedit/partedit_x86.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/usr.sbin/bsdinstall/partedit/partedit_x86.c b/usr.sbin/bsdinstall/partedit/partedit_x86.c index c9eda5d746f..156674bda0d 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_x86.c +++ b/usr.sbin/bsdinstall/partedit/partedit_x86.c @@ -32,8 +32,8 @@ #include "partedit.h" -static char platform[255] = "BIOS"; /* XXX once sysctl exists, make this an empty string */ -static const char *platform_sysctl = "hw.platform"; +static char platform[255] = ""; +static const char *platform_sysctl = "machdep.bootmethod"; const char * default_scheme(void) { @@ -82,7 +82,7 @@ bootpart_type(const char *scheme) { if (strlen(platform) == 0) sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); - if (strcmp(platform, "EFI") == 0) + if (strcmp(platform, "UEFI") == 0) return ("efi"); return ("freebsd-boot"); @@ -93,7 +93,7 @@ bootcode_path(const char *part_type) { size_t platlen = sizeof(platform); if (strlen(platform) == 0) sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); - if (strcmp(platform, "EFI") == 0) + if (strcmp(platform, "UEFI") == 0) return (NULL); if (strcmp(part_type, "GPT") == 0) @@ -113,7 +113,7 @@ partcode_path(const char *part_type) { sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); if (strcmp(part_type, "GPT") == 0) { - if (strcmp(platform, "EFI") == 0) + if (strcmp(platform, "UEFI") == 0) return ("/boot/boot1.efifat"); else return ("/boot/gptboot"); From faecd0da18bcd53db2ee3acb8510306fff2d4fb4 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 27 Apr 2014 16:34:59 +0000 Subject: [PATCH 48/67] loader's GPT support on BIOS does not seem to like the root filesystem being the last filesystem on the disk for some reason when made by this script. Add a vestigial swap partition to allow this to boot with QEMU BIOS. --- release/amd64/make-uefi-memstick.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/amd64/make-uefi-memstick.sh b/release/amd64/make-uefi-memstick.sh index d9145a5312e..6c289e093b8 100755 --- a/release/amd64/make-uefi-memstick.sh +++ b/release/amd64/make-uefi-memstick.sh @@ -36,6 +36,6 @@ if [ $? -ne 0 ]; then fi rm ${1}/etc/fstab -mkimg -s gpt -b ${1}/boot/pmbr -p freebsd-boot:=${1}/boot/gptboot -p efi:=${1}/boot/boot1.efifat -p freebsd-ufs:=${2}.part -o ${2} +mkimg -s gpt -b ${1}/boot/pmbr -p efi:=${1}/boot/boot1.efifat -p freebsd-boot:=${1}/boot/gptboot -p freebsd-ufs:=${2}.part -p freebsd-swap::1M -o ${2} rm ${2}.part From 73e46dba116dd9490e7f713f3d683096af48566a Mon Sep 17 00:00:00 2001 From: Glen Barber Date: Sun, 27 Apr 2014 16:40:40 +0000 Subject: [PATCH 49/67] Turn off the full witness trace on console output. On head/, or more specifically, when WITNESS is in the kernel config, the console is spammed excessively with lock order reversal between isofs and devfs. Set debug.witness.trace=0 in the installer sysctl.conf to avoid printing the full KDB stack backtrace. This does not prevent printing the lock order reversal has happened, only lessens the console spam. Sponsored by: The FreeBSD Foundation --- release/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/release/Makefile b/release/Makefile index c0f5506f9a6..92075f8365a 100644 --- a/release/Makefile +++ b/release/Makefile @@ -164,6 +164,7 @@ system: packagesystem ln -fs /tmp/bsdinstall_etc/resolv.conf release/etc/resolv.conf echo sendmail_enable=\"NONE\" > release/etc/rc.conf echo hostid_enable=\"NO\" >> release/etc/rc.conf + echo debug.witness.trace=0 >> release/etc/sysctl.conf cp ${.CURDIR}/rc.local release/etc touch ${.TARGET} @@ -188,6 +189,7 @@ bootonly: packagesystem ln -fs /tmp/bsdinstall_etc/resolv.conf bootonly/etc/resolv.conf echo sendmail_enable=\"NONE\" > bootonly/etc/rc.conf echo hostid_enable=\"NO\" >> bootonly/etc/rc.conf + echo debug.witness.trace=0 >> bootonly/etc/sysctl.conf cp ${.CURDIR}/rc.local bootonly/etc dvd: @@ -206,6 +208,7 @@ dvd: ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf + echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf cp ${.CURDIR}/rc.local ${.TARGET}/etc touch ${.TARGET} From f2e5eb368a7e6941171e8476572a3bd49b0c99ae Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Sun, 27 Apr 2014 17:41:18 +0000 Subject: [PATCH 50/67] Improve memory allocation model for rt_msg2() rtsock messages: * memory is now allocated as early as possible, without holding locks. * sysctl users are now guaranteed to get a response (M_WAITOK buffer prealloc). * socket users are more likely to use on-stack buffer for replies. * standard kernel malloc/free functions are now used instead of radix wrappers. rt_msg2() has been renamed to rtsock_msg_buffer(). MFC after: 1 month --- sys/net/rtsock.c | 160 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 108 insertions(+), 52 deletions(-) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index ecb31a6dbfa..886d8c53c4f 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -152,8 +152,8 @@ struct walkarg { static void rts_input(struct mbuf *m); static struct mbuf *rt_msg1(int type, struct rt_addrinfo *rtinfo); -static int rt_msg2(int type, struct rt_addrinfo *rtinfo, - caddr_t cp, struct walkarg *w); +static int rtsock_msg_buffer(int type, struct rt_addrinfo *rtinfo, + struct walkarg *w, int *plen); static int rt_xaddrs(caddr_t cp, caddr_t cplim, struct rt_addrinfo *rtinfo); static int sysctl_dumpentry(struct radix_node *rn, void *vw); @@ -526,11 +526,13 @@ route_output(struct mbuf *m, struct socket *so) struct sockaddr_in6 *sin6; int i, rti_need_deembed = 0; #endif - int len, error = 0, fibnum; + int alloc_len = 0, len, error = 0, fibnum; struct ifnet *ifp = NULL; union sockaddr_union saun; sa_family_t saf = AF_UNSPEC; struct rawcb *rp = NULL; + struct walkarg w; + char msgbuf[512]; fibnum = so->so_fibnum; @@ -545,15 +547,31 @@ route_output(struct mbuf *m, struct socket *so) len != mtod(m, struct rt_msghdr *)->rtm_msglen) senderr(EINVAL); - R_Malloc(rtm, struct rt_msghdr *, len); - if (rtm == NULL) - senderr(ENOBUFS); + /* + * Most of current messages are in range 200-240 bytes, + * minimize possible failures by using on-stack buffer + * which should fit for most messages. + * However, use stable memory if we need to handle + * something large. + */ + if (len < sizeof(msgbuf)) { + alloc_len = sizeof(msgbuf); + rtm = (struct rt_msghdr *)msgbuf; + } else { + alloc_len = roundup2(len, 1024); + rtm = malloc(alloc_len, M_TEMP, M_NOWAIT); + if (rtm == NULL) + senderr(ENOBUFS); + } + m_copydata(m, 0, len, (caddr_t)rtm); bzero(&info, sizeof(info)); + bzero(&w, sizeof(w)); if (rtm->rtm_version != RTM_VERSION) { /* Do not touch message since format is unknown */ - Free(rtm); + if ((char *)rtm != msgbuf) + free(rtm, M_TEMP); rtm = NULL; senderr(EPROTONOSUPPORT); } @@ -798,18 +816,26 @@ route_output(struct mbuf *m, struct socket *so) } else if ((ifp = rt->rt_ifp) != NULL) { rtm->rtm_index = ifp->if_index; } - len = rt_msg2(rtm->rtm_type, &info, NULL, NULL); - if (len > rtm->rtm_msglen) { + + /* Check if we need to realloc storage */ + rtsock_msg_buffer(rtm->rtm_type, &info, NULL, &len); + if (len > alloc_len) { struct rt_msghdr *new_rtm; - R_Malloc(new_rtm, struct rt_msghdr *, len); + new_rtm = malloc(len, M_TEMP, M_NOWAIT); if (new_rtm == NULL) { RT_UNLOCK(rt); senderr(ENOBUFS); } bcopy(rtm, new_rtm, rtm->rtm_msglen); - Free(rtm); rtm = new_rtm; + free(rtm, M_TEMP); + rtm = new_rtm; + alloc_len = len; } - (void)rt_msg2(rtm->rtm_type, &info, (caddr_t)rtm, NULL); + + w.w_tmem = (caddr_t)rtm; + w.w_tmemsize = alloc_len; + rtsock_msg_buffer(rtm->rtm_type, &info, &w, &len); + if (rt->rt_flags & RTF_GWFLAG_COMPAT) rtm->rtm_flags = RTF_GATEWAY | (rt->rt_flags & ~RTF_GWFLAG_COMPAT); @@ -833,8 +859,8 @@ route_output(struct mbuf *m, struct socket *so) */ if ((so->so_options & SO_USELOOPBACK) == 0) { if (V_route_cb.any_count <= 1) { - if (rtm != NULL) - Free(rtm); + if (rtm != NULL && (char *)rtm != msgbuf) + free(rtm, M_TEMP); m_freem(m); return (error); } @@ -870,7 +896,9 @@ route_output(struct mbuf *m, struct socket *so) m = NULL; } else if (m->m_pkthdr.len > rtm->rtm_msglen) m_adj(m, rtm->rtm_msglen - m->m_pkthdr.len); - Free(rtm); + + if ((char *)rtm != msgbuf) + free(rtm, M_TEMP); } if (m != NULL) { M_SETFIB(m, fibnum); @@ -1041,21 +1069,26 @@ rt_msg1(int type, struct rt_addrinfo *rtinfo) } /* - * Used by the sysctl code and routing socket. + * Writes information related to @rtinfo object to preallocated buffer. + * Stores needed size in @plen. If @w is NULL, calculates size without + * writing. + * Used for sysctl dumps and rtsock answers (RTM_DEL/RTM_GET) generation. + * + * Returns 0 on success. + * */ static int -rt_msg2(int type, struct rt_addrinfo *rtinfo, caddr_t cp, struct walkarg *w) +rtsock_msg_buffer(int type, struct rt_addrinfo *rtinfo, struct walkarg *w, int *plen) { int i; - int len, dlen, second_time = 0; - caddr_t cp0; + int len, buflen = 0, dlen; + caddr_t cp; + struct rt_msghdr *rtm = NULL; #ifdef INET6 struct sockaddr_storage ss; struct sockaddr_in6 *sin6; #endif - rtinfo->rti_addrs = 0; -again: switch (type) { case RTM_DELADDR: @@ -1094,9 +1127,14 @@ rt_msg2(int type, struct rt_addrinfo *rtinfo, caddr_t cp, struct walkarg *w) default: len = sizeof(struct rt_msghdr); } - cp0 = cp; - if (cp0) - cp += len; + + if (w != NULL) { + rtm = (struct rt_msghdr *)w->w_tmem; + buflen = w->w_tmemsize - len; + cp = (caddr_t)w->w_tmem + len; + } + + rtinfo->rti_addrs = 0; for (i = 0; i < RTAX_MAX; i++) { struct sockaddr *sa; @@ -1104,7 +1142,7 @@ rt_msg2(int type, struct rt_addrinfo *rtinfo, caddr_t cp, struct walkarg *w) continue; rtinfo->rti_addrs |= (1 << i); dlen = SA_SIZE(sa); - if (cp) { + if (cp != NULL && buflen >= dlen) { #ifdef INET6 if (V_deembed_scopeid && sa->sa_family == AF_INET6) { sin6 = (struct sockaddr_in6 *)&ss; @@ -1115,37 +1153,40 @@ rt_msg2(int type, struct rt_addrinfo *rtinfo, caddr_t cp, struct walkarg *w) #endif bcopy((caddr_t)sa, cp, (unsigned)dlen); cp += dlen; + buflen -= dlen; + } else if (cp != NULL) { + /* + * Buffer too small. Count needed size + * and return with error. + */ + cp = NULL; } + len += dlen; } - len = ALIGN(len); - if (cp == NULL && w != NULL && !second_time) { - struct walkarg *rw = w; - if (rw->w_req) { - if (rw->w_tmemsize < len) { - if (rw->w_tmem) - free(rw->w_tmem, M_RTABLE); - rw->w_tmem = (caddr_t) - malloc(len, M_RTABLE, M_NOWAIT); - if (rw->w_tmem) - rw->w_tmemsize = len; - } - if (rw->w_tmem) { - cp = rw->w_tmem; - second_time = 1; - goto again; - } - } + if (cp != NULL) { + dlen = ALIGN(len) - len; + if (buflen < dlen) + cp = NULL; + else + buflen -= dlen; } - if (cp) { - struct rt_msghdr *rtm = (struct rt_msghdr *)cp0; + len = ALIGN(len); + if (cp != NULL) { + /* fill header iff buffer is large enough */ rtm->rtm_version = RTM_VERSION; rtm->rtm_type = type; rtm->rtm_msglen = len; } - return (len); + + *plen = len; + + if (w != NULL && cp == NULL) + return (ENOBUFS); + + return (0); } /* @@ -1473,7 +1514,8 @@ sysctl_dumpentry(struct radix_node *rn, void *vw) if (rt->rt_ifp->if_flags & IFF_POINTOPOINT) info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr; } - size = rt_msg2(RTM_GET, &info, NULL, w); + if ((error = rtsock_msg_buffer(RTM_GET, &info, w, &size)) != 0) + return (error); if (w->w_req && w->w_tmem) { struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem; @@ -1649,7 +1691,9 @@ sysctl_iflist(int af, struct walkarg *w) IF_ADDR_RLOCK(ifp); ifa = ifp->if_addr; info.rti_info[RTAX_IFP] = ifa->ifa_addr; - len = rt_msg2(RTM_IFINFO, &info, NULL, w); + error = rtsock_msg_buffer(RTM_IFINFO, &info, w, &len); + if (error != 0) + goto done; info.rti_info[RTAX_IFP] = NULL; if (w->w_req && w->w_tmem) { if (w->w_op == NET_RT_IFLISTL) @@ -1668,7 +1712,9 @@ sysctl_iflist(int af, struct walkarg *w) info.rti_info[RTAX_IFA] = ifa->ifa_addr; info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask; info.rti_info[RTAX_BRD] = ifa->ifa_dstaddr; - len = rt_msg2(RTM_NEWADDR, &info, NULL, w); + error = rtsock_msg_buffer(RTM_NEWADDR, &info, w, &len); + if (error != 0) + goto done; if (w->w_req && w->w_tmem) { if (w->w_op == NET_RT_IFLISTL) error = sysctl_iflist_ifaml(ifa, &info, @@ -1718,7 +1764,9 @@ sysctl_ifmalist(int af, struct walkarg *w) info.rti_info[RTAX_GATEWAY] = (ifma->ifma_addr->sa_family != AF_LINK) ? ifma->ifma_lladdr : NULL; - len = rt_msg2(RTM_NEWMADDR, &info, NULL, w); + error = rtsock_msg_buffer(RTM_NEWADDR, &info, w, &len); + if (error != 0) + goto done; if (w->w_req && w->w_tmem) { struct ifma_msghdr *ifmam; @@ -1778,6 +1826,14 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS) error = sysctl_wire_old_buffer(req, 0); if (error) return (error); + + /* + * Allocate reply buffer in advance. + * All rtsock messages has maximum length of u_short. + */ + w.w_tmemsize = 65536; + w.w_tmem = malloc(w.w_tmemsize, M_TEMP, M_WAITOK); + switch (w.w_op) { case NET_RT_DUMP: @@ -1824,8 +1880,8 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS) error = sysctl_ifmalist(af, &w); break; } - if (w.w_tmem) - free(w.w_tmem, M_RTABLE); + + free(w.w_tmem, M_TEMP); return (error); } From edecf7f6c15c976c8dfbbe68452319296326e704 Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Sun, 27 Apr 2014 18:12:55 +0000 Subject: [PATCH 51/67] Remove cpu_idcache_wbinv_all() from kdb_cpu_trap(), it's no longer needed. This was added ca. 2004 for the purpose of ensuring the caches were in the right state after the debugger set a breakpoint. kdb_cpu_sync_icache() was added in 2007 to handle that situation, and now the wbinv_all is actually harmful because the operation isn't broadcast to other cores. --- sys/arm/include/kdb.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/arm/include/kdb.h b/sys/arm/include/kdb.h index b04cd581aad..98099a35e1a 100644 --- a/sys/arm/include/kdb.h +++ b/sys/arm/include/kdb.h @@ -55,8 +55,6 @@ kdb_cpu_sync_icache(unsigned char *addr, size_t size) static __inline void kdb_cpu_trap(int type, int code) { - - cpu_idcache_wbinv_all(); } #endif /* _MACHINE_KDB_H_ */ From 824e4131a01b6b1277343ef3c1807c120f97b23c Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Sun, 27 Apr 2014 20:01:59 +0000 Subject: [PATCH 52/67] There is no difference between IPI_STOP and IPI_STOP_HARD on ARM, so map them both to the same interrupt number like other arches do. --- sys/arm/arm/mp_machdep.c | 1 - sys/arm/include/smp.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/arm/arm/mp_machdep.c b/sys/arm/arm/mp_machdep.c index fd275feabe7..141f2db0401 100644 --- a/sys/arm/arm/mp_machdep.c +++ b/sys/arm/arm/mp_machdep.c @@ -278,7 +278,6 @@ ipi_handler(void *arg) break; case IPI_STOP: - case IPI_STOP_HARD: /* * IPI_STOP_HARD is mapped to IPI_STOP so it is not * necessary to add it in the switch. diff --git a/sys/arm/include/smp.h b/sys/arm/include/smp.h index 179882d3817..6301c9a95ce 100644 --- a/sys/arm/include/smp.h +++ b/sys/arm/include/smp.h @@ -10,7 +10,7 @@ #define IPI_PREEMPT 2 #define IPI_RENDEZVOUS 3 #define IPI_STOP 4 -#define IPI_STOP_HARD 5 +#define IPI_STOP_HARD 4 #define IPI_HARDCLOCK 6 #define IPI_TLB 7 From fa046341af27c9b3ab166fb2828e5dd44503cc99 Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Sun, 27 Apr 2014 20:16:51 +0000 Subject: [PATCH 53/67] Flush and invalidate caches on each CPU as part of handling IPI_STOP. Flushing the caches is required before doing a panic dump, but ARM doesn't provide a flavor of flush that gets broadcast to other cores. However, all cores except one are stopped before doing a dump, so this works around the lack of a global flush/invalidate by doing it locally on each CPU as part of stopping. Discussed with: cognet@ --- sys/arm/arm/minidump_machdep.c | 10 +++++++++- sys/arm/arm/mp_machdep.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/sys/arm/arm/minidump_machdep.c b/sys/arm/arm/minidump_machdep.c index 69c82f84c26..85ea2827c25 100644 --- a/sys/arm/arm/minidump_machdep.c +++ b/sys/arm/arm/minidump_machdep.c @@ -210,7 +210,15 @@ minidumpsys(struct dumperinfo *di) int i, k, bit, error; char *addr; - /* Flush cache */ + /* + * Flush caches. Note that in the SMP case this operates only on the + * current CPU's L1 cache. Before we reach this point, code in either + * the system shutdown or kernel debugger has called stop_cpus() to stop + * all cores other than this one. Part of the ARM handling of + * stop_cpus() is to call wbinv_all() on that core's local L1 cache. So + * by time we get to here, all that remains is to flush the L1 for the + * current CPU, then the L2. + */ cpu_idcache_wbinv_all(); cpu_l2cache_wbinv_all(); diff --git a/sys/arm/arm/mp_machdep.c b/sys/arm/arm/mp_machdep.c index 141f2db0401..6b16ad3fb26 100644 --- a/sys/arm/arm/mp_machdep.c +++ b/sys/arm/arm/mp_machdep.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -286,6 +287,19 @@ ipi_handler(void *arg) savectx(&stoppcbs[cpu]); + /* + * CPUs are stopped when entering the debugger and at + * system shutdown, both events which can precede a + * panic dump. For the dump to be correct, all caches + * must be flushed and invalidated, but on ARM there's + * no way to broadcast a wbinv_all to other cores. + * Instead, we have each core do the local wbinv_all as + * part of stopping the core. The core requesting the + * stop will do the l2 cache flush after all other cores + * have done their l1 flushes and stopped. + */ + cpu_idcache_wbinv_all(); + /* Indicate we are stopped */ CPU_SET_ATOMIC(cpu, &stopped_cpus); From f62cbe0e4930e3784490d69ea94895665105aec5 Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Sun, 27 Apr 2014 20:26:15 +0000 Subject: [PATCH 54/67] Explain why wbinv_all is SMP-safe in this case, and add a missing l2 cache flush. (Either it was missing here, or it isn't needed in the minidump case. Adding it here seems like the safer path to consistancy.) --- sys/arm/arm/dump_machdep.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/arm/arm/dump_machdep.c b/sys/arm/arm/dump_machdep.c index e8ba5768f9a..f37346c3d00 100644 --- a/sys/arm/arm/dump_machdep.c +++ b/sys/arm/arm/dump_machdep.c @@ -174,8 +174,14 @@ cb_dumpdata(struct md_pa *mdp, int seqnr, void *arg) printf(" chunk %d: %dMB (%d pages)", seqnr, pgs * PAGE_SIZE / ( 1024*1024), pgs); - /* Make sure we write coherent datas. */ + /* + * Make sure we write coherent data. Note that in the SMP case this + * only operates on the L1 cache of the current CPU, but all other CPUs + * have already been stopped, and their flush/invalidate was done as + * part of stopping. + */ cpu_idcache_wbinv_all(); + cpu_l2cache_wbinv_all(); #ifdef __XSCALE__ xscale_cache_clean_minidata(); #endif From 43336b6385658e8c490fd32839f9a5b8f4b87e73 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 27 Apr 2014 20:36:19 +0000 Subject: [PATCH 55/67] No EFI on i386. This unbreaks the i386 VT kernel build. --- sys/dev/vt/hw/vga/vga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/vt/hw/vga/vga.c b/sys/dev/vt/hw/vga/vga.c index b54210a50be..16e07512f8b 100644 --- a/sys/dev/vt/hw/vga/vga.c +++ b/sys/dev/vt/hw/vga/vga.c @@ -638,7 +638,7 @@ vga_init(struct vt_device *vd) struct vga_softc *sc = vd->vd_softc; int textmode = 0; -#if defined(__amd64__) || defined(__i386__) +#if defined(__amd64__) /* Disable if EFI framebuffer present. Should be handled by priority * logic in vt(9), but this will do for now. XXX */ From de46b2c650b8b9f9f9306aa1063f3c0bb51f0623 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Sun, 27 Apr 2014 21:17:54 +0000 Subject: [PATCH 56/67] Fix build Found by: ian Pointyhat to: me --- sys/net/rtsock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 886d8c53c4f..a40f067325b 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1082,7 +1082,7 @@ rtsock_msg_buffer(int type, struct rt_addrinfo *rtinfo, struct walkarg *w, int * { int i; int len, buflen = 0, dlen; - caddr_t cp; + caddr_t cp = NULL; struct rt_msghdr *rtm = NULL; #ifdef INET6 struct sockaddr_storage ss; From 9febee763bdded4e44b5adde5b860fb5f75b8200 Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Sun, 27 Apr 2014 22:18:33 +0000 Subject: [PATCH 57/67] Disable the beastie menu for EFI console which doesn't support ANSI codes (so things like `at-xy', `clear', and other commands don't work making it impossible to generate a living menu). Reviewed by: nwhitehorn, emaste --- sys/boot/forth/beastie.4th | 5 +++++ sys/boot/forth/beastie.4th.8 | 4 +++- sys/boot/forth/loader.conf.5 | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sys/boot/forth/beastie.4th b/sys/boot/forth/beastie.4th index 7a2cbb094b3..2fc073d1c00 100644 --- a/sys/boot/forth/beastie.4th +++ b/sys/boot/forth/beastie.4th @@ -242,6 +242,11 @@ variable logoY ; : beastie-start ( -- ) \ starts the menu + s" console" getenv dup -1 <> if + s" efi" 2swap contains? if + s" set beastie_disable=YES" evaluate + then + else drop then s" beastie_disable" getenv dup -1 <> if s" YES" compare-insensitive 0= if diff --git a/sys/boot/forth/beastie.4th.8 b/sys/boot/forth/beastie.4th.8 index 30d29b2cb07..534a60ce6bd 100644 --- a/sys/boot/forth/beastie.4th.8 +++ b/sys/boot/forth/beastie.4th.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 16, 2011 +.Dd April 27, 2014 .Dt BEASTIE.4TH 8 .Os .Sh NAME @@ -119,6 +119,8 @@ Sets the desired row position of the logo. Default is 4. If set to .Dq YES , the beastie boot menu will be skipped. +The beastie boot menu is always skipped if booting UEFI or running non-x86 +hardware. .It Va loader_delay If set to a number higher than zero, introduces a delay before starting the beastie boot menu. During the delay the user can press either Ctrl-C to skip diff --git a/sys/boot/forth/loader.conf.5 b/sys/boot/forth/loader.conf.5 index d63890957aa..3c1ce1d320d 100644 --- a/sys/boot/forth/loader.conf.5 +++ b/sys/boot/forth/loader.conf.5 @@ -23,7 +23,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd October 18, 2013 +.Dd April 27, 2014 .Dt LOADER.CONF 5 .Os .Sh NAME @@ -236,6 +236,8 @@ be displayed. If set to .Dq YES , the beastie boot menu will be skipped. +The beastie boot menu is always skipped if booting UEFI or running non-x86 +hardware. .It Va loader_logo Pq Dq Li orbbw Selects a desired logo in the beastie boot menu. Possible values are: From 552c5506283d37430d9f3eb28e927b198fbea4f5 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Sun, 27 Apr 2014 23:31:42 +0000 Subject: [PATCH 58/67] Do a read-after-write to ensure the interrupt register update is flushed to the hardware. The QCA HAL has a comment noting that if this isn't done, modifications to AR_IMR_S2 before AR_IMR is flushed may produce spurious interrupts. Obtained from: QCA --- sys/dev/ath/ath_hal/ar5416/ar5416_interrupts.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_interrupts.c b/sys/dev/ath/ath_hal/ar5416/ar5416_interrupts.c index 631ca2fca2e..32ce2ed5b07 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_interrupts.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_interrupts.c @@ -337,6 +337,9 @@ ar5416SetInterrupts(struct ath_hal *ah, HAL_INT ints) /* Write the new IMR and store off our SW copy. */ HALDEBUG(ah, HAL_DEBUG_INTERRUPT, "%s: new IMR 0x%x\n", __func__, mask); OS_REG_WRITE(ah, AR_IMR, mask); + /* Flush write */ + (void) OS_REG_READ(ah, AR_IMR); + mask = OS_REG_READ(ah, AR_IMR_S2) & ~(AR_IMR_S2_TIM | AR_IMR_S2_DTIM | AR_IMR_S2_DTIMSYNC | From 3e9b8fe01b84e5e5f9db2a3c67f3e9bd5848a7cf Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Sun, 27 Apr 2014 23:33:37 +0000 Subject: [PATCH 59/67] Fix the AR_SLEEP1 and AR_SLEEP2 definitions. Oops! Tested: * AR9285, STA * AR5416, STA Obtained from: QCA, Linux ath9k --- sys/dev/ath/ath_hal/ar5416/ar5416reg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416reg.h b/sys/dev/ath/ath_hal/ar5416/ar5416reg.h index 435599ce71a..0ee1e70efe5 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416reg.h +++ b/sys/dev/ath/ath_hal/ar5416/ar5416reg.h @@ -476,10 +476,10 @@ /* Sleep control */ #define AR5416_SLEEP1_ASSUME_DTIM 0x00080000 #define AR5416_SLEEP1_CAB_TIMEOUT 0xFFE00000 /* Cab timeout (TU) */ -#define AR5416_SLEEP1_CAB_TIMEOUT_S 22 +#define AR5416_SLEEP1_CAB_TIMEOUT_S 21 #define AR5416_SLEEP2_BEACON_TIMEOUT 0xFFE00000 /* Beacon timeout (TU)*/ -#define AR5416_SLEEP2_BEACON_TIMEOUT_S 22 +#define AR5416_SLEEP2_BEACON_TIMEOUT_S 21 /* Sleep Registers */ #define AR_SLP32_HALFCLK_LATENCY 0x000FFFFF /* rising <-> falling edge */ From ee6325ab562b540bd5dbc734e1801c1da9e6d965 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Sun, 27 Apr 2014 23:35:05 +0000 Subject: [PATCH 60/67] Program the AR_TSFOOR_THRESHOLD register with a default lifted from the QCA HAL. This fires off an interrupt if the TSF from the AP / IBSS peer is wildly out of range. I'll add some code to the ath(4) driver soon which makes use of this. TODO: * verify this didn't break TDMA! --- sys/dev/ath/ath_hal/ar5416/ar5416_beacon.c | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_beacon.c b/sys/dev/ath/ath_hal/ar5416/ar5416_beacon.c index e2bf6c73276..6691c11bcdd 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_beacon.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_beacon.c @@ -197,6 +197,25 @@ ar5416SetStaBeaconTimers(struct ath_hal *ah, const HAL_BEACON_STATE *bs) * beacon jitter; cab timeout is max time to wait for cab * after seeing the last DTIM or MORE CAB bit */ + +/* + * I've bumped these to 30TU for now. + * + * Some APs (AR933x/AR934x?) in 2GHz especially seem to not always + * transmit beacon frames at exactly the right times and with it set + * to 10TU, the NIC starts not waking up at the right times to hear + * these slightly-larger-jitering beacons. It also never recovers + * from that (it doesn't resync? I'm not sure.) + * + * So for now bump this to 30TU. Ideally we'd cap this based on + * the beacon interval so the sum of CAB+BEACON timeouts never + * exceeded the beacon interval. + * + * Now, since we're doing all the math in the ath(4) driver in TU + * rather than TSF, we may be seeing the result of dumb rounding + * errors causing the jitter to actually be a much bigger problem. + * I'll have to investigate that with a fine tooth comb. + */ #define CAB_TIMEOUT_VAL 10 /* in TU */ #define BEACON_TIMEOUT_VAL 10 /* in TU */ #define SLEEP_SLOP 3 /* in TU */ @@ -248,6 +267,13 @@ ar5416SetStaBeaconTimers(struct ath_hal *ah, const HAL_BEACON_STATE *bs) OS_REG_SET_BIT(ah, AR_TIMER_MODE, AR_TIMER_MODE_TBTT | AR_TIMER_MODE_TIM | AR_TIMER_MODE_DTIM); + +#define HAL_TSFOOR_THRESHOLD 0x00004240 /* TSF OOR threshold (16k us) */ + + /* TSF out of range threshold */ +// OS_REG_WRITE(ah, AR_TSFOOR_THRESHOLD, bs->bs_tsfoor_threshold); + OS_REG_WRITE(ah, AR_TSFOOR_THRESHOLD, HAL_TSFOOR_THRESHOLD); + HALDEBUG(ah, HAL_DEBUG_BEACON, "%s: next DTIM %d\n", __func__, bs->bs_nextdtim); HALDEBUG(ah, HAL_DEBUG_BEACON, "%s: next beacon %d\n", From dd7b232e399806c400a17a6777b9a185f1c330b5 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Sun, 27 Apr 2014 23:36:44 +0000 Subject: [PATCH 61/67] * Add a new capability which returns whether the hardware supports the MYBEACON RX filter (only receive beacons which match the BSSID) or all beacons on the current channel. * Add the relevant RX filter entry for MYBEACON. Tested: * AR5416, STA * AR9285, STA TODO: * once the code is in -HEAD, just make sure that the code which uses it correctly sets BEACON for pre-AR5416 chips. Obtained from: QCA, Linux ath9k --- sys/dev/ath/ath_hal/ah.c | 2 ++ sys/dev/ath/ath_hal/ah.h | 2 ++ sys/dev/ath/ath_hal/ah_internal.h | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/dev/ath/ath_hal/ah.c b/sys/dev/ath/ath_hal/ah.c index 7187d576e26..bbfc09b84f3 100644 --- a/sys/dev/ath/ath_hal/ah.c +++ b/sys/dev/ath/ath_hal/ah.c @@ -786,6 +786,8 @@ ath_hal_getcapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type, return HAL_OK; case HAL_CAP_RX_LNA_MIXING: /* Hardware uses an RX LNA mixer to map 2 antennas to a 1 stream receiver */ return pCap->halRxUsingLnaMixing ? HAL_OK : HAL_ENOTSUPP; + case HAL_CAP_DO_MYBEACON: /* Hardware supports filtering my-beacons */ + return pCap->halRxDoMyBeacon ? HAL_OK : HAL_ENOTSUPP; default: return HAL_EINVAL; } diff --git a/sys/dev/ath/ath_hal/ah.h b/sys/dev/ath/ath_hal/ah.h index 85735422402..4f2d3e9a0ba 100644 --- a/sys/dev/ath/ath_hal/ah.h +++ b/sys/dev/ath/ath_hal/ah.h @@ -199,6 +199,7 @@ typedef enum { HAL_CAP_SERIALISE_WAR = 245, /* serialise register access on PCI */ HAL_CAP_ENFORCE_TXOP = 246, /* Enforce TXOP if supported */ HAL_CAP_RX_LNA_MIXING = 247, /* RX hardware uses LNA mixing */ + HAL_CAP_DO_MYBEACON = 248, /* Supports HAL_RX_FILTER_MYBEACON */ } HAL_CAPABILITY_TYPE; /* @@ -404,6 +405,7 @@ typedef enum { HAL_RX_FILTER_PROM = 0x00000020, /* Promiscuous mode */ HAL_RX_FILTER_PROBEREQ = 0x00000080, /* Allow probe request frames */ HAL_RX_FILTER_PHYERR = 0x00000100, /* Allow phy errors */ + HAL_RX_FILTER_MYBEACON = 0x00000200, /* Filter beacons other than mine */ HAL_RX_FILTER_COMPBAR = 0x00000400, /* Allow compressed BAR */ HAL_RX_FILTER_COMP_BA = 0x00000800, /* Allow compressed blockack */ HAL_RX_FILTER_PHYRADAR = 0x00002000, /* Allow phy radar errors */ diff --git a/sys/dev/ath/ath_hal/ah_internal.h b/sys/dev/ath/ath_hal/ah_internal.h index 908f33eceda..9e3c83b3098 100644 --- a/sys/dev/ath/ath_hal/ah_internal.h +++ b/sys/dev/ath/ath_hal/ah_internal.h @@ -280,7 +280,8 @@ typedef struct { halAntDivCombSupportOrg : 1, halRadioRetentionSupport : 1, halSpectralScanSupport : 1, - halRxUsingLnaMixing : 1; + halRxUsingLnaMixing : 1, + halRxDoMyBeacon : 1; uint32_t halWirelessModes; uint16_t halTotalQueues; From a4e6347b86da7b9c08e8e717acd13ebaca6f4966 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Sun, 27 Apr 2014 23:37:03 +0000 Subject: [PATCH 62/67] Note that the AR5416 and later hardware supports the MYBEACON RX filter. --- sys/dev/ath/ath_hal/ar5416/ar5416_attach.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c b/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c index 99bab06ee9c..bdc61118b9c 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c @@ -1059,6 +1059,11 @@ ar5416FillCapabilityInfo(struct ath_hal *ah) if (! AH_PRIVATE(ah)->ah_ispcie) pCap->halSerialiseRegWar = 1; + /* + * AR5416 and later NICs support MYBEACON filtering. + */ + pCap->halRxDoMyBeacon = AH_TRUE; + return AH_TRUE; } From 17102f802f68859279ed105a0c30765cab7eb0d1 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Sun, 27 Apr 2014 23:37:39 +0000 Subject: [PATCH 63/67] Note that the AR9380 and later hardware supports MYBEACON. (Yes, I said AR5416 in the committed code. It's still strictly true.) --- sys/contrib/dev/ath/ath_hal/ar9300/ar9300_attach.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_attach.c b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_attach.c index 335414e2b07..46833ef749f 100644 --- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_attach.c +++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_attach.c @@ -2934,6 +2934,10 @@ ar9300_fill_capability_info(struct ath_hal *ah) p_cap->halRxUsingLnaMixing = AH_TRUE; } + /* + * AR5416 and later NICs support MYBEACON filtering. + */ + p_cap->halRxDoMyBeacon = AH_TRUE; #if ATH_WOW_OFFLOAD if (AR_SREV_JUPITER_20_OR_LATER(ah) || AR_SREV_APHRODITE(ah)) { From 88b3694bd99d8e36e522461d3932cba2c260c178 Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Sun, 27 Apr 2014 23:47:38 +0000 Subject: [PATCH 64/67] Move duplicated code to print l2 cache config into the common code. --- sys/arm/arm/pl310.c | 43 ++++++++++++++++++++++++++++++ sys/arm/freescale/imx/imx6_pl310.c | 36 ------------------------- sys/arm/include/pl310.h | 2 ++ sys/arm/ti/omap4/omap4_l2cache.c | 32 ---------------------- 4 files changed, 45 insertions(+), 68 deletions(-) diff --git a/sys/arm/arm/pl310.c b/sys/arm/arm/pl310.c index 64e98b6373b..b087365b583 100644 --- a/sys/arm/arm/pl310.c +++ b/sys/arm/arm/pl310.c @@ -84,6 +84,47 @@ static uint32_t g_ways_assoc; static struct pl310_softc *pl310_softc; +void +pl310_print_config(struct pl310_softc *sc) +{ + uint32_t aux, prefetch; + const char *dis = "disabled"; + const char *ena = "enabled"; + + aux = pl310_read4(sc, PL310_AUX_CTRL); + prefetch = pl310_read4(sc, PL310_PREFETCH_CTRL); + + device_printf(sc->sc_dev, "Early BRESP response: %s\n", + (aux & AUX_CTRL_EARLY_BRESP) ? ena : dis); + device_printf(sc->sc_dev, "Instruction prefetch: %s\n", + (aux & AUX_CTRL_INSTR_PREFETCH) ? ena : dis); + device_printf(sc->sc_dev, "Data prefetch: %s\n", + (aux & AUX_CTRL_DATA_PREFETCH) ? ena : dis); + device_printf(sc->sc_dev, "Non-secure interrupt control: %s\n", + (aux & AUX_CTRL_NS_INT_CTRL) ? ena : dis); + device_printf(sc->sc_dev, "Non-secure lockdown: %s\n", + (aux & AUX_CTRL_NS_LOCKDOWN) ? ena : dis); + device_printf(sc->sc_dev, "Share override: %s\n", + (aux & AUX_CTRL_SHARE_OVERRIDE) ? ena : dis); + + device_printf(sc->sc_dev, "Double linefill: %s\n", + (prefetch & PREFETCH_CTRL_DL) ? ena : dis); + device_printf(sc->sc_dev, "Instruction prefetch: %s\n", + (prefetch & PREFETCH_CTRL_INSTR_PREFETCH) ? ena : dis); + device_printf(sc->sc_dev, "Data prefetch: %s\n", + (prefetch & PREFETCH_CTRL_DATA_PREFETCH) ? ena : dis); + device_printf(sc->sc_dev, "Double linefill on WRAP request: %s\n", + (prefetch & PREFETCH_CTRL_DL_ON_WRAP) ? ena : dis); + device_printf(sc->sc_dev, "Prefetch drop: %s\n", + (prefetch & PREFETCH_CTRL_PREFETCH_DROP) ? ena : dis); + device_printf(sc->sc_dev, "Incr double Linefill: %s\n", + (prefetch & PREFETCH_CTRL_INCR_DL) ? ena : dis); + device_printf(sc->sc_dev, "Not same ID on exclusive sequence: %s\n", + (prefetch & PREFETCH_CTRL_NOTSAMEID) ? ena : dis); + device_printf(sc->sc_dev, "Prefetch offset: %d\n", + (prefetch & PREFETCH_CTRL_OFFSET_MASK)); +} + static int pl310_filter(void *arg) { @@ -351,6 +392,8 @@ pl310_attach(device_t dev) /* Enable the L2 cache if disabled */ platform_pl310_write_ctrl(sc, CTRL_ENABLED); device_printf(dev, "L2 Cache enabled\n"); + if (bootverbose) + pl310_print_config(sc); } if (!sc->sc_enabled && (ctrl_value & CTRL_ENABLED)) { diff --git a/sys/arm/freescale/imx/imx6_pl310.c b/sys/arm/freescale/imx/imx6_pl310.c index f2d1c274f74..a4e383ea1bd 100644 --- a/sys/arm/freescale/imx/imx6_pl310.c +++ b/sys/arm/freescale/imx/imx6_pl310.c @@ -44,42 +44,6 @@ __FBSDID("$FreeBSD$"); void platform_pl310_init(struct pl310_softc *sc) { - uint32_t aux, prefetch; - - aux = pl310_read4(sc, PL310_AUX_CTRL); - prefetch = pl310_read4(sc, PL310_PREFETCH_CTRL); - - if (bootverbose) { - device_printf(sc->sc_dev, "Early BRESP response: %s\n", - (aux & AUX_CTRL_EARLY_BRESP) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Instruction prefetch: %s\n", - (aux & AUX_CTRL_INSTR_PREFETCH) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Data prefetch: %s\n", - (aux & AUX_CTRL_DATA_PREFETCH) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Non-secure interrupt control: %s\n", - (aux & AUX_CTRL_NS_INT_CTRL) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Non-secure lockdown: %s\n", - (aux & AUX_CTRL_NS_LOCKDOWN) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Share override: %s\n", - (aux & AUX_CTRL_SHARE_OVERRIDE) ? "enabled" : "disabled"); - - device_printf(sc->sc_dev, "Double linefil: %s\n", - (prefetch & PREFETCH_CTRL_DL) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Instruction prefetch: %s\n", - (prefetch & PREFETCH_CTRL_INSTR_PREFETCH) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Data prefetch: %s\n", - (prefetch & PREFETCH_CTRL_DATA_PREFETCH) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Double linefill on WRAP request: %s\n", - (prefetch & PREFETCH_CTRL_DL_ON_WRAP) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Prefetch drop: %s\n", - (prefetch & PREFETCH_CTRL_PREFETCH_DROP) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Incr double Linefill: %s\n", - (prefetch & PREFETCH_CTRL_INCR_DL) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Not same ID on exclusive sequence: %s\n", - (prefetch & PREFETCH_CTRL_NOTSAMEID) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Prefetch offset: %d\n", - (prefetch & PREFETCH_CTRL_OFFSET_MASK)); - } } void diff --git a/sys/arm/include/pl310.h b/sys/arm/include/pl310.h index a3c42d8ab7d..b4200a8dada 100644 --- a/sys/arm/include/pl310.h +++ b/sys/arm/include/pl310.h @@ -161,6 +161,8 @@ pl310_write4(struct pl310_softc *sc, bus_size_t off, uint32_t val) bus_write_4(sc->sc_mem_res, off, val); } +void pl310_print_config(struct pl310_softc *sc); + void platform_pl310_init(struct pl310_softc *); void platform_pl310_write_ctrl(struct pl310_softc *, uint32_t); void platform_pl310_write_debug(struct pl310_softc *, uint32_t); diff --git a/sys/arm/ti/omap4/omap4_l2cache.c b/sys/arm/ti/omap4/omap4_l2cache.c index 67678bf44e2..8fddc6f7198 100644 --- a/sys/arm/ti/omap4/omap4_l2cache.c +++ b/sys/arm/ti/omap4/omap4_l2cache.c @@ -45,38 +45,6 @@ platform_pl310_init(struct pl310_softc *sc) aux = pl310_read4(sc, PL310_AUX_CTRL); prefetch = pl310_read4(sc, PL310_PREFETCH_CTRL); - if (bootverbose) { - device_printf(sc->sc_dev, "Early BRESP response: %s\n", - (aux & AUX_CTRL_EARLY_BRESP) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Instruction prefetch: %s\n", - (aux & AUX_CTRL_INSTR_PREFETCH) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Data prefetch: %s\n", - (aux & AUX_CTRL_DATA_PREFETCH) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Non-secure interrupt control: %s\n", - (aux & AUX_CTRL_NS_INT_CTRL) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Non-secure lockdown: %s\n", - (aux & AUX_CTRL_NS_LOCKDOWN) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Share override: %s\n", - (aux & AUX_CTRL_SHARE_OVERRIDE) ? "enabled" : "disabled"); - - device_printf(sc->sc_dev, "Double linefil: %s\n", - (prefetch & PREFETCH_CTRL_DL) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Instruction prefetch: %s\n", - (prefetch & PREFETCH_CTRL_INSTR_PREFETCH) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Data prefetch: %s\n", - (prefetch & PREFETCH_CTRL_DATA_PREFETCH) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Double linefill on WRAP request: %s\n", - (prefetch & PREFETCH_CTRL_DL_ON_WRAP) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Prefetch drop: %s\n", - (prefetch & PREFETCH_CTRL_PREFETCH_DROP) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Incr double Linefill: %s\n", - (prefetch & PREFETCH_CTRL_INCR_DL) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Not same ID on exclusive sequence: %s\n", - (prefetch & PREFETCH_CTRL_NOTSAMEID) ? "enabled" : "disabled"); - device_printf(sc->sc_dev, "Prefetch offset: %d\n", - (prefetch & PREFETCH_CTRL_OFFSET_MASK)); - } - /* * Disable instruction prefetch */ From 440fe55df64454a21ddd5bf15a76eab0f755764b Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Mon, 28 Apr 2014 02:35:28 +0000 Subject: [PATCH 65/67] Don't use multiprocessing-extensions instruction on processors that don't support SMP. Submitted by: loos@ Pointy hat to: me --- sys/arm/arm/cpufunc_asm_armv7.S | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/arm/arm/cpufunc_asm_armv7.S b/sys/arm/arm/cpufunc_asm_armv7.S index 507c5323d71..45f4593cff5 100644 --- a/sys/arm/arm/cpufunc_asm_armv7.S +++ b/sys/arm/arm/cpufunc_asm_armv7.S @@ -251,7 +251,11 @@ ENTRY(armv7_idcache_wbinv_range) END(armv7_idcache_wbinv_range) ENTRY_NP(armv7_icache_sync_all) +#ifdef SMP mcr p15, 0, r0, c7, c1, 0 /* Invalidate all I cache to PoU Inner Shareable */ +#else + mcr p15, 0, r0, c7, c5, 0 /* Invalidate all I cache to PoU (ICIALLU) */ +#endif isb /* instruction synchronization barrier */ dsb /* data synchronization barrier */ RET From 5372fec0bc6a6dd8b41ebbcfa77f9ab6b5db9bb5 Mon Sep 17 00:00:00 2001 From: Ganbold Tsagaankhuu Date: Mon, 28 Apr 2014 05:39:20 +0000 Subject: [PATCH 66/67] Move common device tree informations to separate dtsi files for A10 and A20 SoC. Change cubieboard1 and cubieboard2 dts files accordingly. Approved by: stas (mentor) --- sys/boot/fdt/dts/arm/cubieboard.dts | 88 +---------------- sys/boot/fdt/dts/arm/cubieboard2.dts | 94 +----------------- sys/boot/fdt/dts/arm/sun4i-a10.dtsi | 133 +++++++++++++++++++++++++ sys/boot/fdt/dts/arm/sun7i-a20.dtsi | 139 +++++++++++++++++++++++++++ 4 files changed, 282 insertions(+), 172 deletions(-) create mode 100644 sys/boot/fdt/dts/arm/sun4i-a10.dtsi create mode 100644 sys/boot/fdt/dts/arm/sun7i-a20.dtsi diff --git a/sys/boot/fdt/dts/arm/cubieboard.dts b/sys/boot/fdt/dts/arm/cubieboard.dts index 62e6af280fd..636b5cec641 100644 --- a/sys/boot/fdt/dts/arm/cubieboard.dts +++ b/sys/boot/fdt/dts/arm/cubieboard.dts @@ -28,13 +28,10 @@ /dts-v1/; +/include/ "sun4i-a10.dtsi" + / { model = "Cubietech Cubieboard"; - compatible = "cubietech,a10-cubieboard", "allwinner,sun4i-a10"; - #address-cells = <1>; - #size-cells = <1>; - - interrupt-parent = <&AINTC>; memory { device_type = "memory"; @@ -47,96 +44,21 @@ }; SOC: a10 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "simple-bus"; - ranges; - bus-frequency = <0>; - - AINTC: interrupt-controller@01c20400 { - compatible = "allwinner,sun4i-ic"; - interrupt-controller; - #address-cells = <0>; - #interrupt-cells = <1>; - reg = < 0x01c20400 0x400 >; - }; - - sramc@01c00000 { - compatible = "allwinner,sun4i-sramc"; - #address-cells = <1>; - #size-cells = <1>; - reg = < 0x01c00000 0x1000 >; - }; - - ccm@01c20000 { - compatible = "allwinner,sun4i-ccm"; - #address-cells = <1>; - #size-cells = <1>; - reg = < 0x01c20000 0x400 >; - }; - - timer@01c20c00 { - compatible = "allwinner,sun4i-timer"; - reg = <0x01c20c00 0x90>; - interrupts = < 22 >; - interrupt-parent = <&AINTC>; - clock-frequency = < 24000000 >; - }; - - watchdog@01c20c90 { - compatible = "allwinner,sun4i-wdt"; - reg = <0x01c20c90 0x08>; - }; - - - GPIO: gpio@01c20800 { - #gpio-cells = <3>; - compatible = "allwinner,sun4i-gpio"; - gpio-controller; - reg =< 0x01c20800 0x400 >; - interrupts = < 28 >; - interrupt-parent = <&AINTC>; - }; usb1: usb@01c14000 { - compatible = "allwinner,usb-ehci", "usb-ehci"; - reg = <0x01c14000 0x1000>; - interrupts = < 39 >; - interrupt-parent = <&AINTC>; + status = "okay"; }; usb2: usb@01c1c000 { - compatible = "allwinner,usb-ehci", "usb-ehci"; - reg = <0x01c1c000 0x1000>; - interrupts = < 40 >; - interrupt-parent = <&AINTC>; - }; - - sata@01c18000 { - compatible = "allwinner,ahci"; - reg = <0x01c18000 0x1000>; - interrupts = <56>; - interrupt-parent = <&AINTC>; + status = "okay"; }; UART0: serial@01c28000 { status = "okay"; - compatible = "ns16550"; - reg = <0x01c28000 0x400>; - reg-shift = <2>; - interrupts = <1>; - interrupt-parent = <&AINTC>; - current-speed = <115200>; - clock-frequency = < 24000000 >; - busy-detect = <1>; - broken-txfifo = <1>; }; emac@01c0b000 { - compatible = "allwinner,sun4i-emac"; - reg = <0x01c0b000 0x1000>; - interrupts = <55>; - interrupt-parent = <&AINTC>; + status = "okay"; }; }; diff --git a/sys/boot/fdt/dts/arm/cubieboard2.dts b/sys/boot/fdt/dts/arm/cubieboard2.dts index 38440711a40..08d0245e875 100644 --- a/sys/boot/fdt/dts/arm/cubieboard2.dts +++ b/sys/boot/fdt/dts/arm/cubieboard2.dts @@ -28,13 +28,10 @@ /dts-v1/; +/include/ "sun7i-a20.dtsi" + / { model = "Cubietech Cubieboard2"; - compatible = "cubietech,a20-cubieboard", "allwinner,sun7i-a20"; - #address-cells = <1>; - #size-cells = <1>; - - interrupt-parent = <&GIC>; memory { device_type = "memory"; @@ -47,102 +44,21 @@ }; SOC: a20 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "simple-bus"; - ranges; - bus-frequency = <0>; - - GIC: interrupt-controller@01c81000 { - compatible = "arm,gic"; - reg = <0x01c81000 0x1000>, /* Distributor Registers */ - <0x01c82000 0x0100>; /* CPU Interface Registers */ - interrupt-controller; - #interrupt-cells = <1>; - }; - - sramc@01c00000 { - compatible = "allwinner,sun4i-sramc"; - #address-cells = <1>; - #size-cells = <1>; - reg = < 0x01c00000 0x1000 >; - }; - - cpu-cfg@01c25c00 { - compatible = "allwinner,sun7i-cpu-cfg"; - #address-cells = <1>; - #size-cells = <1>; - reg = < 0x01c25c00 0x400 >; - }; - - ccm@01c20000 { - compatible = "allwinner,sun4i-ccm"; - #address-cells = <1>; - #size-cells = <1>; - reg = < 0x01c20000 0x400 >; - }; - - timer@01c20c00 { - compatible = "allwinner,sun7i-timer"; - reg = <0x01c20c00 0x90>; - interrupts = < 22 >; - interrupt-parent = <&GIC>; - clock-frequency = < 24000000 >; - }; - - watchdog@01c20c90 { - compatible = "allwinner,sun4i-wdt"; - reg = <0x01c20c90 0x10>; - }; - - GPIO: gpio@01c20800 { - #gpio-cells = <3>; - compatible = "allwinner,sun4i-gpio"; - gpio-controller; - reg =< 0x01c20800 0x400 >; - interrupts = < 28 >; - interrupt-parent = <&GIC>; - }; usb1: usb@01c14000 { - compatible = "allwinner,usb-ehci", "usb-ehci"; - reg = <0x01c14000 0x1000>; - interrupts = < 39 >; - interrupt-parent = <&GIC>; + status = "okay"; }; usb2: usb@01c1c000 { - compatible = "allwinner,usb-ehci", "usb-ehci"; - reg = <0x01c1c000 0x1000>; - interrupts = < 40 >; - interrupt-parent = <&GIC>; - }; - - sata@01c18000 { - compatible = "allwinner,ahci"; - reg = <0x01c18000 0x1000>; - interrupts = <56>; - interrupt-parent = <&GIC>; + status = "okay"; }; UART0: serial@01c28000 { status = "okay"; - compatible = "ns16550"; - reg = <0x01c28000 0x400>; - reg-shift = <2>; - interrupts = <1>; - interrupt-parent = <&GIC>; - current-speed = <115200>; - clock-frequency = < 24000000 >; - busy-detect = <1>; - broken-txfifo = <1>; }; emac@01c0b000 { - compatible = "allwinner,sun4i-emac"; - reg = <0x01c0b000 0x1000>; - interrupts = <55>; - interrupt-parent = <&GIC>; + status = "okay"; }; }; diff --git a/sys/boot/fdt/dts/arm/sun4i-a10.dtsi b/sys/boot/fdt/dts/arm/sun4i-a10.dtsi new file mode 100644 index 00000000000..7ee968adba2 --- /dev/null +++ b/sys/boot/fdt/dts/arm/sun4i-a10.dtsi @@ -0,0 +1,133 @@ +/*- + * Copyright (c) 2014 Ganbold Tsagaankhuu + * 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$ + */ + +/ { + compatible = "allwinner,sun4i-a10"; + #address-cells = <1>; + #size-cells = <1>; + + interrupt-parent = <&AINTC>; + + aliases { + soc = &SOC; + }; + + SOC: a10 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + ranges; + bus-frequency = <0>; + + AINTC: interrupt-controller@01c20400 { + compatible = "allwinner,sun4i-ic"; + interrupt-controller; + #address-cells = <0>; + #interrupt-cells = <1>; + reg = < 0x01c20400 0x400 >; + }; + + sramc@01c00000 { + compatible = "allwinner,sun4i-sramc"; + #address-cells = <1>; + #size-cells = <1>; + reg = < 0x01c00000 0x1000 >; + }; + + ccm@01c20000 { + compatible = "allwinner,sun4i-ccm"; + #address-cells = <1>; + #size-cells = <1>; + reg = < 0x01c20000 0x400 >; + }; + + timer@01c20c00 { + compatible = "allwinner,sun4i-timer"; + reg = <0x01c20c00 0x90>; + interrupts = < 22 >; + interrupt-parent = <&AINTC>; + clock-frequency = < 24000000 >; + }; + + watchdog@01c20c90 { + compatible = "allwinner,sun4i-wdt"; + reg = <0x01c20c90 0x08>; + }; + + + GPIO: gpio@01c20800 { + #gpio-cells = <3>; + compatible = "allwinner,sun4i-gpio"; + gpio-controller; + reg =< 0x01c20800 0x400 >; + interrupts = < 28 >; + interrupt-parent = <&AINTC>; + }; + + usb1: usb@01c14000 { + compatible = "allwinner,usb-ehci", "usb-ehci"; + reg = <0x01c14000 0x1000>; + interrupts = < 39 >; + interrupt-parent = <&AINTC>; + }; + + usb2: usb@01c1c000 { + compatible = "allwinner,usb-ehci", "usb-ehci"; + reg = <0x01c1c000 0x1000>; + interrupts = < 40 >; + interrupt-parent = <&AINTC>; + }; + + sata@01c18000 { + compatible = "allwinner,ahci"; + reg = <0x01c18000 0x1000>; + interrupts = <56>; + interrupt-parent = <&AINTC>; + }; + + UART0: serial@01c28000 { + compatible = "ns16550"; + reg = <0x01c28000 0x400>; + reg-shift = <2>; + interrupts = <1>; + interrupt-parent = <&AINTC>; + current-speed = <115200>; + clock-frequency = < 24000000 >; + busy-detect = <1>; + broken-txfifo = <1>; + }; + + emac@01c0b000 { + compatible = "allwinner,sun4i-emac"; + reg = <0x01c0b000 0x1000>; + interrupts = <55>; + interrupt-parent = <&AINTC>; + }; + }; +}; + diff --git a/sys/boot/fdt/dts/arm/sun7i-a20.dtsi b/sys/boot/fdt/dts/arm/sun7i-a20.dtsi new file mode 100644 index 00000000000..3bbc59f5b4b --- /dev/null +++ b/sys/boot/fdt/dts/arm/sun7i-a20.dtsi @@ -0,0 +1,139 @@ +/*- + * Copyright (c) 2014 Ganbold Tsagaankhuu + * 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$ + */ + +/ { + compatible = "allwinner,sun7i-a20"; + #address-cells = <1>; + #size-cells = <1>; + + interrupt-parent = <&GIC>; + + aliases { + soc = &SOC; + }; + + SOC: a20 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + ranges; + bus-frequency = <0>; + + GIC: interrupt-controller@01c81000 { + compatible = "arm,gic"; + reg = <0x01c81000 0x1000>, /* Distributor Registers */ + <0x01c82000 0x0100>; /* CPU Interface Registers */ + interrupt-controller; + #interrupt-cells = <1>; + }; + + sramc@01c00000 { + compatible = "allwinner,sun4i-sramc"; + #address-cells = <1>; + #size-cells = <1>; + reg = < 0x01c00000 0x1000 >; + }; + + cpu-cfg@01c25c00 { + compatible = "allwinner,sun7i-cpu-cfg"; + #address-cells = <1>; + #size-cells = <1>; + reg = < 0x01c25c00 0x400 >; + }; + + ccm@01c20000 { + compatible = "allwinner,sun4i-ccm"; + #address-cells = <1>; + #size-cells = <1>; + reg = < 0x01c20000 0x400 >; + }; + + timer@01c20c00 { + compatible = "allwinner,sun7i-timer"; + reg = <0x01c20c00 0x90>; + interrupts = < 22 >; + interrupt-parent = <&GIC>; + clock-frequency = < 24000000 >; + }; + + watchdog@01c20c90 { + compatible = "allwinner,sun4i-wdt"; + reg = <0x01c20c90 0x10>; + }; + + GPIO: gpio@01c20800 { + #gpio-cells = <3>; + compatible = "allwinner,sun4i-gpio"; + gpio-controller; + reg =< 0x01c20800 0x400 >; + interrupts = < 28 >; + interrupt-parent = <&GIC>; + }; + + usb1: usb@01c14000 { + compatible = "allwinner,usb-ehci", "usb-ehci"; + reg = <0x01c14000 0x1000>; + interrupts = < 39 >; + interrupt-parent = <&GIC>; + }; + + usb2: usb@01c1c000 { + compatible = "allwinner,usb-ehci", "usb-ehci"; + reg = <0x01c1c000 0x1000>; + interrupts = < 40 >; + interrupt-parent = <&GIC>; + }; + + sata@01c18000 { + compatible = "allwinner,ahci"; + reg = <0x01c18000 0x1000>; + interrupts = <56>; + interrupt-parent = <&GIC>; + }; + + UART0: serial@01c28000 { + compatible = "ns16550"; + reg = <0x01c28000 0x400>; + reg-shift = <2>; + interrupts = <1>; + interrupt-parent = <&GIC>; + current-speed = <115200>; + clock-frequency = < 24000000 >; + busy-detect = <1>; + broken-txfifo = <1>; + }; + + emac@01c0b000 { + compatible = "allwinner,sun4i-emac"; + reg = <0x01c0b000 0x1000>; + interrupts = <55>; + interrupt-parent = <&GIC>; + }; + }; +}; + From b2ba55951383498f252746f618d513139da06e8e Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Mon, 28 Apr 2014 06:24:37 +0000 Subject: [PATCH 67/67] bsd-family-tree: Fix date --- share/misc/bsd-family-tree | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/misc/bsd-family-tree b/share/misc/bsd-family-tree index 61beac12bf9..a1d3d12bfa9 100644 --- a/share/misc/bsd-family-tree +++ b/share/misc/bsd-family-tree @@ -635,7 +635,7 @@ FreeBSD 10.0 2014-01-20 [FBD] NetBSD 6.0.4 2014-01-27 [NBD] NetBSD 6.1.3 2014-01-27 [NBD] DragonFly 3.6.1 2014-02-22 [DFB] -DragonFly 3.6.2 2014-03-27 [DFB] +DragonFly 3.6.2 2014-04-10 [DFB] NetBSD 6.0.5 2014-04-19 [NDB] NetBSD 6.1.4 2014-04-19 [NDB]