diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 4ec5684ca..3824f0fa2 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -2358,3 +2358,9 @@ module = {
common = loader/i386/xen_file64.c;
extra_dist = loader/i386/xen_fileXX.c;
};
+
+module = {
+ name = fwconfig;
+ common = commands/fwconfig.c;
+ enable = x86;
+};
diff --git a/grub-core/commands/fwconfig.c b/grub-core/commands/fwconfig.c
new file mode 100644
index 000000000..289d167fd
--- /dev/null
+++ b/grub-core/commands/fwconfig.c
@@ -0,0 +1,121 @@
+/* fwconfig.c - command to read config from qemu fwconfig */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2015 CoreOS, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see .
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define SELECTOR 0x510
+#define DATA 0x511
+
+#define SIGNATURE_INDEX 0x00
+#define DIRECTORY_INDEX 0x19
+
+static grub_extcmd_t cmd_read_fwconfig;
+
+struct grub_qemu_fwcfgfile {
+ grub_uint32_t size;
+ grub_uint16_t select;
+ grub_uint16_t reserved;
+ char name[56];
+};
+
+static const struct grub_arg_option options[] =
+ {
+ {0, 'v', 0, N_("Save read value into variable VARNAME."),
+ N_("VARNAME"), ARG_TYPE_STRING},
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static grub_err_t
+grub_cmd_fwconfig (grub_extcmd_context_t ctxt, int argc, char **argv)
+{
+ grub_uint32_t i, j, value = 0;
+ struct grub_qemu_fwcfgfile file;
+ char fwsig[4], signature[4] = { 'Q', 'E', 'M', 'U' };
+
+ if (argc != 2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
+
+ /* Verify that we have meaningful hardware here */
+ grub_outw(SIGNATURE_INDEX, SELECTOR);
+ for (i=0; i