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=-10.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 1A1BCC433EF for ; Fri, 17 Sep 2021 15:13:39 +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 A7C3661246 for ; Fri, 17 Sep 2021 15:13:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A7C3661246 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bsdimp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:39486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRFYX-0004iK-Rf for qemu-devel@archiver.kernel.org; Fri, 17 Sep 2021 11:13:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRFWD-0001qi-8V for qemu-devel@nongnu.org; Fri, 17 Sep 2021 11:11:14 -0400 Received: from mail-vs1-xe2f.google.com ([2607:f8b0:4864:20::e2f]:44589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mRFWB-0006al-KL for qemu-devel@nongnu.org; Fri, 17 Sep 2021 11:11:13 -0400 Received: by mail-vs1-xe2f.google.com with SMTP id c28so9693682vsh.11 for ; Fri, 17 Sep 2021 08:11:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NS2LObVbBU7tQfz/wsIK/NF+M2XjKz7v99zi8d4RAvE=; b=P4dl+v/DqYD5px2Ge23WsKRRZfdwi/fHqqb6/7Lla5Si5Ak3NrhPi9ElyEdtqB6frY 0Te08nsHplxg2bqMkpN5BbGJxaM5niVFnjt8/kKumMxPF0TdsF1ycdV8SpOiaNcUfTqb eWcMFeU6doPQV0roTSL0X88yMK30I+3z2h57hlydNTy+p3Kzs3C2tsnxM39PzJ0H129l RfDKjaMDzCBRxtT9YhhwBftifDK+Z3iWdSimhLqqyF+7Ex8zOorj3IRBkvDkSKXdHn9E mdaAOD0KqhmvJVdyNXxtJMM41BBLyFeWTZdiQv+cfSK19Pmt2bqz5AqSrkiU1fIt6q63 2nEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NS2LObVbBU7tQfz/wsIK/NF+M2XjKz7v99zi8d4RAvE=; b=Hd+r8CwKnJfCnRQ0X4THOxY0hIgfrqjDW/SfJhpFgo51a7jXskoKLe8pCF9SUMtPB+ 4nax64D+KxFdfOmgMuVoc7hL6cbKXxCGodugDvQysZ6Di7xeMyojAocizbcjqugUzgAi S1akgmm7rH7RZ4e89yt1ibO37afOf69LxENaiGFnoP/IH9NL3bkVxGM1aPEpTOJwJ85q YH4OuJGjwYrwB144qD7AufemSphlRqinoSqD77qYHgW+xmHnEsutcvKAGEvMeOoTV6uS FP+0ZMUj32wlXCAQJ5ATBPu1GAtXbIh+cr5J8pVRq5S5uYT2Cvkwaf8YFMidqlDGrlj0 GfOw== X-Gm-Message-State: AOAM531W22G27fIQdU82muV+2In1pbdODVhTBdRyy29yXeB/Bc0DrmRI vFosgM+j8e9CNFWfLlp7kBS10MZcxzaY02BB3MwFLw== X-Google-Smtp-Source: ABdhPJzn0geJd3DyoK35UR2OzrFoze+U5FyzqqD9K2/OZmUXm3ZUoaNOc99His8o3GMwN2RF5KFD9lQ5g8HID2zwc+g= X-Received: by 2002:a05:6102:1161:: with SMTP id k1mr9056393vsg.6.1631891470092; Fri, 17 Sep 2021 08:11:10 -0700 (PDT) MIME-Version: 1.0 References: <20210917025635.32011-1-imp@bsdimp.com> <20210917025635.32011-2-imp@bsdimp.com> In-Reply-To: From: Warner Losh Date: Fri, 17 Sep 2021 09:10:59 -0600 Message-ID: Subject: Re: [PATCH 1/9] bsd-user: Apply e6deac9cf99 from linux-user (zero anonymous memory) To: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Content-Type: multipart/alternative; boundary="00000000000063391505cc3257b9" Received-SPF: none client-ip=2607:f8b0:4864:20::e2f; envelope-from=wlosh@bsdimp.com; helo=mail-vs1-xe2f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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: Chen Gang , Kyle Evans , Riku Voipio , Laurent Vivier , QEMU Developers , =?UTF-8?Q?Mika=C3=ABl_Urankar?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --00000000000063391505cc3257b9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Sep 17, 2021 at 9:02 AM Philippe Mathieu-Daud=C3=A9 wrote: > On 9/17/21 4:56 AM, Warner Losh wrote: > > From: Mika=C3=ABl Urankar > > > > linux-user/mmap.c: Always zero MAP_ANONYMOUS memory in mmap_frag() > > Please use it as subject, "bsd-user/mmap: Always zero MAP_ANONYMOUS > memory in mmap_frag()" > > Then describe: > > Similar to the equivalent linux-user commit e6deac9cf99, ... > OK. I have three commits like this, so I'll go ahead and edit all three. > > > > When mapping MAP_ANONYMOUS memory fragments, still need notice about to > > set it zero, or it will cause issues. > > > > Signed-off-by: Chen Gang > > Reviewed-by: Laurent Vivier > > Signed-off-by: Riku Voipio > > ^ These tags were for another file, not this one, please > remove them. > Gotcha. I wasn't completely sure what to do in this case since they describe that the work is able to be contributed so I could make a case either way. I'll remove them. Warner > > [ bsd-user merge by Mika=C3=ABl Urankar, updated for untagged by Warner= Losh ] > > Signed-off-by: Mika=C3=ABl Urankar > > Signed-off-by: Warner Losh > > --- > > bsd-user/mmap.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c > > index b40ab9045f..fc3c1480f5 100644 > > --- a/bsd-user/mmap.c > > +++ b/bsd-user/mmap.c > > @@ -180,10 +180,12 @@ static int mmap_frag(abi_ulong real_start, > > if (prot_new !=3D (prot1 | PROT_WRITE)) > > mprotect(host_start, qemu_host_page_size, prot_new); > > } else { > > - /* just update the protection */ > > if (prot_new !=3D prot1) { > > mprotect(host_start, qemu_host_page_size, prot_new); > > } > > + if (prot_new & PROT_WRITE) { > > + memset(g2h_untagged(start), 0, end - start); > > + } > > } > > return 0; > > } > > > > --00000000000063391505cc3257b9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Fri, Sep 17, 2021 at 9:02 AM Phili= ppe Mathieu-Daud=C3=A9 <f4bug@amsat.o= rg> wrote:
mikael.urankar@gmail.com>
>
> linux-user/mmap.c: Always zero MAP_ANONYMOUS memory in mmap_frag()

Please use it as subject, "bsd-user/mmap: Always zero MAP_ANONYMOUS memory in mmap_frag()"

Then describe:

Similar to the equivalent linux-user commit e6deac9cf99, ...

OK. I have three commits like this, so I'll go ah= ead and edit all three.
=C2=A0
>
> When mapping MAP_ANONYMOUS memory fragments, still need notice about t= o
> set it zero, or it will cause issues.
>
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>

^ These tags were for another file, not this one, please
remove them.

Gotcha. I wasn't compl= etely sure what to do in this case since they
describe that the w= ork is able to be contributed so I could make a case either way.
=
I'll remove them.

Warner
<= div>=C2=A0
> [ bsd-user merge by Mika=C3=ABl Urankar, updated for untagged by Warne= r Losh ]
> Signed-off-by: Mika=C3=ABl Urankar <mikael.urankar@gmail.com>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>=C2=A0 bsd-user/mmap.c | 4 +++-
>=C2=A0 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c
> index b40ab9045f..fc3c1480f5 100644
> --- a/bsd-user/mmap.c
> +++ b/bsd-user/mmap.c
> @@ -180,10 +180,12 @@ static int mmap_frag(abi_ulong real_start,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (prot_new !=3D (prot1 | PROT_WRIT= E))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mprotect(host_start, q= emu_host_page_size, prot_new);
>=C2=A0 =C2=A0 =C2=A0 } else {
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 /* just update the protection */
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (prot_new !=3D prot1) {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mprotect(host_start, q= emu_host_page_size, prot_new);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (prot_new & PROT_WRITE) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 memset(g2h_untagged(start),= 0, end - start);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
>=C2=A0 =C2=A0 =C2=A0 }
>=C2=A0 =C2=A0 =C2=A0 return 0;
>=C2=A0 }
>

--00000000000063391505cc3257b9--