CC: kbuild-...@lists.01.org
CC: linux-ker...@vger.kernel.org
CC: x...@kernel.org
TO: Andy Lutomirski <l...@kernel.org>
CC: Borislav Petkov <b...@suse.de>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/mm
head:   c46f52231e79af025e2c89e889d69ec20a4c024f
commit: c46f52231e79af025e2c89e889d69ec20a4c024f [14/14] x86/{fault,efi}: Fix 
and rename efi_recover_from_page_fault()
:::::: branch date: 13 hours ago
:::::: commit date: 13 hours ago
config: x86_64-randconfig-m001-20210211 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <l...@intel.com>
Reported-by: Dan Carpenter <dan.carpen...@oracle.com>

smatch warnings:
arch/x86/platform/efi/quirks.c:736 efi_crash_gracefully_on_page_fault() warn: 
ignoring unreachable code.

vim +736 arch/x86/platform/efi/quirks.c

3425d934fc0312 Sai Praneeth    2018-09-11  678  
3425d934fc0312 Sai Praneeth    2018-09-11  679  /*
3425d934fc0312 Sai Praneeth    2018-09-11  680   * If any access by any efi 
runtime service causes a page fault, then,
3425d934fc0312 Sai Praneeth    2018-09-11  681   * 1. If it's 
efi_reset_system(), reboot through BIOS.
3425d934fc0312 Sai Praneeth    2018-09-11  682   * 2. If any other efi runtime 
service, then
3425d934fc0312 Sai Praneeth    2018-09-11  683   *    a. Return error status to 
the efi caller process.
3425d934fc0312 Sai Praneeth    2018-09-11  684   *    b. Disable EFI Runtime 
Services forever and
3425d934fc0312 Sai Praneeth    2018-09-11  685   *    c. Freeze efi_rts_wq and 
schedule new process.
3425d934fc0312 Sai Praneeth    2018-09-11  686   *
3425d934fc0312 Sai Praneeth    2018-09-11  687   * @return: Returns, if the 
page fault is not handled. This function
3425d934fc0312 Sai Praneeth    2018-09-11  688   * will never return if the 
page fault is handled successfully.
3425d934fc0312 Sai Praneeth    2018-09-11  689   */
c46f52231e79af Andy Lutomirski 2021-02-09  690  void 
efi_crash_gracefully_on_page_fault(unsigned long phys_addr)
3425d934fc0312 Sai Praneeth    2018-09-11  691  {
3425d934fc0312 Sai Praneeth    2018-09-11  692          if 
(!IS_ENABLED(CONFIG_X86_64))
3425d934fc0312 Sai Praneeth    2018-09-11  693                  return;
3425d934fc0312 Sai Praneeth    2018-09-11  694  
c46f52231e79af Andy Lutomirski 2021-02-09  695          /*
c46f52231e79af Andy Lutomirski 2021-02-09  696           * If we get an 
interrupt/NMI while processing an EFI runtime service
c46f52231e79af Andy Lutomirski 2021-02-09  697           * then this is a 
regular OOPS, not an EFI failure.
c46f52231e79af Andy Lutomirski 2021-02-09  698           */
c46f52231e79af Andy Lutomirski 2021-02-09  699          if (in_interrupt())
c46f52231e79af Andy Lutomirski 2021-02-09  700                  return;
c46f52231e79af Andy Lutomirski 2021-02-09  701  
3425d934fc0312 Sai Praneeth    2018-09-11  702          /*
3425d934fc0312 Sai Praneeth    2018-09-11  703           * Make sure that an 
efi runtime service caused the page fault.
c46f52231e79af Andy Lutomirski 2021-02-09  704           * READ_ONCE() because 
we might be OOPSing in a different thread,
c46f52231e79af Andy Lutomirski 2021-02-09  705           * and we don't want to 
trip KTSAN while trying to OOPS.
3425d934fc0312 Sai Praneeth    2018-09-11  706           */
c46f52231e79af Andy Lutomirski 2021-02-09  707          if 
(READ_ONCE(efi_rts_work.efi_rts_id) == EFI_NONE ||
c46f52231e79af Andy Lutomirski 2021-02-09  708              current_work() != 
&efi_rts_work.work)
3425d934fc0312 Sai Praneeth    2018-09-11  709                  return;
3425d934fc0312 Sai Praneeth    2018-09-11  710  
3425d934fc0312 Sai Praneeth    2018-09-11  711          /*
3425d934fc0312 Sai Praneeth    2018-09-11  712           * Address range 0x0000 
- 0x0fff is always mapped in the efi_pgd, so
3425d934fc0312 Sai Praneeth    2018-09-11  713           * page faulting on 
these addresses isn't expected.
3425d934fc0312 Sai Praneeth    2018-09-11  714           */
919aef44d73d5d Qian Cai        2019-06-19  715          if (phys_addr <= 0x0fff)
3425d934fc0312 Sai Praneeth    2018-09-11  716                  return;
3425d934fc0312 Sai Praneeth    2018-09-11  717  
3425d934fc0312 Sai Praneeth    2018-09-11  718          /*
3425d934fc0312 Sai Praneeth    2018-09-11  719           * Print stack trace as 
it might be useful to know which EFI Runtime
3425d934fc0312 Sai Praneeth    2018-09-11  720           * Service is buggy.
3425d934fc0312 Sai Praneeth    2018-09-11  721           */
3425d934fc0312 Sai Praneeth    2018-09-11  722          WARN(1, FW_BUG "Page 
fault caused by firmware at PA: 0x%lx\n",
3425d934fc0312 Sai Praneeth    2018-09-11  723               phys_addr);
3425d934fc0312 Sai Praneeth    2018-09-11  724  
3425d934fc0312 Sai Praneeth    2018-09-11  725          /*
3425d934fc0312 Sai Praneeth    2018-09-11  726           * Buggy 
efi_reset_system() is handled differently from other EFI
3425d934fc0312 Sai Praneeth    2018-09-11  727           * Runtime Services as 
it doesn't use efi_rts_wq. Although,
3425d934fc0312 Sai Praneeth    2018-09-11  728           * 
native_machine_emergency_restart() says that machine_real_restart()
3425d934fc0312 Sai Praneeth    2018-09-11  729           * could fail, it's 
better not to compilcate this fault handler
3425d934fc0312 Sai Praneeth    2018-09-11  730           * because this case 
occurs *very* rarely and hence could be improved
3425d934fc0312 Sai Praneeth    2018-09-11  731           * on a need by basis.
3425d934fc0312 Sai Praneeth    2018-09-11  732           */
5c418dc789a389 Anders Roxell   2019-02-15  733          if 
(efi_rts_work.efi_rts_id == EFI_RESET_SYSTEM) {
3425d934fc0312 Sai Praneeth    2018-09-11  734                  
pr_info("efi_reset_system() buggy! Reboot through BIOS\n");
3425d934fc0312 Sai Praneeth    2018-09-11  735                  
machine_real_restart(MRR_BIOS);
3425d934fc0312 Sai Praneeth    2018-09-11 @736                  return;

:::::: The code at line 736 was first introduced by commit
:::::: 3425d934fc0312f62024163736a7afe4de20c10f efi/x86: Handle page faults 
occurring while running EFI runtime services

:::::: TO: Sai Praneeth <sai.praneeth.prak...@intel.com>
:::::: CC: Ard Biesheuvel <ard.biesheu...@linaro.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to