18c2ecf20Sopenharmony_ci#ifndef __LOONGARCH_KVM_COMPAT_H__ 28c2ecf20Sopenharmony_ci#define __LOONGARCH_KVM_COMPAT_H__ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifdef __ASSEMBLY__ 58c2ecf20Sopenharmony_ci#define _ULCAST_ 68c2ecf20Sopenharmony_ci#else 78c2ecf20Sopenharmony_ci#define _ULCAST_ (unsigned long) 88c2ecf20Sopenharmony_ci#endif 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#define KVM_CSR_CRMD 0x0 /* Current mode info */ 118c2ecf20Sopenharmony_ci#define KVM_CRMD_WE_SHIFT 9 128c2ecf20Sopenharmony_ci#define KVM_CRMD_WE (_ULCAST_(0x1) << KVM_CRMD_WE_SHIFT) 138c2ecf20Sopenharmony_ci#define KVM_CRMD_DACM_SHIFT 7 148c2ecf20Sopenharmony_ci#define KVM_CRMD_DACM_WIDTH 2 158c2ecf20Sopenharmony_ci#define KVM_CRMD_DACM (_ULCAST_(0x3) << KVM_CRMD_DACM_SHIFT) 168c2ecf20Sopenharmony_ci#define KVM_CRMD_DACF_SHIFT 5 178c2ecf20Sopenharmony_ci#define KVM_CRMD_DACF_WIDTH 2 188c2ecf20Sopenharmony_ci#define KVM_CRMD_DACF (_ULCAST_(0x3) << KVM_CRMD_DACF_SHIFT) 198c2ecf20Sopenharmony_ci#define KVM_CRMD_PG_SHIFT 4 208c2ecf20Sopenharmony_ci#define KVM_CRMD_PG (_ULCAST_(0x1) << KVM_CRMD_PG_SHIFT) 218c2ecf20Sopenharmony_ci#define KVM_CRMD_DA_SHIFT 3 228c2ecf20Sopenharmony_ci#define KVM_CRMD_DA (_ULCAST_(0x1) << KVM_CRMD_DA_SHIFT) 238c2ecf20Sopenharmony_ci#define KVM_CRMD_IE_SHIFT 2 248c2ecf20Sopenharmony_ci#define KVM_CRMD_IE (_ULCAST_(0x1) << KVM_CRMD_IE_SHIFT) 258c2ecf20Sopenharmony_ci#define KVM_CRMD_PLV_SHIFT 0 268c2ecf20Sopenharmony_ci#define KVM_CRMD_PLV_WIDTH 2 278c2ecf20Sopenharmony_ci#define KVM_CRMD_PLV (_ULCAST_(0x3) << KVM_CRMD_PLV_SHIFT) 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define KVM_CSR_PRMD 0x1 /* Prev-exception mode info */ 308c2ecf20Sopenharmony_ci#define KVM_PRMD_PIE_SHIFT 2 318c2ecf20Sopenharmony_ci#define KVM_PRMD_PWE_SHIFT 3 328c2ecf20Sopenharmony_ci#define KVM_PRMD_PIE (_ULCAST_(0x1) << KVM_PRMD_PIE_SHIFT) 338c2ecf20Sopenharmony_ci#define KVM_PRMD_PWE (_ULCAST_(0x1) << KVM_PRMD_PWE_SHIFT) 348c2ecf20Sopenharmony_ci#define KVM_PRMD_PPLV_SHIFT 0 358c2ecf20Sopenharmony_ci#define KVM_PRMD_PPLV_WIDTH 2 368c2ecf20Sopenharmony_ci#define KVM_PRMD_PPLV (_ULCAST_(0x3) << KVM_PRMD_PPLV_SHIFT) 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define KVM_CSR_EUEN 0x2 /* Extended unit enable */ 398c2ecf20Sopenharmony_ci#define KVM_EUEN_LBTEN_SHIFT 3 408c2ecf20Sopenharmony_ci#define KVM_EUEN_LBTEN (_ULCAST_(0x1) << KVM_EUEN_LBTEN_SHIFT) 418c2ecf20Sopenharmony_ci#define KVM_EUEN_LASXEN_SHIFT 2 428c2ecf20Sopenharmony_ci#define KVM_EUEN_LASXEN (_ULCAST_(0x1) << KVM_EUEN_LASXEN_SHIFT) 438c2ecf20Sopenharmony_ci#define KVM_EUEN_LSXEN_SHIFT 1 448c2ecf20Sopenharmony_ci#define KVM_EUEN_LSXEN (_ULCAST_(0x1) << KVM_EUEN_LSXEN_SHIFT) 458c2ecf20Sopenharmony_ci#define KVM_EUEN_FPEN_SHIFT 0 468c2ecf20Sopenharmony_ci#define KVM_EUEN_FPEN (_ULCAST_(0x1) << KVM_EUEN_FPEN_SHIFT) 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#define KVM_CSR_MISC 0x3 /* Misc config */ 498c2ecf20Sopenharmony_ci#define KVM_CSR_ECFG 0x4 /* Exception config */ 508c2ecf20Sopenharmony_ci#define KVM_ECFG_VS_SHIFT 16 518c2ecf20Sopenharmony_ci#define KVM_ECFG_VS_WIDTH 3 528c2ecf20Sopenharmony_ci#define KVM_ECFG_VS (_ULCAST_(0x7) << KVM_ECFG_VS_SHIFT) 538c2ecf20Sopenharmony_ci#define KVM_ECFG_IM_SHIFT 0 548c2ecf20Sopenharmony_ci#define KVM_ECFG_IM_WIDTH 13 558c2ecf20Sopenharmony_ci#define KVM_ECFG_IM (_ULCAST_(0x1fff) << KVM_ECFG_IM_SHIFT) 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#define KVM_CSR_ESTAT 0x5 /* Exception status */ 588c2ecf20Sopenharmony_ci#define KVM_ESTAT_ESUBCODE_SHIFT 22 598c2ecf20Sopenharmony_ci#define KVM_ESTAT_ESUBCODE_WIDTH 9 608c2ecf20Sopenharmony_ci#define KVM_ESTAT_ESUBCODE (_ULCAST_(0x1ff) << KVM_ESTAT_ESUBCODE_SHIFT) 618c2ecf20Sopenharmony_ci#define KVM_ESTAT_EXC_SHIFT 16 628c2ecf20Sopenharmony_ci#define KVM_ESTAT_EXC_WIDTH 6 638c2ecf20Sopenharmony_ci#define KVM_ESTAT_EXC (_ULCAST_(0x3f) << KVM_ESTAT_EXC_SHIFT) 648c2ecf20Sopenharmony_ci#define KVM_ESTAT_IS_SHIFT 0 658c2ecf20Sopenharmony_ci#define KVM_ESTAT_IS_WIDTH 15 668c2ecf20Sopenharmony_ci#define KVM_ESTAT_IS (_ULCAST_(0x7fff) << KVM_ESTAT_IS_SHIFT) 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#define KVM_CSR_ERA 0x6 /* ERA */ 698c2ecf20Sopenharmony_ci#define KVM_CSR_BADV 0x7 /* Bad virtual address */ 708c2ecf20Sopenharmony_ci#define KVM_CSR_BADI 0x8 /* Bad instruction */ 718c2ecf20Sopenharmony_ci#define KVM_CSR_EENTRY 0xc /* Exception entry base address */ 728c2ecf20Sopenharmony_ci#define KVM_CSR_TLBIDX 0x10 /* TLB Index, EHINV, PageSize, NP */ 738c2ecf20Sopenharmony_ci#define KVM_CSR_TLBEHI 0x11 /* TLB EntryHi */ 748c2ecf20Sopenharmony_ci#define KVM_CSR_TLBELO0 0x12 /* TLB EntryLo0 */ 758c2ecf20Sopenharmony_ci#define KVM_CSR_TLBELO1 0x13 /* TLB EntryLo1 */ 768c2ecf20Sopenharmony_ci#define KVM_CSR_GTLBC 0x15 /* Guest TLB control */ 778c2ecf20Sopenharmony_ci#define KVM_GTLBC_TGID_SHIFT 16 788c2ecf20Sopenharmony_ci#define KVM_GTLBC_TGID_WIDTH 8 798c2ecf20Sopenharmony_ci#define KVM_GTLBC_TGID (_ULCAST_(0xff) << KVM_GTLBC_TGID_SHIFT) 808c2ecf20Sopenharmony_ci#define KVM_GTLBC_TOTI_SHIFT 13 818c2ecf20Sopenharmony_ci#define KVM_GTLBC_TOTI (_ULCAST_(0x1) << KVM_GTLBC_TOTI_SHIFT) 828c2ecf20Sopenharmony_ci#define KVM_GTLBC_USETGID_SHIFT 12 838c2ecf20Sopenharmony_ci#define KVM_GTLBC_USETGID (_ULCAST_(0x1) << KVM_GTLBC_USETGID_SHIFT) 848c2ecf20Sopenharmony_ci#define KVM_GTLBC_GMTLBSZ_SHIFT 0 858c2ecf20Sopenharmony_ci#define KVM_GTLBC_GMTLBSZ_WIDTH 6 868c2ecf20Sopenharmony_ci#define KVM_GTLBC_GMTLBSZ (_ULCAST_(0x3f) << KVM_GTLBC_GMTLBSZ_SHIFT) 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define KVM_CSR_TRGP 0x16 /* TLBR read guest info */ 898c2ecf20Sopenharmony_ci#define KVM_CSR_ASID 0x18 /* ASID */ 908c2ecf20Sopenharmony_ci#define KVM_CSR_PGDL 0x19 /* Page table base address when VA[47] = 0 */ 918c2ecf20Sopenharmony_ci#define KVM_CSR_PGDH 0x1a /* Page table base address when VA[47] = 1 */ 928c2ecf20Sopenharmony_ci#define KVM_CSR_PGD 0x1b /* Page table base */ 938c2ecf20Sopenharmony_ci#define KVM_CSR_PWCTL0 0x1c /* PWCtl0 */ 948c2ecf20Sopenharmony_ci#define KVM_CSR_PWCTL1 0x1d /* PWCtl1 */ 958c2ecf20Sopenharmony_ci#define KVM_CSR_STLBPGSIZE 0x1e 968c2ecf20Sopenharmony_ci#define KVM_CSR_RVACFG 0x1f 978c2ecf20Sopenharmony_ci#define KVM_CSR_CPUID 0x20 /* CPU core number */ 988c2ecf20Sopenharmony_ci#define KVM_CSR_PRCFG1 0x21 /* Config1 */ 998c2ecf20Sopenharmony_ci#define KVM_CSR_PRCFG2 0x22 /* Config2 */ 1008c2ecf20Sopenharmony_ci#define KVM_CSR_PRCFG3 0x23 /* Config3 */ 1018c2ecf20Sopenharmony_ci#define KVM_CSR_KS0 0x30 1028c2ecf20Sopenharmony_ci#define KVM_CSR_KS1 0x31 1038c2ecf20Sopenharmony_ci#define KVM_CSR_KS2 0x32 1048c2ecf20Sopenharmony_ci#define KVM_CSR_KS3 0x33 1058c2ecf20Sopenharmony_ci#define KVM_CSR_KS4 0x34 1068c2ecf20Sopenharmony_ci#define KVM_CSR_KS5 0x35 1078c2ecf20Sopenharmony_ci#define KVM_CSR_KS6 0x36 1088c2ecf20Sopenharmony_ci#define KVM_CSR_KS7 0x37 1098c2ecf20Sopenharmony_ci#define KVM_CSR_KS8 0x38 1108c2ecf20Sopenharmony_ci#define KVM_CSR_TMID 0x40 /* Timer ID */ 1118c2ecf20Sopenharmony_ci#define KVM_CSR_TCFG 0x41 /* Timer config */ 1128c2ecf20Sopenharmony_ci#define KVM_TCFG_VAL_SHIFT 2 1138c2ecf20Sopenharmony_ci#define KVM_TCFG_VAL_WIDTH 48 1148c2ecf20Sopenharmony_ci#define KVM_TCFG_VAL (_ULCAST_(0x3fffffffffff) << KVM_TCFG_VAL_SHIFT) 1158c2ecf20Sopenharmony_ci#define KVM_TCFG_PERIOD_SHIFT 1 1168c2ecf20Sopenharmony_ci#define KVM_TCFG_PERIOD (_ULCAST_(0x1) << KVM_TCFG_PERIOD_SHIFT) 1178c2ecf20Sopenharmony_ci#define KVM_TCFG_EN (_ULCAST_(0x1)) 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#define KVM_CSR_TVAL 0x42 /* Timer value */ 1208c2ecf20Sopenharmony_ci#define KVM_CSR_CNTC 0x43 /* Timer offset */ 1218c2ecf20Sopenharmony_ci#define KVM_CSR_TINTCLR 0x44 /* Timer interrupt clear */ 1228c2ecf20Sopenharmony_ci#define KVM_CSR_GSTAT 0x50 /* Guest status */ 1238c2ecf20Sopenharmony_ci#define KVM_GSTAT_GID_SHIFT 16 1248c2ecf20Sopenharmony_ci#define KVM_GSTAT_GID_WIDTH 8 1258c2ecf20Sopenharmony_ci#define KVM_GSTAT_GID (_ULCAST_(0xff) << KVM_GSTAT_GID_SHIFT) 1268c2ecf20Sopenharmony_ci#define KVM_GSTAT_GIDBIT_SHIFT 4 1278c2ecf20Sopenharmony_ci#define KVM_GSTAT_GIDBIT_WIDTH 6 1288c2ecf20Sopenharmony_ci#define KVM_GSTAT_GIDBIT (_ULCAST_(0x3f) << KVM_GSTAT_GIDBIT_SHIFT) 1298c2ecf20Sopenharmony_ci#define KVM_GSTAT_PVM_SHIFT 1 1308c2ecf20Sopenharmony_ci#define KVM_GSTAT_PVM (_ULCAST_(0x1) << KVM_GSTAT_PVM_SHIFT) 1318c2ecf20Sopenharmony_ci#define KVM_GSTAT_VM_SHIFT 0 1328c2ecf20Sopenharmony_ci#define KVM_GSTAT_VM (_ULCAST_(0x1) << KVM_GSTAT_VM_SHIFT) 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#define KVM_CSR_GCFG 0x51 /* Guest config */ 1358c2ecf20Sopenharmony_ci#define KVM_GCFG_GPERF_SHIFT 24 1368c2ecf20Sopenharmony_ci#define KVM_GCFG_GPERF_WIDTH 3 1378c2ecf20Sopenharmony_ci#define KVM_GCFG_GPERF (_ULCAST_(0x7) << KVM_GCFG_GPERF_SHIFT) 1388c2ecf20Sopenharmony_ci#define KVM_GCFG_GCI_SHIFT 20 1398c2ecf20Sopenharmony_ci#define KVM_GCFG_GCI_WIDTH 2 1408c2ecf20Sopenharmony_ci#define KVM_GCFG_GCI (_ULCAST_(0x3) << KVM_GCFG_GCI_SHIFT) 1418c2ecf20Sopenharmony_ci#define KVM_GCFG_GCI_ALL (_ULCAST_(0x0) << KVM_GCFG_GCI_SHIFT) 1428c2ecf20Sopenharmony_ci#define KVM_GCFG_GCI_HIT (_ULCAST_(0x1) << KVM_GCFG_GCI_SHIFT) 1438c2ecf20Sopenharmony_ci#define KVM_GCFG_GCI_SECURE (_ULCAST_(0x2) << KVM_GCFG_GCI_SHIFT) 1448c2ecf20Sopenharmony_ci#define KVM_GCFG_GCIP_SHIFT 16 1458c2ecf20Sopenharmony_ci#define KVM_GCFG_GCIP (_ULCAST_(0xf) << KVM_GCFG_GCIP_SHIFT) 1468c2ecf20Sopenharmony_ci#define KVM_GCFG_GCIP_ALL (_ULCAST_(0x1) << KVM_GCFG_GCIP_SHIFT) 1478c2ecf20Sopenharmony_ci#define KVM_GCFG_GCIP_HIT (_ULCAST_(0x1) << (KVM_GCFG_GCIP_SHIFT + 1)) 1488c2ecf20Sopenharmony_ci#define KVM_GCFG_GCIP_SECURE (_ULCAST_(0x1) << (KVM_GCFG_GCIP_SHIFT + 2)) 1498c2ecf20Sopenharmony_ci#define KVM_GCFG_TORU_SHIFT 15 1508c2ecf20Sopenharmony_ci#define KVM_GCFG_TORU (_ULCAST_(0x1) << KVM_GCFG_TORU_SHIFT) 1518c2ecf20Sopenharmony_ci#define KVM_GCFG_TORUP_SHIFT 14 1528c2ecf20Sopenharmony_ci#define KVM_GCFG_TORUP (_ULCAST_(0x1) << KVM_GCFG_TORUP_SHIFT) 1538c2ecf20Sopenharmony_ci#define KVM_GCFG_TOP_SHIFT 13 1548c2ecf20Sopenharmony_ci#define KVM_GCFG_TOP (_ULCAST_(0x1) << KVM_GCFG_TOP_SHIFT) 1558c2ecf20Sopenharmony_ci#define KVM_GCFG_TOPP_SHIFT 12 1568c2ecf20Sopenharmony_ci#define KVM_GCFG_TOPP (_ULCAST_(0x1) << KVM_GCFG_TOPP_SHIFT) 1578c2ecf20Sopenharmony_ci#define KVM_GCFG_TOE_SHIFT 11 1588c2ecf20Sopenharmony_ci#define KVM_GCFG_TOE (_ULCAST_(0x1) << KVM_GCFG_TOE_SHIFT) 1598c2ecf20Sopenharmony_ci#define KVM_GCFG_TOEP_SHIFT 10 1608c2ecf20Sopenharmony_ci#define KVM_GCFG_TOEP (_ULCAST_(0x1) << KVM_GCFG_TOEP_SHIFT) 1618c2ecf20Sopenharmony_ci#define KVM_GCFG_TIT_SHIFT 9 1628c2ecf20Sopenharmony_ci#define KVM_GCFG_TIT (_ULCAST_(0x1) << KVM_GCFG_TIT_SHIFT) 1638c2ecf20Sopenharmony_ci#define KVM_GCFG_TITP_SHIFT 8 1648c2ecf20Sopenharmony_ci#define KVM_GCFG_TITP (_ULCAST_(0x1) << KVM_GCFG_TITP_SHIFT) 1658c2ecf20Sopenharmony_ci#define KVM_GCFG_SIT_SHIFT 7 1668c2ecf20Sopenharmony_ci#define KVM_GCFG_SIT (_ULCAST_(0x1) << KVM_GCFG_SIT_SHIFT) 1678c2ecf20Sopenharmony_ci#define KVM_GCFG_SITP_SHIFT 6 1688c2ecf20Sopenharmony_ci#define KVM_GCFG_SITP (_ULCAST_(0x1) << KVM_GCFG_SITP_SHIFT) 1698c2ecf20Sopenharmony_ci#define KVM_GCFG_MATC_SHITF 4 1708c2ecf20Sopenharmony_ci#define KVM_GCFG_MATC_WIDTH 2 1718c2ecf20Sopenharmony_ci#define KVM_GCFG_MATC_MASK (_ULCAST_(0x3) << KVM_GCFG_MATC_SHITF) 1728c2ecf20Sopenharmony_ci#define KVM_GCFG_MATC_GUEST (_ULCAST_(0x0) << KVM_GCFG_MATC_SHITF) 1738c2ecf20Sopenharmony_ci#define KVM_GCFG_MATC_ROOT (_ULCAST_(0x1) << KVM_GCFG_MATC_SHITF) 1748c2ecf20Sopenharmony_ci#define KVM_GCFG_MATC_NEST (_ULCAST_(0x2) << KVM_GCFG_MATC_SHITF) 1758c2ecf20Sopenharmony_ci#define KVM_GCFG_MATP_SHITF 0 1768c2ecf20Sopenharmony_ci#define KVM_GCFG_MATP_WIDTH 4 1778c2ecf20Sopenharmony_ci#define KVM_GCFG_MATR_MASK (_ULCAST_(0x3) << KVM_GCFG_MATP_SHITF) 1788c2ecf20Sopenharmony_ci#define KVM_GCFG_MATP_GUEST (_ULCAST_(0x0) << KVM_GCFG_MATP_SHITF) 1798c2ecf20Sopenharmony_ci#define KVM_GCFG_MATP_ROOT (_ULCAST_(0x1) << KVM_GCFG_MATP_SHITF) 1808c2ecf20Sopenharmony_ci#define KVM_GCFG_MATP_NEST (_ULCAST_(0x2) << KVM_GCFG_MATP_SHITF) 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci#define KVM_CSR_GINTC 0x52 /* Guest interrupt control */ 1838c2ecf20Sopenharmony_ci#define KVM_CSR_GCNTC 0x53 /* Guest timer offset */ 1848c2ecf20Sopenharmony_ci#define KVM_CSR_LLBCTL 0x60 /* LLBit control */ 1858c2ecf20Sopenharmony_ci#define KVM_LLBCTL_ROLLB_SHIFT 0 1868c2ecf20Sopenharmony_ci#define KVM_LLBCTL_ROLLB (_ULCAST_(1) << KVM_LLBCTL_ROLLB_SHIFT) 1878c2ecf20Sopenharmony_ci#define KVM_LLBCTL_WCLLB_SHIFT 1 1888c2ecf20Sopenharmony_ci#define KVM_LLBCTL_WCLLB (_ULCAST_(1) << KVM_LLBCTL_WCLLB_SHIFT) 1898c2ecf20Sopenharmony_ci#define KVM_LLBCTL_KLO_SHIFT 2 1908c2ecf20Sopenharmony_ci#define KVM_LLBCTL_KLO (_ULCAST_(1) << KVM_LLBCTL_KLO_SHIFT) 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci#define KVM_CSR_IMPCTL1 0x80 /* Loongson config1 */ 1938c2ecf20Sopenharmony_ci#define KVM_CSR_IMPCTL2 0x81 /* Loongson config2 */ 1948c2ecf20Sopenharmony_ci#define KVM_CSR_GNMI 0x82 1958c2ecf20Sopenharmony_ci#define KVM_CSR_TLBRENTRY 0x88 /* TLB refill exception base address */ 1968c2ecf20Sopenharmony_ci#define KVM_CSR_TLBRBADV 0x89 /* TLB refill badvaddr */ 1978c2ecf20Sopenharmony_ci#define KVM_CSR_TLBRERA 0x8a /* TLB refill ERA */ 1988c2ecf20Sopenharmony_ci#define KVM_CSR_TLBRSAVE 0x8b /* KScratch for TLB refill exception */ 1998c2ecf20Sopenharmony_ci#define KVM_CSR_TLBRELO0 0x8c /* TLB refill entrylo0 */ 2008c2ecf20Sopenharmony_ci#define KVM_CSR_TLBRELO1 0x8d /* TLB refill entrylo1 */ 2018c2ecf20Sopenharmony_ci#define KVM_CSR_TLBREHI 0x8e /* TLB refill entryhi */ 2028c2ecf20Sopenharmony_ci#define KVM_CSR_TLBRPRMD 0x8f /* TLB refill mode info */ 2038c2ecf20Sopenharmony_ci#define KVM_CSR_MERRCTL 0x90 /* ERRCTL */ 2048c2ecf20Sopenharmony_ci#define KVM_CSR_MERRINFO1 0x91 /* Error info1 */ 2058c2ecf20Sopenharmony_ci#define KVM_CSR_MERRINFO2 0x92 /* Error info2 */ 2068c2ecf20Sopenharmony_ci#define KVM_CSR_MERRENTRY 0x93 /* Error exception base address */ 2078c2ecf20Sopenharmony_ci#define KVM_CSR_MERRERA 0x94 /* Error exception PC */ 2088c2ecf20Sopenharmony_ci#define KVM_CSR_MERRSAVE 0x95 /* KScratch for machine error exception */ 2098c2ecf20Sopenharmony_ci#define KVM_CSR_CTAG 0x98 /* TagLo + TagHi */ 2108c2ecf20Sopenharmony_ci#define KVM_CSR_DMWIN0 0x180 /* 64 direct map win0: MEM & IF */ 2118c2ecf20Sopenharmony_ci#define KVM_CSR_DMWIN1 0x181 /* 64 direct map win1: MEM & IF */ 2128c2ecf20Sopenharmony_ci#define KVM_CSR_DMWIN2 0x182 /* 64 direct map win2: MEM */ 2138c2ecf20Sopenharmony_ci#define KVM_CSR_DMWIN3 0x183 /* 64 direct map win3: MEM */ 2148c2ecf20Sopenharmony_ci#define KVM_CSR_PERFCTRL0 0x200 /* 32 perf event 0 config */ 2158c2ecf20Sopenharmony_ci#define KVM_CSR_PERFCNTR0 0x201 /* 64 perf event 0 count value */ 2168c2ecf20Sopenharmony_ci#define KVM_CSR_PERFCTRL1 0x202 /* 32 perf event 1 config */ 2178c2ecf20Sopenharmony_ci#define KVM_CSR_PERFCNTR1 0x203 /* 64 perf event 1 count value */ 2188c2ecf20Sopenharmony_ci#define KVM_CSR_PERFCTRL2 0x204 /* 32 perf event 2 config */ 2198c2ecf20Sopenharmony_ci#define KVM_CSR_PERFCNTR2 0x205 /* 64 perf event 2 count value */ 2208c2ecf20Sopenharmony_ci#define KVM_CSR_PERFCTRL3 0x206 /* 32 perf event 3 config */ 2218c2ecf20Sopenharmony_ci#define KVM_CSR_PERFCNTR3 0x207 /* 64 perf event 3 count value */ 2228c2ecf20Sopenharmony_ci#define KVM_CSR_MWPC 0x300 /* data breakpoint config */ 2238c2ecf20Sopenharmony_ci#define KVM_CSR_MWPS 0x301 /* data breakpoint status */ 2248c2ecf20Sopenharmony_ci#define KVM_CSR_FWPC 0x380 /* instruction breakpoint config */ 2258c2ecf20Sopenharmony_ci#define KVM_CSR_FWPS 0x381 /* instruction breakpoint status */ 2268c2ecf20Sopenharmony_ci#define KVM_CSR_DEBUG 0x500 /* debug config */ 2278c2ecf20Sopenharmony_ci#define KVM_CSR_DERA 0x501 /* debug era */ 2288c2ecf20Sopenharmony_ci#define KVM_CSR_DESAVE 0x502 /* debug save */ 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci#define KVM_IOCSR_FEATURES 0x8 2318c2ecf20Sopenharmony_ci#define KVM_IOCSRF_TEMP BIT_ULL(0) 2328c2ecf20Sopenharmony_ci#define KVM_IOCSRF_NODECNT BIT_ULL(1) 2338c2ecf20Sopenharmony_ci#define KVM_IOCSRF_MSI BIT_ULL(2) 2348c2ecf20Sopenharmony_ci#define KVM_IOCSRF_EXTIOI BIT_ULL(3) 2358c2ecf20Sopenharmony_ci#define KVM_IOCSRF_CSRIPI BIT_ULL(4) 2368c2ecf20Sopenharmony_ci#define KVM_IOCSRF_FREQCSR BIT_ULL(5) 2378c2ecf20Sopenharmony_ci#define KVM_IOCSRF_FREQSCALE BIT_ULL(6) 2388c2ecf20Sopenharmony_ci#define KVM_IOCSRF_DVFSV1 BIT_ULL(7) 2398c2ecf20Sopenharmony_ci#define KVM_IOCSRF_EXTIOI_DECODE BIT_ULL(9) 2408c2ecf20Sopenharmony_ci#define KVM_IOCSRF_FLATMODE BIT_ULL(10) 2418c2ecf20Sopenharmony_ci#define KVM_IOCSRF_VM BIT_ULL(11) 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci#define KVM_IOCSR_VENDOR 0x10 2448c2ecf20Sopenharmony_ci#define KVM_IOCSR_CPUNAME 0x20 2458c2ecf20Sopenharmony_ci#define KVM_IOCSR_NODECNT 0x408 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci#define KVM_IOCSR_MISC_FUNC 0x420 2488c2ecf20Sopenharmony_ci#define KVM_IOCSRF_MISC_FUNC_EXT_IOI_EN BIT_ULL(48) 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci/* PerCore CSR, only accessable by local cores */ 2518c2ecf20Sopenharmony_ci#define KVM_IOCSR_IPI_STATUS 0x1000 2528c2ecf20Sopenharmony_ci#define KVM_IOCSR_IPI_SEND 0x1040 2538c2ecf20Sopenharmony_ci#define KVM_IOCSR_MBUF_SEND 0x1048 2548c2ecf20Sopenharmony_ci#define KVM_IOCSR_EXTIOI_NODEMAP_BASE 0x14a0 2558c2ecf20Sopenharmony_ci#define KVM_IOCSR_EXTIOI_IPMAP_BASE 0x14c0 2568c2ecf20Sopenharmony_ci#define KVM_IOCSR_EXTIOI_EN_BASE 0x1600 2578c2ecf20Sopenharmony_ci#define KVM_IOCSR_EXTIOI_BOUNCE_BASE 0x1680 2588c2ecf20Sopenharmony_ci#define KVM_IOCSR_EXTIOI_ISR_BASE 0x1800 2598c2ecf20Sopenharmony_ci#define KVM_IOCSR_EXTIOI_ROUTE_BASE 0x1c00 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci/* CSR */ 2648c2ecf20Sopenharmony_cistatic inline u32 kvm_csr_readl(u32 reg) 2658c2ecf20Sopenharmony_ci{ 2668c2ecf20Sopenharmony_ci u32 val; 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci asm volatile ( 2698c2ecf20Sopenharmony_ci "csrrd %[val], %[reg] \n" 2708c2ecf20Sopenharmony_ci : [val] "=r" (val) 2718c2ecf20Sopenharmony_ci : [reg] "i" (reg) 2728c2ecf20Sopenharmony_ci : "memory"); 2738c2ecf20Sopenharmony_ci return val; 2748c2ecf20Sopenharmony_ci} 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_cistatic inline u64 kvm_csr_readq(u32 reg) 2778c2ecf20Sopenharmony_ci{ 2788c2ecf20Sopenharmony_ci u64 val; 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci asm volatile ( 2818c2ecf20Sopenharmony_ci "csrrd %[val], %[reg] \n" 2828c2ecf20Sopenharmony_ci : [val] "=r" (val) 2838c2ecf20Sopenharmony_ci : [reg] "i" (reg) 2848c2ecf20Sopenharmony_ci : "memory"); 2858c2ecf20Sopenharmony_ci return val; 2868c2ecf20Sopenharmony_ci} 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_cistatic inline void kvm_csr_writel(u32 val, u32 reg) 2898c2ecf20Sopenharmony_ci{ 2908c2ecf20Sopenharmony_ci asm volatile ( 2918c2ecf20Sopenharmony_ci "csrwr %[val], %[reg] \n" 2928c2ecf20Sopenharmony_ci : [val] "+r" (val) 2938c2ecf20Sopenharmony_ci : [reg] "i" (reg) 2948c2ecf20Sopenharmony_ci : "memory"); 2958c2ecf20Sopenharmony_ci} 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_cistatic inline void kvm_csr_writeq(u64 val, u32 reg) 2988c2ecf20Sopenharmony_ci{ 2998c2ecf20Sopenharmony_ci asm volatile ( 3008c2ecf20Sopenharmony_ci "csrwr %[val], %[reg] \n" 3018c2ecf20Sopenharmony_ci : [val] "+r" (val) 3028c2ecf20Sopenharmony_ci : [reg] "i" (reg) 3038c2ecf20Sopenharmony_ci : "memory"); 3048c2ecf20Sopenharmony_ci} 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_cistatic inline u32 kvm_csr_xchgl(u32 val, u32 mask, u32 reg) 3078c2ecf20Sopenharmony_ci{ 3088c2ecf20Sopenharmony_ci asm volatile ( 3098c2ecf20Sopenharmony_ci "csrxchg %[val], %[mask], %[reg] \n" 3108c2ecf20Sopenharmony_ci : [val] "+r" (val) 3118c2ecf20Sopenharmony_ci : [mask] "r" (mask), [reg] "i" (reg) 3128c2ecf20Sopenharmony_ci : "memory"); 3138c2ecf20Sopenharmony_ci return val; 3148c2ecf20Sopenharmony_ci} 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_cistatic inline u64 kvm_csr_xchgq(u64 val, u64 mask, u32 reg) 3178c2ecf20Sopenharmony_ci{ 3188c2ecf20Sopenharmony_ci asm volatile ( 3198c2ecf20Sopenharmony_ci "csrxchg %[val], %[mask], %[reg] \n" 3208c2ecf20Sopenharmony_ci : [val] "+r" (val) 3218c2ecf20Sopenharmony_ci : [mask] "r" (mask), [reg] "i" (reg) 3228c2ecf20Sopenharmony_ci : "memory"); 3238c2ecf20Sopenharmony_ci return val; 3248c2ecf20Sopenharmony_ci} 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci/* IOCSR */ 3288c2ecf20Sopenharmony_cistatic inline u32 kvm_iocsr_readl(u32 reg) 3298c2ecf20Sopenharmony_ci{ 3308c2ecf20Sopenharmony_ci u32 val; 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci asm volatile ( 3338c2ecf20Sopenharmony_ci "iocsrrd.w %[val], %[reg] \n" 3348c2ecf20Sopenharmony_ci : [val] "=r" (val) 3358c2ecf20Sopenharmony_ci : [reg] "r" (reg) 3368c2ecf20Sopenharmony_ci : "memory"); 3378c2ecf20Sopenharmony_ci return val; 3388c2ecf20Sopenharmony_ci} 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_cistatic inline u64 kvm_iocsr_readq(u32 reg) 3418c2ecf20Sopenharmony_ci{ 3428c2ecf20Sopenharmony_ci u64 val; 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci asm volatile ( 3458c2ecf20Sopenharmony_ci "iocsrrd.d %[val], %[reg] \n" 3468c2ecf20Sopenharmony_ci : [val] "=r" (val) 3478c2ecf20Sopenharmony_ci : [reg] "r" (reg) 3488c2ecf20Sopenharmony_ci : "memory"); 3498c2ecf20Sopenharmony_ci return val; 3508c2ecf20Sopenharmony_ci} 3518c2ecf20Sopenharmony_ci 3528c2ecf20Sopenharmony_cistatic inline void kvm_iocsr_writeb(u8 val, u32 reg) 3538c2ecf20Sopenharmony_ci{ 3548c2ecf20Sopenharmony_ci asm volatile ( 3558c2ecf20Sopenharmony_ci "iocsrwr.b %[val], %[reg] \n" 3568c2ecf20Sopenharmony_ci : 3578c2ecf20Sopenharmony_ci : [val] "r" (val), [reg] "r" (reg) 3588c2ecf20Sopenharmony_ci : "memory"); 3598c2ecf20Sopenharmony_ci} 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_cistatic inline void kvm_iocsr_writel(u32 val, u32 reg) 3628c2ecf20Sopenharmony_ci{ 3638c2ecf20Sopenharmony_ci asm volatile ( 3648c2ecf20Sopenharmony_ci "iocsrwr.w %[val], %[reg] \n" 3658c2ecf20Sopenharmony_ci : 3668c2ecf20Sopenharmony_ci : [val] "r" (val), [reg] "r" (reg) 3678c2ecf20Sopenharmony_ci : "memory"); 3688c2ecf20Sopenharmony_ci} 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_cistatic inline void kvm_iocsr_writeq(u64 val, u32 reg) 3718c2ecf20Sopenharmony_ci{ 3728c2ecf20Sopenharmony_ci asm volatile ( 3738c2ecf20Sopenharmony_ci "iocsrwr.d %[val], %[reg] \n" 3748c2ecf20Sopenharmony_ci : 3758c2ecf20Sopenharmony_ci : [val] "r" (val), [reg] "r" (reg) 3768c2ecf20Sopenharmony_ci : "memory"); 3778c2ecf20Sopenharmony_ci} 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci/* GCSR */ 3818c2ecf20Sopenharmony_cistatic inline u64 kvm_gcsr_read(u32 reg) 3828c2ecf20Sopenharmony_ci{ 3838c2ecf20Sopenharmony_ci u64 val = 0; 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_ci asm volatile ( 3868c2ecf20Sopenharmony_ci "parse_r __reg, %[val] \n" 3878c2ecf20Sopenharmony_ci ".word 0x5 << 24 | %[reg] << 10 | 0 << 5 | __reg \n" 3888c2ecf20Sopenharmony_ci : [val] "+r" (val) 3898c2ecf20Sopenharmony_ci : [reg] "i" (reg) 3908c2ecf20Sopenharmony_ci : "memory"); 3918c2ecf20Sopenharmony_ci return val; 3928c2ecf20Sopenharmony_ci} 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_cistatic inline void kvm_gcsr_write(u64 val, u32 reg) 3958c2ecf20Sopenharmony_ci{ 3968c2ecf20Sopenharmony_ci asm volatile ( 3978c2ecf20Sopenharmony_ci "parse_r __reg, %[val] \n" 3988c2ecf20Sopenharmony_ci ".word 0x5 << 24 | %[reg] << 10 | 1 << 5 | __reg \n" 3998c2ecf20Sopenharmony_ci : [val] "+r" (val) 4008c2ecf20Sopenharmony_ci : [reg] "i" (reg) 4018c2ecf20Sopenharmony_ci : "memory"); 4028c2ecf20Sopenharmony_ci} 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_cistatic inline u64 kvm_gcsr_xchg(u64 val, u64 mask, u32 reg) 4058c2ecf20Sopenharmony_ci{ 4068c2ecf20Sopenharmony_ci asm volatile ( 4078c2ecf20Sopenharmony_ci "parse_r __rd, %[val] \n" 4088c2ecf20Sopenharmony_ci "parse_r __rj, %[mask] \n" 4098c2ecf20Sopenharmony_ci ".word 0x5 << 24 | %[reg] << 10 | __rj << 5 | __rd \n" 4108c2ecf20Sopenharmony_ci : [val] "+r" (val) 4118c2ecf20Sopenharmony_ci : [mask] "r" (mask), [reg] "i" (reg) 4128c2ecf20Sopenharmony_ci : "memory"); 4138c2ecf20Sopenharmony_ci return val; 4148c2ecf20Sopenharmony_ci} 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci#define kvm_read_csr_euen() kvm_csr_readq(KVM_CSR_EUEN) 4198c2ecf20Sopenharmony_ci#define kvm_write_csr_euen(val) kvm_csr_writeq(val, KVM_CSR_EUEN) 4208c2ecf20Sopenharmony_ci#define kvm_read_csr_ecfg() kvm_csr_readq(KVM_CSR_ECFG) 4218c2ecf20Sopenharmony_ci#define kvm_write_csr_ecfg(val) kvm_csr_writeq(val, KVM_CSR_ECFG) 4228c2ecf20Sopenharmony_ci#define kvm_write_csr_perfctrl0(val) kvm_csr_writeq(val, KVM_CSR_PERFCTRL0) 4238c2ecf20Sopenharmony_ci#define kvm_write_csr_perfcntr0(val) kvm_csr_writeq(val, LOONGARCH_CSR_PERFCNTR0) 4248c2ecf20Sopenharmony_ci#define kvm_write_csr_perfctrl1(val) kvm_csr_writeq(val, LOONGARCH_CSR_PERFCTRL1) 4258c2ecf20Sopenharmony_ci#define kvm_write_csr_perfcntr1(val) kvm_csr_writeq(val, LOONGARCH_CSR_PERFCNTR1) 4268c2ecf20Sopenharmony_ci#define kvm_write_csr_perfctrl2(val) kvm_csr_writeq(val, LOONGARCH_CSR_PERFCTRL2) 4278c2ecf20Sopenharmony_ci#define kvm_write_csr_perfcntr2(val) kvm_csr_writeq(val, LOONGARCH_CSR_PERFCNTR2) 4288c2ecf20Sopenharmony_ci#define kvm_write_csr_perfctrl3(val) kvm_csr_writeq(val, LOONGARCH_CSR_PERFCTRL3) 4298c2ecf20Sopenharmony_ci#define kvm_write_csr_perfcntr3(val) kvm_csr_writeq(val, LOONGARCH_CSR_PERFCNTR3) 4308c2ecf20Sopenharmony_ci#define kvm_read_csr_impctl1() kvm_csr_readq(LOONGARCH_CSR_IMPCTL1) 4318c2ecf20Sopenharmony_ci#define kvm_write_csr_impctl1(val) kvm_csr_writeq(val, LOONGARCH_CSR_IMPCTL1) 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_ci 4348c2ecf20Sopenharmony_ci/* Guest related CSRS */ 4358c2ecf20Sopenharmony_ci#define kvm_read_csr_gtlbc() kvm_csr_readq(KVM_CSR_GTLBC) 4368c2ecf20Sopenharmony_ci#define kvm_write_csr_gtlbc(val) kvm_csr_writeq(val, KVM_CSR_GTLBC) 4378c2ecf20Sopenharmony_ci#define kvm_read_csr_trgp() kvm_csr_readq(KVM_CSR_TRGP) 4388c2ecf20Sopenharmony_ci#define kvm_read_csr_gcfg() kvm_csr_readq(KVM_CSR_GCFG) 4398c2ecf20Sopenharmony_ci#define kvm_write_csr_gcfg(val) kvm_csr_writeq(val, KVM_CSR_GCFG) 4408c2ecf20Sopenharmony_ci#define kvm_read_csr_gstat() kvm_csr_readq(KVM_CSR_GSTAT) 4418c2ecf20Sopenharmony_ci#define kvm_write_csr_gstat(val) kvm_csr_writeq(val, KVM_CSR_GSTAT) 4428c2ecf20Sopenharmony_ci#define kvm_read_csr_gintc() kvm_csr_readq(KVM_CSR_GINTC) 4438c2ecf20Sopenharmony_ci#define kvm_write_csr_gintc(val) kvm_csr_writeq(val, KVM_CSR_GINTC) 4448c2ecf20Sopenharmony_ci#define kvm_read_csr_gcntc() kvm_csr_readq(KVM_CSR_GCNTC) 4458c2ecf20Sopenharmony_ci#define kvm_write_csr_gcntc(val) kvm_csr_writeq(val, KVM_CSR_GCNTC) 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci/* Guest CSRS read and write */ 4488c2ecf20Sopenharmony_ci#define kvm_read_gcsr_crmd() kvm_gcsr_read(KVM_CSR_CRMD) 4498c2ecf20Sopenharmony_ci#define kvm_write_gcsr_crmd(val) kvm_gcsr_write(val, KVM_CSR_CRMD) 4508c2ecf20Sopenharmony_ci#define kvm_read_gcsr_prmd() kvm_gcsr_read(KVM_CSR_PRMD) 4518c2ecf20Sopenharmony_ci#define kvm_write_gcsr_prmd(val) kvm_gcsr_write(val, KVM_CSR_PRMD) 4528c2ecf20Sopenharmony_ci#define kvm_read_gcsr_euen() kvm_gcsr_read(KVM_CSR_EUEN) 4538c2ecf20Sopenharmony_ci#define kvm_write_gcsr_euen(val) kvm_gcsr_write(val, KVM_CSR_EUEN) 4548c2ecf20Sopenharmony_ci#define kvm_read_gcsr_misc() kvm_gcsr_read(KVM_CSR_MISC) 4558c2ecf20Sopenharmony_ci#define kvm_write_gcsr_misc(val) kvm_gcsr_write(val, KVM_CSR_MISC) 4568c2ecf20Sopenharmony_ci#define kvm_read_gcsr_ecfg() kvm_gcsr_read(KVM_CSR_ECFG) 4578c2ecf20Sopenharmony_ci#define kvm_write_gcsr_ecfg(val) kvm_gcsr_write(val, KVM_CSR_ECFG) 4588c2ecf20Sopenharmony_ci#define kvm_read_gcsr_estat() kvm_gcsr_read(KVM_CSR_ESTAT) 4598c2ecf20Sopenharmony_ci#define kvm_write_gcsr_estat(val) kvm_gcsr_write(val, KVM_CSR_ESTAT) 4608c2ecf20Sopenharmony_ci#define kvm_read_gcsr_era() kvm_gcsr_read(KVM_CSR_ERA) 4618c2ecf20Sopenharmony_ci#define kvm_write_gcsr_era(val) kvm_gcsr_write(val, KVM_CSR_ERA) 4628c2ecf20Sopenharmony_ci#define kvm_read_gcsr_badv() kvm_gcsr_read(KVM_CSR_BADV) 4638c2ecf20Sopenharmony_ci#define kvm_write_gcsr_badv(val) kvm_gcsr_write(val, KVM_CSR_BADV) 4648c2ecf20Sopenharmony_ci#define kvm_read_gcsr_badi() kvm_gcsr_read(KVM_CSR_BADI) 4658c2ecf20Sopenharmony_ci#define kvm_write_gcsr_badi(val) kvm_gcsr_write(val, KVM_CSR_BADI) 4668c2ecf20Sopenharmony_ci#define kvm_read_gcsr_eentry() kvm_gcsr_read(KVM_CSR_EENTRY) 4678c2ecf20Sopenharmony_ci#define kvm_write_gcsr_eentry(val) kvm_gcsr_write(val, KVM_CSR_EENTRY) 4688c2ecf20Sopenharmony_ci 4698c2ecf20Sopenharmony_ci#define kvm_read_gcsr_tlbidx() kvm_gcsr_read(KVM_CSR_TLBIDX) 4708c2ecf20Sopenharmony_ci#define kvm_write_gcsr_tlbidx(val) kvm_gcsr_write(val, KVM_CSR_TLBIDX) 4718c2ecf20Sopenharmony_ci#define kvm_read_gcsr_tlbhi() kvm_gcsr_read(KVM_CSR_TLBEHI) 4728c2ecf20Sopenharmony_ci#define kvm_write_gcsr_tlbhi(val) kvm_gcsr_write(val, KVM_CSR_TLBEHI) 4738c2ecf20Sopenharmony_ci#define kvm_read_gcsr_tlblo0() kvm_gcsr_read(KVM_CSR_TLBELO0) 4748c2ecf20Sopenharmony_ci#define kvm_write_gcsr_tlblo0(val) kvm_gcsr_write(val, KVM_CSR_TLBELO0) 4758c2ecf20Sopenharmony_ci#define kvm_read_gcsr_tlblo1() kvm_gcsr_read(KVM_CSR_TLBELO1) 4768c2ecf20Sopenharmony_ci#define kvm_write_gcsr_tlblo1(val) kvm_gcsr_write(val, KVM_CSR_TLBELO1) 4778c2ecf20Sopenharmony_ci 4788c2ecf20Sopenharmony_ci#define kvm_read_gcsr_asid() kvm_gcsr_read(KVM_CSR_ASID) 4798c2ecf20Sopenharmony_ci#define kvm_write_gcsr_asid(val) kvm_gcsr_write(val, KVM_CSR_ASID) 4808c2ecf20Sopenharmony_ci#define kvm_read_gcsr_pgdl() kvm_gcsr_read(KVM_CSR_PGDL) 4818c2ecf20Sopenharmony_ci#define kvm_write_gcsr_pgdl(val) kvm_gcsr_write(val, KVM_CSR_PGDL) 4828c2ecf20Sopenharmony_ci#define kvm_read_gcsr_pgdh() kvm_gcsr_read(KVM_CSR_PGDH) 4838c2ecf20Sopenharmony_ci#define kvm_write_gcsr_pgdh(val) kvm_gcsr_write(val, KVM_CSR_PGDH) 4848c2ecf20Sopenharmony_ci#define kvm_write_gcsr_pgd(val) kvm_gcsr_write(val, KVM_CSR_PGD) 4858c2ecf20Sopenharmony_ci#define kvm_read_gcsr_pgd() kvm_gcsr_read(KVM_CSR_PGD) 4868c2ecf20Sopenharmony_ci#define kvm_read_gcsr_pwctl0() kvm_gcsr_read(KVM_CSR_PWCTL0) 4878c2ecf20Sopenharmony_ci#define kvm_write_gcsr_pwctl0(val) kvm_gcsr_write(val, KVM_CSR_PWCTL0) 4888c2ecf20Sopenharmony_ci#define kvm_read_gcsr_pwctl1() kvm_gcsr_read(KVM_CSR_PWCTL1) 4898c2ecf20Sopenharmony_ci#define kvm_write_gcsr_pwctl1(val) kvm_gcsr_write(val, KVM_CSR_PWCTL1) 4908c2ecf20Sopenharmony_ci#define kvm_read_gcsr_stlbpgsize() kvm_gcsr_read(KVM_CSR_STLBPGSIZE) 4918c2ecf20Sopenharmony_ci#define kvm_write_gcsr_stlbpgsize(val) kvm_gcsr_write(val, KVM_CSR_STLBPGSIZE) 4928c2ecf20Sopenharmony_ci#define kvm_read_gcsr_rvacfg() kvm_gcsr_read(KVM_CSR_RVACFG) 4938c2ecf20Sopenharmony_ci#define kvm_write_gcsr_rvacfg(val) kvm_gcsr_write(val, KVM_CSR_RVACFG) 4948c2ecf20Sopenharmony_ci 4958c2ecf20Sopenharmony_ci#define kvm_read_gcsr_cpuid() kvm_gcsr_read(KVM_CSR_CPUID) 4968c2ecf20Sopenharmony_ci#define kvm_write_gcsr_cpuid(val) kvm_gcsr_write(val, KVM_CSR_CPUID) 4978c2ecf20Sopenharmony_ci#define kvm_read_gcsr_prcfg1() kvm_gcsr_read(KVM_CSR_PRCFG1) 4988c2ecf20Sopenharmony_ci#define kvm_write_gcsr_prcfg1(val) kvm_gcsr_write(val, KVM_CSR_PRCFG1) 4998c2ecf20Sopenharmony_ci#define kvm_read_gcsr_prcfg2() kvm_gcsr_read(KVM_CSR_PRCFG2) 5008c2ecf20Sopenharmony_ci#define kvm_write_gcsr_prcfg2(val) kvm_gcsr_write(val, KVM_CSR_PRCFG2) 5018c2ecf20Sopenharmony_ci#define kvm_read_gcsr_prcfg3() kvm_gcsr_read(KVM_CSR_PRCFG3) 5028c2ecf20Sopenharmony_ci#define kvm_write_gcsr_prcfg3(val) kvm_gcsr_write(val, KVM_CSR_PRCFG3) 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_ci#define kvm_read_gcsr_kscratch0() kvm_gcsr_read(KVM_CSR_KS0) 5058c2ecf20Sopenharmony_ci#define kvm_write_gcsr_kscratch0(val) kvm_gcsr_write(val, KVM_CSR_KS0) 5068c2ecf20Sopenharmony_ci#define kvm_read_gcsr_kscratch1() kvm_gcsr_read(KVM_CSR_KS1) 5078c2ecf20Sopenharmony_ci#define kvm_write_gcsr_kscratch1(val) kvm_gcsr_write(val, KVM_CSR_KS1) 5088c2ecf20Sopenharmony_ci#define kvm_read_gcsr_kscratch2() kvm_gcsr_read(KVM_CSR_KS2) 5098c2ecf20Sopenharmony_ci#define kvm_write_gcsr_kscratch2(val) kvm_gcsr_write(val, KVM_CSR_KS2) 5108c2ecf20Sopenharmony_ci#define kvm_read_gcsr_kscratch3() kvm_gcsr_read(KVM_CSR_KS3) 5118c2ecf20Sopenharmony_ci#define kvm_write_gcsr_kscratch3(val) kvm_gcsr_write(val, KVM_CSR_KS3) 5128c2ecf20Sopenharmony_ci#define kvm_read_gcsr_kscratch4() kvm_gcsr_read(KVM_CSR_KS4) 5138c2ecf20Sopenharmony_ci#define kvm_write_gcsr_kscratch4(val) kvm_gcsr_write(val, KVM_CSR_KS4) 5148c2ecf20Sopenharmony_ci#define kvm_read_gcsr_kscratch5() kvm_gcsr_read(KVM_CSR_KS5) 5158c2ecf20Sopenharmony_ci#define kvm_write_gcsr_kscratch5(val) kvm_gcsr_write(val, KVM_CSR_KS5) 5168c2ecf20Sopenharmony_ci#define kvm_read_gcsr_kscratch6() kvm_gcsr_read(KVM_CSR_KS6) 5178c2ecf20Sopenharmony_ci#define kvm_write_gcsr_kscratch6(val) kvm_gcsr_write(val, KVM_CSR_KS6) 5188c2ecf20Sopenharmony_ci#define kvm_read_gcsr_kscratch7() kvm_gcsr_read(KVM_CSR_KS7) 5198c2ecf20Sopenharmony_ci#define kvm_write_gcsr_kscratch7(val) kvm_gcsr_write(val, KVM_CSR_KS7) 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_ci#define kvm_read_gcsr_timerid() kvm_gcsr_read(KVM_CSR_TMID) 5228c2ecf20Sopenharmony_ci#define kvm_write_gcsr_timerid(val) kvm_gcsr_write(val, KVM_CSR_TMID) 5238c2ecf20Sopenharmony_ci#define kvm_read_gcsr_timercfg() kvm_gcsr_read(KVM_CSR_TCFG) 5248c2ecf20Sopenharmony_ci#define kvm_write_gcsr_timercfg(val) kvm_gcsr_write(val, KVM_CSR_TCFG) 5258c2ecf20Sopenharmony_ci#define kvm_read_gcsr_timertick() kvm_gcsr_read(KVM_CSR_TVAL) 5268c2ecf20Sopenharmony_ci#define kvm_write_gcsr_timertick(val) kvm_gcsr_write(val, KVM_CSR_TVAL) 5278c2ecf20Sopenharmony_ci#define kvm_read_gcsr_timeroffset() kvm_gcsr_read(KVM_CSR_CNTC) 5288c2ecf20Sopenharmony_ci#define kvm_write_gcsr_timeroffset(val) kvm_gcsr_write(val, KVM_CSR_CNTC) 5298c2ecf20Sopenharmony_ci 5308c2ecf20Sopenharmony_ci#define kvm_read_gcsr_llbctl() kvm_gcsr_read(KVM_CSR_LLBCTL) 5318c2ecf20Sopenharmony_ci#define kvm_write_gcsr_llbctl(val) kvm_gcsr_write(val, KVM_CSR_LLBCTL) 5328c2ecf20Sopenharmony_ci 5338c2ecf20Sopenharmony_ci#define kvm_read_gcsr_tlbrentry() kvm_gcsr_read(KVM_CSR_TLBRENTRY) 5348c2ecf20Sopenharmony_ci#define kvm_write_gcsr_tlbrentry(val) kvm_gcsr_write(val, KVM_CSR_TLBRENTRY) 5358c2ecf20Sopenharmony_ci#define kvm_read_gcsr_tlbrbadv() kvm_gcsr_read(KVM_CSR_TLBRBADV) 5368c2ecf20Sopenharmony_ci#define kvm_write_gcsr_tlbrbadv(val) kvm_gcsr_write(val, KVM_CSR_TLBRBADV) 5378c2ecf20Sopenharmony_ci#define kvm_read_gcsr_tlbrera() kvm_gcsr_read(KVM_CSR_TLBRERA) 5388c2ecf20Sopenharmony_ci#define kvm_write_gcsr_tlbrera(val) kvm_gcsr_write(val, KVM_CSR_TLBRERA) 5398c2ecf20Sopenharmony_ci#define kvm_read_gcsr_tlbrsave() kvm_gcsr_read(KVM_CSR_TLBRSAVE) 5408c2ecf20Sopenharmony_ci#define kvm_write_gcsr_tlbrsave(val) kvm_gcsr_write(val, KVM_CSR_TLBRSAVE) 5418c2ecf20Sopenharmony_ci#define kvm_read_gcsr_tlbrelo0() kvm_gcsr_read(KVM_CSR_TLBRELO0) 5428c2ecf20Sopenharmony_ci#define kvm_write_gcsr_tlbrelo0(val) kvm_gcsr_write(val, KVM_CSR_TLBRELO0) 5438c2ecf20Sopenharmony_ci#define kvm_read_gcsr_tlbrelo1() kvm_gcsr_read(KVM_CSR_TLBRELO1) 5448c2ecf20Sopenharmony_ci#define kvm_write_gcsr_tlbrelo1(val) kvm_gcsr_write(val, KVM_CSR_TLBRELO1) 5458c2ecf20Sopenharmony_ci#define kvm_read_gcsr_tlbrehi() kvm_gcsr_read(KVM_CSR_TLBREHI) 5468c2ecf20Sopenharmony_ci#define kvm_write_gcsr_tlbrehi(val) kvm_gcsr_write(val, KVM_CSR_TLBREHI) 5478c2ecf20Sopenharmony_ci#define kvm_read_gcsr_tlbrprmd() kvm_gcsr_read(KVM_CSR_TLBRPRMD) 5488c2ecf20Sopenharmony_ci#define kvm_write_gcsr_tlbrprmd(val) kvm_gcsr_write(val, KVM_CSR_TLBRPRMD) 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_ci#define kvm_read_gcsr_directwin0() kvm_gcsr_read(KVM_CSR_DMWIN0) 5518c2ecf20Sopenharmony_ci#define kvm_write_gcsr_directwin0(val) kvm_gcsr_write(val, KVM_CSR_DMWIN0) 5528c2ecf20Sopenharmony_ci#define kvm_read_gcsr_directwin1() kvm_gcsr_read(KVM_CSR_DMWIN1) 5538c2ecf20Sopenharmony_ci#define kvm_write_gcsr_directwin1(val) kvm_gcsr_write(val, KVM_CSR_DMWIN1) 5548c2ecf20Sopenharmony_ci#define kvm_read_gcsr_directwin2() kvm_gcsr_read(KVM_CSR_DMWIN2) 5558c2ecf20Sopenharmony_ci#define kvm_write_gcsr_directwin2(val) kvm_gcsr_write(val, KVM_CSR_DMWIN2) 5568c2ecf20Sopenharmony_ci#define kvm_read_gcsr_directwin3() kvm_gcsr_read(KVM_CSR_DMWIN3) 5578c2ecf20Sopenharmony_ci#define kvm_write_gcsr_directwin3(val) kvm_gcsr_write(val, KVM_CSR_DMWIN3) 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_cistatic inline unsigned long 5628c2ecf20Sopenharmony_cikvm_set_csr_gtlbc(unsigned long set) 5638c2ecf20Sopenharmony_ci{ 5648c2ecf20Sopenharmony_ci unsigned long res, new; 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ci res = kvm_read_csr_gtlbc(); 5678c2ecf20Sopenharmony_ci new = res | set; 5688c2ecf20Sopenharmony_ci kvm_write_csr_gtlbc(new); 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_ci return res; 5718c2ecf20Sopenharmony_ci} 5728c2ecf20Sopenharmony_ci 5738c2ecf20Sopenharmony_cistatic inline unsigned long 5748c2ecf20Sopenharmony_cikvm_set_csr_euen(unsigned long set) 5758c2ecf20Sopenharmony_ci{ 5768c2ecf20Sopenharmony_ci unsigned long res, new; 5778c2ecf20Sopenharmony_ci 5788c2ecf20Sopenharmony_ci res = kvm_read_csr_euen(); 5798c2ecf20Sopenharmony_ci new = res | set; 5808c2ecf20Sopenharmony_ci kvm_write_csr_euen(new); 5818c2ecf20Sopenharmony_ci 5828c2ecf20Sopenharmony_ci return res; 5838c2ecf20Sopenharmony_ci} 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_cistatic inline unsigned long 5868c2ecf20Sopenharmony_cikvm_set_csr_gintc(unsigned long set) 5878c2ecf20Sopenharmony_ci{ 5888c2ecf20Sopenharmony_ci unsigned long res, new; 5898c2ecf20Sopenharmony_ci 5908c2ecf20Sopenharmony_ci res = kvm_read_csr_gintc(); 5918c2ecf20Sopenharmony_ci new = res | set; 5928c2ecf20Sopenharmony_ci kvm_write_csr_gintc(new); 5938c2ecf20Sopenharmony_ci 5948c2ecf20Sopenharmony_ci return res; 5958c2ecf20Sopenharmony_ci} 5968c2ecf20Sopenharmony_ci 5978c2ecf20Sopenharmony_cistatic inline unsigned long 5988c2ecf20Sopenharmony_cikvm_set_gcsr_llbctl(unsigned long set) 5998c2ecf20Sopenharmony_ci{ 6008c2ecf20Sopenharmony_ci unsigned long res, new; 6018c2ecf20Sopenharmony_ci 6028c2ecf20Sopenharmony_ci res = kvm_read_gcsr_llbctl(); 6038c2ecf20Sopenharmony_ci new = res | set; 6048c2ecf20Sopenharmony_ci kvm_write_gcsr_llbctl(new); 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci return res; 6078c2ecf20Sopenharmony_ci} 6088c2ecf20Sopenharmony_ci 6098c2ecf20Sopenharmony_ci 6108c2ecf20Sopenharmony_cistatic inline unsigned long 6118c2ecf20Sopenharmony_cikvm_clear_csr_gtlbc(unsigned long clear) 6128c2ecf20Sopenharmony_ci{ 6138c2ecf20Sopenharmony_ci unsigned long res, new; 6148c2ecf20Sopenharmony_ci 6158c2ecf20Sopenharmony_ci res = kvm_read_csr_gtlbc(); 6168c2ecf20Sopenharmony_ci new = res & ~clear; 6178c2ecf20Sopenharmony_ci kvm_write_csr_gtlbc(new); 6188c2ecf20Sopenharmony_ci 6198c2ecf20Sopenharmony_ci return res; 6208c2ecf20Sopenharmony_ci} 6218c2ecf20Sopenharmony_ci 6228c2ecf20Sopenharmony_cistatic inline unsigned long 6238c2ecf20Sopenharmony_cikvm_clear_csr_euen(unsigned long clear) 6248c2ecf20Sopenharmony_ci{ 6258c2ecf20Sopenharmony_ci unsigned long res, new; 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_ci res = kvm_read_csr_euen(); 6288c2ecf20Sopenharmony_ci new = res & ~clear; 6298c2ecf20Sopenharmony_ci kvm_write_csr_euen(new); 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_ci return res; 6328c2ecf20Sopenharmony_ci} 6338c2ecf20Sopenharmony_ci 6348c2ecf20Sopenharmony_cistatic inline unsigned long 6358c2ecf20Sopenharmony_cikvm_clear_csr_gintc(unsigned long clear) 6368c2ecf20Sopenharmony_ci{ 6378c2ecf20Sopenharmony_ci unsigned long res, new; 6388c2ecf20Sopenharmony_ci 6398c2ecf20Sopenharmony_ci res = kvm_read_csr_gintc(); 6408c2ecf20Sopenharmony_ci new = res & ~clear; 6418c2ecf20Sopenharmony_ci kvm_write_csr_gintc(new); 6428c2ecf20Sopenharmony_ci 6438c2ecf20Sopenharmony_ci return res; 6448c2ecf20Sopenharmony_ci} 6458c2ecf20Sopenharmony_ci 6468c2ecf20Sopenharmony_cistatic inline unsigned long 6478c2ecf20Sopenharmony_cikvm_change_csr_gstat(unsigned long change, unsigned long val) 6488c2ecf20Sopenharmony_ci{ 6498c2ecf20Sopenharmony_ci unsigned long res, new; 6508c2ecf20Sopenharmony_ci 6518c2ecf20Sopenharmony_ci res = read_csr_gstat(); 6528c2ecf20Sopenharmony_ci new = res & ~change; 6538c2ecf20Sopenharmony_ci new |= (val & change); 6548c2ecf20Sopenharmony_ci write_csr_gstat(new); 6558c2ecf20Sopenharmony_ci 6568c2ecf20Sopenharmony_ci return res; 6578c2ecf20Sopenharmony_ci} 6588c2ecf20Sopenharmony_ci 6598c2ecf20Sopenharmony_cistatic inline unsigned long 6608c2ecf20Sopenharmony_cikvm_change_csr_gcfg(unsigned long change, unsigned long val) 6618c2ecf20Sopenharmony_ci{ 6628c2ecf20Sopenharmony_ci unsigned long res, new; 6638c2ecf20Sopenharmony_ci 6648c2ecf20Sopenharmony_ci res = read_csr_gcfg(); 6658c2ecf20Sopenharmony_ci new = res & ~change; 6668c2ecf20Sopenharmony_ci new |= (val & change); 6678c2ecf20Sopenharmony_ci write_csr_gcfg(new); 6688c2ecf20Sopenharmony_ci 6698c2ecf20Sopenharmony_ci return res; 6708c2ecf20Sopenharmony_ci} 6718c2ecf20Sopenharmony_ci 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_ci#define kvm_set_gcsr_estat(val) \ 6748c2ecf20Sopenharmony_ci kvm_gcsr_xchg(val, val, KVM_CSR_ESTAT) 6758c2ecf20Sopenharmony_ci#define kvm_clear_gcsr_estat(val) \ 6768c2ecf20Sopenharmony_ci kvm_gcsr_xchg(~(val), val, KVM_CSR_ESTAT) 6778c2ecf20Sopenharmony_ci 6788c2ecf20Sopenharmony_ci#endif 6798c2ecf20Sopenharmony_ci 6808c2ecf20Sopenharmony_ci 6818c2ecf20Sopenharmony_ci#if (_LOONGARCH_SZLONG == 32) 6828c2ecf20Sopenharmony_ci#define KVM_LONG_ADD add.w 6838c2ecf20Sopenharmony_ci#define KVM_LONG_ADDI addi.w 6848c2ecf20Sopenharmony_ci#define KVM_LONG_SUB sub.w 6858c2ecf20Sopenharmony_ci#define KVM_LONG_L ld.w 6868c2ecf20Sopenharmony_ci#define KVM_LONG_S st.w 6878c2ecf20Sopenharmony_ci#define KVM_LONG_SLL slli.w 6888c2ecf20Sopenharmony_ci#define KVM_LONG_SLLV sll.w 6898c2ecf20Sopenharmony_ci#define KVM_LONG_SRL srli.w 6908c2ecf20Sopenharmony_ci#define KVM_LONG_SRLV srl.w 6918c2ecf20Sopenharmony_ci#define KVM_LONG_SRA srai.w 6928c2ecf20Sopenharmony_ci#define KVM_LONG_SRAV sra.w 6938c2ecf20Sopenharmony_ci 6948c2ecf20Sopenharmony_ci#define KVM_LONGSIZE 4 6958c2ecf20Sopenharmony_ci#define KVM_LONGMASK 3 6968c2ecf20Sopenharmony_ci#define KVM_LONGLOG 2 6978c2ecf20Sopenharmony_ci 6988c2ecf20Sopenharmony_ci/* 6998c2ecf20Sopenharmony_ci * How to add/sub/load/store/shift pointers. 7008c2ecf20Sopenharmony_ci */ 7018c2ecf20Sopenharmony_ci 7028c2ecf20Sopenharmony_ci#define KVM_PTR_ADD add.w 7038c2ecf20Sopenharmony_ci#define KVM_PTR_ADDI addi.w 7048c2ecf20Sopenharmony_ci#define KVM_PTR_SUB sub.w 7058c2ecf20Sopenharmony_ci#define KVM_PTR_L ld.w 7068c2ecf20Sopenharmony_ci#define KVM_PTR_S st.w 7078c2ecf20Sopenharmony_ci#define KVM_PTR_LI li.w 7088c2ecf20Sopenharmony_ci#define KVM_PTR_SLL slli.w 7098c2ecf20Sopenharmony_ci#define KVM_PTR_SLLV sll.w 7108c2ecf20Sopenharmony_ci#define KVM_PTR_SRL srli.w 7118c2ecf20Sopenharmony_ci#define KVM_PTR_SRLV srl.w 7128c2ecf20Sopenharmony_ci#define KVM_PTR_SRA srai.w 7138c2ecf20Sopenharmony_ci#define KVM_PTR_SRAV sra.w 7148c2ecf20Sopenharmony_ci 7158c2ecf20Sopenharmony_ci#define KVM_PTR_SCALESHIFT 2 7168c2ecf20Sopenharmony_ci 7178c2ecf20Sopenharmony_ci#define KVM_PTRSIZE 4 7188c2ecf20Sopenharmony_ci#define KVM_PTRLOG 2 7198c2ecf20Sopenharmony_ci 7208c2ecf20Sopenharmony_ci#endif 7218c2ecf20Sopenharmony_ci 7228c2ecf20Sopenharmony_ci#if (_LOONGARCH_SZLONG == 64) 7238c2ecf20Sopenharmony_ci#define KVM_LONG_ADD add.d 7248c2ecf20Sopenharmony_ci#define KVM_LONG_ADDI addi.d 7258c2ecf20Sopenharmony_ci#define KVM_LONG_SUB sub.d 7268c2ecf20Sopenharmony_ci#define KVM_LONG_L ld.d 7278c2ecf20Sopenharmony_ci#define KVM_LONG_S st.d 7288c2ecf20Sopenharmony_ci#define KVM_LONG_SLL slli.d 7298c2ecf20Sopenharmony_ci#define KVM_LONG_SLLV sll.d 7308c2ecf20Sopenharmony_ci#define KVM_LONG_SRL srli.d 7318c2ecf20Sopenharmony_ci#define KVM_LONG_SRLV srl.d 7328c2ecf20Sopenharmony_ci#define KVM_LONG_SRA sra.w 7338c2ecf20Sopenharmony_ci#define KVM_LONG_SRAV sra.d 7348c2ecf20Sopenharmony_ci 7358c2ecf20Sopenharmony_ci#define KVM_LONGSIZE 8 7368c2ecf20Sopenharmony_ci#define KVM_LONGMASK 7 7378c2ecf20Sopenharmony_ci#define KVM_LONGLOG 3 7388c2ecf20Sopenharmony_ci 7398c2ecf20Sopenharmony_ci/* 7408c2ecf20Sopenharmony_ci * How to add/sub/load/store/shift pointers. 7418c2ecf20Sopenharmony_ci */ 7428c2ecf20Sopenharmony_ci 7438c2ecf20Sopenharmony_ci#define KVM_PTR_ADD add.d 7448c2ecf20Sopenharmony_ci#define KVM_PTR_ADDI addi.d 7458c2ecf20Sopenharmony_ci#define KVM_PTR_SUB sub.d 7468c2ecf20Sopenharmony_ci#define KVM_PTR_L ld.d 7478c2ecf20Sopenharmony_ci#define KVM_PTR_S st.d 7488c2ecf20Sopenharmony_ci#define KVM_PTR_LI li.d 7498c2ecf20Sopenharmony_ci#define KVM_PTR_SLL slli.d 7508c2ecf20Sopenharmony_ci#define KVM_PTR_SLLV sll.d 7518c2ecf20Sopenharmony_ci#define KVM_PTR_SRL srli.d 7528c2ecf20Sopenharmony_ci#define KVM_PTR_SRLV srl.d 7538c2ecf20Sopenharmony_ci#define KVM_PTR_SRA srai.d 7548c2ecf20Sopenharmony_ci#define KVM_PTR_SRAV sra.d 7558c2ecf20Sopenharmony_ci 7568c2ecf20Sopenharmony_ci#define KVM_PTR_SCALESHIFT 3 7578c2ecf20Sopenharmony_ci 7588c2ecf20Sopenharmony_ci#define KVM_PTRSIZE 8 7598c2ecf20Sopenharmony_ci#define KVM_PTRLOG 3 7608c2ecf20Sopenharmony_ci#endif 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_ci#endif /* __LOONGARCH_KVM_COMPAT_H__ */ 763