From: Nicholas Piggin <npiggin@gmail.com> Date: 2021-05-03 13:03:25
This series adds a few missing bits added to recent pseries
H_GET_CPU_CHARACTERISTICS and implements them, also removes
a restriction from powernv for some of the flushes.
This is tested mianly in qemu where I just submitted a patch
that adds support for these bits (not upstream yet).
Nicholas Piggin (4):
powerpc/pseries: Get entry and uaccess flush required bits from
H_GET_CPU_CHARACTERISTICS
powerpc/security: Add a security feature for STF barrier
powerpc/pesries: Get STF barrier requirement from
H_GET_CPU_CHARACTERISTICS
powerpc/powernv: Remove POWER9 PVR version check for entry and uaccess
flushes
arch/powerpc/include/asm/hvcall.h | 3 +++
arch/powerpc/include/asm/security_features.h | 4 ++++
arch/powerpc/kernel/security.c | 7 ++-----
arch/powerpc/platforms/powernv/setup.c | 9 ---------
arch/powerpc/platforms/pseries/setup.c | 9 +++++++++
5 files changed, 18 insertions(+), 14 deletions(-)
--
2.23.0
From: Nicholas Piggin <npiggin@gmail.com> Date: 2021-05-03 13:03:49
This allows the hypervisor / firmware to describe these workarounds to
the guest.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/include/asm/hvcall.h | 2 ++
arch/powerpc/platforms/pseries/setup.c | 6 ++++++
2 files changed, 8 insertions(+)
@@ -393,6 +393,8 @@#define H_CPU_BEHAV_FAVOUR_SECURITY_H (1ull << 60) // IBM bit 3#define H_CPU_BEHAV_FLUSH_COUNT_CACHE (1ull << 58) // IBM bit 5#define H_CPU_BEHAV_FLUSH_LINK_STACK (1ull << 57) // IBM bit 6+#define H_CPU_BEHAV_NO_L1D_FLUSH_ENTRY (1ull << 56) // IBM bit 7+#define H_CPU_BEHAV_NO_L1D_FLUSH_UACCESS (1ull << 55) // IBM bit 8/* Flag values used in H_REGISTER_PROC_TBL hcall */#define PROC_TABLE_OP_MASK 0x18
From: Nicholas Piggin <npiggin@gmail.com> Date: 2021-05-03 13:04:13
Rather than tying this mitigation to RFI L1D flush requirement, add a
new bit for it.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/include/asm/security_features.h | 4 ++++
arch/powerpc/kernel/security.c | 7 ++-----
2 files changed, 6 insertions(+), 5 deletions(-)
@@ -92,6 +92,9 @@ static inline bool security_ftr_enabled(u64 feature)// The L1-D cache should be flushed after user accesses from the kernel#define SEC_FTR_L1D_FLUSH_UACCESS 0x0000000000008000ull+// The STF flush should be executed on privilege state switch+#define SEC_FTR_STF_BARRIER 0x0000000000010000ull+// Features enabled by default#define SEC_FTR_DEFAULT \(SEC_FTR_L1D_FLUSH_HV|\
@@ -300,9 +300,7 @@ static void stf_barrier_enable(bool enable)voidsetup_stf_barrier(void){enumstf_barrier_typetype;-boolenable,hv;--hv=cpu_has_feature(CPU_FTR_HVMODE);+boolenable;/* Default to fallback in case fw-features are not available */if(cpu_has_feature(CPU_FTR_ARCH_300))
From: Nicholas Piggin <npiggin@gmail.com> Date: 2021-05-03 13:04:36
This allows the hypervisor / firmware to describe this workarounds to
the guest.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/include/asm/hvcall.h | 1 +
arch/powerpc/platforms/pseries/setup.c | 3 +++
2 files changed, 4 insertions(+)
@@ -395,6 +395,7 @@#define H_CPU_BEHAV_FLUSH_LINK_STACK (1ull << 57) // IBM bit 6#define H_CPU_BEHAV_NO_L1D_FLUSH_ENTRY (1ull << 56) // IBM bit 7#define H_CPU_BEHAV_NO_L1D_FLUSH_UACCESS (1ull << 55) // IBM bit 8+#define H_CPU_BEHAV_NO_STF_BARRIER (1ull << 54) // IBM bit 9/* Flag values used in H_REGISTER_PROC_TBL hcall */#define PROC_TABLE_OP_MASK 0x18
From: Nicholas Piggin <npiggin@gmail.com> Date: 2021-05-03 13:05:00
These aren't necessarily POWER9 only, and it's not to say some new
vulnerability may not get discovered on other processors for which
we would like the flexibility of having the workaround enabled by
firmware.
Remove the restriction that they only apply to POWER9.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/platforms/powernv/setup.c | 9 ---------
1 file changed, 9 deletions(-)
From: Joel Stanley <joel@jms.id.au> Date: 2021-05-04 00:52:21
On Mon, 3 May 2021 at 13:04, Nicholas Piggin [off-list ref] wrote:
These aren't necessarily POWER9 only, and it's not to say some new
vulnerability may not get discovered on other processors for which
we would like the flexibility of having the workaround enabled by
firmware.
Remove the restriction that they only apply to POWER9.
I was wondering how these worked which led me to reviewing your patch.
From what I could see, these are enabled by default (SEC_FTR_DEFAULT
in arch/powerpc/include/asm/security_features.h), so unless all
non-POWER9 machines have set the "please don't" bit in their firmware
this patch will enable the feature for those machines. Is that what
you wanted?
From: Nicholas Piggin <npiggin@gmail.com> Date: 2021-05-04 09:17:16
Excerpts from Joel Stanley's message of May 4, 2021 10:51 am:
On Mon, 3 May 2021 at 13:04, Nicholas Piggin [off-list ref] wrote:
quoted
These aren't necessarily POWER9 only, and it's not to say some new
vulnerability may not get discovered on other processors for which
we would like the flexibility of having the workaround enabled by
firmware.
Remove the restriction that they only apply to POWER9.
I was wondering how these worked which led me to reviewing your patch.
From what I could see, these are enabled by default (SEC_FTR_DEFAULT
in arch/powerpc/include/asm/security_features.h), so unless all
non-POWER9 machines have set the "please don't" bit in their firmware
this patch will enable the feature for those machines. Is that what
you wanted?
Yes. POWER7/8 should be affected (it's similar mechanism that requires
the meltdown RFI flush, which those processors need).
POWER10 we haven't released a bare metal firmware with the right bits
yet. Not urgent at the moment but wouldn't hurt to specify them and
add the Linux code for them.
Thanks,
Nick
From: Joel Stanley <joel@jms.id.au> Date: 2021-05-05 01:44:13
On Tue, 4 May 2021 at 09:16, Nicholas Piggin [off-list ref] wrote:
Excerpts from Joel Stanley's message of May 4, 2021 10:51 am:
quoted
On Mon, 3 May 2021 at 13:04, Nicholas Piggin [off-list ref] wrote:
quoted
These aren't necessarily POWER9 only, and it's not to say some new
vulnerability may not get discovered on other processors for which
we would like the flexibility of having the workaround enabled by
firmware.
Remove the restriction that they only apply to POWER9.
I was wondering how these worked which led me to reviewing your patch.
From what I could see, these are enabled by default (SEC_FTR_DEFAULT
in arch/powerpc/include/asm/security_features.h), so unless all
non-POWER9 machines have set the "please don't" bit in their firmware
this patch will enable the feature for those machines. Is that what
you wanted?
Yes. POWER7/8 should be affected (it's similar mechanism that requires
the meltdown RFI flush, which those processors need).
POWER10 we haven't released a bare metal firmware with the right bits
yet. Not urgent at the moment but wouldn't hurt to specify them and
add the Linux code for them.
Thanks for the explanation. This could go in the commit message if you re-spin.
Reviewed-by: Joel Stanley <joel@jms.id.au>
From: Nicholas Piggin <npiggin@gmail.com> Date: 2021-05-08 10:01:27
Excerpts from Joel Stanley's message of May 5, 2021 11:43 am:
On Tue, 4 May 2021 at 09:16, Nicholas Piggin [off-list ref] wrote:
quoted
Excerpts from Joel Stanley's message of May 4, 2021 10:51 am:
quoted
On Mon, 3 May 2021 at 13:04, Nicholas Piggin [off-list ref] wrote:
quoted
These aren't necessarily POWER9 only, and it's not to say some new
vulnerability may not get discovered on other processors for which
we would like the flexibility of having the workaround enabled by
firmware.
Remove the restriction that they only apply to POWER9.
I was wondering how these worked which led me to reviewing your patch.
From what I could see, these are enabled by default (SEC_FTR_DEFAULT
in arch/powerpc/include/asm/security_features.h), so unless all
non-POWER9 machines have set the "please don't" bit in their firmware
this patch will enable the feature for those machines. Is that what
you wanted?
Yes. POWER7/8 should be affected (it's similar mechanism that requires
the meltdown RFI flush, which those processors need).
POWER10 we haven't released a bare metal firmware with the right bits
yet. Not urgent at the moment but wouldn't hurt to specify them and
add the Linux code for them.
Thanks for the explanation. This could go in the commit message if you re-spin.
Reviewed-by: Joel Stanley <joel@jms.id.au>
I was talking about the same thing with Michael and he dug up an old
email chain that proves me wrong. P7/8 are actually slightly different.
I'm not sure what I can explain of it in public unfortunately.
How about this?
---
These aren't necessarily POWER9 only, and it's not to say some new
vulnerability may not get discovered on other processors for which
we would like the flexibility of having the workaround enabled by
firmware.
Remove the restriction that the workarounds only apply to POWER9.
However POWER7 and POWER8 are not affected, and they may not have
older firmware that does not advertise this, so clear these workarounds
manually.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/platforms/powernv/setup.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
From: Michael Ellerman <hidden> Date: 2021-06-24 14:05:03
On Mon, 3 May 2021 23:02:39 +1000, Nicholas Piggin wrote:
This series adds a few missing bits added to recent pseries
H_GET_CPU_CHARACTERISTICS and implements them, also removes
a restriction from powernv for some of the flushes.
This is tested mianly in qemu where I just submitted a patch
that adds support for these bits (not upstream yet).
[...]
From: Michael Ellerman <hidden> Date: 2021-11-25 09:51:33
On Mon, 3 May 2021 23:02:39 +1000, Nicholas Piggin wrote:
This series adds a few missing bits added to recent pseries
H_GET_CPU_CHARACTERISTICS and implements them, also removes
a restriction from powernv for some of the flushes.
This is tested mianly in qemu where I just submitted a patch
that adds support for these bits (not upstream yet).
[...]