Skip to content

Commit 6ce56e1

Browse files
ldu4mpe
authored andcommitted
powerpc/pseries: export LPAR security flavor in lparcfg
This is helpful to read the security flavor from inside the LPAR. In /sys/kernel/debug/powerpc/security_features it can be seen if mitigations are on or off but not the level set through the ASMI menu. Furthermore, reporting it through /proc/powerpc/lparcfg allows an easy processing by the lparstat command [1]. Export it like this in /proc/powerpc/lparcfg: $ grep security_flavor /proc/powerpc/lparcfg security_flavor=1 Value follows what is documented on the IBM support page [2]: 0 Speculative execution fully enabled 1 Speculative execution controls to mitigate user-to-kernel attacks 2 Speculative execution controls to mitigate user-to-kernel and user-to-user side-channel attacks [1] https://groups.google.com/g/powerpc-utils-devel/c/NaKXvdyl_UI/m/wa2stpIDAQAJ [2] https://www.ibm.com/support/pages/node/715841 Signed-off-by: Laurent Dufour <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 90cbac0 commit 6ce56e1

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

arch/powerpc/include/asm/hvcall.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@
389389
#define H_CPU_BEHAV_FAVOUR_SECURITY (1ull << 63) // IBM bit 0
390390
#define H_CPU_BEHAV_L1D_FLUSH_PR (1ull << 62) // IBM bit 1
391391
#define H_CPU_BEHAV_BNDS_CHK_SPEC_BAR (1ull << 61) // IBM bit 2
392+
#define H_CPU_BEHAV_FAVOUR_SECURITY_H (1ull << 60) // IBM bit 3
392393
#define H_CPU_BEHAV_FLUSH_COUNT_CACHE (1ull << 58) // IBM bit 5
393394
#define H_CPU_BEHAV_FLUSH_LINK_STACK (1ull << 57) // IBM bit 6
394395

arch/powerpc/platforms/pseries/lparcfg.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
537537
parse_em_data(m);
538538
maxmem_data(m);
539539

540+
seq_printf(m, "security_flavor=%u\n", pseries_security_flavor);
541+
540542
return 0;
541543
}
542544

arch/powerpc/platforms/pseries/pseries.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ static inline unsigned long cmo_get_page_size(void)
108108

109109
int dlpar_workqueue_init(void);
110110

111+
extern u32 pseries_security_flavor;
111112
void pseries_setup_security_mitigations(void);
112113
void pseries_lpar_read_hblkrm_characteristics(void);
113114

arch/powerpc/platforms/pseries/setup.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ EXPORT_SYMBOL(CMO_PageSize);
8686

8787
int fwnmi_active; /* TRUE if an FWNMI handler is present */
8888
int ibm_nmi_interlock_token;
89+
u32 pseries_security_flavor;
8990

9091
static void pSeries_show_cpuinfo(struct seq_file *m)
9192
{
@@ -535,9 +536,15 @@ static void init_cpu_char_feature_flags(struct h_cpu_char_result *result)
535536
/*
536537
* The features below are enabled by default, so we instead look to see
537538
* if firmware has *disabled* them, and clear them if so.
539+
* H_CPU_BEHAV_FAVOUR_SECURITY_H could be set only if
540+
* H_CPU_BEHAV_FAVOUR_SECURITY is.
538541
*/
539542
if (!(result->behaviour & H_CPU_BEHAV_FAVOUR_SECURITY))
540543
security_ftr_clear(SEC_FTR_FAVOUR_SECURITY);
544+
else if (result->behaviour & H_CPU_BEHAV_FAVOUR_SECURITY_H)
545+
pseries_security_flavor = 1;
546+
else
547+
pseries_security_flavor = 2;
541548

542549
if (!(result->behaviour & H_CPU_BEHAV_L1D_FLUSH_PR))
543550
security_ftr_clear(SEC_FTR_L1D_FLUSH_PR);

0 commit comments

Comments
 (0)