From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752789AbcCKVeT (ORCPT ); Fri, 11 Mar 2016 16:34:19 -0500 Received: from mail-ob0-f174.google.com ([209.85.214.174]:34395 "EHLO mail-ob0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751196AbcCKVeO (ORCPT ); Fri, 11 Mar 2016 16:34:14 -0500 MIME-Version: 1.0 In-Reply-To: References: <1457729240-3846-1-git-send-email-dmatlack@google.com> <1457729240-3846-2-git-send-email-dmatlack@google.com> From: David Matlack Date: Fri, 11 Mar 2016 13:33:53 -0800 Message-ID: Subject: Re: [PATCH 1/1] KVM: don't allow irq_fpu_usable when the VCPU's XCR0 is loaded To: Andy Lutomirski Cc: "linux-kernel@vger.kernel.org" , X86 ML , kvm list , Paolo Bonzini , Ingo Molnar , Andrew Lutomirski , "H. Peter Anvin" , Eric Northup Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 11, 2016 at 1:14 PM, Andy Lutomirski wrote: > > On Fri, Mar 11, 2016 at 12:47 PM, David Matlack wrote: > > From: Eric Northup > > > > Add a percpu boolean, tracking whether a KVM vCPU is running on the > > host CPU. KVM will set and clear it as it loads/unloads guest XCR0. > > (Note that the rest of the guest FPU load/restore is safe, because > > kvm_load_guest_fpu and kvm_put_guest_fpu call __kernel_fpu_begin() > > and __kernel_fpu_end(), respectively.) irq_fpu_usable() will then > > also check for this percpu boolean. > > Is this better than just always keeping the host's XCR0 loaded outside > if the KVM interrupts-disabled region? Probably not. AFAICT KVM does not rely on it being loaded outside that region. xsetbv isn't insanely expensive, is it? Maybe to minimize the time spent with interrupts disabled it was put outside. I do like that your solution would be contained to KVM. > > --Andy