Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1924867rdb; Wed, 31 Jan 2024 13:27:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHVjz1H1axsCXfM8ci9F5/MI6tSrZndM/XhihAtq4V27MV8U0+wYJnzVVT+iJjWIsPMAKuB X-Received: by 2002:a17:903:1206:b0:1d7:7347:d80e with SMTP id l6-20020a170903120600b001d77347d80emr3408189plh.37.1706736444248; Wed, 31 Jan 2024 13:27:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706736444; cv=pass; d=google.com; s=arc-20160816; b=S5BebBBAuGhP3gTF6wqnal9S7iAWAq/5Vcb3G4E6QYIAYxZjtKDBihKqys194PmYJE YcGgwXp1F8rr44i32OSp4RzAbkta/a0s5ybDjFPSq04hxvfKIlhf5iWEyU+ne2Lr6iNl yJcweMHMbJItZo5Pm1RYzelGNxnFZzGXHkahKS5OyNpARg87LFhdP6/XBLnl/EKNttFq TOhxyW1yqa1VhVYPJiUaDf+uLgOxRu2an0490a+D5O19+NkUtSuKG4G18f21Ms5DzVxH dYX5u6JGp2e2d643X/ufvRetXI0vKBWvWBzFAs3yUPptIayqwydx75+46Kx/w6gf+mi1 YevA== 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=rymz2c3DdrwsI0mDypE02JMx6MX3xJ3zAuZkZlaGZms=; fh=0b82dkJN0AsXUj7xlKm7/0U214Y2vagblGD8jMbQFaw=; b=hVKyQu7Am8t10JGcwJ1F0Adnulu0lELF98br0vFeN9Ok+aPtzFMtrqMyRv9t6Pdoi1 y8vqsdoHTxI64PxXgoIjnE1PTSwf46zk/Cuez2zqWigCuFc8KxMIzuSEVZ8tNVtukpiK KkDHcHSXclDqM6oexNxpqR3HGjEEADh78BIUmofv9JblXlnG2DgUfZKpuERegmzWzrBr UUyLBt4fy/CaBOyUOcYx9m6AKzSP2DtAoShizy+Lk9TRhBh3dFWDsKi2mI0ocV0pZBkh Kns7W/+1RB619zcY+wBTxJXU6PWnvx9EXgbTVPPovxqkXPwecZGmwXELrwNcb4w98spF qYlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="DeN/hxg2"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=f4QwySYW; 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-47138-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47138-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=1; AJvYcCUqItbEFXxXgHqZ0F+IoGMbvnWkYY1y50wAe4hlOD256Dt0zbdafBMRr+jBheDS8IMlhGZ9XwZGd1BMN60YSkd73LL2LG+devbjW3msGQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a4-20020a1709027d8400b001d730061829si10160895plm.324.2024.01.31.13.27.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 13:27:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47138-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="DeN/hxg2"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=f4QwySYW; 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-47138-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47138-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AD54BB25BC3 for ; Wed, 31 Jan 2024 21:20:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E707D41206; Wed, 31 Jan 2024 21:14:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="DeN/hxg2"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="f4QwySYW" 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 6A13D3CF6D; Wed, 31 Jan 2024 21:14:54 +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=1706735696; cv=none; b=mFrz+TO1Zkowmsp8PYq2zcrIBF/vbxcuMWFD5vm1wiKja39olZ/0U8jHlzEH0ScDUFbhEFDZ5DKWxnFTttz8iPWNfv81f1sz9Bimyw8Az4S2kQJIKQtPfqbuwo7CFlwMZxniGMsdLCeG39pjZMjGKvam7Fnn7ff7U3pXIyjKG4M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706735696; c=relaxed/simple; bh=EHFjjE6dQ+n8LuAiDPQ8mrSHGuh2B/d/Lak2e4Q8qqQ=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=oYGuCYJ6nsGOP8OkHLurDzpZlw1IsEklVWcoITMw62d8vSRjkeV+2X60I7I/mao6xiEyNAkEqm191tQdttE0gaznnQVFcH2eH/1YVTbSNdfrptPSqHbaZ7EJx9KDIM/4Vff4VTQoceOaSsNSdXxVoFcsI+aFycWnmTxZLDIICag= 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=DeN/hxg2; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=f4QwySYW; 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, 31 Jan 2024 21:14:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1706735692; 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=rymz2c3DdrwsI0mDypE02JMx6MX3xJ3zAuZkZlaGZms=; b=DeN/hxg2BLmhn3ZE61/BWLdCCsq5n/h7i8/jNlVVvm4gKpLVGWWpNOvRoT7Kt1Z5QUbTpF s5tZSa7m9WQhWayjIvTSG9wF8E+A0CfYcXp34OjJ8rBCDMKLpltuotc+NgQD+92m2vNI23 wcP7829PebciA17ywVG0VK2LuSOdCgDwYjF5a2yY4RAE9AQH4NyFNPU3QNxibXqYFWnYSl rLzwRiJQnrux5cGBA3t+vHtveea7XJ3tnHCqLXl2Y2A3V+b5B0w0E/RE2SSsB5lyiVaYJP 6RcFG4dZoYZ2rAxWlKgJmuu5H2+/sjlHYv8ucnPbPALbrJwQ1GscmZ0pKnk9Hw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706735692; 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=rymz2c3DdrwsI0mDypE02JMx6MX3xJ3zAuZkZlaGZms=; b=f4QwySYWd97rsXbKL/0k/rABmragU0mhUH3/GyTfM88X2mcn4WA/w/KDJjYbJ0v8AWE9Mj kF406FnMOPUJkxBQ== From: "tip-bot2 for Xin Li" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/fred] x86/ptrace: Add FRED additional information to the pt_regs structure Cc: Thomas Gleixner , "H. Peter Anvin (Intel)" , Xin Li , "Borislav Petkov (AMD)" , Shan Kang , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231205105030.8698-15-xin3.li@intel.com> References: <20231205105030.8698-15-xin3.li@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170673569171.398.13558919240133424421.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/fred branch of tip: Commit-ID: 3c77bf02d0c03beb3efdf7a5b427fb2e1a76c265 Gitweb: https://git.kernel.org/tip/3c77bf02d0c03beb3efdf7a5b427fb2e1a76c265 Author: Xin Li AuthorDate: Tue, 05 Dec 2023 02:50:03 -08:00 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 31 Jan 2024 22:01:20 +01:00 x86/ptrace: Add FRED additional information to the pt_regs structure FRED defines additional information in the upper 48 bits of cs/ss fields. Therefore add the information definitions into the pt_regs structure. Specifically introduce a new structure fred_ss to denote the FRED flags above SS selector, which avoids FRED_SSX_ macros and makes the code simpler and easier to read. Suggested-by: Thomas Gleixner Originally-by: H. Peter Anvin (Intel) Signed-off-by: Xin Li Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov (AMD) Tested-by: Shan Kang Link: https://lore.kernel.org/r/20231205105030.8698-15-xin3.li@intel.com --- arch/x86/include/asm/ptrace.h | 66 +++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h index b268cd2..5a83fbd 100644 --- a/arch/x86/include/asm/ptrace.h +++ b/arch/x86/include/asm/ptrace.h @@ -56,6 +56,50 @@ struct pt_regs { #else /* __i386__ */ +struct fred_cs { + /* CS selector */ + u64 cs : 16, + /* Stack level at event time */ + sl : 2, + /* IBT in WAIT_FOR_ENDBRANCH state */ + wfe : 1, + : 45; +}; + +struct fred_ss { + /* SS selector */ + u64 ss : 16, + /* STI state */ + sti : 1, + /* Set if syscall, sysenter or INT n */ + swevent : 1, + /* Event is NMI type */ + nmi : 1, + : 13, + /* Event vector */ + vector : 8, + : 8, + /* Event type */ + type : 4, + : 4, + /* Event was incident to enclave execution */ + enclave : 1, + /* CPU was in long mode */ + lm : 1, + /* + * Nested exception during FRED delivery, not set + * for #DF. + */ + nested : 1, + : 1, + /* + * The length of the instruction causing the event. + * Only set for INTO, INT1, INT3, INT n, SYSCALL + * and SYSENTER. 0 otherwise. + */ + insnlen : 4; +}; + struct pt_regs { /* * C ABI says these regs are callee-preserved. They aren't saved on @@ -85,6 +129,12 @@ struct pt_regs { * - the syscall number (syscall, sysenter, int80) * - error_code stored by the CPU on traps and exceptions * - the interrupt number for device interrupts + * + * A FRED stack frame starts here: + * 1) It _always_ includes an error code; + * + * 2) The return frame for ERET[US] starts here, but + * the content of orig_ax is ignored. */ unsigned long orig_ax; @@ -92,24 +142,30 @@ struct pt_regs { unsigned long ip; union { - /* The full 64-bit data slot containing CS */ - u64 csx; /* CS selector */ u16 cs; + /* The extended 64-bit data slot containing CS */ + u64 csx; + /* The FRED CS extension */ + struct fred_cs fred_cs; }; unsigned long flags; unsigned long sp; union { - /* The full 64-bit data slot containing SS */ - u64 ssx; /* SS selector */ u16 ss; + /* The extended 64-bit data slot containing SS */ + u64 ssx; + /* The FRED SS extension */ + struct fred_ss fred_ss; }; /* - * Top of stack on IDT systems. + * Top of stack on IDT systems, while FRED systems have extra fields + * defined above for storing exception related information, e.g. CR2 or + * DR6. */ };