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: <CADHgK6s4K+K+OZuUZVbHKNzbFiHzm82Ss0WpSfkUdQgP+E3j=w@mail.gmail.com>
Date:	Mon, 10 Mar 2014 11:32:17 -0700
From:	Sebastian Capella <sebastian.capella@...aro.org>
To:	Stephen Boyd <sboyd@...eaurora.org>
Cc:	Linux Kernel <linux-kernel@...r.kernel.org>,
	"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
	"linaro-kernel@...ts.linaro.org" <linaro-kernel@...ts.linaro.org>,
	"linux-arm-kernel@...ts.infradead.org" 
	<linux-arm-kernel@...ts.infradead.org>,
	Len Brown <len.brown@...el.com>,
	Russell King <linux@....linux.org.uk>,
	Jonathan Austin <jonathan.austin@....com>,
	Victor Kamensky <victor.kamensky@...aro.org>,
	Nicolas Pitre <nico@...aro.org>,
	Will Deacon <will.deacon@....com>,
	"Uwe Kleine-K??nig" <u.kleine-koenig@...gutronix.de>,
	"Rafael J. Wysocki" <rjw@...ysocki.net>,
	Laura Abbott <lauraa@...eaurora.org>,
	Sricharan R <r.sricharan@...com>,
	Ben Dooks <ben.dooks@...ethink.co.uk>,
	Russ Dill <Russ.Dill@...com>,
	Catalin Marinas <catalin.marinas@....com>,
	Santosh Shilimkar <santosh.shilimkar@...com>,
	Stefano Stabellini <stefano.stabellini@...citrix.com>,
	Jiang Liu <liuj97@...il.com>
Subject: Re: [PATCH v7 2/2] ARM hibernation / suspend-to-disk

On 6 March 2014 20:42, Stephen Boyd <sboyd@...eaurora.org> wrote:
> On 03/05, Sebastian Capella wrote:
>> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
>> index 8756e4b..d32adbb 100644
>> --- a/arch/arm/include/asm/memory.h
>> +++ b/arch/arm/include/asm/memory.h
>> @@ -291,6 +291,7 @@ static inline void *phys_to_virt(phys_addr_t x)
>>   */
>>  #define __pa(x)                      __virt_to_phys((unsigned long)(x))
>>  #define __va(x)                      ((void *)__phys_to_virt((phys_addr_t)(x)))
>> +#define __pa_symbol(x)               __pa((unsigned long)(x))
> Looking at this definition now it doesn't look right. Isn't
> &__nosave_begin a virtual address? Casting it to an unsigned long
> isn't going to give you a physical address. Why can't we use
> __pa()?

You're correct, sorry, I missed removing the cast, it's not needed.
I've removed the __pa_symbol define as I'm switching to the __pa
implementation you suggested below.

>> +extern const void __nosave_begin, __nosave_end;
>> +
>> +int pfn_is_nosave(unsigned long pfn)
>> +{
>> +     unsigned long nosave_begin_pfn =
>> +                     __pa_symbol(&__nosave_begin) >> PAGE_SHIFT;
>> +     unsigned long nosave_end_pfn =
>> +                     PAGE_ALIGN(__pa_symbol(&__nosave_end)) >> PAGE_SHIFT;
>> +
>> +     return (pfn >= nosave_begin_pfn) && (pfn < nosave_end_pfn);
>> +}
>
> Perhaps this code could be:
>
>         unsigned long nosave_begin_pfn = virt_to_pfn(&__nosave_begin);
>         unsigned long nosave_end_pfn = virt_to_pfn(&__nosave_end);
>
>         return (pfn >= nosave_begin_pfn) && (pfn <= nosave_end_pfn);
>
> or if virt_to_pfn() doesn't exist on ARM and we can't add it for
> some reason:
>
>         unsigned long nosave_begin_pfn = __phys_to_pfn(__pa(&__nosave_begin));
>         unsigned long nosave_end_pfn = __phys_to_pfn(__pa(&__nosave_end));
>
>         return (pfn >= nosave_begin_pfn) && (pfn <= nosave_end_pfn);
I've moved to this second implementation.  I don't think I understand
the ramifications enough to add the virt_to_pfn call for arm.

I've changed one thing.  __nosave_end is pointing at the first byte
not included in the nosave region.  I subtracted one from it so that
we make sure we're referring to the last pfn, and left the pfn
comparison as you'd suggested.

int pfn_is_nosave(unsigned long pfn)
{
        unsigned long nosave_begin_pfn = __phys_to_pfn(__pa(&__nosave_begin));
        unsigned long nosave_end_pfn = __phys_to_pfn(__pa(&__nosave_end - 1));

        return (pfn >= nosave_begin_pfn) && (pfn <= nosave_end_pfn);
}

I'll test this and post it if everyone's ok with it.

Thanks for your review and comments Stephen!

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