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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 EF5BBC47082 for ; Tue, 8 Jun 2021 20:06:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D2BA5613BC for ; Tue, 8 Jun 2021 20:06:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234565AbhFHUIO (ORCPT ); Tue, 8 Jun 2021 16:08:14 -0400 Received: from mail.skyhub.de ([5.9.137.197]:34472 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231162AbhFHUIM (ORCPT ); Tue, 8 Jun 2021 16:08:12 -0400 Received: from zn.tnic (p200300ec2f16b100e640acc4c45ae2c4.dip0.t-ipconnect.de [IPv6:2003:ec:2f16:b100:e640:acc4:c45a:e2c4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id AB5791EC03F0; Tue, 8 Jun 2021 22:06:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1623182778; 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:in-reply-to:in-reply-to: references:references; bh=/qD0+SnYeOyPC9noFgtAGu54g//5aZL1bQvzqOYQggw=; b=YkX29dM9g6kPeyu6JqDQNuALZIlBUfbmvEUQV7DHKHnr+Mp5IRW5KqZze7/aLsWffG+9/T eLMhbiFopYhccE0GNbkqgwuf20JCkD6Ojn6KvT3o9RJsdxJThSIbXiGc4jTAHai50gyOQY 5nZLEjtACsNZx9pQyD6ryjvEdYh+dQU= Date: Tue, 8 Jun 2021 22:06:18 +0200 From: Borislav Petkov To: Thomas Gleixner Cc: LKML , x86@kernel.org, Andy Lutomirski , Dave Hansen , Fenghua Yu , Tony Luck , Yu-cheng Yu , Sebastian Andrzej Siewior , Rik van Riel Subject: Re: [patch V3 4/6] x86/pkru: Make PKRU=0 actually work Message-ID: References: <20210608143617.565868844@linutronix.de> <20210608144346.045616965@linutronix.de> <87tum8xj4x.ffs@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87tum8xj4x.ffs@nanos.tec.linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 08, 2021 at 09:15:42PM +0200, Thomas Gleixner wrote: > But if nothing touched the FPU between T1 scheduling out and back in, > then the fpregs_state is still valid which means switch_fpu_return() > does nothing and just clears TIF_NEED_FPU_LOAD. Back to user space with > DEFAULT_PKRU loaded. -> FAIL #2! Ah ok. > Why? It was clearly wrong and I can reproduce it with a hack which > forces a schedule to a kernel thread and it fails all the way back to > user space. Oh, I was speculating about some weird luserspace's behavior of clearing PKRU and then relying on the buggy behavior of getting PKRU restored to DEFAULT_PKRU. I know, it is nuts but it is user-visible change. And yeah, probably nothing does that... > I chased that because I observed sporadic failures when forcing PKRU to > init state and then observed the default key being written. I had some > extra trace_printks there to analyze something completely different :) As you do. :-) -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette