Received: by 10.213.65.68 with SMTP id h4csp434223imn; Fri, 23 Mar 2018 07:45:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELtqX+ZkKGDH+nxFw++QPoZ/4EWiuLG93XiI00XR2Rd9Vl1EaRWMZqiZ+LcbH4pjTDBzmVrv X-Received: by 10.98.98.194 with SMTP id w185mr24383389pfb.206.1521816303542; Fri, 23 Mar 2018 07:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521816303; cv=none; d=google.com; s=arc-20160816; b=XO5skyiZfNeHgpZ4Cyo4lUVpYYwWIbFhWTeUTf2mFmhfobqMDnE/GruImk39dkXen+ oAyk8q4hWJo/8QsbjnIsw56wacPJtGbowfMtAcA+aCHgK7OkqyuBdz8TGDQOivNl6Pf6 7Fuz80jnoW/FcLM/CtyYj/5Crd6Mab5y9tAePKtXRgZ6Ufvq7cJcl/3RRsC90FVzN0Qa JBIFeXw3CYIapB6V6dBdpt1ImGMU3Ah9gfnDFzDoM+2GksS5NqTAB/wVtDQnzvlfPbC0 81fsi+Lqh+dvDEmqD0v7NEnTDyL1Snz9aWs4u9ntnEKhp0FNORFCRyM9qPBs4+6TaXer x/7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Bah84rXgOyJ5XoVRyicDoh5paf3+bJkwesrHg52T5Jg=; b=YqML5LCidXFhcCgY7GWeZIlaWK0AkHEW0Crg5Dm2gwUBiluZLi87T7wzQukGenvoUN oTnknGQ6a9/FJkbJBcJrroWs+EJD5hciLhb3TNIm6ehUFeGoYAzW+f1lfgPZKc5oXRSZ NE/RRnQBZEdaDh/bTmhSDj6D/FqU1jXpUUqFNLO2lRuUJfN0KV/VQ9hLUgu9JJzvYlXj rWsLSx039+oInHDyS8udO1/EtZCGd/DI8cOyW5nE68ygIreGJS8srVfOb6aD+UFTm2wp i9sueCuuk+wqSRXW/YIPNlNOQFT/Yeyel1iTW7DbIsEUvE9Z767rDonPTHztKDNbkXgC c9jw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si7138003pff.24.2018.03.23.07.44.48; Fri, 23 Mar 2018 07:45:03 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751870AbeCWOnr (ORCPT + 99 others); Fri, 23 Mar 2018 10:43:47 -0400 Received: from smtp.eu.citrix.com ([185.25.65.24]:3678 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751814AbeCWOnp (ORCPT ); Fri, 23 Mar 2018 10:43:45 -0400 X-IronPort-AV: E=Sophos;i="5.48,350,1517875200"; d="scan'208";a="70469679" Subject: Re: [PATCH] KVM: X86: Fix the decoding of segment overrides in 64bit mode To: Wanpeng Li CC: Paolo Bonzini , LKML , kvm , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= References: <1521707651-9375-1-git-send-email-wanpengli@tencent.com> <49454fe4-16e2-4d8b-7ad5-9e488afc786e@citrix.com> <9bd82cb0-d88f-4891-a111-3704802e1d4e@redhat.com> <94bbfac5-2022-ab92-0b9a-1c3cd2275054@citrix.com> From: Andrew Cooper Message-ID: <3cff8fb1-bfa7-0e63-4642-4d779454965a@citrix.com> Date: Fri, 23 Mar 2018 14:43:01 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: 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 AMSPEX02CL02.citrite.net (10.69.22.126) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/03/18 14:27, Wanpeng Li wrote: > 2018-03-22 21:53 GMT+08:00 Andrew Cooper : >> On 22/03/18 13:39, Wanpeng Li wrote: >>> 2018-03-22 20:38 GMT+08:00 Paolo Bonzini : >>>> On 22/03/2018 12:04, Andrew Cooper wrote: >>>>> We've got a Force Emulation Prefix (ud2a; .ascii "xen") for doing >>>>> magic. Originally, this was used for PV guests to explicitly request an >>>>> emulated CPUID, but I extended it to HVM guests for "emulate the next >>>>> instruction", after we had some guest user => guest kernel privilege >>>>> escalations because of incorrect emulation. >>>> Wanpeng, why don't you add it behind a new kvm module parameter? :) >>> Great point! I will have a try. Thanks Paolo and Andrew. :) >> Using the force emulation prefix requires intercepting #UD, which is in >> general a BadThing(tm) for security. Therefore, we have a build time > Yeah, however kvm intercepts and emulates #UD by default, should we > add a new kvm module parameter to enable it and disable by default? > Paolo. > >> configuration option to compile in support, and require that test >> systems explicitly opt into using it via a command line parameter. >> >> http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/arch/x86/hvm/hvm.c;h=db52312882205e65b32e587106ca795f4bfab2eb;hb=refs/heads/staging#l3741 >> is the general #UD intercept handler if you want a reference. (You can > Thanks Andrew, it is useful. :) In addition, I didn't see the > test-memop-seg testcase has "Forced Emulation Prefix", when the prefix > is added to each instruction in the testcase? It has ended up substantially more ugly than I first intended, due to several assembler bugs in older GCC and Clang toolchains. http://xenbits.xen.org/gitweb/?p=xtf.git;a=blob;f=tests/memop-seg/asm.S;h=698661425bcdc9c181b235e323c2460e06c6e986;hb=HEAD#l35 I previously has FEP passed as a second parameter, but that becomes prohibitively complicated to extract when testing %ss or %esp.  FEP is now encoded in the bottom bit of the address passed in. This was the cleanest way I could find of testing every combination, but I'm open to improvements if anyone can spot any. ~Andrew