brintos

brintos / linux-shallow public Read only

0
0
Text · 2.1 KiB · d8c4ac9 Raw
93 lines · plain
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * Copyright(c) 2016-20 Intel Corporation.4 */5 6	.macro ENCLU7	.byte 0x0f, 0x01, 0xd78	.endm9 10	.section ".tcs", "aw"11	.balign	409612 13	.fill	1, 8, 0			# STATE (set by CPU)14	.fill	1, 8, 0			# FLAGS15	.quad	encl_ssa_tcs1		# OSSA16	.fill	1, 4, 0			# CSSA (set by CPU)17	.fill	1, 4, 1			# NSSA18	.quad	encl_entry		# OENTRY19	.fill	1, 8, 0			# AEP (set by EENTER and ERESUME)20	.fill	1, 8, 0			# OFSBASE21	.fill	1, 8, 0			# OGSBASE22	.fill	1, 4, 0xFFFFFFFF 	# FSLIMIT23	.fill	1, 4, 0xFFFFFFFF	# GSLIMIT24	.fill	4024, 1, 0		# Reserved25 26	# TCS227	.fill	1, 8, 0			# STATE (set by CPU)28	.fill	1, 8, 0			# FLAGS29	.quad	encl_ssa_tcs2		# OSSA30	.fill	1, 4, 0			# CSSA (set by CPU)31	.fill	1, 4, 1			# NSSA32	.quad	encl_entry		# OENTRY33	.fill	1, 8, 0			# AEP (set by EENTER and ERESUME)34	.fill	1, 8, 0			# OFSBASE35	.fill	1, 8, 0			# OGSBASE36	.fill	1, 4, 0xFFFFFFFF 	# FSLIMIT37	.fill	1, 4, 0xFFFFFFFF	# GSLIMIT38	.fill	4024, 1, 0		# Reserved39 40	.text41 42encl_entry:43	# RBX contains the base address for TCS, which is the first address44	# inside the enclave for TCS #1 and one page into the enclave for45	# TCS #2. First make it relative by substracting __encl_base and46	# then add the address of encl_stack to get the address for the stack.47	lea __encl_base(%rip), %rax48	sub %rax, %rbx49	lea encl_stack(%rip), %rax50	add %rbx, %rax51	jmp encl_entry_core52encl_dyn_entry:53	# Entry point for dynamically created TCS page expected to follow54	# its stack directly.55	lea -1(%rbx), %rax56encl_entry_core:57	xchg	%rsp, %rax58	push	%rax59 60	push	%rcx # push the address after EENTER61 62	# NOTE: as the selftest enclave is *not* intended for production,63	# simplify the code by not initializing ABI registers on entry or64	# cleansing caller-save registers on exit.65	call	encl_body66 67	# Prepare EEXIT target by popping the address of the instruction after68	# EENTER to RBX.69	pop	%rbx70 71	# Restore the caller stack.72	pop	%rax73	mov	%rax, %rsp74 75	# EEXIT76	mov	$4, %rax77	enclu78 79	.section ".data", "aw"80 81encl_ssa_tcs1:82	.space 409683encl_ssa_tcs2:84	.space 409685 86	.balign 409687	# Stack of TCS #188	.space 409689encl_stack:90	.balign 409691	# Stack of TCS #292	.space 409693