Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp386642lqd; Wed, 24 Apr 2024 05:43:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXPCz5KhH96753d7XvzolL/AArGs5UHjXPBGUa1Vfa9964HQm/S9rg6GpsdLoFB6FJuuNmdP+LxMsxKMJZVW3VcZ3MZ0uH6t03sTsugyQ== X-Google-Smtp-Source: AGHT+IHDCBFcUa+Oar/rMHhbsnYjqlE828Km7+1LZQc9xqk44q0Td1GTWFnCBC1obIxxgPh252Xj X-Received: by 2002:a17:906:2412:b0:a55:5a0a:a74b with SMTP id z18-20020a170906241200b00a555a0aa74bmr1653997eja.33.1713962610966; Wed, 24 Apr 2024 05:43:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713962610; cv=pass; d=google.com; s=arc-20160816; b=PxfG8V+tW2GvOhqG8cDR0SIpr97K0RmayIw/ymXjMhTOOqb/UmBHYfrPKSUdV8ZhHW UrXGQd4tixQzEgDL1LtoOQVqXDMA465Q67UouD5E2Z8tEQe1ScRUCxEe155h65vjYazv SQgk+mUJAQX8MCXssnwhv/LjfWy/Dty+rLWJlbCn7QMUyjFUXvtX5XglpCef9odyadvP o+P0b73ZJ7vpZHVOWptT6CY3hYPcTaUTpvz7ViRVupDlJ6b+NbJCWYPKqMHYLSM5rDdo lfII4rWH1NGCYhFfC+39pccP0VSbGFc87Yn3G6tDEb3UqCfvsrXAy+B5eAxs8nYFJdN5 OxSw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=OUQE+acBF3dvV/ZAfvhPLXrAIWvFtQLpqbB1lud0+Cs=; fh=WDkTG6sVN1VhDPOF+/QIXg9UWBIeyITyfQOfSjWdfGk=; b=YZXCRZyQIUxKcmLSSXo/jZwA0KiCvd1hTNF5Lfeq3KrlMXiOn+gqGkr8iNkgOnQNTa Bmtji+0kiCG8O4T7eL5BdbKhNHT+/U0kwVvVdwYZRKWQg+arWCzHGqSvM0TI/mqV8XOz 0HixjUoPoWJguaacbzsq5E0u0UEwlJRxg4PG1ptomywsHDLJLIfYwm38CaD5GevMTLYh lJezRmyFxnN5gCj9K9gTzBYd3d4l94WJKXPrcWONgAQZQ6MMALqRkV3S6USfNi7NaOZa Xksj3Kksfqzr0vfLVGumh05X08olNmtifbxPjXNBKkKgBFhohZqDWdZh9pnWScd/9Krq 28hw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EpyztPFx; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=X+mJDKLP; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-156887-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156887-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id mb21-20020a170906eb1500b00a5533761bf5si8588362ejb.694.2024.04.24.05.43.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 05:43:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156887-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EpyztPFx; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=X+mJDKLP; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-156887-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156887-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7CC051F25D3F for ; Wed, 24 Apr 2024 12:43:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F7E8143891; Wed, 24 Apr 2024 12:43:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="EpyztPFx"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="X+mJDKLP" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 6560B33989; Wed, 24 Apr 2024 12:43:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713962599; cv=none; b=CTDiaPgjdwZH499Xd+A7n2EiSeNmaBmgvN1o7vWnoHdsVDgq79AKPIg1MdU25uQ9pMz6+L2HFFuLwPNG302UlffZpZjYOnbHKNIti5k5yxYZL46GskQHnSCPv7Hkgomcxu8zgse/9IorFK9K/T2hOkD16Nd3RKTzRy2Q5IzlS9o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713962599; c=relaxed/simple; bh=IRKcdmhT4sIety80BPi8y3Ndwm5wDa35FgP+JRKhwhg=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=SvMQQ6VyM+4QrnS0164FwVeniLr4bh7+wulhssEDkaVz6OgdmkFsG8csxq6j6s/7LVp5F17KEqvRFuCgKKd45fZKPWNPHRqarfKP9wiXMSG1wN3gLU6zJ+NqCt4VG++1a4bxZfPTjRLi0rr2CJGfOMXPIa6CZXEQLjJmXlqOSo0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=EpyztPFx; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=X+mJDKLP; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Wed, 24 Apr 2024 12:43:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1713962596; h=from:from:sender:sender:reply-to: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: in-reply-to:in-reply-to:references:references; bh=OUQE+acBF3dvV/ZAfvhPLXrAIWvFtQLpqbB1lud0+Cs=; b=EpyztPFxY+/m1m2t4kxVmUPlX9cT3It5DM8UChrA1/uJGo8ERIULz+yV7os+vVcU6iqAEr 5YCcj4HOTN6cEURCWS68oTjFIVvbxfjxl3oGH92mgHix01NwPon9wbfztm6KcsRBicy0XX J6NKetpytrA8llnRQ/cL8a1Ek3oXiG4VDYRNlG88dt6Ta1xZQo9S5N7M/vmhUE1ILQw5W6 Oer0Rmz3SAijmpsW82oq+7+f4VocoPovvJ9Pe7ZBZY4cVe5sy9nFplNn69lGYJOV7UKEEs gaqMoCeoqXH52N45AYULBFvNTspJsmC4PBvetZE8zIiG9E12r2jcfBKmrql5Zw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1713962596; h=from:from:sender:sender:reply-to: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: in-reply-to:in-reply-to:references:references; bh=OUQE+acBF3dvV/ZAfvhPLXrAIWvFtQLpqbB1lud0+Cs=; b=X+mJDKLPi0SQpfnOwPR4UuOt5CoVpydMIZ27tSlBLIm1s/XOEdcvZn+ZIYchkEqAEfKx7h HjVuN+uIa4K5BhCA== From: "tip-bot2 for David Kaplan" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/cpu: Fix check for RDPKRU in __show_regs() Cc: David Kaplan , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240421191728.32239-1-bp@kernel.org> References: <20240421191728.32239-1-bp@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171396259581.10875.10910607244661766462.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the x86/urgent branch of tip: Commit-ID: b53c6bd5d271d023857174b8fd3e32f98ae51372 Gitweb: https://git.kernel.org/tip/b53c6bd5d271d023857174b8fd3e32f98ae51372 Author: David Kaplan AuthorDate: Sun, 21 Apr 2024 21:17:28 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 24 Apr 2024 14:30:21 +02:00 x86/cpu: Fix check for RDPKRU in __show_regs() cpu_feature_enabled(X86_FEATURE_OSPKE) does not necessarily reflect whether CR4.PKE is set on the CPU. In particular, they may differ on non-BSP CPUs before setup_pku() is executed. In this scenario, RDPKRU will #UD causing the system to hang. Fix by checking CR4 for PKE enablement which is always correct for the current CPU. The scenario happens by inserting a WARN* before setup_pku() in identiy_cpu() or some other diagnostic which would lead to calling __show_regs(). [ bp: Massage commit message. ] Signed-off-by: David Kaplan Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20240421191728.32239-1-bp@kernel.org --- arch/x86/kernel/process_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 7062b84..6d3d20e 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -139,7 +139,7 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode, log_lvl, d3, d6, d7); } - if (cpu_feature_enabled(X86_FEATURE_OSPKE)) + if (cr4 & X86_CR4_PKE) printk("%sPKRU: %08x\n", log_lvl, read_pkru()); }