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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A28A0C4332F for ; Mon, 18 Oct 2021 11:56:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E6F260F02 for ; Mon, 18 Oct 2021 11:56:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231640AbhJRL6O (ORCPT ); Mon, 18 Oct 2021 07:58:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48528 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231623AbhJRL6I (ORCPT ); Mon, 18 Oct 2021 07:58:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634558157; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fCM/GUGbXTstduw5A7ZtGYQzITbTV7AQFdkBboCynIE=; b=fatAZExHlkYvjov0gS602mfrLcbtAWjSCRMszS/Y814ERwhnT9Yt4LdLP85Lh4PVChBkJZ XcZbMu5UZhqYK3zl/JJY3k1SgcbYYwGz6YoQboekVBLlDxA5KebRhUcec46gck5Q41aYDn zoI/Dr0RJGnGCFNTxsWdIuYWTG85HIA= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-443-W4gMF3P6NvCD9oNC0c803A-1; Mon, 18 Oct 2021 07:55:56 -0400 X-MC-Unique: W4gMF3P6NvCD9oNC0c803A-1 Received: by mail-wr1-f70.google.com with SMTP id l8-20020a5d6d88000000b001611b5de796so8757246wrs.10 for ; Mon, 18 Oct 2021 04:55:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=fCM/GUGbXTstduw5A7ZtGYQzITbTV7AQFdkBboCynIE=; b=HtDz3fzTpqFBB+QgL+8+LaJFeK5bnbDrCnoS3nc6z8mU/EPwAydDZf17D5TA9slgq2 rby7et3+7TsjIRUgWssV4/0eNNyQb5utoRfjvrD6BoJrG+T67Ql6pOs3ZYtwtj2PUqoT lc3JDja5SymXHgFkR+AoZl/60j4cOoBCxOVLM895eGE2obNvfPk0cJrllu4/CuT42CUL 1B44ISaC5Vdtt9nxbze0jPnGobBSEeU3bBFsk13mLSmXpXa5MFjgPnBtqRjbBMGROzMb lWSpmEbGe0mKmnWn2wFTfH6aAkgqdiQJoXHCD0QcTmHKV22xQ0tAoy/YcNVhTJCqDlXm ZzXA== X-Gm-Message-State: AOAM533Zo3bn66nDNbcN48DTst4d+T/vLgbcvJHh81KwfEkMng+nNw8I WP2RIpMemPjEpWlQIre/q7DyLFGh8XmK5ZxRHWeFwhwjM6YzcE0ykjZ8NcW123KLgiAm3KuJ6GI j8FcCVPmWvq/QycDBbyBbz/LW X-Received: by 2002:a5d:598a:: with SMTP id n10mr34535608wri.93.1634558155065; Mon, 18 Oct 2021 04:55:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiVA0bTdZn/OFUfGqxOypsZ4ysp85b1Jd23TcQIsqU26rnc4Y3pUGQXL9xTCEja8xMGZgAYg== X-Received: by 2002:a5d:598a:: with SMTP id n10mr34535587wri.93.1634558154877; Mon, 18 Oct 2021 04:55:54 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id x7sm12108195wrq.69.2021.10.18.04.55.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Oct 2021 04:55:54 -0700 (PDT) Message-ID: Date: Mon, 18 Oct 2021 13:55:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [patch 3/4] x86/kvm: Convert FPU handling to a single swap buffer Content-Language: en-US To: Thomas Gleixner , LKML Cc: x86@kernel.org, "Liu, Jing2" , "Bae, Chang Seok" , Dave Hansen , Arjan van de Ven , kvm@vger.kernel.org, "Nakajima, Jun" , Sean Christopherson References: <20211017151447.829495362@linutronix.de> <20211017152048.666354328@linutronix.de> From: Paolo Bonzini In-Reply-To: <20211017152048.666354328@linutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/10/21 19:03, Thomas Gleixner wrote: > */ > - fpu_swap_kvm_fpu(vcpu->arch.user_fpu, vcpu->arch.guest_fpu, > - ~XFEATURE_MASK_PKRU); > + fpu_swap_kvm_fpstate(&vcpu->arch.guest_fpu, true, ~XFEATURE_MASK_PKRU); > trace_kvm_fpu(1); > } > > /* When vcpu_run ends, restore user space FPU context. */ > static void kvm_put_guest_fpu(struct kvm_vcpu *vcpu) > { > - /* > - * Guests with protected state have guest_fpu == NULL which makes > - * swap only restore the host state. > - */ > - fpu_swap_kvm_fpu(vcpu->arch.guest_fpu, vcpu->arch.user_fpu, ~0ULL); > + fpu_swap_kvm_fpstate(&vcpu->arch.guest_fpu, false, ~0ULL); The restore mask can be ~XFEATURE_MASK_PKRU in this case tool this way it's constant and you can drop the third argument to the function. Also perhaps it could be useful to add an if (WARN_ON_ONCE(cur_fps->is_guest == enter_guest)) return; at the top of fpu_swap_kvm_fpstate, since the is_guest member (at least for now?) is only used for such kind of assertion. Paolo