Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/ukprint: Introduce libukprint #1527

Open
wants to merge 19 commits into
base: staging
Choose a base branch
from

Conversation

michpappas
Copy link
Member

@michpappas michpappas commented Oct 21, 2024

Prerequisite checklist

  • Read the contribution guidelines regarding submitting new changes to the project;
  • Tested your changes against relevant architectures and platforms;
  • Ran the checkpatch.uk on your commit series before opening this PR;
  • Updated relevant documentation.

Base target

  • Architecture(s): [N/A]
  • Platform(s): [N/A]
  • Application(s): [N/A]

Additional configuration

Description of changes

This series introduces libukprint that is entasked to handle all printing and logging facilities. The changes are summarized below:

  • libukdebug/asmdump is deprecated, as it relies on zydis, and effectively was never used.
  • The implementation of the uk_printk() API and the uk_pr_ helpers are migrated from libukdebug into the newly introduced libukprint.
  • Debug printing is now done via a new uk_printk() severity level, UK_PRINT_KLVL_DEBUG. uk_printd() and console redirection are deprecated. The uk_pr_debug() helper is implemented by a call to uk_printk() with UK_PRINT_KLVL_DEBUG. The functionality of enabling debug prints on individual files by defining UK_DEBUG remains unchanged.
  • The uk_printk() API is further enhanced with features that allow raw and unconditional printing. Raw printing does not prepend output with metadata and is implemented by a new flag, UK_PRINT_RAW. Unconditional printing implements messages that appear regardless of the configured severity level and is implemented by a new pseudo-severity flag UK_PRINT_KLVL_NONE. These features are useful for use-cases of the syscall_shim and uktest.
  • ukstore entries are added to libukprint to allow derive and update the severity level at runtime. These can later be used to implement control via /proc/sys/kernel/printk.
  • Introduce logbuffer support. This provides dmesg functionality to Unikraft via the newly introduced uk_print_dmesg(). The logbuffer can be enabled independently of the kernel console.
  • Headers of libukprint are always included in the build. This formalizes convention that calls to kernel printing facilities from various libraries do not need to be conditionally compiled. Moreover, libraries do not need to select LIBUKPRINT in their Config.uk.
  • Various updates on depending libraries.

asmdump is implemented using zydis which is not part of unikraft,
so all asmdump calls are stubbed out.

Signed-off-by: Michalis Pappas <[email protected]>
With asmdump removed from libukdebug, remove references
from plat/

Signed-off-by: Michalis Pappas <[email protected]>
Introduce libukprint for printing and logging facilities, and migrate
printing code from ukdebug.

Signed-off-by: Michalis Pappas <[email protected]>
Update imported sources to match coding conventions.

Checkpatch-Ignore: LONG_LINE
Signed-off-by: Michalis Pappas <[email protected]>
Replace uk_printd() functions with a new UK_PRINT_KLVL severity for
uk_printk(). The uk_pr_debug() helper now invokes uk_printk() with
UK_PRINT_KLVL_DEBUG.

This also obsoletes output redirection (CONFIG_LIBUKPRINT_REDIR).

The behavior of printing debug messages when defining UK_DEBUG
regardless of the configured severity is preserved, provided that
LIBUKPRINT_PRINTK is selected.

Checkpatch-Ignore: MACRO_ARG_REUSE
Signed-off-by: Michalis Pappas <[email protected]>
Add UK_PRINT_RAW flag that causes uk_printk() functions to print
without prepending output with metadata.

Add UK_PRINT_KLVL_NONE pseudo-severity level that instructs the
uk_printk() functions to print unconditionally of the configured
severity.

Checkpatch-Ignore: MACRO_ARG_REUSE
Checkpatch-Ignore: LONG_LINE
Signed-off-by: Michalis Pappas <[email protected]>
@github-actions github-actions bot added arch/arm arch/arm64 arch/x86_64 area/arch Unikraft Architecture area/lib Internal Unikraft Microlibrary area/plat Unikraft Patform lang/c Issues or PRs to do with C/C++ lib/nolibc Only neccessary subset of libc functionality lib/syscall_shim lib/ukdebug plat/common Common to all platforms labels Oct 21, 2024
@michpappas
Copy link
Member Author

michpappas commented Oct 21, 2024

TBD:

  • Add cmdline control.
  • Verbosity controlled via cmdline / ukstore is bound to UK_PRINT_KLVL_MAX. Normally it is useful to increase verbosity for investigation.
  • Runtime controlled verbosity works as expected if UK_DEBUG is not set.
  • Finalize uktest / syscall_shim flags.
  • Document required Kconfig changes in Kraftfile (if any)

Decouple console-specific logic and introduce logbuffer. The logbuffer
is implemented as a circular buffer of variable sized objects.

At Kconfig the kernel console messages can be controlled individually
of the logbuffer. The verbosity option controls both kernel console
mesasges and messages logged into the logbuffer. Reorganize Kconfig
options to reflect this separation.

The logbuffer can be printed into the console by the newly introduced
function uk_print_dmesg().

Checkpatch-Ignore: COMPLEX_MACRO
Checkpatch-Ignore: SPACING
Checkpatch-Ignore: LONG_LINE
Signed-off-by: Michalis Pappas <[email protected]>
This formalizes the convention that the kernel printing facilities do
not need to be conditionally compiled. Moreover, libraries don't need
to select libukprint in their config files.

Checkpatch-Ignore: LINE_SPACING
Signed-off-by: Michalis Pappas <[email protected]>
Provide a static ukstore entry to control the console level at runtime.
The loglevel values used are defined by UK_PRINT_KLVL in print.h.

Notice that the loglevel can be set via ukstore to a value less or equal
to the max loglevel set in Kconfig.

Signed-off-by: Michalis Pappas <[email protected]>
Update libukprint header includes. Replace hexdumpCd() with
hexcumpCk(UK_PRINT_KLVL_DEBUG).

Signed-off-by: Michalis Pappas <[email protected]>
Update libukprint header includes and references to printk flags.
Replace hexdumpCd() with hexcumpCk(UK_PRINT_KLVL_DEBUG).

Checkpatch-Ignore: CAMELCASE
Signed-off-by: Michalis Pappas <[email protected]>
Update libukprint header includes.

Signed-off-by: Michalis Pappas <[email protected]>
Update libukprint header includes.

Signed-off-by: Michalis Pappas <[email protected]>
Update references to printk flags.

Signed-off-by: Michalis Pappas <[email protected]>
Update references to printk flags.

Signed-off-by: Michalis Pappas <[email protected]>
Update references to printk flags.

Signed-off-by: Michalis Pappas <[email protected]>
Update printk flags. Print messages with UK_PRINT_KLVL_NONE.

Signed-off-by: Michalis Pappas <[email protected]>
Map LOG_DEBUG syslog severity to UK_PRINT_KLVL_DEBUG and
invoke uk_printk() similarly to the rest of severities.

Signed-off-by: Michalis Pappas <[email protected]>
Update __UK_SYSCALL_PRINTD and __UK_SYSCALL_EXECENV_PRINTD
to use uk_printk() instead of uk_printd().

Repalce direct calls to uk_console with uk_printk() using
UK_PRINT_FLAGS_RAW.

Checkpatch-Ignore: MULTISTATEMENT_MACRO_USE_DO_WHILE
Checkpatch-Ignore: MACRO_ARG_REUSE
Signed-off-by: Michalis Pappas <[email protected]>
michpappas added a commit to michpappas/unikraft that referenced this pull request Nov 5, 2024
Introduce libukprint

Checkpatch-Ignore: LONG_LINE
Checkpatch-Ignore: COMPLEX_MACRO
Checkpatch-Ignore: SPACING
Checkpatch-Ignore: LINE_SPACING
Checkpatch-Ignore: CAMELCASE
Checkpatch-Ignore: MULTISTATEMENT_MACRO_USE_DO_WHILE
Checkpatch-Ignore: MACRO_ARG_REUSE
Signed-off-by: Michalis Pappas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch/arm arch/arm64 arch/x86_64 area/arch Unikraft Architecture area/lib Internal Unikraft Microlibrary area/plat Unikraft Patform lang/c Issues or PRs to do with C/C++ lib/nolibc Only neccessary subset of libc functionality lib/syscall_shim lib/ukdebug plat/common Common to all platforms
Projects
Status: 🧊 Icebox
Development

Successfully merging this pull request may close these issues.

1 participant