From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75DF6476CFC for ; Tue, 4 Aug 2026 17:42:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785865330; cv=none; b=NZfeysoAr0nCRkLTQpTvyrbQOwpT4LitMp0enntxAsc2B3RIg3hQSlDirWhNFvB4IcRwgWJNS+KA6aU1YofTmcld4l+y3H6SY8VDXzXUDKaMIM/s7Ums8B34e5LLjGYZ6Jy4uMQtVkHi/2dLaHHhq4TjfDtHxZ8kxpJrT2BRA0U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785865330; c=relaxed/simple; bh=4APvWxDjoM/HbTnD5ghUROTY/WPFJ1SmZqM7g8cc3RY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sIfjaF+PJPZa1275P3AgZos8H1l1xON1RapaYgzcLvJHOXeediQUpSGd1hchCWpWRvyAKzDuD7WgS6ZG/F9UQ41OhLAfjMO1B2fZBytWShTl5oEgOgrD3YnzDWkXUDANusG/iN/7cGN9SMpIFmRvmXIwul/0Ron8zx9d+BuBn5g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JRiyFCik; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JRiyFCik" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 063081F000E9; Tue, 4 Aug 2026 17:42:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785865329; bh=NgHzwAZhDQ08J3HJjn7Ukw5+Wc5kIk02Jyfm+f68NPY=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=JRiyFCikLvZEmaiSEBCSQahCJAMu5lcTn0F4Cy2P/RnM31A+SeZBQXdCG7U7S3BC4 qAYgi2gUIZkx7CyYoIAtlAzTShhUG15Jd0QB9rNi+EXqffLPvp4UeABObDNVUHzRNM fzxabF03J+Tkr3e9f447m9T5MUrCzZFfzEkZSIJeZh0q3LpXXvAm+7acRA7Ow6g3Qz FB53OvMYCuCt+aR8gxMqE7CwfhWIFMdYt6syRa7PviNYWtaT8cI1hkAWA0pT6PTsHy 6IBYH+YTAfJJ1xVznpf2sXpNfHZlrXJiTWpT6fh0FQD6m7ZiJA/82q0fMeJbOmdBUl XIG4hWXSYEnxw== Date: Tue, 4 Aug 2026 19:42:03 +0200 From: Ingo Molnar To: Thorsten Blum Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND] x86/fpu: Use vmemdup_user() in xstateregs_set() Message-ID: References: <20260720195534.70111-3-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: * Thorsten Blum wrote: > On Sun, Aug 02, 2026 at 03:20:59PM +0200, Ingo Molnar wrote: > > * Thorsten Blum wrote: > > > > Replace the open-coded vmalloc() and copy_from_user() with > > > > vmemdup_user() to simplify xstateregs_set(). > > > > > > > > vmemdup_user() returns an ERR_PTR() on failure, preserving the existing > > > > -ENOMEM and -EFAULT error codes. Since vmemdup_user() is backed by > > > > kvmalloc(), use kvfree() to free the buffer instead. > > > > > > > > Return early on error and drop the obsolete out label. > > > > > I've resent this cleanup a few times and haven't received feedback. Is > > > this still something you would consider, or would you prefer that I drop > > > it? It's intended to be a mechanical cleanup with no functional changes. > > > > > > Happy to rerun the relevant x86 XSAVE selftests if it helps. > > > > So the changelog is silent on any potential side-effects of this change. > > vmalloc will return page-aligned addresses. kmalloc won't. Will this > > have any effects on performance? > > > > Are there other examples of vmalloc() -> kvmalloc() conversions in > > the tree, is it a recommended and well-tested technique to simplify > > the code? > > > > A very quick git log investigation does not seem to be showing > > any such recent conversion examples: > > > > starship:~/tip> git log -E --grep='kvmalloc' --since=one-year-ago | grep -w vmalloc > > > > I'm not opposed to it in principle, I just think the 'analysis' > > side of the patch description is basically non-existent. > > Performance should be similar, and it's not a hot path. > > Page alignment shouldn't matter because the buffer is only used as a > memcpy() source in copy_uabi_from_kernel_to_xstate(). > > The main difference is that vmemdup_user() uses GFP_USER, which adds > __GFP_HARDWALL and may change cpuset allocations. > > The avx_64 selftests also pass on my Alder Lake CPU: > > [RUN] AVX registers: check context switches, 10 iterations, 5 threads. > [OK] No incorrect case was found. > [RUN] AVX registers: inject xstate via ptrace(). > [OK] 'xfeatures' in SW reserved area was correctly written > [OK] xstate was correctly updated. > [RUN] AVX registers: load xstate and raise SIGUSR1 > [OK] 'magic1' is valid > [OK] 'xfeatures' in SW reserved area is valid > [OK] 'xfeatures' in XSAVE header is valid > [OK] xstate delivery was successful > [OK] 'magic2' is valid > [RUN] AVX registers: load new xstate from sighandler and check it after sigreturn > [OK] xstate was restored correctly > # The kernel does not support feature number: 5 > # The kernel does not support feature number: 6 > # The kernel does not support feature number: 7 With this analysis included in the changelog I suppose it's a worthwile simplification. Thanks, Ingo