linux/arch/mips/vdso
Martin Fäcknitz 8553099bdb MIPS: vdso: Invalid GIC access through VDSO
[ Upstream commit 47ce8527fb ]

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: a7f4df4e21 ("MIPS: VDSO: Add implementations of gettimeofday() and clock_gettime()")
Signed-off-by: Martin Fäcknitz <faecknitz@hotsplots.de>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-07-20 16:16:15 +02:00
..
.gitignore
elf.S MIPS: VDSO: Replace __mips_isa_rev with MIPS_ISA_REV 2018-03-09 11:22:48 +00:00
genvdso.c mips/vdso: Fix resource leaks in genvdso.c 2020-09-03 11:24:21 +02:00
genvdso.h MIPS: genvdso: Remove GOT checks 2018-08-06 15:28:46 -07:00
gettimeofday.c mips: Do not include hi and lo in clobber list for R6 2021-05-07 10:49:25 +02:00
Makefile MIPS: VDSO: Use CLANG_FLAGS instead of filtering out '--target=' 2021-03-07 12:18:54 +01:00
sigreturn.S MIPS: Add DWARF unwinding to assembly 2017-09-06 11:01:52 +02:00
vdso.h MIPS: vdso: Invalid GIC access through VDSO 2021-07-20 16:16:15 +02:00
vdso.lds.S