Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1195565imm; Wed, 19 Sep 2018 13:54:07 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZkTbe+6/UmT2besUqwdCFluaZOeDBYLbQaZhzivSC8KdDXALzBsaaSFpGPwo+/R00tXNdS X-Received: by 2002:a62:d113:: with SMTP id z19-v6mr37403628pfg.98.1537390447770; Wed, 19 Sep 2018 13:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537390447; cv=none; d=google.com; s=arc-20160816; b=pkRHzZSA3liRRCF20GU09727PNya74fCrqtfeFduCMslm6sVjIyKjfaFPj7j64cBRt kM9A10WJLja9pu9pp+HVvgJPLYkJ+SgukyqfeQHqB6tpaSvMPvmMc7Vn4dgMNyUmqQ2w aPaZFfTQ2zULb2KJMnUyxYMHOJ01pxE7+p5I2bHWF/xGfbdS9nO5bwxqfZDW+JqBDk8Z WEJ4MCFxaRpa7+aL780MV9g3g/f/91xVCp4B8V1JKnJiwFVPmPRuN2VytePZ2p72X7d6 5wKWW3qklwlVWDl/U1m3xVD9V1USgQEbW9WE+vnwUPfEGqSJpiXwV8AqNm9snDRcQY49 fObA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=TXxaWmvWwJSZ82Le63q+MPVKCbZ0fMfBagChLVPhkoU=; b=P9puXH/yzDPoe27Vl22yLaIVo+q4WZmXjdC3KGS1gVhb5HBJQ9yiAUSzyD+nhliafu yWqexjy8hsZ0YxX+SWdme23rVtG4IpXfkWJaAXNzkk+NtgYuSOy+4L5mkR9S0PB4g7Zp bxIXnJI1g9vZWu5Ogd6g9Tk77pw/MacqOEhRvFi/SYnTFhIcodlJ0jQLufYemtaDRNjX dszX5Rn7v5IeZZiI/fqJ0mXcM/RynWl4tdqj7Hed1+bkpi7tgO4LchW/jnoc3IB1F4e/ mwk20wSK+kEvBfMrRKDnf/2JcpG76vpOWbwTUgeRSG/3mShcs12Q0wVZaW5zLuondM+A KTEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=JCUEbNXO; 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 l6-v6si2139409pgl.602.2018.09.19.13.53.52; Wed, 19 Sep 2018 13:54: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=JCUEbNXO; 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 S1732084AbeITCaY (ORCPT + 99 others); Wed, 19 Sep 2018 22:30:24 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:45037 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731902AbeITCaW (ORCPT ); Wed, 19 Sep 2018 22:30:22 -0400 Received: by mail-ed1-f66.google.com with SMTP id s10-v6so6008449edb.11 for ; Wed, 19 Sep 2018 13:50:43 -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; bh=TXxaWmvWwJSZ82Le63q+MPVKCbZ0fMfBagChLVPhkoU=; b=JCUEbNXObW5AyGKN1SLiiJ2SILWfYQb6vQT6grrKNAC4JK1YrCKc0VKhYxHF/eUGc6 pubfjI82efwkW9pZlk4KGblZvfuazFuc1o1uBD+6ukGK+ZiIwYx2T7mckb4RCIDO9dg8 1ZqJz+S0rXhQwSx2UG1/pr9glGs5u34L33RgWlX0HDU3wIEliGx/zQuopTnpkADOCz92 Q/SVkk2FBnRp3YtW8lpsVgIyOcon0SJScOdLq62NM1AkvRHNRV3hOT7I/h33t5laRadT r3QbqSviR77yuYdr9EjId+krvxGXabp/F0r4h85FFZEqMYG2qv4JIKwcgzWIC0nlZV3c uU7w== 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; bh=TXxaWmvWwJSZ82Le63q+MPVKCbZ0fMfBagChLVPhkoU=; b=SKzvJI514XqgjlDriOE2mCDMFXx//toPoL5qB+KyxKyVUaz+NojdLemR2DkYiUiewX WaL4u920BrEJz4MdbjXo8OJg/64CeT02G2izTHARGw5TU+yrVWdtV4yWAxrJtZvzBELo 8Y6LiXrVmN431EHPzMlyGVZY5jivIvu6xH4AlNEeu6gf33oiZ8KKM42KYzmAzDIVSd1/ QYhEnQK/fBwgc6nsAv1s5V9IT2QOodg23nQZcViJ+eHfkv8CtUyFOoxjsnAP7U1OK/GR ea7YZ8jlbuBe8nrH68ywH6AiYpG/BaB+e86TSpD+usWVCNUlhJzv9XMuDflEx4DjGqAF 7bdw== X-Gm-Message-State: APzg51DcocLh5JgO1ohwy1IvMt6i13UyCShKfWX8y693hhQGuuI6jjj1 UGim15ENAUHS1/wO60ASi0uJuefhC+w= X-Received: by 2002:a50:9306:: with SMTP id m6-v6mr59777681eda.206.1537390242440; Wed, 19 Sep 2018 13:50:42 -0700 (PDT) Received: from dhcp.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id t17-v6sm1747729edb.27.2018.09.19.13.50.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Sep 2018 13:50:41 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Cc: Dmitry Safonov <0x7f454c46@gmail.com>, Andrei Vagin , Dmitry Safonov , Adrian Reber , Andy Lutomirski , Christian Brauner , Cyrill Gorcunov , "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: [RFC 02/20] timens: Add timens_offsets Date: Wed, 19 Sep 2018 21:50:19 +0100 Message-Id: <20180919205037.9574-3-dima@arista.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180919205037.9574-1-dima@arista.com> References: <20180919205037.9574-1-dima@arista.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrei Vagin Introduce offsets for time namespace. They will contain adjustment needed to convert clocks to/from host's. Allocate one page for each time namespace that will be premapped into userspace with vvar pages. Signed-off-by: Andrei Vagin Signed-off-by: Dmitry Safonov --- include/linux/time_namespace.h | 2 ++ include/linux/timens_offsets.h | 8 ++++++++ kernel/time_namespace.c | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 include/linux/timens_offsets.h diff --git a/include/linux/time_namespace.h b/include/linux/time_namespace.h index bf98f35efe07..4960c54f1b33 100644 --- a/include/linux/time_namespace.h +++ b/include/linux/time_namespace.h @@ -8,6 +8,7 @@ #include #include #include +#include struct user_namespace; extern struct user_namespace init_user_ns; @@ -17,6 +18,7 @@ struct time_namespace { struct user_namespace *user_ns; struct ucounts *ucounts; struct ns_common ns; + struct timens_offsets *offsets; } __randomize_layout; extern struct time_namespace init_time_ns; diff --git a/include/linux/timens_offsets.h b/include/linux/timens_offsets.h new file mode 100644 index 000000000000..7d7cb68ea778 --- /dev/null +++ b/include/linux/timens_offsets.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_TIME_OFFSETS_H +#define _LINUX_TIME_OFFSETS_H + +struct timens_offsets { +}; + +#endif diff --git a/kernel/time_namespace.c b/kernel/time_namespace.c index 902cd9c22159..a985529754b4 100644 --- a/kernel/time_namespace.c +++ b/kernel/time_namespace.c @@ -13,6 +13,7 @@ #include #include #include +#include static struct ucounts *inc_time_namespaces(struct user_namespace *ns) { @@ -44,6 +45,7 @@ static struct time_namespace *clone_time_ns(struct user_namespace *user_ns, { struct time_namespace *ns; struct ucounts *ucounts; + struct page *page; int err; err = -ENOSPC; @@ -56,15 +58,22 @@ static struct time_namespace *clone_time_ns(struct user_namespace *user_ns, if (!ns) goto fail_dec; + page = alloc_page(GFP_KERNEL | __GFP_ZERO); + if (!page) + goto fail_free; + ns->offsets = page_address(page); + BUILD_BUG_ON(sizeof(*ns->offsets) > PAGE_SIZE); + err = ns_alloc_inum(&ns->ns); if (err) - goto fail_free; + goto fail_page; ns->ucounts = ucounts; ns->ns.ops = &timens_operations; ns->user_ns = get_user_ns(user_ns); return ns; - +fail_page: + free_page((unsigned long)ns->offsets); fail_free: kfree(ns); fail_dec: @@ -93,6 +102,7 @@ void free_time_ns(struct kref *kref) struct time_namespace *ns; ns = container_of(kref, struct time_namespace, kref); + free_page((unsigned long)ns->offsets); dec_time_namespaces(ns->ucounts); put_user_ns(ns->user_ns); ns_free_inum(&ns->ns); -- 2.13.6