Skip to content

Commit 2ed119a

Browse files
committed
LoongArch: Set correct size for vDSO code mapping
The current size of vDSO code mapping is hardcoded to PAGE_SIZE. This cannot work for 4KB page size after commit 18efd0b ("LoongArch: vDSO: Wire up getrandom() vDSO implementation") because the code size increases to 8KB. Thus set the code mapping size to its real size, i.e. PAGE_ALIGN(vdso_end - vdso_start). Fixes: 18efd0b ("LoongArch: vDSO: Wire up getrandom() vDSO implementation") Reviewed-by: Xi Ruoyao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 69cc6fa commit 2ed119a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/loongarch/kernel/vdso.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ static union {
3434
struct loongarch_vdso_data vdata;
3535
} loongarch_vdso_data __page_aligned_data;
3636

37-
static struct page *vdso_pages[] = { NULL };
3837
struct vdso_data *vdso_data = generic_vdso_data.data;
3938
struct vdso_pcpu_data *vdso_pdata = loongarch_vdso_data.vdata.pdata;
4039
struct vdso_rng_data *vdso_rng_data = &loongarch_vdso_data.vdata.rng_data;
@@ -85,10 +84,8 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm,
8584

8685
struct loongarch_vdso_info vdso_info = {
8786
.vdso = vdso_start,
88-
.size = PAGE_SIZE,
8987
.code_mapping = {
9088
.name = "[vdso]",
91-
.pages = vdso_pages,
9289
.mremap = vdso_mremap,
9390
},
9491
.data_mapping = {
@@ -103,11 +100,14 @@ static int __init init_vdso(void)
103100
unsigned long i, cpu, pfn;
104101

105102
BUG_ON(!PAGE_ALIGNED(vdso_info.vdso));
106-
BUG_ON(!PAGE_ALIGNED(vdso_info.size));
107103

108104
for_each_possible_cpu(cpu)
109105
vdso_pdata[cpu].node = cpu_to_node(cpu);
110106

107+
vdso_info.size = PAGE_ALIGN(vdso_end - vdso_start);
108+
vdso_info.code_mapping.pages =
109+
kcalloc(vdso_info.size / PAGE_SIZE, sizeof(struct page *), GFP_KERNEL);
110+
111111
pfn = __phys_to_pfn(__pa_symbol(vdso_info.vdso));
112112
for (i = 0; i < vdso_info.size / PAGE_SIZE; i++)
113113
vdso_info.code_mapping.pages[i] = pfn_to_page(pfn + i);

0 commit comments

Comments
 (0)