Пример #1
0
/*
 * Execute an emulated BIOS ioctl to retrieve information about the bios large mailboxes
 */
int bios_get_payload_size(struct ndctl_dimm *p_dimm, struct pt_bios_get_size *p_bios_mb_size)
{
	COMMON_LOG_ENTRY();
	int rc = NVM_SUCCESS;

	if (p_dimm == NULL)
	{
		COMMON_LOG_ERROR("Invalid parameter, Dimm is null");
		rc = NVM_ERR_INVALIDPARAMETER;
	}
	else if (p_bios_mb_size == NULL)
	{
		COMMON_LOG_ERROR("Invalid parameter, size struct is null");
		rc = NVM_ERR_INVALIDPARAMETER;
	}
	else
	{
		memset(p_bios_mb_size, 0, sizeof (*p_bios_mb_size));
		struct ndctl_cmd *p_vendor_cmd = NULL;
		if ((p_vendor_cmd = ndctl_dimm_cmd_new_vendor_specific(p_dimm,
			BUILD_DSM_OPCODE(BIOS_EMULATED_COMMAND, SUBOP_GET_PAYLOAD_SIZE), 128,
			sizeof (struct pt_bios_get_size))) == NULL)
		{
			rc = NVM_ERR_DRIVERFAILED;
			COMMON_LOG_ERROR("Failed to get vendor command from driver");
		}
		else
		{
			if (((rc = linux_err_to_nvm_lib_err(ndctl_cmd_submit(
				p_vendor_cmd))) == NVM_SUCCESS) &&
				((rc = dsm_err_to_nvm_lib_err(ndctl_cmd_get_firmware_status(
				p_vendor_cmd))) == NVM_SUCCESS))
			{
				NVM_SIZE return_size = ndctl_cmd_vendor_get_output(p_vendor_cmd,
					p_bios_mb_size, sizeof (struct pt_bios_get_size));
				if (return_size != sizeof (struct pt_bios_get_size))
				{
					rc = NVM_ERR_DRIVERFAILED;
					COMMON_LOG_ERROR("Small Payload returned less data than requested");
				}
			}
			ndctl_cmd_unref(p_vendor_cmd);
		}
	}
	COMMON_LOG_EXIT_RETURN_I(rc);
	return rc;
}
Пример #2
0
/*
 * Run a diagnostic test on the device specified.
 */
int nvm_run_diagnostic(const NVM_GUID device_guid,
		const struct diagnostic *p_diagnostic, NVM_UINT32 *p_results)
{
	COMMON_LOG_ENTRY();
	int rc = NVM_SUCCESS;

	if (p_diagnostic == NULL)
	{
		COMMON_LOG_ERROR("Invalid parameter, p_diagnostic is NULL");
		rc = NVM_ERR_INVALIDPARAMETER;
	}
	else if (p_results == NULL)
	{
		COMMON_LOG_ERROR("Invalid parameter, p_results is NULL");
		rc = NVM_ERR_INVALIDPARAMETER;
	}
	else if (check_caller_permissions() != NVM_SUCCESS)
	{
		rc = NVM_ERR_INVALIDPERMISSIONS;
	}
	else
	{
		switch (p_diagnostic->test)
		{
			case DIAG_TYPE_QUICK:
				rc = diag_quick_health_check(device_guid, p_diagnostic, p_results);
				break;
			case DIAG_TYPE_PLATFORM_CONFIG:
				rc = diag_platform_config_check(p_diagnostic, p_results);
				break;
			case DIAG_TYPE_PM_META:
				rc = diag_pm_metadata_check(p_results);
				break;
			case DIAG_TYPE_FW_CONSISTENCY:
				rc = diag_firmware_check(p_diagnostic, p_results);
				break;
			case DIAG_TYPE_SECURITY:
				rc = diag_security_check(p_diagnostic, p_results);
				break;
		}
	}

	COMMON_LOG_EXIT_RETURN_I(rc);
	return rc;
}
Пример #3
0
/*
 * Fetch the GUID filter value.
 */
std::string wbem::support::EventLogFilter::getGuid() throw (framework::Exception)
{
	if (!hasGuid())
	{
		COMMON_LOG_ERROR("requested GUID filter when none set");
		throw framework::ExceptionBadParameter("guid");
	}
	return m_guidValue;
}
Пример #4
0
/*
 * Fetch the action required filter value.
 */
bool wbem::support::EventLogFilter::getActionRequired() throw (framework::Exception)
{
	if (!hasActionRequired())
	{
		COMMON_LOG_ERROR("requested action required filter when none set");
		throw framework::ExceptionBadParameter("actionRequired");
	}
	return m_actionReqValue;
}
Пример #5
0
/*!
 * Fetch the event "after timestamp" filter value.
 */
time_t wbem::support::EventLogFilter::getAfterTimestamp() throw (framework::Exception)
{
	if (!hasAfterTimestamp())
	{
		COMMON_LOG_ERROR("requested after timestamp filter when none set");
		throw framework::ExceptionBadParameter("afterTimestamp");
	}
	return m_afterTimestampValue;
}
Пример #6
0
/*
 * Fetch the event ID filter value.
 */
wbem::framework::UINT32 wbem::support::EventLogFilter::getEventId() throw (framework::Exception)
{
	if (!hasEventId())
	{
		COMMON_LOG_ERROR("requested event ID filter when none set");
		throw framework::ExceptionBadParameter("eventId");
	}
	return m_eventIdValue;
}
Пример #7
0
/*
 * Fetch the event severity filter value.
 * @throw Exception if not set
 */
wbem::framework::UINT32 wbem::support::EventLogFilter::getSeverity() throw (framework::Exception)
{
	if (!hasSeverity())
	{
		COMMON_LOG_ERROR("requested severity filter when none set");
		throw framework::ExceptionBadParameter("severity");
	}
	return m_severityValue;
}
Пример #8
0
/*
 * Fetch the event code filter value.
 */
wbem::framework::UINT16 wbem::support::EventLogFilter::getCode() throw (framework::Exception)
{
	if (!hasCode())
	{
		COMMON_LOG_ERROR("requested code filter when none set");
		throw framework::ExceptionBadParameter("code");
	}
	return m_codeValue;
}
Пример #9
0
/*
 * Fetch the event type filter value.
 * @throw Exception if not set
 */
wbem::framework::UINT32 wbem::support::EventLogFilter::getType() throw (framework::Exception)
{
	if (!hasType())
	{
		COMMON_LOG_ERROR("requested type filter when none set");
		throw framework::ExceptionBadParameter("type");
	}
	return m_typeValue;
}
Пример #10
0
/*
 * Execute an emulated BIOS ioctl to retrieve information about the bios large mailboxes
 */
int bios_get_large_payload_size(unsigned int device_handle,
		GET_LARGE_PAYLOAD_SIZE_OUTPUT_PAYLOAD *p_large_payload_size)
{
	COMMON_LOG_ENTRY();
	int rc = NVM_ERR_UNKNOWN;

	size_t arg3_size = sizeof (DSM_VENDOR_SPECIFIC_COMMAND_INPUT_PAYLOAD) -
		ARG3_OPCODE_PARAMETER_DATA_BUFFER_PLACEHOLDER +
		sizeof (DSM_VENDOR_SPECIFIC_COMMAND_OUTPUT_PAYLOAD)
		- DSM_VENDOR_SPECIFIC_COMMAND_OUTPUT_PAYLOAD_PLACEHOLDERS
		+ sizeof (GET_LARGE_PAYLOAD_SIZE_OUTPUT_PAYLOAD);

	size_t buf_size = sizeof (ULONG) + sizeof (NFIT_DEVICE_HANDLE) + arg3_size;

	PPASS_THROUGH_IOCTL p_ioctl_data = calloc(1, buf_size);
	if (p_ioctl_data)
	{
		p_ioctl_data->NfitDeviceHandle.DeviceHandle = device_handle;

		p_ioctl_data->InputPayload.Arg3OpCode = BUILD_DSM_OPCODE(BIOS_EMULATED_COMMAND,
			SUBOP_GET_PAYLOAD_SIZE);
		p_ioctl_data->InputPayload.Arg3OpCodeParameterDataLength = 0;

		PDSM_VENDOR_SPECIFIC_COMMAND_OUTPUT_PAYLOAD p_DsmOutputPayload =
				(PDSM_VENDOR_SPECIFIC_COMMAND_OUTPUT_PAYLOAD)
				(&p_ioctl_data->InputPayload.Arg3OpCodeParameterDataBuffer);

		if ((rc = execute_ioctl(buf_size, p_ioctl_data, IOCTL_CR_PASS_THROUGH))
			== NVM_SUCCESS &&
			(rc = ind_err_to_nvm_lib_err(p_ioctl_data->ReturnCode)) == NVM_SUCCESS)
		{
			if ((rc = dsm_err_to_nvm_lib_err(win_dsm_status_to_int(p_DsmOutputPayload->Arg3Status)))
					== NVM_SUCCESS)
			{
				memmove(p_large_payload_size, p_DsmOutputPayload->Arg3OutputBuffer,
					sizeof (GET_LARGE_PAYLOAD_SIZE_OUTPUT_PAYLOAD));
			}
		}

		free(p_ioctl_data);
	}
	else
	{
		COMMON_LOG_ERROR("couldn't allocate input payload");
		rc = NVM_ERR_NOMEMORY;
	}

	COMMON_LOG_EXIT_RETURN_I(rc);
	return rc;
}
Пример #11
0
bool wbem::profile::RegisteredProfileFactory::isElementConformsToProfileAssociation(
		const framework::Instance& antecedentInstance,
		const framework::Instance& dependentInstance)
	throw (framework::Exception)
{
	bool result = false;

	if (antecedentInstance.getClass() == REGISTEREDPROFILE_CREATIONCLASSNAME)
	{
		framework::Attribute profileInstanceIdAttr;
		if (antecedentInstance.getAttribute(INSTANCEID_KEY, profileInstanceIdAttr) != framework::SUCCESS)
		{
			COMMON_LOG_ERROR("couldn't get InstanceID for RegisteredProfile instance");
			throw framework::ExceptionBadAttribute(INSTANCEID_KEY.c_str());
		}

		std::string profileInstanceId = profileInstanceIdAttr.stringValue();
		std::string dependentClass = dependentInstance.getClass();

		std::string hostName = server::getHostName();
		std::string baseServerInstanceId = hostName + REGISTEREDPROFILE_REGISTEREDNAME_BASESERVER;
		std::string multiSystemMemoryInstanceId = hostName + REGISTEREDPROFILE_REGISTEREDNAME_MULTITYPESYSTEMMEMORY;
		// association - Base Server profile and Intel_BaseServer
		if (profileInstanceId.compare(baseServerInstanceId) == 0)
		{
			if (dependentClass == server::BASESERVER_CREATIONCLASSNAME)
			{
				result = true;
			}
		}
		// association - Multi-type System Memory profile and Intel_VolatileMemory/Intel_PersistentMemory
		else if (profileInstanceId.compare(multiSystemMemoryInstanceId) == 0)
		{
			if (dependentClass == memory::VOLATILEMEMORY_CREATIONCLASSNAME ||
				dependentClass == memory::PERSISTENTMEMORY_CREATIONCLASSNAME)
			{
				result = true;
			}
		}
	}

	return result;
}
Пример #12
0
/*
 * Helper function to allow setting/clearing poison on a particular DPA
 */
int inject_poison_error(struct device_discovery *p_discovery, NVM_UINT64 dpa, NVM_BOOL set_poison)
{
	int rc = NVM_SUCCESS;
	COMMON_LOG_ENTRY();

	if (set_poison)
	{
		if ((rc = validate_poison_injection(p_discovery, dpa)) != NVM_SUCCESS)
		{
			COMMON_LOG_ERROR("Invalid parameter, DPA is invalid");
		}
	}

	if (rc == NVM_SUCCESS)
	{
		// Set up input
		struct pt_payload_poison_err poison_err_input;
		memset(&poison_err_input, 0, sizeof (poison_err_input));
		poison_err_input.enable = set_poison;
		poison_err_input.dpa_address = dpa;

		struct fw_cmd cmd;
		memset(&cmd, 0, sizeof (cmd));
		cmd.device_handle = p_discovery->device_handle.handle;
		cmd.opcode = PT_INJECT_ERROR;
		cmd.sub_opcode = SUBOP_ERROR_POISON;
		cmd.input_payload = &poison_err_input;
		cmd.input_payload_size = sizeof (poison_err_input);
		rc = ioctl_passthrough_cmd(&cmd);

		if (rc != NVM_SUCCESS)
		{
			COMMON_LOG_ERROR_F("Failed to set/clear poison on dimm %u",
					p_discovery->device_handle.handle);
		}
	}

	COMMON_LOG_EXIT_RETURN_I(rc);
	return rc;
}
Пример #13
0
wbem::framework::Instance *wbem::indication::InstIndicationFactory::createIndication(
		struct event *pEvent)
throw(framework::Exception)
{
	LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);
	framework::Instance *pResult = NULL;

	if (pEvent == NULL)
	{
		COMMON_LOG_ERROR("pEvent was NULL");
	}
	else
	{
		COMMON_LOG_DEBUG_F("Event Type: %d, Event Code: %d", (int)pEvent->type, (int)pEvent->code);
		try
		{
			if (isNamespaceEvent(pEvent))
			{
				pResult = createNamespaceIndication(pEvent);
			}
			else if (isDeviceEvent(pEvent))
			{
				pResult = createDeviceIndication(pEvent);
			}
			else if (isSensorEvent(pEvent))
			{
				pResult = createSensorIndication(pEvent);
			}
		}
		catch (core::NoMemoryException)
		{
			throw framework::ExceptionNoMemory(__FILE__, __FUNCTION__, "Could not allocate memory");
		}
	}

	return pResult;
}
Пример #14
0
cli::framework::ResultBase *cli::nvmcli::NamespaceFeature::showPools(cli::framework::ParsedCommand const &parsedCommand)
{
	framework::ResultBase *pResult = NULL;
	wbem::mem_config::PoolViewFactory poolViewFactory;
	wbem::framework::attribute_names_t attributes;
	wbem::framework::instances_t *pInstances = NULL;
	try
	{
		// define default display attributes
		wbem::framework::attribute_names_t defaultAttributes;
		defaultAttributes.push_back(wbem::POOLID_KEY);
		defaultAttributes.push_back(wbem::POOLTYPE_KEY);
		defaultAttributes.push_back(wbem::CAPACITY_KEY);
		defaultAttributes.push_back(wbem::FREECAPACITY_KEY);

		// define all attributes
		wbem::framework::attribute_names_t allAttributes(defaultAttributes);
		allAttributes.push_back(wbem::ENCRYPTIONCAPABLE_KEY);
		allAttributes.push_back(wbem::ENCRYPTIONENABLED_KEY);
		allAttributes.push_back(wbem::ERASECAPABLE_KEY);
		allAttributes.push_back(wbem::SOCKETID_KEY);
		allAttributes.push_back(wbem::APPDIRECTNAMESPACE_MAX_SIZE_KEY);
		allAttributes.push_back(wbem::APPDIRECTNAMESPACE_MIN_SIZE_KEY);
		allAttributes.push_back(wbem::APPDIRECTNAMESPACE_COUNT_KEY);
		allAttributes.push_back(wbem::STORAGENAMESPACE_MAX_SIZE_KEY);
		allAttributes.push_back(wbem::STORAGENAMESPACE_MIN_SIZE_KEY);
		allAttributes.push_back(wbem::STORAGENAMESPACE_COUNT_KEY);
		allAttributes.push_back(wbem::HEALTHSTATE_KEY);
		allAttributes.push_back(wbem::APP_DIRECT_SETTINGS_KEY);

		// get the desired attributes
		wbem::framework::attribute_names_t attributes =
				GetAttributeNames(parsedCommand.options, defaultAttributes, allAttributes);

		// make sure we have the Pool  id in our display
		// this would cover the case the user asks for specific display attributes, but they
		// don't include the physical ID
		if (!wbem::framework_interface::NvmInstanceFactory::containsAttribute(wbem::POOLID_KEY,
				attributes))
		{
			attributes.insert(attributes.begin(), wbem::POOLID_KEY);
		}

		// create the display filters
		wbem::framework::attribute_names_t requestedAttributes = attributes;
		cli::nvmcli::filters_t filters;
		generateSocketFilter(parsedCommand, requestedAttributes, filters);
		generatePoolFilter(parsedCommand, requestedAttributes, filters);
		pInstances = poolViewFactory.getInstances(requestedAttributes);
		if (pInstances == NULL)
		{
			COMMON_LOG_ERROR("PoolViewFactory getInstances returned a NULL instances pointer");
			pResult = new framework::ErrorResult(framework::ErrorResult::ERRORCODE_UNKNOWN,
				TRS(nvmcli::UNKNOWN_ERROR_STR));
		}
		else
		{
			// get the desired units of capacity
			std::string capacityUnits;
			pResult = getCapacityUnits(parsedCommand, &capacityUnits);
			if (pResult == NULL)
			{
				for (size_t i = 0; i < pInstances->size(); i++)
				{
					cli::nvmcli::convertCapacityAttribute((*pInstances)[i], wbem::CAPACITY_KEY, capacityUnits);
					cli::nvmcli::convertCapacityAttribute((*pInstances)[i], wbem::FREECAPACITY_KEY, capacityUnits);
					cli::nvmcli::convertCapacityAttribute((*pInstances)[i], wbem::APPDIRECTNAMESPACE_MAX_SIZE_KEY, capacityUnits);
					cli::nvmcli::convertCapacityAttribute((*pInstances)[i], wbem::APPDIRECTNAMESPACE_MIN_SIZE_KEY, capacityUnits);
					cli::nvmcli::convertCapacityAttribute((*pInstances)[i], wbem::STORAGENAMESPACE_MAX_SIZE_KEY, capacityUnits);
					cli::nvmcli::convertCapacityAttribute((*pInstances)[i], wbem::STORAGENAMESPACE_MIN_SIZE_KEY, capacityUnits);
				}
				pResult = NvmInstanceToObjectListResult(*pInstances, "Pool",
						wbem::POOLID_KEY, attributes, filters);
				// Set layout to table unless the -all or -display option is present
				if (!framework::parsedCommandContains(parsedCommand, framework::OPTION_DISPLAY) &&
					!framework::parsedCommandContains(parsedCommand, framework::OPTION_ALL))
				{
					pResult->setOutputType(framework::ResultBase::OUTPUT_TEXTTABLE);
				}
			}
		}
	}
	catch (wbem::framework::Exception &e)
	{
		if (pResult)
		{
			delete pResult;
			pResult = NULL;
		}
		pResult = NvmExceptionToResult(e);
	}

	if (pInstances)
	{
		delete pInstances;
	}

	return pResult;
}
Пример #15
0
/*
 * Execute a passthrough IOCTL
 */
int ioctl_passthrough_cmd(struct fw_cmd *p_cmd)
{
	COMMON_LOG_ENTRY();
	int rc = NVM_ERR_UNKNOWN;

	if (p_cmd == NULL)
	{
		COMMON_LOG_ERROR("Invalid parameter, cmd is NULL");
		rc = NVM_ERR_INVALIDPARAMETER;
	}
	else if ((p_cmd->input_payload_size > 0 && p_cmd->input_payload == NULL) ||
			(p_cmd->input_payload != NULL && p_cmd->input_payload_size == 0) ||
			(p_cmd->output_payload_size > 0 && p_cmd->output_payload == NULL) ||
			(p_cmd->output_payload != NULL && p_cmd->output_payload_size == 0) ||
			(p_cmd->large_input_payload_size > 0 && p_cmd->large_input_payload == NULL) ||
			(p_cmd->large_input_payload != NULL && p_cmd->large_input_payload_size == 0) ||
			(p_cmd->large_output_payload_size > 0 && p_cmd->large_output_payload == NULL) ||
			(p_cmd->large_output_payload != NULL && p_cmd->large_output_payload_size == 0))
	{
		COMMON_LOG_ERROR("bad input/output payload(s)");
		rc = NVM_ERR_INVALIDPARAMETER;
	}
	// avoid any commands that require early HW or large payloads
#if __EARLY_HW__ || (__LARGE_PAYLOAD__ == 0)
	else if ((p_cmd->opcode == 0x08 && p_cmd->sub_opcode == 0x02) || // get fw debug log
			(p_cmd->opcode == 0x08 && p_cmd->sub_opcode == 0x05) || // get error log
			(p_cmd->opcode == 0x0A)) // inject error
	{
		COMMON_LOG_ERROR_F("Intel DIMM Gen 1 FW command OpCode: 0x%x SubOpCode: "
				"0x%x is not supported",
				p_cmd->opcode, p_cmd->sub_opcode);
		rc = NVM_ERR_NOTSUPPORTED;
	}
#endif
	else
	{
		size_t input_buf_size = sizeof (DSM_VENDOR_SPECIFIC_COMMAND_INPUT_PAYLOAD)
				- ARG3_OPCODE_PARAMETER_DATA_BUFFER_PLACEHOLDER	+ p_cmd->input_payload_size;

		size_t output_buf_size = sizeof (DSM_VENDOR_SPECIFIC_COMMAND_OUTPUT_PAYLOAD)
			- DSM_VENDOR_SPECIFIC_COMMAND_OUTPUT_PAYLOAD_PLACEHOLDERS
			+ DEV_SMALL_PAYLOAD_SIZE;

		size_t arg3_size = input_buf_size + output_buf_size;
		size_t buf_size = sizeof (ULONG) + sizeof (NFIT_DEVICE_HANDLE) + arg3_size;

		PPASS_THROUGH_IOCTL p_ioctl_data = calloc(1, buf_size);
		if (p_ioctl_data)
		{
			p_ioctl_data->NfitDeviceHandle.DeviceHandle =
					p_cmd->device_handle;

			p_ioctl_data->InputPayload.Arg3OpCodeParameterDataLength = p_cmd->input_payload_size;
			p_ioctl_data->InputPayload.Arg3OpCode = BUILD_DSM_OPCODE(p_cmd->opcode,
					p_cmd->sub_opcode);

			if (p_cmd->input_payload_size > 0)
			{
				memmove(p_ioctl_data->InputPayload.Arg3OpCodeParameterDataBuffer,
						p_cmd->input_payload,
						p_cmd->input_payload_size);
			}

			if (p_cmd->large_input_payload_size > 0)
			{
				rc = bios_write_large_payload(p_cmd);
			}

			PDSM_VENDOR_SPECIFIC_COMMAND_OUTPUT_PAYLOAD p_output_payload = NULL;

			p_output_payload =
				(PDSM_VENDOR_SPECIFIC_COMMAND_OUTPUT_PAYLOAD)
				(p_ioctl_data->InputPayload.Arg3OpCodeParameterDataBuffer
					+ p_cmd->input_payload_size);

			if ((rc = execute_ioctl(buf_size, p_ioctl_data, IOCTL_CR_PASS_THROUGH))
				== NVM_SUCCESS &&
				(rc = ind_err_to_nvm_lib_err(p_ioctl_data->ReturnCode)) == NVM_SUCCESS)
			{
				if ((rc = dsm_err_to_nvm_lib_err(
					win_dsm_status_to_int(p_output_payload->Arg3Status))) == NVM_SUCCESS)
				{
					if (p_cmd->output_payload_size > 0)
					{
						size_t bytes_to_copy = p_cmd->output_payload_size;
						if (p_output_payload->Arg3OutputBufferLength <
								p_cmd->output_payload_size)
						{
							// User expected more data than the command returned
							// We can safely copy it, but there could be a developer error
							bytes_to_copy = p_output_payload->Arg3OutputBufferLength;
							COMMON_LOG_WARN_F(
									"output buffer size %llu larger than size returned %u",
									p_cmd->output_payload_size,
									p_output_payload->Arg3OutputBufferLength);
						}
						memmove(p_cmd->output_payload, p_output_payload->Arg3OutputBuffer,
								bytes_to_copy);
					}

					if (p_cmd->large_output_payload_size > 0)
					{
						rc = bios_read_large_payload(p_cmd);
					}
				}
			}

			free(p_ioctl_data);
		}
		else
		{
			COMMON_LOG_ERROR("couldn't allocate input payload");
			rc = NVM_ERR_NOMEMORY;
		}
	}

	s_memset(&p_cmd, sizeof (p_cmd));
	COMMON_LOG_EXIT_RETURN_I(rc);
	return rc;
}
/*
 * entry point for CIMOM to execute an extrinsic method
 */
wbem::framework::UINT32 wbem::software::NVDIMMSoftwareInstallationServiceFactory::executeMethod(
		wbem::framework::UINT32& wbemRc, const std::string method,
		wbem::framework::ObjectPath& object,
		wbem::framework::attributes_t& inParms,
		wbem::framework::attributes_t& outParms)
{
	LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);
	wbem::framework::UINT32 httpRc = framework::MOF_ERR_SUCCESS;
	wbemRc = framework::MOF_ERR_SUCCESS;
	// valid InstallOptions for InstallFromURI
	const NVM_UINT16 DEFER = 2; 
	const NVM_UINT16 FORCE = 3;
	const NVM_UINT16 REBOOT = 7;
	const NVM_UINT16 EXAMINE = 32768;

	if (method == NVDIMMSOFTWAREINSTALLATIONSERVICE_INSTALLFROMURI)
	{
		/*
		 * uint32 InstallFromURI(CIM_ConcreateJob REF Job, string URI,
		 * 		CIM_ManagedElement REF Target, uint16 InstallOptions[],
		 * 		string InstallOptionsValues[])
		 *
		 * Returns one of:
		 * 		0 		- Job Completed with No Error
		 * 		2 		- Unspecified Error
		 * 		4 		- Failed
		 * 		5 		- Invalid Parameter
		 * 		4097 	- Unsupported Target Type
		 * 		4099 	- Downgrade/reinstall not supported
		 * 		4100	- Not enough memory
		 * 		4107 	- URI not accessible
		 *
		 */

		std::string uri = inParms[NVDIMMSOFTWAREINSTALLATIONSERVICE_INSTALLFROMURI_PARAM_URI].stringValue();
		std::string target = inParms[NVDIMMSOFTWAREINSTALLATIONSERVICE_INSTALLFROMURI_PARAM_TARGET].stringValue();
		framework::UINT16_LIST installOptions = inParms[NVDIMMSOFTWAREINSTALLATIONSERVICE_INSTALLFROMURI_INSTALLOPTIONS].uint16ListValue();
		// get valid install options
		bool rebootOption =
				std::find(installOptions.begin(), installOptions.end(), REBOOT) != installOptions.end();
		bool deferOption =
				std::find(installOptions.begin(), installOptions.end(), DEFER) != installOptions.end();
		bool forceOption =
				std::find(installOptions.begin(), installOptions.end(), FORCE) != installOptions.end();
		bool examineOption =
				std::find(installOptions.begin(), installOptions.end(), EXAMINE) != installOptions.end();

		// count invalid install options
		int invalidOptions = 0;
		for (size_t i = 0; i < installOptions.size(); i++)
		{
			if (!(installOptions[i] == DEFER ||
					installOptions[i] == REBOOT ||
					installOptions[i] == FORCE ||
					installOptions[i] == EXAMINE))
			{
				invalidOptions++;
			}
		}
		try
		{
			COMMON_PATH absPath;
			if (uri.empty())
			{
				httpRc = framework::CIM_ERR_INVALID_PARAMETER;
				COMMON_LOG_ERROR("URI parameter was missing");
			}
			else if (target.empty())
			{
				httpRc = framework::CIM_ERR_INVALID_PARAMETER;
				COMMON_LOG_ERROR("Target parameter was missing");
			}
			else if (get_absolute_path(uri.c_str(), uri.length() + 1, absPath) != COMMON_SUCCESS)
			{
				httpRc = framework::CIM_ERR_INVALID_PARAMETER;
				COMMON_LOG_ERROR("URI parameter is not valid");
			}
			else if (invalidOptions > 0)
			{
				httpRc = framework::CIM_ERR_INVALID_PARAMETER;
				COMMON_LOG_ERROR_F("Only %d, %d, %d and/or %d are valid InstallOptions",
						DEFER, REBOOT, FORCE, EXAMINE);
			}
			else if (rebootOption && deferOption)
			{
				httpRc = framework::CIM_ERR_INVALID_PARAMETER;
				COMMON_LOG_ERROR_F("%d and %d cannot be used together as InstallOptions",
						DEFER, REBOOT);
			}
			else
			{
				framework::ObjectPathBuilder targetBuilder(target);
				framework::ObjectPath targetObject;
				targetBuilder.Build(&targetObject);

				if (targetObject.getClass() == NVDIMMCOLLECTION_CREATIONCLASSNAME)
				{
					// all devices on system
					if (examineOption)
					{
						std::string version;

						framework::return_codes rc = examineFwImage(absPath, version);
						if (rc == framework::REQUIRES_FORCE)
						{
							wbemRc = SWINSTALLSERVICE_ERR_DOWNGRADE_NOT_SUPPORTED;
						}
						else if (rc != framework::SUCCESS)
						{
							wbemRc = SWINSTALLSERVICE_ERR_NOT_APPLICABLE_TO_TARGET;
						}
					}
					else
					{
						installFromPath(absPath, rebootOption, forceOption);
					}
				}
				else if (targetObject.getClass() == physical_asset::NVDIMM_CREATIONCLASSNAME)
				{
					// single device
					if (examineOption)
					{
						std::string version;
						framework::return_codes rc = examineFwImage(
								targetObject.getKeyValue(TAG_KEY).stringValue(),
								absPath, version);
						if (rc == framework::REQUIRES_FORCE)
						{
							wbemRc = SWINSTALLSERVICE_ERR_DOWNGRADE_NOT_SUPPORTED;
						}
						else if (rc != framework::SUCCESS)
						{
							wbemRc = SWINSTALLSERVICE_ERR_NOT_APPLICABLE_TO_TARGET;
						}
					}
					else
					{
						installFromPath(targetObject.getKeyValue(TAG_KEY).stringValue(),
								absPath, rebootOption, forceOption);
					}
				}
				else
				{
					httpRc = framework::CIM_ERR_INVALID_PARAMETER;
				}
			}
		}
		catch (wbem::framework::ExceptionBadParameter &)
		{
			wbemRc = SWINSTALLSERVICE_ERR_INVALID_PARAMETER;
		}
		catch (wbem::exception::NvmExceptionLibError &e)
		{
			wbemRc = getReturnCodeFromLibException(e);
		}
		catch (wbem::framework::ExceptionNoMemory &)
		{
			wbemRc = SWINSTALLSERVICE_ERR_NOT_ENOUGH_MEMORY;
		}
		catch (wbem::framework::ExceptionNotSupported &)
		{
			wbemRc = SWINSTALLSERVICE_ERR_FAILED;
		}
		catch (wbem::framework::Exception &)
		{
			wbemRc = SWINSTALLSERVICE_ERR_FAILED;
		}
	}
	else
	{
		httpRc = framework::CIM_ERR_METHOD_NOT_AVAILABLE;
	}
	return httpRc;
}
Пример #17
0
/*
 * Create an Instance that represents an indication.
 * 		className: name of the indication. (InstCreation, InstDeletion, InstModification)
 * 		pSourcePath: object path to the instance being created, deleted, modified
 * 		pSource: instance being created, deleted, modified
 * 		pPrevious: if is an InstModification, this is the instance before being modified
 * 		pChangedProps: if is an InstModification, this is the list of properties changed
 *
 */
wbem::framework::Instance *wbem::indication::InstIndicationFactory::createIndicationInstance(
		const std::string &className,
		const NVM_UINT64 indicationTime,
		framework::ObjectPath *pSourcePath,
		framework::Instance *pSource,
		framework::Instance *pPrevious,
		framework::STR_LIST * pChangedProps)
{
	LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);
	wbem::framework::attributes_t keys;
	wbem::framework::ObjectPath path(wbem::server::getHostName(),
			wbem::NVM_NAMESPACE, className, keys);
	framework::Instance *pResult = new wbem::framework::Instance(path);
	if (pSource  == NULL)
	{
		COMMON_LOG_ERROR("pSource is NULL");
	}
	else if (pSourcePath == NULL)
	{
		COMMON_LOG_ERROR("pSourcePath is NULL");
	}
	else
	{
		// SourceInstance
		framework::Attribute targetAttribute = framework::Attribute(pSource->getCimXml(),	false);
		targetAttribute.setIsEmbedded(true);
		pResult->setAttribute(SOURCEINSTANCE, targetAttribute);

#ifdef __WINDOWS__
		// Unique value that indicates the time at which the event was generated. This is a 64-bit value that represents
		// the number of 100-nanosecond intervals after January 1, 1601. The information is in the
		// Coordinated Universal Time (UTC) format.
		pResult->setAttribute(TIMECREATED_KEY, framework::Attribute((NVM_UINT64)indicationTime,
				wbem::framework::DATETIME_SUBTYPE_DATETIME, false));

		if (pPrevious) // must be an __InstancetModificationEvent
		{
			framework::Attribute previousAttribute = framework::Attribute(pPrevious->getCimXml(), false);
			previousAttribute.setIsEmbedded(true);
			pResult->setAttribute(PREVIOUSINSTANCE_KEY, previousAttribute);
		}
#else

		// Indication Time
		pResult->setAttribute(INDICATIONTIME_KEY, framework::Attribute((NVM_UINT64)indicationTime,
				wbem::framework::DATETIME_SUBTYPE_DATETIME, false));

		// SourceInstanceModelPath
		pResult->setAttribute(SOURCEINSTANCEMODELPATH_KEY,
				framework::Attribute(pSourcePath->asString(), false));

		if (pPrevious && pChangedProps) // must be an instModificationEvent
		{
			pResult->setAttribute(CHANGEDPROPERTYNAMES_KEY,
					framework::Attribute(*pChangedProps, false));

			framework::Attribute previousInstance(pPrevious->getCimXml(), false);
			previousInstance.setIsEmbedded(true);
			pResult->setAttribute(PREVIOUSINSTANCE_KEY, previousInstance);
		}
#endif
	}

	return pResult;
}
Пример #18
0
/*
 * Populate the emulated bios large input mailbox
 */
int bios_write_large_payload(struct ndctl_dimm *p_dimm, struct fw_cmd *p_fw_cmd)
{
	COMMON_LOG_ENTRY();
	int rc = NVM_SUCCESS;
	struct pt_bios_get_size mb_size;

	if (!p_dimm)
	{
		COMMON_LOG_ERROR("Invalid parameter, Dimm is null");
		rc = NVM_ERR_INVALIDPARAMETER;
	}
	else if ((rc = bios_get_payload_size(p_dimm, &mb_size)) == NVM_SUCCESS)
	{
		if (mb_size.large_input_payload_size < p_fw_cmd->large_input_payload_size)
		{
			rc = NVM_ERR_BADSIZE;
		}
		else
		{
			unsigned int transfer_size = mb_size.rw_size;
			unsigned int current_offset = 0;

			while (current_offset < p_fw_cmd->large_input_payload_size &&
					rc == NVM_SUCCESS)
			{
				if ((current_offset + mb_size.rw_size) > p_fw_cmd->large_input_payload_size)
				{
					transfer_size = p_fw_cmd->large_input_payload_size - current_offset;
				}

				BIOS_INPUT(bios_input_payload, transfer_size);
				struct bios_input_payload *p_dsm_input = calloc(1,
					sizeof (struct bios_input_payload));
				if (p_dsm_input)
				{
					struct ndctl_cmd *p_vendor_cmd = NULL;
					if ((p_vendor_cmd = ndctl_dimm_cmd_new_vendor_specific(
							p_dimm, BUILD_DSM_OPCODE(BIOS_EMULATED_COMMAND,
							SUBOP_WRITE_LARGE_PAYLOAD_INPUT),
							sizeof (*p_dsm_input), 0)) == NULL)
					{
						COMMON_LOG_ERROR("Failed to get vendor command from driver");
						rc = NVM_ERR_DRIVERFAILED;
					}
					else
					{
						p_dsm_input->size = transfer_size;
						p_dsm_input->offset = current_offset;

						memmove(p_dsm_input->buffer,
							p_fw_cmd->large_input_payload + current_offset,
							sizeof (p_dsm_input->buffer));

						NVM_SIZE bytes_written = ndctl_cmd_vendor_set_input(
							p_vendor_cmd, p_dsm_input, sizeof (*p_dsm_input));

						if (bytes_written != sizeof (*p_dsm_input))
						{
							COMMON_LOG_ERROR("Failed to write input payload");
							rc = NVM_ERR_DRIVERFAILED;
						}
						else if (((rc = linux_err_to_nvm_lib_err(ndctl_cmd_submit(
								p_vendor_cmd))) == NVM_SUCCESS) &&
								((rc = dsm_err_to_nvm_lib_err(
								ndctl_cmd_get_firmware_status(p_vendor_cmd))) == NVM_SUCCESS))
						{
							current_offset += transfer_size;
						}

						ndctl_cmd_unref(p_vendor_cmd);
					}
					free(p_dsm_input);
				}
				else
				{
					COMMON_LOG_ERROR("Failed to allocate memory for BIOS input payload");
					rc = NVM_ERR_NOMEMORY;
				}
			} // end while

			if (current_offset != p_fw_cmd->large_input_payload_size)
			{
				COMMON_LOG_ERROR("Failed to write large payload");
				rc = NVM_ERR_UNKNOWN;
			}
		}
	}

	COMMON_LOG_EXIT_RETURN_I(rc);
	return rc;
}
Пример #19
0
/*
 * Run the security check diagnostic algorithm
 */
int diag_security_check(const struct diagnostic *p_diagnostic, NVM_UINT32 *p_results)
{
	COMMON_LOG_ENTRY();
	int rc = NVM_SUCCESS;
	int dev_count = 0;
	*p_results = 0;

	// clear previous results
	diag_clear_results(EVENT_TYPE_DIAG_SECURITY, 0, NULL);

	if ((rc = IS_NVM_FEATURE_SUPPORTED(security_diagnostic)) != NVM_SUCCESS)
	{
		COMMON_LOG_ERROR("The security diagnostic is not supported.");
	}
	else
	{
		dev_count = nvm_get_device_count();
		if (dev_count == 0)
		{
			store_event_by_parts(EVENT_TYPE_DIAG_SECURITY, EVENT_SEVERITY_WARN,
					EVENT_CODE_DIAG_SECURITY_NO_DIMMS, NULL, 0, NULL, NULL, NULL,
					DIAGNOSTIC_RESULT_ABORTED);
			(*p_results)++;
		}
		else if (dev_count > 0)
		{
			// get device_discovery information of all dimms
			struct device_discovery dimms[dev_count];
			int manageable_dev_count = 0;
			dev_count = nvm_get_devices(dimms, dev_count);
			if (dev_count > 0)
			{
				rc = NVM_SUCCESS;
				// count the number of dimms in each security state.
				int security_state_count = (int)LOCK_STATE_NOT_SUPPORTED;

				int count[security_state_count+1];
				memset(count, 0, sizeof (int) * (security_state_count + 1));
				for (int i = 0; i < dev_count; i++)
				{
					// only take dimms that are manageable into account
					if (dimms[i].manageability == MANAGEMENT_VALIDCONFIG)
						{
							count[dimms[i].lock_state]++;
							manageable_dev_count++;
						}
				}

				// check if all manageable dimms are security not supported
				if ((count[LOCK_STATE_NOT_SUPPORTED] == manageable_dev_count) &&
						(!(p_diagnostic->excludes &
								DIAG_THRESHOLD_SECURITY_ALL_NOTSUPPORTED)))
				{
					store_event_by_parts(EVENT_TYPE_DIAG_SECURITY,
							EVENT_SEVERITY_WARN,
							EVENT_CODE_DIAG_SECURITY_ALL_NOTSUPPORTED, NULL, 0, NULL,
							NULL, NULL, DIAGNOSTIC_RESULT_FAILED);
					(*p_results)++;
				}
				// check if all manageable dimms are disabled
				else if ((count[LOCK_STATE_DISABLED] == manageable_dev_count) &&
					(!(p_diagnostic->excludes & DIAG_THRESHOLD_SECURITY_ALL_DISABLED)))
				{
					store_event_by_parts(EVENT_TYPE_DIAG_SECURITY,
							EVENT_SEVERITY_WARN,
							EVENT_CODE_DIAG_SECURITY_ALL_DISABLED, NULL, 0, NULL,
							NULL, NULL, DIAGNOSTIC_RESULT_FAILED);
					(*p_results)++;
				}

				if (*p_results == 0)
				{
					// check if all manageable dimms have the same security state
					if (!(p_diagnostic->excludes & DIAG_THRESHOLD_SECURITY_CONSISTENT))
					{
						char inconsistent_security_state_event_arg_str[NVM_EVENT_ARG_LEN];
						NVM_BOOL inconsistent_flag = 0;
						for (int j = 0; j < security_state_count; j++)
						{
							// check if security settings are inconsistent
							if (count[j] > 0 && count[j] != manageable_dev_count)
							{
								// appending to the argument
								if (inconsistent_flag)
								{
									s_strcat(inconsistent_security_state_event_arg_str,
											NVM_EVENT_ARG_LEN, ", ");
								}
								char arg_str_security_state[NVM_EVENT_ARG_LEN];
								s_snprintf(arg_str_security_state, NVM_EVENT_ARG_LEN,
										"%d %s", count[j], lock_state_strings[j]);
								s_strcat(inconsistent_security_state_event_arg_str,
										NVM_EVENT_ARG_LEN, arg_str_security_state);
								inconsistent_flag = 1;
							}
						}

						if (inconsistent_flag)
						{
							store_event_by_parts(EVENT_TYPE_DIAG_SECURITY,
									EVENT_SEVERITY_WARN,
									EVENT_CODE_DIAG_SECURITY_INCONSISTENT, NULL, 0,
									inconsistent_security_state_event_arg_str, NULL,
									NULL, DIAGNOSTIC_RESULT_FAILED);
							(*p_results)++;
						}
					}
				}

			} // nvm_get_devices failed
			else
			{
				rc = dev_count;
			}
		} // nvm_get_device_count failed
		else
		{
			rc = dev_count;
		}

		// add success message
		if ((rc == NVM_SUCCESS) && (*p_results == 0)) // No errors/warnings
		{
			// store success event
			store_event_by_parts(
				EVENT_TYPE_DIAG_SECURITY,
				EVENT_SEVERITY_INFO,
				EVENT_CODE_DIAG_SECURITY_SUCCESS,
				NULL,
				0,
				NULL,
				NULL,
				NULL,
				DIAGNOSTIC_RESULT_OK);
			(*p_results)++;
		}

	}

	COMMON_LOG_EXIT_RETURN_I(rc);
	return rc;
}
Пример #20
0
int nvm_get_jobs(struct job *p_jobs, const NVM_UINT32 count)
{
	COMMON_LOG_ENTRY();
	int rc = NVM_SUCCESS;
	int job_index = 0;

	if (check_caller_permissions() != NVM_SUCCESS)
	{
		rc = NVM_ERR_INVALIDPERMISSIONS;
	}
	else if (!is_supported_driver_available())
	{
		rc = NVM_ERR_BADDRIVER;
	}
	else if (p_jobs == NULL)
	{
		COMMON_LOG_ERROR("Invalid parameter, p_jobs is NULL");
		rc = NVM_ERR_INVALIDPARAMETER;
	}
	else if ((rc = get_job_count()) < 0)
	{
		COMMON_LOG_ERROR("Failed to retrieve job count.");
	}
	else if (rc > 0)
	{
		// clear the structure
		memset(p_jobs, 0, sizeof (struct job) * count);

		if ((rc = nvm_get_device_count()) >= 0)
		{
			int device_count = rc;
			struct device_discovery devices[rc];
			if ((rc = nvm_get_devices(devices, device_count)) > 0)
			{
				// iterate through all devices and add up the capacities
				for (int i = 0; i < device_count; i++)
				{
					if (job_index >= count)
					{
						rc = NVM_ERR_ARRAYTOOSMALL;
						COMMON_LOG_ERROR("Invalid parameter, "
								"count is smaller than number of jobs");
						break;
					}

					if (devices[i].manageability == MANAGEMENT_VALIDCONFIG)
					{
						struct pt_payload_sanitize_dimm_status sanitize_status;
						struct fw_cmd cmd;
						memset(&cmd, 0, sizeof (struct fw_cmd));
						cmd.device_handle = devices[i].device_handle.handle;
						cmd.opcode = PT_GET_SEC_INFO;
						cmd.sub_opcode = SUBOP_GET_SAN_STATE;
						cmd.output_payload_size = sizeof (sanitize_status);
						cmd.output_payload = &sanitize_status;
						if (NVM_SUCCESS != ioctl_passthrough_cmd(&cmd))
						{
							COMMON_LOG_ERROR_F(
									"Unable to get sanitize status for handle: [%d]",
									devices[i].device_handle.handle);
						}
						else
						{
							if (sanitize_status.state != SAN_IDLE)
							{
								if (sanitize_status.state == SAN_INPROGRESS)
								{
									p_jobs[job_index].status = NVM_JOB_STATUS_RUNNING;
								}
								else if (sanitize_status.state ==  SAN_COMPLETED)
								{
									p_jobs[job_index].status = NVM_JOB_STATUS_COMPLETE;
								}
								else
								{
									p_jobs[job_index].status = NVM_JOB_STATUS_UNKNOWN;
								}

								p_jobs[job_index].type = NVM_JOB_TYPE_SANITIZE;
								p_jobs[job_index].percent_complete = sanitize_status.progress;
								memmove(p_jobs[job_index].uid, devices[i].uid, NVM_MAX_UID_LEN);
								memmove(p_jobs[job_index].affected_element,
									devices[i].uid, NVM_MAX_UID_LEN);
								p_jobs[job_index].result = NULL;
								job_index++;
							}
						}
					}
					rc = job_index;
				}
			}
			else
			{
				COMMON_LOG_ERROR_F("Unable to get device discovery: rc = %d", rc);
			}
		}
		else
		{
			COMMON_LOG_ERROR_F("Unable to get device count: rc = %d", rc);
		}
	}
	return rc;
}
Пример #21
0
void monitor::EventMonitor::saveCurrentTopologyState(const DeviceMap &devices)
{
	LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);

	bool saved = true;

	PersistentStore *pStore = get_lib_store();
	if (pStore)
	{
		// Only keep the latest topology
		if (db_delete_all_topology_states(pStore) != DB_SUCCESS)
		{
			COMMON_LOG_ERROR("couldn't delete old topology_state");
			saved = false;
		}
		else
		{
			// Preserve topology state in config DB
			for (DeviceMap::const_iterator iter = devices.begin();
					iter != devices.end(); iter++)
			{
				const std::string &uidStr = iter->first;
				const struct deviceInfo &device = iter->second;

				// only store current devices
				if (device.discovered)
				{
					struct db_topology_state topoState;
					memset(&topoState, 0, sizeof(topoState));
					s_strcpy(topoState.uid, uidStr.c_str(), NVM_MAX_UID_LEN);
					topoState.device_handle = device.discovery.device_handle.handle;
					topoState.manufacturer = MANUFACTURER_TO_UINT(device.discovery.manufacturer);
					topoState.serial_num = SERIAL_NUMBER_TO_UINT(device.discovery.serial_number);
					memmove(topoState.model_num, device.discovery.model_number, NVM_MODEL_LEN);

					topoState.current_config_status = device.status.config_status;
					topoState.config_goal_status = CONFIG_GOAL_STATUS_UNKNOWN;

					struct config_goal goal;
					memset(&goal, 0, sizeof (goal));
					int rc = nvm_get_config_goal(device.discovery.uid, &goal);
					if (rc == NVM_SUCCESS)
					{
						topoState.config_goal_status = goal.status;
					}
					else if (rc == NVM_ERR_NOTFOUND)
					{
						COMMON_LOG_DEBUG_F("No goal for DIMM %s", uidStr.c_str());
					}
					else
					{
						COMMON_LOG_ERROR_F("Error fetching config goalfor DIMM %s: %d",
						                   uidStr.c_str(),
						                   rc);
					}

					if (db_add_topology_state(pStore, &topoState) != DB_SUCCESS)
					{
						COMMON_LOG_ERROR_F("couldn't add topology_state for DIMM %s",
								topoState.uid);
						saved = false;
						break;
					}
				}
			}
		}

		// everything succeeded
		if (saved)
		{
			add_config_value(SQL_KEY_TOPOLOGY_STATE_VALID, "1");
		}
	}
}
Пример #22
0
/*
 * Disables data at rest security and removes the passphrase.
 * The device will be unlocked if it is currently locked.
 */
int nvm_remove_passphrase(const NVM_UID device_uid,
		const NVM_PASSPHRASE passphrase, const NVM_SIZE passphrase_len)
{
	COMMON_LOG_ENTRY();
	int rc = NVM_SUCCESS;
	struct device_discovery discovery;

	// check user has permission to make changes
	if (check_caller_permissions() != COMMON_SUCCESS)
	{
		rc = NVM_ERR_INVALIDPERMISSIONS;
	}
	else if (!is_supported_driver_available())
	{
		rc = NVM_ERR_BADDRIVER;
	}
	else if ((rc = IS_NVM_FEATURE_SUPPORTED(modify_device_security)) != NVM_SUCCESS)
	{
		COMMON_LOG_ERROR("Modifying " NVM_DIMM_NAME " security is not supported.");
	}
	else if (device_uid == NULL)
	{
		COMMON_LOG_ERROR("Invalid parameter, device_uid is NULL");
		rc = NVM_ERR_INVALIDPARAMETER;
	}
	else if (((rc = check_passphrase(passphrase, passphrase_len)) == NVM_SUCCESS) &&
			((rc = exists_and_manageable(device_uid, &discovery, 1)) == NVM_SUCCESS) &&
			((rc = check_passphrase_capable(device_uid)) == NVM_SUCCESS) &&
			((rc = security_change_prepare(&discovery, passphrase, passphrase_len))
					== NVM_SUCCESS))
	{
		// send a pass through command to disable security
		struct pt_payload_passphrase input_payload;
		memset(&input_payload, 0, sizeof (input_payload));
		s_strncpy(input_payload.passphrase_current, NVM_PASSPHRASE_LEN,
				passphrase, passphrase_len);

		struct fw_cmd cmd;
		memset(&cmd, 0, sizeof (struct fw_cmd));
		cmd.device_handle = discovery.device_handle.handle;
		cmd.opcode = PT_SET_SEC_INFO;
		cmd.sub_opcode = SUBOP_DISABLE_PASS;
		cmd.input_payload_size = sizeof (input_payload);
		cmd.input_payload = &input_payload;
		rc = ioctl_passthrough_cmd(&cmd);
		if (rc == NVM_SUCCESS)
		{
			// Log an event indicating we successfully removed the passphrase
			NVM_EVENT_ARG uid_arg;
			uid_to_event_arg(device_uid, uid_arg);
			log_mgmt_event(EVENT_SEVERITY_INFO,
					EVENT_CODE_MGMT_SECURITY_PASSWORD_REMOVED,
					device_uid,
					0, // no action required
					uid_arg, NULL, NULL);
		}
		s_memset(&input_payload, sizeof (input_payload));

		// clear any device context - security state has likely changed
		invalidate_devices();
	}

	COMMON_LOG_EXIT_RETURN_I(rc);
	return rc;
}