[Click] AMD64
Qinghua(Kevin) Ye
qye at trlabs.ca
Mon Jun 6 13:49:55 EDT 2005
Hi Adam,
I have been working on AMD64 and kernel 2.6.11.6 smp based on the CVS
version on May.20. The following is some minor modifications for the Linux
Kernel module. I am still testing on it and plan to report it to Eddie once
I finish testing. Since you are also working on this, let's share
information.
The patch for 2.6.11.6 on my server has some minor problem. But they are
obvious. I will give it at the end.
Eddie, could you check that if there are any incorrect modifications?
Thanks.
Modifications for the type problem:
1. In lib/glue.cc, modify void *operator new(unsigned sz) throw ()
to operator new(size_t sz) throw ()
Reason: The size_t in i386 is unsigned int, but in x86_64 is unsigned
long. We put here size_t to compatible with both
Modify void * operator new[](unsigned sz) throw () to operator
new[](size_t sz) throw ()
2. In elements/linxumodule/cpuqueue.cc,for function String
CPUQueue::read_handler(Element *e, void *thunk)
Change int which = reinterpret_cast<int>(thunk);
to
long which = reinterpret_cast<long>(thunk);
3. In elements/linuxmodule/fromdevice.cc",
In static String FromDevice_read_stats(Element *e, void *thunk)
Change int which = reinterpret_cast<int>(thunk);
to long which = reinterpret_cast<long>(thunk);
4. in elements/linuxmodule/polldevice.cc",
In static String PollDevice_read_stats(Element *e, void *thunk)
Change int which = reinterpret_cast<int>(thunk);
to long which = reinterpret_cast<long>(thunk);
5. In elements/linuxmodule/rtcycles.cc",
In static String FromDevice_read_stats(Element *e, void *thunk)
Change int which = reinterpret_cast<int>(thunk);
to long which = reinterpret_cast<long>(thunk);
6. /linuxmodule/clickfs.c
Change #define FILP_STRINGNO(filp)
(reinterpret_cast<int>((filp)->private_data))
To: #define FILP_STRINGNO(filp)
(reinterpret_cast<long>((filp)->private_data))
Modifications for the 64 bit int problem:
1. include/click/string.hh
Change #if HAVE_INT64_TYPES && !HAVE_64_BIT_LONG
To #if HAVE_INT64_TYPES && (!HAVE_64_BIT_LONG||defined(__KERNEL__))
2. include/click/straccum.hh
Change #if HAVE_INT64_TYPES && !HAVE_64_BIT_LONG
To #if HAVE_INT64_TYPES && (!HAVE_64_BIT_LONG||defined(__KERNEL__))
3. lib/string.cc
Change #if HAVE_INT64_TYPES && !HAVE_64_BIT_LONG
To #if HAVE_INT64_TYPES && (!HAVE_64_BIT_LONG||defined(__KERNEL__))
4. lib/straccum.cc
Change #if HAVE_INT64_TYPES && !HAVE_64_BIT_LONG
To #if HAVE_INT64_TYPES && (!HAVE_64_BIT_LONG||defined(__KERNEL__))
5. /linuxmodule/proclikefs.c
comment the line #include <linux/modversions.h>
Support for SMP:
1. In include/click/atomic.hh, modify inline uint32_t
atomic_uint32_t::read_and_add(uint32_t delta)
after #else in line 85
/* Modified by Qinghua Ye, to add support for __x86_64__ */
#if defined(__x86_64__)
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
asm volatile (LOCK "xaddl %0,%1"
: "=r" (delta), "=m" (_val.counter)
: "0" (delta), "m" (_val.counter));
# else
asm volatile (LOCK "xaddl %0,%1"
: "=r" (delta), "=m" (__atomic_fool_gcc(&_val))
: "0" (delta), "m" (__atomic_fool_gcc(&_val)));
# endif
return delta;
# else
...
...
#endif
2. include/click/atomic.hh, modify inline
atomic_uint32_t::compare_and_swap(uint32_t test_value, uint32_t new_value)
after #else
/* Modified by Qinghua Ye*/
# if defined(__x86_64__)
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
asm (LOCK "cmpxchgl %2,%0"
: "=m" (_val.counter), "=a" (old_value)
: "r" (new_value), "m" (_val.counter), "a" (test_value)
// : "eax", "cc", "memory");
: "cc", "memory");
# else
asm (LOCK "cmpxchgl %2,%0"
: "=m" (__atomic_fool_gcc(&_val)), "=a" (old_value)
: "r" (new_value), "m" (__atomic_fool_gcc(&_val)), "a" (test_value)
// : "eax", "cc", "memory");
: "cc", "memory");
# endif
#else
....
# endif
#endif
return old_value;
}
3. In include/click/sync.hh, modify inline Spinlock::Spinlock() as:
/* Modify by Qinghua Ye*/
#if ((!defined(__i386__))&&(!defined(__x86_64__)))
# error "no multithread support for non i386 or x86_64 click"
#endif
Modifications on patched kernel 2.6.11.6
1. include/asm-x86_64/mmu_context.h
57c57
< asm volatile("movq %0,%%cr3" : "r" (__pa(next->pgd)) : "memory");
---
> asm volatile("movq %0,%%cr3" :: "r" (__pa(next->pgd)) : "memory");
2. include/asm-x86_64/mmu_context.h
7,9d6
< #ifdef __KERNEL__
15a13,14
> #ifdef CONFIG_SMP
3.include/asm-x86_64/thread_info.h
63c63
< ti = (void *)(read_pda(kernelstack) + PDA_STACKOFFSET - THREAD_SIZE);
---
> ti = (struct thread_info *)(read_pda(kernelstack) + PDA_STACKOFFSET -
THREAD_SIZE);
4.include/linux/fs.h
1644c1644
< struct simple_transaction_argresp *ar = file->private_data;
---
> struct simple_transaction_argresp *ar = (struct simple_transaction_argresp
*)file->private_data;
5.include/net/sock.h
1017,1018c1017,1018
< unsigned int csum = csum_and_copy_from_user(from,
< page_address(page) + off,
---
> unsigned int csum = csum_and_copy_from_user((unsigned char *)from,
> (unsigned char *)page_address(page) + off,
1023c1023
< } else if (copy_from_user(page_address(page) + off, from, copy))
---
> } else if (copy_from_user((unsigned char *)page_address(page) + off, from,
copy))
Regards,
Qinghua(Kevin) Ye
----- Original Message -----
From: "Adam Greenhalgh" <a.greenhalgh at cs.ucl.ac.uk>
To: <click at amsterdam.lcs.mit.edu>
Sent: Friday, June 03, 2005 10:37 AM
Subject: [Click] AMD64
> Hi
>
> We are part way through getting click to work on an amd 64 box, has
> anyone else done this and tested it ?
>
> Adam
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
More information about the click
mailing list