<p>Rizwan Qureshi has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/29357">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">intel/basecode/fw_upadte: Add ELOG events to ucode update<br><br>Add ELOG entries for ucode update module.<br><br>TEST=verified that the eventlog shows event 0xb2<br>1 | 2018-10-30 06:06:52 | System boot | 161<br>2 | 2018-10-30 06:06:52 | Unknown | 0xb2<br>3 | 2018-10-30 06:07:09 | System boot | 162<br><br>Change-Id: Idda32a1073b3dc8e3f57e079b69fc415a2837899<br>Signed-off-by: Rizwan Qureshi <rizwan.qureshi@intel.com><br>---<br>M src/include/elog.h<br>M src/soc/intel/common/basecode/fw_update/Makefile.inc<br>A src/soc/intel/common/basecode/fw_update/elog.c<br>A src/soc/intel/common/basecode/fw_update/elog.h<br>M src/soc/intel/common/basecode/fw_update/ucode_update.c<br>5 files changed, 76 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/57/29357/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/include/elog.h b/src/include/elog.h</span><br><span>index 8aecf2c..49e2dd4 100644</span><br><span>--- a/src/include/elog.h</span><br><span>+++ b/src/include/elog.h</span><br><span>@@ -152,6 +152,7 @@</span><br><span> #define  ELOG_WAKE_SOURCE_PME_XHCI_USB_2   0x1d</span><br><span> #define  ELOG_WAKE_SOURCE_PME_XHCI_USB_3   0x1e</span><br><span> #define  ELOG_WAKE_SOURCE_PME_WIFI         0x1f</span><br><span style="color: hsl(120, 100%, 40%);">+#define  ELOG_UCODE_UPDATE                 0x20</span><br><span> </span><br><span> struct elog_event_data_wake {</span><br><span>  u8 source;</span><br><span>@@ -231,6 +232,17 @@</span><br><span>    u32 event_complement;</span><br><span> } __packed;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Microcode Update events */</span><br><span style="color: hsl(120, 100%, 40%);">+#define ELOG_TYPE_INTEL_UCODE_UPDATE     0xb2</span><br><span style="color: hsl(120, 100%, 40%);">+#define ELOG_INTEL_UCODE_UPDATE_FAIL    -1</span><br><span style="color: hsl(120, 100%, 40%);">+#define ELOG_INTEL_UCODE_UPDATE_PASS     0</span><br><span style="color: hsl(120, 100%, 40%);">+struct elog_event_intel_ucode {</span><br><span style="color: hsl(120, 100%, 40%);">+       u32 uc_current;</span><br><span style="color: hsl(120, 100%, 40%);">+       u32 uc_slot;</span><br><span style="color: hsl(120, 100%, 40%);">+  u32 uc_staging;</span><br><span style="color: hsl(120, 100%, 40%);">+       int status;</span><br><span style="color: hsl(120, 100%, 40%);">+} __packed;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #if IS_ENABLED(CONFIG_ELOG)</span><br><span> /* Eventlog backing storage must be initialized before calling elog_init(). */</span><br><span> extern int elog_init(void);</span><br><span>diff --git a/src/soc/intel/common/basecode/fw_update/Makefile.inc b/src/soc/intel/common/basecode/fw_update/Makefile.inc</span><br><span>index f58961b..5631e00 100644</span><br><span>--- a/src/soc/intel/common/basecode/fw_update/Makefile.inc</span><br><span>+++ b/src/soc/intel/common/basecode/fw_update/Makefile.inc</span><br><span>@@ -1 +1,2 @@</span><br><span> ramstage-$(CONFIG_TOP_SWAP_BASED_VBOOT_UCODE_UPDATE) += ucode_update.c</span><br><span style="color: hsl(120, 100%, 40%);">+ramstage-$(CONFIG_TOP_SWAP_BASED_VBOOT_UCODE_UPDATE) += elog.c</span><br><span>diff --git a/src/soc/intel/common/basecode/fw_update/elog.c b/src/soc/intel/common/basecode/fw_update/elog.c</span><br><span>new file mode 100644</span><br><span>index 0000000..8daf674</span><br><span>--- /dev/null</span><br><span>+++ b/src/soc/intel/common/basecode/fw_update/elog.c</span><br><span>@@ -0,0 +1,32 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (C) 2018 Intel Corp.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; version 2 of the License.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdint.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <elog.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include "elog.h"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int ucode_elog_event(u32 current, u32 slot, u32 staging, int status)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       const int event_type = ELOG_TYPE_INTEL_UCODE_UPDATE;</span><br><span style="color: hsl(120, 100%, 40%);">+  struct elog_event_intel_ucode event = {</span><br><span style="color: hsl(120, 100%, 40%);">+               .uc_current = current,</span><br><span style="color: hsl(120, 100%, 40%);">+                .uc_slot = slot,</span><br><span style="color: hsl(120, 100%, 40%);">+              .uc_staging = staging,</span><br><span style="color: hsl(120, 100%, 40%);">+                .status = status,</span><br><span style="color: hsl(120, 100%, 40%);">+     };</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  return (elog_add_event_raw(event_type, &event, sizeof(event)));</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>diff --git a/src/soc/intel/common/basecode/fw_update/elog.h b/src/soc/intel/common/basecode/fw_update/elog.h</span><br><span>new file mode 100644</span><br><span>index 0000000..d56c779</span><br><span>--- /dev/null</span><br><span>+++ b/src/soc/intel/common/basecode/fw_update/elog.h</span><br><span>@@ -0,0 +1,22 @@</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (C) 2018 Intel Corp.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; version 2 of the License.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdint.h></span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Add microcode update ELOG event</span><br><span style="color: hsl(120, 100%, 40%);">+ * return 0 on success, -1 on failure.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int ucode_elog_event(u32 current, u32 slot, u32 staging, int status);</span><br><span>diff --git a/src/soc/intel/common/basecode/fw_update/ucode_update.c b/src/soc/intel/common/basecode/fw_update/ucode_update.c</span><br><span>index 4a7c194..eeb6aec 100644</span><br><span>--- a/src/soc/intel/common/basecode/fw_update/ucode_update.c</span><br><span>+++ b/src/soc/intel/common/basecode/fw_update/ucode_update.c</span><br><span>@@ -19,6 +19,7 @@</span><br><span> #include <commonlib/region.h></span><br><span> #include <console/console.h></span><br><span> #include <cpu/intel/microcode.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <elog.h></span><br><span> #include <fmap.h></span><br><span> #include <halt.h></span><br><span> #include <intelbasecode/ucode_update.h></span><br><span>@@ -29,6 +30,7 @@</span><br><span> #include <stdlib.h></span><br><span> #include <stdint.h></span><br><span> #include <types.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include "elog.h"</span><br><span> </span><br><span> #define locate_staging_rw(rdev) \</span><br><span>  fmap_locate_area_as_rdev_rw(CONFIG_INTEL_TOP_SWAP_FIT_ENTRY_FMAP_REG, \</span><br><span>@@ -188,7 +190,10 @@</span><br><span>               }</span><br><span> </span><br><span>                printk(BIOS_INFO, "Microcode staging area updated, restart!\n");</span><br><span style="color: hsl(0, 100%, 40%);">-              /* TODO: Add ELOG entry */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+          if (ucode_elog_event(current_ucode, slot_rev, staging_rev,</span><br><span style="color: hsl(120, 100%, 40%);">+                                    ELOG_INTEL_UCODE_UPDATE_PASS) < 0)</span><br><span style="color: hsl(120, 100%, 40%);">+                 printk(BIOS_ERR, "Failed to log microcode update event.\n");</span><br><span> </span><br><span>           /* Finished writing, disable safety and reset */</span><br><span>             configure_rtc_buc_top_swap(TS_ENABLE);</span><br><span>@@ -205,6 +210,8 @@</span><br><span> </span><br><span> update_failed:</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  /* TODO: Write Elog */</span><br><span style="color: hsl(120, 100%, 40%);">+        if (ucode_elog_event(0, 0, 0, ELOG_INTEL_UCODE_UPDATE_FAIL) < 0)</span><br><span style="color: hsl(120, 100%, 40%);">+           printk(BIOS_ERR, "Failed to log microcode update event.\n");</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>     return CB_ERR;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/29357">change 29357</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/29357"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Idda32a1073b3dc8e3f57e079b69fc415a2837899 </div>
<div style="display:none"> Gerrit-Change-Number: 29357 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Rizwan Qureshi <rizwan.qureshi@intel.com> </div>