Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4281953pxk; Tue, 29 Sep 2020 21:20:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBfUs1DsVnFDcfZd0X1qYIZinf7Qy/UAu9GPksAtH+4LgBxyfVZvX/Yg6OoiN6ur+L9BhM X-Received: by 2002:a17:907:2079:: with SMTP id qp25mr924367ejb.186.1601439627848; Tue, 29 Sep 2020 21:20:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601439627; cv=none; d=google.com; s=arc-20160816; b=jaKxVtcgN0eyQJ9HcD2HZKcxOct27aFoxAtVc1T6egFwFeHycmnGaca6n/i1c/5rkJ v0hlbuGZqQFLX5OJsFXIX/g6+e7/8eC2uc4kKmTK1wlGD1dLhldKIQubCKpO3DVroDdz Dw/8dmrJ7ItgFKDWDmU+/1Q4Tg882RG4OoQdb3VTqgrFE/kfyZPuiKn9XKJcsj1hxV0/ YCE7KPHtmleH/gOKP5w4jPOb+YNk0r/ut5zrG/aheL+X8o12dUCwBGEP/LK+s+DSjnzN fkiIz+LyZuJTui3rZ4glOG5qDWJvyv7dmWKhoMgp+G6bbp4o7tzvagQjcEtB0kPzdBC1 zpOw== 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=FDTSYtoHFLunBmGC9ypO/3qvDQB0sKtMwLN0ExQrS90=; b=vYxn+dI3sHsnNCYPEx3jO38x8/lLHo+cU3IVseOBKxVT0eiDySLVt3rmkCSu7kafx7 Je19GBki66S0g5Asmoh2GjltPz6Bmcjyy+el8BrW8YeORkKGUbCtA48QHKIStJ0+M7oo HEICUeQ+lYblTpHv9TxBSD3avdbphbGqeFEyiY0CXUsNDXV4cn6g2gI7Rei695ZFXlEu mHTPIAD4w+QBwgH9eJnVEEqpo419rmezfRcyX3gFFr/7uUpeILoCycVpo5LMuH1xf7eU uztv6Jbc/i7JojTG9WqUjuuoHI1r/3avqWtsUWD81EqQstJRJ9JmK8L8uradWFQzOdTc cdKw== 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 u3si250442edp.313.2020.09.29.21.20.04; Tue, 29 Sep 2020 21:20:27 -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 S1725801AbgI3ERD (ORCPT + 99 others); Wed, 30 Sep 2020 00:17:03 -0400 Received: from mga18.intel.com ([134.134.136.126]:60793 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725306AbgI3ERD (ORCPT ); Wed, 30 Sep 2020 00:17:03 -0400 IronPort-SDR: yP2s851zwsADPoqTbfxmReqQ3cF3nFVRqxVDbSJ/VzGwIRDIDzsUI9IQ/7SX+rowT2AGgm1ove EZ7BPTq45oKg== X-IronPort-AV: E=McAfee;i="6000,8403,9759"; a="150137442" X-IronPort-AV: E=Sophos;i="5.77,321,1596524400"; d="scan'208";a="150137442" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2020 21:17:02 -0700 IronPort-SDR: lP4CQa/l4bbc0mzz+ZwM7GnfsFmbuqynTTtO0n5TUvHt0elDV/NUxmWFCNaJzCrM49UE0mXyfN 13vH5TGP9uPQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,321,1596524400"; d="scan'208";a="415607859" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.160]) by fmsmga001.fm.intel.com with ESMTP; 29 Sep 2020 21:17:01 -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, Lai Jiangshan , Lai Jiangshan Subject: [PATCH 0/5] KVM: x86: Handle reserved CR4 bit interception in VMX Date: Tue, 29 Sep 2020 21:16:54 -0700 Message-Id: <20200930041659.28181-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 This series stems from Lai's RFC patches to intercept LA57 and let the guest own FSGSBASE[*]. Discussion and inspection revealed that KVM does not handle the case where LA57 is supported in hardware but not exposed to the guest. This is actually true for all CR4 bits, but LA57 is currently the only bit that can be reserved and also owned by the guest. I have a unit test for this that I'll post separately. Intercepting LA57 was by far the easiest fix for the immedidate bug, and is likely the right change in the long term as there's no justification for letting the guest own LA57. The middle three patches adjust VMX's CR4 guest/host mask to intercept reserved bits. This required reworking CPUID updates to also refresh said mask at the correct time. The last past is Lai's, which let's the guest own FSGSBASE. This depends on the reserved bit handling being in place. Ran everything through unit tests, and ran the kernel's FSGSBASE selftests in a VM. [*] https://lkml.kernel.org/r/20200928083047.3349-1-jiangshanlai@gmail.com Lai Jiangshan (2): KVM: x86: Intercept LA57 to inject #GP fault when it's reserved KVM: x86: Let the guest own CR4.FSGSBASE Sean Christopherson (3): KVM: x86: Invoke vendor's vcpu_after_set_cpuid() after all common updates KVM: x86: Move call to update_exception_bitmap() into VMX code KVM: VMX: Intercept guest reserved CR4 bits to inject #GP fault arch/x86/kvm/cpuid.c | 6 +++--- arch/x86/kvm/kvm_cache_regs.h | 2 +- arch/x86/kvm/vmx/vmx.c | 18 +++++++++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) -- 2.28.0