Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5665270ima; Tue, 5 Feb 2019 16:14:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IZheqxwVUTvlh7H3JhfWnYf9NQ6p2fdYHmSYqgfjanhvSuhmXNJ5vbyi8Oe+X6IkHXyVVH7 X-Received: by 2002:a63:4706:: with SMTP id u6mr6684614pga.95.1549412091311; Tue, 05 Feb 2019 16:14:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549412091; cv=none; d=google.com; s=arc-20160816; b=yxu5xZtZPa/rSG0vH9HDEWTFBbXOVwbdTJG8FuviuToKph1wxJs62tFgnCGupfXoqf K0KUNUQFoOAFrUzA7vro9SpRTU6LtegvSCsWry6YAcgYMqoa7vJRfOT8zxfsCcXAZiwT 0i8g5DEf0+T07Tubl/Rsro5XHFMXzf6oc5aB7txc/m6mOy5KnFBCDixES5S5ISgdQFsB Wx26OgJIgLWXTD9AyApQm28rBp6vw7Cfp8Iizc1PY/tl3lpBw7/ZBETjtlcJinWundc7 b7VfkaOPJTmMu8silLv9jgZ2LEspVZZwINJWHCzTS55uFQE7rsdMIqkNl5IlzrP+1IcJ nsvQ== 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 :dkim-signature; bh=yDZEl1XFH0T8SREVjbYvB1a+jjmkgaWU05OzUhyRFUw=; b=WIt93GgVKO7YenpeUma368VPiX4lHIqb05Hftv7Xs4iDQc6X6ZYacG5nu6u4BaWINk zxvvB79qwmURAQryazOiRWGAx4txQcHJMc43XVnEgi8sQiRkHLxhUT5/S3MExN3m+WZG VBMVhR5Kxli89+vEfEIRyQFgak+Rw+t0ERd/aZphfgtobjX0XttWcA6ugoXim8V/GmJi OWFXOda8BQfNA3wR64CQViBiCB6MkX4PnNVyG1qoNdFS4kCi7Ipx00R2YU9dYTstG3vb wsP5401qGU/0z/XHypjVpd1unSWtw/inVwpQ9Zso6iMb33oENx0On6bCPXxUGFIvzCxZ mHJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b="fgoDr6/E"; 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; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v141si5244297pfc.260.2019.02.05.16.14.35; Tue, 05 Feb 2019 16:14:51 -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; dkim=pass header.i=@arista.com header.s=googlenew header.b="fgoDr6/E"; 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; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728000AbfBFALb (ORCPT + 99 others); Tue, 5 Feb 2019 19:11:31 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:35234 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728446AbfBFAL3 (ORCPT ); Tue, 5 Feb 2019 19:11:29 -0500 Received: by mail-ed1-f65.google.com with SMTP id b17so322229eds.2 for ; Tue, 05 Feb 2019 16:11:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yDZEl1XFH0T8SREVjbYvB1a+jjmkgaWU05OzUhyRFUw=; b=fgoDr6/ELbI1o1FYuezTg2Iwh4qP12IsrCvDs47ajAOeudLdW6n5P64AXmzuxSgguN 2vT8cwNvu7uoTebb1AyVhtjrNUb1TovF12TvaCqjUcGyHiQflPTASnJHkJZQmJgQnZP9 lwHLHhd57Oz4g6Q3t+X4SN5qj1EluOI0t1oNEiMpCFpX2MfHVGI7cACICNHYo+dYh3hV lG+g4vzGbK7Fl/GxQnDMxb3+ml2JYxfNEE8v2LZ9VEZa+qVqrf/anXCnzUtwNYeCZhFW QH1sEnbjgYrrqgio6v6fruaftUv83df3XvEzQEZtcIVAHdOlPD617hWbaNWkZYkpN3sD wgsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yDZEl1XFH0T8SREVjbYvB1a+jjmkgaWU05OzUhyRFUw=; b=JASNc0tfIA5EvTnHPFRPcEH3zPCLMceGVVg6GQb9a53COj12JrOtZhkuorus9dMDyT qVGDDfiBlsceZ/X67CdPworw8jAtPxYHoTXUMrAhoc0HnBSgl0hRmGzx6utVeU8JDg7b bmEQW/zkLNj0FEZ4BGoziCbr53Yga3qBbaP11TZft/6AYYgeYNcrh2oR0R+A7Nu44oPA Nq0i0d0FqsxgLrmYd3TofIROz62Pe/06T9u73MjcYu5owU/DajJAre4V7GHlZ3vA4O+s YNZgSmQEbUJHAA3wHNJcDUJYpGEBPeIbtrYiL0+SkkKdRiL4NqgZteWIBNih4x2jcJMV GqcA== X-Gm-Message-State: AHQUAuaHZ2NEMPmfYoUeMRIC0CE4nPg1I8oKo6RBOl2/pVfnAtuVhtxn 99p49GSFEW94S12v+Xj0Yxdyxfi8BeU= X-Received: by 2002:a17:906:a40a:: with SMTP id l10mr5265882ejz.248.1549411887090; Tue, 05 Feb 2019 16:11:27 -0800 (PST) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id p30sm5489594eda.68.2019.02.05.16.11.25 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 05 Feb 2019 16:11:26 -0800 (PST) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Cc: Dmitry Safonov , Adrian Reber , Andrei Vagin , Andrei Vagin , Andy Lutomirski , Andy Tucker , Arnd Bergmann , Christian Brauner , Cyrill Gorcunov , Dmitry Safonov <0x7f454c46@gmail.com>, "Eric W. Biederman" , "H. Peter Anvin" , Ingo Molnar , Jeff Dike , Oleg Nesterov , Pavel Emelyanov , Shuah Khan , Thomas Gleixner , containers@lists.linux-foundation.org, criu@openvz.org, linux-api@vger.kernel.org, x86@kernel.org Subject: [PATCH 13/32] x86/vdso: Build timens .so(s) Date: Wed, 6 Feb 2019 00:10:47 +0000 Message-Id: <20190206001107.16488-14-dima@arista.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190206001107.16488-1-dima@arista.com> References: <20190206001107.16488-1-dima@arista.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 As it has been discussed on timens RFC, adding a new conditional branch `if (inside_time_ns)` on VDSO for all processes is undesirable. It will add a penalty for everybody as branch predictor may mispredict the jump. Also there are instruction cache lines wasted on cmp/jmp. Those effects of introducing time namespace are very much unwanted having in mind how much work have been spent on micro-optimisation vdso code. Addressing those problems, build two VDSO images instead. At this moment timens is unsupported for x32 binaries (only x86_64 and ia32). This may be added on top afterwards. Suggested-by: Andy Lutomirski Suggested-by: Thomas Gleixner Signed-off-by: Dmitry Safonov --- arch/x86/entry/vdso/Makefile | 28 +++++++++++++++++-- arch/x86/entry/vdso/vclock_gettime-timens.c | 6 ++++ .../entry/vdso/vdso32/vclock_gettime-timens.c | 6 ++++ 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 arch/x86/entry/vdso/vclock_gettime-timens.c create mode 100644 arch/x86/entry/vdso/vdso32/vclock_gettime-timens.c diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index bc0bdbf49397..2433ed9342fd 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -17,8 +17,12 @@ VDSO32-$(CONFIG_X86_32) := y VDSO32-$(CONFIG_IA32_EMULATION) := y # files to link into the vdso -vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o +vobjs-y := vdso-note.o vgetcpu.o +vobjs-timens-y := $(vobjs-y) vclock_gettime-timens.o +vobjs-y += vclock_gettime.o + vobjs32-y := vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o +vobjs32-timens-y := $(vobjs32-y) vdso32/vclock_gettime-timens.o vobjs32-y += vdso32/vclock_gettime.o # files to link into kernel @@ -30,15 +34,21 @@ vdso_img-$(VDSO64-y) += 64 vdso_img-$(VDSOX32-y) += x32 vdso_img-$(VDSO32-y) += 32 +vdso_timens_img-$(VDSO64-y) += 64-timens +vdso_timens_img-$(VDSO32-y) += 32-timens +vdso_img-$(CONFIG_TIME_NS) += $(vdso_timens_img-y) + obj-$(VDSO32-y) += vdso32-setup.o vobjs := $(foreach F,$(vobjs-y),$(obj)/$F) vobjs32 := $(foreach F,$(vobjs32-y),$(obj)/$F) +vobjs-timens := $(foreach F,$(vobjs-timens-y),$(obj)/$F) +vobjs32-timens := $(foreach F,$(vobjs32-timens-y),$(obj)/$F) $(obj)/vdso.o: $(obj)/vdso.so -targets += vdso.lds $(vobjs-y) -targets += vdso32/vdso32.lds $(vobjs32-y) +targets += vdso.lds $(vobjs-y) $(vobjs-timens-y) +targets += vdso32/vdso32.lds $(vobjs32-y) $(vobjs32-timens-y) # Build the vDSO image C files and link them in. vdso_img_objs := $(vdso_img-y:%=vdso-image-%.o) @@ -53,6 +63,9 @@ CPPFLAGS_vdso.lds += -P -C VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \ -z max-page-size=4096 +$(obj)/vdso64-timens.so.dbg: $(obj)/vdso.lds $(vobjs-timens) FORCE + $(call if_changed,vdso) + $(obj)/vdso64.so.dbg: $(obj)/vdso.lds $(vobjs) FORCE $(call if_changed,vdso) @@ -81,12 +94,14 @@ endif endif $(vobjs): KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) +$(vobjs-timens): KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) # # vDSO code runs in userspace and -pg doesn't help with profiling anyway. # CFLAGS_REMOVE_vdso-note.o = -pg CFLAGS_REMOVE_vclock_gettime.o = -pg +CFLAGS_REMOVE_vclock_gettime-timens.o = -pg CFLAGS_REMOVE_vgetcpu.o = -pg CFLAGS_REMOVE_vvar.o = -pg @@ -132,6 +147,8 @@ VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1 KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO $(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32) $(obj)/vdso32.so.dbg: asflags-$(CONFIG_X86_64) += -m32 +$(obj)/vdso32-timens.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32) +$(obj)/vdso32-timens.so.dbg: asflags-$(CONFIG_X86_64) += -m32 KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS)) KBUILD_CFLAGS_32 := $(filter-out -mcmodel=kernel,$(KBUILD_CFLAGS_32)) @@ -152,6 +169,10 @@ endif endif $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) +$(obj)/vdso32-timens.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) + +$(obj)/vdso32-timens.so.dbg: $(obj)/vdso32/vdso32.lds $(vobjs32-timens) FORCE + $(call if_changed,vdso) $(obj)/vdso32.so.dbg: $(obj)/vdso32/vdso32.lds $(vobjs32) FORCE $(call if_changed,vdso) @@ -198,3 +219,4 @@ PHONY += vdso_install $(vdso_img_insttargets) vdso_install: $(vdso_img_insttargets) clean-files := vdso32.so vdso32.so.dbg vdso64* vdso-image-*.c vdsox32.so* +clean-files += vdso32-timens.so vdso32-timens.so.dbg diff --git a/arch/x86/entry/vdso/vclock_gettime-timens.c b/arch/x86/entry/vdso/vclock_gettime-timens.c new file mode 100644 index 000000000000..9e92315f83db --- /dev/null +++ b/arch/x86/entry/vdso/vclock_gettime-timens.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 + +#define BUILD_VDSO_TIME_NS + +#include "vclock_gettime.c" + diff --git a/arch/x86/entry/vdso/vdso32/vclock_gettime-timens.c b/arch/x86/entry/vdso/vdso32/vclock_gettime-timens.c new file mode 100644 index 000000000000..9e92315f83db --- /dev/null +++ b/arch/x86/entry/vdso/vdso32/vclock_gettime-timens.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 + +#define BUILD_VDSO_TIME_NS + +#include "vclock_gettime.c" + -- 2.20.1