FR3131032A1 - Process for generating an executable file containing system calls and associated library. - Google Patents

Process for generating an executable file containing system calls and associated library. Download PDF

Info

Publication number
FR3131032A1
FR3131032A1 FR2114094A FR2114094A FR3131032A1 FR 3131032 A1 FR3131032 A1 FR 3131032A1 FR 2114094 A FR2114094 A FR 2114094A FR 2114094 A FR2114094 A FR 2114094A FR 3131032 A1 FR3131032 A1 FR 3131032A1
Authority
FR
France
Prior art keywords
function
called
calling
mode
model
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
FR2114094A
Other languages
French (fr)
Other versions
FR3131032B1 (en
Inventor
Thibaud Tortech
Moha Ait Hmid
Cyril Faure
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Commissariat a lEnergie Atomique et aux Energies Alternatives CEA
Original Assignee
Commissariat a lEnergie Atomique CEA
Commissariat a lEnergie Atomique et aux Energies Alternatives CEA
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Commissariat a lEnergie Atomique CEA, Commissariat a lEnergie Atomique et aux Energies Alternatives CEA filed Critical Commissariat a lEnergie Atomique CEA
Priority to FR2114094A priority Critical patent/FR3131032B1/en
Publication of FR3131032A1 publication Critical patent/FR3131032A1/en
Application granted granted Critical
Publication of FR3131032B1 publication Critical patent/FR3131032B1/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

Procédé de génération d’un fichier exécutable contenant des appels systèmes et librairie associée. Procédé de génération d’un fichier, exécutable en mode utilisateur et appelant une fonction système définit dans un fichier appelé, exécutable en mode noyau, consistant à : fournir (210) une librairie comportant un méta-modèle des appels systèmes, et un modèle instanciant le méta-modèle pour une fonction système particulière et implémentant une fonction « interne » associée ; éditer (220) un fichier source pour comporter un appel à la fonction « interne », l’exécution de la fonction « interne » appelant la fonction système et à renvoyer le résultat de l’exécution de la fonction système par le code appelé ; compiler (230) le fichier source avec la librairie, le compilateur vérifiant que l’appel de la fonction « interne » est conforme, la conformité à l’appel de la fonction système étant garantie par le modèle. Figure pour l'abrégé : Figure 2Process for generating an executable file containing system calls and associated library. Method for generating a file, executable in user mode and calling a system function defined in a called file, executable in kernel mode, consisting in: providing (210) a library comprising a system call meta-model, and an instantiating model the meta-model for a particular system function and implementing an associated "internal" function; edit (220) a source file to include a call to the "internal" function, the execution of the "internal" function calling the system function and to return the result of the execution of the system function by the called code; compile (230) the source file with the library, the compiler checking that the "internal" function call conforms, the conformance to the system function call being guaranteed by the model. Figure for the abstract: Figure 2

Description

Procédé de génération d’un fichier exécutable contenant des appels systèmes et librairie associée.Process for generating an executable file containing system calls and associated library.

La présente invention concerne le développement de logiciels. Elle concerne plus particulièrement l’étape de compilation permettant de générer un ou plusieurs fichier(s) exécutable(s) à partir d’un ou plusieurs fichier(s) source(s).The present invention relates to software development. It relates more particularly to the compilation step making it possible to generate one or more executable file(s) from one or more source file(s).

Une fonction est une relation entre un ou plusieurs argument(s) d’entrée et un ou plusieurs argument(s) de sortie.A function is a relationship between one or more input argument(s) and one or more output argument(s).

Le contrat d’une fonction définit un certain nombre de contraintes sur cette fonction, en particulier son nommage, le nombre de ses arguments d’entrée, le type de ses arguments d’entrée, le nombre de ses arguments de sortie, le type de ses arguments de sortie.The contract of a function defines a certain number of constraints on this function, in particular its naming, the number of its input arguments, the type of its input arguments, the number of its output arguments, the type of its output arguments.

L’exécution d’une fonction est une tâche, paramétrée par les valeurs des arguments d’entrée, et qui retourne un résultat constitué des valeurs des arguments de sortie.The execution of a function is a task, parameterized by the values of the input arguments, and which returns a result made up of the values of the output arguments.

Lorsqu’un fichier source comporte un appel à une fonction (c’est-à-dire une demande d’exécution d’une fonction), le compilateur vérifie d’abord que cet appel respecte le contrat de la fonction appelée.When a source file contains a call to a function (i.e. a request to execute a function), the compiler first checks that this call respects the contract of the called function.

En cas de vérification négative, le compilateur rejette le code source comme incorrect et affiche une erreur.In the event of a negative check, the compiler rejects the source code as incorrect and displays an error.

En cas de vérification positive, le compilateur génère le code de bas niveau (ou code objet) nécessaire à l’appel à la fonction dans le fichier exécutable, qui résulte de la compilation du fichier source.In case of positive verification, the compiler generates the low-level code (or object code) necessary for the call to the function in the executable file, which results from the compilation of the source file.

Le code objet généré par le compilateur sauvegardera les registres nécessaires aux arguments d’entrée et de sortie de l’appel à la fonction sur une pile associée à l’exécution lors de l’exécution de ce code objet.The object code generated by the compiler will save the registers needed for the input and output arguments of the function call on a runtime associated stack when executing that object code.

Cette vérification du compilateur est possible car la fonction et son contrat sont définis dans le fichier source à compiler, soit dans le fichier source lui-même, soit dans un fichier de librairie fourni pour la compilation (fichier « .c » pour la fonction et fichier « .h » pour son prototype en langage C/C++ par exemple, ou fichier « .rs » en langage RUST par exemple). Dans le présent document, on parle d’une fonction « interne » au sens où le compilateur dispose de toutes les informations nécessaires pour vérifier le bon respect du contrat d’une fonction lors d’un appel à cette fonction.This verification of the compiler is possible because the function and its contract are defined in the source file to be compiled, either in the source file itself, or in a library file provided for compilation (“.c” file for the function and “.h” file for its prototype in C/C++ language for example, or “.rs” file in RUST language for example). In this document, we speak of an “internal” function in the sense that the compiler has all the information necessary to check that the contract of a function is correctly observed when calling this function.

Cependant, une telle vérification n’est pas possible pour ce que l’on peut appeler une fonction « externe », définie comme une fonction pour laquelle le compilateur ne dispose pas de toutes les informations lui permettant de vérifier que l’appel à une fonction respecte le contrat de la fonction appelée.However, such a verification is not possible for what can be called an "external" function, defined as a function for which the compiler does not have all the information enabling it to verify that the call to a function respects the contract of the called function.

Cette situation correspond au cas de premier et second fichiers exécutés en parallèle mais résultant de deux compilations séparées et indépendantes. Si le premier fichier appelle une fonction qui est exécutée par le second fichier et le second fichier retourne un résultat au premier fichier suite à l’exécution de cette fonction, alors le compilateur du premier fichier ne peut pas vérifier que l’appel à cette fonction respecte le contrat de cette fonction. De manière similaire le compilateur du second fichier ne peut pas vérifier que l’appel à cette fonction respecte le contrat de cette fonction.This situation corresponds to the case of first and second files executed in parallel but resulting from two separate and independent compilations. If the first file calls a function that is executed by the second file and the second file returns a result to the first file following the execution of this function, then the compiler of the first file cannot verify that the call to this function respects the contract of this function. Similarly the compiler of the second file cannot verify that the call to this function respects the contract of this function.

Cette situation se rencontre notamment lors des appels à des fonctions où le premier fichier exécutable est adapté pour être exécuté dans un premier mode d’exécution du processeur (tel que le mode « utilisateur »), tout en faisant appel à des fonctions offertes par un second fichier exécutable adapté pour être exécuté dans un second mode d’exécution du processeur, différent du premier mode d’exécution, et présentant souvent plus de privilèges (tel que le mode « superviseur » ou mode « noyau »).This situation is encountered in particular during calls to functions where the first executable file is adapted to be executed in a first mode of execution of the processor (such as the "user" mode), while calling on functions offered by a second executable file adapted to be executed in a second execution mode of the processor, different from the first execution mode, and often having more privileges (such as “supervisor” mode or “kernel” mode).

C’est le cas d’un premier fichier exécutable du type logiciel applicatif, appelant des fonctions dites systèmes offertes par un second fichier exécutable du type système d’exploitation.This is the case of a first executable file of the application software type, calling so-called system functions offered by a second executable file of the operating system type.

Le compilateur utilisé pour générer le fichier exécutable appelant ou appelé n’est donc pas en mesure de détecter une incohérence lors d’un appel à une fonction « externe ». Le compilateur n’est ainsi pas en mesure de garantir la génération d’un code de bas niveau adéquat.The compiler used to generate the calling or called executable file is therefore not able to detect an inconsistency during a call to an “external” function. The compiler is therefore not able to guarantee the generation of adequate low-level code.

Ceci est un inconvénient majeur puisqu’on laisse alors au seul programmeur le soin d’écrire correctement, dans un fichier source, les appels à des fonctions externes, sans possibilité de vérification automatique par le compilateur.This is a major drawback since it is then left to the programmer alone to write correctly, in a source file, the calls to external functions, without the possibility of automatic verification by the compiler.

Par exemple, une mise à jour d’une fonction système occasionnant une modification de son contrat (par exemple un changement du nombre de ses arguments d’entrée) nécessite de revoir manuellement l’intégralité du code source d’un logiciel applicatif afin de vérifier que chaque appel à cette fonction système respecte les contraintes définies par son nouveau contrat.For example, an update of a system function causing a modification of its contract (for example a change in the number of its input arguments) requires manually reviewing the entire source code of an application software in order to verify that each call to this system function respects the constraints defined by its new contract.

Or, l’appel à une fonction système correspond souvent à des instructions critiques pour le fonctionnement du logiciel applicatif et par conséquent pour le fonctionnement de l’ensemble du système mettant en œuvre ce logiciel applicatif.However, the call to a system function often corresponds to critical instructions for the operation of the application software and consequently for the operation of the entire system implementing this application software.

A titre d’exemple, supposons qu’un appel à une fonction système nécessite deux arguments d’entrée de la part d’un fichier appelant. Il est tout à fait possible qu’à la suite d’une erreur de codage, le fichier appelant ne fournisse qu’un seul argument d’entrée. Cette erreur n’est pas détectée à la compilation. La résolution de l’appel de la fonction système par le fichier appelé utilise alors silencieusement une valeur non définie pour le second argument. Ceci reste la plupart du temps sans conséquence, mais peut se révéler dans des situations particulières et avoir des conséquences imprévisibles.As an example, suppose a call to a system function requires two input arguments from a calling file. It is quite possible that due to a coding error, the calling file provides only one input argument. This error is not detected at compile time. Resolving the system function call by the called file then silently uses an undefined value for the second argument. This remains most of the time without consequence, but can appear in particular situations and have unforeseeable consequences.

Ainsi, une mauvaise programmation des fonctions « externes » dans un code source est souvent synonyme de dysfonctionnements graves et/ou de failles de sécurité difficiles à détecter, d’autant plus lorsqu’ils se révèlent tardivement dans le cycle de développement du logiciel.Thus, poor programming of “external” functions in source code is often synonymous with serious malfunctions and/or security flaws that are difficult to detect, especially when they are revealed late in the software development cycle.

On connaît des outils de vérification, tels que la vérification de modèle (« Model Checking » en anglais) ou la vérification formelle, qui permettent de garantir que les contrats des fonctions « externes » sont bien respectés.Verification tools are known, such as Model Checking or formal verification, which make it possible to guarantee that the contracts of the “external” functions are well respected.

Cependant, la contrainte principale de ces outils est que leur mise en œuvre demande l'écriture de nombreuses annotations dans le code source uniquement compréhensible par l’outil de vérification lui-même et non pas par le compilateur.However, the main constraint of these tools is that their implementation requires the writing of many annotations in the source code only understandable by the verification tool itself and not by the compiler.

Ce travail d'annotation du code source est non trivial et constitue une charge de travail significative.This source code annotation work is non-trivial and a significant workload.

De plus, l'utilisation de ces outils est totalement indépendante de la phase de compilation (le logiciel pouvant être générer même s’il ne respecte pas les annotations) et demande une double compétence, à la fois du langage du code source et de la sémantique de l’outils de vérification.Moreover, the use of these tools is completely independent of the compilation phase (the software can be generated even if it does not respect the annotations) and requires a double skill, both in the language of the source code and the semantics of the verification tools.

De plus, la difficulté de mise en œuvre de ces outils croît significativement avec la taille du code à garantir. Ces outils s’accommodent généralement mal avec le besoin de maintenance évolutive d’un code : à chaque modification du code, tout le processus de vérification doit être repris.Moreover, the difficulty of implementing these tools increases significantly with the size of the code to be guaranteed. These tools generally do not fit well with the need for evolutionary maintenance of a code: each time the code is modified, the entire verification process must be repeated.

Il y a donc un besoin de pouvoir vérifier automatiquement le bon emploi d’une fonction « externe » (notamment d’une fonction système) dans un code source.There is therefore a need to be able to automatically check the correct use of an "external" function (in particular a system function) in a source code.

Le but de la présente invention est de répondre à ce besoin.The object of the present invention is to meet this need.

Pour cela l’invention a pour objet, côté appelant, un procédé de génération d’un fichier exécutable appelant, adapté pour être exécuté dans un mode appelant d’un processeur, tout en faisant appel à une fonction « externe » définit dans un fichier exécutable appelé, adapté pour être exécuté dans un mode appelé dudit processeur, le procédé consistant à : fournir une librairie comportant un méta-modèle définissant un prototype pour les appels à des fonctions « externes » et une pluralité de modèles, chaque modèle correspondant à une instanciation du méta-modèle pour une fonction « externe » particulière et implémentant une interface côté appelant définissant une fonction dite « interne » côté appelant et une interface côté appelé définissant une fonction dite « interne » côté appelé ; éditer un fichier source appelant du fichier exécutable appelant, le fichier source appelant comportant un appel à la fonction « interne » côté appelant, l’exécution par l’interface côté appelant de la fonction « interne » côté appelant consistant à appeler la fonction « externe » associée audit modèle et à renvoyer le résultat de l’exécution de ladite fonction « externe » par le code appelé ; compiler le fichier source appelant avec la librairie, le compilateur vérifiant que l’appel de la fonction « interne » côté appelant est conforme au contrat de ladite fonction « interne » côté appelant et la conformité au contrat de la fonction « externe » étant garantie par construction du modèle associé, de sorte que le fichier exécutable appelant obtenu est cohérent.For this, the subject of the invention is, on the calling side, a method for generating a calling executable file, adapted to be executed in a calling mode of a processor, while calling on an "external" function defined in a file called executable, adapted to be executed in a called mode of said processor, the method consisting in: providing a library comprising a meta-model defining a prototype for calls to "external" functions and a plurality of models, each model corresponding to a instantiating the meta-model for a particular "external" function and implementing a calling side interface defining a so-called "internal" function on the calling side and a called side interface defining a so-called "internal" function on the called side; editing a calling source file of the calling executable file, the calling source file comprising a call to the "internal" function on the calling side, the execution by the calling side interface of the "internal" function on the calling side consisting in calling the "external" function associated with said model and returning the result of the execution of said “external” function by the called code; compile the calling source file with the library, the compiler checking that the call to the "internal" function on the calling side complies with the contract of the said "internal" function on the calling side and the conformity to the contract of the "external" function being guaranteed by construction of the associated model, so that the resulting calling executable file is consistent.

L’invention a également pour objet, côté appelé, un procédé de génération d’un fichier exécutable appelé, adapté pour être exécuté dans un mode appelé d’un processeur, le fichier exécutable appelé définissant une fonction « externe » pouvant être appelée par un fichier exécutable appelant, adapté pour être exécuté dans un mode appelant dudit processeur, le procédé consistant à : fournir une librairie comportant un méta-modèle définissant un prototype pour les appels à des fonctions « externes » et une pluralité de modèles, chaque modèle correspondant à une instanciation du méta-modèle pour une fonction « externe » particulière et implémentant une interface côté appelant définissant une fonction dite « interne » côté appelant et une interface côté appelé définissant une fonction dite « interne » côté appelé ; éditer un fichier source appelé du fichier exécutable appelé, le fichier source appelé comportant un appel à la fonction « interne » côté appelé, l’exécution par l’interface côté appelé de la fonction « interne » côté appelé consistant à recevoir l’appel à la fonction « externe » associée audit modèle et à renvoyer le résultat de l’exécution de ladite fonction « externe » par le code appelé ; compiler le fichier source appelé avec la librairie, le compilateur vérifiant que l’appel de la fonction « interne » côté appelé est conforme au contrat de ladite fonction « interne » côté appelé et la conformité au contrat de la fonction système « externe » étant garantie par construction du modèle associé, de sorte que le fichier exécutable appelé obtenu est cohérent.The invention also relates, on the called side, to a method for generating a called executable file, adapted to be executed in a called mode of a processor, the called executable file defining an "external" function that can be called by a calling executable file, adapted to be executed in a calling mode of said processor, the method consisting in: providing a library comprising a meta-model defining a prototype for calls to "external" functions and a plurality of models, each model corresponding to an instantiation of the meta-model for a particular “external” function and implementing a caller-side interface defining a so-called “internal” function on the calling side and a called-side interface defining a so-called “internal” function on the called side; editing a called source file of the called executable file, the called source file comprising a call to the "internal" function on the called side, the execution by the called side interface of the "internal" function on the called side consisting in receiving the call to the “external” function associated with said model and returning the result of the execution of said “external” function by the called code; compile the source file called with the library, the compiler checking that the call to the "internal" function on the called side complies with the contract of said "internal" function on the called side and compliance with the contract of the "external" system function being guaranteed by construction of the associated model, so that the executable file called obtained is consistent.

Suivant des modes particuliers de réalisation, le procédé comporte une ou plusieurs des caractéristiques suivantes, prises isolément ou suivant toutes les combinaisons techniquement possibles :According to particular embodiments, the method comprises one or more of the following characteristics, taken in isolation or according to all the technically possible combinations:

- l’appel à une fonction « interne » côté appelant ou côté appelé conduit l’interface correspondante côté appelant ou côté appelé à construire une instance des arguments d’entrées de la fonction « externe » avant d’appeler la fonction système « externe » sur ladite instance.- the call to an "internal" function on the calling or called side leads the corresponding interface on the calling or called side to construct an instance of the input arguments of the "external" function before calling the "external" system function on said instance.

- l’appel à une fonction « interne » côté appelant ou côté appelé conduit l’interface correspondante côté appelant ou côté appelé à renvoyer des arguments de sortie correspondant à ceux de la fonction « externe ».- the call to an "internal" function on the calling or called side causes the corresponding interface on the calling or called side to return output arguments corresponding to those of the "external" function.

- la fonction « externe » est une fonction système.- the "external" function is a system function.

- le mode appelant est un mode utilisateur du processeur et le mode appelé est un mode superviseur du processeur.- the calling mode is a processor user mode and the called mode is a processor supervisor mode.

- le mode appelant est un mode superviseur du processeur et le mode appelé est un mode hyperviseur du processeur.- the calling mode is a processor supervisor mode and the called mode is a processor hypervisor mode.

- le mode appelant est un mode superviseur ou un mode hyperviseur du processeur et le mode appelé est un mode moniteur du processeur.- the calling mode is a supervisor mode or a hypervisor mode of the processor and the called mode is a monitor mode of the processor.

- le fichier appelant est un logiciel applicatif et le fichier appelé est un système d’exploitation.- the calling file is application software and the called file is an operating system.

- le fichier appelant est un système d’exploitation et le fichier appelé est un hyperviseur.- the calling file is an operating system and the called file is a hypervisor.

- le fichier appelant est un système d’exploitation ou un hyperviseur et le fichier appelé est un moniteur d’environnement d’exécution de confiance.- the calling file is an operating system or a hypervisor and the called file is a trusted execution environment monitor.

- le méta-modèle est défini par un « trait » du langage RUST, chaque modèle par une « structure » du langage RUST, et la fonction « interne » côté appelant ou côté appelé par une « fonction » du langage RUST.- the meta-model is defined by a "feature" of the RUST language, each model by a "structure" of the RUST language, and the "internal" function on the calling or called side by a "function" of the RUST language.

- côté appelé, tous les modèles sont identiques et ne diffèrent donc pas du méta-modèle.- called side, all the models are identical and therefore do not differ from the meta-model.

L’invention a également pour objet un fichier de librairie comportant un méta-modèle définissant un prototype pour les appels à des fonctions « externes » et une pluralité de modèles, chaque modèle correspondant à une instanciation du méta-modèle pour une fonction « externe » particulière et implémentant une interface côté appelant définissant une fonction dite « interne » côté appelant et une interface côté appelé définissant une fonction dite « interne » côté appelé.The invention also relates to a library file comprising a meta-model defining a prototype for calls to "external" functions and a plurality of models, each model corresponding to an instantiation of the meta-model for an "external" function particular and implementing a caller-side interface defining a so-called "internal" function on the calling side and a called-side interface defining a so-called "internal" function on the called side.

L’invention et ses avantages seront mieux compris à la lecture de la description détaillée qui va suivre d’un mode de réalisation particulier, donné uniquement à titre d’exemple non limitatif, cette description étant faite en se référant aux dessins annexés sur lesquels :The invention and its advantages will be better understood on reading the following detailed description of a particular embodiment, given solely by way of non-limiting example, this description being made with reference to the appended drawings in which:

La est une représentation schématique d’une structure possible des codes non-privilégié et privilégié permettant la mise en œuvre du procédé selon l’invention ; et, There is a schematic representation of a possible structure of the non-privileged and privileged codes allowing the implementation of the method according to the invention; And,

La est une représentation schématique sous forme de blocs du procédé . There is a block diagram of the process.

GENERALITESGENERAL

La représente schématiquement un programme dont l’exécution s’étend sur deux modes d’un processeur, soit un premier mode, dit mode non-privilégié – NP, soit un second mode, dit mode privilégié – P.There schematically represents a program whose execution extends over two modes of a processor, either a first mode, called non-privileged mode – NP, or a second mode, called privileged mode – P.

Le procédé selon l’invention s’appuie sur la fourniture d’un premier fichier source, ou fichier non-privilégiée - NP, destiné à être exécuté dans le mode non-privilégié et d’un second fichier source, ou fichier privilégié – P, destiné à être exécuté dans le mode privilégié.The method according to the invention is based on the supply of a first source file, or non-privileged file - NP, intended to be executed in the non-privileged mode and of a second source file, or privileged file - P , intended to be executed in the privileged mode.

Le fichier NP ou fichier appelant comporte un appel à une fonction externe, du fichier P ou fichier appelé.The NP file or calling file includes a call to an external function, from the P file or called file.

Plus précisément, le procédé selon l’invention s’appuie sur un méta-modèle des appels à une fonction externe. Le méta-modèle exprime les aspects communs à tous les appels à des fonctions systèmes.More specifically, the method according to the invention is based on a meta-model of calls to an external function. The meta-model expresses the aspects common to all calls to system functions.

Le procédé selon l’invention s’appuie également sur une pluralité de modèles d’appel à une fonction externe. Chaque modèle de la pluralité de modèles est une instanciation du méta-modèle pour un appel à une fonction externe particulière.The method according to the invention is also based on a plurality of call models to an external function. Each template of the plurality of templates is an instantiation of the meta-template for a call to a particular external function.

Un modèle encapsule l’appel à la fonction système associée et définit une interface d’accès côté NP, ou interface appelant et une interface d’accès côté P, ou interface appelé.A model encapsulates the call to the associated system function and defines an NP-side access interface, or caller interface, and a P-side access interface, or called interface.

Dans le code source, l’appel à une fonction externe se fait alors par l’appel à une fonction interne » de l’interface correspondante du modèle, fonction interne NP de l’interface appelant côté non-privilégié et fonction interne P de l’interface appelé côté privilégié.In the source code, the call to an external function is then made by the call to an internal function" of the corresponding interface of the model, internal function NP of the calling interface on the non-privileged side and internal function P of the interface called privileged side.

Les arguments de l’appel à la fonction interne NP sont des entrées NP et des sortie NP.The arguments of the call to the internal function NP are NP inputs and NP outputs.

Les arguments de l’appel à la fonction interne P sont des entrées P et des sortie P.The arguments of the call to the internal function P are inputs P and outputs P.

Les arguments de l’appel à la fonction externe sont des arguments d’entrée et des arguments de sortie.The arguments of the call to the external function are input arguments and output arguments.

Le méta-modèle et la pluralité de modèles sont prédéfinis. Ils sont avantageusement regroupés dans une librairie à disposition du compilateur du fichier NP et du compilateur du fichier P.The meta-model and the plurality of models are predefined. They are advantageously grouped together in a library available to the compiler of the NP file and the compiler of the P file.

Le mécanisme permettant de générer, lors de la compilation, les appels à des fonctions systèmes côté appelant et côté appelé correspondant à un simple appel à une fonction interne du code à compiler, ces fonctions internes peuvent donc être compilées dans leurs unités de compilation respectives tout en étant garanties comme étant cohérentes puisqu’elles relèvent d’un modèle prédéfini d’appel à une fonction système.The mechanism making it possible to generate, during compilation, the calls to system functions on the calling side and on the called side corresponding to a simple call to an internal function of the code to be compiled, these internal functions can therefore be compiled in their respective compilation units while by being guaranteed as being consistent since they fall under a predefined model of call to a system function.

La structure du code source va être présentée plus en détail dans un mode de réalisation utilisant le langage générique RUST, pour le fichier NP, d’une part, et pour le fichier P, d’autre part.The structure of the source code will be presented in more detail in an embodiment using the generic language RUST, for the NP file, on the one hand, and for the P file, on the other hand.

Structure des codes sourceSource code structure

FICHIER NPNP-FILE

On définit tout d’abord un méta-modèle constituant un prototype pour l’ensemble des appels possibles à des fonctions systèmes.We first define a meta-model constituting a prototype for all possible calls to system functions.

En RUST, le méta-modèle est défini au moyen d’un « trait ». Un « trait » est une collection de méthodes définies pour un type de données quelconque, « Self ». Ces méthodes peuvent accéder à d'autres méthodes déclarées dans le même trait. Un trait peut ensuite être implémenté pour n'importe quel type de données.In RUST, the meta-model is defined by means of a “trait”. A "trait" is a collection of methods defined for any data type, "Self". These methods can access other methods declared in the same trait. A trait can then be implemented for any data type.

Côté NP, le méta-modèle est défini par un trait dénommé « SysCall ». Par exemple, le trait « SysCall » est défini de la manière suivante :On the NP side, the meta-model is defined by a trait called “SysCall”. For example, the "SysCall" trait is defined as follows:


// Trait utilisé pour définir le prototype des appels systèmes.
pub traitSysCall{
// le type retourné par l'appel système.
typeOut;

// l'identifiant de l'appel système.
constNBR: u16 ;

// prototype du code de bas niveau de l'appel système.
fncall( self ) ->Self::Out ;
}

// Trait used to define the system call prototype.
pub trait SysCall {
// the type returned by the system call.
type Out ;

// the system call identifier.
const NBR : u16 ;

// prototype of the low-level system call code.
fn call ( self ) -> Self :: Out;
}

On définit ensuite un modèle pour un appel à une fonction système particulière. Par exemple, on définit un modèle pour un appel à une fonction système d’impression, c’est-à-dire la transmission d’un message à un pilote d’un périphérique d’impression sur un écran ou une imprimante.We then define a template for a call to a particular system function. For example, we define a model for a call to a printing system function, i.e. the transmission of a message to a driver of a printing device on a screen or a printer.

En RUST, un modèle est défini au moyen d’une structure « struct ». Il s’agit ici d’un type particulier de données prenant la forme d’un multiplet de variables.In RUST, a model is defined by means of a “struct” structure. This is a particular type of data taking the form of a multiplet of variables.

Le modèle d’un appel à la fonction système d’impression peut alors être défini par la structure « SysPrint » suivante :The model of a call to the print system function can then be defined by the following “SysPrint” structure:


// Définition de la structure SysPrint qui contient les arguments d'entrée de l'appel système.
structSysPrint{
pubmsg: * const u8 ;// Le pointeur vers le message texte à afficher.
publen: usize ;// La longueur du message.
}

// Definition of the SysPrint structure which contains the input arguments of the system call.
struct SysPrint {
pub msg : * const u8 ; // The pointer to the text message to display.
pub len : use size ; // The message length.
}

Ici, la structure « SysPrint » est définie par deux variables, respectivement le massage « msg » à imprimer (ou plutôt le pointeur vers le message à imprimer) et la longueur « len » de ce message.Here, the "SysPrint" structure is defined by two variables, respectively the message "msg" to print (or rather the pointer to the message to print) and the length "len" of this message.

Ces deux variables sont en fait les arguments d’entrées de la fonction système d’impression.These two variables are in fact the input arguments of the print system function.

Le modèle d’un appel à la fonction système d’impression reçoit ensuite par exemple l’implémentation suivante :The model of a call to the print system function then receives for example the following implementation:


implSysPrint{
// Constructeur de la structure SysPrint à partir d'une chaine de caractères.
pub fnnew(s: & str ) ->Self{
Self{msg:s.as_ptr(),len:s.bytes().len() }
}
}

impl SysPrint {
// Constructor of the SysPrint structure from a character string.
pub fn new ( s : & str ) -> Self {
Self { msg : s . as_ptr (), len : s . bytes (). len () }
}
}

La méthode « new » permet de créer une nouvelle instance du type de données « SysPrint » à partir de la variable « s », qui est du type « chaîne de caractères ».The “new” method creates a new instance of the “SysPrint” data type from the “s” variable, which is of the “character string” type.

On définit également la manière dont se comporte le modèle lorsqu’il est considéré sous l’angle du méta-modèle.We also define how the model behaves when considered from the perspective of the meta-model.

En RUST, cela revient à implémenter le trait « SysCall » pour la structure de données « SysPrint ».In RUST, this amounts to implementing the "SysCall" feature for the "SysPrint" data structure.

Côté NP, cette implémentation est par exemple définie de la manière suivante :On the NP side, this implementation is for example defined as follows:


// Implémentation du trait SysCall pour la structure SysPrint.
implSysCallforSysPrint{
typeOut: ();//Aucun paramètre de retour

constNBR: u16 =255;//identifiant de la fonction système appelée


fncall( self ) ->Self::Out{
// Code de bas niveau permettant d'effectuer l'appel système. XXX
}
}

// Implement SysCall trait for SysPrint structure.
impl SysCall for SysPrint {
type Out : (); //No return parameter

const NBR : u16 = 255 ; // identifier of the system function called


fn call ( self ) -> Self :: Out {
// Low level code to perform the system call. XXX
}
}

Est ici crée une interface côté NP à travers laquelle accéder à l’appel à la fonction système associée au modèle.Is here creates an NP-side interface through which to access the call to the system function associated with the model.

Est ainsi définie la sortie NP lorsque l’interface NP est appelée. Dans l’exemple ci-dessus, l’interface NP définit par la structure « SysPrint » associée à la fonction système d’impression renvoie une sortie NP « Out » vide.This defines the NP output when the NP interface is called. In the example above, the NP interface defined by the "SysPrint" structure associated with the print system function returns an empty NP "Out" output.

L’identifiant de la fonction système associée au modèle est instancié. Dans l’exemple ci-dessus, la fonction système d’impression que la structure « SysPrint » appelle est identifiée par la valeur 255.The identifier of the system function associated with the model is instantiated. In the example above, the print system function that the "SysPrint" structure calls is identified by the value 255.

Est ici instancié le code fonctionnel du mode NP permettant de réaliser effectivement l’appel à la fonction système associée au modèle. Dans l’exemple ci-dessus, ce code fonctionnel n’est pas détaillé et on l’a indiqué par « XXX ».Here is instantiated the functional code of the NP mode making it possible to effectively call the system function associated with the model. In the example above, this functional code is not detailed and has been indicated by "XXX".

L’interface NP lance l’appel à la fonction système associée au travers de l’utilisation de la méthode « call » de la structure « SysPrint ».The NP interface launches the call to the associated system function through the use of the “call” method of the “SysPrint” structure.

Enfin, on définit un appel à l’interface NP pour initier l’appel à la fonction système associée.Finally, we define a call to the NP interface to initiate the call to the associated system function.

En RUST, l’appel à la fonction système d’impression côté NP passe par l’appel à une fonction « interne » « sys_print » recevant par exemple l’implémentation suivante :In RUST, the call to the printing system function on the NP side goes through the call to an “internal” function “sys_print” receiving for example the following implementation:


// Implémentation de l'appel système pour le code utilisateur.
pub fnsys_print(s: & str ) -> <SysPrintasSysCall>::Out{
SysPrint::new(s).call()
}

// Implement system call for user code.
pub fn sys_print ( s : & str ) -> < SysPrint as SysCall >:: Out {
SysPrint :: new ( s ). call ()
}

Cette fonction « interne » porte sur un argument d’entrée « s » du type chaîne de caractères. On la dénomme entrée NP.This "internal" function relates to an input argument "s" of the character string type. It is called NP input.

L’exécution de cette fonction « interne » conduit à l’application de la fonction « new » de la structure « SysPrint » sur l’argument d’entrée « s » pour obtenir une nouvelle instance de la structure « SysPrint », puis à l’application de la fonction « call » sur cette nouvelle instance de la structure « SysPrint ».The execution of this "internal" function leads to the application of the "new" function of the "SysPrint" structure on the input argument "s" to obtain a new instance of the "SysPrint" structure, then to the application of the “call” function on this new instance of the “SysPrint” structure.

Lors de l’appel à cette fonction « interne », il y a donc création automatique d’une instance de la structure « SysPrint ». On est donc certain que les arguments d’entrée de l’appel à la fonction système seront conformes au contrat de cette fonction système.When calling this "internal" function, an instance of the "SysPrint" structure is therefore automatically created. We are therefore certain that the input arguments of the call to the system function will comply with the contract of this system function.

L’appel à cette fonction « interne , retourne, en tant que sortie NP, l’argument de sortie « Out » du trait « SysCall » tel qu’implémenté pour la structure « SysPrint ». Lorsque cette fonction « interne » est appelée, son résultat est par construction une sortie conforme au contrat de la fonction système associée au modèle. Lors de la compilation du code source côté NP, le compilateur vérifie que le contrat de la fonction « sys_print » est respecté. Cependant ce contrat est minimal puisqu’il consiste à vérifier la dénomination de la fonction (« sys_print »), qu’il y a un argument d’entrée du type chaîne de caractères, et qu’il y a un argument de sortie du type correspondant à la sortie prévue pour le modèle.The call to this "internal" function returns, as NP output, the "Out" output argument of the "SysCall" trait as implemented for the "SysPrint" structure. When this "internal" function is called, its result is by construction an output conforming to the contract of the system function associated with the model. When compiling the source code on the NP side, the compiler checks that the contract of the “sys_print” function is respected. However, this contract is minimal since it consists in checking the name of the function (“sys_print”), that there is an input argument of the character string type, and that there is an output argument of the type corresponding to the planned output for the model.

Ainsi, la vérification par le compilateur du contrat de la fonction « interne » conduit toujours à une vérification positive, tout en étant certain que l’appel à la fonction système s’effectue conformément au contrat de la fonction système, grâce à l’implémentation correcte du modèle.Thus, the verification by the compiler of the contract of the "internal" function always leads to a positive verification, while being certain that the call to the system function is carried out in accordance with the contract of the system function, thanks to the implementation correct of the model.

Ainsi le modèle apparaît comme un objet formant interface, masquant l’appel à la fonction « externe ». Dans le code source, l’appel à la fonction « externe » passe donc maintenant par l’interrogation de l’interface NP, cette interrogation prenant la forme d’une fonction « interne » au code source NP. L’interface NP répond à cette interrogation en réalisant l’appel à la fonction « externe». Cette interface NP étant programmée une fois pour toute, tout appel à la fonction « externe » sera effectué sans erreur.Thus the model appears as an object forming an interface, masking the call to the “external” function. In the source code, the call to the “external” function therefore now involves querying the NP interface, this query taking the form of an “internal” function in the NP source code. The NP interface responds to this query by making the call to the "external" function. This NP interface being programmed once and for all, any call to the "external" function will be made without error.

FICHIER PP-FILE

Le trait « SysCall » et la structure « SysPrint », décrits ci-dessus, sont partagés entre codes appelant et appelé.The "SysCall" feature and the "SysPrint" structure, described above, are shared between calling and called codes.

Côté P, le méta-modèle est en outre défini par un trait. Ce trait est dénommé « Context ». Par exemple, le trait « Context » est définit de la manière suivante :On the P side, the meta-model is further defined by a trait. This feature is called “Context”. For example, the "Context" trait is defined as follows:


//Trait utilisé pour traiter de façon générique un appel système reçu par le code privilégié
pub traitContext{
fnsyscall_in<T:SysCall>(& self ) -> &T;

fnsyscall_out<T:SysCall>( & mut self ,res: &T::Out);

fnsyscall<T:SysCall,F>(& mut self ,f:F)
where
F:FnOnce(&T) ->T::Out
{
letinput= self .syscall_in::<T>();
letoutput=f(input);
self .syscall_out::<T>( &output);
}
}

//Trait used to generically process a system call received by the privileged code
pub feature Context {
fn syscall_in < T : SysCall >(& self ) -> & T ;

fn syscall_out < T : SysCall >( & mut self , res : & T :: Out );

fn syscall < T : SysCall , F >(& mut self , f : F )
where
F : FnOnce (& T ) -> T :: Out
{
let input = self . syscall_in ::<T> ();
let output = f ( input );
self . syscall_out ::<T> ( & output );
}
}

Ici, les méthodes rentrant dans la définition du trait « Context » sont génériques. Elles sont définies pour toute structure de données « T » implémentant le trait « SysCall ».Here, the methods falling within the definition of the "Context" trait are generic. They are defined for any "T" data structure implementing the "SysCall" feature.

La méthode « syscall » permet de récupérer les informations relatives à l’appel à la fonction système dans la pile d’exécution du fichier NP (identifiant de la fonction appelée et arguments d’entrées) et de déposer les informations relatives au résultat de l’appel à la fonction système dans la pile d’exécution du fichier NP (arguments de sortie).The "syscall" method is used to retrieve information relating to the call to the system function in the execution stack of the NP file (call function identifier and input arguments) and to deposit information relating to the result of the call. 'call to the system function in the execution stack of the file NP (output arguments).

Côté P, un modèle, comme le modèle de l’appel à la fonction système d’impression, ne reçoit pas de définition particulière, car tous les modèles côté P se comportent d’une même manière, définie par le trait « Context ». En effet, il s’agit simplement après avoir récupérer les informations relatives à l’appel à la fonction système, de lancer l’exécution de la fonction système appelée, puis de renvoyer la sortie de la fonction système une fois exécuté. C’est donc le trait « Context » qui définit l’interface côté P.On the P side, a pattern, such as the print system function call pattern, does not receive a particular definition, because all P-side patterns behave in the same way, defined by the "Context" trait. Indeed, it is simply a matter of having retrieved the information relating to the call to the system function, to launch the execution of the called system function, then to return the output of the system function once executed. It is therefore the "Context" trait that defines the interface on the P side.

En RUST, côté P, l’appel à l’interface P s’effectue par une fonction « sys_print », recevant par exemple l’implémentation suivante :In RUST, on the P side, the call to the P interface is made by a “sys_print” function, receiving for example the following implementation:


// Implémentation de l'appel système pour le code privilégié.
fnsys_print<CTX:Context>(ctx: & mutCTX) {
ctx.syscall<T:SysPrint>(
XXX// Code privilégié traitant l'appel système et qui doit // respecter le contrat définie par le trait SysCall.
);
}

// System call implementation for privileged code.
fn sys_print < CTX : Context >( ctx : & mut CTX ) {
ctx . syscall < T : SysPrint >(
XXX// Privileged code processing the system call and which must // respect the contract defined by the SysCall trait.
);
}

Est ici instancié le code fonctionnel du mode P permettant de réaliser effectivement la fonction système associée au modèle. Dans l’exemple ci-dessus, ce code fonctionnel, totalement dépendant de l'implémentation, n’est pas détaillé et on l’a indiqué par « XXX »Here is instantiated the functional code of mode P making it possible to effectively perform the system function associated with the model. In the example above, this functional code, totally implementation dependent, is not detailed and has been indicated by "XXX".

La fonction « sys_print » est une fonction « interne » permettant d’interroger l’interface P et de lancer l’exécution de la fonction système au travers de l’utilisation de la méthode « syscall » d’une instance « ctx » du trait « Context », la méthode « syscall » générique étant ici spécifique à une structure de données « T » respectant le modèle « SysPrint ».The "sys_print" function is an "internal" function allowing to query the P interface and to launch the execution of the system function through the use of the "syscall" method of a "ctx" instance of the trait “Context”, the generic “syscall” method here being specific to a “T” data structure respecting the “SysPrint” model.

Lors de la compilation du code source côté P, le compilateur vérifie que le contrat de la fonction « sys_print » est respecté, c’est-à-dire le contrat défini par le trait « SysCall »When compiling the source code on the P side, the compiler checks that the contract of the “sys_print” function is respected, i.e. the contract defined by the “SysCall” trait

Ainsi, la vérification par le compilateur du contrat de la fonction « interne » conduit toujours à une vérification positive, tout en étant certain que l’appel à la fonction système reçu est conforme au contrat de la fonction système, grâce à l’implémentation correcte du modèle.Thus, the verification by the compiler of the contract of the "internal" function always leads to a positive verification, while being certain that the call to the system function received conforms to the contract of the system function, thanks to the correct implementation of the model.

PROCEDEPROCESS

La représente un mode de réalisation du procédé 200 de génération d’un fichier exécutable selon l’invention.There represents an embodiment of the method 200 for generating an executable file according to the invention.

Dans une étape 210, est fournie une librairie comportant le méta-modèle définissant un prototype pour les appels à des fonctions « externes » et une pluralité de modèles, chaque modèle correspondant à une instanciation du méta-modèle pour une fonction « externe » particulière. Chaque modèle définit une interface NP, respectivement une interface P, pouvant être interrogée par une fonction dite « interne » NP, respectivement une fonction dite « interne » P.In a step 210, a library is provided comprising the meta-model defining a prototype for calls to “external” functions and a plurality of models, each model corresponding to an instantiation of the meta-model for a particular “external” function. Each model defines an NP interface, respectively a P interface, which can be interrogated by a so-called “internal” function NP, respectively a so-called “internal” function P.

L’étape 220 suivante consiste à éditer un fichier source côté NP (respectivement P), comportant un appel à la fonction « interne » NP (respectivement P), l’exécution par l’interface NP (respectivement P), de la fonction « interne » NP (respectivement P) consistant à appeler la fonction « externe » associée audit modèle et à renvoyer le résultat de l’exécution de ladite fonction « externe ».The next step 220 consists in editing a source file on the NP (respectively P) side, comprising a call to the "internal" function NP (respectively P), the execution by the interface NP (respectively P), of the function " internal” NP (respectively P) consisting of calling the “external” function associated with said model and returning the result of the execution of said “external” function.

Une fois le code source édité, il est compilé (étape 230) avec la librairie fournie à l’étape 210. Le compilateur vérifie que l’appel de la fonction « interne » NP (respectivement P) est conforme au contrat de la fonction « interne » non-privilégié NP (respectivement P). La conformité au contrat de la fonction système « externe » étant garantie par construction du modèle associé à cette fonction « externe », de sorte que le fichier exécutable NP (respectivement P) obtenu est cohérent.Once the source code has been edited, it is compiled (step 230) with the library provided at step 210. The compiler checks that the call to the “internal” function NP (respectively P) complies with the contract of the function “ internal” non-privileged NP (respectively P). Conformity to the contract of the “external” system function being guaranteed by construction of the model associated with this “external” function, so that the executable file NP (respectively P) obtained is consistent.

VARIANTES et GENERALISATIONVARIANTS and GENERALIZATION

Un processeur possède différents modes d’exécution. Chaque mode a des privilèges ou droits (accès aux registres, instructions, etc.).A processor has different execution modes. Each mode has privileges or rights (access to registers, instructions, etc.).

Le mode de réalisation présenté ci-dessus a été présenté pour le cas de deux modes : un mode utilisateur pour les applications et un mode superviseur pour le système d’exploitation. D’où l’appellation de mode « non-privilégié » pour le mode utilisateur et de mode « privilégié » pour le mode superviseur.The embodiment presented above was presented for the case of two modes: a user mode for the applications and a supervisor mode for the operating system. Hence the term “non-privileged” mode for user mode and “privileged” mode for supervisor mode.

Cependant, dans les architectures actuelles, le nombre de modes d’un processeur est souvent supérieur à deux. Par exemple, un processeur peut présenter un mode utilisateur, un mode superviseur, un mode hyperviseur et un mode moniteur.However, in current architectures, the number of modes of a processor is often more than two. For example, a processor may have user mode, supervisor mode, hypervisor mode, and monitor mode.

De plus, il peut exister une hiérarchie entre les modes. Par exemple, les privilèges et les droits de l’hyperviseur incluent ceux du superviseur, qui eux-mêmes incluent ceux de l’utilisateur. Mais ceci n’est pas obligatoire et l’on peut rencontrer le cas de deux modes d’exécution de privilèges et droits disjoints, qui ne s’incluent pas.In addition, there may be a hierarchy between the modes. For example, the privileges and rights of the hypervisor include those of the supervisor, which themselves include those of the user. But this is not obligatory and one can encounter the case of two modes of execution of disjoint privileges and rights, which do not include each other.

Ainsi, la présente invention s’applique plus largement à tout code appelant exécuté dans un premier mode (ou mode appelant) et un code appelé exécuté dans un second mode (mode appelé).Thus, the present invention applies more broadly to any calling code executed in a first mode (or calling mode) and a called code executed in a second mode (called mode).

En effet, selon l’invention, le code appelant peut s’exécuter dans un mode autre que le mode utilisateur (ou « non-privilégié ») et le code appelé peut s’exécuter dans un mode autre que le mode superviseur (ou « non-privilégié »).Indeed, according to the invention, the calling code can be executed in a mode other than the user mode (or “non-privileged”) and the called code can be executed in a mode other than the supervisor mode (or “ non-privileged”).

L’invention s’applique à des codes appelant et appelé compilés séparément et s’exécutant dans des modes d’exécution différents. Mais l’invention s’applique également à des codes appelant et appelé pouvant s’exécuter dans un même mode d’exécution du processeur mais résultant de deux compilation séparées. C’est par exemple le cas d’un pilote (« driver » en anglais) compilé séparément et s’exécutant en mode superviseur qui appelle d’autres fonctions systèmes s’exécutant également en mode superviseur.The invention applies to calling and called codes compiled separately and executing in different execution modes. But the invention also applies to calling and called codes that can be executed in the same execution mode of the processor but resulting from two separate compilations. This is for example the case of a driver compiled separately and running in supervisor mode which calls other system functions also running in supervisor mode.

Ainsi, le mode appelant peut être un mode utilisateur du processeur et le mode appelé, un mode superviseur du processeur ; ou le mode appelant peut être un mode superviseur du processeur et le mode appelé, un mode hyperviseur du processeur ; ou encore le mode appelant peut être un mode superviseur ou un mode hyperviseur du processeur et le mode appelé, un mode moniteur du processeur.Thus, the calling mode can be a user mode of the processor and the called mode, a supervisor mode of the processor; or the calling mode can be a supervisor mode of the processor and the called mode, a hypervisor mode of the processor; or else the calling mode can be a supervisor mode or a hypervisor mode of the processor and the called mode, a monitor mode of the processor.

Ainsi, le fichier appelant peut-être un logiciel applicatif et le fichier appelé, un système d’exploitation ; ou le fichier appelant peut être un système d’exploitation et le fichier appelé un hyperviseur ; ou encore, le fichier appelant peut être un système d’exploitation ou un hyperviseur et le fichier appelé, un moniteur d’environnement d’exécution de confiance (« Trusted Execution Environment »).Thus, the calling file may be an application software and the called file, an operating system; or the calling file can be an operating system and the called file a hypervisor; or the calling file can be an operating system or a hypervisor and the called file a Trusted Execution Environment monitor.

Si dans le mode de réalisation décrit en détail ci-dessus, on a parlé de fichier en tant que synonyme de code. En toute rigueur, un unique code peut-être écrit dans plusieurs fichiers.If in the embodiment described in detail above, we spoke of file as a synonym of code. Strictly speaking, a single code can be written in several files.

Si dans le mode de réalisation décrit en détail ci-dessus, on a pris l’exemple d’une fonction système d’impression, l’invention s’applique à toute fonction système et, plus largement, à toute fonction externe.If in the embodiment described in detail above, the example of a printing system function was taken, the invention applies to any system function and, more broadly, to any external function.

AVANTAGESBENEFITS

La présente invention évite la rupture de la chaîne de vérification du typage des fonctions côtés appelant et appelé en apportant des moyens de vérification de cohérence appelant/appelé, à la compilation, sans surcoût à l’exécution.The present invention avoids breaking the chain of verification of the typing of functions on the calling and called sides by providing means for verifying caller/called consistency, at compile time, without additional cost at runtime.

L’invention se fonde sur la traduction des contraintes sur les appels à des fonctions « externes » en des contraintes sur des appels à des fonctions « internes » qui sont vérifiables par le compilateur. Les appels de fonction externe entre l’appelant et l’appelé sont ainsi mis en œuvre à l’image d’une fonction standard.The invention is based on the translation of constraints on calls to “external” functions into constraints on calls to “internal” functions which are verifiable by the compiler. External function calls between caller and callee are thus implemented as a standard function.

La vérification de ces contraintes de construction par le compilateur garantissent la cohérence des appels de fonctions externes du côté de l’appelant et de l’appelé, à l’image d’un appel de fonction au sein de la même unité de compilation.Checking these construction constraints by the compiler guarantees the consistency of external function calls on the caller and callee side, such as a function call within the same compilation unit.

Le processus de compilation est donc en mesure de rejeter du code mal formé qui pourrait entrainer des comportements erratiques futurs et des failles de sécurité dormantes.The compilation process is therefore able to reject malformed code that could lead to future erratic behavior and dormant security flaws.

Avec la présente invention, un programmeur spécifie un méta-modèle (une interface générique) pour tous les appels de fonctions externes pour qu’ils respectent un même format. Cette interface générique est ensuite traduite en prototype pour chaque appel de fonction externe possible.With the present invention, a programmer specifies a meta-model (a generic interface) for all external function calls so that they follow the same format. This generic interface is then translated into a prototype for each possible external function call.

C’est bien le méta-modèle, qui constitue l’unité de compilation commune, qui formalise le contrat des appels de fonctions externes. Cette unité est utilisée pour la compilation du code appelant d’une part et celle du code appelé d’autre part.It is indeed the meta-model, which constitutes the common compilation unit, which formalizes the contract for calling external functions. This unit is used for the compilation of the calling code on the one hand and that of the called code on the other hand.

Pour la mise en œuvre particulière en langage RUST, la notion de trait permet de déclarer des interfaces génériques que le code peut ensuite utiliser et dont les contraintes sont vérifiées par le compilateur. Mais ces traits ne peuvent s’appliquer que sur des structures de données et non sur des fonctions. Cette limitation est contournée en convertissant les paramètres de l’appel à une fonction externe en deux structures de données liées (une pour les paramètres d’entrées fournis par l’appelant et une pour les paramètres de sorties fournis par l’appelé).For the particular implementation in RUST language, the notion of trait makes it possible to declare generic interfaces that the code can then use and whose constraints are checked by the compiler. But these traits can only be applied to data structures and not to functions. This limitation is circumvented by converting the parameters of the call to an external function into two linked data structures (one for caller-supplied input parameters and one for callee-supplied output parameters).

Si le langage RUST a été utilisé dans la présentation du mode de réalisation préféré, l’invention peut être mise en œuvre dans tout langage de programmation générique.If the RUST language was used in the presentation of the preferred embodiment, the invention can be implemented in any generic programming language.

La mise en œuvre de l’invention n’a aucun impact sur les performances de la compilation. Il est important de noter que ces vérifications n’ont aucun surcoût lors de la mise en œuvre par un système embarquant les logiciels ainsi compilés, puisque tout est réalisé en amont, lors de la conception et la compilation des logiciels.The implementation of the invention has no impact on the performance of the compilation. It is important to note that these verifications have no additional cost during the implementation by a system embedding the software thus compiled, since everything is done upstream, during the design and compilation of the software.

En revanche, la vérification automatique que permet l’invention arrive au plus tôt dans le cycle de développement. La détection d’une incohérence devient possible dès la phase de compilation.On the other hand, the automatic verification that the invention allows occurs at the earliest in the development cycle. The detection of an inconsistency becomes possible from the compilation phase.

L’invention permet donc à un programmeur de logiciel de mettre en œuvre les spécifications des appels de fonctions externes de manière à pouvoir en faire l’appel et la résolution de manière sûre, automatique, dès la compilation et sans surcoût à l’exécution.The invention therefore allows a software programmer to implement the specifications of calls to external functions so as to be able to call and resolve them in a safe, automatic manner, from compilation and without additional cost at runtime.

Les applications de la présente invention concernent tout développement logiciel comportant des codes compilés séparément. Le plus couramment, un code exécuté dans un mode peu privilégié (comme le mode « utilisateur »), pour des raisons de sûreté et sécurité, souhaite faire appel à une fonctionnalité dont la mise en œuvre est faite à un plus haut niveau de privilège (comme le mode « noyau » ). Cela peut donc s’étendre à tout domaine industriel (aéronautique, automobile, militaire) faisant appel à des développements nécessitant de conserver la maîtrise sur toutes les couches logicielles, de la couche applicative jusqu’à celle exploitant le matériel.The applications of the present invention relate to any software development comprising separately compiled codes. Most commonly, a code executed in a less privileged mode (such as the "user" mode), for safety and security reasons, wishes to call upon a functionality whose implementation is made at a higher level of privilege ( like "kernel" mode). This can therefore extend to any industrial field (aeronautics, automotive, military) involving developments that require maintaining control over all software layers, from the application layer to that using the hardware.

Il est à noter que le côté non-privilégié peut-être compilé de manière indépendante du côté privilégié. Notamment, alors que le fichier exécutable du logiciel d’exploitation reste inchangé, on réalise des mises à jour du fichier exécutable du logiciel applicatif, au cours par exemple de son développement. L’inverse est également vrai.Note that the non-privileged side can be compiled independently of the privileged side. In particular, while the executable file of the operating software remains unchanged, updates are made to the executable file of the application software, for example during its development. The reverse is also true.

Claims (14)

Procédé de génération d’un fichier exécutable appelant, adapté pour être exécuté dans un mode appelant d’un processeur, tout en faisant appel à une fonction « externe » définit dans un fichier exécutable appelé, adapté pour être exécuté dans un mode appelé dudit processeur, le procédé consistant à :
- fournir (210) une librairie comportant un méta-modèle définissant un prototype pour les appels à des fonctions « externes » et une pluralité de modèles, chaque modèle correspondant à une instanciation du méta-modèle pour une fonction « externe » particulière et implémentant une interface côté appelant définissant une fonction dite « interne » côté appelant et une interface côté appelé définissant une fonction dite « interne » côté appelé ;
- éditer (220) un fichier source appelant du fichier exécutable appelant, le fichier source appelant comportant un appel à la fonction « interne » côté appelant, l’exécution par l’interface côté appelant de la fonction « interne » côté appelant consistant à appeler la fonction « externe » associée audit modèle et à renvoyer le résultat de l’exécution de ladite fonction « externe » par le code appelé ;
- compiler (230) le fichier source appelant avec la librairie, le compilateur vérifiant que l’appel de la fonction « interne » côté appelant est conforme au contrat de ladite fonction « interne » côté appelant et la conformité au contrat de la fonction « externe » étant garantie par construction du modèle associé, de sorte que le fichier exécutable appelant obtenu est cohérent.
Method for generating a calling executable file, adapted to be executed in a calling mode of a processor, while calling on an "external" function defined in a called executable file, adapted to be executed in a called mode of said processor , the process comprising:
- providing (210) a library comprising a meta-model defining a prototype for calls to "external" functions and a plurality of models, each model corresponding to an instantiation of the meta-model for a particular "external" function and implementing a calling side interface defining a so-called “internal” function on the calling side and a called side interface defining a so-called “internal” function on the called side;
- editing (220) a calling source file of the calling executable file, the calling source file comprising a call to the "internal" function on the calling side, the execution by the calling side interface of the "internal" function on the calling side consisting in calling the “external” function associated with said model and returning the result of the execution of said “external” function by the called code;
- compiling (230) the calling source file with the library, the compiler checking that the call to the "internal" function on the calling side complies with the contract of said "internal" function on the calling side and the conformity with the contract of the "external" function » being guaranteed by construction of the associated model, so that the calling executable file obtained is consistent.
Procédé de génération d’un fichier exécutable appelé, adapté pour être exécuté dans un mode appelé d’un processeur, le fichier exécutable appelé définissant une fonction « externe » pouvant être appelée par un fichier exécutable appelant, adapté pour être exécuté dans un mode appelant dudit processeur, le procédé consistant à :
- fournir (210) une librairie comportant un méta-modèle définissant un prototype pour les appels à des fonctions « externes » et une pluralité de modèles, chaque modèle correspondant à une instanciation du méta-modèle pour une fonction « externe » particulière et implémentant une interface côté appelant définissant une fonction dite « interne » côté appelant et une interface côté appelé définissant une fonction dite « interne » côté appelé ;
- éditer (220) un fichier source appelé du fichier exécutable appelé, le fichier source appelé comportant un appel à la fonction « interne » côté appelé, l’exécution par l’interface côté appelé de la fonction « interne » côté appelé consistant à recevoir l’appel à la fonction « externe » associée audit modèle et à renvoyer le résultat de l’exécution de ladite fonction « externe » par le code appelé ;
- compiler (230) le fichier source appelé avec la librairie, le compilateur vérifiant que l’appel de la fonction « interne » côté appelé est conforme au contrat de ladite fonction « interne » côté appelé et la conformité au contrat de la fonction système « externe » étant garantie par construction du modèle associé, de sorte que le fichier exécutable appelé obtenu est cohérent.
A method of generating a called executable file adapted to be executed in a called mode of a processor, the called executable file defining an "external" function callable by a calling executable file adapted to be executed in a calling mode of said processor, the method comprising:
- providing (210) a library comprising a meta-model defining a prototype for calls to "external" functions and a plurality of models, each model corresponding to an instantiation of the meta-model for a particular "external" function and implementing a calling side interface defining a so-called “internal” function on the calling side and a called side interface defining a so-called “internal” function on the called side;
- editing (220) a called source file of the called executable file, the called source file comprising a call to the "internal" function on the called side, the execution by the called side interface of the "internal" function on the called side consisting in receiving calling the “external” function associated with said model and returning the result of the execution of said “external” function by the called code;
- compiling (230) the source file called with the library, the compiler checking that the call to the "internal" function on the called side complies with the contract of the said "internal" function on the called side and the conformity with the contract of the system function " external” being guaranteed by construction of the associated model, so that the executable file called obtained is consistent.
Procédé selon l’une quelconque des revendications précédentes, dans lequel l’appel à une fonction « interne » côté appelant ou côté appelé conduit l’interface correspondante côté appelant ou côté appelé à construire une instance des arguments d’entrées de la fonction « externe » avant d’appeler la fonction système « externe » sur ladite instance.A method according to any preceding claim, wherein the call to an "inner" function on the calling or called side causes the corresponding interface on the calling or called side to construct an instance of the input arguments of the "outer" function. before calling the "external" system function on said instance. Procédé selon l’une quelconque des revendications précédentes, dans lequel l’appel à une fonction « interne » côté appelant ou côté appelé conduit l’interface correspondante côté appelant ou côté appelé à renvoyer des arguments de sortie correspondant à ceux de la fonction « externe ».A method according to any preceding claim, wherein the call to an "inner" function on the calling or called side causes the corresponding interface on the calling or called side to return output arguments corresponding to those of the "outer" function. ". Procédé selon l’une quelconque des revendications précédentes, dans lequel la fonction « externe » est une fonction système.A method according to any preceding claim, wherein the "external" function is a system function. Procédé selon l’une quelconque des revendications 1 à 5, dans lequel le mode appelant est un mode utilisateur du processeur et le mode appelé est un mode superviseur du processeur.A method according to any one of claims 1 to 5, wherein the calling mode is a user mode of the processor and the called mode is a supervisor mode of the processor. Procédé selon l’une quelconque des revendications 1 à 5, dans lequel le mode appelant est un mode superviseur du processeur et le mode appelé est un mode hyperviseur du processeur.Method according to any one of claims 1 to 5, in which the calling mode is a supervisor mode of the processor and the called mode is a hypervisor mode of the processor. Procédé selon l’une quelconque des revendications 1 à 5, dans lequel le mode appelant est un mode superviseur ou un mode hyperviseur du processeur et le mode appelé est un mode moniteur du processeur.Method according to any one of claims 1 to 5, in which the calling mode is a supervisor mode or a hypervisor mode of the processor and the called mode is a monitor mode of the processor. Procédé selon l’une quelconque des revendications 1 à 8, dans lequel le fichier appelant est un logiciel applicatif et le fichier appelé est un système d’exploitation.A method according to any of claims 1 to 8, wherein the calling file is application software and the called file is an operating system. Procédé selon l’une quelconque des revendications 1 à 8, dans lequel le fichier appelant est un système d’exploitation et le fichier appelé est un hyperviseur.A method according to any of claims 1 to 8, wherein the calling file is an operating system and the called file is a hypervisor. Procédé selon l’une quelconque des revendications 1 à 8, dans lequel le fichier appelant est un système d’exploitation ou un hyperviseur et le fichier appelé est un moniteur d’environnement d’exécution de confiance.A method according to any of claims 1 to 8, wherein the calling file is an operating system or a hypervisor and the called file is a trusted runtime environment monitor. Procédé selon l’une quelconque des revendications précédentes, dans lequel le méta-modèle est défini par un « trait » du langage RUST, chaque modèle par une « structure » du langage RUST, et la fonction « interne » côté appelant ou côté appelé par une « fonction » du langage RUST.A method according to any preceding claim, wherein the meta-model is defined by a RUST language "feature", each model by a RUST language "structure", and the calling side or called side "internal" function by a “function” of the RUST language. Procédé selon l’une quelconque des revendications précédentes, dans lequel, côté appelé, tous les modèles sont identiques et ne diffèrent donc pas du méta-modèle.Method according to one of the preceding claims, in which, on the called side, all the models are identical and therefore do not differ from the meta-model. Librairie comportant un méta-modèle définissant un prototype pour les appels à des fonctions « externes » et une pluralité de modèles, chaque modèle correspondant à une instanciation du méta-modèle pour une fonction « externe » particulière et implémentant une interface côté appelant définissant une fonction dite « interne » côté appelant et une interface côté appelé définissant une fonction dite « interne » côté appelé.Library comprising a meta-model defining a prototype for calls to "external" functions and a plurality of models, each model corresponding to an instantiation of the meta-model for a particular "external" function and implementing a caller-side interface defining a function called "internal" on the calling side and a called side interface defining a so-called "internal" function on the called side.
FR2114094A 2021-12-21 2021-12-21 Method for generating an executable file containing system calls and associated library. Active FR3131032B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
FR2114094A FR3131032B1 (en) 2021-12-21 2021-12-21 Method for generating an executable file containing system calls and associated library.

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
FR2114094A FR3131032B1 (en) 2021-12-21 2021-12-21 Method for generating an executable file containing system calls and associated library.
FR2114094 2021-12-21

Publications (2)

Publication Number Publication Date
FR3131032A1 true FR3131032A1 (en) 2023-06-23
FR3131032B1 FR3131032B1 (en) 2023-12-22

Family

ID=81581147

Family Applications (1)

Application Number Title Priority Date Filing Date
FR2114094A Active FR3131032B1 (en) 2021-12-21 2021-12-21 Method for generating an executable file containing system calls and associated library.

Country Status (1)

Country Link
FR (1) FR3131032B1 (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7694276B2 (en) * 2003-02-28 2010-04-06 Microsoft Corporation Contracts and futures in an asynchronous programming language

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7694276B2 (en) * 2003-02-28 2010-04-06 Microsoft Corporation Contracts and futures in an asynchronous programming language

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
TAN JIAQI ET AL: "AUSPICE-R: Automatic Safety-Property Proofs for Realistic Features in Machine Code", 9 October 2016, SAT 2015 18TH INTERNATIONAL CONFERENCE, AUSTIN, TX, USA, SEPTEMBER 24-27, 2015; [LECTURE NOTES IN COMPUTER SCIENCE; LECT.NOTES COMPUTER], SPRINGER, BERLIN, HEIDELBERG, PAGE(S) 42 - 62, ISBN: 978-3-540-74549-5, XP047358744 *

Also Published As

Publication number Publication date
FR3131032B1 (en) 2023-12-22

Similar Documents

Publication Publication Date Title
US9524152B2 (en) Partial specialization of generic classes
US10747648B2 (en) Mock object generation
US20110225565A1 (en) Optimal incremental workflow execution allowing meta-programming
US20080301648A1 (en) Model oriented debugging
Chong et al. Code-level model checking in the software development workflow
WO2006136565A1 (en) Data processing method compatible with an object modelling formalism
US10083029B2 (en) Detect application defects by correlating contracts in application dependencies
US20220198003A1 (en) Detecting added functionality in open source package
US20220391541A1 (en) Software provenance validation
EP1649363B1 (en) Method of managing software components that are integrated into an embedded system
Ghezzi et al. An evaluation of the adaptation capabilities in programming languages
US10275236B2 (en) Generating related templated files
FR2967275A1 (en) METHOD, COMPUTER PROGRAM AND DEVICE FOR SECURING INTERMEDIATE PROGRAMMING CODE FOR ITS EXECUTION BY A VIRTUAL MACHINE
FR3131032A1 (en) Process for generating an executable file containing system calls and associated library.
Meyer et al. The concept of class invariant in object-oriented programming
WO2011098677A1 (en) System and a method for managing and compiling a software development application framework
EP2182435A1 (en) Verfahren zur Implementierung einer Maschine in fertigen Zuständen über die Verwendung von Java-Notierungen
US7779430B2 (en) Method, system, and article of manufacture for providing service components
EP1337915A1 (en) Formal verification in particular of a secured virtual machine
Zhang et al. Programming smart contract with solidity
Weghofer Moola-a Groovy-based model operation orchestration language
WO2016016473A1 (en) Method for verifying traceability of first instructions in a procedural programming language generated from second instructions in a modelling language
Strömbäck A Syntax Highlighting and Code Formatting Tool for Extensible Languages
Jones ECOOP 2014--Object-Oriented Programming: 28th European Conference, Uppsala, Sweden, July 28--August 1, 2014, Proceedings
Elahi et al. Building and Packaging

Legal Events

Date Code Title Description
PLFP Fee payment

Year of fee payment: 2

PLSC Publication of the preliminary search report

Effective date: 20230623

PLFP Fee payment

Year of fee payment: 3