From 4b58ef1a3ff9c3b82934962811f08ae233842ce0 Mon Sep 17 00:00:00 2001 From: jilles Date: Thu, 5 Sep 2013 19:02:03 +0000 Subject: watch: Do not mess up the tty modes on early error. Record the initial state earlier, so it is always safe to restore it. One way this happens is if watch(8) is started by a user that does not have access to /dev/snp. The result is "staircase effect" during later commands. PR: bin/153052 MFC after: 1 week --- usr.sbin/watch/watch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'usr.sbin') diff --git a/usr.sbin/watch/watch.c b/usr.sbin/watch/watch.c index e69534d..eecf0d3 100644 --- a/usr.sbin/watch/watch.c +++ b/usr.sbin/watch/watch.c @@ -110,7 +110,6 @@ set_tty(void) { struct termios ntty; - tcgetattr(std_in, &otty); ntty = otty; ntty.c_lflag &= ~ICANON; /* disable canonical operation */ ntty.c_lflag &= ~ECHO; @@ -324,6 +323,8 @@ main(int ac, char *av[]) usage(); } + tcgetattr(std_in, &otty); + if (modfind("snp") == -1) if (kldload("snp") == -1 || modfind("snp") == -1) warn("snp module not available"); -- cgit v1.1 From b669765ba2f25c8728a64074b58066017eff9e5f Mon Sep 17 00:00:00 2001 From: grehan Date: Fri, 6 Sep 2013 05:55:43 +0000 Subject: Allow level-triggered interrupt sources. While this isn't precisely emulated, it is good enough for the single consumer i.e. irq4, the serial port on Linux. --- usr.sbin/bhyve/ioapic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/bhyve/ioapic.c b/usr.sbin/bhyve/ioapic.c index c712692..114b446 100644 --- a/usr.sbin/bhyve/ioapic.c +++ b/usr.sbin/bhyve/ioapic.c @@ -101,13 +101,13 @@ ioapic_set_pinstate(struct vmctx *ctx, int pin, bool newstate) * XXX * We only deal with: * - edge triggered interrupts - * - physical destination mode * - fixed delivery mode + * Level-triggered sources will work so long as their is + * no sharing. */ low = ioapic->redtbl[pin]; high = ioapic->redtbl[pin] >> 32; if ((low & IOART_INTMASK) == IOART_INTMCLR && - (low & IOART_TRGRMOD) == IOART_TRGREDG && (low & IOART_DESTMOD) == IOART_DESTPHY && (low & IOART_DELMOD) == IOART_DELFIXED) { vector = low & IOART_INTVEC; -- cgit v1.1 From 32d186cf8328b76c8cce47d562b097a7e0a7f80a Mon Sep 17 00:00:00 2001 From: grehan Date: Fri, 6 Sep 2013 05:58:10 +0000 Subject: Fix spelling. --- usr.sbin/bhyve/ioapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr.sbin') diff --git a/usr.sbin/bhyve/ioapic.c b/usr.sbin/bhyve/ioapic.c index 114b446..aeb008e 100644 --- a/usr.sbin/bhyve/ioapic.c +++ b/usr.sbin/bhyve/ioapic.c @@ -102,7 +102,7 @@ ioapic_set_pinstate(struct vmctx *ctx, int pin, bool newstate) * We only deal with: * - edge triggered interrupts * - fixed delivery mode - * Level-triggered sources will work so long as their is + * Level-triggered sources will work so long as there is * no sharing. */ low = ioapic->redtbl[pin]; -- cgit v1.1 From ef37ef83350cbc5080740b4ed9597ea59d058a59 Mon Sep 17 00:00:00 2001 From: dteske Date: Sat, 7 Sep 2013 03:24:22 +0000 Subject: Long URLs don't always appear even with autosizing and other tricks. So, add some whitespace to put the URL on a line by itself, maximizing view. --- usr.sbin/bsdconfig/examples/browse_packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr.sbin') diff --git a/usr.sbin/bsdconfig/examples/browse_packages.sh b/usr.sbin/bsdconfig/examples/browse_packages.sh index 6396f46..18ab93b 100755 --- a/usr.sbin/bsdconfig/examples/browse_packages.sh +++ b/usr.sbin/bsdconfig/examples/browse_packages.sh @@ -17,7 +17,7 @@ if [ ! -e "$TMPDIR/packages/INDEX" ]; then # For older releases, use ftp://ftp-archive.freebsd.org mediaSetFTP mediaOpen - f_show_info "Downloading packages/INDEX from %s" "$_ftpPath" + f_show_info "Downloading packages/INDEX from\n %s" "$_ftpPath" f_device_get media packages/INDEX > $TMPDIR/packages/INDEX mediaClose fi -- cgit v1.1 From 3b61a48b9f5477a16200438661adf4f782eec118 Mon Sep 17 00:00:00 2001 From: dteske Date: Sat, 7 Sep 2013 03:27:13 +0000 Subject: Remove unnecessary mediaClose (FTP operations are done with either ftp(1) or fetch(1), neither of which are stateful, compared to how sysinstall(8) did FTP operations, maintaining an open session until mediaClose). --- usr.sbin/bsdconfig/examples/browse_packages.sh | 1 - 1 file changed, 1 deletion(-) (limited to 'usr.sbin') diff --git a/usr.sbin/bsdconfig/examples/browse_packages.sh b/usr.sbin/bsdconfig/examples/browse_packages.sh index 18ab93b..1deb562 100755 --- a/usr.sbin/bsdconfig/examples/browse_packages.sh +++ b/usr.sbin/bsdconfig/examples/browse_packages.sh @@ -19,7 +19,6 @@ if [ ! -e "$TMPDIR/packages/INDEX" ]; then mediaOpen f_show_info "Downloading packages/INDEX from\n %s" "$_ftpPath" f_device_get media packages/INDEX > $TMPDIR/packages/INDEX - mediaClose fi _directoryPath=$TMPDIR mediaSetDirectory -- cgit v1.1 From 7fcc90cb2ebf17571bd2f20b94ebb81692848d3b Mon Sep 17 00:00:00 2001 From: des Date: Sat, 7 Sep 2013 20:25:22 +0000 Subject: Tweak wording. --- usr.sbin/setfib/setfib.1 | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/setfib/setfib.1 b/usr.sbin/setfib/setfib.1 index f0143db..5c36748 100644 --- a/usr.sbin/setfib/setfib.1 +++ b/usr.sbin/setfib/setfib.1 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 9, 2008 +.Dd October 20, 2008 .Dt SETFIB 1 .Os .Sh NAME @@ -39,11 +39,11 @@ .Sh DESCRIPTION The .Nm -utility runs +utility runs another .Ar utility -with an different routing table. +with a different routing table. The table number -.Dq Ar fib +.Ar fib will be used by default for all sockets started by this process or descendants. .Sh ENVIRONMENT @@ -69,8 +69,8 @@ An exit status of 127 indicates .Ar utility could not be found. .Sh EXAMPLES -Execute utility -.Sq netstat +Run +.Xr netstat 1 to view the second routing table. .Pp .Dl "setfib -F 1 netstat -rn" @@ -86,8 +86,9 @@ The .Nm utility is a .Fx -specific extension, however many -.Ux +specific extension. +However, many +.Ux Ns - Ns like systems have an equivalent function. .Sh HISTORY -- cgit v1.1 From 504259487c661af075cec8eecf4c7b1362182f0f Mon Sep 17 00:00:00 2001 From: delphij Date: Mon, 9 Sep 2013 20:36:28 +0000 Subject: Pass -n (do not emit comments) when saving mtree information for future mergemaster(8) runs. MFC after: 3 days Approved by: re (kib) --- usr.sbin/mergemaster/mergemaster.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr.sbin') diff --git a/usr.sbin/mergemaster/mergemaster.sh b/usr.sbin/mergemaster/mergemaster.sh index 629d44f..361cef9 100755 --- a/usr.sbin/mergemaster/mergemaster.sh +++ b/usr.sbin/mergemaster/mergemaster.sh @@ -707,7 +707,7 @@ case "${RERUN}" in # Build the mtree database in a temporary location. case "${PRE_WORLD}" in '') MTREENEW=`mktemp -t mergemaster.mtree` - mtree -ci -p ${TEMPROOT} -k size,md5digest > ${MTREENEW} 2>/dev/null + mtree -nci -p ${TEMPROOT} -k size,md5digest > ${MTREENEW} 2>/dev/null ;; *) # We don't want to mess with the mtree database on a pre-world run or # when re-scanning a previously-built tree. -- cgit v1.1 From 3d2b366a366c56edb8a86a84ee95f0de06fa61a4 Mon Sep 17 00:00:00 2001 From: grehan Date: Tue, 10 Sep 2013 03:48:18 +0000 Subject: Go way past 11 and bump bhyve's max vCPUs to 16. This should be sufficient for 10.0 and will do until forthcoming work to avoid limitations in this area is complete. Thanks to Bela Lubkin at tidalscale for the headsup on the apic/cpu id/io apic ASL parameters that are actually hex values and broke when written as decimal when 11 vCPUs were configured. Approved by: re@ --- usr.sbin/bhyve/acpi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index ed0c545..89c11bc 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -241,8 +241,9 @@ basl_fwrite_madt(FILE *fp) for (i = 0; i < basl_ncpu; i++) { EFPRINTF(fp, "[0001]\t\tSubtable Type : 00\n"); EFPRINTF(fp, "[0001]\t\tLength : 08\n"); - EFPRINTF(fp, "[0001]\t\tProcessor ID : %02d\n", i); - EFPRINTF(fp, "[0001]\t\tLocal Apic ID : %02d\n", i); + /* iasl expects hex values for the proc and apic id's */ + EFPRINTF(fp, "[0001]\t\tProcessor ID : %02x\n", i); + EFPRINTF(fp, "[0001]\t\tLocal Apic ID : %02x\n", i); EFPRINTF(fp, "[0004]\t\tFlags (decoded below) : 00000001\n"); EFPRINTF(fp, "\t\t\tProcessor Enabled : 1\n"); EFPRINTF(fp, "\n"); @@ -251,7 +252,8 @@ basl_fwrite_madt(FILE *fp) /* Always a single IOAPIC entry, with ID ncpu+1 */ EFPRINTF(fp, "[0001]\t\tSubtable Type : 01\n"); EFPRINTF(fp, "[0001]\t\tLength : 0C\n"); - EFPRINTF(fp, "[0001]\t\tI/O Apic ID : %02d\n", basl_ncpu); + /* iasl expects a hex value for the i/o apic id */ + EFPRINTF(fp, "[0001]\t\tI/O Apic ID : %02x\n", basl_ncpu); EFPRINTF(fp, "[0001]\t\tReserved : 00\n"); EFPRINTF(fp, "[0004]\t\tAddress : fec00000\n"); EFPRINTF(fp, "[0004]\t\tInterrupt : 00000000\n"); -- cgit v1.1 From aed5107b91d2313d9ef22d9b56c3f6ee77d384b3 Mon Sep 17 00:00:00 2001 From: bapt Date: Tue, 10 Sep 2013 20:56:01 +0000 Subject: Add support to detect arm vs armv6 There are two different versions of the ARM ABI depending on the TARGET_ARCH. As these are sligntly different a package built for one may not work on another. We need to detect which one we are on by parsing the .ARM.attributes section. This will only work on the ARM EABI as this section is part of the ABI definition. As armv6 only supports the ARM EABI this is not a problem for the oabi. Older versions of libelf in FreeBSD fail to read the .ARM.attributes section needed. As armv6 is unsupported on these versions we can assume we are running on arm. Submitted by: andrew Approved by: re (delphij) Obtained from: pkgng git --- usr.sbin/pkg/config.c | 214 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 202 insertions(+), 12 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/pkg/config.c b/usr.sbin/pkg/config.c index 142fd1b..01eaa9f 100644 --- a/usr.sbin/pkg/config.c +++ b/usr.sbin/pkg/config.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -100,6 +101,138 @@ elf_corres_to_string(struct _elf_corres *m, int e) return ("unknown"); } +static const char * +aeabi_parse_arm_attributes(void *data, size_t length) +{ + uint32_t sect_len; + uint8_t *section = data; + +#define MOVE(len) do { \ + assert(length >= (len)); \ + section += (len); \ + length -= (len); \ +} while (0) + + if (length == 0 || *section != 'A') + return (NULL); + + MOVE(1); + + /* Read the section length */ + if (length < sizeof(sect_len)) + return (NULL); + + memcpy(§_len, section, sizeof(sect_len)); + + /* + * The section length should be no longer than the section it is within + */ + if (sect_len > length) + return (NULL); + + MOVE(sizeof(sect_len)); + + /* Skip the vendor name */ + while (length != 0) { + if (*section == '\0') + break; + MOVE(1); + } + if (length == 0) + return (NULL); + MOVE(1); + + while (length != 0) { + uint32_t tag_length; + + switch(*section) { + case 1: /* Tag_File */ + MOVE(1); + if (length < sizeof(tag_length)) + return (NULL); + memcpy(&tag_length, section, sizeof(tag_length)); + break; + case 2: /* Tag_Section */ + case 3: /* Tag_Symbol */ + default: + return (NULL); + } + /* At least space for the tag and size */ + if (tag_length <= 5) + return (NULL); + tag_length--; + /* Check the tag fits */ + if (tag_length > length) + return (NULL); + +#define MOVE_TAG(len) do { \ + assert(tag_length >= (len)); \ + MOVE(len); \ + tag_length -= (len); \ +} while(0) + + MOVE(sizeof(tag_length)); + tag_length -= sizeof(tag_length); + + while (tag_length != 0) { + uint8_t tag; + + assert(tag_length >= length); + + tag = *section; + MOVE_TAG(1); + + /* + * These tag values come from: + * + * Addenda to, and Errata in, the ABI for the + * ARM Architecture. Release 2.08, section 2.3. + */ + if (tag == 6) { /* == Tag_CPU_arch */ + uint8_t val; + + val = *section; + /* + * We don't support values that require + * more than one byte. + */ + if (val & (1 << 7)) + return (NULL); + + /* We have an ARMv4 or ARMv5 */ + if (val <= 5) + return ("arm"); + else /* We have an ARMv6+ */ + return ("armv6"); + } else if (tag == 4 || tag == 5 || tag == 32 || + tag == 65 || tag == 67) { + while (*section != '\0' && length != 0) + MOVE_TAG(1); + if (tag_length == 0) + return (NULL); + /* Skip the last byte */ + MOVE_TAG(1); + } else if ((tag >= 7 && tag <= 31) || tag == 34 || + tag == 36 || tag == 38 || tag == 42 || tag == 44 || + tag == 64 || tag == 66 || tag == 68 || tag == 70) { + /* Skip the uleb128 data */ + while (*section & (1 << 7) && length != 0) + MOVE_TAG(1); + if (tag_length == 0) + return (NULL); + /* Skip the last byte */ + MOVE_TAG(1); + } else + return (NULL); +#undef MOVE_TAG + } + + break; + } + return (NULL); +#undef MOVE +} + static int pkg_get_myabi(char *dest, size_t sz) { @@ -108,7 +241,8 @@ pkg_get_myabi(char *dest, size_t sz) Elf_Note note; Elf_Scn *scn; char *src, *osname; - const char *abi, *fpu; + const char *arch, *abi, *fpu, *endian_corres_str; + const char *wordsize_corres_str; GElf_Ehdr elfhdr; GElf_Shdr shdr; int fd, i, ret; @@ -177,21 +311,72 @@ pkg_get_myabi(char *dest, size_t sz) for (i = 0; osname[i] != '\0'; i++) osname[i] = (char)tolower(osname[i]); - snprintf(dest, sz, "%s:%d:%s:%s", - osname, version / 100000, - elf_corres_to_string(mach_corres, (int)elfhdr.e_machine), - elf_corres_to_string(wordsize_corres, - (int)elfhdr.e_ident[EI_CLASS])); + wordsize_corres_str = elf_corres_to_string(wordsize_corres, + (int)elfhdr.e_ident[EI_CLASS]); + + arch = elf_corres_to_string(mach_corres, (int) elfhdr.e_machine); + + snprintf(dest, sz, "%s:%d", + osname, version / 100000); ret = 0; switch (elfhdr.e_machine) { case EM_ARM: + endian_corres_str = elf_corres_to_string(endian_corres, + (int)elfhdr.e_ident[EI_DATA]); + /* FreeBSD doesn't support the hard-float ABI yet */ fpu = "softfp"; if ((elfhdr.e_flags & 0xFF000000) != 0) { + const char *sh_name = NULL; + size_t shstrndx; + /* This is an EABI file, the conformance level is set */ abi = "eabi"; + /* Find which TARGET_ARCH we are building for. */ + elf_getshdrstrndx(elf, &shstrndx); + while ((scn = elf_nextscn(elf, scn)) != NULL) { + sh_name = NULL; + if (gelf_getshdr(scn, &shdr) != &shdr) { + scn = NULL; + break; + } + + sh_name = elf_strptr(elf, shstrndx, + shdr.sh_name); + if (sh_name == NULL) + continue; + if (strcmp(".ARM.attributes", sh_name) == 0) + break; + } + if (scn != NULL && sh_name != NULL) { + data = elf_getdata(scn, NULL); + /* + * Prior to FreeBSD 10.0 libelf would return + * NULL from elf_getdata on the .ARM.attributes + * section. As this was the first release to + * get armv6 support assume a NULL value means + * arm. + * + * This assumption can be removed when 9.x + * is unsupported. + */ + if (data != NULL) { + arch = aeabi_parse_arm_attributes( + data->d_buf, data->d_size); + if (arch == NULL) { + ret = 1; + warn("unknown ARM ARCH"); + goto cleanup; + } + } + } else { + ret = 1; + warn("Unable to find the .ARM.attributes " + "section"); + goto cleanup; + } } else if (elfhdr.e_ident[EI_OSABI] != ELFOSABI_NONE) { /* * EABI executables all have this field set to @@ -200,12 +385,12 @@ pkg_get_myabi(char *dest, size_t sz) abi = "oabi"; } else { ret = 1; + warn("unknown ARM ABI"); goto cleanup; } snprintf(dest + strlen(dest), sz - strlen(dest), - ":%s:%s:%s", elf_corres_to_string(endian_corres, - (int)elfhdr.e_ident[EI_DATA]), - abi, fpu); + ":%s:%s:%s:%s:%s", arch, wordsize_corres_str, + endian_corres_str, abi, fpu); break; case EM_MIPS: /* @@ -230,10 +415,15 @@ pkg_get_myabi(char *dest, size_t sz) abi = "n64"; break; } - snprintf(dest + strlen(dest), sz - strlen(dest), - ":%s:%s", elf_corres_to_string(endian_corres, - (int)elfhdr.e_ident[EI_DATA]), abi); + endian_corres_str = elf_corres_to_string(endian_corres, + (int)elfhdr.e_ident[EI_DATA]); + + snprintf(dest + strlen(dest), sz - strlen(dest), ":%s:%s:%s:%s", + arch, wordsize_corres_str, endian_corres_str, abi); break; + default: + snprintf(dest + strlen(dest), sz - strlen(dest), ":%s:%s", + arch, wordsize_corres_str); } cleanup: -- cgit v1.1 From fee688be702f335d54aac7b404d77a37a0852936 Mon Sep 17 00:00:00 2001 From: bapt Date: Wed, 11 Sep 2013 06:42:55 +0000 Subject: Cleanup elf macros Only define EF_MIPS_ABI when not already supplied Remove old now unused ARM macros Reported by: imp Approved by: re (kib) --- usr.sbin/pkg/elf_tables.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/pkg/elf_tables.h b/usr.sbin/pkg/elf_tables.h index d3d689a..0589ecf 100644 --- a/usr.sbin/pkg/elf_tables.h +++ b/usr.sbin/pkg/elf_tables.h @@ -58,16 +58,12 @@ static struct _elf_corres endian_corres[] = { { -1, NULL} }; -#define EF_MIPS_ABI 0x0000F000 +#ifndef EF_MIPS_ABI +#define EF_MIPS_ABI 0x0000f000 +#endif #define E_MIPS_ABI_O32 0x00001000 #define E_MIPS_ABI_N32 0x00000020 -#define EF_ARM_NEW_ABI 0x80 -#define EF_ARM_OLD_ABI 0x100 - -#define EF_ARM_SOFT_FLOAT 0x200 -#define EF_ARM_VFP_FLOAT 0x400 - #define NT_VERSION 1 #define NT_ARCH 2 -- cgit v1.1