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]
Message-ID: <20190822090208.GJ30120@smile.fi.intel.com>
Date:   Thu, 22 Aug 2019 12:02:08 +0300
From:   Andy Shevchenko <andriy.shevchenko@...el.com>
To:     Rahul Tanwar <rahul.tanwar@...ux.intel.com>
Cc:     tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, hpa@...or.com,
        tony.luck@...el.com, x86@...nel.org, a.zummo@...ertech.it,
        alexandre.belloni@...tlin.com, robh+dt@...nel.org,
        mark.rutland@....com, linux-rtc@...r.kernel.org,
        devicetree@...r.kernel.org, alan@...ux.intel.com,
        linux-kernel@...r.kernel.org, qi-ming.wu@...el.com,
        cheol.yong.kim@...el.com, rahul.tanwar@...el.com
Subject: Re: [PATCH v1 1/2] x86/rtc: Add option to skip using RTC

On Thu, Aug 22, 2019 at 03:44:03PM +0800, Rahul Tanwar wrote:
> Use a newly introduced optional "status" property of "motorola,mc146818"
> compatible DT node to determine if RTC is supported. Skip read/write from
> RTC device only when this node is present and status is "disabled". In all
> other cases, proceed as before.

Can't we rather update ->get_wallclock() and ->set_wallclock() based on this?

> Suggested-by: Alan Cox <alan@...ux.intel.com>
> Signed-off-by: Rahul Tanwar <rahul.tanwar@...ux.intel.com>
> ---
>  arch/x86/kernel/rtc.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
> index 586f718b8e95..f9f760a8e76a 100644
> --- a/arch/x86/kernel/rtc.c
> +++ b/arch/x86/kernel/rtc.c
> @@ -32,6 +32,11 @@ EXPORT_SYMBOL(cmos_lock);
>  DEFINE_SPINLOCK(rtc_lock);
>  EXPORT_SYMBOL(rtc_lock);
>  
> +static const struct of_device_id of_cmos_match[] = {
> +        { .compatible = "motorola,mc146818" },
> +        {}
> +};
> +
>  /*
>   * In order to set the CMOS clock precisely, set_rtc_mmss has to be
>   * called 500 ms after the second nowtime has started, because when
> @@ -42,9 +47,14 @@ EXPORT_SYMBOL(rtc_lock);
>  int mach_set_rtc_mmss(const struct timespec64 *now)
>  {
>  	unsigned long long nowtime = now->tv_sec;
> +	struct device_node *node;
>  	struct rtc_time tm;
>  	int retval = 0;
>  
> +	node = of_find_matching_node(NULL, of_cmos_match);
> +	if (node && !of_device_is_available(node))
> +		return -EINVAL;
> +
>  	rtc_time64_to_tm(nowtime, &tm);
>  	if (!rtc_valid_tm(&tm)) {
>  		retval = mc146818_set_time(&tm);
> @@ -63,8 +73,15 @@ int mach_set_rtc_mmss(const struct timespec64 *now)
>  void mach_get_cmos_time(struct timespec64 *now)
>  {
>  	unsigned int status, year, mon, day, hour, min, sec, century = 0;
> +	struct device_node *node;
>  	unsigned long flags;
>  
> +	node = of_find_matching_node(NULL, of_cmos_match);
> +	if (node && !of_device_is_available(node)) {
> +		now->tv_sec = now->tv_nsec = 0;
> +		return;
> +	}
> +
>  	/*
>  	 * If pm_trace abused the RTC as storage, set the timespec to 0,
>  	 * which tells the caller that this RTC value is unusable.
> -- 
> 2.11.0
> 

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ