From owner-svn-src-stable-12@freebsd.org Sun May 3 03:21:44 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 174462D1416; Sun, 3 May 2020 03:21:44 +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 49FB9M4s7Xz47Ns; Sun, 3 May 2020 03:21:43 +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 A10DA48B9; Sun, 3 May 2020 03:21:43 +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 0433LhmL016605; Sun, 3 May 2020 03:21:43 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0433LhXU016604; Sun, 3 May 2020 03:21:43 GMT (envelope-from cy@FreeBSD.org) Message-Id: <202005030321.0433LhXU016604@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 3 May 2020 03:21: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: r360591 - in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Group: stable-12 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/sys/contrib/ipfilter/netinet 12/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 360591 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 03 May 2020 03:21:44 -0000 Author: cy Date: Sun May 3 03:21:42 2020 New Revision: 360591 URL: https://svnweb.freebsd.org/changeset/base/360591 Log: MFC r360100: fib4_free_nh_ext is an empty function. It does nothing. Don't call it. Modified: stable/12/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c ============================================================================== --- stable/12/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Sun May 3 03:09:35 2020 (r360590) +++ stable/12/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Sun May 3 03:21:42 2020 (r360591) @@ -710,7 +710,6 @@ ipf_fastroute(m0, mpp, fin, fdp) struct ifnet *ifp, *sifp; struct sockaddr_in dst; struct nhop4_extended nh4; - int has_nhop = 0; u_long fibnum = 0; u_short ip_off; frdest_t node; @@ -793,7 +792,6 @@ ipf_fastroute(m0, mpp, fin, fdp) goto bad; } - has_nhop = 1; if (ifp == NULL) ifp = nh4.nh_ifp; if (nh4.nh_flags & NHF_GATEWAY) @@ -936,9 +934,6 @@ done: V_ipfmain.ipf_frouteok[0]++; else V_ipfmain.ipf_frouteok[1]++; - - if (has_nhop) - fib4_free_nh_ext(fibnum, &nh4); return 0; bad: From owner-svn-src-stable-12@freebsd.org Sun May 3 03:44:59 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AC8A62D2136; Sun, 3 May 2020 03:44:59 +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 49FBhC453pz499b; Sun, 3 May 2020 03:44:59 +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 878754D2F; Sun, 3 May 2020 03:44:59 +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 0433ixVj030987; Sun, 3 May 2020 03:44:59 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0433ixM2030985; Sun, 3 May 2020 03:44:59 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202005030344.0433ixM2030985@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 3 May 2020 03:44: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: r360595 - in stable/12/usr.bin/diff: . tests X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/usr.bin/diff: . tests X-SVN-Commit-Revision: 360595 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 03 May 2020 03:44:59 -0000 Author: kevans Date: Sun May 3 03:44:58 2020 New Revision: 360595 URL: https://svnweb.freebsd.org/changeset/base/360595 Log: MFC r360437: diff(1): don't reject specifying the same format multiple times This may happen, for instance, if one happens to have an alias of diff to diff -up and attempts to specify the amount of context on top of that. Aliases like this may cause other problems, but if they're really not ever generating non-unified diffs then we should at least not break that use-case. In addition, we'll now pick up a format mismatch if -p is specified with !contextual && !unified && !unset. Fix up a small trailing whitespace nit in the tests while we're here, and add tests to make sure that we can double up all the formatting options. Modified: stable/12/usr.bin/diff/diff.c stable/12/usr.bin/diff/tests/diff_test.sh Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/diff/diff.c ============================================================================== --- stable/12/usr.bin/diff/diff.c Sun May 3 03:44:16 2020 (r360594) +++ stable/12/usr.bin/diff/diff.c Sun May 3 03:44:58 2020 (r360595) @@ -122,6 +122,8 @@ main(int argc, char **argv) newarg = 1; diff_context = 3; diff_format = D_UNSET; +#define FORMAT_MISMATCHED(type) \ + (diff_format != D_UNSET && diff_format != (type)) while ((ch = getopt_long(argc, argv, OPTIONS, longopts, NULL)) != -1) { switch (ch) { case '0': case '1': case '2': case '3': case '4': @@ -142,7 +144,7 @@ main(int argc, char **argv) break; case 'C': case 'c': - if (diff_format != D_UNSET) + if (FORMAT_MISMATCHED(D_CONTEXT)) conflicting_format(); cflag = 1; diff_format = D_CONTEXT; @@ -157,18 +159,18 @@ main(int argc, char **argv) dflags |= D_MINIMAL; break; case 'D': - if (diff_format != D_UNSET) + if (FORMAT_MISMATCHED(D_IFDEF)) conflicting_format(); diff_format = D_IFDEF; ifdefname = optarg; break; case 'e': - if (diff_format != D_UNSET) + if (FORMAT_MISMATCHED(D_EDIT)) conflicting_format(); diff_format = D_EDIT; break; case 'f': - if (diff_format != D_UNSET) + if (FORMAT_MISMATCHED(D_REVERSE)) conflicting_format(); diff_format = D_REVERSE; break; @@ -202,11 +204,20 @@ main(int argc, char **argv) Nflag = 1; break; case 'n': - if (diff_format != D_UNSET) + if (FORMAT_MISMATCHED(D_NREVERSE)) conflicting_format(); diff_format = D_NREVERSE; break; case 'p': + /* + * If it's not unset and it's not set to context or + * unified, we'll error out here as a conflicting + * format. If it's unset, we'll go ahead and set it to + * context. + */ + if (FORMAT_MISMATCHED(D_CONTEXT) && + FORMAT_MISMATCHED(D_UNIFIED)) + conflicting_format(); if (diff_format == D_UNSET) diff_format = D_CONTEXT; dflags |= D_PROTOTYPE; @@ -218,7 +229,7 @@ main(int argc, char **argv) rflag = 1; break; case 'q': - if (diff_format != D_UNSET) + if (FORMAT_MISMATCHED(D_BRIEF)) conflicting_format(); diff_format = D_BRIEF; break; @@ -236,7 +247,7 @@ main(int argc, char **argv) break; case 'U': case 'u': - if (diff_format != D_UNSET) + if (FORMAT_MISMATCHED(D_UNIFIED)) conflicting_format(); diff_format = D_UNIFIED; if (optarg != NULL) { @@ -264,12 +275,12 @@ main(int argc, char **argv) push_excludes(optarg); break; case 'y': - if (diff_format != D_UNSET) + if (FORMAT_MISMATCHED(D_SIDEBYSIDE)) conflicting_format(); diff_format = D_SIDEBYSIDE; break; case OPT_CHANGED_GROUP_FORMAT: - if (diff_format != D_UNSET) + if (FORMAT_MISMATCHED(D_GFORMAT)) conflicting_format(); diff_format = D_GFORMAT; group_format = optarg; @@ -283,7 +294,7 @@ main(int argc, char **argv) ignore_file_case = 0; break; case OPT_NORMAL: - if (diff_format != D_UNSET) + if (FORMAT_MISMATCHED(D_NORMAL)) conflicting_format(); diff_format = D_NORMAL; break; Modified: stable/12/usr.bin/diff/tests/diff_test.sh ============================================================================== --- stable/12/usr.bin/diff/tests/diff_test.sh Sun May 3 03:44:16 2020 (r360594) +++ stable/12/usr.bin/diff/tests/diff_test.sh Sun May 3 03:44:58 2020 (r360595) @@ -186,6 +186,13 @@ conflicting_format_body() atf_check -s exit:2 -e ignore diff -q -c A B atf_check -s exit:2 -e ignore diff --normal -c A B atf_check -s exit:2 -e ignore diff -c --normal A B + + atf_check -s exit:1 -o ignore -e ignore diff -u -u A B + atf_check -s exit:1 -o ignore -e ignore diff -e -e A B + atf_check -s exit:1 -o ignore -e ignore diff -y -y A B + atf_check -s exit:1 -o ignore -e ignore diff -q -q A B + atf_check -s exit:1 -o ignore -e ignore diff -c -c A B + atf_check -s exit:1 -o ignore -e ignore diff --normal --normal A B } atf_init_test_cases() @@ -201,5 +208,5 @@ atf_init_test_cases() atf_add_test_case b230049 atf_add_test_case Bflag atf_add_test_case tabsize - atf_add_test_case conflicting_format + atf_add_test_case conflicting_format } From owner-svn-src-stable-12@freebsd.org Sun May 3 03:53:41 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2F9C32D24BA; Sun, 3 May 2020 03:53:41 +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 49FBtD673Bz49h8; Sun, 3 May 2020 03:53:40 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7F3314F17; Sun, 3 May 2020 03:53:40 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0433remw037041; Sun, 3 May 2020 03:53:40 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0433rdem037037; Sun, 3 May 2020 03:53:39 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202005030353.0433rdem037037@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 3 May 2020 03:53: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: r360596 - in stable: 11/stand/defaults 11/stand/lua 12/stand/defaults 12/stand/lua X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/stand/defaults 11/stand/lua 12/stand/defaults 12/stand/lua X-SVN-Commit-Revision: 360596 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 03 May 2020 03:53:41 -0000 Author: kevans Date: Sun May 3 03:53:38 2020 New Revision: 360596 URL: https://svnweb.freebsd.org/changeset/base/360596 Log: MFC lualoader read-conf support: r360420-r360423, r360425, r360427, r360486, \r360505-r360506 r360420: lualoader config: don't call loader.getenv() as much We don't actually need to fetch loader_conf_files as much as we do; we've already fetched it once at the beginning, we only really need to fetch it again after each file we've processed. If it changes, then we can stash that off into our local prefiles. While here, drop a note about the recursion so that I stop trying to change it. It may very well make redundant some of the work we're doing, but that's OK. r360421: lualoader: config: start exporting readConfFiles In the process, change it slightly: readConfFiles will take a string like loader_conf_files in addition to the loaded_files table that it normally takes. This is to facilitate the addition of a read-conf CLI command, which will just pass in the single file to read and an empty table. r360422: lualoader: cli: add read-conf This is a straightforward match to the command used by many in forthloader; it uses the newly-exported config.readConfFiles() to make sure that any loader_conf_files gets done as appropriate. r360423: lualoader: cli: clobber loader_conf_files before proceeding This makes sure that config.readConfFiles doesn't see a stale loader_conf_files from before, in case the newly loaded file doesn't set it. r360425: config.lua(8): "may should" is not proper grammar r360427: config.lua(8): catch up to recently added hooks While we're here, let's stylize these as functions instead of just raw text. A future change may allow arbitrary data arguments to be passed some of these, and the distinction is useful. r360486: loader.conf(5): document that loader_conf_files may be clobbered A future change in lualoader may take some liberties with the loader_conf_files in the name of efficiency; namely, it may start omitting it from the loader environment entirely so that it doesn't need to worry about maintaining any specific value. This variable has historically been incredibly volatile anyways, as it may get set to completely different values in any given configuration file to trigger a load of more files. Document now that we may not maintain it in the future, but perhaps we'll reserve the right to change our minds and eventually formally export all of the loader configuration files that were read using this variable. r360505: lualoader: config: add a table for restricted environment vars This new table should be used for transient values that don't need to end up in the loader environment. Generally, these will be things that are internal details that really aren't needed or interesting outside of the config module (e.g. if we changed how ${module}_* directives work, they might use this instead). To start, populate it with loader_conf_files. Any specific value of loader_conf_files isn't all that interesting; if we're going to export it, we should really instead export a loader_conf_files that indicates all of the configuration files we processed. This will be used to reduce bookkeeping overhead in a future commit that cleans up readConfFiles. r360506: lualoader: config: improve readConfFiles, rename to readConf The previous interface was pretty bad, and required the caller to get some implementation details correct that it really shouldn't need to (e.g. loader_conf_files handling) and pass in an empty table for it to use. The new and much improved interface, readConf, is much less of a hack; hiding these implementation details and just doing the right thing. config.lua will now use it to process /boot/defaults/loader.conf and the subsequent loader_conf_files from there, and read-conf will also use it. This improvement submitted by Olivier (cited below), loader_conf_files handling from the original patch was changed to just clobber it before processing and not bother restoring it after the fact following r360505 where it's now guaranteed to evade the loader environment. PR: 244640 Modified: stable/12/stand/defaults/loader.conf.5 stable/12/stand/lua/cli.lua stable/12/stand/lua/config.lua stable/12/stand/lua/config.lua.8 Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/stand/defaults/loader.conf.5 stable/11/stand/lua/cli.lua stable/11/stand/lua/config.lua stable/11/stand/lua/config.lua.8 Directory Properties: stable/11/ (props changed) Modified: stable/12/stand/defaults/loader.conf.5 ============================================================================== --- stable/12/stand/defaults/loader.conf.5 Sun May 3 03:44:58 2020 (r360595) +++ stable/12/stand/defaults/loader.conf.5 Sun May 3 03:53:38 2020 (r360596) @@ -23,7 +23,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd October 6, 2018 +.Dd April 29, 2020 .Dt LOADER.CONF 5 .Os .Sh NAME @@ -91,6 +91,10 @@ independently. .It Ar loader_conf_files Defines additional configuration files to be processed right after the present file. +.Ar loader_conf_files +should be treated as write-only. +One cannot depend on any value remaining in the loader environment or carried +over into the kernel environment. .It Ar kernel Name of the kernel to be loaded. If no kernel name is set, no additional Modified: stable/12/stand/lua/cli.lua ============================================================================== --- stable/12/stand/lua/cli.lua Sun May 3 03:44:58 2020 (r360595) +++ stable/12/stand/lua/cli.lua Sun May 3 03:53:38 2020 (r360596) @@ -125,6 +125,11 @@ cli['boot-conf'] = function(...) core.autoboot(argstr) end +cli['read-conf'] = function(...) + local _, argv = cli.arguments(...) + config.readConf(assert(core.popFrontTable(argv))) +end + cli['reload-conf'] = function(...) config.reload() end Modified: stable/12/stand/lua/config.lua ============================================================================== --- stable/12/stand/lua/config.lua Sun May 3 03:44:58 2020 (r360595) +++ stable/12/stand/lua/config.lua Sun May 3 03:53:38 2020 (r360596) @@ -61,6 +61,17 @@ local QVALREPL = QVALEXPR:gsub('%%', '%%%%') local WORDEXPR = "([%w]+)" local WORDREPL = WORDEXPR:gsub('%%', '%%%%') +-- Entries that should never make it into the environment; each one should have +-- a documented reason for its existence, and these should all be implementation +-- details of the config module. +local loader_env_restricted_table = { + -- loader_conf_files should be considered write-only, and consumers + -- should not rely on any particular value; it's a loader implementation + -- detail. Moreover, it's not a particularly useful variable to have in + -- the kenv. Save the overhead, let it get fetched other ways. + loader_conf_files = true, +} + local function restoreEnv() -- Examine changed environment variables for k, v in pairs(env_changed) do @@ -88,14 +99,31 @@ local function restoreEnv() env_restore = {} end +-- XXX This getEnv/setEnv should likely be exported at some point. We can save +-- the call back into loader.getenv for any variable that's been set or +-- overridden by any loader.conf using this implementation with little overhead +-- since we're already tracking the values. +local function getEnv(key) + if loader_env_restricted_table[key] ~= nil or + env_changed[key] ~= nil then + return env_changed[key] + end + + return loader.getenv(key) +end + local function setEnv(key, value) + env_changed[key] = value + + if loader_env_restricted_table[key] ~= nil then + return 0 + end + -- Track the original value for this if we haven't already if env_restore[key] == nil then env_restore[key] = {value = loader.getenv(key)} end - env_changed[key] = value - return loader.setenv(key, value) end @@ -340,34 +368,6 @@ local function loadModule(mod, silent) return status end -local function readConfFiles(loaded_files) - local f = loader.getenv("loader_conf_files") - if f ~= nil then - for name in f:gmatch("([%w%p]+)%s*") do - if loaded_files[name] ~= nil then - goto continue - end - - local prefiles = loader.getenv("loader_conf_files") - - print("Loading " .. name) - -- These may or may not exist, and that's ok. Do a - -- silent parse so that we complain on parse errors but - -- not for them simply not existing. - if not config.processFile(name, true) then - print(MSG_FAILPARSECFG:format(name)) - end - - loaded_files[name] = true - local newfiles = loader.getenv("loader_conf_files") - if prefiles ~= newfiles then - readConfFiles(loaded_files) - end - ::continue:: - end - end -end - local function readFile(name, silent) local f = io.open(name) if f == nil then @@ -488,6 +488,40 @@ function config.parse(text) return status end +function config.readConf(file, loaded_files) + if loaded_files == nil then + loaded_files = {} + end + + if loaded_files[file] ~= nil then + return + end + + print("Loading " .. file) + + -- The final value of loader_conf_files is not important, so just + -- clobber it here. We'll later check if it's no longer nil and process + -- the new value for files to read. + setEnv("loader_conf_files", nil) + + -- These may or may not exist, and that's ok. Do a + -- silent parse so that we complain on parse errors but + -- not for them simply not existing. + if not config.processFile(file, true) then + print(MSG_FAILPARSECFG:format(file)) + end + + loaded_files[file] = true + + -- Going to process "loader_conf_files" extra-files + local loader_conf_files = getEnv("loader_conf_files") + if loader_conf_files ~= nil then + for name in loader_conf_files:gmatch("[%w%p]+") do + config.readConf(name, loaded_files) + end + end +end + -- other_kernel is optionally the name of a kernel to load, if not the default -- or autoloaded default from the module_path function config.loadKernel(other_kernel) @@ -596,12 +630,7 @@ function config.load(file, reloading) file = "/boot/defaults/loader.conf" end - if not config.processFile(file) then - print(MSG_FAILPARSECFG:format(file)) - end - - local loaded_files = {file = true} - readConfFiles(loaded_files) + config.readConf(file) checkNextboot() Modified: stable/12/stand/lua/config.lua.8 ============================================================================== --- stable/12/stand/lua/config.lua.8 Sun May 3 03:44:58 2020 (r360595) +++ stable/12/stand/lua/config.lua.8 Sun May 3 03:53:38 2020 (r360596) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 9, 2018 +.Dd April 30, 2020 .Dt CONFIG.LUA 8 .Os .Sh NAME @@ -59,6 +59,24 @@ to A lookup will be done as needed to determine what value .Ev idx actually corresponds to. +.It Fn config.readConf file loaded_files +Process +.Pa file +as a configuration file +.Po e.g., as +.Pa loader.conf +.Pc +and then processing files listed in +.Ev loader_conf_files +variable +.Po see +.Xr loader.conf 5 +.Pc . +The caller may optionally pass in a table as the +.Ev loaded_files +argument, which uses filenames as keys and any non-nil value to +indicate that the file named by the key has already been loaded and +should not be loaded again. .It Fn config.processFile name silent Process and parse .Ev name @@ -171,8 +189,10 @@ commands. The following hooks are defined in .Nm : .Bl -tag -width "config.reloaded" -offset indent -.It config.loaded -.It config.reloaded +.It Fn config.loaded +.It Fn config.reloaded +.It Fn kernel.loaded +.It Fn modules.loaded .El .Sh SEE ALSO .Xr loader.conf 5 , From owner-svn-src-stable-12@freebsd.org Sun May 3 08:13:45 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1DAB32D7830; Sun, 3 May 2020 08:13:45 +0000 (UTC) (envelope-from freqlabs@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 49FJfJ6pJhz4PRj; Sun, 3 May 2020 08:13:44 +0000 (UTC) (envelope-from freqlabs@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 E452B7FE1; Sun, 3 May 2020 08:13:44 +0000 (UTC) (envelope-from freqlabs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0438Dix8097851; Sun, 3 May 2020 08:13:44 GMT (envelope-from freqlabs@FreeBSD.org) Received: (from freqlabs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0438Di4l097850; Sun, 3 May 2020 08:13:44 GMT (envelope-from freqlabs@FreeBSD.org) Message-Id: <202005030813.0438Di4l097850@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: freqlabs set sender to freqlabs@FreeBSD.org using -f From: Ryan Moeller Date: Sun, 3 May 2020 08:13:44 +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: r360601 - stable/12/usr.bin/sockstat X-SVN-Group: stable-12 X-SVN-Commit-Author: freqlabs X-SVN-Commit-Paths: stable/12/usr.bin/sockstat X-SVN-Commit-Revision: 360601 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 03 May 2020 08:13:45 -0000 Author: freqlabs Date: Sun May 3 08:13:44 2020 New Revision: 360601 URL: https://svnweb.freebsd.org/changeset/base/360601 Log: MFC r360356: sockstat: Attach to jail if in new vnet Attach sockstat -j to the specified jail if the jail is in a new vnet. Otherwise we do not see all sockets belonging to the jail. Reviewed by: jamie Approved by: mmacy (mentor) Differential Revision: https://reviews.freebsd.org/D24413 Modified: stable/12/usr.bin/sockstat/sockstat.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/sockstat/sockstat.c ============================================================================== --- stable/12/usr.bin/sockstat/sockstat.c Sun May 3 04:22:27 2020 (r360600) +++ stable/12/usr.bin/sockstat/sockstat.c Sun May 3 08:13:44 2020 (r360601) @@ -32,10 +32,11 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include -#include +#include #include #include @@ -1218,7 +1219,8 @@ display(void) } } -static int set_default_protos(void) +static int +set_default_protos(void) { struct protoent *prot; const char *pname; @@ -1237,6 +1239,38 @@ static int set_default_protos(void) return (pindex); } +/* + * Return the vnet property of the jail, or -1 on error. + */ +static int +jail_getvnet(int jid) +{ + struct iovec jiov[6]; + int vnet; + + vnet = -1; + jiov[0].iov_base = __DECONST(char *, "jid"); + jiov[0].iov_len = sizeof("jid"); + jiov[1].iov_base = &jid; + jiov[1].iov_len = sizeof(jid); + jiov[2].iov_base = __DECONST(char *, "vnet"); + jiov[2].iov_len = sizeof("vnet"); + jiov[3].iov_base = &vnet; + jiov[3].iov_len = sizeof(vnet); + jiov[4].iov_base = __DECONST(char *, "errmsg"); + jiov[4].iov_len = sizeof("errmsg"); + jiov[5].iov_base = jail_errmsg; + jiov[5].iov_len = JAIL_ERRMSGLEN; + jail_errmsg[0] = '\0'; + if (jail_get(jiov, nitems(jiov), 0) < 0) { + if (!jail_errmsg[0]) + snprintf(jail_errmsg, JAIL_ERRMSGLEN, + "jail_get: %s", strerror(errno)); + return (-1); + } + return (vnet); +} + static void usage(void) { @@ -1310,6 +1344,21 @@ main(int argc, char *argv[]) if (argc > 0) usage(); + + if (opt_j > 0) { + switch (jail_getvnet(opt_j)) { + case -1: + errx(2, "%s", jail_errmsg); + case JAIL_SYS_NEW: + if (jail_attach(opt_j) < 0) + errx(3, "%s", jail_errmsg); + /* Set back to -1 for normal output in vnet jail. */ + opt_j = -1; + break; + default: + break; + } + } if ((!opt_4 && !opt_6) && protos_defined != -1) opt_4 = opt_6 = 1; From owner-svn-src-stable-12@freebsd.org Sun May 3 16:06:18 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 78FBA2E17C0; Sun, 3 May 2020 16:06:18 +0000 (UTC) (envelope-from kp@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 49FW7Z2c1cz3NLL; Sun, 3 May 2020 16:06:18 +0000 (UTC) (envelope-from kp@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 54657DA11; Sun, 3 May 2020 16:06:18 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 043G6IBJ089216; Sun, 3 May 2020 16:06:18 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 043G6Ipw089215; Sun, 3 May 2020 16:06:18 GMT (envelope-from kp@FreeBSD.org) Message-Id: <202005031606.043G6Ipw089215@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sun, 3 May 2020 16:06:18 +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: r360607 - stable/12/sys/netpfil/pf X-SVN-Group: stable-12 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: stable/12/sys/netpfil/pf X-SVN-Commit-Revision: 360607 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 03 May 2020 16:06:18 -0000 Author: kp Date: Sun May 3 16:06:17 2020 New Revision: 360607 URL: https://svnweb.freebsd.org/changeset/base/360607 Log: MFC r360344: pf: Improve input validation If we pass an anchor name which doesn't exist pfr_table_count() returns -1, which leads to an overflow in mallocarray() and thus a panic. Explicitly check that pfr_table_count() does not return an error. Reported-by: syzbot+bd09d55d897d63d5f4f4@syzkaller.appspotmail.com Modified: stable/12/sys/netpfil/pf/pf_ioctl.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netpfil/pf/pf_ioctl.c ============================================================================== --- stable/12/sys/netpfil/pf/pf_ioctl.c Sun May 3 15:39:10 2020 (r360606) +++ stable/12/sys/netpfil/pf/pf_ioctl.c Sun May 3 16:06:17 2020 (r360607) @@ -3008,7 +3008,8 @@ DIOCCHANGEADDR_error: case DIOCRGETTABLES: { struct pfioc_table *io = (struct pfioc_table *)addr; struct pfr_table *pfrts; - size_t totlen, n; + size_t totlen; + int n; if (io->pfrio_esize != sizeof(struct pfr_table)) { error = ENODEV; @@ -3016,6 +3017,11 @@ DIOCCHANGEADDR_error: } PF_RULES_RLOCK(); n = pfr_table_count(&io->pfrio_table, io->pfrio_flags); + if (n < 0) { + PF_RULES_RUNLOCK(); + error = EINVAL; + break; + } io->pfrio_size = min(io->pfrio_size, n); totlen = io->pfrio_size * sizeof(struct pfr_table); @@ -3039,7 +3045,8 @@ DIOCCHANGEADDR_error: case DIOCRGETTSTATS: { struct pfioc_table *io = (struct pfioc_table *)addr; struct pfr_tstats *pfrtstats; - size_t totlen, n; + size_t totlen; + int n; if (io->pfrio_esize != sizeof(struct pfr_tstats)) { error = ENODEV; @@ -3047,6 +3054,11 @@ DIOCCHANGEADDR_error: } PF_RULES_WLOCK(); n = pfr_table_count(&io->pfrio_table, io->pfrio_flags); + if (n < 0) { + PF_RULES_WUNLOCK(); + error = EINVAL; + break; + } io->pfrio_size = min(io->pfrio_size, n); totlen = io->pfrio_size * sizeof(struct pfr_tstats); @@ -3069,7 +3081,8 @@ DIOCCHANGEADDR_error: case DIOCRCLRTSTATS: { struct pfioc_table *io = (struct pfioc_table *)addr; struct pfr_table *pfrts; - size_t totlen, n; + size_t totlen; + int n; if (io->pfrio_esize != sizeof(struct pfr_table)) { error = ENODEV; @@ -3078,6 +3091,11 @@ DIOCCHANGEADDR_error: PF_RULES_WLOCK(); n = pfr_table_count(&io->pfrio_table, io->pfrio_flags); + if (n < 0) { + PF_RULES_WUNLOCK(); + error = EINVAL; + break; + } io->pfrio_size = min(io->pfrio_size, n); totlen = io->pfrio_size * sizeof(struct pfr_table); @@ -3104,7 +3122,8 @@ DIOCCHANGEADDR_error: case DIOCRSETTFLAGS: { struct pfioc_table *io = (struct pfioc_table *)addr; struct pfr_table *pfrts; - size_t totlen, n; + size_t totlen; + int n; if (io->pfrio_esize != sizeof(struct pfr_table)) { error = ENODEV; @@ -3113,6 +3132,12 @@ DIOCCHANGEADDR_error: PF_RULES_RLOCK(); n = pfr_table_count(&io->pfrio_table, io->pfrio_flags); + if (n < 0) { + PF_RULES_RUNLOCK(); + error = EINVAL; + break; + } + io->pfrio_size = min(io->pfrio_size, n); PF_RULES_RUNLOCK(); From owner-svn-src-stable-12@freebsd.org Sun May 3 17:50:25 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B7C5A2E3D5F; Sun, 3 May 2020 17:50: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 49FYRj4VCNz40kT; Sun, 3 May 2020 17:50:25 +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 954D8ED8A; Sun, 3 May 2020 17:50:25 +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 043HoP1Q052222; Sun, 3 May 2020 17:50:25 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 043HoOx6052220; Sun, 3 May 2020 17:50:24 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202005031750.043HoOx6052220@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Sun, 3 May 2020 17:50: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: r360612 - in stable/12/stand: efi/loader/arch/amd64 i386/libi386 userboot/userboot X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/12/stand: efi/loader/arch/amd64 i386/libi386 userboot/userboot X-SVN-Commit-Revision: 360612 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 03 May 2020 17:50:25 -0000 Author: markj Date: Sun May 3 17:50:24 2020 New Revision: 360612 URL: https://svnweb.freebsd.org/changeset/base/360612 Log: MFC r360260: Stop setting PG_U in bootstrap mappings. Modified: stable/12/stand/efi/loader/arch/amd64/elf64_freebsd.c stable/12/stand/i386/libi386/elf64_freebsd.c stable/12/stand/userboot/userboot/elf64_freebsd.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/loader/arch/amd64/elf64_freebsd.c ============================================================================== --- stable/12/stand/efi/loader/arch/amd64/elf64_freebsd.c Sun May 3 16:51:59 2020 (r360611) +++ stable/12/stand/efi/loader/arch/amd64/elf64_freebsd.c Sun May 3 17:50:24 2020 (r360612) @@ -172,15 +172,15 @@ elf64_exec(struct preloaded_file *fp) for (i = 0; i < 512; i++) { /* Each slot of the L4 pages points to the same L3 page. */ PT4[i] = (pml4_entry_t)PT3; - PT4[i] |= PG_V | PG_RW | PG_U; + PT4[i] |= PG_V | PG_RW; /* Each slot of the L3 pages points to the same L2 page. */ PT3[i] = (pdp_entry_t)PT2; - PT3[i] |= PG_V | PG_RW | PG_U; + PT3[i] |= PG_V | PG_RW; /* The L2 page slots are mapped with 2MB pages for 1GB. */ PT2[i] = i * (2 * 1024 * 1024); - PT2[i] |= PG_V | PG_RW | PG_PS | PG_U; + PT2[i] |= PG_V | PG_RW | PG_PS; } printf("Start @ 0x%lx ...\n", ehdr->e_entry); Modified: stable/12/stand/i386/libi386/elf64_freebsd.c ============================================================================== --- stable/12/stand/i386/libi386/elf64_freebsd.c Sun May 3 16:51:59 2020 (r360611) +++ stable/12/stand/i386/libi386/elf64_freebsd.c Sun May 3 17:50:24 2020 (r360612) @@ -48,7 +48,6 @@ struct file_format amd64_elf_obj = { elf64_obj_loadfil #define PG_V 0x001 #define PG_RW 0x002 -#define PG_U 0x004 #define PG_PS 0x080 typedef uint64_t p4_entry_t; @@ -96,15 +95,15 @@ elf64_exec(struct preloaded_file *fp) for (i = 0; i < 512; i++) { /* Each slot of the level 4 pages points to the same level 3 page */ PT4[i] = (p4_entry_t)VTOP((uintptr_t)&PT3[0]); - PT4[i] |= PG_V | PG_RW | PG_U; + PT4[i] |= PG_V | PG_RW; /* Each slot of the level 3 pages points to the same level 2 page */ PT3[i] = (p3_entry_t)VTOP((uintptr_t)&PT2[0]); - PT3[i] |= PG_V | PG_RW | PG_U; + PT3[i] |= PG_V | PG_RW; /* The level 2 page slots are mapped with 2MB pages for 1GB. */ PT2[i] = i * (2 * 1024 * 1024); - PT2[i] |= PG_V | PG_RW | PG_PS | PG_U; + PT2[i] |= PG_V | PG_RW | PG_PS; } entry_lo = ehdr->e_entry & 0xffffffff; Modified: stable/12/stand/userboot/userboot/elf64_freebsd.c ============================================================================== --- stable/12/stand/userboot/userboot/elf64_freebsd.c Sun May 3 16:51:59 2020 (r360611) +++ stable/12/stand/userboot/userboot/elf64_freebsd.c Sun May 3 17:50:24 2020 (r360612) @@ -60,7 +60,6 @@ struct file_format amd64_elf_obj = { elf64_obj_loadfil #define PG_V 0x001 #define PG_RW 0x002 -#define PG_U 0x004 #define PG_PS 0x080 typedef uint64_t p4_entry_t; @@ -127,15 +126,15 @@ elf64_exec(struct preloaded_file *fp) for (i = 0; i < 512; i++) { /* Each slot of the level 4 pages points to the same level 3 page */ PT4[i] = (p4_entry_t) 0x3000; - PT4[i] |= PG_V | PG_RW | PG_U; + PT4[i] |= PG_V | PG_RW; /* Each slot of the level 3 pages points to the same level 2 page */ PT3[i] = (p3_entry_t) 0x4000; - PT3[i] |= PG_V | PG_RW | PG_U; + PT3[i] |= PG_V | PG_RW; /* The level 2 page slots are mapped with 2MB pages for 1GB. */ PT2[i] = i * (2 * 1024 * 1024); - PT2[i] |= PG_V | PG_RW | PG_PS | PG_U; + PT2[i] |= PG_V | PG_RW | PG_PS; } #ifdef DEBUG From owner-svn-src-stable-12@freebsd.org Sun May 3 23:38:22 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E67BF2BCFD6; Sun, 3 May 2020 23:38:22 +0000 (UTC) (envelope-from wulf@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 49Fj9B5rJJz4RcF; Sun, 3 May 2020 23:38:22 +0000 (UTC) (envelope-from wulf@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 C3AD51B08D; Sun, 3 May 2020 23:38:22 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 043NcM8c078243; Sun, 3 May 2020 23:38:22 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 043NcM5j078242; Sun, 3 May 2020 23:38:22 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <202005032338.043NcM5j078242@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Sun, 3 May 2020 23:38: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: r360617 - in stable: 11/sys/dev/atkbdc 12/sys/dev/atkbdc X-SVN-Group: stable-12 X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: in stable: 11/sys/dev/atkbdc 12/sys/dev/atkbdc X-SVN-Commit-Revision: 360617 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 03 May 2020 23:38:23 -0000 Author: wulf Date: Sun May 3 23:38:21 2020 New Revision: 360617 URL: https://svnweb.freebsd.org/changeset/base/360617 Log: MFC r360353: psm(4): Fix wrong key-release event occuring after trackpoint use. Some models of laptops e.g. "X1 Carbon 3rd Gen Thinkpad" have LRM buttons wired as so called "Synaptic touchpads extended buttons" rather thah real trackpoint buttons. Handle this case with merging of events from both sources. PR: 245877 Reported by: Raichoo Modified: stable/12/sys/dev/atkbdc/psm.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/dev/atkbdc/psm.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/dev/atkbdc/psm.c ============================================================================== --- stable/12/sys/dev/atkbdc/psm.c Sun May 3 23:15:14 2020 (r360616) +++ stable/12/sys/dev/atkbdc/psm.c Sun May 3 23:38:21 2020 (r360617) @@ -3366,7 +3366,7 @@ proc_synaptics(struct psm_softc *sc, packetbuf_t *pb, evdev_push_rel(sc->evdev_r, REL_X, *x); evdev_push_rel(sc->evdev_r, REL_Y, -*y); evdev_push_mouse_btn(sc->evdev_r, - guest_buttons); + guest_buttons | sc->extended_buttons); evdev_sync(sc->evdev_r); } #endif From owner-svn-src-stable-12@freebsd.org Sun May 3 23:40:16 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DB0952BD10C; Sun, 3 May 2020 23:40:16 +0000 (UTC) (envelope-from wulf@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 49FjCN5Y2yz4RrH; Sun, 3 May 2020 23:40:16 +0000 (UTC) (envelope-from wulf@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 B971B1B097; Sun, 3 May 2020 23:40:16 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 043NeG50078459; Sun, 3 May 2020 23:40:16 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 043NeGKt078458; Sun, 3 May 2020 23:40:16 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <202005032340.043NeGKt078458@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Sun, 3 May 2020 23:40: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: r360618 - stable/12/sys/dev/ichiic X-SVN-Group: stable-12 X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: stable/12/sys/dev/ichiic X-SVN-Commit-Revision: 360618 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 03 May 2020 23:40:16 -0000 Author: wulf Date: Sun May 3 23:40:16 2020 New Revision: 360618 URL: https://svnweb.freebsd.org/changeset/base/360618 Log: MFC r360355: ig4(4): Add PCI IDs for Intel Bay Trail I2C controllers. PR: 245654 Reported by: Modified: stable/12/sys/dev/ichiic/ig4_pci.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/ichiic/ig4_pci.c ============================================================================== --- stable/12/sys/dev/ichiic/ig4_pci.c Sun May 3 23:38:21 2020 (r360617) +++ stable/12/sys/dev/ichiic/ig4_pci.c Sun May 3 23:40:16 2020 (r360618) @@ -66,6 +66,13 @@ __FBSDID("$FreeBSD$"); static int ig4iic_pci_detach(device_t dev); +#define PCI_CHIP_BAYTRAIL_I2C_1 0x0f418086 +#define PCI_CHIP_BAYTRAIL_I2C_2 0x0f428086 +#define PCI_CHIP_BAYTRAIL_I2C_3 0x0f438086 +#define PCI_CHIP_BAYTRAIL_I2C_4 0x0f448086 +#define PCI_CHIP_BAYTRAIL_I2C_5 0x0f458086 +#define PCI_CHIP_BAYTRAIL_I2C_6 0x0f468086 +#define PCI_CHIP_BAYTRAIL_I2C_7 0x0f478086 #define PCI_CHIP_LYNXPT_LP_I2C_1 0x9c618086 #define PCI_CHIP_LYNXPT_LP_I2C_2 0x9c628086 #define PCI_CHIP_BRASWELL_I2C_1 0x22c18086 @@ -108,6 +115,13 @@ struct ig4iic_pci_device { }; static struct ig4iic_pci_device ig4iic_pci_devices[] = { + { PCI_CHIP_BAYTRAIL_I2C_1, "Intel BayTrail Serial I/O I2C Port 1", IG4_ATOM}, + { PCI_CHIP_BAYTRAIL_I2C_2, "Intel BayTrail Serial I/O I2C Port 2", IG4_ATOM}, + { PCI_CHIP_BAYTRAIL_I2C_3, "Intel BayTrail Serial I/O I2C Port 3", IG4_ATOM}, + { PCI_CHIP_BAYTRAIL_I2C_4, "Intel BayTrail Serial I/O I2C Port 4", IG4_ATOM}, + { PCI_CHIP_BAYTRAIL_I2C_5, "Intel BayTrail Serial I/O I2C Port 5", IG4_ATOM}, + { PCI_CHIP_BAYTRAIL_I2C_6, "Intel BayTrail Serial I/O I2C Port 6", IG4_ATOM}, + { PCI_CHIP_BAYTRAIL_I2C_7, "Intel BayTrail Serial I/O I2C Port 7", IG4_ATOM}, { PCI_CHIP_LYNXPT_LP_I2C_1, "Intel Lynx Point-LP I2C Controller-1", IG4_HASWELL}, { PCI_CHIP_LYNXPT_LP_I2C_2, "Intel Lynx Point-LP I2C Controller-2", IG4_HASWELL}, { PCI_CHIP_BRASWELL_I2C_1, "Intel Braswell Serial I/O I2C Port 1", IG4_ATOM}, From owner-svn-src-stable-12@freebsd.org Mon May 4 07:57:56 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 510F62C81DE; Mon, 4 May 2020 07:57:56 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.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 49FwFb6MyQz3M4f; Mon, 4 May 2020 07:57:55 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D5F3920E45; Mon, 4 May 2020 07:57:55 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0447vtaE084736; Mon, 4 May 2020 07:57:55 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0447vt7h084734; Mon, 4 May 2020 07:57:55 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202005040757.0447vt7h084734@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 4 May 2020 07:57: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: r360620 - in stable/12/sys: sys x86/include X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/12/sys: sys x86/include X-SVN-Commit-Revision: 360620 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 04 May 2020 07:57:56 -0000 Author: hselasky Date: Mon May 4 07:57:55 2020 New Revision: 360620 URL: https://svnweb.freebsd.org/changeset/base/360620 Log: Move id_mapped to end of bus_dma_impl structure to preserve KPI for 12-stable. This is a direct commit. Bump the __FreeBSD_version to force recompilation of external kernel modules. Reported by: kib @ Sponsored by: Mellanox Technologies Modified: stable/12/sys/sys/param.h stable/12/sys/x86/include/busdma_impl.h Modified: stable/12/sys/sys/param.h ============================================================================== --- stable/12/sys/sys/param.h Mon May 4 05:49:11 2020 (r360619) +++ stable/12/sys/sys/param.h Mon May 4 07:57:55 2020 (r360620) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1201515 /* Master, propagated to newvers */ +#define __FreeBSD_version 1201516 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, Modified: stable/12/sys/x86/include/busdma_impl.h ============================================================================== --- stable/12/sys/x86/include/busdma_impl.h Mon May 4 05:49:11 2020 (r360619) +++ stable/12/sys/x86/include/busdma_impl.h Mon May 4 07:57:55 2020 (r360620) @@ -62,7 +62,6 @@ struct bus_dma_impl { void *lockfuncarg, bus_dma_tag_t *dmat); int (*tag_destroy)(bus_dma_tag_t dmat); int (*tag_set_domain)(bus_dma_tag_t); - bool (*id_mapped)(bus_dma_tag_t, vm_paddr_t, bus_size_t); 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, @@ -85,6 +84,7 @@ struct bus_dma_impl { 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); + bool (*id_mapped)(bus_dma_tag_t, vm_paddr_t, bus_size_t); }; void bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op); From owner-svn-src-stable-12@freebsd.org Mon May 4 12:27:47 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 24B582CEBF3; Mon, 4 May 2020 12:27:47 +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 49G2Dy6kfVz489R; Mon, 4 May 2020 12:27: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 E0397241B1; Mon, 4 May 2020 12:27: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 044CRku2052545; Mon, 4 May 2020 12:27:46 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 044CRkDW052544; Mon, 4 May 2020 12:27:46 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202005041227.044CRkDW052544@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 4 May 2020 12:27: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: r360627 - stable/12/lib/libc/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/lib/libc/sys X-SVN-Commit-Revision: 360627 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 04 May 2020 12:27:47 -0000 Author: markj Date: Mon May 4 12:27:46 2020 New Revision: 360627 URL: https://svnweb.freebsd.org/changeset/base/360627 Log: MFC r360384: Document handling of connection-mode sockets by sendto(2). PR: 245817 Modified: stable/12/lib/libc/sys/send.2 Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libc/sys/send.2 ============================================================================== --- stable/12/lib/libc/sys/send.2 Mon May 4 11:23:55 2020 (r360626) +++ stable/12/lib/libc/sys/send.2 Mon May 4 12:27:46 2020 (r360627) @@ -28,7 +28,7 @@ .\" From: @(#)send.2 8.2 (Berkeley) 2/21/94 .\" $FreeBSD$ .\" -.Dd January 4, 2019 +.Dd April 27, 2020 .Dt SEND 2 .Os .Sh NAME @@ -69,18 +69,35 @@ The function may be used only when the socket is in a .Em connected -state, while +state. +The functions .Fn sendto , .Fn sendmsg and .Fn sendmmsg -may be used at any time. +may be used at any time if the socket is connectionless-mode. +If the socket is connection-mode, the protocol +must support implied connect (currently +.Xr tcp 4 +is the only protocol with support) or the socket must be in a +connected state before use. .Pp The address of the target is given by .Fa to with .Fa tolen -specifying its size. +specifying its size, or the equivalent +.Fa msg_name +and +.Fa msg_namelen +in +.Fa struct msghdr . +If the socket is in a connected state, the target address passed to +.Fn sendto , +.Fn sendmsg +or +.Fn sendmmsg +is ignored. The length of the message is given by .Fa len . If the message is too long to pass atomically through the @@ -195,6 +212,8 @@ An invalid descriptor was specified. The destination address is a broadcast address, and .Dv SO_BROADCAST has not been set on the socket. +.It Bq Er ENOTCONN +The socket is connection-mode but is not connected. .It Bq Er ENOTSOCK The argument .Fa s @@ -242,6 +261,7 @@ This typically means that the socket is not connected. .El .Sh SEE ALSO +.Xr connect 2 , .Xr fcntl 2 , .Xr getsockopt 2 , .Xr recv 2 , From owner-svn-src-stable-12@freebsd.org Mon May 4 12:28:44 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EDC252CED75; Mon, 4 May 2020 12:28:44 +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 49G2G466fRz48Pp; Mon, 4 May 2020 12:28: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 CD0D3241B3; Mon, 4 May 2020 12:28: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 044CSi4W052649; Mon, 4 May 2020 12:28:44 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 044CSibP052648; Mon, 4 May 2020 12:28:44 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202005041228.044CSibP052648@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 4 May 2020 12:28:44 +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: r360628 - stable/12/sys/dev/iwm X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/dev/iwm X-SVN-Commit-Revision: 360628 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 04 May 2020 12:28:45 -0000 Author: markj Date: Mon May 4 12:28:44 2020 New Revision: 360628 URL: https://svnweb.freebsd.org/changeset/base/360628 Log: MFC r360373: iwm: Print the command code for any unhandled commands. Modified: stable/12/sys/dev/iwm/if_iwm.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/iwm/if_iwm.c ============================================================================== --- stable/12/sys/dev/iwm/if_iwm.c Mon May 4 12:27:46 2020 (r360627) +++ stable/12/sys/dev/iwm/if_iwm.c Mon May 4 12:28:44 2020 (r360628) @@ -5618,9 +5618,8 @@ iwm_handle_rxb(struct iwm_softc *sc, struct mbuf *m) default: device_printf(sc->sc_dev, - "frame %d/%d %x UNHANDLED (this should " - "not happen)\n", qid & ~0x80, idx, - pkt->len_n_flags); + "code %x, frame %d/%d %x unhandled\n", + code, qid & ~0x80, idx, pkt->len_n_flags); break; } From owner-svn-src-stable-12@freebsd.org Mon May 4 15:57:14 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A3E8F2D354D; Mon, 4 May 2020 15:57:14 +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 49G6tf3tzMz4Mmc; Mon, 4 May 2020 15:57:14 +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 7C64826A19; Mon, 4 May 2020 15:57:14 +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 044FvEvM080973; Mon, 4 May 2020 15:57:14 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 044FvExc080972; Mon, 4 May 2020 15:57:14 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <202005041557.044FvExc080972@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 4 May 2020 15:57: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: r360632 - stable/12/lib/csu/common X-SVN-Group: stable-12 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/12/lib/csu/common X-SVN-Commit-Revision: 360632 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 04 May 2020 15:57:14 -0000 Author: emaste Date: Mon May 4 15:57:13 2020 New Revision: 360632 URL: https://svnweb.freebsd.org/changeset/base/360632 Log: MFC r340701: Add NT_FREEBSD_FEATURE_CTL ELF note to csu This note will be used to allow binaries to opt out of, or in to, upcoming vulnerability mitigation and other features. It is not yet connected but being added now to facilitate testing and ensure compatibility with existing kernels and tools. Sponsored by: The FreeBSD Foundation Modified: stable/12/lib/csu/common/crtbrand.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/csu/common/crtbrand.c ============================================================================== --- stable/12/lib/csu/common/crtbrand.c Mon May 4 15:07:57 2020 (r360631) +++ stable/12/lib/csu/common/crtbrand.c Mon May 4 15:57:13 2020 (r360632) @@ -67,3 +67,18 @@ static const struct { .name = NOTE_FREEBSD_VENDOR, .desc = __FreeBSD_version }; + +static const struct { + int32_t namesz; + int32_t descsz; + int32_t type; + char name[sizeof(NOTE_FREEBSD_VENDOR)]; + uint32_t desc[1]; +} crt_feature_ctl __attribute__ ((section (NOTE_SECTION), + aligned(4))) __used = { + .namesz = sizeof(NOTE_FREEBSD_VENDOR), + .descsz = sizeof(uint32_t), + .type = NT_FREEBSD_FEATURE_CTL, + .name = NOTE_FREEBSD_VENDOR, + .desc = { 0 } +}; From owner-svn-src-stable-12@freebsd.org Mon May 4 16:30:37 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 332062D42EF; Mon, 4 May 2020 16:30:37 +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 49G7d90W0bz4Pql; Mon, 4 May 2020 16:30:37 +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 0C963271B0; Mon, 4 May 2020 16:30:37 +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 044GUacH099682; Mon, 4 May 2020 16:30:36 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 044GUapl099679; Mon, 4 May 2020 16:30:36 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005041630.044GUapl099679@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 4 May 2020 16:30: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: r360633 - in stable: 11/share/man/man9 11/sys/kern 11/sys/sys 12/share/man/man9 12/sys/kern 12/sys/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/share/man/man9 11/sys/kern 11/sys/sys 12/share/man/man9 12/sys/kern 12/sys/sys X-SVN-Commit-Revision: 360633 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 04 May 2020 16:30:37 -0000 Author: jhb Date: Mon May 4 16:30:36 2020 New Revision: 360633 URL: https://svnweb.freebsd.org/changeset/base/360633 Log: MFC 355600: Add a callout_func_t typedef for functions used with callout_*(). This typedef is the same as timeout_t except that it is in the callout namespace and header. Use this typedef in various places of the callout implementation that were either using the raw type or timeout_t. While here, add to the manpage. Modified: stable/12/share/man/man9/timeout.9 stable/12/sys/kern/kern_timeout.c stable/12/sys/sys/_callout.h Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/share/man/man9/timeout.9 stable/11/sys/kern/kern_timeout.c stable/11/sys/sys/_callout.h Directory Properties: stable/11/ (props changed) Modified: stable/12/share/man/man9/timeout.9 ============================================================================== --- stable/12/share/man/man9/timeout.9 Mon May 4 15:57:13 2020 (r360632) +++ stable/12/share/man/man9/timeout.9 Mon May 4 16:30:36 2020 (r360633) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 27, 2016 +.Dd December 10, 2019 .Dt TIMEOUT 9 .Os .Sh NAME @@ -62,8 +62,10 @@ .Nd execute a function after a specified length of time .Sh SYNOPSIS .In sys/types.h +.In sys/callout.h .In sys/systm.h .Bd -literal +typedef void callout_func_t (void *); typedef void timeout_t (void *); .Ed .Ft int @@ -71,7 +73,7 @@ typedef void timeout_t (void *); .Ft void .Fn callout_deactivate "struct callout *c" .Ft int -.Fn callout_async_drain "struct callout *c" "timeout_t *drain" +.Fn callout_async_drain "struct callout *c" "callout_func_t *drain" .Ft int .Fn callout_drain "struct callout *c" .Ft void @@ -90,19 +92,24 @@ struct callout_handle handle = CALLOUT_HANDLE_INITIALI .Ft int .Fn callout_pending "struct callout *c" .Ft int -.Fn callout_reset "struct callout *c" "int ticks" "timeout_t *func" "void *arg" +.Fo callout_reset +.Fa "struct callout *c" +.Fa "int ticks" +.Fa "callout_func_t *func" +.Fa "void *arg" +.Fc .Ft int .Fo callout_reset_curcpu .Fa "struct callout *c" .Fa "int ticks" -.Fa "timeout_t *func" +.Fa "callout_func_t *func" .Fa "void *arg" .Fc .Ft int .Fo callout_reset_on .Fa "struct callout *c" .Fa "int ticks" -.Fa "timeout_t *func" +.Fa "callout_func_t *func" .Fa "void *arg" .Fa "int cpu" .Fc @@ -111,7 +118,7 @@ struct callout_handle handle = CALLOUT_HANDLE_INITIALI .Fa "struct callout *c" .Fa "sbintime_t sbt" .Fa "sbintime_t pr" -.Fa "timeout_t *func" +.Fa "callout_func_t *func" .Fa "void *arg" .Fa "int flags" .Fc @@ -120,7 +127,7 @@ struct callout_handle handle = CALLOUT_HANDLE_INITIALI .Fa "struct callout *c" .Fa "sbintime_t sbt" .Fa "sbintime_t pr" -.Fa "timeout_t *func" +.Fa "callout_func_t *func" .Fa "void *arg" .Fa "int flags" .Fc @@ -129,7 +136,7 @@ struct callout_handle handle = CALLOUT_HANDLE_INITIALI .Fa "struct callout *c" .Fa "sbintime_t sbt" .Fa "sbintime_t pr" -.Fa "timeout_t *func" +.Fa "callout_func_t *func" .Fa "void *arg" .Fa "int cpu" .Fa "int flags" Modified: stable/12/sys/kern/kern_timeout.c ============================================================================== --- stable/12/sys/kern/kern_timeout.c Mon May 4 15:57:13 2020 (r360632) +++ stable/12/sys/kern/kern_timeout.c Mon May 4 16:30:36 2020 (r360633) @@ -144,9 +144,9 @@ static u_int __read_mostly callwheelmask; */ struct cc_exec { struct callout *cc_curr; - void (*cc_drain)(void *); + callout_func_t *cc_drain; #ifdef SMP - void (*ce_migration_func)(void *); + callout_func_t *ce_migration_func; void *ce_migration_arg; int ce_migration_cpu; sbintime_t ce_migration_time; @@ -647,7 +647,7 @@ softclock_call_cc(struct callout *c, struct callout_cp int direct) { struct rm_priotracker tracker; - void (*c_func)(void *); + callout_func_t *c_func, *drain; void *c_arg; struct lock_class *class; struct lock_object *c_lock; @@ -655,7 +655,7 @@ softclock_call_cc(struct callout *c, struct callout_cp int c_iflags; #ifdef SMP struct callout_cpu *new_cc; - void (*new_func)(void *); + callout_func_t *new_func; void *new_arg; int flags, new_cpu; sbintime_t new_prec, new_time; @@ -664,7 +664,7 @@ softclock_call_cc(struct callout *c, struct callout_cp sbintime_t sbt1, sbt2; struct timespec ts2; static sbintime_t maxdt = 2 * SBT_1MS; /* 2 msec */ - static timeout_t *lastfunc; + static callout_func_t *lastfunc; #endif KASSERT((c->c_iflags & CALLOUT_PENDING) == CALLOUT_PENDING, @@ -757,8 +757,6 @@ skip: KASSERT(cc_exec_curr(cc, direct) == c, ("mishandled cc_curr")); cc_exec_curr(cc, direct) = NULL; if (cc_exec_drain(cc, direct)) { - void (*drain)(void *); - drain = cc_exec_drain(cc, direct); cc_exec_drain(cc, direct) = NULL; CC_UNLOCK(cc); @@ -1020,7 +1018,7 @@ callout_when(sbintime_t sbt, sbintime_t precision, int */ int callout_reset_sbt_on(struct callout *c, sbintime_t sbt, sbintime_t prec, - void (*ftn)(void *), void *arg, int cpu, int flags) + callout_func_t *ftn, void *arg, int cpu, int flags) { sbintime_t to_sbt, precision; struct callout_cpu *cc; @@ -1179,7 +1177,7 @@ callout_schedule(struct callout *c, int to_ticks) } int -_callout_stop_safe(struct callout *c, int flags, void (*drain)(void *)) +_callout_stop_safe(struct callout *c, int flags, callout_func_t *drain) { struct callout_cpu *cc, *old_cc; struct lock_class *class; Modified: stable/12/sys/sys/_callout.h ============================================================================== --- stable/12/sys/sys/_callout.h Mon May 4 15:57:13 2020 (r360632) +++ stable/12/sys/sys/_callout.h Mon May 4 16:30:36 2020 (r360633) @@ -48,6 +48,8 @@ LIST_HEAD(callout_list, callout); SLIST_HEAD(callout_slist, callout); TAILQ_HEAD(callout_tailq, callout); +typedef void callout_func_t(void *); + struct callout { union { LIST_ENTRY(callout) le; @@ -57,7 +59,7 @@ struct callout { sbintime_t c_time; /* ticks to the event */ sbintime_t c_precision; /* delta allowed wrt opt */ void *c_arg; /* function argument */ - void (*c_func)(void *); /* function to call */ + callout_func_t *c_func; /* function to call */ struct lock_object *c_lock; /* lock to handle */ short c_flags; /* User State */ short c_iflags; /* Internal State */ From owner-svn-src-stable-12@freebsd.org Mon May 4 18:40:56 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C0F4E2D710F; Mon, 4 May 2020 18:40:56 +0000 (UTC) (envelope-from zeising@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 49GBWX4kb2z4ZS8; Mon, 4 May 2020 18:40:56 +0000 (UTC) (envelope-from zeising@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 9DA40B20; Mon, 4 May 2020 18:40:56 +0000 (UTC) (envelope-from zeising@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 044IeuYU085002; Mon, 4 May 2020 18:40:56 GMT (envelope-from zeising@FreeBSD.org) Received: (from zeising@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 044IeuPB085001; Mon, 4 May 2020 18:40:56 GMT (envelope-from zeising@FreeBSD.org) Message-Id: <202005041840.044IeuPB085001@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: zeising set sender to zeising@FreeBSD.org using -f From: Niclas Zeising Date: Mon, 4 May 2020 18:40: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: r360637 - stable/12/sys/dev/evdev X-SVN-Group: stable-12 X-SVN-Commit-Author: zeising X-SVN-Commit-Paths: stable/12/sys/dev/evdev X-SVN-Commit-Revision: 360637 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 04 May 2020 18:40:56 -0000 Author: zeising (doc,ports committer) Date: Mon May 4 18:40:56 2020 New Revision: 360637 URL: https://svnweb.freebsd.org/changeset/base/360637 Log: MFC r360126, r360132: Change kern.evdev.rcpt_mask to 12 by default Original commit messages: Change kern.evdev.rcpt_mask from 3 to 12 by default. This makes us much more evdev-friendly, and will prevent everyone using xorg and wayland with evdev devices (the default) from needing to change this locally. powerpc32 still uses the old value for the keyboard part, becaues the adb keyboard driver used there is not evdev compatible. In r360126, I meant to have a different mask only on powerpc, not powerpc64. Update the check to check that we're not compiling for powerpc64. Approved by: wulf (implicit, mfc) Relnotes: yes Differential Revision: https://reviews.freebsd.org/D24370 Modified: stable/12/sys/dev/evdev/evdev.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/evdev/evdev.c ============================================================================== --- stable/12/sys/dev/evdev/evdev.c Mon May 4 17:45:04 2020 (r360636) +++ stable/12/sys/dev/evdev/evdev.c Mon May 4 18:40:56 2020 (r360637) @@ -66,7 +66,12 @@ enum evdev_sparse_result MALLOC_DEFINE(M_EVDEV, "evdev", "evdev memory"); -int evdev_rcpt_mask = EVDEV_RCPT_SYSMOUSE | EVDEV_RCPT_KBDMUX; +/* adb keyboard driver used on powerpc does not support evdev yet */ +#if defined(__powerpc__) && !defined(__powerpc64__) +int evdev_rcpt_mask = EVDEV_RCPT_KBDMUX | EVDEV_RCPT_HW_MOUSE; +#else +int evdev_rcpt_mask = EVDEV_RCPT_HW_MOUSE | EVDEV_RCPT_HW_KBD; +#endif int evdev_sysmouse_t_axis = 0; SYSCTL_NODE(_kern, OID_AUTO, evdev, CTLFLAG_RW, 0, "Evdev args"); From owner-svn-src-stable-12@freebsd.org Mon May 4 21:09:39 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 038752C3493; Mon, 4 May 2020 21:09:39 +0000 (UTC) (envelope-from jkim@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 49GFq66XJYz3K4L; Mon, 4 May 2020 21:09:38 +0000 (UTC) (envelope-from jkim@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 D6DEF26F7; Mon, 4 May 2020 21:09:38 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 044L9coK083279; Mon, 4 May 2020 21:09:38 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 044L9Zlb083261; Mon, 4 May 2020 21:09:35 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <202005042109.044L9Zlb083261@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Mon, 4 May 2020 21:09: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: r360640 - in stable/12/sys/contrib/dev/acpica: . common compiler components/debugger components/disassembler components/dispatcher components/executer include X-SVN-Group: stable-12 X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: in stable/12/sys/contrib/dev/acpica: . common compiler components/debugger components/disassembler components/dispatcher components/executer include X-SVN-Commit-Revision: 360640 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-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, 04 May 2020 21:09:39 -0000 Author: jkim Date: Mon May 4 21:09:35 2020 New Revision: 360640 URL: https://svnweb.freebsd.org/changeset/base/360640 Log: MFC: r360517 Merge ACPICA 20200430. Modified: stable/12/sys/contrib/dev/acpica/changes.txt stable/12/sys/contrib/dev/acpica/common/acgetline.c stable/12/sys/contrib/dev/acpica/common/dmtbdump2.c stable/12/sys/contrib/dev/acpica/compiler/aslcompiler.l stable/12/sys/contrib/dev/acpica/compiler/aslload.c stable/12/sys/contrib/dev/acpica/compiler/aslmessages.c stable/12/sys/contrib/dev/acpica/compiler/aslmessages.h stable/12/sys/contrib/dev/acpica/compiler/aslpredef.c stable/12/sys/contrib/dev/acpica/compiler/aslxref.c stable/12/sys/contrib/dev/acpica/compiler/dtutils.c stable/12/sys/contrib/dev/acpica/components/debugger/dbhistry.c stable/12/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c stable/12/sys/contrib/dev/acpica/components/dispatcher/dsfield.c stable/12/sys/contrib/dev/acpica/components/executer/exfield.c stable/12/sys/contrib/dev/acpica/include/acglobal.h stable/12/sys/contrib/dev/acpica/include/acpixf.h stable/12/sys/contrib/dev/acpica/include/acpredef.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/contrib/dev/acpica/changes.txt ============================================================================== --- stable/12/sys/contrib/dev/acpica/changes.txt Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/changes.txt Mon May 4 21:09:35 2020 (r360640) @@ -1,4 +1,61 @@ ---------------------------------------- + + +30 April 2020. Summary of changes for version 20200430: + + +1) ACPICA kernel-resident subsystem: + +Cleaned up the coding style of a couple of global variables +(AcpiGbl_NextCmdNum and AcpiProtocolLengths) caught by static analyzers. +AcpiProtocolLengths was made static, and the definition of +AcpiGbl_NextCmdNum was moved to acglobal.h. + + +2) iASL Compiler/Disassembler and ACPICA tools: + +iASL DataTable Compiler: Fixed a segfault on errors that aren't directly +associated with a field. + +Disassembler: has been made more resilient so that it will continue to +parse AML even if the AML generates ACPI namespace errors. This enables +iASL to disassemble some AML that may have been compiled using older +versions of iASL that no longer compile with newer versions of iASL. + +iASL: Fixed the required parameters for _NIH and _NIG. Previously, there +was a mixup where _NIG required one parameter and _NIH required zero +parameters. This change swaps these parameter requirements. Now it is +required that _NIH must be called with one parameter and _NIG requires +zero parameters. + +iASL: Allow use of undefined externals as long as they are protected by +an if (CondRefOf (...)) block when compiling multiple definition blocks. + +iASL: Fixed the type override behavior of named objects that are declared +as External. External declarations will no longer override the type of +the actual definition if it already exists. + +AcpiNames: Added setargv.obj to the MSVC 2017 link sequence to enable +command line wildcard support on Windows. Note: the AcpiNames utility is +essentially redundant with the AcpiExec utility (using the "namespace" +command) and is therefore deprecated. It will be removed in future +releases of ACPICA. + +Disassembler: ignore AE_ALREADY_EXISTS status when parsing create* +operators. The disassembler is intended to emit existing ASL code as-is. +Therefore, error messages emitted during disassembly should be ignored or +handled in a way such that the disassembler can continue to parse the +AML. This change ignores AE_ALREADY_EXISTS errors during the deferred Op +parsing for create operators in order to complete parsing ASL termlists. + +iASL DataTable Compiler: IVRS table: fix potentially uninitialized +variable warning. Some compilers catch potential uninitialized variables. +This is done by examining branches of if/else statements. This change +replaces an "else if" with an "else" to fix the uninitialized variable +warning. + + +---------------------------------------- 26 March 2020. Summary of changes for version 20200326: @@ -674,7 +731,7 @@ temporary. iASL: Emit error for creation of a zero-length operation region. Such a region is rather pointless. If encountered, a runtime error is also -implemented in the interpeter. +implemented in the interpreter. Debugger: Fix a possible fault with the "test objects" command. Modified: stable/12/sys/contrib/dev/acpica/common/acgetline.c ============================================================================== --- stable/12/sys/contrib/dev/acpica/common/acgetline.c Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/common/acgetline.c Mon May 4 21:09:35 2020 (r360640) @@ -189,8 +189,6 @@ AcpiAcClearLine ( #define _ASCII_LEFT_ARROW 'D' #define _ASCII_NEWLINE '\n' -extern UINT32 AcpiGbl_NextCmdNum; - /* Erase a single character on the input command line */ #define ACPI_CLEAR_CHAR() \ Modified: stable/12/sys/contrib/dev/acpica/common/dmtbdump2.c ============================================================================== --- stable/12/sys/contrib/dev/acpica/common/dmtbdump2.c Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/common/dmtbdump2.c Mon May 4 21:09:35 2020 (r360640) @@ -528,8 +528,10 @@ AcpiDmDumpIvrs ( DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, Subtable, sizeof (ACPI_IVRS_HARDWARE1)); } - else if (Subtable->Type == ACPI_IVRS_TYPE_HARDWARE2) + else { + /* ACPI_IVRS_TYPE_HARDWARE2 subtable type */ + EntryOffset = Offset + sizeof (ACPI_IVRS_HARDWARE2); DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, Subtable, sizeof (ACPI_IVRS_HARDWARE2)); Modified: stable/12/sys/contrib/dev/acpica/compiler/aslcompiler.l ============================================================================== --- stable/12/sys/contrib/dev/acpica/compiler/aslcompiler.l Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/compiler/aslcompiler.l Mon May 4 21:09:35 2020 (r360640) @@ -819,7 +819,7 @@ NamePathTail [.]{NameSeg} } /* - * The eror code is contained inside the + * The error code is contained inside the * {ErrorCode} pattern. Extract it and log it * as the expected error code. */ Modified: stable/12/sys/contrib/dev/acpica/compiler/aslload.c ============================================================================== --- stable/12/sys/contrib/dev/acpica/compiler/aslload.c Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/compiler/aslload.c Mon May 4 21:09:35 2020 (r360640) @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: dswload - Dispatcher namespace load callbacks + * Module Name: aslload - compiler namespace load callbacks * *****************************************************************************/ @@ -201,7 +201,6 @@ LdAnalyzeExternals ( ACPI_NAMESPACE_NODE *Node, ACPI_PARSE_OBJECT *Op, ACPI_OBJECT_TYPE ExternalOpType, - ACPI_OBJECT_TYPE ObjectType, ACPI_WALK_STATE *WalkState); @@ -515,7 +514,6 @@ LdNamespace1Begin ( ACPI_PARSE_OBJECT *MethodOp; ACPI_STATUS Status; ACPI_OBJECT_TYPE ObjectType; - ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY; char *Path; UINT32 Flags = ACPI_NS_NO_UPSEARCH; ACPI_PARSE_OBJECT *Arg; @@ -689,8 +687,7 @@ LdNamespace1Begin ( * * first child is name, next child is ObjectType */ - ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; - ObjectType = ACPI_TYPE_ANY; + ObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; /* * We will mark every new node along the path as "External". This @@ -709,7 +706,7 @@ LdNamespace1Begin ( * Store (\_SB_.PCI0.ABCD, Local0) * } */ - Flags |= ACPI_NS_EXTERNAL; + Flags |= ACPI_NS_EXTERNAL | ACPI_NS_DONT_OPEN_SCOPE; break; case PARSEOP_DEFAULT_ARG: @@ -913,8 +910,7 @@ LdNamespace1Begin ( else if ((Node->Flags & ANOBJ_IS_EXTERNAL) || (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) { - Status = LdAnalyzeExternals (Node, Op, ActualObjectType, - ObjectType, WalkState); + Status = LdAnalyzeExternals (Node, Op, ObjectType, WalkState); if (ACPI_FAILURE (Status)) { if (Status == AE_ERROR) @@ -929,6 +925,19 @@ LdNamespace1Begin ( } return_ACPI_STATUS (Status); } + + if (!(Node->Flags & ANOBJ_IS_EXTERNAL) && + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) + { + /* + * If we get to here, it means that an actual definition of + * the object declared external exists. Meaning that Op + * loading this this Op should have no change to the ACPI + * namespace. By going to FinishNode, we skip the + * assignment of Node->Op = Op. + */ + goto FinishNode; + } } else { @@ -980,31 +989,16 @@ LdNamespace1Begin ( } } -FinishNode: - /* - * Point the parse node to the new namespace node, and point - * the Node back to the original Parse node - */ - Op->Asl.Node = Node; + /* Point the Node back to the original Parse node */ + Node->Op = Op; - /* - * Set the actual data type if appropriate (EXTERNAL term only) - * As of 11/19/2019, ASL External() does not support parameter - * counts. When an External method is loaded, the parameter count is - * recorded in the external's arg count parameter. The parameter count may - * or may not be known in the declaration. If the value of this node turns - * out to be ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS, it indicates that - * we do not know the parameter count and that we must look at the usage of - * the External method call to get this information. - */ - if (ActualObjectType != ACPI_TYPE_ANY) - { - Node->Type = (UINT8) ActualObjectType; - Node->Value = (UINT32) - Op->Asl.Child->Asl.Next->Asl.Next->Asl.Value.Integer; - } +FinishNode: + /* Point the parse node to the new namespace node */ + + Op->Asl.Node = Node; + if (Op->Asl.ParseOpcode == PARSEOP_METHOD) { /* @@ -1013,6 +1007,13 @@ FinishNode: */ Node->Value = (UINT32) Op->Asl.Extra; } + else if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL && + Node->Type == ACPI_TYPE_METHOD && + (Node->Flags & ANOBJ_IS_EXTERNAL)) + { + Node->Value = + (UINT32) Op->Asl.Child->Asl.Next->Asl.Next->Asl.Value.Integer; + } return_ACPI_STATUS (Status); } @@ -1020,7 +1021,7 @@ FinishNode: /******************************************************************************* * - * FUNCTION: LdAnalyzeExternals + * FUNCTION: LdMatchExternType * * PARAMETERS: Type1 * Type2 @@ -1037,7 +1038,7 @@ FinishNode: ******************************************************************************/ static BOOLEAN -LdTypesMatchExternType ( +LdMatchExternType ( ACPI_OBJECT_TYPE Type1, ACPI_OBJECT_TYPE Type2) { @@ -1093,7 +1094,6 @@ LdTypesMatchExternType ( * PARAMETERS: Node - Node that represents the named object * Op - Named object declaring this named object * ExternalOpType - Type of ExternalOp - * ObjectType - Type of Declared object * WalkState - Current WalkState * * RETURN: Status @@ -1111,7 +1111,6 @@ LdAnalyzeExternals ( ACPI_NAMESPACE_NODE *Node, ACPI_PARSE_OBJECT *Op, ACPI_OBJECT_TYPE ExternalOpType, - ACPI_OBJECT_TYPE ObjectType, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; @@ -1135,12 +1134,12 @@ LdAnalyzeExternals ( else { ActualExternalOpType = Node->Type; - ActualOpType = ObjectType; + ActualOpType = ExternalOpType; } if ((ActualOpType != ACPI_TYPE_ANY) && (ActualExternalOpType != ACPI_TYPE_ANY) && - !LdTypesMatchExternType (ActualExternalOpType, ActualOpType)) + !LdMatchExternType (ActualExternalOpType, ActualOpType)) { if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL && Node->Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) @@ -1168,6 +1167,8 @@ LdAnalyzeExternals ( } } + /* Set the object type of the external */ + if ((Node->Flags & ANOBJ_IS_EXTERNAL) && (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL)) { @@ -1176,13 +1177,13 @@ LdAnalyzeExternals ( * previously declared External */ Node->Flags &= ~ANOBJ_IS_EXTERNAL; - Node->Type = (UINT8) ObjectType; + Node->Type = (UINT8) ExternalOpType; /* Just retyped a node, probably will need to open a scope */ - if (AcpiNsOpensScope (ObjectType)) + if (AcpiNsOpensScope (ExternalOpType)) { - Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + Status = AcpiDsScopeStackPush (Node, ExternalOpType, WalkState); if (ACPI_FAILURE (Status)) { return (Status); @@ -1203,7 +1204,7 @@ LdAnalyzeExternals ( } else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && - (ObjectType == ACPI_TYPE_ANY)) + (ExternalOpType == ACPI_TYPE_ANY)) { /* Allow update of externals of unknown type. */ Modified: stable/12/sys/contrib/dev/acpica/compiler/aslmessages.c ============================================================================== --- stable/12/sys/contrib/dev/acpica/compiler/aslmessages.c Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/compiler/aslmessages.c Mon May 4 21:09:35 2020 (r360640) @@ -380,6 +380,7 @@ const char *AslCompilerMsgs [] = /* ASL_MSG_TYPE_MISMATCH_FOUND_HERE */ "Actual object declaration:", /* ASL_MSG_DUPLICATE_EXTERN_MISMATCH */ "Type mismatch between multiple external declarations detected", /* ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE */"Duplicate external declaration:", +/* ASL_MSG_CONDREF_NEEDS_EXTERNAL_DECL */"CondRefOf parameter requires External() declaration", }; /* Table compiler */ Modified: stable/12/sys/contrib/dev/acpica/compiler/aslmessages.h ============================================================================== --- stable/12/sys/contrib/dev/acpica/compiler/aslmessages.h Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/compiler/aslmessages.h Mon May 4 21:09:35 2020 (r360640) @@ -382,6 +382,7 @@ typedef enum ASL_MSG_TYPE_MISMATCH_FOUND_HERE, ASL_MSG_DUPLICATE_EXTERN_MISMATCH, ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE, + ASL_MSG_CONDREF_NEEDS_EXTERNAL_DECL, /* These messages are used by the Data Table compiler only */ Modified: stable/12/sys/contrib/dev/acpica/compiler/aslpredef.c ============================================================================== --- stable/12/sys/contrib/dev/acpica/compiler/aslpredef.c Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/compiler/aslpredef.c Mon May 4 21:09:35 2020 (r360640) @@ -674,7 +674,7 @@ ApCheckForSpecialName ( /* * Was not actually emitted by the compiler. This is a special case, * however. If the ASL code being compiled was the result of a - * dissasembly, it may possibly contain valid compiler-emitted names + * disassembly, it may possibly contain valid compiler-emitted names * of the form "_T_x". We don't want to issue an error or even a * warning and force the user to manually change the names. So, we * will issue a remark instead. Modified: stable/12/sys/contrib/dev/acpica/compiler/aslxref.c ============================================================================== --- stable/12/sys/contrib/dev/acpica/compiler/aslxref.c Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/compiler/aslxref.c Mon May 4 21:09:35 2020 (r360640) @@ -199,7 +199,17 @@ XfCheckFieldRange ( UINT32 FieldBitLength, UINT32 AccessBitWidth); +static BOOLEAN +XfFindCondRefOfName ( + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op); +static BOOLEAN +XfRefIsGuardedByIfCondRefOf ( + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op); + + /******************************************************************************* * * FUNCTION: XfCrossReferenceNamespace @@ -582,17 +592,6 @@ XfNamespaceLocateBegin ( } /* - * One special case: CondRefOf operator - we don't care if the name exists - * or not at this point, just ignore it, the point of the operator is to - * determine if the name exists at runtime. - */ - if ((Op->Asl.Parent) && - (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) - { - return_ACPI_STATUS (AE_OK); - } - - /* * We must enable the "search-to-root" for single NameSegs, but * we have to be very careful about opening up scopes */ @@ -600,7 +599,8 @@ XfNamespaceLocateBegin ( if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) || - (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) + (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) || + (Op->Asl.ParseOpcode == PARSEOP_CONDREFOF)) { /* * These are name references, do not push the scope stack @@ -665,8 +665,23 @@ XfNamespaceLocateBegin ( * We didn't find the name reference by path -- we can qualify this * a little better before we print an error message */ - if (strlen (Path) == ACPI_NAMESEG_SIZE) + + if ((Op->Asl.Parent) && + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) { + /* + * One special case: CondRefOf operator - if the name doesn't + * exist at this point, it means that there's no actual or + * external declaration. If the name is not found, just ignore + * it, the point of the operator is to determine if the name + * exists at runtime. We wanted to see if this named object + * exists to facilitate analysis to allow protected usage of + * undeclared externals. + */ + return_ACPI_STATUS (AE_OK); + } + else if (strlen (Path) == ACPI_NAMESEG_SIZE) + { /* A simple, one-segment ACPI name */ if (XfObjectExists (Path)) @@ -1190,6 +1205,7 @@ XfNamespaceLocateBegin ( /* * 5) Check for external resolution + * * By this point, everything should be loaded in the namespace. If a * namespace lookup results in a namespace node that is an external, it * means that this named object was not defined in the input ASL. This @@ -1197,11 +1213,38 @@ XfNamespaceLocateBegin ( * use the external keyword to suppress compiler errors about undefined * objects. Note: this only applies when compiling multiple definition * blocks. + * + * Do not check for external resolution in the following cases: + * + * case 1) External (ABCD) + * + * This declares ABCD as an external so there is no requirement for + * ABCD to be loaded in the namespace when analyzing the actual + * External() statement. + * + * case 2) CondRefOf (ABCD) + * + * This operator will query the ACPI namespace on the existence of + * ABCD. If ABCD does not exist, this operator will return a 0 + * without incurring AML runtime errors. Therefore, ABCD is allowed + * to not exist when analyzing the CondRefOf operator. + * + * case 3) External (ABCD) + * if (CondRefOf (ABCD)) + * { + * Store (0, ABCD) + * } + * + * In this case, ABCD is accessed only if it exists due to the if + * statement so there is no need to flag the ABCD nested in the + * store operator. */ if (AslGbl_ParseTreeRoot->Asl.Child && AslGbl_ParseTreeRoot->Asl.Child->Asl.Next && - (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL && - Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL) && - (Node->Flags & ANOBJ_IS_EXTERNAL)) + (Node->Flags & ANOBJ_IS_EXTERNAL) && + Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_EXTERNAL && + Op->Asl.ParseOpcode != PARSEOP_EXTERNAL && + Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_CONDREFOF && + !XfRefIsGuardedByIfCondRefOf (Node, Op)) { AslError (ASL_ERROR, ASL_MSG_UNDEFINED_EXTERNAL, Op, NULL); } @@ -1216,6 +1259,96 @@ XfNamespaceLocateBegin ( Op->Asl.Node = Node; return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: XfRefIsGuardedByIfCondRefOf + * + * PARAMETERS: Node - Named object reference node + * Op - Named object reference parse node + * + * RETURN: BOOLEAN + * + * DESCRIPTION: returns true if Op checked inside if (CondRefOf (...)) + * refers to Node. + * + ******************************************************************************/ + +static BOOLEAN +XfRefIsGuardedByIfCondRefOf ( + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Parent = Op->Asl.Parent; + + + while (Parent) + { + if (Parent->Asl.ParseOpcode == PARSEOP_IF && + XfFindCondRefOfName (Node, Parent->Asl.Child)) + { + return (TRUE); + } + + Parent = Parent->Asl.Parent; + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: XfRefIsGuardedByIfCondRefOf + * + * PARAMETERS: Node - Named object reference node + * Op - Named object reference parse node + * + * RETURN: BOOLEAN + * + * DESCRIPTION: returns true if Op checked inside if (CondRefOf (...)) + * refers to Node. + * + ******************************************************************************/ + +static BOOLEAN +XfFindCondRefOfName ( + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op) +{ + BOOLEAN CondRefOfFound = FALSE; + + + if (!Op) + { + return (FALSE); + } + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_CONDREFOF: + + return (Op->Asl.Child->Common.Node == Node); + break; + + case PARSEOP_LAND: + + CondRefOfFound = XfFindCondRefOfName (Node, Op->Asl.Child); + if (CondRefOfFound) + { + return (TRUE); + } + + return (XfFindCondRefOfName (Node, Op->Asl.Child->Asl.Next)); + break; + + default: + + return (FALSE); + break; + } } Modified: stable/12/sys/contrib/dev/acpica/compiler/dtutils.c ============================================================================== --- stable/12/sys/contrib/dev/acpica/compiler/dtutils.c Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/compiler/dtutils.c Mon May 4 21:09:35 2020 (r360640) @@ -186,11 +186,20 @@ DtError ( DT_FIELD *FieldObject, char *ExtraMessage) { + UINT32 Line = 0; + + /* Field object could be NULL */ + + if (FieldObject) + { + Line = FieldObject->Line; + } + /* Check if user wants to ignore this exception */ if (AslIsExceptionIgnored (AslGbl_Files[ASL_FILE_INPUT].Filename, - FieldObject->Line, Level, MessageId)) + Line, Level, MessageId)) { return; } Modified: stable/12/sys/contrib/dev/acpica/components/debugger/dbhistry.c ============================================================================== --- stable/12/sys/contrib/dev/acpica/components/debugger/dbhistry.c Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/components/debugger/dbhistry.c Mon May 4 21:09:35 2020 (r360640) @@ -175,7 +175,6 @@ static HISTORY_INFO AcpiGbl_HistoryBuffer[HIST static UINT16 AcpiGbl_LoHistory = 0; static UINT16 AcpiGbl_NumHistory = 0; static UINT16 AcpiGbl_NextHistoryIndex = 0; -UINT32 AcpiGbl_NextCmdNum = 1; /******************************************************************************* Modified: stable/12/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c ============================================================================== --- stable/12/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c Mon May 4 21:09:35 2020 (r360640) @@ -400,6 +400,10 @@ AcpiDmIsUuidBuffer ( /* Buffer size is the buffer argument */ SizeOp = Op->Common.Value.Arg; + if (!SizeOp) + { + return (FALSE); + } /* Next, the initializer byte list to examine */ @@ -520,6 +524,10 @@ AcpiDmIsUnicodeBuffer ( /* Buffer size is the buffer argument */ SizeOp = Op->Common.Value.Arg; + if (!SizeOp) + { + return (FALSE); + } /* Next, the initializer byte list to examine */ @@ -596,6 +604,10 @@ AcpiDmIsStringBuffer ( /* Buffer size is the buffer argument */ SizeOp = Op->Common.Value.Arg; + if (!SizeOp) + { + return (FALSE); + } /* Next, the initializer byte list to examine */ @@ -675,13 +687,18 @@ AcpiDmIsPldBuffer ( UINT64 InitializerSize; + if (!Op) + { + return (FALSE); + } + /* * Get the BufferSize argument - Buffer(BufferSize) * If the buffer was generated by the ToPld macro, it must * be a BYTE constant. */ SizeOp = Op->Common.Value.Arg; - if (SizeOp->Common.AmlOpcode != AML_BYTE_OP) + if (!SizeOp || SizeOp->Common.AmlOpcode != AML_BYTE_OP) { return (FALSE); } Modified: stable/12/sys/contrib/dev/acpica/components/dispatcher/dsfield.c ============================================================================== --- stable/12/sys/contrib/dev/acpica/components/dispatcher/dsfield.c Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/components/dispatcher/dsfield.c Mon May 4 21:09:35 2020 (r360640) @@ -341,8 +341,13 @@ AcpiDsCreateBufferField ( Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); - if (ACPI_FAILURE (Status)) + if ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) && + Status == AE_ALREADY_EXISTS) { + Status = AE_OK; + } + else if (ACPI_FAILURE (Status)) + { ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Arg->Common.Value.String, Status); return_ACPI_STATUS (Status); @@ -682,12 +687,21 @@ AcpiDsCreateField ( Info.RegionNode = RegionNode; Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); - if (Info.RegionNode->Object->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_COMM && - !(RegionNode->Object->Field.InternalPccBuffer - = ACPI_ALLOCATE_ZEROED(Info.RegionNode->Object->Region.Length))) + if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS (Status); } + + if (Info.RegionNode->Object->Region.SpaceId == ACPI_ADR_SPACE_PLATFORM_COMM) + { + RegionNode->Object->Field.InternalPccBuffer = + ACPI_ALLOCATE_ZEROED(Info.RegionNode->Object->Region.Length); + if (!RegionNode->Object->Field.InternalPccBuffer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + return_ACPI_STATUS (Status); } Modified: stable/12/sys/contrib/dev/acpica/components/executer/exfield.c ============================================================================== --- stable/12/sys/contrib/dev/acpica/components/executer/exfield.c Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/components/executer/exfield.c Mon May 4 21:09:35 2020 (r360640) @@ -167,7 +167,7 @@ #define ACPI_INVALID_PROTOCOL_ID 0x80 #define ACPI_MAX_PROTOCOL_ID 0x0F -const UINT8 AcpiProtocolLengths[] = +static const UINT8 AcpiProtocolLengths[] = { ACPI_INVALID_PROTOCOL_ID, /* 0 - reserved */ ACPI_INVALID_PROTOCOL_ID, /* 1 - reserved */ Modified: stable/12/sys/contrib/dev/acpica/include/acglobal.h ============================================================================== --- stable/12/sys/contrib/dev/acpica/include/acglobal.h Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/include/acglobal.h Mon May 4 21:09:35 2020 (r360640) @@ -436,6 +436,7 @@ ACPI_GLOBAL (ACPI_EXTERNAL_FILE *, AcpiGbl_Extern #ifdef ACPI_DEBUGGER ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_AbortMethod, FALSE); ACPI_INIT_GLOBAL (ACPI_THREAD_ID, AcpiGbl_DbThreadId, ACPI_INVALID_THREAD_ID); +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_NextCmdNum, 1); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoIniMethods); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoRegionSupport); Modified: stable/12/sys/contrib/dev/acpica/include/acpixf.h ============================================================================== --- stable/12/sys/contrib/dev/acpica/include/acpixf.h Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/include/acpixf.h Mon May 4 21:09:35 2020 (r360640) @@ -154,7 +154,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20200326 +#define ACPI_CA_VERSION 0x20200430 #include #include Modified: stable/12/sys/contrib/dev/acpica/include/acpredef.h ============================================================================== --- stable/12/sys/contrib/dev/acpica/include/acpredef.h Mon May 4 20:28:53 2020 (r360639) +++ stable/12/sys/contrib/dev/acpica/include/acpredef.h Mon May 4 21:09:35 2020 (r360640) @@ -769,10 +769,10 @@ const ACPI_PREDEFINED_INFO AcpiGbl_Predefined {{"_NIC", METHOD_0ARGS, /* ACPI 6.3 */ METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, - {{"_NIG", METHOD_1ARGS (ACPI_TYPE_BUFFER), /* ACPI 6.3 */ + {{"_NIG", METHOD_0ARGS, /* ACPI 6.3 */ METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, - {{"_NIH", METHOD_0ARGS, /* ACPI 6.3 */ + {{"_NIH", METHOD_1ARGS (ACPI_TYPE_BUFFER), /* ACPI 6.3 */ METHOD_RETURNS (ACPI_RTYPE_BUFFER)}}, {{"_NTT", METHOD_0ARGS, From owner-svn-src-stable-12@freebsd.org Tue May 5 04:25:26 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7F2AF2D5CCE; Tue, 5 May 2020 04:25:26 +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 49GRTy0Pyzz4H12; Tue, 5 May 2020 04:25:26 +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 0962B7F30; Tue, 5 May 2020 04:25:26 +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 0454PPPI058627; Tue, 5 May 2020 04:25:25 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0454PPbl058626; Tue, 5 May 2020 04:25:25 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005050425.0454PPbl058626@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 5 May 2020 04:25:25 +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: r360651 - stable/12/usr.sbin/bhyve X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/12/usr.sbin/bhyve X-SVN-Commit-Revision: 360651 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 05 May 2020 04:25:26 -0000 Author: jhb Date: Tue May 5 04:25:25 2020 New Revision: 360651 URL: https://svnweb.freebsd.org/changeset/base/360651 Log: MFC 355683: Don't call into the debug server if it isn't configured. Modified: stable/12/usr.sbin/bhyve/bhyverun.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/bhyve/bhyverun.c ============================================================================== --- stable/12/usr.sbin/bhyve/bhyverun.c Tue May 5 00:58:03 2020 (r360650) +++ stable/12/usr.sbin/bhyve/bhyverun.c Tue May 5 04:25:25 2020 (r360651) @@ -169,6 +169,7 @@ char *guest_uuid_str; int raw_stdio = 0; +static int gdb_port = 0; static int guest_vmexit_on_hlt, guest_vmexit_on_pause; static int virtio_msix = 1; static int x2apic_mode = 0; /* default is xAPIC */ @@ -418,7 +419,8 @@ fbsdrun_start_thread(void *param) snprintf(tname, sizeof(tname), "vcpu %d", vcpu); pthread_set_name_np(mtp->mt_thr, tname); - gdb_cpu_add(vcpu); + if (gdb_port != 0) + gdb_cpu_add(vcpu); vm_loop(mtp->mt_ctx, vcpu, vmexit[vcpu].rip); @@ -692,8 +694,11 @@ vmexit_mtrap(struct vmctx *ctx, struct vm_exit *vmexit stats.vmexit_mtrap++; + if (gdb_port == 0) { + fprintf(stderr, "vm_loop: unexpected VMEXIT_MTRAP\n"); + exit(4); + } gdb_cpu_mtrap(*pvcpu); - return (VMEXIT_CONTINUE); } @@ -772,6 +777,10 @@ static int vmexit_debug(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) { + if (gdb_port == 0) { + fprintf(stderr, "vm_loop: unexpected VMEXIT_DEBUG\n"); + exit(4); + } gdb_cpu_suspend(*pvcpu); return (VMEXIT_CONTINUE); } From owner-svn-src-stable-12@freebsd.org Tue May 5 04:37:06 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 808342D6338; Tue, 5 May 2020 04:37:06 +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 49GRlQ2sQBz4HXC; Tue, 5 May 2020 04:37:06 +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 5D7E58112; Tue, 5 May 2020 04:37:06 +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 0454b65r064783; Tue, 5 May 2020 04:37:06 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0454b60o064782; Tue, 5 May 2020 04:37:06 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005050437.0454b60o064782@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 5 May 2020 04:37: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: r360652 - stable/12/sys/opencrypto X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/12/sys/opencrypto X-SVN-Commit-Revision: 360652 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 05 May 2020 04:37:06 -0000 Author: jhb Date: Tue May 5 04:37:05 2020 New Revision: 360652 URL: https://svnweb.freebsd.org/changeset/base/360652 Log: MFC 356508: Use falloc_noinstall + finstall for crypto file descriptors. Modified: stable/12/sys/opencrypto/cryptodev.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/opencrypto/cryptodev.c ============================================================================== --- stable/12/sys/opencrypto/cryptodev.c Tue May 5 04:25:25 2020 (r360651) +++ stable/12/sys/opencrypto/cryptodev.c Tue May 5 04:37:05 2020 (r360652) @@ -1498,20 +1498,21 @@ cryptoioctl(struct cdev *dev, u_long cmd, caddr_t data switch (cmd) { case CRIOGET: + error = falloc_noinstall(td, &f); + if (error) + break; + fcr = malloc(sizeof(struct fcrypt), M_XDATA, M_WAITOK | M_ZERO); TAILQ_INIT(&fcr->csessions); mtx_init(&fcr->lock, "fcrypt", NULL, MTX_DEF); - error = falloc(td, &f, &fd, 0); - + finit(f, FREAD | FWRITE, DTYPE_CRYPTO, fcr, &cryptofops); + error = finstall(td, f, &fd, 0, NULL); if (error) { mtx_destroy(&fcr->lock); free(fcr, M_XDATA); - return (error); - } - /* falloc automatically provides an extra reference to 'f'. */ - finit(f, FREAD | FWRITE, DTYPE_CRYPTO, fcr, &cryptofops); - *(u_int32_t *)data = fd; + } else + *(uint32_t *)data = fd; fdrop(f, td); break; case CRIOFINDDEV: From owner-svn-src-stable-12@freebsd.org Tue May 5 04:42:47 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EBF992D65BC; Tue, 5 May 2020 04:42:47 +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 49GRsz5hZMz4Hx3; Tue, 5 May 2020 04:42:47 +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 BEA4582EA; Tue, 5 May 2020 04:42:47 +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 0454glaQ070646; Tue, 5 May 2020 04:42:47 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0454glWw070645; Tue, 5 May 2020 04:42:47 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005050442.0454glWw070645@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 5 May 2020 04:42: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: r360653 - in stable: 11/share/man/man9 12/share/man/man9 X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/share/man/man9 12/share/man/man9 X-SVN-Commit-Revision: 360653 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 05 May 2020 04:42:48 -0000 Author: jhb Date: Tue May 5 04:42:47 2020 New Revision: 360653 URL: https://svnweb.freebsd.org/changeset/base/360653 Log: MFC 357062: Correct the return types of fueword*(). Modified: stable/12/share/man/man9/fetch.9 Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/share/man/man9/fetch.9 Directory Properties: stable/11/ (props changed) Modified: stable/12/share/man/man9/fetch.9 ============================================================================== --- stable/12/share/man/man9/fetch.9 Tue May 5 04:37:05 2020 (r360652) +++ stable/12/share/man/man9/fetch.9 Tue May 5 04:42:47 2020 (r360653) @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 17, 2018 +.Dd January 23, 2020 .Dt FETCH 9 .Os .Sh NAME @@ -61,11 +61,11 @@ .Fn fuword32 "volatile const void *base" .Ft int64_t .Fn fuword64 "volatile const void *base" -.Ft long +.Ft int .Fn fueword "volatile const void *base" "long *val" -.Ft int32_t +.Ft int .Fn fueword32 "volatile const void *base" "int32_t *val" -.Ft int64_t +.Ft int .Fn fueword64 "volatile const void *base" "int64_t *val" .In sys/resourcevar.h .Sh DESCRIPTION From owner-svn-src-stable-12@freebsd.org Wed May 6 00:25:44 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B49932DAA1C; Wed, 6 May 2020 00:25:44 +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 49Gy6w3b6Gz3GTs; Wed, 6 May 2020 00:25:44 +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 764331E9B2; Wed, 6 May 2020 00:25:44 +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 0460PiQd017457; Wed, 6 May 2020 00:25:44 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0460PinQ017456; Wed, 6 May 2020 00:25:44 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <202005060025.0460PinQ017456@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 6 May 2020 00:25:44 +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: r360677 - stable/12/lib/liblua X-SVN-Group: stable-12 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/12/lib/liblua X-SVN-Commit-Revision: 360677 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 06 May 2020 00:25:44 -0000 Author: emaste Date: Wed May 6 00:25:43 2020 New Revision: 360677 URL: https://svnweb.freebsd.org/changeset/base/360677 Log: MFC r360460: liblua: ensure that "require" will fail in bootstrap flua We do not want to support bootstrapping lua modules, so ensure that require will fail by providing a nonexistent path. Sponsored by: The FreeBSD Foundation Modified: stable/12/lib/liblua/Makefile stable/12/lib/liblua/luaconf.h Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/liblua/Makefile ============================================================================== --- stable/12/lib/liblua/Makefile Tue May 5 21:50:52 2020 (r360676) +++ stable/12/lib/liblua/Makefile Wed May 6 00:25:43 2020 (r360677) @@ -26,4 +26,9 @@ SRCS+= lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldbli CFLAGS+= -I${.CURDIR} -I${.CURDIR}/modules -I${LUASRC} CFLAGS+= -DLUA_PROGNAME="\"${PROG}\"" +.if defined(BOOTSTRAPPING) +CFLAGS+= -DLUA_PATH_DEFAULT="\"/nonexistent/?.lua\"" +CFLAGS+= -DLUA_CPATH_DEFAULT="\"/nonexistent/?.so\"" +.endif + .include Modified: stable/12/lib/liblua/luaconf.h ============================================================================== --- stable/12/lib/liblua/luaconf.h Tue May 5 21:50:52 2020 (r360676) +++ stable/12/lib/liblua/luaconf.h Wed May 6 00:25:43 2020 (r360677) @@ -208,12 +208,16 @@ #define LUA_ROOT "/usr/local/" #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" +#if !defined(LUA_PATH_DEFAULT) #define LUA_PATH_DEFAULT \ LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ "./?.lua;" "./?/init.lua" +#endif +#if !defined(LUA_CPATH_DEFAULT) #define LUA_CPATH_DEFAULT \ LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" +#endif #endif /* } */ From owner-svn-src-stable-12@freebsd.org Wed May 6 05:29:00 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F1B222E0517; Wed, 6 May 2020 05:29:00 +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 49H4rr64Rtz444X; Wed, 6 May 2020 05:29:00 +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 C6FB422396; Wed, 6 May 2020 05:29:00 +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 0465T0QW005932; Wed, 6 May 2020 05:29:00 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0465T0b3005930; Wed, 6 May 2020 05:29:00 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005060529.0465T0b3005930@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 6 May 2020 05:29: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: r360681 - stable/12/sys/mips/conf X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/12/sys/mips/conf X-SVN-Commit-Revision: 360681 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 06 May 2020 05:29:01 -0000 Author: jhb Date: Wed May 6 05:29:00 2020 New Revision: 360681 URL: https://svnweb.freebsd.org/changeset/base/360681 Log: Update a few more kernel configs for tun -> tuntap. Modified: stable/12/sys/mips/conf/GXEMUL stable/12/sys/mips/conf/GXEMUL32 Modified: stable/12/sys/mips/conf/GXEMUL ============================================================================== --- stable/12/sys/mips/conf/GXEMUL Wed May 6 01:47:45 2020 (r360680) +++ stable/12/sys/mips/conf/GXEMUL Wed May 6 05:29:00 2020 (r360681) @@ -54,7 +54,7 @@ device gxemul_ether device loop # Network loopback device random # Entropy device device ether # Ethernet support -device tun # Packet tunnel. +device tuntap # Packet tunnel. device md # Memory "disks" device gif # IPv6 and IPv4 tunneling Modified: stable/12/sys/mips/conf/GXEMUL32 ============================================================================== --- stable/12/sys/mips/conf/GXEMUL32 Wed May 6 01:47:45 2020 (r360680) +++ stable/12/sys/mips/conf/GXEMUL32 Wed May 6 05:29:00 2020 (r360681) @@ -52,7 +52,7 @@ device gxemul_ether device loop # Network loopback device random # Entropy device device ether # Ethernet support -device tun # Packet tunnel. +device tuntap # Packet tunnel. device md # Memory "disks" device gif # IPv6 and IPv4 tunneling From owner-svn-src-stable-12@freebsd.org Wed May 6 17:12:27 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 376FE2DA585; Wed, 6 May 2020 17:12:27 +0000 (UTC) (envelope-from brooks@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 49HNSW04wfz3QsD; Wed, 6 May 2020 17:12:26 +0000 (UTC) (envelope-from brooks@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 E21D72C93; Wed, 6 May 2020 17:12:26 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 046HCQt3048689; Wed, 6 May 2020 17:12:26 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 046HCQkw048688; Wed, 6 May 2020 17:12:26 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <202005061712.046HCQkw048688@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 6 May 2020 17:12: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: r360693 - stable/12/sys/mips/mips X-SVN-Group: stable-12 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/12/sys/mips/mips X-SVN-Commit-Revision: 360693 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 06 May 2020 17:12:27 -0000 Author: brooks Date: Wed May 6 17:12:26 2020 New Revision: 360693 URL: https://svnweb.freebsd.org/changeset/base/360693 Log: MFC r359974: Don't directly access userspace memory. Rather then using the racy useracc() followed by direct access to userspace memory, perform a copyin() and use the result if it succeeds. Reviewed by: jhb Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D24410 Modified: stable/12/sys/mips/mips/trap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/mips/mips/trap.c ============================================================================== --- stable/12/sys/mips/mips/trap.c Wed May 6 15:24:31 2020 (r360692) +++ stable/12/sys/mips/mips/trap.c Wed May 6 17:12:26 2020 (r360693) @@ -1404,7 +1404,7 @@ log_illegal_instruction(const char *msg, struct trapfr { pt_entry_t *ptep; pd_entry_t *pdep; - unsigned int *addr; + unsigned int *addr, instr[4]; struct thread *td; struct proc *p; register_t pc; @@ -1431,17 +1431,16 @@ log_illegal_instruction(const char *msg, struct trapfr * Dump a few words around faulting instruction, if the addres is * valid. */ - if (!(pc & 3) && - useracc((caddr_t)(intptr_t)pc, sizeof(int) * 4, VM_PROT_READ)) { + addr = (unsigned int *)(intptr_t)pc; + if ((pc & 3) == 0 && copyin(addr, instr, sizeof(instr)) == 0) { /* dump page table entry for faulting instruction */ log(LOG_ERR, "Page table info for pc address %#jx: pde = %p, pte = %#jx\n", (intmax_t)pc, (void *)(intptr_t)*pdep, (uintmax_t)(ptep ? *ptep : 0)); - addr = (unsigned int *)(intptr_t)pc; log(LOG_ERR, "Dumping 4 words starting at pc address %p: \n", addr); log(LOG_ERR, "%08x %08x %08x %08x\n", - addr[0], addr[1], addr[2], addr[3]); + instr[0], instr[1], instr[2], instr[3]); } else { log(LOG_ERR, "pc address %#jx is inaccessible, pde = %p, pte = %#jx\n", (intmax_t)pc, (void *)(intptr_t)*pdep, (uintmax_t)(ptep ? *ptep : 0)); @@ -1453,7 +1452,7 @@ log_bad_page_fault(char *msg, struct trapframe *frame, { pt_entry_t *ptep; pd_entry_t *pdep; - unsigned int *addr; + unsigned int *addr, instr[4]; struct thread *td; struct proc *p; char *read_or_write; @@ -1501,18 +1500,18 @@ log_bad_page_fault(char *msg, struct trapframe *frame, * Dump a few words around faulting instruction, if the addres is * valid. */ - if (!(pc & 3) && (pc != frame->badvaddr) && - (trap_type != T_BUS_ERR_IFETCH) && - useracc((caddr_t)(intptr_t)pc, sizeof(int) * 4, VM_PROT_READ)) { + addr = (unsigned int *)(intptr_t)pc; + if ((pc & 3) == 0 && pc != frame->badvaddr && + trap_type != T_BUS_ERR_IFETCH && + copyin((caddr_t)(intptr_t)pc, instr, sizeof(instr)) == 0) { /* dump page table entry for faulting instruction */ log(LOG_ERR, "Page table info for pc address %#jx: pde = %p, pte = %#jx\n", (intmax_t)pc, (void *)(intptr_t)*pdep, (uintmax_t)(ptep ? *ptep : 0)); - addr = (unsigned int *)(intptr_t)pc; log(LOG_ERR, "Dumping 4 words starting at pc address %p: \n", addr); log(LOG_ERR, "%08x %08x %08x %08x\n", - addr[0], addr[1], addr[2], addr[3]); + instr[0], instr[1], instr[2], instr[3]); } else { log(LOG_ERR, "pc address %#jx is inaccessible, pde = %p, pte = %#jx\n", (intmax_t)pc, (void *)(intptr_t)*pdep, (uintmax_t)(ptep ? *ptep : 0)); From owner-svn-src-stable-12@freebsd.org Wed May 6 19:50:29 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C94FD2DDF44; Wed, 6 May 2020 19:50:29 +0000 (UTC) (envelope-from mhorne@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 49HRys50fjz46N6; Wed, 6 May 2020 19:50:29 +0000 (UTC) (envelope-from mhorne@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 A6E2C4C05; Wed, 6 May 2020 19:50:29 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 046JoTkA042235; Wed, 6 May 2020 19:50:29 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 046JoRrA042224; Wed, 6 May 2020 19:50:27 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202005061950.046JoRrA042224@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Wed, 6 May 2020 19:50: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: r360703 - in stable/12/sys: arm/arm arm/include arm64/arm64 conf kern sys X-SVN-Group: stable-12 X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: in stable/12/sys: arm/arm arm/include arm64/arm64 conf kern sys X-SVN-Commit-Revision: 360703 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 06 May 2020 19:50:29 -0000 Author: mhorne Date: Wed May 6 19:50:27 2020 New Revision: 360703 URL: https://svnweb.freebsd.org/changeset/base/360703 Log: MFC r360082: Convert arm's physmem interface to MI code Added: stable/12/sys/kern/subr_physmem.c - copied, changed from r360702, stable/12/sys/arm/arm/physmem.c stable/12/sys/sys/physmem.h - copied unchanged from r360082, head/sys/sys/physmem.h Deleted: stable/12/sys/arm/arm/physmem.c stable/12/sys/arm/include/physmem.h Modified: stable/12/sys/arm/arm/machdep.c stable/12/sys/arm/arm/machdep_boot.c stable/12/sys/arm/arm/mp_machdep.c stable/12/sys/arm/arm/pmap-v6.c stable/12/sys/arm/include/md_var.h stable/12/sys/arm64/arm64/machdep.c stable/12/sys/arm64/arm64/pmap.c stable/12/sys/conf/files.arm stable/12/sys/conf/files.arm64 Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/arm/machdep.c ============================================================================== --- stable/12/sys/arm/arm/machdep.c Wed May 6 19:10:39 2020 (r360702) +++ stable/12/sys/arm/arm/machdep.c Wed May 6 19:50:27 2020 (r360703) @@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -82,7 +83,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -122,6 +122,9 @@ uint32_t cpu_reset_address = 0; int cold = 1; vm_offset_t vector_page; +/* The address at which the kernel was loaded. Set early in initarm(). */ +vm_paddr_t arm_physmem_kernaddr; + int (*_arm_memcpy)(void *, void *, int, int) = NULL; int (*_arm_bzero)(void *, int, int) = NULL; int _min_memcpy_size = 0; @@ -159,7 +162,6 @@ static void *delay_arg; #endif struct kva_md_info kmi; - /* * arm32_vector_init: * @@ -236,7 +238,7 @@ cpu_startup(void *dummy) (uintmax_t)arm32_ptob(vm_free_count()), (uintmax_t)arm32_ptob(vm_free_count()) / mbyte); if (bootverbose) { - arm_physmem_print_tables(); + physmem_print_tables(); devmap_print_table(); } @@ -868,11 +870,11 @@ initarm(struct arm_boot_params *abp) /* Grab physical memory regions information from device tree. */ if (fdt_get_mem_regions(mem_regions, &mem_regions_sz, &memsize) != 0) panic("Cannot get physical memory regions"); - arm_physmem_hardware_regions(mem_regions, mem_regions_sz); + physmem_hardware_regions(mem_regions, mem_regions_sz); /* Grab reserved memory regions information from device tree. */ if (fdt_get_reserved_regions(mem_regions, &mem_regions_sz) == 0) - arm_physmem_exclude_regions(mem_regions, mem_regions_sz, + physmem_exclude_regions(mem_regions, mem_regions_sz, EXFLAG_NODUMP | EXFLAG_NOALLOC); /* Platform-specific initialisation */ @@ -1079,9 +1081,9 @@ initarm(struct arm_boot_params *abp) * * Prepare the list of physical memory available to the vm subsystem. */ - arm_physmem_exclude_region(abp->abp_physaddr, + physmem_exclude_region(abp->abp_physaddr, (virtual_avail - KERNVIRTADDR), EXFLAG_NOALLOC); - arm_physmem_init_kernel_globals(); + physmem_init_kernel_globals(); init_param2(physmem); dbg_monitor_init(); @@ -1147,11 +1149,11 @@ initarm(struct arm_boot_params *abp) if (fdt_get_mem_regions(mem_regions, &mem_regions_sz,NULL) != 0) panic("Cannot get physical memory regions"); } - arm_physmem_hardware_regions(mem_regions, mem_regions_sz); + physmem_hardware_regions(mem_regions, mem_regions_sz); /* Grab reserved memory regions information from device tree. */ if (fdt_get_reserved_regions(mem_regions, &mem_regions_sz) == 0) - arm_physmem_exclude_regions(mem_regions, mem_regions_sz, + physmem_exclude_regions(mem_regions, mem_regions_sz, EXFLAG_NODUMP | EXFLAG_NOALLOC); /* @@ -1286,9 +1288,9 @@ initarm(struct arm_boot_params *abp) * * Prepare the list of physical memory available to the vm subsystem. */ - arm_physmem_exclude_region(abp->abp_physaddr, + physmem_exclude_region(abp->abp_physaddr, pmap_preboot_get_pages(0) - abp->abp_physaddr, EXFLAG_NOALLOC); - arm_physmem_init_kernel_globals(); + physmem_init_kernel_globals(); init_param2(physmem); /* Init message buffer. */ Modified: stable/12/sys/arm/arm/machdep_boot.c ============================================================================== --- stable/12/sys/arm/arm/machdep_boot.c Wed May 6 19:10:39 2020 (r360702) +++ stable/12/sys/arm/arm/machdep_boot.c Wed May 6 19:50:27 2020 (r360703) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #if defined(LINUX_BOOT_ABI) @@ -46,7 +47,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include /* For KERNVIRTADDR */ #ifdef FDT @@ -227,7 +227,7 @@ linux_parse_boot_param(struct arm_boot_params *abp) case ATAG_CORE: break; case ATAG_MEM: - arm_physmem_hardware_region(walker->u.tag_mem.start, + physmem_hardware_region(walker->u.tag_mem.start, walker->u.tag_mem.size); break; case ATAG_INITRD2: Modified: stable/12/sys/arm/arm/mp_machdep.c ============================================================================== --- stable/12/sys/arm/arm/mp_machdep.c Wed May 6 19:10:39 2020 (r360702) +++ stable/12/sys/arm/arm/mp_machdep.c Wed May 6 19:50:27 2020 (r360703) @@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #ifdef VFP Modified: stable/12/sys/arm/arm/pmap-v6.c ============================================================================== --- stable/12/sys/arm/arm/pmap-v6.c Wed May 6 19:10:39 2020 (r360702) +++ stable/12/sys/arm/arm/pmap-v6.c Wed May 6 19:50:27 2020 (r360703) @@ -117,8 +117,6 @@ __FBSDID("$FreeBSD$"); #include #endif -#include - #include #include #include Modified: stable/12/sys/arm/include/md_var.h ============================================================================== --- stable/12/sys/arm/include/md_var.h Wed May 6 19:10:39 2020 (r360702) +++ stable/12/sys/arm/include/md_var.h Wed May 6 19:50:27 2020 (r360703) @@ -42,6 +42,7 @@ extern uint32_t *vm_page_dump; extern int vm_page_dump_size; extern u_long elf_hwcap; extern u_long elf_hwcap2; +extern vm_paddr_t arm_physmem_kernaddr; extern int (*_arm_memcpy)(void *, void *, int, int); extern int (*_arm_bzero)(void *, int, int); Modified: stable/12/sys/arm64/arm64/machdep.c ============================================================================== --- stable/12/sys/arm64/arm64/machdep.c Wed May 6 19:10:39 2020 (r360702) +++ stable/12/sys/arm64/arm64/machdep.c Wed May 6 19:50:27 2020 (r360703) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -80,8 +81,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include - #ifdef VFP #include #endif @@ -764,7 +763,7 @@ exclude_efi_map_entry(struct efi_md *p) */ break; default: - arm_physmem_exclude_region(p->md_phys, p->md_pages * PAGE_SIZE, + physmem_exclude_region(p->md_phys, p->md_pages * PAGE_SIZE, EXFLAG_NOALLOC); } } @@ -795,7 +794,7 @@ add_efi_map_entry(struct efi_md *p) /* * We're allowed to use any entry with these types. */ - arm_physmem_hardware_region(p->md_phys, + physmem_hardware_region(p->md_phys, p->md_pages * PAGE_SIZE); break; } @@ -1029,10 +1028,10 @@ initarm(struct arm64_bootparams *abp) if (fdt_get_mem_regions(mem_regions, &mem_regions_sz, NULL) != 0) panic("Cannot get physical memory regions"); - arm_physmem_hardware_regions(mem_regions, mem_regions_sz); + physmem_hardware_regions(mem_regions, mem_regions_sz); } if (fdt_get_reserved_mem(mem_regions, &mem_regions_sz) == 0) - arm_physmem_exclude_regions(mem_regions, mem_regions_sz, + physmem_exclude_regions(mem_regions, mem_regions_sz, EXFLAG_NODUMP | EXFLAG_NOALLOC); #endif @@ -1040,7 +1039,7 @@ initarm(struct arm64_bootparams *abp) efifb = (struct efi_fb *)preload_search_info(kmdp, MODINFO_METADATA | MODINFOMD_EFI_FB); if (efifb != NULL) - arm_physmem_exclude_region(efifb->fb_addr, efifb->fb_size, + physmem_exclude_region(efifb->fb_addr, efifb->fb_size, EXFLAG_NOALLOC); /* Set the pcpu data, this is needed by pmap_bootstrap */ @@ -1069,7 +1068,7 @@ initarm(struct arm64_bootparams *abp) /* Exclude entries neexed in teh DMAP region, but not phys_avail */ if (efihdr != NULL) exclude_efi_map_entries(efihdr); - arm_physmem_init_kernel_globals(); + physmem_init_kernel_globals(); devmap_bootstrap(0, NULL); @@ -1096,7 +1095,7 @@ initarm(struct arm64_bootparams *abp) if (boothowto & RB_VERBOSE) { print_efi_map_entries(efihdr); - arm_physmem_print_tables(); + physmem_print_tables(); } early_boot = 0; Modified: stable/12/sys/arm64/arm64/pmap.c ============================================================================== --- stable/12/sys/arm64/arm64/pmap.c Wed May 6 19:10:39 2020 (r360702) +++ stable/12/sys/arm64/arm64/pmap.c Wed May 6 19:50:27 2020 (r360703) @@ -118,6 +118,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -147,8 +148,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include - #define NL0PG (PAGE_SIZE/(sizeof (pd_entry_t))) #define NL1PG (PAGE_SIZE/(sizeof (pd_entry_t))) #define NL2PG (PAGE_SIZE/(sizeof (pd_entry_t))) @@ -801,7 +800,7 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_ /* Assume the address we were loaded to is a valid physical address */ min_pa = KERNBASE - kern_delta; - physmap_idx = arm_physmem_avail(physmap, nitems(physmap)); + physmap_idx = physmem_avail(physmap, nitems(physmap)); physmap_idx /= 2; /* @@ -882,7 +881,7 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_ pa = pmap_early_vtophys(l1pt, freemempos); - arm_physmem_exclude_region(start_pa, pa - start_pa, EXFLAG_NOALLOC); + physmem_exclude_region(start_pa, pa - start_pa, EXFLAG_NOALLOC); cpu_tlb_flushID(); } Modified: stable/12/sys/conf/files.arm ============================================================================== --- stable/12/sys/conf/files.arm Wed May 6 19:10:39 2020 (r360702) +++ stable/12/sys/conf/files.arm Wed May 6 19:50:27 2020 (r360703) @@ -59,7 +59,6 @@ arm/arm/mp_machdep.c optional smp arm/arm/mpcore_timer.c optional mpcore_timer arm/arm/nexus.c standard arm/arm/ofw_machdep.c optional fdt -arm/arm/physmem.c standard arm/arm/pl190.c optional pl190 arm/arm/pl310.c optional pl310 arm/arm/platform.c optional platform @@ -128,6 +127,7 @@ kern/msi_if.m optional intrng kern/pic_if.m optional intrng kern/subr_busdma_bufalloc.c standard kern/subr_devmap.c standard +kern/subr_physmem.c standard kern/subr_sfbuf.c standard libkern/arm/aeabi_unwind.c standard libkern/arm/divsi3.S standard Modified: stable/12/sys/conf/files.arm64 ============================================================================== --- stable/12/sys/conf/files.arm64 Wed May 6 19:10:39 2020 (r360702) +++ stable/12/sys/conf/files.arm64 Wed May 6 19:50:27 2020 (r360703) @@ -79,7 +79,6 @@ arm/arm/gic.c standard arm/arm/gic_acpi.c optional acpi arm/arm/gic_fdt.c optional fdt arm/arm/pmu.c standard -arm/arm/physmem.c standard arm/broadcom/bcm2835/bcm2835_audio.c optional sound vchiq fdt \ compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" arm/broadcom/bcm2835/bcm2835_bsc.c optional bcm2835_bsc fdt @@ -263,6 +262,7 @@ kern/msi_if.m optional intrng kern/pic_if.m optional intrng kern/subr_devmap.c standard kern/subr_intr.c optional intrng +kern/subr_physmem.c standard libkern/bcmp.c standard libkern/ffs.c standard libkern/ffsl.c standard Copied and modified: stable/12/sys/kern/subr_physmem.c (from r360702, stable/12/sys/arm/arm/physmem.c) ============================================================================== --- stable/12/sys/arm/arm/physmem.c Wed May 6 19:10:39 2020 (r360702, copy source) +++ stable/12/sys/kern/subr_physmem.c Wed May 6 19:50:27 2020 (r360703) @@ -38,9 +38,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include -#include /* * These structures are used internally to keep track of regions of physical @@ -59,10 +59,8 @@ __FBSDID("$FreeBSD$"); #if defined(__arm__) #define MAX_PHYS_ADDR 0xFFFFFFFFull -#define pm_btop(x) arm32_btop(x) -#elif defined(__aarch64__) +#elif defined(__aarch64__) || defined(__riscv) #define MAX_PHYS_ADDR 0xFFFFFFFFFFFFFFFFull -#define pm_btop(x) arm64_btop(x) #endif struct region { @@ -110,9 +108,6 @@ vm_paddr_t dump_avail[MAX_AVAIL_ENTRIES + 2]; /* of ze long realmem; long Maxmem; -/* The address at which the kernel was loaded. Set early in initarm(). */ -vm_paddr_t arm_physmem_kernaddr; - /* * Print the contents of the physical and excluded region tables using the * provided printf-like output function (which will be either printf or @@ -159,7 +154,7 @@ physmem_dump_tables(int (*prfunc)(const char *, ...)) * Print the contents of the static mapping table. Used for bootverbose. */ void -arm_physmem_print_tables(void) +physmem_print_tables(void) { physmem_dump_tables(printf); @@ -188,7 +183,7 @@ regions_to_avail(vm_paddr_t *avail, uint32_t exflags, for (hwi = 0, hwp = hwregions; hwi < hwcnt; ++hwi, ++hwp) { start = hwp->addr; end = hwp->size + start; - totalmem += pm_btop((vm_offset_t)(end - start)); + totalmem += atop((vm_offset_t)(end - start)); for (exi = 0, exp = exregions; exi < excnt; ++exi, ++exp) { /* * If the excluded region does not match given flags, @@ -236,8 +231,7 @@ regions_to_avail(vm_paddr_t *avail, uint32_t exflags, avail[acnt++] = (vm_paddr_t)start; avail[acnt++] = (vm_paddr_t)xstart; } - availmem += - pm_btop((vm_offset_t)(xstart - start)); + availmem += atop((vm_offset_t)(xstart - start)); start = xend; continue; } @@ -262,7 +256,7 @@ regions_to_avail(vm_paddr_t *avail, uint32_t exflags, avail[acnt++] = (vm_paddr_t)start; avail[acnt++] = (vm_paddr_t)end; } - availmem += pm_btop((vm_offset_t)(end - start)); + availmem += atop((vm_offset_t)(end - start)); } if (acnt >= maxavail) panic("Not enough space in the dump/phys_avail arrays"); @@ -316,7 +310,7 @@ insert_region(struct region *regions, size_t rcnt, vm_ * Add a hardware memory region. */ void -arm_physmem_hardware_region(uint64_t pa, uint64_t sz) +physmem_hardware_region(uint64_t pa, uint64_t sz) { vm_offset_t adj; @@ -368,7 +362,7 @@ arm_physmem_hardware_region(uint64_t pa, uint64_t sz) * Add an exclusion region. */ void -arm_physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t exflags) +physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t exflags) { vm_offset_t adj; @@ -387,7 +381,7 @@ arm_physmem_exclude_region(vm_paddr_t pa, vm_size_t sz } size_t -arm_physmem_avail(vm_paddr_t *avail, size_t maxavail) +physmem_avail(vm_paddr_t *avail, size_t maxavail) { return (regions_to_avail(avail, EXFLAG_NOALLOC, maxavail, NULL, NULL)); @@ -403,7 +397,7 @@ arm_physmem_avail(vm_paddr_t *avail, size_t maxavail) * last page of physical memory in the system. */ void -arm_physmem_init_kernel_globals(void) +physmem_init_kernel_globals(void) { size_t nextidx; @@ -426,4 +420,3 @@ DB_SHOW_COMMAND(physmem, db_show_physmem) } #endif /* DDB */ - Copied: stable/12/sys/sys/physmem.h (from r360082, head/sys/sys/physmem.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/sys/physmem.h Wed May 6 19:50:27 2020 (r360703, copy of r360082, head/sys/sys/physmem.h) @@ -0,0 +1,88 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2014 Ian Lepore + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SYS_PHYSMEM_H_ +#define _SYS_PHYSMEM_H_ + +/* + * Routines to help configure physical ram. + * + * Multiple regions of contiguous physical ram can be added (in any order). + * + * Multiple regions of physical ram that should be excluded from crash dumps, or + * memory allocation, or both, can be added (in any order). + * + * After all early kernel init is done and it's time to configure all + * remainining non-excluded physical ram for use by other parts of the kernel, + * physmem_init_kernel_globals() processes the hardware regions and + * exclusion regions to generate the global dump_avail and phys_avail arrays + * that communicate physical ram configuration to other parts of the kernel. + */ + +#define EXFLAG_NODUMP 0x01 +#define EXFLAG_NOALLOC 0x02 + +void physmem_hardware_region(uint64_t pa, uint64_t sz); +void physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t flags); +size_t physmem_avail(vm_paddr_t *avail, size_t maxavail); +void physmem_init_kernel_globals(void); +void physmem_print_tables(void); + +/* + * Convenience routines for FDT. + */ + +#ifdef FDT + +#include + +static inline void +physmem_hardware_regions(struct mem_region * mrptr, int mrcount) +{ + while (mrcount--) { + physmem_hardware_region(mrptr->mr_start, mrptr->mr_size); + ++mrptr; + } +} + +static inline void +physmem_exclude_regions(struct mem_region * mrptr, int mrcount, + uint32_t exflags) +{ + while (mrcount--) { + physmem_exclude_region(mrptr->mr_start, mrptr->mr_size, + exflags); + ++mrptr; + } +} + +#endif /* FDT */ + +#endif /* !_SYS_PHYSMEM_H_ */ From owner-svn-src-stable-12@freebsd.org Wed May 6 19:58:38 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4F3842DE2D8; Wed, 6 May 2020 19:58:38 +0000 (UTC) (envelope-from mhorne@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 49HS8G1D8tz46yc; Wed, 6 May 2020 19:58:38 +0000 (UTC) (envelope-from mhorne@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 252434DF2; Wed, 6 May 2020 19:58:38 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 046JwcIB048609; Wed, 6 May 2020 19:58:38 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 046JwcIW048608; Wed, 6 May 2020 19:58:38 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202005061958.046JwcIW048608@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Wed, 6 May 2020 19:58: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: r360704 - stable/12/usr.sbin/binmiscctl X-SVN-Group: stable-12 X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: stable/12/usr.sbin/binmiscctl X-SVN-Commit-Revision: 360704 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 06 May 2020 19:58:38 -0000 Author: mhorne Date: Wed May 6 19:58:37 2020 New Revision: 360704 URL: https://svnweb.freebsd.org/changeset/base/360704 Log: MFC r360519: Add RISC-V interpreter example Modified: stable/12/usr.sbin/binmiscctl/binmiscctl.8 Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/binmiscctl/binmiscctl.8 ============================================================================== --- stable/12/usr.sbin/binmiscctl/binmiscctl.8 Wed May 6 19:50:27 2020 (r360703) +++ stable/12/usr.sbin/binmiscctl/binmiscctl.8 Wed May 6 19:58:37 2020 (r360704) @@ -27,7 +27,7 @@ .\" .\" Support for miscellaneous binary image activators .\" -.Dd July 21, 2018 +.Dd April 30, 2020 .Dt BINMISCCTL 8 .Os .Sh NAME @@ -280,6 +280,17 @@ Add QEMU bsd-user program as an image activator for SP \ex00\ex00\ex00\ex00\ex00\ex00\ex00\ex02\ex00\ex2b" \e --mask "\exff\exff\exff\exff\exff\exff\exff\ex00\exff\exff\e \exff\exff\exff\exff\exff\exff\exff\exfe\exff\exff" \e + --size 20 --set-enabled +.Ed +.Pp +Add QEMU bsd-user program as an image activator for 64-bit RISC-V binaries: +.Bd -literal -offset indent +# binmiscctl add riscv64 \e + --interpreter "/usr/local/bin/qemu-riscv64-static" \e + --magic "\ex7f\ex45\ex4c\ex46\ex02\ex01\ex01\ex00\ex00\ex00\e + \ex00\ex00\ex00\ex00\ex00\ex00\ex02\ex00\exf3\ex00" \e + --mask "\exff\exff\exff\exff\exff\exff\exff\ex00\exff\exff\e + \exff\exff\exff\exff\exff\exff\exfe\exff\exff\exff" \e --size 20 --set-enabled .Ed .Ss "Create and use an ARMv6 chroot on an AMD64 host" From owner-svn-src-stable-12@freebsd.org Wed May 6 22:20:40 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1B9242E0FF8; Wed, 6 May 2020 22:20:40 +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 49HWJ80HT6z4H66; Wed, 6 May 2020 22:20:40 +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 DD6DF687F; Wed, 6 May 2020 22:20:39 +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 046MKd1E035988; Wed, 6 May 2020 22:20:39 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 046MKbPd035977; Wed, 6 May 2020 22:20:37 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005062220.046MKbPd035977@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 6 May 2020 22:20: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: r360713 - in stable/12: lib/libvmmapi sys/amd64/include sys/amd64/vmm/amd sys/amd64/vmm/intel usr.sbin/bhyve X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/12: lib/libvmmapi sys/amd64/include sys/amd64/vmm/amd sys/amd64/vmm/intel usr.sbin/bhyve X-SVN-Commit-Revision: 360713 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 06 May 2020 22:20:40 -0000 Author: jhb Date: Wed May 6 22:20:37 2020 New Revision: 360713 URL: https://svnweb.freebsd.org/changeset/base/360713 Log: MFC 355724,360166: Software breakpoints on Intel CPUs. 355724: Support software breakpoints in the debug server on Intel CPUs. - Allow the userland hypervisor to intercept breakpoint exceptions (BP#) in the guest. A new capability (VM_CAP_BPT_EXIT) is used to enable this feature. These exceptions are reported to userland via a new VM_EXITCODE_BPT that includes the length of the original breakpoint instruction. If userland wishes to pass the exception through to the guest, it must be explicitly re-injected via vm_inject_exception(). - Export VMCS_ENTRY_INST_LENGTH as a VM_REG_GUEST_ENTRY_INST_LENGTH pseudo-register. Injecting a BP# on Intel requires setting this to the length of the breakpoint instruction. AMD SVM currently ignores writes to this register (but reports success) and fails to read it. - Rework the per-vCPU state tracked by the debug server. Rather than a single 'stepping_vcpu' global, add a structure for each vCPU that tracks state about that vCPU ('stepping', 'stepped', and 'hit_swbreak'). A global 'stopped_vcpu' tracks which vCPU is currently reporting an event. Event handlers for MTRAP and breakpoint exits loop until the associated event is reported to the debugger. Breakpoint events are discarded if the breakpoint is not present when a vCPU resumes in the breakpoint handler to retry submitting the breakpoint event. - Maintain a linked-list of active breakpoints in response to the GDB 'Z0' and 'z0' packets. 360166: Add description string for VM_CAP_BPT_EXIT. While here, replace the array of mapping structures with an array of string pointers where the index is the capability value. Modified: stable/12/lib/libvmmapi/vmmapi.c stable/12/sys/amd64/include/vmm.h stable/12/sys/amd64/vmm/amd/svm.c stable/12/sys/amd64/vmm/intel/vmcs.c stable/12/sys/amd64/vmm/intel/vmx.c stable/12/sys/amd64/vmm/intel/vmx.h stable/12/usr.sbin/bhyve/bhyve.8 stable/12/usr.sbin/bhyve/bhyverun.c stable/12/usr.sbin/bhyve/gdb.c stable/12/usr.sbin/bhyve/gdb.h Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libvmmapi/vmmapi.c ============================================================================== --- stable/12/lib/libvmmapi/vmmapi.c Wed May 6 22:18:24 2020 (r360712) +++ stable/12/lib/libvmmapi/vmmapi.c Wed May 6 22:20:37 2020 (r360713) @@ -812,16 +812,13 @@ vm_inject_nmi(struct vmctx *ctx, int vcpu) return (ioctl(ctx->fd, VM_INJECT_NMI, &vmnmi)); } -static struct { - const char *name; - int type; -} capstrmap[] = { - { "hlt_exit", VM_CAP_HALT_EXIT }, - { "mtrap_exit", VM_CAP_MTRAP_EXIT }, - { "pause_exit", VM_CAP_PAUSE_EXIT }, - { "unrestricted_guest", VM_CAP_UNRESTRICTED_GUEST }, - { "enable_invpcid", VM_CAP_ENABLE_INVPCID }, - { 0 } +static const char *capstrmap[] = { + [VM_CAP_HALT_EXIT] = "hlt_exit", + [VM_CAP_MTRAP_EXIT] = "mtrap_exit", + [VM_CAP_PAUSE_EXIT] = "pause_exit", + [VM_CAP_UNRESTRICTED_GUEST] = "unrestricted_guest", + [VM_CAP_ENABLE_INVPCID] = "enable_invpcid", + [VM_CAP_BPT_EXIT] = "bpt_exit", }; int @@ -829,9 +826,9 @@ vm_capability_name2type(const char *capname) { int i; - for (i = 0; capstrmap[i].name != NULL && capname != NULL; i++) { - if (strcmp(capstrmap[i].name, capname) == 0) - return (capstrmap[i].type); + for (i = 0; i < nitems(capstrmap); i++) { + if (strcmp(capstrmap[i], capname) == 0) + return (i); } return (-1); @@ -840,12 +837,8 @@ vm_capability_name2type(const char *capname) const char * vm_capability_type2name(int type) { - int i; - - for (i = 0; capstrmap[i].name != NULL; i++) { - if (capstrmap[i].type == type) - return (capstrmap[i].name); - } + if (type < nitems(capstrmap)) + return (capstrmap[type]); return (NULL); } Modified: stable/12/sys/amd64/include/vmm.h ============================================================================== --- stable/12/sys/amd64/include/vmm.h Wed May 6 22:18:24 2020 (r360712) +++ stable/12/sys/amd64/include/vmm.h Wed May 6 22:20:37 2020 (r360713) @@ -95,6 +95,7 @@ enum vm_reg_name { VM_REG_GUEST_DR2, VM_REG_GUEST_DR3, VM_REG_GUEST_DR6, + VM_REG_GUEST_ENTRY_INST_LENGTH, VM_REG_LAST }; @@ -434,6 +435,7 @@ enum vm_cap_type { VM_CAP_PAUSE_EXIT, VM_CAP_UNRESTRICTED_GUEST, VM_CAP_ENABLE_INVPCID, + VM_CAP_BPT_EXIT, VM_CAP_MAX }; @@ -559,6 +561,7 @@ enum vm_exitcode { VM_EXITCODE_REQIDLE, VM_EXITCODE_DEBUG, VM_EXITCODE_VMINSN, + VM_EXITCODE_BPT, VM_EXITCODE_MAX }; @@ -645,6 +648,9 @@ struct vm_exit { uint64_t exitinfo1; uint64_t exitinfo2; } svm; + struct { + int inst_length; + } bpt; struct { uint32_t code; /* ecx value */ uint64_t wval; Modified: stable/12/sys/amd64/vmm/amd/svm.c ============================================================================== --- stable/12/sys/amd64/vmm/amd/svm.c Wed May 6 22:18:24 2020 (r360712) +++ stable/12/sys/amd64/vmm/amd/svm.c Wed May 6 22:20:37 2020 (r360713) @@ -2187,6 +2187,11 @@ svm_setreg(void *arg, int vcpu, int ident, uint64_t va return (0); } + if (ident == VM_REG_GUEST_ENTRY_INST_LENGTH) { + /* Ignore. */ + return (0); + } + /* * XXX deal with CR3 and invalidate TLB entries tagged with the * vcpu's ASID. This needs to be treated differently depending on Modified: stable/12/sys/amd64/vmm/intel/vmcs.c ============================================================================== --- stable/12/sys/amd64/vmm/intel/vmcs.c Wed May 6 22:18:24 2020 (r360712) +++ stable/12/sys/amd64/vmm/intel/vmcs.c Wed May 6 22:20:37 2020 (r360713) @@ -120,6 +120,8 @@ vmcs_field_encoding(int ident) return (VMCS_GUEST_PDPTE2); case VM_REG_GUEST_PDPTE3: return (VMCS_GUEST_PDPTE3); + case VM_REG_GUEST_ENTRY_INST_LENGTH: + return (VMCS_ENTRY_INST_LENGTH); default: return (-1); } Modified: stable/12/sys/amd64/vmm/intel/vmx.c ============================================================================== --- stable/12/sys/amd64/vmm/intel/vmx.c Wed May 6 22:18:24 2020 (r360712) +++ stable/12/sys/amd64/vmm/intel/vmx.c Wed May 6 22:20:37 2020 (r360713) @@ -1085,6 +1085,7 @@ vmx_vminit(struct vm *vm, pmap_t pmap) vmx->cap[i].set = 0; vmx->cap[i].proc_ctls = procbased_ctls; vmx->cap[i].proc_ctls2 = procbased_ctls2; + vmx->cap[i].exc_bitmap = exc_bitmap; vmx->state[i].nextrip = ~0; vmx->state[i].lastcpu = NOCPU; @@ -2561,6 +2562,18 @@ vmx_exit_process(struct vmx *vmx, int vcpu, struct vm_ return (1); } + /* + * If the hypervisor has requested user exits for + * debug exceptions, bounce them out to userland. + */ + if (intr_type == VMCS_INTR_T_SWEXCEPTION && intr_vec == IDT_BP && + (vmx->cap[vcpu].set & (1 << VM_CAP_BPT_EXIT))) { + vmexit->exitcode = VM_EXITCODE_BPT; + vmexit->u.bpt.inst_length = vmexit->inst_length; + vmexit->inst_length = 0; + break; + } + if (intr_vec == IDT_PF) { error = vmxctx_setreg(vmxctx, VM_REG_GUEST_CR2, qual); KASSERT(error == 0, ("%s: vmxctx_setreg(cr2) error %d", @@ -3326,6 +3339,9 @@ vmx_getcap(void *arg, int vcpu, int type, int *retval) if (cap_invpcid) ret = 0; break; + case VM_CAP_BPT_EXIT: + ret = 0; + break; default: break; } @@ -3397,11 +3413,25 @@ vmx_setcap(void *arg, int vcpu, int type, int val) reg = VMCS_SEC_PROC_BASED_CTLS; } break; + case VM_CAP_BPT_EXIT: + retval = 0; + + /* Don't change the bitmap if we are tracing all exceptions. */ + if (vmx->cap[vcpu].exc_bitmap != 0xffffffff) { + pptr = &vmx->cap[vcpu].exc_bitmap; + baseval = *pptr; + flag = (1 << IDT_BP); + reg = VMCS_EXCEPTION_BITMAP; + } + break; default: break; } - if (retval == 0) { + if (retval) + return (retval); + + if (pptr != NULL) { if (val) { baseval |= flag; } else { @@ -3411,26 +3441,23 @@ vmx_setcap(void *arg, int vcpu, int type, int val) error = vmwrite(reg, baseval); VMCLEAR(vmcs); - if (error) { - retval = error; - } else { - /* - * Update optional stored flags, and record - * setting - */ - if (pptr != NULL) { - *pptr = baseval; - } + if (error) + return (error); - if (val) { - vmx->cap[vcpu].set |= (1 << type); - } else { - vmx->cap[vcpu].set &= ~(1 << type); - } - } + /* + * Update optional stored flags, and record + * setting + */ + *pptr = baseval; } - return (retval); + if (val) { + vmx->cap[vcpu].set |= (1 << type); + } else { + vmx->cap[vcpu].set &= ~(1 << type); + } + + return (0); } struct vlapic_vtx { Modified: stable/12/sys/amd64/vmm/intel/vmx.h ============================================================================== --- stable/12/sys/amd64/vmm/intel/vmx.h Wed May 6 22:18:24 2020 (r360712) +++ stable/12/sys/amd64/vmm/intel/vmx.h Wed May 6 22:20:37 2020 (r360713) @@ -87,6 +87,7 @@ struct vmxcap { int set; uint32_t proc_ctls; uint32_t proc_ctls2; + uint32_t exc_bitmap; }; struct vmxstate { Modified: stable/12/usr.sbin/bhyve/bhyve.8 ============================================================================== --- stable/12/usr.sbin/bhyve/bhyve.8 Wed May 6 22:18:24 2020 (r360712) +++ stable/12/usr.sbin/bhyve/bhyve.8 Wed May 6 22:20:37 2020 (r360713) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 11, 2018 +.Dd December 13, 2019 .Dt BHYVE 8 .Os .Sh NAME @@ -519,7 +519,10 @@ The running guest can be interrupted by the debugger a .Pp Single stepping is only supported on Intel CPUs supporting the MTRAP VM exit. .Pp -Breakpoints are not supported. +Breakpoints are supported on Intel CPUs that support single stepping. +Note that continuing from a breakpoint while interrupts are enabled in the +guest may not work as expected due to timer interrupts firing while single +stepping over the breakpoint. .Sh SIGNAL HANDLING .Nm deals with the following signals: Modified: stable/12/usr.sbin/bhyve/bhyverun.c ============================================================================== --- stable/12/usr.sbin/bhyve/bhyverun.c Wed May 6 22:18:24 2020 (r360712) +++ stable/12/usr.sbin/bhyve/bhyverun.c Wed May 6 22:20:37 2020 (r360713) @@ -785,6 +785,18 @@ vmexit_debug(struct vmctx *ctx, struct vm_exit *vmexit return (VMEXIT_CONTINUE); } +static int +vmexit_breakpoint(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) +{ + + if (gdb_port == 0) { + fprintf(stderr, "vm_loop: unexpected VMEXIT_DEBUG\n"); + exit(4); + } + gdb_cpu_breakpoint(*pvcpu, vmexit); + return (VMEXIT_CONTINUE); +} + static vmexit_handler_t handler[VM_EXITCODE_MAX] = { [VM_EXITCODE_INOUT] = vmexit_inout, [VM_EXITCODE_INOUT_STR] = vmexit_inout, @@ -800,6 +812,7 @@ static vmexit_handler_t handler[VM_EXITCODE_MAX] = { [VM_EXITCODE_SUSPENDED] = vmexit_suspend, [VM_EXITCODE_TASK_SWITCH] = vmexit_task_switch, [VM_EXITCODE_DEBUG] = vmexit_debug, + [VM_EXITCODE_BPT] = vmexit_breakpoint, }; static void Modified: stable/12/usr.sbin/bhyve/gdb.c ============================================================================== --- stable/12/usr.sbin/bhyve/gdb.c Wed May 6 22:18:24 2020 (r360712) +++ stable/12/usr.sbin/bhyve/gdb.c Wed May 6 22:20:37 2020 (r360713) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -59,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include "bhyverun.h" +#include "gdb.h" #include "mem.h" #include "mevent.h" @@ -76,8 +78,7 @@ static struct mevent *read_event, *write_event; static cpuset_t vcpus_active, vcpus_suspended, vcpus_waiting; static pthread_mutex_t gdb_lock; static pthread_cond_t idle_vcpus; -static bool stop_pending, first_stop; -static int stepping_vcpu, stopped_vcpu; +static bool first_stop, report_next_stop, swbreak_enabled; /* * An I/O buffer contains 'capacity' bytes of room at 'data'. For a @@ -93,11 +94,44 @@ struct io_buffer { size_t len; }; +struct breakpoint { + uint64_t gpa; + uint8_t shadow_inst; + TAILQ_ENTRY(breakpoint) link; +}; + +/* + * When a vCPU stops to due to an event that should be reported to the + * debugger, information about the event is stored in this structure. + * The vCPU thread then sets 'stopped_vcpu' if it is not already set + * and stops other vCPUs so the event can be reported. The + * report_stop() function reports the event for the 'stopped_vcpu' + * vCPU. When the debugger resumes execution via continue or step, + * the event for 'stopped_vcpu' is cleared. vCPUs will loop in their + * event handlers until the associated event is reported or disabled. + * + * An idle vCPU will have all of the boolean fields set to false. + * + * When a vCPU is stepped, 'stepping' is set to true when the vCPU is + * released to execute the stepped instruction. When the vCPU reports + * the stepping trap, 'stepped' is set. + * + * When a vCPU hits a breakpoint set by the debug server, + * 'hit_swbreak' is set to true. + */ +struct vcpu_state { + bool stepping; + bool stepped; + bool hit_swbreak; +}; + static struct io_buffer cur_comm, cur_resp; static uint8_t cur_csum; -static int cur_vcpu; static struct vmctx *ctx; static int cur_fd = -1; +static TAILQ_HEAD(, breakpoint) breakpoints; +static struct vcpu_state *vcpu_state; +static int cur_vcpu, stopped_vcpu; const int gdb_regset[] = { VM_REG_GUEST_RAX, @@ -184,6 +218,8 @@ debug(const char *fmt, ...) #define debug(...) #endif +static void remove_all_sw_breakpoints(void); + static int guest_paging_info(int vcpu, struct vm_guest_paging *paging) { @@ -352,6 +388,11 @@ close_connection(void) io_buffer_reset(&cur_resp); cur_fd = -1; + remove_all_sw_breakpoints(); + + /* Clear any pending events. */ + memset(vcpu_state, 0, guest_ncpus * sizeof(*vcpu_state)); + /* Resume any stopped vCPUs. */ gdb_resume_vcpus(); pthread_mutex_unlock(&gdb_lock); @@ -557,7 +598,7 @@ append_integer(unsigned int value) if (value == 0) append_char('0'); else - append_unsigned_be(value, fls(value) + 7 / 8); + append_unsigned_be(value, (fls(value) + 7) / 8); } static void @@ -610,40 +651,81 @@ parse_threadid(const uint8_t *data, size_t len) return (parse_integer(data, len)); } +/* + * Report the current stop event to the debugger. If the stop is due + * to an event triggered on a specific vCPU such as a breakpoint or + * stepping trap, stopped_vcpu will be set to the vCPU triggering the + * stop. If 'set_cur_vcpu' is true, then cur_vcpu will be updated to + * the reporting vCPU for vCPU events. + */ static void -report_stop(void) +report_stop(bool set_cur_vcpu) { + struct vcpu_state *vs; start_packet(); - if (stopped_vcpu == -1) + if (stopped_vcpu == -1) { append_char('S'); - else + append_byte(GDB_SIGNAL_TRAP); + } else { + vs = &vcpu_state[stopped_vcpu]; + if (set_cur_vcpu) + cur_vcpu = stopped_vcpu; append_char('T'); - append_byte(GDB_SIGNAL_TRAP); - if (stopped_vcpu != -1) { + append_byte(GDB_SIGNAL_TRAP); append_string("thread:"); append_integer(stopped_vcpu + 1); append_char(';'); + if (vs->hit_swbreak) { + debug("$vCPU %d reporting swbreak\n", stopped_vcpu); + if (swbreak_enabled) + append_string("swbreak:;"); + } else if (vs->stepped) + debug("$vCPU %d reporting step\n", stopped_vcpu); + else + debug("$vCPU %d reporting ???\n", stopped_vcpu); } - stopped_vcpu = -1; finish_packet(); + report_next_stop = false; } +/* + * If this stop is due to a vCPU event, clear that event to mark it as + * acknowledged. + */ static void +discard_stop(void) +{ + struct vcpu_state *vs; + + if (stopped_vcpu != -1) { + vs = &vcpu_state[stopped_vcpu]; + vs->hit_swbreak = false; + vs->stepped = false; + stopped_vcpu = -1; + } + report_next_stop = true; +} + +static void gdb_finish_suspend_vcpus(void) { if (first_stop) { first_stop = false; stopped_vcpu = -1; - } else if (response_pending()) - stop_pending = true; - else { - report_stop(); + } else if (report_next_stop) { + assert(!response_pending()); + report_stop(true); send_pending_data(cur_fd); } } +/* + * vCPU threads invoke this function whenever the vCPU enters the + * debug server to pause or report an event. vCPU threads wait here + * as long as the debug server keeps them suspended. + */ static void _gdb_cpu_suspend(int vcpu, bool report_stop) { @@ -652,19 +734,28 @@ _gdb_cpu_suspend(int vcpu, bool report_stop) CPU_SET(vcpu, &vcpus_waiting); if (report_stop && CPU_CMP(&vcpus_waiting, &vcpus_suspended) == 0) gdb_finish_suspend_vcpus(); - while (CPU_ISSET(vcpu, &vcpus_suspended) && vcpu != stepping_vcpu) + while (CPU_ISSET(vcpu, &vcpus_suspended)) pthread_cond_wait(&idle_vcpus, &gdb_lock); CPU_CLR(vcpu, &vcpus_waiting); debug("$vCPU %d resuming\n", vcpu); } +/* + * Invoked at the start of a vCPU thread's execution to inform the + * debug server about the new thread. + */ void gdb_cpu_add(int vcpu) { debug("$vCPU %d starting\n", vcpu); pthread_mutex_lock(&gdb_lock); + assert(vcpu < guest_ncpus); CPU_SET(vcpu, &vcpus_active); + if (!TAILQ_EMPTY(&breakpoints)) { + vm_set_capability(ctx, vcpu, VM_CAP_BPT_EXIT, 1); + debug("$vCPU %d enabled breakpoint exits\n", vcpu); + } /* * If a vcpu is added while vcpus are stopped, suspend the new @@ -678,44 +769,149 @@ gdb_cpu_add(int vcpu) pthread_mutex_unlock(&gdb_lock); } +/* + * Invoked by vCPU before resuming execution. This enables stepping + * if the vCPU is marked as stepping. + */ +static void +gdb_cpu_resume(int vcpu) +{ + struct vcpu_state *vs; + int error; + + vs = &vcpu_state[vcpu]; + + /* + * Any pending event should already be reported before + * resuming. + */ + assert(vs->hit_swbreak == false); + assert(vs->stepped == false); + if (vs->stepping) { + error = vm_set_capability(ctx, vcpu, VM_CAP_MTRAP_EXIT, 1); + assert(error == 0); + } +} + +/* + * Handler for VM_EXITCODE_DEBUG used to suspend a vCPU when the guest + * has been suspended due to an event on different vCPU or in response + * to a guest-wide suspend such as Ctrl-C or the stop on attach. + */ void gdb_cpu_suspend(int vcpu) { pthread_mutex_lock(&gdb_lock); _gdb_cpu_suspend(vcpu, true); + gdb_cpu_resume(vcpu); pthread_mutex_unlock(&gdb_lock); } +static void +gdb_suspend_vcpus(void) +{ + + assert(pthread_mutex_isowned_np(&gdb_lock)); + debug("suspending all CPUs\n"); + vcpus_suspended = vcpus_active; + vm_suspend_cpu(ctx, -1); + if (CPU_CMP(&vcpus_waiting, &vcpus_suspended) == 0) + gdb_finish_suspend_vcpus(); +} + +/* + * Handler for VM_EXITCODE_MTRAP reported when a vCPU single-steps via + * the VT-x-specific MTRAP exit. + */ void gdb_cpu_mtrap(int vcpu) { + struct vcpu_state *vs; debug("$vCPU %d MTRAP\n", vcpu); pthread_mutex_lock(&gdb_lock); - if (vcpu == stepping_vcpu) { - stepping_vcpu = -1; + vs = &vcpu_state[vcpu]; + if (vs->stepping) { + vs->stepping = false; + vs->stepped = true; vm_set_capability(ctx, vcpu, VM_CAP_MTRAP_EXIT, 0); - vm_suspend_cpu(ctx, vcpu); - assert(stopped_vcpu == -1); - stopped_vcpu = vcpu; - _gdb_cpu_suspend(vcpu, true); + while (vs->stepped) { + if (stopped_vcpu == -1) { + debug("$vCPU %d reporting step\n", vcpu); + stopped_vcpu = vcpu; + gdb_suspend_vcpus(); + } + _gdb_cpu_suspend(vcpu, true); + } + gdb_cpu_resume(vcpu); } pthread_mutex_unlock(&gdb_lock); } -static void -gdb_suspend_vcpus(void) +static struct breakpoint * +find_breakpoint(uint64_t gpa) { + struct breakpoint *bp; - assert(pthread_mutex_isowned_np(&gdb_lock)); - debug("suspending all CPUs\n"); - vcpus_suspended = vcpus_active; - vm_suspend_cpu(ctx, -1); - if (CPU_CMP(&vcpus_waiting, &vcpus_suspended) == 0) - gdb_finish_suspend_vcpus(); + TAILQ_FOREACH(bp, &breakpoints, link) { + if (bp->gpa == gpa) + return (bp); + } + return (NULL); } +void +gdb_cpu_breakpoint(int vcpu, struct vm_exit *vmexit) +{ + struct breakpoint *bp; + struct vcpu_state *vs; + uint64_t gpa; + int error; + + pthread_mutex_lock(&gdb_lock); + error = guest_vaddr2paddr(vcpu, vmexit->rip, &gpa); + assert(error == 1); + bp = find_breakpoint(gpa); + if (bp != NULL) { + vs = &vcpu_state[vcpu]; + assert(vs->stepping == false); + assert(vs->stepped == false); + assert(vs->hit_swbreak == false); + vs->hit_swbreak = true; + vm_set_register(ctx, vcpu, VM_REG_GUEST_RIP, vmexit->rip); + for (;;) { + if (stopped_vcpu == -1) { + debug("$vCPU %d reporting breakpoint at rip %#lx\n", vcpu, + vmexit->rip); + stopped_vcpu = vcpu; + gdb_suspend_vcpus(); + } + _gdb_cpu_suspend(vcpu, true); + if (!vs->hit_swbreak) { + /* Breakpoint reported. */ + break; + } + bp = find_breakpoint(gpa); + if (bp == NULL) { + /* Breakpoint was removed. */ + vs->hit_swbreak = false; + break; + } + } + gdb_cpu_resume(vcpu); + } else { + debug("$vCPU %d injecting breakpoint at rip %#lx\n", vcpu, + vmexit->rip); + error = vm_set_register(ctx, vcpu, + VM_REG_GUEST_ENTRY_INST_LENGTH, vmexit->u.bpt.inst_length); + assert(error == 0); + error = vm_inject_exception(ctx, vcpu, IDT_BP, 0, 0, 0); + assert(error == 0); + } + pthread_mutex_unlock(&gdb_lock); +} + static bool gdb_step_vcpu(int vcpu) { @@ -725,9 +921,11 @@ gdb_step_vcpu(int vcpu) error = vm_get_capability(ctx, vcpu, VM_CAP_MTRAP_EXIT, &val); if (error < 0) return (false); - error = vm_set_capability(ctx, vcpu, VM_CAP_MTRAP_EXIT, 1); + + discard_stop(); + vcpu_state[vcpu].stepping = true; vm_resume_cpu(ctx, vcpu); - stepping_vcpu = vcpu; + CPU_CLR(vcpu, &vcpus_suspended); pthread_cond_broadcast(&idle_vcpus); return (true); } @@ -982,6 +1180,174 @@ gdb_write_mem(const uint8_t *data, size_t len) } static bool +set_breakpoint_caps(bool enable) +{ + cpuset_t mask; + int vcpu; + + mask = vcpus_active; + while (!CPU_EMPTY(&mask)) { + vcpu = CPU_FFS(&mask) - 1; + CPU_CLR(vcpu, &mask); + if (vm_set_capability(ctx, vcpu, VM_CAP_BPT_EXIT, + enable ? 1 : 0) < 0) + return (false); + debug("$vCPU %d %sabled breakpoint exits\n", vcpu, + enable ? "en" : "dis"); + } + return (true); +} + +static void +remove_all_sw_breakpoints(void) +{ + struct breakpoint *bp, *nbp; + uint8_t *cp; + + if (TAILQ_EMPTY(&breakpoints)) + return; + + TAILQ_FOREACH_SAFE(bp, &breakpoints, link, nbp) { + debug("remove breakpoint at %#lx\n", bp->gpa); + cp = paddr_guest2host(ctx, bp->gpa, 1); + *cp = bp->shadow_inst; + TAILQ_REMOVE(&breakpoints, bp, link); + free(bp); + } + TAILQ_INIT(&breakpoints); + set_breakpoint_caps(false); +} + +static void +update_sw_breakpoint(uint64_t gva, int kind, bool insert) +{ + struct breakpoint *bp; + uint64_t gpa; + uint8_t *cp; + int error; + + if (kind != 1) { + send_error(EINVAL); + return; + } + + error = guest_vaddr2paddr(cur_vcpu, gva, &gpa); + if (error == -1) { + send_error(errno); + return; + } + if (error == 0) { + send_error(EFAULT); + return; + } + + cp = paddr_guest2host(ctx, gpa, 1); + + /* Only permit breakpoints in guest RAM. */ + if (cp == NULL) { + send_error(EFAULT); + return; + } + + /* Find any existing breakpoint. */ + bp = find_breakpoint(gpa); + + /* + * Silently ignore duplicate commands since the protocol + * requires these packets to be idempotent. + */ + if (insert) { + if (bp == NULL) { + if (TAILQ_EMPTY(&breakpoints) && + !set_breakpoint_caps(true)) { + send_empty_response(); + return; + } + bp = malloc(sizeof(*bp)); + bp->gpa = gpa; + bp->shadow_inst = *cp; + *cp = 0xcc; /* INT 3 */ + TAILQ_INSERT_TAIL(&breakpoints, bp, link); + debug("new breakpoint at %#lx\n", gpa); + } + } else { + if (bp != NULL) { + debug("remove breakpoint at %#lx\n", gpa); + *cp = bp->shadow_inst; + TAILQ_REMOVE(&breakpoints, bp, link); + free(bp); + if (TAILQ_EMPTY(&breakpoints)) + set_breakpoint_caps(false); + } + } + send_ok(); +} + +static void +parse_breakpoint(const uint8_t *data, size_t len) +{ + uint64_t gva; + uint8_t *cp; + bool insert; + int kind, type; + + insert = data[0] == 'Z'; + + /* Skip 'Z/z' */ + data += 1; + len -= 1; + + /* Parse and consume type. */ + cp = memchr(data, ',', len); + if (cp == NULL || cp == data) { + send_error(EINVAL); + return; + } + type = parse_integer(data, cp - data); + len -= (cp - data) + 1; + data += (cp - data) + 1; + + /* Parse and consume address. */ + cp = memchr(data, ',', len); + if (cp == NULL || cp == data) { + send_error(EINVAL); + return; + } + gva = parse_integer(data, cp - data); + len -= (cp - data) + 1; + data += (cp - data) + 1; + + /* Parse and consume kind. */ + cp = memchr(data, ';', len); + if (cp == data) { + send_error(EINVAL); + return; + } + if (cp != NULL) { + /* + * We do not advertise support for either the + * ConditionalBreakpoints or BreakpointCommands + * features, so we should not be getting conditions or + * commands from the remote end. + */ + send_empty_response(); + return; + } + kind = parse_integer(data, len); + data += len; + len = 0; + + switch (type) { + case 0: + update_sw_breakpoint(gva, kind, insert); + break; + default: + send_empty_response(); + break; + } +} + +static bool command_equals(const uint8_t *data, size_t len, const char *cmd) { @@ -1039,7 +1405,8 @@ check_features(const uint8_t *data, size_t len) value = NULL; } - /* No currently supported features. */ + if (strcmp(feature, "swbreak") == 0) + swbreak_enabled = supported; } free(str); @@ -1047,6 +1414,7 @@ check_features(const uint8_t *data, size_t len) /* This is an arbitrary limit. */ append_string("PacketSize=4096"); + append_string(";swbreak+"); finish_packet(); } @@ -1140,7 +1508,7 @@ handle_command(const uint8_t *data, size_t len) break; } - /* Don't send a reply until a stop occurs. */ + discard_stop(); gdb_resume_vcpus(); break; case 'D': @@ -1212,13 +1580,12 @@ handle_command(const uint8_t *data, size_t len) break; } break; + case 'z': + case 'Z': + parse_breakpoint(data, len); + break; case '?': - /* XXX: Only if stopped? */ - /* For now, just report that we are always stopped. */ - start_packet(); - append_char('S'); - append_byte(GDB_SIGNAL_TRAP); - finish_packet(); + report_stop(false); break; case 'G': /* TODO */ case 'v': @@ -1229,8 +1596,6 @@ handle_command(const uint8_t *data, size_t len) case 'Q': /* TODO */ case 't': /* TODO */ case 'X': /* TODO */ - case 'z': /* TODO */ - case 'Z': /* TODO */ default: send_empty_response(); } @@ -1261,9 +1626,8 @@ check_command(int fd) if (response_pending()) io_buffer_reset(&cur_resp); io_buffer_consume(&cur_comm, 1); - if (stop_pending) { - stop_pending = false; - report_stop(); + if (stopped_vcpu != -1 && report_next_stop) { + report_stop(true); send_pending_data(fd); } break; @@ -1417,12 +1781,11 @@ new_connection(int fd, enum ev_type event, void *arg) cur_fd = s; cur_vcpu = 0; - stepping_vcpu = -1; stopped_vcpu = -1; - stop_pending = false; /* Break on attach. */ first_stop = true; + report_next_stop = false; gdb_suspend_vcpus(); pthread_mutex_unlock(&gdb_lock); } @@ -1474,6 +1837,9 @@ init_gdb(struct vmctx *_ctx, int sport, bool wait) if (listen(s, 1) < 0) err(1, "gdb socket listen"); + stopped_vcpu = -1; + TAILQ_INIT(&breakpoints); + vcpu_state = calloc(guest_ncpus, sizeof(*vcpu_state)); if (wait) { /* * Set vcpu 0 in vcpus_suspended. This will trigger the @@ -1481,9 +1847,8 @@ init_gdb(struct vmctx *_ctx, int sport, bool wait) * it starts execution. The vcpu will remain suspended * until a debugger connects. */ - stepping_vcpu = -1; - stopped_vcpu = -1; CPU_SET(0, &vcpus_suspended); + stopped_vcpu = 0; } flags = fcntl(s, F_GETFL); Modified: stable/12/usr.sbin/bhyve/gdb.h ============================================================================== --- stable/12/usr.sbin/bhyve/gdb.h Wed May 6 22:18:24 2020 (r360712) +++ stable/12/usr.sbin/bhyve/gdb.h Wed May 6 22:20:37 2020 (r360713) @@ -32,6 +32,7 @@ #define __GDB_H__ void gdb_cpu_add(int vcpu); +void gdb_cpu_breakpoint(int vcpu, struct vm_exit *vmexit); void gdb_cpu_mtrap(int vcpu); void gdb_cpu_suspend(int vcpu); void init_gdb(struct vmctx *ctx, int sport, bool wait); From owner-svn-src-stable-12@freebsd.org Wed May 6 22:44:55 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 81C8C2E1A95; Wed, 6 May 2020 22:44:55 +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 49HWr73Db7z4Jhf; Wed, 6 May 2020 22:44:55 +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 657496DF2; Wed, 6 May 2020 22:44:55 +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 046MitHJ053889; Wed, 6 May 2020 22:44:55 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 046MisGU053883; Wed, 6 May 2020 22:44:54 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005062244.046MisGU053883@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 6 May 2020 22:44: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: r360717 - in stable/12/sys: conf dev/cxgbe dev/cxgbe/crypto modules/cxgbe/if_cxgbe X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/12/sys: conf dev/cxgbe dev/cxgbe/crypto modules/cxgbe/if_cxgbe X-SVN-Commit-Revision: 360717 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 06 May 2020 22:44:55 -0000 Author: jhb Date: Wed May 6 22:44:53 2020 New Revision: 360717 URL: https://svnweb.freebsd.org/changeset/base/360717 Log: MFC 354667,354686: Share routines for dealing with T6 key contexts. 354667: Create a file to hold shared routines for dealing with T6 key contexts. ccr(4) and TLS support in cxgbe(4) construct key contexts used by the crypto engine in the T6. This consolidates some duplicated code for helper functions used to build key contexts. 354686: Add t4_keyctx.c to sys/conf/files for the non-module build. Missed in r354667. Sponsored by: Chelsio Communications Added: stable/12/sys/dev/cxgbe/crypto/t4_keyctx.c - copied unchanged from r354667, head/sys/dev/cxgbe/crypto/t4_keyctx.c Modified: stable/12/sys/conf/files stable/12/sys/dev/cxgbe/adapter.h stable/12/sys/dev/cxgbe/crypto/t4_crypto.c stable/12/sys/dev/cxgbe/t4_main.c stable/12/sys/modules/cxgbe/if_cxgbe/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/conf/files ============================================================================== --- stable/12/sys/conf/files Wed May 6 22:26:23 2020 (r360716) +++ stable/12/sys/conf/files Wed May 6 22:44:53 2020 (r360717) @@ -1429,6 +1429,8 @@ dev/cxgbe/common/t4_hw.c optional cxgbe pci \ compile-with "${NORMAL_C} -I$S/dev/cxgbe" dev/cxgbe/common/t4vf_hw.c optional cxgbev pci \ compile-with "${NORMAL_C} -I$S/dev/cxgbe" +dev/cxgbe/crypto/t4_keyctx.c optional cxgbe pci \ + compile-with "${NORMAL_C} -I$S/dev/cxgbe" dev/cxgbe/cudbg/cudbg_common.c optional cxgbe \ compile-with "${NORMAL_C} -I$S/dev/cxgbe" dev/cxgbe/cudbg/cudbg_flash_utils.c optional cxgbe \ Modified: stable/12/sys/dev/cxgbe/adapter.h ============================================================================== --- stable/12/sys/dev/cxgbe/adapter.h Wed May 6 22:26:23 2020 (r360716) +++ stable/12/sys/dev/cxgbe/adapter.h Wed May 6 22:44:53 2020 (r360717) @@ -1149,7 +1149,6 @@ void t4_os_link_changed(struct port_info *); void t4_iterate(void (*)(struct adapter *, void *), void *); void t4_init_devnames(struct adapter *); void t4_add_adapter(struct adapter *); -void t4_aes_getdeckey(void *, const void *, unsigned int); int t4_detach_common(device_t); int t4_map_bars_0_and_4(struct adapter *); int t4_map_bar_2(struct adapter *); @@ -1177,6 +1176,15 @@ int cxgbe_media_change(struct ifnet *); void cxgbe_media_status(struct ifnet *, struct ifmediareq *); bool t4_os_dump_cimla(struct adapter *, int, bool); void t4_os_dump_devlog(struct adapter *); + +/* t4_keyctx.c */ +struct auth_hash; +union authctx; + +void t4_aes_getdeckey(void *, const void *, unsigned int); +void t4_copy_partial_hash(int, union authctx *, void *); +void t4_init_gmac_hash(const char *, int, char *); +void t4_init_hmac_digest(struct auth_hash *, u_int, char *, int, char *); #ifdef DEV_NETMAP /* t4_netmap.c */ Modified: stable/12/sys/dev/cxgbe/crypto/t4_crypto.c ============================================================================== --- stable/12/sys/dev/cxgbe/crypto/t4_crypto.c Wed May 6 22:26:23 2020 (r360716) +++ stable/12/sys/dev/cxgbe/crypto/t4_crypto.c Wed May 6 22:44:53 2020 (r360717) @@ -141,8 +141,7 @@ struct ccr_session_hmac { unsigned int partial_digest_len; unsigned int auth_mode; unsigned int mk_size; - char ipad[CHCR_HASH_MAX_BLOCK_SIZE_128]; - char opad[CHCR_HASH_MAX_BLOCK_SIZE_128]; + char pads[CHCR_HASH_MAX_BLOCK_SIZE_128 * 2]; }; struct ccr_session_gmac { @@ -530,10 +529,7 @@ ccr_hash(struct ccr_softc *sc, struct ccr_session *s, V_SCMD_LAST_FRAG(0) | V_SCMD_MORE_FRAGS(crd->crd_len == 0 ? 1 : 0) | V_SCMD_MAC_ONLY(1)); - memcpy(crwr->key_ctx.key, s->hmac.ipad, s->hmac.partial_digest_len); - if (use_opad) - memcpy(crwr->key_ctx.key + iopad_size, s->hmac.opad, - s->hmac.partial_digest_len); + memcpy(crwr->key_ctx.key, s->hmac.pads, kctx_len); /* XXX: F_KEY_CONTEXT_SALT_PRESENT set, but 'salt' not set. */ kctx_flits = (sizeof(struct _key_ctx) + kctx_len) / 16; @@ -1069,8 +1065,7 @@ ccr_authenc(struct ccr_softc *sc, struct ccr_session * } dst = crwr->key_ctx.key + roundup2(s->blkcipher.key_len, 16); - memcpy(dst, s->hmac.ipad, s->hmac.partial_digest_len); - memcpy(dst + iopad_size, s->hmac.opad, s->hmac.partial_digest_len); + memcpy(dst, s->hmac.pads, iopad_size * 2); dst = (char *)(crwr + 1) + kctx_len; ccr_write_phys_dsgl(sc, dst, dsgl_nsegs); @@ -2212,44 +2207,6 @@ ccr_detach(device_t dev) } static void -ccr_copy_partial_hash(void *dst, int cri_alg, union authctx *auth_ctx) -{ - uint32_t *u32; - uint64_t *u64; - u_int i; - - u32 = (uint32_t *)dst; - u64 = (uint64_t *)dst; - switch (cri_alg) { - case CRYPTO_SHA1: - case CRYPTO_SHA1_HMAC: - for (i = 0; i < SHA1_HASH_LEN / 4; i++) - u32[i] = htobe32(auth_ctx->sha1ctx.h.b32[i]); - break; - case CRYPTO_SHA2_224: - case CRYPTO_SHA2_224_HMAC: - for (i = 0; i < SHA2_256_HASH_LEN / 4; i++) - u32[i] = htobe32(auth_ctx->sha224ctx.state[i]); - break; - case CRYPTO_SHA2_256: - case CRYPTO_SHA2_256_HMAC: - for (i = 0; i < SHA2_256_HASH_LEN / 4; i++) - u32[i] = htobe32(auth_ctx->sha256ctx.state[i]); - break; - case CRYPTO_SHA2_384: - case CRYPTO_SHA2_384_HMAC: - for (i = 0; i < SHA2_512_HASH_LEN / 8; i++) - u64[i] = htobe64(auth_ctx->sha384ctx.state[i]); - break; - case CRYPTO_SHA2_512: - case CRYPTO_SHA2_512_HMAC: - for (i = 0; i < SHA2_512_HASH_LEN / 8; i++) - u64[i] = htobe64(auth_ctx->sha512ctx.state[i]); - break; - } -} - -static void ccr_init_hash_digest(struct ccr_session *s, int cri_alg) { union authctx auth_ctx; @@ -2257,66 +2214,9 @@ ccr_init_hash_digest(struct ccr_session *s, int cri_al axf = s->hmac.auth_hash; axf->Init(&auth_ctx); - ccr_copy_partial_hash(s->hmac.ipad, cri_alg, &auth_ctx); + t4_copy_partial_hash(cri_alg, &auth_ctx, s->hmac.pads); } -static void -ccr_init_hmac_digest(struct ccr_session *s, int cri_alg, char *key, - int klen) -{ - union authctx auth_ctx; - struct auth_hash *axf; - u_int i; - - /* - * If the key is larger than the block size, use the digest of - * the key as the key instead. - */ - axf = s->hmac.auth_hash; - klen /= 8; - if (klen > axf->blocksize) { - axf->Init(&auth_ctx); - axf->Update(&auth_ctx, key, klen); - axf->Final(s->hmac.ipad, &auth_ctx); - klen = axf->hashsize; - } else - memcpy(s->hmac.ipad, key, klen); - - memset(s->hmac.ipad + klen, 0, axf->blocksize - klen); - memcpy(s->hmac.opad, s->hmac.ipad, axf->blocksize); - - for (i = 0; i < axf->blocksize; i++) { - s->hmac.ipad[i] ^= HMAC_IPAD_VAL; - s->hmac.opad[i] ^= HMAC_OPAD_VAL; - } - - /* - * Hash the raw ipad and opad and store the partial result in - * the same buffer. - */ - axf->Init(&auth_ctx); - axf->Update(&auth_ctx, s->hmac.ipad, axf->blocksize); - ccr_copy_partial_hash(s->hmac.ipad, cri_alg, &auth_ctx); - - axf->Init(&auth_ctx); - axf->Update(&auth_ctx, s->hmac.opad, axf->blocksize); - ccr_copy_partial_hash(s->hmac.opad, cri_alg, &auth_ctx); -} - -/* - * Borrowed from AES_GMAC_Setkey(). - */ -static void -ccr_init_gmac_hash(struct ccr_session *s, char *key, int klen) -{ - static char zeroes[GMAC_BLOCK_LEN]; - uint32_t keysched[4 * (RIJNDAEL_MAXNR + 1)]; - int rounds; - - rounds = rijndaelKeySetupEnc(keysched, key, klen); - rijndaelEncrypt(keysched, rounds, zeroes, s->gmac.ghash_h); -} - static int ccr_aes_check_keylen(int alg, int klen) { @@ -2613,7 +2513,8 @@ ccr_newsession(device_t dev, crypto_session_t cses, st s->gmac.hash_len = AES_GMAC_HASH_LEN; else s->gmac.hash_len = hash->cri_mlen; - ccr_init_gmac_hash(s, hash->cri_key, hash->cri_klen); + t4_init_gmac_hash(hash->cri_key, hash->cri_klen, + s->gmac.ghash_h); } else if (auth_mode == SCMD_AUTH_MODE_CBCMAC) { if (hash->cri_mlen == 0) s->ccm_mac.hash_len = AES_CBC_MAC_HASH_LEN; @@ -2629,8 +2530,8 @@ ccr_newsession(device_t dev, crypto_session_t cses, st else s->hmac.hash_len = hash->cri_mlen; if (hmac) - ccr_init_hmac_digest(s, hash->cri_alg, hash->cri_key, - hash->cri_klen); + t4_init_hmac_digest(auth_hash, partial_digest_len, + hash->cri_key, hash->cri_klen, s->hmac.pads); else ccr_init_hash_digest(s, hash->cri_alg); } @@ -2694,8 +2595,9 @@ ccr_process(device_t dev, struct cryptop *crp, int hin break; case HMAC: if (crd->crd_flags & CRD_F_KEY_EXPLICIT) - ccr_init_hmac_digest(s, crd->crd_alg, crd->crd_key, - crd->crd_klen); + t4_init_hmac_digest(s->hmac.auth_hash, + s->hmac.partial_digest_len, crd->crd_key, + crd->crd_klen, s->hmac.pads); error = ccr_hash(sc, s, crp); if (error == 0) sc->stats_hmac++; @@ -2743,8 +2645,9 @@ ccr_process(device_t dev, struct cryptop *crp, int hin if (error) break; if (crda->crd_flags & CRD_F_KEY_EXPLICIT) - ccr_init_hmac_digest(s, crda->crd_alg, crda->crd_key, - crda->crd_klen); + t4_init_hmac_digest(s->hmac.auth_hash, + s->hmac.partial_digest_len, crda->crd_key, + crda->crd_klen, s->hmac.pads); if (crde->crd_flags & CRD_F_KEY_EXPLICIT) { error = ccr_aes_check_keylen(crde->crd_alg, crde->crd_klen); @@ -2771,7 +2674,8 @@ ccr_process(device_t dev, struct cryptop *crp, int hin crde = crd->crd_next; } if (crda->crd_flags & CRD_F_KEY_EXPLICIT) - ccr_init_gmac_hash(s, crda->crd_key, crda->crd_klen); + t4_init_gmac_hash(crda->crd_key, crda->crd_klen, + s->gmac.ghash_h); if (crde->crd_flags & CRD_F_KEY_EXPLICIT) { error = ccr_aes_check_keylen(crde->crd_alg, crde->crd_klen); Copied: stable/12/sys/dev/cxgbe/crypto/t4_keyctx.c (from r354667, head/sys/dev/cxgbe/crypto/t4_keyctx.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/dev/cxgbe/crypto/t4_keyctx.c Wed May 6 22:44:53 2020 (r360717, copy of r354667, head/sys/dev/cxgbe/crypto/t4_keyctx.c) @@ -0,0 +1,198 @@ +/*- + * Copyright (c) 2017-2019 Chelsio Communications, Inc. + * All rights reserved. + * Written by: John Baldwin + * + * 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 "common/common.h" +#include "crypto/t4_crypto.h" + +/* + * Crypto operations use a key context to store cipher keys and + * partial hash digests. They can either be passed inline as part of + * a work request using crypto or they can be stored in card RAM. For + * the latter case, work requests must replace the inline key context + * with a request to read the context from card RAM. + * + * The format of a key context: + * + * +-------------------------------+ + * | key context header | + * +-------------------------------+ + * | AES key | ----- For requests with AES + * +-------------------------------+ + * | Hash state | ----- For hash-only requests + * +-------------------------------+ - + * | IPAD (16-byte aligned) | \ + * +-------------------------------+ +---- For requests with HMAC + * | OPAD (16-byte aligned) | / + * +-------------------------------+ - + * | GMAC H | ----- For AES-GCM + * +-------------------------------+ - + */ + +/* + * Generate the initial GMAC hash state for a AES-GCM key. + * + * Borrowed from AES_GMAC_Setkey(). + */ +void +t4_init_gmac_hash(const char *key, int klen, char *ghash) +{ + static char zeroes[GMAC_BLOCK_LEN]; + uint32_t keysched[4 * (RIJNDAEL_MAXNR + 1)]; + int rounds; + + rounds = rijndaelKeySetupEnc(keysched, key, klen); + rijndaelEncrypt(keysched, rounds, zeroes, ghash); +} + +/* Copy out the partial hash state from a software hash implementation. */ +void +t4_copy_partial_hash(int alg, union authctx *auth_ctx, void *dst) +{ + uint32_t *u32; + uint64_t *u64; + u_int i; + + u32 = (uint32_t *)dst; + u64 = (uint64_t *)dst; + switch (alg) { + case CRYPTO_SHA1: + case CRYPTO_SHA1_HMAC: + for (i = 0; i < SHA1_HASH_LEN / 4; i++) + u32[i] = htobe32(auth_ctx->sha1ctx.h.b32[i]); + break; + case CRYPTO_SHA2_224: + case CRYPTO_SHA2_224_HMAC: + for (i = 0; i < SHA2_256_HASH_LEN / 4; i++) + u32[i] = htobe32(auth_ctx->sha224ctx.state[i]); + break; + case CRYPTO_SHA2_256: + case CRYPTO_SHA2_256_HMAC: + for (i = 0; i < SHA2_256_HASH_LEN / 4; i++) + u32[i] = htobe32(auth_ctx->sha256ctx.state[i]); + break; + case CRYPTO_SHA2_384: + case CRYPTO_SHA2_384_HMAC: + for (i = 0; i < SHA2_512_HASH_LEN / 8; i++) + u64[i] = htobe64(auth_ctx->sha384ctx.state[i]); + break; + case CRYPTO_SHA2_512: + case CRYPTO_SHA2_512_HMAC: + for (i = 0; i < SHA2_512_HASH_LEN / 8; i++) + u64[i] = htobe64(auth_ctx->sha512ctx.state[i]); + break; + } +} + +void +t4_init_hmac_digest(struct auth_hash *axf, u_int partial_digest_len, + char *key, int klen, char *dst) +{ + union authctx auth_ctx; + char ipad[SHA2_512_BLOCK_LEN], opad[SHA2_512_BLOCK_LEN]; + u_int i; + + /* + * If the key is larger than the block size, use the digest of + * the key as the key instead. + */ + klen /= 8; + if (klen > axf->blocksize) { + axf->Init(&auth_ctx); + axf->Update(&auth_ctx, key, klen); + axf->Final(ipad, &auth_ctx); + klen = axf->hashsize; + } else + memcpy(ipad, key, klen); + + memset(ipad + klen, 0, axf->blocksize - klen); + memcpy(opad, ipad, axf->blocksize); + + for (i = 0; i < axf->blocksize; i++) { + ipad[i] ^= HMAC_IPAD_VAL; + opad[i] ^= HMAC_OPAD_VAL; + } + + /* + * Hash the raw ipad and opad and store the partial results in + * the key context. + */ + axf->Init(&auth_ctx); + axf->Update(&auth_ctx, ipad, axf->blocksize); + t4_copy_partial_hash(axf->type, &auth_ctx, dst); + + dst += roundup2(partial_digest_len, 16); + axf->Init(&auth_ctx); + axf->Update(&auth_ctx, opad, axf->blocksize); + t4_copy_partial_hash(axf->type, &auth_ctx, dst); +} + +/* + * Borrowed from cesa_prep_aes_key(). + * + * NB: The crypto engine wants the words in the decryption key in reverse + * order. + */ +void +t4_aes_getdeckey(void *dec_key, const void *enc_key, unsigned int kbits) +{ + uint32_t ek[4 * (RIJNDAEL_MAXNR + 1)]; + uint32_t *dkey; + int i; + + rijndaelKeySetupEnc(ek, enc_key, kbits); + dkey = dec_key; + dkey += (kbits / 8) / 4; + + switch (kbits) { + case 128: + for (i = 0; i < 4; i++) + *--dkey = htobe32(ek[4 * 10 + i]); + break; + case 192: + for (i = 0; i < 2; i++) + *--dkey = htobe32(ek[4 * 11 + 2 + i]); + for (i = 0; i < 4; i++) + *--dkey = htobe32(ek[4 * 12 + i]); + break; + case 256: + for (i = 0; i < 4; i++) + *--dkey = htobe32(ek[4 * 13 + i]); + for (i = 0; i < 4; i++) + *--dkey = htobe32(ek[4 * 14 + i]); + break; + } + MPASS(dkey == dec_key); +} Modified: stable/12/sys/dev/cxgbe/t4_main.c ============================================================================== --- stable/12/sys/dev/cxgbe/t4_main.c Wed May 6 22:26:23 2020 (r360716) +++ stable/12/sys/dev/cxgbe/t4_main.c Wed May 6 22:44:53 2020 (r360717) @@ -71,7 +71,6 @@ __FBSDID("$FreeBSD$"); #include #include #endif -#include #ifdef DDB #include #include @@ -10849,44 +10848,6 @@ DB_FUNC(tcb, db_show_t4tcb, db_t4_table, CS_OWN, NULL) t4_dump_tcb(device_get_softc(dev), tid); } #endif - -/* - * Borrowed from cesa_prep_aes_key(). - * - * NB: The crypto engine wants the words in the decryption key in reverse - * order. - */ -void -t4_aes_getdeckey(void *dec_key, const void *enc_key, unsigned int kbits) -{ - uint32_t ek[4 * (RIJNDAEL_MAXNR + 1)]; - uint32_t *dkey; - int i; - - rijndaelKeySetupEnc(ek, enc_key, kbits); - dkey = dec_key; - dkey += (kbits / 8) / 4; - - switch (kbits) { - case 128: - for (i = 0; i < 4; i++) - *--dkey = htobe32(ek[4 * 10 + i]); - break; - case 192: - for (i = 0; i < 2; i++) - *--dkey = htobe32(ek[4 * 11 + 2 + i]); - for (i = 0; i < 4; i++) - *--dkey = htobe32(ek[4 * 12 + i]); - break; - case 256: - for (i = 0; i < 4; i++) - *--dkey = htobe32(ek[4 * 13 + i]); - for (i = 0; i < 4; i++) - *--dkey = htobe32(ek[4 * 14 + i]); - break; - } - MPASS(dkey == dec_key); -} static struct sx mlu; /* mod load unload */ SX_SYSINIT(cxgbe_mlu, &mlu, "cxgbe mod load/unload"); Modified: stable/12/sys/modules/cxgbe/if_cxgbe/Makefile ============================================================================== --- stable/12/sys/modules/cxgbe/if_cxgbe/Makefile Wed May 6 22:26:23 2020 (r360716) +++ stable/12/sys/modules/cxgbe/if_cxgbe/Makefile Wed May 6 22:44:53 2020 (r360717) @@ -3,7 +3,7 @@ # CXGBE= ${SRCTOP}/sys/dev/cxgbe -.PATH: ${CXGBE} ${CXGBE}/common ${CXGBE}/cudbg +.PATH: ${CXGBE} ${CXGBE}/common ${CXGBE}/crypto ${CXGBE}/cudbg KMOD= if_cxgbe SRCS= bus_if.h @@ -20,6 +20,7 @@ SRCS+= t4_filter.c SRCS+= t4_hw.c SRCS+= t4_if.c t4_if.h SRCS+= t4_iov.c +SRCS+= t4_keyctx.c SRCS+= t4_l2t.c SRCS+= t4_main.c SRCS+= t4_mp_ring.c From owner-svn-src-stable-12@freebsd.org Wed May 6 22:49:22 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7B06D2E1BA6; Wed, 6 May 2020 22:49:22 +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 49HWxG2m3Fz4Jvt; Wed, 6 May 2020 22:49:22 +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 59F836DF4; Wed, 6 May 2020 22:49:22 +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 046MnMjq054173; Wed, 6 May 2020 22:49:22 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 046MnLRZ054170; Wed, 6 May 2020 22:49:21 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005062249.046MnLRZ054170@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 6 May 2020 22:49: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: r360718 - in stable/12/sys/dev/cxgbe: . tom X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/12/sys/dev/cxgbe: . tom X-SVN-Commit-Revision: 360718 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 06 May 2020 22:49:22 -0000 Author: jhb Date: Wed May 6 22:49:21 2020 New Revision: 360718 URL: https://svnweb.freebsd.org/changeset/base/360718 Log: MFC 358415: Rename TOE TLS stats from [rt]x_tls_* to [rt]x_toe_tls_*. This more clearly differentiates TLS records encrypted and decrypted in TOE connections from those encrypted via NIC TLS. Sponsored by: Chelsio Communications Modified: stable/12/sys/dev/cxgbe/adapter.h stable/12/sys/dev/cxgbe/t4_main.c stable/12/sys/dev/cxgbe/tom/t4_tls.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/cxgbe/adapter.h ============================================================================== --- stable/12/sys/dev/cxgbe/adapter.h Wed May 6 22:44:53 2020 (r360717) +++ stable/12/sys/dev/cxgbe/adapter.h Wed May 6 22:49:21 2020 (r360718) @@ -304,10 +304,10 @@ struct port_info { struct port_stats stats; u_int tnl_cong_drops; u_int tx_parse_error; - u_long tx_tls_records; - u_long tx_tls_octets; - u_long rx_tls_records; - u_long rx_tls_octets; + u_long tx_toe_tls_records; + u_long tx_toe_tls_octets; + u_long rx_toe_tls_records; + u_long rx_toe_tls_octets; struct callout tick; }; Modified: stable/12/sys/dev/cxgbe/t4_main.c ============================================================================== --- stable/12/sys/dev/cxgbe/t4_main.c Wed May 6 22:44:53 2020 (r360717) +++ stable/12/sys/dev/cxgbe/t4_main.c Wed May 6 22:49:21 2020 (r360718) @@ -6731,17 +6731,17 @@ cxgbe_sysctls(struct port_info *pi) #undef SYSCTL_ADD_T4_PORTSTAT - SYSCTL_ADD_ULONG(ctx, children, OID_AUTO, "tx_tls_records", - CTLFLAG_RD, &pi->tx_tls_records, + SYSCTL_ADD_ULONG(ctx, children, OID_AUTO, "tx_toe_tls_records", + CTLFLAG_RD, &pi->tx_toe_tls_records, "# of TLS records transmitted"); - SYSCTL_ADD_ULONG(ctx, children, OID_AUTO, "tx_tls_octets", - CTLFLAG_RD, &pi->tx_tls_octets, + SYSCTL_ADD_ULONG(ctx, children, OID_AUTO, "tx_toe_tls_octets", + CTLFLAG_RD, &pi->tx_toe_tls_octets, "# of payload octets in transmitted TLS records"); - SYSCTL_ADD_ULONG(ctx, children, OID_AUTO, "rx_tls_records", - CTLFLAG_RD, &pi->rx_tls_records, + SYSCTL_ADD_ULONG(ctx, children, OID_AUTO, "rx_toe_tls_records", + CTLFLAG_RD, &pi->rx_toe_tls_records, "# of TLS records received"); - SYSCTL_ADD_ULONG(ctx, children, OID_AUTO, "rx_tls_octets", - CTLFLAG_RD, &pi->rx_tls_octets, + SYSCTL_ADD_ULONG(ctx, children, OID_AUTO, "rx_toe_tls_octets", + CTLFLAG_RD, &pi->rx_toe_tls_octets, "# of payload octets in received TLS records"); } Modified: stable/12/sys/dev/cxgbe/tom/t4_tls.c ============================================================================== --- stable/12/sys/dev/cxgbe/tom/t4_tls.c Wed May 6 22:44:53 2020 (r360717) +++ stable/12/sys/dev/cxgbe/tom/t4_tls.c Wed May 6 22:49:21 2020 (r360718) @@ -1368,8 +1368,8 @@ t4_push_tls_records(struct adapter *sc, struct toepcb } toep->txsd_avail--; - atomic_add_long(&toep->vi->pi->tx_tls_records, 1); - atomic_add_long(&toep->vi->pi->tx_tls_octets, plen); + atomic_add_long(&toep->vi->pi->tx_toe_tls_records, 1); + atomic_add_long(&toep->vi->pi->tx_toe_tls_octets, plen); t4_l2t_send(sc, wr, toep->l2te); } @@ -1404,7 +1404,7 @@ do_tls_data(struct sge_iq *iq, const struct rss_header m_adj(m, sizeof(*cpl)); len = m->m_pkthdr.len; - atomic_add_long(&toep->vi->pi->rx_tls_octets, len); + atomic_add_long(&toep->vi->pi->rx_toe_tls_octets, len); KASSERT(len == G_CPL_TLS_DATA_LENGTH(be32toh(cpl->length_pkd)), ("%s: payload length mismatch", __func__)); @@ -1467,7 +1467,7 @@ do_rx_tls_cmp(struct sge_iq *iq, const struct rss_head m_adj(m, sizeof(*cpl)); len = m->m_pkthdr.len; - atomic_add_long(&toep->vi->pi->rx_tls_records, 1); + atomic_add_long(&toep->vi->pi->rx_toe_tls_records, 1); KASSERT(len == G_CPL_RX_TLS_CMP_LENGTH(be32toh(cpl->pdulength_length)), ("%s: payload length mismatch", __func__)); From owner-svn-src-stable-12@freebsd.org Wed May 6 23:23:22 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D370D2E25F2; Wed, 6 May 2020 23:23:22 +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 49HXhV5JCdz4LlS; Wed, 6 May 2020 23:23:22 +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 B1268755A; Wed, 6 May 2020 23:23:22 +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 046NNMOT078735; Wed, 6 May 2020 23:23:22 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 046NNMpM078734; Wed, 6 May 2020 23:23:22 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005062323.046NNMpM078734@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 6 May 2020 23:23: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: r360721 - in stable: 11/sys/netipsec 12/sys/netipsec X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/sys/netipsec 12/sys/netipsec X-SVN-Commit-Revision: 360721 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 06 May 2020 23:23:22 -0000 Author: jhb Date: Wed May 6 23:23:22 2020 New Revision: 360721 URL: https://svnweb.freebsd.org/changeset/base/360721 Log: MFC 360202,360206: Deprecate 3des support in IPsec for FreeBSD 13. 360202: Deprecate 3des support in IPsec for FreeBSD 13. RFC 8221 does not outright ban 3des as the algorithms deprecated for 13 in r348205, but it is listed as a SHOULD NOT and will likely be a MUST NOT by the time 13 ships. 360206: Fix name of 3DES cipher in deprecation warning. Sponsored by: Chelsio Communications Modified: stable/12/sys/netipsec/xform_esp.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/netipsec/xform_esp.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/netipsec/xform_esp.c ============================================================================== --- stable/12/sys/netipsec/xform_esp.c Wed May 6 23:03:40 2020 (r360720) +++ stable/12/sys/netipsec/xform_esp.c Wed May 6 23:23:22 2020 (r360721) @@ -94,7 +94,7 @@ SYSCTL_VNET_PCPUSTAT(_net_inet_esp, IPSECCTL_STATS, st struct espstat, espstat, "ESP statistics (struct espstat, netipsec/esp_var.h"); -static struct timeval deswarn, blfwarn, castwarn, camelliawarn; +static struct timeval deswarn, blfwarn, castwarn, camelliawarn, tdeswarn; static int esp_input_cb(struct cryptop *op); static int esp_output_cb(struct cryptop *crp); @@ -163,6 +163,10 @@ esp_init(struct secasvar *sav, struct xformsw *xsp) case SADB_EALG_DESCBC: if (ratecheck(&deswarn, &ipsec_warn_interval)) gone_in(13, "DES cipher for IPsec"); + break; + case SADB_EALG_3DESCBC: + if (ratecheck(&tdeswarn, &ipsec_warn_interval)) + gone_in(13, "3DES cipher for IPsec"); break; case SADB_X_EALG_BLOWFISHCBC: if (ratecheck(&blfwarn, &ipsec_warn_interval)) From owner-svn-src-stable-12@freebsd.org Thu May 7 14:20:53 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 490AC2DA628; Thu, 7 May 2020 14:20:53 +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 49Hwc51J8Kz4Dlm; Thu, 7 May 2020 14:20:53 +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 27C1A1A4F1; Thu, 7 May 2020 14:20:53 +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 047EKrnB034128; Thu, 7 May 2020 14:20:53 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 047EKq0b034125; Thu, 7 May 2020 14:20:52 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005071420.047EKq0b034125@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 7 May 2020 14:20: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: r360780 - in stable/12: share/mk sys/conf X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/12: share/mk sys/conf X-SVN-Commit-Revision: 360780 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 07 May 2020 14:20:53 -0000 Author: jhb Date: Thu May 7 14:20:52 2020 New Revision: 360780 URL: https://svnweb.freebsd.org/changeset/base/360780 Log: MFC 355428,356504: Add a new "riscv-relaxations" linker feature. 355428: Add a new "riscv-relaxations" linker feature. When the linker doesn't have this feature, add -mno-relax to CFLAGS on RISC-V. Define the feature for ld.bfd, but not lld. If lld gains relaxation support in a newer version, we can enable it for those versions of lld in bsd.linker.mk. 356504: Add -mno-relax to CFLAGS in bsd.prog/lib.mk instead of bsd.cpu.mk. bsd.cpu.mk is included by bsd.init.mk before bsd.linker.mk, so it was always setting the flag since LINKER_FEATURES wasn't defined. Modified: stable/12/share/mk/bsd.lib.mk stable/12/share/mk/bsd.linker.mk stable/12/share/mk/bsd.prog.mk stable/12/sys/conf/kern.mk Directory Properties: stable/12/ (props changed) Modified: stable/12/share/mk/bsd.lib.mk ============================================================================== --- stable/12/share/mk/bsd.lib.mk Thu May 7 13:11:32 2020 (r360779) +++ stable/12/share/mk/bsd.lib.mk Thu May 7 14:20:52 2020 (r360780) @@ -86,6 +86,10 @@ CXXFLAGS+= ${DEBUG_FILES_CFLAGS} CTFFLAGS+= -g .endif +.if ${MACHINE_CPUARCH} == "riscv" && ${LINKER_FEATURES:Mriscv-relaxations} == "" +CFLAGS += -mno-relax +.endif + .include # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries Modified: stable/12/share/mk/bsd.linker.mk ============================================================================== --- stable/12/share/mk/bsd.linker.mk Thu May 7 13:11:32 2020 (r360779) +++ stable/12/share/mk/bsd.linker.mk Thu May 7 14:20:52 2020 (r360780) @@ -82,6 +82,9 @@ ${X_}LINKER_FEATURES= ${X_}LINKER_FEATURES+= build-id ${X_}LINKER_FEATURES+= ifunc .endif +.if ${${X_}LINKER_TYPE} == "bfd" && ${${X_}LINKER_VERSION} > 21750 +${X_}LINKER_FEATURES+= riscv-relaxations +.endif .if ${${X_}LINKER_TYPE} != "lld" || ${${X_}LINKER_VERSION} >= 50000 ${X_}LINKER_FEATURES+= filter .endif Modified: stable/12/share/mk/bsd.prog.mk ============================================================================== --- stable/12/share/mk/bsd.prog.mk Thu May 7 13:11:32 2020 (r360779) +++ stable/12/share/mk/bsd.prog.mk Thu May 7 14:20:52 2020 (r360780) @@ -52,6 +52,10 @@ LDFLAGS+= -Wl,-zretpolineplt .endif .endif +.if ${MACHINE_CPUARCH} == "riscv" && ${LINKER_FEATURES:Mriscv-relaxations} == "" +CFLAGS += -mno-relax +.endif + .if defined(CRUNCH_CFLAGS) CFLAGS+=${CRUNCH_CFLAGS} .else Modified: stable/12/sys/conf/kern.mk ============================================================================== --- stable/12/sys/conf/kern.mk Thu May 7 13:11:32 2020 (r360779) +++ stable/12/sys/conf/kern.mk Thu May 7 14:20:52 2020 (r360780) @@ -147,6 +147,10 @@ CFLAGS+= -march=rv64imafdc -mabi=lp64 CFLAGS.clang+= -mcmodel=medium CFLAGS.gcc+= -mcmodel=medany INLINE_LIMIT?= 8000 + +.if ${LINKER_FEATURES:Mriscv-relaxations} == "" +CFLAGS+= -mno-relax +.endif .endif # From owner-svn-src-stable-12@freebsd.org Thu May 7 14:49:18 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5B50F2DB3AE; Thu, 7 May 2020 14:49:18 +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 49HxDt1hzVz4Gcm; Thu, 7 May 2020 14:49:18 +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 352871AAA7; Thu, 7 May 2020 14:49:18 +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 047EnIM0052393; Thu, 7 May 2020 14:49:18 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 047EnITQ052392; Thu, 7 May 2020 14:49:18 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202005071449.047EnITQ052392@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 7 May 2020 14:49:18 +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: r360781 - stable/12/sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/net X-SVN-Commit-Revision: 360781 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 07 May 2020 14:49:18 -0000 Author: markj Date: Thu May 7 14:49:17 2020 New Revision: 360781 URL: https://svnweb.freebsd.org/changeset/base/360781 Log: MFC r360498: Increase the iflib txq callout mutex name length to 32 bytes. PR: 245712 Modified: stable/12/sys/net/iflib.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/iflib.c ============================================================================== --- stable/12/sys/net/iflib.c Thu May 7 14:20:52 2020 (r360780) +++ stable/12/sys/net/iflib.c Thu May 7 14:49:17 2020 (r360781) @@ -359,7 +359,7 @@ struct iflib_txq { bus_dma_tag_t ift_buf_tag; bus_dma_tag_t ift_tso_buf_tag; iflib_dma_info_t ift_ifdi; -#define MTX_NAME_LEN 16 +#define MTX_NAME_LEN 32 char ift_mtx_name[MTX_NAME_LEN]; bus_dma_segment_t ift_segs[IFLIB_MAX_TX_SEGS] __aligned(CACHE_LINE_SIZE); #ifdef IFLIB_DIAGNOSTICS From owner-svn-src-stable-12@freebsd.org Thu May 7 15:59:56 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0F5462DCD4E; Thu, 7 May 2020 15:59:56 +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 49HypM6hxqz4LFR; Thu, 7 May 2020 15:59:55 +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 E149C1B86E; Thu, 7 May 2020 15:59:55 +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 047FxtX8095562; Thu, 7 May 2020 15:59:55 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 047Fxtp0095560; Thu, 7 May 2020 15:59:55 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005071559.047Fxtp0095560@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 7 May 2020 15:59: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: r360783 - stable/12/lib/libc/riscv/gen X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/12/lib/libc/riscv/gen X-SVN-Commit-Revision: 360783 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 07 May 2020 15:59:56 -0000 Author: jhb Date: Thu May 7 15:59:55 2020 New Revision: 360783 URL: https://svnweb.freebsd.org/changeset/base/360783 Log: MFC 355403: Use "far" calls and branches so that lld uses valid relocations. Conditional branch and jump instructions do not always call via PLT stubs and thus will not honor LD_PRELOAD, etc. lld warns about using non-preemptible relocations for preemptible or unknown symbols whereas bfd does not (at least for RISC-V). Modified: stable/12/lib/libc/riscv/gen/setjmp.S stable/12/lib/libc/riscv/gen/sigsetjmp.S Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libc/riscv/gen/setjmp.S ============================================================================== --- stable/12/lib/libc/riscv/gen/setjmp.S Thu May 7 15:12:56 2020 (r360782) +++ stable/12/lib/libc/riscv/gen/setjmp.S Thu May 7 15:59:55 2020 (r360783) @@ -46,7 +46,7 @@ ENTRY(setjmp) addi a2, a0, (_JB_SIGMASK * 8) /* oset */ li a1, 0 /* set */ li a0, 1 /* SIG_BLOCK */ - jal sigprocmask + call _C_LABEL(sigprocmask) ld a0, 0(sp) ld ra, 8(sp) @@ -110,7 +110,7 @@ ENTRY(longjmp) li a2, 0 /* oset */ addi a1, a0, (_JB_SIGMASK * 8) /* set */ li a0, 3 /* SIG_BLOCK */ - jal sigprocmask + call _C_LABEL(sigprocmask) ld a1, (2 * 8)(sp) ld ra, (1 * 8)(sp) Modified: stable/12/lib/libc/riscv/gen/sigsetjmp.S ============================================================================== --- stable/12/lib/libc/riscv/gen/sigsetjmp.S Thu May 7 15:12:56 2020 (r360782) +++ stable/12/lib/libc/riscv/gen/sigsetjmp.S Thu May 7 15:59:55 2020 (r360783) @@ -38,8 +38,10 @@ __FBSDID("$FreeBSD$"); #include ENTRY(sigsetjmp) - beqz a1, _C_LABEL(_setjmp) - j _C_LABEL(setjmp) + beqz a1, 1f + tail _C_LABEL(setjmp) +1: + tail _C_LABEL(_setjmp) END(sigsetjmp) ENTRY(siglongjmp) @@ -48,8 +50,10 @@ ENTRY(siglongjmp) ld a3, 0(a0) /* Check the magic */ - beq a2, a3, _C_LABEL(_longjmp) - j _C_LABEL(longjmp) + beq a2, a3, 1f + tail _C_LABEL(longjmp) +1: + tail _C_LABEL(_longjmp) .align 3 .Lmagic: From owner-svn-src-stable-12@freebsd.org Thu May 7 18:47:55 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 50F9F2E1625; Thu, 7 May 2020 18:47:55 +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 49J2XC1VyTz4YfB; Thu, 7 May 2020 18:47:55 +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 2EE9E1D936; Thu, 7 May 2020 18:47:55 +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 047Ilt1H001588; Thu, 7 May 2020 18:47:55 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 047IlsaQ001586; Thu, 7 May 2020 18:47:54 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005071847.047IlsaQ001586@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 7 May 2020 18:47: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: r360792 - stable/12/sys/conf X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/12/sys/conf X-SVN-Commit-Revision: 360792 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 07 May 2020 18:47:55 -0000 Author: jhb Date: Thu May 7 18:47:54 2020 New Revision: 360792 URL: https://svnweb.freebsd.org/changeset/base/360792 Log: MFC 357145: Compile hack.c with normal CFLAGS + -shared -nostdlib. Originally, hack.c was compiled into a shard object with just -shared -nostdlib. This assumed that ${CC} did not require any additional flags for ABIs, cross-building, etc. When kern.post.mk was created in r89509 by reducing duplication in kernel Makefile. files, the -shared flag was moved into a HACK_EXTRA_FLAGS variable so that sparc64 could override it with -Wl,-shared. The sparc64 hack was removed in r111650, but HACK_EXTRA_FLAGS was left in place. Over time, we have started support toolchains that require flags to support alternate ABIs on MIPS and PowerPC and started (ab)using HACK_EXTRA_FLAGS to set only those flags. I need to fix risc-v to pass -mno-relax to the hack.c build for lld in llvm 10, and the patches to support cross-build from non-FreeBSD hosts need to include -target for clang in CFLAGS for hack.c. Rather than adding more hacks into HACK_EXTRA_FLAGS, just use the full set of CFLAGS with hack.c. Modified: stable/12/sys/conf/Makefile.mips stable/12/sys/conf/kern.post.mk Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/conf/Makefile.mips ============================================================================== --- stable/12/sys/conf/Makefile.mips Thu May 7 18:24:32 2020 (r360791) +++ stable/12/sys/conf/Makefile.mips Thu May 7 18:47:54 2020 (r360792) @@ -44,12 +44,9 @@ TRAMPLOADADDR?=0x807963c0 ARCH_FLAGS?=-march=mips32 EXTRA_FLAGS=-fno-pic -mno-abicalls -G0 -DKERNLOADADDR=${KERNLOADADDR} -HACK_EXTRA_FLAGS=-shared - # We add the -fno-pic flag to kernels because otherwise performance # is extremely poor, as well as -mno-abicalls to force no ABI usage. CFLAGS+=${EXTRA_FLAGS} $(ARCH_FLAGS) -HACK_EXTRA_FLAGS+=${EXTRA_FLAGS} $(ARCH_FLAGS) TRAMP_ARCH_FLAGS?=$(ARCH_FLAGS) TRAMP_EXTRA_FLAGS=${EXTRA_FLAGS} ${TRAMP_ARCH_FLAGS} # Kernel code is always compiled with soft-float on MIPS Modified: stable/12/sys/conf/kern.post.mk ============================================================================== --- stable/12/sys/conf/kern.post.mk Thu May 7 18:24:32 2020 (r360791) +++ stable/12/sys/conf/kern.post.mk Thu May 7 18:47:54 2020 (r360792) @@ -192,10 +192,9 @@ kernel-clean: # This is a hack. BFD "optimizes" away dynamic mode if there are no # dynamic references. We could probably do a '-Bforcedynamic' mode like # in the a.out ld. For now, this works. -HACK_EXTRA_FLAGS?= -shared hack.pico: Makefile :> hack.c - ${CC} ${HACK_EXTRA_FLAGS} -nostdlib hack.c -o hack.pico + ${CC} -shared ${CFLAGS} -nostdlib hack.c -o hack.pico rm -f hack.c offset.inc: $S/kern/genoffset.sh genoffset.o From owner-svn-src-stable-12@freebsd.org Thu May 7 19:19:40 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D36922E263E; Thu, 7 May 2020 19:19:40 +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 49J3Dr4rw9z4bh3; Thu, 7 May 2020 19:19:40 +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 A1D271DF1E; Thu, 7 May 2020 19:19:40 +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 047JJewx020231; Thu, 7 May 2020 19:19:40 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 047JJeRu020230; Thu, 7 May 2020 19:19:40 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005071919.047JJeRu020230@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 7 May 2020 19:19:40 +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: r360793 - in stable/12/sys: conf riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/12/sys: conf riscv/riscv X-SVN-Commit-Revision: 360793 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 07 May 2020 19:19:40 -0000 Author: jhb Date: Thu May 7 19:19:39 2020 New Revision: 360793 URL: https://svnweb.freebsd.org/changeset/base/360793 Log: MFC 356481: Work around lld's inability to handle undefined weak symbols on risc-v. lld on RISC-V is not yet able to handle undefined weak symbols for non-PIC code in the code model (medany/medium) used by the RISC-V kernel. Both GCC and clang emit an auipc / addi pair of instructions to generate an address relative to the current PC with a 31-bit offset. Undefined weak symbols need to have an address of 0, but the kernel runs with PC values much greater than 2^31, so there is no way to construct a NULL pointer as a PC-relative value. The bfd linker rewrites the instruction pair to use lui / addi with values of 0 to force a NULL pointer address. (There are similar cases for 'ld' becoming auipc / ld that bfd rewrites to lui / ld with an address of 0.) To work around this, compile the kernel with -fPIE when using lld. This does not make the kernel position-independent, but it does force the compiler to indirect address lookups through GOT entries (so auipc / ld against a GOT entry to fetch the address). This adds extra memory indirections for global symbols, so should be disabled once lld is finally fixed. A few 'la' instructions in locore that depend on PC-relative addressing to load physical addresses before paging is enabled have to use auipc / addi and not indirect via GOT entries, so change those to use 'lla' which always uses auipc / addi for both PIC and non-PIC. Note that the followup fix for SMP (r356675) was previously merged to stable/12. Modified: stable/12/sys/conf/kern.pre.mk stable/12/sys/riscv/riscv/locore.S Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/conf/kern.pre.mk ============================================================================== --- stable/12/sys/conf/kern.pre.mk Thu May 7 18:47:54 2020 (r360792) +++ stable/12/sys/conf/kern.pre.mk Thu May 7 19:19:39 2020 (r360793) @@ -143,6 +143,17 @@ LDFLAGS+= -z notext -z ifunc-noplt .endif .endif +.if ${MACHINE_CPUARCH} == "riscv" +# Hack: Work around undefined weak symbols being out of range when linking with +# LLD (address is a PC-relative calculation, and BFD works around this by +# rewriting the instructions to generate an absolute address of 0); -fPIE +# avoids this since it uses the GOT for all extern symbols, which is overly +# inefficient for us. Drop once undefined weak symbols work with medany. +.if ${LINKER_TYPE} == "lld" +CFLAGS+= -fPIE +.endif +.endif + NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC} NORMAL_S= ${CC:N${CCACHE_BIN}} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC} PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC} Modified: stable/12/sys/riscv/riscv/locore.S ============================================================================== --- stable/12/sys/riscv/riscv/locore.S Thu May 7 18:47:54 2020 (r360792) +++ stable/12/sys/riscv/riscv/locore.S Thu May 7 19:19:39 2020 (r360793) @@ -54,7 +54,7 @@ .globl _start _start: /* Get the physical address kernel loaded to */ - la t0, virt_map + lla t0, virt_map ld t1, 0(t0) sub t1, t1, t0 li t2, KERNBASE @@ -66,7 +66,7 @@ _start: */ /* Pick a hart to run the boot process. */ - la t0, hart_lottery + lla t0, hart_lottery li t1, 1 amoadd.w t0, t1, 0(t0) @@ -82,8 +82,8 @@ _start: */ 1: /* Add L1 entry for kernel */ - la s1, pagetable_l1 - la s2, pagetable_l2 /* Link to next level PN */ + lla s1, pagetable_l1 + lla s2, pagetable_l2 /* Link to next level PN */ srli s2, s2, PAGE_SHIFT li a5, KERNBASE @@ -100,7 +100,7 @@ _start: sd t6, (t0) /* Level 2 superpages (512 x 2MiB) */ - la s1, pagetable_l2 + lla s1, pagetable_l2 srli t4, s9, 21 /* Div physmem base by 2 MiB */ li t2, 512 /* Build 512 entries */ add t3, t4, t2 @@ -116,8 +116,8 @@ _start: bltu t4, t3, 2b /* Create an L1 page for early devmap */ - la s1, pagetable_l1 - la s2, pagetable_l2_devmap /* Link to next level PN */ + lla s1, pagetable_l1 + lla s2, pagetable_l2_devmap /* Link to next level PN */ srli s2, s2, PAGE_SHIFT li a5, (VM_MAX_KERNEL_ADDRESS - L2_SIZE) @@ -134,7 +134,7 @@ _start: sd t6, (t0) /* Create an L2 page superpage for DTB */ - la s1, pagetable_l2_devmap + lla s1, pagetable_l2_devmap mv s2, a1 srli s2, s2, PAGE_SHIFT @@ -152,14 +152,14 @@ _start: /* Page tables END */ /* Setup supervisor trap vector */ - la t0, va + lla t0, va sub t0, t0, s9 li t1, KERNBASE add t0, t0, t1 csrw stvec, t0 /* Set page tables base register */ - la s2, pagetable_l1 + lla s2, pagetable_l1 srli s2, s2, PAGE_SHIFT li t0, SATP_MODE_SV39 or s2, s2, t0 From owner-svn-src-stable-12@freebsd.org Thu May 7 20:27:33 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1D7602E4746; Thu, 7 May 2020 20:27:33 +0000 (UTC) (envelope-from lwhsu@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 49J4l8752Pz3CqJ; Thu, 7 May 2020 20:27:32 +0000 (UTC) (envelope-from lwhsu@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 EE7FE1ECBF; Thu, 7 May 2020 20:27:32 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 047KRWYc063154; Thu, 7 May 2020 20:27:32 GMT (envelope-from lwhsu@FreeBSD.org) Received: (from lwhsu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 047KRWhW063152; Thu, 7 May 2020 20:27:32 GMT (envelope-from lwhsu@FreeBSD.org) Message-Id: <202005072027.047KRWhW063152@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lwhsu set sender to lwhsu@FreeBSD.org using -f From: Li-Wen Hsu Date: Thu, 7 May 2020 20:27:32 +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: r360797 - in stable/12/lib: libproc/tests msun/tests X-SVN-Group: stable-12 X-SVN-Commit-Author: lwhsu X-SVN-Commit-Paths: in stable/12/lib: libproc/tests msun/tests X-SVN-Commit-Revision: 360797 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 07 May 2020 20:27:33 -0000 Author: lwhsu Date: Thu May 7 20:27:32 2020 New Revision: 360797 URL: https://svnweb.freebsd.org/changeset/base/360797 Log: MFC r358887: Temporarily skip 2 failing tests after llvm10 import PR: 244732 Sponsored by: The FreeBSD Foundation Modified: stable/12/lib/libproc/tests/proc_test.c stable/12/lib/msun/tests/ctrig_test.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libproc/tests/proc_test.c ============================================================================== --- stable/12/lib/libproc/tests/proc_test.c Thu May 7 19:51:53 2020 (r360796) +++ stable/12/lib/libproc/tests/proc_test.c Thu May 7 20:27:32 2020 (r360797) @@ -270,6 +270,9 @@ ATF_TC_BODY(symbol_lookup, tc) u_long saved; int error; + if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false)) + atf_tc_skip("https://bugs.freebsd.org/244732"); + phdl = start_prog(tc, false); error = proc_name2sym(phdl, target_prog_file, "main", &main_sym, NULL); Modified: stable/12/lib/msun/tests/ctrig_test.c ============================================================================== --- stable/12/lib/msun/tests/ctrig_test.c Thu May 7 19:51:53 2020 (r360796) +++ stable/12/lib/msun/tests/ctrig_test.c Thu May 7 20:27:32 2020 (r360797) @@ -248,6 +248,9 @@ ATF_TC_BODY(test_inf_inputs, tc) long double complex z, c, s; unsigned i; + if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false)) + atf_tc_skip("https://bugs.freebsd.org/244732"); + /* * IN CSINH CCOSH CTANH * Inf,Inf +-Inf,NaN inval +-Inf,NaN inval 1,+-0 From owner-svn-src-stable-12@freebsd.org Thu May 7 21:14:12 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 302612E5E12; Thu, 7 May 2020 21:14:12 +0000 (UTC) (envelope-from kp@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 49J5n00Y9Qz3HHf; Thu, 7 May 2020 21:14:12 +0000 (UTC) (envelope-from kp@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 0D5211F654; Thu, 7 May 2020 21:14:12 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 047LEB23094809; Thu, 7 May 2020 21:14:11 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 047LEBOw094808; Thu, 7 May 2020 21:14:11 GMT (envelope-from kp@FreeBSD.org) Message-Id: <202005072114.047LEBOw094808@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Thu, 7 May 2020 21:14: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: r360799 - stable/12/lib/libc/net X-SVN-Group: stable-12 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: stable/12/lib/libc/net X-SVN-Commit-Revision: 360799 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 07 May 2020 21:14:12 -0000 Author: kp Date: Thu May 7 21:14:11 2020 New Revision: 360799 URL: https://svnweb.freebsd.org/changeset/base/360799 Log: MFC r360231: libc: Shortcut if_indextoname() if index == 0 If the index we're trying to convert is 0 we can avoid a potentially expensive call to getifaddrs(). No interface has an ifindex of zero, so we can handle this as an error: set the errno to ENXIO and return NULL. Submitted by: Nick Rogers Sponsored by: RG Nets Modified: stable/12/lib/libc/net/if_indextoname.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libc/net/if_indextoname.c ============================================================================== --- stable/12/lib/libc/net/if_indextoname.c Thu May 7 20:29:38 2020 (r360798) +++ stable/12/lib/libc/net/if_indextoname.c Thu May 7 21:14:11 2020 (r360799) @@ -66,6 +66,11 @@ if_indextoname(unsigned int ifindex, char *ifname) struct ifaddrs *ifaddrs, *ifa; int error = 0; + if (ifindex == 0) { + errno = ENXIO; + return(NULL); + } + if (getifaddrs(&ifaddrs) < 0) return(NULL); /* getifaddrs properly set errno */ From owner-svn-src-stable-12@freebsd.org Fri May 8 05:30:13 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 10B6F2C1593; Fri, 8 May 2020 05:30: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 49JJnJ73pgz4FRJ; Fri, 8 May 2020 05:30: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 CF2632534F; Fri, 8 May 2020 05:30: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 0485UCMe008417; Fri, 8 May 2020 05:30:12 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0485UBdx008409; Fri, 8 May 2020 05:30:11 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005080530.0485UBdx008409@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 8 May 2020 05:30: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: r360808 - in stable/12/sys: conf riscv/include riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/12/sys: conf riscv/include riscv/riscv X-SVN-Commit-Revision: 360808 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.30 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, 08 May 2020 05:30:13 -0000 Author: jhb Date: Fri May 8 05:30:10 2020 New Revision: 360808 URL: https://svnweb.freebsd.org/changeset/base/360808 Log: MFC 354719,354720,354721,354722,357480: OpenSBI support. 354719: RISC-V: pass arg6 in sbi_call Allow for an additional argument to sbi_call which will be passed in a6. This is required for SBI spec 0.2 support, as a6 will indicate the SBI function ID. While here, introduce some macros to clean up the calls. 354720: RISC-V: add support for SBI spec v0.2 The Supervisor Binary Interface (SBI) specification v0.2 is a backwards incompatible update to the SBI call interface for kernels running in supervisor mode. The goal of this update was to make it easier for new and optional functionality to be added to the SBI. SBI functions are now called by passing an "extension ID" and a "function ID" which are passed in a7 and a6 respectively. SBI calls will also return an error and value in the following struct: struct sbi_ret { long error; long value; } This version introduces several new functions under the "base" extension. It is expected that all SBI implementations >= 0.2 will support this base set of functions, as they implement some essential services such as obtaining the SBI version, CPU implementation info, and extension probing. Existing SBI functions have been designated as "legacy". For the time being they will remain implemented, but it is expected that in the future their functionality will be duplicated or replaced by new SBI extensions. Each legacy function has been assigned its own extension ID, and for now we simply probe and assert for their existence. Compatibility with legacy SBI implementations (such as BBL) is maintained by checking the output of sbi_get_spec_version(). This function is guaranteed to succeed by the new spec, but will return an error in legacy implementations. We use this as an indicator of whether or not we can rely on the new SBI base extensions. For further info on the Supervisor Binary Interface, see: https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc 354721: Add missing files from r354720 354722: RISC-V: Print SBI info at startup SBI version 0.2 introduces functions for obtaining the details of the SBI implementation, such as version and implemntation ID. Print this info at startup when it is available. 357480: Set the LMA of the riscv kernel to the OpenSBI jump target by default This allows us to boot FreeBSD RISCV on QEMU using the -kernel command line options. When using that option, QEMU maps the kernel ELF file to the addresses specified in the LMAs in the program headers. Since version 4.2 QEMU ships with OpenSBI fw_jump by default so this allows booting FreeBSD using the following command line: qemu-system-riscv64 -bios default -kernel /.../boot/kernel/kernel -nographic -M virt Without this change the -kernel option cannot be used since the LMAs start at address zero and QEMU already maps a ROM to these low physical addresses. For targets that require a different kernel LMA the make variable KERNEL_LMA can be overwritten in the config file. For example, adding `makeoptions KERNEL_LMA=0xc0200000` will create an ELF file that will be loaded at 0xc0200000. Before: There are 4 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0xffffffc000000000 0x0000000000000000 0x75e598 0x8be318 RWE 0x1000 DYNAMIC 0x71fb20 0xffffffc00071eb20 0x000000000071eb20 0x000100 0x000100 RW 0x8 GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x0 NOTE 0x693400 0xffffffc000692400 0x0000000000692400 0x000024 0x000024 R 0x4 After: There are 4 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0xffffffc000000000 0x0000000080200000 0x734198 0x893e18 RWE 0x1000 DYNAMIC 0x6f7810 0xffffffc0006f6810 0x00000000808f6810 0x000100 0x000100 RW 0x8 GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x0 NOTE 0x66ca70 0xffffffc00066ba70 0x000000008086ba70 0x000024 0x000024 R 0x4 Added: stable/12/sys/riscv/riscv/sbi.c - copied, changed from r354720, head/sys/riscv/riscv/sbi.c Modified: stable/12/sys/conf/Makefile.riscv stable/12/sys/conf/files.riscv stable/12/sys/conf/ldscript.riscv stable/12/sys/riscv/include/md_var.h stable/12/sys/riscv/include/sbi.h stable/12/sys/riscv/riscv/identcpu.c stable/12/sys/riscv/riscv/machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/conf/Makefile.riscv ============================================================================== --- stable/12/sys/conf/Makefile.riscv Fri May 8 02:42:15 2020 (r360807) +++ stable/12/sys/conf/Makefile.riscv Fri May 8 05:30:10 2020 (r360808) @@ -28,8 +28,17 @@ S= ../../.. INCLUDES+= -I$S/contrib/libfdt +# Set the ELF LMA to the address that OpenSBI's fw_jump jumps to. This allows +# us to load the kernel with the -kernel flag in QEMU without having to embed +# it inside BBL or OpenSBI's fw_payload first. +# Note: For rv32 the start address is different (0x80400000). +# We set this value using --defsym rather than hardcoding it in ldscript.riscv +# so that different kernel configs can override the load address. +KERNEL_LMA?= 0x80200000 + SYSTEM_LD= @${LD} -N -m ${LD_EMULATION} -Bdynamic -T ${LDSCRIPT} ${_LDFLAGS} \ --no-warn-mismatch --warn-common --export-dynamic \ + --defsym='kernel_lma=${KERNEL_LMA}' \ --dynamic-linker /red/herring \ -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o Modified: stable/12/sys/conf/files.riscv ============================================================================== --- stable/12/sys/conf/files.riscv Fri May 8 02:42:15 2020 (r360807) +++ stable/12/sys/conf/files.riscv Fri May 8 05:30:10 2020 (r360808) @@ -55,6 +55,7 @@ riscv/riscv/ofw_machdep.c optional fdt riscv/riscv/plic.c standard riscv/riscv/pmap.c standard riscv/riscv/riscv_console.c optional rcons +riscv/riscv/sbi.c standard riscv/riscv/soc.c standard riscv/riscv/stack_machdep.c optional ddb | stack riscv/riscv/support.S standard Modified: stable/12/sys/conf/ldscript.riscv ============================================================================== --- stable/12/sys/conf/ldscript.riscv Fri May 8 02:42:15 2020 (r360807) +++ stable/12/sys/conf/ldscript.riscv Fri May 8 05:30:10 2020 (r360808) @@ -7,7 +7,8 @@ SECTIONS { /* Read-only sections, merged into text segment: */ . = kernbase; - .text : AT(ADDR(.text) - kernbase) + /* The load address kernel_lma is set using --defsym= on the command line. */ + .text : AT(kernel_lma) { *(.text) *(.stub) Modified: stable/12/sys/riscv/include/md_var.h ============================================================================== --- stable/12/sys/riscv/include/md_var.h Fri May 8 02:42:15 2020 (r360807) +++ stable/12/sys/riscv/include/md_var.h Fri May 8 05:30:10 2020 (r360808) @@ -39,6 +39,9 @@ extern int szsigcode; extern uint64_t *vm_page_dump; extern int vm_page_dump_size; extern u_long elf_hwcap; +extern register_t mvendorid; +extern register_t marchid; +extern register_t mimpid; struct dumperinfo; Modified: stable/12/sys/riscv/include/sbi.h ============================================================================== --- stable/12/sys/riscv/include/sbi.h Fri May 8 02:42:15 2020 (r360807) +++ stable/12/sys/riscv/include/sbi.h Fri May 8 05:30:10 2020 (r360808) @@ -1,6 +1,7 @@ /*- * Copyright (c) 2016-2017 Ruslan Bukin * All rights reserved. + * Copyright (c) 2019 Mitchell Horne * * Portions of this software were developed by SRI International and the * University of Cambridge Computer Laboratory under DARPA/AFRL contract @@ -37,6 +38,35 @@ #ifndef _MACHINE_SBI_H_ #define _MACHINE_SBI_H_ +/* SBI Specification Version */ +#define SBI_SPEC_VERS_MAJOR_OFFSET 24 +#define SBI_SPEC_VERS_MAJOR_MASK (0x7F << SBI_SPEC_VERS_MAJOR_OFFSET) +#define SBI_SPEC_VERS_MINOR_OFFSET 0 +#define SBI_SPEC_VERS_MINOR_MASK (0xFFFFFF << SBI_SPEC_VERS_MINOR_OFFSET) + +/* SBI Implementation IDs */ +#define SBI_IMPL_ID_BBL 0 +#define SBI_IMPL_ID_OPENSBI 1 + +/* SBI Error Codes */ +#define SBI_SUCCESS 0 +#define SBI_ERR_FAILURE -1 +#define SBI_ERR_NOT_SUPPORTED -2 +#define SBI_ERR_INVALID_PARAM -3 +#define SBI_ERR_DENIED -4 +#define SBI_ERR_INVALID_ADDRESS -5 + +/* SBI Base Extension */ +#define SBI_EXT_ID_BASE 0x10 +#define SBI_BASE_GET_SPEC_VERSION 0 +#define SBI_BASE_GET_IMPL_ID 1 +#define SBI_BASE_GET_IMPL_VERSION 2 +#define SBI_BASE_PROBE_EXTENSION 3 +#define SBI_BASE_GET_MVENDORID 4 +#define SBI_BASE_GET_MARCHID 5 +#define SBI_BASE_GET_MIMPID 6 + +/* Legacy Extensions */ #define SBI_SET_TIMER 0 #define SBI_CONSOLE_PUTCHAR 1 #define SBI_CONSOLE_GETCHAR 2 @@ -47,77 +77,109 @@ #define SBI_REMOTE_SFENCE_VMA_ASID 7 #define SBI_SHUTDOWN 8 +#define SBI_CALL0(e, f) SBI_CALL4(e, f, 0, 0, 0, 0) +#define SBI_CALL1(e, f, p1) SBI_CALL4(e, f, p1, 0, 0, 0) +#define SBI_CALL2(e, f, p1, p2) SBI_CALL4(e, f, p1, p2, 0, 0) +#define SBI_CALL3(e, f, p1, p2, p3) SBI_CALL4(e, f, p1, p2, p3, 0) +#define SBI_CALL4(e, f, p1, p2, p3, p4) sbi_call(e, f, p1, p2, p3, p4) + /* * Documentation available at - * https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.md + * https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc */ -static __inline uint64_t -sbi_call(uint64_t arg7, uint64_t arg0, uint64_t arg1, uint64_t arg2, - uint64_t arg3) +struct sbi_ret { + long error; + long value; +}; + +static __inline struct sbi_ret +sbi_call(uint64_t arg7, uint64_t arg6, uint64_t arg0, uint64_t arg1, + uint64_t arg2, uint64_t arg3) { + struct sbi_ret ret; + register uintptr_t a0 __asm ("a0") = (uintptr_t)(arg0); register uintptr_t a1 __asm ("a1") = (uintptr_t)(arg1); register uintptr_t a2 __asm ("a2") = (uintptr_t)(arg2); register uintptr_t a3 __asm ("a3") = (uintptr_t)(arg3); + register uintptr_t a6 __asm ("a6") = (uintptr_t)(arg6); register uintptr_t a7 __asm ("a7") = (uintptr_t)(arg7); __asm __volatile( \ "ecall" \ - :"+r"(a0) \ - :"r"(a1), "r"(a2), "r" (a3), "r"(a7) \ + :"+r"(a0), "+r"(a1) \ + :"r"(a2), "r"(a3), "r"(a6), "r"(a7) \ :"memory"); - return (a0); + ret.error = a0; + ret.value = a1; + return (ret); } +/* Base extension functions and variables. */ +extern u_long sbi_spec_version; +extern u_long sbi_impl_id; +extern u_long sbi_impl_version; + +static __inline long +sbi_probe_extension(long id) +{ + return (SBI_CALL1(SBI_EXT_ID_BASE, SBI_BASE_PROBE_EXTENSION, id).value); +} + +/* Legacy extension functions. */ static __inline void sbi_console_putchar(int ch) { - sbi_call(SBI_CONSOLE_PUTCHAR, ch, 0, 0, 0); + (void)SBI_CALL1(SBI_CONSOLE_PUTCHAR, 0, ch); } static __inline int sbi_console_getchar(void) { - return (sbi_call(SBI_CONSOLE_GETCHAR, 0, 0, 0, 0)); + /* + * XXX: The "error" is returned here because legacy SBI functions + * continue to return their value in a0. + */ + return (SBI_CALL0(SBI_CONSOLE_GETCHAR, 0).error); } static __inline void sbi_set_timer(uint64_t val) { - sbi_call(SBI_SET_TIMER, val, 0, 0, 0); + (void)SBI_CALL1(SBI_SET_TIMER, 0, val); } static __inline void sbi_shutdown(void) { - sbi_call(SBI_SHUTDOWN, 0, 0, 0, 0); + (void)SBI_CALL0(SBI_SHUTDOWN, 0); } static __inline void sbi_clear_ipi(void) { - sbi_call(SBI_CLEAR_IPI, 0, 0, 0, 0); + (void)SBI_CALL0(SBI_CLEAR_IPI, 0); } static __inline void sbi_send_ipi(const unsigned long *hart_mask) { - sbi_call(SBI_SEND_IPI, (uint64_t)hart_mask, 0, 0, 0); + (void)SBI_CALL1(SBI_SEND_IPI, 0, (uint64_t)hart_mask); } static __inline void sbi_remote_fence_i(const unsigned long *hart_mask) { - sbi_call(SBI_REMOTE_FENCE_I, (uint64_t)hart_mask, 0, 0, 0); + (void)SBI_CALL1(SBI_REMOTE_FENCE_I, 0, (uint64_t)hart_mask); } static __inline void @@ -125,7 +187,8 @@ sbi_remote_sfence_vma(const unsigned long *hart_mask, unsigned long start, unsigned long size) { - sbi_call(SBI_REMOTE_SFENCE_VMA, (uint64_t)hart_mask, start, size, 0); + (void)SBI_CALL3(SBI_REMOTE_SFENCE_VMA, 0, (uint64_t)hart_mask, start, + size); } static __inline void @@ -134,8 +197,11 @@ sbi_remote_sfence_vma_asid(const unsigned long *hart_m unsigned long asid) { - sbi_call(SBI_REMOTE_SFENCE_VMA_ASID, (uint64_t)hart_mask, start, size, - asid); + (void)SBI_CALL4(SBI_REMOTE_SFENCE_VMA_ASID, 0, (uint64_t)hart_mask, + start, size, asid); } + +void sbi_print_version(void); +void sbi_init(void); #endif /* !_MACHINE_SBI_H_ */ Modified: stable/12/sys/riscv/riscv/identcpu.c ============================================================================== --- stable/12/sys/riscv/riscv/identcpu.c Fri May 8 02:42:15 2020 (r360807) +++ stable/12/sys/riscv/riscv/identcpu.c Fri May 8 05:30:10 2020 (r360808) @@ -59,6 +59,11 @@ char machine[] = "riscv"; SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, "Machine class"); +/* Hardware implementation info. These values may be empty. */ +register_t mvendorid; /* The CPU's JEDEC vendor ID */ +register_t marchid; /* The architecture ID */ +register_t mimpid; /* The implementation ID */ + struct cpu_desc { u_int cpu_impl; u_int cpu_part_num; Modified: stable/12/sys/riscv/riscv/machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/machdep.c Fri May 8 02:42:15 2020 (r360807) +++ stable/12/sys/riscv/riscv/machdep.c Fri May 8 05:30:10 2020 (r360808) @@ -128,6 +128,7 @@ static void cpu_startup(void *dummy) { + sbi_print_version(); identify_cpu(); printf("real memory = %ju (%ju MB)\n", ptoa((uintmax_t)realmem), @@ -847,6 +848,9 @@ initriscv(struct riscv_bootparams *rvbp) __asm __volatile("mv tp, %0" :: "r"(pcpup)); PCPU_SET(curthread, &thread0); + + /* Initialize SBI interface. */ + sbi_init(); /* Set the module data location */ lastaddr = fake_preload_metadata(rvbp); Copied and modified: stable/12/sys/riscv/riscv/sbi.c (from r354720, head/sys/riscv/riscv/sbi.c) ============================================================================== --- head/sys/riscv/riscv/sbi.c Fri Nov 15 03:34:27 2019 (r354720, copy source) +++ stable/12/sys/riscv/riscv/sbi.c Fri May 8 05:30:10 2020 (r360808) @@ -35,6 +35,10 @@ __FBSDID("$FreeBSD$"); #include #include +/* SBI Implementation-Specific Definitions */ +#define OPENSBI_VERSION_MAJOR_OFFSET 16 +#define OPENSBI_VERSION_MINOR_MASK 0xFFFF + u_long sbi_spec_version; u_long sbi_impl_id; u_long sbi_impl_version; @@ -74,6 +78,39 @@ static struct sbi_ret sbi_get_mimpid(void) { return (SBI_CALL0(SBI_EXT_ID_BASE, SBI_BASE_GET_MIMPID)); +} + +void +sbi_print_version(void) +{ + u_int major; + u_int minor; + + /* For legacy SBI implementations. */ + if (sbi_spec_version == 0) { + printf("SBI: Unknown (Legacy) Implementation\n"); + printf("SBI Specification Version: 0.1\n"); + return; + } + + switch (sbi_impl_id) { + case (SBI_IMPL_ID_BBL): + printf("SBI: Berkely Boot Loader %u\n", sbi_impl_version); + break; + case (SBI_IMPL_ID_OPENSBI): + major = sbi_impl_version >> OPENSBI_VERSION_MAJOR_OFFSET; + minor = sbi_impl_version & OPENSBI_VERSION_MINOR_MASK; + printf("SBI: OpenSBI v%u.%u\n", major, minor); + break; + default: + printf("SBI: Unrecognized Implementation: %u\n", sbi_impl_id); + break; + } + + major = (sbi_spec_version & SBI_SPEC_VERS_MAJOR_MASK) >> + SBI_SPEC_VERS_MAJOR_OFFSET; + minor = (sbi_spec_version & SBI_SPEC_VERS_MINOR_MASK); + printf("SBI Specification Version: %u.%u\n", major, minor); } void From owner-svn-src-stable-12@freebsd.org Fri May 8 14:10:30 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 747D42D854E; Fri, 8 May 2020 14:10: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 49JXKf2G1Dz3Ljr; Fri, 8 May 2020 14:10: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 4438737DE; Fri, 8 May 2020 14:10:30 +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 048EAURp037348; Fri, 8 May 2020 14:10:30 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 048EAULJ037347; Fri, 8 May 2020 14:10:30 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202005081410.048EAULJ037347@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 8 May 2020 14:10: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: r360809 - stable/12/sys/mips/mips X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/mips/mips X-SVN-Commit-Revision: 360809 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 08 May 2020 14:10:30 -0000 Author: markj Date: Fri May 8 14:10:29 2020 New Revision: 360809 URL: https://svnweb.freebsd.org/changeset/base/360809 Log: MFC r360281: Fix a race in pmap_emulate_modified(). Modified: stable/12/sys/mips/mips/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/mips/mips/pmap.c ============================================================================== --- stable/12/sys/mips/mips/pmap.c Fri May 8 05:30:10 2020 (r360808) +++ stable/12/sys/mips/mips/pmap.c Fri May 8 14:10:29 2020 (r360809) @@ -3441,28 +3441,71 @@ pmap_emulate_modified(pmap_t pmap, vm_offset_t va) PMAP_LOCK(pmap); pte = pmap_pte(pmap, va); - if (pte == NULL) - panic("pmap_emulate_modified: can't find PTE"); -#ifdef SMP - /* It is possible that some other CPU changed m-bit */ - if (!pte_test(pte, PTE_V) || pte_test(pte, PTE_D)) { + + /* + * It is possible that some other CPU or thread changed the pmap while + * we weren't looking; in the SMP case, this is readily apparent, but + * it can even happen in the UP case, because we may have been blocked + * on PMAP_LOCK(pmap) above while someone changed this out from + * underneath us. + */ + + if (pte == NULL) { + /* + * This PTE's PTP (or one of its ancestors) has been reclaimed; + * trigger a full fault to reconstruct it via pmap_enter. + */ + PMAP_UNLOCK(pmap); + return (1); + } + + if (!pte_test(pte, PTE_V)) { + /* + * This PTE is no longer valid; the other thread or other + * processor must have arranged for our TLB to no longer + * have this entry, possibly by IPI, so no tlb_update is + * required. Fall out of the fast path and go take a + * general fault before retrying the instruction (or taking + * a signal). + */ + PMAP_UNLOCK(pmap); + return (1); + } + + if (pte_test(pte, PTE_D)) { + /* + * This PTE is valid and has the PTE_D bit asserted; since + * this is an increase in permission, we may have been expected + * to update the TLB lazily. Do so here and return, on the + * fast path, to retry the instruction. + */ tlb_update(pmap, va, *pte); PMAP_UNLOCK(pmap); return (0); } -#else - if (!pte_test(pte, PTE_V) || pte_test(pte, PTE_D)) - panic("pmap_emulate_modified: invalid pte"); -#endif + if (pte_test(pte, PTE_RO)) { + /* + * This PTE is valid, not dirty, and read-only. Go take a + * full fault (most likely to upgrade this part of the address + * space to writeable). + */ PMAP_UNLOCK(pmap); return (1); } - pte_set(pte, PTE_D); - tlb_update(pmap, va, *pte); + if (!pte_test(pte, PTE_MANAGED)) panic("pmap_emulate_modified: unmanaged page"); + + /* + * PTE is valid, managed, not dirty, and not read-only. Set PTE_D + * and eagerly update the local TLB, returning on the fast path. + */ + + pte_set(pte, PTE_D); + tlb_update(pmap, va, *pte); PMAP_UNLOCK(pmap); + return (0); } From owner-svn-src-stable-12@freebsd.org Fri May 8 14:10:33 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4918C2D857D; Fri, 8 May 2020 14:10:33 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49JXKj1DZgz3Lkg; Fri, 8 May 2020 14:10:33 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro-164.local (unknown [IPv6:2601:648:8203:2990:540c:ccc7:66a5:27b6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id A0EF5E63D; Fri, 8 May 2020 14:10:32 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: svn commit: r360808 - in stable/12/sys: conf riscv/include riscv/riscv From: John Baldwin To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org References: <202005080530.0485UBdx008409@repo.freebsd.org> Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGfnQH+rNAaH0livoSBQ0IPI/8WfIW7ub4qV6HYwWKVqkDkqwcpmGNDbz3gfaDht6nsie5Z pcuCcul4M9CW7Md6zzyvktjnbz61BADGDCopfZC4of0Z3Ka0u8Wik6UJOuqShBt1WcFS8ya1 oB4rc4tXfSHyMF63aPUBMxHR5DXeH+EO2edoSwViDMqWk1jTnYza51rbGY+pebLQOVOxAY7k do5Ordl3wklBPMVEPWoZ61SdbcjhHVwaC5zfiskcxj5wwXd2E9qYlBqRg7QeSm9obiBCYWxk d2luIDxqaGJARnJlZUJTRC5vcmc+iGAEExECACAFAkTQ+awCGwMGCwkIBwMCBBUCCAMEFgID AQIeAQIXgAAKCRBy3lIGd+N/BI6RAJ9S97fvbME+3hxzE3JUyUZ6vTewDACdE1stFuSfqMvM jomvZdYxIYyTUpC5Ag0ERND5ghAIAPwsO0B7BL+bz8sLlLoQktGxXwXQfS5cInvL17Dsgnr3 1AKa94j9EnXQyPEj7u0d+LmEe6CGEGDh1OcGFTMVrof2ZzkSy4+FkZwMKJpTiqeaShMh+Goj XlwIMDxyADYvBIg3eN5YdFKaPQpfgSqhT+7El7w+wSZZD8pPQuLAnie5iz9C8iKy4/cMSOrH YUK/tO+Nhw8Jjlw94Ik0T80iEhI2t+XBVjwdfjbq3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: <7c3695f6-e58a-b6ef-5004-b8d54feabdf3@FreeBSD.org> Date: Fri, 8 May 2020 07:10:30 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <202005080530.0485UBdx008409@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 08 May 2020 14:10:33 -0000 On 5/7/20 10:30 PM, John Baldwin wrote: > Author: jhb > Date: Fri May 8 05:30:10 2020 > New Revision: 360808 > URL: https://svnweb.freebsd.org/changeset/base/360808 > > Log: > MFC 354719,354720,354721,354722,357480: OpenSBI support. Booting via -kernel with qemu hangs trying to mount root for me on 12.x still which I haven't debugged yet. -- John Baldwin From owner-svn-src-stable-12@freebsd.org Fri May 8 14:10:50 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D963E2D85CD; Fri, 8 May 2020 14:10: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 49JXL13C1jz3Lwy; Fri, 8 May 2020 14:10:49 +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 390C337F8; Fri, 8 May 2020 14:10: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 048EAmqT040464; Fri, 8 May 2020 14:10:48 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 048EAmxx040463; Fri, 8 May 2020 14:10:48 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202005081410.048EAmxx040463@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 8 May 2020 14:10: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: r360810 - stable/12/sys/mips/mips X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/mips/mips X-SVN-Commit-Revision: 360810 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 08 May 2020 14:10:51 -0000 Author: markj Date: Fri May 8 14:10:47 2020 New Revision: 360810 URL: https://svnweb.freebsd.org/changeset/base/360810 Log: MFC r360280: Fix a race between _pmap_unwire_ptp() and MipsDoTLBMiss(). Modified: stable/12/sys/mips/mips/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/mips/mips/pmap.c ============================================================================== --- stable/12/sys/mips/mips/pmap.c Fri May 8 14:10:29 2020 (r360809) +++ stable/12/sys/mips/mips/pmap.c Fri May 8 14:10:47 2020 (r360810) @@ -975,18 +975,26 @@ static void _pmap_unwire_ptp(pmap_t pmap, vm_offset_t va, vm_page_t m) { pd_entry_t *pde; + vm_offset_t sva, eva; PMAP_LOCK_ASSERT(pmap, MA_OWNED); /* * unmap the page table page */ #ifdef __mips_n64 - if (m->pindex < NUPDE) + if (m->pindex < NUPDE) { pde = pmap_pde(pmap, va); - else + sva = va & ~PDRMASK; + eva = sva + NBPDR; + } else { pde = pmap_segmap(pmap, va); + sva = va & ~SEGMASK; + eva = sva + NBSEG; + } #else pde = pmap_pde(pmap, va); + sva = va & ~SEGMASK; + eva = sva + NBSEG; #endif *pde = 0; pmap->pm_stats.resident_count--; @@ -997,12 +1005,22 @@ _pmap_unwire_ptp(pmap_t pmap, vm_offset_t va, vm_page_ vm_page_t pdpg; /* - * Recursively decrement next level pagetable refcount + * Recursively decrement next level pagetable refcount. + * Either that shoots down a larger range from TLBs (below) + * or we're to shoot down just the page in question. */ pdp = (pd_entry_t *)*pmap_segmap(pmap, va); pdpg = PHYS_TO_VM_PAGE(MIPS_DIRECT_TO_PHYS(pdp)); - pmap_unwire_ptp(pmap, va, pdpg); + if (!pmap_unwire_ptp(pmap, va, pdpg)) { + pmap_invalidate_range(pmap, sva, eva); + } + } else { + /* Segmap entry shootdown */ + pmap_invalidate_range(pmap, sva, eva); } +#else + /* Segmap entry shootdown */ + pmap_invalidate_range(pmap, sva, eva); #endif /* @@ -1455,7 +1473,15 @@ pmap_pv_reclaim(pmap_t locked_pmap) if (TAILQ_EMPTY(&m->md.pv_list)) vm_page_aflag_clear(m, PGA_WRITEABLE); pc->pc_map[field] |= 1UL << bit; - pmap_unuse_pt(pmap, va, *pde); + + /* + * For simplicity, we will unconditionally shoot + * down TLBs either at the end of this function + * or at the top of the loop above if we switch + * to a different pmap. + */ + (void)pmap_unuse_pt(pmap, va, *pde); + freed++; } } @@ -1684,6 +1710,23 @@ pmap_try_insert_pv_entry(pmap_t pmap, vm_page_t mpte, /* * pmap_remove_pte: do the things to unmap a page in a process + * + * Returns true if this was the last PTE in the PT (and possibly the last PT in + * the PD, and possibly the last PD in the segmap), in which case... + * + * 1) the TLB has been invalidated for the whole PT's span (at least), + * already, to ensure that MipsDoTLBMiss does not attempt to follow a + * dangling pointer into a freed page. No additional TLB shootdown is + * required. + * + * 2) if this removal was part of a sweep to remove PTEs, it is safe to jump + * to the PT span boundary and continue. + * + * 3) The given pde may now point onto a freed page and must not be + * dereferenced + * + * If the return value is false, the TLB has not been shot down (and the segmap + * entry, PD, and PT all remain in place). */ static int pmap_remove_pte(struct pmap *pmap, pt_entry_t *ptq, vm_offset_t va, @@ -1752,8 +1795,12 @@ pmap_remove_page(struct pmap *pmap, vm_offset_t va) if (!pte_test(ptq, PTE_V)) return; - (void)pmap_remove_pte(pmap, ptq, va, *pde); - pmap_invalidate_page(pmap, va); + /* + * Remove this PTE from the PT. If this is the last one, then + * the TLB has already been shot down, so don't bother again + */ + if (!pmap_remove_pte(pmap, ptq, va, *pde)) + pmap_invalidate_page(pmap, va); } /* @@ -1767,7 +1814,9 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t { pd_entry_t *pde, *pdpe; pt_entry_t *pte; - vm_offset_t va, va_next; + vm_offset_t va_next; + vm_offset_t va_init, va_fini; + bool need_tlb_shootdown; /* * Perform an unsynchronized read. This is, however, safe. @@ -1796,6 +1845,8 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t continue; } #endif + + /* Scan up to the end of the page table pointed to by pde */ va_next = (sva + NBPDR) & ~PDRMASK; if (va_next < sva) va_next = eva; @@ -1812,25 +1863,44 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t if (va_next > eva) va_next = eva; - va = va_next; + need_tlb_shootdown = false; + va_init = sva; + va_fini = va_next; for (pte = pmap_pde_to_pte(pde, sva); sva != va_next; pte++, sva += PAGE_SIZE) { + + /* Skip over invalid entries; no need to shootdown */ if (!pte_test(pte, PTE_V)) { - if (va != va_next) { - pmap_invalidate_range(pmap, va, sva); - va = va_next; - } + /* + * If we have not yet found a valid entry, then + * we can move the lower edge of the region to + * invalidate to the next PTE. + */ + if (!need_tlb_shootdown) + va_init = sva + PAGE_SIZE; continue; } - if (va == va_next) - va = sva; + + /* + * A valid entry; the range we are shooting down must + * include this page. va_fini is used instead of sva + * so that if the range ends with a run of !PTE_V PTEs, + * but doesn't clear out so much that pmap_remove_pte + * removes the entire PT, we won't include these !PTE_V + * entries in the region to be shot down. + */ + va_fini = sva + PAGE_SIZE; + if (pmap_remove_pte(pmap, pte, sva, *pde)) { - sva += PAGE_SIZE; + /* Entire PT removed and TLBs shot down. */ + need_tlb_shootdown = false; break; + } else { + need_tlb_shootdown = true; } } - if (va != va_next) - pmap_invalidate_range(pmap, va, sva); + if (need_tlb_shootdown) + pmap_invalidate_range(pmap, va_init, va_fini); } out: rw_wunlock(&pvh_global_lock); @@ -1900,10 +1970,11 @@ pmap_remove_all(vm_page_t m) __func__, (void *)pv->pv_va, (uintmax_t)tpte)); vm_page_dirty(m); } - pmap_invalidate_page(pmap, pv->pv_va); + if (!pmap_unuse_pt(pmap, pv->pv_va, *pde)) + pmap_invalidate_page(pmap, pv->pv_va); + TAILQ_REMOVE(&m->md.pv_list, pv, pv_list); - pmap_unuse_pt(pmap, pv->pv_va, *pde); free_pv_entry(pmap, pv); PMAP_UNLOCK(pmap); } @@ -2810,7 +2881,12 @@ pmap_remove_pages(pmap_t pmap) TAILQ_REMOVE(&m->md.pv_list, pv, pv_list); if (TAILQ_EMPTY(&m->md.pv_list)) vm_page_aflag_clear(m, PGA_WRITEABLE); - pmap_unuse_pt(pmap, pv->pv_va, *pde); + + /* + * For simplicity, unconditionally call + * pmap_invalidate_all(), below. + */ + (void)pmap_unuse_pt(pmap, pv->pv_va, *pde); } } if (allfree) { From owner-svn-src-stable-12@freebsd.org Fri May 8 14:13:30 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E86022D8809; Fri, 8 May 2020 14:13: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 49JXP65wwcz3MKs; Fri, 8 May 2020 14:13: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 AC79639CD; Fri, 8 May 2020 14:13:30 +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 048EDUaY043070; Fri, 8 May 2020 14:13:30 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 048EDURj043069; Fri, 8 May 2020 14:13:30 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202005081413.048EDURj043069@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 8 May 2020 14:13: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: r360811 - stable/12/sys/arm64/arm64 X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/arm64/arm64 X-SVN-Commit-Revision: 360811 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 08 May 2020 14:13:31 -0000 Author: markj Date: Fri May 8 14:13:30 2020 New Revision: 360811 URL: https://svnweb.freebsd.org/changeset/base/360811 Log: MFC r360277: Fix handling of 1GB mappings in the arm64 minidump code. Modified: stable/12/sys/arm64/arm64/minidump_machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm64/arm64/minidump_machdep.c ============================================================================== --- stable/12/sys/arm64/arm64/minidump_machdep.c Fri May 8 14:10:47 2020 (r360810) +++ stable/12/sys/arm64/arm64/minidump_machdep.c Fri May 8 14:13:30 2020 (r360811) @@ -34,8 +34,6 @@ __FBSDID("$FreeBSD$"); #include "opt_watchdog.h" -#include "opt_watchdog.h" - #include #include #include @@ -68,7 +66,7 @@ static size_t fragsz; static void *dump_va; static size_t counter, progress, dumpsize; -static uint64_t tmpbuffer[PAGE_SIZE / sizeof(uint64_t)]; +static uint64_t tmpbuffer[Ln_ENTRIES]; CTASSERT(sizeof(*vm_page_dump) == 8); @@ -210,16 +208,14 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t int minidumpsys(struct dumperinfo *di) { + struct minidumphdr mdhdr; pd_entry_t *l0, *l1, *l2; pt_entry_t *l3; - uint32_t pmapsize; vm_offset_t va; vm_paddr_t pa; - int error; uint64_t bits; - int i, bit; - int retry_count; - struct minidumphdr mdhdr; + uint32_t pmapsize; + int bit, error, i, j, retry_count; retry_count = 0; retry: @@ -231,11 +227,15 @@ minidumpsys(struct dumperinfo *di) if (!pmap_get_tables(pmap_kernel(), va, &l0, &l1, &l2, &l3)) continue; - /* We should always be using the l2 table for kvm */ - if (l2 == NULL) - continue; - - if ((*l2 & ATTR_DESCR_MASK) == L2_BLOCK) { + if ((*l1 & ATTR_DESCR_MASK) == L1_BLOCK) { + pa = *l1 & ~ATTR_MASK; + for (i = 0; i < Ln_ENTRIES * Ln_ENTRIES; + i++, pa += PAGE_SIZE) + if (is_dumpable(pa)) + dump_add_page(pa); + pmapsize += (Ln_ENTRIES - 1) * PAGE_SIZE; + va += L1_SIZE - L2_SIZE; + } else if ((*l2 & ATTR_DESCR_MASK) == L2_BLOCK) { pa = *l2 & ~ATTR_MASK; for (i = 0; i < Ln_ENTRIES; i++, pa += PAGE_SIZE) { if (is_dumpable(pa)) @@ -327,25 +327,31 @@ minidumpsys(struct dumperinfo *di) error = blk_flush(di); if (error) goto fail; - } else if (l2 == NULL) { + } else if ((*l1 & ATTR_DESCR_MASK) == L1_BLOCK) { + /* + * Handle a 1GB block mapping: write out 512 fake L2 + * pages. + */ pa = (*l1 & ~ATTR_MASK) | (va & L1_OFFSET); - /* Generate fake l3 entries based upon the l1 entry */ for (i = 0; i < Ln_ENTRIES; i++) { - tmpbuffer[i] = pa + (i * PAGE_SIZE) | - ATTR_DEFAULT | L3_PAGE; + for (j = 0; j < Ln_ENTRIES; j++) { + tmpbuffer[j] = pa + i * L2_SIZE + + j * PAGE_SIZE | ATTR_DEFAULT | + L3_PAGE; + } + error = blk_write(di, (char *)&tmpbuffer, 0, + PAGE_SIZE); + if (error) + goto fail; } - /* We always write a page, even if it is zero */ - error = blk_write(di, (char *)&tmpbuffer, 0, PAGE_SIZE); - if (error) - goto fail; /* flush, in case we reuse tmpbuffer in the same block*/ error = blk_flush(di); if (error) goto fail; bzero(&tmpbuffer, sizeof(tmpbuffer)); + va += L1_SIZE - L2_SIZE; } else if ((*l2 & ATTR_DESCR_MASK) == L2_BLOCK) { - /* TODO: Handle an invalid L2 entry */ pa = (*l2 & ~ATTR_MASK) | (va & L2_OFFSET); /* Generate fake l3 entries based upon the l1 entry */ @@ -353,7 +359,6 @@ minidumpsys(struct dumperinfo *di) tmpbuffer[i] = pa + (i * PAGE_SIZE) | ATTR_DEFAULT | L3_PAGE; } - /* We always write a page, even if it is zero */ error = blk_write(di, (char *)&tmpbuffer, 0, PAGE_SIZE); if (error) goto fail; @@ -366,7 +371,6 @@ minidumpsys(struct dumperinfo *di) } else { pa = *l2 & ~ATTR_MASK; - /* We always write a page, even if it is zero */ error = blk_write(di, NULL, pa, PAGE_SIZE); if (error) goto fail; From owner-svn-src-stable-12@freebsd.org Fri May 8 14:48:48 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E91652D933C; Fri, 8 May 2020 14:48:48 +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 49JY9r5r3nz3NvM; Fri, 8 May 2020 14:48:48 +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 BEE824035; Fri, 8 May 2020 14:48:48 +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 048EmmrU062627; Fri, 8 May 2020 14:48:48 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 048Emjdc062610; Fri, 8 May 2020 14:48:45 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005081448.048Emjdc062610@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 8 May 2020 14:48:45 +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: r360814 - in stable/12/sys: conf kern X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/12/sys: conf kern X-SVN-Commit-Revision: 360814 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 08 May 2020 14:48:49 -0000 Author: jhb Date: Fri May 8 14:48:45 2020 New Revision: 360814 URL: https://svnweb.freebsd.org/changeset/base/360814 Log: MFC 348611: Expose the kernel's build-ID through sysctl After our migration (of certain architectures) to lld the kernel is built with a unique build-ID. Make it available via a sysctl and uname(1) to allow the user to identify their running kernel. Modified: stable/12/sys/conf/ldscript.amd64 stable/12/sys/conf/ldscript.arm stable/12/sys/conf/ldscript.arm64 stable/12/sys/conf/ldscript.i386 stable/12/sys/conf/ldscript.mips stable/12/sys/conf/ldscript.mips.cfe stable/12/sys/conf/ldscript.mips.mips64 stable/12/sys/conf/ldscript.mips.octeon1 stable/12/sys/conf/ldscript.powerpc stable/12/sys/conf/ldscript.powerpc64 stable/12/sys/conf/ldscript.powerpcspe stable/12/sys/conf/ldscript.riscv stable/12/sys/conf/ldscript.sparc64 stable/12/sys/kern/kern_mib.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/conf/ldscript.amd64 ============================================================================== --- stable/12/sys/conf/ldscript.amd64 Fri May 8 14:39:38 2020 (r360813) +++ stable/12/sys/conf/ldscript.amd64 Fri May 8 14:48:45 2020 (r360814) @@ -74,6 +74,11 @@ SECTIONS PROVIDE (etext = .); .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } .rodata1 : { *(.rodata1) } + .note.gnu.build-id : { + PROVIDE (__build_id_start = .); + *(.note.gnu.build-id) + PROVIDE (__build_id_end = .); + } .eh_frame_hdr : { *(.eh_frame_hdr) } .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } Modified: stable/12/sys/conf/ldscript.arm ============================================================================== --- stable/12/sys/conf/ldscript.arm Fri May 8 14:39:38 2020 (r360813) +++ stable/12/sys/conf/ldscript.arm Fri May 8 14:48:45 2020 (r360814) @@ -27,6 +27,11 @@ SECTIONS .gnu.version : { *(.gnu.version) } .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } + .note.gnu.build-id : { + PROVIDE (__build_id_start = .); + *(.note.gnu.build-id) + PROVIDE (__build_id_end = .); + } .rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) } .rela.text : Modified: stable/12/sys/conf/ldscript.arm64 ============================================================================== --- stable/12/sys/conf/ldscript.arm64 Fri May 8 14:39:38 2020 (r360813) +++ stable/12/sys/conf/ldscript.arm64 Fri May 8 14:48:45 2020 (r360814) @@ -27,6 +27,11 @@ SECTIONS .gnu.version : { *(.gnu.version) } .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } + .note.gnu.build-id : { + PROVIDE (__build_id_start = .); + *(.note.gnu.build-id) + PROVIDE (__build_id_end = .); + } .rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) } .rela.text : Modified: stable/12/sys/conf/ldscript.i386 ============================================================================== --- stable/12/sys/conf/ldscript.i386 Fri May 8 14:39:38 2020 (r360813) +++ stable/12/sys/conf/ldscript.i386 Fri May 8 14:48:45 2020 (r360814) @@ -62,6 +62,11 @@ SECTIONS PROVIDE (etext = .); .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } .rodata1 : { *(.rodata1) } + .note.gnu.build-id : { + PROVIDE (__build_id_start = .); + *(.note.gnu.build-id) + PROVIDE (__build_id_end = .); + } .eh_frame_hdr : { *(.eh_frame_hdr) } .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } Modified: stable/12/sys/conf/ldscript.mips ============================================================================== --- stable/12/sys/conf/ldscript.mips Fri May 8 14:39:38 2020 (r360813) +++ stable/12/sys/conf/ldscript.mips Fri May 8 14:48:45 2020 (r360814) @@ -63,6 +63,11 @@ SECTIONS .gnu.version : { *(.gnu.version) } .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } + .note.gnu.build-id : { + PROVIDE (__build_id_start = .); + *(.note.gnu.build-id) + PROVIDE (__build_id_end = .); + } .rel.init : { *(.rel.init) } .rela.init : { *(.rela.init) } .rel.text : Modified: stable/12/sys/conf/ldscript.mips.cfe ============================================================================== --- stable/12/sys/conf/ldscript.mips.cfe Fri May 8 14:39:38 2020 (r360813) +++ stable/12/sys/conf/ldscript.mips.cfe Fri May 8 14:48:45 2020 (r360814) @@ -192,6 +192,11 @@ SECTIONS PROVIDE (etext = .); .rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r.*) } .rodata1 : { *(.rodata1) } + .note.gnu.build-id : { + PROVIDE (__build_id_start = .); + *(.note.gnu.build-id) + PROVIDE (__build_id_end = .); + } .reginfo : { *(.reginfo) } .sdata2 : { *(.sdata2) *(.sdata2.*) *(.gnu.linkonce.s2.*) } .sbss2 : { *(.sbss2) *(.sbss2.*) *(.gnu.linkonce.sb2.*) } Modified: stable/12/sys/conf/ldscript.mips.mips64 ============================================================================== --- stable/12/sys/conf/ldscript.mips.mips64 Fri May 8 14:39:38 2020 (r360813) +++ stable/12/sys/conf/ldscript.mips.mips64 Fri May 8 14:48:45 2020 (r360814) @@ -176,6 +176,11 @@ SECTIONS PROVIDE (etext = .); .rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r.*) } .rodata1 : { *(.rodata1) } + .note.gnu.build-id : { + PROVIDE (__build_id_start = .); + *(.note.gnu.build-id) + PROVIDE (__build_id_end = .); + } .reginfo : { *(.reginfo) } .sdata2 : { *(.sdata2) *(.sdata2.*) *(.gnu.linkonce.s2.*) } .sbss2 : { *(.sbss2) *(.sbss2.*) *(.gnu.linkonce.sb2.*) } Modified: stable/12/sys/conf/ldscript.mips.octeon1 ============================================================================== --- stable/12/sys/conf/ldscript.mips.octeon1 Fri May 8 14:39:38 2020 (r360813) +++ stable/12/sys/conf/ldscript.mips.octeon1 Fri May 8 14:48:45 2020 (r360814) @@ -23,6 +23,12 @@ SECTIONS { *(.rodata) . = ALIGN(32); } + + .note.gnu.build-id : { + PROVIDE (__build_id_start = .); + *(.note.gnu.build-id) + PROVIDE (__build_id_end = .); + } .data : { _rwdata = .; Modified: stable/12/sys/conf/ldscript.powerpc ============================================================================== --- stable/12/sys/conf/ldscript.powerpc Fri May 8 14:39:38 2020 (r360813) +++ stable/12/sys/conf/ldscript.powerpc Fri May 8 14:48:45 2020 (r360814) @@ -55,6 +55,11 @@ SECTIONS .fini : { *(.fini) } =0 .rodata : { *(.rodata) *(.gnu.linkonce.r*) } .rodata1 : { *(.rodata1) } + .note.gnu.build-id : { + PROVIDE (__build_id_start = .); + *(.note.gnu.build-id) + PROVIDE (__build_id_end = .); + } .sdata2 : { *(.sdata2) } .sbss2 : { *(.sbss2) } /* Adjust the address for the data segment to the next page up. */ Modified: stable/12/sys/conf/ldscript.powerpc64 ============================================================================== --- stable/12/sys/conf/ldscript.powerpc64 Fri May 8 14:39:38 2020 (r360813) +++ stable/12/sys/conf/ldscript.powerpc64 Fri May 8 14:48:45 2020 (r360814) @@ -41,6 +41,11 @@ SECTIONS .gnu.version : { *(.gnu.version) } .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } + .note.gnu.build-id : { + PROVIDE (__build_id_start = .); + *(.note.gnu.build-id) + PROVIDE (__build_id_end = .); + } .rela.text : { *(.rela.text) *(.rela.gnu.linkonce.t*) } .rela.data : Modified: stable/12/sys/conf/ldscript.powerpcspe ============================================================================== --- stable/12/sys/conf/ldscript.powerpcspe Fri May 8 14:39:38 2020 (r360813) +++ stable/12/sys/conf/ldscript.powerpcspe Fri May 8 14:48:45 2020 (r360814) @@ -55,6 +55,11 @@ SECTIONS .fini : { *(.fini) } =0 .rodata : { *(.rodata) *(.gnu.linkonce.r*) } .rodata1 : { *(.rodata1) } + .note.gnu.build-id : { + PROVIDE (__build_id_start = .); + *(.note.gnu.build-id) + PROVIDE (__build_id_end = .); + } .sdata2 : { *(.sdata2) } .sbss2 : { *(.sbss2) } /* Adjust the address for the data segment to the next page up. */ Modified: stable/12/sys/conf/ldscript.riscv ============================================================================== --- stable/12/sys/conf/ldscript.riscv Fri May 8 14:39:38 2020 (r360813) +++ stable/12/sys/conf/ldscript.riscv Fri May 8 14:48:45 2020 (r360814) @@ -28,6 +28,11 @@ SECTIONS .gnu.version : { *(.gnu.version) } .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } + .note.gnu.build-id : { + PROVIDE (__build_id_start = .); + *(.note.gnu.build-id) + PROVIDE (__build_id_end = .); + } .rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) } .rela.text : Modified: stable/12/sys/conf/ldscript.sparc64 ============================================================================== --- stable/12/sys/conf/ldscript.sparc64 Fri May 8 14:39:38 2020 (r360813) +++ stable/12/sys/conf/ldscript.sparc64 Fri May 8 14:48:45 2020 (r360814) @@ -146,6 +146,11 @@ SECTIONS PROVIDE (etext = .); .rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r.*) } .rodata1 : { *(.rodata1) } + .note.gnu.build-id : { + PROVIDE (__build_id_start = .); + *(.note.gnu.build-id) + PROVIDE (__build_id_end = .); + } .sdata2 : { *(.sdata2) *(.sdata2.*) *(.gnu.linkonce.s2.*) } .sbss2 : { *(.sbss2) *(.sbss2.*) *(.gnu.linkonce.sb2.*) } . = ALIGN(0x2000) + (. & (0x2000 - 1)); Modified: stable/12/sys/kern/kern_mib.c ============================================================================== --- stable/12/sys/kern/kern_mib.c Fri May 8 14:39:38 2020 (r360813) +++ stable/12/sys/kern/kern_mib.c Fri May 8 14:48:45 2020 (r360814) @@ -491,6 +491,54 @@ SYSCTL_PROC(_kern, KERN_OSRELDATE, osreldate, CTLTYPE_INT | CTLFLAG_CAPRD | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, sysctl_osreldate, "I", "Kernel release date"); +/* + * The build-id is copied from the ELF section .note.gnu.build-id. The linker + * script defines two variables to expose the beginning and end. LLVM + * currently uses a SHA-1 hash, but other formats can be supported by checking + * the length of the section. + */ + +extern char __build_id_start[]; +extern char __build_id_end[]; + +#define BUILD_ID_HEADER_LEN 0x10 +#define BUILD_ID_HASH_MAXLEN 0x14 + +static int +sysctl_build_id(SYSCTL_HANDLER_ARGS) +{ + uintptr_t sectionlen = (uintptr_t)(__build_id_end - __build_id_start); + int hashlen; + char buf[2*BUILD_ID_HASH_MAXLEN+1]; + + /* + * The ELF note section has a four byte length for the vendor name, + * four byte length for the value, and a four byte vendor specific + * type. The name for the build id is "GNU\0". We skip the first 16 + * bytes to read the build hash. We will return the remaining bytes up + * to 20 (SHA-1) hash size. If the hash happens to be a custom number + * of bytes we will pad the value with zeros, as the section should be + * four byte aligned. + */ + if (sectionlen <= BUILD_ID_HEADER_LEN || + sectionlen > (BUILD_ID_HEADER_LEN + BUILD_ID_HASH_MAXLEN)) { + return (ENOENT); + } + + + hashlen = sectionlen - BUILD_ID_HEADER_LEN; + for (int i = 0; i < hashlen; i++) { + uint8_t c = __build_id_start[i+BUILD_ID_HEADER_LEN]; + snprintf(&buf[2*i], 3, "%02x", c); + } + + return (SYSCTL_OUT(req, buf, strlen(buf) + 1)); +} + +SYSCTL_PROC(_kern, OID_AUTO, build_id, + CTLTYPE_STRING | CTLFLAG_CAPRD | CTLFLAG_RD | CTLFLAG_MPSAFE, + NULL, 0, sysctl_build_id, "A", "Operating system build-id"); + SYSCTL_NODE(_kern, OID_AUTO, features, CTLFLAG_RD, 0, "Kernel Features"); #ifdef COMPAT_FREEBSD4 From owner-svn-src-stable-12@freebsd.org Fri May 8 15:05:05 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EA9AB2D9881; Fri, 8 May 2020 15:05:05 +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 49JYXd54kKz3Px2; Fri, 8 May 2020 15:05:05 +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 8EEA24427; Fri, 8 May 2020 15:05:05 +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 048F55rU075126; Fri, 8 May 2020 15:05:05 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 048F55WS075125; Fri, 8 May 2020 15:05:05 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005081505.048F55WS075125@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 8 May 2020 15:05: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: r360817 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 360817 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 08 May 2020 15:05:06 -0000 Author: jhb Date: Fri May 8 15:05:05 2020 New Revision: 360817 URL: https://svnweb.freebsd.org/changeset/base/360817 Log: MFC 354603,354604,354717,354718: Sync PLIC code with head. 354603: plic: fix PLIC_MAX_IRQS The maximum number of PLIC interrupts is defined in the PLIC spec[1] as 1024. 354604: plic: check for sifive compatible string The Linux dts for the HiFive Unleashed does not contain the usual "riscv,plic0" compat string, but our PLIC driver is compatible. 354717: plic: fix context calculation The RISC-V PLIC (platform level interrupt controller) registers are divided up by "context", which is purposefully left ambiguous in the PLIC spec. Currently we assume each CPU number corresponds 1-to-1 with a context number, but that is not correct. Most existing PLIC implementations (such as SiFive's) have multiple contexts per-cpu. For example, a single CPU might have a context for machine mode interrupts and a context for supervisor mode interrupts. To complicate things further, FreeBSD renumbers the CPUs during boot, but the PLIC driver still assumes that CPU ID equals the RISC-V hart number, meaning interrupt enables/claims might be performed for the wrong context registers. To fix this, we must calculate each CPU's context number during attachment. This is done by reading the interrupt properties from the device tree, from which a mapping from context to RISC-V hart to CPU number can be created. 354718: plic: support irq distribution Our PLIC implementation only enables interrupts on the boot cpu. Implement plic_bind_intr() so that they can be redistributed near the end of boot during intr_irq_shuffle(). This also slightly modifies how enable bits are handled in an attempt to better fit the PIC interface. plic_enable_intr()/plic_disable_intr() are converted to manage an interrupt source's threshold value, since this value can be used as to globally enable/disable an irq. All handing of the per-context enable bits is moved to the new methods plic_setup_intr() and plic_bind_intr(). Modified: stable/12/sys/riscv/riscv/plic.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/plic.c ============================================================================== --- stable/12/sys/riscv/riscv/plic.c Fri May 8 15:03:28 2020 (r360816) +++ stable/12/sys/riscv/riscv/plic.c Fri May 8 15:05:05 2020 (r360817) @@ -3,11 +3,12 @@ * * Copyright (c) 2018 Ruslan Bukin * All rights reserved. + * Copyright (c) 2019 Mitchell Horne * - * 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. + * Portions of this software were 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 @@ -42,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -52,21 +54,49 @@ __FBSDID("$FreeBSD$"); #include "pic_if.h" -#define PLIC_MAX_IRQS 2048 -#define PLIC_PRIORITY(n) (0x000000 + (n) * 0x4) -#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) +#define PLIC_MAX_IRQS 1024 +#define PLIC_PRIORITY_BASE 0x000000U + +#define PLIC_ENABLE_BASE 0x002000U +#define PLIC_ENABLE_STRIDE 0x80U + +#define PLIC_CONTEXT_BASE 0x200000U +#define PLIC_CONTEXT_STRIDE 0x1000U +#define PLIC_CONTEXT_THRESHOLD 0x0U +#define PLIC_CONTEXT_CLAIM 0x4U + +#define PLIC_PRIORITY(n) (PLIC_PRIORITY_BASE + (n) * sizeof(uint32_t)) +#define PLIC_ENABLE(sc, n, h) \ + (sc->contexts[h].enable_offset + ((n) / 32) * sizeof(uint32_t)) +#define PLIC_THRESHOLD(sc, h) \ + (sc->contexts[h].context_offset + PLIC_CONTEXT_THRESHOLD) +#define PLIC_CLAIM(sc, h) \ + (sc->contexts[h].context_offset + PLIC_CONTEXT_CLAIM) + +static pic_disable_intr_t plic_disable_intr; +static pic_enable_intr_t plic_enable_intr; +static pic_map_intr_t plic_map_intr; +static pic_setup_intr_t plic_setup_intr; +static pic_post_ithread_t plic_post_ithread; +static pic_pre_ithread_t plic_pre_ithread; +static pic_bind_intr_t plic_bind_intr; + struct plic_irqsrc { struct intr_irqsrc isrc; u_int irq; }; +struct plic_context { + bus_size_t enable_offset; + bus_size_t context_offset; +}; + struct plic_softc { device_t dev; struct resource * intc_res; struct plic_irqsrc isrcs[PLIC_MAX_IRQS]; + struct plic_context contexts[MAXCPU]; int ndev; }; @@ -75,6 +105,47 @@ struct plic_softc { #define WR4(sc, reg, val) \ bus_write_4(sc->intc_res, (reg), (val)) +static u_int plic_irq_cpu; + +static int +riscv_hartid_to_cpu(int hartid) +{ + int i; + + CPU_FOREACH(i) { + if (pcpu_find(i)->pc_hart == hartid) + return (i); + } + + return (-1); +} + +static int +plic_get_hartid(device_t dev, phandle_t intc) +{ + int hart; + + /* Check the interrupt controller layout. */ + if (OF_searchencprop(intc, "#interrupt-cells", &hart, + sizeof(hart)) == -1) { + device_printf(dev, + "Could not find #interrupt-cells for phandle %u\n", intc); + return (-1); + } + + /* + * The parent of the interrupt-controller is the CPU we are + * interested in, so search for its hart ID. + */ + if (OF_searchencprop(OF_parent(intc), "reg", (pcell_t *)&hart, + sizeof(hart)) == -1) { + device_printf(dev, "Could not find hartid\n"); + return (-1); + } + + return (hart); +} + static inline void plic_irq_dispatch(struct plic_softc *sc, u_int irq, struct trapframe *tf) @@ -98,11 +169,11 @@ plic_intr(void *arg) sc = arg; cpu = PCPU_GET(cpuid); - pending = RD4(sc, PLIC_CLAIM(cpu)); + pending = RD4(sc, PLIC_CLAIM(sc, cpu)); if (pending) { tf = curthread->td_intr_frame; plic_irq_dispatch(sc, pending, tf); - WR4(sc, PLIC_CLAIM(cpu), pending); + WR4(sc, PLIC_CLAIM(sc, cpu), pending); } return (FILTER_HANDLED); @@ -113,17 +184,11 @@ plic_disable_intr(device_t dev, struct intr_irqsrc *is { struct plic_softc *sc; struct plic_irqsrc *src; - uint32_t reg; - uint32_t cpu; sc = device_get_softc(dev); src = (struct plic_irqsrc *)isrc; - cpu = PCPU_GET(cpuid); - - reg = RD4(sc, PLIC_ENABLE(src->irq, cpu)); - reg &= ~(1 << (src->irq % 32)); - WR4(sc, PLIC_ENABLE(src->irq, cpu), reg); + WR4(sc, PLIC_PRIORITY(src->irq), 0); } static void @@ -131,19 +196,11 @@ plic_enable_intr(device_t dev, struct intr_irqsrc *isr { struct plic_softc *sc; struct plic_irqsrc *src; - uint32_t reg; - uint32_t cpu; sc = device_get_softc(dev); src = (struct plic_irqsrc *)isrc; WR4(sc, PLIC_PRIORITY(src->irq), 1); - - cpu = PCPU_GET(cpuid); - - reg = RD4(sc, PLIC_ENABLE(src->irq, cpu)); - reg |= (1 << (src->irq % 32)); - WR4(sc, PLIC_ENABLE(src->irq, cpu), reg); } static int @@ -174,7 +231,8 @@ plic_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "riscv,plic0")) + if (!ofw_bus_is_compatible(dev, "riscv,plic0") && + !ofw_bus_is_compatible(dev, "sifive,plic-1.0.0")) return (ENXIO); device_set_desc(dev, "RISC-V PLIC"); @@ -188,6 +246,7 @@ plic_attach(device_t dev) struct plic_irqsrc *isrcs; struct plic_softc *sc; struct intr_pic *pic; + pcell_t *cells; uint32_t irq; const char *name; phandle_t node; @@ -195,6 +254,10 @@ plic_attach(device_t dev) uint32_t cpu; int error; int rid; + int nintr; + int context; + int i; + int hart; sc = device_get_softc(dev); @@ -224,9 +287,9 @@ plic_attach(device_t dev) return (ENXIO); } + /* Register the interrupt sources */ isrcs = sc->isrcs; name = device_get_nameunit(sc->dev); - cpu = PCPU_GET(cpuid); for (irq = 1; irq <= sc->ndev; irq++) { isrcs[irq].irq = irq; error = intr_isrc_register(&isrcs[irq].isrc, sc->dev, @@ -235,10 +298,72 @@ plic_attach(device_t dev) return (error); WR4(sc, PLIC_PRIORITY(irq), 0); - WR4(sc, PLIC_ENABLE(irq, cpu), 0); } - WR4(sc, PLIC_THRESHOLD(cpu), 0); + /* + * Calculate the per-cpu enable and context register offsets. + * + * This is tricky for a few reasons. The PLIC divides the interrupt + * enable, threshold, and claim bits by "context", where each context + * routes to a Core-Local Interrupt Controller (CLIC). + * + * The tricky part is that the PLIC spec imposes no restrictions on how + * these contexts are laid out. So for example, there is no guarantee + * that each CPU will have both a machine mode and supervisor context, + * or that different PLIC implementations will organize the context + * registers in the same way. On top of this, we must handle the fact + * that cpuid != hartid, as they may have been renumbered during boot. + * We perform the following steps: + * + * 1. Examine the PLIC's "interrupts-extended" property and skip any + * entries that are not for supervisor external interrupts. + * + * 2. Walk up the device tree to find the corresponding CPU, and grab + * it's hart ID. + * + * 3. Convert the hart to a cpuid, and calculate the register offsets + * based on the context number. + */ + nintr = OF_getencprop_alloc_multi(node, "interrupts-extended", + sizeof(uint32_t), (void **)&cells); + if (nintr <= 0) { + device_printf(dev, "Could not read interrupts-extended\n"); + return (ENXIO); + } + + /* interrupts-extended is a list of phandles and interrupt types. */ + for (i = 0, context = 0; i < nintr; i += 2, context++) { + /* Skip M-mode external interrupts */ + if (cells[i + 1] != IRQ_EXTERNAL_SUPERVISOR) + continue; + + /* Get the hart ID from the CLIC's phandle. */ + hart = plic_get_hartid(dev, OF_node_from_xref(cells[i])); + if (hart < 0) { + OF_prop_free(cells); + return (ENXIO); + } + + /* Get the corresponding cpuid. */ + cpu = riscv_hartid_to_cpu(hart); + if (cpu < 0) { + device_printf(dev, "Invalid hart!\n"); + OF_prop_free(cells); + return (ENXIO); + } + + /* Set the enable and context register offsets for the CPU. */ + sc->contexts[cpu].enable_offset = PLIC_ENABLE_BASE + + context * PLIC_ENABLE_STRIDE; + sc->contexts[cpu].context_offset = PLIC_CONTEXT_BASE + + context * PLIC_CONTEXT_STRIDE; + } + OF_prop_free(cells); + + /* Set the threshold for each CPU to accept all priorities. */ + CPU_FOREACH(cpu) + WR4(sc, PLIC_THRESHOLD(sc, cpu), 0); + xref = OF_xref_from_node(node); pic = intr_pic_register(sc->dev, xref); if (pic == NULL) @@ -252,25 +377,69 @@ plic_attach(device_t dev) static void plic_pre_ithread(device_t dev, struct intr_irqsrc *isrc) { + + plic_disable_intr(dev, isrc); +} + +static void +plic_post_ithread(device_t dev, struct intr_irqsrc *isrc) +{ + + plic_enable_intr(dev, isrc); +} + +static int +plic_setup_intr(device_t dev, struct intr_irqsrc *isrc, + struct resource *res, struct intr_map_data *data) +{ 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); + /* Bind to the boot CPU for now. */ + CPU_SET(PCPU_GET(cpuid), &isrc->isrc_cpu); + plic_bind_intr(dev, isrc); + + return (0); } -static void -plic_post_ithread(device_t dev, struct intr_irqsrc *isrc) +static int +plic_bind_intr(device_t dev, struct intr_irqsrc *isrc) { struct plic_softc *sc; struct plic_irqsrc *src; + uint32_t reg; + u_int cpu; sc = device_get_softc(dev); src = (struct plic_irqsrc *)isrc; - WR4(sc, PLIC_PRIORITY(src->irq), 1); + /* Disable the interrupt source on all CPUs. */ + CPU_FOREACH(cpu) { + reg = RD4(sc, PLIC_ENABLE(sc, src->irq, cpu)); + reg &= ~(1 << (src->irq % 32)); + WR4(sc, PLIC_ENABLE(sc, src->irq, cpu), reg); + } + + if (CPU_EMPTY(&isrc->isrc_cpu)) { + cpu = plic_irq_cpu = intr_irq_next_cpu(plic_irq_cpu, &all_cpus); + CPU_SETOF(cpu, &isrc->isrc_cpu); + } else { + /* + * We will only bind to a single CPU so select the first + * CPU found. + */ + cpu = CPU_FFS(&isrc->isrc_cpu) - 1; + } + + /* Enable the interrupt on the selected CPU only. */ + reg = RD4(sc, PLIC_ENABLE(sc, src->irq, cpu)); + reg |= (1 << (src->irq % 32)); + WR4(sc, PLIC_ENABLE(sc, src->irq, cpu), reg); + + return (0); } static device_method_t plic_methods[] = { @@ -282,6 +451,8 @@ static device_method_t plic_methods[] = { DEVMETHOD(pic_map_intr, plic_map_intr), DEVMETHOD(pic_pre_ithread, plic_pre_ithread), DEVMETHOD(pic_post_ithread, plic_post_ithread), + DEVMETHOD(pic_setup_intr, plic_setup_intr), + DEVMETHOD(pic_bind_intr, plic_bind_intr), DEVMETHOD_END }; From owner-svn-src-stable-12@freebsd.org Fri May 8 17:16:05 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B285F2DCDE4; Fri, 8 May 2020 17:16:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49JcRn34Tdz44bZ; Fri, 8 May 2020 17:16:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro-164.local (unknown [IPv6:2601:648:8203:2990:2188:73e5:7ca9:66ea]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 8A122FD3F; Fri, 8 May 2020 17:16:04 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: svn commit: r360817 - stable/12/sys/riscv/riscv From: John Baldwin To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org References: <202005081505.048F55WS075125@repo.freebsd.org> Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGfnQH+rNAaH0livoSBQ0IPI/8WfIW7ub4qV6HYwWKVqkDkqwcpmGNDbz3gfaDht6nsie5Z pcuCcul4M9CW7Md6zzyvktjnbz61BADGDCopfZC4of0Z3Ka0u8Wik6UJOuqShBt1WcFS8ya1 oB4rc4tXfSHyMF63aPUBMxHR5DXeH+EO2edoSwViDMqWk1jTnYza51rbGY+pebLQOVOxAY7k do5Ordl3wklBPMVEPWoZ61SdbcjhHVwaC5zfiskcxj5wwXd2E9qYlBqRg7QeSm9obiBCYWxk d2luIDxqaGJARnJlZUJTRC5vcmc+iGAEExECACAFAkTQ+awCGwMGCwkIBwMCBBUCCAMEFgID AQIeAQIXgAAKCRBy3lIGd+N/BI6RAJ9S97fvbME+3hxzE3JUyUZ6vTewDACdE1stFuSfqMvM jomvZdYxIYyTUpC5Ag0ERND5ghAIAPwsO0B7BL+bz8sLlLoQktGxXwXQfS5cInvL17Dsgnr3 1AKa94j9EnXQyPEj7u0d+LmEe6CGEGDh1OcGFTMVrof2ZzkSy4+FkZwMKJpTiqeaShMh+Goj XlwIMDxyADYvBIg3eN5YdFKaPQpfgSqhT+7El7w+wSZZD8pPQuLAnie5iz9C8iKy4/cMSOrH YUK/tO+Nhw8Jjlw94Ik0T80iEhI2t+XBVjwdfjbq3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: <4d36bcc6-ca8a-d653-7990-337c0839fd46@FreeBSD.org> Date: Fri, 8 May 2020 10:16:02 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <202005081505.048F55WS075125@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 08 May 2020 17:16:05 -0000 On 5/8/20 8:05 AM, John Baldwin wrote: > Author: jhb > Date: Fri May 8 15:05:05 2020 > New Revision: 360817 > URL: https://svnweb.freebsd.org/changeset/base/360817 > > Log: > MFC 354603,354604,354717,354718: Sync PLIC code with head. This fixes booting under QEMU with OpenSBI. -- John Baldwin From owner-svn-src-stable-12@freebsd.org Sat May 9 05:04:04 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 08FF12DCB4D; Sat, 9 May 2020 05:04:04 +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 49Jw8g6S0Sz4GY3; Sat, 9 May 2020 05:04:03 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D3C83EA79; Sat, 9 May 2020 05:04:03 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 049543s4042653; Sat, 9 May 2020 05:04:03 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 049543pM042651; Sat, 9 May 2020 05:04:03 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <202005090504.049543pM042651@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Sat, 9 May 2020 05:04:03 +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: r360835 - in stable/12/usr.bin: factor primes X-SVN-Group: stable-12 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: in stable/12/usr.bin: factor primes X-SVN-Commit-Revision: 360835 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 09 May 2020 05:04:04 -0000 Author: mckusick Date: Sat May 9 05:04:02 2020 New Revision: 360835 URL: https://svnweb.freebsd.org/changeset/base/360835 Log: MFC of 356666 Fix the way 'factor' behaves when using OpenSSL to match the description of how it works when not compiled with OpenSSL. Modified: stable/12/usr.bin/factor/factor.6 stable/12/usr.bin/factor/factor.c stable/12/usr.bin/primes/primes.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/factor/factor.6 ============================================================================== --- stable/12/usr.bin/factor/factor.6 Sat May 9 04:00:58 2020 (r360834) +++ stable/12/usr.bin/factor/factor.6 Sat May 9 05:04:02 2020 (r360835) @@ -36,7 +36,7 @@ .\" .\" chongo /\oo/\ .\" -.Dd October 10, 2002 +.Dd January 12, 2020 .Dt FACTOR 6 .Os .Sh NAME @@ -67,11 +67,22 @@ When .Nm is invoked with no arguments, .Nm -reads numbers, one per line, from standard input, until end of file or error. +reads numbers, one per line, from standard input until end of file or 0 +is entered or an error occurs. Leading white-space and empty lines are ignored. +.Pp Numbers may be preceded by a single .Ql + . +Numbers can be either decimal or hexadecimal strings where the longest +leading substring is used. Numbers are terminated by a non-digit character (such as a newline). +If the string contains only decimal digits, it is treated as a +decimal representation for a number. +A hexadecimal string can contain an optional +.Em 0x +or +.Em 0X +prefix. After a number is read, it is factored. .Pp The @@ -89,7 +100,7 @@ The value must not be greater than the maximum. The default and maximum value of .Ar stop -is 3825123056546413050. +is 18446744073709551615. .Pp When the .Nm primes Modified: stable/12/usr.bin/factor/factor.c ============================================================================== --- stable/12/usr.bin/factor/factor.c Sat May 9 04:00:58 2020 (r360834) +++ stable/12/usr.bin/factor/factor.c Sat May 9 05:04:02 2020 (r360835) @@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -97,15 +98,16 @@ typedef u_long BN_ULONG; #define BN_is_one(v) (*(v) == 1) #define BN_mod_word(a, b) (*(a) % (b)) -static int BN_dec2bn(BIGNUM **a, const char *str); -static int BN_hex2bn(BIGNUM **a, const char *str); +static int BN_dec2bn(BIGNUM **, const char *); +static int BN_hex2bn(BIGNUM **, const char *); static BN_ULONG BN_div_word(BIGNUM *, BN_ULONG); static void BN_print_fp(FILE *, const BIGNUM *); #endif static void BN_print_dec_fp(FILE *, const BIGNUM *); - +static void convert_str2bn(BIGNUM **, char *); +static bool is_hex_str(char *); static void pr_fact(BIGNUM *); /* print factors of a value */ static void pr_print(BIGNUM *); /* print a prime */ static void usage(void); @@ -148,21 +150,13 @@ main(int argc, char *argv[]) for (p = buf; isblank(*p); ++p); if (*p == '\n' || *p == '\0') continue; - if (*p == '-') - errx(1, "negative numbers aren't permitted."); - if (BN_dec2bn(&val, buf) == 0 && - BN_hex2bn(&val, buf) == 0) - errx(1, "%s: illegal numeric format.", buf); + convert_str2bn(&val, p); pr_fact(val); } /* Factor the arguments. */ else - for (; *argv != NULL; ++argv) { - if (argv[0][0] == '-') - errx(1, "negative numbers aren't permitted."); - if (BN_dec2bn(&val, argv[0]) == 0 && - BN_hex2bn(&val, argv[0]) == 0) - errx(1, "%s: illegal numeric format.", argv[0]); + for (p = *argv; p != NULL; p = *++argv) { + convert_str2bn(&val, p); pr_fact(val); } exit(0); @@ -346,7 +340,7 @@ BN_dec2bn(BIGNUM **a, const char *str) errno = 0; **a = strtoul(str, &p, 10); - return (errno == 0 && (*p == '\n' || *p == '\0')); + return (errno == 0 ? 1 : 0); /* OpenSSL returns 0 on error! */ } static int @@ -356,7 +350,7 @@ BN_hex2bn(BIGNUM **a, const char *str) errno = 0; **a = strtoul(str, &p, 16); - return (errno == 0 && (*p == '\n' || *p == '\0')); + return (errno == 0 ? 1 : 0); /* OpenSSL returns 0 on error! */ } static BN_ULONG @@ -370,3 +364,46 @@ BN_div_word(BIGNUM *a, BN_ULONG b) } #endif + +/* + * Scan the string from left-to-right to see if the longest substring + * is a valid hexadecimal number. + */ +static bool +is_hex_str(char *str) +{ + char c, *p; + bool saw_hex = false; + + for (p = str; *p; p++) { + if (isdigit(*p)) + continue; + c = tolower(*p); + if (c >= 'a' && c <= 'f') { + saw_hex = true; + continue; + } + break; /* Not a hexadecimal digit. */ + } + return saw_hex; +} + +/* Convert string pointed to by *str to a bignum. */ +static void +convert_str2bn(BIGNUM **val, char *p) +{ + int n = 0; + + if (*p == '+') p++; + if (*p == '-') + errx(1, "negative numbers aren't permitted."); + if (*p == '0') { + p++; + if (*p == 'x' || *p == 'X') + n = BN_hex2bn(val, ++p); + } else { + n = is_hex_str(p) ? BN_hex2bn(val, p) : BN_dec2bn(val, p); + } + if (n == 0) + errx(1, "%s: illegal numeric format.", p); +} Modified: stable/12/usr.bin/primes/primes.c ============================================================================== --- stable/12/usr.bin/primes/primes.c Sat May 9 04:00:58 2020 (r360834) +++ stable/12/usr.bin/primes/primes.c Sat May 9 05:04:02 2020 (r360835) @@ -55,8 +55,8 @@ static const char rcsid[] = * primes [-h] [start [stop]] * * Print primes >= start and < stop. If stop is omitted, - * the value 4294967295 (2^32-1) is assumed. If start is - * omitted, start is read from standard input. + * the value 18446744073709551615 (2^64-1) is assumed. If + * start is omitted, start is read from standard input. * * validation check: there are 664579 primes between 0 and 10^7 */ From owner-svn-src-stable-12@freebsd.org Sat May 9 11:18:35 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5DDCD2E5868; Sat, 9 May 2020 11:18:35 +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 49K4Sq1nGpz4dBm; Sat, 9 May 2020 11:18:35 +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 3869E1B0F9; Sat, 9 May 2020 11:18:35 +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 049BIZSf074391; Sat, 9 May 2020 11:18:35 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 049BIZ5R074390; Sat, 9 May 2020 11:18:35 GMT (envelope-from dim@FreeBSD.org) Message-Id: <202005091118.049BIZ5R074390@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sat, 9 May 2020 11:18: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: r360843 - in stable: 11/sys/dev/mfi 12/sys/dev/mfi X-SVN-Group: stable-12 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 11/sys/dev/mfi 12/sys/dev/mfi X-SVN-Commit-Revision: 360843 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 09 May 2020 11:18:35 -0000 Author: dim Date: Sat May 9 11:18:34 2020 New Revision: 360843 URL: https://svnweb.freebsd.org/changeset/base/360843 Log: MFC r358689 (by jhibbits): Fix a mistaken conditional in mfi_tbolt_send_frame() As written, the condition of (cdb[0] != 0x28 || cdb[0] != 0x2A) will always be true, since if it's one, it's obviously not the other. Reading the code, the intent appears to be that it should only perform the operation if it's neither, otherwise the conditional can be elided. Found by clang 10. Modified: stable/12/sys/dev/mfi/mfi_tbolt.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/dev/mfi/mfi_tbolt.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/dev/mfi/mfi_tbolt.c ============================================================================== --- stable/12/sys/dev/mfi/mfi_tbolt.c Sat May 9 11:10:44 2020 (r360842) +++ stable/12/sys/dev/mfi/mfi_tbolt.c Sat May 9 11:18:34 2020 (r360843) @@ -1109,7 +1109,7 @@ mfi_tbolt_send_frame(struct mfi_softc *sc, struct mfi_ if (hdr->cmd == MFI_CMD_PD_SCSI_IO) { /* check for inquiry commands coming from CLI */ - if (cdb[0] != 0x28 || cdb[0] != 0x2A) { + if (cdb[0] != 0x28 && cdb[0] != 0x2A) { if ((req_desc = mfi_tbolt_build_mpt_cmd(sc, cm)) == NULL) { device_printf(sc->mfi_dev, "Mapping from MFI " From owner-svn-src-stable-12@freebsd.org Sat May 9 17:15:00 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3DFCF2F148A; Sat, 9 May 2020 17:15:00 +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 49KDN40ycSz479X; Sat, 9 May 2020 17:15:00 +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 17D951F54D; Sat, 9 May 2020 17:15:00 +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 049HExrq000814; Sat, 9 May 2020 17:14:59 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 049HExs1000811; Sat, 9 May 2020 17:14:59 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005091714.049HExs1000811@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Sat, 9 May 2020 17:14: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: r360850 - in stable/12: . share/man/man7 share/mk X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/12: . share/man/man7 share/mk X-SVN-Commit-Revision: 360850 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 09 May 2020 17:15:00 -0000 Author: jhb Date: Sat May 9 17:14:59 2020 New Revision: 360850 URL: https://svnweb.freebsd.org/changeset/base/360850 Log: MFC 356499: Use clang and lld as the default toolchain for RISCV. - Enable clang and lld as system toolchains. - Don't use external GCC for universe by default. - Re-enable riscv64sf since it builds fine with clang + lld. Sponsored by: DARPA Modified: stable/12/Makefile stable/12/share/man/man7/arch.7 stable/12/share/mk/src.opts.mk Directory Properties: stable/12/ (props changed) Modified: stable/12/Makefile ============================================================================== --- stable/12/Makefile Sat May 9 15:56:02 2020 (r360849) +++ stable/12/Makefile Sat May 9 17:14:59 2020 (r360850) @@ -487,29 +487,9 @@ TARGET_ARCHES_arm?= arm armv6 armv7 TARGET_ARCHES_arm64?= aarch64 TARGET_ARCHES_mips?= mipsel mips mips64el mips64 mipsn32 mipselhf mipshf mips64elhf mips64hf TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpcspe -# riscv64sf excluded due to PR 232085 -TARGET_ARCHES_riscv?= riscv64 +TARGET_ARCHES_riscv?= riscv64 riscv64sf .for target in ${TARGETS} TARGET_ARCHES_${target}?= ${target} -.endfor - -MAKE_PARAMS_riscv?= CROSS_TOOLCHAIN=riscv64-gcc - -# XXX Remove architectures only supported by external toolchain from universe -# if required toolchain packages are missing. -TOOLCHAINS_riscv= riscv64 -.for target in riscv -.if ${_UNIVERSE_TARGETS:M${target}} -.for toolchain in ${TOOLCHAINS_${target}} -.if !exists(/usr/local/share/toolchains/${toolchain}-gcc.mk) -_UNIVERSE_TARGETS:= ${_UNIVERSE_TARGETS:N${target}} -universe: universe_${toolchain}_skip .PHONY -universe_epilogue: universe_${toolchain}_skip .PHONY -universe_${toolchain}_skip: universe_prologue .PHONY - @echo ">> ${target} skipped - install ${toolchain}-xtoolchain-gcc port or package to build" -.endif -.endfor -.endif .endfor .if defined(UNIVERSE_TARGET) Modified: stable/12/share/man/man7/arch.7 ============================================================================== --- stable/12/share/man/man7/arch.7 Sat May 9 15:56:02 2020 (r360849) +++ stable/12/share/man/man7/arch.7 Sat May 9 17:14:59 2020 (r360850) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 14, 2019 +.Dd January 8, 2020 .Dt ARCH 7 .Os .Sh NAME @@ -325,12 +325,10 @@ This table shows the default tool chain for each archi .It powerpc Ta GCC 4.2.1 Ta GNU ld 2.17.50 .It powerpcspe Ta GCC 4.2.1 Ta GNU ld 2.17.50 .It powerpc64 Ta GCC 4.2.1 Ta GNU ld 2.17.50 -.It riscv64 Ta GCC(1) Ta GNU ld(1) -.It riscv64sf Ta GCC(1) Ta GNU ld(1) +.It riscv64 Ta Clang Ta lld +.It riscv64sf Ta Clang Ta lld .It sparc64 Ta GCC 4.2.1 Ta GNU ld 2.17.50 .El -.Pp -(1) External toolchain provided by ports/packages. .Pp Note that GCC 4.2.1 is deprecated, and scheduled for removal on 2020-03-31. Any CPU architectures not migrated by then Modified: stable/12/share/mk/src.opts.mk ============================================================================== --- stable/12/share/mk/src.opts.mk Sat May 9 15:56:02 2020 (r360849) +++ stable/12/share/mk/src.opts.mk Sat May 9 17:14:59 2020 (r360850) @@ -296,7 +296,8 @@ __DEFAULT_NO_OPTIONS+=LLVM_TARGET_BPF # build Clang without using an external compiler. .if ${COMPILER_FEATURES:Mc++11} && (${__T} == "aarch64" || \ - ${__T} == "amd64" || ${__TT} == "arm" || ${__T} == "i386") + ${__T} == "amd64" || ${__TT} == "arm" || ${__T} == "i386" || \ + ${__TT} == "riscv") # Clang is enabled, and will be installed as the default /usr/bin/cc. __DEFAULT_YES_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_IS_CC LLD __DEFAULT_NO_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX GPL_DTC @@ -325,7 +326,7 @@ __DEFAULT_YES_OPTIONS+=LLVM_LIBUNWIND __DEFAULT_NO_OPTIONS+=LLVM_LIBUNWIND .endif .if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "armv7" || \ - ${__T} == "i386" + ${__T} == "i386" || ${__TT} == "riscv" __DEFAULT_YES_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD .else __DEFAULT_NO_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD From owner-svn-src-stable-12@freebsd.org Sat May 9 20:02:49 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 709BE2F44A3; Sat, 9 May 2020 20:02:49 +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 49KJ5j24hBz4GdM; Sat, 9 May 2020 20:02:49 +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 4229F2157C; Sat, 9 May 2020 20:02:49 +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 049K2nOL005288; Sat, 9 May 2020 20:02:49 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 049K2mGL005286; Sat, 9 May 2020 20:02:48 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005092002.049K2mGL005286@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Sat, 9 May 2020 20:02: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: r360853 - in stable/12/share: man/man7 mk X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/12/share: man/man7 mk X-SVN-Commit-Revision: 360853 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 09 May 2020 20:02:49 -0000 Author: jhb Date: Sat May 9 20:02:48 2020 New Revision: 360853 URL: https://svnweb.freebsd.org/changeset/base/360853 Log: MFC 354289,354441,355095: Use lld on armv6. 354289: armv6: Switch to LLD by default This could just be ${__TT} == "arm", except armv5 isn't slated for death until EOY. arm tinderbox builds. Let's see what else shakes out. 354441: arch.7: armv6 uses lld by default as of r354289 355095: remove armv6 LLVM workaround introduced in r341812 r341812 enabled only arm target support in LLVM on arm and armv6, because ld.bfd 2.17.50 lacked support for range extensions required for linking such large binaries/libraries. r341812 indicated that the workaround should be removed once the userland can be linked by lld. r354289 switched armv6 to use lld by default, so remove the workaround on armv6. The workaround remains in place for arm (v5), and will presumably be removed when arm is retired. Modified: stable/12/share/man/man7/arch.7 stable/12/share/mk/src.opts.mk Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man7/arch.7 ============================================================================== --- stable/12/share/man/man7/arch.7 Sat May 9 19:26:44 2020 (r360852) +++ stable/12/share/man/man7/arch.7 Sat May 9 20:02:48 2020 (r360853) @@ -310,7 +310,7 @@ This table shows the default tool chain for each archi .It aarch64 Ta Clang Ta lld .It amd64 Ta Clang Ta lld .It arm Ta Clang Ta GNU ld 2.17.50 -.It armv6 Ta Clang Ta GNU ld 2.17.50 +.It armv6 Ta Clang Ta lld .It armv7 Ta Clang Ta lld .It i386 Ta Clang Ta lld .It mips Ta GCC 4.2.1 Ta GNU ld 2.17.50 Modified: stable/12/share/mk/src.opts.mk ============================================================================== --- stable/12/share/mk/src.opts.mk Sat May 9 19:26:44 2020 (r360852) +++ stable/12/share/mk/src.opts.mk Sat May 9 20:02:48 2020 (r360853) @@ -277,7 +277,7 @@ __LLVM_TARGET_FILT= C/(amd64|i386)/x86/:S/sparc64/spar __DEFAULT_YES_OPTIONS+= LLVM_TARGET_${__llt:${__LLVM_TARGET_FILT}:tu} # Disable other targets for arm and armv6, to work around "relocation truncated # to fit" errors with BFD ld, since libllvm.a will get too large to link. -.elif ${__T} == "arm" || ${__T} == "armv6" +.elif ${__T} == "arm" __DEFAULT_NO_OPTIONS+=LLVM_TARGET_${__llt:tu} # aarch64 needs arm for -m32 support. .elif ${__TT} == "arm64" && ${__llt} == "arm" @@ -325,8 +325,8 @@ __DEFAULT_YES_OPTIONS+=LLVM_LIBUNWIND .else __DEFAULT_NO_OPTIONS+=LLVM_LIBUNWIND .endif -.if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "armv7" || \ - ${__T} == "i386" || ${__TT} == "riscv" +.if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "armv6" || \ + ${__T} == "armv7" || ${__T} == "i386" || ${__TT} == "riscv" __DEFAULT_YES_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD .else __DEFAULT_NO_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD From owner-svn-src-stable-12@freebsd.org Sat May 9 20:05:25 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F20E32F488A; Sat, 9 May 2020 20:05:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49KJ8j67T6z4H0S; Sat, 9 May 2020 20:05:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro-164.local (unknown [IPv6:2601:648:8203:2990:6cc8:51a1:64e1:939f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 603331E223; Sat, 9 May 2020 20:05:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: svn commit: r360850 - in stable/12: . share/man/man7 share/mk From: John Baldwin To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org References: <202005091714.049HExs1000811@repo.freebsd.org> Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGfnQH+rNAaH0livoSBQ0IPI/8WfIW7ub4qV6HYwWKVqkDkqwcpmGNDbz3gfaDht6nsie5Z pcuCcul4M9CW7Md6zzyvktjnbz61BADGDCopfZC4of0Z3Ka0u8Wik6UJOuqShBt1WcFS8ya1 oB4rc4tXfSHyMF63aPUBMxHR5DXeH+EO2edoSwViDMqWk1jTnYza51rbGY+pebLQOVOxAY7k do5Ordl3wklBPMVEPWoZ61SdbcjhHVwaC5zfiskcxj5wwXd2E9qYlBqRg7QeSm9obiBCYWxk d2luIDxqaGJARnJlZUJTRC5vcmc+iGAEExECACAFAkTQ+awCGwMGCwkIBwMCBBUCCAMEFgID AQIeAQIXgAAKCRBy3lIGd+N/BI6RAJ9S97fvbME+3hxzE3JUyUZ6vTewDACdE1stFuSfqMvM jomvZdYxIYyTUpC5Ag0ERND5ghAIAPwsO0B7BL+bz8sLlLoQktGxXwXQfS5cInvL17Dsgnr3 1AKa94j9EnXQyPEj7u0d+LmEe6CGEGDh1OcGFTMVrof2ZzkSy4+FkZwMKJpTiqeaShMh+Goj XlwIMDxyADYvBIg3eN5YdFKaPQpfgSqhT+7El7w+wSZZD8pPQuLAnie5iz9C8iKy4/cMSOrH YUK/tO+Nhw8Jjlw94Ik0T80iEhI2t+XBVjwdfjbq3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: <36b743cd-dbb9-f7a1-d2de-702cb31503fb@FreeBSD.org> Date: Sat, 9 May 2020 13:05:22 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <202005091714.049HExs1000811@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 09 May 2020 20:05:26 -0000 On 5/9/20 10:14 AM, John Baldwin wrote: > Author: jhb > Date: Sat May 9 17:14:59 2020 > New Revision: 360850 > URL: https://svnweb.freebsd.org/changeset/base/360850 > > Log: > MFC 356499: Use clang and lld as the default toolchain for RISCV. > > - Enable clang and lld as system toolchains. > - Don't use external GCC for universe by default. > - Re-enable riscv64sf since it builds fine with clang + lld. > > Sponsored by: DARPA RISC-V using LLVM I merged so it would be enabled in tinderbox and to stop relying on external toolchain in 12. This one was very easy since LLD 10 had already been merged. I don't plan to try to MFC changes for MIPS or powerpc. -- John Baldwin From owner-svn-src-stable-12@freebsd.org Sat May 9 20:10:01 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BD3AE2F4A47; Sat, 9 May 2020 20:10:01 +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 49KJG14VBLz4HDx; Sat, 9 May 2020 20:10:01 +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 9531921586; Sat, 9 May 2020 20:10:01 +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 049KA1jh005719; Sat, 9 May 2020 20:10:01 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 049KA1NE005718; Sat, 9 May 2020 20:10:01 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005092010.049KA1NE005718@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Sat, 9 May 2020 20:10: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: r360854 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 360854 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 09 May 2020 20:10:01 -0000 Author: jhb Date: Sat May 9 20:10:01 2020 New Revision: 360854 URL: https://svnweb.freebsd.org/changeset/base/360854 Log: MFC 357593: Remove stale workaround for the htif console. In practice this discarded all characters entered at the DDB prompt. Modified: stable/12/sys/riscv/riscv/riscv_console.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/riscv_console.c ============================================================================== --- stable/12/sys/riscv/riscv/riscv_console.c Sat May 9 20:02:48 2020 (r360853) +++ stable/12/sys/riscv/riscv/riscv_console.c Sat May 9 20:10:01 2020 (r360854) @@ -206,20 +206,6 @@ riscv_cngetc(struct consdev *cp) { int ch; -#if defined(KDB) - /* - * RISCVTODO: BBL polls for console data on timer interrupt, - * but interrupts are turned off in KDB. - * So we currently do not have console in KDB. - */ - if (kdb_active) { - ch = sbi_console_getchar(); - while (ch) { - ch = sbi_console_getchar(); - } - } -#endif - ch = sbi_console_getchar(); if (ch > 0 && ch < 0xff) { #if defined(KDB) From owner-svn-src-stable-12@freebsd.org Sat May 9 20:14:05 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D15FE2F4C36; Sat, 9 May 2020 20:14:05 +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 49KJLj5BX9z4Hcq; Sat, 9 May 2020 20:14:05 +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 AD31821770; Sat, 9 May 2020 20:14:05 +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 049KE56c011621; Sat, 9 May 2020 20:14:05 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 049KE5tQ011620; Sat, 9 May 2020 20:14:05 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005092014.049KE5tQ011620@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Sat, 9 May 2020 20:14: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: r360855 - stable/12/sys/riscv/include X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/12/sys/riscv/include X-SVN-Commit-Revision: 360855 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 09 May 2020 20:14:05 -0000 Author: jhb Date: Sat May 9 20:14:05 2020 New Revision: 360855 URL: https://svnweb.freebsd.org/changeset/base/360855 Log: MFC 357591: Read the breakpoint instruction to determine its length in BKPT_SKIP. This fixes continuing from debug.kdb.enter=1 after enabling the use of compressed instructions since the compiler can emit the two byte c.ebreak instead of the 4 byte ebreak. Modified: stable/12/sys/riscv/include/db_machdep.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/include/db_machdep.h ============================================================================== --- stable/12/sys/riscv/include/db_machdep.h Sat May 9 20:10:01 2020 (r360854) +++ stable/12/sys/riscv/include/db_machdep.h Sat May 9 20:14:05 2020 (r360855) @@ -53,8 +53,14 @@ typedef long db_expr_t; #define BKPT_SIZE (INSN_SIZE) #define BKPT_SET(inst) (BKPT_INST) -#define BKPT_SKIP do { \ - kdb_frame->tf_sepc += BKPT_SIZE; \ +#define BKPT_SKIP do { \ + uint32_t _instr; \ + \ + _instr = db_get_value(PC_REGS(), sizeof(uint32_t), FALSE); \ + if ((_instr & 0x3) == 0x3) \ + kdb_frame->tf_sepc += 4; /* ebreak */ \ + else \ + kdb_frame->tf_sepc += 2; /* c.ebreak */ \ } while (0) #define db_clear_single_step kdb_cpu_clear_singlestep From owner-svn-src-stable-12@freebsd.org Sat May 9 21:32:45 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A088A2F69E4; Sat, 9 May 2020 21:32:45 +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 49KL5T3ZHyz4MgH; Sat, 9 May 2020 21:32:45 +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 7568C22675; Sat, 9 May 2020 21:32:45 +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 049LWjjl060754; Sat, 9 May 2020 21:32:45 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 049LWidX060750; Sat, 9 May 2020 21:32:44 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005092132.049LWidX060750@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Sat, 9 May 2020 21:32:44 +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: r360856 - in stable/12/sys/riscv: include riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/12/sys/riscv: include riscv X-SVN-Commit-Revision: 360856 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 09 May 2020 21:32:45 -0000 Author: jhb Date: Sat May 9 21:32:44 2020 New Revision: 360856 URL: https://svnweb.freebsd.org/changeset/base/360856 Log: MFC 357305: Remove unused fields from struct pcb. cpu_switch/throw() and savectx() do not save or restore any values in these fields which mostly held non-callee-save registers. makectx() copied these fields from kdb_frame, but they weren't used except for PC_REGS using pcb_sepc. Change PC_REGS to use kdb_frame->tf_sepc directly instead. Modified: stable/12/sys/riscv/include/db_machdep.h stable/12/sys/riscv/include/pcb.h stable/12/sys/riscv/riscv/genassym.c stable/12/sys/riscv/riscv/machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/include/db_machdep.h ============================================================================== --- stable/12/sys/riscv/include/db_machdep.h Sat May 9 20:14:05 2020 (r360855) +++ stable/12/sys/riscv/include/db_machdep.h Sat May 9 21:32:44 2020 (r360856) @@ -47,7 +47,7 @@ typedef vm_offset_t db_addr_t; typedef long db_expr_t; -#define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_sepc) +#define PC_REGS() ((db_addr_t)kdb_frame->tf_sepc) #define BKPT_INST (0x00100073) #define BKPT_SIZE (INSN_SIZE) Modified: stable/12/sys/riscv/include/pcb.h ============================================================================== --- stable/12/sys/riscv/include/pcb.h Sat May 9 20:14:05 2020 (r360855) +++ stable/12/sys/riscv/include/pcb.h Sat May 9 21:32:44 2020 (r360856) @@ -46,15 +46,12 @@ struct pcb { uint64_t pcb_sp; /* Stack pointer */ uint64_t pcb_gp; /* Global pointer */ uint64_t pcb_tp; /* Thread pointer */ - uint64_t pcb_t[7]; /* Temporary registers */ uint64_t pcb_s[12]; /* Saved registers */ - uint64_t pcb_a[8]; /* Argument registers */ uint64_t pcb_x[32][2]; /* Floating point registers */ uint64_t pcb_fcsr; /* Floating point control reg */ uint64_t pcb_fpflags; /* Floating point flags */ #define PCB_FP_STARTED 0x1 #define PCB_FP_USERMASK 0x1 - uint64_t pcb_sepc; /* Supervisor exception pc */ vm_offset_t pcb_onfault; /* Copyinout fault handler */ }; Modified: stable/12/sys/riscv/riscv/genassym.c ============================================================================== --- stable/12/sys/riscv/riscv/genassym.c Sat May 9 20:14:05 2020 (r360855) +++ stable/12/sys/riscv/riscv/genassym.c Sat May 9 21:32:44 2020 (r360856) @@ -68,9 +68,7 @@ ASSYM(PCB_RA, offsetof(struct pcb, pcb_ra)); ASSYM(PCB_SP, offsetof(struct pcb, pcb_sp)); ASSYM(PCB_GP, offsetof(struct pcb, pcb_gp)); ASSYM(PCB_TP, offsetof(struct pcb, pcb_tp)); -ASSYM(PCB_T, offsetof(struct pcb, pcb_t)); ASSYM(PCB_S, offsetof(struct pcb, pcb_s)); -ASSYM(PCB_A, offsetof(struct pcb, pcb_a)); ASSYM(PCB_X, offsetof(struct pcb, pcb_x)); ASSYM(PCB_FCSR, offsetof(struct pcb, pcb_fcsr)); Modified: stable/12/sys/riscv/riscv/machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/machdep.c Sat May 9 20:14:05 2020 (r360855) +++ stable/12/sys/riscv/riscv/machdep.c Sat May 9 21:32:44 2020 (r360856) @@ -556,15 +556,12 @@ void makectx(struct trapframe *tf, struct pcb *pcb) { - memcpy(pcb->pcb_t, tf->tf_t, sizeof(tf->tf_t)); memcpy(pcb->pcb_s, tf->tf_s, sizeof(tf->tf_s)); - memcpy(pcb->pcb_a, tf->tf_a, sizeof(tf->tf_a)); pcb->pcb_ra = tf->tf_ra; pcb->pcb_sp = tf->tf_sp; pcb->pcb_gp = tf->tf_gp; pcb->pcb_tp = tf->tf_tp; - pcb->pcb_sepc = tf->tf_sepc; } void From owner-svn-src-stable-12@freebsd.org Sat May 9 21:34:51 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 39D712F6AF0; Sat, 9 May 2020 21:34:51 +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 49KL7v0Npkz4Mr3; Sat, 9 May 2020 21:34:51 +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 087A62267A; Sat, 9 May 2020 21:34:51 +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 049LYo1H060934; Sat, 9 May 2020 21:34:50 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 049LYoJW060933; Sat, 9 May 2020 21:34:50 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202005092134.049LYoJW060933@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Sat, 9 May 2020 21:34: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: r360857 - stable/12/sys/riscv/riscv X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/12/sys/riscv/riscv X-SVN-Commit-Revision: 360857 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.32 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, 09 May 2020 21:34:51 -0000 Author: jhb Date: Sat May 9 21:34:50 2020 New Revision: 360857 URL: https://svnweb.freebsd.org/changeset/base/360857 Log: MFC 357313: Trim duplicate CSR swaps from user exceptions. The stack pointer is swapped with the sscratch CSR just before the jump to cpu_exception_handler_user where the first instruction swaps it again. The two swaps together are a no-op, but the csr swap instructions can be expensive (e.g. on Bluespec RISC-V cores csr swap instructions force a full pipeline stall). Modified: stable/12/sys/riscv/riscv/exception.S Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/riscv/riscv/exception.S ============================================================================== --- stable/12/sys/riscv/riscv/exception.S Sat May 9 21:32:44 2020 (r360856) +++ stable/12/sys/riscv/riscv/exception.S Sat May 9 21:34:50 2020 (r360857) @@ -208,7 +208,6 @@ ENTRY(cpu_exception_handler) csrrw sp, sscratch, sp beqz sp, 1f /* User mode detected */ - csrrw sp, sscratch, sp j cpu_exception_handler_user 1: /* Supervisor mode detected */ @@ -225,7 +224,6 @@ ENTRY(cpu_exception_handler_supervisor) END(cpu_exception_handler_supervisor) ENTRY(cpu_exception_handler_user) - csrrw sp, sscratch, sp save_registers 0 mv a0, sp call _C_LABEL(do_trap_user)