From patchwork Tue Dec 5 10:50:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 173983 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3359066vqy; Tue, 5 Dec 2023 03:22:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRRjKMMYvv2uXnO90FfSr0xWKJRm5Gg6ZfvjuNfTF0sz/G3p0QYqSVK1JE+49bdJ8HKuL4 X-Received: by 2002:a17:902:c3c5:b0:1d0:708c:d04b with SMTP id j5-20020a170902c3c500b001d0708cd04bmr5602853plj.31.1701775353901; Tue, 05 Dec 2023 03:22:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701775353; cv=none; d=google.com; s=arc-20160816; b=vHqwibUgbYsbrbAQYkaonbFbov7vs/MDnDpZlnsVsODch2wz2Qp7rgAZWtWNF6hdkC uoXOHR6i7ZVGNbEOEiHl7aBeVyZje/Lc7sQnFKywanvdamnkQIsuFwcIuZ9o0WwuMHBa kevy3H7UKnr4r1PLhBAAC5USVkHaflMGnxj3H4v3B3+8oK/InngNwM1Ci4v6ezv5ZGni 4KMzuGy5d3X93NdLRI9yb/Zfxkwtg6M9tE7CVkct4fiivV8HCb9iBywVLBLOj5EKcRQb 6cLOXEtmByZRTqB8aEmxVj3R6o3Wo4G5x94Rhg4gdj2IYTm7eRqaRoFruvSgCXZ0goGs PpdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WqbWYjvc66BG065U++U0Iwa66fkrKvaluz2EDMg59UY=; fh=uCCWEUVpLc/xDP/D3WvGY/BxHU9d0NQYu/T71GEsNmA=; b=m1F3Bk2fdR5xTIEvSQh+FIGNp/KOdRG/qpJnQ1CO5Shqwcx7O5qx4nLLGzzdlTQFcX 5yzzU4tFEouJjB2Z/05gcyHoLXPrm/hoBnvgsx0SO70Y6eOIiGXX4su+As9Nul6YCMPc HRsZAvIFCWpDC8fWnmnvKApvzB7Sdm3jcuaMP5PnbQ1QQuyG+KRmadmrrcZAVrDnHgzK GGJ7B9egdu6x1Jwn+1NHkzQHPyrnGR6FU5c14YrObGhy9BbTpyUu0s/cJOjvDAvmT8Nm 6z1mtIiU+Jsg/ch5zjtDxzcyvSYLduaSrp5nCpbbZG6sjYQVQ3TmenLgmgzpVe3VK7+g L/xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=O7qPRzf1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id z7-20020a170902834700b001d0b78ea7a2si2170037pln.516.2023.12.05.03.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 03:22:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=O7qPRzf1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2670E80530E0; Tue, 5 Dec 2023 03:22:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442255AbjLELWN (ORCPT + 99 others); Tue, 5 Dec 2023 06:22:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442086AbjLELVV (ORCPT ); Tue, 5 Dec 2023 06:21:21 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28DDD122; Tue, 5 Dec 2023 03:21:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701775288; x=1733311288; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1ausx4Z+ZyraUX+YcuvtrDimsqYt0aM/gmBdfI6uiWo=; b=O7qPRzf11XYtu9BLemEDhZSRr67d8BWZtC5lqzFlStIIqH/3lBFRD4eq A1Ff9oWyvdPavGs8BPk0c129Rn1UgxYWFGy7ULjOi8c7qOE6EBh7F0jtD l8l5MEjmmvPdjKi3Jft1s+3hJ8ThrghhZFLxf02LWwCfNNM/DO9is7M5x uaEZ0zokaGUPaWBkmX7XoJppLgKOiyMusQWis6ohbw/3jIMbdqWZxwi7l 4uxiqKj0tC8L0lTRnZF6m2LlrrChfsZMCoMlbZ4RinPoEaKAEAy+HtwhC I89yBU8qt/8vLsoKc/SODoYR+QQqlb83r0zVbZnDojhJ4nypTBaFqq2U7 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="942497" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="942497" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2023 03:21:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="1018192949" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="1018192949" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga006.fm.intel.com with ESMTP; 05 Dec 2023 03:21:20 -0800 From: Xin Li To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-hyperv@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, luto@kernel.org, pbonzini@redhat.com, seanjc@google.com, peterz@infradead.org, jgross@suse.com, ravi.v.shankar@intel.com, mhiramat@kernel.org, andrew.cooper3@citrix.com, jiangshanlai@gmail.com, nik.borisov@suse.com, shan.kang@intel.com Subject: [PATCH v13 15/35] x86/fred: Add a new header file for FRED definitions Date: Tue, 5 Dec 2023 02:50:04 -0800 Message-ID: <20231205105030.8698-16-xin3.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205105030.8698-1-xin3.li@intel.com> References: <20231205105030.8698-1-xin3.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 05 Dec 2023 03:22:26 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784440793482722233 X-GMAIL-MSGID: 1784440793482722233 From: "H. Peter Anvin (Intel)" Add a header file for FRED prototypes and definitions. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v6: * Replace pt_regs csx flags prefix FRED_CSL_ with FRED_CSX_. --- 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 000000000000..f514fdb5a39f --- /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 */