Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4140106ybi; Mon, 29 Jul 2019 20:08:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyv3d9Ac/TWzYjEjykOUTYomDm0gCwY6/ovo0+BUsIjv86ugJKDa/PJ6Calk3J7feqPnpvu X-Received: by 2002:a63:506:: with SMTP id 6mr105668513pgf.434.1564456087729; Mon, 29 Jul 2019 20:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564456087; cv=none; d=google.com; s=arc-20160816; b=QBy2DC/XJ4C/8j02bYgZynvWla69jMji6Vu2mDit5m4ayevnWaK7iFPWoijfSzklwJ TbAosD5hrFdUmJHdIssRHztqxmyYbv6TuQ8SC7q1BEavoHSVCHXA4AXi5UgiVOcosnXD 6SAGFQlV3zlNVZ19LU9FMrOqZr3RnZVT/X6Sh7hG2WwW9jHdruTrqviiEc0/TWJUlJYh 0ww7rBoS2ou5dEf4sUv37sndt6WcliGUdJUlWAxX0+t1vaXFqhYhM0KdMjoS6girWa12 mD/9qNQdDQV677CnF3NF4VR3xUP0+2rHlqZ+tx2IENawaW+ydrC6X5vqtWM/4LtFDKBR a9xQ== 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=uJkPu9y+gmExeCUpCA066mqgvfW2S/OqiamBX4Wlaac=; b=zGeo8Qb/wX4ZkP4vUkwmbVgGOfVwOPJKjhg1CiNnUsX9RNshXirmtHeH8BVYgW8W/a KCjhdJ4nmJBb6JahB7a4S2HV0Inwb3PZcljOcSxICTIBW0Ngi+GWBPajCr9XFLYLqVI9 fQVdlef9yw3xLj9R0glNICIIImb8PjV+BTs4BC9i2NzTodilT1Ce6mch0GBzU4/WZZPL +vUNqAMrpiZE9onhEVWWaNHepOa5j0vWrsppgW5T/P0JZ4fywKENKbk41qnE6XAMMZlx RkXAjX6YqmLpchjsfVTBpt0fTY4fCiY20hNAki55moO7dK3+znGu5pMk9rm+JR9OM72H Cw6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=RQXI05dk; 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 x78si27575581pgx.471.2019.07.29.20.07.52; Mon, 29 Jul 2019 20:08:07 -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; dkim=pass header.i=@arista.com header.s=googlenew header.b=RQXI05dk; 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 S1729101AbfG2WA5 (ORCPT + 99 others); Mon, 29 Jul 2019 18:00:57 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:56135 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730397AbfG2V6k (ORCPT ); Mon, 29 Jul 2019 17:58:40 -0400 Received: by mail-wm1-f65.google.com with SMTP id a15so55190839wmj.5 for ; Mon, 29 Jul 2019 14:58:38 -0700 (PDT) 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=uJkPu9y+gmExeCUpCA066mqgvfW2S/OqiamBX4Wlaac=; b=RQXI05dku4fJ8r2oqnqNf/9NtEAGKp/k38XUdulMZlu8JNkOLGaqwCBnGvnnefJhtt j0kSEsyUTnjhkOssr/JYXs4a9aVojBdgA1b7B3uxvYtTyssni/zvWB/AJj0aS1ze9Rbt iFooZfYAOfO3pQumT9mLGGg17rntF8nn0g8PosgM+Noncni4ntHsRN+v0sNh59waXBFT sJkZ9OhdcyM/Ji5Bmd+DbANCojNGYDzhgpv9CxUd2ApB9OEd4a8lMbnd6ttAuyhioJ1c wdMhghFrcls5LRpF+YoxX0Db852sS9EXb9dm1XyWAj8Q2T3YTEOhITUtW2E3KbkQ/oQG 4uzQ== 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=uJkPu9y+gmExeCUpCA066mqgvfW2S/OqiamBX4Wlaac=; b=nrmM2pbbWMXg3bAd73Y3L3TSuPKLP5zfEKFzCSqfUV9myl9iUnSbD9iY54BKVd/c6w SPExvC25EL4ANexRaAFK7GsC1iAD8RyyRyJHb+KJ0prxUU6aQ7e34e+WnmdwiHa7H6ti EDahAIkA8phhe2OLKA5LsVY176aeD+R/P406XKNNC9d39bxfUbMv6rj1WIqcTTip6qB0 jMLmZs+K94xHzaaRUtzoENAADo9fkmyjQv5HqZ8kEhvThWaP39zRy2Ouu9UjqqD50oV4 3qM1XeJNWFsZTRhftdsnES8jrO28Pb26XGK/IussDd4DASl1xneGs0GGkXXmkDycYvgx eLVg== X-Gm-Message-State: APjAAAUYK2WYzRHfJUS1Wi46Yv+OdViExyPk/5kJyZEVFBTr4vdSxSZb 7KsSCp0dUvEY7p2ZMm/4pgm5acl+kCrPTV0dncOfHO1OMvql89H3keEldpkZdBy3uI0D6nwcSBT jLke3se27X6K6oKmT/SYINpRkCwI12JlSbQmpFCDp9DbVFTF43UxELtDPkRThP/DjPW0Ttny5Ij R8xKKI6VWiLVvLg+5sZxe24gy9CpQ1S5xVi6Gm5Rs= X-Received: by 2002:a1c:5f87:: with SMTP id t129mr106499814wmb.150.1564437517690; Mon, 29 Jul 2019 14:58:37 -0700 (PDT) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id x20sm49230728wmc.1.2019.07.29.14.58.36 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Jul 2019 14:58:37 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Cc: Dmitry Safonov <0x7f454c46@gmail.com>, Dmitry Safonov , Adrian Reber , Andrei Vagin , Andy Lutomirski , Arnd Bergmann , Christian Brauner , Cyrill Gorcunov , "Eric W. Biederman" , "H. Peter Anvin" , Ingo Molnar , Jann Horn , Jeff Dike , Oleg Nesterov , Pavel Emelyanov , Shuah Khan , Thomas Gleixner , Vincenzo Frascino , containers@lists.linux-foundation.org, criu@openvz.org, linux-api@vger.kernel.org, x86@kernel.org, Andrei Vagin Subject: [PATCHv5 27/37] x86/vdso2c: Process jump tables Date: Mon, 29 Jul 2019 22:57:09 +0100 Message-Id: <20190729215758.28405-28-dima@arista.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729215758.28405-1-dima@arista.com> References: <20190729215758.28405-1-dima@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CLOUD-SEC-AV-Info: arista,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 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. Addressing those problems, there are two versions of VDSO's .so: for host tasks (without any penalty) and for processes inside time namespace with clk_to_ns() that subtracts offsets from host's time. The timens code in vdso looks like this: if (timens_static_branch()) { clk_to_ns(clk, ts); } Static branch mechanism adds a __jump_table section into vdso. Vdso's linker script drops all unwanted sections in compile time. Preserve __jump_table section and add it into (struct vdso_image), as it's needed for enabling (patching) static branches that are present on vdso. Co-developed-by: Andrei Vagin Signed-off-by: Andrei Vagin Signed-off-by: Dmitry Safonov --- arch/x86/entry/vdso/vdso-layout.lds.S | 1 + arch/x86/entry/vdso/vdso2c.h | 9 ++++++++- arch/x86/include/asm/vdso.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vdso-layout.lds.S index ba216527e59f..69dbe4821aa5 100644 --- a/arch/x86/entry/vdso/vdso-layout.lds.S +++ b/arch/x86/entry/vdso/vdso-layout.lds.S @@ -45,6 +45,7 @@ SECTIONS .gnu.version : { *(.gnu.version) } .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } + __jump_table : { *(__jump_table) } :text .dynamic : { *(.dynamic) } :text :dynamic diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/entry/vdso/vdso2c.h index 885b988aea19..318b278ca396 100644 --- a/arch/x86/entry/vdso/vdso2c.h +++ b/arch/x86/entry/vdso/vdso2c.h @@ -14,7 +14,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len, unsigned long mapping_size; ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr; unsigned int i, syms_nr; - unsigned long j; + unsigned long j, jump_table_addr = -1UL, jump_table_size = -1UL; ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr, *alt_sec = NULL; ELF(Dyn) *dyn = 0, *dyn_end = 0; @@ -78,6 +78,10 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len, if (!strcmp(secstrings + GET_LE(&sh->sh_name), ".altinstructions")) alt_sec = sh; + if (!strcmp(secstrings + GET_LE(&sh->sh_name), "__jump_table")) { + jump_table_addr = GET_LE(&sh->sh_offset); + jump_table_size = GET_LE(&sh->sh_size); + } } if (!symtab_hdr) @@ -166,6 +170,9 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len, fprintf(outfile, "\t.alt_len = %lu,\n", (unsigned long)GET_LE(&alt_sec->sh_size)); } + fprintf(outfile, "\t.jump_table = %luUL,\n", jump_table_addr); + fprintf(outfile, "\t.jump_table_len = %luUL,\n", jump_table_size); + for (i = 0; i < NSYMS; i++) { if (required_syms[i].export && syms[i]) fprintf(outfile, "\t.sym_%s = %" PRIi64 ",\n", diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h index ccf89dedd04f..5e83bd3cda22 100644 --- a/arch/x86/include/asm/vdso.h +++ b/arch/x86/include/asm/vdso.h @@ -16,6 +16,7 @@ struct vdso_image { unsigned long size; /* Always a multiple of PAGE_SIZE */ unsigned long alt, alt_len; + unsigned long jump_table, jump_table_len; long sym_vvar_start; /* Negative offset to the vvar area */ -- 2.22.0