Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp821679ybi; Thu, 30 May 2019 07:17:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyK2WGvCOUVUEgvgOF23ssSWNWaH1ROUncFbnDcHeJ2QDJYBTQjL+PKV/RGDbg5dRWRDTVq X-Received: by 2002:a63:5014:: with SMTP id e20mr3745887pgb.2.1559225848286; Thu, 30 May 2019 07:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559225848; cv=none; d=google.com; s=arc-20160816; b=E0dIroEe1yuuE72PB0/5RFhg3AZFtc4A/BWcxCc+YWjcaos6xcLq6ddBD/5mxIrnVe EtqhvtsuK4WRokYMsYghuqHLZ8dxUCkd6BmpGw8LH2Wiw3FkDp3EstmSdhSsTRUSG+ix QQTEh7buOswgWZ+7QENI5lDJz46gAx4qhqP0ytm5ncDXvvmG4fehCAOiIcYiX+gzFuz1 2iCXDOP+hgGKKEfQKH2R9JPXyI20BiM7BXcfhu9IXrhGNPd/rvdRVTFNN3NOua1AuZup lSrOT0FrqTxPCmtTNAex2e4WGG1pnuMVSWQOp/lmCcR7GDtk/DdfLI+Mtf88YAPA70Xa nZTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fZRalkZ5FLiTF1A+noiGYwAIpgLMbltXuA/H5b8rWfo=; b=tYOGyhXsdyp0aRuKiY3mbm8yqcQFuSGNs/xnyEJG357DNUhu46wE+8EQ9hg1SOmTue e3OdLH4Pb8Hk946Y+VbS/aUXfroLG7LMNhCK2DDbnpiwqczyiipxWe2nrxqkwDvf8tJY U4GrFOLBj+LRx+lKTJLldrhFqtN6VqfWldwtcDMlyR4S2XLkogr0E1QQZzY6tMZqSTS4 eSVvf3rsiAkSnG7aKpWjVZBXe2qGbNeM8ODKt3B9iFOt2tVn8cQOo1rt2IsLbOZ2FZML 6dOZZbr9kbk/OHpCBCS6iwT0Jp/H6+kSY1E45lSokeC9y5qOjdg6EEeS+keN2ElMUKsQ 04aQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g17si3176859pgd.389.2019.05.30.07.17.07; Thu, 30 May 2019 07:17:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727094AbfE3OPu (ORCPT + 99 others); Thu, 30 May 2019 10:15:50 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:36370 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725870AbfE3OPs (ORCPT ); Thu, 30 May 2019 10:15:48 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8BDF815AD; Thu, 30 May 2019 07:15:48 -0700 (PDT) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 73FF93F59C; Thu, 30 May 2019 07:15:45 -0700 (PDT) From: Vincenzo Frascino To: linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Arnd Bergmann , Russell King , Ralf Baechle , Paul Burton , Daniel Lezcano , Thomas Gleixner , Mark Salyzyn , Peter Collingbourne , Shuah Khan , Dmitry Safonov <0x7f454c46@gmail.com>, Rasmus Villemoes , Huw Davies Subject: [PATCH v6 01/19] kernel: Standardize vdso_datapage Date: Thu, 30 May 2019 15:15:13 +0100 Message-Id: <20190530141531.43462-2-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530141531.43462-1-vincenzo.frascino@arm.com> References: <20190530141531.43462-1-vincenzo.frascino@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In an effort to unify the common code for managing the vdso library in between all the architectures that support it, this patch tries to provide a common format for the vdso datapage. As a result of this, this patch generalized the data structures in vgtod.h from x86 private includes to general includes (include/vdso). Cc: Arnd Bergmann Signed-off-by: Vincenzo Frascino --- include/vdso/datapage.h | 91 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 include/vdso/datapage.h diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h new file mode 100644 index 000000000000..bb7087eec9bd --- /dev/null +++ b/include/vdso/datapage.h @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __VDSO_DATAPAGE_H +#define __VDSO_DATAPAGE_H + +#ifdef __KERNEL__ + +#ifndef __ASSEMBLY__ + +#include +#include +#include + +#define VDSO_BASES (CLOCK_TAI + 1) +#define VDSO_HRES (BIT(CLOCK_REALTIME) | \ + BIT(CLOCK_MONOTONIC) | \ + BIT(CLOCK_BOOTTIME) | \ + BIT(CLOCK_TAI)) +#define VDSO_COARSE (BIT(CLOCK_REALTIME_COARSE) | \ + BIT(CLOCK_MONOTONIC_COARSE)) +#define VDSO_RAW (BIT(CLOCK_MONOTONIC_RAW)) + +#define CS_HRES_COARSE 0 +#define CS_RAW 1 +#define CS_BASES (CS_RAW + 1) + +/** + * struct vdso_timestamp - basetime per clock_id + * @sec: seconds + * @nsec: nanoseconds + * + * There is one vdso_timestamp object in vvar for each vDSO-accelerated + * clock_id. For high-resolution clocks, this encodes the time + * corresponding to vdso_data.cycle_last. For coarse clocks this encodes + * the actual time. + * + * To be noticed that for highres clocks nsec is left-shifted by + * vdso_data.cs[x].shift. + */ +struct vdso_timestamp { + u64 sec; + u64 nsec; +}; + +/** + * struct vdso_data - vdso datapage representation + * @seq: timebase sequence counter + * @clock_mode: clock mode + * @cycle_last: timebase at clocksource init + * @mask: clocksource mask + * @mult: clocksource multiplier + * @shift: clocksource shift + * @basetime[clock_id]: basetime per clock_id + * @tz_minuteswest: minutes west of Greenwich + * @tz_dsttime: type of DST correction + * @hrtimer_res: hrtimer resolution + * + * vdso_data will be accessed by 64 bit and compat code at the same time + * so we should be careful before modifying this structure. + */ +struct vdso_data { + u32 seq; + + s32 clock_mode; + u64 cycle_last; + u64 mask; + u32 mult; + u32 shift; + + struct vdso_timestamp basetime[VDSO_BASES]; + + s32 tz_minuteswest; + s32 tz_dsttime; + u32 hrtimer_res; +}; + +/* + * We use the hidden visibility to prevent the compiler from generating a GOT + * relocation. Not only is going through a GOT useless (the entry couldn't and + * must not be overridden by another library), it does not even work: the linker + * cannot generate an absolute address to the data page. + * + * With the hidden visibility, the compiler simply generates a PC-relative + * relocation, and this is what we need. + */ +extern struct vdso_data _vdso_data[CS_BASES] __attribute__((visibility("hidden"))); + +#endif /* !__ASSEMBLY__ */ + +#endif /* __KERNEL__ */ + +#endif /* __VDSO_DATAPAGE_H */ -- 2.21.0