From nobody Tue Sep 16 21:49:15 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5CBCC4332F for ; Wed, 28 Dec 2022 19:25:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233438AbiL1TZE (ORCPT ); Wed, 28 Dec 2022 14:25:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233285AbiL1TY6 (ORCPT ); Wed, 28 Dec 2022 14:24:58 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B05D1838A for ; Wed, 28 Dec 2022 11:24:52 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id e6-20020aa78c46000000b005772151d489so8656618pfd.15 for ; Wed, 28 Dec 2022 11:24:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eezWDwyqk949sEAV6VBZXvmE65PTPfqNCFhhSoX++44=; b=VQLWwAsnp8xEr114AAmlLuYwOEaQZ3kuhyeF6c365GeAlZ4EMzS8MiWB11jz/EMUgm khDN6r175XUEyW7m/oNk3OZkdkPyvwGwmsgCd4NMjRYpSLjTAYPrx72KQCfsNXcbQRLr 0EkXan3XgXT5CLnAlpsw0Vmj/h7JMY+8peywoXVo1O9CJLLG6GhpKfyUTh1zNLRd6zLY FEq1Y+kNPCkX43rdGocrQGj5MgGl4RnJaqHBexdt3XuZeOQtdNgiFzgO99+DYRM3JFBZ 20n74dHtErcViR3PW+5hpXz5jvnhsU/bhHiP4KqIRiiRfueHHRoeui8yVMj5sxFSEL5j 47jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eezWDwyqk949sEAV6VBZXvmE65PTPfqNCFhhSoX++44=; b=2SMcvlyi+qWifjT+KmkYnsPj3gj52RaZygWetdu0H/hKtQA/AC4OjajPD7HdrxZq6N sEzuvqS9OwuPqLUxmRoZ/meF3G+7xjUOHrho8E6VPDfPXOLqIXad8a357AJDyHRjxXPm 9jrR2Qr0MecDfYo8V/rp1FrbdExIpRuypPWt8ccsMzlqfmiTGOAvaLPhuM4p0LzBpGno ztl1Ku6TBYNxL8pi1OpLa6DML9/6u294KBskGq84+XIjyI3zvNM+ePP0esKhfZIZppA5 Z4WlIjwQZf+K9TcJ4evJ3Pk0nkYFbgk7d3w/JhzqoCSNEogeDOv8+5h5gW2V5sWpVrqq RjAQ== X-Gm-Message-State: AFqh2koD2iqPVrElVCO46SYusSG/EM/3G8H6j2tV/OqebuSi746gxe3z 10HRT4krdaW/jOBCQv3mBSyW3o7WAmDJ7eiH X-Google-Smtp-Source: AMrXdXuFouVTMxaq7VekFjs4wz2DtSH9W9iNxpumCXLOPTj16YNvmf/eBWS8w7lu3B8BzCIKLgDjy4XmaacOkKAz X-Received: from vannapurve2.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:41f8]) (user=vannapurve job=sendgmr) by 2002:a17:90a:5c86:b0:219:c1fb:5da8 with SMTP id r6-20020a17090a5c8600b00219c1fb5da8mr2330892pji.221.1672255492112; Wed, 28 Dec 2022 11:24:52 -0800 (PST) Date: Wed, 28 Dec 2022 19:24:36 +0000 In-Reply-To: <20221228192438.2835203-1-vannapurve@google.com> Mime-Version: 1.0 References: <20221228192438.2835203-1-vannapurve@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20221228192438.2835203-3-vannapurve@google.com> Subject: [V4 PATCH 2/4] KVM: selftests: x86: Add variables to store cpu type From: Vishal Annapurve To: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: pbonzini@redhat.com, shuah@kernel.org, bgardon@google.com, seanjc@google.com, oupton@google.com, peterx@redhat.com, vkuznets@redhat.com, dmatlack@google.com, Vishal Annapurve Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add variables to hold the cpu vendor type that are initialized early during the selftest setup and later synced to guest vm post VM creation. These variables will be used in later patches to avoid querying CPU type multiple times. Suggested-by: Sean Christopherson Signed-off-by: Vishal Annapurve --- tools/testing/selftests/kvm/lib/x86_64/processor.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/tes= ting/selftests/kvm/lib/x86_64/processor.c index a799af572f3f..b3d2a9ab5ced 100644 --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c @@ -19,6 +19,8 @@ #define MAX_NR_CPUID_ENTRIES 100 =20 vm_vaddr_t exception_handlers; +static bool host_cpu_is_amd; +static bool host_cpu_is_intel; =20 static void regs_dump(FILE *stream, struct kvm_regs *regs, uint8_t indent) { @@ -555,6 +557,8 @@ static void vcpu_setup(struct kvm_vm *vm, struct kvm_vc= pu *vcpu) void kvm_arch_vm_post_create(struct kvm_vm *vm) { vm_create_irqchip(vm); + sync_global_to_guest(vm, host_cpu_is_intel); + sync_global_to_guest(vm, host_cpu_is_amd); } =20 struct kvm_vcpu *vm_arch_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id, @@ -1264,3 +1268,9 @@ bool vm_is_unrestricted_guest(struct kvm_vm *vm) =20 return get_kvm_intel_param_bool("unrestricted_guest"); } + +void kvm_selftest_arch_init(void) +{ + host_cpu_is_intel =3D this_cpu_is_intel(); + host_cpu_is_amd =3D this_cpu_is_amd(); +} --=20 2.39.0.314.g84b9a713c41-goog