[PATCH v2] arm64: Add purgatory printing
Simon Horman
horms at verge.net.au
Tue Sep 29 12:20:42 EDT 2020
On Wed, Sep 23, 2020 at 12:48:02PM +0200, matthias.bgg at kernel.org wrote:
> From: Matthias Brugger <mbrugger at suse.com>
>
> Add option to allow purgatory printing on arm64 hardware
> by passing the console name which should be used.
> Based on a patch by Geoff Levand.
>
> Cc: Geoff Levand <geoff at infradead.org>
> Signed-off-by: Matthias Brugger <mbrugger at suse.com>
...
> +/**
> + * find_purgatory_sink - Find a sink for purgatory output.
> + */
> +
> +static uint64_t find_purgatory_sink(const char *console)
> +{
> + int fd, ret;
> + char device[255], mem[255];
> + struct stat sb;
> + char buffer[10];
> + uint64_t iomem = 0x0;
> +
> + if (!console)
> + return 0;
> +
> + snprintf(device, sizeof(device), "/sys/class/tty/%s", console);
> + if (stat(device, &sb) || !S_ISDIR(sb.st_mode)) {
> + fprintf(stderr, "kexec: %s: No valid console found for %s\n",
> + __func__, device);
> + return 0;
> + }
As per "[PATCH] kexec: Fix snprintf related compilation warning",
I think we should be checking the output of snprintf.
> +
> + snprintf(mem, sizeof(mem), "%s%s", device, "/iomem_base");
> + printf("console memory read from %s\n", mem);
> +
> + fd = open(mem, O_RDONLY);
> + if (fd < 0) {
> + fprintf(stderr, "kexec: %s: No able to open %s\n",
> + __func__, mem);
> + return 0;
> + }
...
More information about the kexec
mailing list