Received: by 2002:a19:ee0d:0:0:0:0:0 with SMTP id g13csp2387395lfb; Tue, 20 Apr 2021 12:07:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygRALguuBjPwzdnTW9ID5YdKBn1qGwlO4lyk9Pu5e/ChlfH79kn/edWPj2yvYOHGjewPC3 X-Received: by 2002:a5d:97cb:: with SMTP id k11mr20392588ios.204.1618945664586; Tue, 20 Apr 2021 12:07:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618945664; cv=none; d=google.com; s=arc-20160816; b=iMNtI70oEFO6rzyy6mfoZZc5xRw9grvw7dpTPFoPpdPWMGcWbgoQfJLamk+o2JaaTG /NlfzG7VwL4fZiaxKP/WjB9baHZSeo5n1HNNG+JJpciNxfzrLYqpJQv6Y18dte9MjYd5 cp1uAxsw+KLdxJDNAUb7TCTIuxkBFr/wDHImQAmFA6HH4wHrqjB4maVmTHleVI/+Fnpy qKDP6rb3SKRDw6Bm0uZ3bx9KqAqgOqS1HYpd6vzGGViKah20S2AUHLCIl1A1h6UcMvq4 07BVwcBC7UsyVedxwQCd4llfFE+IMS2B/MrkMPcN5gCloHwRIeoblaO2yIf/MRdIZnma 7U/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :content-disposition:in-reply-to:mime-version:references:message-id :subject:to:from:date:dkim-signature; bh=Z+GqaHEE98VpsfTBpc6n0WESBAyIBmrUSF4SZxsZHMI=; b=XmD1LX8WlZQP1xEvVNGMVJeaOPaQnxkrL3+Jm8lMIlZlPXK67EzTxLfh+bWPPEx/A2 mw/lVe9+0LzRxqyeO2sPPk6zAxGMLBBFDPa1KwhQQjUjfw0+Y6mW+UhBvWPARoZoAhhx 3NIe6nLC0USUcLNGpEtFENn39ET0H2KFpjCc+T+oQ+MmhyKWUcocKIJYXSP5h9n692Vk DbO/2h6H1Okg7J8iMZxlaYQcFkpDGPzd4zwiIKytYPsSXHdO2czSYh/wsxTjG6r/8GQa /bxESTAKG8tgStmxu2lzr0GkayM9+dSXWYDlrwCIi+sBXP1DaxgK0HKZP59RdMCindh8 EBVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=EMpDal56; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d25si4893546ioh.30.2021.04.20.12.07.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Apr 2021 12:07:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=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=@redhat.com header.s=mimecast20190719 header.b=EMpDal56; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:34648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYvip-0005RR-UI for alex.bennee@linaro.org; Tue, 20 Apr 2021 15:07:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYviQ-0005QD-A0 for qemu-arm@nongnu.org; Tue, 20 Apr 2021 15:07:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41327) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYviO-00025c-Ns for qemu-arm@nongnu.org; Tue, 20 Apr 2021 15:07:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618945636; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z+GqaHEE98VpsfTBpc6n0WESBAyIBmrUSF4SZxsZHMI=; b=EMpDal56Efmk1XLlPYwXKRpFIaTcb78Ck7e757niJmg8TEeng0VB1UQH+RnQPr2QglO+VF /NEPo4TbJt+V5xyboctH859KJGFrBnfu0saLraAmkiI8GtV5+WW4rLOIWcobpRNdC4PWfu 9HATSRV2SFVnM1SvuQGnN5tietznrOQ= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-377-5ZLY3ehpMtaeHk4npp_RKQ-1; Tue, 20 Apr 2021 15:07:12 -0400 X-MC-Unique: 5ZLY3ehpMtaeHk4npp_RKQ-1 Received: by mail-qv1-f71.google.com with SMTP id m19-20020a0cdb930000b029019a25080c40so12087693qvk.11 for ; Tue, 20 Apr 2021 12:07:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Z+GqaHEE98VpsfTBpc6n0WESBAyIBmrUSF4SZxsZHMI=; b=sZ6PdHNoZfCT/cHojztj8q/H4HzpjjTDfrLkEBoqMSJCh7GqRZ3p7N/74FszLPR1Ss fNjNkDdupWQ0DErDmGVSAydo6ZFMeen3eFIZ5l97DZXOzseEVTAoVaCfqWNDzOtVoSZ8 MFW0AC/hcEnM8PqokmLjxgHS9Ld2L0y4aoHMtZCIskp7/nOqKo0OOzfZl/V+mY8FwW9u MNixbqMNFd20dPrZBgJtXv/F/KJKLDodNtWFBcxAzPbZAI5i7XPtEiWv8lknNRxdK2eo BR2lAIvElmAoiiLZIteBT7vhKiDjZ+b67qDHMVAt+Vstx76CH2ZBvcvWxIH6yZuZG8Nz 4jRw== X-Gm-Message-State: AOAM533k7AEtaahdbkZuxZqDdJ1te4CJoHnSlflhgq/H+HkqXFKmRbcv 8ss65Y+XmymrCvwDSTRdmQ8bEOj5EINcKyjrIze+1UTcF4sOBIUQa7QHAv2fW3icfDitVSGGckz clnLlcDMulX17 X-Received: by 2002:a0c:9b82:: with SMTP id o2mr28862694qve.47.1618945632100; Tue, 20 Apr 2021 12:07:12 -0700 (PDT) X-Received: by 2002:a0c:9b82:: with SMTP id o2mr28862675qve.47.1618945631831; Tue, 20 Apr 2021 12:07:11 -0700 (PDT) Received: from xz-x1 (bras-base-toroon474qw-grc-88-174-93-75-154.dsl.bell.ca. [174.93.75.154]) by smtp.gmail.com with ESMTPSA id h193sm3024624qke.90.2021.04.20.12.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 12:07:11 -0700 (PDT) Date: Tue, 20 Apr 2021 15:07:09 -0400 From: Peter Xu To: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Subject: Re: [PATCH v2 00/11] memory: Forbid mapping AddressSpace root MemoryRegion Message-ID: <20210420190709.GE4440@xz-x1> References: <20210417103028.601124-1-f4bug@amsat.org> MIME-Version: 1.0 In-Reply-To: <20210417103028.601124-1-f4bug@amsat.org> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=216.205.24.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@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 , qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?utf-8?Q?C=C3=A9dric?= Le Goater , Paolo Bonzini , =?utf-8?B?SGVydsOp?= Poussineau , David Gibson Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: AJMVy5c1i5e+ On Sat, Apr 17, 2021 at 12:30:17PM +0200, Philippe Mathieu-Daudé wrote: > AddressSpace are physical address view and shouldn't be using > non-zero base address. The correct way to map a MR used as AS > root is to use a MR alias. Today when I rethink this, I figured another way (maybe easier?) to fix the issue. The major problem so far we had is that mr->addr can be anything for a root mr if it's added as subregion of another mr. E.g. in current implementation of mtree_print_mr() MR.addr is constantly used as an offset value: cur_start = base + mr->addr; However afaict mr->addr is defined as "relative offset of this mr to its container", as in memory_region_add_subregion_common(). Say, mr->addr is undefined from that pov if mr->container==NULL, as this MR belongs to nobody. And if it's defined, it's only meaning is in its container's context (or say, address space) only. That said, when we do mtree_print_mr(), another solution could be as simple as, not referencing mr->addr if we _know_ we're working on the root mr, as this is definitely _not_ in the context of the mr's container, even if it has one container after all: ---8<--- diff --git a/softmmu/memory.c b/softmmu/memory.c index d4493ef9e43..d71fb8ecc89 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2940,7 +2940,7 @@ static void mtree_print_mr(const MemoryRegion *mr, unsigned int level, return; } - cur_start = base + mr->addr; + cur_start = base + (level == 1) ? 0 : mr->addr; cur_end = cur_start + MR_SIZE(mr->size); /* ---8<--- Phil, do you think it'll work too to fix the strange offset value dumped in "info mtree"? I don't know (even if it works, perhaps I've missed something) which is better, as current series seems cleaner, then any mr will either belong to a AS or a MR (never both!), but just raise it up. Thanks, -- Peter Xu