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] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 13 Feb 2012 15:48:37 -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, amit.shah@...hat.com
Subject: Re: [PATCH RFC] pvclock: Make pv_clock more robust and fixup it if
 overflow happens

On Mon, Feb 13, 2012 at 04:45:59PM +0100, Igor Mammedov wrote:
> Instead of hunting misterious stalls/hungs all over the kernel when
> overflow occurs at pvclock.c:pvclock_get_nsec_offset
> 
>     u64 delta = native_read_tsc() - shadow->tsc_timestamp;
> 
> and introducing hooks when places of unexpected access found, pv_clock
> should be initialized for the calling cpu if overflow condition is detected.
> 
> Signed-off-by: Igor Mammedov <imammedo@...hat.com>

Igor,

I disagree. This is fixing the symptom not the root cause. Additionally,
Xen also uses pvclock_clocksource_read.

How about adding a BUG_ON to detect the overflow, this way hunting for
the problem is not necessary.

>  arch/x86/kernel/pvclock.c |   18 +++++++++++++++---
>  1 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
> index 42eb330..b486756 100644
> --- a/arch/x86/kernel/pvclock.c
> +++ b/arch/x86/kernel/pvclock.c
> @@ -41,9 +41,14 @@ void pvclock_set_flags(u8 flags)
>  	valid_flags = flags;
>  }
>  
> -static u64 pvclock_get_nsec_offset(struct pvclock_shadow_time *shadow)
> +static u64 pvclock_get_nsec_offset(struct pvclock_shadow_time *shadow,
> +				   bool *overflow)
>  {
> -	u64 delta = native_read_tsc() - shadow->tsc_timestamp;
> +	u64 delta;
> +	u64 tsc = native_read_tsc();
> +	u64 shadow_timestamp = shadow->tsc_timestamp;
> +	*overflow = tsc < shadow_timestamp;
> +	delta = tsc - shadow_timestamp;
>  	return pvclock_scale_delta(delta, shadow->tsc_to_nsec_mul,
>  				   shadow->tsc_shift);
>  }
> @@ -94,12 +99,19 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
>  	unsigned version;
>  	cycle_t ret, offset;
>  	u64 last;
> +	bool overflow;
>  
>  	do {
>  		version = pvclock_get_time_values(&shadow, src);
>  		barrier();
> -		offset = pvclock_get_nsec_offset(&shadow);
> +		offset = pvclock_get_nsec_offset(&shadow, &overflow);
>  		ret = shadow.system_timestamp + offset;
> +		if (unlikely(overflow)) {
> +			memset(src, 0, sizeof(*src));
> +			barrier();
> +			x86_cpuinit.early_percpu_clock_init();
> +			continue;
> +		}
>  		barrier();
>  	} while (version != src->version);
>  
> -- 
> 1.7.7.6
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
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