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 06/17] linux-user: Do not use guest_addr_valid for h2g_valid
Date: Sat, 11 Jul 2020 12:30:21 -0700 [thread overview]
Message-ID: <d6c82116-8b33-716f-e76b-ecad2f24267d@linaro.org> (raw)
In-Reply-To: <CAFEAcA_ca4vAxB-2qfsXVUNPUdyFTJQtcBdkegn4ub8SOiR2TA@mail.gmail.com>
On 6/25/20 9:34 AM, Peter Maydell wrote:
> On Fri, 5 Jun 2020 at 05:17, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>>
>> This is the only use of guest_addr_valid that does not begin
>> with a guest address, but a host address being transformed to
>> a guest address.
>>
>> We will shortly adjust guest_addr_valid to handle guest memory
>> tags, and the host address should not be subjected to that.
>>
>> Move h2g_valid adjacent to the other h2g macros.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>> include/exec/cpu_ldst.h | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
>> index c14a48f65e..3930362e20 100644
>> --- a/include/exec/cpu_ldst.h
>> +++ b/include/exec/cpu_ldst.h
>> @@ -77,15 +77,16 @@ typedef uint64_t abi_ptr;
>> #else
>> #define guest_addr_valid(x) ((x) <= GUEST_ADDR_MAX)
>> #endif
>> -#define h2g_valid(x) guest_addr_valid((unsigned long)(x) - guest_base)
>>
>> static inline int guest_range_valid(unsigned long start, unsigned long len)
>> {
>> return len - 1 <= GUEST_ADDR_MAX && start <= GUEST_ADDR_MAX - len + 1;
>> }
>>
>> +#define h2g_valid(x) ((uintptr_t)(x) - guest_base <= GUEST_ADDR_MAX)
>
> The old implementation returns true for
> HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS
> (because there's a different definition of guest_addr_valid() there)
> but this one does a range check even in that case.
It's part and parcel with patch 1, wherein we are in fact attempting to limit
the guest address space to GUEST_ADDR_MAX.
That's why I put patch 1 first, so the behaviour change happens there.
>> #define h2g_nocheck(x) ({ \
>> - unsigned long __ret = (unsigned long)(x) - guest_base; \
>> + uintptr_t __ret = (uintptr_t)(x) - guest_base; \
>> (abi_ptr)__ret; \
>> })
>
> Why the type change? This seems unrelated.
Dropped. Though at some point we should purge unsigned long, as there is
always a clearer type to use.
r~
next prev parent reply other threads:[~2020-07-11 19:31 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
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 [this message]
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=d6c82116-8b33-716f-e76b-ecad2f24267d@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).