From patchwork Sat Sep 23 09:41:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 143987 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp341252vqu; Sat, 23 Sep 2023 12:36:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbWP34uNNScv0gu30cIMDXdWicmjV5wjXl/xXEDlchMYkc+skN7frpbgsW3VZ8r6sRWH0m X-Received: by 2002:a05:6a20:938e:b0:153:8754:8a7e with SMTP id x14-20020a056a20938e00b0015387548a7emr3601563pzh.3.1695497816496; Sat, 23 Sep 2023 12:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695497816; cv=none; d=google.com; s=arc-20160816; b=CwnNSW2eLQ25S7PiG9jAaZksv/+u4vv/JE18lEbbpM0GDPF1VY3Rm6fTBjmIgWW0Gb YA4MhlnmIEMjcugU98dp/yozmjMboEva8lXh4/A80IxcyByLH/m+YAFqeQooVJ2rHdk9 61A2UQOBzweP0diavxK0LY6arpOBZqeDfze6hpAkcwaaD79D412DIxK9rjlqGmirfL3o rlHEiE9EQOIE7mUwBIU1ykZBqFPqS4+5d3ekt8i0iasoQhBy4JzqQGho2VwqWvYXDahW ALZDd0yLIV94/YZ7zrvvju/xjVs32SYGrtdXeTHEmV5HlTGbtyOhZBgr0sj5vamdHutu ynBA== 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=KHGdYssn2/S0nhcvv+MuhXtfyk6bSylHaLWAZxxlieQ=; fh=Tb1p8S3iOxe/kX/WSNC3xEJzSVgGJ5DaxSrKb+pzH+4=; b=X9XMdX+PAjMmoWxT1ZXZ0EUOuiAUDhGdU+L48441AGZNHheQltQ4d6pJfEqPZ4F+BZ XIRVXwGLzln6NGEcrcoGIf/jHBG4hzqWWPBvsD5/NRmpvCbwUcUZx6dzYx2DXeK0U/Pe CvtIxTF3G9YA2UyQO8QBLiGro8ID0GoyM8Iyun0xLDAn/jiYI00OteKvyKt28cX+TKu2 cPYpBfWaIfYJyVNqXrIXUXUbH8pgBCZJPLee/saKn7OyVjKQJ55rTYHIbB5hB9757qTL BTH5zHW4D/SdLl3gQNrrVXk+9OCmnCPOEUuRGQcLf8ehm7LbaT8GWFr4tfZGdXzfgZFB hwJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eJd5ydBb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id cq10-20020a056a00330a00b0069023afd0d1si6429383pfb.329.2023.09.23.12.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 12:36:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eJd5ydBb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 8F46E867F1F7; Sat, 23 Sep 2023 03:13:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231601AbjIWKNM (ORCPT + 29 others); Sat, 23 Sep 2023 06:13:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231398AbjIWKLw (ORCPT ); Sat, 23 Sep 2023 06:11:52 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D56719E; Sat, 23 Sep 2023 03:11:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695463905; x=1726999905; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SbR2wCTkousO/IPIjdDUqT7zLHmXpw3IGG9LN/Z2MXU=; b=eJd5ydBbkRSEEfxYp+oXjchgGCVniK65y84AMrB2vikSANZOheEuNk/Z vzTXsfRQiqeUwP8HWPaJLSfXP+mzioMWHUS52QNMmpyYFiJubkLBhBe0n Ncrx35Oq5TL4ByhqwrmhBiqjBAS8k2+CqQSuVRlbqiQo7IY8E2UaZrp3x T4rg1MytM/mK0pQR1SaTZ6sGVTlKb0V0pSd6HOqBRmgLzYUbkCOxq0eZI taq2TfzsGAuIxPqH95ebEv8eJrykq2mqwFG4FUcGVXyzFNxd/GBK7IPlh 8ZrOYodVZwJbhM+1wDQ7T0HAohLLGp9q8gZYx9y210hmUzh6OBlb8NoGo g==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="447492277" X-IronPort-AV: E=Sophos;i="6.03,171,1694761200"; d="scan'208";a="447492277" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2023 03:11:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="813388157" X-IronPort-AV: E=Sophos;i="6.03,171,1694761200"; d="scan'208";a="813388157" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga008.fm.intel.com with ESMTP; 23 Sep 2023 03:11:44 -0700 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 Subject: [PATCH v11 17/37] x86/fred: Add a new header file for FRED definitions Date: Sat, 23 Sep 2023 02:41:52 -0700 Message-Id: <20230923094212.26520-18-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923094212.26520-1-xin3.li@intel.com> References: <20230923094212.26520-1-xin3.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Sat, 23 Sep 2023 03:13:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777858318382535872 X-GMAIL-MSGID: 1777858318382535872 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 */