From nobody Mon Apr 29 15:29:46 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1571404048; cv=none; d=zoho.com; s=zohoarc; b=dIt6V1A+qcS9deBhNhNKgCjHyXxdqJ44kHDi2FXpdPms+LfRpprwXjec272rBASUGMdv44zkHUvXfbg3knj1T+uuxE0lA5goCRWcHl350NZyaHz7gYnFgDfp5eZVIoTI2gYdf7MdbSfQqvh3dI7emd6zX4C4KHaodt3fFxn+fwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571404048; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=j88Lcm3XztdfSvpw02Z4ai2x++q/S3uN3OzCSkNWqBw=; b=Qt83Sw8pwBnV8Pj89EjhfBwrFWKyPkhrMSNfcFRTHPzMD2m0GHvL7R33d0s/uDx6iFa5Utok+Wm9kzaa6TA77kVXGLb8VxmsBKZESL0mGr8zGKsi34YaCW0vs7QZqrCSIi0kQAvB2BxdaYd7WO9Qdooof+V+igGUuLpexAU2nlg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1571404048227511.1215049288787; Fri, 18 Oct 2019 06:07:28 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iLRw4-0000rZ-Bm; Fri, 18 Oct 2019 13:04:52 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iLRgB-0007mL-0X for xen-devel@lists.xenproject.org; Fri, 18 Oct 2019 12:48:27 +0000 Received: from Galois.linutronix.de (unknown [2a0a:51c0:0:12e:550::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 92e24072-f1a5-11e9-8aca-bc764e2007e4; Fri, 18 Oct 2019 12:48:25 +0000 (UTC) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iLRg3-00078T-ED; Fri, 18 Oct 2019 14:48:19 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 0FC761C0450; Fri, 18 Oct 2019 14:48:19 +0200 (CEST) X-Inumbo-ID: 92e24072-f1a5-11e9-8aca-bc764e2007e4 Date: Fri, 18 Oct 2019 12:48:18 -0000 From: "tip-bot2 for Masami Hiramatsu" To: linux-tip-commits@vger.kernel.org In-Reply-To: <156777563917.25081.7286628561790289995.stgit@devnote2> References: <156777563917.25081.7286628561790289995.stgit@devnote2> MIME-Version: 1.0 Message-ID: <157140289884.29376.11452767773752821731.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1, SHORTCIRCUIT=-0.0001 X-Mailman-Approved-At: Fri, 18 Oct 2019 13:04:51 +0000 Subject: [Xen-devel] [tip: x86/core] x86: xen: kvm: Gather the definition of emulate prefixes X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Reply-To: linux-kernel@vger.kernel.org Cc: Juergen Gross , Stefano Stabellini , Peter Zijlstra , Andrew Cooper , x86@kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov , Masami Hiramatsu , Josh Poimboeuf , xen-devel@lists.xenproject.org, Boris Ostrovsky , Randy Dunlap , Ingo Molnar Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The following commit has been merged into the x86/core branch of tip: Commit-ID: b3dc0695fa40c3b280230fb6fb7fb7a94ce28bf4 Gitweb: https://git.kernel.org/tip/b3dc0695fa40c3b280230fb6fb7fb7a94= ce28bf4 Author: Masami Hiramatsu AuthorDate: Fri, 06 Sep 2019 22:13:59 +09:00 Committer: Peter Zijlstra CommitterDate: Thu, 17 Oct 2019 21:31:57 +02:00 x86: xen: kvm: Gather the definition of emulate prefixes Gather the emulate prefixes, which forcibly make the following instruction emulated on virtualization, in one place. Suggested-by: Peter Zijlstra Signed-off-by: Masami Hiramatsu Signed-off-by: Peter Zijlstra (Intel) Cc: Juergen Gross Cc: x86@kernel.org Cc: Ingo Molnar Cc: Boris Ostrovsky Cc: Andrew Cooper Cc: Stefano Stabellini Cc: Borislav Petkov Cc: xen-devel@lists.xenproject.org Cc: Randy Dunlap Cc: Josh Poimboeuf Link: https://lkml.kernel.org/r/156777563917.25081.7286628561790289995.stgi= t@devnote2 --- arch/x86/include/asm/emulate_prefix.h | 14 ++++++++++++++ arch/x86/include/asm/xen/interface.h | 11 ++++------- arch/x86/kvm/x86.c | 4 +++- 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 arch/x86/include/asm/emulate_prefix.h diff --git a/arch/x86/include/asm/emulate_prefix.h b/arch/x86/include/asm/e= mulate_prefix.h new file mode 100644 index 0000000..70f5b98 --- /dev/null +++ b/arch/x86/include/asm/emulate_prefix.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_EMULATE_PREFIX_H +#define _ASM_X86_EMULATE_PREFIX_H + +/* + * Virt escape sequences to trigger instruction emulation; + * ideally these would decode to 'whole' instruction and not destroy + * the instruction stream; sadly this is not true for the 'kvm' one :/ + */ + +#define __XEN_EMULATE_PREFIX 0x0f,0x0b,0x78,0x65,0x6e /* ud2 ; .ascii "x= en" */ +#define __KVM_EMULATE_PREFIX 0x0f,0x0b,0x6b,0x76,0x6d /* ud2 ; .ascii "kv= m" */ + +#endif diff --git a/arch/x86/include/asm/xen/interface.h b/arch/x86/include/asm/xe= n/interface.h index 62ca03e..9139b3e 100644 --- a/arch/x86/include/asm/xen/interface.h +++ b/arch/x86/include/asm/xen/interface.h @@ -379,12 +379,9 @@ struct xen_pmu_arch { * Prefix forces emulation of some non-trapping instructions. * Currently only CPUID. */ -#ifdef __ASSEMBLY__ -#define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ; -#define XEN_CPUID XEN_EMULATE_PREFIX cpuid -#else -#define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; " -#define XEN_CPUID XEN_EMULATE_PREFIX "cpuid" -#endif +#include + +#define XEN_EMULATE_PREFIX __ASM_FORM(.byte __XEN_EMULATE_PREFIX ;) +#define XEN_CPUID XEN_EMULATE_PREFIX __ASM_FORM(cpuid) =20 #endif /* _ASM_X86_XEN_INTERFACE_H */ diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 661e2bf..777574f 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -68,6 +68,7 @@ #include #include #include +#include #include =20 #define CREATE_TRACE_POINTS @@ -5446,6 +5447,7 @@ EXPORT_SYMBOL_GPL(kvm_write_guest_virt_system); =20 int handle_ud(struct kvm_vcpu *vcpu) { + static const char kvm_emulate_prefix[] =3D { __KVM_EMULATE_PREFIX }; int emul_type =3D EMULTYPE_TRAP_UD; char sig[5]; /* ud2; .ascii "kvm" */ struct x86_exception e; @@ -5453,7 +5455,7 @@ int handle_ud(struct kvm_vcpu *vcpu) if (force_emulation_prefix && kvm_read_guest_virt(vcpu, kvm_get_linear_rip(vcpu), sig, sizeof(sig), &e) =3D=3D 0 && - memcmp(sig, "\xf\xbkvm", sizeof(sig)) =3D=3D 0) { + memcmp(sig, kvm_emulate_prefix, sizeof(sig)) =3D=3D 0) { kvm_rip_write(vcpu, kvm_rip_read(vcpu) + sizeof(sig)); emul_type =3D EMULTYPE_TRAP_UD_FORCED; } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel