mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-09-08 18:21:29 +01:00
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 Signed-off-by: Rahul Pathak <rahul.pathak@oss.qualcomm.com> Reviewed-by: Anup Patel <anup@brainfault.org> Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260820121309.2551296-2-rahul.pathak@oss.qualcomm.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -40,13 +40,17 @@ struct sbi_hart_protection {
|
|||||||
/** Unconfigure protection for current HART (Optional) */
|
/** Unconfigure protection for current HART (Optional) */
|
||||||
void (*unconfigure)(struct sbi_scratch *scratch, struct sbi_domain *dom);
|
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,
|
* Give temporary M-mode access to an S/U-mode address range on current
|
||||||
unsigned long base, unsigned long size);
|
* 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);
|
||||||
|
|
||||||
/** Destroy temporary mapping on current HART (Optional) */
|
/** Remove the temporary M-mode access on the current HART (Optional) */
|
||||||
int (*unmap_range)(struct sbi_scratch *scratch,
|
int (*temp_unmap_range)(struct sbi_scratch *scratch,
|
||||||
unsigned long base, unsigned long size);
|
unsigned long base, unsigned long size);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,23 +115,24 @@ int sbi_hart_protection_reconfigure(struct sbi_scratch *scratch,
|
|||||||
struct sbi_domain *next_dom);
|
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 base base address of the temporary mapping
|
||||||
* @param size size of the temporary mapping
|
* @param size size of the temporary mapping
|
||||||
*
|
*
|
||||||
* @return 0 on success and negative error code on failure
|
* @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 base base address of the temporary mapping
|
||||||
* @param size size of the temporary mapping
|
* @param size size of the temporary mapping
|
||||||
*
|
*
|
||||||
* @return 0 on success and negative error code on failure
|
* @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__ */
|
#endif /* __SBI_HART_PROTECTION_H__ */
|
||||||
|
|||||||
+26
-26
@@ -657,8 +657,8 @@ int sbi_dbtr_read_trig(unsigned long smode,
|
|||||||
|
|
||||||
shmem_base = hart_shmem_base(hs);
|
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));
|
trig_count * sizeof(*entry));
|
||||||
for_each_trig_entry(shmem_base, trig_count, typeof(*entry), entry) {
|
for_each_trig_entry(shmem_base, trig_count, typeof(*entry), entry) {
|
||||||
xmit = &entry->data;
|
xmit = &entry->data;
|
||||||
trig = INDEX_TO_TRIGGER((_idx + trig_idx_base));
|
trig = INDEX_TO_TRIGGER((_idx + trig_idx_base));
|
||||||
@@ -671,8 +671,8 @@ int sbi_dbtr_read_trig(unsigned long smode,
|
|||||||
xmit->tdata2 = cpu_to_lle(trig->tdata2);
|
xmit->tdata2 = cpu_to_lle(trig->tdata2);
|
||||||
xmit->tdata3 = cpu_to_lle(trig->tdata3);
|
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));
|
trig_count * sizeof(*entry));
|
||||||
|
|
||||||
return SBI_SUCCESS;
|
return SBI_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -699,8 +699,8 @@ int sbi_dbtr_install_trig(unsigned long smode,
|
|||||||
return SBI_ERR_NO_SHMEM;
|
return SBI_ERR_NO_SHMEM;
|
||||||
|
|
||||||
shmem_base = hart_shmem_base(hs);
|
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));
|
trig_count * sizeof(*entry));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SBI v3.0 sec 19.4 requires SBI_ERR_NOT_SUPPORTED when a trigger
|
* SBI v3.0 sec 19.4 requires SBI_ERR_NOT_SUPPORTED when a trigger
|
||||||
@@ -720,23 +720,23 @@ int sbi_dbtr_install_trig(unsigned long smode,
|
|||||||
|
|
||||||
if (!dbtr_trigger_supported(TDATA1_GET_TYPE(ctrl))) {
|
if (!dbtr_trigger_supported(TDATA1_GET_TYPE(ctrl))) {
|
||||||
*out = _idx;
|
*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));
|
trig_count * sizeof(*entry));
|
||||||
return SBI_ERR_FAILED;
|
return SBI_ERR_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dbtr_trigger_valid(TDATA1_GET_TYPE(ctrl), ctrl)) {
|
if (!dbtr_trigger_valid(TDATA1_GET_TYPE(ctrl), ctrl)) {
|
||||||
*out = _idx;
|
*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));
|
trig_count * sizeof(*entry));
|
||||||
return SBI_ERR_INVALID_PARAM;
|
return SBI_ERR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((recv->tdata2 && !tdata2_impl) ||
|
if ((recv->tdata2 && !tdata2_impl) ||
|
||||||
(recv->tdata3 && !tdata3_impl)) {
|
(recv->tdata3 && !tdata3_impl)) {
|
||||||
*out = _idx;
|
*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));
|
trig_count * sizeof(*entry));
|
||||||
return SBI_ERR_NOT_SUPPORTED;
|
return SBI_ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,16 +745,16 @@ int sbi_dbtr_install_trig(unsigned long smode,
|
|||||||
lle_to_cpu(recv->tdata2),
|
lle_to_cpu(recv->tdata2),
|
||||||
lle_to_cpu(recv->tdata3))) {
|
lle_to_cpu(recv->tdata3))) {
|
||||||
*out = _idx;
|
*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));
|
trig_count * sizeof(*entry));
|
||||||
return SBI_ERR_NOT_SUPPORTED;
|
return SBI_ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hs->available_trigs < trig_count) {
|
if (hs->available_trigs < trig_count) {
|
||||||
*out = hs->available_trigs;
|
*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));
|
trig_count * sizeof(*entry));
|
||||||
return SBI_ERR_FAILED;
|
return SBI_ERR_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -771,8 +771,8 @@ int sbi_dbtr_install_trig(unsigned long smode,
|
|||||||
lle_to_cpu(recv->tdata3));
|
lle_to_cpu(recv->tdata3));
|
||||||
if (slot < 0) {
|
if (slot < 0) {
|
||||||
*out = _idx;
|
*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));
|
trig_count * sizeof(*entry));
|
||||||
return SBI_ERR_FAILED;
|
return SBI_ERR_FAILED;
|
||||||
}
|
}
|
||||||
claimed |= BIT(slot);
|
claimed |= BIT(slot);
|
||||||
@@ -798,8 +798,8 @@ 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));
|
trig_count * sizeof(*entry));
|
||||||
|
|
||||||
return SBI_SUCCESS;
|
return SBI_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -882,24 +882,24 @@ int sbi_dbtr_update_trig(unsigned long smode,
|
|||||||
tdata3_impl = tdata_implemented(CSR_TDATA3);
|
tdata3_impl = tdata_implemented(CSR_TDATA3);
|
||||||
|
|
||||||
for_each_trig_entry(shmem_base, trig_count, typeof(*entry), entry) {
|
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;
|
trig_idx = entry->id.idx;
|
||||||
|
|
||||||
if (trig_idx >= hs->total_trigs) {
|
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;
|
return SBI_ERR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
trig = INDEX_TO_TRIGGER(trig_idx);
|
trig = INDEX_TO_TRIGGER(trig_idx);
|
||||||
|
|
||||||
if (!(trig->state & RV_DBTR_BIT_MASK(TS, MAPPED))) {
|
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;
|
return SBI_ERR_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((entry->data.tdata2 && !tdata2_impl) ||
|
if ((entry->data.tdata2 && !tdata2_impl) ||
|
||||||
(entry->data.tdata3 && !tdata3_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;
|
return SBI_ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -907,12 +907,12 @@ int sbi_dbtr_update_trig(unsigned long smode,
|
|||||||
lle_to_cpu(entry->data.tdata1),
|
lle_to_cpu(entry->data.tdata1),
|
||||||
lle_to_cpu(entry->data.tdata2),
|
lle_to_cpu(entry->data.tdata2),
|
||||||
lle_to_cpu(entry->data.tdata3))) {
|
lle_to_cpu(entry->data.tdata3))) {
|
||||||
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;
|
return SBI_ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbtr_trigger_setup(trig, &entry->data);
|
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);
|
dbtr_trigger_enable(trig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,12 +46,12 @@ static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid,
|
|||||||
regs->a1, regs->a0, smode,
|
regs->a1, regs->a0, smode,
|
||||||
SBI_DOMAIN_READ|SBI_DOMAIN_WRITE))
|
SBI_DOMAIN_READ|SBI_DOMAIN_WRITE))
|
||||||
return SBI_ERR_INVALID_PARAM;
|
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)
|
if (funcid == SBI_EXT_DBCN_CONSOLE_WRITE)
|
||||||
out->value = sbi_nputs((const char *)regs->a1, regs->a0);
|
out->value = sbi_nputs((const char *)regs->a1, regs->a0);
|
||||||
else
|
else
|
||||||
out->value = sbi_ngets((char *)regs->a1, regs->a0);
|
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;
|
return 0;
|
||||||
case SBI_EXT_DBCN_CONSOLE_WRITE_BYTE:
|
case SBI_EXT_DBCN_CONSOLE_WRITE_BYTE:
|
||||||
sbi_putc(regs->a0);
|
sbi_putc(regs->a0);
|
||||||
|
|||||||
@@ -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
|
* When shared memory access is required, the physical address
|
||||||
* should be programmed into the first PMP entry with R/W
|
* should be programmed into the first PMP entry with R/W
|
||||||
* permissions to the M-mode. Once the work is done, it should be
|
* 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.
|
* function pair should be used to map/unmap the shared memory.
|
||||||
*/
|
*/
|
||||||
#define SBI_SMEPMP_RESV_ENTRY 0
|
#define SBI_SMEPMP_RESV_ENTRY 0
|
||||||
@@ -327,7 +327,7 @@ static int sbi_hart_smepmp_configure(struct sbi_scratch *scratch,
|
|||||||
return 0;
|
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)
|
unsigned long addr, unsigned long size)
|
||||||
{
|
{
|
||||||
/* shared R/W access for M and S/U mode */
|
/* 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;
|
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)
|
unsigned long addr, unsigned long size)
|
||||||
{
|
{
|
||||||
sbi_platform_pmp_disable(sbi_platform_ptr(scratch), SBI_SMEPMP_RESV_ENTRY);
|
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,
|
.type = SBI_HART_PROTECTION_TYPE_MEMORY,
|
||||||
.configure = sbi_hart_smepmp_configure,
|
.configure = sbi_hart_smepmp_configure,
|
||||||
.unconfigure = sbi_hart_pmp_unconfigure,
|
.unconfigure = sbi_hart_pmp_unconfigure,
|
||||||
.map_range = sbi_hart_smepmp_map_range,
|
.temp_map_range = sbi_hart_smepmp_temp_map_range,
|
||||||
.unmap_range = sbi_hart_smepmp_unmap_range,
|
.temp_unmap_range = sbi_hart_smepmp_temp_unmap_range,
|
||||||
};
|
};
|
||||||
|
|
||||||
int sbi_hart_pmp_init(struct sbi_scratch *scratch)
|
int sbi_hart_pmp_init(struct sbi_scratch *scratch)
|
||||||
|
|||||||
@@ -196,22 +196,22 @@ int sbi_hart_protection_reconfigure(struct sbi_scratch *scratch,
|
|||||||
return 0;
|
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();
|
struct sbi_hart_protection *hprot = __hart_memory_protection_best();
|
||||||
|
|
||||||
if (!hprot || !hprot->map_range)
|
if (!hprot || !hprot->temp_map_range)
|
||||||
return 0;
|
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();
|
struct sbi_hart_protection *hprot = __hart_memory_protection_best();
|
||||||
|
|
||||||
if (!hprot || !hprot->unmap_range)
|
if (!hprot || !hprot->temp_unmap_range)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return hprot->unmap_range(sbi_scratch_thishart_ptr(), base, size);
|
return hprot->temp_unmap_range(sbi_scratch_thishart_ptr(), base, size);
|
||||||
}
|
}
|
||||||
|
|||||||
+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) {
|
if (flags == SBI_EXT_MPXY_SHMEM_FLAG_OVERWRITE_RETURN) {
|
||||||
ret_buf = (unsigned long *)(ulong)SHMEM_PHYS_ADDR(shmem_phys_hi,
|
ret_buf = (unsigned long *)(ulong)SHMEM_PHYS_ADDR(shmem_phys_hi,
|
||||||
shmem_phys_lo);
|
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[0] = cpu_to_lle(ms->shmem.shmem_addr_lo);
|
||||||
ret_buf[1] = cpu_to_lle(ms->shmem.shmem_addr_hi);
|
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 */
|
/** Setup the new shared memory */
|
||||||
@@ -436,7 +436,7 @@ int sbi_mpxy_get_channel_ids(u32 start_index)
|
|||||||
return SBI_ERR_INVALID_PARAM;
|
return SBI_ERR_INVALID_PARAM;
|
||||||
|
|
||||||
shmem_base = hart_shmem_base(ms);
|
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
|
/** number of channel ids which can be stored in shmem adjusting
|
||||||
* for remaining and returned fields */
|
* 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[0] = cpu_to_le32(remaining);
|
||||||
shmem_base[1] = cpu_to_le32(returned);
|
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;
|
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);
|
shmem_base = hart_shmem_base(ms);
|
||||||
end_id = base_attr_id + attr_count - 1;
|
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 */
|
/* Standard attributes range check */
|
||||||
if (mpxy_is_std_attr(base_attr_id)) {
|
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);
|
base_attr_id, attr_count);
|
||||||
}
|
}
|
||||||
out:
|
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;
|
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);
|
shmem_base = hart_shmem_base(ms);
|
||||||
end_id = base_attr_id + attr_count - 1;
|
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;
|
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);
|
base_attr_id, attr_count);
|
||||||
}
|
}
|
||||||
out:
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -740,7 +740,7 @@ int sbi_mpxy_send_message(u32 channel_id, u8 msg_id,
|
|||||||
return SBI_ERR_INVALID_PARAM;
|
return SBI_ERR_INVALID_PARAM;
|
||||||
|
|
||||||
shmem_base = hart_shmem_base(ms);
|
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) {
|
if (resp_data_len) {
|
||||||
resp_buf = shmem_base;
|
resp_buf = shmem_base;
|
||||||
@@ -757,7 +757,7 @@ int sbi_mpxy_send_message(u32 channel_id, u8 msg_id,
|
|||||||
msg_data_len);
|
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)
|
if (ret == SBI_ERR_TIMEOUT || ret == SBI_ERR_IO)
|
||||||
return ret;
|
return ret;
|
||||||
@@ -788,12 +788,12 @@ int sbi_mpxy_get_notification_events(u32 channel_id, unsigned long *events_len)
|
|||||||
return SBI_ERR_NOT_SUPPORTED;
|
return SBI_ERR_NOT_SUPPORTED;
|
||||||
|
|
||||||
shmem_base = hart_shmem_base(ms);
|
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;
|
eventsbuf = shmem_base;
|
||||||
ret = channel->get_notification_events(channel, eventsbuf,
|
ret = channel->get_notification_events(channel, eventsbuf,
|
||||||
mpxy_shmem_size,
|
mpxy_shmem_size,
|
||||||
events_len);
|
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)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
+2
-2
@@ -1106,7 +1106,7 @@ int sbi_pmu_event_get_info(unsigned long shmem_phys_lo, unsigned long shmem_phys
|
|||||||
SBI_DOMAIN_READ | SBI_DOMAIN_WRITE))
|
SBI_DOMAIN_READ | SBI_DOMAIN_WRITE))
|
||||||
return SBI_ERR_INVALID_ADDRESS;
|
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);
|
einfo = (struct sbi_pmu_event_info *)(shmem_phys_lo);
|
||||||
for (i = 0; i < num_events; i++) {
|
for (i = 0; i < num_events; i++) {
|
||||||
@@ -1154,7 +1154,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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -1032,7 +1032,7 @@ int sbi_sse_read_attrs(uint32_t event_id, uint32_t base_attr_id,
|
|||||||
if (ret)
|
if (ret)
|
||||||
return 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
|
* Copy all attributes at once since struct sse_event_attrs is matching
|
||||||
@@ -1045,7 +1045,7 @@ int sbi_sse_read_attrs(uint32_t event_id, uint32_t base_attr_id,
|
|||||||
attrs = (unsigned long *)output_phys_lo;
|
attrs = (unsigned long *)output_phys_lo;
|
||||||
copy_attrs(attrs, &e_attrs[base_attr_id], attr_count);
|
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);
|
sse_event_put(e);
|
||||||
|
|
||||||
@@ -1060,7 +1060,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;
|
uint32_t id, end_id = base_attr_id + attr_count;
|
||||||
unsigned long *attrs = (unsigned long *)input_phys;
|
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++) {
|
for (id = base_attr_id; id < end_id; id++) {
|
||||||
val = attrs[attr++];
|
val = attrs[attr++];
|
||||||
@@ -1076,7 +1076,7 @@ static int sse_write_attrs(struct sbi_sse_event *e, uint32_t base_attr_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user