Skip to content

Commit e09c9b5

Browse files
mfaecknitzgregkh
authored andcommitted
MIPS: vdso: Invalid GIC access through VDSO
[ Upstream commit 47ce852 ] Accessing raw timers (currently only CLOCK_MONOTONIC_RAW) through VDSO doesn't return the correct time when using the GIC as clock source. The address of the GIC mapped page is in this case not calculated correctly. The GIC mapped page is calculated from the VDSO data by subtracting PAGE_SIZE: void *get_gic(const struct vdso_data *data) { return (void __iomem *)data - PAGE_SIZE; } However, the data pointer is not page aligned for raw clock sources. This is because the VDSO data for raw clock sources (CS_RAW = 1) is stored after the VDSO data for coarse clock sources (CS_HRES_COARSE = 0). Therefore, only the VDSO data for CS_HRES_COARSE is page aligned: +--------------------+ | | | vd[CS_RAW] | ---+ | vd[CS_HRES_COARSE] | | +--------------------+ | -PAGE_SIZE | | | | GIC mapped page | <--+ | | +--------------------+ When __arch_get_hw_counter() is called with &vd[CS_RAW], get_gic returns the wrong address (somewhere inside the GIC mapped page). The GIC counter values are not returned which results in an invalid time. Fixes: a7f4df4 ("MIPS: VDSO: Add implementations of gettimeofday() and clock_gettime()") Signed-off-by: Martin Fäcknitz <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 20f79ce commit e09c9b5

File tree

1 file changed

+1
-1
lines changed
  • arch/mips/include/asm/vdso

1 file changed

+1
-1
lines changed

arch/mips/include/asm/vdso/vdso.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static inline const struct vdso_data *get_vdso_data(void)
6767

6868
static inline void __iomem *get_gic(const struct vdso_data *data)
6969
{
70-
return (void __iomem *)data - PAGE_SIZE;
70+
return (void __iomem *)((unsigned long)data & PAGE_MASK) - PAGE_SIZE;
7171
}
7272

7373
#endif /* CONFIG_CLKSRC_MIPS_GIC */

0 commit comments

Comments
 (0)