From owner-svn-src-stable-12@freebsd.org Sun Jun 2 09:27:40 2019 Return-Path: Delivered-To: svn-src-stable-12@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 DEE5715B004D; Sun, 2 Jun 2019 09:27:39 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7C5E8912AB; Sun, 2 Jun 2019 09:27:39 +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 63308250A4; Sun, 2 Jun 2019 09:27:39 +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 x529RdJZ021015; Sun, 2 Jun 2019 09:27:39 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x529Rdpm021014; Sun, 2 Jun 2019 09:27:39 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201906020927.x529Rdpm021014@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 2 Jun 2019 09:27:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348507 - stable/12/usr.bin/posixshmcontrol X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/usr.bin/posixshmcontrol X-SVN-Commit-Revision: 348507 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7C5E8912AB X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.946,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Jun 2019 09:27:40 -0000 Author: kib Date: Sun Jun 2 09:27:38 2019 New Revision: 348507 URL: https://svnweb.freebsd.org/changeset/base/348507 Log: MFC r348432: Minor tweaks to the layout. Modified: stable/12/usr.bin/posixshmcontrol/posixshmcontrol.1 Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/posixshmcontrol/posixshmcontrol.1 ============================================================================== --- stable/12/usr.bin/posixshmcontrol/posixshmcontrol.1 Sun Jun 2 04:28:10 2019 (r348506) +++ stable/12/usr.bin/posixshmcontrol/posixshmcontrol.1 Sun Jun 2 09:27:38 2019 (r348507) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 27, 2019 +.Dd May 30, 2019 .Dt POSIXSHMCONTROL 1 .Os .Sh NAME @@ -97,14 +97,14 @@ utility. Change the length of the segments. Argument to the .Fl s -option specifies new length, the human-friendly 'k', 'm', 'g' suffixes -can be used, see +option specifies new length. +The human-friendly 'k', 'm', 'g' suffixes can be used, see .Xr expand_number 3. If the option is not specified, assumed length is zero. .El .Pp For some commands, the following options may be provided: -.Bl -tag XX +.Bl -tag -width XXX .It Fl h If specified, requests human-readable display of size, see .Xr humanize_number 3 . From owner-svn-src-stable-12@freebsd.org Sun Jun 2 09:29:07 2019 Return-Path: Delivered-To: svn-src-stable-12@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 394B215B0087; Sun, 2 Jun 2019 09:29:07 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B6D27913D8; Sun, 2 Jun 2019 09:28:50 +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 8E81A250A6; Sun, 2 Jun 2019 09:28:50 +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 x529SoIt021114; Sun, 2 Jun 2019 09:28:50 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x529Sor3021113; Sun, 2 Jun 2019 09:28:50 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201906020928.x529Sor3021113@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 2 Jun 2019 09:28:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348508 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 348508 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B6D27913D8 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.946,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Jun 2019 09:29:07 -0000 Author: kib Date: Sun Jun 2 09:28:50 2019 New Revision: 348508 URL: https://svnweb.freebsd.org/changeset/base/348508 Log: MFC r348433: Remove TODO comment after posixshmcontrol(1) added. Modified: stable/12/sys/kern/uipc_shm.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/uipc_shm.c ============================================================================== --- stable/12/sys/kern/uipc_shm.c Sun Jun 2 09:27:38 2019 (r348507) +++ stable/12/sys/kern/uipc_shm.c Sun Jun 2 09:28:50 2019 (r348508) @@ -36,16 +36,10 @@ * shm_open(2) and shm_unlink(2). While most of the implementation is * here, vm_mmap.c contains mapping logic changes. * - * TODO: - * - * (1) Need to export data to a userland tool via a sysctl. Should ipcs(1) - * and ipcrm(1) be expanded or should new tools to manage both POSIX - * kernel semaphores and POSIX shared memory be written? - * - * (2) Add support for this file type to fstat(1). - * - * (3) Resource limits? Does this need its own resource limits or are the - * existing limits in mmap(2) sufficient? + * posixshmcontrol(1) allows users to inspect the state of the memory + * objects. Per-uid swap resource limit controls total amount of + * memory that user can consume for anonymous objects, including + * shared. */ #include From owner-svn-src-stable-12@freebsd.org Sun Jun 2 18:46:28 2019 Return-Path: Delivered-To: svn-src-stable-12@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 1FF4115BCF83; Sun, 2 Jun 2019 18:46:28 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 38986747B8; Sun, 2 Jun 2019 18:46:27 +0000 (UTC) (envelope-from vmaffione@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 22D1A2AE2B; Sun, 2 Jun 2019 18:46:22 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x52IkMnt015066; Sun, 2 Jun 2019 18:46:22 GMT (envelope-from vmaffione@FreeBSD.org) Received: (from vmaffione@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x52IkM19015065; Sun, 2 Jun 2019 18:46:22 GMT (envelope-from vmaffione@FreeBSD.org) Message-Id: <201906021846.x52IkM19015065@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vmaffione set sender to vmaffione@FreeBSD.org using -f From: Vincenzo Maffione Date: Sun, 2 Jun 2019 18:46:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348516 - stable/12/tests/sys/netmap X-SVN-Group: stable-12 X-SVN-Commit-Author: vmaffione X-SVN-Commit-Paths: stable/12/tests/sys/netmap X-SVN-Commit-Revision: 348516 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 38986747B8 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Jun 2019 18:46:28 -0000 Author: vmaffione Date: Sun Jun 2 18:46:21 2019 New Revision: 348516 URL: https://svnweb.freebsd.org/changeset/base/348516 Log: MFC r346184 netmap: add test cases for multiple host rings Extend the netmap unit tests with new test cases for the multiple-host-rings feature introduced by r345269. Modified: stable/12/tests/sys/netmap/ctrl-api-test.c Directory Properties: stable/12/ (props changed) Modified: stable/12/tests/sys/netmap/ctrl-api-test.c ============================================================================== --- stable/12/tests/sys/netmap/ctrl-api-test.c Sun Jun 2 16:44:50 2019 (r348515) +++ stable/12/tests/sys/netmap/ctrl-api-test.c Sun Jun 2 18:46:21 2019 (r348516) @@ -50,20 +50,16 @@ #ifdef __FreeBSD__ #include "freebsd_test_suite/macros.h" -#endif - -#ifdef __linux__ -#include -#else - static int eventfd(int x __unused, int y __unused) { errno = ENODEV; return -1; } -#endif /* __linux__ */ +#else /* __linux__ */ +#include +#endif static int exec_command(int argc, const char *const argv[]) @@ -144,6 +140,8 @@ struct TestContext { uint32_t nr_rx_slots; /* slots in rx rings */ uint16_t nr_tx_rings; /* number of tx rings */ uint16_t nr_rx_rings; /* number of rx rings */ + uint16_t nr_host_tx_rings; /* number of host tx rings */ + uint16_t nr_host_rx_rings; /* number of host rx rings */ uint16_t nr_mem_id; /* id of the memory allocator */ uint16_t nr_ringid; /* ring(s) we care about */ uint32_t nr_mode; /* specify NR_REG_* modes */ @@ -242,6 +240,8 @@ port_register(struct TestContext *ctx) req.nr_tx_slots = ctx->nr_tx_slots; req.nr_rx_slots = ctx->nr_rx_slots; req.nr_tx_rings = ctx->nr_tx_rings; + req.nr_host_tx_rings = ctx->nr_host_tx_rings; + req.nr_host_rx_rings = ctx->nr_host_rx_rings; req.nr_rx_rings = ctx->nr_rx_rings; req.nr_extra_bufs = ctx->nr_extra_bufs; ret = ioctl(ctx->fd, NIOCCTRL, &hdr); @@ -255,23 +255,29 @@ port_register(struct TestContext *ctx) printf("nr_rx_slots %u\n", req.nr_rx_slots); printf("nr_tx_rings %u\n", req.nr_tx_rings); printf("nr_rx_rings %u\n", req.nr_rx_rings); + printf("nr_host_tx_rings %u\n", req.nr_host_tx_rings); + printf("nr_host_rx_rings %u\n", req.nr_host_rx_rings); printf("nr_mem_id %u\n", req.nr_mem_id); printf("nr_extra_bufs %u\n", req.nr_extra_bufs); success = req.nr_memsize && (ctx->nr_mode == req.nr_mode) && - (ctx->nr_ringid == req.nr_ringid) && - (ctx->nr_flags == req.nr_flags) && - ((!ctx->nr_tx_slots && req.nr_tx_slots) || - (ctx->nr_tx_slots == req.nr_tx_slots)) && - ((!ctx->nr_rx_slots && req.nr_rx_slots) || - (ctx->nr_rx_slots == req.nr_rx_slots)) && - ((!ctx->nr_tx_rings && req.nr_tx_rings) || - (ctx->nr_tx_rings == req.nr_tx_rings)) && - ((!ctx->nr_rx_rings && req.nr_rx_rings) || - (ctx->nr_rx_rings == req.nr_rx_rings)) && - ((!ctx->nr_mem_id && req.nr_mem_id) || - (ctx->nr_mem_id == req.nr_mem_id)) && - (ctx->nr_extra_bufs == req.nr_extra_bufs); + (ctx->nr_ringid == req.nr_ringid) && + (ctx->nr_flags == req.nr_flags) && + ((!ctx->nr_tx_slots && req.nr_tx_slots) || + (ctx->nr_tx_slots == req.nr_tx_slots)) && + ((!ctx->nr_rx_slots && req.nr_rx_slots) || + (ctx->nr_rx_slots == req.nr_rx_slots)) && + ((!ctx->nr_tx_rings && req.nr_tx_rings) || + (ctx->nr_tx_rings == req.nr_tx_rings)) && + ((!ctx->nr_rx_rings && req.nr_rx_rings) || + (ctx->nr_rx_rings == req.nr_rx_rings)) && + ((!ctx->nr_host_tx_rings && req.nr_host_tx_rings) || + (ctx->nr_host_tx_rings == req.nr_host_tx_rings)) && + ((!ctx->nr_host_rx_rings && req.nr_host_rx_rings) || + (ctx->nr_host_rx_rings == req.nr_host_rx_rings)) && + ((!ctx->nr_mem_id && req.nr_mem_id) || + (ctx->nr_mem_id == req.nr_mem_id)) && + (ctx->nr_extra_bufs == req.nr_extra_bufs); if (!success) { return -1; } @@ -281,6 +287,8 @@ port_register(struct TestContext *ctx) ctx->nr_rx_slots = req.nr_rx_slots; ctx->nr_tx_rings = req.nr_tx_rings; ctx->nr_rx_rings = req.nr_rx_rings; + ctx->nr_host_tx_rings = req.nr_host_tx_rings; + ctx->nr_host_rx_rings = req.nr_host_rx_rings; ctx->nr_mem_id = req.nr_mem_id; ctx->nr_extra_bufs = req.nr_extra_bufs; @@ -448,7 +456,7 @@ port_register_hwall_host(struct TestContext *ctx) } static int -port_register_host(struct TestContext *ctx) +port_register_hostall(struct TestContext *ctx) { ctx->nr_mode = NR_REG_SW; return port_register(ctx); @@ -462,7 +470,7 @@ port_register_hwall(struct TestContext *ctx) } static int -port_register_single_ring_couple(struct TestContext *ctx) +port_register_single_hw_pair(struct TestContext *ctx) { ctx->nr_mode = NR_REG_ONE_NIC; ctx->nr_ringid = 0; @@ -470,6 +478,25 @@ port_register_single_ring_couple(struct TestContext *c } static int +port_register_single_host_pair(struct TestContext *ctx) +{ + ctx->nr_mode = NR_REG_ONE_SW; + ctx->nr_host_tx_rings = 2; + ctx->nr_host_rx_rings = 2; + ctx->nr_ringid = 1; + return port_register(ctx); +} + +static int +port_register_hostall_many(struct TestContext *ctx) +{ + ctx->nr_mode = NR_REG_SW; + ctx->nr_host_tx_rings = 5; + ctx->nr_host_rx_rings = 4; + return port_register(ctx); +} + +static int port_register_hwall_tx(struct TestContext *ctx) { ctx->nr_mode = NR_REG_ALL_NIC; @@ -1701,8 +1728,10 @@ static struct mytest tests[] = { decltest(port_info_get), decltest(port_register_hwall_host), decltest(port_register_hwall), - decltest(port_register_host), - decltest(port_register_single_ring_couple), + decltest(port_register_hostall), + decltest(port_register_single_hw_pair), + decltest(port_register_single_host_pair), + decltest(port_register_hostall_many), decltest(vale_attach_detach), decltest(vale_attach_detach_host_rings), decltest(vale_ephemeral_port_hdr_manipulation), From owner-svn-src-stable-12@freebsd.org Sun Jun 2 20:03:01 2019 Return-Path: Delivered-To: svn-src-stable-12@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 2584015BE784; Sun, 2 Jun 2019 20:03:01 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B9DB376CAF; Sun, 2 Jun 2019 20:03:00 +0000 (UTC) (envelope-from vmaffione@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 8AE6A2BB73; Sun, 2 Jun 2019 20:03:00 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x52K30sq056902; Sun, 2 Jun 2019 20:03:00 GMT (envelope-from vmaffione@FreeBSD.org) Received: (from vmaffione@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x52K30Ks056901; Sun, 2 Jun 2019 20:03:00 GMT (envelope-from vmaffione@FreeBSD.org) Message-Id: <201906022003.x52K30Ks056901@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vmaffione set sender to vmaffione@FreeBSD.org using -f From: Vincenzo Maffione Date: Sun, 2 Jun 2019 20:03:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348517 - stable/12/sys/dev/netmap X-SVN-Group: stable-12 X-SVN-Commit-Author: vmaffione X-SVN-Commit-Paths: stable/12/sys/dev/netmap X-SVN-Commit-Revision: 348517 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B9DB376CAF X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Jun 2019 20:03:01 -0000 Author: vmaffione Date: Sun Jun 2 20:03:00 2019 New Revision: 348517 URL: https://svnweb.freebsd.org/changeset/base/348517 Log: MFC r347944 netmap: align if_ptnet to the changes introduced by r347233 This removes non-functional SCTP checksum offload support. More information in the log message of r347233. Modified: stable/12/sys/dev/netmap/if_ptnet.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/netmap/if_ptnet.c ============================================================================== --- stable/12/sys/dev/netmap/if_ptnet.c Sun Jun 2 18:46:21 2019 (r348516) +++ stable/12/sys/dev/netmap/if_ptnet.c Sun Jun 2 20:03:00 2019 (r348517) @@ -68,7 +68,6 @@ #include #include #include -#include #include #include @@ -281,9 +280,8 @@ static inline void ptnet_kick(struct ptnet_queue *pq) #define PTNET_HDR_SIZE sizeof(struct virtio_net_hdr_mrg_rxbuf) #define PTNET_MAX_PKT_SIZE 65536 -#define PTNET_CSUM_OFFLOAD (CSUM_TCP | CSUM_UDP | CSUM_SCTP) -#define PTNET_CSUM_OFFLOAD_IPV6 (CSUM_TCP_IPV6 | CSUM_UDP_IPV6 |\ - CSUM_SCTP_IPV6) +#define PTNET_CSUM_OFFLOAD (CSUM_TCP | CSUM_UDP) +#define PTNET_CSUM_OFFLOAD_IPV6 (CSUM_TCP_IPV6 | CSUM_UDP_IPV6) #define PTNET_ALL_OFFLOAD (CSUM_TSO | PTNET_CSUM_OFFLOAD |\ PTNET_CSUM_OFFLOAD_IPV6) @@ -1539,9 +1537,6 @@ ptnet_rx_csum_by_offset(struct mbuf *m, uint16_t eth_t m->m_pkthdr.csum_flags |= CSUM_DATA_VALID | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xFFFF; break; - case offsetof(struct sctphdr, checksum): - m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; - break; default: /* Here we should increment the rx_csum_bad_offset counter. */ return (1); @@ -1595,11 +1590,6 @@ ptnet_rx_csum_by_parse(struct mbuf *m, uint16_t eth_ty return (1); m->m_pkthdr.csum_flags |= CSUM_DATA_VALID | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xFFFF; - break; - case IPPROTO_SCTP: - if (__predict_false(m->m_len < offset + sizeof(struct sctphdr))) - return (1); - m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; break; default: /* From owner-svn-src-stable-12@freebsd.org Mon Jun 3 04:35:29 2019 Return-Path: Delivered-To: svn-src-stable-12@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 9DAE315C83A0; Mon, 3 Jun 2019 04:35:29 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3E9C38D42A; Mon, 3 Jun 2019 04:35:29 +0000 (UTC) (envelope-from cy@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 2748F1163; Mon, 3 Jun 2019 04:35:29 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x534ZSHo027725; Mon, 3 Jun 2019 04:35:28 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x534ZS0s027724; Mon, 3 Jun 2019 04:35:28 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201906030435.x534ZS0s027724@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Mon, 3 Jun 2019 04:35:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348522 - stable/12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-12 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: stable/12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 348522 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3E9C38D42A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.95)[-0.949,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2019 04:35:29 -0000 Author: cy Date: Mon Jun 3 04:35:28 2019 New Revision: 348522 URL: https://svnweb.freebsd.org/changeset/base/348522 Log: MFC r348310: Remove compile-time tests for unsupported versions of FreeBSD. Modified: stable/12/sys/contrib/ipfilter/netinet/ip_rules.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/contrib/ipfilter/netinet/ip_rules.c ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/ip_rules.c Sun Jun 2 23:38:19 2019 (r348521) +++ stable/12/sys/contrib/ipfilter/netinet/ip_rules.c Mon Jun 3 04:35:28 2019 (r348522) @@ -30,9 +30,9 @@ #if !defined(__SVR4) && !defined(__svr4__) && !defined(__hpux) # include #endif -#if defined(__FreeBSD__) && (__FreeBSD_version > 220000) +#if defined(__FreeBSD__) # include -#if defined(__FreeBSD_version) && (__FreeBSD_version >= 800000) && defined(_KERNEL) +#if defined(_KERNEL) #include #else #define CURVNET_SET(arg) From owner-svn-src-stable-12@freebsd.org Mon Jun 3 04:36:59 2019 Return-Path: Delivered-To: svn-src-stable-12@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 09A5B15C8417; Mon, 3 Jun 2019 04:36:59 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7573D8D564; Mon, 3 Jun 2019 04:36:58 +0000 (UTC) (envelope-from cy@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 4A3961164; Mon, 3 Jun 2019 04:36:58 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x534aw2x027848; Mon, 3 Jun 2019 04:36:58 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x534awH3027847; Mon, 3 Jun 2019 04:36:58 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201906030436.x534awH3027847@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Mon, 3 Jun 2019 04:36:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348523 - stable/12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-12 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: stable/12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 348523 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7573D8D564 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.95)[-0.949,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2019 04:36:59 -0000 Author: cy Date: Mon Jun 3 04:36:57 2019 New Revision: 348523 URL: https://svnweb.freebsd.org/changeset/base/348523 Log: MFC r348311: Fix indentation and while at it simplfy the code. Reported by: lwhsu@ Modified: stable/12/sys/contrib/ipfilter/netinet/fil.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/contrib/ipfilter/netinet/fil.c ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/fil.c Mon Jun 3 04:35:28 2019 (r348522) +++ stable/12/sys/contrib/ipfilter/netinet/fil.c Mon Jun 3 04:36:57 2019 (r348523) @@ -4982,16 +4982,16 @@ frrequest(softc, unit, req, data, set, makecopy) error = ipf_outobj(softc, data, fp, IPFOBJ_FRENTRY); if (error == 0) { - if ((f->fr_dsize != 0) && (uptr != NULL)) + if ((f->fr_dsize != 0) && (uptr != NULL)) { error = COPYOUT(f->fr_data, uptr, f->fr_dsize); - if (error != 0) { + if (error == 0) { + f->fr_hits = 0; + f->fr_bytes = 0; + } else { IPFERROR(28); error = EFAULT; } - if (error == 0) { - f->fr_hits = 0; - f->fr_bytes = 0; } } } From owner-svn-src-stable-12@freebsd.org Mon Jun 3 04:38:09 2019 Return-Path: Delivered-To: svn-src-stable-12@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 DDACE15C8483; Mon, 3 Jun 2019 04:38:08 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 525188D69E; Mon, 3 Jun 2019 04:38:08 +0000 (UTC) (envelope-from cy@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 2F4FC1165; Mon, 3 Jun 2019 04:38:08 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x534c8FX027941; Mon, 3 Jun 2019 04:38:08 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x534c8Ag027940; Mon, 3 Jun 2019 04:38:08 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201906030438.x534c8Ag027940@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Mon, 3 Jun 2019 04:38:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348524 - stable/12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-12 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: stable/12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 348524 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 525188D69E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.95)[-0.949,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2019 04:38:09 -0000 Author: cy Date: Mon Jun 3 04:38:07 2019 New Revision: 348524 URL: https://svnweb.freebsd.org/changeset/base/348524 Log: MFC r348312: style(9) Modified: stable/12/sys/contrib/ipfilter/netinet/fil.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/contrib/ipfilter/netinet/fil.c ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/fil.c Mon Jun 3 04:36:57 2019 (r348523) +++ stable/12/sys/contrib/ipfilter/netinet/fil.c Mon Jun 3 04:38:07 2019 (r348524) @@ -3913,7 +3913,7 @@ ipf_fixskip(listp, rp, addremove) for (fp = *listp; (fp != NULL) && (fp != rp); fp = fp->fr_next) rules++; - if (!fp) + if (fp == NULL) return; for (rn = 0, fp = *listp; fp && (fp != rp); fp = fp->fr_next, rn++) @@ -5006,7 +5006,7 @@ frrequest(softc, unit, req, data, set, makecopy) return error; } - if (!f) { + if (f == NULL) { /* * At the end of this, ftail must point to the place where the * new rule is to be saved/inserted/added. @@ -5052,7 +5052,7 @@ frrequest(softc, unit, req, data, set, makecopy) * Request to remove a rule. */ if (addrem == 1) { - if (!f) { + if (f == NULL) { IPFERROR(29); error = ESRCH; } else { From owner-svn-src-stable-12@freebsd.org Mon Jun 3 15:10:38 2019 Return-Path: Delivered-To: svn-src-stable-12@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 B767015B3F49; Mon, 3 Jun 2019 15:10:38 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5AB9484E41; Mon, 3 Jun 2019 15:10:38 +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 344557D1B; Mon, 3 Jun 2019 15:10:38 +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 x53FAcPv061552; Mon, 3 Jun 2019 15:10:38 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x53FAc56061551; Mon, 3 Jun 2019 15:10:38 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201906031510.x53FAc56061551@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 3 Jun 2019 15:10:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348531 - stable/12/sys/amd64/amd64 X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/amd64/amd64 X-SVN-Commit-Revision: 348531 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5AB9484E41 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.964,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2019 15:10:39 -0000 Author: kib Date: Mon Jun 3 15:10:37 2019 New Revision: 348531 URL: https://svnweb.freebsd.org/changeset/base/348531 Log: MFC r348306: Correct some inconsistencies in the earliest created kernel page tables which affect demotion. Modified: stable/12/sys/amd64/amd64/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/pmap.c ============================================================================== --- stable/12/sys/amd64/amd64/pmap.c Mon Jun 3 14:14:53 2019 (r348530) +++ stable/12/sys/amd64/amd64/pmap.c Mon Jun 3 15:10:37 2019 (r348531) @@ -964,7 +964,6 @@ static void create_pagetables(vm_paddr_t *firstaddr) { int i, j, ndm1g, nkpdpe, nkdmpde; - pt_entry_t *pt_p; pd_entry_t *pd_p; pdp_entry_t *pdp_p; pml4_entry_t *p4_p; @@ -1025,20 +1024,21 @@ create_pagetables(vm_paddr_t *firstaddr) KPTphys = allocpages(firstaddr, nkpt); KPDphys = allocpages(firstaddr, nkpdpe); - /* Fill in the underlying page table pages */ - /* XXX not fully used, underneath 2M pages */ - pt_p = (pt_entry_t *)KPTphys; - for (i = 0; ptoa(i) < *firstaddr; i++) - pt_p[i] = ptoa(i) | X86_PG_V | pg_g | bootaddr_rwx(ptoa(i)); - - /* Now map the page tables at their location within PTmap */ + /* + * Connect the zero-filled PT pages to their PD entries. This + * implicitly maps the PT pages at their correct locations within + * the PTmap. + */ pd_p = (pd_entry_t *)KPDphys; for (i = 0; i < nkpt; i++) pd_p[i] = (KPTphys + ptoa(i)) | X86_PG_RW | X86_PG_V; - /* Map from zero to end of allocations under 2M pages */ - /* This replaces some of the KPTphys entries above */ - for (i = 0; (i << PDRSHIFT) < *firstaddr; i++) + /* + * Map from physical address zero to the end of loader preallocated + * memory using 2MB pages. This replaces some of the PD entries + * created above. + */ + for (i = 0; (i << PDRSHIFT) < KERNend; i++) /* Preset PG_M and PG_A because demotion expects it. */ pd_p[i] = (i << PDRSHIFT) | X86_PG_V | PG_PS | pg_g | X86_PG_M | X86_PG_A | bootaddr_rwx(i << PDRSHIFT); @@ -1048,7 +1048,8 @@ create_pagetables(vm_paddr_t *firstaddr) * to record the physical blocks we've actually mapped into kernel * virtual address space. */ - *firstaddr = round_2mpage(*firstaddr); + if (*firstaddr < round_2mpage(KERNend)) + *firstaddr = round_2mpage(KERNend); /* And connect up the PD to the PDP (leaving room for L4 pages) */ pdp_p = (pdp_entry_t *)(KPDPphys + ptoa(KPML4I - KPML4BASE)); @@ -1155,7 +1156,10 @@ pmap_bootstrap(vm_paddr_t *firstaddr) */ vm_phys_add_seg(KPTphys, KPTphys + ptoa(nkpt)); - virtual_avail = (vm_offset_t) KERNBASE + *firstaddr; + /* + * Account for the virtual addresses mapped by create_pagetables(). + */ + virtual_avail = (vm_offset_t)KERNBASE + round_2mpage(KERNend); virtual_end = VM_MAX_KERNEL_ADDRESS; /* From owner-svn-src-stable-12@freebsd.org Mon Jun 3 15:28:38 2019 Return-Path: Delivered-To: svn-src-stable-12@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 929B515B49B1; Mon, 3 Jun 2019 15:28:38 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 31E05862B7; Mon, 3 Jun 2019 15:28:38 +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 055C88074; Mon, 3 Jun 2019 15:28:38 +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 x53FSbiE072390; Mon, 3 Jun 2019 15:28:37 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x53FSbvH072389; Mon, 3 Jun 2019 15:28:37 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201906031528.x53FSbvH072389@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 3 Jun 2019 15:28:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348538 - stable/12/lib/libjail X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/lib/libjail X-SVN-Commit-Revision: 348538 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 31E05862B7 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.96)[-0.962,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2019 15:28:38 -0000 Author: kevans Date: Mon Jun 3 15:28:37 2019 New Revision: 348538 URL: https://svnweb.freebsd.org/changeset/base/348538 Log: MFC r348509: jail_getid(3): add special-case immediate return for jid 0 As depicted in the comment: jid 0 always exists, but the lookup will fail as it does not appear in the kernel's alljails list being a special jail. Some callers will expect/rely on this, and we have no reason to lie because it does always exist. Approved by: re (early MFC) Modified: stable/12/lib/libjail/jail_getid.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libjail/jail_getid.c ============================================================================== --- stable/12/lib/libjail/jail_getid.c Mon Jun 3 15:25:12 2019 (r348537) +++ stable/12/lib/libjail/jail_getid.c Mon Jun 3 15:28:37 2019 (r348538) @@ -54,6 +54,15 @@ jail_getid(const char *name) jid = strtoul(name, &ep, 10); if (*name && !*ep) { + /* + * jid == 0 is a special case; it will not appear in the + * kernel's jail list, but naturally processes will be assigned + * to it because it is prison 0. Trivially return this one + * without a trip to the kernel, because it always exists but + * the lookup won't succeed. + */ + if (jid == 0) + return jid; jiov[0].iov_base = __DECONST(char *, "jid"); jiov[0].iov_len = sizeof("jid"); jiov[1].iov_base = &jid; From owner-svn-src-stable-12@freebsd.org Mon Jun 3 16:59:57 2019 Return-Path: Delivered-To: svn-src-stable-12@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 CA7F415B71D0; Mon, 3 Jun 2019 16:59:57 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 503FB8A58A; Mon, 3 Jun 2019 16:59:57 +0000 (UTC) (envelope-from markj@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 27B498F78; Mon, 3 Jun 2019 16:59:57 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x53GxvAE019990; Mon, 3 Jun 2019 16:59:57 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x53Gxu8I019988; Mon, 3 Jun 2019 16:59:56 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906031659.x53Gxu8I019988@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 3 Jun 2019 16:59:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348549 - stable/12/share/man/man9 X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/share/man/man9 X-SVN-Commit-Revision: 348549 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 503FB8A58A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.955,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2019 16:59:58 -0000 Author: markj Date: Mon Jun 3 16:59:56 2019 New Revision: 348549 URL: https://svnweb.freebsd.org/changeset/base/348549 Log: MFC r348003, r348011: Add a man page for DEFINE_IFUNC. Added: stable/12/share/man/man9/DEFINE_IFUNC.9 - copied unchanged from r348003, head/share/man/man9/DEFINE_IFUNC.9 Modified: stable/12/share/man/man9/Makefile Directory Properties: stable/12/ (props changed) Copied: stable/12/share/man/man9/DEFINE_IFUNC.9 (from r348003, head/share/man/man9/DEFINE_IFUNC.9) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/share/man/man9/DEFINE_IFUNC.9 Mon Jun 3 16:59:56 2019 (r348549, copy of r348003, head/share/man/man9/DEFINE_IFUNC.9) @@ -0,0 +1,143 @@ +.\" Copyright (c) 2019 The FreeBSD Foundation +.\" +.\" This documentation was written by Mark Johnston +.\" under sponsorship from the FreeBSD Foundation. +.\" +.\" 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$ +.\" +.Dd May 18, 2019 +.Dt DEFINE_IFUNC 9 +.Os +.Sh NAME +.Nm DEFINE_IFUNC +.Nd define a kernel function with an implementation selected at run-time +.Sh SYNOPSIS +.In machine/ifunc.h +.Fn DEFINE_IFUNC qual ret_type name args +.Sh DESCRIPTION +ifuncs are a linker feature which allows the programmer to define functions +whose implementation is selected at boot-time or module load-time. +The +.Nm +macro can be used to define an ifunc. +The selection is performed by a resolver function, which returns a pointer +to the selected function. +ifunc resolvers are invoked very early during the machine-dependent +initialization routine, or at load time for dynamically loaded modules. +Resolution must occur before the first call to an ifunc. +ifunc resolution is performed after CPU features are enumerated and after the +kernel's environment is initialized. +The typical use-case for an ifunc is a routine whose behavior depends on +optional CPU features. +For example, newer generations of a given CPU architecture may provide an +instruction to optimize a common operation. +To avoid the overhead of testing for the CPU feature each time the operation +is performed, an ifunc can be used to provide two implementations for the +operation: one targeting platforms with the extra instruction, and one +for older platforms. +.Pp +Because +.Nm +is a macro that defines a dynamically typed function, its usage looks somewhat +unusual. +The +.Ar qual +parameter is a list of zero or more C function qualifiers to be applied to the +ifunc. +This parameter is typically empty or the +.Dv static +qualifier. +.Ar ret_type +is the return type of the ifunc. +.Ar name +is the name of the ifunc. +.Ar args +is a parenthesized, comma-separated list of the parameter types of the function, +as they would appear in a C function declaration. +.Pp +The +.Nm +usage must be followed by the resolver function body. +The resolver must return a function with return type +.Ar ret_type +and parameter types +.Ar args . +The resolver function is defined with the +.Ql resolver +gcc-style function attribute, causing the corresponding +.Xr elf 5 +function symbol to be of type +.Dv STT_GNU_IFUNC +instead of +.Dv STT_FUNC . +The kernel linker invokes the resolver to process relocations targeting ifunc +calls and PLT entries referencing such symbols. +.Sh EXAMPLES +ifunc resolvers are executed early during boot, before most kernel facilities +are available. +They are effectively limited to checking CPU feature flags and tunables. +.Bd -literal +static size_t +fast_strlen(const char *s __unused) +{ + size_t len; + + /* Fast, but may not be correct in all cases. */ + __asm("movq $42,%0\\n" : "=r" (len)); + return (len); +} + +static size_t +slow_strlen(const char *s) +{ + const char *t; + + for (t = s; *t != '\\0'; t++); + return (t - s); +} + +DEFINE_IFUNC(, size_t, strlen, (const char *)) +{ + int enabled; + + enabled = 1; + TUNABLE_INT_FETCH("debug.use_fast_strlen", &enabled); + if (enabled && (cpu_features & CPUID_FAST_STRLEN) != 0) + return (fast_strlen); + else + return (slow_strlen); +} +.Ed +.Pp +This defines a +.Fn strlen +function with an optimized implementation for CPUs that advertise support. +.Sh SEE ALSO +.Xr elf 5 +.Sh NOTES +ifuncs are not supported on all architectures. +They require both toolchain support, to emit function symbols of type +.Dv STT_GNU_IFUNC , +and kernel linker support to invoke ifunc resolvers during boot or +during module load. Modified: stable/12/share/man/man9/Makefile ============================================================================== --- stable/12/share/man/man9/Makefile Mon Jun 3 16:57:06 2019 (r348548) +++ stable/12/share/man/man9/Makefile Mon Jun 3 16:59:56 2019 (r348549) @@ -75,6 +75,7 @@ MAN= accept_filter.9 \ DB_COMMAND.9 \ DECLARE_GEOM_CLASS.9 \ DECLARE_MODULE.9 \ + DEFINE_IFUNC.9 \ DELAY.9 \ devclass.9 \ devclass_find.9 \ From owner-svn-src-stable-12@freebsd.org Mon Jun 3 21:03:30 2019 Return-Path: Delivered-To: svn-src-stable-12@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 1195E15BE0A6; Mon, 3 Jun 2019 21:03:30 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AA5426FB85; Mon, 3 Jun 2019 21:03:29 +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 8737DB98E; Mon, 3 Jun 2019 21:03:29 +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 x53L3TQq055441; Mon, 3 Jun 2019 21:03:29 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x53L3SnL055434; Mon, 3 Jun 2019 21:03:28 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201906032103.x53L3SnL055434@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 3 Jun 2019 21:03:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348587 - in stable/12: lib/geom/eli sys/geom/eli tests/sys/geom/class/eli X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/12: lib/geom/eli sys/geom/eli tests/sys/geom/class/eli X-SVN-Commit-Revision: 348587 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: AA5426FB85 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.975,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2019 21:03:30 -0000 Author: jhb Date: Mon Jun 3 21:03:28 2019 New Revision: 348587 URL: https://svnweb.freebsd.org/changeset/base/348587 Log: MFC 348206,348231,348454: GELI crypto deprecation warnings. 348206: Add deprecation warnings for weaker algorithms to geli(4). - Triple DES has been formally deprecated in Kerberos (RFC 8429) and is soon to be deprecated in IPsec (RFC 8221). - Blowfish is deprecated. FreeBSD doesn't support its successor (Twofish). - MD5 is generally considered a weak digest that has known attacks. geli refuses to create new volumes using these algorithms via 'geli init'. It also warns when attaching to existing volumes or creating temporary volumes via 'geli onetime' . The plan is to fully remove support for these algorithms in FreeBSD 13. Note that none of these algorithms have ever been the default algorithm used by geli(8). Users would have had to explicitly select these algorithms when creating volumes in the past. 348231: Correct the argument passed to g_eli_algo2str() 348454: Remove tests for the deprecated algorithms in r348206 The tests are failing because the return value and output have changed, but before test code structure adjusted, removing these test cases help people be able to focus on more important cases. Relnotes: yes Modified: stable/12/lib/geom/eli/geli.8 stable/12/lib/geom/eli/geom_eli.c stable/12/sys/geom/eli/g_eli.c stable/12/tests/sys/geom/class/eli/conf.sh stable/12/tests/sys/geom/class/eli/init_test.sh Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/geom/eli/geli.8 ============================================================================== --- stable/12/lib/geom/eli/geli.8 Mon Jun 3 20:55:52 2019 (r348586) +++ stable/12/lib/geom/eli/geli.8 Mon Jun 3 21:03:28 2019 (r348587) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 24, 2018 +.Dd May 23, 2019 .Dt GELI 8 .Os .Sh NAME @@ -877,6 +877,18 @@ specified in .El .Sh EXIT STATUS Exit status is 0 on success, and 1 if the command fails. +.Sh DEPRECATION NOTICE +Support for the +.Nm Blowfish-CBC +and +.Nm 3DES-CBC +cryptographic algorithms and +.Nm HMAC/MD5 +authentication algorithm will be removed in +.Fx 13.0 . +New volumes cannot be created using these algorithms. +Existing volumes should be migrated to a new volume that uses +non-deprecated algorithms. .Sh EXAMPLES Initialize a provider which is going to be encrypted with a passphrase and random data from a file on the user's pen drive. @@ -1110,7 +1122,7 @@ utility appeared in .Fx 6.0 . Support for the .Nm Camellia -block cipher is implemented by Yoshisato Yanagisawa in +block cipher was implemented by Yoshisato Yanagisawa in .Fx 7.0 . .Pp Highest Modified: stable/12/lib/geom/eli/geom_eli.c ============================================================================== --- stable/12/lib/geom/eli/geom_eli.c Mon Jun 3 20:55:52 2019 (r348586) +++ stable/12/lib/geom/eli/geom_eli.c Mon Jun 3 21:03:28 2019 (r348587) @@ -797,6 +797,22 @@ eli_init(struct gctl_req *req) return; } } + if (md.md_flags & G_ELI_FLAG_AUTH) { + switch (md.md_aalgo) { + case CRYPTO_MD5_HMAC: + gctl_error(req, + "The %s authentication algorithm is deprecated.", + g_eli_algo2str(md.md_aalgo)); + return; + } + } + switch (md.md_ealgo) { + case CRYPTO_3DES_CBC: + case CRYPTO_BLF_CBC: + gctl_error(req, "The %s encryption algorithm is deprecated.", + g_eli_algo2str(md.md_ealgo)); + return; + } val = gctl_get_intmax(req, "keylen"); md.md_keylen = val; md.md_keylen = g_eli_keylen(md.md_ealgo, md.md_keylen); Modified: stable/12/sys/geom/eli/g_eli.c ============================================================================== --- stable/12/sys/geom/eli/g_eli.c Mon Jun 3 20:55:52 2019 (r348586) +++ stable/12/sys/geom/eli/g_eli.c Mon Jun 3 21:03:28 2019 (r348587) @@ -875,8 +875,25 @@ g_eli_create(struct gctl_req *req, struct g_class *mp, G_ELI_DEBUG(0, "Device %s created.", pp->name); G_ELI_DEBUG(0, "Encryption: %s %u", g_eli_algo2str(sc->sc_ealgo), sc->sc_ekeylen); - if (sc->sc_flags & G_ELI_FLAG_AUTH) + switch (sc->sc_ealgo) { + case CRYPTO_3DES_CBC: + gone_in(13, + "support for GEOM_ELI volumes encrypted with 3des"); + break; + case CRYPTO_BLF_CBC: + gone_in(13, + "support for GEOM_ELI volumes encrypted with blowfish"); + break; + } + if (sc->sc_flags & G_ELI_FLAG_AUTH) { G_ELI_DEBUG(0, " Integrity: %s", g_eli_algo2str(sc->sc_aalgo)); + switch (sc->sc_aalgo) { + case CRYPTO_MD5_HMAC: + gone_in(13, + "support for GEOM_ELI volumes authenticated with hmac/md5"); + break; + } + } G_ELI_DEBUG(0, " Crypto: %s", sc->sc_crypto == G_ELI_CRYPTO_SW ? "software" : "hardware"); return (gp); Modified: stable/12/tests/sys/geom/class/eli/conf.sh ============================================================================== --- stable/12/tests/sys/geom/class/eli/conf.sh Mon Jun 3 20:55:52 2019 (r348586) +++ stable/12/tests/sys/geom/class/eli/conf.sh Mon Jun 3 21:03:28 2019 (r348587) @@ -37,15 +37,10 @@ for_each_geli_config() { for cipher in aes-xts:128 aes-xts:256 \ aes-cbc:128 aes-cbc:192 aes-cbc:256 \ - 3des-cbc:192 \ - blowfish-cbc:128 blowfish-cbc:160 blowfish-cbc:192 \ - blowfish-cbc:224 blowfish-cbc:256 blowfish-cbc:288 \ - blowfish-cbc:320 blowfish-cbc:352 blowfish-cbc:384 \ - blowfish-cbc:416 blowfish-cbc:448 \ camellia-cbc:128 camellia-cbc:192 camellia-cbc:256; do ealgo=${cipher%%:*} keylen=${cipher##*:} - for aalgo in hmac/md5 hmac/sha1 hmac/ripemd160 hmac/sha256 \ + for aalgo in hmac/sha1 hmac/ripemd160 hmac/sha256 \ hmac/sha384 hmac/sha512; do for secsize in 512 1024 2048 4096 $MAX_SECSIZE; do ${func} $cipher $aalgo $secsize @@ -66,11 +61,6 @@ for_each_geli_config_nointegrity() { md=$(attach_md -t malloc -s $bytes) for cipher in aes-xts:128 aes-xts:256 \ aes-cbc:128 aes-cbc:192 aes-cbc:256 \ - 3des-cbc:192 \ - blowfish-cbc:128 blowfish-cbc:160 blowfish-cbc:192 \ - blowfish-cbc:224 blowfish-cbc:256 blowfish-cbc:288 \ - blowfish-cbc:320 blowfish-cbc:352 blowfish-cbc:384 \ - blowfish-cbc:416 blowfish-cbc:448 \ camellia-cbc:128 camellia-cbc:192 camellia-cbc:256; do ealgo=${cipher%%:*} keylen=${cipher##*:} Modified: stable/12/tests/sys/geom/class/eli/init_test.sh ============================================================================== --- stable/12/tests/sys/geom/class/eli/init_test.sh Mon Jun 3 20:55:52 2019 (r348586) +++ stable/12/tests/sys/geom/class/eli/init_test.sh Mon Jun 3 21:03:28 2019 (r348587) @@ -308,13 +308,6 @@ init_alias_body() atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none for spec in aes:0:AES-XTS:128 aes:128:AES-XTS:128 aes:256:AES-XTS:256 \ - 3des:0:3DES-CBC:192 3des:192:3DES-CBC:192 \ - blowfish:0:Blowfish-CBC:128 blowfish:128:Blowfish-CBC:128 \ - blowfish:160:Blowfish-CBC:160 blowfish:192:Blowfish-CBC:192 \ - blowfish:224:Blowfish-CBC:224 blowfish:256:Blowfish-CBC:256 \ - blowfish:288:Blowfish-CBC:288 blowfish:352:Blowfish-CBC:352 \ - blowfish:384:Blowfish-CBC:384 blowfish:416:Blowfish-CBC:416 \ - blowfish:448:Blowfish-CBC:448 \ camellia:0:CAMELLIA-CBC:128 camellia:128:CAMELLIA-CBC:128 \ camellia:256:CAMELLIA-CBC:256 ; do From owner-svn-src-stable-12@freebsd.org Tue Jun 4 01:00:31 2019 Return-Path: Delivered-To: svn-src-stable-12@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 37B4515C2CB3; Tue, 4 Jun 2019 01:00:31 +0000 (UTC) (envelope-from johalun@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CA8737772C; Tue, 4 Jun 2019 01:00:30 +0000 (UTC) (envelope-from johalun@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 AF985E21B; Tue, 4 Jun 2019 01:00:30 +0000 (UTC) (envelope-from johalun@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x5410U1p076482; Tue, 4 Jun 2019 01:00:30 GMT (envelope-from johalun@FreeBSD.org) Received: (from johalun@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x5410Ub5076481; Tue, 4 Jun 2019 01:00:30 GMT (envelope-from johalun@FreeBSD.org) Message-Id: <201906040100.x5410Ub5076481@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: johalun set sender to johalun@FreeBSD.org using -f From: Johannes Lundberg Date: Tue, 4 Jun 2019 01:00:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348597 - stable/12/sys/fs/pseudofs X-SVN-Group: stable-12 X-SVN-Commit-Author: johalun X-SVN-Commit-Paths: stable/12/sys/fs/pseudofs X-SVN-Commit-Revision: 348597 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: CA8737772C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.967,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 01:00:31 -0000 Author: johalun Date: Tue Jun 4 01:00:30 2019 New Revision: 348597 URL: https://svnweb.freebsd.org/changeset/base/348597 Log: MFC r348338: pseudofs: Ignore unsupported commands in vop_setattr. Users of pseudofs (e.g. lindebugfs), should be able to receive input from command line via commands like "echo 1 > /path/to/file". Currently this fails because sh tries to truncate the file first and vop_setattr returns not supported error for this. This patch simply ignores the error and returns 0 instead. Reviewed by: imp (mentor), asomers Approved by: imp (mentor), asomers Differential Revision: D20451 Modified: stable/12/sys/fs/pseudofs/pseudofs_vnops.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/pseudofs/pseudofs_vnops.c ============================================================================== --- stable/12/sys/fs/pseudofs/pseudofs_vnops.c Tue Jun 4 00:42:51 2019 (r348596) +++ stable/12/sys/fs/pseudofs/pseudofs_vnops.c Tue Jun 4 01:00:30 2019 (r348597) @@ -967,7 +967,8 @@ pfs_setattr(struct vop_setattr_args *va) PFS_TRACE(("%s", pn->pn_name)); pfs_assert_not_owned(pn); - PFS_RETURN (EOPNOTSUPP); + /* Silently ignore unchangeable attributes. */ + PFS_RETURN (0); } /* From owner-svn-src-stable-12@freebsd.org Tue Jun 4 03:04:32 2019 Return-Path: Delivered-To: svn-src-stable-12@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 02ED715C5FC9; Tue, 4 Jun 2019 03:04:32 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9609E838C6; Tue, 4 Jun 2019 03:04:31 +0000 (UTC) (envelope-from cy@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 576CEF900; Tue, 4 Jun 2019 03:04:31 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x5434VM4044482; Tue, 4 Jun 2019 03:04:31 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x5434UU4044480; Tue, 4 Jun 2019 03:04:30 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201906040304.x5434UU4044480@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Tue, 4 Jun 2019 03:04:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348600 - stable/12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-12 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: stable/12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 348600 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9609E838C6 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.963,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 03:04:32 -0000 Author: cy Date: Tue Jun 4 03:04:30 2019 New Revision: 348600 URL: https://svnweb.freebsd.org/changeset/base/348600 Log: MFC r348320: Contuation of r343701, removal of irrelevant #ifdefs. Modified: stable/12/sys/contrib/ipfilter/netinet/ip_frag.c stable/12/sys/contrib/ipfilter/netinet/ip_proxy.h stable/12/sys/contrib/ipfilter/netinet/ip_rules.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/contrib/ipfilter/netinet/ip_frag.c ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/ip_frag.c Tue Jun 4 02:37:11 2019 (r348599) +++ stable/12/sys/contrib/ipfilter/netinet/ip_frag.c Tue Jun 4 03:04:30 2019 (r348600) @@ -34,11 +34,11 @@ #include #if defined(_KERNEL) # include -# if !defined(__SVR4) && !defined(__svr4__) +# if !defined(__SVR4) # include # endif #endif -#if !defined(__SVR4) && !defined(__svr4__) +#if !defined(__SVR4) # if defined(_KERNEL) # include # endif Modified: stable/12/sys/contrib/ipfilter/netinet/ip_proxy.h ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/ip_proxy.h Tue Jun 4 02:37:11 2019 (r348599) +++ stable/12/sys/contrib/ipfilter/netinet/ip_proxy.h Tue Jun 4 03:04:30 2019 (r348600) @@ -13,14 +13,14 @@ #define __IP_PROXY_H__ #ifndef SOLARIS -# if defined(sun) && (defined(__svr4__) || defined(__SVR4)) +# if defined(sun) && defined(__SVR4)) # define SOLARIS 1 # else # define SOLARIS 0 # endif #endif -#if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51) +#if defined(__STDC__) || defined(__GNUC__) #define SIOCPROXY _IOWR('r', 64, struct ap_control) #else #define SIOCPROXY _IOWR(r, 64, struct ap_control) Modified: stable/12/sys/contrib/ipfilter/netinet/ip_rules.c ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/ip_rules.c Tue Jun 4 02:37:11 2019 (r348599) +++ stable/12/sys/contrib/ipfilter/netinet/ip_rules.c Tue Jun 4 03:04:30 2019 (r348600) @@ -12,22 +12,18 @@ #include #include #include -#if defined(__FreeBSD_version) && (__FreeBSD_version >= 40000) +#if defined(__FreeBSD_version) # if defined(_KERNEL) # include # else # include # endif -#endif -#if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 399000000) #else -# if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__sgi) -# include -# endif +# include #endif #include #include -#if !defined(__SVR4) && !defined(__svr4__) && !defined(__hpux) +#if !defined(__SVR4) # include #endif #if defined(__FreeBSD__) From owner-svn-src-stable-12@freebsd.org Tue Jun 4 10:21:02 2019 Return-Path: Delivered-To: svn-src-stable-12@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 8292B15AB054; Tue, 4 Jun 2019 10:21:02 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2F86690C6D; Tue, 4 Jun 2019 10:21:02 +0000 (UTC) (envelope-from mm@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 06BF41C1C1; Tue, 4 Jun 2019 10:21:02 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54AL1wa070398; Tue, 4 Jun 2019 10:21:01 GMT (envelope-from mm@FreeBSD.org) Received: (from mm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54AKuND070367; Tue, 4 Jun 2019 10:20:56 GMT (envelope-from mm@FreeBSD.org) Message-Id: <201906041020.x54AKuND070367@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mm set sender to mm@FreeBSD.org using -f From: Martin Matuska Date: Tue, 4 Jun 2019 10:20:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348605 - in stable/12: contrib/libarchive contrib/libarchive/cpio/test contrib/libarchive/libarchive contrib/libarchive/libarchive/test contrib/libarchive/tar contrib/libarchive/tar/te... X-SVN-Group: stable-12 X-SVN-Commit-Author: mm X-SVN-Commit-Paths: in stable/12: contrib/libarchive contrib/libarchive/cpio/test contrib/libarchive/libarchive contrib/libarchive/libarchive/test contrib/libarchive/tar contrib/libarchive/tar/test contrib/libarchive/tes... X-SVN-Commit-Revision: 348605 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2F86690C6D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.959,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 10:21:02 -0000 Author: mm Date: Tue Jun 4 10:20:56 2019 New Revision: 348605 URL: https://svnweb.freebsd.org/changeset/base/348605 Log: MFC r347990: Sync libarchive with vendor. Relevant vendor changes: Issue #795: XAR - do not try to add xattrs without an allocated name PR #812: non-recursive option for extract and list PR #958: support reading metadata from compressed files PR #999: add --exclude-vcs option to bsdtar Issue #1062: treat empty archives with a GNU volume header as valid PR #1074: Handle ZIP files with trailing 0s in the extra fields (Android APK archives) PR #1109: Ignore padding in Zip extra field data (Android APK archives) PR #1167: fix problems related to unreadable directories Issue #1168: fix handling of strtol() and strtoul() PR #1172: RAR5 - fix invalid window buffer read in E8E9 filter PR #1174: ZIP reader - fix of MSZIP signature parsing PR #1175: gzip filter - fix reading files larger than 4GB from memory PR #1177: gzip filter - fix memory leak with repeated header reads PR #1180: ZIP reader - add support for Info-ZIP Unicode Path Extra Field PR #1181: RAR5 - fix merge_block() recursion (OSS-Fuzz 12999, 13029, 13144, 13478, 13490) PR #1183: fix memory leak when decompressing ZIP files with LZMA PR #1184: fix RAR5 OSS-Fuzz issues 12466, 14490, 14491, 12817 OSS-Fuzz 12466: RAR5 - fix buffer overflow when parsing huffman tables OSS-Fuzz 14490, 14491: RAR5 - fix bad shift-left operations OSS-Fuzz 12817: RAR5 - handle a case with truncated huffman tables PR #1186: RAR5 - fix invalid type used for dictionary size mask (OSS-Fuzz 14537) PR #1187: RAR5 - fix integer overflow (OSS-Fuzz 14555) PR #1190: RAR5 - RAR5 don't try to unpack entries marked as directories (OSS-Fuzz 14574) PR #1196: RAR5 - fix a potential SIGSEGV on 32-bit builds OSS-Fuzz 2582: RAR - fix use after free if there is an invalid entry OSS-Fuzz 14331: RAR5 - fix maximum owner name length OSS-Fuzz 13965: RAR5 - use unsigned int for volume number + range check Additional RAR5 reader changes: - support symlinks, hardlinks, file owner, file group, versioned files - change ARCHIVE_FORMAT_RAR_V5 to 0x100000 - set correct mode for readonly directories - support readonly, hidden and system Windows file attributes Added: stable/12/contrib/libarchive/libarchive/archive_entry_misc.3 - copied unchanged from r347990, head/contrib/libarchive/libarchive/archive_entry_misc.3 stable/12/contrib/libarchive/libarchive/test/test_read_format_mtree_noprint.mtree.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_mtree_noprint.mtree.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_distance_overflow.rar.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_distance_overflow.rar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_extra_field_version.rar.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_extra_field_version.rar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_fileattr.rar.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_fileattr.rar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_hardlink.rar.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_hardlink.rar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_invalid_dict_reference.rar.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_invalid_dict_reference.rar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_leftshift1.rar.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_leftshift1.rar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_leftshift2.rar.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_leftshift2.rar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_nonempty_dir_stream.rar.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_nonempty_dir_stream.rar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_owner.rar.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_owner.rar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_readtables_overflow.rar.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_readtables_overflow.rar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_symlink.rar.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_symlink.rar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_truncated_huff.rar.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar5_truncated_huff.rar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_rar_ppmd_use_after_free.rar.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_rar_ppmd_use_after_free.rar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_raw.data.gz.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_raw.data.gz.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_tar_empty_with_gnulabel.c - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_tar_empty_with_gnulabel.c stable/12/contrib/libarchive/libarchive/test/test_read_format_tar_empty_with_gnulabel.tar.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_tar_empty_with_gnulabel.tar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_zip_7075_utf8_paths.c - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_zip_7075_utf8_paths.c stable/12/contrib/libarchive/libarchive/test/test_read_format_zip_7075_utf8_paths.zip.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_zip_7075_utf8_paths.zip.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_zip_extra_padding.c - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_zip_extra_padding.c stable/12/contrib/libarchive/libarchive/test/test_read_format_zip_extra_padding.zip.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_zip_extra_padding.zip.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_zip_lzma_alone_leak.zipx.uu - copied unchanged from r347990, head/contrib/libarchive/libarchive/test/test_read_format_zip_lzma_alone_leak.zipx.uu stable/12/contrib/libarchive/tar/test/test_option_exclude_vcs.c - copied unchanged from r347990, head/contrib/libarchive/tar/test/test_option_exclude_vcs.c Modified: stable/12/contrib/libarchive/NEWS stable/12/contrib/libarchive/cpio/test/test_basic.c stable/12/contrib/libarchive/cpio/test/test_format_newc.c stable/12/contrib/libarchive/cpio/test/test_gcpio_compat.c stable/12/contrib/libarchive/cpio/test/test_option_L_upper.c stable/12/contrib/libarchive/cpio/test/test_option_a.c stable/12/contrib/libarchive/cpio/test/test_option_c.c stable/12/contrib/libarchive/libarchive/archive.h stable/12/contrib/libarchive/libarchive/archive_entry.c stable/12/contrib/libarchive/libarchive/archive_entry.h stable/12/contrib/libarchive/libarchive/archive_entry_private.h stable/12/contrib/libarchive/libarchive/archive_hmac.c stable/12/contrib/libarchive/libarchive/archive_match.c stable/12/contrib/libarchive/libarchive/archive_platform.h stable/12/contrib/libarchive/libarchive/archive_read.c stable/12/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c stable/12/contrib/libarchive/libarchive/archive_read_disk_posix.c stable/12/contrib/libarchive/libarchive/archive_read_private.h stable/12/contrib/libarchive/libarchive/archive_read_set_format.c stable/12/contrib/libarchive/libarchive/archive_read_support_filter_gzip.c stable/12/contrib/libarchive/libarchive/archive_read_support_format_cab.c stable/12/contrib/libarchive/libarchive/archive_read_support_format_mtree.c stable/12/contrib/libarchive/libarchive/archive_read_support_format_rar.c stable/12/contrib/libarchive/libarchive/archive_read_support_format_rar5.c stable/12/contrib/libarchive/libarchive/archive_read_support_format_raw.c stable/12/contrib/libarchive/libarchive/archive_read_support_format_tar.c stable/12/contrib/libarchive/libarchive/archive_read_support_format_warc.c stable/12/contrib/libarchive/libarchive/archive_read_support_format_xar.c stable/12/contrib/libarchive/libarchive/archive_read_support_format_zip.c stable/12/contrib/libarchive/libarchive/archive_util.c stable/12/contrib/libarchive/libarchive/archive_write_add_filter_xz.c stable/12/contrib/libarchive/libarchive/archive_write_disk_posix.c stable/12/contrib/libarchive/libarchive/archive_write_set_format_pax.c stable/12/contrib/libarchive/libarchive/archive_write_set_format_xar.c stable/12/contrib/libarchive/libarchive/test/test_entry.c stable/12/contrib/libarchive/libarchive/test/test_fuzz.c stable/12/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c stable/12/contrib/libarchive/libarchive/test/test_read_extract.c stable/12/contrib/libarchive/libarchive/test/test_read_format_mtree.c stable/12/contrib/libarchive/libarchive/test/test_read_format_rar.c stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5.c stable/12/contrib/libarchive/libarchive/test/test_read_format_rar5_win32.rar.uu stable/12/contrib/libarchive/libarchive/test/test_read_format_raw.c stable/12/contrib/libarchive/libarchive/test/test_read_format_zip.c stable/12/contrib/libarchive/libarchive/test/test_sparse_basic.c stable/12/contrib/libarchive/libarchive/test/test_write_disk_symlink.c stable/12/contrib/libarchive/tar/bsdtar.1 stable/12/contrib/libarchive/tar/bsdtar.c stable/12/contrib/libarchive/tar/bsdtar.h stable/12/contrib/libarchive/tar/cmdline.c stable/12/contrib/libarchive/tar/test/test_basic.c stable/12/contrib/libarchive/tar/test/test_copy.c stable/12/contrib/libarchive/tar/test/test_option_C_mtree.c stable/12/contrib/libarchive/tar/test/test_option_H_upper.c stable/12/contrib/libarchive/tar/test/test_option_L_upper.c stable/12/contrib/libarchive/tar/test/test_option_U_upper.c stable/12/contrib/libarchive/tar/test/test_option_n.c stable/12/contrib/libarchive/tar/test/test_option_s.c stable/12/contrib/libarchive/tar/test/test_strip_components.c stable/12/contrib/libarchive/tar/test/test_symlink_dir.c stable/12/contrib/libarchive/test_utils/test_common.h stable/12/contrib/libarchive/test_utils/test_main.c stable/12/lib/libarchive/Makefile stable/12/lib/libarchive/tests/Makefile stable/12/usr.bin/tar/tests/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/contrib/libarchive/NEWS ============================================================================== --- stable/12/contrib/libarchive/NEWS Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/NEWS Tue Jun 4 10:20:56 2019 (r348605) @@ -1,3 +1,13 @@ +Apr 16, 2019: Support for non-recursive list and extract + +Apr 14, 2019: New tar option: --exclude-vcs + +Mar 27, 2019: Support for file and directory symlinks on Windows + +Mar 12, 2019: Important fixes for storing file attributes and flags + +Jan 20, 2019: Support for xz, lzma, ppmd8 and bzip2 compression in zip archives + Oct 06, 2018: RAR 5.0 reader Sep 03, 2018: libarchive 3.3.3 released Modified: stable/12/contrib/libarchive/cpio/test/test_basic.c ============================================================================== --- stable/12/contrib/libarchive/cpio/test/test_basic.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/cpio/test/test_basic.c Tue Jun 4 10:20:56 2019 (r348605) @@ -46,7 +46,7 @@ verify_files(const char *msg) /* Symlink */ if (canSymlink()) - assertIsSymlink("symlink", "file"); + assertIsSymlink("symlink", "file", 0); /* Another file with 1 link and different permissions. */ failure(msg); @@ -173,7 +173,7 @@ DEFINE_TEST(test_basic) /* Symlink to above file. */ if (canSymlink()) { - assertMakeSymlink("symlink", "file"); + assertMakeSymlink("symlink", "file", 0); fprintf(filelist, "symlink\n"); if (is_LargeInode("symlink")) { strncat(result, Modified: stable/12/contrib/libarchive/cpio/test/test_format_newc.c ============================================================================== --- stable/12/contrib/libarchive/cpio/test/test_format_newc.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/cpio/test/test_format_newc.c Tue Jun 4 10:20:56 2019 (r348605) @@ -114,7 +114,7 @@ DEFINE_TEST(test_format_newc) /* "symlink" */ if (canSymlink()) { - assertMakeSymlink("symlink", "file1"); + assertMakeSymlink("symlink", "file1", 0); fprintf(list, "symlink\n"); } @@ -233,7 +233,12 @@ DEFINE_TEST(test_format_newc) assert(is_hex(e, 110)); assertEqualMem(e + 0, "070701", 6); /* Magic */ assert(is_hex(e + 6, 8)); /* ino */ +#if defined(_WIN32) && !defined(CYGWIN) + /* Mode: Group members bits and others bits do not work. */ + assertEqualInt(0xa180, from_hex(e + 14, 8) & 0xffc0); +#else assertEqualInt(0xa1ff, from_hex(e + 14, 8)); /* Mode */ +#endif assertEqualInt(from_hex(e + 22, 8), uid); /* uid */ assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */ assertEqualMem(e + 38, "00000001", 8); /* nlink */ Modified: stable/12/contrib/libarchive/cpio/test/test_gcpio_compat.c ============================================================================== --- stable/12/contrib/libarchive/cpio/test/test_gcpio_compat.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/cpio/test/test_gcpio_compat.c Tue Jun 4 10:20:56 2019 (r348605) @@ -71,7 +71,7 @@ unpack_test(const char *from, const char *options, con /* Symlink */ if (canSymlink()) - assertIsSymlink("symlink", "file"); + assertIsSymlink("symlink", "file", 0); /* dir */ assertIsDir("dir", 0775); Modified: stable/12/contrib/libarchive/cpio/test/test_option_L_upper.c ============================================================================== --- stable/12/contrib/libarchive/cpio/test/test_option_L_upper.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/cpio/test/test_option_L_upper.c Tue Jun 4 10:20:56 2019 (r348605) @@ -30,8 +30,10 @@ __FBSDID("$FreeBSD$"); * tests won't run on Windows. */ #if defined(_WIN32) && !defined(__CYGWIN__) #define CAT "type" +#define SEP "\\" #else #define CAT "cat" +#define SEP "/" #endif DEFINE_TEST(test_option_L_upper) @@ -51,7 +53,7 @@ DEFINE_TEST(test_option_L_upper) fprintf(filelist, "file\n"); /* Symlink to above file. */ - assertMakeSymlink("symlink", "file"); + assertMakeSymlink("symlink", "file", 0); fprintf(filelist, "symlink\n"); fclose(filelist); @@ -61,7 +63,7 @@ DEFINE_TEST(test_option_L_upper) assertTextFileContents("1 block\n", "copy.err"); failure("Regular -p without -L should preserve symlinks."); - assertIsSymlink("copy/symlink", NULL); + assertIsSymlink("copy/symlink", NULL, 0); r = systemf(CAT " filelist | %s -pd -L copy-L >copy-L.out 2>copy-L.err", testprog); assertEqualInt(r, 0); @@ -77,13 +79,14 @@ DEFINE_TEST(test_option_L_upper) assertMakeDir("unpack", 0755); assertChdir("unpack"); - r = systemf(CAT " ../archive.out | %s -i >unpack.out 2>unpack.err", testprog); + r = systemf(CAT " .." SEP "archive.out | %s -i >unpack.out 2>unpack.err", testprog); + failure("Error invoking %s -i", testprog); assertEqualInt(r, 0); assertTextFileContents("1 block\n", "unpack.err"); assertChdir(".."); - assertIsSymlink("unpack/symlink", NULL); + assertIsSymlink("unpack/symlink", NULL, 0); r = systemf(CAT " filelist | %s -oL >archive-L.out 2>archive-L.err", testprog); failure("Error invoking %s -oL", testprog); @@ -92,7 +95,8 @@ DEFINE_TEST(test_option_L_upper) assertMakeDir("unpack-L", 0755); assertChdir("unpack-L"); - r = systemf(CAT " ../archive-L.out | %s -i >unpack-L.out 2>unpack-L.err", testprog); + r = systemf(CAT " .." SEP "archive-L.out | %s -i >unpack-L.out 2>unpack-L.err", testprog); + failure("Error invoking %s -i < archive-L.out", testprog); assertEqualInt(r, 0); assertTextFileContents("1 block\n", "unpack-L.err"); Modified: stable/12/contrib/libarchive/cpio/test/test_option_a.c ============================================================================== --- stable/12/contrib/libarchive/cpio/test/test_option_a.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/cpio/test/test_option_a.c Tue Jun 4 10:20:56 2019 (r348605) @@ -71,8 +71,13 @@ test_create(void) * #ifdef this section out. Most of the test below is * still valid. */ memset(×, 0, sizeof(times)); +#if defined(_WIN32) && !defined(CYGWIN) + times.actime = 86400; + times.modtime = 86400; +#else times.actime = 1; times.modtime = 3; +#endif assertEqualInt(0, utime(files[i].name, ×)); /* Record whatever atime the file ended up with. */ Modified: stable/12/contrib/libarchive/cpio/test/test_option_c.c ============================================================================== --- stable/12/contrib/libarchive/cpio/test/test_option_c.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/cpio/test/test_option_c.c Tue Jun 4 10:20:56 2019 (r348605) @@ -85,7 +85,7 @@ DEFINE_TEST(test_option_c) /* "symlink" */ if (canSymlink()) { - assertMakeSymlink("symlink", "file"); + assertMakeSymlink("symlink", "file", 0); fprintf(filelist, "symlink\n"); } Modified: stable/12/contrib/libarchive/libarchive/archive.h ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive.h Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive.h Tue Jun 4 10:20:56 2019 (r348605) @@ -338,9 +338,9 @@ typedef const char *archive_passphrase_callback(struct #define ARCHIVE_FORMAT_LHA 0xB0000 #define ARCHIVE_FORMAT_CAB 0xC0000 #define ARCHIVE_FORMAT_RAR 0xD0000 -#define ARCHIVE_FORMAT_RAR_V5 (ARCHIVE_FORMAT_RAR | 1) #define ARCHIVE_FORMAT_7ZIP 0xE0000 #define ARCHIVE_FORMAT_WARC 0xF0000 +#define ARCHIVE_FORMAT_RAR_V5 0x100000 /* * Codes returned by archive_read_format_capabilities(). @@ -1095,6 +1095,8 @@ __LA_DECL int archive_match_excluded(struct archive *, */ __LA_DECL int archive_match_path_excluded(struct archive *, struct archive_entry *); +/* Control recursive inclusion of directory content when directory is included. Default on. */ +__LA_DECL int archive_match_set_inclusion_recursion(struct archive *, int); /* Add exclusion pathname pattern. */ __LA_DECL int archive_match_exclude_pattern(struct archive *, const char *); __LA_DECL int archive_match_exclude_pattern_w(struct archive *, Modified: stable/12/contrib/libarchive/libarchive/archive_entry.c ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_entry.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_entry.c Tue Jun 4 10:20:56 2019 (r348605) @@ -168,6 +168,7 @@ archive_entry_clear(struct archive_entry *entry) archive_entry_xattr_clear(entry); archive_entry_sparse_clear(entry); free(entry->stat); + entry->ae_symlink_type = AE_SYMLINK_TYPE_UNDEFINED; memset(entry, 0, sizeof(*entry)); return entry; } @@ -202,6 +203,9 @@ archive_entry_clone(struct archive_entry *entry) entry2->ae_set = entry->ae_set; archive_mstring_copy(&entry2->ae_uname, &entry->ae_uname); + /* Copy symlink type */ + entry2->ae_symlink_type = entry->ae_symlink_type; + /* Copy encryption status */ entry2->encryption = entry->encryption; @@ -253,6 +257,7 @@ archive_entry_new2(struct archive *a) if (entry == NULL) return (NULL); entry->archive = a; + entry->ae_symlink_type = AE_SYMLINK_TYPE_UNDEFINED; return (entry); } @@ -675,6 +680,12 @@ archive_entry_symlink(struct archive_entry *entry) return (NULL); } +int +archive_entry_symlink_type(struct archive_entry *entry) +{ + return (entry->ae_symlink_type); +} + const char * archive_entry_symlink_utf8(struct archive_entry *entry) { @@ -1246,6 +1257,12 @@ archive_entry_set_symlink(struct archive_entry *entry, } void +archive_entry_set_symlink_type(struct archive_entry *entry, int type) +{ + entry->ae_symlink_type = type; +} + +void archive_entry_set_symlink_utf8(struct archive_entry *entry, const char *linkname) { archive_mstring_copy_utf8(&entry->ae_symlink, linkname); @@ -1749,6 +1766,10 @@ static const struct flag { { "nohidden", L"nohidden", UF_HIDDEN, 0}, { "nouhidden", L"nouhidden", UF_HIDDEN, 0}, #endif +#ifdef FILE_ATTRIBUTE_HIDDEN + { "nohidden", L"nohidden", FILE_ATTRIBUTE_HIDDEN, 0}, + { "nouhidden", L"nouhidden", FILE_ATTRIBUTE_HIDDEN, 0}, +#endif #ifdef UF_OFFLINE { "nooffline", L"nooffline", UF_OFFLINE, 0}, { "nouoffline", L"nouoffline", UF_OFFLINE, 0}, @@ -1758,6 +1779,11 @@ static const struct flag { { "nourdonly", L"nourdonly", UF_READONLY, 0}, { "noreadonly", L"noreadonly", UF_READONLY, 0}, #endif +#ifdef FILE_ATTRIBUTE_READONLY + { "nordonly", L"nordonly", FILE_ATTRIBUTE_READONLY, 0}, + { "nourdonly", L"nourdonly", FILE_ATTRIBUTE_READONLY, 0}, + { "noreadonly", L"noreadonly", FILE_ATTRIBUTE_READONLY, 0}, +#endif #ifdef UF_SPARSE { "nosparse", L"nosparse", UF_SPARSE, 0}, { "nousparse", L"nousparse", UF_SPARSE, 0}, @@ -1769,6 +1795,10 @@ static const struct flag { #ifdef UF_SYSTEM { "nosystem", L"nosystem", UF_SYSTEM, 0}, { "nousystem", L"nousystem", UF_SYSTEM, 0}, +#endif +#ifdef FILE_ATTRIBUTE_SYSTEM + { "nosystem", L"nosystem", FILE_ATTRIBUTE_SYSTEM, 0}, + { "nousystem", L"nousystem", FILE_ATTRIBUTE_SYSTEM, 0}, #endif #if defined(FS_UNRM_FL) /* 'u' */ { "noundel", L"noundel", FS_UNRM_FL, 0}, Modified: stable/12/contrib/libarchive/libarchive/archive_entry.h ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_entry.h Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_entry.h Tue Jun 4 10:20:56 2019 (r348605) @@ -191,6 +191,13 @@ struct archive_entry; #define AE_IFIFO ((__LA_MODE_T)0010000) /* + * Symlink types + */ +#define AE_SYMLINK_TYPE_UNDEFINED 0 +#define AE_SYMLINK_TYPE_FILE 1 +#define AE_SYMLINK_TYPE_DIRECTORY 2 + +/* * Basic object manipulation */ @@ -275,6 +282,7 @@ __LA_DECL int archive_entry_size_is_set(struct archi __LA_DECL const char *archive_entry_strmode(struct archive_entry *); __LA_DECL const char *archive_entry_symlink(struct archive_entry *); __LA_DECL const char *archive_entry_symlink_utf8(struct archive_entry *); +__LA_DECL int archive_entry_symlink_type(struct archive_entry *); __LA_DECL const wchar_t *archive_entry_symlink_w(struct archive_entry *); __LA_DECL la_int64_t archive_entry_uid(struct archive_entry *); __LA_DECL const char *archive_entry_uname(struct archive_entry *); @@ -350,6 +358,7 @@ __LA_DECL void archive_entry_unset_size(struct archive __LA_DECL void archive_entry_copy_sourcepath(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_sourcepath_w(struct archive_entry *, const wchar_t *); __LA_DECL void archive_entry_set_symlink(struct archive_entry *, const char *); +__LA_DECL void archive_entry_set_symlink_type(struct archive_entry *, int); __LA_DECL void archive_entry_set_symlink_utf8(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_symlink(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_symlink_w(struct archive_entry *, const wchar_t *); @@ -692,7 +701,6 @@ __LA_DECL void archive_entry_linkify(struct archive_en struct archive_entry **, struct archive_entry **); __LA_DECL struct archive_entry *archive_entry_partial_links( struct archive_entry_linkresolver *res, unsigned int *links); - #ifdef __cplusplus } #endif Copied: stable/12/contrib/libarchive/libarchive/archive_entry_misc.3 (from r347990, head/contrib/libarchive/libarchive/archive_entry_misc.3) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/contrib/libarchive/libarchive/archive_entry_misc.3 Tue Jun 4 10:20:56 2019 (r348605, copy of r347990, head/contrib/libarchive/libarchive/archive_entry_misc.3) @@ -0,0 +1,62 @@ +.\" Copyright (c) 2019 Martin Matuska +.\" 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. +.\" +.Dd April 15, 2019 +.Dt ARCHIVE_ENTRY_MISC 3 +.Os +.Sh NAME +.Nm archive_entry_symlink_type , +.Nm archive_entry_set_symlink_type +.Nd miscellaneous functions for manipulating properties of archive_entry. +.Sh LIBRARY +Streaming Archive Library (libarchive, -larchive) +.Sh SYNOPSIS +.In archive_entry.h +.Ft int +.Fn archive_entry_symlink_type "struct archive_entry *a" +.Ft void +.Fn archive_entry_set_symlink_type "struct archive_entry *a" "int" +.Sh DESCRIPTION +The function +.Fn archive_entry_symlink_type +returns and the function +.Fn archive_entry_set_symlink_type +sets the type of the symbolic link stored in an archive entry. These functions +have special meaning on operating systems that support multiple symbolic link +types (e.g. Microsoft Windows). +.Pp +Supported values are: +.Bl -tag -width "AE_SYMLINK_TYPE_DIRECTORY" -compact +.It AE_SYMLINK_TYPE_UNDEFINED +Symbolic link target type is not defined (default on unix systems) +.It AE_SYMLINK_TYPE_FILE +Symbolic link points to a file +.It AE_SYMLINK_TYPE_DIRECTORY +Symbolic link points to a directory +.El +.Sh SEE ALSO +.Xr archive_entry 3 , +.Xr archive_entry_paths 3 , +.Xr archive_entry_stat 3 , +.Xr libarchive 3 Modified: stable/12/contrib/libarchive/libarchive/archive_entry_private.h ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_entry_private.h Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_entry_private.h Tue Jun 4 10:20:56 2019 (r348605) @@ -176,6 +176,9 @@ struct archive_entry { /* Miscellaneous. */ char strmode[12]; + + /* Symlink type support */ + int ae_symlink_type; }; #endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */ Modified: stable/12/contrib/libarchive/libarchive/archive_hmac.c ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_hmac.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_hmac.c Tue Jun 4 10:20:56 2019 (r348605) @@ -83,6 +83,7 @@ __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx) static int __hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len) { +#pragma GCC diagnostic ignored "-Wcast-qual" BCRYPT_ALG_HANDLE hAlg; BCRYPT_HASH_HANDLE hHash; DWORD hash_len; Modified: stable/12/contrib/libarchive/libarchive/archive_match.c ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_match.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_match.c Tue Jun 4 10:20:56 2019 (r348605) @@ -93,6 +93,9 @@ struct archive_match { /* exclusion/inclusion set flag. */ int setflag; + /* Recursively include directory content? */ + int recursive_include; + /* * Matching filename patterns. */ @@ -223,6 +226,7 @@ archive_match_new(void) return (NULL); a->archive.magic = ARCHIVE_MATCH_MAGIC; a->archive.state = ARCHIVE_STATE_NEW; + a->recursive_include = 1; match_list_init(&(a->inclusions)); match_list_init(&(a->exclusions)); __archive_rb_tree_init(&(a->exclusion_tree), &rb_ops_mbs); @@ -471,6 +475,28 @@ archive_match_path_excluded(struct archive *_a, } /* + * When recursive inclusion of directory content is enabled, + * an inclusion pattern that matches a directory will also + * include everything beneath that directory. Enabled by default. + * + * For compatibility with GNU tar, exclusion patterns always + * match if a subset of the full patch matches (i.e., they are + * are not rooted at the beginning of the path) and thus there + * is no corresponding non-recursive exclusion mode. + */ +int +archive_match_set_inclusion_recursion(struct archive *_a, int enabled) +{ + struct archive_match *a; + + archive_check_magic(_a, ARCHIVE_MATCH_MAGIC, + ARCHIVE_STATE_NEW, "archive_match_set_inclusion_recursion"); + a = (struct archive_match *)_a; + a->recursive_include = enabled; + return (ARCHIVE_OK); +} + +/* * Utility functions to get statistic information for inclusion patterns. */ int @@ -781,7 +807,10 @@ static int match_path_inclusion(struct archive_match *a, struct match *m, int mbs, const void *pn) { - int flag = PATHMATCH_NO_ANCHOR_END; + /* Recursive operation requires only a prefix match. */ + int flag = a->recursive_include ? + PATHMATCH_NO_ANCHOR_END : + 0; int r; if (mbs) { @@ -1232,7 +1261,7 @@ set_timefilter_pathname_mbs(struct archive_match *a, i archive_set_error(&(a->archive), EINVAL, "pathname is empty"); return (ARCHIVE_FAILED); } - if (stat(path, &st) != 0) { + if (la_stat(path, &st) != 0) { archive_set_error(&(a->archive), errno, "Failed to stat()"); return (ARCHIVE_FAILED); } Modified: stable/12/contrib/libarchive/libarchive/archive_platform.h ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_platform.h Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_platform.h Tue Jun 4 10:20:56 2019 (r348605) @@ -69,6 +69,8 @@ * either Windows or Posix APIs. */ #if (defined(__WIN32__) || defined(_WIN32) || defined(__WIN32)) && !defined(__CYGWIN__) #include "archive_windows.h" +#else +#define la_stat(path,stref) stat(path,stref) #endif /* Modified: stable/12/contrib/libarchive/libarchive/archive_read.c ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_read.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_read.c Tue Jun 4 10:20:56 2019 (r348605) @@ -611,6 +611,15 @@ choose_filters(struct archive_read *a) return (ARCHIVE_FATAL); } +int +__archive_read_header(struct archive_read *a, struct archive_entry *entry) +{ + if (a->filter->read_header) + return a->filter->read_header(a->filter, entry); + else + return (ARCHIVE_OK); +} + /* * Read header of next entry. */ Modified: stable/12/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c Tue Jun 4 10:20:56 2019 (r348605) @@ -191,7 +191,7 @@ archive_read_disk_entry_from_file(struct archive *_a, } } else #endif - if (stat(path, &s) != 0) { + if (la_stat(path, &s) != 0) { archive_set_error(&a->archive, errno, "Can't stat %s", path); return (ARCHIVE_FAILED); Modified: stable/12/contrib/libarchive/libarchive/archive_read_disk_posix.c ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_read_disk_posix.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_read_disk_posix.c Tue Jun 4 10:20:56 2019 (r348605) @@ -909,7 +909,7 @@ next_entry(struct archive_read_disk *a, struct tree *t } } break; - } + } } while (lst == NULL); #ifdef __APPLE__ @@ -1295,10 +1295,23 @@ archive_read_disk_descend(struct archive *_a) if (t->visit_type != TREE_REGULAR || !t->descend) return (ARCHIVE_OK); + /* + * We must not treat the initial specified path as a physical dir, + * because if we do then we will try and ascend out of it by opening + * ".." which is (a) wrong and (b) causes spurious permissions errors + * if ".." is not readable by us. Instead, treat it as if it were a + * symlink. (This uses an extra fd, but it can only happen once at the + * top level of a traverse.) But we can't necessarily assume t->st is + * valid here (though t->lst is), which complicates the logic a + * little. + */ if (tree_current_is_physical_dir(t)) { tree_push(t, t->basename, t->current_filesystem_id, t->lst.st_dev, t->lst.st_ino, &t->restore_time); - t->stack->flags |= isDir; + if (t->stack->parent->parent != NULL) + t->stack->flags |= isDir; + else + t->stack->flags |= isDirLink; } else if (tree_current_is_dir(t)) { tree_push(t, t->basename, t->current_filesystem_id, t->st.st_dev, t->st.st_ino, &t->restore_time); @@ -2151,6 +2164,17 @@ tree_open(const char *path, int symlink_mode, int rest static struct tree * tree_reopen(struct tree *t, const char *path, int restore_time) { +#if defined(O_PATH) + /* Linux */ + const int o_flag = O_PATH; +#elif defined(O_SEARCH) + /* SunOS */ + const int o_flag = O_SEARCH; +#elif defined(O_EXEC) + /* FreeBSD */ + const int o_flag = O_EXEC; +#endif + t->flags = (restore_time != 0)?needsRestoreTimes:0; t->flags |= onInitialDir; t->visit_type = 0; @@ -2172,6 +2196,15 @@ tree_reopen(struct tree *t, const char *path, int rest t->stack->flags = needsFirstVisit; t->maxOpenCount = t->openCount = 1; t->initial_dir_fd = open(".", O_RDONLY | O_CLOEXEC); +#if defined(O_PATH) || defined(O_SEARCH) || defined(O_EXEC) + /* + * Most likely reason to fail opening "." is that it's not readable, + * so try again for execute. The consequences of not opening this are + * unhelpful and unnecessary errors later. + */ + if (t->initial_dir_fd < 0) + t->initial_dir_fd = open(".", o_flag | O_CLOEXEC); +#endif __archive_ensure_cloexec_flag(t->initial_dir_fd); t->working_dir_fd = tree_dup(t->initial_dir_fd); return (t); @@ -2479,7 +2512,7 @@ tree_current_stat(struct tree *t) #else if (tree_enter_working_dir(t) != 0) return NULL; - if (stat(tree_current_access_path(t), &t->st) != 0) + if (la_stat(tree_current_access_path(t), &t->st) != 0) #endif return NULL; t->flags |= hasStat; Modified: stable/12/contrib/libarchive/libarchive/archive_read_private.h ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_read_private.h Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_read_private.h Tue Jun 4 10:20:56 2019 (r348605) @@ -98,6 +98,8 @@ struct archive_read_filter { int (*close)(struct archive_read_filter *self); /* Function that handles switching from reading one block to the next/prev */ int (*sswitch)(struct archive_read_filter *self, unsigned int iindex); + /* Read any header metadata if available. */ + int (*read_header)(struct archive_read_filter *self, struct archive_entry *entry); /* My private data. */ void *data; @@ -250,6 +252,7 @@ int64_t __archive_read_seek(struct archive_read*, int6 int64_t __archive_read_filter_seek(struct archive_read_filter *, int64_t, int); int64_t __archive_read_consume(struct archive_read *, int64_t); int64_t __archive_read_filter_consume(struct archive_read_filter *, int64_t); +int __archive_read_header(struct archive_read *, struct archive_entry *); int __archive_read_program(struct archive_read_filter *, const char *); void __archive_read_free_filters(struct archive_read *); struct archive_read_extract *__archive_read_get_extract(struct archive_read *); Modified: stable/12/contrib/libarchive/libarchive/archive_read_set_format.c ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_read_set_format.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_read_set_format.c Tue Jun 4 10:20:56 2019 (r348605) @@ -73,6 +73,9 @@ archive_read_set_format(struct archive *_a, int code) case ARCHIVE_FORMAT_RAR: strcpy(str, "rar"); break; + case ARCHIVE_FORMAT_RAR_V5: + strcpy(str, "rar5"); + break; case ARCHIVE_FORMAT_TAR: strcpy(str, "tar"); break; Modified: stable/12/contrib/libarchive/libarchive/archive_read_support_filter_gzip.c ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_read_support_filter_gzip.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_read_support_filter_gzip.c Tue Jun 4 10:20:56 2019 (r348605) @@ -37,6 +37,9 @@ __FBSDID("$FreeBSD$"); #ifdef HAVE_STRING_H #include #endif +#ifdef HAVE_LIMITS_H +#include +#endif #ifdef HAVE_UNISTD_H #include #endif @@ -45,6 +48,8 @@ __FBSDID("$FreeBSD$"); #endif #include "archive.h" +#include "archive_entry.h" +#include "archive_endian.h" #include "archive_private.h" #include "archive_read_private.h" @@ -56,6 +61,8 @@ struct private_data { size_t out_block_size; int64_t total_out; unsigned long crc; + uint32_t mtime; + char *name; char eof; /* True = found end of compressed data. */ }; @@ -123,7 +130,8 @@ archive_read_support_filter_gzip(struct archive *_a) * count of bits verified, suitable for use by bidder. */ static ssize_t -peek_at_header(struct archive_read_filter *filter, int *pbits) +peek_at_header(struct archive_read_filter *filter, int *pbits, + struct private_data *state) { const unsigned char *p; ssize_t avail, len; @@ -144,7 +152,9 @@ peek_at_header(struct archive_read_filter *filter, int return (0); bits += 3; header_flags = p[3]; - /* Bytes 4-7 are mod time. */ + /* Bytes 4-7 are mod time in little endian. */ + if (state) + state->mtime = archive_le32dec(p + 4); /* Byte 8 is deflate flags. */ /* XXXX TODO: return deflate flags back to consume_header for use in initializing the decompressor. */ @@ -161,6 +171,7 @@ peek_at_header(struct archive_read_filter *filter, int /* Null-terminated optional filename. */ if (header_flags & 8) { + ssize_t file_start = len; do { ++len; if (avail < len) @@ -169,6 +180,12 @@ peek_at_header(struct archive_read_filter *filter, int if (p == NULL) return (0); } while (p[len - 1] != 0); + + if (state) { + /* Reset the name in case of repeat header reads. */ + free(state->name); + state->name = strdup((const char *)&p[file_start]); + } } /* Null-terminated optional comment. */ @@ -214,12 +231,29 @@ gzip_bidder_bid(struct archive_read_filter_bidder *sel (void)self; /* UNUSED */ - if (peek_at_header(filter, &bits_checked)) + if (peek_at_header(filter, &bits_checked, NULL)) return (bits_checked); return (0); } +static int +gzip_read_header(struct archive_read_filter *self, struct archive_entry *entry) +{ + struct private_data *state; + state = (struct private_data *)self->data; + + /* A mtime of 0 is considered invalid/missing. */ + if (state->mtime != 0) + archive_entry_set_mtime(entry, state->mtime, 0); + + /* If the name is available, extract it. */ + if (state->name) + archive_entry_set_pathname(entry, state->name); + + return (ARCHIVE_OK); +} + #ifndef HAVE_ZLIB_H /* @@ -272,6 +306,7 @@ gzip_bidder_init(struct archive_read_filter *self) self->read = gzip_filter_read; self->skip = NULL; /* not supported */ self->close = gzip_filter_close; + self->read_header = gzip_read_header; state->in_stream = 0; /* We're not actually within a stream yet. */ @@ -289,7 +324,7 @@ consume_header(struct archive_read_filter *self) state = (struct private_data *)self->data; /* If this is a real header, consume it. */ - len = peek_at_header(self->upstream, NULL); + len = peek_at_header(self->upstream, NULL, state); if (len == 0) return (ARCHIVE_EOF); __archive_read_filter_consume(self->upstream, len); @@ -374,7 +409,7 @@ gzip_filter_read(struct archive_read_filter *self, con { struct private_data *state; size_t decompressed; - ssize_t avail_in; + ssize_t avail_in, max_in; int ret; state = (struct private_data *)self->data; @@ -408,6 +443,12 @@ gzip_filter_read(struct archive_read_filter *self, con "truncated gzip input"); return (ARCHIVE_FATAL); } + if (UINT_MAX >= SSIZE_MAX) + max_in = SSIZE_MAX; + else + max_in = UINT_MAX; + if (avail_in > max_in) + avail_in = max_in; state->stream.avail_in = (uInt)avail_in; /* Decompress and consume some of that data. */ @@ -469,6 +510,7 @@ gzip_filter_close(struct archive_read_filter *self) } } + free(state->name); free(state->out_block); free(state); return (ret); Modified: stable/12/contrib/libarchive/libarchive/archive_read_support_format_cab.c ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_read_support_format_cab.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_read_support_format_cab.c Tue Jun 4 10:20:56 2019 (r348605) @@ -1509,8 +1509,8 @@ cab_read_ahead_cfdata_deflate(struct archive_read *a, } if (mszip == 1 && cab->stream.next_in[0] != 0x4b) goto nomszip; - else if (cab->stream.next_in[0] != 0x43 || - cab->stream.next_in[1] != 0x4b) + else if (mszip == 2 && (cab->stream.next_in[0] != 0x43 || + cab->stream.next_in[1] != 0x4b)) goto nomszip; cab->stream.next_in += mszip; cab->stream.avail_in -= mszip; Modified: stable/12/contrib/libarchive/libarchive/archive_read_support_format_mtree.c ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_read_support_format_mtree.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_read_support_format_mtree.c Tue Jun 4 10:20:56 2019 (r348605) @@ -45,6 +45,9 @@ __FBSDID("$FreeBSD$"); #ifdef HAVE_STRING_H #include #endif +#ifdef HAVE_CTYPE_H +#include +#endif #include "archive.h" #include "archive_entry.h" @@ -1011,7 +1014,7 @@ read_mtree(struct archive_read *a, struct mtree *mtree { ssize_t len; uintmax_t counter; - char *p; + char *p, *s; struct mtree_option *global; struct mtree_entry *last_entry; int r, is_form_d; @@ -1025,6 +1028,7 @@ read_mtree(struct archive_read *a, struct mtree *mtree (void)detect_form(a, &is_form_d); for (counter = 1; ; ++counter) { + r = ARCHIVE_OK; len = readline(a, mtree, &p, 65536); if (len == 0) { mtree->this_entry = mtree->entries; @@ -1045,6 +1049,15 @@ read_mtree(struct archive_read *a, struct mtree *mtree continue; if (*p == '\r' || *p == '\n' || *p == '\0') continue; + /* Non-printable characters are not allowed */ + for (s = p;s < p + len - 1; s++) { + if (!isprint(*s)) { + r = ARCHIVE_FATAL; + break; + } + } + if (r != ARCHIVE_OK) + break; if (*p != '/') { r = process_add_entry(a, mtree, &global, p, len, &last_entry, is_form_d); Modified: stable/12/contrib/libarchive/libarchive/archive_read_support_format_rar.c ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_read_support_format_rar.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_read_support_format_rar.c Tue Jun 4 10:20:56 2019 (r348605) @@ -1024,8 +1024,10 @@ archive_read_format_rar_read_data(struct archive_read case COMPRESS_METHOD_GOOD: case COMPRESS_METHOD_BEST: ret = read_data_compressed(a, buff, size, offset); - if (ret != ARCHIVE_OK && ret != ARCHIVE_WARN) + if (ret != ARCHIVE_OK && ret != ARCHIVE_WARN) { __archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context); + rar->start_new_table = 1; + } break; default: Modified: stable/12/contrib/libarchive/libarchive/archive_read_support_format_rar5.c ============================================================================== --- stable/12/contrib/libarchive/libarchive/archive_read_support_format_rar5.c Tue Jun 4 09:01:02 2019 (r348604) +++ stable/12/contrib/libarchive/libarchive/archive_read_support_format_rar5.c Tue Jun 4 10:20:56 2019 (r348605) @@ -33,6 +33,9 @@ #ifdef HAVE_ZLIB_H #include /* crc32 */ #endif +#ifdef HAVE_LIMITS_H +#include +#endif #include "archive.h" #ifndef HAVE_ZLIB_H @@ -78,230 +81,275 @@ static unsigned char rar5_signature[] = { 243, 192, 211, 128, 187, 166, 160, 161 }; static const ssize_t rar5_signature_size = sizeof(rar5_signature); -/* static const size_t g_unpack_buf_chunk_size = 1024; */ static const size_t g_unpack_window_size = 0x20000; +/* These could have been static const's, but they aren't, because of + * Visual Studio. */ +#define MAX_NAME_IN_CHARS 2048 +#define MAX_NAME_IN_BYTES (4 * MAX_NAME_IN_CHARS) + struct file_header { - ssize_t bytes_remaining; - ssize_t unpacked_size; - int64_t last_offset; /* Used in sanity checks. */ - int64_t last_size; /* Used in sanity checks. */ + ssize_t bytes_remaining; + ssize_t unpacked_size; + int64_t last_offset; /* Used in sanity checks. */ + int64_t last_size; /* Used in sanity checks. */ - uint8_t solid : 1; /* Is this a solid stream? */ - uint8_t service : 1; /* Is this file a service data? */ - uint8_t eof : 1; /* Did we finish unpacking the file? */ + uint8_t solid : 1; /* Is this a solid stream? */ + uint8_t service : 1; /* Is this file a service data? */ + uint8_t eof : 1; /* Did we finish unpacking the file? */ + uint8_t dir : 1; /* Is this file entry a directory? */ - /* Optional time fields. */ - uint64_t e_mtime; - uint64_t e_ctime; - uint64_t e_atime; - uint32_t e_unix_ns; + /* Optional time fields. */ + uint64_t e_mtime; + uint64_t e_ctime; + uint64_t e_atime; + uint32_t e_unix_ns; - /* Optional hash fields. */ - uint32_t stored_crc32; - uint32_t calculated_crc32; - uint8_t blake2sp[32]; - blake2sp_state b2state; - char has_blake2; + /* Optional hash fields. */ + uint32_t stored_crc32; + uint32_t calculated_crc32; + uint8_t blake2sp[32]; + blake2sp_state b2state; + char has_blake2; + + /* Optional redir fields */ + uint64_t redir_type; + uint64_t redir_flags; }; +enum EXTRA { + EX_CRYPT = 0x01, + EX_HASH = 0x02, + EX_HTIME = 0x03, + EX_VERSION = 0x04, + EX_REDIR = 0x05, + EX_UOWNER = 0x06, + EX_SUBDATA = 0x07 +}; + +#define REDIR_SYMLINK_IS_DIR 1 + +enum REDIR_TYPE { + REDIR_TYPE_NONE = 0, + REDIR_TYPE_UNIXSYMLINK = 1, + REDIR_TYPE_WINSYMLINK = 2, + REDIR_TYPE_JUNCTION = 3, + REDIR_TYPE_HARDLINK = 4, + REDIR_TYPE_FILECOPY = 5, +}; + +#define OWNER_USER_NAME 0x01 +#define OWNER_GROUP_NAME 0x02 +#define OWNER_USER_UID 0x04 +#define OWNER_GROUP_GID 0x08 +#define OWNER_MAXNAMELEN 256 + enum FILTER_TYPE { - FILTER_DELTA = 0, /* Generic pattern. */ - FILTER_E8 = 1, /* Intel x86 code. */ - FILTER_E8E9 = 2, /* Intel x86 code. */ - FILTER_ARM = 3, /* ARM code. */ - FILTER_AUDIO = 4, /* Audio filter, not used in RARv5. */ - FILTER_RGB = 5, /* Color palette, not used in RARv5. */ - FILTER_ITANIUM = 6, /* Intel's Itanium, not used in RARv5. */ - FILTER_PPM = 7, /* Predictive pattern matching, not used in RARv5. */ - FILTER_NONE = 8, + FILTER_DELTA = 0, /* Generic pattern. */ + FILTER_E8 = 1, /* Intel x86 code. */ + FILTER_E8E9 = 2, /* Intel x86 code. */ + FILTER_ARM = 3, /* ARM code. */ + FILTER_AUDIO = 4, /* Audio filter, not used in RARv5. */ + FILTER_RGB = 5, /* Color palette, not used in RARv5. */ + FILTER_ITANIUM = 6, /* Intel's Itanium, not used in RARv5. */ + FILTER_PPM = 7, /* Predictive pattern matching, not used in + RARv5. */ + FILTER_NONE = 8, }; struct filter_info { - int type; - int channels; - int pos_r; + int type; + int channels; + int pos_r; - int64_t block_start; - ssize_t block_length; - uint16_t width; + int64_t block_start; + ssize_t block_length; + uint16_t width; }; struct data_ready { - char used; - const uint8_t* buf; - size_t size; - int64_t offset; + char used; + const uint8_t* buf; + size_t size; + int64_t offset; }; struct cdeque { - uint16_t beg_pos; - uint16_t end_pos; - uint16_t cap_mask; - uint16_t size; - size_t* arr; + uint16_t beg_pos; + uint16_t end_pos; + uint16_t cap_mask; + uint16_t size; + size_t* arr; }; struct decode_table { - uint32_t size; - int32_t decode_len[16]; - uint32_t decode_pos[16]; - uint32_t quick_bits; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Tue Jun 4 10:28:51 2019 Return-Path: Delivered-To: svn-src-stable-12@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 2295515AB217; Tue, 4 Jun 2019 10:28:51 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BC33491198; Tue, 4 Jun 2019 10:28:50 +0000 (UTC) (envelope-from mm@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 9783F1C33F; Tue, 4 Jun 2019 10:28:50 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54ASoxe075647; Tue, 4 Jun 2019 10:28:50 GMT (envelope-from mm@FreeBSD.org) Received: (from mm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54ASocQ075646; Tue, 4 Jun 2019 10:28:50 GMT (envelope-from mm@FreeBSD.org) Message-Id: <201906041028.x54ASocQ075646@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mm set sender to mm@FreeBSD.org using -f From: Martin Matuska Date: Tue, 4 Jun 2019 10:28:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348606 - stable/12/lib/libarchive/tests X-SVN-Group: stable-12 X-SVN-Commit-Author: mm X-SVN-Commit-Paths: stable/12/lib/libarchive/tests X-SVN-Commit-Revision: 348606 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: BC33491198 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.96)[-0.958,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 10:28:51 -0000 Author: mm Date: Tue Jun 4 10:28:50 2019 New Revision: 348606 URL: https://svnweb.freebsd.org/changeset/base/348606 Log: MFC r347999: Install missing data file for lib.libarchive.functional_test.test_read_format_zip_utf8_paths Modified: stable/12/lib/libarchive/tests/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libarchive/tests/Makefile ============================================================================== --- stable/12/lib/libarchive/tests/Makefile Tue Jun 4 10:20:56 2019 (r348605) +++ stable/12/lib/libarchive/tests/Makefile Tue Jun 4 10:28:50 2019 (r348606) @@ -557,6 +557,7 @@ ${PACKAGE}FILES+= test_read_format_ustar_filename_eucj ${PACKAGE}FILES+= test_read_format_ustar_filename_koi8r.tar.Z.uu ${PACKAGE}FILES+= test_read_format_warc.warc.uu ${PACKAGE}FILES+= test_read_format_zip.zip.uu +${PACKAGE}FILES+= test_read_format_zip_7075_utf8_paths.zip.uu ${PACKAGE}FILES+= test_read_format_zip_bz2_hang.zip.uu ${PACKAGE}FILES+= test_read_format_zip_bzip2.zipx.uu ${PACKAGE}FILES+= test_read_format_zip_bzip2_multi.zipx.uu From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:11:15 2019 Return-Path: Delivered-To: svn-src-stable-12@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 9CDD015B386B; Tue, 4 Jun 2019 15:11:15 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 41BAE6CF8D; Tue, 4 Jun 2019 15:11:15 +0000 (UTC) (envelope-from br@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 1DA731F2AE; Tue, 4 Jun 2019 15:11:15 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FBEoS024907; Tue, 4 Jun 2019 15:11:15 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FBExp024906; Tue, 4 Jun 2019 15:11:14 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041511.x54FBExp024906@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:11:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348613 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348613 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 41BAE6CF8D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.938,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:11:16 -0000 Author: br Date: Tue Jun 4 15:11:14 2019 New Revision: 348613 URL: https://svnweb.freebsd.org/changeset/base/348613 Log: MFC 339774: o Add pmap lock around pmap_fault_fixup() to ensure other thread will not modify l3 pte after we loaded old value and before we stored new value. o Preset A(accessed), D(dirty) bits for kernel mappings. Sponsored by: DARPA, AFRL Modified: stable/12/sys/riscv/riscv/pmap.c Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 13:45:30 2019 (r348612) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 15:11:14 2019 (r348613) @@ -1923,16 +1923,21 @@ pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_ pt_entry_t orig_l3; pt_entry_t new_l3; pt_entry_t *l3; + int rv; + rv = 0; + + PMAP_LOCK(pmap); + l3 = pmap_l3(pmap, va); if (l3 == NULL) - return (0); + goto done; orig_l3 = pmap_load(l3); if ((orig_l3 & PTE_V) == 0 || ((prot & VM_PROT_WRITE) != 0 && (orig_l3 & PTE_W) == 0) || ((prot & VM_PROT_READ) != 0 && (orig_l3 & PTE_R) == 0)) - return (0); + goto done; new_l3 = orig_l3 | PTE_A; if ((prot & VM_PROT_WRITE) != 0) @@ -1941,7 +1946,8 @@ pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_ if (orig_l3 != new_l3) { pmap_load_store(l3, new_l3); pmap_invalidate_page(pmap, va); - return (1); + rv = 1; + goto done; } /* @@ -1949,7 +1955,10 @@ pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_ * the PTE shouldn't have resulted in a fault. */ - return (0); +done: + PMAP_UNLOCK(pmap); + + return (rv); } /* @@ -1992,6 +2001,8 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, v new_l3 |= PTE_W; if ((va >> 63) == 0) new_l3 |= PTE_U; + else + new_l3 |= PTE_A | PTE_D; new_l3 |= (pn << PTE_PPN0_S); if ((flags & PMAP_ENTER_WIRED) != 0) From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:13:49 2019 Return-Path: Delivered-To: svn-src-stable-12@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 A85DF15B3B85; Tue, 4 Jun 2019 15:13:49 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4EB036D401; Tue, 4 Jun 2019 15:13:49 +0000 (UTC) (envelope-from br@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 2947F1F426; Tue, 4 Jun 2019 15:13:49 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FDntt027552; Tue, 4 Jun 2019 15:13:49 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FDnaA027551; Tue, 4 Jun 2019 15:13:49 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041513.x54FDnaA027551@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:13:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348614 - stable/12/sys/conf X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: stable/12/sys/conf X-SVN-Commit-Revision: 348614 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4EB036D401 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.938,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:13:49 -0000 Author: br Date: Tue Jun 4 15:13:48 2019 New Revision: 348614 URL: https://svnweb.freebsd.org/changeset/base/348614 Log: MFC r344252: Avoid orphan sections between __bss_start and .(s)bss. Ensure __bss_start is associated with the next section in case orphan sections are placed directly after .sdata, as has been seen to happen with LLD. Sponsored by: DARPA, AFRL Modified: stable/12/sys/conf/ldscript.riscv Modified: stable/12/sys/conf/ldscript.riscv ============================================================================== --- stable/12/sys/conf/ldscript.riscv Tue Jun 4 15:11:14 2019 (r348613) +++ stable/12/sys/conf/ldscript.riscv Tue Jun 4 15:13:48 2019 (r348614) @@ -87,6 +87,10 @@ SECTIONS .sdata : { *(.sdata) } _edata = .; PROVIDE (edata = .); + /* Ensure __bss_start is associated with the next section in case orphan + sections are placed directly after .sdata, as has been seen to happen with + LLD. */ + . = .; __bss_start = .; .sbss : { *(.sbss) *(.scommon) } .bss : From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:15:39 2019 Return-Path: Delivered-To: svn-src-stable-12@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 E4AF715B3CD4; Tue, 4 Jun 2019 15:15:38 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8AE866D5D4; Tue, 4 Jun 2019 15:15:38 +0000 (UTC) (envelope-from br@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 632281F428; Tue, 4 Jun 2019 15:15:38 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FFcqV027702; Tue, 4 Jun 2019 15:15:38 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FFcjm027701; Tue, 4 Jun 2019 15:15:38 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041515.x54FFcjm027701@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:15:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348615 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348615 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8AE866D5D4 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.938,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:15:39 -0000 Author: br Date: Tue Jun 4 15:15:37 2019 New Revision: 348615 URL: https://svnweb.freebsd.org/changeset/base/348615 Log: MFC r345581: Grab timer frequency from FDT. RISC-V timer has no dedicated DTS node and we have to get timer frequency from cpus node. Tested on Government Furnished Equipment (GFE) cores synthesized on Xilinx VCU118. Sponsored by: DARPA, AFRL Modified: stable/12/sys/riscv/riscv/timer.c Modified: stable/12/sys/riscv/riscv/timer.c ============================================================================== --- stable/12/sys/riscv/riscv/timer.c Tue Jun 4 15:13:48 2019 (r348614) +++ stable/12/sys/riscv/riscv/timer.c Tue Jun 4 15:15:37 2019 (r348615) @@ -61,7 +61,10 @@ __FBSDID("$FreeBSD$"); #include #include -#define DEFAULT_FREQ 10000000 +#include +#include +#include +#include #define TIMER_COUNTS 0x00 #define TIMER_MTIMECMP(cpu) (cpu * 8) @@ -157,6 +160,32 @@ riscv_timer_intr(void *arg) } static int +riscv_timer_get_timebase(device_t dev, uint32_t *freq) +{ + phandle_t node; + int len; + + node = OF_finddevice("/cpus"); + if (node == -1) { + if (bootverbose) + device_printf(dev, "Can't find cpus node.\n"); + return (ENXIO); + } + + len = OF_getproplen(node, "timebase-frequency"); + if (len != 4) { + if (bootverbose) + device_printf(dev, + "Can't find timebase-frequency property.\n"); + return (ENXIO); + } + + OF_getencprop(node, "timebase-frequency", freq, len); + + return (0); +} + +static int riscv_timer_probe(device_t dev) { @@ -176,10 +205,9 @@ riscv_timer_attach(device_t dev) return (ENXIO); if (device_get_unit(dev) != 0) - return ENXIO; + return (ENXIO); - sc->clkfreq = DEFAULT_FREQ; - if (sc->clkfreq == 0) { + if (riscv_timer_get_timebase(dev, &sc->clkfreq) != 0) { device_printf(dev, "No clock frequency specified\n"); return (ENXIO); } From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:18:42 2019 Return-Path: Delivered-To: svn-src-stable-12@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 8C95115B3F96; Tue, 4 Jun 2019 15:18:42 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2F4076D851; Tue, 4 Jun 2019 15:18:42 +0000 (UTC) (envelope-from br@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 029D51F42B; Tue, 4 Jun 2019 15:18:42 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FIfK2027877; Tue, 4 Jun 2019 15:18:41 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FIfLK027876; Tue, 4 Jun 2019 15:18:41 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041518.x54FIfLK027876@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:18:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348616 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348616 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2F4076D851 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.939,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:18:42 -0000 Author: br Date: Tue Jun 4 15:18:41 2019 New Revision: 348616 URL: https://svnweb.freebsd.org/changeset/base/348616 Log: MFC r345796: o Grab the number of devices supported by PLIC from FDT. o Fix bug in PLIC_ENABLE macro when irq >= 32. Tested on the real hardware, which is HiFive Unleashed board. Thanks to SiFive, Inc. for the board provided. Sponsored by: DARPA, AFRL Modified: stable/12/sys/riscv/riscv/plic.c Modified: stable/12/sys/riscv/riscv/plic.c ============================================================================== --- stable/12/sys/riscv/riscv/plic.c Tue Jun 4 15:15:37 2019 (r348615) +++ stable/12/sys/riscv/riscv/plic.c Tue Jun 4 15:18:41 2019 (r348616) @@ -52,9 +52,9 @@ __FBSDID("$FreeBSD$"); #include "pic_if.h" -#define PLIC_NIRQS 32 +#define PLIC_MAX_IRQS 2048 #define PLIC_PRIORITY(n) (0x000000 + (n) * 0x4) -#define PLIC_ENABLE(n, h) (0x002000 + (h) * 0x80 + (n) / 32) +#define PLIC_ENABLE(n, h) (0x002000 + (h) * 0x80 + 4 * ((n) / 32)) #define PLIC_THRESHOLD(h) (0x200000 + (h) * 0x1000 + 0x0) #define PLIC_CLAIM(h) (0x200000 + (h) * 0x1000 + 0x4) @@ -66,7 +66,8 @@ struct plic_irqsrc { struct plic_softc { device_t dev; struct resource * intc_res; - struct plic_irqsrc isrcs[PLIC_NIRQS]; + struct plic_irqsrc isrcs[PLIC_MAX_IRQS]; + int ndev; }; #define RD4(sc, reg) \ @@ -158,7 +159,7 @@ plic_map_intr(device_t dev, struct intr_map_data *data return (ENOTSUP); daf = (struct intr_map_data_fdt *)data; - if (daf->ncells != 1 || daf->cells[0] >= PLIC_NIRQS) + if (daf->ncells != 1 || daf->cells[0] > sc->ndev) return (EINVAL); *isrcp = &sc->isrcs[daf->cells[0]].isrc; @@ -189,6 +190,7 @@ plic_attach(device_t dev) struct intr_pic *pic; uint32_t irq; const char *name; + phandle_t node; phandle_t xref; uint32_t cpu; int error; @@ -198,6 +200,20 @@ plic_attach(device_t dev) sc->dev = dev; + node = ofw_bus_get_node(dev); + if ((OF_getencprop(node, "riscv,ndev", &sc->ndev, + sizeof(sc->ndev))) < 0) { + device_printf(dev, + "Error: could not get number of devices\n"); + return (ENXIO); + } + + if (sc->ndev >= PLIC_MAX_IRQS) { + device_printf(dev, + "Error: invalid ndev (%d)\n", sc->ndev); + return (ENXIO); + } + /* Request memory resources */ rid = 0; sc->intc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, @@ -211,7 +227,7 @@ plic_attach(device_t dev) isrcs = sc->isrcs; name = device_get_nameunit(sc->dev); cpu = PCPU_GET(cpuid); - for (irq = 0; irq < PLIC_NIRQS; irq++) { + for (irq = 1; irq <= sc->ndev; irq++) { isrcs[irq].irq = irq; error = intr_isrc_register(&isrcs[irq].isrc, sc->dev, 0, "%s,%u", name, irq); @@ -223,7 +239,7 @@ plic_attach(device_t dev) } WR4(sc, PLIC_THRESHOLD(cpu), 0); - xref = OF_xref_from_node(ofw_bus_get_node(sc->dev)); + xref = OF_xref_from_node(node); pic = intr_pic_register(sc->dev, xref); if (pic == NULL) return (ENXIO); From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:25:04 2019 Return-Path: Delivered-To: svn-src-stable-12@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 C506815B4541; Tue, 4 Jun 2019 15:25:04 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 69E206DF57; Tue, 4 Jun 2019 15:25:04 +0000 (UTC) (envelope-from br@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 458241F5EE; Tue, 4 Jun 2019 15:25:04 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FP4jI032910; Tue, 4 Jun 2019 15:25:04 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FP4en032909; Tue, 4 Jun 2019 15:25:04 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041525.x54FP4en032909@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:25:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348617 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348617 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 69E206DF57 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.938,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:25:05 -0000 Author: br Date: Tue Jun 4 15:25:03 2019 New Revision: 348617 URL: https://svnweb.freebsd.org/changeset/base/348617 Log: MFC r346633: Implement pic_pre_ithread(), pic_post_ithread(). Sponsored by: DARPA, AFRL Modified: stable/12/sys/riscv/riscv/plic.c Modified: stable/12/sys/riscv/riscv/plic.c ============================================================================== --- stable/12/sys/riscv/riscv/plic.c Tue Jun 4 15:18:41 2019 (r348616) +++ stable/12/sys/riscv/riscv/plic.c Tue Jun 4 15:25:03 2019 (r348617) @@ -249,6 +249,30 @@ plic_attach(device_t dev) return (intr_pic_claim_root(sc->dev, xref, plic_intr, sc, 0)); } +static void +plic_pre_ithread(device_t dev, struct intr_irqsrc *isrc) +{ + struct plic_softc *sc; + struct plic_irqsrc *src; + + sc = device_get_softc(dev); + src = (struct plic_irqsrc *)isrc; + + WR4(sc, PLIC_PRIORITY(src->irq), 0); +} + +static void +plic_post_ithread(device_t dev, struct intr_irqsrc *isrc) +{ + struct plic_softc *sc; + struct plic_irqsrc *src; + + sc = device_get_softc(dev); + src = (struct plic_irqsrc *)isrc; + + WR4(sc, PLIC_PRIORITY(src->irq), 1); +} + static device_method_t plic_methods[] = { DEVMETHOD(device_probe, plic_probe), DEVMETHOD(device_attach, plic_attach), @@ -256,6 +280,8 @@ static device_method_t plic_methods[] = { DEVMETHOD(pic_disable_intr, plic_disable_intr), DEVMETHOD(pic_enable_intr, plic_enable_intr), DEVMETHOD(pic_map_intr, plic_map_intr), + DEVMETHOD(pic_pre_ithread, plic_pre_ithread), + DEVMETHOD(pic_post_ithread, plic_post_ithread), DEVMETHOD_END }; From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:26:03 2019 Return-Path: Delivered-To: svn-src-stable-12@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 2306E15B460F; Tue, 4 Jun 2019 15:26:03 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BC7E26E0BE; Tue, 4 Jun 2019 15:26:02 +0000 (UTC) (envelope-from br@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 944B71F5F1; Tue, 4 Jun 2019 15:26:02 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FQ22M032991; Tue, 4 Jun 2019 15:26:02 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FQ23C032990; Tue, 4 Jun 2019 15:26:02 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041526.x54FQ23C032990@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:26:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348618 - stable/12/sys/dev/cadence X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: stable/12/sys/dev/cadence X-SVN-Commit-Revision: 348618 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: BC7E26E0BE X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.938,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:26:03 -0000 Author: br Date: Tue Jun 4 15:26:02 2019 New Revision: 348618 URL: https://svnweb.freebsd.org/changeset/base/348618 Log: MFC r346634: Add support for Cadence network controller found in HiFive Unleashed board. Sponsored by: DARPA, AFRL Modified: stable/12/sys/dev/cadence/if_cgem.c Modified: stable/12/sys/dev/cadence/if_cgem.c ============================================================================== --- stable/12/sys/dev/cadence/if_cgem.c Tue Jun 4 15:25:03 2019 (r348617) +++ stable/12/sys/dev/cadence/if_cgem.c Tue Jun 4 15:26:02 2019 (r348618) @@ -98,6 +98,12 @@ __FBSDID("$FreeBSD$"); #define CGEM_CKSUM_ASSIST (CSUM_IP | CSUM_TCP | CSUM_UDP | \ CSUM_TCP_IPV6 | CSUM_UDP_IPV6) +static struct ofw_compat_data compat_data[] = { + { "cadence,gem", 1 }, + { "cdns,macb", 1 }, + { NULL, 0 }, +}; + struct cgem_softc { if_t ifp; struct mtx sc_mtx; @@ -1635,7 +1641,7 @@ cgem_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "cadence,gem")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "Cadence CGEM Gigabit Ethernet Interface"); From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:28:35 2019 Return-Path: Delivered-To: svn-src-stable-12@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 1AC7615B484A; Tue, 4 Jun 2019 15:28:35 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AC8966E32D; Tue, 4 Jun 2019 15:28:34 +0000 (UTC) (envelope-from br@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 53D511F5F9; Tue, 4 Jun 2019 15:28:34 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FSYQf033146; Tue, 4 Jun 2019 15:28:34 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FSXPh033141; Tue, 4 Jun 2019 15:28:33 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041528.x54FSXPh033141@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:28:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348619 - in stable/12/sys/dev: altera/atse altera/softdma xdma X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: in stable/12/sys/dev: altera/atse altera/softdma xdma X-SVN-Commit-Revision: 348619 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: AC8966E32D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.940,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:28:35 -0000 Author: br Date: Tue Jun 4 15:28:32 2019 New Revision: 348619 URL: https://svnweb.freebsd.org/changeset/base/348619 Log: MFC r346896: o Rewrite softdma_process_tx() of Altera SoftDMA engine driver so it does not require a bounce buffer. The only need for this was to align the buffer address. Implement unaligned access and we don't need to copy data twice. o Remove contigmalloc-based bounce buffer from xDMA code since it is not suitable for arbitrary memory provided by platform, which is sometimes a dedicated piece of memory that is not managed by OS at all. Sponsored by: DARPA, AFRL Modified: stable/12/sys/dev/altera/atse/if_atse.c stable/12/sys/dev/altera/softdma/softdma.c stable/12/sys/dev/xdma/xdma.h stable/12/sys/dev/xdma/xdma_mbuf.c stable/12/sys/dev/xdma/xdma_sg.c Modified: stable/12/sys/dev/altera/atse/if_atse.c ============================================================================== --- stable/12/sys/dev/altera/atse/if_atse.c Tue Jun 4 15:26:02 2019 (r348618) +++ stable/12/sys/dev/altera/atse/if_atse.c Tue Jun 4 15:28:32 2019 (r348619) @@ -1290,7 +1290,7 @@ atse_attach(device_t dev) * Chapter 15. On-Chip FIFO Memory Core. * Embedded Peripherals IP User Guide. */ - caps = XCHAN_CAP_BUSDMA_NOSEG; + caps = XCHAN_CAP_NOSEG; /* Alloc xDMA virtual channel. */ sc->xchan_tx = xdma_channel_alloc(sc->xdma_tx, caps); @@ -1456,6 +1456,11 @@ atse_detach(device_t dev) } mtx_destroy(&sc->atse_mtx); + + xdma_channel_free(sc->xchan_tx); + xdma_channel_free(sc->xchan_rx); + xdma_put(sc->xdma_tx); + xdma_put(sc->xdma_rx); return (0); } Modified: stable/12/sys/dev/altera/softdma/softdma.c ============================================================================== --- stable/12/sys/dev/altera/softdma/softdma.c Tue Jun 4 15:26:02 2019 (r348618) +++ stable/12/sys/dev/altera/softdma/softdma.c Tue Jun 4 15:28:32 2019 (r348619) @@ -190,6 +190,18 @@ softdma_fill_level(struct softdma_softc *sc) return (val); } +static uint32_t +fifo_fill_level_wait(struct softdma_softc *sc) +{ + uint32_t val; + + do + val = softdma_fill_level(sc); + while (val == AVALON_FIFO_TX_BASIC_OPTS_DEPTH); + + return (val); +} + static void softdma_intr(void *arg) { @@ -287,86 +299,96 @@ static int softdma_process_tx(struct softdma_channel *chan, struct softdma_desc *desc) { struct softdma_softc *sc; - uint32_t src_offs, dst_offs; + uint64_t addr; + uint64_t buf; + uint32_t word; + uint32_t missing; uint32_t reg; - uint32_t fill_level; - uint32_t leftm; - uint32_t tmp; - uint32_t val; - uint32_t c; + int got_bits; + int len; sc = chan->sc; - fill_level = softdma_fill_level(sc); - while (fill_level == AVALON_FIFO_TX_BASIC_OPTS_DEPTH) - fill_level = softdma_fill_level(sc); + fifo_fill_level_wait(sc); /* Set start of packet. */ - if (desc->control & CONTROL_GEN_SOP) { - reg = 0; - reg |= A_ONCHIP_FIFO_MEM_CORE_SOP; - softdma_mem_write(sc, A_ONCHIP_FIFO_MEM_CORE_METADATA, reg); - } + if (desc->control & CONTROL_GEN_SOP) + softdma_mem_write(sc, A_ONCHIP_FIFO_MEM_CORE_METADATA, + A_ONCHIP_FIFO_MEM_CORE_SOP); - src_offs = dst_offs = 0; - c = 0; - while ((desc->len - c) >= 4) { - val = *(uint32_t *)(desc->src_addr + src_offs); - bus_write_4(sc->res[0], A_ONCHIP_FIFO_MEM_CORE_DATA, val); - if (desc->src_incr) - src_offs += 4; - if (desc->dst_incr) - dst_offs += 4; - fill_level += 1; + got_bits = 0; + buf = 0; - while (fill_level == AVALON_FIFO_TX_BASIC_OPTS_DEPTH) { - fill_level = softdma_fill_level(sc); - } - c += 4; + addr = desc->src_addr; + len = desc->len; + + if (addr & 1) { + buf = (buf << 8) | *(uint8_t *)addr; + got_bits += 8; + addr += 1; + len -= 1; } - val = 0; - leftm = (desc->len - c); + if (len >= 2 && addr & 2) { + buf = (buf << 16) | *(uint16_t *)addr; + got_bits += 16; + addr += 2; + len -= 2; + } - switch (leftm) { - case 1: - val = *(uint8_t *)(desc->src_addr + src_offs); - val <<= 24; - src_offs += 1; - break; - case 2: - case 3: - val = *(uint16_t *)(desc->src_addr + src_offs); - val <<= 16; - src_offs += 2; + while (len >= 4) { + buf = (buf << 32) | (uint64_t)*(uint32_t *)addr; + addr += 4; + len -= 4; + word = (uint32_t)((buf >> got_bits) & 0xffffffff); - if (leftm == 3) { - tmp = *(uint8_t *)(desc->src_addr + src_offs); - val |= (tmp << 8); - src_offs += 1; - } - break; - case 0: - default: - break; + fifo_fill_level_wait(sc); + if (len == 0 && got_bits == 0 && + (desc->control & CONTROL_GEN_EOP) != 0) + softdma_mem_write(sc, A_ONCHIP_FIFO_MEM_CORE_METADATA, + A_ONCHIP_FIFO_MEM_CORE_EOP); + bus_write_4(sc->res[0], A_ONCHIP_FIFO_MEM_CORE_DATA, word); } - /* Set end of packet. */ - reg = 0; - if (desc->control & CONTROL_GEN_EOP) - reg |= A_ONCHIP_FIFO_MEM_CORE_EOP; - reg |= ((4 - leftm) << A_ONCHIP_FIFO_MEM_CORE_EMPTY_SHIFT); - softdma_mem_write(sc, A_ONCHIP_FIFO_MEM_CORE_METADATA, reg); + if (len & 2) { + buf = (buf << 16) | *(uint16_t *)addr; + got_bits += 16; + addr += 2; + len -= 2; + } - /* Ensure there is a FIFO entry available. */ - fill_level = softdma_fill_level(sc); - while (fill_level == AVALON_FIFO_TX_BASIC_OPTS_DEPTH) - fill_level = softdma_fill_level(sc); + if (len & 1) { + buf = (buf << 8) | *(uint8_t *)addr; + got_bits += 8; + addr += 1; + len -= 1; + } - /* Final write */ - bus_write_4(sc->res[0], A_ONCHIP_FIFO_MEM_CORE_DATA, val); + if (got_bits >= 32) { + got_bits -= 32; + word = (uint32_t)((buf >> got_bits) & 0xffffffff); - return (dst_offs); + fifo_fill_level_wait(sc); + if (len == 0 && got_bits == 0 && + (desc->control & CONTROL_GEN_EOP) != 0) + softdma_mem_write(sc, A_ONCHIP_FIFO_MEM_CORE_METADATA, + A_ONCHIP_FIFO_MEM_CORE_EOP); + bus_write_4(sc->res[0], A_ONCHIP_FIFO_MEM_CORE_DATA, word); + } + + if (got_bits) { + missing = 32 - got_bits; + got_bits /= 8; + + fifo_fill_level_wait(sc); + reg = A_ONCHIP_FIFO_MEM_CORE_EOP | + ((4 - got_bits) << A_ONCHIP_FIFO_MEM_CORE_EMPTY_SHIFT); + softdma_mem_write(sc, A_ONCHIP_FIFO_MEM_CORE_METADATA, reg); + word = (uint32_t)((buf << missing) & 0xffffffff); + bus_write_4(sc->res[0], A_ONCHIP_FIFO_MEM_CORE_DATA, word); + } + + return (desc->len); } static int @@ -594,6 +616,8 @@ softdma_channel_alloc(device_t dev, struct xdma_channe if (chan->used == 0) { chan->xchan = xchan; xchan->chan = (void *)chan; + xchan->caps |= XCHAN_CAP_NOBUFS; + xchan->caps |= XCHAN_CAP_NOSEG; chan->index = i; chan->idx_head = 0; chan->idx_tail = 0; Modified: stable/12/sys/dev/xdma/xdma.h ============================================================================== --- stable/12/sys/dev/xdma/xdma.h Tue Jun 4 15:26:02 2019 (r348618) +++ stable/12/sys/dev/xdma/xdma.h Tue Jun 4 15:28:32 2019 (r348619) @@ -84,7 +84,6 @@ struct xchan_buf { bus_dmamap_t map; uint32_t nsegs; uint32_t nsegs_left; - void *cbuf; }; struct xdma_request { @@ -130,7 +129,8 @@ struct xdma_channel { uint32_t caps; #define XCHAN_CAP_BUSDMA (1 << 0) -#define XCHAN_CAP_BUSDMA_NOSEG (1 << 1) +#define XCHAN_CAP_NOSEG (1 << 1) +#define XCHAN_CAP_NOBUFS (1 << 2) /* A real hardware driver channel. */ void *chan; Modified: stable/12/sys/dev/xdma/xdma_mbuf.c ============================================================================== --- stable/12/sys/dev/xdma/xdma_mbuf.c Tue Jun 4 15:26:02 2019 (r348618) +++ stable/12/sys/dev/xdma/xdma_mbuf.c Tue Jun 4 15:28:32 2019 (r348619) @@ -136,19 +136,15 @@ xdma_mbuf_defrag(xdma_channel_t *xchan, struct xdma_re if (c == 1) return (c); /* Nothing to do. */ - if (xchan->caps & XCHAN_CAP_BUSDMA) { - if ((xchan->caps & XCHAN_CAP_BUSDMA_NOSEG) || \ - (c > xchan->maxnsegs)) { - if ((m = m_defrag(xr->m, M_NOWAIT)) == NULL) { - device_printf(xdma->dma_dev, - "%s: Can't defrag mbuf\n", - __func__); - return (c); - } - xr->m = m; - c = 1; - } + if ((m = m_defrag(xr->m, M_NOWAIT)) == NULL) { + device_printf(xdma->dma_dev, + "%s: Can't defrag mbuf\n", + __func__); + return (c); } + + xr->m = m; + c = 1; return (c); } Modified: stable/12/sys/dev/xdma/xdma_sg.c ============================================================================== --- stable/12/sys/dev/xdma/xdma_sg.c Tue Jun 4 15:26:02 2019 (r348618) +++ stable/12/sys/dev/xdma/xdma_sg.c Tue Jun 4 15:28:32 2019 (r348619) @@ -69,14 +69,7 @@ _xchan_bufs_alloc(xdma_channel_t *xchan) for (i = 0; i < xchan->xr_num; i++) { xr = &xchan->xr_mem[i]; - xr->buf.cbuf = contigmalloc(xchan->maxsegsize, - M_XDMA, 0, 0, ~0, PAGE_SIZE, 0); - if (xr->buf.cbuf == NULL) { - device_printf(xdma->dev, - "%s: Can't allocate contiguous kernel" - " physical memory\n", __func__); - return (-1); - } + /* TODO: bounce buffer */ } return (0); @@ -179,7 +172,7 @@ xchan_bufs_free(xdma_channel_t *xchan) } else { for (i = 0; i < xchan->xr_num; i++) { xr = &xchan->xr_mem[i]; - contigfree(xr->buf.cbuf, xchan->maxsegsize, M_XDMA); + /* TODO: bounce buffer */ } } @@ -245,17 +238,19 @@ xdma_prep_sg(xdma_channel_t *xchan, uint32_t xr_num, return (-1); } - /* Allocate bufs. */ - ret = xchan_bufs_alloc(xchan); - if (ret != 0) { - device_printf(xdma->dev, - "%s: Can't allocate bufs.\n", __func__); + /* Allocate buffers if required. */ + if ((xchan->caps & XCHAN_CAP_NOBUFS) == 0) { + ret = xchan_bufs_alloc(xchan); + if (ret != 0) { + device_printf(xdma->dev, + "%s: Can't allocate bufs.\n", __func__); - /* Cleanup */ - xchan_sglist_free(xchan); - xchan_bank_free(xchan); + /* Cleanup */ + xchan_sglist_free(xchan); + xchan_bank_free(xchan); - return (-1); + return (-1); + } } xchan->flags |= (XCHAN_CONFIGURED | XCHAN_TYPE_SG); @@ -442,14 +437,8 @@ _xdma_load_data(xdma_channel_t *xchan, struct xdma_req switch (xr->req_type) { case XR_TYPE_MBUF: - if (xr->direction == XDMA_MEM_TO_DEV) { - m_copydata(m, 0, m->m_pkthdr.len, xr->buf.cbuf); - seg[0].ds_addr = (bus_addr_t)xr->buf.cbuf; - seg[0].ds_len = m->m_pkthdr.len; - } else { - seg[0].ds_addr = mtod(m, bus_addr_t); - seg[0].ds_len = m->m_pkthdr.len; - } + seg[0].ds_addr = mtod(m, bus_addr_t); + seg[0].ds_len = m->m_pkthdr.len; break; case XR_TYPE_BIO: case XR_TYPE_VIRT: @@ -516,7 +505,9 @@ xdma_process(xdma_channel_t *xchan, TAILQ_FOREACH_SAFE(xr, &xchan->queue_in, xr_next, xr_tmp) { switch (xr->req_type) { case XR_TYPE_MBUF: - c = xdma_mbuf_defrag(xchan, xr); + if ((xchan->caps & XCHAN_CAP_NOSEG) || + (c > xchan->maxnsegs)) + c = xdma_mbuf_defrag(xchan, xr); break; case XR_TYPE_BIO: case XR_TYPE_VIRT: @@ -571,7 +562,8 @@ xdma_queue_submit_sg(xdma_channel_t *xchan) sg = xchan->sg; - if ((xchan->flags & XCHAN_BUFS_ALLOCATED) == 0) { + if ((xchan->caps & XCHAN_CAP_NOBUFS) == 0 && + (xchan->flags & XCHAN_BUFS_ALLOCATED) == 0) { device_printf(xdma->dev, "%s: Can't submit a transfer: no bufs\n", __func__); From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:30:47 2019 Return-Path: Delivered-To: svn-src-stable-12@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 C801B15B4926; Tue, 4 Jun 2019 15:30:47 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 680F26E4DA; Tue, 4 Jun 2019 15:30:47 +0000 (UTC) (envelope-from br@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 3FF8D1F60F; Tue, 4 Jun 2019 15:30:47 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FUlK5034117; Tue, 4 Jun 2019 15:30:47 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FUljl034116; Tue, 4 Jun 2019 15:30:47 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041530.x54FUljl034116@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:30:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348620 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348620 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 680F26E4DA X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.938,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:30:48 -0000 Author: br Date: Tue Jun 4 15:30:46 2019 New Revision: 348620 URL: https://svnweb.freebsd.org/changeset/base/348620 Log: MFC r346994: Deactivate IRQ resource by calling to intr_deactivate_irq(). This is the part of INTRNG support that was missed. Sponsored by: DARPA, AFRL Modified: stable/12/sys/riscv/riscv/nexus.c Modified: stable/12/sys/riscv/riscv/nexus.c ============================================================================== --- stable/12/sys/riscv/riscv/nexus.c Tue Jun 4 15:28:32 2019 (r348619) +++ stable/12/sys/riscv/riscv/nexus.c Tue Jun 4 15:30:46 2019 (r348620) @@ -357,13 +357,17 @@ nexus_deactivate_resource(device_t bus, device_t child bus_size_t psize; bus_space_handle_t vaddr; - psize = (bus_size_t)rman_get_size(r); - vaddr = rman_get_bushandle(r); + if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { + psize = (bus_size_t)rman_get_size(r); + vaddr = rman_get_bushandle(r); - if (vaddr != 0) { - bus_space_unmap(&memmap_bus, vaddr, psize); - rman_set_virtual(r, NULL); - rman_set_bushandle(r, 0); + if (vaddr != 0) { + bus_space_unmap(&memmap_bus, vaddr, psize); + rman_set_virtual(r, NULL); + rman_set_bushandle(r, 0); + } + } else if (type == SYS_RES_IRQ) { + intr_deactivate_irq(child, r); } return (rman_deactivate_resource(r)); From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:32:58 2019 Return-Path: Delivered-To: svn-src-stable-12@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 D9DF315B4B2D; Tue, 4 Jun 2019 15:32:57 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8721A6E89A; Tue, 4 Jun 2019 15:32:57 +0000 (UTC) (envelope-from br@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 6D8EC1F7A1; Tue, 4 Jun 2019 15:32:57 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FWvhF038199; Tue, 4 Jun 2019 15:32:57 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FWuGN038194; Tue, 4 Jun 2019 15:32:56 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041532.x54FWuGN038194@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:32:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348621 - in stable/12/sys: conf riscv/include riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: in stable/12/sys: conf riscv/include riscv/riscv X-SVN-Commit-Revision: 348621 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8721A6E89A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.942,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:32:58 -0000 Author: br Date: Tue Jun 4 15:32:56 2019 New Revision: 348621 URL: https://svnweb.freebsd.org/changeset/base/348621 Log: MFC r347225: Provide a template for busdma code for RISC-V. RISC-V ISA specifies no cache management instructions so leave cache operations in cpufunc.h as no-op for now. Note some new hardware comes with their own memory-mapped cache management controller. Tested on HiFive Unleashed board with cgem(4). Sponsored by: DARPA, AFRL Added: stable/12/sys/riscv/include/bus_dma_impl.h (contents, props changed) stable/12/sys/riscv/riscv/busdma_bounce.c (contents, props changed) Modified: stable/12/sys/conf/files.riscv stable/12/sys/riscv/include/bus_dma.h stable/12/sys/riscv/include/cpufunc.h stable/12/sys/riscv/riscv/busdma_machdep.c stable/12/sys/riscv/riscv/machdep.c Modified: stable/12/sys/conf/files.riscv ============================================================================== --- stable/12/sys/conf/files.riscv Tue Jun 4 15:30:46 2019 (r348620) +++ stable/12/sys/conf/files.riscv Tue Jun 4 15:32:56 2019 (r348621) @@ -28,6 +28,7 @@ libkern/memset.c standard riscv/riscv/autoconf.c standard riscv/riscv/bus_machdep.c standard riscv/riscv/bus_space_asm.S standard +riscv/riscv/busdma_bounce.c standard riscv/riscv/busdma_machdep.c standard riscv/riscv/clock.c standard riscv/riscv/copyinout.S standard Modified: stable/12/sys/riscv/include/bus_dma.h ============================================================================== --- stable/12/sys/riscv/include/bus_dma.h Tue Jun 4 15:30:46 2019 (r348620) +++ stable/12/sys/riscv/include/bus_dma.h Tue Jun 4 15:32:56 2019 (r348621) @@ -3,7 +3,139 @@ #ifndef _MACHINE_BUS_DMA_H_ #define _MACHINE_BUS_DMA_H_ +#define WANT_INLINE_DMAMAP #include -#include + +#include + +/* + * Allocate a handle for mapping from kva/uva/physical + * address space into bus device space. + */ +static inline int +bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) +{ + struct bus_dma_tag_common *tc; + + tc = (struct bus_dma_tag_common *)dmat; + return (tc->impl->map_create(dmat, flags, mapp)); +} + +/* + * Destroy a handle for mapping from kva/uva/physical + * address space into bus device space. + */ +static inline int +bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map) +{ + struct bus_dma_tag_common *tc; + + tc = (struct bus_dma_tag_common *)dmat; + return (tc->impl->map_destroy(dmat, map)); +} + +/* + * Allocate a piece of memory that can be efficiently mapped into + * bus device space based on the constraints listed in the dma tag. + * A dmamap to for use with dmamap_load is also allocated. + */ +static inline int +bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, + bus_dmamap_t *mapp) +{ + struct bus_dma_tag_common *tc; + + tc = (struct bus_dma_tag_common *)dmat; + return (tc->impl->mem_alloc(dmat, vaddr, flags, mapp)); +} + +/* + * Free a piece of memory and it's allociated dmamap, that was allocated + * via bus_dmamem_alloc. Make the same choice for free/contigfree. + */ +static inline void +bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) +{ + struct bus_dma_tag_common *tc; + + tc = (struct bus_dma_tag_common *)dmat; + tc->impl->mem_free(dmat, vaddr, map); +} + +/* + * Release the mapping held by map. + */ +static inline void +bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map) +{ + struct bus_dma_tag_common *tc; + + tc = (struct bus_dma_tag_common *)dmat; + tc->impl->map_unload(dmat, map); +} + +static inline void +bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op) +{ + struct bus_dma_tag_common *tc; + + tc = (struct bus_dma_tag_common *)dmat; + tc->impl->map_sync(dmat, map, op); +} + +static inline int +_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf, + bus_size_t buflen, int flags, bus_dma_segment_t *segs, int *segp) +{ + struct bus_dma_tag_common *tc; + + tc = (struct bus_dma_tag_common *)dmat; + return (tc->impl->load_phys(dmat, map, buf, buflen, flags, segs, + segp)); +} + +static inline int +_bus_dmamap_load_ma(bus_dma_tag_t dmat, bus_dmamap_t map, struct vm_page **ma, + bus_size_t tlen, int ma_offs, int flags, bus_dma_segment_t *segs, + int *segp) +{ + struct bus_dma_tag_common *tc; + + tc = (struct bus_dma_tag_common *)dmat; + return (tc->impl->load_ma(dmat, map, ma, tlen, ma_offs, flags, + segs, segp)); +} + +static inline int +_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, + bus_size_t buflen, struct pmap *pmap, int flags, bus_dma_segment_t *segs, + int *segp) +{ + struct bus_dma_tag_common *tc; + + tc = (struct bus_dma_tag_common *)dmat; + return (tc->impl->load_buffer(dmat, map, buf, buflen, pmap, flags, segs, + segp)); +} + +static inline void +_bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map, + struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg) +{ + struct bus_dma_tag_common *tc; + + tc = (struct bus_dma_tag_common *)dmat; + tc->impl->map_waitok(dmat, map, mem, callback, callback_arg); +} + +static inline bus_dma_segment_t * +_bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t map, + bus_dma_segment_t *segs, int nsegs, int error) +{ + struct bus_dma_tag_common *tc; + + tc = (struct bus_dma_tag_common *)dmat; + return (tc->impl->map_complete(dmat, map, segs, nsegs, error)); +} #endif /* !_MACHINE_BUS_DMA_H_ */ Added: stable/12/sys/riscv/include/bus_dma_impl.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/riscv/include/bus_dma_impl.h Tue Jun 4 15:32:56 2019 (r348621) @@ -0,0 +1,96 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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 _MACHINE_BUS_DMA_IMPL_H_ +#define _MACHINE_BUS_DMA_IMPL_H_ + +struct bus_dma_tag_common { + struct bus_dma_impl *impl; + struct bus_dma_tag_common *parent; + bus_size_t alignment; + bus_addr_t boundary; + bus_addr_t lowaddr; + bus_addr_t highaddr; + bus_dma_filter_t *filter; + void *filterarg; + bus_size_t maxsize; + u_int nsegments; + bus_size_t maxsegsz; + int flags; + bus_dma_lock_t *lockfunc; + void *lockfuncarg; + int ref_count; +}; + +struct bus_dma_impl { + int (*tag_create)(bus_dma_tag_t parent, + bus_size_t alignment, bus_addr_t boundary, bus_addr_t lowaddr, + bus_addr_t highaddr, bus_dma_filter_t *filter, + void *filterarg, bus_size_t maxsize, int nsegments, + bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, + void *lockfuncarg, bus_dma_tag_t *dmat); + int (*tag_destroy)(bus_dma_tag_t dmat); + int (*map_create)(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp); + int (*map_destroy)(bus_dma_tag_t dmat, bus_dmamap_t map); + int (*mem_alloc)(bus_dma_tag_t dmat, void** vaddr, int flags, + bus_dmamap_t *mapp); + void (*mem_free)(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map); + int (*load_ma)(bus_dma_tag_t dmat, bus_dmamap_t map, + struct vm_page **ma, bus_size_t tlen, int ma_offs, int flags, + bus_dma_segment_t *segs, int *segp); + int (*load_phys)(bus_dma_tag_t dmat, bus_dmamap_t map, + vm_paddr_t buf, bus_size_t buflen, int flags, + bus_dma_segment_t *segs, int *segp); + int (*load_buffer)(bus_dma_tag_t dmat, bus_dmamap_t map, + void *buf, bus_size_t buflen, struct pmap *pmap, int flags, + bus_dma_segment_t *segs, int *segp); + void (*map_waitok)(bus_dma_tag_t dmat, bus_dmamap_t map, + struct memdesc *mem, bus_dmamap_callback_t *callback, + void *callback_arg); + bus_dma_segment_t *(*map_complete)(bus_dma_tag_t dmat, bus_dmamap_t map, + bus_dma_segment_t *segs, int nsegs, int error); + void (*map_unload)(bus_dma_tag_t dmat, bus_dmamap_t map); + void (*map_sync)(bus_dma_tag_t dmat, bus_dmamap_t map, + bus_dmasync_op_t op); +}; + +void bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op); +int bus_dma_run_filter(struct bus_dma_tag_common *dmat, bus_addr_t paddr); +int common_bus_dma_tag_create(struct bus_dma_tag_common *parent, + bus_size_t alignment, + bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr, + bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize, + int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, + void *lockfuncarg, size_t sz, void **dmat); + +extern struct bus_dma_impl bus_dma_bounce_impl; + +#endif Modified: stable/12/sys/riscv/include/cpufunc.h ============================================================================== --- stable/12/sys/riscv/include/cpufunc.h Tue Jun 4 15:30:46 2019 (r348620) +++ stable/12/sys/riscv/include/cpufunc.h Tue Jun 4 15:32:56 2019 (r348621) @@ -109,6 +109,17 @@ sfence_vma_page(uintptr_t addr) #define rdinstret() csr_read64(instret) #define rdhpmcounter(n) csr_read64(hpmcounter##n) +extern int64_t dcache_line_size; +extern int64_t icache_line_size; + +#define cpu_dcache_wbinv_range(a, s) +#define cpu_dcache_inv_range(a, s) +#define cpu_dcache_wb_range(a, s) + +#define cpu_idcache_wbinv_range(a, s) +#define cpu_icache_sync_range(a, s) +#define cpu_icache_sync_range_checked(a, s) + static __inline void load_satp(uint64_t val) { Added: stable/12/sys/riscv/riscv/busdma_bounce.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/riscv/riscv/busdma_bounce.c Tue Jun 4 15:32:56 2019 (r348621) @@ -0,0 +1,1330 @@ +/*- + * Copyright (c) 1997, 1998 Justin T. Gibbs. + * Copyright (c) 2015-2016 The FreeBSD Foundation + * All rights reserved. + * + * Portions of this software were developed by Andrew Turner + * under sponsorship of the FreeBSD Foundation. + * + * Portions of this software were developed by Semihalf + * under sponsorship of the FreeBSD Foundation. + * + * 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, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * 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 +#include + +#define MAX_BPAGES 4096 + +enum { + BF_COULD_BOUNCE = 0x01, + BF_MIN_ALLOC_COMP = 0x02, + BF_KMEM_ALLOC = 0x04, + BF_COHERENT = 0x10, +}; + +struct bounce_zone; + +struct bus_dma_tag { + struct bus_dma_tag_common common; + int map_count; + int bounce_flags; + bus_dma_segment_t *segments; + struct bounce_zone *bounce_zone; +}; + +struct bounce_page { + vm_offset_t vaddr; /* kva of bounce buffer */ + bus_addr_t busaddr; /* Physical address */ + vm_offset_t datavaddr; /* kva of client data */ + vm_page_t datapage; /* physical page of client data */ + vm_offset_t dataoffs; /* page offset of client data */ + bus_size_t datacount; /* client data count */ + STAILQ_ENTRY(bounce_page) links; +}; + +int busdma_swi_pending; + +struct bounce_zone { + STAILQ_ENTRY(bounce_zone) links; + STAILQ_HEAD(bp_list, bounce_page) bounce_page_list; + int total_bpages; + int free_bpages; + int reserved_bpages; + int active_bpages; + int total_bounced; + int total_deferred; + int map_count; + bus_size_t alignment; + bus_addr_t lowaddr; + char zoneid[8]; + char lowaddrid[20]; + struct sysctl_ctx_list sysctl_tree; + struct sysctl_oid *sysctl_tree_top; +}; + +static struct mtx bounce_lock; +static int total_bpages; +static int busdma_zonecount; +static STAILQ_HEAD(, bounce_zone) bounce_zone_list; + +static SYSCTL_NODE(_hw, OID_AUTO, busdma, CTLFLAG_RD, 0, "Busdma parameters"); +SYSCTL_INT(_hw_busdma, OID_AUTO, total_bpages, CTLFLAG_RD, &total_bpages, 0, + "Total bounce pages"); + +struct sync_list { + vm_offset_t vaddr; /* kva of client data */ + bus_addr_t paddr; /* physical address */ + vm_page_t pages; /* starting page of client data */ + bus_size_t datacount; /* client data count */ +}; + +struct bus_dmamap { + struct bp_list bpages; + int pagesneeded; + int pagesreserved; + bus_dma_tag_t dmat; + struct memdesc mem; + bus_dmamap_callback_t *callback; + void *callback_arg; + STAILQ_ENTRY(bus_dmamap) links; + u_int flags; +#define DMAMAP_COULD_BOUNCE (1 << 0) +#define DMAMAP_FROM_DMAMEM (1 << 1) + int sync_count; + struct sync_list slist[]; +}; + +static STAILQ_HEAD(, bus_dmamap) bounce_map_waitinglist; +static STAILQ_HEAD(, bus_dmamap) bounce_map_callbacklist; + +static void init_bounce_pages(void *dummy); +static int alloc_bounce_zone(bus_dma_tag_t dmat); +static int alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages); +static int reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map, + int commit); +static bus_addr_t add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, + vm_offset_t vaddr, bus_addr_t addr, bus_size_t size); +static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage); +int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr); +static void _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, + pmap_t pmap, void *buf, bus_size_t buflen, int flags); +static void _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map, + vm_paddr_t buf, bus_size_t buflen, int flags); +static int _bus_dmamap_reserve_pages(bus_dma_tag_t dmat, bus_dmamap_t map, + int flags); + +/* + * Allocate a device specific dma_tag. + */ +static int +bounce_bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, + bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr, + bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize, + int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, + void *lockfuncarg, bus_dma_tag_t *dmat) +{ + bus_dma_tag_t newtag; + int error; + + *dmat = NULL; + error = common_bus_dma_tag_create(parent != NULL ? &parent->common : + NULL, alignment, boundary, lowaddr, highaddr, filter, filterarg, + maxsize, nsegments, maxsegsz, flags, lockfunc, lockfuncarg, + sizeof (struct bus_dma_tag), (void **)&newtag); + if (error != 0) + return (error); + + newtag->common.impl = &bus_dma_bounce_impl; + newtag->map_count = 0; + newtag->segments = NULL; + + if ((flags & BUS_DMA_COHERENT) != 0) + newtag->bounce_flags |= BF_COHERENT; + + if (parent != NULL) { + if ((newtag->common.filter != NULL || + (parent->bounce_flags & BF_COULD_BOUNCE) != 0)) + newtag->bounce_flags |= BF_COULD_BOUNCE; + + /* Copy some flags from the parent */ + newtag->bounce_flags |= parent->bounce_flags & BF_COHERENT; + } + + if (newtag->common.lowaddr < ptoa((vm_paddr_t)Maxmem) || + newtag->common.alignment > 1) + newtag->bounce_flags |= BF_COULD_BOUNCE; + + if (((newtag->bounce_flags & BF_COULD_BOUNCE) != 0) && + (flags & BUS_DMA_ALLOCNOW) != 0) { + struct bounce_zone *bz; + + /* Must bounce */ + if ((error = alloc_bounce_zone(newtag)) != 0) { + free(newtag, M_DEVBUF); + return (error); + } + bz = newtag->bounce_zone; + + if (ptoa(bz->total_bpages) < maxsize) { + int pages; + + pages = atop(maxsize) - bz->total_bpages; + + /* Add pages to our bounce pool */ + if (alloc_bounce_pages(newtag, pages) < pages) + error = ENOMEM; + } + /* Performed initial allocation */ + newtag->bounce_flags |= BF_MIN_ALLOC_COMP; + } else + error = 0; + + if (error != 0) + free(newtag, M_DEVBUF); + else + *dmat = newtag; + CTR4(KTR_BUSDMA, "%s returned tag %p tag flags 0x%x error %d", + __func__, newtag, (newtag != NULL ? newtag->common.flags : 0), + error); + return (error); +} + +static int +bounce_bus_dma_tag_destroy(bus_dma_tag_t dmat) +{ + bus_dma_tag_t dmat_copy, parent; + int error; + + error = 0; + dmat_copy = dmat; + + if (dmat != NULL) { + if (dmat->map_count != 0) { + error = EBUSY; + goto out; + } + while (dmat != NULL) { + parent = (bus_dma_tag_t)dmat->common.parent; + atomic_subtract_int(&dmat->common.ref_count, 1); + if (dmat->common.ref_count == 0) { + if (dmat->segments != NULL) + free(dmat->segments, M_DEVBUF); + free(dmat, M_DEVBUF); + /* + * Last reference count, so + * release our reference + * count on our parent. + */ + dmat = parent; + } else + dmat = NULL; + } + } +out: + CTR3(KTR_BUSDMA, "%s tag %p error %d", __func__, dmat_copy, error); + return (error); +} + +static bus_dmamap_t +alloc_dmamap(bus_dma_tag_t dmat, int flags) +{ + u_long mapsize; + bus_dmamap_t map; + + mapsize = sizeof(*map); + mapsize += sizeof(struct sync_list) * dmat->common.nsegments; + map = malloc(mapsize, M_DEVBUF, flags | M_ZERO); + if (map == NULL) + return (NULL); + + /* Initialize the new map */ + STAILQ_INIT(&map->bpages); + + return (map); +} + +/* + * Allocate a handle for mapping from kva/uva/physical + * address space into bus device space. + */ +static int +bounce_bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) +{ + struct bounce_zone *bz; + int error, maxpages, pages; + + error = 0; + + if (dmat->segments == NULL) { + dmat->segments = (bus_dma_segment_t *)malloc( + sizeof(bus_dma_segment_t) * dmat->common.nsegments, + M_DEVBUF, M_NOWAIT); + if (dmat->segments == NULL) { + CTR3(KTR_BUSDMA, "%s: tag %p error %d", + __func__, dmat, ENOMEM); + return (ENOMEM); + } + } + + *mapp = alloc_dmamap(dmat, M_NOWAIT); + if (*mapp == NULL) { + CTR3(KTR_BUSDMA, "%s: tag %p error %d", + __func__, dmat, ENOMEM); + return (ENOMEM); + } + + /* + * Bouncing might be required if the driver asks for an active + * exclusion region, a data alignment that is stricter than 1, and/or + * an active address boundary. + */ + if (dmat->bounce_flags & BF_COULD_BOUNCE) { + /* Must bounce */ + if (dmat->bounce_zone == NULL) { + if ((error = alloc_bounce_zone(dmat)) != 0) { + free(*mapp, M_DEVBUF); + return (error); + } + } + bz = dmat->bounce_zone; + + (*mapp)->flags = DMAMAP_COULD_BOUNCE; + + /* + * Attempt to add pages to our pool on a per-instance + * basis up to a sane limit. + */ + if (dmat->common.alignment > 1) + maxpages = MAX_BPAGES; + else + maxpages = MIN(MAX_BPAGES, Maxmem - + atop(dmat->common.lowaddr)); + if ((dmat->bounce_flags & BF_MIN_ALLOC_COMP) == 0 || + (bz->map_count > 0 && bz->total_bpages < maxpages)) { + pages = MAX(atop(dmat->common.maxsize), 1); + pages = MIN(maxpages - bz->total_bpages, pages); + pages = MAX(pages, 1); + if (alloc_bounce_pages(dmat, pages) < pages) + error = ENOMEM; + if ((dmat->bounce_flags & BF_MIN_ALLOC_COMP) + == 0) { + if (error == 0) { + dmat->bounce_flags |= + BF_MIN_ALLOC_COMP; + } + } else + error = 0; + } + bz->map_count++; + } + if (error == 0) + dmat->map_count++; + else + free(*mapp, M_DEVBUF); + CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d", + __func__, dmat, dmat->common.flags, error); + return (error); +} + +/* + * Destroy a handle for mapping from kva/uva/physical + * address space into bus device space. + */ +static int +bounce_bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map) +{ + + /* Check we are destroying the correct map type */ + if ((map->flags & DMAMAP_FROM_DMAMEM) != 0) + panic("bounce_bus_dmamap_destroy: Invalid map freed\n"); + + if (STAILQ_FIRST(&map->bpages) != NULL || map->sync_count != 0) { + CTR3(KTR_BUSDMA, "%s: tag %p error %d", __func__, dmat, EBUSY); + return (EBUSY); + } + if (dmat->bounce_zone) { + KASSERT((map->flags & DMAMAP_COULD_BOUNCE) != 0, + ("%s: Bounce zone when cannot bounce", __func__)); + dmat->bounce_zone->map_count--; + } + free(map, M_DEVBUF); + dmat->map_count--; + CTR2(KTR_BUSDMA, "%s: tag %p error 0", __func__, dmat); + return (0); +} + + +/* + * Allocate a piece of memory that can be efficiently mapped into + * bus device space based on the constraints lited in the dma tag. + * A dmamap to for use with dmamap_load is also allocated. + */ +static int +bounce_bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, + bus_dmamap_t *mapp) +{ + /* + * XXX ARM64TODO: + * This bus_dma implementation requires IO-Coherent architecutre. + * If IO-Coherency is not guaranteed, the BUS_DMA_COHERENT flag has + * to be implented using non-cacheable memory. + */ + + vm_memattr_t attr; + int mflags; + + if (flags & BUS_DMA_NOWAIT) + mflags = M_NOWAIT; + else + mflags = M_WAITOK; + + if (dmat->segments == NULL) { + dmat->segments = (bus_dma_segment_t *)malloc( + sizeof(bus_dma_segment_t) * dmat->common.nsegments, + M_DEVBUF, mflags); + if (dmat->segments == NULL) { + CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d", + __func__, dmat, dmat->common.flags, ENOMEM); + return (ENOMEM); + } + } + if (flags & BUS_DMA_ZERO) + mflags |= M_ZERO; + if (flags & BUS_DMA_NOCACHE) + attr = VM_MEMATTR_UNCACHEABLE; + else if ((flags & BUS_DMA_COHERENT) != 0 && + (dmat->bounce_flags & BF_COHERENT) == 0) + /* + * If we have a non-coherent tag, and are trying to allocate + * a coherent block of memory it needs to be uncached. + */ + attr = VM_MEMATTR_UNCACHEABLE; + else + attr = VM_MEMATTR_DEFAULT; + + /* + * Create the map, but don't set the could bounce flag as + * this allocation should never bounce; + */ + *mapp = alloc_dmamap(dmat, mflags); + if (*mapp == NULL) { + CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d", + __func__, dmat, dmat->common.flags, ENOMEM); + return (ENOMEM); + } + (*mapp)->flags = DMAMAP_FROM_DMAMEM; + + /* + * Allocate the buffer from the malloc(9) allocator if... + * - It's small enough to fit into a single power of two sized bucket. + * - The alignment is less than or equal to the maximum size + * - The low address requirement is fulfilled. + * else allocate non-contiguous pages if... + * - The page count that could get allocated doesn't exceed + * nsegments also when the maximum segment size is less + * than PAGE_SIZE. + * - The alignment constraint isn't larger than a page boundary. + * - There are no boundary-crossing constraints. + * else allocate a block of contiguous pages because one or more of the + * constraints is something that only the contig allocator can fulfill. + * + * NOTE: The (dmat->common.alignment <= dmat->maxsize) check + * below is just a quick hack. The exact alignment guarantees + * of malloc(9) need to be nailed down, and the code below + * should be rewritten to take that into account. + * + * In the meantime warn the user if malloc gets it wrong. + */ + if ((dmat->common.maxsize <= PAGE_SIZE) && + (dmat->common.alignment <= dmat->common.maxsize) && + dmat->common.lowaddr >= ptoa((vm_paddr_t)Maxmem) && + attr == VM_MEMATTR_DEFAULT) { + *vaddr = malloc(dmat->common.maxsize, M_DEVBUF, mflags); + } else if (dmat->common.nsegments >= + howmany(dmat->common.maxsize, MIN(dmat->common.maxsegsz, PAGE_SIZE)) && + dmat->common.alignment <= PAGE_SIZE && + (dmat->common.boundary % PAGE_SIZE) == 0) { + /* Page-based multi-segment allocations allowed */ + *vaddr = (void *)kmem_alloc_attr(dmat->common.maxsize, mflags, + 0ul, dmat->common.lowaddr, attr); + dmat->bounce_flags |= BF_KMEM_ALLOC; + } else { + *vaddr = (void *)kmem_alloc_contig(dmat->common.maxsize, mflags, + 0ul, dmat->common.lowaddr, dmat->common.alignment != 0 ? + dmat->common.alignment : 1ul, dmat->common.boundary, attr); + dmat->bounce_flags |= BF_KMEM_ALLOC; + } + if (*vaddr == NULL) { + CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d", + __func__, dmat, dmat->common.flags, ENOMEM); + free(*mapp, M_DEVBUF); + return (ENOMEM); + } else if (vtophys(*vaddr) & (dmat->common.alignment - 1)) { + printf("bus_dmamem_alloc failed to align memory properly.\n"); + } + dmat->map_count++; + CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d", + __func__, dmat, dmat->common.flags, 0); + return (0); +} + +/* + * Free a piece of memory and it's allociated dmamap, that was allocated + * via bus_dmamem_alloc. Make the same choice for free/contigfree. + */ +static void +bounce_bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) +{ + + /* + * Check the map came from bounce_bus_dmamem_alloc, so the map + * should be NULL and the BF_KMEM_ALLOC flag cleared if malloc() + * was used and set if kmem_alloc_contig() was used. + */ + if ((map->flags & DMAMAP_FROM_DMAMEM) == 0) + panic("bus_dmamem_free: Invalid map freed\n"); + if ((dmat->bounce_flags & BF_KMEM_ALLOC) == 0) + free(vaddr, M_DEVBUF); + else + kmem_free((vm_offset_t)vaddr, dmat->common.maxsize); + free(map, M_DEVBUF); + dmat->map_count--; + CTR3(KTR_BUSDMA, "%s: tag %p flags 0x%x", __func__, dmat, + dmat->bounce_flags); +} + +static void +_bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf, + bus_size_t buflen, int flags) +{ + bus_addr_t curaddr; + bus_size_t sgsize; + + if ((map->flags & DMAMAP_COULD_BOUNCE) != 0 && map->pagesneeded == 0) { + /* + * Count the number of bounce pages + * needed in order to complete this transfer + */ + curaddr = buf; + while (buflen != 0) { + sgsize = MIN(buflen, dmat->common.maxsegsz); + if (bus_dma_run_filter(&dmat->common, curaddr)) { + sgsize = MIN(sgsize, + PAGE_SIZE - (curaddr & PAGE_MASK)); + map->pagesneeded++; + } + curaddr += sgsize; + buflen -= sgsize; + } + CTR1(KTR_BUSDMA, "pagesneeded= %d\n", map->pagesneeded); + } +} + +static void +_bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, pmap_t pmap, + void *buf, bus_size_t buflen, int flags) +{ + vm_offset_t vaddr; + vm_offset_t vendaddr; + bus_addr_t paddr; + bus_size_t sg_len; + + if ((map->flags & DMAMAP_COULD_BOUNCE) != 0 && map->pagesneeded == 0) { + CTR4(KTR_BUSDMA, "lowaddr= %d Maxmem= %d, boundary= %d, " + "alignment= %d", dmat->common.lowaddr, + ptoa((vm_paddr_t)Maxmem), + dmat->common.boundary, dmat->common.alignment); + CTR2(KTR_BUSDMA, "map= %p, pagesneeded= %d", map, + map->pagesneeded); + /* + * Count the number of bounce pages + * needed in order to complete this transfer + */ + vaddr = (vm_offset_t)buf; + vendaddr = (vm_offset_t)buf + buflen; + + while (vaddr < vendaddr) { + sg_len = PAGE_SIZE - ((vm_offset_t)vaddr & PAGE_MASK); + if (pmap == kernel_pmap) + paddr = pmap_kextract(vaddr); + else + paddr = pmap_extract(pmap, vaddr); + if (bus_dma_run_filter(&dmat->common, paddr) != 0) { + sg_len = roundup2(sg_len, + dmat->common.alignment); + map->pagesneeded++; + } + vaddr += sg_len; + } + CTR1(KTR_BUSDMA, "pagesneeded= %d\n", map->pagesneeded); + } +} + +static int +_bus_dmamap_reserve_pages(bus_dma_tag_t dmat, bus_dmamap_t map, int flags) +{ + + /* Reserve Necessary Bounce Pages */ + mtx_lock(&bounce_lock); + if (flags & BUS_DMA_NOWAIT) { + if (reserve_bounce_pages(dmat, map, 0) != 0) { + mtx_unlock(&bounce_lock); + return (ENOMEM); + } + } else { + if (reserve_bounce_pages(dmat, map, 1) != 0) { + /* Queue us for resources */ + STAILQ_INSERT_TAIL(&bounce_map_waitinglist, map, links); + mtx_unlock(&bounce_lock); + return (EINPROGRESS); + } + } + mtx_unlock(&bounce_lock); + + return (0); +} + +/* + * Add a single contiguous physical range to the segment list. + */ +static int +_bus_dmamap_addseg(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t curaddr, + bus_size_t sgsize, bus_dma_segment_t *segs, int *segp) +{ + bus_addr_t baddr, bmask; + int seg; + + /* + * Make sure we don't cross any boundaries. + */ + bmask = ~(dmat->common.boundary - 1); + if (dmat->common.boundary > 0) { + baddr = (curaddr + dmat->common.boundary) & bmask; + if (sgsize > (baddr - curaddr)) + sgsize = (baddr - curaddr); + } + + /* + * Insert chunk into a segment, coalescing with + * previous segment if possible. + */ + seg = *segp; + if (seg == -1) { + seg = 0; + segs[seg].ds_addr = curaddr; + segs[seg].ds_len = sgsize; + } else { + if (curaddr == segs[seg].ds_addr + segs[seg].ds_len && + (segs[seg].ds_len + sgsize) <= dmat->common.maxsegsz && + (dmat->common.boundary == 0 || + (segs[seg].ds_addr & bmask) == (curaddr & bmask))) + segs[seg].ds_len += sgsize; + else { + if (++seg >= dmat->common.nsegments) + return (0); + segs[seg].ds_addr = curaddr; + segs[seg].ds_len = sgsize; + } + } + *segp = seg; + return (sgsize); +} + +/* + * Utility function to load a physical buffer. segp contains + * the starting segment on entrace, and the ending segment on exit. + */ +static int +bounce_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, + vm_paddr_t buf, bus_size_t buflen, int flags, bus_dma_segment_t *segs, + int *segp) +{ + struct sync_list *sl; + bus_size_t sgsize; + bus_addr_t curaddr, sl_end; + int error; + + if (segs == NULL) + segs = dmat->segments; + + if ((dmat->bounce_flags & BF_COULD_BOUNCE) != 0) { + _bus_dmamap_count_phys(dmat, map, buf, buflen, flags); + if (map->pagesneeded != 0) { + error = _bus_dmamap_reserve_pages(dmat, map, flags); + if (error) + return (error); + } + } + + sl = map->slist + map->sync_count - 1; + sl_end = 0; + + while (buflen > 0) { + curaddr = buf; + sgsize = MIN(buflen, dmat->common.maxsegsz); + if (((dmat->bounce_flags & BF_COULD_BOUNCE) != 0) && + map->pagesneeded != 0 && + bus_dma_run_filter(&dmat->common, curaddr)) { + sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK)); + curaddr = add_bounce_page(dmat, map, 0, curaddr, + sgsize); + } else if ((dmat->bounce_flags & BF_COHERENT) == 0) { + if (map->sync_count > 0) + sl_end = sl->paddr + sl->datacount; + + if (map->sync_count == 0 || curaddr != sl_end) { + if (++map->sync_count > dmat->common.nsegments) + break; + sl++; + sl->vaddr = 0; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:33:53 2019 Return-Path: Delivered-To: svn-src-stable-12@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 9689D15B4BA9; Tue, 4 Jun 2019 15:33:53 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 354896E9E2; Tue, 4 Jun 2019 15:33:53 +0000 (UTC) (envelope-from br@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 0D5F31F7A5; Tue, 4 Jun 2019 15:33:53 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FXqpu038328; Tue, 4 Jun 2019 15:33:52 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FXqxB038327; Tue, 4 Jun 2019 15:33:52 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041533.x54FXqxB038327@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:33:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348622 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348622 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 354896E9E2 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.970,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:33:53 -0000 Author: br Date: Tue Jun 4 15:33:52 2019 New Revision: 348622 URL: https://svnweb.freebsd.org/changeset/base/348622 Log: MFC r347226: Disable interrupts first and then set spinlock_count to 1. Otherwise interrupt can be generated just after setting spinlock_count and before disabling interrupts. Sponsored by: DARPA, AFRL Modified: stable/12/sys/riscv/riscv/machdep.c Modified: stable/12/sys/riscv/riscv/machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/machdep.c Tue Jun 4 15:32:56 2019 (r348621) +++ stable/12/sys/riscv/riscv/machdep.c Tue Jun 4 15:33:52 2019 (r348622) @@ -460,11 +460,13 @@ void spinlock_enter(void) { struct thread *td; + register_t reg; td = curthread; if (td->td_md.md_spinlock_count == 0) { + reg = intr_disable(); td->td_md.md_spinlock_count = 1; - td->td_md.md_saved_sstatus_ie = intr_disable(); + td->td_md.md_saved_sstatus_ie = reg; } else td->td_md.md_spinlock_count++; critical_enter(); From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:35:48 2019 Return-Path: Delivered-To: svn-src-stable-12@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 5B26915B4C73; Tue, 4 Jun 2019 15:35:48 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0B5F86EB54; Tue, 4 Jun 2019 15:35:48 +0000 (UTC) (envelope-from br@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 D263F1F7A6; Tue, 4 Jun 2019 15:35:47 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FZlBQ038487; Tue, 4 Jun 2019 15:35:47 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FZkRV038481; Tue, 4 Jun 2019 15:35:46 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041535.x54FZkRV038481@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:35:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348623 - stable/12/sys/dev/xdma X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: stable/12/sys/dev/xdma X-SVN-Commit-Revision: 348623 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0B5F86EB54 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:35:48 -0000 Author: br Date: Tue Jun 4 15:35:46 2019 New Revision: 348623 URL: https://svnweb.freebsd.org/changeset/base/348623 Log: MFC r347337: o Implement a bounce buffer based on device reserved memory. Grab device reserved physical memory regions from FDT using standard "memory-region" property and use vmem(9) to allocate buffers from it. The same vmem could be used by DMA engine drivers to allocate memory for DMA descriptors. This is required for platforms that provide uncached memory region reserved exclusively for DMA operations. o Change sleepable sx(9) lock type to non-sleepable mutex(9) since network drivers usually hold mutex during DMA operations. So we don't take sleepable lock after non-sleepable. Tested on U.S. Government Furnished Equipment (GFE) 64-bit RISC-V cores. Sponsored by: DARPA, AFRL Modified: stable/12/sys/dev/xdma/xdma.c stable/12/sys/dev/xdma/xdma.h stable/12/sys/dev/xdma/xdma_bank.c stable/12/sys/dev/xdma/xdma_bio.c stable/12/sys/dev/xdma/xdma_mbuf.c stable/12/sys/dev/xdma/xdma_queue.c stable/12/sys/dev/xdma/xdma_sg.c Modified: stable/12/sys/dev/xdma/xdma.c ============================================================================== --- stable/12/sys/dev/xdma/xdma.c Tue Jun 4 15:33:52 2019 (r348622) +++ stable/12/sys/dev/xdma/xdma.c Tue Jun 4 15:35:46 2019 (r348623) @@ -1,7 +1,8 @@ /*- - * Copyright (c) 2016-2018 Ruslan Bukin - * All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause * + * Copyright (c) 2016-2019 Ruslan Bukin + * * 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. @@ -43,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include @@ -61,12 +61,14 @@ __FBSDID("$FreeBSD$"); * Multiple xDMA controllers may work with single DMA device, * so we have global lock for physical channel management. */ -static struct sx xdma_sx; +static struct mtx xdma_mtx; -#define XDMA_LOCK() sx_xlock(&xdma_sx) -#define XDMA_UNLOCK() sx_xunlock(&xdma_sx) -#define XDMA_ASSERT_LOCKED() sx_xassert(&xdma_sx, MA_OWNED) +#define XDMA_LOCK() mtx_lock(&xdma_mtx) +#define XDMA_UNLOCK() mtx_unlock(&xdma_mtx) +#define XDMA_ASSERT_LOCKED() mtx_assert(&xdma_mtx, MA_OWNED) +#define FDT_REG_CELLS 4 + /* * Allocate virtual xDMA channel. */ @@ -95,11 +97,11 @@ xdma_channel_alloc(xdma_controller_t *xdma, uint32_t c TAILQ_INIT(&xchan->ie_handlers); - sx_init(&xchan->sx_lock, "xDMA chan"); - sx_init(&xchan->sx_qin_lock, "xDMA qin"); - sx_init(&xchan->sx_qout_lock, "xDMA qout"); - sx_init(&xchan->sx_bank_lock, "xDMA bank"); - sx_init(&xchan->sx_proc_lock, "xDMA proc"); + mtx_init(&xchan->mtx_lock, "xDMA chan", NULL, MTX_DEF); + mtx_init(&xchan->mtx_qin_lock, "xDMA qin", NULL, MTX_DEF); + mtx_init(&xchan->mtx_qout_lock, "xDMA qout", NULL, MTX_DEF); + mtx_init(&xchan->mtx_bank_lock, "xDMA bank", NULL, MTX_DEF); + mtx_init(&xchan->mtx_proc_lock, "xDMA proc", NULL, MTX_DEF); TAILQ_INIT(&xchan->bank); TAILQ_INIT(&xchan->queue_in); @@ -138,11 +140,11 @@ xdma_channel_free(xdma_channel_t *xchan) xdma_teardown_all_intr(xchan); - sx_destroy(&xchan->sx_lock); - sx_destroy(&xchan->sx_qin_lock); - sx_destroy(&xchan->sx_qout_lock); - sx_destroy(&xchan->sx_bank_lock); - sx_destroy(&xchan->sx_proc_lock); + mtx_destroy(&xchan->mtx_lock); + mtx_destroy(&xchan->mtx_qin_lock); + mtx_destroy(&xchan->mtx_qout_lock); + mtx_destroy(&xchan->mtx_bank_lock); + mtx_destroy(&xchan->mtx_proc_lock); TAILQ_REMOVE(&xdma->channels, xchan, xchan_next); @@ -303,6 +305,95 @@ xdma_ofw_md_data(xdma_controller_t *xdma, pcell_t *cel return (ret); } +static int +xdma_handle_mem_node(vmem_t *vmem, phandle_t memory) +{ + pcell_t reg[FDT_REG_CELLS * FDT_MEM_REGIONS]; + pcell_t *regp; + int addr_cells, size_cells; + int i, reg_len, ret, tuple_size, tuples; + vmem_addr_t mem_start; + vmem_size_t mem_size; + + if ((ret = fdt_addrsize_cells(OF_parent(memory), &addr_cells, + &size_cells)) != 0) + return (ret); + + if (addr_cells > 2) + return (ERANGE); + + tuple_size = sizeof(pcell_t) * (addr_cells + size_cells); + reg_len = OF_getproplen(memory, "reg"); + if (reg_len <= 0 || reg_len > sizeof(reg)) + return (ERANGE); + + if (OF_getprop(memory, "reg", reg, reg_len) <= 0) + return (ENXIO); + + tuples = reg_len / tuple_size; + regp = (pcell_t *)® + for (i = 0; i < tuples; i++) { + ret = fdt_data_to_res(regp, addr_cells, size_cells, + &mem_start, &mem_size); + if (ret != 0) + return (ret); + + vmem_add(vmem, mem_start, mem_size, 0); + regp += addr_cells + size_cells; + } + + return (0); +} + +vmem_t * +xdma_get_memory(device_t dev) +{ + phandle_t mem_node, node; + pcell_t mem_handle; + vmem_t *vmem; + + node = ofw_bus_get_node(dev); + if (node <= 0) { + device_printf(dev, + "%s called on not ofw based device.\n", __func__); + return (NULL); + } + + if (!OF_hasprop(node, "memory-region")) + return (NULL); + + if (OF_getencprop(node, "memory-region", (void *)&mem_handle, + sizeof(mem_handle)) <= 0) + return (NULL); + + vmem = vmem_create("xDMA vmem", 0, 0, PAGE_SIZE, + PAGE_SIZE, M_BESTFIT | M_WAITOK); + if (vmem == NULL) + return (NULL); + + mem_node = OF_node_from_xref(mem_handle); + if (xdma_handle_mem_node(vmem, mem_node) != 0) { + vmem_destroy(vmem); + return (NULL); + } + + return (vmem); +} + +void +xdma_put_memory(vmem_t *vmem) +{ + + vmem_destroy(vmem); +} + +void +xchan_set_memory(xdma_channel_t *xchan, vmem_t *vmem) +{ + + xchan->vmem = vmem; +} + /* * Allocate xdma controller. */ @@ -400,7 +491,7 @@ static void xdma_init(void) { - sx_init(&xdma_sx, "xDMA"); + mtx_init(&xdma_mtx, "xDMA", NULL, MTX_DEF); } SYSINIT(xdma, SI_SUB_DRIVERS, SI_ORDER_FIRST, xdma_init, NULL); Modified: stable/12/sys/dev/xdma/xdma.h ============================================================================== --- stable/12/sys/dev/xdma/xdma.h Tue Jun 4 15:33:52 2019 (r348622) +++ stable/12/sys/dev/xdma/xdma.h Tue Jun 4 15:35:46 2019 (r348623) @@ -1,7 +1,8 @@ /*- - * Copyright (c) 2016-2018 Ruslan Bukin - * All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause * + * Copyright (c) 2016-2019 Ruslan Bukin + * * 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. @@ -34,6 +35,7 @@ #define _DEV_XDMA_XDMA_H_ #include +#include enum xdma_direction { XDMA_MEM_TO_MEM, @@ -73,6 +75,7 @@ struct xdma_controller { device_t dev; /* DMA consumer device_t. */ device_t dma_dev; /* A real DMA device_t. */ void *data; /* OFW MD part. */ + vmem_t *vmem; /* Bounce memory. */ /* List of virtual channels allocated. */ TAILQ_HEAD(xdma_channel_list, xdma_channel) channels; @@ -84,6 +87,9 @@ struct xchan_buf { bus_dmamap_t map; uint32_t nsegs; uint32_t nsegs_left; + vm_offset_t vaddr; + vm_offset_t paddr; + vm_size_t size; }; struct xdma_request { @@ -117,6 +123,7 @@ struct xdma_sglist { struct xdma_channel { xdma_controller_t *xdma; + vmem_t *vmem; uint32_t flags; #define XCHAN_BUFS_ALLOCATED (1 << 0) @@ -139,11 +146,11 @@ struct xdma_channel { TAILQ_HEAD(, xdma_intr_handler) ie_handlers; TAILQ_ENTRY(xdma_channel) xchan_next; - struct sx sx_lock; - struct sx sx_qin_lock; - struct sx sx_qout_lock; - struct sx sx_bank_lock; - struct sx sx_proc_lock; + struct mtx mtx_lock; + struct mtx mtx_qin_lock; + struct mtx mtx_qout_lock; + struct mtx mtx_bank_lock; + struct mtx mtx_proc_lock; /* Request queue. */ bus_dma_tag_t dma_tag_bufs; @@ -176,30 +183,30 @@ struct xdma_intr_handler { static MALLOC_DEFINE(M_XDMA, "xdma", "xDMA framework"); -#define XCHAN_LOCK(xchan) sx_xlock(&(xchan)->sx_lock) -#define XCHAN_UNLOCK(xchan) sx_xunlock(&(xchan)->sx_lock) +#define XCHAN_LOCK(xchan) mtx_lock(&(xchan)->mtx_lock) +#define XCHAN_UNLOCK(xchan) mtx_unlock(&(xchan)->mtx_lock) #define XCHAN_ASSERT_LOCKED(xchan) \ - sx_assert(&(xchan)->sx_lock, SX_XLOCKED) + mtx_assert(&(xchan)->mtx_lock, MA_OWNED) -#define QUEUE_IN_LOCK(xchan) sx_xlock(&(xchan)->sx_qin_lock) -#define QUEUE_IN_UNLOCK(xchan) sx_xunlock(&(xchan)->sx_qin_lock) +#define QUEUE_IN_LOCK(xchan) mtx_lock(&(xchan)->mtx_qin_lock) +#define QUEUE_IN_UNLOCK(xchan) mtx_unlock(&(xchan)->mtx_qin_lock) #define QUEUE_IN_ASSERT_LOCKED(xchan) \ - sx_assert(&(xchan)->sx_qin_lock, SX_XLOCKED) + mtx_assert(&(xchan)->mtx_qin_lock, MA_OWNED) -#define QUEUE_OUT_LOCK(xchan) sx_xlock(&(xchan)->sx_qout_lock) -#define QUEUE_OUT_UNLOCK(xchan) sx_xunlock(&(xchan)->sx_qout_lock) +#define QUEUE_OUT_LOCK(xchan) mtx_lock(&(xchan)->mtx_qout_lock) +#define QUEUE_OUT_UNLOCK(xchan) mtx_unlock(&(xchan)->mtx_qout_lock) #define QUEUE_OUT_ASSERT_LOCKED(xchan) \ - sx_assert(&(xchan)->sx_qout_lock, SX_XLOCKED) + mtx_assert(&(xchan)->mtx_qout_lock, MA_OWNED) -#define QUEUE_BANK_LOCK(xchan) sx_xlock(&(xchan)->sx_bank_lock) -#define QUEUE_BANK_UNLOCK(xchan) sx_xunlock(&(xchan)->sx_bank_lock) +#define QUEUE_BANK_LOCK(xchan) mtx_lock(&(xchan)->mtx_bank_lock) +#define QUEUE_BANK_UNLOCK(xchan) mtx_unlock(&(xchan)->mtx_bank_lock) #define QUEUE_BANK_ASSERT_LOCKED(xchan) \ - sx_assert(&(xchan)->sx_bank_lock, SX_XLOCKED) + mtx_assert(&(xchan)->mtx_bank_lock, MA_OWNED) -#define QUEUE_PROC_LOCK(xchan) sx_xlock(&(xchan)->sx_proc_lock) -#define QUEUE_PROC_UNLOCK(xchan) sx_xunlock(&(xchan)->sx_proc_lock) +#define QUEUE_PROC_LOCK(xchan) mtx_lock(&(xchan)->mtx_proc_lock) +#define QUEUE_PROC_UNLOCK(xchan) mtx_unlock(&(xchan)->mtx_proc_lock) #define QUEUE_PROC_ASSERT_LOCKED(xchan) \ - sx_assert(&(xchan)->sx_proc_lock, SX_XLOCKED) + mtx_assert(&(xchan)->mtx_proc_lock, MA_OWNED) #define XDMA_SGLIST_MAXLEN 2048 #define XDMA_MAX_SEG 128 @@ -207,11 +214,14 @@ static MALLOC_DEFINE(M_XDMA, "xdma", "xDMA framework") /* xDMA controller ops */ xdma_controller_t *xdma_ofw_get(device_t dev, const char *prop); int xdma_put(xdma_controller_t *xdma); +vmem_t * xdma_get_memory(device_t dev); +void xdma_put_memory(vmem_t *vmem); /* xDMA channel ops */ xdma_channel_t * xdma_channel_alloc(xdma_controller_t *, uint32_t caps); int xdma_channel_free(xdma_channel_t *); int xdma_request(xdma_channel_t *xchan, struct xdma_request *r); +void xchan_set_memory(xdma_channel_t *xchan, vmem_t *vmem); /* SG interface */ int xdma_prep_sg(xdma_channel_t *, uint32_t, Modified: stable/12/sys/dev/xdma/xdma_bank.c ============================================================================== --- stable/12/sys/dev/xdma/xdma_bank.c Tue Jun 4 15:33:52 2019 (r348622) +++ stable/12/sys/dev/xdma/xdma_bank.c Tue Jun 4 15:35:46 2019 (r348623) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2018 Ruslan Bukin + * Copyright (c) 2018-2019 Ruslan Bukin * All rights reserved. * * This software was developed by SRI International and the University of @@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include Modified: stable/12/sys/dev/xdma/xdma_bio.c ============================================================================== --- stable/12/sys/dev/xdma/xdma_bio.c Tue Jun 4 15:33:52 2019 (r348622) +++ stable/12/sys/dev/xdma/xdma_bio.c Tue Jun 4 15:35:46 2019 (r348623) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2017-2018 Ruslan Bukin + * Copyright (c) 2017-2019 Ruslan Bukin * All rights reserved. * * This software was developed by SRI International and the University of @@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include Modified: stable/12/sys/dev/xdma/xdma_mbuf.c ============================================================================== --- stable/12/sys/dev/xdma/xdma_mbuf.c Tue Jun 4 15:33:52 2019 (r348622) +++ stable/12/sys/dev/xdma/xdma_mbuf.c Tue Jun 4 15:35:46 2019 (r348623) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2017-2018 Ruslan Bukin + * Copyright (c) 2017-2019 Ruslan Bukin * All rights reserved. * * This software was developed by SRI International and the University of @@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include Modified: stable/12/sys/dev/xdma/xdma_queue.c ============================================================================== --- stable/12/sys/dev/xdma/xdma_queue.c Tue Jun 4 15:33:52 2019 (r348622) +++ stable/12/sys/dev/xdma/xdma_queue.c Tue Jun 4 15:35:46 2019 (r348623) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2018 Ruslan Bukin + * Copyright (c) 2018-2019 Ruslan Bukin * All rights reserved. * * This software was developed by SRI International and the University of @@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include Modified: stable/12/sys/dev/xdma/xdma_sg.c ============================================================================== --- stable/12/sys/dev/xdma/xdma_sg.c Tue Jun 4 15:33:52 2019 (r348622) +++ stable/12/sys/dev/xdma/xdma_sg.c Tue Jun 4 15:35:46 2019 (r348623) @@ -1,7 +1,8 @@ /*- - * Copyright (c) 2018 Ruslan Bukin - * All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause * + * Copyright (c) 2018-2019 Ruslan Bukin + * * 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. @@ -38,10 +39,14 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include +#include +#include +#include + #ifdef FDT #include #include @@ -58,25 +63,71 @@ struct seg_load_request { uint32_t error; }; +static void +xchan_bufs_free_reserved(xdma_channel_t *xchan) +{ + struct xdma_request *xr; + vm_size_t size; + int i; + + for (i = 0; i < xchan->xr_num; i++) { + xr = &xchan->xr_mem[i]; + size = xr->buf.size; + if (xr->buf.vaddr) { + pmap_kremove_device(xr->buf.vaddr, size); + kva_free(xr->buf.vaddr, size); + xr->buf.vaddr = 0; + } + if (xr->buf.paddr) { + vmem_free(xchan->vmem, xr->buf.paddr, size); + xr->buf.paddr = 0; + } + xr->buf.size = 0; + } +} + static int -_xchan_bufs_alloc(xdma_channel_t *xchan) +xchan_bufs_alloc_reserved(xdma_channel_t *xchan) { xdma_controller_t *xdma; struct xdma_request *xr; + vmem_addr_t addr; + vm_size_t size; int i; xdma = xchan->xdma; + if (xchan->vmem == NULL) + return (ENOBUFS); + for (i = 0; i < xchan->xr_num; i++) { xr = &xchan->xr_mem[i]; - /* TODO: bounce buffer */ + size = round_page(xchan->maxsegsize); + if (vmem_alloc(xchan->vmem, size, + M_BESTFIT | M_NOWAIT, &addr)) { + device_printf(xdma->dev, + "%s: Can't allocate memory\n", __func__); + xchan_bufs_free_reserved(xchan); + return (ENOMEM); + } + + xr->buf.size = size; + xr->buf.paddr = addr; + xr->buf.vaddr = kva_alloc(size); + if (xr->buf.vaddr == 0) { + device_printf(xdma->dev, + "%s: Can't allocate KVA\n", __func__); + xchan_bufs_free_reserved(xchan); + return (ENOMEM); + } + pmap_kenter_device(xr->buf.vaddr, size, addr); } return (0); } static int -_xchan_bufs_alloc_busdma(xdma_channel_t *xchan) +xchan_bufs_alloc_busdma(xdma_channel_t *xchan) { xdma_controller_t *xdma; struct xdma_request *xr; @@ -138,9 +189,10 @@ xchan_bufs_alloc(xdma_channel_t *xchan) } if (xchan->caps & XCHAN_CAP_BUSDMA) - ret = _xchan_bufs_alloc_busdma(xchan); - else - ret = _xchan_bufs_alloc(xchan); + ret = xchan_bufs_alloc_busdma(xchan); + else { + ret = xchan_bufs_alloc_reserved(xchan); + } if (ret != 0) { device_printf(xdma->dev, "%s: Can't allocate bufs.\n", __func__); @@ -169,12 +221,8 @@ xchan_bufs_free(xdma_channel_t *xchan) bus_dmamap_destroy(xchan->dma_tag_bufs, b->map); } bus_dma_tag_destroy(xchan->dma_tag_bufs); - } else { - for (i = 0; i < xchan->xr_num; i++) { - xr = &xchan->xr_mem[i]; - /* TODO: bounce buffer */ - } - } + } else + xchan_bufs_free_reserved(xchan); xchan->flags &= ~XCHAN_BUFS_ALLOCATED; @@ -296,6 +344,11 @@ xchan_seg_done(xdma_channel_t *xchan, bus_dmamap_sync(xchan->dma_tag_bufs, b->map, BUS_DMASYNC_POSTREAD); bus_dmamap_unload(xchan->dma_tag_bufs, b->map); + } else { + if (xr->req_type == XR_TYPE_MBUF && + xr->direction == XDMA_DEV_TO_MEM) + m_copyback(xr->m, 0, st->transferred, + (void *)xr->buf.vaddr); } xr->status.error = st->error; xr->status.transferred = st->transferred; @@ -437,7 +490,13 @@ _xdma_load_data(xdma_channel_t *xchan, struct xdma_req switch (xr->req_type) { case XR_TYPE_MBUF: - seg[0].ds_addr = mtod(m, bus_addr_t); + if ((xchan->caps & XCHAN_CAP_NOBUFS) == 0) { + if (xr->direction == XDMA_MEM_TO_DEV) + m_copydata(m, 0, m->m_pkthdr.len, + (void *)xr->buf.vaddr); + seg[0].ds_addr = (bus_addr_t)xr->buf.paddr; + } else + seg[0].ds_addr = mtod(m, bus_addr_t); seg[0].ds_len = m->m_pkthdr.len; break; case XR_TYPE_BIO: @@ -494,6 +553,7 @@ xdma_process(xdma_channel_t *xchan, xdma = xchan->xdma; n = 0; + c = 0; ret = XDMA_CHANNEL_CAPACITY(xdma->dma_dev, xchan, &capacity); if (ret != 0) { From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:37:37 2019 Return-Path: Delivered-To: svn-src-stable-12@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 96ABA15B4D9A; Tue, 4 Jun 2019 15:37:37 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 42D566ECF7; Tue, 4 Jun 2019 15:37:37 +0000 (UTC) (envelope-from br@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 315E01F7A9; Tue, 4 Jun 2019 15:37:37 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FbbxU038613; Tue, 4 Jun 2019 15:37:37 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54Fbae8038610; Tue, 4 Jun 2019 15:37:36 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041537.x54Fbae8038610@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:37:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348624 - in stable/12/sys/dev: mii xilinx X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: in stable/12/sys/dev: mii xilinx X-SVN-Commit-Revision: 348624 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 42D566ECF7 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:37:37 -0000 Author: br Date: Tue Jun 4 15:37:36 2019 New Revision: 348624 URL: https://svnweb.freebsd.org/changeset/base/348624 Log: MFC r347342: Add driver for Xilinx AXI Ethernet tri-mode (10/100/1000 Mb/s) MAC found in the U.S. Government Furnished Equipment (GFE) 64-bit RISC-V cores. Sponsored by: DARPA, AFRL Added: stable/12/sys/dev/mii/tiphy.h (contents, props changed) stable/12/sys/dev/xilinx/if_xae.c (contents, props changed) stable/12/sys/dev/xilinx/if_xaereg.h (contents, props changed) stable/12/sys/dev/xilinx/if_xaevar.h (contents, props changed) Added: stable/12/sys/dev/mii/tiphy.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/dev/mii/tiphy.h Tue Jun 4 15:37:36 2019 (r348624) @@ -0,0 +1,57 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2019 Ruslan Bukin + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the + * DARPA SSITH 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$ + */ + +/* + * Texas Instruments DP83867IR/CR Robust, High Immunity + * 10/100/1000 Ethernet Physical Layer Transceiver. + */ + +#ifndef _DEV_MII_TIPHY_H_ +#define _DEV_MII_TIPHY_H_ + +#define DP83867_PHYCR 0x10 /* PHY Control Register */ +#define PHYCR_SGMII_EN (1 << 11) +#define DP83867_CFG2 0x14 /* Configuration Register 2 */ +#define CFG2_SPEED_OPT_10M_EN (1 << 6) /* Speed Optimization */ +#define CFG2_SPEED_OPT_ENHANCED_EN (1 << 8) +#define CFG2_SPEED_OPT_ATTEMPT_CNT_S 10 +#define CFG2_SPEED_OPT_ATTEMPT_CNT_M (0x3 << CFG2_SPEED_OPT_ATTEMPT_CNT_S) +#define CFG2_SPEED_OPT_ATTEMPT_CNT_1 (0 << CFG2_SPEED_OPT_ATTEMPT_CNT_S) +#define CFG2_SPEED_OPT_ATTEMPT_CNT_2 (1 << CFG2_SPEED_OPT_ATTEMPT_CNT_S) +#define CFG2_SPEED_OPT_ATTEMPT_CNT_4 (2 << CFG2_SPEED_OPT_ATTEMPT_CNT_S) +#define CFG2_SPEED_OPT_ATTEMPT_CNT_8 (3 << CFG2_SPEED_OPT_ATTEMPT_CNT_S) +#define CFG2_INTERRUPT_POLARITY (1 << 13) /* Int pin is active low. */ +#define DP83867_CFG4 0x31 /* Configuration Register 4 */ + +#endif /* !_DEV_MII_TIPHY_H_ */ Added: stable/12/sys/dev/xilinx/if_xae.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/dev/xilinx/if_xae.c Tue Jun 4 15:37:36 2019 (r348624) @@ -0,0 +1,1097 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2019 Ruslan Bukin + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the + * DARPA SSITH 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 +#include +#include +#include +#include +#include +#include + +#include "miibus_if.h" + +#define READ4(_sc, _reg) \ + bus_read_4((_sc)->res[0], _reg) +#define WRITE4(_sc, _reg, _val) \ + bus_write_4((_sc)->res[0], _reg, _val) + +#define READ8(_sc, _reg) \ + bus_read_8((_sc)->res[0], _reg) +#define WRITE8(_sc, _reg, _val) \ + bus_write_8((_sc)->res[0], _reg, _val) + +#define XAE_LOCK(sc) mtx_lock(&(sc)->mtx) +#define XAE_UNLOCK(sc) mtx_unlock(&(sc)->mtx) +#define XAE_ASSERT_LOCKED(sc) mtx_assert(&(sc)->mtx, MA_OWNED) +#define XAE_ASSERT_UNLOCKED(sc) mtx_assert(&(sc)->mtx, MA_NOTOWNED) + +#define XAE_DEBUG +#undef XAE_DEBUG + +#ifdef XAE_DEBUG +#define dprintf(fmt, ...) printf(fmt, ##__VA_ARGS__) +#else +#define dprintf(fmt, ...) +#endif + +#define RX_QUEUE_SIZE 64 +#define TX_QUEUE_SIZE 64 +#define NUM_RX_MBUF 16 +#define BUFRING_SIZE 8192 +#define MDIO_CLK_DIV_DEFAULT 29 + +#define PHY1_RD(sc, _r) \ + xae_miibus_read_reg(sc->dev, 1, _r) +#define PHY1_WR(sc, _r, _v) \ + xae_miibus_write_reg(sc->dev, 1, _r, _v) + +#define PHY_RD(sc, _r) \ + xae_miibus_read_reg(sc->dev, sc->phy_addr, _r) +#define PHY_WR(sc, _r, _v) \ + xae_miibus_write_reg(sc->dev, sc->phy_addr, _r, _v) + +/* Use this macro to access regs > 0x1f */ +#define WRITE_TI_EREG(sc, reg, data) { \ + PHY_WR(sc, MII_MMDACR, MMDACR_DADDRMASK); \ + PHY_WR(sc, MII_MMDAADR, reg); \ + PHY_WR(sc, MII_MMDACR, MMDACR_DADDRMASK | MMDACR_FN_DATANPI); \ + PHY_WR(sc, MII_MMDAADR, data); \ +} + +/* Not documented, Xilinx VCU118 workaround */ +#define CFG4_SGMII_TMR 0x160 /* bits 8:7 MUST be '10' */ +#define DP83867_SGMIICTL1 0xD3 /* not documented register */ +#define SGMIICTL1_SGMII_6W (1 << 14) /* no idea what it is */ + +static struct resource_spec xae_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE }, + { -1, 0 } +}; + +static void xae_stop_locked(struct xae_softc *sc); +static void xae_setup_rxfilter(struct xae_softc *sc); + +static int +xae_rx_enqueue(struct xae_softc *sc, uint32_t n) +{ + struct mbuf *m; + int i; + + for (i = 0; i < n; i++) { + m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); + if (m == NULL) { + device_printf(sc->dev, + "%s: Can't alloc rx mbuf\n", __func__); + return (-1); + } + + m->m_pkthdr.len = m->m_len = m->m_ext.ext_size; + xdma_enqueue_mbuf(sc->xchan_rx, &m, 0, 4, 4, XDMA_DEV_TO_MEM); + } + + return (0); +} + +static int +xae_get_phyaddr(phandle_t node, int *phy_addr) +{ + phandle_t phy_node; + pcell_t phy_handle, phy_reg; + + if (OF_getencprop(node, "phy-handle", (void *)&phy_handle, + sizeof(phy_handle)) <= 0) + return (ENXIO); + + phy_node = OF_node_from_xref(phy_handle); + + if (OF_getencprop(phy_node, "reg", (void *)&phy_reg, + sizeof(phy_reg)) <= 0) + return (ENXIO); + + *phy_addr = phy_reg; + + return (0); +} + +static int +xae_xdma_tx_intr(void *arg, xdma_transfer_status_t *status) +{ + xdma_transfer_status_t st; + struct xae_softc *sc; + struct ifnet *ifp; + struct mbuf *m; + int err; + + sc = arg; + + XAE_LOCK(sc); + + ifp = sc->ifp; + + for (;;) { + err = xdma_dequeue_mbuf(sc->xchan_tx, &m, &st); + if (err != 0) { + break; + } + + if (st.error != 0) { + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); + } + + m_freem(m); + } + + ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + + XAE_UNLOCK(sc); + + return (0); +} + +static int +xae_xdma_rx_intr(void *arg, xdma_transfer_status_t *status) +{ + xdma_transfer_status_t st; + struct xae_softc *sc; + struct ifnet *ifp; + struct mbuf *m; + int err; + uint32_t cnt_processed; + + sc = arg; + + dprintf("%s\n", __func__); + + XAE_LOCK(sc); + + ifp = sc->ifp; + + cnt_processed = 0; + for (;;) { + err = xdma_dequeue_mbuf(sc->xchan_rx, &m, &st); + if (err != 0) { + break; + } + cnt_processed++; + + if (st.error != 0) { + if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); + m_freem(m); + continue; + } + + m->m_pkthdr.len = m->m_len = st.transferred; + m->m_pkthdr.rcvif = ifp; + XAE_UNLOCK(sc); + (*ifp->if_input)(ifp, m); + XAE_LOCK(sc); + } + + xae_rx_enqueue(sc, cnt_processed); + + XAE_UNLOCK(sc); + + return (0); +} + +static void +xae_qflush(struct ifnet *ifp) +{ + struct xae_softc *sc; + + sc = ifp->if_softc; +} + +static int +xae_transmit_locked(struct ifnet *ifp) +{ + struct xae_softc *sc; + struct mbuf *m; + struct buf_ring *br; + int error; + int enq; + + dprintf("%s\n", __func__); + + sc = ifp->if_softc; + br = sc->br; + + enq = 0; + + while ((m = drbr_peek(ifp, br)) != NULL) { + error = xdma_enqueue_mbuf(sc->xchan_tx, + &m, 0, 4, 4, XDMA_MEM_TO_DEV); + if (error != 0) { + /* No space in request queue available yet. */ + drbr_putback(ifp, br, m); + break; + } + + drbr_advance(ifp, br); + + enq++; + + /* If anyone is interested give them a copy. */ + ETHER_BPF_MTAP(ifp, m); + } + + if (enq > 0) + xdma_queue_submit(sc->xchan_tx); + + return (0); +} + +static int +xae_transmit(struct ifnet *ifp, struct mbuf *m) +{ + struct xae_softc *sc; + int error; + + dprintf("%s\n", __func__); + + sc = ifp->if_softc; + + XAE_LOCK(sc); + + error = drbr_enqueue(ifp, sc->br, m); + if (error) { + XAE_UNLOCK(sc); + return (error); + } + + if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + IFF_DRV_RUNNING) { + XAE_UNLOCK(sc); + return (0); + } + + if (!sc->link_is_up) { + XAE_UNLOCK(sc); + return (0); + } + + error = xae_transmit_locked(ifp); + + XAE_UNLOCK(sc); + + return (error); +} + +static void +xae_stop_locked(struct xae_softc *sc) +{ + struct ifnet *ifp; + uint32_t reg; + + XAE_ASSERT_LOCKED(sc); + + ifp = sc->ifp; + ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + + callout_stop(&sc->xae_callout); + + /* Stop the transmitter */ + reg = READ4(sc, XAE_TC); + reg &= ~TC_TX; + WRITE4(sc, XAE_TC, reg); + + /* Stop the receiver. */ + reg = READ4(sc, XAE_RCW1); + reg &= ~RCW1_RX; + WRITE4(sc, XAE_RCW1, reg); +} + +static uint64_t +xae_stat(struct xae_softc *sc, int counter_id) +{ + uint64_t new, old; + uint64_t delta; + + KASSERT(counter_id < XAE_MAX_COUNTERS, + ("counter %d is out of range", counter_id)); + + new = READ8(sc, XAE_STATCNT(counter_id)); + old = sc->counters[counter_id]; + + if (new >= old) + delta = new - old; + else + delta = UINT64_MAX - old + new; + sc->counters[counter_id] = new; + + return (delta); +} + +static void +xae_harvest_stats(struct xae_softc *sc) +{ + struct ifnet *ifp; + + ifp = sc->ifp; + + if_inc_counter(ifp, IFCOUNTER_IPACKETS, xae_stat(sc, RX_GOOD_FRAMES)); + if_inc_counter(ifp, IFCOUNTER_IMCASTS, xae_stat(sc, RX_GOOD_MCASTS)); + if_inc_counter(ifp, IFCOUNTER_IERRORS, + xae_stat(sc, RX_FRAME_CHECK_SEQ_ERROR) + + xae_stat(sc, RX_LEN_OUT_OF_RANGE) + + xae_stat(sc, RX_ALIGNMENT_ERRORS)); + + if_inc_counter(ifp, IFCOUNTER_OBYTES, xae_stat(sc, TX_BYTES)); + if_inc_counter(ifp, IFCOUNTER_OPACKETS, xae_stat(sc, TX_GOOD_FRAMES)); + if_inc_counter(ifp, IFCOUNTER_OMCASTS, xae_stat(sc, TX_GOOD_MCASTS)); + if_inc_counter(ifp, IFCOUNTER_OERRORS, + xae_stat(sc, TX_GOOD_UNDERRUN_ERRORS)); + + if_inc_counter(ifp, IFCOUNTER_COLLISIONS, + xae_stat(sc, TX_SINGLE_COLLISION_FRAMES) + + xae_stat(sc, TX_MULTI_COLLISION_FRAMES) + + xae_stat(sc, TX_LATE_COLLISIONS) + + xae_stat(sc, TX_EXCESS_COLLISIONS)); +} + +static void +xae_tick(void *arg) +{ + struct xae_softc *sc; + struct ifnet *ifp; + int link_was_up; + + sc = arg; + + XAE_ASSERT_LOCKED(sc); + + ifp = sc->ifp; + + if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) + return; + + /* Gather stats from hardware counters. */ + xae_harvest_stats(sc); + + /* Check the media status. */ + link_was_up = sc->link_is_up; + mii_tick(sc->mii_softc); + if (sc->link_is_up && !link_was_up) + xae_transmit_locked(sc->ifp); + + /* Schedule another check one second from now. */ + callout_reset(&sc->xae_callout, hz, xae_tick, sc); +} + +static void +xae_init_locked(struct xae_softc *sc) +{ + struct ifnet *ifp; + + XAE_ASSERT_LOCKED(sc); + + ifp = sc->ifp; + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + return; + + ifp->if_drv_flags |= IFF_DRV_RUNNING; + + xae_setup_rxfilter(sc); + + /* Enable the transmitter */ + WRITE4(sc, XAE_TC, TC_TX); + + /* Enable the receiver. */ + WRITE4(sc, XAE_RCW1, RCW1_RX); + + /* + * Call mii_mediachg() which will call back into xae_miibus_statchg() + * to set up the remaining config registers based on current media. + */ + mii_mediachg(sc->mii_softc); + callout_reset(&sc->xae_callout, hz, xae_tick, sc); +} + +static void +xae_init(void *arg) +{ + struct xae_softc *sc; + + sc = arg; + + XAE_LOCK(sc); + xae_init_locked(sc); + XAE_UNLOCK(sc); +} + +static void +xae_media_status(struct ifnet * ifp, struct ifmediareq *ifmr) +{ + struct xae_softc *sc; + struct mii_data *mii; + + sc = ifp->if_softc; + mii = sc->mii_softc; + + XAE_LOCK(sc); + mii_pollstat(mii); + ifmr->ifm_active = mii->mii_media_active; + ifmr->ifm_status = mii->mii_media_status; + XAE_UNLOCK(sc); +} + +static int +xae_media_change_locked(struct xae_softc *sc) +{ + + return (mii_mediachg(sc->mii_softc)); +} + +static int +xae_media_change(struct ifnet * ifp) +{ + struct xae_softc *sc; + int error; + + sc = ifp->if_softc; + + XAE_LOCK(sc); + error = xae_media_change_locked(sc); + XAE_UNLOCK(sc); + + return (error); +} + +static void +xae_setup_rxfilter(struct xae_softc *sc) +{ + struct ifmultiaddr *ifma; + struct ifnet *ifp; + uint32_t reg; + uint8_t *ma; + int i; + + XAE_ASSERT_LOCKED(sc); + + ifp = sc->ifp; + + /* + * Set the multicast (group) filter hash. + */ + if ((ifp->if_flags & (IFF_ALLMULTI | IFF_PROMISC)) != 0) { + reg = READ4(sc, XAE_FFC); + reg |= FFC_PM; + WRITE4(sc, XAE_FFC, reg); + } else { + reg = READ4(sc, XAE_FFC); + reg &= ~FFC_PM; + WRITE4(sc, XAE_FFC, reg); + + if_maddr_rlock(ifp); + + i = 0; + CK_STAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; + + if (i >= XAE_MULTICAST_TABLE_SIZE) + break; + + ma = LLADDR((struct sockaddr_dl *)ifma->ifma_addr); + + reg = READ4(sc, XAE_FFC) & 0xffffff00; + reg |= i++; + WRITE4(sc, XAE_FFC, reg); + + reg = (ma[0]); + reg |= (ma[1] << 8); + reg |= (ma[2] << 16); + reg |= (ma[3] << 24); + WRITE4(sc, XAE_FFV(0), reg); + + reg = ma[4]; + reg |= ma[5] << 8; + WRITE4(sc, XAE_FFV(1), reg); + } + if_maddr_runlock(ifp); + } + + /* + * Set the primary address. + */ + reg = sc->macaddr[0]; + reg |= (sc->macaddr[1] << 8); + reg |= (sc->macaddr[2] << 16); + reg |= (sc->macaddr[3] << 24); + WRITE4(sc, XAE_UAW0, reg); + + reg = sc->macaddr[4]; + reg |= (sc->macaddr[5] << 8); + WRITE4(sc, XAE_UAW1, reg); +} + +static int +xae_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +{ + struct xae_softc *sc; + struct mii_data *mii; + struct ifreq *ifr; + int mask, error; + + sc = ifp->if_softc; + ifr = (struct ifreq *)data; + + error = 0; + switch (cmd) { + case SIOCSIFFLAGS: + XAE_LOCK(sc); + if (ifp->if_flags & IFF_UP) { + if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if ((ifp->if_flags ^ sc->if_flags) & + (IFF_PROMISC | IFF_ALLMULTI)) + xae_setup_rxfilter(sc); + } else { + if (!sc->is_detaching) + xae_init_locked(sc); + } + } else { + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + xae_stop_locked(sc); + } + sc->if_flags = ifp->if_flags; + XAE_UNLOCK(sc); + break; + case SIOCADDMULTI: + case SIOCDELMULTI: + if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + XAE_LOCK(sc); + xae_setup_rxfilter(sc); + XAE_UNLOCK(sc); + } + break; + case SIOCSIFMEDIA: + case SIOCGIFMEDIA: + mii = sc->mii_softc; + error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, cmd); + break; + case SIOCSIFCAP: + mask = ifp->if_capenable ^ ifr->ifr_reqcap; + if (mask & IFCAP_VLAN_MTU) { + /* No work to do except acknowledge the change took */ + ifp->if_capenable ^= IFCAP_VLAN_MTU; + } + break; + + default: + error = ether_ioctl(ifp, cmd, data); + break; + } + + return (error); +} + +static void +xae_intr(void *arg) +{ + +} + +static int +xae_get_hwaddr(struct xae_softc *sc, uint8_t *hwaddr) +{ + phandle_t node; + int len; + + node = ofw_bus_get_node(sc->dev); + + /* Check if there is property */ + if ((len = OF_getproplen(node, "local-mac-address")) <= 0) + return (EINVAL); + + if (len != ETHER_ADDR_LEN) + return (EINVAL); + + OF_getprop(node, "local-mac-address", hwaddr, + ETHER_ADDR_LEN); + + return (0); +} + +static int +mdio_wait(struct xae_softc *sc) +{ + uint32_t reg; + int timeout; + + timeout = 200; + + do { + reg = READ4(sc, XAE_MDIO_CTRL); + if (reg & MDIO_CTRL_READY) + break; + DELAY(1); + } while (timeout--); + + if (timeout <= 0) { + printf("Failed to get MDIO ready\n"); + return (1); + } + + return (0); +} + +static int +xae_miibus_read_reg(device_t dev, int phy, int reg) +{ + struct xae_softc *sc; + uint32_t mii; + int rv; + + sc = device_get_softc(dev); + + if (mdio_wait(sc)) + return (0); + + mii = MDIO_CTRL_TX_OP_READ | MDIO_CTRL_INITIATE; + mii |= (reg << MDIO_TX_REGAD_S); + mii |= (phy << MDIO_TX_PHYAD_S); + + WRITE4(sc, XAE_MDIO_CTRL, mii); + + if (mdio_wait(sc)) + return (0); + + rv = READ4(sc, XAE_MDIO_READ); + + return (rv); +} + +static int +xae_miibus_write_reg(device_t dev, int phy, int reg, int val) +{ + struct xae_softc *sc; + uint32_t mii; + + sc = device_get_softc(dev); + + if (mdio_wait(sc)) + return (1); + + mii = MDIO_CTRL_TX_OP_WRITE | MDIO_CTRL_INITIATE; + mii |= (reg << MDIO_TX_REGAD_S); + mii |= (phy << MDIO_TX_PHYAD_S); + + WRITE4(sc, XAE_MDIO_WRITE, val); + WRITE4(sc, XAE_MDIO_CTRL, mii); + + if (mdio_wait(sc)) + return (1); + + return (0); +} + +static void +xae_phy_fixup(struct xae_softc *sc) +{ + uint32_t reg; + device_t dev; + + dev = sc->dev; + + do { + WRITE_TI_EREG(sc, DP83867_SGMIICTL1, SGMIICTL1_SGMII_6W); + PHY_WR(sc, DP83867_PHYCR, PHYCR_SGMII_EN); + + reg = PHY_RD(sc, DP83867_CFG2); + reg &= ~CFG2_SPEED_OPT_ATTEMPT_CNT_M; + reg |= (CFG2_SPEED_OPT_ATTEMPT_CNT_4); + reg |= CFG2_INTERRUPT_POLARITY; + reg |= CFG2_SPEED_OPT_ENHANCED_EN; + reg |= CFG2_SPEED_OPT_10M_EN; + PHY_WR(sc, DP83867_CFG2, reg); + + WRITE_TI_EREG(sc, DP83867_CFG4, CFG4_SGMII_TMR); + PHY_WR(sc, MII_BMCR, + BMCR_AUTOEN | BMCR_FDX | BMCR_SPEED1 | BMCR_RESET); + } while (PHY1_RD(sc, MII_BMCR) == 0x0ffff); + + do { + PHY1_WR(sc, MII_BMCR, + BMCR_AUTOEN | BMCR_FDX | BMCR_SPEED1 | BMCR_STARTNEG); + DELAY(40000); + } while ((PHY1_RD(sc, MII_BMSR) & BMSR_ACOMP) == 0); +} + +static int +setup_xdma(struct xae_softc *sc) +{ + device_t dev; + vmem_t *vmem; + int error; + + dev = sc->dev; + + /* Get xDMA controller */ + sc->xdma_tx = xdma_ofw_get(sc->dev, "tx"); + if (sc->xdma_tx == NULL) { + device_printf(dev, "Could not find DMA controller.\n"); + return (ENXIO); + } + + sc->xdma_rx = xdma_ofw_get(sc->dev, "rx"); + if (sc->xdma_rx == NULL) { + device_printf(dev, "Could not find DMA controller.\n"); + return (ENXIO); + } + + /* Alloc xDMA TX virtual channel. */ + sc->xchan_tx = xdma_channel_alloc(sc->xdma_tx, 0); + if (sc->xchan_tx == NULL) { + device_printf(dev, "Can't alloc virtual DMA TX channel.\n"); + return (ENXIO); + } + + /* Setup interrupt handler. */ + error = xdma_setup_intr(sc->xchan_tx, + xae_xdma_tx_intr, sc, &sc->ih_tx); + if (error) { + device_printf(sc->dev, + "Can't setup xDMA TX interrupt handler.\n"); + return (ENXIO); + } + + /* Alloc xDMA RX virtual channel. */ + sc->xchan_rx = xdma_channel_alloc(sc->xdma_rx, 0); + if (sc->xchan_rx == NULL) { + device_printf(dev, "Can't alloc virtual DMA RX channel.\n"); + return (ENXIO); + } + + /* Setup interrupt handler. */ + error = xdma_setup_intr(sc->xchan_rx, + xae_xdma_rx_intr, sc, &sc->ih_rx); + if (error) { + device_printf(sc->dev, + "Can't setup xDMA RX interrupt handler.\n"); + return (ENXIO); + } + + /* Setup bounce buffer */ + vmem = xdma_get_memory(dev); + if (vmem) { + xchan_set_memory(sc->xchan_tx, vmem); + xchan_set_memory(sc->xchan_rx, vmem); + } + + xdma_prep_sg(sc->xchan_tx, + TX_QUEUE_SIZE, /* xchan requests queue size */ + MCLBYTES, /* maxsegsize */ + 8, /* maxnsegs */ + 16, /* alignment */ + 0, /* boundary */ + BUS_SPACE_MAXADDR_32BIT, + BUS_SPACE_MAXADDR); + + xdma_prep_sg(sc->xchan_rx, + RX_QUEUE_SIZE, /* xchan requests queue size */ + MCLBYTES, /* maxsegsize */ + 1, /* maxnsegs */ + 16, /* alignment */ + 0, /* boundary */ + BUS_SPACE_MAXADDR_32BIT, + BUS_SPACE_MAXADDR); + + return (0); +} + +static int +xae_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "xlnx,axi-ethernet-1.00.a")) + return (ENXIO); + + device_set_desc(dev, "Xilinx AXI Ethernet"); + + return (BUS_PROBE_DEFAULT); +} + +static int +xae_attach(device_t dev) +{ + struct xae_softc *sc; + struct ifnet *ifp; + phandle_t node; + uint32_t reg; + int error; + + sc = device_get_softc(dev); + sc->dev = dev; + node = ofw_bus_get_node(dev); + + if (setup_xdma(sc) != 0) { + device_printf(dev, "Could not setup xDMA.\n"); + return (ENXIO); + } + + mtx_init(&sc->mtx, device_get_nameunit(sc->dev), + MTX_NETWORK_LOCK, MTX_DEF); + + sc->br = buf_ring_alloc(BUFRING_SIZE, M_DEVBUF, + M_NOWAIT, &sc->mtx); + if (sc->br == NULL) + return (ENOMEM); + + if (bus_alloc_resources(dev, xae_spec, sc->res)) { + device_printf(dev, "could not allocate resources\n"); + return (ENXIO); + } + + /* Memory interface */ + sc->bst = rman_get_bustag(sc->res[0]); + sc->bsh = rman_get_bushandle(sc->res[0]); + + device_printf(sc->dev, "Identification: %x\n", + READ4(sc, XAE_IDENT)); + + /* Get MAC addr */ + if (xae_get_hwaddr(sc, sc->macaddr)) { + device_printf(sc->dev, "can't get mac\n"); + return (ENXIO); + } + + /* Enable MII clock */ + reg = (MDIO_CLK_DIV_DEFAULT << MDIO_SETUP_CLK_DIV_S); + reg |= MDIO_SETUP_ENABLE; + WRITE4(sc, XAE_MDIO_SETUP, reg); + if (mdio_wait(sc)) + return (ENXIO); + + callout_init_mtx(&sc->xae_callout, &sc->mtx, 0); + + /* Setup interrupt handler. */ + error = bus_setup_intr(dev, sc->res[1], INTR_TYPE_NET | INTR_MPSAFE, + NULL, xae_intr, sc, &sc->intr_cookie); + if (error != 0) { + device_printf(dev, "could not setup interrupt handler.\n"); + return (ENXIO); + } + + /* Set up the ethernet interface. */ + sc->ifp = ifp = if_alloc(IFT_ETHER); + if (ifp == NULL) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:39:29 2019 Return-Path: Delivered-To: svn-src-stable-12@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 7325215B4EC1; Tue, 4 Jun 2019 15:39:29 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 22D156EEA5; Tue, 4 Jun 2019 15:39:29 +0000 (UTC) (envelope-from br@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 F0E151F7B5; Tue, 4 Jun 2019 15:39:28 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FdSJL038752; Tue, 4 Jun 2019 15:39:28 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FdSwl038749; Tue, 4 Jun 2019 15:39:28 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041539.x54FdSwl038749@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:39:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348625 - stable/12/sys/dev/xilinx X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: stable/12/sys/dev/xilinx X-SVN-Commit-Revision: 348625 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 22D156EEA5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:39:29 -0000 Author: br Date: Tue Jun 4 15:39:28 2019 New Revision: 348625 URL: https://svnweb.freebsd.org/changeset/base/348625 Log: MFC r347344: Add driver for the Xilinx AXI Direct Memory Access (AXI DMA) controller found in the U.S. Government Furnished Equipment (GFE) 64-bit RISC-V cores. Sponsored by: DARPA, AFRL Added: stable/12/sys/dev/xilinx/axidma.c (contents, props changed) stable/12/sys/dev/xilinx/axidma.h (contents, props changed) Added: stable/12/sys/dev/xilinx/axidma.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/dev/xilinx/axidma.c Tue Jun 4 15:39:28 2019 (r348625) @@ -0,0 +1,648 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2019 Ruslan Bukin + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the + * DARPA SSITH 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. + */ + +/* Xilinx AXI DMA controller driver. */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_platform.h" +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#ifdef FDT +#include +#include +#include +#endif + +#include +#include + +#include "xdma_if.h" + +#define AXIDMA_DEBUG +#undef AXIDMA_DEBUG + +#ifdef AXIDMA_DEBUG +#define dprintf(fmt, ...) printf(fmt, ##__VA_ARGS__) +#else +#define dprintf(fmt, ...) +#endif + +#define AXIDMA_NCHANNELS 2 +#define AXIDMA_DESCS_NUM 512 +#define AXIDMA_TX_CHAN 0 +#define AXIDMA_RX_CHAN 1 + +extern struct bus_space memmap_bus; + +struct axidma_fdt_data { + int id; +}; + +struct axidma_channel { + struct axidma_softc *sc; + xdma_channel_t *xchan; + bool used; + int idx_head; + int idx_tail; + + struct axidma_desc **descs; + vm_paddr_t *descs_phys; + uint32_t descs_num; + + vm_size_t mem_size; + vm_offset_t mem_paddr; + vm_offset_t mem_vaddr; + + uint32_t descs_used_count; +}; + +struct axidma_softc { + device_t dev; + struct resource *res[3]; + bus_space_tag_t bst; + bus_space_handle_t bsh; + void *ih[2]; + struct axidma_desc desc; + struct axidma_channel channels[AXIDMA_NCHANNELS]; +}; + +static struct resource_spec axidma_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 1, RF_ACTIVE }, + { -1, 0 } +}; + +#define HWTYPE_NONE 0 +#define HWTYPE_STD 1 + +static struct ofw_compat_data compat_data[] = { + { "xlnx,eth-dma", HWTYPE_STD }, + { NULL, HWTYPE_NONE }, +}; + +static int axidma_probe(device_t dev); +static int axidma_attach(device_t dev); +static int axidma_detach(device_t dev); + +static inline uint32_t +axidma_next_desc(struct axidma_channel *chan, uint32_t curidx) +{ + + return ((curidx + 1) % chan->descs_num); +} + +static void +axidma_intr(struct axidma_softc *sc, + struct axidma_channel *chan) +{ + xdma_transfer_status_t status; + xdma_transfer_status_t st; + struct axidma_fdt_data *data; + xdma_controller_t *xdma; + struct axidma_desc *desc; + struct xdma_channel *xchan; + uint32_t tot_copied; + int pending; + int errors; + + xchan = chan->xchan; + xdma = xchan->xdma; + data = xdma->data; + + pending = READ4(sc, AXI_DMASR(data->id)); + WRITE4(sc, AXI_DMASR(data->id), pending); + + errors = (pending & (DMASR_DMAINTERR | DMASR_DMASLVERR + | DMASR_DMADECOREERR | DMASR_SGINTERR + | DMASR_SGSLVERR | DMASR_SGDECERR)); + + dprintf("%s: AXI_DMASR %x\n", __func__, + READ4(sc, AXI_DMASR(data->id))); + dprintf("%s: AXI_CURDESC %x\n", __func__, + READ4(sc, AXI_CURDESC(data->id))); + dprintf("%s: AXI_TAILDESC %x\n", __func__, + READ4(sc, AXI_TAILDESC(data->id))); + + tot_copied = 0; + + while (chan->idx_tail != chan->idx_head) { + desc = chan->descs[chan->idx_tail]; + if ((desc->status & BD_STATUS_CMPLT) == 0) + break; + + st.error = errors; + st.transferred = desc->status & BD_CONTROL_LEN_M; + tot_copied += st.transferred; + xchan_seg_done(xchan, &st); + + chan->idx_tail = axidma_next_desc(chan, chan->idx_tail); + atomic_subtract_int(&chan->descs_used_count, 1); + } + + /* Finish operation */ + status.error = errors; + status.transferred = tot_copied; + xdma_callback(chan->xchan, &status); +} + +static void +axidma_intr_rx(void *arg) +{ + struct axidma_softc *sc; + struct axidma_channel *chan; + + dprintf("%s\n", __func__); + + sc = arg; + chan = &sc->channels[AXIDMA_RX_CHAN]; + + axidma_intr(sc, chan); +} + +static void +axidma_intr_tx(void *arg) +{ + struct axidma_softc *sc; + struct axidma_channel *chan; + + dprintf("%s\n", __func__); + + sc = arg; + chan = &sc->channels[AXIDMA_TX_CHAN]; + + axidma_intr(sc, chan); +} + +static int +axidma_reset(struct axidma_softc *sc, int chan_id) +{ + int timeout; + + WRITE4(sc, AXI_DMACR(chan_id), DMACR_RESET); + + timeout = 100; + do { + if ((READ4(sc, AXI_DMACR(chan_id)) & DMACR_RESET) == 0) + break; + } while (timeout--); + + dprintf("timeout %d\n", timeout); + + if (timeout == 0) + return (-1); + + dprintf("%s: read control after reset: %x\n", + __func__, READ4(sc, AXI_DMACR(chan_id))); + + return (0); +} + +static int +axidma_probe(device_t dev) +{ + int hwtype; + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + hwtype = ofw_bus_search_compatible(dev, compat_data)->ocd_data; + if (hwtype == HWTYPE_NONE) + return (ENXIO); + + device_set_desc(dev, "Xilinx AXI DMA"); + + return (BUS_PROBE_DEFAULT); +} + +static int +axidma_attach(device_t dev) +{ + struct axidma_softc *sc; + phandle_t xref, node; + int err; + + sc = device_get_softc(dev); + sc->dev = dev; + + if (bus_alloc_resources(dev, axidma_spec, sc->res)) { + device_printf(dev, "could not allocate resources.\n"); + return (ENXIO); + } + + /* CSR memory interface */ + sc->bst = rman_get_bustag(sc->res[0]); + sc->bsh = rman_get_bushandle(sc->res[0]); + + /* Setup interrupt handler */ + err = bus_setup_intr(dev, sc->res[1], INTR_TYPE_MISC | INTR_MPSAFE, + NULL, axidma_intr_tx, sc, &sc->ih[0]); + if (err) { + device_printf(dev, "Unable to alloc interrupt resource.\n"); + return (ENXIO); + } + + /* Setup interrupt handler */ + err = bus_setup_intr(dev, sc->res[2], INTR_TYPE_MISC | INTR_MPSAFE, + NULL, axidma_intr_rx, sc, &sc->ih[1]); + if (err) { + device_printf(dev, "Unable to alloc interrupt resource.\n"); + return (ENXIO); + } + + node = ofw_bus_get_node(dev); + xref = OF_xref_from_node(node); + OF_device_register_xref(xref, dev); + + return (0); +} + +static int +axidma_detach(device_t dev) +{ + struct axidma_softc *sc; + + sc = device_get_softc(dev); + + bus_teardown_intr(dev, sc->res[1], sc->ih[0]); + bus_teardown_intr(dev, sc->res[2], sc->ih[1]); + bus_release_resources(dev, axidma_spec, sc->res); + + return (0); +} + +static int +axidma_desc_free(struct axidma_softc *sc, struct axidma_channel *chan) +{ + struct xdma_channel *xchan; + int nsegments; + + nsegments = chan->descs_num; + xchan = chan->xchan; + + free(chan->descs, M_DEVBUF); + free(chan->descs_phys, M_DEVBUF); + + pmap_kremove_device(chan->mem_vaddr, chan->mem_size); + kva_free(chan->mem_vaddr, chan->mem_size); + vmem_free(xchan->vmem, chan->mem_paddr, chan->mem_size); + + return (0); +} + +static int +axidma_desc_alloc(struct axidma_softc *sc, struct xdma_channel *xchan, + uint32_t desc_size) +{ + struct axidma_channel *chan; + int nsegments; + int i; + + chan = (struct axidma_channel *)xchan->chan; + nsegments = chan->descs_num; + + chan->descs = malloc(nsegments * sizeof(struct axidma_desc *), + M_DEVBUF, M_NOWAIT | M_ZERO); + if (chan->descs == NULL) { + device_printf(sc->dev, + "%s: Can't allocate memory.\n", __func__); + return (-1); + } + + chan->descs_phys = malloc(nsegments * sizeof(bus_dma_segment_t), + M_DEVBUF, M_NOWAIT | M_ZERO); + chan->mem_size = desc_size * nsegments; + if (vmem_alloc(xchan->vmem, chan->mem_size, M_FIRSTFIT | M_NOWAIT, + &chan->mem_paddr)) { + device_printf(sc->dev, "Failed to allocate memory.\n"); + return (-1); + } + chan->mem_vaddr = kva_alloc(chan->mem_size); + pmap_kenter_device(chan->mem_vaddr, chan->mem_size, chan->mem_paddr); + + device_printf(sc->dev, "Allocated chunk %lx %d\n", + chan->mem_paddr, chan->mem_size); + + for (i = 0; i < nsegments; i++) { + chan->descs[i] = (struct axidma_desc *) + ((uint64_t)chan->mem_vaddr + desc_size * i); + chan->descs_phys[i] = chan->mem_paddr + desc_size * i; + } + + return (0); +} + +static int +axidma_channel_alloc(device_t dev, struct xdma_channel *xchan) +{ + xdma_controller_t *xdma; + struct axidma_fdt_data *data; + struct axidma_channel *chan; + struct axidma_softc *sc; + + sc = device_get_softc(dev); + + if (xchan->caps & XCHAN_CAP_BUSDMA) { + device_printf(sc->dev, + "Error: busdma operation is not implemented."); + return (-1); + } + + xdma = xchan->xdma; + data = xdma->data; + + chan = &sc->channels[data->id]; + if (chan->used == false) { + if (axidma_reset(sc, data->id) != 0) + return (-1); + chan->xchan = xchan; + xchan->chan = (void *)chan; + chan->sc = sc; + chan->used = true; + chan->idx_head = 0; + chan->idx_tail = 0; + chan->descs_used_count = 0; + chan->descs_num = AXIDMA_DESCS_NUM; + + return (0); + } + + return (-1); +} + +static int +axidma_channel_free(device_t dev, struct xdma_channel *xchan) +{ + struct axidma_channel *chan; + struct axidma_softc *sc; + + sc = device_get_softc(dev); + + chan = (struct axidma_channel *)xchan->chan; + + axidma_desc_free(sc, chan); + + chan->used = false; + + return (0); +} + +static int +axidma_channel_capacity(device_t dev, xdma_channel_t *xchan, + uint32_t *capacity) +{ + struct axidma_channel *chan; + uint32_t c; + + chan = (struct axidma_channel *)xchan->chan; + + /* At least one descriptor must be left empty. */ + c = (chan->descs_num - chan->descs_used_count - 1); + + *capacity = c; + + return (0); +} + +static int +axidma_channel_submit_sg(device_t dev, struct xdma_channel *xchan, + struct xdma_sglist *sg, uint32_t sg_n) +{ + xdma_controller_t *xdma; + struct axidma_fdt_data *data; + struct axidma_channel *chan; + struct axidma_desc *desc; + struct axidma_softc *sc; + uint32_t src_addr; + uint32_t dst_addr; + uint32_t addr; + uint32_t len; + uint32_t tmp; + int i; + int tail; + + dprintf("%s: sg_n %d\n", __func__, sg_n); + + sc = device_get_softc(dev); + + chan = (struct axidma_channel *)xchan->chan; + xdma = xchan->xdma; + data = xdma->data; + + if (sg_n == 0) + return (0); + + tail = chan->idx_head; + + tmp = 0; + + for (i = 0; i < sg_n; i++) { + src_addr = (uint32_t)sg[i].src_addr; + dst_addr = (uint32_t)sg[i].dst_addr; + len = (uint32_t)sg[i].len; + + dprintf("%s(%d): src %x dst %x len %d\n", __func__, + data->id, src_addr, dst_addr, len); + + desc = chan->descs[chan->idx_head]; + if (sg[i].direction == XDMA_MEM_TO_DEV) + desc->phys = src_addr; + else + desc->phys = dst_addr; + desc->status = 0; + desc->control = len; + if (sg[i].first == 1) + desc->control |= BD_CONTROL_TXSOF; + if (sg[i].last == 1) + desc->control |= BD_CONTROL_TXEOF; + + tmp = chan->idx_head; + + atomic_add_int(&chan->descs_used_count, 1); + chan->idx_head = axidma_next_desc(chan, chan->idx_head); + } + + dprintf("%s(%d): _curdesc %x\n", __func__, data->id, + READ8(sc, AXI_CURDESC(data->id))); + dprintf("%s(%d): _curdesc %x\n", __func__, data->id, + READ8(sc, AXI_CURDESC(data->id))); + dprintf("%s(%d): status %x\n", __func__, data->id, + READ4(sc, AXI_DMASR(data->id))); + + addr = chan->descs_phys[tmp]; + WRITE8(sc, AXI_TAILDESC(data->id), addr); + + return (0); +} + +static int +axidma_channel_prep_sg(device_t dev, struct xdma_channel *xchan) +{ + xdma_controller_t *xdma; + struct axidma_fdt_data *data; + struct axidma_channel *chan; + struct axidma_desc *desc; + struct axidma_softc *sc; + uint32_t addr; + uint32_t reg; + int ret; + int i; + + sc = device_get_softc(dev); + + chan = (struct axidma_channel *)xchan->chan; + xdma = xchan->xdma; + data = xdma->data; + + dprintf("%s(%d)\n", __func__, data->id); + + ret = axidma_desc_alloc(sc, xchan, sizeof(struct axidma_desc)); + if (ret != 0) { + device_printf(sc->dev, + "%s: Can't allocate descriptors.\n", __func__); + return (-1); + } + + for (i = 0; i < chan->descs_num; i++) { + desc = chan->descs[i]; + bzero(desc, sizeof(struct axidma_desc)); + + if (i == (chan->descs_num - 1)) + desc->next = chan->descs_phys[0]; + else + desc->next = chan->descs_phys[i + 1]; + desc->status = 0; + desc->control = 0; + + dprintf("%s(%d): desc %d vaddr %lx next paddr %x\n", __func__, + data->id, i, (uint64_t)desc, le32toh(desc->next)); + } + + addr = chan->descs_phys[0]; + WRITE8(sc, AXI_CURDESC(data->id), addr); + + reg = READ4(sc, AXI_DMACR(data->id)); + reg |= DMACR_IOC_IRQEN | DMACR_DLY_IRQEN | DMACR_ERR_IRQEN; + WRITE4(sc, AXI_DMACR(data->id), reg); + reg |= DMACR_RS; + WRITE4(sc, AXI_DMACR(data->id), reg); + + return (0); +} + +static int +axidma_channel_control(device_t dev, xdma_channel_t *xchan, int cmd) +{ + struct axidma_channel *chan; + struct axidma_softc *sc; + + sc = device_get_softc(dev); + + chan = (struct axidma_channel *)xchan->chan; + + switch (cmd) { + case XDMA_CMD_BEGIN: + case XDMA_CMD_TERMINATE: + case XDMA_CMD_PAUSE: + /* TODO: implement me */ + return (-1); + } + + return (0); +} + +#ifdef FDT +static int +axidma_ofw_md_data(device_t dev, pcell_t *cells, int ncells, void **ptr) +{ + struct axidma_fdt_data *data; + + if (ncells != 1) + return (-1); + + data = malloc(sizeof(struct axidma_fdt_data), + M_DEVBUF, (M_WAITOK | M_ZERO)); + data->id = cells[0]; + + *ptr = data; + + return (0); +} +#endif + +static device_method_t axidma_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, axidma_probe), + DEVMETHOD(device_attach, axidma_attach), + DEVMETHOD(device_detach, axidma_detach), + + /* xDMA Interface */ + DEVMETHOD(xdma_channel_alloc, axidma_channel_alloc), + DEVMETHOD(xdma_channel_free, axidma_channel_free), + DEVMETHOD(xdma_channel_control, axidma_channel_control), + + /* xDMA SG Interface */ + DEVMETHOD(xdma_channel_capacity, axidma_channel_capacity), + DEVMETHOD(xdma_channel_prep_sg, axidma_channel_prep_sg), + DEVMETHOD(xdma_channel_submit_sg, axidma_channel_submit_sg), + +#ifdef FDT + DEVMETHOD(xdma_ofw_md_data, axidma_ofw_md_data), +#endif + + DEVMETHOD_END +}; + +static driver_t axidma_driver = { + "axidma", + axidma_methods, + sizeof(struct axidma_softc), +}; + +static devclass_t axidma_devclass; + +EARLY_DRIVER_MODULE(axidma, simplebus, axidma_driver, axidma_devclass, 0, 0, + BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); Added: stable/12/sys/dev/xilinx/axidma.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/dev/xilinx/axidma.h Tue Jun 4 15:39:28 2019 (r348625) @@ -0,0 +1,96 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2019 Ruslan Bukin + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the + * DARPA SSITH 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$ + */ + +#ifndef _DEV_XILINX_AXIDMA_H_ +#define _DEV_XILINX_AXIDMA_H_ + +#define AXI_DMACR(n) (0x00 + 0x30 * (n)) /* DMA Control register */ +#define DMACR_RS (1 << 0) /* Run / Stop. */ +#define DMACR_RESET (1 << 2) /* Soft reset the AXI DMA core. */ +#define DMACR_IOC_IRQEN (1 << 12) /* Interrupt on Complete (IOC) Interrupt Enable. */ +#define DMACR_DLY_IRQEN (1 << 13) /* Interrupt on Delay Timer Interrupt Enable. */ +#define DMACR_ERR_IRQEN (1 << 14) /* Interrupt on Error Interrupt Enable. */ +#define AXI_DMASR(n) (0x04 + 0x30 * (n)) /* DMA Status register */ +#define DMASR_HALTED (1 << 0) +#define DMASR_IDLE (1 << 1) +#define DMASR_SGINCLD (1 << 3) /* Scatter Gather Enabled */ +#define DMASR_DMAINTERR (1 << 4) /* DMA Internal Error. */ +#define DMASR_DMASLVERR (1 << 5) /* DMA Slave Error. */ +#define DMASR_DMADECOREERR (1 << 6) /* Decode Error. */ +#define DMASR_SGINTERR (1 << 8) /* Scatter Gather Internal Error. */ +#define DMASR_SGSLVERR (1 << 9) /* Scatter Gather Slave Error. */ +#define DMASR_SGDECERR (1 << 10) /* Scatter Gather Decode Error. */ +#define DMASR_IOC_IRQ (1 << 12) /* Interrupt on Complete. */ +#define DMASR_DLY_IRQ (1 << 13) /* Interrupt on Delay. */ +#define DMASR_ERR_IRQ (1 << 14) /* Interrupt on Error. */ +#define AXI_CURDESC(n) (0x08 + 0x30 * (n)) /* Current Descriptor Pointer. Lower 32 bits of the address. */ +#define AXI_CURDESC_MSB(n) (0x0C + 0x30 * (n)) /* Current Descriptor Pointer. Upper 32 bits of address. */ +#define AXI_TAILDESC(n) (0x10 + 0x30 * (n)) /* Tail Descriptor Pointer. Lower 32 bits. */ +#define AXI_TAILDESC_MSB(n) (0x14 + 0x30 * (n)) /* Tail Descriptor Pointer. Upper 32 bits of address. */ +#define AXI_SG_CTL 0x2C /* Scatter/Gather User and Cache */ + +#define READ4(_sc, _reg) \ + bus_space_read_4(_sc->bst, _sc->bsh, _reg) +#define WRITE4(_sc, _reg, _val) \ + bus_space_write_4(_sc->bst, _sc->bsh, _reg, _val) +#define READ8(_sc, _reg) \ + bus_space_read_8(_sc->bst, _sc->bsh, _reg) +#define WRITE8(_sc, _reg, _val) \ + bus_space_write_8(_sc->bst, _sc->bsh, _reg, _val) + +struct axidma_desc { + uint32_t next; + uint32_t reserved1; + uint32_t phys; + uint32_t reserved2; + uint32_t reserved3; + uint32_t reserved4; + uint32_t control; +#define BD_CONTROL_TXSOF (1 << 27) /* Start of Frame. */ +#define BD_CONTROL_TXEOF (1 << 26) /* End of Frame. */ +#define BD_CONTROL_LEN_S 0 /* Buffer Length. */ +#define BD_CONTROL_LEN_M (0x3ffffff << BD_CONTROL_LEN_S) + uint32_t status; +#define BD_STATUS_CMPLT (1 << 31) +#define BD_STATUS_TRANSFERRED_S 0 +#define BD_STATUS_TRANSFERRED_M (0x7fffff << BD_STATUS_TRANSFERRED_S) + uint32_t app0; + uint32_t app1; + uint32_t app2; + uint32_t app3; + uint32_t app4; + uint32_t reserved[3]; +}; + +#endif /* !_DEV_XILINX_AXIDMA_H_ */ From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:40:31 2019 Return-Path: Delivered-To: svn-src-stable-12@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 B9E0F15B4F87; Tue, 4 Jun 2019 15:40:31 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5B7EA6EFF0; Tue, 4 Jun 2019 15:40:31 +0000 (UTC) (envelope-from br@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 315F31F7BB; Tue, 4 Jun 2019 15:40:31 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FeVo4038929; Tue, 4 Jun 2019 15:40:31 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FeUkQ038928; Tue, 4 Jun 2019 15:40:30 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041540.x54FeUkQ038928@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:40:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348626 - in stable/12/sys: conf riscv/conf X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: in stable/12/sys: conf riscv/conf X-SVN-Commit-Revision: 348626 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5B7EA6EFF0 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.970,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:40:32 -0000 Author: br Date: Tue Jun 4 15:40:30 2019 New Revision: 348626 URL: https://svnweb.freebsd.org/changeset/base/348626 Log: MFC r347351: Connect Xilinx AXI drivers and Cadence Ethernet MAC to the RISC-V build. Sponsored by: DARPA, AFRL Modified: stable/12/sys/conf/files.riscv stable/12/sys/riscv/conf/GENERIC Modified: stable/12/sys/conf/files.riscv ============================================================================== --- stable/12/sys/conf/files.riscv Tue Jun 4 15:39:28 2019 (r348625) +++ stable/12/sys/conf/files.riscv Tue Jun 4 15:40:30 2019 (r348626) @@ -5,10 +5,13 @@ cddl/dev/dtrace/riscv/dtrace_subr.c optional dtrace cddl/dev/fbt/riscv/fbt_isa.c optional dtrace_fbt | dtraceall compile-with "${FBT_C}" crypto/blowfish/bf_enc.c optional crypto | ipsec | ipsec_support crypto/des/des_enc.c optional crypto | ipsec | ipsec_support | netsmb +dev/cadence/if_cgem.c optional cgem dev/ofw/ofw_cpu.c optional fdt dev/uart/uart_cpu_fdt.c optional uart fdt dev/uart/uart_dev_lowrisc.c optional uart_lowrisc dev/xilinx/axi_quad_spi.c optional xilinx_spi +dev/xilinx/axidma.c optional axidma xdma +dev/xilinx/if_xae.c optional xae kern/kern_clocksource.c standard kern/msi_if.m standard kern/pic_if.m standard Modified: stable/12/sys/riscv/conf/GENERIC ============================================================================== --- stable/12/sys/riscv/conf/GENERIC Tue Jun 4 15:39:28 2019 (r348625) +++ stable/12/sys/riscv/conf/GENERIC Tue Jun 4 15:40:30 2019 (r348626) @@ -102,6 +102,16 @@ device uart # Generic UART driver device uart_lowrisc # lowRISC UART driver device uart_ns8250 # ns8250-type UART driver + +# Ethernet drivers +device miibus # MII bus support +device cgem # Cadence Gigabit Ethernet MAC +device xae # Xilinx AXI Ethernet MAC + +# DMA support +device xdma # DMA interface +device axidma # Xilinx AXI DMA Controller + # Uncomment for memory disk # options MD_ROOT # options MD_ROOT_SIZE=32768 # 32MB ram disk From owner-svn-src-stable-12@freebsd.org Tue Jun 4 15:42:31 2019 Return-Path: Delivered-To: svn-src-stable-12@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 A9F1115B5283; Tue, 4 Jun 2019 15:42:31 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48F826F487; Tue, 4 Jun 2019 15:42:31 +0000 (UTC) (envelope-from br@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 240111F957; Tue, 4 Jun 2019 15:42:31 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54FgVAG043826; Tue, 4 Jun 2019 15:42:31 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54FgVSS043811; Tue, 4 Jun 2019 15:42:31 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041542.x54FgVSS043811@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 15:42:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348627 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348627 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 48F826F487 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.970,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 15:42:31 -0000 Author: br Date: Tue Jun 4 15:42:30 2019 New Revision: 348627 URL: https://svnweb.freebsd.org/changeset/base/348627 Log: MFC r347427: RISC-V ISA does not specify how to manage physical memory attributes (PMA). So do nothing in pmap_page_set_memattr() and don't panic. Sponsored by: DARPA, AFRL Modified: stable/12/sys/riscv/riscv/pmap.c Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 15:40:30 2019 (r348626) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 15:42:30 2019 (r348627) @@ -3122,16 +3122,6 @@ pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma) { m->md.pv_memattr = ma; - - /* - * RISCVTODO: Implement the below (from the amd64 pmap) - * If "m" is a normal page, update its direct mapping. This update - * can be relied upon to perform any cache operations that are - * required for data coherence. - */ - if ((m->flags & PG_FICTITIOUS) == 0 && - PHYS_IN_DMAP(VM_PAGE_TO_PHYS(m))) - panic("RISCVTODO: pmap_page_set_memattr"); } /* From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:19:17 2019 Return-Path: Delivered-To: svn-src-stable-12@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 6412F15B7CFB; Tue, 4 Jun 2019 17:19:17 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 05BB77359E; Tue, 4 Jun 2019 17:19:17 +0000 (UTC) (envelope-from markj@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 CECCC20928; Tue, 4 Jun 2019 17:19:16 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HJGO7092076; Tue, 4 Jun 2019 17:19:16 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HJGG4092075; Tue, 4 Jun 2019 17:19:16 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041719.x54HJGG4092075@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:19:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348632 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348632 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 05BB77359E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:19:17 -0000 Author: markj Date: Tue Jun 4 17:19:16 2019 New Revision: 348632 URL: https://svnweb.freebsd.org/changeset/base/348632 Log: MFC r342766: Don't enable interrupts in init_secondary(). Modified: stable/12/sys/riscv/riscv/mp_machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/mp_machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/mp_machdep.c Tue Jun 4 16:40:18 2019 (r348631) +++ stable/12/sys/riscv/riscv/mp_machdep.c Tue Jun 4 17:19:16 2019 (r348632) @@ -227,7 +227,6 @@ init_secondary(uint64_t cpu) __asm __volatile("mv gp, %0" :: "r"(pcpup)); /* Workaround: make sure wfi doesn't halt the hart */ - intr_disable(); csr_set(sie, SIE_SSIE); csr_set(sip, SIE_SSIE); @@ -252,9 +251,6 @@ init_secondary(uint64_t cpu) /* Start per-CPU event timers. */ cpu_initclocks_ap(); - - /* Enable interrupts */ - intr_enable(); /* Enable external (PLIC) interrupts */ csr_set(sie, SIE_SEIE); From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:20:35 2019 Return-Path: Delivered-To: svn-src-stable-12@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 9220515B7DAC; Tue, 4 Jun 2019 17:20:35 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 31951736ED; Tue, 4 Jun 2019 17:20:35 +0000 (UTC) (envelope-from markj@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 0B8AD2092D; Tue, 4 Jun 2019 17:20:35 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HKY8N092197; Tue, 4 Jun 2019 17:20:34 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HKYEs092196; Tue, 4 Jun 2019 17:20:34 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041720.x54HKYEs092196@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:20:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348633 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348633 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 31951736ED X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:20:35 -0000 Author: markj Date: Tue Jun 4 17:20:34 2019 New Revision: 348633 URL: https://svnweb.freebsd.org/changeset/base/348633 Log: MFC r342732: Use regular stores to update PTEs in the riscv pmap layer. Modified: stable/12/sys/riscv/riscv/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:19:16 2019 (r348632) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:20:34 2019 (r348633) @@ -257,15 +257,13 @@ static void _pmap_unwire_l3(pmap_t pmap, vm_offset_t v struct spglist *free); static int pmap_unuse_l3(pmap_t, vm_offset_t, pd_entry_t, struct spglist *); -/* - * These load the old table data and store the new value. - * They need to be atomic as the System MMU may write to the table at - * the same time as the CPU. - */ -#define pmap_load_store(table, entry) atomic_swap_64(table, entry) -#define pmap_set(table, mask) atomic_set_64(table, mask) -#define pmap_load_clear(table) atomic_swap_64(table, 0) -#define pmap_load(table) (*table) +#define pmap_clear(pte) pmap_store(pte, 0) +#define pmap_clear_bits(pte, bits) atomic_clear_64(pte, bits) +#define pmap_load_store(pte, entry) atomic_swap_64(pte, entry) +#define pmap_load_clear(pte) pmap_load_store(pte, 0) +#define pmap_load(pte) atomic_load_64(pte) +#define pmap_store(pte, entry) atomic_store_64(pte, entry) +#define pmap_store_bits(pte, bits) atomic_set_64(pte, bits) /********************/ /* Inline functions */ @@ -384,10 +382,7 @@ pmap_distribute_l1(struct pmap *pmap, vm_pindex_t l1in LIST_FOREACH(user_pmap, &allpmaps, pm_list) { l1 = &user_pmap->pm_l1[l1index]; - if (entry) - pmap_load_store(l1, entry); - else - pmap_load_clear(l1); + pmap_store(l1, entry); } } @@ -455,7 +450,7 @@ pmap_bootstrap_dmap(vm_offset_t kern_l1, vm_paddr_t mi pn = (pa / PAGE_SIZE); entry = PTE_KERN; entry |= (pn << PTE_PPN0_S); - pmap_load_store(&l1[l1_slot], entry); + pmap_store(&l1[l1_slot], entry); } /* Set the upper limit of the DMAP region */ @@ -489,7 +484,7 @@ pmap_bootstrap_l3(vm_offset_t l1pt, vm_offset_t va, vm pn = (pa / PAGE_SIZE); entry = (PTE_V); entry |= (pn << PTE_PPN0_S); - pmap_load_store(&l2[l2_slot], entry); + pmap_store(&l2[l2_slot], entry); l3pt += PAGE_SIZE; } @@ -875,7 +870,7 @@ pmap_kenter_device(vm_offset_t sva, vm_size_t size, vm pn = (pa / PAGE_SIZE); entry = PTE_KERN; entry |= (pn << PTE_PPN0_S); - pmap_load_store(l3, entry); + pmap_store(l3, entry); va += PAGE_SIZE; pa += PAGE_SIZE; @@ -896,8 +891,7 @@ pmap_kremove(vm_offset_t va) l3 = pmap_l3(kernel_pmap, va); KASSERT(l3 != NULL, ("pmap_kremove: Invalid address")); - pmap_load_clear(l3); - + pmap_clear(l3); sfence_vma(); } @@ -916,7 +910,7 @@ pmap_kremove_device(vm_offset_t sva, vm_size_t size) while (size != 0) { l3 = pmap_l3(kernel_pmap, va); KASSERT(l3 != NULL, ("Invalid page table, va: 0x%lx", va)); - pmap_load_clear(l3); + pmap_clear(l3); va += PAGE_SIZE; size -= PAGE_SIZE; @@ -973,7 +967,7 @@ pmap_qenter(vm_offset_t sva, vm_page_t *ma, int count) entry = PTE_KERN; entry |= (pn << PTE_PPN0_S); - pmap_load_store(l3, entry); + pmap_store(l3, entry); va += L3_SIZE; } @@ -993,14 +987,10 @@ pmap_qremove(vm_offset_t sva, int count) KASSERT(sva >= VM_MIN_KERNEL_ADDRESS, ("usermode va %lx", sva)); - va = sva; - while (count-- > 0) { + for (va = sva; count-- > 0; va += PAGE_SIZE) { l3 = pmap_l3(kernel_pmap, va); KASSERT(l3 != NULL, ("pmap_kremove: Invalid address")); - - pmap_load_clear(l3); - - va += PAGE_SIZE; + pmap_clear(l3); } pmap_invalidate_range(kernel_pmap, sva, va); } @@ -1057,13 +1047,13 @@ _pmap_unwire_l3(pmap_t pmap, vm_offset_t va, vm_page_t /* PD page */ pd_entry_t *l1; l1 = pmap_l1(pmap, va); - pmap_load_clear(l1); + pmap_clear(l1); pmap_distribute_l1(pmap, pmap_l1_index(va), 0); } else { /* PTE page */ pd_entry_t *l2; l2 = pmap_l2(pmap, va); - pmap_load_clear(l2); + pmap_clear(l2); } pmap_resident_count_dec(pmap, 1); if (m->pindex < NUPDE) { @@ -1207,7 +1197,7 @@ _pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex, str pn = (VM_PAGE_TO_PHYS(m) / PAGE_SIZE); entry = (PTE_V); entry |= (pn << PTE_PPN0_S); - pmap_load_store(l1, entry); + pmap_store(l1, entry); pmap_distribute_l1(pmap, l1index, entry); } else { vm_pindex_t l1index; @@ -1236,7 +1226,7 @@ _pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex, str pn = (VM_PAGE_TO_PHYS(m) / PAGE_SIZE); entry = (PTE_V); entry |= (pn << PTE_PPN0_S); - pmap_load_store(l2, entry); + pmap_store(l2, entry); } pmap_resident_count_inc(pmap, 1); @@ -1367,7 +1357,7 @@ pmap_growkernel(vm_offset_t addr) pn = (paddr / PAGE_SIZE); entry = (PTE_V); entry |= (pn << PTE_PPN0_S); - pmap_load_store(l1, entry); + pmap_store(l1, entry); pmap_distribute_l1(kernel_pmap, pmap_l1_index(kernel_vm_end), entry); continue; /* try again */ @@ -1396,7 +1386,7 @@ pmap_growkernel(vm_offset_t addr) pn = (paddr / PAGE_SIZE); entry = (PTE_V); entry |= (pn << PTE_PPN0_S); - pmap_load_store(l2, entry); + pmap_store(l2, entry); pmap_invalidate_page(kernel_pmap, kernel_vm_end); @@ -1908,7 +1898,7 @@ pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t if ((l3 & PTE_V) != 0) { entry = pmap_load(l3p); entry &= ~PTE_W; - pmap_load_store(l3p, entry); + pmap_store(l3p, entry); /* XXX: Use pmap_invalidate_range */ pmap_invalidate_page(pmap, sva); } @@ -1944,7 +1934,7 @@ pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_ new_l3 |= PTE_D; if (orig_l3 != new_l3) { - pmap_load_store(l3, new_l3); + pmap_store(l3, new_l3); pmap_invalidate_page(pmap, va); rv = 1; goto done; @@ -2050,7 +2040,7 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, v l1 = pmap_l1(pmap, va); entry = (PTE_V); entry |= (l2_pn << PTE_PPN0_S); - pmap_load_store(l1, entry); + pmap_store(l1, entry); pmap_distribute_l1(pmap, pmap_l1_index(va), entry); l2 = pmap_l1_to_l2(l1, va); } @@ -2069,7 +2059,7 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, v l3_pn = (l3_pa / PAGE_SIZE); entry = (PTE_V); entry |= (l3_pn << PTE_PPN0_S); - pmap_load_store(l2, entry); + pmap_store(l2, entry); l3 = pmap_l2_to_l3(l2, va); } pmap_invalidate_page(pmap, va); @@ -2197,7 +2187,7 @@ validate: (PTE_D | PTE_SW_MANAGED)) vm_page_dirty(m); } else { - pmap_load_store(l3, new_l3); + pmap_store(l3, new_l3); } if (lock != NULL) @@ -2278,10 +2268,7 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, v struct spglist free; vm_paddr_t phys; pd_entry_t *l2; - pt_entry_t *l3; - vm_paddr_t pa; - pt_entry_t entry; - pn_t pn; + pt_entry_t *l3, newl3; KASSERT(va < kmi.clean_sva || va >= kmi.clean_eva || (m->oflags & VPO_UNMANAGED) != 0, @@ -2385,7 +2372,7 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, v if (prot & VM_PROT_EXECUTE) pmap_sync_icache(pmap, va, PAGE_SIZE); - pmap_load_store(l3, entry); + pmap_store(l3, entry); pmap_invalidate_page(pmap, va); return (mpte); @@ -2728,7 +2715,7 @@ pmap_remove_pages(pmap_t pmap) ("pmap_remove_pages: bad l3 %#jx", (uintmax_t)tl3)); - pmap_load_clear(l3); + pmap_clear(l3); /* * Update the vm_page_t clean/reference bits. From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:23:25 2019 Return-Path: Delivered-To: svn-src-stable-12@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 4528F15B7FDD; Tue, 4 Jun 2019 17:23:25 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DB4DA73AF6; Tue, 4 Jun 2019 17:23:24 +0000 (UTC) (envelope-from markj@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 B5E3720AC7; Tue, 4 Jun 2019 17:23:24 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HNOTL097444; Tue, 4 Jun 2019 17:23:24 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HNOoL097443; Tue, 4 Jun 2019 17:23:24 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041723.x54HNOoL097443@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:23:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348634 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348634 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: DB4DA73AF6 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:23:25 -0000 Author: markj Date: Tue Jun 4 17:23:24 2019 New Revision: 348634 URL: https://svnweb.freebsd.org/changeset/base/348634 Log: MFC r343529: Remove a redundant test. Modified: stable/12/sys/riscv/riscv/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:20:34 2019 (r348633) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:23:24 2019 (r348634) @@ -2632,7 +2632,7 @@ restart: } } l3 = pmap_l3(pmap, pv->pv_va); - if (l3 != NULL && (pmap_load(l3) & PTE_SW_WIRED) != 0) + if ((pmap_load(l3) & PTE_SW_WIRED) != 0) count++; PMAP_UNLOCK(pmap); } From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:23:59 2019 Return-Path: Delivered-To: svn-src-stable-12@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 90C3D15B8031; Tue, 4 Jun 2019 17:23:59 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 33CDD73C21; Tue, 4 Jun 2019 17:23:59 +0000 (UTC) (envelope-from markj@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 0D14520ACE; Tue, 4 Jun 2019 17:23:59 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HNwiJ097517; Tue, 4 Jun 2019 17:23:58 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HNwae097516; Tue, 4 Jun 2019 17:23:58 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041723.x54HNwae097516@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:23:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348635 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348635 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 33CDD73C21 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:23:59 -0000 Author: markj Date: Tue Jun 4 17:23:58 2019 New Revision: 348635 URL: https://svnweb.freebsd.org/changeset/base/348635 Log: MFC r342734: Fix some issues with the riscv pmap_protect() implementation. Modified: stable/12/sys/riscv/riscv/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:23:24 2019 (r348634) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:23:58 2019 (r348635) @@ -1853,22 +1853,28 @@ pmap_remove_all(vm_page_t m) void pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot) { - vm_offset_t va_next; pd_entry_t *l1, *l2; - pt_entry_t *l3p, l3; - pt_entry_t entry; + pt_entry_t *l3, l3e, mask; + vm_page_t m; + vm_offset_t va_next; if ((prot & VM_PROT_READ) == VM_PROT_NONE) { pmap_remove(pmap, sva, eva); return; } - if ((prot & VM_PROT_WRITE) == VM_PROT_WRITE) + if ((prot & (VM_PROT_WRITE | VM_PROT_EXECUTE)) == + (VM_PROT_WRITE | VM_PROT_EXECUTE)) return; + mask = 0; + if ((prot & VM_PROT_WRITE) == 0) + mask |= PTE_W | PTE_D; + if ((prot & VM_PROT_EXECUTE) == 0) + mask |= PTE_X; + PMAP_LOCK(pmap); for (; sva < eva; sva = va_next) { - l1 = pmap_l1(pmap, sva); if (pmap_load(l1) == 0) { va_next = (sva + L1_SIZE) & ~L1_OFFSET; @@ -1882,26 +1888,30 @@ pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t va_next = eva; l2 = pmap_l1_to_l2(l1, sva); - if (l2 == NULL) + if (l2 == NULL || pmap_load(l2) == 0) continue; - if (pmap_load(l2) == 0) - continue; if ((pmap_load(l2) & PTE_RX) != 0) continue; if (va_next > eva) va_next = eva; - for (l3p = pmap_l2_to_l3(l2, sva); sva != va_next; l3p++, + for (l3 = pmap_l2_to_l3(l2, sva); sva != va_next; l3++, sva += L3_SIZE) { - l3 = pmap_load(l3p); - if ((l3 & PTE_V) != 0) { - entry = pmap_load(l3p); - entry &= ~PTE_W; - pmap_store(l3p, entry); - /* XXX: Use pmap_invalidate_range */ - pmap_invalidate_page(pmap, sva); + l3e = pmap_load(l3); +retry: + if ((l3e & PTE_V) == 0) + continue; + if ((prot & VM_PROT_WRITE) == 0 && + (l3e & (PTE_SW_MANAGED | PTE_D)) == + (PTE_SW_MANAGED | PTE_D)) { + m = PHYS_TO_VM_PAGE(PTE_TO_PHYS(l3e)); + vm_page_dirty(m); } + if (!atomic_fcmpset_long(l3, &l3e, l3e & ~mask)) + goto retry; + /* XXX: Use pmap_invalidate_range */ + pmap_invalidate_page(pmap, sva); } } PMAP_UNLOCK(pmap); From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:24:27 2019 Return-Path: Delivered-To: svn-src-stable-12@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 52A8815B8087; Tue, 4 Jun 2019 17:24:27 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E7243741B7; Tue, 4 Jun 2019 17:24:26 +0000 (UTC) (envelope-from markj@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 C29E120ACF; Tue, 4 Jun 2019 17:24:26 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HOQJ2097583; Tue, 4 Jun 2019 17:24:26 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HOQsH097582; Tue, 4 Jun 2019 17:24:26 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041724.x54HOQsH097582@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:24:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348636 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348636 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E7243741B7 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:24:27 -0000 Author: markj Date: Tue Jun 4 17:24:26 2019 New Revision: 348636 URL: https://svnweb.freebsd.org/changeset/base/348636 Log: MFC r342735: Synchronize access to the allpmaps list. Modified: stable/12/sys/riscv/riscv/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:23:58 2019 (r348635) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:24:26 2019 (r348636) @@ -228,6 +228,7 @@ CTASSERT((DMAP_MIN_ADDRESS & ~L1_OFFSET) == DMAP_MIN_ CTASSERT((DMAP_MAX_ADDRESS & ~L1_OFFSET) == DMAP_MAX_ADDRESS); static struct rwlock_padalign pvh_global_lock; +static struct mtx_padalign allpmaps_lock; /* * Data for the pv entry allocation mechanism @@ -380,10 +381,12 @@ pmap_distribute_l1(struct pmap *pmap, vm_pindex_t l1in if (pmap != kernel_pmap) return; + mtx_lock(&allpmaps_lock); LIST_FOREACH(user_pmap, &allpmaps, pm_list) { l1 = &user_pmap->pm_l1[l1index]; pmap_store(l1, entry); } + mtx_unlock(&allpmaps_lock); } static pt_entry_t * @@ -636,9 +639,10 @@ pmap_init(void) int i; /* - * Initialize the pv chunk list mutex. + * Initialize the pv chunk and pmap list mutexes. */ mtx_init(&pv_chunks_mutex, "pmap pv chunk list", NULL, MTX_DEF); + mtx_init(&allpmaps_lock, "allpmaps", NULL, MTX_DEF); /* * Initialize the pool of pv list locks. @@ -1132,7 +1136,9 @@ pmap_pinit(pmap_t pmap) memcpy(pmap->pm_l1, kernel_pmap->pm_l1, PAGE_SIZE); /* Add to the list of all user pmaps */ + mtx_lock(&allpmaps_lock); LIST_INSERT_HEAD(&allpmaps, pmap, pm_list); + mtx_unlock(&allpmaps_lock); return (1); } @@ -1296,7 +1302,9 @@ pmap_release(pmap_t pmap) vm_page_free_zero(m); /* Remove pmap from the allpmaps list */ + mtx_lock(&allpmaps_lock); LIST_REMOVE(pmap, pm_list); + mtx_unlock(&allpmaps_lock); /* Remove kernel pagetables */ bzero(pmap->pm_l1, PAGE_SIZE); From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:24:54 2019 Return-Path: Delivered-To: svn-src-stable-12@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 E39CC15B80E5; Tue, 4 Jun 2019 17:24:53 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 884C7742E5; Tue, 4 Jun 2019 17:24:53 +0000 (UTC) (envelope-from markj@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 34FF520AD0; Tue, 4 Jun 2019 17:24:53 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HOrYZ097648; Tue, 4 Jun 2019 17:24:53 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HOrOC097647; Tue, 4 Jun 2019 17:24:53 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041724.x54HOrOC097647@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:24:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348637 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348637 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 884C7742E5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:24:54 -0000 Author: markj Date: Tue Jun 4 17:24:52 2019 New Revision: 348637 URL: https://svnweb.freebsd.org/changeset/base/348637 Log: MFC r342736: Fix a use-after-free in the riscv pmap_release() implementation. Modified: stable/12/sys/riscv/riscv/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:24:26 2019 (r348636) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:24:52 2019 (r348637) @@ -1297,17 +1297,13 @@ pmap_release(pmap_t pmap) ("pmap_release: pmap resident count %ld != 0", pmap->pm_stats.resident_count)); - m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pmap->pm_l1)); - vm_page_unwire_noq(m); - vm_page_free_zero(m); - - /* Remove pmap from the allpmaps list */ mtx_lock(&allpmaps_lock); LIST_REMOVE(pmap, pm_list); mtx_unlock(&allpmaps_lock); - /* Remove kernel pagetables */ - bzero(pmap->pm_l1, PAGE_SIZE); + m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pmap->pm_l1)); + vm_page_unwire_noq(m); + vm_page_free(m); } #if 0 From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:25:23 2019 Return-Path: Delivered-To: svn-src-stable-12@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 BA29515B815B; Tue, 4 Jun 2019 17:25:23 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5DF2374418; Tue, 4 Jun 2019 17:25:23 +0000 (UTC) (envelope-from markj@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 386EA20AD1; Tue, 4 Jun 2019 17:25:23 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HPNSA097722; Tue, 4 Jun 2019 17:25:23 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HPNh7097721; Tue, 4 Jun 2019 17:25:23 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041725.x54HPNh7097721@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:25:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348638 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348638 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5DF2374418 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:25:23 -0000 Author: markj Date: Tue Jun 4 17:25:22 2019 New Revision: 348638 URL: https://svnweb.freebsd.org/changeset/base/348638 Log: MFC r342764: Clear PGA_WRITEABLE in pmap_remove_pages(). Modified: stable/12/sys/riscv/riscv/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:24:52 2019 (r348637) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:25:22 2019 (r348638) @@ -2745,6 +2745,9 @@ pmap_remove_pages(pmap_t pmap) pmap_resident_count_dec(pmap, 1); TAILQ_REMOVE(&m->md.pv_list, pv, pv_next); m->md.pv_gen++; + if (TAILQ_EMPTY(&m->md.pv_list) && + (m->aflags & PGA_WRITEABLE) != 0) + vm_page_aflag_clear(m, PGA_WRITEABLE); pmap_unuse_l3(pmap, pv->pv_va, ptepde, &free); freed++; From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:25:47 2019 Return-Path: Delivered-To: svn-src-stable-12@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 E145715B81CA; Tue, 4 Jun 2019 17:25:46 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8123B74545; Tue, 4 Jun 2019 17:25:46 +0000 (UTC) (envelope-from markj@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 5C61C20AD2; Tue, 4 Jun 2019 17:25:46 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HPkhq097781; Tue, 4 Jun 2019 17:25:46 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HPkp8097780; Tue, 4 Jun 2019 17:25:46 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041725.x54HPkp8097780@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:25:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348639 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348639 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8123B74545 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:25:47 -0000 Author: markj Date: Tue Jun 4 17:25:45 2019 New Revision: 348639 URL: https://svnweb.freebsd.org/changeset/base/348639 Log: MFC r342765: Fix dirty bit handling in pmap_remove_write(). Modified: stable/12/sys/riscv/riscv/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:25:22 2019 (r348638) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:25:45 2019 (r348639) @@ -2938,15 +2938,13 @@ retry_pv_loop: } } l3 = pmap_l3(pmap, pv->pv_va); -retry: oldl3 = pmap_load(l3); - +retry: if ((oldl3 & PTE_W) != 0) { - newl3 = oldl3 & ~PTE_W; - if (!atomic_cmpset_long(l3, oldl3, newl3)) + newl3 = oldl3 & ~(PTE_D | PTE_W); + if (!atomic_fcmpset_long(l3, &oldl3, newl3)) goto retry; - /* TODO: check for PTE_D? */ - if ((oldl3 & PTE_A) != 0) + if ((oldl3 & PTE_D) != 0) vm_page_dirty(m); pmap_invalidate_page(pmap, pv->pv_va); } From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:28:50 2019 Return-Path: Delivered-To: svn-src-stable-12@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 A949E15B830E; Tue, 4 Jun 2019 17:28:50 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 493B1746F5; Tue, 4 Jun 2019 17:28:50 +0000 (UTC) (envelope-from markj@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 238BA20AD4; Tue, 4 Jun 2019 17:28:50 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HSocD097942; Tue, 4 Jun 2019 17:28:50 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HSnwD097941; Tue, 4 Jun 2019 17:28:50 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041728.x54HSnwD097941@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:28:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348640 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348640 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 493B1746F5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:28:50 -0000 Author: markj Date: Tue Jun 4 17:28:49 2019 New Revision: 348640 URL: https://svnweb.freebsd.org/changeset/base/348640 Log: MFC r340029 (by jhb): Set PTE_A and PTE_D for user mappings in pmap_enter(). Modified: stable/12/sys/riscv/riscv/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:25:45 2019 (r348639) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:28:49 2019 (r348640) @@ -2000,13 +2000,15 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, v pa = VM_PAGE_TO_PHYS(m); pn = (pa / PAGE_SIZE); - new_l3 = PTE_V | PTE_R | PTE_X; + new_l3 = PTE_V | PTE_R | PTE_X | PTE_A; + if (flags & VM_PROT_WRITE) + new_l3 |= PTE_D; if (prot & VM_PROT_WRITE) new_l3 |= PTE_W; if ((va >> 63) == 0) new_l3 |= PTE_U; - else - new_l3 |= PTE_A | PTE_D; + else if (prot & VM_PROT_WRITE) + new_l3 |= PTE_D; new_l3 |= (pn << PTE_PPN0_S); if ((flags & PMAP_ENTER_WIRED) != 0) From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:29:22 2019 Return-Path: Delivered-To: svn-src-stable-12@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 8B91D15B8360; Tue, 4 Jun 2019 17:29:22 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2A64174825; Tue, 4 Jun 2019 17:29:22 +0000 (UTC) (envelope-from markj@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 ED78120AD5; Tue, 4 Jun 2019 17:29:21 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HTLJx098013; Tue, 4 Jun 2019 17:29:21 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HTLOA098008; Tue, 4 Jun 2019 17:29:21 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041729.x54HTLOA098008@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:29:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348641 - in stable/12/sys/riscv: include riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/12/sys/riscv: include riscv X-SVN-Commit-Revision: 348641 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2A64174825 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:29:22 -0000 Author: markj Date: Tue Jun 4 17:29:20 2019 New Revision: 348641 URL: https://svnweb.freebsd.org/changeset/base/348641 Log: MFC r340030 (by jhb): Restrict setting PTE execute permissions on RISC-V. Modified: stable/12/sys/riscv/include/pte.h stable/12/sys/riscv/riscv/locore.S stable/12/sys/riscv/riscv/pmap.c stable/12/sys/riscv/riscv/trap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/include/pte.h ============================================================================== --- stable/12/sys/riscv/include/pte.h Tue Jun 4 17:28:49 2019 (r348640) +++ stable/12/sys/riscv/include/pte.h Tue Jun 4 17:29:20 2019 (r348641) @@ -78,7 +78,7 @@ typedef uint64_t pn_t; /* page number */ #define PTE_V (1 << 0) /* Valid */ #define PTE_RWX (PTE_R | PTE_W | PTE_X) #define PTE_RX (PTE_R | PTE_X) -#define PTE_KERN (PTE_V | PTE_RWX | PTE_A | PTE_D) +#define PTE_KERN (PTE_V | PTE_R | PTE_W | PTE_A | PTE_D) #define PTE_PPN0_S 10 #define PTE_PPN1_S 19 Modified: stable/12/sys/riscv/riscv/locore.S ============================================================================== --- stable/12/sys/riscv/riscv/locore.S Tue Jun 4 17:28:49 2019 (r348640) +++ stable/12/sys/riscv/riscv/locore.S Tue Jun 4 17:29:20 2019 (r348641) @@ -94,7 +94,7 @@ _start: add t3, t4, t2 li t5, 0 2: - li t0, (PTE_KERN) + li t0, (PTE_KERN | PTE_X) slli t2, t4, PTE_PPN1_S /* << PTE_PPN1_S */ or t5, t0, t2 sd t5, (s1) /* Store PTE entry to position */ Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:28:49 2019 (r348640) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:29:20 2019 (r348641) @@ -1922,7 +1922,7 @@ retry: } int -pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_t prot) +pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_t ftype) { pt_entry_t orig_l3; pt_entry_t new_l3; @@ -1939,12 +1939,13 @@ pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_ orig_l3 = pmap_load(l3); if ((orig_l3 & PTE_V) == 0 || - ((prot & VM_PROT_WRITE) != 0 && (orig_l3 & PTE_W) == 0) || - ((prot & VM_PROT_READ) != 0 && (orig_l3 & PTE_R) == 0)) + (ftype == VM_PROT_WRITE && (orig_l3 & PTE_W) == 0) || + (ftype == VM_PROT_EXECUTE && (orig_l3 & PTE_X) == 0) || + (ftype == VM_PROT_READ && (orig_l3 & PTE_R) == 0)) goto done; new_l3 = orig_l3 | PTE_A; - if ((prot & VM_PROT_WRITE) != 0) + if (ftype == VM_PROT_WRITE) new_l3 |= PTE_D; if (orig_l3 != new_l3) { @@ -2000,7 +2001,9 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, v pa = VM_PAGE_TO_PHYS(m); pn = (pa / PAGE_SIZE); - new_l3 = PTE_V | PTE_R | PTE_X | PTE_A; + new_l3 = PTE_V | PTE_R | PTE_A; + if (prot & VM_PROT_EXECUTE) + new_l3 |= PTE_X; if (flags & VM_PROT_WRITE) new_l3 |= PTE_D; if (prot & VM_PROT_WRITE) @@ -2372,7 +2375,9 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, v pa = VM_PAGE_TO_PHYS(m); pn = (pa / PAGE_SIZE); - entry = (PTE_V | PTE_R | PTE_X); + entry = PTE_V | PTE_R; + if (prot & VM_PROT_EXECUTE) + entry |= PTE_X; entry |= (pn << PTE_PPN0_S); /* Modified: stable/12/sys/riscv/riscv/trap.c ============================================================================== --- stable/12/sys/riscv/riscv/trap.c Tue Jun 4 17:28:49 2019 (r348640) +++ stable/12/sys/riscv/riscv/trap.c Tue Jun 4 17:29:20 2019 (r348641) @@ -209,9 +209,11 @@ data_abort(struct trapframe *frame, int usermode) if ((frame->tf_scause == EXCP_FAULT_STORE) || (frame->tf_scause == EXCP_STORE_PAGE_FAULT)) { - ftype = (VM_PROT_READ | VM_PROT_WRITE); + ftype = VM_PROT_WRITE; + } else if (frame->tf_scause == EXCP_INST_PAGE_FAULT) { + ftype = VM_PROT_EXECUTE; } else { - ftype = (VM_PROT_READ); + ftype = VM_PROT_READ; } if (pmap_fault_fixup(map->pmap, va, ftype)) From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:29:48 2019 Return-Path: Delivered-To: svn-src-stable-12@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 C7DC815B83B9; Tue, 4 Jun 2019 17:29:48 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 67ECA7495C; Tue, 4 Jun 2019 17:29:48 +0000 (UTC) (envelope-from markj@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 3C4BE20AD7; Tue, 4 Jun 2019 17:29:48 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HTmY2098082; Tue, 4 Jun 2019 17:29:48 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HTmFl098081; Tue, 4 Jun 2019 17:29:48 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041729.x54HTmFl098081@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:29:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348642 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348642 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 67ECA7495C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:29:49 -0000 Author: markj Date: Tue Jun 4 17:29:47 2019 New Revision: 348642 URL: https://svnweb.freebsd.org/changeset/base/348642 Log: MFC r340159 (by jhb): Rework setting PTE_D for kernel mappings. Modified: stable/12/sys/riscv/riscv/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:29:20 2019 (r348641) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:29:47 2019 (r348642) @@ -2010,13 +2010,20 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, v new_l3 |= PTE_W; if ((va >> 63) == 0) new_l3 |= PTE_U; - else if (prot & VM_PROT_WRITE) - new_l3 |= PTE_D; new_l3 |= (pn << PTE_PPN0_S); if ((flags & PMAP_ENTER_WIRED) != 0) new_l3 |= PTE_SW_WIRED; - if ((m->oflags & VPO_UNMANAGED) == 0) + + /* + * Set modified bit gratuitously for writeable mappings if + * the page is unmanaged. We do not want to take a fault + * to do the dirty bit accounting for these mappings. + */ + if ((m->oflags & VPO_UNMANAGED) != 0) { + if (prot & VM_PROT_WRITE) + new_l3 |= PTE_D; + } else new_l3 |= PTE_SW_MANAGED; CTR2(KTR_PMAP, "pmap_enter: %.16lx -> %.16lx", va, pa); From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:30:23 2019 Return-Path: Delivered-To: svn-src-stable-12@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 604BD15B8449; Tue, 4 Jun 2019 17:30:23 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F35E574AA1; Tue, 4 Jun 2019 17:30:22 +0000 (UTC) (envelope-from markj@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 C4CCA20ADB; Tue, 4 Jun 2019 17:30:22 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HUMX2098188; Tue, 4 Jun 2019 17:30:22 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HUMkv098187; Tue, 4 Jun 2019 17:30:22 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041730.x54HUMkv098187@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:30:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348643 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348643 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: F35E574AA1 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:30:23 -0000 Author: markj Date: Tue Jun 4 17:30:22 2019 New Revision: 348643 URL: https://svnweb.freebsd.org/changeset/base/348643 Log: MFC r342733: Set PTE_U on PTEs created by pmap_enter_quick(). Modified: stable/12/sys/riscv/riscv/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:29:47 2019 (r348642) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:30:22 2019 (r348643) @@ -2379,19 +2379,14 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, v */ pmap_resident_count_inc(pmap, 1); - pa = VM_PAGE_TO_PHYS(m); - pn = (pa / PAGE_SIZE); - - entry = PTE_V | PTE_R; - if (prot & VM_PROT_EXECUTE) - entry |= PTE_X; - entry |= (pn << PTE_PPN0_S); - - /* - * Now validate mapping with RO protection - */ + newl3 = ((VM_PAGE_TO_PHYS(m) / PAGE_SIZE) << PTE_PPN0_S) | + PTE_V | PTE_R; + if ((prot & VM_PROT_EXECUTE) != 0) + newl3 |= PTE_X; if ((m->oflags & VPO_UNMANAGED) == 0) - entry |= PTE_SW_MANAGED; + newl3 |= PTE_SW_MANAGED; + if (va < VM_MAX_USER_ADDRESS) + newl3 |= PTE_U; /* * Sync the i-cache on all harts before updating the PTE @@ -2400,7 +2395,7 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, v if (prot & VM_PROT_EXECUTE) pmap_sync_icache(pmap, va, PAGE_SIZE); - pmap_store(l3, entry); + pmap_store(l3, newl3); pmap_invalidate_page(pmap, va); return (mpte); From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:31:07 2019 Return-Path: Delivered-To: svn-src-stable-12@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 69E8315B84E9; Tue, 4 Jun 2019 17:31:07 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1A11C74C5B; Tue, 4 Jun 2019 17:31:07 +0000 (UTC) (envelope-from markj@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 D0F6C20B07; Tue, 4 Jun 2019 17:31:06 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HV65H099084; Tue, 4 Jun 2019 17:31:06 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HV5RM099075; Tue, 4 Jun 2019 17:31:05 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041731.x54HV5RM099075@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:31:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348644 - in stable/12/sys: riscv/include riscv/riscv vm X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/12/sys: riscv/include riscv/riscv vm X-SVN-Commit-Revision: 348644 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1A11C74C5B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:31:07 -0000 Author: markj Date: Tue Jun 4 17:31:05 2019 New Revision: 348644 URL: https://svnweb.freebsd.org/changeset/base/348644 Log: MFC r344106: Implement transparent 2MB superpage promotion for RISC-V. Modified: stable/12/sys/riscv/include/param.h stable/12/sys/riscv/include/pmap.h stable/12/sys/riscv/include/pte.h stable/12/sys/riscv/include/vmparam.h stable/12/sys/riscv/riscv/pmap.c stable/12/sys/vm/vm_fault.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/include/param.h ============================================================================== --- stable/12/sys/riscv/include/param.h Tue Jun 4 17:30:22 2019 (r348643) +++ stable/12/sys/riscv/include/param.h Tue Jun 4 17:31:05 2019 (r348644) @@ -82,7 +82,7 @@ #define PAGE_SIZE (1 << PAGE_SHIFT) /* Page size */ #define PAGE_MASK (PAGE_SIZE - 1) -#define MAXPAGESIZES 1 /* maximum number of supported page sizes */ +#define MAXPAGESIZES 3 /* maximum number of supported page sizes */ #ifndef KSTACK_PAGES #define KSTACK_PAGES 4 /* pages of kernel stack (with pcb) */ Modified: stable/12/sys/riscv/include/pmap.h ============================================================================== --- stable/12/sys/riscv/include/pmap.h Tue Jun 4 17:30:22 2019 (r348643) +++ stable/12/sys/riscv/include/pmap.h Tue Jun 4 17:31:05 2019 (r348644) @@ -44,6 +44,8 @@ #include #include +#include + #ifdef _KERNEL #define vtophys(va) pmap_kextract((vm_offset_t)(va)) @@ -80,6 +82,7 @@ struct pmap { pd_entry_t *pm_l1; TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */ LIST_ENTRY(pmap) pm_list; /* List of all pmaps */ + struct vm_radix pm_root; }; typedef struct pv_entry { @@ -139,6 +142,7 @@ void pmap_kenter_device(vm_offset_t, vm_size_t, vm_pad vm_paddr_t pmap_kextract(vm_offset_t va); void pmap_kremove(vm_offset_t); void pmap_kremove_device(vm_offset_t, vm_size_t); +bool pmap_ps_enabled(pmap_t); void *pmap_mapdev(vm_offset_t, vm_size_t); void *pmap_mapbios(vm_paddr_t, vm_size_t); Modified: stable/12/sys/riscv/include/pte.h ============================================================================== --- stable/12/sys/riscv/include/pte.h Tue Jun 4 17:30:22 2019 (r348643) +++ stable/12/sys/riscv/include/pte.h Tue Jun 4 17:31:05 2019 (r348644) @@ -62,7 +62,8 @@ typedef uint64_t pn_t; /* page number */ #define L3_SIZE (1 << L3_SHIFT) #define L3_OFFSET (L3_SIZE - 1) -#define Ln_ENTRIES (1 << 9) +#define Ln_ENTRIES_SHIFT 9 +#define Ln_ENTRIES (1 << Ln_ENTRIES_SHIFT) #define Ln_ADDR_MASK (Ln_ENTRIES - 1) /* Bits 9:8 are reserved for software */ @@ -79,6 +80,8 @@ typedef uint64_t pn_t; /* page number */ #define PTE_RWX (PTE_R | PTE_W | PTE_X) #define PTE_RX (PTE_R | PTE_X) #define PTE_KERN (PTE_V | PTE_R | PTE_W | PTE_A | PTE_D) +#define PTE_PROMOTE (PTE_V | PTE_RWX | PTE_D | PTE_A | PTE_G | PTE_U | \ + PTE_SW_MANAGED | PTE_SW_WIRED) #define PTE_PPN0_S 10 #define PTE_PPN1_S 19 Modified: stable/12/sys/riscv/include/vmparam.h ============================================================================== --- stable/12/sys/riscv/include/vmparam.h Tue Jun 4 17:30:22 2019 (r348643) +++ stable/12/sys/riscv/include/vmparam.h Tue Jun 4 17:31:05 2019 (r348644) @@ -99,10 +99,10 @@ #define VM_NFREEORDER 12 /* - * Disable superpage reservations. + * Enable superpage reservations: 1 level. */ #ifndef VM_NRESERVLEVEL -#define VM_NRESERVLEVEL 0 +#define VM_NRESERVLEVEL 1 #endif /* Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:30:22 2019 (r348643) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:31:05 2019 (r348644) @@ -118,6 +118,7 @@ __FBSDID("$FreeBSD$"); */ #include +#include #include #include #include @@ -145,6 +146,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -154,9 +156,8 @@ __FBSDID("$FreeBSD$"); #include #include -#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t))) -#define NUPDE (NPDEPG * NPDEPG) -#define NUSERPGTBLS (NUPDE + NPDEPG) +#define NUL1E (Ln_ENTRIES * Ln_ENTRIES) +#define NUL2E (Ln_ENTRIES * NUL1E) #if !defined(DIAGNOSTIC) #ifdef __GNUC_GNU_INLINE__ @@ -175,11 +176,12 @@ __FBSDID("$FreeBSD$"); #endif #define pmap_l2_pindex(v) ((v) >> L2_SHIFT) +#define pa_to_pvh(pa) (&pv_table[pa_index(pa)]) #define NPV_LIST_LOCKS MAXCPU #define PHYS_TO_PV_LIST_LOCK(pa) \ - (&pv_list_locks[pa_index(pa) % NPV_LIST_LOCKS]) + (&pv_list_locks[pmap_l2_pindex(pa) % NPV_LIST_LOCKS]) #define CHANGE_PV_LIST_LOCK_TO_PHYS(lockp, pa) do { \ struct rwlock **_lockp = (lockp); \ @@ -230,13 +232,52 @@ CTASSERT((DMAP_MAX_ADDRESS & ~L1_OFFSET) == DMAP_MAX_ static struct rwlock_padalign pvh_global_lock; static struct mtx_padalign allpmaps_lock; +static SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0, + "VM/pmap parameters"); + +static int superpages_enabled = 1; +SYSCTL_INT(_vm_pmap, OID_AUTO, superpages_enabled, + CTLFLAG_RDTUN, &superpages_enabled, 0, + "Enable support for transparent superpages"); + +static SYSCTL_NODE(_vm_pmap, OID_AUTO, l2, CTLFLAG_RD, 0, + "2MB page mapping counters"); + +static u_long pmap_l2_demotions; +SYSCTL_ULONG(_vm_pmap_l2, OID_AUTO, demotions, CTLFLAG_RD, + &pmap_l2_demotions, 0, + "2MB page demotions"); + +static u_long pmap_l2_mappings; +SYSCTL_ULONG(_vm_pmap_l2, OID_AUTO, mappings, CTLFLAG_RD, + &pmap_l2_mappings, 0, + "2MB page mappings"); + +static u_long pmap_l2_p_failures; +SYSCTL_ULONG(_vm_pmap_l2, OID_AUTO, p_failures, CTLFLAG_RD, + &pmap_l2_p_failures, 0, + "2MB page promotion failures"); + +static u_long pmap_l2_promotions; +SYSCTL_ULONG(_vm_pmap_l2, OID_AUTO, promotions, CTLFLAG_RD, + &pmap_l2_promotions, 0, + "2MB page promotions"); + /* * Data for the pv entry allocation mechanism */ static TAILQ_HEAD(pch, pv_chunk) pv_chunks = TAILQ_HEAD_INITIALIZER(pv_chunks); static struct mtx pv_chunks_mutex; static struct rwlock pv_list_locks[NPV_LIST_LOCKS]; +static struct md_page *pv_table; +static struct md_page pv_dummy; +/* + * Internal flags for pmap_enter()'s helper functions. + */ +#define PMAP_ENTER_NORECLAIM 0x1000000 /* Don't reclaim PV entries. */ +#define PMAP_ENTER_NOREPLACE 0x2000000 /* Don't replace mappings. */ + static void free_pv_chunk(struct pv_chunk *pc); static void free_pv_entry(pmap_t pmap, pv_entry_t pv); static pv_entry_t get_pv_entry(pmap_t pmap, struct rwlock **lockp); @@ -244,6 +285,11 @@ static vm_page_t reclaim_pv_chunk(pmap_t locked_pmap, static void pmap_pvh_free(struct md_page *pvh, pmap_t pmap, vm_offset_t va); static pv_entry_t pmap_pvh_remove(struct md_page *pvh, pmap_t pmap, vm_offset_t va); +static bool pmap_demote_l2(pmap_t pmap, pd_entry_t *l2, vm_offset_t va); +static bool pmap_demote_l2_locked(pmap_t pmap, pd_entry_t *l2, + vm_offset_t va, struct rwlock **lockp); +static int pmap_enter_l2(pmap_t pmap, vm_offset_t va, pd_entry_t new_l2, + u_int flags, vm_page_t m, struct rwlock **lockp); static vm_page_t pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot, vm_page_t mpte, struct rwlock **lockp); static int pmap_remove_l3(pmap_t pmap, pt_entry_t *l3, vm_offset_t sva, @@ -254,9 +300,9 @@ static boolean_t pmap_try_insert_pv_entry(pmap_t pmap, static vm_page_t _pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex, struct rwlock **lockp); -static void _pmap_unwire_l3(pmap_t pmap, vm_offset_t va, vm_page_t m, +static void _pmap_unwire_ptp(pmap_t pmap, vm_offset_t va, vm_page_t m, struct spglist *free); -static int pmap_unuse_l3(pmap_t, vm_offset_t, pd_entry_t, struct spglist *); +static int pmap_unuse_pt(pmap_t, vm_offset_t, pd_entry_t, struct spglist *); #define pmap_clear(pte) pmap_store(pte, 0) #define pmap_clear_bits(pte, bits) atomic_clear_64(pte, bits) @@ -636,7 +682,8 @@ pmap_page_init(vm_page_t m) void pmap_init(void) { - int i; + vm_size_t s; + int i, pv_npg; /* * Initialize the pv chunk and pmap list mutexes. @@ -649,6 +696,24 @@ pmap_init(void) */ for (i = 0; i < NPV_LIST_LOCKS; i++) rw_init(&pv_list_locks[i], "pmap pv list"); + + /* + * Calculate the size of the pv head table for superpages. + */ + pv_npg = howmany(vm_phys_segs[vm_phys_nsegs - 1].end, L2_SIZE); + + /* + * Allocate memory for the pv head table for superpages. + */ + s = (vm_size_t)(pv_npg * sizeof(struct md_page)); + s = round_page(s); + pv_table = (struct md_page *)kmem_malloc(s, M_WAITOK | M_ZERO); + for (i = 0; i < pv_npg; i++) + TAILQ_INIT(&pv_table[i].pv_list); + TAILQ_INIT(&pv_dummy.pv_list); + + if (superpages_enabled) + pagesizes[1] = L2_SIZE; } #ifdef SMP @@ -999,6 +1064,13 @@ pmap_qremove(vm_offset_t sva, int count) pmap_invalidate_range(kernel_pmap, sva, va); } +bool +pmap_ps_enabled(pmap_t pmap __unused) +{ + + return (superpages_enabled); +} + /*************************************************** * Page table page management routines..... ***************************************************/ @@ -1018,6 +1090,34 @@ pmap_add_delayed_free_list(vm_page_t m, struct spglist m->flags &= ~PG_ZERO; SLIST_INSERT_HEAD(free, m, plinks.s.ss); } + +/* + * Inserts the specified page table page into the specified pmap's collection + * of idle page table pages. Each of a pmap's page table pages is responsible + * for mapping a distinct range of virtual addresses. The pmap's collection is + * ordered by this virtual address range. + */ +static __inline int +pmap_insert_pt_page(pmap_t pmap, vm_page_t ml3) +{ + + PMAP_LOCK_ASSERT(pmap, MA_OWNED); + return (vm_radix_insert(&pmap->pm_root, ml3)); +} + +/* + * Removes the page table page mapping the specified virtual address from the + * specified pmap's collection of idle page table pages, and returns it. + * Otherwise, returns NULL if there is no page table page corresponding to the + * specified virtual address. + */ +static __inline vm_page_t +pmap_remove_pt_page(pmap_t pmap, vm_offset_t va) +{ + + PMAP_LOCK_ASSERT(pmap, MA_OWNED); + return (vm_radix_remove(&pmap->pm_root, pmap_l2_pindex(va))); +} /* * Decrements a page table page's wire count, which is used to record the @@ -1026,12 +1126,12 @@ pmap_add_delayed_free_list(vm_page_t m, struct spglist * page table page was unmapped and FALSE otherwise. */ static inline boolean_t -pmap_unwire_l3(pmap_t pmap, vm_offset_t va, vm_page_t m, struct spglist *free) +pmap_unwire_ptp(pmap_t pmap, vm_offset_t va, vm_page_t m, struct spglist *free) { --m->wire_count; if (m->wire_count == 0) { - _pmap_unwire_l3(pmap, va, m, free); + _pmap_unwire_ptp(pmap, va, m, free); return (TRUE); } else { return (FALSE); @@ -1039,36 +1139,30 @@ pmap_unwire_l3(pmap_t pmap, vm_offset_t va, vm_page_t } static void -_pmap_unwire_l3(pmap_t pmap, vm_offset_t va, vm_page_t m, struct spglist *free) +_pmap_unwire_ptp(pmap_t pmap, vm_offset_t va, vm_page_t m, struct spglist *free) { vm_paddr_t phys; PMAP_LOCK_ASSERT(pmap, MA_OWNED); - /* - * unmap the page table page - */ - if (m->pindex >= NUPDE) { - /* PD page */ + if (m->pindex >= NUL1E) { pd_entry_t *l1; l1 = pmap_l1(pmap, va); pmap_clear(l1); pmap_distribute_l1(pmap, pmap_l1_index(va), 0); } else { - /* PTE page */ pd_entry_t *l2; l2 = pmap_l2(pmap, va); pmap_clear(l2); } pmap_resident_count_dec(pmap, 1); - if (m->pindex < NUPDE) { + if (m->pindex < NUL1E) { pd_entry_t *l1; - /* We just released a PT, unhold the matching PD */ vm_page_t pdpg; l1 = pmap_l1(pmap, va); phys = PTE_TO_PHYS(pmap_load(l1)); pdpg = PHYS_TO_VM_PAGE(phys); - pmap_unwire_l3(pmap, va, pdpg, free); + pmap_unwire_ptp(pmap, va, pdpg, free); } pmap_invalidate_page(pmap, va); @@ -1082,24 +1176,20 @@ _pmap_unwire_l3(pmap_t pmap, vm_offset_t va, vm_page_t } /* - * After removing an l3 entry, this routine is used to + * After removing a page table entry, this routine is used to * conditionally free the page, and manage the hold/wire counts. */ static int -pmap_unuse_l3(pmap_t pmap, vm_offset_t va, pd_entry_t ptepde, +pmap_unuse_pt(pmap_t pmap, vm_offset_t va, pd_entry_t ptepde, struct spglist *free) { - vm_paddr_t phys; vm_page_t mpte; if (va >= VM_MAXUSER_ADDRESS) return (0); KASSERT(ptepde != 0, ("pmap_unuse_pt: ptepde != 0")); - - phys = PTE_TO_PHYS(ptepde); - - mpte = PHYS_TO_VM_PAGE(phys); - return (pmap_unwire_l3(pmap, va, mpte, free)); + mpte = PHYS_TO_VM_PAGE(PTE_TO_PHYS(ptepde)); + return (pmap_unwire_ptp(pmap, va, mpte, free)); } void @@ -1140,6 +1230,8 @@ pmap_pinit(pmap_t pmap) LIST_INSERT_HEAD(&allpmaps, pmap, pm_list); mtx_unlock(&allpmaps_lock); + vm_radix_init(&pmap->pm_root); + return (1); } @@ -1193,11 +1285,11 @@ _pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex, str * it isn't already there. */ - if (ptepindex >= NUPDE) { + if (ptepindex >= NUL1E) { pd_entry_t *l1; vm_pindex_t l1index; - l1index = ptepindex - NUPDE; + l1index = ptepindex - NUL1E; l1 = &pmap->pm_l1[l1index]; pn = (VM_PAGE_TO_PHYS(m) / PAGE_SIZE); @@ -1213,7 +1305,7 @@ _pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex, str l1 = &pmap->pm_l1[l1index]; if (pmap_load(l1) == 0) { /* recurse for allocating page dir */ - if (_pmap_alloc_l3(pmap, NUPDE + l1index, + if (_pmap_alloc_l3(pmap, NUL1E + l1index, lockp) == NULL) { vm_page_unwire_noq(m); vm_page_free_zero(m); @@ -1241,6 +1333,29 @@ _pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex, str } static vm_page_t +pmap_alloc_l2(pmap_t pmap, vm_offset_t va, struct rwlock **lockp) +{ + pd_entry_t *l1; + vm_page_t l2pg; + vm_pindex_t l2pindex; + +retry: + l1 = pmap_l1(pmap, va); + if (l1 != NULL && (pmap_load(l1) & PTE_RWX) == 0) { + /* Add a reference to the L2 page. */ + l2pg = PHYS_TO_VM_PAGE(PTE_TO_PHYS(pmap_load(l1))); + l2pg->wire_count++; + } else { + /* Allocate a L2 page. */ + l2pindex = pmap_l2_pindex(va) >> Ln_ENTRIES_SHIFT; + l2pg = _pmap_alloc_l3(pmap, NUL2E + l2pindex, lockp); + if (l2pg == NULL && lockp != NULL) + goto retry; + } + return (l2pg); +} + +static vm_page_t pmap_alloc_l3(pmap_t pmap, vm_offset_t va, struct rwlock **lockp) { vm_pindex_t ptepindex; @@ -1599,6 +1714,79 @@ retry: } /* + * Ensure that the number of spare PV entries in the specified pmap meets or + * exceeds the given count, "needed". + * + * The given PV list lock may be released. + */ +static void +reserve_pv_entries(pmap_t pmap, int needed, struct rwlock **lockp) +{ + struct pch new_tail; + struct pv_chunk *pc; + vm_page_t m; + int avail, free; + bool reclaimed; + + rw_assert(&pvh_global_lock, RA_LOCKED); + PMAP_LOCK_ASSERT(pmap, MA_OWNED); + KASSERT(lockp != NULL, ("reserve_pv_entries: lockp is NULL")); + + /* + * Newly allocated PV chunks must be stored in a private list until + * the required number of PV chunks have been allocated. Otherwise, + * reclaim_pv_chunk() could recycle one of these chunks. In + * contrast, these chunks must be added to the pmap upon allocation. + */ + TAILQ_INIT(&new_tail); +retry: + avail = 0; + TAILQ_FOREACH(pc, &pmap->pm_pvchunk, pc_list) { + bit_count((bitstr_t *)pc->pc_map, 0, + sizeof(pc->pc_map) * NBBY, &free); + if (free == 0) + break; + avail += free; + if (avail >= needed) + break; + } + for (reclaimed = false; avail < needed; avail += _NPCPV) { + m = vm_page_alloc(NULL, 0, VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | + VM_ALLOC_WIRED); + if (m == NULL) { + m = reclaim_pv_chunk(pmap, lockp); + if (m == NULL) + goto retry; + reclaimed = true; + } + /* XXX PV STATS */ +#if 0 + dump_add_page(m->phys_addr); +#endif + pc = (void *)PHYS_TO_DMAP(m->phys_addr); + pc->pc_pmap = pmap; + pc->pc_map[0] = PC_FREE0; + pc->pc_map[1] = PC_FREE1; + pc->pc_map[2] = PC_FREE2; + TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); + TAILQ_INSERT_TAIL(&new_tail, pc, pc_lru); + + /* + * The reclaim might have freed a chunk from the current pmap. + * If that chunk contained available entries, we need to + * re-count the number of available entries. + */ + if (reclaimed) + goto retry; + } + if (!TAILQ_EMPTY(&new_tail)) { + mtx_lock(&pv_chunks_mutex); + TAILQ_CONCAT(&pv_chunks, &new_tail, pc_lru); + mtx_unlock(&pv_chunks_mutex); + } +} + +/* * First find and then remove the pv entry for the specified pmap and virtual * address from the specified pv list. Returns the pv entry if found and NULL * otherwise. This operation can be performed on pv lists for either 4KB or @@ -1632,7 +1820,7 @@ pmap_pvh_free(struct md_page *pvh, pmap_t pmap, vm_off pv = pmap_pvh_remove(pvh, pmap, va); - KASSERT(pv != NULL, ("pmap_pvh_free: pv not found")); + KASSERT(pv != NULL, ("pmap_pvh_free: pv not found for %#lx", va)); free_pv_entry(pmap, pv); } @@ -1660,6 +1848,222 @@ pmap_try_insert_pv_entry(pmap_t pmap, vm_offset_t va, } /* + * After demotion from a 2MB page mapping to 512 4KB page mappings, + * destroy the pv entry for the 2MB page mapping and reinstantiate the pv + * entries for each of the 4KB page mappings. + */ +static void __unused +pmap_pv_demote_l2(pmap_t pmap, vm_offset_t va, vm_paddr_t pa, + struct rwlock **lockp) +{ + struct md_page *pvh; + struct pv_chunk *pc; + pv_entry_t pv; + vm_page_t m; + vm_offset_t va_last; + int bit, field; + + rw_assert(&pvh_global_lock, RA_LOCKED); + PMAP_LOCK_ASSERT(pmap, MA_OWNED); + CHANGE_PV_LIST_LOCK_TO_PHYS(lockp, pa); + + /* + * Transfer the 2mpage's pv entry for this mapping to the first + * page's pv list. Once this transfer begins, the pv list lock + * must not be released until the last pv entry is reinstantiated. + */ + pvh = pa_to_pvh(pa); + va &= ~L2_OFFSET; + pv = pmap_pvh_remove(pvh, pmap, va); + KASSERT(pv != NULL, ("pmap_pv_demote_l2: pv not found")); + m = PHYS_TO_VM_PAGE(pa); + TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_next); + m->md.pv_gen++; + /* Instantiate the remaining 511 pv entries. */ + va_last = va + L2_SIZE - PAGE_SIZE; + for (;;) { + pc = TAILQ_FIRST(&pmap->pm_pvchunk); + KASSERT(pc->pc_map[0] != 0 || pc->pc_map[1] != 0 || + pc->pc_map[2] != 0, ("pmap_pv_demote_l2: missing spare")); + for (field = 0; field < _NPCM; field++) { + while (pc->pc_map[field] != 0) { + bit = ffsl(pc->pc_map[field]) - 1; + pc->pc_map[field] &= ~(1ul << bit); + pv = &pc->pc_pventry[field * 64 + bit]; + va += PAGE_SIZE; + pv->pv_va = va; + m++; + KASSERT((m->oflags & VPO_UNMANAGED) == 0, + ("pmap_pv_demote_l2: page %p is not managed", m)); + TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_next); + m->md.pv_gen++; + if (va == va_last) + goto out; + } + } + TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); + TAILQ_INSERT_TAIL(&pmap->pm_pvchunk, pc, pc_list); + } +out: + if (pc->pc_map[0] == 0 && pc->pc_map[1] == 0 && pc->pc_map[2] == 0) { + TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); + TAILQ_INSERT_TAIL(&pmap->pm_pvchunk, pc, pc_list); + } + /* XXX PV stats */ +} + +#if VM_NRESERVLEVEL > 0 +static void +pmap_pv_promote_l2(pmap_t pmap, vm_offset_t va, vm_paddr_t pa, + struct rwlock **lockp) +{ + struct md_page *pvh; + pv_entry_t pv; + vm_page_t m; + vm_offset_t va_last; + + rw_assert(&pvh_global_lock, RA_LOCKED); + KASSERT((va & L2_OFFSET) == 0, + ("pmap_pv_promote_l2: misaligned va %#lx", va)); + + CHANGE_PV_LIST_LOCK_TO_PHYS(lockp, pa); + + m = PHYS_TO_VM_PAGE(pa); + pv = pmap_pvh_remove(&m->md, pmap, va); + KASSERT(pv != NULL, ("pmap_pv_promote_l2: pv for %#lx not found", va)); + pvh = pa_to_pvh(pa); + TAILQ_INSERT_TAIL(&pvh->pv_list, pv, pv_next); + pvh->pv_gen++; + + va_last = va + L2_SIZE - PAGE_SIZE; + do { + m++; + va += PAGE_SIZE; + pmap_pvh_free(&m->md, pmap, va); + } while (va < va_last); +} +#endif /* VM_NRESERVLEVEL > 0 */ + +/* + * Create the PV entry for a 2MB page mapping. Always returns true unless the + * flag PMAP_ENTER_NORECLAIM is specified. If that flag is specified, returns + * false if the PV entry cannot be allocated without resorting to reclamation. + */ +static bool +pmap_pv_insert_l2(pmap_t pmap, vm_offset_t va, pd_entry_t l2e, u_int flags, + struct rwlock **lockp) +{ + struct md_page *pvh; + pv_entry_t pv; + vm_paddr_t pa; + + PMAP_LOCK_ASSERT(pmap, MA_OWNED); + /* Pass NULL instead of the lock pointer to disable reclamation. */ + if ((pv = get_pv_entry(pmap, (flags & PMAP_ENTER_NORECLAIM) != 0 ? + NULL : lockp)) == NULL) + return (false); + pv->pv_va = va; + pa = PTE_TO_PHYS(l2e); + CHANGE_PV_LIST_LOCK_TO_PHYS(lockp, pa); + pvh = pa_to_pvh(pa); + TAILQ_INSERT_TAIL(&pvh->pv_list, pv, pv_next); + pvh->pv_gen++; + return (true); +} + +static void +pmap_remove_kernel_l2(pmap_t pmap, pt_entry_t *l2, vm_offset_t va) +{ + pt_entry_t newl2, oldl2; + vm_page_t ml3; + vm_paddr_t ml3pa; + + KASSERT(!VIRT_IN_DMAP(va), ("removing direct mapping of %#lx", va)); + KASSERT(pmap == kernel_pmap, ("pmap %p is not kernel_pmap", pmap)); + PMAP_LOCK_ASSERT(pmap, MA_OWNED); + + ml3 = pmap_remove_pt_page(pmap, va); + if (ml3 == NULL) + panic("pmap_remove_kernel_l2: Missing pt page"); + + ml3pa = VM_PAGE_TO_PHYS(ml3); + newl2 = ml3pa | PTE_V; + + /* + * Initialize the page table page. + */ + pagezero((void *)PHYS_TO_DMAP(ml3pa)); + + /* + * Demote the mapping. + */ + oldl2 = pmap_load_store(l2, newl2); + KASSERT(oldl2 == 0, ("%s: found existing mapping at %p: %#lx", + __func__, l2, oldl2)); +} + +/* + * pmap_remove_l2: Do the things to unmap a level 2 superpage. + */ +static int +pmap_remove_l2(pmap_t pmap, pt_entry_t *l2, vm_offset_t sva, + pd_entry_t l1e, struct spglist *free, struct rwlock **lockp) +{ + struct md_page *pvh; + pt_entry_t oldl2; + vm_offset_t eva, va; + vm_page_t m, ml3; + + PMAP_LOCK_ASSERT(pmap, MA_OWNED); + KASSERT((sva & L2_OFFSET) == 0, ("pmap_remove_l2: sva is not aligned")); + oldl2 = pmap_load_clear(l2); + KASSERT((oldl2 & PTE_RWX) != 0, + ("pmap_remove_l2: L2e %lx is not a superpage mapping", oldl2)); + + /* + * The sfence.vma documentation states that it is sufficient to specify + * a single address within a superpage mapping. However, since we do + * not perform any invalidation upon promotion, TLBs may still be + * caching 4KB mappings within the superpage, so we must invalidate the + * entire range. + */ + pmap_invalidate_range(pmap, sva, sva + L2_SIZE); + if ((oldl2 & PTE_SW_WIRED) != 0) + pmap->pm_stats.wired_count -= L2_SIZE / PAGE_SIZE; + pmap_resident_count_dec(pmap, L2_SIZE / PAGE_SIZE); + if ((oldl2 & PTE_SW_MANAGED) != 0) { + CHANGE_PV_LIST_LOCK_TO_PHYS(lockp, PTE_TO_PHYS(oldl2)); + pvh = pa_to_pvh(PTE_TO_PHYS(oldl2)); + pmap_pvh_free(pvh, pmap, sva); + eva = sva + L2_SIZE; + for (va = sva, m = PHYS_TO_VM_PAGE(PTE_TO_PHYS(oldl2)); + va < eva; va += PAGE_SIZE, m++) { + if ((oldl2 & PTE_D) != 0) + vm_page_dirty(m); + if ((oldl2 & PTE_A) != 0) + vm_page_aflag_set(m, PGA_REFERENCED); + if (TAILQ_EMPTY(&m->md.pv_list) && + TAILQ_EMPTY(&pvh->pv_list)) + vm_page_aflag_clear(m, PGA_WRITEABLE); + } + } + if (pmap == kernel_pmap) { + pmap_remove_kernel_l2(pmap, l2, sva); + } else { + ml3 = pmap_remove_pt_page(pmap, sva); + if (ml3 != NULL) { + pmap_resident_count_dec(pmap, 1); + KASSERT(ml3->wire_count == Ln_ENTRIES, + ("pmap_remove_l2: l3 page wire count error")); + ml3->wire_count = 1; + vm_page_unwire_noq(ml3); + pmap_add_delayed_free_list(ml3, free, FALSE); + } + } + return (pmap_unuse_pt(pmap, sva, l1e, free)); +} + +/* * pmap_remove_l3: do the things to unmap a page in a process */ static int @@ -1687,7 +2091,7 @@ pmap_remove_l3(pmap_t pmap, pt_entry_t *l3, vm_offset_ pmap_pvh_free(&m->md, pmap, va); } - return (pmap_unuse_l3(pmap, va, l2e, free)); + return (pmap_unuse_pt(pmap, va, l2e, free)); } /* @@ -1699,11 +2103,11 @@ pmap_remove_l3(pmap_t pmap, pt_entry_t *l3, vm_offset_ void pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) { + struct spglist free; struct rwlock *lock; vm_offset_t va, va_next; - pd_entry_t *l1, *l2; - pt_entry_t l3_pte, *l3; - struct spglist free; + pd_entry_t *l1, *l2, l2e; + pt_entry_t *l3; /* * Perform an unsynchronized read. This is, however, safe. @@ -1739,16 +2143,22 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t l2 = pmap_l1_to_l2(l1, sva); if (l2 == NULL) continue; - - l3_pte = pmap_load(l2); - - /* - * Weed out invalid mappings. - */ - if (l3_pte == 0) + if ((l2e = pmap_load(l2)) == 0) continue; - if ((pmap_load(l2) & PTE_RX) != 0) - continue; + if ((l2e & PTE_RWX) != 0) { + if (sva + L2_SIZE == va_next && eva >= va_next) { + (void)pmap_remove_l2(pmap, l2, sva, + pmap_load(l1), &free, &lock); + continue; + } else if (!pmap_demote_l2_locked(pmap, l2, sva, + &lock)) { + /* + * The large page mapping was destroyed. + */ + continue; + } + l2e = pmap_load(l2); + } /* * Limit our scan to either the end of the va represented @@ -1761,8 +2171,6 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t va = va_next; for (l3 = pmap_l2_to_l3(l2, sva); sva != va_next; l3++, sva += L3_SIZE) { - if (l3 == NULL) - panic("l3 == NULL"); if (pmap_load(l3) == 0) { if (va != va_next) { pmap_invalidate_range(pmap, va, sva); @@ -1772,8 +2180,7 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t } if (va == va_next) va = sva; - if (pmap_remove_l3(pmap, l3, sva, l3_pte, &free, - &lock)) { + if (pmap_remove_l3(pmap, l3, sva, l2e, &free, &lock)) { sva += L3_SIZE; break; } @@ -1783,7 +2190,7 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t } if (lock != NULL) rw_wunlock(lock); - rw_runlock(&pvh_global_lock); + rw_runlock(&pvh_global_lock); PMAP_UNLOCK(pmap); vm_page_free_pages_toq(&free, false); } @@ -1804,42 +2211,54 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t void pmap_remove_all(vm_page_t m) { - pv_entry_t pv; - pmap_t pmap; - pt_entry_t *l3, tl3; - pd_entry_t *l2, tl2; struct spglist free; + struct md_page *pvh; + pmap_t pmap; + pt_entry_t *l3, l3e; + pd_entry_t *l2, l2e; + pv_entry_t pv; + vm_offset_t va; KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("pmap_remove_all: page %p is not managed", m)); SLIST_INIT(&free); + pvh = (m->flags & PG_FICTITIOUS) != 0 ? &pv_dummy : + pa_to_pvh(VM_PAGE_TO_PHYS(m)); + rw_wlock(&pvh_global_lock); + while ((pv = TAILQ_FIRST(&pvh->pv_list)) != NULL) { + pmap = PV_PMAP(pv); + PMAP_LOCK(pmap); + va = pv->pv_va; + l2 = pmap_l2(pmap, va); + (void)pmap_demote_l2(pmap, l2, va); + PMAP_UNLOCK(pmap); + } while ((pv = TAILQ_FIRST(&m->md.pv_list)) != NULL) { pmap = PV_PMAP(pv); PMAP_LOCK(pmap); pmap_resident_count_dec(pmap, 1); l2 = pmap_l2(pmap, pv->pv_va); KASSERT(l2 != NULL, ("pmap_remove_all: no l2 table found")); - tl2 = pmap_load(l2); + l2e = pmap_load(l2); - KASSERT((tl2 & PTE_RX) == 0, - ("pmap_remove_all: found a table when expecting " - "a block in %p's pv list", m)); + KASSERT((l2e & PTE_RX) == 0, + ("pmap_remove_all: found a superpage in %p's pv list", m)); l3 = pmap_l2_to_l3(l2, pv->pv_va); - tl3 = pmap_load_clear(l3); + l3e = pmap_load_clear(l3); pmap_invalidate_page(pmap, pv->pv_va); - if (tl3 & PTE_SW_WIRED) + if (l3e & PTE_SW_WIRED) pmap->pm_stats.wired_count--; - if ((tl3 & PTE_A) != 0) + if ((l3e & PTE_A) != 0) vm_page_aflag_set(m, PGA_REFERENCED); /* * Update the vm_page_t clean and reference bits. */ - if ((tl3 & PTE_D) != 0) + if ((l3e & PTE_D) != 0) vm_page_dirty(m); - pmap_unuse_l3(pmap, pv->pv_va, pmap_load(l2), &free); + pmap_unuse_pt(pmap, pv->pv_va, pmap_load(l2), &free); TAILQ_REMOVE(&m->md.pv_list, pv, pv_next); m->md.pv_gen++; free_pv_entry(pmap, pv); @@ -1857,10 +2276,12 @@ pmap_remove_all(vm_page_t m) void pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot) { - pd_entry_t *l1, *l2; + pd_entry_t *l1, *l2, l2e; pt_entry_t *l3, l3e, mask; vm_page_t m; - vm_offset_t va_next; + vm_paddr_t pa; + vm_offset_t va, va_next; + bool anychanged, pv_lists_locked; if ((prot & VM_PROT_READ) == VM_PROT_NONE) { pmap_remove(pmap, sva, eva); @@ -1871,12 +2292,14 @@ pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t (VM_PROT_WRITE | VM_PROT_EXECUTE)) return; + anychanged = false; + pv_lists_locked = false; mask = 0; if ((prot & VM_PROT_WRITE) == 0) mask |= PTE_W | PTE_D; if ((prot & VM_PROT_EXECUTE) == 0) mask |= PTE_X; - +resume: PMAP_LOCK(pmap); for (; sva < eva; sva = va_next) { l1 = pmap_l1(pmap, sva); @@ -1892,10 +2315,41 @@ pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t va_next = eva; l2 = pmap_l1_to_l2(l1, sva); - if (l2 == NULL || pmap_load(l2) == 0) + if (l2 == NULL || (l2e = pmap_load(l2)) == 0) continue; - if ((pmap_load(l2) & PTE_RX) != 0) - continue; + if ((l2e & PTE_RWX) != 0) { + if (sva + L2_SIZE == va_next && eva >= va_next) { +retryl2: + if ((l2e & (PTE_SW_MANAGED | PTE_D)) == + (PTE_SW_MANAGED | PTE_D)) { + pa = PTE_TO_PHYS(l2e); + for (va = sva, m = PHYS_TO_VM_PAGE(pa); + va < va_next; m++, va += PAGE_SIZE) + vm_page_dirty(m); + } + if (!atomic_fcmpset_long(l2, &l2e, l2e & ~mask)) + goto retryl2; + anychanged = true; + } else { + if (!pv_lists_locked) { + pv_lists_locked = true; + if (!rw_try_rlock(&pvh_global_lock)) { + if (anychanged) + pmap_invalidate_all( + pmap); + PMAP_UNLOCK(pmap); + rw_rlock(&pvh_global_lock); + goto resume; + } + } + if (!pmap_demote_l2(pmap, l2, sva)) { + /* + * The large page mapping was destroyed. + */ + continue; + } + } + } if (va_next > eva) va_next = eva; @@ -1903,7 +2357,7 @@ pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t for (l3 = pmap_l2_to_l3(l2, sva); sva != va_next; l3++, sva += L3_SIZE) { l3e = pmap_load(l3); -retry: +retryl3: if ((l3e & PTE_V) == 0) continue; if ((prot & VM_PROT_WRITE) == 0 && @@ -1913,60 +2367,236 @@ retry: vm_page_dirty(m); } if (!atomic_fcmpset_long(l3, &l3e, l3e & ~mask)) - goto retry; - /* XXX: Use pmap_invalidate_range */ - pmap_invalidate_page(pmap, sva); + goto retryl3; + anychanged = true; } } + if (anychanged) + pmap_invalidate_all(pmap); + if (pv_lists_locked) + rw_runlock(&pvh_global_lock); PMAP_UNLOCK(pmap); } int pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_t ftype) { - pt_entry_t orig_l3; - pt_entry_t new_l3; - pt_entry_t *l3; + pd_entry_t *l2, l2e; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:31:30 2019 Return-Path: Delivered-To: svn-src-stable-12@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 851AD15B8575; Tue, 4 Jun 2019 17:31:30 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 29B2F74DD0; Tue, 4 Jun 2019 17:31:30 +0000 (UTC) (envelope-from markj@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 F3E3420B26; Tue, 4 Jun 2019 17:31:29 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HVT0r001509; Tue, 4 Jun 2019 17:31:29 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HVTfJ001508; Tue, 4 Jun 2019 17:31:29 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041731.x54HVTfJ001508@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:31:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348645 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348645 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 29B2F74DD0 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:31:30 -0000 Author: markj Date: Tue Jun 4 17:31:29 2019 New Revision: 348645 URL: https://svnweb.freebsd.org/changeset/base/348645 Log: MFC r344107: Implement pmap_clear_modify() for RISC-V. Modified: stable/12/sys/riscv/riscv/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:31:05 2019 (r348644) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:31:29 2019 (r348645) @@ -4074,6 +4074,14 @@ pmap_advise(pmap_t pmap, vm_offset_t sva, vm_offset_t void pmap_clear_modify(vm_page_t m) { + struct md_page *pvh; + struct rwlock *lock; + pmap_t pmap; + pv_entry_t next_pv, pv; + pd_entry_t *l2, oldl2; + pt_entry_t *l3, oldl3; + vm_offset_t va; + int md_gen, pvh_gen; KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("pmap_clear_modify: page %p is not managed", m)); @@ -4088,8 +4096,78 @@ pmap_clear_modify(vm_page_t m) */ if ((m->aflags & PGA_WRITEABLE) == 0) return; - - /* RISCVTODO: We lack support for tracking if a page is modified */ + pvh = (m->flags & PG_FICTITIOUS) != 0 ? &pv_dummy : + pa_to_pvh(VM_PAGE_TO_PHYS(m)); + lock = VM_PAGE_TO_PV_LIST_LOCK(m); + rw_rlock(&pvh_global_lock); + rw_wlock(lock); +restart: + TAILQ_FOREACH_SAFE(pv, &pvh->pv_list, pv_next, next_pv) { + pmap = PV_PMAP(pv); + if (!PMAP_TRYLOCK(pmap)) { + pvh_gen = pvh->pv_gen; + rw_wunlock(lock); + PMAP_LOCK(pmap); + rw_wlock(lock); + if (pvh_gen != pvh->pv_gen) { + PMAP_UNLOCK(pmap); + goto restart; + } + } + va = pv->pv_va; + l2 = pmap_l2(pmap, va); + oldl2 = pmap_load(l2); + if ((oldl2 & PTE_W) != 0) { + if (pmap_demote_l2_locked(pmap, l2, va, &lock)) { + if ((oldl2 & PTE_SW_WIRED) == 0) { + /* + * Write protect the mapping to a + * single page so that a subsequent + * write access may repromote. + */ + va += VM_PAGE_TO_PHYS(m) - + PTE_TO_PHYS(oldl2); + l3 = pmap_l2_to_l3(l2, va); + oldl3 = pmap_load(l3); + if ((oldl3 & PTE_V) != 0) { + while (!atomic_fcmpset_long(l3, + &oldl3, oldl3 & ~(PTE_D | + PTE_W))) + cpu_spinwait(); + vm_page_dirty(m); + pmap_invalidate_page(pmap, va); + } + } + } + } + PMAP_UNLOCK(pmap); + } + TAILQ_FOREACH(pv, &m->md.pv_list, pv_next) { + pmap = PV_PMAP(pv); + if (!PMAP_TRYLOCK(pmap)) { + md_gen = m->md.pv_gen; + pvh_gen = pvh->pv_gen; + rw_wunlock(lock); + PMAP_LOCK(pmap); + rw_wlock(lock); + if (pvh_gen != pvh->pv_gen || md_gen != m->md.pv_gen) { + PMAP_UNLOCK(pmap); + goto restart; + } + } + l2 = pmap_l2(pmap, pv->pv_va); + KASSERT((pmap_load(l2) & PTE_RWX) == 0, + ("pmap_clear_modify: found a 2mpage in page %p's pv list", + m)); + l3 = pmap_l2_to_l3(l2, pv->pv_va); + if ((pmap_load(l3) & (PTE_D | PTE_W)) == (PTE_D | PTE_W)) { + pmap_clear_bits(l3, PTE_D); + pmap_invalidate_page(pmap, pv->pv_va); + } + PMAP_UNLOCK(pmap); + } + rw_wunlock(lock); + rw_runlock(&pvh_global_lock); } void * From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:32:02 2019 Return-Path: Delivered-To: svn-src-stable-12@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 7A14A15B85E3; Tue, 4 Jun 2019 17:32:02 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1E4EA75087; Tue, 4 Jun 2019 17:32:02 +0000 (UTC) (envelope-from markj@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 EFA4020C57; Tue, 4 Jun 2019 17:32:01 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HW1tX002319; Tue, 4 Jun 2019 17:32:01 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HW0Ql002308; Tue, 4 Jun 2019 17:32:00 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041732.x54HW0Ql002308@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:32:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348646 - in stable/12/sys/riscv: include riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/12/sys/riscv: include riscv X-SVN-Commit-Revision: 348646 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1E4EA75087 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.976,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:32:02 -0000 Author: markj Date: Tue Jun 4 17:31:59 2019 New Revision: 348646 URL: https://svnweb.freebsd.org/changeset/base/348646 Log: MFC r344108: Implement per-CPU pmap activation tracking for RISC-V. Modified: stable/12/sys/riscv/include/pcb.h stable/12/sys/riscv/include/pcpu.h stable/12/sys/riscv/include/pmap.h stable/12/sys/riscv/riscv/genassym.c stable/12/sys/riscv/riscv/machdep.c stable/12/sys/riscv/riscv/mp_machdep.c stable/12/sys/riscv/riscv/pmap.c stable/12/sys/riscv/riscv/swtch.S stable/12/sys/riscv/riscv/vm_machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/include/pcb.h ============================================================================== --- stable/12/sys/riscv/include/pcb.h Tue Jun 4 17:31:29 2019 (r348645) +++ stable/12/sys/riscv/include/pcb.h Tue Jun 4 17:31:59 2019 (r348646) @@ -55,7 +55,6 @@ struct pcb { #define PCB_FP_STARTED 0x1 #define PCB_FP_USERMASK 0x1 uint64_t pcb_sepc; /* Supervisor exception pc */ - vm_offset_t pcb_l1addr; /* L1 page tables base address */ vm_offset_t pcb_onfault; /* Copyinout fault handler */ }; Modified: stable/12/sys/riscv/include/pcpu.h ============================================================================== --- stable/12/sys/riscv/include/pcpu.h Tue Jun 4 17:31:29 2019 (r348645) +++ stable/12/sys/riscv/include/pcpu.h Tue Jun 4 17:31:59 2019 (r348646) @@ -45,6 +45,7 @@ #define ALT_STACK_SIZE 128 #define PCPU_MD_FIELDS \ + struct pmap *pc_curpmap; /* Currently active pmap */ \ uint32_t pc_pending_ipis; /* IPIs pending to this CPU */ \ char __pad[61] Modified: stable/12/sys/riscv/include/pmap.h ============================================================================== --- stable/12/sys/riscv/include/pmap.h Tue Jun 4 17:31:29 2019 (r348645) +++ stable/12/sys/riscv/include/pmap.h Tue Jun 4 17:31:59 2019 (r348646) @@ -41,6 +41,7 @@ #ifndef LOCORE #include +#include #include #include @@ -80,6 +81,8 @@ struct pmap { struct mtx pm_mtx; struct pmap_statistics pm_stats; /* pmap statictics */ pd_entry_t *pm_l1; + u_long pm_satp; /* value for SATP register */ + cpuset_t pm_active; /* active on cpus */ TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */ LIST_ENTRY(pmap) pm_list; /* List of all pmaps */ struct vm_radix pm_root; @@ -137,6 +140,10 @@ extern vm_offset_t virtual_end; #define L1_MAPPABLE_P(va, pa, size) \ ((((va) | (pa)) & L1_OFFSET) == 0 && (size) >= L1_SIZE) +struct thread; + +void pmap_activate_boot(pmap_t); +void pmap_activate_sw(struct thread *); void pmap_bootstrap(vm_offset_t, vm_paddr_t, vm_size_t); void pmap_kenter_device(vm_offset_t, vm_size_t, vm_paddr_t); vm_paddr_t pmap_kextract(vm_offset_t va); Modified: stable/12/sys/riscv/riscv/genassym.c ============================================================================== --- stable/12/sys/riscv/riscv/genassym.c Tue Jun 4 17:31:29 2019 (r348645) +++ stable/12/sys/riscv/riscv/genassym.c Tue Jun 4 17:31:59 2019 (r348646) @@ -63,7 +63,6 @@ ASSYM(TDF_ASTPENDING, TDF_ASTPENDING); ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED); ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); -ASSYM(PCB_L1ADDR, offsetof(struct pcb, pcb_l1addr)); ASSYM(PCB_SIZE, sizeof(struct pcb)); ASSYM(PCB_RA, offsetof(struct pcb, pcb_ra)); ASSYM(PCB_SP, offsetof(struct pcb, pcb_sp)); Modified: stable/12/sys/riscv/riscv/machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/machdep.c Tue Jun 4 17:31:29 2019 (r348645) +++ stable/12/sys/riscv/riscv/machdep.c Tue Jun 4 17:31:59 2019 (r348646) @@ -878,10 +878,6 @@ initriscv(struct riscv_bootparams *rvbp) init_proc0(rvbp->kern_stack); - /* set page table base register for thread0 */ - thread0.td_pcb->pcb_l1addr = \ - (rvbp->kern_l1pt - KERNBASE + rvbp->kern_phys); - msgbufinit(msgbufp, msgbufsize); mutex_init(); init_param2(physmem); Modified: stable/12/sys/riscv/riscv/mp_machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/mp_machdep.c Tue Jun 4 17:31:29 2019 (r348645) +++ stable/12/sys/riscv/riscv/mp_machdep.c Tue Jun 4 17:31:59 2019 (r348646) @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -254,6 +255,9 @@ init_secondary(uint64_t cpu) /* Enable external (PLIC) interrupts */ csr_set(sie, SIE_SEIE); + + /* Activate process 0's pmap. */ + pmap_activate_boot(vmspace_pmap(proc0.p_vmspace)); mtx_lock_spin(&ap_boot_mtx); Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:31:29 2019 (r348645) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:31:59 2019 (r348646) @@ -118,9 +118,10 @@ __FBSDID("$FreeBSD$"); */ #include +#include #include #include -#include +#include #include #include #include @@ -566,6 +567,8 @@ pmap_bootstrap(vm_offset_t l1pt, vm_paddr_t kernstart, rw_init(&pvh_global_lock, "pmap pv global"); + CPU_FILL(&kernel_pmap->pm_active); + /* Assume the address we were loaded to is a valid physical address. */ min_pa = max_pa = kernstart; @@ -723,9 +726,6 @@ pmap_init(void) * In general, the calling thread uses a plain fence to order the * writes to the page tables before invoking an SBI callback to invoke * sfence_vma() on remote CPUs. - * - * Since the riscv pmap does not yet have a pm_active field, IPIs are - * sent to all CPUs in the system. */ static void pmap_invalidate_page(pmap_t pmap, vm_offset_t va) @@ -733,10 +733,11 @@ pmap_invalidate_page(pmap_t pmap, vm_offset_t va) cpuset_t mask; sched_pin(); - mask = all_cpus; + mask = pmap->pm_active; CPU_CLR(PCPU_GET(cpuid), &mask); fence(); - sbi_remote_sfence_vma(mask.__bits, va, 1); + if (!CPU_EMPTY(&mask) && smp_started) + sbi_remote_sfence_vma(mask.__bits, va, 1); sfence_vma_page(va); sched_unpin(); } @@ -747,10 +748,11 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm cpuset_t mask; sched_pin(); - mask = all_cpus; + mask = pmap->pm_active; CPU_CLR(PCPU_GET(cpuid), &mask); fence(); - sbi_remote_sfence_vma(mask.__bits, sva, eva - sva + 1); + if (!CPU_EMPTY(&mask) && smp_started) + sbi_remote_sfence_vma(mask.__bits, sva, eva - sva + 1); /* * Might consider a loop of sfence_vma_page() for a small @@ -766,16 +768,17 @@ pmap_invalidate_all(pmap_t pmap) cpuset_t mask; sched_pin(); - mask = all_cpus; + mask = pmap->pm_active; CPU_CLR(PCPU_GET(cpuid), &mask); - fence(); /* * XXX: The SBI doc doesn't detail how to specify x0 as the * address to perform a global fence. BBL currently treats * all sfence_vma requests as global however. */ - sbi_remote_sfence_vma(mask.__bits, 0, 0); + fence(); + if (!CPU_EMPTY(&mask) && smp_started) + sbi_remote_sfence_vma(mask.__bits, 0, 0); sfence_vma(); sched_unpin(); } @@ -1199,6 +1202,9 @@ pmap_pinit0(pmap_t pmap) PMAP_LOCK_INIT(pmap); bzero(&pmap->pm_stats, sizeof(pmap->pm_stats)); pmap->pm_l1 = kernel_pmap->pm_l1; + pmap->pm_satp = SATP_MODE_SV39 | (vtophys(pmap->pm_l1) >> PAGE_SHIFT); + CPU_ZERO(&pmap->pm_active); + pmap_activate_boot(pmap); } int @@ -1216,12 +1222,15 @@ pmap_pinit(pmap_t pmap) l1phys = VM_PAGE_TO_PHYS(l1pt); pmap->pm_l1 = (pd_entry_t *)PHYS_TO_DMAP(l1phys); + pmap->pm_satp = SATP_MODE_SV39 | (l1phys >> PAGE_SHIFT); if ((l1pt->flags & PG_ZERO) == 0) pagezero(pmap->pm_l1); bzero(&pmap->pm_stats, sizeof(pmap->pm_stats)); + CPU_ZERO(&pmap->pm_active); + /* Install kernel pagetables */ memcpy(pmap->pm_l1, kernel_pmap->pm_l1, PAGE_SIZE); @@ -1411,6 +1420,8 @@ pmap_release(pmap_t pmap) KASSERT(pmap->pm_stats.resident_count == 0, ("pmap_release: pmap resident count %ld != 0", pmap->pm_stats.resident_count)); + KASSERT(CPU_EMPTY(&pmap->pm_active), + ("releasing active pmap %p", pmap)); mtx_lock(&allpmaps_lock); LIST_REMOVE(pmap, pm_list); @@ -4242,26 +4253,56 @@ done: } void -pmap_activate(struct thread *td) +pmap_activate_sw(struct thread *td) { - pmap_t pmap; - uint64_t reg; + pmap_t oldpmap, pmap; + u_int cpu; - critical_enter(); + oldpmap = PCPU_GET(curpmap); pmap = vmspace_pmap(td->td_proc->p_vmspace); - td->td_pcb->pcb_l1addr = vtophys(pmap->pm_l1); + if (pmap == oldpmap) + return; + load_satp(pmap->pm_satp); - reg = SATP_MODE_SV39; - reg |= (td->td_pcb->pcb_l1addr >> PAGE_SHIFT); - load_satp(reg); + cpu = PCPU_GET(cpuid); +#ifdef SMP + CPU_SET_ATOMIC(cpu, &pmap->pm_active); + CPU_CLR_ATOMIC(cpu, &oldpmap->pm_active); +#else + CPU_SET(cpu, &pmap->pm_active); + CPU_CLR(cpu, &oldpmap->pm_active); +#endif + PCPU_SET(curpmap, pmap); - pmap_invalidate_all(pmap); + sfence_vma(); +} + +void +pmap_activate(struct thread *td) +{ + + critical_enter(); + pmap_activate_sw(td); critical_exit(); } void -pmap_sync_icache(pmap_t pm, vm_offset_t va, vm_size_t sz) +pmap_activate_boot(pmap_t pmap) { + u_int cpu; + + cpu = PCPU_GET(cpuid); +#ifdef SMP + CPU_SET_ATOMIC(cpu, &pmap->pm_active); +#else + CPU_SET(cpu, &pmap->pm_active); +#endif + PCPU_SET(curpmap, pmap); +} + +void +pmap_sync_icache(pmap_t pmap, vm_offset_t va, vm_size_t sz) +{ cpuset_t mask; /* @@ -4276,7 +4317,8 @@ pmap_sync_icache(pmap_t pm, vm_offset_t va, vm_size_t mask = all_cpus; CPU_CLR(PCPU_GET(cpuid), &mask); fence(); - sbi_remote_fence_i(mask.__bits); + if (!CPU_EMPTY(&mask) && smp_started) + sbi_remote_fence_i(mask.__bits); sched_unpin(); } Modified: stable/12/sys/riscv/riscv/swtch.S ============================================================================== --- stable/12/sys/riscv/riscv/swtch.S Tue Jun 4 17:31:29 2019 (r348645) +++ stable/12/sys/riscv/riscv/swtch.S Tue Jun 4 17:31:59 2019 (r348646) @@ -207,28 +207,21 @@ ENTRY(fpe_state_clear) END(fpe_state_clear) /* - * void cpu_throw(struct thread *old, struct thread *new) + * void cpu_throw(struct thread *old __unused, struct thread *new) */ ENTRY(cpu_throw) + /* Activate the new thread's pmap. */ + mv s0, a1 + mv a0, a1 + call _C_LABEL(pmap_activate_sw) + mv a0, s0 + /* Store the new curthread */ - sd a1, PC_CURTHREAD(gp) + sd a0, PC_CURTHREAD(gp) /* And the new pcb */ - ld x13, TD_PCB(a1) + ld x13, TD_PCB(a0) sd x13, PC_CURPCB(gp) - sfence.vma - - /* Switch to the new pmap */ - ld t0, PCB_L1ADDR(x13) - srli t0, t0, PAGE_SHIFT - li t1, SATP_MODE_SV39 - or t0, t0, t1 - csrw satp, t0 - - /* TODO: Invalidate the TLB */ - - sfence.vma - /* Load registers */ ld ra, (PCB_RA)(x13) ld sp, (PCB_SP)(x13) @@ -250,7 +243,7 @@ ENTRY(cpu_throw) #ifdef FPE /* Is FPE enabled for new thread? */ - ld t0, TD_FRAME(a1) + ld t0, TD_FRAME(a0) ld t1, (TF_SSTATUS)(t0) li t2, SSTATUS_FS_MASK and t3, t1, t2 @@ -324,38 +317,27 @@ ENTRY(cpu_switch) 1: #endif - /* - * Restore the saved context. - */ - ld x13, TD_PCB(a1) + /* Activate the new thread's pmap */ + mv s0, a0 + mv s1, a1 + mv s2, a2 + mv a0, a1 + call _C_LABEL(pmap_activate_sw) + mv a1, s1 - /* - * TODO: We may need to flush the cache here if switching - * to a user process. - */ - - sfence.vma - - /* Switch to the new pmap */ - ld t0, PCB_L1ADDR(x13) - srli t0, t0, PAGE_SHIFT - li t1, SATP_MODE_SV39 - or t0, t0, t1 - csrw satp, t0 - - /* TODO: Invalidate the TLB */ - - sfence.vma - /* Release the old thread */ - sd a2, TD_LOCK(a0) + sd s2, TD_LOCK(s0) #if defined(SCHED_ULE) && defined(SMP) /* Spin if TD_LOCK points to a blocked_lock */ - la a2, _C_LABEL(blocked_lock) + la s2, _C_LABEL(blocked_lock) 1: ld t0, TD_LOCK(a1) - beq t0, a2, 1b + beq t0, s2, 1b #endif + /* + * Restore the saved context. + */ + ld x13, TD_PCB(a1) /* Restore the registers */ ld tp, (PCB_TP)(x13) Modified: stable/12/sys/riscv/riscv/vm_machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/vm_machdep.c Tue Jun 4 17:31:29 2019 (r348645) +++ stable/12/sys/riscv/riscv/vm_machdep.c Tue Jun 4 17:31:59 2019 (r348646) @@ -92,9 +92,6 @@ cpu_fork(struct thread *td1, struct proc *p2, struct t td2->td_pcb = pcb2; bcopy(td1->td_pcb, pcb2, sizeof(*pcb2)); - td2->td_pcb->pcb_l1addr = - vtophys(vmspace_pmap(td2->td_proc->p_vmspace)->pm_l1); - tf = (struct trapframe *)STACKALIGN((struct trapframe *)pcb2 - 1); bcopy(td1->td_frame, tf, sizeof(*tf)); From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:37:21 2019 Return-Path: Delivered-To: svn-src-stable-12@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 6FBF915B8899; Tue, 4 Jun 2019 17:37:21 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 124CC752B1; Tue, 4 Jun 2019 17:37:21 +0000 (UTC) (envelope-from markj@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 D715320C7C; Tue, 4 Jun 2019 17:37:20 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HbKxS003615; Tue, 4 Jun 2019 17:37:20 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HbKMh003614; Tue, 4 Jun 2019 17:37:20 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041737.x54HbKMh003614@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:37:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348647 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348647 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 124CC752B1 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:37:21 -0000 Author: markj Date: Tue Jun 4 17:37:20 2019 New Revision: 348647 URL: https://svnweb.freebsd.org/changeset/base/348647 Log: MFC r340027 (by jhb): Don't allow debuggers to modify SSTATUS, only to read it. Modified: stable/12/sys/riscv/riscv/machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/machdep.c Tue Jun 4 17:31:59 2019 (r348646) +++ stable/12/sys/riscv/riscv/machdep.c Tue Jun 4 17:37:20 2019 (r348647) @@ -178,7 +178,6 @@ set_regs(struct thread *td, struct reg *regs) frame = td->td_frame; frame->tf_sepc = regs->sepc; - frame->tf_sstatus = regs->sstatus; frame->tf_ra = regs->ra; frame->tf_sp = regs->sp; frame->tf_gp = regs->gp; From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:37:51 2019 Return-Path: Delivered-To: svn-src-stable-12@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 9AE9915B88FB; Tue, 4 Jun 2019 17:37:51 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3DD51753C1; Tue, 4 Jun 2019 17:37:51 +0000 (UTC) (envelope-from markj@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 1845C20C7E; Tue, 4 Jun 2019 17:37:51 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54HboNo003682; Tue, 4 Jun 2019 17:37:50 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54Hbo8a003680; Tue, 4 Jun 2019 17:37:50 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906041737.x54Hbo8a003680@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Jun 2019 17:37:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348648 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 348648 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3DD51753C1 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:37:51 -0000 Author: markj Date: Tue Jun 4 17:37:50 2019 New Revision: 348648 URL: https://svnweb.freebsd.org/changeset/base/348648 Log: MFC r340028 (by jhb): SBI calls expect a pointer to a u_long rather than a pointer. Modified: stable/12/sys/riscv/riscv/intr_machdep.c stable/12/sys/riscv/riscv/mp_machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/intr_machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/intr_machdep.c Tue Jun 4 17:37:20 2019 (r348647) +++ stable/12/sys/riscv/riscv/intr_machdep.c Tue Jun 4 17:37:50 2019 (r348648) @@ -202,7 +202,7 @@ riscv_unmask_ipi(void) static void ipi_send(struct pcpu *pc, int ipi) { - uintptr_t mask; + u_long mask; CTR3(KTR_SMP, "%s: cpu=%d, ipi=%x", __func__, pc->pc_cpuid, ipi); @@ -242,7 +242,7 @@ void ipi_selected(cpuset_t cpus, u_int ipi) { struct pcpu *pc; - uintptr_t mask; + u_long mask; CTR1(KTR_SMP, "ipi_selected: ipi: %x", ipi); Modified: stable/12/sys/riscv/riscv/mp_machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/mp_machdep.c Tue Jun 4 17:37:20 2019 (r348647) +++ stable/12/sys/riscv/riscv/mp_machdep.c Tue Jun 4 17:37:50 2019 (r348648) @@ -182,7 +182,7 @@ riscv64_cpu_attach(device_t dev) static void release_aps(void *dummy __unused) { - uintptr_t mask; + u_long mask; int cpu, i; if (mp_ncpus == 1) From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:39:48 2019 Return-Path: Delivered-To: svn-src-stable-12@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 C6C7615B89D1; Tue, 4 Jun 2019 17:39:48 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 699BF7556A; Tue, 4 Jun 2019 17:39:48 +0000 (UTC) (envelope-from br@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 556F620C7F; Tue, 4 Jun 2019 17:39:48 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54Hdmhv003825; Tue, 4 Jun 2019 17:39:48 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HdlSC003820; Tue, 4 Jun 2019 17:39:47 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041739.x54HdlSC003820@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 17:39:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348649 - in stable/12/sys/riscv: include riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: in stable/12/sys/riscv: include riscv X-SVN-Commit-Revision: 348649 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 699BF7556A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.976,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:39:49 -0000 Author: br Date: Tue Jun 4 17:39:46 2019 New Revision: 348649 URL: https://svnweb.freebsd.org/changeset/base/348649 Log: MFC r347514: Add support for HiFive Unleashed -- the board with a multi-core RISC-V SoC from SiFive, Inc. The first core on this SoC (hart 0) is a 64-bit microcontroller. o Pick a hart to run boot process using hart lottery. This allows to exclude hart 0 from running the boot process. (BBL releases hart 0 after the main harts, so it never wins the lottery). o Renumber CPUs early on boot. Exclude non-MMU cores. Store the original hart ID in struct pcpu. This allows to find out the correct destination for IPIs and remote sfence calls. Thanks to SiFive, Inc for the board provided. Sponsored by: DARPA, AFRL Modified: stable/12/sys/riscv/include/pcpu.h stable/12/sys/riscv/riscv/intr_machdep.c stable/12/sys/riscv/riscv/locore.S stable/12/sys/riscv/riscv/machdep.c stable/12/sys/riscv/riscv/mp_machdep.c stable/12/sys/riscv/riscv/pmap.c Modified: stable/12/sys/riscv/include/pcpu.h ============================================================================== --- stable/12/sys/riscv/include/pcpu.h Tue Jun 4 17:37:50 2019 (r348648) +++ stable/12/sys/riscv/include/pcpu.h Tue Jun 4 17:39:46 2019 (r348649) @@ -47,7 +47,8 @@ #define PCPU_MD_FIELDS \ struct pmap *pc_curpmap; /* Currently active pmap */ \ uint32_t pc_pending_ipis; /* IPIs pending to this CPU */ \ - char __pad[61] + uint32_t pc_hart; /* Hart ID */ \ + char __pad[57] #ifdef _KERNEL Modified: stable/12/sys/riscv/riscv/intr_machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/intr_machdep.c Tue Jun 4 17:37:50 2019 (r348648) +++ stable/12/sys/riscv/riscv/intr_machdep.c Tue Jun 4 17:39:46 2019 (r348649) @@ -207,7 +207,7 @@ ipi_send(struct pcpu *pc, int ipi) CTR3(KTR_SMP, "%s: cpu=%d, ipi=%x", __func__, pc->pc_cpuid, ipi); atomic_set_32(&pc->pc_pending_ipis, ipi); - mask = (1 << (pc->pc_cpuid)); + mask = (1 << pc->pc_hart); sbi_send_ipi(&mask); @@ -252,7 +252,7 @@ ipi_selected(cpuset_t cpus, u_int ipi) CTR3(KTR_SMP, "%s: pc: %p, ipi: %x\n", __func__, pc, ipi); atomic_set_32(&pc->pc_pending_ipis, ipi); - mask |= (1 << (pc->pc_cpuid)); + mask |= (1 << pc->pc_hart); } } sbi_send_ipi(&mask); Modified: stable/12/sys/riscv/riscv/locore.S ============================================================================== --- stable/12/sys/riscv/riscv/locore.S Tue Jun 4 17:37:50 2019 (r348648) +++ stable/12/sys/riscv/riscv/locore.S Tue Jun 4 17:39:46 2019 (r348649) @@ -59,12 +59,18 @@ _start: sub t1, t1, t0 li t2, KERNBASE sub s9, t2, t1 /* s9 = physmem base */ - mv s10, a0 /* s10 = hart id */ - mv s11, a1 /* s11 = dtbp */ - /* Direct secondary cores to mpentry */ - bnez s10, mpentry + /* + * a0 = hart id + * a1 = dtbp + */ + /* Pick a hart to run the boot process. */ + la t0, hart_lottery + li t1, 1 + amoadd.w t0, t1, 0(t0) + bnez t0, mpentry + /* * Page tables */ @@ -123,7 +129,7 @@ _start: /* Create an L2 page superpage for DTB */ la s1, pagetable_l2_devmap - mv s2, s11 + mv s2, a1 srli s2, s2, PAGE_SHIFT li t0, (PTE_KERN) @@ -171,13 +177,19 @@ va: addi sp, sp, -PCB_SIZE /* Clear BSS */ - la a0, _C_LABEL(__bss_start) + la s0, _C_LABEL(__bss_start) la s1, _C_LABEL(_end) 1: - sd zero, 0(a0) - addi a0, a0, 8 - bltu a0, s1, 1b + sd zero, 0(s0) + addi s0, s0, 8 + bltu s0, s1, 1b +#ifdef SMP + /* Store boot hart id. */ + la t0, boot_hart + sw a0, 0(t0) +#endif + /* Fill riscv_bootparams */ addi sp, sp, -40 @@ -190,7 +202,7 @@ va: li t0, (VM_MAX_KERNEL_ADDRESS - 2 * L2_SIZE) sd t0, 24(sp) /* dtbp_virt */ - sd s11, 32(sp) /* dtbp_phys */ + sd a1, 32(sp) /* dtbp_phys */ mv a0, sp call _C_LABEL(initriscv) /* Off we go */ @@ -233,9 +245,11 @@ pagetable_l2: pagetable_l2_devmap: .space PAGE_SIZE - .align 3 + .align 3 virt_map: - .quad virt_map + .quad virt_map +hart_lottery: + .space 4 /* Not in use, but required for linking. */ .align 3 @@ -278,7 +292,8 @@ ENTRY(mpentry) /* Setup stack pointer */ la t0, secondary_stacks li t1, (PAGE_SIZE * KSTACK_PAGES) - mulw t1, t1, s10 + mulw t2, t1, a0 + add t0, t0, t2 add t0, t0, t1 sub t0, t0, s9 li t1, KERNBASE Modified: stable/12/sys/riscv/riscv/machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/machdep.c Tue Jun 4 17:37:50 2019 (r348648) +++ stable/12/sys/riscv/riscv/machdep.c Tue Jun 4 17:39:46 2019 (r348649) @@ -117,6 +117,9 @@ int64_t dcache_line_size; /* The minimum D cache line int64_t icache_line_size; /* The minimum I cache line size */ int64_t idcache_line_size; /* The minimum cache line size */ +uint32_t boot_hart; /* The hart we booted on. */ +cpuset_t all_harts; + extern int *end; extern int *initstack_end; @@ -858,6 +861,7 @@ initriscv(struct riscv_bootparams *rvbp) /* Set the pcpu data, this is needed by pmap_bootstrap */ pcpup = &__pcpu[0]; pcpu_init(pcpup, 0, sizeof(struct pcpu)); + pcpup->pc_hart = boot_hart; /* Set the pcpu pointer */ __asm __volatile("mv gp, %0" :: "r"(pcpup)); Modified: stable/12/sys/riscv/riscv/mp_machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/mp_machdep.c Tue Jun 4 17:37:50 2019 (r348648) +++ stable/12/sys/riscv/riscv/mp_machdep.c Tue Jun 4 17:39:46 2019 (r348649) @@ -91,6 +91,9 @@ static int ipi_handler(void *); struct mtx ap_boot_mtx; struct pcb stoppcbs[MAXCPU]; +extern uint32_t boot_hart; +extern cpuset_t all_harts; + #ifdef INVARIANTS static uint32_t cpu_reg[MAXCPU][2]; #endif @@ -99,7 +102,7 @@ static device_t cpu_list[MAXCPU]; void mpentry(unsigned long cpuid); void init_secondary(uint64_t); -uint8_t secondary_stacks[MAXCPU - 1][PAGE_SIZE * KSTACK_PAGES] __aligned(16); +uint8_t secondary_stacks[MAXCPU][PAGE_SIZE * KSTACK_PAGES] __aligned(16); /* Set to 1 once we're ready to let the APs out of the pen. */ volatile int aps_ready = 0; @@ -182,7 +185,7 @@ riscv64_cpu_attach(device_t dev) static void release_aps(void *dummy __unused) { - u_long mask; + cpuset_t mask; int cpu, i; if (mp_ncpus == 1) @@ -194,15 +197,13 @@ release_aps(void *dummy __unused) atomic_store_rel_int(&aps_ready, 1); /* Wake up the other CPUs */ - mask = 0; + mask = all_harts; + CPU_CLR(boot_hart, &mask); - for (i = 1; i < mp_ncpus; i++) - mask |= (1 << i); - - sbi_send_ipi(&mask); - printf("Release APs\n"); + sbi_send_ipi(mask.__bits); + for (i = 0; i < 2000; i++) { if (smp_started) { for (cpu = 0; cpu <= mp_maxid; cpu++) { @@ -219,12 +220,19 @@ release_aps(void *dummy __unused) SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL); void -init_secondary(uint64_t cpu) +init_secondary(uint64_t hart) { struct pcpu *pcpup; + u_int cpuid; + /* Renumber this cpu */ + cpuid = hart; + if (cpuid < boot_hart) + cpuid += mp_maxid + 1; + cpuid -= boot_hart; + /* Setup the pcpu pointer */ - pcpup = &__pcpu[cpu]; + pcpup = &__pcpu[cpuid]; __asm __volatile("mv gp, %0" :: "r"(pcpup)); /* Workaround: make sure wfi doesn't halt the hart */ @@ -366,11 +374,12 @@ cpu_mp_probe(void) static boolean_t cpu_init_fdt(u_int id, phandle_t node, u_int addr_size, pcell_t *reg) { - uint64_t target_cpu; struct pcpu *pcpup; + uint64_t hart; + u_int cpuid; - /* Check we are able to start this cpu */ - if (id > mp_maxid) + /* Check if this hart supports MMU. */ + if (OF_getproplen(node, "mmu-type") < 0) return (0); KASSERT(id < MAXCPU, ("Too many CPUs")); @@ -382,29 +391,44 @@ cpu_init_fdt(u_int id, phandle_t node, u_int addr_size cpu_reg[id][1] = reg[1]; #endif - target_cpu = reg[0]; + hart = reg[0]; if (addr_size == 2) { - target_cpu <<= 32; - target_cpu |= reg[1]; + hart <<= 32; + hart |= reg[1]; } - pcpup = &__pcpu[id]; + KASSERT(hart < MAXCPU, ("Too many harts.")); - /* We are already running on cpu 0 */ - if (id == 0) { + /* We are already running on this cpu */ + if (hart == boot_hart) return (1); - } - pcpu_init(pcpup, id, sizeof(struct pcpu)); + /* + * Rotate the CPU IDs to put the boot CPU as CPU 0. + * We keep the other CPUs ordered. + */ + cpuid = hart; + if (cpuid < boot_hart) + cpuid += mp_maxid + 1; + cpuid -= boot_hart; - dpcpu[id - 1] = (void *)kmem_malloc(DPCPU_SIZE, M_WAITOK | M_ZERO); - dpcpu_init(dpcpu[id - 1], id); + /* Check if we are able to start this cpu */ + if (cpuid > mp_maxid) + return (0); - printf("Starting CPU %u (%lx)\n", id, target_cpu); - __riscv_boot_ap[id] = 1; + pcpup = &__pcpu[cpuid]; + pcpu_init(pcpup, cpuid, sizeof(struct pcpu)); + pcpup->pc_hart = hart; - CPU_SET(id, &all_cpus); + dpcpu[cpuid - 1] = (void *)kmem_malloc(DPCPU_SIZE, M_WAITOK | M_ZERO); + dpcpu_init(dpcpu[cpuid - 1], cpuid); + printf("Starting CPU %u (hart %lx)\n", cpuid, hart); + __riscv_boot_ap[hart] = 1; + + CPU_SET(cpuid, &all_cpus); + CPU_SET(hart, &all_harts); + return (1); } #endif @@ -417,6 +441,7 @@ cpu_mp_start(void) mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); CPU_SET(0, &all_cpus); + CPU_SET(boot_hart, &all_harts); switch(cpu_enum_method) { #ifdef FDT @@ -435,13 +460,24 @@ cpu_mp_announce(void) { } +static boolean_t +cpu_check_mmu(u_int id, phandle_t node, u_int addr_size, pcell_t *reg) +{ + + /* Check if this hart supports MMU. */ + if (OF_getproplen(node, "mmu-type") < 0) + return (0); + + return (1); +} + void cpu_mp_setmaxid(void) { #ifdef FDT int cores; - cores = ofw_cpu_early_foreach(NULL, false); + cores = ofw_cpu_early_foreach(cpu_check_mmu, true); if (cores > 0) { cores = MIN(cores, MAXCPU); if (bootverbose) Modified: stable/12/sys/riscv/riscv/pmap.c ============================================================================== --- stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:37:50 2019 (r348648) +++ stable/12/sys/riscv/riscv/pmap.c Tue Jun 4 17:39:46 2019 (r348649) @@ -273,6 +273,8 @@ static struct rwlock pv_list_locks[NPV_LIST_LOCKS]; static struct md_page *pv_table; static struct md_page pv_dummy; +extern cpuset_t all_harts; + /* * Internal flags for pmap_enter()'s helper functions. */ @@ -734,7 +736,7 @@ pmap_invalidate_page(pmap_t pmap, vm_offset_t va) sched_pin(); mask = pmap->pm_active; - CPU_CLR(PCPU_GET(cpuid), &mask); + CPU_CLR(PCPU_GET(hart), &mask); fence(); if (!CPU_EMPTY(&mask) && smp_started) sbi_remote_sfence_vma(mask.__bits, va, 1); @@ -749,7 +751,7 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm sched_pin(); mask = pmap->pm_active; - CPU_CLR(PCPU_GET(cpuid), &mask); + CPU_CLR(PCPU_GET(hart), &mask); fence(); if (!CPU_EMPTY(&mask) && smp_started) sbi_remote_sfence_vma(mask.__bits, sva, eva - sva + 1); @@ -769,7 +771,7 @@ pmap_invalidate_all(pmap_t pmap) sched_pin(); mask = pmap->pm_active; - CPU_CLR(PCPU_GET(cpuid), &mask); + CPU_CLR(PCPU_GET(hart), &mask); /* * XXX: The SBI doc doesn't detail how to specify x0 as the @@ -4256,7 +4258,7 @@ void pmap_activate_sw(struct thread *td) { pmap_t oldpmap, pmap; - u_int cpu; + u_int hart; oldpmap = PCPU_GET(curpmap); pmap = vmspace_pmap(td->td_proc->p_vmspace); @@ -4264,13 +4266,13 @@ pmap_activate_sw(struct thread *td) return; load_satp(pmap->pm_satp); - cpu = PCPU_GET(cpuid); + hart = PCPU_GET(hart); #ifdef SMP - CPU_SET_ATOMIC(cpu, &pmap->pm_active); - CPU_CLR_ATOMIC(cpu, &oldpmap->pm_active); + CPU_SET_ATOMIC(hart, &pmap->pm_active); + CPU_CLR_ATOMIC(hart, &oldpmap->pm_active); #else - CPU_SET(cpu, &pmap->pm_active); - CPU_CLR(cpu, &oldpmap->pm_active); + CPU_SET(hart, &pmap->pm_active); + CPU_CLR(hart, &oldpmap->pm_active); #endif PCPU_SET(curpmap, pmap); @@ -4289,13 +4291,13 @@ pmap_activate(struct thread *td) void pmap_activate_boot(pmap_t pmap) { - u_int cpu; + u_int hart; - cpu = PCPU_GET(cpuid); + hart = PCPU_GET(hart); #ifdef SMP - CPU_SET_ATOMIC(cpu, &pmap->pm_active); + CPU_SET_ATOMIC(hart, &pmap->pm_active); #else - CPU_SET(cpu, &pmap->pm_active); + CPU_SET(hart, &pmap->pm_active); #endif PCPU_SET(curpmap, pmap); } @@ -4314,8 +4316,8 @@ pmap_sync_icache(pmap_t pmap, vm_offset_t va, vm_size_ * FENCE.I." */ sched_pin(); - mask = all_cpus; - CPU_CLR(PCPU_GET(cpuid), &mask); + mask = all_harts; + CPU_CLR(PCPU_GET(hart), &mask); fence(); if (!CPU_EMPTY(&mask) && smp_started) sbi_remote_fence_i(mask.__bits); From owner-svn-src-stable-12@freebsd.org Tue Jun 4 17:42:48 2019 Return-Path: Delivered-To: svn-src-stable-12@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 ACB0D15B8C02; Tue, 4 Jun 2019 17:42:48 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 50ED575B16; Tue, 4 Jun 2019 17:42:48 +0000 (UTC) (envelope-from br@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 24E9220E33; Tue, 4 Jun 2019 17:42:48 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x54Hgmgg008551; Tue, 4 Jun 2019 17:42:48 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54HgmZD008550; Tue, 4 Jun 2019 17:42:48 GMT (envelope-from br@FreeBSD.org) Message-Id: <201906041742.x54HgmZD008550@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 4 Jun 2019 17:42:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348650 - stable/12/sys/dev/xdma X-SVN-Group: stable-12 X-SVN-Commit-Author: br X-SVN-Commit-Paths: stable/12/sys/dev/xdma X-SVN-Commit-Revision: 348650 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 50ED575B16 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 17:42:48 -0000 Author: br Date: Tue Jun 4 17:42:47 2019 New Revision: 348650 URL: https://svnweb.freebsd.org/changeset/base/348650 Log: MFC r348364: Don't copy the data from bounce buffer back to the mbuf if channel does not use bounce buffering. Sponsored by: DARPA, AFRL Modified: stable/12/sys/dev/xdma/xdma_sg.c Modified: stable/12/sys/dev/xdma/xdma_sg.c ============================================================================== --- stable/12/sys/dev/xdma/xdma_sg.c Tue Jun 4 17:39:46 2019 (r348649) +++ stable/12/sys/dev/xdma/xdma_sg.c Tue Jun 4 17:42:47 2019 (r348650) @@ -345,7 +345,8 @@ xchan_seg_done(xdma_channel_t *xchan, BUS_DMASYNC_POSTREAD); bus_dmamap_unload(xchan->dma_tag_bufs, b->map); } else { - if (xr->req_type == XR_TYPE_MBUF && + if ((xchan->caps & XCHAN_CAP_NOBUFS) == 0 && + xr->req_type == XR_TYPE_MBUF && xr->direction == XDMA_DEV_TO_MEM) m_copyback(xr->m, 0, st->transferred, (void *)xr->buf.vaddr); From owner-svn-src-stable-12@freebsd.org Tue Jun 4 18:11:13 2019 Return-Path: Delivered-To: svn-src-stable-12@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 0C89715B9873; Tue, 4 Jun 2019 18:11:13 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B533B76BD8; Tue, 4 Jun 2019 18:11: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 8EAB6212C7; Tue, 4 Jun 2019 18:11: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 x54IBCQS022130; Tue, 4 Jun 2019 18:11:12 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54IBC2t022129; Tue, 4 Jun 2019 18:11:12 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201906041811.x54IBC2t022129@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 4 Jun 2019 18:11:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348651 - stable/12/sys/dev/vt/hw/efifb X-SVN-Group: stable-12 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/12/sys/dev/vt/hw/efifb X-SVN-Commit-Revision: 348651 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B533B76BD8 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 18:11:13 -0000 Author: emaste Date: Tue Jun 4 18:11:12 2019 New Revision: 348651 URL: https://svnweb.freebsd.org/changeset/base/348651 Log: MFC r348059: vt efifb: add suspend/resume calls Using the latest NVIDIA driver, upon resuming from suspend with X running the display remained blank. Additionally OpenGL applications that were running triggered a number of error messages from the NVIDIA driver. This occurred because the vt efifb back-end did not signal the X server to release the display before suspending (or to re-acquire it after resuming). The NVIDIA driver includes code for smoothly shutting down and re-initializing the GPU, which was not getting called. Since the NVIDIA driver doesn't currently support framebuffer devices and vt is forced to fall back to the efifb back-end, add vd_suspend and vd_resume members to connect the suspend/resume path. This ensures the X server is properly able to re-initialize the display. PR: 237050 Submitted by: Erik Kurzinger Modified: stable/12/sys/dev/vt/hw/efifb/efifb.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/vt/hw/efifb/efifb.c ============================================================================== --- stable/12/sys/dev/vt/hw/efifb/efifb.c Tue Jun 4 17:42:47 2019 (r348650) +++ stable/12/sys/dev/vt/hw/efifb/efifb.c Tue Jun 4 18:11:12 2019 (r348651) @@ -64,6 +64,8 @@ static struct vt_driver vt_efifb_driver = { .vd_setpixel = vt_fb_setpixel, .vd_fb_ioctl = vt_fb_ioctl, .vd_fb_mmap = vt_fb_mmap, + .vd_suspend = vt_suspend, + .vd_resume = vt_resume, /* Better than VGA, but still generic driver. */ .vd_priority = VD_PRIORITY_GENERIC + 1, }; From owner-svn-src-stable-12@freebsd.org Tue Jun 4 20:37:03 2019 Return-Path: Delivered-To: svn-src-stable-12@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 0CF3115BCCED; Tue, 4 Jun 2019 20:37:03 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A979E8536B; Tue, 4 Jun 2019 20:37:02 +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 84C0422B33; Tue, 4 Jun 2019 20:37:02 +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 x54Kb2YU099603; Tue, 4 Jun 2019 20:37:02 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54Kb17k099597; Tue, 4 Jun 2019 20:37:01 GMT (envelope-from np@FreeBSD.org) Message-Id: <201906042037.x54Kb17k099597@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Tue, 4 Jun 2019 20:37:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348670 - in stable/12/sys/dev/cxgbe: cxgbei tom X-SVN-Group: stable-12 X-SVN-Commit-Author: np X-SVN-Commit-Paths: in stable/12/sys/dev/cxgbe: cxgbei tom X-SVN-Commit-Revision: 348670 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: A979E8536B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 20:37:03 -0000 Author: np Date: Tue Jun 4 20:37:00 2019 New Revision: 348670 URL: https://svnweb.freebsd.org/changeset/base/348670 Log: MFC r348491: cxgbe/t4_tom: adjust the hardware receive window to match changes to the receive sockbuf's high water mark. Calculate rx credits on the spot instead of tracking sbused/sb_cc and rx_credits in the toepcb. The previous method worked when the high water mark changed due to SB_AUTOSIZE but not when it was adjusted directly (for example, by the soreserve in nfsrvd_addsock). This fixes a connection hang while running iozone over an NFS mounted share where nfsd's TCP sockets are being handled by t4_tom. Sponsored by: Chelsio Communications Modified: stable/12/sys/dev/cxgbe/cxgbei/cxgbei.c stable/12/sys/dev/cxgbe/tom/t4_connect.c stable/12/sys/dev/cxgbe/tom/t4_cpl_io.c stable/12/sys/dev/cxgbe/tom/t4_ddp.c stable/12/sys/dev/cxgbe/tom/t4_listen.c stable/12/sys/dev/cxgbe/tom/t4_tls.c stable/12/sys/dev/cxgbe/tom/t4_tom.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/cxgbe/cxgbei/cxgbei.c ============================================================================== --- stable/12/sys/dev/cxgbe/cxgbei/cxgbei.c Tue Jun 4 19:59:43 2019 (r348669) +++ stable/12/sys/dev/cxgbe/cxgbei/cxgbei.c Tue Jun 4 20:37:00 2019 (r348670) @@ -397,7 +397,6 @@ do_rx_iscsi_ddp(struct sge_iq *iq, const struct rss_he tp->t_rcvtime = ticks; /* update rx credits */ - toep->rx_credits += pdu_len; t4_rcvd(&toep->td->tod, tp); /* XXX: sc->tom_softc.tod */ so = inp->inp_socket; Modified: stable/12/sys/dev/cxgbe/tom/t4_connect.c ============================================================================== --- stable/12/sys/dev/cxgbe/tom/t4_connect.c Tue Jun 4 19:59:43 2019 (r348669) +++ stable/12/sys/dev/cxgbe/tom/t4_connect.c Tue Jun 4 20:37:00 2019 (r348670) @@ -385,8 +385,7 @@ t4_connect(struct toedev *tod, struct socket *so, stru toep->vnet = so->so_vnet; set_ulp_mode(toep, select_ulp_mode(so, sc, &settings)); SOCKBUF_LOCK(&so->so_rcv); - /* opt0 rcv_bufsiz initially, assumes its normal meaning later */ - toep->rx_credits = min(select_rcv_wnd(so) >> 10, M_RCV_BUFSIZ); + toep->opt0_rcv_bufsize = min(select_rcv_wnd(so) >> 10, M_RCV_BUFSIZ); SOCKBUF_UNLOCK(&so->so_rcv); /* @@ -440,7 +439,7 @@ t4_connect(struct toedev *tod, struct socket *so, stru cpl->peer_ip_hi = *(uint64_t *)&inp->in6p_faddr.s6_addr[0]; cpl->peer_ip_lo = *(uint64_t *)&inp->in6p_faddr.s6_addr[8]; cpl->opt0 = calc_opt0(so, vi, toep->l2te, mtu_idx, rscale, - toep->rx_credits, toep->ulp_mode, &settings); + toep->opt0_rcv_bufsize, toep->ulp_mode, &settings); cpl->opt2 = calc_opt2a(so, toep, &settings); } else { struct cpl_act_open_req *cpl = wrtod(wr); @@ -469,7 +468,7 @@ t4_connect(struct toedev *tod, struct socket *so, stru inp_4tuple_get(inp, &cpl->local_ip, &cpl->local_port, &cpl->peer_ip, &cpl->peer_port); cpl->opt0 = calc_opt0(so, vi, toep->l2te, mtu_idx, rscale, - toep->rx_credits, toep->ulp_mode, &settings); + toep->opt0_rcv_bufsize, toep->ulp_mode, &settings); cpl->opt2 = calc_opt2a(so, toep, &settings); } Modified: stable/12/sys/dev/cxgbe/tom/t4_cpl_io.c ============================================================================== --- stable/12/sys/dev/cxgbe/tom/t4_cpl_io.c Tue Jun 4 19:59:43 2019 (r348669) +++ stable/12/sys/dev/cxgbe/tom/t4_cpl_io.c Tue Jun 4 20:37:00 2019 (r348670) @@ -399,20 +399,10 @@ make_established(struct toepcb *toep, uint32_t iss, ui tp->irs = irs; tcp_rcvseqinit(tp); - tp->rcv_wnd = toep->rx_credits << 10; + tp->rcv_wnd = toep->opt0_rcv_bufsize << 10; tp->rcv_adv += tp->rcv_wnd; tp->last_ack_sent = tp->rcv_nxt; - /* - * If we were unable to send all rx credits via opt0, save the remainder - * in rx_credits so that they can be handed over with the next credit - * update. - */ - SOCKBUF_LOCK(&so->so_rcv); - bufsize = select_rcv_wnd(so); - SOCKBUF_UNLOCK(&so->so_rcv); - toep->rx_credits = bufsize - tp->rcv_wnd; - tp->iss = iss; tcp_sendseqinit(tp); tp->snd_una = iss + 1; @@ -483,37 +473,29 @@ t4_rcvd_locked(struct toedev *tod, struct tcpcb *tp) struct socket *so = inp->inp_socket; struct sockbuf *sb = &so->so_rcv; struct toepcb *toep = tp->t_toe; - int credits; + int rx_credits; INP_WLOCK_ASSERT(inp); - SOCKBUF_LOCK_ASSERT(sb); - KASSERT(toep->sb_cc >= sbused(sb), - ("%s: sb %p has more data (%d) than last time (%d).", - __func__, sb, sbused(sb), toep->sb_cc)); - credits = toep->sb_cc - sbused(sb); - toep->sb_cc = sbused(sb); + rx_credits = sbspace(sb) > tp->rcv_wnd ? sbspace(sb) - tp->rcv_wnd : 0; if (toep->ulp_mode == ULP_MODE_TLS) { - if (toep->tls.rcv_over >= credits) { - toep->tls.rcv_over -= credits; - credits = 0; + if (toep->tls.rcv_over >= rx_credits) { + toep->tls.rcv_over -= rx_credits; + rx_credits = 0; } else { - credits -= toep->tls.rcv_over; + rx_credits -= toep->tls.rcv_over; toep->tls.rcv_over = 0; } } - toep->rx_credits += credits; - if (toep->rx_credits > 0 && - (tp->rcv_wnd <= 32 * 1024 || toep->rx_credits >= 64 * 1024 || - (toep->rx_credits >= 16 * 1024 && tp->rcv_wnd <= 128 * 1024) || - toep->sb_cc + tp->rcv_wnd < sb->sb_lowat)) { - - credits = send_rx_credits(sc, toep, toep->rx_credits); - toep->rx_credits -= credits; - tp->rcv_wnd += credits; - tp->rcv_adv += credits; + if (rx_credits > 0 && + (tp->rcv_wnd <= 32 * 1024 || rx_credits >= 64 * 1024 || + (rx_credits >= 16 * 1024 && tp->rcv_wnd <= 128 * 1024) || + sbused(sb) + tp->rcv_wnd < sb->sb_lowat)) { + rx_credits = send_rx_credits(sc, toep, rx_credits); + tp->rcv_wnd += rx_credits; + tp->rcv_adv += rx_credits; } else if (toep->flags & TPF_FORCE_CREDITS) send_rx_modulate(sc, toep); } @@ -1551,7 +1533,7 @@ do_rx_data(struct sge_iq *iq, const struct rss_header struct socket *so; struct sockbuf *sb; struct epoch_tracker et; - int len; + int len, rx_credits; uint32_t ddp_placed = 0; if (__predict_false(toep->flags & TPF_SYNQE)) { @@ -1636,8 +1618,6 @@ do_rx_data(struct sge_iq *iq, const struct rss_header if (!sbreserve_locked(sb, newsize, so, NULL)) sb->sb_flags &= ~SB_AUTOSIZE; - else - toep->rx_credits += newsize - hiwat; } if (toep->ulp_mode == ULP_MODE_TCPDDP) { @@ -1675,19 +1655,12 @@ do_rx_data(struct sge_iq *iq, const struct rss_header } } - KASSERT(toep->sb_cc >= sbused(sb), - ("%s: sb %p has more data (%d) than last time (%d).", - __func__, sb, sbused(sb), toep->sb_cc)); - toep->rx_credits += toep->sb_cc - sbused(sb); sbappendstream_locked(sb, m, 0); - toep->sb_cc = sbused(sb); - if (toep->rx_credits > 0 && toep->sb_cc + tp->rcv_wnd < sb->sb_lowat) { - int credits; - - credits = send_rx_credits(sc, toep, toep->rx_credits); - toep->rx_credits -= credits; - tp->rcv_wnd += credits; - tp->rcv_adv += credits; + rx_credits = sbspace(sb) > tp->rcv_wnd ? sbspace(sb) - tp->rcv_wnd : 0; + if (rx_credits > 0 && sbused(sb) + tp->rcv_wnd < sb->sb_lowat) { + rx_credits = send_rx_credits(sc, toep, rx_credits); + tp->rcv_wnd += rx_credits; + tp->rcv_adv += rx_credits; } if (toep->ulp_mode == ULP_MODE_TCPDDP && toep->ddp.waiting_count > 0 && Modified: stable/12/sys/dev/cxgbe/tom/t4_ddp.c ============================================================================== --- stable/12/sys/dev/cxgbe/tom/t4_ddp.c Tue Jun 4 19:59:43 2019 (r348669) +++ stable/12/sys/dev/cxgbe/tom/t4_ddp.c Tue Jun 4 20:37:00 2019 (r348670) @@ -304,9 +304,6 @@ insert_ddp_data(struct toepcb *toep, uint32_t n) KASSERT(tp->rcv_wnd >= n, ("%s: negative window size", __func__)); tp->rcv_wnd -= n; #endif -#ifndef USE_DDP_RX_FLOW_CONTROL - toep->rx_credits += n; -#endif CTR2(KTR_CXGBE, "%s: placed %u bytes before falling out of DDP", __func__, n); while (toep->ddp.active_count > 0) { @@ -555,16 +552,10 @@ handle_ddp_data(struct toepcb *toep, __be32 ddp_report if (!sbreserve_locked(sb, newsize, so, NULL)) sb->sb_flags &= ~SB_AUTOSIZE; - else - toep->rx_credits += newsize - hiwat; } SOCKBUF_UNLOCK(sb); CURVNET_RESTORE(); -#ifndef USE_DDP_RX_FLOW_CONTROL - toep->rx_credits += len; -#endif - job->msgrcv = 1; if (db->cancel_pending) { /* @@ -713,12 +704,9 @@ handle_ddp_close(struct toepcb *toep, struct tcpcb *tp INP_WLOCK_ASSERT(toep->inp); DDP_ASSERT_LOCKED(toep); - len = be32toh(rcv_nxt) - tp->rcv_nxt; + len = be32toh(rcv_nxt) - tp->rcv_nxt; tp->rcv_nxt += len; -#ifndef USE_DDP_RX_FLOW_CONTROL - toep->rx_credits += len; -#endif while (toep->ddp.active_count > 0) { MPASS(toep->ddp.active_id != -1); Modified: stable/12/sys/dev/cxgbe/tom/t4_listen.c ============================================================================== --- stable/12/sys/dev/cxgbe/tom/t4_listen.c Tue Jun 4 19:59:43 2019 (r348669) +++ stable/12/sys/dev/cxgbe/tom/t4_listen.c Tue Jun 4 20:37:00 2019 (r348670) @@ -1400,7 +1400,6 @@ found: mtu_idx = find_best_mtu_idx(sc, &inc, &settings); rscale = cpl->tcpopt.wsf && V_tcp_do_rfc1323 ? select_rcv_wscale() : 0; - /* opt0 rcv_bufsiz initially, assumes its normal meaning later */ wnd = max(so->sol_sbrcv_hiwat, MIN_RCV_WND); wnd = min(wnd, MAX_RCV_WND); rx_credits = min(wnd >> 10, M_RCV_BUFSIZ); @@ -1552,8 +1551,7 @@ reset: toep->l2te = &sc->l2t->l2tab[synqe->l2e_idx]; toep->vnet = lctx->vnet; set_ulp_mode(toep, synqe->ulp_mode); - /* opt0 rcv_bufsiz initially, assumes its normal meaning later */ - toep->rx_credits = synqe->rcv_bufsize; + toep->opt0_rcv_bufsize = synqe->rcv_bufsize; MPASS(be32toh(cpl->snd_isn) - 1 == synqe->iss); MPASS(be32toh(cpl->rcv_isn) - 1 == synqe->irs); Modified: stable/12/sys/dev/cxgbe/tom/t4_tls.c ============================================================================== --- stable/12/sys/dev/cxgbe/tom/t4_tls.c Tue Jun 4 19:59:43 2019 (r348669) +++ stable/12/sys/dev/cxgbe/tom/t4_tls.c Tue Jun 4 20:37:00 2019 (r348670) @@ -1457,7 +1457,7 @@ do_rx_tls_cmp(struct sge_iq *iq, const struct rss_head struct socket *so; struct sockbuf *sb; struct mbuf *tls_data; - int len, pdu_length, pdu_overhead, sb_length; + int len, pdu_length, rx_credits; KASSERT(toep->tid == tid, ("%s: toep tid/atid mismatch", __func__)); KASSERT(!(toep->flags & TPF_SYNQE), @@ -1561,24 +1561,10 @@ do_rx_tls_cmp(struct sge_iq *iq, const struct rss_head } /* - * Not all of the bytes on the wire are included in the socket - * buffer (e.g. the MAC of the TLS record). However, those - * bytes are included in the TCP sequence space. To handle - * this, compute the delta for this TLS record in - * 'pdu_overhead' and treat those bytes as having already been - * "read" by the application for the purposes of expanding the - * window. The meat of the TLS record passed to the - * application ('sb_length') will still not be counted as - * "read" until userland actually reads the bytes. - * - * XXX: Some of the calculations below are probably still not - * really correct. + * Not all of the bytes on the wire are included in the socket buffer + * (e.g. the MAC of the TLS record). However, those bytes are included + * in the TCP sequence space. */ - sb_length = m->m_pkthdr.len; - pdu_overhead = pdu_length - sb_length; - toep->rx_credits += pdu_overhead; - tp->rcv_wnd += pdu_overhead; - tp->rcv_adv += pdu_overhead; /* receive buffer autosize */ MPASS(toep->vnet == so->so_vnet); @@ -1586,34 +1572,25 @@ do_rx_tls_cmp(struct sge_iq *iq, const struct rss_head if (sb->sb_flags & SB_AUTOSIZE && V_tcp_do_autorcvbuf && sb->sb_hiwat < V_tcp_autorcvbuf_max && - sb_length > (sbspace(sb) / 8 * 7)) { + m->m_pkthdr.len > (sbspace(sb) / 8 * 7)) { unsigned int hiwat = sb->sb_hiwat; unsigned int newsize = min(hiwat + V_tcp_autorcvbuf_inc, V_tcp_autorcvbuf_max); if (!sbreserve_locked(sb, newsize, so, NULL)) sb->sb_flags &= ~SB_AUTOSIZE; - else - toep->rx_credits += newsize - hiwat; } - KASSERT(toep->sb_cc >= sbused(sb), - ("%s: sb %p has more data (%d) than last time (%d).", - __func__, sb, sbused(sb), toep->sb_cc)); - toep->rx_credits += toep->sb_cc - sbused(sb); sbappendstream_locked(sb, m, 0); - toep->sb_cc = sbused(sb); + rx_credits = sbspace(sb) > tp->rcv_wnd ? sbspace(sb) - tp->rcv_wnd : 0; #ifdef VERBOSE_TRACES CTR5(KTR_CXGBE, "%s: tid %u PDU overhead %d rx_credits %u rcv_wnd %u", - __func__, tid, pdu_overhead, toep->rx_credits, tp->rcv_wnd); + __func__, tid, pdu_overhead, rx_credits, tp->rcv_wnd); #endif - if (toep->rx_credits > 0 && toep->sb_cc + tp->rcv_wnd < sb->sb_lowat) { - int credits; - - credits = send_rx_credits(sc, toep, toep->rx_credits); - toep->rx_credits -= credits; - tp->rcv_wnd += credits; - tp->rcv_adv += credits; + if (rx_credits > 0 && sbused(sb) + tp->rcv_wnd < sb->sb_lowat) { + rx_credits = send_rx_credits(sc, toep, rx_credits); + tp->rcv_wnd += rx_credits; + tp->rcv_adv += rx_credits; } sorwakeup_locked(so); Modified: stable/12/sys/dev/cxgbe/tom/t4_tom.h ============================================================================== --- stable/12/sys/dev/cxgbe/tom/t4_tom.h Tue Jun 4 19:59:43 2019 (r348669) +++ stable/12/sys/dev/cxgbe/tom/t4_tom.h Tue Jun 4 20:37:00 2019 (r348670) @@ -180,9 +180,7 @@ struct toepcb { u_int tx_nocompl; /* tx WR credits since last compl request */ u_int plen_nocompl; /* payload since last compl request */ - /* rx credit handling */ - u_int sb_cc; /* last noted value of so_rcv->sb_cc */ - int rx_credits; /* rx credits (in bytes) to be returned to hw */ + int opt0_rcv_bufsize; /* XXX: save full opt0/opt2 for later? */ u_int ulp_mode; /* ULP mode */ void *ulpcb; From owner-svn-src-stable-12@freebsd.org Tue Jun 4 21:06:36 2019 Return-Path: Delivered-To: svn-src-stable-12@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 D1C9515BD5A4; Tue, 4 Jun 2019 21:06:35 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 85CAB86273; Tue, 4 Jun 2019 21:06:35 +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 4694A23047; Tue, 4 Jun 2019 21:06:35 +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 x54L6ZPb015198; Tue, 4 Jun 2019 21:06:35 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x54L6YoD015195; Tue, 4 Jun 2019 21:06:34 GMT (envelope-from np@FreeBSD.org) Message-Id: <201906042106.x54L6YoD015195@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Tue, 4 Jun 2019 21:06:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348672 - in stable/12/sys/dev/cxgbe: common tom X-SVN-Group: stable-12 X-SVN-Commit-Author: np X-SVN-Commit-Paths: in stable/12/sys/dev/cxgbe: common tom X-SVN-Commit-Revision: 348672 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 85CAB86273 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 21:06:36 -0000 Author: np Date: Tue Jun 4 21:06:34 2019 New Revision: 348672 URL: https://svnweb.freebsd.org/changeset/base/348672 Log: MFC r346570, r348440 r346570: cxgbe/t4_tom: Add a "TCB history" feature that samples hardware state for a tid and maintains a running history of some interesting events. Service TCP_INFO queries from the history when the tid is being tracked there. r348440: cxgbe/t4_tom: Do not attempt to look up entries in the TCB history if it hasn't been initialized. This fixes a bug in r346570 that could cause a panic when servicing TCP_INFO for offloaded connections. Sponsored by: Chelsio Communications Modified: stable/12/sys/dev/cxgbe/common/t4_msg.h stable/12/sys/dev/cxgbe/tom/t4_tom.c stable/12/sys/dev/cxgbe/tom/t4_tom.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/cxgbe/common/t4_msg.h ============================================================================== --- stable/12/sys/dev/cxgbe/common/t4_msg.h Tue Jun 4 20:53:35 2019 (r348671) +++ stable/12/sys/dev/cxgbe/common/t4_msg.h Tue Jun 4 21:06:34 2019 (r348672) @@ -923,7 +923,8 @@ struct cpl_get_tcb { WR_HDR; union opcode_tid ot; __be16 reply_ctrl; - __be16 cookie; + __u8 rsvd; + __u8 cookie; }; /* cpl_get_tcb.reply_ctrl fields */ Modified: stable/12/sys/dev/cxgbe/tom/t4_tom.c ============================================================================== --- stable/12/sys/dev/cxgbe/tom/t4_tom.c Tue Jun 4 20:53:35 2019 (r348671) +++ stable/12/sys/dev/cxgbe/tom/t4_tom.c Tue Jun 4 21:06:34 2019 (r348672) @@ -386,55 +386,355 @@ t4_ctloutput(struct toedev *tod, struct tcpcb *tp, int } } -static inline int -get_tcb_bit(u_char *tcb, int bit) +static inline uint64_t +get_tcb_tflags(const uint64_t *tcb) { - int ix, shift; - ix = 127 - (bit >> 3); - shift = bit & 0x7; - - return ((tcb[ix] >> shift) & 1); + return ((be64toh(tcb[14]) << 32) | (be64toh(tcb[15]) >> 32)); } -static inline uint64_t -get_tcb_bits(u_char *tcb, int hi, int lo) +static inline uint32_t +get_tcb_field(const uint64_t *tcb, u_int word, uint32_t mask, u_int shift) { - uint64_t rc = 0; +#define LAST_WORD ((TCB_SIZE / 4) - 1) + uint64_t t1, t2; + int flit_idx; - while (hi >= lo) { - rc = (rc << 1) | get_tcb_bit(tcb, hi); - --hi; + MPASS(mask != 0); + MPASS(word <= LAST_WORD); + MPASS(shift < 32); + + flit_idx = (LAST_WORD - word) / 2; + if (word & 0x1) + shift += 32; + t1 = be64toh(tcb[flit_idx]) >> shift; + t2 = 0; + if (fls(mask) > 64 - shift) { + /* + * Will spill over into the next logical flit, which is the flit + * before this one. The flit_idx before this one must be valid. + */ + MPASS(flit_idx > 0); + t2 = be64toh(tcb[flit_idx - 1]) << (64 - shift); } + return ((t2 | t1) & mask); +#undef LAST_WORD +} +#define GET_TCB_FIELD(tcb, F) \ + get_tcb_field(tcb, W_TCB_##F, M_TCB_##F, S_TCB_##F) +/* + * Issues a CPL_GET_TCB to read the entire TCB for the tid. + */ +static int +send_get_tcb(struct adapter *sc, u_int tid) +{ + struct cpl_get_tcb *cpl; + struct wrq_cookie cookie; + + MPASS(tid < sc->tids.ntids); + + cpl = start_wrq_wr(&sc->sge.ctrlq[0], howmany(sizeof(*cpl), 16), + &cookie); + if (__predict_false(cpl == NULL)) + return (ENOMEM); + bzero(cpl, sizeof(*cpl)); + INIT_TP_WR(cpl, tid); + OPCODE_TID(cpl) = htobe32(MK_OPCODE_TID(CPL_GET_TCB, tid)); + cpl->reply_ctrl = htobe16(V_REPLY_CHAN(0) | + V_QUEUENO(sc->sge.ofld_rxq[0].iq.cntxt_id)); + cpl->cookie = 0xff; + commit_wrq_wr(&sc->sge.ctrlq[0], cpl, &cookie); + + return (0); +} + +static struct tcb_histent * +alloc_tcb_histent(struct adapter *sc, u_int tid, int flags) +{ + struct tcb_histent *te; + + MPASS(flags == M_NOWAIT || flags == M_WAITOK); + + te = malloc(sizeof(*te), M_CXGBE, M_ZERO | flags); + if (te == NULL) + return (NULL); + mtx_init(&te->te_lock, "TCB entry", NULL, MTX_DEF); + callout_init_mtx(&te->te_callout, &te->te_lock, 0); + te->te_adapter = sc; + te->te_tid = tid; + + return (te); +} + +static void +free_tcb_histent(struct tcb_histent *te) +{ + + mtx_destroy(&te->te_lock); + free(te, M_CXGBE); +} + +/* + * Start tracking the tid in the TCB history. + */ +int +add_tid_to_history(struct adapter *sc, u_int tid) +{ + struct tcb_histent *te = NULL; + struct tom_data *td = sc->tom_softc; + int rc; + + MPASS(tid < sc->tids.ntids); + + if (td->tcb_history == NULL) + return (ENXIO); + + rw_wlock(&td->tcb_history_lock); + if (td->tcb_history[tid] != NULL) { + rc = EEXIST; + goto done; + } + te = alloc_tcb_histent(sc, tid, M_NOWAIT); + if (te == NULL) { + rc = ENOMEM; + goto done; + } + mtx_lock(&te->te_lock); + rc = send_get_tcb(sc, tid); + if (rc == 0) { + te->te_flags |= TE_RPL_PENDING; + td->tcb_history[tid] = te; + } else { + free(te, M_CXGBE); + } + mtx_unlock(&te->te_lock); +done: + rw_wunlock(&td->tcb_history_lock); return (rc); } +static void +remove_tcb_histent(struct tcb_histent *te) +{ + struct adapter *sc = te->te_adapter; + struct tom_data *td = sc->tom_softc; + + rw_assert(&td->tcb_history_lock, RA_WLOCKED); + mtx_assert(&te->te_lock, MA_OWNED); + MPASS(td->tcb_history[te->te_tid] == te); + + td->tcb_history[te->te_tid] = NULL; + free_tcb_histent(te); + rw_wunlock(&td->tcb_history_lock); +} + +static inline struct tcb_histent * +lookup_tcb_histent(struct adapter *sc, u_int tid, bool addrem) +{ + struct tcb_histent *te; + struct tom_data *td = sc->tom_softc; + + MPASS(tid < sc->tids.ntids); + + if (td->tcb_history == NULL) + return (NULL); + + if (addrem) + rw_wlock(&td->tcb_history_lock); + else + rw_rlock(&td->tcb_history_lock); + te = td->tcb_history[tid]; + if (te != NULL) { + mtx_lock(&te->te_lock); + return (te); /* with both locks held */ + } + if (addrem) + rw_wunlock(&td->tcb_history_lock); + else + rw_runlock(&td->tcb_history_lock); + + return (te); +} + +static inline void +release_tcb_histent(struct tcb_histent *te) +{ + struct adapter *sc = te->te_adapter; + struct tom_data *td = sc->tom_softc; + + mtx_assert(&te->te_lock, MA_OWNED); + mtx_unlock(&te->te_lock); + rw_assert(&td->tcb_history_lock, RA_RLOCKED); + rw_runlock(&td->tcb_history_lock); +} + +static void +request_tcb(void *arg) +{ + struct tcb_histent *te = arg; + + mtx_assert(&te->te_lock, MA_OWNED); + + /* Noone else is supposed to update the histent. */ + MPASS(!(te->te_flags & TE_RPL_PENDING)); + if (send_get_tcb(te->te_adapter, te->te_tid) == 0) + te->te_flags |= TE_RPL_PENDING; + else + callout_schedule(&te->te_callout, hz / 100); +} + +static void +update_tcb_histent(struct tcb_histent *te, const uint64_t *tcb) +{ + struct tom_data *td = te->te_adapter->tom_softc; + uint64_t tflags = get_tcb_tflags(tcb); + uint8_t sample = 0; + + if (GET_TCB_FIELD(tcb, SND_MAX_RAW) != GET_TCB_FIELD(tcb, SND_UNA_RAW)) { + if (GET_TCB_FIELD(tcb, T_RXTSHIFT) != 0) + sample |= TS_RTO; + if (GET_TCB_FIELD(tcb, T_DUPACKS) != 0) + sample |= TS_DUPACKS; + if (GET_TCB_FIELD(tcb, T_DUPACKS) >= td->dupack_threshold) + sample |= TS_FASTREXMT; + } + + if (GET_TCB_FIELD(tcb, SND_MAX_RAW) != 0) { + uint32_t snd_wnd; + + sample |= TS_SND_BACKLOGGED; /* for whatever reason. */ + + snd_wnd = GET_TCB_FIELD(tcb, RCV_ADV); + if (tflags & V_TF_RECV_SCALE(1)) + snd_wnd <<= GET_TCB_FIELD(tcb, RCV_SCALE); + if (GET_TCB_FIELD(tcb, SND_CWND) < snd_wnd) + sample |= TS_CWND_LIMITED; /* maybe due to CWND */ + } + + if (tflags & V_TF_CCTRL_ECN(1)) { + + /* + * CE marker on incoming IP hdr, echoing ECE back in the TCP + * hdr. Indicates congestion somewhere on the way from the peer + * to this node. + */ + if (tflags & V_TF_CCTRL_ECE(1)) + sample |= TS_ECN_ECE; + + /* + * ECE seen and CWR sent (or about to be sent). Might indicate + * congestion on the way to the peer. This node is reducing its + * congestion window in response. + */ + if (tflags & (V_TF_CCTRL_CWR(1) | V_TF_CCTRL_RFR(1))) + sample |= TS_ECN_CWR; + } + + te->te_sample[te->te_pidx] = sample; + if (++te->te_pidx == nitems(te->te_sample)) + te->te_pidx = 0; + memcpy(te->te_tcb, tcb, TCB_SIZE); + te->te_flags |= TE_ACTIVE; +} + +static int +do_get_tcb_rpl(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) +{ + struct adapter *sc = iq->adapter; + const struct cpl_get_tcb_rpl *cpl = mtod(m, const void *); + const uint64_t *tcb = (const uint64_t *)(const void *)(cpl + 1); + struct tcb_histent *te; + const u_int tid = GET_TID(cpl); + bool remove; + + remove = GET_TCB_FIELD(tcb, T_STATE) == TCPS_CLOSED; + te = lookup_tcb_histent(sc, tid, remove); + if (te == NULL) { + /* Not in the history. Who issued the GET_TCB for this? */ + device_printf(sc->dev, "tcb %u: flags 0x%016jx, state %u, " + "srtt %u, sscale %u, rscale %u, cookie 0x%x\n", tid, + (uintmax_t)get_tcb_tflags(tcb), GET_TCB_FIELD(tcb, T_STATE), + GET_TCB_FIELD(tcb, T_SRTT), GET_TCB_FIELD(tcb, SND_SCALE), + GET_TCB_FIELD(tcb, RCV_SCALE), cpl->cookie); + goto done; + } + + MPASS(te->te_flags & TE_RPL_PENDING); + te->te_flags &= ~TE_RPL_PENDING; + if (remove) { + remove_tcb_histent(te); + } else { + update_tcb_histent(te, tcb); + callout_reset(&te->te_callout, hz / 10, request_tcb, te); + release_tcb_histent(te); + } +done: + m_freem(m); + return (0); +} + +static void +fill_tcp_info_from_tcb(struct adapter *sc, uint64_t *tcb, struct tcp_info *ti) +{ + uint32_t v; + + ti->tcpi_state = GET_TCB_FIELD(tcb, T_STATE); + + v = GET_TCB_FIELD(tcb, T_SRTT); + ti->tcpi_rtt = tcp_ticks_to_us(sc, v); + + v = GET_TCB_FIELD(tcb, T_RTTVAR); + ti->tcpi_rttvar = tcp_ticks_to_us(sc, v); + + ti->tcpi_snd_ssthresh = GET_TCB_FIELD(tcb, SND_SSTHRESH); + ti->tcpi_snd_cwnd = GET_TCB_FIELD(tcb, SND_CWND); + ti->tcpi_rcv_nxt = GET_TCB_FIELD(tcb, RCV_NXT); + + v = GET_TCB_FIELD(tcb, TX_MAX); + ti->tcpi_snd_nxt = v - GET_TCB_FIELD(tcb, SND_NXT_RAW); + + /* Receive window being advertised by us. */ + ti->tcpi_rcv_wscale = GET_TCB_FIELD(tcb, SND_SCALE); /* Yes, SND. */ + ti->tcpi_rcv_space = GET_TCB_FIELD(tcb, RCV_WND); + + /* Send window */ + ti->tcpi_snd_wscale = GET_TCB_FIELD(tcb, RCV_SCALE); /* Yes, RCV. */ + ti->tcpi_snd_wnd = GET_TCB_FIELD(tcb, RCV_ADV); + if (get_tcb_tflags(tcb) & V_TF_RECV_SCALE(1)) + ti->tcpi_snd_wnd <<= ti->tcpi_snd_wscale; + else + ti->tcpi_snd_wscale = 0; + +} + +static void +fill_tcp_info_from_history(struct adapter *sc, struct tcb_histent *te, + struct tcp_info *ti) +{ + + fill_tcp_info_from_tcb(sc, te->te_tcb, ti); +} + /* - * Called by the kernel to allow the TOE driver to "refine" values filled up in - * the tcp_info for an offloaded connection. + * Reads the TCB for the given tid using a memory window and copies it to 'buf' + * in the same format as CPL_GET_TCB_RPL. */ static void -t4_tcp_info(struct toedev *tod, struct tcpcb *tp, struct tcp_info *ti) +read_tcb_using_memwin(struct adapter *sc, u_int tid, uint64_t *buf) { int i, j, k, rc; - struct adapter *sc = tod->tod_softc; - struct toepcb *toep = tp->t_toe; - uint32_t addr, v; - uint32_t buf[TCB_SIZE / sizeof(uint32_t)]; + uint32_t addr; u_char *tcb, tmp; - INP_WLOCK_ASSERT(tp->t_inpcb); - MPASS(ti != NULL); + MPASS(tid < sc->tids.ntids); - ti->tcpi_toe_tid = toep->tid; - - addr = t4_read_reg(sc, A_TP_CMM_TCB_BASE) + toep->tid * TCB_SIZE; - rc = read_via_memwin(sc, 2, addr, &buf[0], TCB_SIZE); + addr = t4_read_reg(sc, A_TP_CMM_TCB_BASE) + tid * TCB_SIZE; + rc = read_via_memwin(sc, 2, addr, (uint32_t *)buf, TCB_SIZE); if (rc != 0) return; - tcb = (u_char *)&buf[0]; + tcb = (u_char *)buf; for (i = 0, j = TCB_SIZE - 16; i < j; i += 16, j -= 16) { for (k = 0; k < 16; k++) { tmp = tcb[i + k]; @@ -442,28 +742,42 @@ t4_tcp_info(struct toedev *tod, struct tcpcb *tp, stru tcb[j + k] = tmp; } } +} - ti->tcpi_state = get_tcb_bits(tcb, 115, 112); +static void +fill_tcp_info(struct adapter *sc, u_int tid, struct tcp_info *ti) +{ + uint64_t tcb[TCB_SIZE / sizeof(uint64_t)]; + struct tcb_histent *te; - v = get_tcb_bits(tcb, 271, 256); - ti->tcpi_rtt = tcp_ticks_to_us(sc, v); + ti->tcpi_toe_tid = tid; + te = lookup_tcb_histent(sc, tid, false); + if (te != NULL) { + fill_tcp_info_from_history(sc, te, ti); + release_tcb_histent(te); + } else { + if (!(sc->debug_flags & DF_DISABLE_TCB_CACHE)) { + /* XXX: tell firmware to flush TCB cache. */ + } + read_tcb_using_memwin(sc, tid, tcb); + fill_tcp_info_from_tcb(sc, tcb, ti); + } +} - v = get_tcb_bits(tcb, 287, 272); - ti->tcpi_rttvar = tcp_ticks_to_us(sc, v); +/* + * Called by the kernel to allow the TOE driver to "refine" values filled up in + * the tcp_info for an offloaded connection. + */ +static void +t4_tcp_info(struct toedev *tod, struct tcpcb *tp, struct tcp_info *ti) +{ + struct adapter *sc = tod->tod_softc; + struct toepcb *toep = tp->t_toe; - ti->tcpi_snd_ssthresh = get_tcb_bits(tcb, 487, 460); - ti->tcpi_snd_cwnd = get_tcb_bits(tcb, 459, 432); - ti->tcpi_rcv_nxt = get_tcb_bits(tcb, 553, 522); + INP_WLOCK_ASSERT(tp->t_inpcb); + MPASS(ti != NULL); - ti->tcpi_snd_nxt = get_tcb_bits(tcb, 319, 288) - - get_tcb_bits(tcb, 375, 348); - - /* Receive window being advertised by us. */ - ti->tcpi_rcv_space = get_tcb_bits(tcb, 581, 554); - - /* Send window ceiling. */ - v = get_tcb_bits(tcb, 159, 144) << get_tcb_bits(tcb, 131, 128); - ti->tcpi_snd_wnd = min(v, ti->tcpi_snd_cwnd); + fill_tcp_info(sc, toep->tid, ti); } /* @@ -807,6 +1121,35 @@ failed: return (rc); } +static inline void +alloc_tcb_history(struct adapter *sc, struct tom_data *td) +{ + + if (sc->tids.ntids == 0 || sc->tids.ntids > 1024) + return; + rw_init(&td->tcb_history_lock, "TCB history"); + td->tcb_history = malloc(sc->tids.ntids * sizeof(*td->tcb_history), + M_CXGBE, M_ZERO | M_NOWAIT); + td->dupack_threshold = G_DUPACKTHRESH(t4_read_reg(sc, A_TP_PARA_REG0)); +} + +static inline void +free_tcb_history(struct adapter *sc, struct tom_data *td) +{ +#ifdef INVARIANTS + int i; + + if (td->tcb_history != NULL) { + for (i = 0; i < sc->tids.ntids; i++) { + MPASS(td->tcb_history[i] == NULL); + } + } +#endif + free(td->tcb_history, M_CXGBE); + if (rw_initialized(&td->tcb_history_lock)) + rw_destroy(&td->tcb_history_lock); +} + static void free_tom_data(struct adapter *sc, struct tom_data *td) { @@ -830,6 +1173,7 @@ free_tom_data(struct adapter *sc, struct tom_data *td) if (mtx_initialized(&td->toep_list_lock)) mtx_destroy(&td->toep_list_lock); + free_tcb_history(sc, td); free_tid_tabs(&sc->tids); free(td, M_CXGBE); } @@ -1097,6 +1441,8 @@ t4_tom_activate(struct adapter *sc) t4_set_reg_field(sc, A_ULP_RX_TDDP_TAGMASK, V_TDDPTAGMASK(M_TDDPTAGMASK), td->pr.pr_tag_mask); + alloc_tcb_history(sc, td); + /* toedev ops */ tod = &td->tod; init_toedev(tod); @@ -1214,6 +1560,7 @@ t4_tom_mod_load(void) struct protosw *tcp_protosw, *tcp6_protosw; /* CPL handlers */ + t4_register_cpl_handler(CPL_GET_TCB_RPL, do_get_tcb_rpl); t4_register_shared_cpl_handler(CPL_L2T_WRITE_RPL, do_l2t_write_rpl2, CPL_COOKIE_TOM); t4_init_connect_cpl_handlers(); Modified: stable/12/sys/dev/cxgbe/tom/t4_tom.h ============================================================================== --- stable/12/sys/dev/cxgbe/tom/t4_tom.h Tue Jun 4 20:53:35 2019 (r348671) +++ stable/12/sys/dev/cxgbe/tom/t4_tom.h Tue Jun 4 21:06:34 2019 (r348672) @@ -33,6 +33,7 @@ #ifndef __T4_TOM_H__ #define __T4_TOM_H__ #include +#include "common/t4_hw.h" #include "tom/t4_tls.h" #define LISTEN_HASH_SIZE 32 @@ -252,6 +253,31 @@ struct listen_ctx { struct clip_entry *ce; }; +/* tcb_histent flags */ +#define TE_RPL_PENDING 1 +#define TE_ACTIVE 2 + +/* bits in one 8b tcb_histent sample. */ +#define TS_RTO (1 << 0) +#define TS_DUPACKS (1 << 1) +#define TS_FASTREXMT (1 << 2) +#define TS_SND_BACKLOGGED (1 << 3) +#define TS_CWND_LIMITED (1 << 4) +#define TS_ECN_ECE (1 << 5) +#define TS_ECN_CWR (1 << 6) +#define TS_RESERVED (1 << 7) /* Unused. */ + +struct tcb_histent { + struct mtx te_lock; + struct callout te_callout; + uint64_t te_tcb[TCB_SIZE / sizeof(uint64_t)]; + struct adapter *te_adapter; + u_int te_flags; + u_int te_tid; + uint8_t te_pidx; + uint8_t te_sample[100]; +}; + struct tom_data { struct toedev tod; @@ -266,6 +292,10 @@ struct tom_data { struct ppod_region pr; + struct rwlock tcb_history_lock __aligned(CACHE_LINE_SIZE); + struct tcb_histent **tcb_history; + int dupack_threshold; + /* WRs that will not be sent to the chip because L2 resolution failed */ struct mtx unsent_wr_lock; STAILQ_HEAD(, wrqe) unsent_wr_list; @@ -324,6 +354,7 @@ int select_ulp_mode(struct socket *, struct adapter *, struct offload_settings *); void set_ulp_mode(struct toepcb *, int); int negative_advice(int); +int add_tid_to_history(struct adapter *, u_int); /* t4_connect.c */ void t4_init_connect_cpl_handlers(void); From owner-svn-src-stable-12@freebsd.org Wed Jun 5 00:51:52 2019 Return-Path: Delivered-To: svn-src-stable-12@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 3B5B315C12E4; Wed, 5 Jun 2019 00:51:52 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D49F68C32F; Wed, 5 Jun 2019 00:51:51 +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 B09C7256CD; Wed, 5 Jun 2019 00:51:51 +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 x550pppP033999; Wed, 5 Jun 2019 00:51:51 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x550pp8A033998; Wed, 5 Jun 2019 00:51:51 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201906050051.x550pp8A033998@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 5 Jun 2019 00:51:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348676 - stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 348676 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D49F68C32F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.967,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 00:51:52 -0000 Author: mav Date: Wed Jun 5 00:51:51 2019 New Revision: 348676 URL: https://svnweb.freebsd.org/changeset/base/348676 Log: MFC r348117: Allocate buffers smaller then ABD chunk size as linear. This allows to reduce memory waste by letting UMA to put multiple small buffers into one memory page slab. The page sharing means that UMA may not be able to free memory page when some of buffers are freed, but alternatively memory used by that buffer would just be wasted from the beginning. This change follows alike change in ZoL, but unlike Linux (according to my understanding of it from comments) FreeBSD never shares slabs bigger then one memory page, so this should be even less invasive then there. Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/abd.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/abd.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/abd.c Wed Jun 5 00:08:30 2019 (r348675) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/abd.c Wed Jun 5 00:51:51 2019 (r348676) @@ -290,7 +290,7 @@ abd_free_struct(abd_t *abd) abd_t * abd_alloc(size_t size, boolean_t is_metadata) { - if (!zfs_abd_scatter_enabled) + if (!zfs_abd_scatter_enabled || size <= zfs_abd_chunk_size) return (abd_alloc_linear(size, is_metadata)); VERIFY3U(size, <=, SPA_MAXBLOCKSIZE); From owner-svn-src-stable-12@freebsd.org Wed Jun 5 12:34:31 2019 Return-Path: Delivered-To: svn-src-stable-12@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 C8BB015AC896; Wed, 5 Jun 2019 12:34:31 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 68428812C5; Wed, 5 Jun 2019 12:34:31 +0000 (UTC) (envelope-from luporl@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 3D9EC51B2; Wed, 5 Jun 2019 12:34:31 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x55CYU92098347; Wed, 5 Jun 2019 12:34:30 GMT (envelope-from luporl@FreeBSD.org) Received: (from luporl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x55CYTcC098338; Wed, 5 Jun 2019 12:34:29 GMT (envelope-from luporl@FreeBSD.org) Message-Id: <201906051234.x55CYTcC098338@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luporl set sender to luporl@FreeBSD.org using -f From: Leandro Lupori Date: Wed, 5 Jun 2019 12:34:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348683 - in stable/12: cddl/contrib/opensolaris/lib/libzfs/common stand/common stand/ofw/libofw stand/powerpc/boot1.chrp stand/powerpc/kboot stand/powerpc/ofw X-SVN-Group: stable-12 X-SVN-Commit-Author: luporl X-SVN-Commit-Paths: in stable/12: cddl/contrib/opensolaris/lib/libzfs/common stand/common stand/ofw/libofw stand/powerpc/boot1.chrp stand/powerpc/kboot stand/powerpc/ofw X-SVN-Commit-Revision: 348683 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 68428812C5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.968,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 12:34:32 -0000 Author: luporl Date: Wed Jun 5 12:34:28 2019 New Revision: 348683 URL: https://svnweb.freebsd.org/changeset/base/348683 Log: MFC r348005: [PowerPC64] stand: fix build using clang 8 as compiler This change fixes "stand" build issues when using clang 8 as compiler. Submitted by: alfredo.junior_eldorado.org.br Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D20026 Modified: stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c stable/12/stand/common/load_elf.c stable/12/stand/ofw/libofw/ofw_net.c stable/12/stand/ofw/libofw/openfirm.c stable/12/stand/powerpc/boot1.chrp/boot1.c stable/12/stand/powerpc/kboot/Makefile stable/12/stand/powerpc/kboot/main.c stable/12/stand/powerpc/ofw/elf_freebsd.c stable/12/stand/powerpc/ofw/ppc64_elf_freebsd.c Directory Properties: stable/12/ (props changed) Modified: stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c ============================================================================== --- stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Wed Jun 5 09:25:40 2019 (r348682) +++ stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Wed Jun 5 12:34:28 2019 (r348683) @@ -114,7 +114,7 @@ get_stats_for_obj(differ_info_t *di, const char *dsnam (void) snprintf(di->errbuf, sizeof (di->errbuf), dgettext(TEXT_DOMAIN, "Unable to determine path or stats for " - "object %lld in %s"), obj, dsname); + "object %jd in %s"), (uintmax_t)obj, dsname); return (-1); } } @@ -406,8 +406,8 @@ write_free_diffs(FILE *fp, differ_info_t *di, dmu_diff } else { (void) snprintf(di->errbuf, sizeof (di->errbuf), dgettext(TEXT_DOMAIN, - "next allocated object (> %lld) find failure"), - zc.zc_obj); + "next allocated object (> %jd) find failure"), + (uintmax_t)zc.zc_obj); di->zerr = errno; break; } Modified: stable/12/stand/common/load_elf.c ============================================================================== --- stable/12/stand/common/load_elf.c Wed Jun 5 09:25:40 2019 (r348682) +++ stable/12/stand/common/load_elf.c Wed Jun 5 12:34:28 2019 (r348683) @@ -483,7 +483,7 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_ off += 0x01000000; ehdr->e_entry += off; #ifdef ELF_VERBOSE - printf("Converted entry 0x%08x\n", ehdr->e_entry); + printf("Converted entry 0x%jx\n", (uintmax_t)ehdr->e_entry); #endif } else off = 0; @@ -509,8 +509,8 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_ off -= ehdr->e_entry & ~PAGE_MASK; ehdr->e_entry += off; #ifdef ELF_VERBOSE - printf("ehdr->e_entry 0x%08x, va<->pa off %llx\n", - ehdr->e_entry, off); + printf("ehdr->e_entry 0x%jx", va<->pa off %llx\n", + (uintmax_t)ehdr->e_entry, off); #endif #else off = 0; /* other archs use direct mapped kernels */ Modified: stable/12/stand/ofw/libofw/ofw_net.c ============================================================================== --- stable/12/stand/ofw/libofw/ofw_net.c Wed Jun 5 09:25:40 2019 (r348682) +++ stable/12/stand/ofw/libofw/ofw_net.c Wed Jun 5 12:34:28 2019 (r348683) @@ -225,12 +225,12 @@ ofwn_init(struct iodesc *desc, void *machdep_hint) dmabuf = NULL; if (OF_call_method("dma-alloc", netinstance, 1, 1, (64 * 1024), &dmabuf) < 0) { - printf("Failed to allocate DMA buffer (got %08x).\n", dmabuf); + printf("Failed to allocate DMA buffer (got %p).\n", dmabuf); goto punt; } #if defined(NETIF_DEBUG) - printf("ofwn_init: allocated DMA buffer: %08x\n", dmabuf); + printf("ofwn_init: allocated DMA buffer: %p\n", dmabuf); #endif #endif Modified: stable/12/stand/ofw/libofw/openfirm.c ============================================================================== --- stable/12/stand/ofw/libofw/openfirm.c Wed Jun 5 09:25:40 2019 (r348682) +++ stable/12/stand/ofw/libofw/openfirm.c Wed Jun 5 12:34:28 2019 (r348683) @@ -669,7 +669,6 @@ OF_block_size(ihandle_t instance) } /* -/* * Memory functions */ Modified: stable/12/stand/powerpc/boot1.chrp/boot1.c ============================================================================== --- stable/12/stand/powerpc/boot1.chrp/boot1.c Wed Jun 5 09:25:40 2019 (r348682) +++ stable/12/stand/powerpc/boot1.chrp/boot1.c Wed Jun 5 12:34:28 2019 (r348683) @@ -23,6 +23,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "paths.h" Modified: stable/12/stand/powerpc/kboot/Makefile ============================================================================== --- stable/12/stand/powerpc/kboot/Makefile Wed Jun 5 09:25:40 2019 (r348682) +++ stable/12/stand/powerpc/kboot/Makefile Wed Jun 5 12:34:28 2019 (r348683) @@ -36,9 +36,6 @@ CFLAGS+= -DRELOC=${RELOC} LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.powerpc -# 64-bit bridge extensions -CFLAGS+= -Wa,-mppc64bridge - DPADD= ${LDR_INTERP} ${LIBOFW} ${LIBFDT} ${LIBSA} LDADD= ${LDR_INTERP} ${LIBOFW} ${LIBFDT} ${LIBSA} Modified: stable/12/stand/powerpc/kboot/main.c ============================================================================== --- stable/12/stand/powerpc/kboot/main.c Wed Jun 5 09:25:40 2019 (r348682) +++ stable/12/stand/powerpc/kboot/main.c Wed Jun 5 12:34:28 2019 (r348683) @@ -484,8 +484,18 @@ kboot_kseg_get(int *nseg, void **ptr) void _start(int argc, const char **argv, char **env) { +// This makes error "variable 'sp' is uninitialized" be just a warning on clang. +// Initializing 'sp' is not desired here as it would overwrite "r1" original value +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic warning "-Wuninitialized" +#endif register volatile void **sp asm("r1"); main((int)sp[0], (const char **)&sp[1]); +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + } /* Modified: stable/12/stand/powerpc/ofw/elf_freebsd.c ============================================================================== --- stable/12/stand/powerpc/ofw/elf_freebsd.c Wed Jun 5 09:25:40 2019 (r348682) +++ stable/12/stand/powerpc/ofw/elf_freebsd.c Wed Jun 5 12:34:28 2019 (r348683) @@ -84,7 +84,7 @@ __elfN(ofw_exec)(struct preloaded_file *fp) if ((error = md_load(fp->f_args, &mdp, &dtbp)) != 0) return (error); - printf("Kernel entry at 0x%lx ...\n", e->e_entry); + printf("Kernel entry at 0x%x ...\n", entry); dev_cleanup(); if (dtbp != 0) { Modified: stable/12/stand/powerpc/ofw/ppc64_elf_freebsd.c ============================================================================== --- stable/12/stand/powerpc/ofw/ppc64_elf_freebsd.c Wed Jun 5 09:25:40 2019 (r348682) +++ stable/12/stand/powerpc/ofw/ppc64_elf_freebsd.c Wed Jun 5 12:34:28 2019 (r348683) @@ -87,7 +87,7 @@ ppc64_ofw_elf_exec(struct preloaded_file *fp) if ((error = md_load64(fp->f_args, &mdp, &dtbp)) != 0) return (error); - printf("Kernel entry at 0x%lx ...\n", entry); + printf("Kernel entry at 0x%x ...\n", entry); dev_cleanup(); From owner-svn-src-stable-12@freebsd.org Wed Jun 5 12:38:59 2019 Return-Path: Delivered-To: svn-src-stable-12@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 A3DC915AC9B4; Wed, 5 Jun 2019 12:38:59 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 483098143F; Wed, 5 Jun 2019 12:38:59 +0000 (UTC) (envelope-from luporl@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 1D27151B5; Wed, 5 Jun 2019 12:38:59 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x55CcwGE098575; Wed, 5 Jun 2019 12:38:58 GMT (envelope-from luporl@FreeBSD.org) Received: (from luporl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x55Ccwkg098574; Wed, 5 Jun 2019 12:38:58 GMT (envelope-from luporl@FreeBSD.org) Message-Id: <201906051238.x55Ccwkg098574@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luporl set sender to luporl@FreeBSD.org using -f From: Leandro Lupori Date: Wed, 5 Jun 2019 12:38:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348684 - stable/12/stand/common X-SVN-Group: stable-12 X-SVN-Commit-Author: luporl X-SVN-Commit-Paths: stable/12/stand/common X-SVN-Commit-Revision: 348684 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 483098143F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 12:38:59 -0000 Author: luporl Date: Wed Jun 5 12:38:58 2019 New Revision: 348684 URL: https://svnweb.freebsd.org/changeset/base/348684 Log: MFC r348025: Unbreak the build when `ELF_VERBOSE` is defined after r348005 This change properly terminates the formatting string quote modification done in r348005, which is triggered when `ELF_VERBOSE` is defined. Reported by: ci (amd64, gcc) Modified: stable/12/stand/common/load_elf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/common/load_elf.c ============================================================================== --- stable/12/stand/common/load_elf.c Wed Jun 5 12:34:28 2019 (r348683) +++ stable/12/stand/common/load_elf.c Wed Jun 5 12:38:58 2019 (r348684) @@ -509,7 +509,7 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_ off -= ehdr->e_entry & ~PAGE_MASK; ehdr->e_entry += off; #ifdef ELF_VERBOSE - printf("ehdr->e_entry 0x%jx", va<->pa off %llx\n", + printf("ehdr->e_entry 0x%jx, va<->pa off %llx\n", (uintmax_t)ehdr->e_entry, off); #endif #else From owner-svn-src-stable-12@freebsd.org Wed Jun 5 12:43:47 2019 Return-Path: Delivered-To: svn-src-stable-12@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 5BFF515ACC57; Wed, 5 Jun 2019 12:43:47 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F12818186A; Wed, 5 Jun 2019 12:43:46 +0000 (UTC) (envelope-from luporl@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 DF5A7536F; Wed, 5 Jun 2019 12:43:46 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x55Chkck003462; Wed, 5 Jun 2019 12:43:46 GMT (envelope-from luporl@FreeBSD.org) Received: (from luporl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x55Chknp003460; Wed, 5 Jun 2019 12:43:46 GMT (envelope-from luporl@FreeBSD.org) Message-Id: <201906051243.x55Chknp003460@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luporl set sender to luporl@FreeBSD.org using -f From: Leandro Lupori Date: Wed, 5 Jun 2019 12:43:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348685 - in stable/12/sys: conf powerpc/aim powerpc/powerpc X-SVN-Group: stable-12 X-SVN-Commit-Author: luporl X-SVN-Commit-Paths: in stable/12/sys: conf powerpc/aim powerpc/powerpc X-SVN-Commit-Revision: 348685 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: F12818186A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.968,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 12:43:47 -0000 Author: luporl Date: Wed Jun 5 12:43:45 2019 New Revision: 348685 URL: https://svnweb.freebsd.org/changeset/base/348685 Log: MFC r348112: Fix PPC64 kernel build with clang8 + lld8 This patch fixes the following lld link errors: - unsupported dynamic relocations on read-only sections - out-of-range TOC references Submitted by: git_bdragon.rtk0.net Reviewed by: jhibbits, luporl Differential Revision: https://reviews.freebsd.org/D19352 Modified: stable/12/sys/conf/ldscript.powerpc64 stable/12/sys/powerpc/aim/trap_subr64.S stable/12/sys/powerpc/powerpc/cpu_subr64.S Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/conf/ldscript.powerpc64 ============================================================================== --- stable/12/sys/conf/ldscript.powerpc64 Wed Jun 5 12:38:58 2019 (r348684) +++ stable/12/sys/conf/ldscript.powerpc64 Wed Jun 5 12:43:45 2019 (r348685) @@ -93,7 +93,8 @@ SECTIONS .opd : ALIGN(8) { KEEP (*(.opd)) } .branch_lt : ALIGN(8) { *(.branch_lt) } . = ALIGN(4096); - .got : ALIGN(8) { __tocbase = .; *(.got .toc) } + .got : ALIGN(8) { __tocbase = .; *(.got) } + .toc : ALIGN(8) { *(.toc) } .dynamic : { *(.dynamic) } /* Put .ctors and .dtors next to the .got2 section, so that the pointers Modified: stable/12/sys/powerpc/aim/trap_subr64.S ============================================================================== --- stable/12/sys/powerpc/aim/trap_subr64.S Wed Jun 5 12:38:58 2019 (r348684) +++ stable/12/sys/powerpc/aim/trap_subr64.S Wed Jun 5 12:43:45 2019 (r348685) @@ -317,29 +317,33 @@ CNAME(rstcode): * processor is waking up from power saving mode * It is software reset when 46:47 = 0b00 */ + /* 0x00 */ + ld %r2,TRAP_GENTRAP(0) /* Real-mode &generictrap */ mfsrr1 %r9 /* Load SRR1 into r9 */ andis. %r9,%r9,0x3 /* Logic AND with 46:47 bits */ + beq 2f /* Branch if software reset */ - bl 1f - .llong cpu_wakeup_handler + /* 0x10 */ + /* Reset was wakeup */ + addi %r9,%r2,(cpu_wakeup_handler-generictrap) + b 1f /* Was power save, do the wakeup */ - /* It is software reset */ - + /* Reset was software reset */ /* Explicitly set MSR[SF] */ 2: mfmsr %r9 li %r8,1 + /* 0x20 */ insrdi %r9,%r8,1,0 mtmsrd %r9 isync - bl 1f - .llong cpu_reset_handler /* Make sure to maintain 8-byte alignment */ + addi %r9,%r2,(cpu_reset_handler-generictrap) -1: mflr %r9 - ld %r9,0(%r9) - mtlr %r9 - - blr + /* 0x30 */ +1: mtlr %r9 + blr /* Branch to either cpu_reset_handler + * or cpu_wakeup_handler. + */ CNAME(rstcodeend): cpu_reset_handler: @@ -457,52 +461,59 @@ CNAME(hypertrapcode): addi %r1,%r1,(generichypertrap-generictrap) mtlr %r1 li %r1, 0xe0 /* How to get the vector from LR */ - blrl /* Branch to generictrap */ + blrl /* Branch to generichypertrap */ CNAME(hypertrapcodeend): /* * For SLB misses: do special things for the kernel * - * Note: SPRG1 is always safe to overwrite any time the MMU is on, which is + * Note: SPRG1 is always safe to overwrite any time the MMU was on, which is * the only time this can be called. */ .globl CNAME(slbtrap),CNAME(slbtrapend) .p2align 3 CNAME(slbtrap): + /* 0x00 */ mtsprg1 %r1 /* save SP */ GET_CPUINFO(%r1) - std %r2,(PC_SLBSAVE+16)(%r1) - mfcr %r2 /* save CR */ - std %r2,(PC_SLBSAVE+104)(%r1) + std %r2,(PC_SLBSAVE+16)(%r1) /* save r2 */ + mfcr %r2 + /* 0x10 */ + std %r2,(PC_SLBSAVE+104)(%r1) /* save CR */ mfsrr1 %r2 /* test kernel mode */ mtcr %r2 bf 17,2f /* branch if PSL_PR is false */ + /* 0x20 */ /* User mode */ - ld %r2,(PC_SLBSAVE+104)(%r1) /* Restore CR */ - mtcr %r2 - ld %r2,(PC_SLBSAVE+16)(%r1) /* Restore R2 */ - mflr %r1 /* Save the old LR in r1 */ - mtsprg2 %r1 /* And then in SPRG2 */ - /* 52 bytes so far */ - bl 1f - .llong generictrap -1: mflr %r1 - ld %r1,0(%r1) + ld %r2,(PC_SLBSAVE+104)(%r1) + mtcr %r2 /* restore CR */ + ld %r2,(PC_SLBSAVE+16)(%r1) /* restore r2 */ + mflr %r1 + /* 0x30 */ + mtsprg2 %r1 /* save LR in SPRG2 */ + ld %r1,TRAP_GENTRAP(0) /* real-mode &generictrap */ mtlr %r1 li %r1, 0x80 /* How to get the vector from LR */ + /* 0x40 */ blrl /* Branch to generictrap */ - /* 84 bytes */ 2: mflr %r2 /* Save the old LR in r2 */ - nop - bl 3f /* Begin dance to jump to kern_slbtrap*/ - .llong kern_slbtrap -3: mflr %r1 - ld %r1,0(%r1) + /* Kernel mode */ + ld %r1,TRAP_GENTRAP(0) /* Real-mode &generictrap */ + addi %r1,%r1,(kern_slbtrap-generictrap) + /* 0x50 */ mtlr %r1 GET_CPUINFO(%r1) - blrl /* 124 bytes -- 4 to spare */ + blrl /* Branch to kern_slbtrap */ +/* must fit in 128 bytes! */ CNAME(slbtrapend): +/* + * On entry: + * SPRG1: SP + * r1: pcpu + * r2: LR + * LR: branch address in trap region + */ kern_slbtrap: std %r2,(PC_SLBSAVE+136)(%r1) /* old LR */ std %r3,(PC_SLBSAVE+24)(%r1) /* save R3 */ @@ -510,7 +521,7 @@ kern_slbtrap: /* Check if this needs to be handled as a regular trap (userseg miss) */ mflr %r2 andi. %r2,%r2,0xff80 - cmpwi %r2,0x380 + cmpwi %r2,EXC_DSE bne 1f mfdar %r2 b 2f @@ -639,14 +650,8 @@ CNAME(alitrap): mflr %r28 /* save LR */ mfcr %r29 /* save CR */ - /* Begin dance to branch to s_trap in a bit */ - b 1f - .p2align 3 -1: nop - bl 1f - .llong s_trap -1: mflr %r31 - ld %r31,0(%r31) + ld %r31,TRAP_GENTRAP(0) + addi %r31,%r31,(s_trap - generictrap) mtlr %r31 /* Put our exception vector in SPRG3 */ @@ -656,7 +661,7 @@ CNAME(alitrap): /* Test whether we already had PR set */ mfsrr1 %r31 mtcr %r31 - blrl + blrl /* Branch to s_trap */ CNAME(aliend): /* @@ -679,12 +684,10 @@ CNAME(dsitrap): mfsrr1 %r31 /* test kernel mode */ mtcr %r31 mflr %r28 /* save LR (SP already saved) */ - bl 1f /* Begin branching to disitrap */ - .llong disitrap -1: mflr %r1 - ld %r1,0(%r1) + ld %r1,TRAP_GENTRAP(0) + addi %r1,%r1,(disitrap-generictrap) mtlr %r1 - blrl /* Branch to generictrap */ + blrl /* Branch to disitrap */ CNAME(dsiend): /* @@ -953,7 +956,7 @@ CNAME(dblow): mtlr %r1 li %r1, 0 /* How to get the vector from LR */ blrl /* Branch to generictrap */ - + /* No fallthrough */ 1: GET_CPUINFO(%r1) std %r27,(PC_DBSAVE+CPUSAVE_R27)(%r1) /* free r27 */ @@ -963,12 +966,9 @@ CNAME(dblow): std %r30,(PC_DBSAVE+CPUSAVE_R30)(%r1) /* free r30 */ std %r31,(PC_DBSAVE+CPUSAVE_R31)(%r1) /* free r31 */ mflr %r28 /* save LR */ - nop /* alignment */ - bl 9f /* Begin branch */ - .llong dbtrap -9: mflr %r1 - ld %r1,0(%r1) + ld %r1,TRAP_GENTRAP(0) + addi %r1,%r1,(dbtrap-generictrap) mtlr %r1 - blrl /* Branch to generictrap */ + blrl /* Branch to dbtrap */ CNAME(dbend): #endif /* KDB */ Modified: stable/12/sys/powerpc/powerpc/cpu_subr64.S ============================================================================== --- stable/12/sys/powerpc/powerpc/cpu_subr64.S Wed Jun 5 12:38:58 2019 (r348684) +++ stable/12/sys/powerpc/powerpc/cpu_subr64.S Wed Jun 5 12:43:45 2019 (r348685) @@ -31,7 +31,6 @@ #include - .globl CNAME(power_save_sequence) .p2align 3 ENTRY(enter_idle_powerx) mfsprg0 %r3 /* Get the pcpu pointer */ @@ -65,11 +64,9 @@ ENTRY(enter_idle_powerx) std %r1,PCB_SP(%r3) /* Save the stack pointer */ std %r2,PCB_TOC(%r3) /* Save the TOC pointer */ - /* Set where we want to jump */ bl 1f - .llong power_save_sequence /* Remember about 8 byte alignment */ 1: mflr %r3 - ld %r3,0(%r3) + addi %r3,%r3,power_save_sequence-1b mtsrr0 %r3 /* Set MSR */ @@ -82,7 +79,7 @@ ENTRY(enter_idle_powerx) rfid .p2align 2 -CNAME(power_save_sequence): +power_save_sequence: bl 1f .llong 0x0 /* Playground for power-save sequence */ 1: mflr %r3 From owner-svn-src-stable-12@freebsd.org Wed Jun 5 12:53:37 2019 Return-Path: Delivered-To: svn-src-stable-12@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 6575815ACFB6; Wed, 5 Jun 2019 12:53:37 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 09A2281EEE; Wed, 5 Jun 2019 12:53:37 +0000 (UTC) (envelope-from luporl@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 D48435515; Wed, 5 Jun 2019 12:53:36 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x55Crabg008914; Wed, 5 Jun 2019 12:53:36 GMT (envelope-from luporl@FreeBSD.org) Received: (from luporl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x55CrafE008913; Wed, 5 Jun 2019 12:53:36 GMT (envelope-from luporl@FreeBSD.org) Message-Id: <201906051253.x55CrafE008913@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luporl set sender to luporl@FreeBSD.org using -f From: Leandro Lupori Date: Wed, 5 Jun 2019 12:53:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348686 - stable/12/stand/powerpc X-SVN-Group: stable-12 X-SVN-Commit-Author: luporl X-SVN-Commit-Paths: stable/12/stand/powerpc X-SVN-Commit-Revision: 348686 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 09A2281EEE X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 12:53:37 -0000 Author: luporl Date: Wed Jun 5 12:53:36 2019 New Revision: 348686 URL: https://svnweb.freebsd.org/changeset/base/348686 Log: MFC r348028: stand/powerpc: Only build loader.kboot for powerpc64 kboot is only made for powerpc64 systems, not 32-bit systems. This unbreaks the build for powerpcspe. Reported by: ngie Modified: stable/12/stand/powerpc/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/powerpc/Makefile ============================================================================== --- stable/12/stand/powerpc/Makefile Wed Jun 5 12:43:45 2019 (r348685) +++ stable/12/stand/powerpc/Makefile Wed Jun 5 12:53:36 2019 (r348686) @@ -5,6 +5,9 @@ NO_OBJ=t .include SUBDIR.yes= boot1.chrp ofw uboot + +.if "${TARGET_ARCH}" == "powerpc64" SUBDIR.${MK_FDT}+= kboot +.endif .include From owner-svn-src-stable-12@freebsd.org Wed Jun 5 14:19:56 2019 Return-Path: Delivered-To: svn-src-stable-12@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 512CC15AF37E; Wed, 5 Jun 2019 14:19:56 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EC5CD84E48; Wed, 5 Jun 2019 14:19:55 +0000 (UTC) (envelope-from luporl@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 C15746276; Wed, 5 Jun 2019 14:19:55 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x55EJtkK050663; Wed, 5 Jun 2019 14:19:55 GMT (envelope-from luporl@FreeBSD.org) Received: (from luporl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x55EJsT5050659; Wed, 5 Jun 2019 14:19:54 GMT (envelope-from luporl@FreeBSD.org) Message-Id: <201906051419.x55EJsT5050659@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luporl set sender to luporl@FreeBSD.org using -f From: Leandro Lupori Date: Wed, 5 Jun 2019 14:19:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348690 - stable/12/sys/powerpc/aim X-SVN-Group: stable-12 X-SVN-Commit-Author: luporl X-SVN-Commit-Paths: stable/12/sys/powerpc/aim X-SVN-Commit-Revision: 348690 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EC5CD84E48 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.963,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 14:19:56 -0000 Author: luporl Date: Wed Jun 5 14:19:54 2019 New Revision: 348690 URL: https://svnweb.freebsd.org/changeset/base/348690 Log: MFC r343744: powerpc64: Add a trap stack area Currently, the trap code switches to the the temporary stack in the dbtrap section. It works in most cases, but in the beginning of the execution, the temp stack is being used, as starting in the powerpc_init() code. In this current scenario, the stack is being overwritten, which causes the return of breakpoint() to take abnormal execution. This current patchset create a small stack to use by the dbtrap: codepath avoiding the corruption of the temporary stack. PR: 224872 Submitted by: breno.leitao_gmail.com Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D14484 Modified: stable/12/sys/powerpc/aim/locore32.S stable/12/sys/powerpc/aim/locore64.S stable/12/sys/powerpc/aim/trap_subr32.S stable/12/sys/powerpc/aim/trap_subr64.S Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/powerpc/aim/locore32.S ============================================================================== --- stable/12/sys/powerpc/aim/locore32.S Wed Jun 5 14:08:39 2019 (r348689) +++ stable/12/sys/powerpc/aim/locore32.S Wed Jun 5 14:19:54 2019 (r348690) @@ -60,6 +60,12 @@ GLOBAL(__endkernel) GLOBAL(tmpstk) .space TMPSTKSZ +#ifdef KDB +#define TRAPSTKSZ 4096 /* 4k trap stack */ +GLOBAL(trapstk) + .space TRAPSTKSZ +#endif + .text .globl btext btext: Modified: stable/12/sys/powerpc/aim/locore64.S ============================================================================== --- stable/12/sys/powerpc/aim/locore64.S Wed Jun 5 14:08:39 2019 (r348689) +++ stable/12/sys/powerpc/aim/locore64.S Wed Jun 5 14:19:54 2019 (r348690) @@ -65,6 +65,14 @@ GLOBAL(tmpstk) TOC_ENTRY(tmpstk) TOC_ENTRY(can_wakeup) +#ifdef KDB +#define TRAPSTKSZ 4096 /* 4k trap stack */ +GLOBAL(trapstk) + .space TRAPSTKSZ +TOC_ENTRY(trapstk) +#endif + + /* * Entry point for bootloaders that do not fully implement ELF and start * at the beginning of the image (kexec, notably). In its own section so Modified: stable/12/sys/powerpc/aim/trap_subr32.S ============================================================================== --- stable/12/sys/powerpc/aim/trap_subr32.S Wed Jun 5 14:08:39 2019 (r348689) +++ stable/12/sys/powerpc/aim/trap_subr32.S Wed Jun 5 14:19:54 2019 (r348690) @@ -864,8 +864,8 @@ dbtrap: mtsprg3 %r1 lwz %r1,TRAP_TOCBASE(0) /* get new SP */ - lwz %r1,tmpstk@got(%r1) - addi %r1,%r1,TMPSTKSZ-16 + lwz %r1,trapstk@got(%r1) + addi %r1,%r1,TRAPSTKSZ-16 FRAME_SETUP(PC_DBSAVE) /* Call C trap code: */ Modified: stable/12/sys/powerpc/aim/trap_subr64.S ============================================================================== --- stable/12/sys/powerpc/aim/trap_subr64.S Wed Jun 5 14:08:39 2019 (r348689) +++ stable/12/sys/powerpc/aim/trap_subr64.S Wed Jun 5 14:19:54 2019 (r348690) @@ -900,8 +900,8 @@ dbtrap: mtsprg3 %r1 GET_TOCBASE(%r1) /* get new SP */ - ld %r1,TOC_REF(tmpstk)(%r1) - addi %r1,%r1,(TMPSTKSZ-48) + ld %r1,TOC_REF(trapstk)(%r1) + addi %r1,%r1,(TRAPSTKSZ-48) FRAME_SETUP(PC_DBSAVE) /* Call C trap code: */ From owner-svn-src-stable-12@freebsd.org Wed Jun 5 14:23:12 2019 Return-Path: Delivered-To: svn-src-stable-12@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 56D3315AF5E4; Wed, 5 Jun 2019 14:23:12 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E8B6685277; Wed, 5 Jun 2019 14:23:11 +0000 (UTC) (envelope-from luporl@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 BF8B1642E; Wed, 5 Jun 2019 14:23:11 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x55ENBWM055900; Wed, 5 Jun 2019 14:23:11 GMT (envelope-from luporl@FreeBSD.org) Received: (from luporl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x55ENA2c055895; Wed, 5 Jun 2019 14:23:10 GMT (envelope-from luporl@FreeBSD.org) Message-Id: <201906051423.x55ENA2c055895@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luporl set sender to luporl@FreeBSD.org using -f From: Leandro Lupori Date: Wed, 5 Jun 2019 14:23:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348691 - in stable/12/sys/powerpc: aim booke ofw powernv powerpc X-SVN-Group: stable-12 X-SVN-Commit-Author: luporl X-SVN-Commit-Paths: in stable/12/sys/powerpc: aim booke ofw powernv powerpc X-SVN-Commit-Revision: 348691 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E8B6685277 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.96)[-0.963,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 14:23:12 -0000 Author: luporl Date: Wed Jun 5 14:23:10 2019 New Revision: 348691 URL: https://svnweb.freebsd.org/changeset/base/348691 Log: MFC r345676: powerpc64: Use medium code model in asm files for TOC references Summary: With a sufficiently large TOC, it's possible to index out of range, as the immediate load instructions only permit 16-bit indices, allowing up to 64kB range (signed) from the base pointer. Allow +/- 2GB range, with the medium code model TOC accesses in asm. Patch originally by Brandon Bergren. The issue appears to impact ELFv2 more than ELFv1. Reviewed by: luporl Differential Revision: https://reviews.freebsd.org/D19708 Modified: stable/12/sys/powerpc/aim/trap_subr64.S stable/12/sys/powerpc/booke/locore.S stable/12/sys/powerpc/ofw/ofwcall64.S stable/12/sys/powerpc/powernv/opalcall.S stable/12/sys/powerpc/powerpc/swtch64.S Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/powerpc/aim/trap_subr64.S ============================================================================== --- stable/12/sys/powerpc/aim/trap_subr64.S Wed Jun 5 14:19:54 2019 (r348690) +++ stable/12/sys/powerpc/aim/trap_subr64.S Wed Jun 5 14:23:10 2019 (r348691) @@ -349,7 +349,8 @@ CNAME(rstcodeend): cpu_reset_handler: GET_TOCBASE(%r2) - ld %r1,TOC_REF(tmpstk)(%r2) /* get new SP */ + addis %r1,%r2,TOC_REF(tmpstk)@ha + ld %r1,TOC_REF(tmpstk)@l(%r1) /* get new SP */ addi %r1,%r1,(TMPSTKSZ-48) bl CNAME(cpudep_ap_early_bootstrap) /* Set PCPU */ @@ -384,7 +385,8 @@ cpu_wakeup_handler: GET_TOCBASE(%r2) /* Check for false wake up due to badly SRR1 set (eg. by OPAL) */ - ld %r3,TOC_REF(can_wakeup)(%r2) + addis %r3,%r2,TOC_REF(can_wakeup)@ha + ld %r3,TOC_REF(can_wakeup)@l(%r3) ld %r3,0(%r3) cmpdi %r3,0 beq cpu_reset_handler @@ -900,7 +902,8 @@ dbtrap: mtsprg3 %r1 GET_TOCBASE(%r1) /* get new SP */ - ld %r1,TOC_REF(trapstk)(%r1) + addis %r1,%r1,TOC_REF(trapstk)@ha + ld %r1,TOC_REF(trapstk)@l(%r1) addi %r1,%r1,(TRAPSTKSZ-48) FRAME_SETUP(PC_DBSAVE) Modified: stable/12/sys/powerpc/booke/locore.S ============================================================================== --- stable/12/sys/powerpc/booke/locore.S Wed Jun 5 14:19:54 2019 (r348690) +++ stable/12/sys/powerpc/booke/locore.S Wed Jun 5 14:23:10 2019 (r348691) @@ -302,7 +302,8 @@ done_mapping: subf %r31,%r31,%r2 /* Subtract from real TOC base to get base */ /* Set up the stack pointer */ - ld %r1,TOC_REF(tmpstack)(%r2) + addis %r1,%r2,TOC_REF(tmpstack)@ha + ld %r1,TOC_REF(tmpstack)@l(%r1) addi %r1,%r1,TMPSTACKSZ-96 add %r1,%r1,%r31 bl 1f @@ -550,7 +551,8 @@ bp_kernload: mtspr SPR_SPRG8, %r2 /* Set up the stack pointer */ - ld %r1,TOC_REF(tmpstack)(%r2) + addis %r1,%r2,TOC_REF(tmpstack)@ha + ld %r1,TOC_REF(tmpstack)@l(%r1) addi %r1,%r1,TMPSTACKSZ-96 #else /* Modified: stable/12/sys/powerpc/ofw/ofwcall64.S ============================================================================== --- stable/12/sys/powerpc/ofw/ofwcall64.S Wed Jun 5 14:19:54 2019 (r348690) +++ stable/12/sys/powerpc/ofw/ofwcall64.S Wed Jun 5 14:23:10 2019 (r348691) @@ -101,11 +101,13 @@ ASENTRY_NOPROF(ofwcall) mfmsr %r6 /* read client interface handler */ - ld %r4,TOC_REF(openfirmware_entry)(%r2) + addis %r4,%r2,TOC_REF(openfirmware_entry)@ha + ld %r4,TOC_REF(openfirmware_entry)@l(%r4) ld %r4,0(%r4) /* Get OF stack pointer */ - ld %r7,TOC_REF(ofwstk)(%r2) + addis %r7,%r2,TOC_REF(ofwstk)@ha + ld %r7,TOC_REF(ofwstk)@l(%r7) addi %r7,%r7,OFWSTKSZ-40 /* @@ -113,7 +115,8 @@ ASENTRY_NOPROF(ofwcall) * exceptions, which is important for the next few steps. */ - ld %r5,TOC_REF(ofmsr)(%r2) + addis %r5,%r2,TOC_REF(ofmsr)@ha + ld %r5,TOC_REF(ofmsr)@l(%r5) ld %r5,0(%r5) mtmsrd %r5 isync @@ -233,16 +236,19 @@ ASENTRY_NOPROF(rtascall) mfmsr %r6 /* Read RTAS entry and reg save area pointers */ - ld %r5,TOC_REF(rtas_entry)(%r2) + addis %r5,%r2,TOC_REF(rtas_entry)@ha + ld %r5,TOC_REF(rtas_entry)@l(%r5) ld %r5,0(%r5) - ld %r8,TOC_REF(rtas_regsave)(%r2) + addis %r8,%r2,TOC_REF(rtas_regsave)@ha + ld %r8,TOC_REF(rtas_regsave)@l(%r8) /* * Set the MSR to the RTAS value. This has the side effect of disabling * exceptions, which is important for the next few steps. */ - ld %r7,TOC_REF(rtasmsr)(%r2) + addis %r7,%r2,TOC_REF(rtasmsr)@ha + ld %r7,TOC_REF(rtasmsr)@l(%r7) ld %r7,0(%r7) mtmsrd %r7 isync Modified: stable/12/sys/powerpc/powernv/opalcall.S ============================================================================== --- stable/12/sys/powerpc/powernv/opalcall.S Wed Jun 5 14:19:54 2019 (r348690) +++ stable/12/sys/powerpc/powernv/opalcall.S Wed Jun 5 14:23:10 2019 (r348691) @@ -53,7 +53,8 @@ ASENTRY(opal_call) /* Load OPAL entry information */ mr %r0,%r3 - ld %r3,TOC_REF(opal_entrypoint)(%r2) + addis %r3,%r2,TOC_REF(opal_entrypoint)@ha + ld %r3,TOC_REF(opal_entrypoint)@l(%r3) ld %r3,0(%r3) mtctr %r3 @@ -62,9 +63,11 @@ ASENTRY(opal_call) mfmsr %r31 /* Load last bits from the TOC */ - ld %r3,TOC_REF(opal_msr)(%r2) + addis %r3,%r2,TOC_REF(opal_msr)@ha + ld %r3,TOC_REF(opal_msr)@l(%r3) ld %r3,0(%r3) - ld %r2,TOC_REF(opal_data)(%r2) + addis %r2,%r2,TOC_REF(opal_data)@ha + ld %r2,TOC_REF(opal_data)@l(%r2) ld %r2,0(%r2) mtmsrd %r3 Modified: stable/12/sys/powerpc/powerpc/swtch64.S ============================================================================== --- stable/12/sys/powerpc/powerpc/swtch64.S Wed Jun 5 14:19:54 2019 (r348690) +++ stable/12/sys/powerpc/powerpc/swtch64.S Wed Jun 5 14:23:10 2019 (r348691) @@ -159,7 +159,8 @@ ENTRY(cpu_switch) cpu_switchin: #if defined(SMP) && defined(SCHED_ULE) /* Wait for the new thread to become unblocked */ - ld %r6,TOC_REF(blocked_lock)(%r2) + addis %r6,%r2,TOC_REF(blocked_lock)@ha + ld %r6,TOC_REF(blocked_lock)@l(%r6) blocked_loop: ld %r7,TD_LOCK(%r13) cmpd %r6,%r7 From owner-svn-src-stable-12@freebsd.org Wed Jun 5 19:46:36 2019 Return-Path: Delivered-To: svn-src-stable-12@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 7B99E15B7744; Wed, 5 Jun 2019 19:46:36 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1A5F06A6ED; Wed, 5 Jun 2019 19:46:36 +0000 (UTC) (envelope-from allanjude@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 0B3829B65; Wed, 5 Jun 2019 19:46:36 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x55JkZr0024492; Wed, 5 Jun 2019 19:46:35 GMT (envelope-from allanjude@FreeBSD.org) Received: (from allanjude@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x55JkZNc024491; Wed, 5 Jun 2019 19:46:35 GMT (envelope-from allanjude@FreeBSD.org) Message-Id: <201906051946.x55JkZNc024491@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: allanjude set sender to allanjude@FreeBSD.org using -f From: Allan Jude Date: Wed, 5 Jun 2019 19:46:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348696 - stable/12/cddl/contrib/opensolaris/cmd/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: allanjude X-SVN-Commit-Paths: stable/12/cddl/contrib/opensolaris/cmd/zfs X-SVN-Commit-Revision: 348696 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1A5F06A6ED X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.968,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 19:46:36 -0000 Author: allanjude Date: Wed Jun 5 19:46:35 2019 New Revision: 348696 URL: https://svnweb.freebsd.org/changeset/base/348696 Log: MFC r347953: MFV/ZoL: `zfs userspace` ignored all unresolved UIDs after the first zfsonlinux/zfs@88cfff182432e4d1c24c877f33b47ee6cf109eee zfs_main: fix `zfs userspace` squashing unresolved entries The `zfs userspace` squashes all entries with unresolved numeric values into a single output entry due to the comparsion always made by the string name which is empty in case of unresolved IDs. Fix this by falling to a numerical comparison when either one of string values is not found. This then compares any numerical values after all with a name resolved. Signed-off-by: Pavel Boldin Signed-off-by: Brian Behlendorf Reported by: clusteradm Obtained from: ZFS-on-Linux Modified: stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Wed Jun 5 19:30:32 2019 (r348695) +++ stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Wed Jun 5 19:46:35 2019 (r348696) @@ -2361,6 +2361,7 @@ us_compare(const void *larg, const void *rarg, void *u case ZFS_PROP_NAME: propname = "name"; if (numname) { +compare_nums: (void) nvlist_lookup_uint64(lnvl, propname, &lv64); (void) nvlist_lookup_uint64(rnvl, propname, @@ -2368,10 +2369,12 @@ us_compare(const void *larg, const void *rarg, void *u if (rv64 != lv64) rc = (rv64 < lv64) ? 1 : -1; } else { - (void) nvlist_lookup_string(lnvl, propname, - &lvstr); - (void) nvlist_lookup_string(rnvl, propname, - &rvstr); + if ((nvlist_lookup_string(lnvl, propname, + &lvstr) == ENOENT) || + (nvlist_lookup_string(rnvl, propname, + &rvstr) == ENOENT)) { + goto compare_nums; + } rc = strcmp(lvstr, rvstr); } break; From owner-svn-src-stable-12@freebsd.org Wed Jun 5 20:27:28 2019 Return-Path: Delivered-To: svn-src-stable-12@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 F3CFE15B866B; Wed, 5 Jun 2019 20:27:27 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8B1866BEC7; Wed, 5 Jun 2019 20:27:27 +0000 (UTC) (envelope-from allanjude@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 65E55A24D; Wed, 5 Jun 2019 20:27:27 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x55KRRtw045369; Wed, 5 Jun 2019 20:27:27 GMT (envelope-from allanjude@FreeBSD.org) Received: (from allanjude@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x55KRR1j045368; Wed, 5 Jun 2019 20:27:27 GMT (envelope-from allanjude@FreeBSD.org) Message-Id: <201906052027.x55KRR1j045368@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: allanjude set sender to allanjude@FreeBSD.org using -f From: Allan Jude Date: Wed, 5 Jun 2019 20:27:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348702 - stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: allanjude X-SVN-Commit-Paths: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 348702 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8B1866BEC7 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.977,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 20:27:28 -0000 Author: allanjude Date: Wed Jun 5 20:27:26 2019 New Revision: 348702 URL: https://svnweb.freebsd.org/changeset/base/348702 Log: MFC r348068, r348071 r348068: ZFS: Make deadman tunables no longer read-only This allows the user to enable, disable, and adjust the I/O deadman at runtime. This can be especially useful when a pool is backed by remote storage (such as iscsi, ggated, etc). PR: 221906 Submitted by: Fabian Keil Obtained from: ElectroBSD Sponsored by: Klara Systems Event: Waterloo Hackathon 2019 r348071: Fix typo in r348068 Sponsored by: Klara Systems Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Wed Jun 5 20:21:17 2019 (r348701) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Wed Jun 5 20:27:26 2019 (r348702) @@ -363,13 +363,13 @@ SYSCTL_PROC(_vfs_zfs, OID_AUTO, debugflags, CTLTYPE_UINT | CTLFLAG_MPSAFE | CTLFLAG_RWTUN, 0, sizeof(int), sysctl_vfs_zfs_debug_flags, "IU", "Debug flags for ZFS testing."); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_synctime_ms, CTLFLAG_RDTUN, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_synctime_ms, CTLFLAG_RWTUN, &zfs_deadman_synctime_ms, 0, "Stalled ZFS I/O expiration time in milliseconds"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_checktime_ms, CTLFLAG_RDTUN, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_checktime_ms, CTLFLAG_RWTUN, &zfs_deadman_checktime_ms, 0, "Period of checks for stalled ZFS I/O in milliseconds"); -SYSCTL_INT(_vfs_zfs, OID_AUTO, deadman_enabled, CTLFLAG_RDTUN, +SYSCTL_INT(_vfs_zfs, OID_AUTO, deadman_enabled, CTLFLAG_RWTUN, &zfs_deadman_enabled, 0, "Kernel panic on stalled ZFS I/O"); SYSCTL_INT(_vfs_zfs, OID_AUTO, spa_asize_inflation, CTLFLAG_RWTUN, &spa_asize_inflation, 0, "Worst case inflation factor for single sector writes"); From owner-svn-src-stable-12@freebsd.org Wed Jun 5 20:31:11 2019 Return-Path: Delivered-To: svn-src-stable-12@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 2A9A215B8943; Wed, 5 Jun 2019 20:31:11 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6FA106C1B4; Wed, 5 Jun 2019 20:31:10 +0000 (UTC) (envelope-from allanjude@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 0CF68A38C; Wed, 5 Jun 2019 20:31:10 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x55KV9Gn045616; Wed, 5 Jun 2019 20:31:09 GMT (envelope-from allanjude@FreeBSD.org) Received: (from allanjude@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x55KV9uk045615; Wed, 5 Jun 2019 20:31:09 GMT (envelope-from allanjude@FreeBSD.org) Message-Id: <201906052031.x55KV9uk045615@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: allanjude set sender to allanjude@FreeBSD.org using -f From: Allan Jude Date: Wed, 5 Jun 2019 20:31:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348703 - stable/12/sys/dev/acpica X-SVN-Group: stable-12 X-SVN-Commit-Author: allanjude X-SVN-Commit-Paths: stable/12/sys/dev/acpica X-SVN-Commit-Revision: 348703 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6FA106C1B4 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 20:31:11 -0000 Author: allanjude Date: Wed Jun 5 20:31:09 2019 New Revision: 348703 URL: https://svnweb.freebsd.org/changeset/base/348703 Log: MFC r348065: Correct the way remaining battery life is calculated Previously, if a system had multiple batteries, the remaining life percentage was calculated as the average of each battery's percent remaining. This results in rather incorrect values when you consider the case of the Thinkpad X270 that has a small 3 cell internally battery, and a hot-swappable 9 cell battery that is used first. Battery 0 is at 100%, but battery 1 is at 10%, you do not infact have 55% of your capacity remaining. The new method calculates the percentage based on remaining capacity out of total capacity, giving a much more accurate reading. PR: 229818 Submitted by: Keegan Drake H.P. Sponsored by: Klara Systems Event: Waterloo Hackathon 2019 Modified: stable/12/sys/dev/acpica/acpi_battery.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/acpica/acpi_battery.c ============================================================================== --- stable/12/sys/dev/acpica/acpi_battery.c Wed Jun 5 20:27:26 2019 (r348702) +++ stable/12/sys/dev/acpica/acpi_battery.c Wed Jun 5 20:31:09 2019 (r348703) @@ -119,7 +119,7 @@ int acpi_battery_get_battinfo(device_t dev, struct acpi_battinfo *battinfo) { int batt_stat, devcount, dev_idx, error, i; - int total_cap, total_min, valid_rate, valid_units; + int total_cap, total_lfcap, total_min, valid_rate, valid_units; devclass_t batt_dc; device_t batt_dev; struct acpi_bst *bst; @@ -152,6 +152,7 @@ acpi_battery_get_battinfo(device_t dev, struct acpi_ba */ dev_idx = -1; batt_stat = valid_rate = valid_units = 0; + total_cap = total_lfcap = 0; for (i = 0; i < devcount; i++) { /* Default info for every battery is "not present". */ acpi_reset_battinfo(&bi[i]); @@ -213,17 +214,23 @@ acpi_battery_get_battinfo(device_t dev, struct acpi_ba if (!acpi_battery_bif_valid(bif)) continue; - /* Calculate percent capacity remaining. */ - bi[i].cap = (100 * bst[i].cap) / bif->lfcap; - /* * Some laptops report the "design-capacity" instead of the * "real-capacity" when the battery is fully charged. That breaks * the above arithmetic as it needs to be 100% maximum. */ - if (bi[i].cap > 100) - bi[i].cap = 100; + if (bst[i].cap > bif->lfcap) + bst[i].cap = bif->lfcap; + /* Calculate percent capacity remaining. */ + bi[i].cap = (100 * bst[i].cap) / bif->lfcap; + + /* If this battery is not present, don't use its capacity. */ + if (bi[i].cap != -1) { + total_cap += bst[i].cap; + total_lfcap += bif->lfcap; + } + /* * On systems with more than one battery, they may get used * sequentially, thus bst.rate may only signify the one currently @@ -244,7 +251,7 @@ acpi_battery_get_battinfo(device_t dev, struct acpi_ba } /* Pass 2: calculate capacity and remaining time for all batteries. */ - total_cap = total_min = 0; + total_min = 0; for (i = 0; i < devcount; i++) { /* * If any batteries are discharging, use the sum of the bst.rate @@ -256,10 +263,6 @@ acpi_battery_get_battinfo(device_t dev, struct acpi_ba else bi[i].min = 0; total_min += bi[i].min; - - /* If this battery is not present, don't use its capacity. */ - if (bi[i].cap != -1) - total_cap += bi[i].cap; } /* @@ -268,7 +271,7 @@ acpi_battery_get_battinfo(device_t dev, struct acpi_ba */ if (valid_units > 0) { if (dev == NULL) { - battinfo->cap = total_cap / valid_units; + battinfo->cap = (total_cap * 100) / total_lfcap; battinfo->min = total_min; battinfo->state = batt_stat; battinfo->rate = valid_rate; From owner-svn-src-stable-12@freebsd.org Thu Jun 6 01:16:05 2019 Return-Path: Delivered-To: svn-src-stable-12@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 5699415BE2F0; Thu, 6 Jun 2019 01:16:05 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EC20A75EAF; Thu, 6 Jun 2019 01:16:04 +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 C5806D4AC; Thu, 6 Jun 2019 01:16:04 +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 x561G4Gi099186; Thu, 6 Jun 2019 01:16:04 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x561G49b099185; Thu, 6 Jun 2019 01:16:04 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201906060116.x561G49b099185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 6 Jun 2019 01:16:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348713 - in stable/12/sys/dev: mpr mps X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12/sys/dev: mpr mps X-SVN-Commit-Revision: 348713 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EC20A75EAF X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.944,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 01:16:05 -0000 Author: mav Date: Thu Jun 6 01:16:04 2019 New Revision: 348713 URL: https://svnweb.freebsd.org/changeset/base/348713 Log: MFC r348417: Fix busy status leak in case of incorrect passthrough args. Modified: stable/12/sys/dev/mpr/mpr_user.c stable/12/sys/dev/mps/mps_user.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/mpr/mpr_user.c ============================================================================== --- stable/12/sys/dev/mpr/mpr_user.c Wed Jun 5 23:37:50 2019 (r348712) +++ stable/12/sys/dev/mpr/mpr_user.c Thu Jun 6 01:16:04 2019 (r348713) @@ -790,8 +790,10 @@ mpr_user_pass_thru(struct mpr_softc *sc, mpr_pass_thru data->DataDirection = MPR_PASS_THRU_DIRECTION_READ; else data->DataOutSize = 0; - } else - return (EINVAL); + } else { + err = EINVAL; + goto RetFreeUnlocked; + } mpr_dprint(sc, MPR_USER, "%s: req 0x%jx %d rpl 0x%jx %d " "data in 0x%jx %d data out 0x%jx %d data dir %d\n", __func__, Modified: stable/12/sys/dev/mps/mps_user.c ============================================================================== --- stable/12/sys/dev/mps/mps_user.c Wed Jun 5 23:37:50 2019 (r348712) +++ stable/12/sys/dev/mps/mps_user.c Thu Jun 6 01:16:04 2019 (r348713) @@ -802,8 +802,10 @@ mps_user_pass_thru(struct mps_softc *sc, mps_pass_thru data->DataDirection = MPS_PASS_THRU_DIRECTION_READ; else data->DataOutSize = 0; - } else - return (EINVAL); + } else { + err = EINVAL; + goto RetFreeUnlocked; + } mps_dprint(sc, MPS_USER, "%s: req 0x%jx %d rpl 0x%jx %d " "data in 0x%jx %d data out 0x%jx %d data dir %d\n", __func__, From owner-svn-src-stable-12@freebsd.org Thu Jun 6 02:58:12 2019 Return-Path: Delivered-To: svn-src-stable-12@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 63D5715C025B; Thu, 6 Jun 2019 02:58:12 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F26708086B; Thu, 6 Jun 2019 02:58:11 +0000 (UTC) (envelope-from markj@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 C7B25E562; Thu, 6 Jun 2019 02:58:11 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x562wB3n051646; Thu, 6 Jun 2019 02:58:11 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x562wBPC051645; Thu, 6 Jun 2019 02:58:11 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906060258.x562wBPC051645@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 6 Jun 2019 02:58:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348715 - stable/12/lib/libelftc X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/lib/libelftc X-SVN-Commit-Revision: 348715 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: F26708086B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.959,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 02:58:12 -0000 Author: markj Date: Thu Jun 6 02:58:11 2019 New Revision: 348715 URL: https://svnweb.freebsd.org/changeset/base/348715 Log: MFC r348444: libelftc: Add MLINKS. Modified: stable/12/lib/libelftc/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libelftc/Makefile ============================================================================== --- stable/12/lib/libelftc/Makefile Thu Jun 6 01:32:00 2019 (r348714) +++ stable/12/lib/libelftc/Makefile Thu Jun 6 02:58:11 2019 (r348715) @@ -38,6 +38,19 @@ MAN+= elftc.3 \ elftc_string_table_create.3 \ elftc_version.3 +MLINKS+= \ + elftc_bfd_find_target.3 elftc_bfd_target_class.3 \ + elftc_bfd_find_target.3 elftc_bfd_target_byteorder.3 \ + elftc_bfd_find_target.3 elftc_bfd_target_flavor.3 \ + elftc_bfd_find_target.3 elftc_bfd_target_machine.3 \ + elftc_string_table_create.3 elftc_string_table_destroy.3 \ + elftc_string_table_create.3 elftc_string_table_from_section.3 \ + elftc_string_table_create.3 elftc_string_table_image.3 \ + elftc_string_table_create.3 elftc_string_table_insert.3 \ + elftc_string_table_create.3 elftc_string_table_lookup.3 \ + elftc_string_table_create.3 elftc_string_table_remove.3 \ + elftc_string_table_create.3 elftc_string_table_to_string.3 + # This same hack is in lib/libelf/Makefile and usr.bin/readelf/Makefile # We need to link against the correct version of these files. One # solution is to include ../../sys in the include path. This causes From owner-svn-src-stable-12@freebsd.org Thu Jun 6 03:01:08 2019 Return-Path: Delivered-To: svn-src-stable-12@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 D47CD15C03B7; Thu, 6 Jun 2019 03:01:07 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6248380BF3; Thu, 6 Jun 2019 03:01:07 +0000 (UTC) (envelope-from markj@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 248BEE5D1; Thu, 6 Jun 2019 03:01:06 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x56316fm056536; Thu, 6 Jun 2019 03:01:06 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x56316Y8056535; Thu, 6 Jun 2019 03:01:06 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906060301.x56316Y8056535@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 6 Jun 2019 03:01:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348716 - stable/12/usr.sbin/rpc.yppasswdd X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/usr.sbin/rpc.yppasswdd X-SVN-Commit-Revision: 348716 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6248380BF3 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.959,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 03:01:08 -0000 Author: markj Date: Thu Jun 6 03:01:05 2019 New Revision: 348716 URL: https://svnweb.freebsd.org/changeset/base/348716 Log: MFC r348547: rpc.yppasswdd: Fix dirname(3) usage after r305952. PR: 234972 Modified: stable/12/usr.sbin/rpc.yppasswdd/yppasswdd_server.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/rpc.yppasswdd/yppasswdd_server.c ============================================================================== --- stable/12/usr.sbin/rpc.yppasswdd/yppasswdd_server.c Thu Jun 6 02:58:11 2019 (r348715) +++ stable/12/usr.sbin/rpc.yppasswdd/yppasswdd_server.c Thu Jun 6 03:01:05 2019 (r348716) @@ -468,7 +468,9 @@ yppasswdproc_update_1_svc(yppasswd *argp, struct svc_r char *cryptpw; char *oldshell = NULL; char *oldgecos = NULL; + char *passdir; char *passfile_hold; + char passdir_buf[MAXPATHLEN + 2]; char passfile_buf[MAXPATHLEN + 2]; char passfile_hold_buf[MAXPATHLEN + 2]; char *domain = yppasswd_domain; @@ -602,11 +604,14 @@ yppasswdproc_update_1_svc(yppasswd *argp, struct svc_r snprintf(passfile_hold_buf, sizeof(passfile_hold_buf), "%s.hold", passfile); passfile_hold = (char *)&passfile_hold_buf; - + /* Step 5: make a new password file with the updated info. */ - if (pw_init(dirname(passfile), passfile)) { + snprintf(passdir_buf, sizeof(passdir_buf), "%s", passfile); + passdir = dirname(passdir_buf); + + if (pw_init(passdir, passfile)) { yp_error("pw_init() failed"); return &result; } @@ -726,7 +731,9 @@ yppasswdproc_update_master_1_svc(master_yppasswd *argp uid_t uid; int rval = 0; DBT key, data; + char *passdir; char *passfile_hold; + char passdir_buf[MAXPATHLEN + 2]; char passfile_buf[MAXPATHLEN + 2]; char passfile_hold_buf[MAXPATHLEN + 2]; struct sockaddr_in *rqhost; @@ -829,7 +836,10 @@ allow additions to be made to the password database"); "%s.hold", passfile); passfile_hold = (char *)&passfile_hold_buf; - if (pw_init(dirname(passfile), passfile)) { + snprintf(passdir_buf, sizeof(passdir_buf), "%s", passfile); + passdir = dirname(passdir_buf); + + if (pw_init(passdir, passfile)) { yp_error("pw_init() failed"); return &result; } From owner-svn-src-stable-12@freebsd.org Thu Jun 6 03:01:55 2019 Return-Path: Delivered-To: svn-src-stable-12@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 ED64415C048B; Thu, 6 Jun 2019 03:01:54 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8581280F6B; Thu, 6 Jun 2019 03:01:54 +0000 (UTC) (envelope-from markj@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 219A8E733; Thu, 6 Jun 2019 03:01:53 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x5631rwq056621; Thu, 6 Jun 2019 03:01:53 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x5631qnn056620; Thu, 6 Jun 2019 03:01:52 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906060301.x5631qnn056620@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 6 Jun 2019 03:01:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348717 - stable/12/contrib/elftoolchain/readelf X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/contrib/elftoolchain/readelf X-SVN-Commit-Revision: 348717 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8581280F6B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.959,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 03:01:55 -0000 Author: markj Date: Thu Jun 6 03:01:52 2019 New Revision: 348717 URL: https://svnweb.freebsd.org/changeset/base/348717 Log: MFC r348443: readelf: Make -t imply -S, for compatibility with GNU binutils. Modified: stable/12/contrib/elftoolchain/readelf/readelf.1 stable/12/contrib/elftoolchain/readelf/readelf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/contrib/elftoolchain/readelf/readelf.1 ============================================================================== --- stable/12/contrib/elftoolchain/readelf/readelf.1 Thu Jun 6 03:01:05 2019 (r348716) +++ stable/12/contrib/elftoolchain/readelf/readelf.1 Thu Jun 6 03:01:52 2019 (r348717) @@ -24,7 +24,7 @@ .\" .\" $Id: readelf.1 3642 2018-10-14 14:24:28Z jkoshy $ .\" -.Dd September 13, 2012 +.Dd May 30, 2019 .Dt READELF 1 .Os .Sh NAME @@ -113,6 +113,8 @@ Print symbol tables. .It Fl t | Fl -section-details Print additional information about sections, such as the flags fields in section headers. +Implies +.Fl S . .It Fl v | Fl -version Prints a version identifier for .Nm Modified: stable/12/contrib/elftoolchain/readelf/readelf.c ============================================================================== --- stable/12/contrib/elftoolchain/readelf/readelf.c Thu Jun 6 03:01:05 2019 (r348716) +++ stable/12/contrib/elftoolchain/readelf/readelf.c Thu Jun 6 03:01:52 2019 (r348717) @@ -7471,7 +7471,7 @@ main(int argc, char **argv) re->options |= RE_S; break; case 't': - re->options |= RE_T; + re->options |= RE_SS | RE_T; break; case 'u': re->options |= RE_U; From owner-svn-src-stable-12@freebsd.org Thu Jun 6 03:02:46 2019 Return-Path: Delivered-To: svn-src-stable-12@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 BE64015C06A6; Thu, 6 Jun 2019 03:02:46 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3538481213; Thu, 6 Jun 2019 03:02:44 +0000 (UTC) (envelope-from markj@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 0D85FE766; Thu, 6 Jun 2019 03:02:44 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x5632h7D057552; Thu, 6 Jun 2019 03:02:43 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x5632hVx057551; Thu, 6 Jun 2019 03:02:43 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906060302.x5632hVx057551@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 6 Jun 2019 03:02:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348719 - stable/12/contrib/elftoolchain/elfcopy X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/contrib/elftoolchain/elfcopy X-SVN-Commit-Revision: 348719 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3538481213 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.959,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 03:02:46 -0000 Author: markj Date: Thu Jun 6 03:02:43 2019 New Revision: 348719 URL: https://svnweb.freebsd.org/changeset/base/348719 Log: MFC r348430: elfcopy: Remove an unneeded memset. Modified: stable/12/contrib/elftoolchain/elfcopy/main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/contrib/elftoolchain/elfcopy/main.c ============================================================================== --- stable/12/contrib/elftoolchain/elfcopy/main.c Thu Jun 6 03:02:25 2019 (r348718) +++ stable/12/contrib/elftoolchain/elfcopy/main.c Thu Jun 6 03:02:43 2019 (r348719) @@ -1565,7 +1565,6 @@ main(int argc, char **argv) ecp = calloc(1, sizeof(*ecp)); if (ecp == NULL) err(EXIT_FAILURE, "calloc failed"); - memset(ecp, 0, sizeof(*ecp)); ecp->itf = ecp->otf = ETF_ELF; ecp->iec = ecp->oec = ELFCLASSNONE; From owner-svn-src-stable-12@freebsd.org Thu Jun 6 03:03:56 2019 Return-Path: Delivered-To: svn-src-stable-12@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 23E8F15C0906; Thu, 6 Jun 2019 03:03:56 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B4A2B81549; Thu, 6 Jun 2019 03:03:55 +0000 (UTC) (envelope-from markj@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 8D3BAE76D; Thu, 6 Jun 2019 03:03:55 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x5633tp4057641; Thu, 6 Jun 2019 03:03:55 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x5633t7r057640; Thu, 6 Jun 2019 03:03:55 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906060303.x5633t7r057640@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 6 Jun 2019 03:03:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348720 - stable/12/contrib/elftoolchain/elfcopy X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/contrib/elftoolchain/elfcopy X-SVN-Commit-Revision: 348720 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B4A2B81549 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.959,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 03:03:56 -0000 Author: markj Date: Thu Jun 6 03:03:54 2019 New Revision: 348720 URL: https://svnweb.freebsd.org/changeset/base/348720 Log: MFC r348431: elfcopy: Optimize for insertions at the end of the section list. PR: 234949 Modified: stable/12/contrib/elftoolchain/elfcopy/elfcopy.h stable/12/contrib/elftoolchain/elfcopy/sections.c Directory Properties: stable/12/ (props changed) Modified: stable/12/contrib/elftoolchain/elfcopy/elfcopy.h ============================================================================== --- stable/12/contrib/elftoolchain/elfcopy/elfcopy.h Thu Jun 6 03:02:43 2019 (r348719) +++ stable/12/contrib/elftoolchain/elfcopy/elfcopy.h Thu Jun 6 03:03:54 2019 (r348720) @@ -138,6 +138,8 @@ struct section { TAILQ_ENTRY(section) sec_list; /* next section */ }; +TAILQ_HEAD(sectionlist, section); + /* Internal data structure for segments. */ struct segment { uint64_t vaddr; /* virtual addr (VMA) */ Modified: stable/12/contrib/elftoolchain/elfcopy/sections.c ============================================================================== --- stable/12/contrib/elftoolchain/elfcopy/sections.c Thu Jun 6 03:02:43 2019 (r348719) +++ stable/12/contrib/elftoolchain/elfcopy/sections.c Thu Jun 6 03:03:54 2019 (r348720) @@ -314,18 +314,18 @@ insert_to_sec_list(struct elfcopy *ecp, struct section { struct section *s; - if (!tail) { + if (tail || TAILQ_EMPTY(&ecp->v_sec) || + TAILQ_LAST(&ecp->v_sec, sectionlist)->off <= sec->off) { + TAILQ_INSERT_TAIL(&ecp->v_sec, sec, sec_list); + } else { TAILQ_FOREACH(s, &ecp->v_sec, sec_list) { if (sec->off < s->off) { TAILQ_INSERT_BEFORE(s, sec, sec_list); - goto inc_nos; + break; } } } - TAILQ_INSERT_TAIL(&ecp->v_sec, sec, sec_list); - -inc_nos: if (sec->pseudo == 0) ecp->nos++; } From owner-svn-src-stable-12@freebsd.org Thu Jun 6 03:04:34 2019 Return-Path: Delivered-To: svn-src-stable-12@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 54CA115C098D; Thu, 6 Jun 2019 03:04:34 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E94FC81683; Thu, 6 Jun 2019 03:04:33 +0000 (UTC) (envelope-from markj@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 C3BD5E76F; Thu, 6 Jun 2019 03:04:33 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x5634XbC057730; Thu, 6 Jun 2019 03:04:33 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x5634XTI057729; Thu, 6 Jun 2019 03:04:33 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906060304.x5634XTI057729@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 6 Jun 2019 03:04:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348721 - stable/12/lib/libutil X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/lib/libutil X-SVN-Commit-Revision: 348721 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E94FC81683 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.959,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 03:04:34 -0000 Author: markj Date: Thu Jun 6 03:04:33 2019 New Revision: 348721 URL: https://svnweb.freebsd.org/changeset/base/348721 Log: MFC r348545: Typo. Modified: stable/12/lib/libutil/pw_util.3 Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libutil/pw_util.3 ============================================================================== --- stable/12/lib/libutil/pw_util.3 Thu Jun 6 03:03:54 2019 (r348720) +++ stable/12/lib/libutil/pw_util.3 Thu Jun 6 03:04:33 2019 (r348721) @@ -58,7 +58,7 @@ .Ft void .Fn pw_fini "void" .Ft int -.Fn pw_init "const char *dir" const char *master" +.Fn pw_init "const char *dir" "const char *master" .Ft void .Fn pw_initpwd "struct passwd *pw" .Ft "char *" From owner-svn-src-stable-12@freebsd.org Thu Jun 6 03:30:22 2019 Return-Path: Delivered-To: svn-src-stable-12@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 5533115C118D; Thu, 6 Jun 2019 03:30:22 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E7B9382548; Thu, 6 Jun 2019 03:30:21 +0000 (UTC) (envelope-from gjb@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 A52E5EB30; Thu, 6 Jun 2019 03:30:21 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x563ULsg069005; Thu, 6 Jun 2019 03:30:21 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x563ULhN069004; Thu, 6 Jun 2019 03:30:21 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201906060330.x563ULhN069004@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Thu, 6 Jun 2019 03:30:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348723 - stable/12 X-SVN-Group: stable-12 X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: stable/12 X-SVN-Commit-Revision: 348723 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E7B9382548 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.968,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 03:30:22 -0000 Author: gjb Date: Thu Jun 6 03:30:21 2019 New Revision: 348723 URL: https://svnweb.freebsd.org/changeset/base/348723 Log: MFC r348438, r348474: r348438: Fix GCE virtual machine startup. r348474: Revert previous commit. Note: no-op to appease the merge tracker Sponsored by: The FreeBSD Foundation Modified: Directory Properties: stable/12/ (props changed) From owner-svn-src-stable-12@freebsd.org Thu Jun 6 03:31:56 2019 Return-Path: Delivered-To: svn-src-stable-12@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 8D4ED15C1327; Thu, 6 Jun 2019 03:31:56 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 321C08288D; Thu, 6 Jun 2019 03:31:56 +0000 (UTC) (envelope-from gjb@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 0BC33ECC0; Thu, 6 Jun 2019 03:31:56 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x563VtIp073638; Thu, 6 Jun 2019 03:31:55 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x563Vtro073637; Thu, 6 Jun 2019 03:31:55 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201906060331.x563Vtro073637@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Thu, 6 Jun 2019 03:31:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348724 - stable/12/release/tools X-SVN-Group: stable-12 X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: stable/12/release/tools X-SVN-Commit-Revision: 348724 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 321C08288D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 03:31:56 -0000 Author: gjb Date: Thu Jun 6 03:31:55 2019 New Revision: 348724 URL: https://svnweb.freebsd.org/changeset/base/348724 Log: MFC r348439: Increase the size of the Vagrant default image size, as the 3GB size is too small to bootstrap the firstboot_pkgs list. While here, add the growfs(8) startup script to /etc/rc.conf, as Vagrant images can be resized by modifying the Vagrantfile. Sponsored by: The FreeBSD Foundation Modified: stable/12/release/tools/vagrant.conf Directory Properties: stable/12/ (props changed) Modified: stable/12/release/tools/vagrant.conf ============================================================================== --- stable/12/release/tools/vagrant.conf Thu Jun 6 03:30:21 2019 (r348723) +++ stable/12/release/tools/vagrant.conf Thu Jun 6 03:31:55 2019 (r348724) @@ -3,12 +3,15 @@ # $FreeBSD$ # +# The default of 3GB is too small for Vagrant, so override the size here. +export VMSIZE=8G + # Packages to install into the image we're creating. This is a deliberately # minimalist set, providing only the packages necessary to bootstrap. export VM_EXTRA_PACKAGES="firstboot-freebsd-update firstboot-pkgs" # Set to a list of third-party software to enable in rc.conf(5). -export VM_RC_LIST="firstboot_freebsd_update firstboot_pkgs" +export VM_RC_LIST="firstboot_freebsd_update firstboot_pkgs growfs" vagrant_common () { # The firstboot_pkgs rc.d script will download the repository From owner-svn-src-stable-12@freebsd.org Thu Jun 6 11:32:40 2019 Return-Path: Delivered-To: svn-src-stable-12@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 177A615AFBCF; Thu, 6 Jun 2019 11:32:40 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id ACC7A681BC; Thu, 6 Jun 2019 11:32:39 +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 8042B1BE0C; Thu, 6 Jun 2019 11:32:39 +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 x56BWdiY024309; Thu, 6 Jun 2019 11:32:39 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x56BWd7w024308; Thu, 6 Jun 2019 11:32:39 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201906061132.x56BWd7w024308@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 6 Jun 2019 11:32:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348731 - stable/12/cddl/contrib/opensolaris/lib/libzpool/common X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/cddl/contrib/opensolaris/lib/libzpool/common X-SVN-Commit-Revision: 348731 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: ACC7A681BC X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 11:32:40 -0000 Author: avg Date: Thu Jun 6 11:32:39 2019 New Revision: 348731 URL: https://svnweb.freebsd.org/changeset/base/348731 Log: MFC r344359: fix userland illumos taskq code to pass relative timeout to cv_timedwait Unlike illumos, FreeBSD cv_timedwait requires a relative timeout. That applies both to the kernel illumos compatibility code and to the userland "fake kernel" code. Sponsored by: Panzura Modified: stable/12/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c Directory Properties: stable/12/ (props changed) Modified: stable/12/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c ============================================================================== --- stable/12/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c Thu Jun 6 08:43:23 2019 (r348730) +++ stable/12/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c Thu Jun 6 11:32:39 2019 (r348731) @@ -79,8 +79,13 @@ again: if ((t = tq->tq_freelist) != NULL && tq->tq_nal * immediately retry the allocation. */ tq->tq_maxalloc_wait++; +#ifdef __FreeBSD__ rv = cv_timedwait(&tq->tq_maxalloc_cv, + &tq->tq_lock, hz); +#else + rv = cv_timedwait(&tq->tq_maxalloc_cv, &tq->tq_lock, ddi_get_lbolt() + hz); +#endif tq->tq_maxalloc_wait--; if (rv > 0) goto again; /* signaled */ From owner-svn-src-stable-12@freebsd.org Thu Jun 6 11:35:24 2019 Return-Path: Delivered-To: svn-src-stable-12@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 D149215AFCBB; Thu, 6 Jun 2019 11:35:24 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 453F368361; Thu, 6 Jun 2019 11:35:24 +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 1E0C61BE12; Thu, 6 Jun 2019 11:35:24 +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 x56BZOkI024556; Thu, 6 Jun 2019 11:35:24 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x56BZN9o024555; Thu, 6 Jun 2019 11:35:23 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201906061135.x56BZN9o024555@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 6 Jun 2019 11:35:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348732 - stable/12/cddl/contrib/opensolaris/cmd/zpool X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/cddl/contrib/opensolaris/cmd/zpool X-SVN-Commit-Revision: 348732 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 453F368361 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 11:35:25 -0000 Author: avg Date: Thu Jun 6 11:35:23 2019 New Revision: 348732 URL: https://svnweb.freebsd.org/changeset/base/348732 Log: MFC r344360: zpool.8: document -D flag for zpool status Modified: stable/12/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Directory Properties: stable/12/ (props changed) Modified: stable/12/cddl/contrib/opensolaris/cmd/zpool/zpool.8 ============================================================================== --- stable/12/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Thu Jun 6 11:32:39 2019 (r348731) +++ stable/12/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Thu Jun 6 11:35:23 2019 (r348732) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 27, 2018 +.Dd February 20, 2019 .Dt ZPOOL 8 .Os .Sh NAME @@ -187,7 +187,7 @@ .Op Ar device ... .Nm .Cm status -.Op Fl vx +.Op Fl Dvx .Op Fl T Cm d Ns | Ns Cm u .Op Ar pool .Ar ... @@ -1862,7 +1862,7 @@ section, above, for more information on the available .It Xo .Nm .Cm status -.Op Fl vx +.Op Fl Dvx .Op Fl T Cm d Ns | Ns Cm u .Op Ar pool .Ar ... @@ -1891,6 +1891,12 @@ done and the estimated time to completion. Both of the because the amount of data in the pool and the other workloads on the system can change. .Bl -tag -width indent +.It Fl D +Display a histogram of deduplication statistics, showing the allocated +.Pq physically present on disk +and referenced +.Pq logically referenced in the pool +block counts and sizes by reference count. .It Fl x Only display status for pools that are exhibiting errors or are otherwise unavailable. From owner-svn-src-stable-12@freebsd.org Thu Jun 6 11:37:00 2019 Return-Path: Delivered-To: svn-src-stable-12@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 E86E215AFD66; Thu, 6 Jun 2019 11:36:59 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8CD59684B5; Thu, 6 Jun 2019 11:36:59 +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 64B961BE14; Thu, 6 Jun 2019 11:36:59 +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 x56Baxl6024682; Thu, 6 Jun 2019 11:36:59 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x56BaxQO024681; Thu, 6 Jun 2019 11:36:59 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201906061136.x56BaxQO024681@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 6 Jun 2019 11:36:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348733 - stable/12/cddl/contrib/opensolaris/cmd/zpool X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/cddl/contrib/opensolaris/cmd/zpool X-SVN-Commit-Revision: 348733 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8CD59684B5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.960,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 11:37:00 -0000 Author: avg Date: Thu Jun 6 11:36:58 2019 New Revision: 348733 URL: https://svnweb.freebsd.org/changeset/base/348733 Log: MFC r344361: zpool.8: sort zpool status flags in the same order as in illumos manual Modified: stable/12/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Directory Properties: stable/12/ (props changed) Modified: stable/12/cddl/contrib/opensolaris/cmd/zpool/zpool.8 ============================================================================== --- stable/12/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Thu Jun 6 11:35:23 2019 (r348732) +++ stable/12/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Thu Jun 6 11:36:58 2019 (r348733) @@ -1897,14 +1897,6 @@ Display a histogram of deduplication statistics, showi and referenced .Pq logically referenced in the pool block counts and sizes by reference count. -.It Fl x -Only display status for pools that are exhibiting errors or are otherwise -unavailable. -Warnings about pools not using the latest on-disk format, having non-native -block size or disabled features will not be included. -.It Fl v -Displays verbose data error information, printing out a complete list of all -data errors since the last complete pool scrub. .It Fl T Cm d Ns | Ns Cm u Print a timestamp. .Pp @@ -1916,6 +1908,14 @@ Use modifier .Cm u for unixtime .Pq equals Qq Ic date +%s . +.It Fl v +Displays verbose data error information, printing out a complete list of all +data errors since the last complete pool scrub. +.It Fl x +Only display status for pools that are exhibiting errors or are otherwise +unavailable. +Warnings about pools not using the latest on-disk format, having non-native +block size or disabled features will not be included. .El .It Xo .Nm From owner-svn-src-stable-12@freebsd.org Thu Jun 6 11:38:54 2019 Return-Path: Delivered-To: svn-src-stable-12@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 20A6815AFE8B; Thu, 6 Jun 2019 11:38:54 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B4607699B6; Thu, 6 Jun 2019 11:38:53 +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 86A521BE16; Thu, 6 Jun 2019 11:38:53 +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 x56BcrVW024825; Thu, 6 Jun 2019 11:38:53 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x56BcrtM024824; Thu, 6 Jun 2019 11:38:53 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201906061138.x56BcrtM024824@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 6 Jun 2019 11:38:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348734 - stable/12/sys/dev/intpm X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/dev/intpm X-SVN-Commit-Revision: 348734 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B4607699B6 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.960,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 11:38:54 -0000 Author: avg Date: Thu Jun 6 11:38:53 2019 New Revision: 348734 URL: https://svnweb.freebsd.org/changeset/base/348734 Log: MFC r345411: intpm: change translation of HBA error status to smbus(4) errors PIIX4_SMBHSTSTAT_ERR can be set for several reasons that, unfortunately, cannot be distinguished, but the most typical case is a missing or hung slave (SMB_ENOACK). PIIX4_SMBHSTSTAT_FAIL means failed or killed / aborted transaction, so it's previous mapping to SMB_ENOACK was not ideal. After this change an smb(4) access to a missing slave results in ENXIO rather than EIO. To me, that seems to be more appropriate. Modified: stable/12/sys/dev/intpm/intpm.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/intpm/intpm.c ============================================================================== --- stable/12/sys/dev/intpm/intpm.c Thu Jun 6 11:36:58 2019 (r348733) +++ stable/12/sys/dev/intpm/intpm.c Thu Jun 6 11:38:53 2019 (r348734) @@ -525,12 +525,19 @@ intsmb_error(device_t dev, int status) { int error = 0; + /* + * PIIX4_SMBHSTSTAT_ERR can mean either of + * - SMB_ENOACK ("Unclaimed cycle"), + * - SMB_ETIMEOUT ("Host device time-out"), + * - SMB_EINVAL ("Illegal command field"). + * SMB_ENOACK seems to be most typical. + */ if (status & PIIX4_SMBHSTSTAT_ERR) - error |= SMB_EBUSERR; + error |= SMB_ENOACK; if (status & PIIX4_SMBHSTSTAT_BUSC) error |= SMB_ECOLLI; if (status & PIIX4_SMBHSTSTAT_FAIL) - error |= SMB_ENOACK; + error |= SMB_EABORT; if (error != 0 && bootverbose) device_printf(dev, "error = %d, status = %#x\n", error, status); From owner-svn-src-stable-12@freebsd.org Thu Jun 6 11:42:27 2019 Return-Path: Delivered-To: svn-src-stable-12@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 9B8F715B00FC; Thu, 6 Jun 2019 11:42:27 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3BCD869E04; Thu, 6 Jun 2019 11:42:27 +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 167771BFC4; Thu, 6 Jun 2019 11:42:27 +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 x56BgQOh029593; Thu, 6 Jun 2019 11:42:26 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x56BgQ5n029592; Thu, 6 Jun 2019 11:42:26 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201906061142.x56BgQ5n029592@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 6 Jun 2019 11:42:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348735 - in stable/12: share/man/man4 sys/dev/gpio X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12: share/man/man4 sys/dev/gpio X-SVN-Commit-Revision: 348735 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3BCD869E04 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.960,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 11:42:28 -0000 Author: avg Date: Thu Jun 6 11:42:26 2019 New Revision: 348735 URL: https://svnweb.freebsd.org/changeset/base/348735 Log: MFC r348153-r348155: gpioled: add a new hint for initial state hint.gpioled.%d.state determines the initial state of the LED when the driver takes control over it: 0 - the LED is off 1 - the LED is on -1 - the LED is kept as it was While here, add a module version declaration. Modified: stable/12/share/man/man4/gpioled.4 stable/12/sys/dev/gpio/gpioled.c Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/gpioled.4 ============================================================================== --- stable/12/share/man/man4/gpioled.4 Thu Jun 6 11:38:53 2019 (r348734) +++ stable/12/share/man/man4/gpioled.4 Thu Jun 6 11:42:26 2019 (r348735) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 30, 2016 +.Dd May 23, 2019 .Dt GPIOLED 4 .Os .Sh NAME @@ -73,6 +73,10 @@ Please note that this mask should only ever have one b (any other bits - i.e., pins - will be ignored). .It Va hint.gpioled.%d.invert If set to 1, the pin will be set to 0 to light the LED, and 1 to clear it. +.It Va hint.gpioled.%d.state +The initial state of the LED when the driver takes control over it. +If set to 1 or 0, the LED will be on or off correspondingly. +If set to -1, the LED will be kept in its original state. .El .Pp On a Modified: stable/12/sys/dev/gpio/gpioled.c ============================================================================== --- stable/12/sys/dev/gpio/gpioled.c Thu Jun 6 11:38:53 2019 (r348734) +++ stable/12/sys/dev/gpio/gpioled.c Thu Jun 6 11:42:26 2019 (r348735) @@ -115,6 +115,8 @@ gpioled_attach(device_t dev) name = NULL; resource_int_value(device_get_name(dev), device_get_unit(dev), "invert", &sc->sc_invert); + resource_int_value(device_get_name(dev), + device_get_unit(dev), "state", &state); sc->sc_leddev = led_create_state(gpioled_control, sc, name ? name : device_get_nameunit(dev), state); @@ -155,3 +157,4 @@ static driver_t gpioled_driver = { DRIVER_MODULE(gpioled, gpiobus, gpioled_driver, gpioled_devclass, 0, 0); MODULE_DEPEND(gpioled, gpiobus, 1, 1, 1); +MODULE_VERSION(gpioled, 1); From owner-svn-src-stable-12@freebsd.org Thu Jun 6 19:40:13 2019 Return-Path: Delivered-To: svn-src-stable-12@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 4058315BE16A; Thu, 6 Jun 2019 19:40:13 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DAE7184A8F; Thu, 6 Jun 2019 19:40:12 +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 B0E57210E8; Thu, 6 Jun 2019 19:40:12 +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 x56JeC1t077394; Thu, 6 Jun 2019 19:40:12 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x56JeCNl077393; Thu, 6 Jun 2019 19:40:12 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201906061940.x56JeCNl077393@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 6 Jun 2019 19:40:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348752 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 348752 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: DAE7184A8F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.995,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 19:40:13 -0000 Author: jhb Date: Thu Jun 6 19:40:12 2019 New Revision: 348752 URL: https://svnweb.freebsd.org/changeset/base/348752 Log: MFC 348543: Warn about deprecated features on all major OS versions. Modified: stable/12/sys/kern/subr_bus.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/subr_bus.c ============================================================================== --- stable/12/sys/kern/subr_bus.c Thu Jun 6 17:20:35 2019 (r348751) +++ stable/12/sys/kern/subr_bus.c Thu Jun 6 19:40:12 2019 (r348752) @@ -5920,7 +5920,7 @@ _gone_in(int major, const char *msg) gone_panic(major, P_OSREL_MAJOR(__FreeBSD_version), msg); if (P_OSREL_MAJOR(__FreeBSD_version) >= major) printf("Obsolete code will removed soon: %s\n", msg); - else if (P_OSREL_MAJOR(__FreeBSD_version) + 1 == major) + else printf("Deprecated code (to be removed in FreeBSD %d): %s\n", major, msg); } @@ -5933,7 +5933,7 @@ _gone_in_dev(device_t dev, int major, const char *msg) if (P_OSREL_MAJOR(__FreeBSD_version) >= major) device_printf(dev, "Obsolete code will removed soon: %s\n", msg); - else if (P_OSREL_MAJOR(__FreeBSD_version) + 1 == major) + else device_printf(dev, "Deprecated code (to be removed in FreeBSD %d): %s\n", major, msg); From owner-svn-src-stable-12@freebsd.org Thu Jun 6 19:48:28 2019 Return-Path: Delivered-To: svn-src-stable-12@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 07E8E15BE52D; Thu, 6 Jun 2019 19:48:28 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A1E5B85189; Thu, 6 Jun 2019 19:48:27 +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 70A322128A; Thu, 6 Jun 2019 19:48:27 +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 x56JmRDr082797; Thu, 6 Jun 2019 19:48:27 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x56JmRt9082796; Thu, 6 Jun 2019 19:48:27 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201906061948.x56JmRt9082796@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 6 Jun 2019 19:48:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348754 - stable/12/share/man/man4 X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/12/share/man/man4 X-SVN-Commit-Revision: 348754 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: A1E5B85189 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.995,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 19:48:28 -0000 Author: jhb Date: Thu Jun 6 19:48:27 2019 New Revision: 348754 URL: https://svnweb.freebsd.org/changeset/base/348754 Log: MFC 346931,346933: Note that ccr(4) now supports AES-CCM. 346931: Note that ccr(4) now supports AES-CCM. 346933: Rewrap some long lines. Whitespace only change. Modified: stable/12/share/man/man4/ccr.4 Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/ccr.4 ============================================================================== --- stable/12/share/man/man4/ccr.4 Thu Jun 6 19:41:05 2019 (r348753) +++ stable/12/share/man/man4/ccr.4 Thu Jun 6 19:48:27 2019 (r348754) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 11, 2019 +.Dd April 29, 2019 .Dt CCR 4 .Os .Sh NAME @@ -34,7 +34,7 @@ To compile this driver into the kernel, place the following lines in your kernel configuration file: -.Bd -ragged -offset indeunt +.Bd -ragged -offset indent .Cd "device ccr" .Ed .Pp @@ -49,9 +49,10 @@ The .Nm driver provides support for the crypto accelerator engine included on PCI Express Ethernet adapters based on the Chelsio Terminator 6 ASIC (T6). -The driver accelerates AES-CBC, AES-CTR, AES-GCM, AES-XTS, SHA1, SHA2-224, -SHA2-256, SHA2-384, SHA2-512, SHA1-HMAC, SHA2-224-HMAC, -SHA2-256-HMAC, SHA2-384-HMAC, and SHA2-512-HMAC operations for +The driver accelerates AES-CBC, AES-CCM, AES-CTR, AES-GCM, AES-XTS, +SHA1, SHA2-224, SHA2-256, SHA2-384, SHA2-512, +SHA1-HMAC, SHA2-224-HMAC, SHA2-256-HMAC, SHA2-384-HMAC, and SHA2-512-HMAC +operations for .Xr crypto 4 and .Xr ipsec 4 . From owner-svn-src-stable-12@freebsd.org Thu Jun 6 20:03:24 2019 Return-Path: Delivered-To: svn-src-stable-12@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 2F20515BEC13; Thu, 6 Jun 2019 20:03:24 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C30C885FAE; Thu, 6 Jun 2019 20:03:23 +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 A033D215D2; Thu, 6 Jun 2019 20:03:23 +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 x56K3NLl093049; Thu, 6 Jun 2019 20:03:23 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x56K3Nl5093048; Thu, 6 Jun 2019 20:03:23 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201906062003.x56K3Nl5093048@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 6 Jun 2019 20:03:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348755 - stable/12/share/man/man4 X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/12/share/man/man4 X-SVN-Commit-Revision: 348755 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C30C885FAE X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.995,0]; NEURAL_HAM_SHORT(-0.97)[-0.973,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2019 20:03:24 -0000 Author: jhb Date: Thu Jun 6 20:03:23 2019 New Revision: 348755 URL: https://svnweb.freebsd.org/changeset/base/348755 Log: MFC 348542: Add 'device cxgbe' explicitly in the synopsis. ccr depends on symbols exported by the cxgbe driver as well as having a runtime dependency. While the runtime depenency was noted in the manpage already, the compile-time dependency wasn't as clear. PR: 238265 Modified: stable/12/share/man/man4/ccr.4 Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/ccr.4 ============================================================================== --- stable/12/share/man/man4/ccr.4 Thu Jun 6 19:48:27 2019 (r348754) +++ stable/12/share/man/man4/ccr.4 Thu Jun 6 20:03:23 2019 (r348755) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 29, 2019 +.Dd June 3, 2019 .Dt CCR 4 .Os .Sh NAME @@ -36,6 +36,7 @@ place the following lines in your kernel configuration file: .Bd -ragged -offset indent .Cd "device ccr" +.Cd "device cxgbe" .Ed .Pp To load the driver as a From owner-svn-src-stable-12@freebsd.org Fri Jun 7 08:21:03 2019 Return-Path: Delivered-To: svn-src-stable-12@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 356EA15CBD77; Fri, 7 Jun 2019 08:21:03 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CF2086A9C2; Fri, 7 Jun 2019 08:21: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 A909E13A8; Fri, 7 Jun 2019 08:21: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 x578L2ke081808; Fri, 7 Jun 2019 08:21:02 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x578L2KU081806; Fri, 7 Jun 2019 08:21:02 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201906070821.x578L2KU081806@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Fri, 7 Jun 2019 08:21:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348773 - stable/12/sbin/ipfw X-SVN-Group: stable-12 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/12/sbin/ipfw X-SVN-Commit-Revision: 348773 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: CF2086A9C2 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.995,0]; NEURAL_HAM_SHORT(-0.95)[-0.954,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jun 2019 08:21:03 -0000 Author: ae Date: Fri Jun 7 08:21:01 2019 New Revision: 348773 URL: https://svnweb.freebsd.org/changeset/base/348773 Log: MFC r348235: Add `missing` and `or-flush` options to "ipfw table create" command to simplify firewall reloading. The `missing` option suppresses EEXIST error code, but does check that existing table has the same parameters as new one. The `or-flush` option implies `missing` option and additionally does flush for table if it is already exist. Submitted by: lev Differential Revision: https://reviews.freebsd.org/D18339 MFC r348301 Remove unused token that was added in r348235. Modified: stable/12/sbin/ipfw/ipfw.8 stable/12/sbin/ipfw/ipfw2.h stable/12/sbin/ipfw/tables.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/ipfw/ipfw.8 ============================================================================== --- stable/12/sbin/ipfw/ipfw.8 Fri Jun 7 06:35:42 2019 (r348772) +++ stable/12/sbin/ipfw/ipfw.8 Fri Jun 7 08:21:01 2019 (r348773) @@ -1,7 +1,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 21, 2019 +.Dd May 24, 2019 .Dt IPFW 8 .Os .Sh NAME @@ -2138,7 +2138,7 @@ The following creation options are supported: .Bl -tag -width indent .It Ar create-options : Ar create-option | create-options .It Ar create-option : Cm type Ar table-type | Cm valtype Ar value-mask | Cm algo Ar algo-desc | -.Cm limit Ar number | Cm locked +.Cm limit Ar number | Cm locked | Cm missing | Cm or-flush .It Cm type Table key type. .It Cm valtype @@ -2149,6 +2149,13 @@ Table algorithm to use (see below). Maximum number of items that may be inserted into table. .It Cm locked Restrict any table modifications. +.It Cm missing +Do not fail if table already exists and has exactly same options as new one. +.It Cm or-flush +Flush existing table with same name instead of returning error. +Implies +.Cm missing +so existing table must be compatible with new one. .El .Pp Some of these options may be modified later via Modified: stable/12/sbin/ipfw/ipfw2.h ============================================================================== --- stable/12/sbin/ipfw/ipfw2.h Fri Jun 7 06:35:42 2019 (r348772) +++ stable/12/sbin/ipfw/ipfw2.h Fri Jun 7 08:21:01 2019 (r348773) @@ -264,6 +264,8 @@ enum tokens { TOK_UNLOCK, TOK_VLIST, TOK_OLIST, + TOK_MISSING, + TOK_ORFLUSH, /* NAT64 tokens */ TOK_NAT64STL, Modified: stable/12/sbin/ipfw/tables.c ============================================================================== --- stable/12/sbin/ipfw/tables.c Fri Jun 7 06:35:42 2019 (r348772) +++ stable/12/sbin/ipfw/tables.c Fri Jun 7 08:21:01 2019 (r348773) @@ -327,6 +327,8 @@ static struct _s_x tablenewcmds[] = { { "algo", TOK_ALGO }, { "limit", TOK_LIMIT }, { "locked", TOK_LOCK }, + { "missing", TOK_MISSING }, + { "or-flush", TOK_ORFLUSH }, { NULL, 0 } }; @@ -389,19 +391,19 @@ table_print_type(char *tbuf, size_t size, uint8_t type * Creates new table * * ipfw table NAME create [ type { addr | iface | number | flow } ] - * [ algo algoname ] + * [ algo algoname ] [missing] [or-flush] */ static void table_create(ipfw_obj_header *oh, int ac, char *av[]) { - ipfw_xtable_info xi; - int error, tcmd, val; + ipfw_xtable_info xi, xie; + int error, missing, orflush, tcmd, val; uint32_t fset, fclear; char *e, *p; char tbuf[128]; + missing = orflush = 0; memset(&xi, 0, sizeof(xi)); - while (ac > 0) { tcmd = get_token(tablenewcmds, *av, "option"); ac--; av++; @@ -457,6 +459,12 @@ table_create(ipfw_obj_header *oh, int ac, char *av[]) case TOK_LOCK: xi.flags |= IPFW_TGFLAGS_LOCKED; break; + case TOK_ORFLUSH: + orflush = 1; + /* FALLTHROUGH */ + case TOK_MISSING: + missing = 1; + break; } } @@ -466,8 +474,28 @@ table_create(ipfw_obj_header *oh, int ac, char *av[]) if (xi.vmask == 0) xi.vmask = IPFW_VTYPE_LEGACY; - if ((error = table_do_create(oh, &xi)) != 0) + error = table_do_create(oh, &xi); + + if (error == 0) + return; + + if (errno != EEXIST || missing == 0) err(EX_OSERR, "Table creation failed"); + + /* Check that existing table is the same we are trying to create */ + if (table_get_info(oh, &xie) != 0) + err(EX_OSERR, "Existing table check failed"); + + if (xi.limit != xie.limit || xi.type != xie.type || + xi.tflags != xie.tflags || xi.vmask != xie.vmask || ( + xi.algoname[0] != '\0' && strcmp(xi.algoname, + xie.algoname) != 0) || xi.flags != xie.flags) + errx(EX_DATAERR, "The existing table is not compatible " + "with one you are creating."); + + /* Flush existing table if instructed to do so */ + if (orflush != 0 && table_flush(oh) != 0) + err(EX_OSERR, "Table flush on creation failed"); } /* From owner-svn-src-stable-12@freebsd.org Fri Jun 7 10:09:44 2019 Return-Path: Delivered-To: svn-src-stable-12@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 4870B15A813C; Fri, 7 Jun 2019 10:09:44 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DA93E6D7F9; Fri, 7 Jun 2019 10:09:43 +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 B76482504; Fri, 7 Jun 2019 10:09:43 +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 x57A9hwS037311; Fri, 7 Jun 2019 10:09:43 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x57A9hVG037310; Fri, 7 Jun 2019 10:09:43 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201906071009.x57A9hVG037310@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 7 Jun 2019 10:09:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348775 - stable/12/sys/amd64/amd64 X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/amd64/amd64 X-SVN-Commit-Revision: 348775 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: DA93E6D7F9 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.995,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.95)[-0.953,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jun 2019 10:09:44 -0000 Author: kib Date: Fri Jun 7 10:09:43 2019 New Revision: 348775 URL: https://svnweb.freebsd.org/changeset/base/348775 Log: MFC r348476, r348630 (by alc): Simplify flow of pmap_demote_pde_locked() and add more comprehensive debugging checks. Modified: stable/12/sys/amd64/amd64/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/pmap.c ============================================================================== --- stable/12/sys/amd64/amd64/pmap.c Fri Jun 7 08:30:35 2019 (r348774) +++ stable/12/sys/amd64/amd64/pmap.c Fri Jun 7 10:09:43 2019 (r348775) @@ -4114,6 +4114,50 @@ pmap_demote_pde(pmap_t pmap, pd_entry_t *pde, vm_offse return (rv); } +static void +pmap_demote_pde_check(pt_entry_t *firstpte __unused, pt_entry_t newpte __unused) +{ +#ifdef INVARIANTS +#ifdef DIAGNOSTIC + pt_entry_t *xpte, *ypte; + + for (xpte = firstpte; xpte < firstpte + NPTEPG; + xpte++, newpte += PAGE_SIZE) { + if ((*xpte & PG_FRAME) != (newpte & PG_FRAME)) { + printf("pmap_demote_pde: xpte %zd and newpte map " + "different pages: found %#lx, expected %#lx\n", + xpte - firstpte, *xpte, newpte); + printf("page table dump\n"); + for (ypte = firstpte; ypte < firstpte + NPTEPG; ypte++) + printf("%zd %#lx\n", ypte - firstpte, *ypte); + panic("firstpte"); + } + } +#else + KASSERT((*firstpte & PG_FRAME) == (newpte & PG_FRAME), + ("pmap_demote_pde: firstpte and newpte map different physical" + " addresses")); +#endif +#endif +} + +static void +pmap_demote_pde_abort(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, + pd_entry_t oldpde, struct rwlock **lockp) +{ + struct spglist free; + vm_offset_t sva; + + SLIST_INIT(&free); + sva = trunc_2mpage(va); + pmap_remove_pde(pmap, pde, sva, &free, lockp); + if ((oldpde & pmap_global_bit(pmap)) == 0) + pmap_invalidate_pde_page(pmap, sva, oldpde); + vm_page_free_pages_toq(&free, true); + CTR2(KTR_PMAP, "pmap_demote_pde: failure for va %#lx in pmap %p", + va, pmap); +} + static boolean_t pmap_demote_pde_locked(pmap_t pmap, pd_entry_t *pde, vm_offset_t va, struct rwlock **lockp) @@ -4123,12 +4167,11 @@ pmap_demote_pde_locked(pmap_t pmap, pd_entry_t *pde, v pt_entry_t PG_A, PG_G, PG_M, PG_PKU_MASK, PG_RW, PG_V; vm_paddr_t mptepa; vm_page_t mpte; - struct spglist free; - vm_offset_t sva; int PG_PTE_CACHE; + bool in_kernel; - PG_G = pmap_global_bit(pmap); PG_A = pmap_accessed_bit(pmap); + PG_G = pmap_global_bit(pmap); PG_M = pmap_modified_bit(pmap); PG_RW = pmap_rw_bit(pmap); PG_V = pmap_valid_bit(pmap); @@ -4136,42 +4179,61 @@ pmap_demote_pde_locked(pmap_t pmap, pd_entry_t *pde, v PG_PKU_MASK = pmap_pku_mask_bit(pmap); PMAP_LOCK_ASSERT(pmap, MA_OWNED); + in_kernel = va >= VM_MAXUSER_ADDRESS; oldpde = *pde; KASSERT((oldpde & (PG_PS | PG_V)) == (PG_PS | PG_V), ("pmap_demote_pde: oldpde is missing PG_PS and/or PG_V")); - if ((oldpde & PG_A) == 0 || (mpte = pmap_remove_pt_page(pmap, va)) == - NULL) { + + /* + * Invalidate the 2MB page mapping and return "failure" if the + * mapping was never accessed. + */ + if ((oldpde & PG_A) == 0) { KASSERT((oldpde & PG_W) == 0, + ("pmap_demote_pde: a wired mapping is missing PG_A")); + pmap_demote_pde_abort(pmap, va, pde, oldpde, lockp); + return (FALSE); + } + + mpte = pmap_remove_pt_page(pmap, va); + if (mpte == NULL) { + KASSERT((oldpde & PG_W) == 0, ("pmap_demote_pde: page table page for a wired mapping" " is missing")); /* - * Invalidate the 2MB page mapping and return "failure" if the - * mapping was never accessed or the allocation of the new - * page table page fails. If the 2MB page mapping belongs to - * the direct map region of the kernel's address space, then - * the page allocation request specifies the highest possible - * priority (VM_ALLOC_INTERRUPT). Otherwise, the priority is - * normal. Page table pages are preallocated for every other - * part of the kernel address space, so the direct map region - * is the only part of the kernel address space that must be - * handled here. + * If the page table page is missing and the mapping + * is for a kernel address, the mapping must belong to + * the direct map. Page table pages are preallocated + * for every other part of the kernel address space, + * so the direct map region is the only part of the + * kernel address space that must be handled here. */ - if ((oldpde & PG_A) == 0 || (mpte = vm_page_alloc(NULL, - pmap_pde_pindex(va), (va >= DMAP_MIN_ADDRESS && va < - DMAP_MAX_ADDRESS ? VM_ALLOC_INTERRUPT : VM_ALLOC_NORMAL) | - VM_ALLOC_NOOBJ | VM_ALLOC_WIRED)) == NULL) { - SLIST_INIT(&free); - sva = trunc_2mpage(va); - pmap_remove_pde(pmap, pde, sva, &free, lockp); - if ((oldpde & PG_G) == 0) - pmap_invalidate_pde_page(pmap, sva, oldpde); - vm_page_free_pages_toq(&free, true); - CTR2(KTR_PMAP, "pmap_demote_pde: failure for va %#lx" - " in pmap %p", va, pmap); + KASSERT(!in_kernel || (va >= DMAP_MIN_ADDRESS && + va < DMAP_MAX_ADDRESS), + ("pmap_demote_pde: No saved mpte for va %#lx", va)); + + /* + * If the 2MB page mapping belongs to the direct map + * region of the kernel's address space, then the page + * allocation request specifies the highest possible + * priority (VM_ALLOC_INTERRUPT). Otherwise, the + * priority is normal. + */ + mpte = vm_page_alloc(NULL, pmap_pde_pindex(va), + (in_kernel ? VM_ALLOC_INTERRUPT : VM_ALLOC_NORMAL) | + VM_ALLOC_NOOBJ | VM_ALLOC_WIRED); + + /* + * If the allocation of the new page table page fails, + * invalidate the 2MB page mapping and return "failure". + */ + if (mpte == NULL) { + pmap_demote_pde_abort(pmap, va, pde, oldpde, lockp); return (FALSE); } - if (va < VM_MAXUSER_ADDRESS) { + + if (!in_kernel) { mpte->wire_count = NPTEPG; pmap_resident_count_inc(pmap, 1); } @@ -4179,8 +4241,6 @@ pmap_demote_pde_locked(pmap_t pmap, pd_entry_t *pde, v mptepa = VM_PAGE_TO_PHYS(mpte); firstpte = (pt_entry_t *)PHYS_TO_DMAP(mptepa); newpde = mptepa | PG_M | PG_A | (oldpde & PG_U) | PG_RW | PG_V; - KASSERT((oldpde & PG_A) != 0, - ("pmap_demote_pde: oldpde is missing PG_A")); KASSERT((oldpde & (PG_M | PG_RW)) != PG_RW, ("pmap_demote_pde: oldpde is missing PG_M")); newpte = oldpde & ~PG_PS; @@ -4193,9 +4253,7 @@ pmap_demote_pde_locked(pmap_t pmap, pd_entry_t *pde, v if ((oldpde & PG_PROMOTED) == 0) pmap_fill_ptp(firstpte, newpte); - KASSERT((*firstpte & PG_FRAME) == (newpte & PG_FRAME), - ("pmap_demote_pde: firstpte and newpte map different physical" - " addresses")); + pmap_demote_pde_check(firstpte, newpte); /* * If the mapping has changed attributes, update the page table @@ -4230,7 +4288,7 @@ pmap_demote_pde_locked(pmap_t pmap, pd_entry_t *pde, v /* * Invalidate a stale recursive mapping of the page table page. */ - if (va >= VM_MAXUSER_ADDRESS) + if (in_kernel) pmap_invalidate_page(pmap, (vm_offset_t)vtopte(va)); /* @@ -4240,8 +4298,8 @@ pmap_demote_pde_locked(pmap_t pmap, pd_entry_t *pde, v pmap_pv_demote_pde(pmap, va, oldpde & PG_PS_FRAME, lockp); atomic_add_long(&pmap_pde_demotions, 1); - CTR2(KTR_PMAP, "pmap_demote_pde: success for va %#lx" - " in pmap %p", va, pmap); + CTR2(KTR_PMAP, "pmap_demote_pde: success for va %#lx in pmap %p", + va, pmap); return (TRUE); } From owner-svn-src-stable-12@freebsd.org Fri Jun 7 17:05:59 2019 Return-Path: Delivered-To: svn-src-stable-12@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 1C7BF15B208E; Fri, 7 Jun 2019 17:05:59 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AF5248238E; Fri, 7 Jun 2019 17:05:58 +0000 (UTC) (envelope-from markj@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 9D07B6F11; Fri, 7 Jun 2019 17:05:58 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x57H5wbk056536; Fri, 7 Jun 2019 17:05:58 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x57H5wZ7056535; Fri, 7 Jun 2019 17:05:58 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201906071705.x57H5wZ7056535@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 7 Jun 2019 17:05:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348780 - stable/12/sys/vm X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/vm X-SVN-Commit-Revision: 348780 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: AF5248238E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.96)[-0.964,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jun 2019 17:05:59 -0000 Author: markj Date: Fri Jun 7 17:05:58 2019 New Revision: 348780 URL: https://svnweb.freebsd.org/changeset/base/348780 Log: MFC r348457: Remove a redundant vm_page_remove() call. Modified: stable/12/sys/vm/vm_page.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/vm/vm_page.c ============================================================================== --- stable/12/sys/vm/vm_page.c Fri Jun 7 15:53:27 2019 (r348779) +++ stable/12/sys/vm/vm_page.c Fri Jun 7 17:05:58 2019 (r348780) @@ -2639,7 +2639,6 @@ retry: } else { m->flags &= ~PG_ZERO; vm_page_dequeue(m); - vm_page_remove(m); if (vm_page_free_prep(m)) SLIST_INSERT_HEAD(&free, m, plinks.s.ss); From owner-svn-src-stable-12@freebsd.org Fri Jun 7 18:01:30 2019 Return-Path: Delivered-To: svn-src-stable-12@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 5431815B3419; Fri, 7 Jun 2019 18:01:30 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EBD6C8438B; Fri, 7 Jun 2019 18:01:29 +0000 (UTC) (envelope-from dim@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 C58CF7907; Fri, 7 Jun 2019 18:01:29 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x57I1TNf087374; Fri, 7 Jun 2019 18:01:29 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x57I1TVM087373; Fri, 7 Jun 2019 18:01:29 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201906071801.x57I1TVM087373@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Fri, 7 Jun 2019 18:01:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348784 - stable/12/lib/msun/tests X-SVN-Group: stable-12 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: stable/12/lib/msun/tests X-SVN-Commit-Revision: 348784 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EBD6C8438B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.943,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jun 2019 18:01:30 -0000 Author: dim Date: Fri Jun 7 18:01:29 2019 New Revision: 348784 URL: https://svnweb.freebsd.org/changeset/base/348784 Log: MFC r348500: Partially revert r271349, which disabled the msun cexp test #4 on i386. Ensure the expected result is stored first in a volatile variable with the desired type. This makes all the tests succeed. Slightly changed from the original pull request, but functionally the same. Obtained from: https://github.com/freebsd/freebsd/pull/401 Submitted by: Moritz Buhl PR: 191676 Modified: stable/12/lib/msun/tests/cexp_test.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/msun/tests/cexp_test.c ============================================================================== --- stable/12/lib/msun/tests/cexp_test.c Fri Jun 7 17:58:59 2019 (r348783) +++ stable/12/lib/msun/tests/cexp_test.c Fri Jun 7 18:01:29 2019 (r348784) @@ -59,13 +59,21 @@ __FBSDID("$FreeBSD$"); * XXX The volatile here is to avoid gcc's bogus constant folding and work * around the lack of support for the FENV_ACCESS pragma. */ -#define test(func, z, result, exceptmask, excepts, checksign) do { \ +#define test_t(type, func, z, result, exceptmask, excepts, checksign) \ +do { \ volatile long double complex _d = z; \ + volatile type complex _r = result; \ assert(feclearexcept(FE_ALL_EXCEPT) == 0); \ - assert(cfpequal_cs((func)(_d), (result), (checksign))); \ + assert(cfpequal_cs((func)(_d), (_r), (checksign))); \ assert(((void)(func), fetestexcept(exceptmask) == (excepts))); \ } while (0) +#define test(func, z, result, exceptmask, excepts, checksign) \ + test_t(double, func, z, result, exceptmask, excepts, checksign) + +#define test_f(func, z, result, exceptmask, excepts, checksign) \ + test_t(float, func, z, result, exceptmask, excepts, checksign) + /* Test within a given tolerance. */ #define test_tol(func, z, result, tol) do { \ volatile long double complex _d = z; \ @@ -76,7 +84,7 @@ __FBSDID("$FreeBSD$"); /* Test all the functions that compute cexp(x). */ #define testall(x, result, exceptmask, excepts, checksign) do { \ test(cexp, x, result, exceptmask, excepts, checksign); \ - test(cexpf, x, result, exceptmask, excepts, checksign); \ + test_f(cexpf, x, result, exceptmask, excepts, checksign); \ } while (0) /* @@ -198,10 +206,10 @@ test_reals(void) test(cexp, CMPLXL(finites[i], -0.0), CMPLXL(exp(finites[i]), -0.0), FE_INVALID | FE_DIVBYZERO, 0, 1); - test(cexpf, CMPLXL(finites[i], 0.0), + test_f(cexpf, CMPLXL(finites[i], 0.0), CMPLXL(expf(finites[i]), 0.0), FE_INVALID | FE_DIVBYZERO, 0, 1); - test(cexpf, CMPLXL(finites[i], -0.0), + test_f(cexpf, CMPLXL(finites[i], -0.0), CMPLXL(expf(finites[i]), -0.0), FE_INVALID | FE_DIVBYZERO, 0, 1); } @@ -220,10 +228,10 @@ test_imaginaries(void) test(cexp, CMPLXL(-0.0, finites[i]), CMPLXL(cos(finites[i]), sin(finites[i])), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); - test(cexpf, CMPLXL(0.0, finites[i]), + test_f(cexpf, CMPLXL(0.0, finites[i]), CMPLXL(cosf(finites[i]), sinf(finites[i])), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); - test(cexpf, CMPLXL(-0.0, finites[i]), + test_f(cexpf, CMPLXL(-0.0, finites[i]), CMPLXL(cosf(finites[i]), sinf(finites[i])), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); } @@ -302,12 +310,8 @@ main(void) test_inf(); printf("ok 3 - cexp inf\n"); -#if defined(__i386__) - printf("not ok 4 - cexp reals # TODO: PR # 191676 fails assertion on i386\n"); -#else test_reals(); printf("ok 4 - cexp reals\n"); -#endif test_imaginaries(); printf("ok 5 - cexp imaginaries\n"); From owner-svn-src-stable-12@freebsd.org Fri Jun 7 22:24:59 2019 Return-Path: Delivered-To: svn-src-stable-12@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 477FD15B8778; Fri, 7 Jun 2019 22:24:59 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D3EF48C280; Fri, 7 Jun 2019 22:24:58 +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 5FC74A64E; Fri, 7 Jun 2019 22:24:58 +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 x57MOw2f024644; Fri, 7 Jun 2019 22:24:58 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x57MOwlb024643; Fri, 7 Jun 2019 22:24:58 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201906072224.x57MOwlb024643@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Fri, 7 Jun 2019 22:24:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348792 - stable/12/sys/geom/nop X-SVN-Group: stable-12 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: stable/12/sys/geom/nop X-SVN-Commit-Revision: 348792 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D3EF48C280 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.95)[-0.952,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jun 2019 22:24:59 -0000 Author: mckusick Date: Fri Jun 7 22:24:57 2019 New Revision: 348792 URL: https://svnweb.freebsd.org/changeset/base/348792 Log: MFC of 348259 Proper draining of GEOM nop forced shutdown. Modified: stable/12/sys/geom/nop/g_nop.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/geom/nop/g_nop.c ============================================================================== --- stable/12/sys/geom/nop/g_nop.c Fri Jun 7 21:30:11 2019 (r348791) +++ stable/12/sys/geom/nop/g_nop.c Fri Jun 7 22:24:57 2019 (r348792) @@ -54,17 +54,26 @@ static int g_nop_destroy_geom(struct gctl_req *req, st struct g_geom *gp); static void g_nop_config(struct gctl_req *req, struct g_class *mp, const char *verb); -static void g_nop_dumpconf(struct sbuf *sb, const char *indent, - struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp); +static g_access_t g_nop_access; +static g_dumpconf_t g_nop_dumpconf; +static g_orphan_t g_nop_orphan; +static g_provgone_t g_nop_providergone; +static g_resize_t g_nop_resize; +static g_start_t g_nop_start; struct g_class g_nop_class = { .name = G_NOP_CLASS_NAME, .version = G_VERSION, .ctlreq = g_nop_config, - .destroy_geom = g_nop_destroy_geom + .destroy_geom = g_nop_destroy_geom, + .access = g_nop_access, + .dumpconf = g_nop_dumpconf, + .orphan = g_nop_orphan, + .providergone = g_nop_providergone, + .resize = g_nop_resize, + .start = g_nop_start, }; - static void g_nop_orphan(struct g_consumer *cp) { @@ -277,11 +286,6 @@ g_nop_create(struct gctl_req *req, struct g_class *mp, sc->sc_wrotebytes = 0; mtx_init(&sc->sc_lock, "gnop lock", NULL, MTX_DEF); gp->softc = sc; - gp->start = g_nop_start; - gp->orphan = g_nop_orphan; - gp->resize = g_nop_resize; - gp->access = g_nop_access; - gp->dumpconf = g_nop_dumpconf; newpp = g_new_providerf(gp, "%s", gp->name); newpp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE; @@ -314,6 +318,18 @@ fail: return (error); } +static void +g_nop_providergone(struct g_provider *pp) +{ + struct g_geom *gp = pp->geom; + struct g_nop_softc *sc = gp->softc; + + gp->softc = NULL; + free(sc->sc_physpath, M_GEOM); + mtx_destroy(&sc->sc_lock); + g_free(sc); +} + static int g_nop_destroy(struct g_geom *gp, boolean_t force) { @@ -324,7 +340,6 @@ g_nop_destroy(struct g_geom *gp, boolean_t force) sc = gp->softc; if (sc == NULL) return (ENXIO); - free(sc->sc_physpath, M_GEOM); pp = LIST_FIRST(&gp->provider); if (pp != NULL && (pp->acr != 0 || pp->acw != 0 || pp->ace != 0)) { if (force) { @@ -338,9 +353,6 @@ g_nop_destroy(struct g_geom *gp, boolean_t force) } else { G_NOP_DEBUG(0, "Device %s removed.", gp->name); } - gp->softc = NULL; - mtx_destroy(&sc->sc_lock); - g_free(sc); g_wither_geom(gp, ENXIO); return (0); From owner-svn-src-stable-12@freebsd.org Sat Jun 8 02:30:17 2019 Return-Path: Delivered-To: svn-src-stable-12@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 C187215BEBE0; Sat, 8 Jun 2019 02:30:17 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 576F26DF03; Sat, 8 Jun 2019 02:30:17 +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 2B88FD0A3; Sat, 8 Jun 2019 02:30:17 +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 x582UGG7055136; Sat, 8 Jun 2019 02:30:16 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x582UGoY055134; Sat, 8 Jun 2019 02:30:16 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201906080230.x582UGoY055134@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 8 Jun 2019 02:30:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r348793 - stable/12/share/man/man4 X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/share/man/man4 X-SVN-Commit-Revision: 348793 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 576F26DF03 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.962,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Jun 2019 02:30:18 -0000 Author: mav Date: Sat Jun 8 02:30:16 2019 New Revision: 348793 URL: https://svnweb.freebsd.org/changeset/base/348793 Log: MFC r348496: Document max_chains bump to 16384 at r330049. Modified: stable/12/share/man/man4/mpr.4 stable/12/share/man/man4/mps.4 Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/mpr.4 ============================================================================== --- stable/12/share/man/man4/mpr.4 Fri Jun 7 22:24:57 2019 (r348792) +++ stable/12/share/man/man4/mpr.4 Sat Jun 8 02:30:16 2019 (r348793) @@ -38,7 +38,7 @@ .\" $Id$ .\" $FreeBSD$ .\" -.Dd May 25, 2017 +.Dd June 1, 2019 .Dt MPR 4 .Os .Sh NAME @@ -149,7 +149,7 @@ set this tunable in dev.mpr.X.max_chains=NNNN .Ed .Pp -The default max_chains value is 2048. +The default max_chains value is 16384. .Pp The current number of free chain frames is stored in the dev.mpr.X.chain_free Modified: stable/12/share/man/man4/mps.4 ============================================================================== --- stable/12/share/man/man4/mps.4 Fri Jun 7 22:24:57 2019 (r348792) +++ stable/12/share/man/man4/mps.4 Sat Jun 8 02:30:16 2019 (r348793) @@ -38,7 +38,7 @@ .\" $Id: //depot/SpectraBSD/head/share/man/man4/mps.4#6 $ .\" $FreeBSD$ .\" -.Dd May 25, 2017 +.Dd June 1, 2019 .Dt MPS 4 .Os .Sh NAME @@ -143,7 +143,7 @@ set this tunable in dev.mps.X.max_chains=NNNN .Ed .Pp -The default max_chains value is 2048. +The default max_chains value is 16384. .Pp The current number of free chain frames is stored in the dev.mps.X.chain_free