Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp714494pxb; Fri, 8 Jan 2021 16:49:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlZeSZsRAAuNHcZ7r1qsXrCc32fnSjylpOz/RBTUSDnq5qSYuj7VTGI1IJlHXbm5PNXHob X-Received: by 2002:a17:906:7215:: with SMTP id m21mr4209543ejk.248.1610153380371; Fri, 08 Jan 2021 16:49:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610153380; cv=none; d=google.com; s=arc-20160816; b=0M9mqjduJrlTRe60hkvnlCVVPW2swgxRLTVNfwMlQPoC2yZBaGWoDp+H+JGcLYyusp f1FihOqgXwtHg9WpqbbhpQjSqQB2XK8b1IRiN3GdktvusrPWRSvuJvoCTS4IVmTjP6s3 F8aHvk/Tn7Zxr4H/M4f2aYhOy0hsSFTF4If7eXs9j0PcmERsRoKeXyJH/0DoVG8Vx7lQ V8rVKzUfN2ml17srnx9Z7s5TN3cUhKaqLUZdHQcvbODkuyzvafWaiQulV5LRYthMyu6k M3LZV5s6v+o4dZLC01zwVPcJTfaGOqBhRJB8VdI9OoDi8kVms2R8e14GVJ71TjwZknzs NM4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:sender:dkim-signature; bh=vDh4eKmFYAmn/pACCaUYHAK8byzvJFHct+dqDkZvWfA=; b=yWLoYFape+CQAVY/HIWwVH5gdpdu6o9TbKyEdKUfBxCd1N6xt7TUCZE4Y31gIUzfIZ jsquRS2FZsvR6TCXDz3blaCW5vk38QuVzjDtqAALZg4spY/rezfeWtqCkQLYYkwGrWAR L5WSQaXGJK7P8cdqFG6I8wIU5tw+0JifPM/RmCSPiMb7Vs2bC8QF3Q08ihargbUDXD5o /XDHtPHJExnqCQL0UfQtqkA+jLaY67danmuM689C4HfsY8Ik3ji4BNH/rQtG3s8W0G0v t819pPSabqQ3a+zjYO6gMID7D7P7OD/Z25z0SgFdoWhP59OzDkq/U1YmyfURrq9HQkVW PYLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ab+7KA0q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d2si4063064edd.145.2021.01.08.16.49.16; Fri, 08 Jan 2021 16:49:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ab+7KA0q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726488AbhAIAsT (ORCPT + 99 others); Fri, 8 Jan 2021 19:48:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbhAIAsS (ORCPT ); Fri, 8 Jan 2021 19:48:18 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E9A7C0613C1 for ; Fri, 8 Jan 2021 16:47:38 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id w8so17175687ybj.14 for ; Fri, 08 Jan 2021 16:47:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=vDh4eKmFYAmn/pACCaUYHAK8byzvJFHct+dqDkZvWfA=; b=Ab+7KA0qdYGMnAlMWUILK6GjCUGeaAGIXD1IgpqBsA+n84nWw3Hu9UJnAsDhcSgg/E vJOCJ/HYzKN3TK4VsDF1VD7KLG8mLeDQRhDcT/kpC2PCxVmj2Z7uaDzGYH5nX5ZdUMZf XpVCD90r9FJ+UE30VWduFe/RfljbpsZsnAfgsv7S0aiICdA3UzSwRxKpPUpuj9e+5Y9V 6prkzbU2veqaKHV6H7tNxm/EMvVW2ciZFiXMxv65XkiRkO7M3shcIHwtk6Buxg1s6qzM ZCQLN2K5UHdNrLG4UL2Ouikn2MEiZVvNbSExcgR501mWeMJRWw3BtRLva4c5x2SnJLr1 wn2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=vDh4eKmFYAmn/pACCaUYHAK8byzvJFHct+dqDkZvWfA=; b=Eimzuclj3zNg/VAr9vjsW2hu9e3pVssuUSsHzpeGGhgMD+CU8N2dhGcQIr1x9Qbu/d pQFcRW0WHFBiSy57e/Jm3fEG2ZQAC8ALvjDVmJk1YWPFFr2JqZdznpuH994yrw1GPXm+ Wj04m1076U4MnspsYYoMgk32+fYazUSuLD5fQve/2QhnfbPEB0cdA9RSp7+JBooHhcbg 9XY4lhvbJQ8QHcFCxu9PCh2yozdycMwWAIwb5kyRlDDowFhiLJ0F9icoxHWrvfUQbboT 1M1GOuBPA3pw4UuAlXbCe0BocIwaphYmx/GJl529R9Bcb1mdt/b0b0DIDT8bkQBSG1Om M4aQ== X-Gm-Message-State: AOAM5321fa5OCHAkuBGq6hABmqHCrYX/3h3yP6nPfyMcHVGDInPeyTQd FfL7HjOhtzuNMNtIjVYo7HA9mf3tfYE= Sender: "seanjc via sendgmr" X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:1ea0:b8ff:fe73:50f5]) (user=seanjc job=sendgmr) by 2002:a05:6902:6d4:: with SMTP id m20mr9411689ybt.434.1610153257450; Fri, 08 Jan 2021 16:47:37 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 8 Jan 2021 16:47:02 -0800 In-Reply-To: <20210109004714.1341275-1-seanjc@google.com> Message-Id: <20210109004714.1341275-2-seanjc@google.com> Mime-Version: 1.0 References: <20210109004714.1341275-1-seanjc@google.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH 01/13] KVM: SVM: Free sev_asid_bitmap during init if SEV setup fails From: Sean Christopherson To: Paolo Bonzini , Dave Hansen , Andy Lutomirski , Peter Zijlstra Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky , Borislav Petkov , Brijesh Singh Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Free sev_asid_bitmap if the reclaim bitmap allocation fails, othwerise it will be leaked as sev_hardware_teardown() frees the bitmaps if and only if SEV is fully enabled (which obviously isn't the case if SEV setup fails). Fixes: 33af3a7ef9e6 ("KVM: SVM: Reduce WBINVD/DF_FLUSH invocations") Cc: Tom Lendacky Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/sev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index c8ffdbc81709..0eeb6e1b803d 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -1274,8 +1274,10 @@ void __init sev_hardware_setup(void) goto out; sev_reclaim_asid_bitmap = bitmap_zalloc(max_sev_asid, GFP_KERNEL); - if (!sev_reclaim_asid_bitmap) + if (!sev_reclaim_asid_bitmap) { + bitmap_free(sev_asid_bitmap); goto out; + } pr_info("SEV supported: %u ASIDs\n", max_sev_asid - min_sev_asid + 1); sev_supported = true; -- 2.30.0.284.gd98b1dd5eaa7-goog