From e04f683d85388992d5a0b9aa063c0dedd2ceeff2 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Fri, 5 Jun 2015 00:04:07 +0300 Subject: [PATCH] pie: x86-32 -- Prepare parasite head Signed-off-by: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- arch/x86/include/asm/parasite.h | 4 ++++ arch/x86/parasite-head.S | 23 +++++++++++++++++++++++ pie/parasite.c | 6 +++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/parasite.h b/arch/x86/include/asm/parasite.h index 48e48ac98..669ae63e2 100644 --- a/arch/x86/include/asm/parasite.h +++ b/arch/x86/include/asm/parasite.h @@ -1,6 +1,10 @@ #ifndef __ASM_PARASITE_H__ #define __ASM_PARASITE_H__ +#ifdef CONFIG_X86_32 +# define __parasite_entry __attribute__((regparm(3))) +#endif + static inline void arch_get_tls(tls_t *ptls) { (void)ptls; } #endif diff --git a/arch/x86/parasite-head.S b/arch/x86/parasite-head.S index 8caf9b3b9..b61b712f7 100644 --- a/arch/x86/parasite-head.S +++ b/arch/x86/parasite-head.S @@ -2,6 +2,9 @@ #include "parasite.h" .section .head.text, "ax" + +#ifdef CONFIG_X86_64 + ENTRY(__export_parasite_head_start) subq $16, %rsp andq $~15, %rsp @@ -15,3 +18,23 @@ ENTRY(__export_parasite_head_start) __export_parasite_cmd: .long 0 END(__export_parasite_head_start) + +#else /* CONFIG_X86_64 */ + +ENTRY(__export_parasite_head_start) + subl $8, %esp + andl $~7, %esp + pushl $0 + movl %esp, %ebp + call 1f +1: popl %ecx +2: leal (__export_parasite_cmd-2b)(%ecx), %eax + leal (__export_parasite_args-2b)(%ecx), %edx + call parasite_service + int $0x03 + .align 8 +GLOBAL(__export_parasite_cmd) + .long 0 +END(__export_parasite_head_start) + +#endif /* CONFIG_X86_64 */ diff --git a/pie/parasite.c b/pie/parasite.c index 1ceb821bf..fa87599dc 100644 --- a/pie/parasite.c +++ b/pie/parasite.c @@ -690,7 +690,11 @@ err: return -1; } -int __used parasite_service(unsigned int cmd, void *args) +#ifndef __parasite_entry +# define __parasite_entry +#endif + +int __used __parasite_entry parasite_service(unsigned int cmd, void *args) { pr_info("Parasite cmd %d/%x process\n", cmd, cmd);