Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 57562c50 authored by David Keitel's avatar David Keitel
Browse files

soc: peripheral-loader: only reclaim memory if it was assigned



In the error path of pil_boot, memory is attempted to be reclaimed
from the source VMID of both Linux and the subsystem. This may lead
to a panic if this attempted during one of the error conditions
previous to the assign call of the region for both Linux and the
subsystem.

Fix this by introducing a flag to track the state of the hypervisor
assignment.

Change-Id: I91ab134e645718c1c7c19969da80b879b53af6fa
CRs-Fixed: 957289
Signed-off-by: default avatarDavid Keitel <dkeitel@codeaurora.org>
parent 2f49086b
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
/* Copyright (c) 2010-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2010-2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -741,6 +741,7 @@ int pil_boot(struct pil_desc *desc)
	const struct firmware *fw;
	struct pil_priv *priv = desc->priv;
	bool mem_protect = false;
	bool hyp_assign = false;

	if (desc->shutdown_fail)
		pil_err(desc, "Subsystem shutdown failed previously!\n");
@@ -827,6 +828,7 @@ int pil_boot(struct pil_desc *desc)
								ret);
			goto err_deinit_image;
		}
		hyp_assign = true;
	}

	list_for_each_entry(seg, &desc->priv->segs, list) {
@@ -844,6 +846,7 @@ int pil_boot(struct pil_desc *desc)
							desc->name, ret);
			goto err_deinit_image;
		}
		hyp_assign = false;
	}

	ret = desc->ops->auth_and_reset(desc);
@@ -871,7 +874,8 @@ out:
	up_read(&pil_pm_rwsem);
	if (ret) {
		if (priv->region) {
			if (desc->subsys_vmid > 0 && !mem_protect) {
			if (desc->subsys_vmid > 0 && !mem_protect &&
					hyp_assign) {
				pil_reclaim_mem(desc, priv->region_start,
					(priv->region_end -
						priv->region_start),