public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org
Cc: leif.lindholm@linaro.org, masahisa.kojima@linaro.org,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH edk2-platforms 2/3] Silicon/Socionext/SynQuacer/Stage2Tables: add north SMMU level 3 table
Date: Wed, 30 May 2018 20:19:28 +0200	[thread overview]
Message-ID: <20180530181929.5066-3-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20180530181929.5066-1-ard.biesheuvel@linaro.org>

Extend the static stage 2 page tables with a set of level 3 tables that
describe the ECAM space in a manner that allows the north SMMU to be used
to make the ECAM space appear sane to the CPUs.

It is up to the secure firmware to manipulate the north SMMU page tables
so that the level 2 block entries corresponding with busses #0 .. #1 in
the respective config spaces of PCI0 and PCI1 are replaced with table
entries pointing to the level 3 tables added by this patch.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S | 35 +++++++++++++++-----
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S b/Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S
index 313ef3c56abc..af55f27bca47 100644
--- a/Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S
+++ b/Silicon/Socionext/SynQuacer/Stage2Tables/Stage2Tables.S
@@ -20,15 +20,17 @@
  *   the SoC.
  */
 
-#define TT_S2_CONT_SHIFT          52
-#define TT_S2_AF                  (0x1 << 10)
-#define TT_S2_SH_NON_SHAREABLE    (0x0 << 8)
-#define TT_S2_AP_RW               (0x3 << 6)
-#define TT_S2_MEMATTR_DEVICE_nGRE (0x2 << 2)
-#define TT_S2_MEMATTR_MEMORY_WB   (0xf << 2)
-#define TT_S2_TABLE               (0x3 << 0)
-#define TT_S2_L3_PAGE             (0x1 << 1)
-#define TT_S2_VALID               (0x1 << 0)
+#define TT_S2_CONT_SHIFT            52
+#define TT_S2_AF                    (0x1 << 10)
+#define TT_S2_SH_NON_SHAREABLE      (0x0 << 8)
+#define TT_S2_AP_RO                 (0x1 << 6)
+#define TT_S2_AP_RW                 (0x3 << 6)
+#define TT_S2_MEMATTR_DEVICE_nGRE   (0x2 << 2)
+#define TT_S2_MEMATTR_DEVICE_nGnRE  (0x1 << 2)
+#define TT_S2_MEMATTR_MEMORY_WB     (0xf << 2)
+#define TT_S2_TABLE                 (0x3 << 0)
+#define TT_S2_L3_PAGE               (0x1 << 1)
+#define TT_S2_VALID                 (0x1 << 0)
 
   .altmacro
   .macro    for, start, count, do, arg2, arg3, arg4
@@ -58,6 +60,12 @@
             TT_S2_L3_PAGE | TT_S2_VALID | (\cont << TT_S2_CONT_SHIFT)
   .endm
 
+  .macro    smmu_l3_entry, base, offset=0, ignore=0
+  .quad     ((\base << 12) + \offset) | TT_S2_AF | TT_S2_AP_RO | \
+            TT_S2_SH_NON_SHAREABLE | TT_S2_MEMATTR_DEVICE_nGnRE | \
+            TT_S2_L3_PAGE | TT_S2_VALID
+  .endm
+
   .section  ".rodata", "a", %progbits
   /* level 1 */
   s2_mem_entry  0      /* 0x0000_0000 - 0x3fff_ffff */
@@ -86,3 +94,12 @@
 3:for     0,   8, s2_l3_entry, 0x70000000
   for     0,   8, s2_l3_entry, 0x70010000  /* hide device #1 */
   for     0, 496, s2_l3_entry, 0x70010000, 1
+
+  /* level 3 for north SMMU */
+  .org    0x6000
+  for     0,   8, smmu_l3_entry, 0xc00060000000
+  for     0,   8, smmu_l3_entry, 0xc00060010000  /* hide device #1 */
+  for     0, 496, smmu_l3_entry, 0xc00060010000
+  for     0,   8, smmu_l3_entry, 0x800070000000
+  for     0,   8, smmu_l3_entry, 0x800070010000  /* hide device #1 */
+  for     0, 496, smmu_l3_entry, 0x800070010000
-- 
2.17.0



  parent reply	other threads:[~2018-05-30 18:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-30 18:19 [PATCH edk2-platforms 0/3] More SynQuacer updates Ard Biesheuvel
2018-05-30 18:19 ` [PATCH edk2-platforms 1/3] Silicon/SynQuacerPciHostBridgeLib: add workaround for PCIe MMIO64 Ard Biesheuvel
2018-05-31  9:11   ` Leif Lindholm
2018-05-31  9:17     ` Ard Biesheuvel
2018-05-31  9:46       ` Leif Lindholm
2018-05-31 10:49         ` Ard Biesheuvel
2018-05-30 18:19 ` Ard Biesheuvel [this message]
2018-05-31  9:14   ` [PATCH edk2-platforms 2/3] Silicon/Socionext/SynQuacer/Stage2Tables: add north SMMU level 3 table Leif Lindholm
2018-06-01 10:18     ` Ard Biesheuvel
2018-05-30 18:19 ` [PATCH edk2-platforms 3/3] Silicon/SynQuacer/AcpiTables: add NETSEC/eMMC SMMU to the IORT Ard Biesheuvel
2018-05-31  9:16   ` Leif Lindholm
2018-10-12 10:03     ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180530181929.5066-3-ard.biesheuvel@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox