Commit Graph

988516 Commits

Author SHA1 Message Date
Jerome Brunet
9b70ff660f BACKPORT: arm64: meson: select COMMON_CLK
This fix the recent removal of clock drivers selection.
While it is not necessary to select the clock drivers themselves, we need
to select a proper implementation of the clock API, which for the meson, is
CCF

Bug: 254441685
Fixes: ba66a25536 ("arm64: meson: ship only the necessary clock controllers")
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://lore.kernel.org/r/20210429083823.59546-1-jbrunet@baylibre.com
(cherry picked from commit 4cce442ffe)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I8de74575043f4e1d170310357f850c9ae8855d72
2022-11-23 11:15:51 +00:00
Masahiro Yamada
05fbbf0d13 UPSTREAM: tools: do not include scripts/Kbuild.include
Since commit 57fd251c78 ("kbuild: split cc-option and friends to
scripts/Makefile.compiler"), some kselftests fail to build.

The tools/ directory opted out Kbuild, and went in a different
direction. People copied scripts and Makefiles to the tools/ directory
to create their own build system.

tools/build/Build.include mimics scripts/Kbuild.include, but some
tool Makefiles include the Kbuild one to import a feature that is
missing in tools/build/Build.include:

 - Commit ec04aa3ae8 ("tools/thermal: tmon: use "-fstack-protector"
   only if supported") included scripts/Kbuild.include from
   tools/thermal/tmon/Makefile to import the cc-option macro.

 - Commit c2390f16fc ("selftests: kvm: fix for compilers that do
   not support -no-pie") included scripts/Kbuild.include from
   tools/testing/selftests/kvm/Makefile to import the try-run macro.

 - Commit 9cae4ace80 ("selftests/bpf: do not ignore clang
   failures") included scripts/Kbuild.include from
   tools/testing/selftests/bpf/Makefile to import the .DELETE_ON_ERROR
   target.

 - Commit 0695f8bca9 ("selftests/powerpc: Handle Makefile for
   unrecognized option") included scripts/Kbuild.include from
   tools/testing/selftests/powerpc/pmu/ebb/Makefile to import the
   try-run macro.

Copy what they need into tools/build/Build.include, and make them
include it instead of scripts/Kbuild.include.

Bug: 254441685
Link: https://lore.kernel.org/lkml/86dadf33-70f7-a5ac-cb8c-64966d2f45a1@linux.ibm.com/
Fixes: 57fd251c78 ("kbuild: split cc-option and friends to scripts/Makefile.compiler")
Reported-by: Janosch Frank <frankja@linux.ibm.com>
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Yonghong Song <yhs@fb.com>
(cherry picked from commit b61442df74)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ie17d3ba0bb20a7457a31d10a7c09163aa10e0ea4
2022-11-23 11:15:51 +00:00
Masahiro Yamada
924872e549 UPSTREAM: kbuild: dummy-tools: adjust to scripts/cc-version.sh
Commit aec6c60a01 ("kbuild: check the minimum compiler version in
Kconfig") changed how the script detects the compiler version.

Get 'make CROSS_COMPILE=scripts/dummy-tools/' back working again.

Bug: 254441685
Fixes: aec6c60a01 ("kbuild: check the minimum compiler version in Kconfig")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Miguel Ojeda <ojeda@kernel.org>
(cherry picked from commit f9bc754be4)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I0ce942de1dbc16dd8b974296bc2fd3cc703e49e5
2022-11-23 11:15:51 +00:00
Masahiro Yamada
252e42f395 UPSTREAM: kbuild: do not include include/config/auto.conf from adjust_autoksyms.sh
Commit cd195bc477 ("kbuild: split adjust_autoksyms.sh in two parts")
split out the code that needs include/config/auto.conf.

This script no longer needs to include include/config/auto.conf.

Bug: 254441685
Fixes: cd195bc477 ("kbuild: split adjust_autoksyms.sh in two parts")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
(cherry picked from commit 12e9dea6c9)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I1c2cb44a3266e935f1c23cf8c4edd90ca1a05a0f
2022-11-23 11:15:51 +00:00
Adrian Hunter
b9a8323fde UPSTREAM: scsi: docs: ABI: sysfs-driver-ufs: Add DeepSleep power mode
Update sysfs documentation for addition of DeepSleep power mode.

Bug: 254441685
Link: https://lore.kernel.org/r/20210104155026.16417-1-adrian.hunter@intel.com
Fixes: fe1d4c2ebc ("scsi: ufs: Add DeepSleep feature")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 0b2894cd0f)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I5ea96058d00237dc6133184ec621c675f9d9aa8f
2022-11-23 11:15:51 +00:00
Dan Vacura
26369cdee4 ANDROID: gki_defconfig: enable CONFIG_USB_CONFIGFS_F_UVC
Enable the UVC function driver to allow USB gadgets
to connect as a standard video device to a host.

Bug: 200712777
Bug: 242344221
Signed-off-by: Dan Vacura <w36195@motorola.com>
Change-Id: Ia037f8560664f9e98f28f3fede609764d5d5699d
(cherry picked from commit 8d5dd0a5a4)
(cherry picked from commit 885f16fab68e456b9dc9856641b706ce17551456)
2022-11-23 07:33:52 +00:00
Suren Baghdasaryan
0481654d9f ANDROID: mm: disable speculative page faults for CONFIG_NUMA
NUMA support with speculative page faults might be broken if
vma_replace_policy() replaces the mempolicy object used in
do_anonymous_page()
 alloc_zeroed_user_highpage_movable()
  alloc_page_vma()
    alloc_pages_vma()
      get_vma_policy()
__get_vma_policy() in speculative path does not always refcounts the
mempolicy object, therefore can't be relied on stabilizing it.
Rather than fixing this, just disable speculation for CONFIG_NUMA
for now and fix it if it's ever needed in Android.

Bug: 257443051
Change-Id: Ib5750b9809979a69a42ebfa6c130e123f416f1aa
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2022-11-22 11:37:46 -08:00
Suren Baghdasaryan
f6ddc1c41e ANDROID: mm: fix invalid backport in speculative page fault path
Invalid condition was introduced when porting the original SPF patch
which would affect NUMA mode.

Fixes: 736ae8bde8 ("FROMLIST: mm: adding speculative page fault failure trace events")
Bug: 257443051
Change-Id: Ib20c625615b279dc467588933a1f598dc179861b
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2022-11-22 10:51:25 -08:00
Suren Baghdasaryan
c3f0fd7976 ANDROID: disable page table moves when speculative page faults are enabled
move_page_tables() can move entire pmd or pud without locking individual
ptes. This is problematic for speculative page faults which do not take
mmap_lock because they rely on ptl lock when writing new pte value. To
avoid possible race, disable move_page_tables() optimization when
CONFIG_SPECULATIVE_PAGE_FAULT is enabled.

Bug: 257443051
Change-Id: Ib48dda08ecad1abc60d08fc089a6566a63393c13
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2022-11-21 12:54:47 -08:00
Suren Baghdasaryan
3d3b77c9c0 ANDROID: mm: assert that mmap_lock is taken exclusively in vm_write_begin
vm_write_{begin|end} has to be called when mmap_lock is taken
exlusively. Add an assert statement in vm_write_begin to enforce
that. free_pgtables can free page tables without exclusive mmap_lock
if the vma was isolated, therefore avoid assertions in such cases.

Bug: 257443051
Change-Id: Ie81aefe025c743cda6f66717d2f08f4d78a55608
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2022-11-21 12:54:45 -08:00
Suren Baghdasaryan
df62da3909 ANDROID: mm: remove sequence counting when mmap_lock is not exclusively owned
In a number of cases vm_write_{begin|end} is called while mmap_lock is
not owned exclusively. This is unnecessary and can affect correctness of
the sequence counting protecting speculative page fault handlers. Remove
extra calls.

Bug: 257443051
Change-Id: I1278638a0794448e22fbdab5601212b3b2eaebdc
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2022-11-21 12:54:43 -08:00
Suren Baghdasaryan
66544e79f4 ANDROID: mm/khugepaged: add missing vm_write_{begin|end}
Speculative page fault handler needs to detect concurrent pmd changes
and relies on vma seqcount for that. pmdp_collapse_flush(), set_huge_pmd() and collapse_and_free_pmd() can modify a pmd.
vm_write_{begin|end} are needed in the paths which can call these
functions for page fault handler to detect pmd changes.

Bug: 257443051
Change-Id: Ieb784b5f44901b66a594f61b9e7c91190ff97f80
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2022-11-21 12:54:15 -08:00
Michel Lespinasse
2a3979df04 BACKPORT: FROMLIST: mm: implement speculative handling in filemap_fault()
Extend filemap_fault() to handle speculative faults.

In the speculative case, we will only be fishing existing pages out of
the page cache. The logic we use mirrors what is done in the
non-speculative case, assuming that pages are found in the page cache,
are up to date and not already locked, and that readahead is not
necessary at this time. In all other cases, the fault is aborted to be
handled non-speculatively.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20210407014502.24091-26-michel@lespinasse.org/

Conflicts:
    mm/filemap.c

1. Added back file_ra_state variable used by SPF path.
2. Updated comment for filemap_fault to reflect SPF locking rules.

Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I82eba7fcfc81876245c2e65bc5ae3d33ddfcc368
2022-11-21 10:55:56 -08:00
Suren Baghdasaryan
ec35e912e7 ANDROID: mm: prevent reads of unstable pmd during speculation
Checks of pmd during speculative page fault handling are racy because
pmd is unprotected and might be modified or cleared. This might cause
use-after-free reads from speculative path, therefore prevent such
checks. At the beginning of speculation pmd is checked to be valid and
if it's changed before page fault is handled, the change will be detected
and page fault will be retried under mmap_lock protection.

Bug: 257443051
Change-Id: I0cbd3b0b44e8296cf0d6cb298fae48c696580068
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2022-11-21 10:55:56 -08:00
Suren Baghdasaryan
ce7fa7020a ANDROID: mm: prevent speculative page fault handling for in do_swap_page()
do_swap_page() uses migration_entry_wait() which operates on page tables
without protection. Disable speculative page fault handling.

Bug: 257443051
Change-Id: I677eb1ee85707dce533d5d811dcde5f5dabcfdf3
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2022-11-21 10:55:56 -08:00
Suren Baghdasaryan
4812532ece ANDROID: mm: prevent speculative page fault handling for userfaults
handle_userfault() should be protected against a concurrent
userfaultfd_release(), therefore handling a userfaults speculatively
without mmap_lock protection should be disallowed.

Bug: 257443051
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ic6ae39329c73e8849048ea15b5351a49346404d3
2022-11-21 10:55:56 -08:00
Suren Baghdasaryan
43247cf563 ANDROID: mm: skip pte_alloc during speculative page fault
Speculative page fault checks pmd to be valid before starting to handle
the page fault and pte_alloc() should do nothing if pmd stays valid.
If pmd gets changed during speculative page fault, we will detect the
change later and retry with mmap_lock. Therefore pte_alloc() can be
safely skipped and this prevents the racy pmd_lock() call which can
access pmd->ptl after pmd was cleared.

Bug: 257443051
Change-Id: Iec57df5530dba6e0e0bdf9f7500f910851c3d3fd
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2022-11-21 10:55:55 -08:00
Kever Yang
2f2dc42fbf ANDROID: GKI: rockchip: Add symbols for cpufreq
10 symbol(s) added
  'void cpufreq_dbs_governor_exit(struct cpufreq_policy *)'
  'int cpufreq_dbs_governor_init(struct cpufreq_policy *)'
  'void cpufreq_dbs_governor_limits(struct cpufreq_policy *)'
  'int cpufreq_dbs_governor_start(struct cpufreq_policy *)'
  'void cpufreq_dbs_governor_stop(struct cpufreq_policy *)'
  'void cpufreq_unregister_governor(struct cpufreq_governor *)'
  'unsigned int dbs_update(struct cpufreq_policy *)'
  'void dev_pm_opp_put_prop_name(struct opp_table *)'
  'void gov_update_cpu_data(struct dbs_data *)'
  'ssize_t store_sampling_rate(struct gov_attr_set *, const char *, size_t)'

Bug: 239396464
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Change-Id: I63597fe92f0279199173f0190ef6d3da4f0164f4
2022-11-21 16:56:07 +00:00
Khalid Shaik
c8f45c4915 ANDROID: Update the ABI representation
1 function symbol(s) added
  'int __traceiter_android_rvh_do_sched_yield(void *, struct rq *)'

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

Bug: 254608320

Change-Id: I4b2ed24711889914c901f55bce70fdef8da8ae0b
Signed-off-by: Khalid Shaik <khalid.s@samsung.com>
2022-11-18 22:03:51 +00:00
Tengfei Fan
0fabf2342f ANDROID: sched: add hook point in do_sched_yield()
When a task yields, it relinquishes the cpu and
scheduler is tasked to find another task.
However our vendor scheduler logic implementation
could return the same task leading to a loop where
the yielded task gets to run back, so add hook point
in do_sched_yield() for vendor can do some work
before task is scheduled.

Bug: 205804537
Change-Id: I6528c3f4b0ee360559ef9c97cb1eb2b2d1357870
Signed-off-by: Tengfei Fan <quic_tengfan@quicinc.com>
Signed-off-by: Sai Harshini Nimmala <quic_snimmala@quicinc.com>
Signed-off-by: Khalid Shaik <khalid.s@samsung.com>
2022-11-18 22:03:51 +00:00
David Brazdil
2aed2a7cb0 ANDROID: KVM: arm64: s2mpu: Fix SYNC latency regression
SysMMU_SYNCs provide an invalidation-complete signal to the S2MPU
driver but the latency can be quite high. Improve this by waiting for
all the SYNCs in parallel - separate the initiation of invalidation
barrier from waiting for completion. This way we initiate invalidation
on all SYNCs first, then wait for all of them to complete.

The previously introduced exponential-backoff only kicks in if the
SYNC_COMP_COMPLETE bit is not set after the parallel invalidation.

Bug: 249161451
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I9d544bc65f8633d376c7ccd65ea23195ca432964
2022-11-18 15:35:18 +00:00
David Brazdil
e1ea4666e1 ANDROID: KVM: arm64: iommu: Add host_stage2_idmap_complete
Add a new callback to pkvm_iommu_ops called after
host_stage2_idmap_apply on all IOMMU devices. This allows the drivers to
complete operations like invalidation in two stages.

Bug: 249161451
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I9c077fd2b18ce54ad67eb34ef16bc94428797419
2022-11-18 15:35:18 +00:00
Quentin Perret
15e65b4a22 ANDROID: KVM: arm64: Issue CMOs when tearing down shadow pages
On the guest teardown path, pKVM will zero the pages used to back the
guest shadow data structures before returning them to the host as they
may contain secrets (e.g. in the vCPU registers). However, the zeroing
is done using a cacheable alias, and CMOs are missing, hence giving the
host a potential opportunity to read the original content of the shadow
structs from memory.

Fix this by issuing CMOs after zeroing the pages.

Bug: 259551298
Change-Id: Id696d47d16e4c3fd870cb70b792eeb7f2282fc78
Signed-off-by: Quentin Perret <qperret@google.com>
2022-11-17 17:22:34 +00:00
Mark Fasheh
80fcf382d1 ANDROID: Add ashmem ioctl to return a unique file identifier
This will allow a client program to avoid redundant actions on ashmem
buffers which it has already seen.

Bug: 244233389
Change-Id: Ica57a8842ff163eae5f9eca8141b439091ec0940
Signed-off-by: Mark Fasheh <mfasheh@google.com>
2022-11-17 17:01:16 +00:00
Khalid Shaik
056ee87d05 ANDROID: Update the ABI representation
28 function symbol(s) added
  'int __platform_register_drivers(struct platform_driver * const *, unsigned int, struct module *)'
  'int dapm_pinctrl_event(struct snd_soc_dapm_widget *, struct snd_kcontrol *, int)'
  'struct dentry * debugfs_create_symlink(const char *, struct dentry *, const char *)'
  'ssize_t device_show_bool(struct device *, struct device_attribute *, char *)'
  'ssize_t device_show_int(struct device *, struct device_attribute *, char *)'
  'ssize_t device_store_bool(struct device *, struct device_attribute *, const char *, size_t)'
  'ssize_t device_store_int(struct device *, struct device_attribute *, const char *, size_t)'
  'void * devm_krealloc(struct device *, void *, size_t, gfp_t)'
  'struct pinctrl * pinctrl_get(struct device *)'
  'int pm_runtime_barrier(struct device *)'
  'void pm_runtime_no_callbacks(struct device *)'
  'struct proc_dir_entry * proc_symlink(const char *, struct proc_dir_entry *, const char *)'
  'int snd_hwdep_new(struct snd_card *, char *, int, struct snd_hwdep * *)'
  'void snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *)'
  'unsigned int snd_pcm_rate_range_to_bits(unsigned int, unsigned int)'
  'int snd_soc_bytes_info_ext(struct snd_kcontrol *, struct snd_ctl_elem_info *)'
  'void snd_soc_component_async_complete(struct snd_soc_component *)'
  'int snd_soc_component_update_bits_async(struct snd_soc_component *, unsigned int, unsigned int, unsigned int)'
  'int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *, const char *)'
  'int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *, const struct snd_soc_dapm_route *, int)'
  'struct snd_soc_dai * snd_soc_find_dai(const struct snd_soc_dai_link_component *)'
  'int snd_soc_get_xr_sx(struct snd_kcontrol *, struct snd_ctl_elem_value *)'
  'int snd_soc_info_xr_sx(struct snd_kcontrol *, struct snd_ctl_elem_info *)'
  'int snd_soc_put_xr_sx(struct snd_kcontrol *, struct snd_ctl_elem_value *)'
  'int snd_soc_tplg_component_load(struct snd_soc_component *, struct snd_soc_tplg_ops *, const struct firmware *, u32)'
  'int snd_soc_tplg_component_remove(struct snd_soc_component *, u32)'
  'int snd_soc_tplg_widget_bind_event(struct snd_soc_dapm_widget *, const struct snd_soc_tplg_widget_events *, int, u16)'
  'void sysfs_remove_bin_file(struct kobject *, const struct bin_attribute *)'

Bug: 254608320

Change-Id: I8fbde2c3b7f2e68f58edc940315e28d9ffcc1e64
Signed-off-by: Khalid Shaik <khalid.s@samsung.com>
2022-11-17 16:14:21 +00:00
Will Deacon
b6cfd9d69f ANDROID: KVM: arm64: Fix repainting of PSCI SYSTEM_RESET2 calls
If the host issues a PSCI SYSTEM_RESET2 call requesting a warm reset
while guest pages are live in the system, then pKVM attempts to convert
this to a cold PSCI SYSTEM_RESET request to ensure the EL3 will clear
memory on the next boot. However, this logic is quite badly broken and
will instead attempt to take the 'mem_protect_lock' spinlock twice which
results in a deadlock.

Fix the repainting so that the 'host_ctxt' is updated inline and we
forward the updated request directly to EL3.

Signed-off-by: Will Deacon <will@kernel.org>
Bug: 259523340
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I44719466b7f5abddf73730a3b74db13f935f92ec
2022-11-17 12:31:49 +00:00
Khalid Shaik
03b60942fe ANDROID: Update the ABI representation
15 function symbol(s) added
  'bool cfg80211_chandef_valid(const struct cfg80211_chan_def *)'
  'unsigned int cfg80211_classify8021d(struct sk_buff *, struct cfg80211_qos_map *)'
  'void cfg80211_conn_failed(struct net_device *, const u8 *, enum nl80211_connect_failed_reason, gfp_t)'
  'void cfg80211_ref_bss(struct wiphy *, struct cfg80211_bss *)'
  'int class_create_file_ns(struct class *, const struct class_attribute *, void *)'
  'int dev_vprintk_emit(int, const struct device *, const char *, va_list)'
  'void dma_heap_buffer_free(struct dma_buf *)'
  'int genlmsg_multicast_allns(const struct genl_family *, struct sk_buff *, u32, unsigned int, gfp_t)'
  'struct iio_channel * iio_channel_get_all(struct device *)'
  'void iio_channel_release(struct iio_channel *)'
  'int iio_read_channel_raw(struct iio_channel *, int *)'
  'int irq_get_irqchip_state(unsigned int, enum irqchip_irq_state, bool *)'
  'void kfree_skb_list(struct sk_buff *)'
  'int sg_nents_for_len(struct scatterlist *, u64)'
  'void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *)'

1 variable symbol(s) added
  'const struct kernel_param_ops param_ops_ullong'

Bug: 254608320

Change-Id: I043e6d162e0502bc007645bbead98c8eba2ca15b
Signed-off-by: Khalid Shaik <khalid.s@samsung.com>
2022-11-16 16:26:07 +00:00
Khalid Shaik
d08c3d3ba2 ANDROID: Update the ABI representation
22 function symbol(s) added
  'int __traceiter_android_vh_show_mem(void *, unsigned int, nodemask_t *)'
  'void __wake_up_locked_key(struct wait_queue_head *, unsigned int, void *)'
  'struct file * anon_inode_getfile(const char *, const struct file_operations *, void *, int)'
  'int dma_buf_get_flags(struct dma_buf *, unsigned long int *)'
  'int do_wait_intr(wait_queue_head_t *, wait_queue_entry_t *)'
  'struct file * get_task_exe_file(struct task_struct *)'
  's32 i2c_smbus_write_word_data(const struct i2c_client *, u8, u16)'
  'struct iio_dev * iio_device_alloc(struct device *, int)'
  'void iio_device_free(struct iio_dev *)'
  'int is_dma_buf_file(struct file *)'
  'int iterate_fd(struct files_struct *, unsigned int, int(*)(void *, struct file *, unsigned int), void *)'
  'bool printk_timed_ratelimit(unsigned long int *, unsigned int)'
  'void release_pages(struct page * *, int)'
  'int rtc_set_time(struct rtc_device *, struct rtc_time *)'
  'void * typec_get_drvdata(struct typec_port *)'
  'struct typec_partner * typec_register_partner(struct typec_port *, struct typec_partner_desc *)'
  'struct typec_port * typec_register_port(struct device *, const struct typec_capability *)'
  'void typec_set_data_role(struct typec_port *, enum typec_data_role)'
  'void typec_set_pwr_opmode(struct typec_port *, enum typec_pwr_opmode)'
  'void typec_set_pwr_role(struct typec_port *, enum typec_role)'
  'void typec_unregister_partner(struct typec_partner *)'
  'void typec_unregister_port(struct typec_port *)'

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

Bug: 254608320

Change-Id: I9aa8df7bf0a1545264fd99637d76e24e56bafc32
Signed-off-by: Khalid Shaik <khalid.s@samsung.com>
2022-11-16 16:25:35 +00:00
Khalid Shaik
01645da2f5 ANDROID: Update the ABI representation
20 function symbol(s) added
  'struct vm_struct * __get_vm_area_caller(unsigned long int, unsigned long int, unsigned long int, unsigned long int, void *)'
  'void console_lock()'
  'void console_stop(struct console *)'
  'int dapm_regulator_event(struct snd_soc_dapm_widget *, struct snd_kcontrol *, int)'
  'int devm_hwrng_register(struct device *, struct hwrng *)'
  'int map_kernel_range(unsigned long int, unsigned long int, pgprot_t, struct page * *)'
  'struct proc_dir_entry * proc_create_seq_private(const char *, umode_t, struct proc_dir_entry *, const struct seq_operations *, unsigned int, void *)'
  'int regulator_force_disable(struct regulator *)'
  'int regulator_set_mode(struct regulator *, unsigned int)'
  'struct snd_soc_dapm_widget * snd_soc_dapm_new_control(struct snd_soc_dapm_context *, const struct snd_soc_dapm_widget *)'
  'struct snd_soc_pcm_runtime * snd_soc_get_pcm_runtime(struct snd_soc_card *, struct snd_soc_dai_link *)'
  'void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *)'
  '__poll_t v4l2_ctrl_poll(struct file *, struct poll_table_struct *)'
  'int v4l2_ctrl_subscribe_event(struct v4l2_fh *, const struct v4l2_event_subscription *)'
  'int v4l2_event_unsubscribe(struct v4l2_fh *, const struct v4l2_event_subscription *)'
  'int v4l2_fh_is_singular(struct v4l2_fh *)'
  'int v4l2_fh_release(struct file *)'
  'int v4l2_m2m_querybuf(struct file *, struct v4l2_m2m_ctx *, struct v4l2_buffer *)'
  'int vb2_prepare_buf(struct vb2_queue *, struct media_device *, struct v4l2_buffer *)'
  'int vsprintf(char *, const char *, va_list)'

4 variable symbol(s) added
  'fb_mode_option'
  'atomic_t ignore_console_lock_warning'
  'struct kmem_cache * names_cachep'
  'struct bus_type spi_bus_type'

Bug: 254608320

Change-Id: I8cc3e8bf07945c9be7c27e325c56890cc4ab007a
Signed-off-by: Khalid Shaik <khalid.s@samsung.com>
2022-11-16 15:43:01 +00:00
Rick Yiu
6c86db3f70 ANDROID: Update the ABI representation
1 function symbol(s) added
  'void reweight_task(struct task_struct *, int)'

Bug: 245675204
Change-Id: I30841b0f9fe67009aaa3cace864df75d0f3b4bfc
Signed-off-by: Rick Yiu <rickyiu@google.com>
2022-11-16 08:05:18 +00:00
Rick Yiu
db144888f8 ANDROID: kernel: sched: Export reweight_task
Export reweight_task for vendor usage when they are trying to manipulate
task prio. After the prio changed, it will need to update its load
weight to take effect. Therefore, this function needs to be called
from vendor kernel module. It could be used with
trace_android_rvh_set_user_nice and trace_android_rvh_setscheduler.

Bug: 245675204
Change-Id: I0033518bf1cbd0a8129795743b95340f439d5fe8
Signed-off-by: Rick Yiu <rickyiu@google.com>
2022-11-16 08:05:18 +00:00
Jaegeuk Kim
6f642cd2f2 FROMGIT: f2fs: allow to read node block after shutdown
If block address is still alive, we should give a valid node block even after
shutdown. Otherwise, we can see zero data when reading out a file.

Bug: 257271565
Cc: stable@vger.kernel.org
Fixes: 83a3bfdb5a ("f2fs: indicate shutdown f2fs to allow unmount successfully")
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit 6953bf65286d git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev)
Change-Id: Ifb70f6c73bd67d5112ee9fa1a5e4ad8e10ae8517
2022-11-15 19:18:47 +00:00
Ray Chi
92a7e867cf FROMGIT: usb: core: stop USB enumeration if too many retries
When a broken USB accessory connects to a USB host, usbcore might
keep doing enumeration retries. If the host has a watchdog mechanism,
the kernel panic will happen on the host.

This patch provides an attribute early_stop to limit the numbers of retries
for each port of a hub. If a port was marked with early_stop attribute,
unsuccessful connection attempts will fail quickly. In addition, if an
early_stop port has failed to initialize, it will ignore all future
connection events until early_stop attribute is clear.

Signed-off-by: Ray Chi <raychi@google.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20221107072754.3336357-1-raychi@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 236915598
(cherry picked from commit 430d57f53e
https: //git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ usb-next)
Change-Id: Ib85522ca38c0f26ece9807d5304991853f155669
Signed-off-by: Ray Chi <raychi@google.com>
2022-11-15 04:54:20 +00:00
Will Deacon
f3fe2e6612 ANDROID: KVM: arm64: Adjust PSCI MEM_PROTECT refcount across share/unshare
When a protected guest shares or unshares a page with the host, we
should decrement and increment the PSCI MEM_PROTECT refcount respectively
since shared pages do not require poisoning on the reclaim path and will
therefore not be accounted for.

Bug: 258425493
Reported-by: Quentin Perret <qperret@google.com>
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I80a4fad44de4313c6708a8259a1802ded379f03b
2022-11-15 04:05:41 +00:00
Matthew Wilcox (Oracle)
e7b635a520 BACKPORT: ext4,f2fs: fix readahead of verity data
The recent change of page_cache_ra_unbounded() arguments was buggy in the
two callers, causing us to readahead the wrong pages.  Move the definition
of ractl down to after the index is set correctly.  This affected
performance on configurations that use fs-verity.

Link: https://lkml.kernel.org/r/20221012193419.1453558-1-willy@infradead.org
Fixes: 73bb49da50 ("mm/readahead: make page_cache_ra_unbounded take a readahead_control")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reported-by: Jintao Yin <nicememory@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Bug: 258554362
(cherry picked from commit 4fa0e3ff21)
Change-Id: Ib5160c5c53629be328c370f5d5d464956d6a6312
Signed-off-by: Eric Biggers <ebiggers@google.com>
2022-11-15 01:01:59 +00:00
Khalid Shaik
c57ed31850 ANDROID: Update the ABI representation
39 function symbol(s) added
  'int __traceiter_android_rvh_can_migrate_task(void *, struct task_struct *, int, int *)'
  'int __traceiter_android_rvh_cpu_cgroup_can_attach(void *, struct cgroup_taskset *, int *)'
  'int __traceiter_android_rvh_find_busiest_queue(void *, int, struct sched_group *, struct cpumask *, struct rq * *, int *)'
  'int __traceiter_android_rvh_find_lowest_rq(void *, struct task_struct *, struct cpumask *, int, int *)'
  'int __traceiter_android_rvh_find_new_ilb(void *, struct cpumask *, int *)'
  'int __traceiter_android_rvh_replace_next_task_fair(void *, struct rq *, struct task_struct * *, struct sched_entity * *, bool *, bool, struct task_struct *)'
  'int __traceiter_android_rvh_sched_fork_init(void *, struct task_struct *)'
  'int __traceiter_android_rvh_sched_newidle_balance(void *, struct rq *, struct rq_flags *, int *, int *)'
  'int __traceiter_android_rvh_sched_nohz_balancer_kick(void *, struct rq *, unsigned int *, int *)'
  'int __traceiter_android_rvh_sched_rebalance_domains(void *, struct rq *, int *)'
  'int __traceiter_android_rvh_select_fallback_rq(void *, int, struct task_struct *, int *)'
  'int __traceiter_android_vh_binder_wakeup_ilocked(void *, struct task_struct *, bool, struct binder_proc *)'
  'int __traceiter_binder_transaction_received(void *, struct binder_transaction *)'
  'int __traceiter_ipi_entry(void *, const char *)'
  'int __traceiter_ipi_exit(void *, const char *)'
  'int __traceiter_ipi_raise(void *, const struct cpumask *, const char *)'
  'int _raw_write_trylock(rwlock_t *)'
  'void activate_task(struct rq *, struct task_struct *, int)'
  'caches_clean_inval_pou'
  'struct task_struct * cgroup_taskset_first(struct cgroup_taskset *, struct cgroup_subsys_state * *)'
  'struct task_struct * cgroup_taskset_next(struct cgroup_taskset *, struct cgroup_subsys_state * *)'
  'void cpu_hotplug_disable()'
  'void cpu_hotplug_enable()'
  'int cpufreq_frequency_table_get_index(struct cpufreq_policy *, unsigned int)'
  'struct cpuidle_driver * cpuidle_get_cpu_driver(struct cpuidle_device *)'
  'void deactivate_task(struct rq *, struct task_struct *, int)'
  'const struct cpumask * housekeeping_cpumask(enum hk_flags)'
  'u64 int_pow(u64, unsigned int)'
  'void kick_all_cpus_sync()'
  'ssize_t memory_read_from_buffer(void *, size_t, loff_t *, void *, size_t)'
  'int raw_notifier_chain_unregister(struct raw_notifier_head *, struct notifier_block *)'
  'struct reciprocal_value reciprocal_value(u32)'
  'void refresh_frequency_limits(struct cpufreq_policy *)'
  'void set_next_entity(struct cfs_rq *, struct sched_entity *)'
  'void set_task_cpu(struct task_struct *, unsigned int)'
  'void smp_call_function_many(const struct cpumask *, smp_call_func_t, void *, bool)'
  'bool stop_one_cpu_nowait(unsigned int, cpu_stop_fn_t, void *, struct cpu_stop_work *)'
  'const struct cpumask * system_32bit_el0_cpumask()'
  'void wake_up_if_idle(int)'

17 variable symbol(s) added
  'struct tracepoint __tracepoint_android_rvh_can_migrate_task'
  'struct tracepoint __tracepoint_android_rvh_cpu_cgroup_can_attach'
  'struct tracepoint __tracepoint_android_rvh_find_busiest_queue'
  'struct tracepoint __tracepoint_android_rvh_find_lowest_rq'
  'struct tracepoint __tracepoint_android_rvh_find_new_ilb'
  'struct tracepoint __tracepoint_android_rvh_replace_next_task_fair'
  'struct tracepoint __tracepoint_android_rvh_sched_fork_init'
  'struct tracepoint __tracepoint_android_rvh_sched_newidle_balance'
  'struct tracepoint __tracepoint_android_rvh_sched_nohz_balancer_kick'
  'struct tracepoint __tracepoint_android_rvh_sched_rebalance_domains'
  'struct tracepoint __tracepoint_android_rvh_select_fallback_rq'
  'struct tracepoint __tracepoint_android_vh_binder_wakeup_ilocked'
  'struct tracepoint __tracepoint_binder_transaction_received'
  'struct tracepoint __tracepoint_ipi_entry'
  'struct tracepoint __tracepoint_ipi_exit'
  'struct tracepoint __tracepoint_ipi_raise'
  'const char * const sched_feat_names[24]'

Bug: 254608320
Change-Id: Ie0a5acd2ecebf98572d99b31ee464dd161d7dd7b
Signed-off-by: Khalid Shaik <khalid.s@samsung.com>
2022-11-14 20:07:18 +00:00
Martin Liu
bcf1e503f5 ANDROID: adjust vendor hook to control blk_plug
We shouldn't hold lru_lock to proceed blk_finish_plug.

Fixes: 89fed37332 ("ANDROID: vendor hook to control blk_plug for shrink_lruvec")
Bug: 255471591
Change-Id: Ie9d9b0e4ee76b4735e802b2a202fbb79d0ae090e
Signed-off-by: Martin Liu <liumartin@google.com>
2022-11-14 19:50:30 +00:00
Akilesh Kailash
6cbaa88f4a ANDROID: dm-user: Remove bio recount in I/O path
When I/O is submitted to dm-user target, bio already
has a referance. Additional referance is not needed
in the I/O path.

Bug: 229696117
Test: OTA on Pixel
Change-Id: I8db6802e751336d7a10c6de0bc7a247a6d7f6b37
Signed-off-by: Akilesh Kailash <akailash@google.com>
2022-11-10 17:48:52 +00:00
Khalid Shaik
69e2e9275b ANDROID: Update the ABI representation
10 function symbol(s) added
  'int __traceiter_dwc3_ep_queue(void *, struct dwc3_request *)'
  'int __traceiter_hrtimer_expire_entry(void *, struct hrtimer *, ktime_t *)'
  'int __traceiter_hrtimer_expire_exit(void *, struct hrtimer *)'
  'int __traceiter_workqueue_execute_end(void *, struct work_struct *, work_func_t)'
  'int __traceiter_workqueue_execute_start(void *, struct work_struct *)'
  'int __v4l2_device_register_subdev_nodes(struct v4l2_device *, bool)'
  'void backlight_device_unregister(struct backlight_device *)'
  'struct clk * clk_register_composite(struct device *, const char *, const char * const *, int, struct clk_hw *, const struct clk_ops *, struct clk_hw *, const struct clk_ops *, struct clk_hw *, const struct clk_ops *, unsigned long int)'
  'struct regulator * regulator_get_exclusive(struct device *, const char *)'
  'void si_meminfo(struct sysinfo *)'

5 variable symbol(s) added
  'struct tracepoint __tracepoint_dwc3_ep_queue'
  'struct tracepoint __tracepoint_hrtimer_expire_entry'
  'struct tracepoint __tracepoint_hrtimer_expire_exit'
  'struct tracepoint __tracepoint_workqueue_execute_end'
  'struct tracepoint __tracepoint_workqueue_execute_start'

Bug: 254608320

Change-Id: I201e01cd83435b74bcafced862c508dcaba634c5
Signed-off-by: Khalid Shaik <khalid.s@samsung.com>
2022-11-10 10:04:30 +00:00
Sai Prakash Ranjan
501eeee6e2 UPSTREAM: irqchip/tegra: Fix overflow implicit truncation warnings
[ Upstream commit 443685992b ]

Fix -Woverflow warnings for tegra irqchip driver which is a result
of moving arm64 custom MMIO accessor macros to asm-generic function
implementations giving a bonus type-checking now and uncovering these
overflow warnings.

drivers/irqchip/irq-tegra.c: In function ‘tegra_ictlr_suspend’:
drivers/irqchip/irq-tegra.c:151:18: warning: large integer implicitly truncated to unsigned type [-Woverflow]
   writel_relaxed(~0ul, ictlr + ICTLR_COP_IER_CLR);
                  ^

Suggested-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Sai Prakash Ranjan <quic_saipraka@quicinc.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Fixes: de3ce08049 ("irqchip: tegra: Add DT-based support for legacy interrupt controller")
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Iaee226d0220c9774635cd51953d577ab7e2ebe77
Signed-off-by: Lee Jones <joneslee@google.com>
2022-11-10 10:00:14 +00:00
Sai Prakash Ranjan
13a5e047bd UPSTREAM: drm/meson: Fix overflow implicit truncation warnings
[ Upstream commit 98692f52c5 ]

Fix -Woverflow warnings for drm/meson driver which is a result
of moving arm64 custom MMIO accessor macros to asm-generic function
implementations giving a bonus type-checking now and uncovering these
overflow warnings.

drivers/gpu/drm/meson/meson_viu.c: In function ‘meson_viu_init’:
drivers/gpu/drm/meson/meson_registers.h:1826:48: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
 #define  VIU_OSD_BLEND_REORDER(dest, src)      ((src) << (dest * 4))
                                                ^
drivers/gpu/drm/meson/meson_viu.c:472:18: note: in expansion of macro ‘VIU_OSD_BLEND_REORDER’
   writel_relaxed(VIU_OSD_BLEND_REORDER(0, 1) |
                  ^~~~~~~~~~~~~~~~~~~~~

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Sai Prakash Ranjan <quic_saipraka@quicinc.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Fixes: 147ae1cbaa ("drm: meson: viu: use proper macros instead of magic constants")
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Id3502967ec9df74ea9420a34549bc0ac3c49dfa8
2022-11-10 09:55:51 +00:00
Hyunwoo Kim
55a2910224 UPSTREAM: video: fbdev: pxa3xx-gcu: Fix integer overflow in pxa3xx_gcu_write
[ Upstream commit a09d2d00af ]

In pxa3xx_gcu_write, a count parameter of type size_t is passed to words of
type int.  Then, copy_from_user() may cause a heap overflow because it is used
as the third argument of copy_from_user().

Bug: 245928838
Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I9e21917a52e2cb78cc640a77a6eba21838aa8655
2022-11-10 09:53:36 +00:00
Marc Zyngier
52e7aa3245 FROMLIST: KVM: arm64: pkvm: Fixup boot mode to reflect that the kernel resumes from EL1
The kernel has an awfully complicated boot sequence in order to cope
with the various EL2 configurations, including those that "enhanced"
the architecture. We go from EL2 to EL1, then back to EL2, staying
at EL2 if VHE capable and otherwise go back to EL1.

Here's a paracetamol tablet for you.

The cpu_resume path follows the same logic, because coming up with
two versions of a square wheel is hard.

However, things aren't this straightforward with pKVM, as the host
resume path is always proxied by the hypervisor, which means that
the kernel is always entered at EL1. Which contradicts what the
__boot_cpu_mode[] array contains (it obviously says EL2).

This thus triggers a HVC call from EL1 to EL2 in a vain attempt
to upgrade from EL1 to EL2 VHE, which we are, funnily enough,
reluctant to grant to the host kernel. This is also completely
unexpected, and puzzles your average EL2 hacker.

Address it by fixing up the boot mode at the point the host gets
deprivileged. is_hyp_mode_available() and co already have a static
branch to deal with this, making it pretty safe.

Cc: <stable@vger.kernel.org> # 5.15+
Reported-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vincent Donnefort <vdonnefort@google.com>
Bug: 258157858
Link: https://lore.kernel.org/all/20221108100138.3887862-1-vdonnefort@google.com/
Change-Id: I4a2269402ececa0ec47cab88343c3c623b4b2e3d
2022-11-09 15:27:20 +00:00
Khalid Shaik
bcb19fa296 ANDROID: GKI: Add symbol list for exynos
- Add Initial ABI Symbol list for Exynos SOC

20 function symbol(s) added
  'int __iio_device_register(struct iio_dev *, struct module *)'
  'int cpufreq_unregister_notifier(struct notifier_block *, unsigned int)'
  'int is_console_locked()'
  'struct __kernel_old_timeval ns_to_kernel_old_timeval(const s64)'
  'void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t)'
  'int sysfs_create_bin_file(struct kobject *, const struct bin_attribute *)'
  'int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *)'
  'int v4l2_device_register_subdev(struct v4l2_device *, struct v4l2_subdev *)'
  'int v4l2_device_set_name(struct v4l2_device *, const char *, atomic_t *)'
  'void v4l2_device_unregister_subdev(struct v4l2_subdev *)'
  'void v4l2_i2c_subdev_init(struct v4l2_subdev *, struct i2c_client *, const struct v4l2_subdev_ops *)'
  'int v4l2_m2m_dqbuf(struct file *, struct v4l2_m2m_ctx *, struct v4l2_buffer *)'
  'int v4l2_m2m_mmap(struct file *, struct v4l2_m2m_ctx *, struct vm_area_struct *)'
  '__poll_t v4l2_m2m_poll(struct file *, struct v4l2_m2m_ctx *, struct poll_table_struct *)'
  'int v4l2_m2m_reqbufs(struct file *, struct v4l2_m2m_ctx *, struct v4l2_requestbuffers *)'
  'int v4l2_m2m_streamoff(struct file *, struct v4l2_m2m_ctx *, enum v4l2_buf_type)'
  'int v4l2_m2m_streamon(struct file *, struct v4l2_m2m_ctx *, enum v4l2_buf_type)'
  'void v4l2_subdev_init(struct v4l2_subdev *, const struct v4l2_subdev_ops *)'
  'void v4l_bound_align_image(u32 *, unsigned int, unsigned int, unsigned int, u32 *, unsigned int, unsigned int, unsigned int, unsigned int)'
  'unsigned long int vmalloc_to_pfn(void *)'

1 variable symbol(s) added
  'const struct v4l2_subdev_ops v4l2_subdev_call_wrappers'

Bug: 254608320
Signed-off-by: Khalid Shaik <khalid.s@samsung.com>
Change-Id: I664d1eac2ba9b86fe29f978b8eb915c1386c9ba4
2022-11-09 10:44:02 +00:00
Peter Zijlstra
9e3ae1fbd3 UPSTREAM: sched: Fix yet more sched_fork() races
Where commit 4ef0c5c6b5 ("kernel/sched: Fix sched_fork() access an
invalid sched_task_group") fixed a fork race vs cgroup, it opened up a
race vs syscalls by not placing the task on the runqueue before it
gets exposed through the pidhash.

Commit 13765de814 ("sched/fair: Fix fault in reweight_entity") is
trying to fix a single instance of this, instead fix the whole class
of issues, effectively reverting this commit.

Bug: 255159688
Fixes: 4ef0c5c6b5 ("kernel/sched: Fix sched_fork() access an invalid sched_task_group")
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Tested-by: Zhang Qiao <zhangqiao22@huawei.com>
Tested-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Link: https://lkml.kernel.org/r/YgoeCbwj5mbCR0qA@hirez.programming.kicks-ass.net
(cherry picked from commit b1e8206582)
Signed-off-by: Woody Lin <woodylin@google.com>
Change-Id: Ic593aafb0cc8dae5ba382cdc4ab68526973fdfca
2022-11-09 10:22:02 +00:00
Ryan Roberts
3de7d142cf BACKPORT: KVM: arm64: Fix bad dereference on MTE-enabled systems
enter_exception64() performs an MTE check, which involves dereferencing
vcpu->kvm. While vcpu has already been fixed up to be a HYP VA pointer,
kvm is still a pointer in the kernel VA space.

This only affects nVHE configurations with MTE enabled, as in other
cases, the pointer is either valid (VHE) or not dereferenced (!MTE).

Fix this by first converting kvm to a HYP VA pointer.

Fixes: ea7fc1bb1c ("KVM: arm64: Introduce MTE VM feature")
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Reviewed-by: Steven Price <steven.price@arm.com>
[maz: commit message tidy-up]
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20221027120945.29679-1-ryan.roberts@arm.com
(cherry picked from commit b6bcdc9f6b)
[willdeacon@: Fixed conflict with aosp/2038249 rework moving MTE feature
 check into caller]
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 233587962
Bug: 233588291
Change-Id: Id0aac0fc38dff2569081910af7468ecf97b6eca3
2022-11-08 13:42:11 +00:00
Carlos Llamas
b684150a44 FROMLIST: binder: fix UAF of alloc->vma in race with munmap()
In commit 720c241924 ("ANDROID: binder: change down_write to
down_read") binder assumed the mmap read lock is sufficient to protect
alloc->vma inside binder_update_page_range(). This used to be accurate
until commit dd2283f260 ("mm: mmap: zap pages with read mmap_sem in
munmap"), which now downgrades the mmap_lock after detaching the vma
from the rbtree in munmap(). Then it proceeds to teardown and free the
vma with only the read lock held.

This means that accesses to alloc->vma in binder_update_page_range() now
will race with vm_area_free() in munmap() and can cause a UAF as shown
in the following KASAN trace:

  ==================================================================
  BUG: KASAN: use-after-free in vm_insert_page+0x7c/0x1f0
  Read of size 8 at addr ffff16204ad00600 by task server/558

  CPU: 3 PID: 558 Comm: server Not tainted 5.10.150-00001-gdc8dcf942daa #1
  Hardware name: linux,dummy-virt (DT)
  Call trace:
   dump_backtrace+0x0/0x2a0
   show_stack+0x18/0x2c
   dump_stack+0xf8/0x164
   print_address_description.constprop.0+0x9c/0x538
   kasan_report+0x120/0x200
   __asan_load8+0xa0/0xc4
   vm_insert_page+0x7c/0x1f0
   binder_update_page_range+0x278/0x50c
   binder_alloc_new_buf+0x3f0/0xba0
   binder_transaction+0x64c/0x3040
   binder_thread_write+0x924/0x2020
   binder_ioctl+0x1610/0x2e5c
   __arm64_sys_ioctl+0xd4/0x120
   el0_svc_common.constprop.0+0xac/0x270
   do_el0_svc+0x38/0xa0
   el0_svc+0x1c/0x2c
   el0_sync_handler+0xe8/0x114
   el0_sync+0x180/0x1c0

  Allocated by task 559:
   kasan_save_stack+0x38/0x6c
   __kasan_kmalloc.constprop.0+0xe4/0xf0
   kasan_slab_alloc+0x18/0x2c
   kmem_cache_alloc+0x1b0/0x2d0
   vm_area_alloc+0x28/0x94
   mmap_region+0x378/0x920
   do_mmap+0x3f0/0x600
   vm_mmap_pgoff+0x150/0x17c
   ksys_mmap_pgoff+0x284/0x2dc
   __arm64_sys_mmap+0x84/0xa4
   el0_svc_common.constprop.0+0xac/0x270
   do_el0_svc+0x38/0xa0
   el0_svc+0x1c/0x2c
   el0_sync_handler+0xe8/0x114
   el0_sync+0x180/0x1c0

  Freed by task 560:
   kasan_save_stack+0x38/0x6c
   kasan_set_track+0x28/0x40
   kasan_set_free_info+0x24/0x4c
   __kasan_slab_free+0x100/0x164
   kasan_slab_free+0x14/0x20
   kmem_cache_free+0xc4/0x34c
   vm_area_free+0x1c/0x2c
   remove_vma+0x7c/0x94
   __do_munmap+0x358/0x710
   __vm_munmap+0xbc/0x130
   __arm64_sys_munmap+0x4c/0x64
   el0_svc_common.constprop.0+0xac/0x270
   do_el0_svc+0x38/0xa0
   el0_svc+0x1c/0x2c
   el0_sync_handler+0xe8/0x114
   el0_sync+0x180/0x1c0

  [...]
  ==================================================================

To prevent the race above, revert back to taking the mmap write lock
inside binder_update_page_range(). One might expect an increase of mmap
lock contention. However, binder already serializes these calls via top
level alloc->mutex. Also, there was no performance impact shown when
running the binder benchmark tests.

Note this patch is specific to stable branches 5.4 and 5.10. Since in
newer kernel releases binder no longer caches a pointer to the vma.
Instead, it has been refactored to use vma_lookup() which avoids the
issue described here. This switch was introduced in commit a43cfc87ca
("android: binder: stop saving a pointer to the VMA").

Bug: 254837884
Link: https://lore.kernel.org/all/20221104175450.306810-1-cmllamas@google.com/
Fixes: dd2283f260 ("mm: mmap: zap pages with read mmap_sem in munmap")
Reported-by: Jann Horn <jannh@google.com>
Cc: <stable@vger.kernel.org> # 5.10.x
Cc: Minchan Kim <minchan@kernel.org>
Cc: Yang Shi <yang.shi@linux.alibaba.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Change-Id: Ieabadbfa30f99812da9c226cf1ddd5e60f62c607
2022-11-04 18:09:22 +00:00
Minchan Kim
9ffd177dce ANDROID: Update the ABI representation
1 function symbol(s) added
  'int __traceiter_android_vh_shrink_lruvec_blk_plug(void *, bool *)'

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

Bug: 255471591
Bug: 238728493
Change-Id: I8746bbe2f7ccc09e366deed6aa00bc4834643084
Signed-off-by: Minchan Kim <minchan@google.com>
2022-11-03 19:40:25 +00:00
Minchan Kim
89fed37332 ANDROID: vendor hook to control blk_plug for shrink_lruvec
Add vendor hook to contorl blk plugging for shrink_lruvec.

Bug: 255471591
Bug: 238728493
Change-Id: Iba2603ff2e1b62cf2ee8fd6969d8ccd71416a288
Signed-off-by: Minchan Kim <minchan@google.com>
2022-11-03 19:40:25 +00:00
Jann Horn
c0ce22abf7 UPSTREAM: mm: Fix TLB flush for not-first PFNMAP mappings in unmap_region()
This is a stable-specific patch.
I botched the stable-specific rewrite of
commit b67fbebd4c ("mmu_gather: Force tlb-flush VM_PFNMAP vmas"):
As Hugh pointed out, unmap_region() actually operates on a list of VMAs,
and the variable "vma" merely points to the first VMA in that list.
So if we want to check whether any of the VMAs we're operating on is
PFNMAP or MIXEDMAP, we have to iterate through the list and check each VMA.

Bug: 245812080
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 3998dc50eb)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I115183f65fc7df5d33264e6211adcd2ec531d996
2022-11-03 16:42:11 +00:00