WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Apply proper locking in xenlinux mtrr interface function

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Apply proper locking in xenlinux mtrr interface functions.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 09 Mar 2006 16:28:09 +0000
Delivery-date: Thu, 09 Mar 2006 16:29:12 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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, &ltype);
                        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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Apply proper locking in xenlinux mtrr interface functions., Xen patchbot -unstable <=