qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] target/arm: Implement ARMv8.1-VMID16 extension
@ 2020-02-10 12:01 Peter Maydell
  2020-02-10 12:23 ` Alex Bennée
  2020-02-12  6:33 ` Philippe Mathieu-Daudé
  0 siblings, 2 replies; 5+ messages in thread
From: Peter Maydell @ 2020-02-10 12:01 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Alex Bennée, Richard Henderson

The ARMv8.1-VMID16 extension extends the VMID from 8 bits to 16 bits:

 * the ID_AA64MMFR1_EL1.VMIDBits field specifies whether the VMID is
   8 or 16 bits
 * the VMID field in VTTBR_EL2 is extended to 16 bits
 * VTCR_EL2.VS lets the guest specify whether to use the full 16 bits,
   or use the backwards-compatible 8 bits

For QEMU implementing this is trivial:
 * we do not track VMIDs in TLB entries, so we never use the VMID field
 * we treat any write to VTTBR_EL2, not just a change to the VMID field
   bits, as a "possible VMID change" that causes us to throw away TLB
   entries, so that code doesn't need changing
 * we allow the guest to read/write the VTCR_EL2.VS bit already

So all that's missing is the ID register part: report that we support
VMID16 in our 'max' CPU.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
Not something anybody's been asking for, but worthwhile as
a step towards finishing off support for all the v8.1 extensions.

 target/arm/cpu64.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index 2d97bf45e1e..bf2cf278c03 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -672,6 +672,7 @@ static void aarch64_max_initfn(Object *obj)
         t = cpu->isar.id_aa64mmfr1;
         t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */
         t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1);
+        t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* VMID16 */
         cpu->isar.id_aa64mmfr1 = t;
 
         /* Replicate the same data to the 32-bit id registers.  */
-- 
2.20.1



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

* Re: [PATCH] target/arm: Implement ARMv8.1-VMID16 extension
  2020-02-10 12:01 [PATCH] target/arm: Implement ARMv8.1-VMID16 extension Peter Maydell
@ 2020-02-10 12:23 ` Alex Bennée
  2020-02-10 13:19   ` Peter Maydell
  2020-02-12  6:33 ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 5+ messages in thread
From: Alex Bennée @ 2020-02-10 12:23 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-arm, Richard Henderson, qemu-devel


Peter Maydell <peter.maydell@linaro.org> writes:

> The ARMv8.1-VMID16 extension extends the VMID from 8 bits to 16 bits:
>
>  * the ID_AA64MMFR1_EL1.VMIDBits field specifies whether the VMID is
>    8 or 16 bits
>  * the VMID field in VTTBR_EL2 is extended to 16 bits
>  * VTCR_EL2.VS lets the guest specify whether to use the full 16 bits,
>    or use the backwards-compatible 8 bits
>
> For QEMU implementing this is trivial:
>  * we do not track VMIDs in TLB entries, so we never use the VMID
> field

Not currently but does the VMID allow you to have per-guest page table
caching? Last time I chatted to rth about potential performance wins we
discussed how easy it would be to support this in the softmmu now we
have indirect TLB lookups anyway. Given how much time is currently spent
expensively re-populating tables we could keep the last couple of id
tagged tables around for faster switching between sets of tables.

>  * we treat any write to VTTBR_EL2, not just a change to the VMID field
>    bits, as a "possible VMID change" that causes us to throw away TLB
>    entries, so that code doesn't need changing
>  * we allow the guest to read/write the VTCR_EL2.VS bit already
>
> So all that's missing is the ID register part: report that we support
> VMID16 in our 'max' CPU.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Not something anybody's been asking for, but worthwhile as
> a step towards finishing off support for all the v8.1 extensions.
>
>  target/arm/cpu64.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
> index 2d97bf45e1e..bf2cf278c03 100644
> --- a/target/arm/cpu64.c
> +++ b/target/arm/cpu64.c
> @@ -672,6 +672,7 @@ static void aarch64_max_initfn(Object *obj)
>          t = cpu->isar.id_aa64mmfr1;
>          t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */
>          t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1);
> +        t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* VMID16 */
>          cpu->isar.id_aa64mmfr1 = t;
>  
>          /* Replicate the same data to the 32-bit id registers.  */

I guess we can easily add the isar_feature_aa64_ functions when we need
them.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée


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

* Re: [PATCH] target/arm: Implement ARMv8.1-VMID16 extension
  2020-02-10 12:23 ` Alex Bennée
@ 2020-02-10 13:19   ` Peter Maydell
  2020-02-10 17:05     ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2020-02-10 13:19 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-arm, Richard Henderson, QEMU Developers

On Mon, 10 Feb 2020 at 12:23, Alex Bennée <alex.bennee@linaro.org> wrote:
>
>
> Peter Maydell <peter.maydell@linaro.org> writes:
>
> > The ARMv8.1-VMID16 extension extends the VMID from 8 bits to 16 bits:
> >
> >  * the ID_AA64MMFR1_EL1.VMIDBits field specifies whether the VMID is
> >    8 or 16 bits
> >  * the VMID field in VTTBR_EL2 is extended to 16 bits
> >  * VTCR_EL2.VS lets the guest specify whether to use the full 16 bits,
> >    or use the backwards-compatible 8 bits
> >
> > For QEMU implementing this is trivial:
> >  * we do not track VMIDs in TLB entries, so we never use the VMID
> > field
>
> Not currently but does the VMID allow you to have per-guest page table
> caching? Last time I chatted to rth about potential performance wins we
> discussed how easy it would be to support this in the softmmu now we
> have indirect TLB lookups anyway. Given how much time is currently spent
> expensively re-populating tables we could keep the last couple of id
> tagged tables around for faster switching between sets of tables.

Yeah, in hardware the whole point of the VMID is to have per-guest
caching of VA-to-PA mappings in the TLB so you don't have to blow
them all away when you switch VM (just as ASID does for processes).
The difficulty with QEMU has always been that adding the "and is this
the right VMID/ASID" to the softmmu fastpath code would be expensive,
AIUI. If we ever come up with a clever plan for this it should be
no different if the VMID field is 16 vs 8 bits, though.

thanks
-- PMM


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

* Re: [PATCH] target/arm: Implement ARMv8.1-VMID16 extension
  2020-02-10 13:19   ` Peter Maydell
@ 2020-02-10 17:05     ` Richard Henderson
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2020-02-10 17:05 UTC (permalink / raw)
  To: Peter Maydell, Alex Bennée; +Cc: qemu-arm, QEMU Developers

On 2/10/20 1:19 PM, Peter Maydell wrote:
> On Mon, 10 Feb 2020 at 12:23, Alex Bennée <alex.bennee@linaro.org> wrote:
>>
>>
>> Peter Maydell <peter.maydell@linaro.org> writes:
>>
>>> The ARMv8.1-VMID16 extension extends the VMID from 8 bits to 16 bits:
>>>
>>>  * the ID_AA64MMFR1_EL1.VMIDBits field specifies whether the VMID is
>>>    8 or 16 bits
>>>  * the VMID field in VTTBR_EL2 is extended to 16 bits
>>>  * VTCR_EL2.VS lets the guest specify whether to use the full 16 bits,
>>>    or use the backwards-compatible 8 bits
>>>
>>> For QEMU implementing this is trivial:
>>>  * we do not track VMIDs in TLB entries, so we never use the VMID
>>> field
>>
>> Not currently but does the VMID allow you to have per-guest page table
>> caching? Last time I chatted to rth about potential performance wins we
>> discussed how easy it would be to support this in the softmmu now we
>> have indirect TLB lookups anyway. Given how much time is currently spent
>> expensively re-populating tables we could keep the last couple of id
>> tagged tables around for faster switching between sets of tables.
> 
> Yeah, in hardware the whole point of the VMID is to have per-guest
> caching of VA-to-PA mappings in the TLB so you don't have to blow
> them all away when you switch VM (just as ASID does for processes).

Yep.

> The difficulty with QEMU has always been that adding the "and is this
> the right VMID/ASID" to the softmmu fastpath code would be expensive,

Yep.  My current half-baked idea for this does not involve changing the
fastpath, but swapping out softmmu tlbs in bulk.
Which is possible now that there's a pointer involved, and not 8k of data in an
array.

> AIUI. If we ever come up with a clever plan for this it should be
> no different if the VMID field is 16 vs 8 bits, though.

Yep.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


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

* Re: [PATCH] target/arm: Implement ARMv8.1-VMID16 extension
  2020-02-10 12:01 [PATCH] target/arm: Implement ARMv8.1-VMID16 extension Peter Maydell
  2020-02-10 12:23 ` Alex Bennée
@ 2020-02-12  6:33 ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-12  6:33 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel; +Cc: Richard Henderson

On 2/10/20 1:01 PM, Peter Maydell wrote:
> The ARMv8.1-VMID16 extension extends the VMID from 8 bits to 16 bits:
> 
>   * the ID_AA64MMFR1_EL1.VMIDBits field specifies whether the VMID is
>     8 or 16 bits
>   * the VMID field in VTTBR_EL2 is extended to 16 bits
>   * VTCR_EL2.VS lets the guest specify whether to use the full 16 bits,
>     or use the backwards-compatible 8 bits
> 
> For QEMU implementing this is trivial:
>   * we do not track VMIDs in TLB entries, so we never use the VMID field
>   * we treat any write to VTTBR_EL2, not just a change to the VMID field
>     bits, as a "possible VMID change" that causes us to throw away TLB
>     entries, so that code doesn't need changing
>   * we allow the guest to read/write the VTCR_EL2.VS bit already
> 
> So all that's missing is the ID register part: report that we support
> VMID16 in our 'max' CPU.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Not something anybody's been asking for, but worthwhile as
> a step towards finishing off support for all the v8.1 extensions.
> 
>   target/arm/cpu64.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
> index 2d97bf45e1e..bf2cf278c03 100644
> --- a/target/arm/cpu64.c
> +++ b/target/arm/cpu64.c
> @@ -672,6 +672,7 @@ static void aarch64_max_initfn(Object *obj)
>           t = cpu->isar.id_aa64mmfr1;
>           t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */
>           t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1);
> +        t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* VMID16 */
>           cpu->isar.id_aa64mmfr1 = t;
>   
>           /* Replicate the same data to the 32-bit id registers.  */
> 

Trivial conflict with:

commit cd3f80aba0c559a6291f7c3e686422b15381f6b7
Author: Richard Henderson <richard.henderson@linaro.org>
Date:   Fri Feb 7 14:04:27 2020 +0000

     target/arm: Enable ARMv8.1-VHE in -cpu max

     Tested-by: Alex Bennée <alex.bennee@linaro.org>
     Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
     Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
     Message-id: 20200206105448.4726-38-richard.henderson@linaro.org
     Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index 2d97bf45e1..c80fb5fd43 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -672,6 +672,7 @@ static void aarch64_max_initfn(Object *obj)
          t = cpu->isar.id_aa64mmfr1;
          t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */
          t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1);
+        t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1);
          cpu->isar.id_aa64mmfr1 = t;

          /* Replicate the same data to the 32-bit id registers.  */



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

end of thread, other threads:[~2020-02-12  6:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-10 12:01 [PATCH] target/arm: Implement ARMv8.1-VMID16 extension Peter Maydell
2020-02-10 12:23 ` Alex Bennée
2020-02-10 13:19   ` Peter Maydell
2020-02-10 17:05     ` Richard Henderson
2020-02-12  6:33 ` Philippe Mathieu-Daudé

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).