From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EB39C4363D for ; Wed, 7 Oct 2020 01:44:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2599920782 for ; Wed, 7 Oct 2020 01:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727183AbgJGBoT (ORCPT ); Tue, 6 Oct 2020 21:44:19 -0400 Received: from mga09.intel.com ([134.134.136.24]:7786 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbgJGBoT (ORCPT ); Tue, 6 Oct 2020 21:44:19 -0400 IronPort-SDR: VoyZ/K2RKGL7K/1W/VtnQlAfNA1ewa2myzY3VJNqqkRkV8MKWgooDw8gT/u1UDsute5/P/INoU Fjq7Nn0iPIIA== X-IronPort-AV: E=McAfee;i="6000,8403,9766"; a="164914594" X-IronPort-AV: E=Sophos;i="5.77,344,1596524400"; d="scan'208";a="164914594" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2020 18:44:18 -0700 IronPort-SDR: QPTpCXDbpGbu6qD+HFtns6yMfN22f+KJcQgpbAfbRrLy6DfIPy/g07l97PC9VS/cMfGoFbGEii lRi9br9NlMaA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,344,1596524400"; d="scan'208";a="297410294" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.160]) by fmsmga008.fm.intel.com with ESMTP; 06 Oct 2020 18:44:17 -0700 From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Stas Sergeev Subject: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup Date: Tue, 6 Oct 2020 18:44:11 -0700 Message-Id: <20201007014417.29276-1-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Two bug fixes to handle KVM_SET_SREGS without a preceding KVM_SET_CPUID2. The overarching issue is that kvm_x86_ops.set_cr4() can fail, but its invocation from __set_sregs(), a.k.a. KVM_SET_SREGS, ignores the result. Fix the issue by moving all validity checks out of .set_cr4() in one way or another. I intentionally omitted a Cc to stable. The first bug fix in particular may break stable trees as it simply removes a check, and I don't know that stable trees have the generic CR4 reserved bit check that is needed to prevent the guest from setting VMXE when nVMX is not allowed. Sean Christopherson (6): KVM: VMX: Drop guest CPUID check for VMXE in vmx_set_cr4() KVM: VMX: Drop explicit 'nested' check from vmx_set_cr4() KVM: SVM: Drop VMXE check from svm_set_cr4() KVM: x86: Move vendor CR4 validity check to dedicated kvm_x86_ops hook KVM: x86: Return bool instead of int for CR4 and SREGS validity checks KVM: selftests: Verify supported CR4 bits can be set before KVM_SET_CPUID2 arch/x86/include/asm/kvm_host.h | 3 +- arch/x86/kvm/svm/nested.c | 2 +- arch/x86/kvm/svm/svm.c | 12 ++- arch/x86/kvm/svm/svm.h | 2 +- arch/x86/kvm/vmx/nested.c | 2 +- arch/x86/kvm/vmx/vmx.c | 35 +++---- arch/x86/kvm/vmx/vmx.h | 2 +- arch/x86/kvm/x86.c | 28 +++--- arch/x86/kvm/x86.h | 2 +- .../selftests/kvm/include/x86_64/processor.h | 17 ++++ .../selftests/kvm/include/x86_64/vmx.h | 4 - .../selftests/kvm/x86_64/set_sregs_test.c | 92 ++++++++++++++++++- 12 files changed, 153 insertions(+), 48 deletions(-) -- 2.28.0