Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp60957pxy; Wed, 21 Apr 2021 18:31:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyD6IgAbd6d1NYtemtX2uYjOkvEJD2eNVJHOwkDSZsUkHi3ZiMqq5APbBJraAoI66G1FTS+ X-Received: by 2002:a17:902:d306:b029:ea:bb6c:3c99 with SMTP id b6-20020a170902d306b02900eabb6c3c99mr853661plc.9.1619055109830; Wed, 21 Apr 2021 18:31:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619055109; cv=none; d=google.com; s=arc-20160816; b=Sm+eRd8DlRxPkPJnZ0qUh1KiklYTXKCtnPToGwPc6lKY8XAqBVIbhILUDWXqh4bG84 4V3NKS5n4NxoOeGFjvZeb4vgCacgQXJaKs5OXa5LR9qJmw4u6upjsXaAXvLPIrEXxHbZ pae3ZBDColSQi6Spauws6IPNuffftCBLn68TH3qPKfl9HJ51/kaQAlKS62OaDcc7uWGC DcM2PrtgmNhzXA3G0uofCy1DBbD8HsgkpSvkTFoSlyeMDD0lAUNup28vsjqasQMOLH0g FBJ4hJt1D8UgpFICBboHHio7TwaYCQHn7pA94UbTkBN39+B76gFdDbWGU10bdW4TDVfB J/cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=NzxbZ+GAahgmxduXaRkOwY3LO03b4qVXF2kZFZVIV+M=; b=L8WPW2UQcmcupqI57aMwN8wo7dgHUD67shZhNSVnTvMMJkBWh0CPudlMJEwv2ESxkH 6/zxpfrJ7Q+DgqqtBbLk4WzClt7Z2v5AbUAtLWmuzq807FuR856EIEhX8Fllym4ykY0P 8759VqSzoHRNNitF0MWt5VMU5dfXKjdZTTSrj3fLgvfkMghFDdaKQKyEvIoRVwyY1qFI sBGECMDu1V6OKx5Bonvm8gwDOq8ahFRdiGBxeMDF26bKwDfdbhs+JyXpJfWBYPgD1h1I OD7EhYItbf4cSmtIWI0KaHNclt00M0b3n+IwohPagZN5g9nOgSCCjnFZ7G+gcKlHipQY SJEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="EY/Bkrwt"; 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 f14si1328551plr.128.2021.04.21.18.31.37; Wed, 21 Apr 2021 18:31:49 -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="EY/Bkrwt"; 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 S241825AbhDVA5L (ORCPT + 99 others); Wed, 21 Apr 2021 20:57:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240786AbhDVA5L (ORCPT ); Wed, 21 Apr 2021 20:57:11 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18077C06174A for ; Wed, 21 Apr 2021 17:56:37 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id p133-20020a37428b0000b02902de31dd8da3so10893044qka.1 for ; Wed, 21 Apr 2021 17:56:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=NzxbZ+GAahgmxduXaRkOwY3LO03b4qVXF2kZFZVIV+M=; b=EY/Bkrwt7EOV0vOcFdHrNNLfJEudSb/z5dFRNAUDXJY6GzahV2RUbyBuxe43j5Ba/c 37spJaQTJBA0XFya0TgE4ej7IfVEGU101kUiAdOEvipDBhjCIMth9aD+rTPMJIdwPaPg hcn7HCpOfL+gSOCUrgHTnzfsgYufCUfBlSF79muCJ7O3urR5Xr191bTTgniB/VglLH3B 7qRpKMq8OMdWCjkovJKPox5LSfC4Y5RaQeKkigl3WkCVqvCdBVXtbk9dquRZ4wkt7QI+ ZhKMowSwhzz2u/Ubd4zQWQK5WtVPcIQ9RxH4LaNWB/NCG6JRXIfsAmTifEaDku7qKosz RVIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=NzxbZ+GAahgmxduXaRkOwY3LO03b4qVXF2kZFZVIV+M=; b=AnGR7YEqmAyg+yh8mNbYAkwKkZaKjUNVhfWwc4xF49LvMYgTmAUsv7A7ZHVtdOz2hQ 4H2QbEHakl8fcLQk97k0zhv7AM9it7HwcdO0wRCtB7SgrjWiQXL3fVm2zOaWKfiO9wMz mnX2yjupPGTdE1tggbzonP68waqM8N+G8PnbzfOYdgrWw49FI/i07+rwwcmIajSCCjr8 15shFeEcFtmF/uNzUiFUYdXGzdAilc+/lg6Lljdfoty+WnZXUTlsJ6L0gAwZbgwPlR/E hL5xk1D6BKFAX5kyCpaUKUV9s82Eq3YeaH4ZmoKbzJwnxB0wH82DcbazI76SuNvjpslA MbyA== X-Gm-Message-State: AOAM5315YnueNkRAFJmpIAN+KjLDLi8A+7prF0AcQC7xKLinTOjHS889 0lpSZsnICngDNMjJykUwA8qy7Wnl7B+IDA== X-Received: from ricarkol2.c.googlers.com ([fda3:e722:ac3:10:24:72f4:c0a8:62fe]) (user=ricarkol job=sendgmr) by 2002:a0c:9ad7:: with SMTP id k23mr702884qvf.24.1619052996218; Wed, 21 Apr 2021 17:56:36 -0700 (PDT) Date: Wed, 21 Apr 2021 17:56:21 -0700 Message-Id: <20210422005626.564163-1-ricarkol@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog Subject: [PATCH 0/5] KVM: x86: Use kernel x86 cpuid utilities in KVM selftests From: Ricardo Koller To: Paolo Bonzini Cc: 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 , Jim Mattson , Joerg Roedel , Nathan Chancellor , Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Ricardo Koller Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks, Ricardo Ricardo Koller (5): KVM: x86: Move reverse CPUID helpers to separate header file x86/cpu: Expose CPUID regs, leaf and index definitions to tools tools headers x86: Copy cpuid helpers from the kernel KVM: selftests: Introduce utilities for checking x86 features KVM: selftests: Use kernel x86 cpuid features format arch/x86/events/intel/pt.c | 1 + arch/x86/include/asm/cpufeature.h | 23 +- arch/x86/include/asm/processor.h | 11 - arch/x86/kernel/cpu/scattered.c | 2 +- arch/x86/kernel/cpuid.c | 2 +- arch/x86/kvm/cpuid.h | 177 +----------- arch/x86/kvm/reverse_cpuid.h | 185 +++++++++++++ tools/arch/x86/include/asm/cpufeature.h | 257 ++++++++++++++++++ tools/arch/x86/include/asm/cpufeatures.h | 3 + .../selftests/kvm/include/x86_64/cpuid.h | 61 +++++ .../selftests/kvm/include/x86_64/processor.h | 16 -- .../kvm/include/x86_64/reverse_cpuid.h | 185 +++++++++++++ .../selftests/kvm/include/x86_64/svm_util.h | 11 +- tools/testing/selftests/kvm/lib/x86_64/svm.c | 6 +- tools/testing/selftests/kvm/lib/x86_64/vmx.c | 5 +- tools/testing/selftests/kvm/steal_time.c | 5 +- .../kvm/x86_64/cr4_cpuid_sync_test.c | 23 +- .../selftests/kvm/x86_64/set_sregs_test.c | 25 +- .../selftests/kvm/x86_64/vmx_pmu_msrs_test.c | 8 +- .../kvm/x86_64/vmx_set_nested_state_test.c | 5 +- .../selftests/kvm/x86_64/xss_msr_test.c | 10 +- 21 files changed, 749 insertions(+), 272 deletions(-) create mode 100644 arch/x86/kvm/reverse_cpuid.h create mode 100644 tools/arch/x86/include/asm/cpufeature.h create mode 100644 tools/testing/selftests/kvm/include/x86_64/cpuid.h create mode 100644 tools/testing/selftests/kvm/include/x86_64/reverse_cpuid.h -- 2.31.1.368.gbe11c130af-goog