Commit 573a446f authored by Benjamin Berg's avatar Benjamin Berg Committed by Johannes Berg

um: simplify and consolidate TLB updates

The HVC update was mostly used to compress consecutive calls into one.
This is mostly relevant for userspace where it is already handled by the
syscall stub code.

Simplify the whole logic and consolidate it for both kernel and
userspace. This does remove the sequential syscall compression for the
kernel, however that shouldn't be the main factor in most runs.
Signed-off-by: default avatarBenjamin Berg <benjamin.berg@intel.com>
Link: https://patch.msgid.link/20240703134536.1161108-12-benjamin@sipsolutions.netSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent ef714f15
...@@ -279,12 +279,12 @@ int syscall_stub_flush(struct mm_id *mm_idp); ...@@ -279,12 +279,12 @@ int syscall_stub_flush(struct mm_id *mm_idp);
struct stub_syscall *syscall_stub_alloc(struct mm_id *mm_idp); struct stub_syscall *syscall_stub_alloc(struct mm_id *mm_idp);
void syscall_stub_dump_error(struct mm_id *mm_idp); void syscall_stub_dump_error(struct mm_id *mm_idp);
void map(struct mm_id *mm_idp, unsigned long virt, int map(struct mm_id *mm_idp, unsigned long virt,
unsigned long len, int prot, int phys_fd, unsigned long len, int prot, int phys_fd,
unsigned long long offset); unsigned long long offset);
void unmap(struct mm_id *mm_idp, unsigned long addr, unsigned long len); int unmap(struct mm_id *mm_idp, unsigned long addr, unsigned long len);
void protect(struct mm_id *mm_idp, unsigned long addr, int protect(struct mm_id *mm_idp, unsigned long addr,
unsigned long len, unsigned int prot); unsigned long len, unsigned int prot);
/* skas/process.c */ /* skas/process.c */
extern int is_skas_winch(int pid, int fd, void *data); extern int is_skas_winch(int pid, int fd, void *data);
......
This diff is collapsed.
...@@ -175,7 +175,7 @@ static struct stub_syscall *syscall_stub_get_previous(struct mm_id *mm_idp, ...@@ -175,7 +175,7 @@ static struct stub_syscall *syscall_stub_get_previous(struct mm_id *mm_idp,
return NULL; return NULL;
} }
void map(struct mm_id *mm_idp, unsigned long virt, unsigned long len, int prot, int map(struct mm_id *mm_idp, unsigned long virt, unsigned long len, int prot,
int phys_fd, unsigned long long offset) int phys_fd, unsigned long long offset)
{ {
struct stub_syscall *sc; struct stub_syscall *sc;
...@@ -185,7 +185,7 @@ void map(struct mm_id *mm_idp, unsigned long virt, unsigned long len, int prot, ...@@ -185,7 +185,7 @@ void map(struct mm_id *mm_idp, unsigned long virt, unsigned long len, int prot,
if (sc && sc->mem.prot == prot && sc->mem.fd == phys_fd && if (sc && sc->mem.prot == prot && sc->mem.fd == phys_fd &&
sc->mem.offset == MMAP_OFFSET(offset - sc->mem.length)) { sc->mem.offset == MMAP_OFFSET(offset - sc->mem.length)) {
sc->mem.length += len; sc->mem.length += len;
return; return 0;
} }
sc = syscall_stub_alloc(mm_idp); sc = syscall_stub_alloc(mm_idp);
...@@ -195,9 +195,11 @@ void map(struct mm_id *mm_idp, unsigned long virt, unsigned long len, int prot, ...@@ -195,9 +195,11 @@ void map(struct mm_id *mm_idp, unsigned long virt, unsigned long len, int prot,
sc->mem.prot = prot; sc->mem.prot = prot;
sc->mem.fd = phys_fd; sc->mem.fd = phys_fd;
sc->mem.offset = MMAP_OFFSET(offset); sc->mem.offset = MMAP_OFFSET(offset);
return 0;
} }
void unmap(struct mm_id *mm_idp, unsigned long addr, unsigned long len) int unmap(struct mm_id *mm_idp, unsigned long addr, unsigned long len)
{ {
struct stub_syscall *sc; struct stub_syscall *sc;
...@@ -205,16 +207,18 @@ void unmap(struct mm_id *mm_idp, unsigned long addr, unsigned long len) ...@@ -205,16 +207,18 @@ void unmap(struct mm_id *mm_idp, unsigned long addr, unsigned long len)
sc = syscall_stub_get_previous(mm_idp, STUB_SYSCALL_MUNMAP, addr); sc = syscall_stub_get_previous(mm_idp, STUB_SYSCALL_MUNMAP, addr);
if (sc) { if (sc) {
sc->mem.length += len; sc->mem.length += len;
return; return 0;
} }
sc = syscall_stub_alloc(mm_idp); sc = syscall_stub_alloc(mm_idp);
sc->syscall = STUB_SYSCALL_MUNMAP; sc->syscall = STUB_SYSCALL_MUNMAP;
sc->mem.addr = addr; sc->mem.addr = addr;
sc->mem.length = len; sc->mem.length = len;
return 0;
} }
void protect(struct mm_id *mm_idp, unsigned long addr, unsigned long len, int protect(struct mm_id *mm_idp, unsigned long addr, unsigned long len,
unsigned int prot) unsigned int prot)
{ {
struct stub_syscall *sc; struct stub_syscall *sc;
...@@ -223,7 +227,7 @@ void protect(struct mm_id *mm_idp, unsigned long addr, unsigned long len, ...@@ -223,7 +227,7 @@ void protect(struct mm_id *mm_idp, unsigned long addr, unsigned long len,
sc = syscall_stub_get_previous(mm_idp, STUB_SYSCALL_MPROTECT, addr); sc = syscall_stub_get_previous(mm_idp, STUB_SYSCALL_MPROTECT, addr);
if (sc && sc->mem.prot == prot) { if (sc && sc->mem.prot == prot) {
sc->mem.length += len; sc->mem.length += len;
return; return 0;
} }
sc = syscall_stub_alloc(mm_idp); sc = syscall_stub_alloc(mm_idp);
...@@ -231,4 +235,6 @@ void protect(struct mm_id *mm_idp, unsigned long addr, unsigned long len, ...@@ -231,4 +235,6 @@ void protect(struct mm_id *mm_idp, unsigned long addr, unsigned long len,
sc->mem.addr = addr; sc->mem.addr = addr;
sc->mem.length = len; sc->mem.length = len;
sc->mem.prot = prot; sc->mem.prot = prot;
return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment