mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 00:53:34 +02:00
LoongArch: KVM: Check VM msgint feature during interrupt handling
During message interrupt handling and relative CSR registers saving and restore, it is better to check VM msgint feature rather than host msgint feature, because VM may disable this feature even if host supports this. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
This commit is contained in:
parent
31966edb9a
commit
c2f94dafe1
|
|
@ -265,6 +265,11 @@ static inline void writel_sw_gcsr(struct loongarch_csrs *csr, int reg, unsigned
|
|||
csr->csrs[reg] = val;
|
||||
}
|
||||
|
||||
static inline bool kvm_guest_has_msgint(struct kvm_vcpu_arch *arch)
|
||||
{
|
||||
return arch->cpucfg[1] & CPUCFG1_MSGINT;
|
||||
}
|
||||
|
||||
static inline bool kvm_guest_has_fpu(struct kvm_vcpu_arch *arch)
|
||||
{
|
||||
return arch->cpucfg[2] & CPUCFG2_FP;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ static int kvm_irq_deliver(struct kvm_vcpu *vcpu, unsigned int priority)
|
|||
if (priority < EXCCODE_INT_NUM)
|
||||
irq = priority_to_irq[priority];
|
||||
|
||||
if (cpu_has_msgint && (priority == INT_AVEC)) {
|
||||
if (kvm_guest_has_msgint(&vcpu->arch) && (priority == INT_AVEC)) {
|
||||
set_gcsr_estat(irq);
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ static int kvm_irq_clear(struct kvm_vcpu *vcpu, unsigned int priority)
|
|||
if (priority < EXCCODE_INT_NUM)
|
||||
irq = priority_to_irq[priority];
|
||||
|
||||
if (cpu_has_msgint && (priority == INT_AVEC)) {
|
||||
if (kvm_guest_has_msgint(&vcpu->arch) && (priority == INT_AVEC)) {
|
||||
clear_gcsr_estat(irq);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1679,7 +1679,8 @@ static int _kvm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
|
|||
kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_DMWIN2);
|
||||
kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_DMWIN3);
|
||||
kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_LLBCTL);
|
||||
if (cpu_has_msgint) {
|
||||
|
||||
if (kvm_guest_has_msgint(&vcpu->arch)) {
|
||||
kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_ISR0);
|
||||
kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_ISR1);
|
||||
kvm_restore_hw_gcsr(csr, LOONGARCH_CSR_ISR2);
|
||||
|
|
@ -1774,7 +1775,8 @@ static int _kvm_vcpu_put(struct kvm_vcpu *vcpu, int cpu)
|
|||
kvm_save_hw_gcsr(csr, LOONGARCH_CSR_DMWIN1);
|
||||
kvm_save_hw_gcsr(csr, LOONGARCH_CSR_DMWIN2);
|
||||
kvm_save_hw_gcsr(csr, LOONGARCH_CSR_DMWIN3);
|
||||
if (cpu_has_msgint) {
|
||||
|
||||
if (kvm_guest_has_msgint(&vcpu->arch)) {
|
||||
kvm_save_hw_gcsr(csr, LOONGARCH_CSR_ISR0);
|
||||
kvm_save_hw_gcsr(csr, LOONGARCH_CSR_ISR1);
|
||||
kvm_save_hw_gcsr(csr, LOONGARCH_CSR_ISR2);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user