1c6b99bedSHuacai Chen /* SPDX-License-Identifier: GPL-2.0-or-later */ 2c6b99bedSHuacai Chen /* 3c6b99bedSHuacai Chen * Author: Huacai Chen <chenhuacai@loongson.cn> 4c6b99bedSHuacai Chen * Copyright (C) 2020-2022 Loongson Technology Corporation Limited 5c6b99bedSHuacai Chen */ 6c6b99bedSHuacai Chen 7c6b99bedSHuacai Chen #ifndef __ASSEMBLY__ 8c6b99bedSHuacai Chen 9c6b99bedSHuacai Chen #include <asm/asm.h> 10c6b99bedSHuacai Chen #include <asm/page.h> 11dce6098bSHuacai Chen #include <asm/vdso.h> 12dce6098bSHuacai Chen 13dce6098bSHuacai Chen struct vdso_pcpu_data { 14dce6098bSHuacai Chen u32 node; 15dce6098bSHuacai Chen } ____cacheline_aligned_in_smp; 16dce6098bSHuacai Chen 17dce6098bSHuacai Chen struct loongarch_vdso_data { 18dce6098bSHuacai Chen struct vdso_pcpu_data pdata[NR_CPUS]; 19dce6098bSHuacai Chen }; 20dce6098bSHuacai Chen 21*aa5e65dcSTiezhu Yang /* 22*aa5e65dcSTiezhu Yang * The layout of vvar: 23*aa5e65dcSTiezhu Yang * 24*aa5e65dcSTiezhu Yang * high 25*aa5e65dcSTiezhu Yang * +---------------------+--------------------------+ 26*aa5e65dcSTiezhu Yang * | loongarch vdso data | LOONGARCH_VDSO_DATA_SIZE | 27*aa5e65dcSTiezhu Yang * +---------------------+--------------------------+ 28*aa5e65dcSTiezhu Yang * | time-ns vdso data | PAGE_SIZE | 29*aa5e65dcSTiezhu Yang * +---------------------+--------------------------+ 30*aa5e65dcSTiezhu Yang * | generic vdso data | PAGE_SIZE | 31*aa5e65dcSTiezhu Yang * +---------------------+--------------------------+ 32*aa5e65dcSTiezhu Yang * low 33*aa5e65dcSTiezhu Yang */ 34*aa5e65dcSTiezhu Yang #define LOONGARCH_VDSO_DATA_SIZE PAGE_ALIGN(sizeof(struct loongarch_vdso_data)) 35*aa5e65dcSTiezhu Yang #define LOONGARCH_VDSO_DATA_PAGES (LOONGARCH_VDSO_DATA_SIZE >> PAGE_SHIFT) 36*aa5e65dcSTiezhu Yang 37*aa5e65dcSTiezhu Yang enum vvar_pages { 38*aa5e65dcSTiezhu Yang VVAR_GENERIC_PAGE_OFFSET, 39*aa5e65dcSTiezhu Yang VVAR_TIMENS_PAGE_OFFSET, 40*aa5e65dcSTiezhu Yang VVAR_LOONGARCH_PAGES_START, 41*aa5e65dcSTiezhu Yang VVAR_LOONGARCH_PAGES_END = VVAR_LOONGARCH_PAGES_START + LOONGARCH_VDSO_DATA_PAGES - 1, 42*aa5e65dcSTiezhu Yang VVAR_NR_PAGES, 43*aa5e65dcSTiezhu Yang }; 44*aa5e65dcSTiezhu Yang 45*aa5e65dcSTiezhu Yang #define VVAR_SIZE (VVAR_NR_PAGES << PAGE_SHIFT) 46c6b99bedSHuacai Chen get_vdso_base(void)47c6b99bedSHuacai Chenstatic inline unsigned long get_vdso_base(void) 48c6b99bedSHuacai Chen { 49c6b99bedSHuacai Chen unsigned long addr; 50c6b99bedSHuacai Chen 51c6b99bedSHuacai Chen __asm__( 52c6b99bedSHuacai Chen " la.pcrel %0, _start\n" 53c6b99bedSHuacai Chen : "=r" (addr) 54c6b99bedSHuacai Chen : 55c6b99bedSHuacai Chen :); 56c6b99bedSHuacai Chen 57c6b99bedSHuacai Chen return addr; 58c6b99bedSHuacai Chen } 59c6b99bedSHuacai Chen get_vdso_data(void)60*aa5e65dcSTiezhu Yangstatic inline unsigned long get_vdso_data(void) 61c6b99bedSHuacai Chen { 62*aa5e65dcSTiezhu Yang return get_vdso_base() - VVAR_SIZE; 63c6b99bedSHuacai Chen } 64c6b99bedSHuacai Chen 65c6b99bedSHuacai Chen #endif /* __ASSEMBLY__ */ 66