Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1776709rdb; Mon, 2 Oct 2023 23:56:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUpujrb+qiO/F6fI9mX1h2w5eXjGGOY2g500TQxKMVz8D1QYrXhm6gYqLa9YFlnU4PpRnB X-Received: by 2002:a05:6a21:33a2:b0:15d:c86d:27a6 with SMTP id yy34-20020a056a2133a200b0015dc86d27a6mr13793432pzb.55.1696316173336; Mon, 02 Oct 2023 23:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696316173; cv=none; d=google.com; s=arc-20160816; b=hU9mUpbVYIpeJ+y9M9xRgcgzfRPikjKRqFUEbbfguyLKrJXQLGTKlFvgVfsvIY9jgD uic/FrD//JuKaPQ7kDigeGrk3A9QTzbA2ys4IPI2mzSyAzaAPzXniYTFd04dsHOgKWmk AEEdZS8X/xs2BIXLZO/qWcykGOAuxoTaO7kK7b9nsZAqmMGTCaYP9mEL56CHVOsV+a/J 9BxXJiRdEY84+NJiRl8+QVMO8JnWYM6v0owf7Moj0Vau4yMtF/YO7n/DlPjNPZFAMb9F kEtu+gVqMrP8D/lypy1+J+COebUzzA7mkjVAtgD1JY5iz91NrbvBUgto/teiCrzbbL9N 0rUQ== 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=RIQCDQqINidvh1DTknLDI5oSxkB20f4LpRJe7G0/m+0ca+uln4leADUKyTi0b6v4xC xcOJqe9CVdjy2S9ewLGcr/VK2R2kH/WNG0GBJPBzJZnFsvzNmreYEv4fP2REe1N0a37t 5gV9tIzMKo8meLl20hXsoXi/F4kRFLGSlIe2n5x9cVPqUzzKyMVVwihEFVU/aUq4vdKR pMRZuAFxf41HSxi1M6+T/tBdPRXDYgGjWJVuG6bCBXyS5oVyzyCZOqEnaDa/UeCe2fj+ CONOCeYKEZrS7Mc4Inti+iWMlnyk+lbORHi3gk3y1fLXoNQ2BCRmIKcEr8yGP35uuKvg bGZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AT4vIlyT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a23-20020a656417000000b0056b0b30d05csi779692pgv.245.2023.10.02.23.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 23:56:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AT4vIlyT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 1E6198129AEC; Mon, 2 Oct 2023 23:55:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239203AbjJCGzT (ORCPT + 99 others); Tue, 3 Oct 2023 02:55:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239233AbjJCGyy (ORCPT ); Tue, 3 Oct 2023 02:54:54 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BBBB115; Mon, 2 Oct 2023 23:54:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696316087; x=1727852087; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SbR2wCTkousO/IPIjdDUqT7zLHmXpw3IGG9LN/Z2MXU=; b=AT4vIlyTKisB+dhSHYdibnuOBRutW7Sel+S7aORQl8GzfTUxN9MJC7Y6 AuLKJ/1vh4kTMfPiubh/Xhyn0yHGzQKaq47bRVHbqS+Zkix54bwXxoo2m 80Y20UqaJW7lpBztTa1l+molWhwG77Aih9qZveCPVDFl6dqBeJMCuG4bU zN2+wi572338gPnISYW75dmp4bbZPj7Q18NFgboUTzeVN/fbj18E3WSYs Ao7BjB87UVxn9ZG5oygijfE3TDDz96JuPN6Rs/o2HKRskGW8v8unMDzDQ Z3hELrsPDYUoIXDc93FbHkukAySmeoKEIzbsO79H2nMysDk5pKg0yCw2c Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="367858099" X-IronPort-AV: E=Sophos;i="6.03,196,1694761200"; d="scan'208";a="367858099" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 23:54:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="1081900946" X-IronPort-AV: E=Sophos;i="6.03,196,1694761200"; d="scan'208";a="1081900946" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga005.fm.intel.com with ESMTP; 02 Oct 2023 23:54:43 -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 v12 17/37] x86/fred: Add a new header file for FRED definitions Date: Mon, 2 Oct 2023 23:24:38 -0700 Message-Id: <20231003062458.23552-18-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003062458.23552-1-xin3.li@intel.com> References: <20231003062458.23552-1-xin3.li@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 23:55:25 -0700 (PDT) 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 */ -- 2.34.1