[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e91b9172-8a2e-e299-a84f-1e9331c51cb7@intel.com>
Date: Tue, 21 Feb 2023 19:05:04 -0800
From: "Chang S. Bae" <chang.seok.bae@...el.com>
To: Mingwei Zhang <mizhang@...gle.com>,
Sean Christopherson <seanjc@...gle.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>
CC: "H. Peter Anvin" <hpa@...or.com>, <linux-kernel@...r.kernel.org>,
<kvm@...r.kernel.org>, <linux-kselftest@...r.kernel.org>,
Jim Mattson <jmattson@...gle.com>,
Venkatesh Srinivas <venkateshs@...gle.com>,
"Aaron Lewis" <aaronlewis@...gle.com>,
Chao Gao <chao.gao@...el.com>
Subject: Re: [PATCH v3 01/13] x86/fpu/xstate: Avoid getting xstate address of
init_fpstate if fpstate contains the component
On 2/21/2023 8:36 AM, Mingwei Zhang wrote:
> Avoid getting xstate address of init_fpstate if fpstate contains the xstate
> component. Since XTILEDATA (bit 18) was turned off in xinit, when KVM calls
> __raw_xsave_addr(xinit, 18), it triggers a warning as follows.
>
> __raw_xsave_addr() is an internal function that assume caller does the
> checking, ie., all function arguments should be checked before calling.
> So, instead of removing the WARNING, add checks in
> __copy_xstate_to_uabi_buf().
>
<snip>
> @@ -1151,10 +1152,11 @@ void __copy_xstate_to_uabi_buf(struct membuf to, struct fpstate *fpstate,
> pkru.pkru = pkru_val;
> membuf_write(&to, &pkru, sizeof(pkru));
> } else {
> - copy_feature(header.xfeatures & BIT_ULL(i), &to,
> - __raw_xsave_addr(xsave, i),
> - __raw_xsave_addr(xinit, i),
> - xstate_sizes[i]);
> + xsave_addr = (header.xfeatures & BIT_ULL(i)) ?
> + __raw_xsave_addr(xsave, i) :
> + __raw_xsave_addr(xinit, i);
> +
> + membuf_write(&to, xsave_addr, xstate_sizes[i]);
> }
> /*
> * Keep track of the last copied state in the non-compacted
So this hunk is under for_each_extended_xfeature(i, mask) -- it skips
the copy routine if mask[i] == 0; instead, it fills zeros.
We have this [1]:
if (fpu_state_size_dynamic())
mask &= (header.xfeatures | xinit->header.xcomp_bv);
If header.xfeatures[18] = 0 then mask[18] = 0 because
xinit->header.xcomp_bv[18] = 0. Then, it won't hit that code. So, I'm
confused about the problem that you described here.
Can you elaborate on your test case a bit? Let me try to reproduce the
issue on my end.
Thanks,
Chang
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/fpu/xstate.c#n1134
Powered by blists - more mailing lists