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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, 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 59503C4743C for ; Wed, 23 Jun 2021 12:25:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41DED61076 for ; Wed, 23 Jun 2021 12:25:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231334AbhFWM2K (ORCPT ); Wed, 23 Jun 2021 08:28:10 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:37100 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231216AbhFWM07 (ORCPT ); Wed, 23 Jun 2021 08:26:59 -0400 Message-Id: <20210623121456.708180184@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1624451081; 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: content-transfer-encoding:content-transfer-encoding: references:references; bh=HgUlrfBIFOM8rnuHwF2g/QbRSSYRGCph9RQoo4B94zA=; b=xHykGx4dmMhx+gAg3LF7K14VYtCY8FHsrXQOqBLj3TM+ozKaUEEG7kO+rIaKWVpoGLjIyY Cw08XDKgYDjVXV9IpY4SyqYHsbiwNr+z+68ltvhkIFdskppk3nP78Rt3VjwsHQMM7VQ/JW BhvyCtVlzfuVSDDIthMjB5w0v92W9IeEALSoKtyc9g/60L1WKxTdBbiqgbfHeqAc+qTM9H CBRn8Y9Sc5arMWqsct+k/2hBgg4ZaPeN6WrdaPehoZ/HW0zM9P2BaaIQUoZhwBhVKVAqKy ENP8VpJZmp4B0XLxPct9l7Orgp/2jSSpmdXQHlP0f7pEwBxF+wFu4GCjUWbMyg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1624451081; 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: content-transfer-encoding:content-transfer-encoding: references:references; bh=HgUlrfBIFOM8rnuHwF2g/QbRSSYRGCph9RQoo4B94zA=; b=gaujydeliZXzKMpqg+eu6bRauP6w5NWmIkdgs/tf4+/KUP5YOddC94Ls/LikiEa37WuYMp C7UWWiQlTP6cVnAg== Date: Wed, 23 Jun 2021 14:02:21 +0200 From: Thomas Gleixner To: LKML Cc: Andy Lutomirski , Dave Hansen , Fenghua Yu , Tony Luck , Yu-cheng Yu , Sebastian Andrzej Siewior , Borislav Petkov , Peter Zijlstra , Kan Liang , "Chang Seok Bae" , Megha Dey , Oliver Sang Subject: [patch V4 54/65] x86/fpu: Remove PKRU handling from switch_fpu_finish() References: <20210623120127.327154589@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-transfer-encoding: 8-bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PKRU is already updated and the xstate is not longer the proper source of information. Signed-off-by: Thomas Gleixner Reviewed-by: Borislav Petkov --- arch/x86/include/asm/fpu/internal.h | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) --- a/arch/x86/include/asm/fpu/internal.h +++ b/arch/x86/include/asm/fpu/internal.h @@ -523,39 +523,13 @@ static inline void switch_fpu_prepare(st */ /* - * Load PKRU from the FPU context if available. Delay loading of the - * complete FPU state until the return to userland. + * Delay loading of the complete FPU state until the return to userland. + * PKRU is handled separately. */ static inline void switch_fpu_finish(struct fpu *new_fpu) { - u32 pkru_val = init_pkru_value; - struct pkru_state *pk; - - if (!static_cpu_has(X86_FEATURE_FPU)) - return; - - set_thread_flag(TIF_NEED_FPU_LOAD); - - if (!cpu_feature_enabled(X86_FEATURE_OSPKE)) - return; - - /* - * PKRU state is switched eagerly because it needs to be valid before we - * return to userland e.g. for a copy_to_user() operation. - */ - if (!(current->flags & PF_KTHREAD)) { - /* - * If the PKRU bit in xsave.header.xfeatures is not set, - * then the PKRU component was in init state, which means - * XRSTOR will set PKRU to 0. If the bit is not set then - * get_xsave_addr() will return NULL because the PKRU value - * in memory is not valid. This means pkru_val has to be - * set to 0 and not to init_pkru_value. - */ - pk = get_xsave_addr(&new_fpu->state.xsave, XFEATURE_PKRU); - pkru_val = pk ? pk->pkru : 0; - } - __write_pkru(pkru_val); + if (static_cpu_has(X86_FEATURE_FPU)) + set_thread_flag(TIF_NEED_FPU_LOAD); } #endif /* _ASM_X86_FPU_INTERNAL_H */