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: <20110120050143.GC9482@suse.de>
Date:	Wed, 19 Jan 2011 21:01:43 -0800
From:	Greg KH <gregkh@...e.de>
To:	Uwe Kleine-König 
	<u.kleine-koenig@...gutronix.de>
Cc:	Jiri Slaby <jirislaby@...il.com>, devel@...verdev.osuosl.org,
	Haiyang Zhang <haiyangz@...rosoft.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging/hv/osd: don't reimplement ALIGN macro

On Wed, Jan 19, 2011 at 02:07:30PM +0100, Uwe Kleine-König wrote:
> Hello Jiri,
> 
> On Wed, Jan 19, 2011 at 01:43:57PM +0100, Jiri Slaby wrote:
> > On 01/19/2011 09:54 AM, Uwe Kleine-König wrote:
> > > On Tue, Jan 18, 2011 at 09:37:15PM -0800, Greg KH wrote:
> > >> On Tue, Jan 18, 2011 at 04:39:11PM +0100, Uwe Kleine-König wrote:
> > >>> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
> > >>> ---
> > >>>  drivers/staging/hv/osd.h |    5 ++---
> > >>>  1 files changed, 2 insertions(+), 3 deletions(-)
> > >>>
> > >>> diff --git a/drivers/staging/hv/osd.h b/drivers/staging/hv/osd.h
> > >>> index ce064e8..61ae54c 100644
> > >>> --- a/drivers/staging/hv/osd.h
> > >>> +++ b/drivers/staging/hv/osd.h
> > >>> @@ -28,10 +28,9 @@
> > >>>  #include <linux/workqueue.h>
> > >>>  
> > >>>  /* Defines */
> > >>> -#define ALIGN_UP(value, align)	(((value) & (align-1)) ?		\
> > >>> -				 (((value) + (align-1)) & ~(align-1)) :	\
> > >>> -				 (value))
> > >>> +#define ALIGN_UP(value, align)		ALIGN((value), (align))
> > >>
> > >> How about dropping ALIGN_UP entirely and just using the built-in ALIGN()
> > >> macro instead?
> > > Can do.
> > > 
> > >>>  #define ALIGN_DOWN(value, align)	((value) & ~(align-1))
> > >>
> > >> Any chance to get rid of this as well with the ALIGN() macro, or is that
> > >> really not possible?
> > > it would be
> > > 
> > > 	#define ALIGN_DOWN(value, align) ALIGN((value) - (align) + 1, (align))
> > > 
> > > I think, but as it's only used once it might be easier to just use ALIGN
> > > there, too.
> > > 
> > > BTW, it's used as follows:
> > > 
> > > 	#define NUM_PAGES_SPANNED(addr, len)    ((ALIGN(addr+len, PAGE_SIZE) - \
> > > 						 ALIGN_DOWN(addr, PAGE_SIZE)) >>  \
> > > 						 PAGE_SHIFT)
> > 
> > (DIV_ROUND_UP(addr+len, PAGE_SIZE) - ((addr) >> PAGE_SHIFT)))
> > 
> > or maybe better
> > 
> > (PAGE_ALIGN(addr+len) >> PAGE_SHIFT - ((addr) >> PAGE_SHIFT))
> > 
> > > I wonder if there is already a function yielding this value?
> > > Wouldn't
> > > 
> > > 	((addr + len) >> PAGE_SHIFT) - (addr >> PAGE_SHIFT) + 1
> > 
> > No, this won't work (it's not equivalent).
> Ah, this fails if addr + len is page aligned.
> 
> 	((addr + len - 1) >> PAGE_SHIFT) - (addr >> PAGE_SHIFT) + 1
> 
> would work, but I like
> 
> 	(PAGE_ALIGN(addr+len) >> PAGE_SHIFT - ((addr) >> PAGE_SHIFT))
> 
> better.  (In fact these two are equivalent:
> 
> 	PAGE_ALIGN(addr+len) >> PAGE_SHIFT =
> 	__ALIGN_KERNEL(addr+len, PAGE_SIZE) >> PAGE_SHIFT =
> 	__ALIGN_KERNEL_MASK(addr+len, PAGE_SIZE - 1) >> PAGE_SHIFT =
> 	((addr + len + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) >> PAGE_SHIFT =
> 	(addr + len + PAGE_SIZE - 1) >> PAGE_SHIFT =
> 	(addr + len - 1) >> PAGE_SHIFT + 1
> 
> Greg: should I send an updated patch or do you modify NUM_PAGES_SPANNED
> accordingly?

Can you please send a new patch?

thanks,

greg k-h
--
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