Commit Graph

874085 Commits

Author SHA1 Message Date
Sami Tolvanen
f60143ce12 ANDROID: scripts/mod: disable LTO for empty.c
With CONFIG_LTO_CLANG, clang generates LLVM IR instead of ELF object
files. As empty.o is used for probing target properties, disable LTO
for it to produce an object file instead.

Bug: 145210207
Change-Id: I618d8b86ed88ad048abdee3c541ced19d12982c0
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:10 -08:00
Sami Tolvanen
d671af5fd7 ANDROID: kbuild: fix dynamic ftrace with clang LTO
With CONFIG_LTO_CLANG enabled, LLVM IR won't be compiled into object
files until modpost_link. This change postpones calls to recordmcount
until after this step.

In order to exclude ftrace_process_locs from inspection, we add a new
code section .text..ftrace, which we tell recordmcount to ignore, and
a __norecordmcount attribute for moving functions to this section.

Bug: 145210207
Change-Id: Ib77f7c431fce54243c46d584b55761ed2342965c
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:10 -08:00
Sami Tolvanen
2e39b40dd2 ANDROID: kbuild: add support for Clang LTO
This change adds the configuration option CONFIG_LTO_CLANG, and
build system support for Clang's Link Time Optimization (LTO). In
preparation for LTO support with other compilers, potentially common
parts of the changes are gated behind CONFIG_LTO instead.

With -flto, instead of object files, Clang produces LLVM bitcode,
which is compiled into a native object at link time, allowing the
final binary to be optimized globally. For more details, see:

  https://llvm.org/docs/LinkTimeOptimization.html

While the kernel normally uses GNU ld for linking, LLVM supports LTO
only with LLD or GNU gold linkers. This change assumes LLD is used.

Bug: 145210207
Change-Id: If1164ff33d073358ee7d4bba84cbb06c349c4a88
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:10 -08:00
Sami Tolvanen
548c06ceb9 ANDROID: kbuild: add CONFIG_LD_IS_LLD
Similarly to the CC_IS_CLANG config, add LD_IS_LLD to simplify feature
selection based on the linker.

Bug: 145210207
Change-Id: I097c52899dcf9829eb0e1ea89211b17972301c1a
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:10 -08:00
Sami Tolvanen
d8a936fab6 FROMGIT: driver core: platform: use the correct callback type for bus_find_device
platform_find_device_by_driver calls bus_find_device and passes
platform_match as the callback function. Casting the function to a
mismatching type trips indirect call Control-Flow Integrity (CFI) checking.

This change adds a callback function with the correct type and instead
of casting the function, explicitly casts the second parameter to struct
device_driver* as expected by platform_match.

Bug: 145210207
Change-Id: Idef667974d3c54ebd79f0813531cf2523d651dfe
(cherry picked from commit 492c88720d36eb662f9f10c1633f7726fbb07fc4
 git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
 driver-core-next)
Fixes: 36f3313d6b ("platform: Add platform_find_device_by_driver() helper")
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20191112214156.3430-1-samitolvanen@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-27 12:49:10 -08:00
Sami Tolvanen
8b4777ebbe FROMLIST: arm64: implement Shadow Call Stack
This change implements shadow stack switching, initial SCS set-up,
and interrupt shadow stacks for arm64.

Bug: 145210207
Change-Id: I6fd8770bef9d24c85470d17e6a8e867c7cfe43f4
(am from https://lore.kernel.org/patchwork/patch/1149062/)
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:10 -08:00
Sami Tolvanen
45065a78ff FROMLIST: arm64: disable SCS for hypervisor code
Filter out CC_FLAGS_SCS for code that runs at a different exception
level.

Bug: 145210207
Change-Id: I834424fba7aa18598b618891814327ecc2841c6e
(am from https://lore.kernel.org/patchwork/patch/1149062/)
Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:10 -08:00
Sami Tolvanen
1cb25645a4 FROMLIST: arm64: vdso: disable Shadow Call Stack
Shadow stacks are only available in the kernel, so disable SCS
instrumentation for the vDSO.

Bug: 145210207
Change-Id: Id894b77112801c00a44bcc539cc3882b5f72b251
(am from https://lore.kernel.org/patchwork/patch/1149061/)
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:10 -08:00
Sami Tolvanen
c9ac25bb3b FROMLIST: arm64: efi: restore x18 if it was corrupted
If we detect a corrupted x18 and SCS is enabled, restore the register
before jumping back to instrumented code. This is safe, because the
wrapper is called with preemption disabled and a separate shadow stack
is used for interrupt handling.

Bug: 145210207
Change-Id: Idb75117e38c895231a14f5573261861e722c1264
(am from https://lore.kernel.org/patchwork/patch/1149060/)
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:09 -08:00
Sami Tolvanen
f93d5158d7 FROMLIST: arm64: preserve x18 when CPU is suspended
Don't lose the current task's shadow stack when the CPU is suspended.

Bug: 145210207
Change-Id: I8db58daadcc15a00a6f585580a3c97905c678eb3
(am from https://lore.kernel.org/patchwork/patch/1149059/)
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:09 -08:00
Sami Tolvanen
0a470ab7e1 FROMLIST: arm64: reserve x18 from general allocation with SCS
Reserve the x18 register from general allocation when SCS is enabled,
because the compiler uses the register to store the current task's
shadow stack pointer. Note that all external kernel modules must also be
compiled with -ffixed-x18 if the kernel has SCS enabled.

Bug: 145210207
Change-Id: I0407d38a0a5ecb6852b3f281d52f6601c565157e
(am from https://lore.kernel.org/patchwork/patch/1149058/)
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:09 -08:00
Sami Tolvanen
87705f9b09 FROMLIST: arm64: disable function graph tracing with SCS
The graph tracer hooks returns by modifying frame records on the
(regular) stack, but with SCS the return address is taken from the
shadow stack, and the value in the frame record has no effect. As we
don't currently have a mechanism to determine the corresponding slot
on the shadow stack (and to pass this through the ftrace
infrastructure), for now let's disable the graph tracer when SCS is
enabled.

Bug: 145210207
Change-Id: I65dd098be827121ecf0c08538b11e3b98f5eacde
(am from https://lore.kernel.org/patchwork/patch/1149057/)
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:09 -08:00
Sami Tolvanen
c7c833b13e FROMLIST: scs: add support for stack usage debugging
Implements CONFIG_DEBUG_STACK_USAGE for shadow stacks. When enabled,
also prints out the highest shadow stack usage per process.

Bug: 145210207
Change-Id: I2b2fea68760ca8d94d6f887cfe5828883d233b88
(am from https://lore.kernel.org/patchwork/patch/1149056/)
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:09 -08:00
Sami Tolvanen
7f498a4b7b FROMLIST: scs: add accounting
This change adds accounting for the memory allocated for shadow stacks.

Bug: 145210207
Change-Id: Iee94c22abefcabb63a3bcd4db8ba952130f30a82
(am from https://lore.kernel.org/patchwork/patch/1149055/)
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:09 -08:00
Sami Tolvanen
ff9de73a0a FROMLIST: add support for Clang's Shadow Call Stack (SCS)
This change adds generic support for Clang's Shadow Call Stack,
which uses a shadow stack to protect return addresses from being
overwritten by an attacker. Details are available here:

  https://clang.llvm.org/docs/ShadowCallStack.html

Note that security guarantees in the kernel differ from the
ones documented for user space. The kernel must store addresses
of shadow stacks used by other tasks and interrupt handlers in
memory, which means an attacker capable reading and writing
arbitrary memory may be able to locate them and hijack control
flow by modifying shadow stacks that are not currently in use.

Bug: 145210207
Change-Id: I2a8ba6a3decac50c169731c3121c9dcab96621d2
(am from https://lore.kernel.org/patchwork/patch/1149054/)
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:09 -08:00
Ard Biesheuvel
a1d12f696b FROMLIST: arm64: kernel: avoid x18 in __cpu_soft_restart
The code in __cpu_soft_restart() uses x18 as an arbitrary temp register,
which will shortly be disallowed. So use x8 instead.

Bug: 145210207
Change-Id: Iad10392005b66e6bf3a0f00c40024448e9798b89
(am from https://lore.kernel.org/patchwork/patch/1149053/)
Link: https://patchwork.kernel.org/patch/9836877/
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
[Sami: updated commit message]
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:08 -08:00
Ard Biesheuvel
c8900aab73 FROMLIST: arm64: kvm: stop treating register x18 as caller save
In preparation of reserving x18, stop treating it as caller save in
the KVM guest entry/exit code. Currently, the code assumes there is
no need to preserve it for the host, given that it would have been
assumed clobbered anyway by the function call to __guest_enter().
Instead, preserve its value and restore it upon return.

Bug: 145210207
Change-Id: I341bcb10b615999a59a8413a6b98cb2ce1c62e02
(am from https://lore.kernel.org/patchwork/patch/1149065/)
Link: https://patchwork.kernel.org/patch/9836891/
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
[Sami: updated commit message, switched from x18 to x29 for the guest context]
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:08 -08:00
Ard Biesheuvel
aab371bf9e FROMLIST: arm64/lib: copy_page: avoid x18 register in assembler code
Register x18 will no longer be used as a caller save register in the
future, so stop using it in the copy_page() code.

Bug: 145210207
Change-Id: Iffd77db101d6e83ec8c5e12b11d9f0fef09a630b
(am from https://lore.kernel.org/patchwork/patch/1149064/)
Link: https://patchwork.kernel.org/patch/9836869/
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
[Sami: changed the offset and bias to be explicit]
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:08 -08:00
Sami Tolvanen
527a0aa3ff FROMLIST: arm64: mm: avoid x18 in idmap_kpti_install_ng_mappings
idmap_kpti_install_ng_mappings uses x18 as a temporary register, which
will result in a conflict when x18 is reserved. Use x16 and x17 instead
where needed.

Bug: 145210207
Change-Id: I9fbf40769c5c241422fff8558c7a9bade8ebadb6
(am from https://lore.kernel.org/patchwork/patch/1149052/)
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 12:49:08 -08:00
Alistair Delva
8275ea1fca ANDROID: clang: update to 10.0.1
Bug: 144776928
Change-Id: Ic1c76a05a54b0001eac6f9c6f248222989aa79bd
Signed-off-by: Alistair Delva <adelva@google.com>
2019-11-27 12:49:08 -08:00
Sami Tolvanen
0f5db0f9d5 ANDROID: update ABI representation
Leaf changes summary: 4 artifacts changed
Changed leaf types summary: 4 leaf types changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

'struct pwm_args at pwm.h:41:1' changed:
  type size changed from 64 to 128 (in bits)
  there are data member changes:
   type 'unsigned int' of 'pwm_args::period' changed:
     entity changed from 'unsigned int' to compatible type 'typedef u64' at int-ll64.h:23:1
     type size changed from 32 to 64 (in bits)
, size changed from 32 to 64 (in bits) (by +32 bits)
   'pwm_polarity pwm_args::polarity' offset changed from 32 to 64 (in bits) (by +32 bits)

  19 impacted interfaces:
    [...]

'struct pwm_capture at pwm.h:335:1' changed:
  type size changed from 64 to 128 (in bits)
  there are data member changes:
   type 'unsigned int' of 'pwm_capture::period' changed:
     entity changed from 'unsigned int' to compatible type 'typedef u64' at int-ll64.h:23:1
     type size changed from 32 to 64 (in bits)
, size changed from 32 to 64 (in bits) (by +32 bits)
   type 'unsigned int' of 'pwm_capture::duty_cycle' changed:
     entity changed from 'unsigned int' to compatible type 'typedef u64' at int-ll64.h:23:1
     type size changed from 32 to 64 (in bits)
, offset changed from 32 to 64 (in bits) (by +32 bits), size changed from 32 to 64 (in bits) (by +32 bits)

  19 impacted interfaces:
    [...]

'struct pwm_device at pwm.h:88:1' changed:
  type size changed from 576 to 704 (in bits)
  there are data member changes:
   type 'struct pwm_args' of 'pwm_device::args' changed as reported earlier
   and size changed from 64 to 128 (in bits) (by +64 bits)
   type 'struct pwm_state' of 'pwm_device::state' changed:
, offset changed from 384 to 448 (in bits) (by +64 bits), size changed from 160 to 256 (in bits) (by +96 bits)

  19 impacted interfaces:
    [...]

'struct pwm_state at pwm.h:69:1' changed:
  type size changed from 160 to 256 (in bits)
  there are data member changes:
   type 'unsigned int' of 'pwm_state::period' changed:
     entity changed from 'unsigned int' to compatible type 'typedef u64' at int-ll64.h:23:1
     type size changed from 32 to 64 (in bits)
, size changed from 32 to 64 (in bits) (by +32 bits)
   type 'unsigned int' of 'pwm_state::duty_cycle' changed:
     entity changed from 'unsigned int' to compatible type 'typedef u64' at int-ll64.h:23:1
     type size changed from 32 to 64 (in bits)
, offset changed from 32 to 64 (in bits) (by +32 bits), size changed from 32 to 64 (in bits) (by +32 bits)
   'pwm_polarity pwm_state::polarity' offset changed from 64 to 128 (in bits) (by +64 bits)
   'pwm_output_type pwm_state::output_type' offset changed from 96 to 160 (in bits) (by +64 bits)
   'bool pwm_state::enabled' offset changed from 128 to 192 (in bits) (by +64 bits)

  19 impacted interfaces:
    [...]

Fixes: 0453f563cc ("FROMLIST: pwm: Convert period and duty cycle to u64")
Change-Id: I84a0b3ad7d7798ab3d00d3f45a9eb5b20cea04a9
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2019-11-27 10:53:26 -08:00
Guru Das Srinagesh
0453f563cc FROMLIST: pwm: Convert period and duty cycle to u64
Because period and duty cycle are defined as ints with units of
nanoseconds, the maximum time duration that can be set is limited to
~2.147 seconds. Change their definitions to u64 in the structs of the
PWM framework so that higher durations may be set.

Also make the relevant fixes to those drivers that use the period and
duty_cycle struct members in division operations, viz. replacing the
division operations with 64-bit division macros as appropriate.

Bug: 140290586
Change-Id: Ibb8c7f007f4c11ebf8cf01e7a468cc9c29aa8b23
Link: https://www.spinics.net/lists/linux-pwm/msg11133.html
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
Reported-by: kbuild test robot <lkp@intel.com>
2019-11-26 10:57:36 -08:00
Mark Salyzyn
6f3278abc5 ANDROID: gki_defconfig: FW_CACHE to no
Set the default for FW_CACHE to n to match Android expectations.

Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Bug: 32180327
Bug: 137566496
Change-Id: I86a28040be07fb2f30125d28f7f379798727785c
(cherry picked from commit 8331ce00073074134a283a72a5731cb4689a28e6)
2019-11-26 17:20:14 +00:00
Mark Salyzyn
82967fe174 FROMGIT: firmware_class: make firmware caching configurable
Because firmware caching generates uevent messages that are sent over
a netlink socket, it can prevent suspend on many platforms.  It's
also not always useful, so make it a configurable option.

Signed-off-by: Mark Salyzyn <salyzyn@android.com>
Cc: Tim Murray <timmurray@google.com>
Cc: Venkata Narendra Kumar Gutta <vnkgutta@codeaurora.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: linux-kernel@vger.kernel.org
Cc: kernel-team@android.com
Acked-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20191113225429.118495-1-salyzyn@android.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

(cherry picked from commit c74f8056621738f5be9f5d3d7e0caa927b21aef6 git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git driver-core-testing)
Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Bug: 32180327
Bug: 137566496
Change-Id: I1250512b27edb56caa78d536e5ccf1fb669476ad
(cherry picked from commit cd403ef6a75c38bc126b1b7f2362ab6426062df0)
2019-11-26 17:18:17 +00:00
Ram Muthiah
6d88dbc147 ANDROID: gki_defconfig: removed CONFIG_PM_WAKELOCKS
Change-Id: I9ff74aea38ee20815d9e0cb2b81ebbb2dae6dd7b
Signed-off-by: Ram Muthiah <rammuthiah@google.com>
Bug: 143710295
Bug: 115946999
Test: Treehugger
2019-11-26 00:01:36 +00:00
Ram Muthiah
dae312aa80 ANDROID: gki_defconfig: enable CONFIG_IKHEADERS as m
Change-Id: I584b09e1565a1453567e692fdff9e92790b4a29e
Signed-off-by: Ram Muthiah <rammuthiah@google.com>
Bug: 143710295
Test: Treehugger
2019-11-25 22:22:43 +00:00
Matthias Maennich
fa4d49ae74 ANDROID: update ABI representation
3 Removed functions:

  [D] 'function int of_phandle_iterator_args(of_phandle_iterator*, uint32_t*, int)'
  [D] 'function int pci_for_each_dma_alias(pci_dev*, void ()*, void*)'
  [D] 'function void pci_request_acs()'

Fixes: e739da6595 ("Revert "FROMLIST: PCI: Export PCI ACS and DMA searching functions to modules"")
Fixes: ef78faff0a ("Revert "FROMLIST: of: Export of_phandle_iterator_args() to modules"")
Change-Id: Ib39f875c120ec9241fd971fa7877ede48ec33437
Signed-off-by: Matthias Maennich <maennich@google.com>
2019-11-25 22:07:34 +00:00
Elliot Berman
adcba6dd6d FROMLIST: reboot: Export reboot_mode
Export reboot_mode to support kernel modules wishing to modify reboot_mode.

Change-Id: I8d25aec75331a57fab85c12b8527a329e2a4f19d
Bug: 143964928
Link: https://lore.kernel.org/patchwork/patch/1151092/
Signed-off-by: Elliot Berman <eberman@codeaurora.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-25 11:46:31 -08:00
Will Deacon
6b1859f66a FROMLIST: iommu/arm-smmu: Update my email address in MODULE_AUTHOR()
I no longer work for Arm, so update the stale reference to my old email
address.

Signed-off-by: Will Deacon <will@kernel.org>
Bug: 140290589
Link: https://lore.kernel.org/lkml/20191121114918.2293-15-will@kernel.org/
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I7676e5f736fcb31376444bbfee419bc49ef17287
2019-11-25 11:36:23 -08:00
Will Deacon
c0b8722cbd FROMLIST: iommu/arm-smmu: Allow building as a module
By conditionally dropping support for the legacy binding and exporting
the newly introduced 'arm_smmu_impl_init()' function we can allow the
ARM SMMU driver to be built as a module.

Signed-off-by: Will Deacon <will@kernel.org>
Bug: 140290589
Link: https://lore.kernel.org/lkml/20191121114918.2293-14-will@kernel.org/
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Id42da5829cb180966a0d051ec636be0c9f90efed
2019-11-25 11:36:23 -08:00
Will Deacon
80523d05db FROMLIST: iommu/arm-smmu: Unregister IOMMU and bus ops on device removal
When removing the SMMU driver, we need to clear any state that we
registered during probe. This includes our bus ops, sysfs entries and
the IOMMU device registered for early firmware probing of masters.

Signed-off-by: Will Deacon <will@kernel.org>
Bug: 140290589
Link: https://lore.kernel.org/lkml/20191121114918.2293-13-will@kernel.org/
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I5dd6e68a609ac60bc704f9f916acc0f31dc1bd67
2019-11-25 11:36:22 -08:00
Will Deacon
6d83d361e7 FROMLIST: iommu/arm-smmu-v3: Allow building as a module
By removing the redundant call to 'pci_request_acs()' we can allow the
ARM SMMUv3 driver to be built as a module.

Signed-off-by: Will Deacon <will@kernel.org>
Bug: 140290589
Link: https://lore.kernel.org/lkml/20191121114918.2293-12-will@kernel.org/
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I1d8fbe26ab7114af6409ea13a68fff8afed49703
2019-11-25 11:36:22 -08:00
Will Deacon
3a50680709 FROMLIST: iommu/arm-smmu-v3: Unregister IOMMU and bus ops on device removal
When removing the SMMUv3 driver, we need to clear any state that we
registered during probe. This includes our bus ops, sysfs entries and
the IOMMU device registered for early firmware probing of masters.

Signed-off-by: Will Deacon <will@kernel.org>
Bug: 140290589
Link: https://lore.kernel.org/lkml/20191121114918.2293-11-will@kernel.org/
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I54372d917c871231ced86250498fe2e45cf39246
2019-11-25 11:36:22 -08:00
Will Deacon
e83861a6a0 FROMLIST: iommu/arm-smmu: Prevent forced unbinding of Arm SMMU drivers
Forcefully unbinding the Arm SMMU drivers is a pretty dangerous operation,
since it will likely lead to catastrophic failure for any DMA devices
mastering through the SMMU being unbound. When the driver then attempts
to "handle" the fatal faults, it's very easy to trip over dead data
structures, leading to use-after-free.

On John's machine, he reports that the machine was "unusable" due to
loss of the storage controller following a forced unbind of the SMMUv3
driver:

  | # cd ./bus/platform/drivers/arm-smmu-v3
  | # echo arm-smmu-v3.0.auto > unbind
  | hisi_sas_v2_hw HISI0162:01: CQE_AXI_W_ERR (0x800) found!
  | platform arm-smmu-v3.0.auto: CMD_SYNC timeout at 0x00000146
  | [hwprod 0x00000146, hwcons 0x00000000]

Prevent this forced unbinding of the drivers by setting "suppress_bind_attrs"
to true.

Link: https://lore.kernel.org/lkml/06dfd385-1af0-3106-4cc5-6a5b8e864759@huawei.com
Reported-by: John Garry <john.garry@huawei.com>
Signed-off-by: Will Deacon <will@kernel.org>
Bug: 140290589
Link: https://lore.kernel.org/lkml/20191121114918.2293-10-will@kernel.org/
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I8b1c439f7ba11d6fc38cdf686948ef5909871dfb
2019-11-25 11:36:22 -08:00
Will Deacon
1100adc953 FROMLIST: Revert "iommu/arm-smmu: Make arm-smmu explicitly non-modular"
This reverts commit addb672f20.

Let's get the SMMU driver building as a module, which means putting
back some dead code that we used to carry.

Signed-off-by: Will Deacon <will@kernel.org>
Bug: 140290589
Link: https://lore.kernel.org/lkml/20191121114918.2293-9-will@kernel.org/
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I9779ffa7befa8535a0d7196ef5f728e40ae7d7f7
2019-11-25 11:36:21 -08:00
Will Deacon
b4c5814630 FROMLIST: Revert "iommu/arm-smmu: Make arm-smmu-v3 explicitly non-modular"
This reverts commit c07b6426df.

Let's get the SMMUv3 driver building as a module, which means putting
back some dead code that we used to carry.

Signed-off-by: Will Deacon <will@kernel.org>
Bug: 140290589
Link: https://lore.kernel.org/lkml/20191121114918.2293-8-will@kernel.org/
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Ifde3c5dc81a0db600532b305906c67aa065d2f47
2019-11-25 11:36:21 -08:00
Will Deacon
3acf4223bd FROMLIST: drivers/iommu: Allow IOMMU bus ops to be unregistered
'bus_set_iommu()' allows IOMMU drivers to register their ops for a given
bus type. Unfortunately, it then doesn't allow them to be removed, which
is necessary for modular drivers to shutdown cleanly so that they can be
reloaded later on.

Allow 'bus_set_iommu()' to take a NULL 'ops' argument, which clear the
ops pointer for the selected bus_type.

Signed-off-by: Will Deacon <will@kernel.org>
Bug: 140290589
Link: https://lore.kernel.org/lkml/20191121114918.2293-7-will@kernel.org/
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Ia89fa2df61d2a9ad04901d4c2e71e293c4c6171d
2019-11-25 11:36:21 -08:00
Will Deacon
ce9777db25 FROMLIST: iommu/of: Take a ref to the IOMMU driver during ->of_xlate()
Ensure that we hold a reference to the IOMMU driver module while calling
the '->of_xlate()' callback during early device probing.

Signed-off-by: Will Deacon <will@kernel.org>
Bug: 140290589
Link: https://lore.kernel.org/lkml/20191121114918.2293-6-will@kernel.org/
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Ica9ef2d5ed172c2451c0a19538dc28852c2270d5
2019-11-25 11:36:21 -08:00
Will Deacon
dfb7124564 FROMLIST: drivers/iommu: Take a ref to the IOMMU driver prior to ->add_device()
To avoid accidental removal of an active IOMMU driver module, take a
reference to the driver module in 'iommu_probe_device()' immediately
prior to invoking the '->add_device()' callback and hold it until the
after the device has been removed by '->remove_device()'.

Suggested-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Will Deacon <will@kernel.org>
Bug: 140290589
Link: https://lore.kernel.org/lkml/20191121114918.2293-5-will@kernel.org/
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I8f6a8aad8c41faa51df9c3a440c8b80c74e3ce8a
2019-11-25 11:36:20 -08:00
Will Deacon
5f67aa9980 FROMLIST: PCI: Export pci_ats_disabled() as a GPL symbol to modules
Building drivers for ATS-aware IOMMUs as modules requires access to
pci_ats_disabled(). Export it as a GPL symbol to get things working.

Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
Bug: 140290589
Link: https://lore.kernel.org/lkml/20191121114918.2293-4-will@kernel.org/
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Ia5457fd6c4593565799b97f40c0def3558a97696
2019-11-25 11:36:20 -08:00
Will Deacon
c5ce06fdc0 FROMLIST: iommu/of: Request ACS from the PCI core when configuring IOMMU linkage
To avoid having to export 'pci_request_acs()' to modular IOMMU drivers,
move the call into the 'of_dma_configure()' path in a similar manner to
the way in which ACS is configured when probing via ACPI/IORT.

Signed-off-by: Will Deacon <will@kernel.org>
Bug: 140290589
Link: https://lore.kernel.org/lkml/20191121114918.2293-3-will@kernel.org/
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I3c689845ca493fbe037a2def2050a089036fb7d3
2019-11-25 11:36:20 -08:00
Will Deacon
91740f1937 FROMLIST: drivers/iommu: Export core IOMMU API symbols to permit modular drivers
Building IOMMU drivers as modules requires that the core IOMMU API
symbols are exported as GPL symbols.

Signed-off-by: Will Deacon <will@kernel.org>
Bug: 140290589
Link: https://lore.kernel.org/lkml/20191121114918.2293-2-will@kernel.org/
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Ic1b3b5e6e92c5852af1e3473dd230c506b8d7865
2019-11-25 11:36:19 -08:00
Will Deacon
b0367de0dd FROMGIT: of: property: Add device link support for "iommu-map"
Commit 8e12257dead7 ("of: property: Add device link support for iommus,
mboxes and io-channels") added device link support for IOMMU linkages
described using the "iommus" property. For PCI devices, this property
is not present and instead the "iommu-map" property is used on the host
bridge node to map the endpoint RequesterIDs to their corresponding
IOMMU instance.

Add support for "iommu-map" to the device link supplier bindings so that
probing of PCI devices can be deferred until after the IOMMU is
available.

Cc: Rob Herring <robh@kernel.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>
Acked-by: Saravana Kannan <saravanak@google.com>
Link: https://lore.kernel.org/r/20191120190028.4722-1-will@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry-picked from commit e149573b2f84d0517648dafc0db625afa681ed54
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git driver-core-next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: Ife0cf1ed0256af47ed0cae7156f3184de355c42c
2019-11-25 11:36:19 -08:00
Will Deacon
a5fe6fd6ae Revert "FROMLIST: iommu: Export core IOMMU functions to kernel modules"
This reverts commit 82047fdd5d.

Superseded by arm-smmu changes posted upstream.

Change-Id: If4c2c29195ed2350803c5ca2b4d63d9a84682ed8
Signed-off-by: Will Deacon <willdeacon@google.com>
2019-11-25 11:36:19 -08:00
Will Deacon
e739da6595 Revert "FROMLIST: PCI: Export PCI ACS and DMA searching functions to modules"
This reverts commit c32fef399d.

Superseded by arm-smmu changes posted upstream.

Change-Id: Ib582a4f4da27fe9297e61a0228e14a7929cea6ef
Signed-off-by: Will Deacon <willdeacon@google.com>
2019-11-25 11:36:19 -08:00
Will Deacon
ef78faff0a Revert "FROMLIST: of: Export of_phandle_iterator_args() to modules"
This reverts commit ebc7824f47.

Superseded by arm-smmu changes posted upstream.

Change-Id: I7710d1fde8afd91e05d911c87e3443e8301593d0
Signed-off-by: Will Deacon <willdeacon@google.com>
2019-11-25 11:36:18 -08:00
Matthias Maennich
99721e2f1a ANDROID: initial branch preparations for 5.4
Adjust defconfigs, build.config and initial ABI representation.

Change-Id: I3c859b8a05d35eb3bfd801a04e797ee769f874ee
Signed-off-by: Matthias Maennich <maennich@google.com>
2019-11-25 17:01:07 +00:00
Greg Kroah-Hartman
54e301676a Linux 5.4
-----BEGIN PGP SIGNATURE-----
 
 iQFSBAABCAA8FiEEq68RxlopcLEwq+PEeb4+QwBBGIYFAl3bIQceHHRvcnZhbGRz
 QGxpbnV4LWZvdW5kYXRpb24ub3JnAAoJEHm+PkMAQRiG8mUIAIjMARdI6Fc6Hrwo
 oVAFQU8BY/OB49NbKYCaXMi1AbMv0+f32jEmdcHj4AQa+Dq8owc1pOB2o+iTLrCq
 PWf6t1wjHtPVmkZ+lWGDFT74IBMCZ8M0dgN9rYBUbno09/B9cqN4ttjTrGjTgkGe
 yw4qTzeflZaMSIzvy+nZD8RM9bXsFJUncD/M759ElPj1p7Tdx29c05+e46pYOh7i
 A6QaSMZT2xKHDIDfU1rQhvyrzAX4cF1LtbSNu7GAG7Ajnn3jfxXqUzZdl5r5j04W
 ee+AXER4VXDlq+2fN7/jlGa4kxiZZDX/FqRnS6dsrb+2sNCKlnETI+6a9/dO0zsI
 wzBh36o=
 =0TWn
 -----END PGP SIGNATURE-----

Merge 5.4 into android-mainline

Linux 5.4

Here we go!

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Iee409f3bbf65b93fa419e5b09818efb8e56569fd
2019-11-25 09:57:21 +01:00
Linus Torvalds
219d54332a Linux 5.4 2019-11-24 16:32:01 -08:00
Linus Torvalds
b8387f6f34 Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull cramfs fix from Al Viro:
 "Regression fix, fallen through the cracks"

* 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  cramfs: fix usage on non-MTD device
2019-11-24 12:36:39 -08:00