Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp160772lqe; Fri, 5 Apr 2024 16:59:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXrM7JO+bOI4XSq63mN9J99v8uJPVcfyrbhmDrPx3cTkgPncdBbbI+OIuogdR1GjHVqtv9okwSPuBwmko3yUG3K7lBl8LDJOwyz1rNuSw== X-Google-Smtp-Source: AGHT+IEbTQ08lzvoHe0GvVZ+8rkk2UFosWfdlcUZ6IQgNcRX2xYLPbPU3UDNdi7aG3BQxyqONaqi X-Received: by 2002:a17:903:4283:b0:1e3:bfdb:d469 with SMTP id ju3-20020a170903428300b001e3bfdbd469mr2523539plb.64.1712361552215; Fri, 05 Apr 2024 16:59:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712361552; cv=pass; d=google.com; s=arc-20160816; b=MX6+Ib3poc7+N8U41AIFXOfaahX97YbEZVnpdwf0mijMYH+z9YFpOzKS4fPvTLMG4Y Qkn8jY9SPygFqBFG5DzsKsI2dr9AaUFYtpNWnin1nBAR1fpj2CeysnPXUNGd0IJJ8jq/ NoOlhEW/2sPJ5PdQdNKRUfl4rRybDS+G/TXVXuei/uShCv8+KvqAWFp6Mqm03uhX6ljy sqsM8ZMC2UGc/MmSTlGZbaYAbX2mi0JKUMEhSCzXJfwQGg/lA1CTfGT7Zk/I7sod0Glz YIZd1dx5BLY/7bydqckm3eRDJEwW/UrKjFNLXBgI85gqa7gmFfSz+6Ud6JISJVXYkbpD MU+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=GbwikEYWbQPXHEM5/lws4KQQn5EqaCgsUvoAMFf6UNk=; fh=ghPgz1BSB5+fprWAQa8W02pczLF+GA6nQxQpNNVoBTQ=; b=kPHGo05jID/RmqN4QY++WHmo1HAhpdBgUBLQ/3e+K1tyIpphzoxjTpwhhRvFCDa2vb shzgfc3SwKyB+Ypue4PPnsLjs/4DPOe4+23z3A5I+uCTpxXTkCGaAdsQMpn7kxEFKuXW Xp0YBmyORot65Coc+0dIgCbwsZkuPlsuFaf7G3KELQDI2kOo8FZM+KSNFA9wYb1cohE1 ptRg1tEjMl1cIWJVx1BLnu0j4oPOQ97oP6+fdgQGXLR38LMsrGGtmHTl3H5wDfZdWDsv ANJcUT1FjE8j2ZeQ3OV1t6MPkzn10e/ytrkS64MX/4LUXDrCmfl0S+csSnY6bar+41YQ gHrA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=T3s+Y8Sq; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-133719-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133719-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q18-20020a170902dad200b001dcd4f9fd0dsi2183787plx.455.2024.04.05.16.59.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 16:59:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133719-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=T3s+Y8Sq; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-133719-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133719-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E2E0E283397 for ; Fri, 5 Apr 2024 23:59:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2CB03A26E; Fri, 5 Apr 2024 23:56:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="T3s+Y8Sq" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A14A574BF5 for ; Fri, 5 Apr 2024 23:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712361389; cv=none; b=hyTUk28zoKO6cXGyPPFB6HEK6nA4hltdg9TU418VigXt6kj4biSflx+KKQGmRP0YA8FmJu4+Mpz1iguctgQDS1VHczVYr/gK0DRSStdnyiXIwCbaLUe+R+Q2umIIZ9rsD0ZhLJ4LZqLn9j6WfyZ9GaCzuPKpaWticnS96ORkJ1E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712361389; c=relaxed/simple; bh=5RDlYnCWS4ayQasdUGV2EFJf2g/5sa2I9izwXCuUezI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=dBAEDnGjAOTY0AMcHldM3r8bz4PbYF1yIOZj4XTanDdgDEoaUwTf2K6aWhYgta/PPJtNX5rrp8wlRdoqBSKX5FwB6THDnXIew+8NfJ8I8wBI+TmeqyDE13wCggTI+aDt7c7xl6ctwG4dGxig9HvNQ5osluaLa4VIyBdGv7ypbyM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=T3s+Y8Sq; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-615110c3472so48681627b3.3 for ; Fri, 05 Apr 2024 16:56:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712361386; x=1712966186; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=GbwikEYWbQPXHEM5/lws4KQQn5EqaCgsUvoAMFf6UNk=; b=T3s+Y8SqupuAdHuqAourmoM0WiRcDm/9RvAI+UhLOgJaCvTEX38tD20PUzelLg9CCM Evf9MLKH+Ccd3gqgomBYmBjuGNzvV+Q3p3CzNNG31V8eR4lLo9QC1KaNdA8qf5Iu6ZG5 VGRuxMiNrr/+CBYYCeCjL86cVLdu8T+a6YH7I0HGlfXFOAuiN3l+SpjsdEUsUm8jICqP OHGNDG1M9bVqmTJXA++UM2afd3wAF3ayrmHVmiANJh5DLCGsLKROencvAGLd56Tugp+q +2s/ROuQNzHkmqVeiPHGIEYX3MKQsR+6yCOPSi37czkRMXvmKbcFdE0HL+tGWM6vFmdt djWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712361386; x=1712966186; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GbwikEYWbQPXHEM5/lws4KQQn5EqaCgsUvoAMFf6UNk=; b=h6i+gMPwcTyWMk34Lyi5uguc9pEcCBT3OlUobOTwDv9yJ/gqrPgkblqI3PQjhrbHjH A8H1nBn1omMfmyuPo/WrbXf8wkcnujAN5yJZVofLTs8CE4vckIi9jRyL3ZpLtQuvTNOZ yJNBGM+2aedPIKemFW7Pba3VvAXLiezuvNVlTp+wkS9+JINJHxLp/2ahjVArU1qR9uQt TOElCVVjjdg/qoW2wCh/adNNinA3EuHH2DxzskL0xkUyY03dW1xK2n7RJdRzC8QZEoeE lbfuuTQztXaBKEfRG69kM2gRPS353bolbAir125ZkoVs9nRN9JVauvzv/nhs3BOfvHFG b/QQ== X-Forwarded-Encrypted: i=1; AJvYcCWMhsdrt9LFe6YcG3TFjQx51GQ+/6di/qauaeaFnIzmiWHSHSNnGEWBPy3eFfKf7iH03Sx2mQvfp3zfuqptgt/BpiQsV4U6J1+SzKRG X-Gm-Message-State: AOJu0YzlcIYgcCWtrvnXkk9Iq4iZpR+Phx79MOpGIAq6iupZr2Vcaoal 3y5yM2IN8mCGSsMO/7l3ueA6bJJVoDR+bQ6qPQyZMbahUzk3JnfKdTdncr91RMKG/3puw0yEqol OPQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:690c:d0c:b0:617:cbcf:8233 with SMTP id cn12-20020a05690c0d0c00b00617cbcf8233mr712182ywb.2.1712361386753; Fri, 05 Apr 2024 16:56:26 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 5 Apr 2024 16:56:03 -0700 In-Reply-To: <20240405235603.1173076-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240405235603.1173076-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240405235603.1173076-11-seanjc@google.com> Subject: [PATCH 10/10] KVM: x86: Bury guest_cpuid_is_amd_or_hygon() in cpuid.c From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sandipan Das , Jim Mattson , Like Xu Content-Type: text/plain; charset="UTF-8" Move guest_cpuid_is_amd_or_hygon() into cpuid.c now that, except for one Intel quirk in the emulator, KVM checks for AMD vs. Intel *compatible* vCPUs, not exact vendors, i.e. now that there should not be any reason for KVM at-large to care about the exact vendor. Opportunistically refactor the guts of the helper to use "entry" instead of "best", and short circuit the !entry path to make the common case more readable. Signed-off-by: Sean Christopherson --- arch/x86/kvm/cpuid.c | 12 ++++++++++++ arch/x86/kvm/cpuid.h | 10 ---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 77352a4abd87..c5fb39930213 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -335,6 +335,18 @@ static bool kvm_cpuid_has_hyperv(struct kvm_cpuid_entry2 *entries, int nent) #endif } +static bool guest_cpuid_is_amd_or_hygon(struct kvm_vcpu *vcpu) +{ + struct kvm_cpuid_entry2 *entry; + + entry = kvm_find_cpuid_entry(vcpu, 0); + if (!entry) + return false; + + return is_guest_vendor_amd(entry->ebx, entry->ecx, entry->edx) || + is_guest_vendor_hygon(entry->ebx, entry->ecx, entry->edx); +} + static void kvm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu) { struct kvm_lapic *apic = vcpu->arch.apic; diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h index 03d015e9ce33..41697cca354e 100644 --- a/arch/x86/kvm/cpuid.h +++ b/arch/x86/kvm/cpuid.h @@ -102,16 +102,6 @@ static __always_inline void guest_cpuid_clear(struct kvm_vcpu *vcpu, *reg &= ~__feature_bit(x86_feature); } -static inline bool guest_cpuid_is_amd_or_hygon(struct kvm_vcpu *vcpu) -{ - struct kvm_cpuid_entry2 *best; - - best = kvm_find_cpuid_entry(vcpu, 0); - return best && - (is_guest_vendor_amd(best->ebx, best->ecx, best->edx) || - is_guest_vendor_hygon(best->ebx, best->ecx, best->edx)); -} - static inline bool guest_cpuid_is_amd_compatible(struct kvm_vcpu *vcpu) { return vcpu->arch.is_amd_compatible; -- 2.44.0.478.gd926399ef9-goog