From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 13 13:30:33 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AE51779F for ; Mon, 13 Apr 2015 13:30:33 +0000 (UTC) Received: from mail-oi0-f43.google.com (mail-oi0-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 763B8A0D for ; Mon, 13 Apr 2015 13:30:33 +0000 (UTC) Received: by oica37 with SMTP id a37so3772321oic.0 for ; Mon, 13 Apr 2015 06:30:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=l98lbAQdIvJ+tTomm4G0b6h/WSyrJ92wj/VeV8J0OZI=; b=RlS/RetTdInuWGKEXvEkqTOkpTI1zQaATxAcsSnWHelABt4PbeViACdBEHjYOU/x5P GI+bbhLMRm9Ja1JCMwNQZqkc5KFs5NlGEJI9rAU7Bel5KxhI5W++1K7F7E2J/h+QUm5v zPdn/wlSjEJ016PwYwapo7xgN7PbXjLtU8mVPAIDXhlTARcnVdh2wq/MBY4Nry5pTxhQ fcoW6O813uyfxEZ9M/p7FSAk0k3+SwdPzTl96oEDrfRP6GurMtUWq4MFjgn6eCYQ86fH I6KMkU4O5lMlUhx8Bhlm0AnHklPMYtmZnKZLm3P86m0+FXDC1Ja0FkPh1ti89fEYjZCI kMrw== X-Gm-Message-State: ALoCoQmsO0M2nrSWA6U47poA08cM3cmP+ewHGTUZlNOy+fuvpAi5Sl4tTThjxNH6kumOhHABjc5P MIME-Version: 1.0 X-Received: by 10.202.194.65 with SMTP id s62mr7477010oif.39.1428931431866; Mon, 13 Apr 2015 06:23:51 -0700 (PDT) Received: by 10.202.80.6 with HTTP; Mon, 13 Apr 2015 06:23:51 -0700 (PDT) In-Reply-To: References: Date: Mon, 13 Apr 2015 15:23:51 +0200 Message-ID: Subject: Re: another question - VM mappings From: Oliver Pinter To: Kimmo Paasiala Content-Type: text/plain; charset=UTF-8 Cc: "freebsd-hackers@freebsd.org" , Wojciech Puchar X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Apr 2015 13:30:33 -0000 On Mon, Apr 13, 2015 at 1:34 PM, Kimmo Paasiala wrote: > On Mon, Apr 13, 2015 at 2:25 PM, Oliver Pinter > wrote: >> Under amd64 exists an so called shared-page - similar to linux's vdso >> mechanism - https://github.com/freebsd/freebsd/blob/master/sys/kern/kern_exec.c#L1045 >> . >> >> This page is double mapped with user-space and with kernel. From >> security reason it's only RO, otherwise, when mapped with RW or RWX, >> then you could write kernel memory from user-space. >> >> On Mon, Apr 13, 2015 at 9:31 AM, Wojciech Puchar wrote: >>> below is mapping for very simple process (no libc etc) >>> >>> [wojtek@laptop ~]$ procstat -v 917 >>> PID START END PRT RES PRES REF SHD FL TP >>> PATH >>> 917 0x400000 0x401000 r-x 1 0 1 0 CN-- vn >>> /home/wojtek/test/1 >>> 917 0x600000 0x601000 rw- 1 0 1 0 ---- df >>> 917 0x7ffffffdf000 0x7ffffffff000 rw- 1 0 1 0 ---D df >>> 917 0x7ffffffff000 0x800000000000 r-x 0 0 39 0 ---- ph >>> >>> >>> what is "ph" mapping and why read&executable? >> _______________________________________________ > > What is the function is this page, why is it there for every process? The rationale behind is to speed up things. With the shared page, the system able to eliminate some syscall overhead especially gettimeofday family of syscalls. The shared-page currently used only to hold time specific informations ( kernel part: https://github.com/freebsd/freebsd/blob/master/sys/kern/kern_sharedpage.c libc part: https://github.com/freebsd/freebsd/blob/master/lib/libc/sys/__vdso_gettimeofday.c ). With these solution the system able to get the current time with a "simple" memory read, rather the a syscall. > > -Kimmo