tests: check fpu registers before doing any function call

Function calls can "corrupt" fpu registers.

PiperOrigin-RevId: 671577096
This commit is contained in:
Andrei Vagin
2024-09-05 18:19:44 -07:00
committed by gVisor bot
parent 277c0b60ec
commit 15d2cdc331
2 changed files with 6 additions and 5 deletions
+2 -2
View File
@@ -110,11 +110,11 @@ TEST(FPSigTest, Fork) {
asm volatile("svc #0\n" : "=r"(x0) : "r"(x0), "r"(x1), "r"(x2), "r"(x8) :);
ret = x0;
#endif
EXPECT_EQ(ret, 0);
uint64_t got;
GET_FP0(got);
EXPECT_EQ(ret, 0);
if (getpid() == parent) { // Parent.
int status;
ASSERT_THAT(waitpid(child, &status, 0), SyscallSucceedsWithValue(child));
+4 -3
View File
@@ -82,11 +82,12 @@ void sigusr1(int s, siginfo_t* siginfo, void* _uc) {
asm volatile("svc #0\n" : "=r"(x0) : "r"(x0), "r"(x1), "r"(x2), "r"(x8) :);
ret = x0;
#endif
EXPECT_EQ(ret, 0);
// Record value of %xmm0 again to verify that the nested signal handler
// does not clobber it.
GET_FP0(exitxmm[0]);
EXPECT_EQ(ret, 0);
}
TEST(FPSigTest, NestedSignals) {
@@ -132,11 +133,11 @@ TEST(FPSigTest, NestedSignals) {
asm volatile("svc #0\n" : "=r"(x0) : "r"(x0), "r"(x1), "r"(x2), "r"(x8) :);
ret = x0;
#endif
EXPECT_EQ(ret, 0);
uint64_t got;
GET_FP0(got);
EXPECT_EQ(ret, 0);
//
// The checks below verifies the following:
// - signal handlers must called with a clean fpu state.