From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: [patch 1/3] kvm test: protect fwfcg accesses with spinlock Date: Mon, 05 Jul 2010 15:16:09 -0300 Message-ID: <20100705181654.614344513@amt.cnet> References: <20100705181608.720014170@amt.cnet> Cc: kvm@vger.kernel.org, Marcelo Tosatti To: avi@redhat.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:10576 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756437Ab0GESSL (ORCPT ); Mon, 5 Jul 2010 14:18:11 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o65IIB0t021107 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 5 Jul 2010 14:18:11 -0400 Content-Disposition: inline; filename=3-8-test-protect-fwcfg-accesses-with-lock.patch Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Marcelo Tosatti Index: qemu-kvm/kvm/user/test/lib/x86/fwcfg.c =================================================================== --- qemu-kvm.orig/kvm/test/lib/x86/fwcfg.c +++ qemu-kvm/kvm/test/lib/x86/fwcfg.c @@ -1,4 +1,7 @@ #include "fwcfg.h" +#include "smp.h" + +static struct spinlock lock; uint64_t fwcfg_get_u(uint16_t index, int bytes) { @@ -6,11 +9,13 @@ uint64_t fwcfg_get_u(uint16_t index, int uint8_t b; int i; + spin_lock(&lock); asm volatile ("out %0, %1" : : "a"(index), "d"((uint16_t)BIOS_CFG_IOPORT)); for (i = 0; i < bytes; ++i) { asm volatile ("in %1, %0" : "=a"(b) : "d"((uint16_t)(BIOS_CFG_IOPORT + 1))); r |= (uint64_t)b << (i * 8); } + spin_unlock(&lock); return r; }