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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 16 Mar 2015 09:35:10 +0100
From:	Ingo Molnar <mingo@...nel.org>
To:	Ross Zwisler <ross.zwisler@...ux.intel.com>
Cc:	Borislav Petkov <bp@...en8.de>, linux-kernel@...r.kernel.org,
	H Peter Anvin <h.peter.anvin@...el.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] x86: Add kerneldoc for pcommit_sfence()


* Ross Zwisler <ross.zwisler@...ux.intel.com> wrote:

> > > > + * void flush_and_commit_buffer(void *vaddr, unsigned int size)
> > > > + * {
> > > > + *         unsigned long clflush_mask = boot_cpu_data.x86_clflush_size - 1;
> > > > + *         char *vend = (char *)vaddr + size;
> > 
> > So here we cast vaddr to (char *) - which is unnecessary, as 'void *' 
> > has byte granular pointer arithmetics.
> > 
> > And 'vend' should be void *' to begin with, to match the type 
> > of 'vaddr'.
> 
> The original version, copied in part from clflush_cache_range, did do
> everything with void* pointers.  I changed it to use char* pointers based on
> feedback from hpa.  :)

:-/

Not sure what hpa's problem with 'void *' was: especially in MM code 
we are using 'void *' rather widely.

All compilers that aim for being able to build the Linux kernel 
implement 'void *' as well, so that 'standard C' argument is pretty 
weak IMHO - unlike some of the more esoteric GCC extensions, this one 
is actually pretty well done and widely used in and outside of the 
kernel.

> It seems like both have arguments for them.  Char pointer arithmetic 
> has the advantage that its behavior is standard in C, so it's not 
> specific to gcc.  I agree that void* has the advantage that it fits 
> more naturally with the types of the parameters passed in, requiring 
> no casting.

It's also a bonus property of 'void *' that unlike 'char *' it cannot 
be dereferenced. So we use it for opaque buffers wherever we can.

> > > > + *         for (p = (char *)((unsigned long)vaddr & ~clflush_mask);
> > > > + *              p < vend; p += boot_cpu_data.x86_clflush_size)
> > > > + *                 clwb(p);
> > > > + *
> > > > + *         // sfence to order clwb/clflushopt/clflush cache flushes
> > > > + *         // mfence via mb() also works
> > 
> > Yeah so this isn't a C++ kernel, thank all the 3000+ gods and other 
> > supreme beings worshipped on this planet!
> 
> Yep.  C++ style // comments are happily accepted by gcc in C code, though, and

GCC accepts other C++ braindamage as well, it doesn't mean we should 
use them. But:

> this was my attempt to get around the fact that /* */ style comments can't be
> nested.  I couldn't think of a more elegant way of having code + comments in a
> kerneldoc comment.  I agree that if this code were ever to be pulled out and
> used, the comment style would need to be corrected to be the standard kernel
> style.

I see, I didn't realize the recursion complication with DocBook - so 
this bit is fine.

Thanks,

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