* [PATCH v2] usb: misc: qcom_eud: Access EUD_MODE_MANAGER2 through secure calls
@ 2025-06-27 12:51 Komal Bajaj
2025-06-28 5:44 ` Dmitry Baryshkov
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Komal Bajaj @ 2025-06-27 12:51 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-arm-msm, linux-usb, linux-kernel, Souradeep Chowdhury,
Konrad Dybcio
EUD_MODE_MANAGER2 register is mapped to a memory region that is marked
as read-only for HLOS, enforcing access restrictions that prohibit
direct memory-mapped writes via writel().
Attempts to write to this region from HLOS can result in silent failures
or memory access violations, particularly when toggling EUD (Embedded
USB Debugger) state. To ensure secure register access, modify the driver
to use qcom_scm_io_writel(), which routes the write operation to Qualcomm
Secure Channel Monitor (SCM). SCM has the necessary permissions to access
protected memory regions, enabling reliable control over EUD state.
SC7280, the only user of EUD is also affected, indicating that this could
never have worked on a properly fused device.
Fixes: 9a1bf58ccd44 ("usb: misc: eud: Add driver support for Embedded USB Debugger(EUD)")
Signed-off-by: Melody Olvera <quic_molvera@quicinc.com>
Signed-off-by: Komal Bajaj <komal.bajaj@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
---
Changes in v2:
* Drop separate compatible to be added for secure eud
* Use secure call to access EUD mode manager register
* Link to v1: https://lore.kernel.org/all/20240807183205.803847-1-quic_molvera@quicinc.com/
drivers/usb/misc/qcom_eud.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c
index 83079c414b4f..30c999c49eb0 100644
--- a/drivers/usb/misc/qcom_eud.c
+++ b/drivers/usb/misc/qcom_eud.c
@@ -16,6 +16,8 @@
#include <linux/sysfs.h>
#include <linux/usb/role.h>
+#include <linux/firmware/qcom/qcom_scm.h>
+
#define EUD_REG_INT1_EN_MASK 0x0024
#define EUD_REG_INT_STATUS_1 0x0044
#define EUD_REG_CTL_OUT_1 0x0074
@@ -34,7 +36,7 @@ struct eud_chip {
struct device *dev;
struct usb_role_switch *role_sw;
void __iomem *base;
- void __iomem *mode_mgr;
+ phys_addr_t mode_mgr;
unsigned int int_status;
int irq;
bool enabled;
@@ -43,10 +45,14 @@ struct eud_chip {
static int enable_eud(struct eud_chip *priv)
{
+ int ret;
+
writel(EUD_ENABLE, priv->base + EUD_REG_CSR_EUD_EN);
writel(EUD_INT_VBUS | EUD_INT_SAFE_MODE,
priv->base + EUD_REG_INT1_EN_MASK);
- writel(1, priv->mode_mgr + EUD_REG_EUD_EN2);
+ ret = qcom_scm_io_writel(priv->mode_mgr + EUD_REG_EUD_EN2, 1);
+ if (ret)
+ return ret;
return usb_role_switch_set_role(priv->role_sw, USB_ROLE_DEVICE);
}
@@ -54,7 +60,7 @@ static int enable_eud(struct eud_chip *priv)
static void disable_eud(struct eud_chip *priv)
{
writel(0, priv->base + EUD_REG_CSR_EUD_EN);
- writel(0, priv->mode_mgr + EUD_REG_EUD_EN2);
+ qcom_scm_io_writel(priv->mode_mgr + EUD_REG_EUD_EN2, 0);
}
static ssize_t enable_show(struct device *dev,
@@ -178,6 +184,7 @@ static void eud_role_switch_release(void *data)
static int eud_probe(struct platform_device *pdev)
{
struct eud_chip *chip;
+ struct resource *res;
int ret;
chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
@@ -200,9 +207,10 @@ static int eud_probe(struct platform_device *pdev)
if (IS_ERR(chip->base))
return PTR_ERR(chip->base);
- chip->mode_mgr = devm_platform_ioremap_resource(pdev, 1);
- if (IS_ERR(chip->mode_mgr))
- return PTR_ERR(chip->mode_mgr);
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+ if (!res)
+ return -ENODEV;
+ chip->mode_mgr = res->start;
chip->irq = platform_get_irq(pdev, 0);
if (chip->irq < 0)
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] usb: misc: qcom_eud: Access EUD_MODE_MANAGER2 through secure calls
2025-06-27 12:51 [PATCH v2] usb: misc: qcom_eud: Access EUD_MODE_MANAGER2 through secure calls Komal Bajaj
@ 2025-06-28 5:44 ` Dmitry Baryshkov
2025-06-28 14:00 ` Konrad Dybcio
2025-06-28 14:30 ` Greg Kroah-Hartman
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Dmitry Baryshkov @ 2025-06-28 5:44 UTC (permalink / raw)
To: Komal Bajaj
Cc: Greg Kroah-Hartman, linux-arm-msm, linux-usb, linux-kernel,
Souradeep Chowdhury, Konrad Dybcio
On Fri, Jun 27, 2025 at 06:21:31PM +0530, Komal Bajaj wrote:
> EUD_MODE_MANAGER2 register is mapped to a memory region that is marked
> as read-only for HLOS, enforcing access restrictions that prohibit
> direct memory-mapped writes via writel().
>
> Attempts to write to this region from HLOS can result in silent failures
> or memory access violations, particularly when toggling EUD (Embedded
> USB Debugger) state. To ensure secure register access, modify the driver
> to use qcom_scm_io_writel(), which routes the write operation to Qualcomm
> Secure Channel Monitor (SCM). SCM has the necessary permissions to access
> protected memory regions, enabling reliable control over EUD state.
>
> SC7280, the only user of EUD is also affected, indicating that this could
> never have worked on a properly fused device.
Most likely SC7280 Chrome platforms were fused differently or used a
different configuration of the TZ.
The question is whether there can be other platforms (e.g. SC7180 Chrome
or SDM845 Cheeza prototypes) which should use direct register access
instead of going through the SCM.
>
> Fixes: 9a1bf58ccd44 ("usb: misc: eud: Add driver support for Embedded USB Debugger(EUD)")
> Signed-off-by: Melody Olvera <quic_molvera@quicinc.com>
> Signed-off-by: Komal Bajaj <komal.bajaj@oss.qualcomm.com>
> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> ---
> Changes in v2:
> * Drop separate compatible to be added for secure eud
> * Use secure call to access EUD mode manager register
> * Link to v1: https://lore.kernel.org/all/20240807183205.803847-1-quic_molvera@quicinc.com/
>
> drivers/usb/misc/qcom_eud.c | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] usb: misc: qcom_eud: Access EUD_MODE_MANAGER2 through secure calls
2025-06-28 5:44 ` Dmitry Baryshkov
@ 2025-06-28 14:00 ` Konrad Dybcio
0 siblings, 0 replies; 8+ messages in thread
From: Konrad Dybcio @ 2025-06-28 14:00 UTC (permalink / raw)
To: Dmitry Baryshkov, Komal Bajaj
Cc: Greg Kroah-Hartman, linux-arm-msm, linux-usb, linux-kernel,
Souradeep Chowdhury
On 6/28/25 7:44 AM, Dmitry Baryshkov wrote:
> On Fri, Jun 27, 2025 at 06:21:31PM +0530, Komal Bajaj wrote:
>> EUD_MODE_MANAGER2 register is mapped to a memory region that is marked
>> as read-only for HLOS, enforcing access restrictions that prohibit
>> direct memory-mapped writes via writel().
>>
>> Attempts to write to this region from HLOS can result in silent failures
>> or memory access violations, particularly when toggling EUD (Embedded
>> USB Debugger) state. To ensure secure register access, modify the driver
>> to use qcom_scm_io_writel(), which routes the write operation to Qualcomm
>> Secure Channel Monitor (SCM). SCM has the necessary permissions to access
>> protected memory regions, enabling reliable control over EUD state.
>>
>> SC7280, the only user of EUD is also affected, indicating that this could
>> never have worked on a properly fused device.
>
> Most likely SC7280 Chrome platforms were fused differently or used a
> different configuration of the TZ.
They were not fused for production, as I understand
> The question is whether there can be other platforms (e.g. SC7180 Chrome
> or SDM845 Cheeza prototypes) which should use direct register access
> instead of going through the SCM.
TF-A currently needs an update to the SCM MMIO R/W address whitelist,
but in any case, a write from !TZ is not going to be accepted by the
hardware
Konrad
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] usb: misc: qcom_eud: Access EUD_MODE_MANAGER2 through secure calls
2025-06-27 12:51 [PATCH v2] usb: misc: qcom_eud: Access EUD_MODE_MANAGER2 through secure calls Komal Bajaj
2025-06-28 5:44 ` Dmitry Baryshkov
@ 2025-06-28 14:30 ` Greg Kroah-Hartman
2025-06-28 14:36 ` Greg Kroah-Hartman
2025-06-30 18:11 ` kernel test robot
3 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2025-06-28 14:30 UTC (permalink / raw)
To: Komal Bajaj
Cc: linux-arm-msm, linux-usb, linux-kernel, Souradeep Chowdhury,
Konrad Dybcio
On Fri, Jun 27, 2025 at 06:21:31PM +0530, Komal Bajaj wrote:
> EUD_MODE_MANAGER2 register is mapped to a memory region that is marked
> as read-only for HLOS, enforcing access restrictions that prohibit
> direct memory-mapped writes via writel().
>
> Attempts to write to this region from HLOS can result in silent failures
> or memory access violations, particularly when toggling EUD (Embedded
> USB Debugger) state. To ensure secure register access, modify the driver
> to use qcom_scm_io_writel(), which routes the write operation to Qualcomm
> Secure Channel Monitor (SCM). SCM has the necessary permissions to access
> protected memory regions, enabling reliable control over EUD state.
>
> SC7280, the only user of EUD is also affected, indicating that this could
> never have worked on a properly fused device.
>
> Fixes: 9a1bf58ccd44 ("usb: misc: eud: Add driver support for Embedded USB Debugger(EUD)")
> Signed-off-by: Melody Olvera <quic_molvera@quicinc.com>
> Signed-off-by: Komal Bajaj <komal.bajaj@oss.qualcomm.com>
> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> ---
> Changes in v2:
> * Drop separate compatible to be added for secure eud
> * Use secure call to access EUD mode manager register
> * Link to v1: https://lore.kernel.org/all/20240807183205.803847-1-quic_molvera@quicinc.com/
>
> drivers/usb/misc/qcom_eud.c | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c
> index 83079c414b4f..30c999c49eb0 100644
> --- a/drivers/usb/misc/qcom_eud.c
> +++ b/drivers/usb/misc/qcom_eud.c
> @@ -16,6 +16,8 @@
> #include <linux/sysfs.h>
> #include <linux/usb/role.h>
>
> +#include <linux/firmware/qcom/qcom_scm.h>
> +
> #define EUD_REG_INT1_EN_MASK 0x0024
> #define EUD_REG_INT_STATUS_1 0x0044
> #define EUD_REG_CTL_OUT_1 0x0074
> @@ -34,7 +36,7 @@ struct eud_chip {
> struct device *dev;
> struct usb_role_switch *role_sw;
> void __iomem *base;
> - void __iomem *mode_mgr;
> + phys_addr_t mode_mgr;
> unsigned int int_status;
> int irq;
> bool enabled;
> @@ -43,10 +45,14 @@ struct eud_chip {
>
> static int enable_eud(struct eud_chip *priv)
> {
> + int ret;
> +
> writel(EUD_ENABLE, priv->base + EUD_REG_CSR_EUD_EN);
> writel(EUD_INT_VBUS | EUD_INT_SAFE_MODE,
> priv->base + EUD_REG_INT1_EN_MASK);
> - writel(1, priv->mode_mgr + EUD_REG_EUD_EN2);
> + ret = qcom_scm_io_writel(priv->mode_mgr + EUD_REG_EUD_EN2, 1);
> + if (ret)
> + return ret;
>
> return usb_role_switch_set_role(priv->role_sw, USB_ROLE_DEVICE);
> }
> @@ -54,7 +60,7 @@ static int enable_eud(struct eud_chip *priv)
> static void disable_eud(struct eud_chip *priv)
> {
> writel(0, priv->base + EUD_REG_CSR_EUD_EN);
> - writel(0, priv->mode_mgr + EUD_REG_EUD_EN2);
> + qcom_scm_io_writel(priv->mode_mgr + EUD_REG_EUD_EN2, 0);
> }
>
> static ssize_t enable_show(struct device *dev,
> @@ -178,6 +184,7 @@ static void eud_role_switch_release(void *data)
> static int eud_probe(struct platform_device *pdev)
> {
> struct eud_chip *chip;
> + struct resource *res;
> int ret;
>
> chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
> @@ -200,9 +207,10 @@ static int eud_probe(struct platform_device *pdev)
> if (IS_ERR(chip->base))
> return PTR_ERR(chip->base);
>
> - chip->mode_mgr = devm_platform_ioremap_resource(pdev, 1);
> - if (IS_ERR(chip->mode_mgr))
> - return PTR_ERR(chip->mode_mgr);
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> + if (!res)
> + return -ENODEV;
> + chip->mode_mgr = res->start;
>
> chip->irq = platform_get_irq(pdev, 0);
> if (chip->irq < 0)
> --
> 2.48.1
>
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- You have marked a patch with a "Fixes:" tag for a commit that is in an
older released kernel, yet you do not have a cc: stable line in the
signed-off-by area at all, which means that the patch will not be
applied to any older kernel releases. To properly fix this, please
follow the documented rules in the
Documentation/process/stable-kernel-rules.rst file for how to resolve
this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] usb: misc: qcom_eud: Access EUD_MODE_MANAGER2 through secure calls
2025-06-27 12:51 [PATCH v2] usb: misc: qcom_eud: Access EUD_MODE_MANAGER2 through secure calls Komal Bajaj
2025-06-28 5:44 ` Dmitry Baryshkov
2025-06-28 14:30 ` Greg Kroah-Hartman
@ 2025-06-28 14:36 ` Greg Kroah-Hartman
2025-07-08 5:53 ` Komal Bajaj
2025-06-30 18:11 ` kernel test robot
3 siblings, 1 reply; 8+ messages in thread
From: Greg Kroah-Hartman @ 2025-06-28 14:36 UTC (permalink / raw)
To: Komal Bajaj
Cc: linux-arm-msm, linux-usb, linux-kernel, Souradeep Chowdhury,
Konrad Dybcio
On Fri, Jun 27, 2025 at 06:21:31PM +0530, Komal Bajaj wrote:
> EUD_MODE_MANAGER2 register is mapped to a memory region that is marked
> as read-only for HLOS, enforcing access restrictions that prohibit
> direct memory-mapped writes via writel().
>
> Attempts to write to this region from HLOS can result in silent failures
> or memory access violations, particularly when toggling EUD (Embedded
> USB Debugger) state. To ensure secure register access, modify the driver
> to use qcom_scm_io_writel(), which routes the write operation to Qualcomm
> Secure Channel Monitor (SCM). SCM has the necessary permissions to access
> protected memory regions, enabling reliable control over EUD state.
>
> SC7280, the only user of EUD is also affected, indicating that this could
> never have worked on a properly fused device.
>
> Fixes: 9a1bf58ccd44 ("usb: misc: eud: Add driver support for Embedded USB Debugger(EUD)")
> Signed-off-by: Melody Olvera <quic_molvera@quicinc.com>
> Signed-off-by: Komal Bajaj <komal.bajaj@oss.qualcomm.com>
> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> ---
> Changes in v2:
> * Drop separate compatible to be added for secure eud
> * Use secure call to access EUD mode manager register
> * Link to v1: https://lore.kernel.org/all/20240807183205.803847-1-quic_molvera@quicinc.com/
>
> drivers/usb/misc/qcom_eud.c | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c
> index 83079c414b4f..30c999c49eb0 100644
> --- a/drivers/usb/misc/qcom_eud.c
> +++ b/drivers/usb/misc/qcom_eud.c
> @@ -16,6 +16,8 @@
> #include <linux/sysfs.h>
> #include <linux/usb/role.h>
>
> +#include <linux/firmware/qcom/qcom_scm.h>
Why the blank line before this #include line?
> +
> #define EUD_REG_INT1_EN_MASK 0x0024
> #define EUD_REG_INT_STATUS_1 0x0044
> #define EUD_REG_CTL_OUT_1 0x0074
> @@ -34,7 +36,7 @@ struct eud_chip {
> struct device *dev;
> struct usb_role_switch *role_sw;
> void __iomem *base;
> - void __iomem *mode_mgr;
> + phys_addr_t mode_mgr;
> unsigned int int_status;
> int irq;
> bool enabled;
> @@ -43,10 +45,14 @@ struct eud_chip {
>
> static int enable_eud(struct eud_chip *priv)
> {
> + int ret;
> +
> writel(EUD_ENABLE, priv->base + EUD_REG_CSR_EUD_EN);
> writel(EUD_INT_VBUS | EUD_INT_SAFE_MODE,
> priv->base + EUD_REG_INT1_EN_MASK);
> - writel(1, priv->mode_mgr + EUD_REG_EUD_EN2);
> + ret = qcom_scm_io_writel(priv->mode_mgr + EUD_REG_EUD_EN2, 1);
> + if (ret)
> + return ret;
So the previous writes are ok, but this one could fail? And if it does
fail, what did the previous writes cause to happen to the chip / system?
> return usb_role_switch_set_role(priv->role_sw, USB_ROLE_DEVICE);
> }
> @@ -54,7 +60,7 @@ static int enable_eud(struct eud_chip *priv)
> static void disable_eud(struct eud_chip *priv)
> {
> writel(0, priv->base + EUD_REG_CSR_EUD_EN);
> - writel(0, priv->mode_mgr + EUD_REG_EUD_EN2);
> + qcom_scm_io_writel(priv->mode_mgr + EUD_REG_EUD_EN2, 0);
No error checking needed?
> }
>
> static ssize_t enable_show(struct device *dev,
> @@ -178,6 +184,7 @@ static void eud_role_switch_release(void *data)
> static int eud_probe(struct platform_device *pdev)
> {
> struct eud_chip *chip;
> + struct resource *res;
> int ret;
>
> chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
> @@ -200,9 +207,10 @@ static int eud_probe(struct platform_device *pdev)
> if (IS_ERR(chip->base))
> return PTR_ERR(chip->base);
>
> - chip->mode_mgr = devm_platform_ioremap_resource(pdev, 1);
> - if (IS_ERR(chip->mode_mgr))
> - return PTR_ERR(chip->mode_mgr);
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> + if (!res)
> + return -ENODEV;
-ENOMEM perhaps?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] usb: misc: qcom_eud: Access EUD_MODE_MANAGER2 through secure calls
2025-06-27 12:51 [PATCH v2] usb: misc: qcom_eud: Access EUD_MODE_MANAGER2 through secure calls Komal Bajaj
` (2 preceding siblings ...)
2025-06-28 14:36 ` Greg Kroah-Hartman
@ 2025-06-30 18:11 ` kernel test robot
3 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2025-06-30 18:11 UTC (permalink / raw)
To: Komal Bajaj, Greg Kroah-Hartman
Cc: oe-kbuild-all, linux-arm-msm, linux-usb, linux-kernel,
Souradeep Chowdhury, Konrad Dybcio
Hi Komal,
kernel test robot noticed the following build errors:
[auto build test ERROR on usb/usb-testing]
[also build test ERROR on usb/usb-next usb/usb-linus linus/master v6.16-rc4 next-20250630]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Komal-Bajaj/usb-misc-qcom_eud-Access-EUD_MODE_MANAGER2-through-secure-calls/20250627-205244
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
patch link: https://lore.kernel.org/r/20250627125131.27606-1-komal.bajaj%40oss.qualcomm.com
patch subject: [PATCH v2] usb: misc: qcom_eud: Access EUD_MODE_MANAGER2 through secure calls
config: um-randconfig-r131-20250629 (https://download.01.org/0day-ci/archive/20250701/202507010127.xjmnq7A8-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250701/202507010127.xjmnq7A8-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507010127.xjmnq7A8-lkp@intel.com/
All errors (new ones prefixed by >>):
/usr/bin/ld: drivers/usb/misc/qcom_eud.o: in function `eud_remove':
>> qcom_eud.c:(.text+0x6da): undefined reference to `qcom_scm_io_writel'
/usr/bin/ld: drivers/usb/misc/qcom_eud.o: in function `enable_store':
qcom_eud.c:(.text+0x7c7): undefined reference to `qcom_scm_io_writel'
>> /usr/bin/ld: qcom_eud.c:(.text+0x848): undefined reference to `qcom_scm_io_writel'
collect2: error: ld returned 1 exit status
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] usb: misc: qcom_eud: Access EUD_MODE_MANAGER2 through secure calls
2025-06-28 14:36 ` Greg Kroah-Hartman
@ 2025-07-08 5:53 ` Komal Bajaj
2025-07-08 8:01 ` Greg Kroah-Hartman
0 siblings, 1 reply; 8+ messages in thread
From: Komal Bajaj @ 2025-07-08 5:53 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-arm-msm, linux-usb, linux-kernel, Souradeep Chowdhury,
Konrad Dybcio
On Sat, Jun 28, 2025 at 8:06 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Fri, Jun 27, 2025 at 06:21:31PM +0530, Komal Bajaj wrote:
> > EUD_MODE_MANAGER2 register is mapped to a memory region that is marked
> > as read-only for HLOS, enforcing access restrictions that prohibit
> > direct memory-mapped writes via writel().
> >
> > Attempts to write to this region from HLOS can result in silent failures
> > or memory access violations, particularly when toggling EUD (Embedded
> > USB Debugger) state. To ensure secure register access, modify the driver
> > to use qcom_scm_io_writel(), which routes the write operation to Qualcomm
> > Secure Channel Monitor (SCM). SCM has the necessary permissions to access
> > protected memory regions, enabling reliable control over EUD state.
> >
> > SC7280, the only user of EUD is also affected, indicating that this could
> > never have worked on a properly fused device.
> >
> > Fixes: 9a1bf58ccd44 ("usb: misc: eud: Add driver support for Embedded USB Debugger(EUD)")
> > Signed-off-by: Melody Olvera <quic_molvera@quicinc.com>
> > Signed-off-by: Komal Bajaj <komal.bajaj@oss.qualcomm.com>
> > Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> > ---
> > Changes in v2:
> > * Drop separate compatible to be added for secure eud
> > * Use secure call to access EUD mode manager register
> > * Link to v1: https://lore.kernel.org/all/20240807183205.803847-1-quic_molvera@quicinc.com/
> >
> > drivers/usb/misc/qcom_eud.c | 20 ++++++++++++++------
> > 1 file changed, 14 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c
> > index 83079c414b4f..30c999c49eb0 100644
> > --- a/drivers/usb/misc/qcom_eud.c
> > +++ b/drivers/usb/misc/qcom_eud.c
> > @@ -16,6 +16,8 @@
> > #include <linux/sysfs.h>
> > #include <linux/usb/role.h>
> >
> > +#include <linux/firmware/qcom/qcom_scm.h>
>
> Why the blank line before this #include line?
The qcom_scm.h header has been placed in a distinct paragraph to clearly
differentiate it from generic subsystem headers, with a blank line included
for visual distinction
>
> > +
> > #define EUD_REG_INT1_EN_MASK 0x0024
> > #define EUD_REG_INT_STATUS_1 0x0044
> > #define EUD_REG_CTL_OUT_1 0x0074
> > @@ -34,7 +36,7 @@ struct eud_chip {
> > struct device *dev;
> > struct usb_role_switch *role_sw;
> > void __iomem *base;
> > - void __iomem *mode_mgr;
> > + phys_addr_t mode_mgr;
> > unsigned int int_status;
> > int irq;
> > bool enabled;
> > @@ -43,10 +45,14 @@ struct eud_chip {
> >
> > static int enable_eud(struct eud_chip *priv)
> > {
> > + int ret;
> > +
> > writel(EUD_ENABLE, priv->base + EUD_REG_CSR_EUD_EN);
> > writel(EUD_INT_VBUS | EUD_INT_SAFE_MODE,
> > priv->base + EUD_REG_INT1_EN_MASK);
> > - writel(1, priv->mode_mgr + EUD_REG_EUD_EN2);
> > + ret = qcom_scm_io_writel(priv->mode_mgr + EUD_REG_EUD_EN2, 1);
> > + if (ret)
> > + return ret;
>
> So the previous writes are ok, but this one could fail? And if it does
> fail, what did the previous writes cause to happen to the chip / system?
Thanks for pointing that out. I will move the SCM write before the direct
register writes to avoid any inconsistent state if the SCM call fails
>
> > return usb_role_switch_set_role(priv->role_sw, USB_ROLE_DEVICE);
> > }
> > @@ -54,7 +60,7 @@ static int enable_eud(struct eud_chip *priv)
> > static void disable_eud(struct eud_chip *priv)
> > {
> > writel(0, priv->base + EUD_REG_CSR_EUD_EN);
> > - writel(0, priv->mode_mgr + EUD_REG_EUD_EN2);
> > + qcom_scm_io_writel(priv->mode_mgr + EUD_REG_EUD_EN2, 0);
>
> No error checking needed?
ACK
>
>
> > }
> >
> > static ssize_t enable_show(struct device *dev,
> > @@ -178,6 +184,7 @@ static void eud_role_switch_release(void *data)
> > static int eud_probe(struct platform_device *pdev)
> > {
> > struct eud_chip *chip;
> > + struct resource *res;
> > int ret;
> >
> > chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
> > @@ -200,9 +207,10 @@ static int eud_probe(struct platform_device *pdev)
> > if (IS_ERR(chip->base))
> > return PTR_ERR(chip->base);
> >
> > - chip->mode_mgr = devm_platform_ioremap_resource(pdev, 1);
> > - if (IS_ERR(chip->mode_mgr))
> > - return PTR_ERR(chip->mode_mgr);
> > + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> > + if (!res)
> > + return -ENODEV;
>
> -ENOMEM perhaps?
ACK
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] usb: misc: qcom_eud: Access EUD_MODE_MANAGER2 through secure calls
2025-07-08 5:53 ` Komal Bajaj
@ 2025-07-08 8:01 ` Greg Kroah-Hartman
0 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2025-07-08 8:01 UTC (permalink / raw)
To: Komal Bajaj
Cc: linux-arm-msm, linux-usb, linux-kernel, Souradeep Chowdhury,
Konrad Dybcio
On Tue, Jul 08, 2025 at 11:23:56AM +0530, Komal Bajaj wrote:
> On Sat, Jun 28, 2025 at 8:06 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > On Fri, Jun 27, 2025 at 06:21:31PM +0530, Komal Bajaj wrote:
> > > EUD_MODE_MANAGER2 register is mapped to a memory region that is marked
> > > as read-only for HLOS, enforcing access restrictions that prohibit
> > > direct memory-mapped writes via writel().
> > >
> > > Attempts to write to this region from HLOS can result in silent failures
> > > or memory access violations, particularly when toggling EUD (Embedded
> > > USB Debugger) state. To ensure secure register access, modify the driver
> > > to use qcom_scm_io_writel(), which routes the write operation to Qualcomm
> > > Secure Channel Monitor (SCM). SCM has the necessary permissions to access
> > > protected memory regions, enabling reliable control over EUD state.
> > >
> > > SC7280, the only user of EUD is also affected, indicating that this could
> > > never have worked on a properly fused device.
> > >
> > > Fixes: 9a1bf58ccd44 ("usb: misc: eud: Add driver support for Embedded USB Debugger(EUD)")
> > > Signed-off-by: Melody Olvera <quic_molvera@quicinc.com>
> > > Signed-off-by: Komal Bajaj <komal.bajaj@oss.qualcomm.com>
> > > Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> > > ---
> > > Changes in v2:
> > > * Drop separate compatible to be added for secure eud
> > > * Use secure call to access EUD mode manager register
> > > * Link to v1: https://lore.kernel.org/all/20240807183205.803847-1-quic_molvera@quicinc.com/
> > >
> > > drivers/usb/misc/qcom_eud.c | 20 ++++++++++++++------
> > > 1 file changed, 14 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c
> > > index 83079c414b4f..30c999c49eb0 100644
> > > --- a/drivers/usb/misc/qcom_eud.c
> > > +++ b/drivers/usb/misc/qcom_eud.c
> > > @@ -16,6 +16,8 @@
> > > #include <linux/sysfs.h>
> > > #include <linux/usb/role.h>
> > >
> > > +#include <linux/firmware/qcom/qcom_scm.h>
> >
> > Why the blank line before this #include line?
>
> The qcom_scm.h header has been placed in a distinct paragraph to clearly
> differentiate it from generic subsystem headers, with a blank line included
> for visual distinction
No need for this, it's pretty obvious this is the case when all in one
long list.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-07-08 8:01 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-27 12:51 [PATCH v2] usb: misc: qcom_eud: Access EUD_MODE_MANAGER2 through secure calls Komal Bajaj
2025-06-28 5:44 ` Dmitry Baryshkov
2025-06-28 14:00 ` Konrad Dybcio
2025-06-28 14:30 ` Greg Kroah-Hartman
2025-06-28 14:36 ` Greg Kroah-Hartman
2025-07-08 5:53 ` Komal Bajaj
2025-07-08 8:01 ` Greg Kroah-Hartman
2025-06-30 18:11 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).