From patchwork Thu Jan 20 12:36:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 533565 Delivered-To: patch@linaro.org Received: by 2002:adf:f849:0:0:0:0:0 with SMTP id d9csp21540wrq; Thu, 20 Jan 2022 09:25:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJyX8Bi02JgRhr1BEphC/hUZqG7nzWMJrc9twVNKpcl6CKztyJNJIL4WMas3JgSK1Jgn+F7X X-Received: by 2002:a05:622a:1901:: with SMTP id w1mr29479802qtc.666.1642699501314; Thu, 20 Jan 2022 09:25:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642699501; cv=none; d=google.com; s=arc-20160816; b=fPoIQQYn9K/ZI0TFc9oMdWGpDxSHxbFpjmZLAKMTdORnDj1ItgGqyVZDN2D2Bt7ZkW fTFWdzW/MzP56+g7nnTuaI4Gk6XKwCnDe53ovZ4xy44gzAMMF+QeiFpVQsHJc2AxGZQS wk+/Mcr132i870CcIVSTLFjlUMoCtsX5UXoxKZLsIMDfVQkMBCMXO/K2bTqaIIlLEJYz rKWcm3w9oT+fQkPU1bPHQBCKGD2JV0XimvUp6Hp/D4Ix9yh9hx2MVHEi0JDOXEYqgmdF 8BvmYQBt94dlh+rxlPU3c6z6v3n1n6RXDAhcds9YO0gb2nEiF0XDT0JGb7CbhPsOHSMe NKCg== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=/NfTLPWOeFMHwkrMPtZ5dblg8GV5USf+bzr32beD21U=; b=Fk1ePdO2FwpzZYnof+S6V94saMd+uW+IrubWkQZOFRgpFhsdrT0jE5Kbf1riDjeTd3 471o7pop5okFadqIbQCJAd9gcVOalfvdDwrcqYlGV3ceYCEN+jPzgmRj6ORK3BytvJ3H H/NHDkd2/CDAlaIkvg/5ICK1ZWb0Hx4vvefKutTBjc4eVooPq+aRS16vQwWRi+3MtkmB ZbmTKrMHDT9vRMUQOAbsaMxsq1+50KCIEHVZr/cIA76jRy6AueBASaU3bLYAabqOUO/j a/yPNjc39/malCgSMY2yvdGPJr4d/oulT8h4YVfu6rrQZ+beC+BiSNfAGhbXfML/xVzn Cq3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gELXNFyp; 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=pass (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 br17si1383816qkb.584.2022.01.20.09.25.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Jan 2022 09:25:01 -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=pass header.i=@linaro.org header.s=google header.b=gELXNFyp; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAbBE-0006pB-Nq for patch@linaro.org; Thu, 20 Jan 2022 12:25:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAWgV-0004Fk-Ll for qemu-devel@nongnu.org; Thu, 20 Jan 2022 07:37:00 -0500 Received: from [2a00:1450:4864:20::332] (port=55838 helo=mail-wm1-x332.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAWgT-0003HC-55 for qemu-devel@nongnu.org; Thu, 20 Jan 2022 07:36:59 -0500 Received: by mail-wm1-x332.google.com with SMTP id c66so11771332wma.5 for ; Thu, 20 Jan 2022 04:36:53 -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=/NfTLPWOeFMHwkrMPtZ5dblg8GV5USf+bzr32beD21U=; b=gELXNFypClVzAoubnjvGujwOTXNwzhmZoDqOwAHmd9cNpfH5eoxlUUSvlojB3QgfAV nNU9CDXWFDyylrkNXTwweCfhvIecO+sdiH3aZ31MHQxmqdbCFZS0P16bKjblxMXg7v2W Ckj9BmDU0SegugVYWdKiwYPlAGqKxo07t5BlznEQL6zWNzxedBH910S2ztcv71EDqRgX +8ghsVYy8qGmcz2bYBvgWS6giscH+dseZwBd+dNMq46dlqrF1JVxVsggxUks8wbhei88 Ym6pCvckdJDciEY/ohXGoIwT2UJVVhqZb99Gksii2sGXrkFxP0usJGttKrgFePKBULjr ESdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/NfTLPWOeFMHwkrMPtZ5dblg8GV5USf+bzr32beD21U=; b=qEZHXMzmqxC7YAtgGWueNER52CE4Qx1iuGfe/xgWwo+tCJI96b9a3cttNahera78n8 9mGcwbmlvrkbfy7/3L6ZqRUdctAY3owu1DyyXCnD57O5H8rIBUtHbr3xMWLPlJoDJqYI n+PlxVrwnEFwVf+YAqRLw/xIav8fAllPplTKvR2Od1PLYrRL2BTY1sYJce+SjQC0s+8A gmbuvzi5yu/i/DmE3vutFKydy0d3dO3iEbDECWP5iC+bOQLzI6b/USZOwm0M1kT5O1Mh SJW5vvX7oPNAJSYCS4UFHhCOziZaixCgmEbrKKu+3BTkKuyqfvdqkONyWhDkWJxc6dn9 i3xg== X-Gm-Message-State: AOAM531SYY7SSNBypTVJweICdJsx1D/EU+ZCpOmer2s4mA4D8ltHpiRz FXKKVaCSJwFEgPfjUIpxjXTvmhKrJqh1wA== X-Received: by 2002:adf:e2cc:: with SMTP id d12mr33056426wrj.107.1642682212648; Thu, 20 Jan 2022 04:36:52 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t8sm7993324wmq.43.2022.01.20.04.36.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 04:36:51 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 18/38] hw/arm/virt: Honor highmem setting when computing the memory map Date: Thu, 20 Jan 2022 12:36:10 +0000 Message-Id: <20220120123630.267975-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220120123630.267975-1-peter.maydell@linaro.org> References: <20220120123630.267975-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::332 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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: Marc Zyngier Even when the VM is configured with highmem=off, the highest_gpa field includes devices that are above the 4GiB limit. Similarily, nothing seem to check that the memory is within the limit set by the highmem=off option. This leads to failures in virt_kvm_type() on systems that have a crippled IPA range, as the reported IPA space is larger than what it should be. Instead, honor the user-specified limit to only use the devices at the lowest end of the spectrum, and fail if we have memory crossing the 4GiB limit. Reviewed-by: Andrew Jones Reviewed-by: Eric Auger Signed-off-by: Marc Zyngier Message-id: 20220114140741.1358263-4-maz@kernel.org Signed-off-by: Peter Maydell --- hw/arm/virt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 62bdce1eb4b..3b839ba78ba 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1670,7 +1670,7 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx) static void virt_set_memmap(VirtMachineState *vms) { MachineState *ms = MACHINE(vms); - hwaddr base, device_memory_base, device_memory_size; + hwaddr base, device_memory_base, device_memory_size, memtop; int i; vms->memmap = extended_memmap; @@ -1697,7 +1697,11 @@ static void virt_set_memmap(VirtMachineState *vms) device_memory_size = ms->maxram_size - ms->ram_size + ms->ram_slots * GiB; /* Base address of the high IO region */ - base = device_memory_base + ROUND_UP(device_memory_size, GiB); + memtop = base = device_memory_base + ROUND_UP(device_memory_size, GiB); + if (!vms->highmem && memtop > 4 * GiB) { + error_report("highmem=off, but memory crosses the 4GiB limit\n"); + exit(EXIT_FAILURE); + } if (base < device_memory_base) { error_report("maxmem/slots too huge"); exit(EXIT_FAILURE); @@ -1714,7 +1718,7 @@ static void virt_set_memmap(VirtMachineState *vms) vms->memmap[i].size = size; base += size; } - vms->highest_gpa = base - 1; + vms->highest_gpa = (vms->highmem ? base : memtop) - 1; if (device_memory_size > 0) { ms->device_memory = g_malloc0(sizeof(*ms->device_memory)); ms->device_memory->base = device_memory_base;