-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathmmap_s390_va_bits.c
More file actions
37 lines (34 loc) · 1.43 KB
/
Copy pathmmap_s390_va_bits.c
File metadata and controls
37 lines (34 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// This file is part of KASLD - https://github.com/bcoles/kasld
//
// s390 paging-level detection via an mmap boundary probe, emitted as
// SF_VIRT_ADDR_BITS (42 for 3-level, 53 for 4-level). A rule turns it into a
// text-base ceiling (text < 1<<VA_BITS). s390x only — gated at compile time so
// non-s390 builds skip via the Makefile's `cc-component` wrapper instead of
// shipping a binary whose helper `kasld_s390_va_bits()` returns 0
// unconditionally on the wrong arch.
// ---
// <bcoles@gmail.com>
#if !defined(__s390__) && !defined(__s390x__)
#error "Architecture is not supported"
#endif
#include "include/kasld/api.h"
#include "include/kasld/cli.h"
#include "include/kasld/s390_paging.h"
KASLD_EXPLAIN("Probes the s390 user-address-space limit with a single "
"mmap(MAP_FIXED) at 1<<42 and emits the detected VA-bit width as "
"SF_VIRT_ADDR_BITS. Unprivileged, no sysctl gate. s390x only.");
KASLD_META("method:inferred\n"
"phase:probing\n"
"live:1\n"
"discloses:facts\n");
int main(void) {
if (kasld_skip_live_probe("VA_BITS mmap"))
return 0;
/* Live mmap boundary probe of the running VA space. */
int va = kasld_s390_va_bits();
/* Inferred from an mmap boundary probe, not parsed from an authoritative
* source: CONF_INFERRED (at the sound floor), not CONF_PARSED. */
if (va > 0)
kasld_emit_scalar(SF_VIRT_ADDR_BITS, (unsigned long)va, CONF_INFERRED);
return 0;
}