diff options
author | Bin Lu <bin.lu@arm.com> | 2020-05-27 01:00:30 -0400 |
---|---|---|
committer | Bin Lu <bin.lu@arm.com> | 2020-06-04 21:48:21 -0400 |
commit | 6acd185bd3c04d6d6f57ccc9335513abaadf0651 (patch) | |
tree | 6bbcee10d5ef5ed1f793aa06c0c95b740f6a250b | |
parent | 8e2c5d951ea04f47ad1d37bab196a99fc56f5521 (diff) |
avoid runtime fails with missing stack maps in race mode on Arm64
In race mode, when calling the go function in asm code,
there will be an missing stack maps issue.
The root cause is:
The function of 'muldiv64' has a non-empty frame,
so it needs stack maps for locals, for which the macro NO_LOCAL_POINTERS will do.
Also, the macro GO_ARGS can covers arguments.
Signed-off-by: Bin Lu <bin.lu@arm.com>
-rw-r--r-- | pkg/sentry/time/muldiv_arm64.s | 3 | ||||
-rw-r--r-- | pkg/sentry/time/parameters_test.go | 15 |
2 files changed, 18 insertions, 0 deletions
diff --git a/pkg/sentry/time/muldiv_arm64.s b/pkg/sentry/time/muldiv_arm64.s index 5ad57a8a3..8afc62d53 100644 --- a/pkg/sentry/time/muldiv_arm64.s +++ b/pkg/sentry/time/muldiv_arm64.s @@ -12,12 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "funcdata.h" #include "textflag.h" // Documentation is available in parameters.go. // // func muldiv64(value, multiplier, divisor uint64) (uint64, bool) TEXT ·muldiv64(SB),NOSPLIT,$40-33 + GO_ARGS + NO_LOCAL_POINTERS MOVD value+0(FP), R0 MOVD multiplier+8(FP), R1 MOVD divisor+16(FP), R2 diff --git a/pkg/sentry/time/parameters_test.go b/pkg/sentry/time/parameters_test.go index e1b9084ac..0ce1257f6 100644 --- a/pkg/sentry/time/parameters_test.go +++ b/pkg/sentry/time/parameters_test.go @@ -484,3 +484,18 @@ func TestMulDivOverflow(t *testing.T) { }) } } + +func BenchmarkMuldiv64(b *testing.B) { + var v uint64 = math.MaxUint64 + for i := uint64(1); i <= 1000000; i++ { + mult := uint64(1000000000) + div := i * mult + res, ok := muldiv64(v, mult, div) + if !ok { + b.Errorf("Result of %v * %v / %v ok got false want true", v, mult, div) + } + if want := v / i; res != want { + b.Errorf("Bad result of %v * %v / %v: got %v, want %v", v, mult, div, res, want) + } + } +} |