From patchwork Tue Mar 5 16:50:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 159692 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp5199385jad; Tue, 5 Mar 2019 09:06:14 -0800 (PST) X-Google-Smtp-Source: APXvYqwnyRYYsfIbdkkWxHj8l3nAM27iRXMBdrVEiZIS2fxLLQKsFKJwlI1W6ZVzbfQfc7QQ6Vjq X-Received: by 2002:ac8:2995:: with SMTP id 21mr2183149qts.297.1551805574159; Tue, 05 Mar 2019 09:06:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551805574; cv=none; d=google.com; s=arc-20160816; b=HYKxMIys1BuoVJ1gzOQJwnpzFW0suWr6vMAhC4ERf11KuS/xsv4dAP6fCZWjmRtzBR kyhBjGUFdxdQ0ClpbAaDuyUhLIpMHFaqS097sEM+kQm618F1W4blRMiLygdT6QYcdrGa phE6fPcBlDwFs4hLuJMYLZ8v6T3pV5UC3cCm+dbXVEDvtH01nAwkfpnUt9U0V7n2+PnS xNo12i3CgZfFBscXE+U1WcBhZChF+RciuPoHBBP35Kkh7f/l9BNjQQawbpxJy36S0DEc UPkl9MlUGAFx7RtioFOE4b26OYgpdfLObnxzHLelFosCohfxVPXlBLCGf49nHLpH4CBc xxkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=EOGiDxex+R/Z4NUtbpgj5pPr6Td3m3QTjRVX/jrIni4=; b=ctJV0KNq1dUSUvfRljOCYO4v/dcipdJA5lu/YzEy9PL/sBYa9vaaIXrSmgWEff4hKB fXHb8foHwNt1YfUi7FTPORXARdtIaKUT7rtI7O1qjJ0UC4WTzmOSWcJIaPpnTciz8Pp5 JM5b6bnVHFWjFnycfbS/XV4va4vh15IwAy/S9+D+HmRTdLyNVMJ87SNGg3TmhTBwfkm/ ZIhERePI3rKgrosdrM4PcPQJOuxM0wMgjMtToWyM/k+lHDDitT947FxfoHYWO+odf2gf rSoS1evDmlH9q0UIx4j+8igehzDFuEBlK4RehqDPbuM37OO2iu8zI7VNZyUGX+wuopFX g8iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TTgh+EL9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r58si676546qte.87.2019.03.05.09.06.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 05 Mar 2019 09:06:14 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TTgh+EL9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:45958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DW9-0005g9-Hf for patch@linaro.org; Tue, 05 Mar 2019 12:06:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DHh-0001h1-OR for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:51:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1DHg-00014x-UT for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:51:17 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:38669) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1DHg-00013Z-Ma for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:51:16 -0500 Received: by mail-wr1-x433.google.com with SMTP id g12so10247353wrm.5 for ; Tue, 05 Mar 2019 08:51:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=EOGiDxex+R/Z4NUtbpgj5pPr6Td3m3QTjRVX/jrIni4=; b=TTgh+EL9wZRIIDLUndtgNudEUDtXstDqZ62J/YSO7npDsrZORwrh5EWpjf1jbv8c6M 4n69f47BItgmLYGdZFUOKEpJtDsGxc9kLzIhwVqcJBX+mB1RDFanzdEKdPhYyRhOg4v3 PbMTqv+UNTil4X6HB6CeYDWv8zwCHcQeOPO9YgOlpwO+1WoplruzbkodyxCltO/LOSq1 Z2HYOeSDPKGBAEJqsCzgwG6kgA6NwTMRG1LW8wrKWNIlAk8qGySREoy5aO33T2VSwQ5N GQa+/8uC8gRz2iWtYVsul/OqcSRvkxFDe1//ztPlaLe5VQ9tyyQ+rf0W4+BjS4Qky+m8 mpvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EOGiDxex+R/Z4NUtbpgj5pPr6Td3m3QTjRVX/jrIni4=; b=kNUDEgynSBN3hpbJuKwzbeu4w/FuViwKQ+c89XF2R46ZMHii3tAJUuoMg6myRRuApV t2bgB2/FHkRoQuj0HUjX3UenjzEwRYnIXc2CB2gRHr0kgAbXM3hAC5fRcI7LxyA4EVY8 YAlooZ1ljjA9W8ZT/Ubhl5k0KfS54nusbRbmubyy8IgjEti+eHp8yVh0wJ7HK5Lq1xDg jbEXRpw3nhg+2vfbfv14FyX/MLk1X/qbPbDYb0bby1liBD96cWWx3tuIzgY0bPRrXIX9 lAzI2x2wQebSY77CIIrnG+GlEd7SVNj+wbmTc8pZt8A9ry8rGt9WamwzX4AKF8xeQ4wK LMWg== X-Gm-Message-State: APjAAAWfy1fJGqh0rb9yhuovj7sI7pHESE8EuYWHFFEHVkzKq4qsD0zC 2ZD+Pl+GDe1do3blvAYJYtQna/Hi414= X-Received: by 2002:adf:e98c:: with SMTP id h12mr17862537wrm.302.1551804675480; Tue, 05 Mar 2019 08:51:15 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id 2sm10071495wrg.89.2019.03.05.08.51.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Mar 2019 08:51:14 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 5 Mar 2019 16:50:48 +0000 Message-Id: <20190305165051.26860-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190305165051.26860-1-peter.maydell@linaro.org> References: <20190305165051.26860-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::433 Subject: [Qemu-devel] [PULL 19/22] hw/arm/virt: Implement kvm_type function for 4.0 machine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Eric Auger This patch implements the machine class kvm_type() callback. It returns the number of bits requested to implement the whole GPA range including the RAM and IO regions located beyond. The returned value is passed though the KVM_CREATE_VM ioctl and this allows KVM to set the stage2 tables dynamically. To compute the highest GPA used in the memory map, kvm_type() must freeze the memory map by calling virt_set_memmap(). Signed-off-by: Eric Auger Reviewed-by: Igor Mammedov Message-id: 20190304101339.25970-9-eric.auger@redhat.com Signed-off-by: Peter Maydell --- hw/arm/virt.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 2e788a0361e..3ac6b152f55 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1440,7 +1440,13 @@ static void machvirt_init(MachineState *machine) bool firmware_loaded = bios_name || drive_get(IF_PFLASH, 0, 0); bool aarch64 = true; - virt_set_memmap(vms); + /* + * In accelerated mode, the memory map is computed earlier in kvm_type() + * to create a VM with the right number of IPA bits. + */ + if (!vms->memmap) { + virt_set_memmap(vms); + } /* We can probe only here because during property set * KVM is not available yet @@ -1829,6 +1835,36 @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, return NULL; } +/* + * for arm64 kvm_type [7-0] encodes the requested number of bits + * in the IPA address space + */ +static int virt_kvm_type(MachineState *ms, const char *type_str) +{ + VirtMachineState *vms = VIRT_MACHINE(ms); + int max_vm_pa_size = kvm_arm_get_max_vm_ipa_size(ms); + int requested_pa_size; + + /* we freeze the memory map to compute the highest gpa */ + virt_set_memmap(vms); + + requested_pa_size = 64 - clz64(vms->highest_gpa); + + if (requested_pa_size > max_vm_pa_size) { + error_report("-m and ,maxmem option values " + "require an IPA range (%d bits) larger than " + "the one supported by the host (%d bits)", + requested_pa_size, max_vm_pa_size); + exit(1); + } + /* + * By default we return 0 which corresponds to an implicit legacy + * 40b IPA setting. Otherwise we return the actual requested PA + * logsize + */ + return requested_pa_size > 40 ? requested_pa_size : 0; +} + static void virt_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); @@ -1853,6 +1889,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->cpu_index_to_instance_props = virt_cpu_index_to_props; mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"); mc->get_default_cpu_node_id = virt_get_default_cpu_node_id; + mc->kvm_type = virt_kvm_type; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler = virt_machine_get_hotplug_handler; hc->plug = virt_machine_device_plug_cb;