Skip to content

Commit e678748

Browse files
iamjpnmpe
authored andcommitted
KVM: PPC: Book3S HV nestedv2: Get the PID only if needed to copy tofrom a guest
kvmhv_copy_tofrom_guest_radix() gets the PID at the start of the function. If pid is not used, then this is a wasteful H_GUEST_GET_STATE hcall for nestedv2 hosts. Move the assignment to where pid will be used. Suggested-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Jordan Niethe <jniethe5@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20231201132618.555031-5-vaibhav@linux.ibm.com
1 parent 63ccae7 commit e678748

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/powerpc/kvm/book3s_64_mmu_radix.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static long kvmhv_copy_tofrom_guest_radix(struct kvm_vcpu *vcpu, gva_t eaddr,
9797
void *to, void *from, unsigned long n)
9898
{
9999
int lpid = vcpu->kvm->arch.lpid;
100-
int pid = kvmppc_get_pid(vcpu);
100+
int pid;
101101

102102
/* This would cause a data segment intr so don't allow the access */
103103
if (eaddr & (0x3FFUL << 52))
@@ -110,6 +110,8 @@ static long kvmhv_copy_tofrom_guest_radix(struct kvm_vcpu *vcpu, gva_t eaddr,
110110
/* If accessing quadrant 3 then pid is expected to be 0 */
111111
if (((eaddr >> 62) & 0x3) == 0x3)
112112
pid = 0;
113+
else
114+
pid = kvmppc_get_pid(vcpu);
113115

114116
eaddr &= ~(0xFFFUL << 52);
115117

0 commit comments

Comments
 (0)