lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALCETrWhpmixwh4z6D1vBQVWvuNvg8-iTX9Vvi1J9-YMajrDdQ@mail.gmail.com>
Date:	Fri, 14 Feb 2014 14:40:12 -0800
From:	Andy Lutomirski <luto@...capital.net>
To:	Stefani Seibold <stefani@...bold.net>
Cc:	Greg KH <gregkh@...uxfoundation.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	X86 ML <x86@...nel.org>, Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>, Andi Kleen <ak@...ux.intel.com>,
	Andrea Arcangeli <aarcange@...hat.com>,
	John Stultz <john.stultz@...aro.org>,
	Pavel Emelyanov <xemul@...allels.com>,
	Cyrill Gorcunov <gorcunov@...nvz.org>,
	andriy.shevchenko@...ux.intel.com, Martin.Runge@...de-schwarz.com,
	Andreas.Brief@...de-schwarz.com
Subject: Re: [PATCH v16 0/10] Add 32 bit VDSO time function support

On Fri, Feb 14, 2014 at 12:52 AM, Stefani Seibold <stefani@...bold.net> wrote:
> This patch add the functions vdso_gettimeofday(), vdso_clock_gettime()
> and vdso_time() to the 32 bit VDSO.

Is there any chance you can shove this in a git tree somewhere for the
next version (in addition to sending patches)?  I don't have magic
scripts to make pulling these things in from gmail easy.

--Andy

>
> The reason to do this was to get a fast reliable time stamp. Many developers
> uses TSC to get a fast time stamp, without knowing the pitfalls. VDSO
> time functions a fast and a reliable way, because the kernel knows the
> best time source and the P- and C-state of the CPU.
>
> The helper library to use the VDSO functions can be download at
> http://http://seibold.net/vdso.c
> The libary is very small, only 228 lines of code. Compile it with
> gcc -Wall -O3 -fpic vdso.c -lrt -shared -o libvdso.so
> and use it with LD_PRELOAD=<path>/libvdso.so
>
> This kind of helper must be integrated into glibc, for x86 64 bit and
> PowerPC it is already there.
>
> Some linux 32 bit kernel benchmark results (all measurements are in nano
> seconds):
>
> Intel(R) Celeron(TM) CPU 400MHz
>
> Average time kernel call:
>  gettimeofday(): 1039
>  clock_gettime(): 1578
>  time(): 526
> Average time VDSO call:
>  gettimeofday(): 378
>  clock_gettime(): 303
>  time(): 60
>
> Celeron(R) Dual-Core CPU T3100 1.90GHz
>
> Average time kernel call:
>  gettimeofday(): 209
>  clock_gettime(): 406
>  time(): 135
> Average time VDSO call:
>  gettimeofday(): 51
>  clock_gettime(): 43
>  time(): 10
>
> So you can see a performance increase between 4 and 13, depending on the
> CPU and the function.
>
> The address layout of the VDSO has changed, because there is no fixed
> address space available on a x86 32 bit kernel, despite the name. Because
> someone decided to add an offset to the __FIXADDR_TOP for virtualization.
>
> Also the IA32 Emulation uses the whole 4 GB address space, so there is no
> fixed address available.
>
> This was the reason not depend on this kind of address and change the layout
> of the VDSO. The VDSO for a 32 bit application has now three pages:
>
> ^ Higher Address
> |
> +----------------------------------------+
> + VDSO page (includes code) ro+x         +
> +----------------------------------------+
> + VVAR page (export kernel variables) ro +
> +----------------------------------------+
> + HPET page (mapped registers) ro
> +----------------------------------------+
> |
> ^ Lower Address
>
> The VDSO page for a 32 bit resided still on 0xffffe000, the the VVAR and
> HPET page are mapped before.
>
> In the non compat mode the VMA of the VDSO is now 3 pages for a 32 bit kernel.
> So this decrease the available logical address room by 2 pages.
>
> The patch is against kernel 3.14 (e7651b819e90da924991d727d3c007200a18670d)
>
> Changelog:
> 25.11.2012 - first release and proof of concept for linux 3.4
> 11.12.2012 - Port to linux 3.7 and code cleanup
> 12.12.2012 - fixes suggested by Andy Lutomirski
>            - fixes suggested by John Stultz
>            - use call VDSO32_vsyscall instead of int 80
>            - code cleanup
> 17.12.2012 - support for IA32_EMULATION, this includes
>              - code cleanup
>              - include cleanup to fix compile warnings and errors
>              - move out seqcount from seqlock, enable use in VDSO
>              - map FIXMAP and HPET into the 32 bit address space
> 18.12.2012 - split into separate patches
> 30.01.2014 - revamp the code
>              - code clean up
>              - VDSO layout changed
>              - no fixed addresses
>              - port to 3.14
> 01.02.2014 - code cleanup
> 02.02.2014 - code cleanup
>              - split into more patches
>              - use HPET_COUNTER instead of hard coded value
>              - fix changelog to the right year ;-)
> 02.02.2014 - reverse the mapping, this make the new VDSO 32 bit support
>              full compatible.
> 03.02.2014 - code cleanup
>              - fix comment
>              - fix ABI break in vdso32.lds.S
> 04.02.2014 - revamp IA32 emulation support
>              - introduce VVAR macro
>              - rearranged vsyscall_gtod_data struture for IA32 emulation support
>              - code cleanup
> 05.02.2014 - revamp IA32 emulation support
>              - replace seqcount_t by an unsigned, to make the vsyscall_gtod_data
>                structure independed of kernel config and functions.
> 08.02.2014 - revamp IA32 emulation support
>              - replace all internal structures by fix size elements
> 10.02.2014 - code cleanup
>              - add commets
>              - revamp inline assembly
> 12.02.2014 - add conditional fixmap of vvar and hpet pages for 32 bit kernel
> 14.02.2014 - fix CONFIG_PARAVIRT_CLOCK, which is not supported in 32 bit VDSO



-- 
Andy Lutomirski
AMA Capital Management, LLC
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ