From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>,
qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH RESEND v4 1/4] target/i386: Fix conditional CONFIG_SYNDBG enablement
Date: Thu, 14 Nov 2024 12:33:40 +0100 [thread overview]
Message-ID: <87cyiyjbhn.fsf@redhat.com> (raw)
In-Reply-To: <2d8273dd-3355-439b-9d40-e56286b93100@tls.msk.ru>
Michael Tokarev <mjt@tls.msk.ru> writes:
> 17.09.2024 19:00, Vitaly Kuznetsov пишет:
>> Putting HYPERV_FEAT_SYNDBG entry under "#ifdef CONFIG_SYNDBG" in
>> 'kvm_hyperv_properties' array is wrong: as HYPERV_FEAT_SYNDBG is not
>> the highest feature number, the result is an empty (zeroed) entry in
>> the array (and not a skipped entry!). hyperv_feature_supported() is
>> designed to check that all CPUID bits are set but for a zeroed
>> feature in 'kvm_hyperv_properties' it returns 'true' so QEMU considers
>> HYPERV_FEAT_SYNDBG as always supported, regardless of whether KVM host
>> actually supports it.
>>
>> To fix the issue, leave HYPERV_FEAT_SYNDBG's definition in
>> 'kvm_hyperv_properties' array, there's nothing wrong in having it defined
>> even when 'CONFIG_SYNDBG' is not set. Instead, put "hv-syndbg" CPU property
>> under '#ifdef CONFIG_SYNDBG' to alter the existing behavior when the flag
>> is silently skipped in !CONFIG_SYNDBG builds.
>>
>> Leave an 'assert' sentinel in hyperv_feature_supported() making sure there
>> are no 'holes' or improperly defined features in 'kvm_hyperv_properties'.
>>
>> Fixes: d8701185f40c ("hw: hyperv: Initial commit for Synthetic Debugging device")
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>
>> diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
>> index ada581c5d6ea..4009fcfd6b29 100644
>> --- a/target/i386/kvm/kvm.c
>> +++ b/target/i386/kvm/kvm.c
> ...
>> @@ -3924,13 +3929,11 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
>> kvm_msr_entry_add(cpu, HV_X64_MSR_TSC_EMULATION_STATUS,
>> env->msr_hv_tsc_emulation_status);
>> }
>> -#ifdef CONFIG_SYNDBG
>> if (hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNDBG) &&
>> has_msr_hv_syndbg_options) {
>> kvm_msr_entry_add(cpu, HV_X64_MSR_SYNDBG_OPTIONS,
>> hyperv_syndbg_query_options());
>> }
>> -#endif
>
> This change broke a minimal build:
Sorry about that :-(
>
> $ ../configure --without-default-features --without-default-devices --target-list=x86_64-softmmu --enable-kvm
> ...
> FAILED: qemu-system-x86_64
> cc -m64 @qemu-system-x86_64.rsp
> /usr/bin/ld: libqemu-x86_64-softmmu.a.p/target_i386_kvm_kvm.c.o: in function `kvm_put_msrs':
> target/i386/kvm/kvm.c:4039:(.text+0x83ae): undefined reference to `hyperv_syndbg_query_options'
> collect2: error: ld returned 1 exit status
>
> Why this particular #ifdef has been removed?
The patch was on the list for over a year before it got accepted and I
completely forgot the details... Looking at it now and I don't believe
we need HV_X64_MSR_SYNDBG_OPTIONS at all when !CONFIG_SYNDBG so I guess
we can bring the ifdef back. Let me do some quick tests and I'll send a
patch.
--
Vitaly
next prev parent reply other threads:[~2024-11-14 11:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-17 16:00 [PATCH RESEND v4 0/4] target/i386: Various Hyper-V related fixes Vitaly Kuznetsov
2024-09-17 16:00 ` [PATCH RESEND v4 1/4] target/i386: Fix conditional CONFIG_SYNDBG enablement Vitaly Kuznetsov
2024-11-14 10:46 ` Michael Tokarev
2024-11-14 11:33 ` Vitaly Kuznetsov [this message]
2024-09-17 16:00 ` [PATCH RESEND v4 2/4] target/i386: Exclude 'hv-syndbg' from 'hv-passthrough' Vitaly Kuznetsov
2024-09-17 16:00 ` [PATCH RESEND v4 3/4] target/i386: Make sure SynIC state is really updated before KVM_RUN Vitaly Kuznetsov
2024-09-17 16:00 ` [PATCH RESEND v4 4/4] docs/system: Add recommendations to Hyper-V enlightenments doc Vitaly Kuznetsov
2024-09-30 13:56 ` [PATCH RESEND v4 0/4] target/i386: Various Hyper-V related fixes Vitaly Kuznetsov
2024-10-14 9:04 ` Vitaly Kuznetsov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87cyiyjbhn.fsf@redhat.com \
--to=vkuznets@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.