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: Veera Sundaram Sankaran <veeras@codeaurora.org>
This commit is contained in:

committato da
Dhaval Patel

parent
b261fe33db
commit
04fea2ede3
@@ -1448,6 +1448,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) {
|
||||
@@ -1499,6 +1507,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) {
|
||||
@@ -1596,6 +1612,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,
|
||||
@@ -1607,6 +1632,8 @@ static ssize_t debugfs_esd_trigger_check(struct file *file,
|
||||
}
|
||||
|
||||
rc = len;
|
||||
unlock:
|
||||
mutex_unlock(&display->display_lock);
|
||||
error:
|
||||
kfree(buf);
|
||||
return rc;
|
||||
@@ -4156,10 +4183,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:
|
||||
@@ -4168,6 +4198,7 @@ error_ctrl_put:
|
||||
dsi_ctrl_put(ctrl->ctrl);
|
||||
dsi_phy_put(ctrl->phy);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -5379,19 +5410,33 @@ end:
|
||||
|
||||
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;
|
||||
@@ -7666,6 +7711,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);
|
||||
@@ -8573,6 +8619,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);
|
||||
|
||||
|
@@ -187,6 +187,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.
|
||||
@@ -287,6 +288,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;
|
||||
|
Fai riferimento in un nuovo problema
Block a user