Skip to contentSkip to conversation

PPC: BOOK3S: Disable/Enable TM looking at the ibm, pa-features device tree entry

PATCH Superseded Aneesh Kumar K.V 2 participants 5 messages Apr 30, 2014 – Jun 4, 2014 PowerPC

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PPC: BOOK3S: Disable/Enable TM looking at the ibm, pa-features device tree entry

Runtime disable transactional memory feature looking at pa-features device tree entry. This provides a mechanism to disable TM on P8 systems.

---
 arch/powerpc/kernel/prom.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/powerpc/kernel/prom.c +5 -0
index 668aa4791fd7..537bd7e7db0b 100644
@@ -161,6 +161,11 @@ static struct ibm_pa_feature {
 	{CPU_FTR_NODSISRALIGN, 0, 0,	1, 1, 1},
 	{0, MMU_FTR_CI_LARGE_PAGE, 0,	1, 2, 0},
 	{CPU_FTR_REAL_LE, PPC_FEATURE_TRUE_LE, 5, 0, 0},
+	/*
+	 * We should use CPU_FTR_TM_COMP so that if we disable TM, it won't get
+	 * enabled via device tree
+	 */
+	{CPU_FTR_TM_COMP, 0, 0,		22, 0, 0},
 };
 
 static void __init scan_features(unsigned long node, unsigned char *ftrs,
Signature · 1 line
1.9.1
#1 lore raw
Quoted 3 lines · Aneesh Kumar K.V

Runtime disable transactional memory feature looking at pa-features device tree entry. This provides a mechanism to disable TM on P8 systems.

What are we actually achieving with this?

Quoted 10 lines
---
 arch/powerpc/kernel/prom.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/powerpc/kernel/prom.c +0 -0
index 668aa4791fd7..537bd7e7db0b 100644

arch/powerpc/kernel/prom.c static struct ibm_pa_feature { · line 168

Quoted 8 lines
arch/powerpc/kernel/prom.c +5 -0
@@ -161,6 +161,11 @@ static struct ibm_pa_feature {
 	{CPU_FTR_NODSISRALIGN, 0, 0,	1, 1, 1},
 	{0, MMU_FTR_CI_LARGE_PAGE, 0,	1, 2, 0},
 	{CPU_FTR_REAL_LE, PPC_FEATURE_TRUE_LE, 5, 0, 0},
+	/*
+	 * We should use CPU_FTR_TM_COMP so that if we disable TM, it won't get
+	 * enabled via device tree
+	 */
+	{CPU_FTR_TM_COMP, 0, 0,		22, 0, 0},

What does this do to guests? Will it turn TM unavailable into an illegal instruction?

Mikey

Quoted 10 lines
arch/powerpc/kernel/prom.c +0 -0
 };
 
 static void __init scan_features(unsigned long node, unsigned char *ftrs,
Signature · 6 lines
1.9.1

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
#2 lore raw
Quoted 7 lines · Michael Neuling
Quoted 3 lines · Aneesh Kumar K.V

Runtime disable transactional memory feature looking at pa-features device tree entry. This provides a mechanism to disable TM on P8 systems.

What are we actually achieving with this?

PAPR compliance :) ? Also I wanted to disable guest kernel from doing TM related save restore. Guest kernel already look at the cpu feature before doing that. Hence needed a mechanism to disable the feature.

Things like

static inline void __switch_to_tm(struct task_struct *prev)

{
	if (cpu_has_feature(CPU_FTR_TM)) {
		tm_enable();
		tm_reclaim_task(prev);
	}
}
Quoted 6 lines
Quoted 6 lines
---
 arch/powerpc/kernel/prom.c | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 17 lines

arch/powerpc/kernel/prom.c static struct ibm_pa_feature { · line 168

Quoted 13 lines
arch/powerpc/kernel/prom.c +5 -0
index 668aa4791fd7..537bd7e7db0b 100644
@@ -161,6 +161,11 @@ static struct ibm_pa_feature {
 	{CPU_FTR_NODSISRALIGN, 0, 0,	1, 1, 1},
 	{0, MMU_FTR_CI_LARGE_PAGE, 0,	1, 2, 0},
 	{CPU_FTR_REAL_LE, PPC_FEATURE_TRUE_LE, 5, 0, 0},
+	/*
+	 * We should use CPU_FTR_TM_COMP so that if we disable TM, it won't get
+	 * enabled via device tree
+	 */
+	{CPU_FTR_TM_COMP, 0, 0,		22, 0, 0},

What does this do to guests? Will it turn TM unavailable into an illegal instruction?

Good suggestion. I guess it should be facility unavailable interrupt ? I should also make the sure __init_HFSCR only set HFSCR_TM only if the cpu feature is enabled ?

-aneesh

#3 lore raw
Quoted 49 lines · Aneesh Kumar K.V
Quoted 7 lines · Michael Neuling
Quoted 3 lines · Aneesh Kumar K.V

Runtime disable transactional memory feature looking at pa-features device tree entry. This provides a mechanism to disable TM on P8 systems.

What are we actually achieving with this?

PAPR compliance :) ? Also I wanted to disable guest kernel from doing TM related save restore. Guest kernel already look at the cpu feature before doing that. Hence needed a mechanism to disable the feature.

Things like

static inline void __switch_to_tm(struct task_struct *prev)

{
	if (cpu_has_feature(CPU_FTR_TM)) {
		tm_enable();
		tm_reclaim_task(prev);
	}
}
Quoted 6 lines
Quoted 6 lines
---
 arch/powerpc/kernel/prom.c | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 17 lines

arch/powerpc/kernel/prom.c static struct ibm_pa_feature { · line 168

Quoted 13 lines
arch/powerpc/kernel/prom.c +5 -0
index 668aa4791fd7..537bd7e7db0b 100644
@@ -161,6 +161,11 @@ static struct ibm_pa_feature {
 	{CPU_FTR_NODSISRALIGN, 0, 0,	1, 1, 1},
 	{0, MMU_FTR_CI_LARGE_PAGE, 0,	1, 2, 0},
 	{CPU_FTR_REAL_LE, PPC_FEATURE_TRUE_LE, 5, 0, 0},
+	/*
+	 * We should use CPU_FTR_TM_COMP so that if we disable TM, it won't get
+	 * enabled via device tree
+	 */
+	{CPU_FTR_TM_COMP, 0, 0,		22, 0, 0},

What does this do to guests? Will it turn TM unavailable into an illegal instruction?

Quoted 3 lines

Good suggestion. I guess it should be facility unavailable interrupt ? I should also make the sure __init_HFSCR only set HFSCR_TM only if the cpu feature is enabled ?

I looked at this and I guess we don't need to update HFSCR considering that the guest kernel (privileged) access to TM always happen within if (cpu_has_feature(CPU_FTR_TM)) conditional block. Also we want to disable this per guest and there is no easy way to suggest hypervisor that disable TM in HFSCR.

BTW we already do this for guest problme state. We do in guest kernel

	if (cpu_has_feature(CPU_FTR_TM))
		regs->msr |= MSR_TM;

IIUC that should result in facility unavailable interrupt when problem state try to access TM ?

I will try to run some test with the patch and update here.

-aneesh

#4 lore raw
Quoted 63 lines · Aneesh Kumar K.V
Quoted 49 lines · Aneesh Kumar K.V
Quoted 7 lines · Michael Neuling
Quoted 3 lines · Aneesh Kumar K.V

Runtime disable transactional memory feature looking at pa-features device tree entry. This provides a mechanism to disable TM on P8 systems.

What are we actually achieving with this?

PAPR compliance :) ? Also I wanted to disable guest kernel from doing TM related save restore. Guest kernel already look at the cpu feature before doing that. Hence needed a mechanism to disable the feature.

Things like

static inline void __switch_to_tm(struct task_struct *prev)

{
	if (cpu_has_feature(CPU_FTR_TM)) {
		tm_enable();
		tm_reclaim_task(prev);
	}
}
Quoted 6 lines
Quoted 6 lines
---
 arch/powerpc/kernel/prom.c | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 17 lines

arch/powerpc/kernel/prom.c static struct ibm_pa_feature { · line 168

Quoted 13 lines
arch/powerpc/kernel/prom.c +5 -0
index 668aa4791fd7..537bd7e7db0b 100644
@@ -161,6 +161,11 @@ static struct ibm_pa_feature {
 	{CPU_FTR_NODSISRALIGN, 0, 0,	1, 1, 1},
 	{0, MMU_FTR_CI_LARGE_PAGE, 0,	1, 2, 0},
 	{CPU_FTR_REAL_LE, PPC_FEATURE_TRUE_LE, 5, 0, 0},
+	/*
+	 * We should use CPU_FTR_TM_COMP so that if we disable TM, it won't get
+	 * enabled via device tree
+	 */
+	{CPU_FTR_TM_COMP, 0, 0,		22, 0, 0},

What does this do to guests? Will it turn TM unavailable into an illegal instruction?

Quoted 3 lines

Good suggestion. I guess it should be facility unavailable interrupt ? I should also make the sure __init_HFSCR only set HFSCR_TM only if the cpu feature is enabled ?

I looked at this and I guess we don't need to update HFSCR considering that the guest kernel (privileged) access to TM always happen within if (cpu_has_feature(CPU_FTR_TM)) conditional block. Also we want to disable this per guest and there is no easy way to suggest hypervisor that disable TM in HFSCR.

BTW we already do this for guest problme state. We do in guest kernel

Quoted 7 lines
	if (cpu_has_feature(CPU_FTR_TM))
		regs->msr |= MSR_TM;

IIUC that should result in facility unavailable interrupt when problem state try to access TM ?

I will try to run some test with the patch and update here.

This will actually result in illegal instruction.

-aneesh