]> git.baikalelectronics.ru Git - kernel.git/commit
MIPS: vdso: Invalid GIC access through VDSO
authorMartin Fäcknitz <faecknitz@hotsplots.de>
Mon, 5 Jul 2021 00:03:54 +0000 (02:03 +0200)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Fri, 9 Jul 2021 13:29:06 +0000 (15:29 +0200)
commit36ff3a236630540df8977faef6f98b14b131898b
treef5800a03c5943f1bf2c951b625fe4cb501c86da5
parent2db87bfa7aae1758b40d7cf8519bd0a5723dfb78
MIPS: vdso: Invalid GIC access through VDSO

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: 93c453ef4c00 ("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>
arch/mips/include/asm/vdso/vdso.h