[Qemu-devel] [PATCH v1 4/9] tcg: Enforce single page access in probe_write() for !CONFIG_USER_ONLY

David Hildenbrand posted 9 patches 6 years, 5 months ago
Maintainers: Aleksandar Markovic <amarkovic@wavecomp.com>, Cornelia Huck <cohuck@redhat.com>, Aurelien Jarno <aurelien@aurel32.net>, Richard Henderson <rth@twiddle.net>, Aleksandar Rikalo <arikalo@wavecomp.com>, David Hildenbrand <david@redhat.com>, Riku Voipio <riku.voipio@iki.fi>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>
[Qemu-devel] [PATCH v1 4/9] tcg: Enforce single page access in probe_write() for !CONFIG_USER_ONLY
Posted by David Hildenbrand 6 years, 5 months ago
While the CONFIG_USER_ONLY variant can handle multiple pages (no MMU), the
!CONFIG_USER_ONLY variant can't and won't. We'll want to convert
probe_write() to return a host address (similar to tlb_vaddr_to_host())
soon. This only works on page granularity.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 accel/tcg/cputlb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index bb9897b25a..4b49ccb58a 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1064,6 +1064,8 @@ void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx,
     uintptr_t index = tlb_index(env, mmu_idx, addr);
     CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr);
 
+    g_assert(-(addr | TARGET_PAGE_MASK) >= size);
+
     if (!tlb_hit(tlb_addr_write(entry), addr)) {
         /* TLB entry is for a different page */
         if (!VICTIM_TLB_HIT(addr_write, addr)) {
-- 
2.21.0


Re: [Qemu-devel] [PATCH v1 4/9] tcg: Enforce single page access in probe_write() for !CONFIG_USER_ONLY
Posted by Richard Henderson 6 years, 5 months ago
On 8/23/19 3:07 AM, David Hildenbrand wrote:
> While the CONFIG_USER_ONLY variant can handle multiple pages (no MMU), the
> !CONFIG_USER_ONLY variant can't and won't. We'll want to convert
> probe_write() to return a host address (similar to tlb_vaddr_to_host())
> soon. This only works on page granularity.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  accel/tcg/cputlb.c | 2 ++
>  1 file changed, 2 insertions(+)

As I just mentioned in the previous, I think the two implementations should match.

Anyway, the "multiple pages" thing above still means exactly two, since if
there were three pages involved we were only probing two of them, and the third
could still be unmapped.


r~

Re: [Qemu-devel] [PATCH v1 4/9] tcg: Enforce single page access in probe_write() for !CONFIG_USER_ONLY
Posted by Richard Henderson 6 years, 5 months ago
On 8/23/19 8:28 AM, Richard Henderson wrote:
> On 8/23/19 3:07 AM, David Hildenbrand wrote:
>> While the CONFIG_USER_ONLY variant can handle multiple pages (no MMU), the
>> !CONFIG_USER_ONLY variant can't and won't. We'll want to convert
>> probe_write() to return a host address (similar to tlb_vaddr_to_host())
>> soon. This only works on page granularity.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>>  accel/tcg/cputlb.c | 2 ++
>>  1 file changed, 2 insertions(+)
> 
> As I just mentioned in the previous, I think the two implementations should match.
> 
> Anyway, the "multiple pages" thing above still means exactly two, since if
> there were three pages involved we were only probing two of them, and the third
> could still be unmapped.

Oh, but the actual code here, is fine.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~