From: Stuart Brady <sdbrady@ntlworld.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Use spinlock_t for interrupt_lock
Date: Thu, 20 Mar 2008 22:44:19 +0000 [thread overview]
Message-ID: <20080320224419.GA22571@miranda.arrow> (raw)
Hi,
The included patch changes cpu_interrupt()'s interrupt_lock variable to
a spinlock_t instead of an int, and calls a function to reset the lock
instead of directly setting it to zero. This is needed for HPPA host
support, for which I will submit some preliminary patches, soon.
HPPA does not have a test-and-set instruction -- instead, it has a
load-and-clear instruction (LDCW), so zero must be used for the locked
state instead of the unlocked state. The LDCW instruction requires the
lock variable to be aligned to a 16-byte boundary -- the simplest way to
satisfy this requirement is to use an array of four four-byte words, and
to handle the alignment in testandset() itself.
I would have preferred to use spin_trylock() and spin_unlock() in
cpu_interrupt(), but it seems that spin_* are no-ops when building a
softmmu target. I can submit patches to rename spin_* to spin_user_*,
if that would be preferred.
Thanks,
--
Stuart Brady
diff -urpN qemu-orig/exec-all.h qemu-new/exec-all.h
--- qemu-orig/exec-all.h 2008-03-20 21:46:27.000000000 +0000
+++ qemu-new/exec-all.h 2008-03-20 19:56:03.000000000 +0000
@@ -432,6 +432,11 @@ typedef int spinlock_t;
#define SPIN_LOCK_UNLOCKED 0
+static inline void resetlock(spinlock_t *lock)
+{
+ *lock = SPIN_LOCK_UNLOCKED;
+}
+
#if defined(CONFIG_USER_ONLY)
static inline void spin_lock(spinlock_t *lock)
{
@@ -440,7 +445,7 @@ static inline void spin_lock(spinlock_t
static inline void spin_unlock(spinlock_t *lock)
{
- *lock = 0;
+ resetlock(lock);
}
static inline int spin_trylock(spinlock_t *lock)
diff -urpN qemu-orig/exec.c qemu-new/exec.c
--- qemu-orig/exec.c 2008-03-20 21:46:27.000000000 +0000
+++ qemu-new/exec.c 2008-03-20 21:47:24.000000000 +0000
@@ -1215,7 +1215,7 @@ void cpu_set_log_filename(const char *fi
void cpu_interrupt(CPUState *env, int mask)
{
TranslationBlock *tb;
- static int interrupt_lock;
+ static spinlock_t interrupt_lock = SPIN_LOCK_UNLOCKED;
env->interrupt_request |= mask;
/* if the cpu is currently executing code, we must unlink it and
@@ -1224,7 +1224,7 @@ void cpu_interrupt(CPUState *env, int ma
if (tb && !testandset(&interrupt_lock)) {
env->current_tb = NULL;
tb_reset_jump_recursive(tb);
- interrupt_lock = 0;
+ resetlock(&interrupt_lock);
}
}
reply other threads:[~2008-03-20 22:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080320224419.GA22571@miranda.arrow \
--to=sdbrady@ntlworld.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.