Commit Graph

1068108 Commits

Author SHA1 Message Date
Yi Kong
fc89803eb3 ANDROID: clang: update to 17.0.2
Change-Id: Iac98d18aa284b05267d47a08b30102103e71d293
Test: presubmit
Bug: 277565884
Bug: 279955553
Signed-off-by: Yi Kong <yikong@google.com>
2023-05-15 17:01:01 +00:00
Ulises Mendez Martinez
36756472dc ANDROID: db845c: Remove MAKE_GOALS from build.config
* Instead use the equivalent kernel_build attribute.
* This migrates rockpi4 `MAKE_GOALS` too.

Bug: 236012223
Change-Id: Icf47eb42795100b4955f02170a002689c7566194
Signed-off-by: Ulises Mendez Martinez <umendez@google.com>
2023-05-15 07:01:39 +00:00
Benedict Wong
57ae54b088 FROMGIT: xfrm: Check if_id in inbound policy/secpath match
This change ensures that if configured in the policy, the if_id set in
the policy and secpath states match during the inbound policy check.
Without this, there is potential for ambiguity where entries in the
secpath differing by only the if_id could be mismatched.

Notably, this is checked in the outbound direction when resolving
templates to SAs, but not on the inbound path when matching SAs and
policies.

Test: Tested against Android kernel unit tests & CTS
Signed-off-by: Benedict Wong <benedictwong@google.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>

Bug: 279217934
(cherry picked from commit 8680407b6f
 https://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec.git master)
Change-Id: Ibb97561eaf1a99b7ad239d4d4860bfe5b0ac20ea
Signed-off-by: Carlos Llamas <cmllamas@google.com>
2023-05-12 20:04:23 +00:00
Ramji Jiyani
f3147526a0 ANDROID: GKI: gen_gki_modules_headers update preprocessing
Since we do not enforce symbol lists to be generated using
the ABI tooling; it is possible to have the symbol list
updates with CRLF characters at the end of a line, leading
and trailining white spaces based on how they are manually
edited. The header generation script fails in this case when
it parses these symbols with CRLF or sorting order may not
be correct for symbols with trailing white spaces.

Update the preprocessing of the symbol list to remove any
carriage returns, strip any leading and trailing white spaces
in addition to the other preprocessing.

Bug: 280837072
Test: TH, manual verification
Change-Id: I4b832c28b42f196056c38fc3e2ccd517a03e13fa
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
(cherry picked from commit 6b893a535cfa8a5e9a6cd792e0437fe66cb2296b)
2023-05-12 19:20:07 +00:00
John Stultz
9bb6bf15fc FROMGIT: locking/rwsem: Add __always_inline annotation to __down_read_common() and inlined callers
Apparently despite it being marked inline, the compiler
may not inline __down_read_common() which makes it difficult
to identify the cause of lock contention, as the blocked
function in traceevents will always be listed as
__down_read_common().

So this patch adds __always_inline annotation to the common
function (as well as the inlined helper callers) to force it to
be inlined so the blocking function will be listed (via Wchan)
in traceevents.

Fixes: c995e638cc ("locking/rwsem: Fold __down_{read,write}*()")
Reported-by: Tim Murray <timmurray@google.com>
Signed-off-by: John Stultz <jstultz@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Waiman Long <longman@redhat.com>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20230503023351.2832796-1-jstultz@google.com
Bug: 277817995
(cherry picked from commit 92cc5d00a4
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/urgent)
Signed-off-by: John Stultz <jstultz@google.com>
(cherry picked from https://android-review.googlesource.com/q/commit:a6c75b2e64573cb9f49f6b89808207856fc0309b)
Merged-In: Ifad7ed7fe9f2d5a9eb0cfe7c35e45c0e86bc3ad4
Change-Id: Ifad7ed7fe9f2d5a9eb0cfe7c35e45c0e86bc3ad4
2023-05-12 16:47:54 +00:00
Dan Carpenter
01df29b641 UPSTREAM: KVM: arm64: Fix buffer overflow in kvm_arm_set_fw_reg()
The KVM_REG_SIZE() comes from the ioctl and it can be a power of two
between 0-32768 but if it is more than sizeof(long) this will corrupt
memory.

Fixes: 99adb56763 ("KVM: arm/arm64: Add save/restore support for firmware workaround state")
Change-Id: Ia01204a3f63bcfc8ac3959c2ac7bbccb2ba64c61
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Steven Price <steven.price@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/4efbab8c-640f-43b2-8ac6-6d68e08280fe@kili.mountain
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
(cherry picked from commit a25bc8486f)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-12 08:56:28 +00:00
Treehugger Robot
444e7e1227 Merge "Merge 5.15.110 into android14-5.15" into android14-5.15 2023-05-12 08:55:54 +00:00
Will Deacon
de68c74304 ANDROID: KVM: arm64: Always unmap protected regions from the host
As part of the host deprivilege process, memory regions advertised in
the "pkvm,protected-region" devicetree nodes are unmapped from the
host stage-2 page-table and annotated specially so that the memory can
be used exclusively by hypervisor modules.

Since the state of this memory in the host stage-2 may not be in the
"owned" state (for example, if it corresponds to a "no-map" region),
remove the initial check of the page state and allow unmapping of any
pages from the trusted host.

Bug: 280380533
Cc: Quentin Perret <qperret@google.com>
Fixes: e8cf4c06e1 ("ANDROID: KVM: arm64: Move addr_is_allowed_memory() check into host callback")
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Ic28a2557d6d515b356645228fd41d3c921826489
2023-05-11 22:31:32 +00:00
Bart Van Assche
a349adda90 ANDROID: block: Improve shared tag set performance
Remove the code for fair tag sharing because it significantly hurts
performance for UFS devices. Removing this code is safe because the
legacy block layer worked fine without any equivalent fairness
algorithm.

This algorithm hurts performance for UFS devices because UFS devices
have multiple logical units. One of these logical units (WLUN) is used
to submit control commands, e.g. START STOP UNIT. If any request is
submitted to the WLUN, the queue depth is reduced from 31 to 15 or
lower for data LUNs.

See also https://lore.kernel.org/linux-scsi/20221229030645.11558-1-ed.tsai@mediatek.com/

Cc: Christoph Hellwig <hch@lst.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Cc: Ed Tsai <ed.tsai@mediatek.com>
Change-Id: Ia6d75917d533f32fffc68348b52fd3d972c9074c
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bug: 281845090
Link: https://lore.kernel.org/linux-block/20230103195337.158625-1-bvanassche@acm.org/
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-11 16:03:53 +00:00
Ramji Jiyani
0b5545b549 ANDROID: GKI: Update owners for GKI modules lists
Add ramjiyani@ as per-file owner for list of protected
modules for all current & future architectures.

android/gki_*_protected_modules

Bug: 151893768
Test: TH
Change-Id: I0048c99a28cfe24e1ba7c7d6189fd8c7dfdf6f0d
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
2023-05-11 12:27:24 +00:00
Badhri Jagan Sridharan
9919aa7367 FROMLIST: usb: typec: altmodes/displayport: fix pin_assignment_show
This patch fixes negative indexing of buf array in pin_assignment_show
when get_current_pin_assignments returns 0 i.e. no compatible pin
assignments.

BUG: KASAN: use-after-free in pin_assignment_show+0x26c/0x33c
...
Call trace:
dump_backtrace+0x110/0x204
dump_stack_lvl+0x84/0xbc
print_report+0x358/0x974
kasan_report+0x9c/0xfc
__do_kernel_fault+0xd4/0x2d4
do_bad_area+0x48/0x168
do_tag_check_fault+0x24/0x38
do_mem_abort+0x6c/0x14c
el1_abort+0x44/0x68
el1h_64_sync_handler+0x64/0xa4
el1h_64_sync+0x78/0x7c
pin_assignment_show+0x26c/0x33c
dev_attr_show+0x50/0xc0

Bug: 281126270
Change-Id: I117ec48a09df969029dc1b2f6cb0baea13200ff0
Link: https://lore.kernel.org/lkml/20230508214443.893436-1-badhri@google.com/T/
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
2023-05-11 07:27:30 +00:00
vincenttew
0b015de44e ANDROID: Update the ABI symbol list
Adding the following symbols:
  - __traceiter_android_rvh_audio_usb_offload_disconnect
  - __traceiter_android_vh_audio_usb_offload_connect
  - __tracepoint_android_rvh_audio_usb_offload_disconnect
  - __tracepoint_android_vh_audio_usb_offload_connect

Bug: 279824172
Change-Id: I65d8fbff12a6cc97fcf3c784f138779210b1b2b3
Signed-off-by: vincenttew <vincenttew@google.com>
2023-05-11 06:18:58 +00:00
Greg Kroah-Hartman
a083039e30 Merge 5.15.110 into android14-5.15
Changes in 5.15.110
	PCI/ASPM: Remove pcie_aspm_pm_state_change()
	selftests/kselftest/runner/run_one(): allow running non-executable files
	KVM: arm64: Retry fault if vma_lookup() results become invalid
	KVM: arm64: Fix buffer overflow in kvm_arm_set_fw_reg()
	wifi: brcmfmac: slab-out-of-bounds read in brcmf_get_assoc_ies()
	drm/fb-helper: set x/yres_virtual in drm_fb_helper_check_var
	bluetooth: Perform careful capability checks in hci_sock_ioctl()
	USB: serial: option: add UNISOC vendor and TOZED LT70C product
	driver core: Don't require dynamic_debug for initcall_debug probe timing
	selftests: mptcp: join: fix "invalid address, ADD_ADDR timeout"
	riscv: Move early dtb mapping into the fixmap region
	riscv: Do not set initial_boot_params to the linear address of the dtb
	riscv: No need to relocate the dtb as it lies in the fixmap region
	Linux 5.15.110

Change-Id: I1a4dab8ca13c176a9eda494532a8134a7ed15883
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 05:41:52 +00:00
Carlos Llamas
22ec5ade86 ANDROID: 5/10/2023 KMI update
Set KMI_GENERATION=6 for 5/10 KMI update

122 function symbol(s) removed
  'struct sk_buff* __cfg80211_alloc_event_skb(struct wiphy*, struct wireless_dev*, enum nl80211_commands, enum nl80211_attrs, unsigned int, int, int, gfp_t)'
  'struct sk_buff* __cfg80211_alloc_reply_skb(struct wiphy*, enum nl80211_commands, enum nl80211_attrs, int)'
  'void __cfg80211_send_event_skb(struct sk_buff*, gfp_t)'
  'void cfg80211_assoc_failure(struct net_device*, struct cfg80211_assoc_failure*)'
  'u32 cfg80211_calculate_bitrate(struct rate_info*)'
  'void cfg80211_ch_switch_notify(struct net_device*, struct cfg80211_chan_def*, unsigned int)'
  'void cfg80211_ch_switch_started_notify(struct net_device*, struct cfg80211_chan_def*, unsigned int, u8, bool)'
  'void cfg80211_chandef_create(struct cfg80211_chan_def*, struct ieee80211_channel*, enum nl80211_channel_type)'
  'void cfg80211_connect_done(struct net_device*, struct cfg80211_connect_resp_params*, gfp_t)'
  'void cfg80211_del_sta_sinfo(struct net_device*, const u8*, struct station_info*, gfp_t)'
  'void cfg80211_disconnected(struct net_device*, u16, const u8*, size_t, bool, gfp_t)'
  'int cfg80211_external_auth_request(struct net_device*, struct cfg80211_external_auth_params*, gfp_t)'
  'const struct element* cfg80211_find_elem_match(u8, const u8*, unsigned int, const u8*, unsigned int, unsigned int)'
  'const struct element* cfg80211_find_vendor_elem(unsigned int, int, const u8*, unsigned int)'
  'void cfg80211_ft_event(struct net_device*, struct cfg80211_ft_event_params*)'
  'struct cfg80211_bss* cfg80211_get_bss(struct wiphy*, struct ieee80211_channel*, const u8*, const u8*, size_t, enum ieee80211_bss_type, enum ieee80211_privacy)'
  'void cfg80211_gtk_rekey_notify(struct net_device*, const u8*, const u8*, gfp_t)'
  'void cfg80211_ibss_joined(struct net_device*, const u8*, struct ieee80211_channel*, gfp_t)'
  'struct cfg80211_bss* cfg80211_inform_bss_data(struct wiphy*, struct cfg80211_inform_bss*, enum cfg80211_bss_frame_type, const u8*, u64, u16, u16, const u8*, size_t, gfp_t)'
  'struct cfg80211_bss* cfg80211_inform_bss_frame_data(struct wiphy*, struct cfg80211_inform_bss*, struct ieee80211_mgmt*, size_t, gfp_t)'
  'void cfg80211_mgmt_tx_status_ext(struct wireless_dev*, struct cfg80211_tx_status*, gfp_t)'
  'void cfg80211_michael_mic_failure(struct net_device*, const u8*, enum nl80211_key_type, int, const u8*, gfp_t)'
  'void cfg80211_new_sta(struct net_device*, const u8*, struct station_info*, gfp_t)'
  'void cfg80211_pmksa_candidate_notify(struct net_device*, int, const u8*, bool, gfp_t)'
  'void cfg80211_port_authorized(struct net_device*, const u8*, const u8*, u8, gfp_t)'
  'void cfg80211_put_bss(struct wiphy*, struct cfg80211_bss*)'
  'void cfg80211_ready_on_channel(struct wireless_dev*, u64, struct ieee80211_channel*, unsigned int, gfp_t)'
  'int cfg80211_register_netdevice(struct net_device*)'
  'void cfg80211_remain_on_channel_expired(struct wireless_dev*, u64, struct ieee80211_channel*, gfp_t)'
  'void cfg80211_roamed(struct net_device*, struct cfg80211_roam_info*, gfp_t)'
  'bool cfg80211_rx_mgmt_ext(struct wireless_dev*, struct cfg80211_rx_info*)'
  'void cfg80211_rx_unprot_mlme_mgmt(struct net_device*, const u8*, size_t)'
  'void cfg80211_scan_done(struct cfg80211_scan_request*, struct cfg80211_scan_info*)'
  'void cfg80211_sched_scan_results(struct wiphy*, u64)'
  'void cfg80211_sched_scan_stopped_locked(struct wiphy*, u64)'
  'void cfg80211_tdls_oper_request(struct net_device*, const u8*, enum nl80211_tdls_operation, u16, gfp_t)'
  'void cfg80211_unlink_bss(struct wiphy*, struct cfg80211_bss*)'
  'void cfg80211_unregister_wdev(struct wireless_dev*)'
  'void cfg80211_update_owe_info_event(struct net_device*, struct cfg80211_update_owe_info*, gfp_t)'
  'int cfg80211_vendor_cmd_reply(struct sk_buff*)'
  'const struct ieee80211_reg_rule* freq_reg_info(struct wiphy*, u32)'
  'struct ieee80211_hw* ieee80211_alloc_hw_nm(size_t, const struct ieee80211_ops*, const char*)'
  'bool ieee80211_beacon_cntdwn_is_complete(struct ieee80211_vif*)'
  'struct sk_buff* ieee80211_beacon_get_template(struct ieee80211_hw*, struct ieee80211_vif*, struct ieee80211_mutable_offsets*)'
  'struct sk_buff* ieee80211_beacon_get_tim(struct ieee80211_hw*, struct ieee80211_vif*, u16*, u16*)'
  'void ieee80211_beacon_loss(struct ieee80211_vif*)'
  'u8 ieee80211_beacon_update_cntdwn(struct ieee80211_vif*)'
  'const struct element* ieee80211_bss_get_elem(struct cfg80211_bss*, u8)'
  'u32 ieee80211_calc_rx_airtime(struct ieee80211_hw*, struct ieee80211_rx_status*, int)'
  'u32 ieee80211_calc_tx_airtime(struct ieee80211_hw*, struct ieee80211_tx_info*, int)'
  'u32 ieee80211_channel_to_freq_khz(int, enum nl80211_band)'
  'void ieee80211_connection_loss(struct ieee80211_vif*)'
  'void ieee80211_csa_finish(struct ieee80211_vif*)'
  'struct ieee80211_sta* ieee80211_find_sta(struct ieee80211_vif*, const u8*)'
  'struct ieee80211_sta* ieee80211_find_sta_by_ifaddr(struct ieee80211_hw*, const u8*, const u8*)'
  'void ieee80211_free_hw(struct ieee80211_hw*)'
  'void ieee80211_free_txskb(struct ieee80211_hw*, struct sk_buff*)'
  'int ieee80211_freq_khz_to_channel(u32)'
  'struct sk_buff* ieee80211_get_buffered_bc(struct ieee80211_hw*, struct ieee80211_vif*)'
  'struct ieee80211_channel* ieee80211_get_channel_khz(struct wiphy*, u32)'
  'struct sk_buff* ieee80211_get_fils_discovery_tmpl(struct ieee80211_hw*, struct ieee80211_vif*)'
  'unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff*)'
  'void ieee80211_get_key_rx_seq(struct ieee80211_key_conf*, int, struct ieee80211_key_seq*)'
  'void ieee80211_get_tx_rates(struct ieee80211_vif*, struct ieee80211_sta*, struct sk_buff*, struct ieee80211_tx_rate*, int)'
  'struct sk_buff* ieee80211_get_unsol_bcast_probe_resp_tmpl(struct ieee80211_hw*, struct ieee80211_vif*)'
  'unsigned int ieee80211_hdrlen(__le16)'
  'void ieee80211_iter_chan_contexts_atomic(struct ieee80211_hw*, void(*)(struct ieee80211_hw*, struct ieee80211_chanctx_conf*, void*), void*)'
  'void ieee80211_iter_keys_rcu(struct ieee80211_hw*, struct ieee80211_vif*, void(*)(struct ieee80211_hw*, struct ieee80211_vif*, struct ieee80211_sta*, struct ieee80211_key_conf*, void*), void*)'
  'void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw*, u32, void(*)(void*, u8*, struct ieee80211_vif*), void*)'
  'void ieee80211_iterate_interfaces(struct ieee80211_hw*, u32, void(*)(void*, u8*, struct ieee80211_vif*), void*)'
  'void ieee80211_iterate_stations_atomic(struct ieee80211_hw*, void(*)(void*, struct ieee80211_sta*), void*)'
  'void ieee80211_manage_rx_ba_offl(struct ieee80211_vif*, const u8*, unsigned int)'
  'struct ieee80211_txq* ieee80211_next_txq(struct ieee80211_hw*, u8)'
  'struct sk_buff* ieee80211_probereq_get(struct ieee80211_hw*, const u8*, const u8*, size_t, size_t)'
  'struct sk_buff* ieee80211_proberesp_get(struct ieee80211_hw*, struct ieee80211_vif*)'
  'void ieee80211_queue_delayed_work(struct ieee80211_hw*, struct delayed_work*, unsigned long)'
  'void ieee80211_queue_work(struct ieee80211_hw*, struct work_struct*)'
  'void ieee80211_radar_detected(struct ieee80211_hw*)'
  'void ieee80211_ready_on_channel(struct ieee80211_hw*)'
  'int ieee80211_register_hw(struct ieee80211_hw*)'
  'void ieee80211_remain_on_channel_expired(struct ieee80211_hw*)'
  'void ieee80211_report_low_ack(struct ieee80211_sta*, u32)'
  'void ieee80211_restart_hw(struct ieee80211_hw*)'
  'void ieee80211_return_txq(struct ieee80211_hw*, struct ieee80211_txq*, bool)'
  'void ieee80211_rx_irqsafe(struct ieee80211_hw*, struct sk_buff*)'
  'void ieee80211_rx_list(struct ieee80211_hw*, struct ieee80211_sta*, struct sk_buff*, struct list_head*)'
  'void ieee80211_rx_napi(struct ieee80211_hw*, struct ieee80211_sta*, struct sk_buff*, struct napi_struct*)'
  'void ieee80211_scan_completed(struct ieee80211_hw*, struct cfg80211_scan_info*)'
  'void ieee80211_send_bar(struct ieee80211_vif*, u8*, u16, u16)'
  'void ieee80211_sta_eosp(struct ieee80211_sta*)'
  'int ieee80211_sta_ps_transition(struct ieee80211_sta*, bool)'
  'void ieee80211_sta_pspoll(struct ieee80211_sta*)'
  'void ieee80211_sta_register_airtime(struct ieee80211_sta*, u8, u32, u32)'
  'void ieee80211_sta_uapsd_trigger(struct ieee80211_sta*, u8)'
  'void ieee80211_stop_queue(struct ieee80211_hw*, int)'
  'void ieee80211_stop_queues(struct ieee80211_hw*)'
  'void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_vif*, const u8*, u16)'
  'void ieee80211_tdls_oper_request(struct ieee80211_vif*, const u8*, enum nl80211_tdls_operation, u16, gfp_t)'
  'struct sk_buff* ieee80211_tx_dequeue(struct ieee80211_hw*, struct ieee80211_txq*)'
  'bool ieee80211_tx_prepare_skb(struct ieee80211_hw*, struct ieee80211_vif*, struct sk_buff*, int, struct ieee80211_sta**)'
  'void ieee80211_tx_rate_update(struct ieee80211_hw*, struct ieee80211_sta*, struct ieee80211_tx_info*)'
  'void ieee80211_tx_status(struct ieee80211_hw*, struct sk_buff*)'
  'void ieee80211_tx_status_ext(struct ieee80211_hw*, struct ieee80211_tx_status*)'
  'void ieee80211_tx_status_irqsafe(struct ieee80211_hw*, struct sk_buff*)'
  'void ieee80211_txq_get_depth(struct ieee80211_txq*, unsigned long*, unsigned long*)'
  'bool ieee80211_txq_may_transmit(struct ieee80211_hw*, struct ieee80211_txq*)'
  'void ieee80211_txq_schedule_start(struct ieee80211_hw*, u8)'
  'void ieee80211_unregister_hw(struct ieee80211_hw*)'
  'void ieee80211_wake_queue(struct ieee80211_hw*, int)'
  'void ieee80211_wake_queues(struct ieee80211_hw*)'
  'const char* reg_initiator_name(enum nl80211_reg_initiator)'
  'int regulatory_hint(struct wiphy*, const char*)'
  'int regulatory_set_wiphy_regd(struct wiphy*, struct ieee80211_regdomain*)'
  'int regulatory_set_wiphy_regd_sync(struct wiphy*, struct ieee80211_regdomain*)'
  'void wiphy_apply_custom_regulatory(struct wiphy*, const struct ieee80211_regdomain*)'
  'void wiphy_free(struct wiphy*)'
  'struct wiphy* wiphy_new_nm(const struct cfg80211_ops*, int, const char*)'
  'void wiphy_read_of_freq_limits(struct wiphy*)'
  'int wiphy_register(struct wiphy*)'
  'void wiphy_rfkill_set_hw_state_reason(struct wiphy*, bool, enum rfkill_hard_block_reasons)'
  'struct ieee80211_hw* wiphy_to_ieee80211_hw(struct wiphy*)'
  'void wiphy_unregister(struct wiphy*)'

1 variable symbol(s) removed
  'const unsigned char rfc1042_header[6]'

6 function symbol(s) added
  'int __traceiter_android_vh_do_futex(void*, int, unsigned int*, u32*)'
  'int __traceiter_android_vh_futex_wait_end(void*, unsigned int, u32)'
  'int __traceiter_android_vh_futex_wait_start(void*, unsigned int, u32)'
  'int __traceiter_android_vh_futex_wake_this(void*, int, int, int, struct task_struct*)'
  'int __traceiter_android_vh_futex_wake_traverse_plist(void*, struct plist_head*, int*, union futex_key, u32)'
  'int __traceiter_android_vh_futex_wake_up_q_finish(void*, int, int)'

6 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_do_futex'
  'struct tracepoint __tracepoint_android_vh_futex_wait_end'
  'struct tracepoint __tracepoint_android_vh_futex_wait_start'
  'struct tracepoint __tracepoint_android_vh_futex_wake_this'
  'struct tracepoint __tracepoint_android_vh_futex_wake_traverse_plist'
  'struct tracepoint __tracepoint_android_vh_futex_wake_up_q_finish'

function symbol changed from 'unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup*, unsigned long, gfp_t, bool)' to 'unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup*, unsigned long, gfp_t, unsigned int)'
  CRC changed from 0x79f1d652 to 0x843f8baf
  type changed from 'unsigned long(struct mem_cgroup*, unsigned long, gfp_t, bool)' to 'unsigned long(struct mem_cgroup*, unsigned long, gfp_t, unsigned int)'
    parameter 4 type changed from 'bool' = '_Bool' to 'unsigned int'
      resolved type changed from '_Bool' to 'unsigned int'

function symbol 'struct block_device* I_BDEV(struct inode*)' changed
  CRC changed from 0xf2df037e to 0x5b8d1e5

function symbol 'void __ClearPageMovable(struct page*)' changed
  CRC changed from 0xafefd4e to 0x12b3b0b6

function symbol 'void __SetPageMovable(struct page*, struct address_space*)' changed
  CRC changed from 0x76517c1e to 0x2f7e012

... 1717 omitted; 1720 symbols have only CRC changes

type 'struct request' changed
  byte size changed from 304 to 328
  member 'struct { struct io_cq* icq; void* priv[2]; } elv' was added
  member 'struct { unsigned int seq; struct list_head list; rq_end_io_fn* saved_end_io; } flush' was added
  member 'union { struct { struct io_cq* icq; void* priv[2]; } elv; struct { unsigned int seq; struct list_head list; rq_end_io_fn* saved_end_io; } flush; }' was removed
  19 members ('struct gendisk* rq_disk' .. 'u64 android_kabi_reserved1') changed
    offset changed by 192

type 'struct rq' changed
  byte size changed from 4544 to 4608
  member 'unsigned long cpu_capacity_inverted' was added
  10 members ('struct callback_head* balance_callback' .. 'struct list_head cfs_tasks') changed
    offset changed by 64
  35 members ('struct sched_avg avg_rt' .. 'u64 android_kabi_reserved4') changed
    offset changed by 512

type 'struct cfg80211_conn' changed
  was fully defined, is now only declared

type 'struct cfg80211_cached_keys' changed
  was fully defined, is now only declared

type 'struct cfg80211_cqm_config' changed
  was fully defined, is now only declared

type 'struct cfg80211_internal_bss' changed
  was fully defined, is now only declared

type 'struct pkvm_module_ops' changed
  byte size changed from 496 to 512
  member 'void(* update_hcr_el2)(unsigned long, unsigned long)' was added
  member 'void(* update_hfgwtr_el2)(unsigned long, unsigned long)' was added
  51 members ('int(* register_host_perm_fault_handler)(int(*)(struct kvm_cpu_context*, u64, u64))' .. 'u64 android_kabi_reserved32') changed
    offset changed by 128

Bug: 280599882
Change-Id: I797a325acc9e73853da7cce6be591402303f0467
Signed-off-by: Carlos Llamas <cmllamas@google.com>
2023-05-11 03:39:34 +00:00
Quentin Perret
085255b984 ANDROID: KVM: arm64: Allow tweaking HFGWTR_EL2 from modules
pKVM modules may need to enable fine grain traps. To allow this
use-case, expose a function allowing to manipulate HFGWTR_EL2 on the
current CPU. This configuration will be persistent across power
management cycles and such as it is propagated all the way to the
init params per-cpu struct.

Bug: 245034629
Change-Id: If9c29849df50847d3a796345927bd51c37c358bc
Signed-off-by: Quentin Perret <qperret@google.com>
2023-05-11 03:05:59 +00:00
Quentin Perret
92c988d752 ANDROID: KVM: arm64: Allow tweaking HCR_EL2 from modules
pKVM modules may need to enable additional traps on top of what pKVM
already enables. To allow this use-case, expose a function allowing to
manipulate HCR_EL2 on the current CPU. This configuration will be
persistent across power management cycles and such as it is propagated
all the way to the init params per-cpu struct.

Bug: 245034629
Change-Id: I21d596bd1d01f4edc48a188cc3c2eb78dc9a4444
Signed-off-by: Quentin Perret <qperret@google.com>
2023-05-11 03:05:58 +00:00
Ramji Jiyani
efc340f8e7 ANDROID: GKI: Trimmed symbol lists for 80211 modules
Converting cfg80211.ko & mac80211.ko as vendor modules
made some symbols cited in the symbol lists for partners
but are no longer available in ksymtab as these features
are disabled in the gki_defconfit to convert them to vendor
modules.

Manually trimmed the symbol lists for builds to succeed.

Bug: 281137343
Test: TH
Change-Id: Ieb60c12ddb4f2b89aa387df2d69c31f8cfee54d8
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
2023-05-11 03:05:58 +00:00
Ramji Jiyani
e056397e42 ANDROID: GKI: DB845C: cfg/mac 80211 as vendor modules
Enabled cfg80211.ko and mac80211.ko as vendor module for
db845c target.

Bug: 281137343
Test: TH
Change-Id: I466cbcc81598c3ff127078195974e4cedb2597a1
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
2023-05-11 03:05:58 +00:00
Ramji Jiyani
ee1e4b7c5e ANDROID: GKI: cfg/mac 80211 as vendor modules
Convert cfg80211.ko and mac80211.ko as vendor modules to
pave a way for merging 802.11be Wi-Fi 7 functionalities
from upstream over the next year without affecting the KMI.

Bug: 281137343
Test: TH
Change-Id: Id1823924a3e5d8d03518599e6b3209e9cdd771d5
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
2023-05-11 03:05:58 +00:00
Bart Van Assche
f6d290fd57 ANDROID: block: Prepare for preserving the zoned write order
This patch does not change any functionality. This patch is a subset of
the following patch that is expected to be merged upstream soon:
https://lore.kernel.org/linux-block/20230407235822.1672286-3-bvanassche@acm.org/

Bug: 275581839
Bug: 277112517
Change-Id: I717d1c78233b92fd18297c81ef15335684da5d54
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-05-11 03:05:58 +00:00
xieliujie
b21f9994da ANDROID: ABI: Update oplus symbol list
6 function symbol(s) added
  'int __traceiter_android_vh_do_futex(void*, int, unsigned int*, u32*)'
  'int __traceiter_android_vh_futex_wait_end(void*, unsigned int, u32)'
  'int __traceiter_android_vh_futex_wait_start(void*, unsigned int, u32)'
  'int __traceiter_android_vh_futex_wake_this(void*, int, int, int, struct task_struct*)'
  'int __traceiter_android_vh_futex_wake_traverse_plist(void*, struct plist_head*, int*, union futex_key, u32)'
  'int __traceiter_android_vh_futex_wake_up_q_finish(void*, int, int)'

6 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_do_futex'
  'struct tracepoint __tracepoint_android_vh_futex_wait_end'
  'struct tracepoint __tracepoint_android_vh_futex_wait_start'
  'struct tracepoint __tracepoint_android_vh_futex_wake_this'
  'struct tracepoint __tracepoint_android_vh_futex_wake_traverse_plist'
  'struct tracepoint __tracepoint_android_vh_futex_wake_up_q_finish'

function symbol 'int __traceiter_android_rvh_cgroup_force_kthread_migration(void*, struct task_struct*, struct cgroup*, bool*)' changed
  CRC changed from 0xed48aa7b to 0x2957dc40

function symbol 'int __traceiter_android_rvh_cpu_cgroup_online(void*, struct cgroup_subsys_state*)' changed
  CRC changed from 0xccff069c to 0x6414873c

function symbol 'int __traceiter_android_rvh_gic_v3_set_affinity(void*, struct irq_data*, const struct cpumask*, u64*, bool, void*, void*, u64)' changed
  CRC changed from 0xcecd5d30 to 0x9f93d48d

... 27 omitted; 30 symbols have only CRC changes

Bug: 279355016
Bug: 243110112
Change-Id: I50789ce1d771b6f2e858a987a62892d48f4359e4
Signed-off-by: xieliujie <xieliujie@oppo.com>
2023-05-11 03:05:50 +00:00
xieliujie
e5d032fb33 ANDROID: vendor_hooks: Add hooks for oem futex optimization
If an important task is going to sleep through do_futex(),
find out it's futex-owner by the pid comes from userspace,
and boost the owner by some means to shorten the sleep time.
How to boost? Depends on these hooks:
commit 53e8099784 ("ANDROID: vendor_hooks: Add hooks for scheduler")

Bug: 243110112
Signed-off-by: xieliujie <xieliujie@oppo.com>
Change-Id: I9a315cfb414fd34e0ef7a2cf9d57df50d4dd984f
(cherry picked from commit 548da5d23d)
2023-05-11 02:31:28 +00:00
Yosry Ahmed
17bdc39270 BACKPORT: mm: vmpressure: don't count proactive reclaim in vmpressure
memory.reclaim is a cgroup v2 interface that allows users to proactively
reclaim memory from a memcg, without real memory pressure.  Reclaim
operations invoke vmpressure, which is used: (a) To notify userspace of
reclaim efficiency in cgroup v1, and (b) As a signal for a memcg being
under memory pressure for networking (see
mem_cgroup_under_socket_pressure()).

For (a), vmpressure notifications in v1 are not affected by this change
since memory.reclaim is a v2 feature.

For (b), the effects of the vmpressure signal (according to Shakeel [1])
are as follows:
1. Reducing send and receive buffers of the current socket.
2. May drop packets on the rx path.
3. May throttle current thread on the tx path.

Since proactive reclaim is invoked directly by userspace, not by memory
pressure, it makes sense not to throttle networking.  Hence, this change
makes sure that proactive reclaim caused by memory.reclaim does not
trigger vmpressure.

[1] https://lore.kernel.org/lkml/CALvZod68WdrXEmBpOkadhB5GPYmCXaDZzXH=yyGOCAjFRn4NDQ@mail.gmail.com/

[yosryahmed@google.com: update documentation]
  Link: https://lkml.kernel.org/r/20220721173015.2643248-1-yosryahmed@google.com
Link: https://lkml.kernel.org/r/20220714064918.2576464-1-yosryahmed@google.com
Change-Id: I0e478c737dc9a17ad930fdf6fac0825b43285b29
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Acked-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: David Hildenbrand <david@redhat.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: NeilBrown <neilb@suse.de>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Peter Xu <peterx@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 73b73bac90)
Bug: 280056627
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2023-05-11 02:31:28 +00:00
Shakeel Butt
c9707c205c UPSTREAM: memcg: introduce per-memcg reclaim interface
This patch series adds a memory.reclaim proactive reclaim interface.
The rationale behind the interface and how it works are in the first
patch.

This patch (of 4):

Introduce a memcg interface to trigger memory reclaim on a memory cgroup.

Use case: Proactive Reclaim
---------------------------

A userspace proactive reclaimer can continuously probe the memcg to
reclaim a small amount of memory.  This gives more accurate and up-to-date
workingset estimation as the LRUs are continuously sorted and can
potentially provide more deterministic memory overcommit behavior.  The
memory overcommit controller can provide more proactive response to the
changing behavior of the running applications instead of being reactive.

A userspace reclaimer's purpose in this case is not a complete replacement
for kswapd or direct reclaim, it is to proactively identify memory savings
opportunities and reclaim some amount of cold pages set by the policy to
free up the memory for more demanding jobs or scheduling new jobs.

A user space proactive reclaimer is used in Google data centers.
Additionally, Meta's TMO paper recently referenced a very similar
interface used for user space proactive reclaim:
https://dl.acm.org/doi/pdf/10.1145/3503222.3507731

Benefits of a user space reclaimer:
-----------------------------------

1) More flexible on who should be charged for the cpu of the memory
   reclaim.  For proactive reclaim, it makes more sense to be centralized.

2) More flexible on dedicating the resources (like cpu).  The memory
   overcommit controller can balance the cost between the cpu usage and
   the memory reclaimed.

3) Provides a way to the applications to keep their LRUs sorted, so,
   under memory pressure better reclaim candidates are selected.  This
   also gives more accurate and uptodate notion of working set for an
   application.

Why memory.high is not enough?
------------------------------

- memory.high can be used to trigger reclaim in a memcg and can
  potentially be used for proactive reclaim.  However there is a big
  downside in using memory.high.  It can potentially introduce high
  reclaim stalls in the target application as the allocations from the
  processes or the threads of the application can hit the temporary
  memory.high limit.

- Userspace proactive reclaimers usually use feedback loops to decide
  how much memory to proactively reclaim from a workload.  The metrics
  used for this are usually either refaults or PSI, and these metrics will
  become messy if the application gets throttled by hitting the high
  limit.

- memory.high is a stateful interface, if the userspace proactive
  reclaimer crashes for any reason while triggering reclaim it can leave
  the application in a bad state.

- If a workload is rapidly expanding, setting memory.high to proactively
  reclaim memory can result in actually reclaiming more memory than
  intended.

The benefits of such interface and shortcomings of existing interface were
further discussed in this RFC thread:
https://lore.kernel.org/linux-mm/5df21376-7dd1-bf81-8414-32a73cea45dd@google.com/

Interface:
----------

Introducing a very simple memcg interface 'echo 10M > memory.reclaim' to
trigger reclaim in the target memory cgroup.

The interface is introduced as a nested-keyed file to allow for future
optional arguments to be easily added to configure the behavior of
reclaim.

Possible Extensions:
--------------------

- This interface can be extended with an additional parameter or flags
  to allow specifying one or more types of memory to reclaim from (e.g.
  file, anon, ..).

- The interface can also be extended with a node mask to reclaim from
  specific nodes. This has use cases for reclaim-based demotion in memory
  tiering systens.

- A similar per-node interface can also be added to support proactive
  reclaim and reclaim-based demotion in systems without memcg.

- Add a timeout parameter to make it easier for user space to call the
  interface without worrying about being blocked for an undefined amount
  of time.

For now, let's keep things simple by adding the basic functionality.

[yosryahmed@google.com: worked on versions v2 onwards, refreshed to
current master, updated commit message based on recent
discussions and use cases]
Link: https://lkml.kernel.org/r/20220425190040.2475377-1-yosryahmed@google.com
Link: https://lkml.kernel.org/r/20220425190040.2475377-2-yosryahmed@google.com
Change-Id: Idaaac964dd5169376fcceca35f0676f847069bce
Signed-off-by: Shakeel Butt <shakeelb@google.com>
Co-developed-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Wei Xu <weixugc@google.com>
Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Zefan Li <lizefan.x@bytedance.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Yu Zhao <yuzhao@google.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Greg Thelen <gthelen@google.com>
Cc: Chen Wandun <chenwandun@huawei.com>
Cc: Vaibhav Jain <vaibhav@linux.ibm.com>
Cc: "Michal Koutn" <mkoutny@suse.com>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 94968384dd)
Bug: 280056627
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2023-05-11 02:31:28 +00:00
Greg Kroah-Hartman
dad20f7a85 Revert "Revert "sched/fair: Fixes for capacity inversion detection""
This reverts commit 937164e07b8e56fa2e34bf05ee956ac4fe6a6b47.

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

Change-Id: Ie7aaed3a99ce91258f7eae8683ea27b4d807b7b4
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 02:31:28 +00:00
Greg Kroah-Hartman
60e138c123 Revert "Revert "sched/uclamp: Fix a uninitialized variable warnings""
This reverts commit be0a0feb8e627f2f2f5324c65e5f91f921d4c1b8.

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

Change-Id: I8913de3e6e83876a2b2ed4460c935c3adb2a0721
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 02:31:28 +00:00
Greg Kroah-Hartman
745bc5edc0 Revert "Revert "sched/fair: Consider capacity inversion in util_fits_cpu()""
This reverts commit 16ed1a1dc35911c07b5978781cc4dd54d86a73b1.

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

Change-Id: If9b195f46c800a362857e91a349ed3aad4606030
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 02:31:27 +00:00
Greg Kroah-Hartman
96fa320d7c Revert "Revert "sched/fair: Detect capacity inversion""
This reverts commit 4c150ff0cc193b3b1fc6f0f68a4d79f9aac4f338.

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

Change-Id: Ibae2a63d0d9287f4cbcae1e34b467bdf5c82576b
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-05-11 02:31:27 +00:00
Greg Kroah-Hartman
137e27448f Revert "ANDROID: preserve CRC for xhci symbols"
This reverts commit fcaf5d8a67.

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

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I97c5ce73a4a6b6bcfc009547bb557141d21d4dd4
2023-05-11 02:31:27 +00:00
Ulises Mendez Martinez
bee3580753 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:32 +00:00
Quentin Perret
ad4cc91ca6 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:46:22 +00:00
Yifan Hong
961f2bd43e 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:15 +00:00
Debarshi Dutta
f162fabf2b ANDROID: Update the ABI symbol list
Adding the following symbols:
  - param_get_int

Bug: 280403621
Bug: 278174418
Change-Id: Ie5a8875c1b18b40a3930138a43efcdf6258e509f
Signed-off-by: Debarshi Dutta <debarshid@google.com>
2023-05-09 10:02:20 +00:00
Krishna Kurapati
fc9823eddc 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:47:56 +00:00
Neill Kapron
df4ee615e0 Revert "ANDROID: uid_sys_stat: split the global lock uid_lock to the fine-grained"
This reverts commit 08a2bdeaad.

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

Change-Id: Idd97ce620c0f399ec891e0474ee9876275c0f9c8
Signed-off-by: Neill Kapron <nkapron@google.com>
2023-05-09 04:53:38 +00:00
Wanwei Jiang
625a05a48a ANDROID: GKI: Update symbol list for Amlogic
2 function symbol(s) added
  'int __traceiter_android_vh_cma_drain_all_pages_bypass(void*, unsigned int, bool*)'
  'struct cgroup_subsys_state* css_next_descendant_pre(struct cgroup_subsys_state*, struct cgroup_subsys_state*)'

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

Bug: 280418312
Change-Id: Ie99a46ddfefda163cbbfbd005390d15f7428fea6
Signed-off-by: Wanwei Jiang <wanwei.jiang@amlogic.com>
2023-05-09 03:20:56 +00:00
Ramji Jiyani
3cae1f44dd 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:40 +00:00
Ramji Jiyani
896a2f6ac8 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 16:11:24 -07:00
Carlos Llamas
913110b790 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-06 01:45:34 +00:00
Liujie Xie
73042c1155 ANDROID: ABI: Update oplus symbol list
17 function symbol(s) added
  '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_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_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*)'

17 variable symbol(s) added
  '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_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_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: I81b918a185ee810af97b56f1fc695af45119c1e8
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
Signed-off-by: Carlos Llamas <cmllamas@google.com>
2023-05-06 00:25:54 +00:00
Liujie Xie
ad62172a4b 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-06 00:25:54 +00:00
Liujie Xie
ca14c8d469 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-06 00:25:54 +00:00
Liujie Xie
456a8d4c1f 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-06 00:25:54 +00:00
Liujie Xie
c97f4f3ed5 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-06 00:25:54 +00:00
Liujie Xie
a945254842 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-06 00:25:54 +00:00
Adrian Salido
50bae08f22 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - __drmm_crtc_alloc_with_planes

Bug: 275278929
Change-Id: I5f6e650aa850eb2639abcf5c033e1ed43814d30f
Signed-off-by: Adrian Salido <salidoa@google.com>
2023-05-05 23:46:18 +00:00
Puma Hsu
358b59f1bc ANDROID: usb: Add vendor hook for usb suspend and resume
Add the hook that vendor can design and bypass the suspend/resume.
When the bypass is set, skip the orignal suspend/resume methods.

In mobile, a co-processor can be used with USB audio, and ACPU may
be able to sleep in such condition to improve power consumption.
We will need vendor hook to support this.

Bug: 192774581
Signed-off-by: Puma Hsu <pumahsu@google.com>
Change-Id: Ic62a8a1e662bbe3fb0aa17af7491daace0b9f18a
(cherry picked from commit 98085b5dd8)
2023-05-05 23:14:35 +00:00
JJ Lee
4cbf19a6f8 ANDROID: sound: usb: add vendor hook for cpu suspend support
Add vendor hook android_vh_sound_check_support_cpu_suspend
to allow ACPU to suspend during USB playback/capture,
if this is supported.

Bug: 192206510
Change-Id: Ia8d4c335db27de5fcefab13cab653fd1ae34f691
Signed-off-by: JJ Lee <leejj@google.com>
(cherry picked from commit e8516fd3af)
2023-05-05 23:14:35 +00:00
Albert Wang
3ac740c9c7 ANDROID: Update the ABI symbol list
Adding the following symbols:
  - __traceiter_android_rvh_usb_dev_suspend
  - __traceiter_android_vh_sound_usb_support_cpu_suspend
  - __traceiter_android_vh_usb_dev_resume
  - __tracepoint_android_rvh_usb_dev_suspend
  - __tracepoint_android_vh_sound_usb_support_cpu_suspend
  - __tracepoint_android_vh_usb_dev_resume

Bug: 255700946
Change-Id: I2860d50bf30714cfb627df710f3a4a9faa5f04b4
Signed-off-by: Albert Wang <albertccwang@google.com>
2023-05-05 23:14:35 +00:00
xieliujie
d03243dd76 ANDROID: ABI: Update oplus symbol list
1 function symbol(s) added
  'int __traceiter_sched_stat_runtime(void*, struct task_struct*, u64, u64)'

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

Bug: 193384408
Change-Id: I76ddd3ec107c1474b53a3a0c4bd0fa4386ac6ac3
Signed-off-by: xieliujie <xieliujie@oppo.com>
2023-05-05 22:58:16 +00:00