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 6DDB0C433EF for ; Wed, 10 Nov 2021 20:15:08 +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 1A6786109F for ; Wed, 10 Nov 2021 20:15:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1A6786109F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:52090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mktzv-00029u-1q for qemu-devel@archiver.kernel.org; Wed, 10 Nov 2021 15:15:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mktz7-0001L9-LC; Wed, 10 Nov 2021 15:14:17 -0500 Received: from [2607:f8b0:4864:20::934] (port=45992 helo=mail-ua1-x934.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mktz5-00036V-RE; Wed, 10 Nov 2021 15:14:17 -0500 Received: by mail-ua1-x934.google.com with SMTP id ay21so7296898uab.12; Wed, 10 Nov 2021 12:14:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=fR9j95dndfD8ybie40dEBSzFFWDnEbUuSu178/AMUis=; b=htmmBYGgzZ4utyszuVmeUUJiqpAIGzbCFFDTlUNnUT3OfNZBxfOlZwx2IatEIb2CU8 svjL+lHBS0BB9E0r0Vg3aYV42tWCPYQlyIQjgC6ZQODkMcGgJzuYcHGzRezOW+8BGQjC FBAxuD9Fyu3oevqqXAGmnIJ4vp/qVHXgtyxQbs8/h0hIyyKrWioH11hUvPUWX/69pfk2 d1x0D3XKNdXj53UP1QhbLMk44YM+UjmLC8+EA9JyngphJBOslMr732Wb70uJWaC1pzMQ 27mNQnQHNCwyzBije7XSU/ZRlku2bxA+7kyvFVuDW8+51054lltZvO2aXudDvB5miw+H xLLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=fR9j95dndfD8ybie40dEBSzFFWDnEbUuSu178/AMUis=; b=8GXTgwkhGlMHfkKadYpIkpnKGIl58i0hY6KoIzXdakdaqjwobCTjDgxfzGmn46zTvk vjPJtMVFHxDN19WkAoq2Pml89uFRAuBPonTlHoryUbeF3uzwTEbsXl1grD5Qx7vzDkr0 8g2Qv1DUlBlAdFMg5B/pag/hC5QLYxshmm1c3kVrSoQ2K28Oq8XpQKY7d4i90gctCYTM q50FD4QVb1wLYdi9MWF7k0kDx7nirKUc/z8aR4668xcAdD7r0utXemMKsqS/i/44pwS9 wPJfghzBc0voHgaf05imB76Lb9flinAcmjNEvkxauijKqSA4lwat+czWKjQGCXydkk6+ dU9A== X-Gm-Message-State: AOAM532c9Y3oA/UHlbQFcEe7g247R9N4sbv01ieDHXCWOOIlanVPq7ec jf5UhRNJVLVNs2XEQwQjtwI= X-Google-Smtp-Source: ABdhPJydvG8ii84AVbiCrdQa6jnMsNQwlsWJTRkf2C6PVd4ISIF5UmWBbYCC7QEct53Jj57D5b0oMA== X-Received: by 2002:a9f:2d8c:: with SMTP id v12mr2479809uaj.25.1636575254329; Wed, 10 Nov 2021 12:14:14 -0800 (PST) Received: from [192.168.10.222] ([189.79.219.109]) by smtp.gmail.com with ESMTPSA id y28sm628335vkl.22.2021.11.10.12.14.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Nov 2021 12:14:14 -0800 (PST) Message-ID: <113918f5-49d5-2dc9-4902-0051c785d3ef@gmail.com> Date: Wed, 10 Nov 2021 17:14:10 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH 1/1] ppc/mmu_helper.c: do not truncate 'ea' in booke206_invalidate_ea_tlb() Content-Language: en-US To: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , qemu-devel@nongnu.org References: <20211110184545.1981500-1-danielhb413@gmail.com> <00d2bc57-5e12-7db6-7ddc-44bd198b53d0@amsat.org> From: Daniel Henrique Barboza In-Reply-To: <00d2bc57-5e12-7db6-7ddc-44bd198b53d0@amsat.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::934 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::934; envelope-from=danielhb413@gmail.com; helo=mail-ua1-x934.google.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, NICE_REPLY_A=-1.678, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Graf , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 11/10/21 15:52, Philippe Mathieu-Daudé wrote: > +Alexander > > On 11/10/21 19:45, Daniel Henrique Barboza wrote: >> 'tlbivax' is implemented by gen_tlbivax_booke206() via >> gen_helper_booke206_tlbivax(). In case the TLB needs to be flushed, >> booke206_invalidate_ea_tlb() is called. All these functions, but >> booke206_invalidate_ea_tlb(), uses a 64-bit effective address 'ea'. >> >> booke206_invalidate_ea_tlb() uses an uint32_t 'ea' argument that >> truncates the original 'ea' value for apparently no particular reason. >> This function retrieves the tlb pointer by calling booke206_get_tlbm(), >> which also uses a target_ulong address as parameter - in this case, a >> truncated 'ea' address. All the surrounding logic considers the >> effective TLB address as a 64 bit value, aside from the signature of >> booke206_invalidate_ea_tlb(). >> >> Last but not the least, PowerISA 2.07B section 6.11.4.9 [2] makes it >> clear that the effective address "EA" is a 64 bit value. >> >> Commit 01662f3e5133 introduced this code and no changes were made ever >> since. An user detected a problem with tlbivax [1] stating that this >> address truncation was the cause. This same behavior might be the source >> of several subtle bugs that were never caught. >> >> For all these reasons, this patch assumes that this address truncation >> is the result of a mistake/oversight of the original commit, and changes >> booke206_invalidate_ea_tlb() 'ea' argument to target_ulong. >> >> [1] https://gitlab.com/qemu-project/qemu/-/issues/52 >> [2] https://wiki.raptorcs.com/wiki/File:PowerISA_V2.07B.pdf >> >> Fixes: 01662f3e5133 ("PPC: Implement e500 (FSL) MMU") >> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/52 >> Signed-off-by: Daniel Henrique Barboza >> --- >> target/ppc/mmu_helper.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c >> index 2cb98c5169..21cdae4c6d 100644 >> --- a/target/ppc/mmu_helper.c >> +++ b/target/ppc/mmu_helper.c >> @@ -1216,7 +1216,7 @@ void helper_booke206_tlbsx(CPUPPCState *env, target_ulong address) >> } >> >> static inline void booke206_invalidate_ea_tlb(CPUPPCState *env, int tlbn, >> - uint32_t ea) >> + target_ulong ea) > > Reviewed-by: Philippe Mathieu-Daudé > > But I wonder if vaddr is not more appropriated here, > see "hw/core/cpu.h": Just saw other mmu related code in target/ppc that uses 'vaddr' in this context, so I believe it is appropriate to use it here. I'll send a v2. Thanks, Daniel > > /** > * vaddr: > * Type wide enough to contain any #target_ulong virtual address. > */ >