From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4762DC433EF for ; Mon, 4 Oct 2021 09:44:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B91961181 for ; Mon, 4 Oct 2021 09:44:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232431AbhJDJqZ (ORCPT ); Mon, 4 Oct 2021 05:46:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59538 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231962AbhJDJqY (ORCPT ); Mon, 4 Oct 2021 05:46:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633340675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=SoUkTtOv9XP49TsrzDlI8hEqaw7q+N7J/SxBu7RAHCQ=; b=fHBHGlAQcH7HITOeeZSlw+Af8RP5uM/cjf3Wr82ThRUhaX6roe/OO4zVUFT3q4U9gjVfZ8 uLFSbjKMy801VJu4JI9lwHfk1e5ULduBITt5HHWEprWmDnOoC7zAMWK0ve8aRpd0tEPwWR LtaCGYNqH3jl2HlmlYihGg2xAy86dzI= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-322-DzrBJ6JEPi2O7q1MOTmCDQ-1; Mon, 04 Oct 2021 05:44:34 -0400 X-MC-Unique: DzrBJ6JEPi2O7q1MOTmCDQ-1 Received: by mail-wr1-f70.google.com with SMTP id c2-20020adfa302000000b0015e4260febdso4426823wrb.20 for ; Mon, 04 Oct 2021 02:44:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SoUkTtOv9XP49TsrzDlI8hEqaw7q+N7J/SxBu7RAHCQ=; b=QUrlg2S5KcyBJQQw95Obsbao1idZKAYqyTL0VOlY+jofqr6GPUoVZvRUnBMS7BMYpb QF4p2axY6sqvPuWeHy/dVIFePTOzW6akTdWVD/WZJi6PgGDaZfbKH9tQsbTsmz5syF/U XiHyFoPLa3fQfYxql21ztDV906/uy9AqSoXKzEaTTYnfOQeqse2Lw0wl/KazGNbDaFVU ZX9akABdcXZcded7I2ZTfht11xICYWtwZpTShHgyXruDFq4I+4cGKEWI188lBNZVmxlM EEot4VuJGEnh2A849VdMqZXLIUmMeyR8pTXNDrlJN4Ho9SnaWuxCByzHUCnVa8Twvh9U KiGg== X-Gm-Message-State: AOAM531L92Z9drQBHe4My2T1K3y+L47MopXgPXRdTbDr5s0p2dxDnzL3 +Rx6pxHMkOJYxhL/toUzu/zcjbcng4Bw5HJwUIOrl8qI/rFD0Dn9pN6yvSTK0Rsg7F7Ldn/m+Su VVyHHA+yLR1is X-Received: by 2002:adf:9bc4:: with SMTP id e4mr13142421wrc.257.1633340673301; Mon, 04 Oct 2021 02:44:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2LrCY7HSrjxs2GPwETmmHaFihgfaSnx78iosQ5U6+ikTJPgF0cMge7tL/mMpTCWF7VZGUEw== X-Received: by 2002:adf:9bc4:: with SMTP id e4mr13142407wrc.257.1633340673145; Mon, 04 Oct 2021 02:44:33 -0700 (PDT) Received: from gator (nat-pool-brq-u.redhat.com. [213.175.37.12]) by smtp.gmail.com with ESMTPSA id n17sm6794152wrw.16.2021.10.04.02.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 02:44:32 -0700 (PDT) Date: Mon, 4 Oct 2021 11:44:31 +0200 From: Andrew Jones To: Marc Zyngier Cc: qemu-devel@nongnu.org, Eric Auger , Peter Maydell , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v2 3/5] hw/arm/virt: Honor highmem setting when computing the memory map Message-ID: <20211004094431.2dewqj3hf2vjiil7@gator> References: <20211003164605.3116450-1-maz@kernel.org> <20211003164605.3116450-4-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211003164605.3116450-4-maz@kernel.org> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Sun, Oct 03, 2021 at 05:46:03PM +0100, Marc Zyngier wrote: > 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. > > Signed-off-by: Marc Zyngier > --- > hw/arm/virt.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index bcf58f677d..9d2abdbd5f 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -1628,6 +1628,11 @@ static void virt_set_memmap(VirtMachineState *vms) > exit(EXIT_FAILURE); > } > > + if (!vms->highmem && > + vms->memmap[VIRT_MEM].base + ms->maxram_size > 4 * GiB) { > + error_report("highmem=off, but memory crosses the 4GiB limit\n"); > + exit(EXIT_FAILURE); > + } > /* > * We compute the base of the high IO region depending on the > * amount of initial and device memory. The device memory start/size > @@ -1657,7 +1662,9 @@ 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 : > + vms->memmap[VIRT_MEM].base + ms->maxram_size) - 1; > if (device_memory_size > 0) { > ms->device_memory = g_malloc0(sizeof(*ms->device_memory)); > ms->device_memory->base = device_memory_base; > -- > 2.30.2 > Reviewed-by: Andrew Jones From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69EECC433FE for ; Mon, 4 Oct 2021 09:44:39 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 02B2F61181 for ; Mon, 4 Oct 2021 09:44:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 02B2F61181 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id A6BA74B201; Mon, 4 Oct 2021 05:44:38 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@redhat.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EfzabRT7ByOD; Mon, 4 Oct 2021 05:44:37 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id B67644B252; Mon, 4 Oct 2021 05:44:37 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 61A704B201 for ; Mon, 4 Oct 2021 05:44:36 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DV-5ObY54S44 for ; Mon, 4 Oct 2021 05:44:35 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 71C2B4B234 for ; Mon, 4 Oct 2021 05:44:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633340675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=SoUkTtOv9XP49TsrzDlI8hEqaw7q+N7J/SxBu7RAHCQ=; b=fHBHGlAQcH7HITOeeZSlw+Af8RP5uM/cjf3Wr82ThRUhaX6roe/OO4zVUFT3q4U9gjVfZ8 uLFSbjKMy801VJu4JI9lwHfk1e5ULduBITt5HHWEprWmDnOoC7zAMWK0ve8aRpd0tEPwWR LtaCGYNqH3jl2HlmlYihGg2xAy86dzI= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-352-fOb3_5rHOhmZUpoENWQksw-1; Mon, 04 Oct 2021 05:44:34 -0400 X-MC-Unique: fOb3_5rHOhmZUpoENWQksw-1 Received: by mail-wr1-f69.google.com with SMTP id r16-20020adfbb10000000b00160958ed8acso2682940wrg.16 for ; Mon, 04 Oct 2021 02:44:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SoUkTtOv9XP49TsrzDlI8hEqaw7q+N7J/SxBu7RAHCQ=; b=1ajqmBS9+sBMXbwExh05xSX4DegGnd9oMMy2Ct6bhEQO5TbVOo/5wMfC30v2ygJa0F xIfn108L/yWll68uf2prvKYrKK41d7UesgfAONA4XoCdrIWkU16JVAeOmakovfAgPkfY ueNn9p2w56is223GQvv9s1FYiypcLBxaljsu04TQ9WGcoYCm0jZzTKbw07j9bmzbsxPr CLxmnBLxZXKM2aSUrEIDmf8GhcVcpc/EHrTjQrGW/b28uTG3xYyu3CTyCBPg/HSy5/AK qNTNkGvWODJw98NyxBVSFRYpLgopPsFiDAwNRLRQhy7GYJUcoI4ggqLquQsNVYneMsY4 44nA== X-Gm-Message-State: AOAM530pEZr7/XgPNKool3jp91nOW0Wy0xdU0MoQ+fame+1abJ3LOaUO oCLqKkSYnF3uZWOdkCTsMHe842DkNJeaGVpH59XoHGYTmfTCF7AHx6KxOll3qv7M8+Ca7kpChRa vqw5Bye1x8wN0iB0rOeh8Azi6 X-Received: by 2002:adf:9bc4:: with SMTP id e4mr13142425wrc.257.1633340673325; Mon, 04 Oct 2021 02:44:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2LrCY7HSrjxs2GPwETmmHaFihgfaSnx78iosQ5U6+ikTJPgF0cMge7tL/mMpTCWF7VZGUEw== X-Received: by 2002:adf:9bc4:: with SMTP id e4mr13142407wrc.257.1633340673145; Mon, 04 Oct 2021 02:44:33 -0700 (PDT) Received: from gator (nat-pool-brq-u.redhat.com. [213.175.37.12]) by smtp.gmail.com with ESMTPSA id n17sm6794152wrw.16.2021.10.04.02.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 02:44:32 -0700 (PDT) Date: Mon, 4 Oct 2021 11:44:31 +0200 From: Andrew Jones To: Marc Zyngier Subject: Re: [PATCH v2 3/5] hw/arm/virt: Honor highmem setting when computing the memory map Message-ID: <20211004094431.2dewqj3hf2vjiil7@gator> References: <20211003164605.3116450-1-maz@kernel.org> <20211003164605.3116450-4-maz@kernel.org> MIME-Version: 1.0 In-Reply-To: <20211003164605.3116450-4-maz@kernel.org> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=drjones@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Sun, Oct 03, 2021 at 05:46:03PM +0100, Marc Zyngier wrote: > 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. > > Signed-off-by: Marc Zyngier > --- > hw/arm/virt.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index bcf58f677d..9d2abdbd5f 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -1628,6 +1628,11 @@ static void virt_set_memmap(VirtMachineState *vms) > exit(EXIT_FAILURE); > } > > + if (!vms->highmem && > + vms->memmap[VIRT_MEM].base + ms->maxram_size > 4 * GiB) { > + error_report("highmem=off, but memory crosses the 4GiB limit\n"); > + exit(EXIT_FAILURE); > + } > /* > * We compute the base of the high IO region depending on the > * amount of initial and device memory. The device memory start/size > @@ -1657,7 +1662,9 @@ 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 : > + vms->memmap[VIRT_MEM].base + ms->maxram_size) - 1; > if (device_memory_size > 0) { > ms->device_memory = g_malloc0(sizeof(*ms->device_memory)); > ms->device_memory->base = device_memory_base; > -- > 2.30.2 > Reviewed-by: Andrew Jones _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1EEFC433EF for ; Mon, 4 Oct 2021 10:17:04 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A210D60EFD for ; Mon, 4 Oct 2021 10:17:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A210D60EFD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:34412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXL1r-0000Kl-DE for qemu-devel@archiver.kernel.org; Mon, 04 Oct 2021 06:17:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXKWY-0000bd-JX for qemu-devel@nongnu.org; Mon, 04 Oct 2021 05:44:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:55392) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXKWS-00068c-Hr for qemu-devel@nongnu.org; Mon, 04 Oct 2021 05:44:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633340675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=SoUkTtOv9XP49TsrzDlI8hEqaw7q+N7J/SxBu7RAHCQ=; b=fHBHGlAQcH7HITOeeZSlw+Af8RP5uM/cjf3Wr82ThRUhaX6roe/OO4zVUFT3q4U9gjVfZ8 uLFSbjKMy801VJu4JI9lwHfk1e5ULduBITt5HHWEprWmDnOoC7zAMWK0ve8aRpd0tEPwWR LtaCGYNqH3jl2HlmlYihGg2xAy86dzI= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-437-2kGjzbiZMMqfB7M-og96hQ-1; Mon, 04 Oct 2021 05:44:34 -0400 X-MC-Unique: 2kGjzbiZMMqfB7M-og96hQ-1 Received: by mail-wr1-f70.google.com with SMTP id d13-20020adfa34d000000b00160aa1cc5f1so750300wrb.14 for ; Mon, 04 Oct 2021 02:44:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SoUkTtOv9XP49TsrzDlI8hEqaw7q+N7J/SxBu7RAHCQ=; b=xs0SHPkQWzYM0p29k28leEs2Ft0/2w2LpxA7DMR7URQz33mwpxADgncGzby1yLN4IR ajHM+6tc8ERX/XtxzIDFNywkPfgKSlMkowYgVshdh4miHj0g5l1ksgllIOo1zLEmUoJG UTU7t5sxwsZtrM+cPQcmr1St0mSAlz4MbqcGQv/+9l8JyuI7GU42BFafPlxt9t+cmwHb P52GFKBTjl3vO5jFZAXKP+CKwpVc4AFmgqukLBPs9oHdqpKra+WaNvWr0bKl7mXE3T1p MVeRUmUqO4JyAmemgyBScYrNTDMx27+5mhZ2eaOrptwhFArLXfiUI4fYUch50EJcvwoU 47rQ== X-Gm-Message-State: AOAM531iQKGuo2XYyrntrFCXZ1kE8dFQnWEQ8wbwHBenFH5yYZ6CGk0I qnegK/Eob3SIfF5kBqgPf1QVAT1B6Q15APlcZfz+sJlu0A4FlImG5F0AIkovcAQKw8gnFBfIYZf 1cGBKI4Z0IvqgMfQ= X-Received: by 2002:adf:9bc4:: with SMTP id e4mr13142417wrc.257.1633340673283; Mon, 04 Oct 2021 02:44:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2LrCY7HSrjxs2GPwETmmHaFihgfaSnx78iosQ5U6+ikTJPgF0cMge7tL/mMpTCWF7VZGUEw== X-Received: by 2002:adf:9bc4:: with SMTP id e4mr13142407wrc.257.1633340673145; Mon, 04 Oct 2021 02:44:33 -0700 (PDT) Received: from gator (nat-pool-brq-u.redhat.com. [213.175.37.12]) by smtp.gmail.com with ESMTPSA id n17sm6794152wrw.16.2021.10.04.02.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 02:44:32 -0700 (PDT) Date: Mon, 4 Oct 2021 11:44:31 +0200 From: Andrew Jones To: Marc Zyngier Subject: Re: [PATCH v2 3/5] hw/arm/virt: Honor highmem setting when computing the memory map Message-ID: <20211004094431.2dewqj3hf2vjiil7@gator> References: <20211003164605.3116450-1-maz@kernel.org> <20211003164605.3116450-4-maz@kernel.org> MIME-Version: 1.0 In-Reply-To: <20211003164605.3116450-4-maz@kernel.org> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=drjones@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=drjones@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.055, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , kvm@vger.kernel.org, qemu-devel@nongnu.org, Eric Auger , kernel-team@android.com, kvmarm@lists.cs.columbia.edu Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Sun, Oct 03, 2021 at 05:46:03PM +0100, Marc Zyngier wrote: > 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. > > Signed-off-by: Marc Zyngier > --- > hw/arm/virt.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index bcf58f677d..9d2abdbd5f 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -1628,6 +1628,11 @@ static void virt_set_memmap(VirtMachineState *vms) > exit(EXIT_FAILURE); > } > > + if (!vms->highmem && > + vms->memmap[VIRT_MEM].base + ms->maxram_size > 4 * GiB) { > + error_report("highmem=off, but memory crosses the 4GiB limit\n"); > + exit(EXIT_FAILURE); > + } > /* > * We compute the base of the high IO region depending on the > * amount of initial and device memory. The device memory start/size > @@ -1657,7 +1662,9 @@ 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 : > + vms->memmap[VIRT_MEM].base + ms->maxram_size) - 1; > if (device_memory_size > 0) { > ms->device_memory = g_malloc0(sizeof(*ms->device_memory)); > ms->device_memory->base = device_memory_base; > -- > 2.30.2 > Reviewed-by: Andrew Jones