• Song Gao's avatar
    LoongArch: KVM: Add PMU support for guest · f4e40ea9
    Song Gao authored
    On LoongArch, the host and guest have their own PMU CSRs registers and
    they share PMU hardware resources. A set of PMU CSRs consists of a CTRL
    register and a CNTR register. We can set which PMU CSRs are used by the
    guest by writing to the GCFG register [24:26] bits.
    
    On KVM side:
    - Save the host PMU CSRs into structure kvm_context.
    - If the host supports the PMU feature.
      - When entering guest mode, save the host PMU CSRs and restore the guest PMU CSRs.
      - When exiting guest mode, save the guest PMU CSRs and restore the host PMU CSRs.
    Reviewed-by: default avatarBibo Mao <maobibo@loongson.cn>
    Signed-off-by: default avatarSong Gao <gaosong@loongson.cn>
    Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
    f4e40ea9
vcpu.c 42.7 KB