From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAD70C10F14 for ; Fri, 11 Oct 2019 01:25:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A6619214E0 for ; Fri, 11 Oct 2019 01:25:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com header.b="kh+MDBuR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728407AbfJKBZS (ORCPT ); Thu, 10 Oct 2019 21:25:18 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:34962 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728189AbfJKBYS (ORCPT ); Thu, 10 Oct 2019 21:24:18 -0400 Received: by mail-wr1-f66.google.com with SMTP id v8so9964723wrt.2 for ; Thu, 10 Oct 2019 18:24:16 -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=De+pNqwE3UZqGadaVX0hm3j7kjfrKO6HV/vQkFXaIGA=; b=kh+MDBuR2cMEEXRCL7MtHQg0XwvwYvULoBh2CiV+BfEt1qHtE4R5PIpxV5qh50tHxI s8OOlOtLXj0rl1qayiYvWCTwuKLD/zMztPRr319GGqt6ieaDk+5v//5EGrQSCWprnBEw ry0rjX5HtK7w9AZ4hQy/LgMtAbg65ROB0r5XHnJMQNo1aYNFkPnTq9Z/GYncnCkQAbOb qs3sCAH+OqBWN1DykGUDP/sOMiWFO55v97uQlY4J5McOzxXIKfLN6Q6WlvXkdYa0djMG 8oTlNGXZNxkce17+96jZs/U3ADtEkgzOJjMp8XO3gvlPiVWgLQNB6+kxvqvy7R/oUDGL ZoGQ== 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=De+pNqwE3UZqGadaVX0hm3j7kjfrKO6HV/vQkFXaIGA=; b=tQAazoewnK0+YUKuCm/m5l6rySbThhy7qSLM7QWN6PMfVWinyjmczWnpr3nRYCXJi0 3zP+LN4Rb6SzXv3QJWy2DtzqMr50ix4kujuEof7AlZiFpeoOjgoUUhfDA3rmQdcyPN5j lWhKJYXNC+IWiLc1qbEO5IOa8JngiKB/O3Pq1NeoF+PoXwmvw0sn06ETtEYEsgGOHk+5 jhIBtA5rimxN9ffEHsJInpxUPFFyfWB7RpKVZYUzAfnW5k75rSRKXfq+eX6ap5ZlswV9 SOhwKlAh4WV9nBM34Y1OVb4kOZ8l4BxoOd7tXfJgpeO83OrsJfdrTTQEteOcp2mxc4dj Cdcw== X-Gm-Message-State: APjAAAWdlOLqxoLmbAnSsG3LTRKhaq7tyrjEFy1A8tYi/quR38OaY54k sP+reA3pINW7ZuXyYPMOvFdBNRq01Qo= X-Google-Smtp-Source: APXvYqxlxEsNaMCSxRwB5Q6yar5uBDDb+T8Ish9/NlyPWlHuE70pidS2qCNn8dMtibacbxXdDKuXBw== X-Received: by 2002:adf:ec84:: with SMTP id z4mr10780854wrn.254.1570757055816; Thu, 10 Oct 2019 18:24:15 -0700 (PDT) Received: from localhost.localdomain ([2a02:8084:ea2:c100:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id l13sm7699795wmj.25.2019.10.10.18.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 18:24:15 -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 Subject: [PATCHv7 20/33] x86/vdso: Provide vdso_data offset on vvar_page Date: Fri, 11 Oct 2019 02:23:28 +0100 Message-Id: <20191011012341.846266-21-dima@arista.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191011012341.846266-1-dima@arista.com> References: <20191011012341.846266-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 VDSO support for Time namespace needs to set up a page with the same layout as VVAR. That timens page will be placed on position of VVAR page inside namespace. That page has vdso_data->seq set to 1 to enforce the slow path and vdso_data->clock_mode set to VCLOCK_TIMENS to enforce the time namespace handling path. To prepare timens page kernel needs to know the vdso_data offset. Provide arch_get_vdso_data() helper for locating vdso_data on VVAR page. Co-developed-by: Andrei Vagin Signed-off-by: Andrei Vagin Signed-off-by: Dmitry Safonov --- arch/x86/entry/vdso/vdso-layout.lds.S | 2 -- arch/x86/entry/vdso/vma.c | 11 +++++++++++ arch/x86/include/asm/vvar.h | 8 ++++---- arch/x86/kernel/vmlinux.lds.S | 4 +--- include/linux/time_namespace.h | 1 + 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vdso-layout.lds.S index 93c6dc7812d0..2330daad67c3 100644 --- a/arch/x86/entry/vdso/vdso-layout.lds.S +++ b/arch/x86/entry/vdso/vdso-layout.lds.S @@ -21,9 +21,7 @@ SECTIONS /* Place all vvars at the offsets in asm/vvar.h. */ #define EMIT_VVAR(name, offset) vvar_ ## name = vvar_page + offset; -#define __VVAR_KERNEL_LDS #include -#undef __VVAR_KERNEL_LDS #undef EMIT_VVAR pvclock_page = vvar_start + PAGE_SIZE; diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 000db8282cc8..5dab706aca2e 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -24,6 +24,17 @@ #include #include +#undef _ASM_X86_VVAR_H +#define EMIT_VVAR(name, offset) \ + const size_t name ## _offset = offset; +#include + +struct vdso_data *arch_get_vdso_data(void *vvar_page) +{ + return (struct vdso_data *)(vvar_page + _vdso_data_offset); +} +#undef EMIT_VVAR + #if defined(CONFIG_X86_64) unsigned int __read_mostly vdso64_enabled = 1; #endif diff --git a/arch/x86/include/asm/vvar.h b/arch/x86/include/asm/vvar.h index 32f5d9a0b90e..ff2de3025388 100644 --- a/arch/x86/include/asm/vvar.h +++ b/arch/x86/include/asm/vvar.h @@ -19,10 +19,10 @@ #ifndef _ASM_X86_VVAR_H #define _ASM_X86_VVAR_H -#if defined(__VVAR_KERNEL_LDS) - -/* The kernel linker script defines its own magic to put vvars in the - * right place. +#ifdef EMIT_VVAR +/* + * EMIT_VVAR() is used by the kernel linker script to put vvars in the + * right place. Also, it's used by kernel code to import offsets values. */ #define DECLARE_VVAR(offset, type, name) \ EMIT_VVAR(name, offset) diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index e2feacf921a0..ca02d0d301cd 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -195,12 +195,10 @@ SECTIONS __vvar_beginning_hack = .; /* Place all vvars at the offsets in asm/vvar.h. */ -#define EMIT_VVAR(name, offset) \ +#define EMIT_VVAR(name, offset) \ . = __vvar_beginning_hack + offset; \ *(.vvar_ ## name) -#define __VVAR_KERNEL_LDS #include -#undef __VVAR_KERNEL_LDS #undef EMIT_VVAR /* diff --git a/include/linux/time_namespace.h b/include/linux/time_namespace.h index 9a77d3854830..772911945944 100644 --- a/include/linux/time_namespace.h +++ b/include/linux/time_namespace.h @@ -37,6 +37,7 @@ extern struct time_namespace *copy_time_ns(unsigned long flags, struct user_namespace *user_ns, struct time_namespace *old_ns); extern void free_time_ns(struct kref *kref); extern int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk); +extern struct vdso_data *arch_get_vdso_data(void *vvar_page); static inline void put_time_ns(struct time_namespace *ns) { -- 2.23.0