Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2456318rbb; Wed, 28 Feb 2024 02:19:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXE+08wOtIEe1wj18IAyqqIvfWTx1u9IO++Ldl6RpOIX+1r4rGzg58+4qTUTMuOh2QjpDSsLVGRkL2hXc1kFLjaw6JDc7QhgQOj9JbpVg== X-Google-Smtp-Source: AGHT+IGm9IytDSs/C+VvVfgUr6v3mc33USmWKphJzu8otttYy0hQpBILwn+73uy1F08KPaBDh4us X-Received: by 2002:a17:903:244e:b0:1dc:c45c:5d24 with SMTP id l14-20020a170903244e00b001dcc45c5d24mr3101688pls.4.1709115548021; Wed, 28 Feb 2024 02:19:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709115548; cv=pass; d=google.com; s=arc-20160816; b=CEPvkKs1QQQobfKeO1Yk6ri9Mb17rc7UoeFCJc2SLlo8OCurIaaNNeIKYRTzMXwO+6 lU5Bl++He+yCL5xLVjVWgkZIlNj1Tje6OblYbP/j/XHH1JFtgviREE/b2ragxD9wMo0j y07igwKT/FWpzPr1jAxmi4oBNZxpSb7Z/npBeW+kv8ixCRcz16gQsQZgYdkQwJW6LMG5 sErBysETUZxNimFuJHAVS/g5s2D3wGpfHE5bHJ/44TJy0mhD+eBrx9OhcaY+a0CAhwgJ 8VqRyFJ7gddMUNE/pxE+Ukn3OsQXTDZ0iwA4XKzs8z9DBLaIBFKU/vcreM757kG18V+v WCRg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Tru+vVOx4RxykInR0Cy5aul0KMpFDZJO5JqglFuDZAM=; fh=g5Cow6OuIakVpuXVBF5ZX8XYeT6H+v/9YFSb9jK60ps=; b=VCbVJJ2vXZDVhhNoKUoHmb/7NFhUCSqCAHlMIGFikj0TE5h4r5yzU77yM8sJE2V5PH Dk+xIx/qjBKWAtR/JvUWbCJOYSpDwcErrRbIOgmWnZNbRLTB9P2Ov6HUf4X4EJ7p//18 xOtNXVi1a5IVuuodEm51FZOZkH7p1uNGq2H9rhaHLn1FCknSCX9roPHUTUWvOMVE3UiP t+ND5T3G8q9bE4V3nECmbLCjnG5tecEG1U5RCrI8MKSSWxQeWXxSrQICzZOzC9UfHaIQ wh3e12zdoNHTFfc9AjzG43p0mWevqiWYOL3dd9nqm6okaWmEDGerkT8J4LafcvJkXTt0 JiAw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BwyB4Wvd; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-84823-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84823-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d4-20020a170902654400b001d8ead4fbfesi3016299pln.191.2024.02.28.02.19.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 02:19:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84823-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=@redhat.com header.s=mimecast20190719 header.b=BwyB4Wvd; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-84823-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84823-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 B67D2287D7E for ; Wed, 28 Feb 2024 10:19:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF9E750264; Wed, 28 Feb 2024 10:18:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BwyB4Wvd" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89A594879E for ; Wed, 28 Feb 2024 10:18:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709115527; cv=none; b=JwehL1CYvOKLXQI+x0U1FeZmhPlnqqqOZHGYNeatU6j/M7nKzlcBUp4GkUtF4EmD2dtRi2+LIbHMgqqXvaeeo+kpJl2Fr5YuoeiNiTDFx3OjZJ4y2opNBujznnHKOHz4iTFK1bM31aPXusLy2G7ic6wFOu+0/DIhVAjz88RDq4M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709115527; c=relaxed/simple; bh=9GX/XMY+qWHH5f0/ts7l5PYv9fa6tTvpHvjq3I6ksOA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xkca4uKfs6cRskPgj3innd+HkDLidZMSQ5tQSK48W2P8eG+vAsZtX45y+To8pKvKt5J0viQJUdJBo+5K41mkewRHADq4WUxnA8h+/iahNeyLXZvF1SG8ym9dxToQ5JdUt1xLPoN/+3ZrbZYv8bYokfxGxNOZrGu+mlGWxNhUTJU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BwyB4Wvd; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709115524; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tru+vVOx4RxykInR0Cy5aul0KMpFDZJO5JqglFuDZAM=; b=BwyB4WvdtdzfJ3fgcbGkhXeyaSMs2evtNnkaQSnqPhGdge2VYkbTH6fIx5oU/juyByT+HU OYPjpjt0lCt+2/V6hi5uR4XYMqa5ZnmjsP4aHUpAzptdpM9LzGawKu9YZfEUMrFgKnOvz1 fg+1cdFqgi3mv46kl2nSOJ+4rwBAxX0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-265-0bEoAZwaNEu0p7SajveeqA-1; Wed, 28 Feb 2024 05:18:40 -0500 X-MC-Unique: 0bEoAZwaNEu0p7SajveeqA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8A77F28AC1D3; Wed, 28 Feb 2024 10:18:40 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id 999AD8177; Wed, 28 Feb 2024 10:18:39 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson Cc: Li RongQing , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] KVM: x86: Introduce __kvm_get_hypervisor_cpuid() helper Date: Wed, 28 Feb 2024 11:18:35 +0100 Message-ID: <20240228101837.93642-2-vkuznets@redhat.com> In-Reply-To: <20240228101837.93642-1-vkuznets@redhat.com> References: <20240228101837.93642-1-vkuznets@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Similar to kvm_find_kvm_cpuid_features()/__kvm_find_kvm_cpuid_features(), introduce a helper to search for the specific hypervisor signature in any struct kvm_cpuid_entry2 array, not only in vcpu->arch.cpuid_entries. No functional change intended. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/cpuid.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index adba49afb5fe..0e1e3e5df6dd 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -189,15 +189,15 @@ static int kvm_cpuid_check_equal(struct kvm_vcpu *vcpu, struct kvm_cpuid_entry2 return 0; } -static struct kvm_hypervisor_cpuid kvm_get_hypervisor_cpuid(struct kvm_vcpu *vcpu, - const char *sig) +static struct kvm_hypervisor_cpuid __kvm_get_hypervisor_cpuid(struct kvm_cpuid_entry2 *entries, + int nent, const char *sig) { struct kvm_hypervisor_cpuid cpuid = {}; struct kvm_cpuid_entry2 *entry; u32 base; for_each_possible_hypervisor_cpuid_base(base) { - entry = kvm_find_cpuid_entry(vcpu, base); + entry = cpuid_entry2_find(entries, nent, base, KVM_CPUID_INDEX_NOT_SIGNIFICANT); if (entry) { u32 signature[3]; @@ -217,6 +217,13 @@ static struct kvm_hypervisor_cpuid kvm_get_hypervisor_cpuid(struct kvm_vcpu *vcp return cpuid; } +static struct kvm_hypervisor_cpuid kvm_get_hypervisor_cpuid(struct kvm_vcpu *vcpu, + const char *sig) +{ + return __kvm_get_hypervisor_cpuid(vcpu->arch.cpuid_entries, + vcpu->arch.cpuid_nent, sig); +} + static struct kvm_cpuid_entry2 *__kvm_find_kvm_cpuid_features(struct kvm_vcpu *vcpu, struct kvm_cpuid_entry2 *entries, int nent) { -- 2.43.0