Commit Graph

988008 Commits

Author SHA1 Message Date
Paul Lawrence
b196350f2a ANDROID: fuse-bpf: Fix lseek return value for offset 0
Bug: 227160050
Test: audible app now works
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ib14765285190b5838f28c25a69c91935d02c34f4
2022-04-11 15:11:24 -07:00
Will McVicker
bba21782c8 ANDROID: Update the ABI symbol list and xml
Leaf changes summary: 1 artifact changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

1 Added function:

  [A] 'function void __drm_printfn_debug(drm_printer*, va_format*)'

Bug: 202781851
Change-Id: I8c0270ac538462cc64246195e20f5c653f5894cc
Signed-off-by: Midas Chien <midaschieh@google.com>
Signed-off-by: Will McVicker <willmcvicker@google.com>
2022-04-11 11:20:46 -07:00
Greg Kroah-Hartman
e5765b86ce ANDROID: GKI: set more vfs-only exports into their own namespace
There are more vfs-only symbols that OEMs want to use, so place them in
the proper vfs-only namespace.

Bug: 157965270
Bug: 210074446
Bug: 227656251
Cc: Matthias Maennich <maennich@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I99b9facc8da45fb329f6627d204180d1f89bcf97
2022-04-08 15:46:37 +02:00
Quentin Perret
74ff6e66d2 ANDROID: KVM: arm64: Fix ToCToU issue when refilling the hyp memcache
Xiling reports that the hypervisor dereferences the host memcache struct
twice when refilling its own memcache. This allows the host to change its
memcache head after it has been admitted and before it is consumed,
leading to an arbitrary write in hypervisor memory.

Fix this by copying the host memcache on the stack before starting to
refill hence guaranteeing its stability.

Bug: 228435321
Reported-by: Xiling Gong <xiling@google.com>
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: Ib7c5db203e4a4a7f27eb9f0c0083f4b5c726b4d9
2022-04-08 12:34:52 +00:00
Minchan Kim
8fe46774c6 ANDROID: mm: page_pinner: remove dump_page_pinner
This patch removes dump_page_pinner since it was not useful(IOW,
the page_pinner buffer to keep the history is enough).

This patch also changes mismatched printf format specifier.

Bug: 218731671
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I80c6f5ad656b3b0d27a50eabff4d1382559aa105
2022-04-07 23:15:24 +00:00
Andrey Konovalov
94c6c10c39 BACKPORT: mm, kasan: fix __GFP_BITS_SHIFT definition breaking LOCKDEP
[Backport: resolve conflicts caused by CONFIG_CMA.]

KASAN changes that added new GFP flags mistakenly updated
__GFP_BITS_SHIFT as the total number of GFP bits instead of as a shift
used to define __GFP_BITS_MASK.

This broke LOCKDEP, as __GFP_BITS_MASK now gets the 25th bit enabled
instead of the 28th for __GFP_NOLOCKDEP.

Update __GFP_BITS_SHIFT to always count KASAN GFP bits.

In the future, we could handle all combinations of KASAN and LOCKDEP to
occupy as few bits as possible.  For now, we have enough GFP bits to be
inefficient in this quick fix.

Link: https://lkml.kernel.org/r/462ff52742a1fcc95a69778685737f723ee4dfb3.1648400273.git.andreyknvl@google.com
Fixes: 9353ffa6e9 ("kasan, page_alloc: allow skipping memory init for HW_TAGS")
Fixes: 53ae233c30 ("kasan, page_alloc: allow skipping unpoisoning for HW_TAGS")
Fixes: f49d9c5bb1 ("kasan, mm: only define ___GFP_SKIP_KASAN_POISON with HW_TAGS")
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Tested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Marco Elver <elver@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 78d104f8b401c81d140adad91e027d7d83b3315c)
Bug: 217222520
Change-Id: I82484635012c5773c6ef9164a9368d9e61157f87
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
2022-04-07 17:51:52 +02:00
Andrey Konovalov
7bfa608df5 UPSTREAM: kasan: test: support async (again) and asymm modes for HW_TAGS
Async mode support has already been implemented in commit e80a76aa1a
("kasan, arm64: tests supports for HW_TAGS async mode") but then got
accidentally broken in commit 99734b535d ("kasan: detect false-positives
in tests").

Restore the changes removed by the latter patch and adapt them for asymm
mode: add a sync_fault flag to kunit_kasan_expectation that only get set
if the MTE fault was synchronous, and reenable MTE on such faults in
tests.

Also rename kunit_kasan_expectation to kunit_kasan_status and move its
definition to mm/kasan/kasan.h from include/linux/kasan.h, as this
structure is only internally used by KASAN.  Also put the structure
definition under IS_ENABLED(CONFIG_KUNIT).

Link: https://lkml.kernel.org/r/133970562ccacc93ba19d754012c562351d4a8c8.1645033139.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Marco Elver <elver@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit ed6d74446c)
Bug: 217222520
Change-Id: I8be7f20e72efe7ad81999dc75c848fb89664602c
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
2022-04-07 17:51:51 +02:00
David Brazdil
4e56697b42 ANDROID: KVM: arm64: iommu: Optimize snapshot_host_stage2
Currently the generic IOMMU code lets the driver initialize its PT and
then invokes callbacks to set the permissions across the entire PA
range. Optimize this by making it a requirement on the driver to
initialize its PTs to all memory owned by the host. snapshot_host_stage2
then only calls the driver's callback for memory regions not owned by
the host.

Bug: 190463801
Bug: 218012133
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I51ff38cb4f4e28e19903af942776b401504c363e
2022-04-07 09:25:16 +01:00
David Brazdil
174ac5b7c5 ANDROID: KVM: arm64: s2mpu: Initialize MPTs to PROT_RW
Change the permissions that MPTs are initialized with from PROT_NONE to
PROT_RW. No functional change intended as the generic IOMMU code
sets permissions for the entire address space later. This will allow to
optimize boot time by only unmapping pages not available to host.

Bug: 190463801
Bug: 218012133
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: Ic29ec690a84cde22a2ce8fe33e7127711c6f0f3e
2022-04-07 09:25:15 +01:00
David Brazdil
a946ac5ff5 ANDROID: KVM: arm64: iommu: Fix upper bound of PT walk
The second argument of the kvm_pgtable_walker callback was
misinterpreted as the end of the current entry, where in fact it is
the end of the walked memory region. Fix this by computing the end of
the current entry from the start and the level.

This did not affect correctness, as the code iterates linarly over
the entire address space, but it did affect boot time.

Bug: 190463801
Bug: 218012133
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I6d189b87645f47cd215a783c1bc9e1f032ff8c62
2022-04-07 09:25:15 +01:00
Todd Kjos
a63ec2bcac ANDROID: GKI: 4/6/2022 KMI update
Set KMI_GENERATION=3 for 4/6 KMI update

Leaf changes summary: 26 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 23 Removed, 0 Changed, 1 Added function
Removed/Changed/Added variables summary: 2 Removed, 0 Changed, 0 Added variable

23 Removed functions:

  [D] 'function file* anon_inode_getfile(const char*, const file_operations*, void*, int)'
  [D] 'function int compat_only_sysfs_link_entry_to_kobj(kobject*, kobject*, const char*, const char*)'
  [D] 'function int device_match_name(device*, void*)'
  [D] 'function gnss_device* gnss_allocate_device(device*)'
  [D] 'function void gnss_deregister_device(gnss_device*)'
  [D] 'function int gnss_insert_raw(gnss_device*, const unsigned char*, size_t)'
  [D] 'function void gnss_put_device(gnss_device*)'
  [D] 'function int gnss_register_device(gnss_device*)'
  [D] 'function void* idr_replace(idr*, void*, unsigned long int)'
  [D] 'function void led_set_brightness_nosleep(led_classdev*, led_brightness)'
  [D] 'function void led_trigger_event(led_trigger*, led_brightness)'
  [D] 'function int led_trigger_register(led_trigger*)'
  [D] 'function void led_trigger_unregister(led_trigger*)'
  [D] 'function dentry* securityfs_create_dir(const char*, dentry*)'
  [D] 'function dentry* securityfs_create_file(const char*, umode_t, dentry*, void*, const file_operations*)'
  [D] 'function void securityfs_remove(dentry*)'
  [D] 'function void serdev_device_close(serdev_device*)'
  [D] 'function int serdev_device_open(serdev_device*)'
  [D] 'function unsigned int serdev_device_set_baudrate(serdev_device*, unsigned int)'
  [D] 'function void serdev_device_set_flow_control(serdev_device*, bool)'
  [D] 'function void serdev_device_wait_until_sent(serdev_device*, long int)'
  [D] 'function int serdev_device_write(serdev_device*, const unsigned char*, size_t, long int)'
  [D] 'function void serdev_device_write_wakeup(serdev_device*)'

1 Added function:

  [A] 'function void __page_pinner_put_page(page*)'

2 Removed variables:

  [D] 'int efi_tpm_final_log_size'
  [D] 'const int hash_digest_size[20]'

Bug: 228318757
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I947875f13a75de7cb0c2765057cc468cc6810875
2022-04-07 00:54:47 +00:00
Saravana Kannan
ac3d413511 ANDROID: vendor_hooks: Reduce pointless modversions CRC churn
When vendor hooks are added to a file that previously didn't have any
vendor hooks, we end up indirectly including linux/tracepoint.h.  This
causes some data types that used to be opaque (forward declared) to the
code to become visible to the code.

Modversions correctly catches this change in visibility, but we don't
really care about the data types made visible when linux/tracepoint.h is
included. So, hide this from modversions in the central vendor_hooks.h file
instead of having to fix this on a case by case basis.

This change itself will cause a one time CRC breakage/churn because it's
fixing the existing vendor hook headers, but should reduce unnecessary CRC
churns in the future.

To avoid future pointless CRC churn, vendor hook header files that include
vendor_hooks.h should not include linux/tracepoint.h directly.

Bug: 227513263
Bug: 226140073
Signed-off-by: Saravana Kannan <saravanak@google.com>
Change-Id: Ia88e6af11dd94fe475c464eb30a6e5e1e24c938b
2022-04-06 15:41:56 -07:00
Minchan Kim
f33dc31c48 ANDROID: mm: gup: additional param in vendor hooks
It needs addtional struct page **pages params to judge whether
it's possible to migrate pages out of CMA.

Bug: 227475444
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I9a8aa57ff91228baf0fc970b8499464c07872c09
2022-04-06 15:41:56 -07:00
Minchan Kim
16b4583a99 ANDROID: mm: page_pinner: fix build warning
Remove the build warning below.

mm/page_pinner.c:201:28: warning: comparison of distinct pointer types ('typeof ((ts_usec)) *' (aka 'long long *') and 'uint64_t *' (aka 'unsigned long long *')) [-Wcompare-distinct-pointer-types]
                unsigned long rem_usec = do_div(ts_usec, 1000000);

Bug: 218731671
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I4d7b24998c3288f4066b5f88d5ebbf59e04b9873
2022-04-06 15:41:55 -07:00
Minchan Kim
01edbc91e2 ANDROID: mm: page_pinner: change pinner buffer size
Introduce $debugfs/page_pinner/buffer_size to change
buffer_size on demand. The change of buffer_size will
reset the buffer.

Bug: 218731671
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I505cdc2ee29aa0c6ed4e2dc2c0b6fcff77c388e4
2022-04-06 15:41:55 -07:00
Minchan Kim
b8a18e852e ANDROID: mm: page_pinner: remove static buffer
We shouldn't waste memory for vendors who don't use
page_pinner so remove the page_pinner static buffer.

Bug: 218731671
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I46ae2fb5000c4eb59253159032182ca106b39eb9
2022-04-06 15:41:55 -07:00
Minchan Kim
5c70ecb399 ANDROID: mm: page_pinner: remove longterm_pinner
From the experience, longterm_pinner is not worth maintaining
considering how much it churns MM. Just drop the feature and
we are good with alloc_contig_failed.

The visible effect from this patch is
  1. drop $debugfs/page_pinner/longterm_pinner
  2. drop put_user_page expoerted API
  3. rename alloc_contig_failed to buffer

Bug: 218731671
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I68cc11db448260987a9e26b99647ecb55f571616
2022-04-06 15:41:55 -07:00
Minchan Kim
e17f903a92 ANDROID: mm: page_pinner: change output format for alloc_contig_failed
Currently, output format is a little hard to parse how long the
page has been pinned since user need to figure out the timeline
from migration failure detection to put event. Sometimes, the log
buffer would be overflowed so we lost the migration failure event
timeline, even. This patch stores the page pinning time in kernel
side and keep the information whenever page was released. Thus,
user could understand the output easier and never lose the information.

Bug: 218731671
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I396f0c12438e0ff8a3497253b750a7e5bb342f57
2022-04-06 15:41:55 -07:00
Minchan Kim
a45f3891de ANDROID: mm: page_pinner refactoring
Currently, page_pinner code are too ugly since we missed refactoring
last time due to GKI deadline. Let's make it better this time before
GKI is freezing.

What this patch is cleaning are __reset_page_pinner which is used
for freeing page as well as putting pages depending on free parameter.
It makes code too ugly for readability PoV and hard to make further
changes so split it with each put and free functions.

Bug: 218731671
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I610ffc629eea5e996b7d55340b5589a3f49574d7
2022-04-06 15:41:54 -07:00
Yunfei Wang
8e9a170748 FROMGIT: iommu/iova: Improve 32-bit free space estimate
For various reasons based on the allocator behaviour and typical
use-cases at the time, when the max32_alloc_size optimisation was
introduced it seemed reasonable to couple the reset of the tracked
size to the update of cached32_node upon freeing a relevant IOVA.
However, since subsequent optimisations focused on helping genuine
32-bit devices make best use of even more limited address spaces, it
is now a lot more likely for cached32_node to be anywhere in a "full"
32-bit address space, and as such more likely for space to become
available from IOVAs below that node being freed.

At this point, the short-cut in __cached_rbnode_delete_update() really
doesn't hold up any more, and we need to fix the logic to reliably
provide the expected behaviour. We still want cached32_node to only move
upwards, but we should reset the allocation size if *any* 32-bit space
has become available.

Reported-by: Yunfei Wang <yf.wang@mediatek.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
Link: https://lore.kernel.org/r/033815732d83ca73b13c11485ac39336f15c3b40.1646318408.git.robin.murphy@arm.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>

Bug: 223712131
(cherry picked from commit 5b61343b50
 https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git core)
Signed-off-by: Yunfei Wang <yf.wang@mediatek.com>
Change-Id: I5026411dd022c6ddea5c0e4da6e69c7b14162c3f
(cherry picked from commit ec48b1892e)
2022-04-06 18:01:45 +00:00
Marc Zyngier
34469ce1b4 ANDROID: KVM: arm64: pkvm: Track the SVE state in the shadow vcpu
When dealing with a guest with SVE enabled, we don't populate
the shadow SVE state, nor pin the SVE state at S1 EL2.

Fix both issues in one go.

Bug: 227292021
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Marc Zyngier <mzyngier@google.com>
Change-Id: I88dc7e9c84e5970ec2466a0aa98ad4e3c94711a0
2022-04-06 10:11:42 +00:00
Marc Zyngier
7cea3ceefb ANDROID: KVM: arm64: Make the use of host or shadow vcpu less error prone
It isn't always obvious what vcpu (host or shadow) should be used
in which context, nor whether the provided vcpu is valid or not.

To make this less error prone, provide a helper that will always
return a vcpu in the HYP address space as well as the corresponding
shadow state if we're in protected mode. If the host-provided vcpu
doesn't match the loaded vcpu, NULL is returned for both pointers.

In non-protected mode, no state is provided, of course, but the vcpu
is converted to its HYP pointer.

Bug: 227292021
Bug: 227768863
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Marc Zyngier <mzyngier@google.com>
Change-Id: Idcfc4e042ff05d97ae52f7991666935c1c570f10
2022-04-06 10:11:26 +00:00
Greg Kroah-Hartman
176c157bbe ANDROID: GKI: set vfs-only exports into their own namespace
We have namespaces, so use them for all vfs-exported namespaces so that
filesystems can use them, but not anything else.

Some in-kernel drivers that do direct filesystem accesses (because they
serve up files) are also allowed access to these symbols to keep 'make
allmodconfig' builds working properly, but it is not needed for Android
kernel images.

Bug: 157965270
Bug: 210074446
Cc: Matthias Maennich <maennich@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Iaf6140baf3a18a516ab2d5c3966235c42f3f70de
2022-04-05 17:48:33 +02:00
Greg Kroah-Hartman
21c7e202ac FROMLIST: export: fix string handling of namespace in EXPORT_SYMBOL_NS
Commit c3a6cf19e6 ("export: avoid code duplication in
include/linux/export.h") broke the ability for a defined string to be
used as a namespace value.  Fix this up by adding another layer of
indirection to preserve the previous functionality.

Fixes: c3a6cf19e6 ("export: avoid code duplication in include/linux/export.h")
Cc: Miroslav Benes <mbenes@suse.cz>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Jessica Yu <jeyu@kernel.org>
Cc: Quentin Perret <qperret@google.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Matthias Maennich <maennich@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20220108140415.3360088-1-gregkh@linuxfoundation.org
Bug: 210074446
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ie43aa24f64b55cd1d70161c906b0ef32610430aa
2022-04-05 17:31:33 +02:00
Greg Kroah-Hartman
fdf0178dba UPSTREAM: module.h: allow #define strings to work with MODULE_IMPORT_NS
The MODULE_IMPORT_NS() macro does not allow defined strings to work
properly with it, so add a layer of indirection to allow this to happen.

Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Jessica Yu <jeyu@kernel.org>
Cc: Matthias Maennich <maennich@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
(cherry picked from commit ca321ec743)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ibd64ba139912ea10e81ac22490831129b23a31e1
2022-04-05 17:31:33 +02:00
Victor Hsu
7ba447d039 ANDROID: Update the ABI representation
Leaf changes summary: 2 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 2 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

2 Added functions:

  [A] 'function void pci_msi_mask_irq(irq_data*)'
  [A] 'function void pci_msi_unmask_irq(irq_data*)'

Bug: 226026678
Signed-off-by: Victor Hsu <hsuvictor@google.com>
Change-Id: I53e8444b612c2852be35345385a0401df060a4e3
2022-04-04 18:06:59 +00:00
James Morse
8302ed7fba FROMGIT: arm64: head.S: Initialise MPAM EL2 registers and disable traps
Add code to head.S's el2_setup to detect MPAM and disable any EL2 traps.
This register resets to an unknown value, setting it to the default
parititons/pmg before we enable the MMU is the best thing to do.

Kexec/kdump will depend on this if the previous kernel left the CPU
configured with a restrictive configuration.

If linux is booted at the highest implemented exception level el2_setup
will clear the enable bit, disabling MPAM.

Signed-off-by: James Morse <james.morse@arm.com>

Bug: 221768437
(cherry picked from commit fa0ff38f06b397d8a92d88eb8083c2c5a20ac87f
 git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/snapshot/v5.16)
Change-Id: I2758f7f7b236d09a207e13d1165efb6887e8611a
Signed-off-by: Valentin Schneider <Valentin.Schneider@arm.com>
[bm: amended commit msg, dropped config option and switched to named labels]
Signed-off-by: Beata Michalska <beata.michalska@arm.com>
2022-04-04 08:22:27 +00:00
Valentin Schneider
5748592d14 ANDROID: arm64: Partial MPAM sysreg definition import
This is a partial cherry-pick of commit:

  7fe77616f156 ("arm64: cpufeature: discover CPU support for MPAM")

from git://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git

Bug: 221768437
Change-Id: I77101abb07f9b73dbc7cc2a53ac44fbf772f0b1d
Signed-off-by: Valentin Schneider <Valentin.Schneider@arm.com>
Signed-off-by: Beata Michalska <beata.michalska@arm.com>
2022-04-04 08:22:21 +00:00
Keir Fraser
aadf7ad9db BACKPORT: virtio: pci: check bar values read from virtio config space
virtio pci config structures may in future have non-standard bar
values in the bar field. We should anticipate this by skipping any
structures containing such a reserved value.

The bar value should never change: check for harmful modified values
we re-read it from the config space in vp_modern_map_capability().

Also clean up an existing check to consistently use PCI_STD_NUM_BARS.

Signed-off-by: Keir Fraser <keirf@google.com>
Link: https://lore.kernel.org/r/20220323140727.3499235-1-keirf@google.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 3f63a1d7f6)
Bug: 222232623
[keirf@: Pass virtio_pci_device to map_capability. Move everything
into virtio_pci_modern.c]
Signed-off-by: Keir Fraser <keirf@google.com>
Change-Id: Idbba48154a051cf173b9cb0bd40c77fcf02902a4
2022-04-01 22:56:34 +00:00
Jason Wang
7e5df18bee UPSTREAM: Revert "virtio_pci: harden MSI-X interrupts"
This reverts commit 9e35276a53. Issue
were reported for the drivers that are using affinity managed IRQ
where manually toggling IRQ status is not expected. And we forget to
enable the interrupts in the restore path as well.

In the future, we will rework on the interrupt hardening.

Fixes: 9e35276a53 ("virtio_pci: harden MSI-X interrupts")
Reported-by: Marc Zyngier <maz@kernel.org>
Reported-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20220323031524.6555-2-jasowang@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit eb4cecb453)
Bug: 196772804
Signed-off-by: Keir Fraser <keirf@google.com>
Change-Id: I05264d9e61d558522a8a20cf87399aa3578b3a6e
2022-04-01 15:06:40 +00:00
Jason Wang
c7912e3027 UPSTREAM: Revert "virtio-pci: harden INTX interrupts"
This reverts commit 080cd7c3ac. Since
the MSI-X interrupts hardening will be reverted in the next patch. We
will rework the interrupt hardening in the future.

Fixes: 080cd7c3ac ("virtio-pci: harden INTX interrupts")
Signed-off-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20220323031524.6555-1-jasowang@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 7b79edfb86)
Bug: 196772804
Signed-off-by: Keir Fraser <keirf@google.com>
Change-Id: I11ea35dcff3cfd43a535acf2033d7921f39c8be7
2022-04-01 15:05:51 +00:00
Pradeep P V K
30d72758db FROMLIST: fuse: give wakeup hints to the scheduler
The synchronous wakeup interface is available only for the
interruptible wakeup. Add it for normal wakeup and use this
synchronous wakeup interface to wakeup the userspace daemon.
Scheduler can make use of this hint to find a better CPU for
the waker task.

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

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

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

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

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

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

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

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

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

1 Added function:

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

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

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

Reason for revert: Needs rework - causes unforeseen deadlock.

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

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

2 Added functions:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Bug: 190463801
Signed-off-by: David Brazdil <dbrazdil@google.com>
Change-Id: I285fc822e9fc926c49b9b5e69446790e1edccafb
2022-03-29 17:09:26 +01:00