[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 16/23] target/i386/sev: Remove stubs by using code elision
From: |
Daniel P . Berrangé |
Subject: |
Re: [PATCH v4 16/23] target/i386/sev: Remove stubs by using code elision |
Date: |
Thu, 7 Oct 2021 18:27:52 +0100 |
User-agent: |
Mutt/2.0.7 (2021-05-04) |
On Thu, Oct 07, 2021 at 07:18:04PM +0200, Philippe Mathieu-Daudé wrote:
> On 10/7/21 19:07, Dr. David Alan Gilbert wrote:
> > * Philippe Mathieu-Daudé (philmd@redhat.com) wrote:
> >> Only declare sev_enabled() and sev_es_enabled() when CONFIG_SEV is
> >> set, to allow the compiler to elide unused code. Remove unnecessary
> >> stubs.
> >>
> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> >
> > What makes it allowed to *rely* on the compiler eliding calls?
>
> I am not aware of a particular requirement on the compiler for code
> elision, however we already use this syntax:
Maybe I'm mis-understanding David's question, but I'm not
sure it matters whether the compiler elides the code or
not.
IIUC, with the old code using stubs it is unlikely to be
elided at all. With the new code it will probably be
elided, but if it isn't, then it is no worse than the
code its replacing.
Or am I mis-understanding David's question ?
> $ git grep -A4 'ifdef CONFIG_' include/sysemu/
> ...
> include/sysemu/tcg.h:11:#ifdef CONFIG_TCG
> include/sysemu/tcg.h-12-extern bool tcg_allowed;
> include/sysemu/tcg.h-13-#define tcg_enabled() (tcg_allowed)
> include/sysemu/tcg.h-14-#else
> include/sysemu/tcg.h-15-#define tcg_enabled() 0
> ...
>
> Cc'ing Richard/Eric/Daniel who have more experience with compiler
> features in case they can enlighten me here.
I'd say my general view is we are free to use features explicitly
supported by our designated compilers. We should avoid relying on
undefined compiler behaviour for funtional results in QEMU.
We can rely on our designated compilers to optimize certain code
patterns, as long as its purely for performance benefits, not
functional benefits, since optimizations are not guaranteed and
users can turn them off too.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
[PATCH v4 17/23] target/i386/sev: Move qmp_query_sev_attestation_report() to sev.c, Philippe Mathieu-Daudé, 2021/10/07
[PATCH v4 18/23] target/i386/sev: Move qmp_sev_inject_launch_secret() to sev.c, Philippe Mathieu-Daudé, 2021/10/07
[PATCH v4 19/23] target/i386/sev: Move qmp_query_sev_capabilities() to sev.c, Philippe Mathieu-Daudé, 2021/10/07
[PATCH v4 20/23] target/i386/sev: Move qmp_query_sev_launch_measure() to sev.c, Philippe Mathieu-Daudé, 2021/10/07
[PATCH v4 21/23] target/i386/sev: Move qmp_query_sev() & hmp_info_sev() to sev.c, Philippe Mathieu-Daudé, 2021/10/07
[PATCH v4 22/23] monitor: Reduce hmp_info_sev() declaration, Philippe Mathieu-Daudé, 2021/10/07
[PATCH v4 23/23] MAINTAINERS: Cover SEV-related files with X86/KVM section, Philippe Mathieu-Daudé, 2021/10/07