[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yxpc8NDdtdOl9wpH@google.com>
Date: Thu, 8 Sep 2022 14:21:52 -0700
From: David Matlack <dmatlack@...gle.com>
To: Vishal Annapurve <vannapurve@...gle.com>
Cc: Andrew Jones <andrew.jones@...ux.dev>, x86 <x86@...nel.org>,
kvm list <kvm@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
linux-kselftest@...r.kernel.org,
Paolo Bonzini <pbonzini@...hat.com>, shuah <shuah@...nel.org>,
Ben Gardon <bgardon@...gle.com>,
Sean Christopherson <seanjc@...gle.com>, oupton@...gle.com,
peterx@...hat.com, Vitaly Kuznetsov <vkuznets@...hat.com>,
drjones@...hat.com
Subject: Re: [V1 PATCH 2/5] selftests: kvm: Introduce kvm_arch_main and
helpers
On Tue, Sep 06, 2022 at 03:46:20PM -0700, Vishal Annapurve wrote:
> On Mon, Sep 5, 2022 at 12:46 AM Andrew Jones <andrew.jones@...ux.dev> wrote:
> >
> > On Sat, Sep 03, 2022 at 01:28:46AM +0000, Vishal Annapurve wrote:
> > > Introduce following APIs:
> > > 1) kvm_arch_main : to be called at the startup of each test.
> >
> > With this, AArch64 can move the content of its constructor,
> > init_guest_modes(), into kvm_arch_main(). Or, instead of the
> >
> > main()
> > {
> > /* common main stuff */
> > kvm_arch_main();
> > __main();
> > }
> >
> > approach we could have each arch provide a constructor
> >
> > arch_init()
> > {
> > common_pre_main_stuff();
> > /* arch specific pre-main stuff */
> > }
> >
> > I personally prefer the latter.
> >
>
> I agree with your suggestion of using constructors here. This will
> help avoid changes in all the selftests.
> Maybe I can add a common constructor that can invoke arch specific
> init. I will add this change in the next series.
In case anyone else is confused like me: "constructor" refers to
__attribute__ ((constructor)), which causes the function to run before
main().
I have a slight preference for having as few constructors as possible,
since they are somewhat subtle. So how about one constructor for all
selftests, e.g.:
void __attribute__ ((constructor)) kvm_selftest_init(void)
{
/* Tell stdout not to buffer its content. */
setbuf(stdout, NULL);
kvm_selftest_arch_init();
}
Per-arch:
void kvm_selftest_arch_init(void)
{
/* arch-specific pre-main stuff */
}
Powered by blists - more mailing lists