Anup Patel | fd7bb4a | 2021-09-27 17:10:08 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * Copyright (C) 2019 Western Digital Corporation or its affiliates. |
| 4 | * |
| 5 | * Authors: |
| 6 | * Anup Patel <anup.patel@wdc.com> |
| 7 | */ |
| 8 | |
| 9 | #include <linux/linkage.h> |
| 10 | #include <asm/asm.h> |
| 11 | |
| 12 | .text |
| 13 | .altmacro |
| 14 | .option norelax |
| 15 | |
| 16 | /* |
| 17 | * Instruction encoding of hfence.gvma is: |
| 18 | * HFENCE.GVMA rs1, rs2 |
| 19 | * HFENCE.GVMA zero, rs2 |
| 20 | * HFENCE.GVMA rs1 |
| 21 | * HFENCE.GVMA |
| 22 | * |
| 23 | * rs1!=zero and rs2!=zero ==> HFENCE.GVMA rs1, rs2 |
| 24 | * rs1==zero and rs2!=zero ==> HFENCE.GVMA zero, rs2 |
| 25 | * rs1!=zero and rs2==zero ==> HFENCE.GVMA rs1 |
| 26 | * rs1==zero and rs2==zero ==> HFENCE.GVMA |
| 27 | * |
| 28 | * Instruction encoding of HFENCE.GVMA is: |
| 29 | * 0110001 rs2(5) rs1(5) 000 00000 1110011 |
| 30 | */ |
| 31 | |
| 32 | ENTRY(__kvm_riscv_hfence_gvma_vmid_gpa) |
| 33 | /* |
Anup Patel | 7c8de08 | 2021-10-26 22:31:36 +0530 | [diff] [blame] | 34 | * rs1 = a0 (GPA >> 2) |
Anup Patel | fd7bb4a | 2021-09-27 17:10:08 +0530 | [diff] [blame] | 35 | * rs2 = a1 (VMID) |
| 36 | * HFENCE.GVMA a0, a1 |
| 37 | * 0110001 01011 01010 000 00000 1110011 |
| 38 | */ |
| 39 | .word 0x62b50073 |
| 40 | ret |
| 41 | ENDPROC(__kvm_riscv_hfence_gvma_vmid_gpa) |
| 42 | |
| 43 | ENTRY(__kvm_riscv_hfence_gvma_vmid) |
| 44 | /* |
| 45 | * rs1 = zero |
| 46 | * rs2 = a0 (VMID) |
| 47 | * HFENCE.GVMA zero, a0 |
| 48 | * 0110001 01010 00000 000 00000 1110011 |
| 49 | */ |
| 50 | .word 0x62a00073 |
| 51 | ret |
| 52 | ENDPROC(__kvm_riscv_hfence_gvma_vmid) |
| 53 | |
| 54 | ENTRY(__kvm_riscv_hfence_gvma_gpa) |
| 55 | /* |
Anup Patel | 7c8de08 | 2021-10-26 22:31:36 +0530 | [diff] [blame] | 56 | * rs1 = a0 (GPA >> 2) |
Anup Patel | fd7bb4a | 2021-09-27 17:10:08 +0530 | [diff] [blame] | 57 | * rs2 = zero |
| 58 | * HFENCE.GVMA a0 |
| 59 | * 0110001 00000 01010 000 00000 1110011 |
| 60 | */ |
| 61 | .word 0x62050073 |
| 62 | ret |
| 63 | ENDPROC(__kvm_riscv_hfence_gvma_gpa) |
| 64 | |
| 65 | ENTRY(__kvm_riscv_hfence_gvma_all) |
| 66 | /* |
| 67 | * rs1 = zero |
| 68 | * rs2 = zero |
| 69 | * HFENCE.GVMA |
| 70 | * 0110001 00000 00000 000 00000 1110011 |
| 71 | */ |
| 72 | .word 0x62000073 |
| 73 | ret |
| 74 | ENDPROC(__kvm_riscv_hfence_gvma_all) |