Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3021204rwb; Mon, 15 Aug 2022 16:18:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR4yLD/MAbkVQhPkSZB/DRDy6ZAwlm1kwz/eTddVSxV3OKdyYMr7WqyevsE0et1JNOjXjjm8 X-Received: by 2002:a05:6a00:850:b0:52e:d1c1:df48 with SMTP id q16-20020a056a00085000b0052ed1c1df48mr18276139pfk.75.1660605507488; Mon, 15 Aug 2022 16:18:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605507; cv=none; d=google.com; s=arc-20160816; b=n0x78f+MDujEQX6XLSGuevLk4ZjK075acuTRYCawZjuWkvNj42xItwWIqVxa/k2+5i CCUxR3urOezqXa4sjV7lEAmr1yVOT1MynTaYpcR+ogh35+wq76CvueAijE4XT1HDrFRI fM1MuTN7rk5OBuWiyzHp1mNGieb0wqzRwgGHLSjAHREThl5FYZEs/5wOzr6LIsC5Inar gucz5ilpY9GNTGFog+MncBwjhtoTXT58Wzr+0WwJPoZhqsDJDz/TZLqYo4TcTyK/MTd8 vhXHZoBpheFDw886vgqHj9g+wMF7QvjdmmbzK1ibMJuo9UfEZ7zXk0zKnH2viDzz5BUB D7Sg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d7Zq4y4VKGZUycGBqq2N4fn7CRRgu8vC6CvrFtnUDJM=; b=R0wbb/sz1Dgl3KXqpjTgnQEjYIjk7zaZhtmJOhkf3xvtXO9P0n1eHNUp17Hkog5wQU q9c3WRpWMdtDfZG3lM2C3Gl5xFzY9s1ckByUwDlR43m0U/KDaGdbVv9Z5ttj9ZOv1VeE h+v3nDULwsfbfk8ws0LhsxR0MB+2AeijxGR1Up8n8a4G5VP0AopVfm0hR0JGh33+h44G Dm6srwP4qpXlHHwL+3BWRhFFeChGLGJ9Ln+L+GnPjoOoD21mVS012PocjAsPy0Yz34Xn RckPwucKukUHDQY/p+TXPMvQYt0TjEFrIN0E24UkBPncZhCI8oEbgSgiTmz1McQZZXAN NiCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vR0eogVi; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 23-20020a630217000000b0041cefab5b61si11795947pgc.719.2022.08.15.16.18.16; Mon, 15 Aug 2022 16:18:27 -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=@linuxfoundation.org header.s=korg header.b=vR0eogVi; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349043AbiHOVyV (ORCPT + 99 others); Mon, 15 Aug 2022 17:54:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350505AbiHOVva (ORCPT ); Mon, 15 Aug 2022 17:51:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8461910650A; Mon, 15 Aug 2022 12:32:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B971C60FB9; Mon, 15 Aug 2022 19:32:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB774C433C1; Mon, 15 Aug 2022 19:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591970; bh=F+IUHW4HbX9SiRh8h0ul58D2aCwIe0rryQCeCZm0uYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vR0eogViHFZEpdDJMOT31uJWc3dDkpgT7EbJVgAkb5O1UOWme1eY3NZitLJ1dc/6Q ecwLH7wYscnU6ALN/BkEgZtwVqGtNTTvpjBRO9u4CWYG6v59BYay98+nN71rhUlfgr BQbO7Ttr4+eR3vw4rTGYi3RHepfVOWa9YnZhBCUI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini Subject: [PATCH 5.19 0038/1157] KVM: x86/mmu: Treat NX as a valid SPTE bit for NPT Date: Mon, 15 Aug 2022 19:49:54 +0200 Message-Id: <20220815180440.965453015@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Sean Christopherson commit 6c6ab524cfae0799e55c82b2c1d61f1af0156f8d upstream. Treat the NX bit as valid when using NPT, as KVM will set the NX bit when the NX huge page mitigation is enabled (mindblowing) and trigger the WARN that fires on reserved SPTE bits being set. KVM has required NX support for SVM since commit b26a71a1a5b9 ("KVM: SVM: Refuse to load kvm_amd if NX support is not available") for exactly this reason, but apparently it never occurred to anyone to actually test NPT with the mitigation enabled. ------------[ cut here ]------------ spte = 0x800000018a600ee7, level = 2, rsvd bits = 0x800f0000001fe000 WARNING: CPU: 152 PID: 15966 at arch/x86/kvm/mmu/spte.c:215 make_spte+0x327/0x340 [kvm] Hardware name: Google, Inc. Arcadia_IT_80/Arcadia_IT_80, BIOS 10.48.0 01/27/2022 RIP: 0010:make_spte+0x327/0x340 [kvm] Call Trace: tdp_mmu_map_handle_target_level+0xc3/0x230 [kvm] kvm_tdp_mmu_map+0x343/0x3b0 [kvm] direct_page_fault+0x1ae/0x2a0 [kvm] kvm_tdp_page_fault+0x7d/0x90 [kvm] kvm_mmu_page_fault+0xfb/0x2e0 [kvm] npf_interception+0x55/0x90 [kvm_amd] svm_invoke_exit_handler+0x31/0xf0 [kvm_amd] svm_handle_exit+0xf6/0x1d0 [kvm_amd] vcpu_enter_guest+0xb6d/0xee0 [kvm] ? kvm_pmu_trigger_event+0x6d/0x230 [kvm] vcpu_run+0x65/0x2c0 [kvm] kvm_arch_vcpu_ioctl_run+0x355/0x610 [kvm] kvm_vcpu_ioctl+0x551/0x610 [kvm] __se_sys_ioctl+0x77/0xc0 __x64_sys_ioctl+0x1d/0x20 do_syscall_64+0x44/0xa0 entry_SYSCALL_64_after_hwframe+0x46/0xb0 ---[ end trace 0000000000000000 ]--- Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20220723013029.1753623-1-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/mmu/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -4567,7 +4567,7 @@ reset_tdp_shadow_zero_bits_mask(struct k if (boot_cpu_is_amd()) __reset_rsvds_bits_mask(shadow_zero_check, reserved_hpa_bits(), - context->root_role.level, false, + context->root_role.level, true, boot_cpu_has(X86_FEATURE_GBPAGES), false, true); else