nixpkgs/pkgs/os-specific/linux/blcr/fixes.patch

305 lines
13 KiB
Diff
Raw Normal View History

diff -ru -x Makefile.in -x aclocal.m4 -x configure -x '*config.h.in' -x 'config.*' -x depcomp -x install-sh -x ltmain.sh -x missing blcr-0.8.2-orig/acinclude.m4 blcr-0.8.2/acinclude.m4
--- blcr-0.8.2-orig/acinclude.m4 2009-06-12 22:37:01.000000000 +0200
+++ blcr-0.8.2/acinclude.m4 2010-07-29 21:18:29.000000000 +0200
@@ -953,8 +953,9 @@
# When complete sets LINUX_SYMTAB_CMD such that
# "eval $LINUX_SYMTAB_CMD" will produce a System.map on stdout.
cr_stripped_maps=''
+m4_define([cr_ksymtab_patt],[[-e '[TD] sys_open' -e '[AB] _end']])
AC_DEFUN([_CR_CHECK_SYSTEM_MAP],[
- if test -n "$1" -a -r "$1" && grep ' [[AB]] _end' <"$1" >/dev/null 2>/dev/null; then
+ if test -n "$1" -a -r "$1" && grep cr_ksymtab_patt <"$1" >/dev/null 2>/dev/null; then
if grep -B1 '[[AB]] _end' <"$1" | grep _stext >/dev/null 2>/dev/null; then
# Reject "stripped" files (such as in FC2)
# Recognized (poorly) by _stext and _end as last two entries.
@@ -968,7 +969,7 @@
])
AC_DEFUN([_CR_CHECK_VMLINUX],[
AC_REQUIRE([AC_PROG_NM])
- if test -n "$1" -a -r "$1" && ($NM "$1" | grep ' [[AB]] _end') >/dev/null 2>/dev/null; then
+ if test -n "$1" -a -r "$1" && ($NM "$1" | grep cr_ksymtab_patt) >/dev/null 2>/dev/null; then
LINUX_VMLINUX="$1"
LINUX_SYMTAB_FILE="$1"
LINUX_SYMTAB_CMD="$NM $1 2>/dev/null"
diff -ru -x Makefile.in -x aclocal.m4 -x configure -x '*config.h.in' -x 'config.*' -x depcomp -x install-sh -x ltmain.sh -x missing blcr-0.8.2-orig/blcr_imports/module.c blcr-0.8.2/blcr_imports/module.c
--- blcr-0.8.2-orig/blcr_imports/module.c 2008-05-13 08:06:19.000000000 +0200
+++ blcr-0.8.2/blcr_imports/module.c 2010-07-29 21:18:29.000000000 +0200
@@ -81,7 +81,13 @@
/* Check current kernel against System.map used at configure time */
{
+#if defined(CR_EXPORTED_KCODE_register_chrdev)
unsigned long offset1 = CR_EXPORTED_KCODE_register_chrdev - (unsigned long)&register_chrdev;
+#elif defined(CR_EXPORTED_KCODE___register_chrdev)
+ unsigned long offset1 = CR_EXPORTED_KCODE___register_chrdev - (unsigned long)&__register_chrdev;
+#else
+ #error "No register_chrdev symbol for validation of System.map"
+#endif
unsigned long offset2 = CR_EXPORTED_KCODE_register_blkdev - (unsigned long)&register_blkdev;
if (
#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_PHYSICAL_ALIGN)
diff -ru -x Makefile.in -x aclocal.m4 -x configure -x '*config.h.in' -x 'config.*' -x depcomp -x install-sh -x ltmain.sh -x missing blcr-0.8.2-orig/config/kbuild.mak.in blcr-0.8.2/config/kbuild.mak.in
--- blcr-0.8.2-orig/config/kbuild.mak.in 2008-08-04 20:39:29.000000000 +0200
+++ blcr-0.8.2/config/kbuild.mak.in 2010-07-29 21:18:29.000000000 +0200
@@ -1,7 +1,7 @@
# Here are the configuration bits needed in the "caller" to use this file
#SUBDIR = vmadump4
#TARGET = vmadump
-#SOURCES = vmadump_common.c vmadump_@CR_ARCH@.c optional.h
+#SOURCES = vmadump_common.c vmadump_@CR_KARCH@.c optional.h
#[optional]EXTRA_CFLAGS = -I$(top_builddir)/include -I$(top_builddir) -I$(srcdir)
#[optional]IMPORTS_FROM = /some/other/kbuild/module/dir /and/another
#
@@ -26,7 +26,7 @@
# Remove headers from the list of sources, and sort to remove possible duplicates
DOT_C := $(sort $(filter %.c,$(SOURCES)))
-ifeq ($(TOPDIR),)
+ifeq ($(srctree),)
# not within KBUILD - implement automake's standard goals
all: $(LINUX_OBJ)/.config prepare
diff -ru -x Makefile.in -x aclocal.m4 -x configure -x '*config.h.in' -x 'config.*' -x depcomp -x install-sh -x ltmain.sh -x missing blcr-0.8.2-orig/configure.ac blcr-0.8.2/configure.ac
--- blcr-0.8.2-orig/configure.ac 2009-06-16 00:33:56.000000000 +0200
+++ blcr-0.8.2/configure.ac 2010-07-29 21:18:29.000000000 +0200
@@ -123,6 +123,8 @@
AC_CONFIG_AUX_DIR(./config)
AM_INIT_AUTOMAKE([foreign no-exeext std-options])
+AM_MAINTAINER_MODE([enable])
+
################################################################################
# Boilerplate for versions and copyrights in generated files
################################################################################
@@ -454,9 +456,10 @@
AC_SUBST(CR_CLIENT_LDADD)
# If building the tests, we can optionally test C++
-if test x"$cr_build_tests" = xyes; then
+# Note, however, that bug 2619 reports that we can't call this conditionally.
+dnl if test x"$cr_build_tests" = xyes; then
CR_PROG_CXX
-fi
+dnl fi
################################################################################
# Check libraries
@@ -843,6 +846,22 @@
# Checks for matching (we hope) symbol table
CR_LINUX_SYMTAB
+# Set and substitute CR_KARCH to enable i386 userland on x86_64 kernels
+CR_KARCH=$CR_ARCH
+if test $CR_ARCH = i386; then
+ # probe the System.map to find out if we need to change CR_KARCH at all.
+ # All this does is count the number of *digits* in a hex formatted address
+ AC_MSG_NOTICE([Testing if KARCH is the same as ARCH])
+ symlen=`$LINUX_SYMTAB_CMD | head -n1 | sed 's/ .*$//;s/\(.\)/\1\n/g;s/\n$//'|wc -l`
+ if test $symlen -eq 16; then
+ AC_MSG_NOTICE([Changing KARCH to x86_64])
+ CR_KARCH=x86_64
+ else
+ AC_MSG_NOTICE([Not touching KARCH])
+ fi
+fi
+AC_SUBST([CR_KARCH], $CR_KARCH)
+
## Check for optional kernel headers...
CR_CHECK_KERNEL_HEADER([linux/syscalls.h])
CR_CHECK_KERNEL_HEADER([linux/pspace.h])
@@ -985,7 +1004,7 @@
fi
# put_task_struct() requires one of these:
-CR_FIND_KSYM([__put_task_struct],[CODE])
+CR_FIND_KSYM([__put_task_struct],[CODE],[extern void __put_task_struct(struct task_struct *);])
CR_FIND_KSYM([__put_task_struct_cb],[CODE])
CR_CHECK_KERNEL_MEMBER([mm.task_size],[#include <linux/sched.h>],
@@ -1025,7 +1044,7 @@
if test -n "${HAVE_MAP_VSYSCALL}"; then
CR_FIND_KSYM([map_vsyscall],[CODE])
fi
-if test $CR_ARCH = x86_64; then
+if test $CR_KARCH = x86_64; then
CR_FIND_KSYM([syscall32_setup_pages],[CODE],
[extern int syscall32_setup_pages(void *, int);])
fi
@@ -1093,7 +1112,7 @@
CR_FIND_KSYM([do_sigaltstack],[CODE],
[extern int do_sigaltstack(const stack_t *, stack_t *, unsigned long);])
-if test $CR_ARCH = i386 -o $CR_ARCH = x86_64; then
+if test $CR_KARCH = i386 -o $CR_KARCH = x86_64; then
CR_CHECK_KERNEL_TYPE([struct n_desc_struct],[
#include <linux/sched.h>
#include <asm/desc.h>])
@@ -1144,7 +1163,7 @@
fi
fi
-if test $CR_ARCH = i386; then
+if test $CR_KARCH = i386; then
CR_CHECK_KERNEL_MEMBER([pt_regs.xcs],[#include <asm/ptrace.h>],[struct pt_regs],[int],[xcs])
CR_CHECK_KERNEL_MEMBER([pt_regs.xfs],[#include <asm/ptrace.h>],[struct pt_regs],[int],[xfs])
CR_CHECK_KERNEL_MEMBER([pt_regs.xgs],[#include <asm/ptrace.h>],[struct pt_regs],[int],[xgs])
@@ -1230,6 +1249,7 @@
if test -z "${HAVE_2_ARG_FIND_PID}${HAVE_FIND_TASK_BY_PID}${HAVE_FIND_TASK_BY_PID_NS}"; then
CR_BAD_KERNEL([unable to determine how to map (type, pid_nr) -> struct task])
fi
+CR_FIND_KSYM([find_task_by_pid_ns],[CODE])
CR_CHECK_KERNEL_CALL([alloc_pid],[#include <linux/sched.h>])
if test -n "${HAVE_ALLOC_PID}"; then
@@ -1492,7 +1512,7 @@
CR_FIND_KSYM([sys_mremap],[CODE],
[extern asmlinkage unsigned long sys_mremap(unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr);])
CR_FIND_KSYM([do_sigaction],[CODE])
-if test $CR_ARCH = x86_64; then
+if test $CR_KARCH = x86_64; then
CR_FIND_KSYM([load_gs_index],[CODE])
CR_CHECK_KERNEL_CALL([read_pda],[#include <asm/percpu.h>])
@@ -1536,7 +1556,10 @@
# the System.map used to locate symbols and configure time.
CR_FIND_EXPORTED_KSYM([register_chrdev],[CODE])
if test "$cr_addr" = "0"; then
- CR_BAD_KERNEL([kernel does not export register_chrdev])
+ CR_FIND_EXPORTED_KSYM([__register_chrdev],[CODE])
+ if test "$cr_addr" = "0"; then
+ CR_BAD_KERNEL([kernel does not export register_chrdev or __register_chrdev])
+ fi
fi
CR_FIND_EXPORTED_KSYM([register_blkdev],[CODE])
if test "$cr_addr" = "0"; then
diff -ru -x Makefile.in -x aclocal.m4 -x configure -x '*config.h.in' -x 'config.*' -x depcomp -x install-sh -x ltmain.sh -x missing blcr-0.8.2-orig/cr_module/cr_kcompat.h blcr-0.8.2/cr_module/cr_kcompat.h
--- blcr-0.8.2-orig/cr_module/cr_kcompat.h 2009-06-12 22:37:03.000000000 +0200
+++ blcr-0.8.2/cr_module/cr_kcompat.h 2010-07-29 21:18:29.000000000 +0200
@@ -274,7 +274,8 @@
#elif HAVE_2_ARG_FIND_PID
#define cr_have_pid(T,P) (find_pid((T),(P)) != NULL)
#else
- #error
+ // XXX: untested!
+ #define cr_have_pid(T,P) (pid_task(find_vpid(P),(T)) != NULL)
#endif
// Process table iterators
@@ -583,4 +584,9 @@
#error "no cr_do_pipe() definition"
#endif
+#if !defined(DECLARE_MUTEX)
+ #define DECLARE_MUTEX(m) DEFINE_SEMAPHORE(m)
+ #define init_MUTEX(m) sema_init(m, 1)
+#endif
+
#endif /* _CR_KCOMPAT_H */
diff -ru -x Makefile.in -x aclocal.m4 -x configure -x '*config.h.in' -x 'config.*' -x depcomp -x install-sh -x ltmain.sh -x missing blcr-0.8.2-orig/cr_module/Makefile.am blcr-0.8.2/cr_module/Makefile.am
--- blcr-0.8.2-orig/cr_module/Makefile.am 2008-09-03 02:29:00.000000000 +0200
+++ blcr-0.8.2/cr_module/Makefile.am 2010-07-29 21:18:29.000000000 +0200
@@ -31,13 +31,13 @@
BPROC_VERSION = "4.0.0pre8"
vmadump_dir = $(top_srcdir)/vmadump4
-vmad_sources = $(vmadump_dir)/vmadump_common.c $(vmadump_dir)/vmadump_@CR_ARCH@.c
+vmad_sources = $(vmadump_dir)/vmadump_common.c $(vmadump_dir)/vmadump_@CR_KARCH@.c
vmad_include = -I$(vmadump_dir) -D__NR_vmadump=-1 -DBPROC_VERSION='$(BPROC_VERSION)'
cr_sources = $(my_sources) $(vmad_sources)
INCLUDES = -I$(top_builddir)/include \
-I$(top_srcdir)/include \
- -I$(srcdir)/arch/@CR_ARCH@ \
+ -I$(srcdir)/arch/@CR_KARCH@ \
$(vmad_include)
# echo an arbitrary make/environment variable (needed by kbuild glue)
diff -ru -x Makefile.in -x aclocal.m4 -x configure -x '*config.h.in' -x 'config.*' -x depcomp -x install-sh -x ltmain.sh -x missing blcr-0.8.2-orig/include/blcr_ksyms.h blcr-0.8.2/include/blcr_ksyms.h
--- blcr-0.8.2-orig/include/blcr_ksyms.h 2008-12-02 01:17:42.000000000 +0100
+++ blcr-0.8.2/include/blcr_ksyms.h 2010-07-29 21:18:29.000000000 +0200
@@ -55,7 +55,11 @@
#if defined(__i386__) || defined(__x86_64__)
#ifdef CONFIG_RELOCATABLE
- #define _CR_RELOC_KSYM(_addr) (_addr - CR_EXPORTED_KCODE_register_chrdev + register_chrdev)
+ #ifndef CR_EXPORTED_KCODE___register_chrdev
+ #define _CR_RELOC_KSYM(_addr) (_addr - CR_EXPORTED_KCODE_register_chrdev + register_chrdev)
+ #else
+ #define _CR_RELOC_KSYM(_addr) (_addr - CR_EXPORTED_KCODE___register_chrdev + __register_chrdev)
+ #endif
#else
#define _CR_RELOC_KSYM(_addr) _addr
#endif
diff -ru -x Makefile.in -x aclocal.m4 -x configure -x '*config.h.in' -x 'config.*' -x depcomp -x install-sh -x ltmain.sh -x missing blcr-0.8.2-orig/libcr/arch/arm/cr_atomic.h blcr-0.8.2/libcr/arch/arm/cr_atomic.h
--- blcr-0.8.2-orig/libcr/arch/arm/cr_atomic.h 2008-09-05 05:55:11.000000000 +0200
+++ blcr-0.8.2/libcr/arch/arm/cr_atomic.h 2010-07-29 21:18:29.000000000 +0200
@@ -33,6 +33,25 @@
#ifndef _CR_ATOMIC_H
#define _CR_ATOMIC_H 1
+#if defined(__ARM_ARCH_2__) || defined(__ARM_ARCH_3__)
+ // Sanity-check that we're not building on a really old architecture,
+ // so that the using #ifdef __ARM_ARCH_4__ works to test for
+ // lack of blx <register> support.
+ #error "ARM Architecture versions prior to ARMv4 not supported."
+#elif defined(__ARM_ARCH_4T__) && defined(__thumb__)
+ // The inline asm is not compatible with Thumb-1 anyway, but in particular
+ // we assume later that if __ARM_ARCH_4__ is not defined, we have ARMv5
+ // or above. Ensure here that this assumption will be valid.
+ #error "Building for Thumb on ARMv4 is not supported."
+#endif
+
+// Determine whether to use BLX <register> for function calls to
+// computed addresses:
+#undef ARM_HAVE_BLX_REG
+#if !(defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__))
+ #define ARM_HAVE_BLX_REG 1
+#endif
+
#include "blcr_config.h"
#ifndef _STRINGIFY
@@ -61,7 +80,7 @@
__asm__ __volatile__("": : :"memory");
}
-#if defined(CR_KCODE___kuser_cmpxchg)
+#if 1
// For kernel >= 2.6.12, we use __kernel_cmpxchg()
// See linux-2.6.12/arch/arm/kernel/entry-armv.S
// For >= ARM6 we could/should be using load-exclusive directly.
@@ -83,10 +102,15 @@
__asm__ __volatile__ (
"0: ldr r0, [r2] @ r0 = *p \n"
+ " add r1, r0, %2 @ r1 = r0 + op \n"
" mov r3, #" _STRINGIFY(cri_kuser_base) " \n"
+#ifdef ARM_HAVE_BLX_REG
+ " sub r3, r3, #" _STRINGIFY(cri_kuser_offset) "\n"
+ " blx r3\n"
+#else // ARMv4T and below
" adr lr, 1f @ lr = return address \n"
- " add r1, r0, %2 @ r1 = r0 + op \n"
" sub pc, r3, #" _STRINGIFY(cri_kuser_offset) "\n"
+#endif
"1: bcc 0b @ retry on Carry Clear"
: "=&r" (__sum)
: "r" (__ptr), "rIL" (op)
@@ -135,9 +159,14 @@
__asm__ __volatile__ (
"0: mov r0, r4 @ r0 = oldval \n"
" mov r3, #" _STRINGIFY(cri_kuser_base) " \n"
- " mov lr, pc @ lr = return addr \n"
+#ifdef ARM_HAVE_BLX_REG
+ " sub r3, r3, #" _STRINGIFY(cri_kuser_offset) "\n"
+ " blx r3\n"
+#else // ARMv4T and below
+ " adr lr, 1f @ lr = return addr \n"
" sub pc, r3, #" _STRINGIFY(cri_kuser_offset) "\n"
- " ldrcc ip, [r2] @ if (!swapped) ip=*p \n"
+#endif
+ "1: ldrcc ip, [r2] @ if (!swapped) ip=*p \n"
" eorcs ip, r4, #1 @ else ip=oldval^1 \n"
" teq r4, ip @ if (ip == oldval) \n"
" beq 0b @ then retry "