Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1757812pxb; Mon, 12 Apr 2021 06:10:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAFs9hcm6bFCtRnZYfUnnM8+R25/o8JlhMvIfsHCfFNCsRPXMrHy5/BAIQrj6/h0vvzzlO X-Received: by 2002:a63:a42:: with SMTP id z2mr26647449pgk.52.1618233037004; Mon, 12 Apr 2021 06:10:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618233036; cv=none; d=google.com; s=arc-20160816; b=HuPRaZOGSgxwgYWdX4FvfaSlfRAfY35gmLjmuUcUgm1Yv5ppjIhYt/GaCVgZFRLZGc ydvKoee9PYbQ2RWVOKuoq8zcPYpYIciAzvbDRsUQz3nXjmUK90AosoRIOSATXF2ykIN0 dEPmU+R7GKedjkyrOgy2s9Y5YJE9Z+0ZWqDhi/5KK6R9Ty6xFRgWX0ToICKDEWGFbOpp Bsy8yY8u4wZAkFQ5/ouBO+PBLC//Ok6VyQwsWKPJ8eKcJcP+Ogbb0aWR1kM8ec3sZdnr XIkgjzv3ElWg+q/JF6vok5ptggbPVZDA6iHd1H0GPYIUKwtvw1MxwLgMaHyPFYUMy4sE MTTQ== 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=HvfGYkD6c6q5bKKXXv71mYB4LVLkTvCXjY38JwER9zY=; b=BRWN5VyknB8Exl8vBMzUQ4sjRT8vUYlMMyNQP6GndDEeMqnSC20hN4DzSgBhPYNVIr ka7zLevqpRpW9Vx5rrtIoxcmaYCUHKCcoB0Arp4FHyCvr/AdAAFi8+0Re9XQ00rLaU6T N0uf+lTFkXKxiEuZsTIYYtVfhCvYSEQUmBqtiGA1ya9nj5XyfFw59zkYtkkfRvyTjQha herJX/EYFSYkXjknu7WlKHIb84iQO0S8c8kgDfTwQmoQCUOUj/nbnli4d9GJRNc37zyc dKPghQCcX1zz+42CZpvtXkkCydB8O+iRBWkUVL18B2XqOTODxKnb9WNtCzkcKebPc72f YzKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=IrmYYw3l; 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 c24si13220366pgh.67.2021.04.12.06.10.23; Mon, 12 Apr 2021 06:10:36 -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=fm2 header.b=IrmYYw3l; 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 S241771AbhDLNKE (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) -- 2.30.2