Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4368180pxb; Tue, 5 Oct 2021 01:20:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmtdktatjq3MVnBboVQ4O5SMxpJ0xidrvZ/CGpxG1ciWcf1ibqLIF4wkCieJTxQ4rY9tt6 X-Received: by 2002:a05:6402:784:: with SMTP id d4mr24701164edy.116.1633422002572; Tue, 05 Oct 2021 01:20:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633422002; cv=none; d=google.com; s=arc-20160816; b=z6O9sV3/N4B2Jnq2b71Of406UslwNjYzYX3ln1Vqn1QFABfkCwQYmRcgk1R70cg0lx /ar6OYE3oAqvR3e9ArBU7CzWvuHhJtr2Kku3CgXTZzyCi6b/KyhGfkWilnhBVqKSXkiI FZl26qCepS+db8QRhcR/mbKPMUK027uXXw3MbHElz3cD7Uzk4h0Mujqmp/DjkxBQ/S5B WFcPlElOzfeVgJAulhrdemKfAyuXzVGkAFMHX461ChX4ygFbzWXR+fB4tIBjcyy1gdfK FZgyrmhMK4r6qfhoZdtq/WQFkikYSNJIOHfUwE3+R8QxWgMAcZ5Hnp31YbUWhHcoJHlY fyZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=DeXqgvhgZgba5cIjEbA+9+dV2VIz1J/oWf8XDFTEfK8=; b=ng7fjZlXzXIaqklCA2oQbxLfoMIYdBLL8+l1i97TrDxV9hhwyKZstDUgmOpKBEnvjp 3imcRY/qz4xo/pO0TIZOgMmVQ+1Ojbg98BjIcLUyES2baAh528yTNPhaDjobFxCMLzsh 8p2X/6rgxGJfFktNmxJ1UVtSSQSuzt0Jlf2GFBm/hWyjjRFA4sXizZiCKYxW+ap+KbSd PJPeDax9wsRhpcQXpZT1YaL8lxW3+dGFVH6n4Q2Q2koNyv3GTdWTg2cHfiNDO/F29Gyy TdyTDcWskWFT0XQMdWfXF9uipgzhOMBRc+/YjhpjyNkOrnkMHECZsMWLAsYfLUe2eeoK /lqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TIWt8Qpg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v2si17307100edc.561.2021.10.05.01.19.39; Tue, 05 Oct 2021 01:20:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TIWt8Qpg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233317AbhJEISt (ORCPT + 99 others); Tue, 5 Oct 2021 04:18:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39829 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbhJEISs (ORCPT ); Tue, 5 Oct 2021 04:18:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633421818; 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=DeXqgvhgZgba5cIjEbA+9+dV2VIz1J/oWf8XDFTEfK8=; b=TIWt8QpgIG0h4BiN5pJEKug5lL6wmBSsc07u8t5LM1j4L5tGGiGYrkuqcyAZ+CxULRSr8S mpgEvQkXKkJbj5lt/CdKrukd7e8ZzyqKQZEXGUlhvTmWmpfAAuRXQCeSAfHVbyOBTgHuZm Ddl6mGnAYIN7UuqqmnE7zjB3InrTZrA= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-396-0r9GAdoFPDuEWWF3g1VEwA-1; Tue, 05 Oct 2021 04:16:57 -0400 X-MC-Unique: 0r9GAdoFPDuEWWF3g1VEwA-1 Received: by mail-ed1-f72.google.com with SMTP id n19-20020a509353000000b003dad185759bso11943949eda.6 for ; Tue, 05 Oct 2021 01:16: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=DeXqgvhgZgba5cIjEbA+9+dV2VIz1J/oWf8XDFTEfK8=; b=Rs44mgJODLViXoSwhgWC+8Oih97bQa+LzeN19karXgQbaLY7OXP9tblRbsV7Dy5pPt S48J19W5JosKqN923H2pgO8yQl09mmETquBDbnZR+MOjlx1oDlq1FvMWVK9Dt6/oN7Ke El4w2KowdGyA2JMRUg028LdMNi0DiUghKZWJhNoCZuWvfMlfpEn6OV6ucjZJbXoWQVsZ wHcEWCu2VFGdGj/gisBpVwKH/wEf0QWXyKoK+IVdQ81QVoby1ED+I9VtCaz7Iy+wXdWy kw4hFTwNL7PB8BAt8Opr4zdk+1tlNwKfrY7q8nstqVGbxJMHQwCsPqdjHITCUbanKeU6 D7gA== X-Gm-Message-State: AOAM531Cu3rdRx4TpU9WsjI5j7B1vC1LNQDE8c9aVzyiyV9kfi5kmaRB AYJvubmbgZGLtJh3C408KQ2kJdjt7+RftSvGyC2JdSV1svsibuvr1zD7PaJCJ9NVbKwmeV3memy ZKtBXxxFqrsiHiL5AjJoSmq9S X-Received: by 2002:a17:907:7752:: with SMTP id kx18mr23187400ejc.276.1633421815923; Tue, 05 Oct 2021 01:16:55 -0700 (PDT) X-Received: by 2002:a17:907:7752:: with SMTP id kx18mr23187377ejc.276.1633421815739; Tue, 05 Oct 2021 01:16:55 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e? ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id b2sm8435115edv.73.2021.10.05.01.16.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Oct 2021 01:16:55 -0700 (PDT) Message-ID: Date: Tue, 5 Oct 2021 10:16: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 v10 10/28] x86/fpu/xstate: Update the XSTATE save function to support dynamic states Content-Language: en-US To: "Bae, Chang Seok" , Thomas Gleixner Cc: "bp@suse.de" , "Lutomirski, Andy" , "mingo@kernel.org" , "x86@kernel.org" , "Brown, Len" , "lenb@kernel.org" , "Hansen, Dave" , "Macieira, Thiago" , "Liu, Jing2" , "Shankar, Ravi V" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" References: <87pmsnglkr.ffs@tglx> <0F4DCBED-7A0B-4C0C-A63A-3C7E9AC065D5@intel.com> From: Paolo Bonzini In-Reply-To: <0F4DCBED-7A0B-4C0C-A63A-3C7E9AC065D5@intel.com> 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 03/10/21 00:54, Bae, Chang Seok wrote: > FWIW, the proposed KVM patch for AMX looks to take (1) here [1] and > Paolo said [2]: > > Most guests will not need the whole xstate feature set. So perhaps you > could set XFD to the host value | the guest value, trap #NM if the > host XFD is zero, and possibly reflect the exception to the guest's XFD ^^^^ (better: if the host XFD is nonzero, and the guest XCR0 includes any bit whose state is optional). > and XFD_ERR. This comment is about letting arch/x86/kernel resize current->thread.fpu while the guest runs. It's not necessary before KVM supports AMX, because KVM will never let a guest set XCR0[18] (__kvm_set_xcr). Thomas instead was talking about allocation of vcpu->arch.guest_fpu and vcpu->arch.user_fpu. For dynamic allocation in kvm_save_current_fpu, you can retrieve the XINUSE bitmask (XGETBV with RCX=1). If it contains any bits that have optional state, you check if KVM's vcpu->arch.guest_fpu or vcpu->arch.user_fpu are already big enough, and if not do the reallocation. If X86_FEATURE_XGETBV1 is not available, you will not need to resize. If XFD is supported but X86_FEATURE_XGETBV1 is not, you can just make kvm_arch_init fail with -ENODEV. It's a nonsensical combination. Thanks, Paolo > In addition, loading the guest XFD MSRs should use the MSR autoload > feature (add_atomic_switch_msr). > > And then I guess discussion goes on..