mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-06 14:05:39 +00:00
2717c6b649
When a PTE is updated in the page table, the _PAGE_NEWPAGE bit will always be set. And the corresponding page will always be mapped or unmapped depending on whether the PTE is present or not. The check on the _PAGE_NEWPROT bit is not really reachable. Abandoning it will allow us to simplify the code and remove the unreachable code. Reviewed-by: Benjamin Berg <benjamin.berg@intel.com> Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com> Link: https://patch.msgid.link/20241011102354.1682626-2-tiwei.btw@antgroup.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
60 lines
1.1 KiB
C
60 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (C) 2021 Benjamin Berg <benjamin@sipsolutions.net>
|
|
*/
|
|
|
|
#include <sysdep/stub.h>
|
|
|
|
static __always_inline int syscall_handler(struct stub_data *d)
|
|
{
|
|
int i;
|
|
unsigned long res;
|
|
|
|
for (i = 0; i < d->syscall_data_len; i++) {
|
|
struct stub_syscall *sc = &d->syscall_data[i];
|
|
|
|
switch (sc->syscall) {
|
|
case STUB_SYSCALL_MMAP:
|
|
res = stub_syscall6(STUB_MMAP_NR,
|
|
sc->mem.addr, sc->mem.length,
|
|
sc->mem.prot,
|
|
MAP_SHARED | MAP_FIXED,
|
|
sc->mem.fd, sc->mem.offset);
|
|
if (res != sc->mem.addr) {
|
|
d->err = res;
|
|
d->syscall_data_len = i;
|
|
return -1;
|
|
}
|
|
break;
|
|
case STUB_SYSCALL_MUNMAP:
|
|
res = stub_syscall2(__NR_munmap,
|
|
sc->mem.addr, sc->mem.length);
|
|
if (res) {
|
|
d->err = res;
|
|
d->syscall_data_len = i;
|
|
return -1;
|
|
}
|
|
break;
|
|
default:
|
|
d->err = -95; /* EOPNOTSUPP */
|
|
d->syscall_data_len = i;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
d->err = 0;
|
|
d->syscall_data_len = 0;
|
|
|
|
return 0;
|
|
}
|
|
|
|
void __section(".__syscall_stub")
|
|
stub_syscall_handler(void)
|
|
{
|
|
struct stub_data *d = get_stub_data();
|
|
|
|
syscall_handler(d);
|
|
|
|
trap_myself();
|
|
}
|