ISSN 1000-1239 CN 11-1777/TP

计算机研究与发展 ›› 2021, Vol. 58 ›› Issue (1): 189-207.doi: 10.7544/issn1000-1239.2021.20200284

• 软件技术 • 上一篇    下一篇

基于已有实例的Linux驱动程序前向移植接口补丁推荐

李 斌1,2, 贺也平1,2,3,马恒太1,2,芮建武1,2   

  1. 1(中国科学院大学 北京 100049);2(中国科学院软件研究所基础软件国家工程研究中心 北京 100190);3(计算机科学国家重点实验室(中国科学院软件研究所) 北京 100190) (libin@iscas.ac.cn)
  • 出版日期: 2021-01-01
  • 基金资助: 
    中国科学院战略性先导科技专项(XDA-Y01-01,XDC02010600)

Recommending Interface Patches for Forward Porting of Linux Device Drivers Based on Existing Instances

Li Bin1,2, He Yeping1,2,3, Ma Hengtai1,2, Rui Jianwu1,2   

  1. 1(University of Chinese Academy of Sciences, Beijing 100049);2(National Engineering Center of Fundamental Software, Institute of Software, Chinese Academy of Sciences, Beijing 100190);3(State Key Laboratory of Computer Science(Institute of Software, Chinese Academy of Sciences), Beijing 100190)
  • Online: 2021-01-01
  • Supported by: 
    This work was supported by the CAS Strategic Priority Program (XDA-Y01-01, XDC02010600).

摘要: Linux内核版本频繁升级对驱动程序带来的关联影响程度和影响范围都很大,为了修复这种关联影响带来的驱动程序调用内核接口的不一致性错误,不断修改旧版本驱动代码进行前向移植是一个持续和紧迫的问题.驱动演化辅助理解、驱动移植中间库辅助适配和驱动移植辅助信息等方面的已有研究,通过检索语句级别的辅助信息提高了驱动移植的效率.但是已有方法仅关注了检索辅助信息本身却并没有区分其中包含的有效补丁素材,因此还需要人工分析和手工构造适配性补丁.为了克服上述限制,提出了一种全新的方法旨在推荐驱动前向移植中接口错误的高质量补丁.观察发现,依赖相同内核接口服务的多个不同驱动程序之间存在相同或相似的内核接口调用,内核版本升级后其他驱动的历史开发信息中可能存在这种复用接口及其使用变更的已有实例代码.利用出错接口语句和相似已有实例的共性分析错误问题的特点,通过已有实例的辅助作用抽取针对性的接口修改方式和修改内容等细粒度素材生成待推荐补丁.具体结合分界点识别、相似度计算、细粒度差异比较和频度计算确定有效修改方式.提出了一种基于已有实例差异特征的分类算法,通过区分修改内容的不同类型分别从2种数据源提取.最后使用编辑脚本技术生成推荐补丁列表.在9个不同类型的真实驱动程序上的实验表明,该方法能够推荐驱动移植中7类接口错误补丁,有效补丁占比约67.4%,对现有辅助方法形成了有效补充和拓展.

关键词: 驱动移植, 已有实例, 接口复用, 修改方式, 补丁推荐, 接口错误

Abstract: The extent and scope of associated impact of Linux kernel version upgraded frequently on the drivers are very large. In order to repair the inconsistency error of the driver calling the kernel interface caused by this related impact, constantly modifying the old version drivers’ codes for forward porting is a continuing and urgent problem. There are existing researches on assistant understanding of driven evolution, assistant adaptation of driver porting middle lib and assistant information of driver porting. The efficiency of driver porting is improved by retrieving assistant information at the statement level. However, the existing methods only focus on retrieving assistant information itself without distinguishing the effective patch materials. Therefore, manual analysis and manual construction of adaptable patches are required. To overcome the above limitations, in this paper we propose a new method to recommend high quality patches for interface errors in drivers forward porting. We observe that: there are the same or similar kernel interfaces’ calls between multiple different drivers that rely on the same kernel interface services, and there may be existing instance codes in the development history of other drivers, which share the same interfaces reuse and interfaces changes after kernel version is upgraded. This paper uses the commonality of the error interface statements and similar existing instances in historical development information to analyze the characteristics of the error problem, and extracts targeted interface modification modes and contents of fine-grained materials to generate patches to be recommended. Specifically, the effective modification modes are determined by combining boundary point identification, similarity calculation, fine-grained difference comparison and frequency calculation. A classification algorithm based on the different characteristics of existing instances is proposed for the first time, by distinguishing the different types of modification contents, then content materials from two data sources are extracted respectively. Finally we use the editing script technology to generate the recommended patches using above materials. Experiment on 9 different types of real drivers shows that this method can recommend for 7 types of interface errors patches in driver porting, and the effective patches account for about 67.4%. Partly, it effectively supplements and expands existing assistant methods for driver porting.

Key words: driver porting, existing instances, interface reuse, modification modes, patches recommend, interface error

中图分类号: