From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97DBDC4743C for ; Mon, 21 Jun 2021 20:15:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 756D76134F for ; Mon, 21 Jun 2021 20:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231704AbhFUURt (ORCPT ); Mon, 21 Jun 2021 16:17:49 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:52510 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230028AbhFUURq (ORCPT ); Mon, 21 Jun 2021 16:17:46 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1624306531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=81ScfF7FRAJff1SENxfuOxVRZ7AB9lK/9rJ87bopY34=; b=o2tl+9Wgwu78nJ6qh+EyfQA+HveHDiSv5iu3BS3sCKzPokBf3SA2HQq86UswRswVtHzahi vgrEJrbesbCUdi1hln/tZacWB1DERhrCNWRayiIBMRBcciqxnZi+EpGNvngUiTH0DMFurD UEZUhrB4JY1CW4Da0fbunPW+aZawsNl3zZ3Sh1Phv/3EI7fSRMX51Vs54btIRTX/pKC7b6 5+rLtvUGdxO8USKJM0x2OI3AwMpBIko73MINe9cI/SZEgl8lUaRhfiMUcvfJ2HGaUE32Z2 R0vJHOWe28nAUdokbW3nWyuiXMGKVQRuvBVGeKIBLLu1iPpXSacblvKhZBiRTw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1624306531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=81ScfF7FRAJff1SENxfuOxVRZ7AB9lK/9rJ87bopY34=; b=VC5pvCGPeT1xp3yeu7XV8KRMBAjtsRVXP8fF0l7p9oYKYmxXfhLoPgpaIzRxiyHV/t8p59 Uuo0QhprvXcWpxCA== To: Borislav Petkov Cc: LKML , Andy Lutomirski , Dave Hansen , Fenghua Yu , Tony Luck , Yu-cheng Yu , Sebastian Andrzej Siewior , Peter Zijlstra , Kan Liang Subject: Re: [patch V3 22/66] x86/fpu: Move fpu__write_begin() to regset In-Reply-To: References: <20210618141823.161158090@linutronix.de> <20210618143446.905002907@linutronix.de> Date: Mon, 21 Jun 2021 22:15:30 +0200 Message-ID: <87a6njezz1.ffs@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 21 2021 at 17:30, Borislav Petkov wrote: >> @@ -89,7 +108,7 @@ int xfpregs_set(struct task_struct *targ >> if (newstate.mxcsr & ~mxcsr_feature_mask) >> ret = -EINVAL; > ^^^^^^^^^^^^^^ > > Don't forget to fix that thing, btw. Fixed localy at the right spot already. >> - fpu__prepare_write(fpu); >> + fpu_force_restore(fpu); >> >> /* Copy the state */ >> memcpy(&fpu->state.fxsave, &newstate, sizeof(newstate)); >> @@ -147,7 +166,7 @@ int xstateregs_set(struct task_struct *t >> } >> } >> >> - fpu__prepare_write(fpu); >> + fpu_force_restore(fpu); >> ret = copy_kernel_to_xstate(&fpu->state.xsave, kbuf ?: tmpbuf); > > Ok, this here: > > fpu_force_restore() will unconditionally invalidate the fpregs but the > following copy_kernel_to_xstate() call can return -EINVAL when the > xstate header validation fails or mxcsr has reserved bits set so we will > not have copied anything to the target thread. Then the task has to restore FPU on the way to user space. Not a big deal, it's traced - so what? Thanks, tglx