Skip to contentSkip to conversation

KVM: PPC: Book3S HV: Initialize AMOR in nested entry

PATCH Applied Fabiano Rosas 3 participants 4 messages Apr 25, 2022 – May 24, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: PPC: Book3S HV: Initialize AMOR in nested entry

The hypervisor always sets AMOR to ~0, but let's ensure we're not passing stale values around.

---
 arch/powerpc/kvm/book3s_hv.c | 1 +
 1 file changed, 1 insertion(+)
arch/powerpc/kvm/book3s_hv.c +1 -0
index 6fa518f6501d..b5f504576765 100644
@@ -3967,6 +3967,7 @@ static int kvmhv_vcpu_entry_p9_nested(struct kvm_vcpu *vcpu, u64 time_limit, uns
 
 	kvmhv_save_hv_regs(vcpu, &hvregs);
 	hvregs.lpcr = lpcr;
+	hvregs.amor = ~0;
 	vcpu->arch.regs.msr = vcpu->arch.shregs.msr;
 	hvregs.version = HV_GUEST_STATE_VERSION;
 	if (vcpu->arch.nested) {
Signature · 1 line
2.35.1
reviewer Reviewed-by on v1 1/1
#1 lore raw

Excerpts from Fabiano Rosas's message of April 26, 2022 12:21 am:

Quoted 3 lines

The hypervisor always sets AMOR to ~0, but let's ensure we're not passing stale values around.

Looks like our L0 doesn't do anything with hvregs.amor ?

Thanks,
Nick

Quoted 21 lines
---
 arch/powerpc/kvm/book3s_hv.c | 1 +
 1 file changed, 1 insertion(+)
arch/powerpc/kvm/book3s_hv.c +1 -0
index 6fa518f6501d..b5f504576765 100644
@@ -3967,6 +3967,7 @@ static int kvmhv_vcpu_entry_p9_nested(struct kvm_vcpu *vcpu, u64 time_limit, uns
 
 	kvmhv_save_hv_regs(vcpu, &hvregs);
 	hvregs.lpcr = lpcr;
+	hvregs.amor = ~0;
 	vcpu->arch.regs.msr = vcpu->arch.shregs.msr;
 	hvregs.version = HV_GUEST_STATE_VERSION;
 	if (vcpu->arch.nested) {
Signature · 1 line
2.35.1
#2 lore raw
Quoted 8 lines · Nicholas Piggin

Excerpts from Fabiano Rosas's message of April 26, 2022 12:21 am:

Quoted 3 lines

The hypervisor always sets AMOR to ~0, but let's ensure we're not passing stale values around.

Looks like our L0 doesn't do anything with hvregs.amor ?

It doesn't. And if the HV ever starts clearing bits from AMOR, then we would need to change any kernel code that writes and reads from AMR ( such as the KUAP) to take into consideration that we might read a different value from what we wrote.