From: Richard Henderson <richard.henderson@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm <qemu-arm@nongnu.org>,
QEMU Developers <qemu-devel@nongnu.org>,
Stephen Long <steplong@quicinc.com>
Subject: Re: [PATCH v2 01/17] tcg: Introduce target-specific page data for user-only
Date: Sat, 11 Jul 2020 14:42:21 -0700 [thread overview]
Message-ID: <d5659aa8-1e51-455f-c3be-379e3f224817@linaro.org> (raw)
In-Reply-To: <CAFEAcA-qybDD6GWYPFB6tMfTb9Kj+_bCKCxPyDYMZBr8EwbDmQ@mail.gmail.com>
On 6/25/20 9:20 AM, Peter Maydell wrote:
> On Fri, 5 Jun 2020 at 05:17, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>>
>> This data can be allocated by page_alloc_target_data() and
>> released by page_set_flags(start, end, prot | PAGE_RESET).
>>
>> This data will be used to hold tag memory for AArch64 MTE.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>
>> @@ -289,6 +295,8 @@ int walk_memory_regions(void *, walk_memory_regions_fn);
>> int page_get_flags(target_ulong address);
>> void page_set_flags(target_ulong start, target_ulong end, int flags);
>> int page_check_range(target_ulong start, target_ulong len, int flags);
>> +void *page_get_target_data(target_ulong address);
>> +void *page_alloc_target_data(target_ulong address, size_t size);
>
> Could we have a doc comment for any new function that's got
> global scope, please?
>
>> #endif
>>
>> CPUArchState *cpu_copy(CPUArchState *env);
>
>> +void *page_alloc_target_data(target_ulong address, size_t size)
>> +{
>> + PageDesc *p = page_find(address >> TARGET_PAGE_BITS);
>> + void *ret = NULL;
>> +
>> + if (p) {
>> + ret = p->target_data;
>> + if (!ret && (p->flags & PAGE_VALID)) {
>> + p->target_data = ret = g_malloc0(size);
>> + }
>> + }
>> + return ret;
>
> Can a PageDesc validly have p->target_data != NULL but
> p->flags with PAGE_VALID not set ?
No. But we can be called for a page that is not mapped (returning NULL) and
can be called for a page that already has associated data (returning the old
value).
> It's not clear to me why for a !PAGE_VALID page which
> has target_data already we return that pointer but
> if it doesn't have any we don't allocate: either
> "always allocate" or "always return NULL for non-valid pages"
> would seem more self-consistent.
I was expecting a non-valid page to have no data. I will rearrange this to
ret = NULL;
if (p->flags & PAGE_VALID) {
ret = p->target_data;
if (!ret) {
p->target_data = ret = g_malloc0(size);
}
}
which is probably clearer.
>> + /* FIXME: Move page flags and target_data for each page. */
>
> Is this something we're going to address later in the patchset?
I had not, but I should. Will fix.
r~
next prev parent reply other threads:[~2020-07-11 21:43 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-05 4:17 [PATCH v2 00/17] target-arm: Implement ARMv8.5-MemTag, user mode Richard Henderson
2020-06-05 4:17 ` [PATCH v2 01/17] tcg: Introduce target-specific page data for user-only Richard Henderson
2020-06-25 16:20 ` Peter Maydell
2020-07-11 21:42 ` Richard Henderson [this message]
2020-07-13 1:44 ` Richard Henderson
2020-06-05 4:17 ` [PATCH v2 02/17] linux-user: Introduce PAGE_ANON Richard Henderson
2020-06-25 16:23 ` Peter Maydell
2020-06-05 4:17 ` [PATCH v2 03/17] linux-user: Check for overflow in access_ok Richard Henderson
2020-06-25 16:25 ` Peter Maydell
2020-06-05 4:17 ` [PATCH v2 04/17] linux-user: Tidy VERIFY_READ/VERIFY_WRITE Richard Henderson
2020-06-25 16:29 ` Peter Maydell
2020-06-05 4:17 ` [PATCH v2 05/17] bsd-user: " Richard Henderson
2020-06-25 16:30 ` Peter Maydell
2020-06-05 4:17 ` [PATCH v2 06/17] linux-user: Do not use guest_addr_valid for h2g_valid Richard Henderson
2020-06-25 16:34 ` Peter Maydell
2020-07-11 19:30 ` Richard Henderson
2020-07-11 19:37 ` Richard Henderson
2020-06-05 4:17 ` [PATCH v2 07/17] linux-user: Fix guest_addr_valid vs reserved_va Richard Henderson
2020-06-25 16:37 ` Peter Maydell
2020-07-11 19:26 ` Richard Henderson
2020-06-05 4:17 ` [PATCH v2 08/17] exec: Add support for TARGET_TAGGED_ADDRESSES Richard Henderson
2020-06-25 16:43 ` Peter Maydell
2020-06-05 4:17 ` [PATCH v2 09/17] linux-user/aarch64: Implement PR_TAGGED_ADDR_ENABLE Richard Henderson
2020-06-25 16:46 ` Peter Maydell
2020-06-05 4:17 ` [PATCH v2 10/17] linux-user/aarch64: Implement PR_MTE_TCF and PR_MTE_TAG Richard Henderson
2020-06-25 16:50 ` Peter Maydell
2020-12-17 17:24 ` Richard Henderson
2020-06-05 4:17 ` [PATCH v2 11/17] linux-user/aarch64: Implement PROT_MTE Richard Henderson
2020-06-25 16:53 ` Peter Maydell
2020-06-05 4:17 ` [PATCH v2 12/17] linux-user/aarch64: Pass syndrome to EXC_*_ABORT Richard Henderson
2020-06-25 17:00 ` Peter Maydell
2020-06-05 4:17 ` [PATCH v2 13/17] linux-user/aarch64: Signal SEGV_MTESERR for sync tag check fault Richard Henderson
2020-06-05 4:17 ` [PATCH v2 14/17] linux-user/aarch64: Signal SEGV_MTEAERR for async tag check error Richard Henderson
2020-06-05 4:17 ` [PATCH v2 15/17] target/arm: Add allocation tag storage for user mode Richard Henderson
2020-06-05 4:17 ` [PATCH v2 16/17] target/arm: Enable MTE for user-only Richard Henderson
2020-06-05 4:17 ` [PATCH v2 17/17] tests/tcg/aarch64: Add mte smoke tests Richard Henderson
2020-06-25 17:13 ` [PATCH v2 00/17] target-arm: Implement ARMv8.5-MemTag, user mode Peter Maydell
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=d5659aa8-1e51-455f-c3be-379e3f224817@linaro.org \
--to=richard.henderson@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=steplong@quicinc.com \
/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).