From 2cf01ab7023ce34da711af45413f4ed7850a9837 Mon Sep 17 00:00:00 2001 From: Bruce Dubbs Date: Mon, 31 Jul 2023 01:09:24 -0500 Subject: [PATCH 1/5] Add some color to kernel options --- chapter10/kernel.xml | 74 ++++++++++++++++++------------------- stylesheets/lfs-xsl/lfs.css | 3 ++ 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/chapter10/kernel.xml b/chapter10/kernel.xml index ea367054a..9e522cb0d 100644 --- a/chapter10/kernel.xml +++ b/chapter10/kernel.xml @@ -130,36 +130,36 @@ Be sure to enable/disable/set the following features or the system might not work correctly or boot at all: -General setup ---> - [ ] Compile the kernel with warnings as errors [CONFIG_WERROR] - CPU/Task time and stats accounting ---> - [*] Pressure stall information tracking [CONFIG_PSI] - [ ] Require boot parameter to enable pressure stall information tracking +General setup ---> + [ ] Compile the kernel with warnings as errors [CONFIG_WERROR] + CPU/Task time and stats accounting ---> + [*] Pressure stall information tracking [CONFIG_PSI] + [ ] Require boot parameter to enable pressure stall information tracking [CONFIG_PSI_DEFAULT_DISABLED] - < > Enable kernel headers through /sys/kernel/kheaders.tar.xz [CONFIG_IKHEADERS] - [*] Control Group support [CONFIG_CGROUPS] ---> - [*] Memory controller [CONFIG_MEMCG] - [ ] Configure standard kernel features (expert users) [CONFIG_EXPERT] + < > Enable kernel headers through /sys/kernel/kheaders.tar.xz [CONFIG_IKHEADERS] + [*] Control Group support [CONFIG_CGROUPS] ---> + [*] Memory controller [CONFIG_MEMCG] + [ ] Configure standard kernel features (expert users) [CONFIG_EXPERT] -Processor type and features ---> - [*] Build a relocatable kernel [CONFIG_RELOCATABLE] - [*] Randomize the address of the kernel image (KASLR) [CONFIG_RANDOMIZE_BASE] +Processor type and features ---> + [*] Build a relocatable kernel [CONFIG_RELOCATABLE] + [*] Randomize the address of the kernel image (KASLR) [CONFIG_RANDOMIZE_BASE] -General architecture-dependent options ---> - [*] Stack Protector buffer overflow detection [CONFIG_STACKPROTECTOR] - [*] Strong Stack Protector [CONFIG_STACKPROTECTOR_STRONG] +General architecture-dependent options ---> + [*] Stack Protector buffer overflow detection [CONFIG_STACKPROTECTOR] + [*] Strong Stack Protector [CONFIG_STACKPROTECTOR_STRONG] -Device Drivers ---> - Generic Driver Options ---> - [ ] Support for uevent helper [CONFIG_UEVENT_HELPER] - [*] Maintain a devtmpfs filesystem to mount at /dev [CONFIG_DEVTMPFS] - [*] Automount devtmpfs at /dev, after the kernel mounted the rootfs +Device Drivers ---> + Generic Driver Options ---> + [ ] Support for uevent helper [CONFIG_UEVENT_HELPER] + [*] Maintain a devtmpfs filesystem to mount at /dev [CONFIG_DEVTMPFS] + [*] Automount devtmpfs at /dev, after the kernel mounted the rootfs [CONFIG_DEVTMPFS_MOUNT] - Graphics support ---> - Frame buffer Devices ---> - <*> Support for frame buffer devices ---> - Console display driver support ---> - [*] Framebuffer Console support [CONFIG_FRAMEBUFFER_CONSOLE] + Graphics support ---> + Frame buffer Devices ---> + <*> Support for frame buffer devices ---> + Console display driver support ---> + [*] Framebuffer Console support [CONFIG_FRAMEBUFFER_CONSOLE] General setup ---> @@ -216,31 +216,31 @@ File systems ---> CONFIG_X86_X2APIC because an option only shows up after its dependencies are selected. -Processor type and features ---> - [*] Support x2apic [CONFIG_X86_X2APIC] +Processor type and features ---> + [*] Support x2apic [CONFIG_X86_X2APIC] Device Drivers ---> - [*] PCI Support ---> [CONFIG_PCI] - [*] Message Signaled Interrupts (MSI and MSI-X) [CONFIG_PCI_MSI] - [*] IOMMU Hardware Support ---> [CONFIG_IOMMU_SUPPORT] - [*] Support for Interrupt Remapping [CONFIG_IRQ_REMAP] + [*] PCI Support ---> [CONFIG_PCI] + [*] Message Signaled Interrupts (MSI and MSI-X) [CONFIG_PCI_MSI] + [*] IOMMU Hardware Support ---> [CONFIG_IOMMU_SUPPORT] + [*] Support for Interrupt Remapping [CONFIG_IRQ_REMAP] If you are building a 32-bit system running on a hardware with RAM more than 4GB, adjust the configuration so the kernel will be able to use up to 64GB physical RAM: - Processor type and features ---> - High Memory Support ---> - (X) 64GB [CONFIG_HIGHMEM64G] + Processor type and features ---> + High Memory Support ---> + (X) 64GB [CONFIG_HIGHMEM64G] If the partition for the LFS system is in a NVME SSD (i. e. the device node for the partition is /dev/nvme* instead of /dev/sd*), enable NVME support or the LFS system won't boot: - Device Drivers ---> - NVME Support ---> - <*> NVM Express block device [CONFIG_BLK_DEV_NVME] + Device Drivers ---> + NVME Support ---> + <*> NVM Express block device [CONFIG_BLK_DEV_NVME] diff --git a/stylesheets/lfs-xsl/lfs.css b/stylesheets/lfs-xsl/lfs.css index 3cadbc469..80eca11ed 100644 --- a/stylesheets/lfs-xsl/lfs.css +++ b/stylesheets/lfs-xsl/lfs.css @@ -265,6 +265,9 @@ li.chapter h4 a { margin: .6em 0 .2em 0; } +span.blue { + color: #2ac; +} /* Index */ .item { From 70bf5512d96389ea1c068cd20a48093a10d6a963 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Tue, 1 Aug 2023 00:08:56 +0800 Subject: [PATCH 2/5] kernel: Use new kernel configuration rendering method Import kernel-config infrastructure from BLFS and use it for kernel configuration. Note that kernel-config.py is slightly different from BLFS: we need role="nodump" for here. --- chapter10/kernel.xml | 103 ++-------- chapter10/kernel/.gitignore | 2 + chapter10/kernel/Makefile | 19 ++ chapter10/kernel/highmem.toml | 1 + chapter10/kernel/highmem.xml | 8 + chapter10/kernel/kernel-config.py | 293 +++++++++++++++++++++++++++++ chapter10/kernel/kernel.version | 1 + chapter10/kernel/kernel_version.py | 27 +++ chapter10/kernel/nvme.toml | 1 + chapter10/kernel/nvme.xml | 8 + chapter10/kernel/systemd.toml | 30 +++ chapter10/kernel/systemd.xml | 48 +++++ chapter10/kernel/sysv.toml | 18 ++ chapter10/kernel/sysv.xml | 32 ++++ chapter10/kernel/x2apic.toml | 5 + chapter10/kernel/x2apic.xml | 12 ++ 16 files changed, 518 insertions(+), 90 deletions(-) create mode 100644 chapter10/kernel/.gitignore create mode 100644 chapter10/kernel/Makefile create mode 100644 chapter10/kernel/highmem.toml create mode 100644 chapter10/kernel/highmem.xml create mode 100755 chapter10/kernel/kernel-config.py create mode 100644 chapter10/kernel/kernel.version create mode 100755 chapter10/kernel/kernel_version.py create mode 100644 chapter10/kernel/nvme.toml create mode 100644 chapter10/kernel/nvme.xml create mode 100644 chapter10/kernel/systemd.toml create mode 100644 chapter10/kernel/systemd.xml create mode 100644 chapter10/kernel/sysv.toml create mode 100644 chapter10/kernel/sysv.xml create mode 100644 chapter10/kernel/x2apic.toml create mode 100644 chapter10/kernel/x2apic.xml diff --git a/chapter10/kernel.xml b/chapter10/kernel.xml index 9e522cb0d..8609b1474 100644 --- a/chapter10/kernel.xml +++ b/chapter10/kernel.xml @@ -130,84 +130,15 @@ Be sure to enable/disable/set the following features or the system might not work correctly or boot at all: -General setup ---> - [ ] Compile the kernel with warnings as errors [CONFIG_WERROR] - CPU/Task time and stats accounting ---> - [*] Pressure stall information tracking [CONFIG_PSI] - [ ] Require boot parameter to enable pressure stall information tracking - [CONFIG_PSI_DEFAULT_DISABLED] - < > Enable kernel headers through /sys/kernel/kheaders.tar.xz [CONFIG_IKHEADERS] - [*] Control Group support [CONFIG_CGROUPS] ---> - [*] Memory controller [CONFIG_MEMCG] - [ ] Configure standard kernel features (expert users) [CONFIG_EXPERT] + -Processor type and features ---> - [*] Build a relocatable kernel [CONFIG_RELOCATABLE] - [*] Randomize the address of the kernel image (KASLR) [CONFIG_RANDOMIZE_BASE] + -General architecture-dependent options ---> - [*] Stack Protector buffer overflow detection [CONFIG_STACKPROTECTOR] - [*] Strong Stack Protector [CONFIG_STACKPROTECTOR_STRONG] - -Device Drivers ---> - Generic Driver Options ---> - [ ] Support for uevent helper [CONFIG_UEVENT_HELPER] - [*] Maintain a devtmpfs filesystem to mount at /dev [CONFIG_DEVTMPFS] - [*] Automount devtmpfs at /dev, after the kernel mounted the rootfs - [CONFIG_DEVTMPFS_MOUNT] - Graphics support ---> - Frame buffer Devices ---> - <*> Support for frame buffer devices ---> - Console display driver support ---> - [*] Framebuffer Console support [CONFIG_FRAMEBUFFER_CONSOLE] - - -General setup ---> - [ ] Compile the kernel with warnings as errors [CONFIG_WERROR] - [ ] Auditing Support [CONFIG_AUDIT] - CPU/Task time and stats accounting ---> - [*] Pressure stall information tracking [CONFIG_PSI] - [ ] Require boot parameter to enable pressure stall information tracking - [CONFIG_PSI_DEFAULT_DISABLED] - < > Enable kernel headers through /sys/kernel/kheaders.tar.xz [CONFIG_IKHEADERS] - [*] Control Group support [CONFIG_CGROUPS] ---> - [*] Memory controller [CONFIG_MEMCG] - [ ] Configure standard kernel features (expert users) [CONFIG_EXPERT] - -Processor type and features ---> - [*] Build a relocatable kernel [CONFIG_RELOCATABLE] - [*] Randomize the address of the kernel image (KASLR) [CONFIG_RANDOMIZE_BASE] - -General architecture-dependent options ---> - [*] Enable seccomp to safely compute untrusted bytecode [CONFIG_SECCOMP] - [*] Stack Protector buffer overflow detection [CONFIG_STACKPROTECTOR] - [*] Strong Stack Protector [CONFIG_STACKPROTECTOR_STRONG] - -[*] Networking support ---> [CONFIG_NET] - Networking options ---> - [*] TCP/IP networking [CONFIG_INET] - <*> The IPv6 protocol [CONFIG_IPV6] - -Device Drivers ---> - Generic Driver Options ---> - [ ] Support for uevent helper [CONFIG_UEVENT_HELPER] - [*] Maintain a devtmpfs filesystem to mount at /dev [CONFIG_DEVTMPFS] - [*] Automount devtmpfs at /dev, after the kernel mounted the rootfs - [CONFIG_DEVTMPFS_MOUNT] - Firmware Loader ---> - [ ] Enable the firmware sysfs fallback mechanism [CONFIG_FW_LOADER_USER_HELPER] - Firmware Drivers ---> - [*] Export DMI identification via sysfs to userspace [CONFIG_DMIID] - Graphics support ---> - Frame buffer Devices ---> - <*> Support for frame buffer devices ---> - Console display driver support ---> - [*] Framebuffer Console support [CONFIG_FRAMEBUFFER_CONSOLE] - -File systems ---> - [*] Inotify support for userspace [CONFIG_INOTIFY_USER] - Pseudo filesystems ---> - [*] Tmpfs POSIX Access Control Lists [CONFIG_TMPFS_POSIX_ACL] + Enable some additional features if you are building a 64-bit system. If you are using menuconfig, enable them in the order of @@ -216,31 +147,23 @@ File systems ---> CONFIG_X86_X2APIC because an option only shows up after its dependencies are selected. -Processor type and features ---> - [*] Support x2apic [CONFIG_X86_X2APIC] - -Device Drivers ---> - [*] PCI Support ---> [CONFIG_PCI] - [*] Message Signaled Interrupts (MSI and MSI-X) [CONFIG_PCI_MSI] - [*] IOMMU Hardware Support ---> [CONFIG_IOMMU_SUPPORT] - [*] Support for Interrupt Remapping [CONFIG_IRQ_REMAP] + If you are building a 32-bit system running on a hardware with RAM more than 4GB, adjust the configuration so the kernel will be able to use up to 64GB physical RAM: - Processor type and features ---> - High Memory Support ---> - (X) 64GB [CONFIG_HIGHMEM64G] + If the partition for the LFS system is in a NVME SSD (i. e. the device node for the partition is /dev/nvme* instead of /dev/sd*), enable NVME support or the LFS system won't boot: - Device Drivers ---> - NVME Support ---> - <*> NVM Express block device [CONFIG_BLK_DEV_NVME] + diff --git a/chapter10/kernel/.gitignore b/chapter10/kernel/.gitignore new file mode 100644 index 000000000..e22d2c3a4 --- /dev/null +++ b/chapter10/kernel/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +s-kernel-version diff --git a/chapter10/kernel/Makefile b/chapter10/kernel/Makefile new file mode 100644 index 000000000..d02408dcc --- /dev/null +++ b/chapter10/kernel/Makefile @@ -0,0 +1,19 @@ +INPUT = $(wildcard *.toml) +OUTPUT = $(patsubst %.toml, %.xml, $(INPUT)) + +ifeq ($(KERNEL_TREE),) +$(error "must set KERNEL_TREE=/path/to/kernel/source") +endif + +all: $(OUTPUT) + +kernel.version: s-kernel-version; @true +s-kernel-version: Makefile kernel_version.py + ./kernel_version.py $(KERNEL_TREE) > tmp-kernel.version + if ! diff tmp-kernel.version $@ 2>/dev/null >/dev/null; then \ + mv tmp-kernel.version kernel.version; \ + fi + touch s-kernel-version + +%.xml: %.toml kernel-config.py kernel_version.py kernel.version + ./kernel-config.py $(KERNEL_TREE) $< > $@ diff --git a/chapter10/kernel/highmem.toml b/chapter10/kernel/highmem.toml new file mode 100644 index 000000000..2caf42385 --- /dev/null +++ b/chapter10/kernel/highmem.toml @@ -0,0 +1 @@ +HIGHMEM64G='X' diff --git a/chapter10/kernel/highmem.xml b/chapter10/kernel/highmem.xml new file mode 100644 index 000000000..4f0938142 --- /dev/null +++ b/chapter10/kernel/highmem.xml @@ -0,0 +1,8 @@ + + + +Processor type and features ---> + High Memory Support ---> + (X) 64GB [HIGHMEM64G] diff --git a/chapter10/kernel/kernel-config.py b/chapter10/kernel/kernel-config.py new file mode 100755 index 000000000..93b203a46 --- /dev/null +++ b/chapter10/kernel/kernel-config.py @@ -0,0 +1,293 @@ +#!/usr/bin/env python3 + +# SPDX-License-Identifier: MIT +# Copyright 2023 The LFS Editors + +# Stupid script to render "mconf"-style kernel configuration +# Usage: kernel-config.py [path to kernel tree] [needed config].toml +# The toml file should be like: +# for bool and tristate: +# EXT4="*" +# DRM="*M" +# EXPERT=" " +# DRM_I915="*M" +# for choice: +# HIGHMEM64G="X" +# an entry with comment: +# DRM_I915 = { value = " *M", comment = "for i915, crocus, or iris" } + +choice_bit = 1 << 30 +ind0 = 0 +ind1 = 0 +menu_id = 1 +stack = [] +if_stack = [] + +expand_var_mp = { 'SRCARCH': 'x86' } +main_dep = {} + +def expand_var(s): + for k in expand_var_mp: + s = s.replace('$(' + k + ')', expand_var_mp[k]) + return s + +def pop_stack(cond): + global ind0, ind1, stack + assert(cond(stack[-1][0])) + s, i0, i1, _ = stack[-1] + stack = stack[:-1] + ind0 -= i0 + ind1 -= i1 + +def pop_stack_while(cond): + while stack and cond(stack[-1][0]): + pop_stack(cond) + +def cur_menu(): + global stack + return stack[-1][3] if stack else 0 + +def cur_if(): + global if_stack + return if_stack[-1][:] if if_stack else [] + +def clean_dep(d): + d = d.strip() + if d.endswith('=y') or d.endswith('=M'): + d = d[:-2] + elif d.endswith(' != ""'): + d = d[:-6] + return d + +def parse_config(buf): + global ind0, ind1, stack, menu_id + is_choice = buf[0].strip() == 'choice' + is_menu = buf[0].startswith('menu') or is_choice + is_nonconfig_menu = buf[0].startswith('menu ') or is_choice + key = None if is_nonconfig_menu else buf[0].split()[1].strip() + title = buf[0][len('menu '):] if is_nonconfig_menu else None + deps = ['menu'] + cur_if() + klass = None + + for line in buf[1:]: + line = line.strip() + if line.startswith('depends on '): + new_deps = line[len('depends on '):].split('&&') + deps += [clean_dep(x) for x in new_deps] + elif line.startswith('prompt'): + title = line[len('prompt '):] + else: + for prefix in ['tristate', 'bool', 'string']: + if line.startswith(prefix + ' '): + title = line[len(prefix) + 1:] + klass = prefix + elif line == prefix: + klass = prefix + elif line.startswith('def_' + prefix + ' '): + klass = prefix + else: + continue + + if '"' in line: + tail = line[line.rfind('"') + 1:].strip() + if tail[:3] == 'if ': + deps += [clean_dep(x) for x in tail[3:].split('&&')] + + pop_stack_while(lambda x: x not in deps) + + menu_id += is_menu + internal_key = key or menu_id + if stack: + fa = stack[-1][0] + if fa == 'menu': + fa = cur_menu() & ~choice_bit + main_dep[internal_key] = fa + + val = known_config.get(key) + comment = None + forced = None + + if type(val) == dict: + comment = val.get('comment') + forced = val.get('forced') + val = val['value'] + + klass = klass or 'string' + if title: + title = title.strip().lstrip('"') + title = title[:title.find('"')] + + if not val: + pass + elif klass == 'string': + val = '(' + val + ')' + else: + assert((val == 'X') == bool(cur_menu() & choice_bit)) + if (val == 'X'): + val = '(X)' + else: + val = list(val) + val.sort() + for c in val: + if c not in 'M* ' or (c == 'M' and klass != 'tristate'): + raise Exception('unknown setting %s for %s' % (c, key)) + bracket = None + if klass == 'tristate' and forced != '*' : + bracket = '{}' if forced else '<>' + else: + bracket = '--' if forced else '[]' + + val = bracket[0] + '/'.join(val) + bracket[1] + + arrow = ' --->' if is_menu else '' + r = [ind0, val, ind1, title, arrow, internal_key, cur_menu(), comment] + + # Don't indent for untitled (internal) entries + x = 2 if title else 0 + + key = key or 'menu' + menu = (menu_id if is_menu else cur_menu()) + menu |= choice_bit if is_choice else 0 + stack_ent = (key, 2, 0, menu) if is_menu else (key, 0, x, menu) + ind0 += stack_ent[1] + ind1 += stack_ent[2] + stack += [stack_ent] + + return r + +def load_kconfig(file): + global ind0, ind1, stack, path, menu_id, if_stack + r = [] + config_buf = [] + with open(path + file) as f: + for line in f: + if config_buf: + if not (line.startswith('\t') or line.startswith(' ')): + r += [parse_config(config_buf)] + config_buf = [] + else: + config_buf += [line] + continue + if line.startswith('source') or line.startswith('\tsource'): + sub = expand_var(line.strip().split()[1].strip('"')) + r += load_kconfig(sub) + elif line.startswith('config') or line.startswith('menu'): + config_buf = [line] + elif line.startswith('choice'): + config_buf = [line] + elif line.startswith('endmenu') or line.startswith('endchoice'): + pop_stack_while(lambda x: x != 'menu') + pop_stack(lambda x: x == 'menu') + elif line.startswith('if '): + line = line[3:] + top = cur_if() + top += [x.strip() for x in line.split("&&")] + if_stack += [top] + elif line.startswith('endif'): + if_stack = if_stack[:-1] + return r + +known_config = {} + +def escape(x): + return x.replace('<', '<').replace('>', '>') + +from sys import argv +import tomllib + +path = argv[1] +if path[-1] != '/': + path += '/' +with open(argv[2], 'rb') as f: + known_config = tomllib.load(f) + +r = load_kconfig('Kconfig') + +# Refcount all menus + +index_ikey = {} +for i in reversed(range(len(r))): + index_ikey[r[i][5]] = i + +for i in reversed(range(len(r))): + if r[i][1] != None: + key = r[i][5] + fa = main_dep.get(key) + if not fa: + continue + j = index_ikey[fa] + if type(fa) == int or not r[j][3]: + # The main dependency is a menu or untitled magic entry, + # just mark it used + r[j][1] = '' + if r[j][1] is None: + raise Exception('[%s] needs unselected [%s]' % (key, fa)) + +r = [i for i in r if i[1] != None and i[3]] + +# Now we are going to pretty-print r + +## Calculate the maximum value length for each menu +max_val_len = {} +for _, val, _, _, _, _, menu, _ in r: + x = max_val_len.get(menu) or 0 + max_val_len[menu] = max(x, len(val)) + +## Output + +max_line = 80 +buf = [] + +done = [x[5] for x in r] + ['revision'] +for i in known_config: + if i not in done: + raise Exception("%s seems not exist" % i) + +for i0, val, i1, title, arrow, key, menu, comment in r: + rem = max_line + + if val: + val += (max_val_len[menu] - len(val)) * ' ' + + rem -= i0 + i1 + bool(val) + len(val) + line = i0 * ' ' + escape(val) + (i1 + bool(val)) * ' ' + + rem -= len(arrow) + + if len(title) > rem: + title = title[:rem - 3] + '...' + + b = title.lstrip('YyMmNnHh') + a = title[:len(title) - len(b)] + b0 = "" + escape(b[0]) + "" + line += escape(a) + b0 + escape(b[1:]) + escape(arrow) + + rem -= len(title) + + key = ' [' + key + ']' if type(key) == str else '' + + if len(key) <= rem: + line += (rem - len(key)) * ' ' + key + else: + key = '... ' + key + line += '\n' + ' ' * (max_line - len(key)) + key + if type(comment) == str: + comment = [comment] + if comment: + comment = '\n'.join([' ' * i0 + '# ' + line for line in comment]) + line = escape(comment) + ':\n' + line + + buf += [line.rstrip()] + +from jinja2 import Template + +t = Template(''' + + +{{ '\n'.join(buf) }}''') + +rev = known_config.get('revision') +rev = ' revision="%s"' % rev if rev else '' +print(t.render(rev = rev, buf = buf)) diff --git a/chapter10/kernel/kernel.version b/chapter10/kernel/kernel.version new file mode 100644 index 000000000..3c43d7159 --- /dev/null +++ b/chapter10/kernel/kernel.version @@ -0,0 +1 @@ +6.4.7 diff --git a/chapter10/kernel/kernel_version.py b/chapter10/kernel/kernel_version.py new file mode 100755 index 000000000..764bb2d33 --- /dev/null +++ b/chapter10/kernel/kernel_version.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +def kernel_version(path): + version = None + patchlevel = None + sublevel = None + + with open(path + 'Makefile') as f: + for line in f: + if line.startswith('VERSION ='): + version = line[len('VERSION ='):].strip() + elif line.startswith('PATCHLEVEL ='): + patchlevel = line[len('PATCHLEVEL ='):].strip() + elif line.startswith('SUBLEVEL ='): + sublevel = line[len('SUBLEVEL ='):].strip() + + assert(version and patchlevel and sublevel) + return '.'.join([version, patchlevel, sublevel]) + +if __name__ == '__main__': + from sys import argv + + path = argv[1] + if path[:-1] != '/': + path += '/' + + print(kernel_version(path)) diff --git a/chapter10/kernel/nvme.toml b/chapter10/kernel/nvme.toml new file mode 100644 index 000000000..1e3170fe9 --- /dev/null +++ b/chapter10/kernel/nvme.toml @@ -0,0 +1 @@ +BLK_DEV_NVME='*' diff --git a/chapter10/kernel/nvme.xml b/chapter10/kernel/nvme.xml new file mode 100644 index 000000000..2b55b7c1d --- /dev/null +++ b/chapter10/kernel/nvme.xml @@ -0,0 +1,8 @@ + + + +Device Drivers ---> + NVME Support ---> + <*> NVM Express block device [BLK_DEV_NVME] diff --git a/chapter10/kernel/systemd.toml b/chapter10/kernel/systemd.toml new file mode 100644 index 000000000..936c50492 --- /dev/null +++ b/chapter10/kernel/systemd.toml @@ -0,0 +1,30 @@ +# This part should be sync with sysv.toml +WERROR=' ' +PSI='*' +PSI_DEFAULT_DISABLED=' ' +IKHEADERS=' ' +CGROUPS='*' +MEMCG='*' +EXPERT=' ' +RELOCATABLE='*' +RANDOMIZE_BASE='*' +STACKPROTECTOR='*' +STACKPROTECTOR_STRONG='*' +UEVENT_HELPER=' ' +DEVTMPFS='*' +DEVTMPFS_MOUNT='*' +FB='*' +FRAMEBUFFER_CONSOLE='*' + +AUDIT=' ' +NET='*' +INET='*' +IPV6='*' +FW_LOADER=' *' +FW_LOADER_USER_HELPER='*' +DMIID='*' +INOTIFY_USER='*' +TMPFS='*' +TMPFS_POSIX_ACL='*' + +revision='systemd' diff --git a/chapter10/kernel/systemd.xml b/chapter10/kernel/systemd.xml new file mode 100644 index 000000000..0bbe1d42a --- /dev/null +++ b/chapter10/kernel/systemd.xml @@ -0,0 +1,48 @@ + + + +General setup ---> + [ ] Compile the kernel with warnings as errors [WERROR] + [ ] Auditing support [AUDIT] + CPU/Task time and stats accounting ---> + [*] Pressure stall information tracking [PSI] + [ ] Require boot parameter to enable pressure stall information tracking + ... [PSI_DEFAULT_DISABLED] + < > Enable kernel headers through /sys/kernel/kheaders.tar.xz [IKHEADERS] + [*] Control Group support ---> [CGROUPS] + [*] Memory controller [MEMCG] + [ ] Configure standard kernel features (expert users) ---> [EXPERT] +Processor type and features ---> + [*] Build a relocatable kernel [RELOCATABLE] + [*] Randomize the address of the kernel image (KASLR) [RANDOMIZE_BASE] +General architecture-dependent options ---> + [*] Stack Protector buffer overflow detection [STACKPROTECTOR] + [*] Strong Stack Protector [STACKPROTECTOR_STRONG] +[*] Networking support ---> [NET] + Networking options ---> + [*] TCP/IP networking [INET] + <*> The IPv6 protocol ---> [IPV6] +Device Drivers ---> + Generic Driver Options ---> + [ ] Support for uevent helper [UEVENT_HELPER] + [*] Maintain a devtmpfs filesystem to mount at /dev [DEVTMPFS] + [*] Automount devtmpfs at /dev, after the kernel mounted the rootfs + ... [DEVTMPFS_MOUNT] + Firmware loader ---> + < /*> Firmware loading facility [FW_LOADER] + [*] Enable the firmware sysfs fallback mechanism + ... [FW_LOADER_USER_HELPER] + Firmware Drivers ---> + [*] Export DMI identification via sysfs to userspace [DMIID] + Graphics support ---> + Frame buffer Devices ---> + <*> Support for frame buffer devices ---> [FB] + Console display driver support ---> + [*] Framebuffer Console support [FRAMEBUFFER_CONSOLE] +File systems ---> + [*] Inotify support for userspace [INOTIFY_USER] + Pseudo filesystems ---> + [*] Tmpfs virtual memory file system support (former shm fs) [TMPFS] + [*] Tmpfs POSIX Access Control Lists [TMPFS_POSIX_ACL] diff --git a/chapter10/kernel/sysv.toml b/chapter10/kernel/sysv.toml new file mode 100644 index 000000000..5c8b2df6e --- /dev/null +++ b/chapter10/kernel/sysv.toml @@ -0,0 +1,18 @@ +WERROR=' ' +PSI='*' +PSI_DEFAULT_DISABLED=' ' +IKHEADERS=' ' +CGROUPS='*' +MEMCG='*' +EXPERT=' ' +RELOCATABLE='*' +RANDOMIZE_BASE='*' +STACKPROTECTOR='*' +STACKPROTECTOR_STRONG='*' +UEVENT_HELPER=' ' +DEVTMPFS='*' +DEVTMPFS_MOUNT='*' +FB='*' +FRAMEBUFFER_CONSOLE='*' + +revision='sysv' diff --git a/chapter10/kernel/sysv.xml b/chapter10/kernel/sysv.xml new file mode 100644 index 000000000..7e615a56c --- /dev/null +++ b/chapter10/kernel/sysv.xml @@ -0,0 +1,32 @@ + + + +General setup ---> + [ ] Compile the kernel with warnings as errors [WERROR] + CPU/Task time and stats accounting ---> + [*] Pressure stall information tracking [PSI] + [ ] Require boot parameter to enable pressure stall information tracking + ... [PSI_DEFAULT_DISABLED] + < > Enable kernel headers through /sys/kernel/kheaders.tar.xz [IKHEADERS] + [*] Control Group support ---> [CGROUPS] + [*] Memory controller [MEMCG] + [ ] Configure standard kernel features (expert users) ---> [EXPERT] +Processor type and features ---> + [*] Build a relocatable kernel [RELOCATABLE] + [*] Randomize the address of the kernel image (KASLR) [RANDOMIZE_BASE] +General architecture-dependent options ---> + [*] Stack Protector buffer overflow detection [STACKPROTECTOR] + [*] Strong Stack Protector [STACKPROTECTOR_STRONG] +Device Drivers ---> + Generic Driver Options ---> + [ ] Support for uevent helper [UEVENT_HELPER] + [*] Maintain a devtmpfs filesystem to mount at /dev [DEVTMPFS] + [*] Automount devtmpfs at /dev, after the kernel mounted the rootfs + ... [DEVTMPFS_MOUNT] + Graphics support ---> + Frame buffer Devices ---> + <*> Support for frame buffer devices ---> [FB] + Console display driver support ---> + [*] Framebuffer Console support [FRAMEBUFFER_CONSOLE] diff --git a/chapter10/kernel/x2apic.toml b/chapter10/kernel/x2apic.toml new file mode 100644 index 000000000..6f7657b13 --- /dev/null +++ b/chapter10/kernel/x2apic.toml @@ -0,0 +1,5 @@ +X86_X2APIC='*' +PCI='*' +PCI_MSI='*' +IOMMU_SUPPORT='*' +IRQ_REMAP='*' diff --git a/chapter10/kernel/x2apic.xml b/chapter10/kernel/x2apic.xml new file mode 100644 index 000000000..4e4bd9571 --- /dev/null +++ b/chapter10/kernel/x2apic.xml @@ -0,0 +1,12 @@ + + + +Processor type and features ---> + [*] Support x2apic [X86_X2APIC] +Device Drivers ---> + [*] PCI support ---> [PCI] + [*] Message Signaled Interrupts (MSI and MSI-X) [PCI_MSI] + [*] IOMMU Hardware Support ---> [IOMMU_SUPPORT] + [*] Support for Interrupt Remapping [IRQ_REMAP] From 57499d5909d515e8e4d9bfab91c90350816e148c Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Tue, 1 Aug 2023 09:17:05 +0800 Subject: [PATCH 3/5] kernel: Separate toplevel menus in rendering --- chapter10/kernel/kernel-config.py | 7 ++++++- chapter10/kernel/systemd.xml | 5 +++++ chapter10/kernel/sysv.xml | 3 +++ chapter10/kernel/x2apic.xml | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/chapter10/kernel/kernel-config.py b/chapter10/kernel/kernel-config.py index 93b203a46..fc9bcc0d2 100755 --- a/chapter10/kernel/kernel-config.py +++ b/chapter10/kernel/kernel-config.py @@ -243,6 +243,8 @@ for i in known_config: if i not in done: raise Exception("%s seems not exist" % i) +sep = known_config.get('separate_toplevel_menu') + for i0, val, i1, title, arrow, key, menu, comment in r: rem = max_line @@ -275,7 +277,10 @@ for i0, val, i1, title, arrow, key, menu, comment in r: comment = [comment] if comment: comment = '\n'.join([' ' * i0 + '# ' + line for line in comment]) - line = escape(comment) + ':\n' + line + buf += escape(comment) + ':' + + if not menu and buf: + buf += [''] buf += [line.rstrip()] diff --git a/chapter10/kernel/systemd.xml b/chapter10/kernel/systemd.xml index 0bbe1d42a..4c57776c2 100644 --- a/chapter10/kernel/systemd.xml +++ b/chapter10/kernel/systemd.xml @@ -14,16 +14,20 @@ [*] Control Group support ---> [CGROUPS] [*] Memory controller [MEMCG] [ ] Configure standard kernel features (expert users) ---> [EXPERT] + Processor type and features ---> [*] Build a relocatable kernel [RELOCATABLE] [*] Randomize the address of the kernel image (KASLR) [RANDOMIZE_BASE] + General architecture-dependent options ---> [*] Stack Protector buffer overflow detection [STACKPROTECTOR] [*] Strong Stack Protector [STACKPROTECTOR_STRONG] + [*] Networking support ---> [NET] Networking options ---> [*] TCP/IP networking [INET] <*> The IPv6 protocol ---> [IPV6] + Device Drivers ---> Generic Driver Options ---> [ ] Support for uevent helper [UEVENT_HELPER] @@ -41,6 +45,7 @@ <*> Support for frame buffer devices ---> [FB] Console display driver support ---> [*] Framebuffer Console support [FRAMEBUFFER_CONSOLE] + File systems ---> [*] Inotify support for userspace [INOTIFY_USER] Pseudo filesystems ---> diff --git a/chapter10/kernel/sysv.xml b/chapter10/kernel/sysv.xml index 7e615a56c..7e62725e6 100644 --- a/chapter10/kernel/sysv.xml +++ b/chapter10/kernel/sysv.xml @@ -13,12 +13,15 @@ [*] Control Group support ---> [CGROUPS] [*] Memory controller [MEMCG] [ ] Configure standard kernel features (expert users) ---> [EXPERT] + Processor type and features ---> [*] Build a relocatable kernel [RELOCATABLE] [*] Randomize the address of the kernel image (KASLR) [RANDOMIZE_BASE] + General architecture-dependent options ---> [*] Stack Protector buffer overflow detection [STACKPROTECTOR] [*] Strong Stack Protector [STACKPROTECTOR_STRONG] + Device Drivers ---> Generic Driver Options ---> [ ] Support for uevent helper [UEVENT_HELPER] diff --git a/chapter10/kernel/x2apic.xml b/chapter10/kernel/x2apic.xml index 4e4bd9571..9bd2a719f 100644 --- a/chapter10/kernel/x2apic.xml +++ b/chapter10/kernel/x2apic.xml @@ -5,6 +5,7 @@ DO NOT EDIT! --> Processor type and features ---> [*] Support x2apic [X86_X2APIC] + Device Drivers ---> [*] PCI support ---> [PCI] [*] Message Signaled Interrupts (MSI and MSI-X) [PCI_MSI] From 3d99820133c0ffcd2f51a6a88b4a476f2f6d340a Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Tue, 1 Aug 2023 09:20:08 +0800 Subject: [PATCH 4/5] kernel: Fix a typo --- chapter10/kernel/kernel-config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter10/kernel/kernel-config.py b/chapter10/kernel/kernel-config.py index fc9bcc0d2..a36113175 100755 --- a/chapter10/kernel/kernel-config.py +++ b/chapter10/kernel/kernel-config.py @@ -277,7 +277,7 @@ for i0, val, i1, title, arrow, key, menu, comment in r: comment = [comment] if comment: comment = '\n'.join([' ' * i0 + '# ' + line for line in comment]) - buf += escape(comment) + ':' + buf += [escape(comment) + ':'] if not menu and buf: buf += [''] From be5b2e03fc6e7382f8c012d9fdb8e29a9bbbf17c Mon Sep 17 00:00:00 2001 From: Bruce Dubbs Date: Tue, 1 Aug 2023 13:52:22 -0500 Subject: [PATCH 5/5] Package updates: Update to vim-9.0.1677. Update to openssl-3.1.2. Update to man-pages-6.05. Update to binutils-2.41. Update to gmp-6.3.0. Update to glibc-2.38. --- chapter01/changelog.xml | 30 ++++++++++++++++++++++++++++++ chapter01/whatsnew.xml | 12 ++++++------ chapter06/diffutils.xml | 4 +++- chapter06/grep.xml | 5 +++-- chapter06/sed.xml | 5 +++-- chapter08/binutils.xml | 2 ++ chapter08/glibc.xml | 2 ++ chapter08/gmp.xml | 2 +- chapter08/stripping.xml | 2 +- packages.ent | 37 +++++++++++++++++++------------------ 10 files changed, 70 insertions(+), 31 deletions(-) diff --git a/chapter01/changelog.xml b/chapter01/changelog.xml index ac551a947..caf35cc90 100644 --- a/chapter01/changelog.xml +++ b/chapter01/changelog.xml @@ -40,6 +40,36 @@ appropriate for the entry or if needed the entire day's listitem. --> + + 2023-08-01 + + + [bdubbs] - Update to vim-9.0.1677. Addresses + #4500. + + + [bdubbs] - Update to openssl-3.1.2. Fixes + #5305. + + + [bdubbs] - Update to man-pages-6.05. Fixes + #5303. + + + [bdubbs] - Update to binutils-2.41. Fixes + #5300. + + + [bdubbs] - Update to gmp-6.3.0. Fixes + #5301. + + + [bdubbs] - Update to glibc-2.38. Fixes + #5302. + + + + 2023-07-28 diff --git a/chapter01/whatsnew.xml b/chapter01/whatsnew.xml index f40d3b33a..a2e7823da 100644 --- a/chapter01/whatsnew.xml +++ b/chapter01/whatsnew.xml @@ -64,9 +64,9 @@ Bc &bc-version; - + @@ -124,12 +124,12 @@ Gettext-&gettext-version; - - + diff --git a/chapter06/diffutils.xml b/chapter06/diffutils.xml index af4d95429..d2b875a9d 100644 --- a/chapter06/diffutils.xml +++ b/chapter06/diffutils.xml @@ -45,7 +45,9 @@ Prepare Diffutils for compilation: -./configure --prefix=/usr --host=$LFS_TGT + ./configure --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(./build-aux/config.guess) Compile the package: diff --git a/chapter06/grep.xml b/chapter06/grep.xml index 1bccd7486..dd942c712 100644 --- a/chapter06/grep.xml +++ b/chapter06/grep.xml @@ -45,8 +45,9 @@ Prepare Grep for compilation: -./configure --prefix=/usr \ - --host=$LFS_TGT + ./configure --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(./build-aux/config.guess) Compile the package: diff --git a/chapter06/sed.xml b/chapter06/sed.xml index b3e39c215..b297afedd 100644 --- a/chapter06/sed.xml +++ b/chapter06/sed.xml @@ -45,8 +45,9 @@ Prepare Sed for compilation: -./configure --prefix=/usr \ - --host=$LFS_TGT + ./configure --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(./build-aux/config.guess) Compile the package: diff --git a/chapter08/binutils.xml b/chapter08/binutils.xml index cf1c4f895..c35bf136e 100644 --- a/chapter08/binutils.xml +++ b/chapter08/binutils.xml @@ -145,6 +145,8 @@ cd build and options are passed to GCC. + Three tests in the gprofng suite are also known to fail. + Install the package: make tooldir=/usr install diff --git a/chapter08/glibc.xml b/chapter08/glibc.xml index 4245b0ff4..a1f23a96b 100644 --- a/chapter08/glibc.xml +++ b/chapter08/glibc.xml @@ -166,10 +166,12 @@ esac is known to fail in the LFS chroot environment. + diff --git a/chapter08/gmp.xml b/chapter08/gmp.xml index 01dace92f..05e16722a 100644 --- a/chapter08/gmp.xml +++ b/chapter08/gmp.xml @@ -110,7 +110,7 @@ make html instruction". In this case, gmp should be reconfigured with the option and rebuilt. - Ensure that all 197 tests in the test suite passed. + Ensure that all 199 tests in the test suite passed. Check the results by issuing the following command: awk '/# PASS:/{total+=$3} ; END{print total}' gmp-check-log diff --git a/chapter08/stripping.xml b/chapter08/stripping.xml index 70e0d6ebb..9e71f4382 100644 --- a/chapter08/stripping.xml +++ b/chapter08/stripping.xml @@ -88,7 +88,7 @@ done online_usrbin="bash find strip" online_usrlib="libbfd-&binutils-version;.so - libsframe.so.0.0.0 + libsframe.so.&libsframe-version; libhistory.so.&readline-soversion; libncursesw.so.&ncurses-version; libm.so.6 diff --git a/packages.ent b/packages.ent index 66e7314ab..ac08d20a8 100644 --- a/packages.ent +++ b/packages.ent @@ -66,10 +66,10 @@ - - + + - + @@ -77,6 +77,7 @@ + @@ -256,20 +257,20 @@ - - + + - + - - + + - + @@ -477,10 +478,10 @@ - - + + - + @@ -535,10 +536,10 @@ - - + + - + @@ -726,13 +727,13 @@ - + - + - +