Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1894098pxb; Mon, 12 Apr 2021 09:05:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYI76dzq7N+AJjSMGcYxqwatdXN2K6VspWarhQMl3y1ttONfpCgvcKo896fKafrLI19T0F X-Received: by 2002:a17:906:7206:: with SMTP id m6mr28238684ejk.281.1618243539793; Mon, 12 Apr 2021 09:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618243539; cv=none; d=google.com; s=arc-20160816; b=q2KAdIhNSxLTyBrPF7JZVr8aB5syc7qiwLkG58SLc+Z/MAbfnp8LLeCtK5uHAO6qZW x6oyIi4Sk9AsuIui3BG2XGg8tjl/zPJrZ3r8mF4QhVnRfFrFIYo55bJRKXPBvvhUhgpb 38oQvTo0qWqA93actfm3BHwK1d2WRTCnfgDQQuEcUzl7WlYzWiGdEXj/2X9NWmjqPSWm qdZ7GGZOhpfUiJJDGbYN6PAmGTezMVKmAHzjZ1P2QZgEvVuge3BCUWqGs1KiHjFCe9EV wUqnwCiIdN5oZCf9/LA4Le/iG5U4fSlJEoa721bUfSnFq0KhP0ReRt785cpRuy0hClSm Rnqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JBvLAe+XdwyC1TahhE2etbWctmaxYBIUWvV5rmz141I=; b=S+Rm4vW/kkf+1Y6Ox7aA7/rzd4xxfSIdZXCLXHs/4pWeJvLstWPAqKjGGP7XFmwzX1 e8RW+DP2eLEAkosIGvJJh3WMjlO+rp2oiMwDiCRn6Oo1hzqN4L+IjIzDlvGvJTcDmz3I Xsv9F6/20hjth17kfeCy3FTACtTokRi7Gf4IgPvtp9nB9rt4Fe52NUn3zi3J2KI+xlUD kX+adlU2WQtSIRUuf0p5kpLgrUC1loT/tVQ8R+WV3P26C6NW42VbPHNjThnjS0+y+fzc qp3PjEJHsFTvqQuED/dSXcRqqP0BBTmJHFjRH2oTJ/a1cvZsUVy799hpDUfGPc3R5IOq iWZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=iP2BummN; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n4si7799475edw.607.2021.04.12.09.05.15; Mon, 12 Apr 2021 09:05:39 -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=@google.com header.s=20161025 header.b=iP2BummN; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243206AbhDLQE1 (ORCPT + 99 others); Mon, 12 Apr 2021 12:04:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242899AbhDLQE0 (ORCPT ); Mon, 12 Apr 2021 12:04:26 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64C5BC06174A for ; Mon, 12 Apr 2021 09:04:07 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id p12so9746859pgj.10 for ; Mon, 12 Apr 2021 09:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=JBvLAe+XdwyC1TahhE2etbWctmaxYBIUWvV5rmz141I=; b=iP2BummN96o3Ez8aj7V9/rOfsPo8UnTnLCwQVbYCglNGVspy6LsiU1mUu4Y41zmXKu taawvpF5xCOgJFc5Qmz1GCLztVn8ao0dJMHcYBmTf3JzFmQg6DoyPQr3BU1mv9GLAKkr VcMBBq2+t4OjMccea/TY0zBqiIfOzdUcrxVVyTnlGcIpy7Q+HBHbw5oBvvmO6gwcm9Uu jwJKM1dM8a88MjHK4t2lik4OT7cq83tXjotwfEfB0ThjwoPLZo5+VuKx0lH5O5rtDSEU RU1GIMh+SOVczf5cJU/YGCl4nqVGlOYXHOG6JJB+4nZzrSDoCeNA6tOfOLsDKHObcggc DmzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JBvLAe+XdwyC1TahhE2etbWctmaxYBIUWvV5rmz141I=; b=Mv4M41YqbVZdxSOnffv1X6UIsNdfe911As9xabdAz4VfrN4fFTYs+Z2ZGDYPRd2faO xVO64b5QDzWcsqNB4NKPv3ch6DUg/n7P4rgOpm4EhFeleqs24pFXQThu7puA+HtdgQ/b KMhH7SjFPPIxb4OtLxNAzprAQh0k7o8IzNAy9DuXplLGKPgk164uQoHN8zQusw/KxPU0 qc9MeQ3z08uuj1o3YQrq0xaqp/FWMPQh6IJbmmi7OLL8M5PW7ehg4N96S3Ez1IsWyo2R ww6MwiH6d8hmk1w0QVzPqtOlbEejlmBAyw33KoxhITYCzPVesXZiNSgOG+oIa+5BH+tO CZnA== X-Gm-Message-State: AOAM531cQodnqflRribK9o3B+K7JBOn1HqICHGYLXBAhXbpd1pQhJssr WFS79RBer46p3GlxHE5Jrf4N6r5IQI810A== X-Received: by 2002:a63:6cc:: with SMTP id 195mr28628134pgg.153.1618243446756; Mon, 12 Apr 2021 09:04:06 -0700 (PDT) Received: from google.com (240.111.247.35.bc.googleusercontent.com. [35.247.111.240]) by smtp.gmail.com with ESMTPSA id ev24sm8085263pjb.9.2021.04.12.09.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 09:04:05 -0700 (PDT) Date: Mon, 12 Apr 2021 16:04:02 +0000 From: Sean Christopherson To: David Edmondson Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov , "H. Peter Anvin" , x86@kernel.org, Thomas Gleixner , Joerg Roedel , Wanpeng Li , Borislav Petkov , Jim Mattson , Ingo Molnar , Joao Martins , Aaron Lewis Subject: Re: [PATCH 5/6] KVM: SVM: pass a proper reason in kvm_emulate_instruction() Message-ID: References: <20210412130938.68178-1-david.edmondson@oracle.com> <20210412130938.68178-6-david.edmondson@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210412130938.68178-6-david.edmondson@oracle.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +Aaron On Mon, Apr 12, 2021, David Edmondson wrote: > From: Joao Martins > > Declare various causes of emulation and use them as appropriate. > > Signed-off-by: Joao Martins > Signed-off-by: David Edmondson > --- > arch/x86/include/asm/kvm_host.h | 6 ++++++ > arch/x86/kvm/svm/avic.c | 3 ++- > arch/x86/kvm/svm/svm.c | 26 +++++++++++++++----------- > 3 files changed, 23 insertions(+), 12 deletions(-) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index 79e9ca756742..e1284680cbdc 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1535,6 +1535,12 @@ enum { > EMULREASON_IO_COMPLETE, > EMULREASON_UD, > EMULREASON_PF, > + EMULREASON_SVM_NOASSIST, > + EMULREASON_SVM_RSM, > + EMULREASON_SVM_RDPMC, > + EMULREASON_SVM_CR, > + EMULREASON_SVM_DR, > + EMULREASON_SVM_AVIC_UNACCEL, Passing these to userspace arguably makes them ABI, i.e. they need to go into uapi/kvm.h somewhere. That said, I don't like passing arbitrary values for what is effectively the VM-Exit reason. Why not simply pass the exit reason, assuming we do indeed want to dump this info to userspace? What is the intended end usage of this information? Actual emulation? Debug? Logging? Depending on what you're trying to do with the info, maybe there's a better option. E.g. Aaron is working on a series that includes passing pass the code stream (instruction bytes) to userspace on emulation failure, though I'm not sure if he's planning on providing the VM-Exit reason.