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 X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A840C433F5 for ; Tue, 7 Sep 2021 15:14:06 +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 9AE2F6112D for ; Tue, 7 Sep 2021 15:14:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9AE2F6112D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:42868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNcnT-00026n-0M for qemu-devel@archiver.kernel.org; Tue, 07 Sep 2021 11:14:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNcgg-0003xU-CL for qemu-devel@nongnu.org; Tue, 07 Sep 2021 11:07:02 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:39721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mNcgd-0005hF-KR for qemu-devel@nongnu.org; Tue, 07 Sep 2021 11:07:02 -0400 Received: by mail-wm1-x332.google.com with SMTP id u26-20020a05600c441a00b002f66b2d8603so2096608wmn.4 for ; Tue, 07 Sep 2021 08:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=G/pCJL7qiT2UsMwGYhBVGmFYsPWmxtAI+srQ20ormhw=; b=ieRe9PaLZJitUpPYPBEOnNuij6hy6p96iWRBmBM5NQRbIPdZJsgeyiYVUEX0hyw7OB WKtw92f8vdMsUqVpnJvOKFZ+PKInvDQbVzJGgp08jzQm7rYDx/ibJZOr7L0win1mlYI9 gTs202Hvt3pmZODa8HkFQgPKH7urLAjXGo+X8m8FgbSt1jtpVGtJQmIjzDrfLlaAYTGA qMFXIVxQ08iofw8pNyq6nWcnIqi1oW1bBdT97thfPI7M02ufX0kq4o8Q+PRVISPnQsKt fAhExzwnQM5sEmStUjDmV4sbujTSsm1npouYqEbMxGoyRbsUomjiSX2aHqwpUHTGN0DQ zQ+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=G/pCJL7qiT2UsMwGYhBVGmFYsPWmxtAI+srQ20ormhw=; b=Saq1LukxvK/AuD6mUJwn5GQwdwMQdCtaopBTCEbIRUiN5JNFnztPgJJv9t1jzz78I0 /KxQ1NFeD+hmE3B/LK4PRlrGCjS8jU6GhS7t3qcLN/w8NUw7pFE2PDCAH0KjksJwSvKO cJxDFBqLMHe8p3VYT0Hf1m/S/1EIRpTdQ/094qCt82lBslqwfLtaN0FUi6s4y96Vl5W4 IPuvTFRrz6zBBfJt3IC8m7eMrarS/+fWCXwCERr7SWF11MUNt1LtkK/rSXfnnIzt904y dzlktI6t3Wb+C7crVc1aLPfjHj+xuoZZv6iz9CW03HoXxLalgri9JUsO1ivgexbEioG6 ODOg== X-Gm-Message-State: AOAM532s0f+jmt+IzbVPN7Wp29VYTseD03+WmWPVy5c1fQC9rBJlgJGh /M0COmnX8ZxlZFLfF3BO8aOiNgVVohcxebYQsyewZg== X-Google-Smtp-Source: ABdhPJybqw1zB5BZPa1peyit0cRU1aoBje06zTjC0Z0ghhmTAWvWBxcAGd5/N87ItfMfaXaowtY/4mNWijARsuxerdM= X-Received: by 2002:a7b:ce87:: with SMTP id q7mr4612072wmj.126.1631027217626; Tue, 07 Sep 2021 08:06:57 -0700 (PDT) MIME-Version: 1.0 References: <20210307222625.347268-1-f4bug@amsat.org> <6f13948a-1a33-1eb3-90d0-106afbb2caf8@redhat.com> In-Reply-To: From: Peter Maydell Date: Tue, 7 Sep 2021 16:06:08 +0100 Message-ID: Subject: Re: [PATCH 0/4] hw/block/pflash_cfi01: Remove pflash_cfi01_get_memory() To: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: Kevin Wolf , Aleksandar Rikalo , Eduardo Habkost , Qemu-block , "Michael S. Tsirkin" , QEMU Trivial , Richard Henderson , QEMU Developers , Max Reitz , Max Filippov , Paolo Bonzini , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , Aurelien Jarno Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Tue, 7 Sept 2021 at 15:45, Philippe Mathieu-Daud=C3=A9 = wrote: > The problems I see: > > - pflash_cfi01_get_memory() doesn't really document what it returns, > simply an internal MemoryRegion* in pflash device. Neither we > document this is a ROMD device providing a RAM buffer initialized > by qemu_ram_alloc(). > > - to update the flash content, we get the internal buffer via > memory_region_get_ram_ptr(). If the pflash implementation is > changed (.i.e. reworked to expose a MR container) we break > everything. > > - memory_region_get_ram_ptr() doesn't do any check on the MR type, > it simply calls qemu_map_ram_ptr(mr->ram_block, offset). Using memory_region_get_ram_ptr() is tricky to get right, too -- if you're writing directly to the underlying ram while the system is running you need to use memory_region_flush_rom_device() to make sure it's marked dirty. I think the current users of this on the pflash devices get away with it because they do it during initial machine init. -- PMM