Skip to contentSkip to conversation

LoongArch/KVM: Use CSR_CRMD_PLV instead of CSR_PRMD_PPLV in kvm_arch_vcpu_in_kernel

PATCH Applied cuitao 3 participants 3 messages Apr 9

Subsystems (2)
lore
Share & tools
lore

cuitao

author
#0 lore raw

PATCH 1/1 LoongArch/KVM: Use CSR_CRMD_PLV instead of CSR_PRMD_PPLV in kvm_arch_vcpu_in_kernel

The function reads LOONGARCH_CSR_CRMD but uses CSR_PRMD_PPLV to extract the privilege level. While both masks have the same value (0x3), CSR_CRMD_PLV is the semantically correct constant for CRMD.

---
 arch/loongarch/kvm/vcpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/kvm/vcpu.c +1 -1
index 831f381a8fd1..ed2cfcd76f60 100644
@@ -402,7 +402,7 @@ bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu)
 	val = gcsr_read(LOONGARCH_CSR_CRMD);
 	preempt_enable();
 
-	return (val & CSR_PRMD_PPLV) == PLV_KERN;
+	return (val & CSR_CRMD_PLV) == PLV_KERN;
 }
 
 #ifdef CONFIG_GUEST_PERF_EVENTS
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · cuitao

The function reads LOONGARCH_CSR_CRMD but uses CSR_PRMD_PPLV to extract the privilege level. While both masks have the same value (0x3), CSR_CRMD_PLV is the semantically correct constant for CRMD.

---
  arch/loongarch/kvm/vcpu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/kvm/vcpu.c +0 -0
index 831f381a8fd1..ed2cfcd76f60 100644

arch/loongarch/kvm/vcpu.c bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu) · line 408

Quoted 8 lines
arch/loongarch/kvm/vcpu.c +1 -1
@@ -402,7 +402,7 @@ bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu)
  	val = gcsr_read(LOONGARCH_CSR_CRMD);
  	preempt_enable();
 
-	return (val & CSR_PRMD_PPLV) == PLV_KERN;
+	return (val & CSR_CRMD_PLV) == PLV_KERN;
  }
 
  #ifdef CONFIG_GUEST_PERF_EVENTS
maintainer Applied
#2 lore raw
Quoted 21 lines · Bibo Mao
Quoted 17 lines · cuitao

The function reads LOONGARCH_CSR_CRMD but uses CSR_PRMD_PPLV to extract the privilege level. While both masks have the same value (0x3), CSR_CRMD_PLV is the semantically correct constant for CRMD.

---
  arch/loongarch/kvm/vcpu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/kvm/vcpu.c +0 -0
index 831f381a8fd1..ed2cfcd76f60 100644
@@ -402,7 +402,7 @@ bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu)
      val = gcsr_read(LOONGARCH_CSR_CRMD);
      preempt_enable();
 
Quoted 7 lines

arch/loongarch/kvm/vcpu.c bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu) · line 408

Quoted 6 lines
arch/loongarch/kvm/vcpu.c +1 -1
-     return (val & CSR_PRMD_PPLV) == PLV_KERN;
+     return (val & CSR_CRMD_PLV) == PLV_KERN;
  }
 
  #ifdef CONFIG_GUEST_PERF_EVENTS

Applied, thanks.

Huacai

Quoted 1 line