Skip to contentSkip to conversation

kvm_pagefault01: Do not write into tdp_mmu sysfile

PATCH In review Martin Doucha 3 participants 7 messages May 27, 2024 – May 28, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm_pagefault01: Do not write into tdp_mmu sysfile

The tdp_mmu sysfile was made read-only in kernel v6.3. Do not modify it but only reload vendor KVM modules if needed. Some kernel versions before v6.3 have writable tdp_mmu sysfile which appears to be independent from vendor KVM module settings. Print a warning about false negatives if tdp_mmu appears enabled after reloading KVM modules. It is unclear if that state may impact bug reproducibility.

---
 testcases/kernel/kvm/kvm_pagefault01.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
testcases/kernel/kvm/kvm_pagefault01.c +3 -10
index 91891848a..3dd2fa249 100644
@@ -193,16 +193,14 @@ static void reload_module(const char *module, char *arg)
 
 static void disable_tdp(void)
 {
-	if (!access(TDP_MMU_SYSFILE, F_OK)) {
-		/* FIXME: Is setting tdp_mmu=0 sufficient to disable TDP? */
-		return;
-	}
-
 	if (read_bool_sys_param(TDP_AMD_SYSFILE) > 0)
 		reload_module("kvm_amd", "npt=0");
 
 	if (read_bool_sys_param(TDP_INTEL_SYSFILE) > 0)
 		reload_module("kvm_intel", "ept=0");
+
+	if (read_bool_sys_param(TDP_MMU_SYSFILE) > 0)
+		tst_res(TINFO, "tdp_mmu is enabled, beware of false negatives");
 }
 
 static void setup(void)
@@ -216,11 +214,6 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = tst_kvm_cleanup,
 	.needs_root = 1,
-	.save_restore = (const struct tst_path_val[]) {
-		{"/sys/module/kvm/parameters/tdp_mmu", "0",
-			TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},
-		{}
-	},
 	.supported_archs = (const char *const []) {
 		"x86_64",
 		NULL
Signature · 5 lines
2.44.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Martin,

Quoted 6 lines

The tdp_mmu sysfile was made read-only in kernel v6.3. Do not modify it but only reload vendor KVM modules if needed. Some kernel versions before v6.3 have writable tdp_mmu sysfile which appears to be independent from vendor KVM module settings. Print a warning about false negatives if tdp_mmu appears enabled after reloading KVM modules. It is unclear if that state may impact bug reproducibility.

Good catch.

...

Quoted 5 lines

static void disable_tdp(void)
{

testcases/kernel/kvm/kvm_pagefault01.c +0 -3
-	if (!access(TDP_MMU_SYSFILE, F_OK)) {
-		/* FIXME: Is setting tdp_mmu=0 sufficient to disable TDP? */
-		return;

testcases/kernel/kvm/kvm_pagefault01.c static void reload_module(const char *module, char *arg) · line 203

Quoted 10 lines
testcases/kernel/kvm/kvm_pagefault01.c +3 -2
-	}
-
 	if (read_bool_sys_param(TDP_AMD_SYSFILE) > 0)
 		reload_module("kvm_amd", "npt=0");
 
 	if (read_bool_sys_param(TDP_INTEL_SYSFILE) > 0)
 		reload_module("kvm_intel", "ept=0");
+
+	if (read_bool_sys_param(TDP_MMU_SYSFILE) > 0)
+		tst_res(TINFO, "tdp_mmu is enabled, beware of false negatives");

Wouldn't it be better to add "WARNING:" to make it more visible?

		tst_res(TINFO, "WARNING: tdp_mmu is enabled, beware of false negatives");

(if you agree, I can change it before merge)

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
Quoted 8 lines · Petr Vorel

testcases/kernel/kvm/kvm_pagefault01.c static void reload_module(const char *module, char *arg) · line 203

Quoted 3 lines
testcases/kernel/kvm/kvm_pagefault01.c +3 -0
+
+	if (read_bool_sys_param(TDP_MMU_SYSFILE) > 0)
+		tst_res(TINFO, "tdp_mmu is enabled, beware of false negatives");

Wouldn't it be better to add "WARNING:" to make it more visible?

		tst_res(TINFO, "WARNING: tdp_mmu is enabled, beware of false negatives");

(if you agree, I can change it before merge)

I thought about it for a while and I see good reasons for both TINFO and TWARN. It shouldn't matter for our tests because tdp_mmu defaults to off on SLE-15SP4 and SLE-15SP5. If other reviewers agree, feel free to change it to TWARN.

Signature · 11 lines
Martin Doucha   [email protected]
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw
Quoted 8 lines · Petr Vorel
Quoted 6 lines

testcases/kernel/kvm/kvm_pagefault01.c static void reload_module(const char *module, char *arg) · line 203

Quoted 3 lines
testcases/kernel/kvm/kvm_pagefault01.c +3 -0
+
+	if (read_bool_sys_param(TDP_MMU_SYSFILE) > 0)
+		tst_res(TINFO, "tdp_mmu is enabled, beware of false negatives");

Wouldn't it be better to add "WARNING:" to make it more visible?

		tst_res(TINFO, "WARNING: tdp_mmu is enabled, beware of false negatives");
Quoted 6 lines
Quoted 1 line

(if you agree, I can change it before merge)

I thought about it for a while and I see good reasons for both TINFO and TWARN. It shouldn't matter for our tests because tdp_mmu defaults to off on SLE-15SP4 and SLE-15SP5. If other reviewers agree, feel free to change it to TWARN.

I slightly prefer tst_res(TINFO, "WARNING: ...", than TWARN. Although false negative is serious, still failing the test based on suspicion of false positives is not good.

@Li, @Jan, @Metan: any opinion on it?

Also, I send a patch to add TINFO_WARN flag (yeah, ugly name) to print TINFO but slightly more visible due the color.

https://patchwork.ozlabs.org/project/ltp/list/?series=408394&state=*

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw
Quoted 8 lines · Petr Vorel
Quoted 4 lines

I thought about it for a while and I see good reasons for both TINFO and TWARN. It shouldn't matter for our tests because tdp_mmu defaults to off on SLE-15SP4 and SLE-15SP5. If other reviewers agree, feel free to change it to TWARN.

I slightly prefer tst_res(TINFO, "WARNING: ...", than TWARN. Although false negative is serious, still failing the test based on suspicion of false positives is not good.

+1 to changing the TINFO message during merge.

Signature · 11 lines
Martin Doucha   [email protected]
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw
In reply to Petr Vorel
Quoted 16 lines · Petr Vorel
Quoted 9 lines · Petr Vorel
Quoted 6 lines

testcases/kernel/kvm/kvm_pagefault01.c static void reload_module(const char *module, char *arg) · line 203

Quoted 3 lines
testcases/kernel/kvm/kvm_pagefault01.c +3 -0
+
+ if (read_bool_sys_param(TDP_MMU_SYSFILE) > 0)
+         tst_res(TINFO, "tdp_mmu is enabled, beware of false negatives");

Wouldn't it be better to add "WARNING:" to make it more visible?

            tst_res(TINFO, "WARNING: tdp_mmu is enabled, beware of false negatives");
Quoted 6 lines
Quoted 1 line

(if you agree, I can change it before merge)

I thought about it for a while and I see good reasons for both TINFO and TWARN. It shouldn't matter for our tests because tdp_mmu defaults to off on SLE-15SP4 and SLE-15SP5. If other reviewers agree, feel free to change it to TWARN.

Quoted 5 lines

I slightly prefer tst_res(TINFO, "WARNING: ...", than TWARN. Although false negative is serious, still failing the test based on suspicion of false positives is not good.

@Li, @Jan, @Metan: any opinion on it?

I'd go with TINFO here, as you suggested.

Quoted 9 lines

Also, I send a patch to add TINFO_WARN flag (yeah, ugly name) to print TINFO but slightly more visible due the color.

https://patchwork.ozlabs.org/project/ltp/list/?series=408394&state=*

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Hi Martin, Jan,

Quoted 17 lines · Petr Vorel
Quoted 15 lines
Quoted 15 lines · Petr Vorel
Quoted 8 lines

testcases/kernel/kvm/kvm_pagefault01.c static void reload_module(const char *module, char *arg) · line 203

Quoted 3 lines
testcases/kernel/kvm/kvm_pagefault01.c +3 -0
+
+ if (read_bool_sys_param(TDP_MMU_SYSFILE) > 0)
+         tst_res(TINFO, "tdp_mmu is enabled, beware of false negatives");

Wouldn't it be better to add "WARNING:" to make it more visible?

            tst_res(TINFO, "WARNING: tdp_mmu is enabled, beware of false negatives");

(if you agree, I can change it before merge)

I thought about it for a while and I see good reasons for both TINFO and TWARN. It shouldn't matter for our tests because tdp_mmu defaults to off on SLE-15SP4 and SLE-15SP5. If other reviewers agree, feel free to change it to TWARN.

Quoted 7 lines
Quoted 5 lines

I slightly prefer tst_res(TINFO, "WARNING: ...", than TWARN. Although false negative is serious, still failing the test based on suspicion of false positives is not good.

@Li, @Jan, @Metan: any opinion on it?

I'd go with TINFO here, as you suggested.

Thanks a lot both!

Patchset merged (Jan, I did not dare to add your RBT or ABT as you did not add it), with added WARNING: (as Martin agreed).

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp