diff options
author | jistone <jistone> | 2007-01-20 03:03:42 +0000 |
---|---|---|
committer | jistone <jistone> | 2007-01-20 03:03:42 +0000 |
commit | c4ae8cfe0247e025df7184390db3dec36dcf9263 (patch) | |
tree | 7a0cec5b515183ab807f892981de7adcc32c2175 /runtime | |
parent | 5212330de73ed43224b1fa3c5aaaf567da2ecd93 (diff) | |
download | systemtap-steved-c4ae8cfe0247e025df7184390db3dec36dcf9263.tar.gz systemtap-steved-c4ae8cfe0247e025df7184390db3dec36dcf9263.tar.xz systemtap-steved-c4ae8cfe0247e025df7184390db3dec36dcf9263.zip |
2007-01-19 Josh Stone <joshua.i.stone@intel.com>
PR 3079
runtime/
* loc2c-runtime.h (kread, kwrite): New macros to safely read/write
values from kernel pointers. This includes a workaround for 64-bit
numbers on i386 platforms.
testsuite/
* systemtap.base/deref.stp: Use the new kread macro that should work
fine with 64-bit numbers on i386 platforms. Also expand the test to
include writes with kwrite.
* systemtap.base/deref.exp: Remove the setup_kfail.
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/ChangeLog | 7 | ||||
-rw-r--r-- | runtime/loc2c-runtime.h | 40 |
2 files changed, 46 insertions, 1 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 500dd25b..d14c5b8f 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,10 @@ +2007-01-19 Josh Stone <joshua.i.stone@intel.com> + + PR 3079 + * loc2c-runtime.h (kread, kwrite): New macros to safely read/write + values from kernel pointers. This includes a workaround for 64-bit + numbers on i386 platforms. + 2007-01-10 Martin Hunt <hunt@redhat.com> PR 3708 * map.c (str_copy): Check for NULL pointers. diff --git a/runtime/loc2c-runtime.h b/runtime/loc2c-runtime.h index c51908a9..4617f697 100644 --- a/runtime/loc2c-runtime.h +++ b/runtime/loc2c-runtime.h @@ -1,6 +1,6 @@ /* target operations * Copyright (C) 2005 Red Hat Inc. - * Copyright (C) 2005,2006 Intel Corporation. + * Copyright (C) 2005, 2006, 2007 Intel Corporation. * * This file is part of systemtap, and is free software. You can * redistribute it and/or modify it under the terms of the GNU General @@ -461,3 +461,41 @@ *_d = '\0'; \ (dst); \ }) + + +#if defined __i386__ + +/* x86 can't do 8-byte put/get_user_asm, so we have to split it */ + +#define kread(ptr) \ + ({ \ + typeof(*(ptr)) _r; \ + if (sizeof(*(ptr)) == 8) { \ + union { u64 q; u32 l[2]; } _q; \ + _q.l[0] = (u32) deref(4, &((u32 *)(ptr))[0]); \ + _q.l[1] = (u32) deref(4, &((u32 *)(ptr))[1]); \ + _r = (typeof(*(ptr))) _q.q; \ + } else \ + _r = (typeof(*(ptr))) deref(sizeof(*(ptr)), (ptr)); \ + _r; \ + }) + +#define kwrite(ptr, value) \ + ({ \ + if (sizeof(*(ptr)) == 8) { \ + union { u64 q; u32 l[2]; } _q; \ + _q.q = (u64)(typeof(*(ptr)))(value); \ + store_deref(4, &((u32 *)(ptr))[0], _q.l[0]); \ + store_deref(4, &((u32 *)(ptr))[1], _q.l[1]); \ + } else \ + store_deref(sizeof(*(ptr)), (ptr), (typeof(*(ptr)))(value)); \ + }) + +#else + +#define kread(ptr) \ + ( (typeof(*(ptr))) deref(sizeof(*(ptr)), (ptr)) ) +#define kwrite(ptr, value) \ + ( store_deref(sizeof(*(ptr)), (ptr), (typeof(*(ptr)))(value)) ) + +#endif |