Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp133246pxb; Thu, 14 Jan 2021 22:00:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyeqT4yDpfRAzwA520qs9bgANk8WQ+ra2gWgqbKLq8uBtacJxoT0TDogj2LfbYhNpJuKCwD X-Received: by 2002:a50:9ee6:: with SMTP id a93mr8373883edf.174.1610690422131; Thu, 14 Jan 2021 22:00:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610690422; cv=none; d=google.com; s=arc-20160816; b=iR83B7W1JzyD/ZWcZrp+fRvQ7B22rzplYSpJ+4biOdJvad9JskOH8izJ/wcHgFUmPT 6dJ43z9Jtt61CuXGX7Q8Rk/mNMB34NyKI45HMBmMi0iO6yrbtuAv2gGDDeJ9Ffwbu85R xxW0Zr4+8eTZTtmOpO3ScDz+Sfw3PbZEZuAw5MJFIob9g5CMRadONbOt7byvsyzUwU4E SZ6YdtQS1shdq81f/uA0agBnEm1wBeKmTstUVouB4dDsV85wG7C0B/0Pkac7+ITeQypu 7tug2222D7lvmpu6rzCaeFRuBANp8TdHF14b+yiYCOWPCT3QKIQeSCi8AeO343WdnSA+ S6Yg== 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=bGDsIv5xBlNjALQTtKknWHPapJZGcrrWothGylsqayo=; b=gGzfLA24LWKGobrYyWTEqzbm6XRMGzk/O1QHPzhwtqmoTTqWwpr9KxwCApKYHYNlaf MRkA0MChViqA34YBSHY5AfYv6bsQo9PDIyoEKdFYNgTWHUvaGf0Bl5Fp63KzBtHViRaj 7jCpYMg9DOwPM5h1M2etwWYvJMnzrmfgoqKdQvrH9bd9KlznavmgI4KkSMXDi9Gypcax uW2CUcLcLZlScjy1aVHBwHfagiETN2348DW1ojRmToYuePb4tUyy/XlY2MM/YCWJvu5e 1RVMTzC6tckh/kWTBc5YR4II1vyUCai5sX/BXi3E/iSmRTWaX4wpyygl0Hmkuxf9qj+1 vT9A== 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 h22si3374456ejd.179.2021.01.14.21.59.58; Thu, 14 Jan 2021 22:00:22 -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 S1732341AbhAOFrs (ORCPT + 99 others); Fri, 15 Jan 2021 00:47:48 -0500 Received: from mga17.intel.com ([192.55.52.151]:21743 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730518AbhAOFrq (ORCPT ); Fri, 15 Jan 2021 00:47:46 -0500 IronPort-SDR: /1rWQ9QaU/gRue9608ApWD5cMi50+bg/LQdBZqkn9PJNYGiah5lpnMLIN/Yqr0qMBu438o68Dw WAJb49442BRw== X-IronPort-AV: E=McAfee;i="6000,8403,9864"; a="158277119" X-IronPort-AV: E=Sophos;i="5.79,348,1602572400"; d="scan'208";a="158277119" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jan 2021 21:46:00 -0800 IronPort-SDR: ajAZ0o7rz0TzeVNIP5DH1Rl0oIDoXqN8Cqxn5pIt/ffw0XW9RJXaNqtcIw8OP4YIToYyUv9TpE YnZMBlJv3l5g== X-IronPort-AV: E=Sophos;i="5.79,348,1602572400"; d="scan'208";a="382544785" 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; 14 Jan 2021 21:45:57 -0800 Subject: Re: [PATCH v3 10/21] x86/fpu/xstate: Update xstate save function to support dynamic xstate To: "Bae, Chang Seok" Cc: "Liu, Jing2" , "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> <0361132a-c088-331b-de1f-e0de23d729ab@linux.intel.com> From: "Liu, Jing2" Message-ID: <8178f22a-17bb-26c8-4a0b-4c459d5ef6bb@linux.intel.com> Date: Fri, 15 Jan 2021 13:45:55 +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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/15/2021 12:59 PM, Bae, Chang Seok wrote: >> On Jan 11, 2021, at 18:52, Liu, Jing2 wrote: >> >> 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); > > >>>> - 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). > Thank you for the feedback. Sorry, I don't get any logical reason to set the > mask always here. Sure, I'd like to see if fx_init()->memset is the case, though maybe no hurt so far in test. Thanks, Jing > Perhaps, KVM code can be updated like you mentioned when > supporting the dynamic states there. > > Please let me know if I’m missing any functional issues. > > Thanks, > Chang