StanfordPL / x64asm

x86-64 assembler library
Apache License 2.0
470 stars 60 forks source link

movdqu - validation test fails #147

Closed rknath closed 9 years ago

rknath commented 9 years ago

movdqu 0x1000, %xmm1

It fails during validation.

is it because of the memory operand ????

git_diff diff --git a/Makefile b/Makefile index 66b78da..3260294 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,8 @@

limitations under the License.

CONSTANT DEFINITIONS

-CXX=ccache g++ -std=c++11 -Werror -Wextra -Wfatal-errors +CCACHES=#ccache +CXX=$(CCACHES) g++ -std=c++11 -Werror -Wextra -Wfatal-errors

INC_FOLDERS=\ ./ \ @@ -198,12 +198,12 @@ src/ext/astyle: $(MAKE) -C src/ext/astyle/build/gcc -j8

src/ext/cpputil:

diff --git a/src/validator/handlers/packed_handler.cc b/src/validator/handlers/packed_handler.cc index 0cad40b..5bff6f9 100644 --- a/src/validator/handlers/packed_handler.cc +++ b/src/validator/handlers/packed_handler.cc @@ -100,6 +100,12 @@ void PackedHandler::build_circuit(const x64asm::Instruction& instr, SymState& st

// Compute the result SymBitVector result;

cat movdqu.h class ValidatorMovdquTest : public ValidatorTest {};

TEST_F(ValidatorMovdquTest, NotANoop) {

target << "movdqu 0x1000, %xmm1" << std::endl; target << "retq" << std::endl;

//rewrite << "movdqu %xmm7, %ebx" << std::endl; rewrite << "retq" << std::endl;

assert_ceg(); } TEST_F(ValidatorMovdquTest, Identity) {

target << "movdqu 0x1000, %xmm1" << std::endl; target << "retq" << std::endl;

rewrite << "movdqu 0x1000, %xmm1" << std::endl; rewrite << "retq" << std::endl;

assert_equiv(); } TEST_F(ValidatorMovdquTest, LooksCorrect) {

target << "movdqu 0x1000, %xmm1" << std::endl; target << "retq" << std::endl;

stoke::Sandbox sb; sb.set_abi_check(false); stoke::StateGen sg(&sb); stoke::CpuState cs; sg.get(cs);

set_live_outs(x64asm::RegSet::empty() + x64asm::xmm1);

check_circuit(cs);

}

TEST_F(ValidatorMovdquTest, HardwareTest1){

target << "movdqu 0x1000, %xmm1" << std::endl; target << "retq" << std::endl;

stoke::Sandbox sb; sb.set_abi_check(false); stoke::StateGen sg(&sb); stoke::CpuState cs; sg.get(cs); cs.sse[x64asm::ymm1].get_fixed_quad(0) = 0x0001000200030004; cs.sse[x64asm::ymm1].get_fixed_quad(1) = 0x0005000600070008; cs.sse[x64asm::ymm1].get_fixed_quad(2) = 0xffffffffffffffff; cs.sse[x64asm::ymm1].get_fixed_quad(3) = 0xffffffffffffffff; set_live_outs(x64asm::RegSet::empty() + x64asm::xmm1); check_circuit(cs); }

[ FAILED ] ValidatorMovdquTest.NotANoop [ FAILED ] ValidatorMovdquTest.Identity [ FAILED ] ValidatorMovdquTest.LooksCorrect [ FAILED ] ValidatorMovdquTest.HardwareTest1

rknath commented 9 years ago

Looks like the error code is different at the end. Is it because the memory isn't set up properly ?

bchurchill commented 9 years ago

I don't think the validator has support for immediate memory offsets as it is, but this would be easy to do, I think.

You need to explicitly setup the CpuState to map memmory starting at 0x1000. Take a look in the state/ folder, and (I think) the file is memory.h. This isn't an x64asm issue though (x64asm is just the assembler, not the rest of stoke). I'll close this.

rknath commented 9 years ago

I posted in the wrong place. I couldn't find a way to move it to stoke. I was getting similar error while testing code like movdqu (%rax), %xmm1

bchurchill commented 9 years ago

You should check the assembly or the spreadsheet yourself -- we can't debug for you! :)

rknath commented 9 years ago

I went over the spread sheet. I didn't notice anything for this instruction. For a new Stoke user (not a developer) with limited knowledge on how different features (to what extent) are implemented in stoke, it may not be always trivial to understand the exact cause of an error.

bchurchill commented 9 years ago

It's not trivial for us to understand the exact cause of an error either, especially when we can't reproduce it. In fact, debugging is fairly involved. I recommend you collect more information. You've said the tests failed, but you haven't shown the error message. Usually the validator error messages are packed with information. I would recommend investigating the following:

My first guess would be that it's just making sure the sandbox has memory mapped in the correct location. With movdqu (%rax), %xmm1, the sandbox should have memory at the address pointed to by 'rax', although stategen should set this up for you.