]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
LoongArch: Set correct size for vDSO code mapping
authorHuacai Chen <chenhuacai@loongson.cn>
Mon, 21 Oct 2024 14:11:19 +0000 (22:11 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Mon, 21 Oct 2024 14:11:19 +0000 (22:11 +0800)
The current size of vDSO code mapping is hardcoded to PAGE_SIZE. This
cannot work for 4KB page size after commit 18efd0b10e0fd77 ("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: 18efd0b10e0fd77 ("LoongArch: vDSO: Wire up getrandom() vDSO implementation")
Reviewed-by: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kernel/vdso.c

index f6fcc52aefae0043e307327b8e7a5872fad0822a..2c0d852ca5366b378088a492cf0942d9309dd809 100644 (file)
@@ -34,7 +34,6 @@ static union {
        struct loongarch_vdso_data vdata;
 } loongarch_vdso_data __page_aligned_data;
 
-static struct page *vdso_pages[] = { NULL };
 struct vdso_data *vdso_data = generic_vdso_data.data;
 struct vdso_pcpu_data *vdso_pdata = loongarch_vdso_data.vdata.pdata;
 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,
 
 struct loongarch_vdso_info vdso_info = {
        .vdso = vdso_start,
-       .size = PAGE_SIZE,
        .code_mapping = {
                .name = "[vdso]",
-               .pages = vdso_pages,
                .mremap = vdso_mremap,
        },
        .data_mapping = {
@@ -103,11 +100,14 @@ static int __init init_vdso(void)
        unsigned long i, cpu, pfn;
 
        BUG_ON(!PAGE_ALIGNED(vdso_info.vdso));
-       BUG_ON(!PAGE_ALIGNED(vdso_info.size));
 
        for_each_possible_cpu(cpu)
                vdso_pdata[cpu].node = cpu_to_node(cpu);
 
+       vdso_info.size = PAGE_ALIGN(vdso_end - vdso_start);
+       vdso_info.code_mapping.pages =
+               kcalloc(vdso_info.size / PAGE_SIZE, sizeof(struct page *), GFP_KERNEL);
+
        pfn = __phys_to_pfn(__pa_symbol(vdso_info.vdso));
        for (i = 0; i < vdso_info.size / PAGE_SIZE; i++)
                vdso_info.code_mapping.pages[i] = pfn_to_page(pfn + i);