mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-19 17:14:40 +08:00
57a420bb81
Currently, the TDX_MODULE_CALL asm macro, which handles both TDCALL and SEAMCALL, takes one parameter for each input register and an optional 'struct tdx_module_output' (a collection of output registers) as output. This is different from the TDX_HYPERCALL macro which uses a single 'struct tdx_hypercall_args' to carry all input/output registers. The newer TDX versions introduce more TDCALLs/SEAMCALLs which use more input/output registers. Also, the TDH.VP.ENTER (which isn't covered by the current TDX_MODULE_CALL macro) basically can use all registers that the TDX_HYPERCALL does. The current TDX_MODULE_CALL macro isn't extendible to cover those cases. Similar to the TDX_HYPERCALL macro, simplify the TDX_MODULE_CALL macro to use a single structure 'struct tdx_module_args' to carry all the input/output registers. Currently, R10/R11 are only used as output register but not as input by any TDCALL/SEAMCALL. Change to also use R10/R11 as input register to make input/output registers symmetric. Currently, the TDX_MODULE_CALL macro depends on the caller to pass a non-NULL 'struct tdx_module_output' to get additional output registers. Similar to the TDX_HYPERCALL macro, change the TDX_MODULE_CALL macro to take a new 'ret' macro argument to indicate whether to save the output registers to the 'struct tdx_module_args'. Also introduce a new __tdcall_ret() for that purpose, similar to the __tdx_hypercall_ret(). Note the tdcall(), which is a wrapper of __tdcall(), is called by three callers: tdx_parse_tdinfo(), tdx_get_ve_info() and tdx_early_init(). The former two need the additional output but the last one doesn't. For simplicity, make tdcall() always call __tdcall_ret() to avoid another "_ret()" wrapper. The last caller tdx_early_init() isn't performance critical anyway. Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Kai Huang <kai.huang@intel.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/all/483616c1762d85eb3a3c3035a7de061cfacf2f14.1692096753.git.kai.huang%40intel.com
131 lines
4.1 KiB
C
131 lines
4.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Generate definitions needed by assembly language modules.
|
|
* This code generates raw asm output which is post-processed to extract
|
|
* and format the required data.
|
|
*/
|
|
#define COMPILE_OFFSETS
|
|
|
|
#include <linux/crypto.h>
|
|
#include <crypto/aria.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/stddef.h>
|
|
#include <linux/hardirq.h>
|
|
#include <linux/suspend.h>
|
|
#include <linux/kbuild.h>
|
|
#include <asm/processor.h>
|
|
#include <asm/thread_info.h>
|
|
#include <asm/sigframe.h>
|
|
#include <asm/bootparam.h>
|
|
#include <asm/suspend.h>
|
|
#include <asm/tlbflush.h>
|
|
#include <asm/tdx.h>
|
|
|
|
#ifdef CONFIG_XEN
|
|
#include <xen/interface/xen.h>
|
|
#endif
|
|
|
|
#ifdef CONFIG_X86_32
|
|
# include "asm-offsets_32.c"
|
|
#else
|
|
# include "asm-offsets_64.c"
|
|
#endif
|
|
|
|
static void __used common(void)
|
|
{
|
|
BLANK();
|
|
OFFSET(TASK_threadsp, task_struct, thread.sp);
|
|
#ifdef CONFIG_STACKPROTECTOR
|
|
OFFSET(TASK_stack_canary, task_struct, stack_canary);
|
|
#endif
|
|
|
|
BLANK();
|
|
OFFSET(pbe_address, pbe, address);
|
|
OFFSET(pbe_orig_address, pbe, orig_address);
|
|
OFFSET(pbe_next, pbe, next);
|
|
|
|
#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
|
|
BLANK();
|
|
OFFSET(IA32_SIGCONTEXT_ax, sigcontext_32, ax);
|
|
OFFSET(IA32_SIGCONTEXT_bx, sigcontext_32, bx);
|
|
OFFSET(IA32_SIGCONTEXT_cx, sigcontext_32, cx);
|
|
OFFSET(IA32_SIGCONTEXT_dx, sigcontext_32, dx);
|
|
OFFSET(IA32_SIGCONTEXT_si, sigcontext_32, si);
|
|
OFFSET(IA32_SIGCONTEXT_di, sigcontext_32, di);
|
|
OFFSET(IA32_SIGCONTEXT_bp, sigcontext_32, bp);
|
|
OFFSET(IA32_SIGCONTEXT_sp, sigcontext_32, sp);
|
|
OFFSET(IA32_SIGCONTEXT_ip, sigcontext_32, ip);
|
|
|
|
BLANK();
|
|
OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext);
|
|
#endif
|
|
|
|
#ifdef CONFIG_XEN
|
|
BLANK();
|
|
OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
|
|
OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending);
|
|
OFFSET(XEN_vcpu_info_arch_cr2, vcpu_info, arch.cr2);
|
|
#endif
|
|
|
|
BLANK();
|
|
OFFSET(TDX_MODULE_rcx, tdx_module_args, rcx);
|
|
OFFSET(TDX_MODULE_rdx, tdx_module_args, rdx);
|
|
OFFSET(TDX_MODULE_r8, tdx_module_args, r8);
|
|
OFFSET(TDX_MODULE_r9, tdx_module_args, r9);
|
|
OFFSET(TDX_MODULE_r10, tdx_module_args, r10);
|
|
OFFSET(TDX_MODULE_r11, tdx_module_args, r11);
|
|
|
|
BLANK();
|
|
OFFSET(TDX_HYPERCALL_r8, tdx_hypercall_args, r8);
|
|
OFFSET(TDX_HYPERCALL_r9, tdx_hypercall_args, r9);
|
|
OFFSET(TDX_HYPERCALL_r10, tdx_hypercall_args, r10);
|
|
OFFSET(TDX_HYPERCALL_r11, tdx_hypercall_args, r11);
|
|
OFFSET(TDX_HYPERCALL_r12, tdx_hypercall_args, r12);
|
|
OFFSET(TDX_HYPERCALL_r13, tdx_hypercall_args, r13);
|
|
OFFSET(TDX_HYPERCALL_r14, tdx_hypercall_args, r14);
|
|
OFFSET(TDX_HYPERCALL_r15, tdx_hypercall_args, r15);
|
|
OFFSET(TDX_HYPERCALL_rdi, tdx_hypercall_args, rdi);
|
|
OFFSET(TDX_HYPERCALL_rsi, tdx_hypercall_args, rsi);
|
|
OFFSET(TDX_HYPERCALL_rbx, tdx_hypercall_args, rbx);
|
|
OFFSET(TDX_HYPERCALL_rdx, tdx_hypercall_args, rdx);
|
|
|
|
BLANK();
|
|
OFFSET(BP_scratch, boot_params, scratch);
|
|
OFFSET(BP_secure_boot, boot_params, secure_boot);
|
|
OFFSET(BP_loadflags, boot_params, hdr.loadflags);
|
|
OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch);
|
|
OFFSET(BP_version, boot_params, hdr.version);
|
|
OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment);
|
|
OFFSET(BP_init_size, boot_params, hdr.init_size);
|
|
OFFSET(BP_pref_address, boot_params, hdr.pref_address);
|
|
|
|
BLANK();
|
|
DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
|
|
|
|
/* TLB state for the entry code */
|
|
OFFSET(TLB_STATE_user_pcid_flush_mask, tlb_state, user_pcid_flush_mask);
|
|
|
|
/* Layout info for cpu_entry_area */
|
|
OFFSET(CPU_ENTRY_AREA_entry_stack, cpu_entry_area, entry_stack_page);
|
|
DEFINE(SIZEOF_entry_stack, sizeof(struct entry_stack));
|
|
DEFINE(MASK_entry_stack, (~(sizeof(struct entry_stack) - 1)));
|
|
|
|
/* Offset for fields in tss_struct */
|
|
OFFSET(TSS_sp0, tss_struct, x86_tss.sp0);
|
|
OFFSET(TSS_sp1, tss_struct, x86_tss.sp1);
|
|
OFFSET(TSS_sp2, tss_struct, x86_tss.sp2);
|
|
OFFSET(X86_top_of_stack, pcpu_hot, top_of_stack);
|
|
OFFSET(X86_current_task, pcpu_hot, current_task);
|
|
#ifdef CONFIG_CALL_DEPTH_TRACKING
|
|
OFFSET(X86_call_depth, pcpu_hot, call_depth);
|
|
#endif
|
|
#if IS_ENABLED(CONFIG_CRYPTO_ARIA_AESNI_AVX_X86_64)
|
|
/* Offset for fields in aria_ctx */
|
|
BLANK();
|
|
OFFSET(ARIA_CTX_enc_key, aria_ctx, enc_key);
|
|
OFFSET(ARIA_CTX_dec_key, aria_ctx, dec_key);
|
|
OFFSET(ARIA_CTX_rounds, aria_ctx, rounds);
|
|
#endif
|
|
|
|
}
|