Commit Graph

1052581 Commits

Author SHA1 Message Date
Veerendranath Jakkam
44f32f3f7f UPSTREAM: nl80211: add EHT MCS support
Add support for reporting and calculating EHT bitrates.

Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
Link: https://lore.kernel.org/r/1640163883-12696-7-git-send-email-quic_vjakkam@quicinc.com
Link: https://lore.kernel.org/r/20220214163009.175289-2-johannes@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Bug: 220975804
Change-Id: Idc8fd87e32e7bd84936f29df3e49e57e1efc3b64
(cherry picked from commit cfb14110ac)
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
2022-03-09 08:52:38 -08:00
Jia Ding
263ab78988 UPSTREAM: cfg80211: Add support for EHT 320 MHz channel width
Add 320 MHz support in the channel def and center frequency validation
with compatible check.

Signed-off-by: Jia Ding <quic_jiad@quicinc.com>
Co-authored-by: Karthikeyan Periyasamy <quic_periyasa@quicinc.com>
Signed-off-by: Karthikeyan Periyasamy <quic_periyasa@quicinc.com>
Co-authored-by: Muna Sinada <quic_msinada@quicinc.com>
Signed-off-by: Muna Sinada <quic_msinada@quicinc.com>
Co-authored-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
Link: https://lore.kernel.org/r/1640163883-12696-5-git-send-email-quic_vjakkam@quicinc.com
Link: https://lore.kernel.org/r/20220214163009.175289-1-johannes@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Bug: 220975804
Change-Id: I62a1f7cd17faceea96df4eeb5edf3aa5ef903d2b
(cherry picked from commit 3743bec612)
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
2022-03-09 08:52:38 -08:00
Ilan Peer
2626768c2a UPSTREAM: cfg80211: Add data structures to capture EHT capabilities
And advertise EHT capabilities to user space when supported.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Link: https://lore.kernel.org/r/20220214173004.6fb70658529f.I2413a37c8f7d2d6d638038a3d95360a3fce0114d@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Bug: 220975804
Change-Id: If6ca3026ba618317a1719c62243c6710c16b8344
(cherry picked from commit 5cd5a8a3e2)
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
2022-03-09 08:52:38 -08:00
Mordechay Goodstein
1b0f13df70 UPSTREAM: ieee80211: add EHT 1K aggregation definitions
We add the fields for parsing extended ADDBA request/respond,
and new max 1K aggregation for limit ADDBA request/respond.

Adjust drivers to use the proper macro, IEEE80211_MAX_AMPDU_BUF ->
IEEE80211_MAX_AMPDU_BUF_HE.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Link: https://lore.kernel.org/r/20220214173004.b8b447ce95b7.I0ee2554c94e89abc7a752b0f7cc7fd79c273efea@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Bug: 220975804
Change-Id: I9fdb0e3900de9b605bacf96c78b3985661679fca
(cherry picked from commit 2a2c86f15e)
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
2022-03-09 08:52:38 -08:00
Ilan Peer
902345aabc UPSTREAM: ieee80211: Add EHT (802.11be) definitions
Based on Draft P802.11be_D1.4.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Link: https://lore.kernel.org/r/20220214173004.928e23cacb2b.Id30a3ef2844b296efbd5486fe1da9ca36a95c5cf@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Bug: 220975804
Change-Id: I83860d9e8f46e785e3c0612f4876b519440bc2a9
(cherry picked from commit cbc1ca0a9d)
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
2022-03-09 08:52:38 -08:00
Johannes Berg
3dcf9eb37a UPSTREAM: mac80211_hwsim: check TX and STA bandwidth
Add checks to hwsim to validate that neither TX nor any
station's configured bandwidth can exceed the channel
(context) configuration previously requested.

Link: https://lore.kernel.org/r/20220214173004.9fd154d2c3c2.Ia0cd152357a373149bab017d479ab7d5ded289c0@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Bug: 220975804
Change-Id: I6ea0a0974736aa9e367cd6f90d2b05f53cb8298c
(cherry picked from commit 585625c955)
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
2022-03-09 08:52:37 -08:00
Johannes Berg
d0026ae78f UPSTREAM: nl80211: accept only HE capability elements with valid size
The kernel (driver code) should be able to assume that a station's
HE capabilities are not badly sized, so reject them if they are.

Link: https://lore.kernel.org/r/20220214172921.80b710d45cb7.Id57ce32f9538a40e36c620fabedbd2c73346ef56@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Bug: 220975804
Change-Id: I7043f88e1404c0ffc8f1989c13d240b5dcb540c8
(cherry picked from commit a3a20feb32)
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
2022-03-09 08:52:37 -08:00
Johannes Berg
1afe8a5aa0 UPSTREAM: ieee80211: add helper to check HE capability element size
This element has a very dynamic structure, create a small helper
function to validate its size. We're currently checking it in
mac80211 in a conversion function, but that's actually slightly
buggy.

Link: https://lore.kernel.org/r/20220214172920.750bee9eaf37.Ie18359bd38143b7dc949078f10752413e6d36854@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Bug: 220975804
Change-Id: I68ca6afb834d20ab994f0056f4d6973f01767f69
(cherry picked from commit d61f4274da)
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
2022-03-09 08:52:37 -08:00
Avraham Stern
4c4e96fcb0 UPSTREAM: cfg80211: don't add non transmitted BSS to 6GHz scanned channels
When adding 6GHz channels to scan request based on reported
co-located APs, don't add channels that have only APs with
"non-transmitted" BSSes if they only match the wildcard SSID since
they will be found by probing the "transmitted" BSS.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220202104617.f6ddf099f934.I231e55885d3644f292d00dfe0f42653269f2559e@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Bug: 220975804
Change-Id: Id198660ab8c3f01f9b66ad183a3ffd372709d60c
(cherry picked from commit 5666ee154f)
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
2022-03-09 08:52:37 -08:00
Liam Mark
150c882a3d FROMLIST: iommu/iova: Add a best-fit algorithm
Using the best-fit algorithm, instead of the first-fit
algorithm, may reduce fragmentation when allocating
IOVAs.

Bug: 190519428
Change-Id: I2703bde59256b104015aed774b294c421889a40c
Link: https://lore.kernel.org/r/1581721602-17010-1-git-send-email-isaacm@codeaurora.org
Signed-off-by: Liam Mark <lmark@codeaurora.org>
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
Signed-off-by: Georgi Djakov <quic_c_gdjako@quicinc.com>
2022-03-09 08:52:37 -08:00
Georgi Djakov
989b762eb1 FROMLIST: iommu/iova: Add support for IOVA max alignment tuning
IOVAs are aligned to the smallest PAGE_SIZE order, where the requested
IOVA can fit. But this might not work for all use-cases. It can cause
IOVA fragmentation in some multimedia and 8K video use-cases that may
require larger buffers to be allocated and mapped.

When the above allocation pattern is used with the current alignment
scheme, the IOVA space could be quickly exhausted for 32bit devices.

In order to get better IOVA space utilization and reduce fragmentation,
a new kernel command line parameter is introduced to make the alignment
limit configurable by the user during boot.

Bug: 190519428
Change-Id: I0c8e72370fc3266a5a242837d82aae4f9831aef3
Link: https://lore.kernel.org/r/1634148667-409263-1-git-send-email-quic_c_gdjako@quicinc.com/
Signed-off-by: Georgi Djakov <quic_c_gdjako@quicinc.com>
2022-03-09 08:52:37 -08:00
Ali Pouladi
6215ed4f5f FROMGIT: rtc: pl031: fix rtc features null pointer dereference
When there is no interrupt line, rtc alarm feature is disabled.

The clearing of the alarm feature bit was being done prior to allocations
of ldata->rtc device, resulting in a null pointer dereference.

Clear RTC_FEATURE_ALARM after the rtc device is allocated.

Fixes: d9b0dd54a1 ("rtc: pl031: use RTC_FEATURE_ALARM")
Cc: stable@vger.kernel.org
Signed-off-by: Ali Pouladi <quic_apouladi@quicinc.com>
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20220225161924.274141-1-quic_eberman@quicinc.com
(cherry picked from commit 77b0eea1508d116b67753bdaf9378a2e30b815a9
 https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git
 rtc-next)

Bug: 223381022
Change-Id: Ie48a3ad9708466462331e07334de94f1cf6d4074
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
2022-03-09 16:22:30 +00:00
Tadeusz Struk
097c689d48 Revert "ANDROID: incremental-fs: fix mount_fs issue"
This reverts three increment-fs commits:
d5faa13b59
10412e10c6
7ad88c9349

This is to fix the incrementalinstall test.
Can now install the same apk twice, and repeated installs are stable.

Bug: 217661925
Bug: 219731048
Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: Ia8488d728218881ed17e4d68cab21b0b152e3ca4
2022-03-08 17:30:03 -08:00
Quentin Perret
a0662e559d ANDROID: KVM: arm64: Flag pages needing poisoning in hyp_vmemmap
During teardown, we currently walk the guest stage-2 page-table and
annotate all of its pages as 'pending poisoning' in the host stage-2.
Sadly, this requires a host stage-2 walk for every guest page, which is
rather inefficient and can lead to a long non-preemptible amount of time
spent at EL2. This gets particularly bad with IOMMUs as, in its current
form, the host stage-2 annotation triggers IOMMU updates.

To avoid the host stage-2 walks, let's annotate the pages pending
poisoning using a flag in the hyp_vmemmap instead.

Bug: 219180169
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: I8894bd8e0b10ea8817763479412b540c0291e8f5
2022-03-07 11:22:03 +00:00
Quentin Perret
ba565fd777 ANDROID: KVM: arm64: Add flags to struct hyp_page
Add a 'flags' field to struct hyp_page, and reduce the size of the order
field to u8 to avoid growing the struct size.

Bug: 219180169
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: If629935bb6fa7d832c595685083f7985cfcfa221
2022-03-07 11:21:58 +00:00
Jason Wang
eabae32b80 UPSTREAM: virtio_console: validate max_nr_ports before trying to use it
We calculate nr_ports based on the max_nr_ports:

nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2;

If the device advertises a large max_nr_ports, we will end up with a
integer overflow. Fixing this by validating the max_nr_ports and fail
the probe for invalid max_nr_ports in this case.

Cc: Amit Shah <amit@kernel.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20211019070152.8236-3-jasowang@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 28962ec595)
Bug: 196772804
Signed-off-by: Keir Fraser <keirf@google.com>
Change-Id: Idb5462a1268d2bde5f867f5455da0957ca68035a
2022-03-07 11:14:04 +00:00
Jason Wang
03094c3abe UPSTREAM: virtio-blk: validate num_queues during probe
If an untrusted device neogitates BLK_F_MQ but advertises a zero
num_queues, the driver may end up trying to allocating zero size
buffers where ZERO_SIZE_PTR is returned which may pass the checking
against the NULL. This will lead unexpected results.

Fixing this by failing the probe in this case.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20211019070152.8236-2-jasowang@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit 6ae6ff6f6e)
Bug: 196772804
Signed-off-by: Keir Fraser <keirf@google.com>
Change-Id: I8a4dbd80bdf8e7d41013e43d069b04af9c35e200
2022-03-07 11:14:04 +00:00
Will Deacon
e085ccb3db ANDROID: KVM: arm64: Relax SMCCC version check during FF-A proxy init
Although FF-A claims to require version v1.2 of SMCCC, in reality the
current set of calls work just fine with v1.1 and some devices ship with
EL3 firmware that advertises this configuration.

Allow pKVM to proxy FF-A calls for these devices by relaxing our SMCCC
version check to permit SMCCC v1.1+

Reported-by: Alan Stokes <alanstokes@google.com>
Bug: 222663556
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I41e9ff35f169df3609acee7bbc67999c1d11c9d1
2022-03-04 17:27:05 +00:00
Stephen Dickey
4345c3db84 ANDROID: sched: update is_cpu_allowed tracehook
Currently, the trace hook for is_cpu_allowed only executes if the
cpu is not a kthread. Modules need to be able to reject cpus
regardless of whether the task is a kthread or not. Modules also
need to have the flexibility to execute, or not, the remainder of
is_cpu_allowed.

Move the tracepoint for is_cpu_allowed so that it is invoked
regardless of task's kthread status, but do not interfere with
per-cpu-kthread cpu assignment.

Bug: 222550772
Change-Id: Ide48a82a33129448bb22be28814267b0b76535a2
Signed-off-by: Stephen Dickey <quic_dickey@quicinc.com>
2022-03-04 03:49:45 +00:00
Prasad Sodagudi
16327a1367 ANDROID: tracing: fix register tracing spam on memcpy
Disable register read/write tracing for memcpy and memset
APIs to avoid flood of read/write trace events.

Bug: 202309221
Fixes: 4373261be0 ("ANDROID: tracing: Add generic flag for register tracing disable")
Change-Id: Ic860ee3a86b4664f3c5edd79a9c432dede87733e
Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
Signed-off-by: Vamsi Krishna Lanka <quic_vamslank@quicinc.com>
2022-03-03 23:52:34 +00:00
Chris Goldsworthy
97c18633aa ANDROID: dma-direct: Document disable_dma32
Document the functionality of disable_dma32 as introduced in commit
c3c2bb34ac ("ANDROID: arm64/mm: Add command line option to make
ZONE_DMA32 empty").

Bug: 199917449
Signed-off-by: Chris Goldsworthy <quic_cgoldswo@quicinc.com>
Change-Id: I32ab2969f59fcc49e9ac49e7e6b545f816d120f9
2022-03-03 01:02:20 +00:00
Chris Goldsworthy
4632fda82b ANDROID: dma-direct: Make DMA32 disablement work for CONFIG_NUMA
zone_dma32_is_empty() currently lacks the proper validation to ensure
that the NUMA node ID it receives as an argument is valid. This has no
effect on kernels with CONFIG_NUMA=n as NODE_DATA() will return the
same pglist_data on these devices, but on kernels with CONFIG_NUMA=y,
this is not the case, and the node passed to NODE_DATA must be
validated.

Rather than trying to find the node containing ZONE_DMA32, replace
calls of zone_dma32_is_empty() with zone_dma32_are_empty() (which
iterates over all nodes and returns false if one of the nodes holds
DMA32 and it is non-empty).

Bug: 199917449
Fixes: c3c2bb34ac ("ANDROID: arm64/mm: Add command line option to make ZONE_DMA32 empty")
Signed-off-by: Chris Goldsworthy <quic_cgoldswo@quicinc.com>
Change-Id: I850fb9213b71a1ef29106728bfda0cc6de46fdbb
2022-03-03 01:02:07 +00:00
John Stultz
84915dbcbe UPSTREAM: dma-buf: system_heap: Avoid warning on mid-order allocations
When trying to do mid-order allocations, set __GFP_NOWARN to
avoid warning messages if the allocation fails, as we will
still fall back to single page allocatitions in that case.
This is the similar to what we already do for large order
allocations.

Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Christian Koenig <christian.koenig@amd.com>
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: Simon Ser <contact@emersion.fr>
Cc: James Jones <jajones@nvidia.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: linux-media@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: John Stultz <john.stultz@linaro.org>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210909023741.2592429-1-john.stultz@linaro.org

Bug: 221895941
(cherry picked from commit 5ad2d11fea)
Change-Id: Id3078c3ad22f909dfeb6385aacc9df835240c055
Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
2022-03-02 23:36:49 +00:00
Connor O'Brien
b25a6a78d4 FROMGIT: bpf: Add config to allow loading modules with BTF mismatches
BTF mismatch can occur for a separately-built module even when the ABI is
otherwise compatible and nothing else would prevent successfully loading.

Add a new Kconfig to control how mismatches are handled. By default, preserve
the current behavior of refusing to load the module. If MODULE_ALLOW_BTF_MISMATCH
is enabled, load the module but ignore its BTF information.

Suggested-by: Yonghong Song <yhs@fb.com>
Suggested-by: Michal Suchánek <msuchanek@suse.de>
Signed-off-by: Connor O'Brien <connoro@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/CAADnVQJ+OVPnBz8z3vNu8gKXX42jCUqfuvhWAyCQDu8N_yqqwQ@mail.gmail.com
Link: https: //lore.kernel.org/bpf/20220223012814.1898677-1-connoro@google.com
(cherry picked from commit 5e214f2e43
 git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master)
Bug: 218515241
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: Idabf7f5e38cb58da55faeaafae56dee7262a6886
2022-03-01 21:39:55 +00:00
Peter Zijlstra
42da9cb956 UPSTREAM: sched: Fix yet more sched_fork() races
Where commit 4ef0c5c6b5 ("kernel/sched: Fix sched_fork() access an
invalid sched_task_group") fixed a fork race vs cgroup, it opened up a
race vs syscalls by not placing the task on the runqueue before it
gets exposed through the pidhash.

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

Change-Id: I4d34311eac28b23ee32e9308a21c66afe8fa8a3b
Fixes: 4ef0c5c6b5 ("kernel/sched: Fix sched_fork() access an invalid sched_task_group")
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Tested-by: Zhang Qiao <zhangqiao22@huawei.com>
Tested-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Link: https://lkml.kernel.org/r/YgoeCbwj5mbCR0qA@hirez.programming.kicks-ass.net
BUG: 221850698
(cherry picked from commit b1e8206582)
Signed-off-by: Ashay Jaiswal <quic_ashayj@quicinc.com>
2022-03-01 21:35:25 +00:00
Tadeusz Struk
8ab19855fc UPSTREAM: sched/fair: Fix fault in reweight_entity
Syzbot found a GPF in reweight_entity. This has been bisected to
commit 4ef0c5c6b5 ("kernel/sched: Fix sched_fork() access an invalid
sched_task_group")

There is a race between sched_post_fork() and setpriority(PRIO_PGRP)
within a thread group that causes a null-ptr-deref in
reweight_entity() in CFS. The scenario is that the main process spawns
number of new threads, which then call setpriority(PRIO_PGRP, 0, -20),
wait, and exit.  For each of the new threads the copy_process() gets
invoked, which adds the new task_struct and calls sched_post_fork()
for it.

In the above scenario there is a possibility that
setpriority(PRIO_PGRP) and set_one_prio() will be called for a thread
in the group that is just being created by copy_process(), and for
which the sched_post_fork() has not been executed yet. This will
trigger a null pointer dereference in reweight_entity(), as it will
try to access the run queue pointer, which hasn't been set.

Before the mentioned change the cfs_rq pointer for the task  has been
set in sched_fork(), which is called much earlier in copy_process(),
before the new task is added to the thread_group.  Now it is done in
the sched_post_fork(), which is called after that.  To fix the issue
the remove the update_load param from the update_load param() function
and call reweight_task() only if the task flag doesn't have the
TASK_NEW flag set.

Change-Id: I22d5b9d0b06cd85f0f02446b1e8a2389935cffa8
Fixes: 4ef0c5c6b5 ("kernel/sched: Fix sched_fork() access an invalid sched_task_group")
Reported-by: syzbot+af7a719bc92395ee41b3@syzkaller.appspotmail.com
Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20220203161846.1160750-1-tadeusz.struk@linaro.org
BUG: 221850698
(cherry picked from commit 13765de814)
Signed-off-by: Ashay Jaiswal <quic_ashayj@quicinc.com>
2022-03-01 21:35:17 +00:00
Jeevan Shriram
f3eb1ea20f ANDROID: Update QCOM symbol list
Update QCOM symbol list in android/abi_gki_aarch64_qcom with following
symbols.

powercap_register_control_type
powercap_register_zone
powercap_unregister_control_type
powercap_unregister_zone

Bug: 220884335
Change-Id: I986905c8d6263589294e4eb12796c219305c7641
Signed-off-by: Jeevan Shriram <quic_jshriram@quicinc.com>
Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
2022-03-01 08:22:07 -08:00
Manaf Meethalavalappu Pallikunhi
7300e71355 ANDROID: gki_defconfig: Enable powercap framework
It enables the power capping sysfs interface for
different power zone devices.

Bug: 220884335
Change-Id: I11bc3efe06d2a02dcc602d223d3e6757088ca771
Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
2022-03-01 08:21:57 -08:00
Will Deacon
3b0c9ad7c7 ANDROID: KVM: arm64: Ignore length of 0 in kvm_flush_dcache_to_poc()
kvm_flush_dcache_to_poc() converts its (start,len) parameters into
(start,end) parameters for dcache_clean_inval_poc(). This mostly works
out except for the case when 'len == 0', where dcache_clean_inval_poc()
will still issue cache maintenance for the cache line containing 'start'.
If 'start' is not mapped, then this can generate an unexpected fault.

Don't call into dcache_clean_inval_poc() from kvm_flush_dcache_to_poc()
if the supplied length is 0.

Reported-by: John Stultz <john.stultz@linaro.org>
Bug: 196204410
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Idae2b22289398e941938821d1d3b3a5a1da3fd8f
2022-03-01 10:33:51 +00:00
Suren Baghdasaryan
f03e0cb77b FROMGIT: mm: count time in drain_all_pages during direct reclaim as memory pressure
When page allocation in direct reclaim path fails, the system will make
one attempt to shrink per-cpu page lists and free pages from high alloc
reserves.  Draining per-cpu pages into buddy allocator can be a very slow
operation because it's done using workqueues and the task in direct
reclaim waits for all of them to finish before proceeding.  Currently this
time is not accounted as psi memory stall.

While testing mobile devices under extreme memory pressure, when
allocations are failing during direct reclaim, we notices that psi events
which would be expected in such conditions were not triggered.  After
profiling these cases it was determined that the reason for missing psi
events was that a big chunk of time spent in direct reclaim is not
accounted as memory stall, therefore psi would not reach the levels at
which an event is generated.  Further investigation revealed that the bulk
of that unaccounted time was spent inside drain_all_pages call.

A typical captured case when drain_all_pages path gets activated:

__alloc_pages_slowpath  took 44.644.613ns
    __perform_reclaim   took    751.668ns (1.7%)
    drain_all_pages     took 43.887.167ns (98.3%)

PSI in this case records the time spent in __perform_reclaim but ignores
drain_all_pages, IOW it misses 98.3% of the time spent in
__alloc_pages_slowpath.

Annotate __alloc_pages_direct_reclaim in its entirety so that delays from
handling page allocation failure in the direct reclaim path are accounted
as memory stall.

Link: https://lkml.kernel.org/r/20220223194812.1299646-1-surenb@google.com
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Reported-by: Tim Murray <timmurray@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roman Gushchin <guro@fb.com>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit d4f448732857375eb3dc422225a61e64f8257cb1
https://github.com/hnaz/linux-mm.git master)

Bug: 205182133
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia3a4138f8d5e8ce612bd5c371cfcc0f21e1ebc42
2022-02-28 18:49:10 +00:00
Will Deacon
48870890a3 ANDROID: gki_defconfig: Ensure KVM is configured in "protected" mode
In order to support the Protected KVM (pKVM) development effort, ensure
that the GKI kernel initialises KVM in "protected" mode when booted at
EL2, even if the underlying CPU hardware supports VHE.

This has no impact on platforms entering the kernel at EL1.

Cc: David Brazdil <dbrazdil@google.com>
Cc: Marc Zyngier <mzyngier@google.com>
Cc: Alistair Delva <adelva@google.com>
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: Id84d0b0d08706658d1fc080c09ad8ee5b51ed517
2022-02-28 10:27:51 +00:00
Giuliano Procida
87dcc48027 ANDROID: GKI: remove TIDY_ABI=1 from build configuration
ABI XML is tidied unconditionality from Android 13.

Bug: 221390852
Change-Id: If2d6ad724450d8affbf302f449e408ae2b0d3b2a
Signed-off-by: Giuliano Procida <gprocida@google.com>
2022-02-25 21:11:22 +00:00
Lecopzer Chen
5a379c470b ANDROID: Update mtktv symbol list
Update mtktv symbol list from Feb. main trunk

Leaf changes summary: 43 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 43 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

43 Added functions:

  [A] 'function void __cfg80211_radar_event(wiphy*, cfg80211_chan_def*, bool, gfp_t)'
  [A] 'function int __hwspin_trylock(hwspinlock*, int, unsigned long int*)'
  [A] 'function int __kfifo_to_user(__kfifo*, void*, unsigned long int, unsigned int*)'
  [A] 'function void __napi_schedule_irqoff(napi_struct*)'
  [A] 'function int alg_test(const char*, const char*, u32, u32)'
  [A] 'function void cfg80211_assoc_timeout(net_device*, cfg80211_bss*)'
  [A] 'function void cfg80211_cac_event(net_device*, const cfg80211_chan_def*, nl80211_radar_event, gfp_t)'
  [A] 'function unsigned int cfg80211_classify8021d(sk_buff*, cfg80211_qos_map*)'
  [A] 'function void cfg80211_cqm_rssi_notify(net_device*, nl80211_cqm_rssi_threshold_event, s32, gfp_t)'
  [A] 'function void cfg80211_cqm_txe_notify(net_device*, const u8*, u32, u32, u32, gfp_t)'
  [A] 'function void cfg80211_ft_event(net_device*, cfg80211_ft_event_params*)'
  [A] 'function void cfg80211_pmksa_candidate_notify(net_device*, int, const u8*, bool, gfp_t)'
  [A] 'function void cfg80211_rx_assoc_resp(net_device*, cfg80211_bss*, const u8*, size_t, int, const u8*, size_t)'
  [A] 'function void cfg80211_rx_mlme_mgmt(net_device*, const u8*, size_t)'
  [A] 'function void cfg80211_tdls_oper_request(net_device*, const u8*, nl80211_tdls_operation, u16, gfp_t)'
  [A] 'function void cfg80211_tx_mlme_mgmt(net_device*, const u8*, size_t, bool)'
  [A] 'function unsigned int cpufreq_quick_get_max(unsigned int)'
  [A] 'function bool dev_valid_name(const char*)'
  [A] 'function int dma_heap_bufferfd_alloc(dma_heap*, size_t, unsigned int, unsigned int)'
  [A] 'function gpio_chip* gpiochip_find(void*, int (gpio_chip*, void*)*)'
  [A] 'function int hwspin_lock_get_id(hwspinlock*)'
  [A] 'function hwspinlock* hwspin_lock_request()'
  [A] 'function bool ieee80211_operating_class_to_band(u8, nl80211_band*)'
  [A] 'function iio_dev* iio_device_alloc(device*, int)'
  [A] 'function void iio_device_free(iio_dev*)'
  [A] 'function void napi_gro_flush(napi_struct*, bool)'
  [A] 'function void proc_set_user(proc_dir_entry*, kuid_t, kgid_t)'
  [A] 'function int rtc_set_alarm(rtc_device*, rtc_wkalrm*)'
  [A] 'function int sg_nents(scatterlist*)'
  [A] 'function void* skb_pull_rcsum(sk_buff*, unsigned int)'
  [A] 'function thermal_zone_device* thermal_zone_get_zone_by_name(const char*)'
  [A] 'function int usb_anchor_empty(usb_anchor*)'
  [A] 'function int usb_interrupt_msg(usb_device*, unsigned int, void*, int, int*, int)'
  [A] 'function void usb_kill_urb(urb*)'
  [A] 'function void usb_reset_endpoint(usb_device*, unsigned int)'
  [A] 'function int usb_string(usb_device*, int, char*, size_t)'
  [A] 'function int vsprintf(char*, const char*, va_list)'
  [A] 'function void wireless_send_event(net_device*, unsigned int, iwreq_data*, const char*)'
  [A] 'function int zlib_deflate(z_streamp, int)'
  [A] 'function int zlib_deflateInit2(z_streamp, int, int, int, int, int)'
  [A] 'function int zlib_deflateReset(z_streamp)'
  [A] 'function int zlib_deflate_workspacesize(int, int)'
  [A] 'function int zlib_inflate_workspacesize()'

Bug: 220996488
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
Change-Id: I700546ab080b9ee907c358b3feb7a56c76520e54
Signed-off-by: Giuliano Procida <gprocida@google.com>
2022-02-25 16:20:48 +00:00
Fuad Tabba
29e2f13805 ANDROID: KVM: arm64: get_shadow_vcpu()'s vcpu_idx should be unsigned
Bug: 216808671
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: Ib6a1dfebfa21e14fbb098ef8c4e21f72ef701458
2022-02-25 15:15:55 +00:00
Fuad Tabba
5897711b74 ANDROID: KVM: arm64: Do not use kvm.created_vcpus to track the number of pinned vcpus
Do not use variable to reflect something it wasn't intended to reflect, i.e.,
number of created vcpus vs number of vcpus pinned so far.

Consolidate pinning and error handling to the same level to make
code more readable.

Ensure that the donated pgd is big enough for all vcpus.

Bug: 220830416
Bug: 216808671
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: Ibf41a93bb1175e59b3ab82d2f735f25505d2892a
2022-02-25 15:15:49 +00:00
Fuad Tabba
7ab22b914d ANDROID: KVM: arm64: Change variable names to avoid confusing size and count
Change the variable names to avoid confusion between total memory
area size or just the number of pages.

Use host_kvm.vtcr to make future refactoring easier.

Simplifies future fixes of the bug below.

Bug: 216808671
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: Ica0a0dfcf839dae0625a26a2095e56212385bbe7
2022-02-25 15:15:40 +00:00
Fuad Tabba
0e6b940fce ANDROID: KVM: arm64: Do not pass host struct pointers to pkvm_vcpu_put()
This function only works for loaded vcpus and no more information
is needed by hyp. This removes the need to access potentially
unsafe host memory.

Bug: 220830416
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: I09cb49b06e541bba09e91ce5885b963b88a3c315
2022-02-25 15:15:32 +00:00
Fuad Tabba
6733943e55 ANDROID: KVM: arm64: Do not pass host struct pointers to pkvm_vcpu_sync_state()
This function only works for loaded vcpus and no more information
is needed by hyp. This removes the need to access potentially
unsafe host memory.

Bug: 220830416
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: Id705e9d8f1d147d474cb81af4ce974bbe45f3614
2022-02-25 15:15:23 +00:00
Fuad Tabba
13a11f2073 ANDROID: KVM: arm64: Refactor __sync_vcpu_state()
Split it into two functions, sync/flush, which correspond to the
direction the data is going. Remove the need to explicitly pass
the host vcpu since the shadow already has a trusted pointer to
it.

Bug: 220830416
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: Ibb5a34d66254788782b219565833e061c664abb2
2022-02-25 15:15:13 +00:00
Fuad Tabba
579e21a96c ANDROID: KVM: arm64: Do not pass host struct pointers to pkvm_host_donate_guest()
This function only works for loaded vcpus and no more information
is needed by hyp. This removes the need to access potentially
unsafe host memory.

Bug: 220830416
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: I2dae77b900139bd61e91fcff52beedffa2746d9b
2022-02-25 15:15:05 +00:00
Fuad Tabba
0856ec2e53 ANDROID: KVM: arm64: Do not pass host struct pointers to __pkvm_teardown_shadow()
Pass the handle and other safe data instead for hyp to use to
lookup the shadow vcpu. This removes the need to access
potentially unsafe host memory.

Bug: 220830416
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: Iff01f981aad8f1a064f8a8147e5443807558884c
2022-02-25 15:14:57 +00:00
Fuad Tabba
aaf5614200 ANDROID: KVM: arm64: move kvm_shadow_destroy to pkvm.c for symmetry with create_el2_shadow
Better to have the creation and teardown code in the same file to
understand what's happening. Simplifies subsequent patches.

Bug: 220830416
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: I07bc8a9e254753f000c4faffffcf52a0d8f3a831
2022-02-25 15:14:50 +00:00
Fuad Tabba
ab9f8c8200 ANDROID: KVM: arm64: Do not pass host struct pointers to kvm_arch_vcpu_load()
Pass the handle and other safe data instead for hyp to use to
lookup the shadow vcpu. This removes the need to access
potentially unsafe host memory.

Bug: 220830416
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: I65a2ffc75dbdd34f36cf4d3cc860bbc7a2d9671e
2022-02-25 15:14:44 +00:00
Fuad Tabba
0863f25b5d ANDROID: KVM: arm64: Only call kvm_shadow_destroy() in protected mode
Non-protected mode doesn't have a shadow state.

Bug: 220829442
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: I38f7eb94a8fd02cc796b943cdcda4ff379b1bb64
2022-02-25 15:14:38 +00:00
Fuad Tabba
50d8a0882d ANDROID: KVM: arm64: Memory donated for shadow state must be aligned
Check that the donated memory for the hyp shadow vm is paged-aligned.

Bug: 217683487
Reported-by: David Brazdil <dbrazdil@google.com>
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: I289cf1704eea9c2036cf26a8d767b101626620ed
2022-02-25 15:14:30 +00:00
Giuliano Procida
3edc23316a ANDROID: GKI: refresh XML following KMI enforcement race
Leaf changes summary: 1 artifact changed (1 filtered out)
Changed leaf types summary: 0 (1 filtered out) 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] 'const vb2_mem_ops vb2_dma_sg_memops'

Fixes: 3162b2f66c ("ANDROID: GKI: update the pixel symbol list")
Change-Id: I43e12521554bf5c9765b49d22867476ddb167d05
Signed-off-by: Giuliano Procida <gprocida@google.com>
2022-02-25 14:59:57 +00:00
Will Deacon
e3b73a4b5e ANDROID: KVM: arm64: Clear pvmfw pages on clean host shutdown
When the host shuts down cleanly under pKVM, it is EL2's responsibility
to clear the pvmfw pages before forwarding the PSCI call onto EL3.

Wipe the pvmfw pages on SYSTEM_OFF, SYSTEM_RESET and SYSTEM_RESET2 calls
from the host, cleaning the zeroed memory to the PoC for good measure.

Reported-by: Andrew Scull <ascull@google.com>
Bug: 196204410
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I0dd2757e355f384813319034c6eed0fa2c2328c2
2022-02-25 09:35:35 +00:00
David Brazdil
9eab20c98f ANDROID: KVM: arm64: Fix host MMIO DABT handler IPA
The data abort fault IPA obtained from HFAR_EL2 has the bottom 12 bits
zeroed out. This broke the host MMIO DABT handler because the offsets
of accessed MMIO registers were rounded down to the nearest page.

Include FAR_EL2 in the address to fix the issue.

Bug: 220194478
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I2ee7352dba69c673e5d5bddca7e1df9db1b4ce1f
2022-02-24 19:40:33 +00:00
Will McVicker
3162b2f66c ANDROID: GKI: update the pixel symbol list
Adds vb2_dma_sg_memops to the symbol list now that VIDEOBUF2_DMA_SG is
built-in to the GKI kernel.

Bug: 219998156
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: I59af06d1da835e21751636dd758ac25d9d00c8b1
2022-02-24 18:48:42 +00:00
Mikhail Golubev
c8726f2230 ANDROID: GKI: add VIDEOBUF2_DMA_SG under GKI_HIDDEN_MEDIA_CONFIGS
The virtio video driver v2 [1] uses videobuf2 structure
vb2_dma_sg_memops, when virtio device supports non-contiguous DMA video
buffers.

DMA SG memory allocator for videobuf2
(drivers/media/common/videobuf2/videobuf2-dma-sg.c) is a common code and
has no hardware dependencies.

[1]: https://lore.kernel.org/all/20200218202753.652093-2-dmitry.sepp@opensynergy.com/

Bug: 219998156
Signed-off-by: Mikhail Golubev <Mikhail.Golubev@opensynergy.com>
Change-Id: I897898090d7a97b13202c05aae28955595e09468
2022-02-24 18:48:32 +00:00