Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1586528rwn; Fri, 9 Sep 2022 00:15:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR6nE0CYjSdNjeprTSrExnJ2IVQJLJ0zhKVqdg7zKnQog8D0jA1vpGdrv31syTf8O1sEJYHj X-Received: by 2002:a2e:a44c:0:b0:26b:e70f:a026 with SMTP id v12-20020a2ea44c000000b0026be70fa026mr203348ljn.94.1662707729173; Fri, 09 Sep 2022 00:15:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662707729; cv=none; d=google.com; s=arc-20160816; b=QiONJW1p3zLnCmCPtaA028LJIoErI1dO3AhKHZCNI0xyNzNOPuv0dq5bkMKnClYfvg HBrrSF3lVNEjJLUR/M5aSjq/baP/Jp69u8mVdDXolnCxpPguVS27e6BD4d756fVujxGc /EayL49pU24wLmVUWyXyHz4kNywk4x9oP2jraU2DR4L/0EjPVV+AHldoabrA5uPdjYy5 1UpEP5nJfPVtRE+ZWXJEbd3ndMMDDyMYqLTknQEB1I52p29U2i5Bauox17tyABdBMXmy ITsBT4xu7HM6VBWb4+tnvcqEUjrc6rwa9RABs9eGtwfHa4ek0SLaq1N5oCpitXO2c1e9 AibA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=RWCELvBZAP7UK2m8DqFciqCKvSVVz5+g8uq2bLhQwA8=; b=zIsKbzBaJK5bavq6RpIqMMpRni/MDjD00XYfd1yCHhlnoIcAnbB4qfnFAeGsBPBBtJ /WJWraELnBLR4/PXJlrq/YQOy9ZRE6PS4DvnnFbkgq/LF2xwbunwv1uL4Zc3JO9s3vl7 wfXIK2WwLpVIA1pGBBZGZ+3P2tkeNp2IRy79IJ2oEBZ+BB5fZewEic5Y9nIulHNe3Mt9 /W3oHUyxmgVJdarY27ogizCE/3FeiwNgZO06jSrGb/DBYkuB4Z030VMH8lWyX4SAdMTY NUcLVscK0vNS2s0XU5KQxiuHf7mp3QPyFb/7p6Q2EH8DM3UK01O/vcNZIPGyy/Xs7GVs WHtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=SwQYFx2g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x10-20020a2ea7ca000000b0026aa7b23812si587911ljp.41.2022.09.09.00.15.00; Fri, 09 Sep 2022 00:15:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=SwQYFx2g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231252AbiIIHBl (ORCPT + 99 others); Fri, 9 Sep 2022 03:01:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230285AbiIIHBd (ORCPT ); Fri, 9 Sep 2022 03:01:33 -0400 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AFA0A9C3A; Fri, 9 Sep 2022 00:01:29 -0700 (PDT) Date: Fri, 9 Sep 2022 09:01:25 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1662706887; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RWCELvBZAP7UK2m8DqFciqCKvSVVz5+g8uq2bLhQwA8=; b=SwQYFx2gTSYfpujoytL1i5+wwGrG5ThpC5gpq83EFjxVv08IzH3LHBjo9RP/GlHkgGOw+H HeeegsKUNc+JjU+Sv1kpinOYC8BKj8TSA5OHWn9vO1uwvGowpyeVAvU1Zev38vM91Nynir A5iEQktvI19mNnzP4EwHBlASsW56ZUI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Andrew Jones To: David Matlack Cc: Vishal Annapurve , 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: <20220909070125.dtqfa6neq46fvns2@kamzik> 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: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 08, 2022 at 02:21:52PM -0700, David Matlack wrote: > 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 */ > } WFM and I think that's what Vishal was suggesting as well. Thanks, drew