From patchwork Thu Jan 23 13:50:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1228346 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QhIxhHfK; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 483TKC15Cwz9sQp for ; Fri, 24 Jan 2020 04:09:35 +1100 (AEDT) Received: from localhost ([::1]:33066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iufz2-00030t-Of for incoming@patchwork.ozlabs.org; Thu, 23 Jan 2020 12:09:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52510) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuctT-0008IR-7x for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:51:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuctR-0007wa-1P for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:51:34 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:52685 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuctQ-0007wM-Ux for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:51:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579787492; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tN1ejZZNNDpwR2f7hBVHJMLYu8kEqjTbMs1ArQbeLlc=; b=QhIxhHfKex44neOcvhjcqoU6fJoNPAMZBxucVmCo+8a/vwFeA/hVODDr1rMQPbIdB51I6h KlrkrCyorZITJBebCR6I+e4+c3nZGOIR489A3mN/+2YeacjVRMJ1+lY8ZEG7vamASZrrT1 8JJUEL0zASXC0hkFR4yKMUODOVDyPFA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-183-jIf9gV7IPEqPV03uNt2n1Q-1; Thu, 23 Jan 2020 08:51:30 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2D52100550E for ; Thu, 23 Jan 2020 13:51:29 +0000 (UTC) Received: from 640k.localdomain.com (unknown [10.36.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26AC785785 for ; Thu, 23 Jan 2020 13:51:28 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 20/59] target/i386: kvm: initialize microcode revision from KVM Date: Thu, 23 Jan 2020 14:50:10 +0100 Message-Id: <1579787449-27599-21-git-send-email-pbonzini@redhat.com> In-Reply-To: <1579787449-27599-1-git-send-email-pbonzini@redhat.com> References: <1579787449-27599-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: jIf9gV7IPEqPV03uNt2n1Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" KVM can return the host microcode revision as a feature MSR. Use it as the default value for -cpu host. Signed-off-by: Paolo Bonzini Message-Id: <1579544504-3616-4-git-send-email-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 4 ++++ target/i386/kvm.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 790254e..ffe5de0 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6416,6 +6416,10 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) &cpu->mwait.ecx, &cpu->mwait.edx); env->features[FEAT_1_ECX] |= CPUID_EXT_MONITOR; } + if (kvm_enabled() && cpu->ucode_rev == 0) { + cpu->ucode_rev = kvm_arch_get_supported_msr_feature(kvm_state, + MSR_IA32_UCODE_REV); + } } if (cpu->ucode_rev == 0) { diff --git a/target/i386/kvm.c b/target/i386/kvm.c index f6dd6b7..1b67090 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -2696,6 +2696,11 @@ static void kvm_init_msrs(X86CPU *cpu) env->features[FEAT_CORE_CAPABILITY]); } + if (kvm_arch_get_supported_msr_feature(kvm_state, + MSR_IA32_UCODE_REV)) { + kvm_msr_entry_add(cpu, MSR_IA32_UCODE_REV, cpu->ucode_rev); + } + /* * Older kernels do not include VMX MSRs in KVM_GET_MSR_INDEX_LIST, but * all kernels with MSR features should have them.