From patchwork Wed Apr 13 09:47:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Zhang X-Patchwork-Id: 8820241 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 80A399F39A for ; Wed, 13 Apr 2016 09:48:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE5892010F for ; Wed, 13 Apr 2016 09:48:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BCA1520256 for ; Wed, 13 Apr 2016 09:48:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030391AbcDMJrt (ORCPT ); Wed, 13 Apr 2016 05:47:49 -0400 Received: from mail-pa0-f66.google.com ([209.85.220.66]:33115 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965968AbcDMJrq (ORCPT ); Wed, 13 Apr 2016 05:47:46 -0400 Received: by mail-pa0-f66.google.com with SMTP id vv3so3464432pab.0; Wed, 13 Apr 2016 02:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=hsd3kbpPYLFlKizUCedSJpLS5jCU2D07ZecYSn2fawY=; b=JyFbxhVVYF4PpPzd//D1/HerZKgYvQJ1VOrw2mYhWx5mRLoQY23lrbd3GWXASomopT rFEYkxWwJ5xfW83sQwTUXNykIuBk1cZ9A6LKocWq5VO10glR9UDCZGOAThXS7Z8AsIV7 /xGBY1lnMhWIoUWdKfQycbL8l6+TYRmJIg18SNHM6zCdxrlUPDyoNRu/EcVxFer1OgVZ 4sc7v/PYb9KRb89+6HQujBIKZ82x0h3JOWGZ6XfPlz7rCtcufjJcKpF9lpTAyvHiFUEA vS3wk/gVFkw9hrVUZCmHNqN9OhDhYz79s94MNhkldLf0OZM9Amoel8TA3LQbn7LroMEq qlhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=hsd3kbpPYLFlKizUCedSJpLS5jCU2D07ZecYSn2fawY=; b=K7QWficHPqApqzAQck4rlQMXzAD++DGPomwRjdXFjFTwiLiGmA5YYV3fUa2yXR61Bm yoeb0RI6tbm5XHMeBi493emj3nst+YZETxM+ZM92hxRaJ9p7MMTDWMiuxotFzngN9X1E 8VYkOIvTRqCQYg3kfIOgwTbeydzCsiHuJ0PB6Lke03emoxZJOuGZ8Wkpa5ktE8Z86R9X vM+gXbS5rT/czWxyh2BcJxPcxRBmVs5hbrdws9mP7FJ6iZVoEqTzoD5yJVRFHbXk3ecI zzBvzvLKTWkoTa/NY70pZ3X2EW9BOnEhFtrNjipXC820ovHuzoM8hQeH7qXddvDfsD2S MmVQ== X-Gm-Message-State: AOPr4FWS2h8Y8AC7uuy1UeGEubqk2aqy8NBonV03QNbhdr5deb4/9AMBRyv0i8FfjR0y1Q== X-Received: by 10.66.119.177 with SMTP id kv17mr11655347pab.124.1460540866012; Wed, 13 Apr 2016 02:47:46 -0700 (PDT) Received: from [127.0.0.1] ([47.88.12.123]) by smtp.gmail.com with ESMTPSA id z2sm49621492pfa.90.2016.04.13.02.47.42 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 13 Apr 2016 02:47:45 -0700 (PDT) Subject: Re: [PATCH 1/2] KVM: x86: disable MPX if host did not enable MPX XSAVE features To: Paolo Bonzini References: <1457437481-65784-1-git-send-email-pbonzini@redhat.com> <1457437481-65784-2-git-send-email-pbonzini@redhat.com> <56E2B58B.8020605@redhat.com> <56F3E653.6040901@gmail.com> <56F3E6AB.5070902@redhat.com> Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Xiao Guangrong From: Yang Zhang Message-ID: <570E15B9.5070205@gmail.com> Date: Wed, 13 Apr 2016 17:47:37 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <56F3E6AB.5070902@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 2016/3/24 21:07, Paolo Bonzini wrote: > > > On 24/03/2016 14:06, Yang Zhang wrote: >> >> I mean why not keep the old way that only activate the eager_fpu while >> guest sees the MPX bit in CPUID, like: >> >> vcpu->arch.eager_fpu = use_eager_fpu() && guest_cpuid_has_mpx(vcpu); > > If the host uses eager FPU you can assume that it's faster than lazy FPU. > > Paolo > >> Besides, vmx_fpu_activate is called when do vcpu_reset. So it seems no >> need to call fpu_activate() here again. Hi Paolo The check in kvm_update_cpuid of fpu is strange since nothing relies on cpuid now. How about the following change? diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index bbbaa80..da4e6ad 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -114,9 +114,6 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu) if (best && (best->eax & (F(XSAVES) | F(XSAVEC)))) best->ebx = xstate_required_size(vcpu->arch.xcr0, true); - if (use_eager_fpu()) - kvm_x86_ops->fpu_activate(vcpu); - /* * The existing code assumes virtual address is 48-bit in the canonical * address checks; exit if it is ever changed. diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 9b7798c..8f57335 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7453,6 +7453,9 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) vcpu->arch.regs_avail = ~0; vcpu->arch.regs_dirty = ~0; + if (use_eager_fpu()) + kvm_x86_ops->fpu_activate(vcpu); + kvm_x86_ops->vcpu_reset(vcpu, init_event); }