Date: Thu, 20 Feb 2020 19:07:29 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r358179 - in projects/clang1000-import: . bin/sh lib/libc/stdlib lib/ncurses/ncurses libexec/rtld-elf/rtld-libc share/man/man4 stand/efi/libefi stand/efi/loader stand/i386/libi386 stand... Message-ID: <202002201907.01KJ7TXK022608@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Thu Feb 20 19:07:29 2020 New Revision: 358179 URL: https://svnweb.freebsd.org/changeset/base/358179 Log: Merge ^/head r358131 through r358178. Added: projects/clang1000-import/stand/libsa/smbios.c - copied unchanged from r358166, head/stand/libsa/smbios.c projects/clang1000-import/stand/libsa/smbios.h - copied unchanged from r358166, head/stand/libsa/smbios.h Deleted: projects/clang1000-import/stand/i386/libi386/smbios.c projects/clang1000-import/stand/i386/libi386/smbios.h Modified: projects/clang1000-import/ObsoleteFiles.inc projects/clang1000-import/UPDATING projects/clang1000-import/bin/sh/miscbltin.c projects/clang1000-import/lib/libc/stdlib/realpath.c projects/clang1000-import/lib/ncurses/ncurses/Makefile projects/clang1000-import/libexec/rtld-elf/rtld-libc/Makefile.inc projects/clang1000-import/share/man/man4/Makefile projects/clang1000-import/stand/efi/libefi/efi_driver_utils.c projects/clang1000-import/stand/efi/libefi/efihttp.c projects/clang1000-import/stand/efi/libefi/efinet.c projects/clang1000-import/stand/efi/libefi/efipart.c projects/clang1000-import/stand/efi/libefi/efizfs.c projects/clang1000-import/stand/efi/libefi/handles.c projects/clang1000-import/stand/efi/loader/Makefile projects/clang1000-import/stand/efi/loader/main.c projects/clang1000-import/stand/i386/libi386/Makefile projects/clang1000-import/stand/i386/loader/main.c projects/clang1000-import/stand/libsa/Makefile projects/clang1000-import/stand/libsa/stand.h projects/clang1000-import/sys/bsm/audit_kevents.h projects/clang1000-import/sys/compat/freebsd32/freebsd32_syscall.h projects/clang1000-import/sys/compat/freebsd32/freebsd32_syscalls.c projects/clang1000-import/sys/compat/freebsd32/freebsd32_sysent.c projects/clang1000-import/sys/compat/freebsd32/freebsd32_systrace_args.c projects/clang1000-import/sys/compat/freebsd32/syscalls.master projects/clang1000-import/sys/compat/linuxkpi/common/include/linux/list.h projects/clang1000-import/sys/compat/linuxkpi/common/include/linux/string.h projects/clang1000-import/sys/dev/ath/if_ath.c projects/clang1000-import/sys/dev/ath/if_ath_rx.c projects/clang1000-import/sys/dev/ath/if_ath_rx_edma.c projects/clang1000-import/sys/dev/pci/pcireg.h projects/clang1000-import/sys/dev/virtio/mmio/virtio_mmio.c projects/clang1000-import/sys/kern/init_sysent.c projects/clang1000-import/sys/kern/kern_exec.c projects/clang1000-import/sys/kern/kern_sig.c projects/clang1000-import/sys/kern/subr_syscall.c projects/clang1000-import/sys/kern/subr_trap.c projects/clang1000-import/sys/kern/syscalls.c projects/clang1000-import/sys/kern/syscalls.master projects/clang1000-import/sys/kern/systrace_args.c projects/clang1000-import/sys/kern/vfs_cache.c projects/clang1000-import/sys/netinet/sctp_constants.h projects/clang1000-import/sys/netinet6/ip6_output.c projects/clang1000-import/sys/security/audit/audit_bsm.c projects/clang1000-import/sys/sys/param.h projects/clang1000-import/sys/sys/signalvar.h projects/clang1000-import/sys/sys/syscall.h projects/clang1000-import/sys/sys/syscall.mk projects/clang1000-import/sys/sys/sysproto.h projects/clang1000-import/sys/vm/vm_radix.c projects/clang1000-import/sys/vm/vnode_pager.c projects/clang1000-import/usr.bin/truss/syscalls.c projects/clang1000-import/usr.sbin/pciconf/cap.c projects/clang1000-import/usr.sbin/pciconf/pciconf.c projects/clang1000-import/usr.sbin/services_mkdb/services_mkdb.c Directory Properties: projects/clang1000-import/ (props changed) Modified: projects/clang1000-import/ObsoleteFiles.inc ============================================================================== --- projects/clang1000-import/ObsoleteFiles.inc Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/ObsoleteFiles.inc Thu Feb 20 19:07:29 2020 (r358179) @@ -273,6 +273,12 @@ OLD_DIRS+=usr/lib/clang/9.0.1/lib/freebsd OLD_DIRS+=usr/lib/clang/9.0.1/lib OLD_DIRS+=usr/lib/clang/9.0.1 +# 20200220: Upgrade of ncurses, shlib bumped to version 9 +OLD_LIBS+=lib/libncurses.so.8 +OLD_LIBS+=lib/libncursesw.so.8 +OLD_LIBS+=usr/lib32/libncurses.so.8 +OLD_LIBS+=usr/lib32/libncursesw.so.8 + # 20200206: Remove elf2aout OLD_FILES+=usr/bin/elf2aout OLD_FILES+=usr/share/man/man1/elf2aout.1.gz Modified: projects/clang1000-import/UPDATING ============================================================================== --- projects/clang1000-import/UPDATING Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/UPDATING Thu Feb 20 19:07:29 2020 (r358179) @@ -32,10 +32,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW: information about prerequisites and upgrading, if you are not already using clang 3.5.0 or higher. -20200218: - ncurses has been updated to a newer version (6.1-20200118). After an - update some applications using ncurses may results have some rendering - problems and would need to be rebuilt. +20200220: + ncurses has been updated to a newer version (6.1-20200118). Given the ABI + has changed, users will have to rebuild all the ports that are linked to + ncurses. 20200217: The size of struct vnet and the magic cookie have changed. Modified: projects/clang1000-import/bin/sh/miscbltin.c ============================================================================== --- projects/clang1000-import/bin/sh/miscbltin.c Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/bin/sh/miscbltin.c Thu Feb 20 19:07:29 2020 (r358179) @@ -66,10 +66,79 @@ __FBSDID("$FreeBSD$"); #undef eflag +#define READ_BUFLEN 1024 +struct fdctx { + int fd; + size_t off; /* offset in buf */ + size_t buflen; + char *ep; /* tail pointer */ + char buf[READ_BUFLEN]; +}; + +static void fdctx_init(int, struct fdctx *); +static void fdctx_destroy(struct fdctx *); +static ssize_t fdgetc(struct fdctx *, char *); int readcmd(int, char **); int umaskcmd(int, char **); int ulimitcmd(int, char **); +static void +fdctx_init(int fd, struct fdctx *fdc) +{ + off_t cur; + + /* Check if fd is seekable. */ + cur = lseek(fd, 0, SEEK_CUR); + *fdc = (struct fdctx){ + .fd = fd, + .buflen = (cur != -1) ? READ_BUFLEN : 1, + .ep = &fdc->buf[0], /* No data */ + }; +} + +static ssize_t +fdgetc(struct fdctx *fdc, char *c) +{ + ssize_t nread; + + if (&fdc->buf[fdc->off] == fdc->ep) { + nread = read(fdc->fd, fdc->buf, fdc->buflen); + if (nread > 0) { + fdc->off = 0; + fdc->ep = fdc->buf + nread; + } else + return (nread); + } + *c = fdc->buf[fdc->off++]; + + return (1); +} + +static void +fdctx_destroy(struct fdctx *fdc) +{ + size_t residue; + + if (fdc->buflen > 1) { + /* + * Reposition the file offset. Here is the layout of buf: + * + * | off + * v + * |*****************|-------| + * buf ep buf+buflen + * |<- residue ->| + * + * off: current character + * ep: offset just after read(2) + * residue: length for reposition + */ + residue = (fdc->ep - fdc->buf) - fdc->off; + if (residue > 0) + (void) lseek(fdc->fd, -residue, SEEK_CUR); + } +} + /* * The read builtin. The -r option causes backslashes to be treated like * ordinary characters. @@ -108,6 +177,7 @@ readcmd(int argc __unused, char **argv __unused) fd_set ifds; ssize_t nread; int sig; + struct fdctx fdctx; rflag = 0; prompt = NULL; @@ -173,8 +243,9 @@ readcmd(int argc __unused, char **argv __unused) backslash = 0; STARTSTACKSTR(p); lastnonifs = lastnonifsws = -1; + fdctx_init(STDIN_FILENO, &fdctx); for (;;) { - nread = read(STDIN_FILENO, &c, 1); + nread = fdgetc(&fdctx, &c); if (nread == -1) { if (errno == EINTR) { sig = pendingsig; @@ -260,6 +331,7 @@ readcmd(int argc __unused, char **argv __unused) STARTSTACKSTR(p); lastnonifs = lastnonifsws = -1; } + fdctx_destroy(&fdctx); STACKSTRNUL(p); /* Modified: projects/clang1000-import/lib/libc/stdlib/realpath.c ============================================================================== --- projects/clang1000-import/lib/libc/stdlib/realpath.c Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/lib/libc/stdlib/realpath.c Thu Feb 20 19:07:29 2020 (r358179) @@ -42,14 +42,19 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <fcntl.h> #include "un-namespace.h" +#include "libc_private.h" +extern int __realpathat(int fd, const char *path, char *buf, size_t size, + int flags); + /* * Find the real name of path, by removing all ".", ".." and symlink * components. Returns (resolved) on success, or (NULL) on failure, * in which case the path which caused trouble is left in (resolved). */ -static char * +static char * __noinline realpath1(const char *path, char *resolved) { struct stat sb; @@ -222,6 +227,10 @@ realpath(const char * __restrict path, char * __restri m = resolved = malloc(PATH_MAX); if (resolved == NULL) return (NULL); + } + if (__getosreldate() >= 1300080) { + if (__realpathat(AT_FDCWD, path, resolved, PATH_MAX, 0) == 0) + return (resolved); } res = realpath1(path, resolved); if (res == NULL) Modified: projects/clang1000-import/lib/ncurses/ncurses/Makefile ============================================================================== --- projects/clang1000-import/lib/ncurses/ncurses/Makefile Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/lib/ncurses/ncurses/Makefile Thu Feb 20 19:07:29 2020 (r358179) @@ -13,7 +13,7 @@ MK_MAN=no .include "${.CURDIR:H}/config.mk" LIB= ncurses${LIB_SUFFIX} -SHLIB_MAJOR= 8 +SHLIB_MAJOR= 9 NO_LINT= @@ -292,7 +292,6 @@ CLEANFILES= ${GENSRCS} ${GENHDRS} keys.list make_hash make_keys MKterm.h.awk comp_captab.c curses.head CFLAGS+= -DFREEBSD_NATIVE -DTERMIOS -CFLAGS.lib_freeall.c+= -Wno-missing-prototypes # Installed HEADERS= curses.h term.h termcap.h unctrl.h Modified: projects/clang1000-import/libexec/rtld-elf/rtld-libc/Makefile.inc ============================================================================== --- projects/clang1000-import/libexec/rtld-elf/rtld-libc/Makefile.inc Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/libexec/rtld-elf/rtld-libc/Makefile.inc Thu Feb 20 19:07:29 2020 (r358179) @@ -49,7 +49,7 @@ _libc_other_objects= sigsetjmp lstat stat fstat fstata sysarch __sysctl issetugid __getcwd utrace \ thr_self thr_kill pread mmap lseek _exit _fstat _fstatat _fstatfs \ getdirentries _getdirentries _close _fcntl _open _openat _read \ - _sigprocmask _write readlink _setjmp setjmp setjmperr + _sigprocmask _write readlink __realpathat _setjmp setjmp setjmperr # Finally add additional architecture-dependent libc dependencies Modified: projects/clang1000-import/share/man/man4/Makefile ============================================================================== --- projects/clang1000-import/share/man/man4/Makefile Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/share/man/man4/Makefile Thu Feb 20 19:07:29 2020 (r358179) @@ -192,6 +192,7 @@ MAN= aac.4 \ ${_hv_vmbus.4} \ ${_hv_vss.4} \ hwpmc.4 \ + ${_hwpstate_intel.4} \ iavf.4 \ ichsmb.4 \ ${_ichwd.4} \ @@ -787,6 +788,7 @@ _hv_storvsc.4= hv_storvsc.4 _hv_utils.4= hv_utils.4 _hv_vmbus.4= hv_vmbus.4 _hv_vss.4= hv_vss.4 +_hwpstate_intel.4= hwpstate_intel.4 _i8254.4= i8254.4 _ichwd.4= ichwd.4 _if_bxe.4= if_bxe.4 Modified: projects/clang1000-import/stand/efi/libefi/efi_driver_utils.c ============================================================================== --- projects/clang1000-import/stand/efi/libefi/efi_driver_utils.c Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/stand/efi/libefi/efi_driver_utils.c Thu Feb 20 19:07:29 2020 (r358179) @@ -52,6 +52,8 @@ connect_controllers(EFI_GUID *filter) } handles = malloc(hsize); + if (handles == NULL) + return (EFI_OUT_OF_RESOURCES); nhandles = hsize / sizeof(EFI_HANDLE); status = BS->LocateHandle(ByProtocol, filter, NULL, Modified: projects/clang1000-import/stand/efi/libefi/efihttp.c ============================================================================== --- projects/clang1000-import/stand/efi/libefi/efihttp.c Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/stand/efi/libefi/efihttp.c Thu Feb 20 19:07:29 2020 (r358179) @@ -701,6 +701,8 @@ efihttp_fs_seek(struct open_file *f, off_t offset, int return (0); if (where == SEEK_SET && fh->offset < offset) { buf = malloc(1500); + if (buf == NULL) + return (ENOMEM); res = offset - fh->offset; while (res > 0) { err = _efihttp_fs_read(f, buf, min(1500, res), &res2); Modified: projects/clang1000-import/stand/efi/libefi/efinet.c ============================================================================== --- projects/clang1000-import/stand/efi/libefi/efinet.c Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/stand/efi/libefi/efinet.c Thu Feb 20 19:07:29 2020 (r358179) @@ -371,6 +371,8 @@ efinet_dev_init() status = BS->LocateHandle(ByProtocol, &sn_guid, NULL, &sz, NULL); if (status == EFI_BUFFER_TOO_SMALL) { handles = (EFI_HANDLE *)malloc(sz); + if (handles == NULL) + return (ENOMEM); status = BS->LocateHandle(ByProtocol, &sn_guid, NULL, &sz, handles); if (EFI_ERROR(status)) Modified: projects/clang1000-import/stand/efi/libefi/efipart.c ============================================================================== --- projects/clang1000-import/stand/efi/libefi/efipart.c Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/stand/efi/libefi/efipart.c Thu Feb 20 19:07:29 2020 (r358179) @@ -363,6 +363,8 @@ efipart_inithandles(void) status = BS->LocateHandle(ByProtocol, &blkio_guid, 0, &sz, hin); if (status == EFI_BUFFER_TOO_SMALL) { hin = malloc(sz); + if (hin == NULL) + return (ENOMEM); status = BS->LocateHandle(ByProtocol, &blkio_guid, 0, &sz, hin); if (EFI_ERROR(status)) Modified: projects/clang1000-import/stand/efi/libefi/efizfs.c ============================================================================== --- projects/clang1000-import/stand/efi/libefi/efizfs.c Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/stand/efi/libefi/efizfs.c Thu Feb 20 19:07:29 2020 (r358179) @@ -86,9 +86,11 @@ insert_zfs(EFI_HANDLE handle, uint64_t guid) zfsinfo_t *zi; zi = malloc(sizeof(zfsinfo_t)); - zi->zi_handle = handle; - zi->zi_pool_guid = guid; - STAILQ_INSERT_TAIL(&zfsinfo, zi, zi_link); + if (zi != NULL) { + zi->zi_handle = handle; + zi->zi_pool_guid = guid; + STAILQ_INSERT_TAIL(&zfsinfo, zi, zi_link); + } } void Modified: projects/clang1000-import/stand/efi/libefi/handles.c ============================================================================== --- projects/clang1000-import/stand/efi/libefi/handles.c Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/stand/efi/libefi/handles.c Thu Feb 20 19:07:29 2020 (r358179) @@ -52,6 +52,8 @@ efi_register_handles(struct devsw *sw, EFI_HANDLE *han nentries += count; sz = nentries * sizeof(struct entry); entry = (entry == NULL) ? malloc(sz) : realloc(entry, sz); + if (entry == NULL) + return (ENOMEM); for (unit = 0; idx < nentries; idx++, unit++) { entry[idx].handle = handles[unit]; if (aliases != NULL) Modified: projects/clang1000-import/stand/efi/loader/Makefile ============================================================================== --- projects/clang1000-import/stand/efi/loader/Makefile Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/stand/efi/loader/Makefile Thu Feb 20 19:07:29 2020 (r358179) @@ -22,7 +22,6 @@ SRCS= autoload.c \ framebuffer.c \ main.c \ self_reloc.c \ - smbios.c \ vers.c CFLAGS+= -I${.CURDIR}/../loader @@ -45,8 +44,6 @@ CWARNFLAGS.main.c+= -Wno-format .PATH: ${.CURDIR}/../loader .PATH: ${.CURDIR}/../loader/arch/${MACHINE} -# For smbios.c XXX need to abstract properly -.PATH: ${BOOTSRC}/i386/libi386 .include "${.CURDIR}/../loader/arch/${MACHINE}/Makefile.inc" CFLAGS+= -I${.CURDIR} @@ -56,18 +53,6 @@ CFLAGS+= -I${EFISRC}/include/${MACHINE} CFLAGS+= -I${SYSDIR}/contrib/dev/acpica/include CFLAGS+= -I${BOOTSRC}/i386/libi386 CFLAGS+= -DEFI - -.if !defined(BOOT_HIDE_SERIAL_NUMBERS) -# Export serial numbers, UUID, and asset tag from loader. -CFLAGS+= -DSMBIOS_SERIAL_NUMBERS -.if defined(BOOT_LITTLE_ENDIAN_UUID) -# Use little-endian UUID format as defined in SMBIOS 2.6. -CFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID -.elif defined(BOOT_NETWORK_ENDIAN_UUID) -# Use network-endian UUID format for backward compatibility. -CFLAGS+= -DSMBIOS_NETWORK_ENDIAN_UUID -.endif -.endif .if defined(HAVE_FDT) && ${MK_FDT} != "no" .include "${BOOTSRC}/fdt.mk" Modified: projects/clang1000-import/stand/efi/loader/main.c ============================================================================== --- projects/clang1000-import/stand/efi/loader/main.c Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/stand/efi/loader/main.c Thu Feb 20 19:07:29 2020 (r358179) @@ -852,7 +852,11 @@ read_loader_env(const char *name, char *def_fn, bool o } } - +caddr_t +ptov(uintptr_t x) +{ + return ((caddr_t)x); +} EFI_STATUS main(int argc, CHAR16 *argv[]) Modified: projects/clang1000-import/stand/i386/libi386/Makefile ============================================================================== --- projects/clang1000-import/stand/i386/libi386/Makefile Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/stand/i386/libi386/Makefile Thu Feb 20 19:07:29 2020 (r358179) @@ -9,7 +9,7 @@ SRCS= bio.c biosacpi.c biosdisk.c biosmem.c biospnp.c comconsole.c devicename.c elf32_freebsd.c \ elf64_freebsd.c multiboot.c multiboot_tramp.S relocater_tramp.S \ i386_copy.c i386_module.c nullconsole.c pxe.c pxetramp.S \ - smbios.c time.c vidconsole.c amd64_tramp.S spinconsole.c + time.c vidconsole.c amd64_tramp.S spinconsole.c .PATH: ${ZFSSRC} SRCS+= devicename_stubs.c CFLAGS+= -I${ZFSSRC} @@ -26,18 +26,6 @@ CFLAGS+= -DCOMSPEED=${BOOT_COMCONSOLE_SPEED} .ifdef(BOOT_BIOSDISK_DEBUG) # Make the disk code more talkative CFLAGS+= -DDISK_DEBUG -.endif - -.if !defined(BOOT_HIDE_SERIAL_NUMBERS) -# Export serial numbers, UUID, and asset tag from loader. -CFLAGS+= -DSMBIOS_SERIAL_NUMBERS -.if defined(BOOT_LITTLE_ENDIAN_UUID) -# Use little-endian UUID format as defined in SMBIOS 2.6. -CFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID -.elif defined(BOOT_NETWORK_ENDIAN_UUID) -# Use network-endian UUID format for backward compatibility. -CFLAGS+= -DSMBIOS_NETWORK_ENDIAN_UUID -.endif .endif # terminal emulation Modified: projects/clang1000-import/stand/i386/loader/main.c ============================================================================== --- projects/clang1000-import/stand/i386/loader/main.c Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/stand/i386/loader/main.c Thu Feb 20 19:07:29 2020 (r358179) @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$"); #include "bootstrap.h" #include "common/bootargs.h" #include "libi386/libi386.h" -#include "libi386/smbios.h" +#include <smbios.h> #include "btxv86.h" #ifdef LOADER_ZFS_SUPPORT @@ -85,6 +85,12 @@ extern char end[]; static void *heap_top; static void *heap_bottom; + +caddr_t +ptov(uintptr_t x) +{ + return (PTOV(x)); +} int main(void) Modified: projects/clang1000-import/stand/libsa/Makefile ============================================================================== --- projects/clang1000-import/stand/libsa/Makefile Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/stand/libsa/Makefile Thu Feb 20 19:07:29 2020 (r358179) @@ -137,6 +137,20 @@ CLEANFILES+= ${SAFE_INCS} ${STAND_H_INC} ${OTHER_INC} SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \ fstat.c close.c lseek.c open.c read.c write.c readdir.c +# SMBios routines +SRCS+= smbios.c +.if !defined(BOOT_HIDE_SERIAL_NUMBERS) +# Export serial numbers, UUID, and asset tag from loader. +CFLAGS.smbios.c+= -DSMBIOS_SERIAL_NUMBERS +.if defined(BOOT_LITTLE_ENDIAN_UUID) +# Use little-endian UUID format as defined in SMBIOS 2.6. +CFLAGS.smbios.c+= -DSMBIOS_LITTLE_ENDIAN_UUID +.elif defined(BOOT_NETWORK_ENDIAN_UUID) +# Use network-endian UUID format for backward compatibility. +CFLAGS.smbios.c+= -DSMBIOS_NETWORK_ENDIAN_UUID +.endif +.endif + # network routines SRCS+= arp.c ether.c ip.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c Copied: projects/clang1000-import/stand/libsa/smbios.c (from r358166, head/stand/libsa/smbios.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/clang1000-import/stand/libsa/smbios.c Thu Feb 20 19:07:29 2020 (r358179, copy of r358166, head/stand/libsa/smbios.c) @@ -0,0 +1,447 @@ +/*- + * Copyright (c) 2005-2009 Jung-uk Kim <jkim@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <stand.h> +#include <sys/endian.h> + +#define PTOV(x) ptov(x) + +/* + * Detect SMBIOS and export information about the SMBIOS into the + * environment. + * + * System Management BIOS Reference Specification, v2.6 Final + * http://www.dmtf.org/standards/published_documents/DSP0134_2.6.0.pdf + */ + +/* + * 2.1.1 SMBIOS Structure Table Entry Point + * + * "On non-EFI systems, the SMBIOS Entry Point structure, described below, can + * be located by application software by searching for the anchor-string on + * paragraph (16-byte) boundaries within the physical memory address range + * 000F0000h to 000FFFFFh. This entry point encapsulates an intermediate anchor + * string that is used by some existing DMI browsers." + */ +#define SMBIOS_START 0xf0000 +#define SMBIOS_LENGTH 0x10000 +#define SMBIOS_STEP 0x10 +#define SMBIOS_SIG "_SM_" +#define SMBIOS_DMI_SIG "_DMI_" + +#define SMBIOS_GET8(base, off) (*(uint8_t *)((base) + (off))) +#define SMBIOS_GET16(base, off) (*(uint16_t *)((base) + (off))) +#define SMBIOS_GET32(base, off) (*(uint32_t *)((base) + (off))) + +#define SMBIOS_GETLEN(base) SMBIOS_GET8(base, 0x01) +#define SMBIOS_GETSTR(base) ((base) + SMBIOS_GETLEN(base)) + +struct smbios_attr { + int probed; + caddr_t addr; + size_t length; + size_t count; + int major; + int minor; + int ver; + const char* bios_vendor; + const char* maker; + const char* product; + uint32_t enabled_memory; + uint32_t old_enabled_memory; + uint8_t enabled_sockets; + uint8_t populated_sockets; +}; + +static struct smbios_attr smbios; + +static uint8_t +smbios_checksum(const caddr_t addr, const uint8_t len) +{ + uint8_t sum; + int i; + + for (sum = 0, i = 0; i < len; i++) + sum += SMBIOS_GET8(addr, i); + return (sum); +} + +static caddr_t +smbios_sigsearch(const caddr_t addr, const uint32_t len) +{ + caddr_t cp; + + /* Search on 16-byte boundaries. */ + for (cp = addr; cp < addr + len; cp += SMBIOS_STEP) + if (strncmp(cp, SMBIOS_SIG, 4) == 0 && + smbios_checksum(cp, SMBIOS_GET8(cp, 0x05)) == 0 && + strncmp(cp + 0x10, SMBIOS_DMI_SIG, 5) == 0 && + smbios_checksum(cp + 0x10, 0x0f) == 0) + return (cp); + return (NULL); +} + +static const char* +smbios_getstring(caddr_t addr, const int offset) +{ + caddr_t cp; + int i, idx; + + idx = SMBIOS_GET8(addr, offset); + if (idx != 0) { + cp = SMBIOS_GETSTR(addr); + for (i = 1; i < idx; i++) + cp += strlen(cp) + 1; + return cp; + } + return (NULL); +} + +static void +smbios_setenv(const char *name, caddr_t addr, const int offset) +{ + const char* val; + + val = smbios_getstring(addr, offset); + if (val != NULL) + setenv(name, val, 1); +} + +#ifdef SMBIOS_SERIAL_NUMBERS + +#define UUID_SIZE 16 +#define UUID_TYPE uint32_t +#define UUID_STEP sizeof(UUID_TYPE) +#define UUID_ALL_BITS (UUID_SIZE / UUID_STEP) +#define UUID_GET(base, off) (*(UUID_TYPE *)((base) + (off))) + +static void +smbios_setuuid(const char *name, const caddr_t addr, const int ver) +{ + char uuid[37]; + int byteorder, i, ones, zeros; + UUID_TYPE n; + uint32_t f1; + uint16_t f2, f3; + + for (i = 0, ones = 0, zeros = 0; i < UUID_SIZE; i += UUID_STEP) { + n = UUID_GET(addr, i) + 1; + if (zeros == 0 && n == 0) + ones++; + else if (ones == 0 && n == 1) + zeros++; + else + break; + } + + if (ones != UUID_ALL_BITS && zeros != UUID_ALL_BITS) { + /* + * 3.3.2.1 System UUID + * + * "Although RFC 4122 recommends network byte order for all + * fields, the PC industry (including the ACPI, UEFI, and + * Microsoft specifications) has consistently used + * little-endian byte encoding for the first three fields: + * time_low, time_mid, time_hi_and_version. The same encoding, + * also known as wire format, should also be used for the + * SMBIOS representation of the UUID." + * + * Note: We use network byte order for backward compatibility + * unless SMBIOS version is 2.6+ or little-endian is forced. + */ +#if defined(SMBIOS_LITTLE_ENDIAN_UUID) + byteorder = LITTLE_ENDIAN; +#elif defined(SMBIOS_NETWORK_ENDIAN_UUID) + byteorder = BIG_ENDIAN; +#else + byteorder = ver < 0x0206 ? BIG_ENDIAN : LITTLE_ENDIAN; +#endif + if (byteorder != LITTLE_ENDIAN) { + f1 = ntohl(SMBIOS_GET32(addr, 0)); + f2 = ntohs(SMBIOS_GET16(addr, 4)); + f3 = ntohs(SMBIOS_GET16(addr, 6)); + } else { + f1 = le32toh(SMBIOS_GET32(addr, 0)); + f2 = le16toh(SMBIOS_GET16(addr, 4)); + f3 = le16toh(SMBIOS_GET16(addr, 6)); + } + sprintf(uuid, + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + f1, f2, f3, SMBIOS_GET8(addr, 8), SMBIOS_GET8(addr, 9), + SMBIOS_GET8(addr, 10), SMBIOS_GET8(addr, 11), + SMBIOS_GET8(addr, 12), SMBIOS_GET8(addr, 13), + SMBIOS_GET8(addr, 14), SMBIOS_GET8(addr, 15)); + setenv(name, uuid, 1); + } +} + +#undef UUID_SIZE +#undef UUID_TYPE +#undef UUID_STEP +#undef UUID_ALL_BITS +#undef UUID_GET + +#endif + +static caddr_t +smbios_parse_table(const caddr_t addr) +{ + caddr_t cp; + int proc, size, osize, type; + + type = SMBIOS_GET8(addr, 0); /* 3.1.2 Structure Header Format */ + switch(type) { + case 0: /* 3.3.1 BIOS Information (Type 0) */ + smbios_setenv("smbios.bios.vendor", addr, 0x04); + smbios_setenv("smbios.bios.version", addr, 0x05); + smbios_setenv("smbios.bios.reldate", addr, 0x08); + break; + + case 1: /* 3.3.2 System Information (Type 1) */ + smbios_setenv("smbios.system.maker", addr, 0x04); + smbios_setenv("smbios.system.product", addr, 0x05); + smbios_setenv("smbios.system.version", addr, 0x06); +#ifdef SMBIOS_SERIAL_NUMBERS + smbios_setenv("smbios.system.serial", addr, 0x07); + smbios_setuuid("smbios.system.uuid", addr + 0x08, smbios.ver); +#endif + if (smbios.major > 2 || + (smbios.major == 2 && smbios.minor >= 4)) { + smbios_setenv("smbios.system.sku", addr, 0x19); + smbios_setenv("smbios.system.family", addr, 0x1a); + } + break; + + case 2: /* 3.3.3 Base Board (or Module) Information (Type 2) */ + smbios_setenv("smbios.planar.maker", addr, 0x04); + smbios_setenv("smbios.planar.product", addr, 0x05); + smbios_setenv("smbios.planar.version", addr, 0x06); +#ifdef SMBIOS_SERIAL_NUMBERS + smbios_setenv("smbios.planar.serial", addr, 0x07); + smbios_setenv("smbios.planar.tag", addr, 0x08); +#endif + smbios_setenv("smbios.planar.location", addr, 0x0a); + break; + + case 3: /* 3.3.4 System Enclosure or Chassis (Type 3) */ + smbios_setenv("smbios.chassis.maker", addr, 0x04); + smbios_setenv("smbios.chassis.version", addr, 0x06); +#ifdef SMBIOS_SERIAL_NUMBERS + smbios_setenv("smbios.chassis.serial", addr, 0x07); + smbios_setenv("smbios.chassis.tag", addr, 0x08); +#endif + break; + + case 4: /* 3.3.5 Processor Information (Type 4) */ + /* + * Offset 18h: Processor Status + * + * Bit 7 Reserved, must be 0 + * Bit 6 CPU Socket Populated + * 1 - CPU Socket Populated + * 0 - CPU Socket Unpopulated + * Bit 5:3 Reserved, must be zero + * Bit 2:0 CPU Status + * 0h - Unknown + * 1h - CPU Enabled + * 2h - CPU Disabled by User via BIOS Setup + * 3h - CPU Disabled by BIOS (POST Error) + * 4h - CPU is Idle, waiting to be enabled + * 5-6h - Reserved + * 7h - Other + */ + proc = SMBIOS_GET8(addr, 0x18); + if ((proc & 0x07) == 1) + smbios.enabled_sockets++; + if ((proc & 0x40) != 0) + smbios.populated_sockets++; + break; + + case 6: /* 3.3.7 Memory Module Information (Type 6, Obsolete) */ + /* + * Offset 0Ah: Enabled Size + * + * Bit 7 Bank connection + * 1 - Double-bank connection + * 0 - Single-bank connection + * Bit 6:0 Size (n), where 2**n is the size in MB + * 7Dh - Not determinable (Installed Size only) + * 7Eh - Module is installed, but no memory + * has been enabled + * 7Fh - Not installed + */ + osize = SMBIOS_GET8(addr, 0x0a) & 0x7f; + if (osize > 0 && osize < 22) + smbios.old_enabled_memory += 1 << (osize + 10); + break; + + case 17: /* 3.3.18 Memory Device (Type 17) */ + /* + * Offset 0Ch: Size + * + * Bit 15 Granularity + * 1 - Value is in kilobytes units + * 0 - Value is in megabytes units + * Bit 14:0 Size + */ + size = SMBIOS_GET16(addr, 0x0c); + if (size != 0 && size != 0xffff) + smbios.enabled_memory += (size & 0x8000) != 0 ? + (size & 0x7fff) : (size << 10); + break; + + default: /* skip other types */ + break; + } + + /* Find structure terminator. */ + cp = SMBIOS_GETSTR(addr); + while (SMBIOS_GET16(cp, 0) != 0) + cp++; + + return (cp + 2); +} + +static caddr_t +smbios_find_struct(int type) +{ + caddr_t dmi; + size_t i; + + if (smbios.addr == NULL) + return (NULL); + + for (dmi = smbios.addr, i = 0; + dmi < smbios.addr + smbios.length && i < smbios.count; i++) { + if (SMBIOS_GET8(dmi, 0) == type) + return dmi; + /* Find structure terminator. */ + dmi = SMBIOS_GETSTR(dmi); + while (SMBIOS_GET16(dmi, 0) != 0) + dmi++; + dmi += 2; + } + + return (NULL); +} + +static void +smbios_probe(const caddr_t addr) +{ + caddr_t saddr, info; + uintptr_t paddr; + + if (smbios.probed) + return; + smbios.probed = 1; + + /* Search signatures and validate checksums. */ + saddr = smbios_sigsearch(addr ? addr : PTOV(SMBIOS_START), + SMBIOS_LENGTH); + if (saddr == NULL) + return; + + smbios.length = SMBIOS_GET16(saddr, 0x16); /* Structure Table Length */ + paddr = SMBIOS_GET32(saddr, 0x18); /* Structure Table Address */ + smbios.count = SMBIOS_GET16(saddr, 0x1c); /* No of SMBIOS Structures */ + smbios.ver = SMBIOS_GET8(saddr, 0x1e); /* SMBIOS BCD Revision */ + + if (smbios.ver != 0) { + smbios.major = smbios.ver >> 4; + smbios.minor = smbios.ver & 0x0f; + if (smbios.major > 9 || smbios.minor > 9) + smbios.ver = 0; + } + if (smbios.ver == 0) { + smbios.major = SMBIOS_GET8(saddr, 0x06);/* SMBIOS Major Version */ + smbios.minor = SMBIOS_GET8(saddr, 0x07);/* SMBIOS Minor Version */ + } + smbios.ver = (smbios.major << 8) | smbios.minor; + smbios.addr = PTOV(paddr); + + /* Get system information from SMBIOS */ + info = smbios_find_struct(0x00); + if (info != NULL) { + smbios.bios_vendor = smbios_getstring(info, 0x04); + } + info = smbios_find_struct(0x01); + if (info != NULL) { + smbios.maker = smbios_getstring(info, 0x04); + smbios.product = smbios_getstring(info, 0x05); + } +} + +void +smbios_detect(const caddr_t addr) +{ + char buf[16]; + caddr_t dmi; + size_t i; + + smbios_probe(addr); + if (smbios.addr == NULL) + return; + + for (dmi = smbios.addr, i = 0; + dmi < smbios.addr + smbios.length && i < smbios.count; i++) + dmi = smbios_parse_table(dmi); + + sprintf(buf, "%d.%d", smbios.major, smbios.minor); + setenv("smbios.version", buf, 1); + if (smbios.enabled_memory > 0 || smbios.old_enabled_memory > 0) { + sprintf(buf, "%u", smbios.enabled_memory > 0 ? + smbios.enabled_memory : smbios.old_enabled_memory); + setenv("smbios.memory.enabled", buf, 1); + } + if (smbios.enabled_sockets > 0) { + sprintf(buf, "%u", smbios.enabled_sockets); + setenv("smbios.socket.enabled", buf, 1); + } + if (smbios.populated_sockets > 0) { + sprintf(buf, "%u", smbios.populated_sockets); + setenv("smbios.socket.populated", buf, 1); + } +} + +static int +smbios_match_str(const char* s1, const char* s2) +{ + return (s1 == NULL || (s2 != NULL && !strcmp(s1, s2))); +} + +int +smbios_match(const char* bios_vendor, const char* maker, + const char* product) +{ + /* XXXRP currently, only called from non-EFI. */ + smbios_probe(NULL); + return (smbios_match_str(bios_vendor, smbios.bios_vendor) && + smbios_match_str(maker, smbios.maker) && + smbios_match_str(product, smbios.product)); +} Copied: projects/clang1000-import/stand/libsa/smbios.h (from r358166, head/stand/libsa/smbios.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/clang1000-import/stand/libsa/smbios.h Thu Feb 20 19:07:29 2020 (r358179, copy of r358166, head/stand/libsa/smbios.h) @@ -0,0 +1,34 @@ +/*- + * Copyright (c) 2015 Rui Paulo <rpaulo@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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 _SMBIOS_H_ +#define _SMBIOS_H_ + +void smbios_detect(const caddr_t); +int smbios_match(const char *, const char *, const char *); + +#endif /* _SMBIOS_H_ */ Modified: projects/clang1000-import/stand/libsa/stand.h ============================================================================== --- projects/clang1000-import/stand/libsa/stand.h Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/stand/libsa/stand.h Thu Feb 20 19:07:29 2020 (r358179) @@ -452,4 +452,9 @@ const char *x86_hypervisor(void); #define reallocf(x, y) Reallocf(x, y, NULL, 0) #endif +/* + * va <-> pa routines. MD code must supply. + */ +caddr_t ptov(uintptr_t); + #endif /* STAND_H */ Modified: projects/clang1000-import/sys/bsm/audit_kevents.h ============================================================================== --- projects/clang1000-import/sys/bsm/audit_kevents.h Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/sys/bsm/audit_kevents.h Thu Feb 20 19:07:29 2020 (r358179) @@ -657,6 +657,7 @@ #define AUE_LGETUUID 43261 /* CADETS. */ #define AUE_EXECVEAT 43262 /* FreeBSD/Linux. */ #define AUE_SHMRENAME 43263 /* FreeBSD-specific. */ +#define AUE_REALPATHAT 43264 /* FreeBSD-specific. */ /* * Darwin BSM uses a number of AUE_O_* definitions, which are aliased to the Modified: projects/clang1000-import/sys/compat/freebsd32/freebsd32_syscall.h ============================================================================== --- projects/clang1000-import/sys/compat/freebsd32/freebsd32_syscall.h Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/sys/compat/freebsd32/freebsd32_syscall.h Thu Feb 20 19:07:29 2020 (r358179) @@ -500,4 +500,5 @@ #define FREEBSD32_SYS_shm_open2 571 #define FREEBSD32_SYS_shm_rename 572 #define FREEBSD32_SYS_sigfastblock 573 -#define FREEBSD32_SYS_MAXSYSCALL 574 +#define FREEBSD32_SYS___realpathat 574 +#define FREEBSD32_SYS_MAXSYSCALL 575 Modified: projects/clang1000-import/sys/compat/freebsd32/freebsd32_syscalls.c ============================================================================== --- projects/clang1000-import/sys/compat/freebsd32/freebsd32_syscalls.c Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/sys/compat/freebsd32/freebsd32_syscalls.c Thu Feb 20 19:07:29 2020 (r358179) @@ -610,4 +610,5 @@ const char *freebsd32_syscallnames[] = { "shm_open2", /* 571 = shm_open2 */ "shm_rename", /* 572 = shm_rename */ "sigfastblock", /* 573 = sigfastblock */ + "__realpathat", /* 574 = __realpathat */ }; Modified: projects/clang1000-import/sys/compat/freebsd32/freebsd32_sysent.c ============================================================================== --- projects/clang1000-import/sys/compat/freebsd32/freebsd32_sysent.c Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/sys/compat/freebsd32/freebsd32_sysent.c Thu Feb 20 19:07:29 2020 (r358179) @@ -663,4 +663,5 @@ struct sysent freebsd32_sysent[] = { { AS(shm_open2_args), (sy_call_t *)sys_shm_open2, AUE_SHMOPEN, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 571 = shm_open2 */ { AS(shm_rename_args), (sy_call_t *)sys_shm_rename, AUE_SHMRENAME, NULL, 0, 0, 0, SY_THR_STATIC }, /* 572 = shm_rename */ { AS(sigfastblock_args), (sy_call_t *)sys_sigfastblock, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 573 = sigfastblock */ + { AS(__realpathat_args), (sy_call_t *)sys___realpathat, AUE_REALPATHAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 574 = __realpathat */ }; Modified: projects/clang1000-import/sys/compat/freebsd32/freebsd32_systrace_args.c ============================================================================== --- projects/clang1000-import/sys/compat/freebsd32/freebsd32_systrace_args.c Thu Feb 20 17:26:08 2020 (r358178) +++ projects/clang1000-import/sys/compat/freebsd32/freebsd32_systrace_args.c Thu Feb 20 19:07:29 2020 (r358179) @@ -3363,6 +3363,17 @@ systrace_args(int sysnum, void *params, uint64_t *uarg *n_args = 2; break; } + /* __realpathat */ + case 574: { + struct __realpathat_args *p = params; + iarg[0] = p->fd; /* int */ + uarg[1] = (intptr_t) p->path; /* const char * */ + uarg[2] = (intptr_t) p->buf; /* char * */ + uarg[3] = p->size; /* size_t */ + iarg[4] = p->flags; /* int */ + *n_args = 5; + break; + } default: *n_args = 0; break; @@ -9062,6 +9073,28 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *d break; }; break; + /* __realpathat */ + case 574: + switch(ndx) { + case 0: + p = "int"; + break; + case 1: + p = "userland const char *"; + break; + case 2: + p = "userland char *"; + break; + case 3: + p = "size_t"; + break; + case 4: + p = "int"; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002201907.01KJ7TXK022608>