All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Matlack <dmatlack@google.com>
To: Vishal Annapurve <vannapurve@google.com>
Cc: Andrew Jones <andrew.jones@linux.dev>, x86 <x86@kernel.org>,
	kvm list <kvm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-kselftest@vger.kernel.org,
	Paolo Bonzini <pbonzini@redhat.com>, shuah <shuah@kernel.org>,
	Ben Gardon <bgardon@google.com>,
	Sean Christopherson <seanjc@google.com>,
	oupton@google.com, peterx@redhat.com,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	drjones@redhat.com
Subject: Re: [V1 PATCH 2/5] selftests: kvm: Introduce kvm_arch_main and helpers
Date: Thu, 8 Sep 2022 14:21:52 -0700	[thread overview]
Message-ID: <Yxpc8NDdtdOl9wpH@google.com> (raw)
In-Reply-To: <CAGtprH9Kaemwupgoo_kgM-Ci2cnN2kpXa+ZwEymSnYNFhS9Fsg@mail.gmail.com>

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@linux.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 */
}

  reply	other threads:[~2022-09-08 21:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-03  1:28 [V1 PATCH 0/5] Execute hypercalls from guests according to cpu type Vishal Annapurve
2022-09-03  1:28 ` [V1 PATCH 1/5] selftests: kvm: move common startup logic to kvm_util.c Vishal Annapurve
2022-09-08 21:09   ` David Matlack
2022-09-14 19:09     ` Vishal Annapurve
2022-09-03  1:28 ` [V1 PATCH 2/5] selftests: kvm: Introduce kvm_arch_main and helpers Vishal Annapurve
2022-09-05  7:46   ` Andrew Jones
2022-09-06 22:46     ` Vishal Annapurve
2022-09-08 21:21       ` David Matlack [this message]
2022-09-09  7:01         ` Andrew Jones
2022-09-14 19:13           ` Vishal Annapurve
2022-09-08 21:27   ` David Matlack
2022-09-03  1:28 ` [V1 PATCH 3/5] selftests: kvm: x86: Execute vmcall/vmmcall according to CPU type Vishal Annapurve
2022-09-08 22:54   ` David Matlack
2022-09-08 22:57     ` David Matlack
2022-09-14 19:12     ` Vishal Annapurve
2022-09-03  1:28 ` [V1 PATCH 4/5] selftests: kvm: delete svm_vmcall_test Vishal Annapurve
2022-09-03  1:28 ` [V1 PATCH 5/5] selftests: kvm: Execute vmcall/vmmcall as per cpu type Vishal Annapurve

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=Yxpc8NDdtdOl9wpH@google.com \
    --to=dmatlack@google.com \
    --cc=andrew.jones@linux.dev \
    --cc=bgardon@google.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=oupton@google.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=seanjc@google.com \
    --cc=shuah@kernel.org \
    --cc=vannapurve@google.com \
    --cc=vkuznets@redhat.com \
    --cc=x86@kernel.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.