68
68
#include <asm/plpar_wrappers.h>
69
69
#include <asm/kexec.h>
70
70
#include <asm/isa-bridge.h>
71
+ #include <asm/security_features.h>
71
72
72
73
#include "pseries.h"
73
74
@@ -459,6 +460,40 @@ static void __init find_and_init_phbs(void)
459
460
of_pci_check_probe_only ();
460
461
}
461
462
463
+ static void init_cpu_char_feature_flags (struct h_cpu_char_result * result )
464
+ {
465
+ if (result -> character & H_CPU_CHAR_SPEC_BAR_ORI31 )
466
+ security_ftr_set (SEC_FTR_SPEC_BAR_ORI31 );
467
+
468
+ if (result -> character & H_CPU_CHAR_BCCTRL_SERIALISED )
469
+ security_ftr_set (SEC_FTR_BCCTRL_SERIALISED );
470
+
471
+ if (result -> character & H_CPU_CHAR_L1D_FLUSH_ORI30 )
472
+ security_ftr_set (SEC_FTR_L1D_FLUSH_ORI30 );
473
+
474
+ if (result -> character & H_CPU_CHAR_L1D_FLUSH_TRIG2 )
475
+ security_ftr_set (SEC_FTR_L1D_FLUSH_TRIG2 );
476
+
477
+ if (result -> character & H_CPU_CHAR_L1D_THREAD_PRIV )
478
+ security_ftr_set (SEC_FTR_L1D_THREAD_PRIV );
479
+
480
+ if (result -> character & H_CPU_CHAR_COUNT_CACHE_DISABLED )
481
+ security_ftr_set (SEC_FTR_COUNT_CACHE_DISABLED );
482
+
483
+ /*
484
+ * The features below are enabled by default, so we instead look to see
485
+ * if firmware has *disabled* them, and clear them if so.
486
+ */
487
+ if (!(result -> character & H_CPU_BEHAV_FAVOUR_SECURITY ))
488
+ security_ftr_clear (SEC_FTR_FAVOUR_SECURITY );
489
+
490
+ if (!(result -> character & H_CPU_BEHAV_L1D_FLUSH_PR ))
491
+ security_ftr_clear (SEC_FTR_L1D_FLUSH_PR );
492
+
493
+ if (!(result -> character & H_CPU_BEHAV_BNDS_CHK_SPEC_BAR ))
494
+ security_ftr_clear (SEC_FTR_BNDS_CHK_SPEC_BAR );
495
+ }
496
+
462
497
void pseries_setup_rfi_flush (void )
463
498
{
464
499
struct h_cpu_char_result result ;
@@ -472,6 +507,8 @@ void pseries_setup_rfi_flush(void)
472
507
473
508
rc = plpar_get_cpu_characteristics (& result );
474
509
if (rc == H_SUCCESS ) {
510
+ init_cpu_char_feature_flags (& result );
511
+
475
512
if (result .character & H_CPU_CHAR_L1D_FLUSH_TRIG2 )
476
513
types |= L1D_FLUSH_MTTRIG ;
477
514
if (result .character & H_CPU_CHAR_L1D_FLUSH_ORI30 )
@@ -482,6 +519,12 @@ void pseries_setup_rfi_flush(void)
482
519
enable = false;
483
520
}
484
521
522
+ /*
523
+ * We're the guest so this doesn't apply to us, clear it to simplify
524
+ * handling of it elsewhere.
525
+ */
526
+ security_ftr_clear (SEC_FTR_L1D_FLUSH_HV );
527
+
485
528
setup_rfi_flush (types , enable );
486
529
}
487
530
0 commit comments