From patchwork Tue Apr 7 15:51:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1267477 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=im2/Gh9H; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xX5K1WNTz9sR4 for ; Wed, 8 Apr 2020 01:53:57 +1000 (AEST) Received: from localhost ([::1]:49664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLqXz-0006xY-46 for incoming@patchwork.ozlabs.org; Tue, 07 Apr 2020 11:53:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43686) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLqVf-0003UE-8t for qemu-devel@nongnu.org; Tue, 07 Apr 2020 11:51:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLqVe-0004Mg-AP for qemu-devel@nongnu.org; Tue, 07 Apr 2020 11:51:31 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:34733) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jLqVe-0004Lt-4h for qemu-devel@nongnu.org; Tue, 07 Apr 2020 11:51:30 -0400 Received: by mail-wr1-x42a.google.com with SMTP id 65so4506025wrl.1 for ; Tue, 07 Apr 2020 08:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j8FdPU/oaPxbpC8XFRmXIv/XBHTSg+RMGViKj8kJEZw=; b=im2/Gh9Hxw0EKBnx3wf00FbaA4avWtSg5SUZZLF+t+ggQJqi0XzkuiFQTjWIHQri40 gtPfUzbSbgZsCYcdGnip4B22aq+y8QEH3OKtcB+XBz61GEFj5aA2oJtEjMI1wqM+oFyD bmNOrDtLib0s9SvtyC5jujraGOtCBn9p+s7OUOfg7TV6IKBpuNCQpXFjjsOIqrlD6Lp0 Iy0Vnq+wcdjFpod/FI3je8SVBZhNWt3rqTMbCmIiAxKiWJtniucq4vzxzSYEPsuMXAYm EPsABRbTU+KPnBA5v+zbXrHLuK/FkAZkmkcbeq4VC7fFi8qUQVDfg9ntXEYH0Ah5oXlX Jn2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j8FdPU/oaPxbpC8XFRmXIv/XBHTSg+RMGViKj8kJEZw=; b=qoA0UoCezi8vD20hHsuR1bENyJrjshLR9GNxOhA/ubTxVD9IkFVT2ASchi7L0Mj/ZR 3Zw/+w52kAhl6Y36YN2f9wO4hlL++JEUpGEkczkxWVKBwxdc8ErHKeydkGB5MJcf31fL G2izyqJFPKR4gbaDTnwQ/haTGhquxq8b1Ud4HB4K78Il3XmtsphsjzGyBwSlNOOSQuEG lPchirUpAUqjJ72ut0wh84gAuCY3zWOexJtG7k0EpNYnwHS/N/F2Q/5s2nCewWCiT6g3 lkMOoy46gaNqGTr6l61gMjcb7flzodE5ypubf773APA9mkFseNSpN7sQPcmdqe+uJU9A 9ktg== X-Gm-Message-State: AGi0Pub81vVN3PuoWQP4GWJSKzCBrfqmMQNjekXTolsn14SxxcqxNcfl xrDvA7IosLf+6gHTssBdIbRgsA== X-Google-Smtp-Source: APiQypICSKzQFOuf/Uzaliq7T18bt7H9bzWK+z0dTArpLf5JJ9tcbl0i4ysGORz1Vl6MmxvMWqYOfw== X-Received: by 2002:a5d:5707:: with SMTP id a7mr3392347wrv.108.1586274688989; Tue, 07 Apr 2020 08:51:28 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s13sm15474804wrw.20.2020.04.07.08.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 08:51:26 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C71061FF92; Tue, 7 Apr 2020 16:51:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 06/13] target/xtensa: add FIXME for translation memory leak Date: Tue, 7 Apr 2020 16:51:11 +0100 Message-Id: <20200407155118.20139-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200407155118.20139-1-alex.bennee@linaro.org> References: <20200407155118.20139-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42a X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Filippov , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Dynamically allocating a new structure within the DisasContext can potentially leak as we can longjmp out of the translation loop (see test_phys_mem). The proper fix would be to use static allocation within the DisasContext but as the Xtensa translator imports it's code from elsewhere I leave that as an exercise for the maintainer. Signed-off-by: Alex Bennée Acked-by: Max Filippov Message-Id: <20200403191150.863-6-alex.bennee@linaro.org> diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 8aa972cafdf..37f65b1f030 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -1174,6 +1174,11 @@ static void xtensa_tr_init_disas_context(DisasContextBase *dcbase, dc->callinc = ((tb_flags & XTENSA_TBFLAG_CALLINC_MASK) >> XTENSA_TBFLAG_CALLINC_SHIFT); + /* + * FIXME: This will leak when a failed instruction load or similar + * event causes us to longjump out of the translation loop and + * hence not clean-up in xtensa_tr_tb_stop + */ if (dc->config->isa) { dc->insnbuf = xtensa_insnbuf_alloc(dc->config->isa); dc->slotbuf = xtensa_insnbuf_alloc(dc->config->isa);