Received: by 10.213.65.68 with SMTP id h4csp201932imn; Mon, 26 Mar 2018 19:15:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELtHW4yQe7gYXSSVseexJu4L8+EDeDUPhuUtvntPBGOZhbUbN35phaWp4mJcIq1nWsMXFVUz X-Received: by 10.101.100.9 with SMTP id a9mr11908906pgv.209.1522116937785; Mon, 26 Mar 2018 19:15:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522116937; cv=none; d=google.com; s=arc-20160816; b=l8C/qdcaoUpwsHygF+yk+h4xe3K6GixGAQvj1YhPP3R6J03WQbfG1AsEP85mqWXTY5 ZlNzWF/XWj1Hfl3XQfxaT9Z8YiWzEtpCWkPvOxIHZzaVYWq89ncoF9l3PEhSWUwlrLve dO9B4JgU8NYW9k1GwXdWzTNtKArZ/oRjBVs+Ml/UPobb/z3LIvWXPA0gqrOFAyxAs0xg 58BohQetnICoKerqhssDg+1nmOz6+WNEJ0ZymwZm4bYlxRSoQIkcRUH9fBzNhRxjEOee uJV1g4gBRIZFZVU2/peZ66Smg1KQxgZtT3FLPG6WN7ucij+rWZgNv0mdxgl0F57ei/Y0 SqgA== 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 :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=wMQUXO/hKsdg/pQcEB1Pqb02xb648X+sp0aqXx4j1F8=; b=s8tUWwyLrOKBhTsJjbrO2OWTu2tT+NRD/rsTzV2ezkZzf2bTl8W0UaCi47b9F6seqZ vxkNIByYOeR/Uf/w81crVW9w0D1WbOoqAgJtp4uttg+vipjLZ7K1VIUlgFg+dsE+HuGc MJ+2m1JWlXyo6n8g5x3oQt/YXtfoKuTEu6M2ZBhucnls+eII3UxgWvdJXRjKYjJl2tH7 BJgZ6x41+GuBbTJkXdxnsKI7EYZ3QPZudwQcU8mJ1haY37FlkEfARWSdSO4H5DElKflb eDGDiM8oVoceJocjVZbYd01X9xMuS+7sD+x5cCiS40EIS0Bgf28shoGp2N4PZVOKqxXn WyGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n1jtd2mo; 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.15.22; Mon, 26 Mar 2018 19:15:37 -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=n1jtd2mo; 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 S1752267AbeC0CNI (ORCPT + 99 others); Mon, 26 Mar 2018 22:13:08 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:37031 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752019AbeC0CNG (ORCPT ); Mon, 26 Mar 2018 22:13:06 -0400 Received: by mail-pl0-f67.google.com with SMTP id w12-v6so13172721plp.4; Mon, 26 Mar 2018 19:13:06 -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:mime-version :content-transfer-encoding; bh=wMQUXO/hKsdg/pQcEB1Pqb02xb648X+sp0aqXx4j1F8=; b=n1jtd2moBkrIuViyiGcHWJzmVWsWgkYU8PVQjSPsLP0wUm4xTQpmflcQajWbtp/9Rf aiazr3e+QYW7NZC/O3K+5/ax/l9eGLDGbi5+jrOW8QA3Vjqg4Rzg4a5d9BZ+IgOKm48K nC5McQVDZJbLPIe0RWU92DTmK9bUynot0L0YMAgDkNX4DdtQk5f5mZhiOLPkqdmyNNFM yCt2nHhhVx6F1yHYC7/MGIDngwQG0HQUoEY38BgYxDKT4yfibzMJrJnhla9kE/rb7kf+ mBF8H3ClgHD2APginTva74a9Un+RfIJFCDcbAJA45aL93KpO10/84GgSCvxb+UH7RJ/l Yqew== 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:mime-version :content-transfer-encoding; bh=wMQUXO/hKsdg/pQcEB1Pqb02xb648X+sp0aqXx4j1F8=; b=TE9Squov8vzZ3ME7t4LLureVau0UdUsQj89s5q0wZp+DFrLrlaNP9Z23z+X5XFvZpe JCNoDrBGUdlY6Dc2MM6h25UR4k0PAZMwCFD3l+R/hpVPptdexbzhDRRJO0nDVrPyA4qy yBuE7wUcI5l6lbbzPjnaKgU68w2UwxmjX++t3czAhe9XeP66D6LxzOQpHZybEkUxNZiR Dd4P8d0KAQoDirDe8IJYuV0VHD5BBQq4mVhF71WcEqmEwJqIVgMEyNREtw7I/k0m2moD gV8hxLg3V4utFAw+uKcTI5wo7Uw3u0ClGtXHT3xyLlmTINX/5tB2de+HaUIAeUAK+kSb s8uQ== X-Gm-Message-State: AElRT7GQWSUZRj26Q8XfX8hPGsZMg43G+L0XaAhpxuV15hxeSh5MIBHx mKS0NPFgQGXAm8N1Qk5ugU6wtg== X-Received: by 2002:a17:902:b58f:: with SMTP id a15-v6mr7187497pls.326.1522116786322; Mon, 26 Mar 2018 19:13:06 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.123]) by smtp.googlemail.com with ESMTPSA id k3sm148607pgq.35.2018.03.26.19.13.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Mar 2018 19:13:05 -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 0/2] KVM: VMX: Add Force Emulation Prefix for "emulate the next instruction" Date: Mon, 26 Mar 2018 19:12:13 -0700 Message-Id: <1522116735-4861-1-git-send-email-wanpengli@tencent.com> X-Mailer: git-send-email 2.7.4 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 This patchset introduces a Force Emulation Prefix (ud2a; .ascii "kvm") for "emulate the next instruction", the codes will be executed by emulator instead of processor, for testing purposes. A testcase here: #include #include #define HYPERVISOR_INFO 0x40000000 #define CPUID(idx, eax, ebx, ecx, edx)\ asm volatile (\ "ud2a; .ascii \"kvm\"; 1: cpuid" \ :"=b" (*ebx), "=a" (*eax),"=c" (*ecx), "=d" (*edx)\ :"0"(idx) ); void main() { unsigned int eax,ebx,ecx,edx; char string[13]; CPUID(HYPERVISOR_INFO, &eax, &ebx, &ecx, &edx); *(unsigned int *)(string+0) = ebx; *(unsigned int *)(string+4) = ecx; *(unsigned int *)(string+8) = edx; string[12] = 0; if (strncmp(string, "KVMKVMKVM\0\0\0",12) == 0) printf("kvm guest\n"); else printf("bare hardware\n"); } Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Andrew Cooper Wanpeng Li (2): KVM: VMX: Introduce handle_ud() KVM: VMX: Add Force Emulation Prefix for "emulate the next instruction" arch/x86/kvm/vmx.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) -- 2.7.4