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

Commit 8f957517 authored by Veera Sundaram Sankaran's avatar Veera Sundaram Sankaran
Browse files

disp: msm: dsi: avoid debugfs HW access based on HW ownership



Add VM ownership checks before accessing the HW through the debugfs
path in dsi display/ctrl modules to avoid illegal access.

Change-Id: Ia6e2ab0ef60d0f11e5945a63885d939db2ef78b0
Signed-off-by: default avatarVeera Sundaram Sankaran <veeras@codeaurora.org>
parent 4c29eaf3
Loading
Loading
Loading
Loading
+49 −3
Original line number Diff line number Diff line
@@ -1383,6 +1383,14 @@ static ssize_t debugfs_misr_setup(struct file *file,
	display->misr_frame_count = frame_count;

	mutex_lock(&display->display_lock);

	if (!display->hw_ownership) {
		DSI_DEBUG("[%s] op not supported due to HW unavailability\n",
				display->name);
		rc = -EOPNOTSUPP;
		goto unlock;
	}

	rc = dsi_display_clk_ctrl(display->dsi_clk_handle,
			DSI_CORE_CLK, DSI_CLK_ON);
	if (rc) {
@@ -1434,6 +1442,14 @@ static ssize_t debugfs_misr_read(struct file *file,
		return -ENOMEM;

	mutex_lock(&display->display_lock);

	if (!display->hw_ownership) {
		DSI_DEBUG("[%s] op not supported due to HW unavailability\n",
				display->name);
		rc = -EOPNOTSUPP;
		goto error;
	}

	rc = dsi_display_clk_ctrl(display->dsi_clk_handle,
			DSI_CORE_CLK, DSI_CLK_ON);
	if (rc) {
@@ -1531,6 +1547,15 @@ static ssize_t debugfs_esd_trigger_check(struct file *file,

	display->esd_trigger = esd_trigger;

	mutex_lock(&display->display_lock);

	if (!display->hw_ownership) {
		DSI_DEBUG("[%s] op not supported due to HW unavailability\n",
				display->name);
		rc = -EOPNOTSUPP;
		goto unlock;
	}

	if (display->esd_trigger) {
		DSI_INFO("ESD attack triggered by user\n");
		rc = dsi_panel_trigger_esd_attack(display->panel,
@@ -1542,6 +1567,8 @@ static ssize_t debugfs_esd_trigger_check(struct file *file,
	}

	rc = len;
unlock:
	mutex_unlock(&display->display_lock);
error:
	kfree(buf);
	return rc;
@@ -4159,10 +4186,13 @@ static int dsi_display_res_init(struct dsi_display *display)
	 * In trusted vm, the connectors will not be enabled
	 * until the HW resources are assigned and accepted.
	 */
	if (display->trusted_vm_env)
	if (display->trusted_vm_env) {
		display->is_active = false;
	else
		display->hw_ownership = false;
	} else {
		display->is_active = true;
		display->hw_ownership = true;
	}

	return 0;
error_ctrl_put:
@@ -5405,19 +5435,33 @@ static int dsi_display_get_io_resources(struct msm_io_res *io_res, void *data)

static int dsi_display_pre_release(void *data)
{
	struct dsi_display *display;

	if (!data)
		return -EINVAL;

	dsi_display_ctrl_irq_update((struct dsi_display *)data, false);
	display = (struct dsi_display *)data;
	mutex_lock(&display->display_lock);
	display->hw_ownership = false;
	mutex_unlock(&display->display_lock);

	dsi_display_ctrl_irq_update(display, false);

	return 0;
}

static int dsi_display_pre_acquire(void *data)
{
	struct dsi_display *display;

	if (!data)
		return -EINVAL;

	display = (struct dsi_display *)data;
	mutex_lock(&display->display_lock);
	display->hw_ownership = true;
	mutex_unlock(&display->display_lock);

	dsi_display_ctrl_irq_update((struct dsi_display *)data, true);

	return 0;
@@ -7651,6 +7695,7 @@ int dsi_display_prepare(struct dsi_display *display)
	SDE_EVT32(SDE_EVTLOG_FUNC_ENTRY);
	mutex_lock(&display->display_lock);

	display->hw_ownership = true;
	mode = display->panel->cur_mode;

	dsi_display_set_ctrl_esd_check_flag(display, false);
@@ -8508,6 +8553,7 @@ int dsi_display_unprepare(struct dsi_display *display)
			DSI_ERR("[%s] panel post-unprepare failed, rc=%d\n",
			       display->name, rc);
	}
	display->hw_ownership = false;

	mutex_unlock(&display->display_lock);

+2 −0
Original line number Diff line number Diff line
@@ -192,6 +192,7 @@ struct dsi_display_ext_bridge {
 * @is_active:        status of the display
 * @trusted_vm_env:   Set to true, it the executing VM is Trusted VM.
 *                    Set to false, otherwise.
 * @hw_ownership:     Indicates if VM owns the hardware resources.
 * @tx_cmd_buf_ndx:   Index to the DSI debugfs TX CMD buffer.
 * @cmd_set:	      Debugfs TX cmd set.
 * @enabled:	      Boolean to indicate display enabled.
@@ -290,6 +291,7 @@ struct dsi_display {
	bool is_active;

	bool trusted_vm_env;
	bool hw_ownership;

	int tx_cmd_buf_ndx;
	struct dsi_panel_cmd_set cmd_set;