[PATCH v3 6/6] include/exec: Introduce TARGET_PAGE_ENTRY_EXTRA

Richard Henderson posted 6 patches 3 years, 5 months ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, Yanan Wang <wangyanan55@huawei.com>, Peter Maydell <peter.maydell@linaro.org>, David Hildenbrand <david@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Thomas Huth <thuth@redhat.com>
[PATCH v3 6/6] include/exec: Introduce TARGET_PAGE_ENTRY_EXTRA
Posted by Richard Henderson 3 years, 5 months ago
Allow the target to cache items from the guest page tables.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu-defs.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
index 5e12cc1854..67239b4e5e 100644
--- a/include/exec/cpu-defs.h
+++ b/include/exec/cpu-defs.h
@@ -163,6 +163,15 @@ typedef struct CPUTLBEntryFull {
 
     /* @lg_page_size contains the log2 of the page size. */
     uint8_t lg_page_size;
+
+    /*
+     * Allow target-specific additions to this structure.
+     * This may be used to cache items from the guest cpu
+     * page tables for later use by the implementation.
+     */
+#ifdef TARGET_PAGE_ENTRY_EXTRA
+    TARGET_PAGE_ENTRY_EXTRA
+#endif
 } CPUTLBEntryFull;
 
 /*
-- 
2.34.1
Re: [PATCH v3 6/6] include/exec: Introduce TARGET_PAGE_ENTRY_EXTRA
Posted by Peter Maydell 3 years, 4 months ago
On Mon, 5 Sept 2022 at 21:26, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Allow the target to cache items from the guest page tables.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  include/exec/cpu-defs.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
> index 5e12cc1854..67239b4e5e 100644
> --- a/include/exec/cpu-defs.h
> +++ b/include/exec/cpu-defs.h
> @@ -163,6 +163,15 @@ typedef struct CPUTLBEntryFull {
>
>      /* @lg_page_size contains the log2 of the page size. */
>      uint8_t lg_page_size;
> +
> +    /*
> +     * Allow target-specific additions to this structure.
> +     * This may be used to cache items from the guest cpu
> +     * page tables for later use by the implementation.
> +     */
> +#ifdef TARGET_PAGE_ENTRY_EXTRA
> +    TARGET_PAGE_ENTRY_EXTRA
> +#endif
>  } CPUTLBEntryFull;

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

Shouldn't be too painful to adjust in future if we decide we don't
like doing it by macro magic, I guess.

thanks
-- PMM
Re: [PATCH v3 6/6] include/exec: Introduce TARGET_PAGE_ENTRY_EXTRA
Posted by Philippe Mathieu-Daudé via 3 years, 5 months ago
On 5/9/22 22:22, Richard Henderson wrote:
> Allow the target to cache items from the guest page tables.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   include/exec/cpu-defs.h | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
> index 5e12cc1854..67239b4e5e 100644
> --- a/include/exec/cpu-defs.h
> +++ b/include/exec/cpu-defs.h
> @@ -163,6 +163,15 @@ typedef struct CPUTLBEntryFull {
>   
>       /* @lg_page_size contains the log2 of the page size. */
>       uint8_t lg_page_size;
> +
> +    /*
> +     * Allow target-specific additions to this structure.
> +     * This may be used to cache items from the guest cpu
> +     * page tables for later use by the implementation.
> +     */
> +#ifdef TARGET_PAGE_ENTRY_EXTRA
> +    TARGET_PAGE_ENTRY_EXTRA
> +#endif
>   } CPUTLBEntryFull;

Alternatively declare a per-target structure in cpu-param.h
and here:

typedef struct CPUTLBEntryTarget CPUTLBEntryTarget;

#ifndef TARGET_HAS_PAGE_ENTRY_EXTRA_STRUCT
struct CPUTLBEntryTarget { }
#endif


typedef struct CPUTLBEntryFull {
   ...
   CPUTLBEntryTarget target_extra;
} CPUTLBEntryFull;

Meanwhile:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Re: [PATCH v3 6/6] include/exec: Introduce TARGET_PAGE_ENTRY_EXTRA
Posted by Richard Henderson 3 years, 5 months ago
On 9/5/22 22:28, Philippe Mathieu-Daudé wrote:
>> +    /*
>> +     * Allow target-specific additions to this structure.
>> +     * This may be used to cache items from the guest cpu
>> +     * page tables for later use by the implementation.
>> +     */
>> +#ifdef TARGET_PAGE_ENTRY_EXTRA
>> +    TARGET_PAGE_ENTRY_EXTRA
>> +#endif
>>   } CPUTLBEntryFull;
> 
> Alternatively declare a per-target structure in cpu-param.h
> and here:
> 
> typedef struct CPUTLBEntryTarget CPUTLBEntryTarget;
> 
> #ifndef TARGET_HAS_PAGE_ENTRY_EXTRA_STRUCT
> struct CPUTLBEntryTarget { }
> #endif

This was v1, more or less,
https://lore.kernel.org/qemu-devel/20220703082419.770989-2-richard.henderson@linaro.org/

In the end I thought the "extra" part confusing.
I was also concerned that I might be introducing
extra structure padding unnecessarily.


r~