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 3E8C5C433F5 for ; Wed, 5 Jan 2022 22:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244704AbiAEWDG (ORCPT ); Wed, 5 Jan 2022 17:03:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244642AbiAEWC7 (ORCPT ); Wed, 5 Jan 2022 17:02:59 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 769BCC061212 for ; Wed, 5 Jan 2022 14:02:58 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id i8so349918pgt.13 for ; Wed, 05 Jan 2022 14:02:58 -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=YKCFFRAciZpcdqJmTFTjz+wKvbhjzm225M4aIDaCuiU=; b=fW9ulu/h4JJhF3zfksJLWMb/bqR8giX/dFE0CouDR+T4lybi6lRauIYAouP9mYL2XX YguWms/IVaiZ3ZDCwIsKnjiIpWbcleacvZ/EO7P0mqySNH9ebGIcBvSMfi/iaLmwASwe 2TlHkMJirJyvPG3B30LCRQ1HdqX38PzwsH4j8PyaMwKJiOg8OC8vWl1TGwkY5wOioE2K GqaN3SZNTMLLsyolLb/ExYbL9PgCKZxj1oaZkD2S2bVAWDfqROpz0mplyuwiV1bqPgo4 xWF2cFWOwG70irBz41p2OphNPPmUXrSGaQUwvoSs6suQBfsw7AgL669rhPB5Uu7wAo7P nsoQ== 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=YKCFFRAciZpcdqJmTFTjz+wKvbhjzm225M4aIDaCuiU=; b=eO6AqN+6y2Qtegar01CZA+rmKYKAFHL8odU+8ppiaYWYgo9tBIWQep5bvRuSQ8bVq3 DHe1k4AeuQxg7EOVl+Y92JPxZZkMv9To8cv30oEJBWUi5migXG0v+A1oXpbn0qgm5w+R uHrP2vfpZC61epablJz9atbGkj2DcSaKPnTDN4cp8zQdy/GMSXGUICTl6xRG7NlKU5Lc XPVZZ87SLWUSMErs7NlSir+f79uOsdoki9c1Qg08NCXo0Cer45uUu+LgfglelRHPu+tR dqGJyQsuukd8qWxnFKrwC/QVMJtnSdAPhJlV7ISAz16yj/WEyj1xoGR0ZNkvHR+jSWbz UPNw== X-Gm-Message-State: AOAM533VicaCcLkzSeiIM86V+53oufTUx91rjyh5Qyw9rTc2wJ49qAY4 HlwCuqpDUBzVZnobCX2uEStPrg== X-Google-Smtp-Source: ABdhPJy1j3iKKZs35n/KzJTCkqL0HcCrjjmYG6bssNBIFzGISkV5H8QpwsTR9BEo9HcizmPRobCqBQ== X-Received: by 2002:a62:7c58:0:b0:4bb:314b:86b9 with SMTP id x85-20020a627c58000000b004bb314b86b9mr57302956pfc.84.1641420177751; Wed, 05 Jan 2022 14:02:57 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id 36sm20676pgq.94.2022.01.05.14.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 14:02:57 -0800 (PST) Date: Wed, 5 Jan 2022 22:02:53 +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> <20220105213519.g746jzf756nax562@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220105213519.g746jzf756nax562@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 07:40:57PM +0000, Sean Christopherson wrote: > > 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. > > Makes sense. And if different ops are needed for vmgexit()/tdcall() it > could be something like (if based on patches 1-5 of this series, and > extending vm_guest_mode as you suggested earlier): > > void kvm_vm_load_guest(struct kvm_vm *vm) > { > > kvm_vm_elf_load(vm, program_invocation_name); > > if (vm->mode == VM_MODE_SEV) > ucall_init_ops(vm, ucall_ops_pio_vmgexit); > else (vm->vm_type == VM_MODE_TDX) I don't think we want to do this here, but instead down in the arch-specific ucall_init(). Also, not sure if I was clear before (can't tell what you interpreted based on the above snippet), but I think we'll want VM_MODE_SEV etc... to be modifiers on top of the VA/PA stuff. > ucall_init_ops(vm, ucall_ops_pio_tdcall); > else > ucall_init_ops(vm, ucall_ops_pio); > > Shame we have to update all the kvm_vm_elf_load() call-sites, but > they'd end up potentially breaking things if left as-is anyway. > > Were you planning on sending patches for these changes, or should I incorporate > your prototype and take a stab at the other changes as part of v2 of this > series? Nope, all yours. Thanks!