Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp539127pxb; Fri, 13 Aug 2021 00:13:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmthIJcnkaLiFRcr0jYo3jhrg1GrMhhEgxkwm3/XdVIwDbTmQq5GHhQoSsEJ69XOA5O+oh X-Received: by 2002:a05:6638:14d:: with SMTP id y13mr981825jao.78.1628838815763; Fri, 13 Aug 2021 00:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628838815; cv=none; d=google.com; s=arc-20160816; b=iMhioOWBDUSFmQzWErJDGszm69PCS2plQy0IvFNg0LulvnDzvk3Q9mQPw8ITu6EHVO OdzgDC6B6E54hJgp5zHac2BLtFMIs3NE9KJKFNwADHllMR3Bln9FZbkGRVs5/+uTe2NB E03hT8Pk9EIBt9WOQpMvq/vYaX94n+uaIzirATcMozBXGlgbGW1/pPjRkf4pm3TX24XH KQNew/jrmfFmWhbdgVRaIMW26lnuD7Q+TOJh1opeEQYrQCZYRK5ys9qgOm9HRlO+C+5B Q6LeMS5f4WXiNWrenS0QImP8X6XlyhcODJDHJAIZGGaCpbLIepeQsHMS0PSGUwEG39zw cu0w== 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:dkim-signature; bh=IJ84Zz7cXD2dARXk2E4si9LSMTMEPXvMGAWxocLB7k8=; b=Wngx8ddOV7xGifySADrZmKDDETUXbNZwmtp/DfER8A1cr33eTgaBOsqELvZ7xlN9NV utw/g98f03pse57UAWptVRbMoiwPQNAQto12lS6bLCA4Yb3FPi1rlFwMlxfWtZDgL07I YW1COYnJLQYNxaugmXZeEbZKogGsvGW57HuvZrSVG4WNeYkp3kNePBht7y8LkI73l0Bj 5X9r9AmYcf/SsmV5mHgdlvqekYiESK8XFnQXlxsVqoEeOu2sWFkGcwky+vJiOvsjStKN V14/m63riwUGjxXg/UBi33fvgEbmMhVcfWoMGAFpcMbtSisWj9rGanoa5nffiPLSI4qb Jdtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=KLPKleY+; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r3si652516jan.7.2021.08.13.00.13.25; Fri, 13 Aug 2021 00:13:35 -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; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=KLPKleY+; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239274AbhHMHMs (ORCPT + 99 others); Fri, 13 Aug 2021 03:12:48 -0400 Received: from forward2-smtp.messagingengine.com ([66.111.4.226]:59575 "EHLO forward2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239230AbhHMHMq (ORCPT ); Fri, 13 Aug 2021 03:12:46 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailforward.nyi.internal (Postfix) with ESMTP id 25FA0194076A; Fri, 13 Aug 2021 03:12:18 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 13 Aug 2021 03:12:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=IJ84Zz7cXD2dARXk2 E4si9LSMTMEPXvMGAWxocLB7k8=; b=KLPKleY+V+TZn7ffDpWBbAMHhDbU5PLd4 CGEukJFWJMJ7zseXMfvCsGkDWVB+JlDZkCvkQXLeWg4dh3neJ1756YodHhm6klEP sEVgh3+3vTpDt8hcQhyB4/vRnrn84CHG1g3FfGtK9lAjlAv4cSR6aGOYqFioCo9B PcjhPSw+vhMMDSl8b0jKttvFway/muwGtKvByqBZuWNShdmX5LP5CeNv1hMwC028 3ZkTBN4i/+hODlDecP30cGFoJyl2ydSItwmqaknnqo+IwdktqMpZEDp1xqN/wHhd c/poT2PtVokLUiSwvZvG1fMWEtgG1RSptilx/u0bPt1PJoODfp6pA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrkeeggdduudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpeffrghvihguucfg ughmohhnughsohhnuceouggrvhhiugdrvggumhhonhgushhonhesohhrrggtlhgvrdgtoh hmqeenucggtffrrghtthgvrhhnpeduhfetvdfhgfeltddtgeelheetveeufeegteevtddu iedvgeejhfdukeegteehheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegurghvihgurdgvughmohhnughsohhnsehorhgrtghlvgdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 13 Aug 2021 03:12:14 -0400 (EDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 94f31bc7; Fri, 13 Aug 2021 07:12:12 +0000 (UTC) From: David Edmondson To: linux-kernel@vger.kernel.org Cc: Jim Mattson , Borislav Petkov , Paolo Bonzini , Vitaly Kuznetsov , "H. Peter Anvin" , Thomas Gleixner , Wanpeng Li , Ingo Molnar , Sean Christopherson , Joerg Roedel , David Matlack , x86@kernel.org, kvm@vger.kernel.org, David Edmondson Subject: [PATCH v4 0/4] KVM: x86: Convey the exit reason, etc. to user-space on emulation failure Date: Fri, 13 Aug 2021 08:12:07 +0100 Message-Id: <20210813071211.1635310-1-david.edmondson@oracle.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To help when debugging failures in the field, if instruction emulation fails, report the VM exit reason, etc. to userspace in order that it can be recorded. The SGX changes here are compiled but untested. Sean: if you want me to add your name to patch 3, given that I adopted your sample code almost unaltered, please say. v4: - Update the API for preparing emulation failure report (Sean) - sgx uses the provided API in all relevant cases (Sean) - Clarify the intended layout of kvm_run.emulation_failure. v3: - Convey any debug data un-flagged after the ABI specified data in struct emulation_failure (Sean) - Obey the ABI protocol in sgx_handle_emulation_failure() (Sean) v2: - Improve patch comments (dmatlock) - Intel should provide the full exit reason (dmatlock) - Pass a boolean rather than flags (dmatlock) - Use the helper in kvm_task_switch() and kvm_handle_memory_failure() (dmatlock) - Describe the exit_reason field of the emulation_failure structure (dmatlock) David Edmondson (4): KVM: x86: Clarify the kvm_run.emulation_failure structure layout KVM: x86: Get exit_reason as part of kvm_x86_ops.get_exit_info KVM: x86: On emulation failure, convey the exit reason, etc. to userspace KVM: x86: SGX must obey the KVM_INTERNAL_ERROR_EMULATION protocol arch/x86/include/asm/kvm_host.h | 10 +++-- arch/x86/kvm/svm/svm.c | 8 ++-- arch/x86/kvm/trace.h | 9 ++-- arch/x86/kvm/vmx/nested.c | 2 +- arch/x86/kvm/vmx/sgx.c | 16 +++----- arch/x86/kvm/vmx/vmx.c | 11 +++-- arch/x86/kvm/x86.c | 73 ++++++++++++++++++++++++++------- include/uapi/linux/kvm.h | 15 ++++++- 8 files changed, 100 insertions(+), 44 deletions(-) -- 2.30.2