Add Smsdid and Smmpt supervisor domain protection
v3 cover Add Smsdid and Smmpt supervisor domain protection
This series adds OpenSBI support for the RISC-V SMMPT specification sub-extensions - Smsdid (supervisor domain ID) and
Smmpt (supervisor domain memory protection).
Together these let M-mode firmware confine each supervisor domain to a physical address space that is enforced in hardware, via a per domain memory protection table (MPT) selected by the mmpt CSR.
Every supervisor domain gets its own MPT built from the memory regions of its SBI domain. Per-region XWR permissions are derived from the region's S/U access flags from SBI domain, so a region that does not have S/U access is mapped as an deny instead of skipped.
The Root domain maps all physical memory, with the firmware region explicitly denied to S-mode. Regions may be shared between domains, each side keeping its own permissions.
Testing:
Booted Linux when Smmpt was active. The boot dump shows the expected per region permissions. Also checked with a small self-test in Qemu which confirms the firmware region denied and the kernel region permitted from S-mode.
The Qemu RISC-V Virt machine was used to test this. The new cli args required to be passed to Qemu are -
./qemu-system-riscv64 -nographic -M virt -cpu rv64,x-smsdid=true,x-smmpt=true
Please note that extra some logs in OpenSBI and Qemu are added for testing which will be removed later.
Boot Logs:
sbi_mpt: mode=Smmpt52 SDIDLEN=6 max_domains=64
root_size=0x1000 root_align=0x1000
fw 0x0000000080000000+0x19e000 pool=global heap SDID 0 root=0x0000000080098000 regions=9 dom=root
S-Domain0 Region01 : 0x0000000080000000+0x80000 : xwr=0 (---)
S-Domain0 Region02 : 0x0000000080000000+0x200000 : xwr=0 (---)
S-Domain0 Region03 : 0x0000000000100000+0x1000 : xwr=3 (RW-)
S-Domain0 Region04 : 0x0000000010000000+0x1000 : xwr=3 (RW-)
S-Domain0 Region05 : 0x0000000002000000+0x10000 : xwr=0 (---)
S-Domain0 Region06 : 0x000000000c400000+0x200000 : xwr=3 (RW-)
S-Domain0 Region07 : 0x000000000c000000+0x400000 : xwr=3 (RW-)
S-Domain0 Region08 : 0x0000000080000000+0x19e000 : xwr=0 (---) [LOCKED]
S-Domain0 Default : Rest of the address space : xwr=7 (RWX) [baseline, overlay by regions above]
Boot HART ID : 0
Boot HART Domain : root
Boot HART Priv Version : v1.12
Boot HART Base ISA : rv64imafdch
Boot HART ISA Extensions : sstc,zicntr,zihpm,zicboz,zicbom,sdtrig,svadu,f,d,smsdid,smmpt
Boot HART PMP Count : 16
Boot HART PMP Granularity : 2 bits
Boot HART PMP Address Bits : 54
Boot HART MHPM Info : 16 (0x0007fff8)
Boot HART Debug Triggers : 2 triggers
Boot HART MIDELEG : 0x0000000000001666
Boot HART MEDELEG : 0x0000000000f4b509
The corresponding Qemu Smmpt support from LIU Zhiwei
https://patchew.org/QEMU/[email protected]/
This is part of collaboration work for RISC-V SMMTT development. More details are here:
https://lists.gnu.org/archive/html/qemu-riscv/2026-07/msg01018.html
These OpenSBI changes are also present in github -
https://github.com/pathakraul/opensbi/tree/rpathak_smmpt_v3
Further Development:
This series add base infrastructure for Smsdid and Smmpt. Development and testing with more then one Supervisor Domain. Extensive testing with all the modes and other platform configurations.
v2 -> v3:
1. Adapt to sbi hart protection abstraction.
2. Add missing sbi_mpt_hart_deactivate() decl in sbi_mpt.h.
3. Rename the *map_range and *unmap_range set of functions in sbi_hart_protection.
4. Update the copyright string.
v1 -> v2:
1. Rebase to latest master
2. Change probe order between mode and sdid.
3. Add sbi_mpt_query_access() function.
4. Formatting changes.
Rahul Pathak (5):
lib: sbi: Rename map_range/unmap_range functions
riscv: Add Smsdid and Smmpt hart extensions
mpt: Add Smsdid and Smmpt supervisor domain core platform/generic: Initialise MPT at boot
sbi: init: Print supervisor domains at boot
include/sbi/sbi_hart.h | 4 + include/sbi/sbi_hart_protection.h | 27 +- include/sbi/sbi_mpt.h | 336 ++++++++++ lib/sbi/objects.mk | 2 + lib/sbi/sbi_dbtr.c | 26 +- lib/sbi/sbi_ecall_dbcn.c | 4 +- lib/sbi/sbi_hart.c | 2 + lib/sbi/sbi_hart_pmp.c | 10 +- lib/sbi/sbi_hart_protection.c | 12 +- lib/sbi/sbi_init.c | 4 + lib/sbi/sbi_mpt.c | 955 ++++++++++++++++++++++++++++ lib/sbi/sbi_mpt_mode.c | 997 ++++++++++++++++++++++++++++++ lib/sbi/sbi_mpxy.c | 24 +- lib/sbi/sbi_pmu.c | 4 +- lib/sbi/sbi_sse.c | 8 +- platform/generic/platform.c | 101 +++ 16 files changed, 2461 insertions(+), 55 deletions(-) create mode 100644 include/sbi/sbi_mpt.h create mode 100644 lib/sbi/sbi_mpt.c create mode 100644 lib/sbi/sbi_mpt_mode.c
Signature · 7 lines
2.51.0 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
RFC PATCH v3 1/5 lib: sbi: Rename map_range/unmap_range functions
*_map_range and *_unmap_range functions are required in M-Mode to get the temporary access to S-Mode and U-Mode regions. Thse functions only operate using the TYPE_MEMORY memory protection mechanisms. Rename them to reflect the actual usage of these functions and let generic map/unmap_range names to implement generic functions
--- include/sbi/sbi_hart_protection.h | 27 ++++++++++++++++----------- lib/sbi/sbi_dbtr.c | 26 +++++++++++++------------- lib/sbi/sbi_ecall_dbcn.c | 4 ++-- lib/sbi/sbi_hart_pmp.c | 10 +++++----- lib/sbi/sbi_hart_protection.c | 12 ++++++------ lib/sbi/sbi_mpxy.c | 24 ++++++++++++------------ lib/sbi/sbi_pmu.c | 4 ++-- lib/sbi/sbi_sse.c | 8 ++++---- 8 files changed, 60 insertions(+), 55 deletions(-)
include/sbi/sbi_hart_protection.h +16 -11
@@ -40,13 +40,17 @@ struct sbi_hart_protection {/** Unconfigure protection for current HART (Optional) */ void (*unconfigure)(struct sbi_scratch *scratch,struct sbi_domain *dom); -/** Create temporary mapping to access address range on current HART (Optional) */ -int (*map_range)(struct sbi_scratch *scratch, -unsigned long base,unsigned long size); - -/** Destroy temporary mapping on current HART (Optional) */ -int (*unmap_range)(struct sbi_scratch *scratch, -unsigned long base,unsigned long size); +/** +* Give temporary M-mode access to an S/U-mode address range on current +* HART (Optional). Only applicable for the TYPE_MEMORY and the TYPE_ID +* mechanisms are not invoked. +*/ +int (*temp_map_range)(struct sbi_scratch *scratch, +unsigned long base,unsigned long size); + +/** Remove the temporary M-mode access on the current HART (Optional) */ +int (*temp_unmap_range)(struct sbi_scratch *scratch, +unsigned long base,unsigned long size); };/**
@@ -111,23 +115,24 @@ int sbi_hart_protection_reconfigure(struct sbi_scratch *scratch, struct sbi_domain *next_dom);/** -* Create temporary mapping to access address range on current HART +* Give temporary M-mode access to an S/U-mode address range on the +* current HART. Only valid for TYPE_MEMORY. * * @param base base address of the temporary mapping * @param size size of the temporary mapping * * @return 0 on success and negative error code on failure */ -int sbi_hart_protection_map_range (unsigned long base,unsigned long size); +int sbi_hart_protection_temp_map_range (unsigned long base,unsigned long size);/** -* Destroy temporary mapping to access address range on current HART +* Remove the temporary M-mode access on the current HART * * @param base base address of the temporary mapping * @param size size of the temporary mapping * * @return 0 on success and negative error code on failure */ -int sbi_hart_protection_unmap_range (unsigned long base,unsigned long size); +int sbi_hart_protection_temp_unmap_range (unsigned long base,unsigned long size);#endif /* __SBI_HART_PROTECTION_H__ */
lib/sbi/sbi_dbtr.c +13 -13
@@ -580,7 +580,7 @@ int sbi_dbtr_read_trig(unsigned long smode, shmem_base =hart_shmem_base (hs); -sbi_hart_protection_map_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));for_each_trig_entry (shmem_base, trig_count,typeof (*entry), entry) { xmit = &entry->data;
@@ -594,7 +594,7 @@ int sbi_dbtr_read_trig(unsigned long smode, xmit->tdata2 =cpu_to_lle (trig->tdata2); xmit->tdata3 =cpu_to_lle (trig->tdata3); } -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_SUCCESS ;
@@ -620,7 +620,7 @@ int sbi_dbtr_install_trig(unsigned long smode,return SBI_ERR_NO_SHMEM ; shmem_base =hart_shmem_base (hs); -sbi_hart_protection_map_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));/*
@@ -639,14 +639,14 @@ int sbi_dbtr_install_trig(unsigned long smode,if (!dbtr_trigger_supported (TDATA1_GET_TYPE (ctrl))) { *out = _idx; -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_ERR_FAILED ; }if (!dbtr_trigger_valid (TDATA1_GET_TYPE (ctrl), ctrl)) { *out = _idx; -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_ERR_FAILED ; }
@@ -654,7 +654,7 @@ int sbi_dbtr_install_trig(unsigned long smode,if ((recv->tdata2 && !tdata2_impl) || (recv->tdata3 && !tdata3_impl)) { *out = _idx; -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_ERR_NOT_SUPPORTED ; }
@@ -662,7 +662,7 @@ int sbi_dbtr_install_trig(unsigned long smode,if (hs->available_trigs < trig_count) { *out = hs->available_trigs; -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_ERR_FAILED ; }
@@ -684,7 +684,7 @@ int sbi_dbtr_install_trig(unsigned long smode, } -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_SUCCESS ;
@@ -768,29 +768,29 @@ int sbi_dbtr_update_trig(unsigned long smode, tdata3_impl =tdata_implemented (CSR_TDATA3 );for_each_trig_entry (shmem_base, trig_count,typeof (*entry), entry) { -sbi_hart_protection_map_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_map_range ((unsigned long )entry,sizeof (*entry)); trig_idx = entry->id.idx;if (trig_idx >= hs->total_trigs) { -sbi_hart_protection_unmap_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_unmap_range ((unsigned long )entry,sizeof (*entry));return SBI_ERR_INVALID_PARAM ; } trig =INDEX_TO_TRIGGER (trig_idx);if (!(trig->state &RV_DBTR_BIT_MASK (TS ,MAPPED ))) { -sbi_hart_protection_unmap_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_unmap_range ((unsigned long )entry,sizeof (*entry));return SBI_ERR_FAILED ; }if ((entry->data.tdata2 && !tdata2_impl) || (entry->data.tdata3 && !tdata3_impl)) { -sbi_hart_protection_unmap_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_unmap_range ((unsigned long )entry,sizeof (*entry));return SBI_ERR_NOT_SUPPORTED ; }dbtr_trigger_setup (trig, &entry->data); -sbi_hart_protection_unmap_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_unmap_range ((unsigned long )entry,sizeof (*entry));dbtr_trigger_enable (trig); }
lib/sbi/sbi_ecall_dbcn.c +2 -2
@@ -46,12 +46,12 @@ static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid, regs->a1, regs->a0, smode, SBI_DOMAIN_READ|SBI_DOMAIN_WRITE))return SBI_ERR_INVALID_PARAM ; -sbi_hart_protection_map_range (regs->a1, regs->a0); +sbi_hart_protection_temp_map_range (regs->a1, regs->a0);if (funcid ==SBI_EXT_DBCN_CONSOLE_WRITE ) out->value =sbi_nputs ((const char *)regs->a1, regs->a0);else out->value =sbi_ngets ((char *)regs->a1, regs->a0); -sbi_hart_protection_unmap_range (regs->a1, regs->a0); +sbi_hart_protection_temp_unmap_range (regs->a1, regs->a0);return 0 ;case SBI_EXT_DBCN_CONSOLE_WRITE_BYTE :sbi_putc (regs->a0);
lib/sbi/sbi_hart_pmp.c +5 -5
@@ -135,7 +135,7 @@ int sbi_hart_pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *add* When shared memory access is required, the physical address * should be programmed into the first PMP entry with R/W * permissions to the M-mode. Once the work is done, it should be -* unmapped. sbi_hart_protection_map_range/sbi_hart_protection_unmap_range +* unmapped. sbi_hart_protection_temp_map_range/sbi_hart_protection_temp_unmap_range * function pair should be used to map/unmap the shared memory. */ #define SBI_SMEPMP_RESV_ENTRY 0
@@ -327,7 +327,7 @@ static int sbi_hart_smepmp_configure(struct sbi_scratch *scratch,return 0 ; } -static int sbi_hart_smepmp_map_range (struct sbi_scratch *scratch, +static int sbi_hart_smepmp_temp_map_range (struct sbi_scratch *scratch,unsigned long addr,unsigned long size) {/* shared R/W access for M and S/U mode */
@@ -359,7 +359,7 @@ static int sbi_hart_smepmp_map_range(struct sbi_scratch *scratch,return SBI_OK ; } -static int sbi_hart_smepmp_unmap_range (struct sbi_scratch *scratch, +static int sbi_hart_smepmp_temp_unmap_range (struct sbi_scratch *scratch,unsigned long addr,unsigned long size) {sbi_platform_pmp_disable (sbi_platform_ptr (scratch),SBI_SMEPMP_RESV_ENTRY );
@@ -436,8 +436,8 @@ static struct sbi_hart_protection epmp_protection = { .type = SBI_HART_PROTECTION_TYPE_MEMORY, .configure = sbi_hart_smepmp_configure, .unconfigure = sbi_hart_pmp_unconfigure, - .map_range = sbi_hart_smepmp_map_range, - .unmap_range = sbi_hart_smepmp_unmap_range, + .temp_map_range = sbi_hart_smepmp_temp_map_range, + .temp_unmap_range = sbi_hart_smepmp_temp_unmap_range, };int sbi_hart_pmp_init (struct sbi_scratch *scratch)
lib/sbi/sbi_hart_protection.c +6 -6
@@ -196,22 +196,22 @@ int sbi_hart_protection_reconfigure(struct sbi_scratch *scratch,return 0 ; } -int sbi_hart_protection_map_range (unsigned long base,unsigned long size) +int sbi_hart_protection_temp_map_range (unsigned long base,unsigned long size) {struct sbi_hart_protection *hprot =__hart_memory_protection_best (); -if (!hprot || !hprot->map_range) +if (!hprot || !hprot->temp_map_range)return 0 ; -return hprot->map_range (sbi_scratch_thishart_ptr (), base, size); +return hprot->temp_map_range (sbi_scratch_thishart_ptr (), base, size); } -int sbi_hart_protection_unmap_range (unsigned long base,unsigned long size) +int sbi_hart_protection_temp_unmap_range (unsigned long base,unsigned long size) {struct sbi_hart_protection *hprot =__hart_memory_protection_best (); -if (!hprot || !hprot->unmap_range) +if (!hprot || !hprot->temp_unmap_range)return 0 ; -return hprot->unmap_range (sbi_scratch_thishart_ptr (), base, size); +return hprot->temp_unmap_range (sbi_scratch_thishart_ptr (), base, size); }
lib/sbi/sbi_mpxy.c +12 -12
@@ -401,10 +401,10 @@ int sbi_mpxy_set_shmem(unsigned long shmem_phys_lo,if (flags ==SBI_EXT_MPXY_SHMEM_FLAG_OVERWRITE_RETURN ) { ret_buf = (unsigned long *)(ulong )SHMEM_PHYS_ADDR (shmem_phys_hi, shmem_phys_lo); -sbi_hart_protection_map_range ((unsigned long )ret_buf, mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )ret_buf, mpxy_shmem_size); ret_buf[0 ] =cpu_to_lle (ms->shmem.shmem_addr_lo); ret_buf[1 ] =cpu_to_lle (ms->shmem.shmem_addr_hi); -sbi_hart_protection_unmap_range ((unsigned long )ret_buf, mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )ret_buf, mpxy_shmem_size); }/** Setup the new shared memory */
@@ -436,7 +436,7 @@ int sbi_mpxy_get_channel_ids(u32 start_index)return SBI_ERR_INVALID_PARAM ; shmem_base =hart_shmem_base (ms); -sbi_hart_protection_map_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size);/** number of channel ids which can be stored in shmem adjusting * for remaining and returned fields */
@@ -466,7 +466,7 @@ int sbi_mpxy_get_channel_ids(u32 start_index) shmem_base[0 ] =cpu_to_le32 (remaining); shmem_base[1 ] =cpu_to_le32 (returned); -sbi_hart_protection_unmap_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size);return SBI_SUCCESS ; }
@@ -498,7 +498,7 @@ int sbi_mpxy_read_attrs(u32 channel_id, u32 base_attr_id, u32 attr_count) shmem_base =hart_shmem_base (ms); end_id = base_attr_id + attr_count -1 ; -sbi_hart_protection_map_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size);/* Standard attributes range check */ if (mpxy_is_std_attr (base_attr_id)) {
@@ -537,7 +537,7 @@ int sbi_mpxy_read_attrs(u32 channel_id, u32 base_attr_id, u32 attr_count) base_attr_id, attr_count); } out: -sbi_hart_protection_unmap_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size);return ret; }
@@ -650,7 +650,7 @@ int sbi_mpxy_write_attrs(u32 channel_id, u32 base_attr_id, u32 attr_count) shmem_base =hart_shmem_base (ms); end_id = base_attr_id + attr_count -1 ; -sbi_hart_protection_map_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, mpxy_shmem_size); mem_ptr = (u32 *)shmem_base;
@@ -707,7 +707,7 @@ int sbi_mpxy_write_attrs(u32 channel_id, u32 base_attr_id, u32 attr_count) base_attr_id, attr_count); } out: -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size);return ret; }
@@ -740,7 +740,7 @@ int sbi_mpxy_send_message(u32 channel_id, u8 msg_id,return SBI_ERR_INVALID_PARAM ; shmem_base =hart_shmem_base (ms); -sbi_hart_protection_map_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, mpxy_shmem_size);if (resp_data_len) { resp_buf = shmem_base;
@@ -757,7 +757,7 @@ int sbi_mpxy_send_message(u32 channel_id, u8 msg_id, msg_data_len); } -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size);if (ret ==SBI_ERR_TIMEOUT || ret ==SBI_ERR_IO )return ret;
@@ -788,12 +788,12 @@ int sbi_mpxy_get_notification_events(u32 channel_id, unsigned long *events_len)return SBI_ERR_NOT_SUPPORTED ; shmem_base =hart_shmem_base (ms); -sbi_hart_protection_map_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, mpxy_shmem_size); eventsbuf = shmem_base; ret = channel->get_notification_events (channel, eventsbuf, mpxy_shmem_size, events_len); -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size);if (ret)return ret;
lib/sbi/sbi_pmu.c +2 -2
@@ -1093,7 +1093,7 @@ int sbi_pmu_event_get_info(unsigned long shmem_phys_lo, unsigned long shmem_phys SBI_DOMAIN_READ | SBI_DOMAIN_WRITE))return SBI_ERR_INVALID_ADDRESS ; -sbi_hart_protection_map_range (shmem_phys_lo, shmem_size); +sbi_hart_protection_temp_map_range (shmem_phys_lo, shmem_size); einfo = (struct sbi_pmu_event_info *)(shmem_phys_lo);for (i =0 ; i < num_events; i++) {
@@ -1127,7 +1127,7 @@ int sbi_pmu_event_get_info(unsigned long shmem_phys_lo, unsigned long shmem_phys } } -sbi_hart_protection_unmap_range (shmem_phys_lo, shmem_size); +sbi_hart_protection_temp_unmap_range (shmem_phys_lo, shmem_size);return 0 ; }
lib/sbi/sbi_sse.c +4 -4
@@ -1037,7 +1037,7 @@ int sbi_sse_read_attrs(uint32_t event_id, uint32_t base_attr_id,if (ret)return ret; -sbi_hart_protection_map_range (output_phys_lo,sizeof (unsigned long ) * attr_count); +sbi_hart_protection_temp_map_range (output_phys_lo,sizeof (unsigned long ) * attr_count);/* * Copy all attributes at once since struct sse_event_attrs is matching
@@ -1050,7 +1050,7 @@ int sbi_sse_read_attrs(uint32_t event_id, uint32_t base_attr_id, attrs = (unsigned long *)output_phys_lo;copy_attrs (attrs, &e_attrs[base_attr_id], attr_count); -sbi_hart_protection_unmap_range (output_phys_lo,sizeof (unsigned long ) * attr_count); +sbi_hart_protection_temp_unmap_range (output_phys_lo,sizeof (unsigned long ) * attr_count);sse_event_put (e);
@@ -1065,7 +1065,7 @@ static int sse_write_attrs(struct sbi_sse_event *e, uint32_t base_attr_id,uint32_t id, end_id = base_attr_id + attr_count;unsigned long *attrs = (unsigned long *)input_phys; -sbi_hart_protection_map_range (input_phys,sizeof (unsigned long ) * attr_count); +sbi_hart_protection_temp_map_range (input_phys,sizeof (unsigned long ) * attr_count);for (id = base_attr_id; id < end_id; id++) { val = attrs[attr++];
@@ -1081,7 +1081,7 @@ static int sse_write_attrs(struct sbi_sse_event *e, uint32_t base_attr_id, } out: -sbi_hart_protection_unmap_range (input_phys,sizeof (unsigned long ) * attr_count); +sbi_hart_protection_temp_unmap_range (input_phys,sizeof (unsigned long ) * attr_count);return ret; }
Signature · 7 lines
2.51.0 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Re: [RFC PATCH v3 1/5] lib: sbi: Rename map_range/unmap_range functions
Quoted 4 lines · Rahul Pathak
*_map_rangeand*_unmap_rangefunctions are required in M-Mode to get the temporary access to S-Mode and U-Mode regions. Thse functions only operate using theTYPE_MEMORY
s/Ths/These/
Quoted 5 lines
memory protection mechanisms. Rename them to reflect the actual usage of these functions and let generic map/unmap_range names to implement generic functions
Signed-off-by Rahul Pathak <[email protected]>
LGTM.
Regards,
Anup
Quoted 447 lines
--- include/sbi/sbi_hart_protection.h | 27 ++++++++++++++++----------- lib/sbi/sbi_dbtr.c | 26 +++++++++++++------------- lib/sbi/sbi_ecall_dbcn.c | 4 ++-- lib/sbi/sbi_hart_pmp.c | 10 +++++----- lib/sbi/sbi_hart_protection.c | 12 ++++++------ lib/sbi/sbi_mpxy.c | 24 ++++++++++++------------ lib/sbi/sbi_pmu.c | 4 ++-- lib/sbi/sbi_sse.c | 8 ++++---- 8 files changed, 60 insertions(+), 55 deletions(-)include/sbi/sbi_hart_protection.h +16
-11@@ -40,13 +40,17 @@ struct sbi_hart_protection {/** Unconfigure protection for current HART (Optional) */ void (*unconfigure)(struct sbi_scratch *scratch,struct sbi_domain *dom); -/** Create temporary mapping to access address range on current HART (Optional) */ -int (*map_range)(struct sbi_scratch *scratch, -unsigned long base,unsigned long size); - -/** Destroy temporary mapping on current HART (Optional) */ -int (*unmap_range)(struct sbi_scratch *scratch, -unsigned long base,unsigned long size); +/** +* Give temporary M-mode access to an S/U-mode address range on current +* HART (Optional). Only applicable for the TYPE_MEMORY and the TYPE_ID +* mechanisms are not invoked. +*/ +int (*temp_map_range)(struct sbi_scratch *scratch, +unsigned long base,unsigned long size); + +/** Remove the temporary M-mode access on the current HART (Optional) */ +int (*temp_unmap_range)(struct sbi_scratch *scratch, +unsigned long base,unsigned long size); };/** @@ -111,23 +115,24 @@ int sbi_hart_protection_reconfigure(struct sbi_scratch *scratch, struct sbi_domain *next_dom);/** -* Create temporary mapping to access address range on current HART +* Give temporary M-mode access to an S/U-mode address range on the +* current HART. Only valid for TYPE_MEMORY. * * @param base base address of the temporary mapping * @param size size of the temporary mapping * * @return 0 on success and negative error code on failure */ -int sbi_hart_protection_map_range (unsigned long base,unsigned long size); +int sbi_hart_protection_temp_map_range (unsigned long base,unsigned long size);/** -* Destroy temporary mapping to access address range on current HART +* Remove the temporary M-mode access on the current HART * * @param base base address of the temporary mapping * @param size size of the temporary mapping * * @return 0 on success and negative error code on failure */ -int sbi_hart_protection_unmap_range (unsigned long base,unsigned long size); +int sbi_hart_protection_temp_unmap_range (unsigned long base,unsigned long size);#endif /* __SBI_HART_PROTECTION_H__ */ lib/sbi/sbi_dbtr.c +13
-13@@ -580,7 +580,7 @@ int sbi_dbtr_read_trig(unsigned long smode, shmem_base =hart_shmem_base (hs); -sbi_hart_protection_map_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));for_each_trig_entry (shmem_base, trig_count,typeof (*entry), entry) { xmit = &entry->data;@@ -594,7 +594,7 @@ int sbi_dbtr_read_trig(unsigned long smode, xmit->tdata2 =cpu_to_lle (trig->tdata2); xmit->tdata3 =cpu_to_lle (trig->tdata3); } -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_SUCCESS ;@@ -620,7 +620,7 @@ int sbi_dbtr_install_trig(unsigned long smode,return SBI_ERR_NO_SHMEM ; shmem_base =hart_shmem_base (hs); -sbi_hart_protection_map_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));/* @@ -639,14 +639,14 @@ int sbi_dbtr_install_trig(unsigned long smode,if (!dbtr_trigger_supported (TDATA1_GET_TYPE (ctrl))) { *out = _idx; -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_ERR_FAILED ; }if (!dbtr_trigger_valid (TDATA1_GET_TYPE (ctrl), ctrl)) { *out = _idx; -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_ERR_FAILED ; }@@ -654,7 +654,7 @@ int sbi_dbtr_install_trig(unsigned long smode,if ((recv->tdata2 && !tdata2_impl) || (recv->tdata3 && !tdata3_impl)) { *out = _idx; -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_ERR_NOT_SUPPORTED ; }@@ -662,7 +662,7 @@ int sbi_dbtr_install_trig(unsigned long smode,if (hs->available_trigs < trig_count) { *out = hs->available_trigs; -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_ERR_FAILED ; }@@ -684,7 +684,7 @@ int sbi_dbtr_install_trig(unsigned long smode, } -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_SUCCESS ;@@ -768,29 +768,29 @@ int sbi_dbtr_update_trig(unsigned long smode, tdata3_impl =tdata_implemented (CSR_TDATA3 );for_each_trig_entry (shmem_base, trig_count,typeof (*entry), entry) { -sbi_hart_protection_map_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_map_range ((unsigned long )entry,sizeof (*entry)); trig_idx = entry->id.idx;if (trig_idx >= hs->total_trigs) { -sbi_hart_protection_unmap_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_unmap_range ((unsigned long )entry,sizeof (*entry));return SBI_ERR_INVALID_PARAM ; } trig =INDEX_TO_TRIGGER (trig_idx);if (!(trig->state &RV_DBTR_BIT_MASK (TS ,MAPPED ))) { -sbi_hart_protection_unmap_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_unmap_range ((unsigned long )entry,sizeof (*entry));return SBI_ERR_FAILED ; }if ((entry->data.tdata2 && !tdata2_impl) || (entry->data.tdata3 && !tdata3_impl)) { -sbi_hart_protection_unmap_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_unmap_range ((unsigned long )entry,sizeof (*entry));return SBI_ERR_NOT_SUPPORTED ; }dbtr_trigger_setup (trig, &entry->data); -sbi_hart_protection_unmap_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_unmap_range ((unsigned long )entry,sizeof (*entry));dbtr_trigger_enable (trig); }lib/sbi/sbi_ecall_dbcn.c +2
-2@@ -46,12 +46,12 @@ static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid, regs->a1, regs->a0, smode, SBI_DOMAIN_READ|SBI_DOMAIN_WRITE))return SBI_ERR_INVALID_PARAM ; -sbi_hart_protection_map_range (regs->a1, regs->a0); +sbi_hart_protection_temp_map_range (regs->a1, regs->a0);if (funcid ==SBI_EXT_DBCN_CONSOLE_WRITE ) out->value =sbi_nputs ((const char *)regs->a1, regs->a0);else out->value =sbi_ngets ((char *)regs->a1, regs->a0); -sbi_hart_protection_unmap_range (regs->a1, regs->a0); +sbi_hart_protection_temp_unmap_range (regs->a1, regs->a0);return 0 ;case SBI_EXT_DBCN_CONSOLE_WRITE_BYTE :sbi_putc (regs->a0);lib/sbi/sbi_hart_pmp.c +5
-5@@ -135,7 +135,7 @@ int sbi_hart_pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *add* When shared memory access is required, the physical address * should be programmed into the first PMP entry with R/W * permissions to the M-mode. Once the work is done, it should be -* unmapped. sbi_hart_protection_map_range/sbi_hart_protection_unmap_range +* unmapped. sbi_hart_protection_temp_map_range/sbi_hart_protection_temp_unmap_range * function pair should be used to map/unmap the shared memory. */ #define SBI_SMEPMP_RESV_ENTRY 0@@ -327,7 +327,7 @@ static int sbi_hart_smepmp_configure(struct sbi_scratch *scratch,return 0 ; } -static int sbi_hart_smepmp_map_range (struct sbi_scratch *scratch, +static int sbi_hart_smepmp_temp_map_range (struct sbi_scratch *scratch,unsigned long addr,unsigned long size) {/* shared R/W access for M and S/U mode */ @@ -359,7 +359,7 @@ static int sbi_hart_smepmp_map_range(struct sbi_scratch *scratch,return SBI_OK ; } -static int sbi_hart_smepmp_unmap_range (struct sbi_scratch *scratch, +static int sbi_hart_smepmp_temp_unmap_range (struct sbi_scratch *scratch,unsigned long addr,unsigned long size) {sbi_platform_pmp_disable (sbi_platform_ptr (scratch),SBI_SMEPMP_RESV_ENTRY );@@ -436,8 +436,8 @@ static struct sbi_hart_protection epmp_protection = { .type = SBI_HART_PROTECTION_TYPE_MEMORY, .configure = sbi_hart_smepmp_configure, .unconfigure = sbi_hart_pmp_unconfigure, - .map_range = sbi_hart_smepmp_map_range, - .unmap_range = sbi_hart_smepmp_unmap_range, + .temp_map_range = sbi_hart_smepmp_temp_map_range, + .temp_unmap_range = sbi_hart_smepmp_temp_unmap_range, };int sbi_hart_pmp_init (struct sbi_scratch *scratch)lib/sbi/sbi_hart_protection.c +6
-6@@ -196,22 +196,22 @@ int sbi_hart_protection_reconfigure(struct sbi_scratch *scratch,return 0 ; } -int sbi_hart_protection_map_range (unsigned long base,unsigned long size) +int sbi_hart_protection_temp_map_range (unsigned long base,unsigned long size) {struct sbi_hart_protection *hprot =__hart_memory_protection_best (); -if (!hprot || !hprot->map_range) +if (!hprot || !hprot->temp_map_range)return 0 ; -return hprot->map_range (sbi_scratch_thishart_ptr (), base, size); +return hprot->temp_map_range (sbi_scratch_thishart_ptr (), base, size); } -int sbi_hart_protection_unmap_range (unsigned long base,unsigned long size) +int sbi_hart_protection_temp_unmap_range (unsigned long base,unsigned long size) {struct sbi_hart_protection *hprot =__hart_memory_protection_best (); -if (!hprot || !hprot->unmap_range) +if (!hprot || !hprot->temp_unmap_range)return 0 ; -return hprot->unmap_range (sbi_scratch_thishart_ptr (), base, size); +return hprot->temp_unmap_range (sbi_scratch_thishart_ptr (), base, size); }lib/sbi/sbi_mpxy.c +12
-12@@ -401,10 +401,10 @@ int sbi_mpxy_set_shmem(unsigned long shmem_phys_lo,if (flags ==SBI_EXT_MPXY_SHMEM_FLAG_OVERWRITE_RETURN ) { ret_buf = (unsigned long *)(ulong )SHMEM_PHYS_ADDR (shmem_phys_hi, shmem_phys_lo); -sbi_hart_protection_map_range ((unsigned long )ret_buf, mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )ret_buf, mpxy_shmem_size); ret_buf[0 ] =cpu_to_lle (ms->shmem.shmem_addr_lo); ret_buf[1 ] =cpu_to_lle (ms->shmem.shmem_addr_hi); -sbi_hart_protection_unmap_range ((unsigned long )ret_buf, mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )ret_buf, mpxy_shmem_size); }/** Setup the new shared memory */ @@ -436,7 +436,7 @@ int sbi_mpxy_get_channel_ids(u32 start_index)return SBI_ERR_INVALID_PARAM ; shmem_base =hart_shmem_base (ms); -sbi_hart_protection_map_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size);/** number of channel ids which can be stored in shmem adjusting * for remaining and returned fields */ @@ -466,7 +466,7 @@ int sbi_mpxy_get_channel_ids(u32 start_index) shmem_base[0 ] =cpu_to_le32 (remaining); shmem_base[1 ] =cpu_to_le32 (returned); -sbi_hart_protection_unmap_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size);return SBI_SUCCESS ; }@@ -498,7 +498,7 @@ int sbi_mpxy_read_attrs(u32 channel_id, u32 base_attr_id, u32 attr_count) shmem_base =hart_shmem_base (ms); end_id = base_attr_id + attr_count -1 ; -sbi_hart_protection_map_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size);/* Standard attributes range check */ if (mpxy_is_std_attr (base_attr_id)) {@@ -537,7 +537,7 @@ int sbi_mpxy_read_attrs(u32 channel_id, u32 base_attr_id, u32 attr_count) base_attr_id, attr_count); } out: -sbi_hart_protection_unmap_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size);return ret; }@@ -650,7 +650,7 @@ int sbi_mpxy_write_attrs(u32 channel_id, u32 base_attr_id, u32 attr_count) shmem_base =hart_shmem_base (ms); end_id = base_attr_id + attr_count -1 ; -sbi_hart_protection_map_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, mpxy_shmem_size); mem_ptr = (u32 *)shmem_base;@@ -707,7 +707,7 @@ int sbi_mpxy_write_attrs(u32 channel_id, u32 base_attr_id, u32 attr_count) base_attr_id, attr_count); } out: -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size);return ret; }@@ -740,7 +740,7 @@ int sbi_mpxy_send_message(u32 channel_id, u8 msg_id,return SBI_ERR_INVALID_PARAM ; shmem_base =hart_shmem_base (ms); -sbi_hart_protection_map_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, mpxy_shmem_size);if (resp_data_len) { resp_buf = shmem_base;@@ -757,7 +757,7 @@ int sbi_mpxy_send_message(u32 channel_id, u8 msg_id, msg_data_len); } -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size);if (ret ==SBI_ERR_TIMEOUT || ret ==SBI_ERR_IO )return ret;@@ -788,12 +788,12 @@ int sbi_mpxy_get_notification_events(u32 channel_id, unsigned long *events_len)return SBI_ERR_NOT_SUPPORTED ; shmem_base =hart_shmem_base (ms); -sbi_hart_protection_map_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, mpxy_shmem_size); eventsbuf = shmem_base; ret = channel->get_notification_events (channel, eventsbuf, mpxy_shmem_size, events_len); -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size);if (ret)return ret;lib/sbi/sbi_pmu.c +2
-2@@ -1093,7 +1093,7 @@ int sbi_pmu_event_get_info(unsigned long shmem_phys_lo, unsigned long shmem_phys SBI_DOMAIN_READ | SBI_DOMAIN_WRITE))return SBI_ERR_INVALID_ADDRESS ; -sbi_hart_protection_map_range (shmem_phys_lo, shmem_size); +sbi_hart_protection_temp_map_range (shmem_phys_lo, shmem_size); einfo = (struct sbi_pmu_event_info *)(shmem_phys_lo);for (i =0 ; i < num_events; i++) {@@ -1127,7 +1127,7 @@ int sbi_pmu_event_get_info(unsigned long shmem_phys_lo, unsigned long shmem_phys } } -sbi_hart_protection_unmap_range (shmem_phys_lo, shmem_size); +sbi_hart_protection_temp_unmap_range (shmem_phys_lo, shmem_size);return 0 ; }lib/sbi/sbi_sse.c +4
-5@@ -1037,7 +1037,7 @@ int sbi_sse_read_attrs(uint32_t event_id, uint32_t base_attr_id,if (ret)return ret; -sbi_hart_protection_map_range (output_phys_lo,sizeof (unsigned long ) * attr_count); +sbi_hart_protection_temp_map_range (output_phys_lo,sizeof (unsigned long ) * attr_count);/* * Copy all attributes at once since struct sse_event_attrs is matching @@ -1050,7 +1050,7 @@ int sbi_sse_read_attrs(uint32_t event_id, uint32_t base_attr_id, attrs = (unsigned long *)output_phys_lo;copy_attrs (attrs, &e_attrs[base_attr_id], attr_count); -sbi_hart_protection_unmap_range (output_phys_lo,sizeof (unsigned long ) * attr_count); +sbi_hart_protection_temp_unmap_range (output_phys_lo,sizeof (unsigned long ) * attr_count);sse_event_put (e);@@ -1065,7 +1065,7 @@ static int sse_write_attrs(struct sbi_sse_event *e, uint32_t base_attr_id,uint32_t id, end_id = base_attr_id + attr_count;unsigned long *attrs = (unsigned long *)input_phys; -sbi_hart_protection_map_range (input_phys,sizeof (unsigned long ) * attr_count); +sbi_hart_protection_temp_map_range (input_phys,sizeof (unsigned long ) * attr_count);for (id = base_attr_id; id < end_id; id++) { val = attrs[attr++];@@ -1081,7 +1081,7 @@ static int sse_write_attrs(struct sbi_sse_event *e, uint32_t base_attr_id, } out: -sbi_hart_protection_unmap_range (input_phys,sizeof (unsigned long ) * attr_count); +sbi_hart_protection_temp_unmap_range (input_phys,sizeof (unsigned long ) * attr_count);return ret; } --2.51.0
--
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Pawandeep Oza
Reviewed-byRe: [RFC PATCH v3 1/5] lib: sbi: Rename map_range/unmap_range functions
Quoted 467 lines · Anup Patel
Quoted 4 lines · Rahul Pathak
*_map_rangeand*_unmap_rangefunctions are required in M-Mode to get the temporary access to S-Mode and U-Mode regions. Thse functions only operate using theTYPE_MEMORYs/Ths/These/
Quoted 5 lines
memory protection mechanisms. Rename them to reflect the actual usage of these functions and let generic map/unmap_range names to implement generic functions
Signed-off-by Rahul Pathak <[email protected]>LGTM.
Reviewed-by Anup Patel <[email protected]>Regards,
AnupQuoted 443 lines
--- include/sbi/sbi_hart_protection.h | 27 ++++++++++++++++----------- lib/sbi/sbi_dbtr.c | 26 +++++++++++++------------- lib/sbi/sbi_ecall_dbcn.c | 4 ++-- lib/sbi/sbi_hart_pmp.c | 10 +++++----- lib/sbi/sbi_hart_protection.c | 12 ++++++------ lib/sbi/sbi_mpxy.c | 24 ++++++++++++------------ lib/sbi/sbi_pmu.c | 4 ++-- lib/sbi/sbi_sse.c | 8 ++++---- 8 files changed, 60 insertions(+), 55 deletions(-)include/sbi/sbi_hart_protection.h +16
-11@@ -40,13 +40,17 @@ struct sbi_hart_protection {/** Unconfigure protection for current HART (Optional) */ void (*unconfigure)(struct sbi_scratch *scratch,struct sbi_domain *dom); -/** Create temporary mapping to access address range on current HART (Optional) */ -int (*map_range)(struct sbi_scratch *scratch, -unsigned long base,unsigned long size); - -/** Destroy temporary mapping on current HART (Optional) */ -int (*unmap_range)(struct sbi_scratch *scratch, -unsigned long base,unsigned long size); +/** +* Give temporary M-mode access to an S/U-mode address range on current +* HART (Optional). Only applicable for the TYPE_MEMORY and the TYPE_ID +* mechanisms are not invoked. +*/ +int (*temp_map_range)(struct sbi_scratch *scratch, +unsigned long base,unsigned long size); + +/** Remove the temporary M-mode access on the current HART (Optional) */ +int (*temp_unmap_range)(struct sbi_scratch *scratch, +unsigned long base,unsigned long size); };/** @@ -111,23 +115,24 @@ int sbi_hart_protection_reconfigure(struct sbi_scratch *scratch, struct sbi_domain *next_dom);/** -* Create temporary mapping to access address range on current HART +* Give temporary M-mode access to an S/U-mode address range on the +* current HART. Only valid for TYPE_MEMORY. * * @param base base address of the temporary mapping * @param size size of the temporary mapping * * @return 0 on success and negative error code on failure */ -int sbi_hart_protection_map_range (unsigned long base,unsigned long size); +int sbi_hart_protection_temp_map_range (unsigned long base,unsigned long size);/** -* Destroy temporary mapping to access address range on current HART +* Remove the temporary M-mode access on the current HART * * @param base base address of the temporary mapping * @param size size of the temporary mapping * * @return 0 on success and negative error code on failure */ -int sbi_hart_protection_unmap_range (unsigned long base,unsigned long size); +int sbi_hart_protection_temp_unmap_range (unsigned long base,unsigned long size);#endif /* __SBI_HART_PROTECTION_H__ */ lib/sbi/sbi_dbtr.c +13
-13@@ -580,7 +580,7 @@ int sbi_dbtr_read_trig(unsigned long smode, shmem_base =hart_shmem_base (hs); -sbi_hart_protection_map_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));for_each_trig_entry (shmem_base, trig_count,typeof (*entry), entry) { xmit = &entry->data;@@ -594,7 +594,7 @@ int sbi_dbtr_read_trig(unsigned long smode, xmit->tdata2 =cpu_to_lle (trig->tdata2); xmit->tdata3 =cpu_to_lle (trig->tdata3); } -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_SUCCESS ;@@ -620,7 +620,7 @@ int sbi_dbtr_install_trig(unsigned long smode,return SBI_ERR_NO_SHMEM ; shmem_base =hart_shmem_base (hs); -sbi_hart_protection_map_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));/* @@ -639,14 +639,14 @@ int sbi_dbtr_install_trig(unsigned long smode,if (!dbtr_trigger_supported (TDATA1_GET_TYPE (ctrl))) { *out = _idx; -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_ERR_FAILED ; }if (!dbtr_trigger_valid (TDATA1_GET_TYPE (ctrl), ctrl)) { *out = _idx; -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_ERR_FAILED ; }@@ -654,7 +654,7 @@ int sbi_dbtr_install_trig(unsigned long smode,if ((recv->tdata2 && !tdata2_impl) || (recv->tdata3 && !tdata3_impl)) { *out = _idx; -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_ERR_NOT_SUPPORTED ; }@@ -662,7 +662,7 @@ int sbi_dbtr_install_trig(unsigned long smode,if (hs->available_trigs < trig_count) { *out = hs->available_trigs; -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_ERR_FAILED ; }@@ -684,7 +684,7 @@ int sbi_dbtr_install_trig(unsigned long smode, } -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, trig_count *sizeof (*entry));return SBI_SUCCESS ;@@ -768,29 +768,29 @@ int sbi_dbtr_update_trig(unsigned long smode, tdata3_impl =tdata_implemented (CSR_TDATA3 );for_each_trig_entry (shmem_base, trig_count,typeof (*entry), entry) { -sbi_hart_protection_map_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_map_range ((unsigned long )entry,sizeof (*entry)); trig_idx = entry->id.idx;if (trig_idx >= hs->total_trigs) { -sbi_hart_protection_unmap_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_unmap_range ((unsigned long )entry,sizeof (*entry));return SBI_ERR_INVALID_PARAM ; } trig =INDEX_TO_TRIGGER (trig_idx);if (!(trig->state &RV_DBTR_BIT_MASK (TS ,MAPPED ))) { -sbi_hart_protection_unmap_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_unmap_range ((unsigned long )entry,sizeof (*entry));return SBI_ERR_FAILED ; }if ((entry->data.tdata2 && !tdata2_impl) || (entry->data.tdata3 && !tdata3_impl)) { -sbi_hart_protection_unmap_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_unmap_range ((unsigned long )entry,sizeof (*entry));return SBI_ERR_NOT_SUPPORTED ; }dbtr_trigger_setup (trig, &entry->data); -sbi_hart_protection_unmap_range ((unsigned long )entry,sizeof (*entry)); +sbi_hart_protection_temp_unmap_range ((unsigned long )entry,sizeof (*entry));dbtr_trigger_enable (trig); }lib/sbi/sbi_ecall_dbcn.c +2
-2@@ -46,12 +46,12 @@ static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid, regs->a1, regs->a0, smode, SBI_DOMAIN_READ|SBI_DOMAIN_WRITE))return SBI_ERR_INVALID_PARAM ; -sbi_hart_protection_map_range (regs->a1, regs->a0); +sbi_hart_protection_temp_map_range (regs->a1, regs->a0);if (funcid ==SBI_EXT_DBCN_CONSOLE_WRITE ) out->value =sbi_nputs ((const char *)regs->a1, regs->a0);else out->value =sbi_ngets ((char *)regs->a1, regs->a0); -sbi_hart_protection_unmap_range (regs->a1, regs->a0); +sbi_hart_protection_temp_unmap_range (regs->a1, regs->a0);return 0 ;case SBI_EXT_DBCN_CONSOLE_WRITE_BYTE :sbi_putc (regs->a0);lib/sbi/sbi_hart_pmp.c +5
-5@@ -135,7 +135,7 @@ int sbi_hart_pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *add* When shared memory access is required, the physical address * should be programmed into the first PMP entry with R/W * permissions to the M-mode. Once the work is done, it should be -* unmapped. sbi_hart_protection_map_range/sbi_hart_protection_unmap_range +* unmapped. sbi_hart_protection_temp_map_range/sbi_hart_protection_temp_unmap_range * function pair should be used to map/unmap the shared memory. */ #define SBI_SMEPMP_RESV_ENTRY 0@@ -327,7 +327,7 @@ static int sbi_hart_smepmp_configure(struct sbi_scratch *scratch,return 0 ; } -static int sbi_hart_smepmp_map_range (struct sbi_scratch *scratch, +static int sbi_hart_smepmp_temp_map_range (struct sbi_scratch *scratch,unsigned long addr,unsigned long size) {/* shared R/W access for M and S/U mode */ @@ -359,7 +359,7 @@ static int sbi_hart_smepmp_map_range(struct sbi_scratch *scratch,return SBI_OK ; } -static int sbi_hart_smepmp_unmap_range (struct sbi_scratch *scratch, +static int sbi_hart_smepmp_temp_unmap_range (struct sbi_scratch *scratch,unsigned long addr,unsigned long size) {sbi_platform_pmp_disable (sbi_platform_ptr (scratch),SBI_SMEPMP_RESV_ENTRY );@@ -436,8 +436,8 @@ static struct sbi_hart_protection epmp_protection = { .type = SBI_HART_PROTECTION_TYPE_MEMORY, .configure = sbi_hart_smepmp_configure, .unconfigure = sbi_hart_pmp_unconfigure, - .map_range = sbi_hart_smepmp_map_range, - .unmap_range = sbi_hart_smepmp_unmap_range, + .temp_map_range = sbi_hart_smepmp_temp_map_range, + .temp_unmap_range = sbi_hart_smepmp_temp_unmap_range, };int sbi_hart_pmp_init (struct sbi_scratch *scratch)lib/sbi/sbi_hart_protection.c +6
-6@@ -196,22 +196,22 @@ int sbi_hart_protection_reconfigure(struct sbi_scratch *scratch,return 0 ; } -int sbi_hart_protection_map_range (unsigned long base,unsigned long size) +int sbi_hart_protection_temp_map_range (unsigned long base,unsigned long size) {struct sbi_hart_protection *hprot =__hart_memory_protection_best (); -if (!hprot || !hprot->map_range) +if (!hprot || !hprot->temp_map_range)return 0 ; -return hprot->map_range (sbi_scratch_thishart_ptr (), base, size); +return hprot->temp_map_range (sbi_scratch_thishart_ptr (), base, size); } -int sbi_hart_protection_unmap_range (unsigned long base,unsigned long size) +int sbi_hart_protection_temp_unmap_range (unsigned long base,unsigned long size) {struct sbi_hart_protection *hprot =__hart_memory_protection_best (); -if (!hprot || !hprot->unmap_range) +if (!hprot || !hprot->temp_unmap_range)return 0 ; -return hprot->unmap_range (sbi_scratch_thishart_ptr (), base, size); +return hprot->temp_unmap_range (sbi_scratch_thishart_ptr (), base, size); }lib/sbi/sbi_mpxy.c +12
-12@@ -401,10 +401,10 @@ int sbi_mpxy_set_shmem(unsigned long shmem_phys_lo,if (flags ==SBI_EXT_MPXY_SHMEM_FLAG_OVERWRITE_RETURN ) { ret_buf = (unsigned long *)(ulong )SHMEM_PHYS_ADDR (shmem_phys_hi, shmem_phys_lo); -sbi_hart_protection_map_range ((unsigned long )ret_buf, mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )ret_buf, mpxy_shmem_size); ret_buf[0 ] =cpu_to_lle (ms->shmem.shmem_addr_lo); ret_buf[1 ] =cpu_to_lle (ms->shmem.shmem_addr_hi); -sbi_hart_protection_unmap_range ((unsigned long )ret_buf, mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )ret_buf, mpxy_shmem_size); }/** Setup the new shared memory */ @@ -436,7 +436,7 @@ int sbi_mpxy_get_channel_ids(u32 start_index)return SBI_ERR_INVALID_PARAM ; shmem_base =hart_shmem_base (ms); -sbi_hart_protection_map_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size);/** number of channel ids which can be stored in shmem adjusting * for remaining and returned fields */ @@ -466,7 +466,7 @@ int sbi_mpxy_get_channel_ids(u32 start_index) shmem_base[0 ] =cpu_to_le32 (remaining); shmem_base[1 ] =cpu_to_le32 (returned); -sbi_hart_protection_unmap_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size);return SBI_SUCCESS ; }@@ -498,7 +498,7 @@ int sbi_mpxy_read_attrs(u32 channel_id, u32 base_attr_id, u32 attr_count) shmem_base =hart_shmem_base (ms); end_id = base_attr_id + attr_count -1 ; -sbi_hart_protection_map_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size);/* Standard attributes range check */ if (mpxy_is_std_attr (base_attr_id)) {@@ -537,7 +537,7 @@ int sbi_mpxy_read_attrs(u32 channel_id, u32 base_attr_id, u32 attr_count) base_attr_id, attr_count); } out: -sbi_hart_protection_unmap_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )hart_shmem_base (ms), mpxy_shmem_size);return ret; }@@ -650,7 +650,7 @@ int sbi_mpxy_write_attrs(u32 channel_id, u32 base_attr_id, u32 attr_count) shmem_base =hart_shmem_base (ms); end_id = base_attr_id + attr_count -1 ; -sbi_hart_protection_map_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, mpxy_shmem_size); mem_ptr = (u32 *)shmem_base;@@ -707,7 +707,7 @@ int sbi_mpxy_write_attrs(u32 channel_id, u32 base_attr_id, u32 attr_count) base_attr_id, attr_count); } out: -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size);return ret; }@@ -740,7 +740,7 @@ int sbi_mpxy_send_message(u32 channel_id, u8 msg_id,return SBI_ERR_INVALID_PARAM ; shmem_base =hart_shmem_base (ms); -sbi_hart_protection_map_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, mpxy_shmem_size);if (resp_data_len) { resp_buf = shmem_base;@@ -757,7 +757,7 @@ int sbi_mpxy_send_message(u32 channel_id, u8 msg_id, msg_data_len); } -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size);if (ret ==SBI_ERR_TIMEOUT || ret ==SBI_ERR_IO )return ret;@@ -788,12 +788,12 @@ int sbi_mpxy_get_notification_events(u32 channel_id, unsigned long *events_len)return SBI_ERR_NOT_SUPPORTED ; shmem_base =hart_shmem_base (ms); -sbi_hart_protection_map_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_map_range ((unsigned long )shmem_base, mpxy_shmem_size); eventsbuf = shmem_base; ret = channel->get_notification_events (channel, eventsbuf, mpxy_shmem_size, events_len); -sbi_hart_protection_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size); +sbi_hart_protection_temp_unmap_range ((unsigned long )shmem_base, mpxy_shmem_size);if (ret)return ret;lib/sbi/sbi_pmu.c +2
-2@@ -1093,7 +1093,7 @@ int sbi_pmu_event_get_info(unsigned long shmem_phys_lo, unsigned long shmem_phys SBI_DOMAIN_READ | SBI_DOMAIN_WRITE))return SBI_ERR_INVALID_ADDRESS ; -sbi_hart_protection_map_range (shmem_phys_lo, shmem_size); +sbi_hart_protection_temp_map_range (shmem_phys_lo, shmem_size); einfo = (struct sbi_pmu_event_info *)(shmem_phys_lo);for (i =0 ; i < num_events; i++) {@@ -1127,7 +1127,7 @@ int sbi_pmu_event_get_info(unsigned long shmem_phys_lo, unsigned long shmem_phys } } -sbi_hart_protection_unmap_range (shmem_phys_lo, shmem_size); +sbi_hart_protection_temp_unmap_range (shmem_phys_lo, shmem_size);return 0 ; }lib/sbi/sbi_sse.c +4
-5@@ -1037,7 +1037,7 @@ int sbi_sse_read_attrs(uint32_t event_id, uint32_t base_attr_id,if (ret)return ret; -sbi_hart_protection_map_range (output_phys_lo,sizeof (unsigned long ) * attr_count); +sbi_hart_protection_temp_map_range (output_phys_lo,sizeof (unsigned long ) * attr_count);/* * Copy all attributes at once since struct sse_event_attrs is matching @@ -1050,7 +1050,7 @@ int sbi_sse_read_attrs(uint32_t event_id, uint32_t base_attr_id, attrs = (unsigned long *)output_phys_lo;copy_attrs (attrs, &e_attrs[base_attr_id], attr_count); -sbi_hart_protection_unmap_range (output_phys_lo,sizeof (unsigned long ) * attr_count); +sbi_hart_protection_temp_unmap_range (output_phys_lo,sizeof (unsigned long ) * attr_count);sse_event_put (e);@@ -1065,7 +1065,7 @@ static int sse_write_attrs(struct sbi_sse_event *e, uint32_t base_attr_id,uint32_t id, end_id = base_attr_id + attr_count;unsigned long *attrs = (unsigned long *)input_phys; -sbi_hart_protection_map_range (input_phys,sizeof (unsigned long ) * attr_count); +sbi_hart_protection_temp_map_range (input_phys,sizeof (unsigned long ) * attr_count);for (id = base_attr_id; id < end_id; id++) { val = attrs[attr++];@@ -1081,7 +1081,7 @@ static int sse_write_attrs(struct sbi_sse_event *e, uint32_t base_attr_id, } out: -sbi_hart_protection_unmap_range (input_phys,sizeof (unsigned long ) * attr_count); +sbi_hart_protection_temp_unmap_range (input_phys,sizeof (unsigned long ) * attr_count);return ret; } --2.51.0
Quoted 9 lines
Quoted 4 lines
--
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi--
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
RFC PATCH v3 2/5 riscv: Add Smsdid and Smmpt hart extensions
In reply to Rahul PathakAdd hart extension identifiers for the RISC-V Smsdid (supervisor domain ID) and Smmpt (supervisor domain memory protection) extensions.
--- include/sbi/sbi_hart.h | 4 ++++ lib/sbi/sbi_hart.c | 2 ++ 2 files changed, 6 insertions(+)
include/sbi/sbi_hart.h +4 -0
@@ -95,6 +95,10 @@ enum sbi_hart_extensions {SBI_HART_EXT_F ,/** Hart has D extension */ SBI_HART_EXT_D , +/** Hart has SMMTT - SMSDID extension */ +SBI_HART_EXT_SMSDID , +/** Hart has SMMTT - SMMPT extension */ +SBI_HART_EXT_SMMPT ,/** Maximum index of Hart extension */ SBI_HART_EXT_MAX,
lib/sbi/sbi_hart.c +2 -0
@@ -360,6 +360,8 @@ const struct sbi_hart_ext_data sbi_hart_ext[] = {__SBI_HART_EXT_DATA (v,SBI_HART_EXT_V ),__SBI_HART_EXT_DATA (f,SBI_HART_EXT_F ),__SBI_HART_EXT_DATA (d,SBI_HART_EXT_D ), +__SBI_HART_EXT_DATA (smsdid,SBI_HART_EXT_SMSDID ), +__SBI_HART_EXT_DATA (smmpt,SBI_HART_EXT_SMMPT ), }; _Static_assert(SBI_HART_EXT_MAX == array_size(sbi_hart_ext),
Signature · 7 lines
2.51.0 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Re: [RFC PATCH v3 2/5] riscv: Add Smsdid and Smmpt hart extensions
Quoted 7 lines · Rahul Pathak
Add hart extension identifiers for the RISC-V Smsdid (supervisor domain ID) and Smmpt (supervisor domain memory protection) extensions.
Signed-off-by Rahul Pathak <[email protected]>Reviewed-by Pawandeep Oza <[email protected]>Reviewed-by Ranbir Singh <[email protected]>
LGTM.
Regards,
Anup
Quoted 41 lines
--- include/sbi/sbi_hart.h | 4 ++++ lib/sbi/sbi_hart.c | 2 ++ 2 files changed, 6 insertions(+)include/sbi/sbi_hart.h +4
-0@@ -95,6 +95,10 @@ enum sbi_hart_extensions {SBI_HART_EXT_F ,/** Hart has D extension */ SBI_HART_EXT_D , +/** Hart has SMMTT - SMSDID extension */ +SBI_HART_EXT_SMSDID , +/** Hart has SMMTT - SMMPT extension */ +SBI_HART_EXT_SMMPT ,/** Maximum index of Hart extension */ SBI_HART_EXT_MAX,lib/sbi/sbi_hart.c +2
-1@@ -360,6 +360,8 @@ const struct sbi_hart_ext_data sbi_hart_ext[] = {__SBI_HART_EXT_DATA (v,SBI_HART_EXT_V ),__SBI_HART_EXT_DATA (f,SBI_HART_EXT_F ),__SBI_HART_EXT_DATA (d,SBI_HART_EXT_D ), +__SBI_HART_EXT_DATA (smsdid,SBI_HART_EXT_SMSDID ), +__SBI_HART_EXT_DATA (smmpt,SBI_HART_EXT_SMMPT ), }; _Static_assert(SBI_HART_EXT_MAX == array_size(sbi_hart_ext), --2.51.0
--
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
RFC PATCH v3 3/5 mpt: Add Smsdid and Smmpt supervisor domain core
In reply to Rahul PathakIntroduce the supervisord omain memory-protection (Smmpt) table management core. This adds the mode agnostic core layer and the per mode table walkers/builder.
Add defines for the mmpt CSR encoding, MPTE bit layout, permission flags, structures, fence helpers and the public interfaces.
It implements the RV64 supported modes (Smmpt43/52/64) and the RV32 mode (Smmpt34), its MPT table support.
Also implements mpt core which integrates Smmpt with SBI domains and other core layers.
--- include/sbi/sbi_mpt.h | 336 ++++++++++++++ lib/sbi/objects.mk | 2 + lib/sbi/sbi_mpt.c | 955 +++++++++++++++++++++++++++++++++++++++ lib/sbi/sbi_mpt_mode.c | 997 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 2290 insertions(+) create mode 100644 include/sbi/sbi_mpt.h create mode 100644 lib/sbi/sbi_mpt.c create mode 100644 lib/sbi/sbi_mpt_mode.c
include/sbi/sbi_mpt.h new file +336 -0
@@ -0,0 +1,336 @@ +/* SPDX-License-Identifier: BSD-2-Clause +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* +* Authors: Rahul Pathak <[email protected]> +*/ + +#ifndef __SBI_MPT_H__ +#define __SBI_MPT_H__ + +#include <sbi/sbi_types.h> +#include <sbi/riscv_locks.h> +#include <sbi/sbi_scratch.h> +#include <sbi/sbi_bitmap.h> +#include <sbi/riscv_asm.h> + +struct sbi_domain; +struct sbi_mpt_domain; +struct sbi_mpt_ctrl; +struct sbi_domain_memregion; + +/* CSR addresses */ +#define SBI_CSR_MMPT 0x382 +#define SBI_CSR_MSDCFG 0x74E + +/* mmpt register field definitions */ +#if __riscv_xlen == 64 +# define SBI_MMPT_MODE_SHIFT 60UL +# define SBI_MMPT_MODE_MASK (UL(0xF) << SBI_MMPT_MODE_SHIFT) +# define SBI_MMPT_SDID_SHIFT 52UL +# define SBI_MMPT_SDID_MASK (UL(0x3F) << SBI_MMPT_SDID_SHIFT) +# define SBI_MMPT_PPN_MASK UL(0x00000FFFFFFFFFFF) +#else +# define SBI_MMPT_MODE_SHIFT 30UL +# define SBI_MMPT_MODE_MASK (UL(0x3) << SBI_MMPT_MODE_SHIFT) +# define SBI_MMPT_SDID_SHIFT 22UL +# define SBI_MMPT_SDID_MASK (UL(0x3F) << SBI_MMPT_SDID_SHIFT) +# define SBI_MMPT_PPN_MASK UL(0x3FFFFF) +#endif + +#define SBI_MMPT_MODE_BARE 0UL +#if __riscv_xlen == 64 +# define SBI_MMPT_MODE_SMMPT43 1UL +# define SBI_MMPT_MODE_SMMPT52 2UL +# define SBI_MMPT_MODE_SMMPT64 3UL +#else +# define SBI_MMPT_MODE_SMMPT34 1UL +#endif + +/* + * sbi_mmpt_encode() — assemble the full mmpt CSR value. + */ +static inline unsigned long sbi_mmpt_encode(u32 mode, u32 sdid, + unsigned long ppn) +{ + return (((unsigned long)mode << SBI_MMPT_MODE_SHIFT) & SBI_MMPT_MODE_MASK) | + (((unsigned long)sdid << SBI_MMPT_SDID_SHIFT) & SBI_MMPT_SDID_MASK) | + (ppn & SBI_MMPT_PPN_MASK); +} + +/* + * MPTE bit definitions + */ +#define SBI_MPTE_V (1UL << 0) +#define SBI_MPTE_L (1UL << 1) +#define SBI_MPTE_N (1UL << 2) +#define SBI_MPTE_PPN_SHIFT 10U +#define SBI_MPT_PAGE_SHIFT 12U +#define SBI_MPT_PAGE_SIZE 4096UL +#define SBI_MPT_PAGE_MASK (SBI_MPT_PAGE_SIZE - 1UL) +#define SBI_MPTE_XWR_BASE 8U +#define SBI_MPTE_XWR_WIDTH 3U +#define SBI_MPTE_XWR_MASK 7UL + +static inline u32 sbi_mpte_xwr_shift(u32 n) +{ + return (SBI_MPTE_XWR_BASE + n * SBI_MPTE_XWR_WIDTH); +} + +static inline unsigned long sbi_mpte_leaf_set_xwr(unsigned long mpte, + u32 n, u8 xwr) +{ + u32 sh = sbi_mpte_xwr_shift(n); + + mpte &= ~(SBI_MPTE_XWR_MASK << sh); + mpte |= (xwr & SBI_MPTE_XWR_MASK) << sh; + return mpte; +} + +static inline unsigned long sbi_mpte_nonleaf(unsigned long table_pa) +{ + return (((table_pa >> SBI_MPT_PAGE_SHIFT) << SBI_MPTE_PPN_SHIFT) + | SBI_MPTE_V); +} + +static inline unsigned long sbi_mpte_nonleaf_table_pa(unsigned long mpte) +{ + return ((mpte >> SBI_MPTE_PPN_SHIFT) << SBI_MPT_PAGE_SHIFT); +} + +/* + * XWR permission constants (XWR=000 means no access) + */ +#define SBI_MPT_PERM_NONE 0U +#define SBI_MPT_PERM_R 1U +#define SBI_MPT_PERM_W 2U +#define SBI_MPT_PERM_X 4U +#define SBI_MPT_PERM_RW (SBI_MPT_PERM_R | SBI_MPT_PERM_W) +#define SBI_MPT_PERM_RX (SBI_MPT_PERM_R | SBI_MPT_PERM_X) +#define SBI_MPT_PERM_RWX (SBI_MPT_PERM_R | SBI_MPT_PERM_W | SBI_MPT_PERM_X) + +/* + * SDID constants + */ +#define SBI_MPT_SDIDMAX 6U +#define SBI_MPT_MAX_DOMAINS (1UL << SBI_MPT_SDIDMAX) +#define SBI_MPT_SDID_INVALID SBI_MPT_MAX_DOMAINS + +/* + * SBI_MPT_MAX_REGIONS_DOMAIN: Number of regions a domain may have + * Used for tracking of regions + */ +#define SBI_MPT_MAX_REGIONS_DOMAIN 32U + +/* + * SMSDID mfence and minval raw encodings + * + * R-type, opcode=SYSTEM(0x73), funct3=0, rd=x0, rs1=PADDR, rs2=SDID + * mfence.pa funct7=0x19 -> 0x32000073 where rs1=rs2=x0 + * minval.pa funct7=0x1b -> 0x36000073 where rs1=rs2=x0 + * + * .insn r opcode, func3, func7, rd, rs1, rs2 + */ +#define SBI_MPT_MFENCE_PA(rs1, rs2) ".insn r 0x73, 0, 0x19, x0, " rs1 ", " rs2 + +#define SBI_MPT_MINVAL_PA(rs1, rs2) ".insn r 0x73, 0, 0x1b, x0, " rs1 ", " rs2 + +/* + * Fence and invalidation helpers + */ +static inline void sbi_mpt_fence_all(void) +{ + __asm__ volatile(SBI_MPT_MFENCE_PA("x0", "x0") ::: "memory"); +} + +static inline void sbi_mpt_fence_sdid(u32 sdid) +{ + unsigned long s = (unsigned long)sdid & (SBI_MPT_MAX_DOMAINS - 1UL); + + __asm__ volatile(SBI_MPT_MFENCE_PA("x0", "%0") :: "r"(s) : "memory"); +} + +/* + * rs1=paddr and rs2=x0 + */ +static inline void sbi_mpt_mfence_addr(unsigned long paddr) +{ + __asm__ volatile(SBI_MPT_MFENCE_PA("%0", "x0") :: "r"(paddr) : "memory"); +} + +/* + * rs1=paddr and rs2=sdid + */ +static inline void sbi_mpt_mfence_pa(unsigned long paddr, u32 sdid) +{ + unsigned long s = (unsigned long)sdid & (SBI_MPT_MAX_DOMAINS - 1UL); + + __asm__ volatile(SBI_MPT_MFENCE_PA("%0", "%1") + :: "r"(paddr), "r"(s) : "memory"); +} + +/* + * rs1=0 and rs2=0 + */ +static inline void sbi_mpt_minval_all(void) +{ + /* Prior stores globally visible before invalidation */ + __asm__ volatile("sfence.w.inval" ::: "memory"); + __asm__ volatile(SBI_MPT_MINVAL_PA("x0", "x0") ::: "memory"); + /* Invalidation completes before subsequent implicit accesses */ + __asm__ volatile("sfence.inval.ir" ::: "memory"); +} + +/* + * rs1=paddr and rs2=sdid + */ +static inline void sbi_mpt_minval_sdid(unsigned long pa, u32 sdid) +{ + unsigned long s = (unsigned long)sdid & (SBI_MPT_MAX_DOMAINS - 1UL); + + __asm__ volatile("sfence.w.inval" ::: "memory"); + __asm__ volatile(SBI_MPT_MINVAL_PA("%0", "%1") + :: "r"(pa), "r"(s) : "memory"); + __asm__ volatile("sfence.inval.ir" ::: "memory"); +} + +/* + * Core data structures + */ +struct sbi_mpt_region { + unsigned long pa; + unsigned long size; + u8 xwr; + /* region is locked and deny modification via add/remove_region */ + bool locked; + /* mapped into more than one domain */ + bool shared; +}; + +/* + * struct sbi_mpt_mode — SMMPT mode description. + */ +struct sbi_mpt_mode { + const char *name; + u32 mode_val; + + /* Assemble the MMPT CSR value */ + unsigned long (*encode_mmpt)(unsigned long ppn, u32 sdid); + + /* map a range in MPT table */ + int (*map_range)(struct sbi_mpt_domain *dom, + unsigned long pa, unsigned long size, u8 xwr); + + /* number bytes for root table allocation */ + unsigned long (*root_table_size)(void); + + /* required root table physical address alignment */ + unsigned long (*root_table_align)(void); + + /* check if [pa,pa+size] fits in smmpt mode supported address space */ + bool (*pa_in_range)(unsigned long pa, unsigned long size); + + /* map full range of address space which is supported by the mode */ + int (*map_full_range)(struct sbi_mpt_domain *dom, u8 xwr); + + /* read the xwr for a PA */ + u8 (*get_xwr)(struct sbi_mpt_domain *dom, unsigned long pa); +}; + +struct sbi_mpt_domain { + u32 sdid; + bool valid; + unsigned long root_pa; + struct sbi_mpt_mode *mode; + struct sbi_domain *sbi_dom; + unsigned int nregions; + struct sbi_mpt_region regions[SBI_MPT_MAX_REGIONS_DOMAIN]; + spinlock_t lock; +}; + +/* + * struct sbi_mpt_ctrl — RDSM MPT state + */ +struct sbi_mpt_ctrl { + bool ready; + struct sbi_mpt_mode *mode; + /* detected sdidlen from mmpt probe */ + u32 sdid_len; + /* 2^sdid_len — runtime limit for all domain operations */ + u32 max_domains; + unsigned long fw_pa; + unsigned long fw_size; + struct sbi_mpt_domain domains[SBI_MPT_MAX_DOMAINS]; + u32 ndomain; + /* sdid offset in scratch */ + unsigned long sdid_offset; + /* bitmap to track assigned/free SDID (bit N set = SDID N free) */ + DECLARE_BITMAP(sdid_bitmap, SBI_MPT_MAX_DOMAINS); +}; + +struct sbi_mpt_ctrl *sbi_mpt_ctrl_get(void); + +static inline u32 sbi_mpt_thishart_sdid(void) +{ + struct sbi_mpt_ctrl *ctrl = sbi_mpt_ctrl_get(); + u32 *p; + + if (!ctrl->ready || !ctrl->sdid_offset) + return (u32)SBI_MPT_SDID_INVALID; + p = sbi_scratch_offset_ptr(sbi_scratch_thishart_ptr(), + ctrl->sdid_offset); + return *p; +} + +/* + * Domain creation config + * + * sbi_dom and regions are mutually exclusive. + * when a supervisor domain is backed by a SBI domain + * then the regions list and access permissions are derived + * from the SBI domain structures. + */ +struct sbi_mpt_domain_config { + /* SBI domain whose S/U memregions are mapped. */ + struct sbi_domain *sbi_dom; + /* permission for regions inherited from sbi_dom */ + u8 xwr; + /* protect firmware regions for the domain */ + bool fw_protect; + /* + * explicit region list mapped in MPT table. + * NULL when sbi_dom covers everything + */ + struct sbi_mpt_region *regions; + u32 nregions; +}; + +int sbi_mpt_init(void); + +int sbi_mpt_domain_create(const struct sbi_mpt_domain_config *cfg, u32 *out_sdid); + +int sbi_mpt_domain_add_region(u32 sdid, unsigned long pa, unsigned long size, u8 xwr); + +int sbi_mpt_domain_remove_region(u32 sdid, unsigned long pa, unsigned long size); + +int sbi_mpt_share_region(u32 src_sdid, u32 dst_sdid, unsigned long pa, unsigned long size, u8 dst_xwr); + +int sbi_mpt_unshare_region(u32 sdid, unsigned long pa, unsigned long size); + +int sbi_mpt_hart_activate(u32 sdid); + +void sbi_mpt_hart_deactivate(void); + +int sbi_mpt_hart_activate_for_domain(struct sbi_domain *sbi_dom); + +struct sbi_mpt_domain *sbi_mpt_domain_get(u32 sdid); + +unsigned long sbi_mpt_pool_alloc(unsigned long size, unsigned long align); + +void sbi_mpt_sdid_free(u32 sdid); + +int sbi_mpt_query_access(u32 sdid, unsigned long pa, u8 *out_xwr); + +void sbi_mpt_dump(void); + +#endif /* __SBI_MPT_H__ */
lib/sbi/objects.mk +2 -0
@@ -108,3 +108,5 @@ libsbi-objs-y += sbi_expected_trap.o libsbi-objs-y += sbi_cppc.o libsbi-objs-$(CC_SUPPORT_VECTOR) += sbi_vector.o libsbi-objs-y += sbi_fp.o +libsbi-objs-y += sbi_mpt.o +libsbi-objs-y += sbi_mpt_mode.o
lib/sbi/sbi_mpt.c new file +955 -0
955 lines not on this page · raw message
lib/sbi/sbi_mpt_mode.c new file +997 -0
997 lines not on this page · raw message
Signature · 7 lines
2.51.0 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
RFC PATCH v3 4/5 platform/generic: Initialise MPT at boot
In reply to Rahul PathakIntegrates MPT initialisation into the generic platform boot flow.
mpt_early_init() probes for SMMPT during cold-boot early init and initialises the structures required to build MPT tables.
mpt_final_init() creates the root supervisor domain which is mapping all physical memory with the firmware region explcitly denied to S-mode and adds support for an MPT domain for each additional registered SBI domain.
The heap budget is extended to reserve space for MPT tables.
With this patch MPT tables are built at boot.
--- platform/generic/platform.c | 101 ++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+)
platform/generic/platform.c +101 -0
@@ -17,6 +17,9 @@#include <sbi/sbi_string.h> #include <sbi/sbi_system.h> #include <sbi/sbi_tlb.h> +#include <sbi/sbi_mpt.h> +#include <sbi/sbi_domain.h> +#include <sbi/sbi_console.h> #include <sbi_utils/cache/fdt_cmo_helper.h> #include <sbi_utils/fdt/fdt_domain.h> #include <sbi_utils/fdt/fdt_driver.h>
@@ -33,6 +36,86 @@/* List of platform override modules generated at compile time */ extern const struct fdt_driver *const platform_override_modules[]; +/* +* mpt_early_init(): Detects the SMMPT mode and initializes the +* structures (not MPT tables) requried to prepare MPT tables and +* domain programming. +*/ +int mpt_early_init (bool cold_boot) +{ +int rc; + +if (!cold_boot) +return 0 ; + + rc =sbi_mpt_init (); +if (rc ==SBI_ENODEV ) +return 0 ; + +return rc; +} + +/* +* mpt_final_init(): Performs the final initialzation including +* creation of Root supervisor domain. +*/ +int mpt_final_init (bool cold_boot) +{ +int rc; +u32 sdid; +struct sbi_domain *dom, *root_dom; +struct sbi_mpt_domain_config cfg; + +if (!cold_boot) +return 0 ; + +/* SMMPT may be unavailable */ +if (!sbi_mpt_ctrl_get ()->ready) +return 0 ; + +/* +* Create MPT domain for Root domain. +* +* Root domain maps all physical memory so the +* firmware region must be explicitly denied to S-mode. +* +* regions pointer is NULL and nregions is 0 since there +* are no other regions other than respective SBI domain for mapping. +*/ + root_dom =sbi_domain_thishart_ptr (); + cfg.sbi_dom = root_dom; + cfg.xwr =SBI_MPT_PERM_RWX ; + cfg.fw_protect = true; + cfg.regions =NULL ; + cfg.nregions =0 ; + + rc =sbi_mpt_domain_create (&cfg, &sdid); +if (rc) { +sbi_printf ("mpt: Root domain create failed rc=%d\n" , rc); +return rc; + } + +sbi_memset (&cfg,0 ,sizeof (cfg)); + +/* Create MPT domain for all other registered SBI domains. */ +sbi_domain_for_each (dom) { +if (dom == root_dom) +continue ; + + cfg.sbi_dom = dom; + cfg.xwr =SBI_MPT_PERM_RWX ; + cfg.fw_protect = false; + cfg.regions =NULL ; + cfg.nregions =0 ; + + rc =sbi_mpt_domain_create (&cfg, &sdid); +if (rc) +sbi_printf ("mpt: domain '%s' failed rc=%d\n" , dom->name, rc); + } + +return 0 ; +} +static u32 fw_platform_calculate_heap_size (u32 hart_count) {u32 heap_size;
@@ -42,6 +125,15 @@ static u32 fw_platform_calculate_heap_size(u32 hart_count)/* For TLB fifo */ heap_size +=SBI_TLB_INFO_SIZE * (hart_count) * (hart_count); +/* +* MPT table budget +* 1 MiB memory for MPT allocated currently. +* +* TODO: Need better way to get the memory budget based on active +* SMMPT mode. +*/ + heap_size +=1024 *1024 ; +return BIT_ALIGN (heap_size,HEAP_BASE_ALIGN ); }
@@ -229,6 +321,10 @@ int generic_early_init(bool cold_boot)return rc;fdt_driver_init_all (fdt, fdt_early_drivers); + + rc =mpt_early_init (cold_boot); +if (rc) +return rc; }return fdt_cmo_init (cold_boot);
@@ -236,11 +332,16 @@ int generic_early_init(bool cold_boot)int generic_final_init (bool cold_boot) { +int rc;void *fdt =fdt_get_address_rw ();if (!cold_boot)return 0 ; + rc =mpt_final_init (cold_boot); +if (rc) +return rc; +fdt_cpu_fixup (fdt);fdt_fixups (fdt);fdt_domain_fixup (fdt);
Signature · 7 lines
2.51.0 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Re: [RFC PATCH v3 4/5] platform/generic: Initialise MPT at boot
Quoted 10 lines · Rahul Pathak
Integrates MPT initialisation into the generic platform boot flow.
mpt_early_init()probes for SMMPT during cold-boot early init and initialises the structures required to build MPT tables.
mpt_final_init()creates the root supervisor domain which is mapping all physical memory with the firmware region explcitly denied to S-mode and adds support for an MPT domain for each additional registered SBI domain.
Quoted 5 lines
The heap budget is extended to reserve space for MPT tables.
With this patch MPT tables are built at boot.
Signed-off-by Rahul Pathak <[email protected]>
Initializing MPT from the generic platform is not the right way.
My suggestion is the following:
1) Call sbi_mpt_init() from sbi_hart_init() only when cold_boot == true right after sbi_hart_pmp_init() is called.
2) Instead of mpt_final_init(), the sbi_mpt_init() will register sbi_domain_data with distinct setup() and cleanup() callbacks which are called for each domain.
Regards,
Anup
Quoted 157 lines
--- platform/generic/platform.c | 101 ++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+)platform/generic/platform.c +101
-1@@ -17,6 +17,9 @@#include <sbi/sbi_string.h> #include <sbi/sbi_system.h> #include <sbi/sbi_tlb.h> +#include <sbi/sbi_mpt.h> +#include <sbi/sbi_domain.h> +#include <sbi/sbi_console.h> #include <sbi_utils/cache/fdt_cmo_helper.h> #include <sbi_utils/fdt/fdt_domain.h> #include <sbi_utils/fdt/fdt_driver.h> @@ -33,6 +36,86 @@/* List of platform override modules generated at compile time */ extern const struct fdt_driver *const platform_override_modules[]; +/* +* mpt_early_init(): Detects the SMMPT mode and initializes the +* structures (not MPT tables) requried to prepare MPT tables and +* domain programming. +*/ +int mpt_early_init (bool cold_boot) +{ +int rc; + +if (!cold_boot) +return 0 ; + + rc =sbi_mpt_init (); +if (rc ==SBI_ENODEV ) +return 0 ; + +return rc; +} + +/* +* mpt_final_init(): Performs the final initialzation including +* creation of Root supervisor domain. +*/ +int mpt_final_init (bool cold_boot) +{ +int rc; +u32 sdid; +struct sbi_domain *dom, *root_dom; +struct sbi_mpt_domain_config cfg; + +if (!cold_boot) +return 0 ; + +/* SMMPT may be unavailable */ +if (!sbi_mpt_ctrl_get ()->ready) +return 0 ; + +/* +* Create MPT domain for Root domain. +* +* Root domain maps all physical memory so the +* firmware region must be explicitly denied to S-mode. +* +* regions pointer is NULL and nregions is 0 since there +* are no other regions other than respective SBI domain for mapping. +*/ + root_dom =sbi_domain_thishart_ptr (); + cfg.sbi_dom = root_dom; + cfg.xwr =SBI_MPT_PERM_RWX ; + cfg.fw_protect = true; + cfg.regions =NULL ; + cfg.nregions =0 ; + + rc =sbi_mpt_domain_create (&cfg, &sdid); +if (rc) { +sbi_printf ("mpt: Root domain create failed rc=%d\n" , rc); +return rc; + } + +sbi_memset (&cfg,0 ,sizeof (cfg)); + +/* Create MPT domain for all other registered SBI domains. */ +sbi_domain_for_each (dom) { +if (dom == root_dom) +continue ; + + cfg.sbi_dom = dom; + cfg.xwr =SBI_MPT_PERM_RWX ; + cfg.fw_protect = false; + cfg.regions =NULL ; + cfg.nregions =0 ; + + rc =sbi_mpt_domain_create (&cfg, &sdid); +if (rc) +sbi_printf ("mpt: domain '%s' failed rc=%d\n" , dom->name, rc); + } + +return 0 ; +} +static u32 fw_platform_calculate_heap_size (u32 hart_count) {u32 heap_size;@@ -42,6 +125,15 @@ static u32 fw_platform_calculate_heap_size(u32 hart_count)/* For TLB fifo */ heap_size +=SBI_TLB_INFO_SIZE * (hart_count) * (hart_count); +/* +* MPT table budget +* 1 MiB memory for MPT allocated currently. +* +* TODO: Need better way to get the memory budget based on active +* SMMPT mode. +*/ + heap_size +=1024 *1024 ; +return BIT_ALIGN (heap_size,HEAP_BASE_ALIGN ); }@@ -229,6 +321,10 @@ int generic_early_init(bool cold_boot)return rc;fdt_driver_init_all (fdt, fdt_early_drivers); + + rc =mpt_early_init (cold_boot); +if (rc) +return rc; }return fdt_cmo_init (cold_boot);@@ -236,11 +332,16 @@ int generic_early_init(bool cold_boot)int generic_final_init (bool cold_boot) { +int rc;void *fdt =fdt_get_address_rw ();if (!cold_boot)return 0 ; + rc =mpt_final_init (cold_boot); +if (rc) +return rc; +fdt_cpu_fixup (fdt);fdt_fixups (fdt);fdt_domain_fixup (fdt); --2.51.0
--
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Re: [RFC PATCH v3 4/5] platform/generic: Initialise MPT at boot
Quoted 19 lines · Anup Patel
Quoted 10 lines · Rahul Pathak
Integrates MPT initialisation into the generic platform boot flow.
mpt_early_init()probes for SMMPT during cold-boot early init and initialises the structures required to build MPT tables.
mpt_final_init()creates the root supervisor domain which is mapping all physical memory with the firmware region explcitly denied to S-mode and adds support for an MPT domain for each additional registered SBI domain.Quoted 5 lines
The heap budget is extended to reserve space for MPT tables.
With this patch MPT tables are built at boot.
Signed-off-by Rahul Pathak <[email protected]>
Quoted 9 lines
Initializing MPT from the generic platform is not the right way.
My suggestion is the following:
1) Callsbi_mpt_init()fromsbi_hart_init()only whencold_boot== true right aftersbi_hart_pmp_init()is called.
2) Instead ofmpt_final_init(), thesbi_mpt_init()will registersbi_domain_datawith distinctsetup()andcleanup()callbacks which are called for each domain.
Agree, will update in the next version
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
RFC PATCH v3 5/5 sbi: init: Print supervisor domains at boot
In reply to Rahul PathakPrint the configured supervisor domains alongside the existing domain details during boot.
--- lib/sbi/sbi_init.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/sbi/sbi_init.c +4 -0
@@ -35,6 +35,7 @@#include <sbi/sbi_tlb.h> #include <sbi/sbi_version.h> #include <sbi/sbi_unit_test.h> +#include <sbi/sbi_mpt.h> #define BANNER \ " ____ _____ ____ _____\n" \
@@ -160,6 +161,9 @@ static void sbi_boot_print_domains(struct sbi_scratch *scratch)/* Domain details */ sbi_domain_dump_all (" " ); + +/* Print Supervisor Domains */ +sbi_mpt_dump (); }static void sbi_boot_print_hart (struct sbi_scratch *scratch,u32 hartid)
Signature · 7 lines
2.51.0 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Re: [RFC PATCH v3 5/5] sbi: init: Print supervisor domains at boot
Quoted 22 lines · Rahul Pathak
Print the configured supervisor domains alongside the existing domain details during boot.
Signed-off-by Rahul Pathak <[email protected]>--- lib/sbi/sbi_init.c | 4 ++++ 1 file changed, 4 insertions(+)lib/sbi/sbi_init.c +1
-0@@ -35,6 +35,7 @@#include <sbi/sbi_tlb.h> #include <sbi/sbi_version.h> #include <sbi/sbi_unit_test.h> +#include <sbi/sbi_mpt.h> #define BANNER \ " ____ _____ ____ _____\n" \
lib/sbi/sbi_init.c static void sbi_boot_print_domains(struct sbi_scratch *scratch) · line 166
Quoted 6 lines
lib/sbi/sbi_init.c +3
-0@@ -160,6 +161,9 @@ static void sbi_boot_print_domains(struct sbi_scratch *scratch)/* Domain details */ sbi_domain_dump_all (" " ); + +/* Print Supervisor Domains */ +sbi_mpt_dump ();
The sbi_domain_dump_all() already prints domain regions in a way independent of the underlying hart protection mechanism so drop both sbi_mpt_dump() and this patch.
Regards,
Anup
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Re: [RFC PATCH v3 5/5] sbi: init: Print supervisor domains at boot
Quoted 26 lines · Anup Patel
Quoted 23 lines · Rahul Pathak
Print the configured supervisor domains alongside the existing domain details during boot.
Signed-off-by Rahul Pathak <[email protected]>--- lib/sbi/sbi_init.c | 4 ++++ 1 file changed, 4 insertions(+)lib/sbi/sbi_init.c +1
-0@@ -35,6 +35,7 @@#include <sbi/sbi_tlb.h> #include <sbi/sbi_version.h> #include <sbi/sbi_unit_test.h> +#include <sbi/sbi_mpt.h> #define BANNER \ " ____ _____ ____ _____\n" \@@ -160,6 +161,9 @@ static void sbi_boot_print_domains(struct sbi_scratch *scratch)
Quoted 10 lines
lib/sbi/sbi_init.c static void sbi_boot_print_domains(struct sbi_scratch *scratch) · line 166
Quoted 5 lines
lib/sbi/sbi_init.c +3
-0/* Domain details */ sbi_domain_dump_all (" " ); + +/* Print Supervisor Domains */ +sbi_mpt_dump ();The
sbi_domain_dump_all()already prints domain regions in a way independent of the underlying hart protection mechanism so drop bothsbi_mpt_dump()and this patch.
Will update in the next version, I intend to keep the definition for debugging purposes.
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi