Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2969369pxb; Tue, 12 Jan 2021 03:10:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxB78psKY82DsLSrKWUCdBMYrxw29X59zYfz8pYY8H4VlH/yRRP4uWXOpt9autLgq1s3UFr X-Received: by 2002:a17:907:41e3:: with SMTP id nb3mr2884447ejb.378.1610449842227; Tue, 12 Jan 2021 03:10:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610449842; cv=none; d=google.com; s=arc-20160816; b=XhCwDVwczsxNYi4IFpwYuva9gm77lvoadHB5SnlUOX1SkqqtXAHVQYu090ps5nHP/T b3Mwqrf09vWOSJ2NcfJSyLuSkVHsyAXcmc2cwgQq2ydz+DRHqgOq2UBPJf1B23flRIeV au9XJAZcfKyjtIj0qLPubk0tUwG98+KEyInCHtidNMgKbQcjl8IYIXPm/2eTQE3NR45t B7c4xF9UmHNG2CXfFXYhvQ7pG9k3YhkqV7SyggAuYNI97pUz3EvnyENPs3W7ke8IRG9W aXKRnK0bTaEqjOFcnf8YvDHMWJX0Q+SzCJ+vBqttjU7VS7O+EK8oFX2AWrKos9LDkDun 6WVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=Tt9dGtSgZV+1Fuv3PGjXaCe+sQrtU7ON6xzCvEY0ayM=; b=MThY/02174V+Ysua3Unmng5aeAUlvbeHk6fxj7OZHOKIwpGm4zA0J2ozuOEiI6Q8Vp Y2K76wk3UKrsWbi7IeO01dUkv24nm3Axw8RpgTwgvuHzODxYSEYXncYlGN991G14nFlo idGfpG4mgry+fo4CL3S1/yaPS8gcMVzM6SCvjY4yJuU4qvr1fNyyj/6RjZu7VgTQZ7oT LM53yvRjG+zSaN+MHdUrBvKSepCgOdjPQbIVswCLCpOPkR5S74/Sgfkc12+YCiMECB41 ZqGwXUAy7u7ropMUgkBxDEbMaR5klAnafjObXgDu7CzR9hbYuaAqpfZlXi4iPFUr8sDe eR6g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b27si956689eje.466.2021.01.12.03.10.18; Tue, 12 Jan 2021 03:10:42 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731476AbhALCyV (ORCPT + 99 others); Mon, 11 Jan 2021 21:54:21 -0500 Received: from mga04.intel.com ([192.55.52.120]:58725 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728830AbhALCyV (ORCPT ); Mon, 11 Jan 2021 21:54:21 -0500 IronPort-SDR: 4opLHpNOh0jRWf611QCsbm8aP1E0kBfwsFEzxolLqEi3WsgNjRl3jk8EOGdamQwPtbJTjO2luN cqXLsE7EC9vQ== X-IronPort-AV: E=McAfee;i="6000,8403,9861"; a="175392299" X-IronPort-AV: E=Sophos;i="5.79,340,1602572400"; d="scan'208";a="175392299" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2021 18:52:35 -0800 IronPort-SDR: AnDGpi7IZBTKrjNs84H2+rdVKVqrWnTGTGy9pIqS4NklnD9HFHM+3ExZLRM/YRbPEqoDxygMQi 8RfV9BxQ4/GQ== X-IronPort-AV: E=Sophos;i="5.79,340,1602572400"; d="scan'208";a="381250515" Received: from liujing-mobl.ccr.corp.intel.com (HELO [10.238.130.147]) ([10.238.130.147]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2021 18:52:31 -0800 Subject: Re: [PATCH v3 10/21] x86/fpu/xstate: Update xstate save function to support dynamic xstate To: "Bae, Chang Seok" , "Liu, Jing2" Cc: "bp@suse.de" , "luto@kernel.org" , "tglx@linutronix.de" , "mingo@kernel.org" , "x86@kernel.org" , "Brown, Len" , "Hansen, Dave" , "Shankar, Ravi V" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" References: <20201223155717.19556-1-chang.seok.bae@intel.com> <20201223155717.19556-11-chang.seok.bae@intel.com> <29CB32F5-1E73-46D4-BF92-18AD05F53E8E@intel.com> From: "Liu, Jing2" Message-ID: <0361132a-c088-331b-de1f-e0de23d729ab@linux.intel.com> Date: Tue, 12 Jan 2021 10:52:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <29CB32F5-1E73-46D4-BF92-18AD05F53E8E@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/8/2021 2:40 AM, Bae, Chang Seok wrote: >> On Jan 7, 2021, at 17:41, Liu, Jing2 wrote: >> >> static void kvm_save_current_fpu(struct fpu *fpu) { >> + struct fpu *src_fpu = ¤t->thread.fpu; >> + >> /* >> * If the target FPU state is not resident in the CPU registers, just >> * memcpy() from current, else save CPU state directly to the target. >> */ >> - if (test_thread_flag(TIF_NEED_FPU_LOAD)) >> - memcpy(&fpu->state, ¤t->thread.fpu.state, >> + if (test_thread_flag(TIF_NEED_FPU_LOAD)) { >> + memcpy(&fpu->state, &src_fpu->state, >> fpu_kernel_xstate_min_size); >> For kvm, if we assume that it does not support dynamic features until this series, >> memcpy for only fpu->state is correct. >> I think this kind of assumption is reasonable and we only make original xstate work. >> >> - else >> + } else { >> + if (fpu->state_mask != src_fpu->state_mask) >> + fpu->state_mask = src_fpu->state_mask; >> >> Though dynamic feature is not supported in kvm now, this function still need >> consider more things for fpu->state_mask. > Can you elaborate this? Which path might be affected by fpu->state_mask > without dynamic state supported in KVM? > >> I suggest that we can set it before if...else (for both cases) and not change other. > I tried a minimum change here. The fpu->state_mask value does not impact the > memcpy(). So, why do we need to change it for both? Sure, what I'm considering is that "mask" is the first time introduced into "fpu", representing the usage, so not only set it when needed, but also make it as a representation, in case of anywhere using it (especially between the interval of this series and kvm series in future). Thanks, Jing > Thanks, > Chang