lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <A87E0D60BEDCA22F+511dd411-a9a2-4894-8848-0c92ddf1a3ec@radxa.com>
Date: Fri, 30 Jan 2026 18:58:49 +0800
From: Junhao Xie <bigfoot@...xa.com>
To: Konrad Dybcio <konrad.dybcio@....qualcomm.com>,
 Bjorn Andersson <andersson@...nel.org>,
 Konrad Dybcio <konradybcio@...nel.org>,
 Miquel Raynal <miquel.raynal@...tlin.com>,
 Richard Weinberger <richard@....at>, Vignesh Raghavendra <vigneshr@...com>
Cc: linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-mtd@...ts.infradead.org, Xilin Wu <sophon@...xa.com>,
 Junhao Xie <bigfoot@...xa.com>
Subject: Re: [PATCH v2 1/2] firmware: qcom: scm: Add SCM storage interface
 support

On 2026/1/28 21:39, Konrad Dybcio wrote:
> On 1/26/26 12:44 PM, Junhao Xie wrote:
>> Add infrastructure to support accessing TrustZone-protected storage
>> devices through SCM (Secure Channel Manager) calls. Some Qualcomm
>> platforms protect their firmware storage (typically SPI NOR flash)
>> via TrustZone, making it inaccessible from the non-secure world.
>>
>> Signed-off-by: Junhao Xie <bigfoot@...xa.com>
>> Tested-by: Xilin Wu <sophon@...xa.com>
>> ---
> [...]
>
>> +int qcom_scm_storage_send_cmd(enum qcom_scm_storage_type storage_type,
>> +			      enum qcom_scm_storage_cmd_id cmd_id,
>> +			      u64 lba, void *data, size_t size)
> Please add kerneldoc, as this is an exported function

I will add kerneldoc for qcom_scm_storage_send_cmd in v3

>> +{
>> +	struct qcom_scm_storage_payload *payload __free(qcom_tzmem) = NULL;
>> +	struct qcom_scm_res scm_res = {};
>> +	struct qcom_scm_desc desc = {};
>> +	phys_addr_t payload_addr;
>> +	size_t buf_size;
>> +	int ret;
>> +
>> +	buf_size = sizeof(*payload);
>> +	if (data)
>> +		buf_size += size;
>> +
>> +	payload = qcom_tzmem_alloc(__scm->mempool, buf_size, GFP_KERNEL);
>> +	if (!payload)
>> +		return -ENOMEM;
>> +
>> +	memset(payload, 0, buf_size);
> You're overwriting the data part a line below, let's just zero out the
> cmd+details (sizeof(*payload)) part
>
>> +	if (data)
> (please add a \n above - normally
>
> foo = xyz;
> if (abc)
> 	...
>
> implies the condition takes into account the previous line)

I will fix them in v3.

> [...]
>
>> +	if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_STORAGE,
>> +					 QCOM_SCM_STORAGE_CMD))
>> +		return;
>> +
>> +	ret = qcom_scm_storage_send_cmd(QCOM_SCM_STORAGE_SPINOR,
>> +					QCOM_SCM_STORAGE_GET_INFO,
>> +					0, &info, sizeof(info));
> I'm curious what happens if the call is available but SPINOR is not
> populated onboard..
>
> I thiiiink it should return STORAGE_RESULT_INVALID_PARAMETER but I'm not
> a 100% sure. Guess we'll see down the road.

Yes, on platforms I tested (QCS6490 LE), it returns 
STORAGE_RESULT_INVALID_PARAMETER.

>> +	if (ret < 0) {
>> +		dev_warn(scm->dev, "scm storage get info failed: %d\n", ret);
>> +		return;
>> +	}
>> +
>> +	total_blocks = le64_to_cpu(info.total_blocks);
>> +	block_size = le32_to_cpu(info.block_size);
>> +
>> +	dev_dbg(scm->dev, "scm storage size %llu bytes\n",
>> +		total_blocks * block_size);
>> +
>> +	storage_dev = platform_device_alloc("qcom_scm_storage", -1);
> -1 is PLATFORM_DEVID_NONE
>
> Let's use PLATFORM_DEVID_AUTO to allow potentially multiple instances of
> this driver being spawned down the road

I will change it to PLATFORM_DEVID_AUTO.
But will they really have multiple instances?

> Konrad

Thank you for the review, I will incorporate these changes in v3.

Best regards,
Junhao Xie


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ