Skip to contentSkip to conversation

pmu_lbr: drop check for MSR_LBR_TOS != 0

PATCH Applied Maxim Levitsky 2 participants 7 messages Oct 2, 2024 – Feb 24, 2025 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pmu_lbr: drop check for MSR_LBR_TOS != 0

While this is not likely, it is valid for the MSR_LBR_TOS
to contain 0 value, after a test which issues a series of branches, if the number of branches recorded was divisible by the number of LBR msrs.

This unfortunately depends on the compiler, the number of LBR registers, and it is not even deterministic between different runs of the test, because interrupts, rescheduling, and various other events can affect total number of branches done.

Therefore drop the check, instead of trying to fix it.

---
 x86/pmu_lbr.c | 1 -
 1 file changed, 1 deletion(-)
x86/pmu_lbr.c +0 -1
index c6f010847..8ca8ed044 100644
@@ -98,7 +98,6 @@ int main(int ac, char **av)
 	lbr_test();
 	wrmsr(MSR_IA32_DEBUGCTLMSR, 0);
 
-	report(rdmsr(MSR_LBR_TOS) != 0, "The guest LBR MSR_LBR_TOS value is good.");
 	for (i = 0; i < max; ++i) {
 		if (!rdmsr(lbr_to + i) || !rdmsr(lbr_from + i))
 			break;
Signature · 1 line
2.26.3
#1 lore raw
Quoted 21 lines · Maxim Levitsky

While this is not likely, it is valid for the MSR_LBR_TOS
to contain 0 value, after a test which issues a series of branches, if the number of branches recorded was divisible by the number of LBR msrs.

This unfortunately depends on the compiler, the number of LBR registers, and it is not even deterministic between different runs of the test, because interrupts, rescheduling, and various other events can affect total number of branches done.

Therefore drop the check, instead of trying to fix it.

---
 x86/pmu_lbr.c | 1 -
 1 file changed, 1 deletion(-)
x86/pmu_lbr.c +0 -0
index c6f010847..8ca8ed044 100644

x86/pmu_lbr.c int main(int ac, char **av) · line 103

Quoted 7 lines
x86/pmu_lbr.c +0 -1
@@ -98,7 +98,6 @@ int main(int ac, char **av)
 	lbr_test();
 	wrmsr(MSR_IA32_DEBUGCTLMSR, 0);
 
-	report(rdmsr(MSR_LBR_TOS) != 0, "The guest LBR MSR_LBR_TOS value is good.");
 	for (i = 0; i < max; ++i) {
 		if (!rdmsr(lbr_to + i) || !rdmsr(lbr_from + i))
 			break;

A very kind ping on this patch.

Best regards,
Maxim Levitsky

#2 lore raw
Quoted 7 lines · Maxim Levitsky

A very kind ping on this patch.

Best regards,

Maxim Levitsky

Another very kind ping on this patch.

Best regards,
Maxim Levitsky

#3 lore raw
Quoted 10 lines · Maxim Levitsky
Quoted 7 lines · Maxim Levitsky

A very kind ping on this patch.

Best regards,

Maxim Levitsky

Another very kind ping on this patch.

Any update?

Best regards,
Maxim Levitsky

Quoted 4 lines

Best regards,
Maxim Levitsky

#4 lore raw
In reply to Maxim Levitsky
Quoted 21 lines · Maxim Levitsky

While this is not likely, it is valid for the MSR_LBR_TOS
to contain 0 value, after a test which issues a series of branches, if the number of branches recorded was divisible by the number of LBR msrs.

This unfortunately depends on the compiler, the number of LBR registers, and it is not even deterministic between different runs of the test, because interrupts, rescheduling, and various other events can affect total number of branches done.

Therefore drop the check, instead of trying to fix it.

---
 x86/pmu_lbr.c | 1 -
 1 file changed, 1 deletion(-)
x86/pmu_lbr.c +0 -0
index c6f010847..8ca8ed044 100644

x86/pmu_lbr.c int main(int ac, char **av) · line 103

Quoted 7 lines
x86/pmu_lbr.c +0 -1
@@ -98,7 +98,6 @@ int main(int ac, char **av)
 	lbr_test();
 	wrmsr(MSR_IA32_DEBUGCTLMSR, 0);
 
-	report(rdmsr(MSR_LBR_TOS) != 0, "The guest LBR MSR_LBR_TOS value is good.");
 	for (i = 0; i < max; ++i) {
 		if (!rdmsr(lbr_to + i) || !rdmsr(lbr_from + i))
 			break;

Hi,

This is the other kvm-unit-tests patch that I have a ticket open for, and I would like to get this merged and close the ticket.

Thanks,
Best regards,
Maxim Levitsky

#5 lore raw
Quoted 32 lines · Maxim Levitsky
Quoted 21 lines · Maxim Levitsky

While this is not likely, it is valid for the MSR_LBR_TOS
to contain 0 value, after a test which issues a series of branches, if the number of branches recorded was divisible by the number of LBR msrs.

This unfortunately depends on the compiler, the number of LBR registers, and it is not even deterministic between different runs of the test, because interrupts, rescheduling, and various other events can affect total number of branches done.

Therefore drop the check, instead of trying to fix it.

---
 x86/pmu_lbr.c | 1 -
 1 file changed, 1 deletion(-)
x86/pmu_lbr.c +0 -0
index c6f010847..8ca8ed044 100644

x86/pmu_lbr.c int main(int ac, char **av) · line 103

Quoted 7 lines
x86/pmu_lbr.c +0 -1
@@ -98,7 +98,6 @@ int main(int ac, char **av)
 	lbr_test();
 	wrmsr(MSR_IA32_DEBUGCTLMSR, 0);
 
-	report(rdmsr(MSR_LBR_TOS) != 0, "The guest LBR MSR_LBR_TOS value is good.");
 	for (i = 0; i < max; ++i) {
 		if (!rdmsr(lbr_to + i) || !rdmsr(lbr_from + i))
 			break;

Hi,

Quoted 2 lines

This is the other kvm-unit-tests patch that I have a ticket open for, and I would like to get this merged and close the ticket.

I'll grab it. I'm hoping to get the pull request put together tomorrow, but I might not get to it until Thusrday.

reviewer Applied
#6 lore raw
In reply to Maxim Levitsky
Quoted 10 lines · Maxim Levitsky

While this is not likely, it is valid for the MSR_LBR_TOS
to contain 0 value, after a test which issues a series of branches, if the number of branches recorded was divisible by the number of LBR msrs.

This unfortunately depends on the compiler, the number of LBR registers, and it is not even deterministic between different runs of the test, because interrupts, rescheduling, and various other events can affect total number of branches done.

[...]

Applied to kvm-x86 next (and now pulled by Paolo), thanks!

[1/1] pmu_lbr: drop check for MSR_LBR_TOS != 0

      https://github.com/kvm-x86/kvm-unit-tests/commit/584a927eaf58

--
https://github.com/kvm-x86/kvm-unit-tests/tree/next