* [Qemu-devel] [PATCH 0/5] linux-user for-usptream patches
@ 2010-01-26 15:59 Riku Voipio
2010-01-26 16:00 ` [Qemu-devel] [PATCH 1/5] linux-user: adapt uname machine to emulated CPU Riku Voipio
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Riku Voipio @ 2010-01-26 15:59 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio
From: Riku Voipio <riku.voipio@nokia.com>
Some fixes to avoid hanging, make arm uname match selected
cpu, and fixes to cp15.c13 registers for linux-user tls register
access.
Loïc Minier (1):
linux-user: adapt uname machine to emulated CPU
Riku Voipio (4):
fix locking error with current_tb
linux-user: remove signal handler before calling abort()
linux-user: Add access to TLS registers
target-arm: Thread ID Registers are ARMv6K +
Makefile.target | 2 +-
exec.c | 13 +++++++-
linux-user/cpu-uname.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
linux-user/cpu-uname.h | 1 +
linux-user/syscall.c | 3 +-
target-arm/helper.c | 39 +++++++++++++++++++++++++-
6 files changed, 125 insertions(+), 5 deletions(-)
create mode 100644 linux-user/cpu-uname.c
create mode 100644 linux-user/cpu-uname.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 1/5] linux-user: adapt uname machine to emulated CPU
2010-01-26 15:59 [Qemu-devel] [PATCH 0/5] linux-user for-usptream patches Riku Voipio
@ 2010-01-26 16:00 ` Riku Voipio
2010-01-26 16:00 ` [Qemu-devel] [PATCH 2/5] fix locking error with current_tb Riku Voipio
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Riku Voipio @ 2010-01-26 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: Loïc Minier
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 5219 bytes --]
From: Loïc Minier <lool@dooz.org>
This patch for linux-user adapts the output of the emulated uname()
syscall to match the configured CPU. Tested with x86, x86-64 and arm
emulation.
Signed-off-by: Loïc Minier <lool@dooz.org>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
---
Makefile.target | 2 +-
linux-user/cpu-uname.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
linux-user/cpu-uname.h | 1 +
linux-user/syscall.c | 3 +-
4 files changed, 76 insertions(+), 2 deletions(-)
create mode 100644 linux-user/cpu-uname.c
create mode 100644 linux-user/cpu-uname.h
diff --git a/Makefile.target b/Makefile.target
index 5c0ef1f..9dfc4c2 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -95,7 +95,7 @@ $(call set-vpath, $(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR
QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
obj-y = main.o syscall.o strace.o mmap.o signal.o thunk.o \
- elfload.o linuxload.o uaccess.o gdbstub.o
+ elfload.o linuxload.o uaccess.o gdbstub.o cpu-uname.o
obj-$(TARGET_HAS_BFLT) += flatload.o
obj-$(TARGET_HAS_ELFLOAD32) += elfload32.o
diff --git a/linux-user/cpu-uname.c b/linux-user/cpu-uname.c
new file mode 100644
index 0000000..23afede
--- /dev/null
+++ b/linux-user/cpu-uname.c
@@ -0,0 +1,72 @@
+/*
+ * cpu to uname machine name map
+ *
+ * Copyright (c) 2009 Loïc Minier
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+
+#include "qemu.h"
+//#include "qemu-common.h"
+#include "cpu-uname.h"
+
+/* return highest utsname machine name for emulated instruction set
+ *
+ * NB: the default emulated CPU ("any") might not match any existing CPU, e.g.
+ * on ARM it has all features turned on, so there is no perfect arch string to
+ * return here */
+const char *cpu_to_uname_machine(void *cpu_env)
+{
+#ifdef TARGET_ARM
+ /* utsname machine name on linux arm is CPU arch name + endianness, e.g.
+ * armv7l; to get a list of CPU arch names from the linux source, use:
+ * grep arch_name: -A1 linux/arch/arm/mm/proc-*.S
+ * see arch/arm/kernel/setup.c: setup_processor()
+ *
+ * to test by CPU id, compare cpu_env->cp15.c0_cpuid to ARM_CPUID_*
+ * defines and to test by CPU feature, use arm_feature(cpu_env,
+ * ARM_FEATURE_*) */
+
+ /* in theory, endianness is configurable on some ARM CPUs, but this isn't
+ * used in user mode emulation */
+#ifdef TARGET_WORDS_BIGENDIAN
+#define utsname_suffix "b"
+#else
+#define utsname_suffix "l"
+#endif
+ if (arm_feature(cpu_env, ARM_FEATURE_V7))
+ return "armv7" utsname_suffix;
+ if (arm_feature(cpu_env, ARM_FEATURE_V6))
+ return "armv6" utsname_suffix;
+ /* earliest emulated CPU is ARMv5TE; qemu can emulate the 1026, but not its
+ * Jazelle support */
+ return "armv5te" utsname_suffix;
+#elif defined(TARGET_X86_64)
+ return "x86-64";
+#elif defined(TARGET_I386)
+ /* see arch/x86/kernel/cpu/bugs.c: check_bugs(), 386, 486, 586, 686 */
+ uint32_t cpuid_version = ((CPUX86State *)cpu_env)->cpuid_version;
+ int family = ((cpuid_version >> 8) & 0x0f) + ((cpuid_version >> 20) & 0xff);
+ if (family == 4)
+ return "i486";
+ if (family == 5)
+ return "i586";
+ return "i686";
+#else
+ /* default is #define-d in each arch/ subdir */
+ return UNAME_MACHINE;
+#endif
+}
diff --git a/linux-user/cpu-uname.h b/linux-user/cpu-uname.h
new file mode 100644
index 0000000..32492de
--- /dev/null
+++ b/linux-user/cpu-uname.h
@@ -0,0 +1 @@
+const char *cpu_to_uname_machine(void *cpu_env);
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f2dd39e..9fb493f 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -82,6 +82,7 @@
#include <linux/fb.h>
#include <linux/vt.h>
#include "linux_loop.h"
+#include "cpu-uname.h"
#include "qemu.h"
#include "qemu-common.h"
@@ -5739,7 +5740,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
if (!is_error(ret)) {
/* Overrite the native machine name with whatever is being
emulated. */
- strcpy (buf->machine, UNAME_MACHINE);
+ strcpy (buf->machine, cpu_to_uname_machine(cpu_env));
/* Allow the user to override the reported release. */
if (qemu_uname_release && *qemu_uname_release)
strcpy (buf->release, qemu_uname_release);
--
1.6.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 2/5] fix locking error with current_tb
2010-01-26 15:59 [Qemu-devel] [PATCH 0/5] linux-user for-usptream patches Riku Voipio
2010-01-26 16:00 ` [Qemu-devel] [PATCH 1/5] linux-user: adapt uname machine to emulated CPU Riku Voipio
@ 2010-01-26 16:00 ` Riku Voipio
2010-01-26 16:00 ` [Qemu-devel] [PATCH 3/5] linux-user: remove signal handler before calling abort() Riku Voipio
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Riku Voipio @ 2010-01-26 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio
From: Riku Voipio <riku.voipio@nokia.com>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
---
exec.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/exec.c b/exec.c
index 1190591..71f655f 100644
--- a/exec.c
+++ b/exec.c
@@ -1537,15 +1537,15 @@ static void cpu_unlink_tb(CPUState *env)
TranslationBlock *tb;
static spinlock_t interrupt_lock = SPIN_LOCK_UNLOCKED;
+ spin_lock(&interrupt_lock);
tb = env->current_tb;
/* if the cpu is currently executing code, we must unlink it and
all the potentially executing TB */
if (tb) {
- spin_lock(&interrupt_lock);
env->current_tb = NULL;
tb_reset_jump_recursive(tb);
- spin_unlock(&interrupt_lock);
}
+ spin_unlock(&interrupt_lock);
}
/* mask must never be zero, except for A20 change call */
--
1.6.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 3/5] linux-user: remove signal handler before calling abort()
2010-01-26 15:59 [Qemu-devel] [PATCH 0/5] linux-user for-usptream patches Riku Voipio
2010-01-26 16:00 ` [Qemu-devel] [PATCH 1/5] linux-user: adapt uname machine to emulated CPU Riku Voipio
2010-01-26 16:00 ` [Qemu-devel] [PATCH 2/5] fix locking error with current_tb Riku Voipio
@ 2010-01-26 16:00 ` Riku Voipio
2010-01-26 16:00 ` [Qemu-devel] [PATCH 4/5] linux-user: Add access to TLS registers Riku Voipio
2010-01-26 16:00 ` [Qemu-devel] [PATCH 5/5] target-arm: Thread ID Registers are ARMv6K + Riku Voipio
4 siblings, 0 replies; 9+ messages in thread
From: Riku Voipio @ 2010-01-26 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio
From: Riku Voipio <riku.voipio@nokia.com>
Qemu may hang in host_signal_handler after qemu has done a
seppuku with cpu_abort(). But at this stage we are not really
interested in target process coredump anymore, so unregister
host_signal_handler to die grafefully.
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
---
exec.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/exec.c b/exec.c
index 71f655f..3145b83 100644
--- a/exec.c
+++ b/exec.c
@@ -40,6 +40,7 @@
#include "kvm.h"
#if defined(CONFIG_USER_ONLY)
#include <qemu.h>
+#include <signal.h>
#endif
//#define DEBUG_TB_INVALIDATE
@@ -1692,6 +1693,14 @@ void cpu_abort(CPUState *env, const char *fmt, ...)
}
va_end(ap2);
va_end(ap);
+#if defined(CONFIG_USER_ONLY)
+ {
+ struct sigaction act;
+ sigfillset(&act.sa_mask);
+ act.sa_handler = SIG_DFL;
+ sigaction(SIGABRT, &act, NULL);
+ }
+#endif
abort();
}
--
1.6.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 4/5] linux-user: Add access to TLS registers
2010-01-26 15:59 [Qemu-devel] [PATCH 0/5] linux-user for-usptream patches Riku Voipio
` (2 preceding siblings ...)
2010-01-26 16:00 ` [Qemu-devel] [PATCH 3/5] linux-user: remove signal handler before calling abort() Riku Voipio
@ 2010-01-26 16:00 ` Riku Voipio
2010-01-26 16:27 ` Laurent Desnogues
2010-01-26 16:00 ` [Qemu-devel] [PATCH 5/5] target-arm: Thread ID Registers are ARMv6K + Riku Voipio
4 siblings, 1 reply; 9+ messages in thread
From: Riku Voipio @ 2010-01-26 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio
From: Riku Voipio <riku.voipio@nokia.com>
If you compile applications with gcc -mtp=cp15, __thread
access's will generate an abort. Implement accessing allowed
cp15.c13 registers on ARMv6K+ in linux-user.
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
---
target-arm/helper.c | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/target-arm/helper.c b/target-arm/helper.c
index b3aec99..68578ce 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -505,13 +505,38 @@ uint32_t HELPER(get_cp)(CPUState *env, uint32_t insn)
void HELPER(set_cp15)(CPUState *env, uint32_t insn, uint32_t val)
{
+ int op2;
+
+ op2 = (insn >> 5) & 7;
+ /* Allow write access to CP15 User RW Thread ID Register */
+ if (arm_feature (env, ARM_FEATURE_V6K) && ((insn >> 16) & 0xf) == 13) {
+ switch (op2) {
+ case 2:
+ env->cp15.c13_tls1 = val;
+ return;
+ }
+ }
cpu_abort(env, "cp15 insn %08x\n", insn);
}
uint32_t HELPER(get_cp15)(CPUState *env, uint32_t insn)
{
+ int op2;
+ /* Allow read access to CP15 User RW and RO Thread ID Registers */
+
+ op2 = (insn >> 5) & 7;
+ if (arm_feature (env, ARM_FEATURE_V6K) && ((insn >> 16) & 0xf) == 13) {
+ switch (op2) {
+ case 2:
+ return env->cp15.c13_tls1;
+ case 3:
+ return env->cp15.c13_tls2;
+ default:
+ goto bad_reg;
+ }
+ }
+bad_reg:
cpu_abort(env, "cp15 insn %08x\n", insn);
- return 0;
}
/* These should probably raise undefined insn exceptions. */
--
1.6.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 5/5] target-arm: Thread ID Registers are ARMv6K +
2010-01-26 15:59 [Qemu-devel] [PATCH 0/5] linux-user for-usptream patches Riku Voipio
` (3 preceding siblings ...)
2010-01-26 16:00 ` [Qemu-devel] [PATCH 4/5] linux-user: Add access to TLS registers Riku Voipio
@ 2010-01-26 16:00 ` Riku Voipio
2010-01-26 16:28 ` Laurent Desnogues
4 siblings, 1 reply; 9+ messages in thread
From: Riku Voipio @ 2010-01-26 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio
From: Riku Voipio <riku.voipio@nokia.com>
Change the system-emulation code also to only support accessing
the cp15.c13 Thread ID registers on ARMv6K and newer.
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
---
target-arm/helper.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 68578ce..1245d9d 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -1517,12 +1517,18 @@ void HELPER(set_cp15)(CPUState *env, uint32_t insn, uint32_t val)
env->cp15.c13_context = val;
break;
case 2:
+ if (!arm_feature(env, ARM_FEATURE_V6K))
+ goto bad_reg;
env->cp15.c13_tls1 = val;
break;
case 3:
+ if (!arm_feature(env, ARM_FEATURE_V6K))
+ goto bad_reg;
env->cp15.c13_tls2 = val;
break;
case 4:
+ if (!arm_feature(env, ARM_FEATURE_V6K))
+ goto bad_reg;
env->cp15.c13_tls3 = val;
break;
default:
@@ -1805,10 +1811,16 @@ uint32_t HELPER(get_cp15)(CPUState *env, uint32_t insn)
case 1:
return env->cp15.c13_context;
case 2:
+ if (!arm_feature(env, ARM_FEATURE_V6K))
+ goto bad_reg;
return env->cp15.c13_tls1;
case 3:
+ if (!arm_feature(env, ARM_FEATURE_V6K))
+ goto bad_reg;
return env->cp15.c13_tls2;
case 4:
+ if (!arm_feature(env, ARM_FEATURE_V6K))
+ goto bad_reg;
return env->cp15.c13_tls3;
default:
goto bad_reg;
--
1.6.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 4/5] linux-user: Add access to TLS registers
2010-01-26 16:00 ` [Qemu-devel] [PATCH 4/5] linux-user: Add access to TLS registers Riku Voipio
@ 2010-01-26 16:27 ` Laurent Desnogues
2010-01-26 20:00 ` Riku Voipio
0 siblings, 1 reply; 9+ messages in thread
From: Laurent Desnogues @ 2010-01-26 16:27 UTC (permalink / raw)
To: Riku Voipio; +Cc: Riku Voipio, qemu-devel
On Tue, Jan 26, 2010 at 5:00 PM, Riku Voipio <riku.voipio@iki.fi> wrote:
> From: Riku Voipio <riku.voipio@nokia.com>
>
> If you compile applications with gcc -mtp=cp15, __thread
> access's will generate an abort. Implement accessing allowed
> cp15.c13 registers on ARMv6K+ in linux-user.
>
> Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
> ---
> target-arm/helper.c | 27 ++++++++++++++++++++++++++-
> 1 files changed, 26 insertions(+), 1 deletions(-)
>
> diff --git a/target-arm/helper.c b/target-arm/helper.c
> index b3aec99..68578ce 100644
> --- a/target-arm/helper.c
> +++ b/target-arm/helper.c
> @@ -505,13 +505,38 @@ uint32_t HELPER(get_cp)(CPUState *env, uint32_t insn)
>
> void HELPER(set_cp15)(CPUState *env, uint32_t insn, uint32_t val)
> {
> + int op2;
> +
> + op2 = (insn >> 5) & 7;
> + /* Allow write access to CP15 User RW Thread ID Register */
> + if (arm_feature (env, ARM_FEATURE_V6K) && ((insn >> 16) & 0xf) == 13) {
> + switch (op2) {
> + case 2:
> + env->cp15.c13_tls1 = val;
> + return;
> + }
> + }
> cpu_abort(env, "cp15 insn %08x\n", insn);
> }
>
> uint32_t HELPER(get_cp15)(CPUState *env, uint32_t insn)
> {
> + int op2;
> + /* Allow read access to CP15 User RW and RO Thread ID Registers */
> +
> + op2 = (insn >> 5) & 7;
> + if (arm_feature (env, ARM_FEATURE_V6K) && ((insn >> 16) & 0xf) == 13) {
> + switch (op2) {
> + case 2:
> + return env->cp15.c13_tls1;
> + case 3:
> + return env->cp15.c13_tls2;
> + default:
> + goto bad_reg;
> + }
> + }
> +bad_reg:
> cpu_abort(env, "cp15 insn %08x\n", insn);
> - return 0;
> }
>
> /* These should probably raise undefined insn exceptions. */
Most of the checks you do here could be done in translate.c.
Wouldn't it be better to do them there?
Laurent
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 5/5] target-arm: Thread ID Registers are ARMv6K +
2010-01-26 16:00 ` [Qemu-devel] [PATCH 5/5] target-arm: Thread ID Registers are ARMv6K + Riku Voipio
@ 2010-01-26 16:28 ` Laurent Desnogues
0 siblings, 0 replies; 9+ messages in thread
From: Laurent Desnogues @ 2010-01-26 16:28 UTC (permalink / raw)
To: Riku Voipio; +Cc: Riku Voipio, qemu-devel
On Tue, Jan 26, 2010 at 5:00 PM, Riku Voipio <riku.voipio@iki.fi> wrote:
> From: Riku Voipio <riku.voipio@nokia.com>
>
> Change the system-emulation code also to only support accessing
> the cp15.c13 Thread ID registers on ARMv6K and newer.
>
> Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
> ---
> target-arm/helper.c | 12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/target-arm/helper.c b/target-arm/helper.c
> index 68578ce..1245d9d 100644
> --- a/target-arm/helper.c
> +++ b/target-arm/helper.c
> @@ -1517,12 +1517,18 @@ void HELPER(set_cp15)(CPUState *env, uint32_t insn, uint32_t val)
> env->cp15.c13_context = val;
> break;
> case 2:
> + if (!arm_feature(env, ARM_FEATURE_V6K))
> + goto bad_reg;
> env->cp15.c13_tls1 = val;
> break;
> case 3:
> + if (!arm_feature(env, ARM_FEATURE_V6K))
> + goto bad_reg;
> env->cp15.c13_tls2 = val;
> break;
> case 4:
> + if (!arm_feature(env, ARM_FEATURE_V6K))
> + goto bad_reg;
> env->cp15.c13_tls3 = val;
> break;
> default:
> @@ -1805,10 +1811,16 @@ uint32_t HELPER(get_cp15)(CPUState *env, uint32_t insn)
> case 1:
> return env->cp15.c13_context;
> case 2:
> + if (!arm_feature(env, ARM_FEATURE_V6K))
> + goto bad_reg;
> return env->cp15.c13_tls1;
> case 3:
> + if (!arm_feature(env, ARM_FEATURE_V6K))
> + goto bad_reg;
> return env->cp15.c13_tls2;
> case 4:
> + if (!arm_feature(env, ARM_FEATURE_V6K))
> + goto bad_reg;
> return env->cp15.c13_tls3;
> default:
> goto bad_reg;
Same question as for user mode :-)
Laurent
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 4/5] linux-user: Add access to TLS registers
2010-01-26 16:27 ` Laurent Desnogues
@ 2010-01-26 20:00 ` Riku Voipio
0 siblings, 0 replies; 9+ messages in thread
From: Riku Voipio @ 2010-01-26 20:00 UTC (permalink / raw)
To: Laurent Desnogues; +Cc: qemu-devel
On Tue, Jan 26, 2010 at 05:27:27PM +0100, Laurent Desnogues wrote:
> On Tue, Jan 26, 2010 at 5:00 PM, Riku Voipio <riku.voipio@iki.fi> wrote:
> > From: Riku Voipio <riku.voipio@nokia.com>
> >
> > If you compile applications with gcc -mtp=cp15, __thread
> > access's will generate an abort. Implement accessing allowed
> > cp15.c13 registers on ARMv6K+ in linux-user.
> >
> > Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
> > ---
> > target-arm/helper.c | 27 ++++++++++++++++++++++++++-
> > 1 files changed, 26 insertions(+), 1 deletions(-)
> >
> > diff --git a/target-arm/helper.c b/target-arm/helper.c
> > index b3aec99..68578ce 100644
> > --- a/target-arm/helper.c
> > +++ b/target-arm/helper.c
> > @@ -505,13 +505,38 @@ uint32_t HELPER(get_cp)(CPUState *env, uint32_t insn)
> >
> > void HELPER(set_cp15)(CPUState *env, uint32_t insn, uint32_t val)
> > {
> > + int op2;
> > +
> > + op2 = (insn >> 5) & 7;
> > + /* Allow write access to CP15 User RW Thread ID Register */
> > + if (arm_feature (env, ARM_FEATURE_V6K) && ((insn >> 16) & 0xf) == 13) {
> > + switch (op2) {
> > + case 2:
> > + env->cp15.c13_tls1 = val;
> > + return;
> > + }
> > + }
> > cpu_abort(env, "cp15 insn %08x\n", insn);
> > }
> >
> > uint32_t HELPER(get_cp15)(CPUState *env, uint32_t insn)
> > {
> > + int op2;
> > + /* Allow read access to CP15 User RW and RO Thread ID Registers */
> > +
> > + op2 = (insn >> 5) & 7;
> > + if (arm_feature (env, ARM_FEATURE_V6K) && ((insn >> 16) & 0xf) == 13) {
> > + switch (op2) {
> > + case 2:
> > + return env->cp15.c13_tls1;
> > + case 3:
> > + return env->cp15.c13_tls2;
> > + default:
> > + goto bad_reg;
> > + }
> > + }
> > +bad_reg:
> > cpu_abort(env, "cp15 insn %08x\n", insn);
> > - return 0;
> > }
> >
> > /* These should probably raise undefined insn exceptions. */
> Most of the checks you do here could be done in translate.c.
> Wouldn't it be better to do them there?
Indeed, thus we could even avoid the helper completly. I just followed the the
cp15 implementation of system-qemu here.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-01-26 20:00 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-26 15:59 [Qemu-devel] [PATCH 0/5] linux-user for-usptream patches Riku Voipio
2010-01-26 16:00 ` [Qemu-devel] [PATCH 1/5] linux-user: adapt uname machine to emulated CPU Riku Voipio
2010-01-26 16:00 ` [Qemu-devel] [PATCH 2/5] fix locking error with current_tb Riku Voipio
2010-01-26 16:00 ` [Qemu-devel] [PATCH 3/5] linux-user: remove signal handler before calling abort() Riku Voipio
2010-01-26 16:00 ` [Qemu-devel] [PATCH 4/5] linux-user: Add access to TLS registers Riku Voipio
2010-01-26 16:27 ` Laurent Desnogues
2010-01-26 20:00 ` Riku Voipio
2010-01-26 16:00 ` [Qemu-devel] [PATCH 5/5] target-arm: Thread ID Registers are ARMv6K + Riku Voipio
2010-01-26 16:28 ` Laurent Desnogues
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).