Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 08f1190

Browse filesBrowse files
misc(vm): vm_flags -> flags
Signed-off-by: Anhad Singh <andypythonappdeveloper@gmail.com>
1 parent 773565f commit 08f1190
Copy full SHA for 08f1190

File tree

Expand file treeCollapse file tree

1 file changed

+25
-30
lines changed
Filter options
  • src/aero_kernel/src/userland
Expand file treeCollapse file tree

1 file changed

+25
-30
lines changed

‎src/aero_kernel/src/userland/vm.rs

Copy file name to clipboardExpand all lines: src/aero_kernel/src/userland/vm.rs
+25-30Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ impl MMapFile {
371371

372372
#[derive(Clone)]
373373
pub struct Mapping {
374-
vm_flags: VmFlag,
374+
flags: VmFlag,
375375

376376
pub start_addr: VirtAddr,
377377
pub end_addr: VirtAddr,
@@ -382,22 +382,21 @@ pub struct Mapping {
382382

383383
impl Mapping {
384384
pub fn set_protection(&mut self, protection: MMapProt) -> aero_syscall::Result<()> {
385-
if (protection.contains(MMapProt::PROT_READ) && !self.vm_flags.contains(VmFlag::MAY_READ))
385+
if (protection.contains(MMapProt::PROT_READ) && !self.flags.contains(VmFlag::MAY_READ))
386386
|| (protection.contains(MMapProt::PROT_WRITE)
387-
&& !self.vm_flags.contains(VmFlag::MAY_WRITE))
388-
|| (protection.contains(MMapProt::PROT_EXEC)
389-
&& !self.vm_flags.contains(VmFlag::MAY_EXEC))
387+
&& !self.flags.contains(VmFlag::MAY_WRITE))
388+
|| (protection.contains(MMapProt::PROT_EXEC) && !self.flags.contains(VmFlag::MAY_EXEC))
390389
{
391390
return Err(aero_syscall::SyscallError::EACCES);
392391
}
393392

394-
self.vm_flags = (self.vm_flags & !VM_PROT_MASK) | protection.into();
393+
self.flags = (self.flags & !VM_PROT_MASK) | protection.into();
395394
Ok(())
396395
}
397396

398397
#[inline]
399398
pub fn protection(&self) -> VmFlag {
400-
self.vm_flags & VM_PROT_MASK
399+
self.flags & VM_PROT_MASK
401400
}
402401

403402
/// Handler routine for private anonymous pages. Since its an anonymous page is not
@@ -421,9 +420,7 @@ impl Mapping {
421420
// NOTE: We dont need to remove the writeable flag from this mapping, since
422421
// the writeable flag will be removed from the parent and child on fork so,
423422
// the mapping gets copied on write.
424-
PageTableFlags::USER_ACCESSIBLE
425-
| PageTableFlags::PRESENT
426-
| self.vm_flags.into(),
423+
PageTableFlags::USER_ACCESSIBLE | PageTableFlags::PRESENT | self.flags.into(),
427424
)
428425
}
429426
.expect("Failed to identity map userspace private mapping")
@@ -446,7 +443,7 @@ impl Mapping {
446443
page,
447444
PageTableFlags::USER_ACCESSIBLE
448445
| PageTableFlags::PRESENT
449-
| self.vm_flags.into(),
446+
| self.flags.into(),
450447
)
451448
.unwrap()
452449
.flush();
@@ -475,7 +472,7 @@ impl Mapping {
475472
let addr = addr.align_down(Size4KiB::SIZE);
476473
let size = Size4KiB::SIZE.min(file.size as u64 - (addr - self.start_addr));
477474

478-
return if self.vm_flags.contains(VmFlag::SHARED) {
475+
return if self.flags.contains(VmFlag::SHARED) {
479476
self.handle_pf_shared_file(offset_table, reason, addr, offset as _, size as _)
480477
} else {
481478
self.handle_pf_private_file(offset_table, reason, addr, offset as _, size as _)
@@ -532,7 +529,7 @@ impl Mapping {
532529
frame,
533530
PageTableFlags::PRESENT
534531
| PageTableFlags::USER_ACCESSIBLE
535-
| (self.vm_flags & !VmFlag::WRITE).into(),
532+
| (self.flags & !VmFlag::WRITE).into(),
536533
)
537534
}
538535
.expect("failed to map allocated frame for private file read")
@@ -553,9 +550,7 @@ impl Mapping {
553550
offset_table.map_to(
554551
Page::containing_address(addr),
555552
frame,
556-
PageTableFlags::PRESENT
557-
| PageTableFlags::USER_ACCESSIBLE
558-
| self.vm_flags.into(),
553+
PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE | self.flags.into(),
559554
)
560555
}
561556
.expect("failed to map allocated frame for private file read")
@@ -607,7 +602,7 @@ impl Mapping {
607602
page_cache.page(),
608603
PageTableFlags::PRESENT
609604
| PageTableFlags::USER_ACCESSIBLE
610-
| self.vm_flags.into(),
605+
| self.flags.into(),
611606
)
612607
}
613608
.unwrap()
@@ -621,7 +616,7 @@ impl Mapping {
621616
page_cache.page(),
622617
PageTableFlags::PRESENT
623618
| PageTableFlags::USER_ACCESSIBLE
624-
| (self.vm_flags & !VmFlag::WRITE).into(),
619+
| (self.flags & !VmFlag::WRITE).into(),
625620
)
626621
}
627622
.unwrap()
@@ -636,7 +631,7 @@ impl Mapping {
636631
frame,
637632
PageTableFlags::PRESENT
638633
| PageTableFlags::USER_ACCESSIBLE
639-
| self.vm_flags.into(),
634+
| self.flags.into(),
640635
)
641636
}
642637
.unwrap()
@@ -710,15 +705,15 @@ impl Mapping {
710705
if let Some(vm_frame) = phys_addr.as_vm_frame() {
711706
if vm_frame.ref_count() > 1 || copy {
712707
// This page is used by more then one process, so make it a private copy.
713-
Self::map_copied(offset_table, page, self.vm_flags).unwrap();
708+
Self::map_copied(offset_table, page, self.flags).unwrap();
714709
} else {
715710
// This page is used by only one process, so make it writable.
716711
unsafe {
717712
offset_table.update_flags(
718713
page,
719714
PageTableFlags::PRESENT
720715
| PageTableFlags::USER_ACCESSIBLE
721-
| self.vm_flags.into(),
716+
| self.flags.into(),
722717
)
723718
}
724719
.unwrap()
@@ -769,7 +764,7 @@ impl Mapping {
769764
end_addr: end + (self.end_addr - end),
770765
file: new_file,
771766
refresh_flags: true,
772-
vm_flags: self.vm_flags,
767+
flags: self.flags,
773768
};
774769

775770
self.end_addr = start;
@@ -857,21 +852,21 @@ impl VmProtected {
857852
}
858853

859854
if reason.contains(PageFaultErrorCode::CAUSED_BY_WRITE)
860-
&& !map.vm_flags.contains(VmFlag::WRITE)
855+
&& !map.flags.contains(VmFlag::WRITE)
861856
{
862857
return false;
863858
}
864859

865860
if reason.contains(PageFaultErrorCode::INSTRUCTION_FETCH)
866-
&& !map.vm_flags.contains(VmFlag::EXEC)
861+
&& !map.flags.contains(VmFlag::EXEC)
867862
{
868863
return false;
869864
}
870865

871866
let mut address_space = AddressSpace::this();
872867
let mut offset_table = address_space.offset_page_table();
873868

874-
match (!map.vm_flags.contains(VmFlag::SHARED), map.file.is_none()) {
869+
match (!map.flags.contains(VmFlag::SHARED), map.file.is_none()) {
875870
(true, true) => {
876871
map.handle_pf_private_anon(&mut offset_table, reason, accessed_address)
877872
}
@@ -1024,7 +1019,7 @@ impl VmProtected {
10241019
// Merge same mappings instead of creating a new one.
10251020
if let Some(prev) = cursor.peek_prev() {
10261021
if prev.end_addr == addr
1027-
&& prev.vm_flags == vm_flags
1022+
&& prev.flags == vm_flags
10281023
&& prev.file.is_none()
10291024
&& file.is_none()
10301025
{
@@ -1039,7 +1034,7 @@ impl VmProtected {
10391034

10401035
file: file.map(|f| MMapFile::new(f, offset, size)),
10411036
refresh_flags: true,
1042-
vm_flags,
1037+
flags: vm_flags,
10431038
});
10441039

10451040
addr
@@ -1071,7 +1066,7 @@ impl VmProtected {
10711066
"{:?}..{:?} => {:?} (offset={:#x}, size={:#x})",
10721067
mmap.start_addr,
10731068
mmap.end_addr,
1074-
mmap.vm_flags,
1069+
mmap.flags,
10751070
file.offset,
10761071
file.size,
10771072
);
@@ -1080,7 +1075,7 @@ impl VmProtected {
10801075
"{:?}..{:?} => {:?}",
10811076
mmap.start_addr,
10821077
mmap.end_addr,
1083-
mmap.vm_flags,
1078+
mmap.flags,
10841079
);
10851080
}
10861081
}
@@ -1365,7 +1360,7 @@ impl VmProtected {
13651360

13661361
for map in self.mappings.iter().filter(|map| {
13671362
// Do not copy page table entries where a page fault can map them correctly.
1368-
!map.vm_flags.contains(VmFlag::SHARED) && map.vm_flags.contains(VmFlag::MAY_WRITE)
1363+
!map.flags.contains(VmFlag::SHARED) && map.flags.contains(VmFlag::MAY_WRITE)
13691364
}) {
13701365
offset_table.copy_page_range(&mut current, map.start_addr..=map.end_addr);
13711366
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.