Commit Graph

1149251 Commits

Author SHA1 Message Date
lijianzhong
c22b82c2e4 ANDROID: export find_user() & free_uid()for GKI purpose.
Exporting the symbols find_user() & free_uid() to access user task
information in ko module for monitoring and optimization purposes. This
is a necessary component of our scheduling policy.

Bug: 183674818

Signed-off-by: lijianzhong <lijianzhong@xiaomi.com>
Change-Id: I12135c0af312904dd21b6f074beda086ad5ece98
(cherry picked from commit 16350016d8)
(cherry picked from commit eec2cd3df3aa2d92136658d3619dc5142155c7d4)
2023-05-11 05:22:29 +00:00
heshuai1
4b87d7254b ANDROID: user: Add vendor hook to user for GKI purpose
In order to implement our scheduling tuning policy in certain cases, we
need to initialize the variables that we have defined in the
user_struct. To achieve this, we will add a vendor hook to user.c at
alloc_uid, which will ensure that our own logic is executed during the
initialization of the user_struct.

Bug: 187458531

Signed-off-by: heshuai1 <heshuai1@xiaomi.com>
Change-Id: I078484aac2c3d396aba5971d6d0f491652f3781c
(cherry picked from commit c9b8fa644f)
(cherry picked from commit 9ac0923ef565e4de4e1f35edcba6fcb7e45948c9)
2023-05-11 05:22:29 +00:00
lijianzhong
e273916482 ANDROID: sched: add trace_android_vh_map_util_freq parameter
Add "cpufreq_policy" and "need_freq_update" parameters to the vendor
hook to enable frequency calculation in certain special cases related to
OEM's frequency tuning policy.

Bug: 183674818

Signed-off-by: lijianzhong <lijianzhong@xiaomi.com>
Change-Id: I232d2e1ae885d6736eca9e4709870f4272b4873d
2023-05-11 05:22:29 +00:00
Badhri Jagan Sridharan
b9bb33b73c FROMGIT: usb: gadget: udc: core: Prevent redundant calls to pullup
usb_gadget_connect calls gadget->ops->pullup without checking whether
gadget->connected was previously set. Make this symmetric to
usb_gadget_disconnect by returning early if gadget->connected is
already set.

Bug: 279501392
Bug: 276227797
Fixes: 5a1da544e5 ("usb: gadget: core: do not try to disconnect gadget if it is not connected")
Cc: stable@vger.kernel.org
Change-Id: I60b23114c0df7b282bcb1ce638683960305992c5
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Link: https://lore.kernel.org/r/20230407030741.3163220-2-badhri@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit a3afbf5cc8
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ usb-next)
2023-05-11 05:22:29 +00:00
Badhri Jagan Sridharan
d1c3092479 FROMGIT: usb: gadget: udc: core: Invoke usb_gadget_connect only when started
usb_udc_connect_control does not check to see if the udc has already
been started. This causes gadget->ops->pullup to be called through
usb_gadget_connect when invoked from usb_udc_vbus_handler even before
usb_gadget_udc_start is called. Guard this by checking for udc->started
in usb_udc_connect_control before invoking usb_gadget_connect.

Guarding udc->vbus, udc->started, gadget->connect, gadget->deactivate
related functions with connect_lock. usb_gadget_connect_locked,
usb_gadget_disconnect_locked, usb_udc_connect_control_locked,
usb_gadget_udc_start_locked, usb_gadget_udc_stop_locked are called with
this lock held as they can be simulataneously invoked from different code
paths.

Adding an additional check to make sure udc is started(udc->started)
before pullup callback is invoked.

Bug: 279501392
Bug: 276227797
Fixes: 628ef0d273 ("usb: udc: add usb_udc_vbus_handler")
Cc: stable@vger.kernel.org
Change-Id: Iee7ac5fdf880be5565b9f178708240d619141237
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Link: https://lore.kernel.org/r/20230407030741.3163220-1-badhri@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit a3afbf5cc8
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ usb-next)
2023-05-11 05:22:29 +00:00
Greg Kroah-Hartman
0d9ea5d875 Revert "Revert "KVM: arm64: PMU: Don't save PMCR_EL0.{C,P} for the vCPU""
This reverts commit 067f7ca9fd.

It was perserving the ABI, but that is not needed anymore at this point
in time.

Change-Id: Ie5c4e8b82bac1966ea56834f02ddcc83dccbd7d1
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 05:22:29 +00:00
Greg Kroah-Hartman
8e52c029c9 Revert "Revert "KVM: arm64: PMU: Sanitise PMCR_EL0.LP on first vcpu run""
This reverts commit a8fa816c4d.

It was perserving the ABI, but that is not needed anymore at this point
in time.

Change-Id: I6ca9a9f70805782cdacd7fedc2a057405aae5774
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 05:22:29 +00:00
Greg Kroah-Hartman
350ced2ef1 Revert "Revert "KVM: arm64: PMU: Distinguish between 64bit counter and 64bit overflow""
This reverts commit 7ddb50fff2.

It was perserving the ABI, but that is not needed anymore at this point
in time.

Change-Id: Ie92c7e1fa270672698399600076ac9be1e0ac4f4
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 05:22:29 +00:00
Greg Kroah-Hartman
0871e23703 Revert "Revert "KVM: arm64: PMU: Align chained counter implementation with architecture pseudocode""
This reverts commit 9d29ba9c30.

It was perserving the ABI, but that is not needed anymore at this point
in time.

Change-Id: Iae5f3a6a9025e17aa7b1a0fd805c13953bc0c554
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 05:22:29 +00:00
Greg Kroah-Hartman
019fe14f01 Revert "Revert "pwm: meson: Explicitly set .polarity in .get_state()""
This reverts commit af88eb49be.

It was perserving the ABI, but that is not needed anymore at this point
in time.

Change-Id: Iaf8c7af434912fc219d411c8c9b17292f1605af5
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 05:22:29 +00:00
Greg Kroah-Hartman
0dff4eccbe Revert "Revert "pwm: sprd: Explicitly set .polarity in .get_state()""
This reverts commit 46e1414454.

It was perserving the ABI, but that is not needed anymore at this point
in time.

Change-Id: I935958cfe8d7e01c7469818609534cfd0e9ba6de
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 05:22:29 +00:00
Greg Kroah-Hartman
fa46734e23 Revert "Revert "pwm: iqs620a: Explicitly set .polarity in .get_state()""
This reverts commit 301169bd8c.

It was perserving the ABI, but that is not needed anymore at this point
in time.

Change-Id: I0ffa37b35a4abce29f9ddde7bebf0b8df159fa1e
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 05:22:29 +00:00
Greg Kroah-Hartman
6d6d97db89 Revert "Revert "pwm: cros-ec: Explicitly set .polarity in .get_state()""
This reverts commit b8301c2638.

It was perserving the ABI, but that is not needed anymore at this point
in time.

Change-Id: I4e97d4fb46ce6596880749b8486bbeafb3151d4a
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 05:22:29 +00:00
Greg Kroah-Hartman
dd7c812051 Revert "Revert "pwm: hibvt: Explicitly set .polarity in .get_state()""
This reverts commit 6996d13954.

It was perserving the ABI, but that is not needed anymore at this point
in time.

Change-Id: I29bcae8b8b502b7c4a4b79650996d1ba2556f1c7
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 05:22:29 +00:00
Greg Kroah-Hartman
3aceb12dc1 Revert "Revert "pwm: Make .get_state() callback return an error code""
This reverts commit a3a763fb37.

It was perserving the ABI, but that is not needed anymore at this point
in time.

Change-Id: Ie5a36427c09a3cc7f89949e05c0bb6b013f9c591
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 05:22:29 +00:00
Greg Kroah-Hartman
18c6e1f4af Revert "Revert "raw: Fix NULL deref in raw_get_next().""
This reverts commit cc7a00d2d6.

It was perserving the ABI, but that is not needed anymore at this point
in time.

Change-Id: I30a89a414afcc3db54c040afff3ab067b33170be
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 05:22:29 +00:00
Greg Kroah-Hartman
01e7770c33 Revert "Revert "raw: use net_hash_mix() in hash function""
This reverts commit 2039635543.

It was perserving the ABI, but that is not needed anymore at this point
in time.

Change-Id: Iaa9f70751453325f43d15bc6e4f6cf5bc68d6ec2
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 05:22:29 +00:00
Po-Wen Kao
6203e02485 FROMLIST: scsi: ufs: core: Fix mcq nr_hw_queues
Since MAXQ is 0 based value, add one to obtain number of hardware queue.

Bug: 267974767
Link: https://lore.kernel.org/all/20230504154454.26654-4-powen.kao@mediatek.com/
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Change-Id: Id9facc9ff54f08e599e6f7026924c664cfeaad51
2023-05-11 03:22:33 +00:00
Po-Wen Kao
090320760a FROMLIST: scsi: ufs: core: Rename symbol sizeof_utp_transfer_cmd_desc()
Naming the functions after standard operators like sizeof may cause
confusion. So let's rename it to ufshcd_get_ucd_size().

Bug: 267974767
Link: https://lore.kernel.org/all/20230504154454.26654-3-powen.kao@mediatek.com/
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Suggested-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Change-Id: Icee01d55d0cf932fd70d1b6e796fcf31b233be5c
2023-05-11 03:22:33 +00:00
Po-Wen Kao
922ab3cbf4 FROMLIST: scsi: ufs: core: Fix mcq tag calcualtion
Transfer command descriptor is allocated in ufshcd_memory_alloc()
and referenced by transfer request descriptor with stride size
sizeof_utp_transfer_cmd_desc()
instead of
sizeof(struct utp_transfer_cmd_desc).

Consequently, computing tag by address offset should also refer to the
same stride.

Bug: 267974767
Link: https://lore.kernel.org/all/20230504154454.26654-2-powen.kao@mediatek.com/
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Change-Id: Ibe3cba615e80287b93e42c268fccd03531f364b8
2023-05-11 03:22:33 +00:00
Ulises Mendez Martinez
119cead9cf ANDROID: GKI: Remove MAKE_GOALS from build.config
* Instead use the equivalent kernel_build attribute.

Bug: 236012223
Change-Id: Id90fa89dcadd95d8a8ecf570f46d9d71a925c388
Signed-off-by: Ulises Mendez Martinez <umendez@google.com>
(cherry picked from commit ab7e63ef765d74b388e881800ad500c5f93199fc)
2023-05-10 17:05:37 +00:00
Kim Ba
1e0916fb95 ANDROID: GKI: Add symbols to symbol list for vivo
INFO: 2 function symbol(s) added
  'void* regulator_get_drvdata(struct regulator*)'
  'int ucsi_send_command(struct ucsi*, u64, void*, size_t)'

Bug: 194373509
Change-Id: I75324ae19c83dccfb0f14dbdcc801f73338f4ea6
Signed-off-by: Mingli Feng <mingli.feng@vivo.com>
Signed-off-by: Kim Ba <kim.ba@vivo.com>
Signed-off-by: Kim Ba <kim.ba@vivo.corp-partner.google.com>
2023-05-10 15:30:23 +00:00
Quentin Perret
ccfe12aa18 ANDROID: KVM: arm64: Restrict pKVM hyp exports
The pKVM hypervisor uses the module_ops struct as a way to expose
services to loadable modules. It doesn't however allow fine-grained
definition of the license for each export, and doesn't have a way to
check the license of the loaded module (yet). As such, the  assumption
is that said module is proprietary, and must NOT be allowed to use GPL
symbols.

Even though symbols such as __pkvm_load_el2_module are currently
exported as GPL, these exports only apply to the kernel part of the
module, which is usually only a proxy to load the hyp module, which
may be built separately.

Given the lack of license enforcement at load time, let's seek GPL
compliance by preventing the accidental export of GPL symbols to hyp
modules via pKVM's module_ops struct. To do so, add a build time check
for the absence of such symbols from the KVM nvhe code entirely.

In the future (Android 15+ and upstream), we should consider expanding
the pKVM module loader to allow finer grained licensing of exports.
This would allow exposing internal pKVM functions as GPL only for e.g.
selftests and such w/o risking exports to proprietary modules.

Bug: 263340138
Bug: 267430896
Change-Id: I09b81bfe322c0d2746c0349c5f217a5a76b6e33d
Signed-off-by: Quentin Perret <qperret@google.com>
2023-05-10 07:44:00 +00:00
Yifan Hong
dac17bb8f7 ANDROID: kleaf: move NDK_TRIPLE for arm to build.config.constants.
... so it can be read by Bazel @kernel_toolchain_info
later.

Test: TH
Bug: 272164611
Change-Id: I04648f8fb28537544287797673810946dedb58f3
Signed-off-by: Yifan Hong <elsk@google.com>
2023-05-09 22:36:11 +00:00
Chun-Hung Wu
7e62fb828f FROMLIST: clocksource/drivers/timer-mediatek: Make timer-mediatek become loadable module
Make the timer-mediatek driver which can register
an always-on timer as tick_broadcast_device on
MediaTek SoCs become loadable module in GKI.

Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
Signed-off-by: Walter Chang <walter.chang@mediatek.com>
Tested-by: Walter Chang <walter.chang@mediatek.com>a

Link: https://lore.kernel.org/lkml/20230421034649.15247-5-walter.chang@mediatek.com/T/
Bug: 161675989
Change-Id: I73ad74f0024a8e72ed7f60754d26433c2149e270
Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
2023-05-09 09:49:00 +00:00
Chun-Hung Wu
4625c2b602 FROMLIST: clocksource/drivers/timer-of: Remove __init markings
Remove __init markings to allow timer drivers
can be compiled as modules.

Link: https://lore.kernel.org/lkml/20230421034649.15247-5-walter.chang@mediatek.com/T/
Bug: 161675989
Change-Id: I74c9d1b4bc6f49dc5a69b4502ca68cb8cc3cbf02
Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
2023-05-09 09:49:00 +00:00
Chun-Hung Wu
bc213daa95 FROMLIST: clocksource/drivers/mmio: Export clocksource_mmio_init()
Export clocksource_mmio_init() and clocksource_mmio_readl_up()
to support building clocksource driver as module,
such as timer-mediatek.c.

Link: https://lore.kernel.org/lkml/20230421034649.15247-5-walter.chang@mediatek.com/T/
Bug: 161675989
Change-Id: I4cbed905fc671d6daa7e01d66df4b910e7c32a1e
Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
2023-05-09 09:49:00 +00:00
Chun-Hung Wu
c451105379 FROMLIST: time/sched_clock: Export sched_clock_register()
clocksource driver may use sched_clock_register()
to resigter itself as a sched_clock source.
Export it to support building such driver
as module, like timer-mediatek.c

Link: https://lore.kernel.org/lkml/20230421034649.15247-5-walter.chang@mediatek.com/T/
Bug: 161675989
Change-Id: Ib052d1fd7ccf6a7422eb6f1755515e1236285e01
Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
2023-05-09 09:49:00 +00:00
Junki Min
bdad41f4cc ANDROID: ABI: Update symbol list for Exynos SoC
Update symbols for cpufreq vendorhook

1 function symbol(s) added
  'int __traceiter_android_rvh_cpufreq_transition(void*, struct cpufreq_policy*)'

1 variable symbol(s) added
  'struct tracepoint __tracepoint_android_rvh_cpufreq_transition'

Bug: 280531400
Change-Id: Ie9c7666e6e1b34545b603a555e7042dbb477eb1b
Signed-off-by: Junki Min <joonki.min@samsung.com>
2023-05-09 08:09:49 +00:00
Youngmin Nam
b8bdb49ef4 Revert "Revert "ANDROID: cpufreq: Add a restricted vendor hook for freq transition""
This reverts commit 3a7f9f00f0.

Some module driver need to know current cpufreq change status
to profile cpu operation.

Bug: 280531400
Change-Id: Ibd7fa6c7e04695d2efc39775767b77b522ba6c06
Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
2023-05-09 08:09:49 +00:00
Treehugger Robot
794e18b1af Merge "Merge 55fba69fbf ("rust: kernel: Mark rust_fmt_argument as extern "C"") into android14-6.1" into android14-6.1 2023-05-09 05:56:29 +00:00
Krishna Kurapati
3c474dc481 ANDROID: usb: gadget: configfs: Protect composite_setup in a spinlock
In one of the SMMU faults (NULL Pointer derefernce) the following
race condition was observed and func->interfaces_nums was being
accessed for f_fs interface after it was unbinded resulting in a
crash.

Thread-1                             Thread-2

ffs_func_req_match+0x68/0xc8
				drain_workqueue+0xac
				gsi_unbind[usb_f_gsi]+0x64
				purge_configs_funcs+0xb4
				configfs_composite_unbind+0xac
				usb_gadget_remove_driver+0xac
				usb_gadget_unregister_driver+0xd8
				gadget_dev_desc_UDC_store+0x114

android_setup+0x164/0x2a8
dwc3_ep0_inspect_setup+0x100/0x440
dwc3_ep0_interrupt+0xac/0x300
dwc3_process_event_entry+0x80/0x724
dwc3_process_event_buf+0x80/0x434
dwc3_thread_interrupt+0x60/0x124
irq_thread_fn+0x54/0xe4
irq_thread+0x3a4/0x6ec
kthread+0x188/0x1ec
ret_from_fork+0x10/0x20

The events happened in order are as follows:

We got a setup packet for ffs interface and was passed to android
setup callback from ep0.c. As part of the delegate request, the
dwc->lock is released.

At this instant a composition switch occurred and as per traces
and crash dumps:

1. UDC Stop was done successfully. So run stop is set to '0'
2. Composite disconnect was done and ep disable for all ep's is done
   gadget->connected = FALSE

3. Async callbacks disabled
   dwc->aysnc_callbacks = FALSE

4. composite unbind is going on and the ffs interface in question is
unbinded
udc->driver != NULL
(as per crash dump indicating that unbind is in progress)

5. Purge configs was ongoing because as per crash dumps:
otg_desc[0] = NULL;
cdev->os_desc_req->buf is not NULL

(configfs_composite_unbind is going on, but composite_dev_cleanup
not yet done)

As per the traces:

23.794712:  dwc3_event   event=49216  ep0state=1  str=
23.794909:  dwc3_ctrl_req   bRequestType=161  bRequest=1  wValue=0
wIndex=2  wLength=4096

23.799740:  usb_gadget_disconnect   speed=5  max_speed=6  state=7
mA=0 deactivated=0  connected=0  ret=0

This indicated that android setup came first followed by composite
disconnect. Since the dwc->lock was released by delegate_request,
soft disconnect gets unblocked and runs parallel to composite setup.

After this, there is no check in path of composite setup
indicating unbind happened and bail out is necessary instead of
executing any function ops.

Protect composite_setup (as part of android_setup) in a spinlock
to block composite_disconnect/unbind running in parallel.

Moreover, in the configfs counterpart of android_setup (configfs_
composite_stetup), the composite_setup call is done with spinlock
held.

It is only the android_setup missing this lock.

Bug: 280548269
Fixes: 7a160e2b96 ("ANDROID: usb: gadget: configfs: Add Uevent to notify userspace")
Change-Id: Id245e9f72801541689fcb185ba0459824bfb3904
Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
(cherry picked from commit 9ad803f257a8eb50a52c19a4cf33690cf1b85575)
2023-05-09 05:48:16 +00:00
Neill Kapron
564f90c7a1 Revert "ANDROID: uid_sys_stat: split the global lock uid_lock to the fine-grained"
This reverts commit 9957ea75b7.

Reason for revert: Likely causes "calls a sleeping function from atomic context" https://buganizer.corp.google.com/issues/281144729

Change-Id: I8564430ac7ca950d9a85e2cb4a4fe67d05fd20d4
Signed-off-by: Neill Kapron <nkapron@google.com>
2023-05-09 04:56:36 +00:00
Greg Kroah-Hartman
d31ed3d059 Merge 55fba69fbf ("rust: kernel: Mark rust_fmt_argument as extern "C"") into android14-6.1
Steps on the way to 6.1.26

Change-Id: Idedac255abf3273edfdc8e1c3a88cc97c7af1f41
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-09 03:32:41 +00:00
fengqi
d5d6873356 ANDROID: GKI: update symbol list file for xiaomi
INFO: ABI DIFFERENCES HAVE BEEN DETECTED!
INFO: 7 function symbol(s) added
  'unsigned int blk_crypto_keyslot_index(struct blk_crypto_keyslot*)'
  'bool blk_crypto_register(struct blk_crypto_profile*, struct request_queue*)'
  'void blk_mq_destroy_queue(struct request_queue*)'
  'void blk_pm_runtime_init(struct request_queue*, struct device*)'
  'void blk_put_queue(struct request_queue*)'
  'unsigned int sbitmap_weight(const struct sbitmap*)'
  'void scsi_remove_device(struct scsi_device*)'

Bug: 277846574

Change-Id: Ifb9a78b328210f1b24346b610008c34e52ca1688
Signed-off-by: fengqi <fengqi@xiaomi.com>
2023-05-08 22:45:52 +00:00
Ramji Jiyani
fb8bd2df70 ANDROID: GKI: x86_64: Remove 80211 from protected modules
cfg80211 & mac80211 are being converted to vendor modules.
To be consistent for both arm64 & x86_64 remove them
from protected to unprotected; so they can be converted
to vendor modules for x86_64 as well.

This also helps keep things simpler for virtual_device;
so it doesn't have to maintain seperate list for these
architectures w.r.t. these modules.

Bug: 281137343
Test: TH
Change-Id: Ica028593f30528c361a6ab30da8cb5be5187d067
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
2023-05-08 22:27:59 +00:00
Ramji Jiyani
6afa803997 ANDROID: GKI: Update owners for GKI modules lists
Add ramjiyani@ as per-file owner for:

android/abi_gki_protected_exports_*
android/gki_aarch64_protected_modules
android/gki_x86_64_protected_modules

Update required due to addition of multi arch support
caused renaming of these files with arch name in them.

Bug: 151893768
Test: TH
Change-Id: Ice5c054f90b3fc4f91bfe73f680082dc129c0310
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
2023-05-07 23:38:04 +00:00
Carlos Llamas
1ca1130ec6 FROMLIST: binder: fix UAF caused by faulty buffer cleanup
In binder_transaction_buffer_release() the 'failed_at' offset indicates
the number of objects to clean up. However, this function was changed by
commit 44d8047f1d ("binder: use standard functions to allocate fds"),
to release all the objects in the buffer when 'failed_at' is zero.

This introduced an issue when a transaction buffer is released without
any objects having been processed so far. In this case, 'failed_at' is
indeed zero yet it is misinterpreted as releasing the entire buffer.

This leads to use-after-free errors where nodes are incorrectly freed
and subsequently accessed. Such is the case in the following KASAN
report:

  ==================================================================
  BUG: KASAN: slab-use-after-free in binder_thread_read+0xc40/0x1f30
  Read of size 8 at addr ffff4faf037cfc58 by task poc/474

  CPU: 6 PID: 474 Comm: poc Not tainted 6.3.0-12570-g7df047b3f0aa #5
  Hardware name: linux,dummy-virt (DT)
  Call trace:
   dump_backtrace+0x94/0xec
   show_stack+0x18/0x24
   dump_stack_lvl+0x48/0x60
   print_report+0xf8/0x5b8
   kasan_report+0xb8/0xfc
   __asan_load8+0x9c/0xb8
   binder_thread_read+0xc40/0x1f30
   binder_ioctl+0xd9c/0x1768
   __arm64_sys_ioctl+0xd4/0x118
   invoke_syscall+0x60/0x188
  [...]

  Allocated by task 474:
   kasan_save_stack+0x3c/0x64
   kasan_set_track+0x2c/0x40
   kasan_save_alloc_info+0x24/0x34
   __kasan_kmalloc+0xb8/0xbc
   kmalloc_trace+0x48/0x5c
   binder_new_node+0x3c/0x3a4
   binder_transaction+0x2b58/0x36f0
   binder_thread_write+0x8e0/0x1b78
   binder_ioctl+0x14a0/0x1768
   __arm64_sys_ioctl+0xd4/0x118
   invoke_syscall+0x60/0x188
  [...]

  Freed by task 475:
   kasan_save_stack+0x3c/0x64
   kasan_set_track+0x2c/0x40
   kasan_save_free_info+0x38/0x5c
   __kasan_slab_free+0xe8/0x154
   __kmem_cache_free+0x128/0x2bc
   kfree+0x58/0x70
   binder_dec_node_tmpref+0x178/0x1fc
   binder_transaction_buffer_release+0x430/0x628
   binder_transaction+0x1954/0x36f0
   binder_thread_write+0x8e0/0x1b78
   binder_ioctl+0x14a0/0x1768
   __arm64_sys_ioctl+0xd4/0x118
   invoke_syscall+0x60/0x188
  [...]
  ==================================================================

In order to avoid these issues, let's always calculate the intended
'failed_at' offset beforehand. This is renamed and wrapped in a helper
function to make it clear and convenient.

Fixes: 32e9f56a96 ("binder: don't detect sender/target during buffer cleanup")
Reported-by: Zi Fan Tan <zifantan@google.com>
Link: https://b.corp.google.com/issues/275041864
Cc: stable@vger.kernel.org
Signed-off-by: Carlos Llamas <cmllamas@google.com>

Bug: 275041864
Link: https://lore.kernel.org/all/20230505203020.4101154-1-cmllamas@google.com
Change-Id: I4bcc8bde77a8118872237d100cccb5caf95d99a1
Signed-off-by: Carlos Llamas <cmllamas@google.com>
2023-05-05 23:19:06 +00:00
xieliujie
2431799f21 ANDROID: ABI: Update oplus symbol list
20 function symbol(s) added
  'int __traceiter_android_vh_alter_mutex_list_add(void*, struct mutex*, struct mutex_waiter*, struct list_head*, bool*)'
  'int __traceiter_android_vh_binder_free_proc(void*, struct binder_proc*)'
  'int __traceiter_android_vh_binder_has_work_ilocked(void*, struct binder_thread*, bool, int*)'
  'int __traceiter_android_vh_binder_looper_state_registered(void*, struct binder_thread*, struct binder_proc*)'
  'int __traceiter_android_vh_binder_preset(void*, struct hlist_head*, struct mutex*)'
  'int __traceiter_android_vh_binder_priority_skip(void*, struct task_struct*, bool*)'
  'int __traceiter_android_vh_binder_proc_transaction_entry(void*, struct binder_proc*, struct binder_transaction*, struct binder_thread**, int, bool, bool, bool*)'
  'int __traceiter_android_vh_binder_proc_transaction_finish(void*, struct binder_proc*, struct binder_transaction*, struct task_struct*, bool, bool)'
  'int __traceiter_android_vh_binder_read_done(void*, struct binder_proc*, struct binder_thread*)'
  'int __traceiter_android_vh_binder_select_worklist_ilocked(void*, struct list_head**, struct binder_thread*, struct binder_proc*, int)'
  'int __traceiter_android_vh_binder_thread_read(void*, struct list_head**, struct binder_proc*, struct binder_thread*)'
  'int __traceiter_android_vh_binder_thread_release(void*, struct binder_proc*, struct binder_thread*)'
  'int __traceiter_android_vh_mutex_can_spin_on_owner(void*, struct mutex*, int*)'
  'int __traceiter_android_vh_mutex_opt_spin_finish(void*, struct mutex*, bool)'
  'int __traceiter_android_vh_mutex_opt_spin_start(void*, struct mutex*, bool*, int*)'
  'int __traceiter_android_vh_mutex_unlock_slowpath(void*, struct mutex*)'
  'int __traceiter_android_vh_rwsem_can_spin_on_owner(void*, struct rw_semaphore*, bool*)'
  'int __traceiter_android_vh_rwsem_opt_spin_finish(void*, struct rw_semaphore*, bool)'
  'int __traceiter_android_vh_rwsem_opt_spin_start(void*, struct rw_semaphore*, bool*, int*, bool)'
  'int __traceiter_android_vh_rwsem_wake_finish(void*, struct rw_semaphore*)'

20 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_alter_mutex_list_add'
  'struct tracepoint __tracepoint_android_vh_binder_free_proc'
  'struct tracepoint __tracepoint_android_vh_binder_has_work_ilocked'
  'struct tracepoint __tracepoint_android_vh_binder_looper_state_registered'
  'struct tracepoint __tracepoint_android_vh_binder_preset'
  'struct tracepoint __tracepoint_android_vh_binder_priority_skip'
  'struct tracepoint __tracepoint_android_vh_binder_proc_transaction_entry'
  'struct tracepoint __tracepoint_android_vh_binder_proc_transaction_finish'
  'struct tracepoint __tracepoint_android_vh_binder_read_done'
  'struct tracepoint __tracepoint_android_vh_binder_select_worklist_ilocked'
  'struct tracepoint __tracepoint_android_vh_binder_thread_read'
  'struct tracepoint __tracepoint_android_vh_binder_thread_release'
  'struct tracepoint __tracepoint_android_vh_mutex_can_spin_on_owner'
  'struct tracepoint __tracepoint_android_vh_mutex_opt_spin_finish'
  'struct tracepoint __tracepoint_android_vh_mutex_opt_spin_start'
  'struct tracepoint __tracepoint_android_vh_mutex_unlock_slowpath'
  'struct tracepoint __tracepoint_android_vh_rwsem_can_spin_on_owner'
  'struct tracepoint __tracepoint_android_vh_rwsem_opt_spin_finish'
  'struct tracepoint __tracepoint_android_vh_rwsem_opt_spin_start'
  'struct tracepoint __tracepoint_android_vh_rwsem_wake_finish'

Bug: 193384408
Change-Id: Ib482ef721ae17447fba23153eb3cae3ec86b9666
Signed-off-by: xieliujie <xieliujie@oppo.com>
2023-05-05 23:07:06 +00:00
Liujie Xie
e0d5caf5c9 ANDROID: vendor_hooks: Add hooks to select binder worklist
trace_android_vh_binder_proc_transaction_entry:
We need change binder thread so that this work can be added in
proc->todo, if we found the binder thread, skip native logic.

trace_android_vh_binder_select_worklist_ilocked:
we need this because we can't change list point in ”trace_android_vh_binder_thread_read“,
otherwise, If a work has beed added in our own defined list before,
current may goto retry and loop again and again.

Bug: 219898723
Change-Id: Ifdb3429c9ddac521bc75c1d21740ee7cc4b8f143
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
(cherry picked from commit acefa91e51)
Signed-off-by: Carlos Llamas <cmllamas@google.com>
(cherry picked from commit d26c0e1c409179ea74aaa89f748006bd76000cc3)
2023-05-05 23:07:06 +00:00
Liujie Xie
4619ee1a42 ANDROID: vendor_hooks: Add hooks for binder
We want to add some hooks in the binder module so that we can reduce
block time until binder thread is available
Here are what new hooks do for:
1、android_vh_binder_looper_state_registered: choose a binder thread(do proc work) as a low-level thread.Only this thread has power to excute background binder transaction.
2、android_vh_binder_thread_read: let binder thread do works which come from
our list.
3、android_vh_binder_free_proc: free some pointers and variable.
4、android_vh_binder_thread_release: free the list that we create before.
5、android_vh_binder_has_work_ilocked: to check if our list has work.
6、android_vh_binder_read_done: because of we add hook in binder_has_work_ilocked,
7、android_vh_binder_preset: mark target proc's binder threads.
binder_has_work_ilocked may return true, so we try to wake up low-level thread immediately.

Bug: 212483521
Change-Id: Ic40f452cc4dcf8fc85422e23e6f1a7ad77547309
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
(cherry picked from commit 8d6074509e4ec7e10acf6ee78277ff8cd19e49d0)
2023-05-05 23:07:06 +00:00
Liujie Xie
e80c937cd0 ANDROID: vendor_hooks: Add hooks for rwsem and mutex
Add hooks to apply oem's optimization of rwsem and mutex

Bug: 182237112
Signed-off-by: xieliujie <xieliujie@oppo.com>
(cherry picked from commit 80b4341d05)

Signed-off-by: xieliujie <xieliujie@oppo.com>
Change-Id: I36895c432e5b6d6bff8781b4a7872badb693284c
Signed-off-by: Carlos Llamas <cmllamas@google.com>
[cmllamas: completes the cherry-pick of original commit 80b4341d05
since commit 0902cc73b793 was only partial]
(cherry picked from commit d4528a28cb5be0c322031f333a6230fa3042931f)
2023-05-05 23:07:06 +00:00
Liujie Xie
61b713df51 ANDROID: vendor_hooks: Add hooks for binder proc transaction
We need pointers to proc and t, the current hooks in binder_proc_transaction
are unable to use.

Bug: 208910215
Change-Id: I730964f965a015e5f5a3e237d9b3bd084b5bd0d0
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
(cherry picked from commit cb7e10d31b)
Signed-off-by: Carlos Llamas <cmllamas@google.com>
(cherry picked from commit 8968875ad63f4cda9f263e2a2a930524dd8fdbc7)
2023-05-05 23:07:06 +00:00
xieliujie
40142aa83a ANDROID: vendor_hooks: Add hook for binder
Add hook to support oem's performance feature.

Bug: 186482511

Signed-off-by: xieliujie <xieliujie@oppo.com>
Change-Id: Ib495e80e569cc293eaa98d87a050aee8915eb415
(cherry picked from commit 2337b9185a)
(cherry picked from commit c8a2e136151b49d17fd128ccc913723161f9b691)
2023-05-05 23:07:06 +00:00
Liujie Xie
eb74e5b3fe ANDROID: vendor_hooks: Add hooks for mutex and rwsem optimistic spin
These hooks help us do the following things:
a) Record the number of mutex and rwsem optimistic spin.
b) Monitor the time of mutex and rwsem optimistic spin.
c) Make it possible if oems don't want mutex and rwsem to optimistic spin
for a long time.

Bug: 267565260
Change-Id: I2bee30fb17946be85e026213b481aeaeaee2459f
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
(cherry picked from commit d01f7e1269)
(cherry picked from commit 05b5ff11ad98c5896b352b4c376a84b63684e06c)
2023-05-05 23:07:06 +00:00
xieliujie
86c4152970 ANDROID: vendor_hooks: Add hooks for rwsem and mutex
Add hooks to apply oem's optimization of rwsem and mutex

Bug: 182237112
Signed-off-by: xieliujie <xieliujie@oppo.com>
Change-Id: I6332623732e2d6826b8b61087ca74e55393e0c3d
(cherry picked from commit 0902cc73b793f8b8cc2a80943d85d4ca9b98278b)
Signed-off-by: Carlos Llamas <cmllamas@google.com>
2023-05-05 23:07:06 +00:00
Junki Min
54d553865e ANDROID: ABI: Update cpu-profiler symbol list for Exynos SoC
Update symbols for Exynos cpu-profiler

14 function symbol(s) added
  'struct timespec64 current_time(struct inode*)'
  'void d_add(struct dentry*, struct inode*)'
  'struct dentry* d_alloc_name(struct dentry*, const char*)'
  'struct dentry* d_make_root(struct inode*)'
  'unsigned int get_next_ino()'
  'int get_tree_single(struct fs_context*, int(*)(struct super_block*, struct fs_context*))'
  'void kill_litter_super(struct super_block*)'
  'struct inode* new_inode(struct super_block*)'
  'int register_filesystem(struct file_system_type*)'
  'int sg_nents_for_len(struct scatterlist*, u64)'
  'int simple_statfs(struct dentry*, struct kstatfs*)'
  'int sysfs_create_mount_point(struct kobject*, const char*)'
  'void sysfs_remove_mount_point(struct kobject*, const char*)'
  'int unregister_filesystem(struct file_system_type*)'

3 variable symbol(s) added
  'struct kobject* fs_kobj'
  'const struct inode_operations simple_dir_inode_operations'
  'const struct file_operations simple_dir_operations'

Bug: 280531400
Change-Id: I6ba8e09a499bd0b3ad84ae19ba66c0ce26383ed0
Signed-off-by: Junki Min <joonki.min@samsung.com>
2023-05-05 21:52:50 +00:00
Junki Min
f51be83b73 ANDROID: ABI: Update WLBT, Sensor symbol list for Exynos SoC
Update symbols for WLBT, Sensor and ETC

20 function symbol(s) added
  'void __devm_release_region(struct device*, struct resource*, resource_size_t, resource_size_t)'
  'void __wake_up_locked_key(struct wait_queue_head*, unsigned int, void*)'
  'int dev_vprintk_emit(int, const struct device*, const char*, va_list)'
  'void* dw_pcie_own_conf_map_bus(struct pci_bus*, unsigned int, int)'
  'struct iio_dev* iio_device_alloc(struct device*, int)'
  'void iio_device_free(struct iio_dev*)'
  'struct sk_buff* napi_build_skb(void*, unsigned int)'
  'int of_alias_get_highest_id(const char*)'
  'int pci_generic_config_read(struct pci_bus*, unsigned int, int, int, u32*)'
  'int pci_generic_config_write(struct pci_bus*, unsigned int, int, int, u32)'
  'int pcie_get_mps(struct pci_dev*)'
  'int pcie_set_mps(struct pci_dev*, int)'
  'int rtc_set_time(struct rtc_device*, struct rtc_time*)'
  'int tty_dev_name_to_number(const char*, dev_t*)'
  'void tty_kclose(struct tty_struct*)'
  'struct tty_struct* tty_kopen_exclusive(dev_t)'
  'void tty_lock(struct tty_struct*)'
  'int tty_set_ldisc(struct tty_struct*, int)'
  'void tty_unlock(struct tty_struct*)'
  'int v4l2_device_set_name(struct v4l2_device*, const char*, atomic_t*)'

1 variable symbol(s) added
  'struct kmem_cache* names_cachep'

Bug: 280531400
Change-Id: I1ce0af90cf03c55acab80a4fd213749698b4a2a8
Signed-off-by: Junki Min <joonki.min@samsung.com>
2023-05-05 21:52:50 +00:00
Junki Min
8c47765baf ANDROID: ABI: Update GPU symbol for Exynos SoC
Update symbols for GPU driver

21 function symbol(s) added
  'void __do_once_done(bool*, struct static_key_true*, unsigned long*, struct module*)'
  'bool __do_once_start(bool*, unsigned long*)'
  'void __drm_atomic_helper_bridge_duplicate_state(struct drm_bridge*, struct drm_bridge_state*)'
  'void __drm_atomic_helper_bridge_reset(struct drm_bridge*, struct drm_bridge_state*)'
  'int __drmm_add_action_or_reset(struct drm_device*, drmres_release_t, void*, const char*)'
  'void* __drmm_crtc_alloc_with_planes(struct drm_device*, size_t, size_t, struct drm_plane*, struct drm_plane*, const struct drm_crtc_funcs*, const char*, ...)'
  'void* __drmm_encoder_alloc(struct drm_device*, size_t, size_t, const struct drm_encoder_funcs*, int, const char*, ...)'
  'int console_trylock()'
  'void drm_atomic_bridge_chain_post_disable(struct drm_bridge*, struct drm_atomic_state*)'
  'void drm_atomic_bridge_chain_pre_enable(struct drm_bridge*, struct drm_atomic_state*)'
  'void drm_atomic_helper_calc_timestamping_constants(struct drm_atomic_state*)'
  'u64 drm_crtc_vblank_count(struct drm_crtc*)'
  'bool drm_dev_has_vblank(const struct drm_device*)'
  'int drm_gem_fb_begin_cpu_access(struct drm_framebuffer*, enum dma_data_direction)'
  'void drm_print_bits(struct drm_printer*, unsigned long, const char* const*, unsigned int)'
  'void drm_writeback_cleanup_job(struct drm_writeback_job*)'
  'ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe*, void*, size_t)'
  'int ttm_bo_vmap(struct ttm_buffer_object*, struct iosys_map*)'
  'void ttm_bo_vunmap(struct ttm_buffer_object*, struct iosys_map*)'
  'int v4l2_m2m_mmap(struct file*, struct v4l2_m2m_ctx*, struct vm_area_struct*)'
  'bool v4l2_match_dv_timings(const struct v4l2_dv_timings*, const struct v4l2_dv_timings*, unsigned int, bool)'

Bug: 280531400
Change-Id: Ib7059938c34eee8837475c37e9e16027ad923f9c
Signed-off-by: Junki Min <joonki.min@samsung.com>
2023-05-05 21:52:50 +00:00
xieliujie
8d9518f13a ANDROID: ABI: Update oplus symbol list
4 function symbol(s) added
  'int __traceiter_android_vh_record_mutex_lock_starttime(void*, struct task_struct*, unsigned long)'
  'int __traceiter_android_vh_record_pcpu_rwsem_starttime(void*, struct task_struct*, unsigned long)'
  'int __traceiter_android_vh_record_rtmutex_lock_starttime(void*, struct task_struct*, unsigned long)'
  'int __traceiter_android_vh_record_rwsem_lock_starttime(void*, struct task_struct*, unsigned long)'

4 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_record_mutex_lock_starttime'
  'struct tracepoint __tracepoint_android_vh_record_pcpu_rwsem_starttime'
  'struct tracepoint __tracepoint_android_vh_record_rtmutex_lock_starttime'
  'struct tracepoint __tracepoint_android_vh_record_rwsem_lock_starttime'

Bug: 193384408
Change-Id: I1f4ccfa17fd0052a2b4fe3e050365096b466d034
Signed-off-by: xieliujie <xieliujie@oppo.com>
2023-05-05 19:45:34 +00:00