#include <asm/facility.h>
 #include <asm/lowcore.h>
 #include <asm/sclp.h>
+#include "boot.h"
 
 /*
  * The code within this file will be called very early. It may _not_
        *str = '\0';
 }
 
-static void print_missing_facilities(void)
+void print_missing_facilities(void)
 {
        static char als_str[80] = "Missing facilities: ";
        unsigned long val;
        }
        strcat(als_str, "\n");
        sclp_early_printk(als_str);
-       sclp_early_printk("See Principles of Operations for facility bits\n");
 }
 
 static void facility_mismatch(void)
        sclp_early_printk("The Linux kernel requires more recent processor hardware\n");
        print_machine_type();
        print_missing_facilities();
+       sclp_early_printk("See Principles of Operations for facility bits\n");
        disabled_wait(0x8badcccc);
 }
 
 
 void setup_boot_command_line(void);
 void parse_boot_command_line(void);
 void setup_memory_end(void);
+void print_missing_facilities(void);
 
 #endif /* BOOT_BOOT_H */
 
 // SPDX-License-Identifier: GPL-2.0
+#include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/ctype.h>
 #include <asm/ebcdic.h>
                __set_facility(nr, S390_lowcore.stfle_fac_list);
 }
 
+static void check_cleared_facilities(void)
+{
+       unsigned long als[] = { FACILITIES_ALS };
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(als); i++) {
+               if ((S390_lowcore.stfle_fac_list[i] & als[i]) != als[i]) {
+                       sclp_early_printk("Warning: The Linux kernel requires facilities cleared via command line option\n");
+                       print_missing_facilities();
+                       break;
+               }
+       }
+}
+
 static void modify_fac_list(char *str)
 {
        unsigned long val, endval;
                        break;
                str++;
        }
+       check_cleared_facilities();
 }
 
 static char command_line_buf[COMMAND_LINE_SIZE] __section(.data);