From fce46fd0a2f8995d7b49b4ce23d03e679afee1de Mon Sep 17 00:00:00 2001 From: hanzongcheng Date: Fri, 30 Jun 2023 19:13:39 +0800 Subject: [PATCH 1/4] mcs_km: add print message for the mmu map * we need to know the dma and sharemem information, so add print message for the mmu map. Signed-off-by: hanzongcheng --- mcs_km/mmu_map.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mcs_km/mmu_map.c b/mcs_km/mmu_map.c index 2cdcefc..ced5add 100644 --- a/mcs_km/mmu_map.c +++ b/mcs_km/mmu_map.c @@ -46,6 +46,16 @@ enum { TABLE_MAX }; +const char* mem_name[] = { + "PAGE_TABLE", + "BAR_TABLE", + "DMA_TABLE", + "SHAREMEM_TABLE", + "LOG_TABLE", + "TEXT_TABLE", + "DATA_TABLE", +}; + static mmu_map_info clientos_map_info[TABLE_MAX] = { { // pagetable @@ -113,8 +123,6 @@ static void mem_mmu_page_table(mmu_map_info *map_info) return; } - pr_info("map pa 0x%lx va 0x%lx pagesize 0x%lx\n", map_info->pa, map_info->va, map_info->page_size); - ppe = pml + PAGE_TABLE_OFFSET; pde = ppe + PAGE_TABLE_OFFSET; pte = pde + PAGE_TABLE_OFFSET; @@ -172,6 +180,9 @@ void mem_map_info_set(unsigned long loadaddr) for (i = 0; i < TABLE_MAX; i++) { if (i != BAR_TABLE) { + pr_info("map %s: pa 0x%lx, va 0x%lx, size 0x%lx, pagesize 0x%lx\n", + mem_name[i], clientos_map_info[i].pa, clientos_map_info[i].va, + clientos_map_info[i].size, clientos_map_info[i].page_size); mem_mmu_page_table(&clientos_map_info[i]); } } -- Gitee From d9e359d4f18622db1dfed0556ad8d569f21ba82d Mon Sep 17 00:00:00 2001 From: hanzongcheng Date: Wed, 5 Jul 2023 16:43:11 +0800 Subject: [PATCH 2/4] mcs_km: reimplement send_clientos_ipi * We are currently using maxcpus to prevent linux from booting the cores needed for rtos. As a result, linux will not record the logical_apicid of these cores, which means that the corresponding dest cpu cannot be found under x2apic_cluster and the IPI cannot be successfully sent. So We reimplement send_clientos_ipi() to send X86_MCS_IPI by writing to the icr. Signed-off-by: hanzongcheng --- mcs_km/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mcs_km/main.c b/mcs_km/main.c index 09f6f25..8375017 100644 --- a/mcs_km/main.c +++ b/mcs_km/main.c @@ -129,9 +129,16 @@ static int init_mcs_ipi(void) return err; } +/* + * send X86_MCS_IPI + * Destination Mode: Physical + */ static void send_clientos_ipi(const unsigned int cpu) { - apic->send_IPI(cpu, X86_MCS_IPI_VECTOR); + int apicid = apic->cpu_present_to_apicid(cpu); + + weak_wrmsr_fence(); + wrmsrl(APIC_BASE_MSR + (APIC_ICR >> 4), ((__u64) apicid) << 32 | X86_MCS_IPI_VECTOR); } static unsigned int mcs_poll(struct file *file, poll_table *wait) -- Gitee From 75f102582c0241c0c63a79e1bb5e87d6a8737c72 Mon Sep 17 00:00:00 2001 From: hanzongcheng Date: Wed, 12 Jul 2023 11:56:01 +0800 Subject: [PATCH 3/4] mcs: change phy_shared_mem to 0x3fde00000 * Since the page table is currently built in advance for Uniproton, Uniproton can only access the sharedmem region. When Uniproton's load address is 0x400000000, the corresponding sharedmem address is 0x3fde00000. Signed-off-by: hanzongcheng --- rpmsg_pty_demo/rpmsg_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpmsg_pty_demo/rpmsg_main.c b/rpmsg_pty_demo/rpmsg_main.c index 428609f..14e1dba 100644 --- a/rpmsg_pty_demo/rpmsg_main.c +++ b/rpmsg_pty_demo/rpmsg_main.c @@ -13,7 +13,7 @@ static struct client_os_inst client_os = { /* physical address start of shared device mem */ - .phy_shared_mem = 0x390000000, + .phy_shared_mem = 0x3fde00000, /* size of shared device mem */ .shared_mem_size = 0x30000, .vring_size = VRING_SIZE, -- Gitee From add6d28d6b4bd0f965b1300dc03ab1f7e1197b76 Mon Sep 17 00:00:00 2001 From: hanzongcheng Date: Wed, 12 Jul 2023 21:00:36 +0800 Subject: [PATCH 4/4] msc_km: add set_bar_addr() * Add an exported function set_bar_addr() to allow other drivers to pass the address space of the bar. Signed-off-by: hanzongcheng --- mcs_km/include/mmu_map.h | 2 ++ mcs_km/mmu_map.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mcs_km/include/mmu_map.h b/mcs_km/include/mmu_map.h index f1abdd0..2d6dc79 100644 --- a/mcs_km/include/mmu_map.h +++ b/mcs_km/include/mmu_map.h @@ -1 +1,3 @@ extern void mem_map_info_set(unsigned long loadaddr); + +extern void set_bar_addr(unsigned long phy_addr); diff --git a/mcs_km/mmu_map.c b/mcs_km/mmu_map.c index ced5add..1d4e17f 100644 --- a/mcs_km/mmu_map.c +++ b/mcs_km/mmu_map.c @@ -65,7 +65,7 @@ static mmu_map_info clientos_map_info[TABLE_MAX] = { .attr = MEM_ATTR_CACHE_RWX, .page_size = PAGE_SIZE_4K, }, { - // bar, unused + // bar .va = 0xf00008000, .pa = 0x0, .size = 0x100000, @@ -109,6 +109,12 @@ static mmu_map_info clientos_map_info[TABLE_MAX] = { } }; +void set_bar_addr(unsigned long phy_addr) +{ + clientos_map_info[BAR_TABLE].pa = phy_addr; +} +EXPORT_SYMBOL_GPL(set_bar_addr); + static void mem_mmu_page_table(mmu_map_info *map_info) { unsigned long mapped, val; @@ -179,7 +185,7 @@ void mem_map_info_set(unsigned long loadaddr) memunmap(table_base); for (i = 0; i < TABLE_MAX; i++) { - if (i != BAR_TABLE) { + if (clientos_map_info[i].pa != 0) { pr_info("map %s: pa 0x%lx, va 0x%lx, size 0x%lx, pagesize 0x%lx\n", mem_name[i], clientos_map_info[i].pa, clientos_map_info[i].va, clientos_map_info[i].size, clientos_map_info[i].page_size); -- Gitee