Changeset View
Changeset View
Standalone View
Standalone View
sys/arm64/arm64/sys_machdep.c
Show All 23 Lines | ||||||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |||||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||||||
* SUCH DAMAGE. | * SUCH DAMAGE. | |||||||||
* | * | |||||||||
*/ | */ | |||||||||
#include <sys/param.h> | #include <sys/param.h> | |||||||||
#include <sys/systm.h> | #include <sys/systm.h> | |||||||||
#include <sys/proc.h> | ||||||||||
#include <sys/sysproto.h> | #include <sys/sysproto.h> | |||||||||
#include <vm/vm.h> | ||||||||||
#include <vm/pmap.h> | ||||||||||
#include <vm/vm_map.h> | ||||||||||
#include <machine/sysarch.h> | #include <machine/sysarch.h> | |||||||||
#include <machine/vmparam.h> | ||||||||||
int | int | |||||||||
sysarch(struct thread *td, struct sysarch_args *uap) | sysarch(struct thread *td, struct sysarch_args *uap) | |||||||||
{ | { | |||||||||
struct arm64_guard_page_args gp_args; | ||||||||||
vm_offset_t eva; | ||||||||||
int error; | ||||||||||
markjUnsubmitted Not Done Inline Actions
markj: | ||||||||||
return (ENOTSUP); | switch (uap->op) { | |||||||||
case ARM64_GUARD_PAGE: | ||||||||||
error = copyin(uap->parms, &gp_args, sizeof(gp_args)); | ||||||||||
if (error != 0) | ||||||||||
return (error); | ||||||||||
Not Done Inline ActionsAll of the other error cases below are handled by returning directly. markj: All of the other error cases below are handled by returning directly. | ||||||||||
/* Only accept canonical addresses, no PAC or TBI */ | ||||||||||
if (!ADDR_IS_CANONICAL(gp_args.addr)) | ||||||||||
return (EINVAL); | ||||||||||
eva = gp_args.addr + gp_args.len; | ||||||||||
/* Check for a length overflow */ | ||||||||||
if (gp_args.addr > eva) | ||||||||||
return (EINVAL); | ||||||||||
/* Check in the correct address space */ | ||||||||||
if (eva >= VM_MAX_USER_ADDRESS) | ||||||||||
return (EINVAL); | ||||||||||
/* Nothing to do */ | ||||||||||
if (gp_args.len == 0) | ||||||||||
return (0); | ||||||||||
error = pmap_bti_set(vmspace_pmap(td->td_proc->p_vmspace), | ||||||||||
trunc_page(gp_args.addr), round_page(eva)); | ||||||||||
Not Done Inline ActionsIMO it is clearer to write this in terms of a range: sva = trunc_page(gp_args.addr); eva = round_page(gp_args.addr + gp_args.len); if (sva > eva || eva > VM_MAX_USER_ADDRESS) return (EINVAL); error = pmap_pti_set(pmap, sva, eva); markj: IMO it is clearer to write this in terms of a range:
```
sva = trunc_page(gp_args.addr);
eva =… | ||||||||||
break; | ||||||||||
default: | ||||||||||
Not Done Inline ActionsShouldn't the pmap should be derived from td, not using pcpu? This looks strange, I don't know why PKRU does it this way. markj: Shouldn't the pmap should be derived from `td`, not using pcpu? This looks strange, I don't… | ||||||||||
error = EINVAL; | ||||||||||
Not Done Inline Actionspmap_bti_set() returns 0 if the executable didn't have BTI configured. Don't we want to return an error here in that case? markj: pmap_bti_set() returns 0 if the executable didn't have BTI configured. Don't we want to return… | ||||||||||
break; | ||||||||||
} | ||||||||||
return (error); | ||||||||||
} | } |