diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index 24d33d5..25060bb 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -16,6 +16,8 @@
 CFLAGS_REMOVE_boothart.o := $(CFLAGS_NON_EFI)
 CFLAGS_helloworld.o := $(CFLAGS_EFI) -Os -ffreestanding
 CFLAGS_REMOVE_helloworld.o := $(CFLAGS_NON_EFI)
+CFLAGS_smbiosdump.o := $(CFLAGS_EFI) -Os -ffreestanding
+CFLAGS_REMOVE_smbiosdump.o := $(CFLAGS_NON_EFI)
 CFLAGS_dtbdump.o := $(CFLAGS_EFI) -Os -ffreestanding
 CFLAGS_REMOVE_dtbdump.o := $(CFLAGS_NON_EFI)
 CFLAGS_initrddump.o := $(CFLAGS_EFI) -Os -ffreestanding
@@ -31,6 +33,11 @@
 targets += helloworld.o
 endif
 
+ifneq ($(CONFIG_GENERATE_SMBIOS_TABLE),)
+always += smbiosdump.efi
+targets += smbiosdump.o
+endif
+
 ifeq ($(CONFIG_GENERATE_ACPI_TABLE),)
 always += dtbdump.efi
 targets += dtbdump.o
diff --git a/lib/efi_loader/smbiosdump.c b/lib/efi_loader/smbiosdump.c
new file mode 100644
index 0000000..f0b9018
--- /dev/null
+++ b/lib/efi_loader/smbiosdump.c
@@ -0,0 +1,622 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2023, Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
+ *
+ * smbiosdump.efi saves the SMBIOS table as file.
+ *
+ * Specifying 'nocolor' as load option data suppresses colored output and
+ * clearing of the screen.
+ */
+
+#include <efi_api.h>
+#include <part.h>
+#include <smbios.h>
+#include <string.h>
+
+#define BUFFER_SIZE 64
+
+static struct efi_simple_text_output_protocol *cerr;
+static struct efi_simple_text_output_protocol *cout;
+static struct efi_simple_text_input_protocol *cin;
+static struct efi_boot_services *bs;
+static efi_handle_t handle;
+static struct efi_system_table *systable;
+static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID;
+static const efi_guid_t smbios3_guid = SMBIOS3_TABLE_GUID;
+static const efi_guid_t loaded_image_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
+static const efi_guid_t guid_simple_file_system_protocol =
+					EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
+static const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID;
+static bool nocolor;
+
+/**
+ * color() - set foreground color
+ *
+ * @color:	foreground color
+ */
+static void color(u8 color)
+{
+	if (!nocolor)
+		cout->set_attribute(cout, color | EFI_BACKGROUND_BLACK);
+}
+
+/**
+ * print() - print string
+ *
+ * @string:	text
+ */
+static void print(u16 *string)
+{
+	cout->output_string(cout, string);
+}
+
+/**
+ * cls() - clear screen
+ */
+static void cls(void)
+{
+	if (nocolor)
+		print(u"\r\n");
+	else
+		cout->clear_screen(cout);
+}
+
+/**
+ * error() - print error string
+ *
+ * @string:	error text
+ */
+static void error(u16 *string)
+{
+	color(EFI_LIGHTRED);
+	print(string);
+	color(EFI_LIGHTBLUE);
+}
+
+/**
+ * efi_input_yn() - get answer to yes/no question
+ *
+ * Return:
+ * y or Y
+ *     EFI_SUCCESS
+ * n or N
+ *     EFI_ACCESS_DENIED
+ * ESC
+ *     EFI_ABORTED
+ */
+static efi_status_t efi_input_yn(void)
+{
+	struct efi_input_key key = {0};
+	efi_uintn_t index;
+	efi_status_t ret;
+
+	/* Drain the console input */
+	ret = cin->reset(cin, true);
+	for (;;) {
+		ret = bs->wait_for_event(1, &cin->wait_for_key, &index);
+		if (ret != EFI_SUCCESS)
+			continue;
+		ret = cin->read_key_stroke(cin, &key);
+		if (ret != EFI_SUCCESS)
+			continue;
+		switch (key.scan_code) {
+		case 0x17: /* Escape */
+			return EFI_ABORTED;
+		default:
+			break;
+		}
+		/* Convert to lower case */
+		switch (key.unicode_char | 0x20) {
+		case 'y':
+			return EFI_SUCCESS;
+		case 'n':
+			return EFI_ACCESS_DENIED;
+		default:
+			break;
+		}
+	}
+}
+
+/**
+ * efi_input() - read string from console
+ *
+ * @buffer:		input buffer
+ * @buffer_size:	buffer size
+ * Return:		status code
+ */
+static efi_status_t efi_input(u16 *buffer, efi_uintn_t buffer_size)
+{
+	struct efi_input_key key = {0};
+	efi_uintn_t index;
+	efi_uintn_t pos = 0;
+	u16 outbuf[2] = u" ";
+	efi_status_t ret;
+
+	/* Drain the console input */
+	ret = cin->reset(cin, true);
+	*buffer = 0;
+	for (;;) {
+		ret = bs->wait_for_event(1, &cin->wait_for_key, &index);
+		if (ret != EFI_SUCCESS)
+			continue;
+		ret = cin->read_key_stroke(cin, &key);
+		if (ret != EFI_SUCCESS)
+			continue;
+		switch (key.scan_code) {
+		case 0x17: /* Escape */
+			print(u"\r\nAborted\r\n");
+			return EFI_ABORTED;
+		default:
+			break;
+		}
+		switch (key.unicode_char) {
+		case 0x08: /* Backspace */
+			if (pos) {
+				buffer[pos--] = 0;
+				print(u"\b \b");
+			}
+			break;
+		case 0x0a: /* Linefeed */
+		case 0x0d: /* Carriage return */
+			print(u"\r\n");
+			return EFI_SUCCESS;
+		default:
+			break;
+		}
+		/* Ignore surrogate codes */
+		if (key.unicode_char >= 0xD800 && key.unicode_char <= 0xDBFF)
+			continue;
+		if (key.unicode_char >= 0x20 &&
+		    pos < buffer_size - 1) {
+			*outbuf = key.unicode_char;
+			buffer[pos++] = key.unicode_char;
+			buffer[pos] = 0;
+			print(outbuf);
+		}
+	}
+}
+
+/**
+ * skip_whitespace() - skip over leading whitespace
+ *
+ * @pos:	UTF-16 string
+ * Return:	pointer to first non-whitespace
+ */
+static u16 *skip_whitespace(u16 *pos)
+{
+	for (; *pos && *pos <= 0x20; ++pos)
+		;
+	return pos;
+}
+
+/**
+ * starts_with() - check if @string starts with @keyword
+ *
+ * @string:	string to search for keyword
+ * @keyword:	keyword to be searched
+ * Return:	true fi @string starts with the keyword
+ */
+static bool starts_with(u16 *string, u16 *keyword)
+{
+	if (!string || !keyword)
+		return NULL;
+
+	for (; *keyword; ++string, ++keyword) {
+		if (*string != *keyword)
+			return false;
+	}
+	return true;
+}
+
+/**
+ * open_file_system() - open simple file system protocol
+ *
+ * file_system:	interface of the simple file system protocol
+ * Return:	status code
+ */
+static efi_status_t
+open_file_system(struct efi_simple_file_system_protocol **file_system)
+{
+	struct efi_loaded_image *loaded_image;
+	efi_status_t ret;
+	efi_handle_t *handle_buffer = NULL;
+	efi_uintn_t count;
+
+	ret = bs->open_protocol(handle, &loaded_image_guid,
+				(void **)&loaded_image, NULL, NULL,
+				EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+	if (ret != EFI_SUCCESS) {
+		error(u"Loaded image protocol not found\r\n");
+		return ret;
+	}
+
+	/* Open the simple file system protocol on the same partition */
+	ret = bs->open_protocol(loaded_image->device_handle,
+				&guid_simple_file_system_protocol,
+				(void **)file_system, NULL, NULL,
+				EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+	if (ret == EFI_SUCCESS)
+		return ret;
+
+	/* Open the simple file system protocol on the UEFI system partition */
+	ret = bs->locate_handle_buffer(BY_PROTOCOL, &efi_system_partition_guid,
+				       NULL, &count, &handle_buffer);
+	if (ret == EFI_SUCCESS && handle_buffer)
+		ret = bs->open_protocol(handle_buffer[0],
+					&guid_simple_file_system_protocol,
+					(void **)file_system, NULL, NULL,
+					EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+	if (ret != EFI_SUCCESS)
+		error(u"Failed to open simple file system protocol\r\n");
+	if (handle)
+		bs->free_pool(handle_buffer);
+
+	return ret;
+}
+
+/**
+ * do_help() - print help
+ */
+static void do_help(void)
+{
+	error(u"check       - check SMBIOS table\r\n");
+	error(u"save <file> - save SMBIOS table to file\r\n");
+	error(u"exit        - exit the shell\r\n");
+}
+
+/**
+ * get_config_table() - get configuration table
+ *
+ * @guid:	GUID of the configuration table
+ * Return:	pointer to configuration table or NULL
+ */
+static void *get_config_table(const efi_guid_t *guid)
+{
+	size_t i;
+
+	for (i = 0; i < systable->nr_tables; ++i) {
+		if (!memcmp(guid, &systable->tables[i].guid, 16))
+			return systable->tables[i].table;
+	}
+
+	return NULL;
+}
+
+/**
+ * checksum() - calculate checksum
+ *
+ * @buf:	buffer to checksum
+ * @len:	length of buffer
+ * Return:	checksum
+ */
+u8 checksum(void *buf, int len)
+{
+	u8 ret = 0;
+
+	for (u8 *ptr = buf; len; --len, ++ptr)
+		ret -= *ptr;
+
+	return ret;
+}
+
+/**
+ * do_check() - check SMBIOS table
+ *
+ * Return:	status code
+ */
+efi_status_t do_check(void)
+{
+	struct smbios3_entry *smbios3_anchor;
+	void *table, *table_end;
+	u32 len;
+
+	smbios3_anchor = get_config_table(&smbios3_guid);
+	if (smbios3_anchor) {
+		int r;
+
+		r = memcmp(smbios3_anchor->anchor, "_SM3_", 5);
+		if (r) {
+			error(u"Invalid anchor string\n");
+			return EFI_LOAD_ERROR;
+		}
+		print(u"Found SMBIOS 3 entry point\n");
+		if (smbios3_anchor->length != 0x18) {
+			error(u"Invalid anchor length\n");
+			return EFI_LOAD_ERROR;
+		}
+		if (checksum(smbios3_anchor, smbios3_anchor->length)) {
+			error(u"Invalid anchor checksum\n");
+			return EFI_LOAD_ERROR;
+		}
+		table = (void *)(uintptr_t)smbios3_anchor->struct_table_address;
+		len = smbios3_anchor->max_struct_size;
+	} else {
+		struct smbios_entry *smbios_anchor;
+		int r;
+
+		smbios_anchor = get_config_table(&smbios_guid);
+		if (!smbios_anchor) {
+			error(u"No SMBIOS table\n");
+			return EFI_NOT_FOUND;
+		}
+		r = memcmp(smbios_anchor->anchor, "_SM_", 4);
+		if (r) {
+			error(u"Invalid anchor string\n");
+			return EFI_LOAD_ERROR;
+		}
+		print(u"Found SMBIOS 2.1 entry point\n");
+		if (smbios_anchor->length != 0x1f) {
+			error(u"Invalid anchor length\n");
+			return EFI_LOAD_ERROR;
+		}
+		if (checksum(smbios_anchor, smbios_anchor->length)) {
+			error(u"Invalid anchor checksum\n");
+			return EFI_LOAD_ERROR;
+		}
+		r = memcmp(smbios_anchor->intermediate_anchor, "_DMI_", 5);
+		if (r) {
+			error(u"Invalid intermediate anchor string\n");
+			return EFI_LOAD_ERROR;
+		}
+		if (checksum(&smbios_anchor->intermediate_anchor, 0xf)) {
+			error(u"Invalid intermediate anchor checksum\n");
+			return EFI_LOAD_ERROR;
+		}
+		table = (void *)(uintptr_t)smbios_anchor->struct_table_address;
+		len = smbios_anchor->struct_table_length;
+	}
+
+	table_end = (void *)((u8 *)table + len);
+	for (struct smbios_header *pos = table; ;) {
+		u8 *str = (u8 *)pos + pos->length;
+
+		if (!*str)
+			++str;
+		while (*str) {
+			for (; *str; ++str) {
+				if ((void *)str >= table_end) {
+					error(u"Structure table length exceeded\n");
+					return EFI_LOAD_ERROR;
+				}
+			}
+			++str;
+		}
+		++str;
+		if ((void *)str > table_end) {
+			error(u"Structure table length exceeded\n");
+			return EFI_LOAD_ERROR;
+		}
+		if (pos->type == 0x7f) /* End of table */
+			break;
+		pos = (struct smbios_header *)str;
+	}
+
+	return EFI_SUCCESS;
+}
+
+/**
+ * save_file() - save file to EFI system partition
+ *
+ * @filename:	file name
+ * @buf:	buffer to write
+ * @size:	size of the buffer
+ */
+efi_status_t save_file(u16 *filename, void *buf, efi_uintn_t size)
+{
+	efi_uintn_t ret;
+	struct efi_simple_file_system_protocol *file_system;
+	struct efi_file_handle *root, *file;
+
+	ret = open_file_system(&file_system);
+	if (ret != EFI_SUCCESS)
+		return ret;
+
+	/* Open volume */
+	ret = file_system->open_volume(file_system, &root);
+	if (ret != EFI_SUCCESS) {
+		error(u"Failed to open volume\r\n");
+		return ret;
+	}
+	/* Check if file already exists */
+	ret = root->open(root, &file, filename, EFI_FILE_MODE_READ, 0);
+	if (ret == EFI_SUCCESS) {
+		file->close(file);
+		print(u"Overwrite existing file (y/n)? ");
+		ret = efi_input_yn();
+		print(u"\r\n");
+		if (ret != EFI_SUCCESS) {
+			root->close(root);
+			error(u"Aborted by user\r\n");
+			bs->free_pool(buf);
+			return ret;
+		}
+	}
+
+	/* Create file */
+	ret = root->open(root, &file, filename,
+			 EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE |
+			 EFI_FILE_MODE_CREATE, EFI_FILE_ARCHIVE);
+	if (ret == EFI_SUCCESS) {
+		/* Write file */
+		ret = file->write(file, &size, buf);
+		if (ret != EFI_SUCCESS)
+			error(u"Failed to write file\r\n");
+		file->close(file);
+	} else {
+		error(u"Failed to open file\r\n");
+	}
+	root->close(root);
+
+	return ret;
+}
+
+/**
+ * do_save() - save SMBIOS table
+ *
+ * @filename:	file name
+ * Return:	status code
+ */
+static efi_status_t do_save(u16 *filename)
+{
+	struct smbios3_entry *smbios3_anchor;
+	u8 *buf;
+	efi_uintn_t size;
+	efi_uintn_t ret;
+
+	ret = do_check();
+	if (ret != EFI_SUCCESS)
+		return ret;
+
+	smbios3_anchor = get_config_table(&smbios3_guid);
+	if (smbios3_anchor) {
+		size = 0x20 + smbios3_anchor->max_struct_size;
+		ret = bs->allocate_pool(EFI_LOADER_DATA, size, (void **)&buf);
+		if (ret != EFI_SUCCESS) {
+			error(u"Out of memory\n");
+			return ret;
+		}
+
+		memset(buf, 0, size);
+		memcpy(buf, smbios3_anchor, smbios3_anchor->length);
+		memcpy(buf + 0x20,
+		       (void *)(uintptr_t)smbios3_anchor->struct_table_address,
+		       smbios3_anchor->max_struct_size);
+
+		smbios3_anchor = (struct smbios3_entry *)buf;
+		smbios3_anchor->struct_table_address = 0x20;
+		smbios3_anchor->checksum +=
+			checksum(smbios3_anchor, smbios3_anchor->length);
+	} else {
+		struct smbios_entry *smbios_anchor;
+
+		smbios_anchor = get_config_table(&smbios_guid);
+		if (!smbios_anchor) {
+			/* Should not be reached after successful do_check() */
+			error(u"No SMBIOS table\n");
+			return EFI_NOT_FOUND;
+		}
+
+		size = 0x20 + smbios_anchor->struct_table_length;
+
+		ret = bs->allocate_pool(EFI_LOADER_DATA, size, (void **)&buf);
+		if (ret != EFI_SUCCESS) {
+			error(u"Out of memory\n");
+			return ret;
+		}
+
+		memset(buf, 0, size);
+		memcpy(buf, smbios_anchor, smbios_anchor->length);
+		memcpy(buf + 0x20,
+		       (void *)(uintptr_t)smbios_anchor->struct_table_address,
+		       smbios_anchor->struct_table_length);
+
+		smbios_anchor = (struct smbios_entry *)buf;
+		smbios_anchor->struct_table_address = 0x20;
+		smbios_anchor->intermediate_checksum +=
+			checksum(&smbios_anchor->intermediate_anchor, 0xf);
+		smbios_anchor->checksum +=
+			checksum(smbios_anchor, smbios_anchor->length);
+	}
+
+	filename = skip_whitespace(filename);
+
+	ret = save_file(filename, buf, size);
+
+	if (ret == EFI_SUCCESS) {
+		print(filename);
+		print(u" written\r\n");
+	}
+
+	bs->free_pool(buf);
+
+	return ret;
+}
+
+/**
+ * get_load_options() - get load options
+ *
+ * Return:	load options or NULL
+ */
+static u16 *get_load_options(void)
+{
+	efi_status_t ret;
+	struct efi_loaded_image *loaded_image;
+
+	ret = bs->open_protocol(handle, &loaded_image_guid,
+				(void **)&loaded_image, NULL, NULL,
+				EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+	if (ret != EFI_SUCCESS) {
+		error(u"Loaded image protocol not found\r\n");
+		return NULL;
+	}
+
+	if (!loaded_image->load_options_size || !loaded_image->load_options)
+		return NULL;
+
+	return loaded_image->load_options;
+}
+
+/**
+ * command_loop - process user commands
+ */
+static void command_loop(void)
+{
+	for (;;) {
+		u16 command[BUFFER_SIZE];
+		u16 *pos;
+		efi_uintn_t ret;
+
+		print(u"=> ");
+		ret = efi_input(command, sizeof(command));
+		if (ret == EFI_ABORTED)
+			break;
+		pos = skip_whitespace(command);
+		if (starts_with(pos, u"exit")) {
+			break;
+		} else if (starts_with(pos, u"check")) {
+			ret = do_check();
+			if (ret == EFI_SUCCESS)
+				print(u"OK\n");
+		} else if (starts_with(pos, u"save ")) {
+			do_save(pos + 5);
+		} else {
+			do_help();
+		}
+	}
+}
+
+/**
+ * efi_main() - entry point of the EFI application.
+ *
+ * @handle:	handle of the loaded image
+ * @systab:	system table
+ * Return:	status code
+ */
+efi_status_t EFIAPI efi_main(efi_handle_t image_handle,
+			     struct efi_system_table *systab)
+{
+	u16 *load_options;
+
+	handle = image_handle;
+	systable = systab;
+	cerr = systable->std_err;
+	cout = systable->con_out;
+	cin = systable->con_in;
+	bs = systable->boottime;
+	load_options = get_load_options();
+
+	if (starts_with(load_options, u"nocolor"))
+		nocolor = true;
+
+	color(EFI_WHITE);
+	cls();
+	print(u"SMBIOS Dump\r\n===========\r\n\r\n");
+	color(EFI_LIGHTBLUE);
+
+	command_loop();
+
+	color(EFI_LIGHTGRAY);
+	cls();
+
+	return EFI_SUCCESS;
+}
