Commit Graph

1053309 Commits

Author SHA1 Message Date
Michel Lespinasse
a2138fee6c FROMLIST: fs: list file types that support speculative faults.
Add a speculative field to the vm_operations_struct, which indicates if
the associated file type supports speculative faults.

Initially this is set for files that implement fault() with filemap_fault().

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20210407014502.24091-30-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ic92efdf13283c45e7da7bf703f4f85f8b392ba69
2022-03-23 11:32:19 -07:00
Michel Lespinasse
4979ff3738 FROMLIST: mm: implement speculative handling in filemap_map_pages()
In the speculative case, we know the page table already exists, and it
must be locked with pte_map_lock(). In the case where no page is found
for the given address, return VM_FAULT_RETRY which will abort the
fault before we get into the vm_ops->fault() callback. This is fine
because if filemap_map_pages does not find the page in page cache,
vm_ops->fault() will not either.

Initialize addr and last_pgoff to correspond to the pte at the original
fault address (which was mapped with pte_map_lock()), rather than the
pte at start_pgoff. The choice of initial values doesn't matter as
they will all be adjusted together before use, so they just need to be
consistent with each other, and using the original fault address and
pte allows us to reuse pte_map_lock() without any changes to it.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20210407014502.24091-29-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I0acf4f9626ec0126cdc9a95a7ff1cd735c1af2ca
2022-03-23 11:32:19 -07:00
Michel Lespinasse
7045d2d838 FROMLIST: mm: implement speculative handling in do_fault_around()
Call the vm_ops->map_pages method within an rcu read locked section.
In the speculative case, verify the mmap sequence lock at the start of
the section. A match guarantees that the original vma is still valid
at that time, and that the associated vma->vm_file stays valid while
the vm_ops->map_pages() method is running.

Do not test vmf->pmd in the speculative case - we only speculate when
a page table already exists, and and this saves us from having to handle
synchronization around the vmf->pmd read.

Change xfs_filemap_map_pages() account for the fact that it can not
block anymore, as it is now running within an rcu read lock.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20210407014502.24091-28-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Id771c1e6fa9b883595a48d4df63f448a05916eda
2022-03-23 11:32:19 -07:00
Michel Lespinasse
6877640598 BACKPORT: FROMLIST: mm: implement speculative fault handling in finish_fault()
In the speculative case, we want to avoid direct pmd checks (which
would require some extra synchronization to be safe), and rely on
pte_map_lock which will both lock the page table and verify that the
pmd has not changed from its initial value.

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

Conflicts:
    mm/memory.c

1. Merge conflict due to new vmf->prealloc_pte usage in finish_fault.

Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: If6046592083eaf12caf5c51c3fbb287a4dfa1ace
2022-03-23 11:32:18 -07:00
Michel Lespinasse
cd333a037c 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.

Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I82eba7fcfc81876245c2e65bc5ae3d33ddfcc368
2022-03-23 11:32:18 -07:00
Michel Lespinasse
b12e52ca98 FROMLIST: mm: implement speculative handling in __do_fault()
In the speculative case, call the vm_ops->fault() method from within
an rcu read locked section, and verify the mmap sequence lock at the
start of the section. A match guarantees that the original vma is still
valid at that time, and that the associated vma->vm_file stays valid
while the vm_ops->fault() method is running.

Note that this implies that speculative faults can not sleep within
the vm_ops->fault method. We will only attempt to fetch existing pages
from the page cache during speculative faults; any miss (or prefetch)
will be handled by falling back to non-speculative fault handling.

The speculative handling case also does not preallocate page tables,
as it is always called with a pre-existing page table.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20210407014502.24091-25-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I995ba94d8e96014ef83ac93fe5a4669afcde34b9
2022-03-23 11:32:18 -07:00
Michel Lespinasse
48e35d053f FROMLIST: mm: rcu safe vma->vm_file freeing
Defer freeing of vma->vm_file when freeing vmas.
This is to allow speculative page faults in the mapped file case.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20210407014502.24091-24-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ic766bc2086db82eae9f3aadf0f23dd743be1c464
2022-03-23 11:32:18 -07:00
Michel Lespinasse
fea117c94a FROMLIST: powerpc/mm: attempt speculative mm faults first
Attempt speculative mm fault handling first, and fall back to the
existing (non-speculative) code if that fails.

This follows the lines of the x86 speculative fault handling code,
but with some minor arch differences such as the way that the
access_pkey_error case is handled

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-36-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ic12bc3d5070d1502fc5df182a19c92b4a8d59723
2022-03-23 11:32:18 -07:00
Michel Lespinasse
c3b8c726b8 FROMLIST: powerpc/mm: define ARCH_SUPPORTS_SPECULATIVE_PAGE_FAULT
Set ARCH_SUPPORTS_SPECULATIVE_PAGE_FAULT so that the speculative fault
handling code can be compiled on this architecture.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-35-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia016c531d264c1022af4896b1e33db7b7b4d5013
2022-03-23 11:32:18 -07:00
Michel Lespinasse
ac39e2e1eb FROMLIST: arm64/mm: attempt speculative mm faults first
Attempt speculative mm fault handling first, and fall back to the
existing (non-speculative) code if that fails.

This follows the lines of the x86 speculative fault handling code,
but with some minor arch differences such as the way that the
VM_FAULT_BADACCESS case is handled.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-34-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Iccd87036b15eebf2ff28fbb8022b07c9f91d7353
2022-03-23 11:32:17 -07:00
Michel Lespinasse
f03ec9d1c6 FROMLIST: arm64/mm: define ARCH_SUPPORTS_SPECULATIVE_PAGE_FAULT
Set ARCH_SUPPORTS_SPECULATIVE_PAGE_FAULT so that the speculative fault
handling code can be compiled on this architecture.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-33-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I162b3272a7d2736addf22430ef79c0092baa5842
2022-03-23 11:32:17 -07:00
Michel Lespinasse
9b92402808 FROMLIST: mm: anon spf statistics
Add a new CONFIG_SPECULATIVE_PAGE_FAULT_STATS config option,
and dump extra statistics about executed spf cases and abort reasons
when the option is set.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-32-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia53cd88e4a7140aeb26bf8f3869e1fc5270012da
2022-03-23 11:32:17 -07:00
Michel Lespinasse
956cb3f228 FROMLIST: mm: create new include/linux/vm_event.h header file
Split off the definitions necessary to update event counters from vmstat.h
into a new vm_event.h file.

The rationale is to allow header files included from mm.h to update
counter events. vmstat.h can not be included from such header files,
because it refers to page_pgdat() which is only defined later down
in mm.h, and thus results in compile errors. vm_event.h does not refer
to page_pgdat() and thus does not result in such errors.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-31-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ie70dd435b3dcbad80a4a9bfc294b78a9107c1ac2
2022-03-23 11:32:17 -07:00
Michel Lespinasse
12230588f3 FROMLIST: mm: disable rcu safe vma freeing for single threaded user space
Performance tuning: as single threaded userspace does not use
speculative page faults, it does not require rcu safe vma freeing.
Turn this off to avoid the related (small) extra overheads.

For multi threaded userspace, we often see a performance benefit from
the rcu safe vma freeing - even in tests that do not have any frequent
concurrent page faults ! This is because rcu safe vma freeing prevents
recently released vmas from being immediately reused in a new thread.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-30-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I81ef7ab43e2757f268c567d5bfe6ab02f1e43a1c
2022-03-23 11:32:17 -07:00
Michel Lespinasse
959fc0f0f1 FROMLIST: mm: disable speculative faults for single threaded user space
Performance tuning: single threaded userspace does not benefit from
speculative page faults, so we turn them off to avoid any related
(small) extra overheads.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-29-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I52720f24949d69b3ccaa7dbc1173e47b030fcaaf
2022-03-23 11:32:17 -07:00
Michel Lespinasse
aa9ae5c915 FROMLIST: mm: implement and enable speculative fault handling in handle_pte_fault()
In handle_pte_fault(), allow speculative execution to proceed.

Use pte_spinlock() to validate the mmap sequence count when locking
the page table.

If speculative execution proceeds through do_wp_page(), ensure that we
end up in the wp_page_reuse() or wp_page_copy() paths, rather than
wp_pfn_shared() or wp_page_shared() (both unreachable as we only
handle anon vmas so far) or handle_userfault() (needs an explicit
abort to handle non-speculatively).

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-28-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia45d095ec7b8e23f1c5d68b7a7f572a3f6f6df97
2022-03-23 11:32:17 -07:00
Michel Lespinasse
40bc9ed389 FROMLIST: mm: implement speculative handling in wp_page_copy()
Change wp_page_copy() to handle the speculative case. This involves
aborting speculative faults if they have to allocate an anon_vma,
read-locking the mmu_notifier_lock to avoid races with
mmu_notifier_register(), and using pte_map_lock() instead of
pte_offset_map_lock() to complete the page fault.

Also change call sites to clear vmf->pte after unmapping the page table,
in order to satisfy pte_map_lock()'s preconditions.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-27-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Icd2188e9facf5a7fea42000a2808bcda1ad6f0fc
2022-03-23 11:32:16 -07:00
Michel Lespinasse
81863f7422 FROMLIST: mm: add mmu_notifier_trylock() and mmu_notifier_unlock()
These new functions are to be used when firing MMU notifications
without holding any of the mmap or rmap locks, as is the case with
speculative page fault handlers.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-26-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I3789c44f509d8d7c7cb445e39d891300795cac3c
2022-03-23 11:32:16 -07:00
Michel Lespinasse
3e15787d22 FROMLIST: mm: write lock mmu_notifier_lock when registering mmu notifiers
Change mm_take_all_locks to also take the mmu_notifier_lock.
Note that mm_take_all_locks is called from mmu_notifier_register() only.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-25-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I7ad82c6bc66f8f59a718dc4bf030674d9306a53d
2022-03-23 11:32:16 -07:00
Michel Lespinasse
1ae855f191 FROMLIST: mm: add mmu_notifier_lock
Introduce mmu_notifier_lock as a per-mm percpu_rw_semaphore,
as well as the code to initialize and destroy it together with the mm.

This lock will be used to prevent races between mmu_notifier_register()
and speculative fault handlers that need to fire MMU notifications
without holding any of the mmap or rmap locks.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-24-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I453ebe979c8b9dcc6159b41c5ec7a1ea17d85ee2
2022-03-23 11:32:16 -07:00
Suren Baghdasaryan
3f4fefc1a4 FROMLIST: percpu-rwsem: enable percpu_sem destruction in atomic context
Calling percpu_free_rwsem in atomic context results in "scheduling while
atomic" bug being triggered:

BUG: scheduling while atomic: klogd/158/0x00000002
...
  __schedule_bug+0x191/0x290
  schedule_debug+0x97/0x180
  __schedule+0xdc/0xba0
  schedule+0xda/0x250
  schedule_timeout+0x92/0x2d0
  __wait_for_common+0x25b/0x430
  wait_for_completion+0x1f/0x30
  rcu_barrier+0x440/0x4f0
  rcu_sync_dtor+0xaa/0x190
  percpu_free_rwsem+0x41/0x80

Introduce percpu_rwsem_destroy function to perform semaphore destruction
in a worker thread.

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-23-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ic6df09ff048755cd862d340c89a83dfe8efa1bfb
2022-03-23 11:32:16 -07:00
Michel Lespinasse
009020e3d1 FROMLIST: mm: enable speculative fault handling in do_numa_page()
Change handle_pte_fault() to allow speculative fault execution to proceed
through do_numa_page().

do_swap_page() does not implement speculative execution yet, so it
needs to abort with VM_FAULT_RETRY in that case.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-22-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I0390331facc9ecd37534012abdd9f255ab5bbb12
2022-03-23 11:32:16 -07:00
Michel Lespinasse
fedc4d513e FROMLIST: mm: implement speculative handling in do_numa_page()
change do_numa_page() to use pte_spinlock() when locking the page table,
so that the mmap sequence counter will be validated in the speculative case.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-21-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: If252547faf2a8a6cbba4c0a7ff929071a5f6a657
2022-03-23 11:32:15 -07:00
Michel Lespinasse
c2b2abe724 FROMLIST: mm: enable speculative fault handling through do_anonymous_page()
in x86 fault handler, only attempt spf if the vma is anonymous.

In do_handle_mm_fault(), let speculative page faults proceed as long
as they fall into anonymous vmas. This enables the speculative
handling code in __handle_mm_fault() and do_anonymous_page().

In handle_pte_fault(), if vmf->pte is set (the original pte was not
pte_none), catch speculative faults and return VM_FAULT_RETRY as
those cases are not implemented yet. Also assert that do_fault()
is not reached in the speculative case.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-20-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I875106fcfa1084f570c2bf8f24a129bdce55316b
2022-03-23 11:32:15 -07:00
Michel Lespinasse
31cf1fd564 FROMLIST: mm: implement speculative handling in do_anonymous_page()
Change do_anonymous_page() to handle the speculative case.
This involves aborting speculative faults if they have to allocate a new
anon_vma, and using pte_map_lock() instead of pte_offset_map_lock()
to complete the page fault.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-19-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I5ad955323faabc142c21f62415db039ac889066a
2022-03-23 11:32:15 -07:00
Michel Lespinasse
6e6766ab76 BACKPORT: FROMLIST: mm: add pte_map_lock() and pte_spinlock()
pte_map_lock() and pte_spinlock() are used by fault handlers to ensure
the pte is mapped and locked before they commit the faulted page to the
mm's address space at the end of the fault.

The functions differ in their preconditions; pte_map_lock() expects
the pte to be unmapped prior to the call, while pte_spinlock() expects
it to be already mapped.

In the speculative fault case, the functions verify, after locking the pte,
that the mmap sequence count has not changed since the start of the fault,
and thus that no mmap lock writers have been running concurrently with
the fault. After that point the page table lock serializes any further
races with concurrent mmap lock writers.

If the mmap sequence count check fails, both functions will return false
with the pte being left unmapped and unlocked.

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

Conflicts:
    include/linux/mm.h

1. Fixed pte_map_lock and pte_spinlock macros not to fail when
CONFIG_SPECULATIVE_PAGE_FAULT=n

Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ibd7ccc2ead4fdf29f28c7657b312b2f677ac8836
2022-03-23 11:32:15 -07:00
Michel Lespinasse
6ab660d7cb FROMLIST: mm: implement speculative handling in __handle_mm_fault().
The speculative path calls speculative_page_walk_begin() before walking
the page table tree to prevent page table reclamation. The logic is
otherwise similar to the non-speculative path, but with additional
restrictions: in the speculative path, we do not handle huge pages or
wiring new pages tables.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-17-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: If099534da8b0ac105bbaa5ea4714a6654032592a
2022-03-23 11:32:15 -07:00
Michel Lespinasse
f3f9f17a32 FROMLIST: mm: refactor __handle_mm_fault() / handle_pte_fault()
Move the code that initializes vmf->pte and vmf->orig_pte from
handle_pte_fault() to its single call site in __handle_mm_fault().

This ensures vmf->pte is now initialized together with the higher levels
of the page table hierarchy. This also prepares for speculative page fault
handling, where the entire page table walk (higher levels down to ptes)
needs special care in the speculative case.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-16-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Id550086fe568331aa71c91468f8314faad993b20
2022-03-23 11:32:15 -07:00
Michel Lespinasse
f8a4611b47 FROMLIST: mm: add speculative_page_walk_begin() and speculative_page_walk_end()
Speculative page faults will use these to protect against races with
page table reclamation.

This could always be handled by disabling local IRQs as the fast GUP
code does; however speculative page faults do not need to protect
against races with THP page splitting, so a weaker rcu read lock is
sufficient in the MMU_GATHER_RCU_TABLE_FREE case.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-15-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I3efe5fc6a5a49d537cf33e8093daeea42550077a
2022-03-23 11:32:14 -07:00
Michel Lespinasse
4dea585cfe FROMLIST: x86/mm: attempt speculative mm faults first
Attempt speculative mm fault handling first, and fall back to the
existing (non-speculative) code if that fails.

The speculative handling closely mirrors the non-speculative logic.
This includes some x86 specific bits such as the access_error() call.
This is why we chose to implement the speculative handling in arch/x86
rather than in common code.

The vma is first looked up and copied, under protection of the rcu
read lock. The mmap lock sequence count is used to verify the
integrity of the copied vma, and passed to do_handle_mm_fault() to
allow checking against races with mmap writers when finalizing the fault.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-14-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I2c078a173ee39f35af16daeee8c6a1466d10c3e8
2022-03-23 11:32:14 -07:00
Michel Lespinasse
0823d516af FROMLIST: mm: separate mmap locked assertion from find_vma
This adds a new __find_vma() function, which implements find_vma minus
the mmap_assert_locked() assertion.

find_vma() is then implemented as an inline wrapper around __find_vma().

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-13-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia999b8cb8f5eed93040ab4b3caaf90d739da908d
2022-03-23 11:32:14 -07:00
Michel Lespinasse
67cc8ce9a6 FROMLIST: mm: rcu safe vma freeing
This prepares for speculative page faults looking up and copying vmas
under protection of an rcu read lock, instead of the usual mmap read lock.

Note - it might also be feasible to just use SLAB_TYPESAFE_BY_RCU when
creating the vm_area_cachep, but that's probably too subtle to consider here.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-12-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I992fddb7c32c61bb4ab10b387f91c4e54c2250ef
2022-03-23 11:32:14 -07:00
Michel Lespinasse
29e9bee6fc FROMLIST: mm: add per-mm mmap sequence counter for speculative page fault handling.
The counter's write side is hooked into the existing mmap locking API:
mmap_write_lock() increments the counter to the next (odd) value, and
mmap_write_unlock() increments it again to the next (even) value.

The counter's speculative read side is supposed to be used as follows:

seq = mmap_seq_read_start(mm);
if (seq & 1)
	goto fail;
.... speculative handling here ....
if (!mmap_seq_read_check(mm, seq)
	goto fail;

This API guarantees that, if none of the "fail" tests abort
speculative execution, the speculative code section did not run
concurrently with any mmap writer.

This is very similar to a seqlock, but both the writer and speculative
readers are allowed to block. In the fail case, the speculative reader
does not spin on the sequence counter; instead it should fall back to
a different mechanism such as grabbing the mmap lock read side.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-11-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I60ba909e789371217cd77c39a562a66e156b68bb
2022-03-23 11:32:14 -07:00
Michel Lespinasse
4e2e391ff7 BACKPORT: FROMLIST: mm: add do_handle_mm_fault()
Add a new do_handle_mm_fault function, which extends the existing
handle_mm_fault() API by adding an mmap sequence count, to be used
in the FAULT_FLAG_SPECULATIVE case.

In the initial implementation, FAULT_FLAG_SPECULATIVE always fails
(by returning VM_FAULT_RETRY).

The existing handle_mm_fault() API is kept as a wrapper around
do_handle_mm_fault() so that we do not have to immediately update
every handle_mm_fault() call site.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>

Conflicts:
    mm/memory.c

1. Trivial merge conflict due to folios.

Link: https://lore.kernel.org/all/20220128131006.67712-10-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ic07b6d84af3e5d1fcc856e0968f1a6dd1544fa88
2022-03-23 11:32:14 -07:00
Michel Lespinasse
f2fa9aae2e BACKPORT: FROMLIST: mm: add FAULT_FLAG_SPECULATIVE flag
Define the new FAULT_FLAG_SPECULATIVE flag, which indicates when we are
attempting speculative fault handling (without holding the mmap lock).

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>

Conflicts:
    include/linux/mm_types.h

1. Merge conflict due to enum fault_flag being defined in mm.h instead of
mm_types.h

Link: https://lore.kernel.org/all/20220128131006.67712-9-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I48ab427dfa4d7bdbe9932588bec7ae99e9e80ae9
2022-03-23 11:32:14 -07:00
Michel Lespinasse
f4108b362f FROMLIST: x86/mm: define ARCH_SUPPORTS_SPECULATIVE_PAGE_FAULT
Set ARCH_SUPPORTS_SPECULATIVE_PAGE_FAULT so that the speculative fault
handling code can be compiled on this architecture.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-8-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ica804f098ea7c342a0749511d729470a0e978a2a
2022-03-23 11:32:13 -07:00
Michel Lespinasse
67ad4ad4de FROMLIST: mm: introduce CONFIG_SPECULATIVE_PAGE_FAULT
This configuration variable will be used to build the code needed to
handle speculative page fault.

This is enabled by default on supported architectures with SMP and MMU set.

The architecture support is needed since the speculative page fault handler
is called from the architecture's page faulting code, and some code has to
be added there to try speculative fault handling first.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-7-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ie1dc3af30bf3949173b126e6469f372c4505ec8e
2022-03-23 11:32:13 -07:00
Michel Lespinasse
57f3bb2b12 BACKPORT: FROMLIST: do_anonymous_page: reduce code duplication
In do_anonymous_page(), we have separate cases for the zero page vs
allocating new anonymous pages. However, once the pte entry has been
computed, the rest of the handling (mapping and locking the page table,
checking that we didn't lose a race with another page fault handler, etc)
is identical between the two cases.

This change reduces the code duplication between the two cases.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>

Conflicts:
    mm/memory.c

1. Trivial merge conflict caused by folios in mem_cgroup_charge call.

Link: https://lore.kernel.org/all/20220128131006.67712-6-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ic19579571925878d632e43aa40b9f50cdf473ee6
2022-03-23 11:32:13 -07:00
Michel Lespinasse
82ab55ebcc FROMLIST: do_anonymous_page: use update_mmu_tlb()
update_mmu_tlb() can be used instead of update_mmu_cache() when the
page fault handler detects that it lost the race to another page fault.

It looks like this one call was missed in
https://patchwork.kernel.org/project/linux-mips/patch/1590375160-6997-2-git-send-email-maobibo@loongson.cn
after Andrew asked to replace all update_mmu_cache() calls with an alias
in the previous version of this patch here:
https://patchwork.kernel.org/project/linux-mips/patch/1590031837-9582-2-git-send-email-maobibo@loongson.cn/#23374625

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-5-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Iaad4d3c27e12c2d9bf68d1140709788fc8dead24
2022-03-23 11:32:13 -07:00
Michel Lespinasse
ab55b3bab6 FROMLIST: mmap locking API: name the return values
In the mmap locking API, the *_killable() functions return an error
(or 0 on success), and the *_trylock() functions return a boolean
(true on success).

Rename the return values "int error" and "bool ok", respectively,
rather than using "ret" for both cases which I find less readable.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-4-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I19473932c2692833dca89db5b805dbb46970dc66
2022-03-23 11:32:13 -07:00
Michel Lespinasse
2c3bf019fb FROMLIST: mmap locking API: mmap_lock_is_contended returns a bool
Change mmap_lock_is_contended to return a bool value, rather than an
int which the callers are then supposed to interpret as a bool. This
is to ensure consistency with other mmap lock API functions (such as
the trylock functions).

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-3-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I7a11ff25a493adc58480b1fe8e3f14e44ad46fb3
2022-03-23 11:32:13 -07:00
Michel Lespinasse
80169a2fe4 FROMLIST: mm: export dump_mm
This is necessary in order to allow VM_BUG_ON_MM to be used in modules
(I encountered the issue when adding VM_BUG_ON_MM in mmap locking functions).

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-2-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia373e4adde92ee4aa59ff9a1313d42a3ebccb7e3
2022-03-23 11:32:12 -07:00
Will Deacon
5715f9497b ANDROID: KVM: arm64: Invalidate TLB by VMID when tearing down the shadow VM
When a shadow VM is torn down, its VMID can be reallocated as soon as
the shadow table entry is cleared to NULL. Since tearing down the
stage-2 page-table does not imply TLB invalidation, the TLB could still
contain stale entries from the old VM and the new user of the VMID could
end up seeing erroneous translations.

Invalidate the TLB for the VMID of the VM being torn down prior to
clearing its entry in the shadow table.

Bug: 226312378
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Ice44d030bf01a1b7612413ee32440f3f38cb3e4e
2022-03-23 10:15:47 +00:00
Daniel Mentz
6efc3b4d0d ANDROID: GKI: update the pixel symbol list
Leaf changes summary: 6 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 5 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 1 Added variable

5 Added functions:

  [A] 'function int __bitmap_equal(const unsigned long int*, const unsigned long int*, unsigned int)'
  [A] 'function int down_read_trylock(rw_semaphore*)'
  [A] 'function thermal_cooling_device* of_devfreq_cooling_register_power(device_node*, devfreq*, devfreq_cooling_power*)'
  [A] 'function file* shmem_file_setup(const char*, loff_t, unsigned long int)'
  [A] 'function int thermal_zone_get_temp(thermal_zone_device*, int*)'

1 Added variable:

  [A] 'workqueue_struct* system_long_wq'

Bug: 225041227
Signed-off-by: Daniel Mentz <danielmentz@google.com>
Change-Id: I5b0dcdf3c7067f1caff56f39d2e1d4f4a013fe4a
2022-03-22 18:08:02 +00:00
Gokul krishna Krishnakumar
79f51cc58a ANDROID: Update QCOM symbol list
Update QCOM symbol list in android/abi_gki_aarch64_qcom.

Leaf changes summary: 145 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 77 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 68 Added variables

77 Added functions:

  [A] 'function rq* __migrate_task(rq*, rq_flags*, task_struct*, int)'
  [A] 'function rq* __task_rq_lock(task_struct*, rq_flags*)'
  [A] 'function void activate_task(rq*, task_struct*, int)'
  [A] 'function int add_memory_subsection(int, u64, u64)'
  [A] 'function void android_debug_for_each_module(int (const char*, void*, void*)*, void*)'
  [A] 'function void* android_debug_per_cpu_symbol(android_debug_per_cpu_symbol)'
  [A] 'function void* android_debug_symbol(android_debug_symbol)'
  [A] 'function task_struct* cgroup_taskset_first(cgroup_taskset*, cgroup_subsys_state**)'
  [A] 'function task_struct* cgroup_taskset_next(cgroup_taskset*, cgroup_subsys_state**)'
  [A] 'function void check_preempt_curr(rq*, task_struct*, int)'
  [A] 'function void console_stop(console*)'
  [A] 'function long int copy_from_kernel_nofault(void*, void*, size_t)'
  [A] 'function int cpufreq_get_policy(cpufreq_policy*, unsigned int)'
  [A] 'function int cpumask_any_and_distribute(const cpumask*, const cpumask*)'
  [A] 'function cgroup_subsys_state* css_next_child(cgroup_subsys_state*, cgroup_subsys_state*)'
  [A] 'function char* d_path(const path*, char*, int)'
  [A] 'function void deactivate_task(rq*, task_struct*, int)'
  [A] 'function devfreq* devfreq_get_devfreq_by_node(device_node*)'
  [A] 'function page* dma_alloc_pages(device*, size_t, dma_addr_t*, dma_data_direction, gfp_t)'
  [A] 'function void dma_free_pages(device*, size_t, page*, dma_addr_t, dma_data_direction)'
  [A] 'function void double_rq_lock(rq*, rq*)'
  [A] 'function pid* find_vpid(int)'
  [A] 'function int get_each_dmabuf(int (const dma_buf*, void*)*, void*)'
  [A] 'function unsigned long int get_each_object_track(kmem_cache*, page*, track_item, int (const kmem_cache*, void*, const track*, void*)*, void*)'
  [A] 'function depot_stack_handle_t get_page_owner_handle(page_ext*, unsigned long int)'
  [A] 'function void get_slabinfo(kmem_cache*, slabinfo*)'
  [A] 'function mm_struct* get_task_mm(task_struct*)'
  [A] 'function const cpumask* housekeeping_cpumask(hk_flags)'
  [A] 'function bool housekeeping_test_cpu(int, hk_flags)'
  [A] 'function i3c_generic_ibi_pool* i3c_generic_ibi_alloc_pool(i3c_dev_desc*, const i3c_ibi_setup*)'
  [A] 'function void i3c_generic_ibi_free_pool(i3c_generic_ibi_pool*)'
  [A] 'function i3c_ibi_slot* i3c_generic_ibi_get_free_slot(i3c_generic_ibi_pool*)'
  [A] 'function void i3c_generic_ibi_recycle_slot(i3c_generic_ibi_pool*, i3c_ibi_slot*)'
  [A] 'function int i3c_master_add_i3c_dev_locked(i3c_master_controller*, u8)'
  [A] 'function int i3c_master_disec_locked(i3c_master_controller*, u8, u8)'
  [A] 'function int i3c_master_do_daa(i3c_master_controller*)'
  [A] 'function int i3c_master_enec_locked(i3c_master_controller*, u8, u8)'
  [A] 'function int i3c_master_entdaa_locked(i3c_master_controller*)'
  [A] 'function int i3c_master_get_free_addr(i3c_master_controller*, u8)'
  [A] 'function void i3c_master_queue_ibi(i3c_dev_desc*, i3c_ibi_slot*)'
  [A] 'function int i3c_master_register(i3c_master_controller*, device*, const i3c_master_controller_ops*, bool)'
  [A] 'function int i3c_master_set_info(i3c_master_controller*, const i3c_device_info*)'
  [A] 'function int i3c_master_unregister(i3c_master_controller*)'
  [A] 'function int input_ff_create(input_dev*, unsigned int)'
  [A] 'function void input_ff_destroy(input_dev*)'
  [A] 'function bool irq_work_queue_on(irq_work*, int)'
  [A] 'function int is_dma_buf_file(file*)'
  [A] 'function int iterate_fd(files_struct*, unsigned int, int (void*, file*, unsigned int)*, void*)'
  [A] 'function kset* kset_create_and_add(const char*, const kset_uevent_ops*, kobject*)'
  [A] 'function page_ext* lookup_page_ext(const page*)'
  [A] 'function int migrate_swap(task_struct*, task_struct*, int, int)'
  [A] 'function void mmput(mm_struct*)'
  [A] 'function pci_dev* pci_dev_get(pci_dev*)'
  [A] 'function phys_addr_t per_cpu_ptr_to_phys(void*)'
  [A] 'function void perf_event_disable(perf_event*)'
  [A] 'function task_struct* pick_highest_pushable_task(rq*, int)'
  [A] 'function task_struct* pick_migrate_task(rq*)'
  [A] 'function int proc_dointvec_minmax(ctl_table*, int, void*, size_t*, loff_t*)'
  [A] 'function bool refcount_dec_and_lock(refcount_t*, spinlock_t*)'
  [A] 'function int register_module_notifier(notifier_block*)'
  [A] 'function int remove_memory_subsection(u64, u64)'
  [A] 'function void resched_curr(rq*)'
  [A] 'function void rproc_put(rproc*)'
  [A] 'function int select_fallback_rq(int, task_struct*)'
  [A] 'function int seq_buf_printf(seq_buf*, const char*, ...)'
  [A] 'function void set_next_entity(cfs_rq*, sched_entity*)'
  [A] 'function void set_task_cpu(task_struct*, unsigned int)'
  [A] 'function void si_swapinfo(sysinfo*)'
  [A] 'function char* skip_spaces(const char*)'
  [A] 'function int smp_call_function_single_async(int, __call_single_data*)'
  [A] 'function int stop_one_cpu(unsigned int, cpu_stop_fn_t, void*)'
  [A] 'function bool stop_one_cpu_nowait(unsigned int, cpu_stop_fn_t, void*, cpu_stop_work*)'
  [A] 'function void topology_clear_scale_freq_source(scale_freq_source, const cpumask*)'
  [A] 'function void trace_seq_printf(trace_seq*, const char*, ...)'
  [A] 'function void trace_seq_putc(trace_seq*, unsigned char)'
  [A] 'function void ufshcd_hba_stop(ufs_hba*)'
  [A] 'function int unregister_die_notifier(notifier_block*)'

68 Added variables:

  [A] 'tracepoint __tracepoint_android_rvh_account_irq'
  [A] 'tracepoint __tracepoint_android_rvh_after_dequeue_task'
  [A] 'tracepoint __tracepoint_android_rvh_after_enqueue_task'
  [A] 'tracepoint __tracepoint_android_rvh_build_perf_domains'
  [A] 'tracepoint __tracepoint_android_rvh_can_migrate_task'
  [A] 'tracepoint __tracepoint_android_rvh_cpu_cgroup_attach'
  [A] 'tracepoint __tracepoint_android_rvh_do_sched_yield'
  [A] 'tracepoint __tracepoint_android_rvh_find_busiest_queue'
  [A] 'tracepoint __tracepoint_android_rvh_find_lowest_rq'
  [A] 'tracepoint __tracepoint_android_rvh_flush_task'
  [A] 'tracepoint __tracepoint_android_rvh_get_nohz_timer_target'
  [A] 'tracepoint __tracepoint_android_rvh_is_cpu_allowed'
  [A] 'tracepoint __tracepoint_android_rvh_migrate_queued_task'
  [A] 'tracepoint __tracepoint_android_rvh_new_task_stats'
  [A] 'tracepoint __tracepoint_android_rvh_replace_next_task_fair'
  [A] 'tracepoint __tracepoint_android_rvh_rto_next_cpu'
  [A] 'tracepoint __tracepoint_android_rvh_sched_cpu_dying'
  [A] 'tracepoint __tracepoint_android_rvh_sched_cpu_starting'
  [A] 'tracepoint __tracepoint_android_rvh_sched_exec'
  [A] 'tracepoint __tracepoint_android_rvh_sched_fork_init'
  [A] 'tracepoint __tracepoint_android_rvh_sched_newidle_balance'
  [A] 'tracepoint __tracepoint_android_rvh_sched_nohz_balancer_kick'
  [A] 'tracepoint __tracepoint_android_rvh_sched_setaffinity'
  [A] 'tracepoint __tracepoint_android_rvh_schedule'
  [A] 'tracepoint __tracepoint_android_rvh_select_task_rq_fair'
  [A] 'tracepoint __tracepoint_android_rvh_set_balance_anon_file_reclaim'
  [A] 'tracepoint __tracepoint_android_rvh_set_cpus_allowed_ptr_locked'
  [A] 'tracepoint __tracepoint_android_rvh_set_gfp_zone_flags'
  [A] 'tracepoint __tracepoint_android_rvh_set_readahead_gfp_mask'
  [A] 'tracepoint __tracepoint_android_rvh_set_skip_swapcache_flags'
  [A] 'tracepoint __tracepoint_android_rvh_set_task_cpu'
  [A] 'tracepoint __tracepoint_android_rvh_show_max_freq'
  [A] 'tracepoint __tracepoint_android_rvh_tick_entry'
  [A] 'tracepoint __tracepoint_android_rvh_try_to_wake_up'
  [A] 'tracepoint __tracepoint_android_rvh_try_to_wake_up_success'
  [A] 'tracepoint __tracepoint_android_rvh_ttwu_cond'
  [A] 'tracepoint __tracepoint_android_rvh_update_cpu_capacity'
  [A] 'tracepoint __tracepoint_android_rvh_update_cpus_allowed'
  [A] 'tracepoint __tracepoint_android_rvh_update_misfit_status'
  [A] 'tracepoint __tracepoint_android_rvh_wake_up_new_task'
  [A] 'tracepoint __tracepoint_android_vh_binder_restore_priority'
  [A] 'tracepoint __tracepoint_android_vh_binder_set_priority'
  [A] 'tracepoint __tracepoint_android_vh_binder_wakeup_ilocked'
  [A] 'tracepoint __tracepoint_android_vh_ftrace_dump_buffer'
  [A] 'tracepoint __tracepoint_android_vh_ftrace_format_check'
  [A] 'tracepoint __tracepoint_android_vh_ftrace_oops_enter'
  [A] 'tracepoint __tracepoint_android_vh_ftrace_oops_exit'
  [A] 'tracepoint __tracepoint_android_vh_ftrace_size_check'
  [A] 'tracepoint __tracepoint_android_vh_logbuf'
  [A] 'tracepoint __tracepoint_android_vh_logbuf_pr_cont'
  [A] 'tracepoint __tracepoint_android_vh_show_resume_epoch_val'
  [A] 'tracepoint __tracepoint_android_vh_show_suspend_epoch_val'
  [A] 'tracepoint __tracepoint_android_vh_update_topology_flags_workfn'
  [A] 'tracepoint __tracepoint_binder_transaction_received'
  [A] 'tracepoint __tracepoint_cpu_frequency_limits'
  [A] 'tracepoint __tracepoint_cpu_idle'
  [A] 'unsigned long int arch_freq_scale'
  [A] 'irqtime cpu_irqtime'
  [A] 'cpu_topology cpu_topology[32]'
  [A] 'cma* dma_contiguous_default_area'
  [A] 'static_key_false housekeeping_overridden'
  [A] 'task_struct* ksoftirqd'
  [A] 'const char* const sched_feat_names[25]'
  [A] 'const int sysctl_vals[3]'
  [A] 'rwlock_t tasklist_lock'
  [A] 'unsigned long int thermal_pressure'
  [A] 'bool topology_update_done'
  [A] 'atomic_long_t vm_zone_stat[11]'

Bug: 211744078
Change-Id: I78b76d846ee1c66f0e86f485022d5656812c5aa9
Signed-off-by: Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
2022-03-22 15:38:37 +00:00
Tadeusz Struk
fdf79bad05 ANDROID: incremental-fs: populate userns before calling vfs_rename
The old and new mount user name spaces need to be populated
before calling vfs_rename(). Otherwise vfs_rename will try
to dereference a null ptr and segfault.

Bug: 211066171

Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: I3656073581218107fc3b1a52ebe7bcfd81a10fc2
2022-03-21 20:23:31 +00:00
Andrey Konovalov
e4967c187b FROMLIST: kasan, scs: support tagged vmalloc mappings
Fix up the custom KASAN instrumentation for Shadow Call Stack to support
vmalloc() mappings and pointers being tagged.

- Use the tagged pointer returned by kasan_unpoison_vmalloc() in
  __scs_alloc() when calling memset() to avoid false-positives.

- Do not return a tagged Shadow Call Stack pointer from __scs_alloc(),
  as this might lead to conflicts with the instrumentation.

Link: https://lkml.kernel.org/r/2f6605e3a358cf64d73a05710cb3da356886ad29.1646233925.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Marco Elver <elver@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Evgenii Stepanov <eugenis@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Collingbourne <pcc@google.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
(cherry picked from commit bd2c296805cff9572080bf56807c16d1dd382260
 git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git akpm)
Link: https://lore.kernel.org/all/2f6605e3a358cf64d73a05710cb3da356886ad29.1646233925.git.andreyknvl@google.com/
Bug: 217222520
Bug: 222221793
Change-Id: I9e6e4cd303e0815a5b092ba6ec28638bd1f7bc2c
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
2022-03-21 15:31:19 +00:00
Andrey Konovalov
4b6f018168 ANDROID: kasan: sync vmalloc support with linux-next/akpm
The FROMLIST patches merged in aosp/1974918 that add vmalloc support to
KASAN now have a few fixes staged in linux-next/akpm. Sync the changes.

Bug: 217222520
Bug: 222221793
Change-Id: I33dd30e3834a4d1bb8eac611b350004afdb08a74
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
2022-03-21 15:31:03 +00:00
Jeson Gao
78c7e3132d ANDROID: thermal: Add hook to enable/disable thermal power throttle
By default, thermal power throttle is always enable, but sometimes it
need to be disabled for a period of time, so add it to meet platform
thermal requirement.

Bug: 209386157

Signed-off-by: Jeson Gao <jeson.gao@unisoc.com>
Change-Id: If9c53a9669eec8e2821d837cfa3c660a9cfbf934
(cherry picked from commit 64999249d5)
2022-03-21 14:21:33 +08:00
Greg Kroah-Hartman
167b1e671c Merge 5.15.30 into android13-5.15
Changes in 5.15.30
	Revert "xfrm: state and policy should fail if XFRMA_IF_ID 0"
	arm64: dts: rockchip: fix rk3399-puma-haikou USB OTG mode
	xfrm: Check if_id in xfrm_migrate
	xfrm: Fix xfrm migrate issues when address family changes
	arm64: dts: rockchip: fix rk3399-puma eMMC HS400 signal integrity
	arm64: dts: rockchip: align pl330 node name with dtschema
	arm64: dts: rockchip: reorder rk3399 hdmi clocks
	arm64: dts: agilex: use the compatible "intel,socfpga-agilex-hsotg"
	ARM: dts: rockchip: reorder rk322x hmdi clocks
	ARM: dts: rockchip: fix a typo on rk3288 crypto-controller
	mac80211: refuse aggregations sessions before authorized
	MIPS: smp: fill in sibling and core maps earlier
	ARM: 9178/1: fix unmet dependency on BITREVERSE for HAVE_ARCH_BITREVERSE
	Bluetooth: hci_core: Fix leaking sent_cmd skb
	can: rcar_canfd: rcar_canfd_channel_probe(): register the CAN device when fully ready
	atm: firestream: check the return value of ioremap() in fs_init()
	iwlwifi: don't advertise TWT support
	drm/vrr: Set VRR capable prop only if it is attached to connector
	nl80211: Update bss channel on channel switch for P2P_CLIENT
	tcp: make tcp_read_sock() more robust
	sfc: extend the locking on mcdi->seqno
	bnx2: Fix an error message
	kselftest/vm: fix tests build with old libc
	x86/module: Fix the paravirt vs alternative order
	ice: Fix race condition during interface enslave
	Linux 5.15.30

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Icf3c6ca9fb4bb75435d3964e12c0fcb42397b50b
2022-03-19 14:36:07 +01:00