From patchwork Thu Sep 14 04:47:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 139930 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp707116vqi; Thu, 14 Sep 2023 17:13:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4/lDdyhUeq97q7/KkZL70N9DIRUkcjD5gnX0MvHb/tcLFvBRk5fKFLRyHrS/b9kdIzbY6 X-Received: by 2002:a05:6a20:7f84:b0:13d:7aa3:aa6c with SMTP id d4-20020a056a207f8400b0013d7aa3aa6cmr376553pzj.0.1694736837515; Thu, 14 Sep 2023 17:13:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694736837; cv=none; d=google.com; s=arc-20160816; b=eAMDPXq55p1uJE/lvPSkJ+E2xB5+A/hnRfyE5XNKqD7xlxVTxK0SpiHHb+/akr7jMo AFsEHwCnoC7EUru3ygEaRxkrEhJj14zK23W1kxKyFBGk7Jr+IjLvjLY7+F8zlqV2jYis UpGtyPEDjbSqtAzoVR9sQpVEOtLC++ybY5uy2ZKoP9G9TZYhAX+kn59lRvuCq+lXNOoY 56uP0Yfw03turFwFuJnOiSebnU+euq33M1YTWUqTjnzdbzvtunkk0uUhmqM2SrCSSnfL oHPovmSYWlgZUbvgjvOup8ixnBjZgbtDrzY8tgJSb/cxxV1CfWv9JmYXt06/04oZIjpn iImg== 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=jqCbnajAXgJ+s7A1aA7DOHJD13/+EpD442pw8d+Ofss=; b=0YCeQMJXAYhIpvAwmNJwDnzEWt8fiMHBEsB++zpgzTsnSwOL2H6uvzYWPc/sPQs6BK 3naFB4IlQWHToRqU+EDcsRjhTjThwjGMDTm5QQoPxUB7baa/mvKBwTgvyVqgrYdbCxq6 sgsr1eg8HXX55yGQSGdHsnCL2dxFMZHW58vvMY17WOBGWMslYuqRA2DARgP1VQOheGO8 DU4dcyKUmKB0dDLTn4vfnnT1yiEwj6OnDHdQY3KwGvANdL9WyHR3HHeuS10620YjucsQ 3QXsa/Op6+NKNiCBv9DvGrHD6mu2ZSTN9dwhkkQ4LOl0NlvJsmIoyMfsuoDPD2AoJqw3 wKCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="by/1gscZ"; 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 ca23-20020a056a02069700b00577448019b5si2518005pgb.276.2023.09.14.17.13.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 17:13:57 -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="by/1gscZ"; 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 BBE3185C35C3; Wed, 13 Sep 2023 22:20:20 -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 S234835AbjINFT6 (ORCPT + 35 others); Thu, 14 Sep 2023 01:19:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235029AbjINFT0 (ORCPT ); Thu, 14 Sep 2023 01:19:26 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37A0E1BE6; Wed, 13 Sep 2023 22:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694668760; x=1726204760; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SbR2wCTkousO/IPIjdDUqT7zLHmXpw3IGG9LN/Z2MXU=; b=by/1gscZHY9imVVilKeASC6nrXWpiGIPli9lncLQnJql2IJ0VI8USfo5 BB/yXnsLMZOiwF24pYWki+PzFzNcKIS970lHgEcx8rcvnc+WrNNv6R0yV fGoixDSpDsGsepRHD5qjMSCLEiWz/Uvy22qJXA92BZBFjSfjcfJmc+5EV Z2B81tPXi3bg+El0ALQ9hejZybylTc1xfR7vNydlS4Uy7XiZu4RO5te6i qwiz08YJ08wGJ2QttgU+Ejz+fBsyaIONH71I8NEDGMV/x1ygFiGLRBxEc 6GM4pBVLrI3s8w0Gx9k72Nfh4tGN2SbqTwU66v/a8LmeAqQ4CAOtJRRk6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="382661286" X-IronPort-AV: E=Sophos;i="6.02,145,1688454000"; d="scan'208";a="382661286" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 22:17:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="779488790" X-IronPort-AV: E=Sophos;i="6.02,145,1688454000"; d="scan'208";a="779488790" Received: from unknown (HELO fred..) ([172.25.112.68]) by orsmga001.jf.intel.com with ESMTP; 13 Sep 2023 22:17:37 -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 Subject: [PATCH v10 17/38] x86/fred: Add a new header file for FRED definitions Date: Wed, 13 Sep 2023 21:47:44 -0700 Message-Id: <20230914044805.301390-18-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230914044805.301390-1-xin3.li@intel.com> References: <20230914044805.301390-1-xin3.li@intel.com> MIME-Version: 1.0 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]); Wed, 13 Sep 2023 22:20:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777060373783205235 X-GMAIL-MSGID: 1777060373783205235 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 */