Unverified Commit 5b814159 authored by Arnd Bergmann's avatar Arnd Bergmann
Browse files

Merge tag 'qcom-drivers-for-6.17' of...

Merge tag 'qcom-drivers-for-6.17' of https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux into soc/drivers

Qualcomm driver updates for v6.17

Perform input validation in the MDT loader, as this was not properly
done in the non-remoteproc cases.

Fix endian issues in the QMI encoder/decoder.

Support reading DDR statistic using the Qualcomm stats driver.

Add support for reading TME firmware details to the socinfo driver.

Document the Kryo 470 CPU, and add SM7150 to the DCC to DeviceTree
bindings.

* tag 'qcom-drivers-for-6.17' of https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux:
  soc: qcom: mdt_loader: Fix error return values in mdt_header_valid()
  dt-bindings: sram: qcom,imem: Add a number of missing compatibles
  dt-bindings: arm: cpus: Add Kryo 470 CPUs
  dt-bindings: sram: qcom,imem: Add the SM7150 compatible
  dt-bindings: soc: qcom: aoss-qmp: Add the SM7150 compatible
  dt-bindings: soc: qcom,dcc: Add the SM7150 compatible
  soc: qcom: socinfo: Add support to retrieve TME build details
  soc: qcom: fix endianness for QMI header
  soc: qcom: QMI encoding/decoding for big endian
  dt-bindings: soc: qcom: add qcom,qcs615-imem compatible
  soc: qcom: qcom_stats: Add QMP support for syncing ddr stats
  soc: qcom: qcom_stats: Add support to read DDR statistic
  soc: qcom: mdt_loader: Actually use the e_phoff
  soc: qcom: mdt_loader: Rename mdt_phdr_valid()
  soc: qcom: mdt_loader: Ensure we don't read past the ELF header

Link: https://lore.kernel.org/r/20250715021454.14516-1-andersson@kernel.org


Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parents 9841d927 9f35ab0e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -200,6 +200,7 @@ properties:
      - qcom,kryo385
      - qcom,kryo465
      - qcom,kryo468
      - qcom,kryo470
      - qcom,kryo485
      - qcom,kryo560
      - qcom,kryo570
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ properties:
          - qcom,sdx75-aoss-qmp
          - qcom,sdm845-aoss-qmp
          - qcom,sm6350-aoss-qmp
          - qcom,sm7150-aoss-qmp
          - qcom,sm8150-aoss-qmp
          - qcom,sm8250-aoss-qmp
          - qcom,sm8350-aoss-qmp
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ properties:
  compatible:
    items:
      - enum:
          - qcom,sm7150-dcc
          - qcom,sm8150-dcc
          - qcom,sc7280-dcc
          - qcom,sc7180-dcc
+15 −0
Original line number Diff line number Diff line
@@ -22,17 +22,32 @@ properties:
          - qcom,msm8974-imem
          - qcom,msm8976-imem
          - qcom,qcs404-imem
          - qcom,qcs615-imem
          - qcom,qcs8300-imem
          - qcom,qdu1000-imem
          - qcom,sa8775p-imem
          - qcom,sar2130p-imem
          - qcom,sc7180-imem
          - qcom,sc7280-imem
          - qcom,sc8280xp-imem
          - qcom,sdm630-imem
          - qcom,sdm845-imem
          - qcom,sdx55-imem
          - qcom,sdx65-imem
          - qcom,sdx75-imem
          - qcom,sm6115-imem
          - qcom,sm6125-imem
          - qcom,sm6350-imem
          - qcom,sm6375-imem
          - qcom,sm7150-imem
          - qcom,sm8150-imem
          - qcom,sm8250-imem
          - qcom,sm8350-imem
          - qcom,sm8450-imem
          - qcom,sm8550-imem
          - qcom,sm8650-imem
          - qcom,sm8750-imem
          - qcom,x1e80100-imem
      - const: syscon
      - const: simple-mfd

+53 −10
Original line number Diff line number Diff line
@@ -18,7 +18,38 @@
#include <linux/slab.h>
#include <linux/soc/qcom/mdt_loader.h>

static bool mdt_phdr_valid(const struct elf32_phdr *phdr)
static bool mdt_header_valid(const struct firmware *fw)
{
	const struct elf32_hdr *ehdr;
	size_t phend;
	size_t shend;

	if (fw->size < sizeof(*ehdr))
		return false;

	ehdr = (struct elf32_hdr *)fw->data;

	if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG))
		return false;

	if (ehdr->e_phentsize != sizeof(struct elf32_phdr))
		return false;

	phend = size_add(size_mul(sizeof(struct elf32_phdr), ehdr->e_phnum), ehdr->e_phoff);
	if (phend > fw->size)
		return false;

	if (ehdr->e_shentsize != sizeof(struct elf32_shdr))
		return false;

	shend = size_add(size_mul(sizeof(struct elf32_shdr), ehdr->e_shnum), ehdr->e_shoff);
	if (shend > fw->size)
		return false;

	return true;
}

static bool mdt_phdr_loadable(const struct elf32_phdr *phdr)
{
	if (phdr->p_type != PT_LOAD)
		return false;
@@ -82,13 +113,16 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw)
	phys_addr_t max_addr = 0;
	int i;

	if (!mdt_header_valid(fw))
		return -EINVAL;

	ehdr = (struct elf32_hdr *)fw->data;
	phdrs = (struct elf32_phdr *)(ehdr + 1);
	phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff);

	for (i = 0; i < ehdr->e_phnum; i++) {
		phdr = &phdrs[i];

		if (!mdt_phdr_valid(phdr))
		if (!mdt_phdr_loadable(phdr))
			continue;

		if (phdr->p_paddr < min_addr)
@@ -134,8 +168,11 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len,
	ssize_t ret;
	void *data;

	if (!mdt_header_valid(fw))
		return ERR_PTR(-EINVAL);

	ehdr = (struct elf32_hdr *)fw->data;
	phdrs = (struct elf32_phdr *)(ehdr + 1);
	phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff);

	if (ehdr->e_phnum < 2)
		return ERR_PTR(-EINVAL);
@@ -214,13 +251,16 @@ int qcom_mdt_pas_init(struct device *dev, const struct firmware *fw,
	int ret;
	int i;

	if (!mdt_header_valid(fw))
		return -EINVAL;

	ehdr = (struct elf32_hdr *)fw->data;
	phdrs = (struct elf32_phdr *)(ehdr + 1);
	phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff);

	for (i = 0; i < ehdr->e_phnum; i++) {
		phdr = &phdrs[i];

		if (!mdt_phdr_valid(phdr))
		if (!mdt_phdr_loadable(phdr))
			continue;

		if (phdr->p_flags & QCOM_MDT_RELOCATABLE)
@@ -270,7 +310,7 @@ static bool qcom_mdt_bins_are_split(const struct firmware *fw, const char *fw_na
	int i;

	ehdr = (struct elf32_hdr *)fw->data;
	phdrs = (struct elf32_phdr *)(ehdr + 1);
	phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff);

	for (i = 0; i < ehdr->e_phnum; i++) {
		/*
@@ -310,14 +350,17 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
	if (!fw || !mem_region || !mem_phys || !mem_size)
		return -EINVAL;

	if (!mdt_header_valid(fw))
		return -EINVAL;

	is_split = qcom_mdt_bins_are_split(fw, fw_name);
	ehdr = (struct elf32_hdr *)fw->data;
	phdrs = (struct elf32_phdr *)(ehdr + 1);
	phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff);

	for (i = 0; i < ehdr->e_phnum; i++) {
		phdr = &phdrs[i];

		if (!mdt_phdr_valid(phdr))
		if (!mdt_phdr_loadable(phdr))
			continue;

		if (phdr->p_flags & QCOM_MDT_RELOCATABLE)
@@ -344,7 +387,7 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
	for (i = 0; i < ehdr->e_phnum; i++) {
		phdr = &phdrs[i];

		if (!mdt_phdr_valid(phdr))
		if (!mdt_phdr_loadable(phdr))
			continue;

		offset = phdr->p_paddr - mem_reloc;
Loading