From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.15 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796280853; b=VJO4Ue2PNH1CpVkG30CpF2Y3wd/aDW/J6WnUPtWbm0fNpuWzSxhe0nkwCxx6rQDJc7/u /WQaSBLaAr4pcsSnCZma5f40Z0n9eDEIwKLLF5Y/J7pIHPEap0EjDP1ELg4I9vD2/rE45 f0fPg4hOLhR/eoUFugjQLpWnQYQOeB1fe3h3qIVE/aDFvtKqEMVlAfKPx2vrvsuMxIxoD LEcGis80TUFzqY76RPvR+27GynLuu9f/xJEBMZpRyzqu85FdiSsQ95QCzAZw9bz6Q3m89 yIA0snm0dUziI/9Te78RAmrEDKzoZJcMNF7t9+22rj0dHBWTRZqbL9abTr6QLt+Y3HA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796280853; 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=yHG6TCIPANPLM4rX6dh638TVaKrDskYluLai4SRkqac=; b=LHYn+adE3C3259xWSI9bUg27h4ZVVWBysAm3mUH/xOki9WzSLzweIpnCQSZ4F9dbpRLX fOKyBkxzdcWwKQJFRSax/p2FAQJ4TjAQqmQS2RPhlhg7iHr5ajSWxXCTzTMXmAqG+GA9r p+TL1clK9X9nVOjrSNUi16rsyCqVOrCarJgXfq4fZoaKvPcI5/jp2mC4tbeZOYxdP2BAD 2E2nOAuyoKHSiYsY5QopMyUpi+Z/8+b9gD0XpAmC0Pc3eIBBozP3dS3Y3PALxVumUYLud XiIPL0oDmx4jdFvsFj4BiojlaSm9Pt2PAg12cDJ2z9usQK4UDG1H7kQbxwAtfhyvxrg== 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=CkMEJsfV; arc=none smtp.remote-ip=198.175.65.15 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 26EBB606A322; Thu, 3 Dec 2026 06:54:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 26EBB606A322 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=CkMEJsfV DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796280852; x=1827816852; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=yHG6TCIPANPLM4rX6dh638TVaKrDskYluLai4SRkqac=; b=CkMEJsfVZBq4FQS9xZ47jXYECBtU/QQA16lORFoP5KCw2FAeazh2V21C wFpmCulOdLrWXJWNbZOXgGJz6+ZBABFsk6nX/XmxrW5eFbjFgE9iogA8I TV4i3abA+kPer3SVw/VCGC9Dr4J6eb+BhFWFYMTclNOD4FNYeKykbYKU6 n59uUph8Ca934wV7s+ZguU24sZbOvKMTX/94lPDOW4mMRT+ilGZoCu2up Xo+VHVN3k1KXQRJYrFncmVpJPnykrvqQAY1A4m/CsoyFFnWXBPQk5T/HK zFojFwzK4Pv67PGHoh4ed+Dw4k4pxTZsKVaLm0t6cvv2CTihXeLXYvyES A==; X-CSE-ConnectionGUID: HipzoXIyQTWk9M6A8KrwEA== X-CSE-MsgGUID: Ma9g2mIGS1uR2/9jng3X8Q== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5223556" X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="5223556" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 22:54:11 -0800 X-CSE-ConnectionGUID: Nsj1V5i3Q2CgN9yIr0lDZA== X-CSE-MsgGUID: q+t1eUfWRwGzfM1VDoaroQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="14056222" Received: from sohilmeh.sc.intel.com ([172.25.103.65]) by fmviesa006.fm.intel.com with ESMTP; 02 Dec 2026 22:54:11 -0800 From: Sohil Mehta To: kvm@vger.kernel.org Cc: Paolo Bonzini , Sean Christopherson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Xin Li , Shivansh Dhiman , David Woodhouse , Chao Gao , Binbin Wu , Sohil Mehta , "Chang S . Bae" , Zhao Liu , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/3] KVM: VMX: Support the secondary VM-exit controls Date: Wed, 2 Dec 2026 22:51:46 -0800 Message-ID: <20261203065149.2952509-1-sohil.mehta@intel.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-kernel@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 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. This series focusses on getting the secondary VM-exit controls support in place independent of FRED. Preferably, it 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 v2 ------------- - Split the pair check into "all supported" and "none supported" cases, which also covers a pair with several entry controls (Sean) [patch 2] - Lead the changelogs with a small summary of changes (Chang) [patches 1, 2] - Pick up Chang's review tag [patch 3] v1: https://lore.kernel.org/lkml/20261126022743.4082392-1-sohil.mehta@intel.com/ Background ---------- 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. Binbin, I have kept your review tag since most of the changes are minor. The only significant change on top of FRED KVM v10 is the vmcs02 handling described below. 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. The patches are based on the kvm-x86/next branch (kvm-x86-next-2026.11.11). 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/ 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/nested.c | 3 ++ arch/x86/kvm/vmx/vmcs.h | 1 + arch/x86/kvm/vmx/vmx.c | 52 +++++++++++++++++++++++++++++--- arch/x86/kvm/vmx/vmx.h | 7 ++++- 7 files changed, 68 insertions(+), 5 deletions(-) base-commit: cbe54fc3462b3949ab27b9ae81fb9ddb509040c7 -- 2.43.0