From patchwork Thu Jul 29 13:39:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Edmondson X-Patchwork-Id: 12408785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41D98C4338F for ; Thu, 29 Jul 2021 13:46:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26AB260EBC for ; Thu, 29 Jul 2021 13:46:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237738AbhG2NqO (ORCPT ); Thu, 29 Jul 2021 09:46:14 -0400 Received: from wforward5-smtp.messagingengine.com ([64.147.123.35]:47365 "EHLO wforward5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237665AbhG2NqK (ORCPT ); Thu, 29 Jul 2021 09:46:10 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailforward.west.internal (Postfix) with ESMTP id A42641AC0859; Thu, 29 Jul 2021 09:39:42 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 29 Jul 2021 09:39:43 -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=JjfAbX1pq79BhH/GJ ozIKahQKClhEXVcaFzB6MBJv38=; b=NNSX6bKm3/DuXkmc+nN6bQYRz3OBLW0ld PknxVOFEev5n/ToLoUjxnZoa3VX7vbrlVFNb9/0u1HCnnK6tJdhDoIq+oa/C5VzG N4dkyxFC/BAIlVrzHarBtkraDzE4z5D8c+Dq1lYOljpO6ilB1zmIJAuZjIFnnlPA iB4u4g6toaOeTQPmu75ZTlNCK3/XopvNkma/kBF0utRT54GF/iuFLvidnG4Pw+30 /seeOCFITbE4iHBTMqyVMX5xe5gfiRRUqm7EMwUkoxAsEW7hFPV7V66dqdZyvhBD i+nJg097f/HhqaPE3+Ah4euBlJnN+jc8k1so5gh3MGIfXFxIjlILg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrheefgddviecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepffgrvhhiugcugfgu mhhonhgushhonhcuoegurghvihgurdgvughmohhnughsohhnsehorhgrtghlvgdrtghomh eqnecuggftrfgrthhtvghrnhepudfhtedvhffgledttdegleehteevueefgeetvedtudei vdegjefhudekgeetheehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepuggrvhhiugdrvggumhhonhgushhonhesohhrrggtlhgvrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Jul 2021 09:39:33 -0400 (EDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id c4c7ebe7; Thu, 29 Jul 2021 13:39:32 +0000 (UTC) From: David Edmondson To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Joerg Roedel , Ingo Molnar , Jim Mattson , kvm@vger.kernel.org, Borislav Petkov , David Matlack , Paolo Bonzini , "H. Peter Anvin" , x86@kernel.org, Wanpeng Li , Vitaly Kuznetsov , Sean Christopherson , David Edmondson Subject: [PATCH v3 0/3] kvm: x86: Convey the exit reason, etc. to user-space on emulation failure Date: Thu, 29 Jul 2021 14:39:28 +0100 Message-Id: <20210729133931.1129696-1-david.edmondson@oracle.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org To help when debugging failures in the field, if instruction emulation fails, report the VM exit reason to userspace in order that it can be recorded. Sean: hopefully this is something like what you intended. If not, please clarify and I will have another go. The lack of an ABI for the debug data does feel messy. The SGX changes here are compiled but untested. 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 (3): KVM: x86: kvm_x86_ops.get_exit_info should include the exit reason 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 | 12 ++++++-- arch/x86/kvm/svm/svm.c | 8 +++-- arch/x86/kvm/trace.h | 11 +++---- arch/x86/kvm/vmx/nested.c | 2 +- arch/x86/kvm/vmx/sgx.c | 8 ++--- arch/x86/kvm/vmx/vmx.c | 11 ++++--- arch/x86/kvm/x86.c | 53 ++++++++++++++++++++++++++------- include/uapi/linux/kvm.h | 7 +++++ 8 files changed, 79 insertions(+), 33 deletions(-)