From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABF1CC3A5A5 for ; Thu, 5 Sep 2019 13:32:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D65FC206DE for ; Thu, 5 Sep 2019 13:32:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="UKvcJjsO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726635AbfIENcF (ORCPT ); Thu, 5 Sep 2019 09:32:05 -0400 Received: from esa1.hc3370-68.iphmx.com ([216.71.145.142]:48890 "EHLO esa1.hc3370-68.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726097AbfIENcF (ORCPT ); Thu, 5 Sep 2019 09:32:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1567690323; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=Lcc3gqMGanTbkPh44XjaZd0+ZvHIJNfmbgJ9V1Rp25Y=; b=UKvcJjsO6nxSa8XtI+tkhAs9zBl1RsnjI4BnN8LIqTYlcqvl2dVyeCt2 +e8vfvAG2QqMwzG2X64TyilGp7xaIcLMb9zvOGKzwoSEPlktSQgwHeSvO uCPC5LOO5FrviPfdsf3EP8CQI9pvwiEONdTiJet+ELJvUsjo3nwMqR6vH Q=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 0D7GfDJ/REcuiVsBhabK41pNkxL1cYKmQ8/36VcGrGd04fchw6/HgkxGlH6JSpgVMS4H1hH72J 6X4cLS4N6MHNTg8ATLLwK/Z6sfW4Y1wf57N+QGfcnXaJsoMX6FD/5s51jY3pB6CRnxNkAK5w9c LGk0NYkKO4fzdzccLlZCbHLjsGHevABq9/ZDUPCLHbcIVkEF9iQ9rpFywyuvj+zpuGyjqgxmik /HAnyCzuv4PBND1pMnSAqMH+HcqciI7aFtLVBiOudnIkSY9jkihWkyjp1Gp2lJV8m4ZQ9nbbMw sC4= X-SBRS: 2.7 X-MesageID: 5230845 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,470,1559534400"; d="scan'208";a="5230845" Subject: Re: [Xen-devel] [PATCH -tip 0/2] x86: Prohibit kprobes on XEN_EMULATE_PREFIX To: Masami Hiramatsu CC: Ingo Molnar , Juergen Gross , "Stefano Stabellini" , Peter Zijlstra , Randy Dunlap , , , Borislav Petkov , "Josh Poimboeuf" , , "Boris Ostrovsky" References: <156759754770.24473.11832897710080799131.stgit@devnote2> <20190905104937.60aa03f699a9c0fbf1b651b9@kernel.org> <1372ce73-e2d8-6144-57df-a98429587826@citrix.com> <20190905203224.e41d7f3dfbf918c5031f9766@kernel.org> <20190905220958.d0189e1e253f9e553b880675@kernel.org> From: Andrew Cooper Openpgp: preference=signencrypt Autocrypt: addr=andrew.cooper3@citrix.com; prefer-encrypt=mutual; keydata= mQINBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i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dFLfhKyRdSXuvY3AHJd4CP 4JzW0Bzq/WXY3XMOzUTYApGQpnUpdOmuQSfpV9MQO+/jo7r6yPbxT7CwRS5dcQPzUiuHLK9i nvjREdh84qycnx0/6dDroYhp0DFv4udxuAvt1h4wGwTPRQZerSm4xaYegEFusyhbZrI0U9tJ B8WrhBLXDiYlyJT6zOV2yZFuW47VrLsjYnHwn27hmxTC/7tvG3euCklmkn9Sl9IAKFu29RSo d5bD8kMSCYsTqtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA== Message-ID: <1d868c99-58c5-1bbd-e6a4-2003dd319b5b@citrix.com> Date: Thu, 5 Sep 2019 14:31:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190905220958.d0189e1e253f9e553b880675@kernel.org> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Language: en-GB X-ClientProxiedBy: AMSPEX02CAS01.citrite.net (10.69.22.112) To AMSPEX02CL01.citrite.net (10.69.22.125) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/09/2019 14:09, Masami Hiramatsu wrote: > On Thu, 5 Sep 2019 20:32:24 +0900 > Masami Hiramatsu wrote: > >> On Thu, 5 Sep 2019 08:54:17 +0100 >> Andrew Cooper wrote: >> >>> On 05/09/2019 02:49, Masami Hiramatsu wrote: >>>> On Wed, 4 Sep 2019 12:54:55 +0100 >>>> Andrew Cooper wrote: >>>> >>>>> On 04/09/2019 12:45, Masami Hiramatsu wrote: >>>>>> Hi, >>>>>> >>>>>> These patches allow x86 instruction decoder to decode >>>>>> xen-cpuid which has XEN_EMULATE_PREFIX, and prohibit >>>>>> kprobes to probe on it. >>>>>> >>>>>> Josh reported that the objtool can not decode such special >>>>>> prefixed instructions, and I found that we also have to >>>>>> prohibit kprobes to probe on such instruction. >>>>>> >>>>>> This series can be applied on -tip master branch which >>>>>> has merged Josh's objtool/perf sharing common x86 insn >>>>>> decoder series. >>>>> The paravirtualised xen-cpuid is were you'll see it most in a regular >>>>> kernel, but be aware that it is also used for testing purposes in other >>>>> circumstances, and there is an equivalent KVM prefix which is used for >>>>> KVM testing. >>>> Good catch! I didn't notice that. Is that really same sequance or KVM uses >>>> another sequence of instructions for KVM prefix? >>> I don't know if you've spotted, but the prefix is a ud2a instruction >>> followed by 'xen' in ascii. >>> >>> The KVM version was added in c/s 6c86eedc206dd1f9d37a2796faa8e6f2278215d2 > Hmm, I think I might misunderstand what the "emulate prefix"... that is not > a prefix which replace actual prefix, but just works like an escape sequence. > Thus the next instruction can have any x86 prefix, correct? There is a bit of history here :) Originally, 13 years ago, Xen invented the "Force Emulate Prefix", which was the sequence: ud2a; .ascii 'xen'; cpuid which hit the #UD handler and was recognised as a request for virtualised CPUID information.  This was for ring-deprivileged virtualisation, and is needed because the CPUID instruction itself doesn't trap to the hypervisor. Following some security issues in our instruction emulator, I reused this prefix with VT-x/SVM guests for testing purposes.  It behaves in a similar manner - when enabled, it is recognised in #UD exception intercept, and causes Xen to add 5 to the instruction pointer, then emulate the instruction starting there. Then various folk thought that having the same kind of ability to test KVM's instruction emulator would be a good idea, so they borrowed the idea. >From a behaviour point of view, it is an opaque 5 bytes which means "break into the hypervisor, then emulate the following instruction". The name "prefix" is unfortunate.  It was named thusly because from the programmers point of view, it was something you put before the CPUID instruction which wanted to be emulated.  It is not related to x86 instruction concept of a prefix. ~Andrew