aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lguest/lg.h
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2007-10-21 21:24:24 -0400
committerRusty Russell <rusty@rustcorp.com.au>2007-10-23 01:49:56 -0400
commit2d37f94a28170ca656438758fca577acb49a7932 (patch)
tree21049219a98d314a2c442293e512b74d879e6270 /drivers/lguest/lg.h
parent56ae43dfe233323683248a5c553bad7160db2fa5 (diff)
generalize lgread_u32/lgwrite_u32.
Jes complains that page table code still uses lgread_u32 even though it now uses general kernel pte types. The best thing to do is to generalize lgread_u32 and lgwrite_u32. This means we lose the efficiency of getuser(). We could potentially regain it if we used __copy_from_user instead of copy_from_user, but I'm not certain that our range check is equivalent to access_ok() on all platforms. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Acked-by: Jes Sorensen <jes@sgi.com>
Diffstat (limited to 'drivers/lguest/lg.h')
-rw-r--r--drivers/lguest/lg.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h
index 4d45b7036e82..d9144beca82c 100644
--- a/drivers/lguest/lg.h
+++ b/drivers/lguest/lg.h
@@ -98,12 +98,27 @@ struct lguest
98extern struct mutex lguest_lock; 98extern struct mutex lguest_lock;
99 99
100/* core.c: */ 100/* core.c: */
101u32 lgread_u32(struct lguest *lg, unsigned long addr);
102void lgwrite_u32(struct lguest *lg, unsigned long addr, u32 val);
103void lgread(struct lguest *lg, void *buf, unsigned long addr, unsigned len);
104void lgwrite(struct lguest *lg, unsigned long, const void *buf, unsigned len);
105int lguest_address_ok(const struct lguest *lg, 101int lguest_address_ok(const struct lguest *lg,
106 unsigned long addr, unsigned long len); 102 unsigned long addr, unsigned long len);
103void __lgread(struct lguest *, void *, unsigned long, unsigned);
104void __lgwrite(struct lguest *, unsigned long, const void *, unsigned);
105
106/*L:306 Using memory-copy operations like that is usually inconvient, so we
107 * have the following helper macros which read and write a specific type (often
108 * an unsigned long).
109 *
110 * This reads into a variable of the given type then returns that. */
111#define lgread(lg, addr, type) \
112 ({ type _v; __lgread((lg), &_v, (addr), sizeof(_v)); _v; })
113
114/* This checks that the variable is of the given type, then writes it out. */
115#define lgwrite(lg, addr, type, val) \
116 do { \
117 typecheck(type, val); \
118 __lgwrite((lg), (addr), &(val), sizeof(val)); \
119 } while(0)
120/* (end of memory access helper routines) :*/
121
107int run_guest(struct lguest *lg, unsigned long __user *user); 122int run_guest(struct lguest *lg, unsigned long __user *user);
108 123
109/* Helper macros to obtain the first 12 or the last 20 bits, this is only the 124/* Helper macros to obtain the first 12 or the last 20 bits, this is only the