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 DF1B4C433FE for ; Wed, 5 Jan 2022 19:41:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243649AbiAETlE (ORCPT ); Wed, 5 Jan 2022 14:41:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243637AbiAETlC (ORCPT ); Wed, 5 Jan 2022 14:41:02 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E3C1C061201 for ; Wed, 5 Jan 2022 11:41:02 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id m1so270682pfk.8 for ; Wed, 05 Jan 2022 11:41:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=pZ7Du5aXJypbN5z9JdXaN/bv6j/5WCgbjcAZoOJVTUo=; b=fZrlfDN2fNtW20qRO8Z9+o9nA5CFDsiKwl72mrfDZ538L6+n+8tdbpiIIOCAAtuJ/U kR3kRLZLgvWRszCANN33MnEha5UmcBTrH9HOq653dfDwYe1JNqJKRrbdk9mmWBs3h86k qjo99ocaP1PvNTkh+DsMkxm0dEAh9KCtGCIglmzsyd6gTDNp8Hsp0fZi022Tu+XIZ8IC o79KS8q79BBdJpu2S8Rk7bRM4T+a2Csi/Ew7MqGaW/3MpIp+WIiFc0dwtT0Mw0762+jB J0aW7melAxcapbZXU1N44tXkKhjlm7jCSBWqDErSFgRrhQfQxFBXYId40kXyaBklusJQ xlCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=pZ7Du5aXJypbN5z9JdXaN/bv6j/5WCgbjcAZoOJVTUo=; b=yf3sZFu7Dsmrp1QVnOwKpBHY1MkC8qrIpk4W4S9hdCwuB93fKicQO4yBmhwF22kuE+ Leh8bp1jUFSUtpvn1vy6qwzPCyVHOtiuqtmK6O2du+E+lbl2Z6Bd4dbPzxkeV6AiKErB LUBUHNBHiwqdD2szzj2JmbskH6NzQphgJRVX0T7V+9uVNT05ha712Kzi9GRcPe7lqa8E Z8ZFr6i21qY2po+oVCJV7eYIy4Cr+hhghx6R4qf3o9iNMEmVPsftlOfceP14gSnr/Ehm /zopd+x2jdkalPXYsQKBh5AsnoPgFrjzyEcgJZRZ/swIcZXpnftxOnK+NxPplPeSlNod zInQ== X-Gm-Message-State: AOAM532z6qvdv25riDkGtYVFLqrXA+68GTVchX2s3ZKpLq6tC/TdnFVG rqrDSQbtiDGm2rPZRh7Bjmp4qw== X-Google-Smtp-Source: ABdhPJxd23qEySJcCwtTGFUUCnhs0ACGzCCMlTQh0PUWwigVeZbm2WT+JjUT3hpQbEtMvfjsVpFKNw== X-Received: by 2002:aa7:8e88:0:b0:4ba:8792:b with SMTP id a8-20020aa78e88000000b004ba8792000bmr56091893pfr.23.1641411661585; Wed, 05 Jan 2022 11:41:01 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id n34sm43708606pfv.129.2022.01.05.11.41.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 11:41:01 -0800 (PST) Date: Wed, 5 Jan 2022 19:40:57 +0000 From: Sean Christopherson To: Michael Roth Cc: linux-kselftest@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Nathan Tempelman , Marc Orr , Steve Rutherford , Mingwei Zhang , Brijesh Singh , Tom Lendacky , Varad Gautam , Shuah Khan , Vitaly Kuznetsov , David Woodhouse , Ricardo Koller , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Christian Borntraeger , Janosch Frank , David Hildenbrand , Claudio Imbrenda , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , kvmarm@lists.cs.columbia.edu Subject: Re: [RFC PATCH 00/10] KVM: selftests: Add support for test-selectable ucall implementations Message-ID: References: <20211210164620.11636-1-michael.roth@amd.com> <20220104233517.kxjbdw4t7taymab5@amd.com> <20220105170244.jwr6i2erecbhx3fz@amd.com> <20220105191107.qx67wf2coc3q6giu@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220105191107.qx67wf2coc3q6giu@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 05, 2022, Michael Roth wrote: > On Wed, Jan 05, 2022 at 05:43:21PM +0000, Sean Christopherson wrote: > > Because it uses multiple VMs, and my rough sketch only allows for a single VM to > > use ucall. Though I suppose we could simply keep appending to the ucall list for > > every VM. The requirement would then be that all VMs are of the same type, i.e. > > utilize the same ucall_ops. > > Hmm, maybe I misread your patch. Not supporting multiple VMs was the > reason I gave up on having the ucall structs allocated on-demand and > went with requiring them to be passed as arguments to ucall(). > > I thought with your patch you had solved that by having each vm have it's > own pool, via vm->ucall_list, and then mapping each pool into each guest > separately via: > > ucall_init(vm): > ucall_list = vm->ucall_list > sync_global_to_guest(ucall_list). > > then as long as that ucall_init() is done *after* the guest calls > kvm_vm_elf_load(), it will end up with a 'ucall_list' global that points > to it's own specific vm->ucall_list. Then on the test side it doesn't > matter what the 'ucall_list' global is currently set to since you have > the GPA and know what vm exited. > > Or am I missing something there? Ha, that was not at all intented. But yes, it should work. I'd rather be lucky than good? > Although even if that is the case, now that we're proposing doing the > ucall_init() inside vm_create(), then we run the risk of a test calling > kvm_vm_elf_load() after, which might clobber the guest's copy of > ucall_list global if ucall_init() had since been called for another VM. > But that could maybe be worked around by having whatever vm_create() > variant we use also do the kvm_vm_elf_load() unconditionally as part of > creation. Will sync_global_to_guest() even work as intended if kvm_vm_elf_load() hasn't been called? If not, then sync_global_{to,from}_guest() should really assert if the test hasn't been loaded. As for ucall_init(), I think the best approach would be to make kvm_vm_elf_load() a static and replace all calls with: kvm_vm_load_guest(vm); where its implementation is: void kvm_vm_load_guest(struct kvm_vm *vm) { kvm_vm_elf_load(vm, program_invocation_name); ucall_init(vm); } The logic being that if a test creates a VM but never loads any code into the guest, e.g. kvm_create_max_vcpus, then it _can't_ make ucalls.