From e95fd0154e723813f5d7bf981e97b7ca6f28f7ef Mon Sep 17 00:00:00 2001 From: Matt Spinler Date: Tue, 7 Jan 2020 12:53:16 -0600 Subject: PEL: New event log when receiving bad host PEL Create a new event log/PEL when a PEL comes in from the host but it isn't valid. The PEL subsystem used is 'platform firmware' because the code won't know which specific host subsystem it came from. The severity is unrecoverable as opposed to informational to make it easier to notice. Signed-off-by: Matt Spinler Change-Id: I933e5c82f1ef755c6266604fbdec6d0c1fe5b784 --- extensions/openpower-pels/manager.cpp | 21 +++++++++- .../openpower-pels/registry/message_registry.json | 37 ++++++++++++++++++ test/openpower-pels/pel_manager_test.cpp | 45 ++++++++++++++++++++++ 3 files changed, 101 insertions(+), 2 deletions(-) diff --git a/extensions/openpower-pels/manager.cpp b/extensions/openpower-pels/manager.cpp index 40501a5..05ccb42 100644 --- a/extensions/openpower-pels/manager.cpp +++ b/extensions/openpower-pels/manager.cpp @@ -100,10 +100,27 @@ void Manager::addRawPEL(const std::string& rawPelPath, uint32_t obmcLogID) } else { - log("Invalid PEL found", + log("Invalid PEL received from the host", entry("PELFILE=%s", rawPelPath.c_str()), entry("OBMCLOGID=%d", obmcLogID)); - // TODO, make a whole new OpenBMC event log + PEL + + AdditionalData ad; + ad.add("PLID", getNumberString("0x%08X", pel->plid())); + ad.add("OBMC_LOG_ID", std::to_string(obmcLogID)); + ad.add("RAW_PEL_FILENAME", rawPelPath); + ad.add("PEL_SIZE", std::to_string(data.size())); + + std::string asciiString; + auto src = pel->primarySRC(); + if (src) + { + asciiString = (*src)->asciiString(); + } + + ad.add("SRC", asciiString); + + _eventLogger.log("org.open_power.Logging.Error.BadHostPEL", + Entry::Level::Error, ad); } } else diff --git a/extensions/openpower-pels/registry/message_registry.json b/extensions/openpower-pels/registry/message_registry.json index 6b4ab45..12b977b 100644 --- a/extensions/openpower-pels/registry/message_registry.json +++ b/extensions/openpower-pels/registry/message_registry.json @@ -160,6 +160,43 @@ "The host firmware rejected that PEL." ] } + }, + + { + "Name": "org.open_power.Logging.Error.BadHostPEL", + "Subsystem": "platform_firmware", + "Severity": "unrecoverable", + + "SRC": + { + "ReasonCode": "0x2002", + "Words6To9": + { + "6": + { + "Description": "The PLID of the invalid PEL", + "AdditionalDataPropSource": "PLID" + }, + "7": + { + "Description": "The corresponding OpenBMC event log ID", + "AdditionalDataPropSource": "OBMC_LOG_ID" + }, + "8": + { + "Description": "The size of the invalid PEL", + "AdditionalDataPropSource": "PEL_SIZE" + } + } + }, + + "Documentation": + { + "Description": "The host sent the BMC an invalid PEL", + "Message": "The host sent the BMC an invalid PEL", + "Notes": [ + ] + } } ] } diff --git a/test/openpower-pels/pel_manager_test.cpp b/test/openpower-pels/pel_manager_test.cpp index 5305468..1e0e1a9 100644 --- a/test/openpower-pels/pel_manager_test.cpp +++ b/test/openpower-pels/pel_manager_test.cpp @@ -128,6 +128,51 @@ TEST_F(ManagerTest, TestCreateWithPEL) fs::remove_all(pelFilename.parent_path()); } +TEST_F(ManagerTest, TestCreateWithInvalidPEL) +{ + std::unique_ptr dataIface = + std::make_unique(bus); + + openpower::pels::Manager manager{ + logManager, std::move(dataIface), + std::bind(std::mem_fn(&TestLogger::log), &logger, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3)}; + + // Create a PEL, write it to a file, and pass that filename into + // the create function. + auto data = pelDataFactory(TestPELType::pelSimple); + + // Truncate it to make it invalid. + data.resize(200); + + fs::path pelFilename = makeTempDir() / "rawpel"; + std::ofstream pelFile{pelFilename}; + pelFile.write(reinterpret_cast(data.data()), data.size()); + pelFile.close(); + + std::string adItem = "RAWPEL=" + pelFilename.string(); + std::vector additionalData{adItem}; + std::vector associations; + + manager.create("error message", 42, 0, + phosphor::logging::Entry::Level::Error, additionalData, + associations); + + // Run the event loop to log the bad PEL event + sdeventplus::Event e{sdEvent}; + e.run(std::chrono::milliseconds(1)); + + PEL invalidPEL{data}; + EXPECT_EQ(logger.errName, "org.open_power.Logging.Error.BadHostPEL"); + EXPECT_EQ(logger.errLevel, phosphor::logging::Entry::Level::Error); + EXPECT_EQ(std::stoi(logger.ad["PLID"], nullptr, 16), invalidPEL.plid()); + EXPECT_EQ(logger.ad["OBMC_LOG_ID"], "42"); + EXPECT_EQ(logger.ad["SRC"], (*invalidPEL.primarySRC())->asciiString()); + EXPECT_EQ(logger.ad["PEL_SIZE"], std::to_string(data.size())); + + fs::remove_all(pelFilename.parent_path()); +} + // Test that the message registry can be used to build a PEL. TEST_F(ManagerTest, TestCreateWithMessageRegistry) { -- cgit v1.2.1