Re: [PATCH v3 03/16] KVM: selftests: Add guest read/write macros

From: Sean Christopherson

Date: Tue May 26 2026 - 21:53:12 EST


On Tue, Apr 21, 2026, Josh Hilke wrote:
> diff --git a/tools/testing/selftests/kvm/steal_time.c b/tools/testing/selftests/kvm/steal_time.c
> index 7be8adfe5dd3..23380de79817 100644
> --- a/tools/testing/selftests/kvm/steal_time.c
> +++ b/tools/testing/selftests/kvm/steal_time.c
> @@ -72,8 +72,7 @@ static void steal_time_init(struct kvm_vcpu *vcpu, uint32_t i)
> int ret;
>
> /* ST_GPA_BASE is identity mapped */
> - st_gva[i] = (void *)(ST_GPA_BASE + i * STEAL_TIME_SIZE);
> - sync_global_to_guest(vcpu->vm, st_gva[i]);
> + WRITE_AND_SYNC_TO_GUEST(vcpu->vm, st_gva[i], (void *)(ST_GPA_BASE + i * STEAL_TIME_SIZE));

Please wrap these. 80 chars is a soft limit (and so is 100 chars), but the purpose
of the rules *and* their exceptions is to make the code easier to read. This is
hard to parse, because there's so much going on in one line, whereas I find this
easier to tease apart:

WRITE_AND_SYNC_TO_GUEST(vcpu->vm, st_gva[i],
(void *)(ST_GPA_BASE + i * STEAL_TIME_SIZE));

>
> ret = _vcpu_set_msr(vcpu, MSR_KVM_STEAL_TIME,
> (ulong)st_gva[i] | KVM_STEAL_RESERVED_MASK);