From 52f7209e48b5e8ae138723ff7db8127c5e955675 Mon Sep 17 00:00:00 2001 From: Ravi Sahita Date: Tue, 1 Oct 2024 14:42:27 -0700 Subject: [PATCH 1/6] Describe behavior ext. for SFENCE.VMA and HFENCE.VMA Signed-off-by: Ravi Sahita --- chapter3.adoc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/chapter3.adoc b/chapter3.adoc index 0aa1abb..a548e07 100644 --- a/chapter3.adoc +++ b/chapter3.adoc @@ -244,3 +244,30 @@ prior to the `MINVAL.SPA`, and subsequent to the `MFENCE.SPA` `MINVAL.SPA` is only valid in M-mode. + +=== Extension to behavior of SFENCE.VMA and HFENCE.VMA + +The behavior of the SFENCE.VMA and the HFENCE.VMA instructions are affected when +supervisor domains are used by the M-mode RDSM. + +When SFENCE.VMA is used within a supervisor domain, the virtual-address argument +is a virtual address with either the ASID being a S/HS-level ASID (V=0), or a +VS-level ASID (V=1). + +For S/HS-level ASID, the virtual-address argument to SFENCE.VMA is a host +virtual address within the current supervisor domain, and the ASID argument is +a S/HS-level ASID within the current supervisor domain. The current supervisor +domain is identified by the SDID field of the CSR mttp, and the effective ASID +can be considered the combination of the SDID and the S/HS-level ASID. The +SFENCE.VMA orders stores only to this S/HS-level address-translation structures +with subsequent HS-level address translations. + +When V=1, the virtual-address argument to SFENCE.VMA is a guest virtual address +within the current virtual machine, and the ASID argument is a VS-level ASID +within the current virtual machine. The current virtual machine is identified by +the SDID field of the CSR mttp, the VMID field of CSR hgatp, and the effective +ASID can be considered to be the combination of this SDID and VMID with the +VS-level ASID. The SFENCE.VMA instruction orders stores only to the VS-level +address-translation structures with subsequent VS-stage address translations for +the same virtual machine, i.e., only when mttp.SDID and the hgatp.VMID is the +same as when the SFENCE.VMA executed. From 60bfc0566c98f60d0e2f2da9290120a645777d5d Mon Sep 17 00:00:00 2001 From: Ravi Sahita Date: Wed, 2 Oct 2024 20:03:40 -0700 Subject: [PATCH 2/6] Apply suggestions from PR review Co-authored-by: Samuel Holland Co-authored-by: Ved Shanbhogue <91900059+ved-rivos@users.noreply.github.com> Signed-off-by: Ravi Sahita --- chapter3.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chapter3.adoc b/chapter3.adoc index a548e07..1943065 100644 --- a/chapter3.adoc +++ b/chapter3.adoc @@ -248,7 +248,7 @@ subsequent to the `MFENCE.SPA` === Extension to behavior of SFENCE.VMA and HFENCE.VMA The behavior of the SFENCE.VMA and the HFENCE.VMA instructions are affected when -supervisor domains are used by the M-mode RDSM. +the Smsdid extension is implemented. When SFENCE.VMA is used within a supervisor domain, the virtual-address argument is a virtual address with either the ASID being a S/HS-level ASID (V=0), or a @@ -264,7 +264,7 @@ with subsequent HS-level address translations. When V=1, the virtual-address argument to SFENCE.VMA is a guest virtual address within the current virtual machine, and the ASID argument is a VS-level ASID -within the current virtual machine. The current virtual machine is identified by +within the current virtual machine. The current virtual machine is identified by the combination of the SDID field of the CSR mttp, the VMID field of CSR hgatp, and the effective ASID can be considered to be the combination of this SDID and VMID with the VS-level ASID. The SFENCE.VMA instruction orders stores only to the VS-level From 1e090a5ccfa803262023d932dca490b0c3e8919b Mon Sep 17 00:00:00 2001 From: Ravi Sahita Date: Mon, 7 Oct 2024 11:12:12 -0700 Subject: [PATCH 3/6] Apply suggestions from PR review Signed-off-by: Ravi Sahita --- chapter3.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter3.adoc b/chapter3.adoc index 1943065..783b742 100644 --- a/chapter3.adoc +++ b/chapter3.adoc @@ -245,7 +245,7 @@ subsequent to the `MFENCE.SPA` `MINVAL.SPA` is only valid in M-mode. -=== Extension to behavior of SFENCE.VMA and HFENCE.VMA +=== Extension to behavior of SFENCE.VMA, HFENCE.GVMA and HFENCE.VVMA The behavior of the SFENCE.VMA and the HFENCE.VMA instructions are affected when the Smsdid extension is implemented. From 718a912b860f27f2e95de274109af45c1b7c22b0 Mon Sep 17 00:00:00 2001 From: Ravi Sahita Date: Mon, 7 Oct 2024 15:27:02 -0700 Subject: [PATCH 4/6] updates to behavior of SFENCE.VMA, HFENCE.*, Svinval to consider SDID Signed-off-by: Ravi Sahita --- chapter3.adoc | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/chapter3.adoc b/chapter3.adoc index 783b742..0e2287b 100644 --- a/chapter3.adoc +++ b/chapter3.adoc @@ -205,7 +205,7 @@ and/or the SDID value in rs2, and always perform a global fence for all SDs. In some high-performance implementations, a finer-granular invalidation and fencing is required that allows for synchronization operations to be more -efficiently batched. When `Sinval` is implemented with `Smsdid`, the +efficiently batched. When `Svinval` is implemented with `Smsdid`, the `MINVAL.SPA` instruction must be implemented to support such fine-granular invalidation of physical memory access-permission caches. @@ -247,8 +247,8 @@ subsequent to the `MFENCE.SPA` === Extension to behavior of SFENCE.VMA, HFENCE.GVMA and HFENCE.VVMA -The behavior of the SFENCE.VMA and the HFENCE.VMA instructions are affected when -the Smsdid extension is implemented. +The behavior of the SFENCE.VMA, HFENCE.GVMA and HFENCE.VVMA instructions are +affected when the Smsdid extension is implemented. When SFENCE.VMA is used within a supervisor domain, the virtual-address argument is a virtual address with either the ASID being a S/HS-level ASID (V=0), or a @@ -260,14 +260,41 @@ a S/HS-level ASID within the current supervisor domain. The current supervisor domain is identified by the SDID field of the CSR mttp, and the effective ASID can be considered the combination of the SDID and the S/HS-level ASID. The SFENCE.VMA orders stores only to this S/HS-level address-translation structures -with subsequent HS-level address translations. +with subsequent S/HS-level address translations. When V=1, the virtual-address argument to SFENCE.VMA is a guest virtual address within the current virtual machine, and the ASID argument is a VS-level ASID -within the current virtual machine. The current virtual machine is identified by the combination of -the SDID field of the CSR mttp, the VMID field of CSR hgatp, and the effective -ASID can be considered to be the combination of this SDID and VMID with the -VS-level ASID. The SFENCE.VMA instruction orders stores only to the VS-level -address-translation structures with subsequent VS-stage address translations for -the same virtual machine, i.e., only when mttp.SDID and the hgatp.VMID is the -same as when the SFENCE.VMA executed. +within the current virtual machine. The current virtual machine is identified by +the SDID field of the CSR mttp and the VMID field of CSR hgatp. The effective +ASID within this virtual machine can be considered to be the combination of this +SDID and VMID along with the VS-level ASID. The SFENCE.VMA instruction orders +stores only to the VS-level address-translation structures with subsequent +VS-stage address translations for the same virtual machine, i.e., only when +mttp.SDID and the hgatp.VMID is the same as when the SFENCE.VMA executed. + +For HFENCE.GVMA, the guest-physical address argument is within the context of +the current virtual machine idenfied by the combination of the SDID field of the +CSR mttp and the VMID field of CSR hgatp. Executing an HFENCE.GVMA guarantees +that any previous stores already visible to the current hart are ordered before +all implicit reads by that hart done for G-stage address translation for +instructions that follow the HFENCE.GVMA, and execute with the same mttp.SDID +and hgatp.VMID when HFENCE.GVMA executed. + +For HFENCE.VVMA, the guest-virtual address argument is within the context of +the current virtual machine identified by the combination of the ASID specified +in the vsatp, the VMID field of CSR hgatp, and the SDID field of CSR mttp. +Executing an HFENCE.VVMA guarantees that any previous stores already visible to +the current hart are ordered before all implicit reads by that hart done for +VS-stage address translations for instructions that are subsequent to the +HFENCE.VMMA and execute when hgatp.VMID and mttp.SDID have the same setting as +it did when HFENCE.VVMA executed. + +=== Extension to behavior of `Sinval` + +When `Sinval` is implemented with `Smsdid` the behavior of SINVAL.VMA is +modified to also use the SDID from the CSR mttp in addition to the ASID provided +in SINVAL.VMA. + +When the `Hypervisor` extension is also implemented the behavior of HINVAL.VVMA +and HINVAL.GVMA is modified to also use the SDID from the CSR mttp in addition +to the VMID provided in the HINVAL.GVMA or the ASID provided in HINVAL.VVMA. From bab45360b560ba1dd957a90818372c2e2e7f854d Mon Sep 17 00:00:00 2001 From: Ravi Sahita Date: Mon, 7 Oct 2024 15:28:23 -0700 Subject: [PATCH 5/6] Apply suggestions from code review Signed-off-by: Ravi Sahita --- chapter3.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter3.adoc b/chapter3.adoc index 0e2287b..1cbb571 100644 --- a/chapter3.adoc +++ b/chapter3.adoc @@ -295,6 +295,6 @@ When `Sinval` is implemented with `Smsdid` the behavior of SINVAL.VMA is modified to also use the SDID from the CSR mttp in addition to the ASID provided in SINVAL.VMA. -When the `Hypervisor` extension is also implemented the behavior of HINVAL.VVMA +When the `Hypervisor` extension is also implemented, the behavior of HINVAL.VVMA and HINVAL.GVMA is modified to also use the SDID from the CSR mttp in addition to the VMID provided in the HINVAL.GVMA or the ASID provided in HINVAL.VVMA. From df1eb4645635f8719c70c2868cb1ce424541da85 Mon Sep 17 00:00:00 2001 From: Ravi Sahita Date: Mon, 7 Oct 2024 16:45:16 -0700 Subject: [PATCH 6/6] Apply suggestions from PR review Co-authored-by: Samuel Holland Signed-off-by: Ravi Sahita --- chapter3.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chapter3.adoc b/chapter3.adoc index 1cbb571..ad8380f 100644 --- a/chapter3.adoc +++ b/chapter3.adoc @@ -289,9 +289,9 @@ VS-stage address translations for instructions that are subsequent to the HFENCE.VMMA and execute when hgatp.VMID and mttp.SDID have the same setting as it did when HFENCE.VVMA executed. -=== Extension to behavior of `Sinval` +=== Extension to behavior of `Svinval` -When `Sinval` is implemented with `Smsdid` the behavior of SINVAL.VMA is +When `Svinval` is implemented with `Smsdid` the behavior of SINVAL.VMA is modified to also use the SDID from the CSR mttp in addition to the ASID provided in SINVAL.VMA.