svn commit: r363869 - head/sys/tools

Kyle Evans kevans at FreeBSD.org
Tue Aug 4 21:49:14 UTC 2020


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
 


More information about the svn-src-head mailing list