From patchwork Fri Feb 22 12:24:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 10825827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C55701575 for ; Fri, 22 Feb 2019 12:25:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0FF3286DF for ; Fri, 22 Feb 2019 12:25:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4595302DB; Fri, 22 Feb 2019 12:25:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 41839286DF for ; Fri, 22 Feb 2019 12:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NzY1YB1qDmAL60i0tiETXFBRLTMDRZniozxlE5ybqcA=; b=An//lSIquYLfro v5XNj4t/0F5kJ80mwdtu6iRcC2LZJh217RMswGlTTv96fGPoZJFk1c9ASieDpvXZafgl9KNeUHjDr drp/2YSqvgzqeio5p0sVlGI1GjrTwRDyLBxXKE6Je+Rb/D2VbJKHdcanQF5n6nvTc/YLOPgDC85GO UivUioGFSlZyrovpxnzqXLU9XImFmM0KF/1UTulNJVuz9wkAlu9byCeb1I1U2MGRq79wyW74zEMgd toLkL9T4ESEKcK8IeNGdeHaJm0vAREIesB7o7zEJ7cx0DqxFgrtg9Hhys6A5dZa1huJmpECYvzY0c MXOneiHTx7SCK1DLfmsQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gx9tm-0008Hd-Ny; Fri, 22 Feb 2019 12:25:50 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gx9td-00088J-0L for linux-arm-kernel@lists.infradead.org; Fri, 22 Feb 2019 12:25:42 +0000 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 D1CC515AB; Fri, 22 Feb 2019 04:25:40 -0800 (PST) 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 543D83F690; Fri, 22 Feb 2019 04:25:38 -0800 (PST) From: Vincenzo Frascino To: linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 01/23] kernel: Standardize vdso_datapage Date: Fri, 22 Feb 2019 12:24:08 +0000 Message-Id: <20190222122430.21180-2-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190222122430.21180-1-vincenzo.frascino@arm.com> References: <20190222122430.21180-1-vincenzo.frascino@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190222_042541_056460_1220F37D X-CRM114-Status: GOOD ( 16.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Shuah Khan , Arnd Bergmann , Catalin Marinas , Daniel Lezcano , Will Deacon , Russell King , Ralf Baechle , Mark Salyzyn , Paul Burton , Dmitry Safonov <0x7f454c46@gmail.com>, Rasmus Villemoes , Thomas Gleixner , Peter Collingbourne Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 | 74 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 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..da346ad02b03 --- /dev/null +++ b/include/vdso/datapage.h @@ -0,0 +1,74 @@ +/* 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_MONOTONIC_RAW) | \ + BIT(CLOCK_BOOTTIME) | \ + BIT(CLOCK_TAI)) +#define VDSO_COARSE (BIT(CLOCK_REALTIME_COARSE) | \ + BIT(CLOCK_MONOTONIC_COARSE)) + +/* + * 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; +}; + +#define CLOCKSOURCE_RAW 0 +#define CLOCKSOURCE_MONO 1 +#define CLOCKSOURCE_BASES (CLOCKSOURCE_MONO + 1) + +/* + * There is one vdso_clocksource object in vvar for each vDSO clocksource + * (mono, raw). This struct is designed to keep vdso_data "cache-line friendly" + * and optimal in terms of access pattern. + * + * Note that mask and shift are the same for mono and raw. + */ +struct vdso_clocksource { + u64 mask; /* Clocksource mask */ + u32 mult; /* Clocksource multiplier */ + u32 shift; /* Clocksource shift */ +}; + +/* + * vdso_data will be accessed by 32 and 64 bit code at the same time + * so we should be careful before modifying this structure. + */ +struct vdso_data { + u32 seq; /* Timebase sequence counter */ + + s32 clock_mode; + u64 cycle_last; /* Timebase at clocksource init */ + + struct vdso_clocksource cs[CLOCKSOURCE_BASES]; + struct vdso_timestamp basetime[VDSO_BASES]; + + s32 tz_minuteswest; /* Timezone definitions */ + s32 tz_dsttime; +}; + +#endif /* !__ASSEMBLY__ */ + +#endif /* __KERNEL__ */ + +#endif /* __VDSO_DATAPAGE_H */