From owner-svn-src-all@freebsd.org Tue Aug 4 21:49:14 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 74AC33A16AC; Tue, 4 Aug 2020 21:49:14 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BLpLL2BzWz3gWD; Tue, 4 Aug 2020 21:49:14 +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 2EC34BBCF; Tue, 4 Aug 2020 21:49:14 +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 074LnE4p078306; Tue, 4 Aug 2020 21:49:14 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 074LnESw078305; Tue, 4 Aug 2020 21:49:14 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202008042149.074LnESw078305@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 4 Aug 2020 21:49:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363869 - head/sys/tools X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/tools X-SVN-Commit-Revision: 363869 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Aug 2020 21:49:14 -0000 Author: kevans Date: Tue Aug 4 21:49:13 2020 New Revision: 363869 URL: https://svnweb.freebsd.org/changeset/base/363869 Log: makesyscalls.lua: improve syscall ordering validation There were two separate issues here: 1.) #if/#else wasn't taken into account at all for maxsyscall figures, but 2.) We didn't validate contiguous syscall numbers anyways... This kind of inconsistency is bad as we don't currently ensure explicit indexing of, e.g., the sysent array if one syscall is unimplemented/missing. This could be fixed and might be more robust, but it's also good to have the "documentation" that comes from being explicit as to what the missing syscalls are. The new version looks much like the awk version; stash off the current 'last highest syscall seen' if we hit an #if, restore to that if we hit an #else, and make sure that we're explicitly always defining the next syscall. The logic at the tail end of process_syscall_def that moves maxsyscall has been 'cleaned up' a little since we're now ensuring that it's monotonically increasing earlier in the function. At the moment I think it's unlikely we'd see range-definitions that are not UNIMPL, but there's no reason to specifically handle that case for bumping maxsyscall there. This change was provoked by reading the commit message for r363832 and realizing that this validation hadn't been included in the initial rewrite to lua. Reviewed by: brooks Differential Revision: https://reviews.freebsd.org/D25945 Modified: head/sys/tools/makesyscalls.lua Modified: head/sys/tools/makesyscalls.lua ============================================================================== --- head/sys/tools/makesyscalls.lua Tue Aug 4 21:34:13 2020 (r363868) +++ head/sys/tools/makesyscalls.lua Tue Aug 4 21:49:13 2020 (r363869) @@ -35,7 +35,8 @@ local lfs = require("lfs") local unistd = require("posix.unistd") -local maxsyscall = 0 +local savesyscall = -1 +local maxsyscall = -1 local generated_tag = "@" .. "generated" -- Default configuration; any of these may get replaced by a configuration file @@ -442,6 +443,11 @@ local pattern_table = { dump_prevline = true, pattern = "^#", process = function(line) + if line:find("^#%s*if") then + savesyscall = maxsyscall + elseif line:find("^#%s*else") then + maxsyscall = savesyscall + end line = line .. "\n" write_line('sysent', line) write_line('sysdcl', line) @@ -916,6 +922,16 @@ process_syscall_def = function(line) sysnum = nil sysstart = tonumber(sysstart) sysend = tonumber(sysend) + if sysstart ~= maxsyscall + 1 then + abort(1, "syscall number out of sync, missing " .. + maxsyscall + 1) + end + else + sysnum = tonumber(sysnum) + if sysnum ~= maxsyscall + 1 then + abort(1, "syscall number out of sync, missing " .. + maxsyscall + 1) + end end -- Split flags @@ -1093,15 +1109,14 @@ process_syscall_def = function(line) handle_obsol(sysnum, funcname, funcomment) elseif flags & known_flags["UNIMPL"] ~= 0 then handle_unimpl(sysnum, sysstart, sysend, funcomment) - if sysend ~= nil and sysend > maxsyscall then - maxsyscall = sysend - end else abort(1, "Bad flags? " .. line) end - if sysnum ~= nil and tonumber(sysnum) > maxsyscall then - maxsyscall = tonumber(sysnum) + if sysend ~= nil then + maxsyscall = sysend + elseif sysnum ~= nil then + maxsyscall = sysnum end end