Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp222362rwb; Mon, 26 Sep 2022 17:41:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WBWUEuN/w8sMtmernS7RNO4HIyYAqMrvo3ApsY0an5ALuj32p9fhwIKZ0RVZ0wAzfS7sM X-Received: by 2002:a17:907:1629:b0:782:9b8a:c8b9 with SMTP id hb41-20020a170907162900b007829b8ac8b9mr17135042ejc.673.1664239280287; Mon, 26 Sep 2022 17:41:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664239280; cv=none; d=google.com; s=arc-20160816; b=obZHJwldX7BgYU/0TSQxw6oQDRhwot3zGwEa+/IGhhSjnjrME1deCXhZc/Tw8gyEgV nRO/tBokBaNdSM/soWBuIhn9q8XPpPKNZDx9HCrc3PNvh0a7uRjXWt7oisUxZqwpeX5R 5uagj7z6eEe6YTmVS5zY59DIVT86YKc5c7owywiquIaB6M0Bp78N5nNmddIGWfRTb2PE NrHFB0K2vlOngLBdgS+0iWpZr8LJGIioDGTfVT8pCnqKHY/hthp29Wf3dspt03ZKn37y bE87RJCXJolKzQT/jO3qkXuCpqTld1v2OdnipYy5hUIx/7d0+u9bfWrzqMvgD2oZPuT7 GO0A== 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=HwKLS+p+kzaLysWHkGSka85DTvLRdK+675PcR0q9v3w=; b=x3HQbc8e6mtxXe4WAoT/4fQzl6g8JkeVkOeNWIfT7ykDXLGZk/KoHTMxVWUnMKOkq5 fsmVU/A5lVR88s1EAGBaacp8QNRee8Es6Cj7Y/fTtHm66eMtbLhgKhktCT7WUpttPWSp sjndJFLZvbUxKHsxNssf0MbFmVCX9W0hXfX0L1G+MiK3lxpRtpwcyRSAbrsA0j07uWds zCxP04YerJJAKjGsr9IcybxxWQx0JKf6U7uHb5kNsPFpP4NcOXve1Pi69JPhDfXhttqz 5CyHdBvHTHZxyUz/7ZnB1CWy+p7JmN0ZUbN3Awsz8uW4QMO0P9HKKh885/N5nOKugJF0 tPLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=pm0ElfRJ; 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 l9-20020a170906644900b00783b41d746bsi1188465ejn.123.2022.09.26.17.40.53; Mon, 26 Sep 2022 17:41:20 -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=pm0ElfRJ; 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 S230307AbiIZXyM (ORCPT + 99 others); Mon, 26 Sep 2022 19:54:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230051AbiIZXyG (ORCPT ); Mon, 26 Sep 2022 19:54:06 -0400 Received: from mail-yb1-xb2d.google.com (mail-yb1-xb2d.google.com [IPv6:2607:f8b0:4864:20::b2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A321F96FD6 for ; Mon, 26 Sep 2022 16:54:05 -0700 (PDT) Received: by mail-yb1-xb2d.google.com with SMTP id e81so10307966ybb.13 for ; Mon, 26 Sep 2022 16:54:05 -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=HwKLS+p+kzaLysWHkGSka85DTvLRdK+675PcR0q9v3w=; b=pm0ElfRJfwGKSuhNjHi2Hrm6ChvnLcu8n9EQR2swES7EBtcz6U72fX3JbsrJXY9g6Y eqNib96zQ9YIvlGADNXevxAeyvbZ7zZncUvNb5gHxAmFwpC4+UK3a5/WkWNJ+SzZ4947 FuQ4zyIG8xJ7t3NkEWR3gI6EygLJVRCKL4NonduFnmLPEu66SSPcwShT2tMmhOV24CJp etvD8mJ7Lh8NZbOhd/w7VUECgt46pLy7mLS2h+TXGHGgftLAyWrv50Gwc80LCwhV0byJ cDCbcJHqr+aFEyRfOMQA9xCYVaTXoCSXL2zwfJ0usep3SFk+IvKeStX9PaeEKRSp7s7G 2jxg== 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=HwKLS+p+kzaLysWHkGSka85DTvLRdK+675PcR0q9v3w=; b=sJH1kxQPkIkxMiWSCvxDnaYVfAcJEuAnQAx4T5wlf46ya99cpS9m/paGFI5Zwt6u0W HioMnPGWETA4u3R1vl9yKFzViY5gn9OPpwX9Aily3pyqKnifnGhfuZ7exZdPKOrs8kGV sJpzwMSzxOtvi0bry9DTKX7caj1VnkwypolkBz3tzN23GBZDApwh+QGnARUTqGDE3wfC GPmcxPSMZ+YIz1AMa4+37P85xXz3VzvBoa018jid4ljRryRY+iqxCV3uPmxlpUNpd2/f 7mGHTnB5n7KsFHzcaWPBcTW1HWZTulWeKss8I3rLqdsGaFVue80M8E6735VkU9xGUn9D IyHA== X-Gm-Message-State: ACrzQf2X/TocvdVbEIniXhiRojU6lAvVvrlaMdFJIpI6Oc4/bFotJZWP sn2kdq3pbQ/1LfjlogfwG+5GOahipeBet8fr9oe8LA== X-Received: by 2002:a25:4fc2:0:b0:680:f309:48e5 with SMTP id d185-20020a254fc2000000b00680f30948e5mr24258349ybb.0.1664236444719; Mon, 26 Sep 2022 16:54:04 -0700 (PDT) MIME-Version: 1.0 References: <20220915000448.1674802-1-vannapurve@google.com> <20220915000448.1674802-5-vannapurve@google.com> In-Reply-To: From: David Matlack Date: Mon, 26 Sep 2022 16:53:38 -0700 Message-ID: Subject: Re: [V2 PATCH 4/8] KVM: selftests: x86: Precompute the result for is_{intel,amd}_cpu() To: Vishal Annapurve Cc: x86 , kvm list , LKML , Linuxkselftest , Paolo Bonzini , shuah , Ben Gardon , Sean Christopherson , Oliver Upton , Peter Xu , Vitaly Kuznetsov 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, 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 Mon, Sep 26, 2022 at 4:48 PM Vishal Annapurve wrote: > > On Wed, Sep 21, 2022 at 2:39 PM David Matlack wrote: > > > > On Thu, Sep 15, 2022 at 12:04:44AM +0000, Vishal Annapurve wrote: > > > Cache the vendor CPU type in a global variable so that multiple calls > > > to is_intel_cpu() do not need to re-execute CPUID. > > > > > > Add cpu vendor check in kvm_hypercall() so that it executes correct > > > vmcall/vmmcall instruction when running on Intel/AMD hosts. This avoids > > > exit to KVM which anyway tries to patch the instruction according to > > > the cpu type. > > > > Out of curiousity, why do we want to avoid this exit? > > Referring to the patch set posted for UPM selftests with > non-confidential VMs [1], vmcall patching will not work for selftests > executed with UPM feature enabled since guest memory can not be > modified by KVM. So I tried to add a kvm_hypercall implementation that > will execute the hypercall according to the cpu type. > > Hypercall updates in this series are done to ensure that such a change > is done for all callers to allow consistency and avoid relying on KVM > behavior to patch the vmmcall/vmcall instruction. > > [1] https://lore.kernel.org/lkml/20220819174659.2427983-5-vannapurve@google.com/ Thanks! That makes a ton of sense. Please include that in the cover letter and any of the commit messages that avoid hypercall patching. That will help reviewers understand the context of why the changes are being made, and help anyone reviewing the git history in the future understand the same.