From owner-svn-src-projects@freebsd.org Tue Oct 10 15:47:01 2017 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8F6BEE35934 for ; Tue, 10 Oct 2017 15:47:01 +0000 (UTC) (envelope-from ngie@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 mx1.freebsd.org (Postfix) with ESMTPS id 5823C24E0; Tue, 10 Oct 2017 15:47:01 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9AFl0hT052775; Tue, 10 Oct 2017 15:47:00 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9AFkwxv052749; Tue, 10 Oct 2017 15:46:58 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201710101546.v9AFkwxv052749@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Tue, 10 Oct 2017 15:46:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r324498 - in projects/runtime-coverage: . sys/arm64/arm64 sys/arm64/include sys/conf sys/contrib/rdma/krping sys/dev/hyperv/include sys/dev/hyperv/netvsc sys/dev/hyperv/vmbus sys/dev/ml... X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in projects/runtime-coverage: . sys/arm64/arm64 sys/arm64/include sys/conf sys/contrib/rdma/krping sys/dev/hyperv/include sys/dev/hyperv/netvsc sys/dev/hyperv/vmbus sys/dev/mlx5/mlx5_ib sys/modules sy... X-SVN-Commit-Revision: 324498 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Oct 2017 15:47:01 -0000 Author: ngie Date: Tue Oct 10 15:46:58 2017 New Revision: 324498 URL: https://svnweb.freebsd.org/changeset/base/324498 Log: MFhead@r324497 Added: projects/runtime-coverage/sys/arm64/arm64/efirt_machdep.c - copied unchanged from r324497, head/sys/arm64/arm64/efirt_machdep.c projects/runtime-coverage/sys/arm64/include/fpu.h - copied unchanged from r324497, head/sys/arm64/include/fpu.h Modified: projects/runtime-coverage/Makefile.inc1 projects/runtime-coverage/sys/arm64/arm64/machdep.c projects/runtime-coverage/sys/arm64/arm64/pmap.c projects/runtime-coverage/sys/arm64/include/efi.h projects/runtime-coverage/sys/arm64/include/pte.h projects/runtime-coverage/sys/conf/files.arm64 projects/runtime-coverage/sys/conf/options.arm64 projects/runtime-coverage/sys/contrib/rdma/krping/krping.c projects/runtime-coverage/sys/dev/hyperv/include/hyperv.h projects/runtime-coverage/sys/dev/hyperv/netvsc/hn_nvs.c projects/runtime-coverage/sys/dev/hyperv/netvsc/if_hn.c projects/runtime-coverage/sys/dev/hyperv/netvsc/if_hnvar.h projects/runtime-coverage/sys/dev/hyperv/vmbus/hyperv.c projects/runtime-coverage/sys/dev/hyperv/vmbus/vmbus.c projects/runtime-coverage/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c projects/runtime-coverage/sys/modules/Makefile projects/runtime-coverage/sys/ofed/include/rdma/ib_addr.h projects/runtime-coverage/usr.bin/su/su.c Directory Properties: projects/runtime-coverage/ (props changed) Modified: projects/runtime-coverage/Makefile.inc1 ============================================================================== --- projects/runtime-coverage/Makefile.inc1 Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/Makefile.inc1 Tue Oct 10 15:46:58 2017 (r324498) @@ -2601,7 +2601,7 @@ check-old-files: .PHONY done; \ done # Check for catpages without corresponding manpages. - @find ${DESTDIR}/usr/share/man/cat* ! -type d | \ + @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \ sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \ while read catpage; do \ read manpage; \ Copied: projects/runtime-coverage/sys/arm64/arm64/efirt_machdep.c (from r324497, head/sys/arm64/arm64/efirt_machdep.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/runtime-coverage/sys/arm64/arm64/efirt_machdep.c Tue Oct 10 15:46:58 2017 (r324498, copy of r324497, head/sys/arm64/arm64/efirt_machdep.c) @@ -0,0 +1,252 @@ +/*- + * Copyright (c) 2004 Marcel Moolenaar + * Copyright (c) 2001 Doug Rabson + * Copyright (c) 2016 The FreeBSD Foundation + * Copyright (c) 2017 Andrew Turner + * All rights reserved. + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +static vm_object_t obj_1t1_pt; +static vm_page_t efi_l0_page; +static pd_entry_t *efi_l0; + +void +efi_destroy_1t1_map(void) +{ + vm_page_t m; + + if (obj_1t1_pt != NULL) { + VM_OBJECT_RLOCK(obj_1t1_pt); + TAILQ_FOREACH(m, &obj_1t1_pt->memq, listq) + m->wire_count = 0; + atomic_subtract_int(&vm_cnt.v_wire_count, + obj_1t1_pt->resident_page_count); + VM_OBJECT_RUNLOCK(obj_1t1_pt); + vm_object_deallocate(obj_1t1_pt); + } + + obj_1t1_pt = NULL; + efi_l0 = NULL; + efi_l0_page = NULL; +} + +static vm_page_t +efi_1t1_page(vm_pindex_t idx) +{ + + return (vm_page_grab(obj_1t1_pt, idx, VM_ALLOC_NOBUSY | + VM_ALLOC_WIRED | VM_ALLOC_ZERO)); +} + +static pt_entry_t * +efi_1t1_l3(vm_offset_t va) +{ + pd_entry_t *l0, *l1, *l2; + pt_entry_t *l3; + vm_pindex_t l0_idx, l1_idx, l2_idx; + vm_page_t m; + vm_paddr_t mphys; + + l0_idx = pmap_l0_index(va); + l0 = &efi_l0[l0_idx]; + if (*l0 == 0) { + m = efi_1t1_page(1 + l0_idx); + mphys = VM_PAGE_TO_PHYS(m); + *l0 = mphys | L0_TABLE; + } else { + mphys = *l0 & ~ATTR_MASK; + } + + l1 = (pd_entry_t *)PHYS_TO_DMAP(mphys); + l1_idx = pmap_l1_index(va); + l1 += l1_idx; + if (*l1 == 0) { + m = efi_1t1_page(1 + L0_ENTRIES + (l0_idx + 1) * (l1_idx + 1)); + mphys = VM_PAGE_TO_PHYS(m); + *l1 = mphys | L1_TABLE; + } else { + mphys = *l1 & ~ATTR_MASK; + } + + l2 = (pd_entry_t *)PHYS_TO_DMAP(mphys); + l2_idx = pmap_l2_index(va); + l2 += l2_idx; + if (*l2 == 0) { + m = efi_1t1_page(1 + L0_ENTRIES + L0_ENTRIES * Ln_ENTRIES + + (l0_idx + 1) * (l1_idx + 1) * (l2_idx + 1)); + mphys = VM_PAGE_TO_PHYS(m); + *l2 = mphys | L2_TABLE; + } else { + mphys = *l2 & ~ATTR_MASK; + } + + l3 = (pt_entry_t *)PHYS_TO_DMAP(mphys); + l3 += pmap_l3_index(va); + KASSERT(*l3 == 0, ("%s: Already mapped: va %#jx *pt %#jx", __func__, + va, *l3)); + + return (l3); +} + +/* + * Create the 1:1 virtual to physical map for EFI + */ +bool +efi_create_1t1_map(struct efi_md *map, int ndesc, int descsz) +{ + struct efi_md *p; + pt_entry_t *l3; + vm_offset_t va; + uint64_t idx; + int i, mode; + + obj_1t1_pt = vm_pager_allocate(OBJT_PHYS, NULL, L0_ENTRIES + + L0_ENTRIES * Ln_ENTRIES + L0_ENTRIES * Ln_ENTRIES * Ln_ENTRIES + + L0_ENTRIES * Ln_ENTRIES * Ln_ENTRIES * Ln_ENTRIES, + VM_PROT_ALL, 0, NULL); + VM_OBJECT_WLOCK(obj_1t1_pt); + efi_l0_page = efi_1t1_page(0); + VM_OBJECT_WUNLOCK(obj_1t1_pt); + efi_l0 = (pd_entry_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(efi_l0_page)); + bzero(efi_l0, L0_ENTRIES * sizeof(*efi_l0)); + + for (i = 0, p = map; i < ndesc; i++, p = efi_next_descriptor(p, + descsz)) { + if ((p->md_attr & EFI_MD_ATTR_RT) == 0) + continue; + if (p->md_virt != NULL) { + if (bootverbose) + printf("EFI Runtime entry %d is mapped\n", i); + goto fail; + } + if ((p->md_phys & EFI_PAGE_MASK) != 0) { + if (bootverbose) + printf("EFI Runtime entry %d is not aligned\n", + i); + goto fail; + } + if (p->md_phys + p->md_pages * EFI_PAGE_SIZE < p->md_phys || + p->md_phys + p->md_pages * EFI_PAGE_SIZE >= + VM_MAXUSER_ADDRESS) { + printf("EFI Runtime entry %d is not in mappable for RT:" + "base %#016jx %#jx pages\n", + i, (uintmax_t)p->md_phys, + (uintmax_t)p->md_pages); + goto fail; + } + if ((p->md_attr & EFI_MD_ATTR_WB) != 0) + mode = VM_MEMATTR_WRITE_BACK; + else if ((p->md_attr & EFI_MD_ATTR_WT) != 0) + mode = VM_MEMATTR_WRITE_THROUGH; + else if ((p->md_attr & EFI_MD_ATTR_WC) != 0) + mode = VM_MEMATTR_WRITE_COMBINING; + else if ((p->md_attr & EFI_MD_ATTR_UC) != 0) + mode = VM_MEMATTR_UNCACHEABLE; + else { + if (bootverbose) + printf("EFI Runtime entry %d mapping " + "attributes unsupported\n", i); + mode = VM_MEMATTR_UNCACHEABLE; + } + + printf("MAP %lx mode %x pages %lu\n", p->md_phys, mode, p->md_pages); + VM_OBJECT_WLOCK(obj_1t1_pt); + for (va = p->md_phys, idx = 0; idx < p->md_pages; idx++, + va += PAGE_SIZE) { + l3 = efi_1t1_l3(va); + *l3 = va | ATTR_DEFAULT | ATTR_IDX(mode) | + ATTR_AP(ATTR_AP_RW) | L3_PAGE; + } + VM_OBJECT_WUNLOCK(obj_1t1_pt); + } + + return (true); +fail: + efi_destroy_1t1_map(); + return (false); +} + +int +efi_arch_enter(void) +{ + + __asm __volatile( + "msr ttbr0_el1, %0 \n" + "dsb ishst \n" + "tlbi vmalle1is \n" + "dsb ish \n" + "isb \n" + : : "r"(VM_PAGE_TO_PHYS(efi_l0_page))); + + return (0); +} + +void +efi_arch_leave(void) +{ + struct thread *td; + + td = curthread; + __asm __volatile( + "msr ttbr0_el1, %0 \n" + "dsb ishst \n" + "tlbi vmalle1is \n" + "dsb ish \n" + "isb \n" + : : "r"(td->td_proc->p_md.md_l0addr)); +} Modified: projects/runtime-coverage/sys/arm64/arm64/machdep.c ============================================================================== --- projects/runtime-coverage/sys/arm64/arm64/machdep.c Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/arm64/arm64/machdep.c Tue Oct 10 15:46:58 2017 (r324498) @@ -121,6 +121,12 @@ int64_t idcache_line_size; /* The minimum cache line s int64_t dczva_line_size; /* The size of cache line the dc zva zeroes */ int has_pan; +/* + * Physical address of the EFI System Table. Stashed from the metadata hints + * passed into the kernel and used by the EFI code to call runtime services. + */ +vm_paddr_t efi_systbl_phys; + /* pagezero_* implementations are provided in support.S */ void pagezero_simple(void *); void pagezero_cache(void *); @@ -985,6 +991,8 @@ initarm(struct arm64_bootparams *abp) #ifdef FDT try_load_dtb(kmdp); #endif + + efi_systbl_phys = MD_FETCH(kmdp, MODINFOMD_FW_HANDLE, vm_paddr_t); /* Find the address to start allocating from */ lastaddr = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); Modified: projects/runtime-coverage/sys/arm64/arm64/pmap.c ============================================================================== --- projects/runtime-coverage/sys/arm64/arm64/pmap.c Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/arm64/arm64/pmap.c Tue Oct 10 15:46:58 2017 (r324498) @@ -306,11 +306,6 @@ pagecopy(void *s, void *d) memcpy(d, s, PAGE_SIZE); } -#define pmap_l0_index(va) (((va) >> L0_SHIFT) & L0_ADDR_MASK) -#define pmap_l1_index(va) (((va) >> L1_SHIFT) & Ln_ADDR_MASK) -#define pmap_l2_index(va) (((va) >> L2_SHIFT) & Ln_ADDR_MASK) -#define pmap_l3_index(va) (((va) >> L3_SHIFT) & Ln_ADDR_MASK) - static __inline pd_entry_t * pmap_l0(pmap_t pmap, vm_offset_t va) { Modified: projects/runtime-coverage/sys/arm64/include/efi.h ============================================================================== --- projects/runtime-coverage/sys/arm64/include/efi.h Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/arm64/include/efi.h Tue Oct 10 15:46:58 2017 (r324498) @@ -1,6 +1,32 @@ /*- - * This file is in the public domain since it's just boilerplate. + * Copyright (c) 2017 Andrew Turner + * All rights reserved. * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * 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$ */ @@ -8,5 +34,11 @@ #define __ARM64_INCLUDE_EFI_H_ #define EFIABI_ATTR + +#ifdef _KERNEL +#define EFI_TIME_LOCK() +#define EFI_TIME_UNLOCK() +#define EFI_TIME_OWNED() +#endif #endif /* __ARM64_INCLUDE_EFI_H_ */ Copied: projects/runtime-coverage/sys/arm64/include/fpu.h (from r324497, head/sys/arm64/include/fpu.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/runtime-coverage/sys/arm64/include/fpu.h Tue Oct 10 15:46:58 2017 (r324498, copy of r324497, head/sys/arm64/include/fpu.h) @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + * + * $FreeBSD$ + */ +#include Modified: projects/runtime-coverage/sys/arm64/include/pte.h ============================================================================== --- projects/runtime-coverage/sys/arm64/include/pte.h Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/arm64/include/pte.h Tue Oct 10 15:46:58 2017 (r324498) @@ -118,6 +118,11 @@ typedef uint64_t pt_entry_t; /* page table entry */ #define Ln_ADDR_MASK (Ln_ENTRIES - 1) #define Ln_TABLE_MASK ((1 << 12) - 1) +#define pmap_l0_index(va) (((va) >> L0_SHIFT) & L0_ADDR_MASK) +#define pmap_l1_index(va) (((va) >> L1_SHIFT) & Ln_ADDR_MASK) +#define pmap_l2_index(va) (((va) >> L2_SHIFT) & Ln_ADDR_MASK) +#define pmap_l3_index(va) (((va) >> L3_SHIFT) & Ln_ADDR_MASK) + #endif /* !_MACHINE_PTE_H_ */ /* End of pte.h */ Modified: projects/runtime-coverage/sys/conf/files.arm64 ============================================================================== --- projects/runtime-coverage/sys/conf/files.arm64 Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/conf/files.arm64 Tue Oct 10 15:46:58 2017 (r324498) @@ -95,6 +95,7 @@ arm64/arm64/db_trace.c optional ddb arm64/arm64/debug_monitor.c optional ddb arm64/arm64/disassem.c optional ddb arm64/arm64/dump_machdep.c standard +arm64/arm64/efirt_machdep.c optional efirt arm64/arm64/elf_machdep.c standard arm64/arm64/exception.S standard arm64/arm64/gicv3_its.c optional intrng fdt Modified: projects/runtime-coverage/sys/conf/options.arm64 ============================================================================== --- projects/runtime-coverage/sys/conf/options.arm64 Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/conf/options.arm64 Tue Oct 10 15:46:58 2017 (r324498) @@ -7,6 +7,10 @@ SOCDEV_VA opt_global.h THUNDERX_PASS_1_1_ERRATA opt_global.h VFP opt_global.h +# EFI Runtime services support +EFIRT opt_efirt.h + +# Devices DEV_PSCI opt_platform.h # SoC Support Modified: projects/runtime-coverage/sys/contrib/rdma/krping/krping.c ============================================================================== --- projects/runtime-coverage/sys/contrib/rdma/krping/krping.c Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/contrib/rdma/krping/krping.c Tue Oct 10 15:46:58 2017 (r324498) @@ -86,6 +86,7 @@ static const struct krping_option krping_opts[] = { {"count", OPT_INT, 'C'}, {"size", OPT_INT, 'S'}, {"addr", OPT_STRING, 'a'}, + {"addr6", OPT_STRING, 'A'}, {"port", OPT_INT, 'p'}, {"verbose", OPT_NOPARAM, 'v'}, {"validate", OPT_NOPARAM, 'V'}, @@ -220,7 +221,11 @@ struct krping_cb { struct krping_stats stats; uint16_t port; /* dst port in NBO */ - struct in_addr addr; /* dst addr in NBO */ + union { + struct in_addr v4; + struct in6_addr v6; + } addr; /* dst addr in NBO */ + int addr_type; /* AF_INET or AF_INET6 */ char *addr_str; /* dst addr string */ int verbose; /* verbose logging */ int count; /* ping count */ @@ -1600,15 +1605,31 @@ static int fastreg_supported(struct krping_cb *cb, int static int krping_bind_server(struct krping_cb *cb) { - struct sockaddr_in sin; + union { + struct sockaddr_in v4; + struct sockaddr_in6 v6; + } sin; int ret; memset(&sin, 0, sizeof(sin)); - sin.sin_len = sizeof sin; - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = cb->addr.s_addr; - sin.sin_port = cb->port; + switch (cb->addr_type) { + case AF_INET: + sin.v4.sin_len = sizeof sin.v4; + sin.v4.sin_family = AF_INET; + sin.v4.sin_addr = cb->addr.v4; + sin.v4.sin_port = cb->port; + break; + case AF_INET6: + sin.v6.sin6_len = sizeof sin.v6; + sin.v6.sin6_family = AF_INET6; + sin.v6.sin6_addr = cb->addr.v6; + sin.v6.sin6_port = cb->port; + break; + default: + return (-EINVAL); + } + ret = rdma_bind_addr(cb->cm_id, (struct sockaddr *) &sin); if (ret) { PRINTF(cb, "rdma_bind_addr error %d\n", ret); @@ -3059,15 +3080,31 @@ static int krping_connect_client(struct krping_cb *cb) static int krping_bind_client(struct krping_cb *cb) { - struct sockaddr_in sin; + union { + struct sockaddr_in v4; + struct sockaddr_in6 v6; + } sin; int ret; memset(&sin, 0, sizeof(sin)); - sin.sin_len = sizeof sin; - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = cb->addr.s_addr; - sin.sin_port = cb->port; + switch (cb->addr_type) { + case AF_INET: + sin.v4.sin_len = sizeof sin.v4; + sin.v4.sin_family = AF_INET; + sin.v4.sin_addr = cb->addr.v4; + sin.v4.sin_port = cb->port; + break; + case AF_INET6: + sin.v6.sin6_len = sizeof sin.v6; + sin.v6.sin6_family = AF_INET6; + sin.v6.sin6_addr = cb->addr.v6; + sin.v6.sin6_port = cb->port; + break; + default: + return (-EINVAL); + } + ret = rdma_resolve_addr(cb->cm_id, NULL, (struct sockaddr *) &sin, 2000); if (ret) { @@ -3140,12 +3177,29 @@ err1: krping_free_qp(cb); } +static uint16_t +krping_get_ipv6_scope_id(char *name) +{ + struct ifnet *ifp; + uint16_t retval; + + if (name == NULL) + return (0); + ifp = ifunit_ref(name); + if (ifp == NULL) + return (0); + retval = ifp->if_index; + if_rele(ifp); + return (retval); +} + int krping_doit(char *cmd, void *cookie) { struct krping_cb *cb; int op; int ret = 0; char *optarg; + char *scope; unsigned long optint; cb = kzalloc(sizeof(*cb), GFP_KERNEL); @@ -3162,6 +3216,7 @@ int krping_doit(char *cmd, void *cookie) cb->size = 64; cb->txdepth = RPING_SQ_DEPTH; cb->mem = DMA; + cb->addr_type = AF_INET; init_waitqueue_head(&cb->sem); while ((op = krping_getopt("krping", &cmd, krping_opts, NULL, &optarg, @@ -3169,11 +3224,33 @@ int krping_doit(char *cmd, void *cookie) switch (op) { case 'a': cb->addr_str = optarg; - DEBUG_LOG(cb, "ipaddr (%s)\n", optarg); - if (!inet_aton(optarg, &cb->addr)) { + cb->addr_type = AF_INET; + DEBUG_LOG(cb, "ipv4addr (%s)\n", optarg); + if (inet_pton(AF_INET, optarg, &cb->addr) != 1) { PRINTF(cb, "bad addr string %s\n", optarg); ret = EINVAL; + } + break; + case 'A': + cb->addr_str = optarg; + cb->addr_type = AF_INET6; + DEBUG_LOG(cb, "ipv6addr (%s)\n", optarg); + scope = strstr(optarg, "%"); + /* extract scope ID, if any */ + if (scope != NULL) + *scope++ = 0; + /* extract IPv6 network address */ + if (inet_pton(AF_INET6, optarg, &cb->addr) != 1) { + PRINTF(cb, "bad addr string %s\n", + optarg); + ret = EINVAL; + } else if (IN6_IS_SCOPE_LINKLOCAL(&cb->addr.v6) || + IN6_IS_ADDR_MC_INTFACELOCAL(&cb->addr.v6)) { + uint16_t scope_id = krping_get_ipv6_scope_id(scope); + DEBUG_LOG(cb, "ipv6 scope ID = %d\n", scope_id); + cb->addr.v6.s6_addr[2] = scope_id >> 8; + cb->addr.v6.s6_addr[3] = scope_id & 0xFF; } break; case 'p': Modified: projects/runtime-coverage/sys/dev/hyperv/include/hyperv.h ============================================================================== --- projects/runtime-coverage/sys/dev/hyperv/include/hyperv.h Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/dev/hyperv/include/hyperv.h Tue Oct 10 15:46:58 2017 (r324498) @@ -90,6 +90,7 @@ int hyperv_guid2str(const struct hyperv_guid *, char */ extern hyperv_tc64_t hyperv_tc64; extern u_int hyperv_features; /* CPUID_HV_MSR_ */ +extern u_int hyperv_ver_major; #endif /* _KERNEL */ Modified: projects/runtime-coverage/sys/dev/hyperv/netvsc/hn_nvs.c ============================================================================== --- projects/runtime-coverage/sys/dev/hyperv/netvsc/hn_nvs.c Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/dev/hyperv/netvsc/hn_nvs.c Tue Oct 10 15:46:58 2017 (r324498) @@ -601,6 +601,11 @@ hn_nvs_attach(struct hn_softc *sc, int mtu) { int error; + if (hyperv_ver_major >= 10) { + /* UDP 4-tuple hash is enforced. */ + sc->hn_caps |= HN_CAP_UDPHASH; + } + /* * Initialize NVS. */ Modified: projects/runtime-coverage/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- projects/runtime-coverage/sys/dev/hyperv/netvsc/if_hn.c Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/dev/hyperv/netvsc/if_hn.c Tue Oct 10 15:46:58 2017 (r324498) @@ -385,6 +385,7 @@ static void hn_link_status(struct hn_softc *); static int hn_create_rx_data(struct hn_softc *, int); static void hn_destroy_rx_data(struct hn_softc *); static int hn_check_iplen(const struct mbuf *, int); +static void hn_rxpkt_proto(const struct mbuf *, int *, int *); static int hn_set_rxfilter(struct hn_softc *, uint32_t); static int hn_rxfilter_config(struct hn_softc *); static int hn_rss_reconfig(struct hn_softc *); @@ -399,6 +400,7 @@ static int hn_tx_ring_create(struct hn_softc *, int) static void hn_tx_ring_destroy(struct hn_tx_ring *); static int hn_create_tx_data(struct hn_softc *, int); static void hn_fixup_tx_data(struct hn_softc *); +static void hn_fixup_rx_data(struct hn_softc *); static void hn_destroy_tx_data(struct hn_softc *); static void hn_txdesc_dmamap_destroy(struct hn_txdesc *); static void hn_txdesc_gc(struct hn_tx_ring *, @@ -2238,9 +2240,10 @@ hn_attach(device_t dev) #endif /* - * Fixup TX stuffs after synthetic parts are attached. + * Fixup TX/RX stuffs after synthetic parts are attached. */ hn_fixup_tx_data(sc); + hn_fixup_rx_data(sc); ctx = device_get_sysctl_ctx(dev); child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); @@ -3378,6 +3381,7 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int struct mbuf *m_new; int size, do_lro = 0, do_csum = 1, is_vf = 0; int hash_type = M_HASHTYPE_NONE; + int l3proto = ETHERTYPE_MAX, l4proto = IPPROTO_DONE; ifp = hn_ifp; if (rxr->hn_rxvf_ifp != NULL) { @@ -3477,31 +3481,9 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int (NDIS_RXCSUM_INFO_TCPCS_OK | NDIS_RXCSUM_INFO_IPCS_OK)) do_lro = 1; } else { - const struct ether_header *eh; - uint16_t etype; - int hoff; - - hoff = sizeof(*eh); - /* Checked at the beginning of this function. */ - KASSERT(m_new->m_len >= hoff, ("not ethernet frame")); - - eh = mtod(m_new, struct ether_header *); - etype = ntohs(eh->ether_type); - if (etype == ETHERTYPE_VLAN) { - const struct ether_vlan_header *evl; - - hoff = sizeof(*evl); - if (m_new->m_len < hoff) - goto skip; - evl = mtod(m_new, struct ether_vlan_header *); - etype = ntohs(evl->evl_proto); - } - - if (etype == ETHERTYPE_IP) { - int pr; - - pr = hn_check_iplen(m_new, hoff); - if (pr == IPPROTO_TCP) { + hn_rxpkt_proto(m_new, &l3proto, &l4proto); + if (l3proto == ETHERTYPE_IP) { + if (l4proto == IPPROTO_TCP) { if (do_csum && (rxr->hn_trust_hcsum & HN_TRUST_HCSUM_TCP)) { @@ -3512,7 +3494,7 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int m_new->m_pkthdr.csum_data = 0xffff; } do_lro = 1; - } else if (pr == IPPROTO_UDP) { + } else if (l4proto == IPPROTO_UDP) { if (do_csum && (rxr->hn_trust_hcsum & HN_TRUST_HCSUM_UDP)) { @@ -3522,7 +3504,7 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int CSUM_DATA_VALID | CSUM_PSEUDO_HDR); m_new->m_pkthdr.csum_data = 0xffff; } - } else if (pr != IPPROTO_DONE && do_csum && + } else if (l4proto != IPPROTO_DONE && do_csum && (rxr->hn_trust_hcsum & HN_TRUST_HCSUM_IP)) { rxr->hn_csum_trusted++; m_new->m_pkthdr.csum_flags |= @@ -3530,7 +3512,7 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int } } } -skip: + if (info->vlan_info != HN_NDIS_VLAN_INFO_INVALID) { m_new->m_pkthdr.ether_vtag = EVL_MAKETAG( NDIS_VLAN_INFO_ID(info->vlan_info), @@ -3585,6 +3567,35 @@ skip: case NDIS_HASH_TCP_IPV4: hash_type = M_HASHTYPE_RSS_TCP_IPV4; + if (rxr->hn_rx_flags & HN_RX_FLAG_UDP_HASH) { + int def_htype = M_HASHTYPE_OPAQUE_HASH; + + if (is_vf) + def_htype = M_HASHTYPE_NONE; + + /* + * UDP 4-tuple hash is delivered as + * TCP 4-tuple hash. + */ + if (l3proto == ETHERTYPE_MAX) { + hn_rxpkt_proto(m_new, + &l3proto, &l4proto); + } + if (l3proto == ETHERTYPE_IP) { + if (l4proto == IPPROTO_UDP) { + hash_type = + M_HASHTYPE_RSS_UDP_IPV4; + do_lro = 0; + } else if (l4proto != + IPPROTO_TCP) { + hash_type = def_htype; + do_lro = 0; + } + } else { + hash_type = def_htype; + do_lro = 0; + } + } break; case NDIS_HASH_IPV6: @@ -4835,6 +4846,36 @@ hn_check_iplen(const struct mbuf *m, int hoff) return ip->ip_p; } +static void +hn_rxpkt_proto(const struct mbuf *m_new, int *l3proto, int *l4proto) +{ + const struct ether_header *eh; + uint16_t etype; + int hoff; + + hoff = sizeof(*eh); + /* Checked at the beginning of this function. */ + KASSERT(m_new->m_len >= hoff, ("not ethernet frame")); + + eh = mtod(m_new, const struct ether_header *); + etype = ntohs(eh->ether_type); + if (etype == ETHERTYPE_VLAN) { + const struct ether_vlan_header *evl; + + hoff = sizeof(*evl); + if (m_new->m_len < hoff) + return; + evl = mtod(m_new, const struct ether_vlan_header *); + etype = ntohs(evl->evl_proto); + } + *l3proto = etype; + + if (etype == ETHERTYPE_IP) + *l4proto = hn_check_iplen(m_new, hoff); + else + *l4proto = IPPROTO_DONE; +} + static int hn_create_rx_data(struct hn_softc *sc, int ring_cnt) { @@ -5543,6 +5584,18 @@ hn_fixup_tx_data(struct hn_softc *sc) if_printf(sc->hn_ifp, "support HASHVAL pktinfo\n"); for (i = 0; i < sc->hn_tx_ring_cnt; ++i) sc->hn_tx_ring[i].hn_tx_flags |= HN_TX_FLAG_HASHVAL; + } +} + +static void +hn_fixup_rx_data(struct hn_softc *sc) +{ + + if (sc->hn_caps & HN_CAP_UDPHASH) { + int i; + + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) + sc->hn_rx_ring[i].hn_rx_flags |= HN_RX_FLAG_UDP_HASH; } } Modified: projects/runtime-coverage/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- projects/runtime-coverage/sys/dev/hyperv/netvsc/if_hnvar.h Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/dev/hyperv/netvsc/if_hnvar.h Tue Oct 10 15:46:58 2017 (r324498) @@ -97,6 +97,7 @@ struct hn_rx_ring { #define HN_RX_FLAG_ATTACHED 0x0001 #define HN_RX_FLAG_BR_REF 0x0002 #define HN_RX_FLAG_XPNT_VF 0x0004 +#define HN_RX_FLAG_UDP_HASH 0x0008 struct hn_tx_ring { #ifndef HN_USE_TXDESC_BUFRING @@ -304,11 +305,12 @@ do { \ #define HN_CAP_TSO4 0x0080 #define HN_CAP_TSO6 0x0100 #define HN_CAP_HASHVAL 0x0200 +#define HN_CAP_UDPHASH 0x0400 /* Capability description for use with printf(9) %b identifier. */ #define HN_CAP_BITS \ "\020\1VLAN\2MTU\3IPCS\4TCP4CS\5TCP6CS" \ - "\6UDP4CS\7UDP6CS\10TSO4\11TSO6\12HASHVAL" + "\6UDP4CS\7UDP6CS\10TSO4\11TSO6\12HASHVAL\13UDPHASH" #define HN_LINK_FLAG_LINKUP 0x0001 #define HN_LINK_FLAG_NETCHG 0x0002 Modified: projects/runtime-coverage/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- projects/runtime-coverage/sys/dev/hyperv/vmbus/hyperv.c Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/dev/hyperv/vmbus/hyperv.c Tue Oct 10 15:46:58 2017 (r324498) @@ -77,6 +77,8 @@ static u_int hyperv_get_timecount(struct timecounter static bool hyperv_identify(void); static void hypercall_memfree(void); +u_int hyperv_ver_major; + u_int hyperv_features; u_int hyperv_recommends; @@ -169,8 +171,9 @@ hyperv_identify(void) hyperv_features3 = regs[3]; do_cpuid(CPUID_LEAF_HV_IDENTITY, regs); + hyperv_ver_major = regs[1] >> 16; printf("Hyper-V Version: %d.%d.%d [SP%d]\n", - regs[1] >> 16, regs[1] & 0xffff, regs[0], regs[2]); + hyperv_ver_major, regs[1] & 0xffff, regs[0], regs[2]); printf(" Features=0x%b\n", hyperv_features, "\020" Modified: projects/runtime-coverage/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- projects/runtime-coverage/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 10 15:46:58 2017 (r324498) @@ -128,6 +128,13 @@ static void vmbus_event_proc_dummy(struct vmbus_soft static struct vmbus_softc *vmbus_sc; +SYSCTL_NODE(_hw, OID_AUTO, vmbus, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, + "Hyper-V vmbus"); + +static int vmbus_pin_evttask = 1; +SYSCTL_INT(_hw_vmbus, OID_AUTO, pin_evttask, CTLFLAG_RDTUN, + &vmbus_pin_evttask, 0, "Pin event tasks to their respective CPU"); + extern inthand_t IDTVEC(vmbus_isr); static const uint32_t vmbus_version[] = { @@ -905,10 +912,16 @@ vmbus_intr_setup(struct vmbus_softc *sc) VMBUS_PCPU_GET(sc, event_tq, cpu) = taskqueue_create_fast( "hyperv event", M_WAITOK, taskqueue_thread_enqueue, VMBUS_PCPU_PTR(sc, event_tq, cpu)); - CPU_SETOF(cpu, &cpu_mask); - taskqueue_start_threads_cpuset( - VMBUS_PCPU_PTR(sc, event_tq, cpu), 1, PI_NET, &cpu_mask, - "hvevent%d", cpu); + if (vmbus_pin_evttask) { + CPU_SETOF(cpu, &cpu_mask); + taskqueue_start_threads_cpuset( + VMBUS_PCPU_PTR(sc, event_tq, cpu), 1, PI_NET, + &cpu_mask, "hvevent%d", cpu); + } else { + taskqueue_start_threads( + VMBUS_PCPU_PTR(sc, event_tq, cpu), 1, PI_NET, + "hvevent%d", cpu); + } /* * Setup tasks and taskqueues to handle messages. Modified: projects/runtime-coverage/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c ============================================================================== --- projects/runtime-coverage/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c Tue Oct 10 15:46:58 2017 (r324498) @@ -562,26 +562,6 @@ mlx5_make_default_gid(struct net_device *dev, union ib mlx5_addrconf_ifid_eui48(&gid->raw[8], dev); } -static inline int -mlx5_ip2gid(const struct sockaddr *addr, union ib_gid *gid) -{ - switch (addr->sa_family) { - case AF_INET: - ipv6_addr_set_v4mapped(((const struct sockaddr_in *)addr)->sin_addr.s_addr, - (struct in6_addr *)gid->raw); - break; - case AF_INET6: - memcpy(gid->raw, &((const struct sockaddr_in6 *)addr)->sin6_addr, 16); - /* clear SCOPE ID */ - gid->raw[2] = 0; - gid->raw[3] = 0; - break; - default: - return -EINVAL; - } - return 0; -} - static void mlx5_ib_roce_port_update(void *arg) { @@ -639,7 +619,7 @@ mlx5_ib_roce_port_update(void *arg) gid_index >= MLX5_IB_GID_MAX) continue; memset(&gid_temp, 0, sizeof(gid_temp)); - mlx5_ip2gid(ifa->ifa_addr, &gid_temp); + rdma_ip2gid(ifa->ifa_addr, &gid_temp); /* check for existing entry */ for (j = 0; j != gid_index; j++) { if (bcmp(&gid_temp, &port->gid_table[j], sizeof(gid_temp)) == 0) Modified: projects/runtime-coverage/sys/modules/Makefile ============================================================================== --- projects/runtime-coverage/sys/modules/Makefile Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/modules/Makefile Tue Oct 10 15:46:58 2017 (r324498) @@ -562,6 +562,7 @@ _cxgb= cxgb .if ${MACHINE_CPUARCH} == "aarch64" _armv8crypto= armv8crypto +_efirt= efirt _em= em .endif Modified: projects/runtime-coverage/sys/ofed/include/rdma/ib_addr.h ============================================================================== --- projects/runtime-coverage/sys/ofed/include/rdma/ib_addr.h Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/sys/ofed/include/rdma/ib_addr.h Tue Oct 10 15:46:58 2017 (r324498) @@ -157,6 +157,12 @@ static inline int rdma_ip2gid(struct sockaddr *addr, u case AF_INET6: memcpy(gid->raw, &((struct sockaddr_in6 *)addr)->sin6_addr, 16); + /* make sure scope ID gets zeroed inside GID */ + if (IN6_IS_SCOPE_LINKLOCAL((struct in6_addr *)gid->raw) || + IN6_IS_ADDR_MC_INTFACELOCAL((struct in6_addr *)gid->raw)) { + gid->raw[2] = 0; + gid->raw[3] = 0; + } break; default: return -EINVAL; Modified: projects/runtime-coverage/usr.bin/su/su.c ============================================================================== --- projects/runtime-coverage/usr.bin/su/su.c Tue Oct 10 15:41:35 2017 (r324497) +++ projects/runtime-coverage/usr.bin/su/su.c Tue Oct 10 15:46:58 2017 (r324498) @@ -172,7 +172,7 @@ main(int argc, char *argv[]) au_id_t auid; #endif - shell = class = cleanenv = NULL; + p = shell = class = cleanenv = NULL; asme = asthem = fastlogin = statusp = 0; user = "root"; iscsh = UNSET;