From patchwork Fri Oct 2 15:46:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 525656 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 67BF114030F for ; Sat, 3 Oct 2015 02:53:14 +1000 (AEST) Received: from localhost ([::1]:33374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi3a4-0007DG-CP for incoming@patchwork.ozlabs.org; Fri, 02 Oct 2015 12:53:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi2Xp-0000oA-Q4 for qemu-devel@nongnu.org; Fri, 02 Oct 2015 11:46:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zi2Xm-0005Ro-G8 for qemu-devel@nongnu.org; Fri, 02 Oct 2015 11:46:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi2Xm-0005Rf-AX for qemu-devel@nongnu.org; Fri, 02 Oct 2015 11:46:46 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 6E846461E7; Fri, 2 Oct 2015 15:46:45 +0000 (UTC) Received: from gimli.home (ovpn-113-42.phx2.redhat.com [10.3.113.42]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t92FkiFX010482; Fri, 2 Oct 2015 11:46:44 -0400 From: Alex Williamson To: qemu-devel@nongnu.org, kvm@vger.kernel.org Date: Fri, 02 Oct 2015 09:46:44 -0600 Message-ID: <20151002154541.28619.11688.stgit@gimli.home> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] kvm: Allow the Hyper-V vendor ID to be specified X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 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-bounces+incoming=patchwork.ozlabs.org@nongnu.org According to Microsoft documentation, the signature in the standard hypervisor CPUID leaf at 0x40000000 identifies the Vendor ID and is for reporting and diagnostic purposes only. We can therefore allow the user to change it to whatever they want, within the 12 character limit. Add a new hyperv-vendor-id option to the -cpu flag to allow for this, ex: -cpu host,hv_time,hv_vendor_id=KeenlyKVM Link: http://msdn.microsoft.com/library/windows/hardware/hh975392 Signed-off-by: Alex Williamson --- target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 1 + target-i386/kvm.c | 14 +++++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h index c35b624..6c1eaaa 100644 --- a/target-i386/cpu-qom.h +++ b/target-i386/cpu-qom.h @@ -88,6 +88,7 @@ typedef struct X86CPU { bool hyperv_vapic; bool hyperv_relaxed_timing; int hyperv_spinlock_attempts; + char *hyperv_vendor_id; bool hyperv_time; bool hyperv_crash; bool check_cpuid; diff --git a/target-i386/cpu.c b/target-i386/cpu.c index bd411b9..101c405 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -3122,6 +3122,7 @@ static Property x86_cpu_properties[] = { DEFINE_PROP_UINT32("level", X86CPU, env.cpuid_level, 0), DEFINE_PROP_UINT32("xlevel", X86CPU, env.cpuid_xlevel, 0), DEFINE_PROP_UINT32("xlevel2", X86CPU, env.cpuid_xlevel2, 0), + DEFINE_PROP_STRING("hv-vendor-id", X86CPU, hyperv_vendor_id), DEFINE_PROP_END_OF_LIST() }; diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 7b0ba17..85aa612 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -489,7 +489,19 @@ int kvm_arch_init_vcpu(CPUState *cs) if (hyperv_enabled(cpu)) { c = &cpuid_data.entries[cpuid_i++]; c->function = HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS; - memcpy(signature, "Microsoft Hv", 12); + if (!cpu->hyperv_vendor_id) { + memcpy(signature, "Microsoft Hv", 12); + } else { + size_t len = strlen(cpu->hyperv_vendor_id); + + if (len > 12) { + fprintf(stderr, + "hyperv-vendor-id too long, limited to 12 charaters"); + abort(); + } + memset(signature, 0, 12); + memcpy(signature, cpu->hyperv_vendor_id, len); + } c->eax = HYPERV_CPUID_MIN; c->ebx = signature[0]; c->ecx = signature[1];