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:

کامیت شده توسط
Dhaval Patel

والد
b261fe33db
کامیت
04fea2ede3
@@ -1448,6 +1448,14 @@ static ssize_t debugfs_misr_setup(struct file *file,
|
|||||||
display->misr_frame_count = frame_count;
|
display->misr_frame_count = frame_count;
|
||||||
|
|
||||||
mutex_lock(&display->display_lock);
|
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,
|
rc = dsi_display_clk_ctrl(display->dsi_clk_handle,
|
||||||
DSI_CORE_CLK, DSI_CLK_ON);
|
DSI_CORE_CLK, DSI_CLK_ON);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
@@ -1499,6 +1507,14 @@ static ssize_t debugfs_misr_read(struct file *file,
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
mutex_lock(&display->display_lock);
|
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,
|
rc = dsi_display_clk_ctrl(display->dsi_clk_handle,
|
||||||
DSI_CORE_CLK, DSI_CLK_ON);
|
DSI_CORE_CLK, DSI_CLK_ON);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
@@ -1596,6 +1612,15 @@ static ssize_t debugfs_esd_trigger_check(struct file *file,
|
|||||||
|
|
||||||
display->esd_trigger = esd_trigger;
|
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) {
|
if (display->esd_trigger) {
|
||||||
DSI_INFO("ESD attack triggered by user\n");
|
DSI_INFO("ESD attack triggered by user\n");
|
||||||
rc = dsi_panel_trigger_esd_attack(display->panel,
|
rc = dsi_panel_trigger_esd_attack(display->panel,
|
||||||
@@ -1607,6 +1632,8 @@ static ssize_t debugfs_esd_trigger_check(struct file *file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = len;
|
rc = len;
|
||||||
|
unlock:
|
||||||
|
mutex_unlock(&display->display_lock);
|
||||||
error:
|
error:
|
||||||
kfree(buf);
|
kfree(buf);
|
||||||
return rc;
|
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
|
* In trusted vm, the connectors will not be enabled
|
||||||
* until the HW resources are assigned and accepted.
|
* until the HW resources are assigned and accepted.
|
||||||
*/
|
*/
|
||||||
if (display->trusted_vm_env)
|
if (display->trusted_vm_env) {
|
||||||
display->is_active = false;
|
display->is_active = false;
|
||||||
else
|
display->hw_ownership = false;
|
||||||
|
} else {
|
||||||
display->is_active = true;
|
display->is_active = true;
|
||||||
|
display->hw_ownership = true;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
error_ctrl_put:
|
error_ctrl_put:
|
||||||
@@ -4168,6 +4198,7 @@ error_ctrl_put:
|
|||||||
dsi_ctrl_put(ctrl->ctrl);
|
dsi_ctrl_put(ctrl->ctrl);
|
||||||
dsi_phy_put(ctrl->phy);
|
dsi_phy_put(ctrl->phy);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5379,19 +5410,33 @@ end:
|
|||||||
|
|
||||||
static int dsi_display_pre_release(void *data)
|
static int dsi_display_pre_release(void *data)
|
||||||
{
|
{
|
||||||
|
struct dsi_display *display;
|
||||||
|
|
||||||
if (!data)
|
if (!data)
|
||||||
return -EINVAL;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dsi_display_pre_acquire(void *data)
|
static int dsi_display_pre_acquire(void *data)
|
||||||
{
|
{
|
||||||
|
struct dsi_display *display;
|
||||||
|
|
||||||
if (!data)
|
if (!data)
|
||||||
return -EINVAL;
|
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);
|
dsi_display_ctrl_irq_update((struct dsi_display *)data, true);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -7666,6 +7711,7 @@ int dsi_display_prepare(struct dsi_display *display)
|
|||||||
SDE_EVT32(SDE_EVTLOG_FUNC_ENTRY);
|
SDE_EVT32(SDE_EVTLOG_FUNC_ENTRY);
|
||||||
mutex_lock(&display->display_lock);
|
mutex_lock(&display->display_lock);
|
||||||
|
|
||||||
|
display->hw_ownership = true;
|
||||||
mode = display->panel->cur_mode;
|
mode = display->panel->cur_mode;
|
||||||
|
|
||||||
dsi_display_set_ctrl_esd_check_flag(display, false);
|
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",
|
DSI_ERR("[%s] panel post-unprepare failed, rc=%d\n",
|
||||||
display->name, rc);
|
display->name, rc);
|
||||||
}
|
}
|
||||||
|
display->hw_ownership = false;
|
||||||
|
|
||||||
mutex_unlock(&display->display_lock);
|
mutex_unlock(&display->display_lock);
|
||||||
|
|
||||||
|
@@ -187,6 +187,7 @@ struct dsi_display_ext_bridge {
|
|||||||
* @is_active: status of the display
|
* @is_active: status of the display
|
||||||
* @trusted_vm_env: Set to true, it the executing VM is Trusted VM.
|
* @trusted_vm_env: Set to true, it the executing VM is Trusted VM.
|
||||||
* Set to false, otherwise.
|
* 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.
|
* @tx_cmd_buf_ndx: Index to the DSI debugfs TX CMD buffer.
|
||||||
* @cmd_set: Debugfs TX cmd set.
|
* @cmd_set: Debugfs TX cmd set.
|
||||||
* @enabled: Boolean to indicate display enabled.
|
* @enabled: Boolean to indicate display enabled.
|
||||||
@@ -287,6 +288,7 @@ struct dsi_display {
|
|||||||
bool is_active;
|
bool is_active;
|
||||||
|
|
||||||
bool trusted_vm_env;
|
bool trusted_vm_env;
|
||||||
|
bool hw_ownership;
|
||||||
|
|
||||||
int tx_cmd_buf_ndx;
|
int tx_cmd_buf_ndx;
|
||||||
struct dsi_panel_cmd_set cmd_set;
|
struct dsi_panel_cmd_set cmd_set;
|
||||||
|
مرجع در شماره جدید
Block a user