#include <linux/genhd.h>
#include <linux/ktime.h>
#include <trace/events/power.h>
+#include <linux/security.h>
+#include <linux/efi.h>
#include "power.h"
return -EPERM;
}
+ if (get_securelevel() > 0) {
+ return -EPERM;
+ }
+
lock_system_sleep();
/* The snapshot device should not be opened while we're running */
if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
/*
* If the user said "noresume".. bail out early.
*/
- if (noresume || !hibernation_available())
+ if (noresume || !hibernation_available() || get_securelevel() > 0)
return 0;
/*
if (!hibernation_available())
return sprintf(buf, "[disabled]\n");
+ if (efi_enabled(EFI_SECURE_BOOT)) {
+ buf += sprintf(buf, "[%s]\n", "disabled");
+ return buf-start;
+ }
+
for (i = HIBERNATION_FIRST; i <= HIBERNATION_MAX; i++) {
if (!hibernation_modes[i])
continue;
if (!hibernation_available())
return -EPERM;
+ if (get_securelevel() > 0)
+ return -EPERM;
+
p = memchr(buf, '\n', n);
len = p ? p - buf : n;
#include <linux/workqueue.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
+#include <linux/efi.h>
#include "power.h"
s += sprintf(s,"%s ", pm_states[i]);
#endif
- if (hibernation_available())
- s += sprintf(s, "disk ");
+ if (hibernation_available()) {
+ if (!efi_enabled(EFI_SECURE_BOOT)) {
+ s += sprintf(s, "disk ");
+ } else {
+ s += sprintf(s, "\n");
+ }
+ }
if (s != buf)
/* convert the last space to a newline */
*(s-1) = '\n';