About "Data Segment expansion to low"-an admirable post

Source: Internet
Author: User

When the field of the segment descriptor TYPE is ED = 1, the field is "extended to low". As for what is "extended to low", Yang Jiwen said: "ED = 0 indicates high extension, and ED = 1 indicates low extension... when the maximum segment is 1 MB, it ranges from 0 ~ The offset of limit is valid and valid ~ The offset of 1 m-1 is an invalid offset. In the low expansion segment, the opposite is true, ranging from 0 ~ The offset of limit is invalid ~ The offset of 1-1 is valid ."

I don't seem to understand it. I haven't gotten any results after I checked it online for a long time. I was so impressed by the attitude of the author when I was preparing to wait for a long time. Original document sticking:

Recently, I have been studying the protection mode. A problem has been bothering me, that is, the downward expansion of segments. I think there is an article in the snow about downward expansion, but I still don't understand it. I hope the experts can help me solve the problem.
Assume that I have a 16-bit segment with a base address of 0x2000 h and A CIDR block limit of 0x5 h. The size of this segment should be 0x6 H, but what is the downward scaling layout?
The first possible cause is:

0 <-------- low address

0x1ffbh <-------- segment limit (0x2000h-0x5h)
........
0x2000 h <-------- Segment Base Address (not sure this should be a segment base address)

0 xffff <-------- high address

What is the valid region? I think it should be 0x1ffb ~ 0x2000 h, but the book says the valid offset is Limit + 1 ~ For example, if I want to access the first node, Limit + 1 = 6, I cannot figure out how the segment base address and 6 are associated to access the first byte. (And I am not sure where the first byte is located, is it 0x1ffbh or 0x2000h-1?

The second possibility is that as long as it is extended downward, the segment will change from Base + Limit to Limit + 1 ~ 0 xffffh, that is, the following:
0 <-------- low address

0x2000 h <--------
........
0x2005 h <--------
........
........
0 xffff <-------- high address

The size of this period is changed from 6 to 0xffff-0x2005h + 1. At this time, the segment base address is 0x2000 h (I think), and the segment offset is valid (Limit + 1 ~ I can understand it as soon as 1s-1, and the valid region is 0x2005h 5h ~ 0 xffff, but it feels awkward to think like this, and as mentioned in the book: it can be seen that if a segment is extended downward, all offsets must be greater than the limit length, because its limit length refers to the lower limit, its base address starts from the high address ., Conflict with the blue sentence!
I do not know clearly about the analysis. There is very little information on the Internet about the downward expansion.
In addition, I also see that the direction of ED determines the calculation method (addition/subtraction), but I have no deep understanding of this sentence.
Thank you !!!

 

[Announcement] Please pay attention to your words and deeds and do not make everyone feel uncomfortable!


Jinyuelong

Junior member

MATERIALS:Registration Date: Aug 2007 post:
25 excellent: 0 cash: 179 Kx thanks: 2 Thank-You articles: 0
Member appreciation count: 0
22010-10-13,
17:41:48Another thought
Next, I just found that in the first layout, if 0x2000h is the base address, 0x1ffb ~ 0x2000h is a valid region. If you want to access the byte 0x1ffffh, It is 0x2000h-1, and-1 <=> 0 xFFFF (Signed) <=> 0 xFFFF (unsigned) <=> 1s-1, while 1s-1 is in the Limit + 1 ~ Does the CPU force the offset to the extended segment to be unsigned and then add it to the base address ??
 

[Announcement] If you think someone is provocative, click the "Report" button in the upper right corner of each post!


Jinyuelong

Junior member

MATERIALS:Registration Date: Aug 2007 post:
25 excellent: 0 cash: 179 Kx thanks: 2 Thank-You articles: 0
Member appreciation count: 0
32010-10-13,
18:47:17Further Thoughts
I thought about it again just now. The original Article in the book is:
The Extended Direction and segment boundary of the Data Segment determine the valid range of the offset in the data segment. When the segment size is 1 MB at most, the offset from 0 to Limit is valid in the segment to be extended to the high-end, the offset from Limit + 1 to 1-1 is an invalid offset. The offset from 0 to Limit is an invalid offset in the extended segments to the lower end, the offset from Limit + 1 to 1s-1 is valid and valid. Pay attention to the validity of the address corresponding to the Boundary Value Limit. When the maximum CIDR block is 4 GB, the situation is similar. It can be seen that if a segment is expanded downward, all offsets must be greater than the limit length, because the limit length refers to the lower limit, and its base address starts from the high address. Otherwise, if a segment is expanded upwards, all offsets must be less than or equal to the limit length, because the limit length refers to the upper limit, and the base address starts from the lower address. By using segment wrap, you can define a downward extended segment to any linear address and to any size.
I think the first layout should be correct, that is, when you expand down, the segment boundary should be BASE-Limit => 0x2000h-5 => 0x1ffbh. Read this sentence carefully: "As you can see, if a segment is expanded downward, all offsets must be greater than the limit length, because the limit length refers to the lower limit, and its base address starts from the high address. ", That is to say, for this downward extension segment, 0x1ffbh is indeed the lower limit, and any valid address must be greater than 0x1ffbh (I wonder why it is not greater than or equal to 0x1ffbh ).
However, the valid region for Limit is Limit + 1 ~ I still don't understand this. My own conjecture is that base + negative numbers are used to access the extended segments, for example, base + (-1) => base-1 to access 0x1fffh, base-6 to access 0x1ffbh (again wondering why 0x1ffbh is not a valid address), and then regard the negative index as the unsigned number to determine whether it is in the Limit + 1 ~ 1-1, that is, the steps to determine whether one extension is effective for the following segments are:
1. Assume that there is a negative index X, and the address to be accessed is BASE + X. Note that X is negative, condition 1 is BASE + X> BASE-Limit (again wondering why 0x1ffbh is not a valid address ).
2. Regard negative number X as an unsigned integer, and then condition 2: (DWORD) X> Limit & (DWORD) X <= 1s-1
If both conditions 1 and 2 are met, the access is successful.

The above is just a conjecture. I hope you will discuss it actively -_-

In addition, the book "by using segment wrap, you can define the downward extension segment to any linear address and can be defined as any size ." Which of the following heroes can explain this question?

 

[Announcement] Please pay attention to your words and deeds and do not make everyone feel uncomfortable!


Jinyuelong

Junior member

MATERIALS:Registration Date: Aug 2007 post:
25 excellent: 0 cash: 179 Kx thanks: 2 Thank-You articles: 0
Member appreciation count: 0
42010-10-13,
20:33:04Only a bit confused
I have just read Intel's white paper and read this article:

For expand-down data segments, the segment limit has the same function but is interpreted differently. here, the valid limit specifies the last address that is not allowed to be accessed within the segment; the range of valid offset is from (valid-limit + 1) to FFFFFFFFH if the B is set and from (valid-limit + 1) to FFFFH is the B is clear; An expand-down segment has maximum size when the segment limit is 0.

This should be the most authoritative explanation, or take h as an example, 5 limit, 16-bit segment, then the memory layout should be as follows:

0 <-------- low address

0x2000 h <--------
........
0x2005 h <-------- valid-Limit => Base + Limit
........
........
0 xffff <-------- high address

The valid address range of this segment should be 0x2006h 6h ~ 0 xffffh, that is, the valid range of Limit is from Limit + 1 ~ 1-1, of course, the generated linear address should be within the range of 6h 6h to 1-1.

I have only one question. Why should I start from Limit + 1? This indicates that the accessible memory in this region is from 0x2006h 6 h ~ Why is access not allowed at 0 xffffH and 0x2005 ??

Thank you.

In fact, I have also asked questions on csdn. It seems that we need to reflect on it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.