From 0bb43cbf5abde3718a424c621ea008169b12ea70 Mon Sep 17 00:00:00 2001 From: X512 Date: Sun, 12 Nov 2023 15:28:35 +0900 Subject: [PATCH] poke: map area into client team in `POKE_MAP_MEMORY` ioctl After this change `POKE_UNMAP_MEMORY` ioctl will became redurant and an alias for `delete_area()`. Areas will be automatically deleted on team exit. Change-Id: I336b49c2281abf064e1bf28d908c7b2c5afd4df0 --- headers/private/drivers/poke.h | 1 + src/add-ons/kernel/drivers/misc/poke.cpp | 21 +++++++++------------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/headers/private/drivers/poke.h b/headers/private/drivers/poke.h index fdbee2e988..b023b52c1a 100644 --- a/headers/private/drivers/poke.h +++ b/headers/private/drivers/poke.h @@ -67,4 +67,5 @@ typedef struct { void* address; } mem_map_args; + #endif // _POKE_DRIVER_H_ diff --git a/src/add-ons/kernel/drivers/misc/poke.cpp b/src/add-ons/kernel/drivers/misc/poke.cpp index 7f683cc0a9..a71e19f35c 100644 --- a/src/add-ons/kernel/drivers/misc/poke.cpp +++ b/src/add-ons/kernel/drivers/misc/poke.cpp @@ -1,25 +1,22 @@ /* * Copyright 2005, Oscar Lesta. All rights reserved. - * Copyright 2018, Haiku, Inc. All rights reserved. + * Copyright 2018-2023, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ - +#include "poke.h" #include #include #include #include +#include +#include + #if defined(__i386__) || defined(__x86_64__) #include #endif -#include "poke.h" - -/* - TODO: maintain a list of mapped areas in the cookie - and only allow unmapping them, and clean them up on free. - */ static status_t poke_open(const char*, uint32, void**); static status_t poke_close(void*); @@ -304,9 +301,9 @@ poke_control(void* cookie, uint32 op, void* arg, size_t length) if (user_strlcpy(name, ioctl.name, B_OS_NAME_LENGTH) < B_OK) return B_BAD_ADDRESS; - ioctl.area = map_physical_memory(name, - (addr_t)ioctl.physical_address, ioctl.size, ioctl.flags, - ioctl.protection, (void**)&ioctl.address); + ioctl.area = vm_map_physical_memory(team_get_current_team_id(), name, + (void**)&ioctl.address, ioctl.flags, ioctl.size, ioctl.protection, + ioctl.physical_address, false); if (user_memcpy(arg, &ioctl, sizeof(mem_map_args)) != B_OK) return B_BAD_ADDRESS; @@ -321,7 +318,7 @@ poke_control(void* cookie, uint32 op, void* arg, size_t length) if (ioctl.signature != POKE_SIGNATURE) return B_BAD_VALUE; - return delete_area(ioctl.area); + return _user_delete_area(ioctl.area); } }