Giter VIP home page Giter VIP logo

chikuwait / bitvisor_mruby Goto Github PK

View Code? Open in Web Editor NEW
17.0 3.0 2.0 14.37 MB

mruby running inside the bare-metal hypervisor

License: Other

Makefile 2.73% Assembly 1.52% Shell 0.49% C 83.83% Roff 0.17% C++ 2.18% Objective-C 0.24% Batchfile 0.17% Perl 4.67% DIGITAL Command Language 1.09% XS 0.02% M4 0.17% eC 0.02% Emacs Lisp 0.01% HTML 0.01% Scheme 0.01% Prolog 0.10% Ruby 1.97% Yacc 0.59%
mruby bitvisor

bitvisor_mruby's Introduction

mruby in BitVisor

About this project

This project aims to change the behavior of the hypervisor with a dynamic scripting language. It will modify computer resource control and hypervisor behavior using mruby script language optimized for embedded use. Also, in this project, it send a mruby script from the shell on the guest OS to the hypervisor. And run mruby script without relying on OS.

About Bitvisor

BitVisor is a tiny hypervisor initially designed for mediating I/O access from a single guest OS. Its implementation is mature enough to run Windows and Linux, and can be used as a generic platform for various research and development projects.

LICENSE

See LICENSE.

bitvisor_mruby's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bitvisor_mruby's Issues

.gitignoreについて

本当は本家に言ったほうがいい気はするんですが、
99eb76c みたいなコミットが起きないように、.gitignoreファイルを定義してあげた方がいいかなーと。
最低でも:

*.o
*.s
*.d
.depends
.flags

/.config

ですかねー。あと細々と生成されるファイルもちゃんと入れてあげた方がいいかと。

Implementation of "f64_pow" is incomplete

The pow function existing in math.h in libC is 2.0 when passed as 4.0 and 0.5 as arguments. However, in my implementation there is a problem that the values ​​do not match because the value of the second argument is cast to an integer type.

Run mruby with VM/Ring3 process

In the current implementation, mruby script is running on thread. So, if there are some problems with the mruby scripts, the OS and BitVisor will crash. In order to solve this problem, I think that mruby should be done as a process of VM/Ring3.

ひとまず、レビューなど

mruby-1.2(最新安定版)で試した範囲なんですが

  • 2つに変更を累積させていくと行き来がつらい
  • mrubyにフィードバックしづらい

ことを考慮して、mruby自体には極力変更を加えず、BitVisorの標準ライブラリを充実させてく方向で諸々やってみました。

結果としては

  • libmruby.aの生成までは行けた。
  • まだリンクしてないので、実装しないといけないところがある。(strtodなどの関数)
  • おそらく、gccのsoft-floatライブラリの生成を行わないとリンクできない。

といった風です。

x86_64のABIの都合で浮動小数点数を取り扱うのがつらいので32bitでコンパイルしています。
なので、BitVisorも32bitでビルドしないといけないかと思います。
浮動小数点数を必要としないmrubyのオプションなどを模索中なので@miura1729さんとわたしの会話を追っていただければと...。
組み込み向けを名乗るなら、整数演算だけでもなんとかできないとまずいので...。(こんな反応もありましたし)

一応、64bitでどうなるのか知りたいのでしたら下のbuild_config.rb64のコメントアウトを外してみてください...。

bitvisorの標準ライブラリ関連はこんな風です:
https://gist.github.com/take-cheeze/62f9984354aa78fc5704c702b6d989d2
(足りないのを補ったり、例のパッチを統合した感じです)

build_config.rbは環境変数MRUBY_CONFIGで上書きできるので割と自由にやってます。

MRuby::Build.new do |conf|
  # load specific toolchain settings

  # Gets set by the VS command prompts.
  if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
    toolchain :visualcpp
  else
    toolchain :gcc
  end

  enable_debug
end

MRuby::CrossBuild.new('bitvisor') do |conf|
  toolchain :gcc

  cc.command = linker.command = 'x86_64-elf-gcc' # 'clang -target x86_64-elf'
  cc.include_paths << '../include'

  bits = 32 # 64
  backtrace = true

  cc.flags <<
    "-m#{bits} -mno-red-zone -nostdinc -g -O" <<
    " -ffreestanding -fno-builtin -fno-stack-protector" <<
    " -fno-strict-aliasing -Wall"
  cc.flags << (backtrace ? '-fno-omit-frame-pointer' : '-fomit-frame-pointer')

  # FPU settings
  cc.flags << '-mno-sse -mno-sse2 -mfpmath=387 -msoft-float -mno-mmx -mno-3dnow'

  conf.cc.defines << %w(MRB_DISABLE_STDIO BITVISOR_KERNEL)
  # conf.cc.defines << %w(MRB_INT64)
  conf.bins = []

  # gembox 'full-core'
end

mrubyの変更自体は1行で(abortは<stdlib.h>なのでこれはmrubyにパッチ送れますね):

1 file changed, 1 insertion(+)
src/vm.c | 1 +

modified   src/vm.c
@@ -6,6 +6,7 @@
 
 #include <stddef.h>
 #include <stdarg.h>
+#include <stdlib.h>
 #include <math.h>
 #include "mruby.h"
 #include "mruby/array.h"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.