Project

General

Profile

Actions

Feature #12691

closed

Want means of getting the maximum user address in a process

Added by Robert Mustacchi about 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Category:
lib - userland libraries
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

The CoreCLR part of .net, and presumably other software, wants to know what the maximum mapable user address is. For various reasons, this is not fixed on all architectures on illumos and can shift due to trade offs with memory and more. To facilitate software wanting to know what it is for a given process, we add a new means of accessing it via sysconf with an _SC_MAX_UADDR value. In this case, we would encode the maximum address in a uintptr_t which is cast to the long. Here's an example of what such a program that uses this might look like and how it operates on x86:

nienor:~$ cat usermax.c 
#include <unistd.h>
#include <stdio.h>
#include <inttypes.h>
#include <err.h>

int
main(void)
{
        long out;

        out = sysconf(_SC_UADDR_MAX);
        if (out == -1) {
                warn("failed to get _SC_UADDR_MAX");
        }

        printf("maximum address: %" PRIxPTR "\n", (uintptr_t)out);
        return (0);
}
$ ./a.out 
maximum address: fefff000
$ gcc -Wextra -Wall -m64 usermax.c
$ ./a.out 
maximum address: fffffd7fffe00000
Actions #1

Updated by Electric Monk about 2 years ago

  • Status changed from New to Closed
  • % Done changed from 90 to 100

git commit 4c46c814833d7980b7ebf54590a97d7f91472bd5

commit  4c46c814833d7980b7ebf54590a97d7f91472bd5
Author: Robert Mustacchi <rm@fingolfin.org>
Date:   2020-05-12T05:31:08.000Z

    12691 Want means of getting the maximum user address in a process
    Reviewed by: Yuri Pankov <ypankov@fastmail.com>
    Reviewed by: Dan McDonald <danmcd@joyent.com>
    Reviewed by: Patrick Mooney <pmooney@pfmooney.com>
    Approved by: Gordon Ross <gordon.w.ross@gmail.com>

Actions

Also available in: Atom PDF