From bfdd5cf85692f517d8bae8dbfaf50d43884452bb Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Eduardo Habkost Date: Thu, 25 Oct 2012 19:28:15 +0200 Subject: [PATCH 2/8] i386: kvm: kvm_arch_get_supported_cpuid: replace nested 'if's with single 'if' RH-Author: Eduardo Habkost Message-id: <1351193301-31675-3-git-send-email-ehabkost@redhat.com> Patchwork-id: 43647 O-Subject: [RHEL6.4 qemu-kvm PATCH 2/8] i386: kvm: kvm_arch_get_supported_cpuid: replace nested 'if's with single 'if' Bugzilla: 691638 RH-Acked-by: Marcelo Tosatti RH-Acked-by: Gleb Natapov RH-Acked-by: Laszlo Ersek Bugzilla: 691638 Upstream status: equivalent patch submitted Message-Id: <1349383747-19383-8-git-send-email-ehabkost@redhat.com> Additional fixups will be added, and making them a single 'if/else if' chain makes it clearer than two nested 'if' statements. [RHEL note: the upstream code is on target-i386/kvm.c, this changes the equivalent RHEL-6 code, at qemu-kvm-x86.c] Signed-off-by: Eduardo Habkost --- qemu-kvm-x86.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) Signed-off-by: Michal Novotny --- qemu-kvm-x86.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index d3b5ace..70d0885 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -745,24 +745,20 @@ uint32_t kvm_get_supported_cpuid(kvm_context_t kvm, uint32_t function, /* Fixups for the data returned by KVM, below */ - if (reg == R_EDX) { - if (function == 1) { - /* kvm misreports the following features - */ - ret |= 1 << 12; /* MTRR */ - ret |= 1 << 16; /* PAT */ - ret |= 1 << 7; /* MCE */ - ret |= 1 << 14; /* MCA */ - } - + if (function == 1 && reg == R_EDX) { + /* kvm misreports the following features + */ + ret |= 1 << 12; /* MTRR */ + ret |= 1 << 16; /* PAT */ + ret |= 1 << 7; /* MCE */ + ret |= 1 << 14; /* MCA */ + } else if (function == 0x80000001 && reg == R_EDX) { /* On Intel, kvm returns cpuid according to * the Intel spec, so add missing bits * according to the AMD spec: */ - if (function == 0x80000001) { - cpuid_1_edx = kvm_get_supported_cpuid(kvm, 1, 0, R_EDX); - ret |= cpuid_1_edx & 0x183f7ff; - } + cpuid_1_edx = kvm_get_supported_cpuid(kvm, 1, 0, R_EDX); + ret |= cpuid_1_edx & 0x183f7ff; } free(cpuid); -- 1.7.11.7