Received: by 10.213.65.68 with SMTP id h4csp201337imn; Mon, 26 Mar 2018 19:14:25 -0700 (PDT) X-Google-Smtp-Source: AG47ELs5ugosCq1QK0uZjRjSwpdd+kbvv/UGVmbZo1sIulPeG8uwbvSQMeZU6oLs+m3W9QSKPuIB X-Received: by 2002:a17:902:525:: with SMTP id 34-v6mr12420616plf.267.1522116865473; Mon, 26 Mar 2018 19:14:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522116865; cv=none; d=google.com; s=arc-20160816; b=hxPW3xXR1tQOhbzU5ACAZWPtCOp7Ubh8OQQBhVPyj3ugdUK1BqKb8+Y2pPQhvGxCvJ w1iYfgOQGlHia7kvjE63EduUYAB4mJDKAKzXmmPQZPSURvVFeGt3Y/vhVCgzRXhGgPWf UoZ07ycI951IULxR8xetW/A6AlWV3K1KIWS0xvqbBPBW0VAGUJnznGEKzJEug04Xyrry ieyK1q3c+DgptwWQS2x4Stdsbw1RZgtI/tWEBVYa23YxKa0uKkflczCMCxAhUo5iQwmx uhgZo5dn1mxs3DJtkfQLWpBT70wtrU+TxpKcXaxF2MNnj5muyvCJ0Ut+d1wCV3rw5XUy ppmw== 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 :dkim-signature:arc-authentication-results; bh=a3NKH9xgwcs8FoJsri5F8+AO8CIZmVDXYAPvFliPh2w=; b=Xq0opUDMxrffaACoK/TOXsvlUh25QxGrWuRF7ZRT3Iv7CW9X4zAYjI0yB1DencGyzh mdMySfVuA7Dtwp66vQY4HhKmz25FjAigKCLlGPc7Svh8zHPZHgB1VZsWSA2ogUq/+j7m QxqBqKnCOVBQ8JTw2zXhDNtFR8fNcCkssEVhHlaF+k4ajafT1KfjGMAbpbRf0sCx4K3M w0cGVH7/oT6fxraupxd1sTBsbAflM8trwUuwesean/B95Nfm8XR9GmHk60GHjsUu4ysL xPIdd++Vn16U5JRFRXSBTXQf8985If9/x00RY7gYWJRODuygXdlPy1E+1ZfdLZ7uufbS sipw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iNSjnpUP; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si97727pgt.198.2018.03.26.19.14.09; Mon, 26 Mar 2018 19:14:25 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iNSjnpUP; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752416AbeC0CNM (ORCPT + 99 others); Mon, 26 Mar 2018 22:13:12 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:42204 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752266AbeC0CNI (ORCPT ); Mon, 26 Mar 2018 22:13:08 -0400 Received: by mail-pl0-f65.google.com with SMTP id g20-v6so1895444plo.9; Mon, 26 Mar 2018 19:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a3NKH9xgwcs8FoJsri5F8+AO8CIZmVDXYAPvFliPh2w=; b=iNSjnpUPSkVo2FFLBiahs6tNuc7wHjl1RVLO9KEldTK9NGUrXQfIiaUPViAenhD+2k o6PAw0EezErhSoKUNcbBrWhRh2q7QV2vxnPUiKSRI7cKushJN5lI4R2qkMYlL8K6J94P VH3RKYK92vcHBUS6MKP7o7IfabyMjjEHELAy7jE6ptBG/vjRt/qm9Y7qrDPNVDI+wlWF Q4z0bTZJ1ZmGSA/dWu4aEnjtVlqnVybVhGaCFAumbBn8sr93P29jYZu4kORrKoevk20L jCuX1p74Zo9li+KJXXz6AR+RG4wW7MkZqhJyevVH/sYbd62iK7Lwm2xPo5W/0TpaII6b EXyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a3NKH9xgwcs8FoJsri5F8+AO8CIZmVDXYAPvFliPh2w=; b=UEg09CBCsWYh0F6JFlkyQmFrOm4vYyqFuqLHYFJuq4S6bUigYaM5TLfPO6PkJl7Oq2 4HJuwIjehOpUMZ+Ks4g1kQxT2ZHvAwbhZhH0rWdJ8tq84KXbLCsPud1U++9BJJOXMWTg 6uGPCyZBnLxdNXrgHXGX+SnxKUn8Ar7fXTCZbhlOL1xYOw0acLtORpu45mODrtyB/9yd 1yKVCtZyGILvTFWjonw2nV30R0EAP0dEB26JRy5WP53c4o1bjTp5I4lpD8zt2qGuT91o ZnuMZ5WbQFnTXtP5vnUxPKBTGZOCu5QP6be/z1bh9fL3PhBoRrgskWApNsV3P1Zfo9lt kwkQ== X-Gm-Message-State: AElRT7GISctogXpb9e/WmF8W9cvGtEOi0nxZFiB+6mRRMTIRfVu0QYwu 6ZM09+bpcmVnT00UqinDg3nmFg== X-Received: by 2002:a17:902:684:: with SMTP id 4-v6mr43722380plh.262.1522116788326; Mon, 26 Mar 2018 19:13:08 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.123]) by smtp.googlemail.com with ESMTPSA id k3sm148607pgq.35.2018.03.26.19.13.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Mar 2018 19:13:07 -0700 (PDT) From: Wanpeng Li X-Google-Original-From: Wanpeng Li To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Andrew Cooper Subject: [PATCH 1/2] KVM: VMX: Introduce handle_ud() Date: Mon, 26 Mar 2018 19:12:14 -0700 Message-Id: <1522116735-4861-2-git-send-email-wanpengli@tencent.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522116735-4861-1-git-send-email-wanpengli@tencent.com> References: <1522116735-4861-1-git-send-email-wanpengli@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wanpeng Li Introduce handle_ud() to handle invalid opcode, this function will be used by later patches. Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Andrew Cooper Signed-off-by: Wanpeng Li --- arch/x86/kvm/vmx.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 9bc05f5..0f99833 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -6215,6 +6215,18 @@ static int handle_machine_check(struct kvm_vcpu *vcpu) return 1; } +static int handle_ud(struct kvm_vcpu *vcpu) +{ + enum emulation_result er; + + er = emulate_instruction(vcpu, EMULTYPE_TRAP_UD); + if (er == EMULATE_USER_EXIT) + return 0; + if (er != EMULATE_DONE) + kvm_queue_exception(vcpu, UD_VECTOR); + return 1; +} + static int handle_exception(struct kvm_vcpu *vcpu) { struct vcpu_vmx *vmx = to_vmx(vcpu); @@ -6233,14 +6245,8 @@ static int handle_exception(struct kvm_vcpu *vcpu) if (is_nmi(intr_info)) return 1; /* already handled by vmx_vcpu_run() */ - if (is_invalid_opcode(intr_info)) { - er = emulate_instruction(vcpu, EMULTYPE_TRAP_UD); - if (er == EMULATE_USER_EXIT) - return 0; - if (er != EMULATE_DONE) - kvm_queue_exception(vcpu, UD_VECTOR); - return 1; - } + if (is_invalid_opcode(intr_info)) + return handle_ud(vcpu); error_code = 0; if (intr_info & INTR_INFO_DELIVER_CODE_MASK) -- 2.7.4