Commit Graph

1361 Commits

Author SHA1 Message Date
Deepak Kumar Singh 9a89fcb7d3 soc: qcom: smem: validate fields of shared structures
Structures in shared memory that can be modified by remote
processors may have untrusted values, they should be validated
before use.

Adding proper validation before using fields of shared
structures.

CRs-Fixed: 2421602
Change-Id: I947ed5b0fe5705e5223d75b0ea8aafb36113ca5a
Signed-off-by: Deepak Kumar Singh <deesin@codeaurora.org>
2019-07-27 22:11:30 +02:00
Ajit Pandey 74e190f54e drivers: soc: qcom: Added check to avoid opening multiple instance
Opening of multiple instance of voice_svc user space from app will
lead to pointer deference of private data within apr callback. As
multi-instance not supported added check to deny open() from user
space if previous instance hasn't been closed.

Change-Id: Ia5ef16c69a517760fc9d45530a8a41a333fa2a21
Signed-off-by: Ajit Pandey <ajitp@codeaurora.org>
2019-07-27 22:10:57 +02:00
Wei Wang bb454f3bae ANDROID: fix uninitilized variable
Currently we set CONFIG_CC_OPTIMIZE_FOR_SIZE which suppressed the compiler
warning of unused variables which can lead undefined behavior e.g. memory
corruption and panic. See https://lkml.org/lkml/2013/3/25/347.

This patch fixes all the uninitilized variables in kernel

Bug: 33353384
Test: On device
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I0ae1082f447b435d71156d471878ba71aa16c378
2019-07-27 22:10:15 +02:00
Vatsal Bucha 0177bc3f55 qdsp6v2: apr: check for packet size to header size comparison
Check if packet size is large enough to hold the header.

Change-Id: I7261f8111d8b5f4f7c181e469de248a732242d64
Signed-off-by: Vatsal Bucha <vbucha@codeaurora.org>
2019-07-27 22:08:48 +02:00
Hardik Arya 64e5ce5cc5 soc: qcom: Validate read and write index before calculating ptr
Currently we are not validating read and write index of
tx and rx fifo's before calculating ptr, this can lead to
out-of-bound access. The patch adds proper check for the same.

Change-Id: I7b158e94ae743a90ac364783fe31914ca0fa582b
Signed-off-by: Hardik Arya <harya@codeaurora.org>
2019-07-27 22:08:46 +02:00
Hardik Arya c3f4a5b8ba soc: qcom: Remove smp2p test support
Smp2p test code is used internally to test the
functionality of drivers and has no real use case
in end product.

Change-Id: I7a50c077bb71068188b5411424c5782b3d0edbb7
Signed-off-by: Hardik Arya <harya@codeaurora.org>
2019-07-27 22:08:44 +02:00
Aditya Bavanari 2a5c150c9f voice_svc: Avoid double free in voice_svc driver
voice_svc_dev is allocated as a device managed resource
and need not be freed since it is freed automatically.
Remove the logic to free voice_svc_dev in probe failure
and remove functions to avoid double free.

CRs-Fixed: 2204285
Change-Id: If4f9ca840b00448b987f5ce443f66b0923b01969
Signed-off-by: Aditya Bavanari <abavanar@codeaurora.org>
2019-07-27 21:51:22 +02:00
Xiaogang Cui 26c09c79e5 soc: qcom: dcc: add check if sram data oversteps
If the size of captured data oversteps over SRAM boundary then
it causes corruption of configuration data. Add boundary check
while programming configuration linked list in SRAM, to avoid
this problem.

Change-Id: Idd33f53560585fdbfee4d3822fd93d6f3a365e17
Signed-off-by: Xiaogang Cui <xiaogang@codeaurora.org>
2019-07-27 21:51:09 +02:00
smanag 01d8ecac97 drivers: soc: Synchronize apr callback and voice svc release
Issue is seen when apr callback is received while voice_svc_release
is in process of freeing the driver private data.
Avoid invalid access of private data pointer by putting
the callback and release functions in the same locked context.

Change-Id: I93af13cab0a3c7e653a9bc9fa7f4f86bfa0502df
Signed-off-by: smanag <smanag@codeaurora.org>
2019-07-27 21:50:46 +02:00
Christopher Covington 3647c9eb23 ARM: 7948/1: hw_breakpoint: Add ARMv8 support
Add the trivial support necessary to get hardware breakpoints
working for GDB on ARMv8 simulators running in AArch32 mode.

Change-Id: I340d8793e0da08d1b1f07e72cbf34362dff79fa7
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Git-commit: 5b61d4a5d6676b5bb4c3c101683d3c7fd0df2a38
Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[schikk@codeaurora.org: fix multiple definitions error
(from jtagv8.c) in this change]
Signed-off-by: Swetha Chikkaboraiah <schikk@codeaurora.org>
2019-07-27 21:50:34 +02:00
Banajit Goswami 9b5df51027 soc: q6dspv2: apr: fix client registration refcount
Audio Packet Router (APR) is used by multiple audio services
to communicate between APSS and ADSP. These audio services
registers for service level APR communication (port 0xFFFFFFFF),
or for session level APR communication (using port 0x101 etc.).
The services might choose to call apr_register for any port at
random. The expectation is that the refcounting for the number
of ports registered with APR for any specific service, is handled
irrespective of the order in which registrations are done. The
current logic fails to handle the refcounting when apr_register
is called for 0xFFFFFFFF before other session based ports. Fix
this correctly using the service count (svc_cnt) variable in apr_svc.

CRs-fixed: 2022490
Bug: 34088848
Change-Id: I2fcd1269facf24d509db0d90314e0d2545a2ad67
Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>
2019-07-27 21:50:03 +02:00
Aditya Bavanari dc680cc69f ASoC: apr: Add validity check to APR port
Add boundary checks for APR port received from ADSP.

CRs-Fixed: 2143207
Change-Id: I9a7fa39ee223e1859323caa6eb74c1c8a26a041d
Signed-off-by: Aditya Bavanari <abavanar@codeaurora.org>
2018-08-20 12:08:44 +02:00
LuK1337 39a771baad Merge tag 'LA.BR.1.3.6-05410-8976.0' of https://source.codeaurora.org/quic/la/kernel/msm-3.10 into HEAD
"LA.BR.1.3.6-05410-8976.0"
2018-02-06 13:11:45 +01:00
Jitendra Sharma 7ae8565f29 soc: qcom: pil: Fix error handling during PIL driver probe
During probe function of the Linux PIL kernel driver
Initialization of various resources are done.
This fix is for acquired resource cleanup, in case of error.

CRs-Fixed: 2129451
Change-Id: I0b3511cff7e2917fe83bddfc15086e939f5c2abc
Signed-off-by: Jitendra Sharma <shajit@codeaurora.org>
Signed-off-by: Swetha Chikkaboraiah <schikk@codeaurora.org>
2018-01-18 23:43:10 -08:00
Raghavendra Kakarla faee7b6dce oc: qcom: rpm-smd-debug: Fix potential memory leaks
Fix memory leak due to rpm request not freed during error conditions.

Change-Id: I440a58bf452e76c8886f7bcd8f89b24698a301e9
Signed-off-by: Raghavendra Kakarla <rkakarla@codeaurora.org>
2017-12-27 09:08:54 -08:00
LuK1337 b2213f5c42 Merge tag 'LA.BR.1.3.6-05010-8976.0' of https://source.codeaurora.org/quic/la/kernel/msm-3.10 into cm-14.1-merge
"LA.BR.1.3.6-05010-8976.0"
2017-11-22 00:26:48 +01:00
yidongh dc267211bc ASoC: APR: initialize struct member before being used
Initialize member value of struct apr_client_data after declaration.

CRs-Fixed: 2091948
Change-Id: I8a185ebd4126f7d064de90bf652bc96c2ab7b408
Signed-off-by: Yidong Huang <yidongh@codeaurora.org>
Signed-off-by: Yasir Malik <ymalik@codeaurora.org>
2017-11-08 22:24:56 -08:00
LuK1337 4cce184099 Merge tag 'LA.BR.1.3.6-04910-8976.0' of https://source.codeaurora.org/quic/la/kernel/msm-3.10 into HEAD
"LA.BR.1.3.6-04910-8976.0"
2017-10-14 19:29:50 +02:00
LuK1337 97104ad488 Merge tag 'LA.BR.1.3.6-04710-8976.0' of https://source.codeaurora.org/quic/la/kernel/msm-3.10 into HEAD
"LA.BR.1.3.6-04710-8976.0"
2017-09-15 11:27:24 +02:00
Dhoat Harpal ba841a91cd soc: qcom: glink: Initialize dummy xprt with dummy functions
Few function pointers are left uninitialized in dummy transport.
System can crash if these function pointer get dereferenced.

Initialize all the function pointers which can get called, with
dummy functions.

CRs-Fixed: 2067859
Change-Id: I9172776d9ffa0af5deb9898125fc6403fdcdee0f
Signed-off-by: Dhoat Harpal <hdhoat@codeaurora.org>
2017-09-12 04:18:08 -07:00
Chris Lew 69cf535b2b soc: qcom: smp2p: spinlock_test: Initialize work item
Initialize the has_locked member before running SSR
spinlock test to ensure consistent results.

CRs-Fixed: 2091946
Change-Id: Ifad37541a94668b496aa9204dc80920b9a7ff244
Signed-off-by: Chris Lew <clew@codeaurora.org>
2017-09-06 08:16:58 -07:00
Chetan C R e6b2d88e3a soc: qcom: Clear the memory before freeing it up
It is a case of write after free, this is causing page allocation
failure due to corruption. This is due to freeing up of segments
allocated for venus subsystem, when venus fw loading fail midway.

CRs-Fixed: 2078950
Change-Id: I902ed0241f46fc340c4a307bcb59134e999f8cba
Signed-off-by: Avaneesh Kumar Dwivedi <akdwived@codeaurora.org>
Signed-off-by: Chetan C R <cravin@codeaurora.org>
2017-08-11 05:43:50 -07:00
Se Wang (Patrick) Oh ed20b3dbcb soc: qcom: watchdog_v2: use rt task to pet watchdog
As scheduler doesn't guarantee scheduling even into high
priority worker task within 1 sec after waking up, it can't
pet watchdog properly. Use rt task to pet watchdog even if
the scheduler is busy to handle normal priority tasks.

CRs-Fixed: 940039
Change-Id: Ief8a01df8ef61481c94c3f781d22796882320fc0
Signed-off-by: Se Wang (Patrick) Oh <sewango@codeaurora.org>
[pdaly@codeaurora.org:
resolve INIT_COMPLETION rename
resolve include file changes]
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2017-08-09 23:01:00 -07:00
LuK1337 f77b254b9f Merge tag 'LA.BR.1.3.6-04510-8976.0' of https://source.codeaurora.org/quic/la/kernel/msm-3.10 into HEAD
"LA.BR.1.3.6-04510-8976.0"
2017-08-06 13:38:06 +02:00
Arun Kumar Neelakantam 00515286cf soc: qcom: glink_pkt: Use spinlock to protect Rx data packet list
The current implementation is using mutex lock to protect the Rx data
packet list but Glink core can notify the Rx data in atomic context
and the mutex lock is not used in some places.

Replace the mutex lock with spinlock to protect the Rx data packet list.

CRs-Fixed: 852949
Change-Id: Ie7543a98e6589e8068b873a8bb4f49b9a195d881
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Dhoat Harpal <hdhoat@codeaurora.org>
2017-07-24 23:50:13 -07:00
LuK1337 ea03599937 Merge tag 'LA.BR.1.3.6-04110-8976.0' of https://source.codeaurora.org/quic/la/kernel/msm-3.10 into HEAD
"LA.BR.1.3.6-04110-8976.0"

Change-Id: Ie9bc105eee4263ab1ec2f91556feca988522808f
2017-07-08 18:34:23 +02:00
Naresh Malladi 5c515889e5 drivers: soc: qcom: rpm_stats: Add mutex lock for shared data
The buffer allocated in rpmstats_show need to be protected
as there can be a possiblity of use-after-free scenario.
Process A              B
        |              |
      open             |
        |              |
      read started     |
        |             close

Add mutex lock to protect the buffer to avoid this.

Also allow reading RPM stats information using sysfs nodes.

The stats are available at
	/sys/power/system_sleep/stats

Change-Id: I28ab98e264fc4e425f23c71ddc6dcc8f275d8f6b
Signed-off-by: Naresh Malladi <namall@codeaurora.org>
2017-07-05 23:33:45 -07:00
Naresh Malladi a9dcbcf326 drivers: soc: qcom: rpm_stats: Add mutex lock for shared data
The buffer allocated in rpmstats_show need to be protected
as there can be a possiblity of use-after-free scenario.
Process A              B
        |              |
      open             |
        |              |
      read started     |
        |             close

Add mutex lock to protect the buffer to avoid this.

Also allow reading RPM stats information using sysfs nodes.

The stats are available at
	/sys/power/system_sleep/stats

Change-Id: I28ab98e264fc4e425f23c71ddc6dcc8f275d8f6b
Signed-off-by: Naresh Malladi <namall@codeaurora.org>
2017-07-04 22:46:54 -07:00
Linux Build Service Account c2a6cd49e1 Merge "drivers: soc: qcom: rpm_stats: Add mutex lock for shared data" 2017-06-14 17:23:10 -07:00
Naresh Malladi 4fb4afa4ac drivers: soc: qcom: rpm_stats: Add mutex lock for shared data
The buffer allocated in file open operations need to be
protected as there can be a possiblity of use-after-free
scenario.

Process A              B
        |              |
      open             |
        |              |
      read started     |
        |             close

Add mutex lock to protect the buffer to avoid this.

"msm_rpmstats_copy_stats" accesses the variable "pdata->read_idx"
without locking. The userspace can invoke the "read" call from
multiple threads which will call "msm_rpmstats_file_read" which
in turn calls "msm_rpmstats_copy_stats".

This can allow the statement "pdata->read_idx++" increment
"read_idx" beyond the limit ("prvdata->num_records") and call
"msm_rpmstats_read_register" with this value.

Also allow reading RPM stats information using sysfs nodes.

The stats are available at
	/sys/power/system_sleep/stats

Change-Id: I031f02bb2694a97ced86da0a9f54d0e434e4ad6d
Signed-off-by: Naresh Malladi <namall@codeaurora.org>
2017-06-14 12:19:35 +05:30
Naresh Malladi 06b0bc1b27 soc: qcom: rpm-smd-debug: initialize variables and check for return value
Initialize few variables and check return value of sscanf.
use 'goto' to exit without sending rpm send message request
in case of sscanf failure.

Change-Id: I86f723b4dbbca30b80a33de8b2c28116da8730dd
Signed-off-by: Naresh Malladi <namall@codeaurora.org>
2017-06-09 01:57:58 -07:00
LuK1337 18aceede84 Merge tag 'LA.BR.1.3.6-03910-8976.0' of https://source.codeaurora.org/quic/la/kernel/msm-3.10 into HEAD
"LA.BR.1.3.6-03910-8976.0"

Change-Id: I16643fc055aa2965fe5903396a8e5158c42cf1bc
2017-05-26 13:28:48 +02:00
Kishor PK 8f32f01f57 soc: qcom: pil: Avoid possible buffer overflow during Modem boot
Buffer overflow can occur if MBA firmware size exceeds 1MB.
So validate size before copying the firmware.

CRs-Fixed: 2001803
Change-Id: I070ddf85fbc47df072e7258369272366262ebf46
Signed-off-by: Kishor PK <kpbhat@codeaurora.org>
Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
2017-04-28 12:25:34 +05:30
Satya Durga Srinivasu Prabhala 81cf5b0c4d soc: qcom: remove debugfs interface from ssr
As debugfs interface is intended to test the respective ssr, remove
from the driver to make sure it won't be available by default.

CRs-Fixed: 2025661
Change-Id: I6af9a8333c8028611f889cc2f9b0beb37ef12c9b
Signed-off-by: Satya Durga Srinivasu Prabhala <satyap@codeaurora.org>
2017-04-25 03:51:55 -07:00
Linux Build Service Account b5ffb44153 Merge "soc: qcom: pil: Explicitly clear the subsystem loading address" 2017-04-21 01:49:29 -07:00
LuK1337 4e71469c73 Merge tag 'LA.BR.1.3.6-03510-8976.0' into HEAD
Change-Id: Ie506850703bf9550ede802c13ba5f8c2ce723fa3
2017-04-18 12:11:50 +02:00
Pavankumar Kondeti 5a5f645ab8 core_ctl: Manage number of online cores based on system load
The core_ctl module takes input from userspace and CPU load information to
decide how many CPUs to keep online. User space has the following tunables:

- min_cpus: Minimum number of CPUs to keep online. This overrides other
  heuristics.
- max_cpus: Maximum number of CPUs to keep online. This overrides other
  heuristics.
- additional_cpus: Additional idle CPUs to keep ready for use.
- busy_up_thres: The normalized load% threshold that the CPU load should
  exceeded for the CPU to be go from not busy to busy.
  It could be a single threshold for all CPUs in a group, or num_cpus
  thresholds separated by spaces to specify different thresholds based on
  the current number of online CPUs.
- busy_down_thres: The normalized load% threshold that the CPU load should
  be lower than for the CPU to go from busy to not busy.
  It could be a single threshold for all CPUs in a group, or num_cpus
  thresholds separated by spaces to specify different thresholds based on
  the current number of online CPUs.
- offline_delay_ms: The time to wait for before offline cores when the
  number of needed CPUs goes down.

Mot-CRs-fixed: (CR)

Change-Id: Ied1d5bcbb8da5bbd5f3d1a3f042599babace6b65
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Ravi Chebolu <arc095@motorola.com>
Reviewed-on: http://gerrit.mot.com/866560
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver <sltawvr@motorola.com>
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Lian-Wei Wang <lian-wei.wang@motorola.com>
Reviewed-by: Christopher Fries <cfries@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
2017-04-18 04:37:18 +02:00
LuK1337 fc9499e55a Import latest Samsung release
* Package version: T713XXU2BQCO

Change-Id: I293d9e7f2df458c512d59b7a06f8ca6add610c99
2017-04-18 03:43:52 +02:00
Swetha Chikkaboraiah d8475b0415 soc: qcom: socinfo: Protect current_image using semaphore lock.
Variable current_image can be modified by multiple threads.
This change will protect current_image getting modified
by multiple threads.

Change-Id: I33df463311b24f73b1ba124d388731a72bd13263
CRs-Fixed: 2016485
Signed-off-by: Swetha Chikkaboraiah <schikk@codeaurora.org>
2017-04-11 04:28:05 -07:00
Gaurav Kohli e8e651a6ab soc: qcom: pil: Explicitly clear the subsystem loading address
Explicitly clear the subsystem loading address in case of any
memory failure. It will help to avoid any platform dependency.

Change-Id: I3be8f6318d68f02c02e637fc34f4a868e9fafa45
Signed-off-by: Gaurav Kohli <gkohli@codeaurora.org>
Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
2017-04-09 22:26:37 -07:00
Avaneesh Kumar Dwivedi 3590acf0d7 soc: qcom: Do not clear segments if pil boot failed in memory allocation
PIL boot failure if happened due to memory allocation failure then skip
clearing segments as there is nothing loaded in fw region.

Change-Id: If0c09dd47941be0d9fe42496db43365ece32f3e9
Signed-off-by: Avaneesh Kumar Dwivedi <akdwived@codeaurora.org>
Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
2017-04-04 22:29:26 -07:00
Avaneesh Kumar Dwivedi efb32d0dec soc: qcom: Skip clearing modem FW region post load failure
In existing implementation, we are clearing fw region when loading fails
midway. This is not in consonance with MBA design so differentiate
between modem and other PIL modules. While at it, rectify the data type
of subsys_state in qmi_client_info as well.

Change-Id: I985456fca42346947eac24df5bf66599dcbf4c53
Signed-off-by: Avaneesh Kumar Dwivedi <akdwived@codeaurora.org>
Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
2017-04-04 22:25:43 -07:00
Gaurav Kohli 109ac68ea3 soc: qcom: pil: Clear elf region on authentication failure
In existing implementation elf region was being clearead before memory
access to firmware region assigned to HLOS. So to avoid it using
separate function which will be called only when HLOS is the owner.

Change-Id: I8bb22e4dbe3e1f898678d0c0f6e60268b88fc150
Signed-off-by: Gaurav Kohli <gkohli@codeaurora.org>
2017-03-23 05:03:03 -07:00
Puja Gupta c430133fa9 soc: qcom: pil: Clear elf memory on validation failure
Clear memory where elf segments are loaded if any of the segments fail
authentication.

CRs-Fixed: 1113126
Change-Id: I85d6bdc8efbb5738a863e59c0244222defcc1bcb
Signed-off-by: Puja Gupta <pujag@codeaurora.org>
2017-03-15 23:22:36 -07:00
Siena Richard 79ef5ed29a drivers: soc: add size check
Add size check to ensure the payload fits inside the declared payload
size to prevent loss of data when copying.

CRs-Fixed: 2009224
Signed-off-by: Siena Richard <sienar@codeaurora.org>
Change-Id: I4275c626605272941143b54a7b8861b25f8e750a
2017-03-08 10:22:37 -08:00
Siena Richard 0153409704 drivers: soc: add mutex to prevent response being processed twice
Add a mutex to prevent two threads from processing the same response
at the same time. This ensures responses are processed completely and
sequentially.

CRs-Fixed: 1116015
Change-Id: Id2ef32edb939f8af2850b54bd6f6f447939c0732
Signed-off-by: Siena Richard <sienar@codeaurora.org>
2017-02-23 12:18:18 -08:00
Dhoat Harpal 36e4ae7391 soc: qcom: smem: Fix uninitialized usage of a stack variable
variable size is output variable and is not initialized,
printing it can lead to information leak.

variable size is removed from log message.

CRs-Fixed: 1093837
Change-Id: I95cf227bb82a2ee7c6f43db151f75a942e8e55ce
Signed-off-by: Dhoat Harpal <hdhoat@codeaurora.org>
2017-01-22 04:26:11 -08:00
Puja Gupta 10132a34e8 soc: qcom: pil: Fix kernel pointer leak
Replace WARN with pr_warn so that stack trace is not printed with the
message.

CRs-Fixed: 1111653
Change-Id: Id1c7bbe8a528199261455ba7901e9df81913aef8
Signed-off-by: Puja Gupta <pujag@codeaurora.org>
2017-01-18 21:02:54 -08:00
Linux Build Service Account 2dbdac226f Merge "soc: qcom: add support to append suffix to socinfo" 2016-12-22 14:57:13 -08:00
Lingutla Chandrasekhar c182ffa63a soc: qcom: add support to append suffix to socinfo
Some targets may share same msm-id, but they can have
different product name.
To differentiate them, add support to append suffix to soc_id_string.

Change-Id: Id0272cc4bd776c9872680a218f445160125d6faf
Signed-off-by: Lingutla Chandrasekhar <clingutla@codeaurora.org>
2016-12-21 21:38:59 -08:00