1. 11 8月, 2016 1 次提交
  2. 04 8月, 2016 1 次提交
    • M
      tree-wide: replace config_enabled() with IS_ENABLED() · 97f2645f
      Masahiro Yamada 提交于
      The use of config_enabled() against config options is ambiguous.  In
      practical terms, config_enabled() is equivalent to IS_BUILTIN(), but the
      author might have used it for the meaning of IS_ENABLED().  Using
      IS_ENABLED(), IS_BUILTIN(), IS_MODULE() etc.  makes the intention
      clearer.
      
      This commit replaces config_enabled() with IS_ENABLED() where possible.
      This commit is only touching bool config options.
      
      I noticed two cases where config_enabled() is used against a tristate
      option:
      
       - config_enabled(CONFIG_HWMON)
        [ drivers/net/wireless/ath/ath10k/thermal.c ]
      
       - config_enabled(CONFIG_BACKLIGHT_CLASS_DEVICE)
        [ drivers/gpu/drm/gma500/opregion.c ]
      
      I did not touch them because they should be converted to IS_BUILTIN()
      in order to keep the logic, but I was not sure it was the authors'
      intention.
      
      Link: http://lkml.kernel.org/r/1465215656-20569-1-git-send-email-yamada.masahiro@socionext.comSigned-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: NKees Cook <keescook@chromium.org>
      Cc: Stas Sergeev <stsp@list.ru>
      Cc: Matt Redfearn <matt.redfearn@imgtec.com>
      Cc: Joshua Kinard <kumba@gentoo.org>
      Cc: Jiri Slaby <jslaby@suse.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Markos Chandras <markos.chandras@imgtec.com>
      Cc: "Dmitry V. Levin" <ldv@altlinux.org>
      Cc: yu-cheng yu <yu-cheng.yu@intel.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Johannes Berg <johannes@sipsolutions.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Will Drewry <wad@chromium.org>
      Cc: Nikolay Martynov <mar.kolya@gmail.com>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
      Cc: Rafal Milecki <zajec5@gmail.com>
      Cc: James Cowgill <James.Cowgill@imgtec.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Alex Smith <alex.smith@imgtec.com>
      Cc: Adam Buchbinder <adam.buchbinder@gmail.com>
      Cc: Qais Yousef <qais.yousef@imgtec.com>
      Cc: Jiang Liu <jiang.liu@linux.intel.com>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Brian Norris <computersforpeace@gmail.com>
      Cc: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
      Cc: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
      Cc: Roland McGrath <roland@hack.frob.com>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: Kalle Valo <kvalo@qca.qualcomm.com>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Cc: Tony Wu <tung7970@gmail.com>
      Cc: Huaitong Han <huaitong.han@intel.com>
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Jason Cooper <jason@lakedaemon.net>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Andrea Gelmini <andrea.gelmini@gelma.net>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Rabin Vincent <rabin@rab.in>
      Cc: "Maciej W. Rozycki" <macro@imgtec.com>
      Cc: David Daney <david.daney@cavium.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      97f2645f
  3. 22 7月, 2016 1 次提交
  4. 09 7月, 2016 1 次提交
  5. 07 7月, 2016 1 次提交
    • A
      firmware: scpi: add CONFIG_OF dependency · e517dfe6
      Arnd Bergmann 提交于
      We get a harmless warning if the ARM_SCPI_POWER_DOMAIN driver is enabled
      without CONFIG_OF during compile testing:
      
      warning: (ARM_SCPI_POWER_DOMAIN) selects PM_GENERIC_DOMAINS_OF which has unmet direct dependencies (PM_GENERIC_DOMAINS && OF)
      
      There is no need to select PM_GENERIC_DOMAINS_OF if OF is set, so we can
      replace the 'select' with a dependency.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Fixes: 8bec4337 ("firmware: scpi: add device power domain support using genpd")
      Acked-by: NSudeep Holla <sudeep.holla@arm.com>
      e517dfe6
  6. 06 7月, 2016 3 次提交
    • S
      Xen: EFI: Parse DT parameters for Xen specific UEFI · 0cac5c30
      Shannon Zhao 提交于
      The EFI DT parameters for bare metal are located under /chosen node,
      while for Xen Dom0 they are located under /hyperviosr/uefi node. These
      parameters under /chosen and /hyperviosr/uefi are not expected to appear
      at the same time.
      
      Parse these EFI parameters and initialize EFI like the way for bare
      metal except the runtime services because the runtime services for Xen
      Dom0 are available through hypercalls and they are always enabled. So it
      sets the EFI_RUNTIME_SERVICES flag if it finds /hyperviosr/uefi node and
      bails out in arm_enable_runtime_services() when EFI_RUNTIME_SERVICES
      flag is set already.
      Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
      Cc: Stefano Stabellini <sstabellini@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Leif Lindholm <leif.lindholm@linaro.org>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      0cac5c30
    • A
      firmware: qcom: scm: Change initcall to subsys · 6c8e99d8
      Andy Gross 提交于
      The patch changes the initcall for SCM to use subsys_initcall
      instead of arch_initcall.  This corrects the order so that we don't
      probe defer when trying to get clks which causes issues later when
      the spm driver makes calls to qcom_set_warm_boot_addr().
      
      The order became an issue due to the changes to use arch_initcall_sync
      for of_platform_default_populate_init().
      Signed-off-by: NAndy Gross <andy.gross@linaro.org>
      6c8e99d8
    • A
      firmware: qcom_scm: Add missing is_available API · 72d43419
      Andy Gross 提交于
      Add back function that was dropped when reworking the SCM code.
      Signed-off-by: NAndy Gross <andy.gross@linaro.org>
      72d43419
  7. 27 6月, 2016 2 次提交
    • A
      efi: Convert efi_call_virt() to efi_call_virt_pointer() · 80e75596
      Alex Thorlton 提交于
      This commit makes a few slight modifications to the efi_call_virt() macro
      to get it to work with function pointers that are stored in locations
      other than efi.systab->runtime, and renames the macro to
      efi_call_virt_pointer().  The majority of the changes here are to pull
      these macros up into header files so that they can be accessed from
      outside of drivers/firmware/efi/runtime-wrappers.c.
      
      The most significant change not directly related to the code move is to
      add an extra "p" argument into the appropriate efi_call macros, and use
      that new argument in place of the, formerly hard-coded,
      efi.systab->runtime pointer.
      
      The last piece of the puzzle was to add an efi_call_virt() macro back into
      drivers/firmware/efi/runtime-wrappers.c to wrap around the new
      efi_call_virt_pointer() macro - this was mainly to keep the code from
      looking too cluttered by adding a bunch of extra references to
      efi.systab->runtime everywhere.
      
      Note that I also broke up the code in the efi_call_virt_pointer() macro a
      bit in the process of moving it.
      Signed-off-by: NAlex Thorlton <athorlton@sgi.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Dimitri Sivanich <sivanich@sgi.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Roy Franz <roy.franz@linaro.org>
      Cc: Russ Anderson <rja@sgi.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/1466839230-12781-5-git-send-email-matt@codeblueprint.co.ukSigned-off-by: NIngo Molnar <mingo@kernel.org>
      80e75596
    • C
      efibc: Report more information in the error messages · 5356c327
      Compostella, Jeremy 提交于
      Report the name of the EFI variable if the value size is too large,
      or if efibc_set_variable() fails to allocate the 'struct efivar_entry'
      object.
      
      If efibc_set_variable() fails because the 'size' value is too
      large, it also reports this value in the error message.
      Reported-by: NRobert Elliott <elliott@hpe.com>
      Signed-off-by: NJeremy Compostella <jeremy.compostella@intel.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/1466839230-12781-2-git-send-email-matt@codeblueprint.co.uk
      [ Minor readability edits. ]
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      5356c327
  8. 25 6月, 2016 7 次提交
  9. 21 6月, 2016 2 次提交
  10. 13 6月, 2016 3 次提交
  11. 03 6月, 2016 3 次提交
    • D
      efi/arm: Fix the format of EFI debug messages · c7534397
      Dennis Chen 提交于
      When both EFI and memblock debugging is enabled on the kernel command line:
      
        'efi=debug memblock=debug'
      
      .. the debug messages for early_con look the following way:
      
       [    0.000000] efi:   0x0000e1050000-0x0000e105ffff [Memory Mapped I/O  |RUN|  |  |  |  |  |  |   |  |  |  |UC]
       [    0.000000] efi:   0x0000e1300000-0x0000e1300fff [Memory Mapped I/O  |RUN|  |  |  |  |  |  |   |  |  |  |UC]
       [    0.000000] efi:   0x0000e8200000-0x0000e827ffff [Memory Mapped I/O  |RUN|  |  |  |  |  |  |   |  |  |  |UC]
       [    0.000000] efi:   0x008000000000-0x008001e7ffff [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC]
       [    0.000000] memblock_add: [0x00008000000000-0x00008001e7ffff] flags 0x0 early_init_dt_add_memory_arch+0x54/0x5c
       [    0.000000] *
       ...
      
      Note the misplaced '*' line, which happened because the memblock debug message
      was printed while the EFI debug message was still being constructed..
      
      This patch fixes the output to be the expected:
      
       [    0.000000] efi:   0x0000e1050000-0x0000e105ffff [Memory Mapped I/O  |RUN|  |  |  |  |  |  |   |  |  |  |UC]
       [    0.000000] efi:   0x0000e1300000-0x0000e1300fff [Memory Mapped I/O  |RUN|  |  |  |  |  |  |   |  |  |  |UC]
       [    0.000000] efi:   0x0000e8200000-0x0000e827ffff [Memory Mapped I/O  |RUN|  |  |  |  |  |  |   |  |  |  |UC]
       [    0.000000] efi:   0x008000000000-0x008001e7ffff [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC]*
       [    0.000000] memblock_add: [0x00008000000000-0x00008001e7ffff] flags 0x0 early_init_dt_add_memory_arch+0x54/0x5c
       ...
      
      Note how the '*' is now in the proper EFI debug message line.
      Signed-off-by: NDennis Chen <dennis.chen@arm.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mark Salter <msalter@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steve Capper <steve.capper@arm.com>
      Cc: Steve McIntyre <steve@einval.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/1464690224-4503-3-git-send-email-matt@codeblueprint.co.uk
      [ Made the changelog more readable. ]
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      c7534397
    • G
      efi-pstore: implement efivars_pstore_exit() · cae73167
      Geliang Tang 提交于
      The original efivars_pstore_exit() is empty. I
       1) add a bufsize check statement.
       2) call pstore_unregister as it is defined now.
       3) free the memory and set bufsize to 0.
      Signed-off-by: NGeliang Tang <geliangtang@163.com>
      Acked-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      cae73167
    • G
      pstore: add lzo/lz4 compression support · 8cfc8ddc
      Geliang Tang 提交于
      Like zlib compression in pstore, this patch added lzo and lz4
      compression support so that users can have more options and better
      compression ratio.
      
      The original code treats the compressed data together with the
      uncompressed ECC correction notice by using zlib decompress. The
      ECC correction notice is missing in the decompression process. The
      treatment also makes lzo and lz4 not working. So I treat them
      separately by using pstore_decompress() to treat the compressed
      data, and memcpy() to treat the uncompressed ECC correction notice.
      Signed-off-by: NGeliang Tang <geliangtang@163.com>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      8cfc8ddc
  12. 16 5月, 2016 2 次提交
    • D
      ibft: Expose iBFT acpi header via sysfs · b3c8eb50
      David Bond 提交于
      Some ethernet adapter vendors are supplying products which support optional
      (payed license) features. On some adapters this includes a hardware iscsi
      initiator.  The same adapters in a normal (no extra licenses) mode of
      operation can be used as a software iscsi initiator.  In addition, software
      iscsi boot initiators are becoming a standard part of many vendors uefi
      implementations.  This is creating difficulties during early boot/install
      determining the proper configuration method for these adapters when they
      are used as a boot device.
      
      The attached patch creates sysfs entries to expose information from the
      acpi header of the ibft table.  This information allows for a method to
      easily determining if an ibft table was created by a ethernet card's
      firmware or the system uefi/bios.  In the case of a hardware initiator this
      information in combination with the pci vendor and device id can be used
      to ascertain any vendor specific behaviors that need to be accommodated.
      Reviewed-by: NLee Duncan <lduncan@suse.com>
      Signed-off-by: NDavid Bond <dbond@suse.com>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      b3c8eb50
    • H
      iscsi_ibft: Add prefix-len attr and display netmask · 9a99425f
      Hannes Reinecke 提交于
      The iBFT table only specifies a prefix length, not a netmask.
      And the netmask is pretty much pointless for IPv6.
      So introduce a new attribute 'prefix-len'.
      
      Some older user-space code might rely on the netmask attribute
      being present, so we should always display it.
      
      Changes from v1:
       - Combined two patches into one
      
      Changes from v2:
       - Cleaned up/corrected wording for patch description
      Signed-off-by: NHannes Reinecke <hare@suse.de>
      Signed-off-by: NLee Duncan <lduncan@suse.com>
      Reviewed-by: NMike Christie <michaelc@cs.wisc.edu>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad@kernel.org>
      9a99425f
  13. 13 5月, 2016 1 次提交
  14. 07 5月, 2016 4 次提交
    • J
      efi: Merge boolean flag arguments · 1cfd6316
      Julia Lawall 提交于
      The parameters atomic and duplicates of efivar_init always have opposite
      values.  Drop the parameter atomic, replace the uses of !atomic with
      duplicates, and update the call sites accordingly.
      
      The code using duplicates is slightly reorganized with an 'else', to avoid
      duplicating the lock code.
      Signed-off-by: NJulia Lawall <Julia.Lawall@lip6.fr>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jeremy Kerr <jk@ozlabs.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matthew Garrett <mjg59@srcf.ucam.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Saurabh Sengar <saurabh.truth@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vaishali Thakkar <vaishali.thakkar@oracle.com>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/1462570771-13324-5-git-send-email-matt@codeblueprint.co.ukSigned-off-by: NIngo Molnar <mingo@kernel.org>
      1cfd6316
    • M
      efi/capsule: Move 'capsule' to the stack in efi_capsule_supported() · fb7a84ca
      Matt Fleming 提交于
      Dan Carpenter reports that passing the address of the pointer to the
      kmalloc()'d memory for 'capsule' is dangerous:
      
       "drivers/firmware/efi/capsule.c:109 efi_capsule_supported()
        warn: did you mean to pass the address of 'capsule'
      
         108
         109          status = efi.query_capsule_caps(&capsule, 1, &max_size, reset);
                                                      ^^^^^^^^
        If we modify capsule inside this function call then at the end of the
        function we aren't freeing the original pointer that we allocated."
      
      Ard Biesheuvel noted that we don't even need to call kmalloc() since the
      object we allocate isn't very big and doesn't need to persist after the
      function returns.
      
      Place 'capsule' on the stack instead.
      Suggested-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Bryan O'Donoghue <pure.logic@nexus-software.ie>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kweh Hock Leong <hock.leong.kweh@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: joeyli <jlee@suse.com>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/1462570771-13324-4-git-send-email-matt@codeblueprint.co.ukSigned-off-by: NIngo Molnar <mingo@kernel.org>
      fb7a84ca
    • J
      efibc: Fix excessive stack footprint warning · 2e121d71
      Jeremy Compostella 提交于
      GCC complains about a newly added file for the EFI Bootloader Control:
      
        drivers/firmware/efi/efibc.c: In function 'efibc_set_variable':
        drivers/firmware/efi/efibc.c:53:1: error: the frame size of 2272 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
      
      The problem is the declaration of a local variable of type struct
      efivar_entry, which is by itself larger than the warning limit of 1024
      bytes.
      
      Use dynamic memory allocation instead of stack memory for the entry
      object.
      
      This patch also fixes a potential buffer overflow.
      Reported-by: NIngo Molnar <mingo@kernel.org>
      Reported-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJeremy Compostella <jeremy.compostella@intel.com>
      [ Updated changelog to include GCC error ]
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/1462570771-13324-3-git-send-email-matt@codeblueprint.co.ukSigned-off-by: NIngo Molnar <mingo@kernel.org>
      2e121d71
    • M
      efi/capsule: Make efi_capsule_pending() lockless · 62075e58
      Matt Fleming 提交于
      Taking a mutex in the reboot path is bogus because we cannot sleep
      with interrupts disabled, such as when rebooting due to panic(),
      
        BUG: sleeping function called from invalid context at kernel/locking/mutex.c:97
        in_atomic(): 0, irqs_disabled(): 1, pid: 7, name: rcu_sched
        Call Trace:
          dump_stack+0x63/0x89
          ___might_sleep+0xd8/0x120
          __might_sleep+0x49/0x80
          mutex_lock+0x20/0x50
          efi_capsule_pending+0x1d/0x60
          native_machine_emergency_restart+0x59/0x280
          machine_emergency_restart+0x19/0x20
          emergency_restart+0x18/0x20
          panic+0x1ba/0x217
      
      In this case all other CPUs will have been stopped by the time we
      execute the platform reboot code, so 'capsule_pending' cannot change
      under our feet. We wouldn't care even if it could since we cannot wait
      for it complete.
      
      Also, instead of relying on the external 'system_state' variable just
      use a reboot notifier, so we can set 'stop_capsules' while holding
      'capsule_mutex', thereby avoiding a race where system_state is updated
      while we're in the middle of efi_capsule_update_locked() (since CPUs
      won't have been stopped at that point).
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Bryan O'Donoghue <pure.logic@nexus-software.ie>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Kweh Hock Leong <hock.leong.kweh@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: joeyli <jlee@suse.com>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/1462570771-13324-2-git-send-email-matt@codeblueprint.co.ukSigned-off-by: NIngo Molnar <mingo@kernel.org>
      62075e58
  15. 29 4月, 2016 1 次提交
    • A
      arm64: kaslr: increase randomization granularity · 6f26b367
      Ard Biesheuvel 提交于
      Currently, our KASLR implementation randomizes the placement of the core
      kernel at 2 MB granularity. This is based on the arm64 kernel boot
      protocol, which mandates that the kernel is loaded TEXT_OFFSET bytes above
      a 2 MB aligned base address. This requirement is a result of the fact that
      the block size used by the early mapping code may be 2 MB at the most (for
      a 4 KB granule kernel)
      
      But we can do better than that: since a KASLR kernel needs to be relocated
      in any case, we can tolerate a physical misalignment as long as the virtual
      misalignment relative to this 2 MB block size is equal in size, and code to
      deal with this is already in place.
      
      Since we align the kernel segments to 64 KB, let's randomize the physical
      offset at 64 KB granularity as well (unless CONFIG_DEBUG_ALIGN_RODATA is
      enabled). This way, the page table and TLB footprint is not affected.
      
      The higher granularity allows for 5 bits of additional entropy to be used.
      Reviewed-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      6f26b367
  16. 28 4月, 2016 7 次提交
    • M
      efi/runtime-wrappers: Remove ARCH_EFI_IRQ_FLAGS_MASK #ifdef · 0cf0223c
      Mark Rutland 提交于
      Now that arm, arm64, and x86 all provide ARCH_EFI_IRQ_FLAGS_MASK, we can
      get rid of the trivial and now unused implementation of
      efi_call_virt_check_flags().
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Leif Lindholm <leif.lindholm@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/1461614832-17633-41-git-send-email-matt@codeblueprint.co.ukSigned-off-by: NIngo Molnar <mingo@kernel.org>
      0cf0223c
    • M
      efi/runtime-wrappers: Detect firmware IRQ flag corruption · 1d04ba17
      Mark Rutland 提交于
      The UEFI spec allows runtime services to be called with interrupts
      masked or unmasked, and if a runtime service function needs to mask
      interrupts, it must restore the mask to its original state before
      returning (i.e. from the PoV of the OS, this does not change across a
      call). Firmware should never unmask exceptions, as these may then be
      taken by the OS unexpectedly.
      
      Unfortunately, some firmware has been seen to unmask IRQs (and
      potentially other maskable exceptions) across runtime services calls,
      leaving IRQ flags corrupted after returning from a runtime services
      function call. This may be detected by the IRQ tracing code, but often
      goes unnoticed, leaving a potentially disastrous bug hidden.
      
      This patch detects when the IRQ flags are corrupted by an EFI runtime
      services call, logging the call and specific corruption to the console.
      While restoring the expected value of the flags is insufficient to avoid
      problems, we do so to avoid redundant warnings from elsewhere (e.g. IRQ
      tracing).
      
      The set of bits in flags which we want to check is architecture-specific
      (e.g. we want to check FIQ on arm64, but not the zero flag on x86), so
      each arch must provide ARCH_EFI_IRQ_FLAGS_MASK to describe those. In the
      absence of this mask, the check is a no-op, and we redundantly save the
      flags twice, but that will be short-lived as subsequent patches
      will implement this and remove the scaffolding.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Leif Lindholm <leif.lindholm@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/1461614832-17633-37-git-send-email-matt@codeblueprint.co.ukSigned-off-by: NIngo Molnar <mingo@kernel.org>
      1d04ba17
    • M
      efi/runtime-wrappers: Remove redundant #ifdefs · d9c6e1d0
      Mark Rutland 提交于
      Now that all users of the EFI runtime wrappers (arm,arm64,x86) have been
      migrated to the new setup/teardown macros, we don't need to support
      overridden {__,}efi_call_virt() implementations.
      
      This patch removes the unnecessary #ifdefs.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Leif Lindholm <leif.lindholm@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/1461614832-17633-36-git-send-email-matt@codeblueprint.co.ukSigned-off-by: NIngo Molnar <mingo@kernel.org>
      d9c6e1d0
    • M
      efi/runtime-wrappers: Add {__,}efi_call_virt() templates · f51c35f2
      Mark Rutland 提交于
      Currently each architecture must implement two macros, efi_call_virt() and
      __efi_call_virt(), which only differ by the presence or absence of a
      return type. Otherwise, the logic surrounding the call is identical.
      
      As each architecture must define the entire body of each, we can't place
      any generic manipulation (e.g. irq flag validation) in the middle.
      
      This patch adds template implementations of these macros. With these,
      arch code can implement three template macros, avoiding reptition for
      the void/non-void return cases:
      
      * arch_efi_call_virt_setup()
      
        Sets up the environment for the call (e.g. switching page tables,
        allowing kernel-mode use of floating point, if required).
      
      * arch_efi_call_virt()
      
        Performs the call. The last expression in the macro must be the call
        itself, allowing the logic to be shared by the void and non-void
        cases.
      
      * arch_efi_call_virt_teardown()
      
        Restores the usual kernel environment once the call has returned.
      
      While the savings from repition are minimal, we additionally gain the
      ability to add common code around the call with the call environment set
      up. This can be used to detect common firmware issues (e.g. bad irq mask
      management).
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Reviewed-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Leif Lindholm <leif.lindholm@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/1461614832-17633-32-git-send-email-matt@codeblueprint.co.ukSigned-off-by: NIngo Molnar <mingo@kernel.org>
      f51c35f2
    • A
      efi/arm-init: Reserve rather than unmap the memory map for ARM as well · 249f7632
      Ard Biesheuvel 提交于
      Now that ARM has a fully functional memremap() implementation, there is
      no longer a need to remove the UEFI memory map from the linear mapping
      in order to be able to create a permanent mapping for it using generic
      code.
      
      So remove the 'IS_ENABLED(CONFIG_ARM)' conditional we added in:
      
      7cc8cbcf ("efi/arm64: Don't apply MEMBLOCK_NOMAP to UEFI memory map mapping")
      
      ... and revert to using memblock_reserve() for both ARM and arm64.
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Leif Lindholm <leif.lindholm@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/1461614832-17633-31-git-send-email-matt@codeblueprint.co.ukSigned-off-by: NIngo Molnar <mingo@kernel.org>
      249f7632
    • K
      efi: Add misc char driver interface to update EFI firmware · 65117f1a
      Kweh, Hock Leong 提交于
      This patch introduces a kernel module to expose a capsule loader
      interface (misc char device file note) for users to upload capsule
      binaries.
      
      Example:
      
        cat firmware.bin > /dev/efi_capsule_loader
      
      Any upload error will be returned while doing "cat" through file
      operation write() function call.
      Signed-off-by: NKweh, Hock Leong <hock.leong.kweh@intel.com>
      [ Update comments and Kconfig text ]
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Reviewed-by: NBryan O'Donoghue <pure.logic@nexus-software.ie>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Peter Jones <pjones@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: joeyli <jlee@suse.com>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/1461614832-17633-30-git-send-email-matt@codeblueprint.co.ukSigned-off-by: NIngo Molnar <mingo@kernel.org>
      65117f1a
    • M
      efi: Add 'capsule' update support · f0133f3c
      Matt Fleming 提交于
      The EFI capsule mechanism allows data blobs to be passed to the EFI
      firmware. A common use case is performing firmware updates. This patch
      just introduces the main infrastructure for interacting with the
      firmware, and a driver that allows users to upload capsules will come
      in a later patch.
      
      Once a capsule has been passed to the firmware, the next reboot must
      be performed using the ResetSystem() EFI runtime service, which may
      involve overriding the reboot type specified by reboot=. This ensures
      the reset value returned by QueryCapsuleCapabilities() is used to
      reset the system, which is required for the capsule to be processed.
      efi_capsule_pending() is provided for this purpose.
      
      At the moment we only allow a single capsule blob to be sent to the
      firmware despite the fact that UpdateCapsule() takes a 'CapsuleCount'
      parameter. This simplifies the API and shouldn't result in any
      downside since it is still possible to send multiple capsules by
      repeatedly calling UpdateCapsule().
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Bryan O'Donoghue <pure.logic@nexus-software.ie>
      Cc: Kweh Hock Leong <hock.leong.kweh@intel.com>
      Cc: Mark Salter <msalter@redhat.com>
      Cc: Peter Jones <pjones@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: joeyli <jlee@suse.com>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/1461614832-17633-28-git-send-email-matt@codeblueprint.co.ukSigned-off-by: NIngo Molnar <mingo@kernel.org>
      f0133f3c