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=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 D0FFEC2BB48 for ; Tue, 15 Dec 2020 23:26:22 +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 6C5E32335A for ; Tue, 15 Dec 2020 23:26:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C5E32335A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpJi1-0001g3-GX for qemu-devel@archiver.kernel.org; Tue, 15 Dec 2020 18:26:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpJXz-0004aM-V3 for qemu-devel@nongnu.org; Tue, 15 Dec 2020 18:16:00 -0500 Received: from mail-ej1-x643.google.com ([2a00:1450:4864:20::643]:36925) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kpJXu-00079R-CX for qemu-devel@nongnu.org; Tue, 15 Dec 2020 18:15:55 -0500 Received: by mail-ej1-x643.google.com with SMTP id ga15so30082723ejb.4 for ; Tue, 15 Dec 2020 15:15:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=9dCcW2yfDp7PaJ6DVJDhuVJLOrCCNCTbY7slHpIWSxM=; b=IcZLLArA5vsruhnHAA/Q4+8qO090ljVVEf9iGTmuB6awSZ2UA8O6F6kXU9Tl6wwN6p FF3piSrLk7HGgmdfMxlo+pyXB8Ld9Y//TXgW2pYV2fftOo90vQUcOx2zVkUrzw/M3ktQ QsrrHyVHMUvha1ICNh8WAkVmDMNxGRz9NoXKSWlIypTFmamSaiopW7kbpt1IBeXFvQBJ 7m9YE4rgMLuth+N1Esbm9j0NYhXY81wGF3DFCnPuMtCzNC1aIz0kqe+PTROgoDLps9hH 6OgKmrbIHC/WLDSn63XJCSzL5xvmaHXenQVu+2UpLbekBl+VN1jFrlKkieZpUIglJrn2 K+BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=9dCcW2yfDp7PaJ6DVJDhuVJLOrCCNCTbY7slHpIWSxM=; b=PtX2zTTPwEoqOkoMr4lZPjwvFkbnU1FVURFzO6F71cLFVAQuH3ZgKSKryLjiKNMxWR cKAgh2xXXDr1fSNgQH+OSLcz5Oypo1A8aCGNrjk7X8vzJCUJZgG76Y2fICRaEqK9ol3G TAA5KEvLaoFkY3Im7rUL7nJDKnXsrXe+Orue21zbh6G9Vp6UKHO6byqThTx7f/dtVclj H9uXqTaX0Kqq+iIBcDCiQ9cE430dsmEAzIDU222aOF0nJ5g9O9BnRLgxSfW1d6VrrThi jbpky+s/Gv5xMH6k0+KTu8OoyEVZFtyx+IuCt6nHiwpu4xR0n2+YzgFmShwcBmCpfJ1Q EokQ== X-Gm-Message-State: AOAM530fb7nvvvi8AaNwAe0uF6OvG8AoO1GVhsandi6YTP7VXOB9USkK Pou3+5rV1TtsIwENxqieUDew2i1OnXoX6Q== X-Google-Smtp-Source: ABdhPJwFm4UkuaLZj6y0cFS3mSnuBgCO0K7vXYybfnS2R+8aA92ZMT3Q/llTmm5erEk5Jm+7Chg/Gg== X-Received: by 2002:a17:906:524a:: with SMTP id y10mr28910940ejm.97.1608074151623; Tue, 15 Dec 2020 15:15:51 -0800 (PST) Received: from [192.168.1.36] (101.red-88-21-206.staticip.rima-tde.net. [88.21.206.101]) by smtp.gmail.com with ESMTPSA id n9sm19069016edy.83.2020.12.15.15.15.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Dec 2020 15:15:50 -0800 (PST) Subject: Re: [PATCH v4 07/43] tcg: Add in_code_gen_buffer To: Richard Henderson , qemu-devel@nongnu.org References: <20201214140314.18544-1-richard.henderson@linaro.org> <20201214140314.18544-8-richard.henderson@linaro.org> <0ca448f1-bbd1-36b3-67c7-d430005db00d@amsat.org> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Message-ID: <8461d292-5946-08c0-0e92-16db25e791d4@amsat.org> Date: Wed, 16 Dec 2020 00:15:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::643; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x643.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 12/15/20 11:43 PM, Richard Henderson wrote: > On 12/14/20 4:09 PM, Philippe Mathieu-Daudé wrote: >> On 12/14/20 3:02 PM, Richard Henderson wrote: >>> Create a function to determine if a pointer is within the buffer. >>> >>> Signed-off-by: Richard Henderson >>> --- >>> include/tcg/tcg.h | 6 ++++++ >>> accel/tcg/translate-all.c | 26 ++++++++------------------ >>> 2 files changed, 14 insertions(+), 18 deletions(-) >>> >>> diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h >>> index bb1e97b13b..e4d0ace44b 100644 >>> --- a/include/tcg/tcg.h >>> +++ b/include/tcg/tcg.h >>> @@ -680,6 +680,12 @@ extern __thread TCGContext *tcg_ctx; >>> extern void *tcg_code_gen_epilogue; >>> extern TCGv_env cpu_env; >>> >>> +static inline bool in_code_gen_buffer(const void *p) >>> +{ >>> + const TCGContext *s = &tcg_init_ctx; >>> + return (size_t)(p - s->code_gen_buffer) <= s->code_gen_buffer_size; >> >> If 'p == s->code_gen_buffer + s->code_gen_buffer_size', >> is it really "in" the buffer? > > Well, sort of. > > Compare the fact that in C, a pointer to the end of an array is valid as a > pointer even though it can't be dereferenced. This is a pointer to the end of > the buffer. > > Extra commentary required? Preferably, since you change from '<' to '<=', this would make it clearer, then no question asked :) With it: Reviewed-by: Philippe Mathieu-Daudé Thanks, Phil.