From: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
To: Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Sumit Garg <sumit.garg@oss.qualcomm.com>,
Neil Armstrong <neil.armstrong@linaro.org>
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-remoteproc@vger.kernel.org,
Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Subject: [PATCH v5 4/6] remoteproc: qcom: pas: Map/unmap subsystem region before auth_and_reset
Date: Fri, 24 Jul 2026 23:58:56 +0530 [thread overview]
Message-ID: <20260724182858.1868271-5-mukesh.ojha@oss.qualcomm.com> (raw)
In-Reply-To: <20260724182858.1868271-1-mukesh.ojha@oss.qualcomm.com>
Qualcomm remoteproc drivers such as qcom_q6v5_mss, which do not use the
Peripheral Authentication Service (PAS), always map the MBA region before
use and unmap it once the usage is complete. This behavior was introduced
to avoid issues seen in the past where speculative accesses from the
application processor to the MBA region after it was assigned to the remote
Q6 led to an XPU violation. The issue was mitigated by unmapping the region
before handing control to the remote Q6.
Currently, most Qualcomm SoCs using the PAS driver run either with a
standalone QHEE or the Gunyah hypervisor. In these environments, the
hypervisor unmaps the Q6 memory from HLOS Stage-2 and remaps it into the
Q6 Stage-2 page table. As a result, speculative accesses from HLOS cannot
reach the region even if it remains mapped in HLOS Stage-1; therefore, XPU
violations cannot occur.
However, when the same SoC runs Linux at EL2, Linux itself must perform the
unmapping to avoid such issues. It is still correct to apply this mapping/
unmapping sequence even for SoCs that run under Gunyah, so this behavior
should not be conditional.
Introduce qcom_pas_ctx_map() in qcom_pas.h to centralise the ioremap_wc
pattern used by both qcom_q6v5_pas and qcom_mdt_pas_load, and use it in
both places.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
---
drivers/remoteproc/qcom_q6v5_pas.c | 35 ++++++++++++++++----------
drivers/soc/qcom/mdt_loader.c | 15 ++++++++---
include/linux/firmware/qcom/qcom_pas.h | 12 +++++++++
include/linux/soc/qcom/mdt_loader.h | 4 +--
4 files changed, 47 insertions(+), 19 deletions(-)
diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
index 997b3a7ce672..5cd34086ccac 100644
--- a/drivers/remoteproc/qcom_q6v5_pas.c
+++ b/drivers/remoteproc/qcom_q6v5_pas.c
@@ -150,7 +150,13 @@ static void qcom_pas_minidump(struct rproc *rproc)
if (rproc->dump_conf == RPROC_COREDUMP_DISABLED)
return;
+ pas->mem_region = qcom_pas_ctx_map(pas->pas_ctx);
+ if (!pas->mem_region)
+ return;
+
qcom_minidump(rproc, pas->minidump_id, qcom_pas_segment_dump);
+ iounmap(pas->mem_region);
+ pas->mem_region = NULL;
}
static int qcom_pas_pds_enable(struct qcom_pas *pas, struct device **pds,
@@ -243,8 +249,7 @@ static int qcom_pas_load(struct rproc *rproc, const struct firmware *fw)
}
ret = qcom_mdt_pas_load(pas->dtb_pas_ctx, pas->dtb_firmware,
- pas->dtb_firmware_name, (__force void *)pas->dtb_mem_region,
- &pas->dtb_mem_reloc);
+ pas->dtb_firmware_name, &pas->dtb_mem_reloc);
if (ret) {
qcom_pas_metadata_release(pas->dtb_pas_ctx);
release_firmware(pas->dtb_firmware);
@@ -318,7 +323,7 @@ static int qcom_pas_start(struct rproc *rproc)
}
ret = qcom_mdt_pas_load(pas->pas_ctx, pas->firmware, rproc->firmware,
- (__force void *)pas->mem_region, &pas->mem_reloc);
+ &pas->mem_reloc);
if (ret)
goto release_pas_metadata;
@@ -570,6 +575,19 @@ static int qcom_pas_attach(struct rproc *rproc)
return ret;
}
+static void qcom_pas_coredump(struct rproc *rproc)
+{
+ struct qcom_pas *pas = rproc->priv;
+
+ pas->mem_region = qcom_pas_ctx_map(pas->pas_ctx);
+ if (!pas->mem_region)
+ return;
+
+ rproc_coredump(rproc);
+ iounmap(pas->mem_region);
+ pas->mem_region = NULL;
+}
+
static const struct rproc_ops qcom_pas_ops = {
.unprepare = qcom_pas_unprepare,
.start = qcom_pas_start,
@@ -579,6 +597,7 @@ static const struct rproc_ops qcom_pas_ops = {
.load = qcom_pas_load,
.panic = qcom_pas_panic,
.attach = qcom_pas_attach,
+ .coredump = qcom_pas_coredump,
};
static const struct rproc_ops qcom_pas_minidump_ops = {
@@ -696,11 +715,6 @@ static int qcom_pas_alloc_memory_region(struct qcom_pas *pas)
pas->mem_phys = pas->mem_reloc = res.start;
pas->mem_size = resource_size(&res);
- pas->mem_region = devm_ioremap_resource_wc(pas->dev, &res);
- if (IS_ERR(pas->mem_region)) {
- dev_err(pas->dev, "unable to map memory region: %pR\n", &res);
- return PTR_ERR(pas->mem_region);
- }
pas->pas_ctx = devm_qcom_pas_context_alloc(pas->dev, pas->pas_id,
pas->mem_phys, pas->mem_size);
@@ -718,11 +732,6 @@ static int qcom_pas_alloc_memory_region(struct qcom_pas *pas)
pas->dtb_mem_phys = pas->dtb_mem_reloc = res.start;
pas->dtb_mem_size = resource_size(&res);
- pas->dtb_mem_region = devm_ioremap_resource_wc(pas->dev, &res);
- if (IS_ERR(pas->dtb_mem_region)) {
- dev_err(pas->dev, "unable to map dtb memory region: %pR\n", &res);
- return PTR_ERR(pas->dtb_mem_region);
- }
pas->dtb_pas_ctx = devm_qcom_pas_context_alloc(pas->dev, pas->dtb_pas_id,
pas->dtb_mem_phys,
diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
index 137992456b71..002100fe2d32 100644
--- a/drivers/soc/qcom/mdt_loader.c
+++ b/drivers/soc/qcom/mdt_loader.c
@@ -11,6 +11,7 @@
#include <linux/device.h>
#include <linux/elf.h>
#include <linux/firmware.h>
+#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/firmware/qcom/qcom_pas.h>
@@ -478,22 +479,28 @@ EXPORT_SYMBOL_GPL(qcom_mdt_load);
* @ctx: Pointer to the PAS (Peripheral Authentication Service) context
* @fw: Firmware object representing the .mdt file
* @firmware: Name of the firmware used to construct segment file names
- * @mem_region: Memory region allocated for loading the firmware
* @reloc_base: Physical address adjusted after relocation
*
* Return: 0 on success or a negative error code on failure.
*/
int qcom_mdt_pas_load(struct qcom_pas_context *ctx, const struct firmware *fw,
- const char *firmware, void *mem_region, phys_addr_t *reloc_base)
+ const char *firmware, phys_addr_t *reloc_base)
{
+ void __iomem *mem_region;
int ret;
ret = __qcom_mdt_pas_init(ctx->dev, fw, firmware, ctx->pas_id, ctx->mem_phys, ctx);
if (ret)
return ret;
- return qcom_mdt_load_no_init(ctx->dev, fw, firmware, mem_region, ctx->mem_phys,
- ctx->mem_size, reloc_base);
+ mem_region = qcom_pas_ctx_map(ctx);
+ if (!mem_region)
+ return -ENOMEM;
+
+ ret = qcom_mdt_load_no_init(ctx->dev, fw, firmware, (__force void *)mem_region,
+ ctx->mem_phys, ctx->mem_size, reloc_base);
+ iounmap(mem_region);
+ return ret;
}
EXPORT_SYMBOL_GPL(qcom_mdt_pas_load);
diff --git a/include/linux/firmware/qcom/qcom_pas.h b/include/linux/firmware/qcom/qcom_pas.h
index 65b1c9564458..fb2ec3be6a16 100644
--- a/include/linux/firmware/qcom/qcom_pas.h
+++ b/include/linux/firmware/qcom/qcom_pas.h
@@ -8,7 +8,9 @@
#ifndef __QCOM_PAS_H
#define __QCOM_PAS_H
+#include <linux/device.h>
#include <linux/err.h>
+#include <linux/io.h>
#include <linux/types.h>
struct qcom_pas_context {
@@ -22,6 +24,16 @@ struct qcom_pas_context {
bool use_tzmem;
};
+static inline void __iomem *qcom_pas_ctx_map(struct qcom_pas_context *ctx)
+{
+ void __iomem *ptr = ioremap_wc(ctx->mem_phys, ctx->mem_size);
+
+ if (!ptr)
+ dev_err(ctx->dev, "unable to map memory region: %pa+%zx\n",
+ &ctx->mem_phys, ctx->mem_size);
+ return ptr;
+}
+
bool qcom_pas_is_available(void);
struct qcom_pas_context *devm_qcom_pas_context_alloc(struct device *dev,
u32 pas_id,
diff --git a/include/linux/soc/qcom/mdt_loader.h b/include/linux/soc/qcom/mdt_loader.h
index 142409555425..74886f772d46 100644
--- a/include/linux/soc/qcom/mdt_loader.h
+++ b/include/linux/soc/qcom/mdt_loader.h
@@ -21,7 +21,7 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
phys_addr_t *reloc_base);
int qcom_mdt_pas_load(struct qcom_pas_context *ctx, const struct firmware *fw,
- const char *firmware, void *mem_region, phys_addr_t *reloc_base);
+ const char *firmware, phys_addr_t *reloc_base);
int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw,
const char *fw_name, void *mem_region,
@@ -47,7 +47,7 @@ static inline int qcom_mdt_load(struct device *dev, const struct firmware *fw,
static inline int qcom_mdt_pas_load(struct qcom_pas_context *ctx,
const struct firmware *fw, const char *firmware,
- void *mem_region, phys_addr_t *reloc_base)
+ phys_addr_t *reloc_base)
{
return -ENODEV;
}
--
2.53.0
next prev parent reply other threads:[~2026-07-24 18:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 18:28 [PATCH v5 0/6] remoteproc: qcom: pas: Misc fixes Mukesh Ojha
2026-07-24 18:28 ` [PATCH v5 1/6] remoteproc: qcom: annotate mem_region fields with __iomem Mukesh Ojha
2026-07-24 18:28 ` [PATCH v5 2/6] remoteproc: qcom: pas: Guard dtb metadata release with dtb_pas_id check Mukesh Ojha
2026-07-24 18:28 ` [PATCH v5 3/6] remoteproc: qcom: pas: Fix the PAS context creation placement Mukesh Ojha
2026-07-24 18:28 ` Mukesh Ojha [this message]
2026-07-24 18:28 ` [PATCH v5 5/6] remoteproc: qcom: pas: Drop unused dtb_mem_region field Mukesh Ojha
2026-07-24 18:28 ` [PATCH v5 6/6] firmware: qcom: scm: introduce keep_mdt_buf flag in PAS context Mukesh Ojha
2026-08-02 4:08 ` Bjorn Andersson
2026-08-03 9:06 ` Mukesh Ojha
2026-08-04 15:25 ` Bjorn Andersson
2026-08-04 15:44 ` Mukesh Ojha
2026-07-31 3:26 ` (subset) [PATCH v5 0/6] remoteproc: qcom: pas: Misc fixes Bjorn Andersson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260724182858.1868271-5-mukesh.ojha@oss.qualcomm.com \
--to=mukesh.ojha@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=neil.armstrong@linaro.org \
--cc=sumit.garg@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®