All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Andreas Färber" <afaerber@suse.de>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Riku Voipio" <riku.voipio@iki.fi>,
	"Laurent Vivier" <laurent@vivier.eu>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>
Subject: [Qemu-devel] [PATCH 05/28] sparc: embed sparc_def_t into CPUSPARCState
Date: Fri, 14 Jul 2017 15:51:56 +0200	[thread overview]
Message-ID: <1500040339-119465-6-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1500040339-119465-1-git-send-email-imammedo@redhat.com>

Make CPUSPARCState::def embedded so it would be allocated as part
of cpu instance and we won't have to worry about cleaning def pointer
up mannualy on cpu destruction.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
Embedded CPUSPARCState::def also needed for follow up patch
to use its fields with static qdev properties.

CC: Riku Voipio <riku.voipio@iki.fi>
CC: Laurent Vivier <laurent@vivier.eu>
CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
CC: Artyom Tarasenko <atar4qemu@gmail.com>
---
 linux-user/sparc/target_syscall.h |  2 +-
 target/sparc/cpu.h                |  8 ++++----
 target/sparc/cpu.c                | 39 ++++++++++++++++-----------------------
 target/sparc/int32_helper.c       |  2 +-
 target/sparc/int64_helper.c       |  2 +-
 target/sparc/ldst_helper.c        | 14 +++++++-------
 target/sparc/mmu_helper.c         |  2 +-
 target/sparc/translate.c          |  2 +-
 target/sparc/win_helper.c         |  4 ++--
 9 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/linux-user/sparc/target_syscall.h b/linux-user/sparc/target_syscall.h
index f97aa6b..5f09abf 100644
--- a/linux-user/sparc/target_syscall.h
+++ b/linux-user/sparc/target_syscall.h
@@ -31,7 +31,7 @@ struct target_pt_regs {
 
 static inline abi_ulong target_shmlba(CPUSPARCState *env)
 {
-    if (!(env->def->features & CPU_FEATURE_FLUSH)) {
+    if (!(env->def.features & CPU_FEATURE_FLUSH)) {
         return 64 * 1024;
     } else {
         return 256 * 1024;
diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index 95a36a4..0e41916 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -529,7 +529,7 @@ struct CPUSPARCState {
 #define SOFTINT_INTRMASK (0xFFFE)
 #define SOFTINT_REG_MASK (SOFTINT_STIMER|SOFTINT_INTRMASK|SOFTINT_TIMER)
 #endif
-    sparc_def_t *def;
+    sparc_def_t def;
 
     void *irq_manager;
     void (*qemu_irq_ack)(CPUSPARCState *env, void *irq_manager, int intno);
@@ -679,7 +679,7 @@ int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);
 #if defined (TARGET_SPARC64)
 static inline int cpu_has_hypervisor(CPUSPARCState *env1)
 {
-    return env1->def->features & CPU_FEATURE_HYPV;
+    return env1->def.features & CPU_FEATURE_HYPV;
 }
 
 static inline int cpu_hypervisor_mode(CPUSPARCState *env1)
@@ -788,14 +788,14 @@ static inline void cpu_get_tb_cpu_state(CPUSPARCState *env, target_ulong *pc,
     if (env->pstate & PS_AM) {
         flags |= TB_FLAG_AM_ENABLED;
     }
-    if ((env->def->features & CPU_FEATURE_FLOAT)
+    if ((env->def.features & CPU_FEATURE_FLOAT)
         && (env->pstate & PS_PEF)
         && (env->fprs & FPRS_FEF)) {
         flags |= TB_FLAG_FPU_ENABLED;
     }
     flags |= env->asi << TB_FLAG_ASI_SHIFT;
 #else
-    if ((env->def->features & CPU_FEATURE_FLOAT) && env->psref) {
+    if ((env->def.features & CPU_FEATURE_FLOAT) && env->psref) {
         flags |= TB_FLAG_FPU_ENABLED;
     }
 #endif
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index f8cf751..110a5cd 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -66,7 +66,7 @@ static void sparc_cpu_reset(CPUState *s)
     env->lsu = 0;
 #else
     env->mmuregs[0] &= ~(MMU_E | MMU_NF);
-    env->mmuregs[0] |= env->def->mmu_bm;
+    env->mmuregs[0] |= env->def.mmu_bm;
 #endif
     env->pc = 0;
     env->npc = env->pc + 4;
@@ -120,18 +120,18 @@ static int cpu_sparc_register(SPARCCPU *cpu, const char *cpu_model)
         return -1;
     }
 
-    env->version = env->def->iu_version;
-    env->fsr = env->def->fpu_version;
-    env->nwindows = env->def->nwindows;
+    env->version = env->def.iu_version;
+    env->fsr = env->def.fpu_version;
+    env->nwindows = env->def.nwindows;
 #if !defined(TARGET_SPARC64)
-    env->mmuregs[0] |= env->def->mmu_version;
+    env->mmuregs[0] |= env->def.mmu_version;
     cpu_sparc_set_id(env, 0);
-    env->mxccregs[7] |= env->def->mxcc_version;
+    env->mxccregs[7] |= env->def.mxcc_version;
 #else
-    env->mmu_version = env->def->mmu_version;
-    env->maxtl = env->def->maxtl;
-    env->version |= env->def->maxtl << 8;
-    env->version |= env->def->nwindows - 1;
+    env->mmu_version = env->def.mmu_version;
+    env->maxtl = env->def.maxtl;
+    env->version |= env->def.maxtl << 8;
+    env->version |= env->def.nwindows - 1;
 #endif
     return 0;
 }
@@ -558,7 +558,7 @@ static void sparc_cpu_parse_features(CPUState *cs, char *features,
                                      Error **errp)
 {
     SPARCCPU *cpu = SPARC_CPU(cs);
-    sparc_def_t *cpu_def = cpu->env.def;
+    sparc_def_t *cpu_def = &cpu->env.def;
     char *featurestr;
     uint32_t plus_features = 0;
     uint32_t minus_features = 0;
@@ -819,8 +819,8 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
     SPARCCPU *cpu = SPARC_CPU(dev);
     CPUSPARCState *env = &cpu->env;
 
-    if ((env->def->features & CPU_FEATURE_FLOAT)) {
-        env->def->features |= CPU_FEATURE_FLOAT128;
+    if ((env->def.features & CPU_FEATURE_FLOAT)) {
+        env->def.features |= CPU_FEATURE_FLOAT128;
     }
 #endif
 
@@ -848,15 +848,9 @@ static void sparc_cpu_initfn(Object *obj)
         gen_intermediate_code_init(env);
     }
 
-    env->def = g_memdup(scc->cpu_def, sizeof(*scc->cpu_def));
-}
-
-static void sparc_cpu_uninitfn(Object *obj)
-{
-    SPARCCPU *cpu = SPARC_CPU(obj);
-    CPUSPARCState *env = &cpu->env;
-
-    g_free(env->def);
+    if (scc->cpu_def) {
+        env->def = *scc->cpu_def;
+    }
 }
 
 static void sparc_cpu_class_init(ObjectClass *oc, void *data)
@@ -905,7 +899,6 @@ static const TypeInfo sparc_cpu_type_info = {
     .parent = TYPE_CPU,
     .instance_size = sizeof(SPARCCPU),
     .instance_init = sparc_cpu_initfn,
-    .instance_finalize = sparc_cpu_uninitfn,
     .abstract = false,
     .class_size = sizeof(SPARCCPUClass),
     .class_init = sparc_cpu_class_init,
diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c
index eec9a4d..c772492 100644
--- a/target/sparc/int32_helper.c
+++ b/target/sparc/int32_helper.c
@@ -108,7 +108,7 @@ void sparc_cpu_do_interrupt(CPUState *cs)
 #if !defined(CONFIG_USER_ONLY)
     if (env->psret == 0) {
         if (cs->exception_index == 0x80 &&
-            env->def->features & CPU_FEATURE_TA0_SHUTDOWN) {
+            env->def.features & CPU_FEATURE_TA0_SHUTDOWN) {
             qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
         } else {
             cpu_abort(cs, "Trap 0x%02x while interrupts disabled, Error state",
diff --git a/target/sparc/int64_helper.c b/target/sparc/int64_helper.c
index f942973..f3e7f32 100644
--- a/target/sparc/int64_helper.c
+++ b/target/sparc/int64_helper.c
@@ -147,7 +147,7 @@ void sparc_cpu_do_interrupt(CPUState *cs)
         }
     }
 
-    if (env->def->features & CPU_FEATURE_GL) {
+    if (env->def.features & CPU_FEATURE_GL) {
         tsptr->tstate |= (env->gl & 7ULL) << 40;
         cpu_gl_switch_gregs(env, env->gl + 1);
         env->gl++;
diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
index 57968d9..fb489cb 100644
--- a/target/sparc/ldst_helper.c
+++ b/target/sparc/ldst_helper.c
@@ -513,7 +513,7 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr,
         case 0x00:          /* Leon3 Cache Control */
         case 0x08:          /* Leon3 Instruction Cache config */
         case 0x0C:          /* Leon3 Date Cache config */
-            if (env->def->features & CPU_FEATURE_CACHE_CTRL) {
+            if (env->def.features & CPU_FEATURE_CACHE_CTRL) {
                 ret = leon3_cache_control_ld(env, addr, size);
             }
             break;
@@ -736,7 +736,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,
         case 0x00:          /* Leon3 Cache Control */
         case 0x08:          /* Leon3 Instruction Cache config */
         case 0x0C:          /* Leon3 Date Cache config */
-            if (env->def->features & CPU_FEATURE_CACHE_CTRL) {
+            if (env->def.features & CPU_FEATURE_CACHE_CTRL) {
                 leon3_cache_control_st(env, addr, val, size);
             }
             break;
@@ -904,15 +904,15 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,
                 /* Mappings generated during no-fault mode
                    are invalid in normal mode.  */
                 if ((oldreg ^ env->mmuregs[reg])
-                    & (MMU_NF | env->def->mmu_bm)) {
+                    & (MMU_NF | env->def.mmu_bm)) {
                     tlb_flush(CPU(cpu));
                 }
                 break;
             case 1: /* Context Table Pointer Register */
-                env->mmuregs[reg] = val & env->def->mmu_ctpr_mask;
+                env->mmuregs[reg] = val & env->def.mmu_ctpr_mask;
                 break;
             case 2: /* Context Register */
-                env->mmuregs[reg] = val & env->def->mmu_cxr_mask;
+                env->mmuregs[reg] = val & env->def.mmu_cxr_mask;
                 if (oldreg != env->mmuregs[reg]) {
                     /* we flush when the MMU context changes because
                        QEMU has no MMU context support */
@@ -923,11 +923,11 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,
             case 4: /* Synchronous Fault Address Register */
                 break;
             case 0x10: /* TLB Replacement Control Register */
-                env->mmuregs[reg] = val & env->def->mmu_trcr_mask;
+                env->mmuregs[reg] = val & env->def.mmu_trcr_mask;
                 break;
             case 0x13: /* Synchronous Fault Status Register with Read
                           and Clear */
-                env->mmuregs[3] = val & env->def->mmu_sfsr_mask;
+                env->mmuregs[3] = val & env->def.mmu_sfsr_mask;
                 break;
             case 0x14: /* Synchronous Fault Address Register */
                 env->mmuregs[4] = val;
diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c
index 8b4664d..126ea5e 100644
--- a/target/sparc/mmu_helper.c
+++ b/target/sparc/mmu_helper.c
@@ -95,7 +95,7 @@ static int get_physical_address(CPUSPARCState *env, hwaddr *physical,
     if (mmu_idx == MMU_PHYS_IDX) {
         *page_size = TARGET_PAGE_SIZE;
         /* Boot mode: instruction fetches are taken from PROM */
-        if (rw == 2 && (env->mmuregs[0] & env->def->mmu_bm)) {
+        if (rw == 2 && (env->mmuregs[0] & env->def.mmu_bm)) {
             *physical = env->prom_addr | (address & 0x7ffffULL);
             *prot = PAGE_READ | PAGE_EXEC;
             return 0;
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index aa6734d..5641931 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -5765,7 +5765,7 @@ void gen_intermediate_code(CPUSPARCState * env, TranslationBlock * tb)
     dc->npc = (target_ulong) tb->cs_base;
     dc->cc_op = CC_OP_DYNAMIC;
     dc->mem_idx = tb->flags & TB_FLAG_MMU_MASK;
-    dc->def = env->def;
+    dc->def = &env->def;
     dc->fpu_enabled = tb_fpu_enabled(tb->flags);
     dc->address_mask_32bit = tb_am_enabled(tb->flags);
     dc->singlestep = (cs->singlestep_enabled || singlestep);
diff --git a/target/sparc/win_helper.c b/target/sparc/win_helper.c
index 154279e..8290a21 100644
--- a/target/sparc/win_helper.c
+++ b/target/sparc/win_helper.c
@@ -295,7 +295,7 @@ void helper_wrcwp(CPUSPARCState *env, target_ulong new_cwp)
 
 static inline uint64_t *get_gregset(CPUSPARCState *env, uint32_t pstate)
 {
-    if (env->def->features & CPU_FEATURE_GL) {
+    if (env->def.features & CPU_FEATURE_GL) {
         return env->glregs + (env->gl & 7) * 8;
     }
 
@@ -343,7 +343,7 @@ void cpu_change_pstate(CPUSPARCState *env, uint32_t new_pstate)
     uint32_t pstate_regs, new_pstate_regs;
     uint64_t *src, *dst;
 
-    if (env->def->features & CPU_FEATURE_GL) {
+    if (env->def.features & CPU_FEATURE_GL) {
         /* PS_AG, IG and MG are not implemented in this case */
         new_pstate &= ~(PS_AG | PS_IG | PS_MG);
         env->pstate = new_pstate;
-- 
2.7.4

  parent reply	other threads:[~2017-07-14 13:52 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-14 13:51 [Qemu-devel] [PATCH 00/28] complete cpu QOMification and remove cpu_FOO_init() helpers Igor Mammedov
2017-07-14 13:51 ` [Qemu-devel] [PATCH 01/28] mips: cpu: move mmu/fpu/mvp_init to realize time Igor Mammedov
2017-07-15 21:48   ` Philippe Mathieu-Daudé
2017-07-14 13:51 ` [Qemu-devel] [PATCH 02/28] mips: MIPSCPU model subclasses Igor Mammedov
2017-07-15 21:48   ` Philippe Mathieu-Daudé
2017-08-17  3:38     ` Philippe Mathieu-Daudé
2017-08-17 10:53       ` Igor Mammedov
2017-08-17 11:15         ` Philippe Mathieu-Daudé
2017-07-14 13:51 ` [Qemu-devel] [PATCH 03/28] mips: replace cpu_mips_init() with cpu_generic_init() Igor Mammedov
2017-07-15  6:09   ` Hervé Poussineau
2017-07-15 21:48   ` Philippe Mathieu-Daudé
2017-07-14 13:51 ` [Qemu-devel] [PATCH 04/28] sparc: convert cpu models to SPARC cpu subclasses Igor Mammedov
2017-08-14  7:56   ` Igor Mammedov
2017-08-14 16:24     ` Artyom Tarasenko
2017-08-15  7:38       ` Igor Mammedov
2017-08-15 11:27     ` Mark Cave-Ayland
2017-08-17  3:50   ` Philippe Mathieu-Daudé
2017-08-17 14:11     ` Igor Mammedov
2017-07-14 13:51 ` Igor Mammedov [this message]
2017-07-14 13:51 ` [Qemu-devel] [PATCH 06/28] sparc: convert cpu features to qdev properties Igor Mammedov
2017-07-14 13:51 ` [Qemu-devel] [PATCH 07/28] sparc: move adhoc CPUSPARCState initialization to realize time Igor Mammedov
2017-07-14 13:51 ` [Qemu-devel] [PATCH 08/28] x86: extract legacy cpu features format parser Igor Mammedov
2017-08-16 19:32   ` Eduardo Habkost
2017-08-17 14:07     ` [Qemu-devel] [PATCH 1/2] target-i386: cpu: convert plus/minus properties to global properties Igor Mammedov
2017-08-17 14:07       ` [Qemu-devel] [PATCH 2/2] x86: extract legacy cpu features format parser Igor Mammedov
2017-08-18 17:40       ` [Qemu-devel] [PATCH 1/2] target-i386: cpu: convert plus/minus properties to global properties Eduardo Habkost
2017-08-21  8:32         ` Igor Mammedov
2017-08-23 14:24           ` Eduardo Habkost
2017-08-23 15:54             ` Igor Mammedov
2017-08-23 16:52               ` Eduardo Habkost
2017-07-14 13:52 ` [Qemu-devel] [PATCH 09/28] sparc: replace custom cpu feature parsing with cpu_legacy_parse_featurestr() Igor Mammedov
2017-07-14 13:52 ` [Qemu-devel] [PATCH 10/28] sparc: replace cpu_sparc_init() with cpu_generic_init() Igor Mammedov
2017-07-14 13:52 ` [Qemu-devel] [PATCH 11/28] s390x: replace cpu_s390x_init() " Igor Mammedov
2017-07-18 12:30   ` Cornelia Huck
2017-07-18 13:17     ` Igor Mammedov
2017-08-14  8:03       ` Igor Mammedov
2017-08-14  8:53         ` Cornelia Huck
2017-08-14  9:24           ` Igor Mammedov
2017-08-14  9:27             ` Cornelia Huck
2017-07-14 13:52 ` [Qemu-devel] [PATCH 12/28] alpha: replace cpu_alpha_init() " Igor Mammedov
2017-07-15 18:05   ` Richard Henderson
2017-07-14 13:52 ` [Qemu-devel] [PATCH 13/28] hppa: replace cpu_hppa_init() " Igor Mammedov
2017-07-15 18:06   ` Richard Henderson
2017-07-14 13:52 ` [Qemu-devel] [PATCH 14/28] m68k: replace cpu_m68k_init() " Igor Mammedov
2017-07-15  8:05   ` Thomas Huth
2017-07-15 18:08   ` Richard Henderson
2017-07-15 20:57     ` Laurent Vivier
2017-07-17 10:41     ` Igor Mammedov
2017-07-17 15:05       ` Andreas Färber
2017-07-17 15:23         ` Igor Mammedov
2017-08-14  8:00           ` Igor Mammedov
2017-08-14 18:23             ` Laurent Vivier
2017-07-14 13:52 ` [Qemu-devel] [PATCH 15/28] microblaze: replace cpu_mb_init() " Igor Mammedov
2017-07-15 21:51   ` Philippe Mathieu-Daudé
2017-07-14 13:52 ` [Qemu-devel] [PATCH 16/28] nios2: replace cpu_nios2_init() " Igor Mammedov
2017-07-15 21:53   ` Philippe Mathieu-Daudé
2017-07-14 13:52 ` [Qemu-devel] [PATCH 17/28] tilegx: replace cpu_tilegx_init() " Igor Mammedov
2017-08-16 19:53   ` Eduardo Habkost
2017-07-14 13:52 ` [Qemu-devel] [PATCH 18/28] xtensa: replace cpu_xtensa_init() " Igor Mammedov
2017-08-16 19:56   ` Eduardo Habkost
2017-08-17 14:32     ` Igor Mammedov
2017-08-18 16:50       ` Eduardo Habkost
2017-07-14 13:52 ` [Qemu-devel] [PATCH 19/28] tricore: replace cpu_tricore_init() " Igor Mammedov
2017-08-16 19:56   ` Eduardo Habkost
2017-07-14 13:52 ` [Qemu-devel] [PATCH 20/28] sh4: replace cpu_sh4_init() " Igor Mammedov
2017-08-16 19:57   ` Eduardo Habkost
2017-07-14 13:52 ` [Qemu-devel] [PATCH 21/28] arm: replace cpu_arm_init() " Igor Mammedov
2017-08-14  8:53   ` Andrew Jones
2017-07-14 13:52 ` [Qemu-devel] [PATCH 22/28] cris: replace cpu_cris_init() " Igor Mammedov
2017-08-16 19:57   ` Eduardo Habkost
2017-07-14 13:52 ` [Qemu-devel] [PATCH 23/28] x86: replace cpu_x86_init() " Igor Mammedov
2017-08-16 19:57   ` Eduardo Habkost
2017-07-14 13:52 ` [Qemu-devel] [PATCH 24/28] lm32: replace cpu_lm32_init() " Igor Mammedov
2017-07-14 15:51   ` Michael Walle
2017-08-16 19:58   ` Eduardo Habkost
2017-07-14 13:52 ` [Qemu-devel] [PATCH 25/28] moxie: replace cpu_moxie_init() " Igor Mammedov
2017-08-16 19:58   ` Eduardo Habkost
2017-07-14 13:52 ` [Qemu-devel] [PATCH 26/28] openrisc: replace cpu_openrisc_init() " Igor Mammedov
2017-08-16 19:58   ` Eduardo Habkost
2017-08-16 21:28   ` Stafford Horne
2017-07-14 13:52 ` [Qemu-devel] [PATCH 27/28] unicore32: replace uc32_cpu_init() " Igor Mammedov
2017-08-16 19:59   ` Eduardo Habkost
2017-07-14 13:52 ` [Qemu-devel] [PATCH 28/28] ppc: replace cpu_ppc_init() " Igor Mammedov
2017-07-15  2:36   ` David Gibson
2017-07-15  6:09   ` Hervé Poussineau
2017-08-16 19:59   ` Eduardo Habkost

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=1500040339-119465-6-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=afaerber@suse.de \
    --cc=atar4qemu@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /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.