forked from Mirrors/opensbi
		
	lib: Add hfence instruction encoding
Currently, the toolchains do not have support for hfence instruction. Hence, the instruction are hardcode until we have toolchain support. Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
This commit is contained in:
		
							
								
								
									
										36
									
								
								include/sbi/sbi_hfence.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								include/sbi/sbi_hfence.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
/*
 | 
			
		||||
 * SPDX-License-Identifier: BSD-2-Clause
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 Western Digital Corporation or its affiliates.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *   Atish Patra <atish.patra@wdc.com>
 | 
			
		||||
 *   Anup Patel <anup.patel@wdc.com>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef __SBI_FENCE_H__
 | 
			
		||||
#define __SBI_FENCE_H__
 | 
			
		||||
/** Invalidate Stage2 TLBs for given VMID and guest physical address */
 | 
			
		||||
void __sbi_hfence_gvma_vmid_gpa(unsigned long vmid, unsigned long gpa);
 | 
			
		||||
 | 
			
		||||
/** Invalidate Stage2 TLBs for given VMID */
 | 
			
		||||
void __sbi_hfence_gvma_vmid(unsigned long vmid);
 | 
			
		||||
 | 
			
		||||
/** Invalidate Stage2 TLBs for given guest physical address */
 | 
			
		||||
void __sbi_hfence_gvma_gpa(unsigned long gpa);
 | 
			
		||||
 | 
			
		||||
/** Invalidate all possible Stage2 TLBs */
 | 
			
		||||
void __sbi_hfence_gvma_all(void);
 | 
			
		||||
 | 
			
		||||
/** Invalidate unified TLB entries for given asid and guest virtual address */
 | 
			
		||||
void __sbi_hfence_vvma_asid_va(unsigned long asid, unsigned long va);
 | 
			
		||||
 | 
			
		||||
/** Invalidate unified TLB entries for given ASID for a guest*/
 | 
			
		||||
void __sbi_hfence_vvma_asid(unsigned long asid);
 | 
			
		||||
 | 
			
		||||
/** Invalidate unified TLB entries for a given guest virtual address */
 | 
			
		||||
void __sbi_hfence_vvma_va(unsigned long va);
 | 
			
		||||
 | 
			
		||||
/** Invalidate all possible Stage2 TLBs */
 | 
			
		||||
void __sbi_hfence_vvma_all(void);
 | 
			
		||||
#endif
 | 
			
		||||
@@ -16,6 +16,7 @@ libsbi-objs-y += sbi_console.o
 | 
			
		||||
libsbi-objs-y += sbi_ecall.o
 | 
			
		||||
libsbi-objs-y += sbi_emulate_csr.o
 | 
			
		||||
libsbi-objs-y += sbi_fifo.o
 | 
			
		||||
libsbi-objs-y += sbi_hfence.o
 | 
			
		||||
libsbi-objs-y += sbi_hart.o
 | 
			
		||||
libsbi-objs-y += sbi_illegal_insn.o
 | 
			
		||||
libsbi-objs-y += sbi_init.o
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										75
									
								
								lib/sbi/sbi_hfence.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								lib/sbi/sbi_hfence.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,75 @@
 | 
			
		||||
/*
 | 
			
		||||
 * SPDX-License-Identifier: BSD-2-Clause
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 Western Digital Corporation or its affiliates.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *   Anup Patel <anup.patel@wdc.com>
 | 
			
		||||
 *   Atish Patra <anup.patel@wdc.com>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Instruction encoding of hfence.gvma is:
 | 
			
		||||
	 * 0110001 rs2(5) rs1(5) 000 00000 1110011
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
	.align 3
 | 
			
		||||
	.global __sbi_hfence_gvma_vmid_gpa
 | 
			
		||||
__sbi_hfence_gvma_vmid_gpa:
 | 
			
		||||
	/* hfence.gvma a1, a0 */
 | 
			
		||||
	.word 0x62a60073
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
	.align 3
 | 
			
		||||
	.global __sbi_hfence_gvma_vmid
 | 
			
		||||
__sbi_hfence_gvma_vmid:
 | 
			
		||||
	/* hfence.gvma zero, a0 */
 | 
			
		||||
	.word 0x62a00073
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
	.align 3
 | 
			
		||||
	.global __sbi_hfence_gvma_gpa
 | 
			
		||||
__sbi_hfence_gvma_gpa:
 | 
			
		||||
	/* hfence.gvma a0 */
 | 
			
		||||
	.word 0x62050073
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
	.align 3
 | 
			
		||||
	.global __sbi_hfence_gvma_all
 | 
			
		||||
__sbi_hfence_gvma_all:
 | 
			
		||||
	/* hfence.gvma */
 | 
			
		||||
	.word 0x62000073
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Instruction encoding of hfence.bvma is:
 | 
			
		||||
	 * 0010001 rs2(5) rs1(5) 000 00000 1110011
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
	.align 3
 | 
			
		||||
	.global __sbi_hfence_vvma_asid_va
 | 
			
		||||
__sbi_hfence_vvma_asid_va:
 | 
			
		||||
	/* hfence.bvma a1, a0 */
 | 
			
		||||
	.word 0x22a60073
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
	.align 3
 | 
			
		||||
	.global __sbi_hfence_vvma_asid
 | 
			
		||||
__sbi_hfence_vvma_asid:
 | 
			
		||||
	/* hfence.bvma zero, a0 */
 | 
			
		||||
	.word 0x22a00073
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
	.align 3
 | 
			
		||||
	.global __sbi_hfence_vvma_va
 | 
			
		||||
__sbi_hfence_vvma_va:
 | 
			
		||||
	/* hfence.bvma a0 */
 | 
			
		||||
	.word 0x22050073
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
	.align 3
 | 
			
		||||
	.global __sbi_hfence_vvma_all
 | 
			
		||||
__sbi_hfence_vvma_all:
 | 
			
		||||
	/* hfence.bvma */
 | 
			
		||||
	.word 0x22000073
 | 
			
		||||
	ret
 | 
			
		||||
		Reference in New Issue
	
	Block a user