Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp63827pxu; Tue, 6 Oct 2020 19:00:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJV7lClqimy00Qm8Qmtja/EiaKfCCpnRmkZpdnVAk0BwRkFEzsPIvVngL/X9aVuovdeqzO X-Received: by 2002:a05:6402:207c:: with SMTP id bd28mr1059450edb.316.1602036006255; Tue, 06 Oct 2020 19:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602036006; cv=none; d=google.com; s=arc-20160816; b=WgaGrgiZlBX5Vpkr496/owxKf0d4FPNl/zj+KB8Nr3Kgto44wTzhv5JNICcsyBwVlq VqXgldnETdZ2cp7hP4v6kOTXym5uIL/tYcZaE0ufcfI3f7puhPfufndkKOE/0jxr4zL4 7jxeYMc/+8xiMgad0ivW712OsX6wXr/o/yxpXA4FexiuOdaghs3p1YEOwj7+Ts5cyXPc LCWKfsApJlh6+P1CE+mHO71SPyv5VugXBZYAY13IdRVqjeVgqpwOwjKuLEhPr6cnSB8S G6k9ZBI1dUyQsr5JaY9Dd8sjQ6BLkXN/+MAWbzWvp24BDdjOuUx3bPd9FlBfJkD0P67G wGbg== 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 :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=2/bRgrHgYc7h5X452ZPwehfSEbnD5HBYHu20ShWkI3I=; b=IOah6cLM0NbAYD9MBWHsRRELOSJ7xrTHQxyDgq3hVAYzvnNQ9I3kf1l7yaZSzolZ5f Bb0+RngPCkbbUfqEh/wgXeI0wCwLs0KybKhDz5Dls+tXxPBa2NiWW/m7fcOnUhspAEp0 89NQepBZ9xE6krzgdgI9ltfWKpmFKZ36hfNYjvUfoIn9KWrz7Opj6ro4TIPBS1XOxZOB U4kps0nwpBB+MA7Utvha3iCew+WbuXn3S1tV7uEOM/dWQOTKXJLzBZrCqUvx9JDAEZ0O mV5nlewrUIYlmnhByoCkKu5WGd142HUjRvrNgvcoGmlL7i0JtGE0mVs6Iyz9lM6IvHDX T2PA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oc24si414783ejb.530.2020.10.06.18.59.41; Tue, 06 Oct 2020 19:00:06 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727069AbgJGBoT (ORCPT + 99 others); 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