Commit 91ad64a8 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull tracing and bootconfig updates:
 "Fixes and changes to bootconfig before it goes live in a release.

  Change in API of bootconfig (before it comes live in a release):
  - Have a magic value "BOOTCONFIG" in initrd to know a bootconfig
    exists
  - Set CONFIG_BOOT_CONFIG to 'n' by default
  - Show error if "bootconfig" on cmdline but not compiled in
  - Prevent redefining the same value
  - Have a way to append values
  - Added a SELECT BLK_DEV_INITRD to fix a build failure

  Synthetic event fixes:
  - Switch to raw_smp_processor_id() for recording CPU value in preempt
    section. (No care for what the value actually is)
  - Fix samples always recording u64 values
  - Fix endianess
  - Check number of values matches number of fields
  - Fix a printing bug

  Fix of trace_printk() breaking postponed start up tests

  Make a function static that is only used in a single file"

* tag 'trace-v5.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  bootconfig: Fix CONFIG_BOOTTIME_TRACING dependency issue
  bootconfig: Add append value operator support
  bootconfig: Prohibit re-defining value on same key
  bootconfig: Print array as multiple commands for legacy command line
  bootconfig: Reject subkey and value on same parent key
  tools/bootconfig: Remove unneeded error message silencer
  bootconfig: Add bootconfig magic word for indicating bootconfig explicitly
  bootconfig: Set CONFIG_BOOT_CONFIG=n by default
  tracing: Clear trace_state when starting trace
  bootconfig: Mark boot_config_checksum() static
  tracing: Disable trace_printk() on post poned tests
  tracing: Have synthetic event test use raw_smp_processor_id()
  tracing: Fix number printing bug in print_synth_event()
  tracing: Check that number of vals matches number of synth event fields
  tracing: Make synth_event trace functions endian-correct
  tracing: Make sure synth_event_trace() example always uses u64
parents b98cce1e 2910b5aa
Loading
Loading
Loading
Loading
+31 −3
Original line number Diff line number Diff line
@@ -62,6 +62,30 @@ Or more shorter, written as following::
In both styles, same key words are automatically merged when parsing it
at boot time. So you can append similar trees or key-values.

Same-key Values
---------------

It is prohibited that two or more values or arrays share a same-key.
For example,::

 foo = bar, baz
 foo = qux  # !ERROR! we can not re-define same key

If you want to append the value to existing key as an array member,
you can use ``+=`` operator. For example::

 foo = bar, baz
 foo += qux

In this case, the key ``foo`` has ``bar``, ``baz`` and ``qux``.

However, a sub-key and a value can not co-exist under a parent key.
For example, following config is NOT allowed.::

 foo = value1
 foo.bar = value2 # !ERROR! subkey "bar" and value "value1" can NOT co-exist


Comments
--------

@@ -102,9 +126,13 @@ Boot Kernel With a Boot Config
==============================

Since the boot configuration file is loaded with initrd, it will be added
to the end of the initrd (initramfs) image file. The Linux kernel decodes
the last part of the initrd image in memory to get the boot configuration
data.
to the end of the initrd (initramfs) image file with size, checksum and
12-byte magic word as below.

[initrd][bootconfig][size(u32)][checksum(u32)][#BOOTCONFIG\n]

The Linux kernel decodes the last part of the initrd image in memory to
get the boot configuration data.
Because of this "piggyback" method, there is no need to change or
update the boot loader and the kernel image itself.

+3 −0
Original line number Diff line number Diff line
@@ -10,6 +10,9 @@
#include <linux/kernel.h>
#include <linux/types.h>

#define BOOTCONFIG_MAGIC	"#BOOTCONFIG\n"
#define BOOTCONFIG_MAGIC_LEN	12

/* XBC tree node */
struct xbc_node {
	u16 next;
+2 −3
Original line number Diff line number Diff line
@@ -1226,13 +1226,12 @@ endif

config BOOT_CONFIG
	bool "Boot config support"
	depends on BLK_DEV_INITRD
	default y
	select BLK_DEV_INITRD
	help
	  Extra boot config allows system admin to pass a config file as
	  complemental extension of kernel cmdline when booting.
	  The boot config file must be attached at the end of initramfs
	  with checksum and size.
	  with checksum, size and magic word.
	  See <file:Documentation/admin-guide/bootconfig.rst> for details.

	  If unsure, say Y.
+22 −16
Original line number Diff line number Diff line
@@ -268,7 +268,6 @@ static int __init xbc_snprint_cmdline(char *buf, size_t size,
{
	struct xbc_node *knode, *vnode;
	char *end = buf + size;
	char c = '\"';
	const char *val;
	int ret;

@@ -279,25 +278,20 @@ static int __init xbc_snprint_cmdline(char *buf, size_t size,
			return ret;

		vnode = xbc_node_get_child(knode);
		ret = snprintf(buf, rest(buf, end), "%s%c", xbc_namebuf,
				vnode ? '=' : ' ');
		if (!vnode) {
			ret = snprintf(buf, rest(buf, end), "%s ", xbc_namebuf);
			if (ret < 0)
				return ret;
			buf += ret;
		if (!vnode)
			continue;

		c = '\"';
		}
		xbc_array_for_each_value(vnode, val) {
			ret = snprintf(buf, rest(buf, end), "%c%s", c, val);
			ret = snprintf(buf, rest(buf, end), "%s=\"%s\" ",
				       xbc_namebuf, val);
			if (ret < 0)
				return ret;
			buf += ret;
			c = ',';
		}
		if (rest(buf, end) > 2)
			strcpy(buf, "\" ");
		buf += 2;
	}

	return buf - (end - size);
@@ -335,7 +329,7 @@ static char * __init xbc_make_cmdline(const char *key)
	return new_cmdline;
}

u32 boot_config_checksum(unsigned char *p, u32 size)
static u32 boot_config_checksum(unsigned char *p, u32 size)
{
	u32 ret = 0;

@@ -374,7 +368,11 @@ static void __init setup_boot_config(const char *cmdline)
	if (!initrd_end)
		goto not_found;

	hdr = (u32 *)(initrd_end - 8);
	data = (char *)initrd_end - BOOTCONFIG_MAGIC_LEN;
	if (memcmp(data, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN))
		goto not_found;

	hdr = (u32 *)(data - 8);
	size = hdr[0];
	csum = hdr[1];

@@ -418,6 +416,14 @@ not_found:
}
#else
#define setup_boot_config(cmdline)	do { } while (0)

static int __init warn_bootconfig(char *str)
{
	pr_warn("WARNING: 'bootconfig' found on the kernel command line but CONFIG_BOOTCONFIG is not set.\n");
	return 0;
}
early_param("bootconfig", warn_bootconfig);

#endif

/* Change NUL term back to "=", to make "param" the whole string. */
+2 −2
Original line number Diff line number Diff line
@@ -143,8 +143,8 @@ if FTRACE

config BOOTTIME_TRACING
	bool "Boot-time Tracing support"
	depends on BOOT_CONFIG && TRACING
	default y
	depends on TRACING
	select BOOT_CONFIG
	help
	  Enable developer to setup ftrace subsystem via supplemental
	  kernel cmdline at boot time for debugging (tracing) driver
Loading