From patchwork Thu Apr 20 08:47:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 85792 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp187077vqo; Thu, 20 Apr 2023 02:08:05 -0700 (PDT) X-Google-Smtp-Source: AKy350bIVnWCF3EIFdiXmYbnZaUWrWhnS7lJf2QYh+GotZ8yB7kJ1uBpBzi4g9F2g+36/J5ZJJ2N X-Received: by 2002:a17:902:c3c5:b0:1a5:309e:d205 with SMTP id j5-20020a170902c3c500b001a5309ed205mr977540plj.21.1681981685568; Thu, 20 Apr 2023 02:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681981685; cv=none; d=google.com; s=arc-20160816; b=y/x1rln9FF5a8wJljbsPzrMnmFJmoFz5ZNOnfQ2qweSD4v2+RyEpBaY2D1IbvdpDdd tPqcB9BoaowUYFO65ZakFt79CnFgsXVr+jNhdAlBe98tboP2xZKr0kFi7uYkn3I7IO8E U7WFwYNI2tmMwqqdWLXMCAO62l1MnJIG9dvljEzemoAl0ZFkNOlpr7Is7VpXem2224Rh n/W+0fWFS6Q3OQM2yDe0fkFWNcGUEiA1B0rEJuPNNUVdI3VgW62pyhKaowW1rxBO67OF j/hmAb6wTZat0O9K9IURnermGtLnLcgIy9BzpXPD49cBRi2bzE+rR0Dx7yP+F8HNC8MI +HYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RdaT2Pf0VFYL4LUkKTTIwRSg1FtfHR7MN47zcz2wKyA=; b=ZLnwh74h73gL88Vbura/ndXf1sHNXRYtypTseYy2GnXy7oiERhBsKqsg/LJi4rAGgI cWD2O0OYjf+z//NTPuzjdNb9ErhFiAnd+D71qzde99URmIbzjBMM5j4C6vAmyXrT5FH8 98WCPtqa3hLs5+ODKfCFO1H5q/M+po8jij6UtiAb0ZaT7A+nOVO+nYmdaKBgibV7X1Bg LG5oaVar7iAM6z7Wan1Z9W5F6aQW37i2/kS2vm09dPpYrlOjgGv51Muo7dwzJ7lBxtQk swPeeOQw4DTsN1ISGMicoEITQamImR+GEPPTbmYIPNKQY/rA6gCPIIvUlvooQ7SPrFAg pXcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b="M6X/IL+6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ik8-20020a170902ab0800b001a6458c9f96si1538534plb.37.2023.04.20.02.07.53; Thu, 20 Apr 2023 02:08:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b="M6X/IL+6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234125AbjDTIsP (ORCPT + 99 others); Thu, 20 Apr 2023 04:48:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234558AbjDTIrt (ORCPT ); Thu, 20 Apr 2023 04:47:49 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B3E040CE for ; Thu, 20 Apr 2023 01:47:41 -0700 (PDT) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id C1FB244279 for ; Thu, 20 Apr 2023 08:47:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1681980457; bh=RdaT2Pf0VFYL4LUkKTTIwRSg1FtfHR7MN47zcz2wKyA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=M6X/IL+6C0IANJOtuZiH/AkpBzXPe6+yAYR8X76F5aXjpBjwe5dAQElbLxK8RqCfb cp/DrNaM/O9cudEqraiOh+vNee0jH6mV1B5uigBiNV9zVNG7l8onGbey7B5maUGrhT 5ZvZo9flkWVG0/Nv1G0QtyQzbuW9+aVv8ZhSQkxzHW2ITlrCgkzkhZtd3Six8DvfGT ImuN4eRN0UuqdwX+oqKKUkWH58pC4UBz/TkXYLIs5FW86QK48CvU7cUy/Y3BgiFVT5 0XfHDXKgAAPVyEHnKB+KyZQ94cNtP60WeHmwZAcbSxtJtaR3lCTP03elKfqH7JTUkA ypJh4JiMpDBLA== Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-505149e1a4eso2021302a12.1 for ; Thu, 20 Apr 2023 01:47:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681980457; x=1684572457; 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=RdaT2Pf0VFYL4LUkKTTIwRSg1FtfHR7MN47zcz2wKyA=; b=gM48OX4HlLpsM1zLM09W4QEc4eAsoqxkyr99FTXxiAmAAS9n+YKQSZvLiCuFoeELGj 292OaxM4wZQD1Yd1oYa6wkED3hwoRv2dvg9PUOkMikagkMO1YYdWMQ03PPDdJ77RVlui iPGN6eDddwhMnKFnpRQXUuD3krHy89e5S55AMDvx2YCAE8ukhsoqcf36f3/sJNJozG2m XJQfy+bHzIZEfFYLnsyCd+y7jR/2h3UhDjGay33q8nEE0IZEIhtx37CJCwWsPBW1z89A /KlmWFcEH+lR7+4kvxObXHeKg5xqupxl9YMcNJ4c7T/4cZGyrKPhZk2Rlh+1Vmf/60h0 rWvw== X-Gm-Message-State: AAQBX9faYBVpqhitXHOAq3Wg4sInWzcKcZpEIb8IGm4HPv5PK5Ls/ur/ ov44aL2tRtkm2bOxwol39ixOFu19UOU9TrS1cnvr6Ugap2kAiAB0bXjmCQSQCYVQS+nFnEZYa/U FXZo9f5xLLhMM3J7OFgJTSE4J+MZB090WWEXoKKZzaA== X-Received: by 2002:a05:6402:12c2:b0:506:a44c:e213 with SMTP id k2-20020a05640212c200b00506a44ce213mr594665edx.20.1681980457113; Thu, 20 Apr 2023 01:47:37 -0700 (PDT) X-Received: by 2002:a05:6402:12c2:b0:506:a44c:e213 with SMTP id k2-20020a05640212c200b00506a44ce213mr594650edx.20.1681980456869; Thu, 20 Apr 2023 01:47:36 -0700 (PDT) Received: from amikhalitsyn.. (ip5f5bd076.dynamic.kabel-deutschland.de. [95.91.208.118]) by smtp.gmail.com with ESMTPSA id k26-20020aa7c39a000000b005068053b53dsm500964edq.73.2023.04.20.01.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 01:47:36 -0700 (PDT) From: Alexander Mikhalitsyn To: pbonzini@redhat.com Cc: Alexander Mikhalitsyn , Sean Christopherson , =?utf-8?q?St=C3=A9phane_Graber?= , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Subject: [PATCH RESEND 1/2] KVM: SVM: free sev_*asid_bitmap init if SEV init fails Date: Thu, 20 Apr 2023 10:47:16 +0200 Message-Id: <20230420084717.111024-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230420084717.111024-1-aleksandr.mikhalitsyn@canonical.com> References: <20230420084717.111024-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763685627968581095?= X-GMAIL-MSGID: =?utf-8?q?1763685627968581095?= If misc_cg_set_capacity() fails for some reason then we have a memleak for sev_reclaim_asid_bitmap/sev_asid_bitmap. It's not a case right now, because misc_cg_set_capacity() just can't fail and check inside it is always successful. But let's fix that for code consistency. Cc: Sean Christopherson Cc: Paolo Bonzini Cc: Stéphane Graber Cc: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Alexander Mikhalitsyn --- arch/x86/kvm/svm/sev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index c25aeb550cd9..a42536a0681a 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2213,8 +2213,13 @@ void __init sev_hardware_setup(void) } sev_asid_count = max_sev_asid - min_sev_asid + 1; - if (misc_cg_set_capacity(MISC_CG_RES_SEV, sev_asid_count)) + if (misc_cg_set_capacity(MISC_CG_RES_SEV, sev_asid_count)) { + bitmap_free(sev_reclaim_asid_bitmap); + sev_reclaim_asid_bitmap = NULL; + bitmap_free(sev_asid_bitmap); + sev_asid_bitmap = NULL; goto out; + } pr_info("SEV supported: %u ASIDs\n", sev_asid_count); sev_supported = true; From patchwork Thu Apr 20 08:47:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 85780 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp180336vqo; Thu, 20 Apr 2023 01:56:46 -0700 (PDT) X-Google-Smtp-Source: AKy350Y/sr6sZej8w00PjbMe/r8pqgMQBqATwSH1Z4l49sokgW5v/cz0fmuJOLkbgFOPMw16J7Fk X-Received: by 2002:a05:6a20:9147:b0:ef:e240:b557 with SMTP id x7-20020a056a20914700b000efe240b557mr1344601pzc.34.1681981006187; Thu, 20 Apr 2023 01:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681981006; cv=none; d=google.com; s=arc-20160816; b=Vsxh3AEfrHPTCNqgv+/vjR9Xy2y8z8ROZWxPlRGFlLiuVnNUblk3xdLjGqcXofYnKZ ilLor0S2oOpb4TxC1n0DMbKN1s3jY+KSLgwuzoiRGJccmZ+vE/3lb/J4rQyA8DyLTput fp9TdHbvJAwQfATW6gTPnN5d82YQeAvGbm6k+Cv0JEg7pOIrxXQOCSFHxcHTu6N09fBD 2cLXTs/xGgYwpGmab8AgA5PbDd0LoLPy05CJBZQWyYEXSsRReCcJUl9XgPW/s5K8Bc+G j2ipEmUoZsfVxSHD+UVn6Bo4vF8MxS7Xee6y5QPPTrc1G6lvKD1mYnemCfm/e8+kcY9m MgNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QUa3auAj4u9NqRTBT9WVcUeMs8DEO6WQSLZjTthBB3A=; b=UN8cE4ZATZVNflxgkuzbvl58EeFHtJWYsQvixefKDpuC7aFUTCEa+JOGYNNBEh/sEN zCy1jdD2es6jqXpgylEEcw39vvS+/qZDL8lPhiTy7zKdhIV7GwpWME18oMK0EeBza9i5 7nWZlWUNuvuNiMBP7D0turFN9ICUv1dL52aDyqI7q3RcH1w/S5pd/ykZLncvr1Nu/mIg 7MSliKfiAfb8Z+xbeub9jFVg1RwCKKr66GMH374vSnCeN7mCPnkT9VlQpA5GpWCW8MaC 3d100A0za0pptu+uETxOABpY6PHX7gvDhNTGHQ7VQtAmLLWbLXByJbWdWkNeaAhE3VpX Ptag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=fQpmg6Ek; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j69-20020a638048000000b005180515929csi1140800pgd.28.2023.04.20.01.56.31; Thu, 20 Apr 2023 01:56:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=fQpmg6Ek; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234596AbjDTIs3 (ORCPT + 99 others); Thu, 20 Apr 2023 04:48:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234562AbjDTIrw (ORCPT ); Thu, 20 Apr 2023 04:47:52 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B569527E for ; Thu, 20 Apr 2023 01:47:42 -0700 (PDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id DA86741B36 for ; Thu, 20 Apr 2023 08:47:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1681980459; bh=QUa3auAj4u9NqRTBT9WVcUeMs8DEO6WQSLZjTthBB3A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=fQpmg6Ek3DEy/BCFq3rwl4YPflP+poM/IUZES8u47fAth2Yvupa3yVqnatF30LZ6b iFGjlpfOFmdN3uM3DPN9EBHK5HV8yTQUv201Z7hcQYnAPOwnTbGPdn6uEAPrdhR44l VfSQE7BahR4Ptq10JN2NSjkQQxv/JIHmIDBXyN5xGSTmCSUC8qVAZZoaEQa0RXX0wP LpmoTU/WrVcENfUP9UWaicyHZInxfsRFPFqFd4dEs83jpEYgXj1f3Hpx9PKHE4rBxx Uftz/q0XVZ+s89xyu+lxVD3wRoV9hGrdpQvrUtPQGvCFtrv5AtHSBWD0xnKqQ1y+ji 3vkZtOcQQxG9A== Received: by mail-ej1-f70.google.com with SMTP id q24-20020a170906361800b0094fb847ed94so991100ejb.0 for ; Thu, 20 Apr 2023 01:47:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681980459; x=1684572459; 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=QUa3auAj4u9NqRTBT9WVcUeMs8DEO6WQSLZjTthBB3A=; b=Nr0RRCVKyn6i0jtu4XwAPruc/I54798HgHkkOkAsA0XDFqptabnhuNoIjeBl8l/Neu f839wuJmOQhuqDQNurvEm0KHiavsvdVVFuRuNYxNLBP+55ChpCQH0cT66JraZHvDW50k DYBMwCusw2YxJjoLD6a2y5XdjPz3mJTPXtGdi0CjQujlCTdmd4VC+psDK9NtQhD+EK/5 jn0Ta2f2cm/fbo2d1aTrmc8ObZOAlyd0SL8WkJT1LbwPXU3MAPf8HHFdqZWwRQ8a5ZMl ZXpC/514U1mXeEmaHcOd+VpMPbwiIxx4p9vsTJ7D2fxo4DkN5bsg90fu2uFqtshJvz/D OsKw== X-Gm-Message-State: AAQBX9cOczqhH+FCxPECDGpbQgJXGFR7wST4kk0HS7zN+0Ks53oO9uZB 9zJi8IW+wKPG+pctw+lTYSvnTVK2x+jvsiwCkJmmXa3BJxK/XEtR+OBMhA8VzXkdiDVCr8TVvT6 Tv2Em8cebYNx4brCRjqJJGW/bZWzV5SjRwioPbwsvjQ== X-Received: by 2002:a17:906:3512:b0:94f:12c0:4c8f with SMTP id r18-20020a170906351200b0094f12c04c8fmr820689eja.50.1681980459545; Thu, 20 Apr 2023 01:47:39 -0700 (PDT) X-Received: by 2002:a17:906:3512:b0:94f:12c0:4c8f with SMTP id r18-20020a170906351200b0094f12c04c8fmr820671eja.50.1681980459275; Thu, 20 Apr 2023 01:47:39 -0700 (PDT) Received: from amikhalitsyn.. (ip5f5bd076.dynamic.kabel-deutschland.de. [95.91.208.118]) by smtp.gmail.com with ESMTPSA id k26-20020aa7c39a000000b005068053b53dsm500964edq.73.2023.04.20.01.47.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 01:47:38 -0700 (PDT) From: Alexander Mikhalitsyn To: pbonzini@redhat.com Cc: Alexander Mikhalitsyn , Sean Christopherson , =?utf-8?q?St=C3=A9phane_Graber?= , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Subject: [PATCH RESEND 2/2] KVM: SVM: add some info prints to SEV init Date: Thu, 20 Apr 2023 10:47:17 +0200 Message-Id: <20230420084717.111024-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230420084717.111024-1-aleksandr.mikhalitsyn@canonical.com> References: <20230420084717.111024-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763684915190905402?= X-GMAIL-MSGID: =?utf-8?q?1763684915190905402?= Let's add a few pr_info's to sev_hardware_setup to make SEV/SEV-ES enabling a little bit handier for users. Right now it's too hard to guess why SEV/SEV-ES are failing to enable. There are a few reasons. SEV: - NPT is disabled (module parameter) - CPU lacks some features (sev, decodeassists) - Maximum SEV ASID is 0 SEV-ES: - mmio_caching is disabled (module parameter) - CPU lacks sev_es feature - Minimum SEV ASID value is 1 (can be adjusted in BIOS/UEFI) Cc: Sean Christopherson Cc: Paolo Bonzini Cc: Stéphane Graber Cc: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Alexander Mikhalitsyn --- arch/x86/kvm/svm/sev.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index a42536a0681a..14cbb8f14c6b 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2168,17 +2168,24 @@ void __init sev_hardware_setup(void) bool sev_es_supported = false; bool sev_supported = false; - if (!sev_enabled || !npt_enabled) + if (!sev_enabled) goto out; + if (!npt_enabled) { + pr_info("Failed to enable AMD SEV as it requires Nested Paging to be enabled\n"); + goto out; + } + /* * SEV must obviously be supported in hardware. Sanity check that the * CPU supports decode assists, which is mandatory for SEV guests to * support instruction emulation. */ if (!boot_cpu_has(X86_FEATURE_SEV) || - WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_DECODEASSISTS))) + WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_DECODEASSISTS))) { + pr_info("Failed to enable AMD SEV as it requires decodeassists and sev CPU features\n"); goto out; + } /* Retrieve SEV CPUID information */ cpuid(0x8000001f, &eax, &ebx, &ecx, &edx); @@ -2188,8 +2195,10 @@ void __init sev_hardware_setup(void) /* Maximum number of encrypted guests supported simultaneously */ max_sev_asid = ecx; - if (!max_sev_asid) + if (!max_sev_asid) { + pr_info("Failed to enable SEV as the maximum SEV ASID value is 0.\n"); goto out; + } /* Minimum ASID value that should be used for SEV guest */ min_sev_asid = edx; @@ -2234,16 +2243,22 @@ void __init sev_hardware_setup(void) * instead relies on #NPF(RSVD) being reflected into the guest as #VC * (the guest can then do a #VMGEXIT to request MMIO emulation). */ - if (!enable_mmio_caching) + if (!enable_mmio_caching) { + pr_info("Failed to enable SEV-ES as it requires MMIO caching to be enabled\n"); goto out; + } /* Does the CPU support SEV-ES? */ - if (!boot_cpu_has(X86_FEATURE_SEV_ES)) + if (!boot_cpu_has(X86_FEATURE_SEV_ES)) { + pr_info("Failed to enable SEV-ES as it requires sev_es CPU feature\n"); goto out; + } /* Has the system been allocated ASIDs for SEV-ES? */ - if (min_sev_asid == 1) + if (min_sev_asid == 1) { + pr_info("Failed to enable SEV-ES as the minimum SEV ASID value is 1.\n"); goto out; + } sev_es_asid_count = min_sev_asid - 1; if (misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count))