Re: [PATCH v3 10/21] x86/fpu/xstate: Update xstate save function to support dynamic xstate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 1/15/2021 12:59 PM, Bae, Chang Seok wrote:
On Jan 11, 2021, at 18:52, Liu, Jing2 <jing2.liu@xxxxxxxxxxxxxxx> wrote:

On 1/8/2021 2:40 AM, Bae, Chang Seok wrote:
On Jan 7, 2021, at 17:41, Liu, Jing2 <jing2.liu@xxxxxxxxx> wrote:

static void kvm_save_current_fpu(struct fpu *fpu)  {
+	struct fpu *src_fpu = &current->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, &current->thread.fpu.state,
+	if (test_thread_flag(TIF_NEED_FPU_LOAD)) {
+		memcpy(&fpu->state, &src_fpu->state,
		       fpu_kernel_xstate_min_size);
<snip>

-	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



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux