From: Gustavo Romero <gustavo.romero@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
qemu-devel@nongnu.org, peter.maydell@linaro.org,
alex.bennee@linaro.org, richard.henderson@linaro.org
Subject: Re: [PATCH v2 6/9] target/arm: Factor out code for setting MTE TCF0 field
Date: Thu, 13 Jun 2024 15:15:20 -0300 [thread overview]
Message-ID: <5a93c441-d1a4-6f60-1b35-a313dd9a1b62@linaro.org> (raw)
In-Reply-To: <20996ca9-9feb-42ee-8850-af265f77f72b@linaro.org>
Hi Phil,
On 6/13/24 2:35 PM, Philippe Mathieu-Daudé wrote:
> On 13/6/24 19:21, Gustavo Romero wrote:
>> Factor out the code used for setting the MTE TCF0 field from the prctl
>> code into a convenient function. Other subsystems, like gdbstub, need to
>> set this field as well, so keep it as a separate function to avoid
>> duplication and ensure consistency in how this field is set across the
>> board.
>>
>> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
>> ---
>> linux-user/aarch64/target_prctl.h | 22 ++-----------
>> target/arm/mte.h | 53 +++++++++++++++++++++++++++++++
>> 2 files changed, 55 insertions(+), 20 deletions(-)
>> create mode 100644 target/arm/mte.h
>
>
>> diff --git a/target/arm/mte.h b/target/arm/mte.h
>> new file mode 100644
>> index 0000000000..89712aad70
>> --- /dev/null
>> +++ b/target/arm/mte.h
>> @@ -0,0 +1,53 @@
>> +/*
>> + * ARM MemTag convenience functions.
>> + *
>> + * Copyright (c) 2024 Linaro, Ltd.
>> + *
>> + * This library is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU Lesser General Public
>> + * License as published by the Free Software Foundation; either
>> + * version 2.1 of the License, or (at your option) any later version.
>> + *
>> + * This library is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with this library; if not, see <http://www.gnu.org/licenses/>.
>> + */
>> +
>> +#ifndef MTE_H
>> +#define MTE_H
>> +
>> +#ifdef CONFIG_TCG
>> +#ifdef CONFIG_USER_ONLY
>> +#include "sys/prctl.h"
>> +
>> +static void set_mte_tcf0(CPUArchState *env, abi_long value)
>
> Either declare it inlined (otherwise we'll get multiple symbols
> declared if this header is included multiple times), or
> preferably only expose the prototype.
>
> Also I'd use the 'arm_' prefix.
Thanks, I forgot to add the inline hint and was really wondering if
I should add the arm_ prefix.
>> +{
>> + /*
>> + * Write PR_MTE_TCF to SCTLR_EL1[TCF0].
>> + *
>> + * The kernel has a per-cpu configuration for the sysadmin,
>> + * /sys/devices/system/cpu/cpu<N>/mte_tcf_preferred,
>> + * which qemu does not implement.
>> + *
>> + * Because there is no performance difference between the modes, and
>> + * because SYNC is most useful for debugging MTE errors, choose SYNC
>> + * as the preferred mode. With this preference, and the way the API
>> + * uses only two bits, there is no way for the program to select
>> + * ASYMM mode.
>> + */
>> + unsigned tcf = 0;
>> + if (value & PR_MTE_TCF_SYNC) {
>> + tcf = 1;
>> + } else if (value & PR_MTE_TCF_ASYNC) {
>> + tcf = 2;
>> + }
>> + env->cp15.sctlr_el[1] = deposit64(env->cp15.sctlr_el[1], 38, 2, tcf);
>> +}
>> +#endif /* CONFIG_USER_ONLY */
>> +#endif /* CONFIG_TCG */
>> +
>> +#endif /* MTE_H */
>
next prev parent reply other threads:[~2024-06-13 18:15 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é
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 [this message]
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=5a93c441-d1a4-6f60-1b35-a313dd9a1b62@linaro.org \
--to=gustavo.romero@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=philmd@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).