Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1263113ybl; Fri, 23 Aug 2019 16:28:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqw91jq7hG8PJeSMRpx2SwkQINqZwvZCFDLtJz+A6msa5EDzx+Qa11VlrWNHH1Y5DQHlXQaW X-Received: by 2002:a65:5a44:: with SMTP id z4mr6061257pgs.41.1566602896107; Fri, 23 Aug 2019 16:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566602896; cv=none; d=google.com; s=arc-20160816; b=g1ibkgAZ+Khn4VDOncZ9/xftJRtsqa2V/Lryj+89LAHbNUvqH9qWH2yNMuJ7D1hiIK b91tdi6pNXJ+faSh3ucmLbMRjKkQ1vWYrt3KMzzaowZpeutrEStOqZV0Kf5I670prURb g+H6VgHoZg7x8k/gAghy7oprnwp455jR+9+mOYpRNMTH7wtm/9RoqkyPxpppC4RjjOSU mGS1VzIkmVg4XpHFRgojtPjDWpnNQZRUpXqRjTrofexQezkX2GAp07Bw9jHCE3EsRnT8 lEpebt09rCi0rCkYctUAzW6sKc8Cct0ZkYmKhsSn/RhEdMon92TwYBVH7j8fG5eT/RO0 6bdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=z+eN4ovpqbhCcH6wvzo2RjwDqdisgCi7kwTMU5VqdOo=; b=zJL9f96VkVwGH2l6RdsWBrL9VIpqVYB9ax4ucLmLUxOwr9U9HlnTYMs7lx9rab8nt9 rTSqdbEad0XLo+rKy1+yta4U+ZVK0MCN3RBVhQhRMbSvmZVSGYiZIFDhJM+u5LEvutRb 1qIlLlBbSZhgUihRWR7C6n7FTnOpVFOnbpdfO6xiUtC5evBj3zKKQs1iKs5wUKqfEtZH WKqRVZfaoSvN19XcNsqq57JqGXcJCH1THAxwSDv/DldI8c8BFgfj8KTKK8gqXE84WDWg sAZgurr/Ne9fvplT6DdfGTr5Q12vkf219F8nRZmXrUeV8MghUew5ufkPNXzpdOAiNCET uyGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p10si258403plr.402.2019.08.23.16.28.00; Fri, 23 Aug 2019 16:28:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395407AbfHWOoZ (ORCPT + 99 others); Fri, 23 Aug 2019 10:44:25 -0400 Received: from mga02.intel.com ([134.134.136.20]:63244 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393066AbfHWOoZ (ORCPT ); Fri, 23 Aug 2019 10:44:25 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Aug 2019 07:44:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,421,1559545200"; d="scan'208";a="186886059" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.41]) by FMSMGA003.fm.intel.com with ESMTP; 23 Aug 2019 07:44:23 -0700 Date: Fri, 23 Aug 2019 07:44:23 -0700 From: Sean Christopherson To: Liran Alon Cc: Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RESEND PATCH 07/13] KVM: x86: Add explicit flag for forced emulation on #UD Message-ID: <20190823144423.GB6713@linux.intel.com> References: <20190823010709.24879-1-sean.j.christopherson@intel.com> <20190823010709.24879-8-sean.j.christopherson@intel.com> <9E01A06E-FD3E-4D43-9FFE-6FFE3BAC269A@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9E01A06E-FD3E-4D43-9FFE-6FFE3BAC269A@oracle.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 23, 2019 at 04:47:14PM +0300, Liran Alon wrote: > > > > On 23 Aug 2019, at 4:07, Sean Christopherson wrote: > > > > Add an explicit emulation type for forced #UD emulation and use it to > > detect that KVM should unconditionally inject a #UD instead of falling > > into its standard emulation failure handling. > > > > Signed-off-by: Sean Christopherson > > The name "forced emulation on #UD" is not clear to me. > > If I understand correctly, EMULTYPE_TRAP_UD is currently used to indicate > that in case the x86 emulator fails to decode instruction, the caller would > like the x86 emulator to fail early such that it can handle this condition > properly. Thus, I would rename it EMULTYPE_TRAP_DECODE_FAILURE. EMULTYPE_TRAP_UD is used when KVM intercepts a #UD from hardware. KVM only emulates select instructions in this case in order to minmize the emulator attack surface, e.g.: if (unlikely(ctxt->ud) && likely(!(ctxt->d & EmulateOnUD))) return EMULATION_FAILED; To enable testing of the emulator, KVM recognizes a special "opcode" that triggers full emulation on #UD, e.g. ctxt->ud is false when the #UD was triggered with the magic prefix. The prefix is only recognized when the module param force_emulation_prefix is toggled on, hence the name EMULTYPE_TRAP_UD_FORCED. > But this new flag seems to do the same. So I’m left confused. I’m probably > missing something trivial here.