All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hvf: Avoid mapping regions < PAGE_SIZE as ram
@ 2021-10-25  8:25 Alexander Graf
  2021-10-25 10:56 ` Philippe Mathieu-Daudé
  2021-10-25 17:11 ` Paolo Bonzini
  0 siblings, 2 replies; 5+ messages in thread
From: Alexander Graf @ 2021-10-25  8:25 UTC (permalink / raw)
  To: Cameron Esfahani; +Cc: Paolo Bonzini, Roman Bolshakov, qemu-devel

HVF has generic memory listener code that adds all RAM regions as HVF RAM
regions. However, HVF can only handle page aligned, page granule regions.

So let's ignore regions that are not page aligned and sized. They will be
trapped as MMIO instead.

Signed-off-by: Alexander Graf <agraf@csgraf.de>
---
 accel/hvf/hvf-accel-ops.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index 6bf319d34c..090155853a 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -135,6 +135,12 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
         }
     }
 
+    if (int128_get64(section->size) & (qemu_real_host_page_size - 1) ||
+        section->offset_within_address_space & (qemu_real_host_page_size - 1)) {
+        /* Not page aligned, so we can not map as RAM */
+        add = false;
+    }
+
     mem = hvf_find_overlap_slot(
             section->offset_within_address_space,
             int128_get64(section->size));
-- 
2.30.1 (Apple Git-130)



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] hvf: Avoid mapping regions < PAGE_SIZE as ram
  2021-10-25  8:25 [PATCH] hvf: Avoid mapping regions < PAGE_SIZE as ram Alexander Graf
@ 2021-10-25 10:56 ` Philippe Mathieu-Daudé
  2021-10-25 17:11 ` Paolo Bonzini
  1 sibling, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-10-25 10:56 UTC (permalink / raw)
  To: Alexander Graf, Cameron Esfahani
  Cc: Paolo Bonzini, Roman Bolshakov, qemu-devel

Hi Alex,

On 10/25/21 10:25, Alexander Graf wrote:
> HVF has generic memory listener code that adds all RAM regions as HVF RAM
> regions. However, HVF can only handle page aligned, page granule regions.
> 
> So let's ignore regions that are not page aligned and sized. They will be
> trapped as MMIO instead.
> 
> Signed-off-by: Alexander Graf <agraf@csgraf.de>
> ---
>  accel/hvf/hvf-accel-ops.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
> index 6bf319d34c..090155853a 100644
> --- a/accel/hvf/hvf-accel-ops.c
> +++ b/accel/hvf/hvf-accel-ops.c
> @@ -135,6 +135,12 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
>          }
>      }
>  
> +    if (int128_get64(section->size) & (qemu_real_host_page_size - 1) ||
> +        section->offset_within_address_space & (qemu_real_host_page_size - 1)) {

Could we use QEMU_IS_ALIGNED() instead?

> +        /* Not page aligned, so we can not map as RAM */
> +        add = false;
> +    }
> +
>      mem = hvf_find_overlap_slot(
>              section->offset_within_address_space,
>              int128_get64(section->size));
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hvf: Avoid mapping regions < PAGE_SIZE as ram
  2021-10-25  8:25 [PATCH] hvf: Avoid mapping regions < PAGE_SIZE as ram Alexander Graf
  2021-10-25 10:56 ` Philippe Mathieu-Daudé
@ 2021-10-25 17:11 ` Paolo Bonzini
  2021-10-25 19:10   ` Alexander Graf
  1 sibling, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2021-10-25 17:11 UTC (permalink / raw)
  To: Alexander Graf, Cameron Esfahani; +Cc: Roman Bolshakov, qemu-devel

On 25/10/21 10:25, Alexander Graf wrote:
> HVF has generic memory listener code that adds all RAM regions as HVF RAM
> regions. However, HVF can only handle page aligned, page granule regions.
> 
> So let's ignore regions that are not page aligned and sized. They will be
> trapped as MMIO instead.
> 
> Signed-off-by: Alexander Graf <agraf@csgraf.de>
> ---
>   accel/hvf/hvf-accel-ops.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
> index 6bf319d34c..090155853a 100644
> --- a/accel/hvf/hvf-accel-ops.c
> +++ b/accel/hvf/hvf-accel-ops.c
> @@ -135,6 +135,12 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
>           }
>       }
>   
> +    if (int128_get64(section->size) & (qemu_real_host_page_size - 1) ||
> +        section->offset_within_address_space & (qemu_real_host_page_size - 1)) {
> +        /* Not page aligned, so we can not map as RAM */
> +        add = false;
> +    }
> +
>       mem = hvf_find_overlap_slot(
>               section->offset_within_address_space,
>               int128_get64(section->size));
> 

Queued, thanks.

Paolo



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hvf: Avoid mapping regions < PAGE_SIZE as ram
  2021-10-25 17:11 ` Paolo Bonzini
@ 2021-10-25 19:10   ` Alexander Graf
  2021-10-26 16:34     ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Graf @ 2021-10-25 19:10 UTC (permalink / raw)
  To: Paolo Bonzini, Cameron Esfahani; +Cc: Roman Bolshakov, qemu-devel


On 25.10.21 19:11, Paolo Bonzini wrote:
> On 25/10/21 10:25, Alexander Graf wrote:
>> HVF has generic memory listener code that adds all RAM regions as HVF 
>> RAM
>> regions. However, HVF can only handle page aligned, page granule 
>> regions.
>>
>> So let's ignore regions that are not page aligned and sized. They 
>> will be
>> trapped as MMIO instead.
>>
>> Signed-off-by: Alexander Graf <agraf@csgraf.de>
>> ---
>>   accel/hvf/hvf-accel-ops.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
>> index 6bf319d34c..090155853a 100644
>> --- a/accel/hvf/hvf-accel-ops.c
>> +++ b/accel/hvf/hvf-accel-ops.c
>> @@ -135,6 +135,12 @@ static void hvf_set_phys_mem(MemoryRegionSection 
>> *section, bool add)
>>           }
>>       }
>>   +    if (int128_get64(section->size) & (qemu_real_host_page_size - 
>> 1) ||
>> +        section->offset_within_address_space & 
>> (qemu_real_host_page_size - 1)) {
>> +        /* Not page aligned, so we can not map as RAM */
>> +        add = false;
>> +    }
>> +
>>       mem = hvf_find_overlap_slot(
>>               section->offset_within_address_space,
>>               int128_get64(section->size));
>>
>
> Queued, thanks.


You probably want v2 instead :)

Alex




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hvf: Avoid mapping regions < PAGE_SIZE as ram
  2021-10-25 19:10   ` Alexander Graf
@ 2021-10-26 16:34     ` Paolo Bonzini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2021-10-26 16:34 UTC (permalink / raw)
  To: Alexander Graf, Cameron Esfahani; +Cc: Roman Bolshakov, qemu-devel

On 25/10/21 21:10, Alexander Graf wrote:
>>>           }
>>>       }
>>>   +    if (int128_get64(section->size) & (qemu_real_host_page_size - 
>>> 1) ||
>>> +        section->offset_within_address_space & 
>>> (qemu_real_host_page_size - 1)) {
>>> +        /* Not page aligned, so we can not map as RAM */
>>> +        add = false;
>>> +    }
>>> +
>>>       mem = hvf_find_overlap_slot(
>>>               section->offset_within_address_space,
>>>               int128_get64(section->size));
>>>
>>
>> Queued, thanks.
> 
> 
> You probably want v2 instead :)

That's actually what I had applied. :)

Paolo



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-26 16:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25  8:25 [PATCH] hvf: Avoid mapping regions < PAGE_SIZE as ram Alexander Graf
2021-10-25 10:56 ` Philippe Mathieu-Daudé
2021-10-25 17:11 ` Paolo Bonzini
2021-10-25 19:10   ` Alexander Graf
2021-10-26 16:34     ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.