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 75B71C48BD1 for ; Fri, 11 Jun 2021 16:45:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A4856100A for ; Fri, 11 Jun 2021 16:45:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231878AbhFKQri (ORCPT ); Fri, 11 Jun 2021 12:47:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231504AbhFKQqd (ORCPT ); Fri, 11 Jun 2021 12:46:33 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4013C0613A2 for ; Fri, 11 Jun 2021 09:44:32 -0700 (PDT) Message-Id: <20210611163113.982176939@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1623429871; 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=YKbxl0e2RP10fPzHFgLtW3AlH0ivwLUXrvNVA5njGrI=; b=DgpwVCFuQN0C5yx3zdFMJfe5LO3MhxxC0iRbcdW6QmTJNZZU2qJmh04Oa4FHyjSx/jRkUe celJ+NSpNRoDowtx/5GnpgFCwKfqeDuhhmL0TGmKH0jPq5nmMqfwHO4fBKHQLtPV3nu+Rc M01mcq8jrVb7Oe7okdcd9BqTkjY6mm7UIDjDXUPkKXfwZRNhuBxm5Y91LzzjaQuHW4HZTD Jeo1ENOJ+ihU/Y+9d3IM4cDKRjzXrdTsarCR0LxH2Vbj8Jhccwc6IOCG37mHJeG+zBr12t 32LBe2Ted+vjivZ8KCDxynJqbJXaLJjD5QlE6DXLYNUj5JH+T7GhmBPjXYpb8w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1623429871; 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=YKbxl0e2RP10fPzHFgLtW3AlH0ivwLUXrvNVA5njGrI=; b=xDM6jq934OZFMud600JvNfmKTVIAeLq3TvgzHL75SiMUnzoQKsas2rgMKAnNCFS6gpFKdW c3o8sjV5lN1fKCCg== Date: Fri, 11 Jun 2021 18:15:51 +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 Subject: [patch 28/41] x86/cpu: Write the default PKRU value when enabling PKE References: <20210611161523.508908024@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 In preparation of making the PKRU management more independent from XSTATES, write the default PKRU value into the hardware right after enabling PKRU in CR4. This ensures that switch_to() and copy_thread() have the correct setting for init task and the per CPU idle threads right away. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/cpu/common.c | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -479,6 +479,8 @@ static __always_inline void setup_pku(st } cr4_set_bits(X86_CR4_PKE); + /* Load the default PKRU value */ + pkru_write_default(); } #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS