summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extensions/openpower-pels/manager.cpp21
-rw-r--r--extensions/openpower-pels/registry/message_registry.json37
-rw-r--r--test/openpower-pels/pel_manager_test.cpp45
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<level::ERR>("Invalid PEL found",
+ log<level::ERR>("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<DataInterfaceBase> dataIface =
+ std::make_unique<DataInterface>(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<const char*>(data.data()), data.size());
+ pelFile.close();
+
+ std::string adItem = "RAWPEL=" + pelFilename.string();
+ std::vector<std::string> additionalData{adItem};
+ std::vector<std::string> 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)
{
OpenPOWER on IntegriCloud