Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5665549ima; Tue, 5 Feb 2019 16:15:19 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ8F/CtiJ3Hj+Nrlnijae+RIbMYBBSnGHzBV92tTTrYEPmOdYQVRcMf/N8i2wUQkRttrRDq X-Received: by 2002:a62:5007:: with SMTP id e7mr7736050pfb.92.1549412119012; Tue, 05 Feb 2019 16:15:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549412119; cv=none; d=google.com; s=arc-20160816; b=t4f3X1y0eQliJGqCFYcpmAjSUVO4XOGrYG8A/7QuDcJed2Wj7/lORiYTVLF1a3h0SD DHAiB18vL6m6oTi6wsw0Fasohv61tNVkzpW54ilc0j/vPZnvFvu/nE4dDe1xIa4I/rDy AzhCKHhmF2aEt7SpeEGckXwB7SkSSsmMJDOKiOoyt6/Carq2Yw5f8Z3YAOG16G4XmS1d +sC2nisJiUw18RbTwSkYlVhEuXRTU+d65uWUpwEe0nvwMrUdv2/FiLCjX3tIBzrP+e7d n5TYDGadK5AoxEWuykN1fZpu7XqWWCs3BT+OtNm+8U6S+uv0/9Zb8AgnvURxaRXYuJAf 3kDg== 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=XfzF8o5C6Y++SLatQZonqED2W/7yXqXNgNr+9RatYFY=; b=n9B56Mia82KWSEtmOCxpgTkVeSxSaqXqdA584pFDYgrRI2AtPQ7uVUGdTARCeX5YZO ufMt9smlfqcEkUqTwJMtJMbxYhuyRrsxrjYFZfQl6YSEHAsWXhx0kyMMIFirJ19ZhMDD 5e6DX8tyyXqCRpNer9nBcTQekvTdO+CJp+ZbG0Mbg5l7Win6WwZiyMrBdTdBTPkrVtDN TnPGdsvawoAJ76FFjyRyGs6GpTJnq/60YIpNaH0miAQy7ZLQcQ1In0Jgj8LXPuDmTjXp c4RjRD14iHj0PJeYiG8lkGHTreYum9IpCK/N3f9J/rfAN2EV3kLDdjf9P9CSSAubhTEP CNsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=laO+7NSi; 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 s38si2216332pga.38.2019.02.05.16.15.03; Tue, 05 Feb 2019 16:15:18 -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=laO+7NSi; 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 S1729542AbfBFAOE (ORCPT + 99 others); Tue, 5 Feb 2019 19:14:04 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:46136 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727097AbfBFALN (ORCPT ); Tue, 5 Feb 2019 19:11:13 -0500 Received: by mail-ed1-f65.google.com with SMTP id o10so4431940edt.13 for ; Tue, 05 Feb 2019 16:11:12 -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=XfzF8o5C6Y++SLatQZonqED2W/7yXqXNgNr+9RatYFY=; b=laO+7NSiqO8xUTpdJb5KIunDx5bA8+tlVDTRL+AF+mG9tRGrZ7XirX+3g+xmPNKuXr vTxZ31ZF1oIQ8wzlbYbaMlY7BfUi0m+wTX7vX83bJH1MfziHYlCFvd893Q1GKqU4ILnK eV/8r9ItsbUVUzTzss6lj0F5flMirgmrWMilDvqcqcdztj/xTvJm0CLFN5Uxqs3EC19F 3N7SLEehdRioeqXNYcmzTnyJqQBxM7pqAJfFUCelo8gfmOqmGdI6t4d9+9/Ik5s4Zpxe JpeKnp4Ehf8WapWmNmZSTFOJgcpIgfzy1e/GIzzO5y7VBU6OLcUsXqyCZ7ESyLO1Zmnc 2vaw== 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=XfzF8o5C6Y++SLatQZonqED2W/7yXqXNgNr+9RatYFY=; b=Hm7bI98Sf+DvaV8h/678JlY/FpP3xIXm6KVukte89ddzsoVsGyd0qfuhjZ39b8M2W/ wn9oR0P7R62y5I3SU0vsSrCQ4In0ys7UUWDjYVInnayjEi7ziuSfYRekQoDhpziVuTwf OZtWqrATmNqNVD+cLEirIVmi32gnr5CZQPTApgwqhTq4sV46DPhbIQJn8jTxTykg54I1 +4VKOJOSHjbfXbQDJFIpc0CzlD8CUBDBZ0DE9S1/6VmCnBj67pVZauHnqbWaa4TSrMTH B5Lu6DWLu7Y+CvHUux0e1aExeLtTEU9s0NDtfcLvpa43vD4ksBT9X9Sfxfc+IZYTP9Lc Uaqw== X-Gm-Message-State: AHQUAubipAy3hyh3CzQqauHQpp9SN4T/IBIqVkza90glfZmMP5IfOmgo UHXqCcd8I67dl05GTNXcUrJDMe6ABEA= X-Received: by 2002:a50:924e:: with SMTP id j14mr6045040eda.142.1549411871887; Tue, 05 Feb 2019 16:11:11 -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.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 05 Feb 2019 16:11:11 -0800 (PST) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Cc: Andrei Vagin , Dmitry Safonov , Adrian Reber , 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 02/32] timens: Add timens_offsets Date: Wed, 6 Feb 2019 00:10:36 +0000 Message-Id: <20190206001107.16488-3-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 From: Andrei Vagin Introduce offsets for time namespace. They will contain an adjustment needed to convert clocks to/from host's. Allocate one page for each time namespace that will be premapped into userspace among vvar pages. Signed-off-by: Andrei Vagin Signed-off-by: Dmitry Safonov --- MAINTAINERS | 1 + include/linux/time_namespace.h | 1 + include/linux/timens_offsets.h | 8 ++++++++ kernel/time_namespace.c | 14 ++++++++++++-- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 include/linux/timens_offsets.h diff --git a/MAINTAINERS b/MAINTAINERS index e03f160012e3..cc9054a74886 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12145,6 +12145,7 @@ S: Maintained F: fs/timerfd.c F: include/linux/timer* F: include/linux/time_namespace.h +F: include/linux/timens_offsets.h F: kernel/time_namespace.c F: kernel/time/*timer* diff --git a/include/linux/time_namespace.h b/include/linux/time_namespace.h index 9507ed7072fe..b6985aa87479 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; 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 8c600df9771d..4828447721ec 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) { @@ -46,6 +47,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; @@ -58,15 +60,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: @@ -94,6 +103,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.20.1