On Wed, 2011-05-25 at 18:38 +0100, Dave Martin wrote:
On Wed, May 25, 2011 at 04:02:40PM +0100, Tixy wrote:
On Wed, 2011-05-25 at 14:51 +0100, Dave Martin wrote:
On Wed, May 25, 2011 at 10:17:23AM +0100, Tixy wrote:
The code in question is my module for testing kprobes. I have macros create test cases for probing different CPU instructions, each test case generates inline assembler.
Can this test module go into the kernel tree?
Yes.
Nico might have a view on whether that's likely to be useful.
He suggested it go in the kernel tree when I asked him ;-)
Although we're focusing on ARM, I also wonder whether anything here is generalisable to other arches -- if so, upstream might be correspondingly more interested. This might be hard to achieve with this sort of tests, though.
Most of it is very ARM specific.
It's a minor thing though ... in reality I expect .code will continue to be understood by the assembler forever in any case.
"0: \n\t" "instruction_to_test \n\t" "b __test_case_end_"TEST_ISA" \n\t" ".align \n\t"
(Actually, you don't need .align here, but it's harmless. Unlike data, every instruction emitted by the assembler is always aligned up to the appropriate boundary depending on the ISA.)
I do need the align because otherwise the label 99: below won't be aligned, and that's the label test_case_end jumps back to.
I may just be getting confused by what the complete code does.
Do you have the whole thing committed somewhere? I could take a look if so.
I put my latest code at http://tixy.me.uk/kprobes-test.c it needs some tidying up, documentation, and integrating into the kernel.
test_case_{start,end} are mostly trampolines which call C code, but the functions containing the test cases themselves do just expand to asm statements. However, I make heavy use of macro expansion and string literal concatenation to paste together assembler instructions, I'm not sure I could do all of this in an assembler file. Anyway, I'd rather not redo weeks of work unless things are very broken.
Assembler files are processed by cpp anyway, so anything that can be done in a C source file can be done there.
String concatenation isn't a CPP thing though is it? E.g. can I build a single assembler statement from strings? E.g. this artificial but realistic example macro
#define FOO(A,B) "add" A " r"__sringify(C) ", #99"
When used as FOO("s",0) produces an "adds r0, #99" instruction to assemble.
We also have some useful facilities in <arm/assembler.h> for standalone assembler files, most of which are not easily usable in inline assembler (such as the BSYM macro for taking the address of code symbols so that indirect calls will work in ARM and Thumb) -- plus you can use assembler macros, which are almost infinitely more useful than the C preprocessor IMHO ... but that's just my personal hobby-horse ;)
Point taken though -- if you have something that works already, there's no need to rewrite everything. From snippets of code, I thought you were in the early stages of writing this.
The test code is essentially complete, I wrote it in parallel with the fixing and implementation of the instruction simulation.