Skip to content

Commit 2cce3ed

Browse files
committed
[Build] Prevent module loading if detected CPU count > CORE_COUNT
1 parent 6509cc4 commit 2cce3ed

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

aarch64/corefreqk.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6138,6 +6138,15 @@ static int CoreFreqK_Scale_And_Compute_Level_Up(INIT_ARG *pArg)
61386138
COREFREQ_REV );
61396139

61406140
PUBLIC(RO(Proc))->CPU.Count = pArg->SMT_Count;
6141+
6142+
if (PUBLIC(RO(Proc))->CPU.Count > CORE_COUNT) {
6143+
pr_warn("CoreFreq: Detected %u CPUs, but built with CORE_COUNT=%u\n",
6144+
PUBLIC(RO(Proc))->CPU.Count, CORE_COUNT);
6145+
pr_warn("CoreFreq: Run 'make help' for instructions " \
6146+
"on setting CORE_COUNT.\n");
6147+
6148+
return -ENOMEM;
6149+
} else {
61416150
/* PreCompute SysGate memory allocation. */
61426151
PUBLIC(RO(Proc))->Gate.ReqMem.Size = sizeof(SYSGATE_RO);
61436152

@@ -6159,7 +6168,9 @@ static int CoreFreqK_Scale_And_Compute_Level_Up(INIT_ARG *pArg)
61596168
PUBLIC(RO(Proc))->Features.Info.Vendor.ID;
61606169
/* Initialize with any hypervisor found so far. */
61616170
PUBLIC(RO(Proc))->HypervisorID = pArg->HypervisorID;
6171+
61626172
return 0;
6173+
}
61636174
}
61646175

61656176
static void CoreFreqK_Alloc_Public_Cache_Level_Down(void)

ppc64le/corefreqk.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4491,6 +4491,15 @@ static int CoreFreqK_Scale_And_Compute_Level_Up(INIT_ARG *pArg)
44914491
COREFREQ_REV );
44924492

44934493
PUBLIC(RO(Proc))->CPU.Count = pArg->SMT_Count;
4494+
4495+
if (PUBLIC(RO(Proc))->CPU.Count > CORE_COUNT) {
4496+
pr_warn("CoreFreq: Detected %u CPUs, but built with CORE_COUNT=%u\n",
4497+
PUBLIC(RO(Proc))->CPU.Count, CORE_COUNT);
4498+
pr_warn("CoreFreq: Run 'make help' for instructions " \
4499+
"on setting CORE_COUNT.\n");
4500+
4501+
return -ENOMEM;
4502+
} else {
44944503
/* PreCompute SysGate memory allocation. */
44954504
PUBLIC(RO(Proc))->Gate.ReqMem.Size = sizeof(SYSGATE_RO);
44964505

@@ -4509,7 +4518,9 @@ static int CoreFreqK_Scale_And_Compute_Level_Up(INIT_ARG *pArg)
45094518

45104519
/* Initialize with any hypervisor found so far. */
45114520
PUBLIC(RO(Proc))->HypervisorID = pArg->HypervisorID;
4521+
45124522
return 0;
4523+
}
45134524
}
45144525

45154526
static void CoreFreqK_Alloc_Public_Cache_Level_Down(void)

riscv64/corefreqk.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4482,6 +4482,15 @@ static int CoreFreqK_Scale_And_Compute_Level_Up(INIT_ARG *pArg)
44824482
COREFREQ_REV );
44834483

44844484
PUBLIC(RO(Proc))->CPU.Count = pArg->SMT_Count;
4485+
4486+
if (PUBLIC(RO(Proc))->CPU.Count > CORE_COUNT) {
4487+
pr_warn("CoreFreq: Detected %u CPUs, but built with CORE_COUNT=%u\n",
4488+
PUBLIC(RO(Proc))->CPU.Count, CORE_COUNT);
4489+
pr_warn("CoreFreq: Run 'make help' for instructions " \
4490+
"on setting CORE_COUNT.\n");
4491+
4492+
return -ENOMEM;
4493+
} else {
44854494
/* PreCompute SysGate memory allocation. */
44864495
PUBLIC(RO(Proc))->Gate.ReqMem.Size = sizeof(SYSGATE_RO);
44874496

@@ -4500,7 +4509,9 @@ static int CoreFreqK_Scale_And_Compute_Level_Up(INIT_ARG *pArg)
45004509

45014510
/* Initialize with any hypervisor found so far. */
45024511
PUBLIC(RO(Proc))->HypervisorID = pArg->HypervisorID;
4512+
45034513
return 0;
4514+
}
45044515
}
45054516

45064517
static void CoreFreqK_Alloc_Public_Cache_Level_Down(void)

x86_64/corefreqk.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24639,6 +24639,15 @@ static int CoreFreqK_Scale_And_Compute_Level_Up(INIT_ARG *pArg)
2463924639
COREFREQ_REV );
2464024640

2464124641
PUBLIC(RO(Proc))->CPU.Count = pArg->SMT_Count;
24642+
24643+
if (PUBLIC(RO(Proc))->CPU.Count > CORE_COUNT) {
24644+
pr_warn("CoreFreq: Detected %u CPUs, but built with CORE_COUNT=%u\n",
24645+
PUBLIC(RO(Proc))->CPU.Count, CORE_COUNT);
24646+
pr_warn("CoreFreq: Run 'make help' for instructions " \
24647+
"on setting CORE_COUNT.\n");
24648+
24649+
return -ENOMEM;
24650+
} else {
2464224651
/* PreCompute SysGate memory allocation. */
2464324652
PUBLIC(RO(Proc))->Gate.ReqMem.Size = sizeof(SYSGATE_RO);
2464424653

@@ -24659,6 +24668,7 @@ static int CoreFreqK_Scale_And_Compute_Level_Up(INIT_ARG *pArg)
2465924668
Arch[GenuineArch].Architecture[0] = \
2466024669
PUBLIC(RO(Proc))->Features.Info.Vendor.ID;
2466124670
return 0;
24671+
}
2466224672
}
2466324673

2466424674
static void CoreFreqK_Alloc_Public_Cache_Level_Down(void)

0 commit comments

Comments
 (0)