Skip to content

Add control for the native stack overflow check with hardware trap #1677

@wenyongh

Description

@wenyongh

Motivation

In current design, when the hw bound check feature is enabled (enabled by default for linux/darwin/macos/windows 64-bit), the wasm linear memory access boundary check with hardware trap support and native stack access boundary check with hardware trap support are both enabled by default, which improves the performance, but lacks the accurate control for the native thread's stack:

  • It requires to set the guard pages for the native stack and touch the whole native stack's pages firstly, which previously writes the stack memory, and increases the RSS memory usage .
  • Normally the main thread's stack size is 8MB and the child thread's stack size is 1MB.

In some environment we hope to reduce the memory usage, and disable the native stack hw bound check feature and keep the linear memory hw bound check feature.

The main changes

To achieve the goal, we will add new options to control the native stack hw bound check feature:

  • The linear memory hw bound check and stack hw bound check can work independently. And if the former is set, the latter will be enabled by default if the option isn't set by user, so as to keep the compatibility with current version.
  • Besides the original option cmake -DWAMR_DISABLE_HW_BOUND_CHECK=1/0, add a new cmake variable cmake -DWAMR_DISABLE_STACK_HW_BOUND_CHECK=1/0.
  • Besides the original option --bounds-checks=1, add new option --stack-bounds-checks=1 for wamrc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions