buddy memory allocation in zephyr rtos
play

Buddy Memory Allocation in Zephyr RTOS L o L o g o g o Authors: - PowerPoint PPT Presentation

Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS L o L o g o g o Authors: Feng Zhang , Yongwang Zhao , , Dianfu Ma , Wensheng Niu *. Corresponding Author 1. School of Computer


  1. Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS L o L o g o g o Authors: Feng Zhang 𝟐 , Yongwang Zhao βˆ—,𝟐 , Dianfu Ma 𝟐 , Wensheng Niu πŸ‘ *. Corresponding Author 1. School of Computer Science and Engineering, Beihang Univerisity, China 2. Aeronautical Computing Technique Research Institute, Xi’an, China

  2. Contents ➒ 1. Introduction ➒ 2. Buddy Memory Allocation Algorithm in Zephyr ➒ 3. Fine-Grained Formal Specification in Isabell/HOL ➒ 4. Formal Proof ➒ 5. Results and Discussions ➒ 6. Conclusions 1 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  3. 1. Introduction - Abstract ➒ Memory management (MM) is a critical component of OS ➒ Bugs in MM may crash OS or the whole critical system ➒ This paper presents a case study of formal verification on the buddy memory allocation component of the Zephyr RTOS: β€’ Provide Fine-Grained formal specification in Isabelle/HOL β€’ Conduct Formal proof using the interactive prover in Isabelle β€’ Find two flaws in the C code when executing sequentially 2 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  4. 1. Introduction – Research Status ➒ Verification of the TLSF algorithm in Event-B: O nly verifies an abstract specification at the requirement level β€’ β€’ not check consistency between elements in the data structure ➒ seL4 pushes the memory allocation outside of the kernel ➒ Yu et al. introduce a low-level language CAP (certified assembly programming) in Coq β€’ build certified programs β€’ present a certified library for dynamic storage allocation β€’ not a kernel’s component but a certified memory library β€’ 75 lines C code 3 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  5. 1. Introduction – summary ➒ We create a fine-grained formal specification: β€’ All the elements of the data structure β€’ All the operations (initialization, allocation and release) β€’ System clocks and simple kernel scheduling β€’ The execution of memory allocation is preemptive ➒ We concentrate in five types of critical properties: β€’ Invariants β€’ Correctness of doubly linked lists β€’ Functional correctness of events β€’ Conformity of event specifications to kernel requirements β€’ Livelock-free of the system specification. 4 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  6. Contents ➒ 1. Introduction ➒ 2. Buddy Memory Allocation Algorithm in Zephyr ➒ 3. Fine-Grained Formal Specification in Isabell/HOL ➒ 4. Formal Proof ➒ 5. Results and Discussions ➒ 6. Conclusions 5 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  7. 2.1 – Zephyr Project ➒ Zephyr Project is a Linux Foundation Project ➒ Be perfect for building simple connected sensors: β€’ up to modems and small IoT wireless gateways β€’ Built with safety and security in mind β€’ Cross-architecture with growing developer tool support β€’ Complete, fully integrated, highly configurable, modular for flexibility, better than roll-your-own β€’ Product development ready β€’ Permissively licensed 6 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  8. 2.2 – Zephyr OS Kernel ➒ Derived from Wind River ’s commercial Microkernel Profile ➒ Microkernel Profile has evolved over 20 years from DSP RTOS technology known as Virtuoso ➒ Used in several commercial applications: β€’ satellites, military command and control communications, radar, telecommunications and image processing β€’ successful Philae Landing on Comet Churyumov – Gerasimenko and the accompanying Rosetta Orbiter 7 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  9. 2.2 – Buddy Memory Allocation Algorithm in Zephyr Kernel ➒ (1) Pool and block Initialization β€’ only be defined and initialized at compile time ➒ (2) Block Allocation β€’ Quad-Partitioning: iteratively partitioning larger blocks into smaller quad- ones ➒ (3)Block Release β€’ Immediately, automatically, and recursively combining smaller blocks into bigger ones 8 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  10. 2.2 – Buddy Memory Allocation Algorithm in Zephyr Kernel ➒ (1) Pool and block Initialization β€’ only be defined and initialized at compile time ➒ (2) Block Allocation β€’ Quad-Partitioning: iteratively partitioning larger blocks into smaller quad- ones ➒ (3)Block Release β€’ Immediately, automatically, and recursively combining smaller blocks into bigger ones 9 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  11. Contents ➒ 1. Introduction ➒ 2. Buddy Memory Allocation Algorithm ➒ 3. Fine-Grained Formal Specification in Isabell/HOL ➒ 4. Formal Proof ➒ 5. Results and Discussions ➒ 6. Conclusions 10 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  12. 3 – Fine-Grained Formal Specification ➒ A. State Machine β€’ The state is defined as a record StateD β€’ the initial state 𝑑 0 state-transition functions Ο† β€’ 11 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  13. 3 – Fine-Grained Formal Specification ➒ B. Data Structure 12 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  14. 3 – Fine-Grained Formal Specification ➒ B. Data Structure 13 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  15. 3 – Fine-Grained Formal Specification ➒ C. Event Specification  system behaviors based on Zephyr characteristics β€’ system clocks time_tick β€’ the thread scheduling schedule  actions operated on memory pools and blocks β€’ pool and block initializations β€’ block allocations β€’ block release 14 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  16. 3 – Fine-Grained Formal Specification ➒ C. Event Specification  system behaviors based on Zephyr characteristics β€’ system clocks time_tick β€’ the thread scheduling schedule  actions operated on memory pools and blocks β€’ pool and block initializations β€’ block allocations β€’ block release 15 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  17. 3 – Fine-Grained Formal Specification ➒ C. Event Specification 16 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  18. 3 – Fine-Grained Formal Specification ➒ D. State Space 17 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  19. Contents ➒ 1. Introduction ➒ 2. Buddy Memory Allocation Algorithm in Zephyr ➒ 3. Fine-Grained Formal Specification in Isabell/HOL ➒ 4. Formal Proof ➒ 5. Results and Discussions ➒ 6. Conclusions 18 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  20. 4 – Formal Proof ➒ 4.1 Invariants - Consistency of Data Structure β€’ bitMap_freelistS s specifies the consistency between bit_maps and free lists β€’ bitMap_treeS s specifies the consistency between bit_maps and abstract trees. 19 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  21. 4 – Formal Proof ➒ 4.2 Correctness of Doubly Linked Lists β€’ The pointer in C is specified as a ref in Isabelle β€’ ref = (UNIV::nat set) β€’ head_next :: β€œref => refβ€œ β€’ tail_prev :: "ref => ref" 20 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  22. 4 – Formal Proof ➒ 4.2 Correctness of Doubly Linked Lists β€’ Length of a dilist β€’ Validity of a node β€’ Validity of a dlist β€’ Validity of appending actions 21 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  23. 4 – Formal Proof ➒ 4.3 Functional Correctness of Events β€’ {P} C {Q} β€’ Our specifications are all total correctness specifications β€’ terminations are ensured by using the primrec, fun, function and definition 22 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  24. 4 – Formal Proof ➒ 4.4 Conformity of Event Specifications to Kernel Requirements β€’ determine whether event executions and their return values conform to the kernel requirements ➒ 4.5 Livelock-free β€’ Starvation β€’ Execution loop β€’ No further progress 23 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  25. Contents ➒ 1. Introduction ➒ 2. Buddy Memory Allocation Algorithm in Zephyr ➒ 3. Fine-Grained Formal Specification in Isabell/HOL ➒ 4. Formal Proof ➒ 5. Results and Discussions ➒ 6. Conclusions 24 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  26. 5 – Results and Discussions ➒ A. Evaluation β€’ 600 lines C β€’ 800 lines specification: 109 functions/definitions 12 primary events β€’ 9400 lines proof: 338 lemmas 25 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

  27. 5 – Results and Discussions ➒ B. Results of formal analysis: fine two flaws  Return code not conform to the kernel requirement  Application thread will fall into live lock. 26 Fine-Grained Formal Specification and Analysis of Buddy Memory Allocation in Zephyr RTOS

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend