Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6837514ybf; Fri, 6 Mar 2020 05:33:29 -0800 (PST) X-Google-Smtp-Source: ADFU+vuuphVkVPs34lpTEsJi8TrkMqX5cYeJ/ckzFirSZlq05+1r4aLuhToN87VAXSUyona4dQGJ X-Received: by 2002:a05:6830:1e07:: with SMTP id s7mr2555223otr.85.1583501609702; Fri, 06 Mar 2020 05:33:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583501609; cv=none; d=google.com; s=arc-20160816; b=H3jFLkk+CD4d6brFhVqssHckyaf45uTsx0n13yFq/qGYwPYPhG8lq1BoQqD6YGgJnM aVnCKUauyV1tzEJB2R07Jqex2ZoP4Bbjo9jSG/c1CTTzXOwyIrvaa+iF75EyhOUIWXjh I1iSRWJ5OpzSkweYX30YS2B3CLTjuai2APJODYKmCoClq95L15ErGCOLm3OeatDCw7lH uSNI4/6/0q1sDNTdR8n8YB9u80TOMR+dZmKSoqIu3fXSBHrcQWRBPL0BYtW9HUQdMbbj lcfwecnV6yRghpAqvRte69vuQYGRREiUsybQusvgQlq1Z4HAB5amELebTUCqQYmuVGui zCcA== 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 :message-id:date:subject:cc:to:from; bh=IxI2pGeqlX2Q2dC7GMSJDpekDt++8MBUPgut9FN6NbQ=; b=T+CtxRHJeZiwxuWB3Re7Z1C8upo6OQNdQ2tJuHs+DBryAX16sC4vaZycbMQKi6/Eqq Hhe98nsPFEzsnuMJVmFdLwuniYjzzS1GP4MDyKKu6iKGwUk444VMGqUO9Dnlw83iRBJl aRizrLl29yIj7slav0shpXWtoRV8ZgNZ2tDbTfDZyRz8TuomSdMd1G5ZJEUR+OBv30FD 9aGl6VJ5mPV9fntD229MAjBwi+GTF43qRTyTyUBSbHYxOBGP2MOgNuJm4WDyCjfpVDyo x0j9dvtN+vfCq+v4XbHVzAOkerRGSjHrW8bEBc6bzua0FhLstEf9SL7RhqZ68giUOYTV uo3A== 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 g23si1415179otr.31.2020.03.06.05.33.12; Fri, 06 Mar 2020 05:33:29 -0800 (PST) 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 S1726958AbgCFNcz (ORCPT + 99 others); Fri, 6 Mar 2020 08:32:55 -0500 Received: from foss.arm.com ([217.140.110.172]:33262 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbgCFNcy (ORCPT ); Fri, 6 Mar 2020 08:32:54 -0500 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 05A3631B; Fri, 6 Mar 2020 05:32:54 -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 402E93F6CF; Fri, 6 Mar 2020 05:32:51 -0800 (PST) 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 Cc: Vincenzo Frascino , Catalin Marinas , Will Deacon , Arnd Bergmann , Russell King , Paul Burton , Thomas Gleixner , Andy Lutomirski , Ingo Molnar , Borislav Petkov , Stephen Boyd , Mark Salyzyn , Kees Cook , Peter Collingbourne , Dmitry Safonov <0x7f454c46@gmail.com>, Andrei Vagin , Nick Desaulniers Subject: [PATCH v2 00/20] Introduce common headers Date: Fri, 6 Mar 2020 13:32:22 +0000 Message-Id: <20200306133242.26279-1-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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/common/ * Make sure that where meaningful the kernel includes "common" * Limit the vDSO library to include headers coming only from UAPI and "common" (with 2 exceptions compiler.h for barriers and param.h for HZ). * Adapt all the architectures that support the unified vDSO library to use "common" 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 "common" 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/v2 Changes: -------- 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 Signed-off-by: Vincenzo Frascino Vincenzo Frascino (20): linux/const.h: Extract common header for vDSO linux/bits.h: Extract common header for vDSO linux/limits.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 linux/elfnote.h: Replace elf.h with UAPI equivalent arm64: Introduce asm/common/processor.h arm64: vdso: Include common headers in the vdso library arm64: vdso32: Include common headers in the vdso library arm64: Introduce asm/common/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/common/cp15.h | 38 +++++++++++++++++++ arch/arm/include/asm/common/processor.h | 22 +++++++++++ arch/arm/include/asm/cp15.h | 20 +--------- arch/arm/include/asm/processor.h | 11 +----- arch/arm/include/asm/vdso/gettimeofday.h | 4 +- arch/arm64/include/asm/arch_timer.h | 29 +++----------- arch/arm64/include/asm/common/arch_timer.h | 33 ++++++++++++++++ arch/arm64/include/asm/common/processor.h | 31 +++++++++++++++ arch/arm64/include/asm/processor.h | 16 +------- .../include/asm/vdso/compat_gettimeofday.h | 2 +- arch/arm64/include/asm/vdso/gettimeofday.h | 8 ++-- arch/arm64/kernel/vdso/vgettimeofday.c | 2 - arch/arm64/kernel/vdso32/Makefile | 13 ++++++- arch/arm64/kernel/vdso32/vgettimeofday.c | 3 -- arch/mips/include/asm/common/processor.h | 27 +++++++++++++ arch/mips/include/asm/processor.h | 16 +------- arch/mips/include/asm/vdso/gettimeofday.h | 4 -- arch/x86/include/asm/common/processor.h | 23 +++++++++++ arch/x86/include/asm/processor.h | 12 +----- include/common/bits.h | 9 +++++ include/common/const.h | 10 +++++ include/common/jiffies.h | 11 ++++++ include/common/ktime.h | 16 ++++++++ include/common/limits.h | 18 +++++++++ include/common/math64.h | 24 ++++++++++++ include/common/processor.h | 14 +++++++ include/common/time.h | 12 ++++++ include/common/time32.h | 17 +++++++++ include/common/time64.h | 14 +++++++ include/linux/bits.h | 2 +- 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 | 13 +------ include/linux/time64.h | 10 +---- include/vdso/datapage.h | 32 ++++++++++++++-- lib/vdso/gettimeofday.c | 21 ---------- 41 files changed, 388 insertions(+), 207 deletions(-) create mode 100644 arch/arm/include/asm/common/cp15.h create mode 100644 arch/arm/include/asm/common/processor.h create mode 100644 arch/arm64/include/asm/common/arch_timer.h create mode 100644 arch/arm64/include/asm/common/processor.h create mode 100644 arch/mips/include/asm/common/processor.h create mode 100644 arch/x86/include/asm/common/processor.h create mode 100644 include/common/bits.h create mode 100644 include/common/const.h create mode 100644 include/common/jiffies.h create mode 100644 include/common/ktime.h create mode 100644 include/common/limits.h create mode 100644 include/common/math64.h create mode 100644 include/common/processor.h create mode 100644 include/common/time.h create mode 100644 include/common/time32.h create mode 100644 include/common/time64.h -- 2.25.1