Esempio n. 1
0
/*
 * vb2_check_recovery_request looks up different components to identify if there
 * is a recovery request and returns appropriate reason code:
 * 1. Checks if recovery mode is initiated by EC. If yes, returns
 * VB2_RECOVERY_RO_MANUAL.
 * 2. Checks if recovery request is present in VBNV and returns the code read
 * from it.
 * 3. Checks recovery request in handoff for stages post-cbmem.
 * 4. For non-CBMEM stages, check if vboot verification is done and look-up
 * selected region to identify if vboot_refence library has requested recovery
 * path. If yes, return the reason code from shared data.
 * 5. If nothing applies, return 0 indicating no recovery request.
 */
int vboot_check_recovery_request(void)
{
	int reason = 0;

	/* EC-initiated recovery. */
	if (get_recovery_mode_switch())
		return VB2_RECOVERY_RO_MANUAL;

	/* Recovery request in VBNV. */
	if ((reason = get_recovery_mode_from_vbnv()) != 0)
		return reason;

	/*
	 * Check recovery flag in vboot_handoff for stages post CBMEM coming
	 * online. Since for some stages there is no way to know if cbmem has
	 * already come online, try looking up handoff anyways. If it fails,
	 * flow will fallback to looking up shared data.
	 */
	if (cbmem_possibly_online() &&
	    ((reason = vboot_handoff_get_recovery_reason()) != 0))
		return reason;

	/*
	 * For stages where CBMEM might not be online, identify if vboot
	 * verification is already complete and no slot was selected
	 * i.e. recovery path was requested.
	 */
	if (vboot_possibly_executed() && vb2_logic_executed() &&
	    !vb2_is_slot_selected())
		return vb2_get_recovery_reason_shared_data();

	return 0;
}
Esempio n. 2
0
int vboot_developer_mode_enabled(void)
{
	if (!IS_ENABLED(CONFIG_VBOOT))
		return 0;

	if (get_developer_mode_switch())
		return 1;

	if (cbmem_possibly_online() && vboot_handoff_check_developer_flag())
		return 1;

	return 0;
}
Esempio n. 3
0
struct vboot_working_data * const vboot_get_working_data(void)
{
	struct vboot_working_data *wd = NULL;

	if (cbmem_possibly_online())
		wd = cbmem_find(CBMEM_ID_VBOOT_WORKBUF);

	if (wd == NULL && CONFIG(VBOOT_STARTS_IN_BOOTBLOCK) &&
	    preram_symbols_available())
		wd = (struct vboot_working_data *)_vboot2_work;

	assert(wd != NULL);

	return wd;
}
Esempio n. 4
0
static struct tcpa_table *tcpa_log_init(void)
{
	MAYBE_STATIC struct tcpa_table *tclt = NULL;

	/* We are dealing here with pre CBMEM environment.
	 * If cbmem isn't available use CAR or SRAM */
	if (!cbmem_possibly_online() &&
		!CONFIG(VBOOT_RETURN_FROM_VERSTAGE))
		return (struct tcpa_table *)_vboot2_tpm_log;
	else if (ENV_ROMSTAGE &&
		!CONFIG(VBOOT_RETURN_FROM_VERSTAGE)) {
		tclt = tcpa_cbmem_init();
		if (!tclt)
			return (struct tcpa_table *)_vboot2_tpm_log;
	} else {
		tclt = tcpa_cbmem_init();
	}

	return tclt;
}
Esempio n. 5
0
static struct tcpa_table *tcpa_cbmem_init(void)
{
	MAYBE_STATIC struct tcpa_table *tclt = NULL;
	if (tclt)
		return tclt;

	if (cbmem_possibly_online()) {
		tclt = cbmem_find(CBMEM_ID_TCPA_LOG);
		if (!tclt) {
			size_t tcpa_log_len = sizeof(struct tcpa_table) +
			MAX_TCPA_LOG_ENTRIES * sizeof(struct tcpa_entry);
			tclt = cbmem_add(CBMEM_ID_TCPA_LOG, tcpa_log_len);
			if (tclt) {
				tclt->max_entries = MAX_TCPA_LOG_ENTRIES;
				tclt->num_entries = 0;
			}
		}
	}
	return tclt;
}