From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7082C54EE9 for ; Thu, 8 Sep 2022 21:22:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbiIHVWH (ORCPT ); Thu, 8 Sep 2022 17:22:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230012AbiIHVWD (ORCPT ); Thu, 8 Sep 2022 17:22:03 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 370201197BF for ; Thu, 8 Sep 2022 14:21:59 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id q3so19006942pjg.3 for ; Thu, 08 Sep 2022 14:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=iRCxAqW31No4R523yMeowHDDm6ZPMY3cVOG5h+SWhss=; b=ekRV5++2oqlgPM6t48Xr8iBpXq4/1mPod6LtzGovgAgMeYZ3yGdFCD1C+jzu/CDrmT +iy4VkigNiuTT/IAJEQnHvet8I9oYkHFruxWZof7W/MXKkguDIjcOhxUHJC3SUOCjoXy Ju/+fzoI0xmojvDXeTmm78Mnsk5Vrkfyi6LLVVT/tE1WeQ7WTKZWBxC2jl8kmx4otO/k l+WtBhqvSqxbNsla0R81wZmhQ+fl60W9WaHvkJcXEI6NbELqWwfnd9L/X7hTEdBx4kDh HFZHAP00FAK1kYtrJdU3oMqnZouRV7Js3DCRqyDMVZ7c+u/mH4wZ7ycD2IzvClduU32z hiPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=iRCxAqW31No4R523yMeowHDDm6ZPMY3cVOG5h+SWhss=; b=pmM5qkfsVh3rRKSALg+ZMhz2oZY+LZrU710Vh2EuPmlI7Ttdk/ealPk3RkIR/5lbBI O1MxkXsqR13eMPDtfhrV/22zM4axoYNk2FdFEKx0fBi0JTM2DN8KAhPpXO8BMpuxSBIK ZCMjUH/TBL+stMBXQHctsLEjyFCsosSxe/YD2KVEMAEdfiXgE6PeIuDiOVpe0pokDwyn F4wC/mvrUaZloc/ytVDMWPPFX97lQlOJZN4Nz9MOkun8wU+bSbfna+Rx6EkOZkNzh4DH uzFX1pxJZ0UVrZeKiX8ZKR3b95IpAX+7V5Bqy+ZVXr7dlZhJNrvuQphjanZhg1+42usN SBsA== X-Gm-Message-State: ACgBeo3lDBD0fi5b9X9aImln1gAkWQxI6ulOLYd+rUAgDbYrXwH3BcMY 7fNoZhhIr/qCh+6QAzYazRez3w== X-Google-Smtp-Source: AA6agR48kO9V03khtYOuaO5emQ3zVXXDHHKXaSE9s9WsyqXbAsszqoXX/UCR9xGQJwmGhYbPGMK1aQ== X-Received: by 2002:a17:90b:1803:b0:1fb:45e2:5d85 with SMTP id lw3-20020a17090b180300b001fb45e25d85mr6225074pjb.163.1662672118552; Thu, 08 Sep 2022 14:21:58 -0700 (PDT) Received: from google.com (223.103.125.34.bc.googleusercontent.com. [34.125.103.223]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b00177ff4019d9sm671365plg.274.2022.09.08.14.21.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Sep 2022 14:21:57 -0700 (PDT) Date: Thu, 8 Sep 2022 14:21:52 -0700 From: David Matlack To: Vishal Annapurve Cc: Andrew Jones , x86 , kvm list , LKML , linux-kselftest@vger.kernel.org, Paolo Bonzini , shuah , Ben Gardon , Sean Christopherson , oupton@google.com, peterx@redhat.com, Vitaly Kuznetsov , drjones@redhat.com Subject: Re: [V1 PATCH 2/5] selftests: kvm: Introduce kvm_arch_main and helpers Message-ID: References: <20220903012849.938069-1-vannapurve@google.com> <20220903012849.938069-3-vannapurve@google.com> <20220905074609.ga4tnpuxpcgppx4r@kamzik> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Tue, Sep 06, 2022 at 03:46:20PM -0700, Vishal Annapurve wrote: > On Mon, Sep 5, 2022 at 12:46 AM Andrew Jones 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 */ }