qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>
Subject: Re: [RFC PATCH] configure: Poison (almost) all target-specific #defines
Date: Mon, 15 Mar 2021 16:52:58 +0100	[thread overview]
Message-ID: <94307555-3d39-b993-d8b3-ea78cb675be1@redhat.com> (raw)
In-Reply-To: <CAFEAcA9KvqMycFysq_U1NHwUx8RZToZ5DXvqGnhpuw8XcGhrSQ@mail.gmail.com>

On 15/03/2021 16.37, Peter Maydell wrote:
> On Mon, 15 Mar 2021 at 15:26, Thomas Huth <thuth@redhat.com> wrote:
>>
>> On 15/03/2021 15.52, Philippe Mathieu-Daudé wrote:
>>> On 3/15/21 2:54 PM, Thomas Huth wrote:
>>>> We are generating a lot of target-specific defines in the *-config-devices.h
>>>> and *-config-target.h files. Using them in common code is wrong and leads
>>>> to very subtle bugs since a "#ifdef CONFIG_SOMETHING" is not working there
>>>> as expected. To avoid these issues, we are already poisoning some of the
>>>> macros in include/exec/poison.h - but maintaining this list manually is
>>>> cumbersome. Thus let's generate the list of poisoned macros automatically
>>>> instead.
>>>> Note that CONFIG_TCG (which is also defined in config-host.h) and
>>>
>>> IIRC we can't poison CONFIG_XEN / CONFIG_HAX because they are
>>> pulled in via "sysemu/hw_accel.h".
>>
>> That's a good hint ... but I think it can be fixed with a patch like this:
>>
>> diff a/include/sysemu/hw_accel.h b/include/sysemu/hw_accel.h
>> --- a/include/sysemu/hw_accel.h
>> +++ b/include/sysemu/hw_accel.h
>> @@ -12,19 +12,24 @@
>>    #define QEMU_HW_ACCEL_H
>>
>>    #include "hw/core/cpu.h"
>> +
>> +#ifdef NEED_CPU_H
>> +
>>    #include "sysemu/hax.h"
>>    #include "sysemu/kvm.h"
>>    #include "sysemu/hvf.h"
>>    #include "sysemu/whpx.h"
> 
> This doesn't look right, because sysemu/kvm.h itself contains
> a NEED_CPU_H check, which implies that there are situations where
> NEED_CPU_H is not defined and we need to pull in the header.

I just tried, and QEMU seems to compile fine with my patch... I guess the 
check for NEED_CPU_H is mainly required for files that include 
"sysemu/kvm.h" directly, without the detour via hw_accel.h.

Anyway, I can also push the check rather into the hax.h, hvf.h and whpx.h 
files themselves, to make them more similar to kvm.h.

  Thomas



  reply	other threads:[~2021-03-15 15:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 13:54 [RFC PATCH] configure: Poison (almost) all target-specific #defines Thomas Huth
2021-03-15 14:07 ` Claudio Fontana
2021-03-15 15:08   ` Thomas Huth
2021-03-15 15:22     ` Claudio Fontana
2021-03-15 14:52 ` Philippe Mathieu-Daudé
2021-03-15 15:24   ` Thomas Huth
2021-03-15 15:37     ` Peter Maydell
2021-03-15 15:52       ` Thomas Huth [this message]
2021-03-15 18:24 ` Eric Blake
2021-03-16  5:28   ` Thomas Huth

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=94307555-3d39-b993-d8b3-ea78cb675be1@redhat.com \
    --to=thuth@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).