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: <202209131648.zZ3Spbqt-lkp@intel.com>
Date:   Tue, 13 Sep 2022 16:50:15 +0800
From:   kernel test robot <lkp@...el.com>
To:     Gokul krishna Krishnakumar <quic_gokukris@...cinc.com>,
        Andy Gross <agross@...nel.org>,
        Bjorn Andersson <andersson@...nel.org>,
        Konrad Dybcio <konrad.dybcio@...ainline.org>,
        Philipp Zabel <p.zabel@...gutronix.de>
Cc:     llvm@...ts.linux.dev, kbuild-all@...ts.01.org,
        linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org,
        Trilok Soni <quic_tsoni@...cinc.com>,
        Satya Durga Srinivasu Prabhala <quic_satyap@...cinc.com>,
        Rajendra Nayak <quic_rjendra@...cinc.com>,
        Elliot Berman <quic_eberman@...cinc.com>,
        Guru Das Srinagesh <quic_gurus@...cinc.com>,
        Gokul krishna Krishnakumar <quic_gokukris@...cinc.com>
Subject: Re: [PATCH v1 2/2] soc: qcom: mdt_loader: Move the memory allocation
 into mdt loader

Hi Gokul,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on remoteproc/rproc-next]
[also build test ERROR on linus/master v6.0-rc5 next-20220912]
[cannot apply to pza/reset/next]
[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/Gokul-krishna-Krishnakumar/Memory-allocation-change-in-scm-mdt_loader/20220913-024309
base:   git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux.git rproc-next
config: arm64-randconfig-r003-20220911
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 1546df49f5a6d09df78f569e4137ddb365a3e827)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/93615f3d80d56bd470c334e2055f86bea3e53c25
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Gokul-krishna-Krishnakumar/Memory-allocation-change-in-scm-mdt_loader/20220913-024309
        git checkout 93615f3d80d56bd470c334e2055f86bea3e53c25
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/soc/qcom/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>

All errors (new ones prefixed by >>):

>> drivers/soc/qcom/mdt_loader.c:172:12: error: call to undeclared function 'qcom_get_scm_device'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
           scm_dev = qcom_get_scm_device();
                     ^
>> drivers/soc/qcom/mdt_loader.c:172:10: error: incompatible integer to pointer conversion assigning to 'struct device *' from 'int' [-Wint-conversion]
           scm_dev = qcom_get_scm_device();
                   ^ ~~~~~~~~~~~~~~~~~~~~~
>> drivers/soc/qcom/mdt_loader.c:195:60: error: incompatible pointer to integer conversion passing 'dma_addr_t *' (aka 'unsigned long long *') to parameter of type 'dma_addr_t' (aka 'unsigned long long'); dereference with * [-Wint-conversion]
                           dma_free_coherent(scm_dev, ehdr_size + hash_size, data, mdata_phys);
                                                                                   ^~~~~~~~~~
                                                                                   *
   include/linux/dma-mapping.h:433:30: note: passing argument to parameter 'dma_handle' here
                   void *cpu_addr, dma_addr_t dma_handle)
                                              ^
   3 errors generated.


vim +/qcom_get_scm_device +172 drivers/soc/qcom/mdt_loader.c

   107	
   108	/**
   109	 * qcom_mdt_read_metadata() - read header and metadata from mdt or mbn
   110	 * @fw:		firmware of mdt header or mbn
   111	 * @data_len:	length of the read metadata blob
   112	 * @fw_name:	name of the firmware, for construction of segment file names
   113	 * @dev:	device handle to associate resources with
   114	 * @mdata_phys:	phys address for the assigned metadata buffer
   115	 *
   116	 * The mechanism that performs the authentication of the loading firmware
   117	 * expects an ELF header directly followed by the segment of hashes, with no
   118	 * padding inbetween. This function allocates a chunk of memory for this pair
   119	 * and copy the two pieces into the buffer.
   120	 *
   121	 * In the case of split firmware the hash is found directly following the ELF
   122	 * header, rather than at p_offset described by the second program header.
   123	 *
   124	 * The caller is responsible to free (kfree()) the returned pointer.
   125	 *
   126	 * Return: pointer to data, or ERR_PTR()
   127	 */
   128	void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len,
   129				     const char *fw_name, struct device *dev,
   130				     dma_addr_t *mdata_phys)
   131	{
   132		const struct elf32_phdr *phdrs;
   133		const struct elf32_hdr *ehdr;
   134		unsigned int hash_segment = 0;
   135		struct device *scm_dev = NULL;
   136		size_t hash_offset;
   137		size_t hash_size;
   138		size_t ehdr_size;
   139		unsigned int i;
   140		ssize_t ret;
   141		void *data;
   142	
   143		ehdr = (struct elf32_hdr *)fw->data;
   144		phdrs = (struct elf32_phdr *)(ehdr + 1);
   145	
   146		if (ehdr->e_phnum < 2)
   147			return ERR_PTR(-EINVAL);
   148	
   149		if (phdrs[0].p_type == PT_LOAD)
   150			return ERR_PTR(-EINVAL);
   151	
   152		for (i = 1; i < ehdr->e_phnum; i++) {
   153			if ((phdrs[i].p_flags & QCOM_MDT_TYPE_MASK) == QCOM_MDT_TYPE_HASH) {
   154				hash_segment = i;
   155				break;
   156			}
   157		}
   158	
   159		if (!hash_segment) {
   160			dev_err(dev, "no hash segment found in %s\n", fw_name);
   161			return ERR_PTR(-EINVAL);
   162		}
   163	
   164		ehdr_size = phdrs[0].p_filesz;
   165		hash_size = phdrs[hash_segment].p_filesz;
   166	
   167		/*
   168		 * During the scm call memory protection will be enabled for the meta
   169		 * data blob, so make sure it's physically contiguous, 4K aligned and
   170		 * non-cachable to avoid XPU violations.
   171		 */
 > 172		scm_dev = qcom_get_scm_device();
   173		data = dma_alloc_coherent(scm_dev, ehdr_size + hash_size, mdata_phys,
   174					       GFP_KERNEL);
   175		if (!data) {
   176			dev_err(dev, "Allocation of metadata buffer failed.\n");
   177			return NULL;
   178		}
   179	
   180		/* Copy ELF header */
   181		memcpy(data, fw->data, ehdr_size);
   182	
   183		if (ehdr_size + hash_size == fw->size) {
   184			/* Firmware is split and hash is packed following the ELF header */
   185			hash_offset = phdrs[0].p_filesz;
   186			memcpy(data + ehdr_size, fw->data + hash_offset, hash_size);
   187		} else if (phdrs[hash_segment].p_offset + hash_size <= fw->size) {
   188			/* Hash is in its own segment, but within the loaded file */
   189			hash_offset = phdrs[hash_segment].p_offset;
   190			memcpy(data + ehdr_size, fw->data + hash_offset, hash_size);
   191		} else {
   192			/* Hash is in its own segment, beyond the loaded file */
   193			ret = mdt_load_split_segment(data + ehdr_size, phdrs, hash_segment, fw_name, dev);
   194			if (ret) {
 > 195				dma_free_coherent(scm_dev, ehdr_size + hash_size, data, mdata_phys);
   196				return ERR_PTR(ret);
   197			}
   198		}
   199	
   200		*data_len = ehdr_size + hash_size;
   201	
   202		return data;
   203	}
   204	EXPORT_SYMBOL_GPL(qcom_mdt_read_metadata);
   205	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

View attachment "config" of type "text/plain" (159812 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ