Skip to content

Commit

Permalink
Fix KSPLICE_IP for new x86-64 kernels.
Browse files Browse the repository at this point in the history
Even though struct thread_struct.ip is present after 2.6.25 as a
result of the x86 unification, it is still not used for x86-64; the
context switching macro always begins execution at thread_return.
(See the definitions of switch_to in arch/x86/include/asm/system.h.)
This unused field was removed for 2.6.31 under !CONFIG_X86_32 by
commit 0c23590f00f85467b318ad0c20c36796a5bd4c60.

Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Aug 26, 2009
1 parent a294e8d commit c59aacc
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions kmodsrc/x86/ksplice-arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,31 @@
* 02110-1301, USA.
*/

#if defined(_ASM_X86_PROCESSOR_H) || \
defined(__ASM_X86_PROCESSOR_H) /* New unified x86 */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)

#ifdef CONFIG_X86_64
extern const char thread_return[];
EXTRACT_SYMBOL(thread_return);
#define KSPLICE_IP(x) ((unsigned long)thread_return)
#else /* !CONFIG_X86_64 */
#define KSPLICE_IP(x) ((x)->thread.ip)
#endif /* CONFIG_X86_64 */
#define KSPLICE_SP(x) ((x)->thread.sp)
#elif defined(CONFIG_X86_64) /* Old x86 64-bit */
/* The IP is on the stack, so we don't need to check it separately.
* Instead, we need to prevent Ksplice from patching thread_return.
*/

#else /* LINUX_VERSION_CODE < */
/* faca62273b602ab482fb7d3d940dbf41ef08b00e was after 2.6.24 */

#ifdef CONFIG_X86_64
extern const char thread_return[];
EXTRACT_SYMBOL(thread_return);
#define KSPLICE_IP(x) ((unsigned long)thread_return)
#define KSPLICE_SP(x) ((x)->thread.rsp)
#else /* Old x86 32-bit */
#else /* !CONFIG_X86_64 */
#define KSPLICE_IP(x) ((x)->thread.eip)
#define KSPLICE_SP(x) ((x)->thread.esp)
#endif /* __ASM_X86_PROCESSOR_H */
#endif /* CONFIG_X86_64 */

#endif /* LINUX_VERSION_CODE */

#ifndef CONFIG_FUNCTION_DATA_SECTIONS
#include "udis86.h"
Expand Down

0 comments on commit c59aacc

Please sign in to comment.