Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp972687rwb; Tue, 4 Oct 2022 13:25:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM71NqwkVM7NOSUNmgepHxXlNtlIaDv0Gsu8u7Mcd7/jCDi/+PSR5ScofhZ0F28MKX+DWG9Y X-Received: by 2002:a17:907:b05:b0:78d:23ae:2b29 with SMTP id h5-20020a1709070b0500b0078d23ae2b29mr1287265ejl.671.1664915101420; Tue, 04 Oct 2022 13:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664915101; cv=none; d=google.com; s=arc-20160816; b=rpodLIJNLaeByVrlIt8/QmXhlyU0SqGowzY4ubK6rwAVSvhs1CG5IZFWa7/wvyFjd1 Gub7HCKuefO9WL2nVLTVpjKxLklyhPylf4UYaBtb8P4Z+TUCQWT0IbDg6fp9PP+tj0gt bkdmtwYynC+fqZPbrWvzsINoVRaYPOOAkR/n0teg5YhtpzmhBAy8llOlL4OJ+22wLC3S q1lvQ82Yhc62lpkzIQIIXamJp2cmo35w5I3oyibVTghZ1ch7pc+OkzgI7QOcGniHxLFf ZLqUHdgZHYZGlgcjONRoYZEvdW9X41U/D1sOQQjf/WVhA9X0hHXXDokVK1ieDCk3QNuU dkAQ== 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:date:dkim-signature; bh=bUt2mdAF7otp0r4ftE1Z18HsnkLrCvYit9wnkIHZzWg=; b=KPx6b4udGenGk6mY2Hs3T800h2d2cYMEvSCd8hiCApS2Cn2AspIEDwVIAJBXPtSrlG w9qVIooU7ZncB546ewZnylEIJOo3w1vLC7zyVe3OG+qHL1wF/5DkPcnmWA72uQ6pIRyE gI///fi+utSwqpdXOZJW95r3xdsyQTNdi6WVGM4VpsIuxWbj26Czo+f4neaFlZw7UhDd PymCGCgxw9gdIcNF1x27Hk4m4j2DDjk+6nX1XcCZf7BTPIoFI/fWw0Pj+Z95iN5abq+d GHznIUCkMXPg4eBKxamVfnubj40lgsPjy+k7BJcar4jq2+Glhes0RJXCLJKkYI+Unt9C FTjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=K7tqhlh0; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt16-20020a170907729000b0073da774ff40si12373126ejc.122.2022.10.04.13.24.35; Tue, 04 Oct 2022 13:25:01 -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=@google.com header.s=20210112 header.b=K7tqhlh0; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229602AbiJDUKq (ORCPT + 99 others); Tue, 4 Oct 2022 16:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbiJDUKo (ORCPT ); Tue, 4 Oct 2022 16:10:44 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4E9A20F70 for ; Tue, 4 Oct 2022 13:10:42 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id e129so13572790pgc.9 for ; Tue, 04 Oct 2022 13:10:42 -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=bUt2mdAF7otp0r4ftE1Z18HsnkLrCvYit9wnkIHZzWg=; b=K7tqhlh0shAHpErw/QZIhzhx1aFKorhOn/1DSzxKM4MpXTkIwPih06Z0XDnu6bLSUK V17SkduW8R7UW3RJz24vNA97YZSzFt+AV66s/LkMYjsBjfzmBT56izsPAuBFhgxAyCd9 kSYJfRbKefuacvUbJTqx/QIFW6OZlp38RJsHKMtqaErUWTJJ/3ZPQ9knO7NV6RW8Wcwq HIy/IlCr0fuqLdpBynnYkbn3h3TZiOmG8tFMAF/PXCrUOFw0nx9KetgowjBI05n1sb0l JkF794wMmGoQgFZNGsn/rWpwDuCzNUQqieUmehEJ8NRM6eHx0xtxfCQiPcgVGth8Z1xp SQcQ== 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=bUt2mdAF7otp0r4ftE1Z18HsnkLrCvYit9wnkIHZzWg=; b=ay5Dc7NEqlUomYPg2+l8hir77CMKwSFEXiB8Z539uQizvP7J5+/rDJpvTSPAPsdvnJ 450Hwuv0PQ5a1PhDQJAfcDfnDmgt1ep3EnKNlUoC0fn2Z/5FIne1vA7ZMJx/OTII31/Q LdgLgMq93G1PHODrQJ1AIbmyrRZAbpbfXr2oRDHJk4P/BrK5LTgAYyDScdmT/Az4x6yH 68nB8D9Wa9rEr9LgcBE3B1xGqy4ay6EKxFoTk26oxZ7Ge6xK0nvZcZZ94QYDAZVWFTVp HdDMnQdfve/i8ZJVzY2aZXqfu/3fwCDUm+GrulqQI5/lbJBC7yIlOFfUJKwxNUUytyPY 1m3A== X-Gm-Message-State: ACrzQf3bBJELiEGEavTluTcPgwbvXJBDaG+qpaV/zLZBXCEyGGf97HMt F6rHSRxrC1/NLaqjWyRkz+BhvA== X-Received: by 2002:a63:120b:0:b0:43c:771b:4c52 with SMTP id h11-20020a63120b000000b0043c771b4c52mr25057356pgl.370.1664914242145; Tue, 04 Oct 2022 13:10:42 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id bb5-20020a170902bc8500b00172751a2fa4sm9303853plb.80.2022.10.04.13.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 13:10:41 -0700 (PDT) Date: Tue, 4 Oct 2022 20:10:37 +0000 From: Sean Christopherson To: Vishal Annapurve Cc: David Matlack , x86 , kvm list , LKML , Linuxkselftest , Paolo Bonzini , shuah , Ben Gardon , Oliver Upton , Peter Xu , Vitaly Kuznetsov Subject: Re: [V2 PATCH 3/8] KVM: selftests: Add arch specific post vm load setup Message-ID: References: <20220915000448.1674802-1-vannapurve@google.com> <20220915000448.1674802-4-vannapurve@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Mon, Oct 03, 2022, Vishal Annapurve wrote: > On Mon, Oct 3, 2022 at 8:42 AM Sean Christopherson wrote: > > Even better, call it from __vm_create() and name it something like > > kvm_arch_vm_post_create(). Like David said, while the hook has a dependency on > > being called after loading the ELF image, the action that arch code is expected > > to take doesn't have anything to do with loading the ELF image. > > > > And then instead of introducing an arch hook with no implementation, the patch that > > adds the hook can instead use it to replace the x86-64 #ifdef in __vm_create(). > > > > Today upstream kernel selftests don't have scenarios where > kvm_vm_elf_load can get called directly outside ___vm_create but there > are selftests that are up for review [1], [2] that may call > kvm_vm_elf_load directly. Above suggestion will not work in this > scenario, is it suitable to assume that all the callers of > kvm_vm_elf_load will eventually execute kvm_arch_vm_post_create? No, but that's irrelevant. And actually, in any reasonable hypothetical situation I can think of, it's actually undesirable to always call kvm_arch_vm_post_create() after kvm_vm_elf_load(). Hypothetically, if there were a use case where kvm_vm_elf_load() is called multiple times, then stuffing the "Intel vs. "AMD" flag should only be done for the binary that actually defines that flag. The flag is defined by the library's processor.c, and so the hook should be tied to the library's loading of its binary, i.e. to the creation of the VM. If a test were loading multiple binaries, and the test wanted to tweak things specific to a binary after loading said binary, then the test can and should do that without needed a library arch hook. If the arch hook was to take action specific to loading _any_ binary, than yes, a hook in kvm_vm_elf_load() would be in order, but this hook is about taking action when creating a VM, not to loading a binary. But this is all very, very hypothetical. I can't think of a scenario where loading multiple binaries would be less complex than solving whatever hypothetical problem makes it difficult to link everything into a single binary. And if a test manually loads a binary _and_ wants to actually run the guest after doing vm_create_barebones() or ____vm_create(), then the test is doing it wrong, as those low level APIs are provided _only_ for cases where a test doesn't need to run vCPUs.