diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index ba2056b35910..5466a30d1ec4 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -60,12 +61,12 @@ enum fault_type { GMAP_FAULT, }; -static unsigned long store_indication __read_mostly; +static DEFINE_STATIC_KEY_FALSE(have_store_indication); static int __init fault_init(void) { if (test_facility(75)) - store_indication = 0xc00; + static_branch_enable(&have_store_indication); return 0; } early_initcall(fault_init); @@ -104,11 +105,13 @@ static unsigned long get_fault_address(struct pt_regs *regs) return trans_exc_code & __FAIL_ADDR_MASK; } -static bool fault_is_write(struct pt_regs *regs) +static __always_inline bool fault_is_write(struct pt_regs *regs) { unsigned long trans_exc_code = regs->int_parm_long; - return (trans_exc_code & store_indication) == 0x400; + if (static_branch_likely(&have_store_indication)) + return (trans_exc_code & 0xc00) == 0x400; + return false; } static int bad_address(void *p)