Skip to content

Commit 86aa1eb

Browse files
GitMenschrocallahan
authored andcommitted
update zen_workaround for kernels > 6.16 and C23
* follow kernel function rename * use defines for old names with old kernels * include appropriate headers and explicit mark static functions kernel functions renamed in 7cbc2ba7c107a1a537524ae505e192f4f88cc209 and 6fe22abacd40e259fffec744a02d5ca3febccd68 which both arrived with 6.16. rc1 fixes #4004 co-authored by @symphorien Guillaume Girol
1 parent 2163aad commit 86aa1eb

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

third-party/zen-pmu-workaround/zen_workaround.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
33
* Copyright 2020 Mike Hommey <[email protected]>
4+
* Copyright 2025 RR Community
45
*/
56

67
#include <linux/module.h>
78
#include <linux/tracepoint.h>
89
#include <linux/suspend.h>
10+
#include <linux/version.h>
11+
#include <asm/msr.h>
12+
13+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,16,0)
14+
#define wrmsrq_safe wrmsrl_safe
15+
#define rdmsrq_safe rdmsrl_safe
16+
#define native_wrmsrq native_wrmsrl
17+
#endif
918

1019
#define MODULE_NAME "zen_workaround"
1120

1221
#define SPECLOCKMAP_DISABLE BIT_64(54)
1322

14-
u64 set_speclockmap_disable(u64 msr) {
23+
static u64 set_speclockmap_disable(u64 msr) {
1524
return msr | SPECLOCKMAP_DISABLE;
1625
}
1726

18-
u64 unset_speclockmap_disable(u64 msr) {
27+
static u64 unset_speclockmap_disable(u64 msr) {
1928
return msr & ~SPECLOCKMAP_DISABLE;
2029
}
2130

@@ -26,10 +35,10 @@ static void edit_ls_cfg_on_cpu(void *info)
2635
int cpu = get_cpu();
2736
u64 value = 0;
2837

29-
if (!rdmsrl_safe(MSR_AMD64_LS_CFG, &value)) {
38+
if (!rdmsrq_safe(MSR_AMD64_LS_CFG, &value)) {
3039
edit_msr_func_t edit_msr = (edit_msr_func_t) info;
3140
u64 new_value = edit_msr(value);
32-
if (!wrmsrl_safe(MSR_AMD64_LS_CFG, new_value)) {
41+
if (!wrmsrq_safe(MSR_AMD64_LS_CFG, new_value)) {
3342
pr_info("MSR_AMD64_LS_CFG for cpu %d was 0x%llx, setting to 0x%llx\n",
3443
cpu, value, new_value);
3544
} else {
@@ -50,7 +59,7 @@ static void do_zen_workaround(edit_msr_func_t edit_msr)
5059
void on_write_msr(void *data, unsigned int msr, u64 val, int failed)
5160
{
5261
if (msr == MSR_AMD64_LS_CFG && !(val & SPECLOCKMAP_DISABLE)) {
53-
native_wrmsrl(MSR_AMD64_LS_CFG, set_speclockmap_disable(val));
62+
native_wrmsrq(MSR_AMD64_LS_CFG, set_speclockmap_disable(val));
5463
}
5564
}
5665

@@ -116,4 +125,4 @@ static void __exit zen_workaround_exit(void)
116125
}
117126
module_exit(zen_workaround_exit);
118127

119-
MODULE_LICENSE("GPL");
128+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)