8000 [DOCS] Align usage.json and env.h by ksco · Pull Request #2633 · ptitSeb/box64 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[DOCS] Align usage.json and env.h #2633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ Add --no-sandbox argument to the guest program.

## Compatibility

### BOX64_AVX

Expose AVX extension to CPUID and cpuinfo file. Default value is 2 on Arm64 because it's fully implemented in DynaRec, 0 otherwise.

* 0: Do not expose AVX capabilities.
* 1: Expose AVX, BMI1, F16C and VAES extensions to CPUID and cpuinfo file.
* 2: All in 1, plus AVX2, BMI2, FMA, ADX,VPCLMULQDQ and RDRAND extensions.

### BOX64_BASH

Path to the bash executable.
Expand Down Expand Up @@ -462,9 +470,9 @@ Set the address where the program is loaded, only active for PIE guest programs.

### BOX64_LOG

Enable or disable Box64 logs.
Enable or disable Box64 logs, default value is 0 if stdout is not terminal, 1 otherwise.

* 0: Disable Box64 logs. [Default]
* 0: Disable Box64 logs.
* 1: Enable minimal Box64 logs.
* 2: Enable debug level Box64 logs.
* 3: Enable verbose level Box64 logs.
Expand All @@ -473,7 +481,7 @@ Enable or disable Box64 logs.

Disable the Box64 banner.

* 0: Show the Box64 banner. [Default]
* 0: Show the Box64 banner.
* 1: Do not show the Box64 banner.

### BOX64_NOSIGSEGV
Expand Down Expand Up @@ -567,6 +575,13 @@ Only available on box64 build with trace. Adds trace of all instructions execute

## Performance

### BOX64_DYNAREC

Enable/disable the Dynamic Recompiler (a.k.a DynaRec). This option defaults to 1 if it's enabled in the build options for a supported architecture.

* 0: Disable DynaRec.
* 1: Enable DynaRec.

### BOX64_DYNAREC_ALIGNED_ATOMICS

Generate aligned atomics only (only available on Arm64 for now).
Expand Down Expand Up @@ -684,6 +699,13 @@ Tweak the memory barriers to reduce the performance impact by strong memory emua
* 1: Use weak barriers to have more performance boost. [Default]
* 2: All in 1, plus disabled the last write barriers.

### BOX64_MMAP32

Force 32-bit compatible memory mappings on 64-bit programs that run 32-bit code (like Wine WOW64), can improve performance.

* 0: Do not force 32-bit memory mappings.
* 1: Force 32-bit memory mappings. [Default]

### BOX64_NODYNAREC

Forbid dynablock creation in the address range specified, helpful for debugging behaviour difference between Dynarec and Interpreter.
Expand Down
31 changes: 28 additions & 3 deletions docs/box64.pod
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ Arguments to pass to the guest program, only valid if there is no existing argum
* XXXX YYYY ZZZZ : Pass arguments XXXX, YYYY and ZZZZ to the guest program.


=item B<BOX64_AVX> =I<0|1|2>

Expose AVX extension to CPUID and cpuinfo file. Default value is 2 on Arm64 because it's fully implemented in DynaRec, 0 otherwise.

* 0 : Do not expose AVX capabilities.
* 1 : Expose AVX, BMI1, F16C and VAES extensions to CPUID and cpuinfo file.
* 2 : All in 1, plus AVX2, BMI2, FMA, ADX,VPCLMULQDQ and RDRAND extensions.


=item B<BOX64_BASH> =I<XXXX>

Path to the bash executable.
Expand Down Expand Up @@ -128,6 +137,14 @@ Dump elfloader debug information.
* 1 : Dump elfloader debug information.


=item B<BOX64_DYNAREC> =I<0|1>

Enable/disable the Dynamic Recompiler (a.k.a DynaRec). This option defaults to 1 if it's enabled in the build options for a supported architecture.

* 0 : Disable DynaRec.
* 1 : Enable DynaRec.


=item B<BOX64_DYNAREC_ALIGNED_ATOMICS> =I<0|1>

Generate aligned atomics only (only available on Arm64 for now).
8000 Expand Down Expand Up @@ -484,9 +501,9 @@ Set the address where the program is loaded, only active for PIE guest programs.

=item B<BOX64_LOG> =I<0|1|2|3>

Enable or disable Box64 logs.
Enable or disable Box64 logs, default value is 0 if stdout is not terminal, 1 otherwise.

* 0 : Disable Box64 logs. [Default]
* 0 : Disable Box64 logs.
* 1 : Enable minimal Box64 logs.
* 2 : Enable debug level Box64 logs.
* 3 : Enable verbose level Box64 logs.
Expand All @@ -509,11 +526,19 @@ Maximum CPU cores exposed.
* XXXX : Use XXXX CPU cores.


=item B<BOX64_MMAP32> =I<0|1>

Force 32-bit compatible memory mappings on 64-bit programs that run 32-bit code (like Wine WOW64), can improve performance.

* 0 : Do not force 32-bit memory mappings.
* 1 : Force 32-bit memory mappings. [Default]


=item B<BOX64_NOBANNER> =I<0|1>

Disable the Box64 banner.

* 0 : Show the Box64 banner. [Default]
* 0 : Show the Box64 banner.
* 1 : Do not show the Box64 banner.


Expand Down
34 changes: 18 additions & 16 deletions docs/gen/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,21 @@ def get_usage_entry(usage, define):

if t not in matches:
matches[t] = {}
matches[t][m.group("define")] = m
break
if (m.group("define") in matches[t]):
# multiple definitions, no default
matches[t][m.group("define")]['no_default'] = True
break
matches[t][m.group("define")] = m.groupdict()
matches[t][m.group("define")]['no_default'] = False

for define, m in matches["INTEGER"].items():
name = m.group("name")
default = (
0 if m.group("default") == "DEFAULT_LOG_LEVEL" else int(m.group("default"))
)
min = int(m.group("min"))
max = int(m.group("max"))
name = m["name"]
default = None if m["no_default"] or not m["default"].isdigit() else int(m["default"])
min = int(m["min"])
max = int(m["max"])

# Check default in valid range
if default < min or default > max:
if default and (default < min or default > max):
print(f"{define:<{PADDING}}: default lays outside of min/max range")

# Check consistency with usage.json
Expand Down Expand Up @@ -231,15 +233,15 @@ def get_usage_entry(usage, define):
print(
f"{define:<{PADDING}}: max value mismatch: env.h={max}, usage.json={max2}{(' (possible false positive)' if blank else '')}"
)
if default2 and default2 != default:
if default2 != default:
print(
f"{define:<{PADDING}}: default value mismatch: env.h={default}, usage.json={default2}"
)

for define, m in matches["INTEGER64"].items():
# similar to INTEGER but without min/max
name = m.group("name")
default = int(m.group("default"))
name = m["name"]
default = None if m["no_default"] or not m["default"].isdigit() else int(m["default"])

# Check consistency with usage.json
if e := get_usage_entry(data, define):
Expand All @@ -253,14 +255,14 @@ def get_usage_entry(usage, define):
if o["default"]:
default2 = val

if default2 and default2 != default:
if default2 != default:
print(
f"{define:<{PADDING}}: default value mismatch: env.h={default}, usage.json={default2}"
)

for define, m in matches["BOOLEAN"].items():
name = m.group("name")
default = bool(m.group("default"))
name = m["name"]
default = None if m["no_default"] or m["default"] not in ["0", "1"] else bool(m["default"])

# Check consistency with usage.json
if e := get_usage_entry(data, define):
Expand All @@ -274,7 +276,7 @@ def get_usage_entry(usage, define):
if o["default"]:
default2 = val

if default2 and default2 != default:
if default2 != default:
print(
f"{define:<{PADDING}}: default value mismatch: env.h={default}, usage.json={default2}"
)
Expand Down
62 changes: 59 additions & 3 deletions docs/gen/usage.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,28 @@
}
]
},
{
"name": "BOX64_AVX",
"description": "Expose AVX extension to CPUID and cpuinfo file. Default value is 2 on Arm64 because it's fully implemented in DynaRec, 0 otherwise.",
"category": "Compatibility",
"options": [
{
"key": "0",
"description": "Do not expose AVX capabilities.",
"default": false
},
{
"key": "1",
"description": "Expose AVX, BMI1, F16C and VAES extensions to CPUID and cpuinfo file.",
"default": false
},
{
"key": "2",
"description": "All in 1, plus AVX2, BMI2, FMA, ADX,VPCLMULQDQ and RDRAND extensions.",
"default": false
}
]
},
{
"name": "BOX64_BASH",
"description": "Path to the bash executable.",
Expand Down Expand Up @@ -164,6 +186,23 @@
}
]
},
{
"name": "BOX64_DYNAREC",
"description": "Enable/disable the Dynamic Recompiler (a.k.a DynaRec). This option defaults to 1 if it's enabled in the build options for a supported architecture.",
"category": "Performance",
"options": [
{
"key": "0",
"description": "Disable DynaRec.",
"default": false
},
{
"key": "1",
"description": "Enable DynaRec.",
"default": false
}
]
},
{
"name": "BOX64_DYNAREC_ALIGNED_ATOMICS",
"description": "Generate aligned atomics only (only available on Arm64 for now).",
Expand Down Expand Up @@ -970,13 +1009,13 @@
},
{
"name": "BOX64_LOG",
"description": "Enable or disable Box64 logs.",
"description": "Enable or disable Box64 logs, default value is 0 if stdout is not terminal, 1 otherwise.",
"category": "Debugging",
"options": [
{
"key": "0",
"description": "Disable Box64 logs.",
"default": true
"default": false
},
{
"key": "1",
Expand Down Expand Up @@ -1034,6 +1073,23 @@
}
]
},
{
"name": "BOX64_MMAP32",
"description": "Force 32-bit compatible memory mappings on 64-bit programs that run 32-bit code (like Wine WOW64), can improve performance.",
"category": "Performance",
"options": [
{
"key": "0",
"description": "Do not force 32-bit memory mappings.",
"default": false
},
{
"key": "1",
"description": "Force 32-bit memory mappings.",
"default": true
}
]
},
{
"name": "BOX64_NOBANNER",
"description": "Disable the Box64 banner.",
Expand All @@ -1042,7 +1098,7 @@
{
"key": "0",
"description": "Show the Box64 banner.",
"default": true
"default": false
},
{
"key": "1",
Expand Down
23 changes: 9 additions & 14 deletions src/emu/x64syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,12 +870,11 @@ void EXPORT x64Syscall(x64emu_t *emu)
break;
#endif
case 449:
#ifdef __NR_futex_waitv
if(BOX64ENV(futex_waitv))
S_RAX = syscall(__NR_futex_waitv, R_RDI, R_RSI, R_RDX, R_R10, R_R8);
else
#if defined(__NR_futex_waitv) && !defined(BAD_SIGNAL)
S_RAX = syscall(__NR_futex_waitv, R_RDI, R_RSI, R_RDX, R_R10, R_R8);
#else
S_RAX = -ENOSYS;
#endif
S_RAX = -ENOSYS;
break;
default:
printf_log(LOG_INFO, "Warning: Unsupported Syscall 0x%02Xh (%d)\n", s, s);
Expand Down Expand Up @@ -1156,16 +1155,12 @@ long EXPORT my_syscall(x64emu_t *emu)
return faccessat(S_ESI, (void*)R_RDX, (mode_t)R_RCX, S_R8d);
#endif
case 449:
#ifdef __NR_futex_waitv
if(BOX64ENV(futex_waitv))
return syscall(__NR_futex_waitv, R_RSI, R_RDX, R_RCX, R_R8, R_R9);
else
#if defined(__NR_futex_waitv) && !defined(BAD_SIGNAL)
return syscall(__NR_futex_waitv, R_RSI, R_RDX, R_RCX, R_R8, R_R9);
#else
errno = ENOSYS;
return -1;
#endif
{
errno = ENOSYS;
return -1;
}
break;
default:
if(!(warned&(1<<s))) {
printf_log(LOG_INFO, "Warning: Unsupported libc Syscall 0x%02X (%d)\n", s, s);
Expand Down
23 changes: 9 additions & 14 deletions src/emu/x86syscall_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,11 @@ void EXPORT x86Syscall(x64emu_t *emu)
}
break;
case 449:
#ifdef __NR_futex_waitv
if(BOX64ENV(futex_waitv))
S_RAX = syscall(__NR_futex_waitv, R_EBX, R_ECX, R_EDX, R_ESI, R_EDI);
else
#if defined(__NR_futex_waitv) && !defined(BAD_SIGNAL)
S_RAX = syscall(__NR_futex_waitv, R_EBX, R_ECX, R_EDX, R_ESI, R_EDI);
#else
S_RAX = -ENOSYS;
#endif
S_RAX = -ENOSYS;
break;
default:
printf_log(LOG_INFO, "Warning: Unsupported Syscall 0x%02Xh (%d)\n", s, s);
Expand Down Expand Up @@ -715,16 +714,12 @@ uint32_t EXPORT my32_syscall(x64emu_t *emu, uint32_t s, ptr_t* b)
#endif
#endif
case 449:
#ifdef __NR_futex_waitv
if(BOX64ENV(futex_waitv))
return syscall(__NR_futex_waitv, u32(0), u32(4), u32(8), u32(12), u32(16));
else
#if defined(__NR_futex_waitv) && !defined(BAD_SIGNAL)
return syscall(__NR_futex_waitv, u32(0), u32(4), u32(8), u32(12), u32(16));
#else
errno = ENOSYS;
return -1;
#endif
{
errno = ENOSYS;
return -1;
}
break;
default:
if((s>>6)<sizeof(warned)/sizeof(warned[0])) {
if(!(warned[s>>6]&(1<<(s&0x3f)))) {
Expand Down
Loading
0