From patchwork Wed Mar 23 17:17:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12789981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 89175C433EF for ; Wed, 23 Mar 2022 17:18:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.293995.499659 (Exim 4.92) (envelope-from ) id 1nX4cv-0005S9-SU; Wed, 23 Mar 2022 17:18:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 293995.499659; Wed, 23 Mar 2022 17:18:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nX4cv-0005S2-PR; Wed, 23 Mar 2022 17:18:29 +0000 Received: by outflank-mailman (input) for mailman id 293995; Wed, 23 Mar 2022 17:18:28 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nX4ct-0004Zy-Ry for xen-devel@lists.xenproject.org; Wed, 23 Mar 2022 17:18:27 +0000 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [2607:f8b0:4864:20::1035]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4019c6a7-aacd-11ec-a405-831a346695d4; Wed, 23 Mar 2022 18:18:27 +0100 (CET) Received: by mail-pj1-x1035.google.com with SMTP id o3-20020a17090a3d4300b001c6bc749227so2492351pjf.1 for ; Wed, 23 Mar 2022 10:18:27 -0700 (PDT) Received: from localhost.localdomain (198.red-83-50-65.dynamicip.rima-tde.net. [83.50.65.198]) by smtp.gmail.com with ESMTPSA id s6-20020a056a0008c600b004f667b8a6b6sm448750pfu.193.2022.03.23.10.18.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Mar 2022 10:18:25 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4019c6a7-aacd-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kr2xMtMFIyMaJvHp1QmAibj3cqEfTuMfM82zkP/aCIo=; b=GzQ9UQBsumIhsWs2W2K2ffiFYxEFSk/uJQDwHsoJE62lVsznZpDAk+rbusDkg4/pXh oYRTWwWf3XXjgqFP4meFBl7xIZslLNSKyF5Y1Nkqv7BIN9qrP/HEZc2GPulKuv+eyy0Q CSLUBGrImnHkarTBPYHhqd4Bz5klN6S1366sxNVa10mTmSfYbuDDmi6EMLlX9llM8fg1 Rm4ZEgKbpo0wmx0loAPNkIBIdsbxwIgizQ0MiPiw3WJfDKD7pBaLfqF/gCCtKxZBp7LS gRHq1IcA4FNU/hF6TniJKOWUVqcOHD5j7pUDrlVzfih8abviJtAdwMVwFP6x0OrQ4GyB ud3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kr2xMtMFIyMaJvHp1QmAibj3cqEfTuMfM82zkP/aCIo=; b=nHHTaCFZaE6QoD/OuDLxcFvMeu05SRdgOgaO8m89OLe5t9A/k7m9s00Cki4J0Rtfex Ig5+FtLmNW795Tjg5/aI45IQEN3mmyaes3qJ/Zkj4ImW7glqpDyvk3BM+zTwaZ+jLaOt 35l/zwMbfO9S8q83bhJYoeRpAc+D6M2Hh5CjVByzcy26kXCpTwpEpJo80laOQ9vHDHev u4CugEET9JJFLZL7H9Cyx3WRtMJVRxUNIizvVIIZwetFDfsU6tR51wMGrxjT/99bHUwl TZcxpfNtLm9HVVDOC/BOL+1kSUBrQR/UmPb7DYefhMEJjNUGRoicN6BxRA3iSupEYt0c GR+A== X-Gm-Message-State: AOAM531aEnvK/QuxiidNDp69DFZA0wxPsF/w6vQvmsg7j9LDVC4KNu+q +bP67QJIdgMIjgzgaC1TTfc= X-Google-Smtp-Source: ABdhPJyp9ousXQMjN1mFJdianu0WkJ5NuwBi+VzVmYIuZ9KnREKdbkqv1O8I5j4eIk26Y9GvJf6XJA== X-Received: by 2002:a17:902:834a:b0:14f:3337:35de with SMTP id z10-20020a170902834a00b0014f333735demr1074863pln.8.1648055905736; Wed, 23 Mar 2022 10:18:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Wenchao Wang , Laurent Vivier , David Hildenbrand , Yanan Wang , Cameron Esfahani , Marcelo Tosatti , Sunil Muthuswamy , Anthony Perard , haxm-team@intel.com, Paul Durrant , Richard Henderson , xen-devel@lists.xenproject.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Roman Bolshakov , Reinoud Zandijk , Marcel Apfelbaum , Kamil Rytarowski , Paolo Bonzini , Peter Xu , Eduardo Habkost , Stefano Stabellini , Thomas Huth , Colin Xu , Mark Kanda Subject: [PATCH v4 02/13] target/i386/kvm: Free xsave_buf when destroying vCPU Date: Wed, 23 Mar 2022 18:17:40 +0100 Message-Id: <20220323171751.78612-3-philippe.mathieu.daude@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> References: <20220323171751.78612-1-philippe.mathieu.daude@gmail.com> MIME-Version: 1.0 From: Philippe Mathieu-Daudé Fix vCPU hot-unplug related leak reported by Valgrind: ==132362== 4,096 bytes in 1 blocks are definitely lost in loss record 8,440 of 8,549 ==132362== at 0x4C3B15F: memalign (vg_replace_malloc.c:1265) ==132362== by 0x4C3B288: posix_memalign (vg_replace_malloc.c:1429) ==132362== by 0xB41195: qemu_try_memalign (memalign.c:53) ==132362== by 0xB41204: qemu_memalign (memalign.c:73) ==132362== by 0x7131CB: kvm_init_xsave (kvm.c:1601) ==132362== by 0x7148ED: kvm_arch_init_vcpu (kvm.c:2031) ==132362== by 0x91D224: kvm_init_vcpu (kvm-all.c:516) ==132362== by 0x9242C9: kvm_vcpu_thread_fn (kvm-accel-ops.c:40) ==132362== by 0xB2EB26: qemu_thread_start (qemu-thread-posix.c:556) ==132362== by 0x7EB2159: start_thread (in /usr/lib64/libpthread-2.28.so) ==132362== by 0x9D45DD2: clone (in /usr/lib64/libc-2.28.so) Reported-by: Mark Kanda Tested-by: Mark Kanda Signed-off-by: Philippe Mathieu-Daudé --- target/i386/kvm/kvm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index ef2c68a6f4..e93440e774 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2072,6 +2072,8 @@ int kvm_arch_destroy_vcpu(CPUState *cs) X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; + g_free(env->xsave_buf); + if (cpu->kvm_msr_buf) { g_free(cpu->kvm_msr_buf); cpu->kvm_msr_buf = NULL;