Skip to content

Commit 3e067fd

Browse files
committed
KVM: x86: move guest_pv_has out of user_access section
When UBSAN is enabled, the code emitted for the call to guest_pv_has includes a call to __ubsan_handle_load_invalid_value. objtool complains that this call happens with UACCESS enabled; to avoid the warning, pull the calls to user_access_begin into both arms of the "if" statement, after the check for guest_pv_has. Reported-by: Stephen Rothwell <[email protected]> Cc: David Woodhouse <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent f5396f2 commit 3e067fd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

arch/x86/kvm/x86.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3292,9 +3292,6 @@ static void record_steal_time(struct kvm_vcpu *vcpu)
32923292
}
32933293

32943294
st = (struct kvm_steal_time __user *)ghc->hva;
3295-
if (!user_access_begin(st, sizeof(*st)))
3296-
return;
3297-
32983295
/*
32993296
* Doing a TLB flush here, on the guest's behalf, can avoid
33003297
* expensive IPIs.
@@ -3303,6 +3300,9 @@ static void record_steal_time(struct kvm_vcpu *vcpu)
33033300
u8 st_preempted = 0;
33043301
int err = -EFAULT;
33053302

3303+
if (!user_access_begin(st, sizeof(*st)))
3304+
return;
3305+
33063306
asm volatile("1: xchgb %0, %2\n"
33073307
"xor %1, %1\n"
33083308
"2:\n"
@@ -3325,6 +3325,9 @@ static void record_steal_time(struct kvm_vcpu *vcpu)
33253325
if (!user_access_begin(st, sizeof(*st)))
33263326
goto dirty;
33273327
} else {
3328+
if (!user_access_begin(st, sizeof(*st)))
3329+
return;
3330+
33283331
unsafe_put_user(0, &st->preempted, out);
33293332
vcpu->arch.st.preempted = 0;
33303333
}

0 commit comments

Comments
 (0)