Coder Social home page Coder Social logo

icspa-public's People

Contributors

ics-nju-wl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

icspa-public's Issues

关于push指令实现的细节

有个疑问是关于PA-4-1中的 push %esp 指令,如果要运行成功,那么压入栈中的需要是旧的 esp,可是按照手册的说法,压入栈中的是已经改变过的的 esp

手册上关于 push指令的描述为

PUSH decrements the stack pointer by 2 if the operand-size attribute of the instruction is 16 bits; otherwise, it decrements the stack pointer by 4. PUSH then places the operand on the new top of stack, which is pointed to by the stack pointer.
意思应该是先改变esp的值,再把源操作数的值放入新的esp指向的地方。

PA-3-3遭遇段错误,还在跟进中,希望老师指点下思路

问题描述:

pa3-3 测试过程中遇到Segmentation fault

调试日志:

使用gdb调试有以下log:

Program received signal SIGSEGV, Segmentation fault.
__memcpy_sse2_unaligned () at ../sysdeps/i386/i686/multiarch/memcpy-sse2-unaligned.S:667
667 ../sysdeps/i386/i686/multiarch/memcpy-sse2-unaligned.S: No such file or directory.
(gdb) bt
#0 __memcpy_sse2_unaligned () at ../sysdeps/i386/i686/multiarch/memcpy-sse2-unaligned.S:667
#1 0x0041b532 in hw_mem_read (len=, paddr=)
at src/memory/memory.c:20
#2 paddr_read (len=, paddr=) at src/memory/memory.c:35
#3 laddr_read (laddr=3221475392, len=4) at src/memory/memory.c:62
#4 0x0040612f in operand_read (opr=0x49f880 <opr_src>) at src/cpu/decode/operand.c:15
#5 0x0040c2cc in instr_execute_2op () at src/cpu/instr/mov.c:5
#6 0x0040cafd in mov_o2a_v (eip=204689, opcode=161 '\241') at src/cpu/instr/mov.c:21
#7 0x00405612 in exec_inst () at src/cpu/cpu.c:147
#8 0x0040568c in exec (n=) at src/cpu/cpu.c:71
#9 0x0041defa in cmd_c (args=0x434854 "") at src/monitor/ui.c:319
#10 ui_mainloop (autorun=1 '\001') at src/monitor/ui.c:319
#11 0x0041b38e in single_run (img_file_path=0x84b2400 <image_path> "./kernel/kernel.img",
elf_file_path=0x84b2000 <elf_path> "./testcase/bin/mov") at src/main.c:75
#12 0x004043f3 in main (argc=5, argv=0xbffff304) at src/main.c:158
(gdb) p/x 204689
$1 = 0x31f91
(gdb) p/x 3221475392
$2 = 0xc003d040
(gdb)

问题分析:

其中mov_o2a_v 这条指令地址是c0031f91,完整内容如下:

c0031f90 <__getreent>:
c0031f90: 55 push %ebp
c0031f91: a1 40 d0 03 c0 mov 0xc003d040,%eax
c0031f96: 89 e5 mov %esp,%ebp
c0031f98: 5d pop %ebp
c0031f99: c3 ret
c0031f9a: 66 90 xchg %ax,%ax
c0031f9c: 66 90 xchg %ax,%ax
c0031f9e: 66 90 xchg %ax,%ax

以上指令传递给 laddr_read 方法的参数是0xc003d040
由于此时kernel还没有设置开启内存分页模式(此时cpu.cr0.pg==0),所以直接继续调用paddr_read 和hw_mem_read ,方法参数依旧是0xc003d040,最终造成了段错误,

这个问题暂时还没有解决,还在持续跟进,不知老师可否有空指点下解决思路

A Bug: src/cpu/test/alu_test.c:109 'assert(cpu.eflags.SF == test_eflags.SF)' failed.

这里是报错内容:
9CF3U2V_EWF_0VUXRE9LTM6

在alu.c文件中相关代码为:
void set_SF(uint32_t result, size_t data_size){
result = sign_ext(result & (0xFFFFFFFF >> (32 - data_size)), datasize);
cpu.eflags.SF = sign(result)
}

在alu_test.c种相关代码为:①断言处代码,②是定义SF标志位代码
`3)(778ED7~0LW{7NQS1{HX

WIA NQ99FW14J90PYPC2J
但是我发现这两处代码均无错误,而alu.c 中的 sign() 函数在 include/cpu/alu.h中,源代码如下:
THZ %C3ELDZR_J%2{XC~%{V
在这里可以看到,代码中的最终结果应该是32位的数据,然而标志位SF只是一位数据,所以需要将之转化为一位数据。
因此需要将之改变为:
#define sign(x) (((uint_32_t)(x) >> 31) == 1)
这样返回值为布尔类型、一位数据。但是如果只改变这一处会报redefine错误,因此,同时还需要将src/cpu/cpu.c 中定义的sign(x)作出同样的修改。

make编译出错

老师您好,在PA0的时候,执行make,会出错,具体如下,请问该怎么解决比较合适?自己更改编译选项是个合适的方法吗?
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.