[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Apply proper locking in xenlinux mtrr interface functions.
# HG changeset patch # User kaf24@xxxxxxxxxxxxxxxxxxxx # Node ID e0d32d7cb5da9f898562dd4eea3fd2661e2812c6 # Parent c176d2e45117afdba901affcf0d73b2e2acff9b7 Apply proper locking in xenlinux mtrr interface functions. From: Jan Beulich Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> diff -r c176d2e45117 -r e0d32d7cb5da linux-2.6-xen-sparse/arch/i386/kernel/cpu/mtrr/main-xen.c --- a/linux-2.6-xen-sparse/arch/i386/kernel/cpu/mtrr/main-xen.c Thu Mar 9 14:57:32 2006 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/cpu/mtrr/main-xen.c Thu Mar 9 14:59:53 2006 @@ -7,6 +7,8 @@ #include <asm/mtrr.h> #include "mtrr.h" + +static DECLARE_MUTEX(mtrr_sem); void generic_get_mtrr(unsigned int reg, unsigned long *base, unsigned int *size, mtrr_type * type) @@ -63,18 +65,23 @@ int error; dom0_op_t op; + down(&mtrr_sem); + op.cmd = DOM0_ADD_MEMTYPE; op.u.add_memtype.mfn = base; op.u.add_memtype.nr_mfns = size; op.u.add_memtype.type = type; error = HYPERVISOR_dom0_op(&op); if (error) { + up(&mtrr_sem); BUG_ON(error > 0); return error; } if (increment) ++usage_table[op.u.add_memtype.reg]; + + up(&mtrr_sem); return op.u.add_memtype.reg; } @@ -104,17 +111,18 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) { - int i, max; + unsigned i; mtrr_type ltype; unsigned long lbase; unsigned int lsize; int error = -EINVAL; dom0_op_t op; - max = num_var_ranges; + down(&mtrr_sem); + if (reg < 0) { /* Search for existing MTRR */ - for (i = 0; i < max; ++i) { + for (i = 0; i < num_var_ranges; ++i) { mtrr_if->get(i, &lbase, &lsize, <ype); if (lbase == base && lsize == size) { reg = i; @@ -143,6 +151,7 @@ } error = reg; out: + up(&mtrr_sem); return error; } _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |