From owner-svn-src-head@freebsd.org Sun Apr 1 00:22:52 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0EF98F6B3BA; Sun, 1 Apr 2018 00:22:52 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AF0AC7EBBB; Sun, 1 Apr 2018 00:22:51 +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 A71091F204; Sun, 1 Apr 2018 00:22:51 +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 w310Mphn024400; Sun, 1 Apr 2018 00:22:51 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w310Mp8t024399; Sun, 1 Apr 2018 00:22:51 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201804010022.w310Mp8t024399@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 1 Apr 2018 00:22:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331857 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 331857 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2018 00:22:52 -0000 Author: kevans Date: Sun Apr 1 00:22:51 2018 New Revision: 331857 URL: https://svnweb.freebsd.org/changeset/base/331857 Log: lualoader: Simplify some expressions - No need for a 'goto' when our entire loop body is then wrapped in a conditional. - No need to leave commented out prints laying around - If an expression is clearly going to be either nil or an expression that isn't likely to be a boolean, we might as well use `or` to specify a default value for the expression. e.g. `loader.getenv(...) or "no"` Modified: head/stand/lua/config.lua Modified: head/stand/lua/config.lua ============================================================================== --- head/stand/lua/config.lua Sat Mar 31 23:50:20 2018 (r331856) +++ head/stand/lua/config.lua Sun Apr 1 00:22:51 2018 (r331857) @@ -205,10 +205,7 @@ local function loadModule(mod, silent) local status = true local pstatus for k, v in pairs(mod) do - if v.load == nil then - goto continue - end - if v.load:lower() == "yes" then + if v.load ~= nil and v.load:lower() == "yes" then local str = "load " if v.flags ~= nil then str = str .. v.flags .. " " @@ -247,12 +244,7 @@ local function loadModule(mod, silent) status = status and pstatus end --- else --- if not silent then --- print("Skipping module '". . k .. "'") --- end end - ::continue:: end return status @@ -272,11 +264,8 @@ local function readFile(name, silent) -- We might have read in the whole file, this won't be needed any more. io.close(f) - if text == nil then - if not silent then - print(MSG_FAILREADCFG:format(name)) - end - return nil + if text == nil and not silent then + print(MSG_FAILREADCFG:format(name)) end return text end @@ -322,11 +311,7 @@ config.verbose = false -- The first item in every carousel is always the default item. function config.getCarouselIndex(id) - local val = carousel_choices[id] - if val == nil then - return 1 - end - return val + return carousel_choices[id] or 1 end function config.setCarouselIndex(id, idx) @@ -498,10 +483,7 @@ function config.load(file) -- Cache the provided module_path at load time for later use config.module_path = loader.getenv("module_path") - local verbose = loader.getenv("verbose_loading") - if verbose == nil then - verbose = "no" - end + local verbose = loader.getenv("verbose_loading") or "no" config.verbose = verbose:lower() == "yes" end From owner-svn-src-head@freebsd.org Sun Apr 1 00:25:48 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9AA40F6B750; Sun, 1 Apr 2018 00:25:48 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4908D7EDC6; Sun, 1 Apr 2018 00:25:48 +0000 (UTC) (envelope-from imp@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 40ECE1F209; Sun, 1 Apr 2018 00:25:48 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w310PmTS024618; Sun, 1 Apr 2018 00:25:48 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w310PmWn024616; Sun, 1 Apr 2018 00:25:48 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201804010025.w310PmWn024616@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sun, 1 Apr 2018 00:25:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331858 - head/sys/dev/firewire X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/dev/firewire X-SVN-Commit-Revision: 331858 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2018 00:25:48 -0000 Author: imp Date: Sun Apr 1 00:25:47 2018 New Revision: 331858 URL: https://svnweb.freebsd.org/changeset/base/331858 Log: The Uninorth ID was really for Uninorth 2. Submitted by: Sevan Janiyan Differential Revision: https://reviews.freebsd.org/D14919 Modified: head/sys/dev/firewire/fwohci_pci.c head/sys/dev/firewire/fwohcireg.h Modified: head/sys/dev/firewire/fwohci_pci.c ============================================================================== --- head/sys/dev/firewire/fwohci_pci.c Sun Apr 1 00:22:51 2018 (r331857) +++ head/sys/dev/firewire/fwohci_pci.c Sun Apr 1 00:25:47 2018 (r331858) @@ -171,8 +171,8 @@ fwohci_pci_probe(device_t dev) device_set_desc(dev, "Apple Pangea"); return BUS_PROBE_DEFAULT; } - if (id == (FW_VENDORID_APPLE | FW_DEVICE_UNINORTH)) { - device_set_desc(dev, "Apple UniNorth"); + if (id == (FW_VENDORID_APPLE | FW_DEVICE_UNINORTH2)) { + device_set_desc(dev, "Apple UniNorth 2"); return BUS_PROBE_DEFAULT; } if (id == (FW_VENDORID_LUCENT | FW_DEVICE_FW322)) { Modified: head/sys/dev/firewire/fwohcireg.h ============================================================================== --- head/sys/dev/firewire/fwohcireg.h Sun Apr 1 00:22:51 2018 (r331857) +++ head/sys/dev/firewire/fwohcireg.h Sun Apr 1 00:25:47 2018 (r331858) @@ -74,7 +74,7 @@ #define FW_DEVICE_R5C551 (0x0551 << 16) #define FW_DEVICE_R5C552 (0x0552 << 16) #define FW_DEVICE_PANGEA (0x0030 << 16) -#define FW_DEVICE_UNINORTH (0x0031 << 16) +#define FW_DEVICE_UNINORTH2 (0x0031 << 16) #define FW_DEVICE_AIC5800 (0x5800 << 16) #define FW_DEVICE_FW322 (0x5811 << 16) #define FW_DEVICE_7007 (0x7007 << 16) From owner-svn-src-head@freebsd.org Sun Apr 1 01:07:17 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31A62F6E620; Sun, 1 Apr 2018 01:07:17 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DB1CD80815; Sun, 1 Apr 2018 01:07:16 +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 BC5F21F8BE; Sun, 1 Apr 2018 01:07:16 +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 w3117GJP045775; Sun, 1 Apr 2018 01:07:16 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3117Gt6045768; Sun, 1 Apr 2018 01:07:16 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201804010107.w3117Gt6045768@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 1 Apr 2018 01:07:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331859 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 331859 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2018 01:07:17 -0000 Author: kevans Date: Sun Apr 1 01:07:15 2018 New Revision: 331859 URL: https://svnweb.freebsd.org/changeset/base/331859 Log: lualoader: Split logodefs out into logo-* files This commit splits all of the logodefs/graphics out into their own own files and provides a method for these files to register their logodefs with the drawer. Graphics are now loaded on demand if they don't exist in the current set of logodefs. The drawer module becomes a little easier to navigate through without all of the graphics mixed in. It's also easy to do one-off graphics like the 9.2 Die Hard tribute by dteske@ without adding even more to our memory requirements. Added: head/stand/lua/logo-beastie.lua (contents, props changed) head/stand/lua/logo-beastiebw.lua (contents, props changed) head/stand/lua/logo-fbsdbw.lua (contents, props changed) head/stand/lua/logo-orb.lua (contents, props changed) head/stand/lua/logo-orbbw.lua (contents, props changed) Modified: head/stand/lua/Makefile head/stand/lua/drawer.lua Modified: head/stand/lua/Makefile ============================================================================== --- head/stand/lua/Makefile Sun Apr 1 00:25:47 2018 (r331858) +++ head/stand/lua/Makefile Sun Apr 1 01:07:15 2018 (r331859) @@ -10,6 +10,11 @@ FILES= cli.lua \ drawer.lua \ hook.lua \ loader.lua \ + logo-beastie.lua \ + logo-beastiebw.lua \ + logo-fbsdbw.lua \ + logo-orb.lua \ + logo-orbbw.lua \ menu.lua \ password.lua \ screen.lua Modified: head/stand/lua/drawer.lua ============================================================================== --- head/stand/lua/drawer.lua Sun Apr 1 00:25:47 2018 (r331858) +++ head/stand/lua/drawer.lua Sun Apr 1 01:07:15 2018 (r331859) @@ -36,12 +36,7 @@ local screen = require("screen") local drawer = {} -local fbsd_logo -local beastie_color -local beastie -local fbsd_logo_v -local orb_color -local orb +local fbsd_brand local none local function menuEntryName(drawing_menu, entry) @@ -56,7 +51,20 @@ local function menuEntryName(drawing_menu, entry) return entry.name end -fbsd_logo = { +local function getLogodef(logo) + -- Look it up + local logodef = drawer.logodefs[logo] + + -- Try to pull it in + if logodef == nil then + try_include('logo-' .. logo) + logodef = drawer.logodefs[logo] + end + + return logodef +end + +fbsd_brand = { " ______ ____ _____ _____ ", " | ____| | _ \\ / ____| __ \\ ", " | |___ _ __ ___ ___ | |_) | (___ | | | |", @@ -65,103 +73,6 @@ fbsd_logo = { " | | | | | | || | | |", " |_| |_| \\___|\\___||____/|_____/|_____/ " } - -beastie_color = { -" \027[31m, ,", -" /( )`", -" \\ \\___ / |", -" /- \027[37m_\027[31m `-/ '", -" (\027[37m/\\/ \\\027[31m \\ /\\", -" \027[37m/ / |\027[31m ` \\", -" \027[34mO O \027[37m) \027[31m/ |", -" \027[37m`-^--'\027[31m`< '", -" (_.) _ ) /", -" `.___/` /", -" `-----' /", -" \027[33m<----.\027[31m __ / __ \\", -" \027[33m<----|====\027[31mO)))\027[33m==\027[31m) \\) /\027[33m====|", -" \027[33m<----'\027[31m `--' `.__,' \\", -" | |", -" \\ / /\\", -" \027[36m______\027[31m( (_ / \\______/", -" \027[36m,' ,-----' |", -" `--{__________)\027[37m" -} - -beastie = { -" , ,", -" /( )`", -" \\ \\___ / |", -" /- _ `-/ '", -" (/\\/ \\ \\ /\\", -" / / | ` \\", -" O O ) / |", -" `-^--'`< '", -" (_.) _ ) /", -" `.___/` /", -" `-----' /", -" <----. __ / __ \\", -" <----|====O)))==) \\) /====|", -" <----' `--' `.__,' \\", -" | |", -" \\ / /\\", -" ______( (_ / \\______/", -" ,' ,-----' |", -" `--{__________)" -} - -fbsd_logo_v = { -" ______", -" | ____| __ ___ ___ ", -" | |__ | '__/ _ \\/ _ \\", -" | __|| | | __/ __/", -" | | | | | | |", -" |_| |_| \\___|\\___|", -" ____ _____ _____", -" | _ \\ / ____| __ \\", -" | |_) | (___ | | | |", -" | _ < \\___ \\| | | |", -" | |_) |____) | |__| |", -" | | | |", -" |____/|_____/|_____/" -} - -orb_color = { -" \027[31m``` \027[31;1m`\027[31m", -" s` `.....---...\027[31;1m....--.``` -/\027[31m", -" +o .--` \027[31;1m/y:` +.\027[31m", -" yo`:. \027[31;1m:o `+-\027[31m", -" y/ \027[31;1m-/` -o/\027[31m", -" .- \027[31;1m::/sy+:.\027[31m", -" / \027[31;1m`-- /\027[31m", -" `: \027[31;1m:`\027[31m", -" `: \027[31;1m:`\027[31m", -" / \027[31;1m/\027[31m", -" .- \027[31;1m-.\027[31m", -" -- \027[31;1m-.\027[31m", -" `:` \027[31;1m`:`", -" \027[31;1m.-- `--.", -" .---.....----.\027[37m" -} - -orb = { -" ``` `", -" s` `.....---.......--.``` -/", -" +o .--` /y:` +.", -" yo`:. :o `+-", -" y/ -/` -o/", -" .- ::/sy+:.", -" / `-- /", -" `: :`", -" `: :`", -" / /", -" .- -.", -" -- -.", -" `:` `:`", -" .-- `--.", -" .---.....----." -} - none = {""} -- Module exports @@ -205,42 +116,30 @@ drawer.branddefs = { -- Indexed by valid values for loader_brand in loader.conf(5). Valid -- keys are: graphic (table depicting graphic) ["fbsd"] = { - graphic = fbsd_logo, + graphic = fbsd_brand, }, ["none"] = { graphic = none, }, } +function drawer.addBrand(name, def) + drawer.branddefs[name] = def +end + +function drawer.addLogo(name, def) + drawer.logodefs[name] = def +end + drawer.logodefs = { -- Indexed by valid values for loader_logo in loader.conf(5). Valid keys -- are: requires_color (boolean), graphic (table depicting graphic), and -- shift (table containing x and y). - ["beastie"] = { - requires_color = true, - graphic = beastie_color, - }, - ["beastiebw"] = { - graphic = beastie, - }, - ["fbsdbw"] = { - graphic = fbsd_logo_v, - shift = {x = 5, y = 4}, - }, - ["orb"] = { - requires_color = true, - graphic = orb_color, - shift = {x = 2, y = 4}, - }, - ["orbbw"] = { - graphic = orb, - shift = {x = 2, y = 4}, - }, ["tribute"] = { - graphic = fbsd_logo, + graphic = fbsd_brand, }, ["tributebw"] = { - graphic = fbsd_logo, + graphic = fbsd_brand, }, ["none"] = { graphic = none, @@ -413,10 +312,8 @@ function drawer.drawbrand() local y = tonumber(loader.getenv("loader_brand_y")) or drawer.brand_position.y - local graphic = drawer.branddefs[loader.getenv("loader_brand")] - if graphic == nil then - graphic = fbsd_logo - end + local graphic = drawer.branddefs[loader.getenv("loader_brand")] or + fbsd_brand x = x + drawer.shift.x y = y + drawer.shift.y @@ -432,16 +329,15 @@ function drawer.drawlogo() local logo = loader.getenv("loader_logo") local colored = color.isEnabled() - -- Lookup - local logodef = drawer.logodefs[logo] + local logodef = getLogodef(logo) if logodef == nil or logodef.graphic == nil or (not colored and logodef.requires_color) then -- Choose a sensible default if colored then - logodef = drawer.logodefs["orb"] + logodef = getLogodef("orb") else - logodef = drawer.logodefs["orbbw"] + logodef = getLogodef("orbbw") end end Added: head/stand/lua/logo-beastie.lua ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/stand/lua/logo-beastie.lua Sun Apr 1 01:07:15 2018 (r331859) @@ -0,0 +1,60 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD +-- +-- Copyright (c) 2018 Kyle Evans +-- 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$ +-- + +local drawer = require("drawer") + +local beastie_color = { +" \027[31m, ,", +" /( )`", +" \\ \\___ / |", +" /- \027[37m_\027[31m `-/ '", +" (\027[37m/\\/ \\\027[31m \\ /\\", +" \027[37m/ / |\027[31m ` \\", +" \027[34mO O \027[37m) \027[31m/ |", +" \027[37m`-^--'\027[31m`< '", +" (_.) _ ) /", +" `.___/` /", +" `-----' /", +" \027[33m<----.\027[31m __ / __ \\", +" \027[33m<----|====\027[31mO)))\027[33m==\027[31m) \\) /\027[33m====|", +" \027[33m<----'\027[31m `--' `.__,' \\", +" | |", +" \\ / /\\", +" \027[36m______\027[31m( (_ / \\______/", +" \027[36m,' ,-----' |", +" `--{__________)\027[37m" +} + +drawer.addLogo("beastie", { + requires_color = true, + graphic = beastie_color, +}) + +return true Added: head/stand/lua/logo-beastiebw.lua ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/stand/lua/logo-beastiebw.lua Sun Apr 1 01:07:15 2018 (r331859) @@ -0,0 +1,59 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD +-- +-- Copyright (c) 2018 Kyle Evans +-- 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$ +-- + +local drawer = require("drawer") + +local beastiebw = { +" , ,", +" /( )`", +" \\ \\___ / |", +" /- _ `-/ '", +" (/\\/ \\ \\ /\\", +" / / | ` \\", +" O O ) / |", +" `-^--'`< '", +" (_.) _ ) /", +" `.___/` /", +" `-----' /", +" <----. __ / __ \\", +" <----|====O)))==) \\) /====|", +" <----' `--' `.__,' \\", +" | |", +" \\ / /\\", +" ______( (_ / \\______/", +" ,' ,-----' |", +" `--{__________)" +} + +drawer.addLogo("beastiebw", { + graphic = beastiebw, +}) + +return true Added: head/stand/lua/logo-fbsdbw.lua ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/stand/lua/logo-fbsdbw.lua Sun Apr 1 01:07:15 2018 (r331859) @@ -0,0 +1,54 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD +-- +-- Copyright (c) 2018 Kyle Evans +-- 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$ +-- + +local drawer = require("drawer") + +local fbsd_logo = { +" ______", +" | ____| __ ___ ___ ", +" | |__ | '__/ _ \\/ _ \\", +" | __|| | | __/ __/", +" | | | | | | |", +" |_| |_| \\___|\\___|", +" ____ _____ _____", +" | _ \\ / ____| __ \\", +" | |_) | (___ | | | |", +" | _ < \\___ \\| | | |", +" | |_) |____) | |__| |", +" | | | |", +" |____/|_____/|_____/" +} + +drawer.addLogo("fbsdbw", { + graphic = fbsd_logo, + shift = {x = 5, y = 4}, +}) + +return true Added: head/stand/lua/logo-orb.lua ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/stand/lua/logo-orb.lua Sun Apr 1 01:07:15 2018 (r331859) @@ -0,0 +1,57 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD +-- +-- Copyright (c) 2018 Kyle Evans +-- 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$ +-- + +local drawer = require("drawer") + +local orb_color = { +" \027[31m``` \027[31;1m`\027[31m", +" s` `.....---...\027[31;1m....--.``` -/\027[31m", +" +o .--` \027[31;1m/y:` +.\027[31m", +" yo`:. \027[31;1m:o `+-\027[31m", +" y/ \027[31;1m-/` -o/\027[31m", +" .- \027[31;1m::/sy+:.\027[31m", +" / \027[31;1m`-- /\027[31m", +" `: \027[31;1m:`\027[31m", +" `: \027[31;1m:`\027[31m", +" / \027[31;1m/\027[31m", +" .- \027[31;1m-.\027[31m", +" -- \027[31;1m-.\027[31m", +" `:` \027[31;1m`:`", +" \027[31;1m.-- `--.", +" .---.....----.\027[37m" +} + +drawer.addLogo("orb", { + requires_color = true, + graphic = orb_color, + shift = {x = 2, y = 4}, +}) + +return true Added: head/stand/lua/logo-orbbw.lua ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/stand/lua/logo-orbbw.lua Sun Apr 1 01:07:15 2018 (r331859) @@ -0,0 +1,56 @@ +-- +-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD +-- +-- Copyright (c) 2018 Kyle Evans +-- 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$ +-- + +local drawer = require("drawer") + +local orbbw = { +" ``` `", +" s` `.....---.......--.``` -/", +" +o .--` /y:` +.", +" yo`:. :o `+-", +" y/ -/` -o/", +" .- ::/sy+:.", +" / `-- /", +" `: :`", +" `: :`", +" / /", +" .- -.", +" -- -.", +" `:` `:`", +" .-- `--.", +" .---.....----." +} + +drawer.addLogo("orbbw", { + graphic = orbbw, + shift = {x = 2, y = 4}, +}) + +return true From owner-svn-src-head@freebsd.org Sun Apr 1 01:21:00 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DD52CF6F782; Sun, 1 Apr 2018 01:21:00 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9003F81153; Sun, 1 Apr 2018 01:21:00 +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 8AF1B1FB24; Sun, 1 Apr 2018 01:21:00 +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 w311L0Q8052986; Sun, 1 Apr 2018 01:21:00 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w311L09Y052985; Sun, 1 Apr 2018 01:21:00 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201804010121.w311L09Y052985@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 1 Apr 2018 01:21:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331860 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 331860 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2018 01:21:01 -0000 Author: kevans Date: Sun Apr 1 01:21:00 2018 New Revision: 331860 URL: https://svnweb.freebsd.org/changeset/base/331860 Log: lualoader: Don't try to lookup a nil logo Modified: head/stand/lua/drawer.lua Modified: head/stand/lua/drawer.lua ============================================================================== --- head/stand/lua/drawer.lua Sun Apr 1 01:07:15 2018 (r331859) +++ head/stand/lua/drawer.lua Sun Apr 1 01:21:00 2018 (r331860) @@ -52,6 +52,9 @@ local function menuEntryName(drawing_menu, entry) end local function getLogodef(logo) + if logo == nil then + return nil + end -- Look it up local logodef = drawer.logodefs[logo] From owner-svn-src-head@freebsd.org Sun Apr 1 04:50:06 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 41662F7B77E; Sun, 1 Apr 2018 04:50:06 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E500D68FBC; Sun, 1 Apr 2018 04:50:05 +0000 (UTC) (envelope-from jeff@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 C0ED8220E4; Sun, 1 Apr 2018 04:50:05 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w314o5hP061951; Sun, 1 Apr 2018 04:50:05 GMT (envelope-from jeff@FreeBSD.org) Received: (from jeff@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w314o5s2061947; Sun, 1 Apr 2018 04:50:05 GMT (envelope-from jeff@FreeBSD.org) Message-Id: <201804010450.w314o5s2061947@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jeff set sender to jeff@FreeBSD.org using -f From: Jeff Roberson Date: Sun, 1 Apr 2018 04:50:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331863 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: jeff X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 331863 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2018 04:50:06 -0000 Author: jeff Date: Sun Apr 1 04:50:05 2018 New Revision: 331863 URL: https://svnweb.freebsd.org/changeset/base/331863 Log: Add a uma cache of free pages in the DEFAULT freepool. This gives us per-cpu alloc and free of pages. The cache is filled with as few trips to the phys allocator as possible by the use of a new vm_phys_alloc_npages() function which allocates as many as N pages. This code was originally by markj with the import function rewritten by me. Reviewed by: markj, kib Tested by: pho Sponsored by: Netflix, Dell/EMC Isilon Differential Revision: https://reviews.freebsd.org/D14905 Modified: head/sys/vm/vm_page.c head/sys/vm/vm_pagequeue.h head/sys/vm/vm_phys.c head/sys/vm/vm_phys.h Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Sun Apr 1 04:47:05 2018 (r331862) +++ head/sys/vm/vm_page.c Sun Apr 1 04:50:05 2018 (r331863) @@ -186,6 +186,9 @@ static int vm_page_reclaim_run(int req_class, int doma vm_page_t m_run, vm_paddr_t high); static int vm_domain_alloc_fail(struct vm_domain *vmd, vm_object_t object, int req); +static int vm_page_import(void *arg, void **store, int cnt, int domain, + int flags); +static void vm_page_release(void *arg, void **store, int cnt); SYSINIT(vm_page, SI_SUB_VM, SI_ORDER_SECOND, vm_page_init, NULL); @@ -199,6 +202,32 @@ vm_page_init(void *dummy) VM_ALLOC_NORMAL | VM_ALLOC_WIRED); } +/* + * The cache page zone is initialized later since we need to be able to allocate + * pages before UMA is fully initialized. + */ +static void +vm_page_init_cache_zones(void *dummy __unused) +{ + struct vm_domain *vmd; + int i; + + for (i = 0; i < vm_ndomains; i++) { + vmd = VM_DOMAIN(i); + /* + * Don't allow the page cache to take up more than .25% of + * memory. + */ + if (vmd->vmd_page_count / 400 < 256 * mp_ncpus) + continue; + vmd->vmd_pgcache = uma_zcache_create("vm pgcache", + sizeof(struct vm_page), NULL, NULL, NULL, NULL, + vm_page_import, vm_page_release, vmd, + UMA_ZONE_NOBUCKETCACHE | UMA_ZONE_MAXBUCKET | UMA_ZONE_VM); + } +} +SYSINIT(vm_page2, SI_SUB_VM_CONF, SI_ORDER_ANY, vm_page_init_cache_zones, NULL); + /* Make sure that u_long is at least 64 bits when PAGE_SIZE is 32K. */ #if PAGE_SIZE == 32768 #ifdef CTASSERT @@ -1753,6 +1782,11 @@ again: } #endif vmd = VM_DOMAIN(domain); + if (object != NULL && vmd->vmd_pgcache != NULL) { + m = uma_zalloc(vmd->vmd_pgcache, M_NOWAIT); + if (m != NULL) + goto found; + } if (vm_domain_allocate(vmd, req, 1)) { /* * If not, allocate it from the free page queues. @@ -1783,9 +1817,7 @@ again: */ KASSERT(m != NULL, ("missing page")); -#if VM_NRESERVLEVEL > 0 found: -#endif vm_page_alloc_check(m); /* @@ -2150,6 +2182,52 @@ again: return (m); } +static int +vm_page_import(void *arg, void **store, int cnt, int domain, int flags) +{ + struct vm_domain *vmd; + vm_page_t m; + int i, j, n; + + vmd = arg; + /* Only import if we can bring in a full bucket. */ + if (cnt == 1 || !vm_domain_allocate(vmd, VM_ALLOC_NORMAL, cnt)) + return (0); + domain = vmd->vmd_domain; + n = 64; /* Starting stride, arbitrary. */ + vm_domain_free_lock(vmd); + for (i = 0; i < cnt; i+=n) { + n = vm_phys_alloc_npages(domain, VM_FREELIST_DEFAULT, &m, + MIN(n, cnt-i)); + if (n == 0) + break; + for (j = 0; j < n; j++) + store[i+j] = m++; + } + vm_domain_free_unlock(vmd); + if (cnt != i) + vm_domain_freecnt_inc(vmd, cnt - i); + + return (i); +} + +static void +vm_page_release(void *arg, void **store, int cnt) +{ + struct vm_domain *vmd; + vm_page_t m; + int i; + + vmd = arg; + vm_domain_free_lock(vmd); + for (i = 0; i < cnt; i++) { + m = (vm_page_t)store[i]; + vm_phys_free_pages(m, 0); + } + vm_domain_free_unlock(vmd); + vm_domain_freecnt_inc(vmd, cnt); +} + #define VPSC_ANY 0 /* No restrictions. */ #define VPSC_NORESERV 1 /* Skip reservations; implies VPSC_NOSUPER. */ #define VPSC_NOSUPER 2 /* Skip superpages. */ @@ -3222,7 +3300,12 @@ vm_page_free_toq(vm_page_t m) if (!vm_page_free_prep(m, false)) return; + vmd = vm_pagequeue_domain(m); + if (m->pool == VM_FREEPOOL_DEFAULT && vmd->vmd_pgcache != NULL) { + uma_zfree(vmd->vmd_pgcache, m); + return; + } vm_domain_free_lock(vmd); vm_phys_free_pages(m, 0); vm_domain_free_unlock(vmd); @@ -3243,22 +3326,17 @@ void vm_page_free_pages_toq(struct spglist *free, bool update_wire_count) { vm_page_t m; - struct pglist pgl; int count; if (SLIST_EMPTY(free)) return; count = 0; - TAILQ_INIT(&pgl); while ((m = SLIST_FIRST(free)) != NULL) { count++; SLIST_REMOVE_HEAD(free, plinks.s.ss); - if (vm_page_free_prep(m, false)) - TAILQ_INSERT_TAIL(&pgl, m, listq); + vm_page_free_toq(m); } - - vm_page_free_phys_pglist(&pgl); if (update_wire_count) vm_wire_sub(count); Modified: head/sys/vm/vm_pagequeue.h ============================================================================== --- head/sys/vm/vm_pagequeue.h Sun Apr 1 04:47:05 2018 (r331862) +++ head/sys/vm/vm_pagequeue.h Sun Apr 1 04:50:05 2018 (r331863) @@ -74,6 +74,7 @@ struct vm_pagequeue { } __aligned(CACHE_LINE_SIZE); #include +#include struct sysctl_oid; /* @@ -92,6 +93,7 @@ struct vm_domain { struct vm_pagequeue vmd_pagequeues[PQ_COUNT]; struct mtx_padalign vmd_free_mtx; struct mtx_padalign vmd_pageout_mtx; + uma_zone_t vmd_pgcache; /* (c) page free cache. */ struct vmem *vmd_kernel_arena; /* (c) per-domain kva arena. */ u_int vmd_domain; /* (c) Domain number. */ u_int vmd_page_count; /* (c) Total page count. */ Modified: head/sys/vm/vm_phys.c ============================================================================== --- head/sys/vm/vm_phys.c Sun Apr 1 04:47:05 2018 (r331862) +++ head/sys/vm/vm_phys.c Sun Apr 1 04:50:05 2018 (r331863) @@ -624,6 +624,26 @@ vm_phys_alloc_pages(int domain, int pool, int order) return (NULL); } +int +vm_phys_alloc_npages(int domain, int pool, vm_page_t *mp, int cnt) +{ + vm_page_t m; + int order, freelist; + + for (freelist = 0; freelist < VM_NFREELIST; freelist++) { + for (order = fls(cnt) -1; order >= 0; order--) { + m = vm_phys_alloc_freelist_pages(domain, freelist, + pool, order); + if (m != NULL) { + *mp = m; + return (1 << order); + } + } + } + *mp = NULL; + return (0); +} + /* * Allocate a contiguous, power of two-sized set of physical pages from the * specified free list. The free list must be specified using one of the Modified: head/sys/vm/vm_phys.h ============================================================================== --- head/sys/vm/vm_phys.h Sun Apr 1 04:47:05 2018 (r331862) +++ head/sys/vm/vm_phys.h Sun Apr 1 04:50:05 2018 (r331863) @@ -78,6 +78,7 @@ vm_page_t vm_phys_alloc_contig(int domain, u_long npag vm_page_t vm_phys_alloc_freelist_pages(int domain, int freelist, int pool, int order); vm_page_t vm_phys_alloc_pages(int domain, int pool, int order); +int vm_phys_alloc_npages(int domain, int pool, vm_page_t *m, int cnt); int vm_phys_domain_match(int prefer, vm_paddr_t low, vm_paddr_t high); int vm_phys_fictitious_reg_range(vm_paddr_t start, vm_paddr_t end, vm_memattr_t memattr); From owner-svn-src-head@freebsd.org Sun Apr 1 04:47:06 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82AACF7B5FE; Sun, 1 Apr 2018 04:47:06 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 36E5D68E57; Sun, 1 Apr 2018 04:47:06 +0000 (UTC) (envelope-from jeff@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 31AFC220DD; Sun, 1 Apr 2018 04:47:06 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w314l5JX061724; Sun, 1 Apr 2018 04:47:05 GMT (envelope-from jeff@FreeBSD.org) Received: (from jeff@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w314l5oV061722; Sun, 1 Apr 2018 04:47:05 GMT (envelope-from jeff@FreeBSD.org) Message-Id: <201804010447.w314l5oV061722@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jeff set sender to jeff@FreeBSD.org using -f From: Jeff Roberson Date: Sun, 1 Apr 2018 04:47:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331862 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: jeff X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 331862 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2018 04:47:06 -0000 Author: jeff Date: Sun Apr 1 04:47:05 2018 New Revision: 331862 URL: https://svnweb.freebsd.org/changeset/base/331862 Log: Add the flag ZONE_NOBUCKETCACHE. This flag instructions UMA not to keep a cache of fully populated buckets. This will be used in a follow-on commit. The flag idea was originally from markj. Reviewed by: markj, kib Tested by: pho Sponsored by: Netflix, Dell/EMC Isilon Modified: head/sys/vm/uma.h head/sys/vm/uma_core.c Modified: head/sys/vm/uma.h ============================================================================== --- head/sys/vm/uma.h Sun Apr 1 04:11:38 2018 (r331861) +++ head/sys/vm/uma.h Sun Apr 1 04:47:05 2018 (r331862) @@ -286,6 +286,10 @@ uma_zone_t uma_zcache_create(char *name, int size, uma * NUMA aware Zone. Implements a best * effort first-touch policy. */ +#define UMA_ZONE_NOBUCKETCACHE 0x20000 /* + * Don't cache full buckets. Limit + * UMA to per-cpu state. + */ /* * These flags are shared between the keg and zone. In zones wishing to add Modified: head/sys/vm/uma_core.c ============================================================================== --- head/sys/vm/uma_core.c Sun Apr 1 04:11:38 2018 (r331861) +++ head/sys/vm/uma_core.c Sun Apr 1 04:47:05 2018 (r331862) @@ -2965,7 +2965,13 @@ zfree_start: /* ub_cnt is pointing to the last free item */ KASSERT(bucket->ub_cnt != 0, ("uma_zfree: Attempting to insert an empty bucket onto the full list.\n")); - LIST_INSERT_HEAD(&zdom->uzd_buckets, bucket, ub_link); + if ((zone->uz_flags & UMA_ZONE_NOBUCKETCACHE) != 0) { + ZONE_UNLOCK(zone); + bucket_drain(zone, bucket); + bucket_free(zone, bucket, udata); + goto zfree_restart; + } else + LIST_INSERT_HEAD(&zdom->uzd_buckets, bucket, ub_link); } /* From owner-svn-src-head@freebsd.org Sun Apr 1 15:21:33 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AB3A3F54534; Sun, 1 Apr 2018 15:21:33 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: from mailrelay109.isp.belgacom.be (mailrelay109.isp.belgacom.be [195.238.20.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "relay.skynet.be", Issuer "GlobalSign Organization Validation CA - SHA256 - G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E255670BEE; Sun, 1 Apr 2018 15:21:32 +0000 (UTC) (envelope-from tijl@freebsd.org) X-Belgacom-Dynamic: yes IronPort-PHdr: =?us-ascii?q?9a23=3A0wNu8xb3wnBflsk9nNoXYbT/LSx+4OfEezUN459i?= =?us-ascii?q?sYplN5qZrsWybnLW6fgltlLVR4KTs6sC17KN9fi4EUU7or+5+EgYd5JNUxJXwe?= =?us-ascii?q?43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRp?= =?us-ascii?q?OOv1BpTSj8Oq3Oyu5pHfeQpFiCazbL9oMBm6sRjau9ULj4dlNqs/0AbCrGFSe+?= =?us-ascii?q?RRy2NoJFaTkAj568yt4pNt8Dletuw4+cJYXqr0Y6o3TbpDDDQ7KG81/9HktQPC?= =?us-ascii?q?TQSU+HQRVHgdnwdSDAjE6BH6WYrxsjf/u+Fg1iSWIdH6QLYpUjm58axlVAHnhz?= =?us-ascii?q?sGNz4h8WHYlMpwjL5AoBm8oxBz2pPYbJ2JOPZ7eK7WYNEUSndbXstJWSJPAp2y?= =?us-ascii?q?YZYMAeUDM+ZXoJXyqVQVoBuiBwSgGP/jxiNUinPo26AxzuQvERvB3AwlB98Arn?= =?us-ascii?q?XUrNfxNKwPT+21y67IzS7dYPNTwzj97pPIeQ0mrPGQXLJwc87RxFIvGQPfkFqf?= =?us-ascii?q?t5HoMS6b2OgXtGib9eVgWPuphmU6pQ9xpT2vyd0tionPno8VxErE+jtnz4kuPt?= =?us-ascii?q?23VVR3Ydm+EJtfsSyRKoh4Qts6TmxrpSo20KMKtJGmcCQQ1pgr2wDTZ+aaf4WI?= =?us-ascii?q?7B/uUvuaLy1ii3J/Yr2/gg6/8U2nyuLhSMa5yE1Kri9ZktnUsXANygDT5tCHSv?= =?us-ascii?q?Rj+keh3i6C1wPJ5eFAIEA0kLTUK4QmwrIqipoTsEbDHivslErqi6+WcV4k9fat?= =?us-ascii?q?6+v9ZLXmvYWQN4huigHxKqgum8q/DvokMgUWXGWX5P6w2KPs8EHkWrlGkOE6nr?= =?us-ascii?q?fDvJzHJckWqLa1AwpP3YYi7xa/AS2m0NMdnXQfMFJFeRCHj4zyNlHAOvD3E+mw?= =?us-ascii?q?jE+3kDh23fzGOafhAprVInjZjLjhZap961JbyAcr1tBf+ZRUBqgaIPLpRkD9rd?= =?us-ascii?q?zYAQEjPAOp2OvnBs992Z0AVm2UGa+WLbnesViS5uIgO+OMfpMauC7hK/g54P7j?= =?us-ascii?q?lWQ5mUEbfaWwxpsXcmy3Eu18LEWdZXrhmdkBEX0UsQUgV+Pqk0CNXSRUZ3aoUK?= =?us-ascii?q?I2/is7B56+DYffWoCth6SM3DyhHpJKf2xJFleMEXLtd4WFR/cMdDydItV6kjEf?= =?us-ascii?q?W7ihUZEu2g+1uw/h1rVrNO3U+jcXtZj7zth6+/XTlQ0u9TxzF8md1nuCT3t3nm?= =?us-ascii?q?MKXDI20rp/rlJjxViYyqh3nuZUFdtJ5/NGAU8GMsv5xvZ5Q/L1WgTaYtCPAAKj?= =?us-ascii?q?S8+lAxkfVN886eQiJUFnFIPxoArE2n+WAr0R35eMA4c596vaxDClO8d/z17ozq?= =?us-ascii?q?QspWIKBMxVOjv11eZE6wHPCtuRwA2inKGwePFZhXaV+Q=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2AlCgBH+MBa/5nK8VFcFgYBAQEEAQEKA?= =?us-ascii?q?QGDQlMObxUTjDqMIgEBgXMxAV2SU4F6LoRhAoQkIjUXAQIBAQEBAQECAWoogjc?= =?us-ascii?q?kAYJIAQEBAwEnExwjBQsLFAQJJQ8qHgYThQUMC7AFM4g6giYFiXSDXDSKQwKXO?= =?us-ascii?q?giFUYhSZYtdiRWIDR4DM4FSTTAIgn2QTz0wjX4BAQ?= X-IPAS-Result: =?us-ascii?q?A2AlCgBH+MBa/5nK8VFcFgYBAQEEAQEKAQGDQlMObxUTjDq?= =?us-ascii?q?MIgEBgXMxAV2SU4F6LoRhAoQkIjUXAQIBAQEBAQECAWoogjckAYJIAQEBAwEnE?= =?us-ascii?q?xwjBQsLFAQJJQ8qHgYThQUMC7AFM4g6giYFiXSDXDSKQwKXOgiFUYhSZYtdiRW?= =?us-ascii?q?IDR4DM4FSTTAIgn2QTz0wjX4BAQ?= Received: from 153.202-241-81.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([81.241.202.153]) by relay.skynet.be with ESMTP; 01 Apr 2018 17:20:22 +0200 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.15.2/8.15.2) with ESMTP id w31FKMBb001214; Sun, 1 Apr 2018 17:20:22 +0200 (CEST) (envelope-from tijl@FreeBSD.org) Date: Sun, 1 Apr 2018 17:20:21 +0200 From: Tijl Coosemans To: Mark Johnston Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331732 - head/sys/vm Message-ID: <20180401172021.27852803@kalimero.tijl.coosemans.org> In-Reply-To: <20180331225432.GB1440@raichu> References: <201803291427.w2TEReA3024929@repo.freebsd.org> <20180331202118.5401ed2a@kalimero.tijl.coosemans.org> <20180331225432.GB1440@raichu> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2018 15:21:33 -0000 On Sat, 31 Mar 2018 18:54:32 -0400 Mark Johnston wrote: > On Sat, Mar 31, 2018 at 08:21:18PM +0200, Tijl Coosemans wrote: > > On Thu, 29 Mar 2018 14:27:40 +0000 (UTC) Mark Johnston wrote: > > > Author: markj > > > Date: Thu Mar 29 14:27:40 2018 > > > New Revision: 331732 > > > URL: https://svnweb.freebsd.org/changeset/base/331732 > > > > > > Log: > > > Fix the background laundering mechanism after r329882. > > > > > > Rather than using the number of inactive queue scans as a metric for > > > how many clean pages are being freed by the page daemon, have the > > > page daemon keep a running counter of the number of pages it has freed, > > > and have the laundry thread use that when computing the background > > > laundering threshold. > > > [...] > > > > I'm seeing big processes being killed with an "out of swap space" message > > even though there's still plenty of swap available. It seems to be fixed > > by making this division round upwards: > > > > if (target == 0 && ndirty * isqrt((nfreed + > > (vmd->vmd_free_target - vmd->vmd_free_min) - 1) / > > (vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) { > > > > I don't know where this formula comes from, so I don't know if this > > change is correct. > > Hm, that's somewhat surprising. This code shouldn't be executing in > situations where the OOM kill logic is invoked (i.e., memory pressure > plus a shortage of clean pages in the inactive queue). > > How much RAM does the system have? Could you collect "sysctl vm" output > around the time of an OOM kill? 1GiB RAM. I've sampled sysctl vm every 5s from the moment the process starts swapping until it is killed and uploaded that to https://people.freebsd.org/~tijl/sysctl/ > I'm wondering if the higher inactive queue scan frequency after r329882 > might be responsible: OOM kills are performed after vm.pageout_oom_seq > back-to-back scans fail to reclaim any pages. Does your problem persist > if you increase the value of that sysctl, say to 60? This didn't help. From owner-svn-src-head@freebsd.org Sun Apr 1 16:27:08 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D553FF6B161; Sun, 1 Apr 2018 16:27:07 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-it0-x22f.google.com (mail-it0-x22f.google.com [IPv6:2607:f8b0:4001:c0b::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6932273154; Sun, 1 Apr 2018 16:27:07 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-it0-x22f.google.com with SMTP id z7-v6so6056035iti.1; Sun, 01 Apr 2018 09:27:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Vf8ECtNNzS7niZZwchCI2WHgQiiVRqlPExyjlatX878=; b=SAFHR4PNGWQSwYEeDmD+HG6RyMv0aqTCglkPe7WQD2AQp+xWDe2IG1GF4cAhxjmFM8 DRJJzfqQmQv0/4IFVFizIh81VVKyUq9wwc3v5SBmhFZGkFuvyi7zvsJDzGRnugEY0HmF ioVWSu4JclDN+6DgDwOEA6Ps6nEtNoNAIGQj9WV/g/qmpnFUo8+YKHqjMKNetjmTEu7L jukMy4EbeQiQSchDCoij9FtGaf3NfbdSeqYsZ66GZ3rzO3MpAc2GXIkSljt+fnK74sEV sDCTBarzvNDn/cUwBR3BqhuHZQDkRknh05dWpX7sUEYmSDAutmD8w6FV+8759nk+++Uo rtsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=Vf8ECtNNzS7niZZwchCI2WHgQiiVRqlPExyjlatX878=; b=pbpEQXN7FV2XgWGxzUfD9oqFgN+fqEI6cGftSxooGQacU0a8x9jrZ5+zomnkCFkpPw +8nIvkZbDk0LI4p5F4oVZD3V9+PEdul5ZmLA2g0lfcOsWBj3jOH1mj9wnMQK9YCgBJ13 OVru4MHpKHL+a9fIq9DZC1t+GWCDpdIWWmbgPT4yJUDb5tuY0icJ1oNkWpsp6vo3P5qt hnsRykpk4smZA8btb9ertFv/b6VRQ/Vn/431wADg8SbbzhnbTC8lf1yqP9nKg4PHpCrV 1ETx+8Fl0YHk+KJmRrGghiW2svhU6yXvjfAAdddzjjAG4blt6cRGbSVAYrqR4WzYwu+W UrNQ== X-Gm-Message-State: AElRT7HOQNUsdN+o4j3yKzaZ3kcoDd73454MibyDToDpripu7ZzAv2ue 7fg3lUs/SaaRSm2gFf9Su3B5tQ== X-Google-Smtp-Source: AIpwx4+RWKXISgA6Cn6b6jjsG4ahtUWWjrRGxQvUb7e1KblfXrh5y4FDGpaoJmm9MBywQKSmtKCx8g== X-Received: by 2002:a24:7f46:: with SMTP id r67-v6mr9489409itc.127.1522600026347; Sun, 01 Apr 2018 09:27:06 -0700 (PDT) Received: from raichu (toroon0560w-lp130-01-174-88-76-83.dsl.bell.ca. [174.88.76.83]) by smtp.gmail.com with ESMTPSA id l7sm7053993ioe.50.2018.04.01.09.27.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Apr 2018 09:27:05 -0700 (PDT) Sender: Mark Johnston Date: Sun, 1 Apr 2018 12:27:03 -0400 From: Mark Johnston To: Tijl Coosemans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331732 - head/sys/vm Message-ID: <20180401162703.GD1440@raichu> References: <201803291427.w2TEReA3024929@repo.freebsd.org> <20180331202118.5401ed2a@kalimero.tijl.coosemans.org> <20180331225432.GB1440@raichu> <20180401172021.27852803@kalimero.tijl.coosemans.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180401172021.27852803@kalimero.tijl.coosemans.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2018 16:27:08 -0000 On Sun, Apr 01, 2018 at 05:20:21PM +0200, Tijl Coosemans wrote: > On Sat, 31 Mar 2018 18:54:32 -0400 Mark Johnston wrote: > > On Sat, Mar 31, 2018 at 08:21:18PM +0200, Tijl Coosemans wrote: > > > On Thu, 29 Mar 2018 14:27:40 +0000 (UTC) Mark Johnston wrote: > > > > Author: markj > > > > Date: Thu Mar 29 14:27:40 2018 > > > > New Revision: 331732 > > > > URL: https://svnweb.freebsd.org/changeset/base/331732 > > > > > > > > Log: > > > > Fix the background laundering mechanism after r329882. > > > > > > > > Rather than using the number of inactive queue scans as a metric for > > > > how many clean pages are being freed by the page daemon, have the > > > > page daemon keep a running counter of the number of pages it has freed, > > > > and have the laundry thread use that when computing the background > > > > laundering threshold. > > > > [...] > > > > > > I'm seeing big processes being killed with an "out of swap space" message > > > even though there's still plenty of swap available. It seems to be fixed > > > by making this division round upwards: > > > > > > if (target == 0 && ndirty * isqrt((nfreed + > > > (vmd->vmd_free_target - vmd->vmd_free_min) - 1) / > > > (vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) { > > > > > > I don't know where this formula comes from, so I don't know if this > > > change is correct. > > > > Hm, that's somewhat surprising. This code shouldn't be executing in > > situations where the OOM kill logic is invoked (i.e., memory pressure > > plus a shortage of clean pages in the inactive queue). > > > > How much RAM does the system have? Could you collect "sysctl vm" output > > around the time of an OOM kill? > > 1GiB RAM. I've sampled sysctl vm every 5s from the moment the process > starts swapping until it is killed and uploaded that to > https://people.freebsd.org/~tijl/sysctl/ Thank you. Now I agree with your change. Would you like to commit it? I can take care of it if you prefer. There is still a deeper problem here after r329882 in that the shortfall laundering mechanism is not kicking in before the OOM killer. The problem is that the PID controller may produce a positive output even when the error is negative; this is seen in 22.txt, the last capture before the OOM kill. Because the error is negative (i.e., v_free_count > v_free_target), we will not attempt to launder pages in shortfall mode. The positive output means that the page daemon is repeatedly scanning the (completely depleted) inactive queue, but since the laundering mechanism is failing to produce clean pages, there is nothing to reclaim and so we eventually invoke the OOM killer. I'm not yet sure how best to address this, but your change is probably sufficient to mitigate the problem in general and also corrects an unintentional behaviour change in my commit. From owner-svn-src-head@freebsd.org Sun Apr 1 16:47:42 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E3C93F6CCCB; Sun, 1 Apr 2018 16:47:41 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-io0-x22d.google.com (mail-io0-x22d.google.com [IPv6:2607:f8b0:4001:c06::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 83BEF74243; Sun, 1 Apr 2018 16:47:41 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-io0-x22d.google.com with SMTP id e79so15705396ioi.7; Sun, 01 Apr 2018 09:47:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=nquRhfarP/58yEdGynEUzJtdfXrRdKyGr07a9XzhQ64=; b=E/lrCtKSd4p32BQtTYFhid31a6aCaubAJnyhc0dyZrUmKL08SYifkvl2xwzd9Ya9jU d8N9kVF3Yc6anwQ1eFJS+7YOGxkKuecyEqFqViy5/7158LnvOhscYr9VO+5JprmjZcZk 4xU9IKxJ7UWH8iQFisHrgAW7tGFt84FaQvq1yOx2HdFL6I2TU3EmFBrcWZK5u5HHD2JE LptwJkp9B6iEbxMV9Kkj+d3OR33TrFvrUFCkJGWPrH8+CMa0AroIb4bvLQw4IoEUe/zM eXpdOjik4hBj+v5ihTKJKECy8PRGOO4hE7b+iS1x0jhH43oauGr6/m8zYY5e49QkbZNM OhOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=nquRhfarP/58yEdGynEUzJtdfXrRdKyGr07a9XzhQ64=; b=axVegnNUTnAZzML8LUaHU++RdyXbSreivAdR12dXVQtFb9nXuInRXhD7CGS96M35Bt vdb+DMVjtwcG/oTV7nlEdtCJurA/CHooUzhnJ25R39TO6penWEaIObtGVm29Bx7KJvcN CXt2rjM0Dm4bS9v4SFpbneZgZTpZt1IdFcfMluomy2lRzFWIrBqs4cWyCb475IP5UyHO NPbFfH/pvKAGak1Jd+Ua5b79htf62qEK00uYJhcbck6joGIqXfoOT8G9dJMIzXgAOKm6 kCMuHIV3ZXdxCAslcRBxtSOrBEwmQZhKghU3tcQb2QGjb+HkWJckynjsFmRHa6Dpypop 56yA== X-Gm-Message-State: ALQs6tDUBfv2ZxBSoki5TRMiNGEdU0T0G1spoLWkmEj5kbo/Wds9huMN Eg5S+b6XaSP7Q7mPh1H9Ogp1YaZ7 X-Google-Smtp-Source: AIpwx4+zcCsnkh3oUoNltxUULO25VDgbJutN+gu5PCTWekHzB3ezthWkdstWcthKemVsIJNOxXlAbg== X-Received: by 10.107.146.67 with SMTP id u64mr5273352iod.144.1522601260745; Sun, 01 Apr 2018 09:47:40 -0700 (PDT) Received: from raichu (toroon0560w-lp130-01-174-88-76-83.dsl.bell.ca. [174.88.76.83]) by smtp.gmail.com with ESMTPSA id 79-v6sm4429341itm.11.2018.04.01.09.47.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Apr 2018 09:47:40 -0700 (PDT) Sender: Mark Johnston Date: Sun, 1 Apr 2018 12:47:35 -0400 From: Mark Johnston To: Harry Schmalzbauer Cc: Sean Bruno , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, glebius@FreeBSD.org Subject: Re: svn commit: r324508 - head/sys/kern Message-ID: <20180401164726.GA953@raichu> References: <201710102221.v9AML554015782@repo.freebsd.org> <5ABF55FC.6030102@omnilan.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5ABF55FC.6030102@omnilan.de> User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2018 16:47:42 -0000 On Sat, Mar 31, 2018 at 11:33:48AM +0200, Harry Schmalzbauer wrote: > Bezüglich Sean Bruno's Nachricht vom 11.10.2017 00:21 (localtime): > > Author: sbruno > > Date: Tue Oct 10 22:21:05 2017 > > New Revision: 324508 > > URL: https://svnweb.freebsd.org/changeset/base/324508 > > > > Log: > > match sendfile() error handling to send(). > > > > Sendfile() should match the error checking order of send() which > > is currently: > > > > SBS_CANTSENDMORE > > so_error > > SS_ISCONNECTED > > > > Submitted by: Jason Eggleston > > Reviewed by: glebius > > MFC after: 2 weeks > > Sponsored by: Limelight Networks > > Differential Revision: https://reviews.freebsd.org/D12633 > > > > Modified: > > head/sys/kern/kern_sendfile.c > > > > I'm still applying this one locally to stable/11. > Is it going to be MFCd before 11.2? > > There are a view more candidates: > https://svnweb.freebsd.org/base?view=revision&revision=324601 along with > r324448 > https://svnweb.freebsd.org/base?view=revision&revision=327596 > https://svnweb.freebsd.org/base?view=revision&revision=328977 > These were flagged for MFC with expired defer time. > And tomorrow this one was supposed to be MFCd also: > https://svnweb.freebsd.org/base?view=revision&revision=331130 I think r324446 and r324448 need to be MFCed before most of these can go in. I MFCed the other commits (r317567, r324508) that you asked about in other threads. From owner-svn-src-head@freebsd.org Sun Apr 1 16:53:22 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1C713F6D400; Sun, 1 Apr 2018 16:53:22 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: from mailrelay108.isp.belgacom.be (mailrelay108.isp.belgacom.be [195.238.20.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "relay.skynet.be", Issuer "GlobalSign Organization Validation CA - SHA256 - G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3C4FC74738; Sun, 1 Apr 2018 16:53:20 +0000 (UTC) (envelope-from tijl@freebsd.org) X-Belgacom-Dynamic: yes IronPort-PHdr: =?us-ascii?q?9a23=3AMn70IRQ8VBISfbMnBBoSsEyaY9psv+yvbD5Q0YIu?= =?us-ascii?q?jvd0So/mwa6zbRyN2/xhgRfzUJnB7Loc0qyK6/umATRIyK3CmUhKSIZLWR4BhJ?= =?us-ascii?q?detC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+?= =?us-ascii?q?KPjrFY7OlcS30P2594HObwlSizexfb1/IA+qoQnNq8IbnZZsJqEtxxXTv3BGYf?= =?us-ascii?q?5WxWRmJVKSmxbz+MK994N9/ipTpvws6ddOXb31cKokQ7NYCi8mM30u683wqRbD?= =?us-ascii?q?VwqP6WACXWgQjxFFHhLK7BD+Xpf2ryv6qu9w0zSUMMHqUbw5Xymp4rx1QxH0li?= =?us-ascii?q?gIKz858HnWisNuiqJbvAmhrAF7z4LNfY2ZKOZycqbbcNgHR2ROQ9xRWjRPDI28?= =?us-ascii?q?cYUBEukPMuRWr4byu1QAogCzBRWuCe/z1jNEmmP60bM83u88EQ/GxgsgH9cWvX?= =?us-ascii?q?rKrdX1NqMSWv2rwanPyjXDdO1Z2TLn54jOaRAqvPaBXa5xccrTzUkiDAPLjk+O?= =?us-ascii?q?poP7Ij6by+oDv3Kc7+p6WuKikmgqoBx/rDiow8cjkIjJhoQNx1DK7yV23pg6Ks?= =?us-ascii?q?ajSEFme9KkF4FQty6cOoBrQc0iW3lltSUnxrEcp5K2czUGxI45yxLDdfCLaZWE?= =?us-ascii?q?7xLtWeuXPDx2nmhqeKiliBa36UWgz+r8WdSq31tStSpFl8XMtmgK1xzO9siLUv?= =?us-ascii?q?t98Vml2TaIzw3T6ftLIUQ1lareNZEh2LkwmoAPsUTCHC/2nF/6g7ORdkUj4ein?= =?us-ascii?q?9eHnba/gpp+HLYN0jRv+Mqs2lsy+B+Q3LBQOUnCY9OihzrHv40L0TKhQgvEojq?= =?us-ascii?q?XVrorWKdkbq6O3GwNV15ws6xe7DzeoytQYmnwHIUpZeBKGjYjpP0rDIP7iDfih?= =?us-ascii?q?nVujiyxryO3cMr3mGJXNIWDPkK39crZl905c1A0zwMhE55JKDLENOenzWlXtu9?= =?us-ascii?q?DBDh82LRa7zPv8BdVzzIMRR3yADbSCMKzPq1OI4fgvI+aUbo8PpDn9M+Ql5+Lp?= =?us-ascii?q?jXIhgl8dY6+p0YIMaHCiAvtqOl+WYX7ogtoaH2cKpBQxQ/Lxh12ZTDFffXGyX7?= =?us-ascii?q?gz5jsjEoKpEZ/DRpyxgLyGxCq7BYdWaXxfBl+QFnfocoCEW/YQaCKOPMBhiCcE?= =?us-ascii?q?WKOvS487yx6hqhT1y6F6IebO/S0Yr53j3sBv5+LPjREy6SB0D8OF3mGIVW50hG?= =?us-ascii?q?AIRz0t0aBxu0xy1EmM3rNjg/NFD9BT4OlJUghpfaLbmslzEdO6eAXBeMyVT1Du?= =?us-ascii?q?FtCvGzIzZvwrztIkWGo7HM+t2EPtxS2vVoMUlbjDL5sz6a/Z1n7qb5JhynTC/I?= =?us-ascii?q?c7glQMeecJMnep0P0svzPPDpLExh3K352hcr4RiWuUrD+O?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2CcCADXDMFa/5nK8VFdFgYBAQEEAQEKA?= =?us-ascii?q?QGDQlMObxUTjDqMIgEBgXMxAV2SU4F6LoRhAoQkIjYWAQIBAQEBAQECAWoogjc?= =?us-ascii?q?kAYJJAQUnExwjEAsUBAklDyoeBhOFEQuwKDOIOoImBYl0gxRINIpDApc6CIVRi?= =?us-ascii?q?FJlVoNZhy6JFYgNIwEwgVJNMAiCfZBPPTCOAAEB?= X-IPAS-Result: =?us-ascii?q?A2CcCADXDMFa/5nK8VFdFgYBAQEEAQEKAQGDQlMObxUTjDq?= =?us-ascii?q?MIgEBgXMxAV2SU4F6LoRhAoQkIjYWAQIBAQEBAQECAWoogjckAYJJAQUnExwjE?= =?us-ascii?q?AsUBAklDyoeBhOFEQuwKDOIOoImBYl0gxRINIpDApc6CIVRiFJlVoNZhy6JFYg?= =?us-ascii?q?NIwEwgVJNMAiCfZBPPTCOAAEB?= Received: from 153.202-241-81.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([81.241.202.153]) by relay.skynet.be with ESMTP; 01 Apr 2018 18:52:10 +0200 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.15.2/8.15.2) with ESMTP id w31GqA15001530; Sun, 1 Apr 2018 18:52:10 +0200 (CEST) (envelope-from tijl@FreeBSD.org) Date: Sun, 1 Apr 2018 18:52:09 +0200 From: Tijl Coosemans To: Mark Johnston Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331732 - head/sys/vm Message-ID: <20180401185209.17f65d95@kalimero.tijl.coosemans.org> In-Reply-To: <20180401162703.GD1440@raichu> References: <201803291427.w2TEReA3024929@repo.freebsd.org> <20180331202118.5401ed2a@kalimero.tijl.coosemans.org> <20180331225432.GB1440@raichu> <20180401172021.27852803@kalimero.tijl.coosemans.org> <20180401162703.GD1440@raichu> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2018 16:53:22 -0000 On Sun, 1 Apr 2018 12:27:03 -0400 Mark Johnston wrote: > On Sun, Apr 01, 2018 at 05:20:21PM +0200, Tijl Coosemans wrote: >> On Sat, 31 Mar 2018 18:54:32 -0400 Mark Johnston wrote: >>> On Sat, Mar 31, 2018 at 08:21:18PM +0200, Tijl Coosemans wrote: >>>> On Thu, 29 Mar 2018 14:27:40 +0000 (UTC) Mark Johnston wrote: >>>>> Author: markj >>>>> Date: Thu Mar 29 14:27:40 2018 >>>>> New Revision: 331732 >>>>> URL: https://svnweb.freebsd.org/changeset/base/331732 >>>>> >>>>> Log: >>>>> Fix the background laundering mechanism after r329882. >>>>> >>>>> Rather than using the number of inactive queue scans as a metric for >>>>> how many clean pages are being freed by the page daemon, have the >>>>> page daemon keep a running counter of the number of pages it has freed, >>>>> and have the laundry thread use that when computing the background >>>>> laundering threshold. >>>>> [...] >>>> >>>> I'm seeing big processes being killed with an "out of swap space" message >>>> even though there's still plenty of swap available. It seems to be fixed >>>> by making this division round upwards: >>>> >>>> if (target == 0 && ndirty * isqrt((nfreed + >>>> (vmd->vmd_free_target - vmd->vmd_free_min) - 1) / >>>> (vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) { >>>> >>>> I don't know where this formula comes from, so I don't know if this >>>> change is correct. >>> >>> Hm, that's somewhat surprising. This code shouldn't be executing in >>> situations where the OOM kill logic is invoked (i.e., memory pressure >>> plus a shortage of clean pages in the inactive queue). >>> >>> How much RAM does the system have? Could you collect "sysctl vm" output >>> around the time of an OOM kill? >> >> 1GiB RAM. I've sampled sysctl vm every 5s from the moment the process >> starts swapping until it is killed and uploaded that to >> https://people.freebsd.org/~tijl/sysctl/ > > Thank you. Now I agree with your change. Would you like to commit it? > I can take care of it if you prefer. Please go ahead. You can probably write a better commit log. From owner-svn-src-head@freebsd.org Sun Apr 1 18:22:25 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3E073F72C3D; Sun, 1 Apr 2018 18:22:25 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E2B0477D68; Sun, 1 Apr 2018 18:22:24 +0000 (UTC) (envelope-from ian@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 C46FF27DF; Sun, 1 Apr 2018 18:22:24 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w31IMO0X085506; Sun, 1 Apr 2018 18:22:24 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w31IMOeI085501; Sun, 1 Apr 2018 18:22:24 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804011822.w31IMOeI085501@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 1 Apr 2018 18:22:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331868 - in head/sys/modules: i2c/iicbus i2c/isl spi/at45d spi/mx25l spi/spibus X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in head/sys/modules: i2c/iicbus i2c/isl spi/at45d spi/mx25l spi/spibus X-SVN-Commit-Revision: 331868 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2018 18:22:25 -0000 Author: ian Date: Sun Apr 1 18:22:24 2018 New Revision: 331868 URL: https://svnweb.freebsd.org/changeset/base/331868 Log: Add opt_platform.h for several modules that have #ifdef FDT in the source. Submitted by: Andre Albsmeier Modified: head/sys/modules/i2c/iicbus/Makefile head/sys/modules/i2c/isl/Makefile head/sys/modules/spi/at45d/Makefile head/sys/modules/spi/mx25l/Makefile head/sys/modules/spi/spibus/Makefile Modified: head/sys/modules/i2c/iicbus/Makefile ============================================================================== --- head/sys/modules/i2c/iicbus/Makefile Sun Apr 1 16:43:30 2018 (r331867) +++ head/sys/modules/i2c/iicbus/Makefile Sun Apr 1 18:22:24 2018 (r331868) @@ -13,6 +13,7 @@ SRCS= \ iicbus_if.h \ iiconf.c \ iiconf.h \ + opt_platform.h \ .if !empty(OPT_FDT) SRCS+= ofw_iicbus.c ofw_bus_if.h Modified: head/sys/modules/i2c/isl/Makefile ============================================================================== --- head/sys/modules/i2c/isl/Makefile Sun Apr 1 16:43:30 2018 (r331867) +++ head/sys/modules/i2c/isl/Makefile Sun Apr 1 18:22:24 2018 (r331868) @@ -2,6 +2,6 @@ .PATH: ${SRCTOP}/sys/dev/isl KMOD = isl -SRCS = isl.c device_if.h bus_if.h iicbus_if.h +SRCS = isl.c device_if.h bus_if.h iicbus_if.h opt_platform.h .include Modified: head/sys/modules/spi/at45d/Makefile ============================================================================== --- head/sys/modules/spi/at45d/Makefile Sun Apr 1 16:43:30 2018 (r331867) +++ head/sys/modules/spi/at45d/Makefile Sun Apr 1 18:22:24 2018 (r331868) @@ -9,6 +9,7 @@ SRCS= at45d.c SRCS+= \ bus_if.h \ device_if.h \ + opt_platform.h \ spibus_if.h \ .if !empty(OPT_FDT) Modified: head/sys/modules/spi/mx25l/Makefile ============================================================================== --- head/sys/modules/spi/mx25l/Makefile Sun Apr 1 16:43:30 2018 (r331867) +++ head/sys/modules/spi/mx25l/Makefile Sun Apr 1 18:22:24 2018 (r331868) @@ -9,6 +9,7 @@ SRCS= mx25l.c SRCS+= \ bus_if.h \ device_if.h \ + opt_platform.h \ spibus_if.h \ .if !empty(OPT_FDT) Modified: head/sys/modules/spi/spibus/Makefile ============================================================================== --- head/sys/modules/spi/spibus/Makefile Sun Apr 1 16:43:30 2018 (r331867) +++ head/sys/modules/spi/spibus/Makefile Sun Apr 1 18:22:24 2018 (r331868) @@ -13,6 +13,7 @@ SRCS+= ofw_spibus.c ofw_bus_if.h SRCS+= \ bus_if.h \ device_if.h \ + opt_platform.h \ spibus_if.c \ spibus_if.h \ From owner-svn-src-head@freebsd.org Sun Apr 1 18:53:28 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3F8E0F7476E; Sun, 1 Apr 2018 18:53:28 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E988378E63; Sun, 1 Apr 2018 18:53:27 +0000 (UTC) (envelope-from ian@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 E46DD2CCC; Sun, 1 Apr 2018 18:53:27 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w31IrR9D003324; Sun, 1 Apr 2018 18:53:27 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w31IrR5X003323; Sun, 1 Apr 2018 18:53:27 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804011853.w31IrR5X003323@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 1 Apr 2018 18:53:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331869 - head/sys/dev/nxge X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/dev/nxge X-SVN-Commit-Revision: 331869 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2018 18:53:28 -0000 Author: ian Date: Sun Apr 1 18:53:27 2018 New Revision: 331869 URL: https://svnweb.freebsd.org/changeset/base/331869 Log: Fix the build on arches with default unsigned char. Capture the fubyte() return value in an int as well as the char, and test the full int value for fubyte() failure. Modified: head/sys/dev/nxge/if_nxge.c Modified: head/sys/dev/nxge/if_nxge.c ============================================================================== --- head/sys/dev/nxge/if_nxge.c Sun Apr 1 18:22:24 2018 (r331868) +++ head/sys/dev/nxge/if_nxge.c Sun Apr 1 18:53:27 2018 (r331869) @@ -1366,12 +1366,13 @@ xge_ioctl_stats(xge_lldev_t *lldev, struct ifreq *ifre xge_hal_status_e status = XGE_HAL_OK; char cmd, mode; void *info = NULL; - int retValue = EINVAL; + int retValue; - cmd = fubyte(ifr_data_get_ptr(ifreqp)); - if (cmd == -1) + cmd = retValue = fubyte(ifr_data_get_ptr(ifreqp)); + if (retValue == -1) return (EFAULT); + retValue = EINVAL; switch(cmd) { case XGE_QUERY_STATS: mtx_lock(&lldev->mtx_drv); From owner-svn-src-head@freebsd.org Sun Apr 1 19:35:53 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1E7ECF76C63 for ; Sun, 1 Apr 2018 19:35:53 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1a.eu.mailhop.org (outbound1a.eu.mailhop.org [52.58.109.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 911557A3D5 for ; Sun, 1 Apr 2018 19:35:52 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: e24ccfc7-35e3-11e8-91c6-33ffc249f3e8 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound1.eu.mailhop.org (Halon) with ESMTPSA id e24ccfc7-35e3-11e8-91c6-33ffc249f3e8; Sun, 01 Apr 2018 19:35:51 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id w31JZjf3076285; Sun, 1 Apr 2018 13:35:45 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <1522611345.49673.175.camel@freebsd.org> Subject: Re: svn commit: r327954 - in head/sys: amd64/conf conf dev/acpica vm x86/acpica From: Ian Lepore To: Jeff Roberson , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Sun, 01 Apr 2018 13:35:45 -0600 In-Reply-To: <201801140336.w0E3a3xv010728@repo.freebsd.org> References: <201801140336.w0E3a3xv010728@repo.freebsd.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2018 19:35:53 -0000 On Sun, 2018-01-14 at 03:36 +0000, Jeff Roberson wrote: > Author: jeff > Date: Sun Jan 14 03:36:03 2018 > New Revision: 327954 > URL: https://svnweb.freebsd.org/changeset/base/327954 > > Log: >   Move VM_NUMA_ALLOC and DEVICE_NUMA under the single global config > option NUMA. >    >   Sponsored by: Netflix, Dell/EMC Isilon >   Discussed with: jhb It turns out this breaks building powerpc lint kernels. It shakes out like this... makeLINT.mk copies sys/conf/NOTES into the generated LINT config (I guess on the theory that things documented in NOTES are supported by all arches). So option NUMA is present on powerpc, but the powerpc vmparam.h doesn't define VM_LEVEL_0_ORDER so the build fails. (Mips also doesn't define that, but it has no lint kernel build at all right now.) It could be fixed in vm_domainset.c with: -#ifdef NUMA +#if defined(NUMA) && defined(VM_LEVEL_0_ORDER) but there may be some better way to fix it, I don't know that much about this stuff. -- Ian From owner-svn-src-head@freebsd.org Mon Apr 2 05:12:00 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6C565F7342B; Mon, 2 Apr 2018 05:12:00 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1AA796DCD0; Mon, 2 Apr 2018 05:12:00 +0000 (UTC) (envelope-from glebius@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 1594111526; Mon, 2 Apr 2018 05:12:00 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w325BxPx014265; Mon, 2 Apr 2018 05:11:59 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w325Bx89014264; Mon, 2 Apr 2018 05:11:59 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201804020511.w325Bx89014264@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Mon, 2 Apr 2018 05:11:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331871 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 331871 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 05:12:00 -0000 Author: glebius Date: Mon Apr 2 05:11:59 2018 New Revision: 331871 URL: https://svnweb.freebsd.org/changeset/base/331871 Log: Handle a special case when a slab can fit only one allocation, and zone has a large alignment. With alignment taken into account uk_rsize will be greater than space in a slab. However, since we have only one item per slab, it is always naturally aligned. Code that will panic before this change with 4k page: z = uma_zcreate("test", 3984, NULL, NULL, NULL, NULL, 31, 0); uma_zalloc(z, M_WAITOK); A practical scenario to hit the panic is a machine with 56 CPUs and 2 NUMA domains, which yields in zone size of 3984. PR: 227116 MFC after: 2 weeks Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c ============================================================================== --- head/sys/vm/uma_core.c Sun Apr 1 22:59:53 2018 (r331870) +++ head/sys/vm/uma_core.c Mon Apr 2 05:11:59 2018 (r331871) @@ -1290,7 +1290,15 @@ keg_small_init(uma_keg_t keg) else shsize = sizeof(struct uma_slab); - keg->uk_ipers = (slabsize - shsize) / rsize; + if (rsize <= slabsize - shsize) + keg->uk_ipers = (slabsize - shsize) / rsize; + else { + /* Handle special case when we have 1 item per slab, so + * alignment requirement can be relaxed. */ + KASSERT(keg->uk_size <= slabsize - shsize, + ("%s: size %u greater than slab", __func__, keg->uk_size)); + keg->uk_ipers = 1; + } KASSERT(keg->uk_ipers > 0 && keg->uk_ipers <= SLAB_SETSIZE, ("%s: keg->uk_ipers %u", __func__, keg->uk_ipers)); From owner-svn-src-head@freebsd.org Mon Apr 2 05:14:32 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B3987F735A0; Mon, 2 Apr 2018 05:14:32 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5FD196DEE8; Mon, 2 Apr 2018 05:14:32 +0000 (UTC) (envelope-from glebius@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 4E5CA1154D; Mon, 2 Apr 2018 05:14:32 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w325EW6a014451; Mon, 2 Apr 2018 05:14:32 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w325EW3u014450; Mon, 2 Apr 2018 05:14:32 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201804020514.w325EW3u014450@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Mon, 2 Apr 2018 05:14:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331872 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 331872 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 05:14:32 -0000 Author: glebius Date: Mon Apr 2 05:14:31 2018 New Revision: 331872 URL: https://svnweb.freebsd.org/changeset/base/331872 Log: In uma_startup_count() handle special case when zone will fit into single slab, but with alignment adjustment it won't. Again, when there is only one item in a slab alignment can be ignored. See previous revision of this file for more info. PR: 227116 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c ============================================================================== --- head/sys/vm/uma_core.c Mon Apr 2 05:11:59 2018 (r331871) +++ head/sys/vm/uma_core.c Mon Apr 2 05:14:31 2018 (r331872) @@ -1828,9 +1828,11 @@ uma_startup_count(int vm_zones) #endif /* Memory for the rest of startup zones, UMA and VM, ... */ - if (zsize > UMA_SLAB_SIZE) + if (zsize > UMA_SLAB_SPACE) pages += (zones + vm_zones) * howmany(roundup2(zsize, UMA_BOOT_ALIGN), UMA_SLAB_SIZE); + else if (roundup2(zsize, UMA_BOOT_ALIGN) > UMA_SLAB_SPACE) + pages += zones; else pages += howmany(zones, UMA_SLAB_SPACE / roundup2(zsize, UMA_BOOT_ALIGN)); From owner-svn-src-head@freebsd.org Mon Apr 2 05:15:26 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2530DF73653; Mon, 2 Apr 2018 05:15:26 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CDEB06E047; Mon, 2 Apr 2018 05:15:25 +0000 (UTC) (envelope-from glebius@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 C88E11154F; Mon, 2 Apr 2018 05:15:25 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w325FPfm014556; Mon, 2 Apr 2018 05:15:25 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w325FPdx014555; Mon, 2 Apr 2018 05:15:25 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201804020515.w325FPdx014555@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Mon, 2 Apr 2018 05:15:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331873 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 331873 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 05:15:26 -0000 Author: glebius Date: Mon Apr 2 05:15:25 2018 New Revision: 331873 URL: https://svnweb.freebsd.org/changeset/base/331873 Log: Use UMA_SLAB_SPACE macro. No functional change here. Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c ============================================================================== --- head/sys/vm/uma_core.c Mon Apr 2 05:14:31 2018 (r331872) +++ head/sys/vm/uma_core.c Mon Apr 2 05:15:25 2018 (r331873) @@ -1481,7 +1481,7 @@ keg_ctor(void *mem, int size, void *udata, int flags) if (keg->uk_flags & UMA_ZONE_CACHESPREAD) { keg_cachespread_init(keg); } else { - if (keg->uk_size > (UMA_SLAB_SIZE - sizeof(struct uma_slab))) + if (keg->uk_size > UMA_SLAB_SPACE) keg_large_init(keg); else keg_small_init(keg); From owner-svn-src-head@freebsd.org Mon Apr 2 07:45:14 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 390EDF79CAD; Mon, 2 Apr 2018 07:45:14 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DE63C72B1D; Mon, 2 Apr 2018 07:45:13 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D54F212D54; Mon, 2 Apr 2018 07:45:13 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w327jDEA089793; Mon, 2 Apr 2018 07:45:13 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w327jDOO089791; Mon, 2 Apr 2018 07:45:13 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201804020745.w327jDOO089791@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Mon, 2 Apr 2018 07:45:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331874 - in head/sys: amd64/amd64 i386/i386 X-SVN-Group: head X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in head/sys: amd64/amd64 i386/i386 X-SVN-Commit-Revision: 331874 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 07:45:14 -0000 Author: avg Date: Mon Apr 2 07:45:13 2018 New Revision: 331874 URL: https://svnweb.freebsd.org/changeset/base/331874 Log: x86 cpu_reset_proxy: no need to stop_cpus() the original processor The processor is "parked" in a spin-loop already and that's sufficient for the reset. There is nothing that stop_cpus() would add here, only extra complexity and fragility. The original processor does not need to enable interrupts now, in fact, it must not do that. MFC after: 2 weeks Modified: head/sys/amd64/amd64/vm_machdep.c head/sys/i386/i386/vm_machdep.c Modified: head/sys/amd64/amd64/vm_machdep.c ============================================================================== --- head/sys/amd64/amd64/vm_machdep.c Mon Apr 2 05:15:25 2018 (r331873) +++ head/sys/amd64/amd64/vm_machdep.c Mon Apr 2 07:45:13 2018 (r331874) @@ -569,14 +569,11 @@ cpu_set_user_tls(struct thread *td, void *tls_base) static void cpu_reset_proxy() { - cpuset_t tcrp; cpu_reset_proxy_active = 1; while (cpu_reset_proxy_active == 1) ia32_pause(); /* Wait for other cpu to see that we've started */ - CPU_SETOF(cpu_reset_proxyid, &tcrp); - stop_cpus(tcrp); printf("cpu_reset_proxy: Stopped CPU %d\n", cpu_reset_proxyid); DELAY(1000000); cpu_reset_real(); @@ -616,7 +613,6 @@ cpu_reset() } if (cpu_reset_proxy_active == 0) printf("cpu_reset: Failed to restart BSP\n"); - enable_intr(); cpu_reset_proxy_active = 2; while (1) Modified: head/sys/i386/i386/vm_machdep.c ============================================================================== --- head/sys/i386/i386/vm_machdep.c Mon Apr 2 05:15:25 2018 (r331873) +++ head/sys/i386/i386/vm_machdep.c Mon Apr 2 07:45:13 2018 (r331874) @@ -581,14 +581,11 @@ kvtop(void *addr) static void cpu_reset_proxy() { - cpuset_t tcrp; cpu_reset_proxy_active = 1; while (cpu_reset_proxy_active == 1) ia32_pause(); /* Wait for other cpu to see that we've started */ - CPU_SETOF(cpu_reset_proxyid, &tcrp); - stop_cpus(tcrp); printf("cpu_reset_proxy: Stopped CPU %d\n", cpu_reset_proxyid); DELAY(1000000); cpu_reset_real(); @@ -628,7 +625,6 @@ cpu_reset() } if (cpu_reset_proxy_active == 0) printf("cpu_reset: Failed to restart BSP\n"); - enable_intr(); cpu_reset_proxy_active = 2; while (1) From owner-svn-src-head@freebsd.org Mon Apr 2 08:06:19 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B1793F7AF56; Mon, 2 Apr 2018 08:06:19 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 63E4B736C6; Mon, 2 Apr 2018 08:06:19 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5E59413077; Mon, 2 Apr 2018 08:06:19 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3286JhJ000182; Mon, 2 Apr 2018 08:06:19 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3286J4l000180; Mon, 2 Apr 2018 08:06:19 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201804020806.w3286J4l000180@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Mon, 2 Apr 2018 08:06:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331875 - in head/sys: amd64/amd64 i386/i386 X-SVN-Group: head X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in head/sys: amd64/amd64 i386/i386 X-SVN-Commit-Revision: 331875 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 08:06:19 -0000 Author: avg Date: Mon Apr 2 08:06:18 2018 New Revision: 331875 URL: https://svnweb.freebsd.org/changeset/base/331875 Log: x86 cpu_reset: if failed to switch to BSP proceed to cpu_reset_real If cpu_reset() is called on an AP and if it somehow fails to wake the BSP, then it's better to attempt the reset on the AP than just sit there spinning on an unusable and undebuggable system. MFC after: 16 days Modified: head/sys/amd64/amd64/vm_machdep.c head/sys/i386/i386/vm_machdep.c Modified: head/sys/amd64/amd64/vm_machdep.c ============================================================================== --- head/sys/amd64/amd64/vm_machdep.c Mon Apr 2 07:45:13 2018 (r331874) +++ head/sys/amd64/amd64/vm_machdep.c Mon Apr 2 08:06:18 2018 (r331875) @@ -611,13 +611,14 @@ cpu_reset() ia32_pause(); cnt++; /* Wait for BSP to announce restart */ } - if (cpu_reset_proxy_active == 0) + if (cpu_reset_proxy_active == 0) { printf("cpu_reset: Failed to restart BSP\n"); - cpu_reset_proxy_active = 2; - - while (1) - ia32_pause(); - /* NOTREACHED */ + } else { + cpu_reset_proxy_active = 2; + while (1) + ia32_pause(); + /* NOTREACHED */ + } } DELAY(1000000); Modified: head/sys/i386/i386/vm_machdep.c ============================================================================== --- head/sys/i386/i386/vm_machdep.c Mon Apr 2 07:45:13 2018 (r331874) +++ head/sys/i386/i386/vm_machdep.c Mon Apr 2 08:06:18 2018 (r331875) @@ -623,13 +623,14 @@ cpu_reset() ia32_pause(); cnt++; /* Wait for BSP to announce restart */ } - if (cpu_reset_proxy_active == 0) + if (cpu_reset_proxy_active == 0) { printf("cpu_reset: Failed to restart BSP\n"); - cpu_reset_proxy_active = 2; - - while (1) - ia32_pause(); - /* NOTREACHED */ + } else { + cpu_reset_proxy_active = 2; + while (1) + ia32_pause(); + /* NOTREACHED */ + } } DELAY(1000000); From owner-svn-src-head@freebsd.org Mon Apr 2 08:41:33 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ABF3AF7CDF1; Mon, 2 Apr 2018 08:41:33 +0000 (UTC) (envelope-from freebsd@omnilan.de) Received: from mx0.gentlemail.de (mx0.gentlemail.de [IPv6:2a00:e10:2800::a130]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 32B0874A02; Mon, 2 Apr 2018 08:41:32 +0000 (UTC) (envelope-from freebsd@omnilan.de) Received: from mh0.gentlemail.de (mh0.gentlemail.de [IPv6:2a00:e10:2800::a135]) by mx0.gentlemail.de (8.14.5/8.14.5) with ESMTP id w328fUo6043979; Mon, 2 Apr 2018 10:41:30 +0200 (CEST) (envelope-from freebsd@omnilan.de) Received: from titan.inop.mo1.omnilan.net (s1.omnilan.de [217.91.127.234]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mh0.gentlemail.de (Postfix) with ESMTPSA id 3B718372; Mon, 2 Apr 2018 10:41:29 +0200 (CEST) Message-ID: <5AC1ECB8.6050709@omnilan.de> Date: Mon, 02 Apr 2018 10:41:28 +0200 From: Harry Schmalzbauer Organization: OmniLAN User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; de-DE; rv:1.9.2.8) Gecko/20100906 Lightning/1.0b2 Thunderbird/3.1.2 MIME-Version: 1.0 To: Mark Johnston CC: svn-src-head@freebsd.org, Sean Bruno , src-committers@freebsd.org, glebius@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r324508 - head/sys/kern References: <201710102221.v9AML554015782@repo.freebsd.org> <5ABF55FC.6030102@omnilan.de> <20180401164726.GA953@raichu> In-Reply-To: <20180401164726.GA953@raichu> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (mx0.gentlemail.de [IPv6:2a00:e10:2800::a130]); Mon, 02 Apr 2018 10:41:30 +0200 (CEST) X-Milter: Spamilter (Reciever: mx0.gentlemail.de; Sender-ip: ; Sender-helo: mh0.gentlemail.de; ) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 08:41:33 -0000 Bezüglich Mark Johnston's Nachricht vom 01.04.2018 18:47 (localtime): > On Sat, Mar 31, 2018 at 11:33:48AM +0200, Harry Schmalzbauer wrote: >> Bezüglich Sean Bruno's Nachricht vom 11.10.2017 00:21 (localtime): >>> Author: sbruno >>> Date: Tue Oct 10 22:21:05 2017 >>> New Revision: 324508 >>> URL: https://svnweb.freebsd.org/changeset/base/324508 >>> >>> Log: >>> match sendfile() error handling to send(). >>> >>> Sendfile() should match the error checking order of send() which >>> is currently: >>> >>> SBS_CANTSENDMORE >>> so_error >>> SS_ISCONNECTED >>> >>> Submitted by: Jason Eggleston >>> Reviewed by: glebius >>> MFC after: 2 weeks >>> Sponsored by: Limelight Networks >>> Differential Revision: https://reviews.freebsd.org/D12633 >>> >>> Modified: >>> head/sys/kern/kern_sendfile.c >>> >> >> I'm still applying this one locally to stable/11. >> Is it going to be MFCd before 11.2? >> >> There are a view more candidates: >> https://svnweb.freebsd.org/base?view=revision&revision=324601 along with >> r324448 >> https://svnweb.freebsd.org/base?view=revision&revision=327596 >> https://svnweb.freebsd.org/base?view=revision&revision=328977 >> These were flagged for MFC with expired defer time. >> And tomorrow this one was supposed to be MFCd also: >> https://svnweb.freebsd.org/base?view=revision&revision=331130 > > I think r324446 and r324448 need to be MFCed before most of these can go > in. I MFCed the other commits (r317567, r324508) that you asked about in > other threads. Thanks for MFCing the unrelated other two (r317567, r324508) from cem@! Hope someone finds time to sort out the dependiencies of r324446, r324448 and this r324508 along with r324601, r327596, r328977. Currently I don't have a sendfile() test case, but for some reason I stumbled across this MFCflagged commit some time ago and I guess 11.2 shouldn't ship without. Thanks, -harry From owner-svn-src-head@freebsd.org Mon Apr 2 13:27:18 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ACF63F59205; Mon, 2 Apr 2018 13:27:18 +0000 (UTC) (envelope-from agapon@gmail.com) Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 213607E5AD; Mon, 2 Apr 2018 13:27:17 +0000 (UTC) (envelope-from agapon@gmail.com) Received: by mail-wm0-f52.google.com with SMTP id g8so1626693wmd.2; Mon, 02 Apr 2018 06:27:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=MWGFbLlxvUnupy54sVhUkrOEHMrBCvvdx1luGRX1os4=; b=iei5UOHm4OF0Yw7pSbBtjqKiwFcMZ5wOsbUfQOHIqLZuZIPWwN0PP0V3yk0YM/2JAL sG2ADYRSxK13K2chojCAN2/ljITT8qhVXKbejpjET7pWGq+WA31GTquQKKrFwZDVx7xC D+z7nnskH/T17S9WkjfVto+bjPzBVp1MTRoVfExPY/iCpL7uIum80bd1Rhf6ioUxoJ99 RV/rwT2k9f3qtiu3aDMeuIzgSojN4Wq+cHCcbuYLu2dAeuUcJhkWBpizMqgx/YDcrRlA 6CaPXDqS+FWsx6hkh8kerqX3U4Yv6selfh3FMJJVll+xrgCXR0RkcDNCXHV5LFPfLL/Q krwA== X-Gm-Message-State: ALQs6tDHwStcLlAm7tBJtC7IxJn81FeLMqep4h0ItuHAhWiJ9hFaZmRI ssCGMmpAEGO+mSRDEOt9qUwzdw4v X-Google-Smtp-Source: AIpwx4/E62SiKt+nACmlfkLVSbGldRpZRHyZrhGsSkz4swm5v0jsQlKWEPWutylTSK66yYhiAp+Rvw== X-Received: by 10.46.84.12 with SMTP id i12mr5857983ljb.9.1522675631073; Mon, 02 Apr 2018 06:27:11 -0700 (PDT) Received: from [192.168.0.88] (east.meadow.volia.net. [93.72.151.96]) by smtp.googlemail.com with ESMTPSA id e28-v6sm68487lfb.52.2018.04.02.06.27.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Apr 2018 06:27:10 -0700 (PDT) Subject: Re: svn commit: r327056 - in head/sys: kern sys x86/acpica x86/x86 To: Bruce Evans , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201712210917.vBL9Hmd0042736@repo.freebsd.org> From: Andriy Gapon Openpgp: preference=signencrypt Autocrypt: addr=avg@FreeBSD.org; keydata= xsFNBFm4LIgBEADNB/3lT7f15UKeQ52xCFQx/GqHkSxEdVyLFZTmY3KyNPQGBtyvVyBfprJ7 mAeXZWfhat6cKNRAGZcL5EmewdQuUfQfBdYmKjbw3a9GFDsDNuhDA2QwFt8BmkiVMRYyvI7l N0eVzszWCUgdc3qqM6qqcgBaqsVmJluwpvwp4ZBXmch5BgDDDb1MPO8AZ2QZfIQmplkj8Y6Z AiNMknkmgaekIINSJX8IzRzKD5WwMsin70psE8dpL/iBsA2cpJGzWMObVTtCxeDKlBCNqM1i gTXta1ukdUT7JgLEFZk9ceYQQMJJtUwzWu1UHfZn0Fs29HTqawfWPSZVbulbrnu5q55R4PlQ /xURkWQUTyDpqUvb4JK371zhepXiXDwrrpnyyZABm3SFLkk2bHlheeKU6Yql4pcmSVym1AS4 dV8y0oHAfdlSCF6tpOPf2+K9nW1CFA8b/tw4oJBTtfZ1kxXOMdyZU5fiG7xb1qDgpQKgHUX8 7Rd2T1UVLVeuhYlXNw2F+a2ucY+cMoqz3LtpksUiBppJhw099gEXehcN2JbUZ2TueJdt1FdS ztnZmsHUXLxrRBtGwqnFL7GSd6snpGIKuuL305iaOGODbb9c7ne1JqBbkw1wh8ci6vvwGlzx rexzimRaBzJxlkjNfMx8WpCvYebGMydNoeEtkWldtjTNVsUAtQARAQABzR5BbmRyaXkgR2Fw b24gPGF2Z0BGcmVlQlNELm9yZz7CwZQEEwEIAD4WIQS+LEO7ngQnXA4Bjr538m7TUc1yjwUC WbgsiAIbIwUJBaOagAULCQgHAgYVCAkKCwIEFgIDAQIeAQIXgAAKCRB38m7TUc1yj+JAEACV l9AK/nOWAt/9cufV2fRj0hdOqB1aCshtSrwHk/exXsDa4/FkmegxXQGY+3GWX3deIyesbVRL rYdtdK0dqJyT1SBqXK1h3/at9rxr9GQA6KWOxTjUFURsU7ok/6SIlm8uLRPNKO+yq0GDjgaO LzN+xykuBA0FlhQAXJnpZLcVfPJdWv7sSHGedL5ln8P8rxR+XnmsA5TUaaPcbhTB+mG+iKFj GghASDSfGqLWFPBlX/fpXikBDZ1gvOr8nyMY9nXhgfXpq3B6QCRYKPy58ChrZ5weeJZ29b7/ QdEO8NFNWHjSD9meiLdWQaqo9Y7uUxN3wySc/YUZxtS0bhAd8zJdNPsJYG8sXgKjeBQMVGuT eCAJFEYJqbwWvIXMfVWop4+O4xB+z2YE3jAbG/9tB/GSnQdVSj3G8MS80iLS58frnt+RSEw/ psahrfh0dh6SFHttE049xYiC+cM8J27Aaf0i9RflyITq57NuJm+AHJoU9SQUkIF0nc6lfA+o JRiyRlHZHKoRQkIg4aiKaZSWjQYRl5Txl0IZUP1dSWMX4s3XTMurC/pnja45dge/4ESOtJ9R 8XuIWg45Oq6MeIWdjKddGhRj3OohsltKgkEU3eLKYtB6qRTQypHHUawCXz88uYt5e3w4V16H lCpSTZV/EVHnNe45FVBlvK7k7HFfDDkryM7BTQRZuCyIARAAlq0slcsVboY/+IUJdcbEiJRW be9HKVz4SUchq0z9MZPX/0dcnvz/gkyYA+OuM78dNS7Mbby5dTvOqfpLJfCuhaNYOhlE0wY+ 1T6Tf1f4c/uA3U/YiadukQ3+6TJuYGAdRZD5EqYFIkreARTVWg87N9g0fT9BEqLw9lJtEGDY EWUE7L++B8o4uu3LQFEYxcrb4K/WKmgtmFcm77s0IKDrfcX4doV92QTIpLiRxcOmCC/OCYuO jB1oaaqXQzZrCutXRK0L5XN1Y1PYjIrEzHMIXmCDlLYnpFkK+itlXwlE2ZQxkfMruCWdQXye syl2fynAe8hvp7Mms9qU2r2K9EcJiR5N1t1C2/kTKNUhcRv7Yd/vwusK7BqJbhlng5ZgRx0m WxdntU/JLEntz3QBsBsWM9Y9wf2V4tLv6/DuDBta781RsCB/UrU2zNuOEkSixlUiHxw1dccI 6CVlaWkkJBxmHX22GdDFrcjvwMNIbbyfQLuBq6IOh8nvu9vuItup7qemDG3Ms6TVwA7BD3j+ 3fGprtyW8Fd/RR2bW2+LWkMrqHffAr6Y6V3h5kd2G9Q8ZWpEJk+LG6Mk3fhZhmCnHhDu6CwN MeUvxXDVO+fqc3JjFm5OxhmfVeJKrbCEUJyM8ESWLoNHLqjywdZga4Q7P12g8DUQ1mRxYg/L HgZY3zfKOqcAEQEAAcLBfAQYAQgAJhYhBL4sQ7ueBCdcDgGOvnfybtNRzXKPBQJZuCyIAhsM BQkFo5qAAAoJEHfybtNRzXKPBVwQAKfFy9P7N3OsLDMB56A4Kf+ZT+d5cIx0Yiaf4n6w7m3i ImHHHk9FIetI4Xe54a2IXh4Bq5UkAGY0667eIs+Z1Ea6I2i27Sdo7DxGwq09Qnm/Y65ADvXs 3aBvokCcm7FsM1wky395m8xUos1681oV5oxgqeRI8/76qy0hD9WR65UW+HQgZRIcIjSel9vR XDaD2HLGPTTGr7u4v00UeTMs6qvPsa2PJagogrKY8RXdFtXvweQFz78NbXhluwix2Tb9ETPk LIpDrtzV73CaE2aqBG/KrboXT2C67BgFtnk7T7Y7iKq4/XvEdDWscz2wws91BOXuMMd4c/c4 OmGW9m3RBLufFrOag1q5yUS9QbFfyqL6dftJP3Zq/xe+mr7sbWbhPVCQFrH3r26mpmy841ym dwQnNcsbIGiBASBSKksOvIDYKa2Wy8htPmWFTEOPRpFXdGQ27awcjjnB42nngyCK5ukZDHi6 w0qK5DNQQCkiweevCIC6wc3p67jl1EMFY5+z+zdTPb3h7LeVnGqW0qBQl99vVFgzLxchKcl0 R/paSFgwqXCZhAKMuUHncJuynDOP7z5LirUeFI8qsBAJi1rXpQoLJTVcW72swZ42IdPiboqx NbTMiNOiE36GqMcTPfKylCbF45JNX4nF9ElM0E+Y8gi4cizJYBRr2FBJgay0b9Cp Message-ID: Date: Mon, 2 Apr 2018 16:27:08 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <201712210917.vBL9Hmd0042736@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 13:27:18 -0000 On 21/12/2017 11:17, Bruce Evans wrote: > Author: bde > Date: Thu Dec 21 09:17:48 2017 > New Revision: 327056 > URL: https://svnweb.freebsd.org/changeset/base/327056 > > Log: > Use resume_cpus() instead of restart_cpus() to resume from ACPI suspension. Bruce, do you plan to merge this to stable/11 and maybe stable/10? If you'd like, I can do it. Unless you see any reason not to. > restart_cpus() worked well enough by accident. Before this set of fixes, > resume_cpus() used the same cpuset (started_cpus, meaning CPUs directed to > restart) as restart_cpus(). resume_cpus() waited for the wrong cpuset > (stopped_cpus) to become empty, but since mixtures of stopped and suspended > CPUs are not close to working, stopped_cpus must be empty when resuming so > the wait is null -- restart_cpus just allows the other CPUs to restart and > returns without waiting. > > Fix resume_cpus() to wait on a non-wrong cpuset for the ACPI case, and > add further kludges to try to keep it working for the XEN case. It > was only used for XEN. It waited on suspended_cpus. This works for > XEN. However, for ACPI, resuming is a 2-step process. ACPI has already > woken up the other CPUs and removed them from suspended_cpus. This > fix records the move by putting them in a new cpuset resuming_cpus. > Waiting on suspended_cpus would give the same null wait as waiting on > stopped_cpus. Wait on resuming_cpus instead. > > Add a cpuset toresume_cpus to map the CPUs being told to resume to keep > this separate from the cpuset started_cpus for mapping the CPUs being told > to restart. Mixtures of stopped and suspended/resuming CPUs are still far > from working. Describe new and some old cpusets in comments. > > Add further kludges to cpususpend_handler() to try to avoid breaking it > for XEN. XEN doesn't use resumectx(), so it doesn't use the second > return path for savectx(), and it goes from the suspended state directly > to the restarted state, while ACPI resume goes through the resuming state. > Enter the resuming state early for all cases so that resume_cpus can test > for being in this state and not have to worry about the intermediate > !suspended state for ACPI only. -- Andriy Gapon From owner-svn-src-head@freebsd.org Mon Apr 2 13:36:49 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 62543F59E04; Mon, 2 Apr 2018 13:36:49 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0ED737EBAF; Mon, 2 Apr 2018 13:36:49 +0000 (UTC) (envelope-from andrew@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 09D4616562; Mon, 2 Apr 2018 13:36:49 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w32DamaD066985; Mon, 2 Apr 2018 13:36:48 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w32Dam3m066984; Mon, 2 Apr 2018 13:36:48 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201804021336.w32Dam3m066984@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Mon, 2 Apr 2018 13:36:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331877 - head/sys/arm/arm X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: head/sys/arm/arm X-SVN-Commit-Revision: 331877 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 13:36:49 -0000 Author: andrew Date: Mon Apr 2 13:36:48 2018 New Revision: 331877 URL: https://svnweb.freebsd.org/changeset/base/331877 Log: Add the missing header for malloc(9). It was pulled in through header pollution that doesn't seem to exist in some configurations. Modified: head/sys/arm/arm/gic_acpi.c Modified: head/sys/arm/arm/gic_acpi.c ============================================================================== --- head/sys/arm/arm/gic_acpi.c Mon Apr 2 13:25:38 2018 (r331876) +++ head/sys/arm/arm/gic_acpi.c Mon Apr 2 13:36:48 2018 (r331877) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include From owner-svn-src-head@freebsd.org Mon Apr 2 13:45:24 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4FB2CF63C5E; Mon, 2 Apr 2018 13:45:24 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E76637F55A; Mon, 2 Apr 2018 13:45:23 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DE3D21670F; Mon, 2 Apr 2018 13:45:23 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w32DjNQG072553; Mon, 2 Apr 2018 13:45:23 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w32DjND9072550; Mon, 2 Apr 2018 13:45:23 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201804021345.w32DjND9072550@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Mon, 2 Apr 2018 13:45:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331878 - in head/sys: amd64/amd64 i386/i386 x86/x86 X-SVN-Group: head X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in head/sys: amd64/amd64 i386/i386 x86/x86 X-SVN-Commit-Revision: 331878 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 13:45:24 -0000 Author: avg Date: Mon Apr 2 13:45:23 2018 New Revision: 331878 URL: https://svnweb.freebsd.org/changeset/base/331878 Log: unify amd64 and i386 cpu_reset() in x86/cpu_machdep.c Because I didn't see any reason not too. I've been making some changes to the code and couldn't help but notice that the i386 and am64 code was nearly identical. MFC after: 17 days Modified: head/sys/amd64/amd64/vm_machdep.c head/sys/i386/i386/vm_machdep.c head/sys/x86/x86/cpu_machdep.c Modified: head/sys/amd64/amd64/vm_machdep.c ============================================================================== --- head/sys/amd64/amd64/vm_machdep.c Mon Apr 2 13:36:48 2018 (r331877) +++ head/sys/amd64/amd64/vm_machdep.c Mon Apr 2 13:45:23 2018 (r331878) @@ -84,13 +84,6 @@ __FBSDID("$FreeBSD$"); #include -static void cpu_reset_real(void); -#ifdef SMP -static void cpu_reset_proxy(void); -static u_int cpu_reset_proxyid; -static volatile u_int cpu_reset_proxy_active; -#endif - _Static_assert(OFFSETOF_CURTHREAD == offsetof(struct pcpu, pc_curthread), "OFFSETOF_CURTHREAD does not correspond with offset of pc_curthread."); _Static_assert(OFFSETOF_CURPCB == offsetof(struct pcpu, pc_curpcb), @@ -563,129 +556,6 @@ cpu_set_user_tls(struct thread *td, void *tls_base) #endif pcb->pcb_fsbase = (register_t)tls_base; return (0); -} - -#ifdef SMP -static void -cpu_reset_proxy() -{ - - cpu_reset_proxy_active = 1; - while (cpu_reset_proxy_active == 1) - ia32_pause(); /* Wait for other cpu to see that we've started */ - - printf("cpu_reset_proxy: Stopped CPU %d\n", cpu_reset_proxyid); - DELAY(1000000); - cpu_reset_real(); -} -#endif - -void -cpu_reset() -{ -#ifdef SMP - cpuset_t map; - u_int cnt; - - if (smp_started) { - map = all_cpus; - CPU_CLR(PCPU_GET(cpuid), &map); - CPU_NAND(&map, &stopped_cpus); - if (!CPU_EMPTY(&map)) { - printf("cpu_reset: Stopping other CPUs\n"); - stop_cpus(map); - } - - if (PCPU_GET(cpuid) != 0) { - cpu_reset_proxyid = PCPU_GET(cpuid); - cpustop_restartfunc = cpu_reset_proxy; - cpu_reset_proxy_active = 0; - printf("cpu_reset: Restarting BSP\n"); - - /* Restart CPU #0. */ - CPU_SETOF(0, &started_cpus); - wmb(); - - cnt = 0; - while (cpu_reset_proxy_active == 0 && cnt < 10000000) { - ia32_pause(); - cnt++; /* Wait for BSP to announce restart */ - } - if (cpu_reset_proxy_active == 0) { - printf("cpu_reset: Failed to restart BSP\n"); - } else { - cpu_reset_proxy_active = 2; - while (1) - ia32_pause(); - /* NOTREACHED */ - } - } - - DELAY(1000000); - } -#endif - cpu_reset_real(); - /* NOTREACHED */ -} - -static void -cpu_reset_real() -{ - struct region_descriptor null_idt; - int b; - - disable_intr(); - - /* - * Attempt to do a CPU reset via the keyboard controller, - * do not turn off GateA20, as any machine that fails - * to do the reset here would then end up in no man's land. - */ - outb(IO_KBD + 4, 0xFE); - DELAY(500000); /* wait 0.5 sec to see if that did it */ - - /* - * Attempt to force a reset via the Reset Control register at - * I/O port 0xcf9. Bit 2 forces a system reset when it - * transitions from 0 to 1. Bit 1 selects the type of reset - * to attempt: 0 selects a "soft" reset, and 1 selects a - * "hard" reset. We try a "hard" reset. The first write sets - * bit 1 to select a "hard" reset and clears bit 2. The - * second write forces a 0 -> 1 transition in bit 2 to trigger - * a reset. - */ - outb(0xcf9, 0x2); - outb(0xcf9, 0x6); - DELAY(500000); /* wait 0.5 sec to see if that did it */ - - /* - * Attempt to force a reset via the Fast A20 and Init register - * at I/O port 0x92. Bit 1 serves as an alternate A20 gate. - * Bit 0 asserts INIT# when set to 1. We are careful to only - * preserve bit 1 while setting bit 0. We also must clear bit - * 0 before setting it if it isn't already clear. - */ - b = inb(0x92); - if (b != 0xff) { - if ((b & 0x1) != 0) - outb(0x92, b & 0xfe); - outb(0x92, b | 0x1); - DELAY(500000); /* wait 0.5 sec to see if that did it */ - } - - printf("No known reset method worked, attempting CPU shutdown\n"); - DELAY(1000000); /* wait 1 sec for printf to complete */ - - /* Wipe the IDT. */ - null_idt.rd_limit = 0; - null_idt.rd_base = 0; - lidt(&null_idt); - - /* "good night, sweet prince .... " */ - breakpoint(); - - /* NOTREACHED */ - while(1); } /* Modified: head/sys/i386/i386/vm_machdep.c ============================================================================== --- head/sys/i386/i386/vm_machdep.c Mon Apr 2 13:36:48 2018 (r331877) +++ head/sys/i386/i386/vm_machdep.c Mon Apr 2 13:45:23 2018 (r331878) @@ -103,13 +103,6 @@ _Static_assert(OFFSETOF_CURPCB == offsetof(struct pcpu _Static_assert(__OFFSETOF_MONITORBUF == offsetof(struct pcpu, pc_monitorbuf), "__OFFSETOF_MONINORBUF does not correspond with offset of pc_monitorbuf."); -static void cpu_reset_real(void); -#ifdef SMP -static void cpu_reset_proxy(void); -static u_int cpu_reset_proxyid; -static volatile u_int cpu_reset_proxy_active; -#endif - union savefpu * get_pcb_user_save_td(struct thread *td) { @@ -575,141 +568,6 @@ kvtop(void *addr) if (pa == 0) panic("kvtop: zero page frame"); return (pa); -} - -#ifdef SMP -static void -cpu_reset_proxy() -{ - - cpu_reset_proxy_active = 1; - while (cpu_reset_proxy_active == 1) - ia32_pause(); /* Wait for other cpu to see that we've started */ - - printf("cpu_reset_proxy: Stopped CPU %d\n", cpu_reset_proxyid); - DELAY(1000000); - cpu_reset_real(); -} -#endif - -void -cpu_reset() -{ -#ifdef SMP - cpuset_t map; - u_int cnt; - - if (smp_started) { - map = all_cpus; - CPU_CLR(PCPU_GET(cpuid), &map); - CPU_NAND(&map, &stopped_cpus); - if (!CPU_EMPTY(&map)) { - printf("cpu_reset: Stopping other CPUs\n"); - stop_cpus(map); - } - - if (PCPU_GET(cpuid) != 0) { - cpu_reset_proxyid = PCPU_GET(cpuid); - cpustop_restartfunc = cpu_reset_proxy; - cpu_reset_proxy_active = 0; - printf("cpu_reset: Restarting BSP\n"); - - /* Restart CPU #0. */ - CPU_SETOF(0, &started_cpus); - wmb(); - - cnt = 0; - while (cpu_reset_proxy_active == 0 && cnt < 10000000) { - ia32_pause(); - cnt++; /* Wait for BSP to announce restart */ - } - if (cpu_reset_proxy_active == 0) { - printf("cpu_reset: Failed to restart BSP\n"); - } else { - cpu_reset_proxy_active = 2; - while (1) - ia32_pause(); - /* NOTREACHED */ - } - } - - DELAY(1000000); - } -#endif - cpu_reset_real(); - /* NOTREACHED */ -} - -static void -cpu_reset_real() -{ - struct region_descriptor null_idt; - int b; - - disable_intr(); -#ifdef CPU_ELAN - if (elan_mmcr != NULL) - elan_mmcr->RESCFG = 1; -#endif - - if (cpu == CPU_GEODE1100) { - /* Attempt Geode's own reset */ - outl(0xcf8, 0x80009044ul); - outl(0xcfc, 0xf); - } - -#if !defined(BROKEN_KEYBOARD_RESET) - /* - * Attempt to do a CPU reset via the keyboard controller, - * do not turn off GateA20, as any machine that fails - * to do the reset here would then end up in no man's land. - */ - outb(IO_KBD + 4, 0xFE); - DELAY(500000); /* wait 0.5 sec to see if that did it */ -#endif - - /* - * Attempt to force a reset via the Reset Control register at - * I/O port 0xcf9. Bit 2 forces a system reset when it - * transitions from 0 to 1. Bit 1 selects the type of reset - * to attempt: 0 selects a "soft" reset, and 1 selects a - * "hard" reset. We try a "hard" reset. The first write sets - * bit 1 to select a "hard" reset and clears bit 2. The - * second write forces a 0 -> 1 transition in bit 2 to trigger - * a reset. - */ - outb(0xcf9, 0x2); - outb(0xcf9, 0x6); - DELAY(500000); /* wait 0.5 sec to see if that did it */ - - /* - * Attempt to force a reset via the Fast A20 and Init register - * at I/O port 0x92. Bit 1 serves as an alternate A20 gate. - * Bit 0 asserts INIT# when set to 1. We are careful to only - * preserve bit 1 while setting bit 0. We also must clear bit - * 0 before setting it if it isn't already clear. - */ - b = inb(0x92); - if (b != 0xff) { - if ((b & 0x1) != 0) - outb(0x92, b & 0xfe); - outb(0x92, b | 0x1); - DELAY(500000); /* wait 0.5 sec to see if that did it */ - } - - printf("No known reset method worked, attempting CPU shutdown\n"); - DELAY(1000000); /* wait 1 sec for printf to complete */ - - /* Wipe the IDT. */ - null_idt.rd_limit = 0; - null_idt.rd_base = 0; - lidt(&null_idt); - - /* "good night, sweet prince .... " */ - breakpoint(); - - /* NOTREACHED */ - while(1); } /* Modified: head/sys/x86/x86/cpu_machdep.c ============================================================================== --- head/sys/x86/x86/cpu_machdep.c Mon Apr 2 13:36:48 2018 (r331877) +++ head/sys/x86/x86/cpu_machdep.c Mon Apr 2 13:45:23 2018 (r331878) @@ -96,10 +96,18 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #define STATE_RUNNING 0x0 #define STATE_MWAIT 0x1 #define STATE_SLEEPING 0x2 +#ifdef SMP +static u_int cpu_reset_proxyid; +static volatile u_int cpu_reset_proxy_active; +#endif + + /* * Machine dependent boot() routine * @@ -240,6 +248,141 @@ cpu_halt(void) { for (;;) halt(); +} + +static void +cpu_reset_real() +{ + struct region_descriptor null_idt; + int b; + + disable_intr(); +#ifdef CPU_ELAN + if (elan_mmcr != NULL) + elan_mmcr->RESCFG = 1; +#endif +#ifdef __i386__ + if (cpu == CPU_GEODE1100) { + /* Attempt Geode's own reset */ + outl(0xcf8, 0x80009044ul); + outl(0xcfc, 0xf); + } +#endif +#if !defined(BROKEN_KEYBOARD_RESET) + /* + * Attempt to do a CPU reset via the keyboard controller, + * do not turn off GateA20, as any machine that fails + * to do the reset here would then end up in no man's land. + */ + outb(IO_KBD + 4, 0xFE); + DELAY(500000); /* wait 0.5 sec to see if that did it */ +#endif + + /* + * Attempt to force a reset via the Reset Control register at + * I/O port 0xcf9. Bit 2 forces a system reset when it + * transitions from 0 to 1. Bit 1 selects the type of reset + * to attempt: 0 selects a "soft" reset, and 1 selects a + * "hard" reset. We try a "hard" reset. The first write sets + * bit 1 to select a "hard" reset and clears bit 2. The + * second write forces a 0 -> 1 transition in bit 2 to trigger + * a reset. + */ + outb(0xcf9, 0x2); + outb(0xcf9, 0x6); + DELAY(500000); /* wait 0.5 sec to see if that did it */ + + /* + * Attempt to force a reset via the Fast A20 and Init register + * at I/O port 0x92. Bit 1 serves as an alternate A20 gate. + * Bit 0 asserts INIT# when set to 1. We are careful to only + * preserve bit 1 while setting bit 0. We also must clear bit + * 0 before setting it if it isn't already clear. + */ + b = inb(0x92); + if (b != 0xff) { + if ((b & 0x1) != 0) + outb(0x92, b & 0xfe); + outb(0x92, b | 0x1); + DELAY(500000); /* wait 0.5 sec to see if that did it */ + } + + printf("No known reset method worked, attempting CPU shutdown\n"); + DELAY(1000000); /* wait 1 sec for printf to complete */ + + /* Wipe the IDT. */ + null_idt.rd_limit = 0; + null_idt.rd_base = 0; + lidt(&null_idt); + + /* "good night, sweet prince .... " */ + breakpoint(); + + /* NOTREACHED */ + while(1); +} + +#ifdef SMP +static void +cpu_reset_proxy() +{ + + cpu_reset_proxy_active = 1; + while (cpu_reset_proxy_active == 1) + ia32_pause(); /* Wait for other cpu to see that we've started */ + + printf("cpu_reset_proxy: Stopped CPU %d\n", cpu_reset_proxyid); + DELAY(1000000); + cpu_reset_real(); +} +#endif + +void +cpu_reset() +{ +#ifdef SMP + cpuset_t map; + u_int cnt; + + if (smp_started) { + map = all_cpus; + CPU_CLR(PCPU_GET(cpuid), &map); + CPU_NAND(&map, &stopped_cpus); + if (!CPU_EMPTY(&map)) { + printf("cpu_reset: Stopping other CPUs\n"); + stop_cpus(map); + } + + if (PCPU_GET(cpuid) != 0) { + cpu_reset_proxyid = PCPU_GET(cpuid); + cpustop_restartfunc = cpu_reset_proxy; + cpu_reset_proxy_active = 0; + printf("cpu_reset: Restarting BSP\n"); + + /* Restart CPU #0. */ + CPU_SETOF(0, &started_cpus); + wmb(); + + cnt = 0; + while (cpu_reset_proxy_active == 0 && cnt < 10000000) { + ia32_pause(); + cnt++; /* Wait for BSP to announce restart */ + } + if (cpu_reset_proxy_active == 0) { + printf("cpu_reset: Failed to restart BSP\n"); + } else { + cpu_reset_proxy_active = 2; + while (1) + ia32_pause(); + /* NOTREACHED */ + } + } + + DELAY(1000000); + } +#endif + cpu_reset_real(); + /* NOTREACHED */ } bool From owner-svn-src-head@freebsd.org Mon Apr 2 15:07:41 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB2B5F70654; Mon, 2 Apr 2018 15:07:41 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6B3E882592; Mon, 2 Apr 2018 15:07:41 +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 619741741E; Mon, 2 Apr 2018 15:07:41 +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 w32F7fqG013664; Mon, 2 Apr 2018 15:07:41 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w32F7fML013663; Mon, 2 Apr 2018 15:07:41 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201804021507.w32F7fML013663@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 2 Apr 2018 15:07:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331879 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 331879 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 15:07:41 -0000 Author: markj Date: Mon Apr 2 15:07:41 2018 New Revision: 331879 URL: https://svnweb.freebsd.org/changeset/base/331879 Log: Ensure the background laundering threshold is positive after a scan. The division added in r331732 meant that we wouldn't attempt a background laundering until at least v_free_target - v_free_min clean pages had been freed by the page daemon since the last laundering. If the inactive queue is depleted but not completely empty (e.g., because it contains busy pages), it can thus take a long time to meet this threshold. Restore the pre-r331732 behaviour of using a non-zero background laundering threshold if at least one inactive queue scan has elapsed since the last attempt at background laundering. Submitted by: tijl (original version) Modified: head/sys/vm/vm_pageout.c Modified: head/sys/vm/vm_pageout.c ============================================================================== --- head/sys/vm/vm_pageout.c Mon Apr 2 13:45:23 2018 (r331878) +++ head/sys/vm/vm_pageout.c Mon Apr 2 15:07:41 2018 (r331879) @@ -1015,14 +1015,16 @@ vm_pageout_laundry_worker(void *arg) * clean pages freed by the page daemon since the last * background laundering. Thus, as the ratio of dirty to * clean inactive pages grows, the amount of memory pressure - * required to trigger laundering decreases. + * required to trigger laundering decreases. We ensure + * that the threshold is non-zero after an inactive queue + * scan, even if that scan failed to free a single clean page. */ trybackground: nclean = vmd->vmd_free_count + vmd->vmd_pagequeues[PQ_INACTIVE].pq_cnt; ndirty = vmd->vmd_pagequeues[PQ_LAUNDRY].pq_cnt; - if (target == 0 && ndirty * isqrt(nfreed / - (vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) { + if (target == 0 && ndirty * isqrt(howmany(nfreed + 1, + vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) { target = vmd->vmd_background_launder_target; } From owner-svn-src-head@freebsd.org Mon Apr 2 15:19:36 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DD04FF71318; Mon, 2 Apr 2018 15:19:36 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 87FE782D55; Mon, 2 Apr 2018 15:19:36 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id 65CE05A9F17; Mon, 2 Apr 2018 15:19:35 +0000 (UTC) Date: Mon, 2 Apr 2018 15:19:35 +0000 From: Brooks Davis To: Ian Lepore Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331869 - head/sys/dev/nxge Message-ID: <20180402151935.GB88994@spindle.one-eyed-alien.net> References: <201804011853.w31IrR5X003323@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="WYTEVAkct0FjGQmd" Content-Disposition: inline In-Reply-To: <201804011853.w31IrR5X003323@repo.freebsd.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 15:19:37 -0000 --WYTEVAkct0FjGQmd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Apr 01, 2018 at 06:53:27PM +0000, Ian Lepore wrote: > Author: ian > Date: Sun Apr 1 18:53:27 2018 > New Revision: 331869 > URL: https://svnweb.freebsd.org/changeset/base/331869 >=20 > Log: > Fix the build on arches with default unsigned char. Capture the fubyte= () > return value in an int as well as the char, and test the full int value > for fubyte() failure. Thanks for fixing this and sorry for the breakage. -- Brooks --WYTEVAkct0FjGQmd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJawkoGAAoJEKzQXbSebgfAnSYH/3AyQPfke/1CGK9WjvnBErtg aDp6SaMpNvPL6W1XBczQgOznqkFTwEbKkjKiEFk/VIoUC/pWoRyQj9hYueVy81eV 4bUXw7JqS6M8MSTJoJ/tVyWfXzm0qZKfOK1u3AnaFPgMoFFfhkgI1b9p7mK/RXzf Y9AzLRtV0rUYHTJsM0OrXBuMovAqGDg7iPHCGL/0YOJmbR6LEEC0vIFjVuMDE2Wu SlZ8aUCLlfVRata7Nj1qsSIUezLxzq7mM6SsPu7FoSnJL+TVDoP1qUPl6RIEy6Be +lZPh5lCjlcSX7R3B6pJoS7/KsCjDpiyzkZ3MeWzDr76pAyFNbE0aMad6Qie0mg= =XNCZ -----END PGP SIGNATURE----- --WYTEVAkct0FjGQmd-- From owner-svn-src-head@freebsd.org Mon Apr 2 15:29:01 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 572EDF71D13; Mon, 2 Apr 2018 15:29:01 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail106.syd.optusnet.com.au (mail106.syd.optusnet.com.au [211.29.132.42]) by mx1.freebsd.org (Postfix) with ESMTP id BF8278350D; Mon, 2 Apr 2018 15:29:00 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail106.syd.optusnet.com.au (Postfix) with ESMTPS id F2D143D4875; Tue, 3 Apr 2018 01:28:52 +1000 (AEST) Date: Tue, 3 Apr 2018 01:28:52 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Andriy Gapon cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r327056 - in head/sys: kern sys x86/acpica x86/x86 In-Reply-To: Message-ID: <20180403012043.K1434@besplex.bde.org> References: <201712210917.vBL9Hmd0042736@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=cIaQihWN c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=8vpKE69ueMNQcOfTwboA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 15:29:01 -0000 On Mon, 2 Apr 2018, Andriy Gapon wrote: > On 21/12/2017 11:17, Bruce Evans wrote: >> Author: bde >> Date: Thu Dec 21 09:17:48 2017 >> New Revision: 327056 >> URL: https://svnweb.freebsd.org/changeset/base/327056 >> >> Log: >> Use resume_cpus() instead of restart_cpus() to resume from ACPI suspension. > > Bruce, > > do you plan to merge this to stable/11 and maybe stable/10? No. I'm nit (yet?) set up to merge to stable at all, and this is not the first thing that I would want to merge. > If you'd like, I can do it. Unless you see any reason not to. Please do it. It is only a small part of fixing mapping bugs for low memory which first showed up s incoherent page tables for vm86 (low memory was left unmapped all the time to handle the problem that ACPI resume needs this mapping for 1 instruction). You might need the other fixes. This one is fairly stand- alone but doesn't do much by itself. Bruce From owner-svn-src-head@freebsd.org Mon Apr 2 15:32:10 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 681B4F72100; Mon, 2 Apr 2018 15:32:10 +0000 (UTC) (envelope-from byond.lenox@gmail.com) Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D64E983849; Mon, 2 Apr 2018 15:32:09 +0000 (UTC) (envelope-from byond.lenox@gmail.com) Received: by mail-wm0-f52.google.com with SMTP id f125so27914708wme.4; Mon, 02 Apr 2018 08:32:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=OMw/8RGOC7zxvJ2qSebkBUH2bocg/Q4UT7eXnv7aAz0=; b=epk/R8lS9bY9QVDrJHNk/u3CErdsnvJ1mQGQZkoPAambuxgHguQ+BQGtVmwZvfe2Wa R7DBYtHZJu21IpG3gkSF5WuOTkX7w9sFZOY2lXSBr07m087Y45vGR4m/FzZ22m/zNFXW +semmkxb9yrT3zZAvSCyyAf3u0Aw9ihscz3TNB0Y5P3zVZqyx7ckiHdcsOOqh4V7Z7NZ uXtzqyz6O99nYS9hqbUhXqftV5wBUvNNaYuWpVypI/BJwKqVAdwrb3HXTm9osEYECM+c s3apoL/wR6nJAr/G0qj1yZIJzM8FP5qDE+E0CwqJxb7rJlfFcnpdy0WD/5yV6X/EPgsM RSGg== X-Gm-Message-State: AElRT7EOTNtOgpJzxRtWHTJqu6q78mYE11cqStWFCSouMXchC/sagZeK 8BMx+cbQYvQqLLEAjfmQybpNA2gA X-Google-Smtp-Source: AIpwx49mhuMrxd3IZrYQYPWky8tM3wHRmZXe/+HbrB35+S88qwbHWnQhd5irfsogTxLi9OYdjX4PZA== X-Received: by 10.80.147.89 with SMTP id n25mr13212880eda.189.1522683128539; Mon, 02 Apr 2018 08:32:08 -0700 (PDT) Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com. [74.125.82.53]) by smtp.gmail.com with ESMTPSA id w4sm445920edh.56.2018.04.02.08.32.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Apr 2018 08:32:08 -0700 (PDT) Received: by mail-wm0-f53.google.com with SMTP id i3so4165569wmf.3; Mon, 02 Apr 2018 08:32:08 -0700 (PDT) X-Received: by 10.46.29.1 with SMTP id d1mr6139342ljd.22.1522683128138; Mon, 02 Apr 2018 08:32:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.46.129.90 with HTTP; Mon, 2 Apr 2018 08:31:47 -0700 (PDT) In-Reply-To: <201801241415.w0OEF6vr052976@repo.freebsd.org> References: <201801241415.w0OEF6vr052976@repo.freebsd.org> From: Kyle Evans Date: Mon, 2 Apr 2018 10:31:47 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r328331 - head/etc To: Dmitry Marakasov Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org, 0mp@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 15:32:10 -0000 On Wed, Jan 24, 2018 at 8:15 AM, Dmitry Marakasov wrote: > Author: amdmi3 (ports committer) > Date: Wed Jan 24 14:15:06 2018 > New Revision: 328331 > URL: https://svnweb.freebsd.org/changeset/base/328331 > > Log: > Support configuring arbitrary limits(1) for any daemon in rc.conf > > Usage is ${name}_limits, and the argument is any flags accepted by > limits(1), such as `-n 100' (e.g. only allow 100 open files). > > Approved by: cy > Differential Revision: https://reviews.freebsd.org/D14015 > > Modified: > head/etc/rc.subr > > Modified: head/etc/rc.subr To answer a question you've posed in the Diff. Review, I've MFC'd this to stable/11 as r331880. 0mp@ is working on an effort to correct some leftover ${name}_limits usage in ports that leads to wrong behavior as a result of this commit. Any chance you could help him out with that? Thanks, Kyle Evans From owner-svn-src-head@freebsd.org Mon Apr 2 21:33:17 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E038AF86994; Mon, 2 Apr 2018 21:33:16 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8FB1173493; Mon, 2 Apr 2018 21:33:16 +0000 (UTC) (envelope-from trasz@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 8A4C61B30A; Mon, 2 Apr 2018 21:33:16 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w32LXGnB013075; Mon, 2 Apr 2018 21:33:16 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w32LXGww013074; Mon, 2 Apr 2018 21:33:16 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201804022133.w32LXGww013074@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Mon, 2 Apr 2018 21:33:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331887 - head/share/man/man7 X-SVN-Group: head X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: head/share/man/man7 X-SVN-Commit-Revision: 331887 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 21:33:17 -0000 Author: trasz Date: Mon Apr 2 21:33:16 2018 New Revision: 331887 URL: https://svnweb.freebsd.org/changeset/base/331887 Log: Bring some order to horizontal and vertical spacing in hier(7). MFC after: 2 weeks Modified: head/share/man/man7/hier.7 Modified: head/share/man/man7/hier.7 ============================================================================== --- head/share/man/man7/hier.7 Mon Apr 2 20:54:33 2018 (r331886) +++ head/share/man/man7/hier.7 Mon Apr 2 21:33:16 2018 (r331887) @@ -28,7 +28,7 @@ .\" @(#)hier.7 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd January 27, 2018 +.Dd April 2, 2018 .Dt HIER 7 .Os .Sh NAME @@ -84,7 +84,7 @@ comments apply device special files managed by .Xr devfs 5 .Pp -.Bl -tag -width "net/" -compact +.Bl -tag -width "defaults/" -compact .It Pa fd/ file descriptor files; see @@ -93,7 +93,7 @@ see .It Pa /etc/ system configuration files and scripts .Pp -.Bl -tag -width "bluetooth/" -compact +.Bl -tag -width "defaults/" -compact .It Pa defaults/ default system configuration files; see @@ -143,7 +143,7 @@ critical system libraries needed for binaries in and .Pa /sbin .Pp -.Bl -tag -width "geom/" -compact +.Bl -tag -width "defaults/" -compact .It Pa geom/ class-specific libraries for the .Xr geom 8 @@ -183,7 +183,7 @@ temporary files that are not guaranteed to persist acr .It Pa /usr/ contains the majority of user utilities and applications .Pp -.Bl -tag -width "libdata/" -compact +.Bl -tag -width "defaults/" -compact .It Pa bin/ common utilities, programming tools, and applications .It Pa compat/ @@ -264,7 +264,6 @@ RAID3 GEOM class .It Pa stripe/ STRIPE GEOM class .El -.Pp .It Pa libmilter/ C include files for libmilter, the @@ -274,7 +273,7 @@ mail filter API machine-specific C include files .It Pa net/ miscellaneous network C include files -.Bl -tag -width "altq/" -compact +.Bl -tag -width Fl -compact .It Pa altq/ C include files for alternate queueing .El @@ -342,6 +341,7 @@ see shared and archive .Xr ar 1 Ns -type libraries +.Pp .Bl -tag -width Fl -compact .It Pa aout/ a.out archive libraries @@ -361,6 +361,7 @@ OpenSSL (Cryptography/SSL toolkit) dynamically loadabl .Pp .It Pa libdata/ miscellaneous utility data files +.Pp .Bl -tag -width Fl -compact .It Pa gcc/ .Xr gcc 1 @@ -373,6 +374,7 @@ see .Pp .It Pa libexec/ system daemons & system utilities (executed by other programs) +.Pp .Bl -tag -width Fl -compact .It Pa aout/ utilities to manipulate a.out executables @@ -435,7 +437,7 @@ system daemons & system utilities (executed by users) .It Pa share/ architecture-independent files .Pp -.Bl -tag -width "calendar/" -compact +.Bl -tag -width Fl -compact .It Pa calendar/ a variety of pre-fab calendar files; see @@ -444,7 +446,6 @@ see word lists; see .Xr look 1 -.Pp .Bl -tag -width Fl -compact .It Pa freebsd .Fx Ns -specific @@ -452,7 +453,6 @@ terms, proper names, and jargon .It Pa web2 words from Webster's 2nd International .El -.Pp .It Pa doc/ miscellaneous documentation; source for most of the printed @@ -489,7 +489,6 @@ tutorials .It Pa zh/ Chinese translations of documents in /usr/share/doc .El -.Pp .It Pa examples/ various examples for users and programmers .It Pa firmware/ @@ -498,14 +497,13 @@ firmware images loaded by userland programs ASCII text files used by various games .It Pa keys/ known trusted and revoked keys. -.Bl -tag -width "pkg/" -compact +.Bl -tag -width Fl -compact .It Pa pkg/ fingerprints for .Xr pkg 7 and .Xr pkg 8 .El -.Pp .It Pa locale/ localization files; see @@ -553,7 +551,7 @@ MIB files files used by syscons; see .Xr syscons 4 -.Bl -tag -width "scrnmaps/" -compact +.Bl -tag -width Fl -compact .It Pa fonts/ console fonts; see @@ -581,7 +579,7 @@ localization support and utilities for files used by vt; see .Xr vt 4 -.Bl -tag -width "scrnmaps/" -compact +.Bl -tag -width Fl -compact .It Pa fonts/ console fonts; see @@ -602,6 +600,7 @@ timezone configuration information; see .Xr tzfile 5 .El +.Pp .It Pa src/ .Bx , third-party, and/or local source files @@ -653,7 +652,7 @@ source for files in boot loader source code .It Pa sys/ kernel source code -.Bl -tag -width "opencrypto/" -compact +.Bl -tag -width Fl -compact .It Pa amd64/ AMD64 architecture support .It Pa arm/ @@ -741,7 +740,7 @@ for more details. .It Pa /var/ multi-purpose log, temporary, transient, and spool files .Pp -.Bl -tag -width "preserve/" -compact +.Bl -tag -width "defaults/" -compact .It Pa account/ system accounting files .Pp @@ -756,7 +755,8 @@ see timed command scheduling files; see .Xr \&at 1 -.Bl -tag -width "preserve/" -compact +.Pp +.Bl -tag -width Fl -compact .It Pa jobs/ directory containing job files .It Pa spool/ @@ -767,7 +767,8 @@ directory containing output spool files miscellaneous backup files .It Pa cache/ miscellaneous cached files -.Bl -tag -width "pkg/" -compact +.Pp +.Bl -tag -width Fl -compact .It Pa pkg/ cached packages for .Xr pkg 8 @@ -782,7 +783,8 @@ and files used by cron; see .Xr cron 8 -.Bl -tag -width "preserve/" -compact +.Pp +.Bl -tag -width Fl -compact .It Pa tabs/ crontab files; see @@ -871,10 +873,12 @@ line printer spooling directories .Pp .It Pa tmp/ temporary files that are kept between system reboots +.Pp .Bl -tag -width Fl -compact .It Pa vi.recover/ the directory where recovery files are stored .El +.Pp .It Pa yp/ the NIS maps .El From owner-svn-src-head@freebsd.org Mon Apr 2 21:38:23 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C31BDF86EFE; Mon, 2 Apr 2018 21:38:23 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id D271A73854; Mon, 2 Apr 2018 21:38:22 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id w32La4S6046487 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 2 Apr 2018 14:36:04 -0700 (PDT) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id w32La4uN046486; Mon, 2 Apr 2018 14:36:04 -0700 (PDT) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Mon, 2 Apr 2018 14:36:04 -0700 From: Gleb Smirnoff To: Alexander Motin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331414 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys Message-ID: <20180402213604.GC1917@FreeBSD.org> References: <201803230250.w2N2odbi085924@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201803230250.w2N2odbi085924@repo.freebsd.org> User-Agent: Mutt/1.9.3 (2018-01-21) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 21:38:23 -0000 Alexander, Does it make sense to leave the manual padding at all, if you got compiler hint __aligned(CACHE_LINE_SIZE)? With manual padding can get broken again later. On Fri, Mar 23, 2018 at 02:50:39AM +0000, Alexander Motin wrote: A> Author: mav A> Date: Fri Mar 23 02:50:38 2018 A> New Revision: 331414 A> URL: https://svnweb.freebsd.org/changeset/base/331414 A> A> Log: A> Reduce struct aggsum_bucket padding to fit into one cache line. A> A> Reported by: mjg A> A> Modified: A> head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.h A> A> Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.h A> ============================================================================== A> --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.h Fri Mar 23 02:45:09 2018 (r331413) A> +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.h Fri Mar 23 02:50:38 2018 (r331414) A> @@ -29,7 +29,7 @@ typedef struct aggsum_bucket { A> kmutex_t asc_lock; A> int64_t asc_delta; A> uint64_t asc_borrowed; A> - uint64_t asc_pad[4]; /* pad out to cache line (64 bytes) */ A> + uint64_t asc_pad[2]; /* pad out to cache line (64 bytes) */ A> } aggsum_bucket_t __aligned(CACHE_LINE_SIZE); A> A> /* A> -- Gleb Smirnoff From owner-svn-src-head@freebsd.org Mon Apr 2 22:04:32 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C19DEF4FAEF; Mon, 2 Apr 2018 22:04:32 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4AC8B74D1F; Mon, 2 Apr 2018 22:04:32 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id w32M4UYr046670 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 2 Apr 2018 15:04:30 -0700 (PDT) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id w32M4UDI046669; Mon, 2 Apr 2018 15:04:30 -0700 (PDT) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Mon, 2 Apr 2018 15:04:30 -0700 From: Gleb Smirnoff To: Kristof Provost Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331546 - head/etc/rc.d Message-ID: <20180402220430.GD1917@FreeBSD.org> References: <201803260936.w2Q9aMfD082758@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201803260936.w2Q9aMfD082758@repo.freebsd.org> User-Agent: Mutt/1.9.3 (2018-01-21) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 22:04:32 -0000 Kristof, I just want to note that this is a huge change of behaviour of pf(4) for a user. Over a decade everybody has been used to the difference between "reload" and "resync". Yes, I admit that back in 2008 the difference was awkward and annoying, but todays I'm afraid that change would be more annoying than keeping status quo. This definitely shouldn't reach stable/11, absolutely. I won't argue about keeping it in head, and thus in 12.0. You are pf maintainer now and you know better. You take the risk of explaining the change to users :) On Mon, Mar 26, 2018 at 09:36:22AM +0000, Kristof Provost wrote: K> Author: kp K> Date: Mon Mar 26 09:36:22 2018 K> New Revision: 331546 K> URL: https://svnweb.freebsd.org/changeset/base/331546 K> K> Log: K> pf: reload and resync do the same thing K> K> The reload and resync commands for the startup script do exactly the same K> thing, so implement one as a call to the other. K> K> MFC after: 3 weeks K> K> Modified: K> head/etc/rc.d/pf K> K> Modified: head/etc/rc.d/pf K> ============================================================================== K> --- head/etc/rc.d/pf Mon Mar 26 09:07:16 2018 (r331545) K> +++ head/etc/rc.d/pf Mon Mar 26 09:36:22 2018 (r331546) K> @@ -53,12 +53,12 @@ pf_check() K> pf_reload() K> { K> echo "Reloading pf rules." K> - $pf_program -n -f "$pf_rules" $pf_flags || return 1 K> - $pf_program -f "$pf_rules" $pf_flags K> + pf_resync K> } K> K> pf_resync() K> { K> + $pf_program -n -f "$pf_rules" $pf_flags || return 1 K> $pf_program -f "$pf_rules" $pf_flags K> } K> K> -- Gleb Smirnoff From owner-svn-src-head@freebsd.org Mon Apr 2 22:59:34 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A863AF59C9D; Mon, 2 Apr 2018 22:59:34 +0000 (UTC) (envelope-from bjk@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5C7687737D; Mon, 2 Apr 2018 22:59:34 +0000 (UTC) (envelope-from bjk@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 51E741C01B; Mon, 2 Apr 2018 22:59:34 +0000 (UTC) (envelope-from bjk@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w32MxYj9052847; Mon, 2 Apr 2018 22:59:34 GMT (envelope-from bjk@FreeBSD.org) Received: (from bjk@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w32MxYCb052846; Mon, 2 Apr 2018 22:59:34 GMT (envelope-from bjk@FreeBSD.org) Message-Id: <201804022259.w32MxYCb052846@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bjk set sender to bjk@FreeBSD.org using -f From: Benjamin Kaduk Date: Mon, 2 Apr 2018 22:59:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331892 - head/share/man/man4 X-SVN-Group: head X-SVN-Commit-Author: bjk X-SVN-Commit-Paths: head/share/man/man4 X-SVN-Commit-Revision: 331892 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 22:59:34 -0000 Author: bjk (doc committer) Date: Mon Apr 2 22:59:33 2018 New Revision: 331892 URL: https://svnweb.freebsd.org/changeset/base/331892 Log: Fix formatting in snd_hda.4 Submitted by: 0mp Reviewed by: skreuzer Differential Revision: https://reviews.freebsd.org/D14922 Modified: head/share/man/man4/snd_hda.4 Modified: head/share/man/man4/snd_hda.4 ============================================================================== --- head/share/man/man4/snd_hda.4 Mon Apr 2 22:16:19 2018 (r331891) +++ head/share/man/man4/snd_hda.4 Mon Apr 2 22:59:33 2018 (r331892) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 25, 2012 +.Dd April 1, 2018 .Dt SND_HDA 4 .Os .Sh NAME @@ -564,7 +564,7 @@ input mix first external or second internal microphone input .It Va monitor first internal or second external microphone input -.It Va line , Va line1 , Va line2, Va line3 +.It Va line , Va line1 , Va line2 , Va line3 analog (line) inputs .It Va dig1 , Va dig2 , Va dig3 digital (S/PDIF, HDMI or DisplayPort) inputs @@ -572,7 +572,7 @@ digital (S/PDIF, HDMI or DisplayPort) inputs CD input .It Va speaker PC speaker input -.It Va phin , Va phout , Va radio . Va video +.It Va phin , Va phout , Va radio , Va video other random inputs .El .Pp From owner-svn-src-head@freebsd.org Mon Apr 2 23:40:53 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 335E4F6D87E; Mon, 2 Apr 2018 23:40:53 +0000 (UTC) (envelope-from cognet@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D0BF67909E; Mon, 2 Apr 2018 23:40:52 +0000 (UTC) (envelope-from cognet@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 CA6681C69F; Mon, 2 Apr 2018 23:40:52 +0000 (UTC) (envelope-from cognet@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w32NeqE7015681; Mon, 2 Apr 2018 23:40:52 GMT (envelope-from cognet@FreeBSD.org) Received: (from cognet@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w32Neo60014397; Mon, 2 Apr 2018 23:40:50 GMT (envelope-from cognet@FreeBSD.org) Message-Id: <201804022340.w32Neo60014397@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cognet set sender to cognet@FreeBSD.org using -f From: Olivier Houchard Date: Mon, 2 Apr 2018 23:40:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331898 - in head/sys/contrib/ck: . include include/gcc include/gcc/sparcv9 include/gcc/x86 include/gcc/x86_64 include/spinlock src X-SVN-Group: head X-SVN-Commit-Author: cognet X-SVN-Commit-Paths: in head/sys/contrib/ck: . include include/gcc include/gcc/sparcv9 include/gcc/x86 include/gcc/x86_64 include/spinlock src X-SVN-Commit-Revision: 331898 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2018 23:40:53 -0000 Author: cognet Date: Mon Apr 2 23:40:50 2018 New Revision: 331898 URL: https://svnweb.freebsd.org/changeset/base/331898 Log: Import CK as of commit b19ed4c6a56ec93215ab567ba18ba61bf1cfbac8 It should fix ck_pr_[load|store]_ptr on mips and riscv, make sure no *fence instructions are used on i386, as older cpus don't support it, and make sure we don't rely on gcc builtins that can lead to calls to libatomic when linked with -O0. MFC after: 1 week Modified: head/sys/contrib/ck/FREEBSD-Xlist head/sys/contrib/ck/include/ck_cc.h head/sys/contrib/ck/include/ck_hs.h head/sys/contrib/ck/include/ck_md.h head/sys/contrib/ck/include/ck_pr.h head/sys/contrib/ck/include/ck_queue.h head/sys/contrib/ck/include/ck_ring.h head/sys/contrib/ck/include/gcc/ck_cc.h head/sys/contrib/ck/include/gcc/ck_pr.h head/sys/contrib/ck/include/gcc/sparcv9/ck_pr.h head/sys/contrib/ck/include/gcc/x86/ck_pr.h head/sys/contrib/ck/include/gcc/x86_64/ck_pr.h head/sys/contrib/ck/include/spinlock/dec.h head/sys/contrib/ck/src/ck_hs.c head/sys/contrib/ck/src/ck_ht.c head/sys/contrib/ck/src/ck_ht_hash.h head/sys/contrib/ck/src/ck_internal.h head/sys/contrib/ck/src/ck_rhs.c Directory Properties: head/sys/contrib/ck/ (props changed) Modified: head/sys/contrib/ck/FREEBSD-Xlist ============================================================================== --- head/sys/contrib/ck/FREEBSD-Xlist Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/FREEBSD-Xlist Mon Apr 2 23:40:50 2018 (r331898) @@ -8,4 +8,5 @@ */regressions */tools */include/ck_md.h.in +*/include/freebsd/ck_md.h.in */src/Makefile.in Modified: head/sys/contrib/ck/include/ck_cc.h ============================================================================== --- head/sys/contrib/ck/include/ck_cc.h Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/include/ck_cc.h Mon Apr 2 23:40:50 2018 (r331898) @@ -104,42 +104,36 @@ #define CK_CC_TYPEOF(X, DEFAULT) (DEFAULT) #endif +#define CK_F_CC_FFS_G(L, T) \ +CK_CC_INLINE static int \ +ck_cc_##L(T v) \ +{ \ + unsigned int i; \ + \ + if (v == 0) \ + return 0; \ + \ + for (i = 1; (v & 1) == 0; i++, v >>= 1); \ + return i; \ +} + #ifndef CK_F_CC_FFS #define CK_F_CC_FFS -CK_CC_INLINE static int -ck_cc_ffs(unsigned int x) -{ - unsigned int i; +CK_F_CC_FFS_G(ffs, unsigned int) +#endif /* CK_F_CC_FFS */ - if (x == 0) - return 0; +#ifndef CK_F_CC_FFSL +#define CK_F_CC_FFSL +CK_F_CC_FFS_G(ffsl, unsigned long) +#endif /* CK_F_CC_FFSL */ - for (i = 1; (x & 1) == 0; i++, x >>= 1); +#ifndef CK_F_CC_FFSLL +#define CK_F_CC_FFSLL +CK_F_CC_FFS_G(ffsll, unsigned long long) +#endif /* CK_F_CC_FFSLL */ - return i; -} -#endif +#undef CK_F_CC_FFS_G -#ifndef CK_F_CC_CLZ -#define CK_F_CC_CLZ -#include - -CK_CC_INLINE static int -ck_cc_clz(unsigned int x) -{ - unsigned int count, i; - - for (count = 0, i = sizeof(unsigned int) * CHAR_BIT; i > 0; count++) { - unsigned int bit = 1U << --i; - - if (x & bit) - break; - } - - return count; -} -#endif - #ifndef CK_F_CC_CTZ #define CK_F_CC_CTZ CK_CC_INLINE static int @@ -151,7 +145,6 @@ ck_cc_ctz(unsigned int x) return 0; for (i = 0; (x & 1) == 0; i++, x >>= 1); - return i; } #endif Modified: head/sys/contrib/ck/include/ck_hs.h ============================================================================== --- head/sys/contrib/ck/include/ck_hs.h Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/include/ck_hs.h Mon Apr 2 23:40:50 2018 (r331898) @@ -100,10 +100,11 @@ struct ck_hs_stat { struct ck_hs_iterator { void **cursor; unsigned long offset; + struct ck_hs_map *map; }; typedef struct ck_hs_iterator ck_hs_iterator_t; -#define CK_HS_ITERATOR_INITIALIZER { NULL, 0 } +#define CK_HS_ITERATOR_INITIALIZER { NULL, 0, NULL } /* Convenience wrapper to table hash function. */ #define CK_HS_HASH(T, F, K) F((K), (T)->seed) @@ -112,6 +113,7 @@ typedef void *ck_hs_apply_fn_t(void *, void *); bool ck_hs_apply(ck_hs_t *, unsigned long, const void *, ck_hs_apply_fn_t *, void *); void ck_hs_iterator_init(ck_hs_iterator_t *); bool ck_hs_next(ck_hs_t *, ck_hs_iterator_t *, void **); +bool ck_hs_next_spmc(ck_hs_t *, ck_hs_iterator_t *, void **); bool ck_hs_move(ck_hs_t *, ck_hs_t *, ck_hs_hash_cb_t *, ck_hs_compare_cb_t *, struct ck_malloc *); bool ck_hs_init(ck_hs_t *, unsigned int, ck_hs_hash_cb_t *, Modified: head/sys/contrib/ck/include/ck_md.h ============================================================================== --- head/sys/contrib/ck/include/ck_md.h Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/include/ck_md.h Mon Apr 2 23:40:50 2018 (r331898) @@ -1,5 +1,5 @@ /* - * Copyright 2011-2012 Samy Al Bahra. + * Copyright 2018 Samy Al Bahra. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -23,45 +23,95 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD: head/sys/contrib/ck/include/ck_md.h 329388 2018-02-16 17:50:06Z cog +net $ */ +/* + * This header file is meant for use of Concurrency Kit in the FreeBSD kernel. + */ + #ifndef CK_MD_H #define CK_MD_H +#include + +#ifndef _KERNEL +#error This header file is meant for the FreeBSD kernel. +#endif /* _KERNEL */ + #ifndef CK_MD_CACHELINE +/* + * FreeBSD's CACHE_LINE macro is a compile-time maximum cache-line size for an + * architecture, defined to be 128 bytes by default on x86*. Even in presence + * of adjacent sector prefetch, this doesn't make sense from a modeling + * perspective. + */ +#if defined(__amd64__) || defined(__i386__) #define CK_MD_CACHELINE (64) -#endif +#else +#define CK_MD_CACHELINE (CACHE_LINE_SIZE) +#endif /* !__amd64__ && !__i386__ */ +#endif /* CK_MD_CACHELINE */ #ifndef CK_MD_PAGESIZE -#define CK_MD_PAGESIZE (4096) +#define CK_MD_PAGESIZE (PAGE_SIZE) #endif +/* + * Once FreeBSD has a mechanism to detect RTM, this can be enabled and RTM + * facilities can be called. These facilities refer to TSX. + */ #ifndef CK_MD_RTM_DISABLE #define CK_MD_RTM_DISABLE #endif /* CK_MD_RTM_DISABLE */ +/* + * Do not enable pointer-packing-related (VMA) optimizations in kernel-space. + */ #ifndef CK_MD_POINTER_PACK_DISABLE #define CK_MD_POINTER_PACK_DISABLE #endif /* CK_MD_POINTER_PACK_DISABLE */ -#ifndef CK_MD_VMA_BITS_UNKNOWN -#define CK_MD_VMA_BITS_UNKNOWN +/* + * The following would be used for pointer-packing tricks, disabled for the + * kernel. + */ +#ifndef CK_MD_VMA_BITS_UNKNOWN +#define CK_MD_VMA_BITS_UNKNOWN #endif /* CK_MD_VMA_BITS_UNKNOWN */ +/* + * Do not enable double operations in kernel-space. + */ #ifndef CK_PR_DISABLE_DOUBLE #define CK_PR_DISABLE_DOUBLE #endif /* CK_PR_DISABLE_DOUBLE */ -#define CK_VERSION "0.6.0" -#define CK_GIT_SHA "" +/* + * If building for a uni-processor target, then enable the uniprocessor + * feature flag. This, among other things, will remove the lock prefix. + */ +#ifndef SMP +#define CK_MD_UMP +#endif /* SMP */ /* + * Disable the use of compiler builtin functions. + */ +#define CK_MD_CC_BUILTIN_DISABLE 1 + +/* * CK expects those, which are normally defined by the build system. */ #if defined(__i386__) && !defined(__x86__) #define __x86__ +/* + * If x86 becomes more relevant, we may want to consider importing in + * __mbk() to avoid potential issues around false sharing. + */ #define CK_MD_TSO +#define CK_MD_SSE_DISABLE 1 #elif defined(__amd64__) #define CK_MD_TSO #elif defined(__sparc64__) && !defined(__sparcv9__) @@ -73,8 +123,12 @@ #define __ppc__ #endif +/* If no memory model has been defined, assume RMO. */ #if !defined(CK_MD_RMO) && !defined(CK_MD_TSO) && !defined(CK_MD_PSO) #define CK_MD_RMO #endif + +#define CK_VERSION "0.7.0" +#define CK_GIT_SHA "db5db44" #endif /* CK_MD_H */ Modified: head/sys/contrib/ck/include/ck_pr.h ============================================================================== --- head/sys/contrib/ck/include/ck_pr.h Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/include/ck_pr.h Mon Apr 2 23:40:50 2018 (r331898) @@ -43,6 +43,8 @@ #include "gcc/sparcv9/ck_pr.h" #elif defined(__ppc64__) #include "gcc/ppc64/ck_pr.h" +#elif defined(__s390x__) +#include "gcc/s390x/ck_pr.h" #elif defined(__ppc__) #include "gcc/ppc/ck_pr.h" #elif defined(__arm__) Modified: head/sys/contrib/ck/include/ck_queue.h ============================================================================== --- head/sys/contrib/ck/include/ck_queue.h Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/include/ck_queue.h Mon Apr 2 23:40:50 2018 (r331898) @@ -235,7 +235,7 @@ struct { \ * Singly-linked Tail queue functions. */ #define CK_STAILQ_CONCAT(head1, head2) do { \ - if ((head2)->stqh_first == NULL) { \ + if ((head2)->stqh_first != NULL) { \ ck_pr_store_ptr((head1)->stqh_last, (head2)->stqh_first); \ ck_pr_fence_store(); \ (head1)->stqh_last = (head2)->stqh_last; \ Modified: head/sys/contrib/ck/include/ck_ring.h ============================================================================== --- head/sys/contrib/ck/include/ck_ring.h Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/include/ck_ring.h Mon Apr 2 23:40:50 2018 (r331898) @@ -176,23 +176,54 @@ _ck_ring_enqueue_mp(struct ck_ring *ring, producer = ck_pr_load_uint(&ring->p_head); - do { + for (;;) { /* - * The snapshot of producer must be up to date with - * respect to consumer. + * The snapshot of producer must be up to date with respect to + * consumer. */ ck_pr_fence_load(); consumer = ck_pr_load_uint(&ring->c_head); delta = producer + 1; - if (CK_CC_UNLIKELY((delta & mask) == (consumer & mask))) { - r = false; - goto leave; + + /* + * Only try to CAS if the producer is not clearly stale (not + * less than consumer) and the buffer is definitely not full. + */ + if (CK_CC_LIKELY((producer - consumer) < mask)) { + if (ck_pr_cas_uint_value(&ring->p_head, + producer, delta, &producer) == true) { + break; + } + } else { + unsigned int new_producer; + + /* + * Slow path. Either the buffer is full or we have a + * stale snapshot of p_head. Execute a second read of + * p_read that must be ordered wrt the snapshot of + * c_head. + */ + ck_pr_fence_load(); + new_producer = ck_pr_load_uint(&ring->p_head); + + /* + * Only fail if we haven't made forward progress in + * production: the buffer must have been full when we + * read new_producer (or we wrapped around UINT_MAX + * during this iteration). + */ + if (producer == new_producer) { + r = false; + goto leave; + } + + /* + * p_head advanced during this iteration. Try again. + */ + producer = new_producer; } - } while (ck_pr_cas_uint_value(&ring->p_head, - producer, - delta, - &producer) == false); + } buffer = (char *)buffer + ts * (producer & mask); memcpy(buffer, entry, ts); Modified: head/sys/contrib/ck/include/gcc/ck_cc.h ============================================================================== --- head/sys/contrib/ck/include/gcc/ck_cc.h Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/include/gcc/ck_cc.h Mon Apr 2 23:40:50 2018 (r331898) @@ -103,28 +103,26 @@ #define CK_CC_TYPEOF(X, DEFAULT) __typeof__(X) /* - * Portability wrappers for bitwise ops. + * Portability wrappers for bitwise operations. */ - +#ifndef CK_MD_CC_BUILTIN_DISABLE #define CK_F_CC_FFS -#define CK_F_CC_CLZ -#define CK_F_CC_CTZ -#define CK_F_CC_POPCOUNT - CK_CC_INLINE static int ck_cc_ffs(unsigned int x) { - return __builtin_ffs(x); + return __builtin_ffsl(x); } +#define CK_F_CC_FFSL CK_CC_INLINE static int -ck_cc_clz(unsigned int x) +ck_cc_ffsl(unsigned long x) { - return __builtin_clz(x); + return __builtin_ffsll(x); } +#define CK_F_CC_CTZ CK_CC_INLINE static int ck_cc_ctz(unsigned int x) { @@ -132,11 +130,12 @@ ck_cc_ctz(unsigned int x) return __builtin_ctz(x); } +#define CK_F_CC_POPCOUNT CK_CC_INLINE static int ck_cc_popcount(unsigned int x) { return __builtin_popcount(x); } - +#endif /* CK_MD_CC_BUILTIN_DISABLE */ #endif /* CK_GCC_CC_H */ Modified: head/sys/contrib/ck/include/gcc/ck_pr.h ============================================================================== --- head/sys/contrib/ck/include/gcc/ck_pr.h Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/include/gcc/ck_pr.h Mon Apr 2 23:40:50 2018 (r331898) @@ -80,7 +80,7 @@ ck_pr_md_load_ptr(const void *target) void *r; ck_pr_barrier(); - r = CK_CC_DECONST_PTR(CK_PR_ACCESS(target)); + r = CK_CC_DECONST_PTR(*(volatile void *const*)(target)); ck_pr_barrier(); return r; @@ -91,7 +91,7 @@ ck_pr_md_store_ptr(void *target, const void *v) { ck_pr_barrier(); - CK_PR_ACCESS(target) = CK_CC_DECONST_PTR(v); + *(volatile void **)target = CK_CC_DECONST_PTR(v); ck_pr_barrier(); return; } Modified: head/sys/contrib/ck/include/gcc/sparcv9/ck_pr.h ============================================================================== --- head/sys/contrib/ck/include/gcc/sparcv9/ck_pr.h Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/include/gcc/sparcv9/ck_pr.h Mon Apr 2 23:40:50 2018 (r331898) @@ -76,7 +76,7 @@ CK_PR_FENCE(store, "membar #StoreStore") CK_PR_FENCE(store_load, "membar #StoreLoad") CK_PR_FENCE(load, "membar #LoadLoad") CK_PR_FENCE(load_store, "membar #LoadStore") -CK_PR_FENCE(memory, "membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad") +CK_PR_FENCE(memory, "membar #MemIssue") CK_PR_FENCE(acquire, "membar #LoadLoad | #LoadStore") CK_PR_FENCE(release, "membar #LoadStore | #StoreStore") CK_PR_FENCE(acqrel, "membar #LoadLoad | #LoadStore | #StoreStore") Modified: head/sys/contrib/ck/include/gcc/x86/ck_pr.h ============================================================================== --- head/sys/contrib/ck/include/gcc/x86/ck_pr.h Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/include/gcc/x86/ck_pr.h Mon Apr 2 23:40:50 2018 (r331898) @@ -45,15 +45,9 @@ /* Minimum requirements for the CK_PR interface are met. */ #define CK_F_PR -#ifdef CK_MD_UMP -#define CK_PR_LOCK_PREFIX -#else -#define CK_PR_LOCK_PREFIX "lock " -#endif - /* - * Prevent speculative execution in busy-wait loops (P4 <=) - * or "predefined delay". + * Prevent speculative execution in busy-wait loops (P4 <=) or "predefined + * delay". */ CK_CC_INLINE static void ck_pr_stall(void) @@ -62,28 +56,52 @@ ck_pr_stall(void) return; } +#ifdef CK_MD_UMP +#define CK_PR_LOCK_PREFIX #define CK_PR_FENCE(T, I) \ CK_CC_INLINE static void \ ck_pr_fence_strict_##T(void) \ { \ + __asm__ __volatile__("" ::: "memory"); \ + return; \ + } +#else +#define CK_PR_LOCK_PREFIX "lock " +#define CK_PR_FENCE(T, I) \ + CK_CC_INLINE static void \ + ck_pr_fence_strict_##T(void) \ + { \ __asm__ __volatile__(I ::: "memory"); \ + return; \ } +#endif /* CK_MD_UMP */ -CK_PR_FENCE(atomic, "sfence") -CK_PR_FENCE(atomic_store, "sfence") -CK_PR_FENCE(atomic_load, "mfence") -CK_PR_FENCE(store_atomic, "sfence") -CK_PR_FENCE(load_atomic, "mfence") -CK_PR_FENCE(load, "lfence") -CK_PR_FENCE(load_store, "mfence") -CK_PR_FENCE(store, "sfence") -CK_PR_FENCE(store_load, "mfence") -CK_PR_FENCE(memory, "mfence") -CK_PR_FENCE(release, "mfence") -CK_PR_FENCE(acquire, "mfence") -CK_PR_FENCE(acqrel, "mfence") -CK_PR_FENCE(lock, "mfence") -CK_PR_FENCE(unlock, "mfence") +#if defined(CK_MD_SSE_DISABLE) +/* If SSE is disabled, then use atomic operations for serialization. */ +#define CK_MD_X86_MFENCE "lock addl $0, (%%esp)" +#define CK_MD_X86_SFENCE CK_MD_X86_MFENCE +#define CK_MD_X86_LFENCE CK_MD_X86_MFENCE +#else +#define CK_MD_X86_SFENCE "sfence" +#define CK_MD_X86_LFENCE "lfence" +#define CK_MD_X86_MFENCE "mfence" +#endif /* !CK_MD_SSE_DISABLE */ + +CK_PR_FENCE(atomic, "") +CK_PR_FENCE(atomic_store, "") +CK_PR_FENCE(atomic_load, "") +CK_PR_FENCE(store_atomic, "") +CK_PR_FENCE(load_atomic, "") +CK_PR_FENCE(load, CK_MD_X86_LFENCE) +CK_PR_FENCE(load_store, CK_MD_X86_MFENCE) +CK_PR_FENCE(store, CK_MD_X86_SFENCE) +CK_PR_FENCE(store_load, CK_MD_X86_MFENCE) +CK_PR_FENCE(memory, CK_MD_X86_MFENCE) +CK_PR_FENCE(release, CK_MD_X86_MFENCE) +CK_PR_FENCE(acquire, CK_MD_X86_MFENCE) +CK_PR_FENCE(acqrel, CK_MD_X86_MFENCE) +CK_PR_FENCE(lock, CK_MD_X86_MFENCE) +CK_PR_FENCE(unlock, CK_MD_X86_MFENCE) #undef CK_PR_FENCE Modified: head/sys/contrib/ck/include/gcc/x86_64/ck_pr.h ============================================================================== --- head/sys/contrib/ck/include/gcc/x86_64/ck_pr.h Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/include/gcc/x86_64/ck_pr.h Mon Apr 2 23:40:50 2018 (r331898) @@ -58,8 +58,8 @@ #endif /* - * Prevent speculative execution in busy-wait loops (P4 <=) - * or "predefined delay". + * Prevent speculative execution in busy-wait loops (P4 <=) or "predefined + * delay". */ CK_CC_INLINE static void ck_pr_stall(void) @@ -75,18 +75,39 @@ ck_pr_stall(void) __asm__ __volatile__(I ::: "memory"); \ } -CK_PR_FENCE(atomic, "sfence") -CK_PR_FENCE(atomic_store, "sfence") -CK_PR_FENCE(atomic_load, "mfence") -CK_PR_FENCE(store_atomic, "sfence") -CK_PR_FENCE(load_atomic, "mfence") +/* Atomic operations are always serializing. */ +CK_PR_FENCE(atomic, "") +CK_PR_FENCE(atomic_store, "") +CK_PR_FENCE(atomic_load, "") +CK_PR_FENCE(store_atomic, "") +CK_PR_FENCE(load_atomic, "") + +/* Traditional fence interface. */ CK_PR_FENCE(load, "lfence") CK_PR_FENCE(load_store, "mfence") CK_PR_FENCE(store, "sfence") CK_PR_FENCE(store_load, "mfence") CK_PR_FENCE(memory, "mfence") + +/* Below are stdatomic-style fences. */ + +/* + * Provides load-store and store-store ordering. However, Intel specifies that + * the WC memory model is relaxed. It is likely an sfence *is* sufficient (in + * particular, stores are not re-ordered with respect to prior loads and it is + * really just the stores that are subject to re-ordering). However, we take + * the conservative route as the manuals are too ambiguous for my taste. + */ CK_PR_FENCE(release, "mfence") + +/* + * Provides load-load and load-store ordering. The lfence instruction ensures + * all prior load operations are complete before any subsequent instructions + * actually begin execution. However, the manual also ends up going to describe + * WC memory as a relaxed model. + */ CK_PR_FENCE(acquire, "mfence") + CK_PR_FENCE(acqrel, "mfence") CK_PR_FENCE(lock, "mfence") CK_PR_FENCE(unlock, "mfence") Modified: head/sys/contrib/ck/include/spinlock/dec.h ============================================================================== --- head/sys/contrib/ck/include/spinlock/dec.h Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/include/spinlock/dec.h Mon Apr 2 23:40:50 2018 (r331898) @@ -111,7 +111,8 @@ ck_spinlock_dec_lock_eb(struct ck_spinlock_dec *lock) if (r == true) break; - ck_backoff_eb(&backoff); + while (ck_pr_load_uint(&lock->value) != 1) + ck_backoff_eb(&backoff); } ck_pr_fence_lock(); Modified: head/sys/contrib/ck/src/ck_hs.c ============================================================================== --- head/sys/contrib/ck/src/ck_hs.c Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/src/ck_hs.c Mon Apr 2 23:40:50 2018 (r331898) @@ -105,21 +105,10 @@ ck_hs_map_signal(struct ck_hs_map *map, unsigned long return; } -void -ck_hs_iterator_init(struct ck_hs_iterator *iterator) +static bool +_ck_hs_next(struct ck_hs *hs, struct ck_hs_map *map, struct ck_hs_iterator *i, void **key) { - - iterator->cursor = NULL; - iterator->offset = 0; - return; -} - -bool -ck_hs_next(struct ck_hs *hs, struct ck_hs_iterator *i, void **key) -{ - struct ck_hs_map *map = hs->map; void *value; - if (i->offset >= map->capacity) return false; @@ -129,6 +118,8 @@ ck_hs_next(struct ck_hs *hs, struct ck_hs_iterator *i, #ifdef CK_HS_PP if (hs->mode & CK_HS_MODE_OBJECT) value = CK_HS_VMA(value); +#else + (void)hs; /* Avoid unused parameter warning. */ #endif i->offset++; *key = value; @@ -140,6 +131,32 @@ ck_hs_next(struct ck_hs *hs, struct ck_hs_iterator *i, } void +ck_hs_iterator_init(struct ck_hs_iterator *iterator) +{ + + iterator->cursor = NULL; + iterator->offset = 0; + iterator->map = NULL; + return; +} + +bool +ck_hs_next(struct ck_hs *hs, struct ck_hs_iterator *i, void **key) +{ + return _ck_hs_next(hs, hs->map, i, key); +} + +bool +ck_hs_next_spmc(struct ck_hs *hs, struct ck_hs_iterator *i, void **key) +{ + struct ck_hs_map *m = i->map; + if (m == NULL) { + m = i->map = ck_pr_load_ptr(&hs->map); + } + return _ck_hs_next(hs, m, i, key); +} + +void ck_hs_stat(struct ck_hs *hs, struct ck_hs_stat *st) { struct ck_hs_map *map = hs->map; @@ -206,7 +223,7 @@ ck_hs_map_create(struct ck_hs *hs, unsigned long entri map->probe_limit = (unsigned int)limit; map->probe_maximum = 0; map->capacity = n_entries; - map->step = ck_internal_bsf(n_entries); + map->step = ck_cc_ffsl(n_entries); map->mask = n_entries - 1; map->n_entries = 0; Modified: head/sys/contrib/ck/src/ck_ht.c ============================================================================== --- head/sys/contrib/ck/src/ck_ht.c Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/src/ck_ht.c Mon Apr 2 23:40:50 2018 (r331898) @@ -171,7 +171,7 @@ ck_ht_map_create(struct ck_ht *table, CK_HT_TYPE entri map->deletions = 0; map->probe_maximum = 0; map->capacity = n_entries; - map->step = ck_internal_bsf_64(map->capacity); + map->step = ck_cc_ffsll(map->capacity); map->mask = map->capacity - 1; map->n_entries = 0; map->entries = (struct ck_ht_entry *)(((uintptr_t)&map[1] + prefix + Modified: head/sys/contrib/ck/src/ck_ht_hash.h ============================================================================== --- head/sys/contrib/ck/src/ck_ht_hash.h Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/src/ck_ht_hash.h Mon Apr 2 23:40:50 2018 (r331898) @@ -88,7 +88,15 @@ static inline uint64_t rotl64 ( uint64_t x, int8_t r ) FORCE_INLINE static uint32_t getblock ( const uint32_t * p, int i ) { +#ifdef __s390x__ + uint32_t res; + + __asm__ (" lrv %0,%1\n" + : "=r" (res) : "Q" (p[i]) : "cc", "mem"); + return res; +#else return p[i]; +#endif /* !__s390x__ */ } //----------------------------------------------------------------------------- @@ -147,7 +155,9 @@ static inline void MurmurHash3_x86_32 ( const void * k switch(len & 3) { case 3: k1 ^= tail[2] << 16; + /* fall through */ case 2: k1 ^= tail[1] << 8; + /* fall through */ case 1: k1 ^= tail[0]; k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1; }; @@ -196,11 +206,17 @@ static inline uint64_t MurmurHash64A ( const void * ke switch(len & 7) { case 7: h ^= (uint64_t)(data2[6]) << 48; + /* fall through */ case 6: h ^= (uint64_t)(data2[5]) << 40; + /* fall through */ case 5: h ^= (uint64_t)(data2[4]) << 32; + /* fall through */ case 4: h ^= (uint64_t)(data2[3]) << 24; + /* fall through */ case 3: h ^= (uint64_t)(data2[2]) << 16; + /* fall through */ case 2: h ^= (uint64_t)(data2[1]) << 8; + /* fall through */ case 1: h ^= (uint64_t)(data2[0]); h *= m; }; @@ -249,7 +265,9 @@ static inline uint64_t MurmurHash64B ( const void * ke switch(len) { case 3: h2 ^= ((const unsigned char*)data)[2] << 16; + /* fall through */ case 2: h2 ^= ((const unsigned char*)data)[1] << 8; + /* fall through */ case 1: h2 ^= ((const unsigned char*)data)[0]; h2 *= m; }; Modified: head/sys/contrib/ck/src/ck_internal.h ============================================================================== --- head/sys/contrib/ck/src/ck_internal.h Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/src/ck_internal.h Mon Apr 2 23:40:50 2018 (r331898) @@ -80,40 +80,3 @@ ck_internal_max_32(uint32_t x, uint32_t y) return x ^ ((x ^ y) & -(x < y)); } - -CK_CC_INLINE static unsigned long -ck_internal_bsf(unsigned long v) -{ -#if defined(__GNUC__) - return __builtin_ffs(v); -#else - unsigned int i; - const unsigned int s = sizeof(unsigned long) * 8 - 1; - - for (i = 0; i < s; i++) { - if (v & (1UL << (s - i))) - return sizeof(unsigned long) * 8 - i; - } - - return 1; -#endif /* !__GNUC__ */ -} - -CK_CC_INLINE static uint64_t -ck_internal_bsf_64(uint64_t v) -{ -#if defined(__GNUC__) - return __builtin_ffs(v); -#else - unsigned int i; - const unsigned int s = sizeof(unsigned long) * 8 - 1; - - for (i = 0; i < s; i++) { - if (v & (1ULL << (63U - i))) - return i; - } -#endif /* !__GNUC__ */ - - return 1; -} - Modified: head/sys/contrib/ck/src/ck_rhs.c ============================================================================== --- head/sys/contrib/ck/src/ck_rhs.c Mon Apr 2 23:39:04 2018 (r331897) +++ head/sys/contrib/ck/src/ck_rhs.c Mon Apr 2 23:40:50 2018 (r331898) @@ -366,7 +366,7 @@ ck_rhs_map_create(struct ck_rhs *hs, unsigned long ent map->probe_limit = (unsigned int)limit; map->probe_maximum = 0; map->capacity = n_entries; - map->step = ck_internal_bsf(n_entries); + map->step = ck_cc_ffsl(n_entries); map->mask = n_entries - 1; map->n_entries = 0; From owner-svn-src-head@freebsd.org Tue Apr 3 00:45:39 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0E2D3F71DEB; Tue, 3 Apr 2018 00:45:39 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B1E0A7B756; Tue, 3 Apr 2018 00:45:38 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A88331D206; Tue, 3 Apr 2018 00:45:38 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w330jc9B037761; Tue, 3 Apr 2018 00:45:38 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w330jc1G037742; Tue, 3 Apr 2018 00:45:38 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201804030045.w330jc1G037742@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Tue, 3 Apr 2018 00:45:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331900 - in head/sys/powerpc: booke include X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: in head/sys/powerpc: booke include X-SVN-Commit-Revision: 331900 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 00:45:39 -0000 Author: jhibbits Date: Tue Apr 3 00:45:38 2018 New Revision: 331900 URL: https://svnweb.freebsd.org/changeset/base/331900 Log: Add support for a pmap direct map for 64-bit Book-E As with AIM64, map the DMAP at the beginning of the fourth "quadrant" of memory, and move the KERNBASE to the the start of KVA. Eventually we may run the kernel out of the DMAP, but for now, continue booting as it has been. Modified: head/sys/powerpc/booke/pmap.c head/sys/powerpc/include/vmparam.h Modified: head/sys/powerpc/booke/pmap.c ============================================================================== --- head/sys/powerpc/booke/pmap.c Mon Apr 2 23:44:12 2018 (r331899) +++ head/sys/powerpc/booke/pmap.c Tue Apr 3 00:45:38 2018 (r331900) @@ -1724,7 +1724,11 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset_t start, vm_o debugf("mmu_booke_bootstrap: entered\n"); /* Set interesting system properties */ +#ifdef __powerpc64__ + hw_direct_map = 1; +#else hw_direct_map = 0; +#endif #if defined(COMPAT_FREEBSD32) || !defined(__powerpc64__) elf32_nxstack = 1; #endif @@ -1970,6 +1974,15 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset_t start, vm_o debugf("phys_avail_count = %d\n", phys_avail_count); debugf("physsz = 0x%09jx physmem = %jd (0x%09jx)\n", (uintmax_t)physsz, (uintmax_t)physmem, (uintmax_t)physmem); + +#ifdef __powerpc64__ + /* + * Map the physical memory contiguously in TLB1. + * Round so it fits into a single mapping. + */ + tlb1_mapin_region(DMAP_BASE_ADDRESS, 0, + phys_avail[i + 1]); +#endif /*******************************************************/ /* Initialize (statically allocated) kernel pmap. */ Modified: head/sys/powerpc/include/vmparam.h ============================================================================== --- head/sys/powerpc/include/vmparam.h Mon Apr 2 23:44:12 2018 (r331899) +++ head/sys/powerpc/include/vmparam.h Tue Apr 3 00:45:38 2018 (r331900) @@ -106,13 +106,8 @@ #define FREEBSD32_USRSTACK FREEBSD32_SHAREDPAGE #ifdef __powerpc64__ -#ifdef AIM #define VM_MIN_KERNEL_ADDRESS 0xe000000000000000UL #define VM_MAX_KERNEL_ADDRESS 0xe0000001c7ffffffUL -#else -#define VM_MIN_KERNEL_ADDRESS 0xc000000000000000UL -#define VM_MAX_KERNEL_ADDRESS 0xc0000001c7ffffffUL -#endif #define VM_MAX_SAFE_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS #endif @@ -135,9 +130,9 @@ #ifdef __powerpc64__ #ifndef LOCORE -#define KERNBASE 0xc000000000000100UL /* start of kernel virtual */ +#define KERNBASE 0xe000000000000100UL /* start of kernel virtual */ #else -#define KERNBASE 0xc000000000000100 /* start of kernel virtual */ +#define KERNBASE 0xe000000000000100 /* start of kernel virtual */ #endif #else #define KERNBASE 0xc0000000 /* start of kernel virtual */ From owner-svn-src-head@freebsd.org Tue Apr 3 01:08:55 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8E1ABF734A1; Tue, 3 Apr 2018 01:08:55 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3DFA97CC2C; Tue, 3 Apr 2018 01:08:55 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 37D451D551; Tue, 3 Apr 2018 01:08:55 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3318t62051657; Tue, 3 Apr 2018 01:08:55 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3318s2P051624; Tue, 3 Apr 2018 01:08:54 GMT (envelope-from np@FreeBSD.org) Message-Id: <201804030108.w3318s2P051624@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Tue, 3 Apr 2018 01:08:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331901 - head/sys/netinet X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: head/sys/netinet X-SVN-Commit-Revision: 331901 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 01:08:55 -0000 Author: np Date: Tue Apr 3 01:08:54 2018 New Revision: 331901 URL: https://svnweb.freebsd.org/changeset/base/331901 Log: Add a hook to allow the toedev handling an offloaded connection to provide accurate TCP_INFO. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D14816 Modified: head/sys/netinet/tcp_offload.c head/sys/netinet/tcp_offload.h head/sys/netinet/tcp_usrreq.c head/sys/netinet/toecore.c head/sys/netinet/toecore.h Modified: head/sys/netinet/tcp_offload.c ============================================================================== --- head/sys/netinet/tcp_offload.c Tue Apr 3 00:45:38 2018 (r331900) +++ head/sys/netinet/tcp_offload.c Tue Apr 3 01:08:54 2018 (r331901) @@ -168,6 +168,17 @@ tcp_offload_ctloutput(struct tcpcb *tp, int sopt_dir, } void +tcp_offload_tcp_info(struct tcpcb *tp, struct tcp_info *ti) +{ + struct toedev *tod = tp->tod; + + KASSERT(tod != NULL, ("%s: tp->tod is NULL, tp %p", __func__, tp)); + INP_WLOCK_ASSERT(tp->t_inpcb); + + tod->tod_tcp_info(tod, tp, ti); +} + +void tcp_offload_detach(struct tcpcb *tp) { struct toedev *tod = tp->tod; Modified: head/sys/netinet/tcp_offload.h ============================================================================== --- head/sys/netinet/tcp_offload.h Tue Apr 3 00:45:38 2018 (r331900) +++ head/sys/netinet/tcp_offload.h Tue Apr 3 01:08:54 2018 (r331901) @@ -45,6 +45,7 @@ void tcp_offload_input(struct tcpcb *, struct mbuf *); int tcp_offload_output(struct tcpcb *); void tcp_offload_rcvd(struct tcpcb *); void tcp_offload_ctloutput(struct tcpcb *, int, int); +void tcp_offload_tcp_info(struct tcpcb *, struct tcp_info *); void tcp_offload_detach(struct tcpcb *); #endif Modified: head/sys/netinet/tcp_usrreq.c ============================================================================== --- head/sys/netinet/tcp_usrreq.c Tue Apr 3 00:45:38 2018 (r331900) +++ head/sys/netinet/tcp_usrreq.c Tue Apr 3 01:08:54 2018 (r331901) @@ -1393,11 +1393,15 @@ tcp_fill_info(struct tcpcb *tp, struct tcp_info *ti) ti->tcpi_snd_nxt = tp->snd_nxt; ti->tcpi_snd_mss = tp->t_maxseg; ti->tcpi_rcv_mss = tp->t_maxseg; - if (tp->t_flags & TF_TOE) - ti->tcpi_options |= TCPI_OPT_TOE; ti->tcpi_snd_rexmitpack = tp->t_sndrexmitpack; ti->tcpi_rcv_ooopack = tp->t_rcvoopack; ti->tcpi_snd_zerowin = tp->t_sndzerowin; +#ifdef TCP_OFFLOAD + if (tp->t_flags & TF_TOE) { + ti->tcpi_options |= TCPI_OPT_TOE; + tcp_offload_tcp_info(tp, ti); + } +#endif } /* Modified: head/sys/netinet/toecore.c ============================================================================== --- head/sys/netinet/toecore.c Tue Apr 3 00:45:38 2018 (r331900) +++ head/sys/netinet/toecore.c Tue Apr 3 01:08:54 2018 (r331901) @@ -182,6 +182,14 @@ toedev_ctloutput(struct toedev *tod __unused, struct t return; } +static void +toedev_tcp_info(struct toedev *tod __unused, struct tcpcb *tp __unused, + struct tcp_info *ti __unused) +{ + + return; +} + /* * Inform one or more TOE devices about a listening socket. */ @@ -271,6 +279,7 @@ init_toedev(struct toedev *tod) tod->tod_syncache_respond = toedev_syncache_respond; tod->tod_offload_socket = toedev_offload_socket; tod->tod_ctloutput = toedev_ctloutput; + tod->tod_tcp_info = toedev_tcp_info; } /* Modified: head/sys/netinet/toecore.h ============================================================================== --- head/sys/netinet/toecore.h Tue Apr 3 00:45:38 2018 (r331900) +++ head/sys/netinet/toecore.h Tue Apr 3 01:08:54 2018 (r331901) @@ -38,6 +38,7 @@ struct tcpopt; struct tcphdr; struct in_conninfo; +struct tcp_info; struct toedev { TAILQ_ENTRY(toedev) link; /* glue for toedev_list */ @@ -101,6 +102,10 @@ struct toedev { /* TCP socket option */ void (*tod_ctloutput)(struct toedev *, struct tcpcb *, int, int); + + /* Update software state */ + void (*tod_tcp_info)(struct toedev *, struct tcpcb *, + struct tcp_info *); }; #include From owner-svn-src-head@freebsd.org Tue Apr 3 01:22:17 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DD692F74793; Tue, 3 Apr 2018 01:22:16 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9114C7DA72; Tue, 3 Apr 2018 01:22:16 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8BE2C1D8EA; Tue, 3 Apr 2018 01:22:16 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w331MGnC008181; Tue, 3 Apr 2018 01:22:16 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w331MGWL008166; Tue, 3 Apr 2018 01:22:16 GMT (envelope-from np@FreeBSD.org) Message-Id: <201804030122.w331MGWL008166@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Tue, 3 Apr 2018 01:22:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331902 - in head/sys/dev/cxgbe: . common tom X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: in head/sys/dev/cxgbe: . common tom X-SVN-Commit-Revision: 331902 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 01:22:17 -0000 Author: np Date: Tue Apr 3 01:22:15 2018 New Revision: 331902 URL: https://svnweb.freebsd.org/changeset/base/331902 Log: cxgbe: Implement tcp_info handler for connections handled by t4_tom. The TCB is read using a memory window right now. A better alternate to get self-consistent, uncached information would be to use a GET_TCB request but waiting for a reply from hw while holding non-sleepable locks is quite inconvenient. Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D14817 Modified: head/sys/dev/cxgbe/adapter.h head/sys/dev/cxgbe/common/common.h head/sys/dev/cxgbe/t4_main.c head/sys/dev/cxgbe/tom/t4_tom.c Modified: head/sys/dev/cxgbe/adapter.h ============================================================================== --- head/sys/dev/cxgbe/adapter.h Tue Apr 3 01:08:54 2018 (r331901) +++ head/sys/dev/cxgbe/adapter.h Tue Apr 3 01:22:15 2018 (r331902) @@ -1160,6 +1160,7 @@ int vi_full_init(struct vi_info *); int vi_full_uninit(struct vi_info *); void vi_sysctls(struct vi_info *); void vi_tick(void *); +int rw_via_memwin(struct adapter *, int, uint32_t, uint32_t *, int, int); #ifdef DEV_NETMAP /* t4_netmap.c */ @@ -1252,4 +1253,19 @@ t4_wrq_tx(struct adapter *sc, struct wrqe *wr) TXQ_UNLOCK(wrq); } +static inline int +read_via_memwin(struct adapter *sc, int idx, uint32_t addr, uint32_t *val, + int len) +{ + + return (rw_via_memwin(sc, idx, addr, val, len, 0)); +} + +static inline int +write_via_memwin(struct adapter *sc, int idx, uint32_t addr, + const uint32_t *val, int len) +{ + + return (rw_via_memwin(sc, idx, addr, (void *)(uintptr_t)val, len, 1)); +} #endif Modified: head/sys/dev/cxgbe/common/common.h ============================================================================== --- head/sys/dev/cxgbe/common/common.h Tue Apr 3 01:08:54 2018 (r331901) +++ head/sys/dev/cxgbe/common/common.h Tue Apr 3 01:22:15 2018 (r331902) @@ -519,6 +519,12 @@ static inline u_int us_to_tcp_ticks(const struct adapt return (us * adap->params.vpd.cclk / 1000 >> adap->params.tp.tre); } +static inline u_int tcp_ticks_to_us(const struct adapter *adap, u_int ticks) +{ + return ((uint64_t)ticks << adap->params.tp.tre) / + core_ticks_per_usec(adap); +} + void t4_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask, u32 val); int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, const void *cmd, Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Tue Apr 3 01:08:54 2018 (r331901) +++ head/sys/dev/cxgbe/t4_main.c Tue Apr 3 01:22:15 2018 (r331902) @@ -511,11 +511,6 @@ struct filter_entry { static void setup_memwin(struct adapter *); static void position_memwin(struct adapter *, int, uint32_t); -static int rw_via_memwin(struct adapter *, int, uint32_t, uint32_t *, int, int); -static inline int read_via_memwin(struct adapter *, int, uint32_t, uint32_t *, - int); -static inline int write_via_memwin(struct adapter *, int, uint32_t, - const uint32_t *, int); static int validate_mem_range(struct adapter *, uint32_t, int); static int fwmtype_to_hwmtype(int); static int validate_mt_off_len(struct adapter *, int, uint32_t, int, @@ -2391,7 +2386,7 @@ position_memwin(struct adapter *sc, int idx, uint32_t t4_read_reg(sc, reg); /* flush */ } -static int +int rw_via_memwin(struct adapter *sc, int idx, uint32_t addr, uint32_t *val, int len, int rw) { @@ -2437,22 +2432,6 @@ rw_via_memwin(struct adapter *sc, int idx, uint32_t ad } return (0); -} - -static inline int -read_via_memwin(struct adapter *sc, int idx, uint32_t addr, uint32_t *val, - int len) -{ - - return (rw_via_memwin(sc, idx, addr, val, len, 0)); -} - -static inline int -write_via_memwin(struct adapter *sc, int idx, uint32_t addr, - const uint32_t *val, int len) -{ - - return (rw_via_memwin(sc, idx, addr, (void *)(uintptr_t)val, len, 1)); } static int Modified: head/sys/dev/cxgbe/tom/t4_tom.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_tom.c Tue Apr 3 01:08:54 2018 (r331901) +++ head/sys/dev/cxgbe/tom/t4_tom.c Tue Apr 3 01:22:15 2018 (r331902) @@ -401,7 +401,85 @@ t4_ctloutput(struct toedev *tod, struct tcpcb *tp, int } } +static inline int +get_tcb_bit(u_char *tcb, int bit) +{ + int ix, shift; + + ix = 127 - (bit >> 3); + shift = bit & 0x7; + + return ((tcb[ix] >> shift) & 1); +} + +static inline uint64_t +get_tcb_bits(u_char *tcb, int hi, int lo) +{ + uint64_t rc = 0; + + while (hi >= lo) { + rc = (rc << 1) | get_tcb_bit(tcb, hi); + --hi; + } + + return (rc); +} + /* + * Called by the kernel to allow the TOE driver to "refine" values filled up in + * the tcp_info for an offloaded connection. + */ +static void +t4_tcp_info(struct toedev *tod, struct tcpcb *tp, struct tcp_info *ti) +{ + int i, j, k, rc; + struct adapter *sc = tod->tod_softc; + struct toepcb *toep = tp->t_toe; + uint32_t addr, v; + uint32_t buf[TCB_SIZE / sizeof(uint32_t)]; + u_char *tcb, tmp; + + INP_WLOCK_ASSERT(tp->t_inpcb); + MPASS(ti != NULL); + + addr = t4_read_reg(sc, A_TP_CMM_TCB_BASE) + toep->tid * TCB_SIZE; + rc = read_via_memwin(sc, 2, addr, &buf[0], TCB_SIZE); + if (rc != 0) + return; + + tcb = (u_char *)&buf[0]; + for (i = 0, j = TCB_SIZE - 16; i < j; i += 16, j -= 16) { + for (k = 0; k < 16; k++) { + tmp = tcb[i + k]; + tcb[i + k] = tcb[j + k]; + tcb[j + k] = tmp; + } + } + + ti->tcpi_state = get_tcb_bits(tcb, 115, 112); + + v = get_tcb_bits(tcb, 271, 256); + ti->tcpi_rtt = tcp_ticks_to_us(sc, v); + + v = get_tcb_bits(tcb, 287, 272); + ti->tcpi_rttvar = tcp_ticks_to_us(sc, v); + + ti->tcpi_snd_ssthresh = get_tcb_bits(tcb, 487, 460); + ti->tcpi_snd_cwnd = get_tcb_bits(tcb, 459, 432); + ti->tcpi_rcv_nxt = get_tcb_bits(tcb, 553, 522); + + ti->tcpi_snd_nxt = get_tcb_bits(tcb, 319, 288) - + get_tcb_bits(tcb, 375, 348); + + /* Receive window being advertised by us. */ + ti->tcpi_rcv_space = get_tcb_bits(tcb, 581, 554); + + /* Send window ceiling. */ + v = get_tcb_bits(tcb, 159, 144) << get_tcb_bits(tcb, 131, 128); + ti->tcpi_snd_wnd = min(v, ti->tcpi_snd_cwnd); +} + +/* * The TOE driver will not receive any more CPLs for the tid associated with the * toepcb; release the hold on the inpcb. */ @@ -1126,6 +1204,7 @@ t4_tom_activate(struct adapter *sc) tod->tod_syncache_respond = t4_syncache_respond; tod->tod_offload_socket = t4_offload_socket; tod->tod_ctloutput = t4_ctloutput; + tod->tod_tcp_info = t4_tcp_info; for_each_port(sc, i) { for_each_vi(sc->port[i], v, vi) { From owner-svn-src-head@freebsd.org Tue Apr 3 01:40:28 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0FACAF75A5E; Tue, 3 Apr 2018 01:40:28 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-wr0-x22b.google.com (mail-wr0-x22b.google.com [IPv6:2a00:1450:400c:c0c::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 77D397E4E8; Tue, 3 Apr 2018 01:40:27 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by mail-wr0-x22b.google.com with SMTP id p53so16314661wrc.10; Mon, 02 Apr 2018 18:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=msYvQfyimbsD5wseBtycFUyoCgIslfRyDEug1lO8sJU=; b=Cz7du1tGgxl2vStsUD+VscB47f17MTTBQX5koS7Mv5relSmdJ0WKCBQUlUEGwZZtp1 wxsL4SftrLdd8tKLzklz1EmROeeaDC58+6DSryYKLaY4F7i9KLdvax0Mpk9GGxSxxwCu 0zO01eNTic9orWhmV6UAiMsfb3L5d0ToFRBycPkAvmT5J9og/caSpivnP4gLkoo6c05I 1pTFfi8O85C6piEEDqLT5AHwCYvvO/tkOb3BU8pXV4LCaAFQDAOAqdNTzTKq8GTvLHiP NHmhZWWKESo0QhxXwjUfirdgf7aD0roG2qOz1d59lq9WNp4K8CFbWxwpwlyedhLaB7qm F0qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=msYvQfyimbsD5wseBtycFUyoCgIslfRyDEug1lO8sJU=; b=iZlrKU0NNhPuccw8DHOqzaoYPMHEV2vDQp9fdoYfFU6jhJs+es/w6S7shD4iOOYXdD zbTMpjOd8Bof69JX3ra7l0HyLdaQtciZff/jB7NLsoUG6PwXbwFfij/qj4tuJ+9oghpV Iu8GdNO2CorviqHKsfdcM/CEmd/vWeh9fDiG4sdSJcmC3UTOPm4rv0yNpR8m3z7jipn1 jaHGFPZu+4w2l0rKVlu18W52oOmzYs4v6unFvZ4FJyVvuO+LMDuPgXvE/zxMfdURskue 8SrslgSgBI1tMhvT7gYhX1NQ3WTXM6h5AvWGBpt/ll0NLRi7dDfehdvOLDK+C0+cT0aM cP3g== X-Gm-Message-State: AElRT7EUQ4cWbTRrWHhebcCS6mKmSEFQO1CAIF7b2LavD6W03p0xy+Bg KofO6LcY97Oh2ihK8frA/e3b2EQ726iIPBT76zqwkQ== X-Google-Smtp-Source: AIpwx4+u16gYcoyCFu330Lq9ZjG0V61uGV5HsDGh75o0363hObsGXTw+u0yTZzDcQAbVwz7THhcrF1MOzoqzs9hsgTE= X-Received: by 10.223.195.116 with SMTP id e49mr7924570wrg.5.1522719625932; Mon, 02 Apr 2018 18:40:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.14.202 with HTTP; Mon, 2 Apr 2018 18:40:24 -0700 (PDT) In-Reply-To: <201804022340.w32Neo60014397@repo.freebsd.org> References: <201804022340.w32Neo60014397@repo.freebsd.org> From: Adrian Chadd Date: Mon, 2 Apr 2018 18:40:24 -0700 Message-ID: Subject: Re: svn commit: r331898 - in head/sys/contrib/ck: . include include/gcc include/gcc/sparcv9 include/gcc/x86 include/gcc/x86_64 include/spinlock src To: Olivier Houchard Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 01:40:28 -0000 hi! woohoo! what about CACHE_LINE_SIZE ? -a From owner-svn-src-head@freebsd.org Tue Apr 3 02:41:33 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 56EACF79CBC; Tue, 3 Apr 2018 02:41:33 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0597480D4F; Tue, 3 Apr 2018 02:41:33 +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 0087E1E502; Tue, 3 Apr 2018 02:41:33 +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 w332fW55076157; Tue, 3 Apr 2018 02:41:32 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w332fWnF076156; Tue, 3 Apr 2018 02:41:32 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201804030241.w332fWnF076156@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 3 Apr 2018 02:41:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331904 - head/stand/defaults X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/defaults X-SVN-Commit-Revision: 331904 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 02:41:33 -0000 Author: kevans Date: Tue Apr 3 02:41:32 2018 New Revision: 331904 URL: https://svnweb.freebsd.org/changeset/base/331904 Log: Default loader.conf: Drop efi_max_resolution to 1x1 Effectively disabling the mode changing bits in the loader. No matter which way we go with it, it seems to be wrong- either the firmware doesn't change the resolution and reports the resolution we requested, or the firmware changes the resolution and doesn't report the resolution we requested. It some cases, it does the right thing, but the bad cases outweight those. Interested individuals can still set efi_max_resolution to 1080p or whatnot in loader.conf(5) to restore the new behavior, but the new behavior does not work out well for many cases. Discussed with: imp Modified: head/stand/defaults/loader.conf Modified: head/stand/defaults/loader.conf ============================================================================== --- head/stand/defaults/loader.conf Tue Apr 3 02:29:17 2018 (r331903) +++ head/stand/defaults/loader.conf Tue Apr 3 02:41:32 2018 (r331904) @@ -75,7 +75,7 @@ acpi_video_load="NO" # Load the ACPI video extension #geom_eli_passphrase_prompt="NO" # Prompt for geli(8) passphrase to mount root bootenv_autolist="YES" # Auto populate the list of ZFS Boot Environments #beastie_disable="NO" # Turn the beastie boot menu on and off -efi_max_resolution="1080p" # Set the max resolution for EFI loader to use: +efi_max_resolution="1x1" # Set the max resolution for EFI loader to use: # 480p, 720p, 1080p, 2160p/4k, 5k, or specify # WidthxHeight (e.g. 1920x1080) #kernels="kernel kernel.old" # Kernels to display in the boot menu From owner-svn-src-head@freebsd.org Tue Apr 3 04:31:55 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7D313F80C9E; Tue, 3 Apr 2018 04:31:55 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2FDFD850C6; Tue, 3 Apr 2018 04:31:55 +0000 (UTC) (envelope-from gonzo@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 2A6461F809; Tue, 3 Apr 2018 04:31:55 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w334VtxQ086656; Tue, 3 Apr 2018 04:31:55 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w334VtSp086654; Tue, 3 Apr 2018 04:31:55 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201804030431.w334VtSp086654@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Tue, 3 Apr 2018 04:31:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331906 - head/sys/arm/xilinx X-SVN-Group: head X-SVN-Commit-Author: gonzo X-SVN-Commit-Paths: head/sys/arm/xilinx X-SVN-Commit-Revision: 331906 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 04:31:55 -0000 Author: gonzo Date: Tue Apr 3 04:31:54 2018 New Revision: 331906 URL: https://svnweb.freebsd.org/changeset/base/331906 Log: Fix accidental USB port resets by GPIO on Zynq/Zedboard boards The Zynq/Zedboard GPIO driver attempts to tri-state all GPIO pins on boot up but the order in which I reset the hardware can cause the pins to be briefly held low before being tri-stated. This is a problem on boards that use GPIO pins to reset devices. In particular, the Zybo and ZC-706 boards use a GPIO pin as a USB PHY reset. If U-boot enables the USB port before booting the kernel, the GPIO driver attach causes a glitch on the USB PHY reset and the USB port loses power. My fix is to have the GPIO driver leave the pins in whatever configuration U-boot placed them. PR: 225713 Submitted by: Thomas Skibo MFC after: 1 week Modified: head/sys/arm/xilinx/zy7_gpio.c Modified: head/sys/arm/xilinx/zy7_gpio.c ============================================================================== --- head/sys/arm/xilinx/zy7_gpio.c Tue Apr 3 03:41:55 2018 (r331905) +++ head/sys/arm/xilinx/zy7_gpio.c Tue Apr 3 04:31:54 2018 (r331906) @@ -298,24 +298,6 @@ zy7_gpio_probe(device_t dev) return (0); } -static void -zy7_gpio_hw_reset(struct zy7_gpio_softc *sc) -{ - int i; - - for (i = 0; i < NUMBANKS; i++) { - WR4(sc, ZY7_GPIO_DATA(i), 0); - WR4(sc, ZY7_GPIO_DIRM(i), 0); - WR4(sc, ZY7_GPIO_OEN(i), 0); - WR4(sc, ZY7_GPIO_INT_DIS(i), 0xffffffff); - WR4(sc, ZY7_GPIO_INT_POLARITY(i), 0); - WR4(sc, ZY7_GPIO_INT_TYPE(i), - i == 1 ? 0x003fffff : 0xffffffff); - WR4(sc, ZY7_GPIO_INT_ANY(i), 0); - WR4(sc, ZY7_GPIO_INT_STAT(i), 0xffffffff); - } -} - static int zy7_gpio_detach(device_t dev); static int @@ -337,9 +319,6 @@ zy7_gpio_attach(device_t dev) zy7_gpio_detach(dev); return (ENOMEM); } - - /* Completely reset. */ - zy7_gpio_hw_reset(sc); sc->busdev = gpiobus_attach_bus(dev); if (sc->busdev == NULL) { From owner-svn-src-head@freebsd.org Tue Apr 3 06:46:26 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A7CBCF871E7; Tue, 3 Apr 2018 06:46:26 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5B32D697F3; Tue, 3 Apr 2018 06:46:26 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5614020E93; Tue, 3 Apr 2018 06:46:26 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w336kQQ0004258; Tue, 3 Apr 2018 06:46:26 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w336kQI5004257; Tue, 3 Apr 2018 06:46:26 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201804030646.w336kQI5004257@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 3 Apr 2018 06:46:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331908 - head/sys/x86/x86 X-SVN-Group: head X-SVN-Commit-Author: avg X-SVN-Commit-Paths: head/sys/x86/x86 X-SVN-Commit-Revision: 331908 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 06:46:26 -0000 Author: avg Date: Tue Apr 3 06:46:26 2018 New Revision: 331908 URL: https://svnweb.freebsd.org/changeset/base/331908 Log: fix signatures of cpu_reset_real and cpu_reset_proxy, broken in r331878 When I moved these functions from i386 and amd64 to x86 I dropped their prototype declarations (that were correct) and left only their definitions that became incorrect. Reported by: bde MFC after: 15 days X-MFC with: r331878 Modified: head/sys/x86/x86/cpu_machdep.c Modified: head/sys/x86/x86/cpu_machdep.c ============================================================================== --- head/sys/x86/x86/cpu_machdep.c Tue Apr 3 06:06:39 2018 (r331907) +++ head/sys/x86/x86/cpu_machdep.c Tue Apr 3 06:46:26 2018 (r331908) @@ -251,7 +251,7 @@ cpu_halt(void) } static void -cpu_reset_real() +cpu_reset_real(void) { struct region_descriptor null_idt; int b; @@ -324,7 +324,7 @@ cpu_reset_real() #ifdef SMP static void -cpu_reset_proxy() +cpu_reset_proxy(void) { cpu_reset_proxy_active = 1; @@ -338,7 +338,7 @@ cpu_reset_proxy() #endif void -cpu_reset() +cpu_reset(void) { #ifdef SMP cpuset_t map; From owner-svn-src-head@freebsd.org Tue Apr 3 06:49:12 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C4475F8742F; Tue, 3 Apr 2018 06:49:12 +0000 (UTC) (envelope-from srs0=rwrb=gy=freebsd.org=kp@codepro.be) Received: from venus.codepro.be (venus.codepro.be [IPv6:2a01:4f8:162:1127::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.codepro.be", Issuer "Gandi Standard SSL CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 63DD1699D7; Tue, 3 Apr 2018 06:49:12 +0000 (UTC) (envelope-from srs0=rwrb=gy=freebsd.org=kp@codepro.be) Received: from [10.0.2.164] (ptr-8ripyygqcdbrpdrmc0f.18120a2.ip6.access.telenet.be [IPv6:2a02:1811:2419:4e02:9974:2609:c896:854f]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id 971F6874E; Tue, 3 Apr 2018 08:49:10 +0200 (CEST) From: "Kristof Provost" To: "Gleb Smirnoff" Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331546 - head/etc/rc.d Date: Tue, 03 Apr 2018 08:49:09 +0200 X-Mailer: MailMate (2.0BETAr6106) Message-ID: <4F543A96-C6B1-4FF0-A501-BC6C7FD3F26A@FreeBSD.org> In-Reply-To: <20180402220430.GD1917@FreeBSD.org> References: <201803260936.w2Q9aMfD082758@repo.freebsd.org> <20180402220430.GD1917@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; markup=markdown Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 06:49:12 -0000 On 3 Apr 2018, at 0:04, Gleb Smirnoff wrote: > I just want to note that this is a huge change of behaviour > of pf(4) for a user. Over a decade everybody has been used > to the difference between "reload" and "resync". There is no difference. r330105 removed the ‘$pf_program -Fnat -Fqueue -Frules -FSources -Finfo -FTables -Fosfp’ line, but this never actually did what the author thought it did. pfctl only ever performed the last ‘-F’, not all of them, so all this ever did was flush the OS fingerprints information. Clearly that’s not what was intended. pf never actually breaks existing connections, because existing states keep using the rule that created them, regardless of the current rules. It wouldn’t have broken connections with resync either. A ‘restart’ will, because ‘start’ does ‘pfctl -F all’. If the flush had actually done what was intended it’d arguably have been a security issue, because reloading rules would then (briefly) open the firewall, allowing all traffic to pass and establish state. > Yes, I admit > that back in 2008 the difference was awkward and annoying, but > todays I'm afraid that change would be more annoying than > keeping status quo. > > This definitely shouldn't reach stable/11, absolutely. > I will wait to do the MFC until we’re in agreement about it. Regards, Kristof From owner-svn-src-head@freebsd.org Tue Apr 3 07:57:12 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 162E4F53914; Tue, 3 Apr 2018 07:57:12 +0000 (UTC) (envelope-from agapon@gmail.com) Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 785626C79D; Tue, 3 Apr 2018 07:57:11 +0000 (UTC) (envelope-from agapon@gmail.com) Received: by mail-wm0-f49.google.com with SMTP id t67so11440172wmt.0; Tue, 03 Apr 2018 00:57:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=SVgN95nQM25l//65E93jytMXQ3LyHCQ1+8d68QD9l0A=; b=afX/oE+A3Y2p3jxS4Q4XfoHgo1jWnRImdJ0YFR3R64SbWSxXMRDgECwirHaoYCmxLI JHVy6qrNJkNARN49YnuV94kHyIpu3oCDnf6ImBZCh6Pzi/NT18fsaaMAyfr43g8oImR6 tlwNxJ4YS9+MULhu/YS9XvHLlRL+PDnZvEpxst04+aoKy6EJrKwATQ6TMMP3SQ6eQz0v bQUUb8zYQE78uZHn51G24vg11szqiOBisHH4imYtbgqJqLdDQX2mDCGp50/VxmHDcYeL lt8ESjy3uZQTYtTn64GYNp1bNtYqNoX8Rqn8zGv+ru8aJAu89nqW3mfY/4tsjJh2Edc0 BETA== X-Gm-Message-State: ALQs6tBwPkLWG0vHsOBPV4Z0NxlayBodqDntb9FhzZhQE3aZqwashjks hW5A8jocXpcfOxwI86P7Fib+UXGH X-Google-Smtp-Source: AIpwx4+lDySEHBl7QCALVTGqGFGsk7GxFT57KvBugWaGkvVJlFvyHX1wy+EYjNbYFmvneH0Kq4aOdA== X-Received: by 10.46.151.136 with SMTP id y8mr1411382lji.84.1522742229949; Tue, 03 Apr 2018 00:57:09 -0700 (PDT) Received: from [192.168.0.88] (east.meadow.volia.net. [93.72.151.96]) by smtp.googlemail.com with ESMTPSA id 94-v6sm409268lft.85.2018.04.03.00.57.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Apr 2018 00:57:09 -0700 (PDT) Subject: Re: svn commit: r327056 - in head/sys: kern sys x86/acpica x86/x86 To: Bruce Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201712210917.vBL9Hmd0042736@repo.freebsd.org> <20180403012043.K1434@besplex.bde.org> From: Andriy Gapon Openpgp: preference=signencrypt Autocrypt: addr=avg@FreeBSD.org; keydata= xsFNBFm4LIgBEADNB/3lT7f15UKeQ52xCFQx/GqHkSxEdVyLFZTmY3KyNPQGBtyvVyBfprJ7 mAeXZWfhat6cKNRAGZcL5EmewdQuUfQfBdYmKjbw3a9GFDsDNuhDA2QwFt8BmkiVMRYyvI7l N0eVzszWCUgdc3qqM6qqcgBaqsVmJluwpvwp4ZBXmch5BgDDDb1MPO8AZ2QZfIQmplkj8Y6Z AiNMknkmgaekIINSJX8IzRzKD5WwMsin70psE8dpL/iBsA2cpJGzWMObVTtCxeDKlBCNqM1i gTXta1ukdUT7JgLEFZk9ceYQQMJJtUwzWu1UHfZn0Fs29HTqawfWPSZVbulbrnu5q55R4PlQ /xURkWQUTyDpqUvb4JK371zhepXiXDwrrpnyyZABm3SFLkk2bHlheeKU6Yql4pcmSVym1AS4 dV8y0oHAfdlSCF6tpOPf2+K9nW1CFA8b/tw4oJBTtfZ1kxXOMdyZU5fiG7xb1qDgpQKgHUX8 7Rd2T1UVLVeuhYlXNw2F+a2ucY+cMoqz3LtpksUiBppJhw099gEXehcN2JbUZ2TueJdt1FdS ztnZmsHUXLxrRBtGwqnFL7GSd6snpGIKuuL305iaOGODbb9c7ne1JqBbkw1wh8ci6vvwGlzx rexzimRaBzJxlkjNfMx8WpCvYebGMydNoeEtkWldtjTNVsUAtQARAQABzR5BbmRyaXkgR2Fw b24gPGF2Z0BGcmVlQlNELm9yZz7CwZQEEwEIAD4WIQS+LEO7ngQnXA4Bjr538m7TUc1yjwUC WbgsiAIbIwUJBaOagAULCQgHAgYVCAkKCwIEFgIDAQIeAQIXgAAKCRB38m7TUc1yj+JAEACV l9AK/nOWAt/9cufV2fRj0hdOqB1aCshtSrwHk/exXsDa4/FkmegxXQGY+3GWX3deIyesbVRL rYdtdK0dqJyT1SBqXK1h3/at9rxr9GQA6KWOxTjUFURsU7ok/6SIlm8uLRPNKO+yq0GDjgaO LzN+xykuBA0FlhQAXJnpZLcVfPJdWv7sSHGedL5ln8P8rxR+XnmsA5TUaaPcbhTB+mG+iKFj GghASDSfGqLWFPBlX/fpXikBDZ1gvOr8nyMY9nXhgfXpq3B6QCRYKPy58ChrZ5weeJZ29b7/ QdEO8NFNWHjSD9meiLdWQaqo9Y7uUxN3wySc/YUZxtS0bhAd8zJdNPsJYG8sXgKjeBQMVGuT eCAJFEYJqbwWvIXMfVWop4+O4xB+z2YE3jAbG/9tB/GSnQdVSj3G8MS80iLS58frnt+RSEw/ psahrfh0dh6SFHttE049xYiC+cM8J27Aaf0i9RflyITq57NuJm+AHJoU9SQUkIF0nc6lfA+o JRiyRlHZHKoRQkIg4aiKaZSWjQYRl5Txl0IZUP1dSWMX4s3XTMurC/pnja45dge/4ESOtJ9R 8XuIWg45Oq6MeIWdjKddGhRj3OohsltKgkEU3eLKYtB6qRTQypHHUawCXz88uYt5e3w4V16H lCpSTZV/EVHnNe45FVBlvK7k7HFfDDkryM7BTQRZuCyIARAAlq0slcsVboY/+IUJdcbEiJRW be9HKVz4SUchq0z9MZPX/0dcnvz/gkyYA+OuM78dNS7Mbby5dTvOqfpLJfCuhaNYOhlE0wY+ 1T6Tf1f4c/uA3U/YiadukQ3+6TJuYGAdRZD5EqYFIkreARTVWg87N9g0fT9BEqLw9lJtEGDY EWUE7L++B8o4uu3LQFEYxcrb4K/WKmgtmFcm77s0IKDrfcX4doV92QTIpLiRxcOmCC/OCYuO jB1oaaqXQzZrCutXRK0L5XN1Y1PYjIrEzHMIXmCDlLYnpFkK+itlXwlE2ZQxkfMruCWdQXye syl2fynAe8hvp7Mms9qU2r2K9EcJiR5N1t1C2/kTKNUhcRv7Yd/vwusK7BqJbhlng5ZgRx0m WxdntU/JLEntz3QBsBsWM9Y9wf2V4tLv6/DuDBta781RsCB/UrU2zNuOEkSixlUiHxw1dccI 6CVlaWkkJBxmHX22GdDFrcjvwMNIbbyfQLuBq6IOh8nvu9vuItup7qemDG3Ms6TVwA7BD3j+ 3fGprtyW8Fd/RR2bW2+LWkMrqHffAr6Y6V3h5kd2G9Q8ZWpEJk+LG6Mk3fhZhmCnHhDu6CwN MeUvxXDVO+fqc3JjFm5OxhmfVeJKrbCEUJyM8ESWLoNHLqjywdZga4Q7P12g8DUQ1mRxYg/L HgZY3zfKOqcAEQEAAcLBfAQYAQgAJhYhBL4sQ7ueBCdcDgGOvnfybtNRzXKPBQJZuCyIAhsM BQkFo5qAAAoJEHfybtNRzXKPBVwQAKfFy9P7N3OsLDMB56A4Kf+ZT+d5cIx0Yiaf4n6w7m3i ImHHHk9FIetI4Xe54a2IXh4Bq5UkAGY0667eIs+Z1Ea6I2i27Sdo7DxGwq09Qnm/Y65ADvXs 3aBvokCcm7FsM1wky395m8xUos1681oV5oxgqeRI8/76qy0hD9WR65UW+HQgZRIcIjSel9vR XDaD2HLGPTTGr7u4v00UeTMs6qvPsa2PJagogrKY8RXdFtXvweQFz78NbXhluwix2Tb9ETPk LIpDrtzV73CaE2aqBG/KrboXT2C67BgFtnk7T7Y7iKq4/XvEdDWscz2wws91BOXuMMd4c/c4 OmGW9m3RBLufFrOag1q5yUS9QbFfyqL6dftJP3Zq/xe+mr7sbWbhPVCQFrH3r26mpmy841ym dwQnNcsbIGiBASBSKksOvIDYKa2Wy8htPmWFTEOPRpFXdGQ27awcjjnB42nngyCK5ukZDHi6 w0qK5DNQQCkiweevCIC6wc3p67jl1EMFY5+z+zdTPb3h7LeVnGqW0qBQl99vVFgzLxchKcl0 R/paSFgwqXCZhAKMuUHncJuynDOP7z5LirUeFI8qsBAJi1rXpQoLJTVcW72swZ42IdPiboqx NbTMiNOiE36GqMcTPfKylCbF45JNX4nF9ElM0E+Y8gi4cizJYBRr2FBJgay0b9Cp Message-ID: Date: Tue, 3 Apr 2018 10:57:08 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180403012043.K1434@besplex.bde.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 07:57:12 -0000 On 02/04/2018 18:28, Bruce Evans wrote: > On Mon, 2 Apr 2018, Andriy Gapon wrote: > >> On 21/12/2017 11:17, Bruce Evans wrote: >>> Author: bde >>> Date: Thu Dec 21 09:17:48 2017 >>> New Revision: 327056 >>> URL: https://svnweb.freebsd.org/changeset/base/327056 >>> >>> Log: >>>   Use resume_cpus() instead of restart_cpus() to resume from ACPI suspension. >> >> Bruce, >> >> do you plan to merge this to stable/11 and maybe stable/10? > > No.  I'm nit (yet?) set up to merge to stable at all, and this is not the > first thing that I would want to merge. > >> If you'd like, I can do it.  Unless you see any reason not to. > > Please do it. Done in r327056 and r327056. All merge bugs are mine. > It is only a small part of fixing mapping bugs for low memory which first > showed up s incoherent page tables for vm86 (low memory was left unmapped > all the time to handle the problem that ACPI resume needs this mapping for > 1 instruction).  You might need the other fixes.  This one is fairly stand- > alone but doesn't do much by itself. I was just interested in fixing the KPI misuse (restart vs resume). No particular "real" problems that I wanted to address. -- Andriy Gapon From owner-svn-src-head@freebsd.org Tue Apr 3 11:01:52 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 24901F76D0B; Tue, 3 Apr 2018 11:01:52 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C624C7717D; Tue, 3 Apr 2018 11:01:51 +0000 (UTC) (envelope-from andrew@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 C06F3238F0; Tue, 3 Apr 2018 11:01:51 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33B1pVg027435; Tue, 3 Apr 2018 11:01:51 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33B1p3B027414; Tue, 3 Apr 2018 11:01:51 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201804031101.w33B1p3B027414@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Tue, 3 Apr 2018 11:01:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331924 - in head/sys: arm/freescale/vybrid arm/mv arm/nvidia arm/nvidia/tegra124 dev/fdt X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: in head/sys: arm/freescale/vybrid arm/mv arm/nvidia arm/nvidia/tegra124 dev/fdt X-SVN-Commit-Revision: 331924 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 11:01:52 -0000 Author: andrew Date: Tue Apr 3 11:01:50 2018 New Revision: 331924 URL: https://svnweb.freebsd.org/changeset/base/331924 Log: Switch users of fdt_is_enabled to use ofw_bus_node_status_okay. These are equivalent, so to prepare to remove the former move users to call the latter. Sponsored by: DARPA, AFRL Modified: head/sys/arm/freescale/vybrid/vf_ccm.c head/sys/arm/freescale/vybrid/vf_iomuxc.c head/sys/arm/mv/mv_localbus.c head/sys/arm/nvidia/as3722_gpio.c head/sys/arm/nvidia/tegra124/tegra124_xusbpadctl.c head/sys/arm/nvidia/tegra_pinmux.c head/sys/dev/fdt/fdt_pinctrl.c Modified: head/sys/arm/freescale/vybrid/vf_ccm.c ============================================================================== --- head/sys/arm/freescale/vybrid/vf_ccm.c Tue Apr 3 09:46:28 2018 (r331923) +++ head/sys/arm/freescale/vybrid/vf_ccm.c Tue Apr 3 11:01:50 2018 (r331924) @@ -414,7 +414,7 @@ ccm_fdt_set(struct ccm_softc *sc) child = OF_child(child); } - if (!fdt_is_enabled(child)) + if (!ofw_bus_node_status_okay(child)) continue; if ((len = OF_getproplen(child, "clock_names")) > 0) { Modified: head/sys/arm/freescale/vybrid/vf_iomuxc.c ============================================================================== --- head/sys/arm/freescale/vybrid/vf_iomuxc.c Tue Apr 3 09:46:28 2018 (r331923) +++ head/sys/arm/freescale/vybrid/vf_iomuxc.c Tue Apr 3 11:01:50 2018 (r331924) @@ -146,7 +146,7 @@ pinmux_set(struct iomuxc_softc *sc) child = OF_child(child); } - if (!fdt_is_enabled(child)) + if (!ofw_bus_node_status_okay(child)) continue; if ((len = OF_getproplen(child, "iomux_config")) > 0) { Modified: head/sys/arm/mv/mv_localbus.c ============================================================================== --- head/sys/arm/mv/mv_localbus.c Tue Apr 3 09:46:28 2018 (r331923) +++ head/sys/arm/mv/mv_localbus.c Tue Apr 3 11:01:50 2018 (r331924) @@ -272,7 +272,7 @@ localbus_attach(device_t dev) dt_child = OF_peer(dt_child)) { /* Check and process 'status' property. */ - if (!(fdt_is_enabled(dt_child))) + if (!(ofw_bus_node_status_okay(dt_child))) continue; if (!(fdt_pm_is_enabled(dt_child))) Modified: head/sys/arm/nvidia/as3722_gpio.c ============================================================================== --- head/sys/arm/nvidia/as3722_gpio.c Tue Apr 3 09:46:28 2018 (r331923) +++ head/sys/arm/nvidia/as3722_gpio.c Tue Apr 3 11:01:50 2018 (r331924) @@ -271,7 +271,7 @@ int as3722_pinmux_configure(device_t dev, phandle_t cf cfgnode = OF_node_from_xref(cfgxref); for (node = OF_child(cfgnode); node != 0; node = OF_peer(node)) { - if (!fdt_is_enabled(node)) + if (!ofw_bus_node_status_okay(node)) continue; rv = as3722_pinmux_process_node(sc, node); if (rv != 0) Modified: head/sys/arm/nvidia/tegra124/tegra124_xusbpadctl.c ============================================================================== --- head/sys/arm/nvidia/tegra124/tegra124_xusbpadctl.c Tue Apr 3 09:46:28 2018 (r331923) +++ head/sys/arm/nvidia/tegra124/tegra124_xusbpadctl.c Tue Apr 3 11:01:50 2018 (r331924) @@ -968,7 +968,7 @@ process_pad(struct padctl_softc *sc, phandle_t node) } for (node = OF_child(node); node != 0; node = OF_peer(node)) { - if (!fdt_is_enabled(node)) + if (!ofw_bus_node_status_okay(node)) continue; rv = process_lane(sc, node, pad); @@ -1079,7 +1079,7 @@ parse_fdt(struct padctl_softc *sc, phandle_t base_node return (ENXIO); } for (node = OF_child(node); node != 0; node = OF_peer(node)) { - if (!fdt_is_enabled(node)) + if (!ofw_bus_node_status_okay(node)) continue; rv = process_pad(sc, node); if (rv != 0) @@ -1092,7 +1092,7 @@ parse_fdt(struct padctl_softc *sc, phandle_t base_node return (ENXIO); } for (node = OF_child(node); node != 0; node = OF_peer(node)) { - if (!fdt_is_enabled(node)) + if (!ofw_bus_node_status_okay(node)) continue; rv = process_port(sc, node); if (rv != 0) Modified: head/sys/arm/nvidia/tegra_pinmux.c ============================================================================== --- head/sys/arm/nvidia/tegra_pinmux.c Tue Apr 3 09:46:28 2018 (r331923) +++ head/sys/arm/nvidia/tegra_pinmux.c Tue Apr 3 11:01:50 2018 (r331924) @@ -710,7 +710,7 @@ static int pinmux_configure(device_t dev, phandle_t cf for (node = OF_child(cfgnode); node != 0; node = OF_peer(node)) { - if (!fdt_is_enabled(node)) + if (!ofw_bus_node_status_okay(node)) continue; rv = pinmux_process_node(sc, node); } Modified: head/sys/dev/fdt/fdt_pinctrl.c ============================================================================== --- head/sys/dev/fdt/fdt_pinctrl.c Tue Apr 3 09:46:28 2018 (r331923) +++ head/sys/dev/fdt/fdt_pinctrl.c Tue Apr 3 11:01:50 2018 (r331924) @@ -119,7 +119,7 @@ pinctrl_configure_children(device_t pinctrl, phandle_t int i, nconfigs; for (node = OF_child(parent); node != 0; node = OF_peer(node)) { - if (!fdt_is_enabled(node)) + if (!ofw_bus_node_status_okay(node)) continue; pinctrl_configure_children(pinctrl, node); nconfigs = OF_getencprop_alloc(node, "pinctrl-0", From owner-svn-src-head@freebsd.org Tue Apr 3 13:30:41 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DCE82F80B58; Tue, 3 Apr 2018 13:30:40 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9114C7D1BD; Tue, 3 Apr 2018 13:30:40 +0000 (UTC) (envelope-from andrew@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 8C0E825020; Tue, 3 Apr 2018 13:30:40 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33DUeHX090436; Tue, 3 Apr 2018 13:30:40 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33DUeHc090432; Tue, 3 Apr 2018 13:30:40 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201804031330.w33DUeHc090432@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Tue, 3 Apr 2018 13:30:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331925 - head/sys/dev/fdt X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: head/sys/dev/fdt X-SVN-Commit-Revision: 331925 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 13:30:41 -0000 Author: andrew Date: Tue Apr 3 13:30:40 2018 New Revision: 331925 URL: https://svnweb.freebsd.org/changeset/base/331925 Log: Remove fdt_is_enabled, fdt_reg_to_rl, and fdt_get_unit. These are not used by anything in the tree. Sponsored by: DARPA, AFRL Modified: head/sys/dev/fdt/fdt_common.c head/sys/dev/fdt/fdt_common.h Modified: head/sys/dev/fdt/fdt_common.c ============================================================================== --- head/sys/dev/fdt/fdt_common.c Tue Apr 3 11:01:50 2018 (r331924) +++ head/sys/dev/fdt/fdt_common.c Tue Apr 3 13:30:40 2018 (r331925) @@ -335,28 +335,6 @@ fdt_depth_search_compatible(phandle_t start, const cha } int -fdt_is_enabled(phandle_t node) -{ - char *stat; - int ena, len; - - len = OF_getprop_alloc(node, "status", sizeof(char), - (void **)&stat); - - if (len <= 0) - /* It is OK if no 'status' property. */ - return (1); - - /* Anything other than 'okay' means disabled. */ - ena = 0; - if (strncmp((char *)stat, "okay", len) == 0) - ena = 1; - - OF_prop_free(stat); - return (ena); -} - -int fdt_is_type(phandle_t node, const char *typestr) { char type[FDT_TYPE_LEN]; @@ -475,59 +453,6 @@ fdt_regsize(phandle_t node, u_long *base, u_long *size } int -fdt_reg_to_rl(phandle_t node, struct resource_list *rl) -{ - u_long end, count, start; - pcell_t *reg, *regptr; - pcell_t addr_cells, size_cells; - int tuple_size, tuples; - int i, rv; - long busaddr, bussize; - - if (fdt_addrsize_cells(OF_parent(node), &addr_cells, &size_cells) != 0) - return (ENXIO); - if (fdt_get_range(OF_parent(node), 0, &busaddr, &bussize)) { - busaddr = 0; - bussize = 0; - } - - tuple_size = sizeof(pcell_t) * (addr_cells + size_cells); - tuples = OF_getprop_alloc(node, "reg", tuple_size, (void **)®); - debugf("addr_cells = %d, size_cells = %d\n", addr_cells, size_cells); - debugf("tuples = %d, tuple size = %d\n", tuples, tuple_size); - if (tuples <= 0) - /* No 'reg' property in this node. */ - return (0); - - regptr = reg; - for (i = 0; i < tuples; i++) { - - rv = fdt_data_to_res(reg, addr_cells, size_cells, &start, - &count); - if (rv != 0) { - resource_list_free(rl); - goto out; - } - reg += addr_cells + size_cells; - - /* Calculate address range relative to base. */ - start += busaddr; - end = start + count - 1; - - debugf("reg addr start = %lx, end = %lx, count = %lx\n", start, - end, count); - - resource_list_add(rl, SYS_RES_MEMORY, i, start, end, - count); - } - rv = 0; - -out: - OF_prop_free(regptr); - return (rv); -} - -int fdt_get_phyaddr(phandle_t node, device_t dev, int *phy_addr, void **phy_sc) { phandle_t phy_node; @@ -710,17 +635,6 @@ fdt_get_mem_regions(struct mem_region *mr, int *mrcnt, rv = 0; out: return (rv); -} - -int -fdt_get_unit(device_t dev) -{ - const char * name; - - name = ofw_bus_get_name(dev); - name = strchr(name, '@') + 1; - - return (strtol(name,NULL,0)); } int Modified: head/sys/dev/fdt/fdt_common.h ============================================================================== --- head/sys/dev/fdt/fdt_common.h Tue Apr 3 11:01:50 2018 (r331924) +++ head/sys/dev/fdt/fdt_common.h Tue Apr 3 13:30:40 2018 (r331925) @@ -91,13 +91,10 @@ int fdt_get_range(phandle_t, int, u_long *, u_long *); int fdt_immr_addr(vm_offset_t); int fdt_regsize(phandle_t, u_long *, u_long *); int fdt_is_compatible_strict(phandle_t, const char *); -int fdt_is_enabled(phandle_t); int fdt_pm_is_enabled(phandle_t); int fdt_is_type(phandle_t, const char *); int fdt_parent_addr_cells(phandle_t); -int fdt_reg_to_rl(phandle_t, struct resource_list *); int fdt_pm(phandle_t); -int fdt_get_unit(device_t); int fdt_get_chosen_bootargs(char *bootargs, size_t max_size); #endif /* _FDT_COMMON_H_ */ From owner-svn-src-head@freebsd.org Tue Apr 3 13:54:39 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ADDFBF82461; Tue, 3 Apr 2018 13:54:39 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 407887E5B5; Tue, 3 Apr 2018 13:54:39 +0000 (UTC) (envelope-from jtl@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 3B4C02550B; Tue, 3 Apr 2018 13:54:39 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33Dsdnv034401; Tue, 3 Apr 2018 13:54:39 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33DsdZ6034400; Tue, 3 Apr 2018 13:54:39 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201804031354.w33DsdZ6034400@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Tue, 3 Apr 2018 13:54:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331926 - head/sys/netinet X-SVN-Group: head X-SVN-Commit-Author: jtl X-SVN-Commit-Paths: head/sys/netinet X-SVN-Commit-Revision: 331926 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 13:54:39 -0000 Author: jtl Date: Tue Apr 3 13:54:38 2018 New Revision: 331926 URL: https://svnweb.freebsd.org/changeset/base/331926 Log: r330675 introduced an extra window check in the LRO code to ensure it captured and reported the highest window advertisement with the same SEQ/ACK. However, the window comparison uses modulo 2**16 math, rather than directly comparing the absolute values. Because windows use absolute values and not modulo 2**16 math (i.e. they don't wrap), we need to compare the absolute values. Reviewed by: gallatin MFC after: 3 days Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D14937 Modified: head/sys/netinet/tcp_seq.h Modified: head/sys/netinet/tcp_seq.h ============================================================================== --- head/sys/netinet/tcp_seq.h Tue Apr 3 13:30:40 2018 (r331925) +++ head/sys/netinet/tcp_seq.h Tue Apr 3 13:54:38 2018 (r331926) @@ -47,10 +47,10 @@ #define SEQ_MIN(a, b) ((SEQ_LT(a, b)) ? (a) : (b)) #define SEQ_MAX(a, b) ((SEQ_GT(a, b)) ? (a) : (b)) -#define WIN_LT(a,b) ((short)(ntohs(a)-ntohs(b)) < 0) -#define WIN_LEQ(a,b) ((short)(ntohs(a)-ntohs(b)) <= 0) -#define WIN_GT(a,b) ((short)(ntohs(a)-ntohs(b)) > 0) -#define WIN_GEQ(a,b) ((short)(ntohs(a)-ntohs(b)) >= 0) +#define WIN_LT(a,b) (ntohs(a) < ntohs(b)) +#define WIN_LEQ(a,b) (ntohs(a) <= ntohs(b)) +#define WIN_GT(a,b) (ntohs(a) > ntohs(b)) +#define WIN_GEQ(a,b) (ntohs(a) >= ntohs(b)) #define WIN_MIN(a, b) ((WIN_LT(a, b)) ? (a) : (b)) #define WIN_MAX(a, b) ((WIN_GT(a, b)) ? (a) : (b)) From owner-svn-src-head@freebsd.org Tue Apr 3 16:06:49 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F210F59197; Tue, 3 Apr 2018 16:06:49 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 2B30C848E5; Tue, 3 Apr 2018 16:06:48 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id w33G6l2G052749 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 3 Apr 2018 09:06:47 -0700 (PDT) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id w33G6kN0052748; Tue, 3 Apr 2018 09:06:46 -0700 (PDT) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Tue, 3 Apr 2018 09:06:46 -0700 From: Gleb Smirnoff To: Kristof Provost Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331546 - head/etc/rc.d Message-ID: <20180403160646.GE1917@FreeBSD.org> References: <201803260936.w2Q9aMfD082758@repo.freebsd.org> <20180402220430.GD1917@FreeBSD.org> <4F543A96-C6B1-4FF0-A501-BC6C7FD3F26A@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4F543A96-C6B1-4FF0-A501-BC6C7FD3F26A@FreeBSD.org> User-Agent: Mutt/1.9.3 (2018-01-21) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 16:06:49 -0000 On Tue, Apr 03, 2018 at 08:49:09AM +0200, Kristof Provost wrote: K> On 3 Apr 2018, at 0:04, Gleb Smirnoff wrote: K> > I just want to note that this is a huge change of behaviour K> > of pf(4) for a user. Over a decade everybody has been used K> > to the difference between "reload" and "resync". K> K> There is no difference. r330105 removed the ‘$pf_program -Fnat -Fqueue K> -Frules -FSources -Finfo -FTables -Fosfp’ line, but this never K> actually did what the author thought it did. K> pfctl only ever performed the last ‘-F’, not all of them, so all K> this ever did was flush the OS fingerprints information. Clearly K> that’s not what was intended. K> K> pf never actually breaks existing connections, because existing states K> keep using the rule that created them, regardless of the current rules. K> It wouldn’t have broken connections with resync either. A K> ‘restart’ will, because ‘start’ does ‘pfctl -F all’. K> K> If the flush had actually done what was intended it’d arguably have K> been a security issue, because reloading rules would then (briefly) open K> the firewall, allowing all traffic to pass and establish state. Hmm, may be I am wrong, but back when I was actively working with pf, the "reload" command would break the ssh connection I am using, so I have taught myself to use "resync". If I am wrong, please go forward :) -- Gleb Smirnoff From owner-svn-src-head@freebsd.org Tue Apr 3 16:07:53 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7529EF592F7; Tue, 3 Apr 2018 16:07:53 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 0182584AD4; Tue, 3 Apr 2018 16:07:52 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id w33G7pRg052790 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 3 Apr 2018 09:07:51 -0700 (PDT) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id w33G7p5m052789; Tue, 3 Apr 2018 09:07:51 -0700 (PDT) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Tue, 3 Apr 2018 09:07:51 -0700 From: Gleb Smirnoff To: Kristof Provost Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331546 - head/etc/rc.d Message-ID: <20180403160751.GF1917@FreeBSD.org> References: <201803260936.w2Q9aMfD082758@repo.freebsd.org> <20180402220430.GD1917@FreeBSD.org> <4F543A96-C6B1-4FF0-A501-BC6C7FD3F26A@FreeBSD.org> <20180403160646.GE1917@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180403160646.GE1917@FreeBSD.org> User-Agent: Mutt/1.9.3 (2018-01-21) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 16:07:53 -0000 On Tue, Apr 03, 2018 at 09:06:46AM -0700, Gleb Smirnoff wrote: T> Hmm, may be I am wrong, but back when I was actively working with pf, T> the "reload" command would break the ssh connection I am using, so T> I have taught myself to use "resync". Just checked on r328916, and it doesn't happen. -- Gleb Smirnoff From owner-svn-src-head@freebsd.org Tue Apr 3 16:12:34 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E7C4BF59B11; Tue, 3 Apr 2018 16:12:33 +0000 (UTC) (envelope-from srs0=rwrb=gy=freebsd.org=kp@codepro.be) Received: from venus.codepro.be (venus.codepro.be [IPv6:2a01:4f8:162:1127::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.codepro.be", Issuer "Gandi Standard SSL CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5A8BB851D0; Tue, 3 Apr 2018 16:12:30 +0000 (UTC) (envelope-from srs0=rwrb=gy=freebsd.org=kp@codepro.be) Received: from [10.0.2.164] (ptr-8ripyyg3pshqansoctr.18120a2.ip6.access.telenet.be [IPv6:2a02:1811:2419:4e02:701f:5a9f:25d:ceef]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id DE0159503; Tue, 3 Apr 2018 18:12:27 +0200 (CEST) From: "Kristof Provost" To: "Gleb Smirnoff" Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331546 - head/etc/rc.d Date: Tue, 03 Apr 2018 18:12:26 +0200 X-Mailer: MailMate (2.0BETAr6106) Message-ID: <15CEFBCD-8875-438D-B370-3468DC637A53@FreeBSD.org> In-Reply-To: <20180403160646.GE1917@FreeBSD.org> References: <201803260936.w2Q9aMfD082758@repo.freebsd.org> <20180402220430.GD1917@FreeBSD.org> <4F543A96-C6B1-4FF0-A501-BC6C7FD3F26A@FreeBSD.org> <20180403160646.GE1917@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; markup=markdown Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 16:12:34 -0000 On 3 Apr 2018, at 18:06, Gleb Smirnoff wrote: > On Tue, Apr 03, 2018 at 08:49:09AM +0200, Kristof Provost wrote: > K> On 3 Apr 2018, at 0:04, Gleb Smirnoff wrote: > K> > I just want to note that this is a huge change of behaviour > K> > of pf(4) for a user. Over a decade everybody has been used > K> > to the difference between "reload" and "resync". > K> > K> There is no difference. r330105 removed the ‘$pf_program -Fnat > -Fqueue > K> -Frules -FSources -Finfo -FTables -Fosfp’ line, but this never > K> actually did what the author thought it did. > K> pfctl only ever performed the last ‘-F’, not all of them, so > all > K> this ever did was flush the OS fingerprints information. Clearly > K> that’s not what was intended. > K> > K> pf never actually breaks existing connections, because existing > states > K> keep using the rule that created them, regardless of the current > rules. > K> It wouldn’t have broken connections with resync either. A > K> ‘restart’ will, because ‘start’ does ‘pfctl -F all’. > K> > K> If the flush had actually done what was intended it’d arguably > have > K> been a security issue, because reloading rules would then (briefly) > open > K> the firewall, allowing all traffic to pass and establish state. > > Hmm, may be I am wrong, but back when I was actively working with pf, > the "reload" command would break the ssh connection I am using, so > I have taught myself to use "resync". > Apparently reload used to have a ‘${pf_program:-/sbin/pfctl} -Fa’, which would have flushed everything and killed your connection. That was removed back in 2005 (April 4th, so pretty much exactly 13 years ago), and replaced by the erroneous ‘-Fnat -Fqueue -Frules -FSources -Finfo -FTables -Fosfp’ version. Regards, Kristof From owner-svn-src-head@freebsd.org Tue Apr 3 17:16:07 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CDAAFF6FCA4; Tue, 3 Apr 2018 17:16:07 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 80BE987F2E; Tue, 3 Apr 2018 17:16:07 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7BB2D2767F; Tue, 3 Apr 2018 17:16:07 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33HG7ig062388; Tue, 3 Apr 2018 17:16:07 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33HG7Yc062382; Tue, 3 Apr 2018 17:16:07 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201804031716.w33HG7Yc062382@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 3 Apr 2018 17:16:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331931 - in head/sys: amd64/amd64 i386/i386 x86/x86 X-SVN-Group: head X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in head/sys: amd64/amd64 i386/i386 x86/x86 X-SVN-Commit-Revision: 331931 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 17:16:08 -0000 Author: avg Date: Tue Apr 3 17:16:06 2018 New Revision: 331931 URL: https://svnweb.freebsd.org/changeset/base/331931 Log: fix i386 build with CPU_ELAN (LINT for instance) after r331878 x86/cpu_machdep.c now needs to include elan_mmcr.h when CPU_ELAN is set. While here, also remove the now unneeded inclusion of isareg.h in i386 and amd64 vm_machdep.c. Reported by: lwhsu MFC after: 14 days X-MFC with: r331878 Modified: head/sys/amd64/amd64/vm_machdep.c head/sys/i386/i386/vm_machdep.c head/sys/x86/x86/cpu_machdep.c Modified: head/sys/amd64/amd64/vm_machdep.c ============================================================================== --- head/sys/amd64/amd64/vm_machdep.c Tue Apr 3 15:14:30 2018 (r331930) +++ head/sys/amd64/amd64/vm_machdep.c Tue Apr 3 17:16:06 2018 (r331931) @@ -82,8 +82,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include - _Static_assert(OFFSETOF_CURTHREAD == offsetof(struct pcpu, pc_curthread), "OFFSETOF_CURTHREAD does not correspond with offset of pc_curthread."); _Static_assert(OFFSETOF_CURPCB == offsetof(struct pcpu, pc_curpcb), Modified: head/sys/i386/i386/vm_machdep.c ============================================================================== --- head/sys/i386/i386/vm_machdep.c Tue Apr 3 15:14:30 2018 (r331930) +++ head/sys/i386/i386/vm_machdep.c Tue Apr 3 17:16:06 2018 (r331931) @@ -79,18 +79,12 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef CPU_ELAN -#include -#endif - #include #include #include #include #include #include - -#include #ifndef NSFBUFS #define NSFBUFS (512 + maxusers * 16) Modified: head/sys/x86/x86/cpu_machdep.c ============================================================================== --- head/sys/x86/x86/cpu_machdep.c Tue Apr 3 15:14:30 2018 (r331930) +++ head/sys/x86/x86/cpu_machdep.c Tue Apr 3 17:16:06 2018 (r331931) @@ -85,6 +85,9 @@ __FBSDID("$FreeBSD$"); #ifdef SMP #include #endif +#ifdef CPU_ELAN +#include +#endif #include #include From owner-svn-src-head@freebsd.org Tue Apr 3 18:41:28 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7D9FCF7632A; Tue, 3 Apr 2018 18:41:28 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 29C916C127; Tue, 3 Apr 2018 18:41:28 +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 24A81484; Tue, 3 Apr 2018 18:41:28 +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 w33IfS6N094696; Tue, 3 Apr 2018 18:41:28 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33IfSJ3094695; Tue, 3 Apr 2018 18:41:28 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201804031841.w33IfSJ3094695@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 3 Apr 2018 18:41:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331934 - head/sys/compat/linuxkpi/common/src X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/compat/linuxkpi/common/src X-SVN-Commit-Revision: 331934 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 18:41:28 -0000 Author: markj Date: Tue Apr 3 18:41:27 2018 New Revision: 331934 URL: https://svnweb.freebsd.org/changeset/base/331934 Log: Wrap long lines. MFC after: 3 days Modified: head/sys/compat/linuxkpi/common/src/linux_schedule.c Modified: head/sys/compat/linuxkpi/common/src/linux_schedule.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_schedule.c Tue Apr 3 18:39:49 2018 (r331933) +++ head/sys/compat/linuxkpi/common/src/linux_schedule.c Tue Apr 3 18:41:27 2018 (r331934) @@ -267,7 +267,8 @@ linux_wait_event_common(wait_queue_head_t *wqh, wait_q PHOLD(task->task_thread->td_proc); sleepq_lock(task); if (atomic_read(&task->state) != TASK_WAKING) { - ret = linux_add_to_sleepqueue(task, task, "wevent", timeout, state); + ret = linux_add_to_sleepqueue(task, task, "wevent", timeout, + state); } else { sleepq_release(task); ret = 0; @@ -300,7 +301,8 @@ linux_schedule_timeout(int timeout) sleepq_lock(task); state = atomic_read(&task->state); if (state != TASK_WAKING) { - ret = linux_add_to_sleepqueue(task, task, "sched", timeout, state); + ret = linux_add_to_sleepqueue(task, task, "sched", timeout, + state); } else { sleepq_release(task); ret = 0; @@ -368,7 +370,8 @@ linux_wait_on_bit_timeout(unsigned long *word, int bit break; } set_task_state(task, state); - ret = linux_add_to_sleepqueue(wchan, task, "wbit", timeout, state); + ret = linux_add_to_sleepqueue(wchan, task, "wbit", timeout, + state); if (ret != 0) break; } From owner-svn-src-head@freebsd.org Tue Apr 3 18:43:00 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DB975F764DB; Tue, 3 Apr 2018 18:43:00 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 89BE86C373; Tue, 3 Apr 2018 18:43:00 +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 84A265CE; Tue, 3 Apr 2018 18:43:00 +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 w33Ih0kO098218; Tue, 3 Apr 2018 18:43:00 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33Ih0JA098217; Tue, 3 Apr 2018 18:43:00 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201804031843.w33Ih0JA098217@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 3 Apr 2018 18:43:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331935 - head/usr.bin/vtfontcvt X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/usr.bin/vtfontcvt X-SVN-Commit-Revision: 331935 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 18:43:01 -0000 Author: emaste Date: Tue Apr 3 18:43:00 2018 New Revision: 331935 URL: https://svnweb.freebsd.org/changeset/base/331935 Log: vtfontcvt: allow .bdf characters less than full height Sponsored by: The FreeBSD Foundation Modified: head/usr.bin/vtfontcvt/vtfontcvt.c Modified: head/usr.bin/vtfontcvt/vtfontcvt.c ============================================================================== --- head/usr.bin/vtfontcvt/vtfontcvt.c Tue Apr 3 18:41:27 2018 (r331934) +++ head/usr.bin/vtfontcvt/vtfontcvt.c Tue Apr 3 18:43:00 2018 (r331935) @@ -265,10 +265,23 @@ parse_bdf(FILE *fp, unsigned int map_idx) if (strncmp(ln, "BITMAP", 6) == 0 && (ln[6] == ' ' || ln[6] == '\0')) { + /* + * Assume that the next _height_ lines are bitmap + * data. ENDCHAR is allowed to terminate the bitmap + * early but is not otherwise checked; any extra data + * is ignored. + */ for (i = 0; i < height; i++) { if ((ln = fgetln(fp, &length)) == NULL) errx(1, "Unexpected EOF!"); ln[length - 1] = '\0'; + if (strcmp(ln, "ENDCHAR") == 0) { + memset(bytes + i * wbytes, 0, + (height - i) * wbytes); + memset(bytes_r + i * wbytes, 0, + (height - i) * wbytes); + break; + } sscanf(ln, "%x", &line); if (parse_bitmap_line(bytes + i * wbytes, bytes_r + i * wbytes, line, dwidth) != 0) From owner-svn-src-head@freebsd.org Tue Apr 3 18:52:40 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2AD98F76D6F; Tue, 3 Apr 2018 18:52:40 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CD5C46CA2E; Tue, 3 Apr 2018 18:52:39 +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 C789D780; Tue, 3 Apr 2018 18:52:39 +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 w33Iqdtl013529; Tue, 3 Apr 2018 18:52:39 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33IqdIQ013512; Tue, 3 Apr 2018 18:52:39 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201804031852.w33IqdIQ013512@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Tue, 3 Apr 2018 18:52:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331936 - in head/lib/libc: stdio tests/stdio X-SVN-Group: head X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in head/lib/libc: stdio tests/stdio X-SVN-Commit-Revision: 331936 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 18:52:40 -0000 Author: cy Date: Tue Apr 3 18:52:38 2018 New Revision: 331936 URL: https://svnweb.freebsd.org/changeset/base/331936 Log: Add new gets_s(3) stdio function. This implements the gets_s(3) function as documented at http://en.cppreference.com/w/c/io/gets. It facilitates the optional removal of gets(3). Reviewed by: ed MFC after: 2 weeks Relnotes: yes Differential Revision: https://reviews.freebsd.org/D12785 Added: head/lib/libc/stdio/gets_s.c - copied, changed from r326083, head/lib/libc/stdio/gets.c head/lib/libc/tests/stdio/gets_s_test.c (contents, props changed) Modified: head/lib/libc/stdio/Makefile.inc head/lib/libc/stdio/Symbol.map head/lib/libc/stdio/fgets.3 head/lib/libc/tests/stdio/Makefile Modified: head/lib/libc/stdio/Makefile.inc ============================================================================== --- head/lib/libc/stdio/Makefile.inc Tue Apr 3 18:43:00 2018 (r331935) +++ head/lib/libc/stdio/Makefile.inc Tue Apr 3 18:52:38 2018 (r331936) @@ -14,7 +14,7 @@ SRCS+= _flock_stub.c asprintf.c clrerr.c dprintf.c \ fputwc.c fputws.c fread.c freopen.c fscanf.c fseek.c fsetpos.c \ ftell.c funopen.c fvwrite.c fwalk.c fwide.c fwprintf.c fwscanf.c \ fwrite.c getc.c getchar.c getdelim.c getline.c \ - gets.c getw.c getwc.c getwchar.c makebuf.c mktemp.c \ + gets.c gets_s.c getw.c getwc.c getwchar.c makebuf.c mktemp.c \ open_memstream.c open_wmemstream.c \ perror.c printf.c printf-pos.c putc.c putchar.c \ puts.c putw.c putwc.c putwchar.c \ @@ -50,6 +50,7 @@ MLINKS+=ferror.3 ferror_unlocked.3 \ ferror.3 fileno.3 ferror.3 fileno_unlocked.3 MLINKS+=fflush.3 fpurge.3 MLINKS+=fgets.3 gets.3 +MLINKS+=fgets.3 gets_s.3 MLINKS+=flockfile.3 ftrylockfile.3 flockfile.3 funlockfile.3 MLINKS+=fopen.3 fdopen.3 fopen.3 freopen.3 fopen.3 fmemopen.3 MLINKS+=fputs.3 puts.3 Modified: head/lib/libc/stdio/Symbol.map ============================================================================== --- head/lib/libc/stdio/Symbol.map Tue Apr 3 18:43:00 2018 (r331935) +++ head/lib/libc/stdio/Symbol.map Tue Apr 3 18:52:38 2018 (r331936) @@ -165,6 +165,7 @@ FBSD_1.3 { FBSD_1.4 { fdclose; fopencookie; + gets_s; }; FBSDprivate_1.0 { Modified: head/lib/libc/stdio/fgets.3 ============================================================================== --- head/lib/libc/stdio/fgets.3 Tue Apr 3 18:43:00 2018 (r331935) +++ head/lib/libc/stdio/fgets.3 Tue Apr 3 18:52:38 2018 (r331936) @@ -46,6 +46,8 @@ .Ft char * .Fn fgets "char * restrict str" "int size" "FILE * restrict stream" .Ft char * +.Fn gets_s "char *str" "rsize_t size" +.Ft char * .Fn gets "char *str" .Sh DESCRIPTION The @@ -65,6 +67,17 @@ If any characters are read and there is no error, a character is appended to end the string. .Pp The +.Fn gets_s +function +is equivalent to +.Fn fgets +with a +.Fa stream +of +.Dv stdin , +except that the newline character (if any) is not stored in the string. +.Pp +The .Fn gets function is equivalent to @@ -80,7 +93,8 @@ It is the caller's responsibility to ensure that the i if any, is sufficiently short to fit in the string. .Sh RETURN VALUES Upon successful completion, -.Fn fgets +.Fn fgets , +.Fn gets_s , and .Fn gets return @@ -94,7 +108,8 @@ they return .Dv NULL and the buffer contents are indeterminate. The -.Fn fgets +.Fn fgets , +.Fn gets_s , and .Fn gets functions @@ -141,6 +156,13 @@ and .Fn gets conform to .St -isoC-99 . +.Fn gets_s +conforms to +.St -isoC-2011 +K.3.7.4.1. +.Fn gets +has been removed from +.St -isoC-2011 . .Sh SECURITY CONSIDERATIONS The .Fn gets Copied and modified: head/lib/libc/stdio/gets_s.c (from r326083, head/lib/libc/stdio/gets.c) ============================================================================== --- head/lib/libc/stdio/gets.c Wed Nov 22 01:53:59 2017 (r326083, copy source) +++ head/lib/libc/stdio/gets_s.c Tue Apr 3 18:52:38 2018 (r331936) @@ -3,6 +3,8 @@ * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. + * Copyright (c) 2017, 2018 + * Cyril S. E. Schubert. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. @@ -32,49 +34,69 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)gets.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ #include __FBSDID("$FreeBSD$"); #include "namespace.h" +#include #include +#include #include #include "un-namespace.h" #include "libc_private.h" #include "local.h" -__warn_references(gets, "warning: this program uses gets(), which is unsafe."); - -char * -gets(char *buf) +static inline char * +_gets_s(char *buf, rsize_t n) { int c; - char *s, *ret; - static int warned; - static const char w[] = - "warning: this program uses gets(), which is unsafe.\n"; + char *s; - FLOCKFILE_CANCELSAFE(stdin); ORIENT(stdin, -1); - if (!warned) { - (void) _write(STDERR_FILENO, w, sizeof(w) - 1); - warned = 1; - } - for (s = buf; (c = __sgetc(stdin)) != '\n'; ) { + for (s = buf, n--; (c = __sgetc(stdin)) != '\n' && n > 0 ; n--) { if (c == EOF) { if (s == buf) { - ret = NULL; - goto end; + return (NULL); } else break; } else *s++ = c; } + + /* + * If end of buffer reached, discard until \n or eof. + * Then throw an error. + */ + if (n == 0) { + /* discard */ + while ((c = __sgetc(stdin)) != '\n' && c != EOF); + /* throw the error after lock released prior to exit */ + __throw_constraint_handler_s("gets_s : end of buffer", E2BIG); + return (NULL); + } *s = 0; - ret = buf; -end: + return (buf); +} + +/* ISO/IEC 9899:2011 K.3.7.4.1 */ +char * +gets_s(char *buf, rsize_t n) +{ + char *ret; + if (buf == NULL) { + __throw_constraint_handler_s("gets_s : str is NULL", EINVAL); + return(NULL); + } else if (n > RSIZE_MAX) { + __throw_constraint_handler_s("gets_s : n > RSIZE_MAX", + EINVAL); + return(NULL); + } else if (n == 0) { + __throw_constraint_handler_s("gets_s : n == 0", EINVAL); + return(NULL); + } + + FLOCKFILE_CANCELSAFE(stdin); + ret = _gets_s(buf, n); FUNLOCKFILE_CANCELSAFE(); return (ret); } Modified: head/lib/libc/tests/stdio/Makefile ============================================================================== --- head/lib/libc/tests/stdio/Makefile Tue Apr 3 18:43:00 2018 (r331935) +++ head/lib/libc/tests/stdio/Makefile Tue Apr 3 18:52:38 2018 (r331936) @@ -7,6 +7,7 @@ ATF_TESTS_C+= fmemopen2_test ATF_TESTS_C+= fopen2_test ATF_TESTS_C+= freopen_test ATF_TESTS_C+= getdelim_test +ATF_TESTS_C+= gets_s_test ATF_TESTS_C+= mkostemp_test ATF_TESTS_C+= open_memstream2_test ATF_TESTS_C+= open_wmemstream_test Added: head/lib/libc/tests/stdio/gets_s_test.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libc/tests/stdio/gets_s_test.c Tue Apr 3 18:52:38 2018 (r331936) @@ -0,0 +1,145 @@ +/*- + * Copyright (c) 2017 Cyril S. E. Schubert. 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 REGENTS 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 REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +static errno_t error_code; +static const char * message; + +void +h(const char * msg, void * ptr __unused, errno_t error) +{ + error_code = error; + message = msg; +} + +/* null ptr */ +ATF_TC_WITHOUT_HEAD(null_ptr); +ATF_TC_BODY(null_ptr, tc) +{ + ATF_CHECK_MSG(gets_s(NULL, 1) == NULL, + "gets_s() failed to handle NULL pointer"); +} + +/* normal */ +ATF_TC_WITHOUT_HEAD(normal); +ATF_TC_BODY(normal, tc) +{ + pid_t kidpid; + int fd[2]; + int nfd; + + // close(STDIN_FILENO); + // close(STDOUT_FILENO); + pipe(fd); + + if ((kidpid = fork()) == 0) { + char b[10]; + + close(fd[1]); + nfd = dup2(fd[0], 0); + close(fd[0]); + stdin = fdopen(nfd, "r"); + ATF_CHECK_MSG(gets_s(b, sizeof(b)) == 0, "gets_s() normal failed"); + fclose(stdin); + } else { + int stat; + + close(fd[0]); + stdout = fdopen(fd[1], "w"); + puts("a sting"); + fclose(stdout); + (void) waitpid(kidpid, &stat, WEXITED); + } +} + +/* n > rmax */ +ATF_TC_WITHOUT_HEAD(n_gt_rmax); +ATF_TC_BODY(n_gt_rmax, tc) +{ + char b; + + ATF_CHECK_MSG(gets_s(&b, RSIZE_MAX + 1) == NULL, + "gets_s() n > RSIZE_MAX"); +} + +/* n == 0 */ +ATF_TC_WITHOUT_HEAD(n_eq_zero); +ATF_TC_BODY(n_eq_zero, tc) +{ + char b; + + ATF_CHECK_MSG(gets_s(&b, 0) == NULL, "gets_s() n is zero"); +} + +/* n > rmax, handler */ +ATF_TC_WITHOUT_HEAD(n_gt_rmax_handler); +ATF_TC_BODY(n_gt_rmax_handler, tc) +{ + char b; + + error_code = 0; + message = NULL; + set_constraint_handler_s(h); + ATF_CHECK_MSG(gets_s(&b, RSIZE_MAX + 1) == NULL, "gets_s() n > RSIZE_MAX"); + ATF_CHECK_MSG(error_code > 0, "gets_s() error code is %d", error_code); + ATF_CHECK_MSG(strcmp(message, "gets_s : n > RSIZE_MAX") == 0, "gets_s(): incorrect error message"); +} + +/* n == 0, handler */ +ATF_TC_WITHOUT_HEAD(n_eq_zero_handler); +ATF_TC_BODY(n_eq_zero_handler, tc) +{ + char b; + + error_code = 0; + message = NULL; + set_constraint_handler_s(h); + ATF_CHECK(gets_s(&b, 0) == NULL); + ATF_CHECK_MSG(error_code > 0, "gets_s() error code is %d", error_code); + ATF_CHECK_MSG(strcmp(message, "gets_s : n == 0") == 0, "gets_s(): incorrect error message"); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, null_ptr); + ATF_TP_ADD_TC(tp, normal); + ATF_TP_ADD_TC(tp, n_gt_rmax); + ATF_TP_ADD_TC(tp, n_eq_zero); + ATF_TP_ADD_TC(tp, n_gt_rmax_handler); + ATF_TP_ADD_TC(tp, n_eq_zero_handler); + return (atf_no_error()); +} From owner-svn-src-head@freebsd.org Tue Apr 3 19:51:24 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BD665F7AFAD; Tue, 3 Apr 2018 19:51:24 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 688B86FB97; Tue, 3 Apr 2018 19:51:24 +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 6358E1064; Tue, 3 Apr 2018 19:51:24 +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 w33JpOaZ099166; Tue, 3 Apr 2018 19:51:24 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33JpOmP099165; Tue, 3 Apr 2018 19:51:24 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201804031951.w33JpOmP099165@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Tue, 3 Apr 2018 19:51:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331942 - head/lib/libc/stdio X-SVN-Group: head X-SVN-Commit-Author: cy X-SVN-Commit-Paths: head/lib/libc/stdio X-SVN-Commit-Revision: 331942 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 19:51:24 -0000 Author: cy Date: Tue Apr 3 19:51:23 2018 New Revision: 331942 URL: https://svnweb.freebsd.org/changeset/base/331942 Log: Add gets_s(3) to the man page title (noticed by ed@). While I'm at it correct the update date in the man page. Reported by: ed@ MFC after: 2 weeks X-MFC with: r331936 Differential Revision: https://reviews.freebsd.org/D12785 Modified: head/lib/libc/stdio/fgets.3 Modified: head/lib/libc/stdio/fgets.3 ============================================================================== --- head/lib/libc/stdio/fgets.3 Tue Apr 3 19:39:06 2018 (r331941) +++ head/lib/libc/stdio/fgets.3 Tue Apr 3 19:51:23 2018 (r331942) @@ -32,12 +32,13 @@ .\" @(#)fgets.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd May 5, 2012 +.Dd April 3, 2018 .Dt FGETS 3 .Os .Sh NAME .Nm fgets , -.Nm gets +.Nm gets , +.Nm gets_s .Nd get a line from a stream .Sh LIBRARY .Lb libc From owner-svn-src-head@freebsd.org Tue Apr 3 20:14:38 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 816E5F7CA32; Tue, 3 Apr 2018 20:14:38 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2FA7570E02; Tue, 3 Apr 2018 20:14:38 +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 250471526; Tue, 3 Apr 2018 20:14:38 +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 w33KEbrl036306; Tue, 3 Apr 2018 20:14:37 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33KEbY2036305; Tue, 3 Apr 2018 20:14:37 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201804032014.w33KEbY2036305@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Tue, 3 Apr 2018 20:14:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331943 - head/include X-SVN-Group: head X-SVN-Commit-Author: cy X-SVN-Commit-Paths: head/include X-SVN-Commit-Revision: 331943 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 20:14:38 -0000 Author: cy Date: Tue Apr 3 20:14:37 2018 New Revision: 331943 URL: https://svnweb.freebsd.org/changeset/base/331943 Log: Include update to stdio.h missed in r331936. In my attempt to limit the commit in r331936 to only the gets_s() commit and not include unrelated patches in my tree, this patch was missed. Reported by: pfg MFC after: 2 weeks X-MFC with: r331936 Differential Revision: https://reviews.freebsd.org/D12785 Modified: head/include/stdio.h Modified: head/include/stdio.h ============================================================================== --- head/include/stdio.h Tue Apr 3 19:51:23 2018 (r331942) +++ head/include/stdio.h Tue Apr 3 20:14:37 2018 (r331943) @@ -51,6 +51,11 @@ typedef __size_t size_t; #define _SIZE_T_DECLARED #endif +#ifndef _RSIZE_T_DEFINED +#define _RSIZE_T_DEFINED +typedef size_t rsize_t; +#endif + #if __POSIX_VISIBLE >= 200809 #ifndef _OFF_T_DECLARED #define _OFF_T_DECLARED @@ -265,6 +270,9 @@ size_t fwrite(const void * __restrict, size_t, size_t int getc(FILE *); int getchar(void); char *gets(char *); +#if defined(__EXT1_VISIBLE) && __EXT1_VISIBLE == 1 +char *gets_s(char *, rsize_t); +#endif void perror(const char *); int printf(const char * __restrict, ...); int putc(int, FILE *); From owner-svn-src-head@freebsd.org Tue Apr 3 20:20:21 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 81B46F7CFCF; Tue, 3 Apr 2018 20:20:21 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F136E71246; Tue, 3 Apr 2018 20:20:20 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w33KKAnj062269 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 3 Apr 2018 23:20:13 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w33KKAnj062269 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w33KKAiw062265; Tue, 3 Apr 2018 23:20:10 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 3 Apr 2018 23:20:10 +0300 From: Konstantin Belousov To: Cy Schubert Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331936 - in head/lib/libc: stdio tests/stdio Message-ID: <20180403202010.GK1774@kib.kiev.ua> References: <201804031852.w33IqdIQ013512@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201804031852.w33IqdIQ013512@repo.freebsd.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 20:20:21 -0000 On Tue, Apr 03, 2018 at 06:52:39PM +0000, Cy Schubert wrote: > Modified: head/lib/libc/stdio/Symbol.map > ============================================================================== > --- head/lib/libc/stdio/Symbol.map Tue Apr 3 18:43:00 2018 (r331935) > +++ head/lib/libc/stdio/Symbol.map Tue Apr 3 18:52:38 2018 (r331936) > @@ -165,6 +165,7 @@ FBSD_1.3 { > FBSD_1.4 { > fdclose; > fopencookie; > + gets_s; > }; This is wrong. From owner-svn-src-head@freebsd.org Tue Apr 3 20:22:44 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 86297F7D3B2; Tue, 3 Apr 2018 20:22:44 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 015CC717C5; Tue, 3 Apr 2018 20:22:43 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w33KMXEp063254 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 3 Apr 2018 23:22:36 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w33KMXEp063254 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w33KMXP5063253; Tue, 3 Apr 2018 23:22:33 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 3 Apr 2018 23:22:33 +0300 From: Konstantin Belousov To: Cy Schubert Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331936 - in head/lib/libc: stdio tests/stdio Message-ID: <20180403202233.GL1774@kib.kiev.ua> References: <201804031852.w33IqdIQ013512@repo.freebsd.org> <20180403202010.GK1774@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180403202010.GK1774@kib.kiev.ua> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 20:22:44 -0000 On Tue, Apr 03, 2018 at 11:20:10PM +0300, Konstantin Belousov wrote: > On Tue, Apr 03, 2018 at 06:52:39PM +0000, Cy Schubert wrote: > > Modified: head/lib/libc/stdio/Symbol.map > > ============================================================================== > > --- head/lib/libc/stdio/Symbol.map Tue Apr 3 18:43:00 2018 (r331935) > > +++ head/lib/libc/stdio/Symbol.map Tue Apr 3 18:52:38 2018 (r331936) > > @@ -165,6 +165,7 @@ FBSD_1.3 { > > FBSD_1.4 { > > fdclose; > > fopencookie; > > + gets_s; > > }; > This is wrong. And then, I noticed that the function is not added to the header file as well, am I missing it ? From owner-svn-src-head@freebsd.org Tue Apr 3 20:24:54 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9BAABF7D634; Tue, 3 Apr 2018 20:24:54 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id EBD89719F2; Tue, 3 Apr 2018 20:24:53 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.125.17]) by shaw.ca with ESMTPA id 3SU2fpbJvXziT3SU3fmcK9; Tue, 03 Apr 2018 14:24:47 -0600 X-Authority-Analysis: v=2.3 cv=X6B81lbe c=1 sm=1 tr=0 a=VFtTW3WuZNDh6VkGe7fA3g==:117 a=VFtTW3WuZNDh6VkGe7fA3g==:17 a=kj9zAlcOel0A:10 a=Kd1tUaAdevIA:10 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=SrMf8hbOp_N-bMP_NfsA:9 a=CjuIK1q_8ugA:10 a=Ia-lj3WSrqcvXOmTRaiG:22 a=IjZwj45LgO3ly-622nXo:22 Received: from slippy.cwsent.com (slippy8 [10.2.2.6]) by spqr.komquats.com (Postfix) with ESMTPS id 8F3C97FA; Tue, 3 Apr 2018 13:24:45 -0700 (PDT) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id w33KOgIb022471; Tue, 3 Apr 2018 13:24:42 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id w33KOgcJ022468; Tue, 3 Apr 2018 13:24:42 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201804032024.w33KOgcJ022468@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Konstantin Belousov cc: Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331936 - in head/lib/libc: stdio tests/stdio In-Reply-To: Message from Konstantin Belousov of "Tue, 03 Apr 2018 23:20:10 +0300." <20180403202010.GK1774@kib.kiev.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 03 Apr 2018 13:24:42 -0700 X-CMAE-Envelope: MS4wfK7Gmre+KWXbNqSN84RU3PcaaYOlZYXvuLFk0X3BQ5G/VMZ5dtgNIoc3fbnZcmS6K6My9bM1UB9MnfDF13bBocC8iRp+YV0gMrETvKaV+id66Yww4+eI Vf+ZxfC/sheRi/Y4N1MJGGkfDC1VPzG/U/F+qaUBZin5RSHryn/P1IFKfLmARN4uNFNNb/bKAJZJHdWN+pxKu1VxVNmz/hZIbrMZ8OG1Rd+hxohU9TJ8VOiC t4h/yfAhfuzYcvxE29sPTOj/2g6qM+KN635jzSTlwYmMAQIkKNvhB3ghG9+ID2TYrpupCKe+4FOUUVJt4ruOxA== X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 20:24:54 -0000 In message <20180403202010.GK1774@kib.kiev.ua>, Konstantin Belousov writes: > On Tue, Apr 03, 2018 at 06:52:39PM +0000, Cy Schubert wrote: > > Modified: head/lib/libc/stdio/Symbol.map > > =========================================================================== > === > > --- head/lib/libc/stdio/Symbol.map Tue Apr 3 18:43:00 2018 (r33193 > 5) > > +++ head/lib/libc/stdio/Symbol.map Tue Apr 3 18:52:38 2018 (r33193 > 6) > > @@ -165,6 +165,7 @@ FBSD_1.3 { > > FBSD_1.4 { > > fdclose; > > fopencookie; > > + gets_s; > > }; > This is wrong. Would you suggest a different version number? -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. From owner-svn-src-head@freebsd.org Tue Apr 3 20:26:00 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B8ACDF7D7CF; Tue, 3 Apr 2018 20:26:00 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 12CDE71BB2; Tue, 3 Apr 2018 20:25:59 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.125.17]) by shaw.ca with ESMTPA id 3SVAfpbhqXziT3SVCfmccV; Tue, 03 Apr 2018 14:25:58 -0600 X-Authority-Analysis: v=2.3 cv=X6B81lbe c=1 sm=1 tr=0 a=VFtTW3WuZNDh6VkGe7fA3g==:117 a=VFtTW3WuZNDh6VkGe7fA3g==:17 a=kj9zAlcOel0A:10 a=Kd1tUaAdevIA:10 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=01UsYihvV-c3iVwlEgMA:9 a=CjuIK1q_8ugA:10 a=Ia-lj3WSrqcvXOmTRaiG:22 a=IjZwj45LgO3ly-622nXo:22 Received: from slippy.cwsent.com (slippy8 [10.2.2.6]) by spqr.komquats.com (Postfix) with ESMTPS id 85C27819; Tue, 3 Apr 2018 13:25:56 -0700 (PDT) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id w33KPtAo022515; Tue, 3 Apr 2018 13:25:55 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id w33KPto8022512; Tue, 3 Apr 2018 13:25:55 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201804032025.w33KPto8022512@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Konstantin Belousov cc: Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331936 - in head/lib/libc: stdio tests/stdio In-Reply-To: Message from Konstantin Belousov of "Tue, 03 Apr 2018 23:22:33 +0300." <20180403202233.GL1774@kib.kiev.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 03 Apr 2018 13:25:55 -0700 X-CMAE-Envelope: MS4wfPKEoY16y0p99Y15YZGFWc4N9Hzv1A9MgRrx52SGKYA5Y/cPfBZ3J33CBER58dSuoByzjNcyyfbC8+X/8FTj0lI/3qWxU7AMb62D+tWV1leqqIcWtHbY anMp3WXiGVF6sslAGY7jQtAMxEQWWKQJ9VkaLcySPBrtG1L68QIhuXmTVbSLxytXgV47Xqx3uzmR/R7Isci1DoJUcC2FvvNKw5ZF+DT+d2Qc+UuDXc+xTo/S 6o6+fuEjRoei1lpK/iR/weTDQgn8Yf8R//ZaHxWtTmyHa6OhDmH2ytlW6jpr0skqfe7HaJo8izlKRLueTndF7w== X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 20:26:00 -0000 In message <20180403202233.GL1774@kib.kiev.ua>, Konstantin Belousov writes: > On Tue, Apr 03, 2018 at 11:20:10PM +0300, Konstantin Belousov wrote: > > On Tue, Apr 03, 2018 at 06:52:39PM +0000, Cy Schubert wrote: > > > Modified: head/lib/libc/stdio/Symbol.map > > > ========================================================================= > ===== > > > --- head/lib/libc/stdio/Symbol.map Tue Apr 3 18:43:00 2018 > (r331935) > > > +++ head/lib/libc/stdio/Symbol.map Tue Apr 3 18:52:38 2018 > (r331936) > > > @@ -165,6 +165,7 @@ FBSD_1.3 { > > > FBSD_1.4 { > > > fdclose; > > > fopencookie; > > > + gets_s; > > > }; > > This is wrong. I replied to this previously. > > And then, I noticed that the function is not added to the header file as well > , > am I missing it ? I my attempt to only commit gets_s() and nothing else I missed committing the header file. It's there now. -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. From owner-svn-src-head@freebsd.org Tue Apr 3 20:38:25 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE298F7E617; Tue, 3 Apr 2018 20:38:25 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6129A72527; Tue, 3 Apr 2018 20:38:25 +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 5C225186D; Tue, 3 Apr 2018 20:38:25 +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 w33KcPLo069864; Tue, 3 Apr 2018 20:38:25 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33KcPsj069863; Tue, 3 Apr 2018 20:38:25 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201804032038.w33KcPsj069863@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Tue, 3 Apr 2018 20:38:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331945 - head/lib/libc/stdio X-SVN-Group: head X-SVN-Commit-Author: cy X-SVN-Commit-Paths: head/lib/libc/stdio X-SVN-Commit-Revision: 331945 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 20:38:25 -0000 Author: cy Date: Tue Apr 3 20:38:25 2018 New Revision: 331945 URL: https://svnweb.freebsd.org/changeset/base/331945 Log: Correct the version number for gets_s(3). Reported by: kib@ MFC after: 2 weeks X-MFC with: r331936 Differential Revision: https://reviews.freebsd.org/D12785 Modified: head/lib/libc/stdio/Symbol.map Modified: head/lib/libc/stdio/Symbol.map ============================================================================== --- head/lib/libc/stdio/Symbol.map Tue Apr 3 20:22:02 2018 (r331944) +++ head/lib/libc/stdio/Symbol.map Tue Apr 3 20:38:25 2018 (r331945) @@ -160,12 +160,12 @@ FBSD_1.3 { open_wmemstream; mkostemp; mkostemps; + gets_s; }; FBSD_1.4 { fdclose; fopencookie; - gets_s; }; FBSDprivate_1.0 { From owner-svn-src-head@freebsd.org Tue Apr 3 20:40:11 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B88C6F7E7CD; Tue, 3 Apr 2018 20:40:11 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id C73D672707; Tue, 3 Apr 2018 20:40:10 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.125.17]) by shaw.ca with ESMTPA id 3SitfZiAdYxCT3SiuffJ22; Tue, 03 Apr 2018 14:40:08 -0600 X-Authority-Analysis: v=2.3 cv=cav8UELM c=1 sm=1 tr=0 a=VFtTW3WuZNDh6VkGe7fA3g==:117 a=VFtTW3WuZNDh6VkGe7fA3g==:17 a=kj9zAlcOel0A:10 a=Kd1tUaAdevIA:10 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=pp5kDD734Ao5TmKL9n8A:9 a=CjuIK1q_8ugA:10 a=Ia-lj3WSrqcvXOmTRaiG:22 a=IjZwj45LgO3ly-622nXo:22 Received: from slippy.cwsent.com (slippy8 [10.2.2.6]) by spqr.komquats.com (Postfix) with ESMTPS id 11F7D887; Tue, 3 Apr 2018 13:40:07 -0700 (PDT) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id w33Ke6QL023380; Tue, 3 Apr 2018 13:40:06 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id w33Ke6JZ023377; Tue, 3 Apr 2018 13:40:06 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201804032040.w33Ke6JZ023377@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Konstantin Belousov cc: Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331936 - in head/lib/libc: stdio tests/stdio In-Reply-To: Message from Konstantin Belousov of "Tue, 03 Apr 2018 23:20:10 +0300." <20180403202010.GK1774@kib.kiev.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 03 Apr 2018 13:40:06 -0700 X-CMAE-Envelope: MS4wfE10Nxp853gCzBTHIdZb9p3U6YptcpTTgf+Lkv0M8jC0YISfXQtmGTkCAkzNnfOuECbff3jQvLrG+bC0o2r/7nLVjUnQvIDR6rcDe7g4vLGsXZ4JILcK FG52oq5jUGZc/DWWqFVsyLBmjbh7Vm9M+74kGvka2Je1tQ3ISgWoL90rI0Tpj0DS5oULe8VStPBaSJGVzl0OnChY+l9wfkBgAM/FKrpjs42qe/trzg0V6f0u oVfSAdQNg6JNFXlnlQDzl5mgGBpVKW48jOXC1mDxX2AySwyq8Sn4pKGqW6oTF1AXKVD1c4IGudRfNoGw4f8Vxw== X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 20:40:11 -0000 In message <20180403202010.GK1774@kib.kiev.ua>, Konstantin Belousov writes: > On Tue, Apr 03, 2018 at 06:52:39PM +0000, Cy Schubert wrote: > > Modified: head/lib/libc/stdio/Symbol.map > > =========================================================================== > === > > --- head/lib/libc/stdio/Symbol.map Tue Apr 3 18:43:00 2018 (r33193 > 5) > > +++ head/lib/libc/stdio/Symbol.map Tue Apr 3 18:52:38 2018 (r33193 > 6) > > @@ -165,6 +165,7 @@ FBSD_1.3 { > > FBSD_1.4 { > > fdclose; > > fopencookie; > > + gets_s; > > }; > This is wrong. Fixed. Thanks for input Konstantin. -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. From owner-svn-src-head@freebsd.org Tue Apr 3 20:41:08 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6112DF7E927; Tue, 3 Apr 2018 20:41:08 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B5C5072A17; Tue, 3 Apr 2018 20:41:07 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w33KevlO067759 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 3 Apr 2018 23:41:00 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w33KevlO067759 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w33KevHt067757; Tue, 3 Apr 2018 23:40:57 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 3 Apr 2018 23:40:57 +0300 From: Konstantin Belousov To: Cy Schubert Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331943 - head/include Message-ID: <20180403204057.GM1774@kib.kiev.ua> References: <201804032014.w33KEbY2036305@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201804032014.w33KEbY2036305@repo.freebsd.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 20:41:08 -0000 On Tue, Apr 03, 2018 at 08:14:37PM +0000, Cy Schubert wrote: > Author: cy > Date: Tue Apr 3 20:14:37 2018 > New Revision: 331943 > URL: https://svnweb.freebsd.org/changeset/base/331943 > > Log: > Include update to stdio.h missed in r331936. > > In my attempt to limit the commit in r331936 to only the gets_s() > commit and not include unrelated patches in my tree, this patch > was missed. > > Reported by: pfg > MFC after: 2 weeks > X-MFC with: r331936 > Differential Revision: https://reviews.freebsd.org/D12785 > > Modified: > head/include/stdio.h > > Modified: head/include/stdio.h > ============================================================================== > --- head/include/stdio.h Tue Apr 3 19:51:23 2018 (r331942) > +++ head/include/stdio.h Tue Apr 3 20:14:37 2018 (r331943) > @@ -51,6 +51,11 @@ typedef __size_t size_t; > #define _SIZE_T_DECLARED > #endif > > +#ifndef _RSIZE_T_DEFINED > +#define _RSIZE_T_DEFINED > +typedef size_t rsize_t; > +#endif > + > #if __POSIX_VISIBLE >= 200809 > #ifndef _OFF_T_DECLARED > #define _OFF_T_DECLARED > @@ -265,6 +270,9 @@ size_t fwrite(const void * __restrict, size_t, size_t > int getc(FILE *); > int getchar(void); > char *gets(char *); > +#if defined(__EXT1_VISIBLE) && __EXT1_VISIBLE == 1 What is the purpose of the __EXT1_VISIBLE == 1 check ? It is against the intended __XX_VISIBLE mechanism construction. > +char *gets_s(char *, rsize_t); > +#endif > void perror(const char *); > int printf(const char * __restrict, ...); > int putc(int, FILE *); From owner-svn-src-head@freebsd.org Tue Apr 3 20:42:54 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 981F2F7EBDC; Tue, 3 Apr 2018 20:42:54 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EA59772D7A; Tue, 3 Apr 2018 20:42:53 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w33Kgee2067838 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 3 Apr 2018 23:42:43 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w33Kgee2067838 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w33KgeL6067835; Tue, 3 Apr 2018 23:42:40 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 3 Apr 2018 23:42:40 +0300 From: Konstantin Belousov To: Cy Schubert Cc: Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331936 - in head/lib/libc: stdio tests/stdio Message-ID: <20180403204240.GN1774@kib.kiev.ua> References: <20180403202010.GK1774@kib.kiev.ua> <201804032024.w33KOgcJ022468@slippy.cwsent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201804032024.w33KOgcJ022468@slippy.cwsent.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 20:42:54 -0000 On Tue, Apr 03, 2018 at 01:24:42PM -0700, Cy Schubert wrote: > In message <20180403202010.GK1774@kib.kiev.ua>, Konstantin Belousov > writes: > > On Tue, Apr 03, 2018 at 06:52:39PM +0000, Cy Schubert wrote: > > > Modified: head/lib/libc/stdio/Symbol.map > > > =========================================================================== > > === > > > --- head/lib/libc/stdio/Symbol.map Tue Apr 3 18:43:00 2018 (r33193 > > 5) > > > +++ head/lib/libc/stdio/Symbol.map Tue Apr 3 18:52:38 2018 (r33193 > > 6) > > > @@ -165,6 +165,7 @@ FBSD_1.3 { > > > FBSD_1.4 { > > > fdclose; > > > fopencookie; > > > + gets_s; > > > }; > > This is wrong. > > Would you suggest a different version number? Right version number for HEAD while it is 12 is FBSD_1.5. You will need to add it to stdio/Symbol.map since this is the first symbol in that namespace from stdio subdirectory. From owner-svn-src-head@freebsd.org Tue Apr 3 20:51:28 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80A96F7F70A; Tue, 3 Apr 2018 20:51:28 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id D46877380D; Tue, 3 Apr 2018 20:51:27 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.125.17]) by shaw.ca with ESMTPA id 3StpfpkZxXziT3StqfmjHD; Tue, 03 Apr 2018 14:51:26 -0600 X-Authority-Analysis: v=2.3 cv=X6B81lbe c=1 sm=1 tr=0 a=VFtTW3WuZNDh6VkGe7fA3g==:117 a=VFtTW3WuZNDh6VkGe7fA3g==:17 a=kj9zAlcOel0A:10 a=Kd1tUaAdevIA:10 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=KyEggJhy-pvkK12t3XYA:9 a=yR6CNe_cHF_cZkW1:21 a=IbUFIDMGQQ64dAyb:21 a=CjuIK1q_8ugA:10 a=Ia-lj3WSrqcvXOmTRaiG:22 a=IjZwj45LgO3ly-622nXo:22 Received: from slippy.cwsent.com (slippy8 [10.2.2.6]) by spqr.komquats.com (Postfix) with ESMTPS id D78A5901; Tue, 3 Apr 2018 13:51:24 -0700 (PDT) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id w33KpNit024221; Tue, 3 Apr 2018 13:51:23 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id w33KpN7I024218; Tue, 3 Apr 2018 13:51:23 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201804032051.w33KpN7I024218@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Konstantin Belousov cc: Cy Schubert , Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331936 - in head/lib/libc: stdio tests/stdio In-Reply-To: Message from Konstantin Belousov of "Tue, 03 Apr 2018 23:42:40 +0300." <20180403204240.GN1774@kib.kiev.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 03 Apr 2018 13:51:23 -0700 X-CMAE-Envelope: MS4wfArm1mTfDl3AV80NrseXRsZFiDJkRVJYRn59NcV0wymLjML5xyR3DEQgm7qaGq/SsJtyyrULhQpLdl5f9/L19fEWUHXEyFxgajTtzYPZ6iLPC0rfMjhO ibjavSFCGmH60YpxsI2VRYq1Sme6yNxOsrQQm5B7mkHzZzeizkc2KQvA0zmfU7th9ATU8FYNYiu5Id8UkqcRLfKgXsqHUtOnqy2ZOfp87kfw5sPvhSOyEAT/ Ms+bOnTsZF6RL/d2e9FXTJbm4PwHVuSORwv7t+2qeiFc5LePmmr1xMKdvCia6AnZYwrJgoa522B3REQ3I3oxcw== X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 20:51:28 -0000 In message <20180403204240.GN1774@kib.kiev.ua>, Konstantin Belousov writes: > On Tue, Apr 03, 2018 at 01:24:42PM -0700, Cy Schubert wrote: > > In message <20180403202010.GK1774@kib.kiev.ua>, Konstantin Belousov > > writes: > > > On Tue, Apr 03, 2018 at 06:52:39PM +0000, Cy Schubert wrote: > > > > Modified: head/lib/libc/stdio/Symbol.map > > > > ======================================================================= > ==== > > > === > > > > --- head/lib/libc/stdio/Symbol.map Tue Apr 3 18:43:00 2018 > (r33193 > > > 5) > > > > +++ head/lib/libc/stdio/Symbol.map Tue Apr 3 18:52:38 2018 > (r33193 > > > 6) > > > > @@ -165,6 +165,7 @@ FBSD_1.3 { > > > > FBSD_1.4 { > > > > fdclose; > > > > fopencookie; > > > > + gets_s; > > > > }; > > > This is wrong. > > > > Would you suggest a different version number? > > Right version number for HEAD while it is 12 is FBSD_1.5. You will need > to add it to stdio/Symbol.map since this is the first symbol in that > namespace from stdio subdirectory. Ok. I understand now. -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. From owner-svn-src-head@freebsd.org Tue Apr 3 20:53:54 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A02C1F7F9B2; Tue, 3 Apr 2018 20:53:54 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3E2C173AF9; Tue, 3 Apr 2018 20:53:54 +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 327351BF0; Tue, 3 Apr 2018 20:53:54 +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 w33Krsgu095156; Tue, 3 Apr 2018 20:53:54 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33Krsu1095154; Tue, 3 Apr 2018 20:53:54 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201804032053.w33Krsu1095154@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Tue, 3 Apr 2018 20:53:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331947 - head/lib/libc/stdio X-SVN-Group: head X-SVN-Commit-Author: cy X-SVN-Commit-Paths: head/lib/libc/stdio X-SVN-Commit-Revision: 331947 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 20:53:54 -0000 Author: cy Date: Tue Apr 3 20:53:53 2018 New Revision: 331947 URL: https://svnweb.freebsd.org/changeset/base/331947 Log: The correct symbol version for FreeBSD 12 is 1.5. Reported by: kib@ MFC after: 2 weeks X-MFC with: r331936 Differential Revision: https://reviews.freebsd.org/D12785 Modified: head/lib/libc/stdio/Symbol.map Modified: head/lib/libc/stdio/Symbol.map ============================================================================== --- head/lib/libc/stdio/Symbol.map Tue Apr 3 20:41:57 2018 (r331946) +++ head/lib/libc/stdio/Symbol.map Tue Apr 3 20:53:53 2018 (r331947) @@ -160,12 +160,15 @@ FBSD_1.3 { open_wmemstream; mkostemp; mkostemps; - gets_s; }; FBSD_1.4 { fdclose; fopencookie; +}; + +FBSD_1.5 { + gets_s; }; FBSDprivate_1.0 { From owner-svn-src-head@freebsd.org Tue Apr 3 20:54:42 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 29F50F7FA9B; Tue, 3 Apr 2018 20:54:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9D61873C5A; Tue, 3 Apr 2018 20:54:41 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w33KsVDQ070160 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 3 Apr 2018 23:54:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w33KsVDQ070160 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w33KsVBV070159; Tue, 3 Apr 2018 23:54:31 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 3 Apr 2018 23:54:31 +0300 From: Konstantin Belousov To: Cy Schubert Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331945 - head/lib/libc/stdio Message-ID: <20180403205431.GO1774@kib.kiev.ua> References: <201804032038.w33KcPsj069863@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201804032038.w33KcPsj069863@repo.freebsd.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 20:54:42 -0000 On Tue, Apr 03, 2018 at 08:38:25PM +0000, Cy Schubert wrote: > Author: cy > Date: Tue Apr 3 20:38:25 2018 > New Revision: 331945 > URL: https://svnweb.freebsd.org/changeset/base/331945 > > Log: > Correct the version number for gets_s(3). > > Reported by: kib@ > MFC after: 2 weeks > X-MFC with: r331936 > Differential Revision: https://reviews.freebsd.org/D12785 > > Modified: > head/lib/libc/stdio/Symbol.map > > Modified: head/lib/libc/stdio/Symbol.map > ============================================================================== > --- head/lib/libc/stdio/Symbol.map Tue Apr 3 20:22:02 2018 (r331944) > +++ head/lib/libc/stdio/Symbol.map Tue Apr 3 20:38:25 2018 (r331945) > @@ -160,12 +160,12 @@ FBSD_1.3 { Please re-read my previous mail. > open_wmemstream; > mkostemp; > mkostemps; > + gets_s; > }; > > FBSD_1.4 { > fdclose; > fopencookie; > - gets_s; > }; > > FBSDprivate_1.0 { From owner-svn-src-head@freebsd.org Tue Apr 3 20:58:58 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D2794F7FF2F; Tue, 3 Apr 2018 20:58:58 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 3DB3F7406D; Tue, 3 Apr 2018 20:58:57 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.125.17]) by shaw.ca with ESMTPA id 3T15fZpTDYxCT3T16ffNtZ; Tue, 03 Apr 2018 14:58:56 -0600 X-Authority-Analysis: v=2.3 cv=cav8UELM c=1 sm=1 tr=0 a=VFtTW3WuZNDh6VkGe7fA3g==:117 a=VFtTW3WuZNDh6VkGe7fA3g==:17 a=kj9zAlcOel0A:10 a=Kd1tUaAdevIA:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=qROpeadeCB7nu2nCmHQA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy8 [10.2.2.6]) by spqr.komquats.com (Postfix) with ESMTPS id 3AE7C95F; Tue, 3 Apr 2018 13:58:55 -0700 (PDT) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id w33Kwsss024417; Tue, 3 Apr 2018 13:58:54 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id w33KwsxY024414; Tue, 3 Apr 2018 13:58:54 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201804032058.w33KwsxY024414@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Konstantin Belousov cc: Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331945 - head/lib/libc/stdio In-Reply-To: Message from Konstantin Belousov of "Tue, 03 Apr 2018 23:54:31 +0300." <20180403205431.GO1774@kib.kiev.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 03 Apr 2018 13:58:54 -0700 X-CMAE-Envelope: MS4wfPC/vp1HntaO60xhSARLnBB3uLLDP71MtdCuQRjvYEq+60aBHSkht/MBAdsk36lBA10qnJj6xlqfC2PsvQNzhq/yPpIwlObxSzUqAhhhLR2FHxcQLg7V bJop62NRGpyR1yDvw+xn+RXMUhIV0FRt0q5ubxoF0TaP6+UEUYmXE5348ERivTY1828IjYY0ZklLox19Q/HNOZpnImPzYL5Fl1D2dWuCe8pXL40lIs3vSm1w 0aROr9bfgY9H3rlBdRGlnMtIAJTqDOI7dV7IeS+FhJ9XcXh/F3J2mV3GHT1oWBoA9ptLxyapN5JqK8vjjTMOWQ== X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 20:58:59 -0000 In message <20180403205431.GO1774@kib.kiev.ua>, Konstantin Belousov writes: > On Tue, Apr 03, 2018 at 08:38:25PM +0000, Cy Schubert wrote: > > Author: cy > > Date: Tue Apr 3 20:38:25 2018 > > New Revision: 331945 > > URL: https://svnweb.freebsd.org/changeset/base/331945 > > > > Log: > > Correct the version number for gets_s(3). > > > > Reported by: kib@ > > MFC after: 2 weeks > > X-MFC with: r331936 > > Differential Revision: https://reviews.freebsd.org/D12785 > > > > Modified: > > head/lib/libc/stdio/Symbol.map > > > > Modified: head/lib/libc/stdio/Symbol.map > > =========================================================================== > === > > --- head/lib/libc/stdio/Symbol.map Tue Apr 3 20:22:02 2018 (r33194 > 4) > > +++ head/lib/libc/stdio/Symbol.map Tue Apr 3 20:38:25 2018 (r33194 > 5) > > @@ -160,12 +160,12 @@ FBSD_1.3 { > Please re-read my previous mail. We are out of sync, before you explained it to me. -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. From owner-svn-src-head@freebsd.org Tue Apr 3 20:59:47 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 72129F80012; Tue, 3 Apr 2018 20:59:47 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2503F741DE; Tue, 3 Apr 2018 20:59:47 +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 1FCB61C1B; Tue, 3 Apr 2018 20:59:47 +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 w33KxkmZ001514; Tue, 3 Apr 2018 20:59:46 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33KxklJ001513; Tue, 3 Apr 2018 20:59:46 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201804032059.w33KxklJ001513@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Tue, 3 Apr 2018 20:59:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331948 - head/include X-SVN-Group: head X-SVN-Commit-Author: cy X-SVN-Commit-Paths: head/include X-SVN-Commit-Revision: 331948 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 20:59:47 -0000 Author: cy Date: Tue Apr 3 20:59:46 2018 New Revision: 331948 URL: https://svnweb.freebsd.org/changeset/base/331948 Log: Remove redundant check. Reported by: kib@ MFC after: 2 weeks X-MFC with: r331936 Differential Revision: https://reviews.freebsd.org/D12785 Modified: head/include/stdio.h Modified: head/include/stdio.h ============================================================================== --- head/include/stdio.h Tue Apr 3 20:53:53 2018 (r331947) +++ head/include/stdio.h Tue Apr 3 20:59:46 2018 (r331948) @@ -270,7 +270,7 @@ size_t fwrite(const void * __restrict, size_t, size_t int getc(FILE *); int getchar(void); char *gets(char *); -#if defined(__EXT1_VISIBLE) && __EXT1_VISIBLE == 1 +#if __EXT1_VISIBLE char *gets_s(char *, rsize_t); #endif void perror(const char *); From owner-svn-src-head@freebsd.org Tue Apr 3 21:00:55 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 72934F80235; Tue, 3 Apr 2018 21:00:55 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 9D07D7456D; Tue, 3 Apr 2018 21:00:54 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.125.17]) by shaw.ca with ESMTPA id 3T2rfpnmqXziT3T2tfmlhI; Tue, 03 Apr 2018 15:00:47 -0600 X-Authority-Analysis: v=2.3 cv=X6B81lbe c=1 sm=1 tr=0 a=VFtTW3WuZNDh6VkGe7fA3g==:117 a=VFtTW3WuZNDh6VkGe7fA3g==:17 a=kj9zAlcOel0A:10 a=Kd1tUaAdevIA:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=VOjm7XU_MTT69P80fhcA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy8 [10.2.2.6]) by spqr.komquats.com (Postfix) with ESMTPS id 8CAFF975; Tue, 3 Apr 2018 14:00:45 -0700 (PDT) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id w33L0jp2024505; Tue, 3 Apr 2018 14:00:45 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id w33L0i5g024502; Tue, 3 Apr 2018 14:00:44 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201804032100.w33L0i5g024502@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Konstantin Belousov cc: Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331943 - head/include In-Reply-To: Message from Konstantin Belousov of "Tue, 03 Apr 2018 23:40:57 +0300." <20180403204057.GM1774@kib.kiev.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 03 Apr 2018 14:00:44 -0700 X-CMAE-Envelope: MS4wfIzt9iEVNe6270h+fKaVMX2JOAEcT2ed2QyRG9FEZffvHQQDX0yPIc5K4KACjhd790vEnxgt0MHeGNbP/uF6R1Kk8sFtFXmwyCt6EDrJ0bA8pMBZOQcd II3hgGAZRCpy4iUELPOASZDYd6F1IkiIt1CuEblEQWncYfX+7KxnEAfFi3zHvx9V2lAfs50Skxv19L3sgQDKzGwoJPvkciuMezpwbYc2cX3ExBXeKGlJ/Nu6 +El7XJxyp5hjLyaadMSUDQERn5k2bAokMTo7YFIQsM2/zafYKJ6G2P8IXTfMu04mqBr8/JLxN2yVuzUQD0xBSQ== X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 21:00:55 -0000 In message <20180403204057.GM1774@kib.kiev.ua>, Konstantin Belousov writes: > On Tue, Apr 03, 2018 at 08:14:37PM +0000, Cy Schubert wrote: > > Author: cy > > Date: Tue Apr 3 20:14:37 2018 > > New Revision: 331943 > > URL: https://svnweb.freebsd.org/changeset/base/331943 > > > > Log: > > Include update to stdio.h missed in r331936. > > > > In my attempt to limit the commit in r331936 to only the gets_s() > > commit and not include unrelated patches in my tree, this patch > > was missed. > > > > Reported by: pfg > > MFC after: 2 weeks > > X-MFC with: r331936 > > Differential Revision: https://reviews.freebsd.org/D12785 > > > > Modified: > > head/include/stdio.h > > > > Modified: head/include/stdio.h > > =========================================================================== > === > > --- head/include/stdio.h Tue Apr 3 19:51:23 2018 (r331942) > > +++ head/include/stdio.h Tue Apr 3 20:14:37 2018 (r331943) > > @@ -51,6 +51,11 @@ typedef __size_t size_t; > > #define _SIZE_T_DECLARED > > #endif > > > > +#ifndef _RSIZE_T_DEFINED > > +#define _RSIZE_T_DEFINED > > +typedef size_t rsize_t; > > +#endif > > + > > #if __POSIX_VISIBLE >= 200809 > > #ifndef _OFF_T_DECLARED > > #define _OFF_T_DECLARED > > @@ -265,6 +270,9 @@ size_t fwrite(const void * __restrict, size_t, size_t > > int getc(FILE *); > > int getchar(void); > > char *gets(char *); > > +#if defined(__EXT1_VISIBLE) && __EXT1_VISIBLE == 1 > What is the purpose of the __EXT1_VISIBLE == 1 check ? > It is against the intended __XX_VISIBLE mechanism construction. That appears to have been left over in my commit tree. > > > +char *gets_s(char *, rsize_t); > > +#endif > > void perror(const char *); > > int printf(const char * __restrict, ...); > > int putc(int, FILE *); -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. From owner-svn-src-head@freebsd.org Tue Apr 3 21:08:12 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F1550F80AF4; Tue, 3 Apr 2018 21:08:11 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 93D18749D9; Tue, 3 Apr 2018 21:08:11 +0000 (UTC) (envelope-from benno@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 88F4E1DB7; Tue, 3 Apr 2018 21:08:11 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33L8Bc0014610; Tue, 3 Apr 2018 21:08:11 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33L8AEc014593; Tue, 3 Apr 2018 21:08:10 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804032108.w33L8AEc014593@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Tue, 3 Apr 2018 21:08:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331949 - in head/usr.bin: . etdump X-SVN-Group: head X-SVN-Commit-Author: benno X-SVN-Commit-Paths: in head/usr.bin: . etdump X-SVN-Commit-Revision: 331949 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 21:08:12 -0000 Author: benno Date: Tue Apr 3 21:08:10 2018 New Revision: 331949 URL: https://svnweb.freebsd.org/changeset/base/331949 Log: Add the etdump utility for dumping El Torito boot catalog information. This can be used to check existing images but will be used in the future to find EFI ESP images placed in El Torito catalogs so they can be used for hybrid boot purposes. Reviewed by: imp (code), sbruno (man page), bcr (man page) Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D14952 Added: head/usr.bin/etdump/ head/usr.bin/etdump/Makefile (contents, props changed) head/usr.bin/etdump/etdump.1 (contents, props changed) head/usr.bin/etdump/etdump.c (contents, props changed) head/usr.bin/etdump/etdump.h (contents, props changed) head/usr.bin/etdump/output_shell.c (contents, props changed) head/usr.bin/etdump/output_text.c (contents, props changed) Modified: head/usr.bin/Makefile Modified: head/usr.bin/Makefile ============================================================================== --- head/usr.bin/Makefile Tue Apr 3 20:59:46 2018 (r331948) +++ head/usr.bin/Makefile Tue Apr 3 21:08:10 2018 (r331949) @@ -41,6 +41,7 @@ SUBDIR= alias \ elfdump \ enigma \ env \ + etdump \ expand \ false \ fetch \ Added: head/usr.bin/etdump/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/etdump/Makefile Tue Apr 3 21:08:10 2018 (r331949) @@ -0,0 +1,14 @@ +# $FreeBSD$ + +PROG= etdump + +MAKEFS_SRC= ${SRCTOP}/usr.sbin/makefs + +CFLAGS+= -I${SRCTOP}/sys/fs/cd9660 -I${MAKEFS_SRC} \ + -I${MAKEFS_SRC}/cd9660 + +.PATH: ${MAKEFS_SRC}/cd9660 + +SRCS= etdump.c output_shell.c output_text.c cd9660_conversion.c + +.include Added: head/usr.bin/etdump/etdump.1 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/etdump/etdump.1 Tue Apr 3 21:08:10 2018 (r331949) @@ -0,0 +1,104 @@ +.\" Copyright (c) 2018 iXsystems, Inc +.\" 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$ +.\" +.Dd April 3, 2018 +.Dt ETDUMP 8 +.Os +.Sh NAME +.Nm etdump +.Nd Dump El Torito boot catalog information from ISO images +.Sh SYNOPSIS +.Nm +.Op Fl f Ar format +.Op Fl o Ar file +.Ar +.Sh DESCRIPTION +This program reads El Torito boot catalog information from an ISO image and +outputs it in various formats. +It can be used to check the catalog in an image or to output catalog data in +a format that can be used by other tools such as shell scripts. +.Pp +Supported options are: +.Bl -tag -width flag +.It Fl f Ar format Fl -format Ar format +Select the output format. +Supported output formats are: +.Bl -tag -width shell -offset indent +.It Sy text +Human-readable text (default) +.It Sy shell +Each boot entry is emitted as a string suitable for passing to a sh-compatible +eval command. +The variables emitted are: +.Bl -tag -width et_platform -offset indent +.It et_platform +The platform ID from the section header. +Set to 'default' for the initial (default) entry. +.It et_system +The system ID from the boot entry. +.It et_lba +The starting LBA (2048-byte blocks) of the boot image. +.It et_sectors +The number of sectors (512-byte sectors) that comprise the boot image. +.El +.El +.It Fl o Ar file Fl -output Ar file +Write output to +.Ar file . +If '-' is specified then standard out is used. +.El +.Sh EXAMPLES +To see what entries are in a given boot catalog run +.Nm +passing the filename of the image as an argument like so: +.Bd -literal -offset indent +% etdump bootonly.iso +Image in bootonly.iso +Default entry + System i386 + Start LBA 420 (0x1a4), sector count 4 (0x4) + Media type: no emulation + +Section header: efi, final + Section entry + System i386 + Start LBA 20 (0x14), sector count 1600 (0x640) + Media type: no emulation +.Ed +.Pp +To use the output in a shell script a for loop can be used to iterate over the +entries returned using eval: +.Bd -literal -offset indent +for entry in `etdump --format shell bootonly.iso`; do + eval $entry + echo $et_platform $et_system $et_lba $et_sectors +done +.Ed +.Sh HISTORY +The +.Nm +utility first appeared in +.Fx 12.0 . Added: head/usr.bin/etdump/etdump.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/etdump/etdump.c Tue Apr 3 21:08:10 2018 (r331949) @@ -0,0 +1,268 @@ +/*- + * Copyright (c) 2018 iXsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include "cd9660.h" +#include "cd9660_eltorito.h" + +#include "etdump.h" + +const char * +system_id_string(u_char system_id) +{ + + switch (system_id) { + case ET_SYS_X86: + return ("i386"); + case ET_SYS_PPC: + return ("powerpc"); + case ET_SYS_MAC: + return ("mac"); + case ET_SYS_EFI: + return ("efi"); + default: + return ("invalid"); + } +} + +const char * +media_type_string(u_char media_type) +{ + + switch (media_type) { + case ET_MEDIA_NOEM: + return ("no emulation"); + case ET_MEDIA_12FDD: + return ("1.2MB FDD"); + case ET_MEDIA_144FDD: + return ("1.44MB FDD"); + case ET_MEDIA_288FDD: + return ("2.88MB FDD"); + case ET_MEDIA_HDD: + return ("HDD"); + default: + return ("invalid"); + } +} + +static int +read_sector(FILE *iso, daddr_t sector, char *buffer) +{ + + fseek(iso, sector * ISO_DEFAULT_BLOCK_SIZE, SEEK_SET); + if (fread(buffer, ISO_DEFAULT_BLOCK_SIZE, 1, iso) != 1) { + return (errno); + } + return (0); +} + +static bool +boot_catalog_valid(char *entry) +{ + boot_catalog_validation_entry *ve; + int16_t checksum, sum; + unsigned char *csptr; + size_t i; + + ve = (boot_catalog_validation_entry *)entry; + + checksum = isonum_721(ve->checksum); + cd9660_721(0, ve->checksum); + csptr = (unsigned char *)ve; + + for (i = sum = 0; i < sizeof(*ve); i += 2) { + sum += (int16_t)csptr[i]; + sum += 256 * (int16_t)csptr[i + 1]; + } + if (sum + checksum != 0) { + return (false); + } + + cd9660_721(checksum, ve->checksum); + return (true); +} + +static int +dump_section(char *buffer, size_t offset, FILE *outfile, const char *filename, + struct outputter *outputter) +{ + boot_catalog_section_header *sh; + u_char platform_id; + int i; + size_t entry_offset; + boot_catalog_section_entry *entry; + + sh = (boot_catalog_section_header *)&buffer[offset]; + if (outputter->output_section != NULL) { + outputter->output_section(outfile, filename, sh); + } + + platform_id = sh->platform_id[0]; + + if (outputter->output_entry != NULL) { + for (i = 1; i <= (int)sh->num_section_entries[0]; i++) { + entry_offset = offset + i * ET_BOOT_ENTRY_SIZE; + entry = + (boot_catalog_section_entry *)&buffer[entry_offset]; + outputter->output_entry(outfile, filename, entry, + platform_id, false); + } + } + + return (1 + (int)sh->num_section_entries[0]); +} + +static void +dump_eltorito(FILE *iso, const char *filename, FILE *outfile, + struct outputter *outputter) +{ + char buffer[ISO_DEFAULT_BLOCK_SIZE], *entry; + boot_volume_descriptor *bvd; + daddr_t boot_catalog; + size_t offset; + int entry_count; + + if (read_sector(iso, 17, buffer) != 0) + err(1, "failed to read from image"); + + bvd = (boot_volume_descriptor *)buffer; + if (memcmp(bvd->identifier, ISO_VOLUME_DESCRIPTOR_STANDARD_ID, 5) != 0) + warnx("%s: not a valid ISO", filename); + if (bvd->boot_record_indicator[0] != ISO_VOLUME_DESCRIPTOR_BOOT) + warnx("%s: not an El Torito bootable ISO", filename); + if (memcmp(bvd->boot_system_identifier, ET_ID, 23) != 0) + warnx("%s: not an El Torito bootable ISO", filename); + + boot_catalog = isonum_731(bvd->boot_catalog_pointer); + + if (read_sector(iso, boot_catalog, buffer) != 0) + err(1, "failed to read from image"); + + entry = buffer; + offset = 0; + + if (!boot_catalog_valid(entry)) + warnx("%s: boot catalog checksum is invalid", filename); + + if (outputter->output_image != NULL) + outputter->output_image(outfile, filename, bvd); + + offset += ET_BOOT_ENTRY_SIZE; + entry = &buffer[offset]; + if (outputter->output_entry != NULL) + outputter->output_entry(outfile, filename, + (boot_catalog_section_entry *)entry, 0, true); + + offset += ET_BOOT_ENTRY_SIZE; + + while (offset < ISO_DEFAULT_BLOCK_SIZE) { + entry = &buffer[offset]; + + if ((uint8_t)entry[0] != ET_SECTION_HEADER_MORE && + (uint8_t)entry[0] != ET_SECTION_HEADER_LAST) + break; + + entry_count = dump_section(buffer, offset, outfile, filename, + outputter); + + offset += entry_count * ET_BOOT_ENTRY_SIZE; + } +} + +static void +usage(const char *progname) +{ + char *path; + + path = strdup(progname); + + fprintf(stderr, "usage: %s [-f format] [-o filename] filename [...]\n", + basename(path)); + fprintf(stderr, "\tsupported output formats: shell, text\n"); + exit(1); +} + +int +main(int argc, char **argv) +{ + int ch, i; + FILE *outfile, *iso; + struct outputter *outputter; + + outfile = stdout; + outputter = output_text; + + static struct option longopts[] = { + { "format", required_argument, NULL, 'f' }, + { "output", required_argument, NULL, 'o' }, + { NULL, 0, NULL, 0 }, + }; + + while ((ch = getopt_long(argc, argv, "f:o:", longopts, NULL)) != -1) { + switch (ch) { + case 'f': + if (strcmp(optarg, "shell") == 0) + outputter = output_shell; + else if (strcmp(optarg, "text") == 0) + outputter = output_text; + else + usage(argv[0]); + break; + case 'o': + if (strcmp(optarg, "-") == 0) { + outfile = stdout; + } else if ((outfile = fopen(optarg, "w")) == NULL) { + err(1, "unable to open %s for output", optarg); + } + break; + default: + usage(argv[0]); + } + } + + argc -= optind; + argv += optind; + + for (i = 0; i < argc; i++) { + printf("%d %s\n", optind, argv[i]); + if (strcmp(argv[i], "-") == 0) { + iso = stdin; + } else { + iso = fopen(argv[i], "r"); + if (iso == NULL) + err(1, "could not open %s", argv[1]); + } + dump_eltorito(iso, argv[i], outfile, outputter); + } +} Added: head/usr.bin/etdump/etdump.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/etdump/etdump.h Tue Apr 3 21:08:10 2018 (r331949) @@ -0,0 +1,49 @@ +/*- + * Copyright (c) 2018 iXsystems, Inc. + * 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 _ETDUMP_H_ +#define _ETDUMP_H_ + +struct outputter { + void (*output_image)(FILE *outfile, const char *filename, + boot_volume_descriptor *bvd); + void (*output_section)(FILE *outfile, const char *filename, + boot_catalog_section_header *bcsh); + void (*output_entry)(FILE *outfile, const char *filename, + boot_catalog_section_entry *bcse, + u_char platform_id, bool initial); +}; + +extern struct outputter *output_text; +extern struct outputter *output_shell; + +const char *system_id_string(u_char system_id); +const char *media_type_string(u_char media_type); + +#endif /* _ETDUMP_H_ */ + Added: head/usr.bin/etdump/output_shell.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/etdump/output_shell.c Tue Apr 3 21:08:10 2018 (r331949) @@ -0,0 +1,69 @@ +/*- + * Copyright (c) 2018 iXsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include "cd9660.h" +#include "cd9660_eltorito.h" + +#include "etdump.h" + +static void +output_entry(FILE *outfile, const char *filename __unused, + boot_catalog_section_entry *bcse, u_char platform_id, bool initial) +{ + const char *platform; + + switch (bcse->boot_indicator[0]) { + case ET_BOOTABLE: + break; + case ET_NOT_BOOTABLE: + default: + return; + } + + if (initial) + platform = "default"; + else + platform = system_id_string(platform_id); + + fprintf(outfile, + "et_platform=%s;et_system=%s;et_lba=%d;et_sectors=%d\n", + platform, system_id_string(bcse->system_type[0]), + isonum_731(bcse->load_rba), isonum_721(bcse->sector_count)); +} + +static struct outputter _output_shell = { + .output_image = NULL, + .output_section = NULL, + .output_entry = output_entry, +}; + +struct outputter *output_shell = &_output_shell; Added: head/usr.bin/etdump/output_text.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/etdump/output_text.c Tue Apr 3 21:08:10 2018 (r331949) @@ -0,0 +1,97 @@ +/*- + * Copyright (c) 2018 iXsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include "cd9660.h" +#include "cd9660_eltorito.h" + +#include "etdump.h" + +static void +output_image(FILE *outfile, const char *filename, boot_volume_descriptor *bvd __unused) +{ + + fprintf(outfile, "Image in %s\n", filename); +} + +static void +output_section(FILE *outfile, const char *filename __unused, + boot_catalog_section_header *bcsh) +{ + + fprintf(outfile, "\nSection header: %s", + system_id_string(bcsh->platform_id[0])); + + if (bcsh->header_indicator[0] == ET_SECTION_HEADER_LAST) + fprintf(outfile, ", final\n"); + else + fprintf(outfile, "\n"); +} + +static void +output_entry(FILE *outfile, const char *filename __unused, + boot_catalog_section_entry *bcse, u_char platform_id __unused, + bool initial) +{ + const char *indent; + + switch (bcse->boot_indicator[0]) { + case ET_BOOTABLE: + break; + case ET_NOT_BOOTABLE: + default: + return; + } + + if (initial) { + fprintf(outfile, "Default entry\n"); + indent = "\t"; + } else { + fprintf(outfile, "\tSection entry\n"); + indent = "\t\t"; + } + + fprintf(outfile, "%sSystem %s\n", indent, + system_id_string(bcse->system_type[0])); + fprintf(outfile, "%sStart LBA %d (0x%x), sector count %d (0x%x)\n", + indent, isonum_731(bcse->load_rba), isonum_731(bcse->load_rba), + isonum_721(bcse->sector_count), isonum_721(bcse->sector_count)); + fprintf(outfile, "%sMedia type: %s\n", indent, + media_type_string(bcse->media_type[0])); +} + +static struct outputter _output_text = { + .output_image = output_image, + .output_section = output_section, + .output_entry = output_entry, +}; + +struct outputter *output_text = &_output_text; From owner-svn-src-head@freebsd.org Tue Apr 3 21:16:42 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DECADF813E1; Tue, 3 Apr 2018 21:16:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9042275151; Tue, 3 Apr 2018 21:16:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8A9ED1F5E; Tue, 3 Apr 2018 21:16:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33LGfWX027162; Tue, 3 Apr 2018 21:16:41 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33LGfRq027160; Tue, 3 Apr 2018 21:16:41 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201804032116.w33LGfRq027160@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 3 Apr 2018 21:16:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331950 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 331950 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 21:16:42 -0000 Author: mav Date: Tue Apr 3 21:16:41 2018 New Revision: 331950 URL: https://svnweb.freebsd.org/changeset/base/331950 Log: 9434 Speculative prefetch is blocked by device removal code. Device removal code does not set spa_indirect_vdevs_loaded for pools that never experienced device removal. At least one visual consequence of it is completely blocked speculative prefetcher. This patch sets the variable in such situations. Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_removal.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_removal.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_removal.c Tue Apr 3 21:08:10 2018 (r331949) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_removal.c Tue Apr 3 21:16:41 2018 (r331950) @@ -368,6 +368,7 @@ spa_remove_init(spa_t *spa) spa->spa_removing_phys.sr_state = DSS_NONE; spa->spa_removing_phys.sr_removing_vdev = -1; spa->spa_removing_phys.sr_prev_indirect_vdev = -1; + spa->spa_indirect_vdevs_loaded = B_TRUE; return (0); } else if (error != 0) { return (error); From owner-svn-src-head@freebsd.org Tue Apr 3 21:17:20 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A6BB3F81463; Tue, 3 Apr 2018 21:17:20 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 563FD752A3; Tue, 3 Apr 2018 21:17:20 +0000 (UTC) (envelope-from mw@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 508881F60; Tue, 3 Apr 2018 21:17:20 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33LHKqm027885; Tue, 3 Apr 2018 21:17:20 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33LHJkZ027875; Tue, 3 Apr 2018 21:17:19 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804032117.w33LHJkZ027875@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Tue, 3 Apr 2018 21:17:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331951 - in head/sys/arm: conf include mv X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys/arm: conf include mv X-SVN-Commit-Revision: 331951 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 21:17:20 -0000 Author: mw Date: Tue Apr 3 21:17:19 2018 New Revision: 331951 URL: https://svnweb.freebsd.org/changeset/base/331951 Log: Enable ArmadaXP using INTRNG interrupt controller Defining INTRNG remove some necessary registers and declarations of pic_init_secondary, pic_ipi_send, pic_ipi_read and pic_ipi_clear. Because Marvell ArmadaXP and Armada38X always use INTRNG, include all INTRNG code and remove code that does not use it. Separate pic registers declarations for Armada38X are unnecessary, it works properly with ArmadaXP config. Submitted by: Rafal Kozik Reviewed by: andrew Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14734 Modified: head/sys/arm/conf/ARMADAXP head/sys/arm/include/intr.h head/sys/arm/mv/mpic.c head/sys/arm/mv/mvreg.h Modified: head/sys/arm/conf/ARMADAXP ============================================================================== --- head/sys/arm/conf/ARMADAXP Tue Apr 3 21:16:41 2018 (r331950) +++ head/sys/arm/conf/ARMADAXP Tue Apr 3 21:17:19 2018 (r331951) @@ -88,3 +88,5 @@ device pci options FDT # Configure using FDT/DTB data options FDT_DTB_STATIC makeoptions FDT_DTS_FILE=db78460.dts + +options INTRNG Modified: head/sys/arm/include/intr.h ============================================================================== --- head/sys/arm/include/intr.h Tue Apr 3 21:16:41 2018 (r331950) +++ head/sys/arm/include/intr.h Tue Apr 3 21:17:19 2018 (r331951) @@ -84,13 +84,6 @@ int intr_pic_ipi_setup(u_int, const char *, intr_ipi_h #define NIRQ 288 #elif defined(CPU_ARM1176) #define NIRQ 128 -#elif defined(SOC_MV_ARMADAXP) -#define MAIN_IRQ_NUM 116 -#define ERR_IRQ_NUM 32 -#define ERR_IRQ (MAIN_IRQ_NUM) -#define MSI_IRQ_NUM 32 -#define MSI_IRQ (ERR_IRQ + ERR_IRQ_NUM) -#define NIRQ (MAIN_IRQ_NUM + ERR_IRQ_NUM + MSI_IRQ_NUM) #else #define NIRQ 32 #endif Modified: head/sys/arm/mv/mpic.c ============================================================================== --- head/sys/arm/mv/mpic.c Tue Apr 3 21:16:41 2018 (r331950) +++ head/sys/arm/mv/mpic.c Tue Apr 3 21:17:19 2018 (r331951) @@ -103,12 +103,10 @@ __FBSDID("$FreeBSD$"); #define MPIC_PPI 32 -#ifdef INTRNG struct mv_mpic_irqsrc { struct intr_irqsrc mmi_isrc; u_int mmi_irq; }; -#endif struct mv_mpic_softc { device_t sc_dev; @@ -120,9 +118,7 @@ struct mv_mpic_softc { bus_space_tag_t drbl_bst; bus_space_handle_t drbl_bsh; struct mtx mtx; -#ifdef INTRNG struct mv_mpic_irqsrc * mpic_isrcs; -#endif int nirqs; void * intr_hand; }; @@ -155,10 +151,12 @@ static void mpic_mask_irq(uintptr_t nb); static void mpic_mask_irq_err(uintptr_t nb); static void mpic_unmask_irq_err(uintptr_t nb); static boolean_t mpic_irq_is_percpu(uintptr_t); -#ifdef INTRNG static int mpic_intr(void *arg); -#endif static void mpic_unmask_msi(void); +void mpic_init_secondary(device_t); +void mpic_ipi_send(device_t, struct intr_irqsrc*, cpuset_t, u_int); +int mpic_ipi_read(int); +void mpic_ipi_clear(int); #define MPIC_WRITE(softc, reg, val) \ bus_space_write_4((softc)->mpic_bst, (softc)->mpic_bsh, (reg), (val)) @@ -189,7 +187,6 @@ mv_mpic_probe(device_t dev) return (0); } -#ifdef INTRNG static int mv_mpic_register_isrcs(struct mv_mpic_softc *sc) { @@ -221,7 +218,6 @@ mv_mpic_register_isrcs(struct mv_mpic_softc *sc) } return (0); } -#endif static int mv_mpic_attach(device_t dev) @@ -246,13 +242,11 @@ mv_mpic_attach(device_t dev) device_printf(dev, "could not allocate resources\n"); return (ENXIO); } -#ifdef INTRNG if (sc->mpic_res[3] == NULL) device_printf(dev, "No interrupt to use.\n"); else bus_setup_intr(dev, sc->mpic_res[3], INTR_TYPE_CLK, mpic_intr, NULL, sc, &sc->intr_hand); -#endif sc->mpic_bst = rman_get_bustag(sc->mpic_res[0]); sc->mpic_bsh = rman_get_bushandle(sc->mpic_res[0]); @@ -272,7 +266,6 @@ mv_mpic_attach(device_t dev) val = MPIC_READ(mv_mpic_sc, MPIC_CTRL); sc->nirqs = MPIC_CTRL_NIRQS(val); -#ifdef INTRNG if (mv_mpic_register_isrcs(sc) != 0) { device_printf(dev, "could not register PIC ISRCs\n"); bus_release_resources(dev, mv_mpic_spec, sc->mpic_res); @@ -286,7 +279,6 @@ mv_mpic_attach(device_t dev) bus_release_resources(dev, mv_mpic_spec, sc->mpic_res); return (ENXIO); } -#endif mpic_unmask_msi(); @@ -299,7 +291,6 @@ mv_mpic_attach(device_t dev) return (0); } -#ifdef INTRNG static int mpic_intr(void *arg) { @@ -386,20 +377,19 @@ static void mpic_post_filter(device_t dev, struct intr_irqsrc *isrc) { } -#endif static device_method_t mv_mpic_methods[] = { DEVMETHOD(device_probe, mv_mpic_probe), DEVMETHOD(device_attach, mv_mpic_attach), -#ifdef INTRNG DEVMETHOD(pic_disable_intr, mpic_disable_intr), DEVMETHOD(pic_enable_intr, mpic_enable_intr), DEVMETHOD(pic_map_intr, mpic_map_intr), DEVMETHOD(pic_post_filter, mpic_post_filter), DEVMETHOD(pic_post_ithread, mpic_post_ithread), DEVMETHOD(pic_pre_ithread, mpic_pre_ithread), -#endif + DEVMETHOD(pic_init_secondary, mpic_init_secondary), + DEVMETHOD(pic_ipi_send, mpic_ipi_send), { 0, 0 } }; @@ -414,46 +404,6 @@ static devclass_t mv_mpic_devclass; EARLY_DRIVER_MODULE(mpic, simplebus, mv_mpic_driver, mv_mpic_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); -#ifndef INTRNG -int -arm_get_next_irq(int last) -{ - u_int irq, next = -1; - - irq = mv_mpic_get_cause() & MPIC_IRQ_MASK; - CTR2(KTR_INTR, "%s: irq:%#x", __func__, irq); - - if (irq != MPIC_IRQ_MASK) { - if (irq == MPIC_INT_ERR) - irq = mv_mpic_get_cause_err(); - if (irq == MPIC_INT_MSI) - irq = mv_mpic_get_msi(); - next = irq; - } - - CTR3(KTR_INTR, "%s: last=%d, next=%d", __func__, last, next); - return (next); -} - -/* - * XXX We can make arm_enable_irq to operate on ICE and then mask/unmask only - * by ISM/ICM and remove access to ICE in masking operation - */ -void -arm_mask_irq(uintptr_t nb) -{ - - mpic_mask_irq(nb); -} - -void -arm_unmask_irq(uintptr_t nb) -{ - - mpic_unmask_irq(nb); -} -#endif - static void mpic_unmask_msi(void) { @@ -621,15 +571,13 @@ mv_msi_data(int irq, uint64_t *addr, uint32_t *data) return (0); } - -#if defined(SMP) && defined(SOC_MV_ARMADAXP) void -intr_pic_init_secondary(void) +mpic_init_secondary(device_t dev) { } void -pic_ipi_send(cpuset_t cpus, u_int ipi) +mpic_ipi_send(device_t dev, struct intr_irqsrc *isrc, cpuset_t cpus, u_int ipi) { uint32_t val, i; @@ -642,7 +590,7 @@ pic_ipi_send(cpuset_t cpus, u_int ipi) } int -pic_ipi_read(int i __unused) +mpic_ipi_read(int i __unused) { uint32_t val; int ipi; @@ -658,8 +606,6 @@ pic_ipi_read(int i __unused) } void -pic_ipi_clear(int ipi) +mpic_ipi_clear(int ipi) { } - -#endif Modified: head/sys/arm/mv/mvreg.h ============================================================================== --- head/sys/arm/mv/mvreg.h Tue Apr 3 21:16:41 2018 (r331950) +++ head/sys/arm/mv/mvreg.h Tue Apr 3 21:17:19 2018 (r331951) @@ -54,12 +54,6 @@ #define ENDPOINT_IRQ_MASK(n) 0x30 #define ENDPOINT_IRQ_MASK_HI(n) 0x34 #define ENDPOINT_IRQ_CAUSE_SELECT 0x38 -#elif defined (SOC_MV_ARMADAXP) -#define IRQ_CAUSE 0x18 -#define IRQ_MASK 0x30 -#elif defined (SOC_MV_ARMADA38X) -#define MSI_IRQ 0x3ff -#define ERR_IRQ 0x3ff #else #define IRQ_CAUSE 0x0 #define IRQ_MASK 0x4 @@ -74,6 +68,14 @@ #define IRQ_MASK_ERROR (-1) /* interrupt controller code */ #endif +#define MAIN_IRQ_NUM 116 +#define ERR_IRQ_NUM 32 +#define ERR_IRQ (MAIN_IRQ_NUM) +#define MSI_IRQ (ERR_IRQ + ERR_IRQ_NUM) + +#define MSI_IRQ_NUM 32 + +#define IRQ_CPU_SELF 0x00000001 #if defined(SOC_MV_ARMADAXP) #define BRIDGE_IRQ_CAUSE 0x68 #define IRQ_TIMER0 0x00000001 From owner-svn-src-head@freebsd.org Tue Apr 3 21:25:16 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1ACB8F81E8D; Tue, 3 Apr 2018 21:25:16 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E37F075CD6; Tue, 3 Apr 2018 21:25:15 +0000 (UTC) (envelope-from mw@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 DE643212A; Tue, 3 Apr 2018 21:25:15 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33LPF4p040445; Tue, 3 Apr 2018 21:25:15 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33LPFIK040441; Tue, 3 Apr 2018 21:25:15 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804032125.w33LPFIK040441@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Tue, 3 Apr 2018 21:25:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331953 - head/sys/arm/mv X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/arm/mv X-SVN-Commit-Revision: 331953 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 21:25:16 -0000 Author: mw Date: Tue Apr 3 21:25:15 2018 New Revision: 331953 URL: https://svnweb.freebsd.org/changeset/base/331953 Log: Make Marvell mv_pci.c driver generic PCI ports differ between Marvell SoCs, but have the same compatible in FDT. Identification is made based on parent compatible during attach. For ArmadaXP skipping enable procedure is necessary. To achieve it sc_skip_enable_procedure flag is used. For Armada38x find root procedure is necessary. For other SoCs root link is always at slot 0. sc_enable_find_root_slot flag is used to select proper behaviour. Marvell armv5 platforms does not support msi. Submitted by: Rafal Kozik Reviewed by: andrew Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14735 Modified: head/sys/arm/mv/mv_pci.c head/sys/arm/mv/mvwin.h Modified: head/sys/arm/mv/mv_pci.c ============================================================================== --- head/sys/arm/mv/mv_pci.c Tue Apr 3 21:22:43 2018 (r331952) +++ head/sys/arm/mv/mv_pci.c Tue Apr 3 21:25:15 2018 (r331953) @@ -308,6 +308,9 @@ struct mv_pcib_softc { int sc_type; int sc_mode; /* Endpoint / Root Complex */ + int sc_msi_supported; + int sc_skip_enable_procedure; + int sc_enable_find_root_slot; struct ofw_bus_iinfo sc_pci_iinfo; }; @@ -341,11 +344,10 @@ static uint32_t mv_pcib_read_config(device_t, u_int, u static void mv_pcib_write_config(device_t, u_int, u_int, u_int, u_int, uint32_t, int); static int mv_pcib_route_interrupt(device_t, device_t, int); -#if defined(SOC_MV_ARMADAXP) + static int mv_pcib_alloc_msi(device_t, device_t, int, int, int *); static int mv_pcib_map_msi(device_t, device_t, int, uint64_t *, uint32_t *); static int mv_pcib_release_msi(device_t, device_t, int, int *); -#endif /* * Bus interface definitions. @@ -371,11 +373,10 @@ static device_method_t mv_pcib_methods[] = { DEVMETHOD(pcib_write_config, mv_pcib_write_config), DEVMETHOD(pcib_route_interrupt, mv_pcib_route_interrupt), DEVMETHOD(pcib_request_feature, pcib_request_feature_allow), -#if defined(SOC_MV_ARMADAXP) + DEVMETHOD(pcib_alloc_msi, mv_pcib_alloc_msi), DEVMETHOD(pcib_release_msi, mv_pcib_release_msi), DEVMETHOD(pcib_map_msi, mv_pcib_map_msi), -#endif /* OFW bus interface */ DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), @@ -442,9 +443,19 @@ mv_pcib_attach(device_t self) if (ofw_bus_node_is_compatible(node, "mrvl,pcie")) { sc->sc_type = MV_TYPE_PCIE; - sc->sc_win_target = MV_WIN_PCIE_TARGET(port_id); - sc->sc_mem_win_attr = MV_WIN_PCIE_MEM_ATTR(port_id); - sc->sc_io_win_attr = MV_WIN_PCIE_IO_ATTR(port_id); + if (ofw_bus_node_is_compatible(parnode, "marvell,armada-370-pcie")) { + sc->sc_win_target = MV_WIN_PCIE_TARGET_ARMADA38X(port_id); + sc->sc_mem_win_attr = MV_WIN_PCIE_MEM_ATTR_ARMADA38X(port_id); + sc->sc_io_win_attr = MV_WIN_PCIE_IO_ATTR_ARMADA38X(port_id); + sc->sc_enable_find_root_slot = 1; + } else { + sc->sc_win_target = MV_WIN_PCIE_TARGET(port_id); + sc->sc_mem_win_attr = MV_WIN_PCIE_MEM_ATTR(port_id); + sc->sc_io_win_attr = MV_WIN_PCIE_IO_ATTR(port_id); +#if __ARM_ARCH >= 6 + sc->sc_skip_enable_procedure = 1; +#endif + } } else if (ofw_bus_node_is_compatible(node, "mrvl,pci")) { sc->sc_type = MV_TYPE_PCI; sc->sc_win_target = MV_WIN_PCI_TARGET; @@ -541,9 +552,11 @@ static void mv_pcib_enable(struct mv_pcib_softc *sc, uint32_t unit) { uint32_t val; -#if !defined(SOC_MV_ARMADAXP) int timeout; + if (sc->sc_skip_enable_procedure) + goto pcib_enable_root_mode; + /* * Check if PCIE device is enabled. */ @@ -561,9 +574,8 @@ mv_pcib_enable(struct mv_pcib_softc *sc, uint32_t unit PCIE_REG_STATUS); } } -#endif - +pcib_enable_root_mode: if (sc->sc_mode == MV_MODE_ROOT) { /* * Enable PCI bridge. @@ -1042,20 +1054,19 @@ mv_pcib_maxslots(device_t dev) static int mv_pcib_root_slot(device_t dev, u_int bus, u_int slot, u_int func) { -#if defined(SOC_MV_ARMADA38X) struct mv_pcib_softc *sc = device_get_softc(dev); uint32_t vendor, device; +/* On platforms other than Armada38x, root link is always at slot 0 */ + if (!sc->sc_enable_find_root_slot) + return (slot == 0); + vendor = mv_pcib_hw_cfgread(sc, bus, slot, func, PCIR_VENDOR, PCIR_VENDOR_LENGTH); device = mv_pcib_hw_cfgread(sc, bus, slot, func, PCIR_DEVICE, PCIR_DEVICE_LENGTH) & MV_DEV_FAMILY_MASK; return (vendor == PCI_VENDORID_MRVL && device == MV_DEV_ARMADA38X); -#else - /* On platforms other than Armada38x, root link is always at slot 0 */ - return (slot == 0); -#endif } static uint32_t @@ -1159,7 +1170,6 @@ mv_pcib_decode_win(phandle_t node, struct mv_pcib_soft return (0); } -#if defined(SOC_MV_ARMADAXP) static int mv_pcib_map_msi(device_t dev, device_t child, int irq, uint64_t *addr, uint32_t *data) @@ -1167,6 +1177,9 @@ mv_pcib_map_msi(device_t dev, device_t child, int irq, struct mv_pcib_softc *sc; sc = device_get_softc(dev); + if (!sc->sc_msi_supported) + return (ENOTSUP); + irq = irq - MSI_IRQ; /* validate parameters */ @@ -1175,7 +1188,9 @@ mv_pcib_map_msi(device_t dev, device_t child, int irq, return (EINVAL); } +#if __ARM_ARCH >= 6 mv_msi_data(irq, addr, data); +#endif debugf("%s: irq: %d addr: %jx data: %x\n", __func__, irq, *addr, *data); @@ -1190,10 +1205,13 @@ mv_pcib_alloc_msi(device_t dev, device_t child, int co struct mv_pcib_softc *sc; u_int start = 0, i; + sc = device_get_softc(dev); + if (!sc->sc_msi_supported) + return (ENOTSUP); + if (powerof2(count) == 0 || count > MSI_IRQ_NUM) return (EINVAL); - sc = device_get_softc(dev); mtx_lock(&sc->sc_msi_mtx); for (start = 0; (start + count) < MSI_IRQ_NUM; start++) { @@ -1227,6 +1245,9 @@ mv_pcib_release_msi(device_t dev, device_t child, int u_int i; sc = device_get_softc(dev); + if(!sc->sc_msi_supported) + return (ENOTSUP); + mtx_lock(&sc->sc_msi_mtx); for (i = 0; i < count; i++) @@ -1235,5 +1256,3 @@ mv_pcib_release_msi(device_t dev, device_t child, int mtx_unlock(&sc->sc_msi_mtx); return (0); } -#endif - Modified: head/sys/arm/mv/mvwin.h ============================================================================== --- head/sys/arm/mv/mvwin.h Tue Apr 3 21:22:43 2018 (r331952) +++ head/sys/arm/mv/mvwin.h Tue Apr 3 21:25:15 2018 (r331953) @@ -64,12 +64,8 @@ #define MV_PCI_PORTS 1 /* 1x PCIE */ #elif defined(SOC_MV_DISCOVERY) #define MV_PCI_PORTS 8 /* 8x PCIE */ -#elif defined(SOC_MV_ARMADAXP) -#define MV_PCI_PORTS 3 /* 3x PCIE */ -#elif defined(SOC_MV_ARMADA38X) -#define MV_PCI_PORTS 4 /* 4x PCIE */ #else -#error "MV_PCI_PORTS not configured !" +#define MV_PCI_PORTS 1 /* 1x PCIE -> worst case */ #endif /* PCI/PCIE Memory */ @@ -77,15 +73,11 @@ #define MV_PCI_MEM_SIZE (512 * 1024 * 1024) /* 512 MB */ #define MV_PCI_MEM_BASE MV_PCI_MEM_PHYS_BASE #define MV_PCI_MEM_SLICE_SIZE (MV_PCI_MEM_SIZE / MV_PCI_PORTS) -#define MV_PCI_MEM_SLICE(n) (MV_PCI_MEM_BASE + ((n) * \ - MV_PCI_MEM_SLICE_SIZE)) /* PCI/PCIE I/O */ #define MV_PCI_IO_PHYS_BASE 0xBF000000 #define MV_PCI_IO_SIZE (16 * 1024 * 1024) /* 16 MB */ #define MV_PCI_IO_BASE MV_PCI_IO_PHYS_BASE #define MV_PCI_IO_SLICE_SIZE (MV_PCI_IO_SIZE / MV_PCI_PORTS) -#define MV_PCI_IO_SLICE(n) (MV_PCI_IO_BASE + ((n) * MV_PCI_IO_SLICE_SIZE)) - #define MV_PCI_VA_MEM_BASE 0 #define MV_PCI_VA_IO_BASE 0 @@ -131,22 +123,9 @@ #define MV_PCI_BASE (MV_BASE + 0x30000) #define MV_PCI_SIZE 0x2000 -#if defined(SOC_MV_ARMADA38X) -#define MV_PCIE_BASE (MV_BASE + 0x80000) -#else +#define MV_PCIE_BASE_ARMADA38X (MV_BASE + 0x80000) #define MV_PCIE_BASE (MV_BASE + 0x40000) -#endif #define MV_PCIE_SIZE 0x2000 - -#define MV_PCIE00_BASE (MV_PCIE_BASE + 0x00000) -#define MV_PCIE01_BASE (MV_PCIE_BASE + 0x04000) -#define MV_PCIE02_BASE (MV_PCIE_BASE + 0x08000) -#define MV_PCIE03_BASE (MV_PCIE_BASE + 0x0C000) -#define MV_PCIE10_BASE (MV_PCIE_BASE + 0x40000) -#define MV_PCIE11_BASE (MV_PCIE_BASE + 0x44000) -#define MV_PCIE12_BASE (MV_PCIE_BASE + 0x48000) -#define MV_PCIE13_BASE (MV_PCIE_BASE + 0x4C000) - #define MV_SDIO_BASE (MV_BASE + 0x90000) #define MV_SDIO_SIZE 0x10000 @@ -255,22 +234,24 @@ #define MV_XOR_CHAN_MAX 2 #define MV_XOR_NON_REMAP 4 +#define MV_WIN_PCIE_TARGET_ARMADAXP(n) (4 + (4 * ((n) % 2))) +#define MV_WIN_PCIE_MEM_ATTR_ARMADAXP(n) (0xE8 + (0x10 * ((n) / 2))) +#define MV_WIN_PCIE_IO_ATTR_ARMADAXP(n) (0xE0 + (0x10 * ((n) / 2))) +#define MV_WIN_PCIE_TARGET_ARMADA38X(n) ((n) == 0 ? 8 : 4) +#define MV_WIN_PCIE_MEM_ATTR_ARMADA38X(n) ((n) < 2 ? 0xE8 : (0xD8 - (((n) % 2) * 0x20))) +#define MV_WIN_PCIE_IO_ATTR_ARMADA38X(n) ((n) < 2 ? 0xE0 : (0xD0 - (((n) % 2) * 0x20))) #if defined(SOC_MV_DISCOVERY) || defined(SOC_MV_KIRKWOOD) #define MV_WIN_PCIE_TARGET(n) 4 #define MV_WIN_PCIE_MEM_ATTR(n) 0xE8 #define MV_WIN_PCIE_IO_ATTR(n) 0xE0 -#elif defined(SOC_MV_ARMADAXP) -#define MV_WIN_PCIE_TARGET(n) (4 + (4 * ((n) % 2))) -#define MV_WIN_PCIE_MEM_ATTR(n) (0xE8 + (0x10 * ((n) / 2))) -#define MV_WIN_PCIE_IO_ATTR(n) (0xE0 + (0x10 * ((n) / 2))) -#elif defined(SOC_MV_ARMADA38X) -#define MV_WIN_PCIE_TARGET(n) ((n) == 0 ? 8 : 4) -#define MV_WIN_PCIE_MEM_ATTR(n) ((n) < 2 ? 0xE8 : (0xD8 - (((n) % 2) * 0x20))) -#define MV_WIN_PCIE_IO_ATTR(n) ((n) < 2 ? 0xE0 : (0xD0 - (((n) % 2) * 0x20))) #elif defined(SOC_MV_ORION) #define MV_WIN_PCIE_TARGET(n) 4 #define MV_WIN_PCIE_MEM_ATTR(n) 0x59 #define MV_WIN_PCIE_IO_ATTR(n) 0x51 +#else +#define MV_WIN_PCIE_TARGET(n) (4 + (4 * ((n) % 2))) +#define MV_WIN_PCIE_MEM_ATTR(n) (0xE8 + (0x10 * ((n) / 2))) +#define MV_WIN_PCIE_IO_ATTR(n) (0xE0 + (0x10 * ((n) / 2))) #endif #define MV_WIN_PCI_TARGET 3 From owner-svn-src-head@freebsd.org Tue Apr 3 21:38:12 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD1D8F82CB0; Tue, 3 Apr 2018 21:38:12 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5B3A276764; Tue, 3 Apr 2018 21:38:12 +0000 (UTC) (envelope-from mw@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 55E5922DD; Tue, 3 Apr 2018 21:38:12 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33LcCwp057698; Tue, 3 Apr 2018 21:38:12 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33LcBiD057685; Tue, 3 Apr 2018 21:38:11 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804032138.w33LcBiD057685@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Tue, 3 Apr 2018 21:38:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331954 - in head/sys/arm/mv: . armada38x armadaxp X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys/arm/mv: . armada38x armadaxp X-SVN-Commit-Revision: 331954 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 21:38:13 -0000 Author: mw Date: Tue Apr 3 21:38:11 2018 New Revision: 331954 URL: https://svnweb.freebsd.org/changeset/base/331954 Log: Split get_sar_value function for Marvell ArmadaXP and Armada38X get_sar_value is implemented only for ArmadaXP and Armada38X. Splitting it for two different functions and change registers names result in more generic code. Submitted by: Rafal Kozik Reviewed by: andrew Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14736 Modified: head/sys/arm/mv/armada38x/armada38x.c head/sys/arm/mv/armadaxp/armadaxp.c head/sys/arm/mv/mv_common.c head/sys/arm/mv/mvreg.h head/sys/arm/mv/mvvar.h Modified: head/sys/arm/mv/armada38x/armada38x.c ============================================================================== --- head/sys/arm/mv/armada38x/armada38x.c Tue Apr 3 21:25:15 2018 (r331953) +++ head/sys/arm/mv/armada38x/armada38x.c Tue Apr 3 21:38:11 2018 (r331954) @@ -43,11 +43,23 @@ int armada38x_open_bootrom_win(void); int armada38x_scu_enable(void); int armada38x_win_set_iosync_barrier(void); int armada38x_mbus_optimization(void); +static uint64_t get_sar_value_armada38x(void); static int hw_clockrate; SYSCTL_INT(_hw, OID_AUTO, clockrate, CTLFLAG_RD, &hw_clockrate, 0, "CPU instruction clock rate"); +static uint64_t +get_sar_value_armada38x(void) +{ + uint32_t sar_low, sar_high; + + sar_high = 0; + sar_low = bus_space_read_4(fdtbus_bs_tag, MV_MISC_BASE, + SAMPLE_AT_RESET_ARMADA38X); + return (((uint64_t)sar_high << 32) | sar_low); +} + uint32_t get_tclk(void) { @@ -57,8 +69,8 @@ get_tclk(void) * On Armada38x TCLK can be configured to 250 MHz or 200 MHz. * Current setting is read from Sample At Reset register. */ - sar = (uint32_t)get_sar_value(); - sar = (sar & TCLK_MASK) >> TCLK_SHIFT; + sar = (uint32_t)get_sar_value_armada38x(); + sar = (sar & TCLK_MASK_ARMADA38X) >> TCLK_SHIFT_ARMADA38X; if (sar == 0) return (TCLK_250MHZ); else @@ -78,7 +90,7 @@ get_cpu_freq(void) 1866, 0, 0, 2000 }; - sar = (uint32_t)get_sar_value(); + sar = (uint32_t)get_sar_value_armada38x(); sar = (sar & A38X_CPU_DDR_CLK_MASK) >> A38X_CPU_DDR_CLK_SHIFT; if (sar >= nitems(cpu_frequencies)) return (0); Modified: head/sys/arm/mv/armadaxp/armadaxp.c ============================================================================== --- head/sys/arm/mv/armadaxp/armadaxp.c Tue Apr 3 21:25:15 2018 (r331953) +++ head/sys/arm/mv/armadaxp/armadaxp.c Tue Apr 3 21:38:11 2018 (r331954) @@ -55,6 +55,7 @@ static uint32_t count_l2clk(void); void armadaxp_l2_init(void); void armadaxp_init_coher_fabric(void); int platform_get_ncpus(void); +static uint64_t get_sar_value_armadaxp(void); #define ARMADAXP_L2_BASE (MV_BASE + 0x8000) #define ARMADAXP_L2_CTRL 0x100 @@ -124,6 +125,18 @@ static uint16_t cpu_clock_table[] = { 1000, 1066, 1200, 1333, 1500, 1666, 1800, 2000, 600, 667, 800, 1600, 2133, 2200, 2400 }; +static uint64_t +get_sar_value_armadaxp(void) +{ + uint32_t sar_low, sar_high; + + sar_high = bus_space_read_4(fdtbus_bs_tag, MV_MISC_BASE, + SAMPLE_AT_RESET_HI); + sar_low = bus_space_read_4(fdtbus_bs_tag, MV_MISC_BASE, + SAMPLE_AT_RESET_LO); + return (((uint64_t)sar_high << 32) | sar_low); +} + uint32_t get_tclk(void) { @@ -153,7 +166,7 @@ count_l2clk(void) uint8_t sar_cpu_freq, sar_fab_freq, array_size; /* Get value of the SAR register and process it */ - sar_reg = get_sar_value(); + sar_reg = get_sar_value_armadaxp(); sar_cpu_freq = CPU_FREQ_FIELD(sar_reg); sar_fab_freq = FAB_FREQ_FIELD(sar_reg); Modified: head/sys/arm/mv/mv_common.c ============================================================================== --- head/sys/arm/mv/mv_common.c Tue Apr 3 21:25:15 2018 (r331953) +++ head/sys/arm/mv/mv_common.c Tue Apr 3 21:38:11 2018 (r331954) @@ -2664,28 +2664,3 @@ fdt_pic_decode_t fdt_pic_table[] = { NULL }; #endif - -uint64_t -get_sar_value(void) -{ - uint32_t sar_low, sar_high; - -#if defined(SOC_MV_ARMADAXP) - sar_high = bus_space_read_4(fdtbus_bs_tag, MV_MISC_BASE, - SAMPLE_AT_RESET_HI); - sar_low = bus_space_read_4(fdtbus_bs_tag, MV_MISC_BASE, - SAMPLE_AT_RESET_LO); -#elif defined(SOC_MV_ARMADA38X) - sar_high = 0; - sar_low = bus_space_read_4(fdtbus_bs_tag, MV_MISC_BASE, - SAMPLE_AT_RESET); -#else - /* - * TODO: Add getting proper values for other SoC configurations - */ - sar_high = 0; - sar_low = 0; -#endif - - return (((uint64_t)sar_high << 32) | sar_low); -} Modified: head/sys/arm/mv/mvreg.h ============================================================================== --- head/sys/arm/mv/mvreg.h Tue Apr 3 21:25:15 2018 (r331953) +++ head/sys/arm/mv/mvreg.h Tue Apr 3 21:38:11 2018 (r331954) @@ -327,13 +327,10 @@ #define SAMPLE_AT_RESET 0x10 #elif defined(SOC_MV_KIRKWOOD) #define SAMPLE_AT_RESET 0x30 -#elif defined(SOC_MV_ARMADA38X) -#define SAMPLE_AT_RESET 0x400 #endif -#if defined(SOC_MV_DISCOVERY) || defined(SOC_MV_ARMADAXP) -#define SAMPLE_AT_RESET_LO 0x30 -#define SAMPLE_AT_RESET_HI 0x34 -#endif +#define SAMPLE_AT_RESET_ARMADA38X 0x400 +#define SAMPLE_AT_RESET_LO 0x30 +#define SAMPLE_AT_RESET_HI 0x34 /* * Clocks @@ -344,10 +341,10 @@ #elif defined(SOC_MV_DISCOVERY) #define TCLK_MASK 0x00000180 #define TCLK_SHIFT 0x07 -#elif defined(SOC_MV_ARMADA38X) -#define TCLK_MASK 0x00008000 -#define TCLK_SHIFT 15 #endif + +#define TCLK_MASK_ARMADA38X 0x00008000 +#define TCLK_SHIFT_ARMADA38X 15 #define TCLK_100MHZ 100000000 #define TCLK_125MHZ 125000000 Modified: head/sys/arm/mv/mvvar.h ============================================================================== --- head/sys/arm/mv/mvvar.h Tue Apr 3 21:25:15 2018 (r331953) +++ head/sys/arm/mv/mvvar.h Tue Apr 3 21:38:11 2018 (r331954) @@ -89,7 +89,6 @@ void soc_id(uint32_t *dev, uint32_t *rev); void soc_dump_decode_win(void); uint32_t soc_power_ctrl_get(uint32_t mask); void soc_power_ctrl_set(uint32_t mask); -uint64_t get_sar_value(void); int decode_win_cpu_set(int target, int attr, vm_paddr_t base, uint32_t size, vm_paddr_t remap); From owner-svn-src-head@freebsd.org Tue Apr 3 21:44:44 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2ABB2F83404; Tue, 3 Apr 2018 21:44:44 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CD33976DA1; Tue, 3 Apr 2018 21:44:43 +0000 (UTC) (envelope-from jilles@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 C80932481; Tue, 3 Apr 2018 21:44:43 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33LihCL068964; Tue, 3 Apr 2018 21:44:43 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33Lihl6068963; Tue, 3 Apr 2018 21:44:43 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201804032144.w33Lihl6068963@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Tue, 3 Apr 2018 21:44:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331955 - head/share/man/man8 X-SVN-Group: head X-SVN-Commit-Author: jilles X-SVN-Commit-Paths: head/share/man/man8 X-SVN-Commit-Revision: 331955 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 21:44:44 -0000 Author: jilles Date: Tue Apr 3 21:44:43 2018 New Revision: 331955 URL: https://svnweb.freebsd.org/changeset/base/331955 Log: rc.subr.8: Improve documentation of ${name}_limits and ${name}_login_class Submitted by: 0mp Differential Revision: https://reviews.freebsd.org/D14928 Modified: head/share/man/man8/rc.subr.8 Modified: head/share/man/man8/rc.subr.8 ============================================================================== --- head/share/man/man8/rc.subr.8 Tue Apr 3 21:38:11 2018 (r331954) +++ head/share/man/man8/rc.subr.8 Tue Apr 3 21:44:43 2018 (r331955) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 18, 2016 +.Dd April 3, 2018 .Dt RC.SUBR 8 .Os .Sh NAME @@ -584,21 +584,27 @@ Only supported after .Pa /usr is mounted. .It Va ${name}_limits -.Xr limits 1 -to apply to +Resource limits to apply to .Va command . This will be passed as arguments to the .Xr limits 1 utility. +By default, the resource limits are based on the login class defined in +.Va ${name}_login_class . +.It Va ${name}_login_class +Login class to use with +.Va ${name}_limits . +Defaults to +.Dq Li daemon . .It Va ${name}_oomprotect .Xr protect 1 .Va command from being killed when swap space is exhausted. If -.Em YES +.Dq Li YES is used, no child processes are protected. If -.Em ALL , +.Dq Li ALL , protect all child processes. .It Va ${name}_program Full path to the command. From owner-svn-src-head@freebsd.org Tue Apr 3 21:46:28 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B0E79F83603; Tue, 3 Apr 2018 21:46:28 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5FC3976FA1; Tue, 3 Apr 2018 21:46:28 +0000 (UTC) (envelope-from mw@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 5ABDE249B; Tue, 3 Apr 2018 21:46:28 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33LkSqc070575; Tue, 3 Apr 2018 21:46:28 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33LkSUA070574; Tue, 3 Apr 2018 21:46:28 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804032146.w33LkSUA070574@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Tue, 3 Apr 2018 21:46:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331956 - head/sys/arm/mv X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/arm/mv X-SVN-Commit-Revision: 331956 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 21:46:28 -0000 Author: mw Date: Tue Apr 3 21:46:28 2018 New Revision: 331956 URL: https://svnweb.freebsd.org/changeset/base/331956 Log: Make validation in Marvell mv_common.c generic Validate only drivers used by given platform. Pointers to validation function are added to soc_node_spec structure. Submitted by: Rafal Kozik Reviewed by: andrew Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14737 Modified: head/sys/arm/mv/mv_common.c Modified: head/sys/arm/mv/mv_common.c ============================================================================== --- head/sys/arm/mv/mv_common.c Tue Apr 3 21:44:43 2018 (r331955) +++ head/sys/arm/mv/mv_common.c Tue Apr 3 21:46:28 2018 (r331956) @@ -138,6 +138,7 @@ const struct decode_win *cpu_wins = cpu_win_tbl; typedef void (*decode_win_setup_t)(u_long); typedef void (*dump_win_t)(u_long); +typedef int (*valid_t)(void); /* * The power status of device feature is only supported on @@ -153,22 +154,27 @@ struct soc_node_spec { const char *compat; decode_win_setup_t decode_handler; dump_win_t dump_handler; + valid_t valid_handler; }; static struct soc_node_spec soc_nodes[] = { - { "mrvl,ge", &decode_win_eth_setup, &decode_win_eth_dump }, - { "marvell,armada-370-neta", &decode_win_neta_setup, &decode_win_neta_dump }, - { "mrvl,usb-ehci", &decode_win_usb_setup, &decode_win_usb_dump }, - { "marvell,orion-ehci", &decode_win_usb_setup, &decode_win_usb_dump }, - { "marvell,armada-380-xhci", &decode_win_usb3_setup, &decode_win_usb3_dump }, - { "marvell,armada-380-ahci", &decode_win_ahci_setup, &decode_win_ahci_dump }, - { "marvell,armada-380-sdhci", &decode_win_sdhci_setup, &decode_win_sdhci_dump }, - { "mrvl,sata", &decode_win_sata_setup, NULL }, - { "mrvl,xor", &decode_win_xor_setup, &decode_win_xor_dump }, - { "mrvl,idma", &decode_win_idma_setup, &decode_win_idma_dump }, - { "mrvl,cesa", &decode_win_cesa_setup, &decode_win_cesa_dump }, - { "mrvl,pcie", &decode_win_pcie_setup, &decode_win_pcie_dump }, - { NULL, NULL, NULL }, + { "mrvl,ge", &decode_win_eth_setup, &decode_win_eth_dump, &decode_win_eth_valid}, + { "marvell,armada-370-neta", &decode_win_neta_setup, + &decode_win_neta_dump, NULL }, + { "mrvl,usb-ehci", &decode_win_usb_setup, &decode_win_usb_dump, &decode_win_usb_valid}, + { "marvell,orion-ehci", &decode_win_usb_setup, &decode_win_usb_dump, &decode_win_usb_valid }, + { "marvell,armada-380-xhci", &decode_win_usb3_setup, + &decode_win_usb3_dump, &decode_win_usb3_valid }, + { "marvell,armada-380-ahci", &decode_win_ahci_setup, + &decode_win_ahci_dump, NULL }, + { "marvell,armada-380-sdhci", &decode_win_sdhci_setup, + &decode_win_sdhci_dump, &decode_win_sdhci_valid}, + { "mrvl,sata", &decode_win_sata_setup, NULL, &decode_win_sata_valid}, + { "mrvl,xor", &decode_win_xor_setup, &decode_win_xor_dump, &decode_win_xor_valid}, + { "mrvl,idma", &decode_win_idma_setup, &decode_win_idma_dump, &decode_win_idma_valid}, + { "mrvl,cesa", &decode_win_cesa_setup, &decode_win_cesa_dump, &decode_win_cesa_valid}, + { "mrvl,pcie", &decode_win_pcie_setup, &decode_win_pcie_dump, &decode_win_pcie_valid}, + { NULL, NULL, NULL, NULL }, }; struct fdt_pm_mask_entry { @@ -595,12 +601,6 @@ soc_decode_win(void) return(err); #endif - if (!decode_win_cpu_valid() || !decode_win_usb_valid() || - !decode_win_eth_valid() || !decode_win_idma_valid() || - !decode_win_pcie_valid() || !decode_win_sata_valid() || - !decode_win_xor_valid() || !decode_win_usb3_valid() || - !decode_win_sdhci_valid() || !decode_win_cesa_valid()) - return (EINVAL); decode_win_cpu_setup(); if (MV_DUMP_WIN) @@ -2461,6 +2461,10 @@ fdt_win_process(phandle_t child) else base = fdt_data_get(®[addr_cells - 2], 2); size = fdt_data_get(®[addr_cells], size_cells); + + if (soc_node->valid_handler != NULL) + if (!soc_node->valid_handler()) + return (EINVAL); base = (base & 0x000fffff) | fdt_immr_va; if (soc_node->decode_handler != NULL) From owner-svn-src-head@freebsd.org Tue Apr 3 21:54:37 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8B3E9F83D35; Tue, 3 Apr 2018 21:54:37 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3A51B77553; Tue, 3 Apr 2018 21:54:37 +0000 (UTC) (envelope-from mw@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 34450263E; Tue, 3 Apr 2018 21:54:37 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33Lsbne083291; Tue, 3 Apr 2018 21:54:37 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33Lsa4h083279; Tue, 3 Apr 2018 21:54:36 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804032154.w33Lsa4h083279@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Tue, 3 Apr 2018 21:54:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331957 - head/sys/arm/mv X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/arm/mv X-SVN-Commit-Revision: 331957 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 21:54:37 -0000 Author: mw Date: Tue Apr 3 21:54:36 2018 New Revision: 331957 URL: https://svnweb.freebsd.org/changeset/base/331957 Log: Make mv_common.c generic for Marvell Armada38X and ArmadaXP Preparation for adding Armada38X and ArmadaXP SoC to GENERIC config. Supported platform are listed in soc_family enum. struct decode_win_spec contains platform specific functions and constants. Function mv_check_soc_family checks SoC type and chooses proper structure in runtime, as well as platform-dependent functions. Unnecessary dummy functions are removed. Because of changing registers name to more generic new definition of FDT_DEVMAP_MAX in mv_machdep is added. Submitted by: Rafal Kozik Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14738 Modified: head/sys/arm/mv/mv_common.c head/sys/arm/mv/mv_machdep.c head/sys/arm/mv/mvreg.h head/sys/arm/mv/mvvar.h head/sys/arm/mv/mvwin.h Modified: head/sys/arm/mv/mv_common.c ============================================================================== --- head/sys/arm/mv/mv_common.c Tue Apr 3 21:46:28 2018 (r331956) +++ head/sys/arm/mv/mv_common.c Tue Apr 3 21:54:36 2018 (r331957) @@ -76,6 +76,19 @@ MALLOC_DEFINE(M_IDMA, "idma", "idma dma test memory"); #define MV_DUMP_WIN 0 #endif +static enum soc_family soc_family; + +static int mv_win_cesa_attr(int wng_sel); +static int mv_win_cesa_attr_armv5(int eng_sel); +static int mv_win_cesa_attr_armada38x(int eng_sel); +static int mv_win_cesa_attr_armadaxp(int eng_sel); + +uint32_t read_cpu_ctrl_armv5(uint32_t reg); +uint32_t read_cpu_ctrl_armv7(uint32_t reg); + +void write_cpu_ctrl_armv5(uint32_t reg, uint32_t val); +void write_cpu_ctrl_armv7(uint32_t reg, uint32_t val); + static int win_eth_can_remap(int i); static int decode_win_cesa_valid(void); @@ -91,9 +104,7 @@ static int decode_win_idma_valid(void); static int decode_win_xor_valid(void); static void decode_win_cpu_setup(void); -#ifdef SOC_MV_ARMADAXP static int decode_win_sdram_fixup(void); -#endif static void decode_win_cesa_setup(u_long); static void decode_win_usb_setup(u_long); static void decode_win_usb3_setup(u_long); @@ -117,11 +128,48 @@ static void decode_win_ahci_dump(u_long base); static void decode_win_sdhci_dump(u_long); static void decode_win_pcie_dump(u_long); +static uint32_t win_cpu_cr_read(int); +static uint32_t win_cpu_armv5_cr_read(int); +static uint32_t win_cpu_armv7_cr_read(int); +static uint32_t win_cpu_br_read(int); +static uint32_t win_cpu_armv5_br_read(int); +static uint32_t win_cpu_armv7_br_read(int); +static uint32_t win_cpu_remap_l_read(int); +static uint32_t win_cpu_armv5_remap_l_read(int); +static uint32_t win_cpu_armv7_remap_l_read(int); +static uint32_t win_cpu_remap_h_read(int); +static uint32_t win_cpu_armv5_remap_h_read(int); +static uint32_t win_cpu_armv7_remap_h_read(int); + +static void win_cpu_cr_write(int, uint32_t); +static void win_cpu_armv5_cr_write(int, uint32_t); +static void win_cpu_armv7_cr_write(int, uint32_t); +static void win_cpu_br_write(int, uint32_t); +static void win_cpu_armv5_br_write(int, uint32_t); +static void win_cpu_armv7_br_write(int, uint32_t); +static void win_cpu_remap_l_write(int, uint32_t); +static void win_cpu_armv5_remap_l_write(int, uint32_t); +static void win_cpu_armv7_remap_l_write(int, uint32_t); +static void win_cpu_remap_h_write(int, uint32_t); +static void win_cpu_armv5_remap_h_write(int, uint32_t); +static void win_cpu_armv7_remap_h_write(int, uint32_t); + +static uint32_t ddr_br_read(int); +static uint32_t ddr_sz_read(int); +static uint32_t ddr_armv5_br_read(int); +static uint32_t ddr_armv5_sz_read(int); +static uint32_t ddr_armv7_br_read(int); +static uint32_t ddr_armv7_sz_read(int); +static void ddr_br_write(int, uint32_t); +static void ddr_sz_write(int, uint32_t); +static void ddr_armv5_br_write(int, uint32_t); +static void ddr_armv5_sz_write(int, uint32_t); +static void ddr_armv7_br_write(int, uint32_t); +static void ddr_armv7_sz_write(int, uint32_t); + static int fdt_get_ranges(const char *, void *, int, int *, int *); -#ifdef SOC_MV_ARMADA38X int gic_decode_fdt(phandle_t iparent, pcell_t *intr, int *interrupt, int *trig, int *pol); -#endif static int win_cpu_from_dt(void); static int fdt_win_setup(void); @@ -177,6 +225,95 @@ static struct soc_node_spec soc_nodes[] = { { NULL, NULL, NULL, NULL }, }; +typedef uint32_t(*read_cpu_ctrl_t)(uint32_t); +typedef void(*write_cpu_ctrl_t)(uint32_t, uint32_t); +typedef uint32_t (*win_read_t)(int); +typedef void (*win_write_t)(int, uint32_t); +typedef int (*win_cesa_attr_t)(int); + +struct decode_win_spec { + read_cpu_ctrl_t read_cpu_ctrl; + write_cpu_ctrl_t write_cpu_ctrl; + win_read_t cr_read; + win_read_t br_read; + win_read_t remap_l_read; + win_read_t remap_h_read; + win_write_t cr_write; + win_write_t br_write; + win_write_t remap_l_write; + win_write_t remap_h_write; + uint32_t mv_win_cpu_max; + win_cesa_attr_t win_cesa_attr; + int win_cesa_target; + win_read_t ddr_br_read; + win_read_t ddr_sz_read; + win_write_t ddr_br_write; + win_write_t ddr_sz_write; +}; + +struct decode_win_spec *soc_decode_win_spec; + +static struct decode_win_spec decode_win_specs[] = +{ + { + &read_cpu_ctrl_armv7, + &write_cpu_ctrl_armv7, + &win_cpu_armv7_cr_read, + &win_cpu_armv7_br_read, + &win_cpu_armv7_remap_l_read, + &win_cpu_armv7_remap_h_read, + &win_cpu_armv7_cr_write, + &win_cpu_armv7_br_write, + &win_cpu_armv7_remap_l_write, + &win_cpu_armv7_remap_h_write, + MV_WIN_CPU_MAX_ARMV7, + &mv_win_cesa_attr_armada38x, + MV_WIN_CESA_TARGET_ARMADA38X, + &ddr_armv7_br_read, + &ddr_armv7_sz_read, + &ddr_armv7_br_write, + &ddr_armv7_sz_write, + }, + { + &read_cpu_ctrl_armv7, + &write_cpu_ctrl_armv7, + &win_cpu_armv7_cr_read, + &win_cpu_armv7_br_read, + &win_cpu_armv7_remap_l_read, + &win_cpu_armv7_remap_h_read, + &win_cpu_armv7_cr_write, + &win_cpu_armv7_br_write, + &win_cpu_armv7_remap_l_write, + &win_cpu_armv7_remap_h_write, + MV_WIN_CPU_MAX_ARMV7, + &mv_win_cesa_attr_armadaxp, + MV_WIN_CESA_TARGET_ARMADAXP, + &ddr_armv7_br_read, + &ddr_armv7_sz_read, + &ddr_armv7_br_write, + &ddr_armv7_sz_write, + }, + { + &read_cpu_ctrl_armv5, + &write_cpu_ctrl_armv5, + &win_cpu_armv5_cr_read, + &win_cpu_armv5_br_read, + &win_cpu_armv5_remap_l_read, + &win_cpu_armv5_remap_h_read, + &win_cpu_armv5_cr_write, + &win_cpu_armv5_br_write, + &win_cpu_armv5_remap_l_write, + &win_cpu_armv5_remap_h_write, + MV_WIN_CPU_MAX, + &mv_win_cesa_attr_armv5, + MV_WIN_CESA_TARGET, + &ddr_armv5_br_read, + &ddr_armv5_sz_read, + &ddr_armv5_br_write, + &ddr_armv5_sz_write, + }, +}; + struct fdt_pm_mask_entry { char *compat; uint32_t mask; @@ -237,6 +374,74 @@ pm_is_disabled(uint32_t mask) * This feature can be used only on Kirkwood and Discovery * machines. */ + +static int mv_win_cesa_attr(int eng_sel) +{ + + if (soc_decode_win_spec->win_cesa_attr != NULL) + return (soc_decode_win_spec->win_cesa_attr(eng_sel)); + + return (-1); +} + +static int mv_win_cesa_attr_armv5(int eng_sel) +{ + + return MV_WIN_CESA_ATTR(eng_sel); +} + +static int mv_win_cesa_attr_armada38x(int eng_sel) +{ + + return MV_WIN_CESA_ATTR_ARMADA38X(eng_sel); +} + +static int mv_win_cesa_attr_armadaxp(int eng_sel) +{ + + return MV_WIN_CESA_ATTR_ARMADAXP(eng_sel); +} + +enum soc_family +mv_check_soc_family() +{ + uint32_t dev, rev; + + soc_id(&dev, &rev); + switch (dev) { + case MV_DEV_MV78230: + case MV_DEV_MV78260: + case MV_DEV_MV78460: + soc_decode_win_spec = &decode_win_specs[MV_SOC_ARMADA_XP]; + soc_family = MV_SOC_ARMADA_XP; + return (MV_SOC_ARMADA_XP); + case MV_DEV_88F6828: + case MV_DEV_88F6820: + case MV_DEV_88F6810: + soc_decode_win_spec = &decode_win_specs[MV_SOC_ARMADA_38X]; + soc_family = MV_SOC_ARMADA_38X; + return (MV_SOC_ARMADA_38X); + case MV_DEV_88F5181: + case MV_DEV_88F5182: + case MV_DEV_88F5281: + case MV_DEV_88F6281: + case MV_DEV_88RC8180: + case MV_DEV_88RC9480: + case MV_DEV_88RC9580: + case MV_DEV_88F6781: + case MV_DEV_88F6282: + case MV_DEV_MV78100_Z0: + case MV_DEV_MV78100: + case MV_DEV_MV78160: + soc_decode_win_spec = &decode_win_specs[MV_SOC_ARMV5]; + soc_family = MV_SOC_ARMV5; + return (MV_SOC_ARMV5); + default: + soc_family = MV_SOC_UNSUPPORTED; + return (MV_SOC_UNSUPPORTED); + } +} + static __inline void pm_disable_device(int mask) { @@ -297,17 +502,47 @@ uint32_t read_cpu_ctrl(uint32_t reg) { + if (soc_decode_win_spec->read_cpu_ctrl != NULL) + return (soc_decode_win_spec->read_cpu_ctrl(reg)); + return (-1); +} + +uint32_t +read_cpu_ctrl_armv5(uint32_t reg) +{ + return (bus_space_read_4(fdtbus_bs_tag, MV_CPU_CONTROL_BASE, reg)); } +uint32_t +read_cpu_ctrl_armv7(uint32_t reg) +{ + + return (bus_space_read_4(fdtbus_bs_tag, MV_CPU_CONTROL_BASE_ARMV7, reg)); +} + void write_cpu_ctrl(uint32_t reg, uint32_t val) { + if (soc_decode_win_spec->write_cpu_ctrl != NULL) + soc_decode_win_spec->write_cpu_ctrl(reg, val); +} + +void +write_cpu_ctrl_armv5(uint32_t reg, uint32_t val) +{ + bus_space_write_4(fdtbus_bs_tag, MV_CPU_CONTROL_BASE, reg, val); } -#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) +void +write_cpu_ctrl_armv7(uint32_t reg, uint32_t val) +{ + + bus_space_write_4(fdtbus_bs_tag, MV_CPU_CONTROL_BASE_ARMV7, reg, val); +} + uint32_t read_cpu_mp_clocks(uint32_t reg) { @@ -335,7 +570,6 @@ write_cpu_misc(uint32_t reg, uint32_t val) bus_space_write_4(fdtbus_bs_tag, MV_MISC_BASE, reg, val); } -#endif void cpu_reset(void) @@ -414,6 +648,8 @@ soc_power_ctrl_set(uint32_t mask) void soc_id(uint32_t *dev, uint32_t *rev) { + uint64_t mv_pcie_base = MV_PCIE_BASE; + phandle_t node; /* * Notice: system identifiers are available in the registers range of @@ -421,8 +657,15 @@ soc_id(uint32_t *dev, uint32_t *rev) * possible) after the internal registers range has been mapped in via * devmap_bootstrap(). */ - *dev = bus_space_read_4(fdtbus_bs_tag, MV_PCIE_BASE, 0) >> 16; - *rev = bus_space_read_4(fdtbus_bs_tag, MV_PCIE_BASE, 8) & 0xff; + *dev = 0; + *rev = 0; + if ((node = OF_finddevice("/")) == -1) + return; + if (ofw_bus_node_is_compatible(node, "marvell,armada380")) + mv_pcie_base = MV_PCIE_BASE_ARMADA38X; + + *dev = bus_space_read_4(fdtbus_bs_tag, mv_pcie_base, 0) >> 16; + *rev = bus_space_read_4(fdtbus_bs_tag, mv_pcie_base, 8) & 0xff; } static void @@ -596,10 +839,9 @@ soc_decode_win(void) /* Retrieve our ID: some windows facilities vary between SoC models */ soc_id(&dev, &rev); -#ifdef SOC_MV_ARMADAXP - if ((err = decode_win_sdram_fixup()) != 0) - return(err); -#endif + if (soc_family == MV_SOC_ARMADA_XP) + if ((err = decode_win_sdram_fixup()) != 0) + return(err); decode_win_cpu_setup(); @@ -617,15 +859,92 @@ soc_decode_win(void) /************************************************************************** * Decode windows registers accessors **************************************************************************/ -WIN_REG_IDX_RD(win_cpu, cr, MV_WIN_CPU_CTRL, MV_MBUS_BRIDGE_BASE) -WIN_REG_IDX_RD(win_cpu, br, MV_WIN_CPU_BASE, MV_MBUS_BRIDGE_BASE) -WIN_REG_IDX_RD(win_cpu, remap_l, MV_WIN_CPU_REMAP_LO, MV_MBUS_BRIDGE_BASE) -WIN_REG_IDX_RD(win_cpu, remap_h, MV_WIN_CPU_REMAP_HI, MV_MBUS_BRIDGE_BASE) -WIN_REG_IDX_WR(win_cpu, cr, MV_WIN_CPU_CTRL, MV_MBUS_BRIDGE_BASE) -WIN_REG_IDX_WR(win_cpu, br, MV_WIN_CPU_BASE, MV_MBUS_BRIDGE_BASE) -WIN_REG_IDX_WR(win_cpu, remap_l, MV_WIN_CPU_REMAP_LO, MV_MBUS_BRIDGE_BASE) -WIN_REG_IDX_WR(win_cpu, remap_h, MV_WIN_CPU_REMAP_HI, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_RD(win_cpu_armv5, cr, MV_WIN_CPU_CTRL_ARMV5, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_RD(win_cpu_armv5, br, MV_WIN_CPU_BASE_ARMV5, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_RD(win_cpu_armv5, remap_l, MV_WIN_CPU_REMAP_LO_ARMV5, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_RD(win_cpu_armv5, remap_h, MV_WIN_CPU_REMAP_HI_ARMV5, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_WR(win_cpu_armv5, cr, MV_WIN_CPU_CTRL_ARMV5, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_WR(win_cpu_armv5, br, MV_WIN_CPU_BASE_ARMV5, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_WR(win_cpu_armv5, remap_l, MV_WIN_CPU_REMAP_LO_ARMV5, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_WR(win_cpu_armv5, remap_h, MV_WIN_CPU_REMAP_HI_ARMV5, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_RD(win_cpu_armv7, cr, MV_WIN_CPU_CTRL_ARMV7, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_RD(win_cpu_armv7, br, MV_WIN_CPU_BASE_ARMV7, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_RD(win_cpu_armv7, remap_l, MV_WIN_CPU_REMAP_LO_ARMV7, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_RD(win_cpu_armv7, remap_h, MV_WIN_CPU_REMAP_HI_ARMV7, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_WR(win_cpu_armv7, cr, MV_WIN_CPU_CTRL_ARMV7, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_WR(win_cpu_armv7, br, MV_WIN_CPU_BASE_ARMV7, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_WR(win_cpu_armv7, remap_l, MV_WIN_CPU_REMAP_LO_ARMV7, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_WR(win_cpu_armv7, remap_h, MV_WIN_CPU_REMAP_HI_ARMV7, MV_MBUS_BRIDGE_BASE) + +static uint32_t +win_cpu_cr_read(int i) +{ + + if (soc_decode_win_spec->cr_read != NULL) + return (soc_decode_win_spec->cr_read(i)); + return (-1); +} + +static uint32_t +win_cpu_br_read(int i) +{ + + if (soc_decode_win_spec->br_read != NULL) + return (soc_decode_win_spec->br_read(i)); + return (-1); +} + +static uint32_t +win_cpu_remap_l_read(int i) +{ + + if (soc_decode_win_spec->remap_l_read != NULL) + return (soc_decode_win_spec->remap_l_read(i)); + return (-1); +} + +static uint32_t +win_cpu_remap_h_read(int i) +{ + + if (soc_decode_win_spec->remap_h_read != NULL) + return soc_decode_win_spec->remap_h_read(i); + return (-1); +} + +static void +win_cpu_cr_write(int i, uint32_t val) +{ + + if (soc_decode_win_spec->cr_write != NULL) + soc_decode_win_spec->cr_write(i, val); +} + +static void +win_cpu_br_write(int i, uint32_t val) +{ + + if (soc_decode_win_spec->br_write != NULL) + soc_decode_win_spec->br_write(i, val); +} + +static void +win_cpu_remap_l_write(int i, uint32_t val) +{ + + if (soc_decode_win_spec->remap_l_write != NULL) + soc_decode_win_spec->remap_l_write(i, val); +} + +static void +win_cpu_remap_h_write(int i, uint32_t val) +{ + + if (soc_decode_win_spec->remap_h_write != NULL) + soc_decode_win_spec->remap_h_write(i, val); +} + WIN_REG_BASE_IDX_RD(win_cesa, cr, MV_WIN_CESA_CTRL) WIN_REG_BASE_IDX_RD(win_cesa, br, MV_WIN_CESA_BASE) WIN_REG_BASE_IDX_WR(win_cesa, cr, MV_WIN_CESA_CTRL) @@ -636,12 +955,10 @@ WIN_REG_BASE_IDX_RD(win_usb, br, MV_WIN_USB_BASE) WIN_REG_BASE_IDX_WR(win_usb, cr, MV_WIN_USB_CTRL) WIN_REG_BASE_IDX_WR(win_usb, br, MV_WIN_USB_BASE) -#ifdef SOC_MV_ARMADA38X WIN_REG_BASE_IDX_RD(win_usb3, cr, MV_WIN_USB3_CTRL) WIN_REG_BASE_IDX_RD(win_usb3, br, MV_WIN_USB3_BASE) WIN_REG_BASE_IDX_WR(win_usb3, cr, MV_WIN_USB3_CTRL) WIN_REG_BASE_IDX_WR(win_usb3, br, MV_WIN_USB3_BASE) -#endif WIN_REG_BASE_IDX_RD(win_eth, br, MV_WIN_ETH_BASE) WIN_REG_BASE_IDX_RD(win_eth, sz, MV_WIN_ETH_SIZE) @@ -692,21 +1009,63 @@ WIN_REG_BASE_IDX_RD(win_sata, cr, MV_WIN_SATA_CTRL); WIN_REG_BASE_IDX_RD(win_sata, br, MV_WIN_SATA_BASE); WIN_REG_BASE_IDX_WR(win_sata, cr, MV_WIN_SATA_CTRL); WIN_REG_BASE_IDX_WR(win_sata, br, MV_WIN_SATA_BASE); -#if defined(SOC_MV_ARMADA38X) -WIN_REG_BASE_IDX_RD(win_sata, sz, MV_WIN_SATA_SIZE); -WIN_REG_BASE_IDX_WR(win_sata, sz, MV_WIN_SATA_SIZE); -#endif +WIN_REG_BASE_IDX_RD(win_sata_armada38x, sz, MV_WIN_SATA_SIZE_ARMADA38X); +WIN_REG_BASE_IDX_WR(win_sata_armada38x, sz, MV_WIN_SATA_SIZE_ARMADA38X); +WIN_REG_BASE_IDX_RD(win_sata_armada38x, cr, MV_WIN_SATA_CTRL_ARMADA38X); +WIN_REG_BASE_IDX_RD(win_sata_armada38x, br, MV_WIN_SATA_BASE_ARMADA38X); +WIN_REG_BASE_IDX_WR(win_sata_armada38x, cr, MV_WIN_SATA_CTRL_ARMADA38X); +WIN_REG_BASE_IDX_WR(win_sata_armada38x, br, MV_WIN_SATA_BASE_ARMADA38X); + WIN_REG_BASE_IDX_RD(win_sdhci, cr, MV_WIN_SDHCI_CTRL); WIN_REG_BASE_IDX_RD(win_sdhci, br, MV_WIN_SDHCI_BASE); WIN_REG_BASE_IDX_WR(win_sdhci, cr, MV_WIN_SDHCI_CTRL); WIN_REG_BASE_IDX_WR(win_sdhci, br, MV_WIN_SDHCI_BASE); #ifndef SOC_MV_DOVE -WIN_REG_IDX_RD(ddr, br, MV_WIN_DDR_BASE, MV_DDR_CADR_BASE) -WIN_REG_IDX_RD(ddr, sz, MV_WIN_DDR_SIZE, MV_DDR_CADR_BASE) -WIN_REG_IDX_WR(ddr, br, MV_WIN_DDR_BASE, MV_DDR_CADR_BASE) -WIN_REG_IDX_WR(ddr, sz, MV_WIN_DDR_SIZE, MV_DDR_CADR_BASE) +WIN_REG_IDX_RD(ddr_armv5, br, MV_WIN_DDR_BASE, MV_DDR_CADR_BASE) +WIN_REG_IDX_RD(ddr_armv5, sz, MV_WIN_DDR_SIZE, MV_DDR_CADR_BASE) +WIN_REG_IDX_WR(ddr_armv5, br, MV_WIN_DDR_BASE, MV_DDR_CADR_BASE) +WIN_REG_IDX_WR(ddr_armv5, sz, MV_WIN_DDR_SIZE, MV_DDR_CADR_BASE) + +WIN_REG_IDX_RD(ddr_armv7, br, MV_WIN_DDR_BASE, MV_DDR_CADR_BASE_ARMV7) +WIN_REG_IDX_RD(ddr_armv7, sz, MV_WIN_DDR_SIZE, MV_DDR_CADR_BASE_ARMV7) +WIN_REG_IDX_WR(ddr_armv7, br, MV_WIN_DDR_BASE, MV_DDR_CADR_BASE_ARMV7) +WIN_REG_IDX_WR(ddr_armv7, sz, MV_WIN_DDR_SIZE, MV_DDR_CADR_BASE_ARMV7) + +static inline uint32_t +ddr_br_read(int i) +{ + + if (soc_decode_win_spec->ddr_br_read != NULL) + return (soc_decode_win_spec->ddr_br_read(i)); + return (-1); +} + +static inline uint32_t +ddr_sz_read(int i) +{ + + if (soc_decode_win_spec->ddr_sz_read != NULL) + return (soc_decode_win_spec->ddr_sz_read(i)); + return (-1); +} + +static inline void +ddr_br_write(int i, uint32_t val) +{ + + if (soc_decode_win_spec->ddr_br_write != NULL) + soc_decode_win_spec->ddr_br_write(i, val); +} + +static inline void +ddr_sz_write(int i, uint32_t val) +{ + + if (soc_decode_win_spec->ddr_sz_write != NULL) + soc_decode_win_spec->ddr_sz_write(i, val); +} #else /* * On 88F6781 (Dove) SoC DDR Controller is accessed through @@ -747,12 +1106,9 @@ static inline uint32_t ddr_sz_read(int i) void soc_dump_decode_win(void) { - uint32_t dev, rev; int i; - soc_id(&dev, &rev); - - for (i = 0; i < MV_WIN_CPU_MAX; i++) { + for (i = 0; i < soc_decode_win_spec->mv_win_cpu_max; i++) { printf("CPU window#%d: c 0x%08x, b 0x%08x", i, win_cpu_cr_read(i), win_cpu_br_read(i)); @@ -832,7 +1188,7 @@ decode_win_cpu_valid(void) int i, j, rv; uint32_t b, e, s; - if (cpu_wins_no > MV_WIN_CPU_MAX) { + if (cpu_wins_no > soc_decode_win_spec->mv_win_cpu_max) { printf("CPU windows: too many entries: %d\n", cpu_wins_no); return (0); } @@ -894,14 +1250,14 @@ decode_win_cpu_set(int target, int attr, vm_paddr_t ba int win, i; if (remap == ~0) { - win = MV_WIN_CPU_MAX - 1; + win = soc_decode_win_spec->mv_win_cpu_max - 1; i = -1; } else { win = 0; i = 1; } - while ((win >= 0) && (win < MV_WIN_CPU_MAX)) { + while ((win >= 0) && (win < soc_decode_win_spec->mv_win_cpu_max)) { cr = win_cpu_cr_read(win); if ((cr & MV_WIN_CPU_ENABLE_BIT) == 0) break; @@ -912,7 +1268,7 @@ decode_win_cpu_set(int target, int attr, vm_paddr_t ba break; win += i; } - if ((win < 0) || (win >= MV_WIN_CPU_MAX) || + if ((win < 0) || (win >= soc_decode_win_spec->mv_win_cpu_max) || ((remap != ~0) && (win_cpu_can_remap(win) == 0))) return (-1); @@ -947,7 +1303,7 @@ decode_win_cpu_setup(void) int i; /* Disable all CPU windows */ - for (i = 0; i < MV_WIN_CPU_MAX; i++) { + for (i = 0; i < soc_decode_win_spec->mv_win_cpu_max; i++) { win_cpu_cr_write(i, 0); win_cpu_br_write(i, 0); if (win_cpu_can_remap(i)) { @@ -964,7 +1320,6 @@ decode_win_cpu_setup(void) } -#ifdef SOC_MV_ARMADAXP static int decode_win_sdram_fixup(void) { @@ -1006,7 +1361,6 @@ decode_win_sdram_fixup(void) return (0); } -#endif /* * Check if we're able to cover all active DDR banks. */ @@ -1147,7 +1501,6 @@ decode_win_cesa_setup(u_long base) br = ddr_base(i); size = ddr_size(i); -#ifdef SOC_MV_ARMADA38X /* * Armada 38x SoC's equipped with 4GB DRAM * suffer freeze during CESA operation, if @@ -1156,9 +1509,9 @@ decode_win_cesa_setup(u_long base) * by setting the window size to the closest possible * value, i.e. divide it by 2. */ - if (size + ddr_base(i) == 0x100000000ULL) + if ((soc_family == MV_SOC_ARMADA_38X) && + (size + ddr_base(i) == 0x100000000ULL)) size /= 2; -#endif cr = (((size - 1) & 0xffff0000) | (ddr_attr(i) << IO_WIN_ATTR_SHIFT) | @@ -1248,7 +1601,6 @@ decode_win_usb_setup(u_long base) /************************************************************************** * USB3 windows routines **************************************************************************/ -#ifdef SOC_MV_ARMADA38X static int decode_win_usb3_valid(void) { @@ -1302,28 +1654,8 @@ decode_win_usb3_setup(u_long base) } } } -#else -/* - * Provide dummy functions to satisfy the build - * for SoCs not equipped with USB3 - */ -static int -decode_win_usb3_valid(void) -{ - return (1); -} -static void -decode_win_usb3_setup(u_long base) -{ -} - -static void -decode_win_usb3_dump(u_long base) -{ -} -#endif /************************************************************************** * ETH windows routines **************************************************************************/ @@ -2140,7 +2472,6 @@ decode_win_sata_setup(u_long base) } } -#ifdef SOC_MV_ARMADA38X /* * Configure AHCI decoding windows */ @@ -2150,10 +2481,10 @@ decode_win_ahci_setup(u_long base) uint32_t br, cr, sz; int i, j; - for (i = 0; i < MV_WIN_SATA_MAX; i++) { - win_sata_cr_write(base, i, 0); - win_sata_br_write(base, i, 0); - win_sata_sz_write(base, i, 0); + for (i = 0; i < MV_WIN_SATA_MAX_ARMADA38X; i++) { + win_sata_armada38x_cr_write(base, i, 0); + win_sata_armada38x_br_write(base, i, 0); + win_sata_armada38x_sz_write(base, i, 0); } for (i = 0; i < MV_WIN_DDR_MAX; i++) { @@ -2166,16 +2497,16 @@ decode_win_ahci_setup(u_long base) (IO_WIN_SIZE_MASK << IO_WIN_SIZE_SHIFT); /* Use first available SATA window */ - for (j = 0; j < MV_WIN_SATA_MAX; j++) { - if (win_sata_cr_read(base, j) & IO_WIN_ENA_MASK) + for (j = 0; j < MV_WIN_SATA_MAX_ARMADA38X; j++) { + if (win_sata_armada38x_cr_read(base, j) & IO_WIN_ENA_MASK) continue; /* BASE is set to DRAM base (0x00000000) */ - win_sata_br_write(base, j, br); + win_sata_armada38x_br_write(base, j, br); /* CTRL targets DRAM ctrl with 0x0E or 0x0D */ - win_sata_cr_write(base, j, cr); + win_sata_armada38x_cr_write(base, j, cr); /* SIZE is set to 16MB - max value */ - win_sata_sz_write(base, j, sz); + win_sata_armada38x_sz_write(base, j, sz); break; } } @@ -2187,28 +2518,12 @@ decode_win_ahci_dump(u_long base) { int i; - for (i = 0; i < MV_WIN_SATA_MAX; i++) + for (i = 0; i < MV_WIN_SATA_MAX_ARMADA38X; i++) printf("SATA window#%d: cr 0x%08x, br 0x%08x, sz 0x%08x\n", i, - win_sata_cr_read(base, i), win_sata_br_read(base, i), - win_sata_sz_read(base,i)); + win_sata_armada38x_cr_read(base, i), win_sata_br_read(base, i), + win_sata_armada38x_sz_read(base,i)); } -#else -/* - * Provide dummy functions to satisfy the build - * for SoC's not equipped with AHCI controller - */ -static void -decode_win_ahci_setup(u_long base) -{ -} - -static void -decode_win_ahci_dump(u_long base) -{ -} -#endif - static int decode_win_sata_valid(void) { @@ -2267,12 +2582,7 @@ static int decode_win_sdhci_valid(void) { -#ifdef SOC_MV_ARMADA38X return (decode_win_can_cover_ddr(MV_WIN_SDHCI_MAX)); -#endif - - /* Satisfy platforms not equipped with this controller. */ - return (1); } /************************************************************************** @@ -2384,12 +2694,11 @@ moveon: return (ENOMEM); } - cpu_win_tbl[t].target = MV_WIN_CESA_TARGET; -#ifdef SOC_MV_ARMADA38X - cpu_win_tbl[t].attr = MV_WIN_CESA_ATTR(0); -#else - cpu_win_tbl[t].attr = MV_WIN_CESA_ATTR(1); -#endif + cpu_win_tbl[t].target = soc_decode_win_spec->win_cesa_target; + if (soc_family == MV_SOC_ARMADA_38X) + cpu_win_tbl[t].attr = soc_decode_win_spec->win_cesa_attr(0); + else + cpu_win_tbl[t].attr = soc_decode_win_spec->win_cesa_attr(1); cpu_win_tbl[t].base = sram_base; cpu_win_tbl[t].size = sram_size; cpu_win_tbl[t].remap = ~0; @@ -2415,8 +2724,8 @@ moveon: } /* Configure window for CESA1 */ - cpu_win_tbl[t].target = MV_WIN_CESA_TARGET; - cpu_win_tbl[t].attr = MV_WIN_CESA_ATTR(1); + cpu_win_tbl[t].target = soc_decode_win_spec->win_cesa_target; + cpu_win_tbl[t].attr = soc_decode_win_spec->win_cesa_attr(1); cpu_win_tbl[t].base = sram_base; cpu_win_tbl[t].size = sram_size; cpu_win_tbl[t].remap = ~0; @@ -2661,9 +2970,6 @@ fdt_pic_decode_ic(phandle_t node, pcell_t *intr, int * } fdt_pic_decode_t fdt_pic_table[] = { -#ifdef SOC_MV_ARMADA38X - &gic_decode_fdt, -#endif &fdt_pic_decode_ic, NULL }; Modified: head/sys/arm/mv/mv_machdep.c ============================================================================== --- head/sys/arm/mv/mv_machdep.c Tue Apr 3 21:46:28 2018 (r331956) +++ head/sys/arm/mv/mv_machdep.c Tue Apr 3 21:54:36 2018 (r331957) @@ -285,6 +285,9 @@ platform_late_init(void) /* * Re-initialise decode windows */ + if (mv_check_soc_family() == MV_SOC_UNSUPPORTED) + panic("Unsupported SoC family\n"); + if (soc_decode_win() != 0) printf("WARNING: could not re-initialise decode windows! " "Running with existing settings...\n"); @@ -323,8 +326,11 @@ platform_late_init(void) #endif #endif } - +#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) +#define FDT_DEVMAP_MAX (MV_WIN_CPU_MAX_ARMV7 + 2) +#else #define FDT_DEVMAP_MAX (MV_WIN_CPU_MAX + 2) +#endif static struct devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = { { 0, 0, 0, } }; Modified: head/sys/arm/mv/mvreg.h ============================================================================== --- head/sys/arm/mv/mvreg.h Tue Apr 3 21:46:28 2018 (r331956) +++ head/sys/arm/mv/mvreg.h Tue Apr 3 21:54:36 2018 (r331957) @@ -87,13 +87,13 @@ #define IRQ_TIMER0 0x00000002 #define IRQ_TIMER1 0x00000004 #define IRQ_TIMER_WD 0x00000008 +#endif #define BRIDGE_IRQ_MASK 0x14 #define IRQ_CPU_MASK 0x00000001 #define IRQ_TIMER0_MASK 0x00000002 #define IRQ_TIMER1_MASK 0x00000004 #define IRQ_TIMER_WD_MASK 0x00000008 -#endif #define IRQ_CPU_SELF_CLR (~IRQ_CPU_SELF) #define IRQ_TIMER0_CLR (~IRQ_TIMER0) @@ -423,7 +423,6 @@ /* * SCU */ -#if defined(SOC_MV_ARMADA38X) #define MV_SCU_BASE (MV_BASE + 0xc000) #define MV_SCU_REGS_LEN 0x100 #define MV_SCU_REG_CTRL 0x00 @@ -431,30 +430,23 @@ #define MV_SCU_ENABLE (1 << 0) #define MV_SCU_SL_L2_ENABLE (1 << 3) #define SCU_CFG_REG_NCPU_MASK 0x3 -#endif /* * PMSU */ -#if defined(SOC_MV_ARMADA38X) #define MV_PMSU_BASE (MV_BASE + 0x22000) #define MV_PMSU_REGS_LEN 0x1000 #define PMSU_BOOT_ADDR_REDIRECT_OFFSET(cpu) (((cpu) * 0x100) + 0x124) -#endif /* * CPU RESET */ -#if defined(SOC_MV_ARMADA38X) #define MV_CPU_RESET_BASE (MV_BASE + 0x20800) #define MV_CPU_RESET_REGS_LEN 0x8 #define CPU_RESET_OFFSET(cpu) ((cpu) * 0x8) #define CPU_RESET_ASSERT 0x1 -#endif -#if defined(SOC_MV_ARMADA38X) #define MV_MBUS_CTRL_BASE (MV_BASE + 0x20420) #define MV_MBUS_CTRL_REGS_LEN 0x10 -#endif #endif /* _MVREG_H_ */ Modified: head/sys/arm/mv/mvvar.h ============================================================================== --- head/sys/arm/mv/mvvar.h Tue Apr 3 21:46:28 2018 (r331956) +++ head/sys/arm/mv/mvvar.h Tue Apr 3 21:54:36 2018 (r331957) @@ -55,6 +55,13 @@ #define MV_MODE_ENDPOINT 0 #define MV_MODE_ROOT 1 +enum soc_family{ + MV_SOC_ARMADA_38X = 0x00, + MV_SOC_ARMADA_XP = 0x01, + MV_SOC_ARMV5 = 0x02, + MV_SOC_UNSUPPORTED = 0xff, +}; + struct gpio_config { int gc_gpio; /* GPIO number */ uint32_t gc_flags; /* GPIO flags */ @@ -110,12 +117,10 @@ uint32_t get_l2clk(void); uint32_t read_cpu_ctrl(uint32_t); void write_cpu_ctrl(uint32_t, uint32_t); -#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) uint32_t read_cpu_mp_clocks(uint32_t reg); void write_cpu_mp_clocks(uint32_t reg, uint32_t val); uint32_t read_cpu_misc(uint32_t reg); void write_cpu_misc(uint32_t reg, uint32_t val); -#endif int mv_pcib_bar_win_set(device_t dev, uint32_t base, uint32_t size, uint32_t remap, int winno, int busno); @@ -142,5 +147,5 @@ struct devmap_entry; int mv_pci_devmap(phandle_t, struct devmap_entry *, vm_offset_t, vm_offset_t); int fdt_localbus_devmap(phandle_t, struct devmap_entry *, int, int *); - +enum soc_family mv_check_soc_family(void); #endif /* _MVVAR_H_ */ Modified: head/sys/arm/mv/mvwin.h ============================================================================== --- head/sys/arm/mv/mvwin.h Tue Apr 3 21:46:28 2018 (r331956) +++ head/sys/arm/mv/mvwin.h Tue Apr 3 21:54:36 2018 (r331957) @@ -101,24 +101,18 @@ * Integrated SoC peripherals addresses */ #define MV_BASE MV_PHYS_BASE /* VA == PA mapping */ -#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) -#define MV_DDR_CADR_BASE (MV_BASE + 0x20180) -#else +#define MV_DDR_CADR_BASE_ARMV7 (MV_BASE + 0x20180) #define MV_DDR_CADR_BASE (MV_BASE + 0x1500) -#endif #define MV_MPP_BASE (MV_BASE + 0x10000) -#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) + #define MV_MISC_BASE (MV_BASE + 0x18200) #define MV_MBUS_BRIDGE_BASE (MV_BASE + 0x20000) #define MV_INTREGS_BASE (MV_MBUS_BRIDGE_BASE + 0x80) #define MV_MP_CLOCKS_BASE (MV_MBUS_BRIDGE_BASE + 0x700) -#define MV_CPU_CONTROL_BASE (MV_MBUS_BRIDGE_BASE + 0x1800) -#else -#define MV_MBUS_BRIDGE_BASE (MV_BASE + 0x20000) -#define MV_INTREGS_BASE (MV_MBUS_BRIDGE_BASE + 0x80) + +#define MV_CPU_CONTROL_BASE_ARMV7 (MV_MBUS_BRIDGE_BASE + 0x1800) #define MV_CPU_CONTROL_BASE (MV_MBUS_BRIDGE_BASE + 0x100) -#endif #define MV_PCI_BASE (MV_BASE + 0x30000) #define MV_PCI_SIZE 0x2000 @@ -132,25 +126,22 @@ /* * Decode windows definitions and macros */ -#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) -#define MV_WIN_CPU_CTRL(n) (((n) < 8) ? 0x10 * (n) : 0x90 + (0x8 * ((n) - 8))) -#define MV_WIN_CPU_BASE(n) ((((n) < 8) ? 0x10 * (n) : 0x90 + (0x8 * ((n) - 8))) + 0x4) -#define MV_WIN_CPU_REMAP_LO(n) (0x10 * (n) + 0x008) -#define MV_WIN_CPU_REMAP_HI(n) (0x10 * (n) + 0x00C) -#else -#define MV_WIN_CPU_CTRL(n) (0x10 * (n) + (((n) < 8) ? 0x000 : 0x880)) -#define MV_WIN_CPU_BASE(n) (0x10 * (n) + (((n) < 8) ? 0x004 : 0x884)) -#define MV_WIN_CPU_REMAP_LO(n) (0x10 * (n) + (((n) < 8) ? 0x008 : 0x888)) -#define MV_WIN_CPU_REMAP_HI(n) (0x10 * (n) + (((n) < 8) ? 0x00C : 0x88C)) -#endif +#define MV_WIN_CPU_CTRL_ARMV7(n) (((n) < 8) ? 0x10 * (n) : 0x90 + (0x8 * ((n) - 8))) +#define MV_WIN_CPU_BASE_ARMV7(n) ((((n) < 8) ? 0x10 * (n) : 0x90 + (0x8 * ((n) - 8))) + 0x4) +#define MV_WIN_CPU_REMAP_LO_ARMV7(n) (0x10 * (n) + 0x008) +#define MV_WIN_CPU_REMAP_HI_ARMV7(n) (0x10 * (n) + 0x00C) +#define MV_WIN_CPU_CTRL_ARMV5(n) (0x10 * (n) + (((n) < 8) ? 0x000 : 0x880)) +#define MV_WIN_CPU_BASE_ARMV5(n) (0x10 * (n) + (((n) < 8) ? 0x004 : 0x884)) +#define MV_WIN_CPU_REMAP_LO_ARMV5(n) (0x10 * (n) + (((n) < 8) ? 0x008 : 0x888)) +#define MV_WIN_CPU_REMAP_HI_ARMV5(n) (0x10 * (n) + (((n) < 8) ? 0x00C : 0x88C)) + #if defined(SOC_MV_DISCOVERY) #define MV_WIN_CPU_MAX 14 -#elif defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) -#define MV_WIN_CPU_MAX 20 #else #define MV_WIN_CPU_MAX 8 #endif +#define MV_WIN_CPU_MAX_ARMV7 20 #define MV_WIN_CPU_ATTR_SHIFT 8 #define MV_WIN_CPU_TARGET_SHIFT 4 @@ -170,17 +161,20 @@ #if defined(SOC_MV_DISCOVERY) #define MV_WIN_CESA_TARGET 9 #define MV_WIN_CESA_ATTR(eng_sel) 1 -#elif defined(SOC_MV_ARMADAXP) -#define MV_WIN_CESA_TARGET 9 +#else +#define MV_WIN_CESA_TARGET 3 +#define MV_WIN_CESA_ATTR(eng_sel) 0 +#endif + +#define MV_WIN_CESA_TARGET_ARMADAXP 9 /* * Bits [2:3] of cesa attribute select engine: * eng_sel: * 1: engine1 * 2: engine0 */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Tue Apr 3 22:10:52 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DC624F84BC5; Tue, 3 Apr 2018 22:10:51 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8A65B77F00; Tue, 3 Apr 2018 22:10:51 +0000 (UTC) (envelope-from mw@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 85294281D; Tue, 3 Apr 2018 22:10:51 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33MApFG004568; Tue, 3 Apr 2018 22:10:51 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33MAosI004549; Tue, 3 Apr 2018 22:10:50 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804032210.w33MAosI004549@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Tue, 3 Apr 2018 22:10:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331958 - in head/sys/arm/mv: . armada38x armadaxp X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys/arm/mv: . armada38x armadaxp X-SVN-Commit-Revision: 331958 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 22:10:52 -0000 Author: mw Date: Tue Apr 3 22:10:50 2018 New Revision: 331958 URL: https://svnweb.freebsd.org/changeset/base/331958 Log: Make get_tclk and get_cpu_freq generic for Marvell armv7 SoCs In GENERIC kernel choosing proper get_tclk and get_cpu_freq implementation must be done in runtime. Kernel for both SoC need to have implementation of each other functions, so common file list mv/files.arm7 is added. Marvell armv5 SoC have their own non-generic implementation of those function. Submitted by: Rafal Kozik Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14739 Added: head/sys/arm/mv/files.arm7 (contents, props changed) Modified: head/sys/arm/mv/armada38x/armada38x.c head/sys/arm/mv/armada38x/std.armada38x head/sys/arm/mv/armadaxp/armadaxp.c head/sys/arm/mv/mv_common.c head/sys/arm/mv/mvvar.h head/sys/arm/mv/std-pj4b.mv Modified: head/sys/arm/mv/armada38x/armada38x.c ============================================================================== --- head/sys/arm/mv/armada38x/armada38x.c Tue Apr 3 21:54:36 2018 (r331957) +++ head/sys/arm/mv/armada38x/armada38x.c Tue Apr 3 22:10:50 2018 (r331958) @@ -61,7 +61,7 @@ get_sar_value_armada38x(void) } uint32_t -get_tclk(void) +get_tclk_armada38x(void) { uint32_t sar; @@ -78,7 +78,7 @@ get_tclk(void) } uint32_t -get_cpu_freq(void) +get_cpu_freq_armada38x(void) { uint32_t sar; Modified: head/sys/arm/mv/armada38x/std.armada38x ============================================================================== --- head/sys/arm/mv/armada38x/std.armada38x Tue Apr 3 21:54:36 2018 (r331957) +++ head/sys/arm/mv/armada38x/std.armada38x Tue Apr 3 22:10:50 2018 (r331958) @@ -1,6 +1,7 @@ # $FreeBSD$ files "../mv/armada38x/files.armada38x" files "../mv/files.mv" +files "../mv/files.arm7" cpu CPU_CORTEXA machine arm armv7 Modified: head/sys/arm/mv/armadaxp/armadaxp.c ============================================================================== --- head/sys/arm/mv/armadaxp/armadaxp.c Tue Apr 3 21:54:36 2018 (r331957) +++ head/sys/arm/mv/armadaxp/armadaxp.c Tue Apr 3 22:10:50 2018 (r331958) @@ -138,7 +138,7 @@ get_sar_value_armadaxp(void) } uint32_t -get_tclk(void) +get_tclk_armadaxp(void) { uint32_t cputype; @@ -152,7 +152,7 @@ get_tclk(void) } uint32_t -get_cpu_freq(void) +get_cpu_freq_armadaxp(void) { return (0); Added: head/sys/arm/mv/files.arm7 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm/mv/files.arm7 Tue Apr 3 22:10:50 2018 (r331958) @@ -0,0 +1,3 @@ +# $FreeBSD$ +arm/mv/armada38x/armada38x.c standard +arm/mv/armadaxp/armadaxp.c standard Modified: head/sys/arm/mv/mv_common.c ============================================================================== --- head/sys/arm/mv/mv_common.c Tue Apr 3 21:54:36 2018 (r331957) +++ head/sys/arm/mv/mv_common.c Tue Apr 3 22:10:50 2018 (r331958) @@ -230,6 +230,7 @@ typedef void(*write_cpu_ctrl_t)(uint32_t, uint32_t); typedef uint32_t (*win_read_t)(int); typedef void (*win_write_t)(int, uint32_t); typedef int (*win_cesa_attr_t)(int); +typedef uint32_t (*get_t)(void); struct decode_win_spec { read_cpu_ctrl_t read_cpu_ctrl; @@ -249,6 +250,10 @@ struct decode_win_spec { win_read_t ddr_sz_read; win_write_t ddr_br_write; win_write_t ddr_sz_write; +#if __ARM_ARCH >= 6 + get_t get_tclk; + get_t get_cpu_freq; +#endif }; struct decode_win_spec *soc_decode_win_spec; @@ -273,6 +278,10 @@ static struct decode_win_spec decode_win_specs[] = &ddr_armv7_sz_read, &ddr_armv7_br_write, &ddr_armv7_sz_write, +#if __ARM_ARCH >= 6 + &get_tclk_armada38x, + &get_cpu_freq_armada38x, +#endif }, { &read_cpu_ctrl_armv7, @@ -292,6 +301,10 @@ static struct decode_win_spec decode_win_specs[] = &ddr_armv7_sz_read, &ddr_armv7_br_write, &ddr_armv7_sz_write, +#if __ARM_ARCH >= 6 + &get_tclk_armadaxp, + &get_cpu_freq_armadaxp, +#endif }, { &read_cpu_ctrl_armv5, @@ -311,6 +324,10 @@ static struct decode_win_spec decode_win_specs[] = &ddr_armv5_sz_read, &ddr_armv5_br_write, &ddr_armv5_sz_write, +#if __ARM_ARCH >= 6 + NULL, + NULL, +#endif }, }; @@ -2951,6 +2968,28 @@ struct fdt_fixup_entry fdt_fixup_table[] = { { "mrvl,DB-78460", &fdt_fixup_ranges }, { NULL, NULL } }; + +#if __ARM_ARCH >= 6 +uint32_t +get_tclk(void) +{ + + if (soc_decode_win_spec->get_tclk != NULL) + return soc_decode_win_spec->get_tclk(); + else + return -1; +} + +uint32_t +get_cpu_freq(void) +{ + + if (soc_decode_win_spec->get_cpu_freq != NULL) + return soc_decode_win_spec->get_cpu_freq(); + else + return -1; +} +#endif #ifndef INTRNG static int Modified: head/sys/arm/mv/mvvar.h ============================================================================== --- head/sys/arm/mv/mvvar.h Tue Apr 3 21:54:36 2018 (r331957) +++ head/sys/arm/mv/mvvar.h Tue Apr 3 22:10:50 2018 (r331958) @@ -148,4 +148,9 @@ int mv_pci_devmap(phandle_t, struct devmap_entry *, vm vm_offset_t); int fdt_localbus_devmap(phandle_t, struct devmap_entry *, int, int *); enum soc_family mv_check_soc_family(void); + +uint32_t get_tclk_armadaxp(void); +uint32_t get_tclk_armada38x(void); +uint32_t get_cpu_freq_armadaxp(void); +uint32_t get_cpu_freq_armada38x(void); #endif /* _MVVAR_H_ */ Modified: head/sys/arm/mv/std-pj4b.mv ============================================================================== --- head/sys/arm/mv/std-pj4b.mv Tue Apr 3 21:54:36 2018 (r331957) +++ head/sys/arm/mv/std-pj4b.mv Tue Apr 3 22:10:50 2018 (r331958) @@ -1,6 +1,7 @@ # $FreeBSD$ files "../mv/files.mv" +files "../mv/files.arm7" cpu CPU_MV_PJ4B machine arm armv7 makeoptions CONF_CFLAGS="-march=armv7a" From owner-svn-src-head@freebsd.org Tue Apr 3 22:11:39 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B3DDDF84DDB; Tue, 3 Apr 2018 22:11:39 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 69EF1781FB; Tue, 3 Apr 2018 22:11:39 +0000 (UTC) (envelope-from cem@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 646E7295C; Tue, 3 Apr 2018 22:11:39 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33MBdPF005445; Tue, 3 Apr 2018 22:11:39 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33MBd7l005444; Tue, 3 Apr 2018 22:11:39 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201804032211.w33MBd7l005444@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Tue, 3 Apr 2018 22:11:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331959 - head/sys/opencrypto X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/sys/opencrypto X-SVN-Commit-Revision: 331959 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 22:11:39 -0000 Author: cem Date: Tue Apr 3 22:11:39 2018 New Revision: 331959 URL: https://svnweb.freebsd.org/changeset/base/331959 Log: cryptosoft: Remove a dead store Introduced in r331639 by removing an instance of undefined behavior. While we're here, the variable scope can be entirely moved inside the loop. Reported by: Coverity CID: 1387985 Sponsored by: Dell EMC Isilon Modified: head/sys/opencrypto/cryptosoft.c Modified: head/sys/opencrypto/cryptosoft.c ============================================================================== --- head/sys/opencrypto/cryptosoft.c Tue Apr 3 22:10:50 2018 (r331958) +++ head/sys/opencrypto/cryptosoft.c Tue Apr 3 22:11:39 2018 (r331959) @@ -84,7 +84,7 @@ static int swcr_encdec(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf, int flags) { - unsigned char iv[EALG_MAX_BLOCK_LEN], blk[EALG_MAX_BLOCK_LEN], *idat; + unsigned char iv[EALG_MAX_BLOCK_LEN], blk[EALG_MAX_BLOCK_LEN]; unsigned char *ivp, *nivp, iv2[EALG_MAX_BLOCK_LEN]; struct enc_xform *exf; int i, j, k, blks, ind, count, ivlen; @@ -249,11 +249,12 @@ swcr_encdec(struct cryptodesc *crd, struct swcr_data * } while (uio->uio_iov[ind].iov_len >= k + blks && i > 0) { + uint8_t *idat; size_t nb, rem; nb = blks; rem = uio->uio_iov[ind].iov_len - k; - idat = (char *)uio->uio_iov[ind].iov_base + k; + idat = (uint8_t *)uio->uio_iov[ind].iov_base + k; if (exf->reinit) { if ((crd->crd_flags & CRD_F_ENCRYPT) != 0 && @@ -296,7 +297,6 @@ swcr_encdec(struct cryptodesc *crd, struct swcr_data * ivp = nivp; } - idat += nb; count += nb; k += nb; i -= nb; From owner-svn-src-head@freebsd.org Tue Apr 3 22:15:54 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 262CDF85158; Tue, 3 Apr 2018 22:15:54 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D05F8784ED; Tue, 3 Apr 2018 22:15:53 +0000 (UTC) (envelope-from mw@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 CADC429A0; Tue, 3 Apr 2018 22:15:53 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33MFrOa013470; Tue, 3 Apr 2018 22:15:53 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33MFr3O013467; Tue, 3 Apr 2018 22:15:53 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804032215.w33MFr3O013467@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Tue, 3 Apr 2018 22:15:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331960 - in head/sys/arm/mv: . armada X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys/arm/mv: . armada X-SVN-Commit-Revision: 331960 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 22:15:54 -0000 Author: mw Date: Tue Apr 3 22:15:53 2018 New Revision: 331960 URL: https://svnweb.freebsd.org/changeset/base/331960 Log: Make Marvell Armada watchdog driver more generic Store platform dependent functions and constants in mv_wdt_config structure and select proper configuration on runtime based on compatible string provided in FDT. Marvell Armada38X and ArmadaXP non-repetitive registers are moved to generic part of code. To support armv5 as well, use proper compatible string: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/watchdog/orion_wdt.c?h=v4.13-rc3#n456 Submitted by: Rafal Kozik Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14740 Modified: head/sys/arm/mv/armada/wdt.c head/sys/arm/mv/mvreg.h Modified: head/sys/arm/mv/armada/wdt.c ============================================================================== --- head/sys/arm/mv/armada/wdt.c Tue Apr 3 22:11:39 2018 (r331959) +++ head/sys/arm/mv/armada/wdt.c Tue Apr 3 22:15:53 2018 (r331960) @@ -53,22 +53,54 @@ __FBSDID("$FreeBSD$"); #define INITIAL_TIMECOUNTER (0xffffffff) #define MAX_WATCHDOG_TICKS (0xffffffff) +#define WD_RST_OUT_EN 0x00000002 -#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) -#define MV_CLOCK_SRC 25000000 /* Timers' 25MHz mode */ -#else -#define MV_CLOCK_SRC get_tclk() -#endif +#define MV_CLOCK_SRC_ARMV7 25000000 /* Timers' 25MHz mode */ -#if defined(SOC_MV_ARMADA38X) -#define WATCHDOG_TIMER 4 -#else -#define WATCHDOG_TIMER 2 -#endif +struct mv_wdt_config { + enum soc_family wdt_soc; + uint32_t wdt_timer; + void (*wdt_enable)(void); + void (*wdt_disable)(void); + unsigned int wdt_clock_src; +}; +static void mv_wdt_enable_armv5(void); +static void mv_wdt_enable_armada_38x(void); +static void mv_wdt_enable_armada_xp(void); + +static void mv_wdt_disable_armv5(void); +static void mv_wdt_disable_armada_38x(void); +static void mv_wdt_disable_armada_xp(void); + +static struct mv_wdt_config mv_wdt_armada_38x_config = { + .wdt_soc = MV_SOC_ARMADA_38X, + .wdt_timer = 4, + .wdt_enable = &mv_wdt_enable_armada_38x, + .wdt_disable = &mv_wdt_disable_armada_38x, + .wdt_clock_src = MV_CLOCK_SRC_ARMV7, +}; + +static struct mv_wdt_config mv_wdt_armada_xp_config = { + .wdt_soc = MV_SOC_ARMADA_XP, + .wdt_timer = 2, + .wdt_enable = &mv_wdt_enable_armada_xp, + .wdt_disable = &mv_wdt_disable_armada_xp, + .wdt_clock_src = MV_CLOCK_SRC_ARMV7, +}; + +static struct mv_wdt_config mv_wdt_armv5_config = { + .wdt_soc = MV_SOC_ARMV5, + .wdt_timer = 2, + .wdt_enable = &mv_wdt_enable_armv5, + .wdt_disable = &mv_wdt_disable_armv5, + .wdt_clock_src = 0, +}; + struct mv_wdt_softc { struct resource * wdt_res; struct mtx wdt_mtx; + struct mv_wdt_config * wdt_config; }; static struct resource_spec mv_wdt_spec[] = { @@ -77,8 +109,10 @@ static struct resource_spec mv_wdt_spec[] = { }; static struct ofw_compat_data mv_wdt_compat[] = { - {"marvell,armada-380-wdt", true}, - {NULL, false} + {"marvell,armada-380-wdt", (uintptr_t)&mv_wdt_armada_38x_config}, + {"marvell,armada-xp-wdt", (uintptr_t)&mv_wdt_armada_xp_config}, + {"marvell,orion-wdt", (uintptr_t)&mv_wdt_armv5_config}, + {NULL, (uintptr_t)NULL} }; static struct mv_wdt_softc *wdt_softc = NULL; @@ -91,8 +125,6 @@ static uint32_t mv_get_timer_control(void); static void mv_set_timer_control(uint32_t); static void mv_set_timer(uint32_t, uint32_t); -static void mv_watchdog_enable(void); -static void mv_watchdog_disable(void); static void mv_watchdog_event(void *, unsigned int, int *); static device_method_t mv_wdt_methods[] = { @@ -145,7 +177,14 @@ mv_wdt_attach(device_t dev) mtx_init(&sc->wdt_mtx, "watchdog", NULL, MTX_DEF); - mv_watchdog_disable(); + sc->wdt_config = (struct mv_wdt_config *) + ofw_bus_search_compatible(dev, mv_wdt_compat)->ocd_data; + + if (sc->wdt_config->wdt_clock_src == 0) + sc->wdt_config->wdt_clock_src = get_tclk(); + + if (wdt_softc->wdt_config->wdt_disable != NULL) + wdt_softc->wdt_config->wdt_disable(); EVENTHANDLER_REGISTER(watchdog_list, mv_watchdog_event, sc, 0); return (0); @@ -171,20 +210,37 @@ mv_set_timer(uint32_t timer, uint32_t val) bus_write_4(wdt_softc->wdt_res, CPU_TIMER0 + timer * 0x8, val); } - static void -mv_watchdog_enable(void) +mv_wdt_enable_armv5(void) { + uint32_t val, irq_cause, irq_mask; + + irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); + irq_cause &= IRQ_TIMER_WD_CLR; + write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); + + irq_mask = read_cpu_ctrl(BRIDGE_IRQ_MASK); + irq_mask |= IRQ_TIMER_WD_MASK; + write_cpu_ctrl(BRIDGE_IRQ_MASK, irq_mask); + + val = read_cpu_ctrl(RSTOUTn_MASK); + val |= WD_RST_OUT_EN; + write_cpu_ctrl(RSTOUTn_MASK, val); + + val = mv_get_timer_control(); + val |= CPU_TIMER2_EN | CPU_TIMER2_AUTO; + mv_set_timer_control(val); +} + +static inline void +mv_wdt_enable_armada_38x_xp_helper() +{ uint32_t val, irq_cause; -#if !defined(SOC_MV_ARMADAXP) && !defined(SOC_MV_ARMADA38X) - uint32_t irq_mask; -#endif irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); irq_cause &= IRQ_TIMER_WD_CLR; write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); -#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) val = read_cpu_mp_clocks(WD_RSTOUTn_MASK); val |= (WD_GLOBAL_MASK | WD_CPU0_MASK); write_cpu_mp_clocks(WD_RSTOUTn_MASK, val); @@ -192,52 +248,41 @@ mv_watchdog_enable(void) val = read_cpu_misc(RSTOUTn_MASK); val &= ~RSTOUTn_MASK_WD; write_cpu_misc(RSTOUTn_MASK, val); -#else - irq_mask = read_cpu_ctrl(BRIDGE_IRQ_MASK); - irq_mask |= IRQ_TIMER_WD_MASK; - write_cpu_ctrl(BRIDGE_IRQ_MASK, irq_mask); +} - val = read_cpu_ctrl(RSTOUTn_MASK); - val |= WD_RST_OUT_EN; - write_cpu_ctrl(RSTOUTn_MASK, val); -#endif +static void +mv_wdt_enable_armada_38x(void) +{ + uint32_t val; + mv_wdt_enable_armada_38x_xp_helper(); + val = mv_get_timer_control(); -#if defined(SOC_MV_ARMADA38X) val |= CPU_TIMER_WD_EN | CPU_TIMER_WD_AUTO | CPU_TIMER_WD_25MHZ_EN; -#elif defined(SOC_MV_ARMADAXP) + mv_set_timer_control(val); +} + +static void +mv_wdt_enable_armada_xp(void) +{ + uint32_t val; + + mv_wdt_enable_armada_38x_xp_helper(); + + val = mv_get_timer_control(); val |= CPU_TIMER2_EN | CPU_TIMER2_AUTO | CPU_TIMER_WD_25MHZ_EN; -#else - val |= CPU_TIMER2_EN | CPU_TIMER2_AUTO; -#endif mv_set_timer_control(val); } static void -mv_watchdog_disable(void) +mv_wdt_disable_armv5(void) { - uint32_t val, irq_cause; -#if !defined(SOC_MV_ARMADAXP) && !defined(SOC_MV_ARMADA38X) - uint32_t irq_mask; -#endif + uint32_t val, irq_cause, irq_mask; val = mv_get_timer_control(); -#if defined(SOC_MV_ARMADA38X) - val &= ~(CPU_TIMER_WD_EN | CPU_TIMER_WD_AUTO); -#else val &= ~(CPU_TIMER2_EN | CPU_TIMER2_AUTO); -#endif mv_set_timer_control(val); -#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) - val = read_cpu_mp_clocks(WD_RSTOUTn_MASK); - val &= ~(WD_GLOBAL_MASK | WD_CPU0_MASK); - write_cpu_mp_clocks(WD_RSTOUTn_MASK, val); - - val = read_cpu_misc(RSTOUTn_MASK); - val |= RSTOUTn_MASK_WD; - write_cpu_misc(RSTOUTn_MASK, RSTOUTn_MASK_WD); -#else val = read_cpu_ctrl(RSTOUTn_MASK); val &= ~WD_RST_OUT_EN; write_cpu_ctrl(RSTOUTn_MASK, val); @@ -245,13 +290,50 @@ mv_watchdog_disable(void) irq_mask = read_cpu_ctrl(BRIDGE_IRQ_MASK); irq_mask &= ~(IRQ_TIMER_WD_MASK); write_cpu_ctrl(BRIDGE_IRQ_MASK, irq_mask); -#endif irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); irq_cause &= IRQ_TIMER_WD_CLR; write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); } +static __inline void +mv_wdt_disable_armada_38x_xp_helper(void) +{ + uint32_t val; + + val = read_cpu_mp_clocks(WD_RSTOUTn_MASK); + val &= ~(WD_GLOBAL_MASK | WD_CPU0_MASK); + write_cpu_mp_clocks(WD_RSTOUTn_MASK, val); + + val = read_cpu_misc(RSTOUTn_MASK); + val |= RSTOUTn_MASK_WD; + write_cpu_misc(RSTOUTn_MASK, RSTOUTn_MASK_WD); +} + +static void +mv_wdt_disable_armada_38x(void) +{ + uint32_t val; + + val = mv_get_timer_control(); + val &= ~(CPU_TIMER_WD_EN | CPU_TIMER_WD_AUTO); + mv_set_timer_control(val); + + mv_wdt_disable_armada_38x_xp_helper(); +} + +static void +mv_wdt_disable_armada_xp(void) +{ + uint32_t val; + + val = mv_get_timer_control(); + val &= ~(CPU_TIMER2_EN | CPU_TIMER2_AUTO); + mv_set_timer_control(val); + + mv_wdt_disable_armada_38x_xp_helper(); +} + /* * Watchdog event handler. */ @@ -264,20 +346,24 @@ mv_watchdog_event(void *arg, unsigned int cmd, int *er sc = arg; mtx_lock(&sc->wdt_mtx); - if (cmd == 0) - mv_watchdog_disable(); - else { + if (cmd == 0) { + if (wdt_softc->wdt_config->wdt_disable != NULL) + wdt_softc->wdt_config->wdt_disable(); + } else { /* * Watchdog timeout is in nanosecs, calculation according to * watchdog(9) */ ns = (uint64_t)1 << (cmd & WD_INTERVAL); - ticks = (uint64_t)(ns * MV_CLOCK_SRC) / 1000000000; - if (ticks > MAX_WATCHDOG_TICKS) - mv_watchdog_disable(); + ticks = (uint64_t)(ns * sc->wdt_config->wdt_clock_src) / 1000000000; + if (ticks > MAX_WATCHDOG_TICKS) { + if (wdt_softc->wdt_config->wdt_disable != NULL) + wdt_softc->wdt_config->wdt_disable(); + } else { - mv_set_timer(WATCHDOG_TIMER, ticks); - mv_watchdog_enable(); + mv_set_timer(wdt_softc->wdt_config->wdt_timer, ticks); + if (wdt_softc->wdt_config->wdt_enable != NULL) + wdt_softc->wdt_config->wdt_enable(); *error = 0; } } Modified: head/sys/arm/mv/mvreg.h ============================================================================== --- head/sys/arm/mv/mvreg.h Tue Apr 3 22:11:39 2018 (r331959) +++ head/sys/arm/mv/mvreg.h Tue Apr 3 22:15:53 2018 (r331960) @@ -105,20 +105,20 @@ */ #if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) #define RSTOUTn_MASK 0x60 -#define RSTOUTn_MASK_WD 0x400 #define SYSTEM_SOFT_RESET 0x64 -#define WD_RSTOUTn_MASK 0x4 -#define WD_GLOBAL_MASK 0x00000100 -#define WD_CPU0_MASK 0x00000001 #define SOFT_RST_OUT_EN 0x00000001 #define SYS_SOFT_RST 0x00000001 #else #define RSTOUTn_MASK 0x8 -#define WD_RST_OUT_EN 0x00000002 #define SOFT_RST_OUT_EN 0x00000004 #define SYSTEM_SOFT_RESET 0xc #define SYS_SOFT_RST 0x00000001 #endif +#define RSTOUTn_MASK_WD 0x400 +#define WD_RSTOUTn_MASK 0x4 +#define WD_GLOBAL_MASK 0x00000100 +#define WD_CPU0_MASK 0x00000001 +#define WD_RST_OUT_EN 0x00000002 /* * Power Control From owner-svn-src-head@freebsd.org Tue Apr 3 22:21:13 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A0E3CF855DE; Tue, 3 Apr 2018 22:21:13 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D47D78920; Tue, 3 Apr 2018 22:21:13 +0000 (UTC) (envelope-from mw@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 481282ADA; Tue, 3 Apr 2018 22:21:13 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33MLDwY019505; Tue, 3 Apr 2018 22:21:13 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33MLDTE019502; Tue, 3 Apr 2018 22:21:13 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804032221.w33MLDTE019502@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Tue, 3 Apr 2018 22:21:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331961 - in head/sys: arm/mv dts/arm X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys: arm/mv dts/arm X-SVN-Commit-Revision: 331961 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 22:21:13 -0000 Author: mw Date: Tue Apr 3 22:21:12 2018 New Revision: 331961 URL: https://svnweb.freebsd.org/changeset/base/331961 Log: Make Marvell AmadaXP timer driver more generic Store pointers to SoC specific functions in mv_timer_config structure and determine proper config in runtime based on compatible string from FDT. Compatible string for ArmadaXP timers is changed to match Linux FDT. Armada 38x uses generic Cortex-A9 timer and separate watchdog drivers, so it does not need to be supported by timer driver. Submitted by: Rafal Kozik Reviewed by: manu Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14741 Modified: head/sys/arm/mv/timer.c head/sys/dts/arm/db78460.dts Modified: head/sys/arm/mv/timer.c ============================================================================== --- head/sys/arm/mv/timer.c Tue Apr 3 22:15:53 2018 (r331960) +++ head/sys/arm/mv/timer.c Tue Apr 3 22:21:12 2018 (r331961) @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -60,18 +61,20 @@ __FBSDID("$FreeBSD$"); #define MV_WDT 0x2 #define MV_NONE 0x0 -#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) -#define MV_CLOCK_SRC 25000000 /* Timers' 25MHz mode */ -#else -#define MV_CLOCK_SRC get_tclk() -#endif +#define MV_CLOCK_SRC_ARMV7 25000000 /* Timers' 25MHz mode */ -#if defined(SOC_MV_ARMADA38X) -#define WATCHDOG_TIMER 4 -#else -#define WATCHDOG_TIMER 2 -#endif +#define WATCHDOG_TIMER_ARMV5 2 +typedef void (*mv_watchdog_enable_t)(void); +typedef void (*mv_watchdog_disable_t)(void); + +struct mv_timer_config { + enum soc_family soc_family; + mv_watchdog_enable_t watchdog_enable; + mv_watchdog_disable_t watchdog_disable; + unsigned int clock_src; +}; + struct mv_timer_softc { struct resource * timer_res[2]; bus_space_tag_t timer_bst; @@ -79,6 +82,7 @@ struct mv_timer_softc { struct mtx timer_mtx; struct eventtimer et; boolean_t has_wdt; + struct mv_timer_config* config; }; static struct resource_spec mv_timer_spec[] = { @@ -89,8 +93,9 @@ static struct resource_spec mv_timer_spec[] = { /* Interrupt is not required by MV_WDT devices */ static struct ofw_compat_data mv_timer_compat[] = { + {"marvell,armada-380-timer", MV_NONE }, + {"marvell,armada-xp-timer", MV_TMR | MV_WDT }, {"mrvl,timer", MV_TMR | MV_WDT }, - {"marvell,armada-380-wdt", MV_WDT }, {NULL, MV_NONE } }; @@ -108,14 +113,42 @@ static void mv_set_timer_control(uint32_t); static uint32_t mv_get_timer(uint32_t); static void mv_set_timer(uint32_t, uint32_t); static void mv_set_timer_rel(uint32_t, uint32_t); -static void mv_watchdog_enable(void); -static void mv_watchdog_disable(void); static void mv_watchdog_event(void *, unsigned int, int *); static int mv_timer_start(struct eventtimer *et, sbintime_t first, sbintime_t period); static int mv_timer_stop(struct eventtimer *et); static void mv_setup_timers(void); +static void mv_watchdog_enable_armv5(void); +static void mv_watchdog_enable_armadaxp(void); +static void mv_watchdog_disable_armv5(void); +static void mv_watchdog_disable_armadaxp(void); + +#ifdef PLATFORM +void mv_delay(int usec, void* arg); +#endif + +static struct mv_timer_config timer_armadaxp_config = +{ + MV_SOC_ARMADA_XP, + &mv_watchdog_enable_armadaxp, + &mv_watchdog_disable_armadaxp, + MV_CLOCK_SRC_ARMV7, +}; +static struct mv_timer_config timer_armv5_config = +{ + MV_SOC_ARMV5, + &mv_watchdog_enable_armv5, + &mv_watchdog_disable_armv5, + 0, +}; + +static struct ofw_compat_data mv_timer_soc_config[] = { + {"marvell,armada-xp-timer", (uintptr_t)&timer_armadaxp_config }, + {"mrvl,timer", (uintptr_t)&timer_armv5_config }, + {NULL, (uintptr_t)NULL }, +}; + static struct timecounter mv_timer_timecounter = { .tc_get_timecount = mv_timer_get_timecount, .tc_name = "CPUTimer1", @@ -144,9 +177,7 @@ mv_timer_attach(device_t dev) int error; void *ihl; struct mv_timer_softc *sc; -#if !defined(SOC_MV_ARMADAXP) && !defined(SOC_MV_ARMADA38X) uint32_t irq_cause, irq_mask; -#endif if (timer_softc != NULL) return (ENXIO); @@ -154,6 +185,12 @@ mv_timer_attach(device_t dev) sc = (struct mv_timer_softc *)device_get_softc(dev); timer_softc = sc; + sc->config = (struct mv_timer_config*) + ofw_bus_search_compatible(dev, mv_timer_soc_config)->ocd_data; + + if (sc->config->clock_src == 0) + sc->config->clock_src = get_tclk(); + error = bus_alloc_resources(dev, mv_timer_spec, sc->timer_res); if (error) { device_printf(dev, "could not allocate resources\n"); @@ -163,13 +200,13 @@ mv_timer_attach(device_t dev) sc->timer_bst = rman_get_bustag(sc->timer_res[0]); sc->timer_bsh = rman_get_bushandle(sc->timer_res[0]); - sc->has_wdt = ofw_bus_has_prop(dev, "mrvl,has-wdt") || - ofw_bus_is_compatible(dev, "marvell,armada-380-wdt"); + sc->has_wdt = ofw_bus_has_prop(dev, "mrvl,has-wdt"); mtx_init(&timer_softc->timer_mtx, "watchdog", NULL, MTX_DEF); if (sc->has_wdt) { - mv_watchdog_disable(); + if (sc->config->watchdog_disable) + sc->config->watchdog_disable(); EVENTHANDLER_REGISTER(watchdog_list, mv_watchdog_event, sc, 0); } @@ -192,30 +229,33 @@ mv_timer_attach(device_t dev) } mv_setup_timers(); -#if !defined(SOC_MV_ARMADAXP) && !defined(SOC_MV_ARMADA38X) - irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); - irq_cause &= IRQ_TIMER0_CLR; + if (sc->config->soc_family != MV_SOC_ARMADA_XP ) { + irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); + irq_cause &= IRQ_TIMER0_CLR; - write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); - irq_mask = read_cpu_ctrl(BRIDGE_IRQ_MASK); - irq_mask |= IRQ_TIMER0_MASK; - irq_mask &= ~IRQ_TIMER1_MASK; - write_cpu_ctrl(BRIDGE_IRQ_MASK, irq_mask); -#endif + write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); + irq_mask = read_cpu_ctrl(BRIDGE_IRQ_MASK); + irq_mask |= IRQ_TIMER0_MASK; + irq_mask &= ~IRQ_TIMER1_MASK; + write_cpu_ctrl(BRIDGE_IRQ_MASK, irq_mask); + } sc->et.et_name = "CPUTimer0"; sc->et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT; sc->et.et_quality = 1000; - sc->et.et_frequency = MV_CLOCK_SRC; + sc->et.et_frequency = sc->config->clock_src; sc->et.et_min_period = (0x00000002LLU << 32) / sc->et.et_frequency; sc->et.et_max_period = (0xfffffffeLLU << 32) / sc->et.et_frequency; sc->et.et_start = mv_timer_start; sc->et.et_stop = mv_timer_stop; sc->et.et_priv = sc; et_register(&sc->et); - mv_timer_timecounter.tc_frequency = MV_CLOCK_SRC; + mv_timer_timecounter.tc_frequency = sc->config->clock_src; tc_init(&mv_timer_timecounter); +#ifdef PLATFORM + arm_set_delay(mv_delay, NULL); +#endif return (0); } @@ -260,8 +300,13 @@ mv_timer_get_timecount(struct timecounter *tc) return (INITIAL_TIMECOUNTER - mv_get_timer(1)); } +#ifdef PLATFORM void +mv_delay(int usec, void* arg) +#else +void DELAY(int usec) +#endif { uint32_t val, val_temp; int32_t nticks; @@ -275,7 +320,7 @@ DELAY(int usec) TSENTER(); val = mv_get_timer(1); - nticks = ((MV_CLOCK_SRC / 1000000 + 1) * usec); + nticks = ((timer_softc->config->clock_src / 1000000 + 1) * usec); while (nticks > 0) { val_temp = mv_get_timer(1); @@ -330,26 +375,14 @@ mv_set_timer_rel(uint32_t timer, uint32_t val) } static void -mv_watchdog_enable(void) +mv_watchdog_enable_armv5(void) { - uint32_t val, irq_cause; -#if !defined(SOC_MV_ARMADAXP) && !defined(SOC_MV_ARMADA38X) - uint32_t irq_mask; -#endif + uint32_t val, irq_cause, irq_mask; irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); irq_cause &= IRQ_TIMER_WD_CLR; write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); -#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) - val = read_cpu_mp_clocks(WD_RSTOUTn_MASK); - val |= (WD_GLOBAL_MASK | WD_CPU0_MASK); - write_cpu_mp_clocks(WD_RSTOUTn_MASK, val); - - val = read_cpu_misc(RSTOUTn_MASK); - val &= ~RSTOUTn_MASK_WD; - write_cpu_misc(RSTOUTn_MASK, val); -#else irq_mask = read_cpu_ctrl(BRIDGE_IRQ_MASK); irq_mask |= IRQ_TIMER_WD_MASK; write_cpu_ctrl(BRIDGE_IRQ_MASK, irq_mask); @@ -357,44 +390,43 @@ mv_watchdog_enable(void) val = read_cpu_ctrl(RSTOUTn_MASK); val |= WD_RST_OUT_EN; write_cpu_ctrl(RSTOUTn_MASK, val); -#endif val = mv_get_timer_control(); -#if defined(SOC_MV_ARMADA38X) - val |= CPU_TIMER_WD_EN | CPU_TIMER_WD_AUTO | CPU_TIMER_WD_25MHZ_EN; -#elif defined(SOC_MV_ARMADAXP) - val |= CPU_TIMER2_EN | CPU_TIMER2_AUTO | CPU_TIMER_WD_25MHZ_EN; -#else val |= CPU_TIMER2_EN | CPU_TIMER2_AUTO; -#endif mv_set_timer_control(val); } static void -mv_watchdog_disable(void) +mv_watchdog_enable_armadaxp(void) { - uint32_t val, irq_cause; -#if !defined(SOC_MV_ARMADAXP) && !defined(SOC_MV_ARMADA38X) - uint32_t irq_mask; -#endif + uint32_t irq_cause, val; - val = mv_get_timer_control(); -#if defined(SOC_MV_ARMADA38X) - val &= ~(CPU_TIMER_WD_EN | CPU_TIMER_WD_AUTO); -#else - val &= ~(CPU_TIMER2_EN | CPU_TIMER2_AUTO); -#endif - mv_set_timer_control(val); + irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); + irq_cause &= IRQ_TIMER_WD_CLR; + write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); -#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) val = read_cpu_mp_clocks(WD_RSTOUTn_MASK); - val &= ~(WD_GLOBAL_MASK | WD_CPU0_MASK); + val |= (WD_GLOBAL_MASK | WD_CPU0_MASK); write_cpu_mp_clocks(WD_RSTOUTn_MASK, val); val = read_cpu_misc(RSTOUTn_MASK); - val |= RSTOUTn_MASK_WD; - write_cpu_misc(RSTOUTn_MASK, RSTOUTn_MASK_WD); -#else + val &= ~RSTOUTn_MASK_WD; + write_cpu_misc(RSTOUTn_MASK, val); + + val = mv_get_timer_control(); + val |= CPU_TIMER2_EN | CPU_TIMER2_AUTO | CPU_TIMER_WD_25MHZ_EN; + mv_set_timer_control(val); +} + +static void +mv_watchdog_disable_armv5(void) +{ + uint32_t val, irq_cause,irq_mask; + + val = mv_get_timer_control(); + val &= ~(CPU_TIMER2_EN | CPU_TIMER2_AUTO); + mv_set_timer_control(val); + val = read_cpu_ctrl(RSTOUTn_MASK); val &= ~WD_RST_OUT_EN; write_cpu_ctrl(RSTOUTn_MASK, val); @@ -402,14 +434,34 @@ mv_watchdog_disable(void) irq_mask = read_cpu_ctrl(BRIDGE_IRQ_MASK); irq_mask &= ~(IRQ_TIMER_WD_MASK); write_cpu_ctrl(BRIDGE_IRQ_MASK, irq_mask); -#endif irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); irq_cause &= IRQ_TIMER_WD_CLR; write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); } +static void +mv_watchdog_disable_armadaxp(void) +{ + uint32_t val, irq_cause; + val = read_cpu_mp_clocks(WD_RSTOUTn_MASK); + val &= ~(WD_GLOBAL_MASK | WD_CPU0_MASK); + write_cpu_mp_clocks(WD_RSTOUTn_MASK, val); + + val = read_cpu_misc(RSTOUTn_MASK); + val |= RSTOUTn_MASK_WD; + write_cpu_misc(RSTOUTn_MASK, RSTOUTn_MASK_WD); + + irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); + irq_cause &= IRQ_TIMER_WD_CLR; + write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); + + val = mv_get_timer_control(); + val &= ~(CPU_TIMER2_EN | CPU_TIMER2_AUTO); + mv_set_timer_control(val); +} + /* * Watchdog event handler. */ @@ -420,20 +472,23 @@ mv_watchdog_event(void *arg, unsigned int cmd, int *er uint64_t ticks; mtx_lock(&timer_softc->timer_mtx); - if (cmd == 0) - mv_watchdog_disable(); - else { + if (cmd == 0) { + if (timer_softc->config->watchdog_disable != NULL) + timer_softc->config->watchdog_disable(); + } else { /* * Watchdog timeout is in nanosecs, calculation according to * watchdog(9) */ ns = (uint64_t)1 << (cmd & WD_INTERVAL); - ticks = (uint64_t)(ns * MV_CLOCK_SRC) / 1000000000; - if (ticks > MAX_WATCHDOG_TICKS) - mv_watchdog_disable(); - else { - mv_set_timer(WATCHDOG_TIMER, ticks); - mv_watchdog_enable(); + ticks = (uint64_t)(ns * timer_softc->config->clock_src) / 1000000000; + if (ticks > MAX_WATCHDOG_TICKS) { + if (timer_softc->config->watchdog_disable != NULL) + timer_softc->config->watchdog_disable(); + } else { + mv_set_timer(WATCHDOG_TIMER_ARMV5, ticks); + if (timer_softc->config->watchdog_enable != NULL) + timer_softc->config->watchdog_enable(); *error = 0; } } @@ -491,10 +546,12 @@ mv_setup_timers(void) val = mv_get_timer_control(); val &= ~(CPU_TIMER0_EN | CPU_TIMER0_AUTO); val |= CPU_TIMER1_EN | CPU_TIMER1_AUTO; -#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) - /* Enable 25MHz mode */ - val |= CPU_TIMER0_25MHZ_EN | CPU_TIMER1_25MHZ_EN; -#endif + + if (timer_softc->config->soc_family == MV_SOC_ARMADA_XP) { + /* Enable 25MHz mode */ + val |= CPU_TIMER0_25MHZ_EN | CPU_TIMER1_25MHZ_EN; + } + mv_set_timer_control(val); timers_initialized = 1; } Modified: head/sys/dts/arm/db78460.dts ============================================================================== --- head/sys/dts/arm/db78460.dts Tue Apr 3 22:15:53 2018 (r331960) +++ head/sys/dts/arm/db78460.dts Tue Apr 3 22:21:12 2018 (r331961) @@ -85,7 +85,7 @@ }; timer@21840 { - compatible = "mrvl,timer"; + compatible = "marvell,armada-xp-timer"; reg = <0x21840 0x30>; interrupts = <5>; interrupt-parent = <&MPIC>; From owner-svn-src-head@freebsd.org Tue Apr 3 22:35:36 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F81CF8614C; Tue, 3 Apr 2018 22:35:36 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.blih.net", Issuer "mail.blih.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id B2F4F792BD; Tue, 3 Apr 2018 22:35:35 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) by mail.blih.net (OpenSMTPD) with ESMTP id f698a56e; Wed, 4 Apr 2018 00:28:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bidouilliste.com; h= mime-version:content-type:content-transfer-encoding:date:from:to :cc:subject:in-reply-to:references:message-id; s=mail; bh=NOT2Fn ZYGpUVwE9fHG5K0UllqKo=; b=Mv4lFB2q/VtOiXfa7ewy90cxyjXOnUBTVzyv+M Wpv9dii/dLyjDIew66y56FbNCCuSLbJMntZpmT2fylGDU6cdlO878Xt3l7m+EQLp 27QY9AMvBAkjgDkEsRVf0Kxuri0PfzmiRO/HJa0xJE0t5aXnS2NK+yU1fKAoMogB nq1gg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=bidouilliste.com; h= mime-version:content-type:content-transfer-encoding:date:from:to :cc:subject:in-reply-to:references:message-id; q=dns; s=mail; b= dvPrUnM/D//fALJZ7pkRZjFOMBJAPNALdrvi2Zrh57pv6JRcN62KCwxjbjaugnRV 6RTZdb0cHDmXdvR4zRvbaHvooNHlduIzwkswHVSeCfJB0XkCquk55cFYCkTiFPUA Res2CnSW0kTamEvf4nTvzg0+xGDfW0MSEw72X6v7H7U= Received: from webmail.megadrive.org (www1.blih.net [212.83.177.180]) by mail.blih.net (OpenSMTPD) with ESMTP id 2b35bd42; Wed, 4 Apr 2018 00:28:53 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 04 Apr 2018 00:28:53 +0200 From: Emmanuel Vadot To: Marcin Wojtas Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, owner-src-committers@freebsd.org Subject: Re: svn commit: r331961 - in head/sys: arm/mv dts/arm Organization: Bidouilliste In-Reply-To: <201804032221.w33MLDTE019502@repo.freebsd.org> References: <201804032221.w33MLDTE019502@repo.freebsd.org> Message-ID: <5dea78be118fa5ee4b8cb77a1e26a6f0@megadrive.org> X-Sender: manu@bidouilliste.com User-Agent: Roundcube Webmail/1.1.1 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 22:35:36 -0000 On 2018-04-04 00:21, Marcin Wojtas wrote: > Author: mw > Date: Tue Apr 3 22:21:12 2018 > New Revision: 331961 > URL: https://svnweb.freebsd.org/changeset/base/331961 > > Log: > Make Marvell AmadaXP timer driver more generic > > Store pointers to SoC specific functions in mv_timer_config structure > and determine proper config in runtime based on compatible string > from FDT. > Compatible string for ArmadaXP timers is changed to match Linux FDT. > Armada 38x uses generic Cortex-A9 timer and separate watchdog > drivers, so > it does not need to be supported by timer driver. > > Submitted by: Rafal Kozik > Reviewed by: manu > Obtained from: Semihalf > Sponsored by: Stormshield > Differential Revision: https://reviews.freebsd.org/D14741 Hello Marcin, I've only reviewed the DTS part. Also you didn't address andrew@ comment, see https://reviews.freebsd.org/D14741?id=40452#inline-89719 Cheers, -- Emmanuel Vadot From owner-svn-src-head@freebsd.org Tue Apr 3 23:11:09 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5ED56F8855B; Tue, 3 Apr 2018 23:11:09 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 119BC7A989; Tue, 3 Apr 2018 23:11:09 +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 0C7F13227; Tue, 3 Apr 2018 23:11:09 +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 w33NB8JB090164; Tue, 3 Apr 2018 23:11:08 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33NB83B090161; Tue, 3 Apr 2018 23:11:08 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <201804032311.w33NB83B090161@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Tue, 3 Apr 2018 23:11:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331963 - in head/share: examples/etc mk X-SVN-Group: head X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: in head/share: examples/etc mk X-SVN-Commit-Revision: 331963 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 23:11:09 -0000 Author: jkim Date: Tue Apr 3 23:11:08 2018 New Revision: 331963 URL: https://svnweb.freebsd.org/changeset/base/331963 Log: Catch up with Clang 6.0. MFC after: 3 days Modified: head/share/examples/etc/make.conf head/share/mk/bsd.cpu.mk Modified: head/share/examples/etc/make.conf ============================================================================== --- head/share/examples/etc/make.conf Tue Apr 3 22:49:58 2018 (r331962) +++ head/share/examples/etc/make.conf Tue Apr 3 23:11:08 2018 (r331963) @@ -45,7 +45,8 @@ # Additionally the following CPU types are recognized by clang: # Intel x86 architecture (for both amd64 and i386): # (AMD CPUs) znver1, bdver4, bdver3, bdver2, bdver1, btver2, btver1 -# (Intel CPUs) skylake, knl, broadwell, haswell, ivybridge, +# (Intel CPUs) cannonlake, knm, skylake-avx512, knl, goldmont, +# skylake, broadwell, haswell, ivybridge, # sandybridge, westmere, nehalem, silvermont, bonnell # # (?= allows to buildworld for a different CPUTYPE.) Modified: head/share/mk/bsd.cpu.mk ============================================================================== --- head/share/mk/bsd.cpu.mk Tue Apr 3 22:49:58 2018 (r331962) +++ head/share/mk/bsd.cpu.mk Tue Apr 3 23:11:08 2018 (r331963) @@ -199,14 +199,16 @@ MACHINE_CPU = 3dnow mmx k6 k5 i586 MACHINE_CPU = mmx k6 k5 i586 . elif ${CPUTYPE} == "k5" MACHINE_CPU = k5 i586 -. elif ${CPUTYPE} == "skylake" || ${CPUTYPE} == "knl" +. elif ${CPUTYPE} == "cannonlake" || ${CPUTYPE} == "knm" || \ + ${CPUTYPE} == "skylake-avx512" || ${CPUTYPE} == "knl" MACHINE_CPU = avx512 avx2 avx sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 -. elif ${CPUTYPE} == "broadwell" || ${CPUTYPE} == "haswell" +. elif ${CPUTYPE} == "skylake" || ${CPUTYPE} == "broadwell" || \ + ${CPUTYPE} == "haswell" MACHINE_CPU = avx2 avx sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 . elif ${CPUTYPE} == "ivybridge" || ${CPUTYPE} == "sandybridge" MACHINE_CPU = avx sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 -. elif ${CPUTYPE} == "westmere" || ${CPUTYPE} == "nehalem" || \ - ${CPUTYPE} == "silvermont" +. elif ${CPUTYPE} == "goldmont" || ${CPUTYPE} == "westmere" || \ + ${CPUTYPE} == "nehalem" || ${CPUTYPE} == "silvermont" MACHINE_CPU = sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 . elif ${CPUTYPE} == "penryn" MACHINE_CPU = sse41 ssse3 sse3 sse2 sse i686 mmx i586 @@ -260,14 +262,16 @@ MACHINE_CPU = k8 3dnow sse3 . elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ ${CPUTYPE} == "athlon-fx" || ${CPUTYPE} == "k8" MACHINE_CPU = k8 3dnow -. elif ${CPUTYPE} == "skylake" || ${CPUTYPE} == "knl" +. elif ${CPUTYPE} == "cannonlake" || ${CPUTYPE} == "knm" || \ + ${CPUTYPE} == "skylake-avx512" || ${CPUTYPE} == "knl" MACHINE_CPU = avx512 avx2 avx sse42 sse41 ssse3 sse3 -. elif ${CPUTYPE} == "broadwell" || ${CPUTYPE} == "haswell" +. elif ${CPUTYPE} == "skylake" || ${CPUTYPE} == "broadwell" || \ + ${CPUTYPE} == "haswell" MACHINE_CPU = avx2 avx sse42 sse41 ssse3 sse3 . elif ${CPUTYPE} == "ivybridge" || ${CPUTYPE} == "sandybridge" MACHINE_CPU = avx sse42 sse41 ssse3 sse3 -. elif ${CPUTYPE} == "westmere" || ${CPUTYPE} == "nehalem" || \ - ${CPUTYPE} == "silvermont" +. elif ${CPUTYPE} == "goldmont" || ${CPUTYPE} == "westmere" || \ + ${CPUTYPE} == "nehalem" || ${CPUTYPE} == "silvermont" MACHINE_CPU = sse42 sse41 ssse3 sse3 . elif ${CPUTYPE} == "penryn" MACHINE_CPU = sse41 ssse3 sse3 From owner-svn-src-head@freebsd.org Tue Apr 3 23:27:07 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CD316F89434; Tue, 3 Apr 2018 23:27:07 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7C34B7B6B3; Tue, 3 Apr 2018 23:27:07 +0000 (UTC) (envelope-from mw@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 773C338A7; Tue, 3 Apr 2018 23:27:07 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33NR7u1013323; Tue, 3 Apr 2018 23:27:07 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33NR78n013322; Tue, 3 Apr 2018 23:27:07 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804032327.w33NR78n013322@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Tue, 3 Apr 2018 23:27:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331964 - head/sys/arm/mv X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/arm/mv X-SVN-Commit-Revision: 331964 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 23:27:08 -0000 Author: mw Date: Tue Apr 3 23:27:07 2018 New Revision: 331964 URL: https://svnweb.freebsd.org/changeset/base/331964 Log: Add missing flag check in Marvell PCIE driver Flag was introduced in r331953, but eventually not used. Obtained from: Semihalf Sponsored by: Stormshield Modified: head/sys/arm/mv/mv_pci.c Modified: head/sys/arm/mv/mv_pci.c ============================================================================== --- head/sys/arm/mv/mv_pci.c Tue Apr 3 23:11:08 2018 (r331963) +++ head/sys/arm/mv/mv_pci.c Tue Apr 3 23:27:07 2018 (r331964) @@ -560,7 +560,8 @@ mv_pcib_enable(struct mv_pcib_softc *sc, uint32_t unit /* * Check if PCIE device is enabled. */ - if (read_cpu_ctrl(CPU_CONTROL) & CPU_CONTROL_PCIE_DISABLE(unit)) { + if ((sc->sc_skip_enable_procedure == 0) && + (read_cpu_ctrl(CPU_CONTROL) & CPU_CONTROL_PCIE_DISABLE(unit))) { write_cpu_ctrl(CPU_CONTROL, read_cpu_ctrl(CPU_CONTROL) & ~(CPU_CONTROL_PCIE_DISABLE(unit))); @@ -1057,7 +1058,7 @@ mv_pcib_root_slot(device_t dev, u_int bus, u_int slot, struct mv_pcib_softc *sc = device_get_softc(dev); uint32_t vendor, device; -/* On platforms other than Armada38x, root link is always at slot 0 */ + /* On platforms other than Armada38x, root link is always at slot 0 */ if (!sc->sc_enable_find_root_slot) return (slot == 0); From owner-svn-src-head@freebsd.org Tue Apr 3 23:29:35 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D850F8964F; Tue, 3 Apr 2018 23:29:35 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 008E67B8A9; Tue, 3 Apr 2018 23:29:35 +0000 (UTC) (envelope-from mw@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 EF68138A9; Tue, 3 Apr 2018 23:29:34 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33NTYJw015669; Tue, 3 Apr 2018 23:29:34 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33NTY4C015668; Tue, 3 Apr 2018 23:29:34 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804032329.w33NTY4C015668@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Tue, 3 Apr 2018 23:29:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331965 - head/sys/arm/mv X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/arm/mv X-SVN-Commit-Revision: 331965 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 23:29:35 -0000 Author: mw Date: Tue Apr 3 23:29:34 2018 New Revision: 331965 URL: https://svnweb.freebsd.org/changeset/base/331965 Log: Split out delay code in Marvell timer driver for PLATFORM The PLATFORM code will perform the software loop in the early boot, so extract the actual delay code to handle situation, when the timers are already initialized. Obtained from: Semihalf Sponsored by: Stormshield Modified: head/sys/arm/mv/timer.c Modified: head/sys/arm/mv/timer.c ============================================================================== --- head/sys/arm/mv/timer.c Tue Apr 3 23:27:07 2018 (r331964) +++ head/sys/arm/mv/timer.c Tue Apr 3 23:29:34 2018 (r331965) @@ -124,9 +124,7 @@ static void mv_watchdog_enable_armadaxp(void); static void mv_watchdog_disable_armv5(void); static void mv_watchdog_disable_armadaxp(void); -#ifdef PLATFORM -void mv_delay(int usec, void* arg); -#endif +static void mv_delay(int usec, void* arg); static struct mv_timer_config timer_armadaxp_config = { @@ -300,25 +298,12 @@ mv_timer_get_timecount(struct timecounter *tc) return (INITIAL_TIMECOUNTER - mv_get_timer(1)); } -#ifdef PLATFORM -void +static void mv_delay(int usec, void* arg) -#else -void -DELAY(int usec) -#endif { uint32_t val, val_temp; int32_t nticks; - if (!timers_initialized) { - for (; usec > 0; usec--) - for (val = 100; val > 0; val--) - __asm __volatile("nop" ::: "memory"); - return; - } - TSENTER(); - val = mv_get_timer(1); nticks = ((timer_softc->config->clock_src / 1000000 + 1) * usec); @@ -331,8 +316,25 @@ DELAY(int usec) val = val_temp; } - TSEXIT(); } + +#ifndef PLATFORM +void +DELAY(int usec) +{ + uint32_t val; + + if (!timers_initialized) { + for (; usec > 0; usec--) + for (val = 100; val > 0; val--) + __asm __volatile("nop" ::: "memory"); + } else { + TSENTER(); + mv_delay(usec, NULL); + TSEXIT(); + } +} +#endif static uint32_t mv_get_timer_control(void) From owner-svn-src-head@freebsd.org Tue Apr 3 23:49:36 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE5AEF8A71F; Tue, 3 Apr 2018 23:49:36 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5E07D7C467; Tue, 3 Apr 2018 23:49:36 +0000 (UTC) (envelope-from mw@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 577233C98; Tue, 3 Apr 2018 23:49:36 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w33NnaPd043901; Tue, 3 Apr 2018 23:49:36 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w33NnaBD043897; Tue, 3 Apr 2018 23:49:36 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804032349.w33NnaBD043897@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Tue, 3 Apr 2018 23:49:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331966 - in head/sys: arm/mv dev/ahci X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys: arm/mv dev/ahci X-SVN-Commit-Revision: 331966 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2018 23:49:36 -0000 Author: mw Date: Tue Apr 3 23:49:35 2018 New Revision: 331966 URL: https://svnweb.freebsd.org/changeset/base/331966 Log: Fix kernel modules names for Marvell armv7 Two modules with the same name cannot be loaded, so Marvell specific drivers cannot have the same name as the generic drivers. Files with the same name, even in different folders overlaps their .o files, so in order to prepare for supporting Marvell platforms in GENERIC armv7 config, modify conflicting names. Submitted by: Rafal Kozik Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14743 Modified: head/sys/arm/mv/timer.c head/sys/dev/ahci/ahci_mv_fdt.c Modified: head/sys/arm/mv/timer.c ============================================================================== --- head/sys/arm/mv/timer.c Tue Apr 3 23:29:34 2018 (r331965) +++ head/sys/arm/mv/timer.c Tue Apr 3 23:49:35 2018 (r331966) @@ -289,7 +289,7 @@ static driver_t mv_timer_driver = { static devclass_t mv_timer_devclass; -DRIVER_MODULE(timer, simplebus, mv_timer_driver, mv_timer_devclass, 0, 0); +DRIVER_MODULE(timer_mv, simplebus, mv_timer_driver, mv_timer_devclass, 0, 0); static unsigned mv_timer_get_timecount(struct timecounter *tc) Modified: head/sys/dev/ahci/ahci_mv_fdt.c ============================================================================== --- head/sys/dev/ahci/ahci_mv_fdt.c Tue Apr 3 23:29:34 2018 (r331965) +++ head/sys/dev/ahci/ahci_mv_fdt.c Tue Apr 3 23:49:35 2018 (r331966) @@ -151,5 +151,5 @@ static driver_t ahci_driver = { sizeof(struct ahci_controller) }; -DRIVER_MODULE(ahci, simplebus, ahci_driver, ahci_devclass, NULL, NULL); -DRIVER_MODULE(ahci, ofwbus, ahci_driver, ahci_devclass, NULL, NULL); +DRIVER_MODULE(ahci_mv, simplebus, ahci_driver, ahci_devclass, NULL, NULL); +DRIVER_MODULE(ahci_mv, ofwbus, ahci_driver, ahci_devclass, NULL, NULL); From owner-svn-src-head@freebsd.org Wed Apr 4 00:13:16 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5EACDF8BED6 for ; Wed, 4 Apr 2018 00:13:16 +0000 (UTC) (envelope-from mw@semihalf.com) Received: from mail-io0-x236.google.com (mail-io0-x236.google.com [IPv6:2607:f8b0:4001:c06::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E14D07D3C9 for ; Wed, 4 Apr 2018 00:13:15 +0000 (UTC) (envelope-from mw@semihalf.com) Received: by mail-io0-x236.google.com with SMTP id o4so24165206iod.3 for ; Tue, 03 Apr 2018 17:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=gMqgXI+Gv2rwY6XN7JuqkPNWwxaPZ0JuWZ/aKiTSwks=; b=2Iz7lentGiodLKx8O1huT0V8GccX7F9iOw1ip7h0inGVya+RgPGYOLyF8EM574xjOo FYf5Epvicu9X52Ofbre2jGioMrpJFa7agKh/VJI5KJ8ul7XDbQnklDkMmOWGa9Nm6pFV eLOuIYpC+pAKBNnlvGAKYP50Ozzp4meEjWerPBO3pSSrmWsD09vJWHf4S5/oH/+OAtsP YSo09mzirWPzwaaIJOOCDhbpY/Wrj+GhnPu71QdNFrTBV0AIY35iqXPd8j9JAQe3qneb 3MkZzjB8MXSVP85JF8nVVRUge7+n8vs4UKotp1UaLNS/liqk/Bi5Tgve1zVLXRUsaUF2 ZBnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=gMqgXI+Gv2rwY6XN7JuqkPNWwxaPZ0JuWZ/aKiTSwks=; b=SG0rJudZ2A/DzW+YMHZijsp7R4OuvHeL8E+pVlfRPs2a1hudrKlQ0GrChQ93PrcBlZ 0aeUGRyjYi/fO599SUGcbGhDSdTNkdVBuG+uCauDAlehx2XCmT9T4GdegAiR91z4FC5c Oa3O6PuwhKpCue+WFheEr6T6y27rNej18q9UkJ3XjOHFo+Aw6oPOhqCqoxS53E4AV7xa CW0KzYi5gxQOIzeLZDMjUigBjTanEdT+prV0c87VYlEU90mX8j7q98J+CqEamK1v+MIC PiKi0xwtpxVDQENam9Qht1VwzgFQwQU9Iv20JChXjc4WScoX/Noa9uEe5oD4iJWYwWEm uMfA== X-Gm-Message-State: AElRT7EUdWbwcvL32BRz929NfqiP6pQaplM4N6wUvz3ZWVz0Njb3YIHY 3pq5QIAGoqTXKtFGO3DhRTSigLZd50yYYruhwrPBEA== X-Google-Smtp-Source: AIpwx49+9tp8DdYPr8CyET+uh/9zmm7M5GgbsXSHibP+Y0z1DADa1uW1Z8M61QB6SC6149xnn/FpzJISevMlqAi1cis= X-Received: by 10.107.135.157 with SMTP id r29mr14130602ioi.248.1522800795145; Tue, 03 Apr 2018 17:13:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.183.206 with HTTP; Tue, 3 Apr 2018 17:13:14 -0700 (PDT) In-Reply-To: <5dea78be118fa5ee4b8cb77a1e26a6f0@megadrive.org> References: <201804032221.w33MLDTE019502@repo.freebsd.org> <5dea78be118fa5ee4b8cb77a1e26a6f0@megadrive.org> From: Marcin Wojtas Date: Wed, 4 Apr 2018 02:13:14 +0200 Message-ID: Subject: Re: svn commit: r331961 - in head/sys: arm/mv dts/arm To: Emmanuel Vadot Cc: Marcin Wojtas , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org, owner-src-committers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 00:13:16 -0000 Hi Manu, 2018-04-04 0:28 GMT+02:00 Emmanuel Vadot : > On 2018-04-04 00:21, Marcin Wojtas wrote: >> >> Author: mw >> Date: Tue Apr 3 22:21:12 2018 >> New Revision: 331961 >> URL: https://svnweb.freebsd.org/changeset/base/331961 >> >> Log: >> Make Marvell AmadaXP timer driver more generic >> >> Store pointers to SoC specific functions in mv_timer_config structure >> and determine proper config in runtime based on compatible string from >> FDT. >> Compatible string for ArmadaXP timers is changed to match Linux FDT. >> Armada 38x uses generic Cortex-A9 timer and separate watchdog drivers, >> so >> it does not need to be supported by timer driver. >> >> Submitted by: Rafal Kozik >> Reviewed by: manu >> Obtained from: Semihalf >> Sponsored by: Stormshield >> Differential Revision: https://reviews.freebsd.org/D14741 > > > Hello Marcin, > > I've only reviewed the DTS part. Right, forgot to add note - sorry. > Also you didn't address andrew@ comment, see > https://reviews.freebsd.org/D14741?id=40452#inline-89719 > I took the wrong patch version initially (it was fixed in phabricator long time ago). I applied this improvemnet in r331965. Thanks, Marcin From owner-svn-src-head@freebsd.org Wed Apr 4 01:13:29 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E23F4F82A8D; Wed, 4 Apr 2018 01:13:28 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 94FF67F711; Wed, 4 Apr 2018 01:13:28 +0000 (UTC) (envelope-from gonzo@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 8FF404BEF; Wed, 4 Apr 2018 01:13:28 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w341DSqN062286; Wed, 4 Apr 2018 01:13:28 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w341DSZk062285; Wed, 4 Apr 2018 01:13:28 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201804040113.w341DSZk062285@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 4 Apr 2018 01:13:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331967 - head/sys/arm64/arm64 X-SVN-Group: head X-SVN-Commit-Author: gonzo X-SVN-Commit-Paths: head/sys/arm64/arm64 X-SVN-Commit-Revision: 331967 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 01:13:29 -0000 Author: gonzo Date: Wed Apr 4 01:13:28 2018 New Revision: 331967 URL: https://svnweb.freebsd.org/changeset/base/331967 Log: Fix arm64 buildkernel target with "nooptions KDB" Make kdb_trap in breakpoint exception handler conditional. If "options KDB" is not present just panic with message that debugger is not enabled. PR: 224653 Modified: head/sys/arm64/arm64/trap.c Modified: head/sys/arm64/arm64/trap.c ============================================================================== --- head/sys/arm64/arm64/trap.c Tue Apr 3 23:49:35 2018 (r331966) +++ head/sys/arm64/arm64/trap.c Wed Apr 4 01:13:28 2018 (r331967) @@ -323,8 +323,12 @@ do_el1h_sync(struct thread *td, struct trapframe *fram break; } #endif +#ifdef KDB kdb_trap(exception, 0, (td->td_frame != NULL) ? td->td_frame : frame); +#else + panic("No debugger in kernel.\n"); +#endif frame->tf_elr += 4; break; case EXCP_WATCHPT_EL1: From owner-svn-src-head@freebsd.org Wed Apr 4 02:00:11 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 84DA0F857DD; Wed, 4 Apr 2018 02:00:11 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 338D181599; Wed, 4 Apr 2018 02:00:11 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2A0A6526D; Wed, 4 Apr 2018 02:00:11 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3420AmP022519; Wed, 4 Apr 2018 02:00:10 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3420AC3022518; Wed, 4 Apr 2018 02:00:10 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201804040200.w3420AC3022518@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Wed, 4 Apr 2018 02:00:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331969 - head/include X-SVN-Group: head X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: head/include X-SVN-Commit-Revision: 331969 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 02:00:11 -0000 Author: pfg Date: Wed Apr 4 02:00:10 2018 New Revision: 331969 URL: https://svnweb.freebsd.org/changeset/base/331969 Log: pthread.h: drop nullability attributes. These have been found to be practically useless. We were actually following the Android bionic library and had some interest in replicating the same warnings and behaviour but Android has since removed them. We are still keeping some uses of nullability attributes in other headers, somewhat in line with Apple's libc. MFC after: 1 week Hinted by: bionic (git 3f66e74b903905e763e104396aff52a81718cfde) Modified: head/include/pthread.h Modified: head/include/pthread.h ============================================================================== --- head/include/pthread.h Wed Apr 4 01:56:46 2018 (r331968) +++ head/include/pthread.h Wed Apr 4 02:00:10 2018 (r331969) @@ -48,8 +48,6 @@ #include #include -__NULLABILITY_PRAGMA_PUSH - /* * Run-time invariant values: */ @@ -151,34 +149,33 @@ struct _pthread_cleanup_info { */ __BEGIN_DECLS int pthread_atfork(void (*)(void), void (*)(void), void (*)(void)); -int pthread_attr_destroy(pthread_attr_t * _Nonnull); +int pthread_attr_destroy(pthread_attr_t *); int pthread_attr_getstack( - const pthread_attr_t * _Nonnull __restrict, - void ** _Nonnull __restrict, - size_t * _Nonnull __restrict); -int pthread_attr_getstacksize(const pthread_attr_t * _Nonnull, - size_t * _Nonnull); -int pthread_attr_getguardsize(const pthread_attr_t * _Nonnull, - size_t * _Nonnull); + const pthread_attr_t * __restrict, void ** __restrict, + size_t * __restrict); +int pthread_attr_getstacksize(const pthread_attr_t *, + size_t *); +int pthread_attr_getguardsize(const pthread_attr_t *, + size_t *); int pthread_attr_getstackaddr(const pthread_attr_t *, void **); -int pthread_attr_getdetachstate(const pthread_attr_t * _Nonnull, - int * _Nonnull); -int pthread_attr_init(pthread_attr_t * _Nonnull); -int pthread_attr_setstacksize(pthread_attr_t * _Nonnull, size_t); -int pthread_attr_setguardsize(pthread_attr_t * _Nonnull, size_t); -int pthread_attr_setstack(pthread_attr_t * _Nonnull, void *, +int pthread_attr_getdetachstate(const pthread_attr_t *, + int *); +int pthread_attr_init(pthread_attr_t *); +int pthread_attr_setstacksize(pthread_attr_t *, size_t); +int pthread_attr_setguardsize(pthread_attr_t *, size_t); +int pthread_attr_setstack(pthread_attr_t *, void *, size_t); int pthread_attr_setstackaddr(pthread_attr_t *, void *); -int pthread_attr_setdetachstate(pthread_attr_t * _Nonnull, int); -int pthread_barrier_destroy(pthread_barrier_t * _Nonnull); -int pthread_barrier_init(pthread_barrier_t * _Nonnull, +int pthread_attr_setdetachstate(pthread_attr_t *, int); +int pthread_barrier_destroy(pthread_barrier_t *); +int pthread_barrier_init(pthread_barrier_t *, const pthread_barrierattr_t *, unsigned); -int pthread_barrier_wait(pthread_barrier_t * _Nonnull); -int pthread_barrierattr_destroy(pthread_barrierattr_t * _Nonnull); +int pthread_barrier_wait(pthread_barrier_t *); +int pthread_barrierattr_destroy(pthread_barrierattr_t *); int pthread_barrierattr_getpshared( - const pthread_barrierattr_t * _Nonnull, int * _Nonnull); -int pthread_barrierattr_init(pthread_barrierattr_t * _Nonnull); -int pthread_barrierattr_setpshared(pthread_barrierattr_t * _Nonnull, + const pthread_barrierattr_t *, int *); +int pthread_barrierattr_init(pthread_barrierattr_t *); +int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int); #define pthread_cleanup_push(cleanup_routine, cleanup_arg) \ @@ -194,108 +191,107 @@ int pthread_barrierattr_setpshared(pthread_barrieratt __pthread_cleanup_pop_imp(execute); \ } -int pthread_condattr_destroy(pthread_condattr_t * _Nonnull); -int pthread_condattr_getclock(const pthread_condattr_t * _Nonnull, - clockid_t * _Nonnull); -int pthread_condattr_getpshared(const pthread_condattr_t * _Nonnull, - int * _Nonnull); -int pthread_condattr_init(pthread_condattr_t * _Nonnull); -int pthread_condattr_setclock(pthread_condattr_t * _Nonnull, +int pthread_condattr_destroy(pthread_condattr_t *); +int pthread_condattr_getclock(const pthread_condattr_t *, + clockid_t *); +int pthread_condattr_getpshared(const pthread_condattr_t *, + int *); +int pthread_condattr_init(pthread_condattr_t *); +int pthread_condattr_setclock(pthread_condattr_t *, clockid_t); -int pthread_condattr_setpshared(pthread_condattr_t * _Nonnull, int); -int pthread_cond_broadcast(pthread_cond_t * _Nonnull); -int pthread_cond_destroy(pthread_cond_t * _Nonnull); -int pthread_cond_init(pthread_cond_t * _Nonnull, +int pthread_condattr_setpshared(pthread_condattr_t *, int); +int pthread_cond_broadcast(pthread_cond_t *); +int pthread_cond_destroy(pthread_cond_t *); +int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *); -int pthread_cond_signal(pthread_cond_t * _Nonnull); -int pthread_cond_timedwait(pthread_cond_t * _Nonnull, - pthread_mutex_t * _Nonnull __mutex, - const struct timespec * _Nonnull) +int pthread_cond_signal(pthread_cond_t *); +int pthread_cond_timedwait(pthread_cond_t *, + pthread_mutex_t * __mutex, + const struct timespec *) __requires_exclusive(*__mutex); -int pthread_cond_wait(pthread_cond_t * _Nonnull, - pthread_mutex_t * _Nonnull __mutex) +int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t * __mutex) __requires_exclusive(*__mutex); -int pthread_create(pthread_t * _Nonnull, const pthread_attr_t *, - void *(* _Nonnull) (void *), void *); +int pthread_create(pthread_t *, const pthread_attr_t *, + void *(*) (void *), void *); int pthread_detach(pthread_t); int pthread_equal(pthread_t, pthread_t); void pthread_exit(void *) __dead2; void *pthread_getspecific(pthread_key_t); -int pthread_getcpuclockid(pthread_t, clockid_t * _Nonnull); +int pthread_getcpuclockid(pthread_t, clockid_t *); int pthread_join(pthread_t, void **); -int pthread_key_create(pthread_key_t * _Nonnull, +int pthread_key_create(pthread_key_t *, void (*) (void *)); int pthread_key_delete(pthread_key_t); -int pthread_mutexattr_init(pthread_mutexattr_t * _Nonnull); -int pthread_mutexattr_destroy(pthread_mutexattr_t * _Nonnull); +int pthread_mutexattr_init(pthread_mutexattr_t *); +int pthread_mutexattr_destroy(pthread_mutexattr_t *); int pthread_mutexattr_getpshared( - const pthread_mutexattr_t * _Nonnull, int * _Nonnull); -int pthread_mutexattr_gettype(pthread_mutexattr_t * _Nonnull, - int * _Nonnull); -int pthread_mutexattr_settype(pthread_mutexattr_t * _Nonnull, int); -int pthread_mutexattr_setpshared(pthread_mutexattr_t * _Nonnull, + const pthread_mutexattr_t *, int *); +int pthread_mutexattr_gettype(pthread_mutexattr_t *, + int *); +int pthread_mutexattr_settype(pthread_mutexattr_t *, int); +int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int); -int pthread_mutex_consistent(pthread_mutex_t * _Nonnull __mutex) +int pthread_mutex_consistent(pthread_mutex_t * __mutex) __requires_exclusive(*__mutex); -int pthread_mutex_destroy(pthread_mutex_t * _Nonnull __mutex) +int pthread_mutex_destroy(pthread_mutex_t * __mutex) __requires_unlocked(*__mutex); -int pthread_mutex_init(pthread_mutex_t * _Nonnull __mutex, +int pthread_mutex_init(pthread_mutex_t * __mutex, const pthread_mutexattr_t *) __requires_unlocked(*__mutex); -int pthread_mutex_lock(pthread_mutex_t * _Nonnull __mutex) +int pthread_mutex_lock(pthread_mutex_t * __mutex) __locks_exclusive(*__mutex); -int pthread_mutex_trylock(pthread_mutex_t * _Nonnull __mutex) +int pthread_mutex_trylock(pthread_mutex_t * __mutex) __trylocks_exclusive(0, *__mutex); -int pthread_mutex_timedlock(pthread_mutex_t * _Nonnull __mutex, - const struct timespec * _Nonnull) +int pthread_mutex_timedlock(pthread_mutex_t * __mutex, + const struct timespec *) __trylocks_exclusive(0, *__mutex); -int pthread_mutex_unlock(pthread_mutex_t * _Nonnull __mutex) +int pthread_mutex_unlock(pthread_mutex_t * __mutex) __unlocks(*__mutex); -int pthread_once(pthread_once_t * _Nonnull, - void (* _Nonnull) (void)); -int pthread_rwlock_destroy(pthread_rwlock_t * _Nonnull __rwlock) +int pthread_once(pthread_once_t *, + void (*) (void)); +int pthread_rwlock_destroy(pthread_rwlock_t * __rwlock) __requires_unlocked(*__rwlock); -int pthread_rwlock_init(pthread_rwlock_t * _Nonnull __rwlock, +int pthread_rwlock_init(pthread_rwlock_t * __rwlock, const pthread_rwlockattr_t *) __requires_unlocked(*__rwlock); -int pthread_rwlock_rdlock(pthread_rwlock_t * _Nonnull __rwlock) +int pthread_rwlock_rdlock(pthread_rwlock_t * __rwlock) __locks_shared(*__rwlock); -int pthread_rwlock_timedrdlock(pthread_rwlock_t * _Nonnull __rwlock, - const struct timespec * _Nonnull) +int pthread_rwlock_timedrdlock(pthread_rwlock_t * __rwlock, + const struct timespec *) __trylocks_shared(0, *__rwlock); -int pthread_rwlock_timedwrlock(pthread_rwlock_t * _Nonnull __rwlock, - const struct timespec * _Nonnull) +int pthread_rwlock_timedwrlock(pthread_rwlock_t * __rwlock, + const struct timespec *) __trylocks_exclusive(0, *__rwlock); -int pthread_rwlock_tryrdlock(pthread_rwlock_t * _Nonnull __rwlock) +int pthread_rwlock_tryrdlock(pthread_rwlock_t * __rwlock) __trylocks_shared(0, *__rwlock); -int pthread_rwlock_trywrlock(pthread_rwlock_t * _Nonnull __rwlock) +int pthread_rwlock_trywrlock(pthread_rwlock_t * __rwlock) __trylocks_exclusive(0, *__rwlock); -int pthread_rwlock_unlock(pthread_rwlock_t * _Nonnull __rwlock) +int pthread_rwlock_unlock(pthread_rwlock_t * __rwlock) __unlocks(*__rwlock); -int pthread_rwlock_wrlock(pthread_rwlock_t * _Nonnull __rwlock) +int pthread_rwlock_wrlock(pthread_rwlock_t * __rwlock) __locks_exclusive(*__rwlock); -int pthread_rwlockattr_destroy(pthread_rwlockattr_t * _Nonnull); +int pthread_rwlockattr_destroy(pthread_rwlockattr_t *); int pthread_rwlockattr_getkind_np( - const pthread_rwlockattr_t * _Nonnull, int *); + const pthread_rwlockattr_t *, int *); int pthread_rwlockattr_getpshared( - const pthread_rwlockattr_t * _Nonnull, int * _Nonnull); -int pthread_rwlockattr_init(pthread_rwlockattr_t * _Nonnull); -int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t * _Nonnull, + const pthread_rwlockattr_t *, int *); +int pthread_rwlockattr_init(pthread_rwlockattr_t *); +int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *, int); -int pthread_rwlockattr_setpshared(pthread_rwlockattr_t * _Nonnull, +int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int); pthread_t pthread_self(void); int pthread_setspecific(pthread_key_t, const void *); -int pthread_spin_init(pthread_spinlock_t * _Nonnull __spin, int) +int pthread_spin_init(pthread_spinlock_t * __spin, int) __requires_unlocked(*__spin); -int pthread_spin_destroy(pthread_spinlock_t * _Nonnull __spin) +int pthread_spin_destroy(pthread_spinlock_t * __spin) __requires_unlocked(*__spin); -int pthread_spin_lock(pthread_spinlock_t * _Nonnull __spin) +int pthread_spin_lock(pthread_spinlock_t * __spin) __locks_exclusive(*__spin); -int pthread_spin_trylock(pthread_spinlock_t * _Nonnull __spin) +int pthread_spin_trylock(pthread_spinlock_t * __spin) __trylocks_exclusive(0, *__spin); -int pthread_spin_unlock(pthread_spinlock_t * _Nonnull __spin) +int pthread_spin_unlock(pthread_spinlock_t * __spin) __unlocks(*__spin); int pthread_cancel(pthread_t); int pthread_setcancelstate(int, int *); @@ -317,27 +313,26 @@ int pthread_mutexattr_getprotocol(pthread_mutexattr_t int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int); int pthread_mutexattr_getrobust( - pthread_mutexattr_t * _Nonnull __restrict, - int * _Nonnull __restrict); -int pthread_mutexattr_setrobust(pthread_mutexattr_t * _Nonnull, + pthread_mutexattr_t * __restrict, int * __restrict); +int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int); int pthread_attr_getinheritsched(const pthread_attr_t *, int *); -int pthread_attr_getschedparam(const pthread_attr_t * _Nonnull, - struct sched_param * _Nonnull); -int pthread_attr_getschedpolicy(const pthread_attr_t * _Nonnull, - int * _Nonnull); -int pthread_attr_getscope(const pthread_attr_t * _Nonnull, - int * _Nonnull); +int pthread_attr_getschedparam(const pthread_attr_t *, + struct sched_param *); +int pthread_attr_getschedpolicy(const pthread_attr_t *, + int *); +int pthread_attr_getscope(const pthread_attr_t *, + int *); int pthread_attr_setinheritsched(pthread_attr_t *, int); -int pthread_attr_setschedparam(pthread_attr_t * _Nonnull, - const struct sched_param * _Nonnull); -int pthread_attr_setschedpolicy(pthread_attr_t * _Nonnull, int); -int pthread_attr_setscope(pthread_attr_t * _Nonnull, int); -int pthread_getschedparam(pthread_t pthread, int * _Nonnull, - struct sched_param * _Nonnull); +int pthread_attr_setschedparam(pthread_attr_t *, + const struct sched_param *); +int pthread_attr_setschedpolicy(pthread_attr_t *, int); +int pthread_attr_setscope(pthread_attr_t *, int); +int pthread_getschedparam(pthread_t pthread, int *, + struct sched_param *); int pthread_setschedparam(pthread_t, int, - const struct sched_param * _Nonnull); + const struct sched_param *); #if __XSI_VISIBLE int pthread_getconcurrency(void); int pthread_setconcurrency(int); @@ -347,6 +342,5 @@ void __pthread_cleanup_push_imp(void (*)(void *), voi struct _pthread_cleanup_info *); void __pthread_cleanup_pop_imp(int); __END_DECLS -__NULLABILITY_PRAGMA_POP #endif /* !_PTHREAD_H_ */ From owner-svn-src-head@freebsd.org Wed Apr 4 02:13:28 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B9C3F863E7; Wed, 4 Apr 2018 02:13:28 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D299481EAF; Wed, 4 Apr 2018 02:13:27 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CD6F155A5; Wed, 4 Apr 2018 02:13:27 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w342DRhs043971; Wed, 4 Apr 2018 02:13:27 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w342DRG8043970; Wed, 4 Apr 2018 02:13:27 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201804040213.w342DRG8043970@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 4 Apr 2018 02:13:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331970 - head/sys/powerpc/booke X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/powerpc/booke X-SVN-Commit-Revision: 331970 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 02:13:28 -0000 Author: jhibbits Date: Wed Apr 4 02:13:27 2018 New Revision: 331970 URL: https://svnweb.freebsd.org/changeset/base/331970 Log: Correct the ilog2() for calculating memory sizes. TLB1 can handle ranges up to 4GB (through e5500, larger in e6500), but ilog2() took a unsigned int, which maxes out at 4GB-1, but truncates silently. Increase the input range to the largest supported, at least for 64-bit targets. This lets the DMAP be completely mapped, instead of only 1GB blocks with it assuming being fully mapped. Modified: head/sys/powerpc/booke/pmap.c Modified: head/sys/powerpc/booke/pmap.c ============================================================================== --- head/sys/powerpc/booke/pmap.c Wed Apr 4 02:00:10 2018 (r331969) +++ head/sys/powerpc/booke/pmap.c Wed Apr 4 02:13:27 2018 (r331970) @@ -234,7 +234,7 @@ static vm_size_t tlb1_mapin_region(vm_offset_t, vm_pad static vm_size_t tsize2size(unsigned int); static unsigned int size2tsize(vm_size_t); -static unsigned int ilog2(unsigned int); +static unsigned int ilog2(unsigned long); static void set_mas4_defaults(void); @@ -4020,12 +4020,17 @@ tlb1_write_entry(tlb_entry_t *e, unsigned int idx) * Return the largest uint value log such that 2^log <= num. */ static unsigned int -ilog2(unsigned int num) +ilog2(unsigned long num) { - int lz; + long lz; +#ifdef __powerpc64__ + __asm ("cntlzd %0, %1" : "=r" (lz) : "r" (num)); + return (63 - lz); +#else __asm ("cntlzw %0, %1" : "=r" (lz) : "r" (num)); return (31 - lz); +#endif } /* @@ -4163,7 +4168,8 @@ tlb1_mapin_region(vm_offset_t va, vm_paddr_t pa, vm_si for (idx = 0; idx < nents; idx++) { pgsz = pgs[idx]; - debugf("%u: %llx -> %x, size=%x\n", idx, pa, va, pgsz); + debugf("%u: %llx -> %jx, size=%jx\n", idx, pa, + (uintmax_t)va, (uintmax_t)pgsz); tlb1_set_entry(va, pa, pgsz, _TLB_ENTRY_SHARED | _TLB_ENTRY_MEM); pa += pgsz; From owner-svn-src-head@freebsd.org Wed Apr 4 02:35:49 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7192AF87A58; Wed, 4 Apr 2018 02:35:49 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1F32A833B9; Wed, 4 Apr 2018 02:35:49 +0000 (UTC) (envelope-from imp@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 11E6158F1; Wed, 4 Apr 2018 02:35:49 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w342ZmkW073724; Wed, 4 Apr 2018 02:35:48 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w342ZmEb073723; Wed, 4 Apr 2018 02:35:48 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201804040235.w342ZmEb073723@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Wed, 4 Apr 2018 02:35:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331975 - head/sys/sys X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/sys X-SVN-Commit-Revision: 331975 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 02:35:49 -0000 Author: imp Date: Wed Apr 4 02:35:48 2018 New Revision: 331975 URL: https://svnweb.freebsd.org/changeset/base/331975 Log: Fix minor whitespace nits Modified: head/sys/sys/module.h Modified: head/sys/sys/module.h ============================================================================== --- head/sys/sys/module.h Wed Apr 4 02:31:14 2018 (r331974) +++ head/sys/sys/module.h Wed Apr 4 02:35:48 2018 (r331975) @@ -141,7 +141,7 @@ struct mod_pnp_match_info #define DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, maxver) \ MODULE_DEPEND(name, kernel, __FreeBSD_version, \ - __FreeBSD_version, maxver); \ + __FreeBSD_version, maxver); \ MODULE_METADATA(_md_##name, MDT_MODULE, &data, __XSTRING(name));\ SYSINIT(name##module, sub, order, module_register_init, &data); \ struct __hack @@ -156,7 +156,7 @@ struct mod_pnp_match_info * Use it for modules that use kernel interfaces that are not stable * even on STABLE/X branches. */ -#define DECLARE_MODULE_TIED(name, data, sub, order) \ +#define DECLARE_MODULE_TIED(name, data, sub, order) \ DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, __FreeBSD_version) #define MODULE_VERSION_CONCAT(module, version) _##module##_version From owner-svn-src-head@freebsd.org Wed Apr 4 02:37:06 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E54F2F87B41; Wed, 4 Apr 2018 02:37:05 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 98DEC83531; Wed, 4 Apr 2018 02:37:05 +0000 (UTC) (envelope-from imp@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 9315758F2; Wed, 4 Apr 2018 02:37:05 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w342b5t4074885; Wed, 4 Apr 2018 02:37:05 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w342b5EA074884; Wed, 4 Apr 2018 02:37:05 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201804040237.w342b5EA074884@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Wed, 4 Apr 2018 02:37:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331976 - head/sys/modules/cam X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/modules/cam X-SVN-Commit-Revision: 331976 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 02:37:06 -0000 Author: imp Date: Wed Apr 4 02:37:05 2018 New Revision: 331976 URL: https://svnweb.freebsd.org/changeset/base/331976 Log: Add nvme_da back. Now that it can co-exist in the kernel with nvd, add it back to the cam module. Sponsored by: Netflix Modified: head/sys/modules/cam/Makefile Modified: head/sys/modules/cam/Makefile ============================================================================== --- head/sys/modules/cam/Makefile Wed Apr 4 02:35:48 2018 (r331975) +++ head/sys/modules/cam/Makefile Wed Apr 4 02:37:05 2018 (r331976) @@ -46,6 +46,7 @@ SRCS+= ata_machdep.c SRCS+= ata_pmp.c SRCS+= nvme_all.c SRCS+= nvme_xpt.c +SRCS+= nvme_da.c EXPORT_SYMS= YES # XXX evaluate From owner-svn-src-head@freebsd.org Wed Apr 4 05:21:47 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1B45AF909E4; Wed, 4 Apr 2018 05:21:47 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BDB7489A65; Wed, 4 Apr 2018 05:21:46 +0000 (UTC) (envelope-from gordon@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 B87E174BF; Wed, 4 Apr 2018 05:21:46 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w345LkJJ092880; Wed, 4 Apr 2018 05:21:46 GMT (envelope-from gordon@FreeBSD.org) Received: (from gordon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w345LkiY092879; Wed, 4 Apr 2018 05:21:46 GMT (envelope-from gordon@FreeBSD.org) Message-Id: <201804040521.w345LkiY092879@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gordon set sender to gordon@FreeBSD.org using -f From: Gordon Tetlow Date: Wed, 4 Apr 2018 05:21:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331981 - head/sys/dev/vt X-SVN-Group: head X-SVN-Commit-Author: gordon X-SVN-Commit-Paths: head/sys/dev/vt X-SVN-Commit-Revision: 331981 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 05:21:47 -0000 Author: gordon Date: Wed Apr 4 05:21:46 2018 New Revision: 331981 URL: https://svnweb.freebsd.org/changeset/base/331981 Log: Limit glyph count in vtfont_load to avoid integer overflow. Invalid font data passed to PIO_VFONT can result in an integer overflow in glyphsize. Characters may then be drawn on the console using glyph map entries that point beyond the end of allocated glyph memory, resulting in a kernel memory disclosure. Submitted by: emaste Reported by: Dr. Silvio Cesare of InfoSect Security: CVE-2018-6917 Security: FreeBSD-SA-18:04.vt Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/vt/vt_font.c Modified: head/sys/dev/vt/vt_font.c ============================================================================== --- head/sys/dev/vt/vt_font.c Wed Apr 4 04:26:21 2018 (r331980) +++ head/sys/dev/vt/vt_font.c Wed Apr 4 05:21:46 2018 (r331981) @@ -44,6 +44,7 @@ static MALLOC_DEFINE(M_VTFONT, "vtfont", "vt font"); /* Some limits to prevent abnormal fonts from being loaded. */ #define VTFONT_MAXMAPPINGS 65536 +#define VTFONT_MAXGLYPHS 131072 #define VTFONT_MAXGLYPHSIZE 2097152 #define VTFONT_MAXDIMENSION 128 @@ -173,7 +174,8 @@ vtfont_load(vfnt_t *f, struct vt_font **ret) /* Make sure the dimensions are valid. */ if (f->width < 1 || f->height < 1) return (EINVAL); - if (f->width > VTFONT_MAXDIMENSION || f->height > VTFONT_MAXDIMENSION) + if (f->width > VTFONT_MAXDIMENSION || f->height > VTFONT_MAXDIMENSION || + f->glyph_count > VTFONT_MAXGLYPHS) return (E2BIG); /* Not too many mappings. */ From owner-svn-src-head@freebsd.org Wed Apr 4 06:44:25 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A4124F959E4; Wed, 4 Apr 2018 06:44:25 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 527D58E0E6; Wed, 4 Apr 2018 06:44:25 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4D78D10225; Wed, 4 Apr 2018 06:44:25 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w346iPPe096284; Wed, 4 Apr 2018 06:44:25 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w346iP57096283; Wed, 4 Apr 2018 06:44:25 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201804040644.w346iP57096283@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Wed, 4 Apr 2018 06:44:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331989 - head/sys/dev/extres/regulator X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/extres/regulator X-SVN-Commit-Revision: 331989 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 06:44:26 -0000 Author: manu Date: Wed Apr 4 06:44:24 2018 New Revision: 331989 URL: https://svnweb.freebsd.org/changeset/base/331989 Log: regulator: Disable unused regulator bootloaders such as u-boot might enable regulators, or simply regulators could be enabled by default by the PMIC, even if we don't have a driver for the device or subsystem. Disable unused regulators just before going to userland. A tunable hw.regulator.disable_unused is added to not disable them in case this causes problems on some board but the default behavior is to disable everything unused. I prefer to break thinks now and fix them rather than never switch to the case were we disable regulators. Tested on : Pine64-LTS (an idle board goes from ~0.33A to ~0.27A) Tested on : BananaPi M2 Differential Revision: https://reviews.freebsd.org/D14781 Modified: head/sys/dev/extres/regulator/regulator.c Modified: head/sys/dev/extres/regulator/regulator.c ============================================================================== --- head/sys/dev/extres/regulator/regulator.c Wed Apr 4 06:11:05 2018 (r331988) +++ head/sys/dev/extres/regulator/regulator.c Wed Apr 4 06:44:24 2018 (r331989) @@ -71,6 +71,7 @@ static int regnode_method_status(struct regnode *regno static int regnode_method_set_voltage(struct regnode *regnode, int min_uvolt, int max_uvolt, int *udelay); static int regnode_method_get_voltage(struct regnode *regnode, int *uvolt); +static void regulator_shutdown(void *dummy); /* * Regulator controller methods. @@ -150,6 +151,36 @@ SX_SYSINIT(regulator_topology, ®node_topo_lock, "Re #define REGNODE_SLOCK(_sc) sx_slock(&((_sc)->lock)) #define REGNODE_XLOCK(_sc) sx_xlock(&((_sc)->lock)) #define REGNODE_UNLOCK(_sc) sx_unlock(&((_sc)->lock)) + +SYSINIT(regulator_shutdown, SI_SUB_LAST, SI_ORDER_ANY, regulator_shutdown, + NULL); + +/* + * Disable unused regulator + * We run this function at SI_SUB_LAST which mean that every driver that needs + * regulator should have already enable them. + * All the remaining regulators should be those left enabled by the bootloader + * or enable by default by the PMIC. + */ +static void +regulator_shutdown(void *dummy) +{ + struct regnode *entry; + int disable = 1; + + REG_TOPO_SLOCK(); + TUNABLE_INT_FETCH("hw.regulator.disable_unused", &disable); + TAILQ_FOREACH(entry, ®node_list, reglist_link) { + if (entry->enable_cnt == 0 && + entry->std_param.always_on == 0 && disable) { + if (bootverbose) + printf("regulator: shuting down %s\n", + entry->name); + regnode_stop(entry, 0); + } + } + REG_TOPO_UNLOCK(); +} /* * sysctl handler From owner-svn-src-head@freebsd.org Wed Apr 4 08:40:51 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99025F9E5D2; Wed, 4 Apr 2018 08:40:51 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4C3706C686; Wed, 4 Apr 2018 08:40:51 +0000 (UTC) (envelope-from mw@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 4705A114A8; Wed, 4 Apr 2018 08:40:51 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w348epQn035139; Wed, 4 Apr 2018 08:40:51 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w348en4Y035106; Wed, 4 Apr 2018 08:40:49 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804040840.w348en4Y035106@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 4 Apr 2018 08:40:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331995 - in head/sys/arm: conf mv mv/armada38x mv/armadaxp X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys/arm: conf mv mv/armada38x mv/armadaxp X-SVN-Commit-Revision: 331995 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 08:40:52 -0000 Author: mw Date: Wed Apr 4 08:40:49 2018 New Revision: 331995 URL: https://svnweb.freebsd.org/changeset/base/331995 Log: Use PLATFORM for initializing Marvell ArmadaXP and Armada38X Spliting armv5 and armv7 machdep is necessary for adding Armada38X and ArmadaXP to GENERIC config. PLATFORM framework checks SOC type in FDT and will select proper initialization function implementation during runtime. Pointers to SoC specific implementation are stored in array of platform_method_t and provided to framework by FDT_PLATFORM_DEF macro. PLATFORM framework supports also reset function. To simplify implementation cpu_reset is moved from mv_common to armv5 and armv7 machdep. Armada38X and ArmadaXP share now common list of files, so resolve all dependencies as well. Submitted by: Rafal Kozik Marcin Wojtas Reviewed by: mw Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14744 Added: head/sys/arm/mv/armada38x/armada38x_pl310.h (contents, props changed) head/sys/arm/mv/armv5_machdep.c - copied, changed from r331994, head/sys/arm/mv/mv_machdep.c head/sys/arm/mv/mv_armv7_machdep.c (contents, props changed) Deleted: head/sys/arm/mv/mv_machdep.c Modified: head/sys/arm/conf/ARMADA38X head/sys/arm/conf/ARMADAXP head/sys/arm/mv/armada38x/armada38x_mp.c head/sys/arm/mv/armada38x/armada38x_pl310.c head/sys/arm/mv/armada38x/std.armada38x head/sys/arm/mv/armadaxp/armadaxp_mp.c head/sys/arm/mv/armadaxp/std.mv78x60 head/sys/arm/mv/files.arm7 head/sys/arm/mv/files.mv head/sys/arm/mv/mv_common.c head/sys/arm/mv/std-pj4b.mv Modified: head/sys/arm/conf/ARMADA38X ============================================================================== --- head/sys/arm/conf/ARMADA38X Wed Apr 4 08:39:59 2018 (r331994) +++ head/sys/arm/conf/ARMADA38X Wed Apr 4 08:40:49 2018 (r331995) @@ -48,9 +48,6 @@ device neta # PCI device pci -# RTC -device mv_rtc - # Interrupt controllers device gic options INTRNG @@ -95,6 +92,8 @@ device cryptodev # L2 Cache device pl310 + +options PLATFORM # FDT options FDT Modified: head/sys/arm/conf/ARMADAXP ============================================================================== --- head/sys/arm/conf/ARMADAXP Wed Apr 4 08:39:59 2018 (r331994) +++ head/sys/arm/conf/ARMADAXP Wed Apr 4 08:40:49 2018 (r331995) @@ -90,3 +90,5 @@ options FDT_DTB_STATIC makeoptions FDT_DTS_FILE=db78460.dts options INTRNG + +options PLATFORM Modified: head/sys/arm/mv/armada38x/armada38x_mp.c ============================================================================== --- head/sys/arm/mv/armada38x/armada38x_mp.c Wed Apr 4 08:39:59 2018 (r331994) +++ head/sys/arm/mv/armada38x/armada38x_mp.c Wed Apr 4 08:40:49 2018 (r331995) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -43,9 +44,11 @@ __FBSDID("$FreeBSD$"); #include "pmsu.h" -int cpu_reset_deassert(void); +static int cpu_reset_deassert(void); +void mv_a38x_platform_mp_setmaxid(platform_t plate); +void mv_a38x_platform_mp_start_ap(platform_t plate); -int +static int cpu_reset_deassert(void) { bus_space_handle_t vaddr; @@ -122,7 +125,7 @@ platform_cnt_cpus(void) } void -platform_mp_setmaxid(void) +mv_a38x_platform_mp_setmaxid(platform_t plate) { /* Armada38x family supports maximum 2 cores */ @@ -131,7 +134,7 @@ platform_mp_setmaxid(void) } void -platform_mp_start_ap(void) +mv_a38x_platform_mp_start_ap(platform_t plate) { int rv; Modified: head/sys/arm/mv/armada38x/armada38x_pl310.c ============================================================================== --- head/sys/arm/mv/armada38x/armada38x_pl310.c Wed Apr 4 08:39:59 2018 (r331994) +++ head/sys/arm/mv/armada38x/armada38x_pl310.c Wed Apr 4 08:40:49 2018 (r331995) @@ -40,9 +40,14 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include +#include "armada38x_pl310.h" +#include "platform_pl310_if.h" + void -platform_pl310_init(struct pl310_softc *sc) +mv_a38x_platform_pl310_init(platform_t plat, struct pl310_softc *sc) { uint32_t reg; @@ -63,14 +68,14 @@ platform_pl310_init(struct pl310_softc *sc) } void -platform_pl310_write_ctrl(struct pl310_softc *sc, uint32_t val) +mv_a38x_platform_pl310_write_ctrl(platform_t plat, struct pl310_softc *sc, uint32_t val) { pl310_write4(sc, PL310_CTRL, val); } void -platform_pl310_write_debug(struct pl310_softc *sc, uint32_t val) +mv_a38x_platform_pl310_write_debug(platform_t plat, struct pl310_softc *sc, uint32_t val) { pl310_write4(sc, PL310_DEBUG_CTRL, val); Added: head/sys/arm/mv/armada38x/armada38x_pl310.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm/mv/armada38x/armada38x_pl310.h Wed Apr 4 08:40:49 2018 (r331995) @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2017 Semihalf. + * Copyright (c) 2017 Stormshield. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef ARMADA38X_PL310_H +#define ARMADA38X_PL310_H +#include + +void mv_a38x_platform_pl310_init(platform_t plat, struct pl310_softc *sc); +void mv_a38x_platform_pl310_write_ctrl(platform_t plat, struct pl310_softc *sc, uint32_t val); +void mv_a38x_platform_pl310_write_debug(platform_t plat, struct pl310_softc *sc, uint32_t val); + +#endif Modified: head/sys/arm/mv/armada38x/std.armada38x ============================================================================== --- head/sys/arm/mv/armada38x/std.armada38x Wed Apr 4 08:39:59 2018 (r331994) +++ head/sys/arm/mv/armada38x/std.armada38x Wed Apr 4 08:40:49 2018 (r331995) @@ -1,6 +1,4 @@ # $FreeBSD$ -files "../mv/armada38x/files.armada38x" -files "../mv/files.mv" files "../mv/files.arm7" cpu CPU_CORTEXA machine arm armv7 Modified: head/sys/arm/mv/armadaxp/armadaxp_mp.c ============================================================================== --- head/sys/arm/mv/armadaxp/armadaxp_mp.c Wed Apr 4 08:39:59 2018 (r331994) +++ head/sys/arm/mv/armadaxp/armadaxp_mp.c Wed Apr 4 08:40:49 2018 (r331995) @@ -49,6 +49,8 @@ #include +#include + #define MV_AXP_CPU_DIVCLK_BASE (MV_BASE + 0x18700) #define CPU_DIVCLK_CTRL0 0x00 #define CPU_DIVCLK_CTRL2_RATIO_FULL0 0x08 @@ -66,6 +68,9 @@ void armadaxp_init_coher_fabric(void); int platform_get_ncpus(void); +void mv_axp_platform_mp_setmaxid(platform_t plat); +void mv_axp_platform_mp_start_ap(platform_t plat); + /* Coherency Fabric registers */ static uint32_t read_cpu_clkdiv(uint32_t reg) @@ -82,7 +87,7 @@ write_cpu_clkdiv(uint32_t reg, uint32_t val) } void -platform_mp_setmaxid(void) +mv_axp_platform_mp_setmaxid(platform_t plat) { mp_ncpus = platform_get_ncpus(); @@ -94,7 +99,7 @@ void mptramp_end(void); extern vm_offset_t mptramp_pmu_boot; void -platform_mp_start_ap(void) +mv_axp_platform_mp_start_ap(platform_t plat) { uint32_t reg, *src, *dst, cpu_num, div_val, cputype; vm_offset_t pmu_boot_off; Modified: head/sys/arm/mv/armadaxp/std.mv78x60 ============================================================================== --- head/sys/arm/mv/armadaxp/std.mv78x60 Wed Apr 4 08:39:59 2018 (r331994) +++ head/sys/arm/mv/armadaxp/std.mv78x60 Wed Apr 4 08:40:49 2018 (r331995) @@ -2,4 +2,3 @@ include "../mv/std-pj4b.mv" include "../mv/armadaxp/std.armadaxp" -files "../mv/armadaxp/files.armadaxp" Copied and modified: head/sys/arm/mv/armv5_machdep.c (from r331994, head/sys/arm/mv/mv_machdep.c) ============================================================================== --- head/sys/arm/mv/mv_machdep.c Wed Apr 4 08:39:59 2018 (r331994, copy source) +++ head/sys/arm/mv/armv5_machdep.c Wed Apr 4 08:40:49 2018 (r331995) @@ -61,12 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include -#if __ARM_ARCH < 6 #include -#else -#include -#include -#endif #include /* XXX */ #include /* XXX eventually this should be eliminated */ @@ -76,16 +71,7 @@ __FBSDID("$FreeBSD$"); #include static int platform_mpp_init(void); -#if defined(SOC_MV_ARMADAXP) -void armadaxp_init_coher_fabric(void); -void armadaxp_l2_init(void); -#endif -#if defined(SOC_MV_ARMADA38X) -int armada38x_win_set_iosync_barrier(void); -int armada38x_scu_enable(void); -int armada38x_open_bootrom_win(void); -int armada38x_mbus_optimization(void); -#endif +void cpu_reset(void); #define MPP_PIN_MAX 68 #define MPP_PIN_CELLS 2 @@ -291,46 +277,8 @@ platform_late_init(void) if (soc_decode_win() != 0) printf("WARNING: could not re-initialise decode windows! " "Running with existing settings...\n"); -#if defined(SOC_MV_ARMADAXP) -#if !defined(SMP) - /* For SMP case it should be initialized after APs are booted */ - armadaxp_init_coher_fabric(); -#endif - armadaxp_l2_init(); -#endif - -#if defined(SOC_MV_ARMADA38X) - /* Configure timers' base frequency */ - arm_tmr_change_frequency(get_cpu_freq() / 2); - - /* - * Workaround for Marvell Armada38X family HW issue - * between Cortex-A9 CPUs and on-chip devices that may - * cause hang on heavy load. - * To avoid that, map all registers including PCIe IO - * as strongly ordered instead of device memory. - */ - pmap_remap_vm_attr(VM_MEMATTR_DEVICE, VM_MEMATTR_SO); - - /* Set IO Sync Barrier bit for all Mbus devices */ - if (armada38x_win_set_iosync_barrier() != 0) - printf("WARNING: could not map CPU Subsystem registers\n"); - if (armada38x_mbus_optimization() != 0) - printf("WARNING: could not enable mbus optimization\n"); - if (armada38x_scu_enable() != 0) - printf("WARNING: could not enable SCU\n"); -#ifdef SMP - /* Open window to bootROM memory - needed for SMP */ - if (armada38x_open_bootrom_win() != 0) - printf("WARNING: could not open window to bootROM\n"); -#endif -#endif } -#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) -#define FDT_DEVMAP_MAX (MV_WIN_CPU_MAX_ARMV7 + 2) -#else #define FDT_DEVMAP_MAX (MV_WIN_CPU_MAX + 2) -#endif static struct devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = { { 0, 0, 0, } }; @@ -338,20 +286,19 @@ static struct devmap_entry fdt_devmap[FDT_DEVMAP_MAX] static int platform_sram_devmap(struct devmap_entry *map) { -#if !defined(SOC_MV_ARMADAXP) && !defined(SOC_MV_ARMADA38X) phandle_t child, root; u_long base, size; /* * SRAM range. */ + if ((root = OF_finddevice("/")) == 0) + return (ENXIO); + if ((child = OF_finddevice("/sram")) != 0) if (ofw_bus_node_is_compatible(child, "mrvl,cesa-sram") || ofw_bus_node_is_compatible(child, "mrvl,scratchpad")) goto moveon; - if ((root = OF_finddevice("/")) == 0) - return (ENXIO); - if ((child = fdt_find_compatible(root, "mrvl,cesa-sram", 0)) == 0 && (child = fdt_find_compatible(root, "mrvl,scratchpad", 0)) == 0) goto out; @@ -366,7 +313,6 @@ moveon: return (0); out: -#endif return (ENOENT); } @@ -408,20 +354,10 @@ platform_devmap_init(void) i = 0; devmap_register_table(&fdt_devmap[0]); -#ifdef SOC_MV_ARMADAXP - vm_paddr_t cur_immr_pa; + if ((root = OF_finddevice("/")) == -1) + return (ENXIO); /* - * Acquire SoC registers' base passed by u-boot and fill devmap - * accordingly. DTB is going to be modified basing on this data - * later. - */ - __asm __volatile("mrc p15, 4, %0, c15, c0, 0" : "=r" (cur_immr_pa)); - cur_immr_pa = (cur_immr_pa << 13) & 0xff000000; - if (cur_immr_pa != 0) - fdt_immr_pa = cur_immr_pa; -#endif - /* * IMMR range. */ fdt_devmap[i].pd_va = fdt_immr_va; @@ -440,8 +376,6 @@ platform_devmap_init(void) * PCI range(s). * PCI range(s) and localbus. */ - if ((root = OF_finddevice("/")) == -1) - return (ENXIO); for (child = OF_child(root); child != 0; child = OF_peer(child)) { if (fdt_is_type(child, "pci") || fdt_is_type(child, "pciep")) { /* @@ -485,7 +419,6 @@ platform_devmap_init(void) return (0); } -#if __ARM_ARCH < 6 struct arm32_dma_range * bus_dma_get_range(void) { @@ -499,9 +432,16 @@ bus_dma_get_range_nb(void) return (0); } -#endif -#if defined(CPU_MV_PJ4B) +void +cpu_reset(void) +{ + + write_cpu_ctrl(RSTOUTn_MASK, SOFT_RST_OUT_EN); + write_cpu_ctrl(SYSTEM_SOFT_RESET, SYS_SOFT_RST); + while(1); +} + #ifdef DDB #include @@ -557,5 +497,3 @@ DB_SHOW_COMMAND(vtop, db_show_vtop) db_printf("show vtop \n"); } #endif /* DDB */ -#endif /* CPU_MV_PJ4B */ - Modified: head/sys/arm/mv/files.arm7 ============================================================================== --- head/sys/arm/mv/files.arm7 Wed Apr 4 08:39:59 2018 (r331994) +++ head/sys/arm/mv/files.arm7 Wed Apr 4 08:40:49 2018 (r331995) @@ -1,3 +1,39 @@ # $FreeBSD$ arm/mv/armada38x/armada38x.c standard arm/mv/armadaxp/armadaxp.c standard + +arm/mv/gpio.c optional gpio +arm/mv/mv_common.c standard +arm/mv/mv_localbus.c standard +arm/mv/mv_armv7_machdep.c standard +arm/mv/mv_pci_ctrl.c optional pci | fdt +arm/mv/mv_pci.c optional pci +arm/mv/mv_ts.c standard +arm/mv/timer.c standard + +arm/mv/mpic.c standard +arm/mv/armada/thermal.c optional fdt +arm/mv/armada/wdt.c optional fdt +arm/mv/armada38x/armada38x_mp.c optional smp +arm/mv/armada38x/pmsu.c standard +arm/mv/armada38x/armada38x_rtc.c standard +arm/mv/armada38x/armada38x_pl310.c optional pl310 +dev/sdhci/sdhci_fdt.c optional sdhci + +arm/mv/rtc.c standard +arm/mv/armadaxp/armadaxp_mp.c optional smp +arm/mv/armadaxp/mptramp.S optional smp +dev/cesa/cesa.c optional cesa +dev/iicbus/twsi/mv_twsi.c optional twsi +dev/mge/if_mge.c optional mge +dev/neta/if_mvneta_fdt.c optional neta fdt +dev/neta/if_mvneta.c optional neta mdio mii +dev/nand/nfc_mv.c optional nand +dev/mvs/mvs_soc.c optional mvs +dev/uart/uart_dev_ns8250.c optional uart +dev/uart/uart_dev_snps.c optional uart +dev/usb/controller/ehci_mv.c optional ehci +dev/usb/controller/xhci_mv.c optional xhci +dev/ahci/ahci_mv_fdt.c optional ahci + +kern/kern_clocksource.c standard Modified: head/sys/arm/mv/files.mv ============================================================================== --- head/sys/arm/mv/files.mv Wed Apr 4 08:39:59 2018 (r331994) +++ head/sys/arm/mv/files.mv Wed Apr 4 08:40:49 2018 (r331995) @@ -15,7 +15,7 @@ arm/mv/gpio.c optional gpio arm/mv/mv_common.c standard arm/mv/mv_localbus.c standard -arm/mv/mv_machdep.c standard +arm/mv/armv5_machdep.c standard arm/mv/mv_pci_ctrl.c optional pci | fdt arm/mv/mv_pci.c optional pci arm/mv/mv_ts.c standard Added: head/sys/arm/mv/mv_armv7_machdep.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm/mv/mv_armv7_machdep.c Wed Apr 4 08:40:49 2018 (r331995) @@ -0,0 +1,482 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2017 Semihalf. + * Copyright (c) 1994-1998 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Brini. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI 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. + * + * from: FreeBSD: //depot/projects/arm/src/sys/arm/at91/kb920x_machdep.c, rev 45 + */ + +#include "opt_ddb.h" +#include "opt_platform.h" + +#include +__FBSDID("$FreeBSD$"); + +#define _ARM32_BUS_DMA_PRIVATE +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "opt_platform.h" +#include "platform_if.h" + +#if defined(SOC_MV_ARMADA38X) +#include "platform_pl310_if.h" +#include "armada38x/armada38x_pl310.h" +#endif + +static int platform_mpp_init(void); +int armada38x_win_set_iosync_barrier(void); +int armada38x_scu_enable(void); +int armada38x_open_bootrom_win(void); +int armada38x_mbus_optimization(void); + +static vm_offset_t mv_platform_lastaddr(platform_t plate); +static int mv_platform_probe_and_attach(platform_t plate); +static void mv_platform_gpio_init(platform_t plate); +static void mv_cpu_reset(platform_t plat); + +static void mv_a38x_platform_late_init(platform_t plate); +static int mv_a38x_platform_devmap_init(platform_t plate); +static void mv_axp_platform_late_init(platform_t plate); +static int mv_axp_platform_devmap_init(platform_t plate); + +void armadaxp_init_coher_fabric(void); +void armadaxp_l2_init(void); + +#ifdef SMP +void mv_a38x_platform_mp_setmaxid(platform_t plate); +void mv_a38x_platform_mp_start_ap(platform_t plate); +void mv_axp_platform_mp_setmaxid(platform_t plate); +void mv_axp_platform_mp_start_ap(platform_t plate); +#endif + +#define MPP_PIN_MAX 68 +#define MPP_PIN_CELLS 2 +#define MPP_PINS_PER_REG 8 +#define MPP_SEL(pin,func) (((func) & 0xf) << \ + (((pin) % MPP_PINS_PER_REG) * 4)) + +static void +mv_busdma_tag_init(void *arg __unused) +{ + phandle_t node; + bus_dma_tag_t dmat; + + /* + * If this platform has coherent DMA, create the parent DMA tag to pass + * down the coherent flag to all busses and devices on the platform, + * otherwise return without doing anything. By default create tag + * for all A38x-based platforms only. + */ + if ((node = OF_finddevice("/")) == -1){ + printf("no tree\n"); + return; + } + + if (ofw_bus_node_is_compatible(node, "marvell,armada380") == 0) + return; + + bus_dma_tag_create(NULL, /* No parent tag */ + 1, 0, /* alignment, bounds */ + BUS_SPACE_MAXADDR, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + BUS_SPACE_MAXSIZE, /* maxsize */ + BUS_SPACE_UNRESTRICTED, /* nsegments */ + BUS_SPACE_MAXSIZE, /* maxsegsize */ + BUS_DMA_COHERENT, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &dmat); + + nexus_set_dma_tag(dmat); + +} +SYSINIT(mv_busdma_tag, SI_SUB_DRIVERS, SI_ORDER_ANY, mv_busdma_tag_init, NULL); + +static int +platform_mpp_init(void) +{ + pcell_t pinmap[MPP_PIN_MAX * MPP_PIN_CELLS]; + int mpp[MPP_PIN_MAX]; + uint32_t ctrl_val, ctrl_offset; + pcell_t reg[4]; + u_long start, size; + phandle_t node; + pcell_t pin_cells, *pinmap_ptr, pin_count; + ssize_t len; + int par_addr_cells, par_size_cells; + int tuple_size, tuples, rv, pins, i, j; + int mpp_pin, mpp_function; + + /* + * Try to access the MPP node directly i.e. through /aliases/mpp. + */ + if ((node = OF_finddevice("mpp")) != -1) + if (ofw_bus_node_is_compatible(node, "mrvl,mpp")) + goto moveon; + /* + * Find the node the long way. + */ + if ((node = OF_finddevice("/")) == -1) + return (ENXIO); + + if ((node = fdt_find_compatible(node, "simple-bus", 0)) == 0) + return (ENXIO); + + if ((node = fdt_find_compatible(node, "mrvl,mpp", 0)) == 0) + /* + * No MPP node. Fall back to how MPP got set by the + * first-stage loader and try to continue booting. + */ + return (0); +moveon: + /* + * Process 'reg' prop. + */ + if ((rv = fdt_addrsize_cells(OF_parent(node), &par_addr_cells, + &par_size_cells)) != 0) + return(ENXIO); + + tuple_size = sizeof(pcell_t) * (par_addr_cells + par_size_cells); + len = OF_getprop(node, "reg", reg, sizeof(reg)); + tuples = len / tuple_size; + if (tuple_size <= 0) + return (EINVAL); + + rv = fdt_data_to_res(reg, par_addr_cells, par_size_cells, + &start, &size); + if (rv != 0) + return (rv); + start += fdt_immr_va; + + /* + * Process 'pin-count' and 'pin-map' props. + */ + if (OF_getencprop(node, "pin-count", &pin_count, sizeof(pin_count)) <= 0) + return (ENXIO); + if (pin_count > MPP_PIN_MAX) + return (ERANGE); + + if (OF_getencprop(node, "#pin-cells", &pin_cells, sizeof(pin_cells)) <= 0) + pin_cells = MPP_PIN_CELLS; + if (pin_cells > MPP_PIN_CELLS) + return (ERANGE); + tuple_size = sizeof(pcell_t) * pin_cells; + + bzero(pinmap, sizeof(pinmap)); + len = OF_getencprop(node, "pin-map", pinmap, sizeof(pinmap)); + if (len <= 0) + return (ERANGE); + if (len % tuple_size) + return (ERANGE); + pins = len / tuple_size; + if (pins > pin_count) + return (ERANGE); + /* + * Fill out a "mpp[pin] => function" table. All pins unspecified in + * the 'pin-map' property are defaulted to 0 function i.e. GPIO. + */ + bzero(mpp, sizeof(mpp)); + pinmap_ptr = pinmap; + for (i = 0; i < pins; i++) { + mpp_pin = *pinmap_ptr; + mpp_function = *(pinmap_ptr + 1); + mpp[mpp_pin] = mpp_function; + pinmap_ptr += pin_cells; + } + + /* + * Prepare and program MPP control register values. + */ + ctrl_offset = 0; + for (i = 0; i < pin_count;) { + ctrl_val = 0; + + for (j = 0; j < MPP_PINS_PER_REG; j++) { + if (i + j == pin_count - 1) + break; + ctrl_val |= MPP_SEL(i + j, mpp[i + j]); + } + i += MPP_PINS_PER_REG; + bus_space_write_4(fdtbus_bs_tag, start, ctrl_offset, + ctrl_val); + + ctrl_offset += 4; + } + + return (0); +} + +static vm_offset_t +mv_platform_lastaddr(platform_t plat) +{ + + return (fdt_immr_va); +} + +static int +mv_platform_probe_and_attach(platform_t plate) +{ + + if (fdt_immr_addr(MV_BASE) != 0) + while (1); + return (0); +} + +static void +mv_platform_gpio_init(platform_t plate) +{ + + /* + * Re-initialise MPP. It is important to call this prior to using + * console as the physical connection can be routed via MPP. + */ + if (platform_mpp_init() != 0) + while (1); +} + +static void +mv_a38x_platform_late_init(platform_t plate) +{ + + /* + * Re-initialise decode windows + */ + if (mv_check_soc_family() == MV_SOC_UNSUPPORTED) + panic("Unsupported SoC family\n"); + + if (soc_decode_win() != 0) + printf("WARNING: could not re-initialise decode windows! " + "Running with existing settings...\n"); + + /* Configure timers' base frequency */ + arm_tmr_change_frequency(get_cpu_freq() / 2); + + /* + * Workaround for Marvell Armada38X family HW issue + * between Cortex-A9 CPUs and on-chip devices that may + * cause hang on heavy load. + * To avoid that, map all registers including PCIe IO + * as strongly ordered instead of device memory. + */ + pmap_remap_vm_attr(VM_MEMATTR_DEVICE, VM_MEMATTR_SO); + + /* Set IO Sync Barrier bit for all Mbus devices */ + if (armada38x_win_set_iosync_barrier() != 0) + printf("WARNING: could not map CPU Subsystem registers\n"); + if (armada38x_mbus_optimization() != 0) + printf("WARNING: could not enable mbus optimization\n"); + if (armada38x_scu_enable() != 0) + printf("WARNING: could not enable SCU\n"); +#ifdef SMP + /* Open window to bootROM memory - needed for SMP */ + if (armada38x_open_bootrom_win() != 0) + printf("WARNING: could not open window to bootROM\n"); +#endif +} + +static void +mv_axp_platform_late_init(platform_t plate) +{ + phandle_t node; + /* + * Re-initialise decode windows + */ + if (soc_decode_win() != 0) + printf("WARNING: could not re-initialise decode windows! " + "Running with existing settings...\n"); + if ((node = OF_finddevice("/")) == -1) + return; + +#if !defined(SMP) + /* For SMP case it should be initialized after APs are booted */ + armadaxp_init_coher_fabric(); +#endif + armadaxp_l2_init(); +} + +#define FDT_DEVMAP_MAX (MV_WIN_CPU_MAX_ARMV7 + 2) +static struct devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = { + { 0, 0, 0, } +}; + +static int +platform_sram_devmap(struct devmap_entry *map) +{ + + return (ENOENT); +} + +/* + * Construct devmap table with DT-derived config data. + */ +static int +mv_a38x_platform_devmap_init(platform_t plat) +{ + phandle_t root, child; + int i; + + i = 0; + devmap_register_table(&fdt_devmap[0]); + + if ((root = OF_finddevice("/")) == -1) + return (ENXIO); + + /* + * IMMR range. + */ + fdt_devmap[i].pd_va = fdt_immr_va; + fdt_devmap[i].pd_pa = fdt_immr_pa; + fdt_devmap[i].pd_size = fdt_immr_size; + i++; + + /* + * SRAM range. + */ + if (i < FDT_DEVMAP_MAX) + if (platform_sram_devmap(&fdt_devmap[i]) == 0) + i++; + + /* + * PCI range(s). + * PCI range(s) and localbus. + */ + for (child = OF_child(root); child != 0; child = OF_peer(child)) { + if (fdt_is_type(child, "pci") || fdt_is_type(child, "pciep")) { + /* + * Check space: each PCI node will consume 2 devmap + * entries. + */ + if (i + 1 >= FDT_DEVMAP_MAX) + return (ENOMEM); + + if (mv_pci_devmap(child, &fdt_devmap[i], MV_PCI_VA_IO_BASE, + MV_PCI_VA_MEM_BASE) != 0) + return (ENXIO); + i += 2; + } + } + + return (0); +} + +static int +mv_axp_platform_devmap_init(platform_t plate) +{ + vm_paddr_t cur_immr_pa; + + /* + * Acquire SoC registers' base passed by u-boot and fill devmap + * accordingly. DTB is going to be modified basing on this data + * later. + */ + __asm __volatile("mrc p15, 4, %0, c15, c0, 0" : "=r" (cur_immr_pa)); + cur_immr_pa = (cur_immr_pa << 13) & 0xff000000; + if (cur_immr_pa != 0) + fdt_immr_pa = cur_immr_pa; + + mv_a38x_platform_devmap_init(plate); + + return (0); +} + +static void +mv_cpu_reset(platform_t plat) +{ + + write_cpu_misc(RSTOUTn_MASK, SOFT_RST_OUT_EN); + write_cpu_misc(SYSTEM_SOFT_RESET, SYS_SOFT_RST); +} + +#if defined(SOC_MV_ARMADA38X) +static platform_method_t mv_a38x_methods[] = { + PLATFORMMETHOD(platform_devmap_init, mv_a38x_platform_devmap_init), + PLATFORMMETHOD(platform_cpu_reset, mv_cpu_reset), + PLATFORMMETHOD(platform_lastaddr, mv_platform_lastaddr), + PLATFORMMETHOD(platform_attach, mv_platform_probe_and_attach), + PLATFORMMETHOD(platform_gpio_init, mv_platform_gpio_init), + PLATFORMMETHOD(platform_late_init, mv_a38x_platform_late_init), + PLATFORMMETHOD(platform_pl310_init, mv_a38x_platform_pl310_init), + PLATFORMMETHOD(platform_pl310_write_ctrl, mv_a38x_platform_pl310_write_ctrl), + PLATFORMMETHOD(platform_pl310_write_debug, mv_a38x_platform_pl310_write_debug), +#ifdef SMP + PLATFORMMETHOD(platform_mp_start_ap, mv_a38x_platform_mp_start_ap), + PLATFORMMETHOD(platform_mp_setmaxid, mv_a38x_platform_mp_setmaxid), +#endif + + PLATFORMMETHOD_END, +}; +FDT_PLATFORM_DEF(mv_a38x, "mv_a38x", 0, "marvell,armada380", 100); +#endif + +static platform_method_t mv_axp_methods[] = { + PLATFORMMETHOD(platform_devmap_init, mv_axp_platform_devmap_init), + PLATFORMMETHOD(platform_cpu_reset, mv_cpu_reset), + PLATFORMMETHOD(platform_lastaddr, mv_platform_lastaddr), + PLATFORMMETHOD(platform_attach, mv_platform_probe_and_attach), + PLATFORMMETHOD(platform_gpio_init, mv_platform_gpio_init), + PLATFORMMETHOD(platform_late_init, mv_axp_platform_late_init), +#ifdef SMP + PLATFORMMETHOD(platform_mp_start_ap, mv_axp_platform_mp_start_ap), + PLATFORMMETHOD(platform_mp_setmaxid, mv_axp_platform_mp_setmaxid), +#endif + + PLATFORMMETHOD_END, +}; +FDT_PLATFORM_DEF(mv_axp, "mv_axp", 0, "marvell,armadaxp", 100); + Modified: head/sys/arm/mv/mv_common.c ============================================================================== --- head/sys/arm/mv/mv_common.c Wed Apr 4 08:39:59 2018 (r331994) +++ head/sys/arm/mv/mv_common.c Wed Apr 4 08:40:49 2018 (r331995) @@ -588,20 +588,6 @@ write_cpu_misc(uint32_t reg, uint32_t val) bus_space_write_4(fdtbus_bs_tag, MV_MISC_BASE, reg, val); } -void -cpu_reset(void) -{ - -#if defined(SOC_MV_ARMADAXP) || defined (SOC_MV_ARMADA38X) - write_cpu_misc(RSTOUTn_MASK, SOFT_RST_OUT_EN); - write_cpu_misc(SYSTEM_SOFT_RESET, SYS_SOFT_RST); -#else - write_cpu_ctrl(RSTOUTn_MASK, SOFT_RST_OUT_EN); - write_cpu_ctrl(SYSTEM_SOFT_RESET, SYS_SOFT_RST); -#endif - while (1); -} - uint32_t cpu_extra_feat(void) { Modified: head/sys/arm/mv/std-pj4b.mv ============================================================================== --- head/sys/arm/mv/std-pj4b.mv Wed Apr 4 08:39:59 2018 (r331994) +++ head/sys/arm/mv/std-pj4b.mv Wed Apr 4 08:40:49 2018 (r331995) @@ -1,6 +1,5 @@ # $FreeBSD$ -files "../mv/files.mv" files "../mv/files.arm7" cpu CPU_MV_PJ4B machine arm armv7 From owner-svn-src-head@freebsd.org Wed Apr 4 10:14:44 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A1DB8F80CA6; Wed, 4 Apr 2018 10:14:44 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4C9CF7091F; Wed, 4 Apr 2018 10:14:44 +0000 (UTC) (envelope-from mw@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 4139912526; Wed, 4 Apr 2018 10:14:44 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34AEiMn049686; Wed, 4 Apr 2018 10:14:44 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34AEh7x049677; Wed, 4 Apr 2018 10:14:43 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804041014.w34AEh7x049677@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 4 Apr 2018 10:14:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332002 - in head/sys/arm/mv: . armada X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys/arm/mv: . armada X-SVN-Commit-Revision: 332002 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 10:14:44 -0000 Author: mw Date: Wed Apr 4 10:14:43 2018 New Revision: 332002 URL: https://svnweb.freebsd.org/changeset/base/332002 Log: Make Marvell Armada reset registers usage generic Define reset registers for both Armada38X and ArmadaXP and choose proper one during runtime based on information from FDT. Submitted by: Rafal Kozik Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14745 Modified: head/sys/arm/mv/armada/wdt.c head/sys/arm/mv/mv_armv7_machdep.c head/sys/arm/mv/mvreg.h head/sys/arm/mv/timer.c Modified: head/sys/arm/mv/armada/wdt.c ============================================================================== --- head/sys/arm/mv/armada/wdt.c Wed Apr 4 09:11:15 2018 (r332001) +++ head/sys/arm/mv/armada/wdt.c Wed Apr 4 10:14:43 2018 (r332002) @@ -245,9 +245,9 @@ mv_wdt_enable_armada_38x_xp_helper() val |= (WD_GLOBAL_MASK | WD_CPU0_MASK); write_cpu_mp_clocks(WD_RSTOUTn_MASK, val); - val = read_cpu_misc(RSTOUTn_MASK); + val = read_cpu_misc(RSTOUTn_MASK_ARMV7); val &= ~RSTOUTn_MASK_WD; - write_cpu_misc(RSTOUTn_MASK, val); + write_cpu_misc(RSTOUTn_MASK_ARMV7, val); } static void @@ -305,9 +305,9 @@ mv_wdt_disable_armada_38x_xp_helper(void) val &= ~(WD_GLOBAL_MASK | WD_CPU0_MASK); write_cpu_mp_clocks(WD_RSTOUTn_MASK, val); - val = read_cpu_misc(RSTOUTn_MASK); + val = read_cpu_misc(RSTOUTn_MASK_ARMV7); val |= RSTOUTn_MASK_WD; - write_cpu_misc(RSTOUTn_MASK, RSTOUTn_MASK_WD); + write_cpu_misc(RSTOUTn_MASK_ARMV7, RSTOUTn_MASK_WD); } static void Modified: head/sys/arm/mv/mv_armv7_machdep.c ============================================================================== --- head/sys/arm/mv/mv_armv7_machdep.c Wed Apr 4 09:11:15 2018 (r332001) +++ head/sys/arm/mv/mv_armv7_machdep.c Wed Apr 4 10:14:43 2018 (r332002) @@ -439,8 +439,8 @@ static void mv_cpu_reset(platform_t plat) { - write_cpu_misc(RSTOUTn_MASK, SOFT_RST_OUT_EN); - write_cpu_misc(SYSTEM_SOFT_RESET, SYS_SOFT_RST); + write_cpu_misc(RSTOUTn_MASK_ARMV7, SOFT_RST_OUT_EN_ARMV7); + write_cpu_misc(SYSTEM_SOFT_RESET_ARMV7, SYS_SOFT_RST_ARMV7); } #if defined(SOC_MV_ARMADA38X) Modified: head/sys/arm/mv/mvreg.h ============================================================================== --- head/sys/arm/mv/mvreg.h Wed Apr 4 09:11:15 2018 (r332001) +++ head/sys/arm/mv/mvreg.h Wed Apr 4 10:14:43 2018 (r332002) @@ -103,17 +103,15 @@ /* * System reset */ -#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) -#define RSTOUTn_MASK 0x60 -#define SYSTEM_SOFT_RESET 0x64 -#define SOFT_RST_OUT_EN 0x00000001 -#define SYS_SOFT_RST 0x00000001 -#else +#define RSTOUTn_MASK_ARMV7 0x60 +#define SYSTEM_SOFT_RESET_ARMV7 0x64 +#define SOFT_RST_OUT_EN_ARMV7 0x00000001 +#define SYS_SOFT_RST_ARMV7 0x00000001 + #define RSTOUTn_MASK 0x8 #define SOFT_RST_OUT_EN 0x00000004 #define SYSTEM_SOFT_RESET 0xc #define SYS_SOFT_RST 0x00000001 -#endif #define RSTOUTn_MASK_WD 0x400 #define WD_RSTOUTn_MASK 0x4 #define WD_GLOBAL_MASK 0x00000100 Modified: head/sys/arm/mv/timer.c ============================================================================== --- head/sys/arm/mv/timer.c Wed Apr 4 09:11:15 2018 (r332001) +++ head/sys/arm/mv/timer.c Wed Apr 4 10:14:43 2018 (r332002) @@ -411,9 +411,9 @@ mv_watchdog_enable_armadaxp(void) val |= (WD_GLOBAL_MASK | WD_CPU0_MASK); write_cpu_mp_clocks(WD_RSTOUTn_MASK, val); - val = read_cpu_misc(RSTOUTn_MASK); + val = read_cpu_misc(RSTOUTn_MASK_ARMV7); val &= ~RSTOUTn_MASK_WD; - write_cpu_misc(RSTOUTn_MASK, val); + write_cpu_misc(RSTOUTn_MASK_ARMV7, val); val = mv_get_timer_control(); val |= CPU_TIMER2_EN | CPU_TIMER2_AUTO | CPU_TIMER_WD_25MHZ_EN; @@ -451,9 +451,9 @@ mv_watchdog_disable_armadaxp(void) val &= ~(WD_GLOBAL_MASK | WD_CPU0_MASK); write_cpu_mp_clocks(WD_RSTOUTn_MASK, val); - val = read_cpu_misc(RSTOUTn_MASK); + val = read_cpu_misc(RSTOUTn_MASK_ARMV7); val |= RSTOUTn_MASK_WD; - write_cpu_misc(RSTOUTn_MASK, RSTOUTn_MASK_WD); + write_cpu_misc(RSTOUTn_MASK_ARMV7, RSTOUTn_MASK_WD); irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); irq_cause &= IRQ_TIMER_WD_CLR; From owner-svn-src-head@freebsd.org Wed Apr 4 10:45:07 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 57136F82CDD; Wed, 4 Apr 2018 10:45:07 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0316B71BF6; Wed, 4 Apr 2018 10:45:07 +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 EDFEF12A16; Wed, 4 Apr 2018 10:45:06 +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 w34Aj6gQ085455; Wed, 4 Apr 2018 10:45:06 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34Aj69t085454; Wed, 4 Apr 2018 10:45:06 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201804041045.w34Aj69t085454@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 4 Apr 2018 10:45:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332003 - head/sys/dev/mlx5/mlx5_en X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: head/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 332003 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 10:45:07 -0000 Author: hselasky Date: Wed Apr 4 10:45:06 2018 New Revision: 332003 URL: https://svnweb.freebsd.org/changeset/base/332003 Log: Bump driver version number in mlx5en(4). MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Wed Apr 4 10:14:43 2018 (r332002) +++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Wed Apr 4 10:45:06 2018 (r332003) @@ -30,7 +30,9 @@ #include #include -#define ETH_DRIVER_VERSION "3.1.0-dev" +#ifndef ETH_DRIVER_VERSION +#define ETH_DRIVER_VERSION "3.4.1" +#endif char mlx5e_version[] = "Mellanox Ethernet driver" " (" ETH_DRIVER_VERSION ")"; From owner-svn-src-head@freebsd.org Wed Apr 4 12:30:53 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BD5A9F8A7FC; Wed, 4 Apr 2018 12:30:53 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 714897752F; Wed, 4 Apr 2018 12:30:53 +0000 (UTC) (envelope-from mw@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 6C24313ABD; Wed, 4 Apr 2018 12:30:53 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34CUrSa010072; Wed, 4 Apr 2018 12:30:53 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34CUrL7010067; Wed, 4 Apr 2018 12:30:53 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804041230.w34CUrL7010067@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 4 Apr 2018 12:30:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332011 - in head/sys/arm/mv: . armada X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys/arm/mv: . armada X-SVN-Commit-Revision: 332011 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 12:30:54 -0000 Author: mw Date: Wed Apr 4 12:30:52 2018 New Revision: 332011 URL: https://svnweb.freebsd.org/changeset/base/332011 Log: Make Marvell armv7 timer and wdt registers definitions common Define timers registers for both SoCs and choose proper one during runtime based on information from FDT. In WDT driver there are different function for ArmadaXP and other ARMv5 SoCs. In timer driver registers definitions are stored in resource_spec structure and chosen during runtime. Submitted by: Rafal Kozik Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14746 Modified: head/sys/arm/mv/armada/wdt.c head/sys/arm/mv/mvreg.h head/sys/arm/mv/timer.c Modified: head/sys/arm/mv/armada/wdt.c ============================================================================== --- head/sys/arm/mv/armada/wdt.c Wed Apr 4 11:30:20 2018 (r332010) +++ head/sys/arm/mv/armada/wdt.c Wed Apr 4 12:30:52 2018 (r332011) @@ -253,8 +253,12 @@ mv_wdt_enable_armada_38x_xp_helper() static void mv_wdt_enable_armada_38x(void) { - uint32_t val; + uint32_t val, irq_cause; + irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); + irq_cause &= IRQ_TIMER_WD_CLR; + write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); + mv_wdt_enable_armada_38x_xp_helper(); val = mv_get_timer_control(); @@ -265,7 +269,10 @@ mv_wdt_enable_armada_38x(void) static void mv_wdt_enable_armada_xp(void) { - uint32_t val; + uint32_t val, irq_cause; + irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE_ARMADAXP); + irq_cause &= IRQ_TIMER_WD_CLR_ARMADAXP; + write_cpu_ctrl(BRIDGE_IRQ_CAUSE_ARMADAXP, irq_cause); mv_wdt_enable_armada_38x_xp_helper(); Modified: head/sys/arm/mv/mvreg.h ============================================================================== --- head/sys/arm/mv/mvreg.h Wed Apr 4 11:30:20 2018 (r332010) +++ head/sys/arm/mv/mvreg.h Wed Apr 4 12:30:52 2018 (r332011) @@ -76,18 +76,16 @@ #define MSI_IRQ_NUM 32 #define IRQ_CPU_SELF 0x00000001 -#if defined(SOC_MV_ARMADAXP) -#define BRIDGE_IRQ_CAUSE 0x68 -#define IRQ_TIMER0 0x00000001 -#define IRQ_TIMER1 0x00000002 -#define IRQ_TIMER_WD 0x00000004 -#else +#define BRIDGE_IRQ_CAUSE_ARMADAXP 0x68 +#define IRQ_TIMER0_ARMADAXP 0x00000001 +#define IRQ_TIMER1_ARMADAXP 0x00000002 +#define IRQ_TIMER_WD_ARMADAXP 0x00000004 + #define BRIDGE_IRQ_CAUSE 0x10 #define IRQ_CPU_SELF 0x00000001 #define IRQ_TIMER0 0x00000002 #define IRQ_TIMER1 0x00000004 #define IRQ_TIMER_WD 0x00000008 -#endif #define BRIDGE_IRQ_MASK 0x14 #define IRQ_CPU_MASK 0x00000001 @@ -97,8 +95,10 @@ #define IRQ_CPU_SELF_CLR (~IRQ_CPU_SELF) #define IRQ_TIMER0_CLR (~IRQ_TIMER0) -#define IRQ_TIMER1_CLR (~IRQ_TIMER1) #define IRQ_TIMER_WD_CLR (~IRQ_TIMER_WD) + +#define IRQ_TIMER0_CLR_ARMADAXP (~IRQ_TIMER0_ARMADAXP) +#define IRQ_TIMER_WD_CLR_ARMADAXP (~IRQ_TIMER_WD_ARMADAXP) /* * System reset Modified: head/sys/arm/mv/timer.c ============================================================================== --- head/sys/arm/mv/timer.c Wed Apr 4 11:30:20 2018 (r332010) +++ head/sys/arm/mv/timer.c Wed Apr 4 12:30:52 2018 (r332011) @@ -73,6 +73,9 @@ struct mv_timer_config { mv_watchdog_enable_t watchdog_enable; mv_watchdog_disable_t watchdog_disable; unsigned int clock_src; + uint32_t bridge_irq_cause; + uint32_t irq_timer0_clr; + uint32_t irq_timer_wd_clr; }; struct mv_timer_softc { @@ -132,6 +135,9 @@ static struct mv_timer_config timer_armadaxp_config = &mv_watchdog_enable_armadaxp, &mv_watchdog_disable_armadaxp, MV_CLOCK_SRC_ARMV7, + BRIDGE_IRQ_CAUSE_ARMADAXP, + IRQ_TIMER0_CLR_ARMADAXP, + IRQ_TIMER_WD_CLR_ARMADAXP, }; static struct mv_timer_config timer_armv5_config = { @@ -139,6 +145,9 @@ static struct mv_timer_config timer_armv5_config = &mv_watchdog_enable_armv5, &mv_watchdog_disable_armv5, 0, + BRIDGE_IRQ_CAUSE, + IRQ_TIMER0_CLR, + IRQ_TIMER_WD_CLR, }; static struct ofw_compat_data mv_timer_soc_config[] = { @@ -228,10 +237,10 @@ mv_timer_attach(device_t dev) mv_setup_timers(); if (sc->config->soc_family != MV_SOC_ARMADA_XP ) { - irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); - irq_cause &= IRQ_TIMER0_CLR; + irq_cause = read_cpu_ctrl(sc->config->bridge_irq_cause); + irq_cause &= sc->config->irq_timer0_clr; - write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); + write_cpu_ctrl(sc->config->bridge_irq_cause, irq_cause); irq_mask = read_cpu_ctrl(BRIDGE_IRQ_MASK); irq_mask |= IRQ_TIMER0_MASK; irq_mask &= ~IRQ_TIMER1_MASK; @@ -263,9 +272,9 @@ mv_hardclock(void *arg) struct mv_timer_softc *sc; uint32_t irq_cause; - irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); - irq_cause &= IRQ_TIMER0_CLR; - write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); + irq_cause = read_cpu_ctrl(timer_softc->config->bridge_irq_cause); + irq_cause &= timer_softc->config->irq_timer0_clr; + write_cpu_ctrl(timer_softc->config->bridge_irq_cause, irq_cause); sc = (struct mv_timer_softc *)arg; if (sc->et.et_active) @@ -381,9 +390,9 @@ mv_watchdog_enable_armv5(void) { uint32_t val, irq_cause, irq_mask; - irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); - irq_cause &= IRQ_TIMER_WD_CLR; - write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); + irq_cause = read_cpu_ctrl(timer_softc->config->bridge_irq_cause); + irq_cause &= timer_softc->config->irq_timer_wd_clr; + write_cpu_ctrl(timer_softc->config->bridge_irq_cause, irq_cause); irq_mask = read_cpu_ctrl(BRIDGE_IRQ_MASK); irq_mask |= IRQ_TIMER_WD_MASK; @@ -403,9 +412,9 @@ mv_watchdog_enable_armadaxp(void) { uint32_t irq_cause, val; - irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); - irq_cause &= IRQ_TIMER_WD_CLR; - write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); + irq_cause = read_cpu_ctrl(timer_softc->config->bridge_irq_cause); + irq_cause &= timer_softc->config->irq_timer_wd_clr; + write_cpu_ctrl(timer_softc->config->bridge_irq_cause, irq_cause); val = read_cpu_mp_clocks(WD_RSTOUTn_MASK); val |= (WD_GLOBAL_MASK | WD_CPU0_MASK); @@ -437,9 +446,9 @@ mv_watchdog_disable_armv5(void) irq_mask &= ~(IRQ_TIMER_WD_MASK); write_cpu_ctrl(BRIDGE_IRQ_MASK, irq_mask); - irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); - irq_cause &= IRQ_TIMER_WD_CLR; - write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); + irq_cause = read_cpu_ctrl(timer_softc->config->bridge_irq_cause); + irq_cause &= timer_softc->config->irq_timer_wd_clr; + write_cpu_ctrl(timer_softc->config->bridge_irq_cause, irq_cause); } static void @@ -455,9 +464,9 @@ mv_watchdog_disable_armadaxp(void) val |= RSTOUTn_MASK_WD; write_cpu_misc(RSTOUTn_MASK_ARMV7, RSTOUTn_MASK_WD); - irq_cause = read_cpu_ctrl(BRIDGE_IRQ_CAUSE); - irq_cause &= IRQ_TIMER_WD_CLR; - write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause); + irq_cause = read_cpu_ctrl(timer_softc->config->bridge_irq_cause); + irq_cause &= timer_softc->config->irq_timer_wd_clr; + write_cpu_ctrl(timer_softc->config->bridge_irq_cause, irq_cause); val = mv_get_timer_control(); val &= ~(CPU_TIMER2_EN | CPU_TIMER2_AUTO); From owner-svn-src-head@freebsd.org Wed Apr 4 12:36:56 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8956DF8AF61; Wed, 4 Apr 2018 12:36:56 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3DBE277C0C; Wed, 4 Apr 2018 12:36:56 +0000 (UTC) (envelope-from mw@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 3895C13C49; Wed, 4 Apr 2018 12:36:56 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34Cau4b018042; Wed, 4 Apr 2018 12:36:56 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34CatEl018041; Wed, 4 Apr 2018 12:36:55 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804041236.w34CatEl018041@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 4 Apr 2018 12:36:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332014 - head/sys/arm/mv X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/arm/mv X-SVN-Commit-Revision: 332014 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 12:36:56 -0000 Author: mw Date: Wed Apr 4 12:36:55 2018 New Revision: 332014 URL: https://svnweb.freebsd.org/changeset/base/332014 Log: Add support of PCI_RES_BUS to Marvell PCI driver GENERIC ARM config use NEW_PCIB driver (https://wiki.freebsd.org/NEW_PCIB). To satisfy it, allocation and deallocation of PCI_RES_BUS is necessary. Conditional compilation is added for backward compatibility with ARMv5 configs. Submitted by: Rafal Kozik Reviewed by: jhb Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14748 Modified: head/sys/arm/mv/mv_pci.c Modified: head/sys/arm/mv/mv_pci.c ============================================================================== --- head/sys/arm/mv/mv_pci.c Wed Apr 4 12:35:28 2018 (r332013) +++ head/sys/arm/mv/mv_pci.c Wed Apr 4 12:36:55 2018 (r332014) @@ -312,6 +312,8 @@ struct mv_pcib_softc { int sc_skip_enable_procedure; int sc_enable_find_root_slot; struct ofw_bus_iinfo sc_pci_iinfo; + + int ap_segment; /* PCI domain */ }; /* Local forward prototypes */ @@ -441,6 +443,8 @@ mv_pcib_attach(device_t self) return(ENXIO); } + sc->ap_segment = port_id; + if (ofw_bus_node_is_compatible(node, "mrvl,pcie")) { sc->sc_type = MV_TYPE_PCIE; if (ofw_bus_node_is_compatible(parnode, "marvell,armada-370-pcie")) { @@ -879,6 +883,11 @@ mv_pcib_alloc_resource(device_t dev, device_t child, i case SYS_RES_MEMORY: rm = &sc->sc_mem_rman; break; +#ifdef PCI_RES_BUS + case PCI_RES_BUS: + return (pci_domain_alloc_bus(sc->ap_segment, child, rid, start, + end, count, flags)); +#endif default: return (BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, type, rid, start, end, count, flags)); @@ -915,7 +924,12 @@ static int mv_pcib_release_resource(device_t dev, device_t child, int type, int rid, struct resource *res) { +#ifdef PCI_RES_BUS + struct mv_pcib_softc *sc = device_get_softc(dev); + if (type == PCI_RES_BUS) + return (pci_domain_release_bus(sc->ap_segment, child, rid, res)); +#endif if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY) return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, type, rid, res)); From owner-svn-src-head@freebsd.org Wed Apr 4 12:41:43 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 87F10F8B49E; Wed, 4 Apr 2018 12:41:43 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3A8B377F6A; Wed, 4 Apr 2018 12:41:43 +0000 (UTC) (envelope-from mw@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 356C513D7B; Wed, 4 Apr 2018 12:41:43 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34CfhGj026183; Wed, 4 Apr 2018 12:41:43 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34Cfg6g026175; Wed, 4 Apr 2018 12:41:42 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804041241.w34Cfg6g026175@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 4 Apr 2018 12:41:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332015 - in head/sys: arm/mv dts/arm X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys: arm/mv dts/arm X-SVN-Commit-Revision: 332015 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 12:41:43 -0000 Author: mw Date: Wed Apr 4 12:41:42 2018 New Revision: 332015 URL: https://svnweb.freebsd.org/changeset/base/332015 Log: Match Marvell Armada38X PCI compatible with Linux In Linux FDT pcie does not have compatible string. Configuration of windows in mv_common was based on fdt compatible. Now pcie windows are configured by their parent: pcie_controller. Processing is moved to fdt_win_process_child. fdt_win_process now only walk through the tree. SOC_NODE_PCI is position of pcie function in soc_node_spec array. PCIe probe cannot use ofw_bus_search_compatible, because it needs to check also device type and parents compatible. Submitted by: Rafal Kozik Reviewed by: manu [DT part] Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14749 Modified: head/sys/arm/mv/mv_common.c head/sys/arm/mv/mv_pci.c head/sys/dts/arm/armada-380.dtsi head/sys/dts/arm/armada-385.dtsi Modified: head/sys/arm/mv/mv_common.c ============================================================================== --- head/sys/arm/mv/mv_common.c Wed Apr 4 12:36:55 2018 (r332014) +++ head/sys/arm/mv/mv_common.c Wed Apr 4 12:41:42 2018 (r332015) @@ -76,6 +76,8 @@ MALLOC_DEFINE(M_IDMA, "idma", "idma dma test memory"); #define MV_DUMP_WIN 0 #endif +struct soc_node_spec; + static enum soc_family soc_family; static int mv_win_cesa_attr(int wng_sel); @@ -174,6 +176,8 @@ int gic_decode_fdt(phandle_t iparent, pcell_t *intr, i static int win_cpu_from_dt(void); static int fdt_win_setup(void); +static int fdt_win_process_child(phandle_t, struct soc_node_spec *); + static uint32_t dev_mask = 0; static int cpu_wins_no = 0; static int eth_port = 0; @@ -225,6 +229,8 @@ static struct soc_node_spec soc_nodes[] = { { NULL, NULL, NULL, NULL }, }; +#define SOC_NODE_PCIE_ENTRY_IDX 11 + typedef uint32_t(*read_cpu_ctrl_t)(uint32_t); typedef void(*write_cpu_ctrl_t)(uint32_t, uint32_t); typedef uint32_t (*win_read_t)(int); @@ -2741,55 +2747,63 @@ moveon: static int fdt_win_process(phandle_t child) { - int i; - struct soc_node_spec *soc_node; - int addr_cells, size_cells; - pcell_t reg[8]; - u_long size, base; + int i, ret; for (i = 0; soc_nodes[i].compat != NULL; i++) { - - soc_node = &soc_nodes[i]; - /* Setup only for enabled devices */ if (ofw_bus_node_status_okay(child) == 0) continue; - if (!ofw_bus_node_is_compatible(child, soc_node->compat)) + if (!ofw_bus_node_is_compatible(child, soc_nodes[i].compat)) continue; - if (fdt_addrsize_cells(OF_parent(child), &addr_cells, - &size_cells)) - return (ENXIO); + ret = fdt_win_process_child(child, &soc_nodes[i]); + if (ret != 0) + return (ret); + } - if ((sizeof(pcell_t) * (addr_cells + size_cells)) > sizeof(reg)) - return (ENOMEM); + return (0); +} - if (OF_getprop(child, "reg", ®, sizeof(reg)) <= 0) - return (EINVAL); +static int +fdt_win_process_child(phandle_t child, struct soc_node_spec *soc_node) +{ + int addr_cells, size_cells; + pcell_t reg[8]; + u_long size, base; - if (addr_cells <= 2) - base = fdt_data_get(®[0], addr_cells); - else - base = fdt_data_get(®[addr_cells - 2], 2); - size = fdt_data_get(®[addr_cells], size_cells); + if (fdt_addrsize_cells(OF_parent(child), &addr_cells, + &size_cells)) + return (ENXIO); - if (soc_node->valid_handler != NULL) - if (!soc_node->valid_handler()) - return (EINVAL); + if ((sizeof(pcell_t) * (addr_cells + size_cells)) > sizeof(reg)) + return (ENOMEM); - base = (base & 0x000fffff) | fdt_immr_va; - if (soc_node->decode_handler != NULL) - soc_node->decode_handler(base); - else - return (ENXIO); + if (OF_getprop(child, "reg", ®, sizeof(reg)) <= 0) + return (EINVAL); - if (MV_DUMP_WIN && (soc_node->dump_handler != NULL)) - soc_node->dump_handler(base); - } + if (addr_cells <= 2) + base = fdt_data_get(®[0], addr_cells); + else + base = fdt_data_get(®[addr_cells - 2], 2); + size = fdt_data_get(®[addr_cells], size_cells); + if (soc_node->valid_handler != NULL) + if (!soc_node->valid_handler()) + return (EINVAL); + + base = (base & 0x000fffff) | fdt_immr_va; + if (soc_node->decode_handler != NULL) + soc_node->decode_handler(base); + else + return (ENXIO); + + if (MV_DUMP_WIN && (soc_node->dump_handler != NULL)) + soc_node->dump_handler(base); + return (0); } + static int fdt_win_setup(void) { @@ -2821,7 +2835,8 @@ fdt_win_setup(void) if (ofw_bus_node_is_compatible(child, "marvell,armada-370-pcie")) { child_pci = OF_child(child); while (child_pci != 0) { - err = fdt_win_process(child_pci); + err = fdt_win_process_child(child_pci, + &soc_nodes[SOC_NODE_PCIE_ENTRY_IDX]); if (err != 0) return (err); Modified: head/sys/arm/mv/mv_pci.c ============================================================================== --- head/sys/arm/mv/mv_pci.c Wed Apr 4 12:36:55 2018 (r332014) +++ head/sys/arm/mv/mv_pci.c Wed Apr 4 12:41:42 2018 (r332015) @@ -413,7 +413,9 @@ mv_pcib_probe(device_t self) return (ENXIO); if (!(ofw_bus_is_compatible(self, "mrvl,pcie") || - ofw_bus_is_compatible(self, "mrvl,pci"))) + ofw_bus_is_compatible(self, "mrvl,pci") || + ofw_bus_node_is_compatible( + OF_parent(node), "marvell,armada-370-pcie"))) return (ENXIO); device_set_desc(self, "Marvell Integrated PCI/PCI-E Controller"); @@ -447,19 +449,18 @@ mv_pcib_attach(device_t self) if (ofw_bus_node_is_compatible(node, "mrvl,pcie")) { sc->sc_type = MV_TYPE_PCIE; - if (ofw_bus_node_is_compatible(parnode, "marvell,armada-370-pcie")) { - sc->sc_win_target = MV_WIN_PCIE_TARGET_ARMADA38X(port_id); - sc->sc_mem_win_attr = MV_WIN_PCIE_MEM_ATTR_ARMADA38X(port_id); - sc->sc_io_win_attr = MV_WIN_PCIE_IO_ATTR_ARMADA38X(port_id); - sc->sc_enable_find_root_slot = 1; - } else { - sc->sc_win_target = MV_WIN_PCIE_TARGET(port_id); - sc->sc_mem_win_attr = MV_WIN_PCIE_MEM_ATTR(port_id); - sc->sc_io_win_attr = MV_WIN_PCIE_IO_ATTR(port_id); + sc->sc_win_target = MV_WIN_PCIE_TARGET(port_id); + sc->sc_mem_win_attr = MV_WIN_PCIE_MEM_ATTR(port_id); + sc->sc_io_win_attr = MV_WIN_PCIE_IO_ATTR(port_id); #if __ARM_ARCH >= 6 - sc->sc_skip_enable_procedure = 1; + sc->sc_skip_enable_procedure = 1; #endif - } + } else if (ofw_bus_node_is_compatible(parnode, "marvell,armada-370-pcie")) { + sc->sc_type = MV_TYPE_PCIE; + sc->sc_win_target = MV_WIN_PCIE_TARGET_ARMADA38X(port_id); + sc->sc_mem_win_attr = MV_WIN_PCIE_MEM_ATTR_ARMADA38X(port_id); + sc->sc_io_win_attr = MV_WIN_PCIE_IO_ATTR_ARMADA38X(port_id); + sc->sc_enable_find_root_slot = 1; } else if (ofw_bus_node_is_compatible(node, "mrvl,pci")) { sc->sc_type = MV_TYPE_PCI; sc->sc_win_target = MV_WIN_PCI_TARGET; Modified: head/sys/dts/arm/armada-380.dtsi ============================================================================== --- head/sys/dts/arm/armada-380.dtsi Wed Apr 4 12:36:55 2018 (r332014) +++ head/sys/dts/arm/armada-380.dtsi Wed Apr 4 12:41:42 2018 (r332015) @@ -98,7 +98,6 @@ /* x1 port */ pcie@1,0 { - compatible = "mrvl,pcie"; device_type = "pci"; assigned-addresses = <0x82000800 0 0x80000 0 0x2000>; reg = <0x0 0x0 0x80000 0x0 0x2000>; @@ -119,7 +118,6 @@ /* x1 port */ pcie@2,0 { - compatible = "mrvl,pcie"; device_type = "pci"; assigned-addresses = <0x82000800 0 0x40000 0 0x2000>; reg = <0x0 0x0 0x40000 0x0 0x2000>; @@ -140,7 +138,6 @@ /* x1 port */ pcie@3,0 { - compatible = "mrvl,pcie"; device_type = "pci"; assigned-addresses = <0x82000800 0 0x44000 0 0x2000>; reg = <0x0 0x0 0x44000 0x0 0x2000>; Modified: head/sys/dts/arm/armada-385.dtsi ============================================================================== --- head/sys/dts/arm/armada-385.dtsi Wed Apr 4 12:36:55 2018 (r332014) +++ head/sys/dts/arm/armada-385.dtsi Wed Apr 4 12:41:42 2018 (r332015) @@ -110,7 +110,6 @@ * pcie@4,0 is not available. */ pcie@1,0 { - compatible = "mrvl,pcie"; device_type = "pci"; assigned-addresses = <0x82000800 0 0x80000 0 0x2000>; reg = <0x0 0x0 0x80000 0x0 0x2000>; @@ -131,7 +130,6 @@ /* x1 port */ pcie@2,0 { - compatible = "mrvl,pcie"; device_type = "pci"; assigned-addresses = <0x82000800 0 0x40000 0 0x2000>; reg = <0x0 0x0 0x40000 0x0 0x2000>; @@ -152,7 +150,6 @@ /* x1 port */ pcie@3,0 { - compatible = "mrvl,pcie"; device_type = "pci"; assigned-addresses = <0x82000800 0 0x44000 0 0x2000>; reg = <0x0 0x0 0x44000 0x0 0x2000>; @@ -176,7 +173,6 @@ * configured as a x1 port */ pcie@4,0 { - compatible = "mrvl,pcie"; device_type = "pci"; assigned-addresses = <0x82000800 0 0x48000 0 0x2000>; reg = <0x0 0x0 0x48000 0x0 0x2000>; From owner-svn-src-head@freebsd.org Wed Apr 4 12:47:42 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9028CF8BA1F; Wed, 4 Apr 2018 12:47:42 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4688A7853C; Wed, 4 Apr 2018 12:47:42 +0000 (UTC) (envelope-from mw@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 2433E13DED; Wed, 4 Apr 2018 12:47:42 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34ClfaX030446; Wed, 4 Apr 2018 12:47:41 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34ClfTU030442; Wed, 4 Apr 2018 12:47:41 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804041247.w34ClfTU030442@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 4 Apr 2018 12:47:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332016 - head/sys/dev/ofw X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/dev/ofw X-SVN-Commit-Revision: 332016 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 12:47:42 -0000 Author: mw Date: Wed Apr 4 12:47:41 2018 New Revision: 332016 URL: https://svnweb.freebsd.org/changeset/base/332016 Log: Add api for creating resource list based on 'assigned-addresses' According to device tree binding 'assigned-addresses' can refer to PCIE MMIO register space. New function ofw_bus_assigned_addresses_to_rl is provided to support it. Submitted by: Rafal Kozik Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14750 Modified: head/sys/dev/ofw/ofw_bus_subr.c head/sys/dev/ofw/ofw_bus_subr.h Modified: head/sys/dev/ofw/ofw_bus_subr.c ============================================================================== --- head/sys/dev/ofw/ofw_bus_subr.c Wed Apr 4 12:41:42 2018 (r332015) +++ head/sys/dev/ofw/ofw_bus_subr.c Wed Apr 4 12:47:41 2018 (r332016) @@ -489,9 +489,9 @@ ofw_bus_msimap(phandle_t node, uint16_t pci_rid, phand return (err); } -int -ofw_bus_reg_to_rl(device_t dev, phandle_t node, pcell_t acells, pcell_t scells, - struct resource_list *rl) +static int +ofw_bus_reg_to_rl_helper(device_t dev, phandle_t node, pcell_t acells, pcell_t scells, + struct resource_list *rl, const char *reg_source) { uint64_t phys, size; ssize_t i, j, rid, nreg, ret; @@ -506,7 +506,7 @@ ofw_bus_reg_to_rl(device_t dev, phandle_t node, pcell_ if (ret == -1) name = NULL; - ret = OF_getencprop_alloc(node, "reg", sizeof(*reg), (void **)®); + ret = OF_getencprop_alloc(node, reg_source, sizeof(*reg), (void **)®); nreg = (ret == -1) ? 0 : ret; if (nreg % (acells + scells) != 0) { @@ -535,6 +535,23 @@ ofw_bus_reg_to_rl(device_t dev, phandle_t node, pcell_ free(reg, M_OFWPROP); return (0); +} + +int +ofw_bus_reg_to_rl(device_t dev, phandle_t node, pcell_t acells, pcell_t scells, + struct resource_list *rl) +{ + + return (ofw_bus_reg_to_rl_helper(dev, node, acells, scells, rl, "reg")); +} + +int +ofw_bus_assigned_addresses_to_rl(device_t dev, phandle_t node, pcell_t acells, + pcell_t scells, struct resource_list *rl) +{ + + return (ofw_bus_reg_to_rl_helper(dev, node, acells, scells, + rl, "assigned-addresses")); } /* Modified: head/sys/dev/ofw/ofw_bus_subr.h ============================================================================== --- head/sys/dev/ofw/ofw_bus_subr.h Wed Apr 4 12:41:42 2018 (r332015) +++ head/sys/dev/ofw/ofw_bus_subr.h Wed Apr 4 12:47:41 2018 (r332016) @@ -95,6 +95,8 @@ int ofw_bus_msimap(phandle_t, uint16_t, phandle_t *, u /* Routines for parsing device-tree data into resource lists. */ int ofw_bus_reg_to_rl(device_t, phandle_t, pcell_t, pcell_t, struct resource_list *); +int ofw_bus_assigned_addresses_to_rl(device_t, phandle_t, pcell_t, pcell_t, + struct resource_list *); int ofw_bus_intr_to_rl(device_t, phandle_t, struct resource_list *, int *); int ofw_bus_intr_by_rid(device_t, phandle_t, int, phandle_t *, int *, pcell_t **); From owner-svn-src-head@freebsd.org Wed Apr 4 12:54:19 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 489E6F8C35B; Wed, 4 Apr 2018 12:54:19 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EE72F78F13; Wed, 4 Apr 2018 12:54:18 +0000 (UTC) (envelope-from mw@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 E946513FA1; Wed, 4 Apr 2018 12:54:18 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34CsI7p040379; Wed, 4 Apr 2018 12:54:18 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34CsIwM040371; Wed, 4 Apr 2018 12:54:18 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804041254.w34CsIwM040371@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 4 Apr 2018 12:54:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332017 - in head/sys: arm/mv dts/arm X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys: arm/mv dts/arm X-SVN-Commit-Revision: 332017 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 12:54:19 -0000 Author: mw Date: Wed Apr 4 12:54:18 2018 New Revision: 332017 URL: https://svnweb.freebsd.org/changeset/base/332017 Log: Change reg in Marvell Armada38X pcie FDT Ranges in pcie-controller are unused, so could be changed to match Linux device tree represntation. Same with interrupt-cells and interrupt-parent. In PCI controller driver ocd_data are used for matching driver and choose proper resources acquisition function. fdt_win_process_child have new argument which provide information about fdt node containing addresses of MMIO registers. Submitted by: Rafal Kozik Reviewed by: manu [DT part] Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14751 Modified: head/sys/arm/mv/mv_common.c head/sys/arm/mv/mv_pci_ctrl.c head/sys/dts/arm/armada-380.dtsi head/sys/dts/arm/armada-385.dtsi Modified: head/sys/arm/mv/mv_common.c ============================================================================== --- head/sys/arm/mv/mv_common.c Wed Apr 4 12:47:41 2018 (r332016) +++ head/sys/arm/mv/mv_common.c Wed Apr 4 12:54:18 2018 (r332017) @@ -176,7 +176,7 @@ int gic_decode_fdt(phandle_t iparent, pcell_t *intr, i static int win_cpu_from_dt(void); static int fdt_win_setup(void); -static int fdt_win_process_child(phandle_t, struct soc_node_spec *); +static int fdt_win_process_child(phandle_t, struct soc_node_spec *, const char*); static uint32_t dev_mask = 0; static int cpu_wins_no = 0; @@ -2757,7 +2757,7 @@ fdt_win_process(phandle_t child) if (!ofw_bus_node_is_compatible(child, soc_nodes[i].compat)) continue; - ret = fdt_win_process_child(child, &soc_nodes[i]); + ret = fdt_win_process_child(child, &soc_nodes[i], "reg"); if (ret != 0) return (ret); } @@ -2766,7 +2766,8 @@ fdt_win_process(phandle_t child) } static int -fdt_win_process_child(phandle_t child, struct soc_node_spec *soc_node) +fdt_win_process_child(phandle_t child, struct soc_node_spec *soc_node, + const char* mimo_reg_source) { int addr_cells, size_cells; pcell_t reg[8]; @@ -2778,8 +2779,7 @@ fdt_win_process_child(phandle_t child, struct soc_node if ((sizeof(pcell_t) * (addr_cells + size_cells)) > sizeof(reg)) return (ENOMEM); - - if (OF_getprop(child, "reg", ®, sizeof(reg)) <= 0) + if (OF_getprop(child, mimo_reg_source, ®, sizeof(reg)) <= 0) return (EINVAL); if (addr_cells <= 2) @@ -2836,7 +2836,8 @@ fdt_win_setup(void) child_pci = OF_child(child); while (child_pci != 0) { err = fdt_win_process_child(child_pci, - &soc_nodes[SOC_NODE_PCIE_ENTRY_IDX]); + &soc_nodes[SOC_NODE_PCIE_ENTRY_IDX], + "assigned-addresses"); if (err != 0) return (err); Modified: head/sys/arm/mv/mv_pci_ctrl.c ============================================================================== --- head/sys/arm/mv/mv_pci_ctrl.c Wed Apr 4 12:47:41 2018 (r332016) +++ head/sys/arm/mv/mv_pci_ctrl.c Wed Apr 4 12:54:18 2018 (r332017) @@ -67,6 +67,9 @@ struct mv_pcib_ctrl_range { uint64_t size; }; +typedef int (*get_rl_t)(device_t dev, phandle_t node, pcell_t acells, + pcell_t scells, struct resource_list *rl); + struct mv_pcib_ctrl_softc { pcell_t addr_cells; pcell_t size_cells; @@ -107,6 +110,13 @@ static device_method_t mv_pcib_ctrl_methods[] = { DEVMETHOD_END }; +static struct ofw_compat_data mv_pcib_ctrl_compat[] = { + {"mrvl,pcie-ctrl", (uintptr_t)&ofw_bus_reg_to_rl}, + {"marvell,armada-370-pcie", + (uintptr_t)&ofw_bus_assigned_addresses_to_rl}, + {NULL, (uintptr_t)NULL}, +}; + static driver_t mv_pcib_ctrl_driver = { "pcib_ctrl", mv_pcib_ctrl_methods, @@ -124,10 +134,12 @@ static int mv_pcib_ctrl_probe(device_t dev) { - if (!ofw_bus_is_compatible(dev, "mrvl,pcie-ctrl") && - !ofw_bus_is_compatible(dev, "marvell,armada-370-pcie")) + if (!ofw_bus_status_okay(dev)) return (ENXIO); + if (!ofw_bus_search_compatible(dev, mv_pcib_ctrl_compat)->ocd_data) + return (ENXIO); + device_set_desc(dev, "Marvell Integrated PCIe Bus Controller"); return (BUS_PROBE_DEFAULT); } @@ -151,6 +163,7 @@ mv_pcib_ofw_bus_attach(device_t dev) struct mv_pcib_ctrl_softc *sc; device_t child; phandle_t parent, node; + get_rl_t get_rl; parent = ofw_bus_get_node(dev); sc = device_get_softc(dev); @@ -189,8 +202,11 @@ mv_pcib_ofw_bus_attach(device_t dev) } resource_list_init(&di->di_rl); - ofw_bus_reg_to_rl(child, node, sc->addr_cells, - sc->size_cells, &di->di_rl); + get_rl = (get_rl_t) ofw_bus_search_compatible(dev, + mv_pcib_ctrl_compat)->ocd_data; + if (get_rl != NULL) + get_rl(child, node, sc->addr_cells, + sc->size_cells, &di->di_rl); device_set_ivars(child, di); } Modified: head/sys/dts/arm/armada-380.dtsi ============================================================================== --- head/sys/dts/arm/armada-380.dtsi Wed Apr 4 12:47:41 2018 (r332016) +++ head/sys/dts/arm/armada-380.dtsi Wed Apr 4 12:54:18 2018 (r332017) @@ -88,23 +88,21 @@ <0x82000000 0 0x80000 MBUS_ID(0xf0, 0x01) 0x80000 0 0x00002000 0x82000000 0 0x40000 MBUS_ID(0xf0, 0x01) 0x40000 0 0x00002000 0x82000000 0 0x44000 MBUS_ID(0xf0, 0x01) 0x44000 0 0x00002000 - 0x82000000 0x0 0xf1200000 MBUS_ID(0x08, 0xe8) 0xf1200000 0 0x00100000 /* Port 0 MEM */ - 0x81000000 0x0 0xf1300000 MBUS_ID(0x08, 0xe0) 0xf1300000 0 0x00100000 /* Port 0 IO */ - 0x82000000 0x0 0xf1400000 MBUS_ID(0x04, 0xe8) 0xf1400000 0 0x00100000 /* Port 1 MEM */ - 0x81000000 0x0 0xf1500000 MBUS_ID(0x04, 0xe0) 0xf1500000 0 0x00100000 /* Port 1 IO */ - 0x82000000 0x0 0xf1600000 MBUS_ID(0x04, 0xd8) 0xf1600000 0 0x00100000 /* Port 2 MEM */ - 0x81000000 0x0 0xf1700000 MBUS_ID(0x04, 0xd0) 0xf1700000 0 0x00100000 /* Port 2 IO */ - >; + 0x82000000 0x1 0 MBUS_ID(0x08, 0xe8) 0 1 0 /* Port 0 MEM */ + 0x81000000 0x1 0 MBUS_ID(0x08, 0xe0) 0 1 0 /* Port 0 IO */ + 0x82000000 0x2 0 MBUS_ID(0x04, 0xe8) 0 1 0 /* Port 1 MEM */ + 0x81000000 0x2 0 MBUS_ID(0x04, 0xe0) 0 1 0 /* Port 1 IO */ + 0x82000000 0x3 0 MBUS_ID(0x04, 0xd8) 0 1 0 /* Port 2 MEM */ + 0x81000000 0x3 0 MBUS_ID(0x04, 0xd0) 0 1 0 /* Port 2 IO */>; /* x1 port */ pcie@1,0 { device_type = "pci"; assigned-addresses = <0x82000800 0 0x80000 0 0x2000>; - reg = <0x0 0x0 0x80000 0x0 0x2000>; + reg = <0x0800 0 0 0 0>; #address-cells = <3>; #size-cells = <2>; - #interrupt-cells = <3>; - bus-range = <0 255>; + #interrupt-cells = <1>; ranges = <0x82000000 0x0 0x0 0x82000000 0x0 0xf1200000 0x0 0x00100000 0x81000000 0x0 0x0 0x81000000 0x0 0xf1300000 0x0 0x00100000>; interrupt-map-mask = <0 0 0 0>; @@ -120,11 +118,10 @@ pcie@2,0 { device_type = "pci"; assigned-addresses = <0x82000800 0 0x40000 0 0x2000>; - reg = <0x0 0x0 0x40000 0x0 0x2000>; + reg = <0x1000 0 0 0 0>; #address-cells = <3>; #size-cells = <2>; - #interrupt-cells = <3>; - bus-range = <0 255>; + #interrupt-cells = <1>; ranges = <0x82000000 0x0 0x0 0x82000000 0x0 0xf1400000 0x0 0x00100000 0x81000000 0x0 0x0 0x81000000 0x0 0xf1500000 0x0 0x00100000>; interrupt-map-mask = <0 0 0 0>; @@ -140,11 +137,10 @@ pcie@3,0 { device_type = "pci"; assigned-addresses = <0x82000800 0 0x44000 0 0x2000>; - reg = <0x0 0x0 0x44000 0x0 0x2000>; + reg = <0x1800 0 0 0 0>; #address-cells = <3>; #size-cells = <2>; - #interrupt-cells = <3>; - bus-range = <0 255>; + #interrupt-cells = <1>; ranges = <0x82000000 0x0 0x0 0x82000000 0x0 0xf1600000 0x0 0x00100000 0x81000000 0x0 0x0 0x81000000 0x0 0xf1700000 0x0 0x00100000>; interrupt-map-mask = <0 0 0 0>; Modified: head/sys/dts/arm/armada-385.dtsi ============================================================================== --- head/sys/dts/arm/armada-385.dtsi Wed Apr 4 12:47:41 2018 (r332016) +++ head/sys/dts/arm/armada-385.dtsi Wed Apr 4 12:54:18 2018 (r332017) @@ -94,15 +94,14 @@ 0x82000000 0 0x40000 MBUS_ID(0xf0, 0x01) 0x40000 0 0x00002000 0x82000000 0 0x44000 MBUS_ID(0xf0, 0x01) 0x44000 0 0x00002000 0x82000000 0 0x48000 MBUS_ID(0xf0, 0x01) 0x48000 0 0x00002000 - 0x82000000 0x0 0xf1200000 MBUS_ID(0x08, 0xe8) 0xf1200000 0 0x00100000 /* Port 0 MEM */ - 0x81000000 0x0 0xf1300000 MBUS_ID(0x08, 0xe0) 0xf1300000 0 0x00100000 /* Port 0 IO */ - 0x82000000 0x0 0xf1400000 MBUS_ID(0x04, 0xe8) 0xf1400000 0 0x00100000 /* Port 1 MEM */ - 0x81000000 0x0 0xf1500000 MBUS_ID(0x04, 0xe0) 0xf1500000 0 0x00100000 /* Port 1 IO */ - 0x82000000 0x0 0xf1600000 MBUS_ID(0x04, 0xd8) 0xf1600000 0 0x00100000 /* Port 2 MEM */ - 0x81000000 0x0 0xf1700000 MBUS_ID(0x04, 0xd0) 0xf1700000 0 0x00100000 /* Port 2 IO */ - 0x82000000 0x0 0xf1800000 MBUS_ID(0x04, 0xb8) 0xf1800000 0 0x00100000 /* Port 3 MEM */ - 0x81000000 0x0 0xf1900000 MBUS_ID(0x04, 0xb0) 0xf1900000 0 0x00100000 /* Port 3 IO */ - >; + 0x82000000 0x1 0 MBUS_ID(0x08, 0xe8) 0 1 0 /* Port 0 MEM */ + 0x81000000 0x1 0 MBUS_ID(0x08, 0xe0) 0 1 0 /* Port 0 IO */ + 0x82000000 0x2 0 MBUS_ID(0x04, 0xe8) 0 1 0 /* Port 1 MEM */ + 0x81000000 0x2 0 MBUS_ID(0x04, 0xe0) 0 1 0 /* Port 1 IO */ + 0x82000000 0x3 0 MBUS_ID(0x04, 0xd8) 0 1 0 /* Port 2 MEM */ + 0x81000000 0x3 0 MBUS_ID(0x04, 0xd0) 0 1 0 /* Port 2 IO */ + 0x82000000 0x4 0 MBUS_ID(0x04, 0xb8) 0 1 0 /* Port 3 MEM */ + 0x81000000 0x4 0 MBUS_ID(0x04, 0xb0) 0 1 0 /* Port 3 IO */>; /* * This port can be either x4 or x1. When @@ -112,16 +111,14 @@ pcie@1,0 { device_type = "pci"; assigned-addresses = <0x82000800 0 0x80000 0 0x2000>; - reg = <0x0 0x0 0x80000 0x0 0x2000>; + reg = <0x0800 0 0 0 0>; #address-cells = <3>; #size-cells = <2>; - #interrupt-cells = <3>; - bus-range = <0 255>; + #interrupt-cells = <1>; ranges = <0x82000000 0x0 0x0 0x82000000 0x0 0xf1200000 0x0 0x00100000 0x81000000 0x0 0x0 0x81000000 0x0 0xf1300000 0x0 0x00100000>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &gic GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>; - interrupt-parent = <&gic>; marvell,pcie-port = <0>; marvell,pcie-lane = <0>; clocks = <&gateclk 8>; @@ -132,16 +129,14 @@ pcie@2,0 { device_type = "pci"; assigned-addresses = <0x82000800 0 0x40000 0 0x2000>; - reg = <0x0 0x0 0x40000 0x0 0x2000>; + reg = <0x1000 0 0 0 0>; #address-cells = <3>; #size-cells = <2>; - #interrupt-cells = <3>; - bus-range = <0 255>; + #interrupt-cells = <1>; ranges = <0x82000000 0x0 0x0 0x82000000 0x0 0xf1400000 0x0 0x00100000 0x81000000 0x0 0x0 0x81000000 0x0 0xf1500000 0x0 0x00100000>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &gic GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>; - interrupt-parent = <&gic>; marvell,pcie-port = <1>; marvell,pcie-lane = <0>; clocks = <&gateclk 5>; @@ -152,16 +147,14 @@ pcie@3,0 { device_type = "pci"; assigned-addresses = <0x82000800 0 0x44000 0 0x2000>; - reg = <0x0 0x0 0x44000 0x0 0x2000>; + reg = <0x1800 0 0 0 0>; #address-cells = <3>; #size-cells = <2>; - #interrupt-cells = <3>; - bus-range = <0 255>; + #interrupt-cells = <1>; ranges = <0x82000000 0x0 0x0 0x82000000 0x0 0xf1600000 0x0 0x00100000 0x81000000 0x0 0x0 0x81000000 0x0 0xf1700000 0x0 0x00100000>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &gic GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>; - interrupt-parent = <&gic>; marvell,pcie-port = <2>; marvell,pcie-lane = <0>; clocks = <&gateclk 6>; @@ -175,16 +168,14 @@ pcie@4,0 { device_type = "pci"; assigned-addresses = <0x82000800 0 0x48000 0 0x2000>; - reg = <0x0 0x0 0x48000 0x0 0x2000>; + reg = <0x2000 0 0 0 0>; #address-cells = <3>; #size-cells = <2>; - #interrupt-cells = <3>; - bus-range = <0 255>; + #interrupt-cells = <1>; ranges = <0x82000000 0x0 0x0 0x82000000 0x0 0xf1800000 0x0 0x00100000 0x81000000 0x0 0x0 0x81000000 0x0 0xf1900000 0x0 0x00100000>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &gic GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>; - interrupt-parent = <&gic>; marvell,pcie-port = <3>; marvell,pcie-lane = <0>; clocks = <&gateclk 7>; From owner-svn-src-head@freebsd.org Wed Apr 4 12:55:32 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2A260F8C4D2; Wed, 4 Apr 2018 12:55:32 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D1E4E790F0; Wed, 4 Apr 2018 12:55:31 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CCAC313FA9; Wed, 4 Apr 2018 12:55:31 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34CtV93041324; Wed, 4 Apr 2018 12:55:31 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34CtVt8041323; Wed, 4 Apr 2018 12:55:31 GMT (envelope-from br@FreeBSD.org) Message-Id: <201804041255.w34CtVt8041323@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Wed, 4 Apr 2018 12:55:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332018 - in head/contrib/opencsd: . decoder decoder/include decoder/source X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: in head/contrib/opencsd: . decoder decoder/include decoder/source X-SVN-Commit-Revision: 332018 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 12:55:32 -0000 Author: br Date: Wed Apr 4 12:55:31 2018 New Revision: 332018 URL: https://svnweb.freebsd.org/changeset/base/332018 Log: Import OpenCSD -- an ARM CoreSight(tm) Trace Decode Library. Sponsored by: DARPA, AFRL Added: head/contrib/opencsd/ head/contrib/opencsd/decoder/ head/contrib/opencsd/decoder/include/ - copied from r332013, vendor/opencsd/dist/decoder/include/ head/contrib/opencsd/decoder/source/ - copied from r332013, vendor/opencsd/dist/decoder/source/ From owner-svn-src-head@freebsd.org Wed Apr 4 13:01:16 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EF9A5F8CC68; Wed, 4 Apr 2018 13:01:15 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A164B7966E; Wed, 4 Apr 2018 13:01:15 +0000 (UTC) (envelope-from mw@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 9C456140DD; Wed, 4 Apr 2018 13:01:15 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34D1FjI045495; Wed, 4 Apr 2018 13:01:15 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34D1FGh045490; Wed, 4 Apr 2018 13:01:15 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804041301.w34D1FGh045490@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 4 Apr 2018 13:01:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332019 - in head/sys: arm/mv dts/arm X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: in head/sys: arm/mv dts/arm X-SVN-Commit-Revision: 332019 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 13:01:16 -0000 Author: mw Date: Wed Apr 4 13:01:14 2018 New Revision: 332019 URL: https://svnweb.freebsd.org/changeset/base/332019 Log: Match Marvell Armada38X PCIE ranges in dts with Linux If driver cannot determine ranges based on fdt, it will calculate them based on number and type of current port. Submitted by: Rafal Kozik Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14752 Modified: head/sys/arm/mv/mv_pci.c head/sys/dts/arm/armada-380.dtsi head/sys/dts/arm/armada-385.dtsi Modified: head/sys/arm/mv/mv_pci.c ============================================================================== --- head/sys/arm/mv/mv_pci.c Wed Apr 4 12:55:31 2018 (r332018) +++ head/sys/arm/mv/mv_pci.c Wed Apr 4 13:01:14 2018 (r332019) @@ -100,6 +100,7 @@ struct mv_pci_range { }; #define FDT_RANGES_CELLS ((3 + 3 + 2) * 2) +#define PCI_SPACE_LEN 0x00100000 static void mv_pci_range_dump(struct mv_pci_range *range) @@ -122,6 +123,7 @@ mv_pci_ranges_decode(phandle_t node, struct mv_pci_ran pcell_t *rangesptr; pcell_t cell0, cell1, cell2; int tuple_size, tuples, i, rv, offset_cells, len; + int portid, is_io_space; /* * Retrieve 'ranges' property. @@ -163,11 +165,14 @@ mv_pci_ranges_decode(phandle_t node, struct mv_pci_ran rangesptr++; cell2 = fdt_data_get((void *)rangesptr, 1); rangesptr++; + portid = fdt_data_get((void *)(rangesptr+1), 1); if (cell0 & 0x02000000) { pci_space = mem_space; + is_io_space = 0; } else if (cell0 & 0x01000000) { pci_space = io_space; + is_io_space = 1; } else { rv = ERANGE; goto out; @@ -198,6 +203,12 @@ mv_pci_ranges_decode(phandle_t node, struct mv_pci_ran rangesptr += size_cells; pci_space->base_pci = cell2; + + if (pci_space->len == 0) { + pci_space->len = PCI_SPACE_LEN; + pci_space->base_parent = fdt_immr_va + + PCI_SPACE_LEN * ( 2 * portid + is_io_space); + } } rv = 0; out: Modified: head/sys/dts/arm/armada-380.dtsi ============================================================================== --- head/sys/dts/arm/armada-380.dtsi Wed Apr 4 12:55:31 2018 (r332018) +++ head/sys/dts/arm/armada-380.dtsi Wed Apr 4 13:01:14 2018 (r332019) @@ -103,8 +103,8 @@ #address-cells = <3>; #size-cells = <2>; #interrupt-cells = <1>; - ranges = <0x82000000 0x0 0x0 0x82000000 0x0 0xf1200000 0x0 0x00100000 - 0x81000000 0x0 0x0 0x81000000 0x0 0xf1300000 0x0 0x00100000>; + ranges = <0x82000000 0 0 0x82000000 0x1 0 1 0 + 0x81000000 0 0 0x81000000 0x1 0 1 0>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &gic GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&gic>; @@ -122,8 +122,8 @@ #address-cells = <3>; #size-cells = <2>; #interrupt-cells = <1>; - ranges = <0x82000000 0x0 0x0 0x82000000 0x0 0xf1400000 0x0 0x00100000 - 0x81000000 0x0 0x0 0x81000000 0x0 0xf1500000 0x0 0x00100000>; + ranges = <0x82000000 0 0 0x82000000 0x2 0 1 0 + 0x81000000 0 0 0x81000000 0x2 0 1 0>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &gic GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&gic>; @@ -141,8 +141,8 @@ #address-cells = <3>; #size-cells = <2>; #interrupt-cells = <1>; - ranges = <0x82000000 0x0 0x0 0x82000000 0x0 0xf1600000 0x0 0x00100000 - 0x81000000 0x0 0x0 0x81000000 0x0 0xf1700000 0x0 0x00100000>; + ranges = <0x82000000 0 0 0x82000000 0x3 0 1 0 + 0x81000000 0 0 0x81000000 0x3 0 1 0>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &gic GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>; interrupt-parent = <&gic>; Modified: head/sys/dts/arm/armada-385.dtsi ============================================================================== --- head/sys/dts/arm/armada-385.dtsi Wed Apr 4 12:55:31 2018 (r332018) +++ head/sys/dts/arm/armada-385.dtsi Wed Apr 4 13:01:14 2018 (r332019) @@ -115,8 +115,8 @@ #address-cells = <3>; #size-cells = <2>; #interrupt-cells = <1>; - ranges = <0x82000000 0x0 0x0 0x82000000 0x0 0xf1200000 0x0 0x00100000 - 0x81000000 0x0 0x0 0x81000000 0x0 0xf1300000 0x0 0x00100000>; + ranges = <0x82000000 0 0 0x82000000 0x1 0 1 0 + 0x81000000 0 0 0x81000000 0x1 0 1 0>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &gic GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>; marvell,pcie-port = <0>; @@ -133,8 +133,8 @@ #address-cells = <3>; #size-cells = <2>; #interrupt-cells = <1>; - ranges = <0x82000000 0x0 0x0 0x82000000 0x0 0xf1400000 0x0 0x00100000 - 0x81000000 0x0 0x0 0x81000000 0x0 0xf1500000 0x0 0x00100000>; + ranges = <0x82000000 0 0 0x82000000 0x2 0 1 0 + 0x81000000 0 0 0x81000000 0x2 0 1 0>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &gic GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>; marvell,pcie-port = <1>; @@ -151,8 +151,8 @@ #address-cells = <3>; #size-cells = <2>; #interrupt-cells = <1>; - ranges = <0x82000000 0x0 0x0 0x82000000 0x0 0xf1600000 0x0 0x00100000 - 0x81000000 0x0 0x0 0x81000000 0x0 0xf1700000 0x0 0x00100000>; + ranges = <0x82000000 0 0 0x82000000 0x3 0 1 0 + 0x81000000 0 0 0x81000000 0x3 0 1 0>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &gic GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>; marvell,pcie-port = <2>; @@ -172,8 +172,8 @@ #address-cells = <3>; #size-cells = <2>; #interrupt-cells = <1>; - ranges = <0x82000000 0x0 0x0 0x82000000 0x0 0xf1800000 0x0 0x00100000 - 0x81000000 0x0 0x0 0x81000000 0x0 0xf1900000 0x0 0x00100000>; + ranges = <0x82000000 0 0 0x82000000 0x4 0 1 0 + 0x81000000 0 0 0x81000000 0x4 0 1 0>; interrupt-map-mask = <0 0 0 0>; interrupt-map = <0 0 0 0 &gic GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>; marvell,pcie-port = <3>; From owner-svn-src-head@freebsd.org Wed Apr 4 13:08:52 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8664EF8D450; Wed, 4 Apr 2018 13:08:52 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 30A3A79C9C; Wed, 4 Apr 2018 13:08:52 +0000 (UTC) (envelope-from mw@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 261A81414B; Wed, 4 Apr 2018 13:08:52 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34D8q1d055325; Wed, 4 Apr 2018 13:08:52 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34D8pMu055318; Wed, 4 Apr 2018 13:08:51 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804041308.w34D8pMu055318@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 4 Apr 2018 13:08:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332020 - head/sys/arm/mv X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/arm/mv X-SVN-Commit-Revision: 332020 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 13:08:52 -0000 Author: mw Date: Wed Apr 4 13:08:51 2018 New Revision: 332020 URL: https://svnweb.freebsd.org/changeset/base/332020 Log: Introduce port debouncing mechanism in mv_gpio driver This patch introduces gpio debouncing mechanism with fixed memory allocation in critical section. When you press button, value at gpio pin connected to button is changing many times which will cause in unexpected behaviour. Debouncing mechanism will prevent this phenomenon Submitted by: Patryk Duda Wojciech Macek Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14753 Modified: head/sys/arm/mv/gpio.c head/sys/arm/mv/mvreg.h head/sys/arm/mv/mvvar.h Modified: head/sys/arm/mv/gpio.c ============================================================================== --- head/sys/arm/mv/gpio.c Wed Apr 4 13:01:14 2018 (r332019) +++ head/sys/arm/mv/gpio.c Wed Apr 4 13:08:51 2018 (r332020) @@ -3,6 +3,7 @@ * * Copyright (c) 2006 Benno Rice. * Copyright (C) 2008 MARVELL INTERNATIONAL LTD. + * Copyright (c) 2017 Semihalf. * All rights reserved. * * Adapted and extended for Marvell SoCs by Semihalf. @@ -45,6 +46,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -58,13 +61,26 @@ __FBSDID("$FreeBSD$"); #define GPIO_MAX_INTR_COUNT 8 #define GPIO_PINS_PER_REG 32 +#define DEBOUNCE_CHECK_MS 1 +#define DEBOUNCE_LO_HI_MS 2 +#define DEBOUNCE_HI_LO_MS 2 +#define DEBOUNCE_CHECK_TICKS ((hz / 1000) * DEBOUNCE_CHECK_MS) + struct mv_gpio_softc { struct resource * res[GPIO_MAX_INTR_COUNT + 1]; void *ih_cookie[GPIO_MAX_INTR_COUNT]; bus_space_tag_t bst; bus_space_handle_t bsh; + struct mtx mutex; uint8_t pin_num; /* number of GPIO pins */ uint8_t irq_num; /* number of real IRQs occupied by GPIO controller */ + uint8_t use_high; + + /* Used for debouncing. */ + uint32_t debounced_state_lo; + uint32_t debounced_state_hi; + struct callout **debounce_callouts; + int *debounce_counters; }; extern struct resource_spec mv_gpio_res[]; @@ -77,6 +93,17 @@ static int mv_gpio_attach(device_t); static int mv_gpio_intr(void *); static int mv_gpio_init(void); +static void mv_gpio_double_edge_init(int pin); + +static int mv_gpio_debounce_setup(int pin); +static int mv_gpio_debounce_init(int pin); +static void mv_gpio_debounce_start(int pin); +static int mv_gpio_debounce_prepare(int pin); +static void mv_gpio_debounce(void *arg); +static void mv_gpio_debounced_state_set(int pin, uint8_t new_state); +static uint32_t mv_gpio_debounced_state_get(int pin); + +static void mv_gpio_exec_intr_handlers(uint32_t status, int high); static void mv_gpio_intr_handler(int pin); static uint32_t mv_gpio_reg_read(uint32_t reg); static void mv_gpio_reg_write(uint32_t reg, uint32_t val); @@ -84,14 +111,18 @@ static void mv_gpio_reg_set(uint32_t reg, uint32_t val static void mv_gpio_reg_clear(uint32_t reg, uint32_t val); static void mv_gpio_blink(uint32_t pin, uint8_t enable); -static void mv_gpio_polarity(uint32_t pin, uint8_t enable); +static void mv_gpio_polarity(uint32_t pin, uint8_t enable, uint8_t toggle); static void mv_gpio_level(uint32_t pin, uint8_t enable); static void mv_gpio_edge(uint32_t pin, uint8_t enable); static void mv_gpio_out_en(uint32_t pin, uint8_t enable); static void mv_gpio_int_ack(uint32_t pin); static void mv_gpio_value_set(uint32_t pin, uint8_t val); -static uint32_t mv_gpio_value_get(uint32_t pin); +static uint32_t mv_gpio_value_get(uint32_t pin, uint8_t exclude_polar); +#define MV_GPIO_LOCK() mtx_lock_spin(&mv_gpio_softc->mutex) +#define MV_GPIO_UNLOCK() mtx_unlock_spin(&mv_gpio_softc->mutex) +#define MV_GPIO_ASSERT_LOCKED() mtx_assert(&mv_gpio_softc->mutex, MA_OWNED) + static device_method_t mv_gpio_methods[] = { DEVMETHOD(device_probe, mv_gpio_probe), DEVMETHOD(device_attach, mv_gpio_attach), @@ -148,6 +179,8 @@ mv_gpio_attach(device_t dev) if (sc == NULL) return (ENXIO); + if (mv_gpio_softc != NULL) + return (ENXIO); mv_gpio_softc = sc; /* Get chip id and revision */ @@ -159,19 +192,34 @@ mv_gpio_attach(device_t dev) dev_id == MV_DEV_MV78100_Z0 ) { sc->pin_num = 32; sc->irq_num = 4; + sc->use_high = 0; } else if (dev_id == MV_DEV_88F6281 || dev_id == MV_DEV_88F6282) { sc->pin_num = 50; sc->irq_num = 7; + sc->use_high = 1; } else { device_printf(dev, "unknown chip id=0x%x\n", dev_id); return (ENXIO); } + sc->debounce_callouts = (struct callout **)malloc(sc->pin_num * + sizeof(struct callout *), M_DEVBUF, M_WAITOK | M_ZERO); + if (sc->debounce_callouts == NULL) + return (ENOMEM); + + sc->debounce_counters = (int *)malloc(sc->pin_num * sizeof(int), + M_DEVBUF, M_WAITOK); + if (sc->debounce_counters == NULL) + return (ENOMEM); + + mtx_init(&sc->mutex, device_get_nameunit(dev), NULL, MTX_SPIN); + error = bus_alloc_resources(dev, mv_gpio_res, sc->res); if (error) { + mtx_destroy(&sc->mutex); device_printf(dev, "could not allocate resources\n"); return (ENXIO); } @@ -179,12 +227,11 @@ mv_gpio_attach(device_t dev) sc->bst = rman_get_bustag(sc->res[0]); sc->bsh = rman_get_bushandle(sc->res[0]); - /* Disable and clear all interrupts */ + /* Disable all interrupts */ bus_space_write_4(sc->bst, sc->bsh, GPIO_INT_EDGE_MASK, 0); bus_space_write_4(sc->bst, sc->bsh, GPIO_INT_LEV_MASK, 0); - bus_space_write_4(sc->bst, sc->bsh, GPIO_INT_CAUSE, 0); - if (sc->pin_num > GPIO_PINS_PER_REG) { + if (sc->use_high) { bus_space_write_4(sc->bst, sc->bsh, GPIO_HI_INT_EDGE_MASK, 0); bus_space_write_4(sc->bst, sc->bsh, @@ -195,51 +242,67 @@ mv_gpio_attach(device_t dev) for (i = 0; i < sc->irq_num; i++) { if (bus_setup_intr(dev, sc->res[1 + i], - INTR_TYPE_MISC, mv_gpio_intr, NULL, + INTR_TYPE_MISC, + (driver_filter_t *)mv_gpio_intr, NULL, sc, &sc->ih_cookie[i]) != 0) { + mtx_destroy(&sc->mutex); bus_release_resources(dev, mv_gpio_res, sc->res); device_printf(dev, "could not set up intr %d\n", i); return (ENXIO); } } - return (mv_gpio_init()); + error = mv_gpio_init(); + if (error) { + device_printf(dev, "WARNING: failed to initialize GPIO pins, " + "error = %d\n", error); + } + + /* Clear interrupt status. */ + bus_space_write_4(sc->bst, sc->bsh, GPIO_INT_CAUSE, 0); + + return (0); } static int mv_gpio_intr(void *arg) { uint32_t int_cause, gpio_val; - uint32_t int_cause_hi, gpio_val_hi = 0; - int i; + uint32_t int_cause_hi, gpio_val_hi; + MV_GPIO_LOCK(); + + /* + * According to documentation, edge sensitive interrupts are asserted + * when unmasked GPIO_INT_CAUSE register bits are set. + */ int_cause = mv_gpio_reg_read(GPIO_INT_CAUSE); + int_cause &= mv_gpio_reg_read(GPIO_INT_EDGE_MASK); + + /* + * Level sensitive interrupts are asserted when unmasked GPIO_DATA_IN + * register bits are set. + */ gpio_val = mv_gpio_reg_read(GPIO_DATA_IN); - gpio_val &= int_cause; - if (mv_gpio_softc->pin_num > GPIO_PINS_PER_REG) { + gpio_val &= mv_gpio_reg_read(GPIO_INT_LEV_MASK); + + int_cause_hi = 0; + gpio_val_hi = 0; + if (mv_gpio_softc->use_high) { int_cause_hi = mv_gpio_reg_read(GPIO_HI_INT_CAUSE); + int_cause_hi &= mv_gpio_reg_read(GPIO_HI_INT_EDGE_MASK); + gpio_val_hi = mv_gpio_reg_read(GPIO_HI_DATA_IN); - gpio_val_hi &= int_cause_hi; + gpio_val_hi &= mv_gpio_reg_read(GPIO_HI_INT_LEV_MASK); } - i = 0; - while (gpio_val != 0) { - if (gpio_val & 1) - mv_gpio_intr_handler(i); - gpio_val >>= 1; - i++; - } + mv_gpio_exec_intr_handlers(int_cause | gpio_val, 0); - if (mv_gpio_softc->pin_num > GPIO_PINS_PER_REG) { - i = 0; - while (gpio_val_hi != 0) { - if (gpio_val_hi & 1) - mv_gpio_intr_handler(i + GPIO_PINS_PER_REG); - gpio_val_hi >>= 1; - i++; - } - } + if (mv_gpio_softc->use_high) + mv_gpio_exec_intr_handlers(int_cause_hi | gpio_val_hi, 1); + MV_GPIO_UNLOCK(); + return (FILTER_HANDLED); } @@ -260,6 +323,17 @@ mv_gpio_setup_intrhandler(const char *name, driver_fil return (ENXIO); event = gpio_events[pin]; if (event == NULL) { + MV_GPIO_LOCK(); + if (gpio_setup[pin] & MV_GPIO_IN_DEBOUNCE) { + error = mv_gpio_debounce_init(pin); + if (error != 0) { + MV_GPIO_UNLOCK(); + return (error); + } + } else if (gpio_setup[pin] & MV_GPIO_IN_IRQ_DOUBLE_EDGE) + mv_gpio_double_edge_init(pin); + MV_GPIO_UNLOCK(); + error = intr_event_create(&event, (void *)pin, 0, pin, (void (*)(void *))mv_gpio_intr_mask, (void (*)(void *))mv_gpio_intr_unmask, @@ -283,10 +357,22 @@ mv_gpio_intr_mask(int pin) if (pin >= mv_gpio_softc->pin_num) return; - if (gpio_setup[pin] & MV_GPIO_IN_IRQ_EDGE) + MV_GPIO_LOCK(); + + if (gpio_setup[pin] & (MV_GPIO_IN_IRQ_EDGE | MV_GPIO_IN_IRQ_DOUBLE_EDGE)) mv_gpio_edge(pin, 0); else mv_gpio_level(pin, 0); + + /* + * The interrupt has to be acknowledged before scheduling an interrupt + * thread. This way we allow for interrupt source to trigger again + * (which can happen with shared IRQs e.g. PCI) while processing the + * current event. + */ + mv_gpio_int_ack(pin); + + MV_GPIO_UNLOCK(); } void @@ -296,17 +382,47 @@ mv_gpio_intr_unmask(int pin) if (pin >= mv_gpio_softc->pin_num) return; - if (gpio_setup[pin] & MV_GPIO_IN_IRQ_EDGE) + MV_GPIO_LOCK(); + + if (gpio_setup[pin] & (MV_GPIO_IN_IRQ_EDGE | MV_GPIO_IN_IRQ_DOUBLE_EDGE)) mv_gpio_edge(pin, 1); else mv_gpio_level(pin, 1); + + MV_GPIO_UNLOCK(); } static void +mv_gpio_exec_intr_handlers(uint32_t status, int high) +{ + int i, pin; + + MV_GPIO_ASSERT_LOCKED(); + + i = 0; + while (status != 0) { + if (status & 1) { + pin = (high ? (i + GPIO_PINS_PER_REG) : i); + if (gpio_setup[pin] & MV_GPIO_IN_DEBOUNCE) + mv_gpio_debounce_start(pin); + else if (gpio_setup[pin] & MV_GPIO_IN_IRQ_DOUBLE_EDGE) { + mv_gpio_polarity(pin, 0, 1); + mv_gpio_intr_handler(pin); + } else + mv_gpio_intr_handler(pin); + } + status >>= 1; + i++; + } +} + +static void mv_gpio_intr_handler(int pin) { struct intr_event *event; + MV_GPIO_ASSERT_LOCKED(); + event = gpio_events[pin]; if (event == NULL || TAILQ_EMPTY(&event->ie_handlers)) return; @@ -314,40 +430,286 @@ mv_gpio_intr_handler(int pin) intr_event_handle(event, NULL); } -static int -mv_gpio_configure(uint32_t pin, uint32_t flags) +int +mv_gpio_configure(uint32_t pin, uint32_t flags, uint32_t mask) { + int error; if (pin >= mv_gpio_softc->pin_num) return (EINVAL); - if (flags & MV_GPIO_OUT_BLINK) - mv_gpio_blink(pin, 1); - if (flags & MV_GPIO_IN_POL_LOW) - mv_gpio_polarity(pin, 1); - if (flags & MV_GPIO_IN_IRQ_EDGE) - mv_gpio_edge(pin, 1); - if (flags & MV_GPIO_IN_IRQ_LEVEL) - mv_gpio_level(pin, 1); + /* check flags consistency */ + if (((flags & mask) & (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) == + (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)) + return (EINVAL); - gpio_setup[pin] = flags; + if (mask & MV_GPIO_IN_DEBOUNCE) { + error = mv_gpio_debounce_prepare(pin); + if (error != 0) + return (error); + } + MV_GPIO_LOCK(); + + if (mask & MV_GPIO_OUT_BLINK) + mv_gpio_blink(pin, flags & MV_GPIO_OUT_BLINK); + if (mask & MV_GPIO_IN_POL_LOW) + mv_gpio_polarity(pin, flags & MV_GPIO_IN_POL_LOW, 0); + if (mask & MV_GPIO_IN_DEBOUNCE) { + error = mv_gpio_debounce_setup(pin); + if (error) { + MV_GPIO_UNLOCK(); + return (error); + } + } + + gpio_setup[pin] &= ~(mask); + gpio_setup[pin] |= (flags & mask); + + MV_GPIO_UNLOCK(); + return (0); } +static void +mv_gpio_double_edge_init(int pin) +{ + uint8_t raw_read; + + MV_GPIO_ASSERT_LOCKED(); + + raw_read = (mv_gpio_value_get(pin, 1) ? 1 : 0); + + if (raw_read) + mv_gpio_polarity(pin, 1, 0); + else + mv_gpio_polarity(pin, 0, 0); +} + +static int +mv_gpio_debounce_setup(int pin) +{ + struct callout *c; + + MV_GPIO_ASSERT_LOCKED(); + + c = mv_gpio_softc->debounce_callouts[pin]; + if (c == NULL) + return (ENXIO); + + if (callout_active(c)) + callout_deactivate(c); + + callout_stop(c); + + return (0); +} + +static int +mv_gpio_debounce_prepare(int pin) +{ + struct callout *c; + struct mv_gpio_softc *sc; + + sc = (struct mv_gpio_softc *)mv_gpio_softc; + + c = sc->debounce_callouts[pin]; + if (c == NULL) { + c = (struct callout *)malloc(sizeof(struct callout), + M_DEVBUF, M_WAITOK); + sc->debounce_callouts[pin] = c; + if (c == NULL) + return (ENOMEM); + callout_init(c, 1); + } + + return (0); +} + +static int +mv_gpio_debounce_init(int pin) +{ + uint8_t raw_read; + int *cnt; + + MV_GPIO_ASSERT_LOCKED(); + + cnt = &mv_gpio_softc->debounce_counters[pin]; + + raw_read = (mv_gpio_value_get(pin, 1) ? 1 : 0); + if (raw_read) { + mv_gpio_polarity(pin, 1, 0); + *cnt = DEBOUNCE_HI_LO_MS / DEBOUNCE_CHECK_MS; + } else { + mv_gpio_polarity(pin, 0, 0); + *cnt = DEBOUNCE_LO_HI_MS / DEBOUNCE_CHECK_MS; + } + + mv_gpio_debounced_state_set(pin, raw_read); + + return (0); +} + +static void +mv_gpio_debounce_start(int pin) +{ + struct callout *c; + int *debounced_pin; + + MV_GPIO_ASSERT_LOCKED(); + + c = mv_gpio_softc->debounce_callouts[pin]; + if (c == NULL) { + mv_gpio_int_ack(pin); + return; + } + + if (callout_pending(c) || callout_active(c)) { + mv_gpio_int_ack(pin); + return; + } + + debounced_pin = (int *)malloc(sizeof(int), M_DEVBUF, + M_WAITOK); + if (debounced_pin == NULL) { + mv_gpio_int_ack(pin); + return; + } + *debounced_pin = pin; + + callout_reset(c, DEBOUNCE_CHECK_TICKS, mv_gpio_debounce, + debounced_pin); +} + +static void +mv_gpio_debounce(void *arg) +{ + uint8_t raw_read, last_state; + int pin; + int *debounce_counter; + + pin = *((int *)arg); + + MV_GPIO_LOCK(); + + raw_read = (mv_gpio_value_get(pin, 1) ? 1 : 0); + last_state = (mv_gpio_debounced_state_get(pin) ? 1 : 0); + debounce_counter = &mv_gpio_softc->debounce_counters[pin]; + + if (raw_read == last_state) { + if (last_state) + *debounce_counter = DEBOUNCE_HI_LO_MS / + DEBOUNCE_CHECK_MS; + else + *debounce_counter = DEBOUNCE_LO_HI_MS / + DEBOUNCE_CHECK_MS; + + callout_reset(mv_gpio_softc->debounce_callouts[pin], + DEBOUNCE_CHECK_TICKS, mv_gpio_debounce, arg); + } else { + *debounce_counter = *debounce_counter - 1; + if (*debounce_counter != 0) + callout_reset(mv_gpio_softc->debounce_callouts[pin], + DEBOUNCE_CHECK_TICKS, mv_gpio_debounce, arg); + else { + mv_gpio_debounced_state_set(pin, raw_read); + + if (last_state) + *debounce_counter = DEBOUNCE_HI_LO_MS / + DEBOUNCE_CHECK_MS; + else + *debounce_counter = DEBOUNCE_LO_HI_MS / + DEBOUNCE_CHECK_MS; + + if (((gpio_setup[pin] & MV_GPIO_IN_POL_LOW) && + (raw_read == 0)) || + (((gpio_setup[pin] & MV_GPIO_IN_POL_LOW) == 0) && + raw_read) || + (gpio_setup[pin] & MV_GPIO_IN_IRQ_DOUBLE_EDGE)) + mv_gpio_intr_handler(pin); + + /* Toggle polarity for next edge. */ + mv_gpio_polarity(pin, 0, 1); + + free(arg, M_DEVBUF); + callout_deactivate(mv_gpio_softc-> + debounce_callouts[pin]); + } + } + + MV_GPIO_UNLOCK(); +} + +static void +mv_gpio_debounced_state_set(int pin, uint8_t new_state) +{ + uint32_t *old_state; + + MV_GPIO_ASSERT_LOCKED(); + + if (pin >= GPIO_PINS_PER_REG) { + old_state = &mv_gpio_softc->debounced_state_hi; + pin -= GPIO_PINS_PER_REG; + } else + old_state = &mv_gpio_softc->debounced_state_lo; + + if (new_state) + *old_state |= (1 << pin); + else + *old_state &= ~(1 << pin); +} + +static uint32_t +mv_gpio_debounced_state_get(int pin) +{ + uint32_t *state; + + MV_GPIO_ASSERT_LOCKED(); + + if (pin >= GPIO_PINS_PER_REG) { + state = &mv_gpio_softc->debounced_state_hi; + pin -= GPIO_PINS_PER_REG; + } else + state = &mv_gpio_softc->debounced_state_lo; + + return (*state & (1 << pin)); +} + void mv_gpio_out(uint32_t pin, uint8_t val, uint8_t enable) { + MV_GPIO_LOCK(); + mv_gpio_value_set(pin, val); mv_gpio_out_en(pin, enable); + + MV_GPIO_UNLOCK(); } uint8_t mv_gpio_in(uint32_t pin) { + uint8_t state; - return (mv_gpio_value_get(pin) ? 1 : 0); + MV_GPIO_LOCK(); + + if (gpio_setup[pin] & MV_GPIO_IN_DEBOUNCE) { + if (gpio_setup[pin] & MV_GPIO_IN_POL_LOW) + state = (mv_gpio_debounced_state_get(pin) ? 0 : 1); + else + state = (mv_gpio_debounced_state_get(pin) ? 1 : 0); + } else if (gpio_setup[pin] & MV_GPIO_IN_IRQ_DOUBLE_EDGE) { + if (gpio_setup[pin] & MV_GPIO_IN_POL_LOW) + state = (mv_gpio_value_get(pin, 1) ? 0 : 1); + else + state = (mv_gpio_value_get(pin, 1) ? 1 : 0); + } else + state = (mv_gpio_value_get(pin, 0) ? 1 : 0); + + MV_GPIO_UNLOCK(); + + return (state); } static uint32_t @@ -427,9 +789,9 @@ mv_gpio_blink(uint32_t pin, uint8_t enable) } static void -mv_gpio_polarity(uint32_t pin, uint8_t enable) +mv_gpio_polarity(uint32_t pin, uint8_t enable, uint8_t toggle) { - uint32_t reg; + uint32_t reg, reg_val; if (pin >= mv_gpio_softc->pin_num) return; @@ -440,7 +802,13 @@ mv_gpio_polarity(uint32_t pin, uint8_t enable) } else reg = GPIO_DATA_IN_POLAR; - if (enable) + if (toggle) { + reg_val = mv_gpio_reg_read(reg) & GPIO(pin); + if (reg_val) + mv_gpio_reg_clear(reg, pin); + else + mv_gpio_reg_set(reg, pin); + } else if (enable) mv_gpio_reg_set(reg, pin); else mv_gpio_reg_clear(reg, pin); @@ -504,9 +872,9 @@ mv_gpio_int_ack(uint32_t pin) } static uint32_t -mv_gpio_value_get(uint32_t pin) +mv_gpio_value_get(uint32_t pin, uint8_t exclude_polar) { - uint32_t reg, reg_val; + uint32_t reg, polar_reg, reg_val, polar_reg_val; if (pin >= mv_gpio_softc->pin_num) return (0); @@ -514,12 +882,19 @@ mv_gpio_value_get(uint32_t pin) if (pin >= GPIO_PINS_PER_REG) { reg = GPIO_HI_DATA_IN; pin -= GPIO_PINS_PER_REG; - } else + polar_reg = GPIO_HI_DATA_IN_POLAR; + } else { reg = GPIO_DATA_IN; + polar_reg = GPIO_DATA_IN_POLAR; + } reg_val = mv_gpio_reg_read(reg); - return (reg_val & GPIO(pin)); + if (exclude_polar) { + polar_reg_val = mv_gpio_reg_read(polar_reg); + return ((reg_val & GPIO(pin)) ^ (polar_reg_val & GPIO(pin))); + } else + return (reg_val & GPIO(pin)); } static void @@ -583,7 +958,7 @@ mv_handle_gpios_prop(phandle_t ctrl, pcell_t *gpios, i dir = gpios[1]; flags = gpios[2]; - mv_gpio_configure(pin, flags); + mv_gpio_configure(pin, flags, ~0); if (dir == 1) /* Input. */ Modified: head/sys/arm/mv/mvreg.h ============================================================================== --- head/sys/arm/mv/mvreg.h Wed Apr 4 13:01:14 2018 (r332019) +++ head/sys/arm/mv/mvreg.h Wed Apr 4 13:08:51 2018 (r332020) @@ -308,14 +308,16 @@ #define GPIO(n) (1 << (n)) #define MV_GPIO_MAX_NPINS 64 -#define MV_GPIO_IN_NONE 0x0 -#define MV_GPIO_IN_POL_LOW (1 << 16) -#define MV_GPIO_IN_IRQ_EDGE (2 << 16) -#define MV_GPIO_IN_IRQ_LEVEL (4 << 16) -#define MV_GPIO_OUT_NONE 0x0 -#define MV_GPIO_OUT_BLINK 0x1 -#define MV_GPIO_OUT_OPEN_DRAIN 0x2 -#define MV_GPIO_OUT_OPEN_SRC 0x4 +#define MV_GPIO_IN_NONE 0x0 +#define MV_GPIO_IN_POL_LOW (1 << 16) +#define MV_GPIO_IN_IRQ_EDGE (2 << 16) +#define MV_GPIO_IN_IRQ_LEVEL (4 << 16) +#define MV_GPIO_IN_IRQ_DOUBLE_EDGE (8 << 16) +#define MV_GPIO_IN_DEBOUNCE (16 << 16) +#define MV_GPIO_OUT_NONE 0x0 +#define MV_GPIO_OUT_BLINK 0x1 +#define MV_GPIO_OUT_OPEN_DRAIN 0x2 +#define MV_GPIO_OUT_OPEN_SRC 0x4 #define IS_GPIO_IRQ(irq) ((irq) >= NIRQ && (irq) < NIRQ + MV_GPIO_MAX_NPINS) #define GPIO2IRQ(gpio) ((gpio) + NIRQ) Modified: head/sys/arm/mv/mvvar.h ============================================================================== --- head/sys/arm/mv/mvvar.h Wed Apr 4 13:01:14 2018 (r332019) +++ head/sys/arm/mv/mvvar.h Wed Apr 4 13:08:51 2018 (r332020) @@ -88,6 +88,7 @@ int mv_gpio_setup_intrhandler(const char *name, driver void (*hand)(void *), void *arg, int pin, int flags, void **cookiep); void mv_gpio_intr_mask(int pin); void mv_gpio_intr_unmask(int pin); +int mv_gpio_configure(uint32_t pin, uint32_t flags, uint32_t mask); void mv_gpio_out(uint32_t pin, uint8_t val, uint8_t enable); uint8_t mv_gpio_in(uint32_t pin); From owner-svn-src-head@freebsd.org Wed Apr 4 13:12:51 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4EFAF8DA70; Wed, 4 Apr 2018 13:12:50 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7046E7A2AA; Wed, 4 Apr 2018 13:12:50 +0000 (UTC) (envelope-from mw@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 6B281142FA; Wed, 4 Apr 2018 13:12:50 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34DCoSx062710; Wed, 4 Apr 2018 13:12:50 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34DCoWm062707; Wed, 4 Apr 2018 13:12:50 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804041312.w34DCoWm062707@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 4 Apr 2018 13:12:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332021 - head/sys/arm/mv X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/arm/mv X-SVN-Commit-Revision: 332021 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 13:12:51 -0000 Author: mw Date: Wed Apr 4 13:12:49 2018 New Revision: 332021 URL: https://svnweb.freebsd.org/changeset/base/332021 Log: Improve interrupt and resource allocation in Marvell GPIO driver This patch adds support for more than one interrupts in GPIO controller. It reads necessary information (such as cell size) from FDT, so there are no magic numbers. Note that interrupts are still not working, but this patch makes one good step in correct direction Submitted by: Patryk Duda Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14754 Modified: head/sys/arm/mv/gpio.c head/sys/arm/mv/mvvar.h Modified: head/sys/arm/mv/gpio.c ============================================================================== --- head/sys/arm/mv/gpio.c Wed Apr 4 13:08:51 2018 (r332020) +++ head/sys/arm/mv/gpio.c Wed Apr 4 13:12:49 2018 (r332021) @@ -67,7 +67,10 @@ __FBSDID("$FreeBSD$"); #define DEBOUNCE_CHECK_TICKS ((hz / 1000) * DEBOUNCE_CHECK_MS) struct mv_gpio_softc { - struct resource * res[GPIO_MAX_INTR_COUNT + 1]; + struct resource * mem_res; + int mem_rid; + struct resource * irq_res[GPIO_MAX_INTR_COUNT]; + int irq_rid[GPIO_MAX_INTR_COUNT]; void *ih_cookie[GPIO_MAX_INTR_COUNT]; bus_space_tag_t bst; bus_space_handle_t bsh; @@ -83,8 +86,6 @@ struct mv_gpio_softc { int *debounce_counters; }; -extern struct resource_spec mv_gpio_res[]; - static struct mv_gpio_softc *mv_gpio_softc = NULL; static uint32_t gpio_setup[MV_GPIO_MAX_NPINS]; @@ -119,6 +120,15 @@ static void mv_gpio_int_ack(uint32_t pin); static void mv_gpio_value_set(uint32_t pin, uint8_t val); static uint32_t mv_gpio_value_get(uint32_t pin, uint8_t exclude_polar); +static void mv_gpio_intr_mask(int pin); +static void mv_gpio_intr_unmask(int pin); +int mv_gpio_setup_intrhandler(const char *name, driver_filter_t *filt, + void (*hand)(void *), void *arg, int pin, int flags, void **cookiep); + +int mv_gpio_configure(uint32_t pin, uint32_t flags, uint32_t mask); +void mv_gpio_out(uint32_t pin, uint8_t val, uint8_t enable); +uint8_t mv_gpio_in(uint32_t pin); + #define MV_GPIO_LOCK() mtx_lock_spin(&mv_gpio_softc->mutex) #define MV_GPIO_UNLOCK() mtx_unlock_spin(&mv_gpio_softc->mutex) #define MV_GPIO_ASSERT_LOCKED() mtx_assert(&mv_gpio_softc->mutex, MA_OWNED) @@ -171,9 +181,12 @@ mv_gpio_probe(device_t dev) static int mv_gpio_attach(device_t dev) { - int error, i; + int error, i, size; struct mv_gpio_softc *sc; uint32_t dev_id, rev_id; + pcell_t pincnt = 0; + pcell_t irq_cells = 0; + phandle_t iparent; sc = (struct mv_gpio_softc *)device_get_softc(dev); if (sc == NULL) @@ -201,10 +214,45 @@ mv_gpio_attach(device_t dev) sc->use_high = 1; } else { - device_printf(dev, "unknown chip id=0x%x\n", dev_id); + if (OF_getencprop(ofw_bus_get_node(dev), "pin-count", &pincnt, + sizeof(pcell_t)) >= 0 || + OF_getencprop(ofw_bus_get_node(dev), "ngpios", &pincnt, + sizeof(pcell_t)) >= 0) { + sc->pin_num = pincnt; + device_printf(dev, "%d pins available\n", sc->pin_num); + } else { + device_printf(dev, "ERROR: no pin-count entry found!\n"); + return (ENXIO); + } + } + + /* Find root interrupt controller */ + iparent = ofw_bus_find_iparent(ofw_bus_get_node(dev)); + if (iparent == 0) { + device_printf(dev, "No interrupt-parrent found. " + "Error in DTB\n"); return (ENXIO); + } else { + /* While at parent - store interrupt cells prop */ + if (OF_searchencprop(OF_node_from_xref(iparent), + "#interrupt-cells", &irq_cells, sizeof(irq_cells)) == -1) { + device_printf(dev, "DTB: Missing #interrupt-cells " + "property in interrupt parent node\n"); + return (ENXIO); + } } + size = OF_getproplen(ofw_bus_get_node(dev), "interrupts"); + if (size != -1) { + size = size / sizeof(pcell_t); + size = size / irq_cells; + sc->irq_num = size; + device_printf(dev, "%d IRQs available\n", sc->irq_num); + } else { + device_printf(dev, "ERROR: no interrupts entry found!\n"); + return (ENXIO); + } + sc->debounce_callouts = (struct callout **)malloc(sc->pin_num * sizeof(struct callout *), M_DEVBUF, M_WAITOK | M_ZERO); if (sc->debounce_callouts == NULL) @@ -217,16 +265,31 @@ mv_gpio_attach(device_t dev) mtx_init(&sc->mutex, device_get_nameunit(dev), NULL, MTX_SPIN); - error = bus_alloc_resources(dev, mv_gpio_res, sc->res); - if (error) { + sc->mem_rid = 0; + sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid, + RF_ACTIVE); + + if (!sc->mem_res) { mtx_destroy(&sc->mutex); - device_printf(dev, "could not allocate resources\n"); + device_printf(dev, "could not allocate memory window\n"); return (ENXIO); } - sc->bst = rman_get_bustag(sc->res[0]); - sc->bsh = rman_get_bushandle(sc->res[0]); + sc->bst = rman_get_bustag(sc->mem_res); + sc->bsh = rman_get_bushandle(sc->mem_res); + for (i = 0; i < sc->irq_num; i++) { + sc->irq_rid[i] = i; + sc->irq_res[i] = bus_alloc_resource_any(dev, SYS_RES_IRQ, + &sc->irq_rid[i], RF_ACTIVE); + if (!sc->irq_res[i]) { + mtx_destroy(&sc->mutex); + device_printf(dev, + "could not allocate gpio%d interrupt\n", i+1); + return (ENXIO); + } + } + /* Disable all interrupts */ bus_space_write_4(sc->bst, sc->bsh, GPIO_INT_EDGE_MASK, 0); bus_space_write_4(sc->bst, sc->bsh, GPIO_INT_LEV_MASK, 0); @@ -241,12 +304,13 @@ mv_gpio_attach(device_t dev) } for (i = 0; i < sc->irq_num; i++) { - if (bus_setup_intr(dev, sc->res[1 + i], + if (bus_setup_intr(dev, sc->irq_res[i], INTR_TYPE_MISC, (driver_filter_t *)mv_gpio_intr, NULL, sc, &sc->ih_cookie[i]) != 0) { mtx_destroy(&sc->mutex); - bus_release_resources(dev, mv_gpio_res, sc->res); + bus_release_resource(dev, SYS_RES_IRQ, + sc->irq_rid[i], sc->irq_res[i]); device_printf(dev, "could not set up intr %d\n", i); return (ENXIO); } @@ -419,15 +483,21 @@ mv_gpio_exec_intr_handlers(uint32_t status, int high) static void mv_gpio_intr_handler(int pin) { - struct intr_event *event; +#ifdef INTRNG + struct intr_irqsrc isrc; MV_GPIO_ASSERT_LOCKED(); - event = gpio_events[pin]; - if (event == NULL || TAILQ_EMPTY(&event->ie_handlers)) +#ifdef INTR_SOLO + isrc.isrc_filter = NULL; +#endif + isrc.isrc_event = gpio_events[pin]; + + if (isrc.isrc_event == NULL || TAILQ_EMPTY(&isrc.isrc_event->ie_handlers)) return; - intr_event_handle(event, NULL); + intr_isrc_dispatch(&isrc, NULL); +#endif } int Modified: head/sys/arm/mv/mvvar.h ============================================================================== --- head/sys/arm/mv/mvvar.h Wed Apr 4 13:08:51 2018 (r332020) +++ head/sys/arm/mv/mvvar.h Wed Apr 4 13:12:49 2018 (r332021) @@ -83,15 +83,6 @@ extern const struct decode_win *xor_wins; extern int idma_wins_no; extern int xor_wins_no; -/* Function prototypes */ -int mv_gpio_setup_intrhandler(const char *name, driver_filter_t *filt, - void (*hand)(void *), void *arg, int pin, int flags, void **cookiep); -void mv_gpio_intr_mask(int pin); -void mv_gpio_intr_unmask(int pin); -int mv_gpio_configure(uint32_t pin, uint32_t flags, uint32_t mask); -void mv_gpio_out(uint32_t pin, uint8_t val, uint8_t enable); -uint8_t mv_gpio_in(uint32_t pin); - int soc_decode_win(void); void soc_id(uint32_t *dev, uint32_t *rev); void soc_dump_decode_win(void); From owner-svn-src-head@freebsd.org Wed Apr 4 13:20:30 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D9560F8E372; Wed, 4 Apr 2018 13:20:29 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8D4987A96E; Wed, 4 Apr 2018 13:20:29 +0000 (UTC) (envelope-from mw@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 87EA81431A; Wed, 4 Apr 2018 13:20:29 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34DKTYP068128; Wed, 4 Apr 2018 13:20:29 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34DKTYS068126; Wed, 4 Apr 2018 13:20:29 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201804041320.w34DKTYS068126@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Wed, 4 Apr 2018 13:20:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332024 - head/sys/arm/mv X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/arm/mv X-SVN-Commit-Revision: 332024 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 13:20:30 -0000 Author: mw Date: Wed Apr 4 13:20:29 2018 New Revision: 332024 URL: https://svnweb.freebsd.org/changeset/base/332024 Log: Enable Marvell gpio driver to work with many controllers This patch moves all global data structures into mv_gpio_softc, and puts device_t parameter to functions calls everywhere where needed. As a result, we can create multiple driver instances. Removed names in function declaration to keep style. Submitted by: Patryk Duda Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14755 Modified: head/sys/arm/mv/gpio.c head/sys/arm/mv/mvreg.h Modified: head/sys/arm/mv/gpio.c ============================================================================== --- head/sys/arm/mv/gpio.c Wed Apr 4 13:16:00 2018 (r332023) +++ head/sys/arm/mv/gpio.c Wed Apr 4 13:20:29 2018 (r332024) @@ -71,13 +71,14 @@ struct mv_gpio_softc { int mem_rid; struct resource * irq_res[GPIO_MAX_INTR_COUNT]; int irq_rid[GPIO_MAX_INTR_COUNT]; + struct intr_event * gpio_events[MV_GPIO_MAX_NPINS]; void *ih_cookie[GPIO_MAX_INTR_COUNT]; bus_space_tag_t bst; bus_space_handle_t bsh; struct mtx mutex; uint8_t pin_num; /* number of GPIO pins */ uint8_t irq_num; /* number of real IRQs occupied by GPIO controller */ - uint8_t use_high; + struct gpio_pin gpio_setup[MV_GPIO_MAX_NPINS]; /* Used for debouncing. */ uint32_t debounced_state_lo; @@ -86,52 +87,56 @@ struct mv_gpio_softc { int *debounce_counters; }; -static struct mv_gpio_softc *mv_gpio_softc = NULL; -static uint32_t gpio_setup[MV_GPIO_MAX_NPINS]; +struct mv_gpio_pindev { + device_t dev; + int pin; +}; static int mv_gpio_probe(device_t); static int mv_gpio_attach(device_t); -static int mv_gpio_intr(void *); -static int mv_gpio_init(void); +static int mv_gpio_intr(device_t, void *); +static int mv_gpio_init(device_t); -static void mv_gpio_double_edge_init(int pin); +static void mv_gpio_double_edge_init(device_t, int); -static int mv_gpio_debounce_setup(int pin); -static int mv_gpio_debounce_init(int pin); -static void mv_gpio_debounce_start(int pin); -static int mv_gpio_debounce_prepare(int pin); -static void mv_gpio_debounce(void *arg); -static void mv_gpio_debounced_state_set(int pin, uint8_t new_state); -static uint32_t mv_gpio_debounced_state_get(int pin); +static int mv_gpio_debounce_setup(device_t, int); +static int mv_gpio_debounce_prepare(device_t, int); +static int mv_gpio_debounce_init(device_t, int); +static void mv_gpio_debounce_start(device_t, int); +static void mv_gpio_debounce(void *); +static void mv_gpio_debounced_state_set(device_t, int, uint8_t); +static uint32_t mv_gpio_debounced_state_get(device_t, int); -static void mv_gpio_exec_intr_handlers(uint32_t status, int high); -static void mv_gpio_intr_handler(int pin); -static uint32_t mv_gpio_reg_read(uint32_t reg); -static void mv_gpio_reg_write(uint32_t reg, uint32_t val); -static void mv_gpio_reg_set(uint32_t reg, uint32_t val); -static void mv_gpio_reg_clear(uint32_t reg, uint32_t val); +static void mv_gpio_exec_intr_handlers(device_t, uint32_t, int); +static void mv_gpio_intr_handler(device_t, int); +static uint32_t mv_gpio_reg_read(device_t, uint32_t); +static void mv_gpio_reg_write(device_t, uint32_t, uint32_t); +static void mv_gpio_reg_set(device_t, uint32_t, uint32_t); +static void mv_gpio_reg_clear(device_t, uint32_t, uint32_t); -static void mv_gpio_blink(uint32_t pin, uint8_t enable); -static void mv_gpio_polarity(uint32_t pin, uint8_t enable, uint8_t toggle); -static void mv_gpio_level(uint32_t pin, uint8_t enable); -static void mv_gpio_edge(uint32_t pin, uint8_t enable); -static void mv_gpio_out_en(uint32_t pin, uint8_t enable); -static void mv_gpio_int_ack(uint32_t pin); -static void mv_gpio_value_set(uint32_t pin, uint8_t val); -static uint32_t mv_gpio_value_get(uint32_t pin, uint8_t exclude_polar); +static void mv_gpio_blink(device_t, uint32_t, uint8_t); +static void mv_gpio_polarity(device_t, uint32_t, uint8_t, uint8_t); +static void mv_gpio_level(device_t, uint32_t, uint8_t); +static void mv_gpio_edge(device_t, uint32_t, uint8_t); +static void mv_gpio_out_en(device_t, uint32_t, uint8_t); +static void mv_gpio_int_ack(struct mv_gpio_pindev *); +static void mv_gpio_value_set(device_t, uint32_t, uint8_t); +static uint32_t mv_gpio_value_get(device_t, uint32_t, uint8_t); -static void mv_gpio_intr_mask(int pin); -static void mv_gpio_intr_unmask(int pin); -int mv_gpio_setup_intrhandler(const char *name, driver_filter_t *filt, - void (*hand)(void *), void *arg, int pin, int flags, void **cookiep); +static void mv_gpio_intr_mask(struct mv_gpio_pindev *); +static void mv_gpio_intr_unmask(struct mv_gpio_pindev *); -int mv_gpio_configure(uint32_t pin, uint32_t flags, uint32_t mask); -void mv_gpio_out(uint32_t pin, uint8_t val, uint8_t enable); -uint8_t mv_gpio_in(uint32_t pin); +void mv_gpio_finish_intrhandler(struct mv_gpio_pindev *); +int mv_gpio_setup_intrhandler(device_t, const char *, + driver_filter_t *, void (*)(void *), void *, + int, int, void **); +int mv_gpio_configure(device_t, uint32_t, uint32_t, uint32_t); +void mv_gpio_out(device_t, uint32_t, uint8_t, uint8_t); +uint8_t mv_gpio_in(device_t, uint32_t); -#define MV_GPIO_LOCK() mtx_lock_spin(&mv_gpio_softc->mutex) -#define MV_GPIO_UNLOCK() mtx_unlock_spin(&mv_gpio_softc->mutex) -#define MV_GPIO_ASSERT_LOCKED() mtx_assert(&mv_gpio_softc->mutex, MA_OWNED) +#define MV_GPIO_LOCK() mtx_lock_spin(&sc->mutex) +#define MV_GPIO_UNLOCK() mtx_unlock_spin(&sc->mutex) +#define MV_GPIO_ASSERT_LOCKED() mtx_assert(&sc->mutex, MA_OWNED) static device_method_t mv_gpio_methods[] = { DEVMETHOD(device_probe, mv_gpio_probe), @@ -149,14 +154,14 @@ static devclass_t mv_gpio_devclass; DRIVER_MODULE(gpio, simplebus, mv_gpio_driver, mv_gpio_devclass, 0, 0); -typedef int (*gpios_phandler_t)(phandle_t, pcell_t *, int); +typedef int (*gpios_phandler_t)(device_t, phandle_t, pcell_t *, int); struct gpio_ctrl_entry { const char *compat; gpios_phandler_t handler; }; -static int mv_handle_gpios_prop(phandle_t ctrl, pcell_t *gpios, int len); +static int mv_handle_gpios_prop(device_t, phandle_t, pcell_t *, int); int gpio_get_config_from_dt(void); struct gpio_ctrl_entry gpio_controllers[] = { @@ -192,10 +197,6 @@ mv_gpio_attach(device_t dev) if (sc == NULL) return (ENXIO); - if (mv_gpio_softc != NULL) - return (ENXIO); - mv_gpio_softc = sc; - /* Get chip id and revision */ soc_id(&dev_id, &rev_id); @@ -205,13 +206,11 @@ mv_gpio_attach(device_t dev) dev_id == MV_DEV_MV78100_Z0 ) { sc->pin_num = 32; sc->irq_num = 4; - sc->use_high = 0; } else if (dev_id == MV_DEV_88F6281 || dev_id == MV_DEV_88F6282) { sc->pin_num = 50; sc->irq_num = 7; - sc->use_high = 1; } else { if (OF_getencprop(ofw_bus_get_node(dev), "pin-count", &pincnt, @@ -294,15 +293,6 @@ mv_gpio_attach(device_t dev) bus_space_write_4(sc->bst, sc->bsh, GPIO_INT_EDGE_MASK, 0); bus_space_write_4(sc->bst, sc->bsh, GPIO_INT_LEV_MASK, 0); - if (sc->use_high) { - bus_space_write_4(sc->bst, sc->bsh, - GPIO_HI_INT_EDGE_MASK, 0); - bus_space_write_4(sc->bst, sc->bsh, - GPIO_HI_INT_LEV_MASK, 0); - bus_space_write_4(sc->bst, sc->bsh, - GPIO_HI_INT_CAUSE, 0); - } - for (i = 0; i < sc->irq_num; i++) { if (bus_setup_intr(dev, sc->irq_res[i], INTR_TYPE_MISC, @@ -316,7 +306,7 @@ mv_gpio_attach(device_t dev) } } - error = mv_gpio_init(); + error = mv_gpio_init(dev); if (error) { device_printf(dev, "WARNING: failed to initialize GPIO pins, " "error = %d\n", error); @@ -325,14 +315,18 @@ mv_gpio_attach(device_t dev) /* Clear interrupt status. */ bus_space_write_4(sc->bst, sc->bsh, GPIO_INT_CAUSE, 0); + device_add_child(dev, "gpioc", device_get_unit(dev)); + device_add_child(dev, "gpiobus", device_get_unit(dev)); + return (0); } static int -mv_gpio_intr(void *arg) +mv_gpio_intr(device_t dev, void *arg) { uint32_t int_cause, gpio_val; - uint32_t int_cause_hi, gpio_val_hi; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); MV_GPIO_LOCK(); @@ -340,31 +334,18 @@ mv_gpio_intr(void *arg) * According to documentation, edge sensitive interrupts are asserted * when unmasked GPIO_INT_CAUSE register bits are set. */ - int_cause = mv_gpio_reg_read(GPIO_INT_CAUSE); - int_cause &= mv_gpio_reg_read(GPIO_INT_EDGE_MASK); + int_cause = mv_gpio_reg_read(dev, GPIO_INT_CAUSE); + int_cause &= mv_gpio_reg_read(dev, GPIO_INT_EDGE_MASK); /* * Level sensitive interrupts are asserted when unmasked GPIO_DATA_IN * register bits are set. */ - gpio_val = mv_gpio_reg_read(GPIO_DATA_IN); - gpio_val &= mv_gpio_reg_read(GPIO_INT_LEV_MASK); + gpio_val = mv_gpio_reg_read(dev, GPIO_DATA_IN); + gpio_val &= mv_gpio_reg_read(dev, GPIO_INT_LEV_MASK); - int_cause_hi = 0; - gpio_val_hi = 0; - if (mv_gpio_softc->use_high) { - int_cause_hi = mv_gpio_reg_read(GPIO_HI_INT_CAUSE); - int_cause_hi &= mv_gpio_reg_read(GPIO_HI_INT_EDGE_MASK); + mv_gpio_exec_intr_handlers(dev, int_cause | gpio_val, 0); - gpio_val_hi = mv_gpio_reg_read(GPIO_HI_DATA_IN); - gpio_val_hi &= mv_gpio_reg_read(GPIO_HI_INT_LEV_MASK); - } - - mv_gpio_exec_intr_handlers(int_cause | gpio_val, 0); - - if (mv_gpio_softc->use_high) - mv_gpio_exec_intr_handlers(int_cause_hi | gpio_val_hi, 1); - MV_GPIO_UNLOCK(); return (FILTER_HANDLED); @@ -374,31 +355,47 @@ mv_gpio_intr(void *arg) * GPIO interrupt handling */ -static struct intr_event *gpio_events[MV_GPIO_MAX_NPINS]; +void +mv_gpio_finish_intrhandler(struct mv_gpio_pindev *s) +{ + /* When we acheive full interrupt support + * This function will be opposite to + * mv_gpio_setup_intrhandler + */ + /* Now it exists only to remind that + * there should be place to free mv_gpio_pindev + * allocated by mv_gpio_setup_intrhandler + */ + free(s, M_DEVBUF); +} + int -mv_gpio_setup_intrhandler(const char *name, driver_filter_t *filt, +mv_gpio_setup_intrhandler(device_t dev, const char *name, driver_filter_t *filt, void (*hand)(void *), void *arg, int pin, int flags, void **cookiep) { struct intr_event *event; int error; + struct mv_gpio_pindev *s; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); + s = malloc(sizeof(struct mv_gpio_pindev), M_DEVBUF, M_NOWAIT | M_ZERO); - if (pin < 0 || pin >= mv_gpio_softc->pin_num) + if (pin < 0 || pin >= sc->pin_num) return (ENXIO); - event = gpio_events[pin]; + event = sc->gpio_events[pin]; if (event == NULL) { MV_GPIO_LOCK(); - if (gpio_setup[pin] & MV_GPIO_IN_DEBOUNCE) { - error = mv_gpio_debounce_init(pin); + if (sc->gpio_setup[pin].gp_flags & MV_GPIO_IN_DEBOUNCE) { + error = mv_gpio_debounce_init(dev, pin); if (error != 0) { MV_GPIO_UNLOCK(); return (error); } - } else if (gpio_setup[pin] & MV_GPIO_IN_IRQ_DOUBLE_EDGE) - mv_gpio_double_edge_init(pin); + } else if (sc->gpio_setup[pin].gp_flags & MV_GPIO_IN_IRQ_DOUBLE_EDGE) + mv_gpio_double_edge_init(dev, pin); MV_GPIO_UNLOCK(); - - error = intr_event_create(&event, (void *)pin, 0, pin, + error = intr_event_create(&event, (void *)s, 0, pin, (void (*)(void *))mv_gpio_intr_mask, (void (*)(void *))mv_gpio_intr_unmask, (void (*)(void *))mv_gpio_int_ack, @@ -406,7 +403,7 @@ mv_gpio_setup_intrhandler(const char *name, driver_fil "gpio%d:", pin); if (error != 0) return (error); - gpio_events[pin] = event; + sc->gpio_events[pin] = event; } intr_event_add_handler(event, name, filt, hand, arg, @@ -414,19 +411,22 @@ mv_gpio_setup_intrhandler(const char *name, driver_fil return (0); } -void -mv_gpio_intr_mask(int pin) +static void +mv_gpio_intr_mask(struct mv_gpio_pindev *s) { + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(s->dev); - if (pin >= mv_gpio_softc->pin_num) + if (s->pin >= sc->pin_num) return; MV_GPIO_LOCK(); - if (gpio_setup[pin] & (MV_GPIO_IN_IRQ_EDGE | MV_GPIO_IN_IRQ_DOUBLE_EDGE)) - mv_gpio_edge(pin, 0); + if (sc->gpio_setup[s->pin].gp_flags & (MV_GPIO_IN_IRQ_EDGE | + MV_GPIO_IN_IRQ_DOUBLE_EDGE)) + mv_gpio_edge(s->dev, s->pin, 0); else - mv_gpio_level(pin, 0); + mv_gpio_level(s->dev, s->pin, 0); /* * The interrupt has to be acknowledged before scheduling an interrupt @@ -434,32 +434,41 @@ mv_gpio_intr_mask(int pin) * (which can happen with shared IRQs e.g. PCI) while processing the * current event. */ - mv_gpio_int_ack(pin); + mv_gpio_int_ack(s); MV_GPIO_UNLOCK(); + + return; } -void -mv_gpio_intr_unmask(int pin) +static void +mv_gpio_intr_unmask(struct mv_gpio_pindev *s) { + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(s->dev); - if (pin >= mv_gpio_softc->pin_num) + if (s->pin >= sc->pin_num) return; MV_GPIO_LOCK(); - if (gpio_setup[pin] & (MV_GPIO_IN_IRQ_EDGE | MV_GPIO_IN_IRQ_DOUBLE_EDGE)) - mv_gpio_edge(pin, 1); + if (sc->gpio_setup[s->pin].gp_flags & (MV_GPIO_IN_IRQ_EDGE | + MV_GPIO_IN_IRQ_DOUBLE_EDGE)) + mv_gpio_edge(s->dev, s->pin, 1); else - mv_gpio_level(pin, 1); + mv_gpio_level(s->dev, s->pin, 1); MV_GPIO_UNLOCK(); + + return; } static void -mv_gpio_exec_intr_handlers(uint32_t status, int high) +mv_gpio_exec_intr_handlers(device_t dev, uint32_t status, int high) { int i, pin; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); MV_GPIO_ASSERT_LOCKED(); @@ -467,13 +476,13 @@ mv_gpio_exec_intr_handlers(uint32_t status, int high) while (status != 0) { if (status & 1) { pin = (high ? (i + GPIO_PINS_PER_REG) : i); - if (gpio_setup[pin] & MV_GPIO_IN_DEBOUNCE) - mv_gpio_debounce_start(pin); - else if (gpio_setup[pin] & MV_GPIO_IN_IRQ_DOUBLE_EDGE) { - mv_gpio_polarity(pin, 0, 1); - mv_gpio_intr_handler(pin); + if (sc->gpio_setup[pin].gp_flags & MV_GPIO_IN_DEBOUNCE) + mv_gpio_debounce_start(dev, pin); + else if (sc->gpio_setup[pin].gp_flags & MV_GPIO_IN_IRQ_DOUBLE_EDGE) { + mv_gpio_polarity(dev, pin, 0, 1); + mv_gpio_intr_handler(dev, pin); } else - mv_gpio_intr_handler(pin); + mv_gpio_intr_handler(dev, pin); } status >>= 1; i++; @@ -481,17 +490,19 @@ mv_gpio_exec_intr_handlers(uint32_t status, int high) } static void -mv_gpio_intr_handler(int pin) +mv_gpio_intr_handler(device_t dev, int pin) { #ifdef INTRNG struct intr_irqsrc isrc; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); MV_GPIO_ASSERT_LOCKED(); #ifdef INTR_SOLO isrc.isrc_filter = NULL; #endif - isrc.isrc_event = gpio_events[pin]; + isrc.isrc_event = sc->gpio_events[pin]; if (isrc.isrc_event == NULL || TAILQ_EMPTY(&isrc.isrc_event->ie_handlers)) return; @@ -501,11 +512,14 @@ mv_gpio_intr_handler(int pin) } int -mv_gpio_configure(uint32_t pin, uint32_t flags, uint32_t mask) +mv_gpio_configure(device_t dev, uint32_t pin, uint32_t flags, uint32_t mask) { int error; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); + error = 0; - if (pin >= mv_gpio_softc->pin_num) + if (pin >= sc->pin_num) return (EINVAL); /* check flags consistency */ @@ -514,7 +528,7 @@ mv_gpio_configure(uint32_t pin, uint32_t flags, uint32 return (EINVAL); if (mask & MV_GPIO_IN_DEBOUNCE) { - error = mv_gpio_debounce_prepare(pin); + error = mv_gpio_debounce_prepare(dev, pin); if (error != 0) return (error); } @@ -522,19 +536,19 @@ mv_gpio_configure(uint32_t pin, uint32_t flags, uint32 MV_GPIO_LOCK(); if (mask & MV_GPIO_OUT_BLINK) - mv_gpio_blink(pin, flags & MV_GPIO_OUT_BLINK); + mv_gpio_blink(dev, pin, flags & MV_GPIO_OUT_BLINK); if (mask & MV_GPIO_IN_POL_LOW) - mv_gpio_polarity(pin, flags & MV_GPIO_IN_POL_LOW, 0); + mv_gpio_polarity(dev, pin, flags & MV_GPIO_IN_POL_LOW, 0); if (mask & MV_GPIO_IN_DEBOUNCE) { - error = mv_gpio_debounce_setup(pin); + error = mv_gpio_debounce_setup(dev, pin); if (error) { MV_GPIO_UNLOCK(); return (error); } } - gpio_setup[pin] &= ~(mask); - gpio_setup[pin] |= (flags & mask); + sc->gpio_setup[pin].gp_flags &= ~(mask); + sc->gpio_setup[pin].gp_flags |= (flags & mask); MV_GPIO_UNLOCK(); @@ -542,28 +556,33 @@ mv_gpio_configure(uint32_t pin, uint32_t flags, uint32 } static void -mv_gpio_double_edge_init(int pin) +mv_gpio_double_edge_init(device_t dev, int pin) { uint8_t raw_read; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); MV_GPIO_ASSERT_LOCKED(); - raw_read = (mv_gpio_value_get(pin, 1) ? 1 : 0); + raw_read = (mv_gpio_value_get(dev, pin, 1) ? 1 : 0); if (raw_read) - mv_gpio_polarity(pin, 1, 0); + mv_gpio_polarity(dev, pin, 1, 0); else - mv_gpio_polarity(pin, 0, 0); + mv_gpio_polarity(dev, pin, 0, 0); } static int -mv_gpio_debounce_setup(int pin) +mv_gpio_debounce_setup(device_t dev, int pin) { struct callout *c; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); + MV_GPIO_ASSERT_LOCKED(); - c = mv_gpio_softc->debounce_callouts[pin]; + c = sc->debounce_callouts[pin]; if (c == NULL) return (ENXIO); @@ -576,12 +595,12 @@ mv_gpio_debounce_setup(int pin) } static int -mv_gpio_debounce_prepare(int pin) +mv_gpio_debounce_prepare(device_t dev, int pin) { struct callout *c; struct mv_gpio_softc *sc; - sc = (struct mv_gpio_softc *)mv_gpio_softc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); c = sc->debounce_callouts[pin]; if (c == NULL) { @@ -597,58 +616,63 @@ mv_gpio_debounce_prepare(int pin) } static int -mv_gpio_debounce_init(int pin) +mv_gpio_debounce_init(device_t dev, int pin) { uint8_t raw_read; int *cnt; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); + MV_GPIO_ASSERT_LOCKED(); - cnt = &mv_gpio_softc->debounce_counters[pin]; - - raw_read = (mv_gpio_value_get(pin, 1) ? 1 : 0); + cnt = &sc->debounce_counters[pin]; + raw_read = (mv_gpio_value_get(dev, pin, 1) ? 1 : 0); if (raw_read) { - mv_gpio_polarity(pin, 1, 0); + mv_gpio_polarity(dev, pin, 1, 0); *cnt = DEBOUNCE_HI_LO_MS / DEBOUNCE_CHECK_MS; } else { - mv_gpio_polarity(pin, 0, 0); + mv_gpio_polarity(dev, pin, 0, 0); *cnt = DEBOUNCE_LO_HI_MS / DEBOUNCE_CHECK_MS; } - mv_gpio_debounced_state_set(pin, raw_read); + mv_gpio_debounced_state_set(dev, pin, raw_read); return (0); } static void -mv_gpio_debounce_start(int pin) +mv_gpio_debounce_start(device_t dev, int pin) { struct callout *c; - int *debounced_pin; + struct mv_gpio_pindev s = {dev, pin}; + struct mv_gpio_pindev *sd; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); MV_GPIO_ASSERT_LOCKED(); - c = mv_gpio_softc->debounce_callouts[pin]; + c = sc->debounce_callouts[pin]; if (c == NULL) { - mv_gpio_int_ack(pin); + mv_gpio_int_ack(&s); return; } if (callout_pending(c) || callout_active(c)) { - mv_gpio_int_ack(pin); + mv_gpio_int_ack(&s); return; } - debounced_pin = (int *)malloc(sizeof(int), M_DEVBUF, - M_WAITOK); - if (debounced_pin == NULL) { - mv_gpio_int_ack(pin); + sd = (struct mv_gpio_pindev *)malloc(sizeof(struct mv_gpio_pindev), + M_DEVBUF, M_WAITOK); + if (sd == NULL) { + mv_gpio_int_ack(&s); return; } - *debounced_pin = pin; + sd->pin = pin; + sd->dev = dev; - callout_reset(c, DEBOUNCE_CHECK_TICKS, mv_gpio_debounce, - debounced_pin); + callout_reset(c, DEBOUNCE_CHECK_TICKS, mv_gpio_debounce, sd); } static void @@ -656,15 +680,21 @@ mv_gpio_debounce(void *arg) { uint8_t raw_read, last_state; int pin; + device_t dev; int *debounce_counter; + struct mv_gpio_softc *sc; + struct mv_gpio_pindev *s; - pin = *((int *)arg); + s = (struct mv_gpio_pindev *)arg; + dev = s->dev; + pin = s->pin; + sc = (struct mv_gpio_softc *)device_get_softc(dev); MV_GPIO_LOCK(); - raw_read = (mv_gpio_value_get(pin, 1) ? 1 : 0); - last_state = (mv_gpio_debounced_state_get(pin) ? 1 : 0); - debounce_counter = &mv_gpio_softc->debounce_counters[pin]; + raw_read = (mv_gpio_value_get(dev, pin, 1) ? 1 : 0); + last_state = (mv_gpio_debounced_state_get(dev, pin) ? 1 : 0); + debounce_counter = &sc->debounce_counters[pin]; if (raw_read == last_state) { if (last_state) @@ -674,15 +704,15 @@ mv_gpio_debounce(void *arg) *debounce_counter = DEBOUNCE_LO_HI_MS / DEBOUNCE_CHECK_MS; - callout_reset(mv_gpio_softc->debounce_callouts[pin], + callout_reset(sc->debounce_callouts[pin], DEBOUNCE_CHECK_TICKS, mv_gpio_debounce, arg); } else { *debounce_counter = *debounce_counter - 1; if (*debounce_counter != 0) - callout_reset(mv_gpio_softc->debounce_callouts[pin], + callout_reset(sc->debounce_callouts[pin], DEBOUNCE_CHECK_TICKS, mv_gpio_debounce, arg); else { - mv_gpio_debounced_state_set(pin, raw_read); + mv_gpio_debounced_state_set(dev, pin, raw_read); if (last_state) *debounce_counter = DEBOUNCE_HI_LO_MS / @@ -691,19 +721,18 @@ mv_gpio_debounce(void *arg) *debounce_counter = DEBOUNCE_LO_HI_MS / DEBOUNCE_CHECK_MS; - if (((gpio_setup[pin] & MV_GPIO_IN_POL_LOW) && + if (((sc->gpio_setup[pin].gp_flags & MV_GPIO_IN_POL_LOW) && (raw_read == 0)) || - (((gpio_setup[pin] & MV_GPIO_IN_POL_LOW) == 0) && + (((sc->gpio_setup[pin].gp_flags & MV_GPIO_IN_POL_LOW) == 0) && raw_read) || - (gpio_setup[pin] & MV_GPIO_IN_IRQ_DOUBLE_EDGE)) - mv_gpio_intr_handler(pin); + (sc->gpio_setup[pin].gp_flags & MV_GPIO_IN_IRQ_DOUBLE_EDGE)) + mv_gpio_intr_handler(dev, pin); /* Toggle polarity for next edge. */ - mv_gpio_polarity(pin, 0, 1); + mv_gpio_polarity(dev, pin, 0, 1); free(arg, M_DEVBUF); - callout_deactivate(mv_gpio_softc-> - debounce_callouts[pin]); + callout_deactivate(sc->debounce_callouts[pin]); } } @@ -711,17 +740,19 @@ mv_gpio_debounce(void *arg) } static void -mv_gpio_debounced_state_set(int pin, uint8_t new_state) +mv_gpio_debounced_state_set(device_t dev, int pin, uint8_t new_state) { uint32_t *old_state; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); MV_GPIO_ASSERT_LOCKED(); if (pin >= GPIO_PINS_PER_REG) { - old_state = &mv_gpio_softc->debounced_state_hi; + old_state = &sc->debounced_state_hi; pin -= GPIO_PINS_PER_REG; } else - old_state = &mv_gpio_softc->debounced_state_lo; + old_state = &sc->debounced_state_lo; if (new_state) *old_state |= (1 << pin); @@ -730,265 +761,255 @@ mv_gpio_debounced_state_set(int pin, uint8_t new_state } static uint32_t -mv_gpio_debounced_state_get(int pin) +mv_gpio_debounced_state_get(device_t dev, int pin) { uint32_t *state; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); MV_GPIO_ASSERT_LOCKED(); if (pin >= GPIO_PINS_PER_REG) { - state = &mv_gpio_softc->debounced_state_hi; + state = &sc->debounced_state_hi; pin -= GPIO_PINS_PER_REG; } else - state = &mv_gpio_softc->debounced_state_lo; + state = &sc->debounced_state_lo; return (*state & (1 << pin)); } void -mv_gpio_out(uint32_t pin, uint8_t val, uint8_t enable) +mv_gpio_out(device_t dev, uint32_t pin, uint8_t val, uint8_t enable) { + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); MV_GPIO_LOCK(); - mv_gpio_value_set(pin, val); - mv_gpio_out_en(pin, enable); + mv_gpio_value_set(dev, pin, val); + mv_gpio_out_en(dev, pin, enable); MV_GPIO_UNLOCK(); } uint8_t -mv_gpio_in(uint32_t pin) +mv_gpio_in(device_t dev, uint32_t pin) { uint8_t state; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); MV_GPIO_LOCK(); - if (gpio_setup[pin] & MV_GPIO_IN_DEBOUNCE) { - if (gpio_setup[pin] & MV_GPIO_IN_POL_LOW) - state = (mv_gpio_debounced_state_get(pin) ? 0 : 1); + if (sc->gpio_setup[pin].gp_flags & MV_GPIO_IN_DEBOUNCE) { + if (sc->gpio_setup[pin].gp_flags & MV_GPIO_IN_POL_LOW) + state = (mv_gpio_debounced_state_get(dev, pin) ? 0 : 1); else - state = (mv_gpio_debounced_state_get(pin) ? 1 : 0); - } else if (gpio_setup[pin] & MV_GPIO_IN_IRQ_DOUBLE_EDGE) { - if (gpio_setup[pin] & MV_GPIO_IN_POL_LOW) - state = (mv_gpio_value_get(pin, 1) ? 0 : 1); + state = (mv_gpio_debounced_state_get(dev, pin) ? 1 : 0); + } else if (sc->gpio_setup[pin].gp_flags & MV_GPIO_IN_IRQ_DOUBLE_EDGE) { + if (sc->gpio_setup[pin].gp_flags & MV_GPIO_IN_POL_LOW) + state = (mv_gpio_value_get(dev, pin, 1) ? 0 : 1); else - state = (mv_gpio_value_get(pin, 1) ? 1 : 0); + state = (mv_gpio_value_get(dev, pin, 1) ? 1 : 0); } else - state = (mv_gpio_value_get(pin, 0) ? 1 : 0); + state = (mv_gpio_value_get(dev, pin, 0) ? 1 : 0); - MV_GPIO_UNLOCK(); return (state); } static uint32_t -mv_gpio_reg_read(uint32_t reg) +mv_gpio_reg_read(device_t dev, uint32_t reg) { + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); - return (bus_space_read_4(mv_gpio_softc->bst, - mv_gpio_softc->bsh, reg)); + return (bus_space_read_4(sc->bst, sc->bsh, reg)); } static void -mv_gpio_reg_write(uint32_t reg, uint32_t val) +mv_gpio_reg_write(device_t dev, uint32_t reg, uint32_t val) { + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); - bus_space_write_4(mv_gpio_softc->bst, - mv_gpio_softc->bsh, reg, val); + bus_space_write_4(sc->bst, sc->bsh, reg, val); } static void -mv_gpio_reg_set(uint32_t reg, uint32_t pin) +mv_gpio_reg_set(device_t dev, uint32_t reg, uint32_t pin) { uint32_t reg_val; - reg_val = mv_gpio_reg_read(reg); + reg_val = mv_gpio_reg_read(dev, reg); reg_val |= GPIO(pin); - mv_gpio_reg_write(reg, reg_val); + mv_gpio_reg_write(dev, reg, reg_val); } static void -mv_gpio_reg_clear(uint32_t reg, uint32_t pin) +mv_gpio_reg_clear(device_t dev, uint32_t reg, uint32_t pin) { uint32_t reg_val; - reg_val = mv_gpio_reg_read(reg); + reg_val = mv_gpio_reg_read(dev, reg); reg_val &= ~(GPIO(pin)); - mv_gpio_reg_write(reg, reg_val); + mv_gpio_reg_write(dev, reg, reg_val); } static void -mv_gpio_out_en(uint32_t pin, uint8_t enable) +mv_gpio_out_en(device_t dev, uint32_t pin, uint8_t enable) { uint32_t reg; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); - if (pin >= mv_gpio_softc->pin_num) + if (pin >= sc->pin_num) return; - if (pin >= GPIO_PINS_PER_REG) { - reg = GPIO_HI_DATA_OUT_EN_CTRL; - pin -= GPIO_PINS_PER_REG; - } else - reg = GPIO_DATA_OUT_EN_CTRL; + reg = GPIO_DATA_OUT_EN_CTRL; if (enable) - mv_gpio_reg_clear(reg, pin); + mv_gpio_reg_clear(dev, reg, pin); else - mv_gpio_reg_set(reg, pin); + mv_gpio_reg_set(dev, reg, pin); } static void -mv_gpio_blink(uint32_t pin, uint8_t enable) +mv_gpio_blink(device_t dev, uint32_t pin, uint8_t enable) { uint32_t reg; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); - if (pin >= mv_gpio_softc->pin_num) + if (pin >= sc->pin_num) return; - if (pin >= GPIO_PINS_PER_REG) { - reg = GPIO_HI_BLINK_EN; - pin -= GPIO_PINS_PER_REG; - } else - reg = GPIO_BLINK_EN; + reg = GPIO_BLINK_EN; if (enable) - mv_gpio_reg_set(reg, pin); + mv_gpio_reg_set(dev, reg, pin); else - mv_gpio_reg_clear(reg, pin); + mv_gpio_reg_clear(dev, reg, pin); } static void -mv_gpio_polarity(uint32_t pin, uint8_t enable, uint8_t toggle) +mv_gpio_polarity(device_t dev, uint32_t pin, uint8_t enable, uint8_t toggle) { uint32_t reg, reg_val; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); - if (pin >= mv_gpio_softc->pin_num) + if (pin >= sc->pin_num) return; - if (pin >= GPIO_PINS_PER_REG) { - reg = GPIO_HI_DATA_IN_POLAR; - pin -= GPIO_PINS_PER_REG; - } else - reg = GPIO_DATA_IN_POLAR; + reg = GPIO_DATA_IN_POLAR; if (toggle) { - reg_val = mv_gpio_reg_read(reg) & GPIO(pin); + reg_val = mv_gpio_reg_read(dev, reg) & GPIO(pin); if (reg_val) - mv_gpio_reg_clear(reg, pin); + mv_gpio_reg_clear(dev, reg, pin); else - mv_gpio_reg_set(reg, pin); + mv_gpio_reg_set(dev, reg, pin); } else if (enable) - mv_gpio_reg_set(reg, pin); + mv_gpio_reg_set(dev, reg, pin); else - mv_gpio_reg_clear(reg, pin); + mv_gpio_reg_clear(dev, reg, pin); } static void -mv_gpio_level(uint32_t pin, uint8_t enable) +mv_gpio_level(device_t dev, uint32_t pin, uint8_t enable) { uint32_t reg; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); - if (pin >= mv_gpio_softc->pin_num) + if (pin >= sc->pin_num) return; - if (pin >= GPIO_PINS_PER_REG) { - reg = GPIO_HI_INT_LEV_MASK; - pin -= GPIO_PINS_PER_REG; - } else - reg = GPIO_INT_LEV_MASK; + reg = GPIO_INT_LEV_MASK; if (enable) - mv_gpio_reg_set(reg, pin); + mv_gpio_reg_set(dev, reg, pin); else - mv_gpio_reg_clear(reg, pin); + mv_gpio_reg_clear(dev, reg, pin); } static void -mv_gpio_edge(uint32_t pin, uint8_t enable) +mv_gpio_edge(device_t dev, uint32_t pin, uint8_t enable) { uint32_t reg; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(dev); - if (pin >= mv_gpio_softc->pin_num) + if (pin >= sc->pin_num) return; - if (pin >= GPIO_PINS_PER_REG) { - reg = GPIO_HI_INT_EDGE_MASK; - pin -= GPIO_PINS_PER_REG; - } else - reg = GPIO_INT_EDGE_MASK; + reg = GPIO_INT_EDGE_MASK; if (enable) - mv_gpio_reg_set(reg, pin); + mv_gpio_reg_set(dev, reg, pin); else - mv_gpio_reg_clear(reg, pin); + mv_gpio_reg_clear(dev, reg, pin); } static void -mv_gpio_int_ack(uint32_t pin) +mv_gpio_int_ack(struct mv_gpio_pindev *s) { - uint32_t reg; + uint32_t reg, pin; + struct mv_gpio_softc *sc; + sc = (struct mv_gpio_softc *)device_get_softc(s->dev); + pin = s->pin; - if (pin >= mv_gpio_softc->pin_num) + if (pin >= sc->pin_num) return; - if (pin >= GPIO_PINS_PER_REG) { - reg = GPIO_HI_INT_CAUSE; - pin -= GPIO_PINS_PER_REG; - } else - reg = GPIO_INT_CAUSE; + reg = GPIO_INT_CAUSE; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Wed Apr 4 13:38:00 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A51FBF8F7C8; Wed, 4 Apr 2018 13:38:00 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 587D17BA2B; Wed, 4 Apr 2018 13:38:00 +0000 (UTC) (envelope-from andrew@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 52AB814680; Wed, 4 Apr 2018 13:38:00 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34Dc0H5089660; Wed, 4 Apr 2018 13:38:00 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34Dbxpb089645; Wed, 4 Apr 2018 13:37:59 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201804041337.w34Dbxpb089645@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Wed, 4 Apr 2018 13:37:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332026 - in head/sys: arm/mv dev/fdt X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: in head/sys: arm/mv dev/fdt X-SVN-Commit-Revision: 332026 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 13:38:00 -0000 Author: andrew Date: Wed Apr 4 13:37:59 2018 New Revision: 332026 URL: https://svnweb.freebsd.org/changeset/base/332026 Log: Remove fdt_pm_is_enabled as it's Marvell specific. Replace the only call to it with a call to the helper function fdt_pm_is_enabled would call. Sponsored by: DARPA, AFRL Modified: head/sys/arm/mv/mv_common.c head/sys/arm/mv/mv_localbus.c head/sys/arm/mv/mvvar.h head/sys/dev/fdt/fdt_common.c head/sys/dev/fdt/fdt_common.h Modified: head/sys/arm/mv/mv_common.c ============================================================================== --- head/sys/arm/mv/mv_common.c Wed Apr 4 13:23:06 2018 (r332025) +++ head/sys/arm/mv/mv_common.c Wed Apr 4 13:37:59 2018 (r332026) @@ -484,7 +484,7 @@ pm_disable_device(int mask) } int -fdt_pm(phandle_t node) +mv_fdt_pm(phandle_t node) { uint32_t cpu_pm_ctrl; int i, ena, compat; Modified: head/sys/arm/mv/mv_localbus.c ============================================================================== --- head/sys/arm/mv/mv_localbus.c Wed Apr 4 13:23:06 2018 (r332025) +++ head/sys/arm/mv/mv_localbus.c Wed Apr 4 13:37:59 2018 (r332026) @@ -275,7 +275,7 @@ localbus_attach(device_t dev) if (!(ofw_bus_node_status_okay(dt_child))) continue; - if (!(fdt_pm_is_enabled(dt_child))) + if (!(mv_fdt_pm(dt_child))) continue; di = malloc(sizeof(*di), M_LOCALBUS, M_WAITOK | M_ZERO); Modified: head/sys/arm/mv/mvvar.h ============================================================================== --- head/sys/arm/mv/mvvar.h Wed Apr 4 13:23:06 2018 (r332025) +++ head/sys/arm/mv/mvvar.h Wed Apr 4 13:37:59 2018 (r332026) @@ -141,6 +141,8 @@ int mv_pci_devmap(phandle_t, struct devmap_entry *, vm int fdt_localbus_devmap(phandle_t, struct devmap_entry *, int, int *); enum soc_family mv_check_soc_family(void); +int mv_fdt_pm(phandle_t); + uint32_t get_tclk_armadaxp(void); uint32_t get_tclk_armada38x(void); uint32_t get_cpu_freq_armadaxp(void); Modified: head/sys/dev/fdt/fdt_common.c ============================================================================== --- head/sys/dev/fdt/fdt_common.c Wed Apr 4 13:23:06 2018 (r332025) +++ head/sys/dev/fdt/fdt_common.c Wed Apr 4 13:37:59 2018 (r332026) @@ -365,19 +365,6 @@ fdt_parent_addr_cells(phandle_t node) return ((int)fdt32_to_cpu(addr_cells)); } -int -fdt_pm_is_enabled(phandle_t node) -{ - int ret; - - ret = 1; - -#if defined(SOC_MV_KIRKWOOD) || defined(SOC_MV_DISCOVERY) - ret = fdt_pm(node); -#endif - return (ret); -} - u_long fdt_data_get(void *data, int cells) { Modified: head/sys/dev/fdt/fdt_common.h ============================================================================== --- head/sys/dev/fdt/fdt_common.h Wed Apr 4 13:23:06 2018 (r332025) +++ head/sys/dev/fdt/fdt_common.h Wed Apr 4 13:37:59 2018 (r332026) @@ -91,10 +91,8 @@ int fdt_get_range(phandle_t, int, u_long *, u_long *); int fdt_immr_addr(vm_offset_t); int fdt_regsize(phandle_t, u_long *, u_long *); int fdt_is_compatible_strict(phandle_t, const char *); -int fdt_pm_is_enabled(phandle_t); int fdt_is_type(phandle_t, const char *); int fdt_parent_addr_cells(phandle_t); -int fdt_pm(phandle_t); int fdt_get_chosen_bootargs(char *bootargs, size_t max_size); #endif /* _FDT_COMMON_H_ */ From owner-svn-src-head@freebsd.org Wed Apr 4 14:31:57 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 86533F93359; Wed, 4 Apr 2018 14:31:57 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 390287E826; Wed, 4 Apr 2018 14:31:57 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 33D6614F1D; Wed, 4 Apr 2018 14:31:57 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34EVvBO054624; Wed, 4 Apr 2018 14:31:57 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34EVuEQ054613; Wed, 4 Apr 2018 14:31:56 GMT (envelope-from br@FreeBSD.org) Message-Id: <201804041431.w34EVuEQ054613@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Wed, 4 Apr 2018 14:31:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332033 - in head: etc/mtree lib lib/libopencsd share/mk X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: in head: etc/mtree lib lib/libopencsd share/mk X-SVN-Commit-Revision: 332033 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 14:31:57 -0000 Author: br Date: Wed Apr 4 14:31:56 2018 New Revision: 332033 URL: https://svnweb.freebsd.org/changeset/base/332033 Log: Add new shared library -- libopencsd. OpenCSD is an ARM CoreSight(tm) trace packets decoder. - Connect libopencsd to the arm64 build. - Install opencsd headers to /usr/include/opencsd/ Sponsored by: DARPA, AFRL Added: head/lib/libopencsd/ head/lib/libopencsd/Makefile (contents, props changed) Modified: head/etc/mtree/BSD.include.dist head/lib/Makefile head/share/mk/bsd.libnames.mk head/share/mk/src.libnames.mk Modified: head/etc/mtree/BSD.include.dist ============================================================================== --- head/etc/mtree/BSD.include.dist Wed Apr 4 14:12:07 2018 (r332032) +++ head/etc/mtree/BSD.include.dist Wed Apr 4 14:31:56 2018 (r332033) @@ -317,6 +317,18 @@ .. nfsserver .. + opencsd + c_api + .. + etmv3 + .. + etmv4 + .. + ptm + .. + stm + .. + .. openssl .. pcap Modified: head/lib/Makefile ============================================================================== --- head/lib/Makefile Wed Apr 4 14:12:07 2018 (r332032) +++ head/lib/Makefile Wed Apr 4 14:31:56 2018 (r332033) @@ -175,6 +175,10 @@ SUBDIR.${MK_NIS}+= libypclnt _libvgl= libvgl .endif +.if ${MACHINE_CPUARCH} == "aarch64" +SUBDIR.${MK_PMC}+= libopencsd +.endif + .if ${MACHINE_CPUARCH} == "amd64" SUBDIR.${MK_PMC}+= libipt SUBDIR.${MK_BHYVE}+= libvmmapi Added: head/lib/libopencsd/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libopencsd/Makefile Wed Apr 4 14:31:56 2018 (r332033) @@ -0,0 +1,175 @@ +# $FreeBSD$ + +PACKAGE=lib${LIB} +SHLIBDIR?= /lib + +.include + +OPENCSDSRC= ${SRCTOP}/contrib/opencsd + +.PATH: ${OPENCSDSRC}/decoder/source/etmv4/ \ + ${OPENCSDSRC}/decoder/source/etmv3/ \ + ${OPENCSDSRC}/decoder/source/pkt_printers/ \ + ${OPENCSDSRC}/decoder/source/mem_acc/ \ + ${OPENCSDSRC}/decoder/source/i_dec/ \ + ${OPENCSDSRC}/decoder/source/c_api/ \ + ${OPENCSDSRC}/decoder/source/ptm/ \ + ${OPENCSDSRC}/decoder/source/stm/ \ + ${OPENCSDSRC}/decoder/source/ \ + ${OPENCSDSRC}/decoder/include/opencsd/etmv4/ \ + ${OPENCSDSRC}/decoder/include/opencsd/etmv3/ \ + ${OPENCSDSRC}/decoder/include/opencsd/stm/ \ + ${OPENCSDSRC}/decoder/include/opencsd/ptm/ \ + ${OPENCSDSRC}/decoder/include/opencsd/c_api/ \ + ${OPENCSDSRC}/decoder/include/opencsd/ \ + ${OPENCSDSRC}/decoder/include + +LIB= opencsd +SHLIB_MAJOR=0 + +# ETMv3 +SRCS= \ + trc_cmp_cfg_etmv3.cpp \ + trc_pkt_decode_etmv3.cpp \ + trc_pkt_elem_etmv3.cpp \ + trc_pkt_proc_etmv3.cpp \ + trc_pkt_proc_etmv3_impl.cpp + +# ETMv4 +SRCS+= \ + trc_cmp_cfg_etmv4.cpp \ + trc_etmv4_stack_elem.cpp \ + trc_pkt_decode_etmv4i.cpp \ + trc_pkt_elem_etmv4d.cpp \ + trc_pkt_elem_etmv4i.cpp \ + trc_pkt_proc_etmv4.cpp \ + trc_pkt_proc_etmv4i_impl.cpp + +# PKT_PRINTERS +SRCS+= \ + raw_frame_printer.cpp \ + trc_print_fact.cpp + +# PTM +SRCS+= \ + trc_cmp_cfg_ptm.cpp \ + trc_pkt_decode_ptm.cpp \ + trc_pkt_elem_ptm.cpp \ + trc_pkt_proc_ptm.cpp + +# STM +SRCS+= \ + trc_pkt_decode_stm.cpp \ + trc_pkt_elem_stm.cpp \ + trc_pkt_proc_stm.cpp + +# C_API +SRCS+= \ + ocsd_c_api_custom_obj.cpp \ + ocsd_c_api.cpp + +# SRC +SRCS+= \ + ocsd_code_follower.cpp \ + ocsd_dcd_tree.cpp \ + ocsd_error.cpp \ + ocsd_error_logger.cpp \ + ocsd_gen_elem_list.cpp \ + ocsd_lib_dcd_register.cpp \ + ocsd_msg_logger.cpp \ + ocsd_version.cpp \ + trc_component.cpp \ + trc_core_arch_map.cpp \ + trc_frame_deformatter.cpp \ + trc_gen_elem.cpp \ + trc_printable_elem.cpp \ + trc_ret_stack.cpp + +# MEM_ACC +SRCS+= \ + trc_mem_acc_base.cpp \ + trc_mem_acc_cb.cpp \ + trc_mem_acc_mapper.cpp \ + trc_mem_acc_bufptr.cpp \ + trc_mem_acc_file.cpp + +# I_DEC +SRCS+= \ + trc_i_decode.cpp \ + trc_idec_arminst.cpp + +CFLAGS+= \ + -I${OPENCSDSRC}/decoder/include/ \ + -I${.CURDIR} + +INCS= \ + ocsd_if_types.h \ + trc_gen_elem_types.h \ + trc_pkt_types.h + +INCSDIR=${INCLUDEDIR}/opencsd + +APIINCS= \ + ocsd_c_api_cust_fact.h \ + ocsd_c_api_cust_impl.h \ + ocsd_c_api_custom.h \ + ocsd_c_api_types.h \ + opencsd_c_api.h + +APIINCSDIR=${INCLUDEDIR}/opencsd/c_api/ + +ETMV4INCS= \ + etmv4_decoder.h \ + trc_cmp_cfg_etmv4.h \ + trc_dcd_mngr_etmv4i.h \ + trc_etmv4_stack_elem.h \ + trc_pkt_decode_etmv4i.h \ + trc_pkt_elem_etmv4d.h \ + trc_pkt_elem_etmv4i.h \ + trc_pkt_proc_etmv4.h \ + trc_pkt_types_etmv4.h + +ETMV4INCSDIR=${INCLUDEDIR}/opencsd/etmv4/ + +ETMV3INCS= \ + etmv3_decoder.h \ + trc_cmp_cfg_etmv3.h \ + trc_dcd_mngr_etmv3.h \ + trc_pkt_decode_etmv3.h \ + trc_pkt_elem_etmv3.h \ + trc_pkt_proc_etmv3.h \ + trc_pkt_types_etmv3.h + +ETMV3INCSDIR=${INCLUDEDIR}/opencsd/etmv3/ + +PTMINCS= \ + ptm_decoder.h \ + trc_cmp_cfg_ptm.h \ + trc_dcd_mngr_ptm.h \ + trc_pkt_decode_ptm.h \ + trc_pkt_elem_ptm.h \ + trc_pkt_proc_ptm.h \ + trc_pkt_types_ptm.h + +PTMINCSDIR=${INCLUDEDIR}/opencsd/ptm/ + +STMINCS= \ + stm_decoder.h \ + trc_cmp_cfg_stm.h \ + trc_dcd_mngr_stm.h \ + trc_pkt_decode_stm.h \ + trc_pkt_elem_stm.h \ + trc_pkt_proc_stm.h \ + trc_pkt_types_stm.h + +STMINCSDIR=${INCLUDEDIR}/opencsd/stm/ + +INCSGROUPS=INCS APIINCS ETMV3INCS ETMV4INCS PTMINCS STMINCS + +LIBADD= cxxrt + +WARNS?= 1 + +HAS_TESTS= + +.include Modified: head/share/mk/bsd.libnames.mk ============================================================================== --- head/share/mk/bsd.libnames.mk Wed Apr 4 14:12:07 2018 (r332032) +++ head/share/mk/bsd.libnames.mk Wed Apr 4 14:31:56 2018 (r332033) @@ -118,6 +118,7 @@ LIBNETGRAPH?= ${LIBDESTDIR}${LIBDIR_BASE}/libnetgraph. LIBNGATM?= ${LIBDESTDIR}${LIBDIR_BASE}/libngatm.a LIBNV?= ${LIBDESTDIR}${LIBDIR_BASE}/libnv.a LIBNVPAIR?= ${LIBDESTDIR}${LIBDIR_BASE}/libnvpair.a +LIBOPENCSD?= ${LIBDESTDIR}${LIBDIR_BASE}/libopencsd.a LIBOPENSM?= ${LIBDESTDIR}${LIBDIR_BASE}/libopensm.a LIBOPIE?= ${LIBDESTDIR}${LIBDIR_BASE}/libopie.a LIBOSMCOMP?= ${LIBDESTDIR}${LIBDIR_BASE}/libosmcomp.a Modified: head/share/mk/src.libnames.mk ============================================================================== --- head/share/mk/src.libnames.mk Wed Apr 4 14:12:07 2018 (r332032) +++ head/share/mk/src.libnames.mk Wed Apr 4 14:31:56 2018 (r332033) @@ -135,6 +135,7 @@ _LIBRARIES= \ ngatm \ nv \ nvpair \ + opencsd \ opie \ pam \ panel \ @@ -307,6 +308,7 @@ _DP_gssapi_krb5+= gssapi krb5 crypto roken asn1 com_er _DP_lzma= pthread _DP_ucl= m _DP_vmmapi= util +_DP_opencsd= cxxrt _DP_ctf= z _DP_dtrace= ctf elf proc pthread rtld_db _DP_xo= util From owner-svn-src-head@freebsd.org Wed Apr 4 14:41:49 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7DC2AF94045; Wed, 4 Apr 2018 14:41:49 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 33C387F2A9; Wed, 4 Apr 2018 14:41:49 +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 2EB18151B0; Wed, 4 Apr 2018 14:41:49 +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 w34Efn3d065077; Wed, 4 Apr 2018 14:41:49 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34Efn4C065076; Wed, 4 Apr 2018 14:41:49 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201804041441.w34Efn4C065076@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 4 Apr 2018 14:41:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332034 - head/sys/compat/linux X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/sys/compat/linux X-SVN-Commit-Revision: 332034 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 14:41:49 -0000 Author: emaste Date: Wed Apr 4 14:41:48 2018 New Revision: 332034 URL: https://svnweb.freebsd.org/changeset/base/332034 Log: linux_ioctl_hdio: fix kernel memory disclosure Stack-allocated struct linux_hd_big_geometry has undeclared padding copied to userland. admbugs: 765 Reported by: Vlad Tsyrklevich MFC after: 1 day Security: Kernel memory disclosure Sponsored by: The FreeBSD Foundation Modified: head/sys/compat/linux/linux_ioctl.c Modified: head/sys/compat/linux/linux_ioctl.c ============================================================================== --- head/sys/compat/linux/linux_ioctl.c Wed Apr 4 14:31:56 2018 (r332033) +++ head/sys/compat/linux/linux_ioctl.c Wed Apr 4 14:41:48 2018 (r332034) @@ -253,6 +253,7 @@ linux_ioctl_hdio(struct thread *td, struct linux_ioctl } else if ((args->cmd & 0xffff) == LINUX_HDIO_GET_GEO_BIG) { struct linux_hd_big_geometry hdbg; + memset(&hdbg, 0, sizeof(hdbg)); hdbg.cylinders = fwcylinders; hdbg.heads = fwheads; hdbg.sectors = fwsectors; From owner-svn-src-head@freebsd.org Wed Apr 4 15:16:05 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DA9AEF96238; Wed, 4 Apr 2018 15:16:04 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8C50680ACF; Wed, 4 Apr 2018 15:16:04 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 872A0156D4; Wed, 4 Apr 2018 15:16:04 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34FG4X4002718; Wed, 4 Apr 2018 15:16:04 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34FG47Z002717; Wed, 4 Apr 2018 15:16:04 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201804041516.w34FG47Z002717@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Wed, 4 Apr 2018 15:16:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332035 - head/include X-SVN-Group: head X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: head/include X-SVN-Commit-Revision: 332035 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 15:16:05 -0000 Author: pfg Date: Wed Apr 4 15:16:04 2018 New Revision: 332035 URL: https://svnweb.freebsd.org/changeset/base/332035 Log: pthread.h: minor indentation cleanups. No functional change. X-MFC with: r331969 Modified: head/include/pthread.h Modified: head/include/pthread.h ============================================================================== --- head/include/pthread.h Wed Apr 4 14:41:48 2018 (r332034) +++ head/include/pthread.h Wed Apr 4 15:16:04 2018 (r332035) @@ -175,8 +175,7 @@ int pthread_barrierattr_destroy(pthread_barrierattr_t int pthread_barrierattr_getpshared( const pthread_barrierattr_t *, int *); int pthread_barrierattr_init(pthread_barrierattr_t *); -int pthread_barrierattr_setpshared(pthread_barrierattr_t *, - int); +int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int); #define pthread_cleanup_push(cleanup_routine, cleanup_arg) \ { \ @@ -194,16 +193,13 @@ int pthread_barrierattr_setpshared(pthread_barrieratt int pthread_condattr_destroy(pthread_condattr_t *); int pthread_condattr_getclock(const pthread_condattr_t *, clockid_t *); -int pthread_condattr_getpshared(const pthread_condattr_t *, - int *); +int pthread_condattr_getpshared(const pthread_condattr_t *, int *); int pthread_condattr_init(pthread_condattr_t *); -int pthread_condattr_setclock(pthread_condattr_t *, - clockid_t); +int pthread_condattr_setclock(pthread_condattr_t *, clockid_t); int pthread_condattr_setpshared(pthread_condattr_t *, int); int pthread_cond_broadcast(pthread_cond_t *); int pthread_cond_destroy(pthread_cond_t *); -int pthread_cond_init(pthread_cond_t *, - const pthread_condattr_t *); +int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *); int pthread_cond_signal(pthread_cond_t *); int pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t * __mutex, @@ -219,18 +215,15 @@ void pthread_exit(void *) __dead2; void *pthread_getspecific(pthread_key_t); int pthread_getcpuclockid(pthread_t, clockid_t *); int pthread_join(pthread_t, void **); -int pthread_key_create(pthread_key_t *, - void (*) (void *)); +int pthread_key_create(pthread_key_t *, void (*) (void *)); int pthread_key_delete(pthread_key_t); int pthread_mutexattr_init(pthread_mutexattr_t *); int pthread_mutexattr_destroy(pthread_mutexattr_t *); -int pthread_mutexattr_getpshared( - const pthread_mutexattr_t *, int *); -int pthread_mutexattr_gettype(pthread_mutexattr_t *, +int pthread_mutexattr_getpshared(const pthread_mutexattr_t *, int *); +int pthread_mutexattr_gettype(pthread_mutexattr_t *, int *); int pthread_mutexattr_settype(pthread_mutexattr_t *, int); -int pthread_mutexattr_setpshared(pthread_mutexattr_t *, - int); +int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int); int pthread_mutex_consistent(pthread_mutex_t * __mutex) __requires_exclusive(*__mutex); int pthread_mutex_destroy(pthread_mutex_t * __mutex) @@ -247,8 +240,7 @@ int pthread_mutex_timedlock(pthread_mutex_t * __mutex __trylocks_exclusive(0, *__mutex); int pthread_mutex_unlock(pthread_mutex_t * __mutex) __unlocks(*__mutex); -int pthread_once(pthread_once_t *, - void (*) (void)); +int pthread_once(pthread_once_t *, void (*) (void)); int pthread_rwlock_destroy(pthread_rwlock_t * __rwlock) __requires_unlocked(*__rwlock); int pthread_rwlock_init(pthread_rwlock_t * __rwlock, @@ -271,15 +263,14 @@ int pthread_rwlock_unlock(pthread_rwlock_t * __rwlock int pthread_rwlock_wrlock(pthread_rwlock_t * __rwlock) __locks_exclusive(*__rwlock); int pthread_rwlockattr_destroy(pthread_rwlockattr_t *); -int pthread_rwlockattr_getkind_np( - const pthread_rwlockattr_t *, int *); -int pthread_rwlockattr_getpshared( - const pthread_rwlockattr_t *, int *); +int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t *, + int *); +int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *, + int *); int pthread_rwlockattr_init(pthread_rwlockattr_t *); int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *, int); -int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, - int); +int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int); pthread_t pthread_self(void); int pthread_setspecific(pthread_key_t, const void *); @@ -314,16 +305,13 @@ int pthread_mutexattr_setprotocol(pthread_mutexattr_t int pthread_mutexattr_getrobust( pthread_mutexattr_t * __restrict, int * __restrict); -int pthread_mutexattr_setrobust(pthread_mutexattr_t *, - int); +int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int); int pthread_attr_getinheritsched(const pthread_attr_t *, int *); int pthread_attr_getschedparam(const pthread_attr_t *, struct sched_param *); -int pthread_attr_getschedpolicy(const pthread_attr_t *, - int *); -int pthread_attr_getscope(const pthread_attr_t *, - int *); +int pthread_attr_getschedpolicy(const pthread_attr_t *, int *); +int pthread_attr_getscope(const pthread_attr_t *, int *); int pthread_attr_setinheritsched(pthread_attr_t *, int); int pthread_attr_setschedparam(pthread_attr_t *, const struct sched_param *); From owner-svn-src-head@freebsd.org Wed Apr 4 19:58:25 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CBB75F71912; Wed, 4 Apr 2018 19:58:25 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 79AA8707B6; Wed, 4 Apr 2018 19:58:25 +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 706FD1853C; Wed, 4 Apr 2018 19:58:25 +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 w34JwPu1082548; Wed, 4 Apr 2018 19:58:25 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34JwPhW082547; Wed, 4 Apr 2018 19:58:25 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201804041958.w34JwPhW082547@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 4 Apr 2018 19:58:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332042 - head/sys/compat/linux X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/sys/compat/linux X-SVN-Commit-Revision: 332042 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 19:58:26 -0000 Author: emaste Date: Wed Apr 4 19:58:25 2018 New Revision: 332042 URL: https://svnweb.freebsd.org/changeset/base/332042 Log: Fix kernel memory disclosure in linux_ioctl_socket strlcpy is used to copy a string into a buffer to be copied to userland, previously leaving uninitialized data after the terminating NUL. Zero the buffer first to avoid a kernel memory disclosure. admbugs: 765, 811 MFC after: 1 day Reported by: Ilja Van Sprundel Reported by: Vlad Tsyrklevich Sponsored by: The FreeBSD Foundation Modified: head/sys/compat/linux/linux_ioctl.c Modified: head/sys/compat/linux/linux_ioctl.c ============================================================================== --- head/sys/compat/linux/linux_ioctl.c Wed Apr 4 18:27:18 2018 (r332041) +++ head/sys/compat/linux/linux_ioctl.c Wed Apr 4 19:58:25 2018 (r332042) @@ -2478,6 +2478,7 @@ linux_ioctl_socket(struct thread *td, struct linux_ioc printf("%s(): ioctl %d on %.*s\n", __func__, args->cmd & 0xffff, LINUX_IFNAMSIZ, lifname); #endif + memset(ifname, 0, sizeof(ifname)); ifp = ifname_linux_to_bsd(td, lifname, ifname); if (ifp == NULL) return (EINVAL); From owner-svn-src-head@freebsd.org Wed Apr 4 20:15:42 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2136EF7303C; Wed, 4 Apr 2018 20:15:42 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CC4EB7172C; Wed, 4 Apr 2018 20:15:41 +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 C32BE18879; Wed, 4 Apr 2018 20:15:41 +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 w34KFfY7097617; Wed, 4 Apr 2018 20:15:41 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34KFfnT097616; Wed, 4 Apr 2018 20:15:41 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201804042015.w34KFfnT097616@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 4 Apr 2018 20:15:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332043 - head/share/man/man9 X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/share/man/man9 X-SVN-Commit-Revision: 332043 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 20:15:42 -0000 Author: markj Date: Wed Apr 4 20:15:41 2018 New Revision: 332043 URL: https://svnweb.freebsd.org/changeset/base/332043 Log: Typo. MFC after: 3 days Modified: head/share/man/man9/timeout.9 Modified: head/share/man/man9/timeout.9 ============================================================================== --- head/share/man/man9/timeout.9 Wed Apr 4 19:58:25 2018 (r332042) +++ head/share/man/man9/timeout.9 Wed Apr 4 20:15:41 2018 (r332043) @@ -327,7 +327,6 @@ The .Fa drain function itself is called from the context of the completing callout i.e. softclock or hardclock, just like a callout itself. -p .Pp The function .Fn callout_drain From owner-svn-src-head@freebsd.org Wed Apr 4 21:12:35 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C632FF76B8D; Wed, 4 Apr 2018 21:12:35 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7BF5274212; Wed, 4 Apr 2018 21:12:35 +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 76E0619236; Wed, 4 Apr 2018 21:12:35 +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 w34LCZgt046342; Wed, 4 Apr 2018 21:12:35 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34LCZ8g046341; Wed, 4 Apr 2018 21:12:35 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201804042112.w34LCZ8g046341@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 4 Apr 2018 21:12:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332045 - head/sys/netinet X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/sys/netinet X-SVN-Commit-Revision: 332045 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 21:12:35 -0000 Author: emaste Date: Wed Apr 4 21:12:35 2018 New Revision: 332045 URL: https://svnweb.freebsd.org/changeset/base/332045 Log: Fix kernel memory disclosure in tcp_ctloutput strcpy was used to copy a string into a buffer copied to userland, which left uninitialized data after the terminating 0-byte. Use the same approach as in tcp_subr.c: strncpy and explicit '\0'. admbugs: 765, 822 MFC after: 1 day Reported by: Ilja Van Sprundel Reported by: Vlad Tsyrklevich Security: Kernel memory disclosure Sponsored by: The FreeBSD Foundation Modified: head/sys/netinet/tcp_usrreq.c Modified: head/sys/netinet/tcp_usrreq.c ============================================================================== --- head/sys/netinet/tcp_usrreq.c Wed Apr 4 20:29:55 2018 (r332044) +++ head/sys/netinet/tcp_usrreq.c Wed Apr 4 21:12:35 2018 (r332045) @@ -1533,7 +1533,9 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt) return (error); } else if ((sopt->sopt_dir == SOPT_GET) && (sopt->sopt_name == TCP_FUNCTION_BLK)) { - strcpy(fsn.function_set_name, tp->t_fb->tfb_tcp_block_name); + strncpy(fsn.function_set_name, tp->t_fb->tfb_tcp_block_name, + TCP_FUNCTION_NAME_LEN_MAX); + fsn.function_set_name[TCP_FUNCTION_NAME_LEN_MAX - 1] = '\0'; fsn.pcbcnt = tp->t_fb->tfb_refcnt; INP_WUNLOCK(inp); error = sooptcopyout(sopt, &fsn, sizeof fsn); From owner-svn-src-head@freebsd.org Wed Apr 4 21:19:34 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4BC7FF773B4; Wed, 4 Apr 2018 21:19:34 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EC5C5747D3; Wed, 4 Apr 2018 21:19:33 +0000 (UTC) (envelope-from ian@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 E753A19242; Wed, 4 Apr 2018 21:19:33 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34LJXQI048845; Wed, 4 Apr 2018 21:19:33 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34LJXXH048844; Wed, 4 Apr 2018 21:19:33 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804042119.w34LJXXH048844@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Wed, 4 Apr 2018 21:19:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332046 - head/sys/dev/spibus X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/dev/spibus X-SVN-Commit-Revision: 332046 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 21:19:34 -0000 Author: ian Date: Wed Apr 4 21:19:33 2018 New Revision: 332046 URL: https://svnweb.freebsd.org/changeset/base/332046 Log: Add a missing MODULE_DEPEND(). Modified: head/sys/dev/spibus/spigen.c Modified: head/sys/dev/spibus/spigen.c ============================================================================== --- head/sys/dev/spibus/spigen.c Wed Apr 4 21:12:35 2018 (r332045) +++ head/sys/dev/spibus/spigen.c Wed Apr 4 21:19:33 2018 (r332046) @@ -456,3 +456,4 @@ static driver_t spigen_driver = { }; DRIVER_MODULE(spigen, spibus, spigen_driver, spigen_devclass, 0, 0); +MODULE_DEPEND(spigen, spibus, 1, 1, 1); From owner-svn-src-head@freebsd.org Wed Apr 4 21:31:13 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 30AD4F7808B; Wed, 4 Apr 2018 21:31:13 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D0A9975133; Wed, 4 Apr 2018 21:31:12 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CB21D19516; Wed, 4 Apr 2018 21:31:12 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34LVCTu060014; Wed, 4 Apr 2018 21:31:12 GMT (envelope-from vmaffione@FreeBSD.org) Received: (from vmaffione@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34LVCKp060008; Wed, 4 Apr 2018 21:31:12 GMT (envelope-from vmaffione@FreeBSD.org) Message-Id: <201804042131.w34LVCKp060008@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vmaffione set sender to vmaffione@FreeBSD.org using -f From: Vincenzo Maffione Date: Wed, 4 Apr 2018 21:31:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332047 - in head/sys: dev/netmap net X-SVN-Group: head X-SVN-Commit-Author: vmaffione X-SVN-Commit-Paths: in head/sys: dev/netmap net X-SVN-Commit-Revision: 332047 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 21:31:13 -0000 Author: vmaffione Date: Wed Apr 4 21:31:12 2018 New Revision: 332047 URL: https://svnweb.freebsd.org/changeset/base/332047 Log: netmap: align if_ptnet guest driver to the upstream code (commit 0e15788) The change upgrades the driver to use the split Communication Status Block (CSB) format. In this way the variables written by the guest and read by the host are allocated in a different cacheline than the variables written by the host and read by the guest; this is needed to avoid cache thrashing. Approved by: hrs (mentor) Modified: head/sys/dev/netmap/if_ptnet.c head/sys/dev/netmap/netmap_kern.h head/sys/dev/netmap/netmap_pt.c head/sys/net/netmap_virt.h Modified: head/sys/dev/netmap/if_ptnet.c ============================================================================== --- head/sys/dev/netmap/if_ptnet.c Wed Apr 4 21:19:33 2018 (r332046) +++ head/sys/dev/netmap/if_ptnet.c Wed Apr 4 21:31:12 2018 (r332047) @@ -88,10 +88,6 @@ #include #include -#ifndef PTNET_CSB_ALLOC -#error "No support for on-device CSB" -#endif - #ifndef INET #error "INET not defined, cannot support offloadings" #endif @@ -132,7 +128,8 @@ struct ptnet_queue { struct resource *irq; void *cookie; int kring_id; - struct ptnet_ring *ptring; + struct ptnet_csb_gh *ptgh; + struct ptnet_csb_hg *pthg; unsigned int kick; struct mtx lock; struct buf_ring *bufring; /* for TX queues */ @@ -169,7 +166,8 @@ struct ptnet_softc { unsigned int num_tx_rings; struct ptnet_queue *queues; struct ptnet_queue *rxqueues; - struct ptnet_csb *csb; + struct ptnet_csb_gh *csb_gh; + struct ptnet_csb_hg *csb_hg; unsigned int min_tx_space; @@ -323,33 +321,48 @@ ptnet_attach(device_t dev) ptfeatures = bus_read_4(sc->iomem, PTNET_IO_PTFEAT); /* acked */ sc->ptfeatures = ptfeatures; - /* Allocate CSB and carry out CSB allocation protocol (CSBBAH first, - * then CSBBAL). */ - sc->csb = malloc(sizeof(struct ptnet_csb), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (sc->csb == NULL) { + num_tx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_TX_RINGS); + num_rx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_RX_RINGS); + sc->num_rings = num_tx_rings + num_rx_rings; + sc->num_tx_rings = num_tx_rings; + + if (sc->num_rings * sizeof(struct ptnet_csb_gh) > PAGE_SIZE) { + device_printf(dev, "CSB cannot handle that many rings (%u)\n", + sc->num_rings); + err = ENOMEM; + goto err_path; + } + + /* Allocate CSB and carry out CSB allocation protocol. */ + sc->csb_gh = contigmalloc(2*PAGE_SIZE, M_DEVBUF, M_NOWAIT | M_ZERO, + (size_t)0, -1UL, PAGE_SIZE, 0); + if (sc->csb_gh == NULL) { device_printf(dev, "Failed to allocate CSB\n"); err = ENOMEM; goto err_path; } + sc->csb_hg = (struct ptnet_csb_hg *)(((char *)sc->csb_gh) + PAGE_SIZE); { /* * We use uint64_t rather than vm_paddr_t since we * need 64 bit addresses even on 32 bit platforms. */ - uint64_t paddr = vtophys(sc->csb); + uint64_t paddr = vtophys(sc->csb_gh); - bus_write_4(sc->iomem, PTNET_IO_CSBBAH, - (paddr >> 32) & 0xffffffff); - bus_write_4(sc->iomem, PTNET_IO_CSBBAL, paddr & 0xffffffff); + /* CSB allocation protocol: write to BAH first, then + * to BAL (for both GH and HG sections). */ + bus_write_4(sc->iomem, PTNET_IO_CSB_GH_BAH, + (paddr >> 32) & 0xffffffff); + bus_write_4(sc->iomem, PTNET_IO_CSB_GH_BAL, + paddr & 0xffffffff); + paddr = vtophys(sc->csb_hg); + bus_write_4(sc->iomem, PTNET_IO_CSB_HG_BAH, + (paddr >> 32) & 0xffffffff); + bus_write_4(sc->iomem, PTNET_IO_CSB_HG_BAL, + paddr & 0xffffffff); } - num_tx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_TX_RINGS); - num_rx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_RX_RINGS); - sc->num_rings = num_tx_rings + num_rx_rings; - sc->num_tx_rings = num_tx_rings; - /* Allocate and initialize per-queue data structures. */ sc->queues = malloc(sizeof(struct ptnet_queue) * sc->num_rings, M_DEVBUF, M_NOWAIT | M_ZERO); @@ -365,7 +378,8 @@ ptnet_attach(device_t dev) pq->sc = sc; pq->kring_id = i; pq->kick = PTNET_IO_KICK_BASE + 4 * i; - pq->ptring = sc->csb->rings + i; + pq->ptgh = sc->csb_gh + i; + pq->pthg = sc->csb_hg + i; snprintf(pq->lock_name, sizeof(pq->lock_name), "%s-%d", device_get_nameunit(dev), i); mtx_init(&pq->lock, pq->lock_name, NULL, MTX_DEF); @@ -467,7 +481,7 @@ ptnet_attach(device_t dev) na_arg.nm_txsync = ptnet_nm_txsync; na_arg.nm_rxsync = ptnet_nm_rxsync; - netmap_pt_guest_attach(&na_arg, sc->csb, nifp_offset, + netmap_pt_guest_attach(&na_arg, nifp_offset, bus_read_4(sc->iomem, PTNET_IO_HOSTMEMID)); /* Now a netmap adapter for this ifp has been allocated, and it @@ -526,11 +540,14 @@ ptnet_detach(device_t dev) ptnet_irqs_fini(sc); - if (sc->csb) { - bus_write_4(sc->iomem, PTNET_IO_CSBBAH, 0); - bus_write_4(sc->iomem, PTNET_IO_CSBBAL, 0); - free(sc->csb, M_DEVBUF); - sc->csb = NULL; + if (sc->csb_gh) { + bus_write_4(sc->iomem, PTNET_IO_CSB_GH_BAH, 0); + bus_write_4(sc->iomem, PTNET_IO_CSB_GH_BAL, 0); + bus_write_4(sc->iomem, PTNET_IO_CSB_HG_BAH, 0); + bus_write_4(sc->iomem, PTNET_IO_CSB_HG_BAL, 0); + contigfree(sc->csb_gh, 2*PAGE_SIZE, M_DEVBUF); + sc->csb_gh = NULL; + sc->csb_hg = NULL; } if (sc->queues) { @@ -777,7 +794,7 @@ ptnet_ioctl(if_t ifp, u_long cmd, caddr_t data) /* Make sure the worker sees the * IFF_DRV_RUNNING down. */ PTNET_Q_LOCK(pq); - pq->ptring->guest_need_kick = 0; + pq->ptgh->guest_need_kick = 0; PTNET_Q_UNLOCK(pq); /* Wait for rescheduling to finish. */ if (pq->taskq) { @@ -791,7 +808,7 @@ ptnet_ioctl(if_t ifp, u_long cmd, caddr_t data) for (i = 0; i < sc->num_rings; i++) { pq = sc-> queues + i; PTNET_Q_LOCK(pq); - pq->ptring->guest_need_kick = 1; + pq->ptgh->guest_need_kick = 1; PTNET_Q_UNLOCK(pq); } } @@ -1109,7 +1126,8 @@ ptnet_sync_from_csb(struct ptnet_softc *sc, struct net /* Sync krings from the host, reading from * CSB. */ for (i = 0; i < sc->num_rings; i++) { - struct ptnet_ring *ptring = sc->queues[i].ptring; + struct ptnet_csb_gh *ptgh = sc->queues[i].ptgh; + struct ptnet_csb_hg *pthg = sc->queues[i].pthg; struct netmap_kring *kring; if (i < na->num_tx_rings) { @@ -1117,15 +1135,15 @@ ptnet_sync_from_csb(struct ptnet_softc *sc, struct net } else { kring = na->rx_rings + i - na->num_tx_rings; } - kring->rhead = kring->ring->head = ptring->head; - kring->rcur = kring->ring->cur = ptring->cur; - kring->nr_hwcur = ptring->hwcur; + kring->rhead = kring->ring->head = ptgh->head; + kring->rcur = kring->ring->cur = ptgh->cur; + kring->nr_hwcur = pthg->hwcur; kring->nr_hwtail = kring->rtail = - kring->ring->tail = ptring->hwtail; + kring->ring->tail = pthg->hwtail; ND("%d,%d: csb {hc %u h %u c %u ht %u}", t, i, - ptring->hwcur, ptring->head, ptring->cur, - ptring->hwtail); + pthg->hwcur, ptgh->head, ptgh->cur, + pthg->hwtail); ND("%d,%d: kring {hc %u rh %u rc %u h %u c %u ht %u rt %u t %u}", t, i, kring->nr_hwcur, kring->rhead, kring->rcur, kring->ring->head, kring->ring->cur, kring->nr_hwtail, @@ -1169,7 +1187,7 @@ ptnet_nm_register(struct netmap_adapter *na, int onoff D("Exit netmap mode, re-enable interrupts"); for (i = 0; i < sc->num_rings; i++) { pq = sc->queues + i; - pq->ptring->guest_need_kick = 1; + pq->ptgh->guest_need_kick = 1; } } @@ -1178,8 +1196,8 @@ ptnet_nm_register(struct netmap_adapter *na, int onoff /* Initialize notification enable fields in the CSB. */ for (i = 0; i < sc->num_rings; i++) { pq = sc->queues + i; - pq->ptring->host_need_kick = 1; - pq->ptring->guest_need_kick = + pq->pthg->host_need_kick = 1; + pq->ptgh->guest_need_kick = (!(ifp->if_capenable & IFCAP_POLLING) && i >= sc->num_tx_rings); } @@ -1257,7 +1275,7 @@ ptnet_nm_txsync(struct netmap_kring *kring, int flags) struct ptnet_queue *pq = sc->queues + kring->ring_id; bool notify; - notify = netmap_pt_guest_txsync(pq->ptring, kring, flags); + notify = netmap_pt_guest_txsync(pq->ptgh, pq->pthg, kring, flags); if (notify) { ptnet_kick(pq); } @@ -1272,7 +1290,7 @@ ptnet_nm_rxsync(struct netmap_kring *kring, int flags) struct ptnet_queue *pq = sc->rxqueues + kring->ring_id; bool notify; - notify = netmap_pt_guest_rxsync(pq->ptring, kring, flags); + notify = netmap_pt_guest_rxsync(pq->ptgh, pq->pthg, kring, flags); if (notify) { ptnet_kick(pq); } @@ -1643,12 +1661,12 @@ ptnet_rx_csum(struct mbuf *m, struct virtio_net_hdr *h /* End of offloading-related functions to be shared with vtnet. */ static inline void -ptnet_sync_tail(struct ptnet_ring *ptring, struct netmap_kring *kring) +ptnet_sync_tail(struct ptnet_csb_hg *pthg, struct netmap_kring *kring) { struct netmap_ring *ring = kring->ring; /* Update hwcur and hwtail as known by the host. */ - ptnetmap_guest_read_kring_csb(ptring, kring); + ptnetmap_guest_read_kring_csb(pthg, kring); /* nm_sync_finalize */ ring->tail = kring->rtail = kring->nr_hwtail; @@ -1659,7 +1677,8 @@ ptnet_ring_update(struct ptnet_queue *pq, struct netma unsigned int head, unsigned int sync_flags) { struct netmap_ring *ring = kring->ring; - struct ptnet_ring *ptring = pq->ptring; + struct ptnet_csb_gh *ptgh = pq->ptgh; + struct ptnet_csb_hg *pthg = pq->pthg; /* Some packets have been pushed to the netmap ring. We have * to tell the host to process the new packets, updating cur @@ -1669,11 +1688,11 @@ ptnet_ring_update(struct ptnet_queue *pq, struct netma /* Mimic nm_txsync_prologue/nm_rxsync_prologue. */ kring->rcur = kring->rhead = head; - ptnetmap_guest_write_kring_csb(ptring, kring->rcur, kring->rhead); + ptnetmap_guest_write_kring_csb(ptgh, kring->rcur, kring->rhead); /* Kick the host if needed. */ - if (NM_ACCESS_ONCE(ptring->host_need_kick)) { - ptring->sync_flags = sync_flags; + if (NM_ACCESS_ONCE(pthg->host_need_kick)) { + ptgh->sync_flags = sync_flags; ptnet_kick(pq); } } @@ -1693,7 +1712,8 @@ ptnet_drain_transmit_queue(struct ptnet_queue *pq, uns struct netmap_adapter *na = &sc->ptna->dr.up; if_t ifp = sc->ifp; unsigned int batch_count = 0; - struct ptnet_ring *ptring; + struct ptnet_csb_gh *ptgh; + struct ptnet_csb_hg *pthg; struct netmap_kring *kring; struct netmap_ring *ring; struct netmap_slot *slot; @@ -1722,7 +1742,8 @@ ptnet_drain_transmit_queue(struct ptnet_queue *pq, uns return ENETDOWN; } - ptring = pq->ptring; + ptgh = pq->ptgh; + pthg = pq->pthg; kring = na->tx_rings + pq->kring_id; ring = kring->ring; lim = kring->nkr_num_slots - 1; @@ -1734,17 +1755,17 @@ ptnet_drain_transmit_queue(struct ptnet_queue *pq, uns /* We ran out of slot, let's see if the host has * freed up some, by reading hwcur and hwtail from * the CSB. */ - ptnet_sync_tail(ptring, kring); + ptnet_sync_tail(pthg, kring); if (PTNET_TX_NOSPACE(head, kring, minspace)) { /* Still no slots available. Reactivate the * interrupts so that we can be notified * when some free slots are made available by * the host. */ - ptring->guest_need_kick = 1; + ptgh->guest_need_kick = 1; /* Double-check. */ - ptnet_sync_tail(ptring, kring); + ptnet_sync_tail(pthg, kring); if (likely(PTNET_TX_NOSPACE(head, kring, minspace))) { break; @@ -1753,7 +1774,7 @@ ptnet_drain_transmit_queue(struct ptnet_queue *pq, uns RD(1, "Found more slots by doublecheck"); /* More slots were freed before reactivating * the interrupts. */ - ptring->guest_need_kick = 0; + ptgh->guest_need_kick = 0; } } @@ -1983,15 +2004,16 @@ ptnet_rx_eof(struct ptnet_queue *pq, unsigned int budg { struct ptnet_softc *sc = pq->sc; bool have_vnet_hdr = sc->vnet_hdr_len; - struct ptnet_ring *ptring = pq->ptring; + struct ptnet_csb_gh *ptgh = pq->ptgh; + struct ptnet_csb_hg *pthg = pq->pthg; struct netmap_adapter *na = &sc->ptna->dr.up; struct netmap_kring *kring = na->rx_rings + pq->kring_id; struct netmap_ring *ring = kring->ring; unsigned int const lim = kring->nkr_num_slots - 1; - unsigned int head = ring->head; unsigned int batch_count = 0; if_t ifp = sc->ifp; unsigned int count = 0; + uint32_t head; PTNET_Q_LOCK(pq); @@ -2001,33 +2023,35 @@ ptnet_rx_eof(struct ptnet_queue *pq, unsigned int budg kring->nr_kflags &= ~NKR_PENDINTR; + head = ring->head; while (count < budget) { - unsigned int prev_head = head; + uint32_t prev_head = head; struct mbuf *mhead, *mtail; struct virtio_net_hdr *vh; struct netmap_slot *slot; unsigned int nmbuf_len; uint8_t *nmbuf; + int deliver = 1; /* the mbuf to the network stack. */ host_sync: if (head == ring->tail) { /* We ran out of slot, let's see if the host has * added some, by reading hwcur and hwtail from * the CSB. */ - ptnet_sync_tail(ptring, kring); + ptnet_sync_tail(pthg, kring); if (head == ring->tail) { /* Still no slots available. Reactivate * interrupts as they were disabled by the * host thread right before issuing the * last interrupt. */ - ptring->guest_need_kick = 1; + ptgh->guest_need_kick = 1; /* Double-check. */ - ptnet_sync_tail(ptring, kring); + ptnet_sync_tail(pthg, kring); if (likely(head == ring->tail)) { break; } - ptring->guest_need_kick = 0; + ptgh->guest_need_kick = 0; } } @@ -2046,6 +2070,7 @@ host_sync: RD(1, "Fragmented vnet-hdr: dropping"); head = ptnet_rx_discard(kring, head); pq->stats.iqdrops ++; + deliver = 0; goto skip; } ND(1, "%s: vnet hdr: flags %x csum_start %u " @@ -2152,30 +2177,39 @@ host_sync: m_freem(mhead); RD(1, "Csum offload error: dropping"); pq->stats.iqdrops ++; - goto skip; + deliver = 0; } } - pq->stats.packets ++; - pq->stats.bytes += mhead->m_pkthdr.len; - - PTNET_Q_UNLOCK(pq); - (*ifp->if_input)(ifp, mhead); - PTNET_Q_LOCK(pq); - - if (unlikely(!(ifp->if_drv_flags & IFF_DRV_RUNNING))) { - /* The interface has gone down while we didn't - * have the lock. Stop any processing and exit. */ - goto unlock; - } skip: count ++; - if (++batch_count == PTNET_RX_BATCH) { - /* Some packets have been pushed to the network stack. - * We need to update the CSB to tell the host about the new - * ring->cur and ring->head (RX buffer refill). */ + if (++batch_count >= PTNET_RX_BATCH) { + /* Some packets have been (or will be) pushed to the network + * stack. We need to update the CSB to tell the host about + * the new ring->cur and ring->head (RX buffer refill). */ ptnet_ring_update(pq, kring, head, NAF_FORCE_READ); batch_count = 0; + } + + if (likely(deliver)) { + pq->stats.packets ++; + pq->stats.bytes += mhead->m_pkthdr.len; + + PTNET_Q_UNLOCK(pq); + (*ifp->if_input)(ifp, mhead); + PTNET_Q_LOCK(pq); + /* The ring->head index (and related indices) are + * updated under pq lock by ptnet_ring_update(). + * Since we dropped the lock to call if_input(), we + * must reload ring->head and restart processing the + * ring from there. */ + head = ring->head; + + if (unlikely(!(ifp->if_drv_flags & IFF_DRV_RUNNING))) { + /* The interface has gone down while we didn't + * have the lock. Stop any processing and exit. */ + goto unlock; + } } } escape: Modified: head/sys/dev/netmap/netmap_kern.h ============================================================================== --- head/sys/dev/netmap/netmap_kern.h Wed Apr 4 21:19:33 2018 (r332046) +++ head/sys/dev/netmap/netmap_kern.h Wed Apr 4 21:31:12 2018 (r332047) @@ -2126,8 +2126,6 @@ struct netmap_pt_guest_adapter { /* The netmap adapter to be used by the driver. */ struct netmap_hw_adapter dr; - void *csb; - /* Reference counter to track users of backend netmap port: the * network stack and netmap clients. * Used to decide when we need (de)allocate krings/rings and @@ -2136,13 +2134,18 @@ struct netmap_pt_guest_adapter { }; -int netmap_pt_guest_attach(struct netmap_adapter *na, void *csb, - unsigned int nifp_offset, unsigned int memid); -struct ptnet_ring; -bool netmap_pt_guest_txsync(struct ptnet_ring *ptring, struct netmap_kring *kring, - int flags); -bool netmap_pt_guest_rxsync(struct ptnet_ring *ptring, struct netmap_kring *kring, - int flags); +int netmap_pt_guest_attach(struct netmap_adapter *na, + unsigned int nifp_offset, + unsigned int memid); +struct ptnet_csb_gh; +struct ptnet_csb_hg; +bool netmap_pt_guest_txsync(struct ptnet_csb_gh *ptgh, + struct ptnet_csb_hg *pthg, + struct netmap_kring *kring, + int flags); +bool netmap_pt_guest_rxsync(struct ptnet_csb_gh *ptgh, + struct ptnet_csb_hg *pthg, + struct netmap_kring *kring, int flags); int ptnet_nm_krings_create(struct netmap_adapter *na); void ptnet_nm_krings_delete(struct netmap_adapter *na); void ptnet_nm_dtor(struct netmap_adapter *na); Modified: head/sys/dev/netmap/netmap_pt.c ============================================================================== --- head/sys/dev/netmap/netmap_pt.c Wed Apr 4 21:19:33 2018 (r332046) +++ head/sys/dev/netmap/netmap_pt.c Wed Apr 4 21:31:12 2018 (r332047) @@ -172,8 +172,9 @@ struct ptnetmap_state { /* Kthreads. */ struct nm_kctx **kctxs; - /* Shared memory with the guest (TX/RX) */ - struct ptnet_ring __user *ptrings; + /* Shared memory with the guest (TX/RX) */ + struct ptnet_csb_gh __user *csb_gh; + struct ptnet_csb_hg __user *csb_hg; bool stopped; @@ -200,29 +201,22 @@ ptnetmap_kring_dump(const char *title, const struct ne /* Enable or disable guest --> host kicks. */ static inline void -ptring_kick_enable(struct ptnet_ring __user *ptring, uint32_t val) +pthg_kick_enable(struct ptnet_csb_hg __user *pthg, uint32_t val) { - CSB_WRITE(ptring, host_need_kick, val); + CSB_WRITE(pthg, host_need_kick, val); } /* Are guest interrupt enabled or disabled? */ static inline uint32_t -ptring_intr_enabled(struct ptnet_ring __user *ptring) +ptgh_intr_enabled(struct ptnet_csb_gh __user *ptgh) { uint32_t v; - CSB_READ(ptring, guest_need_kick, v); + CSB_READ(ptgh, guest_need_kick, v); return v; } -/* Enable or disable guest interrupts. */ -static inline void -ptring_intr_enable(struct ptnet_ring __user *ptring, uint32_t val) -{ - CSB_WRITE(ptring, guest_need_kick, val); -} - /* Handle TX events: from the guest or from the backend */ static void ptnetmap_tx_handler(void *data, int is_kthread) @@ -231,7 +225,8 @@ ptnetmap_tx_handler(void *data, int is_kthread) struct netmap_pt_host_adapter *pth_na = (struct netmap_pt_host_adapter *)kring->na->na_private; struct ptnetmap_state *ptns = pth_na->ptns; - struct ptnet_ring __user *ptring; + struct ptnet_csb_gh __user *ptgh; + struct ptnet_csb_hg __user *pthg; struct netmap_ring shadow_ring; /* shadow copy of the netmap_ring */ bool more_txspace = false; struct nm_kctx *kth; @@ -257,18 +252,17 @@ ptnetmap_tx_handler(void *data, int is_kthread) /* This is a guess, to be fixed in the rate callback. */ IFRATE(ptns->rate_ctx.new.gtxk++); - /* Get TX ptring pointer from the CSB. */ - ptring = ptns->ptrings + kring->ring_id; + /* Get TX ptgh/pthg pointer from the CSB. */ + ptgh = ptns->csb_gh + kring->ring_id; + pthg = ptns->csb_hg + kring->ring_id; kth = ptns->kctxs[kring->ring_id]; num_slots = kring->nkr_num_slots; - shadow_ring.head = kring->rhead; - shadow_ring.cur = kring->rcur; /* Disable guest --> host notifications. */ - ptring_kick_enable(ptring, 0); + pthg_kick_enable(pthg, 0); /* Copy the guest kring pointers from the CSB */ - ptnetmap_host_read_kring_csb(ptring, &shadow_ring, num_slots); + ptnetmap_host_read_kring_csb(ptgh, &shadow_ring, num_slots); for (;;) { /* If guest moves ahead too fast, let's cut the move so @@ -299,7 +293,7 @@ ptnetmap_tx_handler(void *data, int is_kthread) if (unlikely(nm_txsync_prologue(kring, &shadow_ring) >= num_slots)) { /* Reinit ring and enable notifications. */ netmap_ring_reinit(kring); - ptring_kick_enable(ptring, 1); + pthg_kick_enable(pthg, 1); break; } @@ -310,7 +304,7 @@ ptnetmap_tx_handler(void *data, int is_kthread) IFRATE(pre_tail = kring->rtail); if (unlikely(kring->nm_sync(kring, shadow_ring.flags))) { /* Reenable notifications. */ - ptring_kick_enable(ptring, 1); + pthg_kick_enable(pthg, 1); D("ERROR txsync()"); break; } @@ -320,7 +314,7 @@ ptnetmap_tx_handler(void *data, int is_kthread) * Copy host hwcur and hwtail into the CSB for the guest sync(), and * do the nm_sync_finalize. */ - ptnetmap_host_write_kring_csb(ptring, kring->nr_hwcur, + ptnetmap_host_write_kring_csb(pthg, kring->nr_hwcur, kring->nr_hwtail); if (kring->rtail != kring->nr_hwtail) { /* Some more room available in the parent adapter. */ @@ -337,16 +331,15 @@ ptnetmap_tx_handler(void *data, int is_kthread) #ifndef BUSY_WAIT /* Interrupt the guest if needed. */ - if (more_txspace && ptring_intr_enabled(ptring) && is_kthread) { + if (more_txspace && ptgh_intr_enabled(ptgh) && is_kthread) { /* Disable guest kick to avoid sending unnecessary kicks */ - ptring_intr_enable(ptring, 0); nm_os_kctx_send_irq(kth); IFRATE(ptns->rate_ctx.new.htxk++); more_txspace = false; } #endif /* Read CSB to see if there is more work to do. */ - ptnetmap_host_read_kring_csb(ptring, &shadow_ring, num_slots); + ptnetmap_host_read_kring_csb(ptgh, &shadow_ring, num_slots); #ifndef BUSY_WAIT if (shadow_ring.head == kring->rhead) { /* @@ -358,13 +351,13 @@ ptnetmap_tx_handler(void *data, int is_kthread) usleep_range(1,1); } /* Reenable notifications. */ - ptring_kick_enable(ptring, 1); + pthg_kick_enable(pthg, 1); /* Doublecheck. */ - ptnetmap_host_read_kring_csb(ptring, &shadow_ring, num_slots); + ptnetmap_host_read_kring_csb(ptgh, &shadow_ring, num_slots); if (shadow_ring.head != kring->rhead) { /* We won the race condition, there are more packets to * transmit. Disable notifications and do another cycle */ - ptring_kick_enable(ptring, 0); + pthg_kick_enable(pthg, 0); continue; } break; @@ -385,8 +378,7 @@ ptnetmap_tx_handler(void *data, int is_kthread) nm_kr_put(kring); - if (more_txspace && ptring_intr_enabled(ptring) && is_kthread) { - ptring_intr_enable(ptring, 0); + if (more_txspace && ptgh_intr_enabled(ptgh) && is_kthread) { nm_os_kctx_send_irq(kth); IFRATE(ptns->rate_ctx.new.htxk++); } @@ -411,12 +403,12 @@ ptnetmap_tx_nothread_notify(void *data) return; } - /* We cannot access the CSB here (to check ptring->guest_need_kick), + /* We cannot access the CSB here (to check ptgh->guest_need_kick), * unless we switch address space to the one of the guest. For now * we unconditionally inject an interrupt. */ - nm_os_kctx_send_irq(ptns->kctxs[kring->ring_id]); - IFRATE(ptns->rate_ctx.new.htxk++); - ND(1, "%s interrupt", kring->name); + nm_os_kctx_send_irq(ptns->kctxs[kring->ring_id]); + IFRATE(ptns->rate_ctx.new.htxk++); + ND(1, "%s interrupt", kring->name); } /* @@ -440,7 +432,8 @@ ptnetmap_rx_handler(void *data, int is_kthread) struct netmap_pt_host_adapter *pth_na = (struct netmap_pt_host_adapter *)kring->na->na_private; struct ptnetmap_state *ptns = pth_na->ptns; - struct ptnet_ring __user *ptring; + struct ptnet_csb_gh __user *ptgh; + struct ptnet_csb_hg __user *pthg; struct netmap_ring shadow_ring; /* shadow copy of the netmap_ring */ struct nm_kctx *kth; uint32_t num_slots; @@ -467,18 +460,17 @@ ptnetmap_rx_handler(void *data, int is_kthread) /* This is a guess, to be fixed in the rate callback. */ IFRATE(ptns->rate_ctx.new.grxk++); - /* Get RX ptring pointer from the CSB. */ - ptring = ptns->ptrings + (pth_na->up.num_tx_rings + kring->ring_id); + /* Get RX ptgh and pthg pointers from the CSB. */ + ptgh = ptns->csb_gh + (pth_na->up.num_tx_rings + kring->ring_id); + pthg = ptns->csb_hg + (pth_na->up.num_tx_rings + kring->ring_id); kth = ptns->kctxs[pth_na->up.num_tx_rings + kring->ring_id]; num_slots = kring->nkr_num_slots; - shadow_ring.head = kring->rhead; - shadow_ring.cur = kring->rcur; /* Disable notifications. */ - ptring_kick_enable(ptring, 0); + pthg_kick_enable(pthg, 0); /* Copy the guest kring pointers from the CSB */ - ptnetmap_host_read_kring_csb(ptring, &shadow_ring, num_slots); + ptnetmap_host_read_kring_csb(ptgh, &shadow_ring, num_slots); for (;;) { uint32_t hwtail; @@ -488,7 +480,7 @@ ptnetmap_rx_handler(void *data, int is_kthread) if (unlikely(nm_rxsync_prologue(kring, &shadow_ring) >= num_slots)) { /* Reinit ring and enable notifications. */ netmap_ring_reinit(kring); - ptring_kick_enable(ptring, 1); + pthg_kick_enable(pthg, 1); break; } @@ -499,7 +491,7 @@ ptnetmap_rx_handler(void *data, int is_kthread) IFRATE(pre_tail = kring->rtail); if (unlikely(kring->nm_sync(kring, shadow_ring.flags))) { /* Reenable notifications. */ - ptring_kick_enable(ptring, 1); + pthg_kick_enable(pthg, 1); D("ERROR rxsync()"); break; } @@ -508,7 +500,7 @@ ptnetmap_rx_handler(void *data, int is_kthread) * Copy host hwcur and hwtail into the CSB for the guest sync() */ hwtail = NM_ACCESS_ONCE(kring->nr_hwtail); - ptnetmap_host_write_kring_csb(ptring, kring->nr_hwcur, hwtail); + ptnetmap_host_write_kring_csb(pthg, kring->nr_hwcur, hwtail); if (kring->rtail != hwtail) { kring->rtail = hwtail; some_recvd = true; @@ -526,16 +518,15 @@ ptnetmap_rx_handler(void *data, int is_kthread) #ifndef BUSY_WAIT /* Interrupt the guest if needed. */ - if (some_recvd && ptring_intr_enabled(ptring)) { + if (some_recvd && ptgh_intr_enabled(ptgh)) { /* Disable guest kick to avoid sending unnecessary kicks */ - ptring_intr_enable(ptring, 0); nm_os_kctx_send_irq(kth); IFRATE(ptns->rate_ctx.new.hrxk++); some_recvd = false; } #endif /* Read CSB to see if there is more work to do. */ - ptnetmap_host_read_kring_csb(ptring, &shadow_ring, num_slots); + ptnetmap_host_read_kring_csb(ptgh, &shadow_ring, num_slots); #ifndef BUSY_WAIT if (ptnetmap_norxslots(kring, shadow_ring.head)) { /* @@ -545,13 +536,13 @@ ptnetmap_rx_handler(void *data, int is_kthread) */ usleep_range(1,1); /* Reenable notifications. */ - ptring_kick_enable(ptring, 1); + pthg_kick_enable(pthg, 1); /* Doublecheck. */ - ptnetmap_host_read_kring_csb(ptring, &shadow_ring, num_slots); + ptnetmap_host_read_kring_csb(ptgh, &shadow_ring, num_slots); if (!ptnetmap_norxslots(kring, shadow_ring.head)) { /* We won the race condition, more slots are available. Disable * notifications and do another cycle. */ - ptring_kick_enable(ptring, 0); + pthg_kick_enable(pthg, 0); continue; } break; @@ -576,8 +567,7 @@ ptnetmap_rx_handler(void *data, int is_kthread) nm_kr_put(kring); /* Interrupt the guest if needed. */ - if (some_recvd && ptring_intr_enabled(ptring)) { - ptring_intr_enable(ptring, 0); + if (some_recvd && ptgh_intr_enabled(ptgh)) { nm_os_kctx_send_irq(kth); IFRATE(ptns->rate_ctx.new.hrxk++); } @@ -590,8 +580,8 @@ ptnetmap_print_configuration(struct ptnetmap_cfg *cfg) int k; D("ptnetmap configuration:"); - D(" CSB ptrings @%p, num_rings=%u, cfgtype %08x", cfg->ptrings, - cfg->num_rings, cfg->cfgtype); + D(" CSB @%p@:%p, num_rings=%u, cfgtype %08x", cfg->csb_gh, + cfg->csb_hg, cfg->num_rings, cfg->cfgtype); for (k = 0; k < cfg->num_rings; k++) { switch (cfg->cfgtype) { case PTNETMAP_CFGTYPE_QEMU: { @@ -624,16 +614,18 @@ ptnetmap_print_configuration(struct ptnetmap_cfg *cfg) /* Copy actual state of the host ring into the CSB for the guest init */ static int -ptnetmap_kring_snapshot(struct netmap_kring *kring, struct ptnet_ring __user *ptring) +ptnetmap_kring_snapshot(struct netmap_kring *kring, + struct ptnet_csb_gh __user *ptgh, + struct ptnet_csb_hg __user *pthg) { - if (CSB_WRITE(ptring, head, kring->rhead)) + if (CSB_WRITE(ptgh, head, kring->rhead)) goto err; - if (CSB_WRITE(ptring, cur, kring->rcur)) + if (CSB_WRITE(ptgh, cur, kring->rcur)) goto err; - if (CSB_WRITE(ptring, hwcur, kring->nr_hwcur)) + if (CSB_WRITE(pthg, hwcur, kring->nr_hwcur)) goto err; - if (CSB_WRITE(ptring, hwtail, NM_ACCESS_ONCE(kring->nr_hwtail))) + if (CSB_WRITE(pthg, hwtail, NM_ACCESS_ONCE(kring->nr_hwtail))) goto err; DBG(ptnetmap_kring_dump("ptnetmap_kring_snapshot", kring);) @@ -665,7 +657,8 @@ ptnetmap_krings_snapshot(struct netmap_pt_host_adapter for (k = 0; k < num_rings; k++) { kring = ptnetmap_kring(pth_na, k); - err |= ptnetmap_kring_snapshot(kring, ptns->ptrings + k); + err |= ptnetmap_kring_snapshot(kring, ptns->csb_gh + k, + ptns->csb_hg + k); } return err; @@ -842,7 +835,8 @@ ptnetmap_create(struct netmap_pt_host_adapter *pth_na, ptns->pth_na = pth_na; /* Store the CSB address provided by the hypervisor. */ - ptns->ptrings = cfg->ptrings; + ptns->csb_gh = cfg->csb_gh; + ptns->csb_hg = cfg->csb_hg; DBG(ptnetmap_print_configuration(cfg)); @@ -1321,26 +1315,26 @@ put_out_noputparent: * block (no space in the ring). */ bool -netmap_pt_guest_txsync(struct ptnet_ring *ptring, struct netmap_kring *kring, - int flags) +netmap_pt_guest_txsync(struct ptnet_csb_gh *ptgh, struct ptnet_csb_hg *pthg, + struct netmap_kring *kring, int flags) { bool notify = false; /* Disable notifications */ - ptring->guest_need_kick = 0; + ptgh->guest_need_kick = 0; /* * First part: tell the host (updating the CSB) to process the new * packets. */ - kring->nr_hwcur = ptring->hwcur; - ptnetmap_guest_write_kring_csb(ptring, kring->rcur, kring->rhead); + kring->nr_hwcur = pthg->hwcur; + ptnetmap_guest_write_kring_csb(ptgh, kring->rcur, kring->rhead); /* Ask for a kick from a guest to the host if needed. */ if (((kring->rhead != kring->nr_hwcur || nm_kr_txempty(kring)) - && NM_ACCESS_ONCE(ptring->host_need_kick)) || + && NM_ACCESS_ONCE(pthg->host_need_kick)) || (flags & NAF_FORCE_RECLAIM)) { - ptring->sync_flags = flags; + ptgh->sync_flags = flags; notify = true; } @@ -1348,7 +1342,7 @@ netmap_pt_guest_txsync(struct ptnet_ring *ptring, stru * Second part: reclaim buffers for completed transmissions. */ if (nm_kr_txempty(kring) || (flags & NAF_FORCE_RECLAIM)) { - ptnetmap_guest_read_kring_csb(ptring, kring); + ptnetmap_guest_read_kring_csb(pthg, kring); } /* @@ -1358,17 +1352,17 @@ netmap_pt_guest_txsync(struct ptnet_ring *ptring, stru */ if (nm_kr_txempty(kring)) { /* Reenable notifications. */ - ptring->guest_need_kick = 1; + ptgh->guest_need_kick = 1; /* Double check */ - ptnetmap_guest_read_kring_csb(ptring, kring); + ptnetmap_guest_read_kring_csb(pthg, kring); /* If there is new free space, disable notifications */ if (unlikely(!nm_kr_txempty(kring))) { - ptring->guest_need_kick = 0; + ptgh->guest_need_kick = 0; } } ND(1, "%s CSB(head:%u cur:%u hwtail:%u) KRING(head:%u cur:%u tail:%u)", - kring->name, ptring->head, ptring->cur, ptring->hwtail, + kring->name, ptgh->head, ptgh->cur, pthg->hwtail, kring->rhead, kring->rcur, kring->nr_hwtail); return notify; @@ -1386,20 +1380,20 @@ netmap_pt_guest_txsync(struct ptnet_ring *ptring, stru * block (no more completed slots in the ring). */ bool -netmap_pt_guest_rxsync(struct ptnet_ring *ptring, struct netmap_kring *kring, - int flags) +netmap_pt_guest_rxsync(struct ptnet_csb_gh *ptgh, struct ptnet_csb_hg *pthg, + struct netmap_kring *kring, int flags) { bool notify = false; /* Disable notifications */ - ptring->guest_need_kick = 0; + ptgh->guest_need_kick = 0; /* * First part: import newly received packets, by updating the kring * hwtail to the hwtail known from the host (read from the CSB). * This also updates the kring hwcur. */ - ptnetmap_guest_read_kring_csb(ptring, kring); + ptnetmap_guest_read_kring_csb(pthg, kring); kring->nr_kflags &= ~NKR_PENDINTR; /* @@ -1407,11 +1401,11 @@ netmap_pt_guest_rxsync(struct ptnet_ring *ptring, stru * released, by updating cur and head in the CSB. */ if (kring->rhead != kring->nr_hwcur) { - ptnetmap_guest_write_kring_csb(ptring, kring->rcur, + ptnetmap_guest_write_kring_csb(ptgh, kring->rcur, kring->rhead); /* Ask for a kick from the guest to the host if needed. */ - if (NM_ACCESS_ONCE(ptring->host_need_kick)) { - ptring->sync_flags = flags; + if (NM_ACCESS_ONCE(pthg->host_need_kick)) { + ptgh->sync_flags = flags; notify = true; } } @@ -1423,17 +1417,17 @@ netmap_pt_guest_rxsync(struct ptnet_ring *ptring, stru */ if (nm_kr_rxempty(kring)) { /* Reenable notifications. */ - ptring->guest_need_kick = 1; + ptgh->guest_need_kick = 1; /* Double check */ - ptnetmap_guest_read_kring_csb(ptring, kring); + ptnetmap_guest_read_kring_csb(pthg, kring); /* If there are new slots, disable notifications. */ if (!nm_kr_rxempty(kring)) { - ptring->guest_need_kick = 0; + ptgh->guest_need_kick = 0; } } ND(1, "%s CSB(head:%u cur:%u hwtail:%u) KRING(head:%u cur:%u tail:%u)", - kring->name, ptring->head, ptring->cur, ptring->hwtail, + kring->name, ptgh->head, ptgh->cur, pthg->hwtail, kring->rhead, kring->rcur, kring->nr_hwtail); return notify; @@ -1492,13 +1486,13 @@ ptnet_nm_dtor(struct netmap_adapter *na) struct netmap_pt_guest_adapter *ptna = (struct netmap_pt_guest_adapter *)na; - netmap_mem_put(ptna->dr.up.nm_mem); // XXX is this needed? + netmap_mem_put(ptna->dr.up.nm_mem); memset(&ptna->dr, 0, sizeof(ptna->dr)); netmap_mem_pt_guest_ifp_del(na->nm_mem, na->ifp); } int -netmap_pt_guest_attach(struct netmap_adapter *arg, void *csb, +netmap_pt_guest_attach(struct netmap_adapter *arg, unsigned int nifp_offset, unsigned int memid) { struct netmap_pt_guest_adapter *ptna; @@ -1516,7 +1510,6 @@ netmap_pt_guest_attach(struct netmap_adapter *arg, voi /* get the netmap_pt_guest_adapter */ ptna = (struct netmap_pt_guest_adapter *) NA(ifp); - ptna->csb = csb; /* Initialize a separate pass-through netmap adapter that is going to * be used by the ptnet driver only, and so never exposed to netmap Modified: head/sys/net/netmap_virt.h ============================================================================== --- head/sys/net/netmap_virt.h Wed Apr 4 21:19:33 2018 (r332046) +++ head/sys/net/netmap_virt.h Wed Apr 4 21:31:12 2018 (r332047) @@ -85,7 +85,8 @@ struct ptnetmap_cfg { uint16_t cfgtype; /* how to interpret the cfg entries */ uint16_t entry_size; /* size of a config entry */ uint32_t num_rings; /* number of config entries */ - void *ptrings; /* ptrings inside CSB */ + void *csb_gh; /* CSB for guest --> host communication */ + void *csb_hg; /* CSB for host --> guest communication */ /* Configuration entries are allocated right after the struct. */ }; @@ -146,8 +147,8 @@ nmreq_pointer_put(struct nmreq *nmr, void *userptr) #define PTNET_IO_PTCTL 4 #define PTNET_IO_MAC_LO 8 #define PTNET_IO_MAC_HI 12 -#define PTNET_IO_CSBBAH 16 -#define PTNET_IO_CSBBAL 20 +#define PTNET_IO_CSBBAH 16 /* deprecated */ +#define PTNET_IO_CSBBAL 20 /* deprecated */ #define PTNET_IO_NIFP_OFS 24 #define PTNET_IO_NUM_TX_RINGS 28 #define PTNET_IO_NUM_RX_RINGS 32 @@ -155,7 +156,11 @@ nmreq_pointer_put(struct nmreq *nmr, void *userptr) #define PTNET_IO_NUM_RX_SLOTS 40 #define PTNET_IO_VNET_HDR_LEN 44 #define PTNET_IO_HOSTMEMID 48 -#define PTNET_IO_END 52 +#define PTNET_IO_CSB_GH_BAH 52 +#define PTNET_IO_CSB_GH_BAL 56 +#define PTNET_IO_CSB_HG_BAH 60 +#define PTNET_IO_CSB_HG_BAL 64 +#define PTNET_IO_END 68 #define PTNET_IO_KICK_BASE 128 #define PTNET_IO_MASK 0xff @@ -163,28 +168,21 @@ nmreq_pointer_put(struct nmreq *nmr, void *userptr) #define PTNETMAP_PTCTL_CREATE 1 #define PTNETMAP_PTCTL_DELETE 2 *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Wed Apr 4 22:45:09 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 88E71F7CC5B; Wed, 4 Apr 2018 22:45:09 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3B3F877EE9; Wed, 4 Apr 2018 22:45:09 +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 31E8C1A117; Wed, 4 Apr 2018 22:45:09 +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 w34Mj9vJ020159; Wed, 4 Apr 2018 22:45:09 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34Mj8o1020153; Wed, 4 Apr 2018 22:45:08 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804042245.w34Mj8o1020153@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 4 Apr 2018 22:45:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332048 - in head/lib/libc: aarch64/sys amd64/sys arm/sys i386/sys riscv/sys X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in head/lib/libc: aarch64/sys amd64/sys arm/sys i386/sys riscv/sys X-SVN-Commit-Revision: 332048 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 22:45:09 -0000 Author: brooks Date: Wed Apr 4 22:45:08 2018 New Revision: 332048 URL: https://svnweb.freebsd.org/changeset/base/332048 Log: Remove architecture specific sigreturn.S files. All of these files are identical (modulo license blocks and VCS IDs) to the files generated by lib/libc/sys/Makefile.inc and serve no purpose. Reported by: Ali Mashtizadeh Reviewed by: kib Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14953 Deleted: head/lib/libc/aarch64/sys/sigreturn.S head/lib/libc/amd64/sys/sigreturn.S head/lib/libc/arm/sys/sigreturn.S head/lib/libc/i386/sys/sigreturn.S head/lib/libc/riscv/sys/sigreturn.S Modified: head/lib/libc/aarch64/sys/Makefile.inc head/lib/libc/amd64/sys/Makefile.inc head/lib/libc/arm/sys/Makefile.inc head/lib/libc/i386/sys/Makefile.inc head/lib/libc/riscv/sys/Makefile.inc Modified: head/lib/libc/aarch64/sys/Makefile.inc ============================================================================== --- head/lib/libc/aarch64/sys/Makefile.inc Wed Apr 4 21:31:12 2018 (r332047) +++ head/lib/libc/aarch64/sys/Makefile.inc Wed Apr 4 22:45:08 2018 (r332048) @@ -6,7 +6,6 @@ SRCS+= __vdso_gettc.c MDASM= cerror.S \ shmat.S \ - sigreturn.S \ syscall.S \ vfork.S Modified: head/lib/libc/amd64/sys/Makefile.inc ============================================================================== --- head/lib/libc/amd64/sys/Makefile.inc Wed Apr 4 21:31:12 2018 (r332047) +++ head/lib/libc/amd64/sys/Makefile.inc Wed Apr 4 22:45:08 2018 (r332048) @@ -9,7 +9,7 @@ SRCS+= \ amd64_set_gsbase.c MDASM= vfork.S brk.S cerror.S exect.S getcontext.S \ - sbrk.S setlogin.S sigreturn.S + sbrk.S setlogin.S # Don't generate default code for these syscalls: NOASM+= vfork.o Modified: head/lib/libc/arm/sys/Makefile.inc ============================================================================== --- head/lib/libc/arm/sys/Makefile.inc Wed Apr 4 21:31:12 2018 (r332047) +++ head/lib/libc/arm/sys/Makefile.inc Wed Apr 4 22:45:08 2018 (r332048) @@ -2,7 +2,7 @@ SRCS+= __vdso_gettc.c -MDASM= Ovfork.S brk.S cerror.S sbrk.S shmat.S sigreturn.S syscall.S +MDASM= Ovfork.S brk.S cerror.S sbrk.S shmat.S syscall.S # Don't generate default code for these syscalls: NOASM+= vfork.o Modified: head/lib/libc/i386/sys/Makefile.inc ============================================================================== --- head/lib/libc/i386/sys/Makefile.inc Wed Apr 4 21:31:12 2018 (r332047) +++ head/lib/libc/i386/sys/Makefile.inc Wed Apr 4 22:45:08 2018 (r332048) @@ -8,7 +8,7 @@ SRCS+= i386_get_fsbase.c i386_get_gsbase.c i386_get_io i386_set_fsbase.c i386_set_gsbase.c i386_set_ioperm.c i386_set_ldt.c MDASM= Ovfork.S brk.S cerror.S exect.S getcontext.S \ - sbrk.S setlogin.S sigreturn.S syscall.S + sbrk.S setlogin.S syscall.S NOASM+= vfork.o Modified: head/lib/libc/riscv/sys/Makefile.inc ============================================================================== --- head/lib/libc/riscv/sys/Makefile.inc Wed Apr 4 21:31:12 2018 (r332047) +++ head/lib/libc/riscv/sys/Makefile.inc Wed Apr 4 22:45:08 2018 (r332048) @@ -5,7 +5,6 @@ SRCS+= trivial-vdso_tc.c #MDASM= ptrace.S MDASM= cerror.S \ shmat.S \ - sigreturn.S \ syscall.S \ vfork.S From owner-svn-src-head@freebsd.org Wed Apr 4 22:46:31 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 470DCF7CE43; Wed, 4 Apr 2018 22:46:31 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F2105780B8; Wed, 4 Apr 2018 22:46:30 +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 ED0AA1A121; Wed, 4 Apr 2018 22:46:30 +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 w34MkUqu020656; Wed, 4 Apr 2018 22:46:30 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34MkUYB020655; Wed, 4 Apr 2018 22:46:30 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804042246.w34MkUYB020655@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 4 Apr 2018 22:46:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332049 - head X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: head X-SVN-Commit-Revision: 332049 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 22:46:31 -0000 Author: brooks Date: Wed Apr 4 22:46:30 2018 New Revision: 332049 URL: https://svnweb.freebsd.org/changeset/base/332049 Log: Allow -DNO_CLEAN builds over r332048. Modified: head/Makefile.inc1 Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Wed Apr 4 22:45:08 2018 (r332048) +++ head/Makefile.inc1 Wed Apr 4 22:46:30 2018 (r332049) @@ -802,11 +802,12 @@ _sanity_check: .PHONY .MAKE # tree changes, particularly with respect to removing source files and # replacing generated files. Handle these cases here in an ad-hoc fashion. _cleanobj_fast_depend_hack: .PHONY -# Syscall stubs rewritten in C +# Syscall stubs rewritten in C and obsolete MD assembly implementations # Date SVN Rev Syscalls # 20160829 r305012 ptrace # 20170624 r320278 fstat fstatat fstatfs getdirentries getfsstat statfs -.for f in fstat fstatat fstatfs getdirentries getfsstat ptrace statfs +# 20180404 r332048 sigreturn +.for f in fstat fstatat fstatfs getdirentries getfsstat ptrace sigreturn statfs .if exists(${OBJTOP}/lib/libc/.depend.${f}.o) @if egrep -qw '${f}\.[sS]' \ ${OBJTOP}/lib/libc/.depend.${f}.o; then \ From owner-svn-src-head@freebsd.org Wed Apr 4 22:52:24 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A351DF7D489; Wed, 4 Apr 2018 22:52:24 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 56F6978673; Wed, 4 Apr 2018 22:52:24 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5181E1A2A8; Wed, 4 Apr 2018 22:52:24 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w34MqOOm026644; Wed, 4 Apr 2018 22:52:24 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w34MqOx5026643; Wed, 4 Apr 2018 22:52:24 GMT (envelope-from np@FreeBSD.org) Message-Id: <201804042252.w34MqOx5026643@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Wed, 4 Apr 2018 22:52:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332050 - head/sys/dev/cxgbe X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: head/sys/dev/cxgbe X-SVN-Commit-Revision: 332050 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 22:52:24 -0000 Author: np Date: Wed Apr 4 22:52:24 2018 New Revision: 332050 URL: https://svnweb.freebsd.org/changeset/base/332050 Log: cxgbe(4): Always display an error message if SIOCSIFFLAGS will leave IFF_UP and IFF_DRV_RUNNING out of sync. ifhwioctl in the kernel pays no attention to the return code from the driver ioctl during SIOCSIFFLAGS so these messages are the only indication that the ioctl was called but failed. MFC after: 1 week Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Wed Apr 4 22:46:30 2018 (r332049) +++ head/sys/dev/cxgbe/t4_main.c Wed Apr 4 22:52:24 2018 (r332050) @@ -1636,8 +1636,13 @@ cxgbe_ioctl(struct ifnet *ifp, unsigned long cmd, cadd redo_sifflags: rc = begin_synchronized_op(sc, vi, can_sleep ? (SLEEP_OK | INTR_OK) : HOLD_LOCK, "t4flg"); - if (rc) + if (rc) { + if_printf(ifp, "%ssleepable synch operation failed: %d." + " if_flags 0x%08x, if_drv_flags 0x%08x\n", + can_sleep ? "" : "non-", rc, ifp->if_flags, + ifp->if_drv_flags); return (rc); + } if (ifp->if_flags & IFF_UP) { if (ifp->if_drv_flags & IFF_DRV_RUNNING) { @@ -4306,8 +4311,13 @@ cxgbe_uninit_synchronized(struct vi_info *vi) ASSERT_SYNCHRONIZED_OP(sc); if (!(vi->flags & VI_INIT_DONE)) { - KASSERT(!(ifp->if_drv_flags & IFF_DRV_RUNNING), - ("uninited VI is running")); + if (__predict_false(ifp->if_drv_flags & IFF_DRV_RUNNING)) { + KASSERT(0, ("uninited VI is running")); + if_printf(ifp, "uninited VI with running ifnet. " + "vi->flags 0x%016lx, if_flags 0x%08x, " + "if_drv_flags 0x%08x\n", vi->flags, ifp->if_flags, + ifp->if_drv_flags); + } return (0); } From owner-svn-src-head@freebsd.org Thu Apr 5 00:32:02 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0D128F83567; Thu, 5 Apr 2018 00:32:02 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B70727C4E8; Thu, 5 Apr 2018 00:32:01 +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 B1DF71B2D0; Thu, 5 Apr 2018 00:32:01 +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 w350W1n6005994; Thu, 5 Apr 2018 00:32:01 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w350W196005991; Thu, 5 Apr 2018 00:32:01 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201804050032.w350W196005991@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Thu, 5 Apr 2018 00:32:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332055 - head/sys/ufs/ffs X-SVN-Group: head X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: head/sys/ufs/ffs X-SVN-Commit-Revision: 332055 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 00:32:02 -0000 Author: mckusick Date: Thu Apr 5 00:32:01 2018 New Revision: 332055 URL: https://svnweb.freebsd.org/changeset/base/332055 Log: Renumber soft-update types starting at 1 instead of 0 to avoid confusion of zero'ed memory appearing to have a valid soft-update type. Also correct some comments. Reviewed by: kib Modified: head/sys/ufs/ffs/ffs_softdep.c head/sys/ufs/ffs/softdep.h Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Thu Apr 5 00:03:38 2018 (r332054) +++ head/sys/ufs/ffs/ffs_softdep.c Thu Apr 5 00:32:01 2018 (r332055) @@ -688,6 +688,7 @@ static MALLOC_DEFINE(M_MOUNTDATA, "softdep", "Softdep * MUST match the defines above, such that memtype[D_XXX] == M_XXX */ static struct malloc_type *memtype[] = { + NULL, M_PAGEDEP, M_INODEDEP, M_BMSAFEMAP, @@ -724,7 +725,8 @@ static struct malloc_type *memtype[] = { * Names of malloc types. */ #define TYPENAME(type) \ - ((unsigned)(type) <= D_LAST ? memtype[type]->ks_shortdesc : "???") + ((unsigned)(type) <= D_LAST && (unsigned)(type) >= D_FIRST ? \ + memtype[type]->ks_shortdesc : "???") /* * End system adaptation definitions. */ @@ -12960,7 +12962,7 @@ flush_newblk_dep(vp, mp, lbn) break; } if (newblk->nb_list.wk_type != D_ALLOCDIRECT) - panic("flush_newblk_deps: Bad newblk %p", newblk); + panic("flush_newblk_dep: Bad newblk %p", newblk); /* * Flush the journal. */ Modified: head/sys/ufs/ffs/softdep.h ============================================================================== --- head/sys/ufs/ffs/softdep.h Thu Apr 5 00:03:38 2018 (r332054) +++ head/sys/ufs/ffs/softdep.h Thu Apr 5 00:32:01 2018 (r332055) @@ -146,37 +146,45 @@ #define ALLCOMPLETE (ATTACHED | COMPLETE | DEPCOMPLETE) +#define PRINT_SOFTDEP_FLAGS "\20\27writesucceeded\26unlinkonlist" \ + "\25unlinkprev\24unlinknext\23unlinked\22ondeplist\21iowaiting" \ + "\20onworklist\17extdata\16ufs1fmt\15inprogress\14newblock" \ + "\13delayedfree\12iostarted\11goingaway\10dirchg\7rmdir\6mkdir_body" \ + "\5mkdir_parent\4depcomplete\3complete\2undone\1attached" + /* * Values for each of the soft dependency types. */ -#define D_PAGEDEP 0 -#define D_INODEDEP 1 -#define D_BMSAFEMAP 2 -#define D_NEWBLK 3 -#define D_ALLOCDIRECT 4 -#define D_INDIRDEP 5 -#define D_ALLOCINDIR 6 -#define D_FREEFRAG 7 -#define D_FREEBLKS 8 -#define D_FREEFILE 9 -#define D_DIRADD 10 -#define D_MKDIR 11 -#define D_DIRREM 12 -#define D_NEWDIRBLK 13 -#define D_FREEWORK 14 -#define D_FREEDEP 15 -#define D_JADDREF 16 -#define D_JREMREF 17 -#define D_JMVREF 18 -#define D_JNEWBLK 19 -#define D_JFREEBLK 20 -#define D_JFREEFRAG 21 -#define D_JSEG 22 -#define D_JSEGDEP 23 -#define D_SBDEP 24 -#define D_JTRUNC 25 -#define D_JFSYNC 26 -#define D_SENTINEL 27 +#define D_UNUSED 0 +#define D_FIRST D_PAGEDEP +#define D_PAGEDEP 1 +#define D_INODEDEP 2 +#define D_BMSAFEMAP 3 +#define D_NEWBLK 4 +#define D_ALLOCDIRECT 5 +#define D_INDIRDEP 6 +#define D_ALLOCINDIR 7 +#define D_FREEFRAG 8 +#define D_FREEBLKS 9 +#define D_FREEFILE 10 +#define D_DIRADD 11 +#define D_MKDIR 12 +#define D_DIRREM 13 +#define D_NEWDIRBLK 14 +#define D_FREEWORK 15 +#define D_FREEDEP 16 +#define D_JADDREF 17 +#define D_JREMREF 18 +#define D_JMVREF 19 +#define D_JNEWBLK 20 +#define D_JFREEBLK 21 +#define D_JFREEFRAG 22 +#define D_JSEG 23 +#define D_JSEGDEP 24 +#define D_SBDEP 25 +#define D_JTRUNC 26 +#define D_JFSYNC 27 +#define D_SENTINEL 28 #define D_LAST D_SENTINEL /* @@ -469,17 +477,17 @@ struct allocdirect { * A single "indirdep" structure manages all allocation dependencies for * pointers in an indirect block. The up-to-date state of the indirect * block is stored in ir_savedata. The set of pointers that may be safely - * written to the disk is stored in ir_safecopy. The state field is used + * written to the disk is stored in ir_savebp. The state field is used * only to track whether the buffer is currently being written (in which - * case it is not safe to update ir_safecopy). Ir_deplisthd contains the + * case it is not safe to update ir_savebp). Ir_deplisthd contains the * list of allocindir structures, one for each block that needs to be * written to disk. Once the block and its bitmap allocation have been * written the safecopy can be updated to reflect the allocation and the * allocindir structure freed. If ir_state indicates that an I/O on the - * indirect block is in progress when ir_safecopy is to be updated, the + * indirect block is in progress when ir_savebp is to be updated, the * update is deferred by placing the allocindir on the ir_donehd list. * When the I/O on the indirect block completes, the entries on the - * ir_donehd list are processed by updating their corresponding ir_safecopy + * ir_donehd list are processed by updating their corresponding ir_savebp * pointers and then freeing the allocindir structure. */ struct indirdep { From owner-svn-src-head@freebsd.org Thu Apr 5 03:26:43 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 66230F82D82; Thu, 5 Apr 2018 03:26:43 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EF9A683F1F; Thu, 5 Apr 2018 03:26:42 +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 EA7091D03D; Thu, 5 Apr 2018 03:26:42 +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 w353QgA1042419; Thu, 5 Apr 2018 03:26:42 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w353Qgsh042418; Thu, 5 Apr 2018 03:26:42 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201804050326.w353Qgsh042418@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 5 Apr 2018 03:26:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332057 - head X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head X-SVN-Commit-Revision: 332057 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 03:26:43 -0000 Author: emaste Date: Thu Apr 5 03:26:42 2018 New Revision: 332057 URL: https://svnweb.freebsd.org/changeset/base/332057 Log: remove special handling for stale ptrace dependencies r318957 added special handling for stale ptrace dependency files to support a -DNO_CLEAN build in a tree last built before r305012. That revision is now over a year and a half old, so retire the special case. Sponsored by: The FreeBSD Foundation Modified: head/Makefile.inc1 Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Thu Apr 5 00:41:33 2018 (r332056) +++ head/Makefile.inc1 Thu Apr 5 03:26:42 2018 (r332057) @@ -804,10 +804,9 @@ _sanity_check: .PHONY .MAKE _cleanobj_fast_depend_hack: .PHONY # Syscall stubs rewritten in C and obsolete MD assembly implementations # Date SVN Rev Syscalls -# 20160829 r305012 ptrace # 20170624 r320278 fstat fstatat fstatfs getdirentries getfsstat statfs # 20180404 r332048 sigreturn -.for f in fstat fstatat fstatfs getdirentries getfsstat ptrace sigreturn statfs +.for f in fstat fstatat fstatfs getdirentries getfsstat sigreturn statfs .if exists(${OBJTOP}/lib/libc/.depend.${f}.o) @if egrep -qw '${f}\.[sS]' \ ${OBJTOP}/lib/libc/.depend.${f}.o; then \ From owner-svn-src-head@freebsd.org Thu Apr 5 11:03:06 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 37CEAF9E75B; Thu, 5 Apr 2018 11:03:06 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C9B8875B1E; Thu, 5 Apr 2018 11:03:05 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C30E421C53; Thu, 5 Apr 2018 11:03:05 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w35B35U8093636; Thu, 5 Apr 2018 11:03:05 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35B35dt093635; Thu, 5 Apr 2018 11:03:05 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201804051103.w35B35dt093635@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 5 Apr 2018 11:03:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332060 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 332060 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 11:03:06 -0000 Author: kib Date: Thu Apr 5 11:03:05 2018 New Revision: 332060 URL: https://svnweb.freebsd.org/changeset/base/332060 Log: Make the INTO instruction operational in 32bit mode. Having the IDT entry specify ring 0 DPL caused delivery of #GP instead of #OF. The instruction is not valid in 64bit mode, which probably explains why the IDT entry for #OF was initially set this way. It is interesting to note that the BOUND instruction works with the IDT #BR entry DPL 0, most likely CPU considers #BR from BOUND as generated by a machine, not user. Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/amd64/amd64/machdep.c Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Thu Apr 5 06:21:51 2018 (r332059) +++ head/sys/amd64/amd64/machdep.c Thu Apr 5 11:03:05 2018 (r332060) @@ -1636,7 +1636,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) setidt(IDT_BP, pti ? &IDTVEC(bpt_pti) : &IDTVEC(bpt), SDT_SYSIGT, SEL_UPL, 0); setidt(IDT_OF, pti ? &IDTVEC(ofl_pti) : &IDTVEC(ofl), SDT_SYSIGT, - SEL_KPL, 0); + SEL_UPL, 0); setidt(IDT_BR, pti ? &IDTVEC(bnd_pti) : &IDTVEC(bnd), SDT_SYSIGT, SEL_KPL, 0); setidt(IDT_UD, pti ? &IDTVEC(ill_pti) : &IDTVEC(ill), SDT_SYSIGT, From owner-svn-src-head@freebsd.org Thu Apr 5 11:03:22 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F34FFF9E7A5; Thu, 5 Apr 2018 11:03:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 90B1375C2E; Thu, 5 Apr 2018 11:03:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8B2C121C54; Thu, 5 Apr 2018 11:03:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w35B3LiQ093756; Thu, 5 Apr 2018 11:03:21 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35B3LTU093755; Thu, 5 Apr 2018 11:03:21 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201804051103.w35B3LTU093755@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 5 Apr 2018 11:03:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332061 - head/sys/amd64/ia32 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/amd64/ia32 X-SVN-Commit-Revision: 332061 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 11:03:22 -0000 Author: kib Date: Thu Apr 5 11:03:21 2018 New Revision: 332061 URL: https://svnweb.freebsd.org/changeset/base/332061 Log: Fix ERESTART for lcall $7,$0 syscalls. The lcall trampoline enters kernel by int $0x80, which sets up invalid length of the instruction for %rip rewind. Reviewed by: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/amd64/ia32/ia32_syscall.c Modified: head/sys/amd64/ia32/ia32_syscall.c ============================================================================== --- head/sys/amd64/ia32/ia32_syscall.c Thu Apr 5 11:03:05 2018 (r332060) +++ head/sys/amd64/ia32/ia32_syscall.c Thu Apr 5 11:03:21 2018 (r332061) @@ -146,6 +146,7 @@ ia32_fetch_syscall_args(struct thread *td) frame->tf_rip = eip; frame->tf_cs = cs; frame->tf_rsp += 2 * sizeof(u_int32_t); + frame->tf_err = 7; /* size of lcall $7,$0 */ } #endif From owner-svn-src-head@freebsd.org Thu Apr 5 12:21:03 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9032AF810D3; Thu, 5 Apr 2018 12:21:03 +0000 (UTC) (envelope-from agapon@gmail.com) Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0E5C978720; Thu, 5 Apr 2018 12:21:02 +0000 (UTC) (envelope-from agapon@gmail.com) Received: by mail-wm0-f54.google.com with SMTP id r82so6609265wme.0; Thu, 05 Apr 2018 05:21:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=Wn4KEboqAFjk/AZVAKMlJUEKfxSKXWyWAxPw5z2YUGo=; b=SWr6gut7rc0yMe1kEfkeR7EL6JT1vyRCYEXrr64/Qk7gDJM5WxHFMAOyHxMg9YIDeo sLtk/jfvDmPUJ7cOtl0ydPzgHJklo0M1rwjDr2VvHTRET4SRG+TqFX7tbOiqmDRozFUM P0RafSS8TxGFEgjvbO58koreWmRpsAXl+zKSl8lFmh8P/wV7IU+OoJ7RFjkbjFOgxop6 20tqr5h/XWu0KtAc1dZiKTWKXC0Nc4qBaSWofrQheoo5HnQx46t6nobLsmwl1LWBzXCl Rtn52O31MmaU4OXttAizM2krgWGKiiUuP7dflFaV6tyInVuoN4+dlsnM5eISuFmzZb5r e0cQ== X-Gm-Message-State: ALQs6tANzt95DVjOgPMbNvGhy6a9H5PHy24DS4rjk3rJQv+tuPhGAJaD HbmUExxMdr5eOdFrQfJmWI6ZvtH3CpQ= X-Google-Smtp-Source: AIpwx48J5renmz/75lzrE3cd8ZP4D+kQ+qE+hn0bpxSQ8HyNYt3MOGombe0os56BAIellKCqSlpvLA== X-Received: by 10.46.150.132 with SMTP id q4mr3852886lji.45.1522930855619; Thu, 05 Apr 2018 05:20:55 -0700 (PDT) Received: from [192.168.0.88] (east.meadow.volia.net. [93.72.151.96]) by smtp.googlemail.com with ESMTPSA id 81sm1279084ljz.67.2018.04.05.05.20.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Apr 2018 05:20:54 -0700 (PDT) Subject: Re: svn commit: r331701 - in head: cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/zpool cddl/contrib/opensolaris/cmd/ztest cddl/contrib/opensolaris/lib/libzfs/common cddl/contrib/opensol... To: Alexander Motin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201803282201.w2SM1RTe029674@repo.freebsd.org> From: Andriy Gapon Openpgp: preference=signencrypt Autocrypt: addr=avg@FreeBSD.org; prefer-encrypt=mutual; keydata= xsFNBFm4LIgBEADNB/3lT7f15UKeQ52xCFQx/GqHkSxEdVyLFZTmY3KyNPQGBtyvVyBfprJ7 mAeXZWfhat6cKNRAGZcL5EmewdQuUfQfBdYmKjbw3a9GFDsDNuhDA2QwFt8BmkiVMRYyvI7l N0eVzszWCUgdc3qqM6qqcgBaqsVmJluwpvwp4ZBXmch5BgDDDb1MPO8AZ2QZfIQmplkj8Y6Z AiNMknkmgaekIINSJX8IzRzKD5WwMsin70psE8dpL/iBsA2cpJGzWMObVTtCxeDKlBCNqM1i gTXta1ukdUT7JgLEFZk9ceYQQMJJtUwzWu1UHfZn0Fs29HTqawfWPSZVbulbrnu5q55R4PlQ /xURkWQUTyDpqUvb4JK371zhepXiXDwrrpnyyZABm3SFLkk2bHlheeKU6Yql4pcmSVym1AS4 dV8y0oHAfdlSCF6tpOPf2+K9nW1CFA8b/tw4oJBTtfZ1kxXOMdyZU5fiG7xb1qDgpQKgHUX8 7Rd2T1UVLVeuhYlXNw2F+a2ucY+cMoqz3LtpksUiBppJhw099gEXehcN2JbUZ2TueJdt1FdS ztnZmsHUXLxrRBtGwqnFL7GSd6snpGIKuuL305iaOGODbb9c7ne1JqBbkw1wh8ci6vvwGlzx rexzimRaBzJxlkjNfMx8WpCvYebGMydNoeEtkWldtjTNVsUAtQARAQABzR5BbmRyaXkgR2Fw b24gPGF2Z0BGcmVlQlNELm9yZz7CwZQEEwEIAD4WIQS+LEO7ngQnXA4Bjr538m7TUc1yjwUC WbgsiAIbIwUJBaOagAULCQgHAgYVCAkKCwIEFgIDAQIeAQIXgAAKCRB38m7TUc1yj+JAEACV l9AK/nOWAt/9cufV2fRj0hdOqB1aCshtSrwHk/exXsDa4/FkmegxXQGY+3GWX3deIyesbVRL rYdtdK0dqJyT1SBqXK1h3/at9rxr9GQA6KWOxTjUFURsU7ok/6SIlm8uLRPNKO+yq0GDjgaO LzN+xykuBA0FlhQAXJnpZLcVfPJdWv7sSHGedL5ln8P8rxR+XnmsA5TUaaPcbhTB+mG+iKFj GghASDSfGqLWFPBlX/fpXikBDZ1gvOr8nyMY9nXhgfXpq3B6QCRYKPy58ChrZ5weeJZ29b7/ QdEO8NFNWHjSD9meiLdWQaqo9Y7uUxN3wySc/YUZxtS0bhAd8zJdNPsJYG8sXgKjeBQMVGuT eCAJFEYJqbwWvIXMfVWop4+O4xB+z2YE3jAbG/9tB/GSnQdVSj3G8MS80iLS58frnt+RSEw/ psahrfh0dh6SFHttE049xYiC+cM8J27Aaf0i9RflyITq57NuJm+AHJoU9SQUkIF0nc6lfA+o JRiyRlHZHKoRQkIg4aiKaZSWjQYRl5Txl0IZUP1dSWMX4s3XTMurC/pnja45dge/4ESOtJ9R 8XuIWg45Oq6MeIWdjKddGhRj3OohsltKgkEU3eLKYtB6qRTQypHHUawCXz88uYt5e3w4V16H lCpSTZV/EVHnNe45FVBlvK7k7HFfDDkryM7BTQRZuCyIARAAlq0slcsVboY/+IUJdcbEiJRW be9HKVz4SUchq0z9MZPX/0dcnvz/gkyYA+OuM78dNS7Mbby5dTvOqfpLJfCuhaNYOhlE0wY+ 1T6Tf1f4c/uA3U/YiadukQ3+6TJuYGAdRZD5EqYFIkreARTVWg87N9g0fT9BEqLw9lJtEGDY EWUE7L++B8o4uu3LQFEYxcrb4K/WKmgtmFcm77s0IKDrfcX4doV92QTIpLiRxcOmCC/OCYuO jB1oaaqXQzZrCutXRK0L5XN1Y1PYjIrEzHMIXmCDlLYnpFkK+itlXwlE2ZQxkfMruCWdQXye syl2fynAe8hvp7Mms9qU2r2K9EcJiR5N1t1C2/kTKNUhcRv7Yd/vwusK7BqJbhlng5ZgRx0m WxdntU/JLEntz3QBsBsWM9Y9wf2V4tLv6/DuDBta781RsCB/UrU2zNuOEkSixlUiHxw1dccI 6CVlaWkkJBxmHX22GdDFrcjvwMNIbbyfQLuBq6IOh8nvu9vuItup7qemDG3Ms6TVwA7BD3j+ 3fGprtyW8Fd/RR2bW2+LWkMrqHffAr6Y6V3h5kd2G9Q8ZWpEJk+LG6Mk3fhZhmCnHhDu6CwN MeUvxXDVO+fqc3JjFm5OxhmfVeJKrbCEUJyM8ESWLoNHLqjywdZga4Q7P12g8DUQ1mRxYg/L HgZY3zfKOqcAEQEAAcLBfAQYAQgAJhYhBL4sQ7ueBCdcDgGOvnfybtNRzXKPBQJZuCyIAhsM BQkFo5qAAAoJEHfybtNRzXKPBVwQAKfFy9P7N3OsLDMB56A4Kf+ZT+d5cIx0Yiaf4n6w7m3i ImHHHk9FIetI4Xe54a2IXh4Bq5UkAGY0667eIs+Z1Ea6I2i27Sdo7DxGwq09Qnm/Y65ADvXs 3aBvokCcm7FsM1wky395m8xUos1681oV5oxgqeRI8/76qy0hD9WR65UW+HQgZRIcIjSel9vR XDaD2HLGPTTGr7u4v00UeTMs6qvPsa2PJagogrKY8RXdFtXvweQFz78NbXhluwix2Tb9ETPk LIpDrtzV73CaE2aqBG/KrboXT2C67BgFtnk7T7Y7iKq4/XvEdDWscz2wws91BOXuMMd4c/c4 OmGW9m3RBLufFrOag1q5yUS9QbFfyqL6dftJP3Zq/xe+mr7sbWbhPVCQFrH3r26mpmy841ym dwQnNcsbIGiBASBSKksOvIDYKa2Wy8htPmWFTEOPRpFXdGQ27awcjjnB42nngyCK5ukZDHi6 w0qK5DNQQCkiweevCIC6wc3p67jl1EMFY5+z+zdTPb3h7LeVnGqW0qBQl99vVFgzLxchKcl0 R/paSFgwqXCZhAKMuUHncJuynDOP7z5LirUeFI8qsBAJi1rXpQoLJTVcW72swZ42IdPiboqx NbTMiNOiE36GqMcTPfKylCbF45JNX4nF9ElM0E+Y8gi4cizJYBRr2FBJgay0b9Cp Message-ID: Date: Thu, 5 Apr 2018 15:20:53 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <201803282201.w2SM1RTe029674@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 12:21:03 -0000 On 29/03/2018 01:01, Alexander Motin wrote: > MFV r331695, 331700: 9166 zfs storage pool checkpoint > > illumos/illumos-gate@8671400134a11c848244896ca51a7db4d0f69da4 > > The idea of Storage Pool Checkpoint (aka zpool checkpoint) deals with > exactly that. It can be thought of as a “pool-wide snapshot†(or a > variation of extreme rewind that doesn’t corrupt your data). It remembers > the entire state of the pool at the point that it was taken and the user > can revert back to it later or discard it. Its generic use case is an > administrator that is about to perform a set of destructive actions to ZFS > as part of a critical procedure. She takes a checkpoint of the pool before > performing the actions, then rewinds back to it if one of them fails or puts > the pool into an unexpected state. Otherwise, she discards it. With the > assumption that no one else is making modifications to ZFS, she basically > wraps all these actions into a “high-level transactionâ€. A small nit: > /* check options */ > - while ((c = getopt(argc, argv, ":aCc:d:DEfFmnNo:R:T:VX")) != -1) { > + while ((c = getopt_long(argc, argv, ":aCc:d:DEfFmnNo:rR:T:VX", > + long_options, NULL)) != -1) { > switch (c) { It seems that on illumos zpool import has an undocumented option with no effect, -r. I think that we removed that option from FreeBSD. This commit restored it. I am actually indifferent about having it. Just pointing out this possibly unintended change. -- Andriy Gapon From owner-svn-src-head@freebsd.org Thu Apr 5 13:56:41 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 33D47F87400; Thu, 5 Apr 2018 13:56:41 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D46787CF72; Thu, 5 Apr 2018 13:56:40 +0000 (UTC) (envelope-from sbruno@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 CD8CE237EF; Thu, 5 Apr 2018 13:56:40 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w35DueDw022534; Thu, 5 Apr 2018 13:56:40 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35Duexg022529; Thu, 5 Apr 2018 13:56:40 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201804051356.w35Duexg022529@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Thu, 5 Apr 2018 13:56:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332070 - in head/sys/geom: . label raid X-SVN-Group: head X-SVN-Commit-Author: sbruno X-SVN-Commit-Paths: in head/sys/geom: . label raid X-SVN-Commit-Revision: 332070 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 13:56:41 -0000 Author: sbruno Date: Thu Apr 5 13:56:40 2018 New Revision: 332070 URL: https://svnweb.freebsd.org/changeset/base/332070 Log: Squash error from geom by sizing ident strings to DISK_IDENT_SIZE. Display attribute in future error strings and differentiate g_handleattr() error messages for ease of debugging in the future. "g_handleattr: md1 bio_length 24 strlen 31 -> EFAULT" Reported by: swills Reviewed by: imp cem avg Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D14962 Modified: head/sys/geom/geom_subr.c head/sys/geom/label/g_label_disk_ident.c head/sys/geom/raid/md_ddf.c head/sys/geom/raid/md_intel.c Modified: head/sys/geom/geom_subr.c ============================================================================== --- head/sys/geom/geom_subr.c Thu Apr 5 13:39:53 2018 (r332069) +++ head/sys/geom/geom_subr.c Thu Apr 5 13:56:40 2018 (r332070) @@ -1050,16 +1050,16 @@ g_handleattr(struct bio *bp, const char *attribute, co bzero(bp->bio_data, bp->bio_length); if (strlcpy(bp->bio_data, val, bp->bio_length) >= bp->bio_length) { - printf("%s: %s bio_length %jd len %zu -> EFAULT\n", - __func__, bp->bio_to->name, + printf("%s: %s %s bio_length %jd strlen %zu -> EFAULT\n", + __func__, bp->bio_to->name, attribute, (intmax_t)bp->bio_length, strlen(val)); error = EFAULT; } } else if (bp->bio_length == len) { bcopy(val, bp->bio_data, len); } else { - printf("%s: %s bio_length %jd len %d -> EFAULT\n", __func__, - bp->bio_to->name, (intmax_t)bp->bio_length, len); + printf("%s: %s %s bio_length %jd len %d -> EFAULT\n", __func__, + bp->bio_to->name, attribute, (intmax_t)bp->bio_length, len); error = EFAULT; } if (error == 0) Modified: head/sys/geom/label/g_label_disk_ident.c ============================================================================== --- head/sys/geom/label/g_label_disk_ident.c Thu Apr 5 13:39:53 2018 (r332069) +++ head/sys/geom/label/g_label_disk_ident.c Thu Apr 5 13:56:40 2018 (r332070) @@ -49,7 +49,7 @@ static void g_label_disk_ident_taste(struct g_consumer *cp, char *label, size_t size) { struct g_class *cls; - char ident[100]; + char ident[DISK_IDENT_SIZE]; int ident_len, found, i; g_topology_assert_not(); Modified: head/sys/geom/raid/md_ddf.c ============================================================================== --- head/sys/geom/raid/md_ddf.c Thu Apr 5 13:39:53 2018 (r332069) +++ head/sys/geom/raid/md_ddf.c Thu Apr 5 13:56:40 2018 (r332070) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "geom/raid/g_raid.h" #include "geom/raid/md_ddf.h" @@ -572,7 +573,7 @@ ddf_meta_create(struct g_raid_disk *disk, struct ddf_m off_t anchorlba; u_int ss, pos, size; int len, error; - char serial_buffer[24]; + char serial_buffer[DISK_IDENT_SIZE]; if (sample->hdr == NULL) sample = NULL; Modified: head/sys/geom/raid/md_intel.c ============================================================================== --- head/sys/geom/raid/md_intel.c Thu Apr 5 13:39:53 2018 (r332069) +++ head/sys/geom/raid/md_intel.c Thu Apr 5 13:56:40 2018 (r332070) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "geom/raid/g_raid.h" #include "g_raid_md_if.h" @@ -1450,7 +1451,7 @@ g_raid_md_create_intel(struct g_raid_md_object *md, st static int g_raid_md_get_label(struct g_consumer *cp, char *serial, int serlen) { - char serial_buffer[24]; + char serial_buffer[DISK_IDENT_SIZE]; int len, error; len = sizeof(serial_buffer); From owner-svn-src-head@freebsd.org Thu Apr 5 14:31:55 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9A167F89E02; Thu, 5 Apr 2018 14:31:55 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4826D7F063; Thu, 5 Apr 2018 14:31:55 +0000 (UTC) (envelope-from royger@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 4309E23E67; Thu, 5 Apr 2018 14:31:55 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w35EVt3e047912; Thu, 5 Apr 2018 14:31:55 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35EVtg4047897; Thu, 5 Apr 2018 14:31:55 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201804051431.w35EVtg4047897@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Thu, 5 Apr 2018 14:31:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332072 - head/sys/sys X-SVN-Group: head X-SVN-Commit-Author: royger X-SVN-Commit-Paths: head/sys/sys X-SVN-Commit-Revision: 332072 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 14:31:55 -0000 Author: royger Date: Thu Apr 5 14:31:54 2018 New Revision: 332072 URL: https://svnweb.freebsd.org/changeset/base/332072 Log: introduce GiB and MiB macros This macros convert from GiB or MiB into bytes. Sponsored by: Citrix Systems R&D Modified: head/sys/sys/param.h Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Thu Apr 5 14:25:39 2018 (r332071) +++ head/sys/sys/param.h Thu Apr 5 14:31:54 2018 (r332072) @@ -362,4 +362,8 @@ __END_DECLS */ #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset]) +/* Unit conversion macros. */ +#define GiB(v) (v ## ULL << 30) +#define MiB(v) (v ## ULL << 20) + #endif /* _SYS_PARAM_H_ */ From owner-svn-src-head@freebsd.org Thu Apr 5 14:39:53 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EDC8BF8A6A0; Thu, 5 Apr 2018 14:39:52 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A2D3B7F50A; Thu, 5 Apr 2018 14:39:52 +0000 (UTC) (envelope-from royger@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 9DB2223E9C; Thu, 5 Apr 2018 14:39:52 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w35EdqJN049568; Thu, 5 Apr 2018 14:39:52 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35EdpMM049557; Thu, 5 Apr 2018 14:39:51 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201804051439.w35EdpMM049557@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Thu, 5 Apr 2018 14:39:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332073 - in head/sys: amd64/amd64 amd64/include i386/i386 i386/include x86/include x86/x86 X-SVN-Group: head X-SVN-Commit-Author: royger X-SVN-Commit-Paths: in head/sys: amd64/amd64 amd64/include i386/i386 i386/include x86/include x86/x86 X-SVN-Commit-Revision: 332073 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 14:39:53 -0000 Author: royger Date: Thu Apr 5 14:39:51 2018 New Revision: 332073 URL: https://svnweb.freebsd.org/changeset/base/332073 Log: x86: improve reservation of AP trampoline memory So that it doesn't rely on physmap[1] containing an address below 1MiB. Instead scan the full physmap and search for a suitable address to place the trampoline code (below 1MiB) and the initial memory pages (below 4GiB). Sponsored by: Citrix Systems R&D Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D14878 Modified: head/sys/amd64/amd64/machdep.c head/sys/amd64/amd64/mp_machdep.c head/sys/amd64/amd64/mpboot.S head/sys/amd64/include/smp.h head/sys/i386/i386/machdep.c head/sys/i386/i386/mp_machdep.c head/sys/i386/include/smp.h head/sys/x86/include/init.h head/sys/x86/include/x86_smp.h head/sys/x86/x86/mp_x86.c Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Thu Apr 5 14:31:54 2018 (r332072) +++ head/sys/amd64/amd64/machdep.c Thu Apr 5 14:39:51 2018 (r332073) @@ -1246,14 +1246,10 @@ getmemsize(caddr_t kmdp, u_int64_t first) * Make hole for "AP -> long mode" bootstrap code. The * mp_bootaddress vector is only available when the kernel * is configured to support APs and APs for the system start - * in 32bit mode (e.g. SMP bare metal). + * in real mode mode (e.g. SMP bare metal). */ - if (init_ops.mp_bootaddress) { - if (physmap[1] >= 0x100000000) - panic( - "Basemem segment is not suitable for AP bootstrap code!"); - physmap[1] = init_ops.mp_bootaddress(physmap[1] / 1024); - } + if (init_ops.mp_bootaddress) + init_ops.mp_bootaddress(physmap, &physmap_idx); /* * Maxmem isn't the "maximum memory", it's one larger than the Modified: head/sys/amd64/amd64/mp_machdep.c ============================================================================== --- head/sys/amd64/amd64/mp_machdep.c Thu Apr 5 14:31:54 2018 (r332072) +++ head/sys/amd64/amd64/mp_machdep.c Thu Apr 5 14:39:51 2018 (r332073) @@ -96,24 +96,45 @@ char *nmi_stack; static int start_ap(int apic_id); -static u_int bootMP_size; -static u_int boot_address; - /* * Calculate usable address in base memory for AP trampoline code. */ -u_int -mp_bootaddress(u_int basemem) +void +mp_bootaddress(vm_paddr_t *physmap, unsigned int *physmap_idx) { + unsigned int i; + bool allocated; - bootMP_size = mptramp_end - mptramp_start; - boot_address = trunc_page(basemem * 1024); /* round down to 4k boundary */ - if (((basemem * 1024) - boot_address) < bootMP_size) - boot_address -= PAGE_SIZE; /* not enough, lower by 4k */ - /* 3 levels of page table pages */ - mptramp_pagetables = boot_address - (PAGE_SIZE * 3); + alloc_ap_trampoline(physmap, physmap_idx); - return mptramp_pagetables; + allocated = false; + for (i = *physmap_idx; i <= *physmap_idx; i -= 2) { + /* + * Find a memory region big enough below the 4GB boundary to + * store the initial page tables. Note that it needs to be + * aligned to a page boundary. + */ + if (physmap[i] >= GiB(4) || + (physmap[i + 1] - round_page(physmap[i])) < (PAGE_SIZE * 3)) + continue; + + allocated = true; + mptramp_pagetables = round_page(physmap[i]); + physmap[i] = round_page(physmap[i]) + (PAGE_SIZE * 3); + if (physmap[i] == physmap[i + 1] && *physmap_idx != 0) { + memmove(&physmap[i], &physmap[i + 2], + sizeof(*physmap) * (*physmap_idx - i + 2)); + *physmap_idx -= 2; + } + } + + if (!allocated) { + mptramp_pagetables = trunc_page(boot_address) - (PAGE_SIZE * 3); + if (bootverbose) + printf( +"Cannot find enough space for the initial AP page tables, placing them at %#x", + mptramp_pagetables); + } } /* Modified: head/sys/amd64/amd64/mpboot.S ============================================================================== --- head/sys/amd64/amd64/mpboot.S Thu Apr 5 14:31:54 2018 (r332072) +++ head/sys/amd64/amd64/mpboot.S Thu Apr 5 14:39:51 2018 (r332073) @@ -216,8 +216,14 @@ lgdt_desc: .word gdtend-gdt /* Length */ .long gdt-mptramp_start /* Offset plus %ds << 4 */ - .globl mptramp_end mptramp_end: + /* + * The size of the trampoline code that needs to be relocated + * below the 1MiB boundary. + */ + .globl bootMP_size +bootMP_size: + .long mptramp_end - mptramp_start /* * From here on down is executed in the kernel .text section. Modified: head/sys/amd64/include/smp.h ============================================================================== --- head/sys/amd64/include/smp.h Thu Apr 5 14:31:54 2018 (r332072) +++ head/sys/amd64/include/smp.h Thu Apr 5 14:39:51 2018 (r332073) @@ -23,7 +23,6 @@ /* global symbols in mpboot.S */ extern char mptramp_start[]; -extern char mptramp_end[]; extern u_int32_t mptramp_pagetables; /* IPI handlers */ @@ -59,6 +58,7 @@ void invlpg_pcid_handler(void); void invlrng_invpcid_handler(void); void invlrng_pcid_handler(void); int native_start_all_aps(void); +void mp_bootaddress(vm_paddr_t *, unsigned int *); #endif /* !LOCORE */ #endif /* SMP */ Modified: head/sys/i386/i386/machdep.c ============================================================================== --- head/sys/i386/i386/machdep.c Thu Apr 5 14:31:54 2018 (r332072) +++ head/sys/i386/i386/machdep.c Thu Apr 5 14:39:51 2018 (r332073) @@ -1903,7 +1903,7 @@ physmap_done: #ifdef SMP /* make hole for AP bootstrap code */ - physmap[1] = mp_bootaddress(physmap[1]); + alloc_ap_trampoline(physmap, &physmap_idx); #endif /* Modified: head/sys/i386/i386/mp_machdep.c ============================================================================== --- head/sys/i386/i386/mp_machdep.c Thu Apr 5 14:31:54 2018 (r332072) +++ head/sys/i386/i386/mp_machdep.c Thu Apr 5 14:39:51 2018 (r332073) @@ -139,22 +139,6 @@ static void install_ap_tramp(void); static int start_all_aps(void); static int start_ap(int apic_id); -static u_int boot_address; - -/* - * Calculate usable address in base memory for AP trampoline code. - */ -u_int -mp_bootaddress(u_int basemem) -{ - - boot_address = trunc_page(basemem); /* round down to 4k boundary */ - if ((basemem - boot_address) < bootMP_size) - boot_address -= PAGE_SIZE; /* not enough, lower by 4k */ - - return boot_address; -} - /* * Initialize the IPI handlers and start up the AP's. */ Modified: head/sys/i386/include/smp.h ============================================================================== --- head/sys/i386/include/smp.h Thu Apr 5 14:31:54 2018 (r332072) +++ head/sys/i386/include/smp.h Thu Apr 5 14:39:51 2018 (r332073) @@ -27,9 +27,6 @@ #include #include -/* global data in mpboot.s */ -extern int bootMP_size; - /* functions in mpboot.s */ void bootMP(void); Modified: head/sys/x86/include/init.h ============================================================================== --- head/sys/x86/include/init.h Thu Apr 5 14:31:54 2018 (r332072) +++ head/sys/x86/include/init.h Thu Apr 5 14:39:51 2018 (r332073) @@ -41,7 +41,7 @@ struct init_ops { void (*early_clock_source_init)(void); void (*early_delay)(int); void (*parse_memmap)(caddr_t, vm_paddr_t *, int *); - u_int (*mp_bootaddress)(u_int); + void (*mp_bootaddress)(vm_paddr_t *, unsigned int *); int (*start_all_aps)(void); void (*msi_init)(void); }; Modified: head/sys/x86/include/x86_smp.h ============================================================================== --- head/sys/x86/include/x86_smp.h Thu Apr 5 14:31:54 2018 (r332072) +++ head/sys/x86/include/x86_smp.h Thu Apr 5 14:39:51 2018 (r332073) @@ -32,6 +32,8 @@ extern int bootAP; extern void *dpcpu; extern char *bootSTK; extern void *bootstacks[]; +extern unsigned int boot_address; +extern unsigned int bootMP_size; extern volatile u_int cpu_ipi_pending[]; extern volatile int aps_ready; extern struct mtx ap_boot_mtx; @@ -83,6 +85,7 @@ void assign_cpu_ids(void); void cpu_add(u_int apic_id, char boot_cpu); void cpustop_handler(void); void cpususpend_handler(void); +void alloc_ap_trampoline(vm_paddr_t *physmap, unsigned int *physmap_idx); void init_secondary_tail(void); void invltlb_handler(void); void invlpg_handler(void); @@ -95,7 +98,6 @@ void ipi_bitmap_handler(struct trapframe frame); void ipi_cpu(int cpu, u_int ipi); int ipi_nmi_handler(void); void ipi_selected(cpuset_t cpus, u_int ipi); -u_int mp_bootaddress(u_int); void set_interrupt_apic_ids(void); void smp_cache_flush(void); void smp_masked_invlpg(cpuset_t mask, vm_offset_t addr, struct pmap *pmap); Modified: head/sys/x86/x86/mp_x86.c ============================================================================== --- head/sys/x86/x86/mp_x86.c Thu Apr 5 14:31:54 2018 (r332072) +++ head/sys/x86/x86/mp_x86.c Thu Apr 5 14:39:51 2018 (r332073) @@ -158,6 +158,8 @@ struct cache_info { int present; } static caches[MAX_CACHE_LEVELS]; +unsigned int boot_address; + void mem_range_AP_init(void) { @@ -903,6 +905,55 @@ cpu_mp_probe(void) */ CPU_SETOF(0, &all_cpus); return (mp_ncpus > 1); +} + +/* Allocate memory for the AP trampoline. */ +void +alloc_ap_trampoline(vm_paddr_t *physmap, unsigned int *physmap_idx) +{ + unsigned int i; + bool allocated; + + allocated = false; + for (i = *physmap_idx; i <= *physmap_idx; i -= 2) { + /* + * Find a memory region big enough and below the 1MB boundary + * for the trampoline code. + * NB: needs to be page aligned. + */ + if (physmap[i] >= MiB(1) || + (trunc_page(physmap[i + 1]) - round_page(physmap[i])) < + round_page(bootMP_size)) + continue; + + allocated = true; + /* + * Try to steal from the end of the region to mimic previous + * behaviour, else fallback to steal from the start. + */ + if (physmap[i + 1] < MiB(1)) { + boot_address = trunc_page(physmap[i + 1]); + if ((physmap[i + 1] - boot_address) < bootMP_size) + boot_address -= round_page(bootMP_size); + physmap[i + 1] = boot_address; + } else { + boot_address = round_page(physmap[i]); + physmap[i] = boot_address + round_page(bootMP_size); + } + if (physmap[i] == physmap[i + 1] && *physmap_idx != 0) { + memmove(&physmap[i], &physmap[i + 2], + sizeof(*physmap) * (*physmap_idx - i + 2)); + *physmap_idx -= 2; + } + } + + if (!allocated) { + boot_address = basemem * 1024 - bootMP_size; + if (bootverbose) + printf( +"Cannot find enough space for the boot trampoline, placing it at %#x", + boot_address); + } } /* From owner-svn-src-head@freebsd.org Thu Apr 5 15:00:09 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7AF70F8BB12; Thu, 5 Apr 2018 15:00:09 +0000 (UTC) (envelope-from rgrimes@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2947580373; Thu, 5 Apr 2018 15:00:09 +0000 (UTC) (envelope-from rgrimes@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 2000A241DF; Thu, 5 Apr 2018 15:00:09 +0000 (UTC) (envelope-from rgrimes@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w35F08J4059483; Thu, 5 Apr 2018 15:00:08 GMT (envelope-from rgrimes@FreeBSD.org) Received: (from rgrimes@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35F08kG059482; Thu, 5 Apr 2018 15:00:08 GMT (envelope-from rgrimes@FreeBSD.org) Message-Id: <201804051500.w35F08kG059482@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rgrimes set sender to rgrimes@FreeBSD.org using -f From: "Rodney W. Grimes" Date: Thu, 5 Apr 2018 15:00:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332075 - head/sbin/reboot X-SVN-Group: head X-SVN-Commit-Author: rgrimes X-SVN-Commit-Paths: head/sbin/reboot X-SVN-Commit-Revision: 332075 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 15:00:09 -0000 Author: rgrimes Date: Thu Apr 5 15:00:08 2018 New Revision: 332075 URL: https://svnweb.freebsd.org/changeset/base/332075 Log: Exit with usage when extra arguments are on command line preventing mistakes such as "halt 0p" for "halt -p". Approved by: bde (mentor), phk (mentor) MFC after: 1 week Modified: head/sbin/reboot/reboot.c Modified: head/sbin/reboot/reboot.c ============================================================================== --- head/sbin/reboot/reboot.c Thu Apr 5 14:55:44 2018 (r332074) +++ head/sbin/reboot/reboot.c Thu Apr 5 15:00:08 2018 (r332075) @@ -116,6 +116,8 @@ main(int argc, char *argv[]) } argc -= optind; argv += optind; + if (argc != 0) + usage(); if ((howto & (RB_DUMP | RB_HALT)) == (RB_DUMP | RB_HALT)) errx(1, "cannot dump (-d) when halting; must reboot instead"); From owner-svn-src-head@freebsd.org Thu Apr 5 15:16:24 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A1996F8CE05; Thu, 5 Apr 2018 15:16:24 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au [211.29.132.53]) by mx1.freebsd.org (Postfix) with ESMTP id 1A6C4810DC; Thu, 5 Apr 2018 15:16:23 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id 62EA2D49D39; Fri, 6 Apr 2018 01:16:22 +1000 (AEST) Date: Fri, 6 Apr 2018 01:16:22 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r332073 - in head/sys: amd64/amd64 amd64/include i386/i386 i386/include x86/include x86/x86 In-Reply-To: <201804051439.w35EdpMM049557@repo.freebsd.org> Message-ID: <20180406005848.S3128@besplex.bde.org> References: <201804051439.w35EdpMM049557@repo.freebsd.org> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=FNpr/6gs c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=nlC_4_pT8q9DhB4Ho9EA:9 a=Eqv2rDMv4T5AlZsafwoA:9 a=45ClL6m2LaAA:10 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 15:16:24 -0000 On Thu, 5 Apr 2018, [UTF-8] Roger Pau Monn=C3=A9 wrote: > Log: > x86: improve reservation of AP trampoline memory This has lots of style bugs. Mainly changing the KNF spelling of 'unsigned' as u_int to the verbose 'unsigned int' in code that used to be careful to use the KNF spelling. Bruce From owner-svn-src-head@freebsd.org Thu Apr 5 15:22:16 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 67665F8D534; Thu, 5 Apr 2018 15:22:16 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D16A18189A; Thu, 5 Apr 2018 15:22:15 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w35FM4aS039936 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 5 Apr 2018 18:22:08 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w35FM4aS039936 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w35FM4Hq039935; Thu, 5 Apr 2018 18:22:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 5 Apr 2018 18:22:04 +0300 From: Konstantin Belousov To: Warner Losh Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331976 - head/sys/modules/cam Message-ID: <20180405152204.GV1774@kib.kiev.ua> References: <201804040237.w342b5EA074884@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201804040237.w342b5EA074884@repo.freebsd.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 15:22:16 -0000 On Wed, Apr 04, 2018 at 02:37:05AM +0000, Warner Losh wrote: > Author: imp > Date: Wed Apr 4 02:37:05 2018 > New Revision: 331976 > URL: https://svnweb.freebsd.org/changeset/base/331976 > > Log: > Add nvme_da back. > > Now that it can co-exist in the kernel with nvd, add it back to the > cam module. > > Sponsored by: Netflix > > Modified: > head/sys/modules/cam/Makefile > > Modified: head/sys/modules/cam/Makefile > ============================================================================== > --- head/sys/modules/cam/Makefile Wed Apr 4 02:35:48 2018 (r331975) > +++ head/sys/modules/cam/Makefile Wed Apr 4 02:37:05 2018 (r331976) > @@ -46,6 +46,7 @@ SRCS+= ata_machdep.c > SRCS+= ata_pmp.c > SRCS+= nvme_all.c > SRCS+= nvme_xpt.c > +SRCS+= nvme_da.c > > EXPORT_SYMS= YES # XXX evaluate This change resulted in the following: Preloaded elf obj module "/boot/kernel/cam.ko" at 0xffffffff812bb898. link_elf_obj: symbol nvme_strvis undefined KLD file cam.ko - could not finalize loading KLD file ahci.ko - cannot find dependency "cam" From owner-svn-src-head@freebsd.org Thu Apr 5 15:23:10 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C3072F8D67D; Thu, 5 Apr 2018 15:23:10 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 2ED6281A5D; Thu, 5 Apr 2018 15:23:09 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 5FA6D10474D1; Fri, 6 Apr 2018 00:58:43 +1000 (AEST) Date: Fri, 6 Apr 2018 00:58:37 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r332072 - head/sys/sys In-Reply-To: <201804051431.w35EVtg4047897@repo.freebsd.org> Message-ID: <20180406005023.Y3128@besplex.bde.org> References: <201804051431.w35EVtg4047897@repo.freebsd.org> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=FNpr/6gs c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=nlC_4_pT8q9DhB4Ho9EA:9 a=br4i30Z5CdPjGGWIS_YA:9 a=45ClL6m2LaAA:10 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 15:23:10 -0000 On Thu, 5 Apr 2018, [UTF-8] Roger Pau Monn=C3=A9 wrote: > Log: > introduce GiB and MiB macros > > This macros convert from GiB or MiB into bytes. This is undocumented namspace pollution with bad names and worse types. The better names GB and MB would be more likely to conflicted with code not written by disk marketers. > Modified: head/sys/sys/param.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/sys/param.h=09Thu Apr 5 14:25:39 2018=09(r332071) > +++ head/sys/sys/param.h=09Thu Apr 5 14:31:54 2018=09(r332072) > @@ -362,4 +362,8 @@ __END_DECLS > */ > #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offs= et]) Old style bug: space instead of tab after #define. > > +/* Unit conversion macros. */ > +#define GiB(v) (v ## ULL << 30) > +#define MiB(v) (v ## ULL << 20) > + New style bugs: - space instead of tab after #define - use of the long long abomination Type error: - the abomination doesn't have the same type of carefully typedefed types like vm_size_t on any supported arch. > #endif=09/* _SYS_PARAM_H_ */ Old style bugs: - tab instead of space before comment on #endif. - backwards comment on #endif. Bruce From owner-svn-src-head@freebsd.org Thu Apr 5 15:33:06 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B3F6FF8E0A8 for ; Thu, 5 Apr 2018 15:33:06 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from pmta2.delivery6.ore.mailhop.org (pmta2.delivery6.ore.mailhop.org [54.200.129.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2C030820F0 for ; Thu, 5 Apr 2018 15:33:05 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: 6f4e4b6f-38e6-11e8-b951-f99fef315fd9 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound2.ore.mailhop.org (Halon) with ESMTPSA id 6f4e4b6f-38e6-11e8-b951-f99fef315fd9; Thu, 05 Apr 2018 15:31:40 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id w35FWvYE087640; Thu, 5 Apr 2018 09:32:57 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <1522942377.49673.245.camel@freebsd.org> Subject: Re: svn commit: r332072 - head/sys/sys From: Ian Lepore To: Roger Pau =?ISO-8859-1?Q?Monn=E9?= , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Thu, 05 Apr 2018 09:32:57 -0600 In-Reply-To: <201804051431.w35EVtg4047897@repo.freebsd.org> References: <201804051431.w35EVtg4047897@repo.freebsd.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 15:33:06 -0000 On Thu, 2018-04-05 at 14:31 +0000, Roger Pau Monné wrote: > Author: royger > Date: Thu Apr  5 14:31:54 2018 > New Revision: 332072 > URL: https://svnweb.freebsd.org/changeset/base/332072 > > Log: >   introduce GiB and MiB macros >    >   This macros convert from GiB or MiB into bytes. >    >   Sponsored by: Citrix Systems R&D > > Modified: >   head/sys/sys/param.h > > Modified: head/sys/sys/param.h > ============================================================================== > --- head/sys/sys/param.h Thu Apr  5 14:25:39 2018 (r332071) > +++ head/sys/sys/param.h Thu Apr  5 14:31:54 2018 (r332072) > @@ -362,4 +362,8 @@ __END_DECLS >   */ >  #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset]) >   > +/* Unit conversion macros. */ > +#define GiB(v) (v ## ULL << 30) > +#define MiB(v) (v ## ULL << 20) > + >  #endif /* _SYS_PARAM_H_ */ > These names don't make it clear whether the conversion is bytes->GiB or GiB->bytes.  The names seem way too generic for a public namespace in a file as heavily included behind your back as param.h is. Also, this completely reasonable usage won't work, likely with confusing compile error messages:   int bytes, gibytes;   ...   bytes = GiB(gibytes); -- Ian From owner-svn-src-head@freebsd.org Thu Apr 5 15:43:31 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 40674F8E972 for ; Thu, 5 Apr 2018 15:43:31 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x234.google.com (mail-it0-x234.google.com [IPv6:2607:f8b0:4001:c0b::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C025382864 for ; Thu, 5 Apr 2018 15:43:30 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x234.google.com with SMTP id x144-v6so2341435itc.0 for ; Thu, 05 Apr 2018 08:43:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=JtTQgxGl/eQurIde6fKwNkIW6kYqXxzOUsw68qZVqzk=; b=Bm5+KSJX5fIFe64ziuIROA4xG803fqMfhzGy+W4g2BF/wMjBvgql5IvN9s3PTcCpQ4 teqe2VfNRa8cEX/bO77XNWhx54FfglbOS4YgrieoEJLo72Zhy9dFKLAumY/h1deaMOsP rceixD1YaaSrXqBeNJj0FA5NgwpIFRH5FaKLKDGwKl1NMrSeXl3I9PqqtwD1LQubIX0Q C/gZc3GHmQZaH5foiKBkVTpzysBbAYPi/hUjdvwuE0txxALJmm1r6paOIKFLYhLp2JEL MsJMK51arUyDnCHL027QTD7qpKRBzHQl6J0I3YB7bqsm49VtAq0hMiJ6O1SPFUwhSGJD w6Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=JtTQgxGl/eQurIde6fKwNkIW6kYqXxzOUsw68qZVqzk=; b=hm2Hm6zISKaDCEQvS+cyCDsg1yOWm2i1OlaoZuaxjUvnBOoeAuVXoE6VmqcDlf29TI lhADN6cYMfbRCL0JGgTAtW49L2Q+0FIDSGdWnZamaPIRXG6epNL1Lrypfl9LU126XTV/ /fYdEhEOW9kTEpwoOicdsoIBHEzEWBqd9cCqhuECx4+dhViydaeI0A2QZj+wRydIwTAI SFopc4DARLfLpGWUqzz3y8Uy3jzx5L5HOrnmn/LN9KqootkJ6eGKJ2NgLgvrcxMI03mv rkyYrTbQaUHkaE3pg+vh8gB4CuGStu4T5XZSe3l6ma8IFuIJbDm3GGLlmQ/k4OPMcscw Vw4w== X-Gm-Message-State: ALQs6tAKSz2PivpC9NX/8RMgEbAbNCGjeOyPbzfrErnp8NBHZMwBb4l+ XJEcDAR4C+DocECPrkShV03KNy400LBrrFdzsI+UgA== X-Google-Smtp-Source: AIpwx497GNgdsNuJKj8qjZqMBZ/tCXjUbUo/Q6VaGXZyFXStOd+ExXBecOYHO7pjbl5m9J2GrkcZm9Dj2z3jYtoq3GY= X-Received: by 2002:a24:fa83:: with SMTP id v125-v6mr14339685ith.36.1522943010003; Thu, 05 Apr 2018 08:43:30 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.203.196 with HTTP; Thu, 5 Apr 2018 08:43:29 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: <20180405152204.GV1774@kib.kiev.ua> References: <201804040237.w342b5EA074884@repo.freebsd.org> <20180405152204.GV1774@kib.kiev.ua> From: Warner Losh Date: Thu, 5 Apr 2018 09:43:29 -0600 X-Google-Sender-Auth: ID164NBgfszhmEXs6zh8GE0cntA Message-ID: Subject: Re: svn commit: r331976 - head/sys/modules/cam To: Konstantin Belousov Cc: Warner Losh , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 15:43:31 -0000 Thanks.... I'll attend to that. Warner On Thu, Apr 5, 2018 at 9:22 AM, Konstantin Belousov wrote: > On Wed, Apr 04, 2018 at 02:37:05AM +0000, Warner Losh wrote: > > Author: imp > > Date: Wed Apr 4 02:37:05 2018 > > New Revision: 331976 > > URL: https://svnweb.freebsd.org/changeset/base/331976 > > > > Log: > > Add nvme_da back. > > > > Now that it can co-exist in the kernel with nvd, add it back to the > > cam module. > > > > Sponsored by: Netflix > > > > Modified: > > head/sys/modules/cam/Makefile > > > > Modified: head/sys/modules/cam/Makefile > > ============================================================ > ================== > > --- head/sys/modules/cam/Makefile Wed Apr 4 02:35:48 2018 > (r331975) > > +++ head/sys/modules/cam/Makefile Wed Apr 4 02:37:05 2018 > (r331976) > > @@ -46,6 +46,7 @@ SRCS+= ata_machdep.c > > SRCS+= ata_pmp.c > > SRCS+= nvme_all.c > > SRCS+= nvme_xpt.c > > +SRCS+= nvme_da.c > > > > EXPORT_SYMS= YES # XXX evaluate > > This change resulted in the following: > > Preloaded elf obj module "/boot/kernel/cam.ko" at 0xffffffff812bb898. > link_elf_obj: symbol nvme_strvis undefined > KLD file cam.ko - could not finalize loading > KLD file ahci.ko - cannot find dependency "cam" > From owner-svn-src-head@freebsd.org Thu Apr 5 15:45:55 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8E777F8EBD3; Thu, 5 Apr 2018 15:45:55 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 40F0882A74; Thu, 5 Apr 2018 15:45:55 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 37B8C249F4; Thu, 5 Apr 2018 15:45:55 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w35Fjtf7084285; Thu, 5 Apr 2018 15:45:55 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35FjsUU084278; Thu, 5 Apr 2018 15:45:54 GMT (envelope-from br@FreeBSD.org) Message-Id: <201804051545.w35FjsUU084278@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Thu, 5 Apr 2018 15:45:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332077 - in head/sys: arm64/coresight conf X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: in head/sys: arm64/coresight conf X-SVN-Commit-Revision: 332077 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 15:45:55 -0000 Author: br Date: Thu Apr 5 15:45:54 2018 New Revision: 332077 URL: https://svnweb.freebsd.org/changeset/base/332077 Log: Add support for the Coresight technology from ARM Ltd. ARM Coresight is a solution for debug and trace of complex SoC designs. This includes a collection of drivers for ARM Coresight interconnect devices within a small Coresight framework. Supported devices are: o Embedded Trace Macrocell v4 (ETMv4) o Funnel o Dynamic Replicator o Trace Memory Controller (TMC) o CPU debug module Devices are connected to each other internally in SoC and the configuration of each device endpoints is described in FDT. Typical trace flow (as found on Qualcomm Snapdragon 410e): CPU0 -> ETM0 -> funnel1 -> funnel0 -> ETF -> replicator -> ETR -> DRAM CPU1 -> ETM1 -^ CPU2 -> ETM2 -^ CPU3 -> ETM3 -^ Note that both Embedded Trace FIFO (ETF) and Embedded Trace Router (ETR) are hardware configurations of TMC. This is required for upcoming HWPMC tracing support. This is tested on single-core system only. Reviewed by: andrew (partially) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14618 Added: head/sys/arm64/coresight/ head/sys/arm64/coresight/coresight-cmd.c (contents, props changed) head/sys/arm64/coresight/coresight-cpu-debug.c (contents, props changed) head/sys/arm64/coresight/coresight-dynamic-replicator.c (contents, props changed) head/sys/arm64/coresight/coresight-etm4x.c (contents, props changed) head/sys/arm64/coresight/coresight-etm4x.h (contents, props changed) head/sys/arm64/coresight/coresight-funnel.c (contents, props changed) head/sys/arm64/coresight/coresight-funnel.h (contents, props changed) head/sys/arm64/coresight/coresight-tmc.c (contents, props changed) head/sys/arm64/coresight/coresight-tmc.h (contents, props changed) head/sys/arm64/coresight/coresight.c (contents, props changed) head/sys/arm64/coresight/coresight.h (contents, props changed) head/sys/arm64/coresight/coresight_if.m (contents, props changed) Modified: head/sys/conf/files.arm64 Added: head/sys/arm64/coresight/coresight-cmd.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/coresight/coresight-cmd.c Thu Apr 5 15:45:54 2018 (r332077) @@ -0,0 +1,156 @@ +/*- + * Copyright (c) 2018 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "coresight_if.h" + +extern struct coresight_device_list cs_devs; + +static struct coresight_device * +coresight_next_device(struct coresight_device *cs_dev, + struct coresight_event *event) +{ + struct coresight_device *out; + struct endpoint *out_endp; + struct endpoint *endp; + + TAILQ_FOREACH(endp, &cs_dev->pdata->endpoints, link) { + if (endp->slave != 0) + continue; + + out = coresight_get_output_device(endp, &out_endp); + if (out != NULL) { + if (LIST_EMPTY(&event->endplist)) { + /* Add source device */ + endp->cs_dev = cs_dev; + LIST_INSERT_HEAD(&event->endplist, endp, + endplink); + } + + /* Add output device */ + out_endp->cs_dev = out; + LIST_INSERT_HEAD(&event->endplist, out_endp, endplink); + + return (out); + } + } + + return (NULL); +} + +static int +coresight_build_list(struct coresight_device *cs_dev, + struct coresight_event *event) +{ + struct coresight_device *out; + + out = cs_dev; + while (out != NULL) + out = coresight_next_device(out, event); + + return (0); +} + +int +coresight_init_event(int cpu, struct coresight_event *event) +{ + struct coresight_device *cs_dev; + struct endpoint *endp; + + /* Start building path from source device */ + TAILQ_FOREACH(cs_dev, &cs_devs, link) { + if (cs_dev->dev_type == event->src && + cs_dev->pdata->cpu == cpu) { + LIST_INIT(&event->endplist); + coresight_build_list(cs_dev, event); + break; + } + } + + /* Ensure Coresight is initialized for the CPU */ + TAILQ_FOREACH(cs_dev, &cs_devs, link) { + if (cs_dev->dev_type == CORESIGHT_CPU_DEBUG && + cs_dev->pdata->cpu == cpu) + CORESIGHT_INIT(cs_dev->dev); + } + + /* Init all devices in the path */ + LIST_FOREACH(endp, &event->endplist, endplink) { + cs_dev = endp->cs_dev; + CORESIGHT_INIT(cs_dev->dev); + } + + return (0); +} + +void +coresight_enable(int cpu, struct coresight_event *event) +{ + struct coresight_device *cs_dev; + struct endpoint *endp; + + LIST_FOREACH(endp, &event->endplist, endplink) { + cs_dev = endp->cs_dev; + CORESIGHT_ENABLE(cs_dev->dev, endp, event); + } +} + +void +coresight_disable(int cpu, struct coresight_event *event) +{ + struct coresight_device *cs_dev; + struct endpoint *endp; + + LIST_FOREACH(endp, &event->endplist, endplink) { + cs_dev = endp->cs_dev; + CORESIGHT_DISABLE(cs_dev->dev, endp, event); + } +} + +void +coresight_read(int cpu, struct coresight_event *event) +{ + struct endpoint *endp; + + LIST_FOREACH(endp, &event->endplist, endplink) + CORESIGHT_READ(endp->cs_dev->dev, endp, event); +} Added: head/sys/arm64/coresight/coresight-cpu-debug.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/coresight/coresight-cpu-debug.c Thu Apr 5 15:45:54 2018 (r332077) @@ -0,0 +1,164 @@ +/*- + * Copyright (c) 2018 Ruslan Bukin + * All rights reserved. + * + * This software was developed by BAE Systems, the University of Cambridge + * Computer Laboratory, and Memorial University under DARPA/AFRL contract + * FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent Computing + * (TC) research program. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include "coresight_if.h" + +#define EDPCSR 0x0a0 +#define EDCIDSR 0x0a4 +#define EDVIDSR 0x0a8 +#define EDPCSR_HI 0x0ac +#define EDOSLAR 0x300 +#define EDPRCR 0x310 +#define EDPRCR_COREPURQ (1 << 3) +#define EDPRCR_CORENPDRQ (1 << 0) +#define EDPRSR 0x314 +#define EDDEVID1 0xfc4 +#define EDDEVID 0xfc8 + +static struct ofw_compat_data compat_data[] = { + { "arm,coresight-cpu-debug", 1 }, + { NULL, 0 } +}; + +struct debug_softc { + struct resource *res; + struct coresight_platform_data *pdata; +}; + +static struct resource_spec debug_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { -1, 0 } +}; + +static int +debug_init(device_t dev) +{ + struct debug_softc *sc; + uint32_t reg; + + sc = device_get_softc(dev); + + /* Unlock Coresight */ + bus_write_4(sc->res, CORESIGHT_LAR, CORESIGHT_UNLOCK); + + /* Unlock Debug */ + bus_write_4(sc->res, EDOSLAR, 0); + + /* Already initialized? */ + reg = bus_read_4(sc->res, EDPRCR); + if (reg & EDPRCR_CORENPDRQ) + return (0); + + /* Enable power */ + reg |= EDPRCR_COREPURQ; + bus_write_4(sc->res, EDPRCR, reg); + + do { + reg = bus_read_4(sc->res, EDPRSR); + } while ((reg & EDPRCR_CORENPDRQ) == 0); + + return (0); +} + +static int +debug_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + + device_set_desc(dev, "Coresight CPU Debug"); + + return (BUS_PROBE_DEFAULT); +} + +static int +debug_attach(device_t dev) +{ + struct coresight_desc desc; + struct debug_softc *sc; + + sc = device_get_softc(dev); + + if (bus_alloc_resources(dev, debug_spec, &sc->res) != 0) { + device_printf(dev, "cannot allocate resources for device\n"); + return (ENXIO); + } + + sc->pdata = coresight_get_platform_data(dev); + desc.pdata = sc->pdata; + desc.dev = dev; + desc.dev_type = CORESIGHT_CPU_DEBUG; + coresight_register(&desc); + + return (0); +} + +static device_method_t debug_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, debug_probe), + DEVMETHOD(device_attach, debug_attach), + + /* Coresight interface */ + DEVMETHOD(coresight_init, debug_init), + DEVMETHOD_END +}; + +static driver_t debug_driver = { + "debug", + debug_methods, + sizeof(struct debug_softc), +}; + +static devclass_t debug_devclass; + +EARLY_DRIVER_MODULE(debug, simplebus, debug_driver, debug_devclass, + 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_LATE); +MODULE_VERSION(debug, 1); Added: head/sys/arm64/coresight/coresight-dynamic-replicator.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/coresight/coresight-dynamic-replicator.c Thu Apr 5 15:45:54 2018 (r332077) @@ -0,0 +1,172 @@ +/*- + * Copyright (c) 2018 Ruslan Bukin + * All rights reserved. + * + * This software was developed by BAE Systems, the University of Cambridge + * Computer Laboratory, and Memorial University under DARPA/AFRL contract + * FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent Computing + * (TC) research program. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "coresight_if.h" + +#define REPLICATOR_IDFILTER0 0x00 +#define REPLICATOR_IDFILTER1 0x04 + +static struct ofw_compat_data compat_data[] = { + { "arm,coresight-dynamic-replicator", 1 }, + { NULL, 0 } +}; + +struct replicator_softc { + struct resource *res; + struct coresight_platform_data *pdata; +}; + +static struct resource_spec replicator_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { -1, 0 } +}; + +static int +replicator_init(device_t dev) +{ + struct replicator_softc *sc; + + sc = device_get_softc(dev); + + /* Unlock Coresight */ + bus_write_4(sc->res, CORESIGHT_LAR, CORESIGHT_UNLOCK); + + return (0); +} + +static int +replicator_enable(device_t dev, struct endpoint *endp, + struct coresight_event *event) +{ + struct replicator_softc *sc; + + sc = device_get_softc(dev); + + /* Enable the port. Keep the other port disabled */ + if (endp->reg == 0) { + bus_write_4(sc->res, REPLICATOR_IDFILTER0, 0x00); + bus_write_4(sc->res, REPLICATOR_IDFILTER1, 0xff); + } else { + bus_write_4(sc->res, REPLICATOR_IDFILTER0, 0xff); + bus_write_4(sc->res, REPLICATOR_IDFILTER1, 0x00); + } + + return (0); +} + +static void +replicator_disable(device_t dev, struct endpoint *endp, + struct coresight_event *event) +{ + struct replicator_softc *sc; + + sc = device_get_softc(dev); + + bus_write_4(sc->res, REPLICATOR_IDFILTER0, 0xff); + bus_write_4(sc->res, REPLICATOR_IDFILTER1, 0xff); +} + +static int +replicator_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + + device_set_desc(dev, "Coresight Dynamic Replicator"); + + return (BUS_PROBE_DEFAULT); +} + +static int +replicator_attach(device_t dev) +{ + struct replicator_softc *sc; + struct coresight_desc desc; + + sc = device_get_softc(dev); + + if (bus_alloc_resources(dev, replicator_spec, &sc->res) != 0) { + device_printf(dev, "cannot allocate resources for device\n"); + return (ENXIO); + } + + sc->pdata = coresight_get_platform_data(dev); + desc.pdata = sc->pdata; + desc.dev = dev; + desc.dev_type = CORESIGHT_DYNAMIC_REPLICATOR; + coresight_register(&desc); + + return (0); +} + +static device_method_t replicator_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, replicator_probe), + DEVMETHOD(device_attach, replicator_attach), + + /* Coresight interface */ + DEVMETHOD(coresight_init, replicator_init), + DEVMETHOD(coresight_enable, replicator_enable), + DEVMETHOD(coresight_disable, replicator_disable), + DEVMETHOD_END +}; + +static driver_t replicator_driver = { + "replicator", + replicator_methods, + sizeof(struct replicator_softc), +}; + +static devclass_t replicator_devclass; + +DRIVER_MODULE(replicator, simplebus, replicator_driver, replicator_devclass, + 0, 0); +MODULE_VERSION(replicator, 1); Added: head/sys/arm64/coresight/coresight-etm4x.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/coresight/coresight-etm4x.c Thu Apr 5 15:45:54 2018 (r332077) @@ -0,0 +1,307 @@ +/*- + * Copyright (c) 2018 Ruslan Bukin + * All rights reserved. + * + * This software was developed by BAE Systems, the University of Cambridge + * Computer Laboratory, and Memorial University under DARPA/AFRL contract + * FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent Computing + * (TC) research program. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "coresight_if.h" + +#define ETM_DEBUG +#undef ETM_DEBUG + +#ifdef ETM_DEBUG +#define dprintf(fmt, ...) printf(fmt, ##__VA_ARGS__) +#else +#define dprintf(fmt, ...) +#endif + +/* + * Typical trace flow: + * + * CPU0 -> ETM0 -> funnel1 -> funnel0 -> ETF -> replicator -> ETR -> DRAM + * CPU1 -> ETM1 -> funnel1 -^ + * CPU2 -> ETM2 -> funnel1 -^ + * CPU3 -> ETM3 -> funnel1 -^ + */ + +static struct ofw_compat_data compat_data[] = { + { "arm,coresight-etm4x", 1 }, + { NULL, 0 } +}; + +struct etm_softc { + struct resource *res; + struct coresight_platform_data *pdata; +}; + +static struct resource_spec etm_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { -1, 0 } +}; + +static int +etm_prepare(device_t dev, struct coresight_event *event) +{ + struct etm_softc *sc; + uint32_t reg; + int i; + + sc = device_get_softc(dev); + + /* Configure ETM */ + + /* + * Enable the return stack, global timestamping, + * Context ID, and Virtual context identifier tracing. + */ + reg = TRCCONFIGR_RS | TRCCONFIGR_TS; + reg |= TRCCONFIGR_CID | TRCCONFIGR_VMID; + reg |= TRCCONFIGR_INSTP0_LDRSTR; + reg |= TRCCONFIGR_COND_ALL; + bus_write_4(sc->res, TRCCONFIGR, reg); + + /* Disable all event tracing. */ + bus_write_4(sc->res, TRCEVENTCTL0R, 0); + bus_write_4(sc->res, TRCEVENTCTL1R, 0); + + /* Disable stalling, if implemented. */ + bus_write_4(sc->res, TRCSTALLCTLR, 0); + + /* Enable trace synchronization every 4096 bytes of trace. */ + bus_write_4(sc->res, TRCSYNCPR, TRCSYNCPR_4K); + + /* Set a value for the trace ID */ + bus_write_4(sc->res, TRCTRACEIDR, event->etm.trace_id); + + /* + * Disable the timestamp event. The trace unit still generates + * timestamps due to other reasons such as trace synchronization. + */ + bus_write_4(sc->res, TRCTSCTLR, 0); + + /* + * Enable ViewInst to trace everything, with the start/stop + * logic started. + */ + reg = TRCVICTLR_SSSTATUS; + + /* The number of the single resource used to activate the event. */ + reg |= (1 << EVENT_SEL_S); + + if (event->excp_level > 2) + return (-1); + + reg |= TRCVICTLR_EXLEVEL_NS_M; + reg &= ~TRCVICTLR_EXLEVEL_NS(event->excp_level); + reg |= TRCVICTLR_EXLEVEL_S_M; + reg &= ~TRCVICTLR_EXLEVEL_S(event->excp_level); + bus_write_4(sc->res, TRCVICTLR, reg); + + for (i = 0; i < event->naddr * 2; i++) { + dprintf("configure range %d, address %lx\n", + i, event->addr[i]); + bus_write_8(sc->res, TRCACVR(i), event->addr[i]); + + reg = 0; + /* Secure state */ + reg |= TRCACATR_EXLEVEL_S_M; + reg &= ~TRCACATR_EXLEVEL_S(event->excp_level); + /* Non-secure state */ + reg |= TRCACATR_EXLEVEL_NS_M; + reg &= ~TRCACATR_EXLEVEL_NS(event->excp_level); + bus_write_4(sc->res, TRCACATR(i), reg); + + /* Address range is included */ + reg = bus_read_4(sc->res, TRCVIIECTLR); + reg |= (1 << (TRCVIIECTLR_INCLUDE_S + i / 2)); + bus_write_4(sc->res, TRCVIIECTLR, reg); + } + + /* No address filtering for ViewData. */ + bus_write_4(sc->res, TRCVDARCCTLR, 0); + + /* Clear the STATUS bit to zero */ + bus_write_4(sc->res, TRCSSCSR(0), 0); + + if (event->naddr == 0) { + /* No address range filtering for ViewInst. */ + bus_write_4(sc->res, TRCVIIECTLR, 0); + } + + /* No start or stop points for ViewInst. */ + bus_write_4(sc->res, TRCVISSCTLR, 0); + + /* Disable ViewData */ + bus_write_4(sc->res, TRCVDCTLR, 0); + + /* No address filtering for ViewData. */ + bus_write_4(sc->res, TRCVDSACCTLR, 0); + + return (0); +} + +static int +etm_init(device_t dev) +{ + struct etm_softc *sc; + uint32_t reg; + + sc = device_get_softc(dev); + + /* Unlocking Coresight */ + bus_write_4(sc->res, CORESIGHT_LAR, CORESIGHT_UNLOCK); + + /* Unlocking ETM */ + bus_write_4(sc->res, TRCOSLAR, 0); + + reg = bus_read_4(sc->res, TRCIDR(1)); + dprintf("ETM Version: %d.%d\n", + (reg & TRCIDR1_TRCARCHMAJ_M) >> TRCIDR1_TRCARCHMAJ_S, + (reg & TRCIDR1_TRCARCHMIN_M) >> TRCIDR1_TRCARCHMIN_S); + + return (0); +} + +static int +etm_enable(device_t dev, struct endpoint *endp, + struct coresight_event *event) +{ + struct etm_softc *sc; + uint32_t reg; + + sc = device_get_softc(dev); + + etm_prepare(dev, event); + + /* Enable the trace unit */ + bus_write_4(sc->res, TRCPRGCTLR, TRCPRGCTLR_EN); + + /* Wait for an IDLE bit to be LOW */ + do { + reg = bus_read_4(sc->res, TRCSTATR); + } while ((reg & TRCSTATR_IDLE) == 1); + + if ((bus_read_4(sc->res, TRCPRGCTLR) & TRCPRGCTLR_EN) == 0) + panic("etm is not enabled\n"); + + return (0); +} + +static void +etm_disable(device_t dev, struct endpoint *endp, + struct coresight_event *event) +{ + struct etm_softc *sc; + uint32_t reg; + + sc = device_get_softc(dev); + + /* Disable the trace unit */ + bus_write_4(sc->res, TRCPRGCTLR, 0); + + /* Wait for an IDLE bit */ + do { + reg = bus_read_4(sc->res, TRCSTATR); + } while ((reg & TRCSTATR_IDLE) == 0); +} + +static int +etm_probe(device_t dev) +{ + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + + device_set_desc(dev, "AArch64 Embedded Trace Macrocell"); + + return (BUS_PROBE_DEFAULT); +} + +static int +etm_attach(device_t dev) +{ + struct coresight_desc desc; + struct etm_softc *sc; + + sc = device_get_softc(dev); + + if (bus_alloc_resources(dev, etm_spec, &sc->res) != 0) { + device_printf(dev, "cannot allocate resources for device\n"); + return (ENXIO); + } + + sc->pdata = coresight_get_platform_data(dev); + desc.pdata = sc->pdata; + desc.dev = dev; + desc.dev_type = CORESIGHT_ETMV4; + coresight_register(&desc); + + return (0); +} + +static device_method_t etm_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, etm_probe), + DEVMETHOD(device_attach, etm_attach), + + /* Coresight interface */ + DEVMETHOD(coresight_init, etm_init), + DEVMETHOD(coresight_enable, etm_enable), + DEVMETHOD(coresight_disable, etm_disable), + DEVMETHOD_END +}; + +static driver_t etm_driver = { + "etm", + etm_methods, + sizeof(struct etm_softc), +}; + +static devclass_t etm_devclass; + +DRIVER_MODULE(etm, simplebus, etm_driver, etm_devclass, 0, 0); +MODULE_VERSION(etm, 1); Added: head/sys/arm64/coresight/coresight-etm4x.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/coresight/coresight-etm4x.h Thu Apr 5 15:45:54 2018 (r332077) @@ -0,0 +1,175 @@ +/*- + * Copyright (c) 2018 Ruslan Bukin + * All rights reserved. + * + * This software was developed by BAE Systems, the University of Cambridge + * Computer Laboratory, and Memorial University under DARPA/AFRL contract + * FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent Computing + * (TC) research program. + * + * 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 _ARM64_CORESIGHT_ETM4X_H_ +#define _ARM64_CORESIGHT_ETM4X_H_ + +#define TRCPRGCTLR 0x004 /* Trace Programming Control Register */ +#define TRCPRGCTLR_EN (1 << 0) /* Trace unit enable bit */ +#define TRCPROCSELR 0x008 /* Trace PE Select Control Register */ +#define TRCSTATR 0x00C /* Trace Trace Status Register */ +#define TRCSTATR_PMSTABLE (1 << 1) /* The programmers' model is stable. */ +#define TRCSTATR_IDLE (1 << 0) /* The trace unit is idle. */ +#define TRCCONFIGR 0x010 /* Trace Trace Configuration Register */ +#define TRCCONFIGR_DV (1 << 17) /* Data value tracing is enabled when INSTP0 is not 0b00 */ +#define TRCCONFIGR_DA (1 << 16) /* Data address tracing is enabled when INSTP0 is not 0b00. */ +#define TRCCONFIGR_VMIDOPT (1 << 15) /* Control bit to configure the Virtual context identifier value */ +#define TRCCONFIGR_QE_S 13 /* Q element enable field */ +#define TRCCONFIGR_QE_M (0x3 << TRCCONFIGR_QE_S) +#define TRCCONFIGR_RS (1 << 12) /* Return stack enable bit */ +#define TRCCONFIGR_TS (1 << 11) /* Global timestamp tracing is enabled. */ +#define TRCCONFIGR_COND_S 8 /* Conditional instruction tracing bit. */ +#define TRCCONFIGR_COND_M (0x7 << TRCCONFIGR_COND_S) +#define TRCCONFIGR_COND_DIS 0 +#define TRCCONFIGR_COND_LDR (1 << TRCCONFIGR_COND_S) /* Conditional load instructions are traced. */ +#define TRCCONFIGR_COND_STR (2 << TRCCONFIGR_COND_S) /* Conditional store instructions are traced. */ +#define TRCCONFIGR_COND_LDRSTR (3 << TRCCONFIGR_COND_S) /* Conditional load and store instructions are traced. */ +#define TRCCONFIGR_COND_ALL (7 << TRCCONFIGR_COND_S) /* All conditional instructions are traced. */ +#define TRCCONFIGR_VMID (1 << 7) /* Virtual context identifier tracing is enabled. */ +#define TRCCONFIGR_CID (1 << 6) /* Context ID tracing is enabled. */ +#define TRCCONFIGR_CCI (1 << 4) /* Cycle counting in the instruction trace is enabled. */ +#define TRCCONFIGR_BB (1 << 3) /* Branch broadcast mode is enabled. */ +#define TRCCONFIGR_INSTP0_S 1 /* Instruction P0 field. */ +#define TRCCONFIGR_INSTP0_M (0x3 << TRCCONFIGR_INSTP0_S) +#define TRCCONFIGR_INSTP0_NONE 0 /* Do not trace load and store instructions as P0 instructions. */ +#define TRCCONFIGR_INSTP0_LDR (1 << TRCCONFIGR_INSTP0_S) /* Trace load instructions as P0 instructions. */ +#define TRCCONFIGR_INSTP0_STR (2 << TRCCONFIGR_INSTP0_S) /* Trace store instructions as P0 instructions. */ +#define TRCCONFIGR_INSTP0_LDRSTR (3 << TRCCONFIGR_INSTP0_S) /* Trace load and store instructions as P0 instr. */ +#define TRCAUXCTLR 0x018 /* Trace Auxiliary Control Register */ +#define TRCEVENTCTL0R 0x020 /* Trace Event Control 0 Register */ +#define TRCEVENTCTL1R 0x024 /* Trace Event Control 1 Register */ +#define TRCSTALLCTLR 0x02C /* Trace Stall Control Register */ +#define TRCTSCTLR 0x030 /* Trace Global Timestamp Control Register */ +#define TRCSYNCPR 0x034 /* Trace Synchronization Period Register */ +#define TRCSYNCPR_PERIOD_S 0 +#define TRCSYNCPR_PERIOD_M 0x1f +#define TRCSYNCPR_1K (10 << TRCSYNCPR_PERIOD_S) +#define TRCSYNCPR_2K (11 << TRCSYNCPR_PERIOD_S) +#define TRCSYNCPR_4K (12 << TRCSYNCPR_PERIOD_S) +#define TRCCCCTLR 0x038 /* Trace Cycle Count Control Register */ +#define TRCBBCTLR 0x03C /* Trace Branch Broadcast Control Register */ +#define TRCTRACEIDR 0x040 /* Trace Trace ID Register */ +#define TRCQCTLR 0x044 /* Trace Q Element Control Register */ +#define TRCQCTLR_MODE_INC (1 << 8) /* Include mode. */ +#define TRCVICTLR 0x080 /* Trace ViewInst Main Control Register */ +#define TRCVICTLR_SSSTATUS (1 << 9) /* The start/stop logic is in the started state. */ +#define TRCVICTLR_EXLEVEL_NS_S 20 +#define TRCVICTLR_EXLEVEL_NS_M (0xf << TRCVICTLR_EXLEVEL_NS_S) +#define TRCVICTLR_EXLEVEL_NS(n) (0x1 << ((n) + TRCVICTLR_EXLEVEL_NS_S)) +#define TRCVICTLR_EXLEVEL_S_S 16 +#define TRCVICTLR_EXLEVEL_S_M (0xf << TRCVICTLR_EXLEVEL_S_S) +#define TRCVICTLR_EXLEVEL_S(n) (0x1 << ((n) + TRCVICTLR_EXLEVEL_S_S)) +#define EVENT_SEL_S 0 +#define EVENT_SEL_M (0x1f << EVENT_SEL_S) +#define TRCVIIECTLR 0x084 /* Trace ViewInst Include/Exclude Control Register */ +#define TRCVIIECTLR_INCLUDE_S 0 +#define TRCVISSCTLR 0x088 /* Trace ViewInst Start/Stop Control Register */ +#define TRCVIPCSSCTLR 0x08C /* Trace ViewInst Start/Stop PE Comparator Control Register */ +#define TRCVDCTLR 0x0A0 /* Trace ViewData Main Control Register */ +#define TRCVDCTLR_TRCEXDATA (1 << 12) /* Exception and exception return data transfers are traced */ +#define TRCVDCTLR_TBI (1 << 11) /* The trace unit assigns bits[63:56] to have the same value as bits[63:56] of the data address. */ +#define TRCVDCTLR_PCREL (1 << 10) /* The trace unit does not trace the address or value portions of PC-relative transfers. */ +#define TRCVDCTLR_SPREL_S 8 +#define TRCVDCTLR_SPREL_M (0x3 << TRCVDCTLR_SPREL_S) +#define TRCVDCTLR_EVENT_S 0 +#define TRCVDCTLR_EVENT_M (0xff << TRCVDCTLR_EVENT_S) +#define TRCVDSACCTLR 0x0A4 /* Trace ViewData Include/Exclude Single Address Comparator Control Register */ +#define TRCVDARCCTLR 0x0A8 /* Trace ViewData Include/Exclude Address Range Comparator Control Register */ +#define TRCSEQEVR(n) (0x100 + (n) * 0x4) /* Trace Sequencer State Transition Control Register [n=0-2] */ +#define TRCSEQRSTEVR 0x118 /* Trace Sequencer Reset Control Register */ +#define TRCSEQSTR 0x11C /* Trace Sequencer State Register */ +#define TRCEXTINSELR 0x120 /* Trace External Input Select Register */ +#define TRCCNTRLDVR(n) (0x140 + (n) * 0x4) /* 32 Trace Counter Reload Value Register [n=0-3] */ +#define TRCCNTCTLR(n) (0x150 + (n) * 0x4) /* 32 Trace Counter Control Register [n=0-3] */ +#define TRCCNTVR(n) (0x160 + (n) * 0x4) /* 32 Trace Counter Value Register [n=0-3] */ +#define TRCIMSPEC(n) (0x1C0 + (n) * 0x4) /* Trace IMPLEMENTATION DEFINED register [n=0-7] */ + +#define TRCIDR0(n) (0x1E0 + 0x4 * (n)) +#define TRCIDR8(n) (0x180 + 0x4 * (n)) +#define TRCIDR(n) ((n > 7) ? TRCIDR8(n) : TRCIDR0(n)) +#define TRCIDR1_TRCARCHMAJ_S 8 +#define TRCIDR1_TRCARCHMAJ_M (0xf << TRCIDR1_TRCARCHMAJ_S) +#define TRCIDR1_TRCARCHMIN_S 4 +#define TRCIDR1_TRCARCHMIN_M (0xf << TRCIDR1_TRCARCHMIN_S) + +#define TRCRSCTLR(n) (0x200 + (n) * 0x4) /* Trace Resource Selection Control Register [n=2-31] */ +#define TRCSSCCR(n) (0x280 + (n) * 0x4) /* Trace Single-shot Comparator Control Register [n=0-7] */ +#define TRCSSCSR(n) (0x2A0 + (n) * 0x4) /* Trace Single-shot Comparator Status Register [n=0-7] */ +#define TRCSSPCICR(n) (0x2C0 + (n) * 0x4) /* Trace Single-shot PE Comparator Input Control [n=0-7] */ +#define TRCOSLAR 0x300 /* Management OS Lock Access Register */ +#define TRCOSLSR 0x304 /* Management OS Lock Status Register */ +#define TRCPDCR 0x310 /* Management PowerDown Control Register */ +#define TRCPDSR 0x314 /* Management PowerDown Status Register */ +#define TRCACVR(n) (0x400 + (n) * 0x8) /* Trace Address Comparator Value Register [n=0-15] */ +#define TRCACATR(n) (0x480 + (n) * 0x8) /* Trace Address Comparator Access Type Register [n=0-15] */ +#define TRCACATR_DTBM (1 << 21) +#define TRCACATR_DATARANGE (1 << 20) +#define TRCACATR_DATASIZE_S 18 +#define TRCACATR_DATASIZE_M (0x3 << TRCACATR_DATASIZE_S) +#define TRCACATR_DATASIZE_B (0x0 << TRCACATR_DATASIZE_S) +#define TRCACATR_DATASIZE_HW (0x1 << TRCACATR_DATASIZE_S) +#define TRCACATR_DATASIZE_W (0x2 << TRCACATR_DATASIZE_S) +#define TRCACATR_DATASIZE_DW (0x3 << TRCACATR_DATASIZE_S) +#define TRCACATR_DATAMATCH_S 16 +#define TRCACATR_DATAMATCH_M (0x3 << TRCACATR_DATAMATCH_S) +#define TRCACATR_EXLEVEL_S_S 8 +#define TRCACATR_EXLEVEL_S_M (0xf << TRCACATR_EXLEVEL_S_S) +#define TRCACATR_EXLEVEL_S(n) (0x1 << ((n) + TRCACATR_EXLEVEL_S_S)) +#define TRCACATR_EXLEVEL_NS_S 12 +#define TRCACATR_EXLEVEL_NS_M (0xf << TRCACATR_EXLEVEL_NS_S) +#define TRCACATR_EXLEVEL_NS(n) (0x1 << ((n) + TRCACATR_EXLEVEL_NS_S)) +#define TRCDVCVR(n) (0x500 + (n) * 0x8) /* Trace Data Value Comparator Value Register [n=0-7] */ +#define TRCDVCMR(n) (0x580 + (n) * 0x8) /* Trace Data Value Comparator Mask Register [n=0-7] */ +#define TRCCIDCVR(n) (0x600 + (n) * 0x8) /* Trace Context ID Comparator Value Register [n=0-7] */ +#define TRCVMIDCVR(n) (0x640 + (n) * 0x8) /* Trace Virtual context identifier Comparator Value [n=0-7] */ +#define TRCCIDCCTLR0 0x680 /* Trace Context ID Comparator Control Register 0 */ +#define TRCCIDCCTLR1 0x684 /* Trace Context ID Comparator Control Register 1 */ +#define TRCVMIDCCTLR0 0x688 /* Trace Virtual context identifier Comparator Control Register 0 */ +#define TRCVMIDCCTLR1 0x68C /* Trace Virtual context identifier Comparator Control Register 1 */ +#define TRCITCTRL 0xF00 /* Management Integration Mode Control register */ +#define TRCCLAIMSET 0xFA0 /* Trace Claim Tag Set register */ +#define TRCCLAIMCLR 0xFA4 /* Trace Claim Tag Clear register */ +#define TRCDEVAFF0 0xFA8 /* Management Device Affinity register 0 */ +#define TRCDEVAFF1 0xFAC /* Management Device Affinity register 1 */ +#define TRCLAR 0xFB0 /* Management Software Lock Access Register */ +#define TRCLSR 0xFB4 /* Management Software Lock Status Register */ +#define TRCAUTHSTATUS 0xFB8 /* Management Authentication Status register */ +#define TRCDEVARCH 0xFBC /* Management Device Architecture register */ +#define TRCDEVID 0xFC8 /* Management Device ID register */ +#define TRCDEVTYPE 0xFCC /* Management Device Type register */ +#define TRCPIDR4 0xFD0 /* Management Peripheral ID4 Register */ +#define TRCPIDR(n) (0xFE0 + (n) * 0x4) /* Management Peripheral IDn Register [n=0-3] */ +#define TRCPIDR567(n) (0xFD4 + ((n) - 5) * 0x4) /* Management Peripheral ID5 to Peripheral ID7 Registers */ +#define TRCCIDR(n) (0xFF0 + (n) * 0x4) /* Management Component IDn Register [n=0-4] */ + +#endif /* !_ARM64_CORESIGHT_ETM4X_H_ */ Added: head/sys/arm64/coresight/coresight-funnel.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/coresight/coresight-funnel.c Thu Apr 5 15:45:54 2018 (r332077) @@ -0,0 +1,180 @@ +/*- + * Copyright (c) 2018 Ruslan Bukin + * All rights reserved. + * + * This software was developed by BAE Systems, the University of Cambridge + * Computer Laboratory, and Memorial University under DARPA/AFRL contract + * FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent Computing + * (TC) research program. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Thu Apr 5 15:46:25 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9B0F7F8EC70; Thu, 5 Apr 2018 15:46:25 +0000 (UTC) (envelope-from royger@gmail.com) Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com [IPv6:2a00:1450:400c:c09::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 089B382BCC; Thu, 5 Apr 2018 15:46:25 +0000 (UTC) (envelope-from royger@gmail.com) Received: by mail-wm0-x22b.google.com with SMTP id b127so6980758wmf.5; Thu, 05 Apr 2018 08:46:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=+iQBHN6MuEXXuH5MHTqc3xzybLKCp18b5mC8LLkvkOc=; b=YBEzVE13rOrepXug3vKUDBUSvDeOPo9TAikGAQeuJIKGQRn4BA+Gn78C3Uh6gm0+tx Ptjqb7iySuwTPy2ur/1kyFCXEtXNTEIJf4rYtoPNhWUDPdrhk/SJTXYO9uH3GA1jmqKL H5SoB3eZtAHHNSM9K/I9Wg7EzSSog4hZHpWS3qH3QEdaL5crKkTTViMR7DKO3+4FHrVG TVI6ipTyTNZKLPf7XYIL0QB1UNODbTrr8XfVU/5olkhP+UIo0oGJMII4I7lz04t4S32q DygxX1hDQToJ2vGjZhGNxP7NeV8lpEahuYkH7DzMIIazW0slbs75a8BnAhv7vqAwW6nG h+4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=+iQBHN6MuEXXuH5MHTqc3xzybLKCp18b5mC8LLkvkOc=; b=JRMnZkIQmylmPrnVSkcELHnLch9GiPZbn9EY880Urhr2AYKQXW/58HAxRPleo0GYsO DhNsVuddkXuSH+JuAmhxmePpXuhMvwOMQqt1yZogy2/iSwnqZYc2FxLfeUe28+JBV8Zx FCnVEIVvCMnTPHVRyQqb9wfdV0cu0gD+bNNmJDEHWVZwVHuvZifC0qtDc5M+NFk5tEN5 D+wDuUX6ic2YE+vzWvbV5/sVHvSLLri1FbMm7iHnDHmWaIAjIsSFDWhdWKlf6d8zx7xV xwoF+cP6VG9xs+agNNTw5+3aml76HnNoSPk2P5OV58SKCZLen22TJe7NDPBGcd7adZIp gvew== X-Gm-Message-State: ALQs6tCljR6S/Hb8Gk31xjtbuM+zdxL1//1FvzFzcw0LDrkx8K2dNrdy lZRqM1p4H7RM9c1OWsgutoezzA== X-Google-Smtp-Source: AIpwx48tmlEY5nzJC+dvJ6p31wwfmTj2oriRf2gAHtys3K8tyj6lK28CL1Np05nU/a7b/vR26JNSbA== X-Received: by 10.80.243.4 with SMTP id p4mr3411790edm.131.1522943183714; Thu, 05 Apr 2018 08:46:23 -0700 (PDT) Received: from localhost (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id y6sm4719240edh.3.2018.04.05.08.46.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Apr 2018 08:46:22 -0700 (PDT) Sender: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Date: Thu, 5 Apr 2018 16:46:19 +0100 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Ian Lepore Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r332072 - head/sys/sys Message-ID: <20180405154619.q3blip266qa3z5ut@MacBook-Pro-de-Roger.local> References: <201804051431.w35EVtg4047897@repo.freebsd.org> <1522942377.49673.245.camel@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1522942377.49673.245.camel@freebsd.org> User-Agent: NeoMutt/20180323 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 15:46:26 -0000 On Thu, Apr 05, 2018 at 09:32:57AM -0600, Ian Lepore wrote: > On Thu, 2018-04-05 at 14:31 +0000, Roger Pau Monné wrote: > > Author: royger > > Date: Thu Apr  5 14:31:54 2018 > > New Revision: 332072 > > URL: https://svnweb.freebsd.org/changeset/base/332072 > > > > Log: > >   introduce GiB and MiB macros > >    > >   This macros convert from GiB or MiB into bytes. > >    > >   Sponsored by: Citrix Systems R&D > > > > Modified: > >   head/sys/sys/param.h > > > > Modified: head/sys/sys/param.h > > ============================================================================== > > --- head/sys/sys/param.h Thu Apr  5 14:25:39 2018 (r332071) > > +++ head/sys/sys/param.h Thu Apr  5 14:31:54 2018 (r332072) > > @@ -362,4 +362,8 @@ __END_DECLS > >   */ > >  #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset]) > >   > > +/* Unit conversion macros. */ > > +#define GiB(v) (v ## ULL << 30) > > +#define MiB(v) (v ## ULL << 20) > > + > >  #endif /* _SYS_PARAM_H_ */ > > > > These names don't make it clear whether the conversion is bytes->GiB or > GiB->bytes.  The names seem way too generic for a public namespace in a > file as heavily included behind your back as param.h is. > > Also, this completely reasonable usage won't work, likely with > confusing compile error messages: > >   int bytes, gibytes; >   ... >   bytes = GiB(gibytes); I find those helpful for their specific usage. I could introduce static inline functions like: size_t gb_to_bytes(size_t)... But I assume this is also going to cause further discussion. Roger. From owner-svn-src-head@freebsd.org Thu Apr 5 15:58:38 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 79CD4F8F80C for ; Thu, 5 Apr 2018 15:58:38 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x22c.google.com (mail-io0-x22c.google.com [IPv6:2607:f8b0:4001:c06::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0A1EA8353C for ; Thu, 5 Apr 2018 15:58:38 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x22c.google.com with SMTP id v13so31193182iob.6 for ; Thu, 05 Apr 2018 08:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=YLfxFBoSQGkqIW65V6UOkbgjI8VF/Dcc1eUDnlivCTY=; b=OaEKY9r8SEWlvZGUCgftNma7j3ZQYreN0E4fP5J/W84/LU9NF/3yfp9XfmlYHWvo47 zn9Q68wuKMzsFNzzE+fT8NRpx0+RwfsjAzTSqXGcOIf4PEiSNiKGNMXz3nHpm95jMwNM JGj5ZSsQj55ow7rW30DL8qC/F2E7tiaFVzsDzmpqJTNPOxdlKui+V15VKDPC/WV0R8bA WxU0auijCOLVCaehK0FME/s/EtMg9x0W/uDN4jDPrSxg/kUtbiLywp355kMU0eP+N66I hw/eAdwZbM4htNBeHKJ9Yr+cwMpSmWzi6k9PjkIKCn3ZA8KfKtjDkgXUU9g6bLpw03Az VB5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=YLfxFBoSQGkqIW65V6UOkbgjI8VF/Dcc1eUDnlivCTY=; b=qgkDAo6W9BV2YExMgdJm/p8Lp7DuW/tUln9wion6Zy0W7JKsp+imU/dm1DzZPe7nI4 lH247MeF6sgVtLb2t4KvqkIpzC7jcOhs6BD4r7pMqRxDeQGNAxEeZrPlg7FGAElFmE12 +QYikEGM1kNVOFkIXOCFoVUsdPIwFU+3Ddeq5dhwy8p1zRmtjSGBjBHBcUXNXhC2albH 7cf9+qWD0ZuTFpwm0iuX6hmyjigZtQzTDU1VmXHbQCPar8rJm6CdJTllZp1uVxOJU2WP vwlrUzHJqb5ko1IIek9csBL3oK6trP5/aQiHmEe42pra2tVgAf0Xro4Zw0S2F8gW+6uL arKQ== X-Gm-Message-State: ALQs6tDPxU+cZmPqhujbQLaFUeaIFvWX9lOiy1D05cVh9EmkTnCXI70C NIoOPg+gr94kXRNJAlN8NbXhCcZVdMk/7isjsCW/eg== X-Google-Smtp-Source: AIpwx48OAVYzY0JqVlQnMYHBFyMwGNmLcwSYX6vI6O2RhjKlbu3eWjQDmhjIca2vESzvuQOK45+/D52vJ0nIlBkiTQA= X-Received: by 10.107.144.11 with SMTP id s11mr21298407iod.37.1522943917285; Thu, 05 Apr 2018 08:58:37 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.203.196 with HTTP; Thu, 5 Apr 2018 08:58:36 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: <20180405154619.q3blip266qa3z5ut@MacBook-Pro-de-Roger.local> References: <201804051431.w35EVtg4047897@repo.freebsd.org> <1522942377.49673.245.camel@freebsd.org> <20180405154619.q3blip266qa3z5ut@MacBook-Pro-de-Roger.local> From: Warner Losh Date: Thu, 5 Apr 2018 09:58:36 -0600 X-Google-Sender-Auth: 4xnmOBh0savK7uMhUlT9cEVyNhE Message-ID: Subject: Re: svn commit: r332072 - head/sys/sys To: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Cc: Ian Lepore , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 15:58:38 -0000 On Thu, Apr 5, 2018 at 9:46 AM, Roger Pau Monn=C3=A9 w= rote: > On Thu, Apr 05, 2018 at 09:32:57AM -0600, Ian Lepore wrote: > > On Thu, 2018-04-05 at 14:31 +0000, Roger Pau Monn=C3=A9 wrote: > > > Author: royger > > > Date: Thu Apr 5 14:31:54 2018 > > > New Revision: 332072 > > > URL: https://svnweb.freebsd.org/changeset/base/332072 > > > > > > Log: > > > introduce GiB and MiB macros > > > > > > This macros convert from GiB or MiB into bytes. > > > > > > Sponsored by: Citrix Systems R&D > > > > > > Modified: > > > head/sys/sys/param.h > > > > > > Modified: head/sys/sys/param.h > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > --- head/sys/sys/param.h Thu Apr 5 14:25:39 2018 (r332071) > > > +++ head/sys/sys/param.h Thu Apr 5 14:31:54 2018 (r332072) > > > @@ -362,4 +362,8 @@ __END_DECLS > > > */ > > > #define __PAST_END(array, offset) (((__typeof__(*(array)) > *)(array))[offset]) > > > > > > +/* Unit conversion macros. */ > > > +#define GiB(v) (v ## ULL << 30) > > > +#define MiB(v) (v ## ULL << 20) > > > + > > > #endif /* _SYS_PARAM_H_ */ > > > > > > > These names don't make it clear whether the conversion is bytes->GiB or > > GiB->bytes. The names seem way too generic for a public namespace in a > > file as heavily included behind your back as param.h is. > > > > Also, this completely reasonable usage won't work, likely with > > confusing compile error messages: > > > > int bytes, gibytes; > > ... > > bytes =3D GiB(gibytes); > > I find those helpful for their specific usage. I could introduce > static inline functions like: > > size_t gb_to_bytes(size_t)... > > But I assume this is also going to cause further discussion. > Yea, traditional macro names would be "gibtob" and "btogib" but I didn't just reply to bikeshed a name: But you don't need to specify a type, consider the current btodb macro: #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ (sizeof (bytes) > sizeof(long) \ ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) which shows how to do this in a macro, which is orthogonal to any name you may choose. I can also bikeshed function vs macro :) Warner From owner-svn-src-head@freebsd.org Thu Apr 5 16:07:41 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 23332F900B5; Thu, 5 Apr 2018 16:07:41 +0000 (UTC) (envelope-from royger@gmail.com) Received: from mail-wm0-x235.google.com (mail-wm0-x235.google.com [IPv6:2a00:1450:400c:c09::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8CADE83B98; Thu, 5 Apr 2018 16:07:40 +0000 (UTC) (envelope-from royger@gmail.com) Received: by mail-wm0-x235.google.com with SMTP id b127so7156184wmf.5; Thu, 05 Apr 2018 09:07:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=Z0b91rhCRGZ1zQOMu/vTjTE7YhkSU99B1x+iPm20ReU=; b=tI77K8KsvFgTS9MCWUUVV2uPFpa4d+qm+/MMrdXN3RQsUVi16O8d72hBWbzU+l80ij lpp9qrX6E3CPfwek/FQJFKysJvHPCUxYeZHkqD8yoYfErDZZIbd9tIOsny2N4n1BiwzO /buyQua1AvNh2MbhRWPbx8O5YyRr9QLKo87FoI/AdxMIgi7M9/oaSUNPoBpFGcH/Lnd0 uG5n8PDo7NRg0JDS3TTV0VCwk1C8ZFIc//EuqQZZnGQQgRtmY8jq7xOzy16DDeghTAeG BT4jYZuPP2JBSWl186XTZfQCakakMWPzjpawboto5qOEEYgerG73tF+zULPTD8EEvohu rZrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=Z0b91rhCRGZ1zQOMu/vTjTE7YhkSU99B1x+iPm20ReU=; b=UISoxshLgtTks60qNJ+/z6TXm4otzAKZUUvpfCtTkbxXJMYWjS4+UYe9OOD2gA0NdS IRZRLKY6nMpDTi1trWgP1/yYSzfmbiXpoaMPs8CIXHmrhvKp1AjBL812BNfZNxHmJj/d uv0gHmjp2vr3MRHfV2QZBIx1FCy+7jxCxuIXpi15rLSOfHbxWujG058pSnjRaYvbC8Qn K3acLTvys4vf0sy10tFVPKp/IFHgld1Rx0wFcLTmaD51btYQq9+aDIWIA27HHqb2emEt j9CKyjUYsKL70aK6GNhEEpVvxrMo2+kiBKBBnDHO9rluJVvtaZRAfWMfaZ3NeeSor/pk 2pfg== X-Gm-Message-State: ALQs6tBEPYqgbyVd/bDE31LiD+yHWuegwcrnonrszuKNJVY6m8wj0dnK HO+CVLuASBJuHnn/jQ7Ug+YhAA== X-Google-Smtp-Source: AIpwx49nJLP4KjsODhBvbPCZfzMBt7PFywSWZ8WT33mWPk38Qi4iMzNWxDKWE/L0SSeR1/i82NfkVA== X-Received: by 10.80.242.135 with SMTP id f7mr3485546edm.169.1522944459508; Thu, 05 Apr 2018 09:07:39 -0700 (PDT) Received: from localhost (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id n21sm4387374eda.73.2018.04.05.09.07.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Apr 2018 09:07:38 -0700 (PDT) Sender: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Date: Thu, 5 Apr 2018 17:07:35 +0100 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Warner Losh Cc: Ian Lepore , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r332072 - head/sys/sys Message-ID: <20180405160735.wkpsqqiyoyh7ewuk@MacBook-Pro-de-Roger.local> References: <201804051431.w35EVtg4047897@repo.freebsd.org> <1522942377.49673.245.camel@freebsd.org> <20180405154619.q3blip266qa3z5ut@MacBook-Pro-de-Roger.local> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180323 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 16:07:41 -0000 On Thu, Apr 05, 2018 at 09:58:36AM -0600, Warner Losh wrote: > On Thu, Apr 5, 2018 at 9:46 AM, Roger Pau Monné wrote: > > > On Thu, Apr 05, 2018 at 09:32:57AM -0600, Ian Lepore wrote: > > > On Thu, 2018-04-05 at 14:31 +0000, Roger Pau Monné wrote: > > > > Author: royger > > > > Date: Thu Apr 5 14:31:54 2018 > > > > New Revision: 332072 > > > > URL: https://svnweb.freebsd.org/changeset/base/332072 > > > > > > > > Log: > > > > introduce GiB and MiB macros > > > > > > > > This macros convert from GiB or MiB into bytes. > > > > > > > > Sponsored by: Citrix Systems R&D > > > > > > > > Modified: > > > > head/sys/sys/param.h > > > > > > > > Modified: head/sys/sys/param.h > > > > ============================================================ > > ================== > > > > --- head/sys/sys/param.h Thu Apr 5 14:25:39 2018 (r332071) > > > > +++ head/sys/sys/param.h Thu Apr 5 14:31:54 2018 (r332072) > > > > @@ -362,4 +362,8 @@ __END_DECLS > > > > */ > > > > #define __PAST_END(array, offset) (((__typeof__(*(array)) > > *)(array))[offset]) > > > > > > > > +/* Unit conversion macros. */ > > > > +#define GiB(v) (v ## ULL << 30) > > > > +#define MiB(v) (v ## ULL << 20) > > > > + > > > > #endif /* _SYS_PARAM_H_ */ > > > > > > > > > > These names don't make it clear whether the conversion is bytes->GiB or > > > GiB->bytes. The names seem way too generic for a public namespace in a > > > file as heavily included behind your back as param.h is. > > > > > > Also, this completely reasonable usage won't work, likely with > > > confusing compile error messages: > > > > > > int bytes, gibytes; > > > ... > > > bytes = GiB(gibytes); > > > > I find those helpful for their specific usage. I could introduce > > static inline functions like: > > > > size_t gb_to_bytes(size_t)... > > > > But I assume this is also going to cause further discussion. > > > > Yea, traditional macro names would be "gibtob" and "btogib" but I didn't > just reply to bikeshed a name: > > But you don't need to specify a type, consider the current btodb macro: > #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) > */ \ > (sizeof (bytes) > sizeof(long) \ > ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ > : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) > > which shows how to do this in a macro, which is orthogonal to any name you > may choose. I can also bikeshed function vs macro :) I was just going to remove those from here and place them in the files where I use them, but I can also change them to: #define gibtob(gib) ((unsigned long long)(gib) << 30) #define mibtob(mib) ((unsigned long long)(mib) << 20) If it's not going to start a bikeshed. Thanks, Roger. From owner-svn-src-head@freebsd.org Thu Apr 5 17:26:04 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6C80AF94A8C; Thu, 5 Apr 2018 17:26:04 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1A2F1874BF; Thu, 5 Apr 2018 17:26:04 +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 1455D25A89; Thu, 5 Apr 2018 17:26:04 +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 w35HQ3X6034992; Thu, 5 Apr 2018 17:26:03 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35HQ3d3034991; Thu, 5 Apr 2018 17:26:03 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201804051726.w35HQ3d3034991@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 5 Apr 2018 17:26:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332079 - head/sys/compat/linuxkpi/common/include/asm X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/compat/linuxkpi/common/include/asm X-SVN-Commit-Revision: 332079 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 17:26:04 -0000 Author: markj Date: Thu Apr 5 17:26:03 2018 New Revision: 332079 URL: https://svnweb.freebsd.org/changeset/base/332079 Log: Fix the definitions of get_cpu() and put_cpu(). They are supposed to disable preemption. Reported by: rstone MFC after: 5 days Modified: head/sys/compat/linuxkpi/common/include/asm/smp.h Modified: head/sys/compat/linuxkpi/common/include/asm/smp.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/asm/smp.h Thu Apr 5 15:52:20 2018 (r332078) +++ head/sys/compat/linuxkpi/common/include/asm/smp.h Thu Apr 5 17:26:03 2018 (r332079) @@ -38,11 +38,11 @@ int linux_wbinvd_on_all_cpus(void); #endif #define get_cpu() ({ \ - sched_pin(); \ + critical_enter(); \ PCPU_GET(cpuid); \ }) #define put_cpu() \ - sched_unpin() + critical_exit() #endif /* _ASM_SMP_H_ */ From owner-svn-src-head@freebsd.org Thu Apr 5 17:31:33 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 59CE2F950C7; Thu, 5 Apr 2018 17:31:33 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail108.syd.optusnet.com.au (mail108.syd.optusnet.com.au [211.29.132.59]) by mx1.freebsd.org (Postfix) with ESMTP id 9C34287825; Thu, 5 Apr 2018 17:31:32 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id 55AD11A2B5E; Fri, 6 Apr 2018 03:12:08 +1000 (AEST) Date: Fri, 6 Apr 2018 03:12:08 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Warner Losh cc: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Ian Lepore , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r332072 - head/sys/sys In-Reply-To: Message-ID: <20180406022720.I3453@besplex.bde.org> References: <201804051431.w35EVtg4047897@repo.freebsd.org> <1522942377.49673.245.camel@freebsd.org> <20180405154619.q3blip266qa3z5ut@MacBook-Pro-de-Roger.local> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=VJytp5HX c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=nlC_4_pT8q9DhB4Ho9EA:9 a=6I5d2MoRAAAA:8 a=cmksfQnWNKoHR5D7ljQA:9 a=QqayTtpXsOdycEfu:21 a=1076iIFNQwPqjI9_:21 a=45ClL6m2LaAA:10 a=IjZwj45LgO3ly-622nXo:22 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 17:31:33 -0000 On Thu, 5 Apr 2018, Warner Losh wrote: > On Thu, Apr 5, 2018 at 9:46 AM, Roger Pau Monn=C3=A9 = wrote: > >> On Thu, Apr 05, 2018 at 09:32:57AM -0600, Ian Lepore wrote: >>> On Thu, 2018-04-05 at 14:31 +0000, Roger Pau Monn=C3=A9 wrote: >>>> Log: >>>> introduce GiB and MiB macros >>>> ... >>>> +/* Unit conversion macros. */ >>>> +#define GiB(v) (v ## ULL << 30) >>>> +#define MiB(v) (v ## ULL << 20) >>>> + >>>> #endif /* _SYS_PARAM_H_ */ >>> >>> These names don't make it clear whether the conversion is bytes->GiB or >>> GiB->bytes. The names seem way too generic for a public namespace in a >>> file as heavily included behind your back as param.h is. >>> >>> Also, this completely reasonable usage won't work, likely with >>> confusing compile error messages: >>> >>> int bytes, gibytes; >>> ... >>> bytes =3D GiB(gibytes); >> >> I find those helpful for their specific usage. I could introduce >> static inline functions like: >> >> size_t gb_to_bytes(size_t)... >> >> But I assume this is also going to cause further discussion. Yes, it gives even more namespace pollution and type errors. Macros at least don't expose their internals if they are not used. size_t is actually already part of the undocumented namespace pollution in . The type errors are restriction to just one type in another way. Type- generic APIs that avoid such restrictions are much harder to implement using inline functions than macros. > Yea, traditional macro names would be "gibtob" and "btogib" but I didn't > just reply to bikeshed a name: > > But you don't need to specify a type, consider the current btodb macro: > #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) > */ \ > (sizeof (bytes) > sizeof(long) \ > ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ > : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) > > which shows how to do this in a macro, which is orthogonal to any name yo= u > may choose. I can also bikeshed function vs macro :) This macro is mostly my mistake in 1995-1996. The long long abominations in it were supposed to be temporary (until C99 standardized something better). It was originally MD for i386 only and then the sizes of almost all types are known and fixed so it is easier to hard-code minimal sizes that work. The optimization of avoiding using 64-bit types was more needed in 1995-1996 since CPUs were slower and compilers did less strength reducti= on. btodb() is much easier than dbtob() since it shifts right, so it can't overflow unless the cast of 'bytes' is wrong so that it truncations. dbtob() doesn't try hard to be optimal. It just always upcasts to off_t. jake later convinced me (in connection with his PAE and sparc64 work) that it should be the caller's responsibility to avoid overflow. Any casts in the macro limits it to the types in it. This is why the page to byte conversion macros don't have any casts in them. PAE usually needs 64-bit results, but this would just be a pessimization for normal i386, and deciding the casts in the macro as above is complicated. So correct GB() macros would look like ((v) << 30), where the caller must cast v to a large enough type. E.g., for variable v which might be larger than 4, on 32-bit systems, the caller must write something like GB((uintmax_t)v). But it is easier for writing to just multiply v by 1G. This is also easier for reading since it is unclear that GB() is even a conversion or which direction it goes in. A longer descriptive name would be about as clear and long as an explicit multiplication. I usually write 1G as ((type)1024 * 1024 * 1024) since the decimal and even hex values of 1G have too many digits to be clear, and multiplication is clearer than shifting and allows the type to be in the factor. Disk block size conversions need to use macros since the DEV_BSIZE =3D 512 was variable in theory (in practice this is now a fixed virtual size). Conversions to G don't need macros since the magic number in them is no more magic than the G in their name. Bruce From owner-svn-src-head@freebsd.org Thu Apr 5 18:17:47 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7D343F97FF8; Thu, 5 Apr 2018 18:17:47 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E4B416961B; Thu, 5 Apr 2018 18:17:46 +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 DF24F262CC; Thu, 5 Apr 2018 18:17:46 +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 w35IHkin059733; Thu, 5 Apr 2018 18:17:46 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35IHkau059730; Thu, 5 Apr 2018 18:17:46 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804051817.w35IHkau059730@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Thu, 5 Apr 2018 18:17:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332080 - in head/lib/libc: aarch64/sys arm/sys mips/sys riscv/sys X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in head/lib/libc: aarch64/sys arm/sys mips/sys riscv/sys X-SVN-Commit-Revision: 332080 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 18:17:47 -0000 Author: brooks Date: Thu Apr 5 18:17:46 2018 New Revision: 332080 URL: https://svnweb.freebsd.org/changeset/base/332080 Log: Remove architecture specific shmat.S files. These files are identical to the generated system calls. In the case of MIPS, the file was already disconnected from the build. Submitted by: Ali Mashtizadeh Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D14976 Deleted: head/lib/libc/aarch64/sys/shmat.S head/lib/libc/arm/sys/shmat.S head/lib/libc/mips/sys/shmat.S head/lib/libc/riscv/sys/shmat.S Modified: head/lib/libc/aarch64/sys/Makefile.inc head/lib/libc/arm/sys/Makefile.inc head/lib/libc/riscv/sys/Makefile.inc Modified: head/lib/libc/aarch64/sys/Makefile.inc ============================================================================== --- head/lib/libc/aarch64/sys/Makefile.inc Thu Apr 5 17:26:03 2018 (r332079) +++ head/lib/libc/aarch64/sys/Makefile.inc Thu Apr 5 18:17:46 2018 (r332080) @@ -5,7 +5,6 @@ MIASM:= ${MIASM:Nfreebsd[467]_*} SRCS+= __vdso_gettc.c MDASM= cerror.S \ - shmat.S \ syscall.S \ vfork.S Modified: head/lib/libc/arm/sys/Makefile.inc ============================================================================== --- head/lib/libc/arm/sys/Makefile.inc Thu Apr 5 17:26:03 2018 (r332079) +++ head/lib/libc/arm/sys/Makefile.inc Thu Apr 5 18:17:46 2018 (r332080) @@ -2,7 +2,7 @@ SRCS+= __vdso_gettc.c -MDASM= Ovfork.S brk.S cerror.S sbrk.S shmat.S syscall.S +MDASM= Ovfork.S brk.S cerror.S sbrk.S syscall.S # Don't generate default code for these syscalls: NOASM+= vfork.o Modified: head/lib/libc/riscv/sys/Makefile.inc ============================================================================== --- head/lib/libc/riscv/sys/Makefile.inc Thu Apr 5 17:26:03 2018 (r332079) +++ head/lib/libc/riscv/sys/Makefile.inc Thu Apr 5 18:17:46 2018 (r332080) @@ -2,9 +2,7 @@ SRCS+= trivial-vdso_tc.c -#MDASM= ptrace.S MDASM= cerror.S \ - shmat.S \ syscall.S \ vfork.S From owner-svn-src-head@freebsd.org Thu Apr 5 18:19:48 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE68EF98287; Thu, 5 Apr 2018 18:19:48 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5C88869860; Thu, 5 Apr 2018 18:19:48 +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 53196262D3; Thu, 5 Apr 2018 18:19:48 +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 w35IJmwb059840; Thu, 5 Apr 2018 18:19:48 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35IJmf3059839; Thu, 5 Apr 2018 18:19:48 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804051819.w35IJmf3059839@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Thu, 5 Apr 2018 18:19:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332081 - head X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: head X-SVN-Commit-Revision: 332081 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 18:19:48 -0000 Author: brooks Date: Thu Apr 5 18:19:48 2018 New Revision: 332081 URL: https://svnweb.freebsd.org/changeset/base/332081 Log: Allow -DNO_CLEAN buildworld after r332080. Modified: head/Makefile.inc1 Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Thu Apr 5 18:17:46 2018 (r332080) +++ head/Makefile.inc1 Thu Apr 5 18:19:48 2018 (r332081) @@ -806,7 +806,8 @@ _cleanobj_fast_depend_hack: .PHONY # Date SVN Rev Syscalls # 20170624 r320278 fstat fstatat fstatfs getdirentries getfsstat statfs # 20180404 r332048 sigreturn -.for f in fstat fstatat fstatfs getdirentries getfsstat sigreturn statfs +# 20180405 r332080 shmat +.for f in fstat fstatat fstatfs getdirentries getfsstat shmat sigreturn statfs .if exists(${OBJTOP}/lib/libc/.depend.${f}.o) @if egrep -qw '${f}\.[sS]' \ ${OBJTOP}/lib/libc/.depend.${f}.o; then \ From owner-svn-src-head@freebsd.org Thu Apr 5 19:27:25 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 75F35F9C817; Thu, 5 Apr 2018 19:27:25 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 21EC56CA1E; Thu, 5 Apr 2018 19:27:25 +0000 (UTC) (envelope-from benno@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 EC59426E2D; Thu, 5 Apr 2018 19:27:24 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w35JROoe096310; Thu, 5 Apr 2018 19:27:24 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35JROAt096309; Thu, 5 Apr 2018 19:27:24 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804051927.w35JROAt096309@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Thu, 5 Apr 2018 19:27:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332082 - head/stand/i386/gptboot X-SVN-Group: head X-SVN-Commit-Author: benno X-SVN-Commit-Paths: head/stand/i386/gptboot X-SVN-Commit-Revision: 332082 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 19:27:25 -0000 Author: benno Date: Thu Apr 5 19:27:24 2018 New Revision: 332082 URL: https://svnweb.freebsd.org/changeset/base/332082 Log: Use consistent whitespace. Reviewed by: strip --strip-debug -o - gptboot.o | md5 Sponsored by: iXsystems, Inc. Modified: head/stand/i386/gptboot/gptboot.c Modified: head/stand/i386/gptboot/gptboot.c ============================================================================== --- head/stand/i386/gptboot/gptboot.c Thu Apr 5 18:19:48 2018 (r332081) +++ head/stand/i386/gptboot/gptboot.c Thu Apr 5 19:27:24 2018 (r332082) @@ -132,87 +132,93 @@ xfsread(ufs_ino_t inode, void *buf, size_t nbyte) static void bios_getmem(void) { - uint64_t size; + uint64_t size; - /* Parse system memory map */ - v86.ebx = 0; - do { - v86.ctl = V86_FLAGS; - v86.addr = MEM_EXT; /* int 0x15 function 0xe820*/ - v86.eax = 0xe820; - v86.ecx = sizeof(struct bios_smap); - v86.edx = SMAP_SIG; - v86.es = VTOPSEG(&smap); - v86.edi = VTOPOFF(&smap); - v86int(); - if ((v86.efl & 1) || (v86.eax != SMAP_SIG)) - break; - /* look for a low-memory segment that's large enough */ - if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0) && - (smap.length >= (512 * 1024))) - bios_basemem = smap.length; - /* look for the first segment in 'extended' memory */ - if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0x100000)) { - bios_extmem = smap.length; - } + /* Parse system memory map */ + v86.ebx = 0; + do { + v86.ctl = V86_FLAGS; + v86.addr = MEM_EXT; /* int 0x15 function 0xe820*/ + v86.eax = 0xe820; + v86.ecx = sizeof(struct bios_smap); + v86.edx = SMAP_SIG; + v86.es = VTOPSEG(&smap); + v86.edi = VTOPOFF(&smap); + v86int(); + if ((v86.efl & 1) || (v86.eax != SMAP_SIG)) + break; + /* look for a low-memory segment that's large enough */ + if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0) && + (smap.length >= (512 * 1024))) + bios_basemem = smap.length; + /* look for the first segment in 'extended' memory */ + if ((smap.type == SMAP_TYPE_MEMORY) && + (smap.base == 0x100000)) { + bios_extmem = smap.length; + } - /* - * Look for the largest segment in 'extended' memory beyond - * 1MB but below 4GB. - */ - if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base > 0x100000) && - (smap.base < 0x100000000ull)) { - size = smap.length; + /* + * Look for the largest segment in 'extended' memory beyond + * 1MB but below 4GB. + */ + if ((smap.type == SMAP_TYPE_MEMORY) && + (smap.base > 0x100000) && (smap.base < 0x100000000ull)) { + size = smap.length; - /* - * If this segment crosses the 4GB boundary, truncate it. - */ - if (smap.base + size > 0x100000000ull) - size = 0x100000000ull - smap.base; + /* + * If this segment crosses the 4GB boundary, + * truncate it. + */ + if (smap.base + size > 0x100000000ull) + size = 0x100000000ull - smap.base; - if (size > high_heap_size) { - high_heap_size = size; - high_heap_base = smap.base; - } - } - } while (v86.ebx != 0); + if (size > high_heap_size) { + high_heap_size = size; + high_heap_base = smap.base; + } + } + } while (v86.ebx != 0); - /* Fall back to the old compatibility function for base memory */ - if (bios_basemem == 0) { - v86.ctl = 0; - v86.addr = 0x12; /* int 0x12 */ - v86int(); + /* Fall back to the old compatibility function for base memory */ + if (bios_basemem == 0) { + v86.ctl = 0; + v86.addr = 0x12; /* int 0x12 */ + v86int(); - bios_basemem = (v86.eax & 0xffff) * 1024; - } + bios_basemem = (v86.eax & 0xffff) * 1024; + } - /* Fall back through several compatibility functions for extended memory */ - if (bios_extmem == 0) { - v86.ctl = V86_FLAGS; - v86.addr = 0x15; /* int 0x15 function 0xe801*/ - v86.eax = 0xe801; - v86int(); - if (!(v86.efl & 1)) { - bios_extmem = ((v86.ecx & 0xffff) + ((v86.edx & 0xffff) * 64)) * 1024; + /* + * Fall back through several compatibility functions for extended + * memory + */ + if (bios_extmem == 0) { + v86.ctl = V86_FLAGS; + v86.addr = 0x15; /* int 0x15 function 0xe801*/ + v86.eax = 0xe801; + v86int(); + if (!(v86.efl & 1)) { + bios_extmem = ((v86.ecx & 0xffff) + + ((v86.edx & 0xffff) * 64)) * 1024; + } } - } - if (bios_extmem == 0) { - v86.ctl = 0; - v86.addr = 0x15; /* int 0x15 function 0x88*/ - v86.eax = 0x8800; - v86int(); - bios_extmem = (v86.eax & 0xffff) * 1024; - } + if (bios_extmem == 0) { + v86.ctl = 0; + v86.addr = 0x15; /* int 0x15 function 0x88*/ + v86.eax = 0x8800; + v86int(); + bios_extmem = (v86.eax & 0xffff) * 1024; + } - /* - * If we have extended memory and did not find a suitable heap - * region in the SMAP, use the last 3MB of 'extended' memory as a - * high heap candidate. - */ - if (bios_extmem >= HEAP_MIN && high_heap_size < HEAP_MIN) { - high_heap_size = HEAP_MIN; - high_heap_base = bios_extmem + 0x100000 - HEAP_MIN; - } + /* + * If we have extended memory and did not find a suitable heap + * region in the SMAP, use the last 3MB of 'extended' memory as a + * high heap candidate. + */ + if (bios_extmem >= HEAP_MIN && high_heap_size < HEAP_MIN) { + high_heap_size = HEAP_MIN; + high_heap_base = bios_extmem + 0x100000 - HEAP_MIN; + } } static int @@ -371,207 +377,215 @@ exit(int x) static void load(void) { - union { - struct exec ex; - Elf32_Ehdr eh; - } hdr; - static Elf32_Phdr ep[2]; - static Elf32_Shdr es[2]; - caddr_t p; - ufs_ino_t ino; - uint32_t addr, x; - int fmt, i, j; + union { + struct exec ex; + Elf32_Ehdr eh; + } hdr; + static Elf32_Phdr ep[2]; + static Elf32_Shdr es[2]; + caddr_t p; + ufs_ino_t ino; + uint32_t addr, x; + int fmt, i, j; - if (!(ino = lookup(kname))) { - if (!ls) { - printf("%s: No %s on %u:%s(%up%u)\n", BOOTPROG, - kname, dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit, - dsk.part); - } - return; - } - if (xfsread(ino, &hdr, sizeof(hdr))) - return; - if (N_GETMAGIC(hdr.ex) == ZMAGIC) - fmt = 0; - else if (IS_ELF(hdr.eh)) - fmt = 1; - else { - printf("Invalid %s\n", "format"); - return; - } - if (fmt == 0) { - addr = hdr.ex.a_entry & 0xffffff; - p = PTOV(addr); - fs_off = PAGE_SIZE; - if (xfsread(ino, p, hdr.ex.a_text)) - return; - p += roundup2(hdr.ex.a_text, PAGE_SIZE); - if (xfsread(ino, p, hdr.ex.a_data)) - return; - p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE); - bootinfo.bi_symtab = VTOP(p); - memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms)); - p += sizeof(hdr.ex.a_syms); - if (hdr.ex.a_syms) { - if (xfsread(ino, p, hdr.ex.a_syms)) + if (!(ino = lookup(kname))) { + if (!ls) { + printf("%s: No %s on %u:%s(%up%u)\n", BOOTPROG, + kname, dsk.drive & DRV_MASK, dev_nm[dsk.type], + dsk.unit, + dsk.part); + } return; - p += hdr.ex.a_syms; - if (xfsread(ino, p, sizeof(int))) - return; - x = *(uint32_t *)p; - p += sizeof(int); - x -= sizeof(int); - if (xfsread(ino, p, x)) - return; - p += x; } - } else { - fs_off = hdr.eh.e_phoff; - for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) { - if (xfsread(ino, ep + j, sizeof(ep[0]))) + if (xfsread(ino, &hdr, sizeof(hdr))) return; - if (ep[j].p_type == PT_LOAD) - j++; - } - for (i = 0; i < 2; i++) { - p = PTOV(ep[i].p_paddr & 0xffffff); - fs_off = ep[i].p_offset; - if (xfsread(ino, p, ep[i].p_filesz)) + if (N_GETMAGIC(hdr.ex) == ZMAGIC) + fmt = 0; + else if (IS_ELF(hdr.eh)) + fmt = 1; + else { + printf("Invalid %s\n", "format"); return; } - p += roundup2(ep[1].p_memsz, PAGE_SIZE); - bootinfo.bi_symtab = VTOP(p); - if (hdr.eh.e_shnum == hdr.eh.e_shstrndx + 3) { - fs_off = hdr.eh.e_shoff + sizeof(es[0]) * - (hdr.eh.e_shstrndx + 1); - if (xfsread(ino, &es, sizeof(es))) - return; - for (i = 0; i < 2; i++) { - memcpy(p, &es[i].sh_size, sizeof(es[i].sh_size)); - p += sizeof(es[i].sh_size); - fs_off = es[i].sh_offset; - if (xfsread(ino, p, es[i].sh_size)) - return; - p += es[i].sh_size; - } + if (fmt == 0) { + addr = hdr.ex.a_entry & 0xffffff; + p = PTOV(addr); + fs_off = PAGE_SIZE; + if (xfsread(ino, p, hdr.ex.a_text)) + return; + p += roundup2(hdr.ex.a_text, PAGE_SIZE); + if (xfsread(ino, p, hdr.ex.a_data)) + return; + p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE); + bootinfo.bi_symtab = VTOP(p); + memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms)); + p += sizeof(hdr.ex.a_syms); + if (hdr.ex.a_syms) { + if (xfsread(ino, p, hdr.ex.a_syms)) + return; + p += hdr.ex.a_syms; + if (xfsread(ino, p, sizeof(int))) + return; + x = *(uint32_t *)p; + p += sizeof(int); + x -= sizeof(int); + if (xfsread(ino, p, x)) + return; + p += x; + } + } else { + fs_off = hdr.eh.e_phoff; + for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) { + if (xfsread(ino, ep + j, sizeof(ep[0]))) + return; + if (ep[j].p_type == PT_LOAD) + j++; + } + for (i = 0; i < 2; i++) { + p = PTOV(ep[i].p_paddr & 0xffffff); + fs_off = ep[i].p_offset; + if (xfsread(ino, p, ep[i].p_filesz)) + return; + } + p += roundup2(ep[1].p_memsz, PAGE_SIZE); + bootinfo.bi_symtab = VTOP(p); + if (hdr.eh.e_shnum == hdr.eh.e_shstrndx + 3) { + fs_off = hdr.eh.e_shoff + sizeof(es[0]) * + (hdr.eh.e_shstrndx + 1); + if (xfsread(ino, &es, sizeof(es))) + return; + for (i = 0; i < 2; i++) { + memcpy(p, &es[i].sh_size, + sizeof(es[i].sh_size)); + p += sizeof(es[i].sh_size); + fs_off = es[i].sh_offset; + if (xfsread(ino, p, es[i].sh_size)) + return; + p += es[i].sh_size; + } + } + addr = hdr.eh.e_entry & 0xffffff; } - addr = hdr.eh.e_entry & 0xffffff; - } - bootinfo.bi_esymtab = VTOP(p); - bootinfo.bi_kernelname = VTOP(kname); - bootinfo.bi_bios_dev = dsk.drive; + bootinfo.bi_esymtab = VTOP(p); + bootinfo.bi_kernelname = VTOP(kname); + bootinfo.bi_bios_dev = dsk.drive; #ifdef LOADER_GELI_SUPPORT - geliargs.size = sizeof(geliargs); - explicit_bzero(gelipw, sizeof(gelipw)); - gelibuf = malloc(sizeof(struct keybuf) + (GELI_MAX_KEYS * sizeof(struct keybuf_ent))); - geli_fill_keybuf(gelibuf); - geliargs.notapw = '\0'; - geliargs.keybuf_sentinel = KEYBUF_SENTINEL; - geliargs.keybuf = gelibuf; + geliargs.size = sizeof(geliargs); + explicit_bzero(gelipw, sizeof(gelipw)); + gelibuf = malloc(sizeof(struct keybuf) + + (GELI_MAX_KEYS * sizeof(struct keybuf_ent))); + geli_fill_keybuf(gelibuf); + geliargs.notapw = '\0'; + geliargs.keybuf_sentinel = KEYBUF_SENTINEL; + geliargs.keybuf = gelibuf; #endif - __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK), - MAKEBOOTDEV(dev_maj[dsk.type], dsk.part + 1, dsk.unit, 0xff), - KARGS_FLAGS_EXTARG, 0, 0, VTOP(&bootinfo) + __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK), + MAKEBOOTDEV(dev_maj[dsk.type], dsk.part + 1, dsk.unit, 0xff), + KARGS_FLAGS_EXTARG, 0, 0, VTOP(&bootinfo) #ifdef LOADER_GELI_SUPPORT - , geliargs + , geliargs #endif - ); + ); } static int parse_cmds(char *cmdstr, int *dskupdated) { - char *arg = cmdstr; - char *ep, *p, *q; - const char *cp; - unsigned int drv; - int c, i, j; + char *arg = cmdstr; + char *ep, *p, *q; + const char *cp; + unsigned int drv; + int c, i, j; - *dskupdated = 0; - while ((c = *arg++)) { - if (c == ' ' || c == '\t' || c == '\n') - continue; - for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++); - ep = p; - if (*p) - *p++ = 0; - if (c == '-') { - while ((c = *arg++)) { - if (c == 'P') { - if (*(uint8_t *)PTOV(0x496) & 0x10) { - cp = "yes"; - } else { - opts |= OPT_SET(RBX_DUAL) | OPT_SET(RBX_SERIAL); - cp = "no"; - } - printf("Keyboard: %s\n", cp); - continue; - } else if (c == 'S') { - j = 0; - while ((unsigned int)(i = *arg++ - '0') <= 9) - j = j * 10 + i; - if (j > 0 && i == -'0') { - comspeed = j; - break; - } - /* Fall through to error below ('S' not in optstr[]). */ + *dskupdated = 0; + while ((c = *arg++)) { + if (c == ' ' || c == '\t' || c == '\n') + continue; + for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++); + ep = p; + if (*p) + *p++ = 0; + if (c == '-') { + while ((c = *arg++)) { + if (c == 'P') { + if (*(uint8_t *)PTOV(0x496) & 0x10) { + cp = "yes"; + } else { + opts |= OPT_SET(RBX_DUAL) | + OPT_SET(RBX_SERIAL); + cp = "no"; + } + printf("Keyboard: %s\n", cp); + continue; + } else if (c == 'S') { + j = 0; + while ((unsigned int)(i = *arg++ - '0') + <= 9) + j = j * 10 + i; + if (j > 0 && i == -'0') { + comspeed = j; + break; + } + /* + * Fall through to error below + * ('S' not in optstr[]). + */ + } + for (i = 0; c != optstr[i]; i++) + if (i == NOPT - 1) + return -1; + opts ^= OPT_SET(flags[i]); + } + ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : + OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; + if (ioctrl & IO_SERIAL) { + if (sio_init(115200 / comspeed) != 0) + ioctrl &= ~IO_SERIAL; + } + } else { + for (q = arg--; *q && *q != '('; q++); + if (*q) { + drv = -1; + if (arg[1] == ':') { + drv = *arg - '0'; + if (drv > 9) + return (-1); + arg += 2; + } + if (q - arg != 2) + return -1; + for (i = 0; arg[0] != dev_nm[i][0] || + arg[1] != dev_nm[i][1]; i++) + if (i == NDEV - 1) + return -1; + dsk.type = i; + arg += 3; + dsk.unit = *arg - '0'; + if (arg[1] != 'p' || dsk.unit > 9) + return -1; + arg += 2; + dsk.part = *arg - '0'; + if (dsk.part < 1 || dsk.part > 9) + return -1; + arg++; + if (arg[0] != ')') + return -1; + arg++; + if (drv == -1) + drv = dsk.unit; + dsk.drive = (dsk.type <= TYPE_MAXHARD + ? DRV_HARD : 0) + drv; + *dskupdated = 1; + } + if ((i = ep - arg)) { + if ((size_t)i >= sizeof(kname)) + return -1; + memcpy(kname, arg, i + 1); + } } - for (i = 0; c != optstr[i]; i++) - if (i == NOPT - 1) - return -1; - opts ^= OPT_SET(flags[i]); - } - ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : - OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; - if (ioctrl & IO_SERIAL) { - if (sio_init(115200 / comspeed) != 0) - ioctrl &= ~IO_SERIAL; - } - } else { - for (q = arg--; *q && *q != '('; q++); - if (*q) { - drv = -1; - if (arg[1] == ':') { - drv = *arg - '0'; - if (drv > 9) - return (-1); - arg += 2; - } - if (q - arg != 2) - return -1; - for (i = 0; arg[0] != dev_nm[i][0] || - arg[1] != dev_nm[i][1]; i++) - if (i == NDEV - 1) - return -1; - dsk.type = i; - arg += 3; - dsk.unit = *arg - '0'; - if (arg[1] != 'p' || dsk.unit > 9) - return -1; - arg += 2; - dsk.part = *arg - '0'; - if (dsk.part < 1 || dsk.part > 9) - return -1; - arg++; - if (arg[0] != ')') - return -1; - arg++; - if (drv == -1) - drv = dsk.unit; - dsk.drive = (dsk.type <= TYPE_MAXHARD - ? DRV_HARD : 0) + drv; - *dskupdated = 1; - } - if ((i = ep - arg)) { - if ((size_t)i >= sizeof(kname)) - return -1; - memcpy(kname, arg, i + 1); - } + arg = p; } - arg = p; - } - return 0; + return 0; } static int From owner-svn-src-head@freebsd.org Thu Apr 5 19:29:23 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B2BFFF9CA25; Thu, 5 Apr 2018 19:29:23 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 615256CBEF; Thu, 5 Apr 2018 19:29:23 +0000 (UTC) (envelope-from benno@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 5C25426E30; Thu, 5 Apr 2018 19:29:23 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w35JTNqr096423; Thu, 5 Apr 2018 19:29:23 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35JTNOH096422; Thu, 5 Apr 2018 19:29:23 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804051929.w35JTNOH096422@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Thu, 5 Apr 2018 19:29:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332083 - head/stand/i386/gptboot X-SVN-Group: head X-SVN-Commit-Author: benno X-SVN-Commit-Paths: head/stand/i386/gptboot X-SVN-Commit-Revision: 332083 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 19:29:24 -0000 Author: benno Date: Thu Apr 5 19:29:22 2018 New Revision: 332083 URL: https://svnweb.freebsd.org/changeset/base/332083 Log: Various style(9) fixes. Reviewed by: strip --strip-debug -o - gptboot.o | md5 Sponsored by: iXsystems, Inc. Modified: head/stand/i386/gptboot/gptboot.c Modified: head/stand/i386/gptboot/gptboot.c ============================================================================== --- head/stand/i386/gptboot/gptboot.c Thu Apr 5 19:27:24 2018 (r332082) +++ head/stand/i386/gptboot/gptboot.c Thu Apr 5 19:29:22 2018 (r332083) @@ -370,6 +370,7 @@ main(void) void exit(int x) { + while (1); __unreachable(); } @@ -491,12 +492,13 @@ load(void) static int parse_cmds(char *cmdstr, int *dskupdated) { - char *arg = cmdstr; + char *arg; char *ep, *p, *q; const char *cp; unsigned int drv; int c, i, j; + arg = cmdstr; *dskupdated = 0; while ((c = *arg++)) { if (c == ' ' || c == '\t' || c == '\n') @@ -533,7 +535,7 @@ parse_cmds(char *cmdstr, int *dskupdated) } for (i = 0; c != optstr[i]; i++) if (i == NOPT - 1) - return -1; + return (-1); opts ^= OPT_SET(flags[i]); } ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : @@ -553,23 +555,23 @@ parse_cmds(char *cmdstr, int *dskupdated) arg += 2; } if (q - arg != 2) - return -1; + return (-1); for (i = 0; arg[0] != dev_nm[i][0] || arg[1] != dev_nm[i][1]; i++) if (i == NDEV - 1) - return -1; + return (-1); dsk.type = i; arg += 3; dsk.unit = *arg - '0'; if (arg[1] != 'p' || dsk.unit > 9) - return -1; + return (-1); arg += 2; dsk.part = *arg - '0'; if (dsk.part < 1 || dsk.part > 9) - return -1; + return (-1); arg++; if (arg[0] != ')') - return -1; + return (-1); arg++; if (drv == -1) drv = dsk.unit; @@ -579,13 +581,13 @@ parse_cmds(char *cmdstr, int *dskupdated) } if ((i = ep - arg)) { if ((size_t)i >= sizeof(kname)) - return -1; + return (-1); memcpy(kname, arg, i + 1); } } arg = p; } - return 0; + return (0); } static int @@ -617,7 +619,9 @@ vdev_read(void *vdev __unused, void *priv, off_t off, char *p; daddr_t lba; unsigned int nb; - struct dsk *dskp = (struct dsk *) priv; + struct dsk *dskp; + + dskp = (struct dsk *)priv; if ((off & (DEV_BSIZE - 1)) || (bytes & (DEV_BSIZE - 1))) return (-1); From owner-svn-src-head@freebsd.org Thu Apr 5 19:40:47 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 975E5F9D3A3; Thu, 5 Apr 2018 19:40:47 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 442806D46A; Thu, 5 Apr 2018 19:40:47 +0000 (UTC) (envelope-from benno@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 3ED6326FE5; Thu, 5 Apr 2018 19:40:47 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w35Jelck001771; Thu, 5 Apr 2018 19:40:47 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35JekjT001765; Thu, 5 Apr 2018 19:40:46 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804051940.w35JekjT001765@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Thu, 5 Apr 2018 19:40:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332084 - in head: stand/i386 stand/i386/isoboot stand/libsa sys/fs/cd9660 X-SVN-Group: head X-SVN-Commit-Author: benno X-SVN-Commit-Paths: in head: stand/i386 stand/i386/isoboot stand/libsa sys/fs/cd9660 X-SVN-Commit-Revision: 332084 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 19:40:47 -0000 Author: benno Date: Thu Apr 5 19:40:46 2018 New Revision: 332084 URL: https://svnweb.freebsd.org/changeset/base/332084 Log: Add isoboot(8) for booting BIOS systems from HDDs containing ISO images. This is part of a project for adding the ability to create hybrid CD/USB boot images. In the BIOS case when booting from something that isn't a CD we need some extra boot code to actually find our next stage (loader) within an ISO9660 filesystem. This code will reside in a GPT partition (similar to gptboot(8) from which it is derived) and looks for /boot/loader in an ISO9660 filesystem on the image. Reviewed by: imp Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D14914 Added: head/stand/i386/isoboot/ head/stand/i386/isoboot/Makefile - copied, changed from r332081, head/stand/i386/gptboot/Makefile head/stand/i386/isoboot/isoboot.8 (contents, props changed) head/stand/i386/isoboot/isoboot.c - copied, changed from r332083, head/stand/i386/gptboot/gptboot.c head/stand/libsa/cd9660read.c (contents, props changed) Modified: head/stand/i386/Makefile head/sys/fs/cd9660/iso.h Modified: head/stand/i386/Makefile ============================================================================== --- head/stand/i386/Makefile Thu Apr 5 19:29:22 2018 (r332083) +++ head/stand/i386/Makefile Thu Apr 5 19:40:46 2018 (r332084) @@ -5,7 +5,7 @@ NO_OBJ=t .include SUBDIR.yes= mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot \ - libi386 + isoboot libi386 SUBDIR.${MK_LOADER_FIREWIRE}+= libfirewire Copied and modified: head/stand/i386/isoboot/Makefile (from r332081, head/stand/i386/gptboot/Makefile) ============================================================================== --- head/stand/i386/gptboot/Makefile Thu Apr 5 18:19:48 2018 (r332081, copy source) +++ head/stand/i386/isoboot/Makefile Thu Apr 5 19:40:46 2018 (r332084) @@ -4,10 +4,11 @@ HAVE_GELI= yes .include -.PATH: ${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/common ${SASRC} +.PATH: ${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/gptboot \ + ${BOOTSRC}/i386/common ${SASRC} -FILES= gptboot -MAN= gptboot.8 +FILES= isoboot +MAN= isoboot.8 NM?= nm @@ -19,15 +20,10 @@ REL1= 0x700 ORG1= 0x7c00 ORG2= 0x0 -# Decide level of UFS support. -GPTBOOT_UFS?= UFS1_AND_UFS2 -#GPTBOOT_UFS?= UFS2_ONLY -#GPTBOOT_UFS?= UFS1_ONLY +ISOBOOTSIZE?= 30720 -CFLAGS+=-DBOOTPROG=\"gptboot\" \ +CFLAGS+=-DBOOTPROG=\"isoboot\" \ -O1 \ - -DGPT \ - -D${GPTBOOT_UFS} \ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ -DSIOFMT=${B2SIOFMT} \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ @@ -40,14 +36,17 @@ CFLAGS+=-DBOOTPROG=\"gptboot\" \ -Winline -Wno-pointer-sign CFLAGS.gcc+= --param max-inline-insns-single=100 +CFLAGS.clang+= -Oz ${CLANG_OPT_SMALL} LD_FLAGS+=${LD_FLAGS_BIN} -CLEANFILES+= gptboot +CLEANFILES+= isoboot -gptboot: gptldr.bin gptboot.bin ${BTXKERN} +isoboot: gptldr.bin isoboot.bin ${BTXKERN} btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l gptldr.bin \ - -o ${.TARGET} gptboot.bin + -o ${.TARGET} isoboot.bin + @set -- `ls -l ${.TARGET}`; x=$$((${ISOBOOTSIZE}-$$5)); \ + echo "$$x bytes available"; test $$x -ge 0 CLEANFILES+= gptldr.bin gptldr.out gptldr.o @@ -57,16 +56,13 @@ gptldr.bin: gptldr.out gptldr.out: gptldr.o ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o -CLEANFILES+= gptboot.bin gptboot.out gptboot.o sio.o crc32.o drv.o \ +CLEANFILES+= isoboot.bin isoboot.out isoboot.o sio.o crc32.o drv.o \ cons.o ${OPENCRYPTO_XTS} -gptboot.bin: gptboot.out - ${OBJCOPY} -S -O binary gptboot.out ${.TARGET} +isoboot.bin: isoboot.out + ${OBJCOPY} -S -O binary isoboot.out ${.TARGET} -gptboot.out: ${BTXCRT} gptboot.o sio.o crc32.o drv.o cons.o ${OPENCRYPTO_XTS} +isoboot.out: ${BTXCRT} isoboot.o sio.o crc32.o drv.o cons.o ${OPENCRYPTO_XTS} ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBGELIBOOT} ${LIBSA32} .include - -# XXX: clang integrated-as doesn't grok .codeNN directives yet -CFLAGS.gptldr.S= ${CLANG_NO_IAS} Added: head/stand/i386/isoboot/isoboot.8 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/stand/i386/isoboot/isoboot.8 Thu Apr 5 19:40:46 2018 (r332084) @@ -0,0 +1,69 @@ +.\" Copyright (c) 2018 iXsystems, Inc. +.\" 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 AUTHORS 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 AUTHORS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd March 30, 2018 +.Dt ISOBOOT 8 +.Os +.Sh NAME +.Nm isoboot +.Nd Boot code for hybrid ISO/USB images on BIOS-based computers +.Sh DESCRIPTION +.Nm +is used on BIOS-based computers to boot from an ISO image that has +been written to a USB flash drive or other HDD-like device. +.Nm +is installed in a +.Cm freebsd-boot +partition with +.Xr mkimg 1 . +.Sh IMPLEMENTATION NOTES +The El Torito standard for bootable CDs provides a 32KB "System Area" +at the beginning of an image. +To create an image that is able to be booted by the BIOS as either a +CD-ROM ("ISO") and as a more HDD-like image (e.g. on a USB flash drive) +it is necessary to have both a standard El Torito boot catalog +containing a HDD-style partition table and boot code. +.Nm +is intended to be placed in a GPT partition to allow the system to find +the standard +.Fx +.Xr loader 8 +in the ISO filesystem later in the image. +.Sh BOOTING +.Nm +looks for an ISO filesystem image on the device it was booted from and +seeks to read either the primary +.Fx +.Xr loader 8 +or kernel from there. +.Sh SEE ALSO +.Xr mkimg 1 +.Sh HISTORY +.Nm +appeared in FreeBSD 12.0. +.Sh AUTHORS +This manual page written by +.An Benno Rice Aq benno@FreeBSD.org . Copied and modified: head/stand/i386/isoboot/isoboot.c (from r332083, head/stand/i386/gptboot/gptboot.c) ============================================================================== --- head/stand/i386/gptboot/gptboot.c Thu Apr 5 19:29:22 2018 (r332083, copy source) +++ head/stand/i386/isoboot/isoboot.c Thu Apr 5 19:40:46 2018 (r332084) @@ -58,7 +58,6 @@ __FBSDID("$FreeBSD$"); extern uint32_t _end; -static const uuid_t freebsd_ufs_uuid = GPT_ENT_TYPE_FREEBSD_UFS; static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */ static const unsigned char flags[NOPT] = { RBX_DUAL, @@ -85,9 +84,6 @@ static struct dsk dsk; static char kname[1024]; static int comspeed = SIOSPD; static struct bootinfo bootinfo; -#ifdef LOADER_GELI_SUPPORT -static struct geli_boot_args geliargs; -#endif static vm_offset_t high_heap_base; static uint32_t bios_basemem, bios_extmem, high_heap_size; @@ -102,27 +98,21 @@ static struct bios_smap smap; static char *heap_next; static char *heap_end; +int main(void); + static void load(void); static int parse_cmds(char *, int *); -static int dskread(void *, daddr_t, unsigned); -#ifdef LOADER_GELI_SUPPORT -static int vdev_read(void *vdev __unused, void *priv, off_t off, void *buf, - size_t bytes); -#endif -#include "ufsread.c" -#include "gpt.c" -#ifdef LOADER_GELI_SUPPORT -#include "geliboot.c" -static char gelipw[GELI_PW_MAXLEN]; -static struct keybuf *gelibuf; -#endif +static uint8_t ls, dsk_meta; +static uint32_t fs_off; +#include "cd9660read.c" + static inline int -xfsread(ufs_ino_t inode, void *buf, size_t nbyte) +xfsread(uint64_t inode, void *buf, size_t nbyte) { - if ((size_t)fsread(inode, buf, nbyte) != nbyte) { + if ((size_t)cd9660_fsread(inode, buf, nbyte) != nbyte) { printf("Invalid %s\n", "format"); return (-1); } @@ -221,52 +211,22 @@ bios_getmem(void) } } -static int -gptinit(void) -{ - - if (gptread(&freebsd_ufs_uuid, &dsk, dmadat->secbuf) == -1) { - printf("%s: unable to load GPT\n", BOOTPROG); - return (-1); - } - if (gptfind(&freebsd_ufs_uuid, &dsk, dsk.part) == -1) { - printf("%s: no UFS partition was found\n", BOOTPROG); - return (-1); - } -#ifdef LOADER_GELI_SUPPORT - if (geli_taste(vdev_read, &dsk, (gpttable[curent].ent_lba_end - - gpttable[curent].ent_lba_start)) == 0) { - if (geli_havekey(&dsk) != 0 && geli_passphrase(gelipw, - dsk.unit, 'p', curent + 1, &dsk) != 0) { - printf("%s: unable to decrypt GELI key\n", BOOTPROG); - return (-1); - } - } -#endif - - dsk_meta = 0; - return (0); -} - -int main(void); - int main(void) { char cmd[512], cmdtmp[512]; ssize_t sz; int autoboot, dskupdated; - ufs_ino_t ino; + uint64_t ino; - dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base); - bios_getmem(); if (high_heap_size > 0) { heap_end = PTOV(high_heap_base + high_heap_size); heap_next = PTOV(high_heap_base); } else { - heap_next = (char *)dmadat + sizeof(*dmadat); + heap_next = (char *) + (roundup2(__base + (int32_t)&_end, 0x10000) - __base); heap_end = (char *)PTOV(bios_basemem); } setheap(heap_next, heap_end); @@ -285,30 +245,20 @@ main(void) bootinfo.bi_memsizes_valid++; bootinfo.bi_bios_dev = dsk.drive; -#ifdef LOADER_GELI_SUPPORT - geli_init(); -#endif - /* Process configuration file */ - - if (gptinit() != 0) - return (-1); - autoboot = 1; *cmd = '\0'; for (;;) { *kname = '\0'; - if ((ino = lookup(PATH_CONFIG)) || - (ino = lookup(PATH_DOTCONFIG))) { - sz = fsread(ino, cmd, sizeof(cmd) - 1); + if ((ino = cd9660_lookup(PATH_CONFIG)) || + (ino = cd9660_lookup(PATH_DOTCONFIG))) { + sz = cd9660_fsread(ino, cmd, sizeof(cmd) - 1); cmd[(sz < 0) ? 0 : sz] = '\0'; } if (*cmd != '\0') { memcpy(cmdtmp, cmd, sizeof(cmdtmp)); if (parse_cmds(cmdtmp, &dskupdated)) break; - if (dskupdated && gptinit() != 0) - break; if (!OPT_CHECK(RBX_QUIET)) printf("%s: %s", PATH_CONFIG, cmd); *cmd = '\0'; @@ -332,9 +282,6 @@ main(void) load(); memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL)); load(); - gptbootfailed(&dsk); - if (gptfind(&freebsd_ufs_uuid, &dsk, -1) == -1) - break; dsk_meta = 0; } @@ -359,14 +306,12 @@ main(void) putchar('\a'); continue; } - if (dskupdated && gptinit() != 0) - continue; load(); } /* NOTREACHED */ } -/* XXX - Needed for btxld to link the boot2 binary; do not remove. */ +/* Needed so btxld can link us properly; do not remove. */ void exit(int x) { @@ -385,11 +330,11 @@ load(void) static Elf32_Phdr ep[2]; static Elf32_Shdr es[2]; caddr_t p; - ufs_ino_t ino; + uint64_t ino; uint32_t addr, x; int fmt, i, j; - if (!(ino = lookup(kname))) { + if (!(ino = cd9660_lookup(kname))) { if (!ls) { printf("%s: No %s on %u:%s(%up%u)\n", BOOTPROG, kname, dsk.drive & DRV_MASK, dev_nm[dsk.type], @@ -470,23 +415,9 @@ load(void) bootinfo.bi_esymtab = VTOP(p); bootinfo.bi_kernelname = VTOP(kname); bootinfo.bi_bios_dev = dsk.drive; -#ifdef LOADER_GELI_SUPPORT - geliargs.size = sizeof(geliargs); - explicit_bzero(gelipw, sizeof(gelipw)); - gelibuf = malloc(sizeof(struct keybuf) + - (GELI_MAX_KEYS * sizeof(struct keybuf_ent))); - geli_fill_keybuf(gelibuf); - geliargs.notapw = '\0'; - geliargs.keybuf_sentinel = KEYBUF_SENTINEL; - geliargs.keybuf = gelibuf; -#endif __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK), - MAKEBOOTDEV(dev_maj[dsk.type], dsk.part + 1, dsk.unit, 0xff), - KARGS_FLAGS_EXTARG, 0, 0, VTOP(&bootinfo) -#ifdef LOADER_GELI_SUPPORT - , geliargs -#endif - ); + MAKEBOOTDEV(dev_maj[dsk.type], 0, dsk.unit, 0), + KARGS_FLAGS_EXTARG, 0, 0, VTOP(&bootinfo)); } static int @@ -589,59 +520,3 @@ parse_cmds(char *cmdstr, int *dskupdated) } return (0); } - -static int -dskread(void *buf, daddr_t lba, unsigned nblk) -{ - int err; - - err = drvread(&dsk, buf, lba + dsk.start, nblk); - -#ifdef LOADER_GELI_SUPPORT - if (err == 0 && is_geli(&dsk) == 0) { - /* Decrypt */ - if (geli_read(&dsk, lba * DEV_BSIZE, buf, nblk * DEV_BSIZE)) - return (err); - } -#endif - - return (err); -} - -#ifdef LOADER_GELI_SUPPORT -/* - * Read function compartible with the ZFS callback, required to keep the GELI - * Implementation the same for both UFS and ZFS - */ -static int -vdev_read(void *vdev __unused, void *priv, off_t off, void *buf, size_t bytes) -{ - char *p; - daddr_t lba; - unsigned int nb; - struct dsk *dskp; - - dskp = (struct dsk *)priv; - - if ((off & (DEV_BSIZE - 1)) || (bytes & (DEV_BSIZE - 1))) - return (-1); - - p = buf; - lba = off / DEV_BSIZE; - lba += dskp->start; - - while (bytes > 0) { - nb = bytes / DEV_BSIZE; - if (nb > VBLKSIZE / DEV_BSIZE) - nb = VBLKSIZE / DEV_BSIZE; - if (drvread(dskp, dmadat->blkbuf, lba, nb)) - return (-1); - memcpy(p, dmadat->blkbuf, nb * DEV_BSIZE); - p += nb * DEV_BSIZE; - lba += nb; - bytes -= nb * DEV_BSIZE; - } - - return (0); -} -#endif /* LOADER_GELI_SUPPORT */ Added: head/stand/libsa/cd9660read.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/stand/libsa/cd9660read.c Thu Apr 5 19:40:46 2018 (r332084) @@ -0,0 +1,364 @@ +/* + * Copyright (C) 1996 Wolfgang Solfrank. + * Copyright (C) 1996 TooLs GmbH. + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. + */ + +/* Originally derived from libsa/cd9660.c: */ +/* $NetBSD: cd9660.c,v 1.5 1997/06/26 19:11:33 drochner Exp $ */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +static uint64_t cd9660_lookup(const char *); +static ssize_t cd9660_fsread(uint64_t, void *, size_t); + +#define SUSP_CONTINUATION "CE" +#define SUSP_PRESENT "SP" +#define SUSP_STOP "ST" +#define SUSP_EXTREF "ER" +#define RRIP_NAME "NM" + +typedef struct { + ISO_SUSP_HEADER h; + u_char signature [ISODCL ( 5, 6)]; + u_char len_skp [ISODCL ( 7, 7)]; /* 711 */ +} ISO_SUSP_PRESENT; + +static int +read_iso_block(void *buffer, daddr_t blkno) +{ + + return (drvread(&dsk, buffer, blkno * 4, 4)); +} + +static ISO_SUSP_HEADER * +susp_lookup_record(const char *identifier, struct iso_directory_record *dp, + int lenskip) +{ + static char susp_buffer[ISO_DEFAULT_BLOCK_SIZE]; + ISO_SUSP_HEADER *sh; + ISO_RRIP_CONT *shc; + char *p, *end; + int error; + + p = dp->name + isonum_711(dp->name_len) + lenskip; + /* Names of even length have a padding byte after the name. */ + if ((isonum_711(dp->name_len) & 1) == 0) + p++; + end = (char *)dp + isonum_711(dp->length); + while (p + 3 < end) { + sh = (ISO_SUSP_HEADER *)p; + if (bcmp(sh->type, identifier, 2) == 0) + return (sh); + if (bcmp(sh->type, SUSP_STOP, 2) == 0) + return (NULL); + if (bcmp(sh->type, SUSP_CONTINUATION, 2) == 0) { + shc = (ISO_RRIP_CONT *)sh; + error = read_iso_block(susp_buffer, + isonum_733(shc->location)); + + /* Bail if it fails. */ + if (error != 0) + return (NULL); + p = susp_buffer + isonum_733(shc->offset); + end = p + isonum_733(shc->length); + } else { + /* Ignore this record and skip to the next. */ + p += isonum_711(sh->length); + + /* Avoid infinite loops with corrupted file systems */ + if (isonum_711(sh->length) == 0) + return (NULL); + } + } + return (NULL); +} + +static const char * +rrip_lookup_name(struct iso_directory_record *dp, int lenskip, size_t *len) +{ + ISO_RRIP_ALTNAME *p; + + if (len == NULL) + return (NULL); + + p = (ISO_RRIP_ALTNAME *)susp_lookup_record(RRIP_NAME, dp, lenskip); + if (p == NULL) + return (NULL); + switch (*p->flags) { + case ISO_SUSP_CFLAG_CURRENT: + *len = 1; + return ("."); + case ISO_SUSP_CFLAG_PARENT: + *len = 2; + return (".."); + case 0: + *len = isonum_711(p->h.length) - 5; + return ((char *)p + 5); + default: + /* + * We don't handle hostnames or continued names as they are + * too hard, so just bail and use the default name. + */ + return (NULL); + } +} + +static int +rrip_check(struct iso_directory_record *dp, int *lenskip) +{ + ISO_SUSP_PRESENT *sp; + ISO_RRIP_EXTREF *er; + char *p; + + /* First, see if we can find a SP field. */ + p = dp->name + isonum_711(dp->name_len); + if (p > (char *)dp + isonum_711(dp->length)) { + return (0); + } + sp = (ISO_SUSP_PRESENT *)p; + if (bcmp(sp->h.type, SUSP_PRESENT, 2) != 0) { + return (0); + } + if (isonum_711(sp->h.length) != sizeof(ISO_SUSP_PRESENT)) { + return (0); + } + if (sp->signature[0] != 0xbe || sp->signature[1] != 0xef) { + return (0); + } + *lenskip = isonum_711(sp->len_skp); + + /* + * Now look for an ER field. If RRIP is present, then there must + * be at least one of these. It would be more pedantic to walk + * through the list of fields looking for a Rock Ridge ER field. + */ + er = (ISO_RRIP_EXTREF *)susp_lookup_record(SUSP_EXTREF, dp, 0); + if (er == NULL) { + return (0); + } + return (1); +} + +static int +dirmatch(const char *path, struct iso_directory_record *dp, int use_rrip, + int lenskip) +{ + size_t len; + const char *cp = NULL, *name = NULL; + int i, icase; + + if (use_rrip) + cp = rrip_lookup_name(dp, lenskip, &len); + else + cp = NULL; + if (cp == NULL) { + len = isonum_711(dp->name_len); + cp = dp->name; + icase = 1; + } else + icase = 0; + name = cp; + for (i = len; --i >= 0; path++, cp++) { + if (!*path || *path == '/') + break; + if (*path == *cp) + continue; + if (!icase && toupper(*path) == *cp) + continue; + return 0; + } + if (*path && *path != '/') { + return 0; + } + /* + * Allow stripping of trailing dots and the version number. + * Note that this will find the first instead of the last version + * of a file. + */ + if (i >= 0 && (*cp == ';' || *cp == '.')) { + /* This is to prevent matching of numeric extensions */ + if (*cp == '.' && cp[1] != ';') { + return 0; + } + while (--i >= 0) + if (*++cp != ';' && (*cp < '0' || *cp > '9')) { + return 0; + } + } + return 1; +} + +static uint64_t +cd9660_lookup(const char *path) +{ + static char blkbuf[ISO_DEFAULT_BLOCK_SIZE]; + struct iso_primary_descriptor *vd; + struct iso_directory_record rec; + struct iso_directory_record *dp = NULL; + size_t dsize, off; + daddr_t bno, boff; + int rc, first, use_rrip, lenskip; + uint64_t cookie; + + for (bno = 16;; bno++) { + rc = read_iso_block(blkbuf, bno); + vd = (struct iso_primary_descriptor *)blkbuf; + + if (bcmp(vd->id, ISO_STANDARD_ID, sizeof vd->id) != 0) + return (0); + if (isonum_711(vd->type) == ISO_VD_END) + return (0); + if (isonum_711(vd->type) == ISO_VD_PRIMARY) + break; + } + + rec = *(struct iso_directory_record *) vd->root_directory_record; + if (*path == '/') path++; /* eat leading '/' */ + + first = 1; + use_rrip = 0; + while (*path) { + bno = isonum_733(rec.extent) + isonum_711(rec.ext_attr_length); + dsize = isonum_733(rec.size); + off = 0; + boff = 0; + + while (off < dsize) { + if ((off % ISO_DEFAULT_BLOCK_SIZE) == 0) { + rc = read_iso_block(blkbuf, bno + boff); + if (rc) { + return (0); + } + boff++; + dp = (struct iso_directory_record *) blkbuf; + } + if (isonum_711(dp->length) == 0) { + /* skip to next block, if any */ + off = boff * ISO_DEFAULT_BLOCK_SIZE; + continue; + } + + /* See if RRIP is in use. */ + if (first) + use_rrip = rrip_check(dp, &lenskip); + + if (dirmatch(path, dp, use_rrip, + first ? 0 : lenskip)) { + first = 0; + break; + } else + first = 0; + + dp = (struct iso_directory_record *) + ((char *) dp + isonum_711(dp->length)); + /* If the new block has zero length, it is padding. */ + if (isonum_711(dp->length) == 0) { + /* Skip to next block, if any. */ + off = boff * ISO_DEFAULT_BLOCK_SIZE; + continue; + } + off += isonum_711(dp->length); + } + if (off >= dsize) { + return (0); + } + + rec = *dp; + while (*path && *path != '/') /* look for next component */ + path++; + if (*path) path++; /* skip '/' */ + } + + if ((isonum_711(rec.flags) & 2) != 0) { + return (0); + } + + cookie = isonum_733(rec.extent) + isonum_711(rec.ext_attr_length); + cookie = (cookie << 32) | isonum_733(rec.size); + + return (cookie); +} + +static ssize_t +cd9660_fsread(uint64_t cookie, void *buf, size_t nbytes) +{ + static char blkbuf[ISO_DEFAULT_BLOCK_SIZE]; + static daddr_t curstart = 0, curblk = 0; + daddr_t blk, blk_off; + off_t byte_off; + size_t size, remaining, n; + char *s; + + size = cookie & 0xffffffff; + blk = (cookie >> 32) & 0xffffffff; + + /* Make sure we're looking at the right file. */ + if (((blk << 32) | size) != cookie) { + return (-1); + } + + if (blk != curstart) { + curstart = blk; + fs_off = 0; + } + + size -= fs_off; + if (size < nbytes) { + nbytes = size; + } + remaining = nbytes; + s = buf; + + while (remaining > 0) { + blk_off = fs_off >> ISO_DEFAULT_BLOCK_SHIFT; + byte_off = fs_off & (ISO_DEFAULT_BLOCK_SIZE - 1); + + if (curblk != curstart + blk_off) { + curblk = curstart + blk_off; + read_iso_block(blkbuf, curblk); + } + + if (remaining < ISO_DEFAULT_BLOCK_SIZE - byte_off) { + n = remaining; + } else { + n = ISO_DEFAULT_BLOCK_SIZE - byte_off; + } + memcpy(s, blkbuf + byte_off, n); + remaining -= n; + s += n; + + fs_off += n; + } + + return (nbytes); +} Modified: head/sys/fs/cd9660/iso.h ============================================================================== --- head/sys/fs/cd9660/iso.h Thu Apr 5 19:29:22 2018 (r332083) +++ head/sys/fs/cd9660/iso.h Thu Apr 5 19:40:46 2018 (r332084) @@ -95,7 +95,8 @@ struct iso_primary_descriptor { char application_data [ISODCL (884, 1395)]; char unused5 [ISODCL (1396, 2048)]; }; -#define ISO_DEFAULT_BLOCK_SIZE 2048 +#define ISO_DEFAULT_BLOCK_SHIFT 11 +#define ISO_DEFAULT_BLOCK_SIZE (1 << ISO_DEFAULT_BLOCK_SHIFT) /* * Used by Microsoft Joliet extension to ISO9660. Almost the same From owner-svn-src-head@freebsd.org Thu Apr 5 19:45:31 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C6839F9D904; Thu, 5 Apr 2018 19:45:31 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 73B6A6D9A4; Thu, 5 Apr 2018 19:45:31 +0000 (UTC) (envelope-from benno@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 6E85627198; Thu, 5 Apr 2018 19:45:31 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w35JjVN9006987; Thu, 5 Apr 2018 19:45:31 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35JjVDJ006984; Thu, 5 Apr 2018 19:45:31 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201804051945.w35JjVDJ006984@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Thu, 5 Apr 2018 19:45:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332085 - head/stand/common X-SVN-Group: head X-SVN-Commit-Author: benno X-SVN-Commit-Paths: head/stand/common X-SVN-Commit-Revision: 332085 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 19:45:32 -0000 Author: benno Date: Thu Apr 5 19:45:30 2018 New Revision: 332085 URL: https://svnweb.freebsd.org/changeset/base/332085 Log: Add an ISO9660 "partition table" type to loader. When booted via isoboot(8) loader will be handed a disk that simply contains an ISO9660 image. Currently this confuses it greatly. Teach it how to spot that it's in this situation and that ISO9660 has one "partition" covering the whole disk. Reviewed by: imp Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D14915 Modified: head/stand/common/disk.c head/stand/common/part.c head/stand/common/part.h Modified: head/stand/common/disk.c ============================================================================== --- head/stand/common/disk.c Thu Apr 5 19:40:46 2018 (r332084) +++ head/stand/common/disk.c Thu Apr 5 19:45:30 2018 (r332085) @@ -270,6 +270,9 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize dev->d_offset = part.start; od->entrysize = part.end - part.start + 1; } + } else if (ptable_gettype(od->table) == PTABLE_ISO9660) { + dev->d_offset = 0; + od->entrysize = mediasize; } else if (slice >= 0) { /* Try to get information about partition */ if (slice == 0) Modified: head/stand/common/part.c ============================================================================== --- head/stand/common/part.c Thu Apr 5 19:40:46 2018 (r332084) +++ head/stand/common/part.c Thu Apr 5 19:45:30 2018 (r332085) @@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -97,6 +99,7 @@ static struct parttypes { { PART_LINUX, "Linux" }, { PART_LINUX_SWAP, "Linux swap" }, { PART_DOS, "DOS/Windows" }, + { PART_ISO9660, "ISO9660" }, }; const char * @@ -603,6 +606,45 @@ out: } #endif /* LOADER_VTOC8_SUPPORT */ +#define cdb2devb(bno) ((bno) * ISO_DEFAULT_BLOCK_SIZE / table->sectorsize) + +static struct ptable * +ptable_iso9660read(struct ptable *table, void *dev, diskread_t dread) +{ + uint8_t *buf; + struct iso_primary_descriptor *vd; + struct pentry *entry; + + buf = malloc(table->sectorsize); + if (buf == NULL) + return (table); + + if (dread(dev, buf, 1, cdb2devb(16)) != 0) { + DEBUG("read failed"); + ptable_close(table); + table = NULL; + goto out; + } + vd = (struct iso_primary_descriptor *)buf; + if (bcmp(vd->id, ISO_STANDARD_ID, sizeof vd->id) != 0) + goto out; + + entry = malloc(sizeof(*entry)); + if (entry == NULL) + goto out; + entry->part.start = 0; + entry->part.end = table->sectors; + entry->part.type = PART_ISO9660; + entry->part.index = 0; + STAILQ_INSERT_TAIL(&table->entries, entry, entry); + + table->type = PTABLE_ISO9660; + +out: + free(buf); + return (table); +} + struct ptable * ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread) @@ -633,6 +675,11 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect table->sectorsize = sectorsize; table->type = PTABLE_NONE; STAILQ_INIT(&table->entries); + + if (ptable_iso9660read(table, dev, dread) != NULL) { + if (table->type == PTABLE_ISO9660) + goto out; + } #ifdef LOADER_VTOC8_SUPPORT if (be16dec(buf + offsetof(struct vtoc8, magic)) == VTOC_MAGIC) { Modified: head/stand/common/part.h ============================================================================== --- head/stand/common/part.h Thu Apr 5 19:40:46 2018 (r332084) +++ head/stand/common/part.h Thu Apr 5 19:45:30 2018 (r332085) @@ -36,7 +36,8 @@ enum ptable_type { PTABLE_BSD, PTABLE_MBR, PTABLE_GPT, - PTABLE_VTOC8 + PTABLE_VTOC8, + PTABLE_ISO9660 }; enum partition_type { @@ -52,6 +53,7 @@ enum partition_type { PART_LINUX, PART_LINUX_SWAP, PART_DOS, + PART_ISO9660 }; struct ptable_entry { From owner-svn-src-head@freebsd.org Thu Apr 5 20:31:46 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 08DE7FA0A79; Thu, 5 Apr 2018 20:31:45 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 76F256FCD5; Thu, 5 Apr 2018 20:31:45 +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 71A092789C; Thu, 5 Apr 2018 20:31:45 +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 w35KVjCF032633; Thu, 5 Apr 2018 20:31:45 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35KVjQE032631; Thu, 5 Apr 2018 20:31:45 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804052031.w35KVjQE032631@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Thu, 5 Apr 2018 20:31:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332086 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 332086 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 20:31:46 -0000 Author: brooks Date: Thu Apr 5 20:31:45 2018 New Revision: 332086 URL: https://svnweb.freebsd.org/changeset/base/332086 Log: Added SAL annotatations to system calls. Modify makesyscalls.sh to strip out SAL annotations. No functional change. This is based on work I started in CheriBSD and use to validate fat pointers at the syscall boundary. Tal Garfinkel reviewed the changes, added annotations to COMPAT* syscalls and is using them in a record and playback framework. One can envision other uses such as a WITNESS-like validator for copyin/out as speculated on in the review. As this time we are only annotating sys/kern/syscalls.master as that is sufficient for userspace work. If kernel use cases materialize, we can annotate other syscalls.master as needed. Submitted by: Tal Garfinkel Sponsored by: DARPA, AFRL (in part) Differential Revision: https://reviews.freebsd.org/D14285 Modified: head/sys/kern/makesyscalls.sh head/sys/kern/syscalls.master Modified: head/sys/kern/makesyscalls.sh ============================================================================== --- head/sys/kern/makesyscalls.sh Thu Apr 5 19:45:30 2018 (r332085) +++ head/sys/kern/makesyscalls.sh Thu Apr 5 20:31:45 2018 (r332086) @@ -400,6 +400,16 @@ sed -e ' } if (argtype[argc] == "") parserr($f, "argument definition") + + # The parser adds space around parens. + # Remove it from annotations. + gsub(/ \( /, "(", argtype[argc]); + gsub(/ \)/, ")", argtype[argc]); + + #remove annotations + gsub(/_In[^ ]*[_)] /, "", argtype[argc]); + gsub(/_Out[^ ]*[_)] /, "", argtype[argc]); + argname[argc]=$f; f += 2; # skip name, and any comma } Modified: head/sys/kern/syscalls.master ============================================================================== --- head/sys/kern/syscalls.master Thu Apr 5 19:45:30 2018 (r332085) +++ head/sys/kern/syscalls.master Thu Apr 5 20:31:45 2018 (r332086) @@ -43,7 +43,32 @@ ; function prototype in sys/sysproto.h. Does add a ; definition to syscall.h besides adding a sysent. ; NOTSTATIC syscall is loadable + +; annotations: +; SAL 2.0 annotations are used to specify how system calls treat +; arguments that are passed using pointers. There are three basic +; annotations. ; +; _In_ Object pointed to will be read and not modified. +; _Out_ Object pointed to will be written and not read. +; _Inout_ Object pointed to will be written and read. +; +; These annotations are used alone when the pointer refers to a single +; object i.e. scalar types, structs, and pointers, and not NULL. Adding +; the _opt_ suffix, e.g. _In_opt_, implies that the pointer may also +; refer to NULL. +; +; For pointers to arrays, additional suffixes are added: +; +; _In_z_, _Out_z_, _Inout_z_: +; for a NUL terminated array e.g. a string. +; _In_reads_z_(n),_Out_writes_z_(n), _Inout_updates_z_(n): +; for a NUL terminated array e.g. a string, of known length n bytes. +; _In_reads_(n),_Out_writes_(n),_Inout_updates_(n): +; for an array of n elements. +; _In_reads_bytes_(n), _Out_writes_bytes_(n), _Inout_updates_bytes(n): +; for a buffer of n-bytes. + ; Please copy any additions and changes to the following compatability tables: ; sys/compat/freebsd32/syscalls.master @@ -63,143 +88,181 @@ 1 AUE_EXIT STD { void sys_exit(int rval); } exit \ sys_exit_args void 2 AUE_FORK STD { int fork(void); } -3 AUE_READ STD { ssize_t read(int fd, void *buf, \ +3 AUE_READ STD { ssize_t read(int fd, \ + _Out_writes_bytes_(nbyte) void *buf, \ size_t nbyte); } -4 AUE_WRITE STD { ssize_t write(int fd, const void *buf, \ +4 AUE_WRITE STD { ssize_t write(int fd, \ + _In_reads_bytes_(nbyte) const void *buf, \ size_t nbyte); } -5 AUE_OPEN_RWTC STD { int open(char *path, int flags, int mode); } +5 AUE_OPEN_RWTC STD { int open( \ + _In_z_ char *path, \ + int flags, \ + int mode); } ; XXX should be { int open(const char *path, int flags, ...); } ; but we're not ready for `const' or varargs. ; XXX man page says `mode_t mode'. 6 AUE_CLOSE STD { int close(int fd); } -7 AUE_WAIT4 STD { int wait4(int pid, int *status, \ - int options, struct rusage *rusage); } -8 AUE_CREAT COMPAT { int creat(char *path, int mode); } -9 AUE_LINK STD { int link(char *path, char *link); } -10 AUE_UNLINK STD { int unlink(char *path); } +7 AUE_WAIT4 STD { int wait4(int pid, \ + _Out_opt_ int *status, \ + int options, \ + _Out_opt_ struct rusage *rusage); } +8 AUE_CREAT COMPAT { int creat(_In_z_ char *path, int mode); } +9 AUE_LINK STD { int link(_In_z_ char *path, \ + _In_z_ char *link); } +10 AUE_UNLINK STD { int unlink(_In_z_ char *path); } 11 AUE_NULL OBSOL execv -12 AUE_CHDIR STD { int chdir(char *path); } +12 AUE_CHDIR STD { int chdir(_In_z_ char *path); } 13 AUE_FCHDIR STD { int fchdir(int fd); } -14 AUE_MKNOD COMPAT11 { int mknod(char *path, int mode, int dev); } -15 AUE_CHMOD STD { int chmod(char *path, int mode); } -16 AUE_CHOWN STD { int chown(char *path, int uid, int gid); } -17 AUE_NULL STD { int obreak(char *nsize); } break \ +14 AUE_MKNOD COMPAT11 { int mknod(_In_z_ char *path, int mode, \ + int dev); } +15 AUE_CHMOD STD { int chmod(_In_z_ char *path, int mode); } +16 AUE_CHOWN STD { int chown(_In_z_ char *path, \ + int uid, int gid); } +17 AUE_NULL STD { int obreak(_In_ char *nsize); } break \ obreak_args int -18 AUE_GETFSSTAT COMPAT4 { int getfsstat(struct ostatfs *buf, \ +18 AUE_GETFSSTAT COMPAT4 { int getfsstat( \ + _Out_writes_bytes_opt_(bufsize) \ + struct ostatfs *buf, \ long bufsize, int mode); } 19 AUE_LSEEK COMPAT { long lseek(int fd, long offset, \ int whence); } 20 AUE_GETPID STD { pid_t getpid(void); } -21 AUE_MOUNT STD { int mount(char *type, char *path, \ - int flags, caddr_t data); } +21 AUE_MOUNT STD { int mount(_In_z_ char *type, \ + _In_z_ char *path, int flags, \ + _In_opt_ caddr_t data); } ; XXX `path' should have type `const char *' but we're not ready for that. -22 AUE_UMOUNT STD { int unmount(char *path, int flags); } +22 AUE_UMOUNT STD { int unmount(_In_z_ char *path, int flags); } 23 AUE_SETUID STD { int setuid(uid_t uid); } 24 AUE_GETUID STD { uid_t getuid(void); } 25 AUE_GETEUID STD { uid_t geteuid(void); } 26 AUE_PTRACE STD { int ptrace(int req, pid_t pid, \ - caddr_t addr, int data); } -27 AUE_RECVMSG STD { int recvmsg(int s, struct msghdr *msg, \ + _Inout_opt_ caddr_t addr, int data); } +27 AUE_RECVMSG STD { int recvmsg(int s, \ + _Inout_ struct msghdr *msg, int flags); } +28 AUE_SENDMSG STD { int sendmsg(int s, _In_ struct msghdr *msg, \ int flags); } -28 AUE_SENDMSG STD { int sendmsg(int s, struct msghdr *msg, \ - int flags); } -29 AUE_RECVFROM STD { int recvfrom(int s, caddr_t buf, \ +29 AUE_RECVFROM STD { int recvfrom(int s, \ + _Out_writes_bytes_(len) caddr_t buf, \ size_t len, int flags, \ + _Out_writes_bytes_opt_(*fromlenaddr) \ struct sockaddr * __restrict from, \ + _Inout_opt_ \ __socklen_t * __restrict fromlenaddr); } 30 AUE_ACCEPT STD { int accept(int s, \ + _Out_writes_bytes_opt_(*anamelen) \ struct sockaddr * __restrict name, \ + _Inout_opt_ \ __socklen_t * __restrict anamelen); } 31 AUE_GETPEERNAME STD { int getpeername(int fdes, \ + _Out_writes_bytes_(*alen) \ struct sockaddr * __restrict asa, \ + _Inout_opt_ \ __socklen_t * __restrict alen); } 32 AUE_GETSOCKNAME STD { int getsockname(int fdes, \ + _Out_writes_bytes_(*alen) \ struct sockaddr * __restrict asa, \ - __socklen_t * __restrict alen); } -33 AUE_ACCESS STD { int access(char *path, int amode); } -34 AUE_CHFLAGS STD { int chflags(const char *path, u_long flags); } + _Inout_ __socklen_t * __restrict alen); } +33 AUE_ACCESS STD { int access(_In_z_ char *path, int amode); } +34 AUE_CHFLAGS STD { int chflags(_In_z_ const char *path, \ + u_long flags); } 35 AUE_FCHFLAGS STD { int fchflags(int fd, u_long flags); } 36 AUE_SYNC STD { int sync(void); } 37 AUE_KILL STD { int kill(int pid, int signum); } -38 AUE_STAT COMPAT { int stat(char *path, struct ostat *ub); } +38 AUE_STAT COMPAT { int stat(_In_z_ char *path, \ + _Out_ struct ostat *ub); } 39 AUE_GETPPID STD { pid_t getppid(void); } -40 AUE_LSTAT COMPAT { int lstat(char *path, struct ostat *ub); } +40 AUE_LSTAT COMPAT { int lstat(_In_z_ char *path, \ + _Out_ struct ostat *ub); } 41 AUE_DUP STD { int dup(u_int fd); } 42 AUE_PIPE COMPAT10 { int pipe(void); } 43 AUE_GETEGID STD { gid_t getegid(void); } -44 AUE_PROFILE STD { int profil(caddr_t samples, size_t size, \ - size_t offset, u_int scale); } -45 AUE_KTRACE STD { int ktrace(const char *fname, int ops, \ - int facs, int pid); } +44 AUE_PROFILE STD { int profil( \ + _Out_writes_bytes_(size) caddr_t samples, \ + size_t size, size_t offset, u_int scale); } +45 AUE_KTRACE STD { int ktrace(_In_z_ const char *fname, \ + int ops, int facs, int pid); } 46 AUE_SIGACTION COMPAT { int sigaction(int signum, \ - struct osigaction *nsa, \ - struct osigaction *osa); } + _In_opt_ struct osigaction *nsa, \ + _Out_opt_ struct osigaction *osa); } 47 AUE_GETGID STD { gid_t getgid(void); } 48 AUE_SIGPROCMASK COMPAT { int sigprocmask(int how, osigset_t mask); } ; XXX note nonstandard (bogus) calling convention - the libc stub passes ; us the mask, not a pointer to it, and we return the old mask as the ; (int) return value. -49 AUE_GETLOGIN STD { int getlogin(char *namebuf, u_int \ - namelen); } -50 AUE_SETLOGIN STD { int setlogin(char *namebuf); } -51 AUE_ACCT STD { int acct(char *path); } +49 AUE_GETLOGIN STD { int getlogin( \ + _Out_writes_z_(namelen) char *namebuf, \ + u_int namelen); } +50 AUE_SETLOGIN STD { int setlogin(_In_z_ char *namebuf); } +51 AUE_ACCT STD { int acct(_In_z_ char *path); } 52 AUE_SIGPENDING COMPAT { int sigpending(void); } -53 AUE_SIGALTSTACK STD { int sigaltstack(stack_t *ss, \ - stack_t *oss); } +53 AUE_SIGALTSTACK STD { int sigaltstack(_In_opt_ stack_t *ss, \ + _Out_opt_ stack_t *oss); } 54 AUE_IOCTL STD { int ioctl(int fd, u_long com, \ - caddr_t data); } + _Inout_opt_ caddr_t data); } 55 AUE_REBOOT STD { int reboot(int opt); } -56 AUE_REVOKE STD { int revoke(char *path); } -57 AUE_SYMLINK STD { int symlink(char *path, char *link); } -58 AUE_READLINK STD { ssize_t readlink(char *path, char *buf, \ +56 AUE_REVOKE STD { int revoke(_In_z_ char *path); } +57 AUE_SYMLINK STD { int symlink(_In_z_ char *path, \ + _In_z_ char *link); } +58 AUE_READLINK STD { ssize_t readlink(_In_z_ char *path, \ + _Out_writes_z_(count) char *buf, \ size_t count); } -59 AUE_EXECVE STD { int execve(char *fname, char **argv, \ - char **envv); } +59 AUE_EXECVE STD { int execve( \ + _In_z_ char *fname, \ + _In_z_ char **argv, \ + _In_z_ char **envv); } 60 AUE_UMASK STD { int umask(int newmask); } umask umask_args \ int -61 AUE_CHROOT STD { int chroot(char *path); } -62 AUE_FSTAT COMPAT { int fstat(int fd, struct ostat *sb); } -63 AUE_NULL COMPAT { int getkerninfo(int op, char *where, \ - size_t *size, int arg); } getkerninfo \ - getkerninfo_args int +61 AUE_CHROOT STD { int chroot(_In_z_ char *path); } +62 AUE_FSTAT COMPAT { int fstat(int fd, _Out_ struct ostat *sb); } +63 AUE_NULL COMPAT { int getkerninfo(int op, \ + _Out_writes_bytes_opt(*size) char *where, \ + _Inout_opt_ size_t *size, \ + int arg); } getkerninfo getkerninfo_args int 64 AUE_NULL COMPAT { int getpagesize(void); } getpagesize \ getpagesize_args int -65 AUE_MSYNC STD { int msync(void *addr, size_t len, \ +65 AUE_MSYNC STD { int msync(_In_ void *addr, size_t len, \ int flags); } 66 AUE_VFORK STD { int vfork(void); } 67 AUE_NULL OBSOL vread 68 AUE_NULL OBSOL vwrite 69 AUE_SBRK STD { int sbrk(int incr); } 70 AUE_SSTK STD { int sstk(int incr); } -71 AUE_MMAP COMPAT { int mmap(void *addr, int len, int prot, \ +71 AUE_MMAP COMPAT { int mmap(_In_ void *addr, int len, int prot, \ int flags, int fd, long pos); } 72 AUE_O_VADVISE STD { int ovadvise(int anom); } vadvise \ ovadvise_args int -73 AUE_MUNMAP STD { int munmap(void *addr, size_t len); } -74 AUE_MPROTECT STD { int mprotect(void *addr, size_t len, \ - int prot); } -75 AUE_MADVISE STD { int madvise(void *addr, size_t len, \ - int behav); } +73 AUE_MUNMAP STD { int munmap(_In_ void *addr, size_t len); } +74 AUE_MPROTECT STD { int mprotect(_In_ void *addr, \ + size_t len, int prot); } +75 AUE_MADVISE STD { int madvise(_In_ void *addr, \ + size_t len, int behav); } 76 AUE_NULL OBSOL vhangup 77 AUE_NULL OBSOL vlimit -78 AUE_MINCORE STD { int mincore(const void *addr, size_t len, \ +78 AUE_MINCORE STD { int mincore( \ + _In_ const void *addr, \ + size_t len, \ + _Out_writes_bytes_(len/PAGE_SIZE) \ char *vec); } 79 AUE_GETGROUPS STD { int getgroups(u_int gidsetsize, \ + _Out_writes_opt_(gidsetsize) \ gid_t *gidset); } 80 AUE_SETGROUPS STD { int setgroups(u_int gidsetsize, \ - gid_t *gidset); } + _In_reads_(gidsetsize) gid_t *gidset); } 81 AUE_GETPGRP STD { int getpgrp(void); } 82 AUE_SETPGRP STD { int setpgid(int pid, int pgid); } -83 AUE_SETITIMER STD { int setitimer(u_int which, struct \ - itimerval *itv, struct itimerval *oitv); } +83 AUE_SETITIMER STD { int setitimer(u_int which, \ + _In_ struct itimerval *itv, \ + _Out_opt_ struct itimerval *oitv); } 84 AUE_WAIT4 COMPAT { int wait(void); } -85 AUE_SWAPON STD { int swapon(char *name); } +85 AUE_SWAPON STD { int swapon(_In_z_ char *name); } 86 AUE_GETITIMER STD { int getitimer(u_int which, \ - struct itimerval *itv); } -87 AUE_SYSCTL COMPAT { int gethostname(char *hostname, \ + _Out_ struct itimerval *itv); } +87 AUE_SYSCTL COMPAT { int gethostname( \ + _Out_writes_z_(len) char *hostname, \ u_int len); } gethostname \ gethostname_args int -88 AUE_SYSCTL COMPAT { int sethostname(char *hostname, \ +88 AUE_SYSCTL COMPAT { int sethostname( \ + _In_reads_z_(len) char *hostname, \ u_int len); } sethostname \ sethostname_args int 89 AUE_GETDTABLESIZE STD { int getdtablesize(void); } @@ -208,98 +271,129 @@ 92 AUE_FCNTL STD { int fcntl(int fd, int cmd, long arg); } ; XXX should be { int fcntl(int fd, int cmd, ...); } ; but we're not ready for varargs. -93 AUE_SELECT STD { int select(int nd, fd_set *in, fd_set *ou, \ - fd_set *ex, struct timeval *tv); } +93 AUE_SELECT STD { int select(int nd, \ + _Inout_opt_ fd_set *in, \ + _Inout_opt_ fd_set *ou, \ + _Inout_opt_ fd_set *ex, \ + _In_opt_ struct timeval *tv); } 94 AUE_NULL UNIMPL setdopt 95 AUE_FSYNC STD { int fsync(int fd); } 96 AUE_SETPRIORITY STD { int setpriority(int which, int who, \ int prio); } 97 AUE_SOCKET STD { int socket(int domain, int type, \ int protocol); } -98 AUE_CONNECT STD { int connect(int s, caddr_t name, \ +98 AUE_CONNECT STD { int connect(int s, \ + _In_reads_bytes_(namelen) caddr_t name, \ int namelen); } -99 AUE_ACCEPT COMPAT|NOARGS { int accept(int s, caddr_t name, \ - int *anamelen); } accept accept_args int +99 AUE_ACCEPT COMPAT|NOARGS { int accept(int s, \ + _Out_writes_bytes_opt_(*anamelen) \ + caddr_t name, int *anamelen); } \ + accept accept_args int 100 AUE_GETPRIORITY STD { int getpriority(int which, int who); } -101 AUE_SEND COMPAT { int send(int s, caddr_t buf, int len, \ +101 AUE_SEND COMPAT { int send(int s, \ + _In_reads_bytes_(len) caddr_t buf, \ + int len, \ int flags); } -102 AUE_RECV COMPAT { int recv(int s, caddr_t buf, int len, \ - int flags); } +102 AUE_RECV COMPAT { int recv(int s, \ + _Out_writes_bytes_(len) caddr_t buf, \ + int len, int flags); } 103 AUE_SIGRETURN COMPAT { int sigreturn( \ - struct osigcontext *sigcntxp); } -104 AUE_BIND STD { int bind(int s, caddr_t name, \ + _In_ struct osigcontext *sigcntxp); } +104 AUE_BIND STD { int bind(int s, \ + _In_reads_bytes_(namelen) caddr_t name, \ int namelen); } 105 AUE_SETSOCKOPT STD { int setsockopt(int s, int level, int name, \ - caddr_t val, int valsize); } + _In_reads_bytes_opt_(valsize) caddr_t val, \ + int valsize); } 106 AUE_LISTEN STD { int listen(int s, int backlog); } 107 AUE_NULL OBSOL vtimes -108 AUE_NULL COMPAT { int sigvec(int signum, struct sigvec *nsv, \ - struct sigvec *osv); } +108 AUE_NULL COMPAT { int sigvec(int signum, \ + _In_opt_ struct sigvec *nsv, \ + _Out_opt_ struct sigvec *osv); } 109 AUE_NULL COMPAT { int sigblock(int mask); } 110 AUE_NULL COMPAT { int sigsetmask(int mask); } 111 AUE_NULL COMPAT { int sigsuspend(osigset_t mask); } ; XXX note nonstandard (bogus) calling convention - the libc stub passes ; us the mask, not a pointer to it. -112 AUE_NULL COMPAT { int sigstack(struct sigstack *nss, \ - struct sigstack *oss); } -113 AUE_RECVMSG COMPAT { int recvmsg(int s, struct omsghdr *msg, \ +112 AUE_NULL COMPAT { int sigstack(_In_opt_ struct sigstack *nss, \ + _Out_opt_ struct sigstack *oss); } +113 AUE_RECVMSG COMPAT { int recvmsg(int s, \ + _Inout_ struct omsghdr *msg, \ int flags); } -114 AUE_SENDMSG COMPAT { int sendmsg(int s, caddr_t msg, \ +114 AUE_SENDMSG COMPAT { int sendmsg(int s, _In_ caddr_t msg, \ int flags); } 115 AUE_NULL OBSOL vtrace -116 AUE_GETTIMEOFDAY STD { int gettimeofday(struct timeval *tp, \ - struct timezone *tzp); } +116 AUE_GETTIMEOFDAY STD { int gettimeofday( \ + _Out_ struct timeval *tp, \ + _Out_opt_ struct timezone *tzp); } 117 AUE_GETRUSAGE STD { int getrusage(int who, \ - struct rusage *rusage); } + _Out_ struct rusage *rusage); } 118 AUE_GETSOCKOPT STD { int getsockopt(int s, int level, int name, \ - caddr_t val, int *avalsize); } + _Out_writes_bytes_opt_(*avalsize) \ + caddr_t val, _Inout_ int *avalsize); } 119 AUE_NULL UNIMPL resuba (BSD/OS 2.x) -120 AUE_READV STD { int readv(int fd, struct iovec *iovp, \ +120 AUE_READV STD { int readv(int fd, \ + _Inout_updates_(iovcnt) struct iovec *iovp, \ + u_int iovcnt); } +121 AUE_WRITEV STD { int writev(int fd, \ + _In_reads_opt_(iovcnt) struct iovec *iovp, \ u_int iovcnt); } -121 AUE_WRITEV STD { int writev(int fd, struct iovec *iovp, \ - u_int iovcnt); } -122 AUE_SETTIMEOFDAY STD { int settimeofday(struct timeval *tv, \ - struct timezone *tzp); } +122 AUE_SETTIMEOFDAY STD { int settimeofday( \ + _In_ struct timeval *tv, \ + _In_opt_ struct timezone *tzp); } 123 AUE_FCHOWN STD { int fchown(int fd, int uid, int gid); } 124 AUE_FCHMOD STD { int fchmod(int fd, int mode); } -125 AUE_RECVFROM COMPAT|NOARGS { int recvfrom(int s, caddr_t buf, \ - size_t len, int flags, caddr_t from, int \ - *fromlenaddr); } recvfrom recvfrom_args \ - int +125 AUE_RECVFROM COMPAT|NOARGS { int recvfrom(int s, \ + _Out_writes_(len) caddr_t buf, \ + size_t len, int flags, \ + _Out_writes_bytes_(*fromlenaddr) \ + caddr_t from, \ + _Inout_ int *fromlenaddr); } \ + recvfrom recvfrom_args int 126 AUE_SETREUID STD { int setreuid(int ruid, int euid); } 127 AUE_SETREGID STD { int setregid(int rgid, int egid); } -128 AUE_RENAME STD { int rename(char *from, char *to); } -129 AUE_TRUNCATE COMPAT { int truncate(char *path, long length); } +128 AUE_RENAME STD { int rename(_In_z_ char *from, \ + _In_z_ char *to); } +129 AUE_TRUNCATE COMPAT { int truncate(_In_z_ char *path, \ + long length); } 130 AUE_FTRUNCATE COMPAT { int ftruncate(int fd, long length); } 131 AUE_FLOCK STD { int flock(int fd, int how); } -132 AUE_MKFIFO STD { int mkfifo(char *path, int mode); } -133 AUE_SENDTO STD { int sendto(int s, caddr_t buf, size_t len, \ - int flags, caddr_t to, int tolen); } +132 AUE_MKFIFO STD { int mkfifo(_In_z_ char *path, int mode); } +133 AUE_SENDTO STD { int sendto(int s, \ + _In_reads_bytes_(len) caddr_t buf, \ + size_t len, int flags, \ + _In_reads_bytes_opt_(tolen) caddr_t to, \ + int tolen); } 134 AUE_SHUTDOWN STD { int shutdown(int s, int how); } 135 AUE_SOCKETPAIR STD { int socketpair(int domain, int type, \ - int protocol, int *rsv); } -136 AUE_MKDIR STD { int mkdir(char *path, int mode); } -137 AUE_RMDIR STD { int rmdir(char *path); } -138 AUE_UTIMES STD { int utimes(char *path, \ - struct timeval *tptr); } + int protocol, _Out_writes_(2) int *rsv); } +136 AUE_MKDIR STD { int mkdir(_In_z_ char *path, int mode); } +137 AUE_RMDIR STD { int rmdir(_In_z_ char *path); } +138 AUE_UTIMES STD { int utimes(_In_z_ char *path, \ + _In_ struct timeval *tptr); } 139 AUE_NULL OBSOL 4.2 sigreturn -140 AUE_ADJTIME STD { int adjtime(struct timeval *delta, \ - struct timeval *olddelta); } -141 AUE_GETPEERNAME COMPAT { int getpeername(int fdes, caddr_t asa, \ - int *alen); } +140 AUE_ADJTIME STD { int adjtime(_In_ struct timeval *delta, \ + _Out_opt_ struct timeval *olddelta); } +141 AUE_GETPEERNAME COMPAT { int getpeername(int fdes, \ + _Out_writes_bytes_(*alen) \ + caddr_t asa, \ + _Inout_opt_ int *alen); } 142 AUE_SYSCTL COMPAT { long gethostid(void); } 143 AUE_SYSCTL COMPAT { int sethostid(long hostid); } -144 AUE_GETRLIMIT COMPAT { int getrlimit(u_int which, struct \ +144 AUE_GETRLIMIT COMPAT { int getrlimit(u_int which, _Out_ struct \ orlimit *rlp); } 145 AUE_SETRLIMIT COMPAT { int setrlimit(u_int which, \ - struct orlimit *rlp); } + _Out_ struct orlimit *rlp); } 146 AUE_KILLPG COMPAT { int killpg(int pgid, int signum); } 147 AUE_SETSID STD { int setsid(void); } -148 AUE_QUOTACTL STD { int quotactl(char *path, int cmd, int uid, \ - caddr_t arg); } +148 AUE_QUOTACTL STD { int quotactl( \ + _In_z_ char *path, int cmd, int uid, \ + _In_ caddr_t arg); } 149 AUE_O_QUOTA COMPAT { int quota(void); } 150 AUE_GETSOCKNAME COMPAT|NOARGS { int getsockname(int fdec, \ - caddr_t asa, int *alen); } getsockname \ + _Out_writes_bytes_(*alen) \ + caddr_t asa, \ + _Inout_ int *alen); } getsockname \ getsockname_args int ; Syscalls 151-180 inclusive are reserved for vendor-specific @@ -310,28 +404,34 @@ 152 AUE_NULL UNIMPL sem_wakeup (BSD/OS 2.x) 153 AUE_NULL UNIMPL asyncdaemon (BSD/OS 2.x) ; 154 is initialised by the NLM code, if present. -154 AUE_NULL NOSTD { int nlm_syscall(int debug_level, int grace_period, int addr_count, char **addrs); } +154 AUE_NULL NOSTD { int nlm_syscall(int debug_level, \ + int grace_period, int addr_count, \ + _In_reads_(addr_count) \ + char **addrs); } ; 155 is initialized by the NFS code, if present. -155 AUE_NFS_SVC NOSTD { int nfssvc(int flag, caddr_t argp); } -156 AUE_GETDIRENTRIES COMPAT { int getdirentries(int fd, char *buf, \ - u_int count, long *basep); } -157 AUE_STATFS COMPAT4 { int statfs(char *path, \ - struct ostatfs *buf); } +155 AUE_NFS_SVC NOSTD { int nfssvc(int flag, _In_ caddr_t argp); } +156 AUE_GETDIRENTRIES COMPAT { int getdirentries(int fd, \ + _Out_writes_bytes_(count) char *buf, \ + u_int count, _Out_ long *basep); } +157 AUE_STATFS COMPAT4 { int statfs(_In_z_ char *path, \ + _Out_ struct ostatfs *buf); } 158 AUE_FSTATFS COMPAT4 { int fstatfs(int fd, \ - struct ostatfs *buf); } + _Out_ struct ostatfs *buf); } 159 AUE_NULL UNIMPL nosys -160 AUE_LGETFH STD { int lgetfh(char *fname, \ - struct fhandle *fhp); } -161 AUE_NFS_GETFH STD { int getfh(char *fname, \ - struct fhandle *fhp); } -162 AUE_SYSCTL COMPAT4 { int getdomainname(char *domainname, \ +160 AUE_LGETFH STD { int lgetfh(_In_z_ char *fname, \ + _Out_ struct fhandle *fhp); } +161 AUE_NFS_GETFH STD { int getfh(_In_z_ char *fname, \ + _Out_ struct fhandle *fhp); } +162 AUE_SYSCTL COMPAT4 { int getdomainname( \ + _Out_writes_z_(len) char *domainname, \ int len); } -163 AUE_SYSCTL COMPAT4 { int setdomainname(char *domainname, \ +163 AUE_SYSCTL COMPAT4 { int setdomainname( \ + _In_reads_z_(len) char *domainname, \ int len); } -164 AUE_NULL COMPAT4 { int uname(struct utsname *name); } -165 AUE_SYSARCH STD { int sysarch(int op, char *parms); } +164 AUE_NULL COMPAT4 { int uname(_Out_ struct utsname *name); } +165 AUE_SYSARCH STD { int sysarch(int op, _In_z_ char *parms); } 166 AUE_RTPRIO STD { int rtprio(int function, pid_t pid, \ - struct rtprio *rtp); } + _Inout_ struct rtprio *rtp); } 167 AUE_NULL UNIMPL nosys 168 AUE_NULL UNIMPL nosys 169 AUE_SEMSYS NOSTD { int semsys(int which, int a2, int a3, \ @@ -344,13 +444,15 @@ int a4); } ; XXX should be { int shmsys(int which, ...); } 172 AUE_NULL UNIMPL nosys -173 AUE_PREAD COMPAT6 { ssize_t pread(int fd, void *buf, \ +173 AUE_PREAD COMPAT6 { ssize_t pread(int fd, \ + _Out_writes_bytes_(nbyte) void *buf, \ size_t nbyte, int pad, off_t offset); } 174 AUE_PWRITE COMPAT6 { ssize_t pwrite(int fd, \ + _In_reads_bytes_(nbyte) \ const void *buf, \ size_t nbyte, int pad, off_t offset); } 175 AUE_SETFIB STD { int setfib(int fibnum); } -176 AUE_NTP_ADJTIME STD { int ntp_adjtime(struct timex *tp); } +176 AUE_NTP_ADJTIME STD { int ntp_adjtime(_Inout_ struct timex *tp); } 177 AUE_NULL UNIMPL sfork (BSD/OS 2.x) 178 AUE_NULL UNIMPL getdescriptor (BSD/OS 2.x) 179 AUE_NULL UNIMPL setdescriptor (BSD/OS 2.x) @@ -364,46 +466,58 @@ 185 AUE_NULL UNIMPL lfs_markv 186 AUE_NULL UNIMPL lfs_segclean 187 AUE_NULL UNIMPL lfs_segwait -188 AUE_STAT COMPAT11 { int stat(char *path, \ - struct freebsd11_stat *ub); } +188 AUE_STAT COMPAT11 { int stat(_In_z_ char *path, \ + _Out_ struct freebsd11_stat *ub); } 189 AUE_FSTAT COMPAT11 { int fstat(int fd, \ - struct freebsd11_stat *sb); } -190 AUE_LSTAT COMPAT11 { int lstat(char *path, \ - struct freebsd11_stat *ub); } -191 AUE_PATHCONF STD { int pathconf(char *path, int name); } + _Out_ struct freebsd11_stat *sb); } +190 AUE_LSTAT COMPAT11 { int lstat(_In_z_ char *path, \ + _Out_ struct freebsd11_stat *ub); } +191 AUE_PATHCONF STD { int pathconf(_In_z_ char *path, int name); } 192 AUE_FPATHCONF STD { int fpathconf(int fd, int name); } 193 AUE_NULL UNIMPL nosys 194 AUE_GETRLIMIT STD { int getrlimit(u_int which, \ - struct rlimit *rlp); } getrlimit \ + _Out_ struct rlimit *rlp); } getrlimit \ __getrlimit_args int 195 AUE_SETRLIMIT STD { int setrlimit(u_int which, \ - struct rlimit *rlp); } setrlimit \ + _In_ struct rlimit *rlp); } setrlimit \ __setrlimit_args int -196 AUE_GETDIRENTRIES COMPAT11 { int getdirentries(int fd, char *buf, \ - u_int count, long *basep); } -197 AUE_MMAP COMPAT6 { caddr_t mmap(caddr_t addr, \ - size_t len, int prot, int flags, int fd, \ - int pad, off_t pos); } +196 AUE_GETDIRENTRIES COMPAT11 { int getdirentries(int fd, \ + _Out_writes_bytes_(count) char *buf, \ + u_int count, _Out_ long *basep); } +197 AUE_MMAP COMPAT6 { caddr_t mmap(_In_ caddr_t addr, size_t len, \ + int prot, int flags, int fd, int pad, \ + off_t pos); } 198 AUE_NULL NOPROTO { int nosys(void); } __syscall \ __syscall_args int 199 AUE_LSEEK COMPAT6 { off_t lseek(int fd, int pad, \ off_t offset, int whence); } -200 AUE_TRUNCATE COMPAT6 { int truncate(char *path, int pad, \ +200 AUE_TRUNCATE COMPAT6 { int truncate(_In_z_ char *path, int pad, \ off_t length); } 201 AUE_FTRUNCATE COMPAT6 { int ftruncate(int fd, int pad, \ off_t length); } -202 AUE_SYSCTL STD { int __sysctl(int *name, u_int namelen, \ - void *old, size_t *oldlenp, void *new, \ - size_t newlen); } __sysctl sysctl_args int -203 AUE_MLOCK STD { int mlock(const void *addr, size_t len); } -204 AUE_MUNLOCK STD { int munlock(const void *addr, size_t len); } -205 AUE_UNDELETE STD { int undelete(char *path); } -206 AUE_FUTIMES STD { int futimes(int fd, struct timeval *tptr); } +202 AUE_SYSCTL STD { int __sysctl( \ + _In_reads_(namelen) int *name, \ + u_int namelen, \ + _Out_writes_bytes_opt_(*oldlenp) \ + void *old, \ + _Inout_opt_ size_t *oldlenp, \ + _In_reads_bytes_opt_(newlen) \ + void *new, \ + size_t newlen); } \ + __sysctl sysctl_args int +203 AUE_MLOCK STD { int mlock(_In_ const void *addr, \ + size_t len); } +204 AUE_MUNLOCK STD { int munlock(_In_ const void *addr, \ + size_t len); } +205 AUE_UNDELETE STD { int undelete(_In_z_ char *path); } +206 AUE_FUTIMES STD { int futimes(int fd, \ + _In_reads_(2) struct timeval *tptr); } 207 AUE_GETPGID STD { int getpgid(pid_t pid); } 208 AUE_NULL UNIMPL nosys -209 AUE_POLL STD { int poll(struct pollfd *fds, u_int nfds, \ - int timeout); } - +209 AUE_POLL STD { int poll( \ + _Inout_updates_(nfds) \ + struct pollfd *fds, \ + u_int nfds, int timeout); } ; ; The following are reserved for loadable syscalls ; @@ -422,67 +536,84 @@ int cmd, union semun_old *arg); } 221 AUE_SEMGET NOSTD { int semget(key_t key, int nsems, \ int semflg); } -222 AUE_SEMOP NOSTD { int semop(int semid, struct sembuf *sops, \ +222 AUE_SEMOP NOSTD { int semop(int semid, \ + _In_reads_(nsops) struct sembuf *sops, \ size_t nsops); } 223 AUE_NULL UNIMPL semconfig 224 AUE_MSGCTL COMPAT7|NOSTD { int msgctl(int msqid, int cmd, \ struct msqid_ds_old *buf); } 225 AUE_MSGGET NOSTD { int msgget(key_t key, int msgflg); } -226 AUE_MSGSND NOSTD { int msgsnd(int msqid, const void *msgp, \ +226 AUE_MSGSND NOSTD { int msgsnd(int msqid, \ + _In_reads_bytes_(msgsz) const void *msgp, \ size_t msgsz, int msgflg); } -227 AUE_MSGRCV NOSTD { ssize_t msgrcv(int msqid, void *msgp, \ +227 AUE_MSGRCV NOSTD { ssize_t msgrcv(int msqid, \ + _Out_writes_bytes_(msgsz) void *msgp, \ size_t msgsz, long msgtyp, int msgflg); } -228 AUE_SHMAT NOSTD { int shmat(int shmid, const void *shmaddr, \ +228 AUE_SHMAT NOSTD { int shmat(int shmid, \ + _In_ const void *shmaddr, \ int shmflg); } 229 AUE_SHMCTL COMPAT7|NOSTD { int shmctl(int shmid, int cmd, \ struct shmid_ds_old *buf); } -230 AUE_SHMDT NOSTD { int shmdt(const void *shmaddr); } +230 AUE_SHMDT NOSTD { int shmdt(_In_ const void *shmaddr); } 231 AUE_SHMGET NOSTD { int shmget(key_t key, size_t size, \ int shmflg); } ; 232 AUE_NULL STD { int clock_gettime(clockid_t clock_id, \ - struct timespec *tp); } -233 AUE_CLOCK_SETTIME STD { int clock_settime( \ - clockid_t clock_id, \ - const struct timespec *tp); } + _Out_ struct timespec *tp); } +233 AUE_CLOCK_SETTIME STD { int clock_settime(clockid_t clock_id, \ + _In_ const struct timespec *tp); } 234 AUE_NULL STD { int clock_getres(clockid_t clock_id, \ - struct timespec *tp); } -235 AUE_NULL STD { int ktimer_create(clockid_t clock_id, \ - struct sigevent *evp, int *timerid); } + _Out_ struct timespec *tp); } +235 AUE_NULL STD { int ktimer_create( \ + clockid_t clock_id, \ + _In_ struct sigevent *evp, \ + _Out_ int *timerid); } 236 AUE_NULL STD { int ktimer_delete(int timerid); } -237 AUE_NULL STD { int ktimer_settime(int timerid, int flags, \ - const struct itimerspec *value, \ - struct itimerspec *ovalue); } -238 AUE_NULL STD { int ktimer_gettime(int timerid, struct \ - itimerspec *value); } +237 AUE_NULL STD { int ktimer_settime(int timerid, \ + int flags, \ + _In_ const struct itimerspec *value, \ + _Out_opt_ struct itimerspec *ovalue); } +238 AUE_NULL STD { int ktimer_gettime(int timerid, \ + _Out_ struct itimerspec *value); } 239 AUE_NULL STD { int ktimer_getoverrun(int timerid); } -240 AUE_NULL STD { int nanosleep(const struct timespec *rqtp, \ - struct timespec *rmtp); } -241 AUE_NULL STD { int ffclock_getcounter(ffcounter *ffcount); } +240 AUE_NULL STD { int nanosleep( \ + _In_ const struct timespec *rqtp, \ + _Out_opt_ struct timespec *rmtp); } +241 AUE_NULL STD { int ffclock_getcounter( \ + _Out_ ffcounter *ffcount); } 242 AUE_NULL STD { int ffclock_setestimate( \ - struct ffclock_estimate *cest); } + _In_ struct ffclock_estimate *cest); } 243 AUE_NULL STD { int ffclock_getestimate( \ - struct ffclock_estimate *cest); } + _Out_ struct ffclock_estimate *cest); } 244 AUE_NULL STD { int clock_nanosleep(clockid_t clock_id, \ - int flags, const struct timespec *rqtp, \ - struct timespec *rmtp); } + int flags, \ + _In_ const struct timespec *rqtp, \ + _Out_opt_ struct timespec *rmtp); } 245 AUE_NULL UNIMPL nosys 246 AUE_NULL UNIMPL nosys -247 AUE_NULL STD { int clock_getcpuclockid2(id_t id,\ - int which, clockid_t *clock_id); } -248 AUE_NULL STD { int ntp_gettime(struct ntptimeval *ntvp); } +247 AUE_NULL STD { int clock_getcpuclockid2(id_t id, \ + int which, _Out_ clockid_t *clock_id); } +248 AUE_NULL STD { int ntp_gettime( \ + _Out_ struct ntptimeval *ntvp); } 249 AUE_NULL UNIMPL nosys -250 AUE_MINHERIT STD { int minherit(void *addr, size_t len, \ - int inherit); } +; syscall numbers initially used in OpenBSD +250 AUE_MINHERIT STD { int minherit( \ + _In_ void *addr, \ + size_t len, int inherit); } 251 AUE_RFORK STD { int rfork(int flags); } 252 AUE_POLL OBSOL openbsd_poll 253 AUE_ISSETUGID STD { int issetugid(void); } -254 AUE_LCHOWN STD { int lchown(char *path, int uid, int gid); } -255 AUE_AIO_READ STD { int aio_read(struct aiocb *aiocbp); } -256 AUE_AIO_WRITE STD { int aio_write(struct aiocb *aiocbp); } +254 AUE_LCHOWN STD { int lchown(_In_z_ char *path, int uid, \ + int gid); } +255 AUE_AIO_READ STD { int aio_read( \ + _Inout_ struct aiocb *aiocbp); } +256 AUE_AIO_WRITE STD { int aio_write( \ + _Inout_ struct aiocb *aiocbp); } 257 AUE_LIO_LISTIO STD { int lio_listio(int mode, \ - struct aiocb * const *acb_list, \ - int nent, struct sigevent *sig); } + _Inout_updates_(nent) \ + struct aiocb* const *acb_list, \ + int nent, \ + _In_opt_ struct sigevent *sig); } 258 AUE_NULL UNIMPL nosys 259 AUE_NULL UNIMPL nosys 260 AUE_NULL UNIMPL nosys @@ -497,20 +628,23 @@ 269 AUE_NULL UNIMPL nosys 270 AUE_NULL UNIMPL nosys 271 AUE_NULL UNIMPL nosys -272 AUE_O_GETDENTS COMPAT11 { int getdents(int fd, char *buf, \ +272 AUE_O_GETDENTS COMPAT11 { int getdents(int fd, \ + _Out_writes_bytes_(count) char *buf, \ size_t count); } 273 AUE_NULL UNIMPL nosys -274 AUE_LCHMOD STD { int lchmod(char *path, mode_t mode); } +274 AUE_LCHMOD STD { int lchmod(_In_z_ char *path, mode_t mode); } 275 AUE_LCHOWN NOPROTO { int lchown(char *path, uid_t uid, \ gid_t gid); } netbsd_lchown lchown_args \ int -276 AUE_LUTIMES STD { int lutimes(char *path, \ - struct timeval *tptr); } -277 AUE_MSYNC NOPROTO { int msync(void *addr, size_t len, \ +276 AUE_LUTIMES STD { int lutimes(_In_z_ char *path, \ + _In_ struct timeval *tptr); } +277 AUE_MSYNC NOPROTO { int msync(_In_ void *addr, size_t len, \ int flags); } netbsd_msync msync_args int -278 AUE_STAT COMPAT11 { int nstat(char *path, struct nstat *ub); } -279 AUE_FSTAT COMPAT11 { int nfstat(int fd, struct nstat *sb); } -280 AUE_LSTAT COMPAT11 { int nlstat(char *path, struct nstat *ub); } +278 AUE_STAT COMPAT11 { int nstat(_In_z_ char *path, \ + _Out_ struct nstat *ub); } +279 AUE_FSTAT COMPAT11 { int nfstat(int fd, _Out_ struct nstat *sb); } +280 AUE_LSTAT COMPAT11 { int nlstat(_In_z_ char *path, \ + _Out_ struct nstat *ub); } 281 AUE_NULL UNIMPL nosys 282 AUE_NULL UNIMPL nosys 283 AUE_NULL UNIMPL nosys @@ -519,10 +653,13 @@ 286 AUE_NULL UNIMPL nosys 287 AUE_NULL UNIMPL nosys 288 AUE_NULL UNIMPL nosys -289 AUE_PREADV STD { ssize_t preadv(int fd, struct iovec *iovp, \ - u_int iovcnt, off_t offset); } -290 AUE_PWRITEV STD { ssize_t pwritev(int fd, struct iovec *iovp, \ - u_int iovcnt, off_t offset); } +289 AUE_PREADV STD { ssize_t preadv(int fd, \ + _In_reads_(iovcnt) \ + struct iovec *iovp, \ + u_int iovcnt, off_t offset); } +290 AUE_PWRITEV STD { ssize_t pwritev(int fd, \ + _In_reads_(iovcnt) struct iovec *iovp, \ + u_int iovcnt, off_t offset); } 291 AUE_NULL UNIMPL nosys 292 AUE_NULL UNIMPL nosys 293 AUE_NULL UNIMPL nosys @@ -530,23 +667,25 @@ 295 AUE_NULL UNIMPL nosys 296 AUE_NULL UNIMPL nosys 297 AUE_FHSTATFS COMPAT4 { int fhstatfs( \ - const struct fhandle *u_fhp, \ - struct ostatfs *buf); } -298 AUE_FHOPEN STD { int fhopen(const struct fhandle *u_fhp, \ + _In_ const struct fhandle *u_fhp, \ + _Out_ struct ostatfs *buf); } +298 AUE_FHOPEN STD { int fhopen( \ + _In_ const struct fhandle *u_fhp, \ int flags); } -299 AUE_FHSTAT COMPAT11 { int fhstat(const struct fhandle *u_fhp, \ - struct freebsd11_stat *sb); } +299 AUE_FHSTAT COMPAT11 { int fhstat( \ + _In_ const struct fhandle *u_fhp, \ + _Out_ struct freebsd11_stat *sb); } 300 AUE_NULL STD { int modnext(int modid); } 301 AUE_NULL STD { int modstat(int modid, \ - struct module_stat *stat); } + _Out_ struct module_stat* stat); } 302 AUE_NULL STD { int modfnext(int modid); } -303 AUE_NULL STD { int modfind(const char *name); } -304 AUE_MODLOAD STD { int kldload(const char *file); } +303 AUE_NULL STD { int modfind(_In_z_ const char *name); } +304 AUE_MODLOAD STD { int kldload(_In_z_ const char *file); } 305 AUE_MODUNLOAD STD { int kldunload(int fileid); } -306 AUE_NULL STD { int kldfind(const char *file); } +306 AUE_NULL STD { int kldfind(_In_z_ const char *file); } 307 AUE_NULL STD { int kldnext(int fileid); } -308 AUE_NULL STD { int kldstat(int fileid, struct \ - kld_file_stat* stat); } +308 AUE_NULL STD { int kldstat(int fileid, \ + _Out_ struct kld_file_stat *stat); } 309 AUE_NULL STD { int kldfirstmod(int fileid); } 310 AUE_GETSID STD { int getsid(pid_t pid); } 311 AUE_SETRESUID STD { int setresuid(uid_t ruid, uid_t euid, \ @@ -554,109 +693,140 @@ 312 AUE_SETRESGID STD { int setresgid(gid_t rgid, gid_t egid, \ gid_t sgid); } 313 AUE_NULL OBSOL signanosleep -314 AUE_AIO_RETURN STD { ssize_t aio_return(struct aiocb *aiocbp); } +314 AUE_AIO_RETURN STD { ssize_t aio_return( \ + _Inout_ struct aiocb *aiocbp); } 315 AUE_AIO_SUSPEND STD { int aio_suspend( \ - struct aiocb * const * aiocbp, int nent, \ + _Inout_updates_(nent) \ + struct aiocb * const * aiocbp, \ + int nent, \ + _In_opt_ \ const struct timespec *timeout); } 316 AUE_AIO_CANCEL STD { int aio_cancel(int fd, \ - struct aiocb *aiocbp); } -317 AUE_AIO_ERROR STD { int aio_error(struct aiocb *aiocbp); } -318 AUE_AIO_READ COMPAT6 { int aio_read(struct oaiocb *aiocbp); } -319 AUE_AIO_WRITE COMPAT6 { int aio_write(struct oaiocb *aiocbp); } + _In_opt_ struct aiocb *aiocbp); } +317 AUE_AIO_ERROR STD { int aio_error( \ + _In_ struct aiocb *aiocbp); } +318 AUE_AIO_READ COMPAT6 { int aio_read( \ + _Inout_ struct oaiocb *aiocbp); } +319 AUE_AIO_WRITE COMPAT6 { int aio_write( \ + _Inout_ struct oaiocb *aiocbp); } 320 AUE_LIO_LISTIO COMPAT6 { int lio_listio(int mode, \ + _Inout_updates_(nent) \ struct oaiocb * const *acb_list, \ - int nent, struct osigevent *sig); } + int nent, \ + _In_opt_ struct osigevent *sig); } 321 AUE_NULL STD { int yield(void); } 322 AUE_NULL OBSOL thr_sleep 323 AUE_NULL OBSOL thr_wakeup 324 AUE_MLOCKALL STD { int mlockall(int how); } 325 AUE_MUNLOCKALL STD { int munlockall(void); } -326 AUE_GETCWD STD { int __getcwd(char *buf, size_t buflen); } - +326 AUE_GETCWD STD { int __getcwd( \ + _Out_writes_z_(buflen) char *buf, \ + size_t buflen); } 327 AUE_NULL STD { int sched_setparam (pid_t pid, \ - const struct sched_param *param); } -328 AUE_NULL STD { int sched_getparam (pid_t pid, struct \ - sched_param *param); } - + _In_ const struct sched_param *param); } +328 AUE_NULL STD { int sched_getparam (pid_t pid, \ + _Out_ struct sched_param *param); } 329 AUE_NULL STD { int sched_setscheduler (pid_t pid, int \ - policy, const struct sched_param \ + policy, _In_ const struct sched_param \ *param); } 330 AUE_NULL STD { int sched_getscheduler (pid_t pid); } - 331 AUE_NULL STD { int sched_yield (void); } 332 AUE_NULL STD { int sched_get_priority_max (int policy); } 333 AUE_NULL STD { int sched_get_priority_min (int policy); } 334 AUE_NULL STD { int sched_rr_get_interval (pid_t pid, \ - struct timespec *interval); } -335 AUE_NULL STD { int utrace(const void *addr, size_t len); } + _Out_ struct timespec *interval); } +335 AUE_NULL STD { int utrace( \ + _In_reads_bytes_(len) const void *addr, \ + size_t len); } 336 AUE_SENDFILE COMPAT4 { int sendfile(int fd, int s, \ off_t offset, size_t nbytes, \ - struct sf_hdtr *hdtr, off_t *sbytes, \ - int flags); } + _In_opt_ struct sf_hdtr *hdtr, \ + _Out_opt_ off_t *sbytes, int flags); } 337 AUE_NULL STD { int kldsym(int fileid, int cmd, \ - void *data); } -338 AUE_JAIL STD { int jail(struct jail *jail); } + _In_ void *data); } +338 AUE_JAIL STD { int jail( \ + _In_ struct jail *jail); } + 339 AUE_NULL NOSTD|NOTSTATIC { int nnpfs_syscall(int operation, \ char *a_pathP, int a_opcode, \ - void *a_paramsP, int a_followSymlinks); } + void *a_paramsP, \ + int a_followSymlinks); } 340 AUE_SIGPROCMASK STD { int sigprocmask(int how, \ - const sigset_t *set, sigset_t *oset); } -341 AUE_SIGSUSPEND STD { int sigsuspend(const sigset_t *sigmask); } -342 AUE_SIGACTION COMPAT4 { int sigaction(int sig, const \ - struct sigaction *act, \ - struct sigaction *oact); } -343 AUE_SIGPENDING STD { int sigpending(sigset_t *set); } + _In_opt_ const sigset_t *set, \ + _Out_opt_ sigset_t *oset); } +341 AUE_SIGSUSPEND STD { int sigsuspend( \ + _In_ const sigset_t *sigmask); } +342 AUE_SIGACTION COMPAT4 { int sigaction(int sig, \ + _In_opt_ const struct sigaction *act, \ + _Out_opt_ struct sigaction *oact); } +343 AUE_SIGPENDING STD { int sigpending(_In_ sigset_t *set); } 344 AUE_SIGRETURN COMPAT4 { int sigreturn( \ - const struct ucontext4 *sigcntxp); } -345 AUE_SIGWAIT STD { int sigtimedwait(const sigset_t *set, \ - siginfo_t *info, \ - const struct timespec *timeout); } -346 AUE_NULL STD { int sigwaitinfo(const sigset_t *set, \ - siginfo_t *info); } -347 AUE_ACL_GET_FILE STD { int __acl_get_file(const char *path, \ - acl_type_t type, struct acl *aclp); } -348 AUE_ACL_SET_FILE STD { int __acl_set_file(const char *path, \ - acl_type_t type, struct acl *aclp); } + _In_ const struct ucontext4 *sigcntxp); } +345 AUE_SIGWAIT STD { int sigtimedwait(_In_ const sigset_t *set, \ + _Out_opt_ siginfo_t *info, \ + _In_opt_ const struct timespec *timeout); } +346 AUE_NULL STD { int sigwaitinfo(_In_ const sigset_t *set, \ + _Out_opt_ siginfo_t *info); } +347 AUE_ACL_GET_FILE STD { int __acl_get_file( \ + _In_z_ const char *path, \ + acl_type_t type, \ + _Out_ struct acl *aclp); } +348 AUE_ACL_SET_FILE STD { int __acl_set_file( \ + _In_z_ const char *path, \ + acl_type_t type, _In_ struct acl *aclp); } 349 AUE_ACL_GET_FD STD { int __acl_get_fd(int filedes, \ - acl_type_t type, struct acl *aclp); } + acl_type_t type, _Out_ struct acl *aclp); } 350 AUE_ACL_SET_FD STD { int __acl_set_fd(int filedes, \ - acl_type_t type, struct acl *aclp); } -351 AUE_ACL_DELETE_FILE STD { int __acl_delete_file(const char *path, \ + acl_type_t type, _In_ struct acl *aclp); } +351 AUE_ACL_DELETE_FILE STD { int __acl_delete_file( \ + _In_z_ const char *path, \ acl_type_t type); } 352 AUE_ACL_DELETE_FD STD { int __acl_delete_fd(int filedes, \ acl_type_t type); } -353 AUE_ACL_CHECK_FILE STD { int __acl_aclcheck_file(const char *path, \ - acl_type_t type, struct acl *aclp); } +353 AUE_ACL_CHECK_FILE STD { int __acl_aclcheck_file( \ + _In_z_ const char *path, \ + acl_type_t type, _In_ struct acl *aclp); } 354 AUE_ACL_CHECK_FD STD { int __acl_aclcheck_fd(int filedes, \ - acl_type_t type, struct acl *aclp); } -355 AUE_EXTATTRCTL STD { int extattrctl(const char *path, int cmd, \ - const char *filename, int attrnamespace, \ - const char *attrname); } + acl_type_t type, _In_ struct acl *aclp); } +355 AUE_EXTATTRCTL STD { int extattrctl(_In_z_ const char *path, \ + int cmd, _In_z_opt_ const char *filename, \ + int attrnamespace, \ + _In_z_ const char *attrname); } 356 AUE_EXTATTR_SET_FILE STD { ssize_t extattr_set_file( \ - const char *path, int attrnamespace, \ - const char *attrname, void *data, \ + _In_z_ const char *path, \ + int attrnamespace, \ + _In_z_ const char *attrname, \ + _In_reads_bytes_(nbytes) void *data, \ size_t nbytes); } 357 AUE_EXTATTR_GET_FILE STD { ssize_t extattr_get_file( \ - const char *path, int attrnamespace, \ - const char *attrname, void *data, \ + _In_z_ const char *path, \ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Thu Apr 5 20:33:02 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C54A9FA0C0A; Thu, 5 Apr 2018 20:33:01 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 725EB6FF73; Thu, 5 Apr 2018 20:33:00 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id 43AA55A9F15; Thu, 5 Apr 2018 20:33:00 +0000 (UTC) Date: Thu, 5 Apr 2018 20:33:00 +0000 From: Brooks Davis To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r332086 - head/sys/kern Message-ID: <20180405203300.GE23904@spindle.one-eyed-alien.net> References: <201804052031.w35KVjQE032631@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="HG+GLK89HZ1zG0kk" Content-Disposition: inline In-Reply-To: <201804052031.w35KVjQE032631@repo.freebsd.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 20:33:02 -0000 --HG+GLK89HZ1zG0kk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 05, 2018 at 08:31:45PM +0000, Brooks Davis wrote: > Author: brooks > Date: Thu Apr 5 20:31:45 2018 > New Revision: 332086 > URL: https://svnweb.freebsd.org/changeset/base/332086 >=20 > Log: > Added SAL annotatations to system calls. > =20 > Modify makesyscalls.sh to strip out SAL annotations. > =20 > No functional change. > =20 > This is based on work I started in CheriBSD and use to validate fat > pointers at the syscall boundary. Tal Garfinkel reviewed the changes, > added annotations to COMPAT* syscalls and is using them in a record and > playback framework. One can envision other uses such as a WITNESS-like > validator for copyin/out as speculated on in the review. > =20 > As this time we are only annotating sys/kern/syscalls.master as that is > sufficient for userspace work. If kernel use cases materialize, we can > annotate other syscalls.master as needed. > =20 > Submitted by: Tal Garfinkel > Sponsored by: DARPA, AFRL (in part) > Differential Revision: https://reviews.freebsd.org/D14285 Sorry, I misplaced a: Reviewed by: cem (prior version) -- Brooks --HG+GLK89HZ1zG0kk Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJaxof7AAoJEKzQXbSebgfANEEIAJ8v7vEFEkv4I8aXo/4qNy8j Tf/68uJO7tfiK1uwTdrtvILrE0se6DhuizyQTJblDIigLUER/IQBXvcNn9fyxjtW kSVz2Ev0zD4BoYtaAtm5Q34VFo0BGMRaIX1WRysWXOJtl+0ozAHJV5N2ttX1JhPC 05ip4fmckJopQKo7hmsp95j6lV/zktdOYuvNOaXsXkuYvgg+sh4627MdnFh50K7O PsMTYMTngGXMfPpc6w2/MXDLxYaiU1GWaAc5oruXpjjx2vU+IT1EPD91gc34ig00 Whi9UJgH4RR4/pSqCFYbd4zGXs/FHt9hLjLE+w7K5RS1I2Mh7TWBq+u458LSvAA= =f1Hz -----END PGP SIGNATURE----- --HG+GLK89HZ1zG0kk-- From owner-svn-src-head@freebsd.org Thu Apr 5 21:58:29 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0C4C9F84A1F; Thu, 5 Apr 2018 21:58:29 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B697273B32; Thu, 5 Apr 2018 21:58:28 +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 B1820790; Thu, 5 Apr 2018 21:58:28 +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 w35LwSBJ073871; Thu, 5 Apr 2018 21:58:28 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35LwSFN073870; Thu, 5 Apr 2018 21:58:28 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804052158.w35LwSFN073870@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Thu, 5 Apr 2018 21:58:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332087 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 332087 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 21:58:29 -0000 Author: brooks Date: Thu Apr 5 21:58:28 2018 New Revision: 332087 URL: https://svnweb.freebsd.org/changeset/base/332087 Log: ifconf(): Always zero the whole struct ifreq. The previous split of zeroing ifr_name and ifr_addr seperately is safe on current architectures, but would be unsafe if pointers were larger than 8 bytes. Combining the zeroing adds no real cost (a few instructions) and makes the security property easier to verify. Reviewed by: kib, emaste Obtained from: CheriBSD MFC after: 3 days Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14912 Modified: head/sys/net/if.c Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Thu Apr 5 20:31:45 2018 (r332086) +++ head/sys/net/if.c Thu Apr 5 21:58:28 2018 (r332087) @@ -3129,10 +3129,10 @@ again: int addrs; /* - * Zero the ifr_name buffer to make sure we don't - * disclose the contents of the stack. + * Zero the ifr to make sure we don't disclose the contents + * of the stack. */ - memset(ifr.ifr_name, 0, sizeof(ifr.ifr_name)); + memset(&ifr, 0, sizeof(ifr)); if (strlcpy(ifr.ifr_name, ifp->if_xname, sizeof(ifr.ifr_name)) >= sizeof(ifr.ifr_name)) { @@ -3166,7 +3166,6 @@ again: } IF_ADDR_RUNLOCK(ifp); if (addrs == 0) { - bzero((caddr_t)&ifr.ifr_addr, sizeof(ifr.ifr_addr)); sbuf_bcat(sb, &ifr, sizeof(ifr)); max_len += sizeof(ifr); From owner-svn-src-head@freebsd.org Thu Apr 5 22:14:57 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E5932F859D4; Thu, 5 Apr 2018 22:14:56 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 87E3F74532; Thu, 5 Apr 2018 22:14:56 +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 64A8AAF4; Thu, 5 Apr 2018 22:14:56 +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 w35MEudC083672; Thu, 5 Apr 2018 22:14:56 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w35MEubl083670; Thu, 5 Apr 2018 22:14:56 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804052214.w35MEubl083670@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Thu, 5 Apr 2018 22:14:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332088 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 332088 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 22:14:57 -0000 Author: brooks Date: Thu Apr 5 22:14:55 2018 New Revision: 332088 URL: https://svnweb.freebsd.org/changeset/base/332088 Log: Add 32-bit compat for ioctls that take struct ifgroupreq. Use an accessor to access ifgr_group and ifgr_groups. Use an macro CASE_IOC_IFGROUPREQ(cmd) in place of case statements such as "case SIOCAIFGROUP:". This avoids poluting the switch statements with large numbers of #ifdefs. Reviewed by: kib Obtained from: CheriBSD MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14960 Modified: head/sys/net/if.c head/sys/net/if.h Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Thu Apr 5 21:58:28 2018 (r332087) +++ head/sys/net/if.c Thu Apr 5 22:14:55 2018 (r332088) @@ -142,8 +142,25 @@ struct ifreq32 { CTASSERT(sizeof(struct ifreq) == sizeof(struct ifreq32)); CTASSERT(__offsetof(struct ifreq, ifr_ifru) == __offsetof(struct ifreq32, ifr_ifru)); -#endif +struct ifgroupreq32 { + char ifgr_name[IFNAMSIZ]; + u_int ifgr_len; + union { + char ifgru_group[IFNAMSIZ]; + uint32_t ifgru_groups; + } ifgr_ifgru; +}; +#define _CASE_IOC_IFGROUPREQ_32(cmd) \ + case _IOC_NEWTYPE((cmd), struct ifgroupreq32): +#else +#define _CASE_IOC_IFGROUPREQ_32(cmd) +#endif /* COMPAT_FREEBSD32 */ + +#define CASE_IOC_IFGROUPREQ(cmd) \ + _CASE_IOC_IFGROUPREQ_32(cmd) \ + case (cmd) + union ifreq_union { struct ifreq ifr; #ifdef COMPAT_FREEBSD32 @@ -151,6 +168,13 @@ union ifreq_union { #endif }; +union ifgroupreq_union { + struct ifgroupreq ifgr; +#ifdef COMPAT_FREEBSD32 + struct ifgroupreq32 ifgr32; +#endif +}; + SYSCTL_NODE(_net, PF_LINK, link, CTLFLAG_RW, 0, "Link layers"); SYSCTL_NODE(_net_link, 0, generic, CTLFLAG_RW, 0, "Generic link-management"); @@ -1500,17 +1524,42 @@ if_delgroups(struct ifnet *ifp) IFNET_WUNLOCK(); } +static char * +ifgr_group_get(void *ifgrp) +{ + union ifgroupreq_union *ifgrup; + + ifgrup = ifgrp; +#ifdef COMPAT_FREEBSD32 + if (SV_CURPROC_FLAG(SV_ILP32)) + return (&ifgrup->ifgr32.ifgr_ifgru.ifgru_group[0]); +#endif + return (&ifgrup->ifgr.ifgr_ifgru.ifgru_group[0]); +} + +static struct ifg_req * +ifgr_groups_get(void *ifgrp) +{ + union ifgroupreq_union *ifgrup; + + ifgrup = ifgrp; +#ifdef COMPAT_FREEBSD32 + if (SV_CURPROC_FLAG(SV_ILP32)) + return ((struct ifg_req *)(uintptr_t) + ifgrup->ifgr32.ifgr_ifgru.ifgru_groups); +#endif + return (ifgrup->ifgr.ifgr_ifgru.ifgru_groups); +} + /* - * Stores all groups from an interface in memory pointed - * to by data + * Stores all groups from an interface in memory pointed to by ifgr. */ static int -if_getgroup(struct ifgroupreq *data, struct ifnet *ifp) +if_getgroup(struct ifgroupreq *ifgr, struct ifnet *ifp) { int len, error; struct ifg_list *ifgl; struct ifg_req ifgrq, *ifgp; - struct ifgroupreq *ifgr = data; if (ifgr->ifgr_len == 0) { IF_ADDR_RLOCK(ifp); @@ -1521,7 +1570,7 @@ if_getgroup(struct ifgroupreq *data, struct ifnet *ifp } len = ifgr->ifgr_len; - ifgp = ifgr->ifgr_groups; + ifgp = ifgr_groups_get(ifgr); /* XXX: wire */ IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifgl, &ifp->if_groups, ifgl_next) { @@ -1545,12 +1594,11 @@ if_getgroup(struct ifgroupreq *data, struct ifnet *ifp } /* - * Stores all members of a group in memory pointed to by data + * Stores all members of a group in memory pointed to by igfr */ static int -if_getgroupmembers(struct ifgroupreq *data) +if_getgroupmembers(struct ifgroupreq *ifgr) { - struct ifgroupreq *ifgr = data; struct ifg_group *ifg; struct ifg_member *ifgm; struct ifg_req ifgrq, *ifgp; @@ -1573,7 +1621,7 @@ if_getgroupmembers(struct ifgroupreq *data) } len = ifgr->ifgr_len; - ifgp = ifgr->ifgr_groups; + ifgp = ifgr_groups_get(ifgr); TAILQ_FOREACH(ifgm, &ifg->ifg_members, ifgm_next) { if (len < sizeof(ifgrq)) { IFNET_RUNLOCK(); @@ -2803,34 +2851,28 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, error = if_gethwaddr(ifp, ifr); break; - case SIOCAIFGROUP: - { - struct ifgroupreq *ifgr = (struct ifgroupreq *)ifr; - + CASE_IOC_IFGROUPREQ(SIOCAIFGROUP): error = priv_check(td, PRIV_NET_ADDIFGROUP); if (error) return (error); - if ((error = if_addgroup(ifp, ifgr->ifgr_group))) + if ((error = if_addgroup(ifp, + ifgr_group_get((struct ifgroupreq *)data)))) return (error); break; - } - case SIOCGIFGROUP: - if ((error = if_getgroup((struct ifgroupreq *)ifr, ifp))) + CASE_IOC_IFGROUPREQ(SIOCGIFGROUP): + if ((error = if_getgroup((struct ifgroupreq *)data, ifp))) return (error); break; - case SIOCDIFGROUP: - { - struct ifgroupreq *ifgr = (struct ifgroupreq *)ifr; - + CASE_IOC_IFGROUPREQ(SIOCDIFGROUP): error = priv_check(td, PRIV_NET_DELIFGROUP); if (error) return (error); - if ((error = if_delgroup(ifp, ifgr->ifgr_group))) + if ((error = if_delgroup(ifp, + ifgr_group_get((struct ifgroupreq *)data)))) return (error); break; - } default: error = ENOIOCTL; @@ -2932,7 +2974,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, s error = if_clone_list((struct if_clonereq *)data); CURVNET_RESTORE(); return (error); - case SIOCGIFGMEMB: + CASE_IOC_IFGROUPREQ(SIOCGIFGMEMB): error = if_getgroupmembers((struct ifgroupreq *)data); CURVNET_RESTORE(); return (error); Modified: head/sys/net/if.h ============================================================================== --- head/sys/net/if.h Thu Apr 5 21:58:28 2018 (r332087) +++ head/sys/net/if.h Thu Apr 5 22:14:55 2018 (r332088) @@ -517,8 +517,10 @@ struct ifgroupreq { char ifgru_group[IFNAMSIZ]; struct ifg_req *ifgru_groups; } ifgr_ifgru; +#ifndef _KERNEL #define ifgr_group ifgr_ifgru.ifgru_group #define ifgr_groups ifgr_ifgru.ifgru_groups +#endif }; /* From owner-svn-src-head@freebsd.org Fri Apr 6 01:08:09 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 42E34F92098; Fri, 6 Apr 2018 01:08:09 +0000 (UTC) (envelope-from allanjude@freebsd.org) Received: from mx1.scaleengine.net (mx1.scaleengine.net [209.51.186.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DFE3E7B2BD; Fri, 6 Apr 2018 01:08:08 +0000 (UTC) (envelope-from allanjude@freebsd.org) Received: from [10.1.1.2] (Seawolf.HML3.ScaleEngine.net [209.51.186.28]) (Authenticated sender: allanjude.freebsd@scaleengine.com) by mx1.scaleengine.net (Postfix) with ESMTPSA id 7D91E14B01; Fri, 6 Apr 2018 01:08:02 +0000 (UTC) Subject: Re: svn commit: r332070 - in head/sys/geom: . label raid To: Sean Bruno , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201804051356.w35Duexg022529@repo.freebsd.org> From: Allan Jude Message-ID: <4cd9a49c-2d75-bfac-20df-72e8c80eded4@freebsd.org> Date: Thu, 5 Apr 2018 21:08:06 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <201804051356.w35Duexg022529@repo.freebsd.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="m1i1JxhQNEm7dh9MBpO8sdv62rRxP7VgF" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 01:08:09 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --m1i1JxhQNEm7dh9MBpO8sdv62rRxP7VgF Content-Type: multipart/mixed; boundary="XnlaW1AVcJD5GE6LFCC0nZCPKLxsauuRA"; protected-headers="v1" From: Allan Jude To: Sean Bruno , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: <4cd9a49c-2d75-bfac-20df-72e8c80eded4@freebsd.org> Subject: Re: svn commit: r332070 - in head/sys/geom: . label raid References: <201804051356.w35Duexg022529@repo.freebsd.org> In-Reply-To: <201804051356.w35Duexg022529@repo.freebsd.org> --XnlaW1AVcJD5GE6LFCC0nZCPKLxsauuRA Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 2018-04-05 09:56, Sean Bruno wrote: > Author: sbruno > Date: Thu Apr 5 13:56:40 2018 > New Revision: 332070 > URL: https://svnweb.freebsd.org/changeset/base/332070 >=20 > Log: > Squash error from geom by sizing ident strings to DISK_IDENT_SIZE. > =20 > Display attribute in future error strings and differentiate g_handlea= ttr() > error messages for ease of debugging in the future. > =20 > "g_handleattr: md1 bio_length 24 strlen 31 -> EFAULT" > =20 > Reported by: swills > Reviewed by: imp cem avg > Sponsored by: Limelight Networks > Differential Revision: https://reviews.freebsd.org/D14962 >=20 > Modified: > head/sys/geom/geom_subr.c > head/sys/geom/label/g_label_disk_ident.c > head/sys/geom/raid/md_ddf.c > head/sys/geom/raid/md_intel.c >=20 I might be missing something here, but it seems like you didn't actually change the side of struct md_s { =2E.. char ident[32]; =2E.. } And I don't see where the destination buffer went from 24 bytes to a larger value. --=20 Allan Jude --XnlaW1AVcJD5GE6LFCC0nZCPKLxsauuRA-- --m1i1JxhQNEm7dh9MBpO8sdv62rRxP7VgF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (MingW32) iQIcBAEBAgAGBQJaxsh6AAoJEBmVNT4SmAt+wVIQANPF9051t2hgxr1iIE5OWAl9 8zLRjumgIhvUZdmYERa/yUnoFANfoAGpMdnst5pkFlHYO9lWgTicNjfa9nGJ85uO IuFbZqeb4l2RI+5C9vlSuJTJiVStCDiJl+c25OJ4dkExNsGskqYiWSZ2XOkcku4e 1KGffT1cZRPYXFnkZJEPh8c8Ewa4gPFx2kBu6RMeCD3vKX4sW5SoCFmgG56UeqM6 NxqUU8zGD9hXYZi2q3wA7qDTflZ8ggR4MQG+Gh8CXUMMjJoZ6cztyj6sjvK20WtW G56VuNe/ZI+GE5yxCceo5DflMO5atxK9rUDRz4uZCcv+w5NtSZzeBRJVvdXiqhs3 CYUzoNNSdZYglTciRW5oleT5mULxtjC/tKJcZfgyFzT3jfeWlgWaap6rekOBtNCO ImRJ1YTI5bbIq6PjdSgtXd/2b165GsbmT8fPvbthzgwSo7wWnmwNRf0PsHw7VZDX nkZIFoIEYIHgi7AFH8wJN3zx8Mc06CFGf0p9xk/97wzqkMRML8K3dvSiwmt4Py69 NUF+NhF7OIqMibAr39yjAaUTrvWGUxfFafP8JEgw6Qtf3hwwRCS6bN2rR6c+1k63 ST8hkJfyWXMs4AsC+XGceGhFfGZez7Ac/HTc4QWrhsJNuf95pb7ocL1sSHsZcliV pigA3J5R564C3FfUTde3 =k4iY -----END PGP SIGNATURE----- --m1i1JxhQNEm7dh9MBpO8sdv62rRxP7VgF-- From owner-svn-src-head@freebsd.org Fri Apr 6 01:20:53 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EB185F92E4F; Fri, 6 Apr 2018 01:20:52 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-it0-f44.google.com (mail-it0-f44.google.com [209.85.214.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 814637BB15; Fri, 6 Apr 2018 01:20:52 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-it0-f44.google.com with SMTP id h143-v6so4870036ita.4; Thu, 05 Apr 2018 18:20:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=/R4YNQiGbc/hpwXkslh3X6H58lCsMMInmc/Uwb6xY1M=; b=GFW2GZDn76WUiQ3P/xPFnPUIcGo2qP7HjRWcEACDdS9D8p/VYUr4jkDBsIJbqTlZPh POQlxAoEjzuckIK/L7ML+nD2JSKUVnV/CVD3Bsx1SNAUVAKzC1r6pNdSsFCEELSik6IU un3AsAE6DPE7/3eNn0YHGXzfnPuBUCNBuriwBXgMXy9fj6B0d2WKBFw8yFzQtkOq4RBX hyxxPhRxb9SLnWvUdxyIN9rTKafvZI1jZDKh0VzpPYLGWZcKrtVv5986h5JOUXNf9+fn IhlKakhnb5pbBl7Lhi5ErvEEAmwsjEydUclU0ddSGCVJfnUFHrdBYFvW0V1RUvxxtR46 7qdw== X-Gm-Message-State: ALQs6tDEHQLiVxjQZHWbLrPhYFhhjoUpzUqkST+EJQgZ6DTj4EzLnEDj Wjy1j7Iy2TFW6mgw2BD+UL7LoGQZ X-Google-Smtp-Source: AIpwx49zAlSGv87o26QClhvAap3P7dYHQSAH3tlJzudOInQMePneW6cSy4blC9pKYfE2TJPkHJqmug== X-Received: by 2002:a24:730e:: with SMTP id y14-v6mr15882260itb.70.1522977651501; Thu, 05 Apr 2018 18:20:51 -0700 (PDT) Received: from mail-io0-f177.google.com (mail-io0-f177.google.com. [209.85.223.177]) by smtp.gmail.com with ESMTPSA id t10sm5720986ioa.29.2018.04.05.18.20.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Apr 2018 18:20:51 -0700 (PDT) Received: by mail-io0-f177.google.com with SMTP id q84so32798009iod.10; Thu, 05 Apr 2018 18:20:51 -0700 (PDT) X-Received: by 10.107.168.78 with SMTP id r75mr22626481ioe.143.1522977651146; Thu, 05 Apr 2018 18:20:51 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.2.62.19 with HTTP; Thu, 5 Apr 2018 18:20:50 -0700 (PDT) In-Reply-To: <4cd9a49c-2d75-bfac-20df-72e8c80eded4@freebsd.org> References: <201804051356.w35Duexg022529@repo.freebsd.org> <4cd9a49c-2d75-bfac-20df-72e8c80eded4@freebsd.org> From: Conrad Meyer Date: Thu, 5 Apr 2018 18:20:50 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r332070 - in head/sys/geom: . label raid To: Allan Jude Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 01:20:53 -0000 On Thu, Apr 5, 2018 at 6:08 PM, Allan Jude wrote: > On 2018-04-05 09:56, Sean Bruno wrote: >> Author: sbruno >> Date: Thu Apr 5 13:56:40 2018 >> New Revision: 332070 >> URL: https://svnweb.freebsd.org/changeset/base/332070 >> >> Log: >> Squash error from geom by sizing ident strings to DISK_IDENT_SIZE. >> >> ... > I might be missing something here, but it seems like you didn't actually > change the side of > ... > struct md_s The md side can be as small as it likes. It's the caller who needs to provide the large buffer, for other providers of the GEOM::ident attribute. > And I don't see where the destination buffer went from 24 bytes to a > larger value. Check the change in md_intel.c. Best, Conrad From owner-svn-src-head@freebsd.org Fri Apr 6 01:29:33 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BA063F9361F; Fri, 6 Apr 2018 01:29:33 +0000 (UTC) (envelope-from allanjude@freebsd.org) Received: from mx1.scaleengine.net (mx1.scaleengine.net [209.51.186.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 661277C0A7; Fri, 6 Apr 2018 01:29:33 +0000 (UTC) (envelope-from allanjude@freebsd.org) Received: from [10.1.1.2] (Seawolf.HML3.ScaleEngine.net [209.51.186.28]) (Authenticated sender: allanjude.freebsd@scaleengine.com) by mx1.scaleengine.net (Postfix) with ESMTPSA id A17F014B2F; Fri, 6 Apr 2018 01:29:32 +0000 (UTC) Subject: Re: svn commit: r332070 - in head/sys/geom: . label raid To: cem@freebsd.org Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201804051356.w35Duexg022529@repo.freebsd.org> <4cd9a49c-2d75-bfac-20df-72e8c80eded4@freebsd.org> From: Allan Jude Message-ID: Date: Thu, 5 Apr 2018 21:29:40 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 01:29:33 -0000 On 2018-04-05 21:20, Conrad Meyer wrote: > On Thu, Apr 5, 2018 at 6:08 PM, Allan Jude wrote: >> On 2018-04-05 09:56, Sean Bruno wrote: >>> Author: sbruno >>> Date: Thu Apr 5 13:56:40 2018 >>> New Revision: 332070 >>> URL: https://svnweb.freebsd.org/changeset/base/332070 >>> >>> Log: >>> Squash error from geom by sizing ident strings to DISK_IDENT_SIZE. >>> >>> ... >> I might be missing something here, but it seems like you didn't actually >> change the side of >> ... >> struct md_s > > The md side can be as small as it likes. It's the caller who needs to > provide the large buffer, for other providers of the GEOM::ident > attribute. > >> And I don't see where the destination buffer went from 24 bytes to a >> larger value. > > Check the change in md_intel.c. > > Best, > Conrad > Right, but md_intel.c is for intel BIOS raid. I don't see the change that increased the size of the buffer in the caller from 24 bytes to something more useful? Or was it md_intel tasting the md(4) device? -- Allan Jude From owner-svn-src-head@freebsd.org Fri Apr 6 01:34:51 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6AB98F93C5D; Fri, 6 Apr 2018 01:34:51 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-it0-f43.google.com (mail-it0-f43.google.com [209.85.214.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 06FBC7C60B; Fri, 6 Apr 2018 01:34:50 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-it0-f43.google.com with SMTP id u62-v6so6708124ita.5; Thu, 05 Apr 2018 18:34:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-transfer-encoding; bh=Z1/A8z/8vW91CPaXvqowPIxeSPR0pqN5W9sTaTZ/lpM=; b=RfxYNgf8E5P9e74LKkmDV0/A6YCLJyCchmqbKVjx+md6WVTYlJrG94BSpM4CGKYGIy N1+4/JJXotltpH1cW8VHF6GUxE5GkRRuIjbhPxbqlBFSihcchin3LOD2dmav7dfES+iI KUzCN2oBY7W1s7BT3Q2ZxdIA3TGc7lM1ucYaZ0rH274Yy/sM5AF7GyWxIxVzqY9TceGV IkQTbuCsDs4uC0+HgevSP0bSH6Ub4bbLW2W9O13Ho7uxCY0pHxViOvw8e/MyK7olefdJ ujUh/duL6Utmut+aCCViGUcsWaDZwQBYsb8F7rYNUN1kbYko7r96ehE3mBYTPxMiW+WE F/KQ== X-Gm-Message-State: ALQs6tD+gB5ldMeBg2vAiEj4upQhTNor4YTQgeZrP+ijxdj8TP81aSKi P4VvGHev4tjUXKq7npJNyU5ssTav X-Google-Smtp-Source: AIpwx48LMA9k0Xo9bT0aH33gzMazgIFBYe4duwsb2KuO/7cuXNKFlICapQwhiAjq/hVAexBGzQl4sw== X-Received: by 2002:a24:428f:: with SMTP id i137-v6mr16767391itb.33.1522978490141; Thu, 05 Apr 2018 18:34:50 -0700 (PDT) Received: from mail-io0-f180.google.com (mail-io0-f180.google.com. [209.85.223.180]) by smtp.gmail.com with ESMTPSA id b72-v6sm5000433iti.17.2018.04.05.18.34.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Apr 2018 18:34:49 -0700 (PDT) Received: by mail-io0-f180.google.com with SMTP id q84so32825432iod.10; Thu, 05 Apr 2018 18:34:49 -0700 (PDT) X-Received: by 10.107.168.78 with SMTP id r75mr22651924ioe.143.1522978489737; Thu, 05 Apr 2018 18:34:49 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.2.62.19 with HTTP; Thu, 5 Apr 2018 18:34:49 -0700 (PDT) In-Reply-To: References: <201804051356.w35Duexg022529@repo.freebsd.org> <4cd9a49c-2d75-bfac-20df-72e8c80eded4@freebsd.org> From: Conrad Meyer Date: Thu, 5 Apr 2018 18:34:49 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r332070 - in head/sys/geom: . label raid To: Allan Jude Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 01:34:51 -0000 Yep, exactly =E2=80=94 md_intel was tasting the md(4) device. md_intel invokes g_raid_md_get_label() early on in its taste routine. On Thu, Apr 5, 2018 at 6:29 PM, Allan Jude wrote: > On 2018-04-05 21:20, Conrad Meyer wrote: >> On Thu, Apr 5, 2018 at 6:08 PM, Allan Jude wrote= : >>> On 2018-04-05 09:56, Sean Bruno wrote: >>>> Author: sbruno >>>> Date: Thu Apr 5 13:56:40 2018 >>>> New Revision: 332070 >>>> URL: https://svnweb.freebsd.org/changeset/base/332070 >>>> >>>> Log: >>>> Squash error from geom by sizing ident strings to DISK_IDENT_SIZE. >>>> >>>> ... >>> I might be missing something here, but it seems like you didn't actuall= y >>> change the side of >>> ... >>> struct md_s >> >> The md side can be as small as it likes. It's the caller who needs to >> provide the large buffer, for other providers of the GEOM::ident >> attribute. >> >>> And I don't see where the destination buffer went from 24 bytes to a >>> larger value. >> >> Check the change in md_intel.c. >> >> Best, >> Conrad >> > > Right, but md_intel.c is for intel BIOS raid. > > I don't see the change that increased the size of the buffer in the > caller from 24 bytes to something more useful? > > Or was it md_intel tasting the md(4) device? > > -- > Allan Jude From owner-svn-src-head@freebsd.org Fri Apr 6 02:57:59 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 596A9F99A52; Fri, 6 Apr 2018 02:57:59 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0A3277FCF9; Fri, 6 Apr 2018 02:57:59 +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 0522D3D85; Fri, 6 Apr 2018 02:57:59 +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 w362vwpE023159; Fri, 6 Apr 2018 02:57:58 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w362vwi3023158; Fri, 6 Apr 2018 02:57:58 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201804060257.w362vwi3023158@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 6 Apr 2018 02:57:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332090 - head/stand/i386 X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/stand/i386 X-SVN-Commit-Revision: 332090 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 02:57:59 -0000 Author: emaste Date: Fri Apr 6 02:57:58 2018 New Revision: 332090 URL: https://svnweb.freebsd.org/changeset/base/332090 Log: stand: pass --no-rosegment for i386 bits when linking with lld btxld does not correctly handle input with other than 2 PT_LOAD segments. Passing --no-rosegment lets lld produce output eqivalent to ld.bfd: 2 PT_LOAD segments and no PT_GNU_RELRO. PR: 225775 MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D14956 Modified: head/stand/i386/Makefile.inc Modified: head/stand/i386/Makefile.inc ============================================================================== --- head/stand/i386/Makefile.inc Fri Apr 6 02:47:43 2018 (r332089) +++ head/stand/i386/Makefile.inc Fri Apr 6 02:57:58 2018 (r332090) @@ -2,8 +2,13 @@ # # $FreeBSD$ +.sinclude + LOADER_ADDRESS?=0x200000 LDFLAGS+= -nostdlib +.if defined(LINKER_TYPE) && ${LINKER_TYPE} == "lld" +LDFLAGS+= -Wl,--no-rosegment +.endif # BTX components BTXDIR= ${BOOTOBJ}/i386/btx From owner-svn-src-head@freebsd.org Fri Apr 6 10:04:28 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F1E20F980BA; Fri, 6 Apr 2018 10:04:27 +0000 (UTC) (envelope-from royger@gmail.com) Received: from mail-wm0-x230.google.com (mail-wm0-x230.google.com [IPv6:2a00:1450:400c:c09::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 74B36719B9; Fri, 6 Apr 2018 10:04:27 +0000 (UTC) (envelope-from royger@gmail.com) Received: by mail-wm0-x230.google.com with SMTP id x82so2214069wmg.1; Fri, 06 Apr 2018 03:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=24vXZUxjJXNFWRN1uqGdqSgXSgZYv+YZQMRxR9RZFlM=; b=KyGRCkvRMGA4c4haE2mH7+7Z3uaMKSmOJpMVAedyQvFF46C9AnjWORQ0xL9aRS0UiA HWwJdInP+CrHgq0yiJ0NeizVWxzf+uMom91B79HDJIu3gvDNyYCCkQmMn8/ezgAMQhnF v1ktienTN0CB+hmQ8jQrZ8R3992X6KBVZDkyyQ0PRpgIDKBEiKlYkgE5WP8a8a49YwE/ CKHlFbOXgbU+S1K0xT+FNDFZwloExMto7XMKXTD+2jJvux/kFU9J1OedXrVQ7NIkUNQ3 w3Ey6RZXInrf2fRLOhigoPkQCh1XXV0k8F5sqXTfOuiVlVnJ59EtwTY8ePEgsJhKjcV6 nEXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=24vXZUxjJXNFWRN1uqGdqSgXSgZYv+YZQMRxR9RZFlM=; b=QKdrhmQPw6I0zEF9M4q0RwLYbXMPt398SAdbRDwJn3KE+hDoZ7hBHsALyDsyjNar1/ yvX/v+tBtgiaWL2In11z5ZVq2ZKj99WwvVAi7fQ7vsLp/Cns5r5ld9wt7BnNrPKfW++t zSrbkQzHbPM6e2DqoQy929x6oiKxdRMMty6RTje5PFoVi7uoPnk0U8A+9yn2zoxMclL2 8nUEXPvZ3kE7N5+c75Py/JGs4uV8InxohroY53md2lxqNp2H3qeRuqYN1HLH7kR4lMwJ LsEWJm8r5hVrQdV5z9nMe0aZWwVc1WgtAItTEhkyN73X8U01McQ88/bLReqxXg6DUIgi atZA== X-Gm-Message-State: ALQs6tAQtf4H6PQu2b1inR/4qxLzfBJhQpMn9MuHPUTOIvMw1IuPDAIA iORU07flWCyctHpxtY1y7wE= X-Google-Smtp-Source: AIpwx493igUMeWgIwHlAJ74/BjuB33ANKWdoHhFAUojDeSC0YMswG95/MB2/1khm6z55MrTOnofiHw== X-Received: by 10.80.137.149 with SMTP id g21mr6234846edg.25.1523009065774; Fri, 06 Apr 2018 03:04:25 -0700 (PDT) Received: from localhost (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id r16sm6157859edb.22.2018.04.06.03.04.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Apr 2018 03:04:24 -0700 (PDT) Sender: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Date: Fri, 6 Apr 2018 11:04:21 +0100 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Bruce Evans Cc: Warner Losh , Ian Lepore , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r332072 - head/sys/sys Message-ID: <20180406100421.kumj77n6sfgagozx@MacBook-Pro-de-Roger.local> References: <201804051431.w35EVtg4047897@repo.freebsd.org> <1522942377.49673.245.camel@freebsd.org> <20180405154619.q3blip266qa3z5ut@MacBook-Pro-de-Roger.local> <20180406022720.I3453@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180406022720.I3453@besplex.bde.org> User-Agent: NeoMutt/20180323 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 10:04:28 -0000 On Fri, Apr 06, 2018 at 03:12:08AM +1000, Bruce Evans wrote: > On Thu, 5 Apr 2018, Warner Losh wrote: > > > On Thu, Apr 5, 2018 at 9:46 AM, Roger Pau Monné wrote: > > > > > On Thu, Apr 05, 2018 at 09:32:57AM -0600, Ian Lepore wrote: > > > > On Thu, 2018-04-05 at 14:31 +0000, Roger Pau Monné wrote: > > > > > Log: > > > > > introduce GiB and MiB macros > > > > > ... > > > > > +/* Unit conversion macros. */ > > > > > +#define GiB(v) (v ## ULL << 30) > > > > > +#define MiB(v) (v ## ULL << 20) > > > > > + > > > > > #endif /* _SYS_PARAM_H_ */ > > > > > > > > These names don't make it clear whether the conversion is bytes->GiB or > > > > GiB->bytes. The names seem way too generic for a public namespace in a > > > > file as heavily included behind your back as param.h is. > > > > > > > > Also, this completely reasonable usage won't work, likely with > > > > confusing compile error messages: > > > > > > > > int bytes, gibytes; > > > > ... > > > > bytes = GiB(gibytes); > > > > > > I find those helpful for their specific usage. I could introduce > > > static inline functions like: > > > > > > size_t gb_to_bytes(size_t)... > > > > > > But I assume this is also going to cause further discussion. > > Yes, it gives even more namespace pollution and type errors. Macros > at least don't expose their internals if they are not used. > > size_t is actually already part of the undocumented namespace pollution > in . > > The type errors are restriction to just one type in another way. Type- > generic APIs that avoid such restrictions are much harder to implement > using inline functions than macros. > > > Yea, traditional macro names would be "gibtob" and "btogib" but I didn't > > just reply to bikeshed a name: > > > > But you don't need to specify a type, consider the current btodb macro: > > #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) > > */ \ > > (sizeof (bytes) > sizeof(long) \ > > ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ > > : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) > > > > which shows how to do this in a macro, which is orthogonal to any name you > > may choose. I can also bikeshed function vs macro :) > > This macro is mostly my mistake in 1995-1996. The long long abominations > in it were supposed to be temporary (until C99 standardized something > better). It was originally MD for i386 only and then the sizes of almost > all types are known and fixed so it is easier to hard-code minimal sizes > that work. The optimization of avoiding using 64-bit types was more needed > in 1995-1996 since CPUs were slower and compilers did less strength reduction. > > btodb() is much easier than dbtob() since it shifts right, so it can't > overflow unless the cast of 'bytes' is wrong so that it truncations. > dbtob() doesn't try hard to be optimal. It just always upcasts to > off_t. > > jake later convinced me (in connection with his PAE and sparc64 work) that > it should be the caller's responsibility to avoid overflow. Any casts in > the macro limits it to the types in it. This is why the page to byte > conversion macros don't have any casts in them. PAE usually needs 64-bit > results, but this would just be a pessimization for normal i386, and > deciding the casts in the macro as above is complicated. > > So correct GB() macros would look like ((v) << 30), where the caller must > cast v to a large enough type. E.g., for variable v which might be larger > than 4, on 32-bit systems, the caller must write something like > GB((uintmax_t)v). But it is easier for writing to just multiply v by 1G. > This is also easier for reading since it is unclear that GB() is even a > conversion or which direction it goes in. A longer descriptive name would > be about as clear and long as an explicit multiplication. > > I usually write 1G as ((type)1024 * 1024 * 1024) since the decimal and > even hex values of 1G have too many digits to be clear, and > multiplication is clearer than shifting and allows the type to be in > the factor. > > Disk block size conversions need to use macros since the DEV_BSIZE = 512 > was variable in theory (in practice this is now a fixed virtual size). > Conversions to G don't need macros since the magic number in them is no > more magic than the G in their name. I personally find the following chunk: if (addr < GiB(4)) ... Much more easier to read and parse than: if (addr < (4 * 1024 * 1024 * 1024)) ... But I won't insist anymore. I will revert this and introduce the macros locally where I need them. Roger. From owner-svn-src-head@freebsd.org Fri Apr 6 11:20:07 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 42005F9D604; Fri, 6 Apr 2018 11:20:07 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E1BD474E77; Fri, 6 Apr 2018 11:20:06 +0000 (UTC) (envelope-from royger@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 D53311105D; Fri, 6 Apr 2018 11:20:06 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36BK6Dx074638; Fri, 6 Apr 2018 11:20:06 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36BK6s6074635; Fri, 6 Apr 2018 11:20:06 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201804061120.w36BK6s6074635@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Fri, 6 Apr 2018 11:20:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332092 - in head/sys: amd64/amd64 sys x86/x86 X-SVN-Group: head X-SVN-Commit-Author: royger X-SVN-Commit-Paths: in head/sys: amd64/amd64 sys x86/x86 X-SVN-Commit-Revision: 332092 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 11:20:07 -0000 Author: royger Date: Fri Apr 6 11:20:06 2018 New Revision: 332092 URL: https://svnweb.freebsd.org/changeset/base/332092 Log: remove GiB/MiB macros from param.h And instead define them in the files where they are used. Requested by: bde Modified: head/sys/amd64/amd64/mp_machdep.c head/sys/sys/param.h head/sys/x86/x86/mp_x86.c Modified: head/sys/amd64/amd64/mp_machdep.c ============================================================================== --- head/sys/amd64/amd64/mp_machdep.c Fri Apr 6 09:25:08 2018 (r332091) +++ head/sys/amd64/amd64/mp_machdep.c Fri Apr 6 11:20:06 2018 (r332092) @@ -83,6 +83,8 @@ __FBSDID("$FreeBSD$"); #define BIOS_RESET (0x0f) #define BIOS_WARM (0x0a) +#define GiB(v) (v ## ULL << 30) + extern struct pcpu __pcpu[]; /* Temporary variables for init_secondary() */ Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Fri Apr 6 09:25:08 2018 (r332091) +++ head/sys/sys/param.h Fri Apr 6 11:20:06 2018 (r332092) @@ -362,8 +362,4 @@ __END_DECLS */ #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset]) -/* Unit conversion macros. */ -#define GiB(v) (v ## ULL << 30) -#define MiB(v) (v ## ULL << 20) - #endif /* _SYS_PARAM_H_ */ Modified: head/sys/x86/x86/mp_x86.c ============================================================================== --- head/sys/x86/x86/mp_x86.c Fri Apr 6 09:25:08 2018 (r332091) +++ head/sys/x86/x86/mp_x86.c Fri Apr 6 11:20:06 2018 (r332092) @@ -160,6 +160,8 @@ struct cache_info { unsigned int boot_address; +#define MiB(v) (v ## ULL << 20) + void mem_range_AP_init(void) { From owner-svn-src-head@freebsd.org Fri Apr 6 12:15:06 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7E7C8FA1BC8; Fri, 6 Apr 2018 12:15:06 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 5515377A41; Fri, 6 Apr 2018 12:15:04 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 0A19210479ED; Fri, 6 Apr 2018 22:15:01 +1000 (AEST) Date: Fri, 6 Apr 2018 22:15:01 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r332092 - in head/sys: amd64/amd64 sys x86/x86 In-Reply-To: <201804061120.w36BK6s6074635@repo.freebsd.org> Message-ID: <20180406213913.G2230@besplex.bde.org> References: <201804061120.w36BK6s6074635@repo.freebsd.org> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=VJytp5HX c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=nlC_4_pT8q9DhB4Ho9EA:9 a=lUc6861xcdqJ360VjMYA:9 a=45ClL6m2LaAA:10 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 12:15:07 -0000 On Fri, 6 Apr 2018, [UTF-8] Roger Pau Monn=C3=A9 wrote: > Log: > remove GiB/MiB macros from param.h > > And instead define them in the files where they are used. > > Requested by: bde Thanks, but these files have a negative need for the macros. > Modified: head/sys/amd64/amd64/mp_machdep.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/amd64/amd64/mp_machdep.c=09Fri Apr 6 09:25:08 2018=09(r3320= 91) > +++ head/sys/amd64/amd64/mp_machdep.c=09Fri Apr 6 11:20:06 2018=09(r3320= 92) > @@ -83,6 +83,8 @@ __FBSDID("$FreeBSD$"); > #define BIOS_RESET=09=09(0x0f) > #define BIOS_WARM=09=09(0x0a) > > +#define GiB(v)=09=09=09(v ## ULL << 30) > + In this file, the macro is used only once. It takes about 4 times as much code to define and use the macro once as to write (vm_paddr_t)4 << 30. Much more than 4 times longer to read, since some searching is needed to find the macro and some decoding is needed to understand it. More to see that the wrong type returned by the macro is not a problem. The value can be written more consisely as 4L << 30 after doing a similar type analysis. 1G is normally written as 1024 * 1024 * 1024 since this is a bit clearer than 1 << 30. This depends n a similar type analysis -- the multipliction and the shift don't overflow 32-bit ints. But care must be taken with multiplication by another 4 or even 2. > Modified: head/sys/x86/x86/mp_x86.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/x86/x86/mp_x86.c=09Fri Apr 6 09:25:08 2018=09(r332091) > +++ head/sys/x86/x86/mp_x86.c=09Fri Apr 6 11:20:06 2018=09(r332092) > @@ -160,6 +160,8 @@ struct cache_info { > > unsigned int boot_address; > > +#define MiB(v)=09(v ## ULL << 20) > + In this file, the macro is used twice with v =3D 1. Defining and using it takes only about twice as much code and time to read as (vm_paddr_t)1 << 20= =2E Here it is more important to use vm_paddr_t since this code is shared by amd64, i386 and i386-PAE so the size of vm_paddr_t is variable. However, since 1MB is far below INT_MAX, it doesn't take much type analysis to see than the shorter 1 << 20 is safe. 2 copies of the clearer 1024 * 1024 is also shorter than the macro and 2 calls to it. The macro name doesn't match the comment. The comment still says 1MB. The fix is not to break the comment. Later in the file, basemem is converted from K to bytes by multiplying by 1024. Now 1024 is shorter and clearer than 1 << 10 or 0x400 or a macro with many undocmented details. The type analysis to show that multiplying by 1024 doesn't overflow is slightly more complicated since basemem is a variable. It is only easy to see that this doesn't overflow because basemem is an old real-mode value. 640K was large enough for anyone, and basemem in bytes is less than that. 640K was 20 times INT_MAX, but is now 1/3276 of INT_MAX. Bruce From owner-svn-src-head@freebsd.org Fri Apr 6 12:57:02 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EDABFF834D8; Fri, 6 Apr 2018 12:57:01 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A0A8279DED; Fri, 6 Apr 2018 12:57:01 +0000 (UTC) (envelope-from ed@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 9AE511209C; Fri, 6 Apr 2018 12:57:01 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36Cv1kN025124; Fri, 6 Apr 2018 12:57:01 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36Cv1ks025123; Fri, 6 Apr 2018 12:57:01 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201804061257.w36Cv1ks025123@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Fri, 6 Apr 2018 12:57:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332099 - head/usr.sbin/syslogd X-SVN-Group: head X-SVN-Commit-Author: ed X-SVN-Commit-Paths: head/usr.sbin/syslogd X-SVN-Commit-Revision: 332099 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 12:57:02 -0000 Author: ed Date: Fri Apr 6 12:57:01 2018 New Revision: 332099 URL: https://svnweb.freebsd.org/changeset/base/332099 Log: Add RFC 5424 syslog message parsing to syslogd. Syslogd currently uses the RFC 3164 format for its log messages.One limitation of RFC 3164 is that it cannot be used to log entries with sub-second precision timestamps. One of our users has expressed a desire for doing this for doing some basic performance measurements. This change attempts to make a first cut at switching to RFC 5424 based logging. The first step is to alter syslogd's input path to properly parse such messages. It alters the logmsg() prototype to match the fields of RFC 5424. The parsemsg() function is extended to parse both RFC 3164 and 5424 messages and call into logmsg() accordingly. Additional changes include: - Introducing proper parsing of timestamps, so that they can be printed in any desired output format. This means we need to infer the year and timezone for RFC 3164 timestamps. - Removing ISKERNEL. This can now be realised by simply providing an APP-NAME (== "kernel"). - Extending RFC 3164 parsing to trim off the TAG prefix and using that to derive APP-NAME and PROCID. - Increase MAXLINE. RFC 5424 mentions we should support 2k messages. Differential Revision: https://reviews.freebsd.org/D14926 Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Fri Apr 6 12:39:47 2018 (r332098) +++ head/usr.sbin/syslogd/syslogd.c Fri Apr 6 12:57:01 2018 (r332099) @@ -28,6 +28,33 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2018 Prodrive Technologies, https://prodrive-technologies.com/ + * Author: Ed Schouten + * + * 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. + */ #ifndef lint static const char copyright[] = @@ -71,8 +98,7 @@ __FBSDID("$FreeBSD$"); */ /* Maximum number of characters in time of last occurrence */ -#define MAXDATELEN 16 -#define MAXLINE 1024 /* maximum line length */ +#define MAXLINE 2048 /* maximum line length */ #define MAXSVLINE MAXLINE /* maximum saved line length */ #define DEFUPRI (LOG_USER|LOG_NOTICE) #define DEFSPRI (LOG_KERN|LOG_CRIT) @@ -97,8 +123,8 @@ __FBSDID("$FreeBSD$"); #include #include #endif -#include +#include #include #include #include @@ -107,6 +133,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -174,8 +201,17 @@ static STAILQ_HEAD(, socklist) shead = STAILQ_HEAD_INI #define IGN_CONS 0x001 /* don't print on console */ #define SYNC_FILE 0x002 /* do fsync on file after printing */ #define MARK 0x008 /* this message is a mark */ -#define ISKERNEL 0x010 /* kernel generated message */ +/* Timestamps of log entries. */ +struct logtime { + struct tm tm; + suseconds_t usec; +}; + +/* Traditional syslog timestamp format. */ +#define RFC3164_DATELEN 15 +#define RFC3164_DATEFMT "%b %e %H:%M:%S" + /* * This structure represents the files that will have log * copies printed. @@ -215,10 +251,10 @@ struct filed { #define fu_pipe_pname f_un.f_pipe.f_pname #define fu_pipe_pid f_un.f_pipe.f_pid char f_prevline[MAXSVLINE]; /* last message logged */ - char f_lasttime[MAXDATELEN]; /* time of last occurrence */ + struct logtime f_lasttime; /* time of last occurrence */ char f_prevhost[MAXHOSTNAMELEN]; /* host from which recd. */ int f_prevpri; /* pri of f_prevline */ - int f_prevlen; /* length of f_prevline */ + size_t f_prevlen; /* length of f_prevline */ int f_prevcount; /* repetition cnt of prevline */ u_int f_repeatcount; /* number of "repeated" msgs */ int f_flags; /* file-specific flags */ @@ -352,7 +388,8 @@ static void domark(int); static void fprintlog(struct filed *, int, const char *); static void init(int); static void logerror(const char *); -static void logmsg(int, const char *, const char *, const char *, int); +static void logmsg(int, const struct logtime *, const char *, const char *, + const char *, const char *, const char *, const char *, int); static void log_deadchild(pid_t, int, const char *); static void markit(void); static int socksetup(struct peer *); @@ -852,17 +889,352 @@ usage(void) } /* - * Take a raw input line, extract PRI, TIMESTAMP and HOSTNAME from the message, - * and print the message on the appropriate log files. + * Removes characters from log messages that are unsafe to display. + * TODO: Permit UTF-8 strings that include a BOM per RFC 5424? */ static void +parsemsg_remove_unsafe_characters(const char *in, char *out, size_t outlen) +{ + char *q; + int c; + + q = out; + while ((c = (unsigned char)*in++) != '\0' && q < out + outlen - 4) { + if (mask_C1 && (c & 0x80) && c < 0xA0) { + c &= 0x7F; + *q++ = 'M'; + *q++ = '-'; + } + if (isascii(c) && iscntrl(c)) { + if (c == '\n') { + *q++ = ' '; + } else if (c == '\t') { + *q++ = '\t'; + } else { + *q++ = '^'; + *q++ = c ^ 0100; + } + } else { + *q++ = c; + } + } + *q = '\0'; +} + +/* + * Parses a syslog message according to RFC 5424, assuming that PRI and + * VERSION (i.e., "<%d>1 ") have already been parsed by parsemsg(). The + * parsed result is passed to logmsg(). + */ +static void +parsemsg_rfc5424(const char *from, int pri, char *msg) +{ + const struct logtime *timestamp; + struct logtime timestamp_remote = { 0 }; + const char *omsg, *hostname, *app_name, *procid, *msgid, + *structured_data; + char line[MAXLINE + 1]; + +#define FAIL_IF(field, expr) do { \ + if (expr) { \ + dprintf("Failed to parse " field " from %s: %s\n", \ + from, omsg); \ + return; \ + } \ +} while (0) +#define PARSE_CHAR(field, sep) do { \ + FAIL_IF(field, *msg != sep); \ + ++msg; \ +} while (0) +#define IF_NOT_NILVALUE(var) \ + if (msg[0] == '-' && msg[1] == ' ') { \ + msg += 2; \ + var = NULL; \ + } else if (msg[0] == '-' && msg[1] == '\0') { \ + ++msg; \ + var = NULL; \ + } else + + omsg = msg; + IF_NOT_NILVALUE(timestamp) { + /* Parse RFC 3339-like timestamp. */ +#define PARSE_NUMBER(dest, length, min, max) do { \ + int i, v; \ + \ + v = 0; \ + for (i = 0; i < length; ++i) { \ + FAIL_IF("TIMESTAMP", *msg < '0' || *msg > '9'); \ + v = v * 10 + *msg++ - '0'; \ + } \ + FAIL_IF("TIMESTAMP", v < min || v > max); \ + dest = v; \ +} while (0) + /* Date and time. */ + PARSE_NUMBER(timestamp_remote.tm.tm_year, 4, 0, 9999); + timestamp_remote.tm.tm_year -= 1900; + PARSE_CHAR("TIMESTAMP", '-'); + PARSE_NUMBER(timestamp_remote.tm.tm_mon, 2, 1, 12); + --timestamp_remote.tm.tm_mon; + PARSE_CHAR("TIMESTAMP", '-'); + PARSE_NUMBER(timestamp_remote.tm.tm_mday, 2, 1, 31); + PARSE_CHAR("TIMESTAMP", 'T'); + PARSE_NUMBER(timestamp_remote.tm.tm_hour, 2, 0, 23); + PARSE_CHAR("TIMESTAMP", ':'); + PARSE_NUMBER(timestamp_remote.tm.tm_min, 2, 0, 59); + PARSE_CHAR("TIMESTAMP", ':'); + PARSE_NUMBER(timestamp_remote.tm.tm_sec, 2, 0, 59); + /* Perform normalization. */ + timegm(×tamp_remote.tm); + /* Optional: fractional seconds. */ + if (msg[0] == '.' && msg[1] >= '0' && msg[1] <= '9') { + int i; + + ++msg; + for (i = 100000; i != 0; i /= 10) { + if (*msg < '0' || *msg > '9') + break; + timestamp_remote.usec += (*msg++ - '0') * i; + } + } + /* Timezone. */ + if (*msg == 'Z') { + /* UTC. */ + ++msg; + } else { + int sign, tz_hour, tz_min; + + /* Local time zone offset. */ + FAIL_IF("TIMESTAMP", *msg != '-' && *msg != '+'); + sign = *msg++ == '-' ? -1 : 1; + PARSE_NUMBER(tz_hour, 2, 0, 23); + PARSE_CHAR("TIMESTAMP", ':'); + PARSE_NUMBER(tz_min, 2, 0, 59); + timestamp_remote.tm.tm_gmtoff = + sign * (tz_hour * 3600 + tz_min * 60); + } +#undef PARSE_NUMBER + PARSE_CHAR("TIMESTAMP", ' '); + timestamp = RemoteAddDate ? NULL : ×tamp_remote; + } + + /* String fields part of the HEADER. */ +#define PARSE_STRING(field, var) \ + IF_NOT_NILVALUE(var) { \ + var = msg; \ + while (*msg >= '!' && *msg <= '~') \ + ++msg; \ + FAIL_IF(field, var == msg); \ + PARSE_CHAR(field, ' '); \ + msg[-1] = '\0'; \ + } + PARSE_STRING("HOSTNAME", hostname); + PARSE_STRING("APP-NAME", app_name); + PARSE_STRING("PROCID", procid); + PARSE_STRING("MSGID", msgid); +#undef PARSE_STRING + + /* Structured data. */ +#define PARSE_SD_NAME() do { \ + const char *start; \ + \ + start = msg; \ + while (*msg >= '!' && *msg <= '~' && *msg != '=' && \ + *msg != ']' && *msg != '"') \ + ++msg; \ + FAIL_IF("STRUCTURED-NAME", start == msg); \ +} while (0) + IF_NOT_NILVALUE(structured_data) { + /* SD-ELEMENT. */ + while (*msg == '[') { + ++msg; + /* SD-ID. */ + PARSE_SD_NAME(); + /* SD-PARAM. */ + while (*msg == ' ') { + ++msg; + /* PARAM-NAME. */ + PARSE_SD_NAME(); + PARSE_CHAR("STRUCTURED-NAME", '='); + PARSE_CHAR("STRUCTURED-NAME", '"'); + while (*msg != '"') { + FAIL_IF("STRUCTURED-NAME", + *msg == '\0'); + if (*msg++ == '\\') { + FAIL_IF("STRUCTURED-NAME", + *msg == '\0'); + ++msg; + } + } + ++msg; + } + PARSE_CHAR("STRUCTURED-NAME", ']'); + } + PARSE_CHAR("STRUCTURED-NAME", ' '); + msg[-1] = '\0'; + } +#undef PARSE_SD_NAME + +#undef FAIL_IF +#undef PARSE_CHAR +#undef IF_NOT_NILVALUE + + parsemsg_remove_unsafe_characters(msg, line, sizeof(line)); + logmsg(pri, timestamp, from, app_name, procid, msgid, + structured_data, line, 0); +} + +/* + * Trims the application name ("TAG" in RFC 3164 terminology) and + * process ID from a message if present. + */ +static void +parsemsg_rfc3164_app_name_procid(char **msg, const char **app_name, + const char **procid) { + char *m, *app_name_begin, *procid_begin; + size_t app_name_length, procid_length; + + m = *msg; + + /* Application name. */ + app_name_begin = m; + app_name_length = strspn(m, + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789" + "_-"); + if (app_name_length == 0) + goto bad; + m += app_name_length; + + /* Process identifier (optional). */ + if (*m == '[') { + procid_begin = ++m; + procid_length = strspn(m, "0123456789"); + if (procid_length == 0) + goto bad; + m += procid_length; + if (*m++ != ']') + goto bad; + } else { + procid_begin = NULL; + procid_length = 0; + } + + /* Separator. */ + if (m[0] != ':' || m[1] != ' ') + goto bad; + + /* Split strings from input. */ + app_name_begin[app_name_length] = '\0'; + if (procid_begin != 0) + procid_begin[procid_length] = '\0'; + + *msg = m + 2; + *app_name = app_name_begin; + *procid = procid_begin; + return; +bad: + *app_name = NULL; + *procid = NULL; +} + +/* + * Parses a syslog message according to RFC 3164, assuming that PRI + * (i.e., "<%d>") has already been parsed by parsemsg(). The parsed + * result is passed to logmsg(). + */ +static void +parsemsg_rfc3164(const char *from, int pri, char *msg) +{ + struct tm tm_parsed; + const struct logtime *timestamp; + struct logtime timestamp_remote = { 0 }; + const char *app_name, *procid; + size_t i, msglen; + char line[MAXLINE + 1]; + + /* Parse the timestamp provided by the remote side. */ + if (strptime(msg, RFC3164_DATEFMT, &tm_parsed) != + msg + RFC3164_DATELEN || msg[RFC3164_DATELEN] != ' ') { + dprintf("Failed to parse TIMESTAMP from %s: %s\n", from, msg); + return; + } + msg += RFC3164_DATELEN + 1; + + if (!RemoteAddDate) { + struct tm tm_now; + time_t t_now; + int year; + + /* + * As the timestamp does not contain the year number, + * daylight saving time information, nor a time zone, + * attempt to infer it. Due to clock skews, the + * timestamp may even be part of the next year. Use the + * last year for which the timestamp is at most one week + * in the future. + * + * This loop can only run for at most three iterations + * before terminating. + */ + t_now = time(NULL); + localtime_r(&t_now, &tm_now); + for (year = tm_now.tm_year + 1;; --year) { + assert(year >= tm_now.tm_year - 1); + timestamp_remote.tm = tm_parsed; + timestamp_remote.tm.tm_year = year; + timestamp_remote.tm.tm_isdst = -1; + if (mktime(×tamp_remote.tm) < + t_now + 7 * 24 * 60 * 60) + break; + } + timestamp = ×tamp_remote; + } else + timestamp = NULL; + + /* + * A single space character MUST also follow the HOSTNAME field. + */ + msglen = strlen(msg); + for (i = 0; i < MIN(MAXHOSTNAMELEN, msglen); i++) { + if (msg[i] == ' ') { + if (RemoteHostname) { + msg[i] = '\0'; + from = msg; + } + msg += i + 1; + break; + } + /* + * Support non RFC compliant messages, without hostname. + */ + if (msg[i] == ':') + break; + } + if (i == MIN(MAXHOSTNAMELEN, msglen)) { + dprintf("Invalid HOSTNAME from %s: %s\n", from, msg); + return; + } + + /* Remove the TAG, if present. */ + parsemsg_rfc3164_app_name_procid(&msg, &app_name, &procid); + parsemsg_remove_unsafe_characters(msg, line, sizeof(line)); + logmsg(pri, timestamp, from, app_name, procid, NULL, NULL, line, 0); +} + +/* + * Takes a raw input line, extracts PRI and determines whether the + * message is formatted according to RFC 3164 or RFC 5424. Continues + * parsing of addition fields in the message according to those + * standards and prints the message on the appropriate log files. + */ +static void parsemsg(const char *from, char *msg) { - const char *timestamp; char *q; long n; - int i, c, pri, msglen; - char line[MAXLINE + 1]; + size_t i; + int pri; /* Parse PRI. */ if (msg[0] != '<' || !isdigit(msg[1])) { @@ -900,75 +1272,12 @@ parsemsg(const char *from, char *msg) if ((pri & LOG_FACMASK) == LOG_KERN && !KeepKernFac) pri = LOG_MAKEPRI(LOG_USER, LOG_PRI(pri)); - /* - * The TIMESTAMP field is the local time and is in the format of - * "Mmm dd hh:mm:ss" (without the quote marks). - * A single space character MUST follow the TIMESTAMP field. - * - * XXXGL: the check can be improved. - */ + /* Parse VERSION. */ msg += i + 1; - msglen = strlen(msg); - if (msglen < MAXDATELEN || msg[3] != ' ' || msg[6] != ' ' || - msg[9] != ':' || msg[12] != ':' || msg[15] != ' ') { - dprintf("Invalid TIMESTAMP from %s: %s\n", from, msg); - return; - } - - if (!RemoteAddDate) - timestamp = msg; + if (msg[0] == '1' && msg[1] == ' ') + parsemsg_rfc5424(from, pri, msg + 2); else - timestamp = NULL; - msg += MAXDATELEN; - msglen -= MAXDATELEN; - - /* - * A single space character MUST also follow the HOSTNAME field. - */ - for (i = 0; i < MIN(MAXHOSTNAMELEN, msglen); i++) { - if (msg[i] == ' ') { - if (RemoteHostname) { - msg[i] = '\0'; - from = msg; - } - msg += i + 1; - break; - } - /* - * Support non RFC compliant messages, without hostname. - */ - if (msg[i] == ':') - break; - } - if (i == MIN(MAXHOSTNAMELEN, msglen)) { - dprintf("Invalid HOSTNAME from %s: %s\n", from, msg); - return; - } - - q = line; - while ((c = (unsigned char)*msg++) != '\0' && - q < &line[sizeof(line) - 4]) { - if (mask_C1 && (c & 0x80) && c < 0xA0) { - c &= 0x7F; - *q++ = 'M'; - *q++ = '-'; - } - if (isascii(c) && iscntrl(c)) { - if (c == '\n') { - *q++ = ' '; - } else if (c == '\t') { - *q++ = '\t'; - } else { - *q++ = '^'; - *q++ = c ^ 0100; - } - } else { - *q++ = c; - } - } - *q = '\0'; - - logmsg(pri, timestamp, line, from, 0); + parsemsg_rfc3164(from, pri, msg); } /* @@ -1022,7 +1331,7 @@ printsys(char *msg) long n; int flags, isprintf, pri; - flags = ISKERNEL | SYNC_FILE; /* fsync after write */ + flags = SYNC_FILE; /* fsync after write */ p = msg; pri = DEFSPRI; isprintf = 1; @@ -1043,7 +1352,7 @@ printsys(char *msg) flags |= IGN_CONS; if (pri &~ (LOG_FACMASK|LOG_PRIMASK)) pri = DEFSPRI; - logmsg(pri, NULL, p, LocalHostName, flags); + logmsg(pri, NULL, LocalHostName, "kernel", NULL, NULL, NULL, p, flags); } static time_t now; @@ -1094,24 +1403,33 @@ skip_message(const char *name, const char *spec, int c } /* - * Log a message to the appropriate log files, users, etc. based on - * the priority. + * Logs a message to the appropriate log files, users, etc. based on the + * priority. Log messages are always formatted according to RFC 3164, + * even if they were in RFC 5424 format originally, The MSGID and + * STRUCTURED-DATA fields are thus discarded for the time being. */ static void -logmsg(int pri, const char *timestamp, const char *msg, const char *from, - int flags) +logmsg(int pri, const struct logtime *timestamp, const char *from, + const char *app_name, const char *procid, const char *msgid __unused, + const char *structured_data __unused, const char *msg, int flags) { + struct timeval tv; + struct logtime timestamp_now; struct filed *f; - int i, fac, msglen, prilev; - char prog[NAME_MAX+1]; + size_t msglen; + int fac, prilev; char buf[MAXLINE+1]; dprintf("logmsg: pri %o, flags %x, from %s, msg %s\n", pri, flags, from, msg); - (void)time(&now); - if (timestamp == NULL) - timestamp = ctime(&now) + 4; + (void)gettimeofday(&tv, NULL); + now = tv.tv_sec; + if (timestamp == NULL) { + localtime_r(&now, ×tamp_now.tm); + timestamp_now.usec = tv.tv_usec; + timestamp = ×tamp_now; + } /* extract facility and priority level */ if (flags & MARK) @@ -1125,22 +1443,17 @@ logmsg(int pri, const char *timestamp, const char *msg prilev = LOG_PRI(pri); - /* Extract TAG part of the message (usually program name). */ - for (i = 0; i < NAME_MAX; i++) { - if (!isprint(msg[i]) || msg[i] == ':' || msg[i] == '[' || - msg[i] == '/' || isspace(msg[i])) - break; - prog[i] = msg[i]; - } - prog[i] = 0; - - /* add kernel prefix for kernel messages */ - if (flags & ISKERNEL) { - snprintf(buf, sizeof(buf), "%s: %s", - use_bootfile ? bootfile : "kernel", msg); + /* Prepend the application name to the message if provided. */ + if (app_name != NULL) { + if (procid != NULL) + msglen = snprintf(buf, sizeof(buf), "%s[%s]: %s", + app_name, procid, msg); + else + msglen = snprintf(buf, sizeof(buf), "%s: %s", + app_name, msg); msg = buf; - } - msglen = strlen(msg); + } else + msglen = strlen(msg); /* log the message to the particular outputs */ if (!Initialized) { @@ -1152,8 +1465,7 @@ logmsg(int pri, const char *timestamp, const char *msg f->f_file = open(ctty, O_WRONLY | O_NONBLOCK, 0); if (f->f_file >= 0) { - (void)strlcpy(f->f_lasttime, timestamp, - sizeof(f->f_lasttime)); + f->f_lasttime = *timestamp; fprintlog(f, flags, msg); close(f->f_file); f->f_file = -1; @@ -1174,7 +1486,8 @@ logmsg(int pri, const char *timestamp, const char *msg continue; /* skip messages with the incorrect program name */ - if (skip_message(prog, f->f_program, 1)) + if (skip_message(app_name == NULL ? "" : app_name, + f->f_program, 1)) continue; /* skip message to console if it has already been printed */ @@ -1192,8 +1505,7 @@ logmsg(int pri, const char *timestamp, const char *msg (flags & MARK) == 0 && msglen == f->f_prevlen && !strcmp(msg, f->f_prevline) && !strcasecmp(from, f->f_prevhost)) { - (void)strlcpy(f->f_lasttime, timestamp, - sizeof(f->f_lasttime)); + f->f_lasttime = *timestamp; f->f_prevcount++; dprintf("msg repeated %d times, %ld sec of %d\n", f->f_prevcount, (long)(now - f->f_time), @@ -1214,8 +1526,7 @@ logmsg(int pri, const char *timestamp, const char *msg fprintlog(f, 0, (char *)NULL); f->f_repeatcount = 0; f->f_prevpri = pri; - (void)strlcpy(f->f_lasttime, timestamp, - sizeof(f->f_lasttime)); + f->f_lasttime = *timestamp; (void)strlcpy(f->f_prevhost, from, sizeof(f->f_prevhost)); if (msglen < MAXSVLINE) { @@ -1254,8 +1565,12 @@ fprintlog(struct filed *f, int flags, const char *msg) int l, lsent = 0; char line[MAXLINE + 1], repbuf[80], greetings[200], *wmsg = NULL; char nul[] = "", space[] = " ", lf[] = "\n", crlf[] = "\r\n"; + char timebuf[RFC3164_DATELEN + 1]; const char *msgret; + if (strftime(timebuf, sizeof(timebuf), RFC3164_DATEFMT, + &f->f_lasttime.tm) == 0) + timebuf[0] = '\0'; if (f->f_type == F_WALL) { /* The time displayed is not synchornized with the other log * destinations (like messages). Following fragment was using @@ -1267,7 +1582,7 @@ fprintlog(struct filed *f, int flags, const char *msg) .iov_len = snprintf(greetings, sizeof(greetings), "\r\n\7Message from syslogd@%s " "at %.24s ...\r\n", - f->f_prevhost, f->f_lasttime) + f->f_prevhost, timebuf) }; if (iov[0].iov_len >= sizeof(greetings)) iov[0].iov_len = sizeof(greetings) - 1; @@ -1277,8 +1592,8 @@ fprintlog(struct filed *f, int flags, const char *msg) }; } else { iov[0] = (struct iovec){ - .iov_base = f->f_lasttime, - .iov_len = strlen(f->f_lasttime) + .iov_base = timebuf, + .iov_len = strlen(timebuf) }; iov[1] = (struct iovec){ .iov_base = space, @@ -1690,7 +2005,8 @@ logerror(const char *type) (void)snprintf(buf, sizeof buf, "syslogd: %s", type); errno = 0; dprintf("%s\n", buf); - logmsg(LOG_SYSLOG|LOG_ERR, NULL, buf, LocalHostName, 0); + logmsg(LOG_SYSLOG|LOG_ERR, NULL, LocalHostName, NULL, NULL, NULL, + NULL, buf, 0); recursed--; } @@ -2037,7 +2353,8 @@ init(int signo) } } - logmsg(LOG_SYSLOG|LOG_INFO, NULL, "syslogd: restart", LocalHostName, 0); + logmsg(LOG_SYSLOG|LOG_INFO, NULL, LocalHostName, NULL, NULL, NULL, + NULL, "syslogd: restart", 0); dprintf("syslogd: restarted\n"); /* * Log a change in hostname, but only on a restart. @@ -2046,7 +2363,8 @@ init(int signo) (void)snprintf(hostMsg, sizeof(hostMsg), "syslogd: hostname changed, \"%s\" to \"%s\"", oldLocalHostName, LocalHostName); - logmsg(LOG_SYSLOG|LOG_INFO, NULL, hostMsg, LocalHostName, 0); + logmsg(LOG_SYSLOG|LOG_INFO, NULL, LocalHostName, NULL, NULL, + NULL, NULL, hostMsg, 0); dprintf("%s\n", hostMsg); } /* @@ -2056,7 +2374,8 @@ init(int signo) if (signo == 0 && !use_bootfile) { (void)snprintf(bootfileMsg, sizeof(bootfileMsg), "syslogd: kernel boot file is %s", bootfile); - logmsg(LOG_KERN|LOG_INFO, NULL, bootfileMsg, LocalHostName, 0); + logmsg(LOG_KERN|LOG_INFO, NULL, LocalHostName, NULL, NULL, + NULL, NULL, bootfileMsg, 0); dprintf("%s\n", bootfileMsg); } } @@ -2365,7 +2684,8 @@ markit(void) now = time((time_t *)NULL); MarkSeq += TIMERINTVL; if (MarkSeq >= MarkInterval) { - logmsg(LOG_INFO, NULL, "-- MARK --", LocalHostName, MARK); + logmsg(LOG_INFO, NULL, LocalHostName, NULL, NULL, NULL, NULL, + "-- MARK --", MARK); MarkSeq = 0; } From owner-svn-src-head@freebsd.org Fri Apr 6 13:00:46 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65B1FF839CA; Fri, 6 Apr 2018 13:00:46 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 117D27A179; Fri, 6 Apr 2018 13:00:46 +0000 (UTC) (envelope-from ed@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 08284120B4; Fri, 6 Apr 2018 13:00:46 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36D0jFo025334; Fri, 6 Apr 2018 13:00:45 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36D0jTT025330; Fri, 6 Apr 2018 13:00:45 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201804061300.w36D0jTT025330@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Fri, 6 Apr 2018 13:00:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332100 - in head: . lib/libc/gen sys/sys X-SVN-Group: head X-SVN-Commit-Author: ed X-SVN-Commit-Paths: in head: . lib/libc/gen sys/sys X-SVN-Commit-Revision: 332100 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 13:00:46 -0000 Author: ed Date: Fri Apr 6 13:00:45 2018 New Revision: 332100 URL: https://svnweb.freebsd.org/changeset/base/332100 Log: Let syslog(3) use RFC 5424. With r332099 changing syslogd(8) to parse RFC 5424 formatted syslog messages, go ahead and also change the syslog(3) libc function to generate them. Compared to RFC 3164, RFC 5424 has various advantages, such as sub-second precision for log entry timestamps. As this change could have adverse effects when not updating syslogd(8) or using a different system logging daemon, add a notice to UPDATING and increase __FreeBSD_version. Differential Revision: https://reviews.freebsd.org/D14926 Modified: head/UPDATING head/lib/libc/gen/syslog.3 head/lib/libc/gen/syslog.c head/sys/sys/param.h Modified: head/UPDATING ============================================================================== --- head/UPDATING Fri Apr 6 12:57:01 2018 (r332099) +++ head/UPDATING Fri Apr 6 13:00:45 2018 (r332100) @@ -51,6 +51,45 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW: ****************************** SPECIAL WARNING: ****************************** +20180406: + In addition to supporting RFC 3164 formatted messages, the + syslogd(8) service is now capable of parsing RFC 5424 formatted + log messages. The main benefit of using RFC 5424 is that clients + may now send log messages with timestamps containing year numbers, + microseconds and time zone offsets. + + Similarly, the syslog(3) C library function has been altered to + send RFC 5424 formatted messages to the local system logging + daemon. On systems using syslogd(8), this change should have no + negative impact, as long as syslogd(8) and the C library are + updated at the same time. On systems using a different system + logging daemon, it may be necessary to make configuration + adjustments, depending on the software used. + + When using syslog-ng, add the 'syslog-protocol' flag to local + input sources to enable parsing of RFC 5424 formatted messages: + + source src { + unix-dgram("/var/run/log" flags(syslog-protocol)); + } + + When using rsyslog, disable the 'SysSock.UseSpecialParser' option + of the 'imuxsock' module to let messages be processed by the + regular RFC 3164/5424 parsing pipeline: + + module(load="imuxsock" SysSock.UseSpecialParser="off") + + Do note that these changes only affect communication between local + applications and syslogd(8). The format that syslogd(8) uses to + store messages on disk or forward messages to other systems + remains unchanged. syslogd(8) still uses RFC 3164 for these + purposes. Options to customize this behaviour will be added in the + future. Utilities that process log files stored in /var/log are + thus expected to continue to function as before. + + __FreeBSD_version has been incremented to 1200061 to denote this + change. + 20180328: Support for token ring networks has been removed. If you have "device token" in your kernel config you should remove Modified: head/lib/libc/gen/syslog.3 ============================================================================== --- head/lib/libc/gen/syslog.3 Fri Apr 6 12:57:01 2018 (r332099) +++ head/lib/libc/gen/syslog.3 Fri Apr 6 13:00:45 2018 (r332100) @@ -28,7 +28,7 @@ .\" @(#)syslog.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd November 5, 2017 +.Dd April 6, 2018 .Dt SYSLOG 3 .Os .Sh NAME @@ -156,6 +156,9 @@ Write the message to standard error output as well to .It Dv LOG_PID Log the process id with each message: useful for identifying instantiations of daemons. +On +.Fx , +this option is enabled by default. .El .Pp The Modified: head/lib/libc/gen/syslog.c ============================================================================== --- head/lib/libc/gen/syslog.c Fri Apr 6 12:57:01 2018 (r332099) +++ head/lib/libc/gen/syslog.c Fri Apr 6 13:00:45 2018 (r332100) @@ -36,9 +36,10 @@ static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/ __FBSDID("$FreeBSD$"); #include "namespace.h" -#include +#include #include #include +#include #include #include #include @@ -134,11 +135,13 @@ syslog(int pri, const char *fmt, ...) static void vsyslog1(int pri, const char *fmt, va_list ap) { - int cnt; + struct timeval now; + struct tm tm; char ch, *p; - time_t now; - int fd, saved_errno; - char *stdp, tbuf[2048], fmt_cpy[1024], timbuf[26], errstr[64]; + long tz_offset; + int cnt, fd, saved_errno; + char hostname[MAXHOSTNAMELEN], *stdp, tbuf[2048], fmt_cpy[1024], + errstr[64], tz_sign; FILE *fp, *fmt_fp; struct bufcookie tbuf_cookie; struct bufcookie fmt_cookie; @@ -168,24 +171,46 @@ vsyslog1(int pri, const char *fmt, va_list ap) if (fp == NULL) return; - /* Build the message. */ - (void)time(&now); - (void)fprintf(fp, "<%d>", pri); - (void)fprintf(fp, "%.15s ", ctime_r(&now, timbuf) + 4); + /* Build the message according to RFC 5424. Tag and version. */ + (void)fprintf(fp, "<%d>1 ", pri); + /* Timestamp similar to RFC 3339. */ + if (gettimeofday(&now, NULL) == 0 && + localtime_r(&now.tv_sec, &tm) != NULL) { + if (tm.tm_gmtoff < 0) { + tz_sign = '-'; + tz_offset = -tm.tm_gmtoff; + } else { + tz_sign = '+'; + tz_offset = tm.tm_gmtoff; + } + + (void)fprintf(fp, + "%04d-%02d-%02d" /* Date. */ + "T%02d:%02d:%02d.%06ld" /* Time. */ + "%c%02ld:%02ld ", /* Time zone offset. */ + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec, now.tv_usec, + tz_sign, tz_offset / 3600, (tz_offset % 3600) / 60); + } else + (void)fprintf(fp, "- "); + /* Hostname. */ + (void)gethostname(hostname, sizeof(hostname)); + (void)fprintf(fp, "%s ", hostname); if (LogStat & LOG_PERROR) { /* Transfer to string buffer */ (void)fflush(fp); stdp = tbuf + (sizeof(tbuf) - tbuf_cookie.left); } + /* + * Application name, process ID, message ID and structured data. + * Provide the process ID regardless of whether LOG_PID has been + * specified, as it provides valuable information. Many + * applications tend not to use this, even though they should. + */ if (LogTag == NULL) LogTag = _getprogname(); - if (LogTag != NULL) - (void)fprintf(fp, "%s", LogTag); - if (LogStat & LOG_PID) - (void)fprintf(fp, "[%d]", getpid()); - if (LogTag != NULL) { - (void)fprintf(fp, ": "); - } + (void)fprintf(fp, "%s %d - - ", + LogTag == NULL ? "-" : LogTag, getpid()); /* Check to see if we can skip expanding the %m */ if (strstr(fmt, "%m")) { @@ -313,7 +338,7 @@ vsyslog1(int pri, const char *fmt, va_list ap) struct iovec iov[2]; struct iovec *v = iov; - p = strchr(tbuf, '>') + 1; + p = strchr(tbuf, '>') + 3; v->iov_base = p; v->iov_len = cnt - (p - tbuf); ++v; Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Fri Apr 6 12:57:01 2018 (r332099) +++ head/sys/sys/param.h Fri Apr 6 13:00:45 2018 (r332100) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1200060 /* Master, propagated to newvers */ +#define __FreeBSD_version 1200061 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-head@freebsd.org Fri Apr 6 14:14:45 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DD34CF892CD; Fri, 6 Apr 2018 14:14:44 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io0-f177.google.com (mail-io0-f177.google.com [209.85.223.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 758EA7DD0E; Fri, 6 Apr 2018 14:14:44 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io0-f177.google.com with SMTP id q84so1881914iod.10; Fri, 06 Apr 2018 07:14:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-transfer-encoding; bh=irA4GjPiFiZC7KoHIIrWxrGK6s9LmizbzmR/8/6+GHs=; b=j1ySjlSGyUljKf/Pmgf7TGNhps9hq1KmSggkH8np0n+UebxcyUeL6/3BWo4Nv5Pn15 w7ZgdPsKc5QO6kd6V11KfcyI1PNJNJftw+8p5xdavaA4FphirVunTaLWUrpeQy7n2Nuk TVI/Sx3aFyR6Ung98ZHuuQc5UF5LICXrfMvoF7pbSQA68lByxKstN7AGPqhJGoIeK6yS smZY+6gYB7bTBlYLj/sB8iPaCCcgJfhCPLX5Nb5zGk6LONyV7GgY4L2yEQ6ndD6UsVxE DU4DVnn0N6hsicVTxcCpC6ocVTRlD6lqC3B0j0DrARVUqFmfvMNemT2bEHA93AejUu+t EVZw== X-Gm-Message-State: AElRT7FjDPYKEjvo4art1+qR0RNxvPBP8xAmDYt2m655qTwUJ4/CyGWt P/aIzAjYgsCrxmw2PabCom7vMwwr X-Google-Smtp-Source: AIpwx49OOZK0cXRjfIDoisalc4Wj0kfG2luanaN/jGzDKmntgHgKpEqgan/UKrBbIbQIpvHgpu0pBQ== X-Received: by 10.107.179.134 with SMTP id c128mr24675656iof.278.1523024083289; Fri, 06 Apr 2018 07:14:43 -0700 (PDT) Received: from mail-io0-f181.google.com (mail-io0-f181.google.com. [209.85.223.181]) by smtp.gmail.com with ESMTPSA id v128-v6sm4747364itg.14.2018.04.06.07.14.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Apr 2018 07:14:42 -0700 (PDT) Received: by mail-io0-f181.google.com with SMTP id q80so1873184ioi.13; Fri, 06 Apr 2018 07:14:42 -0700 (PDT) X-Received: by 10.107.181.72 with SMTP id e69mr25449815iof.267.1523024082688; Fri, 06 Apr 2018 07:14:42 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.2.62.19 with HTTP; Fri, 6 Apr 2018 07:14:42 -0700 (PDT) In-Reply-To: <201804061120.w36BK6s6074635@repo.freebsd.org> References: <201804061120.w36BK6s6074635@repo.freebsd.org> From: Conrad Meyer Date: Fri, 6 Apr 2018 07:14:42 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r332092 - in head/sys: amd64/amd64 sys x86/x86 To: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 14:14:45 -0000 I like something like this for clarity. But I don't see any reason for these function-like macros instead of the more general definition of an SI prefix constant multiple. A multiple works with numeric literals and variables alike. Something like: #define GiB ((size_t)1 << 30) my_foo =3D 15 * GiB; (There's nothing byte-specific about SI prefixes, but "Gi" alone is a worse name. Arguably, size_t is wrong for quantities of bytes on 32-bit platforms with 64-bit off_t.) The compiler will still reduce constant expressions. Perhaps even better, conversion away is straightforward units math, and the compiler can still do the clever thing with right shifts: my_gb =3D howmany(my_foo, GiB); //or my_gb =3D my_foo / GiB; Unfortunately, I expect a lot of code to already have defines or variables with conflicting names, so I'm not sure adding these names to primary headers is viable as-is. Best, Conrad On Fri, Apr 6, 2018 at 4:20 AM, Roger Pau Monn=C3=A9 w= rote: > Author: royger > Date: Fri Apr 6 11:20:06 2018 > New Revision: 332092 > URL: https://svnweb.freebsd.org/changeset/base/332092 > > Log: > remove GiB/MiB macros from param.h > > And instead define them in the files where they are used. > > Requested by: bde > > Modified: > head/sys/amd64/amd64/mp_machdep.c > head/sys/sys/param.h > head/sys/x86/x86/mp_x86.c > > Modified: head/sys/amd64/amd64/mp_machdep.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/amd64/amd64/mp_machdep.c Fri Apr 6 09:25:08 2018 (= r332091) > +++ head/sys/amd64/amd64/mp_machdep.c Fri Apr 6 11:20:06 2018 (= r332092) > @@ -83,6 +83,8 @@ __FBSDID("$FreeBSD$"); > #define BIOS_RESET (0x0f) > #define BIOS_WARM (0x0a) > > +#define GiB(v) (v ## ULL << 30) > + > extern struct pcpu __pcpu[]; > > /* Temporary variables for init_secondary() */ > > Modified: head/sys/sys/param.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/sys/param.h Fri Apr 6 09:25:08 2018 (r332091) > +++ head/sys/sys/param.h Fri Apr 6 11:20:06 2018 (r332092) > @@ -362,8 +362,4 @@ __END_DECLS > */ > #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[off= set]) > > -/* Unit conversion macros. */ > -#define GiB(v) (v ## ULL << 30) > -#define MiB(v) (v ## ULL << 20) > - > #endif /* _SYS_PARAM_H_ */ > > Modified: head/sys/x86/x86/mp_x86.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/x86/x86/mp_x86.c Fri Apr 6 09:25:08 2018 (r332091) > +++ head/sys/x86/x86/mp_x86.c Fri Apr 6 11:20:06 2018 (r332092) > @@ -160,6 +160,8 @@ struct cache_info { > > unsigned int boot_address; > > +#define MiB(v) (v ## ULL << 20) > + > void > mem_range_AP_init(void) > { > From owner-svn-src-head@freebsd.org Fri Apr 6 15:01:46 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 836D9F8C29B; Fri, 6 Apr 2018 15:01:46 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 320217F97A; Fri, 6 Apr 2018 15:01:46 +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 2CE4D1357A; Fri, 6 Apr 2018 15:01:46 +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 w36F1kjs086081; Fri, 6 Apr 2018 15:01:46 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36F1kaq086080; Fri, 6 Apr 2018 15:01:46 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201804061501.w36F1kaq086080@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Fri, 6 Apr 2018 15:01:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332101 - head/sys/netpfil/pf X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: head/sys/netpfil/pf X-SVN-Commit-Revision: 332101 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 15:01:46 -0000 Author: kp Date: Fri Apr 6 15:01:45 2018 New Revision: 332101 URL: https://svnweb.freebsd.org/changeset/base/332101 Log: pf: Improve ioctl validation for DIOCRADDTABLES and DIOCRDELTABLES The DIOCRADDTABLES and DIOCRDELTABLES ioctls can process a number of tables at a time, and as such try to allocate * sizeof(struct pfr_table). This multiplication can overflow. Thanks to mallocarray() this is not exploitable, but an overflow does panic the system. Arbitrarily limit this to 65535 tables. pfctl only ever processes one table at a time, so it presents no issues there. MFC after: 1 week Modified: head/sys/netpfil/pf/pf_ioctl.c Modified: head/sys/netpfil/pf/pf_ioctl.c ============================================================================== --- head/sys/netpfil/pf/pf_ioctl.c Fri Apr 6 13:00:45 2018 (r332100) +++ head/sys/netpfil/pf/pf_ioctl.c Fri Apr 6 15:01:45 2018 (r332101) @@ -89,6 +89,8 @@ __FBSDID("$FreeBSD$"); #include #endif +#define PF_TABLES_MAX_REQUEST 65535 /* Maximum tables per request. */ + static struct pf_pool *pf_get_pool(char *, u_int32_t, u_int8_t, u_int32_t, u_int8_t, u_int8_t, u_int8_t); @@ -2530,13 +2532,15 @@ DIOCCHANGEADDR_error: error = ENODEV; break; } - totlen = io->pfrio_size * sizeof(struct pfr_table); - pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), - M_TEMP, M_WAITOK); - if (! pfrts) { + + if (io->pfrio_size < 0 || io->pfrio_size > PF_TABLES_MAX_REQUEST) { error = ENOMEM; break; } + + totlen = io->pfrio_size * sizeof(struct pfr_table); + pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), + M_TEMP, M_WAITOK); error = copyin(io->pfrio_buffer, pfrts, totlen); if (error) { free(pfrts, M_TEMP); @@ -2559,13 +2563,15 @@ DIOCCHANGEADDR_error: error = ENODEV; break; } - totlen = io->pfrio_size * sizeof(struct pfr_table); - pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), - M_TEMP, M_WAITOK); - if (! pfrts) { + + if (io->pfrio_size < 0 || io->pfrio_size > PF_TABLES_MAX_REQUEST) { error = ENOMEM; break; } + + totlen = io->pfrio_size * sizeof(struct pfr_table); + pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), + M_TEMP, M_WAITOK); error = copyin(io->pfrio_buffer, pfrts, totlen); if (error) { free(pfrts, M_TEMP); From owner-svn-src-head@freebsd.org Fri Apr 6 15:03:49 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 37A9AF8C5EE; Fri, 6 Apr 2018 15:03:49 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D99ED7FD57; Fri, 6 Apr 2018 15:03:48 +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 D48E8135B8; Fri, 6 Apr 2018 15:03:48 +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 w36F3mi2089265; Fri, 6 Apr 2018 15:03:48 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36F3mfD089261; Fri, 6 Apr 2018 15:03:48 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201804061503.w36F3mfD089261@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Fri, 6 Apr 2018 15:03:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332102 - in head: etc/mtree tests/sys/netpfil/pf tests/sys/netpfil/pf/ioctl X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: in head: etc/mtree tests/sys/netpfil/pf tests/sys/netpfil/pf/ioctl X-SVN-Commit-Revision: 332102 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 15:03:49 -0000 Author: kp Date: Fri Apr 6 15:03:48 2018 New Revision: 332102 URL: https://svnweb.freebsd.org/changeset/base/332102 Log: pf tests: Basic ioctl validation tests Validate the DIOCRADDTABLES and DIOCRDELTABLES ioctls with invalid size values. All of these requests should fail. MFC after: 1 week Added: head/tests/sys/netpfil/pf/ioctl/ head/tests/sys/netpfil/pf/ioctl/Makefile (contents, props changed) head/tests/sys/netpfil/pf/ioctl/validation.c (contents, props changed) Modified: head/etc/mtree/BSD.tests.dist head/tests/sys/netpfil/pf/Makefile Modified: head/etc/mtree/BSD.tests.dist ============================================================================== --- head/etc/mtree/BSD.tests.dist Fri Apr 6 15:01:45 2018 (r332101) +++ head/etc/mtree/BSD.tests.dist Fri Apr 6 15:03:48 2018 (r332102) @@ -742,6 +742,8 @@ .. netpfil pf + ioctl + .. .. .. opencrypto Modified: head/tests/sys/netpfil/pf/Makefile ============================================================================== --- head/tests/sys/netpfil/pf/Makefile Fri Apr 6 15:01:45 2018 (r332101) +++ head/tests/sys/netpfil/pf/Makefile Fri Apr 6 15:03:48 2018 (r332102) @@ -3,6 +3,7 @@ PACKAGE= tests TESTSDIR= ${TESTSBASE}/sys/netpfil/pf +TESTS_SUBDIRS+= ioctl ATF_TESTS_SH+= pass_block \ forward \ Added: head/tests/sys/netpfil/pf/ioctl/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/netpfil/pf/ioctl/Makefile Fri Apr 6 15:03:48 2018 (r332102) @@ -0,0 +1,10 @@ +# $FreeBSD$ + +PACKAGE= tests + +TESTSDIR= ${TESTSBASE}/sys/netpfil/pf/ioctl + +ATF_TESTS_C += \ + validation + +.include Added: head/tests/sys/netpfil/pf/ioctl/validation.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/netpfil/pf/ioctl/validation.c Fri Apr 6 15:03:48 2018 (r332102) @@ -0,0 +1,130 @@ +/*- + * Copyright (c) 2018 Kristof Provost + * + * 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$ + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include + +static int dev; + +#define COMMON_HEAD() \ + if (modfind("pf") == -1) \ + atf_tc_skip("pf not loaded"); \ + dev = open("/dev/pf", O_RDWR); \ + if (dev == -1) \ + atf_tc_skip("Failed to open /dev/pf"); + +#define COMMON_CLEANUP() \ + close(dev); + +ATF_TC_WITHOUT_HEAD(addtables); +ATF_TC_BODY(addtables, tc) +{ + struct pfioc_table io; + struct pfr_table tbl; + int flags; + + COMMON_HEAD(); + + flags = 0; + + bzero(&io, sizeof(io)); + io.pfrio_flags = flags; + io.pfrio_buffer = &tbl; + io.pfrio_esize = sizeof(tbl); + + /* Negative size */ + io.pfrio_size = -1; + if (ioctl(dev, DIOCRADDTABLES, &io) == 0) + atf_tc_fail("Request with size -1 succeeded"); + + /* Overly large size */ + io.pfrio_size = 1 << 24; + if (ioctl(dev, DIOCRADDTABLES, &io) == 0) + atf_tc_fail("Request with size 1 << 24 succeeded"); + + /* NULL buffer */ + io.pfrio_size = 1; + io.pfrio_buffer = NULL; + if (ioctl(dev, DIOCRADDTABLES, &io) == 0) + atf_tc_fail("Request with NULL buffer succeeded"); + + COMMON_CLEANUP(); +} + +ATF_TC_WITHOUT_HEAD(deltables); +ATF_TC_BODY(deltables, tc) +{ + struct pfioc_table io; + struct pfr_table tbl; + int flags; + + COMMON_HEAD(); + + flags = 0; + + bzero(&io, sizeof(io)); + io.pfrio_flags = flags; + io.pfrio_buffer = &tbl; + io.pfrio_esize = sizeof(tbl); + + /* Negative size */ + io.pfrio_size = -1; + if (ioctl(dev, DIOCRDELTABLES, &io) == 0) + atf_tc_fail("Request with size -1 succeeded"); + + /* Overly large size */ + io.pfrio_size = 1 << 24; + if (ioctl(dev, DIOCRDELTABLES, &io) == 0) + atf_tc_fail("Request with size 1 << 24 succeeded"); + + /* NULL buffer */ + io.pfrio_size = 1; + io.pfrio_buffer = NULL; + if (ioctl(dev, DIOCRDELTABLES, &io) == 0) + atf_tc_fail("Request with NULL buffer succeeded"); + + COMMON_CLEANUP(); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, addtables); + ATF_TP_ADD_TC(tp, deltables); + + return (atf_no_error()); +} From owner-svn-src-head@freebsd.org Fri Apr 6 15:15:21 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C2699F8D4C1; Fri, 6 Apr 2018 15:15:21 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 70B9F80B2B; Fri, 6 Apr 2018 15:15:21 +0000 (UTC) (envelope-from jtl@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 6B7ED137B6; Fri, 6 Apr 2018 15:15:21 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36FFL8O094387; Fri, 6 Apr 2018 15:15:21 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36FFLR8094386; Fri, 6 Apr 2018 15:15:21 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201804061515.w36FFLR8094386@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Fri, 6 Apr 2018 15:15:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332104 - head/sys/dev/ipmi X-SVN-Group: head X-SVN-Commit-Author: jtl X-SVN-Commit-Paths: head/sys/dev/ipmi X-SVN-Commit-Revision: 332104 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 15:15:21 -0000 Author: jtl Date: Fri Apr 6 15:15:21 2018 New Revision: 332104 URL: https://svnweb.freebsd.org/changeset/base/332104 Log: In cases where an application issues certain IPMI commands at a high enough rate, the IPMI code can print large numbers of messages to the console, such as: ipmi0: KCS: Failed to read completion code ipmi0: KCS error: ff ipmi0: KCS: Failed to read completion code ipmi0: KCS error: ff These seem to be innocuous from a system standpoint, and the user- space code can deal with the failures. Therefore, suppress printing these messages to the console unless bootverbose is enabled. Obtained from: Netflix, Inc. Modified: head/sys/dev/ipmi/ipmi_kcs.c Modified: head/sys/dev/ipmi/ipmi_kcs.c ============================================================================== --- head/sys/dev/ipmi/ipmi_kcs.c Fri Apr 6 15:09:30 2018 (r332103) +++ head/sys/dev/ipmi/ipmi_kcs.c Fri Apr 6 15:15:21 2018 (r332104) @@ -150,7 +150,7 @@ kcs_error(struct ipmi_softc *sc) /* Read error status */ data = INB(sc, KCS_DATA); - if (data != 0) + if (data != 0 && (data != 0xff || bootverbose)) device_printf(sc->ipmi_dev, "KCS error: %02x\n", data); @@ -416,8 +416,10 @@ kcs_polled_request(struct ipmi_softc *sc, struct ipmi_ /* Next we read the completion code. */ if (kcs_read_byte(sc, &req->ir_compcode) != 1) { - device_printf(sc->ipmi_dev, - "KCS: Failed to read completion code\n"); + if (bootverbose) { + device_printf(sc->ipmi_dev, + "KCS: Failed to read completion code\n"); + } goto fail; } #ifdef KCS_DEBUG From owner-svn-src-head@freebsd.org Fri Apr 6 15:17:10 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6A363F8D750; Fri, 6 Apr 2018 15:17:10 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DE0F380D71; Fri, 6 Apr 2018 15:17:09 +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 D89D7137BF; Fri, 6 Apr 2018 15:17:09 +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 w36FH9pI094492; Fri, 6 Apr 2018 15:17:09 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36FH9Xv094491; Fri, 6 Apr 2018 15:17:09 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201804061517.w36FH9Xv094491@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Fri, 6 Apr 2018 15:17:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332105 - head/sys/arm/allwinner X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/arm/allwinner X-SVN-Commit-Revision: 332105 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 15:17:10 -0000 Author: kevans Date: Fri Apr 6 15:17:09 2018 New Revision: 332105 URL: https://svnweb.freebsd.org/changeset/base/332105 Log: aw_sid(4): Use prctl read for all reads when it's required It was later found that some operation on the OrangePi one will cause direct accesses to the eeprom to return wrong data again, so reading it all once via prctl at attach time is no longer sufficient. Modified: head/sys/arm/allwinner/aw_sid.c Modified: head/sys/arm/allwinner/aw_sid.c ============================================================================== --- head/sys/arm/allwinner/aw_sid.c Fri Apr 6 15:15:21 2018 (r332104) +++ head/sys/arm/allwinner/aw_sid.c Fri Apr 6 15:17:09 2018 (r332105) @@ -61,8 +61,11 @@ __FBSDID("$FreeBSD$"); #define SID_RDKEY 0x60 #define SID_SRAM 0x200 -#define SID_THERMAL_CALIB0 (SID_SRAM + 0x34) -#define SID_THERMAL_CALIB1 (SID_SRAM + 0x38) +/* Offsets into efuse space, for convenience */ +#define SID_THERMAL_CALIB0_OFF (0x34) +#define SID_THERMAL_CALIB1_OFF (0x38) +#define SID_THERMAL_CALIB0 (SID_SRAM + SID_THERMAL_CALIB0_OFF) +#define SID_THERMAL_CALIB1 (SID_SRAM + SID_THERMAL_CALIB1_OFF) #define ROOT_KEY_SIZE 4 @@ -116,6 +119,7 @@ static struct ofw_compat_data compat_data[] = { }; struct aw_sid_softc { + device_t sid_dev; struct resource *res; struct aw_sid_conf *sid_conf; struct mtx prctl_mtx; @@ -135,6 +139,8 @@ enum sid_keys { #define RD4(sc, reg) bus_read_4((sc)->res, (reg)) #define WR4(sc, reg, val) bus_write_4((sc)->res, (reg), (val)) +#define PRCTL_RD4(sc, reg, val) aw_sid_prctl_read((sc)->sid_dev, (reg), (val)) + static int aw_sid_sysctl(SYSCTL_HANDLER_ARGS); static int aw_sid_prctl_read(device_t dev, bus_size_t offset, uint32_t *val); @@ -183,10 +189,9 @@ static int aw_sid_attach(device_t dev) { struct aw_sid_softc *sc; - bus_size_t i; - uint32_t val; sc = device_get_softc(dev); + sc->sid_dev = dev; if (bus_alloc_resources(dev, aw_sid_spec, &sc->res) != 0) { device_printf(dev, "cannot allocate resources for device\n"); @@ -197,19 +202,6 @@ aw_sid_attach(device_t dev) sc->sid_conf = (struct aw_sid_conf *)ofw_bus_search_compatible(dev, compat_data)->ocd_data; aw_sid_sc = sc; - /* - * This set of reads is solely for working around a silicon bug on some - * SoC that require a prctl read in order for direct register access to - * return a non-garbled value. Hence, the values we read are simply - * ignored. - */ - if (sc->sid_conf->requires_prctl_read) - for (i = 0; i < sc->sid_conf->efuse_size; i += 4) - if (aw_sid_prctl_read(dev, i, &val) != 0) { - device_printf(dev, "failed prctl read\n"); - goto fail; - } - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "rootkey", @@ -217,11 +209,6 @@ aw_sid_attach(device_t dev) dev, AW_SID_ROOT_KEY, aw_sid_sysctl, "A", "Root Key"); return (0); - -fail: - bus_release_resources(dev, aw_sid_spec, &sc->res); - mtx_destroy(&sc->prctl_mtx); - return (ENXIO); } int @@ -235,8 +222,13 @@ aw_sid_read_tscalib(uint32_t *calib0, uint32_t *calib1 if (!sc->sid_conf->has_thermal) return (ENXIO); - *calib0 = RD4(sc, SID_THERMAL_CALIB0); - *calib1 = RD4(sc, SID_THERMAL_CALIB1); + if (sc->sid_conf->requires_prctl_read) { + PRCTL_RD4(sc, SID_THERMAL_CALIB0_OFF, calib0); + PRCTL_RD4(sc, SID_THERMAL_CALIB1_OFF, calib1); + } else { + *calib0 = RD4(sc, SID_THERMAL_CALIB0); + *calib1 = RD4(sc, SID_THERMAL_CALIB1); + } return (0); } @@ -254,7 +246,10 @@ aw_sid_get_rootkey(u_char *out) return (ENXIO); root_key_off = aw_sid_sc->sid_conf->rootkey_offset; for (i = 0; i < ROOT_KEY_SIZE ; i++) { - tmp = RD4(aw_sid_sc, root_key_off + (i * 4)); + if (sc->sid_conf->requires_prctl_read) + PRCTL_RD4(sc, (i * 4), &tmp); + else + tmp = RD4(aw_sid_sc, root_key_off + (i * 4)); be32enc(&out[i * 4], tmp); } From owner-svn-src-head@freebsd.org Fri Apr 6 15:19:49 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6C911F8DB5E; Fri, 6 Apr 2018 15:19:49 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D59C2810D4; Fri, 6 Apr 2018 15:19:48 +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 D0996137D5; Fri, 6 Apr 2018 15:19:48 +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 w36FJmp8094623; Fri, 6 Apr 2018 15:19:48 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36FJmmg094622; Fri, 6 Apr 2018 15:19:48 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201804061519.w36FJmmg094622@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Fri, 6 Apr 2018 15:19:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332106 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 332106 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 15:19:49 -0000 Author: kevans Date: Fri Apr 6 15:19:48 2018 New Revision: 332106 URL: https://svnweb.freebsd.org/changeset/base/332106 Log: lualoader: Fix menu skipping with loader.conf(5) vars Earlier efforts to stop loading the menu broke the ability to skip the menu with, e.g., beastie_disable in loader.conf(5) as it was decided before configuration was read. Defer bringing in the menu module until we've loaded configuration so that we can make a more informed decision on whether the menu should be skipped or not. Modified: head/stand/lua/loader.lua Modified: head/stand/lua/loader.lua ============================================================================== --- head/stand/lua/loader.lua Fri Apr 6 15:17:09 2018 (r332105) +++ head/stand/lua/loader.lua Fri Apr 6 15:19:48 2018 (r332106) @@ -37,15 +37,17 @@ require("cli") local color = require("color") local core = require("core") local config = require("config") -local menu -if not core.isMenuSkipped() then - menu = require("menu") -end local password = require("password") +-- The menu module will be brought in after config has loaded if we actually +-- need it. +local menu try_include("local") config.load() +if not core.isMenuSkipped() then + menu = require("menu") +end if core.isUEFIBoot() then loader.perform("efi-autoresizecons") end From owner-svn-src-head@freebsd.org Fri Apr 6 15:54:31 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B8984F907D4; Fri, 6 Apr 2018 15:54:31 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 66A4683004; Fri, 6 Apr 2018 15:54:31 +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 60C6313E71; Fri, 6 Apr 2018 15:54:31 +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 w36FsVUf017385; Fri, 6 Apr 2018 15:54:31 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36FsVOI017382; Fri, 6 Apr 2018 15:54:31 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201804061554.w36FsVOI017382@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Fri, 6 Apr 2018 15:54:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332107 - in head/sys: net netpfil/pf X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: in head/sys: net netpfil/pf X-SVN-Commit-Revision: 332107 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 15:54:32 -0000 Author: kp Date: Fri Apr 6 15:54:30 2018 New Revision: 332107 URL: https://svnweb.freebsd.org/changeset/base/332107 Log: pf: Improve ioctl validation for DIOCRGETTABLES, DIOCRGETTSTATS, DIOCRCLRTSTATS and DIOCRSETTFLAGS These ioctls can process a number of items at a time, which puts us at risk of overflow in mallocarray() and of impossibly large allocations even if we don't overflow. Limit the allocation to required size (or the user allocation, if that's smaller). That does mean we need to do the allocation with the rules lock held (so the number doesn't change while we're doing this), so it can't M_WAITOK. MFC after: 1 week Modified: head/sys/net/pfvar.h head/sys/netpfil/pf/pf_ioctl.c head/sys/netpfil/pf/pf_table.c Modified: head/sys/net/pfvar.h ============================================================================== --- head/sys/net/pfvar.h Fri Apr 6 15:19:48 2018 (r332106) +++ head/sys/net/pfvar.h Fri Apr 6 15:54:30 2018 (r332107) @@ -1638,6 +1638,7 @@ void pfr_detach_table(struct pfr_ktable *); int pfr_clr_tables(struct pfr_table *, int *, int); int pfr_add_tables(struct pfr_table *, int, int *, int); int pfr_del_tables(struct pfr_table *, int, int *, int); +int pfr_table_count(struct pfr_table *, int); int pfr_get_tables(struct pfr_table *, struct pfr_table *, int *, int); int pfr_get_tstats(struct pfr_table *, struct pfr_tstats *, int *, int); int pfr_clr_tstats(struct pfr_table *, int, int *, int); Modified: head/sys/netpfil/pf/pf_ioctl.c ============================================================================== --- head/sys/netpfil/pf/pf_ioctl.c Fri Apr 6 15:19:48 2018 (r332106) +++ head/sys/netpfil/pf/pf_ioctl.c Fri Apr 6 15:54:30 2018 (r332107) @@ -2588,20 +2588,25 @@ DIOCCHANGEADDR_error: case DIOCRGETTABLES: { struct pfioc_table *io = (struct pfioc_table *)addr; struct pfr_table *pfrts; - size_t totlen; + size_t totlen, n; if (io->pfrio_esize != sizeof(struct pfr_table)) { error = ENODEV; break; } + PF_RULES_RLOCK(); + n = pfr_table_count(&io->pfrio_table, io->pfrio_flags); + io->pfrio_size = min(io->pfrio_size, n); + totlen = io->pfrio_size * sizeof(struct pfr_table); + pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), - M_TEMP, M_WAITOK); - if (! pfrts) { + M_TEMP, M_NOWAIT); + if (pfrts == NULL) { error = ENOMEM; + PF_RULES_RUNLOCK(); break; } - PF_RULES_RLOCK(); error = pfr_get_tables(&io->pfrio_table, pfrts, &io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL); PF_RULES_RUNLOCK(); @@ -2614,20 +2619,24 @@ DIOCCHANGEADDR_error: case DIOCRGETTSTATS: { struct pfioc_table *io = (struct pfioc_table *)addr; struct pfr_tstats *pfrtstats; - size_t totlen; + size_t totlen, n; if (io->pfrio_esize != sizeof(struct pfr_tstats)) { error = ENODEV; break; } + PF_RULES_WLOCK(); + n = pfr_table_count(&io->pfrio_table, io->pfrio_flags); + io->pfrio_size = min(io->pfrio_size, n); + totlen = io->pfrio_size * sizeof(struct pfr_tstats); pfrtstats = mallocarray(io->pfrio_size, - sizeof(struct pfr_tstats), M_TEMP, M_WAITOK); - if (! pfrtstats) { + sizeof(struct pfr_tstats), M_TEMP, M_NOWAIT); + if (pfrtstats == NULL) { error = ENOMEM; + PF_RULES_WUNLOCK(); break; } - PF_RULES_WLOCK(); error = pfr_get_tstats(&io->pfrio_table, pfrtstats, &io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL); PF_RULES_WUNLOCK(); @@ -2640,25 +2649,31 @@ DIOCCHANGEADDR_error: case DIOCRCLRTSTATS: { struct pfioc_table *io = (struct pfioc_table *)addr; struct pfr_table *pfrts; - size_t totlen; + size_t totlen, n; if (io->pfrio_esize != sizeof(struct pfr_table)) { error = ENODEV; break; } + + PF_RULES_WLOCK(); + n = pfr_table_count(&io->pfrio_table, io->pfrio_flags); + io->pfrio_size = min(io->pfrio_size, n); + totlen = io->pfrio_size * sizeof(struct pfr_table); pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), - M_TEMP, M_WAITOK); - if (! pfrts) { + M_TEMP, M_NOWAIT); + if (pfrts == NULL) { error = ENOMEM; + PF_RULES_WUNLOCK(); break; } error = copyin(io->pfrio_buffer, pfrts, totlen); if (error) { free(pfrts, M_TEMP); + PF_RULES_WUNLOCK(); break; } - PF_RULES_WLOCK(); error = pfr_clr_tstats(pfrts, io->pfrio_size, &io->pfrio_nzero, io->pfrio_flags | PFR_FLAG_USERIOCTL); PF_RULES_WUNLOCK(); @@ -2669,25 +2684,31 @@ DIOCCHANGEADDR_error: case DIOCRSETTFLAGS: { struct pfioc_table *io = (struct pfioc_table *)addr; struct pfr_table *pfrts; - size_t totlen; + size_t totlen, n; if (io->pfrio_esize != sizeof(struct pfr_table)) { error = ENODEV; break; } + + PF_RULES_WLOCK(); + n = pfr_table_count(&io->pfrio_table, io->pfrio_flags); + io->pfrio_size = min(io->pfrio_size, n); + totlen = io->pfrio_size * sizeof(struct pfr_table); pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), - M_TEMP, M_WAITOK); - if (! pfrts) { + M_TEMP, M_NOWAIT); + if (pfrts == NULL) { error = ENOMEM; + PF_RULES_WUNLOCK(); break; } error = copyin(io->pfrio_buffer, pfrts, totlen); if (error) { free(pfrts, M_TEMP); + PF_RULES_WUNLOCK(); break; } - PF_RULES_WLOCK(); error = pfr_set_tflags(pfrts, io->pfrio_size, io->pfrio_setflag, io->pfrio_clrflag, &io->pfrio_nchange, &io->pfrio_ndel, io->pfrio_flags | PFR_FLAG_USERIOCTL); Modified: head/sys/netpfil/pf/pf_table.c ============================================================================== --- head/sys/netpfil/pf/pf_table.c Fri Apr 6 15:19:48 2018 (r332106) +++ head/sys/netpfil/pf/pf_table.c Fri Apr 6 15:54:30 2018 (r332107) @@ -177,7 +177,6 @@ static struct pfr_ktable *pfr_lookup_table(struct pfr_table *); static void pfr_clean_node_mask(struct pfr_ktable *, struct pfr_kentryworkq *); -static int pfr_table_count(struct pfr_table *, int); static int pfr_skip_table(struct pfr_table *, struct pfr_ktable *, int); static struct pfr_kentry @@ -1688,7 +1687,7 @@ pfr_fix_anchor(char *anchor) return (0); } -static int +int pfr_table_count(struct pfr_table *filter, int flags) { struct pf_ruleset *rs; From owner-svn-src-head@freebsd.org Fri Apr 6 15:57:22 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BBC95F90B49; Fri, 6 Apr 2018 15:57:21 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6A186832E9; Fri, 6 Apr 2018 15:57:21 +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 60D7513E72; Fri, 6 Apr 2018 15:57:21 +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 w36FvLOJ017551; Fri, 6 Apr 2018 15:57:21 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36FvLRZ017550; Fri, 6 Apr 2018 15:57:21 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201804061557.w36FvLRZ017550@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Fri, 6 Apr 2018 15:57:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332108 - head/tests/sys/netpfil/pf/ioctl X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: head/tests/sys/netpfil/pf/ioctl X-SVN-Commit-Revision: 332108 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 15:57:22 -0000 Author: kp Date: Fri Apr 6 15:57:20 2018 New Revision: 332108 URL: https://svnweb.freebsd.org/changeset/base/332108 Log: pf tests: Basic ioctl validation for DIOCRGETTABLES, DIOCRGETTSTATS, DIOCRCLRTSTATS and DIOCRSETTFLAGS Validate the DIOCRGETTABLES, DIOCRGETTSTATS, DIOCRCLRTSTATS and DIOCRSETTFLAGS ioctls with invalid values. These may succeed (because the kernel uses the minimally required size, not the specified size), but should not trigger kernel panics. MFC after: 1 week Modified: head/tests/sys/netpfil/pf/ioctl/validation.c Modified: head/tests/sys/netpfil/pf/ioctl/validation.c ============================================================================== --- head/tests/sys/netpfil/pf/ioctl/validation.c Fri Apr 6 15:54:30 2018 (r332107) +++ head/tests/sys/netpfil/pf/ioctl/validation.c Fri Apr 6 15:57:20 2018 (r332108) @@ -51,6 +51,16 @@ static int dev; #define COMMON_CLEANUP() \ close(dev); +void +common_init_tbl(struct pfr_table *tbl) +{ + bzero(tbl, sizeof(struct pfr_table)); + strcpy(tbl->pfrt_anchor, "anchor"); + strcpy(tbl->pfrt_name, "name"); + tbl->pfrt_flags = 0; + tbl->pfrt_fback = 0; +} + ATF_TC_WITHOUT_HEAD(addtables); ATF_TC_BODY(addtables, tc) { @@ -121,10 +131,138 @@ ATF_TC_BODY(deltables, tc) COMMON_CLEANUP(); } +ATF_TC_WITHOUT_HEAD(gettables); +ATF_TC_BODY(gettables, tc) +{ + struct pfioc_table io; + struct pfr_table tbl; + int flags; + + COMMON_HEAD(); + + flags = 0; + + bzero(&io, sizeof(io)); + io.pfrio_flags = flags; + io.pfrio_buffer = &tbl; + io.pfrio_esize = sizeof(tbl); + + /* Negative size. This will succeed, because the kernel will not copy + * tables than it has. */ + io.pfrio_size = -1; + if (ioctl(dev, DIOCRGETTABLES, &io) != 0) + atf_tc_fail("Request with size -1 failed"); + + /* Overly large size. See above. */ + io.pfrio_size = 1 << 24; + if (ioctl(dev, DIOCRGETTABLES, &io) != 0) + atf_tc_fail("Request with size 1 << 24 failed"); + + COMMON_CLEANUP(); +} + +ATF_TC_WITHOUT_HEAD(gettstats); +ATF_TC_BODY(gettstats, tc) +{ + struct pfioc_table io; + struct pfr_tstats stats; + int flags; + + COMMON_HEAD(); + + flags = 0; + + bzero(&io, sizeof(io)); + io.pfrio_flags = flags; + io.pfrio_buffer = &stats; + io.pfrio_esize = sizeof(stats); + + /* Negative size. This will succeed, because the kernel will not copy + * tables than it has. */ + io.pfrio_size = -1; + if (ioctl(dev, DIOCRGETTSTATS, &io) != 0) + atf_tc_fail("Request with size -1 failed"); + + /* Overly large size. See above. */ + io.pfrio_size = 1 << 24; + if (ioctl(dev, DIOCRGETTSTATS, &io) != 0) + atf_tc_fail("Request with size 1 << 24 failed"); + + COMMON_CLEANUP(); +} + +ATF_TC_WITHOUT_HEAD(clrtstats); +ATF_TC_BODY(clrtstats, tc) +{ + struct pfioc_table io; + struct pfr_table tbl; + int flags; + + COMMON_HEAD(); + + flags = 0; + + common_init_tbl(&tbl); + + bzero(&io, sizeof(io)); + io.pfrio_flags = flags; + io.pfrio_buffer = &tbl; + io.pfrio_esize = sizeof(tbl); + + /* Negative size. This will succeed, because the kernel will not copy + * tables than it has. */ + io.pfrio_size = -1; + if (ioctl(dev, DIOCRCLRTSTATS, &io) != 0) + atf_tc_fail("Request with size -1 failed "); + + /* Overly large size. See above. */ + io.pfrio_size = 1 << 24; + if (ioctl(dev, DIOCRCLRTSTATS, &io) != 0) + atf_tc_fail("Request with size 1 << 24 failed"); + + COMMON_CLEANUP(); +} + +ATF_TC_WITHOUT_HEAD(settflags); +ATF_TC_BODY(settflags, tc) +{ + struct pfioc_table io; + struct pfr_table tbl; + int flags; + + COMMON_HEAD(); + + flags = 0; + + common_init_tbl(&tbl); + + bzero(&io, sizeof(io)); + io.pfrio_flags = flags; + io.pfrio_buffer = &tbl; + io.pfrio_esize = sizeof(tbl); + + /* Negative size. This will succeed, because the kernel will not copy + * tables than it has. */ + io.pfrio_size = -1; + if (ioctl(dev, DIOCRSETTFLAGS, &io) != 0) + atf_tc_fail("Request with size -1 failed"); + + /* Overly large size. See above. */ + io.pfrio_size = 1 << 28; + if (ioctl(dev, DIOCRSETTFLAGS, &io) != 0) + atf_tc_fail("Request with size 1 << 24 failed"); + + COMMON_CLEANUP(); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, addtables); ATF_TP_ADD_TC(tp, deltables); + ATF_TP_ADD_TC(tp, gettables); + ATF_TP_ADD_TC(tp, gettstats); + ATF_TP_ADD_TC(tp, clrtstats); + ATF_TP_ADD_TC(tp, settflags); return (atf_no_error()); } From owner-svn-src-head@freebsd.org Fri Apr 6 16:17:14 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B96A6F9230B; Fri, 6 Apr 2018 16:17:14 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2F5A384253; Fri, 6 Apr 2018 16:17:13 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w36GHAxX003444; Fri, 6 Apr 2018 09:17:10 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w36GH9sw003442; Fri, 6 Apr 2018 09:17:09 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201804061617.w36GH9sw003442@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r332092 - in head/sys: amd64/amd64 sys x86/x86 In-Reply-To: <201804061120.w36BK6s6074635@repo.freebsd.org> To: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Date: Fri, 6 Apr 2018 09:17:09 -0700 (PDT) CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 16:17:14 -0000 [ Charset UTF-8 unsupported, converting... ] > Author: royger > Date: Fri Apr 6 11:20:06 2018 > New Revision: 332092 > URL: https://svnweb.freebsd.org/changeset/base/332092 > > Log: > remove GiB/MiB macros from param.h > > And instead define them in the files where they are used. It would of been better to "revert" your prior change and make a seperate new commit. It is rarely desireable to combine a revert of a change with anything. > Requested by: bde > > Modified: > head/sys/amd64/amd64/mp_machdep.c > head/sys/sys/param.h > head/sys/x86/x86/mp_x86.c > > Modified: head/sys/amd64/amd64/mp_machdep.c ... -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-head@freebsd.org Fri Apr 6 16:22:15 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1AB5EF92A75; Fri, 6 Apr 2018 16:22:15 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C3F81848D9; Fri, 6 Apr 2018 16:22:14 +0000 (UTC) (envelope-from royger@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 BEEC514341; Fri, 6 Apr 2018 16:22:14 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36GMEFT032304; Fri, 6 Apr 2018 16:22:14 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36GMEi2032302; Fri, 6 Apr 2018 16:22:14 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201804061622.w36GMEi2032302@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Fri, 6 Apr 2018 16:22:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332109 - in head/sys: amd64/amd64 x86/x86 X-SVN-Group: head X-SVN-Commit-Author: royger X-SVN-Commit-Paths: in head/sys: amd64/amd64 x86/x86 X-SVN-Commit-Revision: 332109 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 16:22:15 -0000 Author: royger Date: Fri Apr 6 16:22:14 2018 New Revision: 332109 URL: https://svnweb.freebsd.org/changeset/base/332109 Log: x86: fix trampoline memory allocation after r332073 Add the missing breaks in the for loops, in order to exit the loop when a suitable entry is found. Also switch amd64 native_start_all_aps to use PHYS_TO_DMAP in order to find the virtual address of the boot_trampoline and the initial page tables. Reported and tested by: pho Sponsored by: Citrix Systems R&D Modified: head/sys/amd64/amd64/mp_machdep.c head/sys/x86/x86/mp_x86.c Modified: head/sys/amd64/amd64/mp_machdep.c ============================================================================== --- head/sys/amd64/amd64/mp_machdep.c Fri Apr 6 15:57:20 2018 (r332108) +++ head/sys/amd64/amd64/mp_machdep.c Fri Apr 6 16:22:14 2018 (r332109) @@ -128,6 +128,7 @@ mp_bootaddress(vm_paddr_t *physmap, unsigned int *phys sizeof(*physmap) * (*physmap_idx - i + 2)); *physmap_idx -= 2; } + break; } if (!allocated) { @@ -336,7 +337,6 @@ init_secondary(void) int native_start_all_aps(void) { - vm_offset_t va = boot_address + KERNBASE; u_int64_t *pt4, *pt3, *pt2; u_int32_t mpbioswarmvec; int apic_id, cpu, i; @@ -344,13 +344,11 @@ native_start_all_aps(void) mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); - /* install the AP 1st level boot code */ - pmap_kenter(va, boot_address); - pmap_invalidate_page(kernel_pmap, va); - bcopy(mptramp_start, (void *)va, bootMP_size); + /* copy the AP 1st level boot code */ + bcopy(mptramp_start, (void *)PHYS_TO_DMAP(boot_address), bootMP_size); /* Locate the page tables, they'll be below the trampoline */ - pt4 = (u_int64_t *)(uintptr_t)(mptramp_pagetables + KERNBASE); + pt4 = (uint64_t *)PHYS_TO_DMAP(mptramp_pagetables); pt3 = pt4 + (PAGE_SIZE) / sizeof(u_int64_t); pt2 = pt3 + (PAGE_SIZE) / sizeof(u_int64_t); Modified: head/sys/x86/x86/mp_x86.c ============================================================================== --- head/sys/x86/x86/mp_x86.c Fri Apr 6 15:57:20 2018 (r332108) +++ head/sys/x86/x86/mp_x86.c Fri Apr 6 16:22:14 2018 (r332109) @@ -947,6 +947,7 @@ alloc_ap_trampoline(vm_paddr_t *physmap, unsigned int sizeof(*physmap) * (*physmap_idx - i + 2)); *physmap_idx -= 2; } + break; } if (!allocated) { From owner-svn-src-head@freebsd.org Fri Apr 6 16:24:04 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 46D28F92C77; Fri, 6 Apr 2018 16:24:04 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F141084B06; Fri, 6 Apr 2018 16:24:03 +0000 (UTC) (envelope-from ed@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 EBD8514357; Fri, 6 Apr 2018 16:24:03 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36GO3iW032430; Fri, 6 Apr 2018 16:24:03 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36GO3hF032429; Fri, 6 Apr 2018 16:24:03 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201804061624.w36GO3hF032429@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Fri, 6 Apr 2018 16:24:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332110 - head/usr.sbin/syslogd X-SVN-Group: head X-SVN-Commit-Author: ed X-SVN-Commit-Paths: head/usr.sbin/syslogd X-SVN-Commit-Revision: 332110 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 16:24:04 -0000 Author: ed Date: Fri Apr 6 16:24:03 2018 New Revision: 332110 URL: https://svnweb.freebsd.org/changeset/base/332110 Log: Properly respect the passed in hostname for RFC 5424 messages. Only override the hostname in case none is provided or when remote hostnames should be ignored. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Fri Apr 6 16:22:14 2018 (r332109) +++ head/usr.sbin/syslogd/syslogd.c Fri Apr 6 16:24:03 2018 (r332110) @@ -1028,6 +1028,8 @@ parsemsg_rfc5424(const char *from, int pri, char *msg) msg[-1] = '\0'; \ } PARSE_STRING("HOSTNAME", hostname); + if (hostname == NULL || !RemoteHostname) + hostname = from; PARSE_STRING("APP-NAME", app_name); PARSE_STRING("PROCID", procid); PARSE_STRING("MSGID", msgid); @@ -1079,7 +1081,7 @@ parsemsg_rfc5424(const char *from, int pri, char *msg) #undef IF_NOT_NILVALUE parsemsg_remove_unsafe_characters(msg, line, sizeof(line)); - logmsg(pri, timestamp, from, app_name, procid, msgid, + logmsg(pri, timestamp, hostname, app_name, procid, msgid, structured_data, line, 0); } From owner-svn-src-head@freebsd.org Fri Apr 6 16:26:47 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 481CAF93085; Fri, 6 Apr 2018 16:26:47 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A41A58520C; Fri, 6 Apr 2018 16:26:46 +0000 (UTC) (envelope-from ed@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 9964214362; Fri, 6 Apr 2018 16:26:46 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36GQkZR033626; Fri, 6 Apr 2018 16:26:46 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36GQkh2033625; Fri, 6 Apr 2018 16:26:46 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201804061626.w36GQkh2033625@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Fri, 6 Apr 2018 16:26:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332111 - head/usr.sbin/syslogd X-SVN-Group: head X-SVN-Commit-Author: ed X-SVN-Commit-Paths: head/usr.sbin/syslogd X-SVN-Commit-Revision: 332111 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 16:26:47 -0000 Author: ed Date: Fri Apr 6 16:26:46 2018 New Revision: 332111 URL: https://svnweb.freebsd.org/changeset/base/332111 Log: Remove some places where error messages are prefixed with "syslogd". Due to using RFC 5424, the application name is stored in a dedicated field. It can simply be passed as an argument to logmsg() now. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Fri Apr 6 16:24:03 2018 (r332110) +++ head/usr.sbin/syslogd/syslogd.c Fri Apr 6 16:26:46 2018 (r332111) @@ -1991,7 +1991,7 @@ domark(int signo __unused) * Print syslogd errors some place. */ static void -logerror(const char *type) +logerror(const char *msg) { char buf[512]; static int recursed = 0; @@ -2000,15 +2000,15 @@ logerror(const char *type) if (recursed) return; recursed++; - if (errno) - (void)snprintf(buf, - sizeof buf, "syslogd: %s: %s", type, strerror(errno)); - else - (void)snprintf(buf, sizeof buf, "syslogd: %s", type); + if (errno != 0) { + (void)snprintf(buf, sizeof(buf), "%s: %s", msg, + strerror(errno)); + msg = buf; + } errno = 0; dprintf("%s\n", buf); - logmsg(LOG_SYSLOG|LOG_ERR, NULL, LocalHostName, NULL, NULL, NULL, - NULL, buf, 0); + logmsg(LOG_SYSLOG|LOG_ERR, NULL, LocalHostName, "syslogd", NULL, NULL, + NULL, msg, 0); recursed--; } @@ -2355,18 +2355,18 @@ init(int signo) } } - logmsg(LOG_SYSLOG|LOG_INFO, NULL, LocalHostName, NULL, NULL, NULL, - NULL, "syslogd: restart", 0); + logmsg(LOG_SYSLOG | LOG_INFO, NULL, LocalHostName, "syslogd", NULL, + NULL, NULL, "restart", 0); dprintf("syslogd: restarted\n"); /* * Log a change in hostname, but only on a restart. */ if (signo != 0 && strcmp(oldLocalHostName, LocalHostName) != 0) { (void)snprintf(hostMsg, sizeof(hostMsg), - "syslogd: hostname changed, \"%s\" to \"%s\"", + "hostname changed, \"%s\" to \"%s\"", oldLocalHostName, LocalHostName); - logmsg(LOG_SYSLOG|LOG_INFO, NULL, LocalHostName, NULL, NULL, - NULL, NULL, hostMsg, 0); + logmsg(LOG_SYSLOG | LOG_INFO, NULL, LocalHostName, "syslogd", + NULL, NULL, NULL, hostMsg, 0); dprintf("%s\n", hostMsg); } /* @@ -2375,9 +2375,9 @@ init(int signo) */ if (signo == 0 && !use_bootfile) { (void)snprintf(bootfileMsg, sizeof(bootfileMsg), - "syslogd: kernel boot file is %s", bootfile); - logmsg(LOG_KERN|LOG_INFO, NULL, LocalHostName, NULL, NULL, - NULL, NULL, bootfileMsg, 0); + "kernel boot file is %s", bootfile); + logmsg(LOG_KERN | LOG_INFO, NULL, LocalHostName, "syslogd", + NULL, NULL, NULL, bootfileMsg, 0); dprintf("%s\n", bootfileMsg); } } From owner-svn-src-head@freebsd.org Fri Apr 6 16:48:12 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70888F94E0A; Fri, 6 Apr 2018 16:48:12 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 257C5878B1; Fri, 6 Apr 2018 16:48:12 +0000 (UTC) (envelope-from jtl@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 1EBB8146E7; Fri, 6 Apr 2018 16:48:12 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36GmC5S046594; Fri, 6 Apr 2018 16:48:12 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36GmBkd046593; Fri, 6 Apr 2018 16:48:11 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201804061648.w36GmBkd046593@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Fri, 6 Apr 2018 16:48:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332114 - head/sys/netinet X-SVN-Group: head X-SVN-Commit-Author: jtl X-SVN-Commit-Paths: head/sys/netinet X-SVN-Commit-Revision: 332114 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 16:48:12 -0000 Author: jtl Date: Fri Apr 6 16:48:11 2018 New Revision: 332114 URL: https://svnweb.freebsd.org/changeset/base/332114 Log: Check that in_pcbfree() is only called once for each PCB. If that assumption is violated, "bad things" could follow. I believe such an assert would have detected some of the problems jch@ was chasing in PR 203175 (see r307551). We also use it in our internal TCP development efforts. And, in case a bug does slip through to released code, this change silently ignores subsequent calls to in_pcbfree(). Reviewed by: rrs Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D14990 Modified: head/sys/netinet/in_pcb.c Modified: head/sys/netinet/in_pcb.c ============================================================================== --- head/sys/netinet/in_pcb.c Fri Apr 6 16:48:07 2018 (r332113) +++ head/sys/netinet/in_pcb.c Fri Apr 6 16:48:11 2018 (r332114) @@ -1288,6 +1288,13 @@ in_pcbfree(struct inpcb *inp) KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__)); + KASSERT((inp->inp_flags2 & INP_FREED) == 0, + ("%s: called twice for pcb %p", __func__, inp)); + if (inp->inp_flags2 & INP_FREED) { + INP_WUNLOCK(inp); + return; + } + #ifdef INVARIANTS if (pcbinfo == &V_tcbinfo) { INP_INFO_LOCK_ASSERT(pcbinfo); From owner-svn-src-head@freebsd.org Fri Apr 6 17:06:23 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 03289F968CD; Fri, 6 Apr 2018 17:06:23 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A8E5C69132; Fri, 6 Apr 2018 17:06:22 +0000 (UTC) (envelope-from jtl@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 A3BDA14A79; Fri, 6 Apr 2018 17:06:22 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36H6MF6056596; Fri, 6 Apr 2018 17:06:22 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36H6MEg056595; Fri, 6 Apr 2018 17:06:22 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201804061706.w36H6MEg056595@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Fri, 6 Apr 2018 17:06:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332117 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: jtl X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 332117 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 17:06:23 -0000 Author: jtl Date: Fri Apr 6 17:06:22 2018 New Revision: 332117 URL: https://svnweb.freebsd.org/changeset/base/332117 Log: Pat the watchdog less while producing a coredump. Prior to this change, we patted the watchdog approximately once per 4KB page of memory. After this change, we pat the watchdog approximately once per 128MB of memory. On a sample machine, this translated to patting the watchdog approximately every 5.4 seconds, which "seems reasonable". We can choose a different value in the future, if warranted. This has extensive field experience. It is a performance improvement, and has not caused any known problems. Reviewed by: imp, kib Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D14988 Modified: head/sys/amd64/amd64/minidump_machdep.c Modified: head/sys/amd64/amd64/minidump_machdep.c ============================================================================== --- head/sys/amd64/amd64/minidump_machdep.c Fri Apr 6 17:04:21 2018 (r332116) +++ head/sys/amd64/amd64/minidump_machdep.c Fri Apr 6 17:06:22 2018 (r332117) @@ -62,7 +62,7 @@ static struct kerneldumpheader kdh; /* Handle chunked writes. */ static size_t fragsz; static void *dump_va; -static size_t counter, progress, dumpsize; +static size_t counter, progress, dumpsize, wdog_next; CTASSERT(sizeof(*vm_page_dump) == 8); static int dump_retry_count = 5; @@ -134,6 +134,9 @@ report_progress(size_t progress, size_t dumpsize) } } +/* Pat the watchdog approximately every 128MB of the dump. */ +#define WDOG_DUMP_INTERVAL (128 * 1024 * 1024) + static int blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) { @@ -173,9 +176,14 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t report_progress(progress, dumpsize); counter &= (1<<24) - 1; } + if (progress <= wdog_next) { + wdog_kern_pat(WD_LASTVAL); + if (wdog_next > WDOG_DUMP_INTERVAL) + wdog_next -= WDOG_DUMP_INTERVAL; + else + wdog_next = 0; + } - wdog_kern_pat(WD_LASTVAL); - if (ptr) { error = dump_append(di, ptr, 0, len); if (error) @@ -313,7 +321,7 @@ minidumpsys(struct dumperinfo *di) } dumpsize += PAGE_SIZE; - progress = dumpsize; + wdog_next = progress = dumpsize; /* Initialize mdhdr */ bzero(&mdhdr, sizeof(mdhdr)); From owner-svn-src-head@freebsd.org Fri Apr 6 17:16:50 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BCE51F97465; Fri, 6 Apr 2018 17:16:50 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6F8CE69AAB; Fri, 6 Apr 2018 17:16:50 +0000 (UTC) (envelope-from ed@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 6A69D14C37; Fri, 6 Apr 2018 17:16:50 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36HGot3061971; Fri, 6 Apr 2018 17:16:50 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36HGo46061970; Fri, 6 Apr 2018 17:16:50 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201804061716.w36HGo46061970@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Fri, 6 Apr 2018 17:16:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332118 - head/usr.sbin/syslogd X-SVN-Group: head X-SVN-Commit-Author: ed X-SVN-Commit-Paths: head/usr.sbin/syslogd X-SVN-Commit-Revision: 332118 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 17:16:51 -0000 Author: ed Date: Fri Apr 6 17:16:50 2018 New Revision: 332118 URL: https://svnweb.freebsd.org/changeset/base/332118 Log: Push RFC 5424 message format from logmsg() into fprintlog(). Now that all of parsemsg() parses both RFC 3164 and 5424 messages and hands them to logmsg(), alter the latter to properly forward all RFC 5424 message attributes to fprintlog(). While there, make some minor cleanups to this code: - Instead of extending the existing code that compares hostnames and message bodies for deduplication, print all of the relevant message fields into a single string that we can compare ('saved'). - No longer let the behaviour of fprintflog() depend on whether 'msg == NULL' to print repetition messages, Simply decompose this function into fprintlog_first() and fprintlog_successive(). This makes the interpretation of function arguments less magical and also allows us to get consistent behaviour across RFC 3164 and 5424 when adding support for the RFC 5424 output format. - As RFC 5424 syslog messages have a dedicated application name field, alter the repetition messages to be printed on behalf of syslogd on the current system. Change these messages to use the local hostname, so that it's obvious which syslogd instance detected the repetition. Remove f_prevhost, as it has now become unnecessary. - Remove a useless strdup(). Deconsting the message string is safe in this specific case. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Fri Apr 6 17:06:22 2018 (r332117) +++ head/usr.sbin/syslogd/syslogd.c Fri Apr 6 17:16:50 2018 (r332118) @@ -252,7 +252,6 @@ struct filed { #define fu_pipe_pid f_un.f_pipe.f_pid char f_prevline[MAXSVLINE]; /* last message logged */ struct logtime f_lasttime; /* time of last occurrence */ - char f_prevhost[MAXHOSTNAMELEN]; /* host from which recd. */ int f_prevpri; /* pri of f_prevline */ size_t f_prevlen; /* length of f_prevline */ int f_prevcount; /* repetition cnt of prevline */ @@ -385,7 +384,9 @@ static void die(int) __dead2; static void dodie(int); static void dofsync(void); static void domark(int); -static void fprintlog(struct filed *, int, const char *); +static void fprintlog_first(struct filed *, const char *, const char *, + const char *, const char *, const char *, const char *, int); +static void fprintlog_successive(struct filed *, int); static void init(int); static void logerror(const char *); static void logmsg(int, const struct logtime *, const char *, const char *, @@ -1411,19 +1412,19 @@ skip_message(const char *name, const char *spec, int c * STRUCTURED-DATA fields are thus discarded for the time being. */ static void -logmsg(int pri, const struct logtime *timestamp, const char *from, - const char *app_name, const char *procid, const char *msgid __unused, - const char *structured_data __unused, const char *msg, int flags) +logmsg(int pri, const struct logtime *timestamp, const char *hostname, + const char *app_name, const char *procid, const char *msgid, + const char *structured_data, const char *msg, int flags) { struct timeval tv; struct logtime timestamp_now; struct filed *f; - size_t msglen; + size_t savedlen; int fac, prilev; - char buf[MAXLINE+1]; + char saved[MAXSVLINE]; dprintf("logmsg: pri %o, flags %x, from %s, msg %s\n", - pri, flags, from, msg); + pri, flags, hostname, msg); (void)gettimeofday(&tv, NULL); now = tv.tv_sec; @@ -1445,18 +1446,6 @@ logmsg(int pri, const struct logtime *timestamp, const prilev = LOG_PRI(pri); - /* Prepend the application name to the message if provided. */ - if (app_name != NULL) { - if (procid != NULL) - msglen = snprintf(buf, sizeof(buf), "%s[%s]: %s", - app_name, procid, msg); - else - msglen = snprintf(buf, sizeof(buf), "%s: %s", - app_name, msg); - msg = buf; - } else - msglen = strlen(msg); - /* log the message to the particular outputs */ if (!Initialized) { f = &consfile; @@ -1468,12 +1457,27 @@ logmsg(int pri, const struct logtime *timestamp, const if (f->f_file >= 0) { f->f_lasttime = *timestamp; - fprintlog(f, flags, msg); + fprintlog_first(f, hostname, app_name, procid, msgid, + structured_data, msg, flags); close(f->f_file); f->f_file = -1; } return; } + + /* + * Store all of the fields of the message, except the timestamp, + * in a single string. This string is used to detect duplicate + * messages. + */ + assert(hostname != NULL); + assert(msg != NULL); + savedlen = snprintf(saved, sizeof(saved), + "%d %s %s %s %s %s %s", pri, hostname, + app_name == NULL ? "-" : app_name, procid == NULL ? "-" : procid, + msgid == NULL ? "-" : msgid, + structured_data == NULL ? "-" : structured_data, msg); + STAILQ_FOREACH(f, &fhead, next) { /* skip messages that are incorrect priority */ if (!(((f->f_pcmp[fac] & PRI_EQ) && (f->f_pmask[fac] == prilev)) @@ -1484,7 +1488,7 @@ logmsg(int pri, const struct logtime *timestamp, const continue; /* skip messages with the incorrect hostname */ - if (skip_message(from, f->f_host, 0)) + if (skip_message(hostname, f->f_host, 0)) continue; /* skip messages with the incorrect program name */ @@ -1504,9 +1508,8 @@ logmsg(int pri, const struct logtime *timestamp, const * suppress duplicate lines to this file */ if (no_compress - (f->f_type != F_PIPE) < 1 && - (flags & MARK) == 0 && msglen == f->f_prevlen && - !strcmp(msg, f->f_prevline) && - !strcasecmp(from, f->f_prevhost)) { + (flags & MARK) == 0 && savedlen == f->f_prevlen && + strcmp(saved, f->f_prevline) == 0) { f->f_lasttime = *timestamp; f->f_prevcount++; dprintf("msg repeated %d times, %ld sec of %d\n", @@ -1519,27 +1522,22 @@ logmsg(int pri, const struct logtime *timestamp, const * in the future. */ if (now > REPEATTIME(f)) { - fprintlog(f, flags, (char *)NULL); + fprintlog_successive(f, flags); BACKOFF(f); } } else { /* new line, save it */ if (f->f_prevcount) - fprintlog(f, 0, (char *)NULL); + fprintlog_successive(f, 0); f->f_repeatcount = 0; f->f_prevpri = pri; f->f_lasttime = *timestamp; - (void)strlcpy(f->f_prevhost, from, - sizeof(f->f_prevhost)); - if (msglen < MAXSVLINE) { - f->f_prevlen = msglen; - (void)strlcpy(f->f_prevline, msg, sizeof(f->f_prevline)); - fprintlog(f, flags, (char *)NULL); - } else { - f->f_prevline[0] = 0; - f->f_prevlen = 0; - fprintlog(f, flags, msg); - } + static_assert(sizeof(f->f_prevline) == sizeof(saved), + "Space to store saved line incorrect"); + (void)strcpy(f->f_prevline, saved); + f->f_prevlen = savedlen; + fprintlog_first(f, hostname, app_name, procid, msgid, + structured_data, msg, flags); } } } @@ -1560,12 +1558,14 @@ dofsync(void) #define IOV_SIZE 7 static void -fprintlog(struct filed *f, int flags, const char *msg) +fprintlog_first(struct filed *f, const char *hostname, const char *app_name, + const char *procid, const char *msgid __unused, + const char *structured_data __unused, const char *msg, int flags) { struct iovec iov[IOV_SIZE]; struct addrinfo *r; int l, lsent = 0; - char line[MAXLINE + 1], repbuf[80], greetings[200], *wmsg = NULL; + char tagged_msg[MAXLINE + 1], line[MAXLINE + 1], greetings[200]; char nul[] = "", space[] = " ", lf[] = "\n", crlf[] = "\r\n"; char timebuf[RFC3164_DATELEN + 1]; const char *msgret; @@ -1583,8 +1583,7 @@ fprintlog(struct filed *f, int flags, const char *msg) .iov_base = greetings, .iov_len = snprintf(greetings, sizeof(greetings), "\r\n\7Message from syslogd@%s " - "at %.24s ...\r\n", - f->f_prevhost, timebuf) + "at %.24s ...\r\n", hostname, timebuf) }; if (iov[0].iov_len >= sizeof(greetings)) iov[0].iov_len = sizeof(greetings) - 1; @@ -1647,36 +1646,28 @@ fprintlog(struct filed *f, int flags, const char *msg) .iov_len = 0 }; } + /* Prepend the application name to the message if provided. */ + if (app_name != NULL) { + if (procid != NULL) + snprintf(tagged_msg, sizeof(tagged_msg), + "%s[%s]: %s", app_name, procid, msg); + else + snprintf(tagged_msg, sizeof(tagged_msg), + "%s: %s", app_name, msg); + msg = tagged_msg; + } iov[3] = (struct iovec){ - .iov_base = f->f_prevhost, - .iov_len = strlen(f->f_prevhost) + .iov_base = __DECONST(char *, hostname), + .iov_len = strlen(hostname) }; iov[4] = (struct iovec){ .iov_base = space, .iov_len = 1 }; - if (msg) { - wmsg = strdup(msg); /* XXX iov_base needs a `const' sibling. */ - if (wmsg == NULL) { - logerror("strdup"); - exit(1); - } - iov[5] = (struct iovec){ - .iov_base = wmsg, - .iov_len = strlen(msg) - }; - } else if (f->f_prevcount > 1) { - iov[5] = (struct iovec){ - .iov_base = repbuf, - .iov_len = snprintf(repbuf, sizeof(repbuf), - "last message repeated %d times", f->f_prevcount) - }; - } else { - iov[5] = (struct iovec){ - .iov_base = f->f_prevline, - .iov_len = f->f_prevlen - }; - } + iov[5] = (struct iovec){ + .iov_base = __DECONST(char *, msg), + .iov_len = strlen(msg) + }; dprintf("Logging to %s", TypeNames[f->f_type]); f->f_time = now; @@ -1704,11 +1695,11 @@ fprintlog(struct filed *f, int flags, const char *msg) dprintf("\n"); } /* check for local vs remote messages */ - if (strcasecmp(f->f_prevhost, LocalHostName)) + if (strcasecmp(hostname, LocalHostName)) l = snprintf(line, sizeof line - 1, "<%d>%.15s Forwarded from %s: %s", f->f_prevpri, (char *)iov[0].iov_base, - f->f_prevhost, (char *)iov[5].iov_base); + hostname, (char *)iov[5].iov_base); else l = snprintf(line, sizeof line - 1, "<%d>%.15s %s", f->f_prevpri, (char *)iov[0].iov_base, @@ -1841,10 +1832,25 @@ fprintlog(struct filed *f, int flags, const char *msg) break; } f->f_prevcount = 0; - free(wmsg); } /* + * Prints a message to a log file that the previously logged message was + * received multiple times. + */ +static void +fprintlog_successive(struct filed *f, int flags) +{ + char msg[100]; + + assert(f->f_prevcount > 0); + snprintf(msg, sizeof(msg), "last message repeated %d times", + f->f_prevcount); + fprintlog_first(f, LocalHostName, "syslogd", NULL, NULL, NULL, msg, + flags); +} + +/* * WALLMSG -- Write a message to the world at large * * Write the specified message to either the entire @@ -2022,7 +2028,7 @@ die(int signo) STAILQ_FOREACH(f, &fhead, next) { /* flush any pending output */ if (f->f_prevcount) - fprintlog(f, 0, (char *)NULL); + fprintlog_successive(f, 0); if (f->f_type == F_PIPE && f->fu_pipe_pid > 0) close_filed(f); } @@ -2252,7 +2258,7 @@ init(int signo) STAILQ_FOREACH(f, &fhead, next) { /* flush any pending output */ if (f->f_prevcount) - fprintlog(f, 0, (char *)NULL); + fprintlog_successive(f, 0); switch (f->f_type) { case F_FILE: @@ -2696,7 +2702,7 @@ markit(void) dprintf("flush %s: repeated %d times, %d sec.\n", TypeNames[f->f_type], f->f_prevcount, repeatinterval[f->f_repeatcount]); - fprintlog(f, 0, (char *)NULL); + fprintlog_successive(f, 0); BACKOFF(f); } } From owner-svn-src-head@freebsd.org Fri Apr 6 17:17:35 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B716EF97532; Fri, 6 Apr 2018 17:17:35 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6957669C1A; Fri, 6 Apr 2018 17:17:35 +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 63D8214C38; Fri, 6 Apr 2018 17:17:35 +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 w36HHZ8C062046; Fri, 6 Apr 2018 17:17:35 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36HHYO3062040; Fri, 6 Apr 2018 17:17:34 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804061717.w36HHYO3062040@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Fri, 6 Apr 2018 17:17:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332119 - in head/lib/libc: amd64/sys gen i386/sys powerpc/sys powerpc64/sys sparc64/sys X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in head/lib/libc: amd64/sys gen i386/sys powerpc/sys powerpc64/sys sparc64/sys X-SVN-Commit-Revision: 332119 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 17:17:36 -0000 Author: brooks Date: Fri Apr 6 17:17:34 2018 New Revision: 332119 URL: https://svnweb.freebsd.org/changeset/base/332119 Log: Remove caching from getlogin(2). This caching has existed since the CSRG import, but serves no obvious purpose. Sure, setlogin() is called rarely, but calls to getlogin() should also be infrequent. The required invalidation was not implemented on aarch64, arm, mips, amd riscv so updates would never occur if getlogin() was called before setlogin(). Reported by: Ali Mashtizadeh Reviewed by: kib Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14965 Deleted: head/lib/libc/amd64/sys/setlogin.S head/lib/libc/i386/sys/setlogin.S head/lib/libc/powerpc/sys/setlogin.S head/lib/libc/powerpc64/sys/setlogin.S head/lib/libc/sparc64/sys/setlogin.S Modified: head/lib/libc/amd64/sys/Makefile.inc head/lib/libc/gen/getlogin.c head/lib/libc/i386/sys/Makefile.inc head/lib/libc/powerpc/sys/Makefile.inc head/lib/libc/powerpc64/sys/Makefile.inc head/lib/libc/sparc64/sys/Makefile.inc Modified: head/lib/libc/amd64/sys/Makefile.inc ============================================================================== --- head/lib/libc/amd64/sys/Makefile.inc Fri Apr 6 17:16:50 2018 (r332118) +++ head/lib/libc/amd64/sys/Makefile.inc Fri Apr 6 17:17:34 2018 (r332119) @@ -9,7 +9,7 @@ SRCS+= \ amd64_set_gsbase.c MDASM= vfork.S brk.S cerror.S exect.S getcontext.S \ - sbrk.S setlogin.S + sbrk.S # Don't generate default code for these syscalls: NOASM+= vfork.o Modified: head/lib/libc/gen/getlogin.c ============================================================================== --- head/lib/libc/gen/getlogin.c Fri Apr 6 17:16:50 2018 (r332118) +++ head/lib/libc/gen/getlogin.c Fri Apr 6 17:17:34 2018 (r332119) @@ -47,62 +47,33 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" -#define THREAD_LOCK() if (__isthreaded) _pthread_mutex_lock(&logname_mutex) -#define THREAD_UNLOCK() if (__isthreaded) _pthread_mutex_unlock(&logname_mutex) - extern int _getlogin(char *, int); -int _logname_valid __hidden; /* known to setlogin() */ -static pthread_mutex_t logname_mutex = PTHREAD_MUTEX_INITIALIZER; - -static char * -getlogin_basic(int *status) -{ - static char logname[MAXLOGNAME]; - - if (_logname_valid == 0) { - if (_getlogin(logname, sizeof(logname)) < 0) { - *status = errno; - return (NULL); - } - _logname_valid = 1; - } - *status = 0; - return (*logname ? logname : NULL); -} - char * getlogin(void) { - char *result; - int status; + static char logname[MAXLOGNAME]; - THREAD_LOCK(); - result = getlogin_basic(&status); - THREAD_UNLOCK(); - return (result); + if (_getlogin(logname, sizeof(logname)) < 0) + return (NULL); + return (logname[0] != '\0' ? logname : NULL); } int getlogin_r(char *logname, int namelen) { - char *result; + char tmpname[MAXLOGNAME]; int len; - int status; if (namelen < 1) return (ERANGE); logname[0] = '\0'; - THREAD_LOCK(); - result = getlogin_basic(&status); - if (status == 0 && result != NULL) { - len = strlen(result) + 1; - if (len > namelen) - status = ERANGE; - else - strncpy(logname, result, len); - } - THREAD_UNLOCK(); - return (status); + if (_getlogin(tmpname, sizeof(tmpname)) < 0) + return (errno); + len = strlen(tmpname) + 1; + if (len > namelen) + return (ERANGE); + strlcpy(logname, tmpname, len); + return (0); } Modified: head/lib/libc/i386/sys/Makefile.inc ============================================================================== --- head/lib/libc/i386/sys/Makefile.inc Fri Apr 6 17:16:50 2018 (r332118) +++ head/lib/libc/i386/sys/Makefile.inc Fri Apr 6 17:17:34 2018 (r332119) @@ -8,7 +8,7 @@ SRCS+= i386_get_fsbase.c i386_get_gsbase.c i386_get_io i386_set_fsbase.c i386_set_gsbase.c i386_set_ioperm.c i386_set_ldt.c MDASM= Ovfork.S brk.S cerror.S exect.S getcontext.S \ - sbrk.S setlogin.S syscall.S + sbrk.S syscall.S NOASM+= vfork.o Modified: head/lib/libc/powerpc/sys/Makefile.inc ============================================================================== --- head/lib/libc/powerpc/sys/Makefile.inc Fri Apr 6 17:16:50 2018 (r332118) +++ head/lib/libc/powerpc/sys/Makefile.inc Fri Apr 6 17:17:34 2018 (r332119) @@ -1,3 +1,3 @@ # $FreeBSD$ -MDASM+= brk.S cerror.S exect.S sbrk.S setlogin.S +MDASM+= brk.S cerror.S exect.S sbrk.S Modified: head/lib/libc/powerpc64/sys/Makefile.inc ============================================================================== --- head/lib/libc/powerpc64/sys/Makefile.inc Fri Apr 6 17:16:50 2018 (r332118) +++ head/lib/libc/powerpc64/sys/Makefile.inc Fri Apr 6 17:17:34 2018 (r332119) @@ -1,3 +1,3 @@ # $FreeBSD$ -MDASM+= brk.S cerror.S exect.S sbrk.S setlogin.S +MDASM+= brk.S cerror.S exect.S sbrk.S Modified: head/lib/libc/sparc64/sys/Makefile.inc ============================================================================== --- head/lib/libc/sparc64/sys/Makefile.inc Fri Apr 6 17:16:50 2018 (r332118) +++ head/lib/libc/sparc64/sys/Makefile.inc Fri Apr 6 17:17:34 2018 (r332119) @@ -12,4 +12,4 @@ SRCS+= __sparc_sigtramp_setup.c \ CFLAGS+= -I${LIBC_SRCTOP}/sparc64/fpu -MDASM+= brk.S cerror.S exect.S sbrk.S setlogin.S sigaction1.S +MDASM+= brk.S cerror.S exect.S sbrk.S sigaction1.S From owner-svn-src-head@freebsd.org Fri Apr 6 17:20:38 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E330EF97986; Fri, 6 Apr 2018 17:20:37 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 97C0F69F20; Fri, 6 Apr 2018 17:20:37 +0000 (UTC) (envelope-from jtl@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 9296A14C48; Fri, 6 Apr 2018 17:20:37 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36HKb85062209; Fri, 6 Apr 2018 17:20:37 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36HKb8A062208; Fri, 6 Apr 2018 17:20:37 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201804061720.w36HKb8A062208@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Fri, 6 Apr 2018 17:20:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332120 - head/sys/netinet X-SVN-Group: head X-SVN-Commit-Author: jtl X-SVN-Commit-Paths: head/sys/netinet X-SVN-Commit-Revision: 332120 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 17:20:38 -0000 Author: jtl Date: Fri Apr 6 17:20:37 2018 New Revision: 332120 URL: https://svnweb.freebsd.org/changeset/base/332120 Log: If a user closes the socket before we call tcp_usr_abort(), then tcp_drop() may unlock the INP. Currently, tcp_usr_abort() does not check for this case, which results in a panic while trying to unlock the already-unlocked INP (not to mention, a use-after-free violation). Make tcp_usr_abort() check the return value of tcp_drop(). In the case where tcp_drop() returns NULL, tcp_usr_abort() can skip further steps to abort the connection and simply unlock the INP_INFO lock prior to returning. Reviewed by: glebius MFC after: 2 weeks Sponsored by: Netflix, Inc. Modified: head/sys/netinet/tcp_usrreq.c Modified: head/sys/netinet/tcp_usrreq.c ============================================================================== --- head/sys/netinet/tcp_usrreq.c Fri Apr 6 17:17:34 2018 (r332119) +++ head/sys/netinet/tcp_usrreq.c Fri Apr 6 17:20:37 2018 (r332120) @@ -1095,7 +1095,9 @@ tcp_usr_abort(struct socket *so) !(inp->inp_flags & INP_DROPPED)) { tp = intotcpcb(inp); TCPDEBUG1(); - tcp_drop(tp, ECONNABORTED); + tp = tcp_drop(tp, ECONNABORTED); + if (tp == NULL) + goto dropped; TCPDEBUG2(PRU_ABORT); TCP_PROBE2(debug__user, tp, PRU_ABORT); } @@ -1106,6 +1108,7 @@ tcp_usr_abort(struct socket *so) inp->inp_flags |= INP_SOCKREF; } INP_WUNLOCK(inp); +dropped: INP_INFO_RUNLOCK(&V_tcbinfo); } From owner-svn-src-head@freebsd.org Fri Apr 6 17:23:47 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D05BEF97E9C; Fri, 6 Apr 2018 17:23:47 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 841666A3F0; Fri, 6 Apr 2018 17:23:47 +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 7EDB314DD1; Fri, 6 Apr 2018 17:23:47 +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 w36HNlCq066924; Fri, 6 Apr 2018 17:23:47 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36HNlHF066923; Fri, 6 Apr 2018 17:23:47 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804061723.w36HNlHF066923@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Fri, 6 Apr 2018 17:23:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332121 - head X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: head X-SVN-Commit-Revision: 332121 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 17:23:48 -0000 Author: brooks Date: Fri Apr 6 17:23:47 2018 New Revision: 332121 URL: https://svnweb.freebsd.org/changeset/base/332121 Log: Support -DNO_CLEAN builds across r332119. Modified: head/Makefile.inc1 Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Fri Apr 6 17:20:37 2018 (r332120) +++ head/Makefile.inc1 Fri Apr 6 17:23:47 2018 (r332121) @@ -807,7 +807,8 @@ _cleanobj_fast_depend_hack: .PHONY # 20170624 r320278 fstat fstatat fstatfs getdirentries getfsstat statfs # 20180404 r332048 sigreturn # 20180405 r332080 shmat -.for f in fstat fstatat fstatfs getdirentries getfsstat shmat sigreturn statfs +# 20180406 r332119 setlogin +.for f in fstat fstatat fstatfs getdirentries getfsstat setlogin shmat sigreturn statfs .if exists(${OBJTOP}/lib/libc/.depend.${f}.o) @if egrep -qw '${f}\.[sS]' \ ${OBJTOP}/lib/libc/.depend.${f}.o; then \ From owner-svn-src-head@freebsd.org Fri Apr 6 17:35:47 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C9C23F98C51; Fri, 6 Apr 2018 17:35:46 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7C24C6AE17; Fri, 6 Apr 2018 17:35:46 +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 7658414F6C; Fri, 6 Apr 2018 17:35:46 +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 w36HZkhO071987; Fri, 6 Apr 2018 17:35:46 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36HZaOD071891; Fri, 6 Apr 2018 17:35:36 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804061735.w36HZaOD071891@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Fri, 6 Apr 2018 17:35:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332122 - in head/sys: amd64/amd64 amd64/ia32 amd64/linux amd64/linux32 arm/arm arm64/arm64 cam/scsi compat/freebsd32 compat/ia32 compat/linux conf dev/aac dev/aacraid dev/acpica dev/at... X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in head/sys: amd64/amd64 amd64/ia32 amd64/linux amd64/linux32 arm/arm arm64/arm64 cam/scsi compat/freebsd32 compat/ia32 compat/linux conf dev/aac dev/aacraid dev/acpica dev/atkbdc dev/cy dev/drm2 dev/... X-SVN-Commit-Revision: 332122 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 17:35:47 -0000 Author: brooks Date: Fri Apr 6 17:35:35 2018 New Revision: 332122 URL: https://svnweb.freebsd.org/changeset/base/332122 Log: Move most of the contents of opt_compat.h to opt_global.h. opt_compat.h is mentioned in nearly 180 files. In-progress network driver compabibility improvements may add over 100 more so this is closer to "just about everywhere" than "only some files" per the guidance in sys/conf/options. Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of sys/compat/linux/*.c. A fake _COMPAT_LINUX option ensure opt_compat.h is created on all architectures. Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the set of compiled files. Reviewed by: kib, cem, jhb, jtl Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14941 Modified: head/sys/amd64/amd64/db_trace.c head/sys/amd64/amd64/exception.S head/sys/amd64/amd64/genassym.c head/sys/amd64/amd64/machdep.c head/sys/amd64/amd64/ptrace_machdep.c head/sys/amd64/amd64/vm_machdep.c head/sys/amd64/ia32/ia32_misc.c head/sys/amd64/ia32/ia32_reg.c head/sys/amd64/ia32/ia32_signal.c head/sys/amd64/ia32/ia32_sigtramp.S head/sys/amd64/ia32/ia32_syscall.c head/sys/amd64/linux/linux_dummy.c head/sys/amd64/linux/linux_sysvec.c head/sys/amd64/linux32/linux32_dummy.c head/sys/amd64/linux32/linux32_machdep.c head/sys/amd64/linux32/linux32_sysent.c head/sys/amd64/linux32/linux32_sysvec.c head/sys/amd64/linux32/syscalls.master head/sys/arm/arm/machdep.c head/sys/arm/arm/vm_machdep.c head/sys/arm64/arm64/machdep.c head/sys/cam/scsi/scsi_enc.c head/sys/cam/scsi/scsi_pass.c head/sys/compat/freebsd32/freebsd32_ioctl.c head/sys/compat/freebsd32/freebsd32_misc.c head/sys/compat/freebsd32/freebsd32_sysent.c head/sys/compat/ia32/ia32_genassym.c head/sys/compat/ia32/ia32_sysvec.c head/sys/compat/linux/linux_util.c head/sys/conf/options head/sys/conf/options.amd64 head/sys/conf/options.arm64 head/sys/conf/options.mips head/sys/conf/options.powerpc head/sys/dev/aac/aac.c head/sys/dev/aacraid/aacraid.c head/sys/dev/acpica/acpi_hpet.c head/sys/dev/atkbdc/atkbd.c head/sys/dev/cy/cy.c head/sys/dev/drm2/drmP.h head/sys/dev/drm2/drm_ioc32.c head/sys/dev/drm2/i915/i915_ioc32.c head/sys/dev/drm2/radeon/radeon_ioc32.c head/sys/dev/filemon/filemon.c head/sys/dev/filemon/filemon_wrapper.c head/sys/dev/kbdmux/kbdmux.c head/sys/dev/md/md.c head/sys/dev/mfi/mfi.c head/sys/dev/mpr/mpr_user.c head/sys/dev/mps/mps_user.c head/sys/dev/mrsas/mrsas_linux.c head/sys/dev/null/null.c head/sys/dev/pci/pci_user.c head/sys/dev/rp/rp.c head/sys/dev/sio/sio.c head/sys/dev/syscons/scvidctl.c head/sys/dev/syscons/syscons.c head/sys/dev/uart/uart_kbd_sun.c head/sys/dev/usb/input/ukbd.c head/sys/dev/vkbd/vkbd.c head/sys/dev/vt/vt_core.c head/sys/fs/cuse/cuse.c head/sys/fs/devfs/devfs_devs.c head/sys/fs/procfs/procfs_dbregs.c head/sys/fs/procfs/procfs_fpregs.c head/sys/fs/procfs/procfs_ioctl.c head/sys/fs/procfs/procfs_map.c head/sys/fs/procfs/procfs_regs.c head/sys/geom/geom_dev.c head/sys/i386/i386/genassym.c head/sys/i386/i386/locore.s head/sys/i386/i386/machdep.c head/sys/i386/i386/sigtramp.s head/sys/i386/linux/linux_dummy.c head/sys/kern/imgact_elf.c head/sys/kern/init_sysent.c head/sys/kern/kern_descrip.c head/sys/kern/kern_event.c head/sys/kern/kern_exec.c head/sys/kern/kern_exit.c head/sys/kern/kern_jail.c head/sys/kern/kern_mib.c head/sys/kern/kern_module.c head/sys/kern/kern_proc.c head/sys/kern/kern_prot.c head/sys/kern/kern_resource.c head/sys/kern/kern_sendfile.c head/sys/kern/kern_sharedpage.c head/sys/kern/kern_sig.c head/sys/kern/kern_sysctl.c head/sys/kern/kern_tc.c head/sys/kern/kern_thr.c head/sys/kern/kern_umtx.c head/sys/kern/kern_xxx.c head/sys/kern/makesyscalls.sh head/sys/kern/subr_dummy_vdso_tc.c head/sys/kern/sys_generic.c head/sys/kern/sys_getrandom.c head/sys/kern/sys_pipe.c head/sys/kern/sys_process.c head/sys/kern/sysv_ipc.c head/sys/kern/sysv_msg.c head/sys/kern/sysv_sem.c head/sys/kern/sysv_shm.c head/sys/kern/tty.c head/sys/kern/tty_compat.c head/sys/kern/uipc_mqueue.c head/sys/kern/uipc_sem.c head/sys/kern/uipc_socket.c head/sys/kern/uipc_syscalls.c head/sys/kern/vfs_aio.c head/sys/kern/vfs_bio.c head/sys/kern/vfs_subr.c head/sys/kern/vfs_syscalls.c head/sys/mips/include/reg.h head/sys/mips/include/sigframe.h head/sys/mips/include/tls.h head/sys/mips/include/ucontext.h head/sys/mips/mips/freebsd32_machdep.c head/sys/mips/mips/pm_machdep.c head/sys/mips/mips/swtch.S head/sys/mips/mips/trap.c head/sys/mips/mips/vm_machdep.c head/sys/modules/aac/Makefile head/sys/modules/aacraid/Makefile head/sys/modules/cam/Makefile head/sys/modules/cryptodev/Makefile head/sys/modules/cuse/Makefile head/sys/modules/drm2/drm2/Makefile head/sys/modules/drm2/i915kms/Makefile head/sys/modules/drm2/radeonkms/Makefile head/sys/modules/dtrace/dtrace/Makefile head/sys/modules/dtrace/dtraceall/Makefile head/sys/modules/dtrace/dtraceall/dtraceall.c head/sys/modules/dtrace/fasttrap/Makefile head/sys/modules/filemon/Makefile head/sys/modules/hyperv/vmbus/Makefile head/sys/modules/if_tap/Makefile head/sys/modules/isp/Makefile head/sys/modules/kbdmux/Makefile head/sys/modules/linux/Makefile head/sys/modules/linux64/Makefile head/sys/modules/linux_common/Makefile head/sys/modules/mfi/Makefile head/sys/modules/mpr/Makefile head/sys/modules/mps/Makefile head/sys/modules/mqueue/Makefile head/sys/modules/procfs/Makefile head/sys/modules/rp/Makefile head/sys/modules/sem/Makefile head/sys/modules/sgx/Makefile head/sys/modules/sio/Makefile head/sys/modules/sysvipc/sysvmsg/Makefile head/sys/modules/sysvipc/sysvsem/Makefile head/sys/modules/sysvipc/sysvshm/Makefile head/sys/modules/usb/ukbd/Makefile head/sys/modules/vkbd/Makefile head/sys/net/bpf.c head/sys/net/if.c head/sys/net/if_tap.c head/sys/net/rtsock.c head/sys/netinet/in_jail.c head/sys/netinet/in_prot.c head/sys/netinet/sctp_os_bsd.h head/sys/netinet/sctp_syscalls.c head/sys/netinet/tcp_subr.c head/sys/netinet6/in6.c head/sys/netinet6/in6_jail.c head/sys/opencrypto/cryptodev.c head/sys/powerpc/aim/aim_machdep.c head/sys/powerpc/aim/mmu_oea64.c head/sys/powerpc/booke/booke_machdep.c head/sys/powerpc/include/reg.h head/sys/powerpc/powerpc/exec_machdep.c head/sys/powerpc/powerpc/machdep.c head/sys/powerpc/powerpc/ptrace_machdep.c head/sys/powerpc/powerpc/sys_machdep.c head/sys/sparc64/sparc64/exception.S head/sys/sparc64/sparc64/machdep.c head/sys/vm/swap_pager.c head/sys/vm/vm_meter.c head/sys/vm/vm_mmap.c head/sys/vm/vm_unix.c head/sys/x86/x86/cpu_machdep.c head/sys/x86/x86/tsc.c Modified: head/sys/amd64/amd64/db_trace.c ============================================================================== --- head/sys/amd64/amd64/db_trace.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/amd64/db_trace.c Fri Apr 6 17:35:35 2018 (r332122) @@ -27,8 +27,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/amd64/amd64/exception.S ============================================================================== --- head/sys/amd64/amd64/exception.S Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/amd64/exception.S Fri Apr 6 17:35:35 2018 (r332122) @@ -39,7 +39,6 @@ */ #include "opt_atpic.h" -#include "opt_compat.h" #include "opt_hwpmc_hooks.h" #include "assym.inc" Modified: head/sys/amd64/amd64/genassym.c ============================================================================== --- head/sys/amd64/amd64/genassym.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/amd64/genassym.c Fri Apr 6 17:35:35 2018 (r332122) @@ -37,7 +37,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_hwpmc_hooks.h" #include "opt_kstack_pages.h" Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/amd64/machdep.c Fri Apr 6 17:35:35 2018 (r332122) @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include "opt_atpic.h" -#include "opt_compat.h" #include "opt_cpu.h" #include "opt_ddb.h" #include "opt_inet.h" Modified: head/sys/amd64/amd64/ptrace_machdep.c ============================================================================== --- head/sys/amd64/amd64/ptrace_machdep.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/amd64/ptrace_machdep.c Fri Apr 6 17:35:35 2018 (r332122) @@ -30,8 +30,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/amd64/amd64/vm_machdep.c ============================================================================== --- head/sys/amd64/amd64/vm_machdep.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/amd64/vm_machdep.c Fri Apr 6 17:35:35 2018 (r332122) @@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$"); #include "opt_isa.h" #include "opt_cpu.h" -#include "opt_compat.h" #include #include Modified: head/sys/amd64/ia32/ia32_misc.c ============================================================================== --- head/sys/amd64/ia32/ia32_misc.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/ia32/ia32_misc.c Fri Apr 6 17:35:35 2018 (r332122) @@ -29,8 +29,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/amd64/ia32/ia32_reg.c ============================================================================== --- head/sys/amd64/ia32/ia32_reg.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/ia32/ia32_reg.c Fri Apr 6 17:35:35 2018 (r332122) @@ -31,8 +31,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/amd64/ia32/ia32_signal.c ============================================================================== --- head/sys/amd64/ia32/ia32_signal.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/ia32/ia32_signal.c Fri Apr 6 17:35:35 2018 (r332122) @@ -36,8 +36,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/amd64/ia32/ia32_sigtramp.S ============================================================================== --- head/sys/amd64/ia32/ia32_sigtramp.S Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/ia32/ia32_sigtramp.S Fri Apr 6 17:35:35 2018 (r332122) @@ -26,8 +26,6 @@ * $FreeBSD$ */ -#include "opt_compat.h" - #include #include Modified: head/sys/amd64/ia32/ia32_syscall.c ============================================================================== --- head/sys/amd64/ia32/ia32_syscall.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/ia32/ia32_syscall.c Fri Apr 6 17:35:35 2018 (r332122) @@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$"); */ #include "opt_clock.h" -#include "opt_compat.h" #include "opt_cpu.h" #include "opt_isa.h" Modified: head/sys/amd64/linux/linux_dummy.c ============================================================================== --- head/sys/amd64/linux/linux_dummy.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/linux/linux_dummy.c Fri Apr 6 17:35:35 2018 (r332122) @@ -29,8 +29,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/amd64/linux/linux_sysvec.c ============================================================================== --- head/sys/amd64/linux/linux_sysvec.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/linux/linux_sysvec.c Fri Apr 6 17:35:35 2018 (r332122) @@ -34,8 +34,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #define __ELF_WORD_SIZE 64 #include Modified: head/sys/amd64/linux32/linux32_dummy.c ============================================================================== --- head/sys/amd64/linux32/linux32_dummy.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/linux32/linux32_dummy.c Fri Apr 6 17:35:35 2018 (r332122) @@ -29,8 +29,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/amd64/linux32/linux32_machdep.c ============================================================================== --- head/sys/amd64/linux32/linux32_machdep.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/linux32/linux32_machdep.c Fri Apr 6 17:35:35 2018 (r332122) @@ -33,8 +33,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/amd64/linux32/linux32_sysent.c ============================================================================== --- head/sys/amd64/linux32/linux32_sysent.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/linux32/linux32_sysent.c Fri Apr 6 17:35:35 2018 (r332122) @@ -5,7 +5,6 @@ * $FreeBSD$ */ -#include "opt_compat.h" #include #include #include Modified: head/sys/amd64/linux32/linux32_sysvec.c ============================================================================== --- head/sys/amd64/linux32/linux32_sysvec.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/linux32/linux32_sysvec.c Fri Apr 6 17:35:35 2018 (r332122) @@ -34,7 +34,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #ifndef COMPAT_FREEBSD32 #error "Unable to compile Linux-emulator due to missing COMPAT_FREEBSD32 option!" Modified: head/sys/amd64/linux32/syscalls.master ============================================================================== --- head/sys/amd64/linux32/syscalls.master Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/amd64/linux32/syscalls.master Fri Apr 6 17:35:35 2018 (r332122) @@ -26,7 +26,6 @@ ; function prototype in sys/sysproto.h. Does add a ; definition to syscall.h besides adding a sysent. -#include "opt_compat.h" #include #include #include Modified: head/sys/arm/arm/machdep.c ============================================================================== --- head/sys/arm/arm/machdep.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/arm/arm/machdep.c Fri Apr 6 17:35:35 2018 (r332122) @@ -44,7 +44,6 @@ * Updated : 18/04/01 updated for new wscons */ -#include "opt_compat.h" #include "opt_ddb.h" #include "opt_kstack_pages.h" #include "opt_platform.h" Modified: head/sys/arm/arm/vm_machdep.c ============================================================================== --- head/sys/arm/arm/vm_machdep.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/arm/arm/vm_machdep.c Fri Apr 6 17:35:35 2018 (r332122) @@ -42,8 +42,6 @@ * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ */ -#include "opt_compat.h" - #include __FBSDID("$FreeBSD$"); Modified: head/sys/arm64/arm64/machdep.c ============================================================================== --- head/sys/arm64/arm64/machdep.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/arm64/arm64/machdep.c Fri Apr 6 17:35:35 2018 (r332122) @@ -26,7 +26,6 @@ */ #include "opt_acpi.h" -#include "opt_compat.h" #include "opt_platform.h" #include "opt_ddb.h" Modified: head/sys/cam/scsi/scsi_enc.c ============================================================================== --- head/sys/cam/scsi/scsi_enc.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/cam/scsi/scsi_enc.c Fri Apr 6 17:35:35 2018 (r332122) @@ -29,8 +29,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include Modified: head/sys/cam/scsi/scsi_pass.c ============================================================================== --- head/sys/cam/scsi/scsi_pass.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/cam/scsi/scsi_pass.c Fri Apr 6 17:35:35 2018 (r332122) @@ -30,8 +30,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/compat/freebsd32/freebsd32_ioctl.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_ioctl.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/compat/freebsd32/freebsd32_ioctl.c Fri Apr 6 17:35:35 2018 (r332122) @@ -32,8 +32,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_misc.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/compat/freebsd32/freebsd32_misc.c Fri Apr 6 17:35:35 2018 (r332122) @@ -29,7 +29,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_inet.h" #include "opt_inet6.h" #include "opt_ktrace.h" Modified: head/sys/compat/freebsd32/freebsd32_sysent.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_sysent.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/compat/freebsd32/freebsd32_sysent.c Fri Apr 6 17:35:35 2018 (r332122) @@ -5,8 +5,6 @@ * $FreeBSD$ */ -#include "opt_compat.h" - #include #include #include Modified: head/sys/compat/ia32/ia32_genassym.c ============================================================================== --- head/sys/compat/ia32/ia32_genassym.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/compat/ia32/ia32_genassym.c Fri Apr 6 17:35:35 2018 (r332122) @@ -1,8 +1,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/compat/ia32/ia32_sysvec.c ============================================================================== --- head/sys/compat/ia32/ia32_sysvec.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/compat/ia32/ia32_sysvec.c Fri Apr 6 17:35:35 2018 (r332122) @@ -30,8 +30,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #define __ELF_WORD_SIZE 32 #include Modified: head/sys/compat/linux/linux_util.c ============================================================================== --- head/sys/compat/linux/linux_util.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/compat/linux/linux_util.c Fri Apr 6 17:35:35 2018 (r332122) @@ -34,8 +34,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/conf/options Fri Apr 6 17:35:35 2018 (r332122) @@ -80,18 +80,18 @@ BOOTVERBOSE opt_global.h CALLOUT_PROFILING CAPABILITIES opt_capsicum.h CAPABILITY_MODE opt_capsicum.h -COMPAT_43 opt_compat.h -COMPAT_43TTY opt_compat.h -COMPAT_FREEBSD4 opt_compat.h -COMPAT_FREEBSD5 opt_compat.h -COMPAT_FREEBSD6 opt_compat.h -COMPAT_FREEBSD7 opt_compat.h -COMPAT_FREEBSD9 opt_compat.h -COMPAT_FREEBSD10 opt_compat.h -COMPAT_FREEBSD11 opt_compat.h +COMPAT_43 opt_global.h +COMPAT_43TTY opt_global.h +COMPAT_FREEBSD4 opt_global.h +COMPAT_FREEBSD5 opt_global.h +COMPAT_FREEBSD6 opt_global.h +COMPAT_FREEBSD7 opt_global.h +COMPAT_FREEBSD9 opt_global.h +COMPAT_FREEBSD10 opt_global.h +COMPAT_FREEBSD11 opt_global.h COMPAT_CLOUDABI32 opt_dontuse.h COMPAT_CLOUDABI64 opt_dontuse.h -COMPAT_LINUXKPI opt_compat.h +COMPAT_LINUXKPI opt_dontuse.h COMPILING_LINT opt_global.h CY_PCI_FASTINTR DEADLKRES opt_watchdog.h Modified: head/sys/conf/options.amd64 ============================================================================== --- head/sys/conf/options.amd64 Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/conf/options.amd64 Fri Apr 6 17:35:35 2018 (r332122) @@ -14,7 +14,7 @@ PV_STATS opt_pmap.h # Options for emulators. These should only be used at config time, so # they are handled like options for static filesystems # (see src/sys/conf/options), except for broken debugging options. -COMPAT_FREEBSD32 opt_compat.h +COMPAT_FREEBSD32 opt_global.h #IBCS2 opt_dontuse.h #COMPAT_LINUX opt_dontuse.h COMPAT_LINUX32 opt_compat.h Modified: head/sys/conf/options.arm64 ============================================================================== --- head/sys/conf/options.arm64 Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/conf/options.arm64 Fri Apr 6 17:35:35 2018 (r332122) @@ -8,7 +8,7 @@ THUNDERX_PASS_1_1_ERRATA opt_global.h VFP opt_global.h # Binary compatibility -COMPAT_FREEBSD32 opt_compat.h +COMPAT_FREEBSD32 opt_global.h # EFI Runtime services support EFIRT opt_efirt.h Modified: head/sys/conf/options.mips ============================================================================== --- head/sys/conf/options.mips Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/conf/options.mips Fri Apr 6 17:35:35 2018 (r332122) @@ -58,7 +58,7 @@ MIPS64EL MIPS64ELHF MIPSN32 -COMPAT_FREEBSD32 opt_compat.h +COMPAT_FREEBSD32 opt_global.h YAMON opt_global.h CFE opt_global.h Modified: head/sys/conf/options.powerpc ============================================================================== --- head/sys/conf/options.powerpc Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/conf/options.powerpc Fri Apr 6 17:35:35 2018 (r332122) @@ -13,7 +13,7 @@ POWERPCSPE FPU_EMU -COMPAT_FREEBSD32 opt_compat.h +COMPAT_FREEBSD32 opt_global.h GFB_DEBUG opt_gfb.h GFB_NO_FONT_LOADING opt_gfb.h Modified: head/sys/dev/aac/aac.c ============================================================================== --- head/sys/dev/aac/aac.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/aac/aac.c Fri Apr 6 17:35:35 2018 (r332122) @@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$"); #define AAC_DRIVERNAME "aac" #include "opt_aac.h" -#include "opt_compat.h" /* #include */ #include Modified: head/sys/dev/aacraid/aacraid.c ============================================================================== --- head/sys/dev/aacraid/aacraid.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/aacraid/aacraid.c Fri Apr 6 17:35:35 2018 (r332122) @@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$"); #define AAC_DRIVERNAME "aacraid" #include "opt_aacraid.h" -#include "opt_compat.h" /* #include */ #include Modified: head/sys/dev/acpica/acpi_hpet.c ============================================================================== --- head/sys/dev/acpica/acpi_hpet.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/acpica/acpi_hpet.c Fri Apr 6 17:35:35 2018 (r332122) @@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$"); #include "opt_acpi.h" -#include "opt_compat.h" #if defined(__amd64__) #define DEV_APIC Modified: head/sys/dev/atkbdc/atkbd.c ============================================================================== --- head/sys/dev/atkbdc/atkbd.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/atkbdc/atkbd.c Fri Apr 6 17:35:35 2018 (r332122) @@ -30,7 +30,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_kbd.h" #include "opt_atkbd.h" #include "opt_evdev.h" Modified: head/sys/dev/cy/cy.c ============================================================================== --- head/sys/dev/cy/cy.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/cy/cy.c Fri Apr 6 17:35:35 2018 (r332122) @@ -33,8 +33,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - /* * TODO: * Atomic COR change. Modified: head/sys/dev/drm2/drmP.h ============================================================================== --- head/sys/dev/drm2/drmP.h Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/drm2/drmP.h Fri Apr 6 17:35:35 2018 (r332122) @@ -121,7 +121,6 @@ struct drm_device; #include #include -#include "opt_compat.h" #include "opt_drm.h" #include "opt_syscons.h" #ifdef DRM_DEBUG Modified: head/sys/dev/drm2/drm_ioc32.c ============================================================================== --- head/sys/dev/drm2/drm_ioc32.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/drm2/drm_ioc32.c Fri Apr 6 17:35:35 2018 (r332122) @@ -25,8 +25,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #ifdef COMPAT_FREEBSD32 #include Modified: head/sys/dev/drm2/i915/i915_ioc32.c ============================================================================== --- head/sys/dev/drm2/i915/i915_ioc32.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/drm2/i915/i915_ioc32.c Fri Apr 6 17:35:35 2018 (r332122) @@ -30,8 +30,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #ifdef COMPAT_FREEBSD32 /** @file i915_ioc32.c Modified: head/sys/dev/drm2/radeon/radeon_ioc32.c ============================================================================== --- head/sys/dev/drm2/radeon/radeon_ioc32.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/drm2/radeon/radeon_ioc32.c Fri Apr 6 17:35:35 2018 (r332122) @@ -31,8 +31,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #ifdef COMPAT_FREEBSD32 #include Modified: head/sys/dev/filemon/filemon.c ============================================================================== --- head/sys/dev/filemon/filemon.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/filemon/filemon.c Fri Apr 6 17:35:35 2018 (r332122) @@ -31,8 +31,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/dev/filemon/filemon_wrapper.c ============================================================================== --- head/sys/dev/filemon/filemon_wrapper.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/filemon/filemon_wrapper.c Fri Apr 6 17:35:35 2018 (r332122) @@ -39,8 +39,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include "opt_compat.h" - static eventhandler_tag filemon_exec_tag; static eventhandler_tag filemon_exit_tag; static eventhandler_tag filemon_fork_tag; Modified: head/sys/dev/kbdmux/kbdmux.c ============================================================================== --- head/sys/dev/kbdmux/kbdmux.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/kbdmux/kbdmux.c Fri Apr 6 17:35:35 2018 (r332122) @@ -33,7 +33,6 @@ * $FreeBSD$ */ -#include "opt_compat.h" #include "opt_evdev.h" #include "opt_kbd.h" #include "opt_kbdmux.h" Modified: head/sys/dev/md/md.c ============================================================================== --- head/sys/dev/md/md.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/md/md.c Fri Apr 6 17:35:35 2018 (r332122) @@ -60,7 +60,6 @@ * From: src/sys/dev/vn/vn.c,v 1.122 2000/12/16 16:06:03 */ -#include "opt_compat.h" #include "opt_rootdevname.h" #include "opt_geom.h" #include "opt_md.h" Modified: head/sys/dev/mfi/mfi.c ============================================================================== --- head/sys/dev/mfi/mfi.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/mfi/mfi.c Fri Apr 6 17:35:35 2018 (r332122) @@ -55,7 +55,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_mfi.h" #include Modified: head/sys/dev/mpr/mpr_user.c ============================================================================== --- head/sys/dev/mpr/mpr_user.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/mpr/mpr_user.c Fri Apr 6 17:35:35 2018 (r332122) @@ -63,8 +63,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - /* TODO Move headers to mprvar */ #include #include Modified: head/sys/dev/mps/mps_user.c ============================================================================== --- head/sys/dev/mps/mps_user.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/mps/mps_user.c Fri Apr 6 17:35:35 2018 (r332122) @@ -65,8 +65,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - /* TODO Move headers to mpsvar */ #include #include Modified: head/sys/dev/mrsas/mrsas_linux.c ============================================================================== --- head/sys/dev/mrsas/mrsas_linux.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/mrsas/mrsas_linux.c Fri Apr 6 17:35:35 2018 (r332122) @@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$"); #include #include +#undef COMPAT_FREEBSD32 #include /* There are multiple ioctl number ranges that need to be handled */ Modified: head/sys/dev/null/null.c ============================================================================== --- head/sys/dev/null/null.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/null/null.c Fri Apr 6 17:35:35 2018 (r332122) @@ -32,8 +32,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/dev/pci/pci_user.c ============================================================================== --- head/sys/dev/pci/pci_user.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/pci/pci_user.c Fri Apr 6 17:35:35 2018 (r332122) @@ -30,7 +30,6 @@ __FBSDID("$FreeBSD$"); #include "opt_bus.h" /* XXX trim includes */ -#include "opt_compat.h" #include #include Modified: head/sys/dev/rp/rp.c ============================================================================== --- head/sys/dev/rp/rp.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/rp/rp.c Fri Apr 6 17:35:35 2018 (r332122) @@ -40,8 +40,6 @@ __FBSDID("$FreeBSD$"); * rp.c - for RocketPort FreeBSD */ -#include "opt_compat.h" - #include #include #include Modified: head/sys/dev/sio/sio.c ============================================================================== --- head/sys/dev/sio/sio.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/sio/sio.c Fri Apr 6 17:35:35 2018 (r332122) @@ -35,7 +35,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_gdb.h" #include "opt_kdb.h" #include "opt_sio.h" Modified: head/sys/dev/syscons/scvidctl.c ============================================================================== --- head/sys/dev/syscons/scvidctl.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/syscons/scvidctl.c Fri Apr 6 17:35:35 2018 (r332122) @@ -32,7 +32,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_syscons.h" #include Modified: head/sys/dev/syscons/syscons.c ============================================================================== --- head/sys/dev/syscons/syscons.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/syscons/syscons.c Fri Apr 6 17:35:35 2018 (r332122) @@ -34,7 +34,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_syscons.h" #include "opt_splash.h" #include "opt_ddb.h" Modified: head/sys/dev/uart/uart_kbd_sun.c ============================================================================== --- head/sys/dev/uart/uart_kbd_sun.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/uart/uart_kbd_sun.c Fri Apr 6 17:35:35 2018 (r332122) @@ -29,7 +29,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_kbd.h" #include "opt_sunkbd.h" Modified: head/sys/dev/usb/input/ukbd.c ============================================================================== --- head/sys/dev/usb/input/ukbd.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/usb/input/ukbd.c Fri Apr 6 17:35:35 2018 (r332122) @@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$"); * HID spec: http://www.usb.org/developers/devclass_docs/HID1_11.pdf */ -#include "opt_compat.h" #include "opt_kbd.h" #include "opt_ukbd.h" #include "opt_evdev.h" Modified: head/sys/dev/vkbd/vkbd.c ============================================================================== --- head/sys/dev/vkbd/vkbd.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/vkbd/vkbd.c Fri Apr 6 17:35:35 2018 (r332122) @@ -33,7 +33,6 @@ * $FreeBSD$ */ -#include "opt_compat.h" #include "opt_kbd.h" #include Modified: head/sys/dev/vt/vt_core.c ============================================================================== --- head/sys/dev/vt/vt_core.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/dev/vt/vt_core.c Fri Apr 6 17:35:35 2018 (r332122) @@ -35,8 +35,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/fs/cuse/cuse.c ============================================================================== --- head/sys/fs/cuse/cuse.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/fs/cuse/cuse.c Fri Apr 6 17:35:35 2018 (r332122) @@ -24,8 +24,6 @@ * SUCH DAMAGE. */ -#include "opt_compat.h" - #include #include #include Modified: head/sys/fs/devfs/devfs_devs.c ============================================================================== --- head/sys/fs/devfs/devfs_devs.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/fs/devfs/devfs_devs.c Fri Apr 6 17:35:35 2018 (r332122) @@ -30,8 +30,6 @@ * $FreeBSD$ */ -#include "opt_compat.h" - #include #include #include Modified: head/sys/fs/procfs/procfs_dbregs.c ============================================================================== --- head/sys/fs/procfs/procfs_dbregs.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/fs/procfs/procfs_dbregs.c Fri Apr 6 17:35:35 2018 (r332122) @@ -45,8 +45,6 @@ * $FreeBSD$ */ -#include "opt_compat.h" - #include #include #include Modified: head/sys/fs/procfs/procfs_fpregs.c ============================================================================== --- head/sys/fs/procfs/procfs_fpregs.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/fs/procfs/procfs_fpregs.c Fri Apr 6 17:35:35 2018 (r332122) @@ -39,8 +39,6 @@ * $FreeBSD$ */ -#include "opt_compat.h" - #include #include #include Modified: head/sys/fs/procfs/procfs_ioctl.c ============================================================================== --- head/sys/fs/procfs/procfs_ioctl.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/fs/procfs/procfs_ioctl.c Fri Apr 6 17:35:35 2018 (r332122) @@ -30,8 +30,6 @@ * $FreeBSD$ */ -#include "opt_compat.h" - #include #include #include Modified: head/sys/fs/procfs/procfs_map.c ============================================================================== --- head/sys/fs/procfs/procfs_map.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/fs/procfs/procfs_map.c Fri Apr 6 17:35:35 2018 (r332122) @@ -37,8 +37,6 @@ * $FreeBSD$ */ -#include "opt_compat.h" - #include #include #include Modified: head/sys/fs/procfs/procfs_regs.c ============================================================================== --- head/sys/fs/procfs/procfs_regs.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/fs/procfs/procfs_regs.c Fri Apr 6 17:35:35 2018 (r332122) @@ -39,8 +39,6 @@ * $FreeBSD$ */ -#include "opt_compat.h" - #include #include #include Modified: head/sys/geom/geom_dev.c ============================================================================== --- head/sys/geom/geom_dev.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/geom/geom_dev.c Fri Apr 6 17:35:35 2018 (r332122) @@ -38,8 +38,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/i386/i386/genassym.c ============================================================================== --- head/sys/i386/i386/genassym.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/i386/i386/genassym.c Fri Apr 6 17:35:35 2018 (r332122) @@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$"); #include "opt_apic.h" -#include "opt_compat.h" #include "opt_hwpmc_hooks.h" #include "opt_kstack_pages.h" Modified: head/sys/i386/i386/locore.s ============================================================================== --- head/sys/i386/i386/locore.s Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/i386/i386/locore.s Fri Apr 6 17:35:35 2018 (r332122) @@ -40,7 +40,6 @@ */ #include "opt_bootp.h" -#include "opt_compat.h" #include "opt_nfsroot.h" #include "opt_pmap.h" Modified: head/sys/i386/i386/machdep.c ============================================================================== --- head/sys/i386/i386/machdep.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/i386/i386/machdep.c Fri Apr 6 17:35:35 2018 (r332122) @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include "opt_apic.h" #include "opt_atpic.h" -#include "opt_compat.h" #include "opt_cpu.h" #include "opt_ddb.h" #include "opt_inet.h" Modified: head/sys/i386/i386/sigtramp.s ============================================================================== --- head/sys/i386/i386/sigtramp.s Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/i386/i386/sigtramp.s Fri Apr 6 17:35:35 2018 (r332122) @@ -39,8 +39,6 @@ * and many others. */ -#include "opt_compat.h" - #include #include #include Modified: head/sys/i386/linux/linux_dummy.c ============================================================================== --- head/sys/i386/linux/linux_dummy.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/i386/linux/linux_dummy.c Fri Apr 6 17:35:35 2018 (r332122) @@ -29,8 +29,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/imgact_elf.c Fri Apr 6 17:35:35 2018 (r332122) @@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$"); #include "opt_capsicum.h" -#include "opt_compat.h" #include #include Modified: head/sys/kern/init_sysent.c ============================================================================== --- head/sys/kern/init_sysent.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/init_sysent.c Fri Apr 6 17:35:35 2018 (r332122) @@ -5,8 +5,6 @@ * $FreeBSD$ */ -#include "opt_compat.h" - #include #include #include Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_descrip.c Fri Apr 6 17:35:35 2018 (r332122) @@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$"); #include "opt_capsicum.h" -#include "opt_compat.h" #include "opt_ddb.h" #include "opt_ktrace.h" Modified: head/sys/kern/kern_event.c ============================================================================== --- head/sys/kern/kern_event.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_event.c Fri Apr 6 17:35:35 2018 (r332122) @@ -31,7 +31,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_ktrace.h" #include "opt_kqueue.h" Modified: head/sys/kern/kern_exec.c ============================================================================== --- head/sys/kern/kern_exec.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_exec.c Fri Apr 6 17:35:35 2018 (r332122) @@ -30,7 +30,6 @@ __FBSDID("$FreeBSD$"); #include "opt_capsicum.h" -#include "opt_compat.h" #include "opt_hwpmc_hooks.h" #include "opt_ktrace.h" #include "opt_vm.h" Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_exit.c Fri Apr 6 17:35:35 2018 (r332122) @@ -39,7 +39,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_ktrace.h" #include Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_jail.c Fri Apr 6 17:35:35 2018 (r332122) @@ -31,7 +31,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_ddb.h" #include "opt_inet.h" #include "opt_inet6.h" Modified: head/sys/kern/kern_mib.c ============================================================================== --- head/sys/kern/kern_mib.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_mib.c Fri Apr 6 17:35:35 2018 (r332122) @@ -40,7 +40,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_posix.h" #include "opt_config.h" Modified: head/sys/kern/kern_module.c ============================================================================== --- head/sys/kern/kern_module.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_module.c Fri Apr 6 17:35:35 2018 (r332122) @@ -26,8 +26,6 @@ * SUCH DAMAGE. */ -#include "opt_compat.h" - #include __FBSDID("$FreeBSD$"); Modified: head/sys/kern/kern_proc.c ============================================================================== --- head/sys/kern/kern_proc.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_proc.c Fri Apr 6 17:35:35 2018 (r332122) @@ -34,7 +34,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_ddb.h" #include "opt_ktrace.h" #include "opt_kstack_pages.h" Modified: head/sys/kern/kern_prot.c ============================================================================== --- head/sys/kern/kern_prot.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_prot.c Fri Apr 6 17:35:35 2018 (r332122) @@ -46,7 +46,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_inet.h" #include "opt_inet6.h" Modified: head/sys/kern/kern_resource.c ============================================================================== --- head/sys/kern/kern_resource.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_resource.c Fri Apr 6 17:35:35 2018 (r332122) @@ -39,8 +39,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/kern/kern_sendfile.c ============================================================================== --- head/sys/kern/kern_sendfile.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_sendfile.c Fri Apr 6 17:35:35 2018 (r332122) @@ -30,8 +30,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" - #include #include #include Modified: head/sys/kern/kern_sharedpage.c ============================================================================== --- head/sys/kern/kern_sharedpage.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_sharedpage.c Fri Apr 6 17:35:35 2018 (r332122) @@ -33,7 +33,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_vm.h" #include Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_sig.c Fri Apr 6 17:35:35 2018 (r332122) @@ -39,7 +39,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_ktrace.h" #include Modified: head/sys/kern/kern_sysctl.c ============================================================================== --- head/sys/kern/kern_sysctl.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_sysctl.c Fri Apr 6 17:35:35 2018 (r332122) @@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$"); #include "opt_capsicum.h" -#include "opt_compat.h" #include "opt_ktrace.h" #include Modified: head/sys/kern/kern_tc.c ============================================================================== --- head/sys/kern/kern_tc.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_tc.c Fri Apr 6 17:35:35 2018 (r332122) @@ -21,7 +21,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_ntp.h" #include "opt_ffclock.h" Modified: head/sys/kern/kern_thr.c ============================================================================== --- head/sys/kern/kern_thr.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_thr.c Fri Apr 6 17:35:35 2018 (r332122) @@ -29,7 +29,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_posix.h" #include #include Modified: head/sys/kern/kern_umtx.c ============================================================================== --- head/sys/kern/kern_umtx.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_umtx.c Fri Apr 6 17:35:35 2018 (r332122) @@ -34,7 +34,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_compat.h" #include "opt_umtx_profiling.h" #include Modified: head/sys/kern/kern_xxx.c ============================================================================== --- head/sys/kern/kern_xxx.c Fri Apr 6 17:23:47 2018 (r332121) +++ head/sys/kern/kern_xxx.c Fri Apr 6 17:35:35 2018 (r332122) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@freebsd.org Fri Apr 6 18:30:17 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 766B6F9CA76; Fri, 6 Apr 2018 18:30:17 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1DB686D84A; Fri, 6 Apr 2018 18:30:17 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 5EFEF10AFAE; Fri, 6 Apr 2018 14:30:16 -0400 (EDT) From: John Baldwin To: Ian Lepore Cc: Jeff Roberson , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r327954 - in head/sys: amd64/conf conf dev/acpica vm x86/acpica Date: Fri, 06 Apr 2018 11:18:10 -0700 Message-ID: <21787612.Ya3XE9VMiB@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) In-Reply-To: <1522611345.49673.175.camel@freebsd.org> References: <201801140336.w0E3a3xv010728@repo.freebsd.org> <1522611345.49673.175.camel@freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Fri, 06 Apr 2018 14:30:16 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 18:30:17 -0000 On Sunday, April 01, 2018 01:35:45 PM Ian Lepore wrote: > On Sun, 2018-01-14 at 03:36 +0000, Jeff Roberson wrote: > > Author: jeff > > Date: Sun Jan 14 03:36:03 2018 > > New Revision: 327954 > > URL: https://svnweb.freebsd.org/changeset/base/327954 > > > > Log: > > Move VM_NUMA_ALLOC and DEVICE_NUMA under the single global config > > option NUMA. > > > > Sponsored by: Netflix, Dell/EMC Isilon > > Discussed with: jhb > > It turns out this breaks building powerpc lint kernels. It shakes out > like this... makeLINT.mk copies sys/conf/NOTES into the generated LINT > config (I guess on the theory that things documented in NOTES are > supported by all arches). So option NUMA is present on powerpc, but the > powerpc vmparam.h doesn't define VM_LEVEL_0_ORDER so the build fails. > (Mips also doesn't define that, but it has no lint kernel build at all > right now.) > > It could be fixed in vm_domainset.c with: > > -#ifdef NUMA > +#if defined(NUMA) && defined(VM_LEVEL_0_ORDER) > > but there may be some better way to fix it, I don't know that much > about this stuff. Maybe add 'nooption NUMA' to sys/powerpc/conf/NOTES? (It has several nooption and nodevice lines already) If it affects more than powerpc then I wouldn't do that, but if it's only powerpc then I think patching powerpc/conf/NOTES is most consistent with how this has been handled to date. -- John Baldwin From owner-svn-src-head@freebsd.org Fri Apr 6 18:30:22 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 020A7F9CADA; Fri, 6 Apr 2018 18:30:22 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2EEA56D929; Fri, 6 Apr 2018 18:30:19 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 60E5F10AFCD; Fri, 6 Apr 2018 14:30:18 -0400 (EDT) From: John Baldwin To: Ed Maste Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r332090 - head/stand/i386 Date: Fri, 06 Apr 2018 10:54:11 -0700 Message-ID: <8352524.sDEuJtqkT0@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) In-Reply-To: <201804060257.w362vwi3023158@repo.freebsd.org> References: <201804060257.w362vwi3023158@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Fri, 06 Apr 2018 14:30:18 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 18:30:22 -0000 On Friday, April 06, 2018 02:57:58 AM Ed Maste wrote: > Author: emaste > Date: Fri Apr 6 02:57:58 2018 > New Revision: 332090 > URL: https://svnweb.freebsd.org/changeset/base/332090 > > Log: > stand: pass --no-rosegment for i386 bits when linking with lld > > btxld does not correctly handle input with other than 2 PT_LOAD > segments. Passing --no-rosegment lets lld produce output eqivalent to > ld.bfd: 2 PT_LOAD segments and no PT_GNU_RELRO. > > PR: 225775 > MFC after: 3 weeks > Sponsored by: The FreeBSD Foundation > Differential Revision: https://reviews.freebsd.org/D14956 > > Modified: > head/stand/i386/Makefile.inc > > Modified: head/stand/i386/Makefile.inc > ============================================================================== > --- head/stand/i386/Makefile.inc Fri Apr 6 02:47:43 2018 (r332089) > +++ head/stand/i386/Makefile.inc Fri Apr 6 02:57:58 2018 (r332090) > @@ -2,8 +2,13 @@ > # > # $FreeBSD$ > > +.sinclude > + > LOADER_ADDRESS?=0x200000 > LDFLAGS+= -nostdlib > +.if defined(LINKER_TYPE) && ${LINKER_TYPE} == "lld" > +LDFLAGS+= -Wl,--no-rosegment > +.endif Maybe we should support LDFLAGS.${LINKER_TYPE} as we do for CFLAGS, etc.? -- John Baldwin From owner-svn-src-head@freebsd.org Fri Apr 6 18:37:02 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 30C2DF9D607 for ; Fri, 6 Apr 2018 18:37:02 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x231.google.com (mail-io0-x231.google.com [IPv6:2607:f8b0:4001:c06::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B4C566E434 for ; Fri, 6 Apr 2018 18:37:01 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x231.google.com with SMTP id o4so2783630iod.3 for ; Fri, 06 Apr 2018 11:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=9fu0V16jHz0Pt9l8dZpue/kBf6mtYa/J5hPWO0RMTrw=; b=rHFlEz89CMewHNX3qoi8fNOmy+Im4t+dllpxbBWaMkASskS0Uq6+UtvTLyJtfCExpO ao1qIRL4+zcwUZBk+NZP5eA8MX98Z2g+FcI37mhmXbD6AvqXOx6X97mGuePpQLq/dgm2 ar/eyIcz/jfaONahN8WSJulOTE2dDc95/SKy40oMQzOKxg4kbrnQ5vpPwCrH+4Geqaow qECzM/eyDDaJXLSvS3kPvGCFJs9d2uuE/RyjpolsV2lvFZoRvHqhENBOrdVpJS6fvG8z 0TZfdevv7nyw4zt4wyi6jBqvVBa6+7J2QChOpDbI/wsh07uKhcyGTckV8VGesBfNdgEl xtMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=9fu0V16jHz0Pt9l8dZpue/kBf6mtYa/J5hPWO0RMTrw=; b=b/Wt6xxMsIfPc+dy+RPf8WhApEb3eAHheTxkBt4Bztf1vVzIVdigSD10QUKpR7mjjL 65OW5vQOCIpeeuXFwbish/SLO3TjfpXN2xGyNJWoRT7yeQLsiPEcYLfhFeNpb4pOYnX+ ykKMItefxuh+QwbFrmfuOnHbmIfj4yb8Vx9F/6xio4VXn/VsFlNmXfM3T4tPTpF0g0/t 3Hn8uFJGzgUoq+Rxqdg7oZ8YZrCl78TtPV6z2unLvf2yG3KskQLLH2Rv6rza93NKCZO6 PZM8LaywDyZ8DSyPVbZfHAgxoCF+JLpBEzKzj9IvvGYRjfefbl5U8YPUAIDBRM+Ye1u8 6PWQ== X-Gm-Message-State: ALQs6tAFvqOw4whKh0qSEgFBJVfXNJCpyhAgQx6+GDA5w8GmuZwl7YcW 1D0XoLGnC+bEete+CYzdJLgdbKgr2QiV1MkFjW9yVg== X-Google-Smtp-Source: AIpwx49hk2AY5b2II+yo+WLIeqeD1sk8q9HSdAee2oE/1X6giikYbKj4q0BEsNaNAiB+pemunRPA+I5QFzI1kDg83hM= X-Received: by 10.107.18.162 with SMTP id 34mr25119907ios.168.1523039820969; Fri, 06 Apr 2018 11:37:00 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.203.196 with HTTP; Fri, 6 Apr 2018 11:37:00 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: <8352524.sDEuJtqkT0@ralph.baldwin.cx> References: <201804060257.w362vwi3023158@repo.freebsd.org> <8352524.sDEuJtqkT0@ralph.baldwin.cx> From: Warner Losh Date: Fri, 6 Apr 2018 12:37:00 -0600 X-Google-Sender-Auth: 3LDF9k79Q64N-teCydZZh-e9E7s Message-ID: Subject: Re: svn commit: r332090 - head/stand/i386 To: John Baldwin Cc: Ed Maste , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 18:37:02 -0000 On Fri, Apr 6, 2018 at 11:54 AM, John Baldwin wrote: > On Friday, April 06, 2018 02:57:58 AM Ed Maste wrote: > > Author: emaste > > Date: Fri Apr 6 02:57:58 2018 > > New Revision: 332090 > > URL: https://svnweb.freebsd.org/changeset/base/332090 > > > > Log: > > stand: pass --no-rosegment for i386 bits when linking with lld > > > > btxld does not correctly handle input with other than 2 PT_LOAD > > segments. Passing --no-rosegment lets lld produce output eqivalent to > > ld.bfd: 2 PT_LOAD segments and no PT_GNU_RELRO. > > > > PR: 225775 > > MFC after: 3 weeks > > Sponsored by: The FreeBSD Foundation > > Differential Revision: https://reviews.freebsd.org/D14956 > > > > Modified: > > head/stand/i386/Makefile.inc > > > > Modified: head/stand/i386/Makefile.inc > > ============================================================ > ================== > > --- head/stand/i386/Makefile.inc Fri Apr 6 02:47:43 2018 > (r332089) > > +++ head/stand/i386/Makefile.inc Fri Apr 6 02:57:58 2018 > (r332090) > > @@ -2,8 +2,13 @@ > > # > > # $FreeBSD$ > > > > +.sinclude > > + > > LOADER_ADDRESS?=0x200000 > > LDFLAGS+= -nostdlib > > +.if defined(LINKER_TYPE) && ${LINKER_TYPE} == "lld" > > +LDFLAGS+= -Wl,--no-rosegment > > +.endif > > Maybe we should support LDFLAGS.${LINKER_TYPE} as we do for CFLAGS, etc.? > I concur. It doesn't take too many of these for that to pay off big time, especially if we have to do anything globally... Warner From owner-svn-src-head@freebsd.org Fri Apr 6 19:11:23 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0A3C1F9FF64; Fri, 6 Apr 2018 19:11:23 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B415F704CC; Fri, 6 Apr 2018 19:11:22 +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 AF24215E9E; Fri, 6 Apr 2018 19:11:22 +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 w36JBMBk017794; Fri, 6 Apr 2018 19:11:22 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36JBMvB017793; Fri, 6 Apr 2018 19:11:22 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804061911.w36JBMvB017793@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Fri, 6 Apr 2018 19:11:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332133 - head/sys/conf X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: head/sys/conf X-SVN-Commit-Revision: 332133 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 19:11:23 -0000 Author: brooks Date: Fri Apr 6 19:11:22 2018 New Revision: 332133 URL: https://svnweb.freebsd.org/changeset/base/332133 Log: Add an unused _COMPAT_LINUX32 option to ensure opt_compat.h exists on platforms without COMPAT_LINUX32. Reported by: kib Modified: head/sys/conf/options Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Fri Apr 6 19:10:11 2018 (r332132) +++ head/sys/conf/options Fri Apr 6 19:11:22 2018 (r332133) @@ -92,6 +92,7 @@ COMPAT_FREEBSD11 opt_global.h COMPAT_CLOUDABI32 opt_dontuse.h COMPAT_CLOUDABI64 opt_dontuse.h COMPAT_LINUXKPI opt_dontuse.h +_COMPAT_LINUX32 opt_compat.h # XXX: make sure opt_compat.h exists COMPILING_LINT opt_global.h CY_PCI_FASTINTR DEADLKRES opt_watchdog.h From owner-svn-src-head@freebsd.org Fri Apr 6 19:20:46 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EE3B5FA09A8; Fri, 6 Apr 2018 19:20:45 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 972F270EDF; Fri, 6 Apr 2018 19:20:45 +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 9202C1602B; Fri, 6 Apr 2018 19:20:45 +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 w36JKjxg022969; Fri, 6 Apr 2018 19:20:45 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36JKj4b022968; Fri, 6 Apr 2018 19:20:45 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201804061920.w36JKj4b022968@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Fri, 6 Apr 2018 19:20:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332136 - head/sys/netpfil/pf X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: head/sys/netpfil/pf X-SVN-Commit-Revision: 332136 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 19:20:46 -0000 Author: kp Date: Fri Apr 6 19:20:45 2018 New Revision: 332136 URL: https://svnweb.freebsd.org/changeset/base/332136 Log: pf: Improve ioctl validation for DIOCIGETIFACES and DIOCXCOMMIT These ioctls can process a number of items at a time, which puts us at risk of overflow in mallocarray() and of impossibly large allocations even if we don't overflow. There's no obvious limit to the request size for these, so we limit the requests to something which won't overflow. Change the memory allocation to M_NOWAIT so excessive requests will fail rather than stall forever. MFC after: 1 week Modified: head/sys/netpfil/pf/pf_ioctl.c Modified: head/sys/netpfil/pf/pf_ioctl.c ============================================================================== --- head/sys/netpfil/pf/pf_ioctl.c Fri Apr 6 19:17:59 2018 (r332135) +++ head/sys/netpfil/pf/pf_ioctl.c Fri Apr 6 19:20:45 2018 (r332136) @@ -3143,10 +3143,17 @@ DIOCCHANGEADDR_error: error = ENODEV; break; } + + if (io->size < 0 || + WOULD_OVERFLOW(io->size, sizeof(struct pfioc_trans_e))) { + error = EINVAL; + break; + } + totlen = sizeof(struct pfioc_trans_e) * io->size; ioes = mallocarray(io->size, sizeof(struct pfioc_trans_e), - M_TEMP, M_WAITOK); - if (! ioes) { + M_TEMP, M_NOWAIT); + if (ioes == NULL) { error = ENOMEM; break; } @@ -3349,13 +3356,20 @@ DIOCCHANGEADDR_error: break; } + if (io->pfiio_size < 0 || + WOULD_OVERFLOW(io->pfiio_size, sizeof(struct pfi_kif))) { + error = EINVAL; + break; + } + bufsiz = io->pfiio_size * sizeof(struct pfi_kif); ifstore = mallocarray(io->pfiio_size, sizeof(struct pfi_kif), - M_TEMP, M_WAITOK); - if (! ifstore) { + M_TEMP, M_NOWAIT); + if (ifstore == NULL) { error = ENOMEM; break; } + PF_RULES_RLOCK(); pfi_get_ifaces(io->pfiio_name, ifstore, &io->pfiio_size); PF_RULES_RUNLOCK(); From owner-svn-src-head@freebsd.org Fri Apr 6 19:21:30 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 94173FA0A60; Fri, 6 Apr 2018 19:21:30 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 43E47710A8; Fri, 6 Apr 2018 19:21:30 +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 3ED2F16156; Fri, 6 Apr 2018 19:21:30 +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 w36JLUvQ024516; Fri, 6 Apr 2018 19:21:30 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36JLUV2024515; Fri, 6 Apr 2018 19:21:30 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201804061921.w36JLUV2024515@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Fri, 6 Apr 2018 19:21:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332137 - head/tests/sys/netpfil/pf/ioctl X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: head/tests/sys/netpfil/pf/ioctl X-SVN-Commit-Revision: 332137 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 19:21:30 -0000 Author: kp Date: Fri Apr 6 19:21:29 2018 New Revision: 332137 URL: https://svnweb.freebsd.org/changeset/base/332137 Log: pf tests: Basic ioctl validation for DIOCIGETIFACES and DIOCXCOMMIT Validate the DIOCIGETIFACES and DIOCXCOMMIT ioctls with invalid values. MFC after: 1 week Modified: head/tests/sys/netpfil/pf/ioctl/validation.c Modified: head/tests/sys/netpfil/pf/ioctl/validation.c ============================================================================== --- head/tests/sys/netpfil/pf/ioctl/validation.c Fri Apr 6 19:20:45 2018 (r332136) +++ head/tests/sys/netpfil/pf/ioctl/validation.c Fri Apr 6 19:21:29 2018 (r332137) @@ -255,6 +255,63 @@ ATF_TC_BODY(settflags, tc) COMMON_CLEANUP(); } +ATF_TC_WITHOUT_HEAD(igetifaces); +ATF_TC_BODY(igetifaces, tc) +{ + struct pfioc_iface io; + struct pfi_kif kif; + + COMMON_HEAD(); + + bzero(&io, sizeof(io)); + io.pfiio_flags = 0; + io.pfiio_buffer = &kif; + io.pfiio_esize = sizeof(kif); + + /* Negative size */ + io.pfiio_size = -1; + if (ioctl(dev, DIOCIGETIFACES, &io) == 0) + atf_tc_fail("request with size -1 succeeded"); + + /* Overflow size */ + io.pfiio_size = 1 << 31; + if (ioctl(dev, DIOCIGETIFACES, &io) == 0) + atf_tc_fail("request with size 1 << 31 succeeded"); + + COMMON_CLEANUP(); +} + +ATF_TC_WITHOUT_HEAD(commit); +ATF_TC_BODY(commit, tc) +{ + struct pfioc_trans io; + struct pfioc_trans_e ioe; + + COMMON_HEAD(); + + bzero(&io, sizeof(io)); + io.esize = sizeof(ioe); + io.array = &ioe; + + /* Negative size */ + io.size = -1; + if (ioctl(dev, DIOCXCOMMIT, &io) == 0) + atf_tc_fail("request with size -1 succeeded"); + + /* Overflow size */ + io.size = 1 << 30; + if (ioctl(dev, DIOCXCOMMIT, &io) == 0) + atf_tc_fail("request with size 1 << 30 succeeded"); + + /* NULL buffer */ + io.size = 1; + io.array = NULL; + if (ioctl(dev, DIOCXCOMMIT, &io) == 0) + atf_tc_fail("request with size -1 succeeded"); + + COMMON_CLEANUP(); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, addtables); @@ -263,6 +320,8 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, gettstats); ATF_TP_ADD_TC(tp, clrtstats); ATF_TP_ADD_TC(tp, settflags); + ATF_TP_ADD_TC(tp, igetifaces); + ATF_TP_ADD_TC(tp, commit); return (atf_no_error()); } From owner-svn-src-head@freebsd.org Fri Apr 6 19:22:22 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B88B6FA0C0B; Fri, 6 Apr 2018 19:22:22 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9026D713E4; Fri, 6 Apr 2018 19:22:22 +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 8B2941619D; Fri, 6 Apr 2018 19:22:22 +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 w36JMM0R027550; Fri, 6 Apr 2018 19:22:22 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36JMMWA027549; Fri, 6 Apr 2018 19:22:22 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201804061922.w36JMMWA027549@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Fri, 6 Apr 2018 19:22:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332139 - head/tests/sys/netpfil/pf/ioctl X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: head/tests/sys/netpfil/pf/ioctl X-SVN-Commit-Revision: 332139 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 19:22:22 -0000 Author: kp Date: Fri Apr 6 19:22:22 2018 New Revision: 332139 URL: https://svnweb.freebsd.org/changeset/base/332139 Log: pf tests: Try to provoke a memory leak There was a memory leak in the DIOCRADDTABLES ioctl() code which could be triggered by trying to add tables with the same name. Try to provoke this memory leak. It was fixed in r331225. MFC after: 1 week Modified: head/tests/sys/netpfil/pf/ioctl/validation.c Modified: head/tests/sys/netpfil/pf/ioctl/validation.c ============================================================================== --- head/tests/sys/netpfil/pf/ioctl/validation.c Fri Apr 6 19:21:36 2018 (r332138) +++ head/tests/sys/netpfil/pf/ioctl/validation.c Fri Apr 6 19:22:22 2018 (r332139) @@ -66,6 +66,7 @@ ATF_TC_BODY(addtables, tc) { struct pfioc_table io; struct pfr_table tbl; + struct pfr_table tbls[4]; int flags; COMMON_HEAD(); @@ -92,6 +93,14 @@ ATF_TC_BODY(addtables, tc) io.pfrio_buffer = NULL; if (ioctl(dev, DIOCRADDTABLES, &io) == 0) atf_tc_fail("Request with NULL buffer succeeded"); + + /* This can provoke a memory leak, see r331225. */ + io.pfrio_size = 4; + for (int i = 0; i < io.pfrio_size; i++) + common_init_tbl(&tbls[i]); + + io.pfrio_buffer = &tbls; + ioctl(dev, DIOCRADDTABLES, &io); COMMON_CLEANUP(); } From owner-svn-src-head@freebsd.org Fri Apr 6 19:36:36 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 39A9BFA1CF8; Fri, 6 Apr 2018 19:36:36 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CF54471F6D; Fri, 6 Apr 2018 19:36:35 +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 C5FBA16373; Fri, 6 Apr 2018 19:36:35 +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 w36JaZ8v033105; Fri, 6 Apr 2018 19:36:35 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36JaZVq033104; Fri, 6 Apr 2018 19:36:35 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201804061936.w36JaZVq033104@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Fri, 6 Apr 2018 19:36:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332142 - head/sys/netpfil/pf X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: head/sys/netpfil/pf X-SVN-Commit-Revision: 332142 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 19:36:36 -0000 Author: kp Date: Fri Apr 6 19:36:35 2018 New Revision: 332142 URL: https://svnweb.freebsd.org/changeset/base/332142 Log: pf: Improve ioctl validation Ensure that multiplications for memory allocations cannot overflow, and that we'll not try to allocate M_WAITOK for potentially overly large allocations. MFC after: 1 week Modified: head/sys/netpfil/pf/pf_ioctl.c Modified: head/sys/netpfil/pf/pf_ioctl.c ============================================================================== --- head/sys/netpfil/pf/pf_ioctl.c Fri Apr 6 19:34:21 2018 (r332141) +++ head/sys/netpfil/pf/pf_ioctl.c Fri Apr 6 19:36:35 2018 (r332142) @@ -2740,9 +2740,14 @@ DIOCCHANGEADDR_error: error = ENODEV; break; } + if (io->pfrio_size < 0 || + WOULD_OVERFLOW(io->pfrio_size, sizeof(struct pfr_addr))) { + error = EINVAL; + break; + } totlen = io->pfrio_size * sizeof(struct pfr_addr); pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), - M_TEMP, M_WAITOK); + M_TEMP, M_NOWAIT); if (! pfras) { error = ENOMEM; break; @@ -2772,9 +2777,14 @@ DIOCCHANGEADDR_error: error = ENODEV; break; } + if (io->pfrio_size < 0 || + WOULD_OVERFLOW(io->pfrio_size, sizeof(struct pfr_addr))) { + error = EINVAL; + break; + } totlen = io->pfrio_size * sizeof(struct pfr_addr); pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), - M_TEMP, M_WAITOK); + M_TEMP, M_NOWAIT); if (! pfras) { error = ENOMEM; break; @@ -2804,10 +2814,18 @@ DIOCCHANGEADDR_error: error = ENODEV; break; } + if (io->pfrio_size < 0 || io->pfrio_size2 < 0) { + error = EINVAL; + break; + } count = max(io->pfrio_size, io->pfrio_size2); + if (WOULD_OVERFLOW(count, sizeof(struct pfr_addr))) { + error = EINVAL; + break; + } totlen = count * sizeof(struct pfr_addr); pfras = mallocarray(count, sizeof(struct pfr_addr), M_TEMP, - M_WAITOK); + M_NOWAIT); if (! pfras) { error = ENOMEM; break; @@ -2838,9 +2856,14 @@ DIOCCHANGEADDR_error: error = ENODEV; break; } + if (io->pfrio_size < 0 || + WOULD_OVERFLOW(io->pfrio_size, sizeof(struct pfr_addr))) { + error = EINVAL; + break; + } totlen = io->pfrio_size * sizeof(struct pfr_addr); pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), - M_TEMP, M_WAITOK); + M_TEMP, M_NOWAIT); if (! pfras) { error = ENOMEM; break; @@ -2864,9 +2887,14 @@ DIOCCHANGEADDR_error: error = ENODEV; break; } + if (io->pfrio_size < 0 || + WOULD_OVERFLOW(io->pfrio_size, sizeof(struct pfr_astats))) { + error = EINVAL; + break; + } totlen = io->pfrio_size * sizeof(struct pfr_astats); pfrastats = mallocarray(io->pfrio_size, - sizeof(struct pfr_astats), M_TEMP, M_WAITOK); + sizeof(struct pfr_astats), M_TEMP, M_NOWAIT); if (! pfrastats) { error = ENOMEM; break; @@ -2890,9 +2918,14 @@ DIOCCHANGEADDR_error: error = ENODEV; break; } + if (io->pfrio_size < 0 || + WOULD_OVERFLOW(io->pfrio_size, sizeof(struct pfr_addr))) { + error = EINVAL; + break; + } totlen = io->pfrio_size * sizeof(struct pfr_addr); pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), - M_TEMP, M_WAITOK); + M_TEMP, M_NOWAIT); if (! pfras) { error = ENOMEM; break; @@ -2922,9 +2955,14 @@ DIOCCHANGEADDR_error: error = ENODEV; break; } + if (io->pfrio_size < 0 || + WOULD_OVERFLOW(io->pfrio_size, sizeof(struct pfr_addr))) { + error = EINVAL; + break; + } totlen = io->pfrio_size * sizeof(struct pfr_addr); pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), - M_TEMP, M_WAITOK); + M_TEMP, M_NOWAIT); if (! pfras) { error = ENOMEM; break; @@ -2954,9 +2992,14 @@ DIOCCHANGEADDR_error: error = ENODEV; break; } + if (io->pfrio_size < 0 || + WOULD_OVERFLOW(io->pfrio_size, sizeof(struct pfr_addr))) { + error = EINVAL; + break; + } totlen = io->pfrio_size * sizeof(struct pfr_addr); pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), - M_TEMP, M_WAITOK); + M_TEMP, M_NOWAIT); if (! pfras) { error = ENOMEM; break; @@ -3001,9 +3044,14 @@ DIOCCHANGEADDR_error: error = ENODEV; break; } + if (io->size < 0 || + WOULD_OVERFLOW(io->size, sizeof(struct pfioc_trans_e))) { + error = EINVAL; + break; + } totlen = sizeof(struct pfioc_trans_e) * io->size; ioes = mallocarray(io->size, sizeof(struct pfioc_trans_e), - M_TEMP, M_WAITOK); + M_TEMP, M_NOWAIT); if (! ioes) { error = ENOMEM; break; @@ -3072,9 +3120,14 @@ DIOCCHANGEADDR_error: error = ENODEV; break; } + if (io->size < 0 || + WOULD_OVERFLOW(io->size, sizeof(struct pfioc_trans_e))) { + error = EINVAL; + break; + } totlen = sizeof(struct pfioc_trans_e) * io->size; ioes = mallocarray(io->size, sizeof(struct pfioc_trans_e), - M_TEMP, M_WAITOK); + M_TEMP, M_NOWAIT); if (! ioes) { error = ENOMEM; break; From owner-svn-src-head@freebsd.org Fri Apr 6 19:37:15 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B0AFFFA1D79; Fri, 6 Apr 2018 19:37:15 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6330F72093; Fri, 6 Apr 2018 19:37:15 +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 5E0DF16379; Fri, 6 Apr 2018 19:37:15 +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 w36JbFw3033185; Fri, 6 Apr 2018 19:37:15 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36JbFfx033184; Fri, 6 Apr 2018 19:37:15 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201804061937.w36JbFfx033184@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Fri, 6 Apr 2018 19:37:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332143 - head/tests/sys/netpfil/pf/ioctl X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: head/tests/sys/netpfil/pf/ioctl X-SVN-Commit-Revision: 332143 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 19:37:15 -0000 Author: kp Date: Fri Apr 6 19:37:15 2018 New Revision: 332143 URL: https://svnweb.freebsd.org/changeset/base/332143 Log: pf tests: Basic ioctl validation Basic validation tests for DIOCRADDADDRS, DIOCRDELADDRS, DIOCRSETADDRS, DIOCRGETADDRS, DIOCRGETASTATS, DIOCRCLRASTATS, DIOCRTSTADDRS, DIOCRINADEFINE, DIOCXBEGIN and DIOCXROLLBACK. MFC after: 1 week Modified: head/tests/sys/netpfil/pf/ioctl/validation.c Modified: head/tests/sys/netpfil/pf/ioctl/validation.c ============================================================================== --- head/tests/sys/netpfil/pf/ioctl/validation.c Fri Apr 6 19:36:35 2018 (r332142) +++ head/tests/sys/netpfil/pf/ioctl/validation.c Fri Apr 6 19:37:15 2018 (r332143) @@ -264,6 +264,232 @@ ATF_TC_BODY(settflags, tc) COMMON_CLEANUP(); } +ATF_TC_WITHOUT_HEAD(addaddrs); +ATF_TC_BODY(addaddrs, tc) +{ + struct pfioc_table io; + struct pfr_addr addr; + + COMMON_HEAD(); + + bzero(&addr, sizeof(addr)); + bzero(&io, sizeof(io)); + io.pfrio_flags = 0; + io.pfrio_buffer = &addr; + io.pfrio_esize = sizeof(addr); + + /* Negative size. */ + io.pfrio_size = -1; + if (ioctl(dev, DIOCRADDADDRS, &io) == 0) + atf_tc_fail("Request with size -1 succeeded"); + + /* Overly large size. */ + io.pfrio_size = 1 << 28; + if (ioctl(dev, DIOCRADDADDRS, &io) == 0) + atf_tc_fail("Reuqest with size 1 << 28 failed"); + + COMMON_CLEANUP(); +} + +ATF_TC_WITHOUT_HEAD(deladdrs); +ATF_TC_BODY(deladdrs, tc) +{ + struct pfioc_table io; + struct pfr_addr addr; + + COMMON_HEAD(); + + bzero(&addr, sizeof(addr)); + bzero(&io, sizeof(io)); + io.pfrio_flags = 0; + io.pfrio_buffer = &addr; + io.pfrio_esize = sizeof(addr); + + /* Negative size. */ + io.pfrio_size = -1; + if (ioctl(dev, DIOCRDELADDRS, &io) == 0) + atf_tc_fail("Request with size -1 succeeded"); + + /* Overly large size. */ + io.pfrio_size = 1 << 28; + if (ioctl(dev, DIOCRDELADDRS, &io) == 0) + atf_tc_fail("Reuqest with size 1 << 28 failed"); + + COMMON_CLEANUP(); +} + +ATF_TC_WITHOUT_HEAD(setaddrs); +ATF_TC_BODY(setaddrs, tc) +{ + struct pfioc_table io; + struct pfr_addr addr; + + COMMON_HEAD(); + + bzero(&addr, sizeof(addr)); + bzero(&io, sizeof(io)); + io.pfrio_flags = 0; + io.pfrio_buffer = &addr; + io.pfrio_esize = sizeof(addr); + + /* Negative size. */ + io.pfrio_size = -1; + if (ioctl(dev, DIOCRSETADDRS, &io) == 0) + atf_tc_fail("Request with size -1 succeeded"); + + /* Overly large size. */ + io.pfrio_size = 1 << 28; + if (ioctl(dev, DIOCRSETADDRS, &io) == 0) + atf_tc_fail("Reuqest with size 1 << 28 failed"); + + COMMON_CLEANUP(); +} + +ATF_TC_WITHOUT_HEAD(getaddrs); +ATF_TC_BODY(getaddrs, tc) +{ + struct pfioc_table io; + struct pfr_addr addr; + + COMMON_HEAD(); + + bzero(&addr, sizeof(addr)); + bzero(&io, sizeof(io)); + io.pfrio_flags = 0; + io.pfrio_buffer = &addr; + io.pfrio_esize = sizeof(addr); + + common_init_tbl(&io.pfrio_table); + + /* Negative size. */ + io.pfrio_size = -1; + if (ioctl(dev, DIOCRGETADDRS, &io) == 0) + atf_tc_fail("Request with size -1 succeeded"); + + /* Overly large size. */ + io.pfrio_size = 1 << 24; + if (ioctl(dev, DIOCRGETADDRS, &io) == 0) + atf_tc_fail("Request with size 1 << 24 failed"); + + COMMON_CLEANUP(); +} + +ATF_TC_WITHOUT_HEAD(getastats); +ATF_TC_BODY(getastats, tc) +{ + struct pfioc_table io; + struct pfr_astats astats; + + COMMON_HEAD(); + + bzero(&astats, sizeof(astats)); + bzero(&io, sizeof(io)); + io.pfrio_flags = 0; + io.pfrio_buffer = &astats; + io.pfrio_esize = sizeof(astats); + + common_init_tbl(&io.pfrio_table); + + /* Negative size. */ + io.pfrio_size = -1; + if (ioctl(dev, DIOCRGETASTATS, &io) == 0) + atf_tc_fail("Request with size -1 succeeded"); + + /* Overly large size. */ + io.pfrio_size = 1 << 24; + if (ioctl(dev, DIOCRGETASTATS, &io) == 0) + atf_tc_fail("Request with size 1 << 24 failed"); + + COMMON_CLEANUP(); +} + +ATF_TC_WITHOUT_HEAD(clrastats); +ATF_TC_BODY(clrastats, tc) +{ + struct pfioc_table io; + struct pfr_addr addr; + + COMMON_HEAD(); + + bzero(&addr, sizeof(addr)); + bzero(&io, sizeof(io)); + io.pfrio_flags = 0; + io.pfrio_buffer = &addr; + io.pfrio_esize = sizeof(addr); + + common_init_tbl(&io.pfrio_table); + + /* Negative size. */ + io.pfrio_size = -1; + if (ioctl(dev, DIOCRCLRASTATS, &io) == 0) + atf_tc_fail("Request with size -1 succeeded"); + + /* Overly large size. */ + io.pfrio_size = 1 << 24; + if (ioctl(dev, DIOCRCLRASTATS, &io) == 0) + atf_tc_fail("Request with size 1 << 24 failed"); + + COMMON_CLEANUP(); +} + +ATF_TC_WITHOUT_HEAD(tstaddrs); +ATF_TC_BODY(tstaddrs, tc) +{ + struct pfioc_table io; + struct pfr_addr addr; + + COMMON_HEAD(); + + bzero(&addr, sizeof(addr)); + bzero(&io, sizeof(io)); + io.pfrio_flags = 0; + io.pfrio_buffer = &addr; + io.pfrio_esize = sizeof(addr); + + common_init_tbl(&io.pfrio_table); + + /* Negative size. */ + io.pfrio_size = -1; + if (ioctl(dev, DIOCRTSTADDRS, &io) == 0) + atf_tc_fail("Request with size -1 succeeded"); + + /* Overly large size. */ + io.pfrio_size = 1 << 24; + if (ioctl(dev, DIOCRTSTADDRS, &io) == 0) + atf_tc_fail("Request with size 1 << 24 failed"); + + COMMON_CLEANUP(); +} + +ATF_TC_WITHOUT_HEAD(inadefine); +ATF_TC_BODY(inadefine, tc) +{ + struct pfioc_table io; + struct pfr_addr addr; + + COMMON_HEAD(); + + bzero(&addr, sizeof(addr)); + bzero(&io, sizeof(io)); + io.pfrio_flags = 0; + io.pfrio_buffer = &addr; + io.pfrio_esize = sizeof(addr); + + common_init_tbl(&io.pfrio_table); + + /* Negative size. */ + io.pfrio_size = -1; + if (ioctl(dev, DIOCRINADEFINE, &io) == 0) + atf_tc_fail("Request with size -1 succeeded"); + + /* Overly large size. */ + io.pfrio_size = 1 << 24; + if (ioctl(dev, DIOCRINADEFINE, &io) == 0) + atf_tc_fail("Request with size 1 << 24 failed"); + + COMMON_CLEANUP(); +} + ATF_TC_WITHOUT_HEAD(igetifaces); ATF_TC_BODY(igetifaces, tc) { @@ -290,6 +516,68 @@ ATF_TC_BODY(igetifaces, tc) COMMON_CLEANUP(); } +ATF_TC_WITHOUT_HEAD(cxbegin); +ATF_TC_BODY(cxbegin, tc) +{ + struct pfioc_trans io; + struct pfioc_trans_e ioe; + + COMMON_HEAD(); + + bzero(&io, sizeof(io)); + io.esize = sizeof(ioe); + io.array = &ioe; + + /* Negative size */ + io.size = -1; + if (ioctl(dev, DIOCXBEGIN, &io) == 0) + atf_tc_fail("request with size -1 succeeded"); + + /* Overflow size */ + io.size = 1 << 30; + if (ioctl(dev, DIOCXBEGIN, &io) == 0) + atf_tc_fail("request with size 1 << 30 succeeded"); + + /* NULL buffer */ + io.size = 1; + io.array = NULL; + if (ioctl(dev, DIOCXBEGIN, &io) == 0) + atf_tc_fail("request with size -1 succeeded"); + + COMMON_CLEANUP(); +} + +ATF_TC_WITHOUT_HEAD(cxrollback); +ATF_TC_BODY(cxrollback, tc) +{ + struct pfioc_trans io; + struct pfioc_trans_e ioe; + + COMMON_HEAD(); + + bzero(&io, sizeof(io)); + io.esize = sizeof(ioe); + io.array = &ioe; + + /* Negative size */ + io.size = -1; + if (ioctl(dev, DIOCXROLLBACK, &io) == 0) + atf_tc_fail("request with size -1 succeeded"); + + /* Overflow size */ + io.size = 1 << 30; + if (ioctl(dev, DIOCXROLLBACK, &io) == 0) + atf_tc_fail("request with size 1 << 30 succeeded"); + + /* NULL buffer */ + io.size = 1; + io.array = NULL; + if (ioctl(dev, DIOCXROLLBACK, &io) == 0) + atf_tc_fail("request with size -1 succeeded"); + + COMMON_CLEANUP(); +} + ATF_TC_WITHOUT_HEAD(commit); ATF_TC_BODY(commit, tc) { @@ -329,7 +617,16 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, gettstats); ATF_TP_ADD_TC(tp, clrtstats); ATF_TP_ADD_TC(tp, settflags); + ATF_TP_ADD_TC(tp, addaddrs); + ATF_TP_ADD_TC(tp, deladdrs); + ATF_TP_ADD_TC(tp, setaddrs); + ATF_TP_ADD_TC(tp, getaddrs); + ATF_TP_ADD_TC(tp, clrastats); + ATF_TP_ADD_TC(tp, tstaddrs); + ATF_TP_ADD_TC(tp, inadefine); ATF_TP_ADD_TC(tp, igetifaces); + ATF_TP_ADD_TC(tp, cxbegin); + ATF_TP_ADD_TC(tp, cxrollback); ATF_TP_ADD_TC(tp, commit); return (atf_no_error()); From owner-svn-src-head@freebsd.org Fri Apr 6 19:47:45 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CCAF1F80998; Fri, 6 Apr 2018 19:47:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4EF9B729BA; Fri, 6 Apr 2018 19:47:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 49C8E16515; Fri, 6 Apr 2018 19:47:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36Jljib038234; Fri, 6 Apr 2018 19:47:45 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36Jljbb038232; Fri, 6 Apr 2018 19:47:45 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201804061947.w36Jljbb038232@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 6 Apr 2018 19:47:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332145 - head/sys/cam/scsi X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/sys/cam/scsi X-SVN-Commit-Revision: 332145 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 19:47:46 -0000 Author: mav Date: Fri Apr 6 19:47:44 2018 New Revision: 332145 URL: https://svnweb.freebsd.org/changeset/base/332145 Log: Do not fail devices just for errors in descriptor format. MFC after: 1 week Sponsored by: iXsystems, Inc. Modified: head/sys/cam/scsi/scsi_cd.c head/sys/cam/scsi/scsi_da.c Modified: head/sys/cam/scsi/scsi_cd.c ============================================================================== --- head/sys/cam/scsi/scsi_cd.c Fri Apr 6 19:47:07 2018 (r332144) +++ head/sys/cam/scsi/scsi_cd.c Fri Apr 6 19:47:44 2018 (r332145) @@ -1119,7 +1119,8 @@ cddone(struct cam_periph *periph, union ccb *done_ccb) * supported" (0x25) error. */ if ((have_sense) && (asc != 0x25) - && (error_code == SSD_CURRENT_ERROR)) { + && (error_code == SSD_CURRENT_ERROR + || error_code == SSD_DESC_CURRENT_ERROR)) { const char *sense_key_desc; const char *asc_desc; Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Fri Apr 6 19:47:07 2018 (r332144) +++ head/sys/cam/scsi/scsi_da.c Fri Apr 6 19:47:44 2018 (r332145) @@ -4649,7 +4649,8 @@ dadone(struct cam_periph *periph, union ccb *done_ccb) (((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INVALID) || ((have_sense) && - (error_code == SSD_CURRENT_ERROR) && + (error_code == SSD_CURRENT_ERROR || + error_code == SSD_DESC_CURRENT_ERROR) && (sense_key == SSD_KEY_ILLEGAL_REQUEST)))) { cam_periph_lock(periph); softc->flags &= ~DA_FLAG_CAN_RC16; @@ -4674,7 +4675,8 @@ dadone(struct cam_periph *periph, union ccb *done_ccb) */ if ((have_sense) && (asc != 0x25) && (asc != 0x44) - && (error_code == SSD_CURRENT_ERROR)) { + && (error_code == SSD_CURRENT_ERROR + || error_code == SSD_DESC_CURRENT_ERROR)) { const char *sense_key_desc; const char *asc_desc; From owner-svn-src-head@freebsd.org Fri Apr 6 19:49:58 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2E59DF80C60; Fri, 6 Apr 2018 19:49:58 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D069B72BF2; Fri, 6 Apr 2018 19:49:57 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CB2AC1652A; Fri, 6 Apr 2018 19:49:57 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w36JnvjE038348; Fri, 6 Apr 2018 19:49:57 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36JnvEd038347; Fri, 6 Apr 2018 19:49:57 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201804061949.w36JnvEd038347@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Fri, 6 Apr 2018 19:49:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332146 - head/share/mk X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/share/mk X-SVN-Commit-Revision: 332146 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 19:49:58 -0000 Author: kevans Date: Fri Apr 6 19:49:57 2018 New Revision: 332146 URL: https://svnweb.freebsd.org/changeset/base/332146 Log: Re-sort LOADER options These have become unsorted from everything else. This is desync'd from stable/11 due to some hand-merging that was done there, so the MFC of this will look slightly different. MFC after: 3 days Modified: head/share/mk/src.opts.mk Modified: head/share/mk/src.opts.mk ============================================================================== --- head/share/mk/src.opts.mk Fri Apr 6 19:47:44 2018 (r332145) +++ head/share/mk/src.opts.mk Fri Apr 6 19:49:57 2018 (r332146) @@ -129,14 +129,14 @@ __DEFAULT_YES_OPTIONS = \ LIBPTHREAD \ LIBTHR \ LLVM_COV \ + LOADER_GELI \ + LOADER_OFW \ + LOADER_UBOOT \ LOCALES \ LOCATE \ LPR \ LS_COLORS \ LZMA_SUPPORT \ - LOADER_GELI \ - LOADER_OFW \ - LOADER_UBOOT \ MAIL \ MAILWRAPPER \ MAKE \ From owner-svn-src-head@freebsd.org Fri Apr 6 20:26:57 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B8577F839B3; Fri, 6 Apr 2018 20:26:57 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6416274A09; Fri, 6 Apr 2018 20:26:57 +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 5AC0516BBF; Fri, 6 Apr 2018 20:26:57 +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 w36KQvjG058666; Fri, 6 Apr 2018 20:26:57 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36KQvYv058665; Fri, 6 Apr 2018 20:26:57 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804062026.w36KQvYv058665@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Fri, 6 Apr 2018 20:26:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332151 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 332151 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 20:26:57 -0000 Author: brooks Date: Fri Apr 6 20:26:56 2018 New Revision: 332151 URL: https://svnweb.freebsd.org/changeset/base/332151 Log: ifconf(): correct handling of sockaddrs smaller than struct sockaddr. Portable programs that use SIOCGIFCONF (e.g. traceroute) assume that each pseudo ifreq is of length MAX(sizeof(struct ifreq), sizeof(ifr_name) + ifr_addr.sa_len). For short sockaddrs we copied too much from the source sockaddr resulting in a heap leak. I believe only one such sockaddr exists (struct sockaddr_sco which is 8 bytes) and it is unclear if such sockaddrs end up on interfaces in practice. If it did, the result would be an 8 byte heap leak on current architectures. admbugs: 869 Reviewed by: kib Obtained from: CheriBSD MFC after: 3 days Security: kernel heap leak Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14981 Modified: head/sys/net/if.c Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Fri Apr 6 20:24:50 2018 (r332150) +++ head/sys/net/if.c Fri Apr 6 20:26:56 2018 (r332151) @@ -3191,7 +3191,13 @@ again: continue; addrs++; if (sa->sa_len <= sizeof(*sa)) { - ifr.ifr_addr = *sa; + if (sa->sa_len < sizeof(*sa)) { + memset(&ifr.ifr_ifru.ifru_addr, 0, + sizeof(ifr.ifr_ifru.ifru_addr)); + memcpy(&ifr.ifr_ifru.ifru_addr, sa, + sa->sa_len); + } else + ifr.ifr_ifru.ifru_addr = *sa; sbuf_bcat(sb, &ifr, sizeof(ifr)); max_len += sizeof(ifr); } else { From owner-svn-src-head@freebsd.org Fri Apr 6 22:03:44 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BFC73F8A591; Fri, 6 Apr 2018 22:03:44 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6CB2778A1C; Fri, 6 Apr 2018 22:03:44 +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 6791B17C84; Fri, 6 Apr 2018 22:03:44 +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 w36M3iBL009221; Fri, 6 Apr 2018 22:03:44 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36M3h1B009213; Fri, 6 Apr 2018 22:03:43 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201804062203.w36M3h1B009213@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 6 Apr 2018 22:03:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332157 - in head: lib/libvmmapi sys/amd64/include sys/amd64/vmm sys/amd64/vmm/amd sys/amd64/vmm/intel X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in head: lib/libvmmapi sys/amd64/include sys/amd64/vmm sys/amd64/vmm/amd sys/amd64/vmm/intel X-SVN-Commit-Revision: 332157 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 22:03:45 -0000 Author: jhb Date: Fri Apr 6 22:03:43 2018 New Revision: 332157 URL: https://svnweb.freebsd.org/changeset/base/332157 Log: Add a way to temporarily suspend and resume virtual CPUs. This is used as part of implementing run control in bhyve's debug server. The hypervisor now maintains a set of "debugged" CPUs. Attempting to run a debugged CPU will fail to execute any guest instructions and will instead report a VM_EXITCODE_DEBUG exit to the userland hypervisor. Virtual CPUs are placed into the debugged state via vm_suspend_cpu() (implemented via a new VM_SUSPEND_CPU ioctl). Virtual CPUs can be resumed via vm_resume_cpu() (VM_RESUME_CPU ioctl). The debug server suspends virtual CPUs when it wishes them to stop executing in the guest (for example, when a debugger attaches to the server). The debug server can choose to resume only a subset of CPUs (for example, when single stepping) or it can choose to resume all CPUs. The debug server must explicitly mark a CPU as resumed via vm_resume_cpu() before the virtual CPU will successfully execute any guest instructions. Reviewed by: avg, grehan Tested on: Intel (jhb), AMD (avg) Differential Revision: https://reviews.freebsd.org/D14466 Modified: head/lib/libvmmapi/vmmapi.c head/lib/libvmmapi/vmmapi.h head/sys/amd64/include/vmm.h head/sys/amd64/include/vmm_dev.h head/sys/amd64/vmm/amd/svm.c head/sys/amd64/vmm/intel/vmx.c head/sys/amd64/vmm/vmm.c head/sys/amd64/vmm/vmm_dev.c Modified: head/lib/libvmmapi/vmmapi.c ============================================================================== --- head/lib/libvmmapi/vmmapi.c Fri Apr 6 21:50:09 2018 (r332156) +++ head/lib/libvmmapi/vmmapi.c Fri Apr 6 22:03:43 2018 (r332157) @@ -1374,6 +1374,13 @@ vm_suspended_cpus(struct vmctx *ctx, cpuset_t *cpus) } int +vm_debug_cpus(struct vmctx *ctx, cpuset_t *cpus) +{ + + return (vm_get_cpus(ctx, VM_DEBUG_CPUS, cpus)); +} + +int vm_activate_cpu(struct vmctx *ctx, int vcpu) { struct vm_activate_cpu ac; @@ -1386,6 +1393,30 @@ vm_activate_cpu(struct vmctx *ctx, int vcpu) } int +vm_suspend_cpu(struct vmctx *ctx, int vcpu) +{ + struct vm_activate_cpu ac; + int error; + + bzero(&ac, sizeof(struct vm_activate_cpu)); + ac.vcpuid = vcpu; + error = ioctl(ctx->fd, VM_SUSPEND_CPU, &ac); + return (error); +} + +int +vm_resume_cpu(struct vmctx *ctx, int vcpu) +{ + struct vm_activate_cpu ac; + int error; + + bzero(&ac, sizeof(struct vm_activate_cpu)); + ac.vcpuid = vcpu; + error = ioctl(ctx->fd, VM_RESUME_CPU, &ac); + return (error); +} + +int vm_get_intinfo(struct vmctx *ctx, int vcpu, uint64_t *info1, uint64_t *info2) { struct vm_intinfo vmii; @@ -1501,7 +1532,8 @@ vm_get_ioctls(size_t *len) VM_SET_X2APIC_STATE, VM_GET_X2APIC_STATE, VM_GET_HPET_CAPABILITIES, VM_GET_GPA_PMAP, VM_GLA2GPA, VM_GLA2GPA_NOFAULT, - VM_ACTIVATE_CPU, VM_GET_CPUS, VM_SET_INTINFO, VM_GET_INTINFO, + VM_ACTIVATE_CPU, VM_GET_CPUS, VM_SUSPEND_CPU, VM_RESUME_CPU, + VM_SET_INTINFO, VM_GET_INTINFO, VM_RTC_WRITE, VM_RTC_READ, VM_RTC_SETTIME, VM_RTC_GETTIME, VM_RESTART_INSTRUCTION }; Modified: head/lib/libvmmapi/vmmapi.h ============================================================================== --- head/lib/libvmmapi/vmmapi.h Fri Apr 6 21:50:09 2018 (r332156) +++ head/lib/libvmmapi/vmmapi.h Fri Apr 6 22:03:43 2018 (r332157) @@ -216,7 +216,10 @@ int vcpu_reset(struct vmctx *ctx, int vcpu); int vm_active_cpus(struct vmctx *ctx, cpuset_t *cpus); int vm_suspended_cpus(struct vmctx *ctx, cpuset_t *cpus); +int vm_debug_cpus(struct vmctx *ctx, cpuset_t *cpus); int vm_activate_cpu(struct vmctx *ctx, int vcpu); +int vm_suspend_cpu(struct vmctx *ctx, int vcpu); +int vm_resume_cpu(struct vmctx *ctx, int vcpu); /* * FreeBSD specific APIs Modified: head/sys/amd64/include/vmm.h ============================================================================== --- head/sys/amd64/include/vmm.h Fri Apr 6 21:50:09 2018 (r332156) +++ head/sys/amd64/include/vmm.h Fri Apr 6 22:03:43 2018 (r332157) @@ -231,8 +231,11 @@ int vm_get_x2apic_state(struct vm *vm, int vcpu, enum int vm_set_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state state); int vm_apicid2vcpuid(struct vm *vm, int apicid); int vm_activate_cpu(struct vm *vm, int vcpu); +int vm_suspend_cpu(struct vm *vm, int vcpu); +int vm_resume_cpu(struct vm *vm, int vcpu); struct vm_exit *vm_exitinfo(struct vm *vm, int vcpuid); void vm_exit_suspended(struct vm *vm, int vcpuid, uint64_t rip); +void vm_exit_debug(struct vm *vm, int vcpuid, uint64_t rip); void vm_exit_rendezvous(struct vm *vm, int vcpuid, uint64_t rip); void vm_exit_astpending(struct vm *vm, int vcpuid, uint64_t rip); void vm_exit_reqidle(struct vm *vm, int vcpuid, uint64_t rip); @@ -256,6 +259,7 @@ typedef void (*vm_rendezvous_func_t)(struct vm *vm, in void vm_smp_rendezvous(struct vm *vm, int vcpuid, cpuset_t dest, vm_rendezvous_func_t func, void *arg); cpuset_t vm_active_cpus(struct vm *vm); +cpuset_t vm_debug_cpus(struct vm *vm); cpuset_t vm_suspended_cpus(struct vm *vm); #endif /* _SYS__CPUSET_H_ */ @@ -280,6 +284,8 @@ vcpu_reqidle(struct vm_eventinfo *info) return (*info->iptr); } +int vcpu_debugged(struct vm *vm, int vcpuid); + /* * Return 1 if device indicated by bus/slot/func is supposed to be a * pci passthrough device. @@ -540,6 +546,7 @@ enum vm_exitcode { VM_EXITCODE_MWAIT, VM_EXITCODE_SVM, VM_EXITCODE_REQIDLE, + VM_EXITCODE_DEBUG, VM_EXITCODE_MAX }; Modified: head/sys/amd64/include/vmm_dev.h ============================================================================== --- head/sys/amd64/include/vmm_dev.h Fri Apr 6 21:50:09 2018 (r332156) +++ head/sys/amd64/include/vmm_dev.h Fri Apr 6 22:03:43 2018 (r332157) @@ -209,6 +209,7 @@ struct vm_cpuset { }; #define VM_ACTIVE_CPUS 0 #define VM_SUSPENDED_CPUS 1 +#define VM_DEBUG_CPUS 2 struct vm_intinfo { int vcpuid; @@ -292,6 +293,8 @@ enum { /* vm_cpuset */ IOCNUM_ACTIVATE_CPU = 90, IOCNUM_GET_CPUSET = 91, + IOCNUM_SUSPEND_CPU = 92, + IOCNUM_RESUME_CPU = 93, /* RTC */ IOCNUM_RTC_READ = 100, @@ -386,6 +389,10 @@ enum { _IOW('v', IOCNUM_ACTIVATE_CPU, struct vm_activate_cpu) #define VM_GET_CPUS \ _IOW('v', IOCNUM_GET_CPUSET, struct vm_cpuset) +#define VM_SUSPEND_CPU \ + _IOW('v', IOCNUM_SUSPEND_CPU, struct vm_activate_cpu) +#define VM_RESUME_CPU \ + _IOW('v', IOCNUM_RESUME_CPU, struct vm_activate_cpu) #define VM_SET_INTINFO \ _IOW('v', IOCNUM_SET_INTINFO, struct vm_intinfo) #define VM_GET_INTINFO \ Modified: head/sys/amd64/vmm/amd/svm.c ============================================================================== --- head/sys/amd64/vmm/amd/svm.c Fri Apr 6 21:50:09 2018 (r332156) +++ head/sys/amd64/vmm/amd/svm.c Fri Apr 6 22:03:43 2018 (r332157) @@ -2015,6 +2015,12 @@ svm_vmrun(void *arg, int vcpu, register_t rip, pmap_t break; } + if (vcpu_debugged(vm, vcpu)) { + enable_gintr(); + vm_exit_debug(vm, vcpu, state->rip); + break; + } + svm_inj_interrupts(svm_sc, vcpu, vlapic); /* Activate the nested pmap on 'curcpu' */ Modified: head/sys/amd64/vmm/intel/vmx.c ============================================================================== --- head/sys/amd64/vmm/intel/vmx.c Fri Apr 6 21:50:09 2018 (r332156) +++ head/sys/amd64/vmm/intel/vmx.c Fri Apr 6 22:03:43 2018 (r332157) @@ -2746,6 +2746,12 @@ vmx_run(void *arg, int vcpu, register_t rip, pmap_t pm break; } + if (vcpu_debugged(vm, vcpu)) { + enable_intr(); + vm_exit_debug(vmx->vm, vcpu, rip); + break; + } + vmx_run_trace(vmx, vcpu); vmx_dr_enter_guest(vmxctx); rc = vmx_enter_guest(vmxctx, vmx, launched); Modified: head/sys/amd64/vmm/vmm.c ============================================================================== --- head/sys/amd64/vmm/vmm.c Fri Apr 6 21:50:09 2018 (r332156) +++ head/sys/amd64/vmm/vmm.c Fri Apr 6 22:03:43 2018 (r332157) @@ -152,6 +152,7 @@ struct vm { struct vpmtmr *vpmtmr; /* (i) virtual ACPI PM timer */ struct vrtc *vrtc; /* (o) virtual RTC */ volatile cpuset_t active_cpus; /* (i) active vcpus */ + volatile cpuset_t debug_cpus; /* (i) vcpus stopped for debug */ int suspend; /* (i) stop VM execution */ volatile cpuset_t suspended_cpus; /* (i) suspended vcpus */ volatile cpuset_t halted_cpus; /* (x) cpus in a hard halt */ @@ -415,6 +416,7 @@ vm_init(struct vm *vm, bool create) vm->vrtc = vrtc_init(vm); CPU_ZERO(&vm->active_cpus); + CPU_ZERO(&vm->debug_cpus); vm->suspend = 0; CPU_ZERO(&vm->suspended_cpus); @@ -1283,6 +1285,9 @@ vm_handle_hlt(struct vm *vm, int vcpuid, bool intr_dis if (vcpu_should_yield(vm, vcpuid)) break; + if (vcpu_debugged(vm, vcpuid)) + break; + /* * Some Linux guests implement "halt" by having all vcpus * execute HLT with interrupts disabled. 'halted_cpus' keeps @@ -1554,6 +1559,17 @@ vm_exit_suspended(struct vm *vm, int vcpuid, uint64_t } void +vm_exit_debug(struct vm *vm, int vcpuid, uint64_t rip) +{ + struct vm_exit *vmexit; + + vmexit = vm_exitinfo(vm, vcpuid); + vmexit->rip = rip; + vmexit->inst_length = 0; + vmexit->exitcode = VM_EXITCODE_DEBUG; +} + +void vm_exit_rendezvous(struct vm *vm, int vcpuid, uint64_t rip) { struct vm_exit *vmexit; @@ -2267,11 +2283,67 @@ vm_activate_cpu(struct vm *vm, int vcpuid) return (0); } +int +vm_suspend_cpu(struct vm *vm, int vcpuid) +{ + int i; + + if (vcpuid < -1 || vcpuid >= VM_MAXCPU) + return (EINVAL); + + if (vcpuid == -1) { + vm->debug_cpus = vm->active_cpus; + for (i = 0; i < VM_MAXCPU; i++) { + if (CPU_ISSET(i, &vm->active_cpus)) + vcpu_notify_event(vm, i, false); + } + } else { + if (!CPU_ISSET(vcpuid, &vm->active_cpus)) + return (EINVAL); + + CPU_SET_ATOMIC(vcpuid, &vm->debug_cpus); + vcpu_notify_event(vm, vcpuid, false); + } + return (0); +} + +int +vm_resume_cpu(struct vm *vm, int vcpuid) +{ + + if (vcpuid < -1 || vcpuid >= VM_MAXCPU) + return (EINVAL); + + if (vcpuid == -1) { + CPU_ZERO(&vm->debug_cpus); + } else { + if (!CPU_ISSET(vcpuid, &vm->debug_cpus)) + return (EINVAL); + + CPU_CLR_ATOMIC(vcpuid, &vm->debug_cpus); + } + return (0); +} + +int +vcpu_debugged(struct vm *vm, int vcpuid) +{ + + return (CPU_ISSET(vcpuid, &vm->debug_cpus)); +} + cpuset_t vm_active_cpus(struct vm *vm) { return (vm->active_cpus); +} + +cpuset_t +vm_debug_cpus(struct vm *vm) +{ + + return (vm->debug_cpus); } cpuset_t Modified: head/sys/amd64/vmm/vmm_dev.c ============================================================================== --- head/sys/amd64/vmm/vmm_dev.c Fri Apr 6 21:50:09 2018 (r332156) +++ head/sys/amd64/vmm/vmm_dev.c Fri Apr 6 22:03:43 2018 (r332157) @@ -690,11 +690,21 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t da *cpuset = vm_active_cpus(sc->vm); else if (vm_cpuset->which == VM_SUSPENDED_CPUS) *cpuset = vm_suspended_cpus(sc->vm); + else if (vm_cpuset->which == VM_DEBUG_CPUS) + *cpuset = vm_debug_cpus(sc->vm); else error = EINVAL; if (error == 0) error = copyout(cpuset, vm_cpuset->cpus, size); free(cpuset, M_TEMP); + break; + case VM_SUSPEND_CPU: + vac = (struct vm_activate_cpu *)data; + error = vm_suspend_cpu(sc->vm, vac->vcpuid); + break; + case VM_RESUME_CPU: + vac = (struct vm_activate_cpu *)data; + error = vm_resume_cpu(sc->vm, vac->vcpuid); break; case VM_SET_INTINFO: vmii = (struct vm_intinfo *)data; From owner-svn-src-head@freebsd.org Fri Apr 6 23:17:29 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9CB62F8F2D0; Fri, 6 Apr 2018 23:17:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 484737B2D0; Fri, 6 Apr 2018 23:17:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 3944E10AFAE; Fri, 6 Apr 2018 19:17:28 -0400 (EDT) From: John Baldwin To: Brooks Davis Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r332133 - head/sys/conf Date: Fri, 06 Apr 2018 14:22:43 -0700 Message-ID: <3249895.eL6Z6pOVrh@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) In-Reply-To: <201804061911.w36JBMvB017793@repo.freebsd.org> References: <201804061911.w36JBMvB017793@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Fri, 06 Apr 2018 19:17:28 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 23:17:29 -0000 On Friday, April 06, 2018 07:11:22 PM Brooks Davis wrote: > Author: brooks > Date: Fri Apr 6 19:11:22 2018 > New Revision: 332133 > URL: https://svnweb.freebsd.org/changeset/base/332133 > > Log: > Add an unused _COMPAT_LINUX32 option to ensure opt_compat.h exists on > platforms without COMPAT_LINUX32. I wonder if it wouldn't be cleaner to just move COMPAT_LINUX32 itself to sys/conf/options? -- John Baldwin From owner-svn-src-head@freebsd.org Fri Apr 6 23:25:55 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 992D3F8FD03; Fri, 6 Apr 2018 23:25:55 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4F37C7B8DE; Fri, 6 Apr 2018 23:25:55 +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 459D31896D; Fri, 6 Apr 2018 23:25:55 +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 w36NPt5R049036; Fri, 6 Apr 2018 23:25:55 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w36NPtvx049035; Fri, 6 Apr 2018 23:25:55 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804062325.w36NPtvx049035@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Fri, 6 Apr 2018 23:25:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332158 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 332158 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 23:25:55 -0000 Author: brooks Date: Fri Apr 6 23:25:54 2018 New Revision: 332158 URL: https://svnweb.freebsd.org/changeset/base/332158 Log: Remove the thread argument from ifr_buffer_*() accessors. They are always used in a context where curthread is the correct thread. This makes them more similar to the ifr_data_get_ptr() accessor. Modified: head/sys/net/if.c Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Fri Apr 6 22:03:43 2018 (r332157) +++ head/sys/net/if.c Fri Apr 6 23:25:54 2018 (r332158) @@ -2403,13 +2403,13 @@ ifunit(const char *name) } static void * -ifr_buffer_get_buffer(struct thread *td, void *data) +ifr_buffer_get_buffer(void *data) { union ifreq_union *ifrup; ifrup = data; #ifdef COMPAT_FREEBSD32 - if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) + if (SV_CURPROC_FLAG(SV_ILP32)) return ((void *)(uintptr_t) ifrup->ifr32.ifr_ifru.ifru_buffer.buffer); #endif @@ -2417,13 +2417,13 @@ ifr_buffer_get_buffer(struct thread *td, void *data) } static void -ifr_buffer_set_buffer_null(struct thread *td, void *data) +ifr_buffer_set_buffer_null(void *data) { union ifreq_union *ifrup; ifrup = data; #ifdef COMPAT_FREEBSD32 - if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) + if (SV_CURPROC_FLAG(SV_ILP32)) ifrup->ifr32.ifr_ifru.ifru_buffer.buffer = 0; else #endif @@ -2431,26 +2431,26 @@ ifr_buffer_set_buffer_null(struct thread *td, void *da } static size_t -ifr_buffer_get_length(struct thread *td, void *data) +ifr_buffer_get_length(void *data) { union ifreq_union *ifrup; ifrup = data; #ifdef COMPAT_FREEBSD32 - if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) + if (SV_CURPROC_FLAG(SV_ILP32)) return (ifrup->ifr32.ifr_ifru.ifru_buffer.length); #endif return (ifrup->ifr.ifr_ifru.ifru_buffer.length); } static void -ifr_buffer_set_length(struct thread *td, void *data, size_t len) +ifr_buffer_set_length(void *data, size_t len) { union ifreq_union *ifrup; ifrup = data; #ifdef COMPAT_FREEBSD32 - if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) + if (SV_CURPROC_FLAG(SV_ILP32)) ifrup->ifr32.ifr_ifru.ifru_buffer.length = len; else #endif @@ -2531,12 +2531,12 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, else { /* space for terminating nul */ descrlen = strlen(ifp->if_description) + 1; - if (ifr_buffer_get_length(td, ifr) < descrlen) - ifr_buffer_set_buffer_null(td, ifr); + if (ifr_buffer_get_length(ifr) < descrlen) + ifr_buffer_set_buffer_null(ifr); else error = copyout(ifp->if_description, - ifr_buffer_get_buffer(td, ifr), descrlen); - ifr_buffer_set_length(td, ifr, descrlen); + ifr_buffer_get_buffer(ifr), descrlen); + ifr_buffer_set_length(ifr, descrlen); } sx_sunlock(&ifdescr_sx); break; @@ -2552,15 +2552,15 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, * length parameter is supposed to count the * terminating nul in. */ - if (ifr_buffer_get_length(td, ifr) > ifdescr_maxlen) + if (ifr_buffer_get_length(ifr) > ifdescr_maxlen) return (ENAMETOOLONG); - else if (ifr_buffer_get_length(td, ifr) == 0) + else if (ifr_buffer_get_length(ifr) == 0) descrbuf = NULL; else { - descrbuf = malloc(ifr_buffer_get_length(td, ifr), + descrbuf = malloc(ifr_buffer_get_length(ifr), M_IFDESCR, M_WAITOK | M_ZERO); - error = copyin(ifr_buffer_get_buffer(td, ifr), descrbuf, - ifr_buffer_get_length(td, ifr) - 1); + error = copyin(ifr_buffer_get_buffer(ifr), descrbuf, + ifr_buffer_get_length(ifr) - 1); if (error) { free(descrbuf, M_IFDESCR); break; From owner-svn-src-head@freebsd.org Sat Apr 7 09:03:52 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2FDCBF99A3E; Sat, 7 Apr 2018 09:03:52 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BACA56E3A3; Sat, 7 Apr 2018 09:03:51 +0000 (UTC) (envelope-from ed@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 B5C6C1EC09; Sat, 7 Apr 2018 09:03:51 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3793pio040311; Sat, 7 Apr 2018 09:03:51 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3793pGN040309; Sat, 7 Apr 2018 09:03:51 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201804070903.w3793pGN040309@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Sat, 7 Apr 2018 09:03:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332165 - head/usr.sbin/syslogd X-SVN-Group: head X-SVN-Commit-Author: ed X-SVN-Commit-Paths: head/usr.sbin/syslogd X-SVN-Commit-Revision: 332165 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 09:03:52 -0000 Author: ed Date: Sat Apr 7 09:03:51 2018 New Revision: 332165 URL: https://svnweb.freebsd.org/changeset/base/332165 Log: Fix enough warnings that we can build syslogd on all targets at WARNS=6. This also fixes the build on MIPS. Reported by: cy (MIPS build failure) Modified: head/usr.sbin/syslogd/Makefile head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/Makefile ============================================================================== --- head/usr.sbin/syslogd/Makefile Sat Apr 7 03:51:19 2018 (r332164) +++ head/usr.sbin/syslogd/Makefile Sat Apr 7 09:03:51 2018 (r332165) @@ -11,8 +11,6 @@ SRCS= syslogd.c ttymsg.c LIBADD= util -WARNS?= 3 - .if ${MK_INET_SUPPORT} != "no" CFLAGS+= -DINET .endif Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Sat Apr 7 03:51:19 2018 (r332164) +++ head/usr.sbin/syslogd/syslogd.c Sat Apr 7 09:03:51 2018 (r332165) @@ -581,7 +581,7 @@ main(int argc, char *argv[]) else if (ch == 'p') { mode = DEFFILEMODE; pflag = 1; - } else if (ch == 'S') { + } else { mode = S_IRUSR | S_IWUSR; Sflag = 1; } @@ -931,7 +931,7 @@ static void parsemsg_rfc5424(const char *from, int pri, char *msg) { const struct logtime *timestamp; - struct logtime timestamp_remote = { 0 }; + struct logtime timestamp_remote; const char *omsg, *hostname, *app_name, *procid, *msgid, *structured_data; char line[MAXLINE + 1]; @@ -971,6 +971,7 @@ parsemsg_rfc5424(const char *from, int pri, char *msg) dest = v; \ } while (0) /* Date and time. */ + memset(×tamp_remote, 0, sizeof(timestamp_remote)); PARSE_NUMBER(timestamp_remote.tm.tm_year, 4, 0, 9999); timestamp_remote.tm.tm_year -= 1900; PARSE_CHAR("TIMESTAMP", '-'); @@ -1151,7 +1152,7 @@ parsemsg_rfc3164(const char *from, int pri, char *msg) { struct tm tm_parsed; const struct logtime *timestamp; - struct logtime timestamp_remote = { 0 }; + struct logtime timestamp_remote; const char *app_name, *procid; size_t i, msglen; char line[MAXLINE + 1]; @@ -1187,6 +1188,7 @@ parsemsg_rfc3164(const char *from, int pri, char *msg) timestamp_remote.tm = tm_parsed; timestamp_remote.tm.tm_year = year; timestamp_remote.tm.tm_isdst = -1; + timestamp_remote.usec = 0; if (mktime(×tamp_remote.tm) < t_now + 7 * 24 * 60 * 60) break; From owner-svn-src-head@freebsd.org Sat Apr 7 14:17:18 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9AF4FF8BBF7; Sat, 7 Apr 2018 14:17:18 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3BEEF79603; Sat, 7 Apr 2018 14:17:18 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2EC8621DF1; Sat, 7 Apr 2018 14:17:18 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37EHIVo095738; Sat, 7 Apr 2018 14:17:18 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37EHIae095737; Sat, 7 Apr 2018 14:17:18 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201804071417.w37EHIae095737@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Sat, 7 Apr 2018 14:17:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332166 - head/sys/arm/allwinner X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/allwinner X-SVN-Commit-Revision: 332166 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 14:17:18 -0000 Author: manu Date: Sat Apr 7 14:17:17 2018 New Revision: 332166 URL: https://svnweb.freebsd.org/changeset/base/332166 Log: axp81x: Do not fail if regulators aren't properly defined If a regulator is missing a mandatory property (like 'regulator-name'), do not fail, regulator_parse_ofw_stdparam is returning a non-zero value so just skip this regulator. Also if any regulator fails to attach continue with the rest of the regulators instead of returning ENXIO in axp8xx_attach Tested On: BananaPi M3 Modified: head/sys/arm/allwinner/axp81x.c Modified: head/sys/arm/allwinner/axp81x.c ============================================================================== --- head/sys/arm/allwinner/axp81x.c Sat Apr 7 09:03:51 2018 (r332165) +++ head/sys/arm/allwinner/axp81x.c Sat Apr 7 14:17:17 2018 (r332166) @@ -900,7 +900,8 @@ axp8xx_reg_attach(device_t dev, phandle_t node, struct regnode *regnode; memset(&initdef, 0, sizeof(initdef)); - regulator_parse_ofw_stdparam(dev, node, &initdef); + if (regulator_parse_ofw_stdparam(dev, node, &initdef) != 0) + return (NULL); if (initdef.std_param.min_uvolt == 0) initdef.std_param.min_uvolt = def->voltage_min * 1000; if (initdef.std_param.max_uvolt == 0) @@ -1039,7 +1040,7 @@ axp8xx_attach(device_t dev) device_printf(dev, "cannot attach regulator %s\n", regname); - return (ENXIO); + continue; } sc->regs[i] = reg; } From owner-svn-src-head@freebsd.org Sat Apr 7 14:40:10 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E2BFAF8D599; Sat, 7 Apr 2018 14:40:09 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9768A86508; Sat, 7 Apr 2018 14:40:09 +0000 (UTC) (envelope-from tsoome@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 91A022214A; Sat, 7 Apr 2018 14:40:09 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37Ee9DA006274; Sat, 7 Apr 2018 14:40:09 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37Ee9Vr006272; Sat, 7 Apr 2018 14:40:09 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201804071440.w37Ee9Vr006272@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Sat, 7 Apr 2018 14:40:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332170 - head/stand/libsa X-SVN-Group: head X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: head/stand/libsa X-SVN-Commit-Revision: 332170 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 14:40:10 -0000 Author: tsoome Date: Sat Apr 7 14:40:09 2018 New Revision: 332170 URL: https://svnweb.freebsd.org/changeset/base/332170 Log: libsa: cd9660: warning: 'lenskip' may be used uninitialized in this function We better provide value for lenskip in both instances. Modified: head/stand/libsa/cd9660.c head/stand/libsa/cd9660read.c Modified: head/stand/libsa/cd9660.c ============================================================================== --- head/stand/libsa/cd9660.c Sat Apr 7 14:38:58 2018 (r332169) +++ head/stand/libsa/cd9660.c Sat Apr 7 14:40:09 2018 (r332170) @@ -309,6 +309,7 @@ cd9660_open(const char *path, struct open_file *f) first = 1; use_rrip = 0; + lenskip = 0; while (*path) { bno = isonum_733(rec.extent) + isonum_711(rec.ext_attr_length); dsize = isonum_733(rec.size); @@ -343,7 +344,7 @@ cd9660_open(const char *path, struct open_file *f) use_rrip = rrip_check(f, dp, &lenskip); if (dirmatch(f, path, dp, use_rrip, - first ? 0 : lenskip)) { + first ? 0 : lenskip)) { first = 0; break; } else Modified: head/stand/libsa/cd9660read.c ============================================================================== --- head/stand/libsa/cd9660read.c Sat Apr 7 14:38:58 2018 (r332169) +++ head/stand/libsa/cd9660read.c Sat Apr 7 14:40:09 2018 (r332170) @@ -247,6 +247,7 @@ cd9660_lookup(const char *path) first = 1; use_rrip = 0; + lenskip = 0; while (*path) { bno = isonum_733(rec.extent) + isonum_711(rec.ext_attr_length); dsize = isonum_733(rec.size); From owner-svn-src-head@freebsd.org Sat Apr 7 14:42:48 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E77CBF8DAAE; Sat, 7 Apr 2018 14:42:47 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9376C87FE1; Sat, 7 Apr 2018 14:42:47 +0000 (UTC) (envelope-from tsoome@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 8CE12222DA; Sat, 7 Apr 2018 14:42:47 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37EglvQ011086; Sat, 7 Apr 2018 14:42:47 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37EglG7011085; Sat, 7 Apr 2018 14:42:47 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201804071442.w37EglG7011085@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Sat, 7 Apr 2018 14:42:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332173 - head/stand/libsa X-SVN-Group: head X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: head/stand/libsa X-SVN-Commit-Revision: 332173 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 14:42:48 -0000 Author: tsoome Date: Sat Apr 7 14:42:47 2018 New Revision: 332173 URL: https://svnweb.freebsd.org/changeset/base/332173 Log: libsa: name is not used in dirmatch() Seems like variable 'name' is leftover. Modified: head/stand/libsa/cd9660read.c Modified: head/stand/libsa/cd9660read.c ============================================================================== --- head/stand/libsa/cd9660read.c Sat Apr 7 14:41:44 2018 (r332172) +++ head/stand/libsa/cd9660read.c Sat Apr 7 14:42:47 2018 (r332173) @@ -174,7 +174,7 @@ dirmatch(const char *path, struct iso_directory_record int lenskip) { size_t len; - const char *cp = NULL, *name = NULL; + const char *cp = NULL; int i, icase; if (use_rrip) @@ -187,7 +187,6 @@ dirmatch(const char *path, struct iso_directory_record icase = 1; } else icase = 0; - name = cp; for (i = len; --i >= 0; path++, cp++) { if (!*path || *path == '/') break; From owner-svn-src-head@freebsd.org Sat Apr 7 15:38:43 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 59908F91A72; Sat, 7 Apr 2018 15:38:43 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 05497872DD; Sat, 7 Apr 2018 15:38:43 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EE22C22AD2; Sat, 7 Apr 2018 15:38:42 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37Fcgqs036297; Sat, 7 Apr 2018 15:38:42 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37FcgSm036294; Sat, 7 Apr 2018 15:38:42 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201804071538.w37FcgSm036294@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Sat, 7 Apr 2018 15:38:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332180 - head/sys/arm/allwinner/clkng X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/allwinner/clkng X-SVN-Commit-Revision: 332180 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 15:38:43 -0000 Author: manu Date: Sat Apr 7 15:38:42 2018 New Revision: 332180 URL: https://svnweb.freebsd.org/changeset/base/332180 Log: allwinner: aw_clk_nm: Add prediv value Some NM clocks needs a fixed prediv value applied to the parent frequency on some conditions. Add support for it. Modified: head/sys/arm/allwinner/clkng/aw_clk.h head/sys/arm/allwinner/clkng/aw_clk_nm.c head/sys/arm/allwinner/clkng/aw_clk_nm.h Modified: head/sys/arm/allwinner/clkng/aw_clk.h ============================================================================== --- head/sys/arm/allwinner/clkng/aw_clk.h Sat Apr 7 15:19:10 2018 (r332179) +++ head/sys/arm/allwinner/clkng/aw_clk.h Sat Apr 7 15:38:42 2018 (r332180) @@ -66,6 +66,7 @@ struct aw_clk_init { #define AW_CLK_SCALE_CHANGE 0x0010 #define AW_CLK_HAS_FRAC 0x0020 #define AW_CLK_HAS_UPDATE 0x0040 +#define AW_CLK_HAS_PREDIV 0x0080 #define AW_CLK_FACTOR_POWER_OF_TWO 0x0001 #define AW_CLK_FACTOR_ZERO_BASED 0x0002 Modified: head/sys/arm/allwinner/clkng/aw_clk_nm.c ============================================================================== --- head/sys/arm/allwinner/clkng/aw_clk_nm.c Sat Apr 7 15:19:10 2018 (r332179) +++ head/sys/arm/allwinner/clkng/aw_clk_nm.c Sat Apr 7 15:38:42 2018 (r332180) @@ -52,6 +52,7 @@ struct aw_clk_nm_sc { struct aw_clk_factor m; struct aw_clk_factor n; + struct aw_clk_factor prediv; struct aw_clk_frac frac; uint32_t mux_shift; @@ -278,7 +279,7 @@ static int aw_clk_nm_recalc(struct clknode *clk, uint64_t *freq) { struct aw_clk_nm_sc *sc; - uint32_t val, m, n; + uint32_t val, m, n, prediv; sc = clknode_get_softc(clk); @@ -294,8 +295,12 @@ aw_clk_nm_recalc(struct clknode *clk, uint64_t *freq) } else { m = aw_clk_get_factor(val, &sc->m); n = aw_clk_get_factor(val, &sc->n); + if (sc->flags & AW_CLK_HAS_PREDIV) + prediv = aw_clk_get_factor(val, &sc->prediv); + else + prediv = 1; - *freq = *freq / n / m; + *freq = *freq / prediv / n / m; } return (0); @@ -339,6 +344,18 @@ aw_clk_nm_register(struct clkdom *clkdom, struct aw_cl sc->n.mask = ((1 << sc->n.width) - 1) << sc->n.shift; sc->n.value = clkdef->n.value; sc->n.flags = clkdef->n.flags; + + sc->prediv.shift = clkdef->prediv.shift; + sc->prediv.width = clkdef->prediv.width; + sc->prediv.mask = ((1 << sc->prediv.width) - 1) << sc->prediv.shift; + sc->prediv.value = clkdef->prediv.value; + sc->prediv.flags = clkdef->prediv.flags; + sc->prediv.cond_shift = clkdef->prediv.cond_shift; + if (clkdef->prediv.cond_width != 0) + sc->prediv.cond_mask = ((1 << clkdef->prediv.cond_width) - 1) << sc->prediv.shift; + else + sc->prediv.cond_mask = clkdef->prediv.cond_mask; + sc->prediv.cond_value = clkdef->prediv.cond_value; sc->frac.freq0 = clkdef->frac.freq0; sc->frac.freq1 = clkdef->frac.freq1; Modified: head/sys/arm/allwinner/clkng/aw_clk_nm.h ============================================================================== --- head/sys/arm/allwinner/clkng/aw_clk_nm.h Sat Apr 7 15:19:10 2018 (r332179) +++ head/sys/arm/allwinner/clkng/aw_clk_nm.h Sat Apr 7 15:38:42 2018 (r332180) @@ -37,6 +37,7 @@ struct aw_clk_nm_def { struct aw_clk_factor m; struct aw_clk_factor n; + struct aw_clk_factor prediv; struct aw_clk_frac frac; uint32_t mux_shift; From owner-svn-src-head@freebsd.org Sat Apr 7 15:40:01 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4FB8AF91BD5; Sat, 7 Apr 2018 15:40:01 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 051E687E7E; Sat, 7 Apr 2018 15:40:01 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F2E2422AD6; Sat, 7 Apr 2018 15:40:00 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37Fe0aC036414; Sat, 7 Apr 2018 15:40:00 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37Fe089036413; Sat, 7 Apr 2018 15:40:00 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201804071540.w37Fe089036413@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Sat, 7 Apr 2018 15:40:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332181 - head/sys/arm/allwinner/clkng X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/allwinner/clkng X-SVN-Commit-Revision: 332181 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 15:40:01 -0000 Author: manu Date: Sat Apr 7 15:40:00 2018 New Revision: 332181 URL: https://svnweb.freebsd.org/changeset/base/332181 Log: allwinner: a83t_r_ccu: Add proper IR clock support Now that NM clocks support prediv, add proper support for the IR clock found on the A83T SoC. Tested On: BananaPi M3 Reported by: kevans Modified: head/sys/arm/allwinner/clkng/ccu_sun8i_r.c Modified: head/sys/arm/allwinner/clkng/ccu_sun8i_r.c ============================================================================== --- head/sys/arm/allwinner/clkng/ccu_sun8i_r.c Sat Apr 7 15:38:42 2018 (r332180) +++ head/sys/arm/allwinner/clkng/ccu_sun8i_r.c Sat Apr 7 15:40:00 2018 (r332181) @@ -108,10 +108,10 @@ DIV_CLK(apb0_clk, 0, 2, /* shift, width */ 0, NULL); /* flags, div table */ -static const char *ir_parents[] = {"osc32k", "osc24M"}; -NM_CLK(ir_clk, +static const char *r_ccu_ir_parents[] = {"osc32k", "osc24M"}; +NM_CLK(r_ccu_ir_clk, CLK_IR, /* id */ - "ir", ir_parents, /* names, parents */ + "ir", r_ccu_ir_parents, /* names, parents */ 0x54, /* offset */ 0, 4, 0, 0, /* N factor */ 16, 2, 0, 0, /* M flags */ @@ -119,6 +119,28 @@ NM_CLK(ir_clk, 31, /* gate */ AW_CLK_HAS_MUX | AW_CLK_REPARENT); /* flags */ +static const char *a83t_ir_parents[] = {"osc16M", "osc24M"}; +static struct aw_clk_nm_def a83t_ir_clk = { + .clkdef = { + .id = CLK_IR, + .name = "ir", + .parent_names = a83t_ir_parents, + .parent_cnt = nitems(a83t_ir_parents), + }, + .offset = 0x54, + .n = {.shift = 0, .width = 4, .flags = AW_CLK_FACTOR_POWER_OF_TWO, }, + .m = {.shift = 16, .width = 2}, + .prediv = { + .cond_shift = 24, + .cond_width = 2, + .cond_value = 0, + .value = 16 + }, + .mux_shift = 24, + .mux_width = 2, + .flags = AW_CLK_HAS_MUX | AW_CLK_HAS_PREDIV, +}; + static struct aw_clk_prediv_mux_def *r_ccu_prediv_mux_clks[] = { &ar100_clk, }; @@ -135,15 +157,20 @@ static struct clk_fixed_def *fixed_factor_clks[] = { &ahb0_clk, }; -static struct aw_clk_nm_def *nm_clks[] = { - &ir_clk, +static struct aw_clk_nm_def *r_ccu_nm_clks[] = { + &r_ccu_ir_clk, }; +static struct aw_clk_nm_def *a83t_nm_clks[] = { + &a83t_ir_clk, +}; + void ccu_sun8i_r_register_clocks(struct aw_ccung_softc *sc) { int i; struct aw_clk_prediv_mux_def **prediv_mux_clks; + struct aw_clk_nm_def **nm_clks; sc->resets = ccu_sun8i_r_resets; sc->nresets = nitems(ccu_sun8i_r_resets); @@ -151,10 +178,13 @@ ccu_sun8i_r_register_clocks(struct aw_ccung_softc *sc) sc->ngates = nitems(ccu_sun8i_r_gates); /* a83t names the parents differently than the others */ - if (sc->type == A83T_R_CCU) + if (sc->type == A83T_R_CCU) { prediv_mux_clks = a83t_r_ccu_prediv_mux_clks; - else + nm_clks = a83t_nm_clks; + } else { prediv_mux_clks = r_ccu_prediv_mux_clks; + nm_clks = r_ccu_nm_clks; + } for (i = 0; i < nitems(prediv_mux_clks); i++) aw_clk_prediv_mux_register(sc->clkdom, prediv_mux_clks[i]); From owner-svn-src-head@freebsd.org Sat Apr 7 17:06:14 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8B404F97C68; Sat, 7 Apr 2018 17:06:14 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3E1E977DEF; Sat, 7 Apr 2018 17:06:14 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 389982397F; Sat, 7 Apr 2018 17:06:14 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37H6Err084184; Sat, 7 Apr 2018 17:06:14 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37H6Da7084181; Sat, 7 Apr 2018 17:06:13 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201804071706.w37H6Da7084181@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 7 Apr 2018 17:06:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332182 - in head/sys: amd64/amd64 vm X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in head/sys: amd64/amd64 vm X-SVN-Commit-Revision: 332182 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 17:06:14 -0000 Author: kib Date: Sat Apr 7 17:06:13 2018 New Revision: 332182 URL: https://svnweb.freebsd.org/changeset/base/332182 Log: Handle Skylake-X errata SKZ63. SKZ63 Processor May Hang When Executing Code In an HLE Transaction Region Problem: Under certain conditions, if the processor acquires an HLE (Hardware Lock Elision) lock via the XACQUIRE instruction in the Host Physical Address range between 40000000H and 403FFFFFH, it may hang with an internal timeout error (MCACOD 0400H) logged into IA32_MCi_STATUS. Move the pages from the range into the blacklist. Add a tunable to not waste 4M if local DoS is not the issue. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D15001 Modified: head/sys/amd64/amd64/pmap.c head/sys/vm/vm_page.c head/sys/vm/vm_page.h Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Sat Apr 7 15:40:00 2018 (r332181) +++ head/sys/amd64/amd64/pmap.c Sat Apr 7 17:06:13 2018 (r332182) @@ -1290,7 +1290,35 @@ pmap_init(void) struct pmap_preinit_mapping *ppim; vm_page_t mpte; vm_size_t s; - int error, i, pv_npg; + int error, i, pv_npg, ret, skz63; + + /* Detect bare-metal Skylake Server and Skylake-X. */ + if (vm_guest == VM_GUEST_NO && cpu_vendor_id == CPU_VENDOR_INTEL && + CPUID_TO_FAMILY(cpu_id) == 0x6 && CPUID_TO_MODEL(cpu_id) == 0x55) { + /* + * Skylake-X errata SKZ63. Processor May Hang When + * Executing Code In an HLE Transaction Region between + * 40000000H and 403FFFFFH. + * + * Mark the pages in the range as preallocated. It + * seems to be impossible to distinguish between + * Skylake Server and Skylake X. + */ + skz63 = 1; + TUNABLE_INT_FETCH("hw.skz63_enable", &skz63); + if (skz63 != 0) { + if (bootverbose) + printf("SKZ63: skipping 4M RAM starting " + "at physical 1G\n"); + for (i = 0; i < atop(0x400000); i++) { + ret = vm_page_blacklist_add(0x40000000 + + ptoa(i), FALSE); + if (!ret && bootverbose) + printf("page at %#lx already used\n", + 0x40000000 + ptoa(i)); + } + } + } /* * Initialize the vm page array entries for the kernel pmap's Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Sat Apr 7 15:40:00 2018 (r332181) +++ head/sys/vm/vm_page.c Sat Apr 7 17:06:13 2018 (r332182) @@ -341,6 +341,29 @@ vm_page_blacklist_next(char **list, char *end) return (0); } +bool +vm_page_blacklist_add(vm_paddr_t pa, bool verbose) +{ + struct vm_domain *vmd; + vm_page_t m; + int ret; + + m = vm_phys_paddr_to_vm_page(pa); + if (m == NULL) + return (true); /* page does not exist, no failure */ + + vmd = vm_pagequeue_domain(m); + vm_domain_free_lock(vmd); + ret = vm_phys_unfree_page(m); + vm_domain_free_unlock(vmd); + if (ret) { + TAILQ_INSERT_TAIL(&blacklist_head, m, listq); + if (verbose) + printf("Skipping page with pa 0x%jx\n", (uintmax_t)pa); + } + return (ret); +} + /* * vm_page_blacklist_check: * @@ -351,29 +374,14 @@ vm_page_blacklist_next(char **list, char *end) static void vm_page_blacklist_check(char *list, char *end) { - struct vm_domain *vmd; vm_paddr_t pa; - vm_page_t m; char *next; - int ret; next = list; while (next != NULL) { if ((pa = vm_page_blacklist_next(&next, end)) == 0) continue; - m = vm_phys_paddr_to_vm_page(pa); - if (m == NULL) - continue; - vmd = vm_pagequeue_domain(m); - vm_domain_free_lock(vmd); - ret = vm_phys_unfree_page(m); - vm_domain_free_unlock(vmd); - if (ret == TRUE) { - TAILQ_INSERT_TAIL(&blacklist_head, m, listq); - if (bootverbose) - printf("Skipping page with pa 0x%jx\n", - (uintmax_t)pa); - } + vm_page_blacklist_add(pa, bootverbose); } } Modified: head/sys/vm/vm_page.h ============================================================================== --- head/sys/vm/vm_page.h Sat Apr 7 15:40:00 2018 (r332181) +++ head/sys/vm/vm_page.h Sat Apr 7 17:06:13 2018 (r332182) @@ -476,6 +476,7 @@ vm_page_t vm_page_alloc_contig_domain(vm_object_t obje vm_memattr_t memattr); vm_page_t vm_page_alloc_freelist(int, int); vm_page_t vm_page_alloc_freelist_domain(int, int, int); +bool vm_page_blacklist_add(vm_paddr_t pa, bool verbose); void vm_page_change_lock(vm_page_t m, struct mtx **mtx); vm_page_t vm_page_grab (vm_object_t, vm_pindex_t, int); int vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags, From owner-svn-src-head@freebsd.org Sat Apr 7 18:09:32 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E1B48F9BD1E; Sat, 7 Apr 2018 18:09:31 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9038D733E0; Sat, 7 Apr 2018 18:09:31 +0000 (UTC) (envelope-from ian@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 8873224353; Sat, 7 Apr 2018 18:09:31 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37I9VmJ015052; Sat, 7 Apr 2018 18:09:31 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37I9Vip015051; Sat, 7 Apr 2018 18:09:31 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804071809.w37I9Vip015051@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 7 Apr 2018 18:09:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332194 - head/sys/dev/spibus X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/dev/spibus X-SVN-Commit-Revision: 332194 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 18:09:32 -0000 Author: ian Date: Sat Apr 7 18:09:31 2018 New Revision: 332194 URL: https://svnweb.freebsd.org/changeset/base/332194 Log: Add support for writing/changing spi device ivars. The SPI mode (polarity and phase) and the maximum bus speed can be changed. The chip select number cannot be changed, because the device instances which are children of spibus are inherently associated with the chip select number they were instantiated for. Modified: head/sys/dev/spibus/spibus.c Modified: head/sys/dev/spibus/spibus.c ============================================================================== --- head/sys/dev/spibus/spibus.c Sat Apr 7 18:08:42 2018 (r332193) +++ head/sys/dev/spibus/spibus.c Sat Apr 7 18:09:31 2018 (r332194) @@ -160,6 +160,37 @@ spibus_read_ivar(device_t bus, device_t child, int whi return (0); } +static int +spibus_write_ivar(device_t bus, device_t child, int which, uintptr_t value) +{ + struct spibus_ivar *devi = SPIBUS_IVAR(child); + + if (devi == NULL || device_get_parent(child) != bus) + return (EDOOFUS); + + switch (which) { + case SPIBUS_IVAR_CLOCK: + /* Any non-zero value is allowed for max clock frequency. */ + if (value == 0) + return (EINVAL); + devi->clock = (uint32_t)value; + break; + case SPIBUS_IVAR_CS: + /* Chip select cannot be changed. */ + return (EINVAL); + case SPIBUS_IVAR_MODE: + /* Valid SPI modes are 0-3. */ + if (value > 3) + return (EINVAL); + devi->mode = (uint32_t)value; + break; + default: + return (EINVAL); + } + + return (0); +} + static device_t spibus_add_child(device_t dev, u_int order, const char *name, int unit) { @@ -211,6 +242,7 @@ static device_method_t spibus_methods[] = { DEVMETHOD(bus_print_child, spibus_print_child), DEVMETHOD(bus_probe_nomatch, spibus_probe_nomatch), DEVMETHOD(bus_read_ivar, spibus_read_ivar), + DEVMETHOD(bus_write_ivar, spibus_write_ivar), DEVMETHOD(bus_child_pnpinfo_str, spibus_child_pnpinfo_str), DEVMETHOD(bus_child_location_str, spibus_child_location_str), DEVMETHOD(bus_hinted_child, spibus_hinted_child), From owner-svn-src-head@freebsd.org Sat Apr 7 18:25:08 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EE5C6F9CD10; Sat, 7 Apr 2018 18:25:07 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9AED67BD18; Sat, 7 Apr 2018 18:25:07 +0000 (UTC) (envelope-from ian@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 95D0F24675; Sat, 7 Apr 2018 18:25:07 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37IP7g2025028; Sat, 7 Apr 2018 18:25:07 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37IP7ri025027; Sat, 7 Apr 2018 18:25:07 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804071825.w37IP7ri025027@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 7 Apr 2018 18:25:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332195 - head/sys/dev/spibus X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/dev/spibus X-SVN-Commit-Revision: 332195 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 18:25:08 -0000 Author: ian Date: Sat Apr 7 18:25:07 2018 New Revision: 332195 URL: https://svnweb.freebsd.org/changeset/base/332195 Log: A couple minor improvements to spibus.c... - Change the description string to "SPI bus" (was "spibus bus"). - This is the default driver for a SPI bus, not a generic implementation, so return the probe value that indicates such. - Use device_delete_children() at detach time, instead of a local loop to enumerate the children and detach each one individually. Modified: head/sys/dev/spibus/spibus.c Modified: head/sys/dev/spibus/spibus.c ============================================================================== --- head/sys/dev/spibus/spibus.c Sat Apr 7 18:09:31 2018 (r332194) +++ head/sys/dev/spibus/spibus.c Sat Apr 7 18:25:07 2018 (r332195) @@ -49,8 +49,9 @@ __FBSDID("$FreeBSD$"); static int spibus_probe(device_t dev) { - device_set_desc(dev, "spibus bus"); - return (BUS_PROBE_GENERIC); + + device_set_desc(dev, "SPI bus"); + return (BUS_PROBE_DEFAULT); } static int @@ -70,16 +71,11 @@ spibus_attach(device_t dev) static int spibus_detach(device_t dev) { - int err, ndevs, i; - device_t *devlist; + int err; if ((err = bus_generic_detach(dev)) != 0) return (err); - if ((err = device_get_children(dev, &devlist, &ndevs)) != 0) - return (err); - for (i = 0; i < ndevs; i++) - device_delete_child(dev, devlist[i]); - free(devlist, M_TEMP); + device_delete_children(dev); return (0); } From owner-svn-src-head@freebsd.org Sat Apr 7 18:58:59 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 251ABF9EDF6; Sat, 7 Apr 2018 18:58:59 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CA27A6E8EE; Sat, 7 Apr 2018 18:58:58 +0000 (UTC) (envelope-from ian@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 C4FEA24B4B; Sat, 7 Apr 2018 18:58:58 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37Iww3B040242; Sat, 7 Apr 2018 18:58:58 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37Iwwdo040241; Sat, 7 Apr 2018 18:58:58 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804071858.w37Iwwdo040241@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 7 Apr 2018 18:58:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332196 - head/sys/dev/spibus X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/dev/spibus X-SVN-Commit-Revision: 332196 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 18:58:59 -0000 Author: ian Date: Sat Apr 7 18:58:58 2018 New Revision: 332196 URL: https://svnweb.freebsd.org/changeset/base/332196 Log: Return BUS_PROBE_DEFAULT, not zero, because this is not the one driver implementation that must be used, it's just the base system default driver. Also add a comment noting that we're being more liberal about the bus frequency property than the dts binding documents require. Modified: head/sys/dev/spibus/ofw_spibus.c Modified: head/sys/dev/spibus/ofw_spibus.c ============================================================================== --- head/sys/dev/spibus/ofw_spibus.c Sat Apr 7 18:25:07 2018 (r332195) +++ head/sys/dev/spibus/ofw_spibus.c Sat Apr 7 18:58:58 2018 (r332196) @@ -71,7 +71,7 @@ ofw_spibus_probe(device_t dev) return (ENXIO); device_set_desc(dev, "OFW SPI bus"); - return (0); + return (BUS_PROBE_DEFAULT); } static int @@ -126,6 +126,10 @@ ofw_spibus_attach(device_t dev) /* * Get the maximum clock frequency for device, zero means * use the default bus speed. + * + * XXX Note that the current (2018-04-07) dts bindings say that + * spi-max-frequency is a required property (but says nothing of + * how to interpret a value of zero). */ if (OF_getencprop(child, "spi-max-frequency", &clock, sizeof(clock)) == -1) From owner-svn-src-head@freebsd.org Sat Apr 7 19:10:00 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70AD1F9F9DD; Sat, 7 Apr 2018 19:10:00 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B494B74BC9; Sat, 7 Apr 2018 19:09:59 +0000 (UTC) (envelope-from ian@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 1AD0E24CE2; Sat, 7 Apr 2018 19:09:58 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37J9vPt046699; Sat, 7 Apr 2018 19:09:57 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37J9v1r046698; Sat, 7 Apr 2018 19:09:57 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804071909.w37J9v1r046698@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 7 Apr 2018 19:09:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332198 - head/sys/modules/spigen X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/modules/spigen X-SVN-Commit-Revision: 332198 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 19:10:00 -0000 Author: ian Date: Sat Apr 7 19:09:57 2018 New Revision: 332198 URL: https://svnweb.freebsd.org/changeset/base/332198 Log: Arrange the list of generated sources as 1-per-line alphbetical, and add the files required when building for FDT-based systems. Modified: head/sys/modules/spigen/Makefile Modified: head/sys/modules/spigen/Makefile ============================================================================== --- head/sys/modules/spigen/Makefile Sat Apr 7 19:09:51 2018 (r332197) +++ head/sys/modules/spigen/Makefile Sat Apr 7 19:09:57 2018 (r332198) @@ -3,6 +3,16 @@ .PATH: ${SRCTOP}/sys/dev/spibus KMOD= spigen SRCS= spigen.c -SRCS+= device_if.h bus_if.h opt_platform.h spibus_if.h + +# Generated files... +SRCS+= \ + bus_if.h \ + device_if.h \ + opt_platform.h \ + spibus_if.h \ + +.if !empty(OPT_FDT) +SRCS+= ofw_bus_if.h +.endif .include From owner-svn-src-head@freebsd.org Sat Apr 7 19:29:20 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4F1E5FA1072; Sat, 7 Apr 2018 19:29:20 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 036877FEEF; Sat, 7 Apr 2018 19:29:20 +0000 (UTC) (envelope-from imp@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 F101325029; Sat, 7 Apr 2018 19:29:19 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37JTJw2057572; Sat, 7 Apr 2018 19:29:19 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37JTJ3R057571; Sat, 7 Apr 2018 19:29:19 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201804071929.w37JTJ3R057571@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sat, 7 Apr 2018 19:29:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332208 - head/sys/modules/cam X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/modules/cam X-SVN-Commit-Revision: 332208 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 19:29:20 -0000 Author: imp Date: Sat Apr 7 19:29:19 2018 New Revision: 332208 URL: https://svnweb.freebsd.org/changeset/base/332208 Log: Add nvme_util.c to cam.ko. cam.ko can't load onto the kernel w/o nvme in the kernel. Add nvme_util.c to cam.ko. Noticed by: kib@ Modified: head/sys/modules/cam/Makefile Modified: head/sys/modules/cam/Makefile ============================================================================== --- head/sys/modules/cam/Makefile Sat Apr 7 19:23:51 2018 (r332207) +++ head/sys/modules/cam/Makefile Sat Apr 7 19:29:19 2018 (r332208) @@ -2,7 +2,7 @@ S= ${SRCTOP}/sys -.PATH: $S/cam $S/cam/scsi $S/cam/ata $S/cam/nvme $S/${MACHINE}/${MACHINE} +.PATH: $S/cam $S/cam/scsi $S/cam/ata $S/cam/nvme $S/dev/nvme $S/${MACHINE}/${MACHINE} KMOD= cam @@ -46,6 +46,7 @@ SRCS+= ata_pmp.c SRCS+= nvme_all.c SRCS+= nvme_xpt.c SRCS+= nvme_da.c +SRCS+= nvme_util.c EXPORT_SYMS= YES # XXX evaluate From owner-svn-src-head@freebsd.org Sat Apr 7 20:04:06 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 76DB2F80A52; Sat, 7 Apr 2018 20:04:06 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A601873C83; Sat, 7 Apr 2018 20:04:03 +0000 (UTC) (envelope-from ian@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 9F4CE256A3; Sat, 7 Apr 2018 20:04:03 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37K435G077812; Sat, 7 Apr 2018 20:04:03 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37K43Nr077811; Sat, 7 Apr 2018 20:04:03 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804072004.w37K43Nr077811@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 7 Apr 2018 20:04:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332219 - head/sys/dev/spibus X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/dev/spibus X-SVN-Commit-Revision: 332219 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 20:04:06 -0000 Author: ian Date: Sat Apr 7 20:04:03 2018 New Revision: 332219 URL: https://svnweb.freebsd.org/changeset/base/332219 Log: Remove the existing identify() hack to force-add a spigen device on FDT-based systems, and instead add proper FDT probe code. Because this driver is freebsd-specific and just provides generic userland access to run spibus transactions, there is no bindings document to mandate a compatible string, so just arbitrarily use "freebsd,spigen". Modified: head/sys/dev/spibus/spigen.c Modified: head/sys/dev/spibus/spigen.c ============================================================================== --- head/sys/dev/spibus/spigen.c Sat Apr 7 20:03:35 2018 (r332218) +++ head/sys/dev/spibus/spigen.c Sat Apr 7 20:04:03 2018 (r332219) @@ -51,6 +51,10 @@ __FBSDID("$FreeBSD$"); #include +#ifdef FDT +#include +#endif + #include "spibus_if.h" #define SPIGEN_OPEN (1 << 0) @@ -70,24 +74,24 @@ struct spigen_softc { int sc_flags; }; -#ifdef FDT -static void -spigen_identify(driver_t *driver, device_t parent) -{ - if (device_find_child(parent, "spigen", -1) != NULL) - return; - if (BUS_ADD_CHILD(parent, 0, "spigen", -1) == NULL) - device_printf(parent, "add child failed\n"); -} -#endif - static int spigen_probe(device_t dev) { + int rv; +#ifdef FDT + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "freebsd,spigen")) + return (ENXIO); + rv = BUS_PROBE_DEFAULT; +#else + rv = BUS_PROBE_NOWILDCARD; +#endif device_set_desc(dev, "SPI Generic IO"); - return (BUS_PROBE_NOWILDCARD); + return (rv); } static int spigen_open(struct cdev *, int, int, struct thread *); @@ -439,9 +443,6 @@ static devclass_t spigen_devclass; static device_method_t spigen_methods[] = { /* Device interface */ -#ifdef FDT - DEVMETHOD(device_identify, spigen_identify), -#endif DEVMETHOD(device_probe, spigen_probe), DEVMETHOD(device_attach, spigen_attach), DEVMETHOD(device_detach, spigen_detach), From owner-svn-src-head@freebsd.org Sat Apr 7 20:34:58 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 28520F8319C; Sat, 7 Apr 2018 20:34:58 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CCCCD84DFA; Sat, 7 Apr 2018 20:34:57 +0000 (UTC) (envelope-from ian@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 C79BE25B97; Sat, 7 Apr 2018 20:34:57 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37KYvUd093720; Sat, 7 Apr 2018 20:34:57 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37KYve9093719; Sat, 7 Apr 2018 20:34:57 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804072034.w37KYve9093719@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 7 Apr 2018 20:34:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332231 - head/sys/dev/spibus X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/dev/spibus X-SVN-Commit-Revision: 332231 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 20:34:58 -0000 Author: ian Date: Sat Apr 7 20:34:57 2018 New Revision: 332231 URL: https://svnweb.freebsd.org/changeset/base/332231 Log: Generate a spibus_set_[ivarname]() convenience function for each ivar, now that they can be set. Modified: head/sys/dev/spibus/spibusvar.h Modified: head/sys/dev/spibus/spibusvar.h ============================================================================== --- head/sys/dev/spibus/spibusvar.h Sat Apr 7 20:34:03 2018 (r332230) +++ head/sys/dev/spibus/spibusvar.h Sat Apr 7 20:34:57 2018 (r332231) @@ -60,8 +60,14 @@ spibus_get_ ## A(device_t dev, T *t) \ { \ return BUS_READ_IVAR(device_get_parent(dev), dev, \ SPIBUS_IVAR_ ## B, (uintptr_t *) t); \ +} \ +static inline int \ +spibus_set_ ## A(device_t dev, T t) \ +{ \ + return BUS_WRITE_IVAR(device_get_parent(dev), dev, \ + SPIBUS_IVAR_ ## B, (uintptr_t) t); \ } - + SPIBUS_ACCESSOR(cs, CS, uint32_t) SPIBUS_ACCESSOR(mode, MODE, uint32_t) SPIBUS_ACCESSOR(clock, CLOCK, uint32_t) From owner-svn-src-head@freebsd.org Sat Apr 7 20:38:02 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7CA28F83478; Sat, 7 Apr 2018 20:38:02 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2FC8386AFE; Sat, 7 Apr 2018 20:38:02 +0000 (UTC) (envelope-from ian@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 2941025B9A; Sat, 7 Apr 2018 20:38:02 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37Kc2GC093933; Sat, 7 Apr 2018 20:38:02 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37Kc2tr093932; Sat, 7 Apr 2018 20:38:02 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804072038.w37Kc2tr093932@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 7 Apr 2018 20:38:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332233 - head/sys/dev/spibus X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/dev/spibus X-SVN-Commit-Revision: 332233 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 20:38:02 -0000 Author: ian Date: Sat Apr 7 20:38:01 2018 New Revision: 332233 URL: https://svnweb.freebsd.org/changeset/base/332233 Log: Add an ioctl to get/set the SPI transfer mode. Also, make the bus clock frequency ioctl actually set the corresponding ivar instead of just storing the value locally in the softc (and then not using it for anything). Also, return the correct error code if the ioctl cmd is not recognized. Modified: head/sys/dev/spibus/spigen.c Modified: head/sys/dev/spibus/spigen.c ============================================================================== --- head/sys/dev/spibus/spigen.c Sat Apr 7 20:37:44 2018 (r332232) +++ head/sys/dev/spibus/spigen.c Sat Apr 7 20:38:01 2018 (r332233) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #ifdef FDT #include @@ -64,7 +65,6 @@ struct spigen_softc { device_t sc_dev; struct cdev *sc_cdev; struct mtx sc_mtx; - uint32_t sc_clock_speed; uint32_t sc_command_length_max; /* cannot change while mmapped */ uint32_t sc_data_length_max; /* cannot change while mmapped */ vm_object_t sc_mmap_buffer; /* command, then data */ @@ -320,7 +320,6 @@ spigen_ioctl(struct cdev *cdev, u_long cmd, caddr_t da struct thread *td) { device_t dev = cdev->si_drv1; - struct spigen_softc *sc = device_get_softc(dev); int error; switch (cmd) { @@ -331,20 +330,20 @@ spigen_ioctl(struct cdev *cdev, u_long cmd, caddr_t da error = spigen_transfer_mmapped(cdev, (struct spigen_transfer_mmapped *)data); break; case SPIGENIOC_GET_CLOCK_SPEED: - mtx_lock(&sc->sc_mtx); - *(uint32_t *)data = sc->sc_clock_speed; - /* XXX TODO: implement spibus ivar call */ - mtx_unlock(&sc->sc_mtx); - error = 0; + error = spibus_get_clock(dev, (uintptr_t *)data); break; case SPIGENIOC_SET_CLOCK_SPEED: - mtx_lock(&sc->sc_mtx); - sc->sc_clock_speed = *(uint32_t *)data; - mtx_unlock(&sc->sc_mtx); - error = 0; + error = spibus_set_clock(dev, *(uint32_t *)data); break; + case SPIGENIOC_GET_SPI_MODE: + error = spibus_get_mode(dev, (uintptr_t *)data); + break; + case SPIGENIOC_SET_SPI_MODE: + error = spibus_set_mode(dev, *(uint32_t *)data); + break; default: - error = EOPNOTSUPP; + error = ENOTTY; + break; } return (error); } From owner-svn-src-head@freebsd.org Sat Apr 7 20:53:35 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 19912F84776; Sat, 7 Apr 2018 20:53:35 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BF81A6F815; Sat, 7 Apr 2018 20:53:34 +0000 (UTC) (envelope-from ian@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 B6FD125ED3; Sat, 7 Apr 2018 20:53:34 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37KrYkt003785; Sat, 7 Apr 2018 20:53:34 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37KrYba003784; Sat, 7 Apr 2018 20:53:34 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804072053.w37KrYba003784@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 7 Apr 2018 20:53:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332240 - head/sys/sys X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/sys X-SVN-Commit-Revision: 332240 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 20:53:35 -0000 Author: ian Date: Sat Apr 7 20:53:34 2018 New Revision: 332240 URL: https://svnweb.freebsd.org/changeset/base/332240 Log: Add the ioctl definitions for spigen get/set spi mode. Should have been part of r332233. Modified: head/sys/sys/spigenio.h Modified: head/sys/sys/spigenio.h ============================================================================== --- head/sys/sys/spigenio.h Sat Apr 7 20:52:05 2018 (r332239) +++ head/sys/sys/spigenio.h Sat Apr 7 20:53:34 2018 (r332240) @@ -50,5 +50,7 @@ struct spigen_transfer_mmapped { struct spigen_transfer_mmapped) #define SPIGENIOC_GET_CLOCK_SPEED _IOR(SPIGENIOC_BASE, 2, uint32_t) #define SPIGENIOC_SET_CLOCK_SPEED _IOW(SPIGENIOC_BASE, 3, uint32_t) +#define SPIGENIOC_GET_SPI_MODE _IOR(SPIGENIOC_BASE, 4, uint32_t) +#define SPIGENIOC_SET_SPI_MODE _IOW(SPIGENIOC_BASE, 5, uint32_t) #endif /* !_SYS_SPIGENIO_H_ */ From owner-svn-src-head@freebsd.org Sat Apr 7 21:31:09 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B14B1F873AC; Sat, 7 Apr 2018 21:31:09 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5F41284910; Sat, 7 Apr 2018 21:31:09 +0000 (UTC) (envelope-from ian@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 59214263E9; Sat, 7 Apr 2018 21:31:09 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37LV9Sk020078; Sat, 7 Apr 2018 21:31:09 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37LV9fv020077; Sat, 7 Apr 2018 21:31:09 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804072131.w37LV9fv020077@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 7 Apr 2018 21:31:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332258 - head/sys/dev/spibus X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/dev/spibus X-SVN-Commit-Revision: 332258 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 21:31:09 -0000 Author: ian Date: Sat Apr 7 21:31:09 2018 New Revision: 332258 URL: https://svnweb.freebsd.org/changeset/base/332258 Log: Don't check for impossible NULL return from malloc(..., M_WAITOK). Modified: head/sys/dev/spibus/spigen.c Modified: head/sys/dev/spibus/spigen.c ============================================================================== --- head/sys/dev/spibus/spigen.c Sat Apr 7 21:25:29 2018 (r332257) +++ head/sys/dev/spibus/spigen.c Sat Apr 7 21:31:09 2018 (r332258) @@ -242,15 +242,9 @@ spigen_transfer(struct cdev *cdev, struct spigen_trans #endif transfer.tx_cmd = transfer.rx_cmd = malloc(st->st_command.iov_len, M_DEVBUF, M_WAITOK); - if (transfer.tx_cmd == NULL) - return (ENOMEM); if (st->st_data.iov_len > 0) { transfer.tx_data = transfer.rx_data = malloc(st->st_data.iov_len, M_DEVBUF, M_WAITOK); - if (transfer.tx_data == NULL) { - free(transfer.tx_cmd, M_DEVBUF); - return (ENOMEM); - } } else transfer.tx_data = transfer.rx_data = NULL; From owner-svn-src-head@freebsd.org Sat Apr 7 22:00:24 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31AC9F89438; Sat, 7 Apr 2018 22:00:24 +0000 (UTC) (envelope-from ohartmann@walstatt.org) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.gmx.net", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 95477745C8; Sat, 7 Apr 2018 22:00:23 +0000 (UTC) (envelope-from ohartmann@walstatt.org) Received: from thor.intern.walstatt.dynvpn.de ([77.179.50.133]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0M09Ee-1eDEIi1fkC-00uMVM; Sun, 08 Apr 2018 00:00:20 +0200 Date: Sat, 7 Apr 2018 23:59:46 +0200 From: "O. Hartmann" To: Ian Lepore Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r332258 - head/sys/dev/spibus Message-ID: <20180408000013.1fc266c4@thor.intern.walstatt.dynvpn.de> In-Reply-To: <201804072131.w37LV9fv020077@repo.freebsd.org> References: <201804072131.w37LV9fv020077@repo.freebsd.org> Organization: WALSTATT User-Agent: OutScare 3.1415926 X-Operating-System: ImNotAnOperatingSystem 3.141592527 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64 X-Provags-ID: V03:K1:x1mGWjwZd5TdWkJziJCTYgIgJavPdoeG2cUKVUQjEUhGw5h+7hd q/h8HUNJN8H+rjr3tlxMUmReYOYDpBvvXnVF8qW1kJ+Efy3AgsxDkZkm7Rns+wX8BXWRW9x O7S9g4qO3B9cbQHMX/E/abeG9Fbpd1NtgUUz9oWnU9+Z0Q+AFrGOCH7WqT0+MKb6PlTP4wn FIj/Cx6N6qEq4XMQR0fUw== X-UI-Out-Filterresults: notjunk:1;V01:K0:qthFfxGA4Q8=:py7vSWf7cPHkNU1syqSmXb jU++4PreJQhHKd4TyHexMiW/HTZKTWYoQNJflD2FNVe53Cl6R2pPvq8ehKXjfsEA4fpxVEEZO 1FaZXT1qgTIjwJGLYv1zXIRPFb/oyFTYNa/BF90lu/JP+G9MYjTmSkJdVd2n1hplquQ4qGo4y DD8QfqUNOTL+MvtOTw9wbkXF8c933x2dM6J05sT7S3I2Lt4mzOefPF4ubja4MDi33fZ2IqXyY fDGSGpBCemNs/LbVDsHAGsuFjNHh/u4klcpvxd17yFcChWVhqDO3TT9sEphoiVPaBeGIx/bJc usEN/J+4bUb7RojuWy7Aro/wtvuLVcr/T1vSWqG/awEXHKB/a0MhCSNb6MpIhX6sq5LGOOxjS 7ESzKBU5Me7FAGoU9ixP1Nj2KJlUMBnv+eAw65giqWBh1MPYwcejwjbgUHbCKKZd1p7YJeED2 IvCUeH8x6XYj9/sbAYpyIM431iGWBy6gDwxFz7Id10gmir3KHLXBPBmE0DY+ydI32aNCUb83W 1+sotBYXyiyPMW+bU7EH+LFoqr3ZlMH7qvP9BaFamMiG9i9tfOnNRn6etcW5cfsCmtDEBuozx Fy69Hw9/Apc4XzOQeQfgPAjFilta7EZd0qgjR7aV8ap68Hfv+g/kfV/YHbwcBYAT87yrUI3fj xDMWGHJUOnYaCLpe89cfedfQhchMhotdkyeql1ylFNITfEWUTCGs7uCMhwavQFjKgynxevGW/ FGQ6oDXQF/cAk23QB+d0AEtZHGSHYBCVaBE7cIZW9kWCnF+WFHib3DcWal0sORYoa8mZmyG4V /oIB1sYDVJo2pa/eUlEU9DbSXgUHkfBeLYFrAjBEFQNhQ9kBIA= X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 22:00:24 -0000 LS0tLS1CRUdJTiBQR1AgU0lHTkVEIE1FU1NBR0UtLS0tLQ0KSGFzaDogU0hBNTEyDQoNCkFtIFNh dCwgNyBBcHIgMjAxOCAyMTozMTowOSArMDAwMCAoVVRDKQ0KSWFuIExlcG9yZSA8aWFuQEZyZWVC U0Qub3JnPiBzY2hyaWViOg0KDQo+IEF1dGhvcjogaWFuDQo+IERhdGU6IFNhdCBBcHIgIDcgMjE6 MzE6MDkgMjAxOA0KPiBOZXcgUmV2aXNpb246IDMzMjI1OA0KPiBVUkw6IGh0dHBzOi8vc3Zud2Vi LmZyZWVic2Qub3JnL2NoYW5nZXNldC9iYXNlLzMzMjI1OA0KPiANCj4gTG9nOg0KPiAgIERvbid0 IGNoZWNrIGZvciBpbXBvc3NpYmxlIE5VTEwgcmV0dXJuIGZyb20gbWFsbG9jKC4uLiwgTV9XQUlU T0spLg0KPiANCj4gTW9kaWZpZWQ6DQo+ICAgaGVhZC9zeXMvZGV2L3NwaWJ1cy9zcGlnZW4uYw0K PiANCj4gTW9kaWZpZWQ6IGhlYWQvc3lzL2Rldi9zcGlidXMvc3BpZ2VuLmMNCj4gPT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09DQo+IC0tLSBoZWFkL3N5cy9kZXYvc3BpYnVzL3NwaWdlbi5jCVNhdCBBcHIg IDcgMjE6MjU6MjkgMjAxOAkocjMzMjI1NykNCj4gKysrIGhlYWQvc3lzL2Rldi9zcGlidXMvc3Bp Z2VuLmMJU2F0IEFwciAgNyAyMTozMTowOSAyMDE4CShyMzMyMjU4KQ0KPiBAQCAtMjQyLDE1ICsy NDIsOSBAQCBzcGlnZW5fdHJhbnNmZXIoc3RydWN0IGNkZXYgKmNkZXYsIHN0cnVjdCBzcGlnZW5f dHJhbnMNCj4gICNlbmRpZg0KPiAgCXRyYW5zZmVyLnR4X2NtZCA9IHRyYW5zZmVyLnJ4X2NtZCA9 IG1hbGxvYyhzdC0+c3RfY29tbWFuZC5pb3ZfbGVuLA0KPiAgCSAgICBNX0RFVkJVRiwgTV9XQUlU T0spOw0KPiAtCWlmICh0cmFuc2Zlci50eF9jbWQgPT0gTlVMTCkNCj4gLQkJcmV0dXJuIChFTk9N RU0pOw0KPiAgCWlmIChzdC0+c3RfZGF0YS5pb3ZfbGVuID4gMCkgew0KPiAgCQl0cmFuc2Zlci50 eF9kYXRhID0gdHJhbnNmZXIucnhfZGF0YSA9IG1hbGxvYyhzdC0+c3RfZGF0YS5pb3ZfbGVuLA0K PiAgCQkgICAgTV9ERVZCVUYsIE1fV0FJVE9LKTsNCj4gLQkJaWYgKHRyYW5zZmVyLnR4X2RhdGEg PT0gTlVMTCkgew0KPiAtCQkJZnJlZSh0cmFuc2Zlci50eF9jbWQsIE1fREVWQlVGKTsNCj4gLQkJ CXJldHVybiAoRU5PTUVNKTsNCj4gLQkJfQ0KPiAgCX0NCj4gIAllbHNlDQo+ICAJCXRyYW5zZmVy LnR4X2RhdGEgPSB0cmFuc2Zlci5yeF9kYXRhID0gTlVMTDsNCj4gX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX18NCj4gc3ZuLXNyYy1oZWFkQGZyZWVic2Qub3Jn IG1haWxpbmcgbGlzdA0KPiBodHRwczovL2xpc3RzLmZyZWVic2Qub3JnL21haWxtYW4vbGlzdGlu Zm8vc3ZuLXNyYy1oZWFkDQo+IFRvIHVuc3Vic2NyaWJlLCBzZW5kIGFueSBtYWlsIHRvICJzdm4t c3JjLWhlYWQtdW5zdWJzY3JpYmVAZnJlZWJzZC5vcmciDQoNClRoaXMgb25lIGtpbGxzIGJ1aWxk a2VybmVsOg0KDQpbLi4uXQ0KLSAtLS0gc3BpZ2VuLm8gLS0tDQovdXNyL3NyYy9zeXMvZGV2L3Nw aWJ1cy9zcGlnZW4uYzozMjc6MzM6IGVycm9yOiBpbmNvbXBhdGlibGUgcG9pbnRlciB0eXBlcyBw YXNzaW5nDQondWludHB0cl90IConIChha2EgJ3Vuc2lnbmVkIGxvbmcgKicpIHRvIHBhcmFtZXRl ciBvZiB0eXBlICd1aW50MzJfdCAqJyAoYWthICd1bnNpZ25lZA0KaW50IConKSBbLVdlcnJvciwt V2luY29tcGF0aWJsZS1wb2ludGVyLXR5cGVzXSBlcnJvciA9IHNwaWJ1c19nZXRfY2xvY2soZGV2 LCAodWludHB0cl90DQoqKWRhdGEpOyBefn5+fn5+fn5+fn5+fn5+fg0KDQotIC0tIA0KTy4gSGFy dG1hbm4NCg0KSWNoIHdpZGVyc3ByZWNoZSBkZXIgTnV0enVuZyBvZGVyIMOcYmVybWl0dGx1bmcg bWVpbmVyIERhdGVuIGbDvHINCldlcmJlendlY2tlIG9kZXIgZsO8ciBkaWUgTWFya3QtIG9kZXIg TWVpbnVuZ3Nmb3JzY2h1bmcgKMKnIDI4IEFicy4gNCBCRFNHKS4NCi0tLS0tQkVHSU4gUEdQIFNJ R05BVFVSRS0tLS0tDQoNCmlMVUVBUk1LQUIwV0lRUVpWWk16QXR3QzJULzg2VHJTNTI4ZnlGaFls QVVDV3NrL2JRQUtDUkRTNTI4ZnlGaFkNCmxFM1hBZjQvaHhORGlzZUtmNERvNE95Z2RadE52K0pE QzM2ajNBUTUrRTk2R3dwSC9raEZCRUx4S0lSSEg4NVkNClRvZi9RTEw4VW40M3daVHI2bW95ZEU1 ZU9kaVJBZjlaMHZ2VnZvZEVrbVZQYldzZnFuMGxZVFZqWHFua1VmREgNCjdRTW8zUUJST3RNVUJv NExPYTdmTTdPbFpadjlvTUdVQnNCV3FITWpQWGVxVU9xYk0rQTQNCj14R1dzDQotLS0tLUVORCBQ R1AgU0lHTkFUVVJFLS0tLS0NCg== From owner-svn-src-head@freebsd.org Sat Apr 7 22:21:07 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0D2BBF8A9D9; Sat, 7 Apr 2018 22:21:07 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B271C7F99E; Sat, 7 Apr 2018 22:21:06 +0000 (UTC) (envelope-from ian@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 AC17326C06; Sat, 7 Apr 2018 22:21:06 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37ML6Sr045537; Sat, 7 Apr 2018 22:21:06 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37ML6ei045536; Sat, 7 Apr 2018 22:21:06 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804072221.w37ML6ei045536@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 7 Apr 2018 22:21:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332259 - head/sys/dev/spibus X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/dev/spibus X-SVN-Commit-Revision: 332259 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 22:21:07 -0000 Author: ian Date: Sat Apr 7 22:21:06 2018 New Revision: 332259 URL: https://svnweb.freebsd.org/changeset/base/332259 Log: Cast the data pointer to the correct type for the data being accessed (as opposed to one that accidentally worked on the one arch I test-compiled for on my first try). Reported by: np@, O. Hartmann Pointy hat: ian@ Modified: head/sys/dev/spibus/spigen.c Modified: head/sys/dev/spibus/spigen.c ============================================================================== --- head/sys/dev/spibus/spigen.c Sat Apr 7 21:31:09 2018 (r332258) +++ head/sys/dev/spibus/spigen.c Sat Apr 7 22:21:06 2018 (r332259) @@ -324,13 +324,13 @@ spigen_ioctl(struct cdev *cdev, u_long cmd, caddr_t da error = spigen_transfer_mmapped(cdev, (struct spigen_transfer_mmapped *)data); break; case SPIGENIOC_GET_CLOCK_SPEED: - error = spibus_get_clock(dev, (uintptr_t *)data); + error = spibus_get_clock(dev, (uint32_t *)data); break; case SPIGENIOC_SET_CLOCK_SPEED: error = spibus_set_clock(dev, *(uint32_t *)data); break; case SPIGENIOC_GET_SPI_MODE: - error = spibus_get_mode(dev, (uintptr_t *)data); + error = spibus_get_mode(dev, (uint32_t *)data); break; case SPIGENIOC_SET_SPI_MODE: error = spibus_set_mode(dev, *(uint32_t *)data); From owner-svn-src-head@freebsd.org Sat Apr 7 22:23:14 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F08CF8ACEB for ; Sat, 7 Apr 2018 22:23:14 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1a.eu.mailhop.org (outbound1a.eu.mailhop.org [52.58.109.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 298F980CE0 for ; Sat, 7 Apr 2018 22:23:13 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: 41618142-3ab2-11e8-91c6-33ffc249f3e8 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound1.eu.mailhop.org (Halon) with ESMTPSA id 41618142-3ab2-11e8-91c6-33ffc249f3e8; Sat, 07 Apr 2018 22:23:12 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id w37MN53j094272; Sat, 7 Apr 2018 16:23:05 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <1523139785.89422.3.camel@freebsd.org> Subject: Re: svn commit: r332258 - head/sys/dev/spibus From: Ian Lepore To: "O. Hartmann" , Navdeep Parhar Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Sat, 07 Apr 2018 16:23:05 -0600 In-Reply-To: <20180408000013.1fc266c4@thor.intern.walstatt.dynvpn.de> References: <201804072131.w37LV9fv020077@repo.freebsd.org> <20180408000013.1fc266c4@thor.intern.walstatt.dynvpn.de> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 22:23:14 -0000 On Sat, 2018-04-07 at 23:59 +0200, O. Hartmann wrote: > Am Sat, 7 Apr 2018 21:31:09 +0000 (UTC) > Ian Lepore schrieb: > > > > > Author: ian > > Date: Sat Apr  7 21:31:09 2018 > > New Revision: 332258 > > URL: https://svnweb.freebsd.org/changeset/base/332258 > > > > Log: > >   Don't check for impossible NULL return from malloc(..., M_WAITOK). > > > > Modified: > >   head/sys/dev/spibus/spigen.c > > > > [...] > > [...] > --- spigen.o --- > /usr/src/sys/dev/spibus/spigen.c:327:33: error: incompatible pointer types passing > 'uintptr_t *' (aka 'unsigned long *') to parameter of type 'uint32_t *' (aka 'unsigned > int *') [-Werror,-Wincompatible-pointer-types] error = spibus_get_clock(dev, (uintptr_t > *)data); ^~~~~~~~~~~~~~~~~ > Doh!  Sorry about that, fixed in r332259. -- Ian From owner-svn-src-head@freebsd.org Sat Apr 7 22:23:25 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D0540F8AD27; Sat, 7 Apr 2018 22:23:24 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 27CB080EB9; Sat, 7 Apr 2018 22:23:23 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.125.17]) by shaw.ca with ESMTPA id 4wErfZLAmU5pn4wEtfWqM6; Sat, 07 Apr 2018 16:23:17 -0600 X-Authority-Analysis: v=2.3 cv=Tai4SyYh c=1 sm=1 tr=0 a=VFtTW3WuZNDh6VkGe7fA3g==:117 a=VFtTW3WuZNDh6VkGe7fA3g==:17 a=kj9zAlcOel0A:10 a=Kd1tUaAdevIA:10 a=VxmjJ2MpAAAA:8 a=JzwRw_2MAAAA:8 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=PPDduXdDeSw3b1VufPgA:9 a=CjuIK1q_8ugA:10 a=jDxBBm0fxBEA:10 a=7gXAzLPJhVmCkEl4_tsf:22 a=_bBvcJC8wCc67rcU61zu:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=IjZwj45LgO3ly-622nXo:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id 7B9317EC; Sat, 7 Apr 2018 15:23:13 -0700 (PDT) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id w37MNDY0009251; Sat, 7 Apr 2018 15:23:13 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id w37MNBQI009248; Sat, 7 Apr 2018 15:23:11 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201804072223.w37MNBQI009248@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Cy Schubert cc: Bruce Evans , Jeff Roberson , Justin Hibbits , Jeff Roberson , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331369 - head/sys/vm In-Reply-To: Message from Cy Schubert of "Thu, 22 Mar 2018 23:15:29 -0700." <201803230615.w2N6FTMJ040628@slippy.cwsent.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 07 Apr 2018 15:23:11 -0700 X-CMAE-Envelope: MS4wfLmTrm+kXE4yT2WiGQXNAxaj3sHgnMQZFvjqxVSvxkYVLBd6MEgCpgvAWJtQB15ClybSmQkj7bdD/0MScMA76TZvyufO9t/NHjHVN7BdSj0T64jXio1j VVJ+/Cdt4NGkiNEJQiDjO5fWMLZn9SZHEHfoK7HASabke9QE48OX/69GglPqdRaplXgWwQUPOTqM27fFBknAxfmWam7xMKwS0YZfrOntQCJ2cXYiNdRlEcze g7BTmvbuXwMlm1/QImkvIUwneCs1WMIyNNnoCuZMrhRhJQRISoPl79JJophX0nH/SkkFJhpdOTBWD3cB6JyaAuQjSwRVLRraACtWxI5tdPq/oKDWex8PSMYo AhdNIO2B7h78Zn2ygwWb5UMH/ABtbA== X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 22:23:25 -0000 In message <201803230615.w2N6FTMJ040628@slippy.cwsent.com>, Cy Schubert writes: > In message <20180323150709.H968@besplex.bde.org>, Bruce Evans writes: > > On Thu, 22 Mar 2018, Jeff Roberson wrote: > > > > > On Thu, 22 Mar 2018, Cy Schubert wrote: > > > > > >> It broke i386 too. > > > > > > I just did > > > TARGET_ARCH=i386 make buildworld > > > TARGET_ARCH=i386 make buildkernel > > > > > > This worked for me? > > >> > > >> Index: sys/vm/vm_reserv.c > > >> =================================================================== > > >> --- sys/vm/vm_reserv.c (revision 331399) > > >> +++ sys/vm/vm_reserv.c (working copy) > > >> @@ -45,8 +45,6 @@ > > >> > > >> #include > > >> #include > > >> -#include > > >> -#include > > >> #include > > >> #include > > >> #include > > >> @@ -55,6 +53,8 @@ > > >> #include > > >> #include > > >> #include > > >> +#include > > >> +#include > > >> #include > > >> #include > > >> > > >> This is because sys/i386/include/machine.h uses critical_enter() and > > >> critical_exit() which are defined in sys/systm.h. > > > > Wrong fix. I see you committed this. Now there are more bugs to fix. > > > > is a prerequisite for all kernel headers except > > , since it defines and declares things like KASSERT() and > > critical_enter() which might be used in other headers (except > > sys/param.h and its standard pollution). Sometimes sys/systm.h is > > included as undocumented namespace pollution in headers that are > > accidentally included before the (other) ones that use KASSERT(), etc. > > The headers that have this bug have it to work around bugs in .c files > > like the one above. It is more usual to have this bug by not including > > sys/systm.h at all than to have it by including it in a wrong order. > > Sorting it alphabetically almost always gives a wrong order. It must > > be included after sys/param.h and that must be included first. > > Agreed on alphabetic sorting. > > > > > It is a related bug to include only sys/types.h and not sys/param.h. > > This requires chumminess with the current implementation and all > > future implementations. sys/param.h provides certain undocumented > > but standard namespace pollution which might vary with the implementation, > > as necessary to satisfy some of the pollution requirements of all current > > and future implementations of other headers. (The pollution should be > > monotonically decreasing but it was only that for a few years about 20 > > years ago when I worked on fixing it.) .c files that include sys/types.h > > instead of sys/param.h have do some subset of the includes in sys/param.h. > > Since nothing is documented and the subset might depend on the arch and > > user options, it is hard to know the minimal subset. > > That's not the case here. sys/types.h is not included in this file but > point taken. > > > > > .c files that include sys/types.h tend to have lots of other #include > > bugs like not including sys/systm.h. Again it is hard to know the > > minimal replacement for sys/systm.h and its undocumented but standard > > pollution. It is a style bug to include both sys/types.h and sys/param.h. > > style(9) even explicitly forbids including both. It is a larger style > > bug to include the standard pollution in sys/systm.h direction. This > > includes especially and . These > > should be considered as being implemented in sys/systm.h, with the > > headers for them only and implementation detail. Similarly > > for . > > > > >> It built nicely on my amd64's though. > > > > amd64 apparently has more namespace pollution which breaks detection > > of the bug. But I couldn't find where it is. sys/systm.h isn't included > > nested in any amd64 or x86 headers. Apparently some amd64 option gives > > it. > > The reason is amd64 doesn't use critical_enter() and critical_exit() > because counter_enter() and counter_exit() are NOPs. The reason they > are NOPs in amd64 and not in i386 is not all i386 processors support > cmpxchg8b. It is only then that the critical_*() functions are called. > > > > > Bruce > > I can create a phabricator revision to clean this instance up and move > sys/systm.h just after sys/param.h. I'm just about to head out of town > so I'll create it after I get back, after April 4. > > Thank you for your input Bruce. Hi Bruce, Can you please give this a once over? diff --git a/sys/vm/vm_reserv.c b/sys/vm/vm_reserv.c index d8869e3bdbe..6d31d79da39 100644 --- a/sys/vm/vm_reserv.c +++ b/sys/vm/vm_reserv.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include "opt_vm.h" #include +#include #include #include #include @@ -52,7 +53,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. From owner-svn-src-head@freebsd.org Sat Apr 7 22:28:44 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 34712F8B179; Sat, 7 Apr 2018 22:28:44 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DCE8C83DD2; Sat, 7 Apr 2018 22:28:43 +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 D3A4F26D71; Sat, 7 Apr 2018 22:28:43 +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 w37MShEM049959; Sat, 7 Apr 2018 22:28:43 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37MShU5049956; Sat, 7 Apr 2018 22:28:43 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201804072228.w37MShU5049956@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sat, 7 Apr 2018 22:28:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332260 - head/sys/dts/arm/overlays X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/dts/arm/overlays X-SVN-Commit-Revision: 332260 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 22:28:44 -0000 Author: kevans Date: Sat Apr 7 22:28:43 2018 New Revision: 332260 URL: https://svnweb.freebsd.org/changeset/base/332260 Log: Add a83t overlays for sid and emac The sun8i-a83t-bananapi-m3-emac overlay technically doesn't match what will be coming from upstream. The tx-delay and rx-delay should be specified in terms of allwinner,tx-delay-ps and allwinner,rx-delay-ps respectively. The values are still technically correct for what we write in if_awg, and support for the new bindings will be coming soon. Added: head/sys/dts/arm/overlays/sun8i-a83t-bananapi-m3-emac.dtso (contents, props changed) head/sys/dts/arm/overlays/sun8i-a83t-emac.dtso (contents, props changed) head/sys/dts/arm/overlays/sun8i-a83t-sid.dtso (contents, props changed) Added: head/sys/dts/arm/overlays/sun8i-a83t-bananapi-m3-emac.dtso ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dts/arm/overlays/sun8i-a83t-bananapi-m3-emac.dtso Sat Apr 7 22:28:43 2018 (r332260) @@ -0,0 +1,29 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "sinovoip,bpi-m3"; + + fragment@0 { + target = <&mdio>; + __overlay__ { + rgmii_phy: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x1>; + }; + }; + }; + + fragment@1 { + target = <&emac>; + __overlay__ { + pinctrl-names = "default"; + pinctrl-0 = <&emac_rgmii_pins>; + phy-handle = <&rgmii_phy>; + phy-mode = "rgmii"; + rx-delay = <0x7>; + tx-delay = <0x7>; + status = "okay"; + }; + }; +}; Added: head/sys/dts/arm/overlays/sun8i-a83t-emac.dtso ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dts/arm/overlays/sun8i-a83t-emac.dtso Sat Apr 7 22:28:43 2018 (r332260) @@ -0,0 +1,44 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "allwinner,sun8i-a83t"; + + fragment@0 { + target = <&pio>; + __overlay__ { + emac_rgmii_pins: emac-rgmii-pins { + pins = "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", + "PD11", "PD12", "PD13", "PD14", "PD18", + "PD19", "PD20", "PD21", "PD22", "PD23"; + function = "emac"; + drive-strength = <0x28>; + }; + }; + }; + + fragment@1 { + target-path = "/soc"; + __overlay__ { + emac: ethernet@1c30000 { + compatible = "allwinner,sun8i-a83t-emac"; + syscon = <&syscon>; + reg = <0x1c30000 0x104>; + interrupts = <0x0 0x52 0x4>; + interrupt-names = "macirq"; + resets = <&ccu 0xd>; + reset-names = "ahb"; + clocks = <&ccu 0x1b>; + clock-names = "ahb"; + #address-cells = <0x1>; + #size-cells = <0x0>; + status = "disabled"; + mdio: mdio { + compatible = "snps,dwmac-mdio"; + #address-cells = <0x1>; + #size-cells = <0x0>; + }; + }; + }; + }; +}; Added: head/sys/dts/arm/overlays/sun8i-a83t-sid.dtso ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dts/arm/overlays/sun8i-a83t-sid.dtso Sat Apr 7 22:28:43 2018 (r332260) @@ -0,0 +1,17 @@ +/dts-v1/; +/plugin/; + +/ { + compatible = "allwinner,sun8i-a83t"; + + fragment@0 { + target-path = "/soc"; + __overlay__ { + sid: eeprom@1c14000 { + compatible = "allwinner,sun8i-a83t-sid"; + reg = <0x1c14000 0x400>; + status = "okay"; + }; + }; + }; +}; From owner-svn-src-head@freebsd.org Sat Apr 7 23:31:56 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F27D8F8ECC1; Sat, 7 Apr 2018 23:31:55 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9F33D86543; Sat, 7 Apr 2018 23:31:55 +0000 (UTC) (envelope-from ian@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 96DF427872; Sat, 7 Apr 2018 23:31:55 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w37NVt4q081170; Sat, 7 Apr 2018 23:31:55 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w37NVt7w081169; Sat, 7 Apr 2018 23:31:55 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201804072331.w37NVt7w081169@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 7 Apr 2018 23:31:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332261 - head/share/man/man4 X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/share/man/man4 X-SVN-Commit-Revision: 332261 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2018 23:31:56 -0000 Author: ian Date: Sat Apr 7 23:31:55 2018 New Revision: 332261 URL: https://svnweb.freebsd.org/changeset/base/332261 Log: Add a manpage for spigen(4). Added: head/share/man/man4/spigen.4 (contents, props changed) Added: head/share/man/man4/spigen.4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man4/spigen.4 Sat Apr 7 23:31:55 2018 (r332261) @@ -0,0 +1,206 @@ +.\" +.\" Copyright (c) 2018 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 ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd April 7, 2018 +.Dt SPIGEN 4 +.Os +.Sh NAME +.Nm spigen +.Nd SPI generic I/O device driver +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device spi" +.Cd "device spibus" +.Cd "device spigen" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +spigen_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides direct access to a slave device on the SPI bus. +Each instance of a +.Nm +device is associated with a single chip-select +line on the bus, and all I/O performed through that instance is done +with that chip-select line asserted. +.Pp +SPI data transfers are inherently bi-directional; there are not separate +read and write operations. +When commands and data are sent to a device, data also comes back from +the device, although in some cases the data may not be useful (or even +documented or predictable for some devices). +Likewise on a read operation, whatever data is in the buffer at the start +of the operation is sent to (and typically ignored by) the device, with each +outgoing byte then replaced in the buffer by the corresponding incoming byte. +Thus, all buffers passed to the transfer functions are both input and +output buffers. +.Pp +The +.Nm +driver provides access to the SPI slave device with the following +.Xr ioctl 2 +calls, defined in +.In sys/spigenio.h : +.Bl -tag -width indent +.It Dv SPIGENIOC_TRANSFER Pq Vt "struct spigen_transfer" +Transfer a command and optional associated data to/from the device, +using the buffers described by the st_command and st_data fields in the +.Vt spigen_transfer . +Set +.Vt st_data.iov_len +to zero if there is no data associated with the command. +.Bd -literal +struct spigen_transfer { + struct iovec st_command; + struct iovec st_data; +}; +.Ed +.It Dv SPIGENIOC_TRANSFER_MMAPPED Pq Vt "spigen_transfer_mmapped" +Transfer a command and optional associated data to/from the device. +The buffers for the transfer are a previously-mmap'd region. +The length of the command and data within that region are described by the +.Vt stm_command_length +and +.Vt stm_data_length +fields of +.Vt spigen_transfer_mmapped . +If +.Vt stm_data_length +is non-zero, the data appears in the memory region immediately +following the command (that is, at offset +.Vt stm_command_length +from the start of the mapped region). +.Bd -literal +struct spigen_transfer_mmapped { + size_t stm_command_length; + size_t stm_data_length; +}; +.Ed +.It Dv SPIGENIOC_GET_CLOCK_SPEED Pq Vt uint32_t +Get the maximum clock speed (bus frequency in Hertz) to be used +when communicating with this slave device. +.It Dv SPIGENIOC_SET_CLOCK_SPEED Pq Vt uint32_t +Set the maximum clock speed (bus frequency in Hertz) to be used +when communicating with this slave device. +The setting remains in effect for subsequent transfers; it +is not necessary to reset this before each transfer. +The actual bus frequency may be lower due to hardware limitiations +of the SPI bus controller device. +.It Dv SPIGENIOC_GET_SPI_MODE Pq Vt uint32_t +Get the SPI mode (clock polarity and phase) to be used +when communicating with this device. +.It Dv SPIGENIOC_SET_SPI_MODE Pq Vt uint32_t +Set the SPI mode (clock polarity and phase) to be used +when communicating with this device. +The setting remains in effect for subsequent transfers; it +is not necessary to reset this before each transfer. +.El +.Sh HINTS CONFIGURATION +On a +.Xr device.hints 5 +based system, such as +.Li MIPS , +these values are configurable for +.Nm : +.Bl -tag -width indent +.It Va hint.spigen.%d.at +The spibus the +.Nm +instance is attached to. +.It Va hint.spigen.%d.clock +The maximum bus frequency to use when communicating with this device. +Actual bus speed may be lower, depending on the capabilities of the SPI +bus controller hardware. +.It Va hint.spigen.%d.cs +The chip-select number to assert when performing I/O for this device. +Set the high bit (1 << 31) to invert the logic level of the chip select line. +.It Va hint.spigen.%d.mode +The SPI mode (0-3) to use when communicating with this device. +.El +.Sh FDT CONFIGURATION +On an +.Xr fdt 4 +based system, the spigen device is defined as a slave device subnode +of the SPI bus controller node. +All properties documented in the +.Va spibus.txt +bindings document can be used with the +.Nm +device. +The most commonly-used ones are documented below. +.Pp +The following properties are required in the +.Nm +device subnode: +.Bl -tag -width indent +.It Va compatible +Must be the string "freebsd,spigen". +.It Va reg +Chip select address of device. +.It Va spi-max-frequency +The maximum bus frequency to use when communicating with this slave device. +Actual bus speed may be lower, depending on the capabilities of the SPI +bus controller hardware. +.El +.Pp +The following properties are optional for the +.Nm +device subnode: +.Bl -tag -width indent +.It Va spi-cpha +Empty property indicating the slave device requires shifted clock +phase (CPHA) mode. +.It Va spi-cpol +Empty property indicating the slave device requires inverse clock +polarity (CPOL) mode. +.It Va spi-cs-high +Empty property indicating the slave device requires chip select active high. +.El +.Sh FILES +.Bl -tag -width -compact +.It Pa /dev/spigen* +.El +.Sh SEE ALSO +.Xr fdt 4 , +.Xr device.hints 5 +.Sh HISTORY +The +.Nm +driver +appeared in +.Fx 11.0 . +FDT support appeared in +.Fx 11.2 .