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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20120207194735.GB20618@amt.cnet>
Date:	Tue, 7 Feb 2012 17:47:35 -0200
From:	Marcelo Tosatti <mtosatti@...hat.com>
To:	Igor Mammedov <imammedo@...hat.com>
Cc:	linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
	tglx@...utronix.de, mingo@...hat.com, hpa@...or.com,
	x86@...nel.org, jacob.jun.pan@...ux.intel.com,
	alan@...ux.intel.com, feng.tang@...el.com, konrad.wilk@...cle.com,
	avi@...hat.com, glommer@...hat.com, johnstul@...ibm.com,
	riel@...hat.com, tj@...nel.org, kosaki.motohiro@...fujitsu.com,
	akpm@...ux-foundation.org
Subject: Re: [PATCH] Introduce x86_cpuinit.early_percpu_clock_init hook

On Tue, Feb 07, 2012 at 03:52:44PM +0100, Igor Mammedov wrote:
> When kvm guest uses kvmclock, it may hang on vcpu hot-plug.
> This is caused by an overflow in pvclock_get_nsec_offset,
> 
>     u64 delta = tsc - shadow->tsc_timestamp;
> 
> which in turn is caused by an undefined values from percpu
> hv_clock that hasn't been initialized yet.
> Uninitialized clock on being booted cpu is accessed from
>    start_secondary
>     -> smp_callin
>       ->  smp_store_cpu_info
>         -> identify_secondary_cpu
>           -> mtrr_ap_init
>             -> mtrr_restore
>               -> stop_machine_from_inactive_cpu
>                 -> queue_stop_cpus_work
>                   ...
>                     -> sched_clock
>                       -> kvm_clock_read
> which is well before x86_cpuinit.setup_percpu_clockev call in
> start_secondary, where percpu clock is initialized.
> 
> This patch introduces a hook that allows to setup/initialize
> per_cpu clock early and avoid overflow due to reading
>   - undefined values
>   - old values if cpu was offlined and then onlined again
> 
> Another possible early user of this clock source is ftrace that
> accesses it to get timestamps for ring buffer entries. So if
> mtrr_ap_init is moved from identify_secondary_cpu to past
> x86_cpuinit.setup_percpu_clockev in start_secondary, ftrace
> may cause the same overflow/hang on cpu hot-plug anyway.
> 
> More complete description of the problem:
>   https://lkml.org/lkml/2012/2/2/101
> 
> Credits to Marcelo Tosatti <mtosatti@...hat.com> for hook idea.
> 
> Signed-off-by: Igor Mammedov <imammedo@...hat.com>
> ---
>  arch/x86/include/asm/x86_init.h |    2 ++
>  arch/x86/kernel/kvmclock.c      |    4 +---
>  arch/x86/kernel/smpboot.c       |    1 +
>  arch/x86/kernel/x86_init.c      |    1 +
>  4 files changed, 5 insertions(+), 3 deletions(-)

Applied, thanks.

--
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