Commit Graph

1066276 Commits

Author SHA1 Message Date
Daniel Mentz
e2cdae06e2 ANDROID: sched: Export sched_domains_mutex for lockdep
If CONFIG_LOCKDEP is enabled, export `sched_domains_mutex` as it is
indirectly accessed by the macro `for_each_domain()`. This allows
vendors to call the `for_each_domain()` macro with CONFIG_LOCKDEP
enabled via the GKI_BUILD_CONFIG_FRAGMENT.

Bug: 176254015
Signed-off-by: Daniel Mentz <danielmentz@google.com>
Change-Id: Ia9f2989de41b2224c63855f2fd129cbeeac4f195
Signed-off-by: Will McVicker <willmcvicker@google.com>
(cherry picked from commit 7171a5de98)
2023-03-16 17:56:59 +00:00
Cai Huoqing
6d8d934a20 UPSTREAM: kthread: add the helper function kthread_run_on_cpu()
Add a new helper function kthread_run_on_cpu(), which includes
kthread_create_on_cpu/wake_up_process().

In some cases, use kthread_run_on_cpu() directly instead of
kthread_create_on_node/kthread_bind/wake_up_process() or
kthread_create_on_cpu/wake_up_process() or
kthreadd_create/kthread_bind/wake_up_process() to simplify the code.

[akpm@linux-foundation.org: export kthread_create_on_cpu to modules]

Bug: 266595872
Link: https://lkml.kernel.org/r/20211022025711.3673-2-caihuoqing@baidu.com
Change-Id: Id15b1200f0cbf7b3af0388e7be7cdc88e7e4290c
Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Cc: Bernard Metzler <bmt@zurich.ibm.com>
Cc: Cai Huoqing <caihuoqing@baidu.com>
Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Doug Ledford <dledford@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: "Paul E . McKenney" <paulmck@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 800977f6f3)
Signed-off-by: Arve Hjønnevåg <arve@android.com>
(cherry picked from commit 748d0fb5d1198582c8dba791b29e469ec4cd209c)
2023-03-16 15:56:34 +00:00
Vincent Donnefort
b8b10f87c2 ANDROID: KVM: arm64: Page-align hyp events section
The following change: 16d9a0f908 ("ANDROID: KVM: arm64: Rename nVHE
hyp event ELF sections") Interverted the hyp events with the hypervisor
read-only sections. This had the side-effect of breaking the alignment
for idmap_pg_dir.

Bug: 273752182
Change-Id: I50a2220aa93b10d97e20d794b0283aa9e18839c1
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-15 20:17:25 +00:00
Ray Chi
bda4c2029f ANDROID: Update the ABI symbol list
Adding the following symbols:
  - usb_udc_vbus_handler

Bug: 267846601
Change-Id: I5282adb6350ae91758f6ec3f8462aba57f37ce79
Signed-off-by: Ray Chi <raychi@google.com>
2023-03-15 17:42:35 +00:00
Bart Van Assche
94bfdd3c5f FROMLIST: loop: Fix use-after-free issues
do_req_filebacked() calls blk_mq_complete_request() synchronously or
asynchronously when using asynchronous I/O unless memory allocation fails.
Hence, modify loop_handle_cmd() such that it does not dereference 'cmd' nor
'rq' after do_req_filebacked() finished unless we are sure that the request
has not yet been completed. This patch fixes the following kernel crash:

Unable to handle kernel NULL pointer dereference at virtual address 0000000000000054
Call trace:
 css_put.42938+0x1c/0x1ac
 loop_process_work+0xc8c/0xfd4
 loop_rootcg_workfn+0x24/0x34
 process_one_work+0x244/0x558
 worker_thread+0x400/0x8fc
 kthread+0x16c/0x1e0
 ret_from_fork+0x10/0x20

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Dan Schatzberg <schatzberg.dan@gmail.com>
Fixes: c74d40e8b5 ("loop: charge i/o to mem and blk cg")
Fixes: bc07c10a36 ("block: loop: support DIO & AIO")
Change-Id: I42284fbd98e9c28bacfe71c5958353a55a296e77
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bug: 267551550
Link: https://lore.kernel.org/linux-block/20230314182155.80625-1-bvanassche@acm.org/T/#u
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-03-15 14:54:15 +00:00
Yifan Hong
e28f3d0936 ANDROID: Disable AF_RXRPC for allmodconfig.
AF_RXRPC imposes a 49 char limit on UTS_RELEASE, but building with

  BUILD_NUMBER=P12345678 bazel build //common:kernel_x86_64_allmodconfig --config=stamp

requires more than 49 chars in UTS_RELEASE. Hence, this module
is disabled for allmodconfig.

Bug: 273576197
Test: ABTD
Change-Id: Ife604db109f870eda2fdbc0668d6bd1f4e4e906e
Signed-off-by: Yifan Hong <elsk@google.com>
2023-03-15 14:09:33 +00:00
Todd Kjos
4060af67be ANDROID: GKI: 3/15/2023 KMI update
Set KMI_GENERATION=2 for 3/15 KMI update

Bug: 273322767
Change-Id: I0ba1b7fa4e150f8f61e13b7c6c37c77c9efb10e3
Signed-off-by: Todd Kjos <tkjos@google.com>
2023-03-15 14:03:19 +00:00
Robin Peng
e816768334 ANDROID: ufs: Enable CONFIG_SCSI_UFS_VARIABLE_SG_ENTRY_SIZE
Since the Exynos UFS host controller driver is supported by the GKI
kernel, CONFIG_SCSI_UFS_VARIABLE_SG_ENTRY_SIZE needs to be enabled.
This CL is necessary because the Pixel 6/7 Exynos UFS host controller
driver is not upstream and because the kernel configuration symbol that
controls whether or not that driver is built is not present in the
upstream kernel either (CONFIG_SCSI_UFS_EXYNOS_GS).

Bug: 271162672
Change-Id: Ib74f2c2638b8de272edfb2b2e4d2d9f006468e51
Signed-off-by: Robin Peng <robinpeng@google.com>
[ bvanassche: modified CL title and rewrote CL description ]
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-03-15 14:03:19 +00:00
Treehugger Robot
1f3bac7f88 Merge "Merge remote-tracking branch 'aosp/upstream-f2fs-stable-linux-5.15.y' into android14-5.15" into android14-5.15 2023-03-15 14:03:19 +00:00
Paul Lawrence
7899985277 ANDROID: incremental fs: Evict inodes before freeing mount data
Since evicting inodes triggers writes to the backing file, which uses
the mi_owner field from the mount_info struct, make sure inodes are
evicted before we free the mount_info data

Test: incfs_test
Bug: 270117845
Change-Id: I673b2e0e04b5adc3998caf6f22443598a30338af
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2023-03-14 19:42:44 +00:00
Paul Lawrence
aa23463501 ANDROID: incremental fs: Fix incfs_test build
Bug: 270117845
Test: run_incfs runs, passes
Change-Id: Ib784b3900f1658401866e238a6baa3f3b02cb9ca
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2023-03-14 19:42:44 +00:00
Vincent Donnefort
1263964707 ANDROID: KVM: arm64: pKVM module loading before deprivilege
kvm-arm.protected_modules="" takes a list of modules that pKVM will load
before de-privileging the host. This is necessary as no loading will be
allowed later.

We can't rely on request_module() that might be disabled by umh's
configuration. Instead, create our own version, locked by the pKVM/KVM
static keys and marked as __init to be cleared once the kernel init is
done. Belt and braces.

Keep the previous kvm-arm.protected_modules for compatibility.

Bug: 254835242
Change-Id: Ia6881b4c7a60cf81d19ead12c5d4638a27eff3eb
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 14:36:44 +00:00
Vincent Donnefort
408fad8bb6 ANDROID: KVM: arm64: Move pKVM host deprivilege to device_initcall
In preparation for early loading of pKVM modules (i.e. before
deprivilege), move the pKVM finalization in device_initcall. This is
needed as modules are found in the initramfs whom unpack starts in the
previous initcall.

A deprivilege failure now ends-up in erasing the PVM firmware and simply
prevent loading of any protected VM.

As an interesting side effect, it also allows us to mark the module
loading functions as __init.  Those functions will then be erased once
the init is complete, reducing the attack surface.

Bug: 254835242
Change-Id: Ifab4b9167b8924222bc8b6c2a0af529a3f8540c0
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 14:36:24 +00:00
Vincent Donnefort
8a87989900 ANDROID: KVM: arm64: Cleanup useless declarations
While introducing ("KVM: arm64: Rework pKVM module locking") some bits
have been missed. Remove them.

Bug: 254835242
Change-Id: Ib2b5c84c6d900cfa452232c9ec62483dd230af0c
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 14:36:11 +00:00
Vincent Donnefort
936fbd4a1d ANDROID: CONFIG_MODPROBE_PATH to toolbox's modprobe
Early loading of pKVM modules (i.e. before deprivilege) implies to let
the kernel call modprobe. Notice this doesn't really enable
request_module: UMH is still "disabled" due to
CONFIG_STATIC_USERMODEHELPER_PATH="".

Bug: 254835242
Change-Id: I753ac4177e5017f7d913804bb8439f676d7c2fd8
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 14:35:56 +00:00
Vincent Donnefort
edcdcb7a4f ANDROID: KVM: arm64: Move hyp events in a hyp/ folder
Align with the host tracing events by adding another layer in the event
path. As no group exists at the moment, move all of them in a common
hyp/ one.

Bug: 249050813
Change-Id: I4c77d1ec676f896bba77f147e0a4b30bc9c92606
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 13:02:13 +00:00
Vincent Donnefort
e66ed68b27 ANDROID: KVM: arm64: Allow single char for hyp tracing interface
Some userspace tools might poke hyp tracing files without a newline
char. Accomodate for them.

Bug: 249050813
Change-Id: I2641080897646dcd299ca491a562b36a7b9b22dc
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 13:02:13 +00:00
Vincent Donnefort
71511e0c2d ANDROID: KVM: arm64: Hyp tracing polling to 100ms
The nVHE hypervisor having no way of telling the host events occured,
the host needs to poll. A second long period has been proven to be a bit
too light compared to storm of events that can occur during this window.
Make it 10x shorter.

Bug: 249050813
Change-Id: I4ff243aff615f0a7d40193485b3da8970feeb5d2
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 13:02:13 +00:00
Vincent Donnefort
fae4306674 ANDROID: KVM: arm64: Fix nVHE enter/exit events
Some entry and exit points were not covered. This hopefully won't miss
anything: each SMC call is exiting EL2 and when a CPU is being turned on,
it goes directly through kvm_host_psci_cpu_entry().

Bug: 249050813
Change-Id: Ie88d36df249cb6f0f8e8a49df20654b0628d43d5
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 13:02:13 +00:00
Vincent Donnefort
4651708c27 ANDROID: KVM: arm64: Handle pipe buffer overflow for hyp tracing
Hyp events can overflow the userspace buffer used for hyp trace_pipe.
Make sure no events is lost when this happens.

Bug: 249050813
Change-Id: I8b4032d89b327a2dc83f410d6c20ee59fdd30320
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 13:02:13 +00:00
Vincent Donnefort
64f573257e ANDROID: KVM: arm64: Flush hyp trace pipe when tracing stops
The hyp having no way of telling the host events occured, hyp tracing
has to poll the hyp on a regular basis (RB_POLL_MS). The userspace has
currently no way of forcing a poll, so add one when tracing is disabled.

It improves support for tools such as trace-cmd which disable tracing
before killing their recording threads.

Aside, this removes most of the users of ht_iterator->trace_buffer. So
clean this thing out in the meantime.

Bug: 249050813
Change-Id: I4c5333eff21fc30fdcb4d8d96826beee8b78d56d
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 13:02:13 +00:00
Vincent Donnefort
c8d86d177a ANDROID: ring-buffer: Fix ring_buffer_read_page for external writers
No shortcut is possible for reading a page without removing it from
the ring-buffer. The reader needs to be moved and its timestamp
updated.

Bug: 249050813
Change-Id: I80fbc1e265500e419278346e2973df2488b7e8b3
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 13:02:13 +00:00
Nikita Ioffe
e80aeaf594 ANDROID: KVM: arm64: Add trace_clock for nVHE tracing
Added userspace file that describes what clock is used for hyp tracing.
Unlike tracefs root instance, the hyp tracing only supports boot clock,
hence the trace_clock file is read-only.

Bug: 249050813
Change-Id: Ib9cc1f582699245ed94cf745dae0888eb7556ced
Signed-off-by: Nikita Ioffe <ioffe@google.com>
2023-03-14 13:02:13 +00:00
Vincent Donnefort
73bf84c36b ANDROID: KVM: arm64: Add common "trace_pipe" file for hyp tracing
Like the common "trace" file introduced previously, that new common
file aggregates a pipe version for all CPUs, similarly to the tracefs
root file of the same name.

Bug: 249050813
Change-Id: I1872bf3cfeef637902fcdfa5f589a903c0121d04
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 13:02:13 +00:00
Vincent Donnefort
2cec790c70 ANDROID: KVM: arm64: Allow to reset hyp trace buffers
Writing anything to the "trace" file will delete the content of the
buffer. When using the common "trace", the ring buffer will also be
unloaded from the hypervisor and all the memory will be freed.

At the same time, tracing_on will not reset the buffers anymore and
trace pipe interfaces will be able to setup the ring buffers, bringing
the hyp tracing interface a bit closer from the host behavior.

Bug: 249050813
Change-Id: I9d4ba7b18504440f3d03dbedf1186d384a53a990
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 13:02:13 +00:00
Vincent Donnefort
c0ea2e9801 ANDROID: KVM: arm64: Add common "trace" file for hyp tracing
Extend the hyp tracing interface with a new hyp/trace file that merges
all per-CPU traces. This is similar to "trace" file found in the tracefs
root.

At the same time, align the output of the files with the host:

  [<CPU>] <timestamp>: <event>

Bug: 249050813
Change-Id: I816f8504b14480b13d40f8689f9b9f63706a4daf
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 13:02:13 +00:00
Vincent Donnefort
aa678caf2f ANDROID: KVM: arm64: Add __pkvm_enable_tracing
This newly introduced hypercall allows the host to disable tracing on
all CPUs, while keeping the tracing buffers loaded into the hypervisor.
This intends to later improve the userspace interface which will be able
to turn on and off tracing and reset (teardown for the hyp) the tracing
buffers.

As disabling buffers will switch the buffer status, rename those status
to nonwritable - writable - writing. Another way of identifying buffers
which have not been loaded is needed. See rb_cpu_loaded().

Bug: 249050813
Change-Id: I6080aafe71d5628e94b37c432bcd8616e68ddfe8
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 13:02:13 +00:00
Vincent Donnefort
a7e5601e77 ANDROID: KVM: arm64: Empty buffer support for hyp tracing trace file
Previously, hyp/per_cpu/cpu*/trace files would return an error when no
buffer has been allocated (i.e. when no tracing has ever started).
Return an empty header instead.

Bug: 249050813
Change-Id: Ic88bbdf8c876b8f26101ce2b33d3aca26fb88c94
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 13:02:13 +00:00
Will Deacon
16d9a0f908 ANDROID: KVM: arm64: Rename nVHE hyp event ELF sections
The ELF sections and delimiters used by the hyp events were not
following the convention used by other hyp sections. Align them all.

Bug: 249050813
Change-Id: I7b3ee4915c8904cd531911df59c1fd1853bbbe9f
Signed-off-by: Will Deacon <willdeacon@google.com>
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
2023-03-14 13:02:13 +00:00
Jun Nie
a0371ac66a UPSTREAM: ext4: refuse to create ea block when umounted
commit f31173c199 upstream.

The ea block expansion need to access s_root while it is
already set as NULL when umount is triggered. Refuse this
request to avoid panic.

Reported-by: syzbot+2dacb8f015bf1420155f@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?id=3613786cb88c93aa1c6a279b1df6a7b201347d08
Link: https://lore.kernel.org/r/20230103014517.495275-3-jun.nie@linaro.org
Cc: stable@kernel.org
Signed-off-by: Jun Nie <jun.nie@linaro.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 262267471
Change-Id: I0a5c974e696cf7a132f3cbb8acbe066edba4660f
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
2023-03-14 06:20:32 +00:00
Jun Nie
e82469017b UPSTREAM: ext4: optimize ea_inode block expansion
commit 1e9d62d252 upstream.

Copy ea data from inode entry when expanding ea block if possible.
Then remove the ea entry if expansion success. Thus memcpy to a
temporary buffer may be avoided.

If the expansion fails, we do not need to recovery the removed ea
entry neither in this way.

Reported-by: syzbot+2dacb8f015bf1420155f@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?id=3613786cb88c93aa1c6a279b1df6a7b201347d08
Link: https://lore.kernel.org/r/20230103014517.495275-2-jun.nie@linaro.org
Cc: stable@kernel.org
Signed-off-by: Jun Nie <jun.nie@linaro.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 262267471
Change-Id: I26e7d45ab21bcf9e38eeb66601067f42b01c11f5
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
2023-03-14 06:20:18 +00:00
Jaegeuk Kim
3f73abd926 Merge remote-tracking branch 'aosp/upstream-f2fs-stable-linux-5.15.y' into android14-5.15
* aosp/upstream-f2fs-stable-linux-5.15.y:
  fscrypt: fix ext4 breakage in fscrypt
  fsverity.rst: update git repo URL for fsverity-utils
  ext4: allow verity with fs block size < PAGE_SIZE
  fs/buffer.c: support fsverity in block_read_full_folio()
  f2fs: simplify f2fs_readpage_limit()
  ext4: simplify ext4_readpage_limit()
  fsverity: support enabling with tree block size < PAGE_SIZE
  fsverity: support verification with tree block size < PAGE_SIZE
  fsverity: replace fsverity_hash_page() with fsverity_hash_block()
  fsverity: use EFBIG for file too large to enable verity
  fsverity: store log2(digest_size) precomputed
  fsverity: simplify Merkle tree readahead size calculation
  fsverity: use unsigned long for level_start
  fsverity: remove debug messages and CONFIG_FS_VERITY_DEBUG
  fsverity: pass pos and size to ->write_merkle_tree_block
  fsverity: optimize fsverity_cleanup_inode() on non-verity files
  fsverity: optimize fsverity_prepare_setattr() on non-verity files
  fsverity: optimize fsverity_file_open() on non-verity files
  fscrypt: clean up fscrypt_add_test_dummy_key()
  fs/super.c: stop calling fscrypt_destroy_keyring() from __put_super()
  f2fs: stop calling fscrypt_add_test_dummy_key()
  fscrypt: add the test dummy encryption key on-demand
  f2fs: drop unnecessary arg for f2fs_ioc_*()
  f2fs: Revert "f2fs: truncate blocks in batch in __complete_revoke_list()"
  f2fs: synchronize atomic write aborts
  f2fs: fix wrong segment count
  f2fs: replace si->sbi w/ sbi in stat_show()
  f2fs: export ipu policy in debugfs
  f2fs: fix to do sanity check on extent cache correctly
  f2fs: add missing description for ipu_policy node
  f2fs: fix to set ipu policy
  f2fs: fix typos in comments
  f2fs: fix kernel crash due to null io->bio
  f2fs: use iostat_lat_type directly as a parameter in the iostat_update_and_unbind_ctx()
  f2fs: add sysfs nodes to set last_age_weight
  f2fs: fix f2fs_show_options to show nogc_merge mount option
  f2fs: fix cgroup writeback accounting with fs-layer encryption
  f2fs: fix wrong calculation of block age
  f2fs: fix to update age extent in f2fs_do_zero_range()
  f2fs: fix to update age extent correctly during truncation
  f2fs: fix to avoid potential memory corruption in __update_iostat_latency()
  f2fs: retry to update the inode page given data corruption
  f2fs: fix to handle F2FS_IOC_START_ATOMIC_REPLACE in f2fs_compat_ioctl()
  f2fs: clean up i_compress_flag and i_compress_level usage
  f2fs: reduce stack memory cost by using bitfield in struct f2fs_io_info
  f2fs: factor the read/write tracing logic into a helper
  f2fs: remove __has_curseg_space
  f2fs: refactor next blk selection
  f2fs: remove __allocate_new_section
  f2fs: refactor __allocate_new_segment
  f2fs: add a f2fs_curseg_valid_blocks helper
  f2fs: simplify do_checkpoint
  f2fs: remove __add_sum_entry
  f2fs: fix to abort atomic write only during do_exist()
  f2fs: allow set compression option of files without blocks
  f2fs: fix information leak in f2fs_move_inline_dirents()
  fs: f2fs: initialize fsdata in pagecache_write()
  f2fs: fix to check warm_data_age_threshold
  f2fs: return true if all cmd were issued or no cmd need to be issued for f2fs_issue_discard_timeout()
  f2fs: clarify compress level bit offset
  f2fs: fix to show discard_unit mount opt
  f2fs: fix to do sanity check on extent cache correctly
  f2fs: remove unneeded f2fs_cp_error() in f2fs_create_whiteout()
  f2fs: clear atomic_write_task in f2fs_abort_atomic_write()
  f2fs: introduce trace_f2fs_replace_atomic_write_block
  f2fs: introduce discard_io_aware_gran sysfs node
  f2fs: drop useless initializer and unneeded local variable
  f2fs: add iostat support for flush
  f2fs: support accounting iostat count and avg_bytes
  f2fs: convert discard_wake and gc_wake to bool type
  f2fs: convert to use MIN_DISCARD_GRANULARITY macro
  f2fs: merge f2fs_show_injection_info() into time_to_inject()
  f2fs: add a f2fs_ prefix to punch_hole() and expand_inode_data()
  f2fs: remove unnecessary blank lines
  f2fs: mark f2fs_init_compress_mempool w/ __init
  f2fs: judge whether discard_unit is section only when have CONFIG_BLK_DEV_ZONED
  f2fs: start freeing cluster pages from the unused number
  MAINTAINERS: Add f2fs's patchwork
  f2fs: deliver the accumulated 'issued' to __issue_discard_cmd_orderly()
  f2fs: avoid to check PG_error flag
  f2fs: add missing doc for fault injection sysfs
  f2fs: fix to avoid potential deadlock
  f2fs: introduce IS_F2FS_IPU_* macro
  f2fs: refactor the hole reporting and allocation logic in f2fs_map_blocks
  f2fs: factor out a f2fs_map_no_dnode
  f2fs: factor a f2fs_map_blocks_cached helper
  f2fs: remove the create argument to f2fs_map_blocks
  f2fs: remove f2fs_get_block
  docs: f2fs: fix html doc error
  f2fs: simplify __allocate_data_block
  f2fs: reflow prepare_write_begin
  f2fs: f2fs_do_map_lock
  f2fs: add a f2fs_get_block_locked helper
  f2fs: add a f2fs_lookup_extent_cache_block helper
  f2fs: split __submit_bio
  f2fs: rename F2FS_MAP_UNWRITTEN to F2FS_MAP_DELALLOC
  f2fs: decouple F2FS_MAP_ from buffer head flags
  f2fs: don't rely on F2FS_MAP_* in f2fs_iomap_begin
  f2fs: remove unused PAGE_PRIVATE_ATOMIC_WRITE
  f2fs: file: drop useless initializer in expand_inode_data()

Bug: 264705711
Bug: 269384820
Bug: 269593531
Change-Id: I5091f2a3513116961d2869a6fc32a15d2ef01273
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2023-03-13 15:44:12 -07:00
davidchiang
d02b0b627e ANDROID: Update the ABI symbol list and xml
Add symbols for Pixel kernel.

6 function symbol(s) added
  'unsigned long alloc_iova_fast(struct iova_domain*, unsigned long, unsigned long, bool)'
  'void free_iova_fast(struct iova_domain*, unsigned long, unsigned long)'
  'unsigned long gen_pool_best_fit(unsigned long*, unsigned long, unsigned long, unsigned int, void*, struct gen_pool*, unsigned long)'
  'void gen_pool_set_algo(struct gen_pool*, genpool_algo_t, void*)'
  'void init_iova_domain(struct iova_domain*, unsigned long, unsigned long)'
  'void put_iova_domain(struct iova_domain*)'

Bug: 273201558
Change-Id: I5157906d12ddd56ba5be74c3185e5a2f52928987
Signed-off-by: David Chiang <davidchiang@google.com>
2023-03-13 16:58:12 +00:00
John Stultz
29a6ff2f7a FROMGIT: pstore: Revert pmsg_lock back to a normal mutex
This reverts commit 76d62f24db.

So while priority inversion on the pmsg_lock is an occasional
problem that an rt_mutex would help with, in uses where logging
is writing to pmsg heavily from multiple threads, the pmsg_lock
can be heavily contended.

After this change landed, it was reported that cases where the
mutex locking overhead was commonly adding on the order of 10s
of usecs delay had suddenly jumped to ~msec delay with rtmutex.

It seems the slight differences in the locks under this level
of contention causes the normal mutexes to utilize the spinning
optimizations, while the rtmutexes end up in the sleeping
slowpath (which allows additional threads to pile on trying
to take the lock).

In this case, it devolves to a worse case senerio where the lock
acquisition and scheduling overhead dominates, and each thread
is waiting on the order of ~ms to do ~us of work.

Obviously, having tons of threads all contending on a single
lock for logging is non-optimal, so the proper fix is probably
reworking pstore pmsg to have per-cpu buffers so we don't have
contention.

Additionally, Steven Rostedt has provided some furhter
optimizations for rtmutexes that improves the rtmutex spinning
path, but at least in my testing, I still see the test tripping
into the sleeping path on rtmutexes while utilizing the spinning
path with mutexes.

But in the short term, lets revert the change to the rt_mutex
and go back to normal mutexes to avoid a potentially major
performance regression. And we can work on optimizations to both
rtmutexes and finer-grained locking for pstore pmsg in the
future.

Cc: Wei Wang <wvw@google.com>
Cc: Midas Chien<midaschieh@google.com>
Cc: "Chunhui Li (李春辉)" <chunhui.li@mediatek.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Anton Vorontsov <anton@enomsg.org>
Cc: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: kernel-team@android.com
Fixes: 76d62f24db ("pstore: Switch pmsg_lock to an rt_mutex to avoid priority inversion")
Reported-by: "Chunhui Li (李春辉)" <chunhui.li@mediatek.com>
Signed-off-by: John Stultz <jstultz@google.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20230308204043.2061631-1-jstultz@google.com
Bug: 271041816
Bug: 272453930
(cherry picked from commit 5239a89b06
 https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore )
Change-Id: Iadf30bcbf5ba3895dd4af8c15c3a8aecf4301acb
Signed-off-by: John Stultz <jstultz@google.com>
2023-03-10 18:27:29 +00:00
Will McVicker
31d0967a3a ANDROID: Update the ABI symbol list
Adding the following symbols:
  - cleancache_register_ops
  - cma_get_size
  - csum_partial
  - __xa_erase
  - xa_load
  - xas_find
  - xas_pause
  - __xa_store

Bug: 236887352
Change-Id: Id9d93a83fec9a35e219a1702081982bc204ce049
Signed-off-by: Will McVicker <willmcvicker@google.com>
2023-03-09 18:00:48 +00:00
Geert Uytterhoeven
47b4728f6d UPSTREAM: of: reserved_mem: Use proper binary prefix
The printed reserved memory information uses the non-standard "K"
prefix, while all other printed values use proper binary prefixes.
Fix this by using "Ki" instead.

While at it, drop the superfluous spaces inside the parentheses, to
reduce printed line length.

Bug: 254441685
Fixes: aeb9267eb6 ("of: reserved-mem: print out reserved-mem details during boot")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230216083725.1244817-1-geert+renesas@glider.be
Signed-off-by: Rob Herring <robh@kernel.org>
(cherry picked from commit 6ee7afbabc)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ide373aecb11b08df071a9f7633af3ae21a677799
2023-03-08 14:40:24 +00:00
Marc Bornand
3d3214481f UPSTREAM: wifi: cfg80211: Set SSID if it is not already set
When a connection was established without going through
NL80211_CMD_CONNECT, the ssid was never set in the wireless_dev struct.
Now we set it in __cfg80211_connect_result() when it is not already set.

When using a userspace configuration that does not call
cfg80211_connect() (can be checked with breakpoints in the kernel),
this patch should allow `networkctl status device_name` to output the
SSID instead of null.

Bug: 254441685
Cc: stable@vger.kernel.org
Reported-by: Yohan Prod'homme <kernel@zoddo.fr>
Fixes: 7b0a0e3c3a (wifi: cfg80211: do some rework towards MLO link APIs)
Link: https://bugzilla.kernel.org/show_bug.cgi?id=216711
Signed-off-by: Marc Bornand <dev.mbornand@systemb.ch>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
(cherry picked from commit c38c701851)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Idc15d5f35fc93a5f48848b462b19e8b18774fcbc
2023-03-08 14:40:23 +00:00
Yu Zhao
578a3a3d0f UPSTREAM: mm: multi-gen LRU: fix crash during cgroup migration
lru_gen_migrate_mm() assumes lru_gen_add_mm() runs prior to itself.  This
isn't true for the following scenario:

    CPU 1                         CPU 2

  clone()
    cgroup_can_fork()
                                cgroup_procs_write()
    cgroup_post_fork()
                                  task_lock()
                                  lru_gen_migrate_mm()
                                  task_unlock()
    task_lock()
    lru_gen_add_mm()
    task_unlock()

And when the above happens, kernel crashes because of linked list
corruption (mm_struct->lru_gen.list).

Bug: 254441685
Link: https://lore.kernel.org/r/20230115134651.30028-1-msizanoen@qtmlabs.xyz/
Link: https://lkml.kernel.org/r/20230116034405.2960276-1-yuzhao@google.com
Fixes: bd74fdaea1 ("mm: multi-gen LRU: support page table walks")
Signed-off-by: Yu Zhao <yuzhao@google.com>
Reported-by: msizanoen <msizanoen@qtmlabs.xyz>
Tested-by: msizanoen <msizanoen@qtmlabs.xyz>
Cc: <stable@vger.kernel.org>	[6.1+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit de08eaa615)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Id8012efa73b7ba3cc46e7061f762bd4dbd6a4d3e
2023-03-08 14:40:23 +00:00
Robin Murphy
6920d34e7a UPSTREAM: Partially revert "perf/arm-cmn: Optimise DTC counter accesses"
It turns out the optimisation implemented by commit 4f2c3872dd is
totally broken, since all the places that consume hw->dtcs_used for
events other than cycle count are still not expecting it to be sparsely
populated, and fail to read all the relevant DTC counters correctly if
so.

If implemented correctly, the optimisation potentially saves up to 3
register reads per event update, which is reasonably significant for
events targeting a single node, but still not worth a massive amount of
additional code complexity overall. Getting it right within the current
design looks a fair bit more involved than it was ever intended to be,
so let's just make a functional revert which restores the old behaviour
while still backporting easily.

Bug: 254441685
Fixes: 4f2c3872dd ("perf/arm-cmn: Optimise DTC counter accesses")
Reported-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/b41bb4ed7283c3d8400ce5cf5e6ec94915e6750f.1674498637.git.robin.murphy@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit a428eb4b99)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I3bc5b2e6a8fc483a051862ddba084f59142cab3d
2023-03-08 14:40:23 +00:00
Bean Huo
a3269a6879 UPSTREAM: scsi: ufs: core: bsg: Fix cast to restricted __be16 warning
Fix the following sparse endianness warning:

"sparse warnings: drivers/ufs/core/ufs_bsg.c:91:25: sparse: sparse: cast to
restricted __be16."

For consistency with endianness annotations of other UFS data structures,
change __u16/32 to __be16/32 in UFS ARPMB data structures.

Bug: 254441685
Fixes: 6ff265fc5e ("scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit e2cb6e8db6)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I78195aa5c606a766c7414b256c9e23b1a16434bd
2023-03-08 14:40:23 +00:00
Mark Brown
7d3d4eb2c3 UPSTREAM: arm64/signal: Always allocate SVE signal frames on SME only systems
Currently we only allocate space for SVE signal frames on systems that
support SVE, meaning that SME only systems do not allocate a signal frame
for streaming mode SVE state. Change the check so space is allocated if
either feature is supported.

Bug: 254441685
Fixes: 85ed24dad2 ("arm64/sme: Implement streaming SVE signal handling")
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20221223-arm64-fix-sme-only-v1-3-938d663f69e5@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit f26cd73721)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I74e735b2fba9e055acb1d43881eec814f7eba91d
2023-03-08 14:40:23 +00:00
Zenghui Yu
d39a8ec550 UPSTREAM: arm64: ptrace: Use ARM64_SME to guard the SME register enumerations
We currently guard REGSET_{SSVE, ZA} using ARM64_SVE for no good reason.
Both enumerations would be pointless without ARM64_SME and create two empty
entries in aarch64_regsets[] which would then become part of a process's
native regset view (they should be ignored though).

Switch to use ARM64_SME instead.

Bug: 254441685
Fixes: e12310a0d3 ("arm64/sme: Implement ptrace support for streaming mode SVE registers")
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20221214135943.379-1-yuzenghui@huawei.com
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit eb9a85261e)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I1aca02e58dfe67db7eb45efc8e9ad08a8c1f9392
2023-03-08 14:40:23 +00:00
Yuan Can
34c6b75975 UPSTREAM: wifi: nl80211: Add checks for nla_nest_start() in nl80211_send_iface()
As the nla_nest_start() may fail with NULL returned, the return value needs
to be checked.

Bug: 254441685
Fixes: ce08cd344a ("wifi: nl80211: expose link information for interfaces")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Link: https://lore.kernel.org/r/20221129014211.56558-1-yuancan@huawei.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
(cherry picked from commit 5cc58b3766)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I7bec8d810f887c6bcf2073fb0374a2aebf3fd73a
2023-03-08 14:40:23 +00:00
Charan Teja Kalla
826d2d5fb3 UPSTREAM: mm/page_exit: fix kernel doc warning in page_ext_put()
Fix the below compiler warnings reported with 'make W=1 mm/'.
mm/page_ext.c:178: warning: Function parameter or member 'page_ext' not
described in 'page_ext_put'.

Bug: 254441685
[quic_pkondeti@quicinc.com: better patch title]
Link: https://lkml.kernel.org/r/1667884582-2465-1-git-send-email-quic_charante@quicinc.com
Fixes: b1d5488a25 ("mm: fix use-after free of page_ext after race with memory-offline")
Signed-off-by: Charan Teja Kalla <quic_charante@quicinc.com>
Reported-by: Vlastimil Babka <vbabka@suse.cz>
Tested-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Pavan Kondeti <quic_pkondeti@quicinc.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit ed86b74874)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I1bb50ab9b95a01462a3e6622e43cfd969fcaabaf
2023-03-08 12:48:28 +00:00
Sebastian Andrzej Siewior
093fc8a857 BACKPORT: mm: multi-gen LRU: move lru_gen_add_mm() out of IRQ-off region
lru_gen_add_mm() has been added within an IRQ-off region in the commit
mentioned below.  The other invocations of lru_gen_add_mm() are not within
an IRQ-off region.

The invocation within IRQ-off region is problematic on PREEMPT_RT because
the function is using a spin_lock_t which must not be used within
IRQ-disabled regions.

The other invocations of lru_gen_add_mm() occur while
task_struct::alloc_lock is acquired.  Move lru_gen_add_mm() after
interrupts are enabled and before task_unlock().

Bug: 254441685
Link: https://lkml.kernel.org/r/20221026134830.711887-1-bigeasy@linutronix.de
Fixes: bd74fdaea1 ("mm: multi-gen LRU: support page table walks")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Yu Zhao <yuzhao@google.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: "Eric W . Biederman" <ebiederm@xmission.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit dda1c41a07)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: If85c9bf03c4ffa47cd0e79db2f75fdb0ff92ce0a
2023-03-08 10:56:49 +00:00
Johannes Berg
cd1848bb97 UPSTREAM: wifi: fix multi-link element subelement iteration
The subelements obviously start after the common data, including
the common multi-link element structure definition itself. This
bug was possibly just hidden by the higher bits of the control
being set to 0, so the iteration just found one bogus element
and most of the code could continue anyway.

Bug: 254441685
Fixes: 0f48b8b88a ("wifi: ieee80211: add definitions for multi-link element")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
(cherry picked from commit 1177aaa7fe)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I068a4a16eaad463ada5ba976fc065d0ddb058195
2023-03-08 10:55:10 +00:00
Ilkka Koskinen
d886fe15e5 UPSTREAM: perf/arm-cmn: Add more bits to child node address offset field
CMN-600 uses bits [27:0] for child node address offset while bits [30:28]
are required to be zero.

For CMN-650, the child node address offset field has been increased
to include bits [29:0] while leaving only bit 30 set to zero.

Let's include the missing two bits and assume older implementations
comply with the spec and set bits [29:28] to 0.

Bug: 254441685
Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Fixes: 60d1504070 ("perf/arm-cmn: Support new IP features")
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/20220808195455.79277-1-ilkka@os.amperecomputing.com
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit 05d6f6d346)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I8d4048e6bca6498c04b10f31bc188bebdf3f716b
2023-03-08 10:55:00 +00:00
Vincent Whitchurch
375c07024f UPSTREAM: um: Prevent KASAN splats in dump_stack()
Use READ_ONCE_NOCHECK() when reading the stack to prevent KASAN splats
when dump_stack() is used.

Bug: 254441685
Fixes: 5b301409e8 ("UML: add support for KASAN under x86_64")
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
(cherry picked from commit 2975e4a282)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I592c51099761e9eef0b24a40ea427d5d2ab0bacf
2023-03-08 10:54:50 +00:00
Johannes Berg
189eab64d6 UPSTREAM: wifi: mac80211: set STA deflink addresses
We should set the STA deflink addresses in case no
link is really added.

Bug: 254441685
Fixes: 046d2e7c50 ("mac80211: prepare sta handling for MLO support")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
(cherry picked from commit 630c7e4621)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I709a549c3394926c67e003ed4b923dfafd18b4df
2023-03-08 10:52:56 +00:00
Robin Murphy
04256d656a UPSTREAM: perf/arm-cmn: Update watchpoint format
From CMN-650 onwards, some of the fields in the watchpoint config
registers moved subtly enough to easily overlook. Watchpoint events are
still only partially supported on newer IPs - which in itself deserves
noting - but were not intended to become any *less* functional than on
CMN-600.

Bug: 254441685
Fixes: 60d1504070 ("perf/arm-cmn: Support new IP features")
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/e1ce4c2f1e4f73ab1c60c3a85e4037cd62dd6352.1645727871.git.robin.murphy@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit 31fac56577)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I09f3740c63f90e49d84bc2d0ddd6176cd5869db3
2023-03-08 10:52:40 +00:00