Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4644029pxv; Tue, 29 Jun 2021 11:56:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/JmfYmBlpj2FW8KvzRjREnBb4CMnpg2PI0o/J70FQu4hKyrCV39FUEIJRKlqBpaAhyPuO X-Received: by 2002:a02:b11b:: with SMTP id r27mr5515000jah.99.1624992969348; Tue, 29 Jun 2021 11:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624992969; cv=none; d=google.com; s=arc-20160816; b=dYH9AWzBdmqIoxNIY6KkvHLf2D4AEvHUgItGhWLg9XdWgMegzXWekFVrta9dkSjUbs e5bUHrquj4Y8KwW3m1SyfNz0Nu0riNJEpqughHW01xraSyNIFajiOt5oY8wUJHOeIl9H amT4x31YMrGL++198w3AYGqZ73Qw39zLNLZkrkc0wQ6PglJerHPwgd5EXlEYsLKKuQJU I2AaZfdO0M/20Zxf4sjQcp/GlFmivphbyfZBniEQesxX4Q0UA7V00rFdpIIi5g0JmXm/ cHZYjvL+l/a0LvW9koqjp9FjJwIe0c+0qyDhNc3j4++3VDcj4rN/ksRiZxh83+BxqFne 4s1g== 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=nM0hxmvD70FyKTgRduBIM3ouSrzzqdB4hs0/OpkgBsM=; b=lcZwUiwWIeoOOIQGxGOCcYAnS+MEBEn9sfCqweYvi8ygUbxRZIMtUH9Zkpgy41T69Y vgLWXjlX6gQXs3uyLwYJazr2c8PtWyYgYVCF3/w3iFbRwH2AAueAfuO94oSb6HaNlTkn Xz7PLk6TTO9Xw5+bMnKa794CyAcivaE9Mfeq1S9MsItaSxv85/kUp74Atrg7uhLb1RnF R2UJjHIsLtugDuPa5YgOy866PQV+qbKq1RzrkLDyxaPILGYac2wuLSpxCZuBr+sGJD3z SFhstmsCHXMMg/o4Gbiq4wYZj2LZg8YwlNFAK8I9AuTR7P1o2vjcLrFfQ+YnTvL5dCkl kyBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WRvcY0hG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x15si16610111ila.57.2021.06.29.11.55.56; Tue, 29 Jun 2021 11:56:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WRvcY0hG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S234533AbhF2Rb3 (ORCPT + 99 others); Tue, 29 Jun 2021 13:31:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234509AbhF2Rb2 (ORCPT ); Tue, 29 Jun 2021 13:31:28 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77310C061766 for ; Tue, 29 Jun 2021 10:29:01 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id w127so27107055oig.12 for ; Tue, 29 Jun 2021 10:29:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nM0hxmvD70FyKTgRduBIM3ouSrzzqdB4hs0/OpkgBsM=; b=WRvcY0hGq5EzTuFheWXArZXKb1H3YPtTvOuMjF+g9gikn8MhrvYxF+9pOrVv3ToiR/ d/Y0dbrG3zaaRmWhirtjEZAeIIsNInpIXg9qfyBlUyyOxOU4qy4nb/PoGBCdWC4/6Mxz fkatD/7SPH4QOGsOuyaqeQwsUKW3ZWsxmBFWuMoDRR3pm8uQO+o62FE6MYX8LufBKS+j Iq2uTq/j1gUqvECgSDJc0fdHM3PDOJi+NvKQjSij7hBA+rS/CxzUxpz5uR9oDciiuQlH 9EjH2DF/+aJ8QWxCEvz0GwxjO7Jm3Ou5m1/wCbadTO9H7gCB1pw1dZ0PobvQOoS7Bpq4 dW/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nM0hxmvD70FyKTgRduBIM3ouSrzzqdB4hs0/OpkgBsM=; b=t6GDg0BQs23za/m03ijUibgwlAgvEfd6qo3JpavTXKYkkYBIZ+DGktERQoDtO8z3c8 qMOB70iiG1EQ8JqcsRTgs14Q26aSj7TghJKDXY06iazgm1BqmVqK3jNch497/lBTGelZ dR0UZpke0PEU1FEkrDEA9imeNYIC2w5mB7eqyi8gGD+pHXcyi8qsThwxQeTpJFY1LjeS i5jXPSN+ChSWKAW3cXq6Q261/uj9nvdhExoCabONH24Nh306Q/LBrbr6Q+BDtV2i8dU2 8BfKKz/rUTAfouwVDEkO61nLy9IQr7vreWgAGajwlGuRX8FxTTwgw1TW+xX4OlloZqdV mQbA== X-Gm-Message-State: AOAM53077CrNspOaBwyejmIa7JWK91Ta0inJ+JHdw93u/Q2Yriv+F4V6 H8YhsE8Wcfclzn2AySRG75w1xlAe/KAK0zzTCFJGbg== X-Received: by 2002:aca:1e07:: with SMTP id m7mr21785451oic.28.1624987740542; Tue, 29 Jun 2021 10:29:00 -0700 (PDT) MIME-Version: 1.0 References: <20210422005626.564163-1-ricarkol@google.com> In-Reply-To: From: Jim Mattson Date: Tue, 29 Jun 2021 10:28:46 -0700 Message-ID: Subject: Re: [PATCH 0/5] KVM: x86: Use kernel x86 cpuid utilities in KVM selftests To: Ricardo Koller Cc: Paolo Bonzini , kvm@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , "H. Peter Anvin" , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , Nathan Chancellor , Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 28, 2021 at 12:46 PM Ricardo Koller wrote: > > On Thu, Apr 22, 2021 at 09:02:09AM +0200, Paolo Bonzini wrote: > > On 22/04/21 02:56, Ricardo Koller wrote: > > > The kernel has a set of utilities and definitions to deal with x86 cpu > > > features. The x86 KVM selftests don't use them, and instead have > > > evolved to use differing and ad-hoc methods for checking features. The > > > advantage of the kernel feature definitions is that they use a format > > > that embeds the info needed to extract them from cpuid (function, index, > > > and register to use). > > > > > > The first 3 patches massage the related cpuid header files in the kernel > > > side, then copy them into tools/ so they can be included by selftests. > > > The last 2 patches replace the tests checking for cpu features to use > > > the definitions and utilities introduced from the kernel. > > > > I queued the first, but I am not sure about the rest. > > > > An alternative is to copy over the code from kvm-unit-tests which encodes > > the leaf/subleaf/register/bit values into the X86_FEATURE_* value. Sharing > > code with kvm-unit-tests is probably simpler than adding #ifdef __KERNEL__ > > and keeping the headers in sync. > > > > Paolo > > > > Thanks. I was thinking about kvm-unit-tests, but the issue is that it > would also be a copy. And just like with kernel headers, it would be > ideal to keep them in-sync. The advantage of the kernel headers is that > it's much easier to check and fix diffs with them. On the other hand, as > you say, there would not be any #ifdef stuff with kvm=unit-tests. Please > let me know what you think. I think the kvm-unit-tests implementation is superior to the kernel implementation, but that's probably because I suggested it. Still, I think there's an argument to be made that selftests, unlike kvm-unit-tests, are part of the kernel distribution and should be consistent with the kernel where possible. Paolo?