Commit Graph

1050428 Commits

Author SHA1 Message Date
David Brazdil
fa6ad0bcb8 ANDROID: KVM: arm64: Add S2MPU kselftest
Add a kselftest which exercises the S2MPU's MPT logic. The functions are
included into a kernel module and exercised in EL1. This is because
testing the EL2 driver itself would require generating DMA traffic and
probing the S2MPU without crashing the system. Instead, the logic is
used on a local FMPT/SMPT and the results are inspected.

Test: run kvm/aarch64/s2mpu kselftest
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: Ib1e572e3247d864e59fad8a4960e38956237ef8c
2022-01-10 18:24:20 +00:00
David Brazdil
ce1b8ebce8 ANDROID: KVM: arm64: Modify S2MPU MPT in 'host_stage2_set_owner'
The 'host_stage2_set_owner' callback indicates that a range of
PA-contiguous pages changed owner. With all devices owned by the host,
the driver sets the protection bits in the corresponding FMPT/SMPT to
either MPT_PROT_RW if owned by the host or MPT_PROT_NONE otherwise.

For each gigabyte region, the implementation will select between 1G and
4K/64K (depending on PAGE_SIZE) mappings and populate the L1ENTRY_ATTR
register or SMPT bitmap, respectivelly.

The driver never dynamically switches between two granularities which
both require a SMPT. This is because the L1ENTRY_ATTR and
L1ENTRY_L2TABLE_ADDR registers would need to be set atomically.

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I9d21df4c615e436285a08720216ac5119e1cfeef
2022-01-10 18:24:20 +00:00
David Brazdil
4bd76c88c5 ANDROID: KVM: arm64: Set up S2MPU Memory Protection Table
S2MPU Second-level Memory Protection Table is a PA-contiguous buffer
containing an array of 2-bit read/write entries at given granularity
for a given gigabyte physical address space region. The size of SMPT
varies per granularity but at the finest 4K granularity it is 64KB
PA-contiguous, aligned to 64KB.

Allocate sufficient number of SMPT buffers for the S2MPU driver assuming
4K granularity for 4K/16K PAGE_SIZE, and 64K granularity for 64K
PAGE_SIZE. We also assume that all S2MPUs share SMPTs for a given
gigabyte region. There are 34 gigabyte regions that can be set by the
driver (GBs 4-33 always block all traffic).

Hyp takes ownership of the memory in s2mpu_init and assigns pointers to
the buffers to L1ENTRY_L2TABLE_ADDR registers on init and power-on
events. The pointers remain static as the driver will only change
granularity between 1G and 4K/64K (depending on PAGE_SIZE).

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: If27436087ebba1dd0a977960d960d5eaff4279fd
2022-01-10 18:24:20 +00:00
David Brazdil
6a2df20712 ANDROID: KVM: arm64: Reprogram S2MPUs in 'host_smc_handler'
Intercept SMCs known to be used by the host to inform EL3 about power
events, either powering SoC blocks on or off.

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I936f7aaecf3ec77ec252f067a3c1571aadba4cdb
2022-01-10 18:24:20 +00:00
David Brazdil
f6b90bb6f5 ANDROID: KVM: arm64: Enable S2MPUs in __pkvm_init_stage2_iommu
Initialize the S2MPU driver in __pkvm_init_stage2_iommu if requested by
the host. The driver sets kvm_iommu_ops and configures all S2MPUs which
are powered on at that point (ie. all S2MPUs on currently supported
devices).

The S2MPU L1ENTRY registers are set to 1G granularity and R/W access.
CTRL0/CTRL1/CFG as set to reasonable defaults, though the code relies on
the reset state blocking all traffic as well.

On fault the S2MPUs are configured to return SLVERR/DECERR (v8/9) to the
master. Interrupts are enabled for all VIDs and trigger an IRQ handler
if EL1 init registered a handler as a result of a DT interrupts entry.

Because the host can configure the SSMTs freely, all permission bits are
configured for all VIDs. For v9 CONTEXT_CFG_VALID_VIDS is set to the
value precomputed at EL1, allocating a context ID to each VID.

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I20e658a77c93fa18a07e388d13a639dc67e600d8
2022-01-10 18:24:20 +00:00
David Brazdil
0ed6ef5469 ANDROID: KVM: arm64: Copy S2MPU configuration to hyp
Create variables in hyp that will hold the DT information about S2MPUs
to use by hyp at runtime. Copy the information from EL1 to EL2.

The EL1 code computes the size of the data and allocates a sufficient
number of pages, which hyp will later take ownership of.

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I45ff22ea2049dd285bfcedbad3390baba9fc59a0
2022-01-10 18:24:19 +00:00
David Brazdil
4a75e1b060 ANDROID: KVM: arm64: Implement IRQ handler for S2MPU faults
The S2MPU can be configured to trigger an interrupt on faults: access
permission (both regular and during page table walks) and if no matching
context ID is found for request's VID (v9 only).

When interrupt information is provided in the S2MPU's DT node, parse the
information and enable an IRQ handler. Later patch will enable the
functionality in the S2MPU.

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I5e26a64fc2f09f96f36a93ea9bc5bf3035a71077
2022-01-10 18:24:19 +00:00
David Brazdil
a74e3b10a1 ANDROID: KVM: arm64: Allocate context IDs for valid VIDs
S2MPU_CONTEXT_CFG_VALID_VID register must be configured on v9,
allocating a context ID in range 0 to S2MPU_NUM_CONTEXT to each valid
VID. For now assume that all 8 VIDs are valid. This will change once
the hypervisor takes control over SSMT configuration as well.

If there are more VIDs than available context IDs, the driver prints
a warning that DMA may be blocked and continues.

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I7a78999b73c4ddf4ff78900a7c91eabe57aad572
2022-01-10 18:24:19 +00:00
David Brazdil
e850485374 ANDROID: KVM: arm64: Read and check S2MPU_VERSION
Read S2MPU_VERSION during driver init and check it against list of
supported versions. The register fields are as follows:
  - MAJOR_ARCH_VER,
  - MINOR_ARCH_VER,
  - REV_ARCH_VER,
  - RTL_VER.
Their exact use is not documented. For now, we mask out RTL_VER and
expect a match on MAJOR_, MINOR_ and REV_ARCH_VER. This may be tweaked
in the future.

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I2fbd20ab78a992c8bdb3574a6d480012260c9ded
2022-01-10 18:24:19 +00:00
David Brazdil
8827315de0 ANDROID: KVM: arm64: Parse S2MPU MMIO region
Start EL1 portion of the S2MPU driver with an init function which
probes the Device tree for nodes compatible with 'google,s2mpu'.
Parse and check the base, size and power domain ID.

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: Ic8b421e20b40b4a9fc5fb268dece00a11e35e3eb
2022-01-10 18:24:19 +00:00
David Brazdil
d907ef4ba5 ANDROID: KVM: arm64: Create empty S2MPU driver
Create a skeleton driver for the S2MPU - an EL1 portion called during
KVM init which will parse the DT and configure the kernel, and an EL2
portion which will program the S2MPUs later at runtime. The code is
behind CONFIG_KVM_S2MPU.

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: Ic6a3460cad69fba673754cc1926a5bac88f1fa17
2022-01-10 18:24:19 +00:00
David Brazdil
f43970daf2 ANDROID: dt-bindings: iommu: Add Google S2MPU
Add DeviceTree bindings for Google S2MPU.

Test: n/a
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I002b5df1cac73766179d73ed56fe4945e8e7c2e6
2022-01-10 18:24:19 +00:00
David Brazdil
57454d3763 ANDROID: KVM: arm64: Add 'host_stage2_adjust_mmio_range' to kvm_iommu_ops
Add a new kvm_iommu_ops hook to the lower-EL instruction/data abort
handler, which allows the IOMMU driver to restrict the region of device
memory that is about to be mapped in the host stage-2.

This can be used by the IOMMU driver to restrict access to the MMIO
registers of the IOMMU itself.

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I58f7b7a78795a3bfc4d77f7128e4fdc1110fde58
2022-01-10 18:24:19 +00:00
David Brazdil
565267794a ANDROID: KVM: arm64: Add 'host_mmio_dabt_handler' to kvm_iommu_ops
Add a new kvm_iommu_ops hook which allows the IOMMU driver to handle
data aborts in unmapped device memory regions. If the abort is handled
by the driver, the global abort handler will not attempt to map in the
page.

For example, this enables the IOMMU driver to virtualize access to
the underlying IOMMU hardware, or to allow access to a subset of the
functionality, eg. performance counters.

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: Ie2e38652f0568c27d30190fcc3879592872863ae
2022-01-10 18:24:18 +00:00
David Brazdil
f51f6b5d26 ANDROID: KVM: arm64: Add 'host_stage2_set_owner' to kvm_iommu_ops
Add a new hook to kvm_iommu_ops that is invoked whenever a range of
pages changes their owner in the host stage2. This is currently limited
to finalize_host_mappings, which changes the owner of EL2-mapped pages
from host to hyp.

The driver is expected to apply corresponding changes in the IOMMU it
controls, so that only the new owner can access the page range.

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: Ic5ca01a56344cd0253bf7b71560f057ba0e54d6b
2022-01-10 18:24:18 +00:00
David Brazdil
ba27273db7 ANDROID: KVM: arm64: Add 'host_smc_handler' to kvm_iommu_ops
IOMMU drivers need to intercept power management SMCs between the host
and EL3. Add a hook to hyp's 'handle_host_smc'.

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: Ief42370ac371f6b3b87a0d46c00acfffece47052
2022-01-10 18:24:18 +00:00
David Brazdil
5158bd95fe ANDROID: KVM: arm64: Introduce IOMMU driver infrastructure
Bootstrap infrastructure for IOMMU drivers by introducing kvm_iommu_ops
struct in EL2 that is populated based on a iommu_driver parameter to
__pkvm_init hypercall and selected in EL1 early init.

An 'init' operation is called in __pkvm_init_finalise, giving the driver
an opportunity to initialize itself in EL2 and create any EL2 mappings
that it will need. 'init' is specifically called before
'finalize_host_mappings' so that:
  (a) pages mapped by the driver change owner to hyp,
  (b) ownership changes in 'finalize_host_mappings' get reflected in
      IOMMU mappings (added in a future patch).

Test: builds, boots
Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: Icd496d193c0bbf811406c3a8d4b94610e2a03197
2022-01-10 18:24:18 +00:00
Park Bumgyu
9e280ea43e ANDROID: sched: export task_rq_lock
Declare task_rq_lock as EXPORT_SYMBOL_GPL needed by vendor module.

Bug: 178340230

Signed-off-by: Park Bumgyu <bumgyu.park@samsung.com>
Change-Id: I4afc2d67bd208b00e6c43590782196cb4ee07937
2022-01-10 17:11:44 +00:00
Choonghoon Park
cabf26b4eb ANDROID: sched: Add vendor hook to select ilb cpu
Add android_rvh_find_new_ilb to select a next ilb cpu for vendors.

Bug: 190228983

Change-Id: Iba1a0cd9cdc22dcf628dd33f8d838fe513a4818f
Signed-off-by: Choonghoon Park <choong.park@samsung.com>
2022-01-10 17:11:39 +00:00
Choonghoon Park
25d620ba79 ANDROID: GKI: sched: add rvh for new cfs task util
A vendor hook is added in post_init_entity_util_avg before
a new cfs task's util is attached to cfs_rq's util so that
vendors can gather and modify se's information to modify
scheduling behavior and DVFS as they want.

trace_android_rvh_new_task_stats is not a proper hook because
it is called after the task's util is attached to cfs_rq's util,
which means updating cfs_rq's sched_avg and DVFS request are done.

Bug: 184219858

Signed-off-by: Choonghoon Park <choong.park@samsung.com>
Change-Id: I2deaa93297f8464895978496c9838cdffaa35b7f
2022-01-10 17:11:30 +00:00
Park Bumgyu
ca6883251a ANDROID: sched: add rvh for rebalance domains
Vendor scheduler may not want to rebalance between domains in some case.
New vendor hook is added for vendor to decide whether rebalance domains.

Bug: 176952463

Change-Id: Ie2edbd4b11679786096dd0170496904ae180583c
Signed-off-by: Park Bumgyu <bumgyu.park@samsung.com>
2022-01-10 17:11:25 +00:00
Gokul krishna Krishnakumar
88b7cf0b5b ANDROID: Add initial QCOM symbol list
Add initial sybol list for QCOM in android/abi_gki_aarch64_qcom.

Bug: 211744078
Change-Id: I0b7c8cf52c8c0fa944ad431865379d101b30a66e
Signed-off-by: Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
2022-01-10 17:10:14 +00:00
Nick Desaulniers
4c62466a00 ANDROID: clang: update to 14.0.1
Bug: 213621148
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Change-Id: Ie4c909bc0748bee2918eef8df2cf1a441da92f8c
2022-01-10 11:54:53 +00:00
Will McVicker
23c5cc8714 ANDROID: GKI: Disable module signing support from gki_defconfig
Device kernels merge gki_defconfig for modules build;
forcing them to sign the modules with no certificates
from the gki build available causing breakage.

GKI module signing support will be enabled via config
fragment; so partner builds don't have to disable support
in their fragments.

Fixes: 9ab6a24225 ("ANDROID: GKI: Add module load time protected symbol lookup")
Bug: 200082547
Test: TreeHugger, local builds
Signed-off-by: Ramji Jiyani <ramjiyani@google.com>
Change-Id: Ia90f0acd57ba9a8795da3f85c2cbe21758f5f4fb
Signed-off-by: Will McVicker <willmcvicker@google.com>
2022-01-07 16:49:45 -08:00
Suren Baghdasaryan
1d50adbe5a ANDROID: Fix "one_thousand" defined but not used warning
Fix the following warning issued when CONFIG_PERF_EVENTS is not
defined:

kernel/sysctl.c:124:12: error: ‘one_thousand’ defined but not used [-Werror=unused-variable]

These definitions in upstream has been changed [1] and therefore
the issue does not exist there.

[1] https://lore.kernel.org/all/20211124220801.ip01WsWPQ%25akpm@linux-foundation.org/

Fixes: 0f047989b0 ("FROMGIT: mm/pagealloc: sysctl: change watermark_scale_factor max limit to 30%")
Bug: 194652782
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I5539a2d0d27a126f7405455a8cf08c23b80d2e0b
2022-01-07 07:22:39 +00:00
Hridya Valsaraju
c6e5bd97f6 ANDROID: GKI: defconfig: Enable DMA-BUF sysfs stats
This patch turns on CONFIG_DMABUF_SYSFS_STATS to enable the DMA-BUF
sysfs statistics.

Bug: 167709539
Change-Id: Idc4cb231edfedcdf672474119238e5d7e545002d
Signed-off-by: Hridya Valsaraju <hridya@google.com>
2022-01-06 23:04:50 +00:00
Andy Shevchenko
de680fdc4b FROMGIT: KVM: arm64: vgic: Replace kernel.h with the necessary inclusions
arm_vgic.h does not require all the stuff that kernel.h provides.
Replace kernel.h inclusion with the list of what is really being used.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20220104151940.55399-1-andriy.shevchenko@linux.intel.com
(cherry picked from commit 6c9eeb5f4a
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Bug: 209777660
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I90713958b02f5d11e925c27716d478744796acf8
2022-01-06 18:24:10 +00:00
Zenghui Yu
90ee768cbc FROMGIT: KVM: arm64: Fix comment typo in kvm_vcpu_finalize_sve()
kvm_arm_init_arch_resources() was renamed to kvm_arm_init_sve() in
commit a3be836df7 ("KVM: arm/arm64: Demote
kvm_arm_init_arch_resources() to just set up SVE"). Fix the function
name in comment of kvm_vcpu_finalize_sve().

Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211230141535.1389-1-yuzenghui@huawei.com
(cherry picked from commit e938eddbeb
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Bug: 209777660
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Ia4dd418253ee40891559a61430583c3c3188f47a
2022-01-06 18:24:10 +00:00
Marc Zyngier
fc13bc019f FROMGIT: KVM: arm64: Rework kvm_pgtable initialisation
Ganapatrao reported that the kvm_pgtable->mmu pointer is more or
less hardcoded to the main S2 mmu structure, while the nested
code needs it to point to other instances (as we have one instance
per nested context).

Rework the initialisation of the kvm_pgtable structure so that
this assumtion doesn't hold true anymore. This requires some
minor changes to the order in which things are initialised
(the mmu->arch pointer being the critical one).

Reported-by: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
Reviewed-by: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211129200150.351436-5-maz@kernel.org
(cherry picked from commit 9d8604b285
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Bug: 209777660
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: If942bf4a01a975a60c37ad8483eafc52185234d5
2022-01-06 18:24:10 +00:00
Marc Zyngier
60bd62a27a FROMGIT: KVM: arm64: vgic: Demote userspace-triggered console prints to kvm_debug()
Running the KVM selftests results in these messages being dumped
in the kernel console:

[  188.051073] kvm [469]: VGIC redist and dist frames overlap
[  188.056820] kvm [469]: VGIC redist and dist frames overlap
[  188.076199] kvm [469]: VGIC redist and dist frames overlap

Being amle to trigger this from userspace is definitely not on,
so demote these warnings to kvm_debug().

Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211216104507.1482017-1-maz@kernel.org
(cherry picked from commit 440523b92b
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Bug: 209777660
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I0c6c94795a86705925dc1c9519bb0dec831b641c
2022-01-06 18:24:09 +00:00
Marc Zyngier
d11273c6b3 FROMGIT: KVM: arm64: vgic-v3: Fix vcpu index comparison
When handling an error at the point where we try and register
all the redistributors, we unregister all the previously
registered frames by counting down from the failing index.

However, the way the code is written relies on that index
being a signed value. Which won't be true once we switch to
an xarray-based vcpu set.

Since this code is pretty awkward the first place, and that the
failure mode is hard to spot, rewrite this loop to iterate
over the vcpus upwards rather than downwards.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211216104526.1482124-1-maz@kernel.org
(cherry picked from commit c95b1d7ca7
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Bug: 209777660
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I9df3874b4a6542e5d20125d436108d8c1235b8e5
2022-01-06 18:24:09 +00:00
Marc Zyngier
79e8cbf51a FROMGIT: KVM: arm64: Drop unused workaround_flags vcpu field
workaround_flags is a leftover from our earlier Spectre-v4 workaround
implementation, and now serves no purpose.

Get rid of the field and the corresponding asm-offset definition.

Fixes: 29e8910a56 ("KVM: arm64: Simplify handling of ARCH_WORKAROUND_2")
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit 142ff9bddb
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Bug: 209777660
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Ie059d34e32f35718abc13b321fbf9f762a5585c1
2022-01-06 18:24:09 +00:00
Hridya Valsaraju
8b7fdc4ca7 ANDROID: GKI: Update virtual_device symbol list
Update symbol list after making the DMA-BUF heap page-pool helper
library built-in.

Bug: 183902174
Change-Id: I855e034942e2cbaf935e855d0db8882ccefb0395
Signed-off-by: Hridya Valsaraju <hridya@google.com>
2022-01-06 10:12:49 -08:00
Hridya Valsaraju
0df2708696 ANDROID: dma-heap: Make the page-pool library built-in
Since vendors might depend on them for their system heap
implementations, make the page-pool library built-in to
freeze its KMI.

Bug: 183902174
Bug: 212210831
Change-Id: If633619ec1f78d0fbd73c43c48b19d98db7807af
Signed-off-by: Hridya Valsaraju <hridya@google.com>
2022-01-06 10:12:49 -08:00
xieliujie
7a2d401ac2 ANDROID: dma-buf: heaps: fix dma-buf heap pool pages stat
this critical region should be protected by pool->mutex.

Bug: 207658347
Fixes: e7dac4c323 ("ANDROID: dma-buf: heaps: Add a shrinker controlled page pool")
Signed-off-by: liuhailong <liuhailong@oppo.com>
Signed-off-by: xieliujie <xieliujie@oppo.com>
Change-Id: I6f129926c96176258a965964c24602fc647db61e
2022-01-06 10:12:49 -08:00
Hridya Valsaraju
c6a639f589 ANDROID: dma-heap: Let system heap report total pool size
This information will be exposed as part of Android Bugreport[1].

[1]:
https://android-review.googlesource.com/q/topic:%22b%252F167709539%22+(status:open%20OR%20status:merged)

Bug: 167709539
Change-Id: I5b810bd18a495fe8e7f4907c047917ba4718796d
Signed-off-by: Hridya Valsaraju <hridya@google.com>
2022-01-06 10:12:49 -08:00
Hridya Valsaraju
32fe36e04d ANDROID: dma-buf: heaps: Add a sysfs file to report total pool size.
In order to help with memory accounting, expose the total pool size of
all DMA-BUF heaps at /sys/kernel/dma_heap/total_pools_kb.

This information will be exposed as part of Android Bugreport[1].

[1]: https://android-review.googlesource.com/q/topic:%22b%252F167709539%22+(status:open%20OR%20status:merged)

Bug: 167709539
Change-Id: I6a1b52517e73103122690f6567f4f295db9ca1ad
Signed-off-by: Hridya Valsaraju <hridya@google.com>
2022-01-06 10:12:49 -08:00
Suren Baghdasaryan
7f612dda44 ANDROID: dma-buf: heaps: fix a warning in dmabuf page pools
dmabuf_page_pool_init_shrinker needs to be static to prevent a warning
when compiling with -Wmissing-prototypes. Change it to be static.

Fixes: e7dac4c323 ("ANDROID: dma-buf: heaps: Add a shrinker controlled page pool")

Bug: 168742043
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I64184cf4062e33c14a60b9c3d505db922f2b9c0b
2022-01-06 10:12:49 -08:00
John Stultz
ef2ab77cc1 ANDROID: dma-buf: system_heap: Add pagepool support to system heap
Utilize the dmabuf pagepool code to speed up allocation
performance.

This is similar to the ION pagepool usage, but tries to
utilize generic code instead of a custom implementation.

Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Liam Mark <lmark@codeaurora.org>
Cc: Chris Goldsworthy <cgoldswo@codeaurora.org>
Cc: Laura Abbott <labbott@kernel.org>
Cc: Brian Starkey <Brian.Starkey@arm.com>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Sandeep Patil <sspatil@google.com>
Cc: Daniel Mentz <danielmentz@google.com>
Cc: Ørjan Eide <orjan.eide@arm.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Ezequiel Garcia <ezequiel@collabora.com>
Cc: Simon Ser <contact@emersion.fr>
Cc: James Jones <jajones@nvidia.com>
Cc: linux-media@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: John Stultz <john.stultz@linaro.org>
Bug: 168742043
Change-Id: I36fce5d350edcff59bf83ab213b687aec8cb9970
---
v2:
* Fix build issue caused by selecting PAGE_POOL w/o NET
  as Reported-by: kernel test robot <lkp@intel.com>
v3:
* Simplify the page zeroing logic a bit by using kmap_atomic
  instead of vmap as suggested by Daniel Mentz
v5:
* Shift away from networking page pool completely to
  dmabuf page pool implementation
2022-01-06 10:12:48 -08:00
John Stultz
cc46bc6803 ANDROID: dma-buf: heaps: Add a shrinker controlled page pool
This patch adds a simple shrinker controlled page pool to the
dmabuf heaps subsystem.

This replaces the use of the networking page_pool, over concerns
that the lack of a shrinker for that implementation may cause
additional low-memory kills

TODO: Take another pass at trying to unify this w/ the ttm pool

Thoughts and feedback would be greatly appreciated!

Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Liam Mark <lmark@codeaurora.org>
Cc: Laura Abbott <labbott@kernel.org>
Cc: Brian Starkey <Brian.Starkey@arm.com>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Sandeep Patil <sspatil@google.com>
Cc: Daniel Mentz <danielmentz@google.com>
Cc: Chris Goldsworthy <cgoldswo@codeaurora.org>
Cc: Ørjan Eide <orjan.eide@arm.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Ezequiel Garcia <ezequiel@collabora.com>
Cc: Simon Ser <contact@emersion.fr>
Cc: James Jones <jajones@nvidia.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: linux-mm@kvack.org
Cc: linux-media@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: John Stultz <john.stultz@linaro.org>
Bug: 168742043
Change-Id: Ic385e27a352d2fbf665ca288fee4f34eea5666d0
2022-01-06 10:12:48 -08:00
Suren Baghdasaryan
d35a883ae5 ANDROID: mm/oom_kill: allow process_mrelease reclaim memory in parallel with exit_mmap
To allow process_mrelease to reap targeted mm in parallel with exit_mmap
mark the victim with MMF_OOM_VICTIM flag.

Bug: 189803002
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I89cf5f8fbeeb18b93a340b9ebe7f200837ebe846
2022-01-06 17:49:48 +00:00
Suren Baghdasaryan
563cf57f78 FROMLIST: mm/oom_kill: allow process_mrelease to run under mmap_lock protection
With exit_mmap holding mmap_write_lock during free_pgtables call,
process_mrelease does not need to elevate mm->mm_users in order to
prevent exit_mmap from destrying pagetables while __oom_reap_task_mm
is walking the VMA tree. The change prevents process_mrelease from
calling the last mmput, which can lead to waiting for IO completion
in exit_aio.

Fixes: 337546e83f ("mm/oom_kill.c: prevent a race between process_mrelease and exit_mmap")
Signed-off-by: Suren Baghdasaryan <surenb@google.com>

Link: https://lore.kernel.org/all/20211124235906.14437-2-surenb@google.com/

Bug: 130172058
Bug: 189803002
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I1e2728e0c477af9cc20e9e0b715ee67dee760618
2022-01-06 17:49:38 +00:00
Suren Baghdasaryan
28358ebf2a FROMLIST: mm: protect free_pgtables with mmap_lock write lock in exit_mmap
oom-reaper and process_mrelease system call should protect against
races with exit_mmap which can destroy page tables while they
walk the VMA tree. oom-reaper protects from that race by setting
MMF_OOM_VICTIM and by relying on exit_mmap to set MMF_OOM_SKIP
before taking and releasing mmap_write_lock. process_mrelease has
to elevate mm->mm_users to prevent such race. Both oom-reaper and
process_mrelease hold mmap_read_lock when walking the VMA tree.
The locking rules and mechanisms could be simpler if exit_mmap takes
mmap_write_lock while executing destructive operations such as
free_pgtables.
Change exit_mmap to hold the mmap_write_lock when calling
free_pgtables. Operations like unmap_vmas() and unlock_range() are not
destructive and could run under mmap_read_lock but for simplicity we
take one mmap_write_lock during almost the entire operation. Note
also that because oom-reaper checks VM_LOCKED flag, unlock_range()
should not be allowed to race with it.
In most cases this lock should be uncontended. Previously, Kirill
reported ~4% regression caused by a similar change [1]. We reran the
same test and although the individual results are quite noisy, the
percentiles show lower regression with 1.6% being the worst case [2].
The change allows oom-reaper and process_mrelease to execute safely
under mmap_read_lock without worries that exit_mmap might destroy page
tables from under them.

[1] https://lore.kernel.org/all/20170725141723.ivukwhddk2voyhuc@node.shutemov.name/
[2] https://lore.kernel.org/all/CAJuCfpGC9-c9P40x7oy=jy5SphMcd0o0G_6U1-+JAziGKG6dGA@mail.gmail.com/

Signed-off-by: Suren Baghdasaryan <surenb@google.com>

Link: https://lore.kernel.org/all/20211124235906.14437-1-surenb@google.com/

Bug: 130172058
Bug: 189803002
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ic87272d09a0b68a1b0e968e8f1a1510fd6fc776a
2022-01-06 17:49:28 +00:00
Lecopzer Chen
9ec6b2ff43 ANDROID: add initial symbol list for mtktv
1. ABI diff by
BUILD_CONFIG=common/build.config.gki.aarch64 build/build_abi.sh -j64

2. symbol added:
Leaf changes summary: 370 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 353 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 17 Added variables
Function symbols changes summary: 0 Removed, 2 Added function symbols not referenced by debug info
Variable symbols changes summary: 0 Removed, 0 Added variable symbol not referenced by debug info

353 Added functions:

  [A] 'function buffer_head* __bread_gfp(block_device*, sector_t, unsigned int, gfp_t)'
  [A] 'function void __brelse(buffer_head*)'
  [A] 'function int __cpufreq_driver_target(cpufreq_policy*, unsigned int, unsigned int)'
  [A] 'function buffer_head* __getblk_gfp(block_device*, sector_t, unsigned int, gfp_t)'
  [A] 'function int __iio_device_register(iio_dev*, module*)'
  [A] 'function void __insert_inode_hash(inode*, unsigned long int)'
  [A] 'function unsigned int __kfifo_in_r(__kfifo*, void*, unsigned int, size_t)'
  [A] 'function unsigned int __kfifo_out_r(__kfifo*, void*, unsigned int, size_t)'
  [A] 'function void __lock_buffer(buffer_head*)'
  [A] 'function int __media_device_register(media_device*, module*)'
  [A] 'function int __mmc_claim_host(mmc_host*, mmc_ctx*, atomic_t*)'
  [A] 'function void __module_put_and_exit(module*, long int)'
  [A] 'function int __platform_register_drivers(platform_driver* const*, unsigned int, module*)'
  [A] 'function regmap* __regmap_init_i2c(i2c_client*, const regmap_config*, lock_class_key*, const char*)'
  [A] 'function void* __symbol_get(const char*)'
  [A] 'function void __symbol_put(const char*)'
  [A] 'function int __trace_bprintk(unsigned long int, const char*, ...)'
  [A] 'function int __trace_bputs(unsigned long int, const char*)'
  [A] 'function int __trace_puts(unsigned long int, const char*, int)'
  [A] 'function void __wait_on_buffer(buffer_head*)'
  [A] 'function unsigned long int _snd_pcm_stream_lock_irqsave(snd_pcm_substream*)'
  [A] 'function int alloc_contig_range(unsigned long int, unsigned long int, unsigned int, gfp_t)'
  [A] 'function file* anon_inode_getfile(const char*, const file_operations*, void*, int)'
  [A] 'function backlight_device* backlight_device_register(const char*, device*, void*, const backlight_ops*, const backlight_properties*)'
  [A] 'function void backlight_device_unregister(backlight_device*)'
  [A] 'function void baswap(bdaddr_t*, const bdaddr_t*)'
  [A] 'function int bitmap_find_free_region(unsigned long int*, unsigned int, int)'
  [A] 'function void bitmap_release_region(unsigned long int*, unsigned int, int)'
  [A] 'function int block_is_partially_uptodate(page*, unsigned long int, unsigned long int)'
  [A] 'function void bt_procfs_cleanup(net*, const char*)'
  [A] 'function int bt_procfs_init(net*, const char*, bt_sock_list*, int (seq_file*, void*)*)'
  [A] 'function void bt_sock_link(bt_sock_list*, sock*)'
  [A] 'function int bt_sock_register(int, const net_proto_family*)'
  [A] 'function void bt_sock_unlink(bt_sock_list*, sock*)'
  [A] 'function void bt_sock_unregister(int)'
  [A] 'function int buffer_migrate_page(address_space*, page*, page*, migrate_mode)'
  [A] 'function void cec_transmit_done_ts(cec_adapter*, u8, u8, u8, u8, u8, ktime_t)'
  [A] 'function device* class_find_device(class*, device*, void*, int (device*, void*)*)'
  [A] 'function void clear_inode(inode*)'
  [A] 'function void clk_bulk_put_all(int, clk_bulk_data*)'
  [A] 'function int clk_hw_set_parent(clk_hw*, clk_hw*)'
  [A] 'function clk* clk_register_composite(device*, const char*, const char* const*, int, clk_hw*, const clk_ops*, clk_hw*, const clk_ops*, clk_hw*, const clk_ops*, unsigned long int)'
  [A] 'function clk* clk_register_divider_table(device*, const char*, const char*, unsigned long int, void*, u8, u8, u8, const clk_div_table*, spinlock_t*)'
  [A] 'function void cpufreq_dbs_governor_exit(cpufreq_policy*)'
  [A] 'function int cpufreq_dbs_governor_init(cpufreq_policy*)'
  [A] 'function void cpufreq_dbs_governor_limits(cpufreq_policy*)'
  [A] 'function int cpufreq_dbs_governor_start(cpufreq_policy*)'
  [A] 'function void cpufreq_dbs_governor_stop(cpufreq_policy*)'
  [A] 'function int cpufreq_register_governor(cpufreq_governor*)'
  [A] 'function int cpufreq_table_index_unsorted(cpufreq_policy*, unsigned int, unsigned int)'
  [A] 'function void cpufreq_unregister_governor(cpufreq_governor*)'
  [A] 'function void cpufreq_update_policy(unsigned int)'
  [A] 'function u32 crc32_be(u32, const unsigned char*, size_t)'
  [A] 'function void create_empty_buffers(page*, unsigned long int, unsigned long int)'
  [A] 'function int crypto_register_alg(crypto_alg*)'
  [A] 'function void crypto_unregister_alg(crypto_alg*)'
  [A] 'function void crypto_unregister_scomp(scomp_alg*)'
  [A] 'function void d_add(dentry*, inode*)'
  [A] 'function dentry* d_add_ci(dentry*, inode*, qstr*)'
  [A] 'function dentry* d_make_root(inode*)'
  [A] 'function dentry* d_obtain_alias(inode*)'
  [A] 'function dentry* d_splice_alias(inode*, dentry*)'
  [A] 'function unsigned int dbs_update(cpufreq_policy*)'
  [A] 'function void debugfs_create_devm_seqfile(device*, const char*, dentry*, int (seq_file*, void*)*)'
  [A] 'function void debugfs_create_regset32(const char*, umode_t, dentry*, debugfs_regset32*)'
  [A] 'function dentry* debugfs_create_symlink(const char*, dentry*, const char*)'
  [A] 'function opp_table* dev_pm_opp_get_opp_table(device*)'
  [A] 'function int dev_pm_opp_init_cpufreq_table(device*, cpufreq_frequency_table**)'
  [A] 'function int dev_pm_opp_of_add_table_indexed(device*, int)'
  [A] 'function int dev_pm_opp_of_cpumask_add_table(const cpumask*)'
  [A] 'function int dev_pm_opp_of_get_sharing_cpus(device*, cpumask*)'
  [A] 'function void dev_pm_opp_put_opp_table(opp_table*)'
  [A] 'function devfreq* devfreq_get_devfreq_by_phandle(device*, const char*, int)'
  [A] 'function int devfreq_remove_governor(devfreq_governor*)'
  [A] 'function unsigned int device_get_child_node_count(device*)'
  [A] 'function fwnode_handle* device_get_next_child_node(device*, fwnode_handle*)'
  [A] 'function int device_match_of_node(device*, void*)'
  [A] 'function regmap* device_node_to_regmap(device_node*)'
  [A] 'function int devm_devfreq_register_notifier(device*, devfreq*, notifier_block*, unsigned int)'
  [A] 'function void devm_devfreq_remove_device(device*, devfreq*)'
  [A] 'function void devm_devfreq_unregister_notifier(device*, devfreq*, notifier_block*, unsigned int)'
  [A] 'function int devm_extcon_register_notifier(device*, extcon_dev*, unsigned int, notifier_block*)'
  [A] 'function gpio_desc* devm_fwnode_gpiod_get_index(device*, fwnode_handle*, const char*, int, gpiod_flags, const char*)'
  [A] 'function gpio_desc* devm_gpiod_get_index_optional(device*, const char*, unsigned int, gpiod_flags)'
  [A] 'function int devm_hwrng_register(device*, hwrng*)'
  [A] 'function int devm_hwspin_lock_unregister(device*, hwspinlock_device*)'
  [A] 'function int devm_led_classdev_register_ext(device*, led_classdev*, led_init_data*)'
  [A] 'function nvmem_device* devm_nvmem_device_get(device*, const char*)'
  [A] 'function phy* devm_of_phy_get_by_index(device*, device_node*, int)'
  [A] 'function pci_host_bridge* devm_pci_alloc_host_bridge(device*, size_t)'
  [A] 'function pwm_device* devm_pwm_get(device*, const char*)'
  [A] 'function int devm_request_pci_bus_resources(device*, list_head*)'
  [A] 'function dma_fence_array* dma_fence_array_create(int, dma_fence**, u64, unsigned int, bool)'
  [A] 'function int dma_supported(device*, u64)'
  [A] 'function void do_exit(long int)'
  [A] 'function int down_timeout(semaphore*, long int)'
  [A] 'function device_driver* driver_find(const char*, bus_type*)'
  [A] 'function void drm_atomic_helper_async_commit(drm_device*, drm_atomic_state*)'
  [A] 'function void drm_atomic_state_default_clear(drm_atomic_state*)'
  [A] 'function void drm_display_mode_from_videomode(const videomode*, drm_display_mode*)'
  [A] 'function int drm_gem_mmap_obj(drm_gem_object*, unsigned long int, vm_area_struct*)'
  [A] 'function drm_display_mode* drm_mode_create(drm_device*)'
  [A] 'function int drm_mode_crtc_set_gamma_size(drm_crtc*, int)'
  [A] 'function drm_property* drm_property_create_signed_range(drm_device*, u32, const char*, int64_t, int64_t)'
  [A] 'function void drm_self_refresh_helper_update_avg_times(drm_atomic_state*, unsigned int, unsigned int)'
  [A] 'function void end_buffer_read_sync(buffer_head*, int)'
  [A] 'function int eth_header(sk_buff*, net_device*, unsigned short int, void*, void*, unsigned int)'
  [A] 'function int eth_header_parse(const sk_buff*, unsigned char*)'
  [A] 'function int follow_pfn(vm_area_struct*, unsigned long int, unsigned long int*)'
  [A] 'function unsigned long int gen_pool_best_fit(unsigned long int*, unsigned long int, unsigned long int, unsigned int, void*, gen_pool*, unsigned long int)'
  [A] 'function void* gen_pool_dma_alloc(gen_pool*, size_t, dma_addr_t*)'
  [A] 'function gen_pool* gen_pool_get(device*, const char*)'
  [A] 'function void gen_pool_set_algo(gen_pool*, genpool_algo_t, void*)'
  [A] 'function phys_addr_t gen_pool_virt_to_phys(gen_pool*, unsigned long int)'
  [A] 'function int generic_error_remove_page(address_space*, page*)'
  [A] 'function dentry* generic_fh_to_dentry(super_block*, fid*, int, int, inode* (super_block*, typedef u64, typedef u32)*)'
  [A] 'function dentry* generic_fh_to_parent(super_block*, fid*, int, int, inode* (super_block*, typedef u64, typedef u32)*)'
  [A] 'function int generic_file_mmap(file*, vm_area_struct*)'
  [A] 'function int generic_file_open(inode*, file*)'
  [A] 'function ssize_t generic_file_read_iter(kiocb*, iov_iter*)'
  [A] 'function ssize_t generic_file_splice_read(file*, loff_t*, pipe_inode_info*, size_t, unsigned int)'
  [A] 'function ssize_t generic_read_dir(file*, char*, size_t, loff_t*)'
  [A] 'function int get_kernel_pages(const kvec*, int, int, page**)'
  [A] 'function long int get_user_pages_locked(unsigned long int, unsigned long int, unsigned int, page**, int*)'
  [A] 'function long int get_user_pages_remote(mm_struct*, unsigned long int, unsigned long int, unsigned int, page**, vm_area_struct**, int*)'
  [A] 'function void gov_update_cpu_data(dbs_data*)'
  [A] 'function int gpiod_cansleep(const gpio_desc*)'
  [A] 'function int gpiod_is_active_low(const gpio_desc*)'
  [A] 'function int i2c_bit_add_numbered_bus(i2c_adapter*)'
  [A] 'function void i2c_clients_command(i2c_adapter*, unsigned int, void*)'
  [A] 'function void ida_destroy(ida*)'
  [A] 'function inode* iget5_locked(super_block*, unsigned long int, int (inode*, void*)*, int (inode*, void*)*, void*)'
  [A] 'function inode* igrab(inode*)'
  [A] 'function void ihold(inode*)'
  [A] 'function int in_egroup_p(kgid_t)'
  [A] 'function void inode_init_once(inode*)'
  [A] 'function void invalidate_bh_lrus()'
  [A] 'function void io_schedule()'
  [A] 'function void* ioremap_cache(phys_addr_t, size_t)'
  [A] 'function void irq_domain_free_irqs_parent(irq_domain*, unsigned int, unsigned int)'
  [A] 'function irq_data* irq_domain_get_irq_data(irq_domain*, unsigned int)'
  [A] 'function irq_desc* irq_to_desc(unsigned int)'
  [A] 'function bool is_bad_inode(inode*)'
  [A] 'function u64 jiffies64_to_nsecs(u64)'
  [A] 'function int kern_path(const char*, unsigned int, path*)'
  [A] 'function void kernel_sigaction(int, __sighandler_t)'
  [A] 'function void kill_block_super(super_block*)'
  [A] 'function void ktime_get_coarse_real_ts64(timespec64*)'
  [A] 'function bool l2cap_is_socket(socket*)'
  [A] 'function led_default_state led_init_default_state_get(fwnode_handle*)'
  [A] 'function nls_table* load_nls(char*)'
  [A] 'function nls_table* load_nls_default()'
  [A] 'function int lzo1x_1_compress(const unsigned char*, size_t, unsigned char*, size_t*, void*)'
  [A] 'function int lzo1x_decompress_safe(const unsigned char*, size_t, unsigned char*, size_t*)'
  [A] 'function void make_bad_inode(inode*)'
  [A] 'function void mark_buffer_dirty(buffer_head*)'
  [A] 'function media_link* media_create_intf_link(media_entity*, media_interface*, u32)'
  [A] 'function int media_create_pad_link(media_entity*, u16, media_entity*, u16, u32)'
  [A] 'function int media_create_pad_links(const media_device*, const u32, media_entity*, const u16, const u32, media_entity*, const u16, u32, const bool)'
  [A] 'function void media_device_cleanup(media_device*)'
  [A] 'function void media_device_init(media_device*)'
  [A] 'function int media_device_register_entity(media_device*, media_entity*)'
  [A] 'function int media_device_register_entity_notify(media_device*, media_entity_notify*)'
  [A] 'function void media_device_unregister(media_device*)'
  [A] 'function void media_device_unregister_entity(media_entity*)'
  [A] 'function media_intf_devnode* media_devnode_create(media_device*, u32, u32, u32, u32)'
  [A] 'function void media_devnode_remove(media_intf_devnode*)'
  [A] 'function media_link* media_entity_find_link(media_pad*, media_pad*)'
  [A] 'function int media_entity_pads_init(media_entity*, u16, media_pad*)'
  [A] 'function int media_get_pad_index(media_entity*, bool, media_pad_signal_type)'
  [A] 'function void mmc_release_host(mmc_host*)'
  [A] 'function void mmc_wait_for_req(mmc_host*, mmc_request*)'
  [A] 'function dentry* mount_bdev(file_system_type*, int, const char*, void*, int (super_block*, void*, int)*)'
  [A] 'function inode* new_inode(super_block*)'
  [A] 'function clk* of_clk_get_from_provider(of_phandle_args*)'
  [A] 'function thermal_cooling_device* of_cpufreq_cooling_register(cpufreq_policy*)'
  [A] 'function device_node* of_find_node_with_property(device_node*, const char*)'
  [A] 'function int of_get_mac_address(device_node*, u8*)'
  [A] 'function int of_irq_parse_and_map_pci(const pci_dev*, u8, u8)'
  [A] 'function int of_pci_get_devfn(device_node*)'
  [A] 'function int of_pci_parse_bus_range(device_node*, resource*)'
  [A] 'function int of_pci_range_parser_init(of_pci_range_parser*, device_node*)'
  [A] 'function of_pci_range* of_pci_range_parser_one(of_pci_range_parser*, of_pci_range*)'
  [A] 'function int of_pci_range_to_resource(of_pci_range*, device_node*, resource*)'
  [A] 'function page* pagecache_get_page(address_space*, unsigned long int, int, gfp_t)'
  [A] 'function void path_put(const path*)'
  [A] 'function void pci_add_resource(list_head*, resource*)'
  [A] 'function void pci_add_resource_offset(list_head*, resource*, resource_size_t)'
  [A] 'function void pci_bus_add_devices(const pci_bus*)'
  [A] 'function void pci_bus_assign_resources(const pci_bus*)'
  [A] 'function void pci_bus_size_bridges(pci_bus*)'
  [A] 'function u8 pci_common_swizzle(pci_dev*, u8*)'
  [A] 'function void pci_free_resource_list(list_head*)'
  [A] 'function int pci_generic_config_read32(pci_bus*, unsigned int, int, int, u32*)'
  [A] 'function int pci_generic_config_write32(pci_bus*, unsigned int, int, int, u32)'
  [A] 'function irq_domain* pci_msi_create_irq_domain(fwnode_handle*, msi_domain_info*, irq_domain*)'
  [A] 'function void pci_msi_mask_irq(irq_data*)'
  [A] 'function void pci_msi_unmask_irq(irq_data*)'
  [A] 'function int pci_remap_iospace(const resource*, phys_addr_t)'
  [A] 'function void pci_remove_root_bus(pci_bus*)'
  [A] 'function int pci_scan_root_bus_bridge(pci_host_bridge*)'
  [A] 'function void pci_stop_root_bus(pci_bus*)'
  [A] 'function void pci_unmap_iospace(resource*)'
  [A] 'function void pcie_bus_configure_settings(pci_bus*)'
  [A] 'function void pinconf_generic_dump_config(pinctrl_dev*, seq_file*, unsigned long int)'
  [A] 'function int pinctrl_count_index_with_args(const device_node*, const char*)'
  [A] 'function int pinctrl_generic_add_group(pinctrl_dev*, const char*, int*, int, void*)'
  [A] 'function int pinctrl_generic_get_group_count(pinctrl_dev*)'
  [A] 'function const char* pinctrl_generic_get_group_name(pinctrl_dev*, unsigned int)'
  [A] 'function int pinctrl_generic_get_group_pins(pinctrl_dev*, unsigned int, const unsigned int**, unsigned int*)'
  [A] 'function int pinctrl_generic_remove_group(pinctrl_dev*, unsigned int)'
  [A] 'function int pinctrl_parse_index_with_args(const device_node*, const char*, int, of_phandle_args*)'
  [A] 'function int pinctrl_register_and_init(pinctrl_desc*, device*, void*, pinctrl_dev**)'
  [A] 'function void pinctrl_unregister(pinctrl_dev*)'
  [A] 'function int pinmux_generic_add_function(pinctrl_dev*, const char*, const char**, const unsigned int, void*)'
  [A] 'function function_desc* pinmux_generic_get_function(pinctrl_dev*, unsigned int)'
  [A] 'function int pinmux_generic_get_function_count(pinctrl_dev*)'
  [A] 'function int pinmux_generic_get_function_groups(pinctrl_dev*, unsigned int, const char* const**, unsigned int* const)'
  [A] 'function const char* pinmux_generic_get_function_name(pinctrl_dev*, unsigned int)'
  [A] 'function int pinmux_generic_remove_function(pinctrl_dev*, unsigned int)'
  [A] 'function void platform_unregister_drivers(platform_driver* const*, unsigned int)'
  [A] 'function proc_dir_entry* proc_create_single_data(const char*, umode_t, proc_dir_entry*, int (seq_file*, void*)*, void*)'
  [A] 'function int pwm_apply_state(pwm_device*, const pwm_state*)'
  [A] 'function void pwm_free(pwm_device*)'
  [A] 'function pwm_device* pwm_request(int, const char*)'
  [A] 'function int pwmchip_add(pwm_chip*)'
  [A] 'function void pwmchip_remove(pwm_chip*)'
  [A] 'function page* read_cache_page(address_space*, unsigned long int, int (void*, page*)*, void*)'
  [A] 'function int register_filesystem(file_system_type*)'
  [A] 'function int regulator_get_voltage(regulator*)'
  [A] 'function int regulator_set_mode(regulator*, unsigned int)'
  [A] 'function int regulator_set_voltage_time(regulator*, int, int)'
  [A] 'function int remove_proc_subtree(const char*, proc_dir_entry*)'
  [A] 'function device* rpmsg_find_device(device*, rpmsg_channel_info*)'
  [A] 'function int rpmsg_sendto(rpmsg_endpoint*, void*, int, u32)'
  [A] 'function void rproc_add_carveout(rproc*, rproc_mem_entry*)'
  [A] 'function rproc_mem_entry* rproc_mem_entry_init(device*, void*, dma_addr_t, size_t, u32, int (rproc*, rproc_mem_entry*)*, int (rproc*, rproc_mem_entry*)*, const char*, ...)'
  [A] 'function rproc_mem_entry* rproc_of_resm_mem_entry_init(device*, u32, size_t, u32, const char*, ...)'
  [A] 'function irqreturn_t rproc_vq_interrupt(rproc*, int)'
  [A] 'function int rtc_add_group(rtc_device*, const attribute_group*)'
  [A] 'function int sb_min_blocksize(super_block*, int)'
  [A] 'function int sb_set_blocksize(super_block*, int)'
  [A] 'function int schedule_hrtimeout(ktime_t*, const hrtimer_mode)'
  [A] 'function void serial8250_do_pm(uart_port*, unsigned int, unsigned int)'
  [A] 'function void serial8250_do_set_termios(uart_port*, ktermios*, ktermios*)'
  [A] 'function unsigned int serial8250_modem_status(uart_8250_port*)'
  [A] 'function int serial8250_register_8250_port(const uart_8250_port*)'
  [A] 'function void serial8250_resume_port(int)'
  [A] 'function unsigned char serial8250_rx_chars(uart_8250_port*, unsigned char)'
  [A] 'function void serial8250_suspend_port(int)'
  [A] 'function void serial8250_tx_chars(uart_8250_port*)'
  [A] 'function void serial8250_unregister_port(int)'
  [A] 'function void set_nlink(inode*, unsigned int)'
  [A] 'function void set_user_nice(task_struct*, long int)'
  [A] 'function snd_card* snd_card_ref(int)'
  [A] 'function int snd_devm_card_new(device*, int, const char*, module*, size_t, snd_card**)'
  [A] 'function int snd_info_get_line(snd_info_buffer*, char*, int)'
  [A] 'function int snd_interval_refine(snd_interval*, const snd_interval*)'
  [A] 'function int snd_pcm_format_set_silence(snd_pcm_format_t, void*, unsigned int)'
  [A] 'function int snd_pcm_hw_rule_add(snd_pcm_runtime*, unsigned int, int, snd_pcm_hw_rule_func_t, void*, int, ...)'
  [A] 'function int snd_pcm_stop(snd_pcm_substream*, snd_pcm_state_t)'
  [A] 'function int snd_pcm_stop_xrun(snd_pcm_substream*)'
  [A] 'function void snd_pcm_stream_unlock_irqrestore(snd_pcm_substream*, unsigned long int)'
  [A] 'function int snd_soc_bytes_info_ext(snd_kcontrol*, snd_ctl_elem_info*)'
  [A] 'function void snd_timer_close(snd_timer_instance*)'
  [A] 'function void snd_timer_instance_free(snd_timer_instance*)'
  [A] 'function snd_timer_instance* snd_timer_instance_new(const char*)'
  [A] 'function int snd_timer_open(snd_timer_instance*, snd_timer_id*, unsigned int)'
  [A] 'function int snd_timer_start(snd_timer_instance*, unsigned int)'
  [A] 'function int snd_timer_stop(snd_timer_instance*)'
  [A] 'function int sock_no_bind(socket*, sockaddr*, int)'
  [A] 'function int sock_no_connect(socket*, sockaddr*, int, int)'
  [A] 'function int sock_no_getname(socket*, sockaddr*, int)'
  [A] 'function int sock_no_recvmsg(socket*, msghdr*, size_t, int)'
  [A] 'function int sock_no_sendmsg(socket*, msghdr*, size_t)'
  [A] 'function spi_device* spi_new_device(spi_controller*, spi_board_info*)'
  [A] 'function ssize_t store_sampling_rate(gov_attr_set*, const char*, size_t)'
  [A] 'function int submit_bh(int, int, buffer_head*)'
  [A] 'function void suspend_set_ops(const platform_suspend_ops*)'
  [A] 'function void symbol_put_addr(void*)'
  [A] 'function int sync_dirty_buffer(buffer_head*)'
  [A] 'function int sync_filesystem(super_block*)'
  [A] 'function int sysfs_merge_group(kobject*, const attribute_group*)'
  [A] 'function void sysfs_unmerge_group(kobject*, const attribute_group*)'
  [A] 'function int trace_array_destroy(trace_array*)'
  [A] 'function trace_array* trace_array_get_by_name(const char*)'
  [A] 'function int trace_array_init_printk(trace_array*)'
  [A] 'function int trace_array_printk(trace_array*, unsigned long int, const char*, ...)'
  [A] 'function void truncate_inode_pages_final(address_space*)'
  [A] 'function unsigned int uart_get_divisor(uart_port*, unsigned int)'
  [A] 'function void unload_nls(nls_table*)'
  [A] 'function void unlock_buffer(buffer_head*)'
  [A] 'function void unlock_new_inode(inode*)'
  [A] 'function void unpin_user_pages(page**, unsigned long int)'
  [A] 'function int unregister_filesystem(file_system_type*)'
  [A] 'function int usb_ep_set_halt(usb_ep*)'
  [A] 'function int usb_gadget_map_request(usb_gadget*, usb_request*, int)'
  [A] 'function void usb_gadget_unmap_request(usb_gadget*, usb_request*, int)'
  [A] 'function usb_dr_mode usb_get_dr_mode(device*)'
  [A] 'function void v4l2_ctrl_auto_cluster(unsigned int, v4l2_ctrl**, u8, bool)'
  [A] 'function int v4l2_ctrl_handler_setup(v4l2_ctrl_handler*)'
  [A] 'function __poll_t v4l2_ctrl_poll(file*, poll_table_struct*)'
  [A] 'function void v4l2_ctrl_request_complete(media_request*, v4l2_ctrl_handler*)'
  [A] 'function int v4l2_ctrl_request_setup(media_request*, v4l2_ctrl_handler*)'
  [A] 'function int v4l2_ctrl_subdev_log_status(v4l2_subdev*)'
  [A] 'function int v4l2_ctrl_subscribe_event(v4l2_fh*, const v4l2_event_subscription*)'
  [A] 'function int v4l2_device_register_subdev(v4l2_device*, v4l2_subdev*)'
  [A] 'function void v4l2_device_unregister_subdev(v4l2_subdev*)'
  [A] 'function void v4l2_event_queue(video_device*, const v4l2_event*)'
  [A] 'function void v4l2_event_queue_fh(v4l2_fh*, const v4l2_event*)'
  [A] 'function int v4l2_event_subscribe(v4l2_fh*, const v4l2_event_subscription*, unsigned int, const v4l2_subscribed_event_ops*)'
  [A] 'function int v4l2_event_unsubscribe(v4l2_fh*, const v4l2_event_subscription*)'
  [A] 'function int v4l2_fh_is_singular(v4l2_fh*)'
  [A] 'function void v4l2_i2c_subdev_init(v4l2_subdev*, i2c_client*, const v4l2_subdev_ops*)'
  [A] 'function void v4l2_m2m_buf_copy_metadata(const vb2_v4l2_buffer*, vb2_v4l2_buffer*, bool)'
  [A] 'function int v4l2_m2m_dqbuf(file*, v4l2_m2m_ctx*, v4l2_buffer*)'
  [A] 'function int v4l2_m2m_ioctl_create_bufs(file*, void*, v4l2_create_buffers*)'
  [A] 'function int v4l2_m2m_ioctl_expbuf(file*, void*, v4l2_exportbuffer*)'
  [A] 'function int v4l2_m2m_ioctl_prepare_buf(file*, void*, v4l2_buffer*)'
  [A] 'function int v4l2_m2m_ioctl_qbuf(file*, void*, v4l2_buffer*)'
  [A] 'function int v4l2_m2m_querybuf(file*, v4l2_m2m_ctx*, v4l2_buffer*)'
  [A] 'function int v4l2_m2m_register_media_controller(v4l2_m2m_dev*, video_device*, int)'
  [A] 'function int v4l2_m2m_reqbufs(file*, v4l2_m2m_ctx*, v4l2_requestbuffers*)'
  [A] 'function void v4l2_m2m_request_queue(media_request*)'
  [A] 'function int v4l2_m2m_streamoff(file*, v4l2_m2m_ctx*, v4l2_buf_type)'
  [A] 'function int v4l2_m2m_streamon(file*, v4l2_m2m_ctx*, v4l2_buf_type)'
  [A] 'function void v4l2_m2m_try_schedule(v4l2_m2m_ctx*)'
  [A] 'function void v4l2_m2m_unregister_media_controller(v4l2_m2m_dev*)'
  [A] 'function void v4l2_spi_subdev_init(v4l2_subdev*, spi_device*, const v4l2_subdev_ops*)'
  [A] 'function int v4l2_src_change_event_subscribe(v4l2_fh*, const v4l2_event_subscription*)'
  [A] 'function void v4l2_subdev_init(v4l2_subdev*, const v4l2_subdev_ops*)'
  [A] 'function void v4l_bound_align_image(u32*, unsigned int, unsigned int, unsigned int, u32*, unsigned int, unsigned int, unsigned int, unsigned int)'
  [A] 'function int vb2_core_dqbuf(vb2_queue*, unsigned int*, void*, bool)'
  [A] 'function int vb2_core_expbuf(vb2_queue*, int*, unsigned int, unsigned int, unsigned int, unsigned int)'
  [A] 'function __poll_t vb2_core_poll(vb2_queue*, file*, poll_table*)'
  [A] 'function int vb2_core_qbuf(vb2_queue*, unsigned int, void*, media_request*)'
  [A] 'function void vb2_core_querybuf(vb2_queue*, unsigned int, void*)'
  [A] 'function int vb2_core_queue_init(vb2_queue*)'
  [A] 'function void vb2_core_queue_release(vb2_queue*)'
  [A] 'function int vb2_core_reqbufs(vb2_queue*, vb2_memory, unsigned int*)'
  [A] 'function int vb2_core_streamoff(vb2_queue*, unsigned int)'
  [A] 'function int vb2_core_streamon(vb2_queue*, unsigned int)'
  [A] 'function int vb2_request_validate(media_request*)'
  [A] 'function loff_t vfs_llseek(file*, loff_t, int)'
  [A] 'function void videomode_from_timing(const display_timing*, videomode*)'
  [A] 'function int vm_iomap_memory(vm_area_struct*, phys_addr_t, unsigned long int)'
  [A] 'function int xhci_add_endpoint(usb_hcd*, usb_device*, usb_host_endpoint*)'
  [A] 'function int xhci_check_bandwidth(usb_hcd*, usb_device*)'
  [A] 'function int xhci_drop_endpoint(usb_hcd*, usb_device*, usb_host_endpoint*)'
  [A] 'function unsigned int xhci_get_endpoint_index(usb_endpoint_descriptor*)'
  [A] 'function xhci_ep_ctx* xhci_get_ep_ctx(xhci_hcd*, xhci_container_ctx*, unsigned int)'
  [A] 'function void xhci_reset_bandwidth(usb_hcd*, usb_device*)'
  [A] 'function void yield()'

17 Added variables:

  [A] 'const clk_ops clk_divider_ops'
  [A] 'const clk_ops clk_gate_ops'
  [A] 'const clk_ops clk_mux_ops'
  [A] 'int console_printk[4]'
  [A] 'const dma_fence_ops dma_fence_array_ops'
  [A] 'const vm_operations_struct drm_gem_cma_vm_ops'
  [A] 'irq_chip dummy_irq_chip'
  [A] 'const fwnode_operations irqchip_fwnode_ops'
  [A] 'int overflowgid'
  [A] 'int overflowuid'
  [A] 'const kernel_param_ops param_ops_short'
  [A] 'const kernel_param_ops param_ops_ushort'
  [A] 'workqueue_struct* pm_wq'
  [A] 'int snd_ecards_limit'
  [A] 'const dev_pm_ops snd_soc_pm_ops'
  [A] 'const uuid_t uuid_null'
  [A] 'const vb2_mem_ops vb2_dma_contig_memops'

2 Added function symbols not referenced by debug info:

  [A] __arm_smccc_hvc
  [A] memchr

Bug: 211722396
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
Change-Id: Ieb488bd9cdacbc71ac7564a1e7dd925da5c0ba30
2022-01-06 16:27:38 +00:00
Quentin Perret
12f8b6f54b FROMGIT: KVM: arm64: pkvm: Unshare guest structs during teardown
Make use of the newly introduced unshare hypercall during guest teardown
to unmap guest-related data structures from the hyp stage-1.

Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211215161232.1480836-15-qperret@google.com
(cherry picked from commit 52b28657eb
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Bug: 209599700
Change-Id: Ic8ec2c74d3e803e4d5f0df37d144d2c2eb0e9ad3
2022-01-06 11:05:20 +00:00
Will Deacon
b45ecf7774 FROMGIT: KVM: arm64: Expose unshare hypercall to the host
Introduce an unshare hypercall which can be used to unmap memory from
the hypervisor stage-1 in nVHE protected mode. This will be useful to
update the EL2 ownership state of pages during guest teardown, and
avoids keeping dangling mappings to unreferenced portions of memory.

Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211215161232.1480836-14-qperret@google.com
(cherry picked from commit b8cc6eb5bd
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Bug: 209599700
Change-Id: I0b2839046914a0fd9a6d0077383d53dc84a8ac3d
2022-01-06 11:05:20 +00:00
Will Deacon
2d57dde147 FROMGIT: KVM: arm64: Implement do_unshare() helper for unsharing memory
Tearing down a previously shared memory region results in the borrower
losing access to the underlying pages and returning them to the "owned"
state in the owner.

Implement a do_unshare() helper, along the same lines as do_share(), to
provide this functionality for the host-to-hyp case.

Reviewed-by: Andrew Walbran <qwandor@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211215161232.1480836-13-qperret@google.com
(cherry picked from commit 376a240f03
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Bug: 209599700
Change-Id: I07aa6194099325c955f48ab608c4b601664419e5
2022-01-06 11:05:20 +00:00
Will Deacon
ba98bc064b FROMGIT: KVM: arm64: Implement __pkvm_host_share_hyp() using do_share()
__pkvm_host_share_hyp() shares memory between the host and the
hypervisor so implement it as an invocation of the new do_share()
mechanism.

Note that double-sharing is no longer permitted (as this allows us to
reduce the number of page-table walks significantly), but is thankfully
no longer relied upon by the host.

Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211215161232.1480836-12-qperret@google.com
(cherry picked from commit 1ee32109fd
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Bug: 209599700
Change-Id: I9f5877b6ea7b9bf735a90492fbca16f485e73110
2022-01-06 11:05:20 +00:00
Will Deacon
2477c5eb2b FROMGIT: KVM: arm64: Implement do_share() helper for sharing memory
By default, protected KVM isolates memory pages so that they are
accessible only to their owner: be it the host kernel, the hypervisor
at EL2 or (in future) the guest. Establishing shared-memory regions
between these components therefore involves a transition for each page
so that the owner can share memory with a borrower under a certain set
of permissions.

Introduce a do_share() helper for safely sharing a memory region between
two components. Currently, only host-to-hyp sharing is implemented, but
the code is easily extended to handle other combinations and the
permission checks for each component are reusable.

Reviewed-by: Andrew Walbran <qwandor@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211215161232.1480836-11-qperret@google.com
(cherry picked from commit e82edcc75c
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Bug: 209599700
Change-Id: I3ee4486ab08faa24015ac608979e3596b27806a2
2022-01-06 11:05:19 +00:00
Will Deacon
32cc9591f0 FROMGIT: KVM: arm64: Introduce wrappers for host and hyp spin lock accessors
In preparation for adding additional locked sections for manipulating
page-tables at EL2, introduce some simple wrappers around the host and
hypervisor locks so that it's a bit easier to read and bit more difficult
to take the wrong lock (or even take them in the wrong order).

Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211215161232.1480836-10-qperret@google.com
(cherry picked from commit 61d99e33e7
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Bug: 209599700
Change-Id: I413e2d7f514db507a1aca9a21f04115e97f72c00
2022-01-06 11:05:19 +00:00