qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Gustavo Romero <gustavo.romero@linaro.org>,
	qemu-devel@nongnu.org, peter.maydell@linaro.org,
	alex.bennee@linaro.org, richard.henderson@linaro.org
Subject: Re: [PATCH v2 5/9] target/arm: Make some MTE helpers widely available
Date: Fri, 14 Jun 2024 14:34:38 +0200	[thread overview]
Message-ID: <18b942c0-ffc9-48c6-aded-cd68fd54384a@linaro.org> (raw)
In-Reply-To: <e1a79665-62c3-5511-b7ad-baf8e72a17b1@linaro.org>

On 13/6/24 20:13, Gustavo Romero wrote:
> Hi Phil!
> 
> On 6/13/24 2:32 PM, Philippe Mathieu-Daudé wrote:
>> Hi Gustavo,
>>
>> On 13/6/24 19:20, Gustavo Romero wrote:
>>> Make the MTE helpers allocation_tag_mem_probe, load_tag1, and store_tag1
>>> available to other subsystems by moving them from mte_helper.c to a new
>>> header file, mte_helper.h.
>>>
>>> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
>>> ---
>>>   target/arm/tcg/mte_helper.c | 184 +------------------------------
>>>   target/arm/tcg/mte_helper.h | 211 ++++++++++++++++++++++++++++++++++++
>>>   2 files changed, 212 insertions(+), 183 deletions(-)
>>>   create mode 100644 target/arm/tcg/mte_helper.h


>>> + */
>>> +
>>> +#ifndef TARGET_ARM_MTE_H
>>> +#define TARGET_ARM_MTE_H
>>> +
>>> +#include "exec/exec-all.h"
>>
>> Why do you need "exec/exec-all.h"?
> 
> Otherwise one gets:
> 
> In file included from ../target/arm/gdbstub.c:30:
> ../target/arm/tcg/mte_helper.h: In function ‘allocation_tag_mem_probe’:
> ../target/arm/tcg/mte_helper.h:77:9: error: implicit declaration of 
> function ‘cpu_loop_exit_sigsegv’; did you mean ‘cpu_loop_exit_noexc’? 
> [-Werror=implicit-function-declaration]
>     77 |         cpu_loop_exit_sigsegv(env_cpu(env), ptr, ptr_access,
>        |         ^~~~~~~~~~~~~~~~~~~~~
>        |         cpu_loop_exit_noexc
> ../target/arm/tcg/mte_helper.h:77:9: error: nested extern declaration of 
> ‘cpu_loop_exit_sigsegv’ [-Werror=nested-externs]
> 
> Any other idea on how to satisfy it?

OK, I'll fix once I get my include/exec/ rework merged.

>>> +#include "exec/ram_addr.h"
>>> +#include "hw/core/tcg-cpu-ops.h"
>>> +#include "qemu/log.h"
>>> +
>>> +/**
>>> + * allocation_tag_mem_probe:
>>> + * @env: the cpu environment
>>> + * @ptr_mmu_idx: the addressing regime to use for the virtual address
>>> + * @ptr: the virtual address for which to look up tag memory
>>> + * @ptr_access: the access to use for the virtual address
>>> + * @ptr_size: the number of bytes in the normal memory access
>>> + * @tag_access: the access to use for the tag memory
>>> + * @probe: true to merely probe, never taking an exception
>>> + * @ra: the return address for exception handling
>>> + *
>>> + * Our tag memory is formatted as a sequence of little-endian nibbles.
>>> + * That is, the byte at (addr >> (LOG2_TAG_GRANULE + 1)) contains two
>>> + * tags, with the tag at [3:0] for the lower addr and the tag at [7:4]
>>> + * for the higher addr.
>>> + *
>>> + * Here, resolve the physical address from the virtual address, and 
>>> return
>>> + * a pointer to the corresponding tag byte.
>>> + *
>>> + * If there is no tag storage corresponding to @ptr, return NULL.
>>> + *
>>> + * If the page is inaccessible for @ptr_access, or has a watchpoint, 
>>> there are
>>> + * three options:
>>> + * (1) probe = true, ra = 0 : pure probe -- we return NULL if the 
>>> page is not
>>> + *     accessible, and do not take watchpoint traps. The calling 
>>> code must
>>> + *     handle those cases in the right priority compared to MTE traps.
>>> + * (2) probe = false, ra = 0 : probe, no fault expected -- the 
>>> caller guarantees
>>> + *     that the page is going to be accessible. We will take 
>>> watchpoint traps.
>>> + * (3) probe = false, ra != 0 : non-probe -- we will take both 
>>> memory access
>>> + *     traps and watchpoint traps.
>>> + * (probe = true, ra != 0 is invalid and will assert.)
>>> + */
>>> +static inline uint8_t *allocation_tag_mem_probe(CPUARMState *env, 
>>> int ptr_mmu_idx,
>>> +                                         uint64_t ptr, MMUAccessType 
>>> ptr_access,
>>> +                                         int ptr_size, MMUAccessType 
>>> tag_access,
>>> +                                         bool probe, uintptr_t ra)
>>
>> Do we really need an inlined function? Since it calls non-inlined
>> methods, I don't really see the point.
> 
> inline is just a hint and I think that in general at least the overhead
> for calling this function is reduced, but it's hard to say what the
> compile heuristics will do exactly without looking at the compiled code.

My question is about having the function definition in an header,
instead of its prototype (and the definition in a .c source file).

> But I can remove it for this function and leave it just for 
> {load,store}_tag1.



  reply	other threads:[~2024-06-14 12:35 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13 17:20 [PATCH v2 0/9] Add MTE stubs for aarch64 user mode Gustavo Romero
2024-06-13 17:20 ` [PATCH v2 1/9] gdbstub: Clean up process_string_cmd Gustavo Romero
2024-06-14 11:24   ` Alex Bennée
2024-06-13 17:20 ` [PATCH v2 2/9] gdbstub: Move GdbCmdParseEntry into a new header file Gustavo Romero
2024-06-14 11:25   ` Alex Bennée
2024-06-13 17:20 ` [PATCH v2 3/9] gdbstub: Add support for target-specific stubs Gustavo Romero
2024-06-14 11:27   ` Alex Bennée
2024-06-17  6:33     ` Gustavo Romero
2024-06-17  9:41       ` Alex Bennée
2024-06-13 17:20 ` [PATCH v2 4/9] target/arm: Fix exception case in allocation_tag_mem_probe Gustavo Romero
2024-06-14 11:29   ` Alex Bennée
2024-06-13 17:20 ` [PATCH v2 5/9] target/arm: Make some MTE helpers widely available Gustavo Romero
2024-06-13 17:32   ` Philippe Mathieu-Daudé
2024-06-13 18:13     ` Gustavo Romero
2024-06-14 12:34       ` Philippe Mathieu-Daudé [this message]
2024-06-17  6:37         ` Gustavo Romero
2024-06-13 17:21 ` [PATCH v2 6/9] target/arm: Factor out code for setting MTE TCF0 field Gustavo Romero
2024-06-13 17:35   ` Philippe Mathieu-Daudé
2024-06-13 18:15     ` Gustavo Romero
2024-06-14  9:02       ` Philippe Mathieu-Daudé
2024-06-17  6:56         ` Gustavo Romero
2024-06-14 11:21   ` Alex Bennée
2024-06-13 17:21 ` [PATCH v2 7/9] gdbstub: Make get cpu and hex conversion functions non-internal Gustavo Romero
2024-06-14 11:34   ` Alex Bennée
2024-06-13 17:21 ` [PATCH v2 8/9] gdbstub: Add support for MTE in user mode Gustavo Romero
2024-06-14 10:51   ` Alex Bennée
2024-06-14 16:16     ` Gustavo Romero
2024-06-13 17:21 ` [PATCH v2 9/9] tests/tcg/aarch64: Add MTE gdbstub tests Gustavo Romero
2024-06-14 11:42   ` Alex Bennée
2024-06-14 15:58     ` Gustavo Romero
2024-06-14 15:49 ` [PATCH v2 0/9] Add MTE stubs for aarch64 user mode Alex Bennée
2024-06-14 16:01   ` Gustavo Romero
2024-06-17  7:02   ` Gustavo Romero
2024-06-17  9:50     ` Alex Bennée
2024-06-24  5:40       ` Gustavo Romero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18b942c0-ffc9-48c6-aded-cd68fd54384a@linaro.org \
    --to=philmd@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=gustavo.romero@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).