Why I can't get the address that triggers Page Fault
Why I can't get the address that triggers Page Fault
I know the address will store in cr2 register, but I actually read cr2, but I get a wrong answer.
like this:
first,
I will execute this instruction.
I think it will set cr2 register to 0x1004a080, but it doesn't
when I push the step button, I see cr2 is like this.
Why is cr2 0x10056618 rather than 0x1004a080
and how can I get the correct value?(such as 0x1004a080)
like this:
first,
I will execute this instruction.
I think it will set cr2 register to 0x1004a080, but it doesn't
when I push the step button, I see cr2 is like this.
Why is cr2 0x10056618 rather than 0x1004a080
and how can I get the correct value?(such as 0x1004a080)
Re: Why I can't get the address that triggers Page Fault
I think we would need to see your complete code (particularly the exception handlers and their setup) before knowing what is happening. As a matter of interest, what is the address of your page fault handler? Also, what debugger are you using? And what is the error code from the page fault?
-
- Member
- Posts: 510
- Joined: Wed Mar 09, 2011 3:55 am
Re: Why I can't get the address that triggers Page Fault
Does DS by any chance have a non-zero base?
Re: Why I can't get the address that triggers Page Fault
No, the base is 0, So I am so weird in itlinguofreak wrote:Does DS by any chance have a non-zero base?
Re: Why I can't get the address that triggers Page Fault
I don't know which part of code I need to provide. do you really need the complete code? I think it doesn't cause by Page Fault handler. because I only read cr2, but I don't get a correct valueiansjack wrote:I think we would need to see your complete code (particularly the exception handlers and their setup) before knowing what is happening. As a matter of interest, what is the address of your page fault handler? Also, what debugger are you using? And what is the error code from the page fault?
and the error code is 0x00000007
I am using bochs. and I've tried qemu, I can't also get the correct value, so it is not the problem of emulator
And as you see, I just ran one command by pushing step button, so I don't think it causes by Page Fault handler.
I think maybe there is some attributes in pte or pde need to set it correct, but i don't know anything about it.
and the base of ds is 0.
Re: Why I can't get the address that triggers Page Fault
One more question - what is the content of address 0x1004a080?
Edit: And another - what is the value of the stack pointer when the exception occurs?
Obviously there is something wrong with your code or with the debugger you are using. Since you don't show us the code and don't tell us what debugger you are using it's difficult to second-guess what you are doing wrong.
It is good practice to supply a link to a repository of your entire code base when seeking help as the fault could be anywhere in it. We try to help, but you have to help us help.
Edit: And another - what is the value of the stack pointer when the exception occurs?
Obviously there is something wrong with your code or with the debugger you are using. Since you don't show us the code and don't tell us what debugger you are using it's difficult to second-guess what you are doing wrong.
It is good practice to supply a link to a repository of your entire code base when seeking help as the fault could be anywhere in it. We try to help, but you have to help us help.
Re: Why I can't get the address that triggers Page Fault
i am sorry about that, but my code is so bad and we come from different countries , so I am afraid you can’t understand it (comments ), would you mind it? But anyway,I will upload the code later.iansjack wrote:One more question - what is the content of address 0x1004a080?
Edit: And another - what is the value of the stack pointer when the exception occurs?
Obviously there is something wrong with your code or with the debugger you are using. Since you don't show us the code and don't tell us what debugger you are using it's difficult to second-guess what you are doing wrong.
It is good practice to supply a link to a repository of your entire code base when seeking help as the fault could be anywhere in it. We try to help, but you have to help us help.
question 1: I am using bochs debugger
question 2: I saw it is 0
I don’t know what the value of stack pointer is. Please wait for me, I need to see it and tell you.
At last, i am sorry for the way i asked the question.
Re: Why I can't get the address that triggers Page Fault
ok there is the code https://gitlab.com/min0911/PlantOSiansjack wrote:One more question - what is the content of address 0x1004a080?
Edit: And another - what is the value of the stack pointer when the exception occurs?
Obviously there is something wrong with your code or with the debugger you are using. Since you don't show us the code and don't tell us what debugger you are using it's difficult to second-guess what you are doing wrong.
It is good practice to supply a link to a repository of your entire code base when seeking help as the fault could be anywhere in it. We try to help, but you have to help us help.
-
- Member
- Posts: 5560
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Why I can't get the address that triggers Page Fault
How do I run the program that triggers the page fault?
Re: Why I can't get the address that triggers Page Fault
I am sorry, I haven’t uploaded the loader, so you can’t build and run now.Please wait for me,I am about to upload the loaderOctocontrabass wrote:How do I run the program that triggers the page fault?
Re: Why I can't get the address that triggers Page Fault
In GAS syntax, the operands are reversed as compared to Intel syntax. It should be mov %%cr2,%0.
Re: Why I can't get the address that triggers Page Fault
I have uploaded all the code, you need to do:Octocontrabass wrote:How do I run the program that triggers the page fault?
1. go to loader, then make
2. go to apps, then make
3. go to kernel, then make
and you can use qemu or bochs to run
the command is in run.sh
or you can run "bochs"
and to trigger page fault, you need to change to disk c or disk d by running C: or D: in the shell(if you are using qemu, change to disk d, or else, change to disk c)
And run lua.bin, try the following code twice, it will be blocked when the second run, you will see the page fault
os.execute(“dir”)
Last edited by min0911 on Thu Sep 14, 2023 9:43 am, edited 5 times in total.
Re: Why I can't get the address that triggers Page Fault
I know this, not cause by itGigasoft wrote:In GAS syntax, the operands are reversed as compared to Intel syntax. It should be mov %%cr2,%0.
-
- Member
- Posts: 5560
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Why I can't get the address that triggers Page Fault
That is the cause. It should be "mov %%cr2,%0".min0911 wrote:I know this, not cause by itGigasoft wrote:In GAS syntax, the operands are reversed as compared to Intel syntax. It should be mov %%cr2,%0.
Open Powerint_DOS_386.img in your hex editor and disassemble the instruction at 0x32806. The operands are reversed.
Code: Select all
00032806 0F 22 D0 mov cr2, eax
Code: Select all
00032806 0F 20 D0 mov eax, cr2
Re: Why I can't get the address that triggers Page Fault
oh I know,thank you so much!!!!Octocontrabass wrote:That is the cause. It should be "mov %%cr2,%0".min0911 wrote:I know this, not cause by itGigasoft wrote:In GAS syntax, the operands are reversed as compared to Intel syntax. It should be mov %%cr2,%0.
Open Powerint_DOS_386.img in your hex editor and disassemble the instruction at 0x32806. The operands are reversed.I corrected the instruction and now it works.Code: Select all
00032806 0F 22 D0 mov cr2, eax
Code: Select all
00032806 0F 20 D0 mov eax, cr2