From patchwork Wed Jul 8 22:42:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bandan Das X-Patchwork-Id: 6751811 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AE220C05AC for ; Wed, 8 Jul 2015 22:42:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E493720567 for ; Wed, 8 Jul 2015 22:42:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE79120562 for ; Wed, 8 Jul 2015 22:42:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752893AbbGHWmH (ORCPT ); Wed, 8 Jul 2015 18:42:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49628 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752436AbbGHWmD (ORCPT ); Wed, 8 Jul 2015 18:42:03 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id A1172C7844; Wed, 8 Jul 2015 22:42:03 +0000 (UTC) Received: from aqua (ovpn-113-63.phx2.redhat.com [10.3.113.63]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t68Mg1Wh021423 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 8 Jul 2015 18:42:02 -0400 From: Bandan Das To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Paolo Bonzini , Laszlo Ersek , Eduardo Habkost Subject: [PATCH] target-i386: Sanity check host processor physical address width Date: Wed, 08 Jul 2015 18:42:01 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a Linux guest is assigned more memory than is supported by the host processor, the guest is unable to boot. That is expected, however, there's no message indicating the user what went wrong. This change prints a message to stderr if KVM has the corresponding capability. Reported-by: Laszlo Ersek Signed-off-by: Bandan Das --- linux-headers/linux/kvm.h | 1 + target-i386/kvm.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 3bac873..6afad49 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -817,6 +817,7 @@ struct kvm_ppc_smmu_info { #define KVM_CAP_DISABLE_QUIRKS 116 #define KVM_CAP_X86_SMM 117 #define KVM_CAP_MULTI_ADDRESS_SPACE 118 +#define KVM_CAP_PHY_ADDR_WIDTH 119 #ifdef KVM_CAP_IRQ_ROUTING diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 066d03d..66e3448 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -892,6 +892,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) uint64_t shadow_mem; int ret; struct utsname utsname; + int max_phys_bits; ret = kvm_get_supported_msrs(s); if (ret < 0) { @@ -945,6 +946,11 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } } + max_phys_bits = kvm_check_extension(s, KVM_CAP_PHY_ADDR_WIDTH); + if (max_phys_bits && (1ULL << max_phys_bits) <= ram_size) + fprintf(stderr, "Warning: The amount of memory assigned to the guest " + "is more than that supported by the host CPU(s). Guest may be unstable.\n"); + if (kvm_check_extension(s, KVM_CAP_X86_SMM)) { smram_machine_done.notify = register_smram_listener; qemu_add_machine_init_done_notifier(&smram_machine_done);