Skip to content

Commit 7c8d354

Browse files
committed
[CR] Fix memory allocation in kernel pages for the SysGate
1 parent e6d383a commit 7c8d354

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

aarch64/corefreqd.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,7 @@ void PerCore_Update( RO(SHM_STRUCT) *RO(Shm), RO(PROC) *RO(Proc),
11311131
int SysGate_OnDemand(REF *Ref, int operation)
11321132
{
11331133
int rc = -1;
1134-
const size_t allocPages = \
1135-
(size_t)PAGE_SIZE << Ref->RO(Proc)->Gate.ReqMem.Order;
1134+
const size_t allocPages = Ref->RO(Proc)->Gate.ReqMem.Size;
11361135

11371136
if (operation == 0) {
11381137
if (Ref->RO(SysGate) != NULL) {

aarch64/corefreqk.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3478,9 +3478,7 @@ static long SysGate_OnDemand(void)
34783478
GFP_KERNEL);
34793479
if (PUBLIC(OF(Gate)) != NULL)
34803480
{
3481-
const size_t
3482-
allocPages = PAGE_SIZE << PUBLIC(RO(Proc))->Gate.ReqMem.Order;
3483-
memset(PUBLIC(OF(Gate)), 0, allocPages);
3481+
memset(PUBLIC(OF(Gate)), 0, PUBLIC(RO(Proc))->Gate.ReqMem.Size);
34843482
rc = 0;
34853483
}
34863484
} else { /* Already allocated */
@@ -4897,9 +4895,7 @@ static int CoreFreqK_mmap(struct file *pfile, struct vm_area_struct *vma)
48974895
case 1:
48984896
fallthrough;
48994897
case 0: {
4900-
const unsigned long
4901-
secSize = PAGE_SIZE << PUBLIC(RO(Proc))->Gate.ReqMem.Order;
4902-
if (reqSize != secSize) {
4898+
if (reqSize != PUBLIC(RO(Proc))->Gate.ReqMem.Size) {
49034899
return -EAGAIN;
49044900
}
49054901

@@ -5644,6 +5640,9 @@ static int CoreFreqK_Scale_And_Compute_Level_Up(INIT_ARG *pArg)
56445640
PUBLIC(RO(Proc))->Gate.ReqMem.Order = \
56455641
get_order(PUBLIC(RO(Proc))->Gate.ReqMem.Size);
56465642

5643+
PUBLIC(RO(Proc))->Gate.ReqMem.Size = \
5644+
PAGE_SIZE << PUBLIC(RO(Proc))->Gate.ReqMem.Order;
5645+
56475646
PUBLIC(RO(Proc))->Registration.AutoClock = AutoClock;
56485647
PUBLIC(RO(Proc))->Registration.Experimental = Experimental;
56495648

x86_64/corefreqd.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8143,8 +8143,7 @@ void PerCore_Update( RO(SHM_STRUCT) *RO(Shm), RO(PROC) *RO(Proc),
81438143
int SysGate_OnDemand(REF *Ref, int operation)
81448144
{
81458145
int rc = -1;
8146-
const size_t allocPages = \
8147-
(size_t)PAGE_SIZE << Ref->RO(Proc)->Gate.ReqMem.Order;
8146+
const size_t allocPages = Ref->RO(Proc)->Gate.ReqMem.Size;
81488147

81498148
if (operation == 0) {
81508149
if (Ref->RO(SysGate) != NULL) {

x86_64/corefreqk.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20331,9 +20331,7 @@ static long SysGate_OnDemand(void)
2033120331
GFP_KERNEL);
2033220332
if (PUBLIC(OF(Gate)) != NULL)
2033320333
{
20334-
const size_t
20335-
allocPages = PAGE_SIZE << PUBLIC(RO(Proc))->Gate.ReqMem.Order;
20336-
memset(PUBLIC(OF(Gate)), 0, allocPages);
20334+
memset(PUBLIC(OF(Gate)), 0, PUBLIC(RO(Proc))->Gate.ReqMem.Size);
2033720335
rc = 0;
2033820336
}
2033920337
} else { /* Already allocated */
@@ -23376,9 +23374,7 @@ static int CoreFreqK_mmap(struct file *pfile, struct vm_area_struct *vma)
2337623374
case 1:
2337723375
fallthrough;
2337823376
case 0: {
23379-
const unsigned long
23380-
secSize = PAGE_SIZE << PUBLIC(RO(Proc))->Gate.ReqMem.Order;
23381-
if (reqSize != secSize) {
23377+
if (reqSize != PUBLIC(RO(Proc))->Gate.ReqMem.Size) {
2338223378
return -EAGAIN;
2338323379
}
2338423380

@@ -24141,6 +24137,9 @@ static int CoreFreqK_Scale_And_Compute_Level_Up(INIT_ARG *pArg)
2414124137
PUBLIC(RO(Proc))->Gate.ReqMem.Order = \
2414224138
get_order(PUBLIC(RO(Proc))->Gate.ReqMem.Size);
2414324139

24140+
PUBLIC(RO(Proc))->Gate.ReqMem.Size = \
24141+
PAGE_SIZE << PUBLIC(RO(Proc))->Gate.ReqMem.Order;
24142+
2414424143
PUBLIC(RO(Proc))->Registration.AutoClock = AutoClock;
2414524144
PUBLIC(RO(Proc))->Registration.Experimental = Experimental;
2414624145

0 commit comments

Comments
 (0)