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=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, 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 525EEC2BB48 for ; Tue, 15 Dec 2020 22:47:48 +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 D3D7B22D05 for ; Tue, 15 Dec 2020 22:47:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3D7B22D05 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpJ6g-0004Vt-II for qemu-devel@archiver.kernel.org; Tue, 15 Dec 2020 17:47:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpJ2O-0000Aj-2W for qemu-devel@nongnu.org; Tue, 15 Dec 2020 17:43:21 -0500 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:38449) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kpJ2L-0007YP-1a for qemu-devel@nongnu.org; Tue, 15 Dec 2020 17:43:19 -0500 Received: by mail-oi1-x242.google.com with SMTP id x13so16166783oic.5 for ; Tue, 15 Dec 2020 14:43:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=Tac8R0/4/dnpUcxt6Aj8QnSKzTmEC8dVmvD5YDU6yl4=; b=ogNklUOdINw15uqD1JRGpwL9IF1VNZbbWTCMaXfR5zxYB8pwMsR+zqlgF5nZJnhk5u SPrEmippAr3LM29ORDYiACY+3hSb2KEINSENdQZm+KNprYYbcyYvv1YyT8pnB58nmbTn OWpbIwTyyMnOaMXFpRvRfhDUyxussOwGtLqQaKJNlzE34lA/6R+zr1XeBQicnX3m32d9 dB6p8etRFtPw87geHrbX7Ay+NUEijDk36qqafLZ9R9mXvRCM9rSlIntorx8rGjkb3rym 5l0qqVTGfH578s5R1LdVm2/PPvgDuNYqtwzVH4WeLGsmeKNAGPqcqu7mSGAHhR0I48ra BC8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Tac8R0/4/dnpUcxt6Aj8QnSKzTmEC8dVmvD5YDU6yl4=; b=cokc/naoR/TKFyKnBgy8Kq4QpOXO+hSiLBkn8kKm+wVQFjrn6b+ScRE19KCuF+84vz q6IGP6+gsEY6fhVL1m3uCk7gGdsjvdWjiTPxofDU8uF541/tDkEiwHte/EaBq2WUnK1r UqDXfPmEgRR0tfauuyhL78RGS+IoXy93tlEqciB1fUhXI674Lr7dQt7ROCDDh5nFp8vo Ak+XvSHrdnfD1WgueGkSmag1X/W4WDSw6xlHslikGZSErKOpbCWQqctv34+wLyXitMrS 5oRHHf25+Kz4xNe4zyZMbAXbJjHiOEvoqoJLD0JrqATty5NirAYWr4bX4jtZVaXY2mG5 98QQ== X-Gm-Message-State: AOAM533yb1nZivUrJg2kDK1bD0EyAUUFQPZqelfTKdk9mQ/DiW7UHl/v b3Eg5VdBwD5wM3oWg2oUtsWEBcPdv7O8+qfI X-Google-Smtp-Source: ABdhPJyAbwAaGD5lnDegWLK088FSpmP1W6RA/CEtkmQXIgZsgfQiDGrsbTkoYcCAQCUSzeo+X7t47g== X-Received: by 2002:aca:b587:: with SMTP id e129mr587060oif.90.1608072195427; Tue, 15 Dec 2020 14:43:15 -0800 (PST) Received: from [10.10.121.52] (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id q21sm10030oog.30.2020.12.15.14.43.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Dec 2020 14:43:14 -0800 (PST) Subject: Re: [PATCH v4 07/43] tcg: Add in_code_gen_buffer To: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , 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: Richard Henderson Message-ID: Date: Tue, 15 Dec 2020 16:43:12 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <0ca448f1-bbd1-36b3-67c7-d430005db00d@amsat.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::242; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x242.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, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.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/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? r~