From patchwork Fri Mar 13 15:43:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 11437161 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 05D191392 for ; Fri, 13 Mar 2020 15:44:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D17EC2074B for ; Fri, 13 Mar 2020 15:44:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ioD6+bJ1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D17EC2074B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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: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:In-Reply-To:References: List-Owner; bh=faz54xCnQTExPskMMFZY+DTW0DtoOX5DTSI4LB5t89I=; b=ioD6+bJ1cgbTDN onmjPywmdCjcVw6C4YvF43BHT56kivlfrO0J99uca0Bw74doDMQaG1OxcBH5AH4xTjalA16cNwA+M V5yPcLACyq5CMvIZpiCSX1nW7N/4rt5Fi/gJRVXS8q4BWqkO6LCvyVU4AfZlK95WNJt9kxrqqFQYy aduOgTLwZVMLFnH3RgAOf0PHQpA/sUYx9IFxKS93Dha8h/SWyNGSOnRI2crnnn30b9mwpJWyQooMJ Uu703LiDy/hH8/niq08Tl7G42GztRdvfro6/9vQmahktNm1uc3ICl7LkNFfYvjtNYLAIbuZS6wpTC 5zSjsXIVXzL9nkeFDk4Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jCmUA-000514-GI; Fri, 13 Mar 2020 15:44:30 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jCmTm-0004dL-9n for linux-arm-kernel@lists.infradead.org; Fri, 13 Mar 2020 15:44:08 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8913331B; Fri, 13 Mar 2020 08:44:05 -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 5E0C53F67D; Fri, 13 Mar 2020 08:44:02 -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, clang-built-linux@googlegroups.com, x86@kernel.org Subject: [PATCH v3 00/26] Introduce common headers for vDSO Date: Fri, 13 Mar 2020 15:43:19 +0000 Message-Id: <20200313154345.56760-1-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200313_084406_500613_1E5FD1E5 X-CRM114-Status: GOOD ( 20.00 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Nick Desaulniers , Dmitry Safonov <0x7f454c46@gmail.com>, Kees Cook , Arnd Bergmann , Stephen Boyd , Catalin Marinas , Will Deacon , Russell King , Mark Salyzyn , Paul Burton , Ingo Molnar , Borislav Petkov , Andy Lutomirski , Marc Zyngier , Thomas Gleixner , Vincenzo Frascino , Peter Collingbourne , Andrei Vagin Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Back in July last year we started having a problem in building compat vDSOs on arm64 [1] [2] that was not present when the arm64 porting to the Unified vDSO was done. In particular when the compat vDSO on such architecture is built with gcc it generates the warning below: In file included from ./arch/arm64/include/asm/thread_info.h:17:0, from ./include/linux/thread_info.h:38, from ./arch/arm64/include/asm/preempt.h:5, from ./include/linux/preempt.h:78, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./lib/vdso/gettimeofday.c:7, from :0: ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’: ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] u64 __addr = (u64)addr & ~__tag_shifted(0xff); ^ In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0, from ./arch/arm64/include/asm/processor.h:34, from ./arch/arm64/include/asm/elf.h:118, from ./include/linux/elf.h:5, from ./include/linux/elfnote.h:62, from arch/arm64/kernel/vdso32/note.c:11: ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’: ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] u64 __addr = (u64)addr & ~__tag_shifted(0xff); The same porting does not build at all when the selected compiler is clang. I started an investigation to try to understand better the problem and after various discussions at Plumbers and Recipes last year the conclusion was that the vDSO library as it stands it is including more headers that it needs. In particular, being a user-space library, it should require only the UAPI and a minimal vDSO kernel interface instead of all the kernel-related inline functions which are not directly used and in some cases can have side effects. To solve the problem, I decided to use the approach below: * Extract from include/linux/ the vDSO required kernel interface and place it in include/vdso/ * Make sure that where meaningful the kernel includes "vdso" headers. * Limit the vDSO library to include headers coming only from UAPI and "vdso" (with 2 exceptions compiler.h for barriers and param.h for HZ). * Adapt all the architectures that support the unified vDSO library to use "vdso" headers. According to me this approach allows up to exercise a better control on what the vDSO library can include and to prevent potential issues in future. This patch series contains the implementation of the described approach. The "vdso" headers have been verified on all the architectures that support unified vDSO using the vdsotest [3] testsuite for what concerns the vDSO part and randconfig to verify that they are included in the correct places. To simplify the testing, a copy of the patchset on top of a recent linux tree can be found at [4]. [1] https://github.com/ClangBuiltLinux/linux/issues/595 [2] https://lore.kernel.org/lkml/20190926151704.GH9689@arrakis.emea.arm.com [3] https://github.com/nathanlynch/vdsotest [4] git://linux-arm.org/linux-vf.git common-headers/v3 Changes: -------- v3: - Changed the namespace from common to vdso. - Addressed an issue involving parisc modules compilation. - Added vdso header for clocksource.h. - Addressed review comments. - Rebased on tip/timers/core. v2: - Addressed review comments for clang support. - Rebased on 5.6-rc4. Cc: Catalin Marinas Cc: Will Deacon Cc: Arnd Bergmann Cc: Russell King Cc: Paul Burton Cc: Thomas Gleixner Cc: Andy Lutomirski Cc: Ingo Molnar Cc: Borislav Petkov Cc: Stephen Boyd Cc: Mark Salyzyn Cc: Kees Cook Cc: Peter Collingbourne Cc: Dmitry Safonov <0x7f454c46@gmail.com> Cc: Andrei Vagin Cc: Nick Desaulniers Cc: Marc Zyngier Cc: Mark Rutland Signed-off-by: Vincenzo Frascino Vincenzo Frascino (26): linux/const.h: Extract common header for vDSO linux/bits.h: Extract common header for vDSO linux/limits.h: Extract common header for vDSO x86:Introduce asm/vdso/clocksource.h arm: Introduce asm/vdso/clocksource.h arm64: Introduce asm/vdso/clocksource.h mips: Introduce asm/vdso/clocksource.h linux/clocksource.h: Extract common header for vDSO linux/math64.h: Extract common header for vDSO linux/time.h: Extract common header for vDSO linux/time32.h: Extract common header for vDSO linux/time64.h: Extract common header for vDSO linux/jiffies.h: Extract common header for vDSO linux/ktime.h: Extract common header for vDSO common: Introduce processor.h scripts: Fix the inclusion order in modpost linux/elfnote.h: Replace elf.h with UAPI equivalent arm64: Introduce asm/vdso/processor.h arm64: vdso: Include common headers in the vdso library arm64: vdso32: Include common headers in the vdso library arm64: Introduce asm/vdso/arch_timer.h mips: vdso: Enable mips to use common headers x86: vdso: Enable x86 to use common headers arm: vdso: Enable arm to use common headers lib: vdso: Enable common headers arm64: vdso32: Enable Clang Compilation arch/arm/include/asm/clocksource.h | 6 +-- arch/arm/include/asm/cp15.h | 20 +--------- arch/arm/include/asm/processor.h | 11 +----- arch/arm/include/asm/vdso/clocksource.h | 8 ++++ arch/arm/include/asm/vdso/cp15.h | 38 +++++++++++++++++++ arch/arm/include/asm/vdso/gettimeofday.h | 4 +- arch/arm/include/asm/vdso/processor.h | 22 +++++++++++ arch/arm64/include/asm/arch_timer.h | 29 +++----------- arch/arm64/include/asm/clocksource.h | 3 +- arch/arm64/include/asm/processor.h | 16 +------- arch/arm64/include/asm/vdso/arch_timer.h | 33 ++++++++++++++++ arch/arm64/include/asm/vdso/clocksource.h | 8 ++++ .../include/asm/vdso/compat_gettimeofday.h | 2 +- arch/arm64/include/asm/vdso/gettimeofday.h | 8 ++-- arch/arm64/include/asm/vdso/processor.h | 31 +++++++++++++++ arch/arm64/kernel/vdso/vgettimeofday.c | 2 - arch/arm64/kernel/vdso32/Makefile | 11 ++++++ arch/arm64/kernel/vdso32/vgettimeofday.c | 3 -- arch/mips/include/asm/clocksource.h | 4 +- arch/mips/include/asm/processor.h | 16 +------- arch/mips/include/asm/vdso/clocksource.h | 9 +++++ arch/mips/include/asm/vdso/gettimeofday.h | 4 -- arch/mips/include/asm/vdso/processor.h | 27 +++++++++++++ arch/x86/include/asm/clocksource.h | 5 +-- arch/x86/include/asm/processor.h | 12 +----- arch/x86/include/asm/vdso/clocksource.h | 10 +++++ arch/x86/include/asm/vdso/processor.h | 23 +++++++++++ include/linux/bits.h | 2 +- include/linux/clocksource.h | 11 +----- include/linux/const.h | 5 +-- include/linux/elfnote.h | 2 +- include/linux/jiffies.h | 4 +- include/linux/ktime.h | 9 +---- include/linux/limits.h | 13 +------ include/linux/math64.h | 20 +--------- include/linux/time.h | 5 +-- include/linux/time32.h | 14 +------ include/linux/time64.h | 10 +---- include/vdso/bits.h | 9 +++++ include/vdso/clocksource.h | 23 +++++++++++ include/vdso/const.h | 10 +++++ include/vdso/datapage.h | 33 ++++++++++++++-- include/vdso/jiffies.h | 11 ++++++ include/vdso/ktime.h | 16 ++++++++ include/vdso/limits.h | 18 +++++++++ include/vdso/math64.h | 24 ++++++++++++ include/vdso/processor.h | 14 +++++++ include/vdso/time.h | 12 ++++++ include/vdso/time32.h | 17 +++++++++ include/vdso/time64.h | 14 +++++++ lib/vdso/gettimeofday.c | 22 ----------- scripts/mod/modpost.c | 6 ++- 52 files changed, 459 insertions(+), 230 deletions(-) create mode 100644 arch/arm/include/asm/vdso/clocksource.h create mode 100644 arch/arm/include/asm/vdso/cp15.h create mode 100644 arch/arm/include/asm/vdso/processor.h create mode 100644 arch/arm64/include/asm/vdso/arch_timer.h create mode 100644 arch/arm64/include/asm/vdso/clocksource.h create mode 100644 arch/arm64/include/asm/vdso/processor.h create mode 100644 arch/mips/include/asm/vdso/clocksource.h create mode 100644 arch/mips/include/asm/vdso/processor.h create mode 100644 arch/x86/include/asm/vdso/clocksource.h create mode 100644 arch/x86/include/asm/vdso/processor.h create mode 100644 include/vdso/bits.h create mode 100644 include/vdso/clocksource.h create mode 100644 include/vdso/const.h create mode 100644 include/vdso/jiffies.h create mode 100644 include/vdso/ktime.h create mode 100644 include/vdso/limits.h create mode 100644 include/vdso/math64.h create mode 100644 include/vdso/processor.h create mode 100644 include/vdso/time.h create mode 100644 include/vdso/time32.h create mode 100644 include/vdso/time64.h