sysent: move away from allowing all compat options for other ABIs

Notably, the current compat_options only makes sense for native and
freebsd32 ABIs.  For the others, it just adds cruft. Switch to having
sets of compat options, and default to the native set.  Setup the other
ABIs where it doesn't make sense to opt-out of the native set.

This removes some redundant COMPAT_FREEBSD* stuff from Linuxolator bits.

line_expr in makesyscalls.lua is fixed to allow empty strings to be
specified, since they're harmless.

Reviewed by:	brooks, kib (both earlier version)
Differential Revision:	https://reviews.freebsd.org/D33356
This commit is contained in:
Kyle Evans 2021-12-08 22:37:28 -06:00
parent d8b45c8e14
commit 8494666658
5 changed files with 37 additions and 16 deletions

View File

@ -9,3 +9,4 @@ syscallprefix="LINUX_SYS_"
switchname="linux_sysent"
namesname="linux_syscallnames"
systrace="linux_systrace_args.c"
compat_set=""

View File

@ -9,3 +9,4 @@ syscallprefix="LINUX32_SYS_"
switchname="linux32_sysent"
namesname="linux32_syscallnames"
systrace="linux32_systrace_args.c"
compat_set=""

View File

@ -9,3 +9,4 @@ syscallprefix="LINUX_SYS_"
switchname="linux_sysent"
namesname="linux_syscallnames"
systrace="linux_systrace_args.c"
compat_set=""

View File

@ -9,3 +9,4 @@ syscallprefix="LINUX_SYS_"
switchname="linux_sysent"
namesname="linux_syscallnames"
systrace="linux_systrace_args.c"
compat_set=""

View File

@ -56,6 +56,7 @@ local config = {
systrace = "systrace_args.c",
capabilities_conf = "capabilities.conf",
capenabled = {},
compat_set = "native",
mincompat = 0,
abi_type_suffix = "",
abi_flags = "",
@ -201,7 +202,7 @@ local known_flags = {
-- Compat flags start from here. We have plenty of space.
}
-- All compat_options entries should have five entries:
-- All compat option entries should have five entries:
-- definition: The preprocessor macro that will be set for this
-- compatlevel: The level this compatibility should be included at. This
-- generally represents the version of FreeBSD that it is compatible
@ -212,23 +213,28 @@ local known_flags = {
-- used as-is, without "_" or any other character appended.
-- descr: The description of this compat option in init_sysent.c comments.
-- The special "stdcompat" entry will cause the other five to be autogenerated.
local compat_options = {
{
definition = "COMPAT_43",
compatlevel = 3,
flag = "COMPAT",
prefix = "o",
descr = "old",
local compat_option_sets = {
native = {
{
definition = "COMPAT_43",
compatlevel = 3,
flag = "COMPAT",
prefix = "o",
descr = "old",
},
{ stdcompat = "FREEBSD4" },
{ stdcompat = "FREEBSD6" },
{ stdcompat = "FREEBSD7" },
{ stdcompat = "FREEBSD10" },
{ stdcompat = "FREEBSD11" },
{ stdcompat = "FREEBSD12" },
{ stdcompat = "FREEBSD13" },
},
{ stdcompat = "FREEBSD4" },
{ stdcompat = "FREEBSD6" },
{ stdcompat = "FREEBSD7" },
{ stdcompat = "FREEBSD10" },
{ stdcompat = "FREEBSD11" },
{ stdcompat = "FREEBSD12" },
{ stdcompat = "FREEBSD13" },
}
-- compat_options will be resolved to a set from the configuration.
local compat_options
local function trim(s, char)
if s == nil then
return nil
@ -250,7 +256,7 @@ local function process_config(file)
-- Alternatively, we could drop the whitespace and instead try to
-- use a pattern to strip out the meaty part of the line, but then we
-- would need to sanitize the line for potentially special characters.
local line_expr = "^([%w%p]+%s*)=(%s*[`\"]?[^\"`]+[`\"]?)"
local line_expr = "^([%w%p]+%s*)=(%s*[`\"]?[^\"`]*[`\"]?)"
if not file then
return nil, "No file given"
@ -1336,6 +1342,17 @@ if configfile ~= nil then
end
end
local compat_set = config['compat_set']
if compat_set ~= "" then
if not compat_option_sets[compat_set] then
abort(1, "Undefined compat set: " .. compat_set)
end
compat_options = compat_option_sets[compat_set]
else
compat_options = {}
end
-- We ignore errors here if we're relying on the default configuration.
if not config_modified["capenabled"] then
config["capenabled"] = grab_capenabled(config['capabilities_conf'],