From owner-svn-src-stable-11@freebsd.org Sun Feb 4 03:15:07 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99410EE234A; Sun, 4 Feb 2018 03:15:07 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CBEF269B59; Sun, 4 Feb 2018 03:15:06 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C6CAA1460A; Sun, 4 Feb 2018 03:15:06 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w143F6p0014125; Sun, 4 Feb 2018 03:15:06 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w143F645014124; Sun, 4 Feb 2018 03:15:06 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201802040315.w143F645014124@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Sun, 4 Feb 2018 03:15:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328837 - stable/11/lib/libpmc X-SVN-Group: stable-11 X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: stable/11/lib/libpmc X-SVN-Commit-Revision: 328837 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Feb 2018 03:15:07 -0000 Author: jhibbits Date: Sun Feb 4 03:15:06 2018 New Revision: 328837 URL: https://svnweb.freebsd.org/changeset/base/328837 Log: MFC r327911: Replace the PMC class struct copy with an explicit memcpy() Modified: stable/11/lib/libpmc/libpmc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libpmc/libpmc.c ============================================================================== --- stable/11/lib/libpmc/libpmc.c Sun Feb 4 02:58:12 2018 (r328836) +++ stable/11/lib/libpmc/libpmc.c Sun Feb 4 03:15:06 2018 (r328837) @@ -3268,7 +3268,8 @@ pmc_init(void) cpu_info.pm_npmc = op_cpu_info.pm_npmc; cpu_info.pm_nclass = op_cpu_info.pm_nclass; for (n = 0; n < cpu_info.pm_nclass; n++) - cpu_info.pm_classes[n] = op_cpu_info.pm_classes[n]; + memcpy(&cpu_info.pm_classes[n], &op_cpu_info.pm_classes[n], + sizeof(cpu_info.pm_classes[n])); pmc_class_table = malloc(PMC_CLASS_TABLE_SIZE * sizeof(struct pmc_class_descr *)); From owner-svn-src-stable-11@freebsd.org Sun Feb 4 02:58:12 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E053AEE10BB; Sun, 4 Feb 2018 02:58:12 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 86BBA689A6; Sun, 4 Feb 2018 02:58:12 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7C051141E8; Sun, 4 Feb 2018 02:58:12 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w142wCNL003126; Sun, 4 Feb 2018 02:58:12 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w142wCfi003125; Sun, 4 Feb 2018 02:58:12 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201802040258.w142wCfi003125@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sun, 4 Feb 2018 02:58:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328836 - stable/11/sys/boot/efi/fdt X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/sys/boot/efi/fdt X-SVN-Commit-Revision: 328836 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Feb 2018 02:58:13 -0000 Author: emaste Date: Sun Feb 4 02:58:12 2018 New Revision: 328836 URL: https://svnweb.freebsd.org/changeset/base/328836 Log: Remove now-unused variable after r328809 Modified: stable/11/sys/boot/efi/fdt/efi_fdt.c Modified: stable/11/sys/boot/efi/fdt/efi_fdt.c ============================================================================== --- stable/11/sys/boot/efi/fdt/efi_fdt.c Sat Feb 3 23:49:21 2018 (r328835) +++ stable/11/sys/boot/efi/fdt/efi_fdt.c Sun Feb 4 02:58:12 2018 (r328836) @@ -44,7 +44,6 @@ int fdt_platform_load_dtb(void) { struct fdt_header *hdr; - const char *s; hdr = efi_get_table(&fdtdtb); if (hdr == NULL) From owner-svn-src-stable-11@freebsd.org Sun Feb 4 13:53:46 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0367CED7E28; Sun, 4 Feb 2018 13:53:46 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9F8DD80A05; Sun, 4 Feb 2018 13:53:45 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 98D4B1B00F; Sun, 4 Feb 2018 13:53:45 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w14Drj2A036766; Sun, 4 Feb 2018 13:53:45 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w14DrjRY036764; Sun, 4 Feb 2018 13:53:45 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201802041353.w14DrjRY036764@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Sun, 4 Feb 2018 13:53:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328840 - stable/11/sys/amd64/vmm/amd X-SVN-Group: stable-11 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/11/sys/amd64/vmm/amd X-SVN-Commit-Revision: 328840 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Feb 2018 13:53:46 -0000 Author: avg Date: Sun Feb 4 13:53:45 2018 New Revision: 328840 URL: https://svnweb.freebsd.org/changeset/base/328840 Log: MFC r327726: vmm/svm: contigmalloc of the whole svm_softc is excessive Modified: stable/11/sys/amd64/vmm/amd/svm.c stable/11/sys/amd64/vmm/amd/svm_softc.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/vmm/amd/svm.c ============================================================================== --- stable/11/sys/amd64/vmm/amd/svm.c Sun Feb 4 12:16:36 2018 (r328839) +++ stable/11/sys/amd64/vmm/amd/svm.c Sun Feb 4 13:53:45 2018 (r328840) @@ -517,15 +517,26 @@ svm_vminit(struct vm *vm, pmap_t pmap) vm_paddr_t msrpm_pa, iopm_pa, pml4_pa; int i; - svm_sc = contigmalloc(sizeof (*svm_sc), M_SVM, M_WAITOK | M_ZERO, - 0, ~(vm_paddr_t)0, PAGE_SIZE, 0); + svm_sc = malloc(sizeof (*svm_sc), M_SVM, M_WAITOK | M_ZERO); + if (((uintptr_t)svm_sc & PAGE_MASK) != 0) + panic("malloc of svm_softc not aligned on page boundary"); + + svm_sc->msr_bitmap = contigmalloc(SVM_MSR_BITMAP_SIZE, M_SVM, + M_WAITOK, 0, ~(vm_paddr_t)0, PAGE_SIZE, 0); + if (svm_sc->msr_bitmap == NULL) + panic("contigmalloc of SVM MSR bitmap failed"); + svm_sc->iopm_bitmap = contigmalloc(SVM_IO_BITMAP_SIZE, M_SVM, + M_WAITOK, 0, ~(vm_paddr_t)0, PAGE_SIZE, 0); + if (svm_sc->iopm_bitmap == NULL) + panic("contigmalloc of SVM IO bitmap failed"); + svm_sc->vm = vm; svm_sc->nptp = (vm_offset_t)vtophys(pmap->pm_pml4); /* * Intercept read and write accesses to all MSRs. */ - memset(svm_sc->msr_bitmap, 0xFF, sizeof(svm_sc->msr_bitmap)); + memset(svm_sc->msr_bitmap, 0xFF, SVM_MSR_BITMAP_SIZE); /* * Access to the following MSRs is redirected to the VMCB when the @@ -553,7 +564,7 @@ svm_vminit(struct vm *vm, pmap_t pmap) svm_msr_rd_ok(svm_sc->msr_bitmap, MSR_EFER); /* Intercept access to all I/O ports. */ - memset(svm_sc->iopm_bitmap, 0xFF, sizeof(svm_sc->iopm_bitmap)); + memset(svm_sc->iopm_bitmap, 0xFF, SVM_IO_BITMAP_SIZE); iopm_pa = vtophys(svm_sc->iopm_bitmap); msrpm_pa = vtophys(svm_sc->msr_bitmap); @@ -2043,7 +2054,9 @@ svm_vmcleanup(void *arg) { struct svm_softc *sc = arg; - contigfree(sc, sizeof (*sc), M_SVM); + contigfree(sc->iopm_bitmap, SVM_IO_BITMAP_SIZE, M_SVM); + contigfree(sc->msr_bitmap, SVM_MSR_BITMAP_SIZE, M_SVM); + free(sc, M_SVM); } static register_t * Modified: stable/11/sys/amd64/vmm/amd/svm_softc.h ============================================================================== --- stable/11/sys/amd64/vmm/amd/svm_softc.h Sun Feb 4 12:16:36 2018 (r328839) +++ stable/11/sys/amd64/vmm/amd/svm_softc.h Sun Feb 4 13:53:45 2018 (r328840) @@ -56,13 +56,13 @@ struct svm_vcpu { * SVM softc, one per virtual machine. */ struct svm_softc { - uint8_t iopm_bitmap[SVM_IO_BITMAP_SIZE]; /* shared by all vcpus */ - uint8_t msr_bitmap[SVM_MSR_BITMAP_SIZE]; /* shared by all vcpus */ uint8_t apic_page[VM_MAXCPU][PAGE_SIZE]; struct svm_vcpu vcpu[VM_MAXCPU]; vm_offset_t nptp; /* nested page table */ + uint8_t *iopm_bitmap; /* shared by all vcpus */ + uint8_t *msr_bitmap; /* shared by all vcpus */ struct vm *vm; -} __aligned(PAGE_SIZE); +}; CTASSERT((offsetof(struct svm_softc, nptp) & PAGE_MASK) == 0); From owner-svn-src-stable-11@freebsd.org Sun Feb 4 14:00:38 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D78EBED80F5; Sun, 4 Feb 2018 14:00:38 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8D79E811FC; Sun, 4 Feb 2018 14:00:38 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 885FC1B024; Sun, 4 Feb 2018 14:00:38 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w14E0c4B038415; Sun, 4 Feb 2018 14:00:38 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w14E0c6h038414; Sun, 4 Feb 2018 14:00:38 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201802041400.w14E0c6h038414@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Sun, 4 Feb 2018 14:00:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328847 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 328847 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Feb 2018 14:00:39 -0000 Author: avg Date: Sun Feb 4 14:00:38 2018 New Revision: 328847 URL: https://svnweb.freebsd.org/changeset/base/328847 Log: MFC r328126: correct read-ahead calculations in vfs_bio_getpages Modified: stable/11/sys/kern/vfs_bio.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/vfs_bio.c ============================================================================== --- stable/11/sys/kern/vfs_bio.c Sun Feb 4 13:58:31 2018 (r328846) +++ stable/11/sys/kern/vfs_bio.c Sun Feb 4 14:00:38 2018 (r328847) @@ -4764,7 +4764,14 @@ vfs_bio_getpages(struct vnode *vp, vm_page_t *ma, int la = IDX_TO_OFF(ma[count - 1]->pindex); if (la >= object->un_pager.vnp.vnp_size) return (VM_PAGER_BAD); - lpart = la + PAGE_SIZE > object->un_pager.vnp.vnp_size; + + /* + * Change the meaning of la from where the last requested page starts + * to where it ends, because that's the end of the requested region + * and the start of the potential read-ahead region. + */ + la += PAGE_SIZE; + lpart = la > object->un_pager.vnp.vnp_size; bo_bs = get_blksize(vp, get_lblkno(vp, IDX_TO_OFF(ma[0]->pindex))); /* From owner-svn-src-stable-11@freebsd.org Sun Feb 4 13:57:16 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7CE8DED7FC8; Sun, 4 Feb 2018 13:57:16 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 32CC580DDE; Sun, 4 Feb 2018 13:57:16 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 299031B013; Sun, 4 Feb 2018 13:57:16 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w14DvFL7037186; Sun, 4 Feb 2018 13:57:15 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w14DvFWf037185; Sun, 4 Feb 2018 13:57:15 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201802041357.w14DvFWf037185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Sun, 4 Feb 2018 13:57:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328844 - stable/11/sys/dev/amdsbwd X-SVN-Group: stable-11 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/11/sys/dev/amdsbwd X-SVN-Commit-Revision: 328844 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Feb 2018 13:57:16 -0000 Author: avg Date: Sun Feb 4 13:57:15 2018 New Revision: 328844 URL: https://svnweb.freebsd.org/changeset/base/328844 Log: MFC r327775: amdsbwd: fix handling of timeout values beyond the supported range Modified: stable/11/sys/dev/amdsbwd/amdsbwd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/amdsbwd/amdsbwd.c ============================================================================== --- stable/11/sys/dev/amdsbwd/amdsbwd.c Sun Feb 4 13:55:20 2018 (r328843) +++ stable/11/sys/dev/amdsbwd/amdsbwd.c Sun Feb 4 13:57:15 2018 (r328844) @@ -208,21 +208,30 @@ static void amdsbwd_event(void *arg, unsigned int cmd, int *error) { struct amdsbwd_softc *sc = arg; - unsigned int timeout; + uint64_t timeout; - /* convert from power-of-two-ns to WDT ticks */ - cmd &= WD_INTERVAL; - if (cmd < WD_TO_1SEC) - cmd = 0; - if (cmd) { - timeout = ((uint64_t)1 << (cmd - WD_TO_1MS)) / sc->ms_per_tick; + if (cmd != 0) { + timeout = 0; + cmd &= WD_INTERVAL; + if (cmd >= WD_TO_1MS) { + timeout = (uint64_t)1 << (cmd - WD_TO_1MS); + timeout = timeout / sc->ms_per_tick; + } + /* For a too short timeout use 1 tick. */ + if (timeout == 0) + timeout = 1; + /* For a too long timeout stop the timer. */ if (timeout > sc->max_ticks) - timeout = sc->max_ticks; - if (timeout != sc->timeout) { + timeout = 0; + } else { + timeout = 0; + } + + if (timeout != 0) { + if (timeout != sc->timeout) amdsbwd_tmr_set(sc, timeout); - if (!sc->active) - amdsbwd_tmr_enable(sc); - } + if (!sc->active) + amdsbwd_tmr_enable(sc); amdsbwd_tmr_reload(sc); *error = 0; } else { From owner-svn-src-stable-11@freebsd.org Sun Feb 4 17:38:46 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5BE8CEE3A77; Sun, 4 Feb 2018 17:38:46 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 09B8C6A04D; Sun, 4 Feb 2018 17:38:46 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E04AA1D33B; Sun, 4 Feb 2018 17:38:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w14Hcj81047644; Sun, 4 Feb 2018 17:38:45 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w14HcjmK047643; Sun, 4 Feb 2018 17:38:45 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802041738.w14HcjmK047643@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 4 Feb 2018 17:38:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328854 - stable/11 X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11 X-SVN-Commit-Revision: 328854 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Feb 2018 17:38:46 -0000 Author: kevans Date: Sun Feb 4 17:38:45 2018 New Revision: 328854 URL: https://svnweb.freebsd.org/changeset/base/328854 Log: Record svn:mergeinfo for r328853 r328853 was actually a forward-port of r328836 (emaste) from stable/11. Record mergeinfo so it doesn't pop back up during MFC efforts. Modified: Directory Properties: stable/11/ (props changed) From owner-svn-src-stable-11@freebsd.org Sun Feb 4 19:12:03 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E09DAEEA309; Sun, 4 Feb 2018 19:12:03 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 979F06DE77; Sun, 4 Feb 2018 19:12:03 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 70B341E356; Sun, 4 Feb 2018 19:12:03 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w14JC3HP096641; Sun, 4 Feb 2018 19:12:03 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w14JC3Ls096640; Sun, 4 Feb 2018 19:12:03 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802041912.w14JC3Ls096640@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 4 Feb 2018 19:12:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328859 - stable/11 X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11 X-SVN-Commit-Revision: 328859 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Feb 2018 19:12:04 -0000 Author: kevans Date: Sun Feb 4 19:12:03 2018 New Revision: 328859 URL: https://svnweb.freebsd.org/changeset/base/328859 Log: Record svn:mergeinfo from r326934 r326934 effectively MFC'd r326752 and r326754 with a direct commit to stable/11 due to path restructuring in HEAD. Modified: Directory Properties: stable/11/ (props changed) From owner-svn-src-stable-11@freebsd.org Mon Feb 5 04:01:02 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 52401EED763; Mon, 5 Feb 2018 04:01:02 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0118A802E1; Mon, 5 Feb 2018 04:01:02 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EFCA6237E3; Mon, 5 Feb 2018 04:01:01 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w15411j6059217; Mon, 5 Feb 2018 04:01:01 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w154102i058511; Mon, 5 Feb 2018 04:01:00 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802050401.w154102i058511@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 5 Feb 2018 04:01:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328866 - in stable/11/sys: boot/efi/boot1 boot/efi/loader boot/i386/boot2 boot/i386/gptboot boot/i386/gptzfsboot boot/i386/zfsboot boot/userboot/ficl boot/userboot/userboot boot/userbo... X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11/sys: boot/efi/boot1 boot/efi/loader boot/i386/boot2 boot/i386/gptboot boot/i386/gptzfsboot boot/i386/zfsboot boot/userboot/ficl boot/userboot/userboot boot/userboot/zfs boot/zfs cddl/boot... X-SVN-Commit-Revision: 328866 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2018 04:01:02 -0000 Author: kevans Date: Mon Feb 5 04:00:59 2018 New Revision: 328866 URL: https://svnweb.freebsd.org/changeset/base/328866 Log: MFC r304321,304753,304754,306751,316077,316110: SHA512, skein, large block support for loader zfs MFC r304321: Add SHA512, skein, large blocks support for loader zfs. MFC r304753: loader: zio_checksum_verify() must test spa for NULL pointer MFC r304754: r304321 broken bhyve zvol VM bhyveload hang 100% WCPU MFC r306751: Disable loop unrolling in skein for sys/boot MFC r316077: Unbreak compilation with gcc 4.2.1 MFC r316110: Use `-Wno-missing-declarations` with CWARNFLAGS for skein.c Added: stable/11/sys/cddl/boot/zfs/skein_zfs.c - copied unchanged from r304321, head/sys/cddl/boot/zfs/skein_zfs.c Modified: stable/11/sys/boot/efi/boot1/Makefile stable/11/sys/boot/efi/loader/Makefile stable/11/sys/boot/i386/boot2/Makefile stable/11/sys/boot/i386/gptboot/Makefile stable/11/sys/boot/i386/gptboot/gptldr.S stable/11/sys/boot/i386/gptzfsboot/Makefile stable/11/sys/boot/i386/zfsboot/Makefile stable/11/sys/boot/i386/zfsboot/zfsboot.c stable/11/sys/boot/i386/zfsboot/zfsldr.S stable/11/sys/boot/userboot/ficl/Makefile stable/11/sys/boot/userboot/userboot/Makefile stable/11/sys/boot/userboot/userboot/main.c stable/11/sys/boot/userboot/zfs/Makefile stable/11/sys/boot/zfs/Makefile stable/11/sys/boot/zfs/zfsimpl.c stable/11/sys/cddl/boot/zfs/fletcher.c stable/11/sys/cddl/boot/zfs/sha256.c stable/11/sys/cddl/boot/zfs/zfsimpl.h stable/11/sys/cddl/boot/zfs/zfssubr.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/boot/efi/boot1/Makefile ============================================================================== --- stable/11/sys/boot/efi/boot1/Makefile Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/efi/boot1/Makefile Mon Feb 5 04:00:59 2018 (r328866) @@ -19,12 +19,22 @@ CWARNFLAGS.zfs_module.c += -Wno-missing-prototypes CWARNFLAGS.zfs_module.c += -Wno-sign-compare CWARNFLAGS.zfs_module.c += -Wno-unused-parameter CWARNFLAGS.zfs_module.c += -Wno-unused-function +CWARNFLAGS.skein.c += -Wno-cast-align +.if ${COMPILER_TYPE} == "clang" +CWARNFLAGS.skein.c += -Wno-missing-variable-declarations +.else if ${COMPILER_TYPE} == "gcc" +CWARNFLAGS.skein.c += -Wno-missing-declarations .endif +.endif # architecture-specific loader code SRCS= boot1.c self_reloc.c start.S ufs_module.c .if ${MK_ZFS} != "no" SRCS+= zfs_module.c +SRCS+= skein.c skein_block.c +# Do not unroll skein loops, reduce code size +CFLAGS+= -DSKEIN_LOOP=111 +.PATH: ${.CURDIR}/../../../crypto/skein .endif .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201 @@ -44,6 +54,7 @@ CFLAGS+= -DEFI_DEBUG .if ${MK_ZFS} != "no" CFLAGS+= -I${.CURDIR}/../../zfs/ CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs/ +CFLAGS+= -I${.CURDIR}/../../../crypto/skein CFLAGS+= -DEFI_ZFS_BOOT .endif Modified: stable/11/sys/boot/efi/loader/Makefile ============================================================================== --- stable/11/sys/boot/efi/loader/Makefile Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/efi/loader/Makefile Mon Feb 5 04:00:59 2018 (r328866) @@ -24,6 +24,10 @@ SRCS= autoload.c \ .if ${MK_ZFS} != "no" SRCS+= zfs.c .PATH: ${.CURDIR}/../../zfs +SRCS+= skein.c skein_block.c +# Do not unroll skein loops, reduce code size +CFLAGS+= -DSKEIN_LOOP=111 +.PATH: ${.CURDIR}/../../../crypto/skein # Disable warnings that are currently incompatible with the zfs boot code CWARNFLAGS.zfs.c+= -Wno-sign-compare @@ -57,6 +61,7 @@ CFLAGS+= -I${.CURDIR}/../../i386/libi386 .if ${MK_ZFS} != "no" CFLAGS+= -I${.CURDIR}/../../zfs CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs +CFLAGS+= -I${.CURDIR}/../../../crypto/skein CFLAGS+= -DEFI_ZFS_BOOT .endif CFLAGS+= -DNO_PCI -DEFI Modified: stable/11/sys/boot/i386/boot2/Makefile ============================================================================== --- stable/11/sys/boot/i386/boot2/Makefile Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/i386/boot2/Makefile Mon Feb 5 04:00:59 2018 (r328866) @@ -33,7 +33,7 @@ CFLAGS= -fomit-frame-pointer \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ -I${.CURDIR}/../../common \ -I${.CURDIR}/../btx/lib -I. \ - -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ + -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ -Winline Modified: stable/11/sys/boot/i386/gptboot/Makefile ============================================================================== --- stable/11/sys/boot/i386/gptboot/Makefile Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/i386/gptboot/Makefile Mon Feb 5 04:00:59 2018 (r328866) @@ -32,10 +32,10 @@ CFLAGS= -DBOOTPROG=\"gptboot\" \ -I${.CURDIR}/../btx/lib -I. \ -I${.CURDIR}/../boot2 \ -I${.CURDIR}/../../.. \ - -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ + -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ - -Winline + -Winline -Wno-pointer-sign CFLAGS.gcc+= --param max-inline-insns-single=100 Modified: stable/11/sys/boot/i386/gptboot/gptldr.S ============================================================================== --- stable/11/sys/boot/i386/gptboot/gptldr.S Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/i386/gptboot/gptldr.S Mon Feb 5 04:00:59 2018 (r328866) @@ -45,7 +45,7 @@ /* Misc. Constants */ .set SIZ_PAG,0x1000 # Page size .set SIZ_SEC,0x200 # Sector size - .set COPY_BLKS,0x4 # Number of blocks + .set COPY_BLKS,0x8 # Number of blocks # to copy for boot2 .set COPY_BLK_SZ,0x8000 # Copy in 32k blocks; must be # a multiple of 16 bytes Modified: stable/11/sys/boot/i386/gptzfsboot/Makefile ============================================================================== --- stable/11/sys/boot/i386/gptzfsboot/Makefile Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/i386/gptzfsboot/Makefile Mon Feb 5 04:00:59 2018 (r328866) @@ -1,8 +1,10 @@ # $FreeBSD$ +.include + .PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../gptboot \ ${.CURDIR}/../zfsboot ${.CURDIR}/../common \ - ${.CURDIR}/../../common + ${.CURDIR}/../../common ${.CURDIR}/../../../crypto/skein FILES= gptzfsboot MAN= gptzfsboot.8 @@ -27,14 +29,23 @@ CFLAGS= -DBOOTPROG=\"gptzfsboot\" \ -I${.CURDIR}/../common \ -I${.CURDIR}/../../zfs \ -I${.CURDIR}/../../../cddl/boot/zfs \ + -I${.CURDIR}/../../../crypto/skein \ -I${.CURDIR}/../btx/lib -I. \ -I${.CURDIR}/../boot2 \ -I${.CURDIR}/../../.. \ - -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ + -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ - -Winline + -Winline -Wno-pointer-sign +.if ${COMPILER_TYPE} == "clang" || \ + (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201) +CFLAGS+= -Wno-tentative-definition-incomplete-type +.endif + +# Do not unroll skein loops, reduce code size +CFLAGS+= -DSKEIN_LOOP=111 + .if !defined(LOADER_NO_GELI_SUPPORT) CFLAGS+= -DLOADER_GELI_SUPPORT CFLAGS+= -I${.CURDIR}/../../geli @@ -67,12 +78,13 @@ gptldr.out: gptldr.o ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o CLEANFILES+= gptzfsboot.bin gptzfsboot.out zfsboot.o sio.o cons.o \ - drv.o gpt.o util.o ${OPENCRYPTO_XTS} + drv.o gpt.o util.o skein.o skein_block.o ${OPENCRYPTO_XTS} gptzfsboot.bin: gptzfsboot.out ${OBJCOPY} -S -O binary gptzfsboot.out ${.TARGET} -gptzfsboot.out: ${BTXCRT} zfsboot.o sio.o gpt.o drv.o cons.o util.o ${OPENCRYPTO_XTS} +gptzfsboot.out: ${BTXCRT} zfsboot.o sio.o gpt.o drv.o cons.o util.o \ + skein.o skein_block.o ${OPENCRYPTO_XTS} ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND} ${LIBGELIBOOT} zfsboot.o: ${.CURDIR}/../../zfs/zfsimpl.c Modified: stable/11/sys/boot/i386/zfsboot/Makefile ============================================================================== --- stable/11/sys/boot/i386/zfsboot/Makefile Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/i386/zfsboot/Makefile Mon Feb 5 04:00:59 2018 (r328866) @@ -1,6 +1,7 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common +.PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../common \ + ${.CURDIR}/../../common ${.CURDIR}/../../../crypto/skein FILES= zfsboot MAN= zfsboot.8 @@ -25,14 +26,17 @@ CFLAGS= -DBOOTPROG=\"zfsboot\" \ -I${.CURDIR}/../common \ -I${.CURDIR}/../../zfs \ -I${.CURDIR}/../../../cddl/boot/zfs \ + -I${.CURDIR}/../../../crypto/skein \ -I${.CURDIR}/../btx/lib -I. \ -I${.CURDIR}/../boot2 \ - -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ + -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ -Winline CFLAGS.gcc+= --param max-inline-insns-single=100 +# Do not unroll skein loops, reduce code size +CFLAGS+= -DSKEIN_LOOP=111 LD_FLAGS=-static -N --gc-sections @@ -55,12 +59,13 @@ zfsldr.out: zfsldr.o ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} zfsldr.o CLEANFILES+= zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \ - zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o util.o + zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o util.o \ + skein.o skein_block.o -# We currently allow 65536 bytes for zfsboot - in practice it could be +# We currently allow 128k bytes for zfsboot - in practice it could be # any size up to 3.5Mb but keeping it fixed size simplifies zfsldr. # -BOOT2SIZE= 65536 +BOOT2SIZE= 131072 zfsboot2: zfsboot.ld @set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \ @@ -77,7 +82,7 @@ zfsboot.ldr: zfsboot.bin: zfsboot.out ${OBJCOPY} -S -O binary zfsboot.out ${.TARGET} -zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o util.o +zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o util.o skein.o skein_block.o ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND} SRCS= zfsboot.c Modified: stable/11/sys/boot/i386/zfsboot/zfsboot.c ============================================================================== --- stable/11/sys/boot/i386/zfsboot/zfsboot.c Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/i386/zfsboot/zfsboot.c Mon Feb 5 04:00:59 2018 (r328866) @@ -105,7 +105,7 @@ static struct bios_smap smap; /* * The minimum amount of memory to reserve in bios_extmem for the heap. */ -#define HEAP_MIN (3 * 1024 * 1024) +#define HEAP_MIN (64 * 1024 * 1024) static char *heap_next; static char *heap_end; Modified: stable/11/sys/boot/i386/zfsboot/zfsldr.S ============================================================================== --- stable/11/sys/boot/i386/zfsboot/zfsldr.S Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/i386/zfsboot/zfsldr.S Mon Feb 5 04:00:59 2018 (r328866) @@ -32,8 +32,11 @@ /* Misc. Constants */ .set SIZ_PAG,0x1000 # Page size .set SIZ_SEC,0x200 # Sector size - - .set NSECT,0x80 + .set COPY_BLKS,0x8 # Number of blocks + # to copy for boot2 + .set COPY_BLK_SZ,0x8000 # Copy in 32k blocks; must be + # a multiple of 16 bytes + .set NSECT,(COPY_BLK_SZ / SIZ_SEC * COPY_BLKS) .globl start .code16 @@ -88,12 +91,12 @@ main.3: add $0x10,%si # Next entry /* * Ok, we have a slice and drive in %dx now, so use that to locate and * load boot2. %si references the start of the slice we are looking - * for, so go ahead and load up the 128 sectors starting at sector 1024 - * (i.e. after the two vdev labels). We don't have do anything fancy - * here to allow for an extra copy of boot1 and a partition table - * (compare to this section of the UFS bootstrap) so we just load it - * all at 0x9000. The first part of boot2 is BTX, which wants to run - * at 0x9000. The boot2.bin binary starts right after the end of BTX, + * for, so go ahead and load up the COPY_BLKS*COPY_BLK_SZ/SIZ_SEC sectors + * starting at sector 1024 (i.e. after the two vdev labels). We don't + * have do anything fancy here to allow for an extra copy of boot1 and + * a partition table (compare to this section of the UFS bootstrap) so we + * just load it all at 0x9000. The first part of boot2 is BTX, which wants + * to run at 0x9000. The boot2.bin binary starts right after the end of BTX, * so we have to figure out where the start of it is and then move the * binary to 0xc000. Normally, BTX clients start at MEM_USR, or 0xa000, * but when we use btxld to create zfsboot2, we use an entry point of @@ -116,23 +119,37 @@ main.6: pushal # Save params incl %eax # Advance to add $SIZ_SEC,%ebx # next sector loop main.6 # If not last, read another - mov MEM_BTX+0xa,%bx # Get BTX length - mov $NSECT*SIZ_SEC-1,%di # Size of load area (less one) - mov %di,%si # End of load area, 0x9000 rel - sub %bx,%di # End of client, 0xc000 rel - mov %di,%cx # Size of - inc %cx # client - mov $(MEM_BTX)>>4,%dx # Segment - mov %dx,%ds # addressing 0x9000 - mov $(MEM_USR+2*SIZ_PAG)>>4,%dx # Segment - mov %dx,%es # addressing 0xc000 - std # Move with decrement - rep # Relocate - movsb # client + + mov $MEM_BTX,%bx # BTX + mov 0xa(%bx),%si # Get BTX length and set + add %bx,%si # %si to start of boot2 + dec %si # Set %ds:%si to point at the + mov %si,%ax # last byte we want to copy + shr $4,%ax # from boot2, with %si made as + add $(COPY_BLKS*COPY_BLK_SZ/16),%ax # small as possible. + and $0xf,%si # + mov %ax,%ds # + mov $(MEM_USR+2*SIZ_PAG)/16,%ax # Set %es:(-1) to point at + add $(COPY_BLKS*COPY_BLK_SZ/16),%ax # the last byte we + mov %ax,%es # want to copy boot2 into. + mov $COPY_BLKS,%bx # Copy COPY_BLKS 32k blocks +copyloop: + add $COPY_BLK_SZ,%si # Adjust %ds:%si to point at + mov %ds,%ax # the end of the next 32k to + sub $COPY_BLK_SZ/16,%ax # copy from boot2 + mov %ax,%ds + mov $COPY_BLK_SZ-1,%di # Adjust %es:%di to point at + mov %es,%ax # the end of the next 32k into + sub $COPY_BLK_SZ/16,%ax # which we want boot2 copied + mov %ax,%es + mov $COPY_BLK_SZ,%cx # Copy 32k + std + rep movsb + dec %bx + jnz copyloop + mov %cx,%ds # Reset %ds and %es + mov %cx,%es cld # Back to increment - xor %dx,%dx # Back - mov %ds,%dx # to zero - mov %dx,%es # segment /* * Enable A20 so we can access memory above 1 meg. Modified: stable/11/sys/boot/userboot/ficl/Makefile ============================================================================== --- stable/11/sys/boot/userboot/ficl/Makefile Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/userboot/ficl/Makefile Mon Feb 5 04:00:59 2018 (r328866) @@ -10,6 +10,9 @@ BASE_SRCS= dict.c ficl.c fileaccess.c float.c loader.c SRCS= ${BASE_SRCS} sysdep.c softcore.c CLEANFILES= softcore.c testmain testmain.o + +CWARNFLAGS.loader.c.c += -Wno-implicit-function-declaration + .if HAVE_PNP CFLAGS+= -DHAVE_PNP .endif Modified: stable/11/sys/boot/userboot/userboot/Makefile ============================================================================== --- stable/11/sys/boot/userboot/userboot/Makefile Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/userboot/userboot/Makefile Mon Feb 5 04:00:59 2018 (r328866) @@ -35,6 +35,8 @@ CFLAGS+= -I${.CURDIR}/../../.. CFLAGS+= -I${.CURDIR}/../../../../lib/libstand CFLAGS+= -ffreestanding -I. +CWARNFLAGS.main.c += -Wno-implicit-function-declaration + LDFLAGS+= -nostdlib -Wl,-Bsymbolic NEWVERSWHAT= "User boot" ${MACHINE_CPUARCH} Modified: stable/11/sys/boot/userboot/userboot/main.c ============================================================================== --- stable/11/sys/boot/userboot/userboot/main.c Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/userboot/userboot/main.c Mon Feb 5 04:00:59 2018 (r328866) @@ -46,7 +46,7 @@ static int userboot_zfs_found; /* Minimum version required */ #define USERBOOT_VERSION USERBOOT_VERSION_3 -#define MALLOCSZ (10*1024*1024) +#define MALLOCSZ (64*1024*1024) struct loader_callbacks *callbacks; void *callbacks_arg; Modified: stable/11/sys/boot/userboot/zfs/Makefile ============================================================================== --- stable/11/sys/boot/userboot/zfs/Makefile Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/userboot/zfs/Makefile Mon Feb 5 04:00:59 2018 (r328866) @@ -2,15 +2,19 @@ S= ${.CURDIR}/../../zfs -.PATH: ${S} +.PATH: ${S} ${.CURDIR}/../../../crypto/skein LIB= zfsboot INTERNALLIB= -SRCS+= zfs.c +SRCS+= zfs.c skein.c skein_block.c +# Do not unroll skein loops, reduce code size +CFLAGS+= -DSKEIN_LOOP=111 + CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I. CFLAGS+= -I${.CURDIR}/../../../../lib/libstand CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs +CFLAGS+= -I${.CURDIR}/../../../crypto/skein CFLAGS+= -ffreestanding -fPIC CFLAGS+= -Wformat -Wall Modified: stable/11/sys/boot/zfs/Makefile ============================================================================== --- stable/11/sys/boot/zfs/Makefile Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/zfs/Makefile Mon Feb 5 04:00:59 2018 (r328866) @@ -5,10 +5,16 @@ INTERNALLIB= SRCS+= zfs.c +SRCS+= skein.c skein_block.c +# Do not unroll skein loops, reduce code size +CFLAGS+= -DSKEIN_LOOP=111 +.PATH: ${.CURDIR}/../../crypto/skein + CFLAGS+= -DBOOTPROG=\"zfsloader\" CFLAGS+= -I${.CURDIR}/../common -I${.CURDIR}/../.. -I. CFLAGS+= -I${.CURDIR}/../../../lib/libstand CFLAGS+= -I${.CURDIR}/../../cddl/boot/zfs +CFLAGS+= -I${.CURDIR}/../../crypto/skein .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" CFLAGS+= -march=i386 Modified: stable/11/sys/boot/zfs/zfsimpl.c ============================================================================== --- stable/11/sys/boot/zfs/zfsimpl.c Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/boot/zfs/zfsimpl.c Mon Feb 5 04:00:59 2018 (r328866) @@ -58,6 +58,8 @@ static const char *features_for_read[] = { "com.delphix:extensible_dataset", "com.delphix:embedded_data", "org.open-zfs:large_blocks", + "org.illumos:sha512", + "org.illumos:skein", NULL }; @@ -77,6 +79,9 @@ static char *zfs_temp_buf, *zfs_temp_end, *zfs_temp_pt static int zio_read(const spa_t *spa, const blkptr_t *bp, void *buf); static int zfs_get_root(const spa_t *spa, uint64_t *objid); static int zfs_rlookup(const spa_t *spa, uint64_t objnum, char *result); +static int zap_lookup(const spa_t *spa, const dnode_phys_t *dnode, + const char *name, uint64_t integer_size, uint64_t num_integers, + void *value); static void zfs_init(void) @@ -419,7 +424,7 @@ vdev_read_phys(vdev_t *vdev, const blkptr_t *bp, void rc = vdev->v_phys_read(vdev, vdev->v_read_priv, offset, buf, psize); if (rc) return (rc); - if (bp && zio_checksum_verify(bp, buf)) + if (bp && zio_checksum_verify(vdev->spa, bp, buf)) return (EIO); return (0); @@ -1073,6 +1078,7 @@ vdev_probe(vdev_phys_read_t *_read, void *read_priv, s } zfs_free(upbuf, VDEV_UBERBLOCK_SIZE(vdev)); + vdev->spa = spa; if (spap) *spap = spa; return (0); @@ -1121,7 +1127,7 @@ zio_read_gang(const spa_t *spa, const blkptr_t *bp, vo pbuf += BP_GET_PSIZE(gbp); } - if (zio_checksum_verify(bp, buf)) + if (zio_checksum_verify(spa, bp, buf)) return (EIO); return (0); } @@ -1223,7 +1229,8 @@ dnode_read(const spa_t *spa, const dnode_phys_t *dnode int i, rc; if (bsize > SPA_MAXBLOCKSIZE) { - printf("ZFS: I/O error - blocks larger than 128K are not supported\n"); + printf("ZFS: I/O error - blocks larger than %llu are not " + "supported\n", SPA_MAXBLOCKSIZE); return (EIO); } @@ -1363,12 +1370,73 @@ fzap_leaf_value(const zap_leaf_t *zl, const zap_leaf_c return value; } +static void +stv(int len, void *addr, uint64_t value) +{ + switch (len) { + case 1: + *(uint8_t *)addr = value; + return; + case 2: + *(uint16_t *)addr = value; + return; + case 4: + *(uint32_t *)addr = value; + return; + case 8: + *(uint64_t *)addr = value; + return; + } +} + /* + * Extract a array from a zap leaf entry. + */ +static void +fzap_leaf_array(const zap_leaf_t *zl, const zap_leaf_chunk_t *zc, + uint64_t integer_size, uint64_t num_integers, void *buf) +{ + uint64_t array_int_len = zc->l_entry.le_value_intlen; + uint64_t value = 0; + uint64_t *u64 = buf; + char *p = buf; + int len = MIN(zc->l_entry.le_value_numints, num_integers); + int chunk = zc->l_entry.le_value_chunk; + int byten = 0; + + if (integer_size == 8 && len == 1) { + *u64 = fzap_leaf_value(zl, zc); + return; + } + + while (len > 0) { + struct zap_leaf_array *la = &ZAP_LEAF_CHUNK(zl, chunk).l_array; + int i; + + ASSERT3U(chunk, <, ZAP_LEAF_NUMCHUNKS(zl)); + for (i = 0; i < ZAP_LEAF_ARRAY_BYTES && len > 0; i++) { + value = (value << 8) | la->la_array[i]; + byten++; + if (byten == array_int_len) { + stv(integer_size, p, value); + byten = 0; + len--; + if (len == 0) + return; + p += integer_size; + } + } + chunk = la->la_next; + } +} + +/* * Lookup a value in a fatzap directory. Assumes that the zap scratch * buffer contains the directory header. */ static int -fzap_lookup(const spa_t *spa, const dnode_phys_t *dnode, const char *name, uint64_t *value) +fzap_lookup(const spa_t *spa, const dnode_phys_t *dnode, const char *name, + uint64_t integer_size, uint64_t num_integers, void *value) { int bsize = dnode->dn_datablkszsec << SPA_MINBLOCKSHIFT; zap_phys_t zh = *(zap_phys_t *) zap_scratch; @@ -1435,9 +1503,10 @@ fzap_lookup(const spa_t *spa, const dnode_phys_t *dnod zc = &ZAP_LEAF_CHUNK(&zl, zc->l_entry.le_next); } if (fzap_name_equal(&zl, zc, name)) { - if (zc->l_entry.le_value_intlen * zc->l_entry.le_value_numints > 8) + if (zc->l_entry.le_value_intlen * zc->l_entry.le_value_numints > + integer_size * num_integers) return (E2BIG); - *value = fzap_leaf_value(&zl, zc); + fzap_leaf_array(&zl, zc, integer_size, num_integers, value); return (0); } @@ -1448,7 +1517,8 @@ fzap_lookup(const spa_t *spa, const dnode_phys_t *dnod * Lookup a name in a zap object and return its value as a uint64_t. */ static int -zap_lookup(const spa_t *spa, const dnode_phys_t *dnode, const char *name, uint64_t *value) +zap_lookup(const spa_t *spa, const dnode_phys_t *dnode, const char *name, + uint64_t integer_size, uint64_t num_integers, void *value) { int rc; uint64_t zap_type; @@ -1461,8 +1531,10 @@ zap_lookup(const spa_t *spa, const dnode_phys_t *dnode zap_type = *(uint64_t *) zap_scratch; if (zap_type == ZBT_MICRO) return mzap_lookup(dnode, name, value); - else if (zap_type == ZBT_HEADER) - return fzap_lookup(spa, dnode, name, value); + else if (zap_type == ZBT_HEADER) { + return fzap_lookup(spa, dnode, name, integer_size, + num_integers, value); + } printf("ZFS: invalid zap_type=%d\n", (int)zap_type); return (EIO); } @@ -1801,7 +1873,8 @@ zfs_lookup_dataset(const spa_t *spa, const char *name, if (objset_get_dnode(spa, &spa->spa_mos, DMU_POOL_DIRECTORY_OBJECT, &dir)) return (EIO); - if (zap_lookup(spa, &dir, DMU_POOL_ROOT_DATASET, &dir_obj)) + if (zap_lookup(spa, &dir, DMU_POOL_ROOT_DATASET, sizeof (dir_obj), + 1, &dir_obj)) return (EIO); p = name; @@ -1831,7 +1904,8 @@ zfs_lookup_dataset(const spa_t *spa, const char *name, return (EIO); /* Actual loop condition #2. */ - if (zap_lookup(spa, &child_dir_zap, element, &dir_obj) != 0) + if (zap_lookup(spa, &child_dir_zap, element, sizeof (dir_obj), + 1, &dir_obj) != 0) return (ENOENT); } @@ -1961,9 +2035,9 @@ zfs_get_root(const spa_t *spa, uint64_t *objid) /* * Lookup the pool_props and see if we can find a bootfs. */ - if (zap_lookup(spa, &dir, DMU_POOL_PROPS, &props) == 0 + if (zap_lookup(spa, &dir, DMU_POOL_PROPS, sizeof (props), 1, &props) == 0 && objset_get_dnode(spa, &spa->spa_mos, props, &propdir) == 0 - && zap_lookup(spa, &propdir, "bootfs", &bootfs) == 0 + && zap_lookup(spa, &propdir, "bootfs", sizeof (bootfs), 1, &bootfs) == 0 && bootfs != 0) { *objid = bootfs; @@ -1972,7 +2046,7 @@ zfs_get_root(const spa_t *spa, uint64_t *objid) /* * Lookup the root dataset directory */ - if (zap_lookup(spa, &dir, DMU_POOL_ROOT_DATASET, &root) + if (zap_lookup(spa, &dir, DMU_POOL_ROOT_DATASET, sizeof (root), 1, &root) || objset_get_dnode(spa, &spa->spa_mos, root, &dir)) { printf("ZFS: can't find root dsl_dir\n"); return (EIO); @@ -2046,7 +2120,8 @@ check_mos_features(const spa_t *spa) if ((rc = objset_get_dnode(spa, &spa->spa_mos, DMU_OT_OBJECT_DIRECTORY, &dir)) != 0) return (rc); - if ((rc = zap_lookup(spa, &dir, DMU_POOL_FEATURES_FOR_READ, &objnum)) != 0) { + if ((rc = zap_lookup(spa, &dir, DMU_POOL_FEATURES_FOR_READ, + sizeof (objnum), 1, &objnum)) != 0) { /* * It is older pool without features. As we have already * tested the label, just return without raising the error. @@ -2076,6 +2151,7 @@ check_mos_features(const spa_t *spa) static int zfs_spa_init(spa_t *spa) { + dnode_phys_t dir; int rc; if (zio_read(spa, &spa->spa_uberblock.ub_rootbp, &spa->spa_mos)) { @@ -2087,6 +2163,17 @@ zfs_spa_init(spa_t *spa) return (EIO); } + if (objset_get_dnode(spa, &spa->spa_mos, DMU_POOL_DIRECTORY_OBJECT, + &dir)) { + printf("ZFS: failed to read pool %s directory object\n", + spa->spa_name); + return (EIO); + } + /* this is allowed to fail, older pools do not have salt */ + rc = zap_lookup(spa, &dir, DMU_POOL_CHECKSUM_SALT, 1, + sizeof (spa->spa_cksum_salt.zcs_bytes), + spa->spa_cksum_salt.zcs_bytes); + rc = check_mos_features(spa); if (rc != 0) { printf("ZFS: pool %s is not supported\n", spa->spa_name); @@ -2239,7 +2326,7 @@ zfs_lookup(const struct zfsmount *mount, const char *u return (rc); } - rc = zap_lookup(spa, &dn, ZFS_ROOT_OBJ, &objnum); + rc = zap_lookup(spa, &dn, ZFS_ROOT_OBJ, sizeof (objnum), 1, &objnum); if (rc) { free(entry); return (rc); @@ -2299,7 +2386,7 @@ zfs_lookup(const struct zfsmount *mount, const char *u goto done; } - rc = zap_lookup(spa, &dn, element, &objnum); + rc = zap_lookup(spa, &dn, element, sizeof (objnum), 1, &objnum); if (rc) goto done; objnum = ZFS_DIRENT_OBJ(objnum); Modified: stable/11/sys/cddl/boot/zfs/fletcher.c ============================================================================== --- stable/11/sys/cddl/boot/zfs/fletcher.c Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/cddl/boot/zfs/fletcher.c Mon Feb 5 04:00:59 2018 (r328866) @@ -23,10 +23,9 @@ * Use is subject to license terms. */ -/*#pragma ident "%Z%%M% %I% %E% SMI"*/ - static void -fletcher_2_native(const void *buf, uint64_t size, zio_cksum_t *zcp) +fletcher_2_native(const void *buf, uint64_t size, + const void *ctx_template __unused, zio_cksum_t *zcp) { const uint64_t *ip = buf; const uint64_t *ipend = ip + (size / sizeof (uint64_t)); @@ -43,7 +42,8 @@ fletcher_2_native(const void *buf, uint64_t size, zio_ } static void -fletcher_2_byteswap(const void *buf, uint64_t size, zio_cksum_t *zcp) +fletcher_2_byteswap(const void *buf, uint64_t size, + const void *ctx_template __unused, zio_cksum_t *zcp) { const uint64_t *ip = buf; const uint64_t *ipend = ip + (size / sizeof (uint64_t)); @@ -60,7 +60,8 @@ fletcher_2_byteswap(const void *buf, uint64_t size, zi } static void -fletcher_4_native(const void *buf, uint64_t size, zio_cksum_t *zcp) +fletcher_4_native(const void *buf, uint64_t size, + const void *ctx_template __unused, zio_cksum_t *zcp) { const uint32_t *ip = buf; const uint32_t *ipend = ip + (size / sizeof (uint32_t)); @@ -77,7 +78,8 @@ fletcher_4_native(const void *buf, uint64_t size, zio_ } static void -fletcher_4_byteswap(const void *buf, uint64_t size, zio_cksum_t *zcp) +fletcher_4_byteswap(const void *buf, uint64_t size, + const void *ctx_template __unused, zio_cksum_t *zcp) { const uint32_t *ip = buf; const uint32_t *ipend = ip + (size / sizeof (uint32_t)); Modified: stable/11/sys/cddl/boot/zfs/sha256.c ============================================================================== --- stable/11/sys/cddl/boot/zfs/sha256.c Mon Feb 5 00:18:21 2018 (r328865) +++ stable/11/sys/cddl/boot/zfs/sha256.c Mon Feb 5 04:00:59 2018 (r328866) @@ -23,19 +23,21 @@ * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2013 Saso Kiselkov. All rights reserved. + * Copyright 2015 Toomas Soome + */ -/*#pragma ident "%Z%%M% %I% %E% SMI"*/ - /* - * SHA-256 checksum, as specified in FIPS 180-2, available at: + * SHA-256 and SHA-512/256 hashes, as specified in FIPS 180-4, available at: * http://csrc.nist.gov/cryptval * - * This is a very compact implementation of SHA-256. + * This is a very compact implementation of SHA-256 and SHA-512/256. * It is designed to be simple and portable, not to be fast. */ /* - * The literal definitions according to FIPS180-2 would be: + * The literal definitions according to FIPS180-4 would be: * * Ch(x, y, z) (((x) & (y)) ^ ((~(x)) & (z))) * Maj(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) @@ -44,12 +46,21 @@ */ #define Ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) #define Maj(x, y, z) (((x) & (y)) ^ ((z) & ((x) ^ (y)))) -#define Rot32(x, s) (((x) >> s) | ((x) << (32 - s))) -#define SIGMA0(x) (Rot32(x, 2) ^ Rot32(x, 13) ^ Rot32(x, 22)) -#define SIGMA1(x) (Rot32(x, 6) ^ Rot32(x, 11) ^ Rot32(x, 25)) -#define sigma0(x) (Rot32(x, 7) ^ Rot32(x, 18) ^ ((x) >> 3)) -#define sigma1(x) (Rot32(x, 17) ^ Rot32(x, 19) ^ ((x) >> 10)) +#define ROTR(x, n) (((x) >> (n)) | ((x) << ((sizeof (x) * NBBY)-(n)))) +/* SHA-224/256 operations */ +#define BIGSIGMA0_256(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22)) +#define BIGSIGMA1_256(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25)) +#define SIGMA0_256(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ ((x) >> 3)) +#define SIGMA1_256(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ ((x) >> 10)) + +/* SHA-384/512 operations */ +#define BIGSIGMA0_512(x) (ROTR((x), 28) ^ ROTR((x), 34) ^ ROTR((x), 39)) +#define BIGSIGMA1_512(x) (ROTR((x), 14) ^ ROTR((x), 18) ^ ROTR((x), 41)) +#define SIGMA0_512(x) (ROTR((x), 1) ^ ROTR((x), 8) ^ ((x) >> 7)) +#define SIGMA1_512(x) (ROTR((x), 19) ^ ROTR((x), 61) ^ ((x) >> 6)) + +/* SHA-256 round constants */ static const uint32_t SHA256_K[64] = { 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, @@ -69,46 +80,134 @@ static const uint32_t SHA256_K[64] = { 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 }; +/* SHA-512 round constants */ +static const uint64_t SHA512_K[80] = { + 0x428A2F98D728AE22ULL, 0x7137449123EF65CDULL, + 0xB5C0FBCFEC4D3B2FULL, 0xE9B5DBA58189DBBCULL, + 0x3956C25BF348B538ULL, 0x59F111F1B605D019ULL, + 0x923F82A4AF194F9BULL, 0xAB1C5ED5DA6D8118ULL, + 0xD807AA98A3030242ULL, 0x12835B0145706FBEULL, + 0x243185BE4EE4B28CULL, 0x550C7DC3D5FFB4E2ULL, + 0x72BE5D74F27B896FULL, 0x80DEB1FE3B1696B1ULL, + 0x9BDC06A725C71235ULL, 0xC19BF174CF692694ULL, + 0xE49B69C19EF14AD2ULL, 0xEFBE4786384F25E3ULL, + 0x0FC19DC68B8CD5B5ULL, 0x240CA1CC77AC9C65ULL, + 0x2DE92C6F592B0275ULL, 0x4A7484AA6EA6E483ULL, + 0x5CB0A9DCBD41FBD4ULL, 0x76F988DA831153B5ULL, + 0x983E5152EE66DFABULL, 0xA831C66D2DB43210ULL, + 0xB00327C898FB213FULL, 0xBF597FC7BEEF0EE4ULL, + 0xC6E00BF33DA88FC2ULL, 0xD5A79147930AA725ULL, + 0x06CA6351E003826FULL, 0x142929670A0E6E70ULL, + 0x27B70A8546D22FFCULL, 0x2E1B21385C26C926ULL, + 0x4D2C6DFC5AC42AEDULL, 0x53380D139D95B3DFULL, + 0x650A73548BAF63DEULL, 0x766A0ABB3C77B2A8ULL, + 0x81C2C92E47EDAEE6ULL, 0x92722C851482353BULL, + 0xA2BFE8A14CF10364ULL, 0xA81A664BBC423001ULL, + 0xC24B8B70D0F89791ULL, 0xC76C51A30654BE30ULL, + 0xD192E819D6EF5218ULL, 0xD69906245565A910ULL, + 0xF40E35855771202AULL, 0x106AA07032BBD1B8ULL, + 0x19A4C116B8D2D0C8ULL, 0x1E376C085141AB53ULL, + 0x2748774CDF8EEB99ULL, 0x34B0BCB5E19B48A8ULL, + 0x391C0CB3C5C95A63ULL, 0x4ED8AA4AE3418ACBULL, + 0x5B9CCA4F7763E373ULL, 0x682E6FF3D6B2B8A3ULL, + 0x748F82EE5DEFB2FCULL, 0x78A5636F43172F60ULL, + 0x84C87814A1F0AB72ULL, 0x8CC702081A6439ECULL, + 0x90BEFFFA23631E28ULL, 0xA4506CEBDE82BDE9ULL, + 0xBEF9A3F7B2C67915ULL, 0xC67178F2E372532BULL, + 0xCA273ECEEA26619CULL, 0xD186B8C721C0C207ULL, + 0xEADA7DD6CDE0EB1EULL, 0xF57D4F7FEE6ED178ULL, + 0x06F067AA72176FBAULL, 0x0A637DC5A2C898A6ULL, + 0x113F9804BEF90DAEULL, 0x1B710B35131C471BULL, + 0x28DB77F523047D84ULL, 0x32CAAB7B40C72493ULL, + 0x3C9EBE0A15C9BEBCULL, 0x431D67C49C100D4CULL, + 0x4CC5D4BECB3E42B6ULL, 0x597F299CFC657E2AULL, + 0x5FCB6FAB3AD6FAECULL, 0x6C44198C4A475817ULL +}; + static void SHA256Transform(uint32_t *H, const uint8_t *cp) { uint32_t a, b, c, d, e, f, g, h, t, T1, T2, W[64]; - for (t = 0; t < 16; t++, cp += 4) + /* copy chunk into the first 16 words of the message schedule */ + for (t = 0; t < 16; t++, cp += sizeof (uint32_t)) W[t] = (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | cp[3]; + /* extend the first 16 words into the remaining 48 words */ for (t = 16; t < 64; t++) - W[t] = sigma1(W[t - 2]) + W[t - 7] + - sigma0(W[t - 15]) + W[t - 16]; + W[t] = SIGMA1_256(W[t - 2]) + W[t - 7] + + SIGMA0_256(W[t - 15]) + W[t - 16]; + /* init working variables to the current hash value */ a = H[0]; b = H[1]; c = H[2]; d = H[3]; e = H[4]; f = H[5]; g = H[6]; h = H[7]; + /* iterate the compression function for all rounds of the hash */ for (t = 0; t < 64; t++) { - T1 = h + SIGMA1(e) + Ch(e, f, g) + SHA256_K[t] + W[t]; - T2 = SIGMA0(a) + Maj(a, b, c); + T1 = h + BIGSIGMA1_256(e) + Ch(e, f, g) + SHA256_K[t] + W[t]; + T2 = BIGSIGMA0_256(a) + Maj(a, b, c); h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; } + /* add the compressed chunk to the current hash value */ H[0] += a; H[1] += b; H[2] += c; H[3] += d; H[4] += e; H[5] += f; H[6] += g; H[7] += h; } static void -zio_checksum_SHA256(const void *buf, uint64_t size, zio_cksum_t *zcp) +SHA512Transform(uint64_t *H, const uint8_t *cp) { - uint32_t H[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; + uint64_t a, b, c, d, e, f, g, h, t, T1, T2, W[80]; + + /* copy chunk into the first 16 words of the message schedule */ + for (t = 0; t < 16; t++, cp += sizeof (uint64_t)) + W[t] = ((uint64_t)cp[0] << 56) | ((uint64_t)cp[1] << 48) | + ((uint64_t)cp[2] << 40) | ((uint64_t)cp[3] << 32) | + ((uint64_t)cp[4] << 24) | ((uint64_t)cp[5] << 16) | + ((uint64_t)cp[6] << 8) | (uint64_t)cp[7]; + + /* extend the first 16 words into the remaining 64 words */ + for (t = 16; t < 80; t++) + W[t] = SIGMA1_512(W[t - 2]) + W[t - 7] + + SIGMA0_512(W[t - 15]) + W[t - 16]; + + /* init working variables to the current hash value */ + a = H[0]; b = H[1]; c = H[2]; d = H[3]; + e = H[4]; f = H[5]; g = H[6]; h = H[7]; + + /* iterate the compression function for all rounds of the hash */ + for (t = 0; t < 80; t++) { + T1 = h + BIGSIGMA1_512(e) + Ch(e, f, g) + SHA512_K[t] + W[t]; + T2 = BIGSIGMA0_512(a) + Maj(a, b, c); + h = g; g = f; f = e; e = d + T1; + d = c; c = b; b = a; a = T1 + T2; + } + + /* add the compressed chunk to the current hash value */ + H[0] += a; H[1] += b; H[2] += c; H[3] += d; + H[4] += e; H[5] += f; H[6] += g; H[7] += h; +} + +/* + * Implements the SHA-224 and SHA-256 hash algos - to select between them + * pass the appropriate initial values of 'H' and truncate the last 32 bits + * in case of SHA-224. + */ +static void +SHA256(uint32_t *H, const void *buf, uint64_t size, zio_cksum_t *zcp) +{ uint8_t pad[128]; - int padsize = size & 63; - int i; + unsigned padsize = size & 63; + unsigned i, k; + /* process all blocks up to the last one */ for (i = 0; i < size - padsize; i += 64) SHA256Transform(H, (uint8_t *)buf + i); - for (i = 0; i < padsize; i++) - pad[i] = ((uint8_t *)buf)[i]; + /* process the last block and padding */ + for (k = 0; k < padsize; k++) + pad[k] = ((uint8_t *)buf)[k+i]; for (pad[padsize++] = 0x80; (padsize & 63) != 56; padsize++) pad[padsize] = 0; @@ -124,4 +223,103 @@ zio_checksum_SHA256(const void *buf, uint64_t size, zi (uint64_t)H[2] << 32 | H[3], (uint64_t)H[4] << 32 | H[5], (uint64_t)H[6] << 32 | H[7]); +} + +/* + * encode 64bit data in big-endian format. + */ +static void +Encode64(uint8_t *output, uint64_t *input, size_t len) +{ + size_t i, j; + for (i = 0, j = 0; j < len; i++, j += 8) { + output[j] = (input[i] >> 56) & 0xff; + output[j + 1] = (input[i] >> 48) & 0xff; + output[j + 2] = (input[i] >> 40) & 0xff; + output[j + 3] = (input[i] >> 32) & 0xff; + output[j + 4] = (input[i] >> 24) & 0xff; + output[j + 5] = (input[i] >> 16) & 0xff; + output[j + 6] = (input[i] >> 8) & 0xff; + output[j + 7] = input[i] & 0xff; + } +} + +/* + * Implements the SHA-384, SHA-512 and SHA-512/t hash algos - to select + * between them pass the appropriate initial values for 'H'. The output + * of this function is truncated to the first 256 bits that fit into 'zcp'. + */ +static void +SHA512(uint64_t *H, const void *buf, uint64_t size, zio_cksum_t *zcp) +{ + uint64_t c64[2]; + uint8_t pad[256]; + unsigned padsize = size & 127; + unsigned i, k; + + /* process all blocks up to the last one */ + for (i = 0; i < size - padsize; i += 128) + SHA512Transform(H, (uint8_t *)buf + i); + + /* process the last block and padding */ + for (k = 0; k < padsize; k++) + pad[k] = ((uint8_t *)buf)[k+i]; + + if (padsize < 112) { + for (pad[padsize++] = 0x80; padsize < 112; padsize++) + pad[padsize] = 0; + } else { + for (pad[padsize++] = 0x80; padsize < 240; padsize++) + pad[padsize] = 0; + } + + c64[0] = 0; + c64[1] = size << 3; + Encode64(pad+padsize, c64, sizeof (c64)); + padsize += sizeof (c64); + + for (i = 0; i < padsize; i += 128) + SHA512Transform(H, pad + i); + + /* truncate the output to the first 256 bits which fit into 'zcp' */ + Encode64((uint8_t *)zcp, H, sizeof (uint64_t) * 4); +} + +static void +zio_checksum_SHA256(const void *buf, uint64_t size, + const void *ctx_template __unused, zio_cksum_t *zcp) +{ + /* SHA-256 as per FIPS 180-4. */ + uint32_t H[] = { + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + }; + SHA256(H, buf, size, zcp); +} + +static void +zio_checksum_SHA512_native(const void *buf, uint64_t size, + const void *ctx_template __unused, zio_cksum_t *zcp) +{ + /* SHA-512/256 as per FIPS 180-4. */ + uint64_t H[] = { + 0x22312194FC2BF72CULL, 0x9F555FA3C84C64C2ULL, + 0x2393B86B6F53B151ULL, 0x963877195940EABDULL, + 0x96283EE2A88EFFE3ULL, 0xBE5E1E2553863992ULL, + 0x2B0199FC2C85B8AAULL, 0x0EB72DDC81C52CA2ULL + }; + SHA512(H, buf, size, zcp); +} + +static void +zio_checksum_SHA512_byteswap(const void *buf, uint64_t size, + const void *ctx_template, zio_cksum_t *zcp) +{ + zio_cksum_t tmp; + + zio_checksum_SHA512_native(buf, size, ctx_template, &tmp); + zcp->zc_word[0] = BSWAP_64(tmp.zc_word[0]); + zcp->zc_word[1] = BSWAP_64(tmp.zc_word[1]); + zcp->zc_word[2] = BSWAP_64(tmp.zc_word[2]); + zcp->zc_word[3] = BSWAP_64(tmp.zc_word[3]); } Copied: stable/11/sys/cddl/boot/zfs/skein_zfs.c (from r304321, head/sys/cddl/boot/zfs/skein_zfs.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/cddl/boot/zfs/skein_zfs.c Mon Feb 5 04:00:59 2018 (r328866, copy of r304321, head/sys/cddl/boot/zfs/skein_zfs.c) @@ -0,0 +1,92 @@ +/* + * CDDL HEADER START *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Mon Feb 5 05:02:01 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD816EF14EF; Mon, 5 Feb 2018 05:02:01 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 828E9826B0; Mon, 5 Feb 2018 05:02:01 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 63DF8242AE; Mon, 5 Feb 2018 05:02:01 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w155212G091062; Mon, 5 Feb 2018 05:02:01 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w15521oo091061; Mon, 5 Feb 2018 05:02:01 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802050502.w15521oo091061@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 5 Feb 2018 05:02:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328870 - stable/11 X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11 X-SVN-Commit-Revision: 328870 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2018 05:02:01 -0000 Author: kevans Date: Mon Feb 5 05:02:01 2018 New Revision: 328870 URL: https://svnweb.freebsd.org/changeset/base/328870 Log: Record r303039 in mergeinfo r303039 was MFC'd in r303333 Modified: Directory Properties: stable/11/ (props changed) From owner-svn-src-stable-11@freebsd.org Mon Feb 5 08:20:14 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A2DEDED8F85; Mon, 5 Feb 2018 08:20:13 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48AB0682BA; Mon, 5 Feb 2018 08:20:13 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 25FA726116; Mon, 5 Feb 2018 08:20:13 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w158KDLU086760; Mon, 5 Feb 2018 08:20:13 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w158KBwv086748; Mon, 5 Feb 2018 08:20:11 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201802050820.w158KBwv086748@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Mon, 5 Feb 2018 08:20:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328874 - in stable/11: contrib/file contrib/file/doc contrib/file/magic contrib/file/magic/Magdir contrib/file/python contrib/file/src contrib/file/tests lib/libmagic X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: in stable/11: contrib/file contrib/file/doc contrib/file/magic contrib/file/magic/Magdir contrib/file/python contrib/file/src contrib/file/tests lib/libmagic X-SVN-Commit-Revision: 328874 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2018 08:20:14 -0000 Author: eadler Date: Mon Feb 5 08:20:11 2018 New Revision: 328874 URL: https://svnweb.freebsd.org/changeset/base/328874 Log: MFC r323683: MFV r323678: file 5.32 Added: stable/11/contrib/file/magic/Magdir/apache - copied unchanged from r323683, head/contrib/file/magic/Magdir/apache stable/11/contrib/file/magic/Magdir/bhl - copied unchanged from r323683, head/contrib/file/magic/Magdir/bhl stable/11/contrib/file/magic/Magdir/gconv - copied unchanged from r323683, head/contrib/file/magic/Magdir/gconv stable/11/contrib/file/magic/Magdir/gpu - copied unchanged from r323683, head/contrib/file/magic/Magdir/gpu stable/11/contrib/file/magic/Magdir/webassembly - copied unchanged from r323683, head/contrib/file/magic/Magdir/webassembly stable/11/contrib/file/magic/Magdir/yara - copied unchanged from r323683, head/contrib/file/magic/Magdir/yara stable/11/contrib/file/tests/hddrawcopytool.result - copied unchanged from r323683, head/contrib/file/tests/hddrawcopytool.result stable/11/contrib/file/tests/hddrawcopytool.testfile - copied unchanged from r323683, head/contrib/file/tests/hddrawcopytool.testfile Modified: stable/11/contrib/file/ChangeLog stable/11/contrib/file/aclocal.m4 stable/11/contrib/file/config.guess stable/11/contrib/file/config.sub stable/11/contrib/file/configure stable/11/contrib/file/configure.ac stable/11/contrib/file/doc/file.man stable/11/contrib/file/doc/libmagic.man stable/11/contrib/file/doc/magic.man stable/11/contrib/file/magic/Localstuff stable/11/contrib/file/magic/Magdir/adventure stable/11/contrib/file/magic/Magdir/amanda stable/11/contrib/file/magic/Magdir/amigaos stable/11/contrib/file/magic/Magdir/android stable/11/contrib/file/magic/Magdir/animation stable/11/contrib/file/magic/Magdir/apple stable/11/contrib/file/magic/Magdir/archive stable/11/contrib/file/magic/Magdir/att3b stable/11/contrib/file/magic/Magdir/audio stable/11/contrib/file/magic/Magdir/blackberry stable/11/contrib/file/magic/Magdir/blender stable/11/contrib/file/magic/Magdir/c-lang stable/11/contrib/file/magic/Magdir/cad stable/11/contrib/file/magic/Magdir/cafebabe stable/11/contrib/file/magic/Magdir/clipper stable/11/contrib/file/magic/Magdir/coff stable/11/contrib/file/magic/Magdir/commands stable/11/contrib/file/magic/Magdir/compress stable/11/contrib/file/magic/Magdir/console stable/11/contrib/file/magic/Magdir/cups stable/11/contrib/file/magic/Magdir/database stable/11/contrib/file/magic/Magdir/der stable/11/contrib/file/magic/Magdir/diff stable/11/contrib/file/magic/Magdir/dolby stable/11/contrib/file/magic/Magdir/dump stable/11/contrib/file/magic/Magdir/dyadic stable/11/contrib/file/magic/Magdir/editors stable/11/contrib/file/magic/Magdir/filesystems stable/11/contrib/file/magic/Magdir/flash stable/11/contrib/file/magic/Magdir/fonts stable/11/contrib/file/magic/Magdir/fsav stable/11/contrib/file/magic/Magdir/games stable/11/contrib/file/magic/Magdir/geo stable/11/contrib/file/magic/Magdir/gnu stable/11/contrib/file/magic/Magdir/gpt stable/11/contrib/file/magic/Magdir/gringotts stable/11/contrib/file/magic/Magdir/hitachi-sh stable/11/contrib/file/magic/Magdir/ibm370 stable/11/contrib/file/magic/Magdir/ibm6000 stable/11/contrib/file/magic/Magdir/icc stable/11/contrib/file/magic/Magdir/images stable/11/contrib/file/magic/Magdir/intel stable/11/contrib/file/magic/Magdir/isz stable/11/contrib/file/magic/Magdir/jpeg stable/11/contrib/file/magic/Magdir/kerberos stable/11/contrib/file/magic/Magdir/kml stable/11/contrib/file/magic/Magdir/linux stable/11/contrib/file/magic/Magdir/lisp stable/11/contrib/file/magic/Magdir/m4 stable/11/contrib/file/magic/Magdir/macintosh stable/11/contrib/file/magic/Magdir/make stable/11/contrib/file/magic/Magdir/maple stable/11/contrib/file/magic/Magdir/marc21 stable/11/contrib/file/magic/Magdir/mathematica stable/11/contrib/file/magic/Magdir/metastore stable/11/contrib/file/magic/Magdir/meteorological stable/11/contrib/file/magic/Magdir/microfocus stable/11/contrib/file/magic/Magdir/mime stable/11/contrib/file/magic/Magdir/misctools stable/11/contrib/file/magic/Magdir/modem stable/11/contrib/file/magic/Magdir/mozilla stable/11/contrib/file/magic/Magdir/msdos stable/11/contrib/file/magic/Magdir/msvc stable/11/contrib/file/magic/Magdir/msx stable/11/contrib/file/magic/Magdir/mup stable/11/contrib/file/magic/Magdir/nasa stable/11/contrib/file/magic/Magdir/netbsd stable/11/contrib/file/magic/Magdir/netscape stable/11/contrib/file/magic/Magdir/nitpicker stable/11/contrib/file/magic/Magdir/os2 stable/11/contrib/file/magic/Magdir/os9 stable/11/contrib/file/magic/Magdir/pbf stable/11/contrib/file/magic/Magdir/pc88 stable/11/contrib/file/magic/Magdir/pc98 stable/11/contrib/file/magic/Magdir/pdf stable/11/contrib/file/magic/Magdir/pdp stable/11/contrib/file/magic/Magdir/perl stable/11/contrib/file/magic/Magdir/pgf stable/11/contrib/file/magic/Magdir/pgp stable/11/contrib/file/magic/Magdir/printer stable/11/contrib/file/magic/Magdir/project stable/11/contrib/file/magic/Magdir/psdbms stable/11/contrib/file/magic/Magdir/python stable/11/contrib/file/magic/Magdir/riff stable/11/contrib/file/magic/Magdir/ruby stable/11/contrib/file/magic/Magdir/sccs stable/11/contrib/file/magic/Magdir/scientific stable/11/contrib/file/magic/Magdir/sendmail stable/11/contrib/file/magic/Magdir/sequent stable/11/contrib/file/magic/Magdir/sgml stable/11/contrib/file/magic/Magdir/sharc stable/11/contrib/file/magic/Magdir/sketch stable/11/contrib/file/magic/Magdir/sql stable/11/contrib/file/magic/Magdir/ssl stable/11/contrib/file/magic/Magdir/sysex stable/11/contrib/file/magic/Magdir/terminfo stable/11/contrib/file/magic/Magdir/vms stable/11/contrib/file/magic/Magdir/vmware stable/11/contrib/file/magic/Magdir/vorbis stable/11/contrib/file/magic/Magdir/windows stable/11/contrib/file/magic/Magdir/xenix stable/11/contrib/file/magic/Magdir/xilinx stable/11/contrib/file/magic/Magdir/xwindows stable/11/contrib/file/magic/Makefile.am stable/11/contrib/file/magic/Makefile.in stable/11/contrib/file/python/magic.py stable/11/contrib/file/src/apprentice.c stable/11/contrib/file/src/cdf.c stable/11/contrib/file/src/cdf.h stable/11/contrib/file/src/cdf_time.c stable/11/contrib/file/src/compress.c stable/11/contrib/file/src/der.c stable/11/contrib/file/src/file.h stable/11/contrib/file/src/fsmagic.c stable/11/contrib/file/src/funcs.c stable/11/contrib/file/src/is_tar.c stable/11/contrib/file/src/magic.c stable/11/contrib/file/src/magic.h.in stable/11/contrib/file/src/print.c stable/11/contrib/file/src/readcdf.c stable/11/contrib/file/src/readelf.c stable/11/contrib/file/src/readelf.h stable/11/contrib/file/src/softmagic.c stable/11/contrib/file/src/vasprintf.c stable/11/contrib/file/tests/Makefile.am stable/11/contrib/file/tests/Makefile.in stable/11/contrib/file/tests/test.c stable/11/lib/libmagic/config.h Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/file/ChangeLog ============================================================================== --- stable/11/contrib/file/ChangeLog Mon Feb 5 07:05:28 2018 (r328873) +++ stable/11/contrib/file/ChangeLog Mon Feb 5 08:20:11 2018 (r328874) @@ -1,6 +1,60 @@ +2017-09-02 11:53 Christos Zoulas + + * release 5.32 + +2017-08-28 16:37 Christos Zoulas + + * Always reset state in {file,buffer}_apprentice (Krzysztof Wilczynski) + +2017-08-27 03:55 Christos Zoulas + + * Fix always true condition (Thomas Jarosch) + +2017-05-24 17:30 Christos Zoulas + + * pickier parsing of numeric values in magic files. + +2017-05-23 17:55 Christos Zoulas + + * PR/615 add magic_getflags() + +2017-05-23 13:55 Christos Zoulas + + * release 5.31 + +2017-03-17 20:32 Christos Zoulas + + * remove trailing spaces from magic files + * refactor is_tar + * better bounds checks for cdf + +2017-02-10 12:24 Christos Zoulas + + * release 5.30 + +2017-02-07 23:27 Christos Zoulas + + * If we exceeded the offset in a search return no match + (Christoph Biedl) + * Be more lenient on corrupt CDF files (Christoph Biedl) + +2017-02-04 16:46 Christos Zoulas + + * pacify ubsan sign extension (oss-fuzz/524) + +2017-02-01 12:42 Christos Zoulas + + * off by one in cdf parsing (PR/593) + * report debugging sections in elf (PR/591) + +2016-11-06 10:52 Christos Zoulas + + * Allow @@@ in extensions + * Add missing overflow check in der magic (Jonas Wagner) + 2016-10-25 10:40 Christos Zoulas - * release 5.28 + * release 5.29 2016-10-24 11:20 Christos Zoulas @@ -387,7 +441,7 @@ ` 2013-11-06 14:40 Christos Zoulas - * fix erroneous non-zero exit code from non-existant file and message + * fix erroneous non-zero exit code from non-existent file and message 2013-10-29 14:25 Christos Zoulas Modified: stable/11/contrib/file/aclocal.m4 ============================================================================== --- stable/11/contrib/file/aclocal.m4 Mon Feb 5 07:05:28 2018 (r328873) +++ stable/11/contrib/file/aclocal.m4 Mon Feb 5 08:20:11 2018 (r328874) @@ -21,7 +21,7 @@ If you have problems, you may need to regenerate the b To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # visibility.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2005, 2008, 2010-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2008, 2010-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. Modified: stable/11/contrib/file/config.guess ============================================================================== --- stable/11/contrib/file/config.guess Mon Feb 5 07:05:28 2018 (r328873) +++ stable/11/contrib/file/config.guess Mon Feb 5 08:20:11 2018 (r328874) @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2015 Free Software Foundation, Inc. +# Copyright 1992-2017 Free Software Foundation, Inc. -timestamp='2015-03-04' +timestamp='2017-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ timestamp='2015-03-04' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to . @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2015 Free Software Foundation, Inc. +Copyright 1992-2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -186,9 +186,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. + # to ELF recently (or will in the future) and ABI. case "${UNAME_MACHINE_ARCH}" in - arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ @@ -221,7 +224,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: @@ -237,6 +240,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} + exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; @@ -249,6 +256,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; + *:Sortix:*:*) + echo ${UNAME_MACHINE}-unknown-sortix + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) @@ -265,42 +275,42 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 @@ -373,16 +383,16 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build - SUN_ARCH="i386" + SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH="x86_64" + SUN_ARCH=x86_64 fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` @@ -407,7 +417,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} @@ -632,13 +642,13 @@ EOF sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi @@ -677,11 +687,11 @@ EOF exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = "hppa2.0w" ] + if [ ${HP_ARCH} = hppa2.0w ] then eval $set_cc_for_build @@ -694,12 +704,12 @@ EOF # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} @@ -804,14 +814,14 @@ EOF echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) @@ -893,7 +903,7 @@ EOF exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix @@ -916,7 +926,7 @@ EOF EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) @@ -962,6 +972,9 @@ EOF ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; + k1om:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; @@ -987,6 +1000,9 @@ EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; + mips64el:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; @@ -1019,6 +1035,9 @@ EOF ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; @@ -1038,7 +1057,7 @@ EOF echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} @@ -1117,7 +1136,7 @@ EOF # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that + # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; @@ -1266,6 +1285,9 @@ EOF SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux${UNAME_RELEASE} + exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; @@ -1279,9 +1301,9 @@ EOF UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in @@ -1303,7 +1325,7 @@ EOF exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then + if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi @@ -1334,7 +1356,7 @@ EOF # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" @@ -1376,7 +1398,7 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos @@ -1387,23 +1409,25 @@ EOF x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs + exit ;; esac cat >&2 < in order to provide the needed -information to handle your system. +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. config.guess timestamp = $timestamp Modified: stable/11/contrib/file/config.sub ============================================================================== --- stable/11/contrib/file/config.sub Mon Feb 5 07:05:28 2018 (r328873) +++ stable/11/contrib/file/config.sub Mon Feb 5 08:20:11 2018 (r328874) @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2015 Free Software Foundation, Inc. +# Copyright 1992-2017 Free Software Foundation, Inc. -timestamp='2015-03-08' +timestamp='2017-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -33,7 +33,7 @@ timestamp='2015-03-08' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -53,8 +53,7 @@ timestamp='2015-03-08' me=`echo "$0" | sed -e 's,.*/,,'` usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. @@ -68,7 +67,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2015 Free Software Foundation, Inc. +Copyright 1992-2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -118,7 +117,7 @@ case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` @@ -255,6 +254,7 @@ case $basic_machine in | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ + | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ @@ -301,11 +301,12 @@ case $basic_machine in | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ @@ -376,6 +377,7 @@ case $basic_machine in | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ @@ -427,13 +429,15 @@ case $basic_machine in | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ | pyramid-* \ + | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ @@ -518,7 +522,7 @@ case $basic_machine in basic_machine=i386-pc os=-aros ;; - asmjs) + asmjs) basic_machine=asmjs-unknown ;; aux) @@ -641,6 +645,14 @@ case $basic_machine in basic_machine=m68k-bull os=-sysv3 ;; + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" + ;; + e500v[12]-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + os=$os"spe" + ;; ebmon29k) basic_machine=a29k-amd os=-ebmon @@ -1020,7 +1032,7 @@ case $basic_machine in ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppcle | powerpclittle | ppc-le | powerpc-little) + ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) @@ -1030,7 +1042,7 @@ case $basic_machine in ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) + ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) @@ -1376,18 +1388,18 @@ case $os in | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* | -cloudabi* \ + | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ + | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ + | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ @@ -1396,7 +1408,8 @@ case $os in | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ + | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1528,6 +1541,8 @@ case $os in ;; -nacl*) ;; + -ios) + ;; -none) ;; *) @@ -1622,6 +1637,9 @@ case $basic_machine in ;; sparc-* | *-sun) os=-sunos4.1.1 + ;; + pru-*) + os=-elf ;; *-be) os=-beos Modified: stable/11/contrib/file/configure ============================================================================== --- stable/11/contrib/file/configure Mon Feb 5 07:05:28 2018 (r328873) +++ stable/11/contrib/file/configure Mon Feb 5 08:20:11 2018 (r328874) @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for file 5.29. +# Generated by GNU Autoconf 2.69 for file 5.32. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='file' PACKAGE_TARNAME='file' -PACKAGE_VERSION='5.29' -PACKAGE_STRING='file 5.29' +PACKAGE_VERSION='5.32' +PACKAGE_STRING='file 5.32' PACKAGE_BUGREPORT='christos@astron.com' PACKAGE_URL='' @@ -1328,7 +1328,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures file 5.29 to adapt to many kinds of systems. +\`configure' configures file 5.32 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1398,7 +1398,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of file 5.29:";; + short | recursive ) echo "Configuration of file 5.32:";; esac cat <<\_ACEOF @@ -1509,7 +1509,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -file configure 5.29 +file configure 5.32 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2165,7 +2165,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by file $as_me 5.29, which was +It was created by file $as_me 5.32, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3031,7 +3031,7 @@ fi # Define the identity of the package. PACKAGE='file' - VERSION='5.29' + VERSION='5.32' cat >>confdefs.h <<_ACEOF @@ -15075,7 +15075,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by file $as_me 5.29, which was +This file was extended by file $as_me 5.32, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15141,7 +15141,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -file config.status 5.29 +file config.status 5.32 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Modified: stable/11/contrib/file/configure.ac ============================================================================== --- stable/11/contrib/file/configure.ac Mon Feb 5 07:05:28 2018 (r328873) +++ stable/11/contrib/file/configure.ac Mon Feb 5 08:20:11 2018 (r328874) @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([file],[5.29],[christos@astron.com]) +AC_INIT([file],[5.32],[christos@astron.com]) AM_INIT_AUTOMAKE([subdir-objects foreign]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) Modified: stable/11/contrib/file/doc/file.man ============================================================================== --- stable/11/contrib/file/doc/file.man Mon Feb 5 07:05:28 2018 (r328873) +++ stable/11/contrib/file/doc/file.man Mon Feb 5 08:20:11 2018 (r328874) @@ -1,4 +1,4 @@ -.\" $File: file.man,v 1.124 2016/10/19 20:52:45 christos Exp $ +.\" $File: file.man,v 1.125 2017/01/03 11:24:46 christos Exp $ .Dd October 19, 2016 .Dt FILE __CSECTION__ .Os @@ -238,8 +238,8 @@ or at least one filename argument must be present; to test the standard input, use .Sq - as a filename argument. -Please note that -.Ar namefile +Please note that +.Ar namefile is unwrapped and the enclosed filenames are processed when this option is encountered and before any further options processing is done. This allows one to process multiple lists of files with different command line @@ -411,10 +411,10 @@ and .Fl h options. .Sh SEE ALSO -.Xr magic __FSECTION__ , .Xr hexdump 1 , .Xr od 1 , .Xr strings 1 , +.Xr magic __FSECTION__ , .Xr fstyp 8 .Sh STANDARDS CONFORMANCE This program is believed to exceed the System V Interface Definition @@ -531,16 +531,15 @@ John Gilmore revised the code extensively, making it b the first version. Geoff Collyer found several inadequacies and provided some magic file entries. -Contributions by the +Contributions of the .Sq \*[Am] operator by Rob McMahon, .Aq cudcv@warwick.ac.uk , 1989. .Pp -Guy Harris, +Guy Harris, .Aq guy@netapp.com , made many changes from 1993 to the present. -1989. .Pp Primary development and maintenance from 1990 to the present by Christos Zoulas @@ -588,7 +587,6 @@ program, and are not covered by the above license. .Nm returns 0 on success, and non-zero on error. .Sh BUGS -.Pp Please report bugs and send patches to the bug tracker at .Pa http://bugs.gw.com/ or the mailing list at @@ -597,7 +595,6 @@ or the mailing list at .Pa http://mx.gw.com/mailman/listinfo/file first to subscribe). .Sh TODO -.Pp Fix output so that tests for MIME and APPLE flags are not needed all over the place, and actual output is only done in one place. This needs a design. @@ -646,16 +643,16 @@ Fix .Dq name and .Dq use -to check for consistency at compile time (duplicate +to check for consistency at compile time (duplicate .Dq name , .Dq use pointing to undefined .Dq name ). -Make +Make .Dq name / -.Dq use +.Dq use more efficient by keeping a sorted list of names. Special-case ^ to flip endianness in the parser so that it does not have to be escaped, and document it. Modified: stable/11/contrib/file/doc/libmagic.man ============================================================================== --- stable/11/contrib/file/doc/libmagic.man Mon Feb 5 07:05:28 2018 (r328873) +++ stable/11/contrib/file/doc/libmagic.man Mon Feb 5 08:20:11 2018 (r328874) @@ -1,4 +1,4 @@ -.\" $File: libmagic.man,v 1.40 2016/03/31 17:51:12 christos Exp $ +.\" $File: libmagic.man,v 1.41 2017/05/23 21:54:07 christos Exp $ .\" .\" Copyright (c) Christos Zoulas 2003. .\" All Rights Reserved. @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 11, 2015 +.Dd May 23, 2017 .Dt LIBMAGIC 3 .Os .Sh NAME @@ -35,6 +35,7 @@ .Nm magic_errno , .Nm magic_descriptor , .Nm magic_buffer , +.Nm magic_getflags , .Nm magic_setflags , .Nm magic_check , .Nm magic_compile , @@ -64,6 +65,8 @@ .Ft const char * .Fn magic_buffer "magic_t cookie" "const void *buffer" "size_t length" .Ft int +.Fn magic_getflags "magic_t cookie" +.Ft int .Fn magic_setflags "magic_t cookie" "int flags" .Ft int .Fn magic_check "magic_t cookie" "const char *filename" @@ -204,6 +207,12 @@ function returns a textual description of the contents argument with .Ar length bytes size. +.Pp +The +.Fn magic_getflags +functions returns a value representing current +.Ar flags +set. .Pp The .Fn magic_setflags Modified: stable/11/contrib/file/doc/magic.man ============================================================================== --- stable/11/contrib/file/doc/magic.man Mon Feb 5 07:05:28 2018 (r328873) +++ stable/11/contrib/file/doc/magic.man Mon Feb 5 08:20:11 2018 (r328874) @@ -1,5 +1,5 @@ -.\" $File: magic.man,v 1.88 2016/07/27 09:42:49 rrt Exp $ -.Dd July 20, 2016 +.\" $File: magic.man,v 1.91 2017/02/12 15:30:08 christos Exp $ +.Dd February 12, 2017 .Dt MAGIC __FSECTION__ .Os .\" install as magic.4 on USG, magic.5 on V7, Berkeley and Linux systems. @@ -7,7 +7,7 @@ .Nm magic .Nd file command's magic pattern file .Sh DESCRIPTION -This manual page documents the format of the magic file as +This manual page documents the format of magic files as used by the .Xr file __CSECTION__ command, version __VERSION__. @@ -17,13 +17,19 @@ command identifies the type of a file using, among other tests, a test for whether the file contains certain .Dq "magic patterns" . -The file -.Pa __MAGIC__ -specifies what patterns are to be tested for, what message or +The database of these +.Dq "magic patterns" +is usually located in a binary file in +.Pa __MAGIC__.mgc +or a directory of source text magic pattern fragment files in +.Pa __MAGIC__ . +The database specifies what patterns are to be tested for, what message or MIME type to print if a particular pattern is found, and additional information to extract from the file. .Pp -Each line of the file specifies a test to be performed. +The format of the source fragment files that are used to build this database +is as follows: +Each line of a fragment file specifies a test to be performed. A test compares the data starting at a particular offset in the file with a byte value, a string or a numeric value. If the test succeeds, a message is printed. @@ -98,13 +104,13 @@ The following modifiers are supported: .It B A byte length (default). .It H -A 2 byte big endian length. +A 4 byte big endian length. .It h -A 2 byte big little length. +A 2 byte big endian length. .It L -A 4 byte big endian length. +A 4 byte little endian length. .It l -A 4 byte big little length. +A 2 byte little endian length. .It J The length includes itself in its count. .El @@ -651,7 +657,7 @@ start of the main indirect offset. \*[Gt]\*[Gt]\*[Gt]\*[Gt](\*[Am]0xe.l+(-4)) string PK\e3\e4 \eb, ZIP self-extracting archive .Ed .Pp -If you have a list of known avalues at a particular continuation level, +If you have a list of known values at a particular continuation level, and you want to provide a switch-like default case: .Bd -literal -offset indent # clear that continuation level match Modified: stable/11/contrib/file/magic/Localstuff ============================================================================== --- stable/11/contrib/file/magic/Localstuff Mon Feb 5 07:05:28 2018 (r328873) +++ stable/11/contrib/file/magic/Localstuff Mon Feb 5 08:20:11 2018 (r328874) @@ -2,6 +2,6 @@ #------------------------------------------------------------------------------ # Localstuff: file(1) magic for locally observed files # -# $File: Localstuff,v 1.4 2003/03/23 04:17:27 christos Exp $ +# $File: Localstuff,v 1.5 2007/01/12 17:38:27 christos Exp $ # Add any locally observed files here. Remember: # text if readable, executable if runnable binary, data if unreadable. Modified: stable/11/contrib/file/magic/Magdir/adventure ============================================================================== --- stable/11/contrib/file/magic/Magdir/adventure Mon Feb 5 07:05:28 2018 (r328873) +++ stable/11/contrib/file/magic/Magdir/adventure Mon Feb 5 08:20:11 2018 (r328874) @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: adventure,v 1.15 2015/09/07 10:03:21 christos Exp $ +# $File: adventure,v 1.17 2017/07/03 16:03:40 christos Exp $ # adventure: file(1) magic for Adventure game files # # from Allen Garvin @@ -36,11 +36,12 @@ >0 ubyte <9 >>16 belong&0xfe00f0f0 0x3030 >>>0 ubyte < 10 ->>>>2 ubeshort < 10 +>>>>2 ubeshort x >>>>>18 regex [0-9][0-9][0-9][0-9][0-9][0-9] ->>>>>>0 ubyte < 10 Infocom (Z-machine %d, ->>>>>>>2 ubeshort < 10 Release %d / ->>>>>>>>18 string >\0 Serial %.6s) +>>>>>>0 ubyte < 10 Infocom (Z-machine %d +>>>>>>>2 ubeshort x \b, Release %d +>>>>>>>>18 string >\0 \b, Serial %.6s +>>>>>>>>18 string x \b) !:strength + 40 !:mime application/x-zmachine @@ -78,7 +79,7 @@ !:mime application/x-tads # Some saved game files start with "TADS2 save/g\n\r\032\0", a little-endian # 2-byte length N, the N-char name of the game file *without* a NUL (darn!), -# "TADS2 save\n\r\032\0" and the interpreter version. +# "TADS2 save\n\r\032\0" and the interpreter version. 0 string TADS2\ save/g TADS >12 belong !0x0A0D1A00 saved game data, CORRUPTED >12 belong 0x0A0D1A00 *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Mon Feb 5 09:25:03 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F418AEDE2BA; Mon, 5 Feb 2018 09:25:02 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A6D816AB0A; Mon, 5 Feb 2018 09:25:02 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9D9D626C36; Mon, 5 Feb 2018 09:25:02 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w159P2b4021712; Mon, 5 Feb 2018 09:25:02 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w159P2Yl021711; Mon, 5 Feb 2018 09:25:02 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201802050925.w159P2Yl021711@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 5 Feb 2018 09:25:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328877 - stable/11/sys/netinet6 X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sys/netinet6 X-SVN-Commit-Revision: 328877 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2018 09:25:03 -0000 Author: ae Date: Mon Feb 5 09:25:02 2018 New Revision: 328877 URL: https://svnweb.freebsd.org/changeset/base/328877 Log: MFC r328770: Merge r1.120 from NetBSD: Fix a pretty simple, yet pretty tragic typo: we should return IPPROTO_DONE, not IPPROTO_NONE. With IPPROTO_NONE we will keep parsing the header chain on an mbuf that was already freed. Reported by: Maxime Villard Modified: stable/11/sys/netinet6/ip6_mroute.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet6/ip6_mroute.c ============================================================================== --- stable/11/sys/netinet6/ip6_mroute.c Mon Feb 5 09:22:07 2018 (r328876) +++ stable/11/sys/netinet6/ip6_mroute.c Mon Feb 5 09:25:02 2018 (r328877) @@ -1854,7 +1854,7 @@ pim6_input(struct mbuf **mp, int *offp, int proto) "of the inner packet", (eip6->ip6_vfc & IPV6_VERSION)); m_freem(m); - return (IPPROTO_NONE); + return (IPPROTO_DONE); } /* verify the inner packet is destined to a mcast group */ From owner-svn-src-stable-11@freebsd.org Mon Feb 5 10:29:58 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8BE64EE332D; Mon, 5 Feb 2018 10:29:58 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3F2E86CD19; Mon, 5 Feb 2018 10:29:58 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 35EFA275F2; Mon, 5 Feb 2018 10:29:58 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w15ATwxx051478; Mon, 5 Feb 2018 10:29:58 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w15ATwak051477; Mon, 5 Feb 2018 10:29:58 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201802051029.w15ATwak051477@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 5 Feb 2018 10:29:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328879 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 328879 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2018 10:29:58 -0000 Author: kib Date: Mon Feb 5 10:29:57 2018 New Revision: 328879 URL: https://svnweb.freebsd.org/changeset/base/328879 Log: MFC r328773: On pageout, in vnode generic pager, for partially dirty page, only clear dirty bits for completely invalid blocks. PR: 225586 Modified: stable/11/sys/vm/vnode_pager.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vnode_pager.c ============================================================================== --- stable/11/sys/vm/vnode_pager.c Mon Feb 5 09:25:53 2018 (r328878) +++ stable/11/sys/vm/vnode_pager.c Mon Feb 5 10:29:57 2018 (r328879) @@ -1223,6 +1223,8 @@ vnode_pager_generic_putpages(struct vnode *vp, vm_page maxsize = object->un_pager.vnp.vnp_size - poffset; ncount = btoc(maxsize); if ((pgoff = (int)maxsize & PAGE_MASK) != 0) { + pgoff = roundup2(pgoff, DEV_BSIZE); + /* * If the object is locked and the following * conditions hold, then the page's dirty From owner-svn-src-stable-11@freebsd.org Mon Feb 5 15:02:36 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 21629ECB44F; Mon, 5 Feb 2018 15:02:36 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C7A0176EE4; Mon, 5 Feb 2018 15:02:35 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C259E2399; Mon, 5 Feb 2018 15:02:35 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w15F2Z3N090019; Mon, 5 Feb 2018 15:02:35 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w15F2Zj5090018; Mon, 5 Feb 2018 15:02:35 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201802051502.w15F2Zj5090018@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 5 Feb 2018 15:02:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328884 - stable/11/lib/libedit X-SVN-Group: stable-11 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: stable/11/lib/libedit X-SVN-Commit-Revision: 328884 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2018 15:02:36 -0000 Author: pfg Date: Mon Feb 5 15:02:35 2018 New Revision: 328884 URL: https://svnweb.freebsd.org/changeset/base/328884 Log: MFC r328567: libedit: sort the Makefile in line with NetBSD's version. NetBSD's libedit has been been cleaned-up considerably so the non-widecharacter version is no longer an option. Re-sorting the Makefile should make it easier for some brave soul trying to update it. No functional change intended. Modified: stable/11/lib/libedit/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libedit/Makefile ============================================================================== --- stable/11/lib/libedit/Makefile Mon Feb 5 14:53:18 2018 (r328883) +++ stable/11/lib/libedit/Makefile Mon Feb 5 15:02:35 2018 (r328884) @@ -3,18 +3,19 @@ # $FreeBSD$ PACKAGE=clibs -LIB= edit + SHLIB_MAJOR= 7 SHLIBDIR?= /lib WARNS?= 3 +LIB= edit +LIBADD= ncursesw + OSRCS= chared.c common.c el.c eln.c emacs.c fcns.c filecomplete.c help.c \ hist.c keymacro.c map.c chartype.c \ parse.c prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c -LIBADD= ncursesw - MAN= editline.3 editrc.5 MLINKS= editline.3 el_deletestr.3 editline.3 el_end.3 editline.3 el_init.3 \ @@ -28,25 +29,26 @@ MLINKS= editline.3 el_deletestr.3 editline.3 el_end.3 editline.3 tok_line.3 editline.3 tok_str.3 # For speed and debugging -#SRCS= ${OSRCS} +#SRCS= ${OSRCS} readline.c tokenizer.c history.c # For protection -SRCS= editline.c -SRCS+= tokenizer.c history.c readline.c +SRCS= editline.c readline.c tokenizer.c history.c SRCS+= common.h emacs.h fcns.h help.h vi.h -CLEANFILES+= common.h editline.c emacs.h fcns.c fcns.h help.c help.h vi.h -INCS= histedit.h - +# Widechar SRCS+= tokenizern.c historyn.c CLEANFILES+= tokenizern.c historyn.c + +INCS= histedit.h + +CLEANFILES+= common.h editline.c emacs.h fcns.c fcns.h help.c help.h vi.h CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/edit -DWIDECHAR #CFLAGS+= -DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH #CFLAGS+= -DDEBUG_PASTE -DDEBUG_EDIT -SUBDIR= edit/readline - AHDR= vi.h emacs.h common.h ASRC= ${.CURDIR}/vi.c ${.CURDIR}/emacs.c ${.CURDIR}/common.c + +SUBDIR= edit/readline .for hdr in vi emacs common ${hdr}.h: ${hdr}.c makelist From owner-svn-src-stable-11@freebsd.org Mon Feb 5 16:28:04 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4231ED9C9C; Mon, 5 Feb 2018 16:28:03 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9338C7A8FE; Mon, 5 Feb 2018 16:28:03 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 86489304B; Mon, 5 Feb 2018 16:28:03 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w15GS3RX030655; Mon, 5 Feb 2018 16:28:03 GMT (envelope-from n_hibma@FreeBSD.org) Received: (from n_hibma@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w15GS3Vf030653; Mon, 5 Feb 2018 16:28:03 GMT (envelope-from n_hibma@FreeBSD.org) Message-Id: <201802051628.w15GS3Vf030653@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: n_hibma set sender to n_hibma@FreeBSD.org using -f From: Nick Hibma Date: Mon, 5 Feb 2018 16:28:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328888 - in stable/11/sys/dev/usb: . serial X-SVN-Group: stable-11 X-SVN-Commit-Author: n_hibma X-SVN-Commit-Paths: in stable/11/sys/dev/usb: . serial X-SVN-Commit-Revision: 328888 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2018 16:28:04 -0000 Author: n_hibma Date: Mon Feb 5 16:28:03 2018 New Revision: 328888 URL: https://svnweb.freebsd.org/changeset/base/328888 Log: Merge r327951 Add IDs for Quectel EC25. Submitted by: Samuel Crookes Modified: stable/11/sys/dev/usb/serial/u3g.c stable/11/sys/dev/usb/usbdevs Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/usb/serial/u3g.c ============================================================================== --- stable/11/sys/dev/usb/serial/u3g.c Mon Feb 5 16:01:34 2018 (r328887) +++ stable/11/sys/dev/usb/serial/u3g.c Mon Feb 5 16:28:03 2018 (r328888) @@ -487,6 +487,7 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = { U3G_DEV(QUANTA, GLX, 0), U3G_DEV(QUANTA, Q101, 0), U3G_DEV(QUANTA, Q111, 0), + U3G_DEV(QUECTEL, EC25, 0), U3G_DEV(SIERRA, AC402, 0), U3G_DEV(SIERRA, AC595U, 0), U3G_DEV(SIERRA, AC313U, 0), Modified: stable/11/sys/dev/usb/usbdevs ============================================================================== --- stable/11/sys/dev/usb/usbdevs Mon Feb 5 16:01:34 2018 (r328887) +++ stable/11/sys/dev/usb/usbdevs Mon Feb 5 16:28:03 2018 (r328888) @@ -746,6 +746,7 @@ vendor TRIPPLITE 0x2478 Tripp-Lite vendor HIROSE 0x2631 Hirose Electric vendor NHJ 0x2770 NHJ vendor PLANEX 0x2c02 Planex Communications +vendor QUECTEL 0x2c7c Quectel Wireless Solutions vendor VIDZMEDIA 0x3275 VidzMedia Pte Ltd vendor LINKINSTRUMENTS 0x3195 Link Instruments Inc. vendor AEI 0x3334 AEI @@ -3757,11 +3758,14 @@ product QUANTA GKE 0xea05 HSDPA modem product QUANTA GLE 0xea06 HSDPA modem product QUANTA RW6815R 0xf003 HP iPAQ rw6815 RNDIS -/* Qtronix products */ -product QTRONIX 980N 0x2011 Scorpion-980N keyboard +/* Quectel products */ +product QUECTEL EC25 0x0125 LTE modem /* Quickshot products */ product QUICKSHOT STRIKEPAD 0x6238 USB StrikePad + +/* Qtronix products */ +product QTRONIX 980N 0x2011 Scorpion-980N keyboard /* Radio Shack */ product RADIOSHACK USBCABLE 0x4026 USB to Serial Cable From owner-svn-src-stable-11@freebsd.org Mon Feb 5 17:01:22 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1B542EDC922; Mon, 5 Feb 2018 17:01:22 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BF5937BF97; Mon, 5 Feb 2018 17:01:21 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BA09C39B4; Mon, 5 Feb 2018 17:01:21 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w15H1Lor046247; Mon, 5 Feb 2018 17:01:21 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w15H1JS8046220; Mon, 5 Feb 2018 17:01:19 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802051701.w15H1JS8046220@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 5 Feb 2018 17:01:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328889 - in stable/11: lib/libstand sys/boot/common sys/boot/efi/libefi sys/boot/efi/loader sys/boot/i386/libfirewire sys/boot/i386/libi386 sys/boot/mips/beri/loader sys/boot/ofw/libof... X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: lib/libstand sys/boot/common sys/boot/efi/libefi sys/boot/efi/loader sys/boot/i386/libfirewire sys/boot/i386/libi386 sys/boot/mips/beri/loader sys/boot/ofw/libofw sys/boot/pc98/libpc98 s... X-SVN-Commit-Revision: 328889 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2018 17:01:22 -0000 Author: kevans Date: Mon Feb 5 17:01:18 2018 New Revision: 328889 URL: https://svnweb.freebsd.org/changeset/base/328889 Log: MFC r308434, 308827 MFC r308434: Loader paged/pageable data is not always paged. MFC r308827: lsdev device name section headers should be printed by dv_print callback. Modified: stable/11/lib/libstand/stand.h stable/11/sys/boot/common/commands.c stable/11/sys/boot/common/dev_net.c stable/11/sys/boot/common/md.c stable/11/sys/boot/common/module.c stable/11/sys/boot/common/part.c stable/11/sys/boot/common/util.c stable/11/sys/boot/common/util.h stable/11/sys/boot/efi/libefi/efinet.c stable/11/sys/boot/efi/libefi/efipart.c stable/11/sys/boot/efi/loader/main.c stable/11/sys/boot/i386/libfirewire/firewire.c stable/11/sys/boot/i386/libi386/bioscd.c stable/11/sys/boot/i386/libi386/biosdisk.c stable/11/sys/boot/i386/libi386/pxe.c stable/11/sys/boot/mips/beri/loader/beri_disk_cfi.c stable/11/sys/boot/mips/beri/loader/beri_disk_sdcard.c stable/11/sys/boot/ofw/libofw/ofw_disk.c stable/11/sys/boot/pc98/libpc98/bioscd.c stable/11/sys/boot/pc98/libpc98/biosdisk.c stable/11/sys/boot/powerpc/kboot/hostdisk.c stable/11/sys/boot/powerpc/ps3/ps3cdrom.c stable/11/sys/boot/powerpc/ps3/ps3disk.c stable/11/sys/boot/uboot/lib/disk.c stable/11/sys/boot/usb/storage/umass_loader.c stable/11/sys/boot/userboot/userboot/host.c stable/11/sys/boot/userboot/userboot/userboot_disk.c stable/11/sys/boot/zfs/zfs.c stable/11/sys/boot/zfs/zfsimpl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libstand/stand.h ============================================================================== --- stable/11/lib/libstand/stand.h Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/lib/libstand/stand.h Mon Feb 5 17:01:18 2018 (r328889) @@ -143,7 +143,7 @@ struct devsw { int (*dv_open)(struct open_file *f, ...); int (*dv_close)(struct open_file *f); int (*dv_ioctl)(struct open_file *f, u_long cmd, void *data); - void (*dv_print)(int verbose); /* print device information */ + int (*dv_print)(int verbose); /* print device information */ void (*dv_cleanup)(void); }; Modified: stable/11/sys/boot/common/commands.c ============================================================================== --- stable/11/sys/boot/common/commands.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/common/commands.c Mon Feb 5 17:01:18 2018 (r328889) @@ -491,10 +491,8 @@ command_lsdev(int argc, char *argv[]) pager_open(); for (i = 0; devsw[i] != NULL; i++) { if (devsw[i]->dv_print != NULL){ - sprintf(line, "%s devices:\n", devsw[i]->dv_name); - if (pager_output(line)) - break; - devsw[i]->dv_print(verbose); + if (devsw[i]->dv_print(verbose)) + break; } else { sprintf(line, "%s: (unknown)\n", devsw[i]->dv_name); if (pager_output(line)) Modified: stable/11/sys/boot/common/dev_net.c ============================================================================== --- stable/11/sys/boot/common/dev_net.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/common/dev_net.c Mon Feb 5 17:01:18 2018 (r328889) @@ -80,7 +80,7 @@ static int net_open(struct open_file *, ...); static int net_close(struct open_file *); static void net_cleanup(void); static int net_strategy(); -static void net_print(int); +static int net_print(int); static int net_getparams(int sock); @@ -325,23 +325,34 @@ exit: return (0); } -static void +static int net_print(int verbose) { struct netif_driver *drv; int i, d, cnt; + int ret = 0; + if (netif_drivers[0] == NULL) + return (ret); + + printf("%s devices:", netdev.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + cnt = 0; for (d = 0; netif_drivers[d]; d++) { drv = netif_drivers[d]; for (i = 0; i < drv->netif_nifs; i++) { - printf("\t%s%d:", "net", cnt++); - if (verbose) + printf("\t%s%d:", netdev.dv_name, cnt++); + if (verbose) { printf(" (%s%d)", drv->netif_bname, drv->netif_ifs[i].dif_unit); + } + if ((ret = pager_output("\n")) != 0) + return (ret); } } - printf("\n"); + return (ret); } /* Modified: stable/11/sys/boot/common/md.c ============================================================================== --- stable/11/sys/boot/common/md.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/common/md.c Mon Feb 5 17:01:18 2018 (r328889) @@ -63,7 +63,7 @@ static int md_init(void); static int md_strategy(void *, int, daddr_t, size_t, char *, size_t *); static int md_open(struct open_file *, ...); static int md_close(struct open_file *); -static void md_print(int); +static int md_print(int); struct devsw md_dev = { "md", @@ -143,9 +143,14 @@ md_close(struct open_file *f) return ((dev->d_unit != 0) ? ENXIO : 0); } -static void +static int md_print(int verbose) { - printf("MD (%u bytes)\n", MD_IMAGE_SIZE); + printf("%s devices:", md_dev.dv_name); + if (pager_output("\n") != 0) + return (1); + + printf("MD (%u bytes)", MD_IMAGE_SIZE); + return (pager_output("\n")); } Modified: stable/11/sys/boot/common/module.c ============================================================================== --- stable/11/sys/boot/common/module.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/common/module.c Mon Feb 5 17:01:18 2018 (r328889) @@ -252,7 +252,7 @@ command_lsmod(int argc, char *argv[]) struct kernel_module *mp; struct file_metadata *md; char lbuf[80]; - int ch, verbose; + int ch, verbose, ret = 0; verbose = 0; optind = 1; @@ -271,11 +271,13 @@ command_lsmod(int argc, char *argv[]) pager_open(); for (fp = preloaded_files; fp; fp = fp->f_next) { - sprintf(lbuf, " %p: ", (void *) fp->f_addr); + snprintf(lbuf, sizeof(lbuf), " %p: ", (void *) fp->f_addr); pager_output(lbuf); pager_output(fp->f_name); - sprintf(lbuf, " (%s, 0x%lx)\n", fp->f_type, (long)fp->f_size); - pager_output(lbuf); + snprintf(lbuf, sizeof(lbuf), " (%s, 0x%lx)\n", fp->f_type, + (long)fp->f_size); + if (pager_output(lbuf)) + break; if (fp->f_args != NULL) { pager_output(" args: "); pager_output(fp->f_args); @@ -285,7 +287,8 @@ command_lsmod(int argc, char *argv[]) if (fp->f_modules) { pager_output(" modules: "); for (mp = fp->f_modules; mp; mp = mp->m_next) { - sprintf(lbuf, "%s.%d ", mp->m_name, mp->m_version); + snprintf(lbuf, sizeof(lbuf), "%s.%d ", mp->m_name, + mp->m_version); pager_output(lbuf); } if (pager_output("\n")) @@ -294,11 +297,14 @@ command_lsmod(int argc, char *argv[]) if (verbose) { /* XXX could add some formatting smarts here to display some better */ for (md = fp->f_metadata; md != NULL; md = md->md_next) { - sprintf(lbuf, " 0x%04x, 0x%lx\n", md->md_type, (long) md->md_size); + snprintf(lbuf, sizeof(lbuf), " 0x%04x, 0x%lx\n", + md->md_type, (long) md->md_size); if (pager_output(lbuf)) break; } } + if (ret) + break; } pager_close(); return(CMD_OK); Modified: stable/11/sys/boot/common/part.c ============================================================================== --- stable/11/sys/boot/common/part.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/common/part.c Mon Feb 5 17:01:18 2018 (r328889) @@ -835,6 +835,7 @@ ptable_iterate(const struct ptable *table, void *arg, { struct pentry *entry; char name[32]; + int ret = 0; name[0] = '\0'; STAILQ_FOREACH(entry, &table->entries, entry) { @@ -857,9 +858,8 @@ ptable_iterate(const struct ptable *table, void *arg, if (table->type == PTABLE_BSD) sprintf(name, "%c", (u_char) 'a' + entry->part.index); - if (iter(arg, name, &entry->part)) - return 1; + if ((ret = iter(arg, name, &entry->part)) != 0) + return (ret); } - return 0; + return (ret); } - Modified: stable/11/sys/boot/common/util.c ============================================================================== --- stable/11/sys/boot/common/util.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/common/util.c Mon Feb 5 17:01:18 2018 (r328889) @@ -114,7 +114,7 @@ strlen(const char *s) return (len); } -void +int printf(const char *fmt, ...) { va_list ap; @@ -178,4 +178,5 @@ nextfmt: } } va_end(ap); + return (0); } Modified: stable/11/sys/boot/common/util.h ============================================================================== --- stable/11/sys/boot/common/util.h Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/common/util.h Mon Feb 5 17:01:18 2018 (r328889) @@ -48,6 +48,6 @@ void strcat(char *dst, const char *src); char *strchr(const char *s, char ch); size_t strlen(const char *s); -void printf(const char *fmt, ...); +int printf(const char *fmt, ...); #endif /* !_UTIL_H_ */ Modified: stable/11/sys/boot/efi/libefi/efinet.c ============================================================================== --- stable/11/sys/boot/efi/libefi/efinet.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/efi/libefi/efinet.c Mon Feb 5 17:01:18 2018 (r328889) @@ -252,7 +252,7 @@ efinet_end(struct netif *nif) } static int efinet_dev_init(void); -static void efinet_dev_print(int); +static int efinet_dev_print(int); struct devsw efinet_dev = { .dv_name = "net", @@ -346,14 +346,17 @@ efinet_dev_init() return (0); } -static void +static int efinet_dev_print(int verbose) { CHAR16 *text; EFI_HANDLE h; - int unit; + int unit, ret = 0; - pager_open(); + printf("%s devices:", efinet_dev.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + for (unit = 0, h = efi_find_handle(&efinet_dev, 0); h != NULL; h = efi_find_handle(&efinet_dev, ++unit)) { printf(" %s%d:", efinet_dev.dv_name, unit); @@ -362,8 +365,8 @@ efinet_dev_print(int verbose) printf(" %S", text); efi_free_devpath_name(text); } - if (pager_output("\n")) + if ((ret = pager_output("\n")) != 0) break; } - pager_close(); + return (ret); } Modified: stable/11/sys/boot/efi/libefi/efipart.c ============================================================================== --- stable/11/sys/boot/efi/libefi/efipart.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/efi/libefi/efipart.c Mon Feb 5 17:01:18 2018 (r328889) @@ -45,7 +45,7 @@ static int efipart_strategy(void *, int, daddr_t, size static int efipart_realstrategy(void *, int, daddr_t, size_t, char *, size_t *); static int efipart_open(struct open_file *, ...); static int efipart_close(struct open_file *); -static void efipart_print(int); +static int efipart_print(int); struct devsw efipart_dev = { .dv_name = "part", @@ -160,7 +160,7 @@ efipart_init(void) return (err); } -static void +static int efipart_print(int verbose) { char line[80]; @@ -168,28 +168,33 @@ efipart_print(int verbose) EFI_HANDLE h; EFI_STATUS status; u_int unit; + int ret = 0; - pager_open(); + printf("%s devices:", efipart_dev.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + for (unit = 0, h = efi_find_handle(&efipart_dev, 0); h != NULL; h = efi_find_handle(&efipart_dev, ++unit)) { - sprintf(line, " %s%d:", efipart_dev.dv_name, unit); - if (pager_output(line)) + snprintf(line, sizeof(line), " %s%d:", + efipart_dev.dv_name, unit); + if ((ret = pager_output(line)) != 0) break; status = BS->HandleProtocol(h, &blkio_guid, (void **)&blkio); if (!EFI_ERROR(status)) { - sprintf(line, " %llu blocks", + snprintf(line, sizeof(line), " %llu blocks", (unsigned long long)(blkio->Media->LastBlock + 1)); - if (pager_output(line)) + if ((ret = pager_output(line)) != 0) break; if (blkio->Media->RemovableMedia) - if (pager_output(" (removable)")) + if ((ret = pager_output(" (removable)")) != 0) break; } - if (pager_output("\n")) + if ((ret = pager_output("\n")) != 0) break; } - pager_close(); + return (ret); } static int Modified: stable/11/sys/boot/efi/loader/main.c ============================================================================== --- stable/11/sys/boot/efi/loader/main.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/efi/loader/main.c Mon Feb 5 17:01:18 2018 (r328889) @@ -503,6 +503,7 @@ command_memmap(int argc, char *argv[]) UINT32 dver; EFI_STATUS status; int i, ndesc; + char line[80]; static char *types[] = { "Reserved", "LoaderCode", @@ -534,14 +535,19 @@ command_memmap(int argc, char *argv[]) } ndesc = sz / dsz; - printf("%23s %12s %12s %8s %4s\n", + snprintf(line, sizeof(line), "%23s %12s %12s %8s %4s\n", "Type", "Physical", "Virtual", "#Pages", "Attr"); + pager_open(); + if (pager_output(line)) { + pager_close(); + return (CMD_OK); + } for (i = 0, p = map; i < ndesc; i++, p = NextMemoryDescriptor(p, dsz)) { printf("%23s %012jx %012jx %08jx ", types[p->Type], - (uintmax_t)p->PhysicalStart, (uintmax_t)p->VirtualStart, - (uintmax_t)p->NumberOfPages); + (uintmax_t)p->PhysicalStart, (uintmax_t)p->VirtualStart, + (uintmax_t)p->NumberOfPages); if (p->Attribute & EFI_MEMORY_UC) printf("UC "); if (p->Attribute & EFI_MEMORY_WC) @@ -558,9 +564,11 @@ command_memmap(int argc, char *argv[]) printf("RP "); if (p->Attribute & EFI_MEMORY_XP) printf("XP "); - printf("\n"); + if (pager_output("\n")) + break; } + pager_close(); return (CMD_OK); } @@ -582,10 +590,17 @@ guid_to_string(EFI_GUID *guid) static int command_configuration(int argc, char *argv[]) { + char line[80]; UINTN i; - printf("NumberOfTableEntries=%lu\n", + snprintf(line, sizeof(line), "NumberOfTableEntries=%lu\n", (unsigned long)ST->NumberOfTableEntries); + pager_open(); + if (pager_output(line)) { + pager_close(); + return (CMD_OK); + } + for (i = 0; i < ST->NumberOfTableEntries; i++) { EFI_GUID *guid; @@ -611,9 +626,13 @@ command_configuration(int argc, char *argv[]) printf("FDT Table"); else printf("Unknown Table (%s)", guid_to_string(guid)); - printf(" at %p\n", ST->ConfigurationTable[i].VendorTable); + snprintf(line, sizeof(line), " at %p\n", + ST->ConfigurationTable[i].VendorTable); + if (pager_output(line)) + break; } + pager_close(); return (CMD_OK); } Modified: stable/11/sys/boot/i386/libfirewire/firewire.c ============================================================================== --- stable/11/sys/boot/i386/libfirewire/firewire.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/i386/libfirewire/firewire.c Mon Feb 5 17:01:18 2018 (r328889) @@ -69,7 +69,7 @@ static int fw_strategy(void *devdata, int flag, daddr_ size_t size, char *buf, size_t *rsize); static int fw_open(struct open_file *f, ...); static int fw_close(struct open_file *f); -static void fw_print(int verbose); +static int fw_print(int verbose); static void fw_cleanup(void); void fw_enable(void); @@ -148,21 +148,30 @@ fw_init(void) /* * Print information about OHCI chips */ -static void +static int fw_print(int verbose) { - int i; + char line[80]; + int i, ret = 0; struct fwohci_softc *sc; + printf("%s devices:", fwohci.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + for (i = 0; i < MAX_OHCI; i ++) { sc = &fwinfo[i]; if (sc->state == FWOHCI_STATE_DEAD) break; - printf("%d: locator=0x%04x devid=0x%08x" + snprintf(line, sizeof(line), "%d: locator=0x%04x devid=0x%08x" " base_addr=0x%08x handle=0x%08x bus_id=0x%08x\n", i, sc->locator, sc->devid, sc->base_addr, sc->handle, sc->bus_id); + ret = pager_output(line); + if (ret != 0) + break; } + return (ret); } static int Modified: stable/11/sys/boot/i386/libi386/bioscd.c ============================================================================== --- stable/11/sys/boot/i386/libi386/bioscd.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/i386/libi386/bioscd.c Mon Feb 5 17:01:18 2018 (r328889) @@ -100,7 +100,7 @@ static int bc_realstrategy(void *devdata, int flag, da size_t size, char *buf, size_t *rsize); static int bc_open(struct open_file *f, ...); static int bc_close(struct open_file *f); -static void bc_print(int verbose); +static int bc_print(int verbose); struct devsw bioscd = { "cd", @@ -177,20 +177,26 @@ bc_add(int biosdev) /* * Print information about disks */ -static void +static int bc_print(int verbose) { char line[80]; - int i; + int i, ret = 0; - pager_open(); + if (nbcinfo == 0) + return (0); + + printf("%s devices:", bioscd.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + for (i = 0; i < nbcinfo; i++) { - sprintf(line, " cd%d: Device 0x%x\n", i, + snprintf(line, sizeof(line), " cd%d: Device 0x%x\n", i, bcinfo[i].bc_sp.sp_devicespec); - if (pager_output(line)) + if ((ret = pager_output(line)) != 0) break; } - pager_close(); + return (ret); } /* Modified: stable/11/sys/boot/i386/libi386/biosdisk.c ============================================================================== --- stable/11/sys/boot/i386/libi386/biosdisk.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/i386/libi386/biosdisk.c Mon Feb 5 17:01:18 2018 (r328889) @@ -135,7 +135,7 @@ static int bd_realstrategy(void *devdata, int flag, da static int bd_open(struct open_file *f, ...); static int bd_close(struct open_file *f); static int bd_ioctl(struct open_file *f, u_long cmd, void *data); -static void bd_print(int verbose); +static int bd_print(int verbose); static void bd_cleanup(void); #ifdef LOADER_GELI_SUPPORT @@ -306,21 +306,28 @@ bd_int13probe(struct bdinfo *bd) /* * Print information about disks */ -static void +static int bd_print(int verbose) { static char line[80]; struct disk_devdesc dev; - int i; + int i, ret = 0; - pager_open(); + if (nbdinfo == 0) + return (0); + + printf("%s devices:", biosdisk.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + for (i = 0; i < nbdinfo; i++) { - sprintf(line, " disk%d: BIOS drive %c (%ju X %u):\n", i, + snprintf(line, sizeof(line), + " disk%d: BIOS drive %c (%ju X %u):\n", i, (bdinfo[i].bd_unit < 0x80) ? ('A' + bdinfo[i].bd_unit): ('C' + bdinfo[i].bd_unit - 0x80), (uintmax_t)bdinfo[i].bd_sectors, bdinfo[i].bd_sectorsize); - if (pager_output(line)) + if ((ret = pager_output(line)) != 0) break; dev.d_dev = &biosdisk; dev.d_unit = i; @@ -331,12 +338,14 @@ bd_print(int verbose) bdinfo[i].bd_sectorsize, (bdinfo[i].bd_flags & BD_FLOPPY) ? DISK_F_NOCACHE: 0) == 0) { - sprintf(line, " disk%d", i); - disk_print(&dev, line, verbose); + snprintf(line, sizeof(line), " disk%d", i); + ret = disk_print(&dev, line, verbose); disk_close(&dev); + if (ret != 0) + return (ret); } } - pager_close(); + return (ret); } /* Modified: stable/11/sys/boot/i386/libi386/pxe.c ============================================================================== --- stable/11/sys/boot/i386/libi386/pxe.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/i386/libi386/pxe.c Mon Feb 5 17:01:18 2018 (r328889) @@ -75,7 +75,7 @@ static int pxe_strategy(void *devdata, int flag, daddr size_t size, char *buf, size_t *rsize); static int pxe_open(struct open_file *f, ...); static int pxe_close(struct open_file *f); -static void pxe_print(int verbose); +static int pxe_print(int verbose); static void pxe_cleanup(void); static void pxe_setnfshandle(char *rootpath); @@ -382,14 +382,23 @@ pxe_close(struct open_file *f) return (0); } -static void +static int pxe_print(int verbose) { - + char line[255]; if (pxe_call == NULL) - return; + return (0); - printf(" pxe0: %s:%s\n", inet_ntoa(rootip), rootpath); + printf("%s devices:", pxedisk.dv_name); + if (pager_output("\n") != 0) + return (1); + if (verbose) { + snprintf(line, sizeof(line), " pxe0: %s:%s\n", + inet_ntoa(rootip), rootpath); + } else { + snprintf(line, sizeof(line), " pxe0:\n"); + } + return (pager_output(line)); } static void Modified: stable/11/sys/boot/mips/beri/loader/beri_disk_cfi.c ============================================================================== --- stable/11/sys/boot/mips/beri/loader/beri_disk_cfi.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/mips/beri/loader/beri_disk_cfi.c Mon Feb 5 17:01:18 2018 (r328889) @@ -47,7 +47,7 @@ static int beri_cfi_disk_close(struct open_file *); static void beri_cfi_disk_cleanup(void); static int beri_cfi_disk_strategy(void *, int, daddr_t, size_t, char *, size_t *); -static void beri_cfi_disk_print(int); +static int beri_cfi_disk_print(int); struct devsw beri_cfi_disk = { .dv_name = "cfi", @@ -112,25 +112,33 @@ beri_cfi_disk_close(struct open_file *f) return (disk_close(dev)); } -static void +static int beri_cfi_disk_print(int verbose) { struct disk_devdesc dev; char line[80]; + int ret; - sprintf(line, " cfi%d CFI flash device\n", 0); - pager_output(line); + printf("%s devices:", beri_cfi_disk.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + + snprintf(line, sizeof(line), " cfi%d CFI flash device\n", 0); + ret = pager_output(line); + if (ret != 0) + return (ret); dev.d_dev = &beri_cfi_disk; dev.d_unit = 0; dev.d_slice = -1; dev.d_partition = -1; if (disk_open(&dev, cfi_get_mediasize(), cfi_get_sectorsize(), 0) == 0) { - sprintf(line, " cfi%d", 0); - disk_print(&dev, line, verbose); + snprintf(line, sizeof(line), " cfi%d", 0); + ret = disk_print(&dev, line, verbose); disk_close(&dev); } + return (ret); } static void Modified: stable/11/sys/boot/mips/beri/loader/beri_disk_sdcard.c ============================================================================== --- stable/11/sys/boot/mips/beri/loader/beri_disk_sdcard.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/mips/beri/loader/beri_disk_sdcard.c Mon Feb 5 17:01:18 2018 (r328889) @@ -47,7 +47,7 @@ static int beri_sdcard_disk_close(struct open_file *); static void beri_sdcard_disk_cleanup(void); static int beri_sdcard_disk_strategy(void *, int, daddr_t, size_t, char *, size_t *); -static void beri_sdcard_disk_print(int); +static int beri_sdcard_disk_print(int); struct devsw beri_sdcard_disk = { .dv_name = "sdcard", @@ -123,19 +123,27 @@ beri_sdcard_disk_print(int verbose) { struct disk_devdesc dev; char line[80]; + int ret; - sprintf(line, " sdcard%d Altera SD card drive\n", 0); - pager_output(line); + printf("%s devices:", beri_sdcard_disk.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + + snprintf(line, sizeof(line), " sdcard%d Altera SD card drive\n", 0); + ret = pager_output(line); + if (ret != 0) + return (ret); dev.d_dev = &beri_sdcard_disk; dev.d_unit = 0; dev.d_slice = -1; dev.d_partition = -1; if (disk_open(&dev, altera_sdcard_get_mediasize(), altera_sdcard_get_sectorsize(), 0) == 0) { - sprintf(line, " sdcard%d", 0); - disk_print(&dev, line, verbose); + snprintf(line, sizeof(line), " sdcard%d", 0); + ret = disk_print(&dev, line, verbose); disk_close(&dev); } + return (ret); } static void Modified: stable/11/sys/boot/ofw/libofw/ofw_disk.c ============================================================================== --- stable/11/sys/boot/ofw/libofw/ofw_disk.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/ofw/libofw/ofw_disk.c Mon Feb 5 17:01:18 2018 (r328889) @@ -47,7 +47,7 @@ static int ofwd_strategy(void *devdata, int flag, dadd static int ofwd_open(struct open_file *f, ...); static int ofwd_close(struct open_file *f); static int ofwd_ioctl(struct open_file *f, u_long cmd, void *data); -static void ofwd_print(int verbose); +static int ofwd_print(int verbose); struct devsw ofwdisk = { "block", @@ -161,8 +161,8 @@ ofwd_ioctl(struct open_file *f __unused, u_long cmd __ return (EINVAL); } -static void +static int ofwd_print(int verbose __unused) { - + return (0); } Modified: stable/11/sys/boot/pc98/libpc98/bioscd.c ============================================================================== --- stable/11/sys/boot/pc98/libpc98/bioscd.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/pc98/libpc98/bioscd.c Mon Feb 5 17:01:18 2018 (r328889) @@ -99,7 +99,7 @@ static int bc_realstrategy(void *devdata, int flag, da size_t size, char *buf, size_t *rsize); static int bc_open(struct open_file *f, ...); static int bc_close(struct open_file *f); -static void bc_print(int verbose); +static int bc_print(int verbose); struct devsw bioscd = { "cd", @@ -173,20 +173,26 @@ bc_add(int biosdev) /* * Print information about disks */ -static void +static int bc_print(int verbose) { char line[80]; - int i; + int i, ret = 0; - pager_open(); + if (nbcinfo == 0) + return (0); + + printf("%s devices:", bioscd.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + for (i = 0; i < nbcinfo; i++) { sprintf(line, " cd%d: Device 0x%x\n", i, bcinfo[i].bc_sp.sp_devicespec); - if (pager_output(line)) + if ((ret = pager_output(line)) != 0) break; } - pager_close(); + return (ret); } /* Modified: stable/11/sys/boot/pc98/libpc98/biosdisk.c ============================================================================== --- stable/11/sys/boot/pc98/libpc98/biosdisk.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/pc98/libpc98/biosdisk.c Mon Feb 5 17:01:18 2018 (r328889) @@ -123,7 +123,7 @@ static int bd_realstrategy(void *devdata, int flag, da size_t size, char *buf, size_t *rsize); static int bd_open(struct open_file *f, ...); static int bd_close(struct open_file *f); -static void bd_print(int verbose); +static int bd_print(int verbose); struct devsw biosdisk = { "disk", @@ -249,22 +249,28 @@ bd_int13probe(struct bdinfo *bd) /* * Print information about disks */ -static void +static int bd_print(int verbose) { - int i, j, done; + int i, j, ret = 0; char line[80]; struct i386_devdesc dev; struct open_disk *od; struct pc98_partition *dptr; - pager_open(); - done = 0; - for (i = 0; i < nbdinfo && !done; i++) { - sprintf(line, " disk%d: BIOS drive %c:\n", i, 'A' + i); - if (pager_output(line)) - break; + if (nbdinfo == 0) + return (0); + printf("%s devices:", biosdisk.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + + for (i = 0; i < nbdinfo; i++) { + snprintf(line, sizeof(line), " disk%d: BIOS drive %c:\n", + i, 'A' + i); + if ((ret = pager_output(line)) != 0) + break; + /* try to open the whole disk */ dev.d_unit = i; dev.d_kind.biosdisk.slice = -1; @@ -278,17 +284,17 @@ bd_print(int verbose) /* Check for a "dedicated" disk */ for (j = 0; j < od->od_nslices; j++) { - sprintf(line, " disk%ds%d", i, j + 1); - if (bd_printslice(od, &dptr[j], line, verbose)) { - done = 1; - break; - } + snprintf(line, sizeof(line), " disk%ds%d", i, j + 1); + if ((ret = bd_printslice(od, &dptr[j], line, verbose)) != 0) + break; } } bd_closedisk(od); + if (ret != 0) + break; } } - pager_close(); + return (ret); } /* Given a size in 512 byte sectors, convert it to a human-readable number. */ Modified: stable/11/sys/boot/powerpc/kboot/hostdisk.c ============================================================================== --- stable/11/sys/boot/powerpc/kboot/hostdisk.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/powerpc/kboot/hostdisk.c Mon Feb 5 17:01:18 2018 (r328889) @@ -37,7 +37,7 @@ static int hostdisk_strategy(void *devdata, int flag, static int hostdisk_open(struct open_file *f, ...); static int hostdisk_close(struct open_file *f); static int hostdisk_ioctl(struct open_file *f, u_long cmd, void *data); -static void hostdisk_print(int verbose); +static int hostdisk_print(int verbose); struct devsw hostdisk = { "/dev", @@ -117,9 +117,9 @@ hostdisk_ioctl(struct open_file *f, u_long cmd, void * return (EINVAL); } -static void +static int hostdisk_print(int verbose) { - + return (0); } Modified: stable/11/sys/boot/powerpc/ps3/ps3cdrom.c ============================================================================== --- stable/11/sys/boot/powerpc/ps3/ps3cdrom.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/powerpc/ps3/ps3cdrom.c Mon Feb 5 17:01:18 2018 (r328889) @@ -49,7 +49,7 @@ static int ps3cdrom_strategy(void *devdata, int flag, size_t size, char *buf, size_t *rsize); static int ps3cdrom_open(struct open_file *f, ...); static int ps3cdrom_close(struct open_file *f); -static void ps3cdrom_print(int verbose); +static int ps3cdrom_print(int verbose); struct devsw ps3cdrom = { "cd", @@ -149,6 +149,7 @@ static int ps3cdrom_close(struct open_file *f) return 0; } -static void ps3cdrom_print(int verbose) +static int ps3cdrom_print(int verbose) { + return (0); } Modified: stable/11/sys/boot/powerpc/ps3/ps3disk.c ============================================================================== --- stable/11/sys/boot/powerpc/ps3/ps3disk.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/powerpc/ps3/ps3disk.c Mon Feb 5 17:01:18 2018 (r328889) @@ -61,7 +61,7 @@ static int ps3disk_strategy(void *devdata, int flag, d size_t size, char *buf, size_t *rsize); static int ps3disk_open(struct open_file *f, ...); static int ps3disk_close(struct open_file *f); -static void ps3disk_print(int verbose); +static int ps3disk_print(int verbose); struct devsw ps3disk = { "disk", @@ -186,8 +186,9 @@ static int ps3disk_close(struct open_file *f) return 0; } -static void ps3disk_print(int verbose) +static int ps3disk_print(int verbose) { + return (0); } static int ps3disk_open_gpt(struct ps3_devdesc *dev, struct open_dev *od) Modified: stable/11/sys/boot/uboot/lib/disk.c ============================================================================== --- stable/11/sys/boot/uboot/lib/disk.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/uboot/lib/disk.c Mon Feb 5 17:01:18 2018 (r328889) @@ -77,7 +77,7 @@ static int stor_strategy(void *, int, daddr_t, size_t, static int stor_open(struct open_file *, ...); static int stor_close(struct open_file *); static int stor_ioctl(struct open_file *f, u_long cmd, void *data); -static void stor_print(int); +static int stor_print(int); static void stor_cleanup(void); struct devsw uboot_storage = { @@ -237,30 +237,38 @@ stor_readdev(struct disk_devdesc *dev, daddr_t blk, si return (err); } -static void +static int stor_print(int verbose) { struct disk_devdesc dev; static char line[80]; - int i; + int i, ret = 0; - pager_open(); + if (stor_info_no == 0) + return (ret); + + printf("%s devices:", uboot_storage.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + for (i = 0; i < stor_info_no; i++) { dev.d_dev = &uboot_storage; dev.d_unit = i; dev.d_slice = -1; dev.d_partition = -1; - sprintf(line, "\tdisk%d (%s)\n", i, + snprintf(line, sizeof(line), "\tdisk%d (%s)\n", i, ub_stor_type(SI(&dev).type)); - if (pager_output(line)) + if ((ret = pager_output(line)) != 0) break; if (stor_opendev(&dev) == 0) { sprintf(line, "\tdisk%d", i); - disk_print(&dev, line, verbose); + ret = disk_print(&dev, line, verbose); disk_close(&dev); + if (ret != 0) + break; } } - pager_close(); + return (ret); } static int Modified: stable/11/sys/boot/usb/storage/umass_loader.c ============================================================================== --- stable/11/sys/boot/usb/storage/umass_loader.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/usb/storage/umass_loader.c Mon Feb 5 17:01:18 2018 (r328889) @@ -49,7 +49,7 @@ static int umass_disk_close(struct open_file *); static void umass_disk_cleanup(void); static int umass_disk_ioctl(struct open_file *, u_long, void *); static int umass_disk_strategy(void *, int, daddr_t, size_t, char *, size_t *); -static void umass_disk_print(int); +static int umass_disk_print(int); struct devsw umass_disk = { .dv_name = "umass", @@ -169,23 +169,30 @@ umass_disk_close(struct open_file *f) return (disk_close(dev)); } -static void +static int umass_disk_print(int verbose) { struct disk_devdesc dev; + printf("%s devices:", umass_disk.dv_name); + if (pager_output("\n") != 0) + return (1); + memset(&dev, 0, sizeof(dev)); - pager_output(" umass0 UMASS device\n"); + ret = pager_output(" umass0 UMASS device\n"); + if (ret != 0) + return (ret); dev.d_dev = &umass_disk; dev.d_unit = 0; dev.d_slice = -1; dev.d_partition = -1; if (umass_disk_open_sub(&dev) == 0) { - disk_print(&dev, " umass0", verbose); + ret = disk_print(&dev, " umass0", verbose); disk_close(&dev); } + return (ret); } static void Modified: stable/11/sys/boot/userboot/userboot/host.c ============================================================================== --- stable/11/sys/boot/userboot/userboot/host.c Mon Feb 5 16:28:03 2018 (r328888) +++ stable/11/sys/boot/userboot/userboot/host.c Mon Feb 5 17:01:18 2018 (r328889) @@ -134,13 +134,17 @@ host_dev_init(void) return (0); } -static void +static int host_dev_print(int verbose) { char line[80]; - sprintf(line, " host%d: Host filesystem\n", 0); - pager_output(line); + printf("%s devices:", host_dev.dv_name); + if (pager_output("\n") != 0) + return (1); + + snprintf(line, sizeof(line), " host%d: Host filesystem\n", 0); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Mon Feb 5 18:56:35 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E2FEEEE6D16; Mon, 5 Feb 2018 18:56:34 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 95252839ED; Mon, 5 Feb 2018 18:56:34 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F60D4DBB; Mon, 5 Feb 2018 18:56:34 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w15IuYTa009577; Mon, 5 Feb 2018 18:56:34 GMT (envelope-from vangyzen@FreeBSD.org) Received: (from vangyzen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w15IuYNt009576; Mon, 5 Feb 2018 18:56:34 GMT (envelope-from vangyzen@FreeBSD.org) Message-Id: <201802051856.w15IuYNt009576@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vangyzen set sender to vangyzen@FreeBSD.org using -f From: Eric van Gyzen Date: Mon, 5 Feb 2018 18:56:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328897 - stable/11/sys/netinet6 X-SVN-Group: stable-11 X-SVN-Commit-Author: vangyzen X-SVN-Commit-Paths: stable/11/sys/netinet6 X-SVN-Commit-Revision: 328897 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2018 18:56:35 -0000 Author: vangyzen Date: Mon Feb 5 18:56:34 2018 New Revision: 328897 URL: https://svnweb.freebsd.org/changeset/base/328897 Log: MFC r328552 ND6: Set the correct state for new neighbor cache entries Restore state 6. Many of the UNH tests end up exercising this state, where we have a new neighbor cache entry and a new link-layer entry is being created for it. The link-layer address is currently unknown so the initial state of the "llentry" should remain initialized to ND6_LLINFO_NOSTATE so that the ND code will send a solicitation. Setting this to ND6_LLINFO_STALE implies that the link-level entry is valid and can be used (but needs to be refreshed via the Neighbor Unreachability state machine). https://forums.freebsd.org/threads/64287/ Submitted by: Farrell Woods Reviewed by: mjoras, dab, ae Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D14059 Modified: stable/11/sys/netinet6/nd6.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet6/nd6.c ============================================================================== --- stable/11/sys/netinet6/nd6.c Mon Feb 5 18:48:00 2018 (r328896) +++ stable/11/sys/netinet6/nd6.c Mon Feb 5 18:56:34 2018 (r328897) @@ -2030,10 +2030,11 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *f if (ln_tmp == NULL) { /* No existing lle, mark as new entry (6,7) */ is_newentry = 1; - nd6_llinfo_setstate(ln, ND6_LLINFO_STALE); - if (lladdr != NULL) /* (7) */ + if (lladdr != NULL) { /* (7) */ + nd6_llinfo_setstate(ln, ND6_LLINFO_STALE); EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED); + } } else { lltable_free_entry(LLTABLE6(ifp), ln); ln = ln_tmp; From owner-svn-src-stable-11@freebsd.org Mon Feb 5 21:29:28 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 12530EF1708; Mon, 5 Feb 2018 21:29:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B61288A5DD; Mon, 5 Feb 2018 21:29:27 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B0CDA65D8; Mon, 5 Feb 2018 21:29:27 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w15LTRvE087322; Mon, 5 Feb 2018 21:29:27 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w15LTR9f087321; Mon, 5 Feb 2018 21:29:27 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802052129.w15LTR9f087321@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 5 Feb 2018 21:29:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328902 - stable/11/tools/boot X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/tools/boot X-SVN-Commit-Revision: 328902 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2018 21:29:28 -0000 Author: kevans Date: Mon Feb 5 21:29:27 2018 New Revision: 328902 URL: https://svnweb.freebsd.org/changeset/base/328902 Log: MFC r342882,r324979,r325115: sys/boot test scripts [Note: arm/armv7 has been removed in the interest of not having a failing architecture from the start] MFC r342882: Create a shell script to build sys/boot on all the architectures. MFC r324979: Do a chdir to SRCTOP/sys/boot before starting the run. MFC r325115: Fix parallel build issues and add MK_ZFS=no case Added: stable/11/tools/boot/ - copied from r324882, head/tools/boot/ Modified: stable/11/tools/boot/universe.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/tools/boot/universe.sh ============================================================================== --- head/tools/boot/universe.sh Sun Oct 22 22:52:23 2017 (r324882) +++ stable/11/tools/boot/universe.sh Mon Feb 5 21:29:27 2018 (r328902) @@ -19,9 +19,12 @@ # Output is put into _.boot.$TARGET_ARCH.log in sys.boot. # +top=$(make -V SRCTOP) +cd $top/sys/boot + for i in \ amd64/amd64 \ - arm/arm arm/armeb arm/armv7 \ + arm/arm arm/armeb \ arm64/aarch64 \ i386/i386 \ mips/mips mips/mips64 \ @@ -30,9 +33,33 @@ for i in \ ; do ta=${i##*/} echo -n "Building $ta..." - ( ( make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make -j 20 clean cleandepend cleandir obj depend all" \ - > _.boot.${ta}.log 2>&1 ) && echo Success ) || echo Fail + if ! make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make clean cleandepend cleandir obj depend" \ + > _.boot.${ta}.log 2>&1; then + echo "Fail (cleanup)" + continue + fi + if ! make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make -j 20 all" \ + >> _.boot.${ta}.log 2>&1; then + echo "Fail (build)" + continue + fi + echo "Success" done - - - +for i in \ + amd64/amd64 \ + i386/i386 \ + ; do + ta=${i##*/} + echo -n "Building $ta MK_ZFS=no..." + if ! make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make clean cleandepend cleandir obj depend" \ + > _.boot.${ta}.noZFS.log 2>&1; then + echo "Fail (cleanup)" + continue + fi + if ! make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make MK_ZFS=no -j 20 all" \ + >> _.boot.${ta}.noZFS.log 2>&1; then + echo "Fail (build)" + continue + fi + echo "Success" +done From owner-svn-src-stable-11@freebsd.org Mon Feb 5 22:21:31 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 317DCEF4D4B for ; Mon, 5 Feb 2018 22:21:31 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-wm0-x236.google.com (mail-wm0-x236.google.com [IPv6:2a00:1450:400c:c09::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9F7A98C86A for ; Mon, 5 Feb 2018 22:21:30 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-wm0-x236.google.com with SMTP id t74so152289wme.3 for ; Mon, 05 Feb 2018 14:21:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=NEvD7tUhf/oKLFBSzkEN0h7J64XVyNSI+YSbh58ppsA=; b=rrB6RHARSNQB62HsDa+qD4HJC7Sn8wZ1CzjfrVRChQ+v/2XfSr4kPfD1PPZISEQ0Tf BmxHJVyKJKeFCx1Kep5aAqlU5O3c9MTb3IgDYdJsS9LvqzKXTpyo+y4pWetRoRRSLaQO 40SKGzRVu/7t9GUdVPtUhCQKHeWpA2eMbqYoOuq0Uxzm7KR1Ce1cs3iXo5X+zKOd3SMw tmrh5cFojbIyTlwFC7KIrv9u7qWNd11MRKVe6Kc/9fWM3sxaZqaIFkw+tO6Gqr4nUqH3 o4nXtHraWLL/PM2VaDZD8/KlwMxjsGJzH2bXOvjyoIxS56GkJvnzF7X3DEzH7wyAmRmE EXDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=NEvD7tUhf/oKLFBSzkEN0h7J64XVyNSI+YSbh58ppsA=; b=M7SPlaNjh0DY4BOT8x/rwJBKhw3hlP1E49t9vxMR66c1hZAx6dz7rBGmv+0BGoTEZR S1djAYN8T/UeGWLIN1AXYQhHieM0x7pEnjWuMXLPjv35VKbEJZGOPtYO5vO/ZRHGjbWs VYb2moSElvwIJkliBmEyfHUPQl3D+fsZtjwcdhY33vbVM8T4HFN1fSMa6PTmLiwWBhpr K0ImrlgMNQ3F4PcHqjVBdfr+MBqc/RW/zMdDfrt5I7+nYhEjJp4+vuYpAkmyyIFzWFWg eivui6J2BZq7eoV40LIQiulb/mfAhEy39TrDMvV6r+ZceWO+ERVmCnXGMf3jVJ+SJd19 7Pbg== X-Gm-Message-State: APf1xPCxVMYZbyrXsa7+x+T7OvybbY/F1dN6wI/4yla2UQIuyR/sjjpN 8KBT2jTY8FXGmuAOO/gPYq3dCon7p5CSXkb2bLTrKw== X-Google-Smtp-Source: AH8x224NHqSsyuCn+7r+UW/wvuNSV2AE513YTydPIIouSfB4pPPwfpNYGcJaLuHg4BgLhpl5EouTt5GVqxoajuvuCmw= X-Received: by 10.80.183.214 with SMTP id i22mr1005838ede.15.1517869289604; Mon, 05 Feb 2018 14:21:29 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.148.90 with HTTP; Mon, 5 Feb 2018 14:21:29 -0800 (PST) In-Reply-To: <201802022322.w12NMwnq074609@repo.freebsd.org> References: <201802022322.w12NMwnq074609@repo.freebsd.org> From: Oliver Pinter Date: Mon, 5 Feb 2018 23:21:29 +0100 Message-ID: Subject: Re: svn commit: r328820 - in stable/11/sys/cam: . ata nvme scsi To: Alexander Motin Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-stable@freebsd.org" , "svn-src-stable-11@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2018 22:21:31 -0000 On Saturday, February 3, 2018, Alexander Motin wrote: > Author: mav > Date: Fri Feb 2 23:22:58 2018 > New Revision: 328820 > URL: https://svnweb.freebsd.org/changeset/base/328820 > > Log: > MFC r303468 (by imp): > Move protocol specific stuff into a linker set object that's > per-protocol. This reduces the number scsi symbols references by > cam_xpt significantly, and eliminates all ata / nvme symbols. There's > still some NVME / ATA specific code for dealing with XPT_NVME_IO and > XPT_ATA_IO respectively, and a bunch of scsi-specific code, but this > is progress. > > Hi! Once you finished with the cherry-picking of nvme related commits, could you please bump the __FreeBSD_version and add them to release notes? > Modified: > stable/11/sys/cam/ata/ata_xpt.c > stable/11/sys/cam/cam_xpt.c > stable/11/sys/cam/cam_xpt_internal.h > stable/11/sys/cam/nvme/nvme_xpt.c > stable/11/sys/cam/scsi/scsi_xpt.c > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/sys/cam/ata/ata_xpt.c > ============================================================ > ================== > --- stable/11/sys/cam/ata/ata_xpt.c Fri Feb 2 23:19:20 2018 > (r328819) > +++ stable/11/sys/cam/ata/ata_xpt.c Fri Feb 2 23:22:58 2018 > (r328820) > @@ -189,6 +189,11 @@ static void ata_dev_async(u_int32_t > async_code, > void *async_arg); > static void ata_action(union ccb *start_ccb); > static void ata_announce_periph(struct cam_periph *periph); > +static void ata_proto_announce(struct cam_ed *device); > +static void ata_proto_denounce(struct cam_ed *device); > +static void ata_proto_debug_out(union ccb *ccb); > +static void semb_proto_announce(struct cam_ed *device); > +static void semb_proto_denounce(struct cam_ed *device); > > static int ata_dma = 1; > static int atapi_dma = 1; > @@ -215,6 +220,43 @@ ATA_XPT_XPORT(sata, SATA); > > #undef ATA_XPORT_XPORT > > +static struct xpt_proto_ops ata_proto_ops_ata = { > + .announce = ata_proto_announce, > + .denounce = ata_proto_denounce, > + .debug_out = ata_proto_debug_out, > +}; > +static struct xpt_proto ata_proto_ata = { > + .proto = PROTO_ATA, > + .name = "ata", > + .ops = &ata_proto_ops_ata, > +}; > + > +static struct xpt_proto_ops ata_proto_ops_satapm = { > + .announce = ata_proto_announce, > + .denounce = ata_proto_denounce, > + .debug_out = ata_proto_debug_out, > +}; > +static struct xpt_proto ata_proto_satapm = { > + .proto = PROTO_SATAPM, > + .name = "satapm", > + .ops = &ata_proto_ops_satapm, > +}; > + > +static struct xpt_proto_ops ata_proto_ops_semb = { > + .announce = semb_proto_announce, > + .denounce = semb_proto_denounce, > + .debug_out = ata_proto_debug_out, > +}; > +static struct xpt_proto ata_proto_semb = { > + .proto = PROTO_SEMB, > + .name = "semb", > + .ops = &ata_proto_ops_semb, > +}; > + > +CAM_XPT_PROTO(ata_proto_ata); > +CAM_XPT_PROTO(ata_proto_satapm); > +CAM_XPT_PROTO(ata_proto_semb); > + > static void > probe_periph_init() > { > @@ -2116,4 +2158,41 @@ ata_announce_periph(struct cam_periph *periph) > printf(")"); > } > printf("\n"); > +} > + > +static void > +ata_proto_announce(struct cam_ed *device) > +{ > + ata_print_ident(&device->ident_data); > +} > + > +static void > +ata_proto_denounce(struct cam_ed *device) > +{ > + ata_print_ident_short(&device->ident_data); > +} > + > +static void > +semb_proto_announce(struct cam_ed *device) > +{ > + semb_print_ident((struct sep_identify_data *)&device->ident_data); > +} > + > +static void > +semb_proto_denounce(struct cam_ed *device) > +{ > + semb_print_ident_short((struct sep_identify_data > *)&device->ident_data); > +} > + > +static void > +ata_proto_debug_out(union ccb *ccb) > +{ > + char cdb_str[(sizeof(struct ata_cmd) * 3) + 1]; > + > + if (ccb->ccb_h.func_code != XPT_ATA_IO) > + return; > + > + CAM_DEBUG(ccb->ccb_h.path, > + CAM_DEBUG_CDB,("%s. ACB: %s\n", ata_op_string(&ccb->ataio.cmd) > , > + ata_cmd_string(&ccb->ataio.cmd, cdb_str, > sizeof(cdb_str)))); > } > > Modified: stable/11/sys/cam/cam_xpt.c > ============================================================ > ================== > --- stable/11/sys/cam/cam_xpt.c Fri Feb 2 23:19:20 2018 (r328819) > +++ stable/11/sys/cam/cam_xpt.c Fri Feb 2 23:22:58 2018 (r328820) > @@ -747,6 +747,19 @@ cam_module_event_handler(module_t mod, int what, void > return 0; > } > > +static struct xpt_proto * > +xpt_proto_find(cam_proto proto) > +{ > + struct xpt_proto **pp; > + > + SET_FOREACH(pp, cam_xpt_proto_set) { > + if ((*pp)->proto == proto) > + return *pp; > + } > + > + return NULL; > +} > + > static void > xpt_rescan_done(struct cam_periph *periph, union ccb *done_ccb) > { > @@ -1013,6 +1026,7 @@ void > xpt_announce_periph(struct cam_periph *periph, char *announce_string) > { > struct cam_path *path = periph->path; > + struct xpt_proto *proto; > > cam_periph_assert(periph, MA_OWNED); > periph->flags |= CAM_PERIPH_ANNOUNCED; > @@ -1026,25 +1040,20 @@ xpt_announce_periph(struct cam_periph *periph, > char *a > path->target->target_id, > (uintmax_t)path->device->lun_id); > printf("%s%d: ", periph->periph_name, periph->unit_number); > - if (path->device->protocol == PROTO_SCSI) > - scsi_print_inquiry(&path->device->inq_data); > - else if (path->device->protocol == PROTO_ATA || > - path->device->protocol == PROTO_SATAPM) > - ata_print_ident(&path->device->ident_data); > - else if (path->device->protocol == PROTO_SEMB) > - semb_print_ident( > - (struct sep_identify_data *)&path->device->ident_data); > - else if (path->device->protocol == PROTO_NVME) > - nvme_print_ident(path->device->nvme_cdata, > path->device->nvme_data); > + proto = xpt_proto_find(path->device->protocol); > + if (proto) > + proto->ops->announce(path->device); > else > - printf("Unknown protocol device\n"); > + printf("%s%d: Unknown protocol device %d\n", > + periph->periph_name, periph->unit_number, > + path->device->protocol); > if (path->device->serial_num_len > 0) { > /* Don't wrap the screen - print only the first 60 chars > */ > printf("%s%d: Serial Number %.60s\n", periph->periph_name, > periph->unit_number, path->device->serial_num); > } > /* Announce transport details. */ > - (*(path->bus->xport->ops->announce))(periph); > + path->bus->xport->ops->announce(periph); > /* Announce command queueing. */ > if (path->device->inq_flags & SID_CmdQue > || path->device->flags & CAM_DEV_TAG_AFTER_COUNT) { > @@ -1070,6 +1079,7 @@ void > xpt_denounce_periph(struct cam_periph *periph) > { > struct cam_path *path = periph->path; > + struct xpt_proto *proto; > > cam_periph_assert(periph, MA_OWNED); > printf("%s%d at %s%d bus %d scbus%d target %d lun %jx\n", > @@ -1081,18 +1091,13 @@ xpt_denounce_periph(struct cam_periph *periph) > path->target->target_id, > (uintmax_t)path->device->lun_id); > printf("%s%d: ", periph->periph_name, periph->unit_number); > - if (path->device->protocol == PROTO_SCSI) > - scsi_print_inquiry_short(&path->device->inq_data); > - else if (path->device->protocol == PROTO_ATA || > - path->device->protocol == PROTO_SATAPM) > - ata_print_ident_short(&path->device->ident_data); > - else if (path->device->protocol == PROTO_SEMB) > - semb_print_ident_short( > - (struct sep_identify_data *)&path->device->ident_data); > - else if (path->device->protocol == PROTO_NVME) > - nvme_print_ident(path->device->nvme_cdata, > path->device->nvme_data); > + proto = xpt_proto_find(path->device->protocol); > + if (proto) > + proto->ops->denounce(path->device); > else > - printf("Unknown protocol device"); > + printf("%s%d: Unknown protocol device %d\n", > + periph->periph_name, periph->unit_number, > + path->device->protocol); > if (path->device->serial_num_len > 0) > printf(" s/n %.60s", path->device->serial_num); > printf(" detached\n"); > @@ -3257,7 +3262,6 @@ restart: > static void > xpt_run_devq(struct cam_devq *devq) > { > - char cdb_str[(SCSI_MAX_CDBLEN * 3) + 1]; > struct mtx *mtx; > > CAM_DEBUG_PRINT(CAM_DEBUG_XPT, ("xpt_run_devq\n")); > @@ -3269,6 +3273,7 @@ xpt_run_devq(struct cam_devq *devq) > struct cam_ed *device; > union ccb *work_ccb; > struct cam_sim *sim; > + struct xpt_proto *proto; > > device = (struct cam_ed *)camq_remove(&devq->send_queue, > CAMQ_HEAD); > @@ -3334,32 +3339,12 @@ xpt_run_devq(struct cam_devq *devq) > work_ccb->ccb_h.flags &= > ~CAM_TAG_ACTION_VALID; > } > > - switch (work_ccb->ccb_h.func_code) { > - case XPT_SCSI_IO: > - CAM_DEBUG(work_ccb->ccb_h.path, > - CAM_DEBUG_CDB,("%s. CDB: %s\n", > - scsi_op_desc(work_ccb->csio. > cdb_io.cdb_bytes[0], > - &device->inq_data), > - scsi_cdb_string(work_ccb-> > csio.cdb_io.cdb_bytes, > - cdb_str, sizeof(cdb_str)))); > - break; > - case XPT_ATA_IO: > - CAM_DEBUG(work_ccb->ccb_h.path, > - CAM_DEBUG_CDB,("%s. ACB: %s\n", > - ata_op_string(&work_ccb->ataio.cmd), > - ata_cmd_string(&work_ccb->ataio.cmd, > - cdb_str, sizeof(cdb_str)))); > - break; > - case XPT_NVME_IO: > - CAM_DEBUG(work_ccb->ccb_h.path, > - CAM_DEBUG_CDB,("%s. NCB: %s\n", > - nvme_op_string(&work_ccb->nvmeio.cmd), > - nvme_cmd_string(&work_ccb->nvmeio.cmd, > - cdb_str, sizeof(cdb_str)))); > - break; > - default: > - break; > - } > + KASSERT(device == work_ccb->ccb_h.path->device, > + ("device (%p) / path->device (%p) mismatch", > + device, work_ccb->ccb_h.path->device)); > + proto = xpt_proto_find(device->protocol); > + if (proto && proto->ops->debug_out) > + proto->ops->debug_out(work_ccb); > > /* > * Device queues can be shared among multiple SIM instances > > Modified: stable/11/sys/cam/cam_xpt_internal.h > ============================================================ > ================== > --- stable/11/sys/cam/cam_xpt_internal.h Fri Feb 2 23:19:20 2018 > (r328819) > +++ stable/11/sys/cam/cam_xpt_internal.h Fri Feb 2 23:22:58 2018 > (r328820) > @@ -66,6 +66,26 @@ SET_DECLARE(cam_xpt_xport_set, struct xpt_xport); > #define CAM_XPT_XPORT(data) \ > DATA_SET(cam_xpt_xport_set, data) > > +typedef void (*xpt_proto_announce_func)(struct cam_ed *); > +typedef void (*xpt_proto_debug_out_func)(union ccb *); > + > +struct xpt_proto_ops { > + xpt_proto_announce_func announce; > + xpt_proto_announce_func denounce; > + xpt_proto_debug_out_func debug_out; > +}; > + > +struct xpt_proto { > + cam_proto proto; > + const char *name; > + struct xpt_proto_ops *ops; > +}; > + > +SET_DECLARE(cam_xpt_proto_set, struct xpt_proto); > +#define CAM_XPT_PROTO(data) \ > + DATA_SET(cam_xpt_proto_set, data) > + > + > /* > * The CAM EDT (Existing Device Table) contains the device information for > * all devices for all busses in the system. The table contains a > > Modified: stable/11/sys/cam/nvme/nvme_xpt.c > ============================================================ > ================== > --- stable/11/sys/cam/nvme/nvme_xpt.c Fri Feb 2 23:19:20 2018 > (r328819) > +++ stable/11/sys/cam/nvme/nvme_xpt.c Fri Feb 2 23:22:58 2018 > (r328820) > @@ -152,6 +152,9 @@ static void nvme_dev_async(u_int32_t async_code, > void *async_arg); > static void nvme_action(union ccb *start_ccb); > static void nvme_announce_periph(struct cam_periph *periph); > +static void nvme_proto_announce(struct cam_ed *device); > +static void nvme_proto_denounce(struct cam_ed *device); > +static void nvme_proto_debug_out(union ccb *ccb); > > static struct xpt_xport_ops nvme_xport_ops = { > .alloc_device = nvme_alloc_device, > @@ -171,6 +174,18 @@ NVME_XPT_XPORT(nvme, NVME); > > #undef NVME_XPT_XPORT > > +static struct xpt_proto_ops nvme_proto_ops = { > + .announce = nvme_proto_announce, > + .denounce = nvme_proto_denounce, > + .debug_out = nvme_proto_debug_out, > +}; > +static struct xpt_proto nvme_proto = { > + .proto = PROTO_NVME, > + .name = "nvme", > + .ops = &nvme_proto_ops, > +}; > +CAM_XPT_PROTO(nvme_proto); > + > static void > nvme_probe_periph_init() > { > @@ -620,3 +635,29 @@ nvme_announce_periph(struct cam_periph *periph) > /* XXX NVME STUFF HERE */ > printf("\n"); > } > + > +static void > +nvme_proto_announce(struct cam_ed *device) > +{ > + nvme_print_ident(device->nvme_cdata, device->nvme_data); > +} > + > +static void > +nvme_proto_denounce(struct cam_ed *device) > +{ > + nvme_print_ident(device->nvme_cdata, device->nvme_data); > +} > + > +static void > +nvme_proto_debug_out(union ccb *ccb) > +{ > + char cdb_str[(sizeof(struct nvme_command) * 3) + 1]; > + > + if (ccb->ccb_h.func_code != XPT_NVME_IO) > + return; > + > + CAM_DEBUG(ccb->ccb_h.path, > + CAM_DEBUG_CDB,("%s. NCB: %s\n", nvme_op_string(&ccb->nvmeio. > cmd), > + nvme_cmd_string(&ccb->nvmeio.cmd, cdb_str, > sizeof(cdb_str)))); > +} > + > > Modified: stable/11/sys/cam/scsi/scsi_xpt.c > ============================================================ > ================== > --- stable/11/sys/cam/scsi/scsi_xpt.c Fri Feb 2 23:19:20 2018 > (r328819) > +++ stable/11/sys/cam/scsi/scsi_xpt.c Fri Feb 2 23:22:58 2018 > (r328820) > @@ -589,6 +589,9 @@ static void scsi_dev_async(u_int32_t async_code, > void *async_arg); > static void scsi_action(union ccb *start_ccb); > static void scsi_announce_periph(struct cam_periph *periph); > +static void scsi_proto_announce(struct cam_ed *device); > +static void scsi_proto_denounce(struct cam_ed *device); > +static void scsi_proto_debug_out(union ccb *ccb); > > static struct xpt_xport_ops scsi_xport_ops = { > .alloc_device = scsi_alloc_device, > @@ -614,6 +617,18 @@ SCSI_XPT_XPORT(ppb, PPB); > > #undef SCSI_XPORT_XPORT > > +static struct xpt_proto_ops scsi_proto_ops = { > + .announce = scsi_proto_announce, > + .denounce = scsi_proto_denounce, > + .debug_out = scsi_proto_debug_out, > +}; > +static struct xpt_proto scsi_proto = { > + .proto = PROTO_SCSI, > + .name = "scsi", > + .ops = &scsi_proto_ops, > +}; > +CAM_XPT_PROTO(scsi_proto); > + > static void > probe_periph_init() > { > @@ -3102,3 +3117,30 @@ scsi_announce_periph(struct cam_periph *periph) > printf("\n"); > } > > +static void > +scsi_proto_announce(struct cam_ed *device) > +{ > + scsi_print_inquiry(&device->inq_data); > +} > + > +static void > +scsi_proto_denounce(struct cam_ed *device) > +{ > + scsi_print_inquiry_short(&device->inq_data); > +} > + > +static void > +scsi_proto_debug_out(union ccb *ccb) > +{ > + char cdb_str[(SCSI_MAX_CDBLEN * 3) + 1]; > + struct cam_ed *device; > + > + if (ccb->ccb_h.func_code != XPT_SCSI_IO) > + return; > + > + device = ccb->ccb_h.path->device; > + CAM_DEBUG(ccb->ccb_h.path, > + CAM_DEBUG_CDB,("%s. CDB: %s\n", > + scsi_op_desc(ccb->csio.cdb_io.cdb_bytes[0], > &device->inq_data), > + scsi_cdb_string(ccb->csio.cdb_io.cdb_bytes, cdb_str, > sizeof(cdb_str)))); > +} > _______________________________________________ > svn-src-stable-11@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-stable-11 > To unsubscribe, send any mail to " > svn-src-stable-11-unsubscribe@freebsd.org" > From owner-svn-src-stable-11@freebsd.org Tue Feb 6 07:47:23 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4415CEDED17; Tue, 6 Feb 2018 07:47:23 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id ECC707B2E8; Tue, 6 Feb 2018 07:47:22 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E7BF214F2A; Tue, 6 Feb 2018 07:47:22 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w167lMVc001118; Tue, 6 Feb 2018 07:47:22 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w167lMgh001117; Tue, 6 Feb 2018 07:47:22 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201802060747.w167lMgh001117@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Tue, 6 Feb 2018 07:47:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328920 - stable/11/share/man/man4 X-SVN-Group: stable-11 X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: stable/11/share/man/man4 X-SVN-Commit-Revision: 328920 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 07:47:23 -0000 Author: delphij Date: Tue Feb 6 07:47:22 2018 New Revision: 328920 URL: https://svnweb.freebsd.org/changeset/base/328920 Log: MFC r328273 (kevlo): Document how to load nmdm(4) from a kernel module. Modified: stable/11/share/man/man4/nmdm.4 Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/nmdm.4 ============================================================================== --- stable/11/share/man/man4/nmdm.4 Tue Feb 6 06:55:55 2018 (r328919) +++ stable/11/share/man/man4/nmdm.4 Tue Feb 6 07:47:22 2018 (r328920) @@ -21,14 +21,26 @@ .\" .\" $FreeBSD$ .\" -.Dd January 27, 2005 +.Dd January 23, 2018 .Dt NMDM 4 .Os .Sh NAME .Nm nmdm .Nd nullmodem terminal driver .Sh SYNOPSIS +To compile this driver into the kernel, +place the following line in your +kernel configuration file: +.Bd -ragged -offset indent .Cd "device nmdm" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +nmdm_load="YES" +.Ed .Sh DESCRIPTION The .Nm From owner-svn-src-stable-11@freebsd.org Tue Feb 6 14:04:40 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8D03AED8797; Tue, 6 Feb 2018 14:04:40 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3B9E06A9A9; Tue, 6 Feb 2018 14:04:40 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 366E918D8F; Tue, 6 Feb 2018 14:04:40 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w16E4drB089449; Tue, 6 Feb 2018 14:04:39 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w16E4dPl089448; Tue, 6 Feb 2018 14:04:39 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802061404.w16E4dPl089448@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 6 Feb 2018 14:04:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328929 - stable/11 X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11 X-SVN-Commit-Revision: 328929 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 14:04:40 -0000 Author: kevans Date: Tue Feb 6 14:04:39 2018 New Revision: 328929 URL: https://svnweb.freebsd.org/changeset/base/328929 Log: MFC r325116,r325515: Stop masking errors during buildenv MFC r325116(imp): Return proper status from buildenv. make buildenv BUILDENV_SHELL= more useful. Remove '|| true' from the command line so that errors are properly returned. There appears to be no reason for it, and it dates back to the original commit by ru@. MFC r325515 (imp): Note interactive shell errors for make buildenv and add a warning for people tempted to add back the || true to get rid of them. Modified: stable/11/Makefile.inc1 Directory Properties: stable/11/ (props changed) Modified: stable/11/Makefile.inc1 ============================================================================== --- stable/11/Makefile.inc1 Tue Feb 6 12:22:42 2018 (r328928) +++ stable/11/Makefile.inc1 Tue Feb 6 14:04:39 2018 (r328929) @@ -853,13 +853,20 @@ buildenvvars: .PHONY .endif .endif BUILDENV_DIR?= ${.CURDIR} +# +# Note: make will report any errors the shell reports. This can +# be odd if the last command in an interactive shell generates an +# error or is terminated by SIGINT. These reported errors look bad, +# but are harmless. Allowing them also allows BUIDLENV_SHELL to +# be a complex command whose status will be returned to the caller. +# Some scripts in tools rely on this behavior to report build errors. +# buildenv: .PHONY @echo Entering world for ${TARGET_ARCH}:${TARGET} .if ${BUILDENV_SHELL:M*zsh*} @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE} .endif - @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \ - || true + @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}} toolchain: ${TOOLCHAIN_TGTS} .PHONY From owner-svn-src-stable-11@freebsd.org Tue Feb 6 18:01:42 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 59639EEE328; Tue, 6 Feb 2018 18:01:42 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0ECC376892; Tue, 6 Feb 2018 18:01:42 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 094BF1B52C; Tue, 6 Feb 2018 18:01:42 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w16I1fiC009962; Tue, 6 Feb 2018 18:01:41 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w16I1fvp009942; Tue, 6 Feb 2018 18:01:41 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802061801.w16I1fvp009942@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 6 Feb 2018 18:01:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328941 - stable/11/sys/boot/mips/beri/loader X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/sys/boot/mips/beri/loader X-SVN-Commit-Revision: 328941 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 18:01:42 -0000 Author: kevans Date: Tue Feb 6 18:01:41 2018 New Revision: 328941 URL: https://svnweb.freebsd.org/changeset/base/328941 Log: MFC r308774: loader: beri_sdcard_disk_print() needs to return int. r308434 did change the return type for dv_print callbacks, but the return type for beri_sdcard_disk_print() was left unchanged, causing compile errors. Modified: stable/11/sys/boot/mips/beri/loader/beri_disk_sdcard.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/boot/mips/beri/loader/beri_disk_sdcard.c ============================================================================== --- stable/11/sys/boot/mips/beri/loader/beri_disk_sdcard.c Tue Feb 6 17:26:11 2018 (r328940) +++ stable/11/sys/boot/mips/beri/loader/beri_disk_sdcard.c Tue Feb 6 18:01:41 2018 (r328941) @@ -118,7 +118,7 @@ beri_sdcard_disk_close(struct open_file *f) return (disk_close(dev)); } -static void +static int beri_sdcard_disk_print(int verbose) { struct disk_devdesc dev; From owner-svn-src-stable-11@freebsd.org Tue Feb 6 19:09:03 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DAFCCEF3BA5; Tue, 6 Feb 2018 19:09:03 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8B07479FF9; Tue, 6 Feb 2018 19:09:03 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 82A3C1BFD6; Tue, 6 Feb 2018 19:09:03 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w16J93Lu042669; Tue, 6 Feb 2018 19:09:03 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w16J93KW042667; Tue, 6 Feb 2018 19:09:03 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201802061909.w16J93KW042667@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Tue, 6 Feb 2018 19:09:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328942 - in stable/11/lib/libc: gen sys X-SVN-Group: stable-11 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: in stable/11/lib/libc: gen sys X-SVN-Commit-Revision: 328942 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 19:09:04 -0000 Author: mckusick Date: Tue Feb 6 19:09:03 2018 New Revision: 328942 URL: https://svnweb.freebsd.org/changeset/base/328942 Log: MFC of 328304 and 328382. Do not dedup egid (group entry 0) Modified: stable/11/lib/libc/gen/getgrent.c stable/11/lib/libc/sys/setgroups.2 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/gen/getgrent.c ============================================================================== --- stable/11/lib/libc/gen/getgrent.c Tue Feb 6 18:01:41 2018 (r328941) +++ stable/11/lib/libc/gen/getgrent.c Tue Feb 6 19:09:03 2018 (r328942) @@ -434,7 +434,7 @@ gr_addgid(gid_t gid, gid_t *groups, int maxgrp, int *g { int ret, dupc; - for (dupc = 0; dupc < MIN(maxgrp, *grpcnt); dupc++) { + for (dupc = 1; dupc < MIN(maxgrp, *grpcnt); dupc++) { if (groups[dupc] == gid) return 1; } Modified: stable/11/lib/libc/sys/setgroups.2 ============================================================================== --- stable/11/lib/libc/sys/setgroups.2 Tue Feb 6 18:01:41 2018 (r328941) +++ stable/11/lib/libc/sys/setgroups.2 Tue Feb 6 19:09:03 2018 (r328942) @@ -28,7 +28,7 @@ .\" @(#)setgroups.2 8.2 (Berkeley) 4/16/94 .\" $FreeBSD$ .\" -.Dd April 16, 1994 +.Dd January 19, 2018 .Dt SETGROUPS 2 .Os .Sh NAME @@ -56,6 +56,23 @@ more than .Dv {NGROUPS_MAX}+1 . .Pp Only the super-user may set a new group list. +.Pp +The first entry of the group array +.Pq Va gidset[0] +is used as the effective group-ID for the process. +This entry is over-written when a setgid program is run. +To avoid losing access to the privileges of the +.Va gidset[0] +entry, it should be duplicated later in the group array. +By convention, +this happens because the group value indicated +in the password file also appears in +.Pa /etc/group . +The group value in the password file is placed in +.Va gidset[0] +and that value then gets added a second time when the +.Pa /etc/group +file is scanned to create the group set. .Sh RETURN VALUES .Rv -std setgroups .Sh ERRORS From owner-svn-src-stable-11@freebsd.org Tue Feb 6 19:13:45 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F278DEF4207; Tue, 6 Feb 2018 19:13:44 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A3C217A617; Tue, 6 Feb 2018 19:13:44 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9EB6B1C16E; Tue, 6 Feb 2018 19:13:44 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w16JDi9X047548; Tue, 6 Feb 2018 19:13:44 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w16JDiP8047547; Tue, 6 Feb 2018 19:13:44 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201802061913.w16JDiP8047547@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Tue, 6 Feb 2018 19:13:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328944 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 328944 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 19:13:45 -0000 Author: mckusick Date: Tue Feb 6 19:13:44 2018 New Revision: 328944 URL: https://svnweb.freebsd.org/changeset/base/328944 Log: MFC of 328643. fix vn_printf listing of its union Modified: stable/11/sys/kern/vfs_subr.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/vfs_subr.c ============================================================================== --- stable/11/sys/kern/vfs_subr.c Tue Feb 6 19:09:49 2018 (r328943) +++ stable/11/sys/kern/vfs_subr.c Tue Feb 6 19:13:44 2018 (r328944) @@ -3355,8 +3355,25 @@ vn_printf(struct vnode *vp, const char *fmt, ...) va_end(ap); printf("%p: ", (void *)vp); printf("tag %s, type %s\n", vp->v_tag, typename[vp->v_type]); - printf(" usecount %d, writecount %d, refcount %d mountedhere %p\n", - vp->v_usecount, vp->v_writecount, vp->v_holdcnt, vp->v_mountedhere); + printf(" usecount %d, writecount %d, refcount %d", + vp->v_usecount, vp->v_writecount, vp->v_holdcnt); + switch (vp->v_type) { + case VDIR: + printf(" mountedhere %p\n", vp->v_mountedhere); + break; + case VCHR: + printf(" rdev %p\n", vp->v_rdev); + break; + case VSOCK: + printf(" socket %p\n", vp->v_unpcb); + break; + case VFIFO: + printf(" fifoinfo %p\n", vp->v_fifoinfo); + break; + default: + printf("\n"); + break; + } buf[0] = '\0'; buf[1] = '\0'; if (vp->v_vflag & VV_ROOT) From owner-svn-src-stable-11@freebsd.org Tue Feb 6 19:17:06 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 25DD1EF4784; Tue, 6 Feb 2018 19:17:06 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CC0577AB5D; Tue, 6 Feb 2018 19:17:05 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C70CA1C18E; Tue, 6 Feb 2018 19:17:05 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w16JH5WA047823; Tue, 6 Feb 2018 19:17:05 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w16JH5XX047822; Tue, 6 Feb 2018 19:17:05 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201802061917.w16JH5XX047822@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Tue, 6 Feb 2018 19:17:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328947 - stable/11/sys/geom/journal X-SVN-Group: stable-11 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: stable/11/sys/geom/journal X-SVN-Commit-Revision: 328947 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 19:17:06 -0000 Author: mckusick Date: Tue Feb 6 19:17:05 2018 New Revision: 328947 URL: https://svnweb.freebsd.org/changeset/base/328947 Log: MFC of 328647. avoid segment fault in g_journal Modified: stable/11/sys/geom/journal/g_journal.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/journal/g_journal.c ============================================================================== --- stable/11/sys/geom/journal/g_journal.c Tue Feb 6 19:14:53 2018 (r328946) +++ stable/11/sys/geom/journal/g_journal.c Tue Feb 6 19:17:05 2018 (r328947) @@ -2430,6 +2430,7 @@ g_journal_destroy(struct g_journal_softc *sc) sc->sc_current_count); } + gp->softc = NULL; LIST_FOREACH(cp, &gp->consumer, consumer) { if (cp->acr + cp->acw + cp->ace > 0) g_access(cp, -1, -1, -1); @@ -2441,7 +2442,6 @@ g_journal_destroy(struct g_journal_softc *sc) */ g_post_event(g_journal_destroy_consumer, cp, M_WAITOK, NULL); } - gp->softc = NULL; g_wither_geom(gp, ENXIO); free(sc, M_JOURNAL); return (0); From owner-svn-src-stable-11@freebsd.org Tue Feb 6 21:42:50 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E5CDF09639; Tue, 6 Feb 2018 21:42:50 +0000 (UTC) (envelope-from mike@sentex.net) Received: from smarthost2.sentex.ca (smarthost2.sentex.ca [IPv6:2607:f3e0:80:80::2]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "smarthost.sentex.ca", Issuer "smarthost.sentex.ca" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 0C39783479; Tue, 6 Feb 2018 21:42:49 +0000 (UTC) (envelope-from mike@sentex.net) Received: from lava.sentex.ca (lava.sentex.ca [IPv6:2607:f3e0:0:5::11]) by smarthost2.sentex.ca (8.15.2/8.15.2) with ESMTPS id w16Lgm3l082814 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Tue, 6 Feb 2018 16:42:49 -0500 (EST) (envelope-from mike@sentex.net) Received: from [192.168.43.26] (saphire3.sentex.ca [192.168.43.26]) by lava.sentex.ca (8.15.2/8.15.2) with ESMTP id w16LgjlU060794; Tue, 6 Feb 2018 16:42:46 -0500 (EST) (envelope-from mike@sentex.net) Subject: Re: svn commit: r328944 - stable/11/sys/kern To: Kirk McKusick , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org References: <201802061913.w16JDiP8047547@repo.freebsd.org> From: Mike Tancsa Organization: Sentex Communications Message-ID: <3c1f7e72-364b-f08a-7b25-d2e7177b41c2@sentex.net> Date: Tue, 6 Feb 2018 16:42:46 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <201802061913.w16JDiP8047547@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 21:42:50 -0000 On 2/6/2018 2:13 PM, Kirk McKusick wrote: > Author: mckusick > Date: Tue Feb 6 19:13:44 2018 > New Revision: 328944 > URL: https://svnweb.freebsd.org/changeset/base/328944 > > Log: > MFC of 328643. > > fix vn_printf listing of its union Hi, I am getting a buildfailure with this commit, I think -------------------------------------------------------------- >>> stage 3.1: building everything -------------------------------------------------------------- cd /usr/obj/usr/src/sys/server; COMPILER_VERSION=50001 COMPILER_FEATURES=c++11 COMPILER_TYPE=clang COMPILER_FREEBSD_VERSION=1100505 MAKEOBJDIRPREFIX=/usr/obj MACHINE_ARCH=amd64 MACHINE=amd64 CPUTYPE= GROFF_BIN_PATH=/usr/obj/usr/src/tmp/legacy/usr/bin GROFF_FONT_PATH=/usr/obj/usr/src/tmp/legacy/usr/share/groff_font GROFF_TMAC_PATH=/usr/obj/usr/src/tmp/legacy/usr/share/tmac CC="cc -target x86_64-unknown-freebsd11.1 --sysroot=/usr/obj/usr/src/tmp -B/usr/obj/usr/src/tmp/usr/bin" CXX="c++ -target x86_64-unknown-freebsd11.1 --sysroot=/usr/obj/usr/src/tmp -B/usr/obj/usr/src/tmp/usr/bin" CPP="cpp -target x86_64-unknown-freebsd11.1 --sysroot=/usr/obj/usr/src/tmp -B/usr/obj/usr/src/tmp/usr/bin" AS="as" AR="ar" LD="ld" NM=nm OBJDUMP=objdump OBJCOPY="objcopy" RANLIB=ranlib STRINGS= SIZE="size" INSTALL="sh /usr/src/tools/install.sh" PATH=/usr/obj/usr/src/tmp/legacy/usr/sbin:/usr/obj/usr/src/tmp/legacy/usr/bin:/usr/obj/usr/src/tmp/legacy/bin:/usr/obj/usr/src/tmp/usr/sbin:/usr/obj/usr/src/tmp/usr/bin:/sbin:/bin:/usr/sbin:/usr/bin make -D NO_KERNELCLEAN -m /usr/src/share/mk KERNEL=kernel all -DNO_MODULES_OBJ cc -target x86_64-unknown-freebsd11.1 --sysroot=/usr/obj/usr/src/tmp -B/usr/obj/usr/src/tmp/usr/bin -c -O2 -pipe -fno-strict-aliasing -g -nostdinc -I. -I/usr/src/sys -I/usr/src/sys/contrib/libfdt -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -MD -MF.depend.vfs_subr.o -MTvfs_subr.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -gdwarf-2 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-error-address-of-packed-member -mno-aes -mno-avx -std=iso9899:1999 -Werror /usr/src/sys/kern/vfs_subr.c /usr/src/sys/kern/vfs_subr.c:3368:30: error: no member named 'v_unpcb' in 'struct vnode' printf(" socket %p\n", vp->v_unpcb); ~~ ^ 1 error generated. *** Error code 1 Stop. make[2]: stopped in /usr/obj/usr/src/sys/server *** Error code 1 Stop. make[1]: stopped in /usr/src *** Error code 1 Stop. > > Modified: > stable/11/sys/kern/vfs_subr.c > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/sys/kern/vfs_subr.c > ============================================================================== > --- stable/11/sys/kern/vfs_subr.c Tue Feb 6 19:09:49 2018 (r328943) > +++ stable/11/sys/kern/vfs_subr.c Tue Feb 6 19:13:44 2018 (r328944) > @@ -3355,8 +3355,25 @@ vn_printf(struct vnode *vp, const char *fmt, ...) > va_end(ap); > printf("%p: ", (void *)vp); > printf("tag %s, type %s\n", vp->v_tag, typename[vp->v_type]); > - printf(" usecount %d, writecount %d, refcount %d mountedhere %p\n", > - vp->v_usecount, vp->v_writecount, vp->v_holdcnt, vp->v_mountedhere); > + printf(" usecount %d, writecount %d, refcount %d", > + vp->v_usecount, vp->v_writecount, vp->v_holdcnt); > + switch (vp->v_type) { > + case VDIR: > + printf(" mountedhere %p\n", vp->v_mountedhere); > + break; > + case VCHR: > + printf(" rdev %p\n", vp->v_rdev); > + break; > + case VSOCK: > + printf(" socket %p\n", vp->v_unpcb); > + break; > + case VFIFO: > + printf(" fifoinfo %p\n", vp->v_fifoinfo); > + break; > + default: > + printf("\n"); > + break; > + } > buf[0] = '\0'; > buf[1] = '\0'; > if (vp->v_vflag & VV_ROOT) > _______________________________________________ > svn-src-stable-11@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-stable-11 > To unsubscribe, send any mail to "svn-src-stable-11-unsubscribe@freebsd.org" > > -- ------------------- Mike Tancsa, tel +1 519 651 3400 x203 Sentex Communications, mike@sentex.net Providing Internet services since 1994 www.sentex.net Cambridge, Ontario Canada From owner-svn-src-stable-11@freebsd.org Tue Feb 6 23:08:16 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 98EBCF107D8; Tue, 6 Feb 2018 23:08:16 +0000 (UTC) (envelope-from dexuan.bsd@gmail.com) Received: from mail-lf0-x22a.google.com (mail-lf0-x22a.google.com [IPv6:2a00:1450:4010:c07::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 95788681D8; Tue, 6 Feb 2018 23:08:15 +0000 (UTC) (envelope-from dexuan.bsd@gmail.com) Received: by mail-lf0-x22a.google.com with SMTP id g72so5130088lfg.5; Tue, 06 Feb 2018 15:08:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=J859qlJHPfz2sfp462GZTDZ3wEtHI05Vhj2AKvUDbMc=; b=e2GPINrJCt0OSnwGDPsDwFEpRRFJVzbrN6ao1vSHbvkjoCJ9jxvtU6bnpbpCeNpowT 8qqzGMxlcxvj3U5r2tu8K6DlXp7TpbJohnVDCSkIvI4iEIC60lpaBd4UOF4Qh6nf2GB9 wSaJuWW5EHrNL1RKLT4iIdQwAJwoJTzLflSRHKExAqfRSC2810IxZyArUbrBLZ6k7AMo WPE2oQ3i1BS9Ys1HuEm85WPv42AWcFPq0feyc5OmpZdUWsmZe+YibBD5dqc4mPjIo8F6 AJx/pii6HBwkTvDXse2Xp3Lh8T0XwwF2bwczIjm8wv3XUKx5IAD/AHBd/EJNgCk8y1mt RvdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=J859qlJHPfz2sfp462GZTDZ3wEtHI05Vhj2AKvUDbMc=; b=ZH1ebcSjwuqoWlCb03jzRKimrBRMMOhnxm+wdFabUN6qzRRAxJ3TEbe7Vbh81E36gg aYLSYhA2PDnBxp8qj9v8fdOK06bdaNj8snKx7GDAxl+ge752q6+bUdpyX4W5640fOmR4 zaIgF/SRPhfntZR6T8imRfI+jgmfYmMV9HruNhl8Ll2VoQd9XHNfizL/n8MNIEPmFusR K4tSDPmi5elGRQ5P5fe1vCL1on6d2NfvN4qrD5qu/7U27wz73M9nNbWINoTg8UXCL2ta nArHowmHqz2cqUyi4LApRSjBFirWX7w9BHRVbrnRL5SLtitnCoaaZ54oOd/y4MSMKVAo DQog== X-Gm-Message-State: APf1xPAtIQgXBTtO1F3d8fcfLpNKqrrikJF3fjJXj4ujidDdY4+X0GSH zzvLmawdJFOAMWK2rTyz9LjQgb4EsN91DXSFivXlNg== X-Google-Smtp-Source: AH8x224t23iKokUEtvwtkBQyF7E4mUy2vfLPYQntJOAJYMni0I/X7w5d1eQf37AKs/YiGw4t19+3ZED0KmYy9wNz90k= X-Received: by 10.25.143.12 with SMTP id r12mr2996459lfd.30.1517958493231; Tue, 06 Feb 2018 15:08:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.228.148 with HTTP; Tue, 6 Feb 2018 15:08:12 -0800 (PST) In-Reply-To: <3c1f7e72-364b-f08a-7b25-d2e7177b41c2@sentex.net> References: <201802061913.w16JDiP8047547@repo.freebsd.org> <3c1f7e72-364b-f08a-7b25-d2e7177b41c2@sentex.net> From: Dexuan-BSD Cui Date: Tue, 6 Feb 2018 15:08:12 -0800 Message-ID: Subject: Re: svn commit: r328944 - stable/11/sys/kern To: Mike Tancsa , decui@microsoft.com Cc: Kirk McKusick , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 23:08:16 -0000 I'm getting the error too: /root/freebsd/sys/kern/vfs_subr.c:3368:30: error: no member named 'v_unpcb' in 'struct vnode' printf(" socket %p\n", vp->v_unpcb); On Tue, Feb 6, 2018 at 1:42 PM, Mike Tancsa wrote: > On 2/6/2018 2:13 PM, Kirk McKusick wrote: >> Author: mckusick >> Date: Tue Feb 6 19:13:44 2018 >> New Revision: 328944 >> URL: https://svnweb.freebsd.org/changeset/base/328944 >> >> Log: >> MFC of 328643. >> >> fix vn_printf listing of its union > > Hi, > I am getting a buildfailure with this commit, I think > > -------------------------------------------------------------- >>>> stage 3.1: building everything > -------------------------------------------------------------- > cd /usr/obj/usr/src/sys/server; COMPILER_VERSION=50001 > COMPILER_FEATURES=c++11 COMPILER_TYPE=clang > COMPILER_FREEBSD_VERSION=1100505 MAKEOBJDIRPREFIX=/usr/obj > MACHINE_ARCH=amd64 MACHINE=amd64 CPUTYPE= > GROFF_BIN_PATH=/usr/obj/usr/src/tmp/legacy/usr/bin > GROFF_FONT_PATH=/usr/obj/usr/src/tmp/legacy/usr/share/groff_font > GROFF_TMAC_PATH=/usr/obj/usr/src/tmp/legacy/usr/share/tmac CC="cc > -target x86_64-unknown-freebsd11.1 --sysroot=/usr/obj/usr/src/tmp > -B/usr/obj/usr/src/tmp/usr/bin" CXX="c++ -target > x86_64-unknown-freebsd11.1 --sysroot=/usr/obj/usr/src/tmp > -B/usr/obj/usr/src/tmp/usr/bin" CPP="cpp -target > x86_64-unknown-freebsd11.1 --sysroot=/usr/obj/usr/src/tmp > -B/usr/obj/usr/src/tmp/usr/bin" AS="as" AR="ar" LD="ld" NM=nm > OBJDUMP=objdump OBJCOPY="objcopy" RANLIB=ranlib STRINGS= SIZE="size" > INSTALL="sh /usr/src/tools/install.sh" > PATH=/usr/obj/usr/src/tmp/legacy/usr/sbin:/usr/obj/usr/src/tmp/legacy/usr/bin:/usr/obj/usr/src/tmp/legacy/bin:/usr/obj/usr/src/tmp/usr/sbin:/usr/obj/usr/src/tmp/usr/bin:/sbin:/bin:/usr/sbin:/usr/bin > make -D NO_KERNELCLEAN -m /usr/src/share/mk KERNEL=kernel all > -DNO_MODULES_OBJ > cc -target x86_64-unknown-freebsd11.1 --sysroot=/usr/obj/usr/src/tmp > -B/usr/obj/usr/src/tmp/usr/bin -c -O2 -pipe -fno-strict-aliasing -g > -nostdinc -I. -I/usr/src/sys -I/usr/src/sys/contrib/libfdt -D_KERNEL > -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h > -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -MD > -MF.depend.vfs_subr.o -MTvfs_subr.o -mcmodel=kernel -mno-red-zone > -mno-mmx -mno-sse -msoft-float -fno-asynchronous-unwind-tables > -ffreestanding -fwrapv -fstack-protector -gdwarf-2 -Wall > -Wredundant-decls -Wnested-externs -Wstrict-prototypes > -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef > -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ > -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas > -Wno-error-tautological-compare -Wno-error-empty-body > -Wno-error-parentheses-equality -Wno-error-unused-function > -Wno-error-pointer-sign -Wno-error-shift-negative-value > -Wno-error-address-of-packed-member -mno-aes -mno-avx > -std=iso9899:1999 -Werror /usr/src/sys/kern/vfs_subr.c > /usr/src/sys/kern/vfs_subr.c:3368:30: error: no member named 'v_unpcb' > in 'struct vnode' > printf(" socket %p\n", vp->v_unpcb); > ~~ ^ > 1 error generated. > *** Error code 1 > > Stop. > make[2]: stopped in /usr/obj/usr/src/sys/server > *** Error code 1 > > Stop. > make[1]: stopped in /usr/src > *** Error code 1 > > Stop. > > >> >> Modified: >> stable/11/sys/kern/vfs_subr.c >> Directory Properties: >> stable/11/ (props changed) >> >> Modified: stable/11/sys/kern/vfs_subr.c >> ============================================================================== >> --- stable/11/sys/kern/vfs_subr.c Tue Feb 6 19:09:49 2018 (r328943) >> +++ stable/11/sys/kern/vfs_subr.c Tue Feb 6 19:13:44 2018 (r328944) >> @@ -3355,8 +3355,25 @@ vn_printf(struct vnode *vp, const char *fmt, ...) >> va_end(ap); >> printf("%p: ", (void *)vp); >> printf("tag %s, type %s\n", vp->v_tag, typename[vp->v_type]); >> - printf(" usecount %d, writecount %d, refcount %d mountedhere %p\n", >> - vp->v_usecount, vp->v_writecount, vp->v_holdcnt, vp->v_mountedhere); >> + printf(" usecount %d, writecount %d, refcount %d", >> + vp->v_usecount, vp->v_writecount, vp->v_holdcnt); >> + switch (vp->v_type) { >> + case VDIR: >> + printf(" mountedhere %p\n", vp->v_mountedhere); >> + break; >> + case VCHR: >> + printf(" rdev %p\n", vp->v_rdev); >> + break; >> + case VSOCK: >> + printf(" socket %p\n", vp->v_unpcb); >> + break; >> + case VFIFO: >> + printf(" fifoinfo %p\n", vp->v_fifoinfo); >> + break; >> + default: >> + printf("\n"); >> + break; >> + } >> buf[0] = '\0'; >> buf[1] = '\0'; >> if (vp->v_vflag & VV_ROOT) >> _______________________________________________ >> svn-src-stable-11@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/svn-src-stable-11 >> To unsubscribe, send any mail to "svn-src-stable-11-unsubscribe@freebsd.org" >> >> > > > -- > ------------------- > Mike Tancsa, tel +1 519 651 3400 x203 > Sentex Communications, mike@sentex.net > Providing Internet services since 1994 www.sentex.net > Cambridge, Ontario Canada > From owner-svn-src-stable-11@freebsd.org Tue Feb 6 23:11:21 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15149F10B01; Tue, 6 Feb 2018 23:11:21 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 920946845C; Tue, 6 Feb 2018 23:11:20 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id w16NBESR002545 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 6 Feb 2018 15:11:14 -0800 (PST) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id w16NBEHa002544; Tue, 6 Feb 2018 15:11:14 -0800 (PST) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Tue, 6 Feb 2018 15:11:14 -0800 From: Gleb Smirnoff To: Dexuan-BSD Cui Cc: Mike Tancsa , decui@microsoft.com, Kirk McKusick , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r328944 - stable/11/sys/kern Message-ID: <20180206231114.GF1063@FreeBSD.org> References: <201802061913.w16JDiP8047547@repo.freebsd.org> <3c1f7e72-364b-f08a-7b25-d2e7177b41c2@sentex.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.3 (2018-01-21) X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 23:11:21 -0000 On Tue, Feb 06, 2018 at 03:08:12PM -0800, Dexuan-BSD Cui wrote: D> I'm getting the error too: D> D> /root/freebsd/sys/kern/vfs_subr.c:3368:30: error: no member named D> 'v_unpcb' in 'struct vnode' D> printf(" socket %p\n", vp->v_unpcb); It should be v_socket on stable/11. If that change fixes the compile for you, feel free to commit. I don't have stable/11 system at hand. -- Gleb Smirnoff From owner-svn-src-stable-11@freebsd.org Tue Feb 6 23:50:03 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8C660F138C8; Tue, 6 Feb 2018 23:50:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3E96E6A5A0; Tue, 6 Feb 2018 23:50:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 398491EFC4; Tue, 6 Feb 2018 23:50:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w16No3PC085371; Tue, 6 Feb 2018 23:50:03 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w16No3Vk085370; Tue, 6 Feb 2018 23:50:03 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201802062350.w16No3Vk085370@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 6 Feb 2018 23:50:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328961 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 328961 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Feb 2018 23:50:03 -0000 Author: kib Date: Tue Feb 6 23:50:02 2018 New Revision: 328961 URL: https://svnweb.freebsd.org/changeset/base/328961 Log: Adjust MFC in r328944 to stable/11. This is a direct commit to the branch. Sponsored by: The FreeBSD Foundation Modified: stable/11/sys/kern/vfs_subr.c Modified: stable/11/sys/kern/vfs_subr.c ============================================================================== --- stable/11/sys/kern/vfs_subr.c Tue Feb 6 23:21:08 2018 (r328960) +++ stable/11/sys/kern/vfs_subr.c Tue Feb 6 23:50:02 2018 (r328961) @@ -3365,7 +3365,7 @@ vn_printf(struct vnode *vp, const char *fmt, ...) printf(" rdev %p\n", vp->v_rdev); break; case VSOCK: - printf(" socket %p\n", vp->v_unpcb); + printf(" socket %p\n", vp->v_socket); break; case VFIFO: printf(" fifoinfo %p\n", vp->v_fifoinfo); From owner-svn-src-stable-11@freebsd.org Wed Feb 7 00:00:51 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 63881F1471A; Wed, 7 Feb 2018 00:00:51 +0000 (UTC) (envelope-from decui@microsoft.com) Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sg2apc01on0104.outbound.protection.outlook.com [104.47.125.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "Microsoft IT TLS CA 4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 65A9F6B1F6; Wed, 7 Feb 2018 00:00:49 +0000 (UTC) (envelope-from decui@microsoft.com) Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM (10.170.167.17) by KL1P15301MB0022.APCP153.PROD.OUTLOOK.COM (10.170.167.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.506.7; Wed, 7 Feb 2018 00:00:43 +0000 Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) by KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) with mapi id 15.20.0506.007; Wed, 7 Feb 2018 00:00:42 +0000 From: Dexuan Cui To: Gleb Smirnoff , Dexuan-BSD Cui CC: Mike Tancsa , Kirk McKusick , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-stable@freebsd.org" , "svn-src-stable-11@freebsd.org" Subject: RE: svn commit: r328944 - stable/11/sys/kern Thread-Topic: svn commit: r328944 - stable/11/sys/kern Thread-Index: AQHTn5/T37VzMblK80arLfna/5sc4KOYBRYw Date: Wed, 7 Feb 2018 00:00:42 +0000 Message-ID: References: <201802061913.w16JDiP8047547@repo.freebsd.org> <3c1f7e72-364b-f08a-7b25-d2e7177b41c2@sentex.net> <20180206231114.GF1063@FreeBSD.org> In-Reply-To: <20180206231114.GF1063@FreeBSD.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=decui@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2018-02-07T00:00:37.7579728Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General x-originating-ip: [2001:4898:80e8:4::5eb] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; KL1P15301MB0022; 6:y8FglW/TlFz7Nw5gyw1hsHvYBtEf62gBeRjk2xPR/6DkzcF5SbqSKfJXMHnDCFa5e70vLJrRnKrYiUvKzMl50LNfETbe49TXgBwY8E5GV3mub8gSblQwQ8wtK8VEj7KR3hOStC5XfwihpDouEiMHAZgwaqeJrQQY7Q9+5XYqRdYs/Un11lJAdgkQbgfCo7aD0NzRZyh4NFu8wreJ9QZ2Z4n+fMZSRbBNxd0Cs31wZPxhdI9C6tJC43Fcj6BozZuclX58nYcgj8BMx1Tzak9T/2DgrUyBDH5jZA4MHTLlv+5bOelrSpetF529bJcpqD0A3qUCLjeiuLfkq5omcev4A6jPMXmzEf+ZzxbrQUUCf8cQrM3U6KtH7srMs7VZj0LK; 5:RiFCiQPhFPbwAz1x8qenh94CCHdk8xKWGge30u6Jc6N7+Xpnv9u0VA1QDAdBZmCgNa4qHkc7BYZJ2wSy8It9Yqe+ZDXF5hbuAYd78g2qiV9QrvPH6t8luWWf99ttPzEk1X/ksYsoqQhbUZ0NRQadYWIXI+1G+5tkNFJS2WPBhn8=; 24:aifmkTO90HYTuQEDzphU23Bjp2BwM/ydI3M811V1i5zegspo6TkMV3gPszx8rmdqWPM5izZtqOxvBhqKEocDRX3GLQjI+e5WquJZ31fuXfE=; 7:z+OOvjl1gr4FoLilIYIWye9InIJu78r//9clo9CVy/k7C7LkH1LP0i+n75oH8aTUlCbRQSD0xSK5y7TZmYRdwsf4PnycVMei+MJIiNnRgLP3+E+0PtfCeFI9OothnpgOh69agrjOT+UaxfA9j/Qejo07OKiCKHfMiE8c4mlfvA+mMRudbaAb7VtlN1NY0e3+eSDcZ7eMTJ3zQPSRyLDVpcbe/MR7fnMHvvLOE9QZLj6mYz9Eh/sg9Rvvzc8JMBSb x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: e636448b-a032-4db2-9c78-08d56dbdd4cd x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020); SRVR:KL1P15301MB0022; x-ms-traffictypediagnostic: KL1P15301MB0022: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(56005881305849)(166708455590820); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(61425038)(6040501)(2401047)(8121501046)(5005006)(3231101)(2400082)(944501161)(10201501046)(3002001)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(6072148)(201708071742011); SRVR:KL1P15301MB0022; BCL:0; PCL:0; RULEID:; SRVR:KL1P15301MB0022; x-forefront-prvs: 0576145E86 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(376002)(39380400002)(396003)(39860400002)(346002)(189003)(199004)(6506007)(74316002)(22452003)(105586002)(7736002)(68736007)(2900100001)(77096007)(5660300001)(305945005)(86362001)(99286004)(7696005)(229853002)(3280700002)(86612001)(186003)(25786009)(102836004)(14454004)(4326008)(478600001)(6246003)(3660700001)(8990500004)(55016002)(97736004)(110136005)(2950100002)(93886005)(6436002)(10090500001)(966005)(39060400002)(316002)(76176011)(54906003)(8936002)(53936002)(9686003)(81166006)(33656002)(6306002)(81156014)(2906002)(6116002)(106356001)(10290500003)(8676002); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1P15301MB0022; H:KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: UQ/C/SDIyLqaSjLSl6zQapASDtqnFIHck1KlVvZPySMsVBfTYjTogHP4Wmb2RysL7Ej6nVFsRydZ3RWFECsocQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: e636448b-a032-4db2-9c78-08d56dbdd4cd X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Feb 2018 00:00:42.4210 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0022 X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 00:00:51 -0000 > From: Gleb Smirnoff > Sent: Tuesday, February 6, 2018 15:11 >=20 > On Tue, Feb 06, 2018 at 03:08:12PM -0800, Dexuan-BSD Cui wrote: > D> I'm getting the error too: > D> > D> /root/freebsd/sys/kern/vfs_subr.c:3368:30: error: no member named > D> 'v_unpcb' in 'struct vnode' > D> printf(" socket %p\n", vp->v_unpcb); >=20 > It should be v_socket on stable/11. If that change fixes the compile > for you, feel free to commit. I don't have stable/11 system at hand. > -- > Gleb Smirnoff Yes, that change fixes the issue, and I can see the renaming happened in:=20 https://github.com/freebsd/freebsd/commit/8a7f8bb123cb2056ca239a472deaef029= 62bdd3e kib just fixed it by https://svnweb.freebsd.org/base?view=3Drevision&revision=3D328961 Thanks, -- Dexuan From owner-svn-src-stable-11@freebsd.org Wed Feb 7 06:24:35 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4483EE0D8D; Wed, 7 Feb 2018 06:24:34 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7CA7B78733; Wed, 7 Feb 2018 06:24:34 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 732C723236; Wed, 7 Feb 2018 06:24:34 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w176OY6w083669; Wed, 7 Feb 2018 06:24:34 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w176OYtU083668; Wed, 7 Feb 2018 06:24:34 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201802070624.w176OYtU083668@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Wed, 7 Feb 2018 06:24:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328965 - stable/11/lib/libc/gen X-SVN-Group: stable-11 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/11/lib/libc/gen X-SVN-Commit-Revision: 328965 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 06:24:35 -0000 Author: mmel Date: Wed Feb 7 06:24:34 2018 New Revision: 328965 URL: https://svnweb.freebsd.org/changeset/base/328965 Log: MFC r325364,r326794: r325364: Add alignment support to __libc_allocate_tls(). r326794: Rework alignment handling in __libc_allocate_tls() for Variant I of TLS layout. Modified: stable/11/lib/libc/gen/tls.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/gen/tls.c ============================================================================== --- stable/11/lib/libc/gen/tls.c Wed Feb 7 01:54:13 2018 (r328964) +++ stable/11/lib/libc/gen/tls.c Wed Feb 7 06:24:34 2018 (r328965) @@ -37,9 +37,15 @@ #include #include #include +#include #include "libc_private.h" +#define tls_assert(cond) ((cond) ? (void) 0 : \ + (tls_msg(#cond ": assert failed: " __FILE__ ":" \ + __XSTRING(__LINE__) "\n"), abort())) +#define tls_msg(s) write(STDOUT_FILENO, s, strlen(s)) + /* Provided by jemalloc to avoid bootstrapping issues. */ void *__je_bootstrap_malloc(size_t size); void *__je_bootstrap_calloc(size_t num, size_t size); @@ -81,10 +87,17 @@ void __libc_free_tls(void *tls, size_t tcbsize, size_t #define TLS_VARIANT_II #endif +#if defined(__mips__) || defined(__powerpc__) || defined(__riscv) +#define DTV_OFFSET 0x8000 +#else +#define DTV_OFFSET 0 +#endif + #ifndef PIC static size_t tls_static_space; static size_t tls_init_size; +static size_t tls_init_align; static void *tls_init; #endif @@ -109,60 +122,190 @@ __libc_tls_get_addr(void *ti __unused) #ifndef PIC +static void * +malloc_aligned(size_t size, size_t align) +{ + void *mem, *res; + + if (align < sizeof(void *)) + align = sizeof(void *); + + mem = __je_bootstrap_malloc(size + sizeof(void *) + align - 1); + res = (void *)roundup2((uintptr_t)mem + sizeof(void *), align); + *(void **)((uintptr_t)res - sizeof(void *)) = mem; + return (res); +} + +static void +free_aligned(void *ptr) +{ + void *mem; + uintptr_t x; + + if (ptr == NULL) + return; + + x = (uintptr_t)ptr; + x -= sizeof(void *); + mem = *(void **)x; + __je_bootstrap_free(mem); +} + #ifdef TLS_VARIANT_I +/* + * There are two versions of variant I of TLS + * + * - ARM and aarch64 uses original variant I as is described in [1] and [2], + * where TP points to start of TCB followed by aligned TLS segment. + * Both TCB and TLS must be aligned to alignment of TLS section. The TCB[0] + * points to DTV vector and DTV values are real addresses (without bias). + * Note: for Local Exec TLS Model, the offsets from TP (TCB in this case) to + * TLS variables are computed by linker, so we cannot overalign TLS section. + * + * - MIPS, PowerPC and RISC-V use modified version of variant I, + * described in [3] where TP points (with bias) to TLS and TCB immediately + * precedes TLS without any alignment gap[4]. Only TLS should be aligned. + * The TCB[0] points to DTV vector and DTV values are biased by constant + * value (0x8000) from real addresses[5]. + * + * [1] Ulrich Drepper: ELF Handling for Thread-Local Storage + * www.akkadia.org/drepper/tls.pdf + * + * [2] ARM IHI 0045E: Addenda to, and Errata in, the ABI for the ARM(r) + * Architecture + * infocenter.arm.com/help/topic/com.arm.doc.ihi0045e/IHI0045E_ABI_addenda.pdf + * + * [3] OpenPOWER: Power Architecture 64-Bit ELF V2 ABI Specification + * https://members.openpowerfoundation.org/document/dl/576 + * + * [4] Its unclear if "without any alignment gap" is hard ABI requirement, + * but we must follow this rule due to suboptimal _set_tp() + * (aka _SET_TP) implementation. This function doesn't expect TP but + * TCB as argument. + * + * [5] I'm not able to validate "values are biased" assertions. + */ + #define TLS_TCB_SIZE (2 * sizeof(void *)) /* - * Free Static TLS using the Variant I method. + * Return pointer to allocated TLS block */ +static void * +get_tls_block_ptr(void *tcb, size_t tcbsize) +{ + size_t extra_size, post_size, pre_size, tls_block_size; + + /* Compute fragments sizes. */ + extra_size = tcbsize - TLS_TCB_SIZE; +#if defined(__aarch64__) || defined(__arm__) + post_size = roundup2(TLS_TCB_SIZE, tls_init_align) - TLS_TCB_SIZE; +#else + post_size = 0; +#endif + tls_block_size = tcbsize + post_size; + pre_size = roundup2(tls_block_size, tls_init_align) - tls_block_size; + + return ((char *)tcb - pre_size - extra_size); +} + +/* + * Free Static TLS using the Variant I method. The tcbsize + * and tcbalign parameters must be the same as those used to allocate + * the block. + */ void __libc_free_tls(void *tcb, size_t tcbsize, size_t tcbalign __unused) { Elf_Addr *dtv; Elf_Addr **tls; - tls = (Elf_Addr **)((Elf_Addr)tcb + tcbsize - TLS_TCB_SIZE); + tls = (Elf_Addr **)tcb; dtv = tls[0]; __je_bootstrap_free(dtv); - __je_bootstrap_free(tcb); + free_aligned(get_tls_block_ptr(tcb, tcbsize)); } /* * Allocate Static TLS using the Variant I method. + * + * To handle all above requirements, we setup the following layout for + * TLS block: + * (whole memory block is aligned with MAX(TLS_TCB_ALIGN, tls_init_align)) + * + * +----------+--------------+--------------+-----------+------------------+ + * | pre gap | extended TCB | TCB | post gap | TLS segment | + * | pre_size | extra_size | TLS_TCB_SIZE | post_size | tls_static_space | + * +----------+--------------+--------------+-----------+------------------+ + * + * where: + * extra_size is tcbsize - TLS_TCB_SIZE + * post_size is used to adjust TCB to TLS aligment for first version of TLS + * layout and is always 0 for second version. + * pre_size is used to adjust TCB aligment for first version and to adjust + * TLS alignment for second version. + * */ void * -__libc_allocate_tls(void *oldtcb, size_t tcbsize, size_t tcbalign __unused) +__libc_allocate_tls(void *oldtcb, size_t tcbsize, size_t tcbalign) { - Elf_Addr *dtv; - Elf_Addr **tls; - char *tcb; + Elf_Addr *dtv, **tcb; + char *tls_block, *tls; + size_t extra_size, maxalign, post_size, pre_size, tls_block_size; if (oldtcb != NULL && tcbsize == TLS_TCB_SIZE) return (oldtcb); - tcb = __je_bootstrap_calloc(1, tls_static_space + tcbsize - TLS_TCB_SIZE); - tls = (Elf_Addr **)(tcb + tcbsize - TLS_TCB_SIZE); + tls_assert(tcbalign >= TLS_TCB_ALIGN); + maxalign = MAX(tcbalign, tls_init_align); + /* Compute fragmets sizes. */ + extra_size = tcbsize - TLS_TCB_SIZE; +#if defined(__aarch64__) || defined(__arm__) + post_size = roundup2(TLS_TCB_SIZE, tls_init_align) - TLS_TCB_SIZE; +#else + post_size = 0; +#endif + tls_block_size = tcbsize + post_size; + pre_size = roundup2(tls_block_size, tls_init_align) - tls_block_size; + tls_block_size += pre_size + tls_static_space; + + /* Allocate whole TLS block */ + tls_block = malloc_aligned(tls_block_size, maxalign); + if (tls_block == NULL) { + tls_msg("__libc_allocate_tls: Out of memory.\n"); + abort(); + } + memset(tls_block, 0, tls_block_size); + tcb = (Elf_Addr **)(tls_block + pre_size + extra_size); + tls = (char *)tcb + TLS_TCB_SIZE + post_size; + if (oldtcb != NULL) { - memcpy(tls, oldtcb, tls_static_space); - __je_bootstrap_free(oldtcb); + memcpy(tls_block, get_tls_block_ptr(oldtcb, tcbsize), + tls_block_size); + free_aligned(oldtcb); /* Adjust the DTV. */ - dtv = tls[0]; - dtv[2] = (Elf_Addr)tls + TLS_TCB_SIZE; + dtv = tcb[0]; + dtv[2] = (Elf_Addr)(tls + DTV_OFFSET); } else { dtv = __je_bootstrap_malloc(3 * sizeof(Elf_Addr)); - tls[0] = dtv; - dtv[0] = 1; - dtv[1] = 1; - dtv[2] = (Elf_Addr)tls + TLS_TCB_SIZE; + if (dtv == NULL) { + tls_msg("__libc_allocate_tls: Out of memory.\n"); + abort(); + } + /* Build the DTV. */ + tcb[0] = dtv; + dtv[0] = 1; /* Generation. */ + dtv[1] = 1; /* Segments count. */ + dtv[2] = (Elf_Addr)(tls + DTV_OFFSET); if (tls_init_size > 0) - memcpy((void*)dtv[2], tls_init, tls_init_size); + memcpy(tls, tls_init, tls_init_size); } - return(tcb); + return (tcb); } #endif @@ -185,12 +328,13 @@ __libc_free_tls(void *tcb, size_t tcbsize __unused, si * Figure out the size of the initial TLS block so that we can * find stuff which ___tls_get_addr() allocated dynamically. */ + tcbalign = MAX(tcbalign, tls_init_align); size = roundup2(tls_static_space, tcbalign); dtv = ((Elf_Addr**)tcb)[1]; tlsend = (Elf_Addr) tcb; tlsstart = tlsend - size; - __je_bootstrap_free((void*) tlsstart); + free_aligned((void*)tlsstart); __je_bootstrap_free(dtv); } @@ -205,12 +349,22 @@ __libc_allocate_tls(void *oldtls, size_t tcbsize, size Elf_Addr *dtv; Elf_Addr segbase, oldsegbase; + tcbalign = MAX(tcbalign, tls_init_align); size = roundup2(tls_static_space, tcbalign); if (tcbsize < 2 * sizeof(Elf_Addr)) tcbsize = 2 * sizeof(Elf_Addr); - tls = __je_bootstrap_calloc(1, size + tcbsize); + tls = malloc_aligned(size + tcbsize, tcbalign); + if (tls == NULL) { + tls_msg("__libc_allocate_tls: Out of memory.\n"); + abort(); + } + memset(tls, 0, size + tcbsize); dtv = __je_bootstrap_malloc(3 * sizeof(Elf_Addr)); + if (dtv == NULL) { + tls_msg("__libc_allocate_tls: Out of memory.\n"); + abort(); + } segbase = (Elf_Addr)(tls + size); ((Elf_Addr*)segbase)[0] = segbase; @@ -305,17 +459,11 @@ _init_tls(void) tls_static_space = roundup2(phdr[i].p_memsz, phdr[i].p_align); tls_init_size = phdr[i].p_filesz; + tls_init_align = phdr[i].p_align; tls_init = (void*) phdr[i].p_vaddr; + break; } } - -#ifdef TLS_VARIANT_I - /* - * tls_static_space should include space for TLS structure - */ - tls_static_space += TLS_TCB_SIZE; -#endif - tls = _rtld_allocate_tls(NULL, TLS_TCB_SIZE, TLS_TCB_ALIGN); _set_tp(tls); From owner-svn-src-stable-11@freebsd.org Wed Feb 7 06:27:30 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C224FEE1006; Wed, 7 Feb 2018 06:27:30 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6CFB978975; Wed, 7 Feb 2018 06:27:30 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6505E2323B; Wed, 7 Feb 2018 06:27:30 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w176RUpA083830; Wed, 7 Feb 2018 06:27:30 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w176RU9c083828; Wed, 7 Feb 2018 06:27:30 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201802070627.w176RU9c083828@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Wed, 7 Feb 2018 06:27:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328966 - stable/11/sys/arm/include X-SVN-Group: stable-11 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/11/sys/arm/include X-SVN-Commit-Revision: 328966 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 06:27:30 -0000 Author: mmel Date: Wed Feb 7 06:27:29 2018 New Revision: 328966 URL: https://svnweb.freebsd.org/changeset/base/328966 Log: MFC r325438: All CP15 registers are bit fields or counters, don't use signed type when accessing them. Modified: stable/11/sys/arm/include/cpu-v4.h stable/11/sys/arm/include/cpu-v6.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/include/cpu-v4.h ============================================================================== --- stable/11/sys/arm/include/cpu-v4.h Wed Feb 7 06:24:34 2018 (r328965) +++ stable/11/sys/arm/include/cpu-v4.h Wed Feb 7 06:27:29 2018 (r328966) @@ -51,10 +51,10 @@ #define _FX(s...) #s #define _RF0(fname, aname...) \ -static __inline register_t \ +static __inline uint32_t \ fname(void) \ { \ - register_t reg; \ + uint32_t reg; \ __asm __volatile("mrc\t" _FX(aname): "=r" (reg)); \ return(reg); \ } @@ -77,7 +77,7 @@ fname(void) \ #define _WF1(fname, aname...) \ static __inline void \ -fname(register_t reg) \ +fname(uint32_t reg) \ { \ __asm __volatile("mcr\t" _FX(aname):: "r" (reg)); \ } Modified: stable/11/sys/arm/include/cpu-v6.h ============================================================================== --- stable/11/sys/arm/include/cpu-v6.h Wed Feb 7 06:24:34 2018 (r328965) +++ stable/11/sys/arm/include/cpu-v6.h Wed Feb 7 06:27:29 2018 (r328966) @@ -65,10 +65,10 @@ extern int pmu_attched; #define _FX(s...) #s #define _RF0(fname, aname...) \ -static __inline register_t \ +static __inline uint32_t \ fname(void) \ { \ - register_t reg; \ + uint32_t reg; \ __asm __volatile("mrc\t" _FX(aname): "=r" (reg)); \ return(reg); \ } @@ -91,7 +91,7 @@ fname(void) \ #define _WF1(fname, aname...) \ static __inline void \ -fname(register_t reg) \ +fname(uint32_t reg) \ { \ __asm __volatile("mcr\t" _FX(aname):: "r" (reg)); \ } From owner-svn-src-stable-11@freebsd.org Wed Feb 7 06:29:08 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AF6BFEE1110; Wed, 7 Feb 2018 06:29:08 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 565EC78AC9; Wed, 7 Feb 2018 06:29:08 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4DA6B2323E; Wed, 7 Feb 2018 06:29:08 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w176T8H1083939; Wed, 7 Feb 2018 06:29:08 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w176T8ca083938; Wed, 7 Feb 2018 06:29:08 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201802070629.w176T8ca083938@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Wed, 7 Feb 2018 06:29:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328967 - stable/11/sys/arm/arm X-SVN-Group: stable-11 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/11/sys/arm/arm X-SVN-Commit-Revision: 328967 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 06:29:08 -0000 Author: mmel Date: Wed Feb 7 06:29:07 2018 New Revision: 328967 URL: https://svnweb.freebsd.org/changeset/base/328967 Log: MFC r324821: Fix spelling. Modified: stable/11/sys/arm/arm/cpuinfo.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/arm/cpuinfo.c ============================================================================== --- stable/11/sys/arm/arm/cpuinfo.c Wed Feb 7 06:27:29 2018 (r328966) +++ stable/11/sys/arm/arm/cpuinfo.c Wed Feb 7 06:29:07 2018 (r328967) @@ -157,8 +157,8 @@ cpuinfo_init(void) cpuinfo.icache_line_mask = cpuinfo.icache_line_size - 1; /* Fill AT_HWCAP bits. */ - elf_hwcap |= HWCAP_HALF | HWCAP_FAST_MULT; /* Requierd for all CPUs */ - elf_hwcap |= HWCAP_TLS | HWCAP_EDSP; /* Requierd for v6+ CPUs */ + elf_hwcap |= HWCAP_HALF | HWCAP_FAST_MULT; /* Required for all CPUs */ + elf_hwcap |= HWCAP_TLS | HWCAP_EDSP; /* Required for v6+ CPUs */ tmp = (cpuinfo.id_isar0 >> 24) & 0xF; /* Divide_instrs */ if (tmp >= 1) From owner-svn-src-stable-11@freebsd.org Wed Feb 7 09:28:24 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B37E8EECF1D; Wed, 7 Feb 2018 09:28:24 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 56F977EF98; Wed, 7 Feb 2018 09:28:24 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 43C0C24F16; Wed, 7 Feb 2018 09:28:24 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w179SOu1072938; Wed, 7 Feb 2018 09:28:24 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w179SOej072937; Wed, 7 Feb 2018 09:28:24 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201802070928.w179SOej072937@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Wed, 7 Feb 2018 09:28:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328968 - stable/11/sys/netpfil/ipfw X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sys/netpfil/ipfw X-SVN-Commit-Revision: 328968 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 09:28:24 -0000 Author: ae Date: Wed Feb 7 09:28:23 2018 New Revision: 328968 URL: https://svnweb.freebsd.org/changeset/base/328968 Log: MFC r328326: When IPv6 packet is handled by O_REJECT opcode, convert ICMP code specified in the arg1 into ICMPv6 destination unreachable code according to RFC7915. Obtained from: Yandex LLC Sponsored by: Yandex LLC Modified: stable/11/sys/netpfil/ipfw/ip_fw2.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw2.c Wed Feb 7 06:29:07 2018 (r328967) +++ stable/11/sys/netpfil/ipfw/ip_fw2.c Wed Feb 7 09:28:23 2018 (r328968) @@ -710,6 +710,32 @@ is_icmp6_query(int icmp6_type) return (0); } +static int +map_icmp_unreach(int code) +{ + + /* RFC 7915 p4.2 */ + switch (code) { + case ICMP_UNREACH_NET: + case ICMP_UNREACH_HOST: + case ICMP_UNREACH_SRCFAIL: + case ICMP_UNREACH_NET_UNKNOWN: + case ICMP_UNREACH_HOST_UNKNOWN: + case ICMP_UNREACH_TOSNET: + case ICMP_UNREACH_TOSHOST: + return (ICMP6_DST_UNREACH_NOROUTE); + case ICMP_UNREACH_PORT: + return (ICMP6_DST_UNREACH_NOPORT); + default: + /* + * Map the rest of codes into admit prohibited. + * XXX: unreach proto should be mapped into ICMPv6 + * parameter problem, but we use only unreach type. + */ + return (ICMP6_DST_UNREACH_ADMIN); + } +} + static void send_reject6(struct ip_fw_args *args, int code, u_int hlen, struct ip6_hdr *ip6) { @@ -2570,9 +2596,12 @@ do { \ (proto != IPPROTO_ICMPV6 || (is_icmp6_query(icmp6_type) == 1)) && !(m->m_flags & (M_BCAST|M_MCAST)) && - !IN6_IS_ADDR_MULTICAST(&args->f_id.dst_ip6)) { - send_reject6( - args, cmd->arg1, hlen, + !IN6_IS_ADDR_MULTICAST( + &args->f_id.dst_ip6)) { + send_reject6(args, + cmd->opcode == O_REJECT ? + map_icmp_unreach(cmd->arg1): + cmd->arg1, hlen, (struct ip6_hdr *)ip); m = args->m; } From owner-svn-src-stable-11@freebsd.org Wed Feb 7 15:06:55 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 169E7F0CC65; Wed, 7 Feb 2018 15:06:55 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B19ED6D5ED; Wed, 7 Feb 2018 15:06:54 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A3F4A6B8; Wed, 7 Feb 2018 15:06:54 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w17F6soJ043165; Wed, 7 Feb 2018 15:06:54 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w17F6s5l043163; Wed, 7 Feb 2018 15:06:54 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201802071506.w17F6s5l043163@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 7 Feb 2018 15:06:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328973 - in stable/11: include sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/11: include sys/sys X-SVN-Commit-Revision: 328973 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 15:06:55 -0000 Author: hselasky Date: Wed Feb 7 15:06:54 2018 New Revision: 328973 URL: https://svnweb.freebsd.org/changeset/base/328973 Log: MFC r328237: Use the __alloc_size2 attribute where relevant. This follows the documented use in GCC. It is basically only relevant for calloc(3), reallocarray(3) and mallocarray(9). NOTE: Without this change clang 5.0.1 can produce incorrect optimisation code for static processing of data using the allocated object. For example this has been seen compiling the mlx4 core module, which allocates a fixed size array which is then sorted by a fixed order loop. The optimised result, -O2, is incorrect unless this patch is in place. Suggested by: Mark Millard Reference: https://docs.freebsd.org/cgi/mid.cgi?9DE674C6-EAA3-4E8A-906F-446E74D82FC4 Modified: stable/11/include/stdlib.h stable/11/sys/sys/malloc.h Directory Properties: stable/11/ (props changed) Modified: stable/11/include/stdlib.h ============================================================================== --- stable/11/include/stdlib.h Wed Feb 7 14:50:06 2018 (r328972) +++ stable/11/include/stdlib.h Wed Feb 7 15:06:54 2018 (r328973) @@ -90,7 +90,7 @@ long atol(const char *); void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void * _Nonnull, const void *)); void *calloc(size_t, size_t) __malloc_like __result_use_check - __alloc_size(1) __alloc_size(2); + __alloc_size2(1, 2); div_t div(int, int) __pure2; _Noreturn void exit(int); void free(void *); @@ -307,8 +307,8 @@ void qsort_r(void *, size_t, size_t, void *, int (*)(void *, const void *, const void *)); int radixsort(const unsigned char **, int, const unsigned char *, unsigned); -void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size(2) - __alloc_size(3); +void *reallocarray(void *, size_t, size_t) __result_use_check + __alloc_size2(2, 3); void *reallocf(void *, size_t) __result_use_check __alloc_size(2); int rpmatch(const char *); void setprogname(const char *); Modified: stable/11/sys/sys/malloc.h ============================================================================== --- stable/11/sys/sys/malloc.h Wed Feb 7 14:50:06 2018 (r328972) +++ stable/11/sys/sys/malloc.h Wed Feb 7 15:06:54 2018 (r328973) @@ -178,7 +178,7 @@ void *malloc(unsigned long size, struct malloc_type *t __malloc_like __result_use_check __alloc_size(1); void *mallocarray(size_t nmemb, size_t size, struct malloc_type *type, int flags) __malloc_like __result_use_check - __alloc_size(1) __alloc_size(2); + __alloc_size2(1, 2); void malloc_init(void *); int malloc_last_fail(void); void malloc_type_allocated(struct malloc_type *type, unsigned long size); From owner-svn-src-stable-11@freebsd.org Wed Feb 7 15:32:33 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8A050F0EC41; Wed, 7 Feb 2018 15:32:33 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 34E766E9B4; Wed, 7 Feb 2018 15:32:33 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2F69BB98; Wed, 7 Feb 2018 15:32:33 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w17FWXFE057980; Wed, 7 Feb 2018 15:32:33 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w17FWW7L057965; Wed, 7 Feb 2018 15:32:32 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201802071532.w17FWW7L057965@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Wed, 7 Feb 2018 15:32:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328974 - in stable/11/usr.bin/mkimg: . tests X-SVN-Group: stable-11 X-SVN-Commit-Author: manu X-SVN-Commit-Paths: in stable/11/usr.bin/mkimg: . tests X-SVN-Commit-Revision: 328974 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 15:32:33 -0000 Author: manu Date: Wed Feb 7 15:32:31 2018 New Revision: 328974 URL: https://svnweb.freebsd.org/changeset/base/328974 Log: MFC r306325, r306329-r306330, r306333, r306620-r306622, r307387, r307544, r307550, r318137, r319125, r319295 r306325 by marcel: Replace the use of linker sets with constructors for both the formats and schemes. Formats and schemes are registered at runtime now, rather than collected at link time. r306329 by marcel: Eliminate the use of EDOOFUS. The error code was used to signal programming errors, but is really a poor substitute for assert. And less portable as well. r306330 by marcel: Avoid depending on the header for le*enc and be*enc. Not only is the header unportable, the encoding/decoding functions are as well. Instead, duplicate the handful of small inlines we need into a private header called endian.h. Aside: an alternative approach is to move the encoding/decoding functions to a separate system header. While the header is still nonportable, such an approach would make it possible to re-use the definitions by playing games with include paths. This may be the preferred approach if more (build) utilities need this. This change does not preclude that. In fact, it makes it easier. r306333 by marcel: Portability changes: 1. macOS nor Linux have MAP_NOCORE nor MAP_NOSYNC. Define as 0. 2. macOS doesn't have SEEK_DATA nor SEEK_HOLE. Define as -1 so that lseek will return -1 (with errno set to EINVAL). 3. gcc correctly warns that error is assigned but not used in image_copyout_region(). Fix by returning on the first error. r306620 by marcel: Replace STAILQ with TAILQ. TAILQs are portable enough that they can be used on both macOS and Linux. STAILQs are not. In particular, STAILQ_LAST does not next on Linux. Since neither STAILQ_FOREACH_SAFE nor TAILQ_FOREACH_SAFE exist on Linux, replace its use with a regular TAILQ_FOREACH. The _SAFE variant was only used for having the next pointer in a local variable. r306621 by marcel: Prefer over . While here remove redundant inclusion of . Move the inclusion of the disk partitioning headers out of order and inbetween standard headers and local header. They will change in a subsequent commit. r306622 by marcel: Replace OFF_MAX with INT64_MAX. The former is defined on Linux. r307387 by marcel: Switch to using the portable partition scheme headers. r307544 by marcel: o Provide a private definition for UUIDs (mkimg_uuid_t) because UUIDs are not portable. o Move mkimg_uuid() to a new file and merge both gpt_uuid_enc() and vhd_uuid_enc() into a single mkimg_uuid_enc() that lives in the same file. o Move the OS-specific implementation of generating a UUID to osdep_uuidgen() and provide the implementations for FreeBSD, macOS and Linux. o Expect the partitioning scheme headers to be found by having a search to the directory in which the headers live. This avoids conflicts on non-FreeBSD machines. r307550 by imp: Add a new flag to mkimg (-a num) to specify the active partition for those partitioning schemes that have this concept. Implement it as an override for mbr's setting 0x80 in the flags for the first partition when we have boot code. Differential Revision: https://reviews.freebsd.org/D4403 r318137: mkimg: Add -C argument to specify maximum capacity Add a -C option to specify a maximum capacity for the final image file. It is useful to control the size of the generated image for sdcard or when we will add dynamic size partition. Add --capacity which is a shorthand to define min and max capacity at the same time. Reviewed by: bapt, marcel, wblock (manpages) Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D10509 r319125: mkimg: Correct an off by one error in the PMBR size The PMBR last sector should be number of sector - 1 (As stated in UEFI Spec 2.6 page 118 table 17). This fixes warning printed by linux tools like parted or fdisk. Sponsored by: Gandi.net r319295 by ngie: Update the usr.bin/mkimg golden test output files after ^/head@r319125 ^/head@r319125 changed the location of the backup pmbr, requiring the output files to be regenerated, since they're binary disk dumps. The output files were regenerated with "make rebase"--fixed in ^/head@r319294. MFC with: r319125, r319294 PR: 219673 Sponsored by: Dell EMC Isilon Added: stable/11/usr.bin/mkimg/endian.h - copied unchanged from r306330, head/usr.bin/mkimg/endian.h stable/11/usr.bin/mkimg/uuid.c - copied unchanged from r307544, head/usr.bin/mkimg/uuid.c Modified: stable/11/usr.bin/mkimg/Makefile stable/11/usr.bin/mkimg/apm.c stable/11/usr.bin/mkimg/bsd.c stable/11/usr.bin/mkimg/ebr.c stable/11/usr.bin/mkimg/format.c stable/11/usr.bin/mkimg/format.h stable/11/usr.bin/mkimg/gpt.c stable/11/usr.bin/mkimg/image.c stable/11/usr.bin/mkimg/mbr.c stable/11/usr.bin/mkimg/mkimg.1 stable/11/usr.bin/mkimg/mkimg.c stable/11/usr.bin/mkimg/mkimg.h stable/11/usr.bin/mkimg/pc98.c stable/11/usr.bin/mkimg/qcow.c stable/11/usr.bin/mkimg/raw.c stable/11/usr.bin/mkimg/scheme.c stable/11/usr.bin/mkimg/scheme.h stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow2.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.raw.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhd.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhdf.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.vmdk.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.qcow.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.qcow2.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.raw.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.vhd.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.vhdf.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.vmdk.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.qcow.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.qcow2.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.raw.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.vhd.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.vhdf.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.vmdk.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.qcow.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.qcow2.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.raw.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.vhd.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.vhdf.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.vmdk.gz.uu stable/11/usr.bin/mkimg/vhd.c stable/11/usr.bin/mkimg/vmdk.c stable/11/usr.bin/mkimg/vtoc8.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/mkimg/Makefile ============================================================================== --- stable/11/usr.bin/mkimg/Makefile Wed Feb 7 15:06:54 2018 (r328973) +++ stable/11/usr.bin/mkimg/Makefile Wed Feb 7 15:32:31 2018 (r328974) @@ -3,14 +3,15 @@ .include PROG= mkimg -SRCS= format.c image.c mkimg.c scheme.c +SRCS= format.c image.c mkimg.c scheme.c uuid.c MAN= mkimg.1 -MKIMG_VERSION=20151211 +MKIMG_VERSION=20161016 mkimg.o: Makefile CFLAGS+=-DMKIMG_VERSION=${MKIMG_VERSION} CFLAGS+=-DSPARSE_WRITE +CFLAGS+=-I${SRCTOP}/sys/sys/disk # List of formats to support SRCS+= \ Modified: stable/11/usr.bin/mkimg/apm.c ============================================================================== --- stable/11/usr.bin/mkimg/apm.c Wed Feb 7 15:06:54 2018 (r328973) +++ stable/11/usr.bin/mkimg/apm.c Wed Feb 7 15:32:31 2018 (r328974) @@ -27,25 +27,19 @@ #include __FBSDID("$FreeBSD$"); -#include -#include -#include #include +#include #include #include #include +#include + +#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" -#ifndef APM_ENT_TYPE_APPLE_BOOT -#define APM_ENT_TYPE_APPLE_BOOT "Apple_Bootstrap" -#endif -#ifndef APM_ENT_TYPE_FREEBSD_NANDFS -#define APM_ENT_TYPE_FREEBSD_NANDFS "FreeBSD-nandfs" -#endif - static struct mkimg_alias apm_aliases[] = { { ALIAS_FREEBSD, ALIAS_PTR2TYPE(APM_ENT_TYPE_FREEBSD) }, { ALIAS_FREEBSD_BOOT, ALIAS_PTR2TYPE(APM_ENT_TYPE_APPLE_BOOT) }, @@ -91,7 +85,7 @@ apm_write(lba_t imgsz, void *bootcode __unused) strncpy(ent->ent_type, APM_ENT_TYPE_SELF, sizeof(ent->ent_type)); strncpy(ent->ent_name, "Apple", sizeof(ent->ent_name)); - STAILQ_FOREACH(part, &partlist, link) { + TAILQ_FOREACH(part, &partlist, link) { ent = (void *)(buf + (part->index + 2) * secsz); be16enc(&ent->ent_sig, APM_ENT_SIG); be32enc(&ent->ent_pmblkcnt, nparts + 1); Modified: stable/11/usr.bin/mkimg/bsd.c ============================================================================== --- stable/11/usr.bin/mkimg/bsd.c Wed Feb 7 15:06:54 2018 (r328973) +++ stable/11/usr.bin/mkimg/bsd.c Wed Feb 7 15:32:31 2018 (r328974) @@ -27,22 +27,19 @@ #include __FBSDID("$FreeBSD$"); -#include -#include -#include #include +#include #include #include #include +#include + +#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" -#ifndef FS_NANDFS -#define FS_NANDFS 30 -#endif - static struct mkimg_alias bsd_aliases[] = { { ALIAS_FREEBSD_NANDFS, ALIAS_INT2TYPE(FS_NANDFS) }, { ALIAS_FREEBSD_SWAP, ALIAS_INT2TYPE(FS_SWAP) }, @@ -57,7 +54,7 @@ bsd_metadata(u_int where, lba_t blk) { if (where == SCHEME_META_IMG_START) - blk += BBSIZE / secsz; + blk += BSD_BOOTBLOCK_SIZE / secsz; else if (where == SCHEME_META_IMG_END) blk = round_cylinder(blk); else @@ -75,21 +72,21 @@ bsd_write(lba_t imgsz, void *bootcode) int bsdparts, error, n; uint16_t checksum; - buf = malloc(BBSIZE); + buf = malloc(BSD_BOOTBLOCK_SIZE); if (buf == NULL) return (ENOMEM); if (bootcode != NULL) { - memcpy(buf, bootcode, BBSIZE); + memcpy(buf, bootcode, BSD_BOOTBLOCK_SIZE); memset(buf + secsz, 0, sizeof(struct disklabel)); } else - memset(buf, 0, BBSIZE); + memset(buf, 0, BSD_BOOTBLOCK_SIZE); bsdparts = nparts + 1; /* Account for c partition */ - if (bsdparts < MAXPARTITIONS) - bsdparts = MAXPARTITIONS; + if (bsdparts < BSD_NPARTS_MIN) + bsdparts = BSD_NPARTS_MIN; d = (void *)(buf + secsz); - le32enc(&d->d_magic, DISKMAGIC); + le32enc(&d->d_magic, BSD_MAGIC); le32enc(&d->d_secsize, secsz); le32enc(&d->d_nsectors, nsecs); le32enc(&d->d_ntracks, nheads); @@ -97,14 +94,14 @@ bsd_write(lba_t imgsz, void *bootcode) le32enc(&d->d_secpercyl, nsecs * nheads); le32enc(&d->d_secperunit, imgsz); le16enc(&d->d_rpm, 3600); - le32enc(&d->d_magic2, DISKMAGIC); + le32enc(&d->d_magic2, BSD_MAGIC); le16enc(&d->d_npartitions, bsdparts); - le32enc(&d->d_bbsize, BBSIZE); + le32enc(&d->d_bbsize, BSD_BOOTBLOCK_SIZE); - dp = &d->d_partitions[RAW_PART]; + dp = &d->d_partitions[BSD_PART_RAW]; le32enc(&dp->p_size, imgsz); - STAILQ_FOREACH(part, &partlist, link) { - n = part->index + ((part->index >= RAW_PART) ? 1 : 0); + TAILQ_FOREACH(part, &partlist, link) { + n = part->index + ((part->index >= BSD_PART_RAW) ? 1 : 0); dp = &d->d_partitions[n]; le32enc(&dp->p_size, part->size); le32enc(&dp->p_offset, part->block); @@ -120,7 +117,7 @@ bsd_write(lba_t imgsz, void *bootcode) checksum ^= le16dec(p); le16enc(&d->d_checksum, checksum); - error = image_write(0, buf, BBSIZE / secsz); + error = image_write(0, buf, BSD_BOOTBLOCK_SIZE / secsz); free(buf); return (error); } @@ -131,8 +128,8 @@ static struct mkimg_scheme bsd_scheme = { .aliases = bsd_aliases, .metadata = bsd_metadata, .write = bsd_write, - .nparts = 19, - .bootcode = BBSIZE, + .nparts = BSD_NPARTS_MAX - 1, + .bootcode = BSD_BOOTBLOCK_SIZE, .maxsecsz = 512 }; Modified: stable/11/usr.bin/mkimg/ebr.c ============================================================================== --- stable/11/usr.bin/mkimg/ebr.c Wed Feb 7 15:06:54 2018 (r328973) +++ stable/11/usr.bin/mkimg/ebr.c Wed Feb 7 15:32:31 2018 (r328974) @@ -27,27 +27,21 @@ #include __FBSDID("$FreeBSD$"); -#include -#include -#include #include +#include #include #include #include +#include + +#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" -#ifndef DOSPTYP_FAT16B -#define DOSPTYP_FAT16B 0x06 -#endif -#ifndef DOSPTYP_FAT32 -#define DOSPTYP_FAT32 0x0b -#endif - static struct mkimg_alias ebr_aliases[] = { - { ALIAS_FAT16B, ALIAS_INT2TYPE(DOSPTYP_FAT16B) }, + { ALIAS_FAT16B, ALIAS_INT2TYPE(DOSPTYP_FAT16) }, { ALIAS_FAT32, ALIAS_INT2TYPE(DOSPTYP_FAT32) }, { ALIAS_FREEBSD, ALIAS_INT2TYPE(DOSPTYP_386BSD) }, { ALIAS_NONE, 0 } @@ -88,7 +82,7 @@ ebr_write(lba_t imgsz __unused, void *bootcode __unuse le16enc(ebr + DOSMAGICOFFSET, DOSMAGIC); error = 0; - STAILQ_FOREACH_SAFE(part, &partlist, link, next) { + TAILQ_FOREACH(part, &partlist, link) { block = part->block - nsecs; size = round_track(part->size); dp = (void *)(ebr + DOSPARTOFF); @@ -100,6 +94,7 @@ ebr_write(lba_t imgsz __unused, void *bootcode __unuse le32enc(&dp->dp_size, size); /* Add link entry */ + next = TAILQ_NEXT(part, link); if (next != NULL) { size = round_track(next->size); dp++; Copied: stable/11/usr.bin/mkimg/endian.h (from r306330, head/usr.bin/mkimg/endian.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/usr.bin/mkimg/endian.h Wed Feb 7 15:32:31 2018 (r328974, copy of r306330, head/usr.bin/mkimg/endian.h) @@ -0,0 +1,106 @@ +/*- + * Copyright (c) 2002 Thomas Moestl + * 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 _MKIMG_ENDIAN_H_ +#define _MKIMG_ENDIAN_H_ + +static __inline uint16_t +be16dec(const void *pp) +{ + uint8_t const *p = (uint8_t const *)pp; + + return ((p[0] << 8) | p[1]); +} + +static __inline void +be16enc(void *pp, uint16_t u) +{ + uint8_t *p = (uint8_t *)pp; + + p[0] = (u >> 8) & 0xff; + p[1] = u & 0xff; +} + +static __inline void +be32enc(void *pp, uint32_t u) +{ + uint8_t *p = (uint8_t *)pp; + + p[0] = (u >> 24) & 0xff; + p[1] = (u >> 16) & 0xff; + p[2] = (u >> 8) & 0xff; + p[3] = u & 0xff; +} + +static __inline void +be64enc(void *pp, uint64_t u) +{ + uint8_t *p = (uint8_t *)pp; + + be32enc(p, (uint32_t)(u >> 32)); + be32enc(p + 4, (uint32_t)(u & 0xffffffffU)); +} + +static __inline uint16_t +le16dec(const void *pp) +{ + uint8_t const *p = (uint8_t const *)pp; + + return ((p[1] << 8) | p[0]); +} + +static __inline void +le16enc(void *pp, uint16_t u) +{ + uint8_t *p = (uint8_t *)pp; + + p[0] = u & 0xff; + p[1] = (u >> 8) & 0xff; +} + +static __inline void +le32enc(void *pp, uint32_t u) +{ + uint8_t *p = (uint8_t *)pp; + + p[0] = u & 0xff; + p[1] = (u >> 8) & 0xff; + p[2] = (u >> 16) & 0xff; + p[3] = (u >> 24) & 0xff; +} + +static __inline void +le64enc(void *pp, uint64_t u) +{ + uint8_t *p = (uint8_t *)pp; + + le32enc(p, (uint32_t)(u & 0xffffffffU)); + le32enc(p + 4, (uint32_t)(u >> 32)); +} + +#endif /* _MKIMG_ENDIAN_H_ */ Modified: stable/11/usr.bin/mkimg/format.c ============================================================================== --- stable/11/usr.bin/mkimg/format.c Wed Feb 7 15:06:54 2018 (r328973) +++ stable/11/usr.bin/mkimg/format.c Wed Feb 7 15:32:31 2018 (r328974) @@ -27,9 +27,6 @@ #include __FBSDID("$FreeBSD$"); -#include -#include -#include #include #include #include @@ -42,8 +39,24 @@ __FBSDID("$FreeBSD$"); #include "format.h" #include "mkimg.h" +static struct mkimg_format *first; static struct mkimg_format *format; +struct mkimg_format * +format_iterate(struct mkimg_format *f) +{ + + return ((f == NULL) ? first : f->next); +} + +void +format_register(struct mkimg_format *f) +{ + + f->next = first; + first = f; +} + int format_resize(lba_t end) { @@ -56,10 +69,10 @@ format_resize(lba_t end) int format_select(const char *spec) { - struct mkimg_format *f, **iter; + struct mkimg_format *f; - SET_FOREACH(iter, formats) { - f = *iter; + f = NULL; + while ((f = format_iterate(f)) != NULL) { if (strcasecmp(spec, f->name) == 0) { format = f; return (0); Modified: stable/11/usr.bin/mkimg/format.h ============================================================================== --- stable/11/usr.bin/mkimg/format.h Wed Feb 7 15:06:54 2018 (r328973) +++ stable/11/usr.bin/mkimg/format.h Wed Feb 7 15:32:31 2018 (r328974) @@ -29,21 +29,24 @@ #ifndef _MKIMG_FORMAT_H_ #define _MKIMG_FORMAT_H_ -#include - struct mkimg_format { + struct mkimg_format *next; const char *name; const char *description; int (*resize)(lba_t); int (*write)(int); }; -SET_DECLARE(formats, struct mkimg_format); -#define FORMAT_DEFINE(nm) DATA_SET(formats, nm) +#define FORMAT_DEFINE(nm) \ +static void format_register_##nm(void) __attribute__((constructor)); \ +static void format_register_##nm(void) { format_register(&nm); } -int format_resize(lba_t); +struct mkimg_format *format_iterate(struct mkimg_format *); +void format_register(struct mkimg_format *); int format_select(const char *); struct mkimg_format *format_selected(void); + +int format_resize(lba_t); int format_write(int); #endif /* _MKIMG_FORMAT_H_ */ Modified: stable/11/usr.bin/mkimg/gpt.c ============================================================================== --- stable/11/usr.bin/mkimg/gpt.c Wed Feb 7 15:06:54 2018 (r328973) +++ stable/11/usr.bin/mkimg/gpt.c Wed Feb 7 15:32:31 2018 (r328974) @@ -27,38 +27,32 @@ #include __FBSDID("$FreeBSD$"); -#include -#include -#include #include -#include #include #include #include #include #include -#include +#include +#include + +#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" -#ifndef GPT_ENT_TYPE_FREEBSD_NANDFS -#define GPT_ENT_TYPE_FREEBSD_NANDFS \ - {0x74ba7dd9,0xa689,0x11e1,0xbd,0x04,{0x00,0xe0,0x81,0x28,0x6a,0xcf}} -#endif +static mkimg_uuid_t gpt_uuid_efi = GPT_ENT_TYPE_EFI; +static mkimg_uuid_t gpt_uuid_freebsd = GPT_ENT_TYPE_FREEBSD; +static mkimg_uuid_t gpt_uuid_freebsd_boot = GPT_ENT_TYPE_FREEBSD_BOOT; +static mkimg_uuid_t gpt_uuid_freebsd_nandfs = GPT_ENT_TYPE_FREEBSD_NANDFS; +static mkimg_uuid_t gpt_uuid_freebsd_swap = GPT_ENT_TYPE_FREEBSD_SWAP; +static mkimg_uuid_t gpt_uuid_freebsd_ufs = GPT_ENT_TYPE_FREEBSD_UFS; +static mkimg_uuid_t gpt_uuid_freebsd_vinum = GPT_ENT_TYPE_FREEBSD_VINUM; +static mkimg_uuid_t gpt_uuid_freebsd_zfs = GPT_ENT_TYPE_FREEBSD_ZFS; +static mkimg_uuid_t gpt_uuid_mbr = GPT_ENT_TYPE_MBR; +static mkimg_uuid_t gpt_uuid_ms_basic_data = GPT_ENT_TYPE_MS_BASIC_DATA; -static uuid_t gpt_uuid_efi = GPT_ENT_TYPE_EFI; -static uuid_t gpt_uuid_freebsd = GPT_ENT_TYPE_FREEBSD; -static uuid_t gpt_uuid_freebsd_boot = GPT_ENT_TYPE_FREEBSD_BOOT; -static uuid_t gpt_uuid_freebsd_nandfs = GPT_ENT_TYPE_FREEBSD_NANDFS; -static uuid_t gpt_uuid_freebsd_swap = GPT_ENT_TYPE_FREEBSD_SWAP; -static uuid_t gpt_uuid_freebsd_ufs = GPT_ENT_TYPE_FREEBSD_UFS; -static uuid_t gpt_uuid_freebsd_vinum = GPT_ENT_TYPE_FREEBSD_VINUM; -static uuid_t gpt_uuid_freebsd_zfs = GPT_ENT_TYPE_FREEBSD_ZFS; -static uuid_t gpt_uuid_mbr = GPT_ENT_TYPE_MBR; -static uuid_t gpt_uuid_ms_basic_data = GPT_ENT_TYPE_MS_BASIC_DATA; - static struct mkimg_alias gpt_aliases[] = { { ALIAS_EFI, ALIAS_PTR2TYPE(&gpt_uuid_efi) }, { ALIAS_FREEBSD, ALIAS_PTR2TYPE(&gpt_uuid_freebsd) }, @@ -131,21 +125,6 @@ crc32(const void *buf, size_t sz) return (crc ^ ~0U); } -static void -gpt_uuid_enc(void *buf, const uuid_t *uuid) -{ - uint8_t *p = buf; - int i; - - le32enc(p, uuid->time_low); - le16enc(p + 4, uuid->time_mid); - le16enc(p + 6, uuid->time_hi_and_version); - p[8] = uuid->clock_seq_hi_and_reserved; - p[9] = uuid->clock_seq_low; - for (i = 0; i < _UUID_NODE_LEN; i++) - p[10 + i] = uuid->node[i]; -} - static u_int gpt_tblsz(void) { @@ -173,7 +152,7 @@ gpt_write_pmbr(lba_t blks, void *bootcode) uint32_t secs; int error; - secs = (blks > UINT32_MAX) ? UINT32_MAX : (uint32_t)blks; + secs = (blks > UINT32_MAX) ? UINT32_MAX : (uint32_t)blks - 1; pmbr = malloc(secsz); if (pmbr == NULL) @@ -199,7 +178,7 @@ gpt_write_pmbr(lba_t blks, void *bootcode) static struct gpt_ent * gpt_mktbl(u_int tblsz) { - uuid_t uuid; + mkimg_uuid_t uuid; struct gpt_ent *tbl, *ent; struct part *part; int c, idx; @@ -208,11 +187,11 @@ gpt_mktbl(u_int tblsz) if (tbl == NULL) return (NULL); - STAILQ_FOREACH(part, &partlist, link) { + TAILQ_FOREACH(part, &partlist, link) { ent = tbl + part->index; - gpt_uuid_enc(&ent->ent_type, ALIAS_TYPE2PTR(part->type)); + mkimg_uuid_enc(&ent->ent_type, ALIAS_TYPE2PTR(part->type)); mkimg_uuid(&uuid); - gpt_uuid_enc(&ent->ent_uuid, &uuid); + mkimg_uuid_enc(&ent->ent_uuid, &uuid); le64enc(&ent->ent_lba_start, part->block); le64enc(&ent->ent_lba_end, part->block + part->size - 1); if (part->label != NULL) { @@ -243,7 +222,7 @@ gpt_write_hdr(struct gpt_hdr *hdr, uint64_t self, uint static int gpt_write(lba_t imgsz, void *bootcode) { - uuid_t uuid; + mkimg_uuid_t uuid; struct gpt_ent *tbl; struct gpt_hdr *hdr; uint32_t crc; @@ -280,7 +259,7 @@ gpt_write(lba_t imgsz, void *bootcode) le64enc(&hdr->hdr_lba_start, 2 + tblsz); le64enc(&hdr->hdr_lba_end, imgsz - tblsz - 2); mkimg_uuid(&uuid); - gpt_uuid_enc(&hdr->hdr_uuid, &uuid); + mkimg_uuid_enc(&hdr->hdr_uuid, &uuid); le32enc(&hdr->hdr_entries, nparts); le32enc(&hdr->hdr_entsz, sizeof(struct gpt_ent)); crc = crc32(tbl, nparts * sizeof(struct gpt_ent)); Modified: stable/11/usr.bin/mkimg/image.c ============================================================================== --- stable/11/usr.bin/mkimg/image.c Wed Feb 7 15:06:54 2018 (r328973) +++ stable/11/usr.bin/mkimg/image.c Wed Feb 7 15:32:31 2018 (r328974) @@ -28,9 +28,7 @@ __FBSDID("$FreeBSD$"); #include -#include #include -#include #include #include #include @@ -45,8 +43,22 @@ __FBSDID("$FreeBSD$"); #include "image.h" #include "mkimg.h" +#ifndef MAP_NOCORE +#define MAP_NOCORE 0 +#endif +#ifndef MAP_NOSYNC +#define MAP_NOSYNC 0 +#endif + +#ifndef SEEK_DATA +#define SEEK_DATA -1 +#endif +#ifndef SEEK_HOLE +#define SEEK_HOLE -1 +#endif + struct chunk { - STAILQ_ENTRY(chunk) ch_list; + TAILQ_ENTRY(chunk) ch_list; size_t ch_size; /* Size of chunk in bytes. */ lba_t ch_block; /* Block address in image. */ union { @@ -64,7 +76,7 @@ struct chunk { #define CH_TYPE_MEMORY 2 /* Memory-backed chunk */ }; -static STAILQ_HEAD(chunk_head, chunk) image_chunks; +static TAILQ_HEAD(chunk_head, chunk) image_chunks; static u_int image_nchunks; static char image_swap_file[PATH_MAX]; @@ -125,14 +137,14 @@ image_chunk_find(lba_t blk) struct chunk *ch; ch = (last != NULL && last->ch_block <= blk) - ? last : STAILQ_FIRST(&image_chunks); + ? last : TAILQ_FIRST(&image_chunks); while (ch != NULL) { if (ch->ch_block <= blk && (lba_t)(ch->ch_block + (ch->ch_size / secsz)) > blk) { last = ch; break; } - ch = STAILQ_NEXT(ch, ch_list); + ch = TAILQ_NEXT(ch, ch_list); } return (ch); } @@ -174,7 +186,7 @@ image_chunk_memory(struct chunk *ch, lba_t blk) ch->ch_size = (blk - ch->ch_block) * secsz; new->ch_block = blk; new->ch_size -= ch->ch_size; - STAILQ_INSERT_AFTER(&image_chunks, ch, new, ch_list); + TAILQ_INSERT_AFTER(&image_chunks, ch, new, ch_list); image_nchunks++; ch = new; } @@ -189,7 +201,7 @@ image_chunk_memory(struct chunk *ch, lba_t blk) ch->ch_size = secsz; new->ch_block++; new->ch_size -= secsz; - STAILQ_INSERT_AFTER(&image_chunks, ch, new, ch_list); + TAILQ_INSERT_AFTER(&image_chunks, ch, new, ch_list); image_nchunks++; } @@ -205,7 +217,7 @@ image_chunk_skipto(lba_t to) lba_t from; size_t sz; - ch = STAILQ_LAST(&image_chunks, chunk, ch_list); + ch = TAILQ_LAST(&image_chunks, chunk_head); from = (ch != NULL) ? ch->ch_block + (ch->ch_size / secsz) : 0LL; assert(from <= to); @@ -230,7 +242,7 @@ image_chunk_skipto(lba_t to) ch->ch_block = from; ch->ch_size = sz; ch->ch_type = CH_TYPE_ZEROES; - STAILQ_INSERT_TAIL(&image_chunks, ch, ch_list); + TAILQ_INSERT_TAIL(&image_chunks, ch, ch_list); image_nchunks++; return (0); } @@ -240,7 +252,7 @@ image_chunk_append(lba_t blk, size_t sz, off_t ofs, in { struct chunk *ch; - ch = STAILQ_LAST(&image_chunks, chunk, ch_list); + ch = TAILQ_LAST(&image_chunks, chunk_head); if (ch != NULL && ch->ch_type == CH_TYPE_FILE) { if (fd == ch->ch_u.file.fd && blk == (lba_t)(ch->ch_block + (ch->ch_size / secsz)) && @@ -261,7 +273,7 @@ image_chunk_append(lba_t blk, size_t sz, off_t ofs, in ch->ch_type = CH_TYPE_FILE; ch->ch_u.file.ofs = ofs; ch->ch_u.file.fd = fd; - STAILQ_INSERT_TAIL(&image_chunks, ch, ch_list); + TAILQ_INSERT_TAIL(&image_chunks, ch, ch_list); image_nchunks++; return (0); } @@ -456,8 +468,7 @@ image_copyin_mapped(lba_t blk, int fd, uint64_t *sizep * I don't know what this means or whether it * can happen at all... */ - error = EDOOFUS; - break; + assert(0); } } if (error) @@ -583,10 +594,13 @@ image_copyout_region(int fd, lba_t blk, lba_t size) size *= secsz; - while (size > 0) { + error = 0; + while (!error && size > 0) { ch = image_chunk_find(blk); - if (ch == NULL) - return (EINVAL); + if (ch == NULL) { + error = EINVAL; + break; + } ofs = (blk - ch->ch_block) * secsz; sz = ch->ch_size - ofs; sz = ((lba_t)sz < size) ? sz : (size_t)size; @@ -602,12 +616,12 @@ image_copyout_region(int fd, lba_t blk, lba_t size) error = image_copyout_memory(fd, sz, ch->ch_u.mem.ptr); break; default: - return (EDOOFUS); + assert(0); } size -= sz; blk += sz / secsz; } - return (0); + return (error); } int @@ -682,7 +696,7 @@ image_cleanup(void) { struct chunk *ch; - while ((ch = STAILQ_FIRST(&image_chunks)) != NULL) { + while ((ch = TAILQ_FIRST(&image_chunks)) != NULL) { switch (ch->ch_type) { case CH_TYPE_FILE: /* We may be closing the same file multiple times. */ @@ -695,7 +709,7 @@ image_cleanup(void) default: break; } - STAILQ_REMOVE_HEAD(&image_chunks, ch_list); + TAILQ_REMOVE(&image_chunks, ch, ch_list); free(ch); } if (image_swap_fd != -1) @@ -708,7 +722,7 @@ image_init(void) { const char *tmpdir; - STAILQ_INIT(&image_chunks); + TAILQ_INIT(&image_chunks); image_nchunks = 0; image_swap_size = 0; Modified: stable/11/usr.bin/mkimg/mbr.c ============================================================================== --- stable/11/usr.bin/mkimg/mbr.c Wed Feb 7 15:06:54 2018 (r328973) +++ stable/11/usr.bin/mkimg/mbr.c Wed Feb 7 15:32:31 2018 (r328974) @@ -27,35 +27,23 @@ #include __FBSDID("$FreeBSD$"); -#include -#include -#include #include +#include #include #include #include +#include + +#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" -#ifndef DOSPTYP_FAT16B -#define DOSPTYP_FAT16B 0x06 -#endif -#ifndef DOSPTYP_FAT32 -#define DOSPTYP_FAT32 0x0b -#endif -#ifndef DOSPTYP_PPCBOOT -#define DOSPTYP_PPCBOOT 0x41 -#endif -#ifndef DOSPTYP_EFI -#define DOSPTYP_EFI 0xef -#endif - static struct mkimg_alias mbr_aliases[] = { { ALIAS_EBR, ALIAS_INT2TYPE(DOSPTYP_EXT) }, { ALIAS_EFI, ALIAS_INT2TYPE(DOSPTYP_EFI) }, - { ALIAS_FAT16B, ALIAS_INT2TYPE(DOSPTYP_FAT16B) }, + { ALIAS_FAT16B, ALIAS_INT2TYPE(DOSPTYP_FAT16) }, { ALIAS_FAT32, ALIAS_INT2TYPE(DOSPTYP_FAT32) }, { ALIAS_FREEBSD, ALIAS_INT2TYPE(DOSPTYP_386BSD) }, { ALIAS_NTFS, ALIAS_INT2TYPE(DOSPTYP_NTFS) }, @@ -101,10 +89,15 @@ mbr_write(lba_t imgsz __unused, void *bootcode) memset(mbr, 0, secsz); le16enc(mbr + DOSMAGICOFFSET, DOSMAGIC); dpbase = (void *)(mbr + DOSPARTOFF); - STAILQ_FOREACH(part, &partlist, link) { + TAILQ_FOREACH(part, &partlist, link) { size = round_track(part->size); dp = dpbase + part->index; - dp->dp_flag = (part->index == 0 && bootcode != NULL) ? 0x80 : 0; + if (active_partition != 0) + dp->dp_flag = + (part->index + 1 == active_partition) ? 0x80 : 0; + else + dp->dp_flag = + (part->index == 0 && bootcode != NULL) ? 0x80 : 0; mbr_chs(&dp->dp_scyl, &dp->dp_shd, &dp->dp_ssect, part->block); dp->dp_typ = ALIAS_TYPE2INT(part->type); Modified: stable/11/usr.bin/mkimg/mkimg.1 ============================================================================== --- stable/11/usr.bin/mkimg/mkimg.1 Wed Feb 7 15:06:54 2018 (r328973) +++ stable/11/usr.bin/mkimg/mkimg.1 Wed Feb 7 15:32:31 2018 (r328974) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 7, 2015 +.Dd April 26, 2017 .Dt MKIMG 1 .Os .Sh NAME @@ -37,9 +37,12 @@ .Op Fl S Ar secsz .Op Fl T Ar tracksz .Op Fl b Ar bootcode -.Op Fl c Ar capacity +.Op Fl c Ar min_capacity +.Op Fl C Ar max_capacity +.Op Fl -capacity Ar capacity .Op Fl f Ar format .Op Fl o Ar outfile +.Op Fl a Ar active .Op Fl v .Op Fl y .Op Fl s Ar scheme Op Fl p Ar partition ... @@ -119,11 +122,23 @@ An empty partition table can be written to the disk wh partitioning scheme with the .Fl s option, but without specifying any partitions. -When the size required to for all the partitions is larger than the +When the size required for all the partitions is larger than the given capacity, then the disk image will be larger than the capacity given. .Pp The +.Fl C +option specifies a maximum capacity for the disk image. +If the combined sizes of the given partitions exceed the size given with +.Fl C , +image creation fails. +.Pp +The +.Fl -capacity +option is a shorthand to specify the minimum and maximum capacity at the +same time. +.Pp +The .Fl v option increases the level of output that the .Nm @@ -138,6 +153,26 @@ utility will generate predictable values for Universal (UUIDs) and time stamps so that consecutive runs of the .Nm utility will create images that are identical. +.Pp +The +.Ar active +option marks a partition as active, if the partitioning +scheme supports it. +Currently, only the +.Ar mbr +scheme supports this concept. +By default, +.Nm +will only mark the first partition as active when boot code is +specified. +Use the +.Ar active +option to override the active partition. +The number specified corresponds to the number after the 's' in the +partition's +.Xr geom 8 +name. +No partitions are marked active when the value is 0. .Pp A set of long options exist to query about the .Nm Modified: stable/11/usr.bin/mkimg/mkimg.c ============================================================================== --- stable/11/usr.bin/mkimg/mkimg.c Wed Feb 7 15:06:54 2018 (r328973) +++ stable/11/usr.bin/mkimg/mkimg.c Wed Feb 7 15:32:31 2018 (r328974) @@ -27,17 +27,15 @@ #include __FBSDID("$FreeBSD$"); -#include -#include +#include #include -#include -#include #include #include #include #include #include #include +#include #include #include #include @@ -49,20 +47,23 @@ __FBSDID("$FreeBSD$"); #include "mkimg.h" #include "scheme.h" -#define LONGOPT_FORMATS 0x01000001 -#define LONGOPT_SCHEMES 0x01000002 -#define LONGOPT_VERSION 0x01000003 +#define LONGOPT_FORMATS 0x01000001 +#define LONGOPT_SCHEMES 0x01000002 +#define LONGOPT_VERSION 0x01000003 +#define LONGOPT_CAPACITY 0x01000004 static struct option longopts[] = { { "formats", no_argument, NULL, LONGOPT_FORMATS }, { "schemes", no_argument, NULL, LONGOPT_SCHEMES }, { "version", no_argument, NULL, LONGOPT_VERSION }, + { "capacity", required_argument, NULL, LONGOPT_CAPACITY }, { NULL, 0, NULL, 0 } }; -static uint64_t capacity; +static uint64_t min_capacity = 0; +static uint64_t max_capacity = 0; -struct partlisthead partlist = STAILQ_HEAD_INITIALIZER(partlist); +struct partlisthead partlist = TAILQ_HEAD_INITIALIZER(partlist); u_int nparts = 0; u_int unit_testing; @@ -73,24 +74,25 @@ u_int nheads = 1; u_int nsecs = 1; u_int secsz = 512; u_int blksz = 0; +uint32_t active_partition = 0; static void print_formats(int usage) { - struct mkimg_format *f, **f_iter; + struct mkimg_format *f; const char *sep; if (usage) { fprintf(stderr, " formats:\n"); - SET_FOREACH(f_iter, formats) { - f = *f_iter; + f = NULL; + while ((f = format_iterate(f)) != NULL) { fprintf(stderr, "\t%s\t- %s\n", f->name, f->description); } } else { sep = ""; - SET_FOREACH(f_iter, formats) { - f = *f_iter; + f = NULL; + while ((f = format_iterate(f)) != NULL) { printf("%s%s", sep, f->name); sep = " "; } @@ -101,20 +103,20 @@ print_formats(int usage) static void print_schemes(int usage) { - struct mkimg_scheme *s, **s_iter; + struct mkimg_scheme *s; const char *sep; if (usage) { fprintf(stderr, " schemes:\n"); - SET_FOREACH(s_iter, schemes) { - s = *s_iter; + s = NULL; + while ((s = scheme_iterate(s)) != NULL) { fprintf(stderr, "\t%s\t- %s\n", s->name, s->description); } } else { sep = ""; - SET_FOREACH(s_iter, schemes) { - s = *s_iter; + s = NULL; + while ((s = scheme_iterate(s)) != NULL) { printf("%s%s", sep, s->name); sep = " "; } @@ -148,8 +150,10 @@ usage(const char *why) fprintf(stderr, "\t--schemes\t- list partition schemes\n"); fprintf(stderr, "\t--version\t- show version information\n"); fputc('\n', stderr); + fprintf(stderr, "\t-a \t- mark num'th partion as active\n"); fprintf(stderr, "\t-b \t- file containing boot code\n"); - fprintf(stderr, "\t-c \t- capacity (in bytes) of the disk\n"); + fprintf(stderr, "\t-c \t- minimum capacity (in bytes) of the disk\n"); + fprintf(stderr, "\t-C \t- maximum capacity (in bytes) of the disk\n"); fprintf(stderr, "\t-f \n"); fprintf(stderr, "\t-o \t- file to write image into\n"); fprintf(stderr, "\t-p \n"); @@ -302,7 +306,7 @@ parse_part(const char *spec) } part->index = nparts; - STAILQ_INSERT_TAIL(&partlist, part, link); + TAILQ_INSERT_TAIL(&partlist, part, link); nparts++; return (0); @@ -376,31 +380,20 @@ mkimg_chs(lba_t lba, u_int maxcyl, u_int *cylp, u_int *secp = sec; } -void -mkimg_uuid(struct uuid *uuid) -{ - static uint8_t gen[sizeof(struct uuid)]; - u_int i; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Wed Feb 7 16:45:40 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 64ED5F13FB3; Wed, 7 Feb 2018 16:45:40 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 167C872000; Wed, 7 Feb 2018 16:45:40 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0FFD51708; Wed, 7 Feb 2018 16:45:40 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w17GjeoW093423; Wed, 7 Feb 2018 16:45:40 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w17Gjd2F093411; Wed, 7 Feb 2018 16:45:39 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201802071645.w17Gjd2F093411@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Wed, 7 Feb 2018 16:45:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328976 - in stable/11/usr.bin/mkimg: . tests X-SVN-Group: stable-11 X-SVN-Commit-Author: manu X-SVN-Commit-Paths: in stable/11/usr.bin/mkimg: . tests X-SVN-Commit-Revision: 328976 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 16:45:40 -0000 Author: manu Date: Wed Feb 7 16:45:38 2018 New Revision: 328976 URL: https://svnweb.freebsd.org/changeset/base/328976 Log: Revert r328974, r307387 was not supposed to be part of it. Deleted: stable/11/usr.bin/mkimg/endian.h stable/11/usr.bin/mkimg/uuid.c Modified: stable/11/usr.bin/mkimg/Makefile stable/11/usr.bin/mkimg/apm.c stable/11/usr.bin/mkimg/bsd.c stable/11/usr.bin/mkimg/ebr.c stable/11/usr.bin/mkimg/format.c stable/11/usr.bin/mkimg/format.h stable/11/usr.bin/mkimg/gpt.c stable/11/usr.bin/mkimg/image.c stable/11/usr.bin/mkimg/mbr.c stable/11/usr.bin/mkimg/mkimg.1 stable/11/usr.bin/mkimg/mkimg.c stable/11/usr.bin/mkimg/mkimg.h stable/11/usr.bin/mkimg/pc98.c stable/11/usr.bin/mkimg/qcow.c stable/11/usr.bin/mkimg/raw.c stable/11/usr.bin/mkimg/scheme.c stable/11/usr.bin/mkimg/scheme.h stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow2.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.raw.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhd.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhdf.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.vmdk.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.qcow.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.qcow2.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.raw.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.vhd.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.vhdf.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.vmdk.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.qcow.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.qcow2.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.raw.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.vhd.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.vhdf.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.vmdk.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.qcow.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.qcow2.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.raw.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.vhd.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.vhdf.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.vmdk.gz.uu stable/11/usr.bin/mkimg/vhd.c stable/11/usr.bin/mkimg/vmdk.c stable/11/usr.bin/mkimg/vtoc8.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/mkimg/Makefile ============================================================================== --- stable/11/usr.bin/mkimg/Makefile Wed Feb 7 16:28:26 2018 (r328975) +++ stable/11/usr.bin/mkimg/Makefile Wed Feb 7 16:45:38 2018 (r328976) @@ -3,15 +3,14 @@ .include PROG= mkimg -SRCS= format.c image.c mkimg.c scheme.c uuid.c +SRCS= format.c image.c mkimg.c scheme.c MAN= mkimg.1 -MKIMG_VERSION=20161016 +MKIMG_VERSION=20151211 mkimg.o: Makefile CFLAGS+=-DMKIMG_VERSION=${MKIMG_VERSION} CFLAGS+=-DSPARSE_WRITE -CFLAGS+=-I${SRCTOP}/sys/sys/disk # List of formats to support SRCS+= \ Modified: stable/11/usr.bin/mkimg/apm.c ============================================================================== --- stable/11/usr.bin/mkimg/apm.c Wed Feb 7 16:28:26 2018 (r328975) +++ stable/11/usr.bin/mkimg/apm.c Wed Feb 7 16:45:38 2018 (r328976) @@ -27,19 +27,25 @@ #include __FBSDID("$FreeBSD$"); +#include +#include +#include #include -#include #include #include #include -#include - -#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" +#ifndef APM_ENT_TYPE_APPLE_BOOT +#define APM_ENT_TYPE_APPLE_BOOT "Apple_Bootstrap" +#endif +#ifndef APM_ENT_TYPE_FREEBSD_NANDFS +#define APM_ENT_TYPE_FREEBSD_NANDFS "FreeBSD-nandfs" +#endif + static struct mkimg_alias apm_aliases[] = { { ALIAS_FREEBSD, ALIAS_PTR2TYPE(APM_ENT_TYPE_FREEBSD) }, { ALIAS_FREEBSD_BOOT, ALIAS_PTR2TYPE(APM_ENT_TYPE_APPLE_BOOT) }, @@ -85,7 +91,7 @@ apm_write(lba_t imgsz, void *bootcode __unused) strncpy(ent->ent_type, APM_ENT_TYPE_SELF, sizeof(ent->ent_type)); strncpy(ent->ent_name, "Apple", sizeof(ent->ent_name)); - TAILQ_FOREACH(part, &partlist, link) { + STAILQ_FOREACH(part, &partlist, link) { ent = (void *)(buf + (part->index + 2) * secsz); be16enc(&ent->ent_sig, APM_ENT_SIG); be32enc(&ent->ent_pmblkcnt, nparts + 1); Modified: stable/11/usr.bin/mkimg/bsd.c ============================================================================== --- stable/11/usr.bin/mkimg/bsd.c Wed Feb 7 16:28:26 2018 (r328975) +++ stable/11/usr.bin/mkimg/bsd.c Wed Feb 7 16:45:38 2018 (r328976) @@ -27,19 +27,22 @@ #include __FBSDID("$FreeBSD$"); +#include +#include +#include #include -#include #include #include #include -#include - -#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" +#ifndef FS_NANDFS +#define FS_NANDFS 30 +#endif + static struct mkimg_alias bsd_aliases[] = { { ALIAS_FREEBSD_NANDFS, ALIAS_INT2TYPE(FS_NANDFS) }, { ALIAS_FREEBSD_SWAP, ALIAS_INT2TYPE(FS_SWAP) }, @@ -54,7 +57,7 @@ bsd_metadata(u_int where, lba_t blk) { if (where == SCHEME_META_IMG_START) - blk += BSD_BOOTBLOCK_SIZE / secsz; + blk += BBSIZE / secsz; else if (where == SCHEME_META_IMG_END) blk = round_cylinder(blk); else @@ -72,21 +75,21 @@ bsd_write(lba_t imgsz, void *bootcode) int bsdparts, error, n; uint16_t checksum; - buf = malloc(BSD_BOOTBLOCK_SIZE); + buf = malloc(BBSIZE); if (buf == NULL) return (ENOMEM); if (bootcode != NULL) { - memcpy(buf, bootcode, BSD_BOOTBLOCK_SIZE); + memcpy(buf, bootcode, BBSIZE); memset(buf + secsz, 0, sizeof(struct disklabel)); } else - memset(buf, 0, BSD_BOOTBLOCK_SIZE); + memset(buf, 0, BBSIZE); bsdparts = nparts + 1; /* Account for c partition */ - if (bsdparts < BSD_NPARTS_MIN) - bsdparts = BSD_NPARTS_MIN; + if (bsdparts < MAXPARTITIONS) + bsdparts = MAXPARTITIONS; d = (void *)(buf + secsz); - le32enc(&d->d_magic, BSD_MAGIC); + le32enc(&d->d_magic, DISKMAGIC); le32enc(&d->d_secsize, secsz); le32enc(&d->d_nsectors, nsecs); le32enc(&d->d_ntracks, nheads); @@ -94,14 +97,14 @@ bsd_write(lba_t imgsz, void *bootcode) le32enc(&d->d_secpercyl, nsecs * nheads); le32enc(&d->d_secperunit, imgsz); le16enc(&d->d_rpm, 3600); - le32enc(&d->d_magic2, BSD_MAGIC); + le32enc(&d->d_magic2, DISKMAGIC); le16enc(&d->d_npartitions, bsdparts); - le32enc(&d->d_bbsize, BSD_BOOTBLOCK_SIZE); + le32enc(&d->d_bbsize, BBSIZE); - dp = &d->d_partitions[BSD_PART_RAW]; + dp = &d->d_partitions[RAW_PART]; le32enc(&dp->p_size, imgsz); - TAILQ_FOREACH(part, &partlist, link) { - n = part->index + ((part->index >= BSD_PART_RAW) ? 1 : 0); + STAILQ_FOREACH(part, &partlist, link) { + n = part->index + ((part->index >= RAW_PART) ? 1 : 0); dp = &d->d_partitions[n]; le32enc(&dp->p_size, part->size); le32enc(&dp->p_offset, part->block); @@ -117,7 +120,7 @@ bsd_write(lba_t imgsz, void *bootcode) checksum ^= le16dec(p); le16enc(&d->d_checksum, checksum); - error = image_write(0, buf, BSD_BOOTBLOCK_SIZE / secsz); + error = image_write(0, buf, BBSIZE / secsz); free(buf); return (error); } @@ -128,8 +131,8 @@ static struct mkimg_scheme bsd_scheme = { .aliases = bsd_aliases, .metadata = bsd_metadata, .write = bsd_write, - .nparts = BSD_NPARTS_MAX - 1, - .bootcode = BSD_BOOTBLOCK_SIZE, + .nparts = 19, + .bootcode = BBSIZE, .maxsecsz = 512 }; Modified: stable/11/usr.bin/mkimg/ebr.c ============================================================================== --- stable/11/usr.bin/mkimg/ebr.c Wed Feb 7 16:28:26 2018 (r328975) +++ stable/11/usr.bin/mkimg/ebr.c Wed Feb 7 16:45:38 2018 (r328976) @@ -27,21 +27,27 @@ #include __FBSDID("$FreeBSD$"); +#include +#include +#include #include -#include #include #include #include -#include - -#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" +#ifndef DOSPTYP_FAT16B +#define DOSPTYP_FAT16B 0x06 +#endif +#ifndef DOSPTYP_FAT32 +#define DOSPTYP_FAT32 0x0b +#endif + static struct mkimg_alias ebr_aliases[] = { - { ALIAS_FAT16B, ALIAS_INT2TYPE(DOSPTYP_FAT16) }, + { ALIAS_FAT16B, ALIAS_INT2TYPE(DOSPTYP_FAT16B) }, { ALIAS_FAT32, ALIAS_INT2TYPE(DOSPTYP_FAT32) }, { ALIAS_FREEBSD, ALIAS_INT2TYPE(DOSPTYP_386BSD) }, { ALIAS_NONE, 0 } @@ -82,7 +88,7 @@ ebr_write(lba_t imgsz __unused, void *bootcode __unuse le16enc(ebr + DOSMAGICOFFSET, DOSMAGIC); error = 0; - TAILQ_FOREACH(part, &partlist, link) { + STAILQ_FOREACH_SAFE(part, &partlist, link, next) { block = part->block - nsecs; size = round_track(part->size); dp = (void *)(ebr + DOSPARTOFF); @@ -94,7 +100,6 @@ ebr_write(lba_t imgsz __unused, void *bootcode __unuse le32enc(&dp->dp_size, size); /* Add link entry */ - next = TAILQ_NEXT(part, link); if (next != NULL) { size = round_track(next->size); dp++; Modified: stable/11/usr.bin/mkimg/format.c ============================================================================== --- stable/11/usr.bin/mkimg/format.c Wed Feb 7 16:28:26 2018 (r328975) +++ stable/11/usr.bin/mkimg/format.c Wed Feb 7 16:45:38 2018 (r328976) @@ -27,6 +27,9 @@ #include __FBSDID("$FreeBSD$"); +#include +#include +#include #include #include #include @@ -39,24 +42,8 @@ __FBSDID("$FreeBSD$"); #include "format.h" #include "mkimg.h" -static struct mkimg_format *first; static struct mkimg_format *format; -struct mkimg_format * -format_iterate(struct mkimg_format *f) -{ - - return ((f == NULL) ? first : f->next); -} - -void -format_register(struct mkimg_format *f) -{ - - f->next = first; - first = f; -} - int format_resize(lba_t end) { @@ -69,10 +56,10 @@ format_resize(lba_t end) int format_select(const char *spec) { - struct mkimg_format *f; + struct mkimg_format *f, **iter; - f = NULL; - while ((f = format_iterate(f)) != NULL) { + SET_FOREACH(iter, formats) { + f = *iter; if (strcasecmp(spec, f->name) == 0) { format = f; return (0); Modified: stable/11/usr.bin/mkimg/format.h ============================================================================== --- stable/11/usr.bin/mkimg/format.h Wed Feb 7 16:28:26 2018 (r328975) +++ stable/11/usr.bin/mkimg/format.h Wed Feb 7 16:45:38 2018 (r328976) @@ -29,24 +29,21 @@ #ifndef _MKIMG_FORMAT_H_ #define _MKIMG_FORMAT_H_ +#include + struct mkimg_format { - struct mkimg_format *next; const char *name; const char *description; int (*resize)(lba_t); int (*write)(int); }; -#define FORMAT_DEFINE(nm) \ -static void format_register_##nm(void) __attribute__((constructor)); \ -static void format_register_##nm(void) { format_register(&nm); } +SET_DECLARE(formats, struct mkimg_format); +#define FORMAT_DEFINE(nm) DATA_SET(formats, nm) -struct mkimg_format *format_iterate(struct mkimg_format *); -void format_register(struct mkimg_format *); +int format_resize(lba_t); int format_select(const char *); struct mkimg_format *format_selected(void); - -int format_resize(lba_t); int format_write(int); #endif /* _MKIMG_FORMAT_H_ */ Modified: stable/11/usr.bin/mkimg/gpt.c ============================================================================== --- stable/11/usr.bin/mkimg/gpt.c Wed Feb 7 16:28:26 2018 (r328975) +++ stable/11/usr.bin/mkimg/gpt.c Wed Feb 7 16:45:38 2018 (r328976) @@ -27,32 +27,38 @@ #include __FBSDID("$FreeBSD$"); +#include +#include +#include #include +#include #include #include #include #include #include +#include -#include -#include - -#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" -static mkimg_uuid_t gpt_uuid_efi = GPT_ENT_TYPE_EFI; -static mkimg_uuid_t gpt_uuid_freebsd = GPT_ENT_TYPE_FREEBSD; -static mkimg_uuid_t gpt_uuid_freebsd_boot = GPT_ENT_TYPE_FREEBSD_BOOT; -static mkimg_uuid_t gpt_uuid_freebsd_nandfs = GPT_ENT_TYPE_FREEBSD_NANDFS; -static mkimg_uuid_t gpt_uuid_freebsd_swap = GPT_ENT_TYPE_FREEBSD_SWAP; -static mkimg_uuid_t gpt_uuid_freebsd_ufs = GPT_ENT_TYPE_FREEBSD_UFS; -static mkimg_uuid_t gpt_uuid_freebsd_vinum = GPT_ENT_TYPE_FREEBSD_VINUM; -static mkimg_uuid_t gpt_uuid_freebsd_zfs = GPT_ENT_TYPE_FREEBSD_ZFS; -static mkimg_uuid_t gpt_uuid_mbr = GPT_ENT_TYPE_MBR; -static mkimg_uuid_t gpt_uuid_ms_basic_data = GPT_ENT_TYPE_MS_BASIC_DATA; +#ifndef GPT_ENT_TYPE_FREEBSD_NANDFS +#define GPT_ENT_TYPE_FREEBSD_NANDFS \ + {0x74ba7dd9,0xa689,0x11e1,0xbd,0x04,{0x00,0xe0,0x81,0x28,0x6a,0xcf}} +#endif +static uuid_t gpt_uuid_efi = GPT_ENT_TYPE_EFI; +static uuid_t gpt_uuid_freebsd = GPT_ENT_TYPE_FREEBSD; +static uuid_t gpt_uuid_freebsd_boot = GPT_ENT_TYPE_FREEBSD_BOOT; +static uuid_t gpt_uuid_freebsd_nandfs = GPT_ENT_TYPE_FREEBSD_NANDFS; +static uuid_t gpt_uuid_freebsd_swap = GPT_ENT_TYPE_FREEBSD_SWAP; +static uuid_t gpt_uuid_freebsd_ufs = GPT_ENT_TYPE_FREEBSD_UFS; +static uuid_t gpt_uuid_freebsd_vinum = GPT_ENT_TYPE_FREEBSD_VINUM; +static uuid_t gpt_uuid_freebsd_zfs = GPT_ENT_TYPE_FREEBSD_ZFS; +static uuid_t gpt_uuid_mbr = GPT_ENT_TYPE_MBR; +static uuid_t gpt_uuid_ms_basic_data = GPT_ENT_TYPE_MS_BASIC_DATA; + static struct mkimg_alias gpt_aliases[] = { { ALIAS_EFI, ALIAS_PTR2TYPE(&gpt_uuid_efi) }, { ALIAS_FREEBSD, ALIAS_PTR2TYPE(&gpt_uuid_freebsd) }, @@ -125,6 +131,21 @@ crc32(const void *buf, size_t sz) return (crc ^ ~0U); } +static void +gpt_uuid_enc(void *buf, const uuid_t *uuid) +{ + uint8_t *p = buf; + int i; + + le32enc(p, uuid->time_low); + le16enc(p + 4, uuid->time_mid); + le16enc(p + 6, uuid->time_hi_and_version); + p[8] = uuid->clock_seq_hi_and_reserved; + p[9] = uuid->clock_seq_low; + for (i = 0; i < _UUID_NODE_LEN; i++) + p[10 + i] = uuid->node[i]; +} + static u_int gpt_tblsz(void) { @@ -152,7 +173,7 @@ gpt_write_pmbr(lba_t blks, void *bootcode) uint32_t secs; int error; - secs = (blks > UINT32_MAX) ? UINT32_MAX : (uint32_t)blks - 1; + secs = (blks > UINT32_MAX) ? UINT32_MAX : (uint32_t)blks; pmbr = malloc(secsz); if (pmbr == NULL) @@ -178,7 +199,7 @@ gpt_write_pmbr(lba_t blks, void *bootcode) static struct gpt_ent * gpt_mktbl(u_int tblsz) { - mkimg_uuid_t uuid; + uuid_t uuid; struct gpt_ent *tbl, *ent; struct part *part; int c, idx; @@ -187,11 +208,11 @@ gpt_mktbl(u_int tblsz) if (tbl == NULL) return (NULL); - TAILQ_FOREACH(part, &partlist, link) { + STAILQ_FOREACH(part, &partlist, link) { ent = tbl + part->index; - mkimg_uuid_enc(&ent->ent_type, ALIAS_TYPE2PTR(part->type)); + gpt_uuid_enc(&ent->ent_type, ALIAS_TYPE2PTR(part->type)); mkimg_uuid(&uuid); - mkimg_uuid_enc(&ent->ent_uuid, &uuid); + gpt_uuid_enc(&ent->ent_uuid, &uuid); le64enc(&ent->ent_lba_start, part->block); le64enc(&ent->ent_lba_end, part->block + part->size - 1); if (part->label != NULL) { @@ -222,7 +243,7 @@ gpt_write_hdr(struct gpt_hdr *hdr, uint64_t self, uint static int gpt_write(lba_t imgsz, void *bootcode) { - mkimg_uuid_t uuid; + uuid_t uuid; struct gpt_ent *tbl; struct gpt_hdr *hdr; uint32_t crc; @@ -259,7 +280,7 @@ gpt_write(lba_t imgsz, void *bootcode) le64enc(&hdr->hdr_lba_start, 2 + tblsz); le64enc(&hdr->hdr_lba_end, imgsz - tblsz - 2); mkimg_uuid(&uuid); - mkimg_uuid_enc(&hdr->hdr_uuid, &uuid); + gpt_uuid_enc(&hdr->hdr_uuid, &uuid); le32enc(&hdr->hdr_entries, nparts); le32enc(&hdr->hdr_entsz, sizeof(struct gpt_ent)); crc = crc32(tbl, nparts * sizeof(struct gpt_ent)); Modified: stable/11/usr.bin/mkimg/image.c ============================================================================== --- stable/11/usr.bin/mkimg/image.c Wed Feb 7 16:28:26 2018 (r328975) +++ stable/11/usr.bin/mkimg/image.c Wed Feb 7 16:45:38 2018 (r328976) @@ -28,7 +28,9 @@ __FBSDID("$FreeBSD$"); #include +#include #include +#include #include #include #include @@ -43,22 +45,8 @@ __FBSDID("$FreeBSD$"); #include "image.h" #include "mkimg.h" -#ifndef MAP_NOCORE -#define MAP_NOCORE 0 -#endif -#ifndef MAP_NOSYNC -#define MAP_NOSYNC 0 -#endif - -#ifndef SEEK_DATA -#define SEEK_DATA -1 -#endif -#ifndef SEEK_HOLE -#define SEEK_HOLE -1 -#endif - struct chunk { - TAILQ_ENTRY(chunk) ch_list; + STAILQ_ENTRY(chunk) ch_list; size_t ch_size; /* Size of chunk in bytes. */ lba_t ch_block; /* Block address in image. */ union { @@ -76,7 +64,7 @@ struct chunk { #define CH_TYPE_MEMORY 2 /* Memory-backed chunk */ }; -static TAILQ_HEAD(chunk_head, chunk) image_chunks; +static STAILQ_HEAD(chunk_head, chunk) image_chunks; static u_int image_nchunks; static char image_swap_file[PATH_MAX]; @@ -137,14 +125,14 @@ image_chunk_find(lba_t blk) struct chunk *ch; ch = (last != NULL && last->ch_block <= blk) - ? last : TAILQ_FIRST(&image_chunks); + ? last : STAILQ_FIRST(&image_chunks); while (ch != NULL) { if (ch->ch_block <= blk && (lba_t)(ch->ch_block + (ch->ch_size / secsz)) > blk) { last = ch; break; } - ch = TAILQ_NEXT(ch, ch_list); + ch = STAILQ_NEXT(ch, ch_list); } return (ch); } @@ -186,7 +174,7 @@ image_chunk_memory(struct chunk *ch, lba_t blk) ch->ch_size = (blk - ch->ch_block) * secsz; new->ch_block = blk; new->ch_size -= ch->ch_size; - TAILQ_INSERT_AFTER(&image_chunks, ch, new, ch_list); + STAILQ_INSERT_AFTER(&image_chunks, ch, new, ch_list); image_nchunks++; ch = new; } @@ -201,7 +189,7 @@ image_chunk_memory(struct chunk *ch, lba_t blk) ch->ch_size = secsz; new->ch_block++; new->ch_size -= secsz; - TAILQ_INSERT_AFTER(&image_chunks, ch, new, ch_list); + STAILQ_INSERT_AFTER(&image_chunks, ch, new, ch_list); image_nchunks++; } @@ -217,7 +205,7 @@ image_chunk_skipto(lba_t to) lba_t from; size_t sz; - ch = TAILQ_LAST(&image_chunks, chunk_head); + ch = STAILQ_LAST(&image_chunks, chunk, ch_list); from = (ch != NULL) ? ch->ch_block + (ch->ch_size / secsz) : 0LL; assert(from <= to); @@ -242,7 +230,7 @@ image_chunk_skipto(lba_t to) ch->ch_block = from; ch->ch_size = sz; ch->ch_type = CH_TYPE_ZEROES; - TAILQ_INSERT_TAIL(&image_chunks, ch, ch_list); + STAILQ_INSERT_TAIL(&image_chunks, ch, ch_list); image_nchunks++; return (0); } @@ -252,7 +240,7 @@ image_chunk_append(lba_t blk, size_t sz, off_t ofs, in { struct chunk *ch; - ch = TAILQ_LAST(&image_chunks, chunk_head); + ch = STAILQ_LAST(&image_chunks, chunk, ch_list); if (ch != NULL && ch->ch_type == CH_TYPE_FILE) { if (fd == ch->ch_u.file.fd && blk == (lba_t)(ch->ch_block + (ch->ch_size / secsz)) && @@ -273,7 +261,7 @@ image_chunk_append(lba_t blk, size_t sz, off_t ofs, in ch->ch_type = CH_TYPE_FILE; ch->ch_u.file.ofs = ofs; ch->ch_u.file.fd = fd; - TAILQ_INSERT_TAIL(&image_chunks, ch, ch_list); + STAILQ_INSERT_TAIL(&image_chunks, ch, ch_list); image_nchunks++; return (0); } @@ -468,7 +456,8 @@ image_copyin_mapped(lba_t blk, int fd, uint64_t *sizep * I don't know what this means or whether it * can happen at all... */ - assert(0); + error = EDOOFUS; + break; } } if (error) @@ -594,13 +583,10 @@ image_copyout_region(int fd, lba_t blk, lba_t size) size *= secsz; - error = 0; - while (!error && size > 0) { + while (size > 0) { ch = image_chunk_find(blk); - if (ch == NULL) { - error = EINVAL; - break; - } + if (ch == NULL) + return (EINVAL); ofs = (blk - ch->ch_block) * secsz; sz = ch->ch_size - ofs; sz = ((lba_t)sz < size) ? sz : (size_t)size; @@ -616,12 +602,12 @@ image_copyout_region(int fd, lba_t blk, lba_t size) error = image_copyout_memory(fd, sz, ch->ch_u.mem.ptr); break; default: - assert(0); + return (EDOOFUS); } size -= sz; blk += sz / secsz; } - return (error); + return (0); } int @@ -696,7 +682,7 @@ image_cleanup(void) { struct chunk *ch; - while ((ch = TAILQ_FIRST(&image_chunks)) != NULL) { + while ((ch = STAILQ_FIRST(&image_chunks)) != NULL) { switch (ch->ch_type) { case CH_TYPE_FILE: /* We may be closing the same file multiple times. */ @@ -709,7 +695,7 @@ image_cleanup(void) default: break; } - TAILQ_REMOVE(&image_chunks, ch, ch_list); + STAILQ_REMOVE_HEAD(&image_chunks, ch_list); free(ch); } if (image_swap_fd != -1) @@ -722,7 +708,7 @@ image_init(void) { const char *tmpdir; - TAILQ_INIT(&image_chunks); + STAILQ_INIT(&image_chunks); image_nchunks = 0; image_swap_size = 0; Modified: stable/11/usr.bin/mkimg/mbr.c ============================================================================== --- stable/11/usr.bin/mkimg/mbr.c Wed Feb 7 16:28:26 2018 (r328975) +++ stable/11/usr.bin/mkimg/mbr.c Wed Feb 7 16:45:38 2018 (r328976) @@ -27,23 +27,35 @@ #include __FBSDID("$FreeBSD$"); +#include +#include +#include #include -#include #include #include #include -#include - -#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" +#ifndef DOSPTYP_FAT16B +#define DOSPTYP_FAT16B 0x06 +#endif +#ifndef DOSPTYP_FAT32 +#define DOSPTYP_FAT32 0x0b +#endif +#ifndef DOSPTYP_PPCBOOT +#define DOSPTYP_PPCBOOT 0x41 +#endif +#ifndef DOSPTYP_EFI +#define DOSPTYP_EFI 0xef +#endif + static struct mkimg_alias mbr_aliases[] = { { ALIAS_EBR, ALIAS_INT2TYPE(DOSPTYP_EXT) }, { ALIAS_EFI, ALIAS_INT2TYPE(DOSPTYP_EFI) }, - { ALIAS_FAT16B, ALIAS_INT2TYPE(DOSPTYP_FAT16) }, + { ALIAS_FAT16B, ALIAS_INT2TYPE(DOSPTYP_FAT16B) }, { ALIAS_FAT32, ALIAS_INT2TYPE(DOSPTYP_FAT32) }, { ALIAS_FREEBSD, ALIAS_INT2TYPE(DOSPTYP_386BSD) }, { ALIAS_NTFS, ALIAS_INT2TYPE(DOSPTYP_NTFS) }, @@ -89,15 +101,10 @@ mbr_write(lba_t imgsz __unused, void *bootcode) memset(mbr, 0, secsz); le16enc(mbr + DOSMAGICOFFSET, DOSMAGIC); dpbase = (void *)(mbr + DOSPARTOFF); - TAILQ_FOREACH(part, &partlist, link) { + STAILQ_FOREACH(part, &partlist, link) { size = round_track(part->size); dp = dpbase + part->index; - if (active_partition != 0) - dp->dp_flag = - (part->index + 1 == active_partition) ? 0x80 : 0; - else - dp->dp_flag = - (part->index == 0 && bootcode != NULL) ? 0x80 : 0; + dp->dp_flag = (part->index == 0 && bootcode != NULL) ? 0x80 : 0; mbr_chs(&dp->dp_scyl, &dp->dp_shd, &dp->dp_ssect, part->block); dp->dp_typ = ALIAS_TYPE2INT(part->type); Modified: stable/11/usr.bin/mkimg/mkimg.1 ============================================================================== --- stable/11/usr.bin/mkimg/mkimg.1 Wed Feb 7 16:28:26 2018 (r328975) +++ stable/11/usr.bin/mkimg/mkimg.1 Wed Feb 7 16:45:38 2018 (r328976) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 26, 2017 +.Dd August 7, 2015 .Dt MKIMG 1 .Os .Sh NAME @@ -37,12 +37,9 @@ .Op Fl S Ar secsz .Op Fl T Ar tracksz .Op Fl b Ar bootcode -.Op Fl c Ar min_capacity -.Op Fl C Ar max_capacity -.Op Fl -capacity Ar capacity +.Op Fl c Ar capacity .Op Fl f Ar format .Op Fl o Ar outfile -.Op Fl a Ar active .Op Fl v .Op Fl y .Op Fl s Ar scheme Op Fl p Ar partition ... @@ -122,23 +119,11 @@ An empty partition table can be written to the disk wh partitioning scheme with the .Fl s option, but without specifying any partitions. -When the size required for all the partitions is larger than the +When the size required to for all the partitions is larger than the given capacity, then the disk image will be larger than the capacity given. .Pp The -.Fl C -option specifies a maximum capacity for the disk image. -If the combined sizes of the given partitions exceed the size given with -.Fl C , -image creation fails. -.Pp -The -.Fl -capacity -option is a shorthand to specify the minimum and maximum capacity at the -same time. -.Pp -The .Fl v option increases the level of output that the .Nm @@ -153,26 +138,6 @@ utility will generate predictable values for Universal (UUIDs) and time stamps so that consecutive runs of the .Nm utility will create images that are identical. -.Pp -The -.Ar active -option marks a partition as active, if the partitioning -scheme supports it. -Currently, only the -.Ar mbr -scheme supports this concept. -By default, -.Nm -will only mark the first partition as active when boot code is -specified. -Use the -.Ar active -option to override the active partition. -The number specified corresponds to the number after the 's' in the -partition's -.Xr geom 8 -name. -No partitions are marked active when the value is 0. .Pp A set of long options exist to query about the .Nm Modified: stable/11/usr.bin/mkimg/mkimg.c ============================================================================== --- stable/11/usr.bin/mkimg/mkimg.c Wed Feb 7 16:28:26 2018 (r328975) +++ stable/11/usr.bin/mkimg/mkimg.c Wed Feb 7 16:45:38 2018 (r328976) @@ -27,15 +27,17 @@ #include __FBSDID("$FreeBSD$"); -#include +#include +#include #include +#include +#include #include #include #include #include #include #include -#include #include #include #include @@ -47,23 +49,20 @@ __FBSDID("$FreeBSD$"); #include "mkimg.h" #include "scheme.h" -#define LONGOPT_FORMATS 0x01000001 -#define LONGOPT_SCHEMES 0x01000002 -#define LONGOPT_VERSION 0x01000003 -#define LONGOPT_CAPACITY 0x01000004 +#define LONGOPT_FORMATS 0x01000001 +#define LONGOPT_SCHEMES 0x01000002 +#define LONGOPT_VERSION 0x01000003 static struct option longopts[] = { { "formats", no_argument, NULL, LONGOPT_FORMATS }, { "schemes", no_argument, NULL, LONGOPT_SCHEMES }, { "version", no_argument, NULL, LONGOPT_VERSION }, - { "capacity", required_argument, NULL, LONGOPT_CAPACITY }, { NULL, 0, NULL, 0 } }; -static uint64_t min_capacity = 0; -static uint64_t max_capacity = 0; +static uint64_t capacity; -struct partlisthead partlist = TAILQ_HEAD_INITIALIZER(partlist); +struct partlisthead partlist = STAILQ_HEAD_INITIALIZER(partlist); u_int nparts = 0; u_int unit_testing; @@ -74,25 +73,24 @@ u_int nheads = 1; u_int nsecs = 1; u_int secsz = 512; u_int blksz = 0; -uint32_t active_partition = 0; static void print_formats(int usage) { - struct mkimg_format *f; + struct mkimg_format *f, **f_iter; const char *sep; if (usage) { fprintf(stderr, " formats:\n"); - f = NULL; - while ((f = format_iterate(f)) != NULL) { + SET_FOREACH(f_iter, formats) { + f = *f_iter; fprintf(stderr, "\t%s\t- %s\n", f->name, f->description); } } else { sep = ""; - f = NULL; - while ((f = format_iterate(f)) != NULL) { + SET_FOREACH(f_iter, formats) { + f = *f_iter; printf("%s%s", sep, f->name); sep = " "; } @@ -103,20 +101,20 @@ print_formats(int usage) static void print_schemes(int usage) { - struct mkimg_scheme *s; + struct mkimg_scheme *s, **s_iter; const char *sep; if (usage) { fprintf(stderr, " schemes:\n"); - s = NULL; - while ((s = scheme_iterate(s)) != NULL) { + SET_FOREACH(s_iter, schemes) { + s = *s_iter; fprintf(stderr, "\t%s\t- %s\n", s->name, s->description); } } else { sep = ""; - s = NULL; - while ((s = scheme_iterate(s)) != NULL) { + SET_FOREACH(s_iter, schemes) { + s = *s_iter; printf("%s%s", sep, s->name); sep = " "; } @@ -150,10 +148,8 @@ usage(const char *why) fprintf(stderr, "\t--schemes\t- list partition schemes\n"); fprintf(stderr, "\t--version\t- show version information\n"); fputc('\n', stderr); - fprintf(stderr, "\t-a \t- mark num'th partion as active\n"); fprintf(stderr, "\t-b \t- file containing boot code\n"); - fprintf(stderr, "\t-c \t- minimum capacity (in bytes) of the disk\n"); - fprintf(stderr, "\t-C \t- maximum capacity (in bytes) of the disk\n"); + fprintf(stderr, "\t-c \t- capacity (in bytes) of the disk\n"); fprintf(stderr, "\t-f \n"); fprintf(stderr, "\t-o \t- file to write image into\n"); fprintf(stderr, "\t-p \n"); @@ -306,7 +302,7 @@ parse_part(const char *spec) } part->index = nparts; - TAILQ_INSERT_TAIL(&partlist, part, link); + STAILQ_INSERT_TAIL(&partlist, part, link); nparts++; return (0); @@ -380,20 +376,31 @@ mkimg_chs(lba_t lba, u_int maxcyl, u_int *cylp, u_int *secp = sec; } +void +mkimg_uuid(struct uuid *uuid) +{ + static uint8_t gen[sizeof(struct uuid)]; + u_int i; + + if (!unit_testing) { + uuidgen(uuid, 1); + return; + } + + for (i = 0; i < sizeof(gen); i++) + gen[i]++; + memcpy(uuid, gen, sizeof(uuid_t)); +} + static int capacity_resize(lba_t end) { - lba_t min_capsz, max_capsz; + lba_t capsz; - min_capsz = (min_capacity + secsz - 1) / secsz; - max_capsz = (max_capacity + secsz - 1) / secsz; - - if (max_capsz != 0 && end > max_capsz) - return (ENOSPC); - if (end >= min_capsz) + capsz = (capacity + secsz - 1) / secsz; + if (end >= capsz) return (0); - - return (image_set_size(min_capsz)); + return (image_set_size(capsz)); } static void @@ -406,14 +413,14 @@ mkimg(void) int error, fd; /* First check partition information */ - TAILQ_FOREACH(part, &partlist, link) { + STAILQ_FOREACH(part, &partlist, link) { error = scheme_check_part(part); if (error) errc(EX_DATAERR, error, "partition %d", part->index+1); } block = scheme_metadata(SCHEME_META_IMG_START, 0); - TAILQ_FOREACH(part, &partlist, link) { + STAILQ_FOREACH(part, &partlist, link) { block = scheme_metadata(SCHEME_META_PART_BEFORE, block); if (verbose) fprintf(stderr, "partition %d: starting block %llu " @@ -480,14 +487,9 @@ main(int argc, char *argv[]) bcfd = -1; outfd = 1; /* Write to stdout by default */ - while ((c = getopt_long(argc, argv, "a:b:c:C:f:o:p:s:vyH:P:S:T:", + while ((c = getopt_long(argc, argv, "b:c:f:o:p:s:vyH:P:S:T:", longopts, NULL)) != -1) { switch (c) { - case 'a': /* ACTIVE PARTITION, if supported */ - error = parse_uint32(&active_partition, 1, 100, optarg); - if (error) - errc(EX_DATAERR, error, "Partition ordinal"); - break; case 'b': /* BOOT CODE */ if (bcfd != -1) usage("multiple bootcode given"); @@ -495,16 +497,11 @@ main(int argc, char *argv[]) if (bcfd == -1) err(EX_UNAVAILABLE, "%s", optarg); break; - case 'c': /* MINIMUM CAPACITY */ - error = parse_uint64(&min_capacity, 1, INT64_MAX, optarg); + case 'c': /* CAPACITY */ + error = parse_uint64(&capacity, 1, OFF_MAX, optarg); if (error) - errc(EX_DATAERR, error, "minimum capacity in bytes"); + errc(EX_DATAERR, error, "capacity in bytes"); break; - case 'C': /* MAXIMUM CAPACITY */ - error = parse_uint64(&max_capacity, 1, INT64_MAX, optarg); - if (error) - errc(EX_DATAERR, error, "maximum capacity in bytes"); - break; case 'f': /* OUTPUT FORMAT */ if (format_selected() != NULL) usage("multiple formats given"); @@ -574,12 +571,6 @@ main(int argc, char *argv[]) print_version(); exit(EX_OK); /*NOTREACHED*/ - case LONGOPT_CAPACITY: - error = parse_uint64(&min_capacity, 1, INT64_MAX, optarg); - if (error) - errc(EX_DATAERR, error, "capacity in bytes"); - max_capacity = min_capacity; - break; default: usage("unknown option"); } @@ -589,10 +580,8 @@ main(int argc, char *argv[]) usage("trailing arguments"); if (scheme_selected() == NULL && nparts > 0) usage("no scheme"); - if (nparts == 0 && min_capacity == 0) + if (nparts == 0 && capacity == 0) usage("no partitions"); - if (max_capacity != 0 && min_capacity > max_capacity) - usage("minimum capacity cannot be larger than the maximum one"); if (secsz > blksz) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Wed Feb 7 18:17:12 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EB007F1A4C2; Wed, 7 Feb 2018 18:17:11 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D55047644F; Wed, 7 Feb 2018 18:17:10 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D005625A9; Wed, 7 Feb 2018 18:17:10 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w17IHAQp039622; Wed, 7 Feb 2018 18:17:10 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w17IHAXA039620; Wed, 7 Feb 2018 18:17:10 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201802071817.w17IHAXA039620@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 7 Feb 2018 18:17:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328980 - stable/11/sys/compat/linuxkpi/common/src X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/compat/linuxkpi/common/src X-SVN-Commit-Revision: 328980 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 18:17:12 -0000 Author: hselasky Date: Wed Feb 7 18:17:10 2018 New Revision: 328980 URL: https://svnweb.freebsd.org/changeset/base/328980 Log: MFC r328436 and r328731: Decouple Linux files from the belonging character device right after open in the LinuxKPI. This is done by calling finit() just before returning a magic value of ENXIO in the "linux_dev_fdopen" function. The Linux file structure should mimic the BSD file structure as much as possible. This patch decouples the Linux file structure from the belonging character device right after the "linux_dev_fdopen" function has returned. This fixes an issue which allows a Linux file handle to exist after a character device has been destroyed and removed from the directory index of /dev. Only when the reference count of the BSD file handle reaches zero, the Linux file handle is destroyed. This fixes use-after-free issues related to accessing the Linux file structure after the character device has been destroyed. While at it add a missing NULL check for non-present file operation. Calling a NULL pointer will result in a segmentation fault. Fix some recent regressions after r328436 in the LinuxKPI: 1) The OPW() function macro should have the same return type like the function it executes. 2) The DEVFS I/O-limit should be enforced for all character device reads and writes. 3) The character device file handle should be passable, same as for DEVFS based file handles. Reviewed by: kib @ Reported by: jbeich @ Sponsored by: Mellanox Technologies Modified: stable/11/sys/compat/linuxkpi/common/src/linux_compat.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/src/linux_compat.c ============================================================================== --- stable/11/sys/compat/linuxkpi/common/src/linux_compat.c Wed Feb 7 17:09:12 2018 (r328979) +++ stable/11/sys/compat/linuxkpi/common/src/linux_compat.c Wed Feb 7 18:17:10 2018 (r328980) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -391,18 +392,6 @@ kobject_init_and_add(struct kobject *kobj, const struc } static void -linux_file_dtor(void *cdp) -{ - struct linux_file *filp; - - linux_set_current(curthread); - filp = cdp; - filp->f_op->release(filp->f_vnode, filp); - vdrop(filp->f_vnode); - kfree(filp); -} - -static void linux_kq_lock(void *arg) { spinlock_t *s = arg; @@ -438,7 +427,7 @@ linux_kq_lock_unowned(void *arg) } static void -linux_dev_kqfilter_poll(struct linux_file *, int); +linux_file_kqfilter_poll(struct linux_file *, int); struct linux_file * linux_file_alloc(void) @@ -678,24 +667,31 @@ static struct cdev_pager_ops linux_cdev_pager_ops[2] = }, }; +#define OPW(fp,td,code) ({ \ + struct file *__fpop; \ + __typeof(code) __retval; \ + \ + __fpop = (td)->td_fpop; \ + (td)->td_fpop = (fp); \ + __retval = (code); \ + (td)->td_fpop = __fpop; \ + __retval; \ +}) + static int -linux_dev_open(struct cdev *dev, int oflags, int devtype, struct thread *td) +linux_dev_fdopen(struct cdev *dev, int fflags, struct thread *td, struct file *file) { struct linux_cdev *ldev; struct linux_file *filp; - struct file *file; int error; - file = td->td_fpop; ldev = dev->si_drv1; - if (ldev == NULL) - return (ENODEV); filp = linux_file_alloc(); filp->f_dentry = &filp->f_dentry_store; filp->f_op = ldev->ops; + filp->f_mode = file->f_flag; filp->f_flags = file->f_flag; - vhold(file->f_vnode); filp->f_vnode = file->f_vnode; filp->_file = file; @@ -704,35 +700,17 @@ linux_dev_open(struct cdev *dev, int oflags, int devty if (filp->f_op->open) { error = -filp->f_op->open(file->f_vnode, filp); if (error) { - vdrop(filp->f_vnode); kfree(filp); - goto done; + return (error); } } - error = devfs_set_cdevpriv(filp, linux_file_dtor); - if (error) { - filp->f_op->release(file->f_vnode, filp); - vdrop(filp->f_vnode); - kfree(filp); - } -done: - return (error); -} -static int -linux_dev_close(struct cdev *dev, int fflag, int devtype, struct thread *td) -{ - struct linux_file *filp; - struct file *file; - int error; + /* hold on to the vnode - used for fstat() */ + vhold(filp->f_vnode); - file = td->td_fpop; - if ((error = devfs_get_cdevpriv((void **)&filp)) != 0) - return (error); - filp->f_flags = file->f_flag; - devfs_clear_cdevpriv(); - - return (0); + /* release the file from devfs */ + finit(file, filp->f_mode, DTYPE_DEV, filp, &linuxfileops); + return (ENXIO); } #define LINUX_IOCTL_MIN_PTR 0x10000UL @@ -850,24 +828,12 @@ linux_access_ok(int rw, const void *uaddr, size_t len) } static int -linux_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, - struct thread *td) +linux_file_ioctl_sub(struct file *fp, struct linux_file *filp, + u_long cmd, caddr_t data, struct thread *td) { - struct linux_file *filp; - struct file *file; unsigned size; int error; - file = td->td_fpop; - if ((error = devfs_get_cdevpriv((void **)&filp)) != 0) - return (error); - filp->f_flags = file->f_flag; - - /* the LinuxKPI supports blocking and non-blocking I/O */ - if (cmd == FIONBIO || cmd == FIOASYNC) - return (0); - - linux_set_current(td); size = IOCPARM_LEN(cmd); /* refer to logic in sys_ioctl() */ if (size > 0) { @@ -888,17 +854,17 @@ linux_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t if (td->td_proc->p_elf_machine == EM_386) { /* try the compat IOCTL handler first */ if (filp->f_op->compat_ioctl != NULL) - error = -filp->f_op->compat_ioctl(filp, cmd, (u_long)data); + error = -OPW(fp, td, filp->f_op->compat_ioctl(filp, cmd, (u_long)data)); else error = ENOTTY; /* fallback to the regular IOCTL handler, if any */ if (error == ENOTTY && filp->f_op->unlocked_ioctl != NULL) - error = -filp->f_op->unlocked_ioctl(filp, cmd, (u_long)data); + error = -OPW(fp, td, filp->f_op->unlocked_ioctl(filp, cmd, (u_long)data)); } else #endif if (filp->f_op->unlocked_ioctl != NULL) - error = -filp->f_op->unlocked_ioctl(filp, cmd, (u_long)data); + error = -OPW(fp, td, filp->f_op->unlocked_ioctl(filp, cmd, (u_long)data)); else error = ENOTTY; if (size > 0) { @@ -908,118 +874,15 @@ linux_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t if (error == EWOULDBLOCK) { /* update kqfilter status, if any */ - linux_dev_kqfilter_poll(filp, + linux_file_kqfilter_poll(filp, LINUX_KQ_FLAG_HAS_READ | LINUX_KQ_FLAG_HAS_WRITE); } else if (error == ERESTARTSYS) error = ERESTART; return (error); } -static int -linux_dev_read(struct cdev *dev, struct uio *uio, int ioflag) -{ - struct linux_file *filp; - struct thread *td; - struct file *file; - ssize_t bytes; - int error; - - td = curthread; - file = td->td_fpop; - if ((error = devfs_get_cdevpriv((void **)&filp)) != 0) - return (error); - filp->f_flags = file->f_flag; - /* XXX no support for I/O vectors currently */ - if (uio->uio_iovcnt != 1) - return (EOPNOTSUPP); - linux_set_current(td); - if (filp->f_op->read) { - bytes = filp->f_op->read(filp, uio->uio_iov->iov_base, - uio->uio_iov->iov_len, &uio->uio_offset); - if (bytes >= 0) { - uio->uio_iov->iov_base = - ((uint8_t *)uio->uio_iov->iov_base) + bytes; - uio->uio_iov->iov_len -= bytes; - uio->uio_resid -= bytes; - } else { - error = -bytes; - if (error == ERESTARTSYS) - error = ERESTART; - } - } else - error = ENXIO; - - /* update kqfilter status, if any */ - linux_dev_kqfilter_poll(filp, LINUX_KQ_FLAG_HAS_READ); - - return (error); -} - -static int -linux_dev_write(struct cdev *dev, struct uio *uio, int ioflag) -{ - struct linux_file *filp; - struct thread *td; - struct file *file; - ssize_t bytes; - int error; - - td = curthread; - file = td->td_fpop; - if ((error = devfs_get_cdevpriv((void **)&filp)) != 0) - return (error); - filp->f_flags = file->f_flag; - /* XXX no support for I/O vectors currently */ - if (uio->uio_iovcnt != 1) - return (EOPNOTSUPP); - linux_set_current(td); - if (filp->f_op->write) { - bytes = filp->f_op->write(filp, uio->uio_iov->iov_base, - uio->uio_iov->iov_len, &uio->uio_offset); - if (bytes >= 0) { - uio->uio_iov->iov_base = - ((uint8_t *)uio->uio_iov->iov_base) + bytes; - uio->uio_iov->iov_len -= bytes; - uio->uio_resid -= bytes; - } else { - error = -bytes; - if (error == ERESTARTSYS) - error = ERESTART; - } - } else - error = ENXIO; - - /* update kqfilter status, if any */ - linux_dev_kqfilter_poll(filp, LINUX_KQ_FLAG_HAS_WRITE); - - return (error); -} - #define LINUX_POLL_TABLE_NORMAL ((poll_table *)1) -static int -linux_dev_poll(struct cdev *dev, int events, struct thread *td) -{ - struct linux_file *filp; - struct file *file; - int revents; - - if (devfs_get_cdevpriv((void **)&filp) != 0) - goto error; - - file = td->td_fpop; - filp->f_flags = file->f_flag; - linux_set_current(td); - if (filp->f_op->poll != NULL) - revents = filp->f_op->poll(filp, LINUX_POLL_TABLE_NORMAL) & events; - else - revents = 0; - - return (revents); -error: - return (events & (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM)); -} - /* * This function atomically updates the poll wakeup state and returns * the previous state at the time of update. @@ -1127,7 +990,7 @@ linux_poll_wakeup(struct linux_file *filp) } static void -linux_dev_kqfilter_detach(struct knote *kn) +linux_file_kqfilter_detach(struct knote *kn) { struct linux_file *filp = kn->kn_hook; @@ -1137,7 +1000,7 @@ linux_dev_kqfilter_detach(struct knote *kn) } static int -linux_dev_kqfilter_read_event(struct knote *kn, long hint) +linux_file_kqfilter_read_event(struct knote *kn, long hint) { struct linux_file *filp = kn->kn_hook; @@ -1147,7 +1010,7 @@ linux_dev_kqfilter_read_event(struct knote *kn, long h } static int -linux_dev_kqfilter_write_event(struct knote *kn, long hint) +linux_file_kqfilter_write_event(struct knote *kn, long hint) { struct linux_file *filp = kn->kn_hook; @@ -1158,24 +1021,26 @@ linux_dev_kqfilter_write_event(struct knote *kn, long static struct filterops linux_dev_kqfiltops_read = { .f_isfd = 1, - .f_detach = linux_dev_kqfilter_detach, - .f_event = linux_dev_kqfilter_read_event, + .f_detach = linux_file_kqfilter_detach, + .f_event = linux_file_kqfilter_read_event, }; static struct filterops linux_dev_kqfiltops_write = { .f_isfd = 1, - .f_detach = linux_dev_kqfilter_detach, - .f_event = linux_dev_kqfilter_write_event, + .f_detach = linux_file_kqfilter_detach, + .f_event = linux_file_kqfilter_write_event, }; static void -linux_dev_kqfilter_poll(struct linux_file *filp, int kqflags) +linux_file_kqfilter_poll(struct linux_file *filp, int kqflags) { int temp; if (filp->f_kqflags & kqflags) { + struct thread *td = curthread; + /* get the latest polling state */ - temp = filp->f_op->poll(filp, NULL); + temp = OPW(filp->_file, td, filp->f_op->poll(filp, NULL)); spin_lock(&filp->f_kqlock); /* clear kqflags */ @@ -1196,17 +1061,14 @@ linux_dev_kqfilter_poll(struct linux_file *filp, int k } static int -linux_dev_kqfilter(struct cdev *dev, struct knote *kn) +linux_file_kqfilter(struct file *file, struct knote *kn) { struct linux_file *filp; - struct file *file; struct thread *td; int error; td = curthread; - file = td->td_fpop; - if ((error = devfs_get_cdevpriv((void **)&filp)) != 0) - return (error); + filp = (struct linux_file *)file->f_data; filp->f_flags = file->f_flag; if (filp->f_op->poll == NULL) return (EINVAL); @@ -1218,12 +1080,14 @@ linux_dev_kqfilter(struct cdev *dev, struct knote *kn) kn->kn_fop = &linux_dev_kqfiltops_read; kn->kn_hook = filp; knlist_add(&filp->f_selinfo.si_note, kn, 1); + error = 0; break; case EVFILT_WRITE: filp->f_kqflags |= LINUX_KQ_FLAG_HAS_WRITE; kn->kn_fop = &linux_dev_kqfiltops_write; kn->kn_hook = filp; knlist_add(&filp->f_selinfo.si_note, kn, 1); + error = 0; break; default: error = EINVAL; @@ -1235,32 +1099,28 @@ linux_dev_kqfilter(struct cdev *dev, struct knote *kn) linux_set_current(td); /* update kqfilter status, if any */ - linux_dev_kqfilter_poll(filp, + linux_file_kqfilter_poll(filp, LINUX_KQ_FLAG_HAS_READ | LINUX_KQ_FLAG_HAS_WRITE); } return (error); } static int -linux_dev_mmap_single(struct cdev *dev, vm_ooffset_t *offset, - vm_size_t size, struct vm_object **object, int nprot) +linux_file_mmap_single(struct file *fp, vm_ooffset_t *offset, + vm_size_t size, struct vm_object **object, int nprot, + struct thread *td) { struct vm_area_struct *vmap; struct mm_struct *mm; struct linux_file *filp; - struct thread *td; - struct file *file; vm_memattr_t attr; int error; - td = curthread; - file = td->td_fpop; - if ((error = devfs_get_cdevpriv((void **)&filp)) != 0) - return (error); - filp->f_flags = file->f_flag; + filp = (struct linux_file *)fp->f_data; + filp->f_flags = fp->f_flag; if (filp->f_op->mmap == NULL) - return (ENODEV); + return (EOPNOTSUPP); linux_set_current(td); @@ -1288,7 +1148,7 @@ linux_dev_mmap_single(struct cdev *dev, vm_ooffset_t * if (unlikely(down_write_killable(&vmap->vm_mm->mmap_sem))) { error = EINTR; } else { - error = -filp->f_op->mmap(filp, vmap); + error = -OPW(fp, td, filp->f_op->mmap(filp, vmap)); up_write(&vmap->vm_mm->mmap_sem); } @@ -1351,11 +1211,11 @@ linux_dev_mmap_single(struct cdev *dev, vm_ooffset_t * if (vm_no_fault) { *object = cdev_pager_allocate(vm_private_data, OBJT_DEVICE, &linux_cdev_pager_ops[1], size, nprot, *offset, - curthread->td_ucred); + td->td_ucred); } else { *object = cdev_pager_allocate(vm_private_data, OBJT_MGTDEVICE, &linux_cdev_pager_ops[0], size, nprot, *offset, - curthread->td_ucred); + td->td_ucred); } /* check if allocating the VM object failed */ @@ -1376,7 +1236,7 @@ linux_dev_mmap_single(struct cdev *dev, vm_ooffset_t * (vm_paddr_t)vmap->vm_pfn << PAGE_SHIFT, vmap->vm_len); *object = vm_pager_allocate(OBJT_SG, sg, vmap->vm_len, - nprot, 0, curthread->td_ucred); + nprot, 0, td->td_ucred); linux_cdev_handle_free(vmap); @@ -1397,15 +1257,7 @@ linux_dev_mmap_single(struct cdev *dev, vm_ooffset_t * struct cdevsw linuxcdevsw = { .d_version = D_VERSION, - .d_flags = D_TRACKCLOSE, - .d_open = linux_dev_open, - .d_close = linux_dev_close, - .d_read = linux_dev_read, - .d_write = linux_dev_write, - .d_ioctl = linux_dev_ioctl, - .d_mmap_single = linux_dev_mmap_single, - .d_poll = linux_dev_poll, - .d_kqfilter = linux_dev_kqfilter, + .d_fdopen = linux_dev_fdopen, .d_name = "lkpidev", }; @@ -1423,24 +1275,71 @@ linux_file_read(struct file *file, struct uio *uio, st /* XXX no support for I/O vectors currently */ if (uio->uio_iovcnt != 1) return (EOPNOTSUPP); + if (uio->uio_resid > DEVFS_IOSIZE_MAX) + return (EINVAL); linux_set_current(td); if (filp->f_op->read) { - bytes = filp->f_op->read(filp, uio->uio_iov->iov_base, - uio->uio_iov->iov_len, &uio->uio_offset); + bytes = OPW(file, td, filp->f_op->read(filp, uio->uio_iov->iov_base, + uio->uio_iov->iov_len, &uio->uio_offset)); if (bytes >= 0) { uio->uio_iov->iov_base = ((uint8_t *)uio->uio_iov->iov_base) + bytes; uio->uio_iov->iov_len -= bytes; uio->uio_resid -= bytes; - } else + } else { error = -bytes; + if (error == ERESTARTSYS) + error = ERESTART; + } } else error = ENXIO; + /* update kqfilter status, if any */ + linux_file_kqfilter_poll(filp, LINUX_KQ_FLAG_HAS_READ); + return (error); } static int +linux_file_write(struct file *file, struct uio *uio, struct ucred *active_cred, + int flags, struct thread *td) +{ + struct linux_file *filp; + ssize_t bytes; + int error; + + error = 0; + filp = (struct linux_file *)file->f_data; + filp->f_flags = file->f_flag; + /* XXX no support for I/O vectors currently */ + if (uio->uio_iovcnt != 1) + return (EOPNOTSUPP); + if (uio->uio_resid > DEVFS_IOSIZE_MAX) + return (EINVAL); + linux_set_current(td); + if (filp->f_op->write) { + bytes = OPW(file, td, filp->f_op->write(filp, uio->uio_iov->iov_base, + uio->uio_iov->iov_len, &uio->uio_offset)); + if (bytes >= 0) { + uio->uio_iov->iov_base = + ((uint8_t *)uio->uio_iov->iov_base) + bytes; + uio->uio_iov->iov_len -= bytes; + uio->uio_resid -= bytes; + } else { + error = -bytes; + if (error == ERESTARTSYS) + error = ERESTART; + } + } else + error = ENXIO; + + /* update kqfilter status, if any */ + linux_file_kqfilter_poll(filp, LINUX_KQ_FLAG_HAS_WRITE); + + return (error); +} + +static int linux_file_poll(struct file *file, int events, struct ucred *active_cred, struct thread *td) { @@ -1451,7 +1350,7 @@ linux_file_poll(struct file *file, int events, struct filp->f_flags = file->f_flag; linux_set_current(td); if (filp->f_op->poll != NULL) - revents = filp->f_op->poll(filp, LINUX_POLL_TABLE_NORMAL) & events; + revents = OPW(file, td, filp->f_op->poll(filp, LINUX_POLL_TABLE_NORMAL)) & events; else revents = 0; @@ -1465,11 +1364,16 @@ linux_file_close(struct file *file, struct thread *td) int error; filp = (struct linux_file *)file->f_data; + + KASSERT(file_count(filp) == 0, ("File refcount(%d) is not zero", file_count(filp))); + filp->f_flags = file->f_flag; linux_set_current(td); linux_poll_wait_dequeue(filp); - error = -filp->f_op->release(NULL, filp); + error = -OPW(file, td, filp->f_op->release(filp->f_vnode, filp)); funsetown(&filp->f_sigio); + if (filp->f_vnode != NULL) + vdrop(filp->f_vnode); kfree(filp); return (error); @@ -1493,30 +1397,128 @@ linux_file_ioctl(struct file *fp, u_long cmd, void *da case FIOASYNC: if (filp->f_op->fasync == NULL) break; - error = filp->f_op->fasync(0, filp, fp->f_flag & FASYNC); + error = -OPW(fp, td, filp->f_op->fasync(0, filp, fp->f_flag & FASYNC)); break; case FIOSETOWN: error = fsetown(*(int *)data, &filp->f_sigio); - if (error == 0) - error = filp->f_op->fasync(0, filp, - fp->f_flag & FASYNC); + if (error == 0) { + if (filp->f_op->fasync == NULL) + break; + error = -OPW(fp, td, filp->f_op->fasync(0, filp, + fp->f_flag & FASYNC)); + } break; case FIOGETOWN: *(int *)data = fgetown(&filp->f_sigio); break; default: - error = ENOTTY; + error = linux_file_ioctl_sub(fp, filp, cmd, data, td); break; } return (error); } static int +linux_file_mmap_sub(struct thread *td, vm_size_t objsize, vm_prot_t prot, + vm_prot_t *maxprotp, int *flagsp, struct file *fp, + vm_ooffset_t *foff, vm_object_t *objp) +{ + /* + * Character devices do not provide private mappings + * of any kind: + */ + if ((*maxprotp & VM_PROT_WRITE) == 0 && + (prot & VM_PROT_WRITE) != 0) + return (EACCES); + if ((*flagsp & (MAP_PRIVATE | MAP_COPY)) != 0) + return (EINVAL); + + return (linux_file_mmap_single(fp, foff, objsize, objp, (int)prot, td)); +} + +static int +linux_file_mmap(struct file *fp, vm_map_t map, vm_offset_t *addr, vm_size_t size, + vm_prot_t prot, vm_prot_t cap_maxprot, int flags, vm_ooffset_t foff, + struct thread *td) +{ + struct linux_file *filp; + struct mount *mp; + struct vnode *vp; + vm_object_t object; + vm_prot_t maxprot; + int error; + + filp = (struct linux_file *)fp->f_data; + + vp = filp->f_vnode; + if (vp == NULL) + return (EOPNOTSUPP); + + /* + * Ensure that file and memory protections are + * compatible. + */ + mp = vp->v_mount; + if (mp != NULL && (mp->mnt_flag & MNT_NOEXEC) != 0) { + maxprot = VM_PROT_NONE; + if ((prot & VM_PROT_EXECUTE) != 0) + return (EACCES); + } else + maxprot = VM_PROT_EXECUTE; + if ((fp->f_flag & FREAD) != 0) + maxprot |= VM_PROT_READ; + else if ((prot & VM_PROT_READ) != 0) + return (EACCES); + + /* + * If we are sharing potential changes via MAP_SHARED and we + * are trying to get write permission although we opened it + * without asking for it, bail out. + * + * Note that most character devices always share mappings. + * + * Rely on linux_file_mmap_sub() to fail invalid MAP_PRIVATE + * requests rather than doing it here. + */ + if ((flags & MAP_SHARED) != 0) { + if ((fp->f_flag & FWRITE) != 0) + maxprot |= VM_PROT_WRITE; + else if ((prot & VM_PROT_WRITE) != 0) + return (EACCES); + } + maxprot &= cap_maxprot; + + error = linux_file_mmap_sub(td, size, prot, &maxprot, &flags, fp, &foff, + &object); + if (error != 0) + return (error); + + error = vm_mmap_object(map, addr, size, prot, maxprot, flags, object, + foff, FALSE, td); + if (error != 0) + vm_object_deallocate(object); + return (error); +} + +static int linux_file_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td) { + struct linux_file *filp; + struct vnode *vp; + int error; - return (EOPNOTSUPP); + filp = (struct linux_file *)fp->f_data; + if (filp->f_vnode == NULL) + return (EOPNOTSUPP); + + vp = filp->f_vnode; + + vn_lock(vp, LK_SHARED | LK_RETRY); + error = vn_stat(vp, sb, td->td_ucred, NOCRED, td); + VOP_UNLOCK(vp, 0); + + return (error); } static int @@ -1544,17 +1546,19 @@ linux_iminor(struct inode *inode) struct fileops linuxfileops = { .fo_read = linux_file_read, - .fo_write = invfo_rdwr, + .fo_write = linux_file_write, .fo_truncate = invfo_truncate, - .fo_kqfilter = invfo_kqfilter, + .fo_kqfilter = linux_file_kqfilter, .fo_stat = linux_file_stat, .fo_fill_kinfo = linux_file_fill_kinfo, .fo_poll = linux_file_poll, .fo_close = linux_file_close, .fo_ioctl = linux_file_ioctl, + .fo_mmap = linux_file_mmap, .fo_chmod = invfo_chmod, .fo_chown = invfo_chown, .fo_sendfile = invfo_sendfile, + .fo_flags = DFLAG_PASSABLE, }; /* From owner-svn-src-stable-11@freebsd.org Wed Feb 7 18:18:33 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B2813F1A702; Wed, 7 Feb 2018 18:18:33 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 64C9E7662D; Wed, 7 Feb 2018 18:18:33 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5FC1125AA; Wed, 7 Feb 2018 18:18:33 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w17IIXaj039721; Wed, 7 Feb 2018 18:18:33 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w17IIXCi039720; Wed, 7 Feb 2018 18:18:33 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201802071818.w17IIXCi039720@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 7 Feb 2018 18:18:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328981 - stable/11/sys/compat/linuxkpi/common/src X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/compat/linuxkpi/common/src X-SVN-Commit-Revision: 328981 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 18:18:33 -0000 Author: hselasky Date: Wed Feb 7 18:18:33 2018 New Revision: 328981 URL: https://svnweb.freebsd.org/changeset/base/328981 Log: MFC r328694: Make sure the LinuxKPI's internal ERESTARTSYS error code gets translated into ERESTART for mmap and page fault calls aswell. Sponsored by: Mellanox Technologies Modified: stable/11/sys/compat/linuxkpi/common/src/linux_compat.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/src/linux_compat.c ============================================================================== --- stable/11/sys/compat/linuxkpi/common/src/linux_compat.c Wed Feb 7 18:17:10 2018 (r328980) +++ stable/11/sys/compat/linuxkpi/common/src/linux_compat.c Wed Feb 7 18:18:33 2018 (r328981) @@ -1149,6 +1149,8 @@ linux_file_mmap_single(struct file *fp, vm_ooffset_t * error = EINTR; } else { error = -OPW(fp, td, filp->f_op->mmap(filp, vmap)); + if (error == ERESTARTSYS) + error = ERESTART; up_write(&vmap->vm_mm->mmap_sem); } From owner-svn-src-stable-11@freebsd.org Wed Feb 7 19:45:25 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8816F20986; Wed, 7 Feb 2018 19:45:24 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7B4CA7B6E2; Wed, 7 Feb 2018 19:45:24 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5B347348D; Wed, 7 Feb 2018 19:45:24 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w17JjOFY086218; Wed, 7 Feb 2018 19:45:24 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w17JjORS086216; Wed, 7 Feb 2018 19:45:24 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802071945.w17JjORS086216@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 7 Feb 2018 19:45:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328991 - stable/11/tools/boot X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/tools/boot X-SVN-Commit-Revision: 328991 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 19:45:25 -0000 Author: kevans Date: Wed Feb 7 19:45:23 2018 New Revision: 328991 URL: https://svnweb.freebsd.org/changeset/base/328991 Log: MFC r326873,r326874,r326875,r326883,r326884,r326885,r326954,r328865 r326873: Script that knows how to put boot blocks onto a device. r326874: Script to generate minimal boot images for each of the 24 supported r326875: Add missing of=/dev/${dev}s${s} when installing zfsboot. r326883: For now, make the gpart commands verbose r326884: Be a little verbose and list the loader files we're putting on r326885: Use -h -D in preference to -D so that the serial port gets the interactive console. r326954: Support more images (but still no geli) r328865: Flesh out the creation of sparc64 UFS images. Added: stable/11/tools/boot/install-boot.sh - copied, changed from r326873, head/tools/boot/install-boot.sh stable/11/tools/boot/rootgen.sh - copied, changed from r326874, head/tools/boot/rootgen.sh Modified: Directory Properties: stable/11/ (props changed) Copied and modified: stable/11/tools/boot/install-boot.sh (from r326873, head/tools/boot/install-boot.sh) ============================================================================== --- head/tools/boot/install-boot.sh Fri Dec 15 06:34:11 2017 (r326873, copy source) +++ stable/11/tools/boot/install-boot.sh Wed Feb 7 19:45:23 2018 (r328991) @@ -15,6 +15,11 @@ die() { exit 1 } +doit() { + echo $* + eval $* +} + find-part() { dev=$1 part=$2 @@ -30,7 +35,7 @@ boot_nogeli_gpt_zfs_legacy() { if [ -z "$idx" ] ; then die "No freebsd-boot partition found" fi - gpart bootcode -b ${gpt0} -p ${gpt2} -i $idx $dev + doit gpart bootcode -b ${gpt0} -p ${gptzfs2} -i $idx $dev exit 0 } @@ -42,7 +47,7 @@ boot_nogeli_gpt_ufs_legacy() { if [ -z "$idx" ] ; then die "No freebsd-boot partition found" fi - gpart bootcode -b ${gpt0} -p ${gpt2} -i $idx $dev + doit gpart bootcode -b ${gpt0} -p ${gpt2} -i $idx $dev exit 0 } @@ -58,9 +63,9 @@ boot_nogeli_mbr_zfs_legacy() { # search to find the freebsd-zfs partition within the slice # Or just assume it is 'a' because it has to be since it fails otherwise dd if=${dst}/boot/zfsboot of=/tmp/zfsboot1 count=1 - gpart bootcode -b /tmp/zfsboo1 ${dev}s${s} # Put boot1 into the start of part - sysctl kern.geom.debugflags=0x10 - dd if=${dst}/boot/zfsboot iseek=1 seek=1024 # Put boot2 into ZFS boot slot + doit gpart bootcode -b /tmp/zfsboo1 ${dev}s${s} # Put boot1 into the start of part + sysctl kern.geom.debugflags=0x10 # Put boot2 into ZFS boot slot + doit dd if=${dst}/boot/zfsboot of=/dev/${dev}s${s} iseek=1 seek=1024 sysctl kern.geom.debugflags=0x0 exit 0 @@ -70,15 +75,25 @@ boot_nogeli_mbr_ufs_legacy() { dev=$1 dst=$2 - gpart bootcode -b ${mbr0} ${dev} + doit gpart bootcode -b ${mbr0} ${dev} s=$(findpart $dev "freebsd-ufs") if [ -z "$s" ] ; then - die "No freebsd-zfs slice found" + die "No freebsd-ufs slice found" fi - gpart bootcode -p ${mbr2} ${dev}s${s} + doit gpart bootcode -p ${mbr2} ${dev}s${s} exit 0 } +boot_nogeli_vtoc8_ufs_ofw() { + dev=$1 + dst=$2 + + # For non-native builds, ensure that geom_part(4) supports VTOC8. + kldload geom_part_vtoc8.ko + doit gpart bootcode -p ${vtoc8} ${dev} + exit 0 +} + DESTDIR=/ # Note: we really don't support geli boot in this script yet. @@ -122,6 +137,9 @@ gptzfs2=${DESTDIR}/boot/gptzfsboot # For MBR, we have lots of choices, but select boot0 mbr0=${DESTDIR}/boot/boot0 mbr2=${DESTDIR}/boot/boot + +# VTOC8 +vtoc8=${DESTDIR}/boot/boot1 # sanity check here Copied and modified: stable/11/tools/boot/rootgen.sh (from r326874, head/tools/boot/rootgen.sh) ============================================================================== --- head/tools/boot/rootgen.sh Fri Dec 15 06:34:27 2017 (r326874, copy source) +++ stable/11/tools/boot/rootgen.sh Wed Feb 7 19:45:23 2018 (r328991) @@ -33,28 +33,41 @@ mk_nogeli_gpt_ufs_legacy() { src=$1 img=$2 - rm -f ${img} ${img}.p2 + cat > ${src}/etc/fstab < ${src}/etc/fstab < ${src}/etc/fstab < ${src}/etc/fstab < ${src}/etc/fstab < $sh +# https://wiki.freebsd.org/arm64/QEMU also has +# -device virtio-net-device,netdev=net0 +# -netdev user,id=net0 +} + +# Amd64 qemu +qemu_amd64_legacy() +{ + img=$1 + sh=$2 + + echo "qemu-system-x86_64 --drive file=${img},format=raw ${qser}" > $sh +} + +qemu_amd64_uefi() +{ + img=$1 + sh=$2 + + echo "qemu-system-x86_64 -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser}" > $sh +} + +qemu_amd64_both() +{ + img=$1 + sh=$2 + + echo "qemu-system-x86_64 --drive file=${img},format=raw ${qser}" > $sh + echo "qemu-system-x86_64 -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser}" > $sh +} + +# arm +# nothing listed? + +# i386 +qemu_i386_legacy() +{ + img=$1 + sh=$2 + + echo "qemu-system-i386 --drive file=${img},format=raw ${qser}" > $sh +} + +# Not yet supported +qemu_i386_uefi() +{ + img=$1 + sh=$2 + + echo "qemu-system-i386 -bios ~/bios/OVMF-X32.fd --drive file=${img},format=raw ${qser}" > $sh +} + +# Needs UEFI to be supported +qemu_i386_both() +{ + img=$1 + sh=$2 + + echo "qemu-system-i386 --drive file=${img},format=raw ${qser}" > $sh + echo "qemu-system-i386 -bios ~/bios/OVMF-X32.fd --drive file=${img},format=raw ${qser}" > $sh +} + +# mips +# qemu-system-mips -kernel /path/to/rootfs/boot/kernel/kernel -nographic -hda /path/to/disk.img -m 2048 + +# Powerpc -- doesn't work but maybe it would enough for testing -- needs details +# powerpc64 +# qemu-system-ppc64 -drive file=/path/to/disk.img,format=raw + +# sparc64 +# qemu-system-sparc64 -drive file=/path/to/disk.img,format=raw + # Misc variables SRCTOP=$(make -v SRCTOP) cd ${SRCTOP}/stand @@ -181,33 +314,127 @@ DESTDIR=${OBJDIR}/boot-tree rm -rf ${DESTDIR} mkdir -p ${DESTDIR}/boot/defaults mkdir -p ${DESTDIR}/boot/kernel +# XXX boot1 exists only on sparc64 +cp /boot/boot1 ${DESTDIR}/boot +cp /boot/loader ${DESTDIR}/boot cp /boot/kernel/kernel ${DESTDIR}/boot/kernel -echo -D -S115200 > ${DESTDIR}/boot.config +echo -h -D -S115200 > ${DESTDIR}/boot.config # XXX cp /boot/device.hints ${DESTDIR}/boot/device.hints # Assume we're already built make install DESTDIR=${DESTDIR} MK_MAN=no MK_INSTALL_AS_USER=yes -# Copy init, /bin/sh and minimal libraries -mkdir -p ${DESTDIR}/sbin ${DESTDIR}/bin ${DESTDIR}/lib ${DESTDIR}/libexec -for f in /sbin/init /bin/sh $(ldd /bin/sh | awk 'NF == 4 { print $3; }') /libexec/ld-elf.so.1; do +# Copy init, /bin/sh, minimal libraries and testing /etc/rc +mkdir -p ${DESTDIR}/sbin ${DESTDIR}/bin \ + ${DESTDIR}/lib ${DESTDIR}/libexec \ + ${DESTDIR}/etc ${DESTDIR}/dev +for f in /sbin/halt /sbin/init /bin/sh $(ldd /bin/sh | awk 'NF == 4 { print $3; }') /libexec/ld-elf.so.1; do cp $f ${DESTDIR}/$f done -mkdir ${DESTDIR}/dev +cat > ${DESTDIR}/etc/rc < Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 74975F20DC0; Wed, 7 Feb 2018 19:49:08 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 236257B990; Wed, 7 Feb 2018 19:49:08 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 19C2C348E; Wed, 7 Feb 2018 19:49:08 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w17Jn77p086407; Wed, 7 Feb 2018 19:49:07 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w17Jn79C086406; Wed, 7 Feb 2018 19:49:07 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802071949.w17Jn79C086406@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 7 Feb 2018 19:49:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328992 - stable/11/tools/boot X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/tools/boot X-SVN-Commit-Revision: 328992 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 19:49:08 -0000 Author: kevans Date: Wed Feb 7 19:49:07 2018 New Revision: 328992 URL: https://svnweb.freebsd.org/changeset/base/328992 Log: Fix rootgen.sh to reflect proper bootloader paths This is a direct commit to stable/11 to use sys/boot instead of stand/. It will be reverted once the move from sys/boot to stand/ gets an MFC. Modified: stable/11/tools/boot/rootgen.sh Modified: stable/11/tools/boot/rootgen.sh ============================================================================== --- stable/11/tools/boot/rootgen.sh Wed Feb 7 19:45:23 2018 (r328991) +++ stable/11/tools/boot/rootgen.sh Wed Feb 7 19:49:07 2018 (r328992) @@ -303,7 +303,7 @@ qemu_i386_both() # Misc variables SRCTOP=$(make -v SRCTOP) -cd ${SRCTOP}/stand +cd ${SRCTOP}/sys/boot OBJDIR=$(make -v .OBJDIR) IMGDIR=${OBJDIR}/boot-images mkdir -p ${IMGDIR} From owner-svn-src-stable-11@freebsd.org Thu Feb 8 00:40:57 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1F284EE8D01; Thu, 8 Feb 2018 00:40:57 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C854E87894; Thu, 8 Feb 2018 00:40:56 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C34EB67FC; Thu, 8 Feb 2018 00:40:56 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w180euH8031639; Thu, 8 Feb 2018 00:40:56 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w180eu5x031638; Thu, 8 Feb 2018 00:40:56 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201802080040.w180eu5x031638@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 8 Feb 2018 00:40:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329005 - stable/11/share/vt/keymaps X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/share/vt/keymaps X-SVN-Commit-Revision: 329005 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 00:40:57 -0000 Author: emaste Date: Thu Feb 8 00:40:56 2018 New Revision: 329005 URL: https://svnweb.freebsd.org/changeset/base/329005 Log: MFC r328412: vt: add Ctrl+/ key mapping This matches Xorg's handling of Ctrl+/ and may be useful as a tmux escape. PR: 212197 Submitted by: martin at sugioarto.com Relnotes: Yes Modified: stable/11/share/vt/keymaps/us.kbd Directory Properties: stable/11/ (props changed) Modified: stable/11/share/vt/keymaps/us.kbd ============================================================================== --- stable/11/share/vt/keymaps/us.kbd Thu Feb 8 00:14:20 2018 (r329004) +++ stable/11/share/vt/keymaps/us.kbd Thu Feb 8 00:40:56 2018 (r329005) @@ -56,7 +56,7 @@ 050 'm' 'M' cr cr 'm' 'M' cr cr C 051 ',' '<' nop nop ',' '<' nop nop O 052 '.' '>' nop nop '.' '>' nop nop O - 053 '/' '?' nop nop '/' '?' nop nop O + 053 '/' '?' 0x1f nop '/' '?' nop nop O 054 rshift rshift rshift rshift rshift rshift rshift rshift O 055 '*' '*' '*' '*' '*' '*' '*' '*' O 056 lalt lalt lalt lalt lalt lalt lalt lalt O From owner-svn-src-stable-11@freebsd.org Thu Feb 8 00:59:59 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D3399EEA2E5; Thu, 8 Feb 2018 00:59:59 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CAB6468874; Thu, 8 Feb 2018 00:59:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7D9D26B0E; Thu, 8 Feb 2018 00:59:57 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w180xu4o042782; Thu, 8 Feb 2018 00:59:56 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w180xuLN042781; Thu, 8 Feb 2018 00:59:56 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201802080059.w180xuLN042781@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 8 Feb 2018 00:59:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329008 - stable/11/tests/sys/opencrypto X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/11/tests/sys/opencrypto X-SVN-Commit-Revision: 329008 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 01:00:00 -0000 Author: jhb Date: Thu Feb 8 00:59:56 2018 New Revision: 329008 URL: https://svnweb.freebsd.org/changeset/base/329008 Log: MFC 319454: Honor the requested crid when running a test. Otherwise, the kernel is free to choose an aribtrary crypto device rather than the requested device subverting tests that force the use of a specific device. Modified: stable/11/tests/sys/opencrypto/cryptodev.py Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/opencrypto/cryptodev.py ============================================================================== --- stable/11/tests/sys/opencrypto/cryptodev.py Thu Feb 8 00:42:28 2018 (r329007) +++ stable/11/tests/sys/opencrypto/cryptodev.py Thu Feb 8 00:59:56 2018 (r329008) @@ -173,10 +173,7 @@ class Crypto: if not cipher and not mac: raise ValueError('one of cipher or mac MUST be specified.') - ses.crid = CRYPTOCAP_F_SOFTWARE | CRYPTOCAP_F_HARDWARE - #ses.crid = CRYPTOCAP_F_HARDWARE - #ses.crid = CRYPTOCAP_F_SOFTWARE - #ses.crid = 0 + ses.crid = crid #print `ses` s = array.array('B', ses.pack_hdr()) #print `s` From owner-svn-src-stable-11@freebsd.org Thu Feb 8 02:50:50 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 864ECEF2453; Thu, 8 Feb 2018 02:50:50 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 337F86DCC2; Thu, 8 Feb 2018 02:50:50 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2E4C77F86; Thu, 8 Feb 2018 02:50:50 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w182ooZ8097906; Thu, 8 Feb 2018 02:50:50 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w182olh7097879; Thu, 8 Feb 2018 02:50:47 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802080250.w182olh7097879@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 8 Feb 2018 02:50:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329011 - in stable/11: sys/boot sys/boot/common sys/boot/efi/libefi sys/boot/efi/loader sys/boot/efi/loader/arch/amd64 sys/boot/efi/loader/arch/arm sys/boot/efi/loader/arch/arm64 sys/b... X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: sys/boot sys/boot/common sys/boot/efi/libefi sys/boot/efi/loader sys/boot/efi/loader/arch/amd64 sys/boot/efi/loader/arch/arm sys/boot/efi/loader/arch/arm64 sys/boot/efi/loader/arch/i386 ... X-SVN-Commit-Revision: 329011 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 02:50:51 -0000 Author: kevans Date: Thu Feb 8 02:50:47 2018 New Revision: 329011 URL: https://svnweb.freebsd.org/changeset/base/329011 Log: MFC r307322,r307323,r307324,r307326,r307327,r307338,r307879,r307908,r307911, r307942,r307950,r307951,r307954,r307955,r308125,r308195,r308476,r308534, r308535,r308776,r308843,r310236,r310726: Loader fixes, 2016q4 r307322: Remove /boot/boot.conf, deprecated for 16 years r307323: Remove fetching of pInterp. r307324: Create a new linker set, Xficl_compile_set which contains a list of functions to call to register new forth words. r307326: In UEFI mode expose the SMBIOS anchor base address via kenv r307327: Update i386 build of loader.efi (but leave it disabled) so that we at least build it now. r307338: Create a pcibios-version environment FORTH word. r307879: Preliminary support for EFI in boot loader. r307908: Fix the build on both arm64 and when WITHOUT_FORTH is defined. r307911: Add better comment... r307942: Really make WITHOUT_FORTH (MK_FORTH==no) work. r307950: Add it (Makefile.ficl) to the right place r307951: Fix two backwards tests. r307954: Back out the move to the loader script from -N. r307955: LIBSTAND goes last, so put it last here too. r308125: In loader.efi, instead of exiting directly, try to fallback. r308195: efinet_dev_print should honor verbose option. r308476: boot/forth spelling issue in forth word r308534: The file_loadraw function grew an argument, update install function r308535: Add support for LOADER_RC setting in the pkgfs manifes r308776: loader: zfs toplevel vdev must have spa set. r308843: loader: smbios version check is not correct r310236: Renumber license clauses to avoid skipping #3 r310726: cdboot: add explict suffix to ambiguous or instruction PR: 214375 Added: stable/11/sys/boot/Makefile.ficl - copied unchanged from r307950, head/sys/boot/Makefile.ficl stable/11/sys/boot/forth/efi.4th - copied unchanged from r307879, head/sys/boot/forth/efi.4th Deleted: stable/11/sys/boot/ficl/efi.c Modified: stable/11/sys/boot/common/Makefile.inc stable/11/sys/boot/common/bootstrap.h stable/11/sys/boot/common/install.c stable/11/sys/boot/common/interp.c stable/11/sys/boot/common/interp_forth.c stable/11/sys/boot/common/loader.8 stable/11/sys/boot/common/newvers.sh stable/11/sys/boot/common/pnp.c stable/11/sys/boot/efi/libefi/Makefile stable/11/sys/boot/efi/libefi/efinet.c stable/11/sys/boot/efi/libefi/env.c stable/11/sys/boot/efi/loader/Makefile stable/11/sys/boot/efi/loader/arch/amd64/ldscript.amd64 stable/11/sys/boot/efi/loader/arch/arm/ldscript.arm stable/11/sys/boot/efi/loader/arch/arm64/ldscript.arm64 stable/11/sys/boot/efi/loader/arch/i386/efimd.c stable/11/sys/boot/efi/loader/arch/i386/elf32_freebsd.c stable/11/sys/boot/efi/loader/arch/i386/exec.c stable/11/sys/boot/efi/loader/arch/i386/ldscript.i386 stable/11/sys/boot/efi/loader/main.c stable/11/sys/boot/ficl/Makefile stable/11/sys/boot/ficl/ficl.h stable/11/sys/boot/ficl/i386/sysdep.c stable/11/sys/boot/ficl/loader.c stable/11/sys/boot/ficl32/Makefile stable/11/sys/boot/forth/Makefile.inc stable/11/sys/boot/forth/loader.4th stable/11/sys/boot/forth/support.4th stable/11/sys/boot/i386/Makefile.inc stable/11/sys/boot/i386/cdboot/cdboot.S stable/11/sys/boot/i386/gptboot/Makefile stable/11/sys/boot/i386/gptzfsboot/Makefile stable/11/sys/boot/i386/libi386/Makefile stable/11/sys/boot/i386/libi386/biospci.c stable/11/sys/boot/i386/libi386/libi386.h stable/11/sys/boot/i386/libi386/smbios.c stable/11/sys/boot/i386/loader/Makefile stable/11/sys/boot/mips/beri/loader/loader.ldscript stable/11/sys/boot/pc98/libpc98/Makefile stable/11/sys/boot/zfs/zfsimpl.c stable/11/targets/pseudo/userland/misc/Makefile.depend Directory Properties: stable/11/ (props changed) Copied: stable/11/sys/boot/Makefile.ficl (from r307950, head/sys/boot/Makefile.ficl) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/boot/Makefile.ficl Thu Feb 8 02:50:47 2018 (r329011, copy of r307950, head/sys/boot/Makefile.ficl) @@ -0,0 +1,43 @@ +# $FreeBSD$ + +# Common flags to build FICL related files + +FICLDIR?= ${SRCTOP}/sys/boot/ficl + +.if ${MACHINE_CPUARCH} == "amd64" && defined(FICL32) +FICL_CPUARCH= i386 +.elif ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el" +FICL_CPUARCH= mips64 +.else +FICL_CPUARCH= ${MACHINE_CPUARCH} +.endif + +.PATH: ${FICLDIR} ${FICLDIR}/${FICL_CPUARCH} + +.if ${MACHINE_CPUARCH} == "amd64" +.if defined(FICL32) +CFLAGS+= -m32 -I. +.else +CFLAGS+= -fPIC +.endif +.endif + +.if ${MACHINE_ARCH} == "powerpc64" +CFLAGS+= -m32 -mcpu=powerpc -I. +.endif + +CFLAGS+= -I${FICLDIR} -I${FICLDIR}/${FICL_CPUARCH} \ + -I${FICLDIR}/../common + +.if ${MACHINE_CPUARCH} == "amd64" && defined(FICL32) +.if !exists(machine) +${SRCS:M*.c:R:S/$/.o/g}: machine + +beforedepend ${OBJS}: machine +.endif + +machine: .NOMETA + ln -sf ${.CURDIR}/../../i386/include machine + +CLEANFILES+= machine +.endif Modified: stable/11/sys/boot/common/Makefile.inc ============================================================================== --- stable/11/sys/boot/common/Makefile.inc Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/common/Makefile.inc Thu Feb 8 02:50:47 2018 (r329011) @@ -65,6 +65,7 @@ SRCS+= pnp.c # Forth interpreter .if defined(BOOT_FORTH) SRCS+= interp_forth.c +.include "${SRCTOP}/sys/boot/Makefile.ficl" .endif .if defined(BOOT_PROMPT_123) Modified: stable/11/sys/boot/common/bootstrap.h ============================================================================== --- stable/11/sys/boot/common/bootstrap.h Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/common/bootstrap.h Thu Feb 8 02:50:47 2018 (r329011) @@ -142,8 +142,6 @@ struct pnpinfo STAILQ_HEAD(pnpinfo_stql, pnpinfo); -extern struct pnpinfo_stql pnp_devices; - extern struct pnphandler *pnphandlers[]; /* provided by MD code */ void pnp_addident(struct pnpinfo *pi, char *ident); Modified: stable/11/sys/boot/common/install.c ============================================================================== --- stable/11/sys/boot/common/install.c Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/common/install.c Thu Feb 8 02:50:47 2018 (r329011) @@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$"); #include "bootstrap.h" -extern struct in_addr rootip; extern struct in_addr servip; extern int pkgfs_init(const char *, struct fs_ops *); @@ -50,6 +49,7 @@ COMMAND_SET(install, "install", "install software pack static char *inst_kernel; static char **inst_modules; static char *inst_rootfs; +static char *inst_loader_rc; static int setpath(char **what, char *val) @@ -146,6 +146,8 @@ read_metatags(int fd) error = setmultipath(&inst_modules, val); else if (strcmp(tag, "ROOTFS") == 0) error = setpath(&inst_rootfs, val); + else if (strcmp(tag, "LOADER_RC") == 0) + error = setpath(&inst_loader_rc, val); tag = p; } @@ -173,6 +175,10 @@ cleanup(void) free(inst_rootfs); inst_rootfs = NULL; } + if (inst_loader_rc != NULL) { + free(inst_loader_rc); + inst_loader_rc = NULL; + } pkgfs_cleanup(); } @@ -275,6 +281,16 @@ install(char *pkgname) goto fail; } + /* If there is a loader.rc in the package, execute it */ + s = (inst_loader_rc == NULL) ? "/loader.rc" : inst_loader_rc; + fd = open(s, O_RDONLY); + if (fd != -1) { + close(fd); + error = include(s); + if (error == CMD_ERROR) + goto fail; + } + i = 0; while (inst_modules != NULL && inst_modules[i] != NULL) { error = mod_loadkld(inst_modules[i], 0, NULL); @@ -286,7 +302,7 @@ install(char *pkgname) } s = (inst_rootfs == NULL) ? "/install.iso" : inst_rootfs; - if (file_loadraw(s, "mfs_root") == NULL) { + if (file_loadraw(s, "mfs_root", 1) == NULL) { error = errno; command_errmsg = "cannot load root file system"; goto fail; Modified: stable/11/sys/boot/common/interp.c ============================================================================== --- stable/11/sys/boot/common/interp.c Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/common/interp.c Thu Feb 8 02:50:47 2018 (r329011) @@ -104,8 +104,7 @@ interact(const char *rc) if (rc == NULL) { /* Read our default configuration. */ - if (include("/boot/loader.rc") != CMD_OK) - include("/boot/boot.conf"); + include("/boot/loader.rc"); } else if (*rc != '\0') include(rc); Modified: stable/11/sys/boot/common/interp_forth.c ============================================================================== --- stable/11/sys/boot/common/interp_forth.c Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/common/interp_forth.c Thu Feb 8 02:50:47 2018 (r329011) @@ -63,7 +63,6 @@ extern unsigned bootprog_rev; FICL_SYSTEM *bf_sys; FICL_VM *bf_vm; -FICL_WORD *pInterp; /* * Shim for taking commands from BF and passing them out to 'standard' @@ -280,8 +279,6 @@ bf_init(const char *rc) ficlSetEnv(bf_sys, "FreeBSD_version", __FreeBSD_version); ficlSetEnv(bf_sys, "loader_version", bootprog_rev); - pInterp = ficlLookup(bf_sys, "interpret"); - /* try to load and run init file if present */ if (rc == NULL) rc = "/boot/boot.4th"; @@ -292,9 +289,6 @@ bf_init(const char *rc) close(fd); } } - - /* Do this again, so that interpret can be redefined. */ - pInterp = ficlLookup(bf_sys, "interpret"); } /* Modified: stable/11/sys/boot/common/loader.8 ============================================================================== --- stable/11/sys/boot/common/loader.8 Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/common/loader.8 Thu Feb 8 02:50:47 2018 (r329011) @@ -90,9 +90,7 @@ which is default. After that, .Pa /boot/loader.rc -is processed if available, and, failing that, -.Pa /boot/boot.conf -is read for historical reasons. +is processed if available. These files are processed through the .Ic include command, which reads all of them into memory before processing them, @@ -957,10 +955,6 @@ itself. Additional .Tn FICL initialization. -.It Pa /boot/boot.conf -.Nm -bootstrapping script. -Deprecated. .It Pa /boot/defaults/loader.conf .It Pa /boot/loader.conf .It Pa /boot/loader.conf.local Modified: stable/11/sys/boot/common/newvers.sh ============================================================================== --- stable/11/sys/boot/common/newvers.sh Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/common/newvers.sh Thu Feb 8 02:50:47 2018 (r329011) @@ -14,7 +14,7 @@ # 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. -# 4. Neither the name of the University nor the names of its contributors +# 3. Neither the name of the University nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # Modified: stable/11/sys/boot/common/pnp.c ============================================================================== --- stable/11/sys/boot/common/pnp.c Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/common/pnp.c Thu Feb 8 02:50:47 2018 (r329011) @@ -17,8 +17,11 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef BOOT_FORTH +#include "ficl.h" +#endif -struct pnpinfo_stql pnp_devices; +static struct pnpinfo_stql pnp_devices; static int pnp_devices_initted = 0; static void pnp_discard(void); @@ -185,3 +188,49 @@ pnp_eisaformat(u_int8_t *data) return(idbuf); } +#ifdef BOOT_FORTH +void +ficlPnpdevices(FICL_VM *pVM) +{ + static int pnp_devices_initted = 0; +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 0, 1); +#endif + + if(!pnp_devices_initted) { + STAILQ_INIT(&pnp_devices); + pnp_devices_initted = 1; + } + + stackPushPtr(pVM->pStack, &pnp_devices); + + return; +} + +void +ficlPnphandlers(FICL_VM *pVM) +{ +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 0, 1); +#endif + + stackPushPtr(pVM->pStack, pnphandlers); + + return; +} + +/* + * Glue function to add the appropriate forth words to access pnp BIOS + * functionality. + */ +static void ficlCompilePnp(FICL_SYSTEM *pSys) +{ + FICL_DICT *dp = pSys->dp; + assert (dp); + + dictAppendWord(dp, "pnpdevices",ficlPnpdevices, FW_DEFAULT); + dictAppendWord(dp, "pnphandlers",ficlPnphandlers, FW_DEFAULT); +} + +FICL_COMPILE_SET(ficlCompilePnp); +#endif Modified: stable/11/sys/boot/efi/libefi/Makefile ============================================================================== --- stable/11/sys/boot/efi/libefi/Makefile Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/efi/libefi/Makefile Thu Feb 8 02:50:47 2018 (r329011) @@ -1,16 +1,25 @@ # $FreeBSD$ +.include + +.if ${MK_FORTH} != "no" +.include "${.CURDIR}/../../Makefile.ficl" +.endif + LIB= efi INTERNALLIB= WARNS?= 2 -SRCS= delay.c devpath.c efi_console.c efinet.c efipart.c env.c errno.c \ +SRCS= delay.c devpath.c efi_console.c efinet.c efipart.c errno.c \ handles.c libefi.c .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" SRCS+= time.c .elif ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" SRCS+= time_event.c +.endif +.if ${MK_FORTH} != "no" +SRCS+= env.c .endif # We implement a slightly non-standard %S in that it always takes a Modified: stable/11/sys/boot/efi/libefi/efinet.c ============================================================================== --- stable/11/sys/boot/efi/libefi/efinet.c Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/efi/libefi/efinet.c Thu Feb 8 02:50:47 2018 (r329011) @@ -360,10 +360,12 @@ efinet_dev_print(int verbose) for (unit = 0, h = efi_find_handle(&efinet_dev, 0); h != NULL; h = efi_find_handle(&efinet_dev, ++unit)) { printf(" %s%d:", efinet_dev.dv_name, unit); - text = efi_devpath_name(efi_lookup_devpath(h)); - if (text != NULL) { - printf(" %S", text); - efi_free_devpath_name(text); + if (verbose) { + text = efi_devpath_name(efi_lookup_devpath(h)); + if (text != NULL) { + printf(" %S", text); + efi_free_devpath_name(text); + } } if ((ret = pager_output("\n")) != 0) break; Modified: stable/11/sys/boot/efi/libefi/env.c ============================================================================== --- stable/11/sys/boot/efi/libefi/env.c Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/efi/libefi/env.c Thu Feb 8 02:50:47 2018 (r329011) @@ -26,9 +26,16 @@ #include __FBSDID("$FreeBSD$"); +#include +#include #include #include +#include +#include "bootstrap.h" +#include "ficl.h" +int efi_variable_support = 1; + /* * Simple wrappers to the underlying UEFI functions. * See http://wiki.phoenix.com/wiki/index.php/EFI_RUNTIME_SERVICES @@ -53,3 +60,175 @@ efi_set_variable(CHAR16 *variable_name, EFI_GUID *vend { return RS->SetVariable(variable_name, vendor_guid, attributes, data_size, data); } + +/* + * FreeBSD's loader interaction words and extras + * + * efi-setenv ( value n name n guid n attr -- 0 | -1) + * efi-getenv ( guid n addr n -- addr' n' | -1 ) + * efi-unsetenv ( name n guid n'' -- ) + */ + +/* + * efi-setenv + * efi-setenv ( value n name n guid n attr -- 0 | -1) + * + * Set environment variables using the SetVariable EFI runtime service. + * + * Value and guid are passed through in binary form (so guid needs to be + * converted to binary form from its string form). Name is converted from + * ASCII to CHAR16. Since ficl doesn't have support for internationalization, + * there's no native CHAR16 interface provided. + * + * attr is an int in the bitmask of the following attributes for this variable. + * + * 1 Non volatile + * 2 Boot service access + * 4 Run time access + * (corresponding to the same bits in the UEFI spec). + */ +void +ficlEfiSetenv(FICL_VM *pVM) +{ +#ifndef TESTMAIN + char *value = NULL, *guid = NULL; + CHAR16 *name = NULL; + int i; +#endif + char *namep, *valuep, *guidp; + int names, values, guids, attr; + int status; + uuid_t u; + uint32_t ustatus; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 6, 0); +#endif + attr = stackPopINT(pVM->pStack); + guids = stackPopINT(pVM->pStack); + guidp = (char*)stackPopPtr(pVM->pStack); + names = stackPopINT(pVM->pStack); + namep = (char*)stackPopPtr(pVM->pStack); + values = stackPopINT(pVM->pStack); + valuep = (char*)stackPopPtr(pVM->pStack); + +#ifndef TESTMAIN + guid = (char*)ficlMalloc(guids); + if (guid == NULL) + vmThrowErr(pVM, "Error: out of memory"); + memcpy(guid, guidp, guids); + uuid_from_string(guid, &u, &ustatus); + if (ustatus != uuid_s_ok) { + stackPushINT(pVM->pStack, -1); + goto out; + } + + name = (CHAR16 *)ficlMalloc((names + 1) * sizeof(CHAR16)); + if (name == NULL) + vmThrowErr(pVM, "Error: out of memory"); + for (i = 0; i < names; i++) + name[i] = namep[i]; + name[names] = (CHAR16)0; + + value = (char*)ficlMalloc(values + 1); + if (value == NULL) + vmThrowErr(pVM, "Error: out of memory"); + memcpy(value, valuep, values); + + status = efi_set_variable(name, (EFI_GUID *)&u, attr, values, value); + if (status == EFI_SUCCESS) + stackPushINT(pVM->pStack, 0); + else + stackPushINT(pVM->pStack, -1); +out: + ficlFree(name); + ficlFree(value); + ficlFree(guid); +#endif + + return; +} + +void +ficlEfiGetenv(FICL_VM *pVM) +{ +#ifndef TESTMAIN + char *name, *value; +#endif + char *namep; + int names; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 2, 2); +#endif + names = stackPopINT(pVM->pStack); + namep = (char*) stackPopPtr(pVM->pStack); + +#ifndef TESTMAIN + name = (char*) ficlMalloc(names+1); + if (name == NULL) + vmThrowErr(pVM, "Error: out of memory"); + strncpy(name, namep, names); + name[names] = '\0'; + + value = getenv(name); + ficlFree(name); + + if(value != NULL) { + stackPushPtr(pVM->pStack, value); + stackPushINT(pVM->pStack, strlen(value)); + } else +#endif + stackPushINT(pVM->pStack, -1); + + return; +} + +void +ficlEfiUnsetenv(FICL_VM *pVM) +{ +#ifndef TESTMAIN + char *name; +#endif + char *namep; + int names; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 2, 0); +#endif + names = stackPopINT(pVM->pStack); + namep = (char*) stackPopPtr(pVM->pStack); + +#ifndef TESTMAIN + name = (char*) ficlMalloc(names+1); + if (name == NULL) + vmThrowErr(pVM, "Error: out of memory"); + strncpy(name, namep, names); + name[names] = '\0'; + + unsetenv(name); + ficlFree(name); +#endif + + return; +} + +/************************************************************************** +** Add FreeBSD UEFI platform extensions into the system dictionary +**************************************************************************/ +void ficlEfiCompilePlatform(FICL_SYSTEM *pSys) +{ + FICL_DICT *dp = pSys->dp; + assert (dp); + + dictAppendWord(dp, "efi-setenv", ficlEfiSetenv, FW_DEFAULT); + dictAppendWord(dp, "efi-getenv", ficlEfiGetenv, FW_DEFAULT); + dictAppendWord(dp, "efi-unsetenv", ficlEfiUnsetenv, FW_DEFAULT); + + /* Would like to export the EFI version, but this will do for now */ + ficlSetEnv(pSys, "efi-boot", 1); + + return; +} + +FICL_COMPILE_SET(ficlEfiCompilePlatform); Modified: stable/11/sys/boot/efi/loader/Makefile ============================================================================== --- stable/11/sys/boot/efi/loader/Makefile Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/efi/loader/Makefile Thu Feb 8 02:50:47 2018 (r329011) @@ -146,6 +146,7 @@ loader.efi: ${PROG} ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ -j .dynamic -j .dynsym -j .rel.dyn \ -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \ + -j set_Xficl_compile_set \ --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} LIBEFI= ${.OBJDIR}/../libefi/libefi.a Modified: stable/11/sys/boot/efi/loader/arch/amd64/ldscript.amd64 ============================================================================== --- stable/11/sys/boot/efi/loader/arch/amd64/ldscript.amd64 Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/efi/loader/arch/amd64/ldscript.amd64 Thu Feb 8 02:50:47 2018 (r329011) @@ -40,6 +40,11 @@ SECTIONS *(set_Xcommand_set) __stop_set_Xcommand_set = .; } + set_Xficl_compile_set : { + __start_set_Xficl_compile_set = .; + *(set_Xficl_compile_set) + __stop_set_Xficl_compile_set = .; + } . = ALIGN(4096); __gp = .; .sdata : { Modified: stable/11/sys/boot/efi/loader/arch/arm/ldscript.arm ============================================================================== --- stable/11/sys/boot/efi/loader/arch/arm/ldscript.arm Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/efi/loader/arch/arm/ldscript.arm Thu Feb 8 02:50:47 2018 (r329011) @@ -47,6 +47,11 @@ SECTIONS *(set_Xcommand_set) __stop_set_Xcommand_set = .; } + set_Xficl_compile_set : { + __start_set_Xficl_compile_set = .; + *(set_Xficl_compile_set) + __stop_set_Xficl_compile_set = .; + } __gp = .; .plt : { *(.plt) } .dynamic : { *(.dynamic) } Modified: stable/11/sys/boot/efi/loader/arch/arm64/ldscript.arm64 ============================================================================== --- stable/11/sys/boot/efi/loader/arch/arm64/ldscript.arm64 Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/efi/loader/arch/arm64/ldscript.arm64 Thu Feb 8 02:50:47 2018 (r329011) @@ -43,6 +43,11 @@ SECTIONS *(set_Xcommand_set) __stop_set_Xcommand_set = .; } + set_Xficl_compile_set : { + __start_set_Xficl_compile_set = .; + *(set_Xficl_compile_set) + __stop_set_Xficl_compile_set = .; + } . = ALIGN(16); __gp = .; .sdata : { Modified: stable/11/sys/boot/efi/loader/arch/i386/efimd.c ============================================================================== --- stable/11/sys/boot/efi/loader/arch/i386/efimd.c Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/efi/loader/arch/i386/efimd.c Thu Feb 8 02:50:47 2018 (r329011) @@ -48,7 +48,10 @@ static EFI_GUID hcdp_guid = HCDP_TABLE_GUID; static UINTN mapkey; -uint64_t +int ldr_bootinfo(struct bootinfo *, uint64_t *); +int ldr_enter(const char *); + +static uint64_t ldr_alloc(vm_offset_t va) { Modified: stable/11/sys/boot/efi/loader/arch/i386/elf32_freebsd.c ============================================================================== --- stable/11/sys/boot/efi/loader/arch/i386/elf32_freebsd.c Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/efi/loader/arch/i386/elf32_freebsd.c Thu Feb 8 02:50:47 2018 (r329011) @@ -35,13 +35,17 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + #include "bootstrap.h" #include "../libi386/libi386.h" #include "../btx/lib/btxv86.h" extern void __exec(caddr_t addr, ...); +extern int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp); +extern int ldr_enter(const char *kernel); - static int elf32_exec(struct preloaded_file *amp); static int elf32_obj_exec(struct preloaded_file *amp); @@ -72,14 +76,14 @@ elf32_exec(struct preloaded_file *fp) ehdr = (Elf_Ehdr *)&(md->md_data); efi_time_fini(); - err = bi_load(fp->f_args, &boothowto, &bootdev, &bootinfop, &modulep, &kernend); + err = bi_load(fp->f_args, &modulep, &kernend); if (err != 0) { efi_time_init(); return(err); } entry = ehdr->e_entry & 0xffffff; - printf("Start @ 0x%lx ...\n", entry); + printf("Start @ 0x%x ...\n", entry); ldr_enter(fp->f_name); Modified: stable/11/sys/boot/efi/loader/arch/i386/exec.c ============================================================================== --- stable/11/sys/boot/efi/loader/arch/i386/exec.c Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/efi/loader/arch/i386/exec.c Thu Feb 8 02:50:47 2018 (r329011) @@ -36,6 +36,12 @@ __FBSDID("$FreeBSD$"); uint32_t __base; struct __v86 __v86; +/* XXX - Needed a definition here to implicitly define exit(); do not remove. */ +static void +exit(int x) +{ +} + void __v86int() { Modified: stable/11/sys/boot/efi/loader/arch/i386/ldscript.i386 ============================================================================== --- stable/11/sys/boot/efi/loader/arch/i386/ldscript.i386 Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/efi/loader/arch/i386/ldscript.i386 Thu Feb 8 02:50:47 2018 (r329011) @@ -35,6 +35,11 @@ SECTIONS *(set_Xcommand_set) __stop_set_Xcommand_set = .; } + set_Xficl_compile_set : { + __start_set_Xficl_compile_set = .; + *(set_Xficl_compile_set) + __stop_set_Xficl_compile_set = .; + } . = ALIGN(4096); __gp = .; .sdata : { Modified: stable/11/sys/boot/efi/loader/main.c ============================================================================== --- stable/11/sys/boot/efi/loader/main.c Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/efi/loader/main.c Thu Feb 8 02:50:47 2018 (r329011) @@ -52,6 +52,22 @@ __FBSDID("$FreeBSD$"); extern char bootprog_info[]; +#ifdef BOOT_FORTH +/* + * Normally, efi.o from libefi.a would be brought in due to a function we call + * there that's defined there. However, none of its functions are callable from + * here since it just adds words to the FORTH environment or implement those + * words. So, add a reference to a symbol in efi.o to force it to be be brought + * in so the init function there gets added to the "compile" linker set happens + * correctly. + * + * This assumes there's no global analysys that notices dummy1 isn't used + * anywhere and tries to eliminate it. + */ +extern int efi_variable_support; +int *dummy1 = &efi_variable_support; +#endif + struct arch_switch archsw; /* MI/MD interface boundary */ EFI_GUID acpi = ACPI_TABLE_GUID; @@ -218,6 +234,11 @@ find_currdev(EFI_LOADED_IMAGE *img, struct devsw **dev } } + /* Try to fallback on first device */ + if (devsw[0] != NULL) { + *dev = devsw[0]; + return (0); + } return (ENOENT); } @@ -232,6 +253,7 @@ main(int argc, CHAR16 *argv[]) uint64_t pool_guid; UINTN k; int has_kbd; + char buf[40]; archsw.arch_autoload = efi_autoload; archsw.arch_getdev = efi_getdev; @@ -442,6 +464,9 @@ main(int argc, CHAR16 *argv[]) for (k = 0; k < ST->NumberOfTableEntries; k++) { guid = &ST->ConfigurationTable[k].VendorGuid; if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) { + snprintf(buf, sizeof(buf), "%p", + ST->ConfigurationTable[k].VendorTable); + setenv("hint.smbios.0.mem", buf, 1); smbios_detect(ST->ConfigurationTable[k].VendorTable); break; } @@ -613,7 +638,8 @@ command_configuration(int argc, char *argv[]) else if (!memcmp(guid, &acpi20, sizeof(EFI_GUID))) printf("ACPI 2.0 Table"); else if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) - printf("SMBIOS Table"); + printf("SMBIOS Table %p", + ST->ConfigurationTable[i].VendorTable); else if (!memcmp(guid, &dxe, sizeof(EFI_GUID))) printf("DXE Table"); else if (!memcmp(guid, &hoblist, sizeof(EFI_GUID))) @@ -915,8 +941,8 @@ command_efi_show(int argc, char *argv[]) return (rv); } - if (argc != 0) { - printf("Too many args\n"); + if (argc > 0) { + printf("Too many args %d\n", argc); pager_close(); return (CMD_ERROR); } Modified: stable/11/sys/boot/ficl/Makefile ============================================================================== --- stable/11/sys/boot/ficl/Makefile Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/ficl/Makefile Thu Feb 8 02:50:47 2018 (r329011) @@ -1,15 +1,8 @@ # $FreeBSD$ # -FICLDIR?= ${.CURDIR} +.include "${.CURDIR}/../Makefile.ficl" -.if defined(FICL32) -.PATH: ${FICLDIR}/${MACHINE_CPUARCH:S/amd64/i386/} -.elif ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el" -.PATH: ${FICLDIR}/mips64 -.else -.PATH: ${FICLDIR}/${MACHINE_CPUARCH} -.endif BASE_SRCS= dict.c ficl.c fileaccess.c float.c loader.c math64.c \ prefix.c search.c stack.c tools.c vm.c words.c @@ -41,42 +34,6 @@ SOFTWORDS= softcore.fr jhlocal.fr marker.fr freebsd.fr # Optional OO extension softwords #SOFTWORDS+= oo.fr classes.fr -.if ${MACHINE_CPUARCH} == "amd64" -.if defined(FICL32) -CFLAGS+= -m32 -I. -.else -CFLAGS+= -fPIC -.endif -.endif - -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -mcpu=powerpc -I. -.endif - -.if ${MACHINE_CPUARCH} == "amd64" && defined(FICL32) -FICL_CPUARCH= i386 -.elif ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el" -FICL_CPUARCH= mips64 -.else -FICL_CPUARCH= ${MACHINE_CPUARCH} -.endif - -CFLAGS+= -I${FICLDIR} -I${FICLDIR}/${FICL_CPUARCH} \ - -I${FICLDIR}/../common - softcore.c: ${SOFTWORDS} softcore.awk (cd ${FICLDIR}/softwords; cat ${SOFTWORDS} \ | awk -f softcore.awk -v datestamp="`LC_ALL=C date`") > ${.TARGET} - -.if ${MACHINE_CPUARCH} == "amd64" && defined(FICL32) -.if !exists(machine) -${SRCS:M*.c:R:S/$/.o/g}: machine - -beforedepend ${OBJS}: machine -.endif - -machine: .NOMETA - ln -sf ${.CURDIR}/../../i386/include machine - -CLEANFILES+= machine -.endif Modified: stable/11/sys/boot/ficl/ficl.h ============================================================================== --- stable/11/sys/boot/ficl/ficl.h Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/ficl/ficl.h Thu Feb 8 02:50:47 2018 (r329011) @@ -1150,6 +1150,13 @@ typedef struct ficlFILE } ficlFILE; #endif +#include + +typedef void ficlCompileFcn(FICL_SYSTEM *); +#define FICL_COMPILE_SET(func) \ + DATA_SET(Xficl_compile_set, func) +SET_DECLARE(Xficl_compile_set, ficlCompileFcn); + #ifdef __cplusplus } #endif Modified: stable/11/sys/boot/ficl/i386/sysdep.c ============================================================================== --- stable/11/sys/boot/ficl/i386/sysdep.c Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/ficl/i386/sysdep.c Thu Feb 8 02:50:47 2018 (r329011) @@ -81,7 +81,6 @@ void ficlFree (void *p) } #ifndef TESTMAIN -#ifdef __i386__ /* * outb ( port# c -- ) * Store a byte to I/O port number port# @@ -111,7 +110,22 @@ ficlInb(FICL_VM *pVM) c=inb(port); stackPushINT(pVM->pStack,c); } -#endif + +/* + * Glue function to add the appropriate forth words to access x86 special cpu + * functionality. + */ +static void ficlCompileCpufunc(FICL_SYSTEM *pSys) +{ + FICL_DICT *dp = pSys->dp; + assert (dp); + + dictAppendWord(dp, "outb", ficlOutb, FW_DEFAULT); + dictAppendWord(dp, "inb", ficlInb, FW_DEFAULT); +} + +FICL_COMPILE_SET(ficlCompileCpufunc); + #endif /* Modified: stable/11/sys/boot/ficl/loader.c ============================================================================== --- stable/11/sys/boot/ficl/loader.c Thu Feb 8 02:44:21 2018 (r329010) +++ stable/11/sys/boot/ficl/loader.c Thu Feb 8 02:50:47 2018 (r329011) @@ -287,44 +287,7 @@ ficlFindfile(FICL_VM *pVM) return; } -#ifndef TESTMAIN -#ifdef HAVE_PNP - void -ficlPnpdevices(FICL_VM *pVM) -{ - static int pnp_devices_initted = 0; -#if FICL_ROBUST > 1 - vmCheckStack(pVM, 0, 1); -#endif - - if(!pnp_devices_initted) { - STAILQ_INIT(&pnp_devices); - pnp_devices_initted = 1; - } - - stackPushPtr(pVM->pStack, &pnp_devices); - - return; -} - -void -ficlPnphandlers(FICL_VM *pVM) -{ -#if FICL_ROBUST > 1 - vmCheckStack(pVM, 0, 1); -#endif - - stackPushPtr(pVM->pStack, pnphandlers); - - return; -} - -#endif - -#endif /* ndef TESTMAIN */ - -void ficlCcall(FICL_VM *pVM) { int (*func)(int, ...); @@ -800,142 +763,7 @@ static void fkey(FICL_VM *pVM) } -#ifdef __i386__ /* - * pcibios-device-count (devid -- count) - * - * Returns the PCI BIOS' count of how many devices matching devid are in the system. - * devid is the 32-bit vendor + device. - */ -static void -ficlPciBiosCountDevices(FICL_VM *pVM) -{ - uint32_t devid; - int i; - - devid = stackPopINT(pVM->pStack); - - i = biospci_count_device_type(devid); - - stackPushINT(pVM->pStack, i); -} - -/* - * pcibios-write-config (locator offset width value -- ) - * - * Writes the specified config register. - * Locator is bus << 8 | device << 3 | fuction - * offset is the pci config register - * width is 0 for byte, 1 for word, 2 for dword - * value is the value to write - */ -static void -ficlPciBiosWriteConfig(FICL_VM *pVM) -{ - uint32_t value, width, offset, locator; - - value = stackPopINT(pVM->pStack); - width = stackPopINT(pVM->pStack); - offset = stackPopINT(pVM->pStack); - locator = stackPopINT(pVM->pStack); - - biospci_write_config(locator, offset, width, value); -} - -/* - * pcibios-read-config (locator offset width -- value) - * - * Reads the specified config register. - * Locator is bus << 8 | device << 3 | fuction - * offset is the pci config register - * width is 0 for byte, 1 for word, 2 for dword - * value is the value to read from the register - */ -static void -ficlPciBiosReadConfig(FICL_VM *pVM) -{ - uint32_t value, width, offset, locator; - - width = stackPopINT(pVM->pStack); - offset = stackPopINT(pVM->pStack); - locator = stackPopINT(pVM->pStack); - - biospci_read_config(locator, offset, width, &value); - - stackPushINT(pVM->pStack, value); -} - -/* - * pcibios-find-devclass (class index -- locator) - * - * Finds the index'th instance of class in the pci tree. - * must be an exact match. - * class is the class to search for. - * index 0..N (set to 0, increment until error) - * - * Locator is bus << 8 | device << 3 | fuction (or -1 on error) - */ -static void -ficlPciBiosFindDevclass(FICL_VM *pVM) -{ - uint32_t index, class, locator; - - index = stackPopINT(pVM->pStack); - class = stackPopINT(pVM->pStack); - - if (biospci_find_devclass(class, index, &locator)) - locator = 0xffffffff; - - stackPushINT(pVM->pStack, locator); -} - -/* - * pcibios-find-device(devid index -- locator) - * - * Finds the index'th instance of devid in the pci tree. - * must be an exact match. - * class is the class to search for. - * index 0..N (set to 0, increment until error) - * - * Locator is bus << 8 | device << 3 | fuction (or -1 on error) - */ -static void -ficlPciBiosFindDevice(FICL_VM *pVM) -{ - uint32_t index, devid, locator; - - index = stackPopINT(pVM->pStack); - devid = stackPopINT(pVM->pStack); - - if (biospci_find_device(devid, index, &locator)) - locator = 0xffffffff; - - stackPushINT(pVM->pStack, locator); -} - *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Thu Feb 8 03:16:52 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ED046EF4039 for ; Thu, 8 Feb 2018 03:16:51 +0000 (UTC) (envelope-from byond.lenox@gmail.com) Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com [209.85.215.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6129F6F590 for ; Thu, 8 Feb 2018 03:16:51 +0000 (UTC) (envelope-from byond.lenox@gmail.com) Received: by mail-lf0-f50.google.com with SMTP id x196so4319570lfd.12 for ; Wed, 07 Feb 2018 19:16:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc; bh=UeOgJeO1ZPsTb+ZhdbJcfsNdWmR5SmysfG0KahQE2mE=; b=GNiB3goNnM9rCgjV1OX4omeh6CU3kxX4Vfd5QKleZHbFi86dMzNIWMNb8h5U8IWQYX jSOxMLWg0yI0hbHIPphuerF7VW/XGc75kDTkECDGCp6FJWVjmF8E9YEsO9nzZ4+qDHCD DPS0/4Nwn7XLP+kHaKDiDeMYXNKtsFdgGgKDvnrWItWXPUyvu3CfionhbxXQJX8wer5J XvHTb2PbjmCo7t6Gnn8JpfgPQFcTl70cCcFvus2fMTaMJcJVBVKMIb/GSE35/sbWAsgi z4P/feb7xzzA8eKxZdbNCMGlLPGFv11+vty6fay8zi6T0ap0yLEQaCpT1QeyULTExEPv MRpA== X-Gm-Message-State: APf1xPCNwAIhxfmMzCk254H1vzA8HBq/nqvohZT8h0HxgSflxzWEx013 URBWp+yzn1SSHf7n7RTpWLNR6dbg X-Google-Smtp-Source: AH8x227gPmIfMjMN/7zWmEZ1cCuc76MUvZiwybm1gCTLWMbxCkwScz2OhHwRyQbHkvTsLMUFloG+DQ== X-Received: by 10.25.193.7 with SMTP id r7mr5255143lff.29.1518059803967; Wed, 07 Feb 2018 19:16:43 -0800 (PST) Received: from mail-lf0-f47.google.com (mail-lf0-f47.google.com. [209.85.215.47]) by smtp.gmail.com with ESMTPSA id s72sm134576lfk.3.2018.02.07.19.16.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Feb 2018 19:16:43 -0800 (PST) Received: by mail-lf0-f47.google.com with SMTP id u20so2156889lff.11 for ; Wed, 07 Feb 2018 19:16:43 -0800 (PST) X-Received: by 10.46.80.9 with SMTP id e9mt6531564ljb.61.1518059803046; Wed, 07 Feb 2018 19:16:43 -0800 (PST) MIME-Version: 1.0 Received: by 10.46.106.8 with HTTP; Wed, 7 Feb 2018 19:16:22 -0800 (PST) In-Reply-To: <201802080250.w182olh7097879@repo.freebsd.org> References: <201802080250.w182olh7097879@repo.freebsd.org> From: Kyle Evans Date: Wed, 7 Feb 2018 21:16:22 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r329011 - in stable/11: sys/boot sys/boot/common sys/boot/efi/libefi sys/boot/efi/loader sys/boot/efi/loader/arch/amd64 sys/boot/efi/loader/arch/arm sys/boot/efi/loader/arch/arm64 sys/b... Cc: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 03:16:52 -0000 On Wed, Feb 7, 2018 at 8:50 PM, Kyle Evans wrote: > Author: kevans > Date: Thu Feb 8 02:50:47 2018 > New Revision: 329011 > URL: https://svnweb.freebsd.org/changeset/base/329011 > > Log: > MFC r307322,r307323,r307324,r307326,r307327,r307338,r307879,r307908,r307911, > r307942,r307950,r307951,r307954,r307955,r308125,r308195,r308476,r308534, > r308535,r308776,r308843,r310236,r310726: Loader fixes, 2016q4 > > r307322: Remove /boot/boot.conf, deprecated for 16 years > > r307323: Remove fetching of pInterp. > > r307324: Create a new linker set, Xficl_compile_set which contains a list of > functions to call to register new forth words. > > r307326: In UEFI mode expose the SMBIOS anchor base address via kenv > > r307327: Update i386 build of loader.efi (but leave it disabled) so that we > at least build it now. > > r307338: Create a pcibios-version environment FORTH word. > > r307879: Preliminary support for EFI in boot loader. > > r307908: Fix the build on both arm64 and when WITHOUT_FORTH is defined. > > r307911: Add better comment... > > r307942: Really make WITHOUT_FORTH (MK_FORTH==no) work. > > r307950: Add it (Makefile.ficl) to the right place > > r307951: Fix two backwards tests. > > r307954: Back out the move to the loader script from -N. > > r307955: LIBSTAND goes last, so put it last here too. > > r308125: In loader.efi, instead of exiting directly, try to fallback. > > r308195: efinet_dev_print should honor verbose option. > > r308476: boot/forth spelling issue in forth word > > r308534: The file_loadraw function grew an argument, update install function > > r308535: Add support for LOADER_RC setting in the pkgfs manifes > > r308776: loader: zfs toplevel vdev must have spa set. > > r308843: loader: smbios version check is not correct > > r310236: Renumber license clauses to avoid skipping #3 > > r310726: cdboot: add explict suffix to ambiguous or instruction > > PR: 214375 > Just as an FYI- this is the format that I intend to do these MFC's of sys/boot work in. The intention is to batch these up by fiscal quarter while we're playing catch up since there are so many (450+) commits that need to make it back before we hit 2018Q1. I will be preparing batches and committing every couple of days, two batches at a time. Please do speak up before the next batches (likely to be committed in the Friday/Saturday time frame) if this format is particularly appalling. From owner-svn-src-stable-11@freebsd.org Thu Feb 8 02:44:25 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 596E4EF1F9D; Thu, 8 Feb 2018 02:44:25 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0AE836D989; Thu, 8 Feb 2018 02:44:25 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 058E37F43; Thu, 8 Feb 2018 02:44:25 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w182iPOo096758; Thu, 8 Feb 2018 02:44:25 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w182iMIH096727; Thu, 8 Feb 2018 02:44:22 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802080244.w182iMIH096727@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 8 Feb 2018 02:44:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329010 - in stable/11/sys/boot: common efi/boot1 efi/libefi efi/loader efi/loader/arch/amd64 fdt forth i386 i386/boot0 i386/boot2 i386/btx/btx i386/btx/btxldr i386/cdboot i386/gptboot ... X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11/sys/boot: common efi/boot1 efi/libefi efi/loader efi/loader/arch/amd64 fdt forth i386 i386/boot0 i386/boot2 i386/btx/btx i386/btx/btxldr i386/cdboot i386/gptboot i386/gptzfsboot i386/libi... X-SVN-Commit-Revision: 329010 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 02:44:25 -0000 Author: kevans Date: Thu Feb 8 02:44:21 2018 New Revision: 329010 URL: https://svnweb.freebsd.org/changeset/base/329010 Log: MFC r303555,r303556,r303936,r303962,r304317,r304532,r305026,r305107,r305132, r305178,r305353,r305814,r306159,r306380,r306504: Loader fixes, 2016q3 r303555: bcache should support reads shorter than sector size r303556: Improve boot loader quote parsing r303936: Add kernel environment variables under smbios.system r303962: Add the missing space between .asciz directive and opening quote for some lines with #ifdef BTXLDR_VERBOSE/#endif r304317: boot1.efi Free() should check for NULL to provide consistent behavior r304532: Replace sprintf -> snprintf for command_errbuf provisioned from dynamic content. r305026: Emulate efi_cons_poll when WaitForKey is not available r305107: Create a hook 'post-initialize' for people that want to define something to read in .conf files after all other .conf files for the purpose of overriding. r305132: Remove accidentally committed stray comment. r305178: bd_int13probe() should check extended info if sector info is bad r305353: Don't use -N to set the OMAGIC with data and text writeable and data not page aligned. r305814: ufsread: Do not cast struct direct from void * r306159: Consistently declare getsecs(void) with proper return type and void when no arguments are present. r306380: loader command interpreter should reset command_errmsg r306504: Fix a cluster of bugs in list EFI environment variables PR: 204602, 211958, 211958 Relnotes: yes ("Improve boot loader quote parsing") Added: stable/11/sys/boot/i386/boot.ldscript - copied unchanged from r305353, head/sys/boot/i386/boot.ldscript Modified: stable/11/sys/boot/common/bcache.c stable/11/sys/boot/common/boot.c stable/11/sys/boot/common/bootstrap.h stable/11/sys/boot/common/commands.c stable/11/sys/boot/common/interp.c stable/11/sys/boot/common/interp_forth.c stable/11/sys/boot/common/interp_parse.c stable/11/sys/boot/common/ls.c stable/11/sys/boot/common/module.c stable/11/sys/boot/common/ufsread.c stable/11/sys/boot/efi/boot1/boot1.c stable/11/sys/boot/efi/libefi/efi_console.c stable/11/sys/boot/efi/libefi/time.c stable/11/sys/boot/efi/libefi/time_event.c stable/11/sys/boot/efi/loader/arch/amd64/framebuffer.c stable/11/sys/boot/efi/loader/main.c stable/11/sys/boot/fdt/fdt_loader_cmd.c stable/11/sys/boot/forth/loader.4th stable/11/sys/boot/i386/Makefile.inc stable/11/sys/boot/i386/boot0/Makefile stable/11/sys/boot/i386/boot2/Makefile stable/11/sys/boot/i386/btx/btx/Makefile stable/11/sys/boot/i386/btx/btxldr/Makefile stable/11/sys/boot/i386/btx/btxldr/btxldr.S stable/11/sys/boot/i386/cdboot/Makefile stable/11/sys/boot/i386/gptboot/Makefile stable/11/sys/boot/i386/gptzfsboot/Makefile stable/11/sys/boot/i386/libi386/biosdisk.c stable/11/sys/boot/i386/libi386/pxe.c stable/11/sys/boot/i386/libi386/smbios.c stable/11/sys/boot/i386/mbr/Makefile stable/11/sys/boot/i386/pmbr/Makefile stable/11/sys/boot/i386/pxeldr/Makefile stable/11/sys/boot/i386/zfsboot/Makefile stable/11/sys/boot/ofw/libofw/ofw_time.c stable/11/sys/boot/pc98/Makefile.inc stable/11/sys/boot/pc98/boot0/Makefile stable/11/sys/boot/pc98/boot2/Makefile stable/11/sys/boot/pc98/btx/btx/Makefile stable/11/sys/boot/pc98/btx/btxldr/Makefile stable/11/sys/boot/pc98/cdboot/Makefile stable/11/sys/boot/powerpc/kboot/main.c stable/11/sys/boot/powerpc/ps3/main.c stable/11/sys/boot/uboot/lib/time.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/boot/common/bcache.c ============================================================================== --- stable/11/sys/boot/common/bcache.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/common/bcache.c Thu Feb 8 02:44:21 2018 (r329010) @@ -302,7 +302,9 @@ read_strategy(void *devdata, int rw, daddr_t blk, size break; } - size = i * bcache_blksize; + if (size > i * bcache_blksize) + size = i * bcache_blksize; + if (size != 0) { bcopy(bc->bcache_data + (bcache_blksize * BHASH(bc, blk)), buf, size); result = 0; Modified: stable/11/sys/boot/common/boot.c ============================================================================== --- stable/11/sys/boot/common/boot.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/common/boot.c Thu Feb 8 02:44:21 2018 (r329010) @@ -61,7 +61,8 @@ command_boot(int argc, char *argv[]) /* XXX maybe we should discard everything and start again? */ if (file_findfile(NULL, NULL) != NULL) { - sprintf(command_errbuf, "can't boot '%s', kernel module already loaded", argv[1]); + snprintf(command_errbuf, sizeof(command_errbuf), + "can't boot '%s', kernel module already loaded", argv[1]); return(CMD_ERROR); } @@ -129,7 +130,8 @@ command_autoboot(int argc, char *argv[]) case 2: howlong = strtol(argv[1], &cp, 0); if (*cp != 0) { - sprintf(command_errbuf, "bad delay '%s'", argv[1]); + snprintf(command_errbuf, sizeof(command_errbuf), + "bad delay '%s'", argv[1]); return(CMD_ERROR); } /* FALLTHROUGH */ Modified: stable/11/sys/boot/common/bootstrap.h ============================================================================== --- stable/11/sys/boot/common/bootstrap.h Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/common/bootstrap.h Thu Feb 8 02:44:21 2018 (r329010) @@ -35,8 +35,9 @@ /* Commands and return values; nonzero return sets command_errmsg != NULL */ typedef int (bootblk_cmd_t)(int argc, char *argv[]); +#define COMMAND_ERRBUFSZ (256) extern char *command_errmsg; -extern char command_errbuf[]; /* XXX blah, length */ +extern char command_errbuf[COMMAND_ERRBUFSZ]; #define CMD_OK 0 #define CMD_WARN 1 #define CMD_ERROR 2 Modified: stable/11/sys/boot/common/commands.c ============================================================================== --- stable/11/sys/boot/common/commands.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/common/commands.c Thu Feb 8 02:44:21 2018 (r329010) @@ -33,7 +33,8 @@ __FBSDID("$FreeBSD$"); #include "bootstrap.h" char *command_errmsg; -char command_errbuf[256]; /* XXX should have procedural interface for setting, size limit? */ +/* XXX should have procedural interface for setting, size limit? */ +char command_errbuf[COMMAND_ERRBUFSZ]; static int page_file(char *filename); @@ -196,7 +197,8 @@ command_help(int argc, char *argv[]) pager_close(); close(hfd); if (!matched) { - sprintf(command_errbuf, "no help available for '%s'", topic); + snprintf(command_errbuf, sizeof(command_errbuf), + "no help available for '%s'", topic); free(topic); if (subtopic) free(subtopic); @@ -276,7 +278,8 @@ command_show(int argc, char *argv[]) if ((cp = getenv(argv[1])) != NULL) { printf("%s\n", cp); } else { - sprintf(command_errbuf, "variable '%s' not found", argv[1]); + snprintf(command_errbuf, sizeof(command_errbuf), + "variable '%s' not found", argv[1]); return(CMD_ERROR); } } @@ -386,7 +389,8 @@ command_read(int argc, char *argv[]) case 't': timeout = strtol(optarg, &cp, 0); if (cp == optarg) { - sprintf(command_errbuf, "bad timeout '%s'", optarg); + snprintf(command_errbuf, sizeof(command_errbuf), + "bad timeout '%s'", optarg); return(CMD_ERROR); } break; @@ -454,8 +458,10 @@ page_file(char *filename) result = pager_file(filename); - if (result == -1) - sprintf(command_errbuf, "error showing %s", filename); + if (result == -1) { + snprintf(command_errbuf, sizeof(command_errbuf), + "error showing %s", filename); + } return result; } Modified: stable/11/sys/boot/common/interp.c ============================================================================== --- stable/11/sys/boot/common/interp.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/common/interp.c Thu Feb 8 02:44:21 2018 (r329010) @@ -214,7 +214,8 @@ include(const char *filename) #endif if (((fd = open(filename, O_RDONLY)) == -1)) { - sprintf(command_errbuf,"can't open '%s': %s", filename, strerror(errno)); + snprintf(command_errbuf, sizeof(command_errbuf), + "can't open '%s': %s", filename, strerror(errno)); return(CMD_ERROR); } @@ -256,8 +257,9 @@ include(const char *filename) script = script->next; free(se); } - sprintf(command_errbuf, "file '%s' line %d: memory allocation " - "failure - aborting", filename, line); + snprintf(command_errbuf, sizeof(command_errbuf), + "file '%s' line %d: memory allocation failure - aborting", + filename, line); return (CMD_ERROR); } strcpy(sp->text, cp); @@ -291,7 +293,9 @@ include(const char *filename) #ifdef BOOT_FORTH res = bf_run(sp->text); if (res != VM_OUTOFTEXT) { - sprintf(command_errbuf, "Error while including %s, in the line:\n%s", filename, sp->text); + snprintf(command_errbuf, sizeof(command_errbuf), + "Error while including %s, in the line:\n%s", + filename, sp->text); res = CMD_ERROR; break; } else Modified: stable/11/sys/boot/common/interp_forth.c ============================================================================== --- stable/11/sys/boot/common/interp_forth.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/common/interp_forth.c Thu Feb 8 02:44:21 2018 (r329010) @@ -324,13 +324,15 @@ bf_run(char *line) printf("Parse error!\n"); break; default: - /* Hopefully, all other codes filled this buffer */ - printf("%s\n", command_errmsg); + if (command_errmsg != NULL) { + printf("%s\n", command_errmsg); + command_errmsg = NULL; + } } if (result == VM_USEREXIT) panic("interpreter exit"); setenv("interpret", bf_vm->state ? "" : "OK", 1); - return result; + return (result); } Modified: stable/11/sys/boot/common/interp_parse.c ============================================================================== --- stable/11/sys/boot/common/interp_parse.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/common/interp_parse.c Thu Feb 8 02:44:21 2018 (r329010) @@ -72,20 +72,26 @@ isdelim(int ch) static int isquote(int ch) { - return (ch == '\'' || ch == '"'); + return (ch == '\''); } +static int +isdquote(int ch) +{ + return (ch == '"'); +} + int parse(int *argc, char ***argv, char *str) { int ac; char *val, *p, *q, *copy = NULL; size_t i = 0; - char token, tmp, quote, *buf; + char token, tmp, quote, dquote, *buf; enum { STR, VAR, WHITE } state; ac = *argc = 0; - quote = 0; + dquote = quote = 0; if (!str || (p = copy = backslash(str)) == NULL) return 1; @@ -105,9 +111,19 @@ parse(int *argc, char ***argv, char *str) buf[i++] = *p++; } else if (isquote(*p)) { quote = quote ? 0 : *p; - ++p; - } - else if (isspace(*p) && !quote) { + if (dquote) { /* keep quote */ + PARSE_FAIL(i == (PARSE_BUFSIZE - 1)); + buf[i++] = *p++; + } else + ++p; + } else if (isdquote(*p)) { + dquote = dquote ? 0 : *p; + if (quote) { /* keep dquote */ + PARSE_FAIL(i == (PARSE_BUFSIZE - 1)); + buf[i++] = *p++; + } else + ++p; + } else if (isspace(*p) && !quote && !dquote) { state = WHITE; if (i) { buf[i] = '\0'; @@ -115,7 +131,7 @@ parse(int *argc, char ***argv, char *str) i = 0; } ++p; - } else if (*p == '$') { + } else if (*p == '$' && !quote) { token = isdelim(*(p + 1)); if (token) p += 2; @@ -157,6 +173,8 @@ parse(int *argc, char ***argv, char *str) break; } } + /* missing terminating ' or " */ + PARSE_FAIL(quote || dquote); /* If at end of token, add it */ if (i && state == STR) { buf[i] = '\0'; Modified: stable/11/sys/boot/common/ls.c ============================================================================== --- stable/11/sys/boot/common/ls.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/common/ls.c Thu Feb 8 02:44:21 2018 (r329010) @@ -149,7 +149,8 @@ ls_getdir(char **pathp) /* Make sure the path is respectable to begin with */ if (archsw.arch_getdev(NULL, path, &cp)) { - sprintf(command_errbuf, "bad path '%s'", path); + snprintf(command_errbuf, sizeof(command_errbuf), + "bad path '%s'", path); goto out; } @@ -159,15 +160,18 @@ ls_getdir(char **pathp) fd = open(path, O_RDONLY); if (fd < 0) { - sprintf(command_errbuf, "open '%s' failed: %s", path, strerror(errno)); + snprintf(command_errbuf, sizeof(command_errbuf), + "open '%s' failed: %s", path, strerror(errno)); goto out; } if (fstat(fd, &sb) < 0) { - sprintf(command_errbuf, "stat failed: %s", strerror(errno)); + snprintf(command_errbuf, sizeof(command_errbuf), + "stat failed: %s", strerror(errno)); goto out; } if (!S_ISDIR(sb.st_mode)) { - sprintf(command_errbuf, "%s: %s", path, strerror(ENOTDIR)); + snprintf(command_errbuf, sizeof(command_errbuf), + "%s: %s", path, strerror(ENOTDIR)); goto out; } Modified: stable/11/sys/boot/common/module.c ============================================================================== --- stable/11/sys/boot/common/module.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/common/module.c Thu Feb 8 02:44:21 2018 (r329010) @@ -143,7 +143,8 @@ command_load(int argc, char *argv[]) fp = file_findfile(argv[1], typestr); if (fp) { - sprintf(command_errbuf, "warning: file '%s' already loaded", argv[1]); + snprintf(command_errbuf, sizeof(command_errbuf), + "warning: file '%s' already loaded", argv[1]); return (CMD_WARN); } @@ -162,7 +163,8 @@ command_load(int argc, char *argv[]) if (dokld || file_havepath(argv[1])) { error = mod_loadkld(argv[1], argc - 2, argv + 2); if (error == EEXIST) { - sprintf(command_errbuf, "warning: KLD '%s' already loaded", argv[1]); + snprintf(command_errbuf, sizeof(command_errbuf), + "warning: KLD '%s' already loaded", argv[1]); return (CMD_WARN); } @@ -173,7 +175,8 @@ command_load(int argc, char *argv[]) */ error = mod_load(argv[1], NULL, argc - 2, argv + 2); if (error == EEXIST) { - sprintf(command_errbuf, "warning: module '%s' already loaded", argv[1]); + snprintf(command_errbuf, sizeof(command_errbuf), + "warning: module '%s' already loaded", argv[1]); return (CMD_WARN); } @@ -203,7 +206,8 @@ command_load_geli(int argc, char *argv[]) case 'n': num = strtol(optarg, &cp, 0); if (cp == optarg) { - sprintf(command_errbuf, "bad key index '%s'", optarg); + snprintf(command_errbuf, sizeof(command_errbuf), + "bad key index '%s'", optarg); return(CMD_ERROR); } break; @@ -342,8 +346,8 @@ file_load(char *filename, vm_offset_t dest, struct pre if (error == EFTYPE) continue; /* Unknown to this handler? */ if (error) { - sprintf(command_errbuf, "can't load file '%s': %s", - filename, strerror(error)); + snprintf(command_errbuf, sizeof(command_errbuf), + "can't load file '%s': %s", filename, strerror(error)); break; } } @@ -379,8 +383,8 @@ file_load_dependencies(struct preloaded_file *base_fil */ mp = file_findmodule(NULL, dmodname, verinfo); if (mp == NULL) { - sprintf(command_errbuf, "module '%s' exists but with wrong version", - dmodname); + snprintf(command_errbuf, sizeof(command_errbuf), + "module '%s' exists but with wrong version", dmodname); error = ENOENT; break; } @@ -419,12 +423,14 @@ file_loadraw(const char *fname, char *type, int insert /* locate the file on the load path */ name = file_search(fname, NULL); if (name == NULL) { - sprintf(command_errbuf, "can't find '%s'", fname); + snprintf(command_errbuf, sizeof(command_errbuf), + "can't find '%s'", fname); return(NULL); } if ((fd = open(name, O_RDONLY)) < 0) { - sprintf(command_errbuf, "can't open '%s': %s", name, strerror(errno)); + snprintf(command_errbuf, sizeof(command_errbuf), + "can't open '%s': %s", name, strerror(errno)); free(name); return(NULL); } @@ -441,7 +447,8 @@ file_loadraw(const char *fname, char *type, int insert if (got == 0) /* end of file */ break; if (got < 0) { /* error */ - sprintf(command_errbuf, "error reading '%s': %s", name, strerror(errno)); + snprintf(command_errbuf, sizeof(command_errbuf), + "error reading '%s': %s", name, strerror(errno)); free(name); close(fd); return(NULL); @@ -495,13 +502,15 @@ mod_load(char *modname, struct mod_depend *verinfo, in free(mp->m_args); mp->m_args = unargv(argc, argv); #endif - sprintf(command_errbuf, "warning: module '%s' already loaded", mp->m_name); + snprintf(command_errbuf, sizeof(command_errbuf), + "warning: module '%s' already loaded", mp->m_name); return (0); } /* locate file with the module on the search path */ filename = mod_searchmodule(modname, verinfo); if (filename == NULL) { - sprintf(command_errbuf, "can't find '%s'", modname); + snprintf(command_errbuf, sizeof(command_errbuf), + "can't find '%s'", modname); return (ENOENT); } err = mod_loadkld(filename, argc, argv); @@ -524,7 +533,8 @@ mod_loadkld(const char *kldname, int argc, char *argv[ */ filename = file_search(kldname, kld_ext_list); if (filename == NULL) { - sprintf(command_errbuf, "can't find '%s'", kldname); + snprintf(command_errbuf, sizeof(command_errbuf), + "can't find '%s'", kldname); return (ENOENT); } /* @@ -532,7 +542,8 @@ mod_loadkld(const char *kldname, int argc, char *argv[ */ fp = file_findfile(filename, NULL); if (fp) { - sprintf(command_errbuf, "warning: KLD '%s' already loaded", filename); + snprintf(command_errbuf, sizeof(command_errbuf), + "warning: KLD '%s' already loaded", filename); free(filename); return (0); } @@ -556,8 +567,10 @@ mod_loadkld(const char *kldname, int argc, char *argv[ break; } } while(0); - if (err == EFTYPE) - sprintf(command_errbuf, "don't know how to load module '%s'", filename); + if (err == EFTYPE) { + snprintf(command_errbuf, sizeof(command_errbuf), + "don't know how to load module '%s'", filename); + } if (err && fp) file_discard(fp); free(filename); Modified: stable/11/sys/boot/common/ufsread.c ============================================================================== --- stable/11/sys/boot/common/ufsread.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/common/ufsread.c Thu Feb 8 02:44:21 2018 (r329010) @@ -97,21 +97,21 @@ static __inline uint8_t fsfind(const char *name, ufs_ino_t * ino) { static char buf[DEV_BSIZE]; - struct direct *d; + static struct direct d; char *s; ssize_t n; fs_off = 0; while ((n = fsread(*ino, buf, DEV_BSIZE)) > 0) for (s = buf; s < buf + DEV_BSIZE;) { - d = (void *)s; + memcpy(&d, s, sizeof(struct direct)); if (ls) - printf("%s ", d->d_name); - else if (!strcmp(name, d->d_name)) { - *ino = d->d_ino; - return d->d_type; + printf("%s ", d.d_name); + else if (!strcmp(name, d.d_name)) { + *ino = d.d_ino; + return d.d_type; } - s += d->d_reclen; + s += d.d_reclen; } if (n != -1 && ls) printf("\n"); Modified: stable/11/sys/boot/efi/boot1/boot1.c ============================================================================== --- stable/11/sys/boot/efi/boot1/boot1.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/efi/boot1/boot1.c Thu Feb 8 02:44:21 2018 (r329010) @@ -77,7 +77,8 @@ Malloc(size_t len, const char *file __unused, int line void Free(void *buf, const char *file __unused, int line __unused) { - (void)bs->FreePool(buf); + if (buf != NULL) + (void)bs->FreePool(buf); } /* Modified: stable/11/sys/boot/efi/libefi/efi_console.c ============================================================================== --- stable/11/sys/boot/efi/libefi/efi_console.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/efi/libefi/efi_console.c Thu Feb 8 02:44:21 2018 (r329010) @@ -51,6 +51,9 @@ void HO(void); void end_term(void); #endif +static EFI_INPUT_KEY key_cur; +static int key_pending; + static void efi_cons_probe(struct console *); static int efi_cons_init(int); void efi_cons_putchar(int); @@ -436,14 +439,20 @@ efi_cons_getchar() EFI_STATUS status; UINTN junk; - /* Try to read a key stroke. We wait for one if none is pending. */ - status = conin->ReadKeyStroke(conin, &key); - while (status == EFI_NOT_READY) { - /* Some EFI implementation (u-boot for example) do not support WaitForKey */ - if (conin->WaitForKey != NULL) - BS->WaitForEvent(1, &conin->WaitForKey, &junk); + if (key_pending) { + key = key_cur; + key_pending = 0; + } else { + /* Try to read a key stroke. We wait for one if none is pending. */ status = conin->ReadKeyStroke(conin, &key); + while (status == EFI_NOT_READY) { + /* Some EFI implementation (u-boot for example) do not support WaitForKey */ + if (conin->WaitForKey != NULL) + BS->WaitForEvent(1, &conin->WaitForKey, &junk); + status = conin->ReadKeyStroke(conin, &key); + } } + switch (key.ScanCode) { case 0x17: /* ESC */ return (0x1b); /* esc */ @@ -456,9 +465,20 @@ efi_cons_getchar() int efi_cons_poll() { + EFI_INPUT_KEY key; + EFI_STATUS status; - if (conin->WaitForKey == NULL) - return (1); + if (conin->WaitForKey == NULL) { + if (key_pending) + return (1); + status = conin->ReadKeyStroke(conin, &key); + if (status == EFI_SUCCESS) { + key_cur = key; + key_pending = 1; + } + return (key_pending); + } + /* This can clear the signaled state. */ return (BS->CheckEvent(conin->WaitForKey) == EFI_SUCCESS); } Modified: stable/11/sys/boot/efi/libefi/time.c ============================================================================== --- stable/11/sys/boot/efi/libefi/time.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/efi/libefi/time.c Thu Feb 8 02:44:21 2018 (r329010) @@ -228,7 +228,7 @@ time(time_t *tloc) } time_t -getsecs() +getsecs(void) { return time(0); } Modified: stable/11/sys/boot/efi/libefi/time_event.c ============================================================================== --- stable/11/sys/boot/efi/libefi/time_event.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/efi/libefi/time_event.c Thu Feb 8 02:44:21 2018 (r329010) @@ -76,7 +76,7 @@ time(time_t *tloc) } time_t -getsecs() +getsecs(void) { return time(0); } Modified: stable/11/sys/boot/efi/loader/arch/amd64/framebuffer.c ============================================================================== --- stable/11/sys/boot/efi/loader/arch/amd64/framebuffer.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/efi/loader/arch/amd64/framebuffer.c Thu Feb 8 02:44:21 2018 (r329010) @@ -474,8 +474,9 @@ command_gop(int argc, char *argv[]) status = BS->LocateProtocol(&gop_guid, NULL, (VOID **)&gop); if (EFI_ERROR(status)) { - sprintf(command_errbuf, "%s: Graphics Output Protocol not " - "present (error=%lu)", argv[0], EFI_ERROR_CODE(status)); + snprintf(command_errbuf, sizeof(command_errbuf), + "%s: Graphics Output Protocol not present (error=%lu)", + argv[0], EFI_ERROR_CODE(status)); return (CMD_ERROR); } @@ -494,9 +495,9 @@ command_gop(int argc, char *argv[]) } status = gop->SetMode(gop, mode); if (EFI_ERROR(status)) { - sprintf(command_errbuf, "%s: Unable to set mode to " - "%u (error=%lu)", argv[0], mode, - EFI_ERROR_CODE(status)); + snprintf(command_errbuf, sizeof(command_errbuf), + "%s: Unable to set mode to %u (error=%lu)", + argv[0], mode, EFI_ERROR_CODE(status)); return (CMD_ERROR); } } else if (!strcmp(argv[1], "get")) { @@ -526,8 +527,8 @@ command_gop(int argc, char *argv[]) return (CMD_OK); usage: - sprintf(command_errbuf, "usage: %s [list | get | set ]", - argv[0]); + snprintf(command_errbuf, sizeof(command_errbuf), + "usage: %s [list | get | set ]", argv[0]); return (CMD_ERROR); } @@ -542,8 +543,9 @@ command_uga(int argc, char *argv[]) status = BS->LocateProtocol(&uga_guid, NULL, (VOID **)&uga); if (EFI_ERROR(status)) { - sprintf(command_errbuf, "%s: UGA Protocol not present " - "(error=%lu)", argv[0], EFI_ERROR_CODE(status)); + snprintf(command_errbuf, sizeof(command_errbuf), + "%s: UGA Protocol not present (error=%lu)", + argv[0], EFI_ERROR_CODE(status)); return (CMD_ERROR); } @@ -551,8 +553,8 @@ command_uga(int argc, char *argv[]) goto usage; if (efifb_from_uga(&efifb, uga) != CMD_OK) { - sprintf(command_errbuf, "%s: Unable to get UGA information", - argv[0]); + snprintf(command_errbuf, sizeof(command_errbuf), + "%s: Unable to get UGA information", argv[0]); return (CMD_ERROR); } @@ -561,6 +563,6 @@ command_uga(int argc, char *argv[]) return (CMD_OK); usage: - sprintf(command_errbuf, "usage: %s", argv[0]); + snprintf(command_errbuf, sizeof(command_errbuf), "usage: %s", argv[0]); return (CMD_ERROR); } Modified: stable/11/sys/boot/efi/loader/main.c ============================================================================== --- stable/11/sys/boot/efi/loader/main.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/efi/loader/main.c Thu Feb 8 02:44:21 2018 (r329010) @@ -828,8 +828,10 @@ command_efi_show(int argc, char *argv[]) EFI_GUID varguid = { 0,0,0,{0,0,0,0,0,0,0,0} }; EFI_GUID matchguid = { 0,0,0,{0,0,0,0,0,0,0,0} }; uint32_t uuid_status; - CHAR16 varname[128]; + CHAR16 *varname; + CHAR16 *newnm; CHAR16 varnamearg[128]; + UINTN varalloc; UINTN varsz; while ((ch = getopt(argc, argv, "ag:lv:")) != -1) { @@ -924,10 +926,33 @@ command_efi_show(int argc, char *argv[]) * to specify the initial call must be a poiner to a NULL * character. */ - varsz = nitems(varname); + varalloc = 1024; + varname = malloc(varalloc); + if (varname == NULL) { + printf("Can't allocate memory to get variables\n"); + pager_close(); + return (CMD_ERROR); + } varname[0] = 0; - while ((status = RS->GetNextVariableName(&varsz, varname, &varguid)) != - EFI_NOT_FOUND) { + while (1) { + varsz = varalloc; + status = RS->GetNextVariableName(&varsz, varname, &varguid); + if (status == EFI_BUFFER_TOO_SMALL) { + varalloc = varsz; + newnm = malloc(varalloc); + if (newnm == NULL) { + printf("Can't allocate memory to get variables\n"); + free(varname); + pager_close(); + return (CMD_ERROR); + } + memcpy(newnm, varname, varsz); + free(varname); + varname = newnm; + continue; /* Try again with bigger buffer */ + } + if (status != EFI_SUCCESS) + break; if (aflag) { if (efi_print_var(varname, &varguid, lflag) != CMD_OK) break; @@ -948,6 +973,7 @@ command_efi_show(int argc, char *argv[]) } } } + free(varname); pager_close(); return (CMD_OK); Modified: stable/11/sys/boot/fdt/fdt_loader_cmd.c ============================================================================== --- stable/11/sys/boot/fdt/fdt_loader_cmd.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/fdt/fdt_loader_cmd.c Thu Feb 8 02:44:21 2018 (r329010) @@ -195,14 +195,14 @@ fdt_load_dtb(vm_offset_t va) COPYOUT(va, &header, sizeof(header)); err = fdt_check_header(&header); if (err < 0) { - if (err == -FDT_ERR_BADVERSION) - sprintf(command_errbuf, + if (err == -FDT_ERR_BADVERSION) { + snprintf(command_errbuf, sizeof(command_errbuf), "incompatible blob version: %d, should be: %d", fdt_version(fdtp), FDT_LAST_SUPPORTED_VERSION); - - else - sprintf(command_errbuf, "error validating blob: %s", - fdt_strerror(err)); + } else { + snprintf(command_errbuf, sizeof(command_errbuf), + "error validating blob: %s", fdt_strerror(err)); + } return (1); } @@ -237,8 +237,8 @@ fdt_load_dtb_addr(struct fdt_header *header) fdtp_size = fdt_totalsize(header); err = fdt_check_header(header); if (err < 0) { - sprintf(command_errbuf, "error validating blob: %s", - fdt_strerror(err)); + snprintf(command_errbuf, sizeof(command_errbuf), + "error validating blob: %s", fdt_strerror(err)); return (err); } free(fdtp); @@ -264,7 +264,8 @@ fdt_load_dtb_file(const char * filename) /* Attempt to load and validate a new dtb from a file. */ if ((bfp = file_loadraw(filename, "dtb", 1)) == NULL) { - sprintf(command_errbuf, "failed to load file '%s'", filename); + snprintf(command_errbuf, sizeof(command_errbuf), + "failed to load file '%s'", filename); return (1); } if ((err = fdt_load_dtb(bfp->f_addr)) != 0) { @@ -659,7 +660,8 @@ fdt_fixup_memory(struct fdt_mem_region *region, size_t /* Create proper '/memory' node. */ memory = fdt_add_subnode(fdtp, root, "memory"); if (memory <= 0) { - sprintf(command_errbuf, "Could not fixup '/memory' " + snprintf(command_errbuf, sizeof(command_errbuf), + "Could not fixup '/memory' " "node, error code : %d!\n", memory); return; } @@ -676,7 +678,8 @@ fdt_fixup_memory(struct fdt_mem_region *region, size_t size_cellsp = (uint32_t *)fdt_getprop(fdtp, root, "#size-cells", NULL); if (addr_cellsp == NULL || size_cellsp == NULL) { - sprintf(command_errbuf, "Could not fixup '/memory' node : " + snprintf(command_errbuf, sizeof(command_errbuf), + "Could not fixup '/memory' node : " "%s %s property not found in root node!\n", (!addr_cellsp) ? "#address-cells" : "", (!size_cellsp) ? "#size-cells" : ""); @@ -975,7 +978,8 @@ fdt_cmd_addr(int argc, char *argv[]) hdr = (struct fdt_header *)strtoul(addr, &cp, 16); if (cp == addr) { - sprintf(command_errbuf, "Invalid address: %s", addr); + snprintf(command_errbuf, sizeof(command_errbuf), + "Invalid address: %s", addr); return (CMD_ERROR); } @@ -1014,7 +1018,8 @@ fdt_cmd_cd(int argc, char *argv[]) o = fdt_path_offset(fdtp, path); if (o < 0) { - sprintf(command_errbuf, "could not find node: '%s'", path); + snprintf(command_errbuf, sizeof(command_errbuf), + "could not find node: '%s'", path); return (CMD_ERROR); } @@ -1022,8 +1027,8 @@ fdt_cmd_cd(int argc, char *argv[]) return (CMD_OK); fail: - sprintf(command_errbuf, "path too long: %d, max allowed: %d", - len, FDT_CWD_LEN - 1); + snprintf(command_errbuf, sizeof(command_errbuf), + "path too long: %d, max allowed: %d", len, FDT_CWD_LEN - 1); return (CMD_ERROR); } @@ -1106,7 +1111,8 @@ fdt_cmd_ls(int argc, char *argv[]) o = fdt_path_offset(fdtp, path); if (o < 0) { - sprintf(command_errbuf, "could not find node: '%s'", path); + snprintf(command_errbuf, sizeof(command_errbuf), + "could not find node: '%s'", path); return (CMD_ERROR); } @@ -1552,7 +1558,8 @@ fdt_extract_nameloc(char **pathp, char **namep, int *n return (1); } if (o < 0) { - sprintf(command_errbuf, "could not find node: '%s'", path); + snprintf(command_errbuf, sizeof(command_errbuf), + "could not find node: '%s'", path); return (1); } *namep = name; @@ -1599,7 +1606,8 @@ fdt_cmd_prop(int argc, char *argv[]) o = fdt_path_offset(fdtp, path); if (o < 0) { - sprintf(command_errbuf, "could not find node: '%s'", path); + snprintf(command_errbuf, sizeof(command_errbuf), + "could not find node: '%s'", path); rv = CMD_ERROR; goto out; } @@ -1692,8 +1700,9 @@ fdt_cmd_rm(int argc, char *argv[]) return (CMD_ERROR); if ((rv = fdt_delprop(fdtp, o, propname)) != 0) { - sprintf(command_errbuf, "could not delete" - "%s\n", (rv == -FDT_ERR_NOTFOUND) ? + snprintf(command_errbuf, sizeof(command_errbuf), + "could not delete %s\n", + (rv == -FDT_ERR_NOTFOUND) ? "(property/node does not exist)" : ""); return (CMD_ERROR); Modified: stable/11/sys/boot/forth/loader.4th ============================================================================== --- stable/11/sys/boot/forth/loader.4th Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/forth/loader.4th Thu Feb 8 02:44:21 2018 (r329010) @@ -143,6 +143,8 @@ only forth definitions also support-functions s" /boot/defaults/loader.conf" initialize include_conf_files include_nextboot_file + \ If the user defined a post-initialize hook, call it now + s" post-initialize" sfind if execute else drop then \ Will *NOT* try to load kernel and modules if no configuration file \ was successfully loaded! any_conf_read? if @@ -165,12 +167,14 @@ only forth definitions also support-functions \ \ Overrides support.4th initialization word with one that does \ everything start one does, short of loading the kernel and -\ modules. Returns a flag +\ modules. Returns a flag. : initialize ( -- flag ) s" /boot/defaults/loader.conf" initialize include_conf_files include_nextboot_file + \ If the user defined a post-initialize hook, call it now + s" post-initialize" sfind if execute else drop then any_conf_read? ; Modified: stable/11/sys/boot/i386/Makefile.inc ============================================================================== --- stable/11/sys/boot/i386/Makefile.inc Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/i386/Makefile.inc Thu Feb 8 02:44:21 2018 (r329010) @@ -28,4 +28,9 @@ BTXLDR= ${BTXDIR}/btxldr/btxldr BTXKERN= ${BTXDIR}/btx/btx BTXCRT= ${BTXDIR}/lib/crt0.o +# compact binary with no padding between text, data, bss +LDSCRIPT= ${SRCTOP}/sys/boot/i386/boot.ldscript +LDFLAGS_BIN=-e start -Ttext ${ORG} -Wl,-T,${LDSCRIPT},-S,--oformat,binary +LD_FLAGS_BIN=-static -T ${LDSCRIPT} --gc-sections + .include "../Makefile.inc" Copied: stable/11/sys/boot/i386/boot.ldscript (from r305353, head/sys/boot/i386/boot.ldscript) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/boot/i386/boot.ldscript Thu Feb 8 02:44:21 2018 (r329010, copy of r305353, head/sys/boot/i386/boot.ldscript) @@ -0,0 +1,11 @@ +/* $FreeBSD$ */ +/* Merge text, data and bss together almost no padding */ +OUTPUT_FORMAT("elf32-i386-freebsd") +OUTPUT_ARCH(i386) +ENTRY(_start) +SECTIONS { + . = 0x08048000 + SIZEOF_HEADERS; + .text : { *(.text) } =0x90909090 /* Pad with nops, if needed */ + .data : { *(.data) } _edata = .; + .bss : { *(.bss) } _end = .; +} Modified: stable/11/sys/boot/i386/boot0/Makefile ============================================================================== --- stable/11/sys/boot/i386/boot0/Makefile Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/i386/boot0/Makefile Thu Feb 8 02:44:21 2018 (r329010) @@ -40,6 +40,7 @@ BOOT_BOOT0_TICKS?= 0xb6 # The base address that we the boot0 code to to run it. Don't change this # unless you are glutton for punishment. BOOT_BOOT0_ORG?= 0x600 +ORG=${BOOT_BOOT0_ORG} # Comm settings for boot0sio. # Bit(s) Description @@ -74,7 +75,7 @@ CFLAGS+=-DFLAGS=${BOOT_BOOT0_FLAGS} \ -DTICKS=${BOOT_BOOT0_TICKS} \ -DCOMSPEED=${BOOT_BOOT0_COMCONSOLE_SPEED} -LDFLAGS=-e start -Ttext ${BOOT_BOOT0_ORG} -Wl,-N,-S,--oformat,binary +LDFLAGS=${LDFLAGS_BIN} .include Modified: stable/11/sys/boot/i386/boot2/Makefile ============================================================================== --- stable/11/sys/boot/i386/boot2/Makefile Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/i386/boot2/Makefile Thu Feb 8 02:44:21 2018 (r329010) @@ -49,7 +49,7 @@ CFLAGS.gcc+= -mno-align-long-strings CFLAGS.clang+= -Oz ${CLANG_OPT_SMALL} -LD_FLAGS=-static -N --gc-sections +LD_FLAGS=${LD_FLAGS_BIN} # Pick up ../Makefile.inc early. .include Modified: stable/11/sys/boot/i386/btx/btx/Makefile ============================================================================== --- stable/11/sys/boot/i386/btx/btx/Makefile Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/i386/btx/btx/Makefile Thu Feb 8 02:44:21 2018 (r329010) @@ -25,7 +25,7 @@ CFLAGS+=-DBTX_SERIAL -DSIOPRT=${BOOT_COMCONSOLE_PORT} ORG= 0x9000 -LDFLAGS=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary +LDFLAGS=${LDFLAGS_BIN} .include Modified: stable/11/sys/boot/i386/btx/btxldr/Makefile ============================================================================== --- stable/11/sys/boot/i386/btx/btxldr/Makefile Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/i386/btx/btxldr/Makefile Thu Feb 8 02:44:21 2018 (r329010) @@ -12,7 +12,8 @@ CFLAGS+=-I${.CURDIR}/../../common CFLAGS+=-DBTXLDR_VERBOSE .endif -LDFLAGS=-e start -Ttext ${LOADER_ADDRESS} -Wl,-N,-S,--oformat,binary +ORG=${LOADER_ADDRESS} +LDFLAGS=${LDFLAGS_BIN} .include Modified: stable/11/sys/boot/i386/btx/btxldr/btxldr.S ============================================================================== --- stable/11/sys/boot/i386/btx/btxldr/btxldr.S Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/i386/btx/btxldr/btxldr.S Thu Feb 8 02:44:21 2018 (r329010) @@ -376,12 +376,12 @@ e_fmt: .asciz "Error: Client format not supported\n" #ifdef BTXLDR_VERBOSE m_mem: .asciz "Starting in protected mode (base mem=\0)\n" m_esp: .asciz "Arguments passed (esp=\0):\n" -m_args: .asciz"\n" +m_args: .asciz "\n" m_rel_bi: .asciz "Relocated bootinfo (size=48) to \0\n" m_rel_args: .asciz "Relocated arguments (size=18) to \0\n" m_rel_btx: .asciz "Relocated kernel (size=\0) to \0\n" Modified: stable/11/sys/boot/i386/cdboot/Makefile ============================================================================== --- stable/11/sys/boot/i386/cdboot/Makefile Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/i386/cdboot/Makefile Thu Feb 8 02:44:21 2018 (r329010) @@ -10,7 +10,7 @@ CFLAGS+=-I${.CURDIR}/../common ORG= 0x7c00 -LDFLAGS=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary +LDFLAGS=${LDFLAGS_BIN} .include Modified: stable/11/sys/boot/i386/gptboot/Makefile ============================================================================== --- stable/11/sys/boot/i386/gptboot/Makefile Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/i386/gptboot/Makefile Thu Feb 8 02:44:21 2018 (r329010) @@ -47,7 +47,7 @@ LIBGELIBOOT= ${.OBJDIR}/../../geli/libgeliboot.a OPENCRYPTO_XTS= xform_aes_xts.o .endif -LD_FLAGS=-static -N --gc-sections +LD_FLAGS=${LD_FLAGS_BIN} LIBSTAND= ${.OBJDIR}/../../libstand32/libstand.a Modified: stable/11/sys/boot/i386/gptzfsboot/Makefile ============================================================================== --- stable/11/sys/boot/i386/gptzfsboot/Makefile Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/i386/gptzfsboot/Makefile Thu Feb 8 02:44:21 2018 (r329010) @@ -56,7 +56,7 @@ OPENCRYPTO_XTS= xform_aes_xts.o CFLAGS.gcc+= --param max-inline-insns-single=100 -LD_FLAGS=-static -N --gc-sections +LD_FLAGS=${LD_FLAGS_BIN} LIBSTAND= ${.OBJDIR}/../../libstand32/libstand.a Modified: stable/11/sys/boot/i386/libi386/biosdisk.c ============================================================================== --- stable/11/sys/boot/i386/libi386/biosdisk.c Thu Feb 8 01:34:35 2018 (r329009) +++ stable/11/sys/boot/i386/libi386/biosdisk.c Thu Feb 8 02:44:21 2018 (r329010) @@ -244,6 +244,7 @@ static int bd_int13probe(struct bdinfo *bd) { struct edd_params params; + int ret = 1; /* assume success */ v86.ctl = V86_FLAGS; v86.addr = 0x13; @@ -251,11 +252,14 @@ bd_int13probe(struct bdinfo *bd) v86.edx = bd->bd_unit; v86int(); + /* Don't error out if we get bad sector number, try EDD as well */ if (V86_CY(v86.efl) || /* carry set */ - (v86.ecx & 0x3f) == 0 || /* absurd sector number */ (v86.edx & 0xff) <= (unsigned)(bd->bd_unit & 0x7f)) /* unit # bad */ return (0); /* skip device */ + if ((v86.ecx & 0x3f) == 0) /* absurd sector number */ + ret = 0; /* set error */ + /* Convert max cyl # -> # of cylinders */ bd->bd_cyl = ((v86.ecx & 0xc0) << 2) + ((v86.ecx & 0xff00) >> 8) + 1; /* Convert max head # -> # of heads */ @@ -280,7 +284,8 @@ bd_int13probe(struct bdinfo *bd) if (V86_CY(v86.efl) || /* carry set */ (v86.ebx & 0xffff) != 0xaa55 || /* signature */ (v86.ecx & EDD_INTERFACE_FIXED_DISK) == 0) - return (1); + return (ret); /* return code from int13 AH=08 */ + /* EDD supported */ bd->bd_flags |= BD_MODEEDD1; if ((v86.eax & 0xff00) >= 0x3000) @@ -295,12 +300,22 @@ bd_int13probe(struct bdinfo *bd) v86.esi = VTOPOFF(¶ms); v86int(); if (!V86_CY(v86.efl)) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Thu Feb 8 06:17:15 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 19377F066CA for ; Thu, 8 Feb 2018 06:17:15 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x235.google.com (mail-it0-x235.google.com [IPv6:2607:f8b0:4001:c0b::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9DFE27550C for ; Thu, 8 Feb 2018 06:17:14 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x235.google.com with SMTP id i144so5296597ita.3 for ; Wed, 07 Feb 2018 22:17:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=rW4MdzbfNZJnEED8dTqBakCc/jPY74pEaBbqi3Diydw=; b=ZXpF77t5GwSLu6Me/nkJULo2xmaut5DqgMWRCsYzV0dL+Bk1rQfD6Cul69qI7QCuY+ TVb9pu0HVL/iE25H7fftcB8HrHl0hghB/Lw2bMnOl9sMauCSSapZFOTQEf7f1RbxdqeG sXAL59peB42dz2Xt4gDEzUfDNWI4/4Ig13hp88kWsKh7wt3SVUPKqnzBHZOMTJ/A21Y7 4dFfTgp6Q3XRNBTmZ0AdnnnHax/DcMRWt86S6M25ekCnilfAmfengT5NUOvMWB/mIDQE pL1TSXiJ02hFLzPSCvSPqAe68iHWEXT4nCxKuWDwHkbTo4EOhvWuNvuifWtmdlBW7wV8 a7nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=rW4MdzbfNZJnEED8dTqBakCc/jPY74pEaBbqi3Diydw=; b=DJHGOLh3aYO7pDjueV56fTxKvrpbVKgSPrSjvETs7CLWUvWIwzleWUXwAsWWOTFAf+ tUJWhUOcjhFnaH/JVeW5coe6ntZkqjQdyiP0JiSFCyfZjtAEUiPzeT7sqVjyLuhMiAw4 LvsUENNTmOZ9GjV31o3eUZfhup53bJFNWqz5fkTdnkutCSxXHm98tGcvusT4ik2aGOYP bulnP0uvSLckbbalPRAIvn8psM90FUKHydeuU+JrB8taTI3bcnPGCX0QWTLTVGudn2O6 +tvVWA0ScF+OHxlLeF479NgMoM+4JBhG3DnskuN8nfUziNwOw6Bx5MIh0XKjuNuR7T/H tL+Q== X-Gm-Message-State: APf1xPBP+PvzkJSXq8o0B+Ow9HaGmDoeMF4Ph2IKk2mW2Dnv/aOAK+1J /Pw0RtjTweTAIARy42A75eFPUgRR65ELtb8AWDS/Gg== X-Google-Smtp-Source: AH8x225XZGjzIGjKmUKCU2/BaVwnNAIKAgW/GI9HnnIDng/586Q/20fmvK9S1J+OE7GByQjPoMPJkZpsEMRxQuqXl4o= X-Received: by 10.36.250.193 with SMTP id v184mr10241ith.64.1518070633803; Wed, 07 Feb 2018 22:17:13 -0800 (PST) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.201.67 with HTTP; Wed, 7 Feb 2018 22:17:12 -0800 (PST) X-Originating-IP: [2603:300b:6:5100:c81d:c97b:c7cd:ac64] Received: by 10.79.201.67 with HTTP; Wed, 7 Feb 2018 22:17:12 -0800 (PST) In-Reply-To: References: <201802080250.w182olh7097879@repo.freebsd.org> From: Warner Losh Date: Wed, 7 Feb 2018 23:17:12 -0700 X-Google-Sender-Auth: wDZ5aO-NFtI1OUlHZqbWxAwVCbM Message-ID: Subject: Re: svn commit: r329011 - in stable/11: sys/boot sys/boot/common sys/boot/efi/libefi sys/boot/efi/loader sys/boot/efi/loader/arch/amd64 sys/boot/efi/loader/arch/arm sys/boot/efi/loader/arch/arm64 sys/b... To: Kyle Evans Cc: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 06:17:15 -0000 On Feb 7, 2018 8:23 PM, "Kyle Evans" wrote: On Wed, Feb 7, 2018 at 8:50 PM, Kyle Evans wrote: > Author: kevans > Date: Thu Feb 8 02:50:47 2018 > New Revision: 329011 > URL: https://svnweb.freebsd.org/changeset/base/329011 > > Log: > MFC r307322,r307323,r307324,r307326,r307327,r307338, r307879,r307908,r307911, > r307942,r307950,r307951,r307954,r307955,r308125,r308195,r308476,r308534, > r308535,r308776,r308843,r310236,r310726: Loader fixes, 2016q4 > > r307322: Remove /boot/boot.conf, deprecated for 16 years > > r307323: Remove fetching of pInterp. > > r307324: Create a new linker set, Xficl_compile_set which contains a list of > functions to call to register new forth words. > > r307326: In UEFI mode expose the SMBIOS anchor base address via kenv > > r307327: Update i386 build of loader.efi (but leave it disabled) so that we > at least build it now. > > r307338: Create a pcibios-version environment FORTH word. > > r307879: Preliminary support for EFI in boot loader. > > r307908: Fix the build on both arm64 and when WITHOUT_FORTH is defined. > > r307911: Add better comment... > > r307942: Really make WITHOUT_FORTH (MK_FORTH==no) work. > > r307950: Add it (Makefile.ficl) to the right place > > r307951: Fix two backwards tests. > > r307954: Back out the move to the loader script from -N. > > r307955: LIBSTAND goes last, so put it last here too. > > r308125: In loader.efi, instead of exiting directly, try to fallback. > > r308195: efinet_dev_print should honor verbose option. > > r308476: boot/forth spelling issue in forth word > > r308534: The file_loadraw function grew an argument, update install function > > r308535: Add support for LOADER_RC setting in the pkgfs manifes > > r308776: loader: zfs toplevel vdev must have spa set. > > r308843: loader: smbios version check is not correct > > r310236: Renumber license clauses to avoid skipping #3 > > r310726: cdboot: add explict suffix to ambiguous or instruction > > PR: 214375 > Just as an FYI- this is the format that I intend to do these MFC's of sys/boot work in. The intention is to batch these up by fiscal quarter while we're playing catch up since there are so many (450+) commits that need to make it back before we hit 2018Q1. I will be preparing batches and committing every couple of days, two batches at a time. Please do speak up before the next batches (likely to be committed in the Friday/Saturday time frame) if this format is particularly appalling. Thanks for tackling this. It means we might just have Lau as an option for the boot loader in 11.2. Warner From owner-svn-src-stable-11@freebsd.org Thu Feb 8 09:32:41 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 324F0F1310A; Thu, 8 Feb 2018 09:32:41 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9AC5F7D7D4; Thu, 8 Feb 2018 09:32:39 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w189WSD0025126; Thu, 8 Feb 2018 01:32:28 -0800 (PST) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w189WMHZ025125; Thu, 8 Feb 2018 01:32:22 -0800 (PST) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201802080932.w189WMHZ025125@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r329011 - in stable/11: sys/boot sys/boot/common sys/boot/efi/libefi sys/boot/efi/loader sys/boot/efi/loader/arch/amd64 sys/boot/efi/loader/arch/arm sys/boot/efi/loader/arch/arm64 sys/b... In-Reply-To: To: Kyle Evans Date: Thu, 8 Feb 2018 01:32:22 -0800 (PST) CC: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 09:32:41 -0000 > On Wed, Feb 7, 2018 at 8:50 PM, Kyle Evans wrote: > > Author: kevans > > Date: Thu Feb 8 02:50:47 2018 > > New Revision: 329011 > > URL: https://svnweb.freebsd.org/changeset/base/329011 > > > > Log: Log: MFC Loader fixes, 2016q4: r307322,r307323,... This helps to see things easier in the websvn interface, otherwise your just seeing a long list not telling you much. > > MFC r307322,r307323,r307324,r307326,r307327,r307338,r307879,r307908,r307911, > > r307942,r307950,r307951,r307954,r307955,r308125,r308195,r308476,r308534, > > r308535,r308776,r308843,r310236,r310726: Loader fixes, 2016q4 > > > > r307322: Remove /boot/boot.conf, deprecated for 16 years ... > > Just as an FYI- this is the format that I intend to do these MFC's of > sys/boot work in. The intention is to batch these up by fiscal quarter > while we're playing catch up since there are so many (450+) commits > that need to make it back before we hit 2018Q1. I will be preparing > batches and committing every couple of days, two batches at a time. > Please do speak up before the next batches (likely to be committed in > the Friday/Saturday time frame) if this format is particularly > appalling. This format is particualarly pleasing from the apperance here in the email, though the slight change above would make it a bit easier to know what one is looking at in the svnweb interface. The very first line of a Log: is what one sees when walking down the hierarchy in svnweb. Go here to see a sample of why I would like to have you re-order the text: https://svnweb.freebsd.org/base/stable/11/sys/boot/efi/ Thanks, -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-stable-11@freebsd.org Thu Feb 8 13:56:56 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 00370F05C49; Thu, 8 Feb 2018 13:56:55 +0000 (UTC) (envelope-from byond.lenox@gmail.com) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com [209.85.215.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6568A692ED; Thu, 8 Feb 2018 13:56:55 +0000 (UTC) (envelope-from byond.lenox@gmail.com) Received: by mail-lf0-f43.google.com with SMTP id o89so6506078lfg.10; Thu, 08 Feb 2018 05:56:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Ca0t/iVoRdrmEsBwkeQf6zY3enNr5wV0C581IJGktT0=; b=aUjsnbWABMz0Rk7Mo/zpmfNBlMH1iM/SauNJA2ZEc4noJ2/T/s5E9co5W6M87H4NgP XrsFilDzCJkUwWIo7A/9arrI6kbsvaqFRSqECWM4FDqMSrlbEOLdafNYUsdxjRy9sEDC 4QS9/9c3w0b/46fz7NXiGo5Qh7cHQ/mX7/Lr7AtjgZPNPOACpWnwyg7wqOcdumSPPBym admIgFBlHqf/3nlblHIn8OZWiUuV5d1F3GV6RTUJmTx+ZN32+U2x89jzWwf6M5le8ZpL skOmLohEbWbzACYSzQ/K+ZLBnbwZdkR1T+2Jrjdvr95p2IUSLph0btwyYxP403f15j3p wzAA== X-Gm-Message-State: APf1xPD/M8bCT+wzvTfohHsP78Iyj7TrWxCiVJEThuVH23nxj3mUQNRY KBmtnKMskY6YQNUt1uG4cBoYh1cY X-Google-Smtp-Source: AH8x2253BMda6QhmZaaNtKG6wQa64s6lvIYL+6eDzUW/hPg8IBC2AS6uSWcdkVjYgshMSZ2PVt8IHg== X-Received: by 10.25.205.148 with SMTP id d142mr602703lfg.9.1518098213424; Thu, 08 Feb 2018 05:56:53 -0800 (PST) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com. [209.85.215.49]) by smtp.gmail.com with ESMTPSA id m18sm7421lfj.34.2018.02.08.05.56.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Feb 2018 05:56:53 -0800 (PST) Received: by mail-lf0-f49.google.com with SMTP id q194so6501374lfe.13; Thu, 08 Feb 2018 05:56:53 -0800 (PST) X-Received: by 10.46.23.215 with SMTP id 84mr558754ljx.29.1518098212867; Thu, 08 Feb 2018 05:56:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.46.106.8 with HTTP; Thu, 8 Feb 2018 05:56:32 -0800 (PST) In-Reply-To: <201802080932.w189WMHZ025125@pdx.rh.CN85.dnsmgr.net> References: <201802080932.w189WMHZ025125@pdx.rh.CN85.dnsmgr.net> From: Kyle Evans Date: Thu, 8 Feb 2018 07:56:32 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r329011 - in stable/11: sys/boot sys/boot/common sys/boot/efi/libefi sys/boot/efi/loader sys/boot/efi/loader/arch/amd64 sys/boot/efi/loader/arch/arm sys/boot/efi/loader/arch/arm64 sys/b... To: rgrimes@freebsd.org Cc: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 13:56:56 -0000 On Thu, Feb 8, 2018 at 3:32 AM, Rodney W. Grimes wrote: >> On Wed, Feb 7, 2018 at 8:50 PM, Kyle Evans wrote: >> > Author: kevans >> > Date: Thu Feb 8 02:50:47 2018 >> > New Revision: 329011 >> > URL: https://svnweb.freebsd.org/changeset/base/329011 >> > >> > Log: > Log: > MFC Loader fixes, 2016q4: r307322,r307323,... > > This helps to see things easier in the websvn interface, otherwise > your just seeing a long list not telling you much. > > >> > MFC r307322,r307323,r307324,r307326,r307327,r307338,r307879,r307908,r307911, >> > r307942,r307950,r307951,r307954,r307955,r308125,r308195,r308476,r308534, >> > r308535,r308776,r308843,r310236,r310726: Loader fixes, 2016q4 >> > >> > r307322: Remove /boot/boot.conf, deprecated for 16 years > ... > >> >> Just as an FYI- this is the format that I intend to do these MFC's of >> sys/boot work in. The intention is to batch these up by fiscal quarter >> while we're playing catch up since there are so many (450+) commits >> that need to make it back before we hit 2018Q1. I will be preparing >> batches and committing every couple of days, two batches at a time. >> Please do speak up before the next batches (likely to be committed in >> the Friday/Saturday time frame) if this format is particularly >> appalling. > > This format is particualarly pleasing from the apperance here in the email, > though the slight change above would make it a bit easier to know what > one is looking at in the svnweb interface. > > The very first line of a Log: is what one sees when walking down the > hierarchy in svnweb. > > Go here to see a sample of why I would like to have you re-order the > text: > https://svnweb.freebsd.org/base/stable/11/sys/boot/efi/ > Right, I see what you mean- that's even more worthless than "Loader fixes, 2016q4" as far as context goes. I'll adjust future batch messages accordingly. Thanks! From owner-svn-src-stable-11@freebsd.org Thu Feb 8 14:39:08 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 19EB2F08E29; Thu, 8 Feb 2018 14:39:08 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BAF2D6AF05; Thu, 8 Feb 2018 14:39:07 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B5AED17444; Thu, 8 Feb 2018 14:39:07 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w18Ed7MC052551; Thu, 8 Feb 2018 14:39:07 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w18Ed7jO052547; Thu, 8 Feb 2018 14:39:07 GMT (envelope-from np@FreeBSD.org) Message-Id: <201802081439.w18Ed7jO052547@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Thu, 8 Feb 2018 14:39:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329017 - stable/11/sys/dev/cxgbe/iw_cxgbe X-SVN-Group: stable-11 X-SVN-Commit-Author: np X-SVN-Commit-Paths: stable/11/sys/dev/cxgbe/iw_cxgbe X-SVN-Commit-Revision: 329017 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 14:39:08 -0000 Author: np Date: Thu Feb 8 14:39:07 2018 New Revision: 329017 URL: https://svnweb.freebsd.org/changeset/base/329017 Log: iw_cxgbe: Manually backport changes related to QP flush. This fixes a panic where poll_cq sees an empty RQ while processing an incoming SEND for a QP that is being taken down. This is a direct commit to stable/11. Sponsored by: Chelsio Communications Modified: stable/11/sys/dev/cxgbe/iw_cxgbe/cq.c stable/11/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h stable/11/sys/dev/cxgbe/iw_cxgbe/qp.c stable/11/sys/dev/cxgbe/iw_cxgbe/t4.h Modified: stable/11/sys/dev/cxgbe/iw_cxgbe/cq.c ============================================================================== --- stable/11/sys/dev/cxgbe/iw_cxgbe/cq.c Thu Feb 8 13:22:40 2018 (r329016) +++ stable/11/sys/dev/cxgbe/iw_cxgbe/cq.c Thu Feb 8 14:39:07 2018 (r329017) @@ -245,137 +245,82 @@ static void insert_sq_cqe(struct t4_wq *wq, struct t4_ t4_swcq_produce(cq); } -int c4iw_flush_sq(struct t4_wq *wq, struct t4_cq *cq, int count) +static void advance_oldest_read(struct t4_wq *wq); + +int c4iw_flush_sq(struct c4iw_qp *qhp) { int flushed = 0; - struct t4_swsqe *swsqe = &wq->sq.sw_sq[wq->sq.cidx + count]; - int in_use = wq->sq.in_use - count; + struct t4_wq *wq = &qhp->wq; + struct c4iw_cq *chp = to_c4iw_cq(qhp->ibqp.send_cq); + struct t4_cq *cq = &chp->cq; + int idx; + struct t4_swsqe *swsqe; - BUG_ON(in_use < 0); - while (in_use--) { - swsqe->signaled = 0; + if (wq->sq.flush_cidx == -1) + wq->sq.flush_cidx = wq->sq.cidx; + idx = wq->sq.flush_cidx; + BUG_ON(idx >= wq->sq.size); + while (idx != wq->sq.pidx) { + swsqe = &wq->sq.sw_sq[idx]; + BUG_ON(swsqe->flushed); + swsqe->flushed = 1; insert_sq_cqe(wq, cq, swsqe); - swsqe++; - if (swsqe == (wq->sq.sw_sq + wq->sq.size)) - swsqe = wq->sq.sw_sq; + if (wq->sq.oldest_read == swsqe) { + BUG_ON(swsqe->opcode != FW_RI_READ_REQ); + advance_oldest_read(wq); + } flushed++; + if (++idx == wq->sq.size) + idx = 0; } + wq->sq.flush_cidx += flushed; + if (wq->sq.flush_cidx >= wq->sq.size) + wq->sq.flush_cidx -= wq->sq.size; return flushed; } -/* - * Move all CQEs from the HWCQ into the SWCQ. - */ -void c4iw_flush_hw_cq(struct t4_cq *cq) -{ - struct t4_cqe *cqe = NULL, *swcqe; - int ret; - - CTR3(KTR_IW_CXGBE, "%s cq %p cqid 0x%x", __func__, cq, cq->cqid); - ret = t4_next_hw_cqe(cq, &cqe); - while (!ret) { - CTR3(KTR_IW_CXGBE, "%s flushing hwcq cidx 0x%x swcq pidx 0x%x", - __func__, cq->cidx, cq->sw_pidx); - swcqe = &cq->sw_queue[cq->sw_pidx]; - *swcqe = *cqe; - swcqe->header |= cpu_to_be32(V_CQE_SWCQE(1)); - t4_swcq_produce(cq); - t4_hwcq_consume(cq); - ret = t4_next_hw_cqe(cq, &cqe); - } -} - -static int cqe_completes_wr(struct t4_cqe *cqe, struct t4_wq *wq) -{ - if (CQE_OPCODE(cqe) == FW_RI_TERMINATE) - return 0; - - if ((CQE_OPCODE(cqe) == FW_RI_RDMA_WRITE) && RQ_TYPE(cqe)) - return 0; - - if ((CQE_OPCODE(cqe) == FW_RI_READ_RESP) && SQ_TYPE(cqe)) - return 0; - - if (CQE_SEND_OPCODE(cqe) && RQ_TYPE(cqe) && t4_rq_empty(wq)) - return 0; - return 1; -} - -void c4iw_count_scqes(struct t4_cq *cq, struct t4_wq *wq, int *count) -{ - struct t4_cqe *cqe; - u32 ptr; - - *count = 0; - ptr = cq->sw_cidx; - while (ptr != cq->sw_pidx) { - cqe = &cq->sw_queue[ptr]; - if ((SQ_TYPE(cqe) || ((CQE_OPCODE(cqe) == FW_RI_READ_RESP) && - wq->sq.oldest_read)) && - (CQE_QPID(cqe) == wq->sq.qid)) - (*count)++; - if (++ptr == cq->size) - ptr = 0; - } - CTR3(KTR_IW_CXGBE, "%s cq %p count %d", __func__, cq, *count); -} - -void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count) -{ - struct t4_cqe *cqe; - u32 ptr; - - *count = 0; - CTR2(KTR_IW_CXGBE, "%s count zero %d", __func__, *count); - ptr = cq->sw_cidx; - while (ptr != cq->sw_pidx) { - cqe = &cq->sw_queue[ptr]; - if (RQ_TYPE(cqe) && (CQE_OPCODE(cqe) != FW_RI_READ_RESP) && - (CQE_QPID(cqe) == wq->sq.qid) && cqe_completes_wr(cqe, wq)) - (*count)++; - if (++ptr == cq->size) - ptr = 0; - } - CTR3(KTR_IW_CXGBE, "%s cq %p count %d", __func__, cq, *count); -} - static void flush_completed_wrs(struct t4_wq *wq, struct t4_cq *cq) { struct t4_swsqe *swsqe; - u16 ptr = wq->sq.cidx; - int count = wq->sq.in_use; - int unsignaled = 0; + int cidx; - swsqe = &wq->sq.sw_sq[ptr]; - while (count--) + if (wq->sq.flush_cidx == -1) + wq->sq.flush_cidx = wq->sq.cidx; + cidx = wq->sq.flush_cidx; + BUG_ON(cidx > wq->sq.size); + + while (cidx != wq->sq.pidx) { + swsqe = &wq->sq.sw_sq[cidx]; if (!swsqe->signaled) { - if (++ptr == wq->sq.size) - ptr = 0; - swsqe = &wq->sq.sw_sq[ptr]; - unsignaled++; + if (++cidx == wq->sq.size) + cidx = 0; } else if (swsqe->complete) { + BUG_ON(swsqe->flushed); + /* * Insert this completed cqe into the swcq. */ CTR3(KTR_IW_CXGBE, - "%s moving cqe into swcq sq idx %u cq idx %u", - __func__, ptr, cq->sw_pidx); + "%s moving cqe into swcq sq idx %u cq idx %u\n", + __func__, cidx, cq->sw_pidx); swsqe->cqe.header |= htonl(V_CQE_SWCQE(1)); cq->sw_queue[cq->sw_pidx] = swsqe->cqe; t4_swcq_produce(cq); - swsqe->signaled = 0; - wq->sq.in_use -= unsignaled; - break; + swsqe->flushed = 1; + if (++cidx == wq->sq.size) + cidx = 0; + wq->sq.flush_cidx = cidx; } else break; + } } static void create_read_req_cqe(struct t4_wq *wq, struct t4_cqe *hw_cqe, struct t4_cqe *read_cqe) { read_cqe->u.scqe.cidx = wq->sq.oldest_read->idx; - read_cqe->len = cpu_to_be32(wq->sq.oldest_read->read_len); + read_cqe->len = htonl(wq->sq.oldest_read->read_len); read_cqe->header = htonl(V_CQE_QPID(CQE_QPID(hw_cqe)) | V_CQE_SWCQE(SW_CQE(hw_cqe)) | V_CQE_OPCODE(FW_RI_READ_REQ) | @@ -383,9 +328,6 @@ static void create_read_req_cqe(struct t4_wq *wq, stru read_cqe->bits_type_ts = hw_cqe->bits_type_ts; } -/* - * Return a ptr to the next read wr in the SWSQ or NULL. - */ static void advance_oldest_read(struct t4_wq *wq) { @@ -405,6 +347,128 @@ static void advance_oldest_read(struct t4_wq *wq) } /* + * Move all CQEs from the HWCQ into the SWCQ. + * Deal with out-of-order and/or completions that complete + * prior unsignalled WRs. + */ +void c4iw_flush_hw_cq(struct c4iw_cq *chp) +{ + struct t4_cqe *hw_cqe, *swcqe, read_cqe; + struct c4iw_qp *qhp; + struct t4_swsqe *swsqe; + int ret; + + CTR3(KTR_IW_CXGBE, "%s c4iw_cq %p cqid 0x%x", __func__, chp, + chp->cq.cqid); + ret = t4_next_hw_cqe(&chp->cq, &hw_cqe); + + /* + * This logic is similar to poll_cq(), but not quite the same + * unfortunately. Need to move pertinent HW CQEs to the SW CQ but + * also do any translation magic that poll_cq() normally does. + */ + while (!ret) { + qhp = get_qhp(chp->rhp, CQE_QPID(hw_cqe)); + + /* + * drop CQEs with no associated QP + */ + if (qhp == NULL) + goto next_cqe; + + if (CQE_OPCODE(hw_cqe) == FW_RI_TERMINATE) + goto next_cqe; + + if (CQE_OPCODE(hw_cqe) == FW_RI_READ_RESP) { + + /* + * If we have reached here because of async + * event or other error, and have egress error + * then drop + */ + if (CQE_TYPE(hw_cqe) == 1) { + goto next_cqe; + } + + /* + * drop peer2peer RTR reads. + */ + if (CQE_WRID_STAG(hw_cqe) == 1) + goto next_cqe; + + /* + * Eat completions for unsignaled read WRs. + */ + if (!qhp->wq.sq.oldest_read->signaled) { + advance_oldest_read(&qhp->wq); + goto next_cqe; + } + + /* + * Don't write to the HWCQ, create a new read req CQE + * in local memory and move it into the swcq. + */ + create_read_req_cqe(&qhp->wq, hw_cqe, &read_cqe); + hw_cqe = &read_cqe; + advance_oldest_read(&qhp->wq); + } + + /* if its a SQ completion, then do the magic to move all the + * unsignaled and now in-order completions into the swcq. + */ + if (SQ_TYPE(hw_cqe)) { + swsqe = &qhp->wq.sq.sw_sq[CQE_WRID_SQ_IDX(hw_cqe)]; + swsqe->cqe = *hw_cqe; + swsqe->complete = 1; + flush_completed_wrs(&qhp->wq, &chp->cq); + } else { + swcqe = &chp->cq.sw_queue[chp->cq.sw_pidx]; + *swcqe = *hw_cqe; + swcqe->header |= cpu_to_be32(V_CQE_SWCQE(1)); + t4_swcq_produce(&chp->cq); + } +next_cqe: + t4_hwcq_consume(&chp->cq); + ret = t4_next_hw_cqe(&chp->cq, &hw_cqe); + } +} + +static int cqe_completes_wr(struct t4_cqe *cqe, struct t4_wq *wq) +{ + if (CQE_OPCODE(cqe) == FW_RI_TERMINATE) + return 0; + + if ((CQE_OPCODE(cqe) == FW_RI_RDMA_WRITE) && RQ_TYPE(cqe)) + return 0; + + if ((CQE_OPCODE(cqe) == FW_RI_READ_RESP) && SQ_TYPE(cqe)) + return 0; + + if (CQE_SEND_OPCODE(cqe) && RQ_TYPE(cqe) && t4_rq_empty(wq)) + return 0; + return 1; +} + +void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count) +{ + struct t4_cqe *cqe; + u32 ptr; + + *count = 0; + CTR2(KTR_IW_CXGBE, "%s count zero %d", __func__, *count); + ptr = cq->sw_cidx; + while (ptr != cq->sw_pidx) { + cqe = &cq->sw_queue[ptr]; + if (RQ_TYPE(cqe) && (CQE_OPCODE(cqe) != FW_RI_READ_RESP) && + (CQE_QPID(cqe) == wq->sq.qid) && cqe_completes_wr(cqe, wq)) + (*count)++; + if (++ptr == cq->size) + ptr = 0; + } + CTR3(KTR_IW_CXGBE, "%s cq %p count %d", __func__, cq, *count); +} + +/* * poll_cq * * Caller must: @@ -450,6 +514,22 @@ static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, } /* + * skip hw cqe's if the wq is flushed. + */ + if (wq->flushed && !SW_CQE(hw_cqe)) { + ret = -EAGAIN; + goto skip_cqe; + } + + /* + * skip TERMINATE cqes... + */ + if (CQE_OPCODE(hw_cqe) == FW_RI_TERMINATE) { + ret = -EAGAIN; + goto skip_cqe; + } + + /* * Special cqe for drain WR completions... */ if (CQE_OPCODE(hw_cqe) == C4IW_DRAIN_OPCODE) { @@ -467,12 +547,22 @@ static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, */ if (RQ_TYPE(hw_cqe) && (CQE_OPCODE(hw_cqe) == FW_RI_READ_RESP)) { - /* - * If this is an unsolicited read response, then the read + /* If we have reached here because of async + * event or other error, and have egress error + * then drop + */ + if (CQE_TYPE(hw_cqe) == 1) { + if (CQE_STATUS(hw_cqe)) + t4_set_wq_in_error(wq); + ret = -EAGAIN; + goto skip_cqe; + } + + /* If this is an unsolicited read response, then the read * was generated by the kernel driver as part of peer-2-peer * connection setup. So ignore the completion. */ - if (!wq->sq.oldest_read) { + if (CQE_WRID_STAG(hw_cqe) == 1) { if (CQE_STATUS(hw_cqe)) t4_set_wq_in_error(wq); ret = -EAGAIN; @@ -480,6 +570,15 @@ static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, } /* + * Eat completions for unsignaled read WRs. + */ + if (!wq->sq.oldest_read->signaled) { + advance_oldest_read(wq); + ret = -EAGAIN; + goto skip_cqe; + } + + /* * Don't write to the HWCQ, so create a new read req CQE * in local memory. */ @@ -489,16 +588,10 @@ static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, } if (CQE_STATUS(hw_cqe) || t4_wq_in_error(wq)) { - *cqe_flushed = t4_wq_in_error(wq); + *cqe_flushed = (CQE_STATUS(hw_cqe) == T4_ERR_SWFLUSH); t4_set_wq_in_error(wq); - goto proc_cqe; } - if (CQE_OPCODE(hw_cqe) == FW_RI_TERMINATE) { - ret = -EAGAIN; - goto skip_cqe; - } - /* * RECV completion. */ @@ -510,12 +603,7 @@ static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, * then we complete this with T4_ERR_MSN and mark the wq in * error. */ - - if (t4_rq_empty(wq)) { - t4_set_wq_in_error(wq); - ret = -EAGAIN; - goto skip_cqe; - } + BUG_ON(t4_rq_empty(wq)); if (unlikely((CQE_WRID_MSN(hw_cqe) != (wq->rq.msn)))) { t4_set_wq_in_error(wq); hw_cqe->header |= htonl(V_CQE_STATUS(T4_ERR_MSN)); @@ -556,9 +644,26 @@ proc_cqe: * completion. */ if (SQ_TYPE(hw_cqe)) { - wq->sq.cidx = CQE_WRID_SQ_IDX(hw_cqe); - CTR2(KTR_IW_CXGBE, "%s completing sq idx %u", - __func__, wq->sq.cidx); + int idx = CQE_WRID_SQ_IDX(hw_cqe); + BUG_ON(idx >= wq->sq.size); + + /* + * Account for any unsignaled completions completed by + * this signaled completion. In this case, cidx points + * to the first unsignaled one, and idx points to the + * signaled one. So adjust in_use based on this delta. + * if this is not completing any unsigned wrs, then the + * delta will be 0. Handle wrapping also! + */ + if (idx < wq->sq.cidx) + wq->sq.in_use -= wq->sq.size + idx - wq->sq.cidx; + else + wq->sq.in_use -= idx - wq->sq.cidx; + BUG_ON(wq->sq.in_use <= 0 || wq->sq.in_use >= wq->sq.size); + + wq->sq.cidx = (uint16_t)idx; + CTR2(KTR_IW_CXGBE, "%s completing sq idx %u\n", + __func__, wq->sq.cidx); *cookie = wq->sq.sw_sq[wq->sq.cidx].wr_id; t4_sq_consume(wq); } else { @@ -567,6 +672,7 @@ proc_cqe: *cookie = wq->rq.sw_rq[wq->rq.cidx].wr_id; BUG_ON(t4_rq_empty(wq)); t4_rq_consume(wq); + goto skip_cqe; } flush_wq: Modified: stable/11/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h ============================================================================== --- stable/11/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h Thu Feb 8 13:22:40 2018 (r329016) +++ stable/11/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h Thu Feb 8 14:39:07 2018 (r329017) @@ -926,12 +926,11 @@ void c4iw_rqtpool_free(struct c4iw_rdev *rdev, u32 add u32 c4iw_pblpool_alloc(struct c4iw_rdev *rdev, int size); void c4iw_pblpool_free(struct c4iw_rdev *rdev, u32 addr, int size); int c4iw_ofld_send(struct c4iw_rdev *rdev, struct mbuf *m); -void c4iw_flush_hw_cq(struct t4_cq *cq); +void c4iw_flush_hw_cq(struct c4iw_cq *chp); void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count); -void c4iw_count_scqes(struct t4_cq *cq, struct t4_wq *wq, int *count); int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp); int c4iw_flush_rq(struct t4_wq *wq, struct t4_cq *cq, int count); -int c4iw_flush_sq(struct t4_wq *wq, struct t4_cq *cq, int count); +int c4iw_flush_sq(struct c4iw_qp *qhp); int c4iw_ev_handler(struct sge_iq *, const struct rsp_ctrl *); u16 c4iw_rqes_posted(struct c4iw_qp *qhp); int c4iw_post_terminate(struct c4iw_qp *qhp, struct t4_cqe *err_cqe); Modified: stable/11/sys/dev/cxgbe/iw_cxgbe/qp.c ============================================================================== --- stable/11/sys/dev/cxgbe/iw_cxgbe/qp.c Thu Feb 8 13:22:40 2018 (r329016) +++ stable/11/sys/dev/cxgbe/iw_cxgbe/qp.c Thu Feb 8 14:39:07 2018 (r329017) @@ -734,6 +734,7 @@ int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_ swsqe->complete = 0; swsqe->signaled = (wr->send_flags & IB_SEND_SIGNALED) || qhp->sq_sig_all; + swsqe->flushed = 0; swsqe->wr_id = wr->wr_id; init_wr_hdr(wqe, qhp->wq.sq.pidx, fw_opcode, fw_flags, len16); @@ -1010,10 +1011,18 @@ static void __flush_qp(struct c4iw_qp *qhp, struct c4i CTR4(KTR_IW_CXGBE, "%s qhp %p rchp %p schp %p", __func__, qhp, rchp, schp); - /* locking hierarchy: cq lock first, then qp lock. */ + /* locking heirarchy: cq lock first, then qp lock. */ spin_lock_irqsave(&rchp->lock, flag); spin_lock(&qhp->lock); - c4iw_flush_hw_cq(&rchp->cq); + + if (qhp->wq.flushed) { + spin_unlock(&qhp->lock); + spin_unlock_irqrestore(&rchp->lock, flag); + return; + } + qhp->wq.flushed = 1; + + c4iw_flush_hw_cq(rchp); c4iw_count_rcqes(&rchp->cq, &qhp->wq, &count); flushed = c4iw_flush_rq(&qhp->wq, &rchp->cq, count); spin_unlock(&qhp->lock); @@ -1024,12 +1033,11 @@ static void __flush_qp(struct c4iw_qp *qhp, struct c4i spin_unlock_irqrestore(&rchp->comp_handler_lock, flag); } - /* locking hierarchy: cq lock first, then qp lock. */ + /* locking heirarchy: cq lock first, then qp lock. */ spin_lock_irqsave(&schp->lock, flag); spin_lock(&qhp->lock); - c4iw_flush_hw_cq(&schp->cq); - c4iw_count_scqes(&schp->cq, &qhp->wq, &count); - flushed = c4iw_flush_sq(&qhp->wq, &schp->cq, count); + c4iw_flush_hw_cq(schp); + flushed = c4iw_flush_sq(qhp); spin_unlock(&qhp->lock); spin_unlock_irqrestore(&schp->lock, flag); if (flushed && schp->ibcq.comp_handler) { @@ -1047,8 +1055,8 @@ static void flush_qp(struct c4iw_qp *qhp) rchp = get_chp(qhp->rhp, qhp->attr.rcq); schp = get_chp(qhp->rhp, qhp->attr.scq); + t4_set_wq_in_error(&qhp->wq); if (qhp->ibqp.uobject) { - t4_set_wq_in_error(&qhp->wq); t4_set_cq_in_error(&rchp->cq); spin_lock_irqsave(&rchp->comp_handler_lock, flag); (*rchp->ibcq.comp_handler)(&rchp->ibcq, rchp->ibcq.cq_context); @@ -1339,6 +1347,7 @@ int c4iw_modify_qp(struct c4iw_dev *rhp, struct c4iw_q switch (attrs->next_state) { case C4IW_QP_STATE_CLOSING: BUG_ON(atomic_read(&qhp->ep->com.kref.refcount) < 2); + t4_set_wq_in_error(&qhp->wq); set_state(qhp, C4IW_QP_STATE_CLOSING); ep = qhp->ep; if (!internal) { @@ -1346,18 +1355,15 @@ int c4iw_modify_qp(struct c4iw_dev *rhp, struct c4iw_q disconnect = 1; c4iw_get_ep(&qhp->ep->com); } - if (qhp->ibqp.uobject) - t4_set_wq_in_error(&qhp->wq); ret = rdma_fini(rhp, qhp, ep); if (ret) goto err; break; case C4IW_QP_STATE_TERMINATE: + t4_set_wq_in_error(&qhp->wq); set_state(qhp, C4IW_QP_STATE_TERMINATE); qhp->attr.layer_etype = attrs->layer_etype; qhp->attr.ecode = attrs->ecode; - if (qhp->ibqp.uobject) - t4_set_wq_in_error(&qhp->wq); ep = qhp->ep; if (!internal) terminate = 1; @@ -1365,9 +1371,8 @@ int c4iw_modify_qp(struct c4iw_dev *rhp, struct c4iw_q c4iw_get_ep(&qhp->ep->com); break; case C4IW_QP_STATE_ERROR: + t4_set_wq_in_error(&qhp->wq); set_state(qhp, C4IW_QP_STATE_ERROR); - if (qhp->ibqp.uobject) - t4_set_wq_in_error(&qhp->wq); if (!internal) { abort = 1; disconnect = 1; @@ -1558,6 +1563,7 @@ c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_att qhp->wq.sq.size = sqsize; qhp->wq.sq.memsize = (sqsize + spg_ndesc) * sizeof *qhp->wq.sq.queue + 16 * sizeof(__be64); + qhp->wq.sq.flush_cidx = -1; qhp->wq.rq.size = rqsize; qhp->wq.rq.memsize = (rqsize + spg_ndesc) * sizeof *qhp->wq.rq.queue; Modified: stable/11/sys/dev/cxgbe/iw_cxgbe/t4.h ============================================================================== --- stable/11/sys/dev/cxgbe/iw_cxgbe/t4.h Thu Feb 8 13:22:40 2018 (r329016) +++ stable/11/sys/dev/cxgbe/iw_cxgbe/t4.h Thu Feb 8 14:39:07 2018 (r329017) @@ -289,6 +289,7 @@ struct t4_swsqe { int complete; int signaled; u16 idx; + int flushed; }; struct t4_sq { @@ -307,6 +308,7 @@ struct t4_sq { u16 pidx; u16 wq_pidx; u16 flags; + short flush_cidx; }; struct t4_swrqe { @@ -337,6 +339,7 @@ struct t4_wq { void __iomem *db; void __iomem *gts; struct c4iw_rdev *rdev; + int flushed; }; static inline int t4_rqes_posted(struct t4_wq *wq) @@ -414,6 +417,9 @@ static inline void t4_sq_produce(struct t4_wq *wq, u8 static inline void t4_sq_consume(struct t4_wq *wq) { + BUG_ON(wq->sq.in_use < 1); + if (wq->sq.cidx == wq->sq.flush_cidx) + wq->sq.flush_cidx = -1; wq->sq.in_use--; if (++wq->sq.cidx == wq->sq.size) wq->sq.cidx = 0; @@ -492,12 +498,14 @@ static inline int t4_arm_cq(struct t4_cq *cq, int se) static inline void t4_swcq_produce(struct t4_cq *cq) { cq->sw_in_use++; + BUG_ON(cq->sw_in_use >= cq->size); if (++cq->sw_pidx == cq->size) cq->sw_pidx = 0; } static inline void t4_swcq_consume(struct t4_cq *cq) { + BUG_ON(cq->sw_in_use < 1); cq->sw_in_use--; if (++cq->sw_cidx == cq->size) cq->sw_cidx = 0; @@ -540,6 +548,7 @@ static inline int t4_next_hw_cqe(struct t4_cq *cq, str cq->error = 1; printk(KERN_ERR MOD "cq overflow cqid %u\n", cq->cqid); } else if (t4_valid_cqe(cq, &cq->queue[cq->cidx])) { + rmb(); *cqe = &cq->queue[cq->cidx]; ret = 0; } else From owner-svn-src-stable-11@freebsd.org Thu Feb 8 17:14:57 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 95F3BF144D2; Thu, 8 Feb 2018 17:14:57 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46E8171B21; Thu, 8 Feb 2018 17:14:57 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 41C0D18EC9; Thu, 8 Feb 2018 17:14:57 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w18HEvhB032194; Thu, 8 Feb 2018 17:14:57 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w18HEuWI032186; Thu, 8 Feb 2018 17:14:56 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802081714.w18HEuWI032186@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 8 Feb 2018 17:14:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329020 - in stable/11/sys: fs/ext2fs kern sys ufs/ffs vm X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11/sys: fs/ext2fs kern sys ufs/ffs vm X-SVN-Commit-Revision: 329020 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 17:14:57 -0000 Author: kevans Date: Thu Feb 8 17:14:56 2018 New Revision: 329020 URL: https://svnweb.freebsd.org/changeset/base/329020 Log: MFC r309062: Release laundered vnode pages to the head of the inactive queue. The swap pager enqueues laundered pages near the head of the inactive queue to avoid another trip through LRU before reclamation. This change adds support for this behaviour to the vnode pager and makes use of it in UFS and ext2fs. Some ioflag handling is consolidated into a common subroutine so that this support can be easily extended to other filesystems which make use of the buffer cache. No changes are needed for ZFS since its putpages routine always undirties the pages before returning, and the laundry thread requeues the pages appropriately in this case. Modified: stable/11/sys/fs/ext2fs/ext2_vnops.c stable/11/sys/kern/vfs_bio.c stable/11/sys/sys/buf.h stable/11/sys/sys/vnode.h stable/11/sys/ufs/ffs/ffs_vnops.c stable/11/sys/vm/vm_pageout.c stable/11/sys/vm/vm_pager.h stable/11/sys/vm/vnode_pager.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/ext2fs/ext2_vnops.c ============================================================================== --- stable/11/sys/fs/ext2fs/ext2_vnops.c Thu Feb 8 17:07:27 2018 (r329019) +++ stable/11/sys/fs/ext2fs/ext2_vnops.c Thu Feb 8 17:14:56 2018 (r329020) @@ -2061,15 +2061,6 @@ ext2_ind_read(struct vop_read_args *ap) } /* - * If IO_DIRECT then set B_DIRECT for the buffer. This - * will cause us to attempt to release the buffer later on - * and will cause the buffer cache to attempt to free the - * underlying pages. - */ - if (ioflag & IO_DIRECT) - bp->b_flags |= B_DIRECT; - - /* * We should only get non-zero b_resid when an I/O error * has occurred, which should cause us to break above. * However, if the short read did not cause an error, @@ -2086,25 +2077,7 @@ ext2_ind_read(struct vop_read_args *ap) (int)xfersize, uio); if (error) break; - - if (ioflag & (IO_VMIO|IO_DIRECT)) { - /* - * If it's VMIO or direct I/O, then we don't - * need the buf, mark it available for - * freeing. If it's non-direct VMIO, the VM has - * the data. - */ - bp->b_flags |= B_RELBUF; - brelse(bp); - } else { - /* - * Otherwise let whoever - * made the request take care of - * freeing it. We just queue - * it onto another list. - */ - bqrelse(bp); - } + vfs_bio_brelse(bp, ioflag); } /* @@ -2113,14 +2086,8 @@ ext2_ind_read(struct vop_read_args *ap) * completion has not set a new value into it. so it must have come * from a 'break' statement */ - if (bp != NULL) { - if (ioflag & (IO_VMIO|IO_DIRECT)) { - bp->b_flags |= B_RELBUF; - brelse(bp); - } else { - bqrelse(bp); - } - } + if (bp != NULL) + vfs_bio_brelse(bp, ioflag); if ((error == 0 || uio->uio_resid != orig_resid) && (vp->v_mount->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0) @@ -2378,9 +2345,8 @@ ext2_write(struct vop_write_args *ap) if (error != 0 && (bp->b_flags & B_CACHE) == 0 && fs->e2fs_bsize == xfersize) vfs_bio_clrbuf(bp); - if (ioflag & (IO_VMIO|IO_DIRECT)) { - bp->b_flags |= B_RELBUF; - } + + vfs_bio_set_flags(bp, ioflag); /* * If IO_SYNC each buffer is written synchronously. Otherwise Modified: stable/11/sys/kern/vfs_bio.c ============================================================================== --- stable/11/sys/kern/vfs_bio.c Thu Feb 8 17:07:27 2018 (r329019) +++ stable/11/sys/kern/vfs_bio.c Thu Feb 8 17:14:56 2018 (r329020) @@ -4452,6 +4452,45 @@ vfs_bio_bzero_buf(struct buf *bp, int base, int size) } /* + * Update buffer flags based on I/O request parameters, optionally releasing the + * buffer. If it's VMIO or direct I/O, the buffer pages are released to the VM, + * where they may be placed on a page queue (VMIO) or freed immediately (direct + * I/O). Otherwise the buffer is released to the cache. + */ +static void +b_io_dismiss(struct buf *bp, int ioflag, bool release) +{ + + KASSERT((ioflag & IO_NOREUSE) == 0 || (ioflag & IO_VMIO) != 0, + ("buf %p non-VMIO noreuse", bp)); + + if ((ioflag & IO_DIRECT) != 0) + bp->b_flags |= B_DIRECT; + if ((ioflag & (IO_VMIO | IO_DIRECT)) != 0 && LIST_EMPTY(&bp->b_dep)) { + bp->b_flags |= B_RELBUF; + if ((ioflag & IO_NOREUSE) != 0) + bp->b_flags |= B_NOREUSE; + if (release) + brelse(bp); + } else if (release) + bqrelse(bp); +} + +void +vfs_bio_brelse(struct buf *bp, int ioflag) +{ + + b_io_dismiss(bp, ioflag, true); +} + +void +vfs_bio_set_flags(struct buf *bp, int ioflag) +{ + + b_io_dismiss(bp, ioflag, false); +} + +/* * vm_hold_load_pages and vm_hold_free_pages get pages into * a buffers address space. The pages are anonymous and are * not associated with a file object. Modified: stable/11/sys/sys/buf.h ============================================================================== --- stable/11/sys/sys/buf.h Thu Feb 8 17:07:27 2018 (r329019) +++ stable/11/sys/sys/buf.h Thu Feb 8 17:14:56 2018 (r329020) @@ -526,9 +526,11 @@ int cluster_read(struct vnode *, u_quad_t, daddr_t, lo struct ucred *, long, int, int, struct buf **); int cluster_wbuild(struct vnode *, long, daddr_t, int, int); void cluster_write(struct vnode *, struct buf *, u_quad_t, int, int); +void vfs_bio_brelse(struct buf *bp, int ioflags); void vfs_bio_bzero_buf(struct buf *bp, int base, int size); -void vfs_bio_set_valid(struct buf *, int base, int size); void vfs_bio_clrbuf(struct buf *); +void vfs_bio_set_flags(struct buf *bp, int ioflags); +void vfs_bio_set_valid(struct buf *, int base, int size); void vfs_busy_pages(struct buf *, int clear_modify); void vfs_unbusy_pages(struct buf *); int vmapbuf(struct buf *, int); Modified: stable/11/sys/sys/vnode.h ============================================================================== --- stable/11/sys/sys/vnode.h Thu Feb 8 17:07:27 2018 (r329019) +++ stable/11/sys/sys/vnode.h Thu Feb 8 17:14:56 2018 (r329020) @@ -303,6 +303,7 @@ struct vattr { #define IO_INVAL 0x0040 /* invalidate after I/O */ #define IO_SYNC 0x0080 /* do I/O synchronously */ #define IO_DIRECT 0x0100 /* attempt to bypass buffer cache */ +#define IO_NOREUSE 0x0200 /* VMIO data won't be reused */ #define IO_EXT 0x0400 /* operate on external attributes */ #define IO_NORMAL 0x0800 /* operate on regular data */ #define IO_NOMACCHECK 0x1000 /* MAC checks unnecessary */ Modified: stable/11/sys/ufs/ffs/ffs_vnops.c ============================================================================== --- stable/11/sys/ufs/ffs/ffs_vnops.c Thu Feb 8 17:07:27 2018 (r329019) +++ stable/11/sys/ufs/ffs/ffs_vnops.c Thu Feb 8 17:14:56 2018 (r329020) @@ -601,15 +601,6 @@ ffs_read(ap) } /* - * If IO_DIRECT then set B_DIRECT for the buffer. This - * will cause us to attempt to release the buffer later on - * and will cause the buffer cache to attempt to free the - * underlying pages. - */ - if (ioflag & IO_DIRECT) - bp->b_flags |= B_DIRECT; - - /* * We should only get non-zero b_resid when an I/O error * has occurred, which should cause us to break above. * However, if the short read did not cause an error, @@ -633,25 +624,7 @@ ffs_read(ap) if (error) break; - if ((ioflag & (IO_VMIO|IO_DIRECT)) && - (LIST_EMPTY(&bp->b_dep))) { - /* - * If there are no dependencies, and it's VMIO, - * then we don't need the buf, mark it available - * for freeing. For non-direct VMIO reads, the VM - * has the data. - */ - bp->b_flags |= B_RELBUF; - brelse(bp); - } else { - /* - * Otherwise let whoever - * made the request take care of - * freeing it. We just queue - * it onto another list. - */ - bqrelse(bp); - } + vfs_bio_brelse(bp, ioflag); } /* @@ -660,15 +633,8 @@ ffs_read(ap) * and on normal completion has not set a new value into it. * so it must have come from a 'break' statement */ - if (bp != NULL) { - if ((ioflag & (IO_VMIO|IO_DIRECT)) && - (LIST_EMPTY(&bp->b_dep))) { - bp->b_flags |= B_RELBUF; - brelse(bp); - } else { - bqrelse(bp); - } - } + if (bp != NULL) + vfs_bio_brelse(bp, ioflag); if ((error == 0 || uio->uio_resid != orig_resid) && (vp->v_mount->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0 && @@ -786,8 +752,6 @@ ffs_write(ap) vnode_pager_setsize(vp, ip->i_size); break; } - if (ioflag & IO_DIRECT) - bp->b_flags |= B_DIRECT; if ((ioflag & (IO_SYNC|IO_INVAL)) == (IO_SYNC|IO_INVAL)) bp->b_flags |= B_NOCACHE; @@ -827,11 +791,9 @@ ffs_write(ap) if (error != 0 && (bp->b_flags & B_CACHE) == 0 && fs->fs_bsize == xfersize) vfs_bio_clrbuf(bp); - if ((ioflag & (IO_VMIO|IO_DIRECT)) && - (LIST_EMPTY(&bp->b_dep))) { - bp->b_flags |= B_RELBUF; - } + vfs_bio_set_flags(bp, ioflag); + /* * If IO_SYNC each buffer is written synchronously. Otherwise * if we have a severe page deficiency write the buffer @@ -978,15 +940,6 @@ ffs_extread(struct vnode *vp, struct uio *uio, int iof } /* - * If IO_DIRECT then set B_DIRECT for the buffer. This - * will cause us to attempt to release the buffer later on - * and will cause the buffer cache to attempt to free the - * underlying pages. - */ - if (ioflag & IO_DIRECT) - bp->b_flags |= B_DIRECT; - - /* * We should only get non-zero b_resid when an I/O error * has occurred, which should cause us to break above. * However, if the short read did not cause an error, @@ -1004,26 +957,7 @@ ffs_extread(struct vnode *vp, struct uio *uio, int iof (int)xfersize, uio); if (error) break; - - if ((ioflag & (IO_VMIO|IO_DIRECT)) && - (LIST_EMPTY(&bp->b_dep))) { - /* - * If there are no dependencies, and it's VMIO, - * then we don't need the buf, mark it available - * for freeing. For non-direct VMIO reads, the VM - * has the data. - */ - bp->b_flags |= B_RELBUF; - brelse(bp); - } else { - /* - * Otherwise let whoever - * made the request take care of - * freeing it. We just queue - * it onto another list. - */ - bqrelse(bp); - } + vfs_bio_brelse(bp, ioflag); } /* @@ -1032,15 +966,8 @@ ffs_extread(struct vnode *vp, struct uio *uio, int iof * and on normal completion has not set a new value into it. * so it must have come from a 'break' statement */ - if (bp != NULL) { - if ((ioflag & (IO_VMIO|IO_DIRECT)) && - (LIST_EMPTY(&bp->b_dep))) { - bp->b_flags |= B_RELBUF; - brelse(bp); - } else { - bqrelse(bp); - } - } + if (bp != NULL) + vfs_bio_brelse(bp, ioflag); return (error); } @@ -1109,8 +1036,6 @@ ffs_extwrite(struct vnode *vp, struct uio *uio, int io */ if ((bp->b_flags & B_CACHE) == 0 && fs->fs_bsize <= xfersize) vfs_bio_clrbuf(bp); - if (ioflag & IO_DIRECT) - bp->b_flags |= B_DIRECT; if (uio->uio_offset + xfersize > dp->di_extsize) dp->di_extsize = uio->uio_offset + xfersize; @@ -1121,10 +1046,8 @@ ffs_extwrite(struct vnode *vp, struct uio *uio, int io error = uiomove((char *)bp->b_data + blkoffset, (int)xfersize, uio); - if ((ioflag & (IO_VMIO|IO_DIRECT)) && - (LIST_EMPTY(&bp->b_dep))) { - bp->b_flags |= B_RELBUF; - } + + vfs_bio_set_flags(bp, ioflag); /* * If IO_SYNC each buffer is written synchronously. Otherwise Modified: stable/11/sys/vm/vm_pageout.c ============================================================================== --- stable/11/sys/vm/vm_pageout.c Thu Feb 8 17:07:27 2018 (r329019) +++ stable/11/sys/vm/vm_pageout.c Thu Feb 8 17:14:56 2018 (r329020) @@ -441,8 +441,8 @@ more: if (ib != 0 && pageout_count < vm_pageout_page_count) goto more; - return (vm_pageout_flush(&mc[page_base], pageout_count, 0, 0, NULL, - NULL)); + return (vm_pageout_flush(&mc[page_base], pageout_count, + VM_PAGER_PUT_NOREUSE, 0, NULL, NULL)); } /* Modified: stable/11/sys/vm/vm_pager.h ============================================================================== --- stable/11/sys/vm/vm_pager.h Thu Feb 8 17:07:27 2018 (r329019) +++ stable/11/sys/vm/vm_pager.h Thu Feb 8 17:14:56 2018 (r329020) @@ -98,6 +98,7 @@ extern struct pagerops mgtdevicepagerops; #define VM_PAGER_PUT_SYNC 0x0001 #define VM_PAGER_PUT_INVAL 0x0002 +#define VM_PAGER_PUT_NOREUSE 0x0004 #define VM_PAGER_CLUSTER_OK 0x0008 #ifdef _KERNEL Modified: stable/11/sys/vm/vnode_pager.c ============================================================================== --- stable/11/sys/vm/vnode_pager.c Thu Feb 8 17:07:27 2018 (r329019) +++ stable/11/sys/vm/vnode_pager.c Thu Feb 8 17:14:56 2018 (r329020) @@ -1366,9 +1366,7 @@ vnode_pager_putpages_ioflags(int pager_flags) else if ((pager_flags & VM_PAGER_CLUSTER_OK) == 0) ioflags |= IO_ASYNC; ioflags |= (pager_flags & VM_PAGER_PUT_INVAL) != 0 ? IO_INVAL: 0; -#ifdef notyet ioflags |= (pager_flags & VM_PAGER_PUT_NOREUSE) != 0 ? IO_NOREUSE : 0; -#endif ioflags |= IO_SEQMAX << IO_SEQSHIFT; return (ioflags); } From owner-svn-src-stable-11@freebsd.org Fri Feb 9 03:06:46 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7CFEDF1E0E1; Fri, 9 Feb 2018 03:06:46 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 30A6A6D924; Fri, 9 Feb 2018 03:06:46 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2B7081F1F1; Fri, 9 Feb 2018 03:06:46 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1936jVV040107; Fri, 9 Feb 2018 03:06:45 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1936jhN040106; Fri, 9 Feb 2018 03:06:45 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201802090306.w1936jhN040106@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 9 Feb 2018 03:06:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329056 - stable/11/sys/dev/ntb X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/ntb X-SVN-Commit-Revision: 329056 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Feb 2018 03:06:46 -0000 Author: mav Date: Fri Feb 9 03:06:45 2018 New Revision: 329056 URL: https://svnweb.freebsd.org/changeset/base/329056 Log: MFC r328450: Use bus_dmamem_alloc(9) KPI instead of contigmalloc(9). I suppose it should make this code NUMA-aware with recent NUMA drop-in, trying to allocate shared memory buffers from domain closer to NT-bridge. Modified: stable/11/sys/dev/ntb/ntb_transport.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ntb/ntb_transport.c ============================================================================== --- stable/11/sys/dev/ntb/ntb_transport.c Fri Feb 9 00:38:50 2018 (r329055) +++ stable/11/sys/dev/ntb/ntb_transport.c Fri Feb 9 03:06:45 2018 (r329056) @@ -182,6 +182,8 @@ struct ntb_transport_mw { size_t xlat_size; size_t buff_size; /* Rx buff is off virt_addr / dma_addr */ + bus_dma_tag_t dma_tag; + bus_dmamap_t dma_map; caddr_t virt_addr; bus_addr_t dma_addr; }; @@ -1147,10 +1149,25 @@ out: NTB_LINK_DOWN_TIMEOUT * hz / 1000, ntb_transport_link_work, nt); } +struct ntb_load_cb_args { + bus_addr_t addr; + int error; +}; + +static void +ntb_load_cb(void *xsc, bus_dma_segment_t *segs, int nsegs, int error) +{ + struct ntb_load_cb_args *cba = (struct ntb_load_cb_args *)xsc; + + if (!(cba->error = error)) + cba->addr = segs[0].ds_addr; +} + static int ntb_set_mw(struct ntb_transport_ctx *nt, int num_mw, size_t size) { struct ntb_transport_mw *mw = &nt->mw_vec[num_mw]; + struct ntb_load_cb_args cba; size_t xlat_size, buff_size; int rc; @@ -1171,30 +1188,36 @@ ntb_set_mw(struct ntb_transport_ctx *nt, int num_mw, s mw->xlat_size = xlat_size; mw->buff_size = buff_size; - mw->virt_addr = contigmalloc(mw->buff_size, M_NTB_T, M_ZERO, 0, - mw->addr_limit, mw->xlat_align, 0); - if (mw->virt_addr == NULL) { + if (bus_dma_tag_create(bus_get_dma_tag(nt->dev), mw->xlat_align, 0, + mw->addr_limit, BUS_SPACE_MAXADDR, + NULL, NULL, mw->buff_size, 1, mw->buff_size, + 0, NULL, NULL, &mw->dma_tag)) { + ntb_printf(0, "Unable to create MW tag of size %zu/%zu\n", + mw->buff_size, mw->xlat_size); + mw->xlat_size = 0; + mw->buff_size = 0; + return (ENOMEM); + } + if (bus_dmamem_alloc(mw->dma_tag, (void **)&mw->virt_addr, + BUS_DMA_WAITOK | BUS_DMA_ZERO, &mw->dma_map)) { + bus_dma_tag_destroy(mw->dma_tag); ntb_printf(0, "Unable to allocate MW buffer of size %zu/%zu\n", mw->buff_size, mw->xlat_size); mw->xlat_size = 0; mw->buff_size = 0; return (ENOMEM); } - /* TODO: replace with bus_space_* functions */ - mw->dma_addr = vtophys(mw->virt_addr); - - /* - * Ensure that the allocation from contigmalloc is aligned as - * requested. XXX: This may not be needed -- brought in for parity - * with the Linux driver. - */ - if (mw->dma_addr % mw->xlat_align != 0) { - ntb_printf(0, - "DMA memory 0x%jx not aligned to BAR size 0x%zx\n", - (uintmax_t)mw->dma_addr, size); - ntb_free_mw(nt, num_mw); + if (bus_dmamap_load(mw->dma_tag, mw->dma_map, mw->virt_addr, + mw->buff_size, ntb_load_cb, &cba, BUS_DMA_NOWAIT) || cba.error) { + bus_dmamem_free(mw->dma_tag, mw->virt_addr, mw->dma_map); + bus_dma_tag_destroy(mw->dma_tag); + ntb_printf(0, "Unable to load MW buffer of size %zu/%zu\n", + mw->buff_size, mw->xlat_size); + mw->xlat_size = 0; + mw->buff_size = 0; return (ENOMEM); } + mw->dma_addr = cba.addr; /* Notify HW the memory location of the receive buffer */ rc = ntb_mw_set_trans(nt->dev, num_mw, mw->dma_addr, mw->xlat_size); @@ -1216,7 +1239,9 @@ ntb_free_mw(struct ntb_transport_ctx *nt, int num_mw) return; ntb_mw_clear_trans(nt->dev, num_mw); - contigfree(mw->virt_addr, mw->xlat_size, M_NTB_T); + bus_dmamap_unload(mw->dma_tag, mw->dma_map); + bus_dmamem_free(mw->dma_tag, mw->virt_addr, mw->dma_map); + bus_dma_tag_destroy(mw->dma_tag); mw->xlat_size = 0; mw->buff_size = 0; mw->virt_addr = NULL; From owner-svn-src-stable-11@freebsd.org Fri Feb 9 03:07:13 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6FFC6F1E193; Fri, 9 Feb 2018 03:07:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 25BBB6DA52; Fri, 9 Feb 2018 03:07:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 209821F1F3; Fri, 9 Feb 2018 03:07:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1937D91040188; Fri, 9 Feb 2018 03:07:13 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1937DVm040187; Fri, 9 Feb 2018 03:07:13 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201802090307.w1937DVm040187@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 9 Feb 2018 03:07:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329057 - stable/11/sys/dev/ntb X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/ntb X-SVN-Commit-Revision: 329057 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Feb 2018 03:07:13 -0000 Author: mav Date: Fri Feb 9 03:07:12 2018 New Revision: 329057 URL: https://svnweb.freebsd.org/changeset/base/329057 Log: MFC r328611: Try to preallocate receive memory early. We may not have enough contiguous memory later, when NTB connection get established. It is quite likely that NTB windows are symmetric and this allocation remain, but even if not, we will just reallocate it later. Modified: stable/11/sys/dev/ntb/ntb_transport.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ntb/ntb_transport.c ============================================================================== --- stable/11/sys/dev/ntb/ntb_transport.c Fri Feb 9 03:06:45 2018 (r329056) +++ stable/11/sys/dev/ntb/ntb_transport.c Fri Feb 9 03:07:12 2018 (r329057) @@ -332,7 +332,7 @@ ntb_transport_attach(device_t dev) struct ntb_transport_child **cpp = &nt->child; struct ntb_transport_child *nc; struct ntb_transport_mw *mw; - uint64_t db_bitmap; + uint64_t db_bitmap, size; int rc, i, db_count, spad_count, qp, qpu, qpo, qpt; char cfg[128] = ""; char buf[32]; @@ -383,6 +383,17 @@ ntb_transport_attach(device_t dev) rc = ntb_mw_set_wc(dev, i, VM_MEMATTR_WRITE_COMBINING); if (rc) ntb_printf(0, "Unable to set mw%d caching\n", i); + + /* + * Try to preallocate receive memory early, since there may + * be not enough contiguous memory later. It is quite likely + * that NTB windows are symmetric and this allocation remain, + * but even if not, we will just reallocate it later. + */ + size = mw->phys_size; + if (max_mw_size != 0 && size > max_mw_size) + size = max_mw_size; + ntb_set_mw(nt, i, size); } qpu = 0; From owner-svn-src-stable-11@freebsd.org Fri Feb 9 05:29:17 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 821C6F05D72; Fri, 9 Feb 2018 05:29:17 +0000 (UTC) (envelope-from Andre.Albsmeier@siemens.com) Received: from goliath.siemens.de (goliath.siemens.de [192.35.17.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "goliath.siemens.de", Issuer "Siemens Issuing CA Internet Server 2017" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A595E7264A; Fri, 9 Feb 2018 05:29:16 +0000 (UTC) (envelope-from Andre.Albsmeier@siemens.com) Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id w195PKdI029693 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Feb 2018 06:25:20 +0100 Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.40.130]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w195PKwg014191; Fri, 9 Feb 2018 06:25:20 +0100 Received: (from user@localhost) by curry.mchp.siemens.de (8.15.2/8.15.2) id w195PK5N039787; Date: Fri, 9 Feb 2018 06:25:20 +0100 From: Andre Albsmeier To: Alexander Motin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r328692 - in stable/11/sys: conf dev/nvme Message-ID: <20180209052520.GA19647@bali> References: <201802011653.w11Gr8p4031848@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201802011653.w11Gr8p4031848@repo.freebsd.org> User-Agent: Mutt/1.7.2 (2016-11-26) X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Feb 2018 05:29:17 -0000 On Thu, 01-Feb-2018 at 16:53:08 +0000, Alexander Motin wrote: > Author: mav > Date: Thu Feb 1 16:53:08 2018 > New Revision: 328692 > URL: https://svnweb.freebsd.org/changeset/base/328692 > > Log: > MFC r322995 (by imp): > Add new compile-time option NVME_USE_NVD that sets the default value We probably need this one as well: me-2@buildbox:/usr/src>odiff sys/modules/nvme/Makefile --- sys/modules/nvme/Makefile.ORI 2017-05-31 06:17:35.982891000 +0200 +++ sys/modules/nvme/Makefile 2018-02-09 06:19:57.268173000 +0100 @@ -17,6 +17,7 @@ bus_if.h \ device_if.h \ opt_cam.h \ + opt_nvme.h \ pci_if.h .include -Andre From owner-svn-src-stable-11@freebsd.org Fri Feb 9 09:15:45 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3343CF12873; Fri, 9 Feb 2018 09:15:45 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D8FEF799BA; Fri, 9 Feb 2018 09:15:44 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CFA2122E5D; Fri, 9 Feb 2018 09:15:44 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w199FimK022993; Fri, 9 Feb 2018 09:15:44 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w199FhKm022979; Fri, 9 Feb 2018 09:15:43 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201802090915.w199FhKm022979@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Fri, 9 Feb 2018 09:15:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329059 - in stable/11/usr.bin/mkimg: . tests X-SVN-Group: stable-11 X-SVN-Commit-Author: manu X-SVN-Commit-Paths: in stable/11/usr.bin/mkimg: . tests X-SVN-Commit-Revision: 329059 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Feb 2018 09:15:45 -0000 Author: manu Date: Fri Feb 9 09:15:43 2018 New Revision: 329059 URL: https://svnweb.freebsd.org/changeset/base/329059 Log: MFC r306325, r306329-r306330, r306333, r306620-r306622, r307544, r307550, r318137, r319125, r319295 r306325 by marcel: Replace the use of linker sets with constructors for both the formats and schemes. Formats and schemes are registered at runtime now, rather than collected at link time. r306329 by marcel: Eliminate the use of EDOOFUS. The error code was used to signal programming errors, but is really a poor substitute for assert. And less portable as well. r306330 by marcel: Avoid depending on the header for le*enc and be*enc. Not only is the header unportable, the encoding/decoding functions are as well. Instead, duplicate the handful of small inlines we need into a private header called endian.h. Aside: an alternative approach is to move the encoding/decoding functions to a separate system header. While the header is still nonportable, such an approach would make it possible to re-use the definitions by playing games with include paths. This may be the preferred approach if more (build) utilities need this. This change does not preclude that. In fact, it makes it easier. r306333 by marcel: Portability changes: 1. macOS nor Linux have MAP_NOCORE nor MAP_NOSYNC. Define as 0. 2. macOS doesn't have SEEK_DATA nor SEEK_HOLE. Define as -1 so that lseek will return -1 (with errno set to EINVAL). 3. gcc correctly warns that error is assigned but not used in image_copyout_region(). Fix by returning on the first error. r306620 by marcel: Replace STAILQ with TAILQ. TAILQs are portable enough that they can be used on both macOS and Linux. STAILQs are not. In particular, STAILQ_LAST does not next on Linux. Since neither STAILQ_FOREACH_SAFE nor TAILQ_FOREACH_SAFE exist on Linux, replace its use with a regular TAILQ_FOREACH. The _SAFE variant was only used for having the next pointer in a local variable. r306621 by marcel: Prefer over . While here remove redundant inclusion of . Move the inclusion of the disk partitioning headers out of order and inbetween standard headers and local header. They will change in a subsequent commit. r306622 by marcel: Replace OFF_MAX with INT64_MAX. The former is defined on Linux. r307544 by marcel: o Provide a private definition for UUIDs (mkimg_uuid_t) because UUIDs are not portable. o Move mkimg_uuid() to a new file and merge both gpt_uuid_enc() and vhd_uuid_enc() into a single mkimg_uuid_enc() that lives in the same file. o Move the OS-specific implementation of generating a UUID to osdep_uuidgen() and provide the implementations for FreeBSD, macOS and Linux. o Expect the partitioning scheme headers to be found by having a search to the directory in which the headers live. This avoids conflicts on non-FreeBSD machines. r307550 by imp: Add a new flag to mkimg (-a num) to specify the active partition for those partitioning schemes that have this concept. Implement it as an override for mbr's setting 0x80 in the flags for the first partition when we have boot code. Differential Revision: https://reviews.freebsd.org/D4403 r318137: mkimg: Add -C argument to specify maximum capacity Add a -C option to specify a maximum capacity for the final image file. It is useful to control the size of the generated image for sdcard or when we will add dynamic size partition. Add --capacity which is a shorthand to define min and max capacity at the same time. Reviewed by: bapt, marcel, wblock (manpages) Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D10509 r319125: mkimg: Correct an off by one error in the PMBR size The PMBR last sector should be number of sector - 1 (As stated in UEFI Spec 2.6 page 118 table 17). This fixes warning printed by linux tools like parted or fdisk. Sponsored by: Gandi.net r319295 by ngie: Update the usr.bin/mkimg golden test output files after ^/head@r319125 ^/head@r319125 changed the location of the backup pmbr, requiring the output files to be regenerated, since they're binary disk dumps. The output files were regenerated with "make rebase"--fixed in ^/head@r319294. MFC with: r319125, r319294 PR: 219673 Sponsored by: Dell EMC Isilon Added: stable/11/usr.bin/mkimg/endian.h - copied unchanged from r306330, head/usr.bin/mkimg/endian.h stable/11/usr.bin/mkimg/uuid.c - copied unchanged from r307544, head/usr.bin/mkimg/uuid.c Modified: stable/11/usr.bin/mkimg/Makefile stable/11/usr.bin/mkimg/apm.c stable/11/usr.bin/mkimg/bsd.c stable/11/usr.bin/mkimg/ebr.c stable/11/usr.bin/mkimg/format.c stable/11/usr.bin/mkimg/format.h stable/11/usr.bin/mkimg/gpt.c stable/11/usr.bin/mkimg/image.c stable/11/usr.bin/mkimg/mbr.c stable/11/usr.bin/mkimg/mkimg.1 stable/11/usr.bin/mkimg/mkimg.c stable/11/usr.bin/mkimg/mkimg.h stable/11/usr.bin/mkimg/pc98.c stable/11/usr.bin/mkimg/qcow.c stable/11/usr.bin/mkimg/raw.c stable/11/usr.bin/mkimg/scheme.c stable/11/usr.bin/mkimg/scheme.h stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.qcow2.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.raw.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhd.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.vhdf.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-4096-gpt.vmdk.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.qcow.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.qcow2.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.raw.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.vhd.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.vhdf.gz.uu stable/11/usr.bin/mkimg/tests/img-1x1-512-gpt.vmdk.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.qcow.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.qcow2.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.raw.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.vhd.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.vhdf.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-4096-gpt.vmdk.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.qcow.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.qcow2.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.raw.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.vhd.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.vhdf.gz.uu stable/11/usr.bin/mkimg/tests/img-63x255-512-gpt.vmdk.gz.uu stable/11/usr.bin/mkimg/vhd.c stable/11/usr.bin/mkimg/vmdk.c stable/11/usr.bin/mkimg/vtoc8.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/mkimg/Makefile ============================================================================== --- stable/11/usr.bin/mkimg/Makefile Fri Feb 9 04:45:39 2018 (r329058) +++ stable/11/usr.bin/mkimg/Makefile Fri Feb 9 09:15:43 2018 (r329059) @@ -3,14 +3,15 @@ .include PROG= mkimg -SRCS= format.c image.c mkimg.c scheme.c +SRCS= format.c image.c mkimg.c scheme.c uuid.c MAN= mkimg.1 -MKIMG_VERSION=20151211 +MKIMG_VERSION=20161016 mkimg.o: Makefile CFLAGS+=-DMKIMG_VERSION=${MKIMG_VERSION} CFLAGS+=-DSPARSE_WRITE +CFLAGS+=-I${.CURDIR:H:H}/sys # List of formats to support SRCS+= \ Modified: stable/11/usr.bin/mkimg/apm.c ============================================================================== --- stable/11/usr.bin/mkimg/apm.c Fri Feb 9 04:45:39 2018 (r329058) +++ stable/11/usr.bin/mkimg/apm.c Fri Feb 9 09:15:43 2018 (r329059) @@ -27,14 +27,15 @@ #include __FBSDID("$FreeBSD$"); -#include -#include -#include #include +#include #include #include #include +#include + +#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" @@ -91,7 +92,7 @@ apm_write(lba_t imgsz, void *bootcode __unused) strncpy(ent->ent_type, APM_ENT_TYPE_SELF, sizeof(ent->ent_type)); strncpy(ent->ent_name, "Apple", sizeof(ent->ent_name)); - STAILQ_FOREACH(part, &partlist, link) { + TAILQ_FOREACH(part, &partlist, link) { ent = (void *)(buf + (part->index + 2) * secsz); be16enc(&ent->ent_sig, APM_ENT_SIG); be32enc(&ent->ent_pmblkcnt, nparts + 1); Modified: stable/11/usr.bin/mkimg/bsd.c ============================================================================== --- stable/11/usr.bin/mkimg/bsd.c Fri Feb 9 04:45:39 2018 (r329058) +++ stable/11/usr.bin/mkimg/bsd.c Fri Feb 9 09:15:43 2018 (r329059) @@ -27,14 +27,15 @@ #include __FBSDID("$FreeBSD$"); -#include -#include -#include #include +#include #include #include #include +#include + +#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" @@ -103,7 +104,7 @@ bsd_write(lba_t imgsz, void *bootcode) dp = &d->d_partitions[RAW_PART]; le32enc(&dp->p_size, imgsz); - STAILQ_FOREACH(part, &partlist, link) { + TAILQ_FOREACH(part, &partlist, link) { n = part->index + ((part->index >= RAW_PART) ? 1 : 0); dp = &d->d_partitions[n]; le32enc(&dp->p_size, part->size); Modified: stable/11/usr.bin/mkimg/ebr.c ============================================================================== --- stable/11/usr.bin/mkimg/ebr.c Fri Feb 9 04:45:39 2018 (r329058) +++ stable/11/usr.bin/mkimg/ebr.c Fri Feb 9 09:15:43 2018 (r329059) @@ -27,14 +27,15 @@ #include __FBSDID("$FreeBSD$"); -#include -#include -#include #include +#include #include #include #include +#include + +#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" @@ -88,7 +89,7 @@ ebr_write(lba_t imgsz __unused, void *bootcode __unuse le16enc(ebr + DOSMAGICOFFSET, DOSMAGIC); error = 0; - STAILQ_FOREACH_SAFE(part, &partlist, link, next) { + TAILQ_FOREACH(part, &partlist, link) { block = part->block - nsecs; size = round_track(part->size); dp = (void *)(ebr + DOSPARTOFF); @@ -100,6 +101,7 @@ ebr_write(lba_t imgsz __unused, void *bootcode __unuse le32enc(&dp->dp_size, size); /* Add link entry */ + next = TAILQ_NEXT(part, link); if (next != NULL) { size = round_track(next->size); dp++; Copied: stable/11/usr.bin/mkimg/endian.h (from r306330, head/usr.bin/mkimg/endian.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/usr.bin/mkimg/endian.h Fri Feb 9 09:15:43 2018 (r329059, copy of r306330, head/usr.bin/mkimg/endian.h) @@ -0,0 +1,106 @@ +/*- + * Copyright (c) 2002 Thomas Moestl + * 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 _MKIMG_ENDIAN_H_ +#define _MKIMG_ENDIAN_H_ + +static __inline uint16_t +be16dec(const void *pp) +{ + uint8_t const *p = (uint8_t const *)pp; + + return ((p[0] << 8) | p[1]); +} + +static __inline void +be16enc(void *pp, uint16_t u) +{ + uint8_t *p = (uint8_t *)pp; + + p[0] = (u >> 8) & 0xff; + p[1] = u & 0xff; +} + +static __inline void +be32enc(void *pp, uint32_t u) +{ + uint8_t *p = (uint8_t *)pp; + + p[0] = (u >> 24) & 0xff; + p[1] = (u >> 16) & 0xff; + p[2] = (u >> 8) & 0xff; + p[3] = u & 0xff; +} + +static __inline void +be64enc(void *pp, uint64_t u) +{ + uint8_t *p = (uint8_t *)pp; + + be32enc(p, (uint32_t)(u >> 32)); + be32enc(p + 4, (uint32_t)(u & 0xffffffffU)); +} + +static __inline uint16_t +le16dec(const void *pp) +{ + uint8_t const *p = (uint8_t const *)pp; + + return ((p[1] << 8) | p[0]); +} + +static __inline void +le16enc(void *pp, uint16_t u) +{ + uint8_t *p = (uint8_t *)pp; + + p[0] = u & 0xff; + p[1] = (u >> 8) & 0xff; +} + +static __inline void +le32enc(void *pp, uint32_t u) +{ + uint8_t *p = (uint8_t *)pp; + + p[0] = u & 0xff; + p[1] = (u >> 8) & 0xff; + p[2] = (u >> 16) & 0xff; + p[3] = (u >> 24) & 0xff; +} + +static __inline void +le64enc(void *pp, uint64_t u) +{ + uint8_t *p = (uint8_t *)pp; + + le32enc(p, (uint32_t)(u & 0xffffffffU)); + le32enc(p + 4, (uint32_t)(u >> 32)); +} + +#endif /* _MKIMG_ENDIAN_H_ */ Modified: stable/11/usr.bin/mkimg/format.c ============================================================================== --- stable/11/usr.bin/mkimg/format.c Fri Feb 9 04:45:39 2018 (r329058) +++ stable/11/usr.bin/mkimg/format.c Fri Feb 9 09:15:43 2018 (r329059) @@ -27,9 +27,6 @@ #include __FBSDID("$FreeBSD$"); -#include -#include -#include #include #include #include @@ -42,8 +39,24 @@ __FBSDID("$FreeBSD$"); #include "format.h" #include "mkimg.h" +static struct mkimg_format *first; static struct mkimg_format *format; +struct mkimg_format * +format_iterate(struct mkimg_format *f) +{ + + return ((f == NULL) ? first : f->next); +} + +void +format_register(struct mkimg_format *f) +{ + + f->next = first; + first = f; +} + int format_resize(lba_t end) { @@ -56,10 +69,10 @@ format_resize(lba_t end) int format_select(const char *spec) { - struct mkimg_format *f, **iter; + struct mkimg_format *f; - SET_FOREACH(iter, formats) { - f = *iter; + f = NULL; + while ((f = format_iterate(f)) != NULL) { if (strcasecmp(spec, f->name) == 0) { format = f; return (0); Modified: stable/11/usr.bin/mkimg/format.h ============================================================================== --- stable/11/usr.bin/mkimg/format.h Fri Feb 9 04:45:39 2018 (r329058) +++ stable/11/usr.bin/mkimg/format.h Fri Feb 9 09:15:43 2018 (r329059) @@ -29,21 +29,24 @@ #ifndef _MKIMG_FORMAT_H_ #define _MKIMG_FORMAT_H_ -#include - struct mkimg_format { + struct mkimg_format *next; const char *name; const char *description; int (*resize)(lba_t); int (*write)(int); }; -SET_DECLARE(formats, struct mkimg_format); -#define FORMAT_DEFINE(nm) DATA_SET(formats, nm) +#define FORMAT_DEFINE(nm) \ +static void format_register_##nm(void) __attribute__((constructor)); \ +static void format_register_##nm(void) { format_register(&nm); } -int format_resize(lba_t); +struct mkimg_format *format_iterate(struct mkimg_format *); +void format_register(struct mkimg_format *); int format_select(const char *); struct mkimg_format *format_selected(void); + +int format_resize(lba_t); int format_write(int); #endif /* _MKIMG_FORMAT_H_ */ Modified: stable/11/usr.bin/mkimg/gpt.c ============================================================================== --- stable/11/usr.bin/mkimg/gpt.c Fri Feb 9 04:45:39 2018 (r329058) +++ stable/11/usr.bin/mkimg/gpt.c Fri Feb 9 09:15:43 2018 (r329059) @@ -27,18 +27,17 @@ #include __FBSDID("$FreeBSD$"); -#include -#include -#include #include -#include #include #include #include #include #include -#include +#include +#include + +#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" @@ -131,21 +130,6 @@ crc32(const void *buf, size_t sz) return (crc ^ ~0U); } -static void -gpt_uuid_enc(void *buf, const uuid_t *uuid) -{ - uint8_t *p = buf; - int i; - - le32enc(p, uuid->time_low); - le16enc(p + 4, uuid->time_mid); - le16enc(p + 6, uuid->time_hi_and_version); - p[8] = uuid->clock_seq_hi_and_reserved; - p[9] = uuid->clock_seq_low; - for (i = 0; i < _UUID_NODE_LEN; i++) - p[10 + i] = uuid->node[i]; -} - static u_int gpt_tblsz(void) { @@ -173,7 +157,7 @@ gpt_write_pmbr(lba_t blks, void *bootcode) uint32_t secs; int error; - secs = (blks > UINT32_MAX) ? UINT32_MAX : (uint32_t)blks; + secs = (blks > UINT32_MAX) ? UINT32_MAX : (uint32_t)blks - 1; pmbr = malloc(secsz); if (pmbr == NULL) @@ -199,7 +183,7 @@ gpt_write_pmbr(lba_t blks, void *bootcode) static struct gpt_ent * gpt_mktbl(u_int tblsz) { - uuid_t uuid; + mkimg_uuid_t uuid; struct gpt_ent *tbl, *ent; struct part *part; int c, idx; @@ -208,11 +192,11 @@ gpt_mktbl(u_int tblsz) if (tbl == NULL) return (NULL); - STAILQ_FOREACH(part, &partlist, link) { + TAILQ_FOREACH(part, &partlist, link) { ent = tbl + part->index; - gpt_uuid_enc(&ent->ent_type, ALIAS_TYPE2PTR(part->type)); + mkimg_uuid_enc(&ent->ent_type, ALIAS_TYPE2PTR(part->type)); mkimg_uuid(&uuid); - gpt_uuid_enc(&ent->ent_uuid, &uuid); + mkimg_uuid_enc(&ent->ent_uuid, &uuid); le64enc(&ent->ent_lba_start, part->block); le64enc(&ent->ent_lba_end, part->block + part->size - 1); if (part->label != NULL) { @@ -243,7 +227,7 @@ gpt_write_hdr(struct gpt_hdr *hdr, uint64_t self, uint static int gpt_write(lba_t imgsz, void *bootcode) { - uuid_t uuid; + mkimg_uuid_t uuid; struct gpt_ent *tbl; struct gpt_hdr *hdr; uint32_t crc; @@ -280,7 +264,7 @@ gpt_write(lba_t imgsz, void *bootcode) le64enc(&hdr->hdr_lba_start, 2 + tblsz); le64enc(&hdr->hdr_lba_end, imgsz - tblsz - 2); mkimg_uuid(&uuid); - gpt_uuid_enc(&hdr->hdr_uuid, &uuid); + mkimg_uuid_enc(&hdr->hdr_uuid, &uuid); le32enc(&hdr->hdr_entries, nparts); le32enc(&hdr->hdr_entsz, sizeof(struct gpt_ent)); crc = crc32(tbl, nparts * sizeof(struct gpt_ent)); Modified: stable/11/usr.bin/mkimg/image.c ============================================================================== --- stable/11/usr.bin/mkimg/image.c Fri Feb 9 04:45:39 2018 (r329058) +++ stable/11/usr.bin/mkimg/image.c Fri Feb 9 09:15:43 2018 (r329059) @@ -28,9 +28,7 @@ __FBSDID("$FreeBSD$"); #include -#include #include -#include #include #include #include @@ -45,8 +43,22 @@ __FBSDID("$FreeBSD$"); #include "image.h" #include "mkimg.h" +#ifndef MAP_NOCORE +#define MAP_NOCORE 0 +#endif +#ifndef MAP_NOSYNC +#define MAP_NOSYNC 0 +#endif + +#ifndef SEEK_DATA +#define SEEK_DATA -1 +#endif +#ifndef SEEK_HOLE +#define SEEK_HOLE -1 +#endif + struct chunk { - STAILQ_ENTRY(chunk) ch_list; + TAILQ_ENTRY(chunk) ch_list; size_t ch_size; /* Size of chunk in bytes. */ lba_t ch_block; /* Block address in image. */ union { @@ -64,7 +76,7 @@ struct chunk { #define CH_TYPE_MEMORY 2 /* Memory-backed chunk */ }; -static STAILQ_HEAD(chunk_head, chunk) image_chunks; +static TAILQ_HEAD(chunk_head, chunk) image_chunks; static u_int image_nchunks; static char image_swap_file[PATH_MAX]; @@ -125,14 +137,14 @@ image_chunk_find(lba_t blk) struct chunk *ch; ch = (last != NULL && last->ch_block <= blk) - ? last : STAILQ_FIRST(&image_chunks); + ? last : TAILQ_FIRST(&image_chunks); while (ch != NULL) { if (ch->ch_block <= blk && (lba_t)(ch->ch_block + (ch->ch_size / secsz)) > blk) { last = ch; break; } - ch = STAILQ_NEXT(ch, ch_list); + ch = TAILQ_NEXT(ch, ch_list); } return (ch); } @@ -174,7 +186,7 @@ image_chunk_memory(struct chunk *ch, lba_t blk) ch->ch_size = (blk - ch->ch_block) * secsz; new->ch_block = blk; new->ch_size -= ch->ch_size; - STAILQ_INSERT_AFTER(&image_chunks, ch, new, ch_list); + TAILQ_INSERT_AFTER(&image_chunks, ch, new, ch_list); image_nchunks++; ch = new; } @@ -189,7 +201,7 @@ image_chunk_memory(struct chunk *ch, lba_t blk) ch->ch_size = secsz; new->ch_block++; new->ch_size -= secsz; - STAILQ_INSERT_AFTER(&image_chunks, ch, new, ch_list); + TAILQ_INSERT_AFTER(&image_chunks, ch, new, ch_list); image_nchunks++; } @@ -205,7 +217,7 @@ image_chunk_skipto(lba_t to) lba_t from; size_t sz; - ch = STAILQ_LAST(&image_chunks, chunk, ch_list); + ch = TAILQ_LAST(&image_chunks, chunk_head); from = (ch != NULL) ? ch->ch_block + (ch->ch_size / secsz) : 0LL; assert(from <= to); @@ -230,7 +242,7 @@ image_chunk_skipto(lba_t to) ch->ch_block = from; ch->ch_size = sz; ch->ch_type = CH_TYPE_ZEROES; - STAILQ_INSERT_TAIL(&image_chunks, ch, ch_list); + TAILQ_INSERT_TAIL(&image_chunks, ch, ch_list); image_nchunks++; return (0); } @@ -240,7 +252,7 @@ image_chunk_append(lba_t blk, size_t sz, off_t ofs, in { struct chunk *ch; - ch = STAILQ_LAST(&image_chunks, chunk, ch_list); + ch = TAILQ_LAST(&image_chunks, chunk_head); if (ch != NULL && ch->ch_type == CH_TYPE_FILE) { if (fd == ch->ch_u.file.fd && blk == (lba_t)(ch->ch_block + (ch->ch_size / secsz)) && @@ -261,7 +273,7 @@ image_chunk_append(lba_t blk, size_t sz, off_t ofs, in ch->ch_type = CH_TYPE_FILE; ch->ch_u.file.ofs = ofs; ch->ch_u.file.fd = fd; - STAILQ_INSERT_TAIL(&image_chunks, ch, ch_list); + TAILQ_INSERT_TAIL(&image_chunks, ch, ch_list); image_nchunks++; return (0); } @@ -456,8 +468,7 @@ image_copyin_mapped(lba_t blk, int fd, uint64_t *sizep * I don't know what this means or whether it * can happen at all... */ - error = EDOOFUS; - break; + assert(0); } } if (error) @@ -583,10 +594,13 @@ image_copyout_region(int fd, lba_t blk, lba_t size) size *= secsz; - while (size > 0) { + error = 0; + while (!error && size > 0) { ch = image_chunk_find(blk); - if (ch == NULL) - return (EINVAL); + if (ch == NULL) { + error = EINVAL; + break; + } ofs = (blk - ch->ch_block) * secsz; sz = ch->ch_size - ofs; sz = ((lba_t)sz < size) ? sz : (size_t)size; @@ -602,12 +616,12 @@ image_copyout_region(int fd, lba_t blk, lba_t size) error = image_copyout_memory(fd, sz, ch->ch_u.mem.ptr); break; default: - return (EDOOFUS); + assert(0); } size -= sz; blk += sz / secsz; } - return (0); + return (error); } int @@ -682,7 +696,7 @@ image_cleanup(void) { struct chunk *ch; - while ((ch = STAILQ_FIRST(&image_chunks)) != NULL) { + while ((ch = TAILQ_FIRST(&image_chunks)) != NULL) { switch (ch->ch_type) { case CH_TYPE_FILE: /* We may be closing the same file multiple times. */ @@ -695,7 +709,7 @@ image_cleanup(void) default: break; } - STAILQ_REMOVE_HEAD(&image_chunks, ch_list); + TAILQ_REMOVE(&image_chunks, ch, ch_list); free(ch); } if (image_swap_fd != -1) @@ -708,7 +722,7 @@ image_init(void) { const char *tmpdir; - STAILQ_INIT(&image_chunks); + TAILQ_INIT(&image_chunks); image_nchunks = 0; image_swap_size = 0; Modified: stable/11/usr.bin/mkimg/mbr.c ============================================================================== --- stable/11/usr.bin/mkimg/mbr.c Fri Feb 9 04:45:39 2018 (r329058) +++ stable/11/usr.bin/mkimg/mbr.c Fri Feb 9 09:15:43 2018 (r329059) @@ -27,14 +27,15 @@ #include __FBSDID("$FreeBSD$"); -#include -#include -#include #include +#include #include #include #include +#include + +#include "endian.h" #include "image.h" #include "mkimg.h" #include "scheme.h" @@ -101,10 +102,15 @@ mbr_write(lba_t imgsz __unused, void *bootcode) memset(mbr, 0, secsz); le16enc(mbr + DOSMAGICOFFSET, DOSMAGIC); dpbase = (void *)(mbr + DOSPARTOFF); - STAILQ_FOREACH(part, &partlist, link) { + TAILQ_FOREACH(part, &partlist, link) { size = round_track(part->size); dp = dpbase + part->index; - dp->dp_flag = (part->index == 0 && bootcode != NULL) ? 0x80 : 0; + if (active_partition != 0) + dp->dp_flag = + (part->index + 1 == active_partition) ? 0x80 : 0; + else + dp->dp_flag = + (part->index == 0 && bootcode != NULL) ? 0x80 : 0; mbr_chs(&dp->dp_scyl, &dp->dp_shd, &dp->dp_ssect, part->block); dp->dp_typ = ALIAS_TYPE2INT(part->type); Modified: stable/11/usr.bin/mkimg/mkimg.1 ============================================================================== --- stable/11/usr.bin/mkimg/mkimg.1 Fri Feb 9 04:45:39 2018 (r329058) +++ stable/11/usr.bin/mkimg/mkimg.1 Fri Feb 9 09:15:43 2018 (r329059) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 7, 2015 +.Dd April 26, 2017 .Dt MKIMG 1 .Os .Sh NAME @@ -37,9 +37,12 @@ .Op Fl S Ar secsz .Op Fl T Ar tracksz .Op Fl b Ar bootcode -.Op Fl c Ar capacity +.Op Fl c Ar min_capacity +.Op Fl C Ar max_capacity +.Op Fl -capacity Ar capacity .Op Fl f Ar format .Op Fl o Ar outfile +.Op Fl a Ar active .Op Fl v .Op Fl y .Op Fl s Ar scheme Op Fl p Ar partition ... @@ -119,11 +122,23 @@ An empty partition table can be written to the disk wh partitioning scheme with the .Fl s option, but without specifying any partitions. -When the size required to for all the partitions is larger than the +When the size required for all the partitions is larger than the given capacity, then the disk image will be larger than the capacity given. .Pp The +.Fl C +option specifies a maximum capacity for the disk image. +If the combined sizes of the given partitions exceed the size given with +.Fl C , +image creation fails. +.Pp +The +.Fl -capacity +option is a shorthand to specify the minimum and maximum capacity at the +same time. +.Pp +The .Fl v option increases the level of output that the .Nm @@ -138,6 +153,26 @@ utility will generate predictable values for Universal (UUIDs) and time stamps so that consecutive runs of the .Nm utility will create images that are identical. +.Pp +The +.Ar active +option marks a partition as active, if the partitioning +scheme supports it. +Currently, only the +.Ar mbr +scheme supports this concept. +By default, +.Nm +will only mark the first partition as active when boot code is +specified. +Use the +.Ar active +option to override the active partition. +The number specified corresponds to the number after the 's' in the +partition's +.Xr geom 8 +name. +No partitions are marked active when the value is 0. .Pp A set of long options exist to query about the .Nm Modified: stable/11/usr.bin/mkimg/mkimg.c ============================================================================== --- stable/11/usr.bin/mkimg/mkimg.c Fri Feb 9 04:45:39 2018 (r329058) +++ stable/11/usr.bin/mkimg/mkimg.c Fri Feb 9 09:15:43 2018 (r329059) @@ -27,17 +27,15 @@ #include __FBSDID("$FreeBSD$"); -#include -#include +#include #include -#include -#include #include #include #include #include #include #include +#include #include #include #include @@ -49,20 +47,23 @@ __FBSDID("$FreeBSD$"); #include "mkimg.h" #include "scheme.h" -#define LONGOPT_FORMATS 0x01000001 -#define LONGOPT_SCHEMES 0x01000002 -#define LONGOPT_VERSION 0x01000003 +#define LONGOPT_FORMATS 0x01000001 +#define LONGOPT_SCHEMES 0x01000002 +#define LONGOPT_VERSION 0x01000003 +#define LONGOPT_CAPACITY 0x01000004 static struct option longopts[] = { { "formats", no_argument, NULL, LONGOPT_FORMATS }, { "schemes", no_argument, NULL, LONGOPT_SCHEMES }, { "version", no_argument, NULL, LONGOPT_VERSION }, + { "capacity", required_argument, NULL, LONGOPT_CAPACITY }, { NULL, 0, NULL, 0 } }; -static uint64_t capacity; +static uint64_t min_capacity = 0; +static uint64_t max_capacity = 0; -struct partlisthead partlist = STAILQ_HEAD_INITIALIZER(partlist); +struct partlisthead partlist = TAILQ_HEAD_INITIALIZER(partlist); u_int nparts = 0; u_int unit_testing; @@ -73,24 +74,25 @@ u_int nheads = 1; u_int nsecs = 1; u_int secsz = 512; u_int blksz = 0; +uint32_t active_partition = 0; static void print_formats(int usage) { - struct mkimg_format *f, **f_iter; + struct mkimg_format *f; const char *sep; if (usage) { fprintf(stderr, " formats:\n"); - SET_FOREACH(f_iter, formats) { - f = *f_iter; + f = NULL; + while ((f = format_iterate(f)) != NULL) { fprintf(stderr, "\t%s\t- %s\n", f->name, f->description); } } else { sep = ""; - SET_FOREACH(f_iter, formats) { - f = *f_iter; + f = NULL; + while ((f = format_iterate(f)) != NULL) { printf("%s%s", sep, f->name); sep = " "; } @@ -101,20 +103,20 @@ print_formats(int usage) static void print_schemes(int usage) { - struct mkimg_scheme *s, **s_iter; + struct mkimg_scheme *s; const char *sep; if (usage) { fprintf(stderr, " schemes:\n"); - SET_FOREACH(s_iter, schemes) { - s = *s_iter; + s = NULL; + while ((s = scheme_iterate(s)) != NULL) { fprintf(stderr, "\t%s\t- %s\n", s->name, s->description); } } else { sep = ""; - SET_FOREACH(s_iter, schemes) { - s = *s_iter; + s = NULL; + while ((s = scheme_iterate(s)) != NULL) { printf("%s%s", sep, s->name); sep = " "; } @@ -148,8 +150,10 @@ usage(const char *why) fprintf(stderr, "\t--schemes\t- list partition schemes\n"); fprintf(stderr, "\t--version\t- show version information\n"); fputc('\n', stderr); + fprintf(stderr, "\t-a \t- mark num'th partion as active\n"); fprintf(stderr, "\t-b \t- file containing boot code\n"); - fprintf(stderr, "\t-c \t- capacity (in bytes) of the disk\n"); + fprintf(stderr, "\t-c \t- minimum capacity (in bytes) of the disk\n"); + fprintf(stderr, "\t-C \t- maximum capacity (in bytes) of the disk\n"); fprintf(stderr, "\t-f \n"); fprintf(stderr, "\t-o \t- file to write image into\n"); fprintf(stderr, "\t-p \n"); @@ -302,7 +306,7 @@ parse_part(const char *spec) } part->index = nparts; - STAILQ_INSERT_TAIL(&partlist, part, link); + TAILQ_INSERT_TAIL(&partlist, part, link); nparts++; return (0); @@ -376,31 +380,20 @@ mkimg_chs(lba_t lba, u_int maxcyl, u_int *cylp, u_int *secp = sec; } -void -mkimg_uuid(struct uuid *uuid) -{ - static uint8_t gen[sizeof(struct uuid)]; - u_int i; - - if (!unit_testing) { - uuidgen(uuid, 1); - return; - } - - for (i = 0; i < sizeof(gen); i++) - gen[i]++; - memcpy(uuid, gen, sizeof(uuid_t)); -} - static int capacity_resize(lba_t end) { - lba_t capsz; + lba_t min_capsz, max_capsz; - capsz = (capacity + secsz - 1) / secsz; - if (end >= capsz) + min_capsz = (min_capacity + secsz - 1) / secsz; + max_capsz = (max_capacity + secsz - 1) / secsz; + + if (max_capsz != 0 && end > max_capsz) + return (ENOSPC); + if (end >= min_capsz) return (0); - return (image_set_size(capsz)); + + return (image_set_size(min_capsz)); } static void @@ -413,14 +406,14 @@ mkimg(void) int error, fd; /* First check partition information */ - STAILQ_FOREACH(part, &partlist, link) { + TAILQ_FOREACH(part, &partlist, link) { error = scheme_check_part(part); if (error) errc(EX_DATAERR, error, "partition %d", part->index+1); } block = scheme_metadata(SCHEME_META_IMG_START, 0); - STAILQ_FOREACH(part, &partlist, link) { + TAILQ_FOREACH(part, &partlist, link) { block = scheme_metadata(SCHEME_META_PART_BEFORE, block); if (verbose) fprintf(stderr, "partition %d: starting block %llu " @@ -487,9 +480,14 @@ main(int argc, char *argv[]) bcfd = -1; outfd = 1; /* Write to stdout by default */ - while ((c = getopt_long(argc, argv, "b:c:f:o:p:s:vyH:P:S:T:", + while ((c = getopt_long(argc, argv, "a:b:c:C:f:o:p:s:vyH:P:S:T:", longopts, NULL)) != -1) { switch (c) { + case 'a': /* ACTIVE PARTITION, if supported */ + error = parse_uint32(&active_partition, 1, 100, optarg); + if (error) + errc(EX_DATAERR, error, "Partition ordinal"); + break; case 'b': /* BOOT CODE */ if (bcfd != -1) usage("multiple bootcode given"); @@ -497,11 +495,16 @@ main(int argc, char *argv[]) if (bcfd == -1) err(EX_UNAVAILABLE, "%s", optarg); break; - case 'c': /* CAPACITY */ - error = parse_uint64(&capacity, 1, OFF_MAX, optarg); + case 'c': /* MINIMUM CAPACITY */ + error = parse_uint64(&min_capacity, 1, INT64_MAX, optarg); if (error) - errc(EX_DATAERR, error, "capacity in bytes"); + errc(EX_DATAERR, error, "minimum capacity in bytes"); break; + case 'C': /* MAXIMUM CAPACITY */ + error = parse_uint64(&max_capacity, 1, INT64_MAX, optarg); + if (error) + errc(EX_DATAERR, error, "maximum capacity in bytes"); + break; case 'f': /* OUTPUT FORMAT */ if (format_selected() != NULL) usage("multiple formats given"); @@ -571,6 +574,12 @@ main(int argc, char *argv[]) print_version(); exit(EX_OK); /*NOTREACHED*/ + case LONGOPT_CAPACITY: + error = parse_uint64(&min_capacity, 1, INT64_MAX, optarg); + if (error) + errc(EX_DATAERR, error, "capacity in bytes"); + max_capacity = min_capacity; + break; default: usage("unknown option"); } @@ -580,8 +589,10 @@ main(int argc, char *argv[]) usage("trailing arguments"); if (scheme_selected() == NULL && nparts > 0) usage("no scheme"); - if (nparts == 0 && capacity == 0) + if (nparts == 0 && min_capacity == 0) usage("no partitions"); + if (max_capacity != 0 && min_capacity > max_capacity) + usage("minimum capacity cannot be larger than the maximum one"); if (secsz > blksz) { if (blksz != 0) Modified: stable/11/usr.bin/mkimg/mkimg.h ============================================================================== --- stable/11/usr.bin/mkimg/mkimg.h Fri Feb 9 04:45:39 2018 (r329058) +++ stable/11/usr.bin/mkimg/mkimg.h Fri Feb 9 09:15:43 2018 (r329059) @@ -30,9 +30,10 @@ #define _MKIMG_MKIMG_H_ #include +#include struct part { - STAILQ_ENTRY(part) link; + TAILQ_ENTRY(part) link; char *alias; /* Partition type alias. */ char *contents; /* Contents/size specification. */ u_int kind; /* Content kind. */ @@ -47,7 +48,7 @@ struct part { char *label; /* Partition label. */ }; -extern STAILQ_HEAD(partlisthead, part) partlist; +extern TAILQ_HEAD(partlisthead, part) partlist; extern u_int nparts; extern u_int unit_testing; @@ -58,6 +59,7 @@ extern u_int nheads; extern u_int nsecs; extern u_int secsz; /* Logical block size. */ extern u_int blksz; /* Physical block size. */ +extern uint32_t active_partition; static inline lba_t round_block(lba_t n) @@ -89,7 +91,17 @@ ssize_t sparse_write(int, const void *, size_t); void mkimg_chs(lba_t, u_int, u_int *, u_int *, u_int *); -struct uuid; -void mkimg_uuid(struct uuid *); +struct mkimg_uuid { + uint32_t time_low; + uint16_t time_mid; + uint16_t time_hi_and_version; + uint8_t clock_seq_hi_and_reserved; + uint8_t clock_seq_low; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Fri Feb 9 17:25:35 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8233AF152A7; Fri, 9 Feb 2018 17:25:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 357AA6E9B0; Fri, 9 Feb 2018 17:25:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2BD4427CA5; Fri, 9 Feb 2018 17:25:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w19HPZt3067706; Fri, 9 Feb 2018 17:25:35 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w19HPZFC067705; Fri, 9 Feb 2018 17:25:35 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802091725.w19HPZFC067705@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Fri, 9 Feb 2018 17:25:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329070 - stable/11/sys/boot/i386/libi386 X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/sys/boot/i386/libi386 X-SVN-Commit-Revision: 329070 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Feb 2018 17:25:35 -0000 Author: kevans Date: Fri Feb 9 17:25:34 2018 New Revision: 329070 URL: https://svnweb.freebsd.org/changeset/base/329070 Log: MFC r327606: Handle misconfigured/nonexistent pcidev for comconsole instead of BTX panic. [This is effectively a direct commit to stable/11 due to path restructuring in head. Diffs have simply been applied to previous location] PR: 203319 Modified: stable/11/sys/boot/i386/libi386/comconsole.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/boot/i386/libi386/comconsole.c ============================================================================== --- stable/11/sys/boot/i386/libi386/comconsole.c Fri Feb 9 17:01:30 2018 (r329069) +++ stable/11/sys/boot/i386/libi386/comconsole.c Fri Feb 9 17:25:34 2018 (r329070) @@ -267,6 +267,16 @@ comc_pcidev_handle(uint32_t locator) printf("Cannot read bar at 0x%x\n", locator); return (CMD_ERROR); } + + /* + * biospci_read_config() sets port == 0xffffffff if the pcidev + * isn't found on the bus. Check for 0xffffffff and return to not + * panic in BTX. + */ + if (port == 0xffffffff) { + printf("Cannot find specified pcidev\n"); + return (CMD_ERROR); + } if (!PCI_BAR_IO(port)) { printf("Memory bar at 0x%x\n", locator); return (CMD_ERROR); From owner-svn-src-stable-11@freebsd.org Sat Feb 10 00:39:35 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BAEA3F10172; Sat, 10 Feb 2018 00:39:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6D56C81C9F; Sat, 10 Feb 2018 00:39:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 63A9E47F3; Sat, 10 Feb 2018 00:39:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1A0dZvi087758; Sat, 10 Feb 2018 00:39:35 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1A0dZO7087757; Sat, 10 Feb 2018 00:39:35 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201802100039.w1A0dZO7087757@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 10 Feb 2018 00:39:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329095 - stable/11/sys/modules/nvme X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/modules/nvme X-SVN-Commit-Revision: 329095 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Feb 2018 00:39:35 -0000 Author: mav Date: Sat Feb 10 00:39:34 2018 New Revision: 329095 URL: https://svnweb.freebsd.org/changeset/base/329095 Log: MFC r325795 (by imp): Belatedly add opt_nvme.h to fix building nvme.ko outside of a kernel build. Modified: stable/11/sys/modules/nvme/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/modules/nvme/Makefile ============================================================================== --- stable/11/sys/modules/nvme/Makefile Sat Feb 10 00:27:29 2018 (r329094) +++ stable/11/sys/modules/nvme/Makefile Sat Feb 10 00:39:34 2018 (r329095) @@ -17,6 +17,7 @@ SRCS = nvme.c \ bus_if.h \ device_if.h \ opt_cam.h \ + opt_nvme.h \ pci_if.h .include From owner-svn-src-stable-11@freebsd.org Sat Feb 10 01:52:58 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CC113F15842; Sat, 10 Feb 2018 01:52:58 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7EC8285BFE; Sat, 10 Feb 2018 01:52:58 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 79689566F; Sat, 10 Feb 2018 01:52:58 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1A1qwJx028838; Sat, 10 Feb 2018 01:52:58 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1A1qwE9028836; Sat, 10 Feb 2018 01:52:58 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802100152.w1A1qwE9028836@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sat, 10 Feb 2018 01:52:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329098 - stable/11/lib/libstand X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/lib/libstand X-SVN-Commit-Revision: 329098 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Feb 2018 01:52:59 -0000 Author: kevans Date: Sat Feb 10 01:52:58 2018 New Revision: 329098 URL: https://svnweb.freebsd.org/changeset/base/329098 Log: MFC libstand catch-up: r305116,306534,306538,306552,306638 r305116: recvtftp() is broken for large files, report file size r306534: cd9660_open should check for padding r306538: cstyle fix of cd9660_open in libstand r306552: Fix remaining cstyle issues in libstand/cd9660.c r306638: Fix remaining bugs in libstand/cd9660.c reported by Bruce Evans. PR: 200500 Modified: stable/11/lib/libstand/cd9660.c stable/11/lib/libstand/tftp.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libstand/cd9660.c ============================================================================== --- stable/11/lib/libstand/cd9660.c Sat Feb 10 01:09:22 2018 (r329097) +++ stable/11/lib/libstand/cd9660.c Sat Feb 10 01:52:58 2018 (r329098) @@ -353,6 +353,12 @@ cd9660_open(const char *path, struct open_file *f) dp = (struct iso_directory_record *) ((char *) dp + isonum_711(dp->length)); + /* If the new block has zero length, it is padding. */ + if (isonum_711(dp->length) == 0) { + /* Skip to next block, if any. */ + off = boff * ISO_DEFAULT_BLOCK_SIZE; + continue; + } off += isonum_711(dp->length); } if (off >= dsize) { Modified: stable/11/lib/libstand/tftp.c ============================================================================== --- stable/11/lib/libstand/tftp.c Sat Feb 10 01:09:22 2018 (r329097) +++ stable/11/lib/libstand/tftp.c Sat Feb 10 01:52:58 2018 (r329098) @@ -200,7 +200,7 @@ recvtftp(struct tftp_handle *h, void *pkt, ssize_t len case DATA: { int got; - if (htons(t->th_block) != d->xid) { + if (htons(t->th_block) != (u_short) d->xid) { /* * Expected block? */ @@ -563,7 +563,7 @@ tftp_stat(struct open_file *f, struct stat *sb) sb->st_nlink = 1; sb->st_uid = 0; sb->st_gid = 0; - sb->st_size = -1; + sb->st_size = (off_t) tftpfile->tftp_tsize; return (0); } @@ -734,6 +734,8 @@ tftp_parse_oack(struct tftp_handle *h, char *buf, size } else if (strcasecmp(tftp_options[i], "tsize") == 0) { if (i + 1 < option_idx) tsize = strtol(tftp_options[i + 1], (char **)NULL, 10); + if (tsize != 0) + h->tftp_tsize = tsize; } else { /* Do not allow any options we did not expect to be ACKed. */ printf("unexpected tftp option '%s'\n", tftp_options[i]); From owner-svn-src-stable-11@freebsd.org Sat Feb 10 04:37:45 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 64625F1CB70; Sat, 10 Feb 2018 04:37:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 166046BC0E; Sat, 10 Feb 2018 04:37:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 110C872E5; Sat, 10 Feb 2018 04:37:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1A4bj2j009178; Sat, 10 Feb 2018 04:37:45 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1A4biOi009170; Sat, 10 Feb 2018 04:37:44 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802100437.w1A4biOi009170@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sat, 10 Feb 2018 04:37:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329099 - in stable/11: lib/libstand sys/boot/common sys/boot/efi/include sys/boot/efi/libefi sys/boot/efi/loader sys/boot/forth sys/boot/geli sys/boot/i386/boot2 sys/boot/i386/btx/lib ... X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: lib/libstand sys/boot/common sys/boot/efi/include sys/boot/efi/libefi sys/boot/efi/loader sys/boot/forth sys/boot/geli sys/boot/i386/boot2 sys/boot/i386/btx/lib sys/boot/i386/common sys/... X-SVN-Commit-Revision: 329099 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Feb 2018 04:37:45 -0000 Author: kevans Date: Sat Feb 10 04:37:44 2018 New Revision: 329099 URL: https://svnweb.freebsd.org/changeset/base/329099 Log: MFC Loader Fixes 2017q1: r311458,r312237,r312314,r312374,r312947,r313042, r313047,r313166,r313328,r313332,r313333,r313337,r313348,r313349,r313389, r313442,r313451,r313575,r313645,r313710,r314114,r314213,r314275,r314945, r314948,r315008,r315408,r315427,r315645,r315646,r315648,r315653,r315850, r316064,r316078,r316079,r316100,r316104,r316111,r316112,r316171,r316279, r316280,r316287,r316311,r316343,r316424,r316436 r311458: Use compiler driver to link BERI boot loaders r312237: loader.efi: find_currdev() can leak memory r312314: loader: move device path definitions to include/efidevp.h r312374: loader: efi devpath api usage should be more aware of NULL pointers r312947: Remove "-Xassembler -G0" from CFLAGS. r313042: loader.efi environment related cleanups r313047: loader: disk/part api needs to use uint64_t offsets r313166: loader: libefi/env.c warnings in arm build r313328: loader: Implement disk_ioctl() to support DIOCGSECTORSIZE and DIOCGMEDIASIZE. r313332: loader: bcache read ahead block count should take account the large sectors r313333: loader: Replace EFI part devices. r313337: loader: 313329 missed ZFS guard in loader/main.c r313348: loader: biosdisk fix for 2+TB disks r313349: loader: disk io should not use alloca() r313389: efipart is also using the '%S' printf format, add -Wno-format for it. r313442: loader: possible NULL pointer dereference in efipart.c r313451: loader: possible NULL pointer dereference in bcache.c r313575: makefs: make the buffer functions look exactly like the kernel ones r313645: loader: implement MEDIA_FILEPATH_DP support in efipart r313710: loader: cstyle fixes and DIOCGMEDIASIZE should use uint64_t r314114: Use LDFLAGS with CC instead of _LDFLAGS. r314213: Remove control+r handling from geliboot's pwgets() r314275: Remove unused macro from common/drv.c. r314945: Some style(9) fixes. No functional changes. r314948: Try to extract the RFC1048 data from PXE. r315008: r314948 seems to be missing a variable or two that will break r315408: loader: remove open_disk cache r315427: loader: biosdisk should report IO error from INT13 r315645: loader: disk_cleanup was left in userboot_disk.c r315646: loader: pxe.h constants have wrong values r315648: libstand: verify value provided by nfs.read_size r315653: loader: verify the value from dhcp.interface-mtu and use snprintf o set mtu r315850: The original author abused Nd (one-line description, used by makewhatis) r316064: Fix build with path names with 'align' or 'nop' in them. r316078: gpt*boot: Save a bit more memory when LOADER_NO_GELI_SUPPORT is specified r316079: Simply retire the sedification of the boot2.s file. r316100: Remove -fno-guess-branch-probability and -fno-unit-at-a-time. r316104: Use `NO_WCAST_ALIGN` instead of spelling it out as -Wno-cast-align in CFLAGS r316111: loader: move bios getsecs into time.c r316112: loader: ls command should display file types properly r316171: xfsread inlined uses more space, so remove the inline tag. r316279: loader: efipart should check disk size from partition table r316280: loader: simplify efi_zfs_probe and avoid double probing for zfs. r316287: Remove OLD_NFSV2 from loader and libstand r316311: Add explicit_bzero() to libstand, and switch GELIBoot to using it r316343: Implement boot-time encryption key passing (keybuf) r316424: Fix sparc64 build broken by r316343 and r316076 r316436: Restore EFI boot environment functionality broken in r313333 PR: 216940 217298 217935 Added: stable/11/sys/boot/efi/libefi/wchar.c - copied unchanged from r313042, head/sys/boot/efi/libefi/wchar.c stable/11/sys/boot/geli/geliboot_internal.h - copied unchanged from r316343, head/sys/boot/geli/geliboot_internal.h stable/11/sys/crypto/intake.h - copied unchanged from r316343, head/sys/crypto/intake.h Modified: stable/11/lib/libstand/Makefile stable/11/lib/libstand/bootp.c stable/11/lib/libstand/bootp.h stable/11/lib/libstand/nfs.c stable/11/lib/libstand/nfsv2.h stable/11/lib/libstand/stand.h stable/11/sys/boot/common/bcache.c stable/11/sys/boot/common/bootstrap.h stable/11/sys/boot/common/dev_net.c stable/11/sys/boot/common/disk.c stable/11/sys/boot/common/disk.h stable/11/sys/boot/common/ls.c stable/11/sys/boot/common/part.c stable/11/sys/boot/common/part.h stable/11/sys/boot/efi/include/efidevp.h stable/11/sys/boot/efi/include/efilib.h stable/11/sys/boot/efi/libefi/Makefile stable/11/sys/boot/efi/libefi/devpath.c stable/11/sys/boot/efi/libefi/efinet.c stable/11/sys/boot/efi/libefi/efipart.c stable/11/sys/boot/efi/libefi/env.c stable/11/sys/boot/efi/loader/conf.c stable/11/sys/boot/efi/loader/devicename.c stable/11/sys/boot/efi/loader/main.c stable/11/sys/boot/forth/beastie.4th.8 stable/11/sys/boot/forth/loader.4th stable/11/sys/boot/geli/Makefile stable/11/sys/boot/geli/geliboot.c stable/11/sys/boot/geli/geliboot.h stable/11/sys/boot/geli/geliboot_crypto.c stable/11/sys/boot/geli/pwgets.c stable/11/sys/boot/i386/boot2/Makefile stable/11/sys/boot/i386/boot2/boot2.c stable/11/sys/boot/i386/btx/lib/btxv86.h stable/11/sys/boot/i386/common/bootargs.h stable/11/sys/boot/i386/common/drv.c stable/11/sys/boot/i386/gptboot/Makefile stable/11/sys/boot/i386/gptboot/gptboot.c stable/11/sys/boot/i386/gptzfsboot/Makefile stable/11/sys/boot/i386/libi386/bioscd.c stable/11/sys/boot/i386/libi386/biosdisk.c stable/11/sys/boot/i386/libi386/bootinfo32.c stable/11/sys/boot/i386/libi386/bootinfo64.c stable/11/sys/boot/i386/libi386/pxe.c stable/11/sys/boot/i386/libi386/pxe.h stable/11/sys/boot/i386/libi386/time.c stable/11/sys/boot/i386/loader/Makefile stable/11/sys/boot/i386/loader/main.c stable/11/sys/boot/i386/zfsboot/zfsboot.c stable/11/sys/boot/mips/beri/boot2/Makefile stable/11/sys/boot/mips/beri/common/common.ldscript stable/11/sys/boot/mips/beri/loader/beri_disk_cfi.c stable/11/sys/boot/mips/beri/loader/beri_disk_sdcard.c stable/11/sys/boot/mips/beri/loader/loader.ldscript stable/11/sys/boot/sparc64/loader/Makefile stable/11/sys/boot/uboot/lib/disk.c stable/11/sys/boot/usb/storage/umass_loader.c stable/11/sys/boot/userboot/userboot/userboot_disk.c stable/11/sys/boot/zfs/libzfs.h stable/11/sys/boot/zfs/zfs.c stable/11/sys/geom/eli/g_eli.c stable/11/sys/geom/eli/g_eli.h stable/11/sys/opencrypto/crypto.c stable/11/sys/sys/linker.h stable/11/usr.sbin/makefs/ffs.c stable/11/usr.sbin/makefs/ffs/buf.c stable/11/usr.sbin/makefs/ffs/buf.h stable/11/usr.sbin/makefs/ffs/ffs_alloc.c stable/11/usr.sbin/makefs/ffs/ffs_balloc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libstand/Makefile ============================================================================== --- stable/11/lib/libstand/Makefile Sat Feb 10 01:52:58 2018 (r329098) +++ stable/11/lib/libstand/Makefile Sat Feb 10 04:37:44 2018 (r329099) @@ -155,5 +155,9 @@ SRCS+= pkgfs.c SRCS+= nandfs.c .endif +# explicit_bzero +.PATH: ${SRCTOP}/sys/libkern +SRCS+= explicit_bzero.c + .include .include Modified: stable/11/lib/libstand/bootp.c ============================================================================== --- stable/11/lib/libstand/bootp.c Sat Feb 10 01:52:58 2018 (r329098) +++ stable/11/lib/libstand/bootp.c Sat Feb 10 04:37:44 2018 (r329099) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -344,6 +345,17 @@ bad: return (-1); } +int +dhcp_try_rfc1048(u_char *cp, u_int len) +{ + + expected_dhcpmsgtype = DHCPACK; + if (bcmp(vm_rfc1048, cp, sizeof(vm_rfc1048)) == 0) { + return (vend_rfc1048(cp, len)); + } + return (-1); +} + static int vend_rfc1048(cp, len) u_char *cp; @@ -392,11 +404,29 @@ vend_rfc1048(cp, len) strlcpy(hostname, val, sizeof(hostname)); } if (tag == TAG_INTF_MTU) { + intf_mtu = 0; if ((val = getenv("dhcp.interface-mtu")) != NULL) { - intf_mtu = (u_int)strtoul(val, NULL, 0); - } else { - intf_mtu = be16dec(cp); + unsigned long tmp; + char *end; + + errno = 0; + /* + * Do not allow MTU to exceed max IPv4 packet + * size, max value of 16-bit word. + */ + tmp = strtoul(val, &end, 0); + if (errno != 0 || + *val == '\0' || *end != '\0' || + tmp > USHRT_MAX) { + printf("%s: bad value: \"%s\", " + "ignoring\n", + "dhcp.interface-mtu", val); + } else { + intf_mtu = (u_int)tmp; + } } + if (intf_mtu <= 0) + intf_mtu = be16dec(cp); } #ifdef SUPPORT_DHCP if (tag == TAG_DHCP_MSGTYPE) { Modified: stable/11/lib/libstand/bootp.h ============================================================================== --- stable/11/lib/libstand/bootp.h Sat Feb 10 01:52:58 2018 (r329098) +++ stable/11/lib/libstand/bootp.h Sat Feb 10 04:37:44 2018 (r329099) @@ -22,6 +22,8 @@ * $FreeBSD$ */ +#ifndef _BOOTP_H_ +#define _BOOTP_H_ struct bootp { unsigned char bp_op; /* packet opcode type */ @@ -145,3 +147,7 @@ struct cmu_vend { /* v_flags values */ #define VF_SMASK 1 /* Subnet mask field contains valid data */ + +int dhcp_try_rfc1048(u_char *cp, u_int len); + +#endif /* _BOOTP_H_ */ Modified: stable/11/lib/libstand/nfs.c ============================================================================== --- stable/11/lib/libstand/nfs.c Sat Feb 10 01:52:58 2018 (r329098) +++ stable/11/lib/libstand/nfs.c Sat Feb 10 04:37:44 2018 (r329099) @@ -54,73 +54,6 @@ __FBSDID("$FreeBSD$"); #define NFSREAD_MIN_SIZE 1024 #define NFSREAD_MAX_SIZE 4096 -/* Define our own NFS attributes without NQNFS stuff. */ -#ifdef OLD_NFSV2 -struct nfsv2_fattrs { - n_long fa_type; - n_long fa_mode; - n_long fa_nlink; - n_long fa_uid; - n_long fa_gid; - n_long fa_size; - n_long fa_blocksize; - n_long fa_rdev; - n_long fa_blocks; - n_long fa_fsid; - n_long fa_fileid; - struct nfsv2_time fa_atime; - struct nfsv2_time fa_mtime; - struct nfsv2_time fa_ctime; -}; - -struct nfs_read_args { - u_char fh[NFS_FHSIZE]; - n_long off; - n_long len; - n_long xxx; /* XXX what's this for? */ -}; - -/* Data part of nfs rpc reply (also the largest thing we receive) */ -struct nfs_read_repl { - n_long errno; - struct nfsv2_fattrs fa; - n_long count; - u_char data[NFSREAD_MAX_SIZE]; -}; - -#ifndef NFS_NOSYMLINK -struct nfs_readlnk_repl { - n_long errno; - n_long len; - char path[NFS_MAXPATHLEN]; -}; -#endif - -struct nfs_readdir_args { - u_char fh[NFS_FHSIZE]; - n_long cookie; - n_long count; -}; - -struct nfs_readdir_data { - n_long fileid; - n_long len; - char name[0]; -}; - -struct nfs_readdir_off { - n_long cookie; - n_long follows; -}; - -struct nfs_iodesc { - struct iodesc *iodesc; - off_t off; - u_char fh[NFS_FHSIZE]; - struct nfsv2_fattrs fa; /* all in network order */ -}; -#else /* !OLD_NFSV2 */ - /* NFSv3 definitions */ #define NFS_V3MAXFHSIZE 64 #define NFS_VER3 3 @@ -185,7 +118,6 @@ struct nfs_iodesc { struct nfsv3_fattrs fa; /* all in network order */ uint64_t cookie; }; -#endif /* OLD_NFSV2 */ /* * XXX interactions with tftp? See nfswrapper.c for a confusing @@ -214,622 +146,39 @@ struct fs_ops nfs_fsops = { static int nfs_read_size = NFSREAD_MIN_SIZE; -#ifdef OLD_NFSV2 /* - * Fetch the root file handle (call mount daemon) - * Return zero or error number. + * Improve boot performance over NFS */ -int -nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp) +static void +set_nfs_read_size(void) { - int len; - struct args { - n_long len; - char path[FNAME_SIZE]; - } *args; - struct repl { - n_long errno; - u_char fh[NFS_FHSIZE]; - } *repl; - struct { - n_long h[RPC_HEADER_WORDS]; - struct args d; - } sdata; - struct { - n_long h[RPC_HEADER_WORDS]; - struct repl d; - } rdata; - size_t cc; + char *env, *end; + char buf[10]; -#ifdef NFS_DEBUG - if (debug) - printf("nfs_getrootfh: %s\n", path); -#endif - - args = &sdata.d; - repl = &rdata.d; - - bzero(args, sizeof(*args)); - len = strlen(path); - if (len > sizeof(args->path)) - len = sizeof(args->path); - args->len = htonl(len); - bcopy(path, args->path, len); - len = 4 + roundup(len, 4); - - cc = rpc_call(d, RPCPROG_MNT, RPCMNT_VER1, RPCMNT_MOUNT, - args, len, repl, sizeof(*repl)); - if (cc == -1) { - /* errno was set by rpc_call */ - return (errno); + if ((env = getenv("nfs.read_size")) != NULL) { + errno = 0; + nfs_read_size = (int)strtol(env, &end, 0); + if (errno != 0 || *env == '\0' || *end != '\0') { + printf("%s: bad value: \"%s\", defaulting to %d\n", + "nfs.read_size", env, NFSREAD_MIN_SIZE); + nfs_read_size = NFSREAD_MIN_SIZE; + } } - if (cc < 4) - return (EBADRPC); - if (repl->errno) - return (ntohl(repl->errno)); - bcopy(repl->fh, fhp, sizeof(repl->fh)); - - /* - * Improve boot performance over NFS - */ - if (getenv("nfs.read_size") != NULL) - nfs_read_size = strtol(getenv("nfs.read_size"), NULL, 0); - if (nfs_read_size < NFSREAD_MIN_SIZE) + if (nfs_read_size < NFSREAD_MIN_SIZE) { + printf("%s: bad value: \"%d\", defaulting to %d\n", + "nfs.read_size", nfs_read_size, NFSREAD_MIN_SIZE); nfs_read_size = NFSREAD_MIN_SIZE; - if (nfs_read_size > NFSREAD_MAX_SIZE) + } + if (nfs_read_size > NFSREAD_MAX_SIZE) { + printf("%s: bad value: \"%d\", defaulting to %d\n", + "nfs.read_size", nfs_read_size, NFSREAD_MIN_SIZE); nfs_read_size = NFSREAD_MAX_SIZE; - - return (0); -} - -/* - * Lookup a file. Store handle and attributes. - * Return zero or error number. - */ -int -nfs_lookupfh(struct nfs_iodesc *d, const char *name, struct nfs_iodesc *newfd) -{ - int len, rlen; - struct args { - u_char fh[NFS_FHSIZE]; - n_long len; - char name[FNAME_SIZE]; - } *args; - struct repl { - n_long errno; - u_char fh[NFS_FHSIZE]; - struct nfsv2_fattrs fa; - } *repl; - struct { - n_long h[RPC_HEADER_WORDS]; - struct args d; - } sdata; - struct { - n_long h[RPC_HEADER_WORDS]; - struct repl d; - } rdata; - ssize_t cc; - -#ifdef NFS_DEBUG - if (debug) - printf("lookupfh: called\n"); -#endif - - args = &sdata.d; - repl = &rdata.d; - - bzero(args, sizeof(*args)); - bcopy(d->fh, args->fh, sizeof(args->fh)); - len = strlen(name); - if (len > sizeof(args->name)) - len = sizeof(args->name); - bcopy(name, args->name, len); - args->len = htonl(len); - len = 4 + roundup(len, 4); - len += NFS_FHSIZE; - - rlen = sizeof(*repl); - - cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_LOOKUP, - args, len, repl, rlen); - if (cc == -1) - return (errno); /* XXX - from rpc_call */ - if (cc < 4) - return (EIO); - if (repl->errno) { - /* saerrno.h now matches NFS error numbers. */ - return (ntohl(repl->errno)); } - bcopy( repl->fh, &newfd->fh, sizeof(newfd->fh)); - bcopy(&repl->fa, &newfd->fa, sizeof(newfd->fa)); - return (0); + snprintf(buf, sizeof (buf), "%d", nfs_read_size); + setenv("nfs.read_size", buf, 1); } -#ifndef NFS_NOSYMLINK /* - * Get the destination of a symbolic link. - */ -int -nfs_readlink(struct nfs_iodesc *d, char *buf) -{ - struct { - n_long h[RPC_HEADER_WORDS]; - u_char fh[NFS_FHSIZE]; - } sdata; - struct { - n_long h[RPC_HEADER_WORDS]; - struct nfs_readlnk_repl d; - } rdata; - ssize_t cc; - -#ifdef NFS_DEBUG - if (debug) - printf("readlink: called\n"); -#endif - - bcopy(d->fh, sdata.fh, NFS_FHSIZE); - cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READLINK, - sdata.fh, NFS_FHSIZE, - &rdata.d, sizeof(rdata.d)); - if (cc == -1) - return (errno); - - if (cc < 4) - return (EIO); - - if (rdata.d.errno) - return (ntohl(rdata.d.errno)); - - rdata.d.len = ntohl(rdata.d.len); - if (rdata.d.len > NFS_MAXPATHLEN) - return (ENAMETOOLONG); - - bcopy(rdata.d.path, buf, rdata.d.len); - buf[rdata.d.len] = 0; - return (0); -} -#endif - -/* - * Read data from a file. - * Return transfer count or -1 (and set errno) - */ -ssize_t -nfs_readdata(struct nfs_iodesc *d, off_t off, void *addr, size_t len) -{ - struct nfs_read_args *args; - struct nfs_read_repl *repl; - struct { - n_long h[RPC_HEADER_WORDS]; - struct nfs_read_args d; - } sdata; - struct { - n_long h[RPC_HEADER_WORDS]; - struct nfs_read_repl d; - } rdata; - size_t cc; - long x; - int hlen, rlen; - - args = &sdata.d; - repl = &rdata.d; - - bcopy(d->fh, args->fh, NFS_FHSIZE); - args->off = htonl((n_long)off); - if (len > nfs_read_size) - len = nfs_read_size; - args->len = htonl((n_long)len); - args->xxx = htonl((n_long)0); - hlen = offsetof(struct nfs_read_rpl, data[0]); - - cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READ, - args, sizeof(*args), - repl, sizeof(*repl)); - if (cc == -1) { - /* errno was already set by rpc_call */ - return (-1); - } - if (cc < hlen) { - errno = EBADRPC; - return (-1); - } - if (repl->errno) { - errno = ntohl(repl->errno); - return (-1); - } - rlen = cc - hlen; - x = ntohl(repl->count); - if (rlen < x) { - printf("nfsread: short packet, %d < %ld\n", rlen, x); - errno = EBADRPC; - return(-1); - } - bcopy(repl->data, addr, x); - return (x); -} - -/* - * Open a file. - * return zero or error number - */ -int -nfs_open(const char *upath, struct open_file *f) -{ - struct iodesc *desc; - struct nfs_iodesc *currfd; - char buf[2 * NFS_FHSIZE + 3]; - u_char *fh; - char *cp; - int i; -#ifndef NFS_NOSYMLINK - struct nfs_iodesc *newfd; - struct nfsv2_fattrs *fa; - char *ncp; - int c; - char namebuf[NFS_MAXPATHLEN + 1]; - char linkbuf[NFS_MAXPATHLEN + 1]; - int nlinks = 0; -#endif - int error; - char *path; - - if (netproto != NET_NFS) - return (EINVAL); - -#ifdef NFS_DEBUG - if (debug) - printf("nfs_open: %s (rootpath=%s)\n", upath, rootpath); -#endif - if (!rootpath[0]) { - printf("no rootpath, no nfs\n"); - return (ENXIO); - } - - /* - * This is silly - we should look at dv_type but that value is - * arch dependant and we can't use it here. - */ -#ifndef __i386__ - if (strcmp(f->f_dev->dv_name, "net") != 0) - return(EINVAL); -#else - if (strcmp(f->f_dev->dv_name, "pxe") != 0) - return(EINVAL); -#endif - - if (!(desc = socktodesc(*(int *)(f->f_devdata)))) - return(EINVAL); - - /* Bind to a reserved port. */ - desc->myport = htons(--rpc_port); - desc->destip = rootip; - if ((error = nfs_getrootfh(desc, rootpath, nfs_root_node.fh))) - return (error); - nfs_root_node.fa.fa_type = htonl(NFDIR); - nfs_root_node.fa.fa_mode = htonl(0755); - nfs_root_node.fa.fa_nlink = htonl(2); - nfs_root_node.iodesc = desc; - - fh = &nfs_root_node.fh[0]; - buf[0] = 'X'; - cp = &buf[1]; - for (i = 0; i < NFS_FHSIZE; i++, cp += 2) - sprintf(cp, "%02x", fh[i]); - sprintf(cp, "X"); - setenv("boot.nfsroot.server", inet_ntoa(rootip), 1); - setenv("boot.nfsroot.path", rootpath, 1); - setenv("boot.nfsroot.nfshandle", buf, 1); - - /* Allocate file system specific data structure */ - currfd = malloc(sizeof(*newfd)); - if (currfd == NULL) { - error = ENOMEM; - goto out; - } - -#ifndef NFS_NOSYMLINK - bcopy(&nfs_root_node, currfd, sizeof(*currfd)); - newfd = NULL; - - cp = path = strdup(upath); - if (path == NULL) { - error = ENOMEM; - goto out; - } - while (*cp) { - /* - * Remove extra separators - */ - while (*cp == '/') - cp++; - - if (*cp == '\0') - break; - /* - * Check that current node is a directory. - */ - if (currfd->fa.fa_type != htonl(NFDIR)) { - error = ENOTDIR; - goto out; - } - - /* allocate file system specific data structure */ - newfd = malloc(sizeof(*newfd)); - newfd->iodesc = currfd->iodesc; - - /* - * Get next component of path name. - */ - { - int len = 0; - - ncp = cp; - while ((c = *cp) != '\0' && c != '/') { - if (++len > NFS_MAXNAMLEN) { - error = ENOENT; - goto out; - } - cp++; - } - *cp = '\0'; - } - - /* lookup a file handle */ - error = nfs_lookupfh(currfd, ncp, newfd); - *cp = c; - if (error) - goto out; - - /* - * Check for symbolic link - */ - if (newfd->fa.fa_type == htonl(NFLNK)) { - int link_len, len; - - error = nfs_readlink(newfd, linkbuf); - if (error) - goto out; - - link_len = strlen(linkbuf); - len = strlen(cp); - - if (link_len + len > MAXPATHLEN - || ++nlinks > MAXSYMLINKS) { - error = ENOENT; - goto out; - } - - bcopy(cp, &namebuf[link_len], len + 1); - bcopy(linkbuf, namebuf, link_len); - - /* - * If absolute pathname, restart at root. - * If relative pathname, restart at parent directory. - */ - cp = namebuf; - if (*cp == '/') - bcopy(&nfs_root_node, currfd, sizeof(*currfd)); - - free(newfd); - newfd = NULL; - - continue; - } - - free(currfd); - currfd = newfd; - newfd = NULL; - } - - error = 0; - -out: - free(newfd); - free(path); -#else - currfd->iodesc = desc; - - error = nfs_lookupfh(&nfs_root_node, upath, currfd); -#endif - if (!error) { - currfd->off = 0; - f->f_fsdata = (void *)currfd; - return (0); - } - -#ifdef NFS_DEBUG - if (debug) - printf("nfs_open: %s lookupfh failed: %s\n", - path, strerror(error)); -#endif - free(currfd); - - return (error); -} - -int -nfs_close(struct open_file *f) -{ - struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; - -#ifdef NFS_DEBUG - if (debug) - printf("nfs_close: fp=0x%lx\n", (u_long)fp); -#endif - - if (fp) - free(fp); - f->f_fsdata = (void *)0; - - return (0); -} - -/* - * read a portion of a file - */ -int -nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid) -{ - struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; - ssize_t cc; - char *addr = buf; - -#ifdef NFS_DEBUG - if (debug) - printf("nfs_read: size=%lu off=%d\n", (u_long)size, - (int)fp->off); -#endif - while ((int)size > 0) { - twiddle(16); - cc = nfs_readdata(fp, fp->off, (void *)addr, size); - /* XXX maybe should retry on certain errors */ - if (cc == -1) { -#ifdef NFS_DEBUG - if (debug) - printf("nfs_read: read: %s", strerror(errno)); -#endif - return (errno); /* XXX - from nfs_readdata */ - } - if (cc == 0) { -#ifdef NFS_DEBUG - if (debug) - printf("nfs_read: hit EOF unexpectantly"); -#endif - goto ret; - } - fp->off += cc; - addr += cc; - size -= cc; - } -ret: - if (resid) - *resid = size; - - return (0); -} - -/* - * Not implemented. - */ -int -nfs_write(struct open_file *f, void *buf, size_t size, size_t *resid) -{ - return (EROFS); -} - -off_t -nfs_seek(struct open_file *f, off_t offset, int where) -{ - struct nfs_iodesc *d = (struct nfs_iodesc *)f->f_fsdata; - n_long size = ntohl(d->fa.fa_size); - - switch (where) { - case SEEK_SET: - d->off = offset; - break; - case SEEK_CUR: - d->off += offset; - break; - case SEEK_END: - d->off = size - offset; - break; - default: - errno = EINVAL; - return (-1); - } - - return (d->off); -} - -/* NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5 */ -int nfs_stat_types[8] = { - 0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK, 0 }; - -int -nfs_stat(struct open_file *f, struct stat *sb) -{ - struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; - n_long ftype, mode; - - ftype = ntohl(fp->fa.fa_type); - mode = ntohl(fp->fa.fa_mode); - mode |= nfs_stat_types[ftype & 7]; - - sb->st_mode = mode; - sb->st_nlink = ntohl(fp->fa.fa_nlink); - sb->st_uid = ntohl(fp->fa.fa_uid); - sb->st_gid = ntohl(fp->fa.fa_gid); - sb->st_size = ntohl(fp->fa.fa_size); - - return (0); -} - -static int -nfs_readdir(struct open_file *f, struct dirent *d) -{ - struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; - struct nfs_readdir_args *args; - struct nfs_readdir_data *rd; - struct nfs_readdir_off *roff = NULL; - static char *buf; - static struct nfs_iodesc *pfp = NULL; - static n_long cookie = 0; - size_t cc; - n_long eof; - - struct { - n_long h[RPC_HEADER_WORDS]; - struct nfs_readdir_args d; - } sdata; - static struct { - n_long h[RPC_HEADER_WORDS]; - u_char d[NFS_READDIRSIZE]; - } rdata; - - if (fp != pfp || fp->off != cookie) { - pfp = NULL; - refill: - args = &sdata.d; - bzero(args, sizeof(*args)); - - bcopy(fp->fh, args->fh, NFS_FHSIZE); - args->cookie = htonl(fp->off); - args->count = htonl(NFS_READDIRSIZE); - - cc = rpc_call(fp->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READDIR, - args, sizeof(*args), - rdata.d, sizeof(rdata.d)); - buf = rdata.d; - roff = (struct nfs_readdir_off *)buf; - if (ntohl(roff->cookie) != 0) - return EIO; - pfp = fp; - cookie = fp->off; - } - roff = (struct nfs_readdir_off *)buf; - - if (ntohl(roff->follows) == 0) { - eof = ntohl((roff+1)->cookie); - if (eof) { - cookie = 0; - return ENOENT; - } - goto refill; - } - - buf += sizeof(struct nfs_readdir_off); - rd = (struct nfs_readdir_data *)buf; - d->d_namlen = ntohl(rd->len); - bcopy(rd->name, d->d_name, d->d_namlen); - d->d_name[d->d_namlen] = '\0'; - - buf += (sizeof(struct nfs_readdir_data) + roundup(htonl(rd->len),4)); - roff = (struct nfs_readdir_off *)buf; - fp->off = cookie = ntohl(roff->cookie); - return 0; -} -#else /* !OLD_NFSV2 */ -/* * Fetch the root file handle (call mount daemon) * Return zero or error number. */ @@ -885,6 +234,8 @@ nfs_getrootfh(struct iodesc *d, char *path, uint32_t * return (ntohl(repl->errno)); *fhlenp = ntohl(repl->fhsize); bcopy(repl->fh, fhp, *fhlenp); + + set_nfs_read_size(); return (0); } @@ -1492,4 +843,3 @@ nfs_readdir(struct open_file *f, struct dirent *d) buf = (u_char *)&rent->nameplus[pos]; return (0); } -#endif /* OLD_NFSV2 */ Modified: stable/11/lib/libstand/nfsv2.h ============================================================================== --- stable/11/lib/libstand/nfsv2.h Sat Feb 10 01:52:58 2018 (r329098) +++ stable/11/lib/libstand/nfsv2.h Sat Feb 10 04:37:44 2018 (r329099) @@ -119,46 +119,3 @@ typedef enum { NFCHR=4, NFLNK=5 } nfstype; - -/* Structs for common parts of the rpc's */ -struct nfsv2_time { - n_long nfs_sec; - n_long nfs_usec; -}; - -/* - * File attributes and setable attributes. - */ -struct nfsv2_fattr { - n_long fa_type; - n_long fa_mode; - n_long fa_nlink; - n_long fa_uid; - n_long fa_gid; - n_long fa_size; - n_long fa_blocksize; - n_long fa_rdev; - n_long fa_blocks; - n_long fa_fsid; - n_long fa_fileid; - struct nfsv2_time fa_atime; - struct nfsv2_time fa_mtime; - struct nfsv2_time fa_ctime; -}; - -struct nfsv2_sattr { - n_long sa_mode; - n_long sa_uid; - n_long sa_gid; - n_long sa_size; - struct nfsv2_time sa_atime; - struct nfsv2_time sa_mtime; -}; - -struct nfsv2_statfs { - n_long sf_tsize; - n_long sf_bsize; - n_long sf_blocks; - n_long sf_bfree; - n_long sf_bavail; -}; Modified: stable/11/lib/libstand/stand.h ============================================================================== --- stable/11/lib/libstand/stand.h Sat Feb 10 01:52:58 2018 (r329098) +++ stable/11/lib/libstand/stand.h Sat Feb 10 04:37:44 2018 (r329099) @@ -168,6 +168,7 @@ struct devdesc #define DEVT_NET 2 #define DEVT_CD 3 #define DEVT_ZFS 4 +#define DEVT_FD 5 int d_unit; void *d_opendata; }; Modified: stable/11/sys/boot/common/bcache.c ============================================================================== --- stable/11/sys/boot/common/bcache.c Sat Feb 10 01:52:58 2018 (r329098) +++ stable/11/sys/boot/common/bcache.c Sat Feb 10 04:37:44 2018 (r329099) @@ -64,7 +64,7 @@ struct bcachectl struct bcache { struct bcachectl *bcache_ctl; caddr_t bcache_data; - u_int bcache_nblks; + size_t bcache_nblks; size_t ra; }; @@ -86,6 +86,7 @@ static u_int bcache_rablks; ((bc)->bcache_ctl[BHASH((bc), (blkno))].bc_blkno != (blkno)) #define BCACHE_READAHEAD 256 #define BCACHE_MINREADAHEAD 32 +#define BCACHE_MARKER 0xdeadbeef static void bcache_invalidate(struct bcache *bc, daddr_t blkno); static void bcache_insert(struct bcache *bc, daddr_t blkno); @@ -95,7 +96,7 @@ static void bcache_free_instance(struct bcache *bc); * Initialise the cache for (nblks) of (bsize). */ void -bcache_init(u_int nblks, size_t bsize) +bcache_init(size_t nblks, size_t bsize) { /* set up control data */ bcache_total_nblks = nblks; @@ -122,6 +123,7 @@ bcache_allocate(void) u_int i; struct bcache *bc = malloc(sizeof (struct bcache)); int disks = bcache_numdev; + uint32_t *marker; if (disks == 0) disks = 1; /* safe guard */ @@ -140,11 +142,13 @@ bcache_allocate(void) bc->bcache_nblks = bcache_total_nblks >> i; bcache_unit_nblks = bc->bcache_nblks; - bc->bcache_data = malloc(bc->bcache_nblks * bcache_blksize); + bc->bcache_data = malloc(bc->bcache_nblks * bcache_blksize + + sizeof(uint32_t)); if (bc->bcache_data == NULL) { /* dont error out yet. fall back to 32 blocks and try again */ bc->bcache_nblks = 32; - bc->bcache_data = malloc(bc->bcache_nblks * bcache_blksize); + bc->bcache_data = malloc(bc->bcache_nblks * bcache_blksize + + sizeof(uint32_t)); } bc->bcache_ctl = malloc(bc->bcache_nblks * sizeof(struct bcachectl)); @@ -152,8 +156,11 @@ bcache_allocate(void) if ((bc->bcache_data == NULL) || (bc->bcache_ctl == NULL)) { bcache_free_instance(bc); errno = ENOMEM; - return(NULL); + return (NULL); } + /* Insert cache end marker. */ + marker = (uint32_t *)(bc->bcache_data + bc->bcache_nblks * bcache_blksize); + *marker = BCACHE_MARKER; /* Flush the cache */ for (i = 0; i < bc->bcache_nblks; i++) { @@ -215,12 +222,15 @@ read_strategy(void *devdata, int rw, daddr_t blk, size int result; daddr_t p_blk; caddr_t p_buf; + uint32_t *marker; if (bc == NULL) { errno = ENODEV; return (-1); } + marker = (uint32_t *)(bc->bcache_data + bc->bcache_nblks * bcache_blksize); + if (rsize != NULL) *rsize = 0; @@ -261,9 +271,34 @@ read_strategy(void *devdata, int rw, daddr_t blk, size p_size = MIN(r_size, nblk - i); /* read at least those blocks */ + /* + * The read ahead size setup. + * While the read ahead can save us IO, it also can complicate things: + * 1. We do not want to read ahead by wrapping around the + * bcache end - this would complicate the cache management. + * 2. We are using bc->ra as dynamic hint for read ahead size, + * detected cache hits will increase the read-ahead block count, and + * misses will decrease, see the code above. + * 3. The bcache is sized by 512B blocks, however, the underlying device + * may have a larger sector size, and we should perform the IO by + * taking into account these larger sector sizes. We could solve this by + * passing the sector size to bcache_allocate(), or by using ioctl(), but + * in this version we are using the constant, 16 blocks, and are rounding + * read ahead block count down to multiple of 16. + * Using the constant has two reasons, we are not entirely sure if the + * BIOS disk interface is providing the correct value for sector size. + * And secondly, this way we get the most conservative setup for the ra. + * + * The selection of multiple of 16 blocks (8KB) is quite arbitrary, however, + * we want to cover CDs (2K) and 4K disks. + * bcache_allocate() will always fall back to a minimum of 32 blocks. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Sat Feb 10 04:56:09 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F3700F1D39E; Sat, 10 Feb 2018 04:56:08 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8A2EF6C48A; Sat, 10 Feb 2018 04:56:08 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7FB9B7636; Sat, 10 Feb 2018 04:56:08 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1A4u8ek018962; Sat, 10 Feb 2018 04:56:08 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1A4u7QV018955; Sat, 10 Feb 2018 04:56:07 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802100456.w1A4u7QV018955@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sat, 10 Feb 2018 04:56:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329100 - in stable/11: lib/libstand share/mk sys/boot/common sys/boot/efi sys/boot/efi/boot1 sys/boot/efi/fdt sys/boot/efi/include sys/boot/efi/libefi sys/boot/efi/loader sys/boot/efi/... X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: lib/libstand share/mk sys/boot/common sys/boot/efi sys/boot/efi/boot1 sys/boot/efi/fdt sys/boot/efi/include sys/boot/efi/libefi sys/boot/efi/loader sys/boot/efi/loader/arch/arm sys/boot/... X-SVN-Commit-Revision: 329100 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Feb 2018 04:56:09 -0000 Author: kevans Date: Sat Feb 10 04:56:07 2018 New Revision: 329100 URL: https://svnweb.freebsd.org/changeset/base/329100 Log: MFC Loader Fixes 2017q2: r316437,r316577,r316578,r316585,r316590,r316612, r316625,r316628,r316654,r316682,r316704,r316771,r317092,r317097,r317099, r317652,r317785,r317886,r317887,r318142,r318320,r318356,r318678,r318754, r318982,r318986,r318987,r318988,r318989,r318990,r318991,r318992,r318993, r318994,r318999,r319083,r319084,r319085,r320011,r320234,r320288,r320304, r320467,r320482 r316437: Small cleanup to make i386/loader match efi/loader boot environment code r316577: loader: part.c cstyle cleanup r316578: loader: want mechanism to avoid RA with bcache r316585: loader: zfs reader should check all labels r316590: libstand/dosfs: cache FAT32 in 128 Kb blocks to save loader memory r316612: In r298230 the value of HEAP_MIN was changed from 3MB to 64MB. Correct a comment. r316625: Do not use -msoft-float with intention of disabling FP on aarch64 r316628: Silence GCC warning by initializing the local variable. r316654: loader: r316585 did miss userboot update r316682: loader: r316585 did miss sparc/ofw r316704: loader.efi: only fetch zfs pool guid for the actual boot device r316771: loader: Avoid possible overflow via environment variable r317092: loader: zfs reader vdev_probe should check for minimum device size r317097: loader: F_READ/F_WRITE should be checked against masked flag r317099: loader: uboot disk ioctl should call disk_ioctl r317652: loader.efi: ResetSystem does not use data with EFI_SUCCESS r317785: zfsboot: drvsize() may be unusable on some systems r317886: distinguish NFS versus TFTP boot by rootpath r317887: loader: network read rework r318142: libstand: NULL pointer dereference in rarp r318320: loader: add ip layer code into libstand r318356: libstand: increase nfs max read size to 16k r318678: Replacing iterating over rootpath by strsep(3). r318754: Pass -N directly to ld via -Wl rather than passing it to the compiler driver. r318982: Pass a "FREEBSD" user-class in PXE dhcp request r318986: add a comment on vendor index 19 and 20 to avoid confusion r318987: Support URI scheme for root-path in netbooting r318988: Always build tftpfs support along with nfs for pxeboot r318989: Always issue the pxe request r318990: Partially revert r314948 r318991: Document recent changes on pxeboot r318992: Capitalize DHCP r318993: Use the usual FreeBSD spelling for the DHCP user class r318994: Catch with the change in the user class r318999: Update the comments concerning net_parse_rootpath to reflect what it is now r319083: Followup on the user-class changes r319084: Small cleanup in dev_net.c r319085: use the same option list for dhcp discovery and request r320011: Add chain loader support for loader r320234: Make structure padding explicit in EFI_MEMORY_DESCRIPTOR r320288: Allow Clang's integrated assembler to assemble boot0 r320304: loader.efi: Disable smbios for arm r320467: loader: chain load relocate data declaration is bad r320482: As with arm64 mark the EFI PE header as allocated on arm. PR: 218473 Added: stable/11/lib/libstand/ip.c - copied unchanged from r318320, head/lib/libstand/ip.c stable/11/sys/boot/i386/libi386/relocater_tramp.S - copied unchanged from r320011, head/sys/boot/i386/libi386/relocater_tramp.S stable/11/sys/boot/i386/loader/chain.c - copied, changed from r320011, head/sys/boot/i386/loader/chain.c Modified: stable/11/lib/libstand/Makefile stable/11/lib/libstand/arp.c stable/11/lib/libstand/bootp.c stable/11/lib/libstand/bootp.h stable/11/lib/libstand/bootparam.c stable/11/lib/libstand/dosfs.c stable/11/lib/libstand/dosfs.h stable/11/lib/libstand/ether.c stable/11/lib/libstand/globals.c stable/11/lib/libstand/net.c stable/11/lib/libstand/net.h stable/11/lib/libstand/netif.c stable/11/lib/libstand/netif.h stable/11/lib/libstand/nfs.c stable/11/lib/libstand/rarp.c stable/11/lib/libstand/rpc.c stable/11/lib/libstand/rpc.h stable/11/lib/libstand/stand.h stable/11/lib/libstand/tftp.c stable/11/lib/libstand/udp.c stable/11/share/mk/bsd.stand.mk stable/11/sys/boot/common/bcache.c stable/11/sys/boot/common/commands.c stable/11/sys/boot/common/dev_net.c stable/11/sys/boot/common/disk.c stable/11/sys/boot/common/md.c stable/11/sys/boot/common/part.c stable/11/sys/boot/efi/Makefile.inc stable/11/sys/boot/efi/boot1/Makefile stable/11/sys/boot/efi/boot1/boot1.c stable/11/sys/boot/efi/boot1/zfs_module.c stable/11/sys/boot/efi/fdt/Makefile stable/11/sys/boot/efi/include/efidef.h stable/11/sys/boot/efi/libefi/Makefile stable/11/sys/boot/efi/libefi/efinet.c stable/11/sys/boot/efi/libefi/efipart.c stable/11/sys/boot/efi/libefi/time.c stable/11/sys/boot/efi/loader/Makefile stable/11/sys/boot/efi/loader/arch/arm/start.S stable/11/sys/boot/efi/loader/arch/arm64/Makefile.inc stable/11/sys/boot/efi/loader/main.c stable/11/sys/boot/forth/menu.rc stable/11/sys/boot/i386/boot0/Makefile stable/11/sys/boot/i386/common/drv.h stable/11/sys/boot/i386/libi386/Makefile stable/11/sys/boot/i386/libi386/bioscd.c stable/11/sys/boot/i386/libi386/biosdisk.c stable/11/sys/boot/i386/libi386/biosmem.c stable/11/sys/boot/i386/libi386/libi386.h stable/11/sys/boot/i386/libi386/pxe.c stable/11/sys/boot/i386/libi386/pxe.h stable/11/sys/boot/i386/loader/Makefile stable/11/sys/boot/i386/loader/help.i386 stable/11/sys/boot/i386/loader/main.c stable/11/sys/boot/i386/pxeldr/pxeboot.8 stable/11/sys/boot/i386/zfsboot/zfsboot.c stable/11/sys/boot/mips/beri/boot2/Makefile stable/11/sys/boot/mips/beri/loader/beri_disk_cfi.c stable/11/sys/boot/mips/beri/loader/beri_disk_sdcard.c stable/11/sys/boot/ofw/libofw/ofw_disk.c stable/11/sys/boot/ofw/libofw/ofw_net.c stable/11/sys/boot/ofw/libofw/openfirm.c stable/11/sys/boot/ofw/libofw/openfirm.h stable/11/sys/boot/powerpc/ps3/ps3cdrom.c stable/11/sys/boot/powerpc/ps3/ps3disk.c stable/11/sys/boot/sparc64/loader/main.c stable/11/sys/boot/uboot/lib/disk.c stable/11/sys/boot/uboot/lib/net.c stable/11/sys/boot/usb/storage/umass_loader.c stable/11/sys/boot/userboot/userboot/main.c stable/11/sys/boot/userboot/userboot/userboot_disk.c stable/11/sys/boot/zfs/libzfs.h stable/11/sys/boot/zfs/zfsimpl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libstand/Makefile ============================================================================== --- stable/11/lib/libstand/Makefile Sat Feb 10 04:37:44 2018 (r329099) +++ stable/11/lib/libstand/Makefile Sat Feb 10 04:56:07 2018 (r329100) @@ -141,7 +141,7 @@ 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 # network routines -SRCS+= arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c +SRCS+= arp.c ether.c ip.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c # network info services: SRCS+= bootp.c rarp.c bootparam.c Modified: stable/11/lib/libstand/arp.c ============================================================================== --- stable/11/lib/libstand/arp.c Sat Feb 10 04:37:44 2018 (r329099) +++ stable/11/lib/libstand/arp.c Sat Feb 10 04:56:07 2018 (r329100) @@ -65,17 +65,16 @@ int arp_num = 1; /* Local forwards */ static ssize_t arpsend(struct iodesc *, void *, size_t); -static ssize_t arprecv(struct iodesc *, void *, size_t, time_t); +static ssize_t arprecv(struct iodesc *, void **, void **, time_t); /* Broadcast an ARP packet, asking who has addr on interface d */ u_char * -arpwhohas(d, addr) - struct iodesc *d; - struct in_addr addr; +arpwhohas(struct iodesc *d, struct in_addr addr) { int i; struct ether_arp *ah; struct arp_list *al; + void *pkt; struct { struct ether_header eh; struct { @@ -83,13 +82,6 @@ arpwhohas(d, addr) u_char pad[18]; /* 60 - sizeof(...) */ } data; } wbuf; - struct { - struct ether_header eh; - struct { - struct ether_arp arp; - u_char pad[24]; /* extra space */ - } data; - } rbuf; /* Try for cached answer first */ for (i = 0, al = arp_list; i < arp_num; ++i, ++al) @@ -122,20 +114,24 @@ arpwhohas(d, addr) /* Store ip address in cache (incomplete entry). */ al->addr = addr; + pkt = NULL; + ah = NULL; i = sendrecv(d, arpsend, &wbuf.data, sizeof(wbuf.data), - arprecv, &rbuf.data, sizeof(rbuf.data)); + arprecv, &pkt, (void **)&ah); if (i == -1) { panic("arp: no response for %s\n", inet_ntoa(addr)); } /* Store ethernet address in cache */ - ah = &rbuf.data.arp; #ifdef ARP_DEBUG if (debug) { + struct ether_header *eh; + + eh = (struct ether_header *)((uintptr_t)pkt + ETHER_ALIGN); printf("arp: response from %s\n", - ether_sprintf(rbuf.eh.ether_shost)); + ether_sprintf(eh->ether_shost)); printf("arp: cacheing %s --> %s\n", inet_ntoa(addr), ether_sprintf(ah->arp_sha)); } @@ -143,14 +139,12 @@ arpwhohas(d, addr) MACPY(ah->arp_sha, al->ea); ++arp_num; + free(pkt); return (al->ea); } static ssize_t -arpsend(d, pkt, len) - struct iodesc *d; - void *pkt; - size_t len; +arpsend(struct iodesc *d, void *pkt, size_t len) { #ifdef ARP_DEBUG @@ -166,28 +160,27 @@ arpsend(d, pkt, len) * else -1 (and errno == 0) */ static ssize_t -arprecv(d, pkt, len, tleft) - struct iodesc *d; - void *pkt; - size_t len; - time_t tleft; +arprecv(struct iodesc *d, void **pkt, void **payload, time_t tleft) { ssize_t n; struct ether_arp *ah; u_int16_t etype; /* host order */ + void *ptr; #ifdef ARP_DEBUG if (debug) printf("arprecv: "); #endif - n = readether(d, pkt, len, tleft, &etype); + ptr = NULL; + n = readether(d, &ptr, (void **)&ah, tleft, &etype); errno = 0; /* XXX */ if (n == -1 || n < sizeof(struct ether_arp)) { #ifdef ARP_DEBUG if (debug) printf("bad len=%d\n", n); #endif + free(ptr); return (-1); } @@ -196,12 +189,11 @@ arprecv(d, pkt, len, tleft) if (debug) printf("not arp type=%d\n", etype); #endif + free(ptr); return (-1); } /* Ethernet address now checked in readether() */ - - ah = (struct ether_arp *)pkt; if (ah->arp_hrd != htons(ARPHRD_ETHER) || ah->arp_pro != htons(ETHERTYPE_IP) || ah->arp_hln != sizeof(ah->arp_sha) || @@ -211,6 +203,7 @@ arprecv(d, pkt, len, tleft) if (debug) printf("bad hrd/pro/hln/pln\n"); #endif + free(ptr); return (-1); } @@ -220,6 +213,7 @@ arprecv(d, pkt, len, tleft) printf("is request\n"); #endif arp_reply(d, ah); + free(ptr); return (-1); } @@ -228,6 +222,7 @@ arprecv(d, pkt, len, tleft) if (debug) printf("not ARP reply\n"); #endif + free(ptr); return (-1); } @@ -239,6 +234,7 @@ arprecv(d, pkt, len, tleft) if (debug) printf("unwanted address\n"); #endif + free(ptr); return (-1); } /* We don't care who the reply was sent to. */ @@ -248,6 +244,8 @@ arprecv(d, pkt, len, tleft) if (debug) printf("got it\n"); #endif + *pkt = ptr; + *payload = ah; return (n); } @@ -256,9 +254,7 @@ arprecv(d, pkt, len, tleft) * Notes: Re-uses buffer. Pad to length = 46. */ void -arp_reply(d, pkt) - struct iodesc *d; - void *pkt; /* the request */ +arp_reply(struct iodesc *d, void *pkt) { struct ether_arp *arp = pkt; Modified: stable/11/lib/libstand/bootp.c ============================================================================== --- stable/11/lib/libstand/bootp.c Sat Feb 10 04:37:44 2018 (r329099) +++ stable/11/lib/libstand/bootp.c Sat Feb 10 04:56:07 2018 (r329100) @@ -38,6 +38,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -72,7 +73,7 @@ static char vm_cmu[4] = VM_CMU; /* Local forwards */ static ssize_t bootpsend(struct iodesc *, void *, size_t); -static ssize_t bootprecv(struct iodesc *, void *, size_t, time_t); +static ssize_t bootprecv(struct iodesc *, void **, void **, time_t); static int vend_rfc1048(u_char *, u_int); #ifdef BOOTP_VEND_CMU static void vend_cmu(u_char *); @@ -89,23 +90,50 @@ static void setenv_(u_char *cp, u_char *ep, struct dh static char expected_dhcpmsgtype = -1, dhcp_ok; struct in_addr dhcp_serverip; #endif +struct bootp *bootp_response; +size_t bootp_response_size; +static void +bootp_fill_request(unsigned char *bp_vend) +{ + /* + * We are booting from PXE, we want to send the string + * 'PXEClient' to the DHCP server so you have the option of + * only responding to PXE aware dhcp requests. + */ + bp_vend[0] = TAG_CLASSID; + bp_vend[1] = 9; + bcopy("PXEClient", &bp_vend[2], 9); + bp_vend[11] = TAG_USER_CLASS; + /* len of each user class + number of user class */ + bp_vend[12] = 8; + /* len of the first user class */ + bp_vend[13] = 7; + bcopy("FreeBSD", &bp_vend[14], 7); + bp_vend[21] = TAG_PARAM_REQ; + bp_vend[22] = 7; + bp_vend[23] = TAG_ROOTPATH; + bp_vend[24] = TAG_HOSTNAME; + bp_vend[25] = TAG_SWAPSERVER; + bp_vend[26] = TAG_GATEWAY; + bp_vend[27] = TAG_SUBNET_MASK; + bp_vend[28] = TAG_INTF_MTU; + bp_vend[29] = TAG_SERVERID; + bp_vend[30] = TAG_END; +} + /* Fetch required bootp infomation */ void -bootp(sock, flag) - int sock; - int flag; +bootp(int sock) { + void *pkt; struct iodesc *d; struct bootp *bp; struct { u_char header[HEADER_SIZE]; struct bootp wbootp; } wbuf; - struct { - u_char header[HEADER_SIZE]; - struct bootp rbootp; - } rbuf; + struct bootp *rbootp; #ifdef BOOTP_DEBUG if (debug) @@ -137,29 +165,8 @@ bootp(sock, flag) bp->bp_vend[4] = TAG_DHCP_MSGTYPE; bp->bp_vend[5] = 1; bp->bp_vend[6] = DHCPDISCOVER; + bootp_fill_request(&bp->bp_vend[7]); - /* - * If we are booting from PXE, we want to send the string - * 'PXEClient' to the DHCP server so you have the option of - * only responding to PXE aware dhcp requests. - */ - if (flag & BOOTP_PXE) { - bp->bp_vend[7] = TAG_CLASSID; - bp->bp_vend[8] = 9; - bcopy("PXEClient", &bp->bp_vend[9], 9); - bp->bp_vend[18] = TAG_PARAM_REQ; - bp->bp_vend[19] = 8; - bp->bp_vend[20] = TAG_ROOTPATH; - bp->bp_vend[21] = TAG_TFTP_SERVER; - bp->bp_vend[22] = TAG_HOSTNAME; - bp->bp_vend[23] = TAG_SWAPSERVER; - bp->bp_vend[24] = TAG_GATEWAY; - bp->bp_vend[25] = TAG_SUBNET_MASK; - bp->bp_vend[26] = TAG_INTF_MTU; - bp->bp_vend[27] = TAG_SERVERID; - bp->bp_vend[28] = TAG_END; - } else - bp->bp_vend[7] = TAG_END; #else bp->bp_vend[4] = TAG_END; #endif @@ -176,8 +183,7 @@ bootp(sock, flag) if(sendrecv(d, bootpsend, bp, sizeof(*bp), - bootprecv, &rbuf.rbootp, sizeof(rbuf.rbootp)) - == -1) { + bootprecv, &pkt, (void **)&rbootp) == -1) { printf("bootp: no reply\n"); return; } @@ -188,7 +194,7 @@ bootp(sock, flag) bp->bp_vend[6] = DHCPREQUEST; bp->bp_vend[7] = TAG_REQ_ADDR; bp->bp_vend[8] = 4; - bcopy(&rbuf.rbootp.bp_yiaddr, &bp->bp_vend[9], 4); + bcopy(&rbootp->bp_yiaddr, &bp->bp_vend[9], 4); bp->bp_vend[13] = TAG_SERVERID; bp->bp_vend[14] = 4; bcopy(&dhcp_serverip.s_addr, &bp->bp_vend[15], 4); @@ -196,30 +202,25 @@ bootp(sock, flag) bp->bp_vend[20] = 4; leasetime = htonl(300); bcopy(&leasetime, &bp->bp_vend[21], 4); - if (flag & BOOTP_PXE) { - bp->bp_vend[25] = TAG_CLASSID; - bp->bp_vend[26] = 9; - bcopy("PXEClient", &bp->bp_vend[27], 9); - bp->bp_vend[36] = TAG_END; - } else - bp->bp_vend[25] = TAG_END; + bootp_fill_request(&bp->bp_vend[25]); expected_dhcpmsgtype = DHCPACK; + free(pkt); if(sendrecv(d, bootpsend, bp, sizeof(*bp), - bootprecv, &rbuf.rbootp, sizeof(rbuf.rbootp)) - == -1) { + bootprecv, &pkt, (void **)&rbootp) == -1) { printf("DHCPREQUEST failed\n"); return; } } #endif - myip = d->myip = rbuf.rbootp.bp_yiaddr; - servip = rbuf.rbootp.bp_siaddr; - if(rootip.s_addr == INADDR_ANY) rootip = servip; - bcopy(rbuf.rbootp.bp_file, bootfile, sizeof(bootfile)); + myip = d->myip = rbootp->bp_yiaddr; + servip = rbootp->bp_siaddr; + if (rootip.s_addr == INADDR_ANY) + rootip = servip; + bcopy(rbootp->bp_file, bootfile, sizeof(bootfile)); bootfile[sizeof(bootfile) - 1] = '\0'; if (!netmask) { @@ -259,14 +260,12 @@ bootp(sock, flag) /* Bump xid so next request will be unique. */ ++d->xid; + free(pkt); } /* Transmit a bootp request */ static ssize_t -bootpsend(d, pkt, len) - struct iodesc *d; - void *pkt; - size_t len; +bootpsend(struct iodesc *d, void *pkt, size_t len) { struct bootp *bp; @@ -287,30 +286,25 @@ bootpsend(d, pkt, len) } static ssize_t -bootprecv(d, pkt, len, tleft) -struct iodesc *d; -void *pkt; -size_t len; -time_t tleft; +bootprecv(struct iodesc *d, void **pkt, void **payload, time_t tleft) { ssize_t n; struct bootp *bp; + void *ptr; -#ifdef BOOTP_DEBUGx +#ifdef BOOTP_DEBUG if (debug) printf("bootp_recvoffer: called\n"); #endif - n = readudp(d, pkt, len, tleft); + ptr = NULL; + n = readudp(d, &ptr, (void **)&bp, tleft); if (n == -1 || n < sizeof(struct bootp) - BOOTP_VENDSIZE) goto bad; - bp = (struct bootp *)pkt; - #ifdef BOOTP_DEBUG if (debug) - printf("bootprecv: checked. bp = 0x%lx, n = %d\n", - (long)bp, (int)n); + printf("bootprecv: checked. bp = %p, n = %zd\n", bp, n); #endif if (bp->bp_xid != htonl(d->xid)) { #ifdef BOOTP_DEBUG @@ -329,8 +323,21 @@ time_t tleft; /* Suck out vendor info */ if (bcmp(vm_rfc1048, bp->bp_vend, sizeof(vm_rfc1048)) == 0) { - if(vend_rfc1048(bp->bp_vend, sizeof(bp->bp_vend)) != 0) + int vsize = n - offsetof(struct bootp, bp_vend); + if (vend_rfc1048(bp->bp_vend, vsize) != 0) goto bad; + + /* Save copy of bootp reply or DHCP ACK message */ + if (bp->bp_op == BOOTREPLY && + ((dhcp_ok == 1 && expected_dhcpmsgtype == DHCPACK) || + dhcp_ok == 0)) { + free(bootp_response); + bootp_response = malloc(n); + if (bootp_response != NULL) { + bootp_response_size = n; + bcopy(bp, bootp_response, bootp_response_size); + } + } } #ifdef BOOTP_VEND_CMU else if (bcmp(vm_cmu, bp->bp_vend, sizeof(vm_cmu)) == 0) @@ -339,8 +346,11 @@ time_t tleft; else printf("bootprecv: unknown vendor 0x%lx\n", (long)bp->bp_vend); - return(n); + *pkt = ptr; + *payload = bp; + return (n); bad: + free(ptr); errno = 0; return (-1); } @@ -357,9 +367,7 @@ dhcp_try_rfc1048(u_char *cp, u_int len) } static int -vend_rfc1048(cp, len) - u_char *cp; - u_int len; +vend_rfc1048(u_char *cp, u_int len) { u_char *ep; int size; @@ -438,10 +446,6 @@ vend_rfc1048(cp, len) bcopy(cp, &dhcp_serverip.s_addr, sizeof(dhcp_serverip.s_addr)); } - if (tag == TAG_TFTP_SERVER) { - bcopy(cp, &tftpip.s_addr, - sizeof(tftpip.s_addr)); - } #endif cp += size; } @@ -450,8 +454,7 @@ vend_rfc1048(cp, len) #ifdef BOOTP_VEND_CMU static void -vend_cmu(cp) - u_char *cp; +vend_cmu(u_char *cp) { struct cmu_vend *vp; Modified: stable/11/lib/libstand/bootp.h ============================================================================== --- stable/11/lib/libstand/bootp.h Sat Feb 10 04:37:44 2018 (r329099) +++ stable/11/lib/libstand/bootp.h Sat Feb 10 04:56:07 2018 (r329100) @@ -108,7 +108,7 @@ struct bootp { #define TAG_T2 ((unsigned char) 59) #define TAG_CLASSID ((unsigned char) 60) #define TAG_CLIENTID ((unsigned char) 61) -#define TAG_TFTP_SERVER ((unsigned char) 150) +#define TAG_USER_CLASS ((unsigned char) 77) #endif #define TAG_END ((unsigned char) 255) @@ -124,12 +124,6 @@ struct bootp { #endif /* - * bootp flags - */ -#define BOOTP_NONE 0x0000 /* No flags */ -#define BOOTP_PXE 0x0001 /* Booting from PXE. */ - -/* * "vendor" data permitted for CMU bootp clients. */ @@ -147,6 +141,10 @@ struct cmu_vend { /* v_flags values */ #define VF_SMASK 1 /* Subnet mask field contains valid data */ + +/* cached bootp response/dhcp ack */ +extern struct bootp *bootp_response; +extern size_t bootp_response_size; int dhcp_try_rfc1048(u_char *cp, u_int len); Modified: stable/11/lib/libstand/bootparam.c ============================================================================== --- stable/11/lib/libstand/bootparam.c Sat Feb 10 04:37:44 2018 (r329099) +++ stable/11/lib/libstand/bootparam.c Sat Feb 10 04:56:07 2018 (r329100) @@ -104,8 +104,7 @@ int xdr_string_decode(char **p, char *str, int *len_p) * know about us (don't want to broadcast a getport call). */ int -bp_whoami(sockfd) - int sockfd; +bp_whoami(int sockfd) { /* RPC structures for PMAPPROC_CALLIT */ struct args { @@ -126,22 +125,19 @@ bp_whoami(sockfd) n_long h[RPC_HEADER_WORDS]; struct args d; } sdata; - struct { - n_long h[RPC_HEADER_WORDS]; - struct repl d; - } rdata; char *send_tail, *recv_head; struct iodesc *d; - int len, x; + void *pkt; + int len, x, rc; RPC_PRINTF(("bp_whoami: myip=%s\n", inet_ntoa(myip))); + rc = -1; if (!(d = socktodesc(sockfd))) { RPC_PRINTF(("bp_whoami: bad socket. %d\n", sockfd)); - return (-1); + return (rc); } args = &sdata.d; - repl = &rdata.d; /* * Build request args for PMAPPROC_CALLIT. @@ -156,19 +152,19 @@ bp_whoami(sockfd) * append encapsulated data (client IP address) */ if (xdr_inaddr_encode(&send_tail, myip)) - return (-1); + return (rc); /* RPC: portmap/callit */ d->myport = htons(--rpc_port); d->destip.s_addr = INADDR_BROADCAST; /* XXX: subnet bcast? */ /* rpc_call will set d->destport */ + pkt = NULL; len = rpc_call(d, PMAPPROG, PMAPVERS, PMAPPROC_CALLIT, - args, send_tail - (char*)args, - repl, sizeof(*repl)); + args, send_tail - (char*)args, (void **)&repl, &pkt); if (len < 8) { printf("bootparamd: 'whoami' call failed\n"); - return (-1); + goto done; } /* Save bootparam server address (from IP header). */ @@ -196,7 +192,7 @@ bp_whoami(sockfd) x = ntohl(repl->encap_len); if (len < x) { printf("bp_whoami: short reply, %d < %d\n", len, x); - return (-1); + goto done; } recv_head = (char*) repl->capsule; @@ -204,24 +200,27 @@ bp_whoami(sockfd) hostnamelen = MAXHOSTNAMELEN-1; if (xdr_string_decode(&recv_head, hostname, &hostnamelen)) { RPC_PRINTF(("bp_whoami: bad hostname\n")); - return (-1); + goto done; } /* domain name */ domainnamelen = MAXHOSTNAMELEN-1; if (xdr_string_decode(&recv_head, domainname, &domainnamelen)) { RPC_PRINTF(("bp_whoami: bad domainname\n")); - return (-1); + goto done; } /* gateway address */ if (xdr_inaddr_decode(&recv_head, &gateip)) { RPC_PRINTF(("bp_whoami: bad gateway\n")); - return (-1); + goto done; } /* success */ - return(0); + rc = 0; +done: + free(pkt); + return (rc); } @@ -233,25 +232,18 @@ bp_whoami(sockfd) * server pathname */ int -bp_getfile(sockfd, key, serv_addr, pathname) - int sockfd; - char *key; - char *pathname; - struct in_addr *serv_addr; +bp_getfile(int sockfd, char *key, struct in_addr *serv_addr, char *pathname) { struct { n_long h[RPC_HEADER_WORDS]; n_long d[64]; } sdata; - struct { - n_long h[RPC_HEADER_WORDS]; - n_long d[128]; - } rdata; + void *pkt; char serv_name[FNAME_SIZE]; - char *send_tail, *recv_head; + char *rdata, *send_tail; /* misc... */ struct iodesc *d; - int sn_len, path_len, rlen; + int rc = -1, sn_len, path_len, rlen; if (!(d = socktodesc(sockfd))) { RPC_PRINTF(("bp_getfile: bad socket. %d\n", sockfd)); @@ -259,7 +251,6 @@ bp_getfile(sockfd, key, serv_addr, pathname) } send_tail = (char*) sdata.d; - recv_head = (char*) rdata.d; /* * Build request message. @@ -281,17 +272,16 @@ bp_getfile(sockfd, key, serv_addr, pathname) d->myport = htons(--rpc_port); d->destip = bp_server_addr; /* rpc_call will set d->destport */ - + pkt = NULL; rlen = rpc_call(d, BOOTPARAM_PROG, BOOTPARAM_VERS, BOOTPARAM_GETFILE, sdata.d, send_tail - (char*)sdata.d, - rdata.d, sizeof(rdata.d)); + (void **)&rdata, &pkt); if (rlen < 4) { RPC_PRINTF(("bp_getfile: short reply\n")); errno = EBADRPC; - return (-1); + goto done; } - recv_head = (char*) rdata.d; /* * Parse result message. @@ -299,26 +289,29 @@ bp_getfile(sockfd, key, serv_addr, pathname) /* server name */ sn_len = FNAME_SIZE-1; - if (xdr_string_decode(&recv_head, serv_name, &sn_len)) { + if (xdr_string_decode(&rdata, serv_name, &sn_len)) { RPC_PRINTF(("bp_getfile: bad server name\n")); - return (-1); + goto done; } /* server IP address (mountd/NFS) */ - if (xdr_inaddr_decode(&recv_head, serv_addr)) { + if (xdr_inaddr_decode(&rdata, serv_addr)) { RPC_PRINTF(("bp_getfile: bad server addr\n")); - return (-1); + goto done; } /* server pathname */ path_len = MAXPATHLEN-1; - if (xdr_string_decode(&recv_head, pathname, &path_len)) { + if (xdr_string_decode(&rdata, pathname, &path_len)) { RPC_PRINTF(("bp_getfile: bad server path\n")); - return (-1); + goto done; } /* success */ - return(0); + rc = 0; +done: + free(pkt); + return (rc); } @@ -329,17 +322,14 @@ bp_getfile(sockfd, key, serv_addr, pathname) int -xdr_string_encode(pkt, str, len) - char **pkt; - char *str; - int len; +xdr_string_encode(char **pkt, char *str, int len) { - u_int32_t *lenp; + uint32_t *lenp; char *datap; int padlen = (len + 3) & ~3; /* padded length */ /* The data will be int aligned. */ - lenp = (u_int32_t*) *pkt; + lenp = (uint32_t *) *pkt; *pkt += sizeof(*lenp); *lenp = htonl(len); @@ -351,18 +341,15 @@ xdr_string_encode(pkt, str, len) } int -xdr_string_decode(pkt, str, len_p) - char **pkt; - char *str; - int *len_p; /* bufsize - 1 */ +xdr_string_decode(char **pkt, char *str, int *len_p) { - u_int32_t *lenp; + uint32_t *lenp; char *datap; int slen; /* string length */ int plen; /* padded length */ /* The data will be int aligned. */ - lenp = (u_int32_t*) *pkt; + lenp = (uint32_t *) *pkt; *pkt += sizeof(*lenp); slen = ntohl(*lenp); plen = (slen + 3) & ~3; @@ -381,9 +368,7 @@ xdr_string_decode(pkt, str, len_p) int -xdr_inaddr_encode(pkt, ia) - char **pkt; - struct in_addr ia; /* network order */ +xdr_inaddr_encode(char **pkt, struct in_addr ia) { struct xdr_inaddr *xi; u_char *cp; @@ -414,9 +399,7 @@ xdr_inaddr_encode(pkt, ia) } int -xdr_inaddr_decode(pkt, ia) - char **pkt; - struct in_addr *ia; /* network order */ +xdr_inaddr_decode(char **pkt, struct in_addr *ia) { struct xdr_inaddr *xi; u_char *cp; Modified: stable/11/lib/libstand/dosfs.c ============================================================================== --- stable/11/lib/libstand/dosfs.c Sat Feb 10 04:37:44 2018 (r329099) +++ stable/11/lib/libstand/dosfs.c Sat Feb 10 04:56:07 2018 (r329100) @@ -65,6 +65,7 @@ struct fs_ops dosfs_fsops = { #define DEPSEC 16 /* directory entries per sector */ #define DSHIFT 4 /* DEPSEC shift */ #define LOCLUS 2 /* lowest cluster number */ +#define FATBLKSZ 0x20000 /* size of block in the FAT cache buffer */ /* DOS "BIOS Parameter Block" */ typedef struct { @@ -132,18 +133,6 @@ static DOS_DE dot[2] = { ((u_int)cv2((de)->dex.h_clus) << 16) | \ cv2((de)->clus)) -/* - * fat cache metadata - */ -struct fatcache { - int unit; /* disk unit number */ - int size; /* buffer (and fat) size in sectors */ - u_char *buf; -}; - -static struct fatcache fat; - -static int dosunmount(DOS_FS *); static int parsebs(DOS_FS *, DOS_BS *); static int namede(DOS_FS *, const char *, DOS_DE **); static int lookup(DOS_FS *, u_int, const char *, DOS_DE **); @@ -153,36 +142,37 @@ static off_t fsize(DOS_FS *, DOS_DE *); static int fatcnt(DOS_FS *, u_int); static int fatget(DOS_FS *, u_int *); static int fatend(u_int, u_int); -static int ioread(DOS_FS *, u_int, void *, u_int); -static int ioget(struct open_file *, daddr_t, void *, u_int); +static int ioread(DOS_FS *, u_int, void *, size_t); +static int ioget(struct open_file *, daddr_t, void *, size_t); -static void -dos_read_fat(DOS_FS *fs, struct open_file *fd) +static int +dos_read_fatblk(DOS_FS *fs, struct open_file *fd, u_int blknum) { - struct devdesc *dd = fd->f_devdata; + int err; + size_t io_size; + daddr_t offset_in_fat, max_offset_in_fat; - if (fat.buf != NULL) { /* can we reuse old buffer? */ - if (fat.size != fs->spf) { - free(fat.buf); /* no, free old buffer */ - fat.buf = NULL; - } - } + offset_in_fat = ((daddr_t)blknum) * FATBLKSZ; + max_offset_in_fat = secbyt(fs->spf); + io_size = FATBLKSZ; + if (offset_in_fat > max_offset_in_fat) + offset_in_fat = max_offset_in_fat; + if (offset_in_fat + io_size > max_offset_in_fat) + io_size = ((size_t)(max_offset_in_fat - offset_in_fat)); - if (fat.buf == NULL) - fat.buf = malloc(secbyt(fs->spf)); - - if (fat.buf != NULL) { - if (ioget(fd, fs->lsnfat, fat.buf, secbyt(fs->spf)) == 0) { - fat.size = fs->spf; - fat.unit = dd->d_unit; - return; - } + if (io_size != 0) { + err = ioget(fd, fs->lsnfat + bytsec(offset_in_fat), + fs->fatbuf, io_size); + if (err != 0) { + fs->fatbuf_blknum = ((u_int)(-1)); + return (err); + } } - if (fat.buf != NULL) /* got IO error */ - free(fat.buf); - fat.buf = NULL; - fat.unit = -1; /* impossible unit */ - fat.size = 0; + if (io_size < FATBLKSZ) + memset(fs->fatbuf + io_size, 0, FATBLKSZ - io_size); + + fs->fatbuf_blknum = blknum; + return (0); } /* @@ -192,24 +182,27 @@ static int dos_mount(DOS_FS *fs, struct open_file *fd) { int err; - struct devdesc *dd = fd->f_devdata; u_char *buf; bzero(fs, sizeof(DOS_FS)); fs->fd = fd; - if ((err = !(buf = malloc(secbyt(1))) ? errno : 0) || - (err = ioget(fs->fd, 0, buf, secbyt(1))) || + if ((buf = malloc(secbyt(1))) == NULL) + return (errno); + if ((err = ioget(fs->fd, 0, buf, secbyt(1))) || (err = parsebs(fs, (DOS_BS *)buf))) { - if (buf != NULL) - free(buf); - (void)dosunmount(fs); + free(buf); return (err); } free(buf); - if (fat.buf == NULL || fat.unit != dd->d_unit) - dos_read_fat(fs, fd); + if ((fs->fatbuf = malloc(FATBLKSZ)) == NULL) + return (errno); + err = dos_read_fatblk(fs, fd, 0); + if (err != 0) { + free(fs->fatbuf); + return (err); + } fs->root = dot[0]; fs->root.name[0] = ' '; @@ -228,21 +221,9 @@ dos_mount(DOS_FS *fs, struct open_file *fd) static int dos_unmount(DOS_FS *fs) { - int err; - if (fs->links) return (EBUSY); - if ((err = dosunmount(fs))) - return (err); - return (0); -} - -/* - * Common code shared by dos_mount() and dos_unmount() - */ -static int -dosunmount(DOS_FS *fs) -{ + free(fs->fatbuf); free(fs); return (0); } @@ -257,16 +238,20 @@ dos_open(const char *path, struct open_file *fd) DOS_FILE *f; DOS_FS *fs; u_int size, clus; - int err = 0; + int err; /* Allocate mount structure, associate with open */ - fs = malloc(sizeof(DOS_FS)); - - if ((err = dos_mount(fs, fd))) - goto out; + if ((fs = malloc(sizeof(DOS_FS))) == NULL) + return (errno); + if ((err = dos_mount(fs, fd))) { + free(fs); + return (err); + } - if ((err = namede(fs, path, &de))) - goto out; + if ((err = namede(fs, path, &de))) { + dos_unmount(fs); + return (err); + } clus = stclus(fs->fatsz, de); size = cv4(de->size); @@ -274,18 +259,20 @@ dos_open(const char *path, struct open_file *fd) if ((!(de->attr & FA_DIR) && (!clus != !size)) || ((de->attr & FA_DIR) && size) || (clus && !okclus(fs, clus))) { - err = EINVAL; - goto out; + dos_unmount(fs); + return (EINVAL); } - f = malloc(sizeof(DOS_FILE)); + if ((f = malloc(sizeof(DOS_FILE))) == NULL) { + err = errno; + dos_unmount(fs); + return (err); + } bzero(f, sizeof(DOS_FILE)); f->fs = fs; fs->links++; f->de = *de; fd->f_fsdata = (void *)f; - - out: - return (err); + return (0); } /* @@ -761,34 +748,57 @@ fatcnt(DOS_FS *fs, u_int c) } /* - * Get next cluster in cluster chain. Use in core fat cache unless another - * device replaced it. + * Get next cluster in cluster chain. Use in core fat cache unless + * the number of current 128K block in FAT has changed. */ static int fatget(DOS_FS *fs, u_int *c) { - u_char buf[4]; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-11@freebsd.org Sat Feb 10 15:23:31 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 01D87F04293; Sat, 10 Feb 2018 15:23:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A5AAA836C4; Sat, 10 Feb 2018 15:23:30 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A07F415D66; Sat, 10 Feb 2018 15:23:30 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1AFNUQP058059; Sat, 10 Feb 2018 15:23:30 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1AFNUFk058058; Sat, 10 Feb 2018 15:23:30 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802101523.w1AFNUFk058058@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sat, 10 Feb 2018 15:23:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329103 - stable/11/sbin/geom/class/eli X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/sbin/geom/class/eli X-SVN-Commit-Revision: 329103 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Feb 2018 15:23:31 -0000 Author: kevans Date: Sat Feb 10 15:23:30 2018 New Revision: 329103 URL: https://svnweb.freebsd.org/changeset/base/329103 Log: MFC r303725 (oshogbo): Fix misleading description of the -b option in the geli init command. Modified: stable/11/sbin/geom/class/eli/geli.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/geom/class/eli/geli.8 ============================================================================== --- stable/11/sbin/geom/class/eli/geli.8 Sat Feb 10 14:45:29 2018 (r329102) +++ stable/11/sbin/geom/class/eli/geli.8 Sat Feb 10 15:23:30 2018 (r329103) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 10, 2015 +.Dd August 3, 2016 .Dt GELI 8 .Os .Sh NAME @@ -266,7 +266,7 @@ If the option is not given, there will be no authentic The recommended algorithm is .Nm HMAC/SHA256 . .It Fl b -Ask for the passphrase on boot, before the root partition is mounted. +Try to decrypt this partition during boot, before the root partition is mounted. This makes it possible to use an encrypted root partition. One will still need bootable unencrypted storage with a .Pa /boot/ From owner-svn-src-stable-11@freebsd.org Sat Feb 10 22:34:48 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1BE1CF027F5; Sat, 10 Feb 2018 22:34:48 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C61B776086; Sat, 10 Feb 2018 22:34:47 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C11BF1A3B9; Sat, 10 Feb 2018 22:34:47 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1AMYlce075796; Sat, 10 Feb 2018 22:34:47 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1AMYlRP075795; Sat, 10 Feb 2018 22:34:47 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201802102234.w1AMYlRP075795@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sat, 10 Feb 2018 22:34:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329111 - stable/11/etc X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/etc X-SVN-Commit-Revision: 329111 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Feb 2018 22:34:48 -0000 Author: emaste Date: Sat Feb 10 22:34:47 2018 New Revision: 329111 URL: https://svnweb.freebsd.org/changeset/base/329111 Log: MFC r328895: Correct Russia spelling in regdomain.xml PR: 225658 Modified: stable/11/etc/regdomain.xml Directory Properties: stable/11/ (props changed) Modified: stable/11/etc/regdomain.xml ============================================================================== --- stable/11/etc/regdomain.xml Sat Feb 10 22:34:46 2018 (r329110) +++ stable/11/etc/regdomain.xml Sat Feb 10 22:34:47 2018 (r329111) @@ -1595,7 +1595,7 @@ 642 Romania - 643 Rusia + 643 Russia 682 Saudi Arabia