Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1922470rdb; Wed, 31 Jan 2024 13:21:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZClWd0i5pdf9GTI/KV10eQptpG+LRcWYQPCX4RBh4qftddBaT37AAZvkPRsI3or8jFmkY X-Received: by 2002:a05:6a20:499b:b0:19e:3ae2:eff2 with SMTP id fs27-20020a056a20499b00b0019e3ae2eff2mr237940pzb.32.1706736080445; Wed, 31 Jan 2024 13:21:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706736080; cv=pass; d=google.com; s=arc-20160816; b=fW4IRoC1k+g5cSNayqc702YyG1I/MhH0gUA72i6E/o5sygMWf8Ju1p3ZWFM5dq73zh 7U2W0wYNCJL+DrR/UPVKjbIgOu4hCJjcmbNMPnMNrbFqUKWtJxlDaDXkPpHbyWsqwmXY wIggtJoLq8QTVDIV1CVrdHfWFmA1JyoiA9e8IDHas64/fHT9PCWklAuKk1cxFSx/kQs9 EIKntJMqyVgA7tR71BEXsieJmpV0iTrVx2xWhtxz8X0+H2N2MQc7B10AM+dojZITeALq EEA1AnqCl2MJ3pJZGHn1bc73gIBJLpLUBf9Q5MFr6ragD991zmR42t+VHBRSDM2NFwPw UMAQ== 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=sUzytkYDxm0KkYE8qGL7MI80IjdjFs7UE9gxGXTmv/M=; fh=c0h/sRMWWluJy3Z1Vyq0S2ReP9n4DBlLh0Vw5Vac6uc=; b=HUYrD6bksGUbl2ia6HQFd2tjPtvR+Vpiw+H6HaENVQLeswUycuDW6M4CqJB3nIPz4/ AQ/IZVwhn6mWMfAWXTNExH5i6S+y/UkfIod+TM0U2enGCM9gdSjzRDyz16YeCrI+203C +j4IVvmLaSQcZ/2T/dgI7/3ogi5dOYStQB+KwY+uR23ONqwVVBe1vwvKcARP4+St0SWp VAnQFKqayyYZfuEEn0e4e6w6m9RxTuggBufslxtJorJ2IWZJS2Vah88m6g5hPlcXT2Af Qk3PdaKbNYHPWrtq2FGari6HB94reKrw7mOYZ59Pm7rBzhEMXWE/e7ExCXnVFEqK9klj pxQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tEaoIFow; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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-47137-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47137-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; AJvYcCXql010+Fe2ROz4ehLfKFWDHqEAim3voTSFkTaQVtiXCyEA/TmZTP6HFrFms9wrfrK2SBk72eUAxtm4MvTM1PCE52Ywes22WtQHLLO25w== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m15-20020a056a00080f00b006ddcee012c6si10613010pfk.273.2024.01.31.13.21.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 13:21:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47137-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tEaoIFow; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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-47137-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47137-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BB662285854 for ; Wed, 31 Jan 2024 21:19:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 317D9405E8; 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="tEaoIFow"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dzvV2JjC" 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 BA0363C697; Wed, 31 Jan 2024 21:14:53 +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=1706735695; cv=none; b=PMHDbRWzDnjZcbXtu7UAqB3ZDFZFWFusZqiSEzHk7BRpD7lt//E7V6+EsBtmxFa7u2yKRwz+zsYJoa7Kv+Bl9oHPBTd3+8GDO3jIieNfjWPmnJlhCGvjUqNhpT2n6MpbuPsALAYVMa1fcK3oy7iNZlEGtyeSx+NJzRPfsHftoOg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706735695; c=relaxed/simple; bh=8O9DRo6yNumFZDNuSPEsyNf+Zc0iYbQA4Gjvilwrqxw=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=Srd1eeCODYwm8ME07mF/GWWoL9NO8mA8jCjCHn0ZtlGkNvNwFYJcItuhjDux3zuKj5jWk6eDfx3nG6RwsBJhKlPHbJg3UGF/wh530UOHrnoWyYzydQ/6CqyImPU+y/nxhCFloeWEWj1xbz9Kc97q3Kcis3vnHmm0OLbftd+z7cM= 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=tEaoIFow; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dzvV2JjC; 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=1706735691; 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=sUzytkYDxm0KkYE8qGL7MI80IjdjFs7UE9gxGXTmv/M=; b=tEaoIFowAIxwCeXqDBXG0xt+TLrdWXBEsPAkpbtizDH32JWqxce8Ncwnc4wvWD4PPKgM5w 33YS04AI6TlN5Is80txhxlMgbXIhif3lyzaEFgJJtIEzDQqeJ0ub/CGBM80JKKIDbXfEVL EqnYmVPKy1L7S9lIEjtAA9WiSk2NIujItnCkIN0wrwfZErH9G3uZkxs2yz2/gqf2v6UPyL 92AT/akUo4Gt6waBi7rmA3G2ArNsyiMxefy6lcjaDLCSCdGuCbQIJB0Hooe2E/hyQEFfht db7pi6+UQJ+FEVdupOvMQG9TgDorzOpfPnoDbvlX6y7sBYItMvUoHFproL4YvA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706735691; 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=sUzytkYDxm0KkYE8qGL7MI80IjdjFs7UE9gxGXTmv/M=; b=dzvV2JjCllAmiSgaSTfKaVffvdjMEDtOSiZMFCZigUT7hWVbpdNR/x/SwcPefQm09TIR7G NA3QRrnq6znIV3CA== From: "tip-bot2 for H. Peter Anvin (Intel)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/fred] x86/fred: Add a new header file for FRED definitions Cc: "H. Peter Anvin (Intel)" , Xin Li , Thomas Gleixner , "Borislav Petkov (AMD)" , Shan Kang , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231205105030.8698-16-xin3.li@intel.com> References: <20231205105030.8698-16-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: <170673569110.398.3068899198407694474.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: 32b09c230392ca4c03fcbade9e28b2053f11396b Gitweb: https://git.kernel.org/tip/32b09c230392ca4c03fcbade9e28b2053f11396b Author: H. Peter Anvin (Intel) AuthorDate: Tue, 05 Dec 2023 02:50:04 -08:00 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 31 Jan 2024 22:01:25 +01:00 x86/fred: Add a new header file for FRED definitions Add a header file for FRED prototypes and definitions. Signed-off-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-16-xin3.li@intel.com --- arch/x86/include/asm/fred.h | 68 ++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+) create mode 100644 arch/x86/include/asm/fred.h diff --git a/arch/x86/include/asm/fred.h b/arch/x86/include/asm/fred.h new file mode 100644 index 0000000..f514fdb --- /dev/null +++ b/arch/x86/include/asm/fred.h @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Macros for Flexible Return and Event Delivery (FRED) + */ + +#ifndef ASM_X86_FRED_H +#define ASM_X86_FRED_H + +#include + +#include + +/* + * FRED event return instruction opcodes for ERET{S,U}; supported in + * binutils >= 2.41. + */ +#define ERETS _ASM_BYTES(0xf2,0x0f,0x01,0xca) +#define ERETU _ASM_BYTES(0xf3,0x0f,0x01,0xca) + +/* + * RSP is aligned to a 64-byte boundary before used to push a new stack frame + */ +#define FRED_STACK_FRAME_RSP_MASK _AT(unsigned long, (~0x3f)) + +/* + * Used for the return address for call emulation during code patching, + * and measured in 64-byte cache lines. + */ +#define FRED_CONFIG_REDZONE_AMOUNT 1 +#define FRED_CONFIG_REDZONE (_AT(unsigned long, FRED_CONFIG_REDZONE_AMOUNT) << 6) +#define FRED_CONFIG_INT_STKLVL(l) (_AT(unsigned long, l) << 9) +#define FRED_CONFIG_ENTRYPOINT(p) _AT(unsigned long, (p)) + +#ifndef __ASSEMBLY__ + +#ifdef CONFIG_X86_FRED +#include + +#include + +struct fred_info { + /* Event data: CR2, DR6, ... */ + unsigned long edata; + unsigned long resv; +}; + +/* Full format of the FRED stack frame */ +struct fred_frame { + struct pt_regs regs; + struct fred_info info; +}; + +static __always_inline struct fred_info *fred_info(struct pt_regs *regs) +{ + return &container_of(regs, struct fred_frame, regs)->info; +} + +static __always_inline unsigned long fred_event_data(struct pt_regs *regs) +{ + return fred_info(regs)->edata; +} + +#else /* CONFIG_X86_FRED */ +static __always_inline unsigned long fred_event_data(struct pt_regs *regs) { return 0; } +#endif /* CONFIG_X86_FRED */ +#endif /* !__ASSEMBLY__ */ + +#endif /* ASM_X86_FRED_H */