虚拟MMU---客户机页表遍历
客户 机页表的遍历 MMU的功能: 虚拟 机地址转换为物理地址,下面函数模拟此过程。 1.数据结构 struct guest_walker { int level; gfn_t table_gfn[PT_MAX_FULL_LEVELS]; pt_element_t ptes[PT_MAX_FULL_LEVELS]; gpa_t pte_gpa[PT_MAX_FULL_LEVELS]; unsign
客户机页表的遍历
MMU的功能:虚拟机地址转换为物理地址,下面函数模拟此过程。
1.数据结构
struct guest_walker {int level;
gfn_t table_gfn[PT_MAX_FULL_LEVELS];
pt_element_t ptes[PT_MAX_FULL_LEVELS];
gpa_t pte_gpa[PT_MAX_FULL_LEVELS];
unsigned pt_access;
unsigned pte_access;
gfn_t gfn;
u32 error_code;
};
+-------+
| |
+-------+
| c |
|-------| | |
+-------+
|-------|
|-------|
+-------+ 某级页表
a:页表项基地址
b:index的地址
c:index的地址内容
遍历完成后,数据结构内容为
gfn:客户机页表转换后物理地址页框号
假设PT_MAX_FULL_LEVELS=4
table_gfn【0-3】存放 4级页表项基地址
pte_gpa【0-3】 存放4级页表项中index基地址
ptes【0-3】 存放4级页表项中index基地址内容
pt_access: gfn的访问权限
pte_access: gfn的访问权限
2:客户机页表的遍历,也是虚拟MMU
static int FNAME(walk_addr)(struct guest_walker *walker,
struct kvm_vcpu *vcpu, gva_t addr,
int write_fault, int user_fault, int fetch_fault)
walker->level = vcpu->arch.mmu.root_level;//64位客户机系统,页表级数为4.
pte = vcpu->arch.cr3; //页目录基地址
for (;;) { //从64位客户机页目录开始遍历,最后到页表
index = PT_INDEX(addr, walker->level);
table_gfn = gpte_to_gfn(pte);
pte_gpa = gfn_to_gpa(table_gfn);
pte_gpa += index * sizeof(pt_element_t);
walker->table_gfn[walker->level - 1] = table_gfn; //存放页表基地址
walker->pte_gpa[walker->level - 1] = pte_gpa; //存放页表index基地址
if (kvm_read_guest(vcpu->kvm, pte_gpa, &pte, sizeof(pte)))//获取存放页表index基地址页表项
goto not_present;
pte_access = pt_access & FNAME(gpte_access)(vcpu, pte);//获取存放页表index基地址页表项权限
walker->ptes[walker->level - 1] = pte;//存放存放页表index基地址页表项
if ((walker->level == PT_PAGE_TABLE_LEVEL)//页表的最后一级存放客户机物理页地址
{
int lvl = walker->level;
walker->gfn = gpte_to_gfn_lvl(pte, lvl);//转换客户机物理页地址为客户机物理页框号
walker->gfn += (addr & PT_LVL_OFFSET_MASK(lvl))
>> PAGE_SHIFT;
break;
}
pt_access = pte_access;
--walker->level; //遍历下一级页表
}
//页表遍历完成后,获取页表的访问权限,存放到数据结构中
walker->pt_access = pt_access;
walker->pte_access = pte_access;
pgprintk("%s: pte %llx pte_access %x pt_access %x\n",
__func__, (u64)pte, pt_access, pte_access);
return 1;
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

You may be wondering what the Microsoft Wi-Fi Direct Virtual Adapter does on your PC. Better rest assured that this network adapter is Microsoft and completely secure. But if the adapter is messing up your activity and you're wondering if it's worth keeping, this guide will give you everything you need to know. What does the Microsoft Wi-Fi Direct virtual adapter do? As the name suggests, Microsoft Wi-Fi Direct Virtual Adapter helps make your PC a wireless hotspot. This way, other computers can connect to your PC to access the Internet. It does this by virtualizing wireless network adapters. This way, your single physical wireless adapter is converted into two virtual

Audiences familiar with "Westworld" know that this show is set in a huge high-tech adult theme park in the future world. The robots have similar behavioral capabilities to humans, and can remember what they see and hear, and repeat the core storyline. Every day, these robots will be reset and returned to their initial state. After the release of the Stanford paper "Generative Agents: Interactive Simulacra of Human Behavior", this scenario is no longer limited to movies and TV series. AI has successfully reproduced this scene in Smallville's "Virtual Town" 》Overview map paper address: https://arxiv.org/pdf/2304.03442v1.pdf

According to news on September 25, Huawei Mall has begun accepting reservations for AITO’s Wenjie M9 car. This car is positioned as a panoramic smart flagship SUV with eye-catching features. Consumers only need to pay a deposit of 5,000 yuan, which can be used to offset the final payment of up to 10,000 yuan. The new car will be available in two versions, namely the extended-range version and the pure electric version. The price is expected to be between 500,000 yuan and 600,000 yuan, making it competitive in the high-end SUV market. Wenjie M9 is expected to be officially launched in the fourth quarter of 2023. No information on its specific configuration has been disclosed yet. It is understood that the M9 model adopts a family-oriented design language. Judging from the two official pictures, the side lines of the vehicle are smooth, and the door handles adopt a hidden design, adding technology to the entire vehicle.

Java is a popular programming language with powerful file handling capabilities. In Java, traversing a folder and getting all file names is a common operation, which can help us quickly locate and process files in a specific directory. This article will introduce how to implement a method of traversing a folder and getting all file names in Java, and provide specific code examples. 1. Use the recursive method to traverse the folder. We can use the recursive method to traverse the folder. The recursive method is a way of calling itself, which can effectively traverse the folder.

Example of using PHPglob() function: Traverse all files in a specified folder In PHP development, it is often necessary to traverse all files in a specified folder to implement batch operation or reading of files. PHP's glob() function is used to achieve this requirement. The glob() function can obtain the path information of all files that meet the conditions in the specified folder by specifying a wildcard matching pattern. In this article, we will demonstrate how to use the glob() function to iterate through all files in a specified folder

Top 10 virtual currency trading platforms in the 2025 cryptocurrency circle: 1. OKX, known for its high liquidity, low fees and abundant products; 2. Binance, one of the world's largest exchanges, with a huge user base; 3. Gate.io, a veteran exchange, safe and stable; 4. Kraken, focusing on professional traders, safe and compliant; 5. Huobi Global, a world-renowned, strong technical strength; 6. Coinbase, a leading exchange in the United States, easy to use compliance; 7. KuCoin, rich trading pairs, low fees.

Conceptual differences: Iterator: Iterator is an interface that represents an iterator that obtains values from a collection. It provides methods such as MoveNext(), Current() and Reset(), allowing you to traverse the elements in the collection and operate on the current element. Iterable: Iterable is also an interface, representing an iterable object. It provides the Iterator() method, which returns an Iterator object to facilitate traversing the elements in the collection. Usage: Iterator: To use Iterator, you need to first obtain an Iterator object, and then call the MoveNext() method to move to the next

Microsoft today announced an early preview of SharePoint integration with Copilot in Dynamics 365 Customer Service. This integration will give customer service agents access to a wider range of knowledge sources, resulting in increased productivity and improved customer interactions. Currently, Copilot in Dynamics365 Customer Service leverages an internal knowledge base to provide guidance to customer service agents. By suggesting chat and draft email content, Copilot has become a key tool for increasing the productivity of your customer service team. However, customer feedback indicates that the tool needs to leverage knowledge from external sources such as SharePoint. SharePoint Collaborative Driving Integration In response to this feedback,
