Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4531574pxv; Tue, 6 Jul 2021 03:16:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO87DBFCJfxn4Qh7Kk3JmBqUrWZc+RMqT9FfqUHtN7OR6dAVN61Rb2/a6civREsEPUiL3m X-Received: by 2002:aa7:c352:: with SMTP id j18mr21825122edr.67.1625566582215; Tue, 06 Jul 2021 03:16:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625566582; cv=none; d=google.com; s=arc-20160816; b=oktUaAp/VC2Iosee2ZcDbbR6zTaxB7IdpNj5MSnk3yu1LXfEvmelZ0xHgR3mB13kKV pNum6YsVkXb8wPNS1PYeAPb2im/3DEvyCLlpA11ohrto/xvflUkY+Fk+UFf/TAnSneZw nQMfvlPTjjOsAmmstXCoaoq1U9rRirP3lRXNeAvziEqMYc1WMVoTx+K4nW8cxMwXb49n mBQ0zzVGc4vloOAE0iWEDbqCJAfBqnuxO+8fZkgDE+/UB4ii6tGeKE9rVEvyFVBayVyH vt1X7n+oQJ6t5WrZLmZKJToU3vuOHyaTplnRDegNUWkKz9BtnKyqrrzucuHw2gggTJOU 3TCw== 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=Iot6iTHoRwguuwO1T5bvar0xmQaQxY5IuWYCD5WGT0I=; b=VzrEdpneYJ5nIrcOoeNckI/Z2ZvvqC1wwR0sZvvLxLYGmzdpF6ykiSaK5uxe99JJ4A 026oe96QuG5czjB9/pVSMSSEGMBiqeidzgwklNXkFNwsvHcVvlLwVfdvjZfnp6K2ni+6 te7neAbG9d9g6iYHZB+qzgYBLJoMkcZUYuB9MWYVNz6lqWowZ/v71BdCgelGU+i4nugn uCQYe2qXpY0tqXsp8BSAG2rQcINr1njVoTu/uO1PewCYzpYt+ODQ1YIyLSg1nNy+m24J bKz9BGEbn795rSKn6bxd3hxtlPb+ASeePZRElybPlLSzqjg05Dat05+2SHchpavqQx7S +++w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="J/KICNYq"; 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 3si13493603ejl.715.2021.07.06.03.15.57; Tue, 06 Jul 2021 03:16:22 -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="J/KICNYq"; 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 S231364AbhGFKPF (ORCPT + 99 others); Tue, 6 Jul 2021 06:15:05 -0400 Received: from forward3-smtp.messagingengine.com ([66.111.4.237]:57703 "EHLO forward3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231354AbhGFKPE (ORCPT ); Tue, 6 Jul 2021 06:15:04 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailforward.nyi.internal (Postfix) with ESMTP id 878581940671; Tue, 6 Jul 2021 06:12:25 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 06 Jul 2021 06:12:25 -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=Iot6iTHoRwguuwO1T 5bvar0xmQaQxY5IuWYCD5WGT0I=; b=J/KICNYqNtmx4ETG3cnWxJGfVrrw5O14/ vY0/uydc9UY6r6RdPQRMddlAMZcm8n6vp0hZnO07zgJveYK+3PI2/vBnanbEyoJt bngYutCMPfpj628AzvW7DRwnYUGyBfC5dSpG5HkO6mYW9AJTJwCgYQn+Q81wn5Xk NlSP5r2iR02ZSLhGtf6ipKFA8rvRJxeq3OLQ2mfBtDiDy46M4RgXk9t5henwk4Vx m9MlGMNuLMx7dDDRHmALy6lkE6CYTxKzLu5X1S0cSo7TacFQuRwuUjyJL7dL3qXT G3ocqqC7JDD1McCTXyxkSEQJKMov+q/eCWRepo/0PL3B7UdNIclYA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeejiedgvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpeffrghvihguucfg ughmohhnughsohhnuceouggrvhhiugdrvggumhhonhgushhonhesohhrrggtlhgvrdgtoh hmqeenucggtffrrghtthgvrhhnpeduhfetvdfhgfeltddtgeelheetveeufeegteevtddu iedvgeejhfdukeegteehheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegurghvihgurdgvughmohhnughsohhnsehorhgrtghlvgdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 6 Jul 2021 06:12:08 -0400 (EDT) Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 8d70566b; Tue, 6 Jul 2021 10:12:07 +0000 (UTC) From: David Edmondson To: linux-kernel@vger.kernel.org Cc: Wanpeng Li , Jim Mattson , Sean Christopherson , Borislav Petkov , Vitaly Kuznetsov , Joerg Roedel , kvm@vger.kernel.org, Paolo Bonzini , David Matlack , Thomas Gleixner , x86@kernel.org, Ingo Molnar , "H. Peter Anvin" , David Edmondson Subject: [PATCH v2 0/2] kvm: x86: Convey the exit reason to user-space on emulation failure Date: Tue, 6 Jul 2021 11:12:05 +0100 Message-Id: <20210706101207.2993686-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 to userspace in order that it can be recorded. I'm unsure whether sgx_handle_emulation_failure() needs to be adapted to use the emulation_failure part of the exit union in struct kvm_run - advice welcomed. v2: - Improve patch comments (dmatlack) - Intel should provide the full exit reason (dmatlack) - Pass a boolean rather than flags (dmatlack) - Use the helper in kvm_task_switch() and kvm_handle_memory_failure() (dmatlack) - Describe the exit_reason field of the emulation_failure structure (dmatlack) David Edmondson (2): KVM: x86: Add kvm_x86_ops.get_exit_reason KVM: x86: On emulation failure, convey the exit reason to userspace arch/x86/include/asm/kvm-x86-ops.h | 1 + arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/svm/svm.c | 6 ++++++ arch/x86/kvm/vmx/vmx.c | 11 +++++++---- arch/x86/kvm/x86.c | 22 +++++++++++++--------- include/uapi/linux/kvm.h | 7 +++++++ 6 files changed, 37 insertions(+), 13 deletions(-) -- 2.30.2