Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4114ybl; Tue, 27 Aug 2019 14:45:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPoUONZrGijmgPOtRumnKhvHUbQLBd/IaGFK8sAXoHyzOz0rj6v9gZ9VPXfQHYgKPVhWnB X-Received: by 2002:a17:902:6843:: with SMTP id f3mr1023537pln.97.1566942330274; Tue, 27 Aug 2019 14:45:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566942330; cv=none; d=google.com; s=arc-20160816; b=xYES/1Au6Ibxwmo+u+OUZ4koI5+7kT79YQl1yzD/cikiRcPP3XpFpZMAPbVj1F9vg2 F5/7dXWK4lXo3sMnIu/JKq6kDT0UfQN8ubMbWfaAJwWWVgENgDTIrAKLRuhzIRHfPtM7 eOQvsyOB1ljriq4SLw6ZhefNkJVOmw1NqSWRQVMlALWAFkjGicEJNWQpYfqEEqhoZpkn b3N3GGzqa1itEVLFuuRiXurkKl5g+CNFwHCLh21WVdISTOEUUvuqiIUI7XdUWBSSO9i3 RYvhApojzOhUUEMoPC+IVBHCYI/aEqpljpu1S1VK/oFn/5W7fB6inGyxu+iJFsulc41f 821g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=8ppu7tuIfNGFPb53YBkNvCCYP2PH6NplP8gdFf1Is10=; b=xd4yP7gemYCNB94sKpzF7Mv0678/YIakjp7/B79ZwXLFbYtItg+dcWIKcmtJSGtf9P 76uZoDWu7X7j00ApojW47XcqMb+F1S26y4g4khUskzJpi79YadPGQqfou3f+n1oWtWVY dIbF8Xaq8srRNhXoMd8380wAAP0AiEXNw66y62H4UhenZgbrHx2aulL+MrEXANxFgORp vD5JfAud/8zoYV/IgCHDbbGsOogWY7haJfh6AEC5rF4utSe2R/rUEM2apXvAl3cRRK9u EsV1nGfheW7QjtBflC139S8cYEILMwsu8A/+TXxNNIG4XkKb1RFL/84Lk8vQ2JbNhxYz wN+Q== 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 l184si480636pgd.203.2019.08.27.14.45.14; Tue, 27 Aug 2019 14:45:30 -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 S1731233AbfH0Vl1 (ORCPT + 99 others); Tue, 27 Aug 2019 17:41:27 -0400 Received: from mga03.intel.com ([134.134.136.65]:61902 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730866AbfH0Vkt (ORCPT ); Tue, 27 Aug 2019 17:40:49 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Aug 2019 14:40:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,438,1559545200"; d="scan'208";a="182919779" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.41]) by orsmga003.jf.intel.com with ESMTP; 27 Aug 2019 14:40:46 -0700 From: Sean Christopherson To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Liran Alon Subject: [PATCH v2 14/14] KVM: x86: Add comments to document various emulation types Date: Tue, 27 Aug 2019 14:40:40 -0700 Message-Id: <20190827214040.18710-15-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190827214040.18710-1-sean.j.christopherson@intel.com> References: <20190827214040.18710-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Document the intended usage of each emulation type as each exists to handle an edge case of one kind or another and can be easily misinterpreted at first glance. Cc: Liran Alon Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 3f524cea20ad..8221e68bbb0c 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1308,6 +1308,36 @@ extern u64 kvm_default_tsc_scaling_ratio; extern u64 kvm_mce_cap_supported; +/* + * EMULTYPE_NO_DECODE - Set when re-emulating an instruction (after completing + * userspace I/O) to indicate that the emulation context + * should be resued as is, i.e. skip initialization of + * emulation context, instruction fetch and decode. + * + * EMULTYPE_TRAP_UD - Set when emulating an intercepted #UD from hardware. + * Indicates that only select instructions (tagged with + * EmulateOnUD) should be emulated (to minimize the emulator + * attack surface). See also EMULTYPE_TRAP_UD_FORCED. + * + * EMULTYPE_SKIP - Set when emulating solely to skip an instruction, i.e. to + * decode the instruction length. For use *only* by + * kvm_x86_ops->skip_emulated_instruction() implementations. + * + * EMULTYPE_ALLOW_RETRY - Set when the emulator should resume the guest to + * retry native execution under certain conditions. + * + * EMULTYPE_TRAP_UD_FORCED - Set when emulating an intercepted #UD that was + * triggered by KVM's magic "force emulation" prefix, + * which is opt in via module param (off by default). + * Bypasses EmulateOnUD restriction despite emulating + * due to an intercepted #UD (see EMULTYPE_TRAP_UD). + * Used to test the full emulator from userspace. + * + * EMULTYPE_VMWARE_GP - Set when emulating an intercepted #GP for VMware + * backdoor emulation, which is opt in via module param. + * VMware backoor emulation handles select instructions + * and reinjects the #GP for all other cases. + */ #define EMULTYPE_NO_DECODE (1 << 0) #define EMULTYPE_TRAP_UD (1 << 1) #define EMULTYPE_SKIP (1 << 2) -- 2.22.0