Commit Graph

987977 Commits

Author SHA1 Message Date
Pradeep P V K
30d72758db FROMLIST: fuse: give wakeup hints to the scheduler
The synchronous wakeup interface is available only for the
interruptible wakeup. Add it for normal wakeup and use this
synchronous wakeup interface to wakeup the userspace daemon.
Scheduler can make use of this hint to find a better CPU for
the waker task.

With this change the performance numbers for compress, decompress
and copy use-cases on /sdcard path has improved by ~30%.

Use-case details:
1. copy 10000 files of each 4k size into /sdcard path
2. use any File explorer application that has compress/decompress
support
3. start compress/decompress and capture the time.

-------------------------------------------------
| Default   | wakeup support | Improvement/Diff |
-------------------------------------------------
| 13.8 sec  | 9.9 sec        | 3.9 sec (28.26%) |
-------------------------------------------------

Co-developed-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
Signed-off-by: Pradeep P V K <quic_pragalla@quicinc.com>

Bug: 216261533
Link: https://lore.kernel.org/lkml/1638780405-38026-1-git-send-email-quic_pragalla@quicinc.com/
Change-Id: I9ac89064e34b1e0605064bf4d2d3a310679cb605
Signed-off-by: Pradeep P V K <quic_pragalla@quicinc.com>
Signed-off-by: Alessio Balsini <balsini@google.com>
2022-04-01 11:12:11 +00:00
Quentin Perret
11e605185f ANDROID: KVM: arm64: Don't map host sections in pkvm
We no longer need to map the host's .rodata and .bss sections in the
pkvm hypervisor, so let's remove those mappings. This will avoid
creating dependencies at EL2 on host-controlled data-structures.

Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 225169428
Change-Id: I0fcb0e1b34d3c7c0c226b3fd30cdec0e8d7bfb44
2022-04-01 08:21:21 +00:00
Quentin Perret
fce8d906cf ANDROID: KVM: arm64: Explicitely map kvm_vgic_global_state at EL2
The pkvm hypervisor may need to read the kvm_vgic_global_state variable
at EL2. Make sure to explicitely map it in the its stage-1 page-table
rather than relying on mapping all of .rodata.

Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 225169428
Change-Id: I72d1eba78fb6b7593d236539cd81269480856fdf
2022-04-01 08:21:15 +00:00
Quentin Perret
6e12d67ad0 ANDROID: KVM: arm64: Unmap kvm_arm_hyp_percpu_base from the host
In pKVM mode, we can't trust the host not to mess with the hypervisor
per-cpu offsets, so let's move the array containing them to the nVHE
code.

Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 225169428
Change-Id: I9ef4175ce9cf00d6ff1c0e358551a565358f2408
2022-04-01 08:21:09 +00:00
Quentin Perret
ae49ca9a17 ANDROID: KVM: arm64: pkvm: Don't access kvm_arm_hyp_percpu_base at EL1
The host KVM PMU code can currently index kvm_arm_hyp_percpu_base[]
through this_cpu_ptr_hyp_sym(), but will not actually dereference that
pointer when protected KVM is enabled. In preparation for making
kvm_arm_hyp_percpu_base[] unaccessible to the host, let's make sure the
indexing in hyp per-cpu pages is also done after the static key check to
avoid spurious accesses to EL2-private data from EL1.

Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 225169428
Change-Id: I3f4e3f7ee789c31a1ae1f67e07edf8fb34f520b9
2022-04-01 08:21:04 +00:00
Mars Lin
b576a36a95 ANDROID: Update the ABI symbol list
Leaf changes summary: 1 artifact changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

1 Added function:

  [A] 'function irq_data* irq_domain_get_irq_data(irq_domain*, unsigned int)'

Bug: 208368211
Change-Id: I513e4392ea9aa556d9acb7f8cc1f06d802e34dfb
Signed-off-by: Mars Lin <marslin@google.com>
2022-04-01 01:48:39 +00:00
Huang Jianan
4c3d004aa7 UPSTREAM: erofs: add sysfs interface
Add sysfs interface to configure erofs related parameters later.

Link: https://lore.kernel.org/r/20211201145436.4357-1-huangjianan@oppo.com
Reviewed-by: Chao Yu <chao@kernel.org>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Huang Jianan <huangjianan@oppo.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: David Anderson <dvander@google.com>
Change-Id: I1c6a5af906cdac3e49bd7fc94d3ca58d5f80c4a4
(cherry picked from commit 168e9a7620)
2022-03-31 17:13:48 +00:00
Lee Jones
dc123bee94 Revert "ANDROID: dm-bow: Protect Ranges fetched and erased from the RB tree"
This reverts commit 3dcc5d0b9d.

Reason for revert: Needs rework - causes unforeseen deadlock.

Bug: 227141277
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Id23e99dfca3449017e6095e169a383241cc413ff
2022-03-31 11:21:02 +00:00
Rick Yiu
3f9db3f711 ANDROID: sched: Add vendor hook for rt util update
Vendor may have need to track rt util.

Bug: 201261299
Signed-off-by: Rick Yiu <rickyiu@google.com>
Change-Id: I2f4e5142c6bc8574ee3558042e1fb0dae13b702d
2022-03-31 00:34:54 +00:00
David Brazdil
cd5c13796b ANDROID: Update the ABI symbol list
Leaf changes summary: 2 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 2 Added
functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added
variable

2 Added functions:

  [A] 'function int pkvm_iommu_finalize()'
  [A] 'function int pkvm_iommu_sysmmu_sync_register(device*, phys_addr_t, device*)'

Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: Ibc7bf50b9b68c0334ea786b603f40c04b8ccea5b
2022-03-30 13:51:45 +01:00
David Brazdil
9859d2761e ANDROID: Add new pkvm_iommu_* functions to aarch64 ABI
Add two new symbols to aarch64 kernel ABI:
  * pkvm_iommu_sysmmu_sync_register
  * pkvm_iommu_finalize

The former allows vendor modules to register a SYSMMU_SYNC device with
the hypervisor, and the latter tells the hypervisor to stop acception
new device registrations.

Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I6c6948d94cb6494f07d52b4e2b7e91db40e2fcd6
2022-03-30 13:51:45 +01:00
David Brazdil
8fd93b0ef9 ANDROID: KVM: arm64: iommu: Add pkvm_iommu_finalize
Add new hypercall that the host can use to inform the hypervisor that
all hypervisor-controlled IOMMUs have been registered and no new
registrations should be allowed. This will typically be called at the
end of kernel module initialization phase.

Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I8c175310d5b262a67947443c5a0154056a8ebf3e
2022-03-30 13:51:45 +01:00
David Brazdil
798c4ea545 ANDROID: KVM: arm64: iommu: No powered check in DABT handler
The IOMMU DABT handler currently checks if the device is considered
powered by hyp before resolving the request. If the power tracking does
not reflect reality, the IOMMU may trigger issues in the host but the
incorrect state prevents it from diagnosing the issue.

Drop the powered check from the generic IOMMU code. The host accessing
the device's SFR means that it assumes it is powered, and individual
drivers can choose to reject that DABT request.

Bug: 224891559
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I1c132c4030a61a90be4675867c9658e3bc696118
2022-03-30 07:47:48 +00:00
David Brazdil
57381d548d ANDROID: KVM: arm64: s2mpu: Create SysMMU_SYNC driver
SysMMU_SYNC devices expose an interface to start a sync counter and
poll its SFR until the device signals that all memory transactions in
flight at the start have drained. This gives the hypervisor a reliable
indicator that S2MPU invalidation has fully completed and all new
transactions will use the new MPTs.

Add a new pKVM IOMMU driver that the host can use to register
SysMMU_SYNCs. Each device is expected to be a supplier to exactly one
S2MPU (parent), but multiple SYNCs can supply a single S2MPU.

To keep things simple, the SYNCs do not implement suspend/resume and are
assumed to follow the power transitions of their parent.

Following an invalidation, the S2MPU driver iterates over its children
and waits for each SYNC to signal that its transactions have drained.
The algorithm currently waits on each SYNC in turn. If latency proves to
be an issue, this could be optimized to initiate a SYNC on all powered
devices before starting to poll.

Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I45b832fd11d76b65987935c8548e2a214ee2fa2a
2022-03-29 17:09:26 +01:00
David Brazdil
e69c61cf4e ANDROID: KVM: arm64: iommu: Create parent/child relation
In preparation for adding new IOMMU devices that act as suppliers to
others, add the notion of a parent IOMMU device. Such device must be
registered after its parent and the driver of the parent device must
validate the addition.

The relation has no generic implications, it is up to drivers to make
use of it.

Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I4ee3675e5529bb73ad4546fa32380f237f054177
2022-03-29 17:09:26 +01:00
David Brazdil
be84f2c770 ANDROID: KVM: arm64: iommu: Run validate() on struct pkvm_iommu
In preparation for needing to validate more aspects of a device that is
about to be registered, change the callback to accept the to-be-added
'struct pkvm_iommu' rather than individual inputs.

Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I3fb911e4280c220ddd779cf6a5fc9c302a5617f7
2022-03-29 17:09:26 +01:00
David Brazdil
e6574a68fa ANDROID: KVM: arm64: iommu: Create private mapping last
Private EL2 mappings currently cannot be removed. Move the creation of
IOMMU device mappings at the end of the registration function so that
other errors do not result in unnecessary mappings.

Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I3139e9af3345f157295eb72441a7cf3cc055116d
2022-03-29 17:09:26 +01:00
David Brazdil
acb9a25416 ANDROID: KVM: arm64: iommu: Free memory on registration error
Memory for IOMMU device entries gets allocated from a pool donated by
the host. It is possible for pkvm_iommu_register() to allocate the
memory and then fail, in which case the memory remains unused but not
freed.

Refactor the code such that the host lock covers the entire section
where the memory is allocated. This way we can return the memory back to
the linear allocator if an error is returned.

Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I8c1650ba3e545741144d793de506e93c4066896f
2022-03-29 17:09:26 +01:00
David Brazdil
6eaed0b8b7 ANDROID: KVM: arm64: iommu: Harden __pkvm_iommu_pm_notify
Currently __pkvm_iommu_pm_notify always changes the value of
dev->powered following a suspend/resume attempt. This could potentially
be abused to force the hypervisor to stop issuing updates to an S2MPU
and preserving an old/invalid state.

Modify to only update the power state if suspend/resume was successful.

Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I285fc822e9fc926c49b9b5e69446790e1edccafb
2022-03-29 17:09:26 +01:00
Will Deacon
a75cb9df82 ANDROID: KVM: arm64: Drop FOLL_FORCE when pinning guest memory pages
Passing FOLL_FORCE when pinning guest memory pages was intended to allow
the VMM to map guest memory as PROT_NONE without prohibiting access from
the guest. As it turns out, crosvm doesn't implement this, and since
the host kernel will inject a signal into the VMM on a bad access
irrespective of the stage-1 permissions, we can drop the FOLL_FORCE flag
altogether.

Bug: 226564150
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: If21091b6adf3dbe4155c5c840753c912d283b159
2022-03-29 09:05:07 +01:00
Will Deacon
a246583fcc Revert "ANDROID: BACKPORT: KVM: arm64: Add initial support for KVM_CAP_EXIT_HYPERCALL"
This reverts commit e853c3b172.

This capability is unused, so remove it to avoid UAPI divergence from
upstream.

Bug: 226564150
[willdeacon@: Also removed additional instance in arch/arm64/kvm/arm.c]
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Ib3e929a5fc81dc5c9c1ff8512d48f63bdda5c404
2022-03-29 09:05:06 +01:00
Will Deacon
bbe5c85592 Revert "ANDROID: KVM: arm64: Allow userspace to receive SHARE and UNSHARE notifications"
This reverts commit 7f19cf521f.

These notifications are unused by crosvm and are no longer required now
that the host takes care of injecting a SEGV on an illegal memory access
from userspace.

Bug: 226564150
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I22c3e49b4aa5f023961c8849b79e2e0a21ebf0c1
2022-03-29 09:05:06 +01:00
Xie Yongji
588affc843 BACKPORT: virtio-blk: Use blk_validate_block_size() to validate block size
The block layer can't support a block size larger than
page size yet. And a block size that's too small or
not a power of two won't work either. If a misconfigured
device presents an invalid block size in configuration space,
it will result in the kernel crash something like below:

[  506.154324] BUG: kernel NULL pointer dereference, address: 0000000000000008
[  506.160416] RIP: 0010:create_empty_buffers+0x24/0x100
[  506.174302] Call Trace:
[  506.174651]  create_page_buffers+0x4d/0x60
[  506.175207]  block_read_full_page+0x50/0x380
[  506.175798]  ? __mod_lruvec_page_state+0x60/0xa0
[  506.176412]  ? __add_to_page_cache_locked+0x1b2/0x390
[  506.177085]  ? blkdev_direct_IO+0x4a0/0x4a0
[  506.177644]  ? scan_shadow_nodes+0x30/0x30
[  506.178206]  ? lru_cache_add+0x42/0x60
[  506.178716]  do_read_cache_page+0x695/0x740
[  506.179278]  ? read_part_sector+0xe0/0xe0
[  506.179821]  read_part_sector+0x36/0xe0
[  506.180337]  adfspart_check_ICS+0x32/0x320
[  506.180890]  ? snprintf+0x45/0x70
[  506.181350]  ? read_part_sector+0xe0/0xe0
[  506.181906]  bdev_disk_changed+0x229/0x5c0
[  506.182483]  blkdev_get_whole+0x6d/0x90
[  506.183013]  blkdev_get_by_dev+0x122/0x2d0
[  506.183562]  device_add_disk+0x39e/0x3c0
[  506.184472]  virtblk_probe+0x3f8/0x79b [virtio_blk]
[  506.185461]  virtio_dev_probe+0x15e/0x1d0 [virtio]

So let's use a block layer helper to validate the block size.

Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Link: https://lore.kernel.org/r/20211026144015.188-5-xieyongji@bytedance.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
(cherry picked from commit 57a13a5b81)
[keirf@: Implement missing error path]
Bug: 226679849
Signed-off-by: Keir Fraser <keirf@google.com>
Change-Id: I78cde1101baf8da2f68d0b9f942a0f1ec89fb30e
2022-03-29 07:01:22 +00:00
Rick Yiu
fe0484006f ANDROID: Update the ABI representation
Leaf changes summary: 13 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 7 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 6 Added variables

7 Added functions:

  [A] 'function void ___update_load_avg(sched_avg*, unsigned long int)'
  [A] 'function int ___update_load_sum(u64, sched_avg*, unsigned long int, unsigned long int, int)'
  [A] 'function int __traceiter_android_rvh_attach_entity_load_avg(void*, cfs_rq*, sched_entity*)'
  [A] 'function int __traceiter_android_rvh_detach_entity_load_avg(void*, cfs_rq*, sched_entity*)'
  [A] 'function int __traceiter_android_rvh_remove_entity_load_avg(void*, cfs_rq*, sched_entity*)'
  [A] 'function int __traceiter_android_rvh_update_blocked_fair(void*, rq*)'
  [A] 'function int __traceiter_android_rvh_update_load_avg(void*, u64, cfs_rq*, sched_entity*)'

6 Added variables:

  [A] 'tracepoint __tracepoint_android_rvh_attach_entity_load_avg'
  [A] 'tracepoint __tracepoint_android_rvh_detach_entity_load_avg'
  [A] 'tracepoint __tracepoint_android_rvh_remove_entity_load_avg'
  [A] 'tracepoint __tracepoint_android_rvh_update_blocked_fair'
  [A] 'tracepoint __tracepoint_android_rvh_update_load_avg'
  [A] 'int pelt_load_avg_max'

Bug: 201260585
Signed-off-by: Rick Yiu <rickyiu@google.com>
Change-Id: Ie75a373840f3cb531648d760eaba846065328d1a
2022-03-29 03:03:54 +00:00
Rick Yiu
e3356ca0a6 ANDROID: sched: Add vendor hook for util-update related functions
Vendor may have the need to implement their own util tracking.

Bug: 201260585
Signed-off-by: Rick Yiu <rickyiu@google.com>
Change-Id: I973902e6ff82a85ecd029ac5a78692d629df1ebe
2022-03-29 01:08:35 +00:00
Ray Chi
ec7c9ea9d4 ANDROID: Update the ABI representation
Leaf changes summary: 19 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 19 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

19 Added functions:

  [A] 'function void gether_cleanup(eth_dev*)'
  [A] 'function net_device* gether_connect(gether*)'
  [A] 'function void gether_disconnect(gether*)'
  [A] 'function int gether_get_dev_addr(net_device*, char*, int)'
  [A] 'function int gether_get_host_addr(net_device*, char*, int)'
  [A] 'function void gether_get_host_addr_u8(net_device*, u8*)'
  [A] 'function int gether_get_ifname(net_device*, char*, int)'
  [A] 'function unsigned int gether_get_qmult(net_device*)'
  [A] 'function int gether_register_netdev(net_device*)'
  [A] 'function int gether_set_dev_addr(net_device*, const char*)'
  [A] 'function void gether_set_gadget(net_device*, usb_gadget*)'
  [A] 'function int gether_set_host_addr(net_device*, const char*)'
  [A] 'function int gether_set_ifname(net_device*, const char*, int)'
  [A] 'function void gether_set_qmult(net_device*, unsigned int)'
  [A] 'function net_device* gether_setup_name_default(const char*)'
  [A] 'function int usb_assign_descriptors(usb_function*, usb_descriptor_header**, usb_descriptor_header**, usb_descriptor_header**, usb_descriptor_header**)'
  [A] 'function void usb_free_all_descriptors(usb_function*)'
  [A] 'function usb_string* usb_gstrings_attach(usb_composite_dev*, usb_gadget_strings**, unsigned int)'
  [A] 'function config_group* usb_os_desc_prepare_interf_dir(config_group*, int, usb_os_desc**, char**, module*)'

Bug: 226074645
Change-Id: Iddfd251ee91514fac4153e14737825f40d855634
Signed-off-by: Ray Chi <raychi@google.com>
2022-03-28 15:58:20 +00:00
Quentin Perret
982febefcd ANDROID: KVM: arm64: pkvm: Inject SIGSEGV on illegal accesses
The pKVM hypervisor will currently panic if the host tries to access
memory that it doesn't own (e.g. protected guest memory). Sadly, as
guest memory can still be mapped into the VMM's address space, userspace
can trivially crash the kernel/hypervisor by poking into guest memory.

To prevent this, inject the abort back in the host with S1PTW set in the
ESR, hence allowing the host to differentiate this abort from normal
userspace faults and inject a SIGSEGV cleanly.

Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 215520143
Change-Id: I9636e71e2fe3eb49d2d7cddaab7774cd672cfcae
2022-03-28 10:53:17 +00:00
Quentin Perret
e7b80adac2 ANDROID: KVM: arm64: Refactor enter_exception64()
In order to simplify the injection of exceptions in the host in pkvm
context, let's factor out of enter_exception64() the code calculating
the exception offset from VBAR_EL1 and the cpsr.

Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 215520143
Change-Id: I97b2431a79fdec87c95c2d1f691bd3a11635c29b
2022-03-28 10:53:11 +00:00
Quentin Perret
91c32ff1fe ANDROID: KVM: arm64: Add is_pkvm_initialized() helper
Add a helper allowing to check when the pkvm static key is enabled to
ease the introduction of pkvm hooks in other parts of the code.

Signed-off-by: Quentin Perret <qperret@google.com>
Bug: 215520143
Change-Id: Iae065b09bb33d42d73a408365c803727269d0de0
2022-03-28 10:53:05 +00:00
Will Deacon
ba73e0b827 ANDROID: KVM: arm64: Use PSCI MEM_PROTECT to zap guest pages on reset
If a malicious/compromised host issues a PSCI SYSTEM_RESET call in the
presence of guest-owned pages then the contents of those pages may be
susceptible to cold-reboot attacks.

Use the PSCI MEM_PROTECT call to ensure that volatile memory is wiped by
the firmware if a SYSTEM_RESET occurs while unpoisoned guest pages exist
in the system. Since this call does not offer protection for a "warm"
reset initiated by SYSTEM_RESET2, detect this case in the PSCI relay and
repaint the call to a standard SYSTEM_RESET instead.

Bug: 196204410
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I5c3dd93bc83ebcd0b6cea2ec734f6e3a77f0064e
2022-03-28 10:50:25 +00:00
Quentin Perret
40493bc91e ANDROID: KVM: arm64: Check pin_user_pages() return value
Let's check the return value of pin_user_pages() before blindly
dereferencing the struct page pointer as it may very well be NULL.

Bug: 223678931
Reported-by: Keir Fraser <keirf@google.com>
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: I49eb0eb14b88429cfeed3e7cc8a2a72404cfea97
2022-03-28 08:19:58 +00:00
Marc Zyngier
dbba49b6cb ANDROID: KVM: arm64: Handle all ID registers trapped for a protected VM
A protected VM accessing ID_AA64ISAR2_EL1 gets punished with an UNDEF,
while it really should only get a zero back if the register is not
handled by the hypervisor emulation (as mandated by the architecture).

Introduce all the missing ID registers (including the unallocated ones),
and have them to return 0.

Bug: 226913064
Reported-by: Will Deacon <willdeacon@google.com>
Signed-off-by: Marc Zyngier <mzyngier@google.com>
Change-Id: I1f8de324af8a47974e6ab6b0bf68c8e1b01c4baf
2022-03-27 11:47:42 +00:00
Siddharth Kapoor
5c6f14f146 ANDROID: Update the ABI symbol list
Leaf changes summary: 0 artifact changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable
Function symbols changes summary: 0 Removed, 1 Added function symbol not referenced by debug info
Variable symbols changes summary: 0 Removed, 0 Added variable symbol not referenced by debug info

1 Added function symbol not referenced by debug info:

  [A] memchr

Bug: 220942030
Signed-off-by: Siddharth Kapoor <ksiddharth@google.com>
Change-Id: If972ccefd136c76871fece6be793db36e76e42e0
2022-03-26 06:33:50 +00:00
Bowgo Tsai
373e5bd7d4 ANDROID: GKI: Enable BUILD_GKI_CERTIFICATION_TOOLS
Bug: 222082632
Test: TH
Signed-off-by: Bowgo Tsai <bowgotsai@google.com>
Change-Id: I29aa163a8de8d60c103aad642f306ad5d4b92d40
2022-03-26 03:21:01 +00:00
Aran Dalton
83631772f3 ANDROID: usb: gadget: f_accessory: add compat_ioctl support
On Android 32-bit system, the following Cts Verifier testcase failed:

manualTests#com.android.cts.verifier.usb.accessory.UsbAccessoryTestActivity

The reason is that compat_ioctl() needs to be called.
So let's add compat_ioctl() for 32-bit applications to solve this issue.

Bug: 223101878
Change-Id: I6e1f797d919494d293184411041955c33ad08aef
Signed-off-by: Aran Dalton <arda@allwinnertech.com>
(cherry picked from commit 77bf53b486)
2022-03-25 19:55:01 +00:00
Suren Baghdasaryan
4443600ce1 UPSTREAM: mm: fix use-after-free when anon vma name is used after vma is freed
When adjacent vmas are being merged it can result in the vma that was
originally passed to madvise_update_vma being destroyed.  In the current
implementation, the name parameter passed to madvise_update_vma points
directly to vma->anon_name and it is used after the call to vma_merge.
In the cases when vma_merge merges the original vma and destroys it,
this might result in UAF.  For that the original vma would have to hold
the anon_vma_name with the last reference.  The following vma would need
to contain a different anon_vma_name object with the same string.  Such
scenario is shown below:

madvise_vma_behavior(vma)
  madvise_update_vma(vma, ..., anon_name == vma->anon_name)
    vma_merge(vma)
      __vma_adjust(vma) <-- merges vma with adjacent one
        vm_area_free(vma) <-- frees the original vma
    replace_vma_anon_name(anon_name) <-- UAF of vma->anon_name

Fix this by raising the name refcount and stabilizing it.

Link: https://lkml.kernel.org/r/20220224231834.1481408-3-surenb@google.com
Link: https://lkml.kernel.org/r/20220223153613.835563-3-surenb@google.com
Fixes: 9a10064f56 ("mm: add a field to store names for private anonymous memory")
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Reported-by: syzbot+aa7b3d4b35f9dc46a366@syzkaller.appspotmail.com
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Alexey Gladkov <legion@kernel.org>
Cc: Chris Hyser <chris.hyser@oracle.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Colin Cross <ccross@google.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Peter Collingbourne <pcc@google.com>
Cc: Sasha Levin <sashal@kernel.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Xiaofeng Cao <caoxiaofeng@yulong.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 942341dcc5)

Bug: 218352794
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I07e3cbff2eaa69a0d56281537510f7a42feaaf09
2022-03-25 16:28:52 +00:00
Suren Baghdasaryan
6962eb33d8 UPSTREAM: mm: prevent vm_area_struct::anon_name refcount saturation
A deep process chain with many vmas could grow really high.  With
default sysctl_max_map_count (64k) and default pid_max (32k) the max
number of vmas in the system is 2147450880 and the refcounter has
headroom of 1073774592 before it reaches REFCOUNT_SATURATED
(3221225472).

Therefore it's unlikely that an anonymous name refcounter will overflow
with these defaults.  Currently the max for pid_max is PID_MAX_LIMIT
(4194304) and for sysctl_max_map_count it's INT_MAX (2147483647).  In
this configuration anon_vma_name refcount overflow becomes theoretically
possible (that still require heavy sharing of that anon_vma_name between
processes).

kref refcounting interface used in anon_vma_name structure will detect a
counter overflow when it reaches REFCOUNT_SATURATED value but will only
generate a warning and freeze the ref counter.  This would lead to the
refcounted object never being freed.  A determined attacker could leak
memory like that but it would be rather expensive and inefficient way to
do so.

To ensure anon_vma_name refcount does not overflow, stop anon_vma_name
sharing when the refcount reaches REFCOUNT_MAX (2147483647), which still
leaves INT_MAX/2 (1073741823) values before the counter reaches
REFCOUNT_SATURATED.  This should provide enough headroom for raising the
refcounts temporarily.

Link: https://lkml.kernel.org/r/20220223153613.835563-2-surenb@google.com
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Suggested-by: Michal Hocko <mhocko@suse.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Alexey Gladkov <legion@kernel.org>
Cc: Chris Hyser <chris.hyser@oracle.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Colin Cross <ccross@google.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Peter Collingbourne <pcc@google.com>
Cc: Sasha Levin <sashal@kernel.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Xiaofeng Cao <caoxiaofeng@yulong.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 96403e1128)

Bug: 218352794
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ieaab58f6300d9aff3139eed1c1d3417237d81955
2022-03-25 16:28:46 +00:00
Suren Baghdasaryan
9fbdc4b53f UPSTREAM: mm: refactor vm_area_struct::anon_vma_name usage code
Avoid mixing strings and their anon_vma_name referenced pointers by
using struct anon_vma_name whenever possible.  This simplifies the code
and allows easier sharing of anon_vma_name structures when they
represent the same name.

[surenb@google.com: fix comment]

Link: https://lkml.kernel.org/r/20220223153613.835563-1-surenb@google.com
Link: https://lkml.kernel.org/r/20220224231834.1481408-1-surenb@google.com
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Suggested-by: Matthew Wilcox <willy@infradead.org>
Suggested-by: Michal Hocko <mhocko@suse.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Colin Cross <ccross@google.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Alexey Gladkov <legion@kernel.org>
Cc: Sasha Levin <sashal@kernel.org>
Cc: Chris Hyser <chris.hyser@oracle.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Peter Collingbourne <pcc@google.com>
Cc: Xiaofeng Cao <caoxiaofeng@yulong.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 5c26f6ac94)

Bug: 218352794
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I4a6b5602ce7151d1a4b88fac489f86d68089bd4d
2022-03-25 16:28:27 +00:00
Will Deacon
6b94b8c3b7 ANDROID: KVM: arm64: Only map swap-backed pages into the guest
Alistair reports an ext4 splat when running a non-protected guest under
pKVM using Cuttlefish on a rockpi board:

 | WARNING: CPU: 4 PID: 3125 at fs/ext4/inode.c:3592 ext4_set_page_dirty+0x6c/0x90
 |  sp : ffffffc00e1a39b0
 |  x29: ffffffc00e1a39b0 x28: ffffffc009ac3c18 x27: ffffffc009a80968
 |  x26: ffffff80c2753a00 x25: 0000000200000000 x24: ffffffc00a6dc000
 |  x23: 0000000000000000 x22: 0000000000000001 x21: fffffffe0314f640
 |  x20: ffffff8063a99890 x19: fffffffe0314f640 x18: ffffffc00dbf5090
 |  x17: 0000000000000020 x16: ffffffc00ab73080 x15: 0000000000000040
 |  x14: 0000000000000040 x13: 0000000000000040 x12: 0000000080200000
 |  x11: 0000000000000000 x10: fffffffe0314f640 x9 : 0000000000000016
 |  x8 : 0000000000000015 x7 : 0000000000000062 x6 : 0000000000000068
 |  x5 : 0000000080200015 x4 : ffffff80067c7500 x3 : 0000000080200016
 |  x2 : 0000000000000001 x1 : 0000000000000001 x0 : fffffffe0314f640
 |  Call trace:
 |   ext4_set_page_dirty+0x6c/0x90
 |   set_page_dirty+0xf0/0x264
 |   set_page_dirty_lock+0x94/0x164
 |   unpin_user_pages_dirty_lock+0xa0/0x15c
 |   kvm_shadow_destroy+0xd4/0x150
 |   kvm_arch_destroy_vm+0xa0/0xa4
 |   kvm_destroy_vm+0x634/0xa0c
 |   kvm_vcpu_release+0x44/0xc0
 |   __fput+0xf8/0x43c
 |   ____fput+0x14/0x24
 |   task_work_run+0x140/0x204
 |   do_exit+0x450/0x12b0
 |   do_group_exit+0xc8/0x17c
 |   get_signal+0x85c/0xa10
 |   do_signal+0x9c/0x268
 |   do_notify_resume+0x98/0x220
 |   el0_svc+0x5c/0x84
 |   el0t_64_sync_handler+0x88/0xec
 |   el0t_64_sync+0x1b4/0x1b8

This appears to be due to virtio-pmem mapping a host page-cache page
directly into the guest and pinning it with GUP. A later attempt to
wrprotect the page using page_mkclean() on the writeback path will not
find the guest mapping and consequently the filesystem becomes confused
when we later dirty the page without any page buffers having been
allocated.

Since the host cannot generally access the memory of protected VMs,
restrict ourselves to swap-backed pages for now and avoid attempting
writeback altogether, with the GUP pin preventing swapout.

Bug: 223678931
Reported-by: Alistair Delva <adelva@google.com>
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Id8da126aac220df6eff44177a911dc4627e68c02
2022-03-25 10:07:45 +00:00
Will McVicker
c8b5505153 ANDROID: Update the ABI representation
Leaf changes summary: 1 artifact changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 1 Added variable

1 Added variable:

  [A] 'reboot_mode reboot_mode'

Bug: 226526792
Change-Id: Ic51d233429f0325c33111bc36a65b78fc4288fa6
Signed-off-by: Will McVicker <willmcvicker@google.com>
2022-03-24 22:37:14 +00:00
Nick Desaulniers
3101b49e5b ANDROID: clang: update to 14.0.3
Bug: 225394140
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Change-Id: Id092562afb73b51883feafbd8ae49736a570af09
2022-03-24 19:46:10 +00:00
Will Deacon
93846ccca1 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-24 09:02:48 +00:00
Jaegeuk Kim
ed0dec098e ANDROID: gki_config: enable F2FS_UNFAIR_RWSEM
Let's try this to avoid lock contention, until we find a better solution.

Bug: 216636351
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: Ib7ae218cb4a2531fdb85679b8530e4eba755e06a
2022-03-24 00:52:18 +00:00
Jaegeuk Kim
f8c415b6c2 Merge remote-tracking branch 'aosp/upstream-f2fs-stable-linux-5.10.y' into android13-5.10
* aosp/upstream-f2fs-stable-linux-5.10.y:
  fscrypt: update documentation for direct I/O support
  f2fs: support direct I/O with fscrypt using blk-crypto
  ext4: support direct I/O with fscrypt using blk-crypto
  iomap: support direct I/O with fscrypt using blk-crypto
  fscrypt: add functions for direct I/O support
  f2fs: fix to do sanity check on .cp_pack_total_block_count
  f2fs: make gc_urgent and gc_segment_mode sysfs node readable
  f2fs: use aggressive GC policy during f2fs_disable_checkpoint()
  f2fs: fix compressed file start atomic write may cause data corruption
  f2fs: initialize sbi->gc_mode explicitly
  f2fs: introduce gc_urgent_mid mode
  f2fs: compress: fix to print raw data size in error path of lz4 decompression
  f2fs: remove redundant parameter judgment
  f2fs: use spin_lock to avoid hang
  f2fs: don't get FREEZE lock in f2fs_evict_inode in frozen fs
  f2fs: remove unnecessary read for F2FS_FITS_IN_INODE
  f2fs: introduce F2FS_UNFAIR_RWSEM to support unfair rwsem
  f2fs: avoid an infinite loop in f2fs_sync_dirty_inodes
  f2fs: fix to do sanity check on curseg->alloc_type
  f2fs: fix to avoid potential deadlock
  f2fs: quota: fix loop condition at f2fs_quota_sync()
  f2fs: Restore rwsem lockdep support
  f2fs: fix missing free nid in f2fs_handle_failed_inode
  f2fs: add a way to limit roll forward recovery time
  f2fs: introduce F2FS_IPU_HONOR_OPU_WRITE ipu policy
  f2fs: adjust readahead block number during recovery
  f2fs: fix to unlock page correctly in error path of is_alive()
  f2fs: expose discard related parameters in sysfs
  f2fs: move discard parameters into discard_cmd_control
  f2fs: fix to enable ATGC correctly via gc_idle sysfs interface
  f2fs: move f2fs to use reader-unfair rwsems

Bug: 216636351
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I53cc37765ba69df2a9b7b9c070e4938822354f05
2022-03-24 00:51:47 +00:00
Todd Kjos
cf9be86ac4 ANDROID: GKI: 3/23/2022 KMI update
Set KMI_GENERATION=2 for 3/23 KMI update

Leaf changes summary: 505 artifacts changed
Changed leaf types summary: 2 leaf types changed
Removed/Changed/Added functions summary: 0 Removed, 489 Changed, 6 Added functions
Removed/Changed/Added variables summary: 0 Removed, 3 Changed, 5 Added variables

6 Added functions:

  [A] 'function int __traceiter_android_vh___get_user_pages_remote(void*, int*, unsigned int*)'
  [A] 'function int __traceiter_android_vh_get_user_pages(void*, unsigned int*)'
  [A] 'function int __traceiter_android_vh_internal_get_user_pages_fast(void*, unsigned int*)'
  [A] 'function int __traceiter_android_vh_pin_user_pages(void*, unsigned int*)'
  [A] 'function int __traceiter_android_vh_try_grab_compound_head(void*, page*, int, unsigned int, bool*)'
  [A] 'function unsigned long int get_pfnblock_flags_mask(page*, unsigned long int, unsigned long int)'

489 functions with some sub-type change:

  [C] 'function sk_buff* __alloc_skb(unsigned int, gfp_t, int, int)' at skbuff.c:183:1 has some sub-type changes:
    CRC (modversions) changed from 0x42ee9964 to 0x7c77e5af

  [C] 'function sk_buff* __cfg80211_alloc_event_skb(wiphy*, wireless_dev*, nl80211_commands, nl80211_attrs, unsigned int, int, int, gfp_t)' at nl80211.c:10277:1 has some sub-type changes:
    CRC (modversions) changed from 0x55bb655c to 0x5f07fe5f

  [C] 'function sk_buff* __cfg80211_alloc_reply_skb(wiphy*, nl80211_commands, nl80211_attrs, int)' at nl80211.c:13811:1 has some sub-type changes:
    CRC (modversions) changed from 0x8854dc9d to 0x4d096973

  ... 486 omitted; 489 symbols have only CRC changes

5 Added variables:

  [A] 'tracepoint __tracepoint_android_vh___get_user_pages_remote'
  [A] 'tracepoint __tracepoint_android_vh_get_user_pages'
  [A] 'tracepoint __tracepoint_android_vh_internal_get_user_pages_fast'
  [A] 'tracepoint __tracepoint_android_vh_pin_user_pages'
  [A] 'tracepoint __tracepoint_android_vh_try_grab_compound_head'

3 Changed variables:

  [C] 'net init_net' was changed at net_namespace.c:47:1:
    CRC (modversions) changed from 0xaff22d13 to 0x59ca894

  [C] 'pid_namespace init_pid_ns' was changed at pid.c:75:1:
    CRC (modversions) changed from 0x31a2d4d4 to 0x1ee0d04c

  [C] 'softnet_data softnet_data' was changed at dev.c:403:1:
    CRC (modversions) changed from 0x3f45ee4 to 0xad33d222

'struct net_device at netdevice.h:1898:1' changed:
  type size hasn't changed
  1 data member insertion:
    'const macsec_ops* macsec_ops', at offset 19328 (in bits) at netdevice.h:2202:1
  there are data member changes:
    11 ('const udp_tunnel_nic_info* udp_tunnel_nic_info' .. 'u64 android_kabi_reserved8') offsets changed (by +64 bits)
  2953 impacted interfaces

'struct phy_device at phy.h:541:1' changed:
  type size changed from 12736 to 12800 (in bits)
  1 data member insertion:
    'const macsec_ops* macsec_ops', at offset 12480 (in bits) at phy.h:647:1
  there are data member changes:
    4 ('u64 android_kabi_reserved1' .. 'u64 android_kabi_reserved4') offsets changed (by +64 bits)
  2953 impacted interfaces

Bug: 226384098
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I128f3003dff88cee9e0dd4041e2f2cc467dac1ee
2022-03-23 19:49:30 +00:00
Victor Shutemov
e5315a20b2 ANDROID: GKI: enable macsec
This is needed for Volvo Cars

Bug: 224999021

Signed-off-by: Victor Shutemov <victor@haleytek.com>
Change-Id: I61fb2388524ba9efa6cd34873d91dd7cc9fe246e
2022-03-23 19:49:23 +00:00
Minchan Kim
7531264e68 ANDROID: Update the ABI symbol list
Update the generic symbol list.

Bug: 218731671
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I8c48b029a1a1c7da39e3611446616815630173ab
2022-03-23 19:49:15 +00:00
Minchan Kim
aea946bdf0 ANDROID: mm: gup: vendor hook in GUP friends
The page pinning causes CMA allocation long latency until the process
held the refcont is scheduled in and then released the refcount, which
introduces CMA allocaiton failure.

To overcome the issue, add vendor hooks to migrate the target page of
GUP out of CMA area.

Bug: 218731671
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I5ebf491531d0bfee96ebee83919f22e34ee1d41b
2022-03-23 19:49:08 +00:00
Tadeusz Struk
0375b0d297 ANDROID: selftests: incfs: Add umount helper function
Bug: 211066171

Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: I3c8eebbce3079292fc85dad8984efe6382f22cac
2022-03-23 08:39:53 -07:00
Tadeusz Struk
5fdeabb1a2 ANDROID: selftests: incfs: skip large_file_test test is not enough free space
Make the large_file_test check if there is at least 3GB of free disk
space and skip the test if there is not. This is to make the tests pass
on a VM with limited disk size, now all functional tests are passing.

TAP version 13
1..26
ok 1 basic_file_ops_test
ok 2 cant_touch_index_test
ok 3 dynamic_files_and_data_test
ok 4 concurrent_reads_and_writes_test
ok 5 attribute_test
ok 6 work_after_remount_test
ok 7 child_procs_waiting_for_data_test
ok 8 multiple_providers_test
ok 9 hash_tree_test
ok 10 read_log_test
ok 11 get_blocks_test
ok 12 get_hash_blocks_test
ok 13 large_file_test
ok 14 mapped_file_test
ok 15 compatibility_test
ok 16 data_block_count_test
ok 17 hash_block_count_test
ok 18 per_uid_read_timeouts_test
ok 19 inotify_test
ok 20 verity_test
ok 21 enable_verity_test
ok 22 mmap_test
ok 23 truncate_test
ok 24 stat_test
ok 25 sysfs_test
Error mounting fs.: File exists
Error mounting fs.: File exists
ok 26 sysfs_rename_test

Bug: 211066171

Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: I2260e2b314429251070d0163c70173f237f86476
2022-03-23 08:39:22 -07:00