Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796366931; b=S5QYSOioj1WEpUkulrKsKhN+Is7LWbmkCiKZXZHihQr+hueTjwIXBu4g+qI77FiwpPv4 Vnxtvl3jizlx2eDxYChfDZSOj8Ue4deUfcAq04pkgkw6VefC5jaPAzoK7h6s0A86dGwxd pwTi2wGI9FdwpzL3k2JvMEWc8xhafdoECXpj9gKuZ/5ZDZs2lQa7U2lr6Zmd3LWnWGcIJ 2gQfFOwNaEyt5kxtkUFMKVGHr/QLiqLsojXFe2c/ESm66ZOjRbKaFbKnxh18ARJLVS7XC Ov0WNLZ/pCmUutojRvHCKxZ+/SrM9JbTTo977kCEfhnF9NBUJLzV34jOr4UK9Jf5FGg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796366931; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=UlHiBBW6n688VkxPVDKNhp0EPNdpEXDA/LgxF736v1g=; b=sbSM4tAchqLKnVPlqdnu/TfpGRZQnK+eq9NCSss+mphHFmGy334rrbaTJXj4sCHFYyY4 uXK+z8YOornPg+J0FVRqIy2EyFCJB/HuFvBDRNfQ0gTv8tpVnr0PmHDs6Jzea2RilVcVl 4FsMw1yqaUkrySZO0IKsgDsz86Ty4zX3S4vP4V06bhzT9F0NlQ0IQuyzVt3dWyJ5gAbj1 tNv7yn970uxTvOIriquHb1uZ9LWYNuibDx0wb3RdpuFzUjiPh2uAEYwScGc7AyfdwCrev LFXXplCYJn/5RLJPdBrp+NTj52XW/T/ZskoE19wiv1qqhNe5IjP0b8Q4ptoMRwf8DlQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=SK6yno3K; arc=none smtp.remote-ip=192.198.163.18 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3598606A322; Fri, 4 Dec 2026 06:48:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F3598606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=SK6yno3K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796366931; x=1827902931; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=UlHiBBW6n688VkxPVDKNhp0EPNdpEXDA/LgxF736v1g=; b=SK6yno3Kv61v9y/0e+mMUAuWpoufh5/W6meA5PkxJCrzdaG08+pRsjw/ dCLpszQN40qVBPMPTQ0lYhlvXQlnHWvjl5azw+xWPndZbb+BU/5leH+0O y6j0uvlL2clGwSSJo1XlJMnWiEx7SHUNG1ScnB6YgDDG9eOv3MKFj8dz+ umMNHrrSalWgNolxRgjZnMmG2XE/3bATauQaUck9+t7/uVWlIaPFmPual UpHQPFyLvq8nxnswf5X3onVdviIQS0C7SpoELLuEumMOSwW+lWNp4cuxy nEgMuNuRJTlu59o0y/6K4egFDisBTtf2GFEuCul1dVr4veRCh8MEg8AQF Q==; X-CSE-ConnectionGUID: Du+c7tTqRReZnP/RnXFzGQ== X-CSE-MsgGUID: WmDt1L/UR4WsoGj0Jv3Aew== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5353837" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5353837" Received: from fmviesa012.fm.intel.com ([10.60.135.152]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 22:48:50 -0800 X-CSE-ConnectionGUID: mEkumKYLQwOVb7Vw+P7bYg== X-CSE-MsgGUID: hA+kuiI8SrCrV/CvLb7pRA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="15659834" Received: from sohilmeh.sc.intel.com ([172.25.103.65]) by fmviesa012.fm.intel.com with ESMTP; 03 Dec 2026 22:48:49 -0800 From: Sohil Mehta To: kvm@vger.kernel.org, Sean Christopherson Cc: Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Xin Li , Shivansh Dhiman , David Woodhouse , Chao Gao , Binbin Wu , Vitaly Kuznetsov , Sohil Mehta , "Chang S . Bae" , Zhao Liu , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/3] KVM: VMX: Support the secondary VM-exit controls Date: Thu, 3 Dec 2026 22:46:31 -0800 Message-ID: <20261204064634.1569133-1-sohil.mehta@intel.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This series puts the secondary VM-exit controls support in place (independent of FRED). The patches are mature and ready for maintainer review. Preferably, they can be merged into the KVM tree separately. Otherwise, I'll place the patches at the beginning of the FRED series for a combined merge. Changes in v3 ------------- - Rebase onto the latest kvm-x86/next (kvm-x86-next-2026.12.03) - Clear the secondary exit controls when KVM is running on Hyper-V [patch 1] - Give Sean's reason for the separate pair table [patch 1] - Spell out how FRED uses both exit controls [patch 2] - Pick up review tags from Chao and Binbin v2: https://lore.kernel.org/lkml/20261203065149.2952509-1-sohil.mehta@intel.com/ Background ---------- Some of these patches started out as part of the FRED KVM series [1]. I am working towards getting the core infrastructure pieces ready first then the FRED guest support followed by the nested FRED support. The secondary VM-exit controls are a 64-bit VMCS field, activated by bit 31 of the primary VM-exit controls. The SDM defines four of them so far: "save FRED", "load FRED", "load IA32_SPEC_CTRL" and "prematurely busy shadow stack". With this series, KVM discovers the field and programs it in vmcs01 and vmcs02, so that FRED or any other user of these controls only has to set its own bits later on. Patches ------- Patch 1 adds the support for the secondary VM-exit controls. Patch 2 fixes an issue reported by sashiko related to the entry/exit pair checking [2] and patch 3 adds the new field to the VMCS dump. The last two patches are optional, but they help complete the support. vmcs02 issue ------------ KVM seeds vmcs02's VM-exit controls from vmcs01's, so vmcs02 inherits bit 31 but not the secondary controls themselves. vmcs02 then runs with the secondary controls active but empty, which is harmless only while every bit is clear. Once FRED sets its controls in vmcs01, vmcs02 also inherits FRED's VM-entry control. Entering any L2 loads FRED state, but the exit from L2 doesn't restore the host's. Until the next VM entry the host runs with a zeroed FRED configuration, and any event in that window hangs the CPU. This isn't specific to FRED, any future secondary VM-exit control would likewise be silently off whenever an L2 runs. Testing ------- This was tested on a FRED capable system with FRED enabled as well as fred=off. The CPU enumerates all four secondary VM-exit controls (IA32_VMX_EXIT_CTLS2 = 0xf), so KVM activates the field in vmcs01 and copies it into vmcs02, with every bit clear. A debug dump_vmcs() on first VM exit from vmcs01 and from vmcs02 shows the same controls in both: ExitControls=0x902befff SecondaryExitControls=0x0000000000000000 KVM selftests and kvm-unit-tests show no regressions. Patch 2's new check was also tested with the upcoming FRED guest support, whose pair has two exit controls. KVM keeps the pair when all three controls are supported and rejects it when any one is forced off. Links ----- [1]: https://lore.kernel.org/lkml/20260911213659.2025974-2-sohil.mehta@intel.com/ [2]: https://lore.kernel.org/lkml/20260911220046.1A4A91F000FF@smtp.kernel.org/ Previous versions ----------------- v2: https://lore.kernel.org/lkml/20261203065149.2952509-1-sohil.mehta@intel.com/ v1: https://lore.kernel.org/lkml/20261126022743.4082392-1-sohil.mehta@intel.com/ Sohil Mehta (1): KVM: VMX: Treat partial support of an entry/exit pair as inconsistent Xin Li (Intel) (2): KVM: VMX: Support the secondary VM-exit controls KVM: VMX: Dump the secondary VM-exit controls in dump_vmcs() arch/x86/include/asm/msr-index.h | 1 + arch/x86/include/asm/vmx.h | 3 ++ arch/x86/kvm/vmx/capabilities.h | 6 ++++ arch/x86/kvm/vmx/hyperv_evmcs.h | 2 ++ arch/x86/kvm/vmx/nested.c | 3 ++ arch/x86/kvm/vmx/vmcs.h | 1 + arch/x86/kvm/vmx/vmx.c | 52 +++++++++++++++++++++++++++++--- arch/x86/kvm/vmx/vmx.h | 7 ++++- arch/x86/kvm/vmx/vmx_onhyperv.c | 1 + 9 files changed, 71 insertions(+), 5 deletions(-) base-commit: 4c9f462c7094c480144c98a942af7e935fa87a6a -- 2.43.0