Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp8314114rwn; Wed, 14 Sep 2022 12:18:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ZJjc8zByZszwoJLvRs5R0kyhwV9d6TJWi3CNthwHXApCEs3Qvbcq6qJHs0E6ekRGcBQun X-Received: by 2002:a17:90b:3c6:b0:202:c01b:feb4 with SMTP id go6-20020a17090b03c600b00202c01bfeb4mr6672070pjb.28.1663183134250; Wed, 14 Sep 2022 12:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663183134; cv=none; d=google.com; s=arc-20160816; b=Svqqrrbcl+NwgwgsK0OQ9PQOgAWxc+GsvAM+IpNlFbifIwdZtpupxl9V8PPmpNVuNY GbMgfYo/OsU/78C0YEYCbfxSqtA1dA3Ip9CXw4TOKQJqNcZMAKJPx6o5B01fh55MbP/J 93DAZrGYVMrFjPee2KHdfli6whdmQKvRh9wlAaw2sD+HTE53FR5X44rofPEEnXkkKW6R n0CIiHRt5OItR84OsP2wM4mSfr77nE4T1GkRkgyx0ZSt3SGnemE2pfpxACNbv8Q6J8Zs 0T+stRtz2TpYPLGMC/s3hBlBF5BX6ZUc9MeCl5hQX3vnT8O+ZVuESA0RhPYIcNz5m+CA 3iPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=jQp1+Ka6WRFxpjSfTMZnhetzciGUJa6yU4O7NscoajA=; b=N9+NuF8R1jomrxl9vfo5JbwnEvnEaVeImo2ZzSlyWzSnjh1oelHov0mXx+T9JOIZDX wfPftI2eFRQu7Cocx7CxC0Ic4u4n7FT0hSXd7FAblCgariwco5dCeAKHil5BLHr40qRy HCBEYPAjXx9i9S460uWjcDVA7yhEtCJWmFQe5MPsGZx2z9JyyJvYdbnIdH8owqMX+aGa EPx+uLaqFLYGwKSqbDqTpjFCzn3egVe6C2E1oG0+JBms4shSL9cAD8UHcMcKNjVEeLTF ErcAf744VFW7X/Y6qqMZwq5PC3YL/e1784xGRSD5XJ2kMs6qhUX5tq72XF1FhDdGFNJW MPgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=IeN0Cl+m; 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 g32-20020a635220000000b0043486074814si15723652pgb.661.2022.09.14.12.18.42; Wed, 14 Sep 2022 12:18:54 -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=IeN0Cl+m; 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 S229608AbiINTMc (ORCPT + 99 others); Wed, 14 Sep 2022 15:12:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbiINTM3 (ORCPT ); Wed, 14 Sep 2022 15:12:29 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3291782770 for ; Wed, 14 Sep 2022 12:12:28 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id o70-20020a17090a0a4c00b00202f898fa86so5913064pjo.2 for ; Wed, 14 Sep 2022 12:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=jQp1+Ka6WRFxpjSfTMZnhetzciGUJa6yU4O7NscoajA=; b=IeN0Cl+mtGiGg7nrtyNfnplaI4CYtE6C8gQqNLIiK2oJypSmlW93xSxiISSQU4d2MF MZ0F9ce+eGGyfWONcZEQ85D7ZRb0Hj9ZUPAvnhzyXj7Kmj/cNJlRXAtLp3Nbh1/OAfE3 5/VC7tFS32WVWK8E/wGcLAxti3h9HmfRl0a3NLgJOyNVq75XSy9pL8U95YHS5CaPdaNz Hlc71gyQT2zomO/d6mQQ3km5/Ce2Z/C0JDwE2L6ty1vw97w+T9yu3Ukw79ErOq4VCNJz y7HaRofdUWUDnZwe3qz80Tr7xF2O2c05miWK1B7EkB9TbkD+aeFZt8S2cJOos2EEni8y xkIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=jQp1+Ka6WRFxpjSfTMZnhetzciGUJa6yU4O7NscoajA=; b=kfdXQNxEIMmmKSpsXX7xvOGzyDUVQN2XXCmkqHlgkMkjbe5S9Rvj+FZxVd3URcorq5 B4liz/kdAbqotkx5W3wlaS0HpbGsLekkFxl/hAn4aLKRtqaMHWI+LTYMPBpZXmGSEOzG 9E2JlrXIo1whlzzqS5F3BMamNO+N+/BR/ysUhlw0TrTNZ6XfhVz+y7fSPGjrqg8kll4B BcaGN9Tid99WNU+nreBaJnYMXOJyswf0y4xmnXGr3BNiqemr/QU+ZgQkX6yhbw2Stgoc Ldh8fZMvdVtXoKKrKSPNJs6NkpYtM9GA/TxqP2Yk4FtTcUGB4LAHuxdW1wK3iLWK1vdH 3VWQ== X-Gm-Message-State: ACrzQf3qDk7EsflIZvO10EZnVqFZ43hdD+701QjO0uhZrM6YiTbHIfYx Qc4BCQswysMr62eYImXR3H/qpmPsr0hup4ZeaFDHXA== X-Received: by 2002:a17:902:e74f:b0:178:3af4:fb13 with SMTP id p15-20020a170902e74f00b001783af4fb13mr449762plf.19.1663182747200; Wed, 14 Sep 2022 12:12:27 -0700 (PDT) MIME-Version: 1.0 References: <20220903012849.938069-1-vannapurve@google.com> <20220903012849.938069-4-vannapurve@google.com> In-Reply-To: From: Vishal Annapurve Date: Wed, 14 Sep 2022 12:12:16 -0700 Message-ID: Subject: Re: [V1 PATCH 3/5] selftests: kvm: x86: Execute vmcall/vmmcall according to CPU type To: David Matlack Cc: x86 , kvm list , LKML , linux-kselftest@vger.kernel.org, Paolo Bonzini , shuah , Ben Gardon , Sean Christopherson , Oliver Upton , peterx@redhat.com, Vitaly Kuznetsov , drjones@redhat.com Content-Type: text/plain; charset="UTF-8" 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, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 8, 2022 at 3:54 PM David Matlack wrote: > > Please use "KVM: selftest: ..." for the shortlog. > Ack. > On Sat, Sep 03, 2022 at 01:28:47AM +0000, Vishal Annapurve wrote: > > Modify following APIs for x86 implementation: > > 1) kvm_arch_main : Query the cpu vendor and cache the value in advance. > > 2) kvm_arch_post_vm_load: Populate cpu type in the guest memory so that > > guest doesn't need to execute cpuid instruction again. > > This commit message only describes a subset of the changes in this > commit, and does not provide any context on why the changes are being > made (other than a clue about avoiding CPUID). > > I also think this could be split up into 2 separate commits. > Ack, will add more details to the commit log. Though since is_amd_cpu/is_intel_cpu is used by both selftest VMM and selftest guest logic, I would prefer to not split this change into two. For now, I will upload the series with this change being a single patch. We can discuss again if this split is really needed. Regards, Vishal > I would suggest first patch changes is_{intel,amd}_cpu() to return a cached > result. e.g. > > KVM: selftests: Precompute the result for is_{intel,amd}_cpu() > > Cache the vendor CPU type in a global variable so that multiple calls > to is_intel_cpu() do not need to re-execute CPUID. This will be useful > in a follow-up commit to check if running on AMD or Intel from within > a selftest guest where executing CPUID requires a VM-exit. > > Then add support for AMD to kvm_hypercall(): > > KVM: selftests: Add AMD support to kvm_hypercall() > > Add support for AMD hypercalls to kvm_hypercall() so that it can be > used in selftests running on Intel or AMD hosts. This will be used in > a follow up commit to ... > > As part of this change, sync the global variable is_cpu_amd into the > guest so the guest can determine which hypercall instruction to use > without needing to re-execute CPUID for every hypercall. >