	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_intel_pasid_setup_second_level ## -- Begin function intel_pasid_setup_second_level
	.p2align	4, 0x90
_intel_pasid_setup_second_level:        ## @intel_pasid_setup_second_level
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%ecx, %ebx
	movq	%rdx, %r12
	movq	%rsi, %r15
	movq	%rdi, %r13
	movl	20(%rdi), %edi
	callq	_ecap_slts
	testl	%eax, %eax
	je	LBB0_1
## %bb.2:
	movl	%ebx, -44(%rbp)                 ## 4-byte Spill
	movq	16(%r15), %r14
	movl	(%r15), %ebx
	cmpl	(%r13), %ebx
	jle	LBB0_7
	.p2align	4, 0x90
LBB0_4:                                 ## =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	callq	_dma_pte_addr
	movl	%eax, %edi
	callq	_phys_to_virt
	movq	%rax, %r14
	movq	%rax, %rdi
	callq	_dma_pte_present
	testl	%eax, %eax
	je	LBB0_5
## %bb.6:                               ##   in Loop: Header=BB0_4 Depth=1
	decl	%ebx
	cmpl	(%r13), %ebx
	jg	LBB0_4
LBB0_7:
	movq	%r14, %rdi
	callq	_virt_to_phys
	movl	%eax, -48(%rbp)                 ## 4-byte Spill
	movq	8(%r15), %rax
	movq	8(%r13), %rcx
	movl	(%rax,%rcx,4), %eax
	movl	%eax, -52(%rbp)                 ## 4-byte Spill
	movq	%r12, %rdi
	movl	-44(%rbp), %r14d                ## 4-byte Reload
	movl	%r14d, %esi
	callq	_intel_pasid_get_entry
	testq	%rax, %rax
	je	LBB0_8
## %bb.9:
	movq	%rax, %r15
	movq	%rax, %rdi
	callq	_pasid_clear_entry
	movq	%r15, %rdi
	movl	-52(%rbp), %r14d                ## 4-byte Reload
	movl	%r14d, %esi
	callq	_pasid_set_domain_id
	movq	%r15, %rdi
	movl	-48(%rbp), %esi                 ## 4-byte Reload
	callq	_pasid_set_slptr
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_pasid_set_address_width
	movq	%r15, %rdi
	movl	$2, %esi
	callq	_pasid_set_translation_type
	movq	%r15, %rdi
	callq	_pasid_set_fault_enable
	movl	20(%r13), %edi
	callq	_ecap_smpwc
	xorl	%esi, %esi
	testl	%eax, %eax
	setne	%sil
	movq	%r15, %rdi
	callq	_pasid_set_page_snoop
	movq	%r15, %rdi
	callq	_pasid_set_sre
	movq	%r15, %rdi
	callq	_pasid_set_present
	movl	20(%r13), %edi
	callq	_ecap_coherent
	testl	%eax, %eax
	jne	LBB0_11
## %bb.10:
	movq	%r15, %rdi
	movl	$4, %esi
	callq	_clflush_cache_range
LBB0_11:
	movl	16(%r13), %edi
	callq	_cap_caching_mode
	testq	%rax, %rax
	movl	-44(%rbp), %ebx                 ## 4-byte Reload
	je	LBB0_13
## %bb.12:
	movq	%r13, %rdi
	movl	%r14d, %esi
	movl	%ebx, %edx
	callq	_pasid_cache_invalidation_with_pasid
	movq	%r13, %rdi
	movl	%r14d, %esi
	movl	%ebx, %edx
	callq	_iotlb_invalidation_with_pasid
	jmp	LBB0_14
LBB0_1:
	movl	24(%r13), %esi
	leaq	L_.str(%rip), %rdi
	callq	_pr_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_15
LBB0_8:
	leaq	L_.str.2(%rip), %rsi
	xorl	%ebx, %ebx
	movq	%r12, %rdi
	movl	%r14d, %edx
	xorl	%eax, %eax
	callq	_dev_err
	movq	_ENODEV@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_15
LBB0_5:
	leaq	L_.str.1(%rip), %rsi
	xorl	%ebx, %ebx
	movq	%r12, %rdi
	xorl	%eax, %eax
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_15
LBB0_13:
	movq	%r13, %rdi
	callq	_iommu_flush_write_buffer
LBB0_14:
	xorl	%ebx, %ebx
LBB0_15:
	movl	%ebx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"No second level translation support on %s\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
L_.str.1:                               ## @.str.1
	.asciz	"Invalid domain page table\n"

L_.str.2:                               ## @.str.2
	.asciz	"Failed to get pasid entry of PASID %d\n"

	.comm	_ENODEV,4,2                     ## @ENODEV
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_intel_pasid_setup_second_level ; -- Begin function intel_pasid_setup_second_level
	.p2align	2
_intel_pasid_setup_second_level:        ; @intel_pasid_setup_second_level
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	mov	x19, x3
	mov	x22, x2
	mov	x21, x1
	mov	x20, x0
	ldr	w0, [x0, #20]
	bl	_ecap_slts
	cbz	w0, LBB0_10
; %bb.1:
	ldr	x24, [x21, #16]
	ldr	w23, [x21]
LBB0_2:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w8, [x20]
	mov	x0, x24
	cmp	w23, w8
	b.le	LBB0_5
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	bl	_dma_pte_addr
	bl	_phys_to_virt
	mov	x24, x0
	bl	_dma_pte_present
	cbz	w0, LBB0_12
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	sub	w23, w23, #1
	b	LBB0_2
LBB0_5:
	bl	_virt_to_phys
	mov	x25, x0
	ldr	x8, [x21, #8]
	ldr	x9, [x20, #8]
	ldr	w21, [x8, x9, lsl #2]
	mov	x0, x22
	mov	x1, x19
	bl	_intel_pasid_get_entry
	cbz	x0, LBB0_11
; %bb.6:
	mov	x24, x0
	bl	_pasid_clear_entry
	mov	x0, x24
	mov	x1, x21
	bl	_pasid_set_domain_id
	mov	x0, x24
	mov	x1, x25
	bl	_pasid_set_slptr
	mov	x0, x24
	mov	x1, x23
	bl	_pasid_set_address_width
	mov	x0, x24
	mov	w1, #2
	bl	_pasid_set_translation_type
	mov	x0, x24
	bl	_pasid_set_fault_enable
	ldr	w0, [x20, #20]
	bl	_ecap_smpwc
	cmp	w0, #0
	cset	w1, ne
	mov	x0, x24
	bl	_pasid_set_page_snoop
	mov	x0, x24
	bl	_pasid_set_sre
	mov	x0, x24
	bl	_pasid_set_present
	ldr	w0, [x20, #20]
	bl	_ecap_coherent
	cbnz	w0, LBB0_8
; %bb.7:
	mov	x0, x24
	mov	w1, #4
	bl	_clflush_cache_range
LBB0_8:
	ldr	w0, [x20, #16]
	bl	_cap_caching_mode
	cbz	x0, LBB0_15
; %bb.9:
	mov	x0, x20
	mov	x1, x21
	mov	x2, x19
	bl	_pasid_cache_invalidation_with_pasid
	mov	x0, x20
	mov	x1, x21
	mov	x2, x19
	bl	_iotlb_invalidation_with_pasid
	b	LBB0_16
LBB0_10:
	ldr	w1, [x20, #24]
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	bl	_pr_err
	b	LBB0_13
LBB0_11:
	str	x19, [sp]
Lloh2:
	adrp	x1, l_.str.2@PAGE
Lloh3:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x22
	bl	_dev_err
Lloh4:
	adrp	x8, _ENODEV@GOTPAGE
Lloh5:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
	b	LBB0_14
LBB0_12:
Lloh6:
	adrp	x1, l_.str.1@PAGE
Lloh7:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x22
	bl	_dev_err
LBB0_13:
Lloh8:
	adrp	x8, _EINVAL@GOTPAGE
Lloh9:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_14:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_17
LBB0_15:
	mov	x0, x20
	bl	_iommu_flush_write_buffer
LBB0_16:
	mov	w0, #0
LBB0_17:
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #96
	ret
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh8, Lloh9
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"No second level translation support on %s\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
l_.str.1:                               ; @.str.1
	.asciz	"Invalid domain page table\n"

l_.str.2:                               ; @.str.2
	.asciz	"Failed to get pasid entry of PASID %d\n"

	.comm	_ENODEV,4,2                     ; @ENODEV
.subsections_via_symbols
