On Wed, May 25, 2011 at 09:02:55PM +0100, Tixy wrote:
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.
OK, fair enough.
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.
Thanks
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.
In assembler almost nothing is quoted, so you can just use token- pasting:
#define HASH # #define FOO(A,B) add##A r##B, HASH 99
(admittedly the HASH thing is unfortunate, resulting from ARM assembler happening to use a symbol that's also a C preprocessor operator. There might be a better way of solving that.)
This would be referenced with A unquoted, i.e., FOO(s, 0)
Alternatively you can do it with an asembler macro:
.macro FOO A, B add\A r\B , #99 .endm
...
FOO s, 0
Cheers ---Dave