From patchwork Sun Nov 8 10:50:21 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 37933 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 83830B6F2B for ; Sun, 8 Nov 2009 21:51:42 +1100 (EST) Received: from localhost ([127.0.0.1]:50377 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N75Mw-0005Fv-DI for incoming@patchwork.ozlabs.org; Sun, 08 Nov 2009 05:51:38 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N75M8-0005DX-4i for qemu-devel@nongnu.org; Sun, 08 Nov 2009 05:50:48 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N75M3-00058I-Lt for qemu-devel@nongnu.org; Sun, 08 Nov 2009 05:50:47 -0500 Received: from [199.232.76.173] (port=44948 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N75M3-000583-Eq for qemu-devel@nongnu.org; Sun, 08 Nov 2009 05:50:43 -0500 Received: from mail-yx0-f188.google.com ([209.85.210.188]:44366) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N75M2-0002hB-St for qemu-devel@nongnu.org; Sun, 08 Nov 2009 05:50:43 -0500 Received: by yxe26 with SMTP id 26so1921621yxe.4 for ; Sun, 08 Nov 2009 02:50:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:from:date:message-id :subject:to:content-type; bh=ne851fTlTl+U4iRofWScbqhe/IWFylirpWUUHojlfMc=; b=YoB/GmkfUdSpyo7Taj+a5zuKI19NRWPx++owv1XHNm7tuS5JCOkxxNtZs7Cn4QDzAn szlFpxUaId0H318svrUn9zfsFHd6VgR+wHP5ybxGuVWCYkFyMWvB8X+jnbxBo8gExOFj dkny1SiDFbjxVgVnMtdNXHWqwazNgdfYL3g+w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=nIDA1hmE2gsEb18NrbeaCUS2GDRujfnX7ZopJBuoFzWCTCmOry/uvj5/FnLJuij3gr PaqZ0CaNuBRFhYUKDdnxaDe0zxeKKURaHieLC3tdzhBjCg+eOjtzGc34Oc32Ay5Uvxhl /Ar3LSym/ackrGZRFU4fLvkyZgeX5Nvl0CVsc= MIME-Version: 1.0 Received: by 10.101.191.16 with SMTP id t16mr40457anp.163.1257677441183; Sun, 08 Nov 2009 02:50:41 -0800 (PST) From: Blue Swirl Date: Sun, 8 Nov 2009 12:50:21 +0200 Message-ID: To: Aurelien Jarno , qemu-devel X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: Subject: [Qemu-devel] [PATCH, RFC] mips: fix cpu_reset memory leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Both mmu_init() and mvp_init() allocate structures, so call cpu_mips_register only when creating a CPU. In addition, maybe some of the some of the field initialization stuff in cpu_mips_register, mmu_init, mvp_init, fpu_init etc. should be moved to cpu_reset instead, in case the fields should be reset to original values during CPU reset. Maximally only the env->mvp etc. structure allocation would be left to cpu_mips_register. This is the minimal version, but it may be incorrect. Comments? Signed-off-by: Blue Swirl --- target-mips/translate.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/target-mips/translate.c b/target-mips/translate.c index 58f483f..738efb7 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -8601,6 +8601,7 @@ CPUMIPSState *cpu_mips_init (const char *cpu_model) cpu_exec_init(env); env->cpu_model_str = cpu_model; + cpu_mips_register(env, def); mips_tcg_init(); cpu_reset(env); qemu_init_vcpu(env); @@ -8654,7 +8655,6 @@ void cpu_reset (CPUMIPSState *env) env->hflags = MIPS_HFLAG_CP0; #endif env->exception_index = EXCP_NONE; - cpu_mips_register(env, env->cpu_model); } void gen_pc_load(CPUState *env, TranslationBlock *tb,