Skip to contentSkip to conversation

Xilinx queue

GIT PULL Applied Edgar E. Iglesias 2 participants 5 messages Jan 27, 2021

lore
Share & tools
lore
#0 lore raw

From: "Edgar E. Iglesias" <[email protected]>

The following changes since commit 9cd69f1a270235b652766f00b94114f48a2d603f:

Merge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2021-01-25-1' into staging (2021-01-26 09:51:02 +0000)

are available in the Git repository at:

[email protected]:edgarigl/qemu.git tags/edgar/xilinx-next-2021-01-27.for-upstream

for you to fetch changes up to 43a9ede1efd12d297278d017ce7df7130672e15d:

target/microblaze: Add security attributes on memory transactions (2021-01-27 08:32:55 +0100)

----------------------------------------------------------------
For upstream

----------------------------------------------------------------

Joe Komlodi (3):
target/microblaze: Add use-non-secure property target/microblaze: use MMUAccessType instead of int in mmu_translate target/microblaze: Add security attributes on memory transactions

 target/microblaze/cpu.h    | 14 ++++++++++-
 target/microblaze/mmu.h    |  2 +-
 target/microblaze/cpu.c    | 48 +++++++++++++++++++++++++++++++++++++-
 target/microblaze/helper.c | 26 ++++++++++++++++++---
 target/microblaze/mmu.c    |  2 +-
 5 files changed, 85 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

[PULL v1 1/3] target/microblaze: Add use-non-secure property

From: Joe Komlodi <[email protected]>

This property is used to control the security of the following interfaces on MicroBlaze:
M_AXI_DP - data interface
M_AXI_IP - instruction interface
M_AXI_DC - dcache interface
M_AXI_IC - icache interface

It works by enabling or disabling the use of the non_secure[3:0] signals.

Interfaces and their corresponding values are taken from:
https://www.xilinx.com/support/documentation/sw_manuals/xilinx2020_2/ug984-vivado-microblaze-ref.pdf
page 153.

Message-Id: <[email protected]>

---
 target/microblaze/cpu.h | 11 ++++++++++
 target/microblaze/cpu.c | 46 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)
target/microblaze/cpu.h +11 -0
index c1c264199f..199cfb02d6 100644
@@ -233,6 +233,12 @@ typedef struct CPUMBState CPUMBState;
 
 #define TARGET_INSN_START_EXTRA_WORDS 1
 
+/* use-non-secure property masks */
+#define USE_NON_SECURE_M_AXI_DP_MASK 0x1
+#define USE_NON_SECURE_M_AXI_IP_MASK 0x2
+#define USE_NON_SECURE_M_AXI_DC_MASK 0x4
+#define USE_NON_SECURE_M_AXI_IC_MASK 0x8
+
 struct CPUMBState {
     uint32_t bvalue;   /* TCG temporary, only valid during a TB */
     uint32_t btarget;  /* Full resolved branch destination */
@@ -316,6 +322,7 @@ typedef struct {
     bool use_msr_instr;
     bool use_pcmp_instr;
     bool use_mmu;
+    uint8_t use_non_secure;
     bool dcache_writeback;
     bool endi;
     bool dopb_bus_exception;
@@ -337,6 +344,10 @@ struct MicroBlazeCPU {
     CPUState parent_obj;
 
     /*< public >*/
+    bool ns_axi_dp;
+    bool ns_axi_ip;
+    bool ns_axi_dc;
+    bool ns_axi_ic;
 
     CPUNegativeOffsetState neg;
     CPUMBState env;
target/microblaze/cpu.c +46 -0

64 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

[PULL v1 2/3] target/microblaze: use MMUAccessType instead of int in mmu_translate

In reply to Edgar E. Iglesias

From: Joe Komlodi <[email protected]>

Using MMUAccessType makes it more clear what the variable's use is. No functional change.

Message-Id: <[email protected]>

---
 target/microblaze/mmu.h | 2 +-
 target/microblaze/mmu.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
target/microblaze/mmu.h +1 -1
index 09e4075739..b6b4b9ad60 100644
@@ -84,7 +84,7 @@ typedef struct {
 } MicroBlazeMMULookup;
 
 unsigned int mmu_translate(MicroBlazeCPU *cpu, MicroBlazeMMULookup *lu,
-                           target_ulong vaddr, int rw, int mmu_idx);
+                           target_ulong vaddr, MMUAccessType rw, int mmu_idx);
 uint32_t mmu_read(CPUMBState *env, bool ea, uint32_t rn);
 void mmu_write(CPUMBState *env, bool ea, uint32_t rn, uint32_t v);
 void mmu_init(MicroBlazeMMU *mmu);
target/microblaze/mmu.c +1 -1
index 1e426963ba..cc40f275ea 100644
@@ -74,7 +74,7 @@ static void mmu_change_pid(CPUMBState *env, unsigned int newpid)
 
 /* rw - 0 = read, 1 = write, 2 = fetch.  */
 unsigned int mmu_translate(MicroBlazeCPU *cpu, MicroBlazeMMULookup *lu,
-                           target_ulong vaddr, int rw, int mmu_idx)
+                           target_ulong vaddr, MMUAccessType rw, int mmu_idx)
 {
     MicroBlazeMMU *mmu = &cpu->env.mmu;
     unsigned int i, hit = 0;
Signature · 1 line
2.25.1
#3 lore raw

[PULL v1 3/3] target/microblaze: Add security attributes on memory transactions

In reply to Edgar E. Iglesias

From: Joe Komlodi <[email protected]>

Using the cfg.use_non_secure bitfield and the MMU access type, we can determine if the access should be secure or not.

Message-Id: <[email protected]>

---
 target/microblaze/cpu.h    |  3 ++-
 target/microblaze/cpu.c    |  2 +-
 target/microblaze/helper.c | 26 +++++++++++++++++++++++---
 3 files changed, 26 insertions(+), 5 deletions(-)
target/microblaze/cpu.h +2 -1
index 199cfb02d6..e4bba8a755 100644
@@ -361,7 +361,8 @@ void mb_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
                                 MMUAccessType access_type,
                                 int mmu_idx, uintptr_t retaddr);
 void mb_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
-hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+hwaddr mb_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
+                                        MemTxAttrs *attrs);
 int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 
target/microblaze/cpu.c +1 -1
index accfb23a4f..d5e8bfe11f 100644
@@ -375,7 +375,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data)
     cc->tlb_fill = mb_cpu_tlb_fill;
 #ifndef CONFIG_USER_ONLY
     cc->do_transaction_failed = mb_cpu_transaction_failed;
-    cc->get_phys_page_debug = mb_cpu_get_phys_page_debug;
+    cc->get_phys_page_attrs_debug = mb_cpu_get_phys_page_attrs_debug;
     dc->vmsd = &vmstate_mb_cpu;
 #endif
     device_class_set_props(dc, mb_properties);
target/microblaze/helper.c +23 -3
index cda14a14be..20dbd67313 100644
@@ -46,6 +46,16 @@ bool mb_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
 
 #else /* !CONFIG_USER_ONLY */
 
+static bool mb_cpu_access_is_secure(MicroBlazeCPU *cpu,
+                                    MMUAccessType access_type)
+{
+    if (access_type == MMU_INST_FETCH) {
+        return !cpu->ns_axi_ip;
+    } else {
+        return !cpu->ns_axi_dp;
+    }
+}
+
 bool mb_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                      MMUAccessType access_type, int mmu_idx,
                      bool probe, uintptr_t retaddr)
@@ -55,12 +65,16 @@ bool mb_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
     MicroBlazeMMULookup lu;
     unsigned int hit;
     int prot;
+    MemTxAttrs attrs = {};
+
+    attrs.secure = mb_cpu_access_is_secure(cpu, access_type);
 
     if (mmu_idx == MMU_NOMMU_IDX) {
         /* MMU disabled or not available.  */
         address &= TARGET_PAGE_MASK;
         prot = PAGE_BITS;
-        tlb_set_page(cs, address, address, prot, mmu_idx, TARGET_PAGE_SIZE);
+        tlb_set_page_with_attrs(cs, address, address, attrs, prot, mmu_idx,
+                                TARGET_PAGE_SIZE);
         return true;
     }
 
@@ -71,7 +85,8 @@ bool mb_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
 
         qemu_log_mask(CPU_LOG_MMU, "MMU map mmu=%d v=%x p=%x prot=%x\n",
                       mmu_idx, vaddr, paddr, lu.prot);
-        tlb_set_page(cs, vaddr, paddr, lu.prot, mmu_idx, TARGET_PAGE_SIZE);
+        tlb_set_page_with_attrs(cs, vaddr, paddr, attrs, lu.prot, mmu_idx,
+                                TARGET_PAGE_SIZE);
         return true;
     }
 
@@ -230,7 +245,8 @@ void mb_cpu_do_interrupt(CPUState *cs)
     }
 }
 
-hwaddr mb_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
+hwaddr mb_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr,
+                                        MemTxAttrs *attrs)
 {
     MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);
     CPUMBState *env = &cpu->env;
@@ -239,6 +255,10 @@ hwaddr mb_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
     int mmu_idx = cpu_mmu_index(env, false);
     unsigned int hit;
 
+    /* Caller doesn't initialize */
+    *attrs = (MemTxAttrs) {};
+    attrs->secure = mb_cpu_access_is_secure(cpu, MMU_DATA_LOAD);
+
     if (mmu_idx != MMU_NOMMU_IDX) {
         hit = mmu_translate(cpu, &lu, addr, 0, 0);
         if (hit) {
Signature · 1 line
2.25.1
#4 lore raw
In reply to Edgar E. Iglesias
Quoted 11 lines · Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

The following changes since commit 9cd69f1a270235b652766f00b94114f48a2d603f:

Merge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2021-01-25-1' into staging (2021-01-26 09:51:02 +0000)

are available in the Git repository at:

[email protected]:edgarigl/qemu.git tags/edgar/xilinx-next-2021-01-27.for-upstream

Quoted 8 lines

for you to fetch changes up to 43a9ede1efd12d297278d017ce7df7130672e15d:

target/microblaze: Add security attributes on memory transactions (2021-01-27 08:32:55 +0100)

----------------------------------------------------------------
For upstream

----------------------------------------------------------------

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/6.0
for any user-visible changes.

-- PMM