Lines Matching full:csr

68 	struct loongarch_csrs *csr = vcpu->arch.csr;  in kvm_save_guest_pmu()  local
70 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_PERFCNTR0); in kvm_save_guest_pmu()
71 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_PERFCNTR1); in kvm_save_guest_pmu()
72 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_PERFCNTR2); in kvm_save_guest_pmu()
73 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_PERFCNTR3); in kvm_save_guest_pmu()
74 kvm_read_clear_hw_gcsr(csr, LOONGARCH_CSR_PERFCTRL0); in kvm_save_guest_pmu()
75 kvm_read_clear_hw_gcsr(csr, LOONGARCH_CSR_PERFCTRL1); in kvm_save_guest_pmu()
76 kvm_read_clear_hw_gcsr(csr, LOONGARCH_CSR_PERFCTRL2); in kvm_save_guest_pmu()
77 kvm_read_clear_hw_gcsr(csr, LOONGARCH_CSR_PERFCTRL3); in kvm_save_guest_pmu()
82 struct loongarch_csrs *csr = vcpu->arch.csr; in kvm_restore_guest_pmu() local
84 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_PERFCNTR0); in kvm_restore_guest_pmu()
85 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_PERFCNTR1); in kvm_restore_guest_pmu()
86 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_PERFCNTR2); in kvm_restore_guest_pmu()
87 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_PERFCNTR3); in kvm_restore_guest_pmu()
88 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_PERFCTRL0); in kvm_restore_guest_pmu()
89 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_PERFCTRL1); in kvm_restore_guest_pmu()
90 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_PERFCTRL2); in kvm_restore_guest_pmu()
91 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_PERFCTRL3); in kvm_restore_guest_pmu()
116 struct loongarch_csrs *csr = vcpu->arch.csr; in kvm_lose_pmu() local
131 val = kvm_read_sw_gcsr(csr, LOONGARCH_CSR_PERFCTRL0); in kvm_lose_pmu()
132 val |= kvm_read_sw_gcsr(csr, LOONGARCH_CSR_PERFCTRL1); in kvm_lose_pmu()
133 val |= kvm_read_sw_gcsr(csr, LOONGARCH_CSR_PERFCTRL2); in kvm_lose_pmu()
134 val |= kvm_read_sw_gcsr(csr, LOONGARCH_CSR_PERFCTRL3); in kvm_lose_pmu()
288 * Since it updates CSR.GSTAT used by kvm_flush_tlb_gpa(), in kvm_pre_enter_guest()
293 /* Clear KVM_LARCH_SWCSR_LATEST as CSR will change when enter guest */ in kvm_pre_enter_guest()
456 struct loongarch_csrs *csr = vcpu->arch.csr; in kvm_set_cpuid() local
462 cpuid = kvm_read_sw_gcsr(csr, LOONGARCH_CSR_CPUID); in kvm_set_cpuid()
495 kvm_write_sw_gcsr(csr, LOONGARCH_CSR_CPUID, val); in kvm_set_cpuid()
507 struct loongarch_csrs *csr = vcpu->arch.csr; in kvm_drop_cpuid() local
510 cpuid = kvm_read_sw_gcsr(csr, LOONGARCH_CSR_CPUID); in kvm_drop_cpuid()
519 kvm_write_sw_gcsr(csr, LOONGARCH_CSR_CPUID, KVM_MAX_PHYID); in kvm_drop_cpuid()
541 struct loongarch_csrs *csr = vcpu->arch.csr; in _kvm_getcsr() local
559 gintc = kvm_read_sw_gcsr(csr, LOONGARCH_CSR_GINTC) & 0xff; in _kvm_getcsr()
560 *val = kvm_read_sw_gcsr(csr, LOONGARCH_CSR_ESTAT) | (gintc << 2); in _kvm_getcsr()
565 * Get software CSR state since software state is consistent in _kvm_getcsr()
568 *val = kvm_read_sw_gcsr(csr, id); in _kvm_getcsr()
576 struct loongarch_csrs *csr = vcpu->arch.csr; in _kvm_setcsr() local
587 kvm_set_sw_gcsr(csr, LOONGARCH_CSR_GINTC, gintc); in _kvm_setcsr()
590 kvm_set_sw_gcsr(csr, LOONGARCH_CSR_ESTAT, gintc); in _kvm_setcsr()
595 kvm_write_sw_gcsr(csr, id, val); in _kvm_setcsr()
598 * After modifying the PMU CSR register value of the vcpu. in _kvm_setcsr()
604 val = kvm_read_sw_gcsr(csr, LOONGARCH_CSR_PERFCTRL0) | in _kvm_setcsr()
605 kvm_read_sw_gcsr(csr, LOONGARCH_CSR_PERFCTRL1) | in _kvm_setcsr()
606 kvm_read_sw_gcsr(csr, LOONGARCH_CSR_PERFCTRL2) | in _kvm_setcsr()
607 kvm_read_sw_gcsr(csr, LOONGARCH_CSR_PERFCTRL3); in _kvm_setcsr()
1149 * Only software CSR should be modified in kvm_arch_vcpu_ioctl()
1151 * If any hardware CSR register is modified, vcpu_load/vcpu_put pair in kvm_arch_vcpu_ioctl()
1152 * should be used. Since CSR registers owns by this vcpu, if switch in kvm_arch_vcpu_ioctl()
1153 * to other vcpus, other vcpus need reload CSR registers. in kvm_arch_vcpu_ioctl()
1155 * If software CSR is modified, bit KVM_LARCH_HWCSR_USABLE should in kvm_arch_vcpu_ioctl()
1157 * aux_inuse flag and reload CSR registers form software. in kvm_arch_vcpu_ioctl()
1457 struct loongarch_csrs *csr; in kvm_arch_vcpu_create() local
1467 vcpu->arch.csr = kzalloc(sizeof(struct loongarch_csrs), GFP_KERNEL); in kvm_arch_vcpu_create()
1468 if (!vcpu->arch.csr) in kvm_arch_vcpu_create()
1490 csr = vcpu->arch.csr; in kvm_arch_vcpu_create()
1491 kvm_write_sw_gcsr(csr, LOONGARCH_CSR_CRMD, CSR_CRMD_DA); in kvm_arch_vcpu_create()
1494 kvm_write_sw_gcsr(csr, LOONGARCH_CSR_TMID, vcpu->vcpu_id); in kvm_arch_vcpu_create()
1495 kvm_write_sw_gcsr(csr, LOONGARCH_CSR_CPUID, KVM_MAX_PHYID); in kvm_arch_vcpu_create()
1498 csr->csrs[LOONGARCH_CSR_GINTC] = 0; in kvm_arch_vcpu_create()
1515 kfree(vcpu->arch.csr); in kvm_arch_vcpu_destroy()
1532 struct loongarch_csrs *csr = vcpu->arch.csr; in _kvm_vcpu_load() local
1565 /* Restore guest CSR registers */ in _kvm_vcpu_load()
1566 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_CRMD); in _kvm_vcpu_load()
1567 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_PRMD); in _kvm_vcpu_load()
1568 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_EUEN); in _kvm_vcpu_load()
1569 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_MISC); in _kvm_vcpu_load()
1570 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_ECFG); in _kvm_vcpu_load()
1571 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_ERA); in _kvm_vcpu_load()
1572 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_BADV); in _kvm_vcpu_load()
1573 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_BADI); in _kvm_vcpu_load()
1574 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_EENTRY); in _kvm_vcpu_load()
1575 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_TLBIDX); in _kvm_vcpu_load()
1576 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_TLBEHI); in _kvm_vcpu_load()
1577 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_TLBELO0); in _kvm_vcpu_load()
1578 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_TLBELO1); in _kvm_vcpu_load()
1579 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_ASID); in _kvm_vcpu_load()
1580 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_PGDL); in _kvm_vcpu_load()
1581 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_PGDH); in _kvm_vcpu_load()
1582 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_PWCTL0); in _kvm_vcpu_load()
1583 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_PWCTL1); in _kvm_vcpu_load()
1584 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_STLBPGSIZE); in _kvm_vcpu_load()
1585 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_RVACFG); in _kvm_vcpu_load()
1586 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_CPUID); in _kvm_vcpu_load()
1587 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_KS0); in _kvm_vcpu_load()
1588 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_KS1); in _kvm_vcpu_load()
1589 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_KS2); in _kvm_vcpu_load()
1590 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_KS3); in _kvm_vcpu_load()
1591 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_KS4); in _kvm_vcpu_load()
1592 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_KS5); in _kvm_vcpu_load()
1593 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_KS6); in _kvm_vcpu_load()
1594 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_KS7); in _kvm_vcpu_load()
1595 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_TMID); in _kvm_vcpu_load()
1596 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_CNTC); in _kvm_vcpu_load()
1597 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_TLBRENTRY); in _kvm_vcpu_load()
1598 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_TLBRBADV); in _kvm_vcpu_load()
1599 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_TLBRERA); in _kvm_vcpu_load()
1600 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_TLBRSAVE); in _kvm_vcpu_load()
1601 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_TLBRELO0); in _kvm_vcpu_load()
1602 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_TLBRELO1); in _kvm_vcpu_load()
1603 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_TLBREHI); in _kvm_vcpu_load()
1604 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_TLBRPRMD); in _kvm_vcpu_load()
1605 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_DMWIN0); in _kvm_vcpu_load()
1606 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_DMWIN1); in _kvm_vcpu_load()
1607 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_DMWIN2); in _kvm_vcpu_load()
1608 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_DMWIN3); in _kvm_vcpu_load()
1609 kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_LLBCTL); in _kvm_vcpu_load()
1612 write_csr_gintc(csr->csrs[LOONGARCH_CSR_GINTC]); in _kvm_vcpu_load()
1639 struct loongarch_csrs *csr = vcpu->arch.csr; in _kvm_vcpu_put() local
1644 * Update CSR state from hardware if software CSR state is stale, in _kvm_vcpu_put()
1645 * most CSR registers are kept unchanged during process context in _kvm_vcpu_put()
1646 * switch except CSR registers like remaining timer tick value and in _kvm_vcpu_put()
1652 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_CRMD); in _kvm_vcpu_put()
1653 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_PRMD); in _kvm_vcpu_put()
1654 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_EUEN); in _kvm_vcpu_put()
1655 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_MISC); in _kvm_vcpu_put()
1656 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_ECFG); in _kvm_vcpu_put()
1657 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_ERA); in _kvm_vcpu_put()
1658 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_BADV); in _kvm_vcpu_put()
1659 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_BADI); in _kvm_vcpu_put()
1660 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_EENTRY); in _kvm_vcpu_put()
1661 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_TLBIDX); in _kvm_vcpu_put()
1662 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_TLBEHI); in _kvm_vcpu_put()
1663 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_TLBELO0); in _kvm_vcpu_put()
1664 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_TLBELO1); in _kvm_vcpu_put()
1665 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_ASID); in _kvm_vcpu_put()
1666 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_PGDL); in _kvm_vcpu_put()
1667 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_PGDH); in _kvm_vcpu_put()
1668 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_PWCTL0); in _kvm_vcpu_put()
1669 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_PWCTL1); in _kvm_vcpu_put()
1670 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_STLBPGSIZE); in _kvm_vcpu_put()
1671 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_RVACFG); in _kvm_vcpu_put()
1672 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_CPUID); in _kvm_vcpu_put()
1673 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_PRCFG1); in _kvm_vcpu_put()
1674 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_PRCFG2); in _kvm_vcpu_put()
1675 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_PRCFG3); in _kvm_vcpu_put()
1676 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_KS0); in _kvm_vcpu_put()
1677 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_KS1); in _kvm_vcpu_put()
1678 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_KS2); in _kvm_vcpu_put()
1679 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_KS3); in _kvm_vcpu_put()
1680 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_KS4); in _kvm_vcpu_put()
1681 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_KS5); in _kvm_vcpu_put()
1682 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_KS6); in _kvm_vcpu_put()
1683 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_KS7); in _kvm_vcpu_put()
1684 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_TMID); in _kvm_vcpu_put()
1685 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_CNTC); in _kvm_vcpu_put()
1686 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_LLBCTL); in _kvm_vcpu_put()
1687 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_TLBRENTRY); in _kvm_vcpu_put()
1688 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_TLBRBADV); in _kvm_vcpu_put()
1689 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_TLBRERA); in _kvm_vcpu_put()
1690 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_TLBRSAVE); in _kvm_vcpu_put()
1691 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_TLBRELO0); in _kvm_vcpu_put()
1692 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_TLBRELO1); in _kvm_vcpu_put()
1693 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_TLBREHI); in _kvm_vcpu_put()
1694 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_TLBRPRMD); in _kvm_vcpu_put()
1695 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_DMWIN0); in _kvm_vcpu_put()
1696 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_DMWIN1); in _kvm_vcpu_put()
1697 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_DMWIN2); in _kvm_vcpu_put()
1698 kvm_save_hw_gcsr(csr, LOONGARCH_CSR_DMWIN3); in _kvm_vcpu_put()
1705 csr->csrs[LOONGARCH_CSR_GINTC] = read_csr_gintc(); in _kvm_vcpu_put()