From patchwork Mon Apr 12 13:09:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Edmondson X-Patchwork-Id: 12198017 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.7 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 7E05AC433B4 for ; Mon, 12 Apr 2021 13:09:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39BBF61356 for ; Mon, 12 Apr 2021 13:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241773AbhDLNKE (ORCPT ); Mon, 12 Apr 2021 09:10:04 -0400 Received: from wforward5-smtp.messagingengine.com ([64.147.123.35]:50317 "EHLO wforward5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241762AbhDLNKD (ORCPT ); Mon, 12 Apr 2021 09:10:03 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailforward.west.internal (Postfix) with ESMTP id DD56F166C; Mon, 12 Apr 2021 09:09:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 12 Apr 2021 09:09:44 -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=fm2; bh=HvfGYkD6c6q5bKKXX v71mYB4LVLkTvCXjY38JwER9zY=; b=IrmYYw3lKD9YPFcY2YObOjK5hmSskK1No 0Pi4pNblwsWnnkPrVssJO2q/n2ekOtwhLKj0sBZG3J0pudk2S1rZva27+rU1uc7o nXofXjBsUzQ7a1sKJeqLAluYIeVfa20lWlOl5GvCRJi7FTQ300iVg4AGhDG1Szmi USX5p8jfP94K2I5o2iFnvgIXWMyjhCpZqO8hCHzvSSh5NMxyhpU973b2PffQbQKL nX10/wh3nbsbd9Mc5gPvxegPomaTckCUozd9ubX5BLWhrLFoKrDYLMa4Lb75g4mP MgRpkndHPnvdpQpuMbfGFb1BP40EuslaoBTCeQLT0Cp+gnADOeoZA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudekjedgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpeffrghvihguucfg ughmohhnughsohhnuceouggrvhhiugdrvggumhhonhgushhonhesohhrrggtlhgvrdgtoh hmqeenucggtffrrghtthgvrhhnpefhfedtieevleetueeukeffvdfffeeigfdtvdffgeei tdegfeffleeihfevtdekfeenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecukfhppe ekuddrudekjedrvdeirddvfeeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghm pehmrghilhhfrhhomhepuggrvhhiugdrvggumhhonhgushhonhesohhrrggtlhgvrdgtoh hm X-ME-Proxy: Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net [81.187.26.238]) by mail.messagingengine.com (Postfix) with ESMTPA id A83D91080067; Mon, 12 Apr 2021 09:09:39 -0400 (EDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id d55ec073; Mon, 12 Apr 2021 13:09:38 +0000 (UTC) From: David Edmondson To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov , "H. Peter Anvin" , x86@kernel.org, Sean Christopherson , Thomas Gleixner , Joerg Roedel , Wanpeng Li , Borislav Petkov , Jim Mattson , Ingo Molnar , David Edmondson Subject: [PATCH 0/6] KVM: x86: Make the cause of instruction emulation available to user-space Date: Mon, 12 Apr 2021 14:09:31 +0100 Message-Id: <20210412130938.68178-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 Instruction emulation happens for a variety of reasons, yet on error we have no idea exactly what triggered it. Add a cause of emulation to the various originators and pass it upstream when emulation fails. Joao originally produced the patches but is busy with other things and I wanted to use it, so picked it up. Tested by reverting commit 51b958e5aeb1e18c00332e0b37c5d4e95a3eff84 ("KVM: x86: clflushopt should be treated as a no-op by emulation") then running the test included in https://lore.kernel.org/r/20201118121129.6276-1-david.edmondson@oracle.com. Joao Martins (6): KVM: x86: add an emulation_reason to x86_emulate_instruction() KVM: x86: pass emulation_reason to handle_emulation_failure() KVM: x86: add emulation_reason to kvm_emulate_instruction() KVM: x86: pass a proper reason to kvm_emulate_instruction() KVM: SVM: pass a proper reason in kvm_emulate_instruction() KVM: VMX: pass a proper reason in kvm_emulate_instruction() arch/x86/include/asm/kvm_host.h | 27 +++++++++++++++++++++++-- arch/x86/kvm/mmu/mmu.c | 4 ++-- arch/x86/kvm/svm/avic.c | 3 ++- arch/x86/kvm/svm/svm.c | 26 +++++++++++++----------- arch/x86/kvm/vmx/vmx.c | 17 ++++++++-------- arch/x86/kvm/x86.c | 35 ++++++++++++++++++++++----------- arch/x86/kvm/x86.h | 3 ++- 7 files changed, 78 insertions(+), 37 deletions(-)