File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,11 @@ impl VirtAddr {
107107 }
108108 ///`VirtAddr`->`VirtPageNum`
109109 pub fn ceil ( & self ) -> VirtPageNum {
110- VirtPageNum ( ( self . 0 - 1 + PAGE_SIZE ) / PAGE_SIZE )
110+ if self . 0 == 0 {
111+ VirtPageNum ( 0 )
112+ } else {
113+ VirtPageNum ( ( self . 0 - 1 + PAGE_SIZE ) / PAGE_SIZE )
114+ }
111115 }
112116 ///Get page offset
113117 pub fn page_offset ( & self ) -> usize {
@@ -136,7 +140,11 @@ impl PhysAddr {
136140 }
137141 ///`PhysAddr`->`PhysPageNum`
138142 pub fn ceil ( & self ) -> PhysPageNum {
139- PhysPageNum ( ( self . 0 - 1 + PAGE_SIZE ) / PAGE_SIZE )
143+ if self . 0 == 0 {
144+ PhysPageNum ( 0 )
145+ } else {
146+ PhysPageNum ( ( self . 0 - 1 + PAGE_SIZE ) / PAGE_SIZE )
147+ }
140148 }
141149 ///Get page offset
142150 pub fn page_offset ( & self ) -> usize {
You can’t perform that action at this time.
0 commit comments