map bss to addr zero

5 messages, 4 authors, 2012-09-02 · open the first message on its own page

map bss to addr zero

From: Srinivas Ramanan <hidden>
Date: 2012-08-26 20:31:16

Hi all,
This is an interview question.
"What is the implication of mapping BSS to the Virtual Memory Segment 0?"

 I was not able to find the answer from web. So posting here.
thanks,
srinivas

map bss to addr zero

From: Greg Freemyer <hidden>
Date: 2012-08-26 22:41:29

Srinivas Ramanan [off-list ref] wrote:
Hi all,
This is an interview question.
"What is the implication of mapping BSS to the Virtual Memory Segment
0?"

I was not able to find the answer from web. So posting here.
thanks,
srinivas

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
As a guess,

Linux kernel developers leverage the fact that low address values are illegal, thus a pointer handling error that generates a low address value triggers a trap which allows the programmer to know he screwed up.

Using virtual memory segment zero makes those valid addresses and thus programming errors are more likely to slip through un-noticed.

HTH
Greg
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

map bss to addr zero

From: Mulyadi Santosa <hidden>
Date: 2012-08-27 14:15:14

On Mon, Aug 27, 2012 at 3:31 AM, Srinivas Ramanan
[off-list ref] wrote:
Hi all,
This is an interview question.
"What is the implication of mapping BSS to the Virtual Memory Segment 0?"
segment 0? or mapping zero page?

If it is indeed zero page, well, it's to trigger page fault later and
do actual page allocation when the variables (or structure etc) at BSS
is actually accessed.

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

map bss to addr zero

From: Ritesh Harjani <hidden>
Date: 2012-09-01 19:23:17

On Mon, Aug 27, 2012 at 2:01 AM, Srinivas Ramanan <
srinivas.ramanan@gmail.com> wrote:
Hi all,
This is an interview question.
"What is the implication of mapping BSS to the Virtual Memory Segment 0?"

 I was not able to find the answer from web. So posting here.
thanks,
srinivas

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Hi,

The bss section typically includes all uninitialized variables declared
with the static keyword.
The zero page which  is a copy-on-write page that reads as zero is used to
map the BSS segment. Any process referencing the zero page sees the page
filled with zeos and if it tries to writes to the page, it ends up
modifying a private copy. (LDD ch15. page 429)

Mulyadi,

Why it will generate a page fault later when process will tries to
reference it, while it already has mapped with the zero page?


Sorry if i am wrong anywhere.
Ritesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120902/b18f7568/attachment.html 

map bss to addr zero

From: Mulyadi Santosa <hidden>
Date: 2012-09-02 05:46:29

Hi... :)

On Sun, Sep 2, 2012 at 2:23 AM, Ritesh Harjani [off-list ref] wrote:
Mulyadi,

Why it will generate a page fault later when process will tries to reference
it, while it already has mapped with the zero page?
Hopefully I interpret it correctly that this question is for me :)

Sorry, maybe I am not clear, by reference, I meant "updating " or
"writing" new value.

Since this zero page is mapped as read only, when writing to this zero
page, page fault is triggered. Then page fault handler conclude that
this is actually a write toward zero page from valid address, so it
will allocate page(s).


-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help