secureboot.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* Core kernel secure boot support.
  2. *
  3. * Copyright (C) 2017 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  12. #include <linux/efi.h>
  13. #include <linux/kernel.h>
  14. #include <linux/printk.h>
  15. /*
  16. * Decide what to do when UEFI secure boot mode is enabled.
  17. */
  18. void __init efi_set_secure_boot(enum efi_secureboot_mode mode)
  19. {
  20. if (efi_enabled(EFI_BOOT)) {
  21. switch (mode) {
  22. case efi_secureboot_mode_disabled:
  23. pr_info("Secure boot disabled\n");
  24. break;
  25. case efi_secureboot_mode_enabled:
  26. set_bit(EFI_SECURE_BOOT, &efi.flags);
  27. pr_info("Secure boot enabled\n");
  28. break;
  29. default:
  30. pr_warning("Secure boot could not be determined (mode %u)\n",
  31. mode);
  32. break;
  33. }
  34. }
  35. }