Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3865934pxv; Mon, 19 Jul 2021 10:37:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHPNMxXxGpv0jR5WfDu4rywLxeOuVTk1tDmqQlHH2jnrCSRK4DnDYmtAHhjLgqzV/ULtRv X-Received: by 2002:a17:906:c29a:: with SMTP id r26mr29020380ejz.235.1626716226567; Mon, 19 Jul 2021 10:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626716226; cv=none; d=google.com; s=arc-20160816; b=pNsWQgHlrMK0CvXsyZFJvVab1NA/bAr82Vu2SkISQAZyvY1VTDo56I+rAjbEaLe2bw yzcvhyUg7Q1xLSEKWHlS8EuLSmR8nl5/qCBn479PkSiPr6sHeAnv82KYkL5bRlcxuwa9 u3yHpc2Vhb/1XNFFL8llUhIxWIEBQkivn+5KA+YgRwnxpwUKgeDzuzpR0bVOo27CBlvO S7ALqKdm/LBRJMhVZtX0emvDpdt4O7xhvCke3tyrZvT/aDNt1uFKvslLwMQy+rtpBLIR daQ2wLfB+9b8EYYZ6zkLcGX5Q8NFWjGYNaDFmsA4jstygvbv63Ujq9/64Otr1m7p2uax Uv0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=K87LKbXNtY//OwDXppbbobycULv6IxGa/MEGLtStpMU=; b=UGECqWeHIWSAy9aRG3odN46UQRhSj15wGD7Hs2SRkv322FeVnXDXLYy4VxiWO9T1OL Pfkp0x1enTbNLrCiOngijemBZ5VhfGO8NKGyFJu8VArwF95v09WAs4fIYAjcM8+jPw+7 Kuu7o1N16oyxzyBMpx9PxPNsERusyo2dL+6Ih/xznLh7TR7/T+ki/etnQy5BPEhtcHJ3 9HaUPIskAzhUPMmLKv7wADfAKOwcYvPpHCOqK5IDnr68KMHJEBv6Wmnn1387nAgum5JT +JfJgrMr0w9tTV7b5Ouy79puJCaq+iohrF9XAmM4eSrMmWb8OlixPHj1Jvh24IaUeYGG Gkog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0tZkHmks; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t12si23202577eje.175.2021.07.19.10.36.44; Mon, 19 Jul 2021 10:37:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0tZkHmks; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353106AbhGSQuT (ORCPT + 99 others); Mon, 19 Jul 2021 12:50:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:38038 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348082AbhGSPYd (ORCPT ); Mon, 19 Jul 2021 11:24:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F2EAE61434; Mon, 19 Jul 2021 16:01:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710500; bh=wrAXyTUu8iaEYGFgf4AL1J9lnFaFjPOR7mr8+BQtH7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0tZkHmksTlDIH/chAO2iXP9TcVvodZihWbxM205UVYvYBFls3dEe/uXP3a2yLXmd6 mZfJKP0QS+CENjob2aBG2ejQ/UucfhMVnujPIcPXdBuGvpJ2xR06lNaSOoe4xsFYf9 VHhdGHwXG7yp4mXTQQoQP1Q5JpP48Ei7pSzVdMrg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Martin=20F=C3=A4cknitz?= , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 5.10 242/243] MIPS: vdso: Invalid GIC access through VDSO Date: Mon, 19 Jul 2021 16:54:31 +0200 Message-Id: <20210719144948.735522139@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.904087935@linuxfoundation.org> References: <20210719144940.904087935@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Martin Fäcknitz [ Upstream commit 47ce8527fbba145a7723685bc9a27d9855e06491 ] 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: a7f4df4e21dd ("MIPS: VDSO: Add implementations of gettimeofday() and clock_gettime()") Signed-off-by: Martin Fäcknitz Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- arch/mips/include/asm/vdso/vdso.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/include/asm/vdso/vdso.h b/arch/mips/include/asm/vdso/vdso.h index 737ddfc3411c..a327ca21270e 100644 --- a/arch/mips/include/asm/vdso/vdso.h +++ b/arch/mips/include/asm/vdso/vdso.h @@ -67,7 +67,7 @@ static inline const struct vdso_data *get_vdso_data(void) static inline void __iomem *get_gic(const struct vdso_data *data) { - return (void __iomem *)data - PAGE_SIZE; + return (void __iomem *)((unsigned long)data & PAGE_MASK) - PAGE_SIZE; } #endif /* CONFIG_CLKSRC_MIPS_GIC */ -- 2.30.2