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=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 85884C3A589 for ; Sun, 18 Aug 2019 16:29:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5B91B2064A for ; Sun, 18 Aug 2019 16:29:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726851AbfHRQ3m (ORCPT ); Sun, 18 Aug 2019 12:29:42 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:44780 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726005AbfHRQ3m (ORCPT ); Sun, 18 Aug 2019 12:29:42 -0400 Received: from pd9ef1cb8.dip0.t-ipconnect.de ([217.239.28.184] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hzO3U-0008Nc-7D; Sun, 18 Aug 2019 18:29:20 +0200 Date: Sun, 18 Aug 2019 18:29:19 +0200 (CEST) From: Thomas Gleixner To: Dmitry Safonov <0x7f454c46@gmail.com> cc: Andy Lutomirski , Dmitry Safonov , linux-kernel@vger.kernel.org, Adrian Reber , Andrei Vagin , Arnd Bergmann , Christian Brauner , Cyrill Gorcunov , "Eric W. Biederman" , "H. Peter Anvin" , Ingo Molnar , Jann Horn , Jeff Dike , Oleg Nesterov , Pavel Emelyanov , Shuah Khan , Vincenzo Frascino , containers@lists.linux-foundation.org, criu@openvz.org, linux-api@vger.kernel.org, x86@kernel.org Subject: Re: [PATCHv6 23/36] x86/vdso: Allocate timens vdso In-Reply-To: Message-ID: References: <20190815163836.2927-1-dima@arista.com> <20190815163836.2927-24-dima@arista.com> <483678c7-7687-5445-f09e-e45e9460d559@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 18 Aug 2019, Thomas Gleixner wrote: > On Sun, 18 Aug 2019, Thomas Gleixner wrote: > > > > Patch below. I tested this with the normal order and by installing a > > 'timens' page unconditionally for all processes. I'll reply with the timens > > testing hacks so you can see what I did. > > First hack... And the second one. Thanks, tglx 8<----------------- Subject: x86/vdso: Hack to test the time namespace path From: Thomas Gleixner Date: Sun, 18 Aug 2019 16:49:00 +0200 Install a special TIMENS vvar page which forces the VDSO to take the time namespace path for testing. Not-Signed-off-by: Thomas Gleixner --- arch/x86/entry/vdso/vma.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -84,6 +84,33 @@ static int vdso_mremap(const struct vm_s return 0; } +/* Hack for testing */ +static struct page *vdso_timens_page; + +static int __init init_vdso_timens(void) +{ + struct vdso_data *vdata; + void *va; + + vdso_timens_page = alloc_page(GFP_KERNEL | __GFP_ZERO); + if (!vdso_timens_page) + return -ENOMEM; + + /* Hack: vdso data is at offset 0x80 in the page ... */ + va = page_address(vdso_timens_page); + vdata = (struct vdso_data *)(va + 0x80); + + vdata[0].seq = 1; + vdata[0].clock_mode = UINT_MAX; + vdata[1].seq = 1; + vdata[1].clock_mode = UINT_MAX; + + /* All offsets are zero */ + + return 0; +} +subsys_initcall(init_vdso_timens); + static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, struct vm_area_struct *vma, struct vm_fault *vmf) { @@ -106,7 +133,7 @@ static vm_fault_t vvar_fault(const struc if (sym_offset == 0) return VM_FAULT_SIGBUS; - if (sym_offset == image->sym_vvar_page) { + if (sym_offset == image->sym_timens_page) { return vmf_insert_pfn(vma, vmf->address, __pa_symbol(&__vvar_page) >> PAGE_SHIFT); } else if (sym_offset == image->sym_pvclock_page) { @@ -123,6 +150,11 @@ static vm_fault_t vvar_fault(const struc if (tsc_pg && vclock_was_used(VCLOCK_HVCLOCK)) return vmf_insert_pfn(vma, vmf->address, vmalloc_to_pfn(tsc_pg)); + } else if (sym_offset == image->sym_vvar_page) { + unsigned long pfn; + + pfn = page_to_pfn(vdso_timens_page); + return vmf_insert_pfn(vma, vmf->address, pfn); } return VM_FAULT_SIGBUS;