mcctrl: move translate_rva_to_rpa to archdep
Change-Id: I0efa51468a7ff4d776d8340a612e6f44eac2ed53 Fujitsu: POSTK_DEBUG_ARCH_DEP_83
This commit is contained in:
@@ -9,7 +9,6 @@ IHK_BASE=$(src)/../../../../ihk
|
|||||||
|
|
||||||
obj-m += mcctrl.o
|
obj-m += mcctrl.o
|
||||||
|
|
||||||
# POSTK_DEBUG_ARCH_DEP_83, arch depend translate_rva_to_rpa() move
|
|
||||||
ccflags-y := -I$(IHK_BASE)/linux/include \
|
ccflags-y := -I$(IHK_BASE)/linux/include \
|
||||||
-I$(IHK_BASE)/linux/include/ihk/arch/$(ARCH) \
|
-I$(IHK_BASE)/linux/include/ihk/arch/$(ARCH) \
|
||||||
-I$(IHK_BASE)/ikc/include \
|
-I$(IHK_BASE)/ikc/include \
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include "../../../config.h"
|
#include "../../../config.h"
|
||||||
#include "../../mcctrl.h"
|
#include "../../mcctrl.h"
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_83 /* arch depend translate_rva_to_rpa() move */
|
|
||||||
//#define SC_DEBUG
|
//#define SC_DEBUG
|
||||||
|
|
||||||
#ifdef SC_DEBUG
|
#ifdef SC_DEBUG
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
#else
|
#else
|
||||||
#define dprintk(...)
|
#define dprintk(...)
|
||||||
#endif
|
#endif
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_83 */
|
|
||||||
|
|
||||||
#define D(fmt, ...) printk("%s(%d) " fmt, __func__, __LINE__, ##__VA_ARGS__)
|
#define D(fmt, ...) printk("%s(%d) " fmt, __func__, __LINE__, ##__VA_ARGS__)
|
||||||
|
|
||||||
@@ -212,7 +210,6 @@ struct page_table {
|
|||||||
int asid;
|
int asid;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_83 /* arch depend translate_rva_to_rpa() move */
|
|
||||||
int translate_rva_to_rpa(ihk_os_t os, unsigned long rpt, unsigned long rva,
|
int translate_rva_to_rpa(ihk_os_t os, unsigned long rpt, unsigned long rva,
|
||||||
unsigned long *rpap, unsigned long *pgsizep)
|
unsigned long *rpap, unsigned long *pgsizep)
|
||||||
{
|
{
|
||||||
@@ -307,7 +304,6 @@ out:
|
|||||||
error, rva, rpa, pgsize);
|
error, rva, rpa, pgsize);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_83 */
|
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_12
|
#ifdef POSTK_DEBUG_ARCH_DEP_12
|
||||||
#define PFN_WRITE_COMBINED PTE_ATTRINDX(MT_NORMAL_NC)
|
#define PFN_WRITE_COMBINED PTE_ATTRINDX(MT_NORMAL_NC)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/* archdeps.h COPYRIGHT FUJITSU LIMITED 2017 */
|
/* archdeps.h COPYRIGHT FUJITSU LIMITED 2017 */
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_83 /* arch depend translate_rva_to_rpa() move */
|
|
||||||
#ifndef __HEADER_MCCTRL_ARM64_ARCHDEPS_H
|
#ifndef __HEADER_MCCTRL_ARM64_ARCHDEPS_H
|
||||||
#define __HEADER_MCCTRL_ARM64_ARCHDEPS_H
|
#define __HEADER_MCCTRL_ARM64_ARCHDEPS_H
|
||||||
|
|
||||||
@@ -15,4 +14,3 @@ static inline bool pte_is_write_combined(pte_t pte)
|
|||||||
}
|
}
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_12 */
|
#endif /* POSTK_DEBUG_ARCH_DEP_12 */
|
||||||
#endif /* __HEADER_MCCTRL_ARM64_ARCHDEPS_H */
|
#endif /* __HEADER_MCCTRL_ARM64_ARCHDEPS_H */
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_83 */
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "../../../config.h"
|
#include "../../../config.h"
|
||||||
#include "../../mcctrl.h"
|
#include "../../mcctrl.h"
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_83 /* arch depend translate_rva_to_rpa() move */
|
|
||||||
//#define SC_DEBUG
|
//#define SC_DEBUG
|
||||||
|
|
||||||
#ifdef SC_DEBUG
|
#ifdef SC_DEBUG
|
||||||
@@ -13,7 +12,6 @@
|
|||||||
#else
|
#else
|
||||||
#define dprintk(...)
|
#define dprintk(...)
|
||||||
#endif
|
#endif
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_83 */
|
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
|
||||||
static struct vdso_image *_vdso_image_64;
|
static struct vdso_image *_vdso_image_64;
|
||||||
@@ -288,7 +286,6 @@ get_rsp_ctx(void *ctx)
|
|||||||
return tctx->rsp;
|
return tctx->rsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_83 /* arch depend translate_rva_to_rpa() move */
|
|
||||||
int translate_rva_to_rpa(ihk_os_t os, unsigned long rpt, unsigned long rva,
|
int translate_rva_to_rpa(ihk_os_t os, unsigned long rpt, unsigned long rva,
|
||||||
unsigned long *rpap, unsigned long *pgsizep)
|
unsigned long *rpap, unsigned long *pgsizep)
|
||||||
{
|
{
|
||||||
@@ -358,7 +355,6 @@ out:
|
|||||||
error, rva, rpa, pgsize);
|
error, rva, rpa, pgsize);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_83 */
|
|
||||||
|
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_12
|
#ifdef POSTK_DEBUG_ARCH_DEP_12
|
||||||
#define PFN_WRITE_COMBINED _PAGE_PWT
|
#define PFN_WRITE_COMBINED _PAGE_PWT
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/* archdeps.h COPYRIGHT FUJITSU LIMITED 2017 */
|
/* archdeps.h COPYRIGHT FUJITSU LIMITED 2017 */
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_83 /* arch depend translate_rva_to_rpa() move */
|
|
||||||
#ifndef __HEADER_MCCTRL_X86_64_ARCHDEPS_H
|
#ifndef __HEADER_MCCTRL_X86_64_ARCHDEPS_H
|
||||||
#define __HEADER_MCCTRL_X86_64_ARCHDEPS_H
|
#define __HEADER_MCCTRL_X86_64_ARCHDEPS_H
|
||||||
|
|
||||||
@@ -15,4 +14,3 @@ static inline bool pte_is_write_combined(pte_t pte)
|
|||||||
}
|
}
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_12 */
|
#endif /* POSTK_DEBUG_ARCH_DEP_12 */
|
||||||
#endif /* __HEADER_MCCTRL_X86_64_ARCHDEPS_H */
|
#endif /* __HEADER_MCCTRL_X86_64_ARCHDEPS_H */
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_83 */
|
|
||||||
|
|||||||
@@ -49,9 +49,7 @@
|
|||||||
#include "../../../config.h"
|
#include "../../../config.h"
|
||||||
#include "mcctrl.h"
|
#include "mcctrl.h"
|
||||||
#include <linux/version.h>
|
#include <linux/version.h>
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_83 /* arch depend translate_rva_to_rpa() move */
|
|
||||||
#include <archdeps.h>
|
#include <archdeps.h>
|
||||||
#endif /* POSTK_DEBUG_ARCH_DEP_83 */
|
|
||||||
|
|
||||||
#define ALIGN_WAIT_BUF(z) (((z + 63) >> 6) << 6)
|
#define ALIGN_WAIT_BUF(z) (((z + 63) >> 6) << 6)
|
||||||
|
|
||||||
@@ -212,80 +210,6 @@ struct mcctrl_per_thread_data *mcctrl_get_per_thread_data(struct mcctrl_per_proc
|
|||||||
}
|
}
|
||||||
#endif /* !POSTK_DEBUG_ARCH_DEP_56 */
|
#endif /* !POSTK_DEBUG_ARCH_DEP_56 */
|
||||||
|
|
||||||
#ifndef POSTK_DEBUG_ARCH_DEP_83 /* arch depend translate_rva_to_rpa() move */
|
|
||||||
#if 1 /* x86 depend, host OS side */
|
|
||||||
int translate_rva_to_rpa(ihk_os_t os, unsigned long rpt, unsigned long rva,
|
|
||||||
unsigned long *rpap, unsigned long *pgsizep)
|
|
||||||
{
|
|
||||||
unsigned long rpa;
|
|
||||||
int offsh;
|
|
||||||
int i;
|
|
||||||
int ix;
|
|
||||||
unsigned long phys;
|
|
||||||
unsigned long *pt;
|
|
||||||
int error;
|
|
||||||
unsigned long pgsize;
|
|
||||||
|
|
||||||
rpa = rpt;
|
|
||||||
offsh = 39;
|
|
||||||
pgsize = 0;
|
|
||||||
/* i = 0: PML4, 1: PDPT, 2: PDT, 3: PT */
|
|
||||||
for (i = 0; i < 4; ++i) {
|
|
||||||
ix = (rva >> offsh) & 0x1FF;
|
|
||||||
phys = ihk_device_map_memory(ihk_os_to_dev(os), rpa, PAGE_SIZE);
|
|
||||||
pt = ihk_device_map_virtual(ihk_os_to_dev(os), phys, PAGE_SIZE, NULL, 0);
|
|
||||||
dprintk("rpa %#lx offsh %d ix %#x phys %#lx pt %p pt[ix] %#lx\n",
|
|
||||||
rpa, offsh, ix, phys, pt, pt[ix]);
|
|
||||||
|
|
||||||
#define PTE_P 0x001
|
|
||||||
if (!(pt[ix] & PTE_P)) {
|
|
||||||
ihk_device_unmap_virtual(ihk_os_to_dev(os), pt, PAGE_SIZE);
|
|
||||||
ihk_device_unmap_memory(ihk_os_to_dev(os), phys, PAGE_SIZE);
|
|
||||||
error = -EFAULT;
|
|
||||||
dprintk("Remote PTE is not present for 0x%lx (rpt: %lx) ?\n", rva, rpt);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PTE_PS 0x080
|
|
||||||
if (pt[ix] & PTE_PS) {
|
|
||||||
pgsize = 1UL << offsh;
|
|
||||||
rpa = pt[ix] & ((1UL << 52) - 1) & ~(pgsize - 1);
|
|
||||||
rpa |= rva & (pgsize - 1);
|
|
||||||
|
|
||||||
/* For GB pages, just report regular 2MB page */
|
|
||||||
if (offsh == 30) {
|
|
||||||
pgsize = 1UL << 21;
|
|
||||||
dprintk("%s: GB page translated 0x%lx -> 0x%lx, pgsize: %lu\n",
|
|
||||||
__FUNCTION__, rva, rpa, pgsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
ihk_device_unmap_virtual(ihk_os_to_dev(os), pt, PAGE_SIZE);
|
|
||||||
ihk_device_unmap_memory(ihk_os_to_dev(os), phys, PAGE_SIZE);
|
|
||||||
error = 0;
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
|
|
||||||
rpa = pt[ix] & ((1UL << 52) - 1) & ~((1UL << 12) - 1);
|
|
||||||
offsh -= 9;
|
|
||||||
ihk_device_unmap_virtual(ihk_os_to_dev(os), pt, PAGE_SIZE);
|
|
||||||
ihk_device_unmap_memory(ihk_os_to_dev(os), phys, PAGE_SIZE);
|
|
||||||
}
|
|
||||||
pgsize = 1UL << 12;
|
|
||||||
rpa |= rva & (pgsize - 1);
|
|
||||||
|
|
||||||
found:
|
|
||||||
error = 0;
|
|
||||||
*rpap = rpa;
|
|
||||||
*pgsizep = pgsize;
|
|
||||||
|
|
||||||
out:
|
|
||||||
dprintk("translate_rva_to_rpa: %d rva %#lx --> rpa %#lx (%lx)\n",
|
|
||||||
error, rva, rpa, pgsize);
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif /* !POSTK_DEBUG_ARCH_DEP_83 */
|
|
||||||
|
|
||||||
static int __notify_syscall_requester(ihk_os_t os, struct ikc_scd_packet *packet,
|
static int __notify_syscall_requester(ihk_os_t os, struct ikc_scd_packet *packet,
|
||||||
struct syscall_response *res)
|
struct syscall_response *res)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user