From nobody Mon Feb 9 20:12:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1614795822; cv=none; d=zohomail.com; s=zohoarc; b=Du1GtTqshhao3mnLaXkEnFSd7Sn3XOJQezERG9rHWZr+Bld45UxRSbJUPBHwUI0WwPR7ry7ZK2BVRFyHtF3FXDonKvqRWT+SMEPjsUZK+VQVs7OfuaOY7shFX73EjqeJw1ZcBFoEOy7Gpa+zC0De8nOkIPaWF0ElllhRSonyyZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614795822; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=79DgZpr2EmNkKjevsnbnnQniykZdHifg2JouUZY5E8w=; b=Omar0Zw0/+Hsi9nOyf3zmx0M5axVx+vyk3QTK3GzSjX6/7QwapDZj3ZS6dEP5pb6EIZJ5bvdZnaWiZIK6o/2MZhVWrfWW7q0kwcO7hjlw3/riRUwfvAUVsKa/1ztDtqWXUZMoFBrszVhrvcNrNZW5/igwDzQLXNSXjZjQ4M16B0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614795822883244.09968595796533; Wed, 3 Mar 2021 10:23:42 -0800 (PST) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-282-l6Z1vn4LNWC-R1JEGh3hlw-1; Wed, 03 Mar 2021 13:23:40 -0500 Received: by mail-wr1-f72.google.com with SMTP id v1so2635428wru.7 for ; Wed, 03 Mar 2021 10:23:39 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id t14sm34525097wru.64.2021.03.03.10.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 10:23:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614795821; 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=79DgZpr2EmNkKjevsnbnnQniykZdHifg2JouUZY5E8w=; b=RMIThd85MBEpUEDRMa6C3BXWNXPRonEBX3aItDd99DjeoO2y6JHgN3FCWIvFZRt4eK+cL7 CAzhH2xzu6ckTpfdQRgAyeh0b/hxkjzHgTV0xhFXHdck+RPONUGnXkFIoZKVzjnd0vkith bXHIuIhGeROX7QgRfoK+SUhwdDWMo4k= X-MC-Unique: l6Z1vn4LNWC-R1JEGh3hlw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=79DgZpr2EmNkKjevsnbnnQniykZdHifg2JouUZY5E8w=; b=iD2FAzIMMswKnUIA71qS2HKvPi5hUnZYPb2t5cCpSouBrVNyKQGbTquyycaZ7Qc0X7 SAVMWBsOjn0rVImaCo20nicTgE5pCciku1BPbdzzc6qw874ugwdznixuDjLWUrzbp7li 9uIclapU2VpNSQUU28kzNefnnWoGEZWfNhadbw2+mOWru8HbP6lW1pRpYkttRAm36wfm 8wKwkrVXSuZ1esOWsv5xXX8TFxKaYI7UJHUHxz5X6ZdQr/gUBy4klHz2w2DBO2jhFn1o xLtgTdZR5o1x0p4a5v3mf7vGajcE/5rPeHSj4KL4AI5miIoictVV1Cb04wN1wIyEIR83 +XYw== X-Gm-Message-State: AOAM533z5OuikFP5EoPeVCo6F4/vcnrAmbh63wwEZ8X3k+1FOTZuijzL Mlk1ya6gc/xYBloGA4SaFhsBvIyqanLPKJS+RMsgz1vXOIXOKFutwICZnjC9lfeF5X8lQfIW1vd uGHA5ZbZ3qIxT4g== X-Received: by 2002:a7b:c407:: with SMTP id k7mr292582wmi.136.1614795819009; Wed, 03 Mar 2021 10:23:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2ZZPhH9pI1ojwAdx3yz1Bw2buB6+u4yZQIHTFUxGfLpDaJfYOKtQLkaZHng2glOOMTYruTw== X-Received: by 2002:a7b:c407:: with SMTP id k7mr292558wmi.136.1614795818843; Wed, 03 Mar 2021 10:23:38 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Cornelia Huck , Richard Henderson , Sunil Muthuswamy , Marcelo Tosatti , David Gibson , Marcel Apfelbaum , kvm@vger.kernel.org, Wenchao Wang , Thomas Huth , Cameron Esfahani , Paolo Bonzini , David Hildenbrand , Roman Bolshakov , Peter Maydell , Greg Kurz , qemu-arm@nongnu.org, Halil Pasic , Colin Xu , Claudio Fontana , qemu-ppc@nongnu.org, Christian Borntraeger , qemu-s390x@nongnu.org, haxm-team@intel.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH 11/19] accel/kvm: Introduce kvm_vcpu_state() helper Date: Wed, 3 Mar 2021 19:22:11 +0100 Message-Id: <20210303182219.1631042-12-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210303182219.1631042-1-philmd@redhat.com> References: <20210303182219.1631042-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/sysemu/kvm.h | 2 ++ accel/kvm/kvm-all.c | 5 +++++ target/i386/cpu.c | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 687c598be9b..f339be31d1b 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -361,6 +361,8 @@ int kvm_arch_init_vcpu(CPUState *cpu); int kvm_arch_destroy_vcpu(CPUState *cpu); =20 bool kvm_vcpu_id_is_valid(int vcpu_id); +/* Returns a pointer to the KVMState associated with this vCPU */ +KVMState *kvm_vcpu_state(CPUState *cpu); =20 /* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */ unsigned long kvm_arch_vcpu_id(CPUState *cpu); diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 84c943fcdb2..b787d590a9a 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1978,6 +1978,11 @@ bool kvm_vcpu_id_is_valid(int vcpu_id) return vcpu_id >=3D 0 && vcpu_id < kvm_max_vcpu_id(s); } =20 +KVMState *kvm_vcpu_state(CPUState *cpu) +{ + return cpu->kvm_state; +} + static int kvm_init(MachineState *ms) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6a53446e6a5..0d6376322bb 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5755,7 +5755,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, case 0xA: /* Architectural Performance Monitoring Leaf */ if (kvm_enabled() && cpu->enable_pmu) { - KVMState *s =3D cs->kvm_state; + KVMState *s =3D kvm_vcpu_state(cs); =20 *eax =3D kvm_arch_get_supported_cpuid(s, 0xA, count, R_EAX); *ebx =3D kvm_arch_get_supported_cpuid(s, 0xA, count, R_EBX); @@ -6620,7 +6620,7 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool= verbose) =20 if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) && kvm_enabled()) { - KVMState *s =3D CPU(cpu)->kvm_state; + KVMState *s =3D kvm_vcpu_state(CPU(cpu)); uint32_t eax_0 =3D kvm_arch_get_supported_cpuid(s, 0x14, 0, R_EAX); uint32_t ebx_0 =3D kvm_arch_get_supported_cpuid(s, 0x14, 0, R_EBX); uint32_t ecx_0 =3D kvm_arch_get_supported_cpuid(s, 0x14, 0, R_ECX); --=20 2.26.2