From patchwork Mon Jun 5 20:15:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 689234 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp2286442wru; Mon, 5 Jun 2023 13:20:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4e6iNi9PFxirR92Hgq+cC5qRT2/s0WFi0gmNEQgvmAWHfHTkWgZK+E13JJeXRDiuGHjoYZ X-Received: by 2002:a05:622a:1741:b0:3f9:a8af:88b2 with SMTP id l1-20020a05622a174100b003f9a8af88b2mr2807245qtk.25.1685996428194; Mon, 05 Jun 2023 13:20:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685996428; cv=none; d=google.com; s=arc-20160816; b=wHfiGpC0+nVp6eSKeFv40huE69maKJsbIOMyjx0HoMmlvnMNtvpAnO8LiYsn1yGAKT llkCutoSFXksaTQDL4sS12yGTwHadfKSciaf4y23w9nBuKvGRYfBd5xsv8/FDWbIwxFU lwCTyGDyf+Ujgp/y1uKU98k+aLrIOAnG4YpMAUBnVzPEoOREiPupQcA25S1CrpPhwCDm 5GVaSbcXfd1MPideQIbyku9Y0jMLXuWIH56g85rRXtRXrnOkxKJ9+/i+FWjXb/sKCSaR Uq4j5BgfP8hJN331Oet730+nL+eVADgfkPCvvgBC+xmWy2CaTcQuevwTV2hpD7e+ZLtk hK3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NES3rUjYxvsEhP1PSaVSBmUCbjMXZRddYq+Gk3VmTrM=; b=w+qTJ76cMvXgvwYHY6bCYG+oEBHSJ10AEXoJyxmk2ZMnzRdYLlYcEjEvcWbCOCJ6V4 ZrJaXhz3jnF/IV2Mp+gaN6YJuIvdHCi/JQdZ9qkkhjN6TDVw3X5kLsFpMNIp9n7+aAiF UPYVEjzBxnscaChEoMjbPKc63y2aaOb+pV99E6NbqZ/J6dugM0W7Q25F2MuI2lkk33yT Fg4D4kCOMJcqvFkGaiZruYmpyE+cPEaDLNdDvjHID8J6f6osyqqIJz87hbgBfSsFEUY3 58TmuTEVrmfafPjArbBMIR2O3YlN7EUuRiIGOMHV/kivvxQJj8/WCFU7S0O33GVSroQ5 0t8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tBSPMizc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w4-20020ac857c4000000b003f6aa9086b7si5145553qta.790.2023.06.05.13.20.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Jun 2023 13:20:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tBSPMizc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6GgP-0007rf-Qb; Mon, 05 Jun 2023 16:20:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6Gg1-0006xc-T8 for qemu-devel@nongnu.org; Mon, 05 Jun 2023 16:19:43 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q6Gfw-0005no-BB for qemu-devel@nongnu.org; Mon, 05 Jun 2023 16:19:39 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1b025d26f4fso46226905ad.1 for ; Mon, 05 Jun 2023 13:19:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685996374; x=1688588374; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NES3rUjYxvsEhP1PSaVSBmUCbjMXZRddYq+Gk3VmTrM=; b=tBSPMizcoq94Za5n3BEBJ4e+DEKdf7hNtEWfA2/Jv7ln7/L1EuMd8XxjZgHId5JsF+ nVSlIqwYqgpSubvFtiBSSouiw7e1QyR87y2GSuZgYlt1kjLmI8nnQE76aHCO6V9os+dV p1P8XBEhUIot8qsEjH63vWSgbNpVopBntWw2aWMe3zRQoXfDW1Mr1HtCXhrskW0aXDOz 3P2o7UPM+OGq4mbeDGYC4pXDlm6ibm3YEigj3PkbkUcf6gVzXkq57dZ9HXkKQQiKViIf oolcrt27O+j4ed0hhanVdywOBNpIAX05l8DiTWnXXZ7ifxY2tsPPbG676izbfd4c7clo IOSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685996374; x=1688588374; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NES3rUjYxvsEhP1PSaVSBmUCbjMXZRddYq+Gk3VmTrM=; b=KgdxHVz07VqkZgZp4aAyrJXRI0/jSJzB6mIXdIjlZBCX3txJ8yWc3eJhcCx9jaz37X q5uqeQQh2tqhpekHwFfbaWaruhJ/GdOkI1ee2UmIKu/SoJZc8juh4CdPZb8zX2AK+mZZ 5agJiFLrpNl9q2e62nSAYCEaO8Y/WzHBXx15ex9oaAjg6Cd64yHs27N34uCo8zeWOpCN pViCpy4h2XY9BjZfqgmWDdAj9Rz6uE3anrIYDfFjPrv5eZTl8FuF9TNlLHnUEbrLPuqN fET/JW7kgpdGzL0o+mG0eMWFLD57vvoZMXvjziMlqDypmwzUTaw9A3cDjiEKt1huzQ9Z qOwQ== X-Gm-Message-State: AC+VfDz8KC2WnJuYwKYvH3uXqS5pmojTIOaEyuXPz/945UuhW4SVr3II /uOxte1D4hfJBzBin0z7Y6rDlv2MD09JVvtD//0= X-Received: by 2002:a17:902:f68a:b0:1a6:71b1:a0b9 with SMTP id l10-20020a170902f68a00b001a671b1a0b9mr11621569plg.47.1685996373913; Mon, 05 Jun 2023 13:19:33 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:3f85:a600:6a3e:e465]) by smtp.gmail.com with ESMTPSA id w20-20020a170902c79400b001a980a23802sm7018184pla.111.2023.06.05.13.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 13:19:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich Subject: [PULL 51/52] accel/tcg: Unmap perf_marker Date: Mon, 5 Jun 2023 13:15:47 -0700 Message-Id: <20230605201548.1596865-52-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230605201548.1596865-1-richard.henderson@linaro.org> References: <20230605201548.1596865-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Ilya Leoshkevich Coverity complains that perf_marker is never unmapped. Fix by unmapping it in perf_exit(). Fixes: Coverity CID 1507929 Fixes: 5584e2dbe8c9 ("tcg: add perfmap and jitdump") Signed-off-by: Ilya Leoshkevich Message-Id: <20230605114134.1169974-1-iii@linux.ibm.com> Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- accel/tcg/perf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/accel/tcg/perf.c b/accel/tcg/perf.c index f5a1eda39f..cd1aa99a7e 100644 --- a/accel/tcg/perf.c +++ b/accel/tcg/perf.c @@ -111,6 +111,8 @@ static void write_perfmap_entry(const void *start, size_t insn, } static FILE *jitdump; +static size_t perf_marker_size; +static void *perf_marker = MAP_FAILED; #define JITHEADER_MAGIC 0x4A695444 #define JITHEADER_VERSION 1 @@ -190,7 +192,6 @@ void perf_enable_jitdump(void) { struct jitheader header; char jitdump_file[32]; - void *perf_marker; if (!use_rt_clock) { warn_report("CLOCK_MONOTONIC is not available, proceeding without jitdump"); @@ -210,7 +211,8 @@ void perf_enable_jitdump(void) * PERF_RECORD_MMAP or PERF_RECORD_MMAP2 event is of the form jit-%d.dump * and will process it as a jitdump file. */ - perf_marker = mmap(NULL, qemu_real_host_page_size(), PROT_READ | PROT_EXEC, + perf_marker_size = qemu_real_host_page_size(); + perf_marker = mmap(NULL, perf_marker_size, PROT_READ | PROT_EXEC, MAP_PRIVATE, fileno(jitdump), 0); if (perf_marker == MAP_FAILED) { warn_report("Could not map %s: %s, proceeding without jitdump", @@ -372,6 +374,11 @@ void perf_exit(void) perfmap = NULL; } + if (perf_marker != MAP_FAILED) { + munmap(perf_marker, perf_marker_size); + perf_marker = MAP_FAILED; + } + if (jitdump) { fclose(jitdump); jitdump = NULL;