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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B61D5C433F5 for ; Mon, 10 Jan 2022 18:51:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241955AbiAJSvh (ORCPT ); Mon, 10 Jan 2022 13:51:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241986AbiAJSvg (ORCPT ); Mon, 10 Jan 2022 13:51:36 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71DA3C06173F for ; Mon, 10 Jan 2022 10:51:35 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 220EFCE13E1 for ; Mon, 10 Jan 2022 18:51:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75E9FC36AE3; Mon, 10 Jan 2022 18:51:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641840691; bh=QQatavSkleIaeKr1SpRISb450FZAIpJSTALwjGZwGjQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BIksrciHAnMJA1PX5D8xRDsOGpJaF5P4uCRrzzPScgZZ59l1Am/jBOSDO5labt4m9 V1GSaHOQ94OqtMpWZm42Em2eXTWHPdBchRLtDH3D8XGVWYyIe1xTyMsB38GZ2OqfVv jlOCOIE50rk2YRLSijG7gJOMGXNyfyBfAK3cQTZTTiPG0C89leynYwSf+lkw13OAsy c97XvEnO7Sj4MKZyvW1BwskMLvgcE0MDYlBdBOaAw7603g5hSH0yOpj5Ef6W7Nk8+a tnRorID7CrX1h4hgMzhyGZZB3g7/9P6aJkMwfbz/MKya6+YpF0mm43zNO/+yA8ngmj ypgJzMJ4rRb/Q== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n6zlR-00HCcj-CH; Mon, 10 Jan 2022 18:51:29 +0000 Date: Mon, 10 Jan 2022 18:51:29 +0000 Message-ID: <87ee5ftoem.wl-maz@kernel.org> From: Marc Zyngier To: eric.auger@redhat.com Cc: qemu-devel@nongnu.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kernel-team@android.com, Andrew Jones , Peter Maydell Subject: Re: [PATCH v4 5/6] hw/arm/virt: Disable highmem devices that don't fit in the PA range In-Reply-To: References: <20220107163324.2491209-1-maz@kernel.org> <20220107163324.2491209-6-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: eric.auger@redhat.com, qemu-devel@nongnu.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kernel-team@android.com, drjones@redhat.com, peter.maydell@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Mon, 10 Jan 2022 17:12:50 +0000, Eric Auger wrote: > > Hi Marc, > > On 1/7/22 5:33 PM, Marc Zyngier wrote: > > In order to only keep the highmem devices that actually fit in > > the PA range, check their location against the range and update > > highest_gpa if they fit. If they don't, mark them them as disabled. > s/them them/them > > > > Signed-off-by: Marc Zyngier > > --- > > hw/arm/virt.c | 34 ++++++++++++++++++++++++++++------ > > 1 file changed, 28 insertions(+), 6 deletions(-) > > > > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > > index db4b0636e1..70b4773b3e 100644 > > --- a/hw/arm/virt.c > > +++ b/hw/arm/virt.c > > @@ -1711,21 +1711,43 @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits) > > base = vms->memmap[VIRT_MEM].base + LEGACY_RAMLIMIT_BYTES; > > } > > > > + /* We know for sure that at least the memory fits in the PA space */ > > + vms->highest_gpa = memtop - 1; > > + > > for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) { > > hwaddr size = extended_memmap[i].size; > > + bool fits; > > > > base = ROUND_UP(base, size); > > vms->memmap[i].base = base; > > vms->memmap[i].size = size; > > + > > + /* > > + * Check each device to see if they fit in the PA space, > > + * moving highest_gpa as we go. > > + * > > + * For each device that doesn't fit, disable it. > > + */ > > + fits = (base + size) <= BIT_ULL(pa_bits); > > + if (fits) { > > + vms->highest_gpa = MAX(vms->highest_gpa, base + size - 1); > why do you need the MAX()? Well spotted, I don't. Since we build the memmap by moving base upward, I can directly use 'base + size - 1' as the new highest_gpa value. Thanks, M. -- Without deviation from the norm, progress is not possible.