2009年7月12日 (日)

BotNet 簡単メモ

ひさしぶりのブログです。

ハーダー → CCサーバ → ボット

フラッディング
SMTPリレー
LEAK系

ステルス機能 
ドロッパー
ルートキット

話題
中米では実際にATMがとまった。
数十万台ゾンビマシン
一時間100ドルでレンタル(ヨーロッパ)
一ヶ月 2万8000ドル(欧米)

米韓DDOSの話題はどうなるんでしょうか。


|

2009年6月 7日 (日)

volattility for introspsction

https://www.volatilesystems.com/default/volatility

|

2009年3月25日 (水)

xen 3.3.3 tg3 not seem to be present

HP proliantなサーバにxen-3.3.0を入れましたが、NIC(tg3 broadcom)で躓きました。

xenカーネル 2.6.18ですと
tg3 eth0 not seem to be present
というエラーが出てeth0があがりませぬ。

かなりあせりましたが、いろいろgoogleりまして
broadcomのサイトからtb3-3.92nというソースコードをダウンロードして
insmodしたらうまくいきました。

いまのところはうまくいっている様子
XENの中のlinuxソースツリーのtg3.koではうまくいかない模様。。

|

2009年2月 6日 (金)

VNC ポートフォわーディング

5901 -> 1234

ssh localhost:1234

|

2009年1月27日 (火)

yum install エラー urlopen

サーバを移動しまして、

yum install emacs
しますと、
Error: Cannot retrieve repository metadata (repomd.xml) urlopen
となりますた。

といいますのは、移動する前の環境で、
.bashrc http_proxy= "**"

とかhttp_proxyの環境変数が設定されていたからですた。ウ~無


|

2009年1月15日 (木)

linux 起動スクリプト

# chkconfig: 2345 80 30
# description: active eth0
ifup eth0

上の2行が重要 これがねいとchkconfig をサポートしていませんといわれるる

|

Embedded Design Using Programmable Gate Arrays

http://astro.temple.edu/~silage/embeddes.htm
spartan3Eを使っているらすい。。

|

2009年1月14日 (水)

Spartan-3E Starter Kit Board User Guide

http://www.engr.sjsu.edu/crabill/ug230.pdf

|

kvm operation not permitted

kvm-83をインストールすますたが、
insmod kvm-intel.ko
でoperation not permitted と出ますた。

ははんこれはBIOSの設定だなと思い
virtualization technologyの設定をすますたが、
operation not permittedがでますた

これはとおもひ、何度か設定を変えてコンパイルすますたが
ハードウェアリセットをしないとだめなのが気づきませぬですた

電源落としてあげなおしたらうまくいきすた。:)

|

2009年1月 9日 (金)

NFS 起動エラー

[root@localhost ~]# /etc/init.d/nfs restart
NFS mountd を終了中: [失敗]
NFS デーモンを終了中: [失敗]
NFS quotas を終了中: [失敗]
NFS サービスを終了中: [ OK ]
NFS サービスを起動中: [ OK ]
NFS クォータを起動中: サービスを登録できません: RPC: 認証エラー; why = クライアントの信任が弱すぎます
rpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp).
[失敗]
NFS デーモンを起動中: [失敗]
[root@localhost ~]# /etc/init.d/rcpbind restart
-bash: /etc/init.d/rcpbind: そのようなファイルやディレクトリはありません
[root@localhost ~]# /etc/init.d/rpcbind restart
rpcbind を停止中: [ OK ]
rpcbind を起動中: [ OK ]
[root@localhost ~]# /etc/init.d/nfs restart
NFS mountd を終了中: [失敗]
NFS デーモンを終了中: [失敗]
NFS quotas を終了中: [失敗]
NFS サービスを終了中: [ OK ]
NFS サービスを起動中: [ OK ]
NFS クォータを起動中: [ OK ]
NFS デーモンを起動中: [ OK ]
NFS mountd を起動中:

|

linux 2.6.18.8 コンパイル

Kernel: arch/x86_64/boot/bzImage is ready (#1)
Building modules, stage 2.
MODPOST
sh /usr/src/xen-3.3.0/linux-2.6.18-xen-3.3.0/arch/x86_64/boot/install.sh 2.6.18.8 arch/x86_64/boot/bzImage System.map "/boot"
WARNING: No module ata_piix found for kernel 2.6.18.8, continuing anyway
WARNING: No module ata_piix found for kernel 2.6.18.8, continuing anyway

|

2009年1月 5日 (月)

Spartan-3E FPGA Starter Kit Board Design Examples

Spartan-3E FPGA Starter Kit Board Design Examples
http://japan.xilinx.com/products/boards/s3estarter/reference_designs.htm

|

2009年1月 1日 (木)

SSL証明書に価格破壊の波

http://www.nikkeibp.co.jp/it/article/NEWS/20081209/321103/

|

2008年12月22日 (月)

NetFPGA

ネットワークアクセラレータ

OpenFlow netFPGA
http://www.openflowswitch.org/wp/tag/netfpga/

An open network hardware platform
implemented with Field Programmable
Gate Array (FPGA) logic.

openFlowとルータの関係がわからん。。
http://conferences.sigcomm.org/sigcomm/2008/workshops/presto/papers/p1.pdf

netFPGA raw packet sockets
http://comp519.cs.rice.edu/index.php/Raw_Packet_Sockets

Prototyping Fast, Simple, Secure Switches for Etha

OpenFlow: Enabling Innovation in Campus Networks
http://ccr.sigcomm.org/online/files/p69-v38n2n-mckeown.pdf

Virtual Routers on the Move: Live Router Migration
as a Network-Management Primitive
http://www.cs.princeton.edu/~yiwang/papers/vroom_sigcomm08.pdf

Prototyping Counter Braids on NetFPGA
http://simula.stanford.edu/luyi/fpga.pdf

Orphal: API Design Challenges for Open Router Platforms on Proprietary
Hardware
http://www.hpl.hp.com/techreports/2008/HPL-2008-108.pdf

|

2008年12月16日 (火)

組み込みセキュリティシンポジウム

replay attack
TPM reset attack
cold boot attack

IDベース暗号 shamir
ユーザIDを公開鍵
公開鍵の認証機関CAは不要
秘密鍵製造期間が必要

|

2008年11月25日 (火)

コルモゴロフ複雑性

コルモゴロフ複雑性
http://ja.wikipedia.org/wiki/%E3%82%B3%E3%83%AB%E3%83%A2%E3%82%B4%E3%83%AD%E3%83%95%E8%A4%87%E9%9B%91%E6%80%A7
よくわからんが、有限長のビット列の複雑性に関するモノ
周期の問題だろうか・・
データ間の距離を測るのに使えるらしい。

Two applications
http://www.ens-lyon.fr/LIP/MC2/files/Andrei_Romashchenko2.pdf

MALABのライブラリ
http://www.mathworks.com/matlabcentral/fileexchange/6886

クラスタリングアリゴリズムの比較評価にも使えるらしい。。
Comparison of cluster algorithms for the analysis of text data using Kolmogorov complexity
Tina Geweniger, Frank-Michael Schleif, Alexander Hasenfuss, Barbara Hammer, and Thomas Villmann
ICONIP 2008

|

Latent Symantec Indexing

Latent Symantec Indexing
Googleが最近使っているらしい。。

http://www.buzzle.com/articles/latent-symantec-indexing-lsi-key-to-high-search-rankings.html

Latent Symantec Indexing (LSI) is the new technique search leader Google is applying to determine the weight of a backlink pointing at a website.
http://www.nb-talks.com/latent-symantec-indexing-lsi-google/12/14/2006/


http://silomatic.blogspot.com/2007/09/latent-symantec-indexing-lsi-key-to.html

http://www.1stonthelist.ca/Articles/lsi-algorithm/

exampleの話が少しある。。
http://learn-the-basics.com/blog/?p=134

|

2008年11月17日 (月)

xen live migration ソースたんきぅ *xc_map_foreign_batch

Live migrationのメモ

void *xc_map_foreign_batch
ioctlが入っているので、最もprimitiveな関数だと思ふ。。

xc_domain_save.c

/* HVM: shared-memory bitmaps for getting log-dirty bits from qemu-dm */
static unsigned long *qemu_bitmaps[2];
static int qemu_active;
static int qemu_non_active;

/* number of pfns this guest has (i.e. number of entries in the P2M) */
static unsigned long p2m_size;

/* Live mapping of the table mapping each PFN to its current MFN. */
static xen_pfn_t *live_p2m = NULL;

/* Live mapping of system MFN to PFN table. */
static xen_pfn_t *live_m2p = NULL;
static unsigned long m2p_mfn0;

/* Live mapping of shared info structure */
shared_info_t *live_shinfo = NULL;

/*
** During (live) save/migrate, we maintain a number of bitmaps to track
** which pages we have to send, to fixup, and to skip.
*/

#define BITS_PER_LONG (sizeof(unsigned long) * 8)
#define BITS_TO_LONGS(bits) (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
#define BITMAP_SIZE (BITS_TO_LONGS(p2m_size) * sizeof(unsigned long))

#define BITMAP_ENTRY(_nr,_bmap) \
((volatile unsigned long *)(_bmap))[(_nr)/BITS_PER_LONG]

#define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG)

-----------------

if ( pte & _PAGE_PRESENT )
{
mfn = (pte >> PAGE_SHIFT) & MFN_MASK_X86;
if ( !MFN_IS_IN_PSEUDOPHYS_MAP(mfn) )
{
/* This will happen if the type info is stale which
is quite feasible under live migration */
pfn = 0; /* zap it - we'll retransmit this page later */
race = 1; /* inform the caller of race; fatal if !live */
}

-------------------

static xen_pfn_t *map_and_save_p2m_table(int xc_handle,
int io_fd,
uint32_t dom,
unsigned long p2m_size,
shared_info_t *live_shinfo)
{
vcpu_guest_context_t ctxt;

/* Double and single indirect references to the live P2M table */
xen_pfn_t *live_p2m_frame_list_list = NULL;
xen_pfn_t *live_p2m_frame_list = NULL;

/* A copy of the pfn-to-mfn table frame list. */
xen_pfn_t *p2m_frame_list = NULL;

/* The mapping of the live p2m table itself */
xen_pfn_t *p2m = NULL;

int i, success = 0;

live_p2m_frame_list_list = map_frame_list_list(xc_handle, dom,
live_shinfo);
if ( !live_p2m_frame_list_list )
goto out;

-----------------------

live_p2m_frame_list_list = map_frame_list_list(xc_handle, dom,
live_shinfo);
if ( !live_p2m_frame_list_list )
goto out;

live_p2m_frame_list =
xc_map_foreign_batch(xc_handle, dom, PROT_READ,
live_p2m_frame_list_list,
P2M_FLL_ENTRIES);
if ( !live_p2m_frame_list )
{
ERROR("Couldn't map p2m_frame_list");
goto out;
}

[root@localhost xen-3.1.0-src]# grep -rin live_p2m_frame_list_list *
tools/libxc/xc_domain_save.c:667: xen_pfn_t *live_p2m_frame_list_list = NULL;
tools/libxc/xc_domain_save.c:678: live_p2m_frame_list_list = map_frame_list_list(xc_handle, dom,
tools/libxc/xc_domain_save.c:680: if ( !live_p2m_frame_list_list )
tools/libxc/xc_domain_save.c:685: live_p2m_frame_list_list,
tools/libxc/xc_domain_save.c:771: if ( live_p2m_frame_list_list )
tools/libxc/xc_domain_save.c:772: munmap(live_p2m_frame_list_list, PAGE_SIZE);
tools/libxc/xc_core_x86.c:65: xen_pfn_t *live_p2m_frame_list_list = NULL;
tools/libxc/xc_core_x86.c:78: live_p2m_frame_list_list =
tools/libxc/xc_core_x86.c:82: if ( !live_p2m_frame_list_list )
tools/libxc/xc_core_x86.c:90: live_p2m_frame_list_list,
tools/libxc/xc_core_x86.c:116: if ( live_p2m_frame_list_list )
tools/libxc/xc_core_x86.c:117: munmap(live_p2m_frame_list_list, PAGE_SIZE);

int
xc_core_arch_map_p2m(int xc_handle, xc_dominfo_t *info,
shared_info_t *live_shinfo, xen_pfn_t **live_p2m,
unsigned long *pfnp)

live_p2m_frame_list =
xc_map_foreign_batch(xc_handle, dom, PROT_READ,
live_p2m_frame_list_list,
P2M_FLL_ENTRIES);


xc_linux.c

void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
xen_pfn_t *arr, int num)
{
privcmd_mmapbatch_t ioctlx;
void *addr;
addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, xc_handle, 0);
if ( addr == MAP_FAILED )
return NULL;

ioctlx.num=num;
ioctlx.dom=dom;
ioctlx.addr=(unsigned long)addr;
ioctlx.arr=arr;
if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx) < 0 )

-------------

xc_core_x86.c

int
xc_core_arch_map_p2m(int xc_handle, xc_dominfo_t *info,
shared_info_t *live_shinfo, xen_pfn_t **live_p2m,
unsigned long *pfnp)
{
/* Double and single indirect references to the live P2M table */
xen_pfn_t *live_p2m_frame_list_list = NULL;
xen_pfn_t *live_p2m_frame_list = NULL;
uint32_t dom = info->domid;
unsigned long p2m_size = nr_gpfns(xc_handle, info->domid);
int ret = -1;
int err;

if ( p2m_size < info->nr_pages )
{
ERROR("p2m_size < nr_pages -1 (%lx < %lx", p2m_size, info->nr_pages - 1);
goto out;
}

live_p2m_frame_list_list =
xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ,
live_shinfo->arch.pfn_to_mfn_frame_list_list);


/////////////////////////////////////////////

xc_linux.c

void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
xen_pfn_t *arr, int num)
{
privcmd_mmapbatch_t ioctlx;
void *addr;
addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, xc_handle, 0);
if ( addr == MAP_FAILED )
return NULL;

ioctlx.num=num;
ioctlx.dom=dom;
ioctlx.addr=(unsigned long)addr;
ioctlx.arr=arr;
if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx) < 0 )
{
int saved_errno = errno;
perror("XXXXXXXX");
(void)munmap(addr, num*PAGE_SIZE);
errno = saved_errno;
return NULL;
}
return addr;

}

こういう使いかたをする。。。

live_p2m_frame_list =
xc_core_x86.c:89: xc_map_foreign_batch(xc_handle, dom, PROT_READ,
xc_core_x86.c-90- live_p2m_frame_list_list,
xc_core_x86.c-91- P2M_FLL_ENTRIES);

|

シグナリングプロトコル

シグナリングプロトコル

おそらく。。。
端末同士が相手の状態を把握し、通信の前後に、通信のパラメータなどを策定するプロトコル。
通信の前後に行われるそうな。。

|

プロトコルスタック

PCやら、サーバ運用から入った人とかは、プロトコルスタックは
縁遠いのではないだろうですが。。。

調べてみますた

http://www.asahi-net.or.jp/~QX5K-ISKW/robot/blue.html

https://www.codeblog.org/blog/gniibe/20060104.html

プロトコルスタック navajo
http://itpro.nikkeibp.co.jp/article/COLUMN/20080711/310645/?ST=develop&P=6

組み込みシステム用TCP/IPプロトコルスタックの開発
http://www.tl.cc.uec.ac.jp/~okazaki/svbl/svbl.html

PICで楽しむネットワーク接続機器の自作
http://bookweb.kinokuniya.co.jp/htm/4774136174.html

組み込み系だとプロトコルスタックを自作するツワモノがいますな~

還暦プログラマの挑戦(Haskell に挑む)
http://www.cmas60.com/sample/dotnet/socket.php
↑粋です。

プロトコルスタックは、OSに組み込まれているので、
あまり意識しないが。。

TCP/IPだけでなく、USBなんかもプロトコルスタックなんですな~
http://www.fumi2kick.com/komekame/archives/170
USBは、フルスクラッチで書くのが大変そうだ~
オープンソースで公開しているのがあるので、それを使うのが吉か。。

最近オープンソース化した
シンビアンOS屋さんいわく、プロなんちゃらOSは開発コストが
かかるというのは、こういうことをいうのでせぅか。

SIPプロトコルスタックの作成
http://cai.int-univ.com/sugsi/Lecture/VoIP/Exercise/SIPstack.html

SIPプロトコルの解説
http://www.atmarkit.co.jp/fnetwork/rensai/voip02/01.html

徒然と作成例を探していたのですが。。

基礎からわかるTCP/IP SIPによるVoIPプログラミング―Linux対応
http://bookweb.kinokuniya.co.jp/htm/4274065596.html
簡易SIPスタックの作成というのがあるぞ~!

|

2008年11月12日 (水)

グリーンIT Powerシステム

グリーンIT
http://itpro.nikkeibp.co.jp/as/ibm_hitachi/index.shtml
によると、サーバはアイドル時間が80%
プロセサの消費電力は30%くらいなそうな。。

データセンター全体では
電源の安定化(UPS)と冷やす(サーバ)ことに電力の多くを
ついやしているそうな。。

サーバに対するサービスの集約度を上げるのがポイントでしょうか。

リソース利用効率の適正化は、
WINHEC2008とかでやっていましたが、
プロセッサだけでなく、全体的に見ないとだめなみたいなことを
言っていました。


|

2008年11月 8日 (土)

11月7日 ニュース

USBメモリのマルウェア
http://is702.jp/news/detail.php?id=194
WORM_AUTORUN(オートラン)

USBにアンチウィルスも。。
http://jp.trendmicro.com/jp/about/news/pr/article/20080929095100.html

IBMでandroidの勉強会が
http://www.ibm.com/developerworks/jp/offers/cz/library/cz04/index.html?ca=drs-jp-0829

セキュアハッシュコンテスト
http://www.securityfocus.com/news/11536?ref=rss

|

rootkit installation

OpenSCMManager
CreateService
->comint32.sys

make installation more stealth about registry
ZwSetSystemInformation(SystemLoadAndCallImage, ...)

|

2008年11月 1日 (土)

11月1日 ニュース

米Intel社、台湾政府と共同でオープン・ソース・ソフトウエアの開発センターを設立
http://www.nikkeibp.co.jp/article/news/20081031/109484/

|

2008年10月 3日 (金)

could not find filesystem dev root

Linux カネルをアップデート(再コンパイル)すますたが

could not find filesystem dev root
switchroot: mount failed

このやふなエラーがでますた

検索しますと。。みなさん苦労しているやふで。。

よく把握できておりませぬので
make menuconfigでコンパイルオプションにて
SCSIのオプションすべて オン*にしますたら、

起動されますた。

ドライバがロードされないので、ハードディスクが認識されなひ模様

|

2008年9月25日 (木)

libvirt + KVM + virsh

kvm + libvirt + virsh

まず、rootでやってたら hypervisorに接続できませんとのエラーが出てはまった。。

既存のqemu imgファイルを使う方法
virt-install --name my.OS --ram 256 --vnc --hvm --accelerate
--cdrom /dev/cdrom --file /home/flare/my.OS.img

xmlファイルから、network タグをはずした。

virt-manager my.OS とかやったらうまくイキマスタ o( `∀´)b

|

2008年9月19日 (金)

XEN HYPERCALL

xen/include/public/xen.h

#define __HYPERVISOR_set_trap_table 0
#define __HYPERVISOR_mmu_update 1
#define __HYPERVISOR_set_gdt 2
#define __HYPERVISOR_stack_switch 3
#define __HYPERVISOR_set_callbacks 4
#define __HYPERVISOR_fpu_taskswitch 5
#define __HYPERVISOR_sched_op_compat 6 /* compat since 0x00030101 */
#define __HYPERVISOR_platform_op 7
#define __HYPERVISOR_set_debugreg 8
#define __HYPERVISOR_get_debugreg 9
#define __HYPERVISOR_update_descriptor 10
#define __HYPERVISOR_memory_op 12
#define __HYPERVISOR_multicall 13
#define __HYPERVISOR_update_va_mapping 14
#define __HYPERVISOR_set_timer_op 15
#define __HYPERVISOR_event_channel_op_compat 16 /* compat since 0x00030202 */
#define __HYPERVISOR_xen_version 17
#define __HYPERVISOR_console_io 18
#define __HYPERVISOR_physdev_op_compat 19 /* compat since 0x00030202 */
#define __HYPERVISOR_grant_table_op 20
#define __HYPERVISOR_vm_assist 21
#define __HYPERVISOR_update_va_mapping_otherdomain 22
#define __HYPERVISOR_iret 23 /* x86 only */
#define __HYPERVISOR_vcpu_op 24
#define __HYPERVISOR_set_segment_base 25 /* x86/64 only */
#define __HYPERVISOR_mmuext_op 26
#define __HYPERVISOR_acm_op 27
#define __HYPERVISOR_nmi_op 28
#define __HYPERVISOR_sched_op 29
#define __HYPERVISOR_callback_op 30
#define __HYPERVISOR_xenoprof_op 31

xenの全貌を端的に表しているといえなくもない。。

|

2008年9月18日 (木)

DCRT (Debug C Runtime Library)

DCRT ヒープメモリ追跡機能を持つ。

new、malloc、callocなどで割り当てたヒープメモリの

メモリアンダーライト
メモリオーバーライト
メモリリーク

を検出する。BoundsChekerやpurifyよりもfine grainedらしい。。
ASSERTで、_CrtCheckMemoryをコード内にscatterしておくと良い模様。

メモリ状態関数

_CrtIsValidHeapPointer
_CrtIsMemoryBlock
_CrtMemDifference
_CrtMemDumpStatistics

ライブラリ呼び出し前後のヒープ状態のスナップをとることができるそうな

MemDumperValidator
http://ec.nikkeibp.co.jp/item/contents/mokuji/m_563600.html
.NET版もあるよ。

|

2008年9月10日 (水)

米国特許

読者の質問に答える---なぜ米国特許が重要なのか
http://itpro.nikkeibp.co.jp/article/Watcher/20060123/227706/

このままでいいのか米国特許出願
http://www.nihon-ir.jp/?page_id=47

第2回 今なぜソフトウェアを特許で保護すべきなのか
http://itckinki.jp/article.php/20071101patent02/print

日米の特許協力には本質の問題を解決せねばならない
http://nihonir.exblog.jp/4887640/

米国特許出願使用しよう
http://homepage2.nifty.com/UNYLEC/PCT.htm

IBM、500件の特許をオープンソースに「寄贈」 ちょっと古いが。。2005年
http://www.itmedia.co.jp/enterprise/articles/0501/11/news048.html

http://okwave.jp/qa2655876.html?ans_count_asc=2

米最高裁、国外複製の『Windows』に米国特許法の適用を認めず
http://210.155.151.141/busnews/20070501/11.html

2006年米国特許取得件数、トップは14年連続で IBM
http://japan.internet.com/busnews/20070112/12.html


|

2008年9月 8日 (月)

ROCKS クラスタ

UCSDがNSFのファンドで開発したもの。
http://www.rocksclusters.org/wordpress/

rocks cluster toolkit
http://www.clubscs.com/rockscluster/
http://www.clubscs.com/

インストール手順書
http://www.venus.dti.ne.jp/~iisaka/Rocks/HowtoInstall.html

sourceForge.jp
http://sourceforge.jp/magazine/08/08/20/0127233

インストールには、16GBのハードディスクと512MBのメモリがあればOK.

|

2008年9月 2日 (火)

Xen Live Migrationのいいところ?

http://www.thinkit.co.jp/cert/tech/26/2/3.htm

VMWare VMotionの場合、FC接続の共有ディスクが要る。XENの場合、NFSやらiSCSIを利用することが可能。ネットワーク回線があればよい。

|

2008年9月 1日 (月)

Linux 電源管理

http://www.p3international.com/products/special/P4400/P4400-CE.html

Linuxのパワーマネジメント powerTop
http://japan.internet.com/linuxtutorial/20080418/2.html

Linuxのパワーマネジメント パート2
http://japan.internet.com/linuxtoday/20080425/5.html

LessWatts Saving Power with Linux
http://www.lesswatts.org/

APMで電源管理
http://www.atmarkit.co.jp/flinux/rensai/linuxtips/501useapm.html

LinuxにおけるACPI構造の解説
http://opentechpress.jp/kernel/lkc2002/C06.pdf

Linux ACPI howto
http://www.linux.or.jp/JF/JFdocs/ACPI-HOWTO.html#toc1

|

Linux 電源管理

http://www.p3international.com/products/special/P4400/P4400-CE.html

Linuxのパワーマネジメント powerTop
http://japan.internet.com/linuxtutorial/20080418/2.html

Linuxのパワーマネジメント パート2
http://japan.internet.com/linuxtoday/20080425/5.html

LessWatts Saving Power with Linux
http://www.lesswatts.org/

APMで電源管理
http://www.atmarkit.co.jp/flinux/rensai/linuxtips/501useapm.html

LinuxにおけるACPI構造の解説
http://opentechpress.jp/kernel/lkc2002/C06.pdf


|

2008年8月31日 (日)

Power Aware System

http://pages.cs.wisc.edu/~saisanth/papers/poweros.pdf
http://portal.acm.org/citation.cfm?id=356989.356999
http://www.ecs.umass.edu/ece/realtime/publications/unko03.pdf
http://www.sosp2007.org/papers/sosp111-nathuji.pdf
http://academic.csuohio.edu/yuc/papers/survey_10_18_final.pdf

http://www.csm.ornl.gov/~engelman/publications/nagarajan07proactive.pdf
http://www.iti.tugraz.at/de/people/kaefer/publications/phdthesis_kaefer.pdf
http://www.cs.cmu.edu/~satya/docdir/p137-flinn.pdf

http://drops.dagstuhl.de/opus/volltexte/2005/308/pdf/05141.HomJerry.Paper.308.pdf
http://www.cs.rochester.edu/~papathan/papers/2002-URCS-TR-792-Bursty/2002-urcs-tr792.pdf

http://www.cs.rochester.edu/~papathan/papers/2002-URCS-TR-792-Bursty/2002-urcs-tr792.pdf
http://www.cercs.gatech.edu/mmcs08/program/amur.pdf

http://www.eecs.umich.edu/~tnm/theses/krisf.pdf
http://www.efficient-server.eu/fileadmin/docs/reports/E-Server-Report_PartII.pdf

|

2008年8月26日 (火)

www.dshiled.org

http://www.dshield.org/indexd.html

|

API hook

http://www.codeproject.com/KB/system/hooksys.aspx?fid=3602&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=26&select=1461868

|

libvirt

Libvirtは、VMにAPIを提供するライブラリだそうな。。
そういえば、yum install xenすると入りますな。
サポートしているのは、KVM,XEN、OpenVZなど多岐に渡すそうだが、
よくわからん。。

KVMもXENもlibvirtを使っている?
Libvirtがないと動かない?(そうでしたっけ?) xenAPIは?

というよりも、KVM、XENとかの違いを吸収して、VMを操作するためのライブラリということでせぅか
Virshとかいうのもあるらすぃ
http://www.thinkit.co.jp/free/article/0706/10/4/index.html?fr=rdf

http://www.asahi-net.or.jp/~AA4T-NNGK/xen5.html

|

2008年8月25日 (月)

CERT's MP3 podcast

http://www.cert.org/podcast/

|

2008年8月24日 (日)

トレンドマイクロ TDS TMS

トレンドマイクロ、ネットワーク常時監視で未知マルウェアを検知・駆除するソリューション
http://techtarget.itmedia.co.jp/tt/news/0808/20/news05.html

|

2008年8月19日 (火)

qemu イメージ変換

|

2008年8月15日 (金)

ZHRシステム

http://www.securebrain.co.jp/news/070312_zhr.html

|

Syser debugger

http://solitonwave.co.jp/products/syserdebugger.html

|

2008年7月25日 (金)

directory harvest attack

http://www.hotfix.jp/archives/word/2007/word07-23.html

|

2008年7月 9日 (水)

kvm 構造体

struct kvm_vcpu {
kvm-63/kernel/include/linux

struct kvm_vcpu_arch {
kvm-63/kernel/include/asm

KVMはシンプルだな〜 

|

2008年6月25日 (水)

DFRWS

http://www.dfrws.org/

|

2008年6月13日 (金)

テキストログイン

/etc/inittab
にて
id:3:initdefault:
こ~する。

|

Xen Migration メモ

Xen のmigartionは、両サイドで環境を同じくする必要があるとのことのでしたが、
バージョンを同じくすれば(xen-3.1.0-src)
違うスペックのマシン(INTELマシン←→DELLマシン)でのマイグレーションは
うまく行きますた。

|

2008年6月11日 (水)

LEET08 論文

Characterizing Botnets From Email Spam Records

Li Zhuang, John Dunagan, Daniel R. Simon, Helen J. Wang, Ivan Osipkov Geoff Hulten, J. D. Tygar First USENIX Workshop on Large-Scale Exploits and Emergent Threats (LEET)

www.usenix.org/event/leet08/tech/full_papers/zhuang/zhuang.pdf

HotMail Web mail service の Junk Mail Samples を利用。
Spam campaignsの識別。
スパムメールが、ボットネットから来たかどうか切り分ける。
IPアドレスの評価。Cサブネットのアドレスを扱っている?
ボットネットの識別とサイズの推定。

JMSデータセットから、294のボットネットを検出した。


|

2008年5月30日 (金)

CDF

Cumulative distribution function
http://en.wikipedia.org/wiki/Cumulative_distribution_function

www.usenix.org/event/leet08/tech/full_papers/zhuang/zhuang.pdf

|

2008年5月11日 (日)

PCI

マザーボードに、白いスロットがあり、これにネットーワークカードやらグラフィックカードを差し込んでいることがあるだらう。。

なので、
あれはPCIといい、NICもグラボのこの場合、PCIデバイスとして認識されていることになるといまさらナガラ ピカデリー梅田 ナイアガラ スタント

|

2008年4月28日 (月)

tcpdump すくりぷちょ

tcpdump script スクリプト

#!/bin/sh

count=1
while [ $count -le 5 ];
do
tcpdump -i br2 > out$count & sleep 3 PID=$!
echo "$PID" kill $PID
echo "switch"
count=`expr $count + 1`
done

kill $PID

|

2008年4月27日 (日)

p2p tcpdump

20M -> 26713

|

2008年4月20日 (日)

KVMのCDROM問題

KVM63 on FC7な感じでは、CDROMがマウント認識されませぬる
QEMUをyum installして使い申し上げまつれれ

|

2008年4月19日 (土)

xen ライブ マイグレ-ション

xend-config.sxpを、

(xend-relocation-server yes)
(xend-relocation-port 8002)
(xend-relocation-address '')
(xend-relocation-hosts-allow '')

このように変更シマスタ

最後の4ぎゃうデスガ
(xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$')
となっておりますとポートが開きませぬのでちういデス

|

2008年4月14日 (月)

RSS:チェック・ポイント、インシデント対策と性能を強化したIPS新版をリリース

http://techtarget.itmedia.co.jp/tt/news/0804/11/news05.html

ビジュアライズ
トレースバック
対応策の提示
並列処理で1Gbpsのスループット

すげ~

|

2008年4月 8日 (火)

qemuのrtl8139


/* Loads values of tally counters from VM state file */
static void RTL8139TallyCounters_load(QEMUFile* f, RTL8139TallyCounters *tally_counters);

/* Saves values of tally counters to VM state file */static void rtl8139_update_irq(RTL8139State *s)

static void RTL8139TallyCounters_save(QEMUFile* f, RTL8139TallyCounters *tally_counters);

typedef struct RTL8139State {
-- snip --
/* PCI interrupt timer */
QEMUTimer *timer;
}

static void rtl8139_update_irq(RTL8139State *s)
{
int isr;
isr = (s->IntrStatus & s->IntrMask) & 0xffff;

DEBUG_PRINT(("RTL8139: Set IRQ to %d (%04x %04x)\n",
isr ? 1 : 0, s->IntrStatus, s->IntrMask));

qemu_set_irq(s->pci_dev->irq[0], (isr != 0));
}

static void rtl8139_transfer_frame(RTL8139State *s, const uint8_t *buf, int size, int do_interrupt)
{
if (!size)
{
DEBUG_PRINT(("RTL8139: +++ empty ethernet frame\n"));
return;
}

if (TxLoopBack == (s->TxConfig & TxLoopBack))
{
DEBUG_PRINT(("RTL8139: +++ transmit loopback mode\n"));
rtl8139_do_receive(s, buf, size, do_interrupt);
}
else
{
qemu_send_packet(s->vc, buf, size);
}
}


static void rtl8139_save(QEMUFile* f,void* opaque){


void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn)
{
#if RTL8139_ONBOARD_TIMER
s->timer = qemu_new_timer(vm_clock, rtl8139_timer, s);

qemu_mod_timer(s->timer,
rtl8139_get_next_tctr_time(s,qemu_get_clock(vm_clock)));
#endif /* RTL8139_ONBOARD_TIMER */
}

|

2008年4月 7日 (月)

顔文字 ぐはっ

「´∀`)≡○)`Д).・:.」

|

2008年4月 5日 (土)

IDA pro

http://www.microsoft.com/japan/technet/security/secnews/columns/column070328.mspx
http://www.atmarkit.co.jp/fwin2k/insiderseye/20051109rootkit/rootkit_01.html

http://www.amazon.com/Reverse-Engineering-Code-IDA-Pro/dp/159749237X
http://www.amazon.com/Reverse-Engineering-Code-IDA-Pro/dp/159749237X


http://old.idapalace.net/index.html

|

2008年4月 4日 (金)

xm save

xm_domain_save.c

DPRINTF("%d pfn= %08lx mfn= %08lx %d [mfn]= %08lx\n",
iter, (unsigned long)n, hvm ? 0 : live_p2m[n],
test_bit(n, to_send),
hvm ? 0 : mfn_to_pfn(live_p2m[n]&0xFFFFF));


DPRINTF("%d pfn= %08lx mfn= %08lx [mfn]= %08lx"
" sum= %08lx\n",
iter,
(pfn_type[j] & XEN_DOMCTL_PFINFO_LTAB_MASK) |
pfn_batch[j],
pfn_type[j],
mfn_to_pfn(pfn_type[j] &
~XEN_DOMCTL_PFINFO_LTAB_MASK),
csum_page(region_base + (PAGE_SIZE*j)));

|

2008年4月 2日 (水)

顔文字

(゚ー゚)(。_。)ウンウン
(゚д゚)(。_。)ウン!

(*`▼´*)b

|

GPFS クラスターを対象とした SNMP ベースの監視

GPFS クラスターを対象とした SNMP ベースの監視
http://www.ibm.com/developerworks/jp/linux/library/l-snmp-gpfs/index.html?ca=drs-jp-0129

|

RSS:700MHz帯はなぜそれほど重要なのか

http://techtarget.itmedia.co.jp/tt/news/0804/01/news02.html

700MHz信号からの受信電力は、1,9GHzなどに比べ高い。低周波数信号の方が受信電力は高くなるらすい。そのため、信号をデコードしやすい。なので、700Mhzは遠くまで飛ぶ。一等地だそうな

|

2008年4月 1日 (火)

winAPI writeProcessMemory

BOOL WriteProcessMemory(
HANDLE hProcess,
LPVOID lpBaseAddress,
LPVOID lpBuffer,
DWORD nSize,
LPDWORD lpNumberOfBytesWritten
);
引数
hProcess
プロセスハンドル
lpBaseAddress
ベースアドレス
lpBuffer
データを格納するバッファ
nSize
同、サイズ
lpNumberOfBytesWritten
コピーバイト数

|

parallel redundancy protocol

ines.zhwin.ch/fileadmin/user_upload/high_availability/PRP/PRP_Tutorial.pdf

|

kvm qemu-ifup(s)

KVM上で複数のOSを動かす

tapベースでこのやうなのを使いますと

#!/bin/sh

#switch=$(/sbin/ip route list | awk '/^default / { print $NF }')
/sbin/ifconfig $1 172.20.0.1 up
#/usr/sbin/brctl addif ${switch} $1

2つ目のOSが普通になりますえれ

brctl addbr br2
すて

#!/bin/sh

#. /etc/rc.d/init.d/functions
#ulimit -c unlimited

echo 'config qemu network with xen bridge for ' $*

ifconfig $1 0.0.0.0 up
brctl addif br2 $1

ifconfig br2 182.168.128.1

ホストのIPアドレスを192.168.128.3などとすますたら
PING通りました

|

2008年3月24日 (月)

win ddk コンパイル

c:\winddk\1\setenv.bat c:\winddk\1 fre
cd c:\winddk\target
build

|

2008年3月20日 (木)

RSS; もう1つのガラパゴス「受託開発」

組み込み系では、ソフトウェア開発の効率性追求に関する投資比率が高い。検証ツールの利用率も高い。携帯の日本市場は海外勢が参入しにくい反面、開発結果を海外市場で活かすことができない。

このような状態について。。。
http://www.atmarkit.co.jp/news/analysis/200803/18/si.html

|

RSS:セキュリティギャップ解消のための3つの要件とは ~TippingPoint Technical Forumレポート~

tipping pointでは、
「Slammer」は1月下旬に20万台近く、「Windows RPCワーム」は2月上旬に3千台近く

webへの攻撃が多く,phpファイルインクルード、SQLいんじぇくしょん、XSSで66%
phpファイルインクルードは、ほとんどゼロデイ

|

RSS: IPS/IDS location suggestions in Network.

http://seclists.org/focus-ids/2008/Mar/0003.html
gigabit IDS: GX6116, IBM appliances (ISS+Proventia).

|

2008年3月19日 (水)

懐石

とあるアプリケションのrecvを解析いたすましふぁ

●IDA pro
importでwsa見つかりませず 調査中

●OllyDBG
shift + F10
search for name in all modules で,

All names, item 16245
Address=760272B5 WS2_32
Section=.text
Type=Export (Known)
Name=WSARecv

●うさみみハリケーン

デバッグ モジュール別参照関数表示
WSOCK32.DLL
WS2_32.dll IAT 74141000 start address 760272B5

●Dependency walker

WSARecv 0x6C9F72B5 0x000072B5
とかでアドレス一致せず

●スペシャルねこまんま57号
コントローラとしてはすごそう API情報の出し方は調べ中

●Tsearch
プロセスメモリエディタなのでAPIチェッカとはない??
調査中

|

2008年3月17日 (月)

XEN NAT モード その2

追加:ドメインUからゲートウェイのアドレスにpingは通らない模様

OSの挙動を見るのに、静かなネットワークでありたいときがあるだろう。。
XENのNATモードをつかいませぅ

UBUNTUでやりました

xend-config.sxpを修正

## Use the following if network traffic is routed with NAT, as an alternative
# to the settings for bridged networking given above.
(network-script network-nat)
(vif-script vif-nat)

NATの部分をコメントアウと

ドメインブートスクリプト
name="sarge"
memory=128
kernel="/boot/vmlinuz-2.6.*-xen"
nics=1
ip="192.168.1.2"
netmask="255.255.255.0"
gateway="192.168.1.128"
#vif=['ip=192.168.0.2']
vif=['ip=192.168.1.2']
disk=['file:/etc/xen/images/sarge-root.img,sda1,w','file:/etc/xen/images/sarge-swap.img,sda2,w']
root="/dev/sda1 ro"

このようかく

ゲストOSのねっとわーくスクリプト変更
sarge-xen-guest:/etc/network# more interfaces
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.128

起動すると、土間院0のVIFにこのようなアドレスが。。

vif1.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF
inet addr:192.168.1.129 Bcast:0.0.0.0 Mask:255.255.255.255
inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:15 errors:0 dropped:0 overruns:0 frame:0
TX packets:15 errors:0 dropped:6 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1162 (1.1 KiB) TX bytes:1642 (1.6 KiB)

これで、ping 192.168.1.2 / 129 とかやると通じする

こんなで必要条件は満たしているとおもふが。。

|

2008年3月13日 (木)

RSS: トレンドマイクロのWebページが改ざん--日米のWebサーバが攻撃される

トレンドマイクロのWebページが改ざん--日米のWebサーバが攻撃される
http://japan.zdnet.com/security/story/0,3800079245,20369271,00.htm

|

RSS: 日本のIPS導入状況は~専業ベンダTippingPoint相馬社長(1)

日本のIPS導入状況は~専業ベンダTippingPoint相馬社長(1)
https://www.netsecurity.ne.jp/3_11159.html

|

2008年3月 5日 (水)

arch/i386/kernel/asm-offsets.c:79: error: impossible constraint in ‘asm’

root@flare-desktop:/usr/src/xen-3.1.0-src/linux-2.6.18-xen# time make
scripts/kconfig/conf -s arch/i386/Kconfig
CHK include/linux/version.h
CHK include/linux/utsrelease.h
CC arch/i386/kernel/asm-offsets.s
arch/i386/kernel/asm-offsets.c: In function ‘foo’:
arch/i386/kernel/asm-offsets.c:79: 警告: asm operand 0 probably doesn’t match constraints
arch/i386/kernel/asm-offsets.c:79: error: impossible constraint in ‘asm’
make[1]: *** [arch/i386/kernel/asm-offsets.s] エラー 1
make: *** [prepare0] エラー 2

real 0m0.551s
user 0m0.416s

該当箇所

DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
DEFINE(VDSO_PRELINK, VDSO_PRELINK);

OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);

なので、VDSOとやらをOFFにシマスタ

CONFIG_HZ=250
CONFIG_KEXEC=y
CONFIG_CRASH_DUMP=y
CONFIG_PHYSICAL_START=0x100000
CONFIG_HOTPLUG_CPU=y
CONFIG_COMPAT_VDSO=n
CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y

|

2008年3月 4日 (火)

RSS: Worries over "good worms" rise again

http://www.securityfocus.com/news/11506?ref=rss

|

2008年3月 1日 (土)

fc6 コンパイル on kvm qemu

fc6 linux カーネルをkvm qemu(49)上でコンパイルしました

ですが、ブート時に、
not syncing attempted to kill init
が出ますので、コンパイルオプションいろいろ変えましたが、
ダメですた

結局、menu.lstにて
nmi_watchdog=0
を追加しましたらうまくいきマスタ

|

a brief survey of XEN grant table 03/01

a brief survey of grant table XEN
02/26/2008

The first mode of use allows domA to grant domB access to a specific frame,
whilst retaining ownership. The block front driver uses this to grant memory
access to the block back driver, so that it may read or write as requested.

1. domA creates a grant access reference, and transmits the ref id to domB.
2. domB uses the reference to map the granted frame.
3. domB performs the memory access.
4. domB unmaps the granted frame.
5. domA removes its grant.

gnttab_claim and gnttab_grant is used by

1)
rx in tpmfront.c

2)
allocate rx buffer in netfront.c
start_xmit in netfront.c

3)
blk_queue_request in blkfront.c

-- tpmfront.c

tpmfront has only rx utility.
alloc -> claim -> grant -> release ?
claim / grant is used by rx.

1[tpmfront.c] 284 static void destroy_tpmring(struct tpm_private *tp)

gnttab_end_foreign_access

2[tpmfront.c] 574 static void tpmif_rx_action(unsigned long priv)
gnttab_release_grant_reference

3[tpmfront.c] 563 static int tpm_xmit(struct tpm_private *tp,
const u8 * buf, size_t count, int isuserbuffer,
void *remember)

gnttab_claim_grant_refenrece
tx->ref = gnttab_claim_grant_reference(&gref_head);

4[tpmfront.c] 660 static int tpm_xmit(struct tpm_private *tp,
const u8 * buf, size_t count, int isuserbuffer,
void *remember)

gnttab_grant_foreign_access_ref
gnttab_grant_foreign_access_ref( tx->ref, tp->backend_id,(tx->addr >>
PAGE_SHIFT),0); 0 = R/W.


5[tpmfront.c] 737 static int __init tpmif_init(void)
gnttab_alloc_grant_references

6[tpmfront.c] 752 static void __exit tpmif_exit(void)
gnttab_free_grant_references

--- netfront.c ----

netfront has rx/tx utilities.
claim / grant is used by rx / xmit.

1[netfront.c] 481 static void network_tx_buf_gc(struct net_device *dev)

gnttab_query_foreign_access

2[netfront.c] 488 static void network_tx_buf_gc(struct net_device *dev)
gnttab_end_foreign_access

3[netfront.c] 490 static void network_tx_buf_gc(struct net_device *dev)
gnttab_release_grant_reference

4[netfront.c] 515 static void network_tx_buf_gc(struct net_device *dev)
out:
gnttab_empty_grant_references

-----

about rx, claim -> grant

5[netfront.c] 592 static void network_alloc_rx_buffers(struct net_device *dev)
gnttab_claim_foreign_reference

6[netfront.c] 594 static void network_alloc_rx_buffers(struct net_device *dev)
gnttab_grant_foreign_transfer_ref

-----

about xmit, claim -> grant
7[netfront.c] 693 static int network_start_xmit(struct sk_buff *skb,
struct net_device *dev)
gnttab_claim_grant_reference

8[netfront.c] 697 static int network_start_xmit(struct sk_buff *skb,
struct net_device *dev)
gnttab_grant_foreign_access_ref

-----

9[netfront.c] 717 static int network_start_xmit(struct sk_buff *skb,
struct net_device *dev)
gnttab_empty_grant_references

10[netfront.c] 798 static int netif_poll(struct net_device *dev, int *pbudget)
gnttab_end_foreign_transfer_ref

11[netfront.c] 812 static int netif_poll(struct net_device *dev, int *pbudget)
gnttab_release_grant_reference

12[netfront.c] 1021 static void network_connect(struct net_device *dev)
gnttab_grant_foreign_access_ref

13[netfront.c] 1045 static void network_connect(struct net_device *dev)
gnttab_grant_foreign_transfer_ref

14[netfront.c] 1093 static void netif_uninit(struct net_device *dev)
gnttab_free_grant_references

15[netfront.c] 1152 static int create_netdev(int handle, struct
xenbus_device *dev,
struct net_device **val)
gnttab_alloc_grant_references

16[netfront.c] 1154 static int create_netdev(int handle, struct
xenbus_device *dev,
struct net_device **val)
gnttab_alloc_grant_references

17[netfront.c] 1156 static int create_netdev(int handle, struct
xenbus_device *dev,
struct net_device **val)
gnttab_free_grant_references

18[netfront.c] 1307 static void end_access(int ref, void *page)
gnttab_end_foreign_access

--- blkfront.c ---

claim / grant is used by queue_request.

1[blkfrtont.c] 502 static int blkif_queue_request(struct request *req)
gnttab_alloc_grant_refereces

2[blkfrtont.c] 504 static int blkif_queue_request(struct request *req)
gnttab_request_free_callback

-----

3[blkfrtont.c] 532 static int blkif_queue_request(struct request *req)
gnttab_claim_grant_reference

ref = gnttab_claim_grant_reference(&gref_head);

4[blkfrtont.c] 535 static int blkif_queue_request(struct request *req)
gnttab_grant_foreign_access_ref

gnttab_grant_foreign_access_ref(ref,
info->xbdev->otherend_id,
buffer_mfn,
rq_data_dir(req) );

-----

5[blkfrtont.c] 559 static int blkif_queue_request(struct request *req)
gnttab_free_grant_referecnes

6[blkfrtont.c] 689 static void blkif_free(struct blkfront_info *info,
int suspend)
gnttab_end_foreign_access

7[blkfrtont.c] 704 static void blkif_completion(struct blk_shadow *s)
gnttab_end_foreign_access

8[blkfrtont.c] 742 static void blkif_recover(struct blkfront_info *info)
gnttab_grant_foreign_access_ref

|

2008年2月29日 (金)

a brief survey of XEN grant table 02/29

a brief survey of XEN grant table
02/29/2008
setup of shared ring I

-- blkfront.c ---
static int setup_blkring(struct xenbus_device *dev,
struct blkfront_info *info)
{
blkif_sring_t *sring;
int err;

--- netfront.c ---
static int setup_device(struct xenbus_device *dev, struct netfront_info *info)
{
netif_tx_sring_t *txs;
netif_rx_sring_t *rxs;
int err;
struct net_device *netdev = info->netdev;

[1] setting up the structure with GRANT_INVALID_REF

--- blkfront.c ---
info->ring_ref = GRANT_INVALID_REF

--- netfront.c ---
info->tx_ring_ref = GRANT_INVALID_REF;
info->rx_ring_ref = GRANT_INVALID_REF;
info->rx.sring = NULL;
info->tx.sring = NULL;
info->irq = 0;

[2] setting up the structure with __get_free_page(GFP_KERNEL)

--- blkfront.c ---
sring = (blkif_sring_t *)__get_free_page(GFP_KERNEL);
if (!sring) {
xenbus_dev_fatal(dev, -ENOMEM, "allocating shared ring");
return -ENOMEM;
}

--- netfront.c ---
txs = (netif_tx_sring_t *)__get_free_page(GFP_KERNEL);
if (!txs) {
err = -ENOMEM;
xenbus_dev_fatal(dev, err, "allocating tx ring page");
goto fail;
}
rxs = (netif_rx_sring_t *)__get_free_page(GFP_KERNEL);
if (!rxs) {
err = -ENOMEM;
xenbus_dev_fatal(dev, err, "allocating rx ring page");
goto fail;
}

/* special to netfront */
memset(txs, 0, PAGE_SIZE);
memset(rxs, 0, PAGE_SIZE);
info->backend_state = BEST_DISCONNECTED;

[3] initializing RING

--- blkfront.c ---
SHARED_RING_INIT(sring);
FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE);

--- netfront.c ---
SHARED_RING_INIT(txs);
FRONT_RING_INIT(&info->tx, txs, PAGE_SIZE);

SHARED_RING_INIT(rxs);
FRONT_RING_INIT(&info->rx, rxs, PAGE_SIZE);

[4] xenbus_grant_ring

--- blkfront.c ---
err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring));
if (err < 0) {
printk("DEVICEFRONT: xenbus_grant_ring failed \n");
free_page((unsigned long)sring);
info->ring.sring = NULL;
goto fail;
}
info->ring_ref = err;

--- netfront.c ---
err = xenbus_grant_ring(dev, virt_to_mfn(txs));
if (err < 0)
goto fail;
info->tx_ring_ref = err;

err = xenbus_grant_ring(dev, virt_to_mfn(rxs));
if (err < 0)
goto fail;
info->rx_ring_ref = err;

#define __get_free_page(gfp_mask) \

__get_free_pages((gfp_mask),0)

* 1ページを取得、アドレスを返す
o メモリの取得に失敗した場合 0
o see also __get_free_pages()

|

RSS: KDDIやGoogleら、日米間光海底ケーブルネットワーク「Unity」の共同建設協定を締結

KDDIやGoogleら、日米間光海底ケーブルネットワーク「Unity」の共同建設協定を締結
http://japan.cnet.com/news/com/story/0,2000056021,20368189,00.htm?ref=rss

DWDM 高密度波長分割多重方式
波長の異なる光ビームは互いに干渉しないという性質があるそうな

そのため、WDMでは
光ファイバを多重利用できる(波長の違う光信号を使えば?)そうな。

http://ja.broadcom.com/products/Data-Telecom-Networks/DWDM-Transport-Processor
10Gとかでるヨウダ~

|

RSS: 米VMware、セキュリティ技術「VMsafe」を発表、APIを提供

米VMware、セキュリティ技術「VMsafe」を発表、APIを提供
http://opentechpress.jp/security/article.pl?sid=08/02/28/0732207&from=rss

|

kvm nat 設定

qemu-system-** -net nic -net tap **.img
しますと、
ホスト側では172.20.0.1が割り当てられ枡

そのため、ゲスト側では、172.20.0.2を割り当てますて

**
**
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -j MASQUERADE

のようなことをした島すると、つながりもうしあげますた

/etc/qemu-ifup には、
#!/bin/sh

#switch=$(/sbin/ip route list | awk '/^default / { print $NF }')
/sbin/ifconfig $1 172.20.0.1 up
#/usr/sbin/brctl addif ${switch} $1
のようなものにし申し上げまつるる

|

2008年2月28日 (木)

RSS: ヒッポネン氏が警告「マルウェアを作る敵は変化した」

マルウェアもスパムも「状況は悪化」
ヒッポネン氏が警告「マルウェアを作る敵は変化した」
2008/02/27
http://www.atmarkit.co.jp/news/200802/27/fsecure.html

|

2008年2月27日 (水)

ubuntu 起動スクリプト

/etc/init.d/スクリプト
update-rc.d スクリプト defaults 99 1

|

2008年2月24日 (日)

Dbghelp.h

システマなプログラムをコンパイルする場合、
Dbghelp.hがないという鰓がでる場合がありますが

LINK : fatal error LNK1104: ファイル "dbghelp.lib" を開けません。

windows platform SDKを入れ、
Windows® Server 2003 SP1 Platform SDK Web Install

C:\Program Files\Microsoft Platform SDK\Libから、
dbghelp.h dbghelp.libをフォルダにコピーしてコンパイルしました

|

2008年2月23日 (土)

XEN: gnttab_claim_grant_reference

static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
unsigned short id;
struct netfront_info *np = netdev_priv(dev);
netif_tx_request_t *tx;
RING_IDX i;
grant_ref_t ref;

// Reference to a grant entry in a specified domain's grant table.

typedef uint32_t grant_ref_t;
ref = gnttab_claim_grant_reference(&np->gref_tx_head);

// netfront.c

struct netfront_info
{
#define TX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256)
grant_ref_t gref_tx_head;
grant_ref_t grant_tx_ref[NET_TX_RING_SIZE + 1];
grant_ref_t gref_rx_head;
grant_ref_t grant_rx_ref[NET_TX_RING_SIZE + 1];

というわけで、
ref = gnttab_claim_grant_reference(&np->gref_tx_head);は

すべてunsignedが引数ということになるのですな~ ?

|

xen gnttab_query_foreign_access

netfront.c

do {
prod = np->tx.sring->rsp_prod;
rmb(); /* Ensure we see responses up to 'rp'. */

for (i = np->tx.rsp_cons; i != prod; i++) {
id = RING_GET_RESPONSE(&np->tx, i)->id;
skb = np->tx_skbs[id];
if (unlikely(gnttab_query_foreign_access(
np->grant_tx_ref[id]) != 0)) {
printk(KERN_ALERT "network_tx_buf_gc: warning "
"-- grant still in use by backend "
"domain.\n");
goto out;
}

gnttab_query_foreign_access( np->grant_tx_ref[id])

grant_tx_refはなんぞやといふ話になるが。。

これは、grant_table.hに、
/***********************************
* GRANT TABLE QUERIES AND USES
*/

/*
* Reference to a grant entry in a specified domain's grant table.
*/
typedef uint32_t grant_ref_t;

/*
* Handle to track a mapping created via a grant reference.
*/
typedef uint32_t grant_handle_t;

として定義されてお~る。

int
gnttab_query_foreign_access(grant_ref_t ref)
{
u16 nflags;

nflags = shared[ref].flags;

return (nflags & (GTF_reading|GTF_writing));
}

えらいシンプルな関数ですが。。

|

2008年2月22日 (金)

仮想サーバの脆弱性は仮想マシンにあり――研究者がBlack Hatで講演へ

http://www.computerworld.jp/news/sec/98649.html

|

Xen ドライバ 追加 1

linux/.configに
CONFIG_XEN_TEST_FRONTEND=y
CONFIG_XEN_TEST_BACKEND=y
を追加

#
# XEN
#
CONFIG_XEN_PRIVILEGED_GUEST=y
# CONFIG_XEN_UNPRIVILEGED_GUEST is not set
CONFIG_XEN_BACKEND=y
CONFIG_XEN_PCIDEV_BACKEND=m
CONFIG_XEN_PCIDEV_BACKEND_VPCI=y
# CONFIG_XEN_PCIDEV_BACKEND_PASS is not set
# CONFIG_XEN_PCIDEV_BE_DEBUG is not set
CONFIG_XEN_BLKDEV_BACKEND=y
# CONFIG_XEN_BLKDEV_TAP_BE is not set
CONFIG_XEN_NETDEV_BACKEND=y
# CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
CONFIG_XEN_NETDEV_LOOPBACK=y
# CONFIG_XEN_TPMDEV_BACKEND is not set
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
# CONFIG_XEN_BLKDEV_TAP is not set
CONFIG_XEN_TPMDEV_FRONTEND=m
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DISABLE_SERIAL=y
CONFIG_XEN_SYSFS=y
CONFIG_XEN_TEST_FRONTEND=y
CONFIG_XEN_TEST_BACKEND=y
CONFIG_HAVE_ARCH_ALLOC_SKB=y
CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
CONFIG_NO_IDLE_HZ=y

drivers/xen/Makefile修正
obj-y += net_driver_util.o
obj-y += util.o

obj-y += core/
obj-y += char/
obj-y += console/
obj-y += evtchn/
obj-y += balloon/
obj-y += privcmd/
obj-y += xenbus/

obj-$(CONFIG_XEN_BLKDEV_BACKEND) += blkback/
obj-$(CONFIG_XEN_NETDEV_BACKEND) += netback/
obj-$(CONFIG_XEN_TPMDEV_BACKEND) += tpmback/
obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += blkfront/
obj-$(CONFIG_XEN_NETDEV_FRONTEND) += netfront/
obj-$(CONFIG_XEN_BLKDEV_TAP) += blktap/
obj-$(CONFIG_XEN_TPMDEV_FRONTEND) += tpmfront/
obj-$(CONFIG_XEN_PCIDEV_BACKEND) += pciback/
obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += pcifront/
obj-$(CONFIG_XEN_TEST_BACKEND) += deviceback/
obj-$(CONFIG_XEN_TEST_FRONTEND) += devicefront/

drivers/Kconfigに追加
config XEN_TEST_FRONTEND
tristate "Xen test frontend driver"
depends on XEN
default y
help
Xen Test Frontend Driver

config XEN_TEST_BACKEND
tristate "Xen test backend driver"
depends on XEN
default y
help
Xen Test backend Driver

|

2008年2月20日 (水)

tcpdump

tcpdump -i virbr0 -s 65535 -nw file.dmp

|

2008年2月19日 (火)

もっとも影響力を持つセキュリティ専門家は誰か

http://japan.zdnet.com/security/story/0,3800079245,20367309,00.htm

|

2008年2月17日 (日)

VB ファイル実行

visual basicで任意のファイルを実行させる

shell, "c:\test.exe", vbNormalForcus

|

2008年2月13日 (水)

fedora xen ブリッジ設定

fedora 7 に xen-3.1.0を入れますタ

yumでこれらを入れます田
yum install bridge-utils dnsmasq virt-viewer

xmexample.hvmを修正して
#----------------------------------------------------------------------------
# enable SDL library for graphics, default = 0
sdl=1

#----------------------------------------------------------------------------
# enable VNC library for graphics, default = 1
vnc=0

sdlにして起動したら、ブリッジでIPで取れました。

朕思ふに、fedora6ではうまくいかなかったりでしたが、fedora7ではそれが修正されたのでは??
ただし、ハードウェアによって異なると思われ枡

.hvmファイル修正

ブリッジで直接
vif = [ 'type=ioemu, bridge=xenbr0' ]
#vif = [ 'type=ioemu, bridge=virbr0' ]

プライベトアドで NAT
#vif = [ 'type=ioemu, bridge=xenbr0' ]
vif = [ 'type=ioemu, bridge=virbr0' ]

このように致し申し上げました

ただし、2つのネットワーク環境で試したところ、
一方は、ブリッジ成功したが、一方は駄目でした

関連DHCPやらのネットワーク状況も関連すると思われ枡

|

2008年2月 4日 (月)

xen xc_domain_save

int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
uint32_t max_factor, uint32_t flags, int (*suspend)(int),
int hvm, void *(*init_qemu_maps)(int, unsigned),
void (*qemu_flip_buffer)(int, int))
{
/* Live mapping of shared info structure */
shared_info_t *live_shinfo = NULL;

このような関数がある。

shared_info構造体をダンディー坂田

/* Map the shared info frame */
if ( !hvm )
{
// DPRINTF("[xc_domain_save.c][xc_domain_save] Map the shared info Frame \n");

live_shinfo = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
PROT_READ, shared_info_frame);
if ( !live_shinfo )
{
ERROR("Couldn't map live_shinfo");
goto out;
}
}

xen.h

typedef union {
struct shared_info native;
struct compat_shared_info compat;
} shared_info_t;

struct shared_infoはじゅうやうな構造体でありますて
pendingやらmaskやらがありまする

struct shared_info {
struct vcpu_info vcpu_info[MAX_VIRT_CPUS];

/*
* A domain can create "event channels" on which it can send and receive
* asynchronous event notifications. There are three classes of event that
* are delivered by this mechanism:
* 1. Bi-directional inter- and intra-domain connections. Domains must
* arrange out-of-band to set up a connection (usually by allocating
* an unbound 'listener' port and avertising that via a storage service
* such as xenstore).
* 2. Physical interrupts. A domain with suitable hardware-access
* privileges can bind an event-channel port to a physical interrupt
* source.
* 3. Virtual interrupts ('events'). A domain can bind an event-channel
* port to a virtual interrupt source, such as the virtual-timer
* device or the emergency console.
*
* Event channels are addressed by a "port index". Each channel is
* associated with two bits of information:
* 1. PENDING -- notifies the domain that there is a pending notification
* to be processed. This bit is cleared by the guest.
* 2. MASK -- if this bit is clear then a 0->1 transition of PENDING
* will cause an asynchronous upcall to be scheduled. This bit is only
* updated by the guest. It is read-only within Xen. If a channel
* becomes pending while the channel is masked then the 'edge' is lost
* (i.e., when the channel is unmasked, the guest must manually handle
* pending notifications as no upcall will be scheduled by Xen).
*
* To expedite scanning of pending notifications, any 0->1 pending
* transition on an unmasked channel causes a corresponding bit in a
* per-vcpu selector word to be set. Each bit in the selector covers a
* 'C long' in the PENDING bitfield array.
*/
unsigned long evtchn_pending[sizeof(unsigned long) * 8];
unsigned long evtchn_mask[sizeof(unsigned long) * 8];

/*
* Wallclock time: updated only by control software. Guests should base
* their gettimeofday() syscall on this wallclock-base value.
*/
uint32_t wc_version; /* Version counter: see vcpu_time_info_t. */
uint32_t wc_sec; /* Secs 00:00:00 UTC, Jan 1, 1970. */
uint32_t wc_nsec; /* Nsecs 00:00:00 UTC, Jan 1, 1970. */

struct arch_shared_info arch;

};

arch_shared_infoは、xen/include/public/arch-x86/xen.hにありますて、

struct arch_shared_info {
unsigned long max_pfn; /* max pfn that appears in table */
/* Frame containing list of mfns containing list of mfns containing p2m. */
xen_pfn_t pfn_to_mfn_frame_list_list;
unsigned long nmi_reason;
uint64_t pad[32];
};
typedef struct arch_shared_info arch_shared_info_t;


|

Microblaze

Microblazeにブレーク信号を追加する方法
http://www.cqpub.co.jp/interface/default.asp

|

モデル検査

デルモ検査では、システムは、

変数と、
状態遷移ルール

で与えられる。

A(0,1,2)
B(0,1,2)
C(0,1,2)
O(0,1)

変数だけ考えれば、このデルモは、3*3*3*2=54通りの状態
があるわけだが。。実際には、
状態遷移ルールがあるので、そのうちの10とか、20の状態しかとらないということになる。

はなしは簡単で、知りたいことは、おそらくですが、

その1:マズイ状態になるか否か。 
   オーバーフローがおきかどうか
   勝手にスタートするか

これは、安全性(ある状態にはけっしてならない)
裏返すと、可達性の否定になる。

その2:デルモがちゃんと反応するかどうか。

用は、ループして黙りこむとこまるという話である。
これは、デッドロックといい、プログラマをよく狂わせる。
この場合、どのような入力を入れても反応しない。
これは、公平性(ある状態がなんども起こる)のぎゃくなのかどうかは、知りませぬ。

なので、変数だけ見た場合のくみあわせ全状態群から、状態遷移ルールを使って、

どのような状態にいくのか 安全性 かたつせい
ループはあるのか、あれば、それはまずぃループなのか 活性 公平性
ループすると反応しないので

を検査するのがモデル検査らすぃ

この状態とループの有無をチェックするのが、LTL式と呼ばれるものである。

なので、モデル検査プログは、

変数
遷移系記述
検査項目(LTL 様相論理しき)

の3つから構成されるのでありんした

-------

痴的なアドバンスド デルモ検査

応用として、デルモを2つにすることができる。

ループ検出の応用として、1つのデルモがループに入った場合、
並行システムがうまく実装されていないことを検出することができるらすい

とにかくシステマにおいうては
ループというのは厄介になる場合があるので、検討が必要なのである

1)共有領域で、ループに入られると、他のでモルはそこに入れない。
これはまずいのであるらすぃ

2)また、システムを2つ用意し、変数{共有領域/IN}とかして、
同時に2つのシステムがこの状態になるとまずいのでありますから、
これを検出シマス

イヤ~ンな部分では、複数が、入れ替わり
出たり入ったりしないといけない。

複数が同時に入ったり触れたり、
ひとつがそこで入ったまま惚けてとまってはいけぬのである。

だからこそマイッチングな部分なのである。

|

2008年2月 2日 (土)

spartan3E starter kit

http://www.xilinx.com/products/boards/s3estarter/reference_designs.htm
ココからはじめることにした。

Using SPI Serial Flash
ですが、hello worldというアプリケーションがあるので、
ソースをみましたら、

int main (void) {

print("\n\rHello World\n\r");

return 0;
}

となっておりましろ。この場合、
miroblazeの上には、なにが載っておるのでせぅ
簡単なブートローダでしょうか??

聞けば、GDBや、ELFの話があると聞く。。
どうなっておるのやら??

いつの間に。。これは、すげぇ~

Microblaze uClinux Project Home Page
http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux/

atmarkのSUZAKUがspartan3Eを。。。
http://suzaku.atmark-techno.com/series/suzaku-s

|

2008年1月31日 (木)

XEN ホットプラグ ドライバ

XENにホットプラグ系のドライバを組み込む場合

/etc/udev/xend-backend.rules
SUBSYSTEM=="xen-backend", KERNEL=="vbd*", RUN+="/etc/xen/scripts/block $env{ACTION}"
SUBSYSTEM=="xen-backend", KERNEL=="vtpm*", RUN+="/etc/xen/scripts/vtpm $env{ACTION}"
SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="online", RUN+="$env{script} online"
SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="offline", RUN+="$env{script} offline"
SUBSYSTEM=="xen-backend", KERNEL=="test*", RUN+="/etc/xen/scripts/test"
SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/etc/xen/scripts/xen-hotplug-cleanup"

ホットプラグスクリプトはこのようにした。とりあえずこれでとまらぬる

/etc/xen/scprits/test

#!/bin/sh

dir=$(dirname "$0")
. "$dir/xen-hotplug-common.sh"

#if [ "$command" == "online" ]
#then
success
#fi

|

RSS: Home Router Hacks

http://blogs.technet.com/staysafe/archive/2008/01/24/home-router-hacks-voip-phishing-driveby-pharming.aspx

|

2008年1月30日 (水)

XEN / netfront.c

network_tx_buf_gc

np->tx_skbs[id]のバッファを、skbに入れて、割り込み立ち上げ
dev_kfree_skb_irq(skb);

for (i = np->tx.rsp_cons; i != prod; i++) {
id = RING_GET_RESPONSE(&np->tx, i)->id;

printk("[netfront.c][network_tx_buf_gc] skb=np->tx_skbs[id] \n");
skb = np->tx_skbs[id];

クエリー
if (unlikely(gnttab_query_foreign_access(
np->grant_tx_ref[id]) != 0)) {
printk(KERN_ALERT "network_tx_buf_gc: warning "
"-- grant still in use by backend "
"domain.\n");
goto out;
}

  アクセス
gnttab_end_foreign_access_ref(
np->grant_tx_ref[id], GNTMAP_readonly);

           リリース
gnttab_release_grant_reference(
&np->gref_tx_head, np->grant_tx_ref[id]);
np->grant_tx_ref[id] = GRANT_INVALID_REF;
add_id_to_freelist(np->tx_skbs, id);
dev_kfree_skb_irq(skb);
}

netdevice.h

static inline void dev_kfree_skb_irq(struct sk_buff *skb)
{ if (atomic_dec_and_test(&skb->users)) {
struct softnet_data *sd;
unsigned long flags;
local_irq_save(flags);
sd = &__get_cpu_var(softnet_data);
skb->next = sd->completion_queue;
sd->completion_queue = skb;
raise_softirq_irqoff(NET_TX_SOFTIRQ);
local_irq_restore(flags);
}
}

|

2008年1月 9日 (水)

Windows カーネル API Hook

ZwOpenProcessを対象とするとしますと。。。

InterlockedExchangeを使う。
http://msdn.microsoft.com/library/ja/default.asp?url=/library/ja/jpdllpro/html/_win32_interlockedexchange.asp

HookedZwOpenProcess = (ZW_OPEN_PROCESS)
InterlockedExchange((PLONG)
&SYSTEM_SERVICE(ZwOpenProcess),
(ULONG)ReplaceZwOpenProcess);

NTSYSAPI NTSTATUS NTAPI
ZwOpenProcess(PHANDLE, ACCESS_MASK,
POBJECT_ATTRIBUTES, PCLIENT_ID);
もとをこのやふに書いておく。

HookedZwOpenProcessと、ReplaceZwOpenProcess、
ZW_OPEN_PROCESSは定義しておく必要がある。

ZW_OPEN_PROCESSは、はじめの方で、
typedef NTSTATUS (*ZW_OPEN_PROCESS)
(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, PCLIENT_ID);

引数は、特有の型のようなので、
http://msdn2.microsoft.com/en-us/library/aa491525.aspx
あたりを見て調べる。

HookedZwOpenProcessは、その後このように定義する。
ZW_OPEN_PROCESS HookedZwOpenProcess = NULL;

その後、置き換える関数を書く。
NTSTATUS ReplaceZwOpenProcess(PHANDLE ProcessHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
PCLIENT_ID ClientId)
{

NTSTATUS NtStatus = HookedZwOpenProcess(....)
}


|

2008年1月 8日 (火)

再帰

関数型言語では、繰り返しにforルプはつかへませぬ
再帰をつかいまふ

再帰というのをずらずら調べていくと、
不動点定理といふものででてきよる

Banachの不動店定理
Tarskiの不動店てひり

不動点定理は、昔、ミクロ経済学ででてきよった
需給均衡があるということを保障するものであったよふな

このばあひは??

再帰プロぐらむは、写像の不動店として解釈することができる。
となると、どうなるのでせぅか?(調査中
とりあへず、フドウ点ていりは、再帰動作の解析につかへるらすぃ

再帰演算子は、カリー(ハスケル)とチューリングのとがあるやうな
しまいにゃ~、ゲデルなど降臨なさいこそあらめ

領域理論、
今は昔、凸理論と非線形解析とかでてきよりて、いみじけれ

|

2008年1月 7日 (月)

KVM スナプショー

KVMのスナップショットは、qcow2で対応いたしておりまする
rawイメジではオリョプショ~
hdaはsupoortされていないとか出るなり

qemu-img convert -f raw w2k.img -O qcow2 w2k.qcow2.img
としますれはスナップがとれプショ~

-f raw
がないと could not open *.img とか出るめれ
あればケンチャナヨ~

|

2008年1月 6日 (日)

モデル検査

モデル検査には、CTL(分岐)、LTL(線形)の2つを用いる。

メジャーになっておりますのはLTL???
SPINとかでつかはれてるならめ

作法といたすますては
状態遷移系を記述。
しらべたい性質を、時相論理式として記述。

すると、時相論理式からステートマシンを
生成しますでして、それを、ユーザが記述した
状態遷移系と比較(合成)するらむ

LTLは、ステートマスンが生成する
実行系列を検査すます。

そのため、決定性と非決定性の
ステトマスンが生成する実行系列が
同じであれば、両者を識別できない。

逆にこれは、保存定理といいますて、
利点でもあるめり。

といふわけですて
時相論理式からステーチョマスンが生成
できハムニダ

ステートマシンの生成合成表示には、
GUIのあるSPINやらLTSAが便利だそうな。


|

2007年12月28日 (金)

news

http://japan.cnet.com/column/rwweb/story/0,2000090739,20363895,00.htm?ref=rss
ソーシャルニュースサイト digg
http://ja.wikipedia.org/wiki/Digg

What’s the real story on the Windows Home Server data corruption bug?
http://blogs.zdnet.com/Bott/?p=348

情報流出の事後対策経費は増加の一途
http://techtarget.itmedia.co.jp/tt/news/0712/27/news01.html

クリスマスのWinny利用は微減――ネットエージェント調べ
http://www.itmedia.co.jp/enterprise/articles/0712/27/news035.html
調査期間は12月22~25日の4日間で、平均33万強のノード数が観測

|

2007年12月26日 (水)

バイナリコード でおじゃるるれば

section .text
global _start

msg db 'hello, binary', 0x0A
msglength equ $ - msg

_start:
mov ecx, msg
mov edx, msglength
mov eax, 4
mov ebx, 1
int 0x80
mov eax, 1
mov ebx, 0
int 0x80

こういうコードがあったとする。。

root@:~/ex_asm# objdump -Sd hello

hello: file format elf32-i386

Disassembly of section .text:

08048060 <.text>:
8048060: 68 65 6c 6c 6f push $0x6f6c6c65
8048065: 2c 20   sub $0x20,%al
8048067: 62 69 6e  bound %ebp,0x6e(%ecx)
804806a: 61    popa
804806b: 72 79   jb 0x80480e6
804806d: 0a b9 60 80 04 08 or 0x8048060(%ecx),%bh
8048073: ba 0e 00 00 00 mov $0xe,%edx
8048078: b8 04 00 00 00 mov $0x4,%eax
804807d: bb 01 00 00 00 mov $0x1,%ebx
8048082: cd 80   int $0x80
8048084: b8 01 00 00 00 mov $0x1,%eax
8048089: bb 00 00 00 00 mov $0x0,%ebx
804808e: cd 80   int $0x80

root@:~/ex_asm# hexdump -C hello
00000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
00000010 02 00 03 00 01 00 00 00 6e 80 04 08 34 00 00 00 |........n...4...|
00000020 cc 00 00 00 00 00 00 00 34 00 20 00 01 00 28 00 |........4. ...(.|
00000030 04 00 03 00 01 00 00 00 00 00 00 00 00 80 04 08 |................|
00000040 00 80 04 08 90 00 00 00 90 00 00 00 05 00 00 00 |................|
00000050 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000060 68 65 6c 6c 6f 2c 20 62 69 6e 61 72 79 0a b9 60 |hello, binary..`|
00000070 80 04 08 ba 0e 00 00 00 b8 04 00 00 00 bb 01 00 |................|
00000080 00 00 cd 80 b8 01 00 00 00 bb 00 00 00 00 cd 80 |................|
00000090 00 54 68 65 20 4e 65 74 77 69 64 65 20 41 73 73 |.The Netwide Ass|
000000a0 65 6d 62 6c 65 72 20 30 2e 39 38 2e 33 38 00 00 |embler 0.98.38..|
000000b0 2e 73 68 73 74 72 74 61 62 00 2e 74 65 78 74 00 |.shstrtab..text.|
000000c0 2e 63 6f 6d 6d 65 6e 74 00 00 00 00 00 00 00 00 |.comment........|
000000d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000000f0 00 00 00 00 0b 00 00 00 01 00 00 00 06 00 00 00 |................|
00000100 60 80 04 08 60 00 00 00 30 00 00 00 00 00 00 00 |`...`...0.......|
00000110 00 00 00 00 10 00 00 00 00 00 00 00 11 00 00 00 |................|
00000120 01 00 00 00 00 00 00 00 00 00 00 00 90 00 00 00 |................|
00000130 1f 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 |................|
00000140 00 00 00 00 01 00 00 00 03 00 00 00 00 00 00 00 |................|
00000150 00 00 00 00 af 00 00 00 1a 00 00 00 00 00 00 00 |................|
00000160 00 00 00 00 01 00 00 00 00 00 00 00 |............|
0000016c

となると、テキストセクションのはじめは、
00000060 68 65 6c 6c 6f 2c 20 62 69 6e 61 72 79 0a b9 60 |hello, binary..`|
ということになりまする

とくに、
8048060: 68 65 6c 6c 6f push $0x6f6c6c65
8048065: 2c 20   sub $0x20,%al
8048067: 62 69 6e  bound %ebp,0x6e(%ecx)
804806a: 61    popa
804806b: 72 79   jb 0x80480e6
804806d: 0a b9 60 80 04 08 or 0x8048060(%ecx),%bh
は御流儀であろますので

root@:~/ex_asm# dd if=hello of=hello2 bs=116 count=1
1+0 records in
1+0 records out
116 bytes (116 B) copied, 6.1e-05 seconds, 1.9 MB/s
root@:~/ex_asm# dd if=hello of=hello2 bs=115 count=1
1+0 records in
1+0 records out
115 bytes (115 B) copied, 8.4e-05 seconds, 1.4 MB/s
root@:~/ex_asm# chmod 755 hello2
root@:~/ex_asm# ./hello2
Segmentation fault
root@:~/ex_asm# hexdump -C hello2
00000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
00000010 02 00 03 00 01 00 00 00 6e 80 04 08 34 00 00 00 |........n...4...|
00000020 cc 00 00 00 00 00 00 00 34 00 20 00 01 00 28 00 |........4. ...(.|
00000030 04 00 03 00 01 00 00 00 00 00 00 00 00 80 04 08 |................|
00000040 00 80 04 08 90 00 00 00 90 00 00 00 05 00 00 00 |................|
00000050 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000060 68 65 6c 6c 6f 2c 20 62 69 6e 61 72 79 0a b9 60 |hello, binary..`|
00000070 80 04 08 |...|
00000073

とした島すれて

root@:~/ex_asm# hexdump -C hello2
00000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
00000010 02 00 03 00 01 00 00 00 6e 80 04 08 34 00 00 00 |........n...4...|
00000020 cc 00 00 00 00 00 00 00 34 00 20 00 01 00 28 00 |........4. ...(.|
00000030 04 00 03 00 01 00 00 00 00 00 00 00 00 80 04 08 |................|
00000040 00 80 04 08 90 00 00 00 90 00 00 00 05 00 00 00 |................|
00000050 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000060 68 65 6c 6c 6f 2c 20 62 69 6e 61 72 79 0a b9 60 |hello, binary..`|
00000070 80 04 08 cc

とすますれば

root@:~/ex_asm# ./hello2
Trace/breakpoint trap

となりすれれする

プログラムセグメント ELFヘッダー プログラムヘッダー1
プログラムヘッダー2 TEXTセクションで構成されておりすれうるるれる

|

2007年12月24日 (月)

モデル検査 メモ

対象とするシステマが、とある性質をもっているかどうか検査いたしまする

このばあひ、検査対象は、ステートマシンと様相論理式(LTL)の2つがございまするる

方法1
ステーマシンを記述する。

  しらべたひ性質、システムが、行ってほすい、逝ってほしくなひ性質を反例として記述いたしますする
  調べたい性質を、LTLとして記述いたしまするる

方法2 
LTLを検査する。

  ステートマシンが生成する実行系列を検査するすい コマンド入力でできるらすい
  ステートマシンがない代わりに、ランダムに変化する乱数をつかふ

LTLからステートマシンを生成することもできるこそあらめ


|

2007年12月18日 (火)

AMD-V and Intel TXT

AMD-Vのセキュリティ機能関連

セキュアブート
secure INIT (SKINIT) : TPMと連動

悪意のあるデイバスからのDMA → External Access Protection

その他
物理 論理 アドレスの変換結果をキャッシュする
Tagged TLB
これは、Nested Page Tableといふものに続くらすぃ。。

セキュアブート
Intel TXT

DMA攻撃に対応 → Vt-d

|

2007年12月17日 (月)

にぅす

DNSSEC Is Dead, Stick a Fork in It
http://www.eweek.com/article2/0,1759,2234746,00.asp

Botnets linked to political hacking in Russia
http://www.theregister.co.uk/2007/12/14/botnet_hacktivism/

Traffic snags on Juniper router glitch
http://www.theregister.co.uk/2007/12/14/juniper_router_traffic_glitch/
BGP処理にglitchが。。

ストレージの電力効率を改善する「5つの実践」
http://opentechpress.jp/enterprise/article.pl?sid=07/12/13/054209&from=rss
2006ねんで生成されたデータ量 1610億GB
消費でんりょく サーバ 40% ストレージ37%

Spam a bigger concern than network neutrality

New MSN and P2P worms
http://www.net-security.org/malware_news.php?id=889
MSNWorm.BF and Cazdeg.A.

http://blog.tmcnet.com/regulations/international/opera-complains-to-european-commission-about-microsofts-ie-bundling.asp
Opera Complains To European Commission About Microsoft's IE Bundling

Britain teams bound for Beijing put on alert as hackers spark web of intrigue
http://seclists.org/isn/2007/Dec/0066.html

Internet poisoned by open DNS servers
http://www.cio.co.uk/news/index.cfm?RSS&ArticleID=2381

|

buffalo LPC 4-TX

axnet_csとして認識されるモヨウ

|

2007年12月12日 (水)

spartan 3E starter KIT

uClinuxがノルらしい。。すげ~

spartan 3E starter KIT
ペリフェラルは全部ついてる。うぉ~
CQの評価ボードを使っていたころがなつかすぃ。。

ISE webpackと、EDKをインストルした後にUSBを挿すと、
自動認識してくれマス。

|

2007年11月14日 (水)

XEN netfront パケット送信 その1

これは、xen特有の関数でありました
static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
これは、ハンドラの一種であらう。。

static int create_netdev(int handle, struct xenbus_device *dev,
struct net_device **val)

netdev->hard_start_xmit = network_start_xmit;
ここで登録されている

関数の内容
スピンロックをかける
spin_lock_irq(&np->tx_lock);

グラントテーブル第一弾
ref = gnttab_claim_grant_reference(&np->gref_tx_head);

グラントテーブル第2弾
gnttab_grant_foreign_access_ref(
ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly);

allocate a new entry in the grant table and fill out the access permissions
accordingly. the access permissions will be locked up by XEN when the grantee
attempts to use the reference to map the granted frame.

RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&np->tx, notify);

 不明であるが、リングバッファの操作であらう。。

 notify_remote_via_irq(np->irq);

 IRQをたたき、リモートドメインに通知 iRQはイベントチャンネルのポートに変換
 されるのであらう。。

  network_tx_buf_gc(dev);
 次に、このような関数を呼ぶ この関数の中では、

グラントテーブル第3弾
  gnttab_end_foreign_access_ref(
np->grant_tx_ref[id], GNTMAP_readonly);

グラントテーブル第4弾
   gnttab_release_grant_reference(
&np->gref_tx_head, np->grant_tx_ref[id]);

が呼ばれる。

その後, network_tx_buf_gcから復帰し、
spin_unlock_irq
スピンロック解除。

packet tx/rxではtransfer系のグラントテーブルが使われるとのうわさであったが。。
どうなんでSHOW??

|

2007年11月13日 (火)

lids_check_acl_indoe LIDS2.6

アクセスコントロールリストチェック関数でゴザイマス

static int
lids_check_acl_inode(struct inode *inode, int type)
{

struct lids_task_acl *task_acl = current->security;
struct lids_object_acl *o_acl;
struct lids_inode_acl *i_acl= inode->i_security;
//time_t currenttime;
int i=0;


if (!(task_acl && task_acl->s_acl))
return -EPERM;

while (i_acl->perm[i].sid != 0 && i< 64) {

o_acl = task_acl->s_acl->o_acl;
while(o_acl) {
if ( i_acl->perm[i].sid == o_acl->sid &&
i_acl->perm[i].oid == o_acl->oid ) {

return type & i_acl->perm[i].type ? 0 : -EPERM;
}
o_acl = o_acl->next;
}
i++;
}
return -EPERM;
}

この構造体を用いて、チェックするのでゴザイマス
struct lids_inode_acl {
__u32 magic;
__u32 type; /* READ WRITE APPEND DENY */
__u32 version; /* current vesion of acl*/
__u32 flags; /* inode flags */
struct lids_s_inode inode; /* point the the original inode */
struct lids_perm perm[64]; /* the sid/oid that have perm on this file */
struct lids_subject_acl *s_acl;
#ifdef __KERNEL__
char name[64]; /* filename of the inode */
#else
char name[PATH_MAX]; /* filename of the inode */
#endif
} __attribute__ ((__packed__)) ;

この3項演算子がポイントでゴザイマス
return type & i_acl->perm[i].type ? 0 : -EPERM;

|

2007年11月 6日 (火)

lids 2.4

Nov 6 17:16:34 tbn-office-05 kernel: [lids_tpe.c][lids_mmap_tpe_permission]
Nov 6 17:16:34 tbn-office-05 kernel: [lids_tde.c][lids_tde_policy]
Nov 6 17:16:34 tbn-office-05 kernel: [lids_tpe.c][lids_mmap_tpe_permission]
Nov 6 17:16:34 tbn-office-05 kernel: [lids_tpe.c][lids_mmap_tpe_permission]
Nov 6 17:16:34 tbn-office-05 kernel: [lids_tde.c][lids_tde_policy]
Nov 6 17:16:39 tbn-office-05 last message repeated 155300 times

ブート時に連発されますた

|

xen dev.c

オリジナル 2.6.16 カネルとの差分をとりますた

root@flare-desktop:/usr/src/diff# diff dev.c.org dev.c.xen
118a119,124
> #ifdef CONFIG_XEN
> #include
> #include
> #include
> #endif
>
1216a1223,1259
> #ifdef CONFIG_XEN
> inline int skb_checksum_setup(struct sk_buff *skb)
> {
> if (skb->proto_csum_blank) {
> if (skb->protocol != htons(ETH_P_IP))
> goto out;
> skb->h.raw = (unsigned char *)skb->nh.iph + 4*skb->nh.iph->ihl;
> if (skb->h.raw >= skb->tail)
> goto out;
> switch (skb->nh.iph->protocol) {
> case IPPROTO_TCP:
> skb->csum = offsetof(struct tcphdr, check);
> break;
> case IPPROTO_UDP:
> skb->csum = offsetof(struct udphdr, check);
> break;
> default:
> if (net_ratelimit())
> printk(KERN_ERR "Attempting to checksum a non-"
> "TCP/UDP packet, dropping a protocol"
> " %d packet", skb->nh.iph->protocol);
> goto out;
> }
> if ((skb->h.raw + skb->csum + 2) > skb->tail)
> goto out;
> skb->ip_summed = CHECKSUM_HW;
> skb->proto_csum_blank = 0;
> }
> return 0;
> out:
> return -EPROTO;
> }
> #else
> inline int skb_checksum_setup(struct sk_buff *skb) { return 0; }
> #endif
>
>
1262a1306,1311
> /* If a checksum-deferred packet is forwarded to a device that needs a
> * checksum, correct the pointers and force checksumming.
> */
> if(skb_checksum_setup(skb))
> goto out_kfree_skb;
>
1611a1661,1673
> #ifdef CONFIG_XEN
> switch (skb->ip_summed) {
> case CHECKSUM_UNNECESSARY:
> skb->proto_data_valid = 1;
> break;
> case CHECKSUM_HW:
> /* XXX Implement me. */
> default:
> skb->proto_data_valid = 0;
> break;
> }
> #endif
>
3164a3227,3228
> printk("[dev.c][dev_cpu_callback]\n");
>
3215a3280,3281
> printk("[dev.c][net_dev_init]\n");
>
3302a3369
> EXPORT_SYMBOL(skb_checksum_setup);

net_tx_actionとかの違いがある鴨南蛮と思ったのですが、
あまり変わらぬやうダーー????


|

XEN 分割ドライバ

net_tx_aciton/ net_rx_actionは、バックエンドドライバにありけり

root@flare-desktop:/usr/src/xen-unstable/linux-2.6.16-xen/drivers/xen# grep -rin net_tx_action *
バイナリー・ファイルbuilt-in.oは一致しました
netback/netback.c:55:static void net_tx_action(unsigned long unused);
netback/netback.c:56:static DECLARE_TASKLET(net_tx_tasklet, net_tx_action, 0);
netback/netback.c:446:inline static void net_tx_action_dealloc(void)
netback/netback.c:487:static void net_tx_action(unsigned long unused)
netback/netback.c:500: net_tx_action_dealloc();
バイナリー・ファイルnetback/netbk.oは一致しました
バイナリー・ファイルnetback/netback.oは一致しました
バイナリー・ファイルnetback/built-in.oは一致しました
netback/netback.c.0619.1:77:static void net_tx_action(unsigned long unused);
netback/netback.c.0619.1:78:static DECLARE_TASKLET(net_tx_tasklet, net_tx_action, 0);
netback/netback.c.0619.1:522:inline static void net_tx_action_dealloc(void)
netback/netback.c.0619.1:536: length1=sprintf(filedata,"NETBACK: net_tx_action_dealloc \n");
netback/netback.c.0619.1:564: length1=sprintf(filedata,"NETBACK: GNTTABOP_unmap_grant_ref: net_tx_action tx_unmap_ops %u, gop %u \n",
netback/netback.c.0619.1:596:static void net_tx_action(unsigned long unused)
netback/netback.c.0619.1:618: printk("Netback: net_tx_action \n");
netback/netback.c.0619.1:621: length1=sprintf(filedata,"NETBACK net_tx_action \n");
netback/netback.c.0619.1:633: net_tx_action_dealloc();
netback/netback.c.0619.1:745: length1=sprintf(filedata,"NETBACK: GNTTABOP_map_grant_ref: net_tx_action tx_map_ops %u, mop %u \n",
netback/netback.c.0619.1:835: length1=sprintf(filedata,"NETBACK net_tx_action protocol 0x%2o 0x%2x \n",
netback/#netback.c.0619.1#:77:static void net_tx_action(unsigned long unused);
netback/#netback.c.0619.1#:78:static DECLARE_TASKLET(net_tx_tasklet, net_tx_action, 0);
netback/#netback.c.0619.1#:522:inline static void net_tx_action_dealloc(void)
netback/#netback.c.0619.1#:536: length1=sprintf(filedata,"NETBACK: net_tx_action_dealloc \n");
netback/#netback.c.0619.1#:564: length1=sprintf(filedata,"NETBACK: GNTTABOP_unmap_grant_ref: net_tx_action tx_unmap_ops %u, gop %u \n",
netback/#netback.c.0619.1#:596:static void net_tx_action(unsigned long unused)
netback/#netback.c.0619.1#:618: printk("Netback: net_tx_action \n");
netback/#netback.c.0619.1#:621: length1=sprintf(filedata,"NETBACK net_tx_action \n");
netback/#netback.c.0619.1#:633: net_tx_action_dealloc();
netback/#netback.c.0619.1#:745: length1=sprintf(filedata,"NETBACK: GNTTABOP_map_grant_ref: net_tx_action tx_map_ops %u, mop %u \n",
netback/#netback.c.0619.1#:835: length1=sprintf(filedata,"NETBACK net_tx_action protocol 0x%2o 0x%2x \n",
バイナリー・ファイルnetback.08.0617.tarは一致しました
バイナリー・ファイルnetback.14.0617.tarは一致しました
root@flare-desktop:/usr/src/xen-unstable/linux-2.6.16-xen/drivers/xen# grep -rin net_rx_action *
バイナリー・ファイルbuilt-in.oは一致しました
netback/netback.c:58:static void net_rx_action(unsigned long unused);
netback/netback.c:59:static DECLARE_TASKLET(net_rx_tasklet, net_rx_action, 0);
netback/netback.c:212:static void net_rx_action(unsigned long unused)
netback/netback.c:228: // printk("[netback.c][net_rx_action]\n");
netback/netback.c:811: /* We can increase reservation by this much in net_rx_action(). */
バイナリー・ファイルnetback/netbk.oは一致しました
バイナリー・ファイルnetback/netback.oは一致しました
バイナリー・ファイルnetback/built-in.oは一致しました
netback/netback.c.0619.1:80:static void net_rx_action(unsigned long unused);
netback/netback.c.0619.1:81:static DECLARE_TASKLET(net_rx_tasklet, net_rx_action, 0);
netback/netback.c.0619.1:257:static void net_rx_action(unsigned long unused)
netback/netback.c.0619.1:282: length1=sprintf(filedata,"NETBACK: net_rx_action \n");
netback/netback.c.0619.1:974: /* We can increase reservation by this much in net_rx_action(). */
netback/#netback.c.0619.1#:80:static void net_rx_action(unsigned long unused);
netback/#netback.c.0619.1#:81:static DECLARE_TASKLET(net_rx_tasklet, net_rx_action, 0);
netback/#netback.c.0619.1#:257:static void net_rx_action(unsigned long unused)
netback/#netback.c.0619.1#:282: length1=sprintf(filedata,"NETBACK: net_rx_action \n");
netback/#netback.c.0619.1#:974: /* We can increase reservation by this much in net_rx_action(). */
バイナリー・ファイルnetback.08.0617.tarは一致しました
バイナリー・ファイルnetback.14.0617.tarは一致しました

|

ネッチョワーク


ユーザアプリケーション 

VFS:socketを開く open/write

TCP:到達確認/再送
IP:ルーティング
ネットワークドライバ:

ソフトウェア割り込み
HI_SOFTREQ
TIMER_SOFTREQ
NET_TX_SOFTIRQ
NET_RX_SOFTIRQ
SCSI_SOFTIRQ
TASKLET_SOFTIRQ

パケット送信
net_tx_action
NET_TX_SOFTIRQ

hard_start_xmit
失敗した場合:cpu_raise_softirq -> NET_TX_SOFTIRQ

パケット受信

  NET_RX_SOFTIRQ
net_rx_action

NICで割り込みハンドラ処理
netif_rxが呼び出される

netif_rx
キュー処理をした後、NET_RX_SOFTIRQを呼び出す

NET_RX_SOFIIRQ
net_rx_action

そうしん
   dev_queue_xmit
qdisc構造体

   qdisc_run

hard_start_xmit

NET_TX_SOFTIRQで割り込み要求

   NET_TX_SOFTIRQ -> net_tx_action

|

2007年11月 5日 (月)

lids2.4 patch

patch されたファイルの随所に
#ifdef CONFIG_LIDS
こういう箇所が出る。

# grep "RCS file" lids-1.2.2-2.4.30.patch

RCS file: /export/cvsroot/linux/linux-2.4/Makefile,v
RCS file: /export/cvsroot/linux/linux-2.4/Documentation/Configure.help,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/alpha/config.in,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/alpha/defconfig,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/arm/defconfig,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/cris/defconfig,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/i386/config.in,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/i386/defconfig,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/i386/kernel/ioport.c,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/i386/kernel/ptrace.c,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/i386/kernel/vm86.c,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/ia64/config.in,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/ia64/defconfig,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/m68k/defconfig,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/mips/config.in,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/mips64/config.in,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/mips64/defconfig,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/parisc/config.in,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/parisc/defconfig,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/ppc/config.in,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/ppc/defconfig,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/s390/config.in,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/s390/defconfig,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/s390x/defconfig,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/sh/config.in,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/sh/defconfig,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/sparc/config.in,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/sparc/defconfig,v
RCS file: /export/cvsroot/linux/linux-2.4/arch/sparc64/config.in,v
RCS file: /export/cvsroot/linux/linux-2.4/fs/buffer.c,v
RCS file: /export/cvsroot/linux/linux-2.4/fs/exec.c,v
RCS file: /export/cvsroot/linux/linux-2.4/fs/namei.c,v
RCS file: /export/cvsroot/linux/linux-2.4/fs/namespace.c,v
RCS file: /export/cvsroot/linux/linux-2.4/fs/open.c,v
RCS file: /export/cvsroot/linux/linux-2.4/fs/quota.c,v
RCS file: /export/cvsroot/linux/linux-2.4/fs/read_write.c,v
RCS file: /export/cvsroot/linux/linux-2.4/fs/readdir.c,v
RCS file: /export/cvsroot/linux/linux-2.4/fs/proc/base.c,v
RCS file: /export/cvsroot/linux/linux-2.4/include/linux/capability.h,v
RCS file: /export/cvsroot/linux/linux-2.4/include/linux/fs.h,v
RCS file: linux-2.4//include/linux/lids.h
RCS file: linux-2.4//include/linux/lidsext.h
RCS file: linux-2.4//include/linux/lidsif.h
RCS file: linux-2.4//include/linux/rmd160.h
RCS file: /export/cvsroot/linux/linux-2.4/include/linux/sched.h,v
RCS file: /export/cvsroot/linux/linux-2.4/include/linux/sysctl.h,v
RCS file: /export/cvsroot/linux/linux-2.4/include/linux/tty.h,v
RCS file: /export/cvsroot/linux/linux-2.4/init/main.c,v
RCS file: linux-2.4//kernel/Config.in
RCS file: /export/cvsroot/linux/linux-2.4/kernel/Makefile,v
RCS file: /export/cvsroot/linux/linux-2.4/kernel/exit.c,v
RCS file: /export/cvsroot/linux/linux-2.4/kernel/fork.c,v
RCS file: linux-2.4//kernel/klids.c
RCS file: /export/cvsroot/linux/linux-2.4/kernel/ksyms.c,v
RCS file: linux-2.4//kernel/lids.c
RCS file: linux-2.4//kernel/lids_logs.c
RCS file: linux-2.4//kernel/lids_mail_script.c
RCS file: linux-2.4//kernel/lids_net.c
RCS file: linux-2.4//kernel/lids_socket.c
RCS file: linux-2.4//kernel/lids_syslog_script.c
RCS file: linux-2.4//kernel/lids_tde.c
RCS file: linux-2.4//kernel/lids_tpe.c
RCS file: linux-2.4//kernel/lids_utils.c
RCS file: /export/cvsroot/linux/linux-2.4/kernel/module.c,v
RCS file: /export/cvsroot/linux/linux-2.4/kernel/printk.c,v
RCS file: /export/cvsroot/linux/linux-2.4/kernel/ptrace.c,v
RCS file: linux-2.4//kernel/rmd160.c
RCS file: /export/cvsroot/linux/linux-2.4/kernel/signal.c,v
RCS file: /export/cvsroot/linux/linux-2.4/kernel/sys.c,v
RCS file: /export/cvsroot/linux/linux-2.4/kernel/sysctl.c,v
RCS file: /export/cvsroot/linux/linux-2.4/mm/mmap.c,v
RCS file: /export/cvsroot/linux/linux-2.4/net/socket.c,v
RCS file: /export/cvsroot/linux/linux-2.4/net/core/rtnetlink.c,v
RCS file: /export/cvsroot/linux/linux-2.4/net/ipv4/Makefile,v
RCS file: /export/cvsroot/linux/linux-2.4/net/ipv4/af_inet.c,v
RCS file: linux-2.4//net/ipv4/lids_check_scan.c
RCS file: /export/cvsroot/linux/linux-2.4/net/ipv4/tcp_ipv4.c,v
RCS file: /export/cvsroot/linux/linux-2.4/net/ipv4/udp.c,v
RCS file: /export/cvsroot/linux/linux-2.4/net/ipv4/netfilter/ip_queue.c,v
RCS file: /export/cvsroot/linux/linux-2.4/net/ipv4/netfilter/ipt_MARK.c,v
RCS file: /export/cvsroot/linux/linux-2.4/net/ipv6/af_inet6.c,v
RCS file: /export/cvsroot/linux/linux-2.4/net/ipv6/netfilter/ip6_queue.c,v
RCS file: /export/cvsroot/linux/linux-2.4/net/netlink/af_netlink.c,v
RCS file: /export/cvsroot/linux/linux-2.4/net/sctp/socket.c,v

|

2007年11月 3日 (土)

isabelle

http://www.cl.cam.ac.uk/~lp15/Course/
http://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-189.pdf
http://isabelle.in.tum.de/coursematerial/IJCAR04/session1/main.pdf

http://www.di.unipi.it/~semprini/isabelle.htm
http://typessummerschool07.cs.unibo.it/courses/wenzel-isar-exercises.pdf
http://www.cs.chalmers.se/Cs/Research/Logic/TypesSS05/Extra/nipkow_ex.pdf
http://staff.aist.go.jp/reynald.affeldt/types02/exercices.pdf
http://www.cl.cam.ac.uk/~jrh13/hol-light/tutorial_220.pdf

http://isabelle.in.tum.de/library/HOL/ex/outline.pdf

The seventeen provers of the world
http://www.cs.ru.nl/~freek/comparison/comparison.pdf


|

2007年10月29日 (月)

ubuntu 起動シェルスクリプト

update-rc.d n.sh defaults 99 1

|

2007年10月24日 (水)

8クイーン特集

|

2007年10月14日 (日)

XEN NATモード

OSの挙動を見るのに、静かなネットワークでありたいときがあるだろう。。
XENのNATモードをつかいませぅ

UBUNTUでやりました

xend-config.sxpを修正

## Use the following if network traffic is routed with NAT, as an alternative
# to the settings for bridged networking given above.
(network-script network-nat)
(vif-script vif-nat)

NATの部分をコメントアウと

ドメインブートスクリプト
name="sarge"
memory=128
kernel="/boot/vmlinuz-2.6.*-xen"
nics=1
ip="192.168.1.2"
netmask="255.255.255.0"
gateway="192.168.1.128"
#vif=['ip=192.168.0.2']
vif=['ip=192.168.1.2']
disk=['file:/etc/xen/images/sarge-root.img,sda1,w','file:/etc/xen/images/sarge-swap.img,sda2,w']
root="/dev/sda1 ro"

このようかく

ゲストOSのねっとわーくスクリプト変更
sarge-xen-guest:/etc/network# more interfaces
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.128

起動すると、土間院0のVIFにこのようなアドレスが。。

vif1.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF
inet addr:192.168.1.129 Bcast:0.0.0.0 Mask:255.255.255.255
inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:15 errors:0 dropped:0 overruns:0 frame:0
TX packets:15 errors:0 dropped:6 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1162 (1.1 KiB) TX bytes:1642 (1.6 KiB)

これで、ping 192.168.1.2 / 129 とかやると通じする

こんなで必要条件は満たしているとおもふが。。

|

xen 共有メモリ

グラントテーブル(共有メモリ)の方法には2種類あり。。
以下は、おそらくこうであろうという推測

これは、
ブロックデバイス(アクセス:カーネルからドライバに頼む) 下へ

ネットワークデバイス(受信:ドライバからカーネルに頼む) 上へ
に分けられる。

おそらく、事象はドメインBでおこり、これがユーザドメインだと思われる。

ブロックデバイスドライバ
ドメインAがリファレンスを作成、ドメインBが(Aのメモリに)マップしてアクセス
1 ドメインAがgrant referenceを作成、ドメインBに送る
2 ドメインBがgrant frameを作成するために、ドメインAから送られてきたリファレンスを利用
3 ドメインBがメモリアクセスする
4 ドメインBがグラントフレームのマップ解除
5 ドメインAが作成したリファレンスを削除

ネットワークドライバ
ドメインAがリファレンスを作成、ドメインBが(Bのメモリを)受け渡す
1 ドメインAがtransfer grant referenceを作成し、ドメインBに送る
2 ドメインBがリファレンスを使って、自己(ドメインB)の持つフレームを手渡す
3 ドメインAがフレームを受け取る
4 ドメインAが利用したリファレンスをクリアする。

-----------------------------------

|

2007年10月 6日 (土)

xen (backend) block device

static void blkif_notify_work(blkif_t *blkif)
{
blkif->waiting_reqs = 1;
wake_up(&blkif->wq);
}

コールバック系
irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs)
{
blkif_notify_work(dev_id);
return IRQ_HANDLED;
}

構造体 blkif_t

typedef struct blkif_st {
/* Unique identifier for this interface. */
domid_t domid;
unsigned int handle;
/* Physical parameters of the comms window. */
unsigned int irq;
/* Comms information. */
enum blkif_protocol blk_protocol;
blkif_back_rings_t blk_rings;
struct vm_struct *blk_ring_area;
/* The VBD attached to this interface. */
struct vbd vbd;
/* Back pointer to the backend_info. */
struct backend_info *be; /* Private fields. */
spinlock_t blk_ring_lock;
atomic_t refcnt;

wait_queue_head_t wq;
struct task_struct *xenblkd;
unsigned int waiting_reqs;
request_queue_t *plug;

/* statistics */
unsigned long st_print;
int st_rd_req;
int st_wr_req;
int st_oo_req;
int st_br_req;
int st_rd_sect;
int st_wr_sect;

wait_queue_head_t waiting_to_free;

grant_handle_t shmem_handle;
grant_ref_t shmem_ref;
} blkif_t;

フロントエンドと一緒にうじょじょはこのあたりでSHOWか

/* Comms information. */
enum blkif_protocol blk_protocol;
blkif_back_rings_t blk_rings;
struct vm_struct *blk_ring_area;

リングバッファ系

grant_handle_t shmem_handle;
grant_ref_t shmem_ref;

グラントテブル

|

2007年10月 5日 (金)

プロセスディスクリプタ task_struct

task_structの中の構造体でありん酢

thread_info
   include/asm/thread_info.h
   TIFフラグ、PFフラグ

struct linux_binfmt
   include/linux/binfmts.h
実行ファイルのローダ

mm_struct
   メモリ管理    

tty_struct

   ↓ファイル関連の構造体
fs_struct
files_struct

struct namespace
名前空間?

signal_struct

|

2007年10月 4日 (木)

lids_check_ack_inode

核心関数

lids_check_acl_inode(struct inode *inode, int type)
{

struct lids_task_acl *task_acl = current->security;
struct lids_object_acl *o_acl;
struct lids_inode_acl *i_acl= inode->i_security;
//time_t currenttime;
int i=0;


if (!(task_acl && task_acl->s_acl))
return -EPERM;

while (i_acl->perm[i].sid != 0 && i< 64) {

o_acl = task_acl->s_acl->o_acl;
while(o_acl) {
if ( i_acl->perm[i].sid == o_acl->sid &&
i_acl->perm[i].oid == o_acl->oid ) {

return type & i_acl->perm[i].type ? 0 : -EPERM;
}
o_acl = o_acl->next;
}
i++;
}
return -EPERM;
}

核心
return type & i_acl->perm[i].type ? 0 : -EPERM;

|

2007年10月 3日 (水)

fork ← fork, vfork, clone

fork ← fork, vfork, clone

mm_struct構造体と初期化
PGD、LDTの割り当て
vm_area_stcut構造体の割り当てと初期化 (dup_mmap関数)

copy_process関数で行う。
同じ構造体を利用する場合と、新たにメモリを確保する場合がある。

|

XEN dynamic-irq init

root@tbn-office-19:/usr/src/winxen# cat /proc/interrupts
[irq-xen.c] CPU0 [irq-xen.c] CPU1
1: 241 0 Phys-irq i8042
6: 5 0 Phys-irq floppy
8: 0 0 Phys-irq rtc
9: 0 0 Phys-irq acpi
12: 1714 0 Phys-irq i8042
14: 633073 0 Phys-irq ide0
16: 242995 0 Phys-irq peth0
17: 0 0 Phys-irq uhci_hcd:usb2
18: 0 0 Phys-irq uhci_hcd:usb3
20: 104063 0 Phys-irq uhci_hcd:usb1, TEST: libata, TEST: ehci_hcd:usb4
256: 7012067 0 Dynamic-irq timer0
257: 79372 0 Dynamic-irq resched0
258: 28 0 Dynamic-irq callfunc0
259: 0 98320 Dynamic-irq resched1
260: 0 66 Dynamic-irq callfunc1
261: 0 825784 Dynamic-irq timer1
262: 1556 0 Dynamic-irq xenbus
263: 2 0 Dynamic-irq console
TEST:NMI: 0 0
TEST:LOC: 0 0
TEST:ERR: 0
TEST:MIS: 0

reschedの登録

static int xen_smp_intr_init(unsigned int cpu){
int rc;

per_cpu(resched_irq, cpu) = per_cpu(callfunc_irq, cpu) = -1;

printk("[smpboot.c][xen_smp_intr_init]\n");

sprintf(resched_name[cpu], "resched%d", cpu);
rc = bind_ipi_to_irqhandler(RESCHEDULE_VECTOR,
cpu,
smp_reschedule_interrupt,
SA_INTERRUPT,
resched_name[cpu],
NULL);
if (rc < 0)
goto fail;
per_cpu(resched_irq, cpu) = rc;

sprintf(callfunc_name[cpu], "callfunc%d", cpu);
rc = bind_ipi_to_irqhandler(CALL_FUNCTION_VECTOR,
cpu,
smp_call_function_interrupt,
SA_INTERRUPT,
callfunc_name[cpu],
NULL);

この関数は、__cpu_upで呼ばれる。
/xen/setup.c ニテ
void __init __start_xen(multiboot_info_t *mbi)
setup.cは、XENの初期化を行う。 ジゥヨウ

|

fixed point combinator

日本語訳は。。。高階関数??? higher-order function

プログラミング言語での再帰や項書き換えを保障する。

p=f(g), g(p)=p
g(f(g)) = f(g).

|

モデル検査

決定的
次の状態が1つのとき

非決定的
次の状態が1つ以上のとき

安全性
いけなげな状態へは遷移しない
可達グラフを検証する

活性
良いことは必ず起こる
応答性はともかく、意図したイベントは必ず起こる
因果関係がずっと成り立つ???

|

2007年9月30日 (日)

fails sanity check

checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking dependency style of g++... none
checking how to run the C++ preprocessor... /lib/cpp
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.

g++をインストールしました


|

2007年9月29日 (土)

stochastic optimization

Genetic Strategy Selection for Parallel Theorem Proving
wwwbroy.informatik.tu-muenchen.de/~stenzg/documents/hiper99.ps.gz

GA-MGTPによる Condensed Detachment問題の解法
http://ci.nii.ac.jp/naid/110003186994/en/

MGTP
ss104.is.kyushu-u.ac.jp/Paper/H9/tab97HaseFujiKoshi.ps.Z

|

2007年9月24日 (月)

KVM paravirtualization mode

KVMにもparavirtualizationモードがあるそうな

kvm_main.c
static int vcpu_register_para(struct kvm_vcpu *vcpu, gpa_t para_state_gpa)
{
struct kvm_vcpu_para_state *para_state;
hpa_t para_state_hpa, hypercall_hpa;
struct page *para_state_page;
unsigned char *hypercall;
gpa_t hypercall_gpa;

printk(KERN_DEBUG "kvm: guest trying to enter paravirtual mode\n");
printk(KERN_DEBUG ".... para_state_gpa: %08Lx\n", para_state_gpa);

この関数で使われている。

int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
{
switch (msr) {

/*
* This is the 'probe whether the host is KVM' logic:
*/
case MSR_KVM_API_MAGIC:
return vcpu_register_para(vcpu, data);

この関数をたどっていくと。。

vmx.cの↓この関数で使われている

/*
* Writes msr value into into the appropriate "register".
* Returns 0 on success, non-0 otherwise.
* Assumes vcpu_load() was already called.
*/
static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
{
struct vmx_msr_entry *msr;
int ret = 0;

switch (msr_index) {
#ifdef CONFIG_X86_64
case MSR_EFER:
ret = kvm_set_msr_common(vcpu, msr_index, data);
if (vcpu->vmx_host_state.loaded)
load_transition_efer(vcpu);
break;

さらに、vmx_set_msrは。。。


/*
* Writes msr value into into the appropriate "register".
* Returns 0 on success, non-0 otherwise.
* Assumes vcpu_load() was already called.
*/
static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
{
struct vmx_msr_entry *msr;
int ret = 0;

switch (msr_index) {
#ifdef CONFIG_X86_64
case MSR_EFER:
ret = kvm_set_msr_common(vcpu, msr_index, data);
if (vcpu->vmx_host_state.loaded)
load_transition_efer(vcpu);
break;

/*
* Writes msr value into into the appropriate "register".
* Returns 0 on success, non-0 otherwise.
* Assumes vcpu_load() was already called.
*/
static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
{
struct vmx_msr_entry *msr;
int ret = 0;

switch (msr_index) {
#ifdef CONFIG_X86_64
case MSR_EFER:
ret = kvm_set_msr_common(vcpu, msr_index, data);
if (vcpu->vmx_host_state.loaded)
load_transition_efer(vcpu);
break;

paravirtualization modeは、もう動くのだらうか?

http://kerneltrap.org/node/7545
パッチを見ましたが、修正カネルなどはありませぬなぬ

|

2007年9月23日 (日)

xen 仮想割り込み

root@desktop:/usr/src/forgrep/xen-3.1.0-src# grep -rin VIRQ_DEBUG *
linux-2.6-xen-sparse/drivers/xen/netback/netback.c:1483: (void)bind_virq_to_irqhandler(VIRQ_DEBUG,
xen/common/domain.c:467: send_guest_global_virq(dom0, VIRQ_DEBUGGER);
xen/common/event_channel.c:61: case VIRQ_DEBUG:
xen/common/keyhandler.c:203: VIRQ_DEBUG, v->virq_to_evtchn[VIRQ_DEBUG],
xen/common/keyhandler.c:204: test_bit(v->virq_to_evtchn[VIRQ_DEBUG],
xen/common/keyhandler.c:206: test_bit(v->virq_to_evtchn[VIRQ_DEBUG],
xen/common/keyhandler.c:208: test_bit(v->virq_to_evtchn[VIRQ_DEBUG] /
xen/common/keyhandler.c:211: send_guest_vcpu_virq(v, VIRQ_DEBUG);
xen/include/public/xen.h:128:#define VIRQ_DEBUG 1 /* V. Request guest to dump debug info. */
xen/include/public/xen.h:132:#define VIRQ_DEBUGGER 6 /* G. (DOM0) A domain has paused for debugging. */

domain.cで使われる。ドメインのポーズ

root@desktop:/usr/src/forgrep/xen-3.1.0-src# grep -rin VIRQ_DOM_EXC *
tools/xenstore/xenstored_domain.c:564: if ((rc = xc_evtchn_bind_virq(xce_handle, VIRQ_DOM_EXC)) == -1)
xen/common/domain.c:106: send_guest_global_virq(dom0, VIRQ_DOM_EXC);
xen/common/domain.c:331: send_guest_global_virq(dom0, VIRQ_DOM_EXC);
xen/common/domain.c:486: send_guest_global_virq(dom0, VIRQ_DOM_EXC);
xen/include/public/xen.h:130:#define VIRQ_DOM_EXC 3 /* G. (DOM0) Exceptional event for some domain. */

domain.cで使われる。xm destroy ナド。。

ナゾ NMIはヒットしているようだが、/proc/interruptsには反映されず???

|

random graph generation

http://www.eecg.toronto.edu/~steffan/items/globecom/README

|

2007年9月22日 (土)

xen 仮想割り込み

割り込みの転送と言われているが、
virq, pirq 双方の送信に使われている。

void evtchn_set_pending(struct vcpu *v, int port)
{
struct domain *d = v->domain;
shared_info_t *s = d->shared_info;
/*
* The following bit operations must happen in strict order.
* NB. On x86, the atomic bit operations also act as memory barriers.
* There is therefore sufficiently strict ordering for this architecture --
* others may require explicit memory barriers.
*/

if ( test_and_set_bit(port, __shared_info_addr(d, s, evtchn_pending)) )
     ↑ 割り込み種類の記録?
     失敗したらリターンか?
return;

if ( !test_bit (port, __shared_info_addr(d, s, evtchn_mask)) &&
↑ 割り込みマスクのチェック

!test_and_set_bit(port / BITS_PER_GUEST_LONG(d),
vcpu_info_addr(v, evtchn_pending_sel)) )
      ↑ 割り込み種類の記録?

{
vcpu_mark_events_pending(v);
}

/* Check if some VCPU might be polling for this event. */
if ( unlikely(d->is_polling) )
{
d->is_polling = 0;
smp_mb(); /* check vcpu poll-flags /after/ clearing domain poll-flag */
for_each_vcpu ( d, v )
{
if ( !v->is_polling )
continue;
v->is_polling = 0;
vcpu_unblock(v);
}
}
}

呼ばれる箇所
void send_guest_vcpu_virq(struct vcpu *v, int virq)
{
int port;

ASSERT(!virq_is_global(virq));

port = v->virq_to_evtchn[virq];
if ( unlikely(port == 0) )
return;

evtchn_set_pending(v, port);
}

void send_guest_global_virq(struct domain *d, int virq)
{
int port;
struct vcpu *v;
struct evtchn *chn;

ASSERT(virq_is_global(virq));

if ( unlikely(d == NULL) )
return;

v = d->vcpu[0];
if ( unlikely(v == NULL) )
return;

port = v->virq_to_evtchn[virq];
if ( unlikely(port == 0) )
return;

chn = evtchn_from_port(d, port);
evtchn_set_pending(d->vcpu[chn->notify_vcpu_id], port);
}


void send_guest_pirq(struct domain *d, int pirq)
{
int port = d->pirq_to_evtchn[pirq];
struct evtchn *chn;

ASSERT(port != 0);

chn = evtchn_from_port(d, port);
evtchn_set_pending(d->vcpu[chn->notify_vcpu_id], port);
}

switch ( lchn->state )
{
case ECS_INTERDOMAIN:
rd = lchn->u.interdomain.remote_dom;
rport = lchn->u.interdomain.remote_port;
rchn = evtchn_from_port(rd, rport);
rvcpu = rd->vcpu[rchn->notify_vcpu_id];
if ( rchn->consumer_is_xen )
{
/* Xen consumers need notification only if they are blocked. */
if ( test_and_clear_bit(_VPF_blocked_in_xen,
&rvcpu->pause_flags) )
vcpu_wake(rvcpu);
}
else
{
evtchn_set_pending(rvcpu, rport);
}
break;
case ECS_IPI:
evtchn_set_pending(ld->vcpu[lchn->notify_vcpu_id], lport);
break;

|

2007年9月21日 (金)

日本語キーボード問題

日本語キーボードが英語キーボードに認識される問題であるのでせぅ

私は、HID keyboardから、microsoft USB office keyboard に変更したら
直りました

|

2007年9月17日 (月)

kvmのナゾ

kvm_main.c <---> kvmctl.c の連携

kvm_main.c * vmx.c -> kvm_intel.ko ?

ioctl メソッドはkvm_main.cで定義されており。。
kvmctl.cでコントロールする。

int kvm_create_vcpu(kvm_context_t kvm, int slot)
{
long mmap_size;
int r;

fprintf(stderr,"[kvmctl.c][kvm_create_vcpu]\n");

r = ioctl(kvm->vm_fd, KVM_CREATE_VCPU, slot);
if (r == -1) {
r = -errno;
fprintf(stderr, "kvm_create_vcpu: %m\n");
return r;
}

など。

?? kvmのモジュール自体は、LINUXカーネルの中にある。
これが、ハイパバイザとして動作すると思われるのだが????

|

2007年9月16日 (日)

コントロールレジスタ

http://caspar.hazymoon.jp/OpenBSD/annex/intel_arc.html

|

kvm_mmu_load

mmu.c
int kvm_mmu_load(struct kvm_vcpu *vcpu)
{
int r;

printk("[mmu.c][kvm_mmu_load]\n");
spin_lock(&vcpu->kvm->lock);
r = mmu_topup_memory_caches(vcpu);
if (r)
goto out;
mmu_alloc_roots(vcpu);
kvm_arch_ops->set_cr3(vcpu, vcpu->mmu.root_hpa);
kvm_mmu_flush_tlb(vcpu);
out:
spin_unlock(&vcpu->kvm->lock);
return r;
}
EXPORT_SYMBOL_GPL(kvm_mmu_load);

定期的に呼ばれる

kvm.h
static inline int kvm_mmu_reload(struct kvm_vcpu *vcpu)
{
if (likely(vcpu->mmu.root_hpa != INVALID_PAGE))
return 0;

return kvm_mmu_load(vcpu);
}

こういう関数から呼ばれる。

vmx.c
static int vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
{
u8 fail;
int r;

preempted:
if (vcpu->guest_debug.enabled)
kvm_guest_debug_pre(vcpu);

again:
if (!vcpu->mmio_read_completed)
do_interrupt_requests(vcpu, kvm_run);

vmx_save_host_state(vcpu);
kvm_load_guest_fpu(vcpu);

r = kvm_mmu_reload(vcpu);

if (unlikely(r))
goto out;

vmx.cで登録されている

static struct kvm_arch_ops vmx_arch_ops = {
.run = vmx_vcpu_run,


|

2007年9月15日 (土)

live migration xen

xm migrate --live sarge ***.***.***.***

|

2007年9月14日 (金)

dont belive the moon

仮想アドレス

セグメンテーション回路

リニアアドレス

ページング回路

物理アドレス

セグメンテーション
CPUは、GDTを使う。

ページング
CPUは、CR3レジスタと変換テーブルを使ふ。

|

struct vcpu

少し探しましたが、sched.hにアリマス
vcpu.hやdomain.hではアリマセヌ

struct vcpu
{
int vcpu_id;

int processor;

vcpu_info_t *vcpu_info;

struct domain *domain;

struct vcpu *next_in_list;

uint64_t periodic_period;
uint64_t periodic_last_event;
struct timer periodic_timer;
struct timer singleshot_timer;

struct timer poll_timer; /* timeout for SCHEDOP_poll */

void *sched_priv; /* scheduler-specific data */

struct vcpu_runstate_info runstate;
#ifndef CONFIG_COMPAT
# define runstate_guest(v) ((v)->runstate_guest)
XEN_GUEST_HANDLE(vcpu_runstate_info_t) runstate_guest; /* guest address */
#else
# define runstate_guest(v) ((v)->runstate_guest.native)
union {
XEN_GUEST_HANDLE(vcpu_runstate_info_t) native;
XEN_GUEST_HANDLE(vcpu_runstate_info_compat_t) compat;
} runstate_guest; /* guest address */
#endif

/* Has the FPU been initialised? */
bool_t fpu_initialised;
/* Has the FPU been used since it was last saved? */
bool_t fpu_dirtied;
/* Is this VCPU polling any event channels (SCHEDOP_poll)? */
bool_t is_polling;
/* Initialization completed for this VCPU? */
bool_t is_initialised;
/* Currently running on a CPU? */
bool_t is_running;
/* NMI callback pending for this VCPU? */
bool_t nmi_pending;
/* Avoid NMI reentry by allowing NMIs to be masked for short periods. */
bool_t nmi_masked;
/* Require shutdown to be deferred for some asynchronous operation? */
bool_t defer_shutdown;
/* VCPU is paused following shutdown request (d->is_shutting_down)? */
bool_t paused_for_shutdown;

unsigned long pause_flags;
atomic_t pause_count;

u16 virq_to_evtchn[NR_VIRQS];

/* Bitmask of CPUs on which this VCPU may run. */
cpumask_t cpu_affinity;

unsigned long nmi_addr; /* NMI callback address. */

/* Bitmask of CPUs which are holding onto this VCPU's state. */
cpumask_t vcpu_dirty_cpumask;

struct arch_vcpu arch;
};

|

XEN MMU 仮想化

XENでは。。

ゲストドメインとXENがページテーブルを共有する(direct mode)。

CPUは、ドメインが管理するページテーブルを直接参照する。

CPUは、マシンアドレスを処理する。が、ゲストOSがいじっているのは、擬似物理アドレスなので、
 
pseudo physical address <-> machine address P2M ゲストOSが管理
machine address <-> pseudo physical address  M2P XENが管理

に変換するモノが必要である。

通常の環境では、仮想アドレス <-> 物理アドレス BY MMU

ゼーンな環境では、 仮想アドレス ,<-> マシンアドレス 
そのため、MMUの仮想化が必要になる。

ページがページテーブルとして利用されていることは、PIN/UNPINコマンドで印をツケマス。
ページテーブルがアドレス変換に利用されているかどうかは、CR3レジスタの値で決まります。



|

KVM mmu.c

static void kvm_mmu_audit(struct kvm_vcpu *vcpu, const char *msg);
static void kvm_mmu_audit(struct kvm_vcpu *vcpu, const char *msg) {}
static int dbg = 1;
static struct kmem_cache *pte_chain_cache;
static struct kmem_cache *rmap_desc_cache;
static struct kmem_cache *mmu_page_header_cache;
static int is_write_protection(struct kvm_vcpu *vcpu)
static int is_cpuid_PSE36(void)
static int is_nx(struct kvm_vcpu *vcpu)
static int is_present_pte(unsigned long pte)
static int is_writeble_pte(unsigned long pte)
static int is_io_pte(unsigned long pte)
static int is_rmap_pte(u64 pte)
static void set_shadow_pte(u64 *sptep, u64 spte)
static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache,
static void mmu_free_memory_cache(struct kvm_mmu_memory_cache *mc)
static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache,
static void mmu_free_memory_cache_page(struct kvm_mmu_memory_cache *mc)
static int __mmu_topup_memory_caches(struct kvm_vcpu *vcpu, gfp_t gfp_flags)
static int mmu_topup_memory_caches(struct kvm_vcpu *vcpu)
static void mmu_free_memory_caches(struct kvm_vcpu *vcpu)
static void *mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc,
static struct kvm_pte_chain *mmu_alloc_pte_chain(struct kvm_vcpu *vcpu)
static void mmu_free_pte_chain(struct kvm_pte_chain *pc)

static struct kvm_rmap_desc *mmu_alloc_rmap_desc(struct kvm_vcpu *vcpu)
static void mmu_free_rmap_desc(struct kvm_rmap_desc *rd)
static void rmap_add(struct kvm_vcpu *vcpu, u64 *spte)
static void rmap_desc_remove_entry(struct page *page,
static void rmap_remove(u64 *spte)
static void rmap_write_protect(struct kvm_vcpu *vcpu, u64 gfn)
static int is_empty_shadow_page(u64 *spt)

static void kvm_mmu_free_page(struct kvm *kvm,
static unsigned kvm_page_table_hashfn(gfn_t gfn)
static struct kvm_mmu_page *kvm_mmu_alloc_page(struct kvm_vcpu *vcpu,
static void mmu_page_add_parent_pte(struct kvm_vcpu *vcpu,
static void mmu_page_remove_parent_pte(struct kvm_mmu_page *page,
static struct kvm_mmu_page *kvm_mmu_lookup_page(struct kvm_vcpu *vcpu,
static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
static void kvm_mmu_page_unlink_children(struct kvm *kvm,
static void kvm_mmu_put_page(struct kvm_mmu_page *page,
static void kvm_mmu_zap_page(struct kvm *kvm,
static int kvm_mmu_unprotect_page(struct kvm_vcpu *vcpu, gfn_t gfn)
static void mmu_unshadow(struct kvm_vcpu *vcpu, gfn_t gfn)
static void page_header_update_slot(struct kvm *kvm, void *pte, gpa_t gpa)
static void nonpaging_new_cr3(struct kvm_vcpu *vcpu)
static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, hpa_t p)
static void mmu_free_roots(struct kvm_vcpu *vcpu)
static void mmu_alloc_roots(struct kvm_vcpu *vcpu)
static gpa_t nonpaging_gva_to_gpa(struct kvm_vcpu *vcpu, gva_t vaddr)
static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
static void nonpaging_free(struct kvm_vcpu *vcpu)
static int nonpaging_init_context(struct kvm_vcpu *vcpu)
static void kvm_mmu_flush_tlb(struct kvm_vcpu *vcpu)
static void paging_new_cr3(struct kvm_vcpu *vcpu)
static void inject_page_fault(struct kvm_vcpu *vcpu,
static void paging_free(struct kvm_vcpu *vcpu)
static int paging64_init_context_common(struct kvm_vcpu *vcpu, int level)
static int paging64_init_context(struct kvm_vcpu *vcpu)
static int paging32_init_context(struct kvm_vcpu *vcpu)
static int paging32E_init_context(struct kvm_vcpu *vcpu)

static int init_kvm_mmu(struct kvm_vcpu *vcpu)
この関数は定期的に呼ばれる

static void destroy_kvm_mmu(struct kvm_vcpu *vcpu)
static void mmu_pte_write_zap_pte(struct kvm_vcpu *vcpu,
static void mmu_pte_write_new_pte(struct kvm_vcpu *vcpu,
static void free_mmu_pages(struct kvm_vcpu *vcpu)
static int alloc_mmu_pages(struct kvm_vcpu *vcpu)
static const char *audit_msg;
static gva_t canonicalize(gva_t gva)
static void audit_mappings_page(struct kvm_vcpu *vcpu, u64 page_pte,
static void audit_mappings(struct kvm_vcpu *vcpu)
static int count_rmaps(struct kvm_vcpu *vcpu)
static int count_writable_mappings(struct kvm_vcpu *vcpu)
static void audit_rmap(struct kvm_vcpu *vcpu)
static void audit_write_protection(struct kvm_vcpu *vcpu)
static void kvm_mmu_audit(struct kvm_vcpu *vcpu, const char *msg)


int kvm_mmu_reset_context(struct kvm_vcpu *vcpu)
int kvm_mmu_load(struct kvm_vcpu *vcpu)
これは、恒常的に呼ばれる。

int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva)
static int alloc_mmu_pages(struct kvm_vcpu *vcpu)
int kvm_mmu_create(struct kvm_vcpu *vcpu)
int kvm_mmu_setup(struct kvm_vcpu *vcpu)

|

2007年9月11日 (火)

KVM MMU

static int nonpaging_init_context(struct kvm_vcpu *vcpu)
{
struct kvm_mmu *context = &vcpu->mmu;

printk("[mmu.c][nonpaging_init_context]\n");

context->new_cr3 = nonpaging_new_cr3;
context->page_fault = nonpaging_page_fault;
context->gva_to_gpa = nonpaging_gva_to_gpa;
context->free = nonpaging_free;
context->root_level = 0;
context->shadow_root_level = PT32E_ROOT_LEVEL;
context->root_hpa = INVALID_PAGE;
return 0;
}

ブート時にはこの関数が呼ばれる。

int kvm_mmu_load(struct kvm_vcpu *vcpu)
{
int r;

printk("[mmu.c][kvm_mmu_load]\n");

spin_lock(&vcpu->kvm->lock);
r = mmu_topup_memory_caches(vcpu);
if (r)
goto out;
mmu_alloc_roots(vcpu);
kvm_arch_ops->set_cr3(vcpu, vcpu->mmu.root_hpa);
kvm_mmu_flush_tlb(vcpu);
out:
spin_unlock(&vcpu->kvm->lock);
return r;
}
EXPORT_SYMBOL_GPL(kvm_mmu_load);

ログイン待ちの状態で、この関数が繰り返される。
なんかCR3を操作しているやふですが。。

load_mmuの間に、この関数が呼ばれる。

static int init_kvm_mmu(struct kvm_vcpu *vcpu)
{
ASSERT(vcpu);
ASSERT(!VALID_PAGE(vcpu->mmu.root_hpa));

printk("[mmu.c][init_kvm_mmu]\n");

if (!is_paging(vcpu))
return nonpaging_init_context(vcpu);
else if (is_long_mode(vcpu))
return paging64_init_context(vcpu);
else if (is_pae(vcpu))
return paging32E_init_context(vcpu);
else
return paging32_init_context(vcpu);
}

|

2007年9月 8日 (土)

オントロジー関係

http://cs-www.cs.yale.edu/homes/ddj/papers/DouEtal-MAS.pdf

Metadata: a case study from the environmental sciences
http://ieeexplore.ieee.org/Xplore/login.jsp?url=/iel3/4893/13494/00621182.pdf?arnumber=621182

セマンティックWEB
http://www.flacp.fujitsulabs.com/~rmasuoka/papers/20051101-SWS-in-US-for-JSAI-Masuoka-Submitted.pdf

|

2007年9月 7日 (金)

TPTP problem library

http://www.cs.miami.edu/~tptp/

|

メモリフォレンジクス関係

XENのチェックポイント
http://xen.xensource.com/files/xensummit_4/talk_Cully.pdf

elsevir
http://dfrws.org/2007/proceedings/p126-schatz.pdf

Fireware
http://www.friendsglobal.com/papers/FireWire%20Memory%20Dump%20of%20Windows%20XP.pdf

Blackhat
http://i.i.com.com/cnwk.1d/i/z/200701/bh-dc-07-Rutkowska-ppt.pdf

解説論文か?
http://www.cse.ucsd.edu/~jfisherogden/hardwareVirt.pdf

|

2007年9月 5日 (水)

cmp / je

cmp X, Y
X=Y なら ZF=1

je A
ZF=1ならAへ

|

2007年9月 3日 (月)

xen evtchn_set_pending

(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 17
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 4
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 2
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 17
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 17
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 2
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 6
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 1
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 4
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 6
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 6
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 1
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 6
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 1
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 6
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 1
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 6
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 1
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 6
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 1
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 6
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 1
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 6
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 1
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 6
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 1
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 6
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 1
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 4
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 4
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 2
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 22
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 22
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 22
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 22
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 22
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 22
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 22
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 22
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 17
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 1
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 1
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 1
(XEN) [event_channel.c][evtchn_set_pending] vcpu_mark_events_pending port 1

完全仮想化なOSが待機中でもいろいろなポートがたたかれているらしい。。

|

2007年8月31日 (金)

xen hvm evtchn_send

long evtchn_send(unsigned int lport)
{
struct evtchn *lchn, *rchn; struct domain *ld = current->domain, *rd;
struct vcpu *rvcpu;
int rport, ret = 0;

case ECS_IPI:

// printk("[event_channel.c][evtchn] ECS_IPI \n"); evtchn_set_pending(ld->vcpu[lchn->notify_vcpu_id], lport);
break;
case ECS_UNBOUND:
printk("[event_channel.c][evtchn] ECS_UNBOUND \n");
/* silently drop the notification */
break; default:
ret = -EINVAL;
}

spin_unlock(&ld->evtchn_lock);

return ret;
}

完全仮想化では、ECS_IPIなsendが連発される

|

2007年8月30日 (木)

XEN HVM event-channel

event-channelでは、完全仮想化でも使われている。

(XEN) [event_channel.c][evtchn_bind_virq]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][evtchn_bind_virq]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][evtchn_bind_virq]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) mtrr: type mismatch for fd000000,1000000 old: write-back new: write-combining
(XEN) [event_channel.c][evtchn_bind_interdomain]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][evtchn_bind_virq]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][evtchn_init]
(XEN) [event_channel.c][get_free_port]
(XEN) [vmx.c][vmx_vcpu_initialise]
(XEN) [vmcs.c] vmx_create_vmcs
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][evtchn_bind_interdomain]
(XEN) [event_channel.c][get_free_port]
(XEN) [event_channel.c][evtchn_bind_interdomain]
(XEN) [event_channel.c][get_free_port]

|

2007年8月29日 (水)

HVM console

xm dmesg

[console.c][init_console]
[console.c][init_console] serial_set_rx_handler
[serial.c][serial_set_rx_handler] handle 8
__ __ _____ _ ___
\ \/ /___ _ __ |___ / / | / _ \
\ // _ \ '_ \ |_ \ | || | | |
/ \ __/ | | | ___) || || |_| |
/_/\_\___|_| |_| |____(_)_(_)___/

こ、これは・・・

|

HVM softirq_handler

void open_softirq(int nr, softirq_handler handler)
{
printk("[softirq.c][open_softirq] nr %d \n",nr);
softirq_handlers[nr] = handler;
}

ハンドラ登録関数でありますれる

static softirq_handler softirq_handlers[NR_SOFTIRQS];

#define TIMER_SOFTIRQ 0
#define SCHEDULE_SOFTIRQ 1
#define NEW_TLBFLUSH_CLOCK_PERIOD_SOFTIRQ 2
#define KEYPRESS_SOFTIRQ 3
#define NMI_SOFTIRQ 4
#define PAGE_SCRUB_SOFTIRQ 5
#define TRACE_SOFTIRQ 6
#define RCU_SOFTIRQ 7
#define NR_COMMON_SOFTIRQS 8

例えば、タイマーですが、
open_softirq(TIMER_SOFTIRQ, timer_softirq_action);

|

HVM NMI softirq

#define TIMER_SOFTIRQ 0
#define SCHEDULE_SOFTIRQ 1
#define NEW_TLBFLUSH_CLOCK_PERIOD_SOFTIRQ 2
#define KEYPRESS_SOFTIRQ 3
#define NMI_SOFTIRQ 4
#define PAGE_SCRUB_SOFTIRQ 5
#define TRACE_SOFTIRQ 6
#define RCU_SOFTIRQ 7
#define NR_COMMON_SOFTIRQS 8

#define NMI_SOFTIRQ 4
の初期化関数は、

nmi.c / nmi_int.cではなく、traps.cにあるナリヨ

File Edit Options Buffers Tools C Help
void __init trap_init(void)
{
extern void percpu_traps_init(void);

printk("[traps.c][trap_init]\n");

/*
* Note that interrupt gates are always used, rather than trap gates. We
* must have interrupts disabled until DS/ES/FS/GS are saved because the
* first activation must have the "bad" value(s) for these registers and
* we may lose them if another activation is installed before they are
* saved. The page-fault handler also needs interrupts disabled until %cr2
* has been read and saved on the stack.
*/
set_intr_gate(TRAP_divide_error,÷_error);
set_intr_gate(TRAP_debug,&debug);
set_intr_gate(TRAP_nmi,&nmi);
set_system_gate(TRAP_int3,&int3); /* usable from all privileges */
set_system_gate(TRAP_overflow,&overflow); /* usable from all privileges */
set_intr_gate(TRAP_bounds,&bounds);
set_intr_gate(TRAP_invalid_op,&invalid_op);
set_intr_gate(TRAP_no_device,&device_not_available);
set_intr_gate(TRAP_copro_seg,&coprocessor_segment_overrun);
set_intr_gate(TRAP_invalid_tss,&invalid_TSS);
set_intr_gate(TRAP_no_segment,&segment_not_present);
set_intr_gate(TRAP_stack_error,&stack_segment);
set_intr_gate(TRAP_gp_fault,&general_protection);
set_intr_gate(TRAP_page_fault,&page_fault);
set_intr_gate(TRAP_spurious_int,&spurious_interrupt_bug);
set_intr_gate(TRAP_copro_error,&coprocessor_error);
set_intr_gate(TRAP_alignment_check,&alignment_check);
set_intr_gate(TRAP_machine_check,&machine_check);
set_intr_gate(TRAP_simd_error,&simd_coprocessor_error);

percpu_traps_init();

cpu_init();

printk("[traps.c][trap_init] open_softirq \n");
open_softirq(NMI_SOFTIRQ, nmi_softirq);
}

|

2007年8月28日 (火)

XLAT

アセンブラの命令
BX + AL のアドレスの値を、ALに代入

http://hp.vector.co.jp/authors/VA003991/kouza/beginner/kouza_asm.html
くわしい

|

HVM softirq その2

softirq.h より

/* Common softirqs come first in the following list. */
#define TIMER_SOFTIRQ 0
#define SCHEDULE_SOFTIRQ 1
#define NEW_TLBFLUSH_CLOCK_PERIOD_SOFTIRQ 2
#define KEYPRESS_SOFTIRQ 3
#define NMI_SOFTIRQ 4
#define PAGE_SCRUB_SOFTIRQ 5
#define TRACE_SOFTIRQ 6
#define RCU_SOFTIRQ 7

#define NR_COMMON_SOFTIRQS 8

タイマーやらコンソールはそぅですなですが。。。
NMIはどこにあんだ??

|

2007年8月27日 (月)

HVM softirq

(XEN) System RAM: 8191MB (8387960kB)
(XEN) Xen heap: 9MB (10020kB)
(XEN) Domain heap initialised: DMA width 32 bits
(XEN) PAE enabled, limit: 16 GB
(XEN) [softirq.c][open_softirq] nr 2
(XEN) Processor #0 15:6 APIC version 20
(XEN) Processor #1 15:6 APIC version 20
(XEN) IOAPIC[0]: apic_id 2, version 32, address 0xfec00000, GSI 0-23
(XEN) IOAPIC[1]: apic_id 3, version 32, address 0xfec10000, GSI 32-55
(XEN) Enabling APIC mode: Flat. Using 2 I/O APICs
(XEN) [irq.c][setup_irq]
(XEN) [softirq.c][open_softirq] nr 1
(XEN) Using scheduler: SMP Credit Scheduler (credit)
(XEN) [softirq.c][open_softirq] nr 4
(XEN) [softirq.c][open_softirq] nr 7
(XEN) [timer.c][timer_init]
(XEN) [softirq.c][open_softirq] nr 0
(XEN) Detected 3400.307 MHz processor.
(XEN) [irq.c][setup_irq]
CPU: Trace cache: 12K uops(XEN) HVM: VMX enabled
(XEN) CPU0: CPU0: Intel(R) Pentium(R) D CPU 3.40GHzIntel(R) Pentium(R) D CPU 3.40GHz stepping 04
(XEN) Mapping cpu 0 to node 255
(XEN) Booting processor 1/1 eip 90000
(XEN) Mapping cpu 1 to node 255
CPU: Trace cache: 12K uops(XEN) CPU1: CPU1: Intel(R) Pentium(R) D CPU 3.40GHzIntel(R) Pentium(R) D CPU 3.40GHz stepping 04
(XEN) Total of 2 processors activated.
(XEN) ENABLING IO-APIC IRQs

この辺でドライバの登録をしているのか?ハンニャカー まいぅ~

|

stosb stosw stosd

文字列処理命令

レジスタからメモリへの代入

stosb : ALを、DIに保存 フラグをセット DIをインクリメント/デクリメント プラスマイナス1
stosw : AXを、DIに保存 フラグをセット DIをインクリメント/デクリメント プラスマイナス2
stosd : AXを、DIに保存 フラグをセット DIをインクリメント/デクリメント プラスマイナス4

メモリの初期化などに使われるらすぃ

CX=256
REP MOVSB

こうすると、SIのデータをDIに256回転送するノダー 

|

2007年8月25日 (土)

VM 分類

http://www.atdot.net/~ko1/vimpl/w3ml.cgi/vimpl/msg/48/0/AIST_xen_intro_20061206_2.pdf
VM分類が載っている

|

XEN ファイルリスト

root@desktop:/usr/src/xen-3.1.0-src/xen/arch/x86# ls
Makefile crash.c e820.o io_apic.o nmi.o shutdown.o trampoline.S
Rules.mk crash.o extable.c irq.c numa.c smp.c trampoline.o
acpi delay.c extable.o irq.o numa.o smp.o traps.c
apic.c delay.o flushtlb.c machine_kexec.c oprofile smpboot.c traps.o
apic.o dmi_scan.c flushtlb.o machine_kexec.o physdev.c smpboot.o usercopy.c
asm-offsets.s dmi_scan.o gdbstub.c microcode.c physdev.o srat.c usercopy.o
bitops.c domain.c genapic microcode.o platform_hypercall.c srat.o x86_32
bitops.o domain.o hvm mm platform_hypercall.o string.c x86_64
boot domain_build.c i387.c mm.c rwlock.c string.o x86_emulate.c
built_in.o domain_build.o i387.o mm.o rwlock.o sysctl.c x86_emulate.o
compat.c domctl.c i8259.c mpparse.c setup.c sysctl.o xen.lds
compat.o domctl.o i8259.o mpparse.o setup.o time.c
cpu e820.c io_apic.c nmi.c shutdown.c time.o

root@desktop:/usr/src/xen-3.1.0-src/xen/arch/x86/mm# ls
Makefile built_in.o hap p2m.c p2m.o page-guest32.h paging.c paging.o shadow

root@desktop:/usr/src/xen-3.1.0-src/xen/arch/x86/hvm# ls
#hvm.c# hpet.o i8254.o intercept.o irq.o pmtimer.o save.o vlapic.c vpic.o
Makefile hvm.c instrlen.c io.c platform.c rtc.c svm vlapic.o vpt.c
built_in.o hvm.o instrlen.o io.o platform.o rtc.o vioapic.c vmx vpt.o
hpet.c i8254.c intercept.c irq.c pmtimer.c save.c vioapic.o vpic.c

root@desktop:/usr/src/xen-3.1.0-src/xen/common# ls
Makefile domctl.c kexec.c multicall.c sched_credit.c softirq.o time.c vsprintf.o
acm_ops.c domctl.o kexec.o multicall.o sched_credit.o string.c time.o xencomm.c
acm_ops.o event_channel.c keyhandler.c page_alloc.c sched_sedf.c string.o timer.c xenoprof.c
bitmap.c event_channel.o keyhandler.o page_alloc.o sched_sedf.o symbols-dummy.c timer.o xenoprof.o
bitmap.o gdbstub.c lib.c perfc.c schedule.c symbols-dummy.o trace.c xmalloc.c
built_in.o grant_table.c lib.o rangeset.c schedule.o symbols.c trace.o xmalloc.o
compat grant_table.o libelf rangeset.o shutdown.c symbols.o version.c
domain.c kernel.c memory.c rcupdate.c shutdown.o sysctl.c version.o
domain.o kernel.o memory.o rcupdate.o softirq.c sysctl.o vsprintf.c

root@desktop:/usr/src/xen-3.1.0-src/xen/include/xen# ls
acm_policy.h compiler.h elf.h inttypes.h mm.h prefetch.h smp.h types.h
acpi.h config.h elfcore.h iocap.h multiboot.h rangeset.h softirq.h version.h
bitmap.h console.h errno.h irq.h multicall.h rcupdate.h spinlock.h vga.h
bitops.h cpumask.h event.h irq_cpustat.h nmi.h sched-if.h stdarg.h xencomm.h
byteorder ctype.h gdbstub.h kernel.h nodemask.h sched.h string.h xenoprof.h
cache.h delay.h grant_table.h kexec.h numa.h serial.h symbols.h xmalloc.h
compat.h dmi.h guest_access.h keyhandler.h percpu.h shadow.h time.h
compile.h domain.h hypercall.h lib.h perfc.h shared.h timer.h
compile.h.in domain_page.h init.h list.h perfc_defn.h shutdown.h trace.h

root@desktop:/usr/src/xen-3.1.0-src/xen/include/public# ls
COPYING arch-x86 domctl.h foreign libelf.h sched.h xen-compat.h
acm.h arch-x86_32.h elfnote.h grant_table.h memory.h sysctl.h xen.h
acm_ops.h arch-x86_64.h elfstructs.h hvm nmi.h trace.h xencomm.h
arch-ia64.h callback.h event_channel.h io physdev.h vcpu.h xenoprof.h
arch-powerpc.h dom0_ops.h features.h kexec.h platform.h version.h

root@desktop:/usr/src/xen-3.1.0-src/xen/include/public/hvm# ls
e820.h hvm_info_table.h hvm_op.h ioreq.h params.h save.h vmx_assist.h

root@desktop:/usr/src/xen-3.1.0-src/xen/include/asm# ls
acpi.h compat.h e820.h hpet.h ldt.h mtrr.h processor.h system.h
apic.h config.h elf.h hvm mach-default multicall.h regs.h time.h
apicdef.h cpufeature.h event.h hypercall.h mach-es7000 nmi.h rwlock.h types.h
asm-offsets.h current.h fixmap.h i387.h mach-generic numa.h shadow.h uaccess.h
asm_defns.h debugger.h flushtlb.h init.h mach-summit p2m.h shared.h x86_32
atomic.h debugreg.h genapic.h io.h mc146818rtc.h page.h smp.h x86_64
bitops.h delay.h grant_table.h io_apic.h mm.h paging.h smpboot.h x86_emulate.h
bug.h desc.h guest_access.h iocap.h mpspec.h percpu.h softirq.h xenoprof.h
byteorder.h div64.h hap.h ipi.h mpspec_def.h perfc.h spinlock.h
cache.h domain.h hardirq.h irq.h msr.h perfc_defn.h string.h

|

2007年8月23日 (木)

live migration (日本語)

http://begi.net/files/virt6/LiveMigrationL.pdf
iSCSI以外に、NFSでもいいらすぃ

作業例が載っている
http://cropcrusher.web.infoseek.co.jp/shufuden/xensemi/index.html

|

http://kvm.qumranet.com/kvmwiki/Migration

http://kvm.qumranet.com/kvmwiki/Migration
転送速度の設定、暗号化もデキルのか???

|

2007年8月22日 (水)

xm dmesg

static void __putstr(const char *str)
{
int c;

sercon_puts(str);

while ( (c = *str++) != '\0' )
{
vga_putchar(c);
putchar_console_ring(c);
// added displayed ! verbose
// putchar_console_ring(c);
}

send_guest_global_virq(dom0, VIRQ_CON_RING);
}

さいしぅ的には、この関数が使われる。
putchar_console_ringで一文字表示。。。デア~ル

console.c

|

qemu_savevm

vl.c

int qemu_savevm(const char *filename, QEMUFile *f)
{
SaveStateEntry *se;
int len, len_pos, cur_pos, saved_vm_running, ret;

saved_vm_running = vm_running;
vm_stop(0);

if (f->open(f, filename, "wb")) {
ret = -1;
goto the_end;
}

qemu_put_be32(f, QEMU_VM_FILE_MAGIC);
qemu_put_be32(f, QEMU_VM_FILE_VERSION);

for(se = first_se; se != NULL; se = se->next) { /* ID string */
len = strlen(se->idstr);
qemu_put_byte(f, len);
qemu_put_buffer(f, se->idstr, len);

qemu_put_be32(f, se->instance_id);
qemu_put_be32(f, se->version_id);

/* record size: filled later */
len_pos = qemu_ftell(f);
qemu_put_be32(f, 0);

se->save_state(f, se->opaque);

/* fill record size */
cur_pos = qemu_ftell(f);
len = qemu_ftell(f) - len_pos - 4;
qemu_fseek(f, len_pos, SEEK_SET);
qemu_put_be32(f, len);
qemu_fseek(f, cur_pos, SEEK_SET);
}
qemu_put_byte(f, 0); /* len==0 represents end of state */
f->close(f);
ret = 0;
the_end:
if (saved_vm_running)
vm_start();
return ret;
}

put_byteな関数群

/***********************************************************/
/* savevm/loadvm support */

void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size)
{
f->put_buffer(f, buf, size);
}

void qemu_put_byte(QEMUFile *f, int v)
{
f->put_byte(f, v);
}

void qemu_put_be16(QEMUFile *f, unsigned int v)
{
qemu_put_byte(f, v >> 8);
qemu_put_byte(f, v);
}

void qemu_put_be32(QEMUFile *f, unsigned int v)
{
qemu_put_byte(f, v >> 24);
qemu_put_byte(f, v >> 16);
qemu_put_byte(f, v >> 8);
qemu_put_byte(f, v);
}

void qemu_put_be64(QEMUFile *f, uint64_t v)
{
qemu_put_be32(f, v >> 32);
qemu_put_be32(f, v);
}

put_byteはvl.c同じく定義されており。。。

QEMUFile qemu_savevm_method_file = {
.opaque = NULL,
.open = qemu_savevm_method_file_open,
.close = qemu_savevm_method_file_close,
.put_byte = qemu_savevm_method_file_put_byte,
.get_byte = qemu_savevm_method_file_get_byte,
.put_buffer = qemu_savevm_method_file_put_buffer,
.get_buffer = qemu_savevm_method_file_get_buffer,
.tell = qemu_savevm_method_file_tell,
.seek = qemu_savevm_method_file_seek,
.eof = qemu_savevm_method_file_eof
};

こういう構造体があり。。

typedef struct SaveStateEntry {
char idstr[256];
int instance_id;
int version_id;
SaveStateHandler *save_state;
LoadStateHandler *load_state;
void *opaque;
struct SaveStateEntry *next;
} SaveStateEntry;

for(se = first_se; se != NULL; se = se->next) {
これでまわしているので、このこうぞふたいをたどれば
仮想RAMまでいけるということけれ

|

2007年8月21日 (火)

VMware deterministic replay

VMWareの論文。

hypervisorを使って、deterministic replayをするさうな。
ReTraceというそうな。 capturing and expansion

結果は。。
efficiency and inexpensively
effective for compressing large trace files
hypervisorを使うので、traceが、disturbされにくい。

deterministic replayは、いろいろ参考文献があるヨウダー
実はまだ調べてないノダー オモシロソウダー

ReTrace: Collecting Execution Trace with Virtual Machine Deterministic Replay,
Min Xu, Vyacheslav Malyugin, Jeffrey Sheldon, Ganesh Venkitachalam and Boris Weissman,
Third Annual Workshop on Modeling, Benchmarking and Simulation, held in conjunction with the 34th Annual International Symposium on Computer Architecture, June 2007.

|

2007年8月20日 (月)

ghost in the browser (paper)

googleの論文
Niels Provos, Dean McNamee, Panayiotis Mavrommatis, Ke Wang, Nagendra Modadugu. The Ghost in the Browser: Analysis of Web-based Malware. 2007. HotBots '07.

googleレポジトリの中から、web系攻撃の分析・トレンドの抽出。

ボットネットと、WEB系攻撃の違い
the main difference is that web-based malware infections are pull-based and that the resulting command feed back is looser.

レポジトリの中から危険なサイトの抽出方法が、チャプタ3にある。

4つの有力なメカニズム
web server security
user contributed content
advertising and third party widgets

5つのトレンド

続く

|

2007年8月17日 (金)

microsoft: Instruction-level tracing and analysis 2

Framework for instruction-level tracing and analysis of program executions

VEE06
Sanjay Bhansali Microsoft Corporation, Redmond, WA
Wen-Ke Chen Microsoft Corporation, Redmond, WA
Stuart de Jong Microsoft Corporation, Redmond, WA
Andrew Edwards Microsoft Corporation, Redmond, WA
Ron Murray Microsoft Corporation, Redmond, WA
Milenko Drinić Microsoft Corporation, Redmond, WA
Darek Mihočka Microsoft Corporation, Redmond, WA
Joe Chau Microsoft Corporation, Redmond, WA

instruction-level traceというが、実は私はよくわかっていない。。

これを使うと、
ユーザモードでのre-simulationが(deterministicに)可能である。

nirvanaとiDNAというモノで構成されており。。

nirvana runtime engine
"Nirvana's goal is to provide a flexible environment and rich set of dynamic instrumentation points
such that a full execution trace can be recorded."

self modifying codeにも対応。自己改変コードみたいなものでせぅか

Nirvana APIといのがあり。。
これを見ていると、KVMのソレとダブりますが。

iDNAについては、まったくわからん。。
トレーサか、シミュレータ??
ここに同名のモノがありますが。。組み込まれたのか??
www.cs.wisc.edu/areas/pl/seminar/fall05/Bhansali.ppt

アプリケーション
time travel debugging
ユーザモードからdeterministicにできる??

data locality profiling
??


|

2007年8月16日 (木)

subvirt

Samuel T. King, Peter M. Chen, Yi-Min Wang, Chad Verbowski, Helen J. Wang, Jacob R. Lorch, "SubVirt: Implementing malware with virtual machines", in Proc. IEEE Symp. on Security and Privacy (the Oakland Conference), May 2006.

VMMベースのrootkit.

attackers and defenders of computer systems both strive to gain complete control over the system. To maximize their contorl, bothe have migrated to low-level, operating system code.

感染の仕方

1)ドライバを仕込ませる
2)ブートシーケンスを変更する

評価として、ブートシーケンスの測定などをしている。

対策

安全なメディア、CDROMや、USB,ネットワークブートサーバなどを使う。
セキュアVMMを使う。→セキュアなブートシーケンス

|

kvm savevm

1 monitor.c do_savevm
2 vl.c qemu_savevm
3 qemu-kvm.c save_regs

|

phishing

朕もまだまだ若輩者ですが。。

セキュリティも何年かやってると、ギジツは変われど、ニンゲムのやっていることはあまり変わらんな~と思ふ今日このごろ

phishingとIDS

ブラックリスト(ホワイトリスト)形式と、ヒューリスティクス形式があるのは、同じ。

googleは、ブラックリスト方式らすぃ。。snortと一緒で、し具に茶をアップデート管理する。

ヒューリスティクス方式の本命は、spoofguard.

おそらく、IDSとの違いは、クラシフィケーション以外の、アノマリがないことでは?
正常状態からの乖離を計算するというのは、調べたが、ないのでは??確信はありませんが。
なので、正例と負例が必要ということ。クラスタリングのでる幕はネイということでせぅか。

類似度とは、偽サイト、スパムメールとの類似度のヨウダー 正例との類似度ではねいヨウダー
SVMが多デス。あたりまえだが、あとは、見た限り、ベイズ、K-NN、決定木等。

CMUがこれらの方式を比較してお~る
http://www.cylab.cmu.edu/default.aspx?id=2255
負例100、政令510

ジムコウチノウには、
1最適化
2教師あり
3教師なし 

2が出番のやふだ。

フィッシングは、受動的攻撃。。

人間が注意ぶかくみれば、わかるのでしょうか?最近は、巧妙なのが増えてきたので、マシン支援があるとイーネ!クレイジーケンバンド タオル名曲 というはなしですな~。

システムに100%安全はない。
最終的に、ボタムを押すのは、ニンゲムなので。GALVANIZER名盤 ケミカルBROS

F(マシン支援、人間の注意力、アタッカ:巧) > なんちゃらスレショルド

spoofguardは、検出率が基本的に、時間変化しない。ヒューリスティクスだから。ただ、誤警報が多い。ですが、クラスタリングベースのアノマリではなく、教師つきのアノマリある(多分 ここが、バーストトラフィック検出とちょっと違ふ。すぱむメールとは話が、一緒。便利そうですが、さいごは自分で判断する。。

DNS spoofingと絡みますと、話がらりと、深刻ですな。ウーム。。
どうすんでしょう??

この話も、しばらくは、続きそうだ。。

http://www.mozilla.org/security/phishing-test.html
http://csdl2.computer.org/persagen/DLAbsToc.jsp?resourcePath=/dl/trans/tq/&toc=comp/trans/tq/2006/04/q4toc.xml&DOI=10.1109/TDSC.2006.50

ロムブム シミラリティ
http://www.mit.edu/~ayf/publication/WDA-antiphishing.pdf

http://www.cs.berkeley.edu/~asimma/294-fall06/projects/reports/cordero.pdf
http://www.cs.bell-labs.com/cm/cs/who/pfps/temp/web/www2007.org/papers/paper557.pdf

アノマリベースありますた USING SVM
http://www.acsac.org/2006/papers/66.pdf

ぶらっくリスト方式 評価
http://www.auto.tuwien.ac.at/~chris/research/doc/dimva07_phishing.pdf

|

2007年8月15日 (水)

harware virtualization trenad

http://www.usenix.org/events/vee06/full_papers/vandoorn-keynote.pdf
usenix

|

2007年8月14日 (火)

ページング

論理アドレス → リニアアドレス → 物理アドレス

セグメント機構 論理アドレス → リニアアドレス
GDTRレジスタを利用

ページング機構 リニアアドレス → 物理アドレス
CR3レジスタを利用

|

XEN メモリ

XEN上では、複数のOSが動く。

OSがアクセスするのが、物理アドレスだすが、XENはそれを仮想化しますので、
複数の仮想化された物理アドレスがXEN上には存在しますです。

XENがアクセスするリアルの物理メモリのアドレスをマシンアドレスと言ふ。

準仮想化では。。

OSが管理するページテーブルを、CPUが直接参照する。
おそらくゲストOSを変更しているのでせぅ、仮想アドレスからマシンアドレスへの変換は、ゲストOSにさせている。

完全仮想化では。。

ゲストOSは変更されないため、OSが作るページテーブルのコピーを作る。(シャドーページテーブル)CPUは、これを使ふ。

このページングにはいろいろな方式があるらすぃ。。

|

2007年8月10日 (金)

qemu_savevm

int qemu_savevm(const char *filename, QEMUFile *f)
{
SaveStateEntry *se;
int len, len_pos, cur_pos, saved_vm_running, ret;

saved_vm_running = vm_running; vm_stop(0);
if (f->open(f, filename, "wb")) {
ret = -1;
goto the_end;
}

qemu_put_be32(f, QEMU_VM_FILE_MAGIC);
qemu_put_be32(f, QEMU_VM_FILE_VERSION);

for(se = first_se; se != NULL; se = se->next) {
/* ID string */
len = strlen(se->idstr);
qemu_put_byte(f, len);
qemu_put_buffer(f, se->idstr, len);

qemu_put_be32(f, se->instance_id);
qemu_put_be32(f, se->version_id);

/* record size: filled later */
len_pos = qemu_ftell(f);
qemu_put_be32(f, 0);

se->save_state(f, se->opaque);

/* fill record size */
cur_pos = qemu_ftell(f);
len = qemu_ftell(f) - len_pos - 4;
qemu_fseek(f, len_pos, SEEK_SET);
qemu_put_be32(f, len);
qemu_fseek(f, cur_pos, SEEK_SET);
}
qemu_put_byte(f, 0); /* len==0 represents end of state */
f->close(f);
ret = 0;
the_end:
if (saved_vm_running)
vm_start();
return ret;
}

意外と短い シンプルかも知れませぬ。
このやふなストラクチャが vl.h にてござれ

/* VM Load/Save */

//typedef FILE QEMUFile;
typedef struct QEMUFile_s QEMUFile;
struct QEMUFile_s {
void *opaque;
int (*open)(QEMUFile *f, const char *filename, const char *flags);
void (*close)(QEMUFile *f);
void (*put_byte)(QEMUFile *f, int v);
int (*get_byte)(QEMUFile *f);
void (*put_buffer)(QEMUFile *f, const uint8_t *buf, int size);
int (*get_buffer)(QEMUFile *f, uint8_t *buf, int size);
int64_t (*tell)(QEMUFile *f);
int64_t (*seek)(QEMUFile *f, int64_t pos, int whence);
int (*eof)(QEMUFile *f);
};

|

kvm vmの扱い

サベイしますた

kvmは、xenと同様 VMのセーブやらロード、マイグレションが可能だすが、
qemuのモニタ経由らしい。

that is、 一度 ctl-alt-2押してqemu のmonitorに入る必要がある???
モヨウ

xm のように、外から、xm save とかするコマンドはないものなのけれ??

|

Live migration of virtual machines

http://www.cl.cam.ac.uk/research/srg/netos/papers/2005-migration-nsdi-pre.pdf
https://db.usenix.org/publications/library/proceedings/nsdi05/tech/full_papers/clark/clark.pdf

|

2007年8月 8日 (水)

XEN security modules

http://www.xensource.com/files/summit_3/coker-xsm-summit-090706.pdf
NSAなヤツ

event-channelやgrant-tableに、FLASKをテキヨウ???

|

キャリーフラグ

キャリーというからには、演算の桁上がりなどに使われ申し上げ奉るが、

DOS(DOS=DR)のシステムコール、ファンクションコールでは
勝手が違いまするる

3C ファイル作成 Create a File
3D ファイルオープン Open a File
41 ファイル削除 Erase a File from Directory
43 ファイルモード変更 Change File Mode
4B プログラムのロードと実行 Load or Execute a Program
4E 最初のファイル検索 Find First
56 ファイルリネーム Rename a File
5A 一時ファイル作成 Create Unique File
5B ファイル新規作成 Create New File

このよふなファンクションコールで、呼び出しが成功しない場合に、
キャリーフラグがセットされまつれる。

AXに、エラーコードが格納されまる
http://hp.vector.co.jp/authors/VA003720/lpproj/drdos/progdoc/sysprog/chap5j.htm

このよふに用いる

int 21
jnc loc_1

エラー処理

mov ax 4C
int 21 終了シェリー ビーマイン

loc_1
通常処理は続く。。

などでありますれるな

|

debug registers

私的誤解 デバッグレジスタはフラグに非ず アィヤー
MOVで操作するアルヨ

http://faydoc.tripod.com/cpu/mov2.htm
http://www.sesp.cse.clrc.ac.uk/html/SoftwareTools/vtune/users_guide/mergedProjects/analyzer_ec/mergedProjects/reference_olh/mergedProjects/instructions/instruct32_hh/vc179.htm

|

2007年8月 7日 (火)

otter

http://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-644.pdf
ケンブリジ

|

2007年8月 3日 (金)

CPU

レジスタの種類は6種類あり。。

「1」汎用レジスタ
「2」セグメントレジスタ
「3」命令ポインタ
「4」フラグレジスタ
「5」浮動少数演算ユニット
「6」システムレジスタ

VTになってから、システムレジスタのの中の
制御用レジスタが拡張された。

システムレジスタの種類

「1」システムフラグ
GDTR (global descriptor table register)
IDTR (割り込みディスクリプタテーブル)
TR (トレースレジスタ?)
LDTR (local descriptor table register)

「2」制御レジスタ CR0-4
CR0 DNA例外の扱いなど。 DNA device not available
CR1 予約
CR2 ページフォールトリニアアドレス
CR3 ページフォールトのライトスルー、キャッシュの扱いなど
CR4 タイムスタンプカウンタ、グローバルページの扱いなど

http://www.nowsmartsoft.or.tv/nws/Japanese/cpu.htm
詳しい。

「3」デバッグレジスタ DR0-7


|

2007年8月 2日 (木)

ファンクションコール

http://home.impress.co.jp/catalog/impress/bk4615/c0302.htm

システムコルのうち、INT21をファンクションコルといふ

アセムブラの解析時に、プログラムの区切り(INT21で区切る)
に てふど良い場合がありけれ

|

qemu@kvm -> internet

504 iptables -L
505 iptables -A INPUT -j ACCEPT
506 iptables -A OUTPUT -j ACCEPT
507 iptables -A FORWARD -j ACCEPT
508 cat /proc/sys/net/ipv4/ip_forward
509 echo 1 > /proc/sys/net/ipv4/ip_forward
510 cat /proc/sys/net/ipv4/ip_forward
511 iptables -t nat -A POSTROUTING -j MASQUERADE

ホストOSサイドゥの設定 緩々にしますた

|

2007年7月28日 (土)

XEN HVM on feisty

XEN HVM on feisty (ウブントゥーキック)

winのイメージだすが、
qemuだとあがるのダスが、

xm craete /etc/xen/win.hvm

とかしても、あがりませぬですた。
いろいろapt-get しますたが、徒然けり

qemuでwindowsを上げますて、
コントロルパネルでACPI(電源)の設定を変えますたら、

windowの設定の法に問題がある場合がありけり
あがりますタ。

|

2007年7月24日 (火)

KVM: kvm_dev_ioctl_interrupt

static int kvm_dev_ioctl_interrupt(struct kvm *kvm, struct kvm_interrupt *irq)
{
struct kvm_vcpu *vcpu;
// flood
printk("[kvm_main.c][kvm_ioctl_interrupt]\n");

if (!valid_vcpu(irq->vcpu))
return -EINVAL;
if (irq->irq < 0 || irq->irq >= 256)
return -EINVAL;
vcpu = vcpu_load(kvm, irq->vcpu);
if (!vcpu) return -ENOENT;

set_bit(irq->irq, vcpu->irq_pending);
set_bit(irq->irq / BITS_PER_LONG, &vcpu->irq_summary);

vcpu_put(vcpu);

return 0;
}

この関数も常に呼ばれている。

vcpu_put -> vmx_vcpu_put

static void vmx_vcpu_put(struct kvm_vcpu *vcpu)
{
put_cpu();
}


|

2007年7月23日 (月)

KVM enter_rmode (vmx.c)

Jul 23 15:49:01 tbn-office-21 kernel: [19789.248338] [vmx.c][enter_rmode]
Jul 23 15:49:01 tbn-office-21 kernel: [19789.248436] [vmx.c][enter_rmode]
Jul 23 15:49:01 tbn-office-21 kernel: [19789.258456] [vmx.c][enter_rmode]
Jul 23 15:49:01 tbn-office-21 kernel: [19789.369915] [vmx.c][vmx_set_msr]:struct kvm_vcpu *vcpu, u32 msr_index, u64 data
Jul 23 15:49:01 tbn-office-21 kernel: [19789.369918] [vmx.c][vmx_set_msr]:u32 msr_index 139s
Jul 23 15:49:01 tbn-office-21 kernel: [19789.369919] [vmx.c][vmx_set_msr]:default
Jul 23 15:49:01 tbn-office-21 kernel: [19789.369920] [vmx.c][find_msr_entry]
Jul 23 15:49:01 tbn-office-21 kernel: [19789.369928] [vmx.c][vmx_get_msr]
Jul 23 15:49:01 tbn-office-21 kernel: [19789.369929] [vmx.c][find_msr_entry]
Jul 23 15:49:01 tbn-office-21 kernel: [19789.369930] [kvm_main.c][kvm_get_msr_common]
Jul 23 15:49:01 tbn-office-21 kernel: [19789.369931] [kvm_main.c][kvm_get_msr_common] kvm_vcpu, msr, *pdata
Jul 23 15:49:03 tbn-office-21 kernel: [19791.784303] [vmx.c][vmx_set_msr]:struct kvm_vcpu *vcpu, u32 msr_index, u64 data
Jul 23 15:49:03 tbn-office-21 kernel: [19791.784309] [vmx.c][vmx_set_msr]:u32 msr_index 631s
Jul 23 15:49:03 tbn-office-21 kernel: [19791.784310] [vmx.c][vmx_set_msr]:default
Jul 23 15:49:03 tbn-office-21 kernel: [19791.784311] [vmx.c][find_msr_entry]
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101130] [vmx.c][vmx_set_msr]:struct kvm_vcpu *vcpu, u32 msr_index, u64 data
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101135] [vmx.c][vmx_set_msr]:u32 msr_index 139s
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101136] [vmx.c][vmx_set_msr]:default
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101137] [vmx.c][find_msr_entry]
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101149] [vmx.c][vmx_get_msr]
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101149] [vmx.c][find_msr_entry]
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101151] [kvm_main.c][kvm_get_msr_common]
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101152] [kvm_main.c][kvm_get_msr_common] kvm_vcpu, msr, *pdata
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101227] [vmx.c][vmx_set_msr]:struct kvm_vcpu *vcpu, u32 msr_index, u64 data
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101228] [vmx.c][vmx_set_msr]:u32 msr_index 121s
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101229] [vmx.c][vmx_set_msr]:default
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101230] [vmx.c][find_msr_entry]
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101268] [vmx.c][vmx_set_msr]:struct kvm_vcpu *vcpu, u32 msr_index, u64 data
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101269] [vmx.c][vmx_set_msr]:u32 msr_index 139s
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101270] [vmx.c][vmx_set_msr]:default
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101271] [vmx.c][find_msr_entry]
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101283] [vmx.c][vmx_get_msr]
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101283] [vmx.c][find_msr_entry]
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101284] [kvm_main.c][kvm_get_msr_common]
Jul 23 15:49:26 tbn-office-21 kernel: [19814.101285] [kvm_main.c][kvm_get_msr_common] kvm_vcpu, msr, *pdata

起動時にまとめて呼ばれる。
static void enter_rmode(struct kvm_vcpu *vcpu)
{
unsigned long flags;

printk("[vmx.c][enter_rmode]\n");

vcpu->rmode.active = 1;

|

2.6.20 lsmod

Module Size Used by
binfmt_misc 12936 1
rfcomm 41112 0
l2cap 25984 5 rfcomm
bluetooth 55524 4 rfcomm,l2cap
ppdev 10372 0

i915 24704 2
drm 81684 3 i915
マザーボード

capability 6024 0
commoncap 8448 1 capability
acpi_cpufreq 10184 1
cpufreq_stats 7616 0
cpufreq_ondemand 9484 2
freq_table 6048 3 acpi_cpufreq,cpufreq_stats,cpufreq_ondemand
cpufreq_powersave 2944 0
cpufreq_conservative 8456 0
cpufreq_userspace 5664 0
video 16644 0
container 5504 0
button 8848 0
dock 10512 0
asus_acpi 17436 0
battery 10884 0
ac 6276 0
backlight 7168 1 asus_acpi
sbs 15908 0
i2c_ec 6016 1 sbs
i2c_core 23040 1 i2c_ec
af_packet 23944 0
sbp2 23940 0
lp 12580 0
fuse 46996 0
snd_hda_intel 21784 1
snd_hda_codec 164736 1 snd_hda_intel
snd_pcm_oss 44928 0
snd_mixer_oss 17664 1 snd_pcm_oss
snd_pcm 80260 3 snd_hda_intel,snd_hda_codec,snd_pcm_oss
snd_seq_dummy 4996 0
snd_seq_oss 33408 0
sr_mod 17316 0
cdrom 37792 1 sr_mod
snd_seq_midi 9728 0
snd_rawmidi 25728 1 snd_seq_midi
snd_seq_midi_event 8576 2 snd_seq_oss,snd_seq_midi
snd_seq 53104 6 snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_seq_midi_event
snd_timer 23812 2 snd_pcm,snd_seq
snd_seq_device 9228 5 snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_rawmidi,snd_seq
parport_pc 36644 1
psmouse 39048 0
shpchp 34708 0

|

2007年7月22日 (日)

KVM static vmx_set_msr

起動時に何回か呼ばれる

Jul 22 11:49:19 flare-laptop kernel: [29878.032000] [kvm_main.c][kvm_init_arch]
Jul 22 11:49:20 flare-laptop kernel: [29878.424000] [kvm_main.c][kvm_dev_ioctl_create_vcpu]
Jul 22 11:49:25 flare-laptop kernel: [29883.568000] [vmx.c][vmx_set_msr]:struct kvm_vcpu *vcpu, u32 msr_index, u64 data
Jul 22 11:49:25 flare-laptop kernel: [29883.568000] [vmx.c][vmx_get_msr]
Jul 22 11:49:25 flare-laptop kernel: [29883.568000] [kvm_main.c][kvm_get_msr_common]
Jul 22 11:49:25 flare-laptop kernel: [29883.568000] [kvm_main.c][kvm_get_msr_common] kvm_vcpu, msr, *pdata
Jul 22 11:49:27 flare-laptop kernel: [29886.180000] [vmx.c][vmx_set_msr]:struct kvm_vcpu *vcpu, u32 msr_index, u64 data
Jul 22 11:49:53 flare-laptop kernel: [29911.640000] [vmx.c][vmx_set_msr]:struct kvm_vcpu *vcpu, u32 msr_index, u64 data
Jul 22 11:49:53 flare-laptop kernel: [29911.640000] [vmx.c][vmx_get_msr]
Jul 22 11:49:53 flare-laptop kernel: [29911.640000] [kvm_main.c][kvm_get_msr_common]
Jul 22 11:49:53 flare-laptop kernel: [29911.640000] [kvm_main.c][kvm_get_msr_common] kvm_vcpu, msr, *pdata
Jul 22 11:49:53 flare-laptop kernel: [29911.640000] [vmx.c][vmx_set_msr]:struct kvm_vcpu *vcpu, u32 msr_index, u64 data
Jul 22 11:49:53 flare-laptop kernel: [29911.640000] [vmx.c][vmx_set_msr]:struct kvm_vcpu *vcpu, u32 msr_index, u64 data
Jul 22 11:49:53 flare-laptop kernel: [29911.640000] [vmx.c][vmx_get_msr]
Jul 22 11:49:53 flare-laptop kernel: [29911.640000] [kvm_main.c][kvm_get_msr_common]
Jul 22 11:49:53 flare-laptop kernel: [29911.640000] [kvm_main.c][kvm_get_msr_common] kvm_vcpu, msr, *pdata
^[[D

switch (msr_index) {
#ifdef CONFIG_X86_64
case MSR_EFER:
return kvm_set_msr_common(vcpu, msr_index, data);
case MSR_FS_BASE:
vmcs_writel(GUEST_FS_BASE, data);
break;
case MSR_GS_BASE:
vmcs_writel(GUEST_GS_BASE, data);
break;
#endif
case MSR_IA32_SYSENTER_CS:
vmcs_write32(GUEST_SYSENTER_CS, data);
break;
case MSR_IA32_SYSENTER_EIP:
vmcs_write32(GUEST_SYSENTER_EIP, data);
break;
case MSR_IA32_SYSENTER_ESP:
vmcs_write32(GUEST_SYSENTER_ESP, data);
break;
case MSR_IA32_TIME_STAMP_COUNTER: {
guest_write_tsc(data);
break;

EIP / ESP / CS とかのレジスタがありますが。。

|

2007年7月21日 (土)

XEN RING_GET_REQUEST

tx = RING_GET_REQUEST(&np->tx, i);
printk("[network_start_xmit.c][start_xmit] tx->offset %d tx->id %d tx->size %d \n",
tx->offset,tx->id,tx->size);

[network_start_xmit] RING_GET_REQUEST &np->tx,i
[network_start_xmit.c][start_xmit] tx->offset 0 tx->id 0 tx->size 0

リングバッファにTXが入っているわけではなく。。
リングバッファにTX分割り当てる??

この後、
mfn = virt_to_mfn(skb->data);

printk("[network_start_xmit] gnttab_grant_foreign_access_ref \n");
gnttab_grant_foreign_access_ref(
ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly);

skb->dataと、txの関係は??

|

2007年7月19日 (木)

kvm_create_phys_mem

これは、起動時に2回呼ばれる。

void *kvm_create_phys_mem(kvm_context_t kvm, unsigned long phys_start,
unsigned long len, int slot, int log, int writable)
{
void *ptr;
int r;
int fd = kvm->fd;
int prot = PROT_READ;
struct kvm_memory_region memory = {
.slot = slot,
.memory_size = len,
.guest_phys_addr = phys_start,
.flags = log ? KVM_MEM_LOG_DIRTY_PAGES : 0,
};

// flood
fprintf(stderr,"[kvmctl.c][kvm_create_phys_mem]\n"); r = ioctl(fd, KVM_SET_MEMORY_REGION, &memory);
if (r == -1)
return 0;

if (writable)
prot |= PROT_WRITE;

ptr = mmap(0, len, prot, MAP_SHARED, fd, phys_start);
if (ptr == MAP_FAILED)
return 0;
return ptr;
}

kvm_contextは、kvmctl.cに入っている。

struct kvm_context {
/// Filedescriptor to /dev/kvm
int fd;
/// Callbacks that KVM uses to emulate various unvirtualizable functionality
struct kvm_callbacks *callbacks;
void *opaque;
/// A pointer to the memory used as the physical memory for the guest
void *physical_memory;
};

VMのコンテキストをデバイスドライバとして扱うということでせぅか??
ナゾは深まるばかりでゴザイマス

|

kvm_run

これも呼ばれている

int kvm_run(kvm_context_t kvm, int vcpu)
{
int r;
int fd = kvm->fd;
struct kvm_run kvm_run = {
.vcpu = vcpu,
.emulated = 0,
.mmio_completed = 0,
};


// flood
// fprintf(stderr,"[kvmctl.c][kvm_run]\n");
again:
kvm_run.request_interrupt_window = try_push_interrupts(kvm);
r = ioctl(fd, KVM_RUN, &kvm_run);
post_kvm_run(kvm, &kvm_run);

kvm_run.emulated = 0;
kvm_run.mmio_completed = 0;
if (r == -1 && errno != EINTR) {
printf("kvm_run: %m\n");
exit(1);
}
if (r == -1) {
r = handle_io_window(kvm, &kvm_run);
goto more;
}
switch (kvm_run.exit_type) {

VM_EXITのハンドラをする関数か?

case KVM_EXIT_IO:
r = handle_io(kvm, &kvm_run);
break;
case KVM_EXIT_CPUID:
r = handle_cpuid(kvm, &kvm_run);
break;
case KVM_EXIT_DEBUG:
r = handle_debug(kvm, &kvm_run);
break;
case KVM_EXIT_MMIO:
r = handle_mmio(kvm, &kvm_run);
break;
case KVM_EXIT_HLT:
r = handle_halt(kvm, &kvm_run);
break;
case KVM_EXIT_IRQ_WINDOW_OPEN:
break; default:
fprintf(stderr, "unhandled vm exit: 0x%x\n", kvm_run.exit_reason);
kvm_show_regs(kvm, vcpu);
abort();
break;
}

EXITのパターンには、このようなモノがある。

|

2007年7月18日 (水)

KVM handle_exception 

コレもずっと呼ばれ続けているモヨウ
vmxはナゾである。。。

static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
{
u32 intr_info, error_code;
unsigned long cr2, rip;
u32 vect_info;
enum emulation_result er;
int r;
// flood
printk("[vmx.c][handle_exception]\n");
vect_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
intr_info = vmcs_read32(VM_EXIT_INTR_INFO);

|

kvm_inject_irq

この関数も起動時に連発される
よくわからん。。

int kvm_inject_irq(kvm_context_t kvm, int vcpu, unsigned irq)
{
struct kvm_interrupt intr;

// flood
fprintf(stderr,"[kvmctl.c][kvm_inject_irq]\n");
intr.vcpu = vcpu;
intr.irq = irq;
return ioctl(kvm->fd, KVM_INTERRUPT, &intr);
}

|

2007年7月17日 (火)

KVM: vmx_inject_gp

OS起動初期に呼ばれる関数の壱つ

static void vmx_inject_gp(struct kvm_vcpu *vcpu, unsigned error_code)
{
printk(KERN_DEBUG "inject_general_protection: rip 0x%lx\n",
vmcs_readl(GUEST_RIP));
vmcs_write32(VM_ENTRY_EXCEPTION_ERROR_CODE, error_code);
vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
GP_VECTOR |
INTR_TYPE_EXCEPTION |
INTR_INFO_DELIEVER_CODE_MASK |
INTR_INFO_VALID_MASK);
}

vmcs_write32(VM_ENTRY_EXCEPTION_ERROR_CODE, error_code);
この関数にprintkとか入れると目世辞があふるる


|

2007年7月15日 (日)

XEN TPM create thread

vtpm.cのmain関数

vtpm_managerd起動時にスレッドが3つ立つ。

= BACKEND =
vtpmloginfo(VTPM_LOG_VTPM, "[vtpmd.c][main] create threads. Hook 1 \n"); if (pthread_create(&be_thread, NULL, vtpm_manager_thread, &be_thread_params) != 0) {
vtpmlogerror(VTPM_LOG_VTPM, "Failed to launch BE Thread.\n"); exit(-1);
}

= TPMBACK =
vtpmloginfo(VTPM_LOG_VTPM, "[vtpmd.c][main] create threads. Hook 1 \n"); if (pthread_create(&dmi_thread, NULL, vtpm_manager_thread, &dmi_thread_params) != 0) {
vtpmlogerror(VTPM_LOG_VTPM, "Failed to launch DMI Thread.\n");
exit(-1);
}
vtpmloginfo(VTPM_LOG_VTPM, "[vtpmd.c][main] create threads. Hook 1 \n");

= Hotplug =
if (pthread_create(&hp_thread, NULL, vtpm_manager_thread, &hp_thread_params) != 0) {
vtpmlogerror(VTPM_LOG_VTPM, "Failed to launch HP Thread.\n");
exit(-1);
}

|

2007年7月14日 (土)

SMEG INT21

ファイル作成

locloop_2:
push cx
mov bp,data_41e
mov di,1208h
mov dx,358h
mov cx,85Ah
mov ax,100h
call sub_2
mov data_26,ax
mov ah,5Bh ; '['
mov dx,offset data_32 ; ('shit0000.COM')
xor cx,cx ; Zero register
int 21h ; DOS Services ah=function 5Bh
; create new file, name @ ds:dx
; cx=file attribute bits
jnc loc_5 ; Jump if carry=0

ファイル作成
mov ah,5Bh
3Chもあるが、5Bhは存在すればエラー

|

XEN 資料

最近はかなり詳しい資料が。。
http://www.isg.rhul.ac.uk/~uqai221/IY5608/IY5608_-_Lecture_5_Virtualisation.pdf

|

paper

http://www.cs.princeton.edu/~sudhakar/papers/memerr.pdf

|

2007年7月13日 (金)

KVM12 softmmu

softmmuがないとのエラーが出ましたが、SDL関係をAPTしていなかったためでした
./configure後のメセジが参考になりました

300 cd kvm-12
301 ls
302 ./configure
303 apt-cache search gcc
304 apt-get install gcc-3.3*
305 apt-get install uuid
306 apt-get install libasound
307 apt-get install libasound*
308 ./configure
309 make
310 apt-cache search uuid
311 apt-cache search uuid-dev libuuid1 libblkid-dev libblkid1
312 apt-get install uuid-dev libuuid1 libblkid-dev libblkid1
313 make
314 apt-get cache search qemu
315 apt-cache search qemu
316 apt-get install kqemu-common kqemu-source qemu qemu-launcher qemuctl vde vgabios
317 make
318 apt-cache search qemu
319 apt-get install softmmu
320 apt-cache search softmmu
321 ./configure
322 make
323 locate softmmu
324 ls
325 emacs Makefile
326 ls
327 cd qemu/
328 make
329 apt-cache search i386-softmmu
330 ls
331 ./confiugre
332 ./configure
333 cd ..
334 ls
335 ./confiugre
336 ./configure
337 apt-get install sdl
338 apt-cache search sdl
339 apt-get install libsdl*
340 apt-cache search sdl
341 apt-get install libsdl-*
342 apt-get install libsdl1.2-dev
343 make
344 apt-get install libsdl1.2-dev libsdl1.2debian-all libsdl-console libsdl-consok
345 ./configure
346 apt-get install libsdl1.2-dev libsdl1.2debian-all libsdl-console libsdl-console
347 make
348 history > out

|

MSR

これは、LINUXカネルとデバイスドライバの索引にはのってない。
http://download.intel.com/jp/developer/jpdoc/IA32_Arh_Dev_Man_Vol1_Online_i.pdf
を見たのでありました。

マシン固有レジスタあるいはモデル固有レジスタ
プロセッサのステータスが記入されるらしい。

アプリケーションプログラムはMSRにアクセスできない。

その他システムなレジスタとしては、

コントロールレジスタ 
システムテーブルポインタレジスタ GDTR,LDTR、IDTR
デバッグレジスタ DR*
MSRレジスタ MSR

読み取り RDMSR
書き込み WRMSR

知らなんだ

下巻の付録Bにも参考資料あるらしいでアルヨ

|

XEN netif netback

ざっと見てですが。。
初期化処理 (IRQ割り当て、リングバッファセットアップ)はinterface.c
パケット送受信のgrant tableの処理の大部分は、net_tx_actionに集中している。
と思われニキビ

ありゃそうでもないですな
xenbus.c

static int connect_rings(struct backend_info *);
static void connect(struct backend_info *);
static void maybe_connect(struct backend_info *);
static void backend_changed(struct xenbus_watch *, const char **,
unsigned int);

忘れてましたが、xenbus.cからinterface.cのnetif_map呼び出ス

|

netif_be_start_xmit XEN

int netif_be_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
netif_t *netif = netdev_priv(dev);

ここに、フックみたいなの入れると、カーネルがフリズしますだ

|

kvm_vcpu

struct kvm_vcpu {
struct kvm *kvm;
union {
struct vmcs *vmcs;
struct vcpu_svm *svm;
};
struct mutex mutex;
int cpu;
int launched;
int interrupt_window_open;
unsigned long irq_summary; /* bit vector: 1 per word in irq_pending */
#define NR_IRQ_WORDS KVM_IRQ_BITMAP_SIZE(unsigned long)
unsigned long irq_pending[NR_IRQ_WORDS];
unsigned long regs[NR_VCPU_REGS]; /* for rsp: vcpu_load_rsp_rip() */
unsigned long rip; /* needs vcpu_load_rsp_rip() */

unsigned long cr0;
unsigned long cr2; unsigned long cr3;
unsigned long cr4;
unsigned long cr8;
u64 pdptrs[4]; /* pae */
u64 shadow_efer;
u64 apic_base;
u64 ia32_misc_enable_msr;
int nmsrs;
struct vmx_msr_entry *guest_msrs;
struct vmx_msr_entry *host_msrs;

struct list_head free_pages;
struct kvm_mmu_page page_header_buf[KVM_NUM_MMU_PAGES];
struct kvm_mmu mmu;

struct kvm_mmu_memory_cache mmu_pte_chain_cache;
struct kvm_mmu_memory_cache mmu_rmap_desc_cache;

gfn_t last_pt_write_gfn;
int last_pt_write_count;

struct kvm_guest_debug guest_debug;

char fx_buf[FX_BUF_SIZE];
char *host_fx_image;
char *guest_fx_image;

int mmio_needed;
int mmio_read_completed;
int mmio_is_write;
int mmio_size;
unsigned char mmio_data[8];
gpa_t mmio_phys_addr;

struct {
int active;
u8 save_iopl;
struct kvm_save_segment {
u16 selector;
unsigned long base;
u32 limit;
u32 ar;
} tr, es, ds, fs, gs;
} rmode;
};

struct kvm {
spinlock_t lock; /* protects everything except vcpus */
int nmemslots;
struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS];
/*
* Hash table of struct kvm_mmu_page.
*/
struct list_head active_mmu_pages;
int n_free_mmu_pages;
struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES];
struct kvm_vcpu vcpus[KVM_MAX_VCPUS];
int memory_config_version;
int busy;
unsigned long rmap_overflow;
};

ソースコードが、USERとKERNELでわかれている。
IOCTLをつかう。

見当たるのは。。CR,MSRレジスタ
MMUのところは、よくわからん。

LINUXをハイパバイザーとして使う。
XENとかやってると、かなりシンプルに見える。

|

2007年7月12日 (木)

XEN net_start_xmit netfront

static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
id = get_id_from_freelist(np->tx_skbs);

np->tx_skbs[id] = skb;

//typedef struct netif_tx_request {
// grant_ref_t gref; /* Reference to buffer page */
// uint16_t offset; /* Offset within buffer page */
// uint16_t flags; /* NETTXF_* */
// uint16_t id; /* Echoed in response message. */
// uint16_t size; /* Packet size in bytes. */
//} netif_tx_request_t;

//struct netfront_info *np = netdev_priv(dev);
//struct netfront info
//netif_tx_front_ring_t tx;

printk("[network_start_xmit] RING_GET_REQUEST &np->tx,i \n");

// netif_tx_request_t *tx;
tx = RING_GET_REQUEST(&np->tx, i);
RING_GET_REQUESTの方向が分からん。。

tx->id = id;

// typedef uint32_t grant_ref_t;
// grant_ref_t gref_tx_head;

printk("[network_start_xmit] gnttab_claim_grant_reference &np->gref_tx_head \n");

   *gnttab_grant_foreign_access_refの引数ゲット
ref = gnttab_claim_grant_reference(&np->gref_tx_head);

BUG_ON((signed short)ref < 0);

    *gnttab_grant_foreign_access_refの引数ゲット
mfn = virt_to_mfn(skb->data);

printk("[network_start_xmit] gnttab_grant_foreign_access_ref \n");

gnttab_grant_foreign_access_ref(
ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly);

   *その後、tx構造体を埋めてnotifyする。

tx->gref = np->grant_tx_ref[id] = ref;
tx->offset = (unsigned long)skb->data & ~PAGE_MASK;
tx->size = skb->len;

tx->flags = 0;
if (skb->ip_summed == CHECKSUM_HW) /* local packet? */
tx->flags |= NETTXF_csum_blank | NETTXF_data_validated;
if (skb->proto_data_valid) /* remote but checksummed? */
tx->flags |= NETTXF_data_validated;

np->tx.req_prod_pvt = i + 1;

   printk("[network_start_xmit] RING_PUSH_REQUESTS_AND_CHECK_NOTIFY ENTER notify %d \n",notify);
RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&np->tx, notify);
printk("[network_start_xmit] RING_PUSH_REQUESTS_AND_CHECK_NOTIFY RETURN notify %d \n",notify);

if (notify)
notify_remote_via_irq(np->irq);

不明な関数
   ref = gnttab_claim_grant_reference(&np->gref_tx_head);

np構造体はすでに埋まってんのか??

network_openとか、setup_deviceとかで一部埋められているヨウダ~

|

エンデバー

http://ascii24.com/news/i/hard/article/2006/11/21/665966-000.html
ええな~
降ってこね~かな~

|

2007年7月11日 (水)

RING_PUSH_REQUESTS_AND_CHECK_NOTIFY

network_start_xmitの関数

static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)

    printk("[network_start_xmit] RING_PUSH_REQUESTS_AND_CHECK_NOTIFY ENTER notify %d \n",notify);
RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&np->tx, notify);
printk("[network_start_xmit] RING_PUSH_REQUESTS_AND_CHECK_NOTIFY RETURN notify %d \n",notify);

if (notify)
notify_remote_via_irq(np->irq);

[network_start_xmit] RING_PUSH_REQUESTS_AND_CHECK_NOTIFY ENTER notify -1046406236
[network_start_xmit] RING_PUSH_REQUESTS_AND_CHECK_NOTIFY RETURN notify 1

この関数によってnotifyの値が埋まる。1の場合のみ、IRQを叩く。

|

2007年7月 9日 (月)

postfix on ubuntu

cvs4:/usr/lib# postfix
postfix: fatal: chdir(/usr/libexec/postfix): No such file or directory

こういうエラーがデル。

postfixは、/usr/libに格納されているので、

main.cfを変更
daemon_directory = /usr/lib/postfix

|

2007年7月 6日 (金)

RING_GET_REQUEST XEN

saba:/usr/src/forgrep/xen-unstable/linux-2.6-xen-sparse/drivers/xen/netfront# grep -n RING_GET_REQUEST *

netfront.c:587: RING_GET_REQUEST(&np->rx, req_prod + i)->id = id;
netfront.c:594: RING_GET_REQUEST(&np->rx, req_prod + i)->gref = ref;
netfront.c:685: tx = RING_GET_REQUEST(&np->tx, i);
netfront.c:796: RING_GET_REQUEST(&np->rx, np->rx.req_prod_pvt)->id =
netfront.c:798: RING_GET_REQUEST(&np->rx, np->rx.req_prod_pvt)->gref =
netfront.c:1011: tx = RING_GET_REQUEST(&np->tx, requeue_idx);
netfront.c:1042: RING_GET_REQUEST(&np->rx, requeue_idx)->gref =
netfront.c:1044: RING_GET_REQUEST(&np->rx, requeue_idx)->id = i;

このうち、network_alloc_rx_buffersのRING_GET_REQUESTが連発される。
PINGを打つと、
[network_start_xmit] RING_GET_REQUEST
[network_start_xmit] RING_GET_REQUEST
が繰り返される。

|

KVM12 on feisty 2.6.20

521 apt-get install uuid
522 make
523 updatedb
524 locate uuid.h
525 ls
526 apt-cache search uuid
527 apt-get install uuid-dev
528 make
529 ls
530 apt-cache search
531 apt-cache search alsa
532 apt-get install alsa-*
533 apt-get install alsa-base
534 ls
535 make
536 apt-get install alsa-source
537 ls
538 cd qemu/
539 ls
540 emacs MA
541 ls
542 emacs Makefile
543 ls
544 grep alsa *
545 emacs configure
546 ./configure
547 make
548 ls
549 ./configure
550 ./configure --disable-gcc-check
551 make
552 ls
553 make clean
554 make
555 ls
556 cd ..
557 ls
558 cd ..
559 s
560 ls
561 rm -rf kvm-12
562 ls
563 tar zxvf kvm-12.tar.gz
564 cd kvm-1
565 cd kvm-12
566 ./configure
567 make
568 ls
569 apt-cache search alsa
570 apt-get install lib*alsa*
571 apt-get install libasound*
572 ifconifg
573 ls
574 make
575 history > out

kvm12では、uuidとalsa関係でエラーがデルニコフ

|

xen qemu_set_fd_handler

fprintf(logfile, "[helper2.c][main_loop] qemu_set_fd_handler evtchn_fd %d cpu_handle_ioreq, NULL, env \n",evtchn_fd);
fprintf(logfile, "[helper2.c][main_loop] ENTER \n");
qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, env);
fprintf(logfile, "[helper2.c][main_loop] RETURN \n");

こうすると、

[helper2.c][main_loop] qemu_set_fd_handler evtchn_fd 11 cpu_handle_ioreq, NULL, env
[helper2.c][main_loop] ENTER
[vl.c][qemu_set_fd_handler2] fd 11
[helper2.c][main_loop] RETURN
I/O request not ready: 0, ptr: 0, port: 0, data: 0, count: 0, size: 0
[xenstore.c]xenstore_process_event

こうなる。関数から、かえってきてからエラーがでるわけですが。。
set_fd_handlerはハンドラ登録関数であるそうな。
cpu_handle_ioreq,内でエラーが発生。


|

2007年7月 5日 (木)

qemu_set_fd_handler

qemu: the number of cpus is 1
Watching /local/domain/6/logdirty/next-active
qemu_map_cache_init nr_buckets = 4000
shared page at pfn 7fff
buffered io page at pfn 7ffd
Time offset set 0
init_ioports / main
xenstore_read_vncpasswd / main
xenstore_read_vncpasswd / xenstore.c .
xs_read(): vncpasswd get error. /vm/25016da6-2963-072d-ef25-391a2cd49a0d/vncpasswd.
char device redirected to /dev/pts/10
[vl.c][qemu_set_fd_handler2] fd 9
[vl.c][qemu_set_fd_handler2] fd 7
[helper2.c][main_loop] qemu_set_fd_handler evtchn_fd 11
[vl.c][qemu_set_fd_handler2] fd 11
I/O request not ready: 0, ptr: 0, port: 0, data: 0, count: 0, size: 0

helper.2のmain_loopの前に、qemu_set_fd_handlerが2回呼ばれている。。
vnc.cか、gdbstub.cのどちらかでしょか

|

qemu_set_fd_handler XEN

helper2の関数。 main loopから呼ばれる。
qemu_set_fd_handler

vl.c
int qemu_set_fd_handler(int fd,
IOHandler *fd_read,
IOHandler *fd_write,
void *opaque)
{
return qemu_set_fd_handler2(fd, NULL, fd_read, fd_write, opaque);
}

helper2.cのmain loopから呼ばれる
qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, env);

cpu_handle_ioreq,の
なかに、cpu_get_ioreq()があり、その中の__cpu_get_ioreqに
このようなメッセージが。。

if (req->state != STATE_IOREQ_READY) {
fprintf(logfile, "I/O request not ready: "
"%x, ptr: %x, port: %"PRIx64", "
"data: %"PRIx64", count: %"PRIx64", size: %"PRIx64"\n",
req->state, req->data_is_ptr, req->addr,
req->data, req->count, req->size);
return NULL;
}

|

2007年7月 4日 (水)

xen 3.1 on feisty

apt-get update
apt-get install openssh-server make libncurses5-dev libncurses5 gcc libc6-dev zlib1g-dev python python-dev python-twisted bridge-utils iproute libcurl3 li\
bcurl3-dev bzip2 module-init-tools
apt-get install x-dev x11-common xlibs-dev libx11-6 libx11-6-dbg libx11-data libx11-dev
apt-get install gettext*

このよにAPT致しました

|

XEN ioemu

helper2のメイン部分

int main_loop(void)
{
extern int vm_running;
extern int shutdown_requested;
extern int suspend_requested;
CPUState *env = cpu_single_env;
int evtchn_fd = xc_evtchn_fd(xce_handle);
char qemu_file[20];

buffered_io_timer = qemu_new_timer(rt_clock, handle_buffered_io,
cpu_single_env);
qemu_mod_timer(buffered_io_timer, qemu_get_clock(rt_clock));

fprintf(logfile, "qemu_set_fd_handler \n");

qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, env);

while (!(vm_running && suspend_requested))
/* Wait up to 10 msec. */
main_loop_wait(10);

fprintf(logfile, "device model received suspend signal!\n");

/* Pull all outstanding ioreqs through the system */
handle_buffered_io(env);
main_loop_wait(1); /* For the select() on events */

/* Stop the IDE thread */
ide_stop_dma_thread();

/* Save the device state */
sprintf(qemu_file, "/tmp/xen.qemu-dm.%d", domid);
if (qemu_savevm(qemu_file) < 0)
fprintf(stderr, "qemu save fail.\n");

return 0;
}

// qemuで動くが、hvmで動かないwindows
// この関数内でエラーが出る。

static ioreq_t *__cpu_get_ioreq(int vcpu)
{
ioreq_t *req;

// fprintf(logfile, "__cpu_get_ioreq vcpu %d",vcpu);

req = &(shared_page->vcpu_iodata[vcpu].vp_ioreq);

if (req->state != STATE_IOREQ_READY) {
fprintf(logfile, "I/O request not ready: "
"%x, ptr: %x, port: %"PRIx64", "
"data: %"PRIx64", count: %"PRIx64", size: %"PRIx64"\n",
req->state, req->data_is_ptr, req->addr,
req->data, req->count, req->size);
return NULL;
}

rmb(); /* see IOREQ_READY /then/ read contents of ioreq */

req->state = STATE_IOREQ_INPROCESS;
return req;
}

これでreq構造体をゲット
req = &(shared_page->vcpu_iodata[vcpu].vp_ioreq);

/*
* VMExit dispatcher should cooperate with instruction decoder to
* prepare this structure and notify service OS and DM by sending
* virq
*/
struct ioreq {
uint64_t addr; /* physical address */
uint64_t size; /* size in bytes */
uint64_t count; /* for rep prefixes */
uint64_t data; /* data (or paddr of data) */
uint8_t state:4;
uint8_t data_is_ptr:1; /* if 1, data above is the guest paddr
* of the real data to use. */
uint8_t dir:1; /* 1=read, 0=write */
uint8_t df:1;
uint8_t type; /* I/O type */
uint8_t _pad0[6];
uint64_t io_count; /* How many IO done on a vcpu */
};
typedef struct ioreq ioreq_t;

req = &(shared_page->vcpu_iodata[vcpu].vp_ioreq);
ですが、shared_pageは、
helper2.cの最初の方

shared_iopage_t *shared_page = NULL;

で定義されている。

構造体は、ioreq.h

struct vcpu_iodata {
struct ioreq vp_ioreq;
/* Event channel port, used for notifications to/from the device model. */
uint32_t vp_eport;
uint32_t _pad0;
};
typedef struct vcpu_iodata vcpu_iodata_t;

struct shared_iopage {
struct vcpu_iodata vcpu_iodata[1];
};
typedef struct shared_iopage shared_iopage_t;


|

2007年7月 3日 (火)

xen hvmloader

[auau firmware]# make
***********************************************************
Require dev86 package version >= 0.16.14 to build firmware!
(visit http://www.cix.co.uk/~mayday for more information)
***********************************************************

こんなんでましたので、dev86を入れました。

63 time make world
64 time make install
65 ls
66 cd /boot
67 ls
68 cd grub/
69 ls
70 ls
71 emacs menu.lst
72 yum install emacs
73 emacs menu.lst
74 ls
75 mkinitrd -v /boot/initrd.img-2.6.16-xen 2.6.16-xen
76 mkinitrd -v /boot/initrd.img-2.6.18-xen 2.6.18-xen
77 emacs menu.lst
78 ls
79 mv /lib/tls/ /lib/tls.disabled
80 ls
81 uname -a
82 reboot
83 ls
84 cd /etc
85 ls
86 tail -f /var/log/xend.log
87 cd /var/log/
88 ls
89 tail -f messages
90 ls
91 cd xen/
92 ls
93 tail -f xend.log
94 ls
95 cd /usr/src
96 ls
97 cd xen-3.1.0-srcls
98 cd xen-3.1.0-src
99 ls
100 cd tools/
101 ls
102 cd ioemu/
103 make
104 maek install
105 make install
106 cd /usr/lib/xen/bin
107 ls
108 history

なんか途中から、qemuが立ち上がるようになりますた
qemu-dmがしかるべき場所になかったからか???

windowsはqemuでインス取る申し上げました

windows98は、qemuでは動きますが、HVMではフリズ致しまする

|

2007年6月30日 (土)

アセンブラ 最適化

http://download.intel.com/jp/developer/jpdoc/ia_opti.pdf

|

2007年6月29日 (金)

xen 3.1.0 on feisty ubuntu

1 fcondif
2 ls
3 cd /etc
4 ls
5 cd network/
6 ls
7 vi interfaces
8 ls
9 apt-get update
10 ls
11 cd /home/flare/
12 ls
13 vi .bashrc
14 ls
15 reboot
16 export
17 ls
18 apls
19 ls
20 ifconfig
21 ls
22 cd /etc
23 ls
24 cd apt/
25 ls
26 vi sources.list
27 ls
28 apt-get udpate
29 apt-get update
30 ls
31 apt-get update
32 ls
33 cd /home/f
34 ls
35 cd /home/flare/
36 ls
37 vi .bashrc
38 ls
39 reboot
40 ls
41 ifconfig
42 sl
43 ls
44 vi .bashrc
45 apt-get update
46 ls
47 ifconfig
48 ls
49 cd /root
50 cd /home/flare/
51 ls
52 vi .bashrc
53 ls
54 bash
55 l
56 apt-get update
57 ls
58 cd /etc
59 ls
60 vi resolv.conf
61 ls
62 apt-get update
63 ls
64 cd /usr/rsc

69 lcd
70 ls
71 ifconfig
72 ls
73 l
74 ifconfig
75 l
76 mx list
77 l
78 ls
79 cd /usr/rsc
80 lc
81 ls
82 cd /usr/src
83 ls

85 ls
86 cd mkuserdomain/
87 ls
88 chmod 700 aptget.sh
89 ls
90 ./aptget.sh
91 ls
92 ifconifg
93 ifconfig
94 ls
95 xm lit
96 l
97 ls
98 cd ..
99 ls

101 ls
102 tar zxvf xen-3.1.0-src.tgz
103 ls
104 cd xen-3.1.0-src/
105 ls
106 time make world
107 apt-get install x-dev x11-common xlibs-dev libx11-6 libx11-6-dbg libx11-data libx11-dev
108 time make world
109 apt-cache search gettext
110 apt-cache search gettext* xgettext*
111 apt-get install gettext* xgettext*
112 apt-get install gettext*
113 time make world
114 time make install
115 ls
116 cd /boot/
117 ls
118 cd /etc
119 lscd
120 emacs hosts
121 emacs hostname
122 lsc
123 ls
124 cd /etc
125 ls
126 cd /boot
127 ls
128 cd grub/
129 ls
130 free
131 ls
132 emacs menu.lst
133 ls
134 cd /lib/modules/
135 ls
136 cd /boot
137 ls
138 cd grub/
139 ls
140 emacs menu.lst
141 ls
142 mkinitramfs -o /boot/initrd.img-2.6.18-xen /lib/modules/2.6.18-xen/
143 ls
144 cd ..
145 ls
146 reboot
147 ls
148 ifconifg
149 ls
150 ifconfig
151 ls
152 ifconfigls
153 ls
154 cd /boot
155 ls
156 cd grub/
157 ls
158 emacs menu.lst
159 xm list
160 ls
161 history > out

apt-get update
apt-get install openssh-server make libncurses5-dev libncurses5 gcc libc6-dev zlib1g-dev python python-dev python-twisted bridge-utils iproute libcurl\
3 libcurl3-dev bzip2 module-init-tools

|

ゴア

http://blog.japan.zdnet.com/tokuda/

|

2007年6月28日 (木)

XEN net_tx_action RING_GET_REQUEST

/* Called after netfront has transmitted */
static void net_tx_action(unsigned long unused)
{

netif_tx_request_t txreq;

RING_FINAL_CHECK_FOR_REQUESTS(&netif->tx, work_to_do);
if (!work_to_do) { netif_put(netif);
continue;
}

i = netif->tx.req_cons;
rmb(); /* Ensure that we see the request before we copy it. */

memcpy(&txreq, RING_GET_REQUEST(&netif->tx, i), sizeof(txreq));

txreq構造体はコチラ
   
    typedef struct netif_tx_request {
    grant_ref_t gref; /* Reference to buffer page */
   uint16_t offset; /* Offset within buffer page */
   uint16_t flags; /* NETTXF_* */
   uint16_t id; /* Echoed in response message. */
   uint16_t size; /* Packet size in bytes. */
    } netif_tx_request_t;  

   tx = RING_GET_REQUEST(&np->tx, i);
    フロントエンドではこのやぅに使われている。なぜ?

まぁ~ RING_GET_REQUESTするとリクエスト系の構造体が手に入るモヨウでありマス

|

setup_blkring / setup_device

リングバッファを作成して、イベントチャンネルを割り当てる。

●ブロックデバイスの場合
static int setup_blkring(struct xenbus_device *dev,
struct blkfront_info *info)
{
   blkif_sring_t *sring;
   int err;

err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring));
if (err < 0) {
free_page((unsigned long)sring);
info->ring.sring = NULL;
goto fail; }
info->ring_ref = err;

err = xenbus_alloc_evtchn(dev, &info->evtchn);
if (err)
goto fail;

err = bind_evtchn_to_irqhandler(
info->evtchn, blkif_int, SA_SAMPLE_RANDOM, "blkif", info);
if (err <= 0) {
xenbus_dev_fatal(dev, err,
"bind_evtchn_to_irqhandler failed");
goto fail;
}
info->irq = err;

ringバッファを作成し、イベントチャンネルを割り当て、
それにIRQハンドラをバインドする。

●ネットワークデバイスの場合

static int setup_device(struct xenbus_device *dev, struct netfront_info *info)
{

送信、受信双方のリングバッファを作成する。   

    err = xenbus_grant_ring(dev, virt_to_mfn(txs));
if (err < 0)
goto fail;
info->tx_ring_ref = err;

err = xenbus_grant_ring(dev, virt_to_mfn(rxs));
if (err < 0)
goto fail;
info->rx_ring_ref = err;

   イベントチャンネルを割り当てる。

err = xenbus_alloc_evtchn(dev, &info->evtchn);
if (err)
goto fail;

memcpy(netdev->dev_addr, info->mac, ETH_ALEN);
network_connect(netdev);

   IRQハンドラをバインドする。

    info->irq = bind_evtchn_to_irqhandler(
info->evtchn, netif_int, SA_SAMPLE_RANDOM, netdev->name,
netdev);

|

XEN talk_to_backend

blkfrontの場合
static int talk_to_backend(struct xenbus_device *dev,
struct blkfront_info *info)
{
const char *message = NULL;
xenbus_transaction_t xbt;
int err;

/* Create shared ring, alloc event channel. */
err = setup_blkring(dev, info);
if (err)
goto out;

netfrontの場合
static int talk_to_backend(struct xenbus_device *dev,
struct netfront_info *info)
{
const char *message;
xenbus_transaction_t xbt;
int err;

/* Create shared ring, alloc event channel. */
err = setup_device(dev, info);
if (err)
goto out;

setup_blkrintとsetup_deviceと名前は違うが、リングバッファ?
を作成してイベントチャンネルを割り当てるのは同じ。

その後、xenbus_transactionをする。

err = xenbus_transaction_start(&xbt);
if (err) {
xenbus_dev_fatal(dev, err, "starting transaction");
goto destroy_blkring;
}

err = xenbus_printf(xbt, dev->nodename,
"ring-ref","%u", info->ring_ref);
if (err) {
message = "writing ring-ref";
goto abort_transaction;
}
err = xenbus_printf(xbt, dev->nodename,
"event-channel", "%u", info->evtchn);
if (err) {
message = "writing event-channel";
goto abort_transaction;
}

err = xenbus_transaction_end(xbt, 0);
if (err) {
if (err == -EAGAIN)
goto again;
xenbus_dev_fatal(dev, err, "completing transaction");
goto destroy_blkring;
}

xenbus_switch_state(dev, XenbusStateInitialised);


err = xenbus_transaction_start(&xbt);
if (err) {
xenbus_dev_fatal(dev, err, "starting transaction");
goto destroy_ring;
}

err = xenbus_printf(xbt, dev->nodename, "tx-ring-ref","%u",
info->tx_ring_ref);
if (err) {
message = "writing tx ring-ref";
goto abort_transaction;
}
err = xenbus_printf(xbt, dev->nodename, "rx-ring-ref","%u",
info->rx_ring_ref);
if (err) {
message = "writing rx ring-ref";
goto abort_transaction;
}
err = xenbus_printf(xbt, dev->nodename,
"event-channel", "%u", info->evtchn);
if (err) {
message = "writing event-channel";
goto abort_transaction;
}

なんかxenstore系にいろいろ書いているモヨウ


|

xen frontend probe

ブロック型デバイス
static int blkfront_probe(struct xenbus_device *dev,
const struct xenbus_device_id *id)
{
err = xenbus_scanf(XBT_NULL, dev->nodename,
"virtual-device", "%i", &vdevice);
if (err != 1) {
xenbus_dev_fatal(dev, err, "reading virtual-device");
return err;
}

err = talk_to_backend(dev, info);
if (err) {
kfree(info);
dev->data = NULL;
return err;
}


ネットワークデバイス
static int netfront_probe(struct xenbus_device *dev,
const struct xenbus_device_id *id)
{
  err = xenbus_scanf(XBT_NULL, dev->nodename, "handle", "%u", &handle);
if (err != 1) {
xenbus_dev_fatal(dev, err, "reading handle");
return err;
}

err = talk_to_backend(dev, info);
if (err) {
kfree(info);
dev->data = NULL;
return err;
}

どちらも
xenbus_scanf した後に、talk_to_backend する。

|

2007年6月27日 (水)

KVM

https://help.ubuntu.com/community/KVM
http://www.atmarkit.co.jp/flinux/rensai/watch2007/watch02a.html

http://kvm.qumranet.com/kvmwiki/HOWTO
http://blog.browncat.org/2006/12/_itli.html

http://www.kurdt.net/~peo/diary/20070104.html

http://www.ice.gelato.org/apr07/pres_pdf/gelato_ICE07apr_kvm_yu_intel.pdf

http://www.qumranet.com/wp/kvm_wp.pdf

|

XEN RING_GET_REQUEST 2

network_start_xmit より

i = np->tx.req_prod_pvt;

id = get_id_from_freelist(np->tx_skbs);
np->tx_skbs[id] = skb;

tx = RING_GET_REQUEST(&np->tx, i);

npは、netfront固有の構造体である

struct netfront_info *np = netdev_priv(dev);

blkif_queue_request より

ring_req = RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt);

infoも、blkfront固有の構造体である。

struct blkfront_info *info = req->rq_disk->private_data;

|

XEN RING_GET_REQUEST 1

netfront.cより

network_start_xmit
tx = RING_GET_REQUEST(&np->tx, i);

txはこのように定義されている。
netif_tx_request_t *tx;

この構造体は、netif.hにある。

  typedef struct netif_tx_request {
   grant_ref_t gref; /* Reference to buffer page */
  uint16_t offset; /* Offset within buffer page */
  uint16_t flags; /* NETTXF_* */
  uint16_t id; /* Echoed in response message. */
  uint16_t size; /* Packet size in bytes. */
  } netif_tx_request_t;


blkfront.cより

static int blkif_queue_request(struct request *req)

ring_req = RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt);

この関数のはじめの方で定義されている。
blkif_request_t *ring_req;

この構造体は、blkif.hにある。

 typedef struct blkif_request {
  uint8_t operation; /* BLKIF_OP_??? */
  uint8_t nr_segments; /* number of segments */
  blkif_vdev_t handle; /* only for read/write requests */
 uint64_t id; /* private guest value, echoed in resp */
 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
 struct blkif_request_segment {
  grant_ref_t gref; /* reference to I/O buffer frame */
  /* @first_sect: first sector in frame to transfer (inclusive). */
  /* @last_sect: last sector in frame to transfer (inclusive). */
 uint8_t first_sect, last_sect;
 } seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 } blkif_request_t;

|

xen grant table

リングバッファとグラントテーブル関係比較

net_tx_action

RING_FINAL_CHECK_FOR_REQUESTS(&netif->tx, work_to_do);
memcpy(&txreq, RING_GET_REQUEST(&netif->tx, i), sizeof(txreq));

gnttab_set_map_op(mop, MMAP_VADDR(pending_idx),
GNTMAP_host_map | GNTMAP_readonly,
txreq.gref, netif->domid);

ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops);

net_rx_action

gop->ref = RING_GET_REQUEST(&netif->rx, netif->rx.req_cons)->gref;
ret = HYPERVISOR_grant_table_op(GNTTABOP_transfer, grant_rx_opgop - grant_rx_op);

ゲストOSがPINGを打つと、ドメイン0では、net_tx_actionが呼ばれる。その後、パケットが帰ってくると、net_rx_actionが呼ばれる。

nt_rx_actionは、ページの所有権を持つドメイン0がドメインUにトランスファーしている。
と思われる。

|

2007年6月25日 (月)

ioctl

http://www.mnet.ne.jp/~tnomura/syscall/ioctl.c

|

2007年6月22日 (金)

IOCTL

なんか得体が知れねぃのですが。。

http://www.linux.or.jp/JM/html/LDP_man-pages/man2/ioctl.2.html

注意より
このシステムコールを使うには、オープンされたファイル・ディスクリプタが必要である。しばしば open(2) コールは望んでいない副作用を伴うことがあるが、Linux では open(2) に O_NONBLOCK フラグをつけることでこの副作用を避けることができる。

これは、システムコールでありました。 ユーザ空間から、デバイスを操作できるので、KVMでも重宝されているらすぃ。

ファイル操作なので、かねる空間でも使えるであ漏。おそらく
ドライバで、対応する(独自の)動作を用意しておければいいヨウダー。いろいろ工夫でそうですな~


|

アセンブラ (最適化)

HOW TO OPTIMIZE FOR THE PENTIUM PROCESSOR (In Japanese)
http://hp.vector.co.jp/authors/VA003988/pentopt.htm

http://www.cqpub.co.jp/hanbai/books/MIF/MIFZ200601/MIFZ200601_5syo.pdf

|

kick_pending_request_queues

blkfrontの関数。
使われている関数は、4つ

①static void connect(struct blkfront_info *info)
{
/* Kick pending requests. */
    spin_lock_irq(&blkif_io_lock);
info->connected = BLKIF_STATE_CONNECTED;
kick_pending_request_queues(info);
spin_unlock_irq(&blkif_io_lock);

②static void blkif_restart_queue(void *arg)
{
struct blkfront_info *info = (struct blkfront_info *)arg;
spin_lock_irq(&blkif_io_lock);
kick_pending_request_queues(info);
spin_unlock_irq(&blkif_io_lock);
}

③static irqreturn_t blkif_int(int irq, void *dev_id, struct pt_regs *ptregs)
{
kick_pending_request_queues(info);

④static void blkif_recover(struct blkfront_info *info)
{
/* Kick any other new requests queued since we resumed */
spin_lock_irq(&blkif_io_lock);
kick_pending_request_queues(info);
spin_unlock_irq(&blkif_io_lock);

関数本体はコチラ。
static void kick_pending_request_queues(struct blkfront_info *info)
{
if (!RING_FULL(&info->ring)) {
/* Re-enable calldowns. */
blk_start_queue(info->rq);
/* Kick things off immediately. */
do_blkif_request(info->rq);
}
}

do_blkif_request内で、

blkdev_dequeue_request(req);
if (blkif_queue_request(req)) {
blk_requeue_request(rq, req);
wait:
/* Avoid pointless unplugs. */
blk_stop_queue(rq);
break;

static int blkif_queue_request(struct request *req)
この関数が、netfrontのstart_xmitと同じような働きをスル。

つまり、
RING_GET_REQUESTやら、gnttab_claim, / gnttab_grant_foreign_access
なんかが入っている。

ネットは、NICからのバッファ扱いを、カーネルに頼む。
ブロックは、カーネルからのIO要求を、リクエストを頼まれる。
方向が違うのです。

ブロックの法が実装がややこすぃ感じがしますが、どぅでせぅか

|

network_start_xmit

フロントから見た場合、ネットワークデバイスの方がgrant tableの扱いは簡単と見た。(おそらく)

static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
{

tx = RING_GET_REQUEST(&np->tx, i);

ここから、

    tx = RING_GET_REQUEST(&np->tx, i);

tx->id = id;
ref = gnttab_claim_grant_reference(&np->gref_tx_head);
BUG_ON((signed short)ref < 0);
mfn = virt_to_mfn(skb->data);
gnttab_grant_foreign_access_ref(
ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly);
tx->gref = np->grant_tx_ref[id] = ref;
tx->offset = (unsigned long)skb->data & ~PAGE_MASK;
tx->size = skb->len;

tx->flags = 0;
if (skb->ip_summed == CHECKSUM_HW) /* local packet? */
tx->flags |= NETTXF_csum_blank | NETTXF_data_validated;
if (skb->proto_data_valid) /* remote but checksummed? */
tx->flags |= NETTXF_data_validated;

np->tx.req_prod_pvt = i + 1;
RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&np->tx, notify);

if (notify)
notify_remote_via_irq(np->irq);

リングバッファとグラントテーブルの処理が一気に行われ、IRQが叩かれる。

network_start_xmit この関数は、probe関数から、
static int create_netdev(int handle, struct xenbus_device *dev,
struct net_device **val)
が呼ばれ、この中で、

netdev->open = network_open;
netdev->hard_start_xmit = network_start_xmit;
netdev->stop = network_close;
netdev->get_stats = network_get_stats;
netdev->poll = netif_poll;
netdev->uninit = netif_uninit;
netdev->weight = 64;
netdev->features = NETIF_F_IP_CSUM;

される。


|

RING_GET_REQUEST

ネット
static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct netfront_info *np = netdev_priv(dev);
netif_tx_request_t *tx;

tx = RING_GET_REQUEST(&np->tx, i);
RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&np->tx, notify);

ブロック
static int blkif_queue_request(struct request *req)
{
struct blkfront_info *info = req->rq_disk->private_data;
blkif_request_t *ring_req;

ring_req = RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt);

この後、txとring_req構造体を埋めていくコードが続き枡。


|

RING_PUSH_REQUESTS_AND_CHECK_NOTIFY

割り込みハンドラをたたく前の関数

#define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify) do {
RING_IDX __old = (_r)->sring->req_prod;
RING_IDX __new = (_r)->req_prod_pvt;
wmb(); /* back sees requests /before/ updated producer index */
(_r)->sring->req_prod = __new;
mb(); /* back sees new requests /before/ we check req_event */
(_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) <
(RING_IDX)(__new - __old));
} while (0)

blkfrontの場合。
static inline void flush_requests(struct blkfront_info *info)
{
int notify;

RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&info->ring, notify);

if (notify)
notify_remote_via_irq(info->irq);
}

struct blkfront_info
{
struct xenbus_device *xbdev;
dev_t dev;
struct gendisk *gd;
int vdevice;
blkif_vdev_t handle;
int connected;
int ring_ref;
blkif_front_ring_t ring;
unsigned int evtchn, irq;
struct xlbd_major_info *mi;
request_queue_t *rq;
struct work_struct work;
struct gnttab_free_callback callback;
struct blk_shadow shadow[BLK_RING_SIZE];
unsigned long shadow_free;

/**
* The number of people holding this device open. We won't allow a
* hot-unplug unless this is 0.
*/
int users;
};
extern spinlock_t blkif_io_loc

blkif_front_ring_t ring;に関しては、不明。
grepしても出てこない。

netfrontの場合

static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
np->tx.req_prod_pvt = i + 1;
RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&np->tx, notify);
if (notify)
notify_remote_via_irq(np->irq);

npは、
struct netfront_info *np = netdev_priv(dev);
で宣言されておりマス。

struct netfront_info
{
struct list_head list;
struct net_device *netdev;

struct net_device_stats stats;
unsigned int tx_full;

netif_tx_front_ring_t tx;
netif_rx_front_ring_t rx;

spinlock_t tx_lock;
spinlock_t rx_lock;

unsigned int handle;
unsigned int evtchn, irq;

/* What is the status of our connection to the remote backend? */
#define BEST_CLOSED 0
#define BEST_DISCONNECTED 1
#define BEST_CONNECTED 2
unsigned int backend_state;

/* Is this interface open or closed (down or up)? */
#define UST_CLOSED 0
#define UST_OPEN 1
unsigned int user_state;

/* Receive-ring batched refills. */
#define RX_MIN_TARGET 8
#define RX_DFL_MIN_TARGET 64
#define RX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256)
int rx_min_target, rx_max_target, rx_target;
struct sk_buff_head rx_batch;

struct timer_list rx_refill_timer;

/*
* {tx,rx}_skbs store outstanding skbuffs. The first entry in each
* array is an index into a chain of free entries.
*/
struct sk_buff *tx_skbs[NET_TX_RING_SIZE+1];
struct sk_buff *rx_skbs[NET_RX_RING_SIZE+1];

#define TX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256)
grant_ref_t gref_tx_head;
grant_ref_t grant_tx_ref[NET_TX_RING_SIZE + 1];
grant_ref_t gref_rx_head;
grant_ref_t grant_rx_ref[NET_TX_RING_SIZE + 1];

struct xenbus_device *xbdev;
int tx_ring_ref;
int rx_ring_ref;
u8 mac[ETH_ALEN];

unsigned long rx_pfn_array[NET_RX_RING_SIZE];
multicall_entry_t rx_mcl[NET_RX_RING_SIZE+1];
mmu_update_t rx_mmu[NET_RX_RING_SIZE];
};

netif_tx_front_ring_t tx;に関しては、不明。
grepしても出てこない。

結局、
blkif_front_ring_t
netif_tx_front_ring_t
を代入することになる。

|

ioctl

入出力制御関数

ioctl デバイスの情報、パラメータを取得。
デバイス固有の操作を追加するのにも使われる。

|

notify_remote_via_irq(info->irq);

notify_remote_via_irqは、
RING_PUSH_REQUESTS_AND_CHECK_NOTIFYとペアになっており。。

netfrontの場合。。
static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
{

np->tx.req_prod_pvt = i + 1;
RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&np->tx, notify);
if (notify)
notify_remote_via_irq(np->irq);

blkfrontの場合。。
static inline void flush_requests(struct blkfront_info *info)
{
int notify;

RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&info->ring, notify);

if (notify)
notify_remote_via_irq(info->irq);
}

これは、この関数の中にある。
void do_blkif_request(request_queue_t *rq)
{

たどっていくと、このような関数が。。

static void connect(struct blkfront_info *info

|

xen be_int

netbackの場合
irqreturn_t netif_be_int(int irq, void *dev_id, struct pt_regs *regs)
{
netif_t *netif = dev_id;
add_to_net_schedule_list_tail(netif);
maybe_schedule_tx_action();
return IRQ_HANDLED;
}

static inline void maybe_schedule_tx_action(void)
{
smp_mb();
if ((NR_PENDING_REQS < (MAX_PENDING_REQS/2)) &&
!list_empty(&net_schedule_list))
tasklet_schedule(&net_tx_tasklet);
}

blkbackの場合
static void blkif_notify_work(blkif_t *blkif)
{
blkif->waiting_reqs = 1;
wake_up(&blkif->wq);
}

irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs)
{
blkif_notify_work(dev_id);
return IRQ_HANDLED;
}

blkif構造体は、common.hで定義されている。

typedef struct blkif_st {
/* Unique identifier for this interface. */
domid_t domid;
unsigned int handle;
/* Physical parameters of the comms window. */
unsigned int evtchn;
unsigned int irq;
/* Comms information. */
blkif_back_ring_t blk_ring;
struct vm_struct *blk_ring_area;
/* The VBD attached to this interface. */
struct vbd vbd;
/* Back pointer to the backend_info. */
struct backend_info *be;
/* Private fields. */
#ifdef CONFIG_XEN_BLKDEV_TAP_BE
/* Is this a blktap frontend */
unsigned int is_blktap;
#endif
spinlock_t blk_ring_lock;
atomic_t refcnt;
wait_queue_head_t wq;
struct task_struct *xenblkd;
unsigned int waiting_reqs;
request_queue_t *plug;

/* statistics */
unsigned long st_print;
int st_rd_req;
int st_wr_req;
int st_oo_req;

struct work_struct free_work;

grant_handle_t shmem_handle;
grant_ref_t shmem_ref;
} blkif_t;


|

2007年6月21日 (木)

grant_table

gnttab_claim_grant_reference
した後に、
gnttab_grant_foreign_access_ref
する。

ネットワークデバイスの場合は、
static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)

ブロック型デバイスの場合は、
static int blkif_queue_request(struct request *req)

ネットワークデバイス
tx->id = id;
ref = gnttab_claim_grant_reference(&np->gref_tx_head);
BUG_ON((signed short)ref < 0);
mfn = virt_to_mfn(skb->data);
gnttab_grant_foreign_access_ref(
ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly);
tx->gref = np->grant_tx_ref[id] = ref;
tx->offset = (unsigned long)skb->data & ~PAGE_MASK;
tx->size = skb->len;

ブロック型デバイス
fsect = bvec->bv_offset >> 9;
  lsect = fsect + (bvec->bv_len >> 9) - 1;

     /* install a grant reference. */
ref = gnttab_claim_grant_reference(&gref_head);
BUG_ON(ref == -ENOSPC);

gnttab_grant_foreign_access_ref(
ref,
info->xbdev->otherend_id,
buffer_mfn,
rq_data_dir(req) );

さらに比較してみると。。

N: ref = gnttab_claim_grant_reference(&np->gref_tx_head);
B: ref = gnttab_claim_grant_reference(&gref_head);
 
N: gnttab_grant_foreign_access_ref(
ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly);
B:  gnttab_grant_foreign_access_ref(
ref,info->xbdev->otherend_id,buffer_mfn,rq_data_dir(req) );

ネットの場合、mfnはソケットバッファのポインタでアル
ソケットバッファへのポインタをリングバッファにいれて割り込みをかける??

ブロックの場合、buffer_mfnは、
buffer_mfn = page_to_phys(bvec->bv_page) >> PAGE_SHIFT;
とかやる。


|

talk_to_backend

初期化関数の一環?

blkfrontの場合

/* Common code used when first setting up, and when resuming. */
static int talk_to_backend(struct xenbus_device *dev,
struct blkfront_info *info)
{
const char *message = NULL;
xenbus_transaction_t xbt;
int err;

/* Create shared ring, alloc event channel. */
err = setup_blkring(dev, info);
if (err)
goto out;

blkbackの場合

/* Common code used when first setting up, and when resuming. */
static int talk_to_backend(struct xenbus_device *dev,
struct netfront_info *info)
{
const char *message;
xenbus_transaction_t xbt;
int err;

err = xen_net_read_mac(dev, info->mac);
if (err) {
xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename);
goto out;
}

/* Create shared ring, alloc event channel. */
err = setup_device(dev, info);
if (err)
goto out;

again:
err = xenbus_transaction_start(&xbt);
if (err) {
xenbus_dev_fatal(dev, err, "starting transaction");
goto destroy_ring;
}

|

2007年6月20日 (水)

ioctl

http://homepage3.nifty.com/rio_i/lab/driver24/00205ioctl.html

linuxとwindowsの比較
http://www.geekpage.jp/blog/?id=2007/4/23

KVM資料
http://www-06.ibm.com/jp/developerworks/linux/library/l-linux-kvm/

ソケットとIOCTL
http://www.geekpage.jp/programming/linux-network/set-macaddr-2.php

linux デバイスドライバ
http://w3.icpdas.com/reed/cahier/ldd.shtml#T00032400

linux input subsystem
http://www.aya.or.jp/~takuo/input_subsystem/input_subsystem.html

hardware emulation
http://www-06.ibm.com/jp/developerworks/linux/051125/j_l-hardsim.shtml

|

gnttab_claim_grant_reference

static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
ref = gnttab_claim_grant_reference(&gref_head);

static int blkif_queue_request(struct request *req)
{
ref = gnttab_claim_grant_reference(&np->gref_tx_head);

この2つの関数で使われる。

int
gnttab_claim_grant_reference(grant_ref_t *private_head)
{
grant_ref_t g = *private_head;
if (unlikely(g == GNTTAB_LIST_END))
return -ENOSPC;
*private_head = gnttab_list[g];
return g;
}

grant_ref_t構造体が引数になっている。

#define GNTTABOP_map_grant_ref 0
typedef struct gnttab_map_grant_ref {
/* IN parameters. */
uint64_t host_addr;
uint32_t flags; /* GNTMAP_* */
grant_ref_t ref;
domid_t dom;
/* OUT parameters. */
int16_t status; /* GNTST_* */
grant_handle_t handle;
uint64_t dev_bus_addr;
} gnttab_map_grant_ref_t;
DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t);

|

RING_GET_REQUEST

RING_GET_REQUEST

static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
tx = RING_GET_REQUEST(&np->tx, i);

static int blkif_queue_request(struct request *req)
{
  ring_req = RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt); 

使われる。リングバッファのためのメモリを確保するための関数?

tx は、
typedef struct netif_tx_request {
grant_ref_t gref; /* Reference to buffer page */
uint16_t offset; /* Offset within buffer page */
uint16_t flags; /* NETTXF_* */
uint16_t id; /* Echoed in response message. */
uint16_t size; /* Packet size in bytes. */
} netif_tx_request_t;

ring_reqは、
typedef struct blkif_request {
uint8_t operation; /* BLKIF_OP_??? */
uint8_t nr_segments; /* number of segments */
blkif_vdev_t handle; /* only for read/write requests */
uint64_t id; /* private guest value, echoed in resp */
blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
struct blkif_request_segment {
grant_ref_t gref; /* reference to I/O buffer frame */
/* @first_sect: first sector in frame to transfer (inclusive). */
/* @last_sect: last sector in frame to transfer (inclusive). */
uint8_t first_sect, last_sect;
} seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
} blkif_request_t;


|

2007年6月19日 (火)

grant_table_op

ret = HYPERVISOR_grant_table_op(
GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops);
BUG_ON(ret);

引数1は静的関数
tx_map_ops
static gnttab_map_grant_ref_t tx_map_ops[MAX_PENDING_REQS];

引数2は関数内で定義
map
gnttab_map_grant_ref_t *mop;

static void net_tx_action(unsigned long unused)
{
struct list_head *ent;
struct sk_buff *skb;
netif_t *netif;
netif_tx_request_t txreq;
u16 pending_idx;
RING_IDX i;
gnttab_map_grant_ref_t *mop;
unsigned int data_len;
int ret, work_to_do;

while文のはじめで、

mop = tx_map_ops;
while ((NR_PENDING_REQS < MAX_PENDING_REQS) &&

こうして、mop++していく。

while ((NR_PENDING_REQS < MAX_PENDING_REQS) &&
!list_empty(&net_schedule_list)) {

終了条件はいまいちよくわかりませぬ。。

|

2007年6月18日 (月)

grant_table_op

pingを打つとこういうのが呼ばれる。

ret = HYPERVISOR_grant_table_op(GNTTABOP_transfer, grant_rx_op,
gop - grant_rx_op);


なんかハンドラを引数にしているモヨウ

long
do_grant_table_op(
unsigned int cmd, XEN_GUEST_HANDLE(void) uop, unsigned in\
t count)
{
long rc;
struct domain *d = current->domain;

DPRINTK("GNTTAB: grant_table_op \n");

if ( count > 512 )
return -EINVAL;

LOCK_BIGLOCK(d);

sync_pagetable_state(d);

rc = -EFAULT;
switch ( cmd )
{
case GNTTABOP_map_grant_ref:
{
XEN_GUEST_HANDLE(gnttab_map_grant_ref_t) map =
guest_handle_cast(uop, gnttab_map_grant_ref_t);
if ( unlikely(!guest_handle_okay(map, count)) )
goto out;
rc = gnttab_map_grant_ref(map, count);
break;
}

この中に、gnntab_map_grant_refという関数がある。

gnttab_map_grant_ref(
XEN_GUEST_HANDLE(gnttab_map_grant_ref_t) uop, unsigned int c\
ount)
{
int i;
struct gnttab_map_grant_ref op;

for ( i = 0; i < count; i++ )
{
if ( unlikely(__copy_from_guest_offset(&op, uop, i, 1)) \
)
return -EFAULT;
__gnttab_map_grant_ref(&op);
if ( unlikely(__copy_to_guest_offset(uop, i, &op, 1)) )
return -EFAULT;
}

return 0;
}

grant_rx_op,
は、netbackの最初の方で定義されており。。。

static struct sk_buff_head rx_queue;
static multicall_entry_t rx_mcl[NET_RX_RING_SIZE+1];
static mmu_update_t rx_mmu[NET_RX_RING_SIZE];
static gnttab_transfer_t grant_rx_op[NET_RX_RING_SIZE];
static unsigned char rx_notify[NR_IRQS];

grant_table.hから。

#define GNTTABOP_transfer 4
typedef struct gnttab_transfer {
/* IN parameters. */
unsigned long mfn;
domid_t domid;
grant_ref_t ref;
/* OUT parameters. */
int16_t status;
} gnttab_transfer_t;
DEFINE_XEN_GUEST_HANDLE(gnttab_transfer_t);

この構造体を渡す。ドメインIDと、アドレスなどでしょうか


|

2007年6月17日 (日)

model check

ftp://info.mcs.anl.gov/pub/tech_reports/reports/TM-261.pdf

|

2007年6月16日 (土)

secure routing

http://www.cs.berkeley.edu/~ckarlof/papers/senroute-adnj.pdf

http://lcawww.epfl.ch/papadimitratos/secure-routing-cnds02.pdf

http://webs.cs.berkeley.edu/papers/sensor-route-security.pdf

|

2007年6月15日 (金)

DoS

http://www.ensc.sfu.ca/~ljilja/papers/smc00.pdf
キホン

http://lib.tkk.fi/Diss/2006/isbn9512282151/article2.pdf
対策

http://www.caip.rutgers.edu/TASSL/Papers/ddos-icics-04.pdf
トポロジ

無線への攻撃
http://www.caip.rutgers.edu/TASSL/Papers/ddos-icics-04.pdf

Fidelity
http://www.cs.purdue.edu/homes/fahmy/emist/abstracts/fidelity.pdf

センサーネットへの攻撃
http://www.cs.mu.oz.au/~caleckie/ijdsn.pdf

RREQ攻撃 (NS2シナリオつき)
http://www.softcomputing.net/iwdc-manet.pdf

WIRELESS トポロジ

http://www.ieee-infocom.org/2006/Posters/1568980862_Attacker%20Traceback%20and%20Countermeasure%20with%20Cross-layer%20Monitoring/CrossLayerMonitoring.pdf

キホン
http://www-static.cc.gatech.edu/~yian/Zhang_03.pdf

トポロジ
http://www.cs.bu.edu/faculty/matta/Papers/roq-ccn04.pdf

repeated packets
http://faculty.uoit.ca/vargas/IJIS-06-published-version.pdf

|

NS-2 wireless

http://www.winlab.rutgers.edu/~zhibinwu/html/network_simulator_2.html

REDの無線評価
http://www.cs.fiu.edu/~czhang/publication/ijcs2004.pdf

simulation vs emulation
http://www.ctr.kcl.ac.uk/IWWAN2005/papers/56.pdf


|

2007年6月14日 (木)

NS-2

http://www.isi.edu/nsnam/ns/tutorial/

|

2007年6月13日 (水)

code obfuscation

http://www.cs.arizona.edu/solar/papers/CCS2003.pdf

http://pages.cs.wisc.edu/~arinib/writeup.pdf
http://www.cs.wisc.edu/techreports/2005/TR1531.pdf

|

Shrews

http://www.cs.northwestern.edu/~akuzma/rice/shrew/

http://www.diadem-firewall.org/publications/

|

ryumin light not found

Error: Ryumin-Light not found, using Font Substitution.
これは、
dvipskするとでますです。

dvipsvしたらでなくなりますた

|

DoS NS2

http://www.cs.northwestern.edu/~akuzma/rice/shrew/
http://staff.washington.edu/dittrich/misc/ddos/

|

2007年6月11日 (月)

グラフ分割

http://www-or.amp.i.kyoto-u.ac.jp/algo-eng/db/demo/GraphPartition/index.html
http://www.logos.t.u-tokyo.ac.jp/~tau/lecture/graph/index.html

http://www.dbsj.org/Japanese/DBSJLetters/vol2/no4/papers/maekawa.pdf
http://www-imase.ics.es.osaka-u.ac.jp/paper/Kogawa06_Sougou.pdf

|

wireless

http://www-mura.ist.osaka-u.ac.jp/achievements/web2001/papers/tak-ymmt01rts-PacketDuplication.pdf
http://spa.jssst.or.jp/2005/papers/papers/spa2005-10-1.pdf

http://www.winlab.rutgers.edu/~zhibinwu/html/network_simulator_2.html
http://www.katto.comm.waseda.ac.jp/~katto/conferences/ieice/2003-spring/02.pdf

http://www-ivs.cs.uni-magdeburg.de/EuK/forschung/projekte/nse/howtos/ns2uml_userguide.pdf
http://www-static.cc.gatech.edu/~yian/Zhang_03.pdf

|

2007年6月 9日 (土)

仮想化マシンモニタ(VT以前)

欲しいのは、モノではなくロジックだったりする。。

CPUの構造

リング3 リング2 リング1 リング0

通常は、OSはリング0で稼動する。
VM上でOSを動かす場合、リング1で稼動させないといけない。

完全仮想化以前は、これが問題であった。

2つの解決方法

バイナリトランスレーション(VMWARE、BOCHS おそらく)
デバッガとか、仮想CPU を用意して、
ゲストOSのハードウェアアクセス、割り込みをトラップする。
重いといわれる。

擬似仮想化(パラバーチャリゼーション)
ゲストOSのソースを修正する。
軽いが、WINDOWSとかの修正はできないので動かない。

ユーザにしてみれば、GUIや端末からの入力に対して、
適切な出力や効果が返ってくればヨイので、中が
ホント(物理的)がウソかはどうでもよい。
ほしいのは、ロジカルな効果である。

OSにしてみれば、ハードウェアやデバイスドライバへの
アクセスに対して、適切な応答が返ってくれば、バグらない。

この2者の要求を満たしていれば、だれも文句は言わない
(遅いというのはあるかも知れないが)
何も変わらず事が進む上に、管理コストが減る。

要は、CPUの性能が劇的に上がったことに端を発する。。

ゲストOSについて

基本的に、OSは、
ハードウェアへのアクセスを、ドライバに頼む (ブロック、キャラクタデバイス)
か、
ドライバから、アプリにデータを上げる(ネットワーク)ことを頼まれるの2つしかない。

そのため、この2方向のアクセスを仮想化すればよい。
XENは、ブロックとネットワークIO要求だけを仮想化し、実際のドライバ処理は
ホストドメインに頼む。
そのため、ゲストOSには、2,3種類(他は、端末ドライバなど)のドライバしか
ない。タイマとかはありますが。

バージョン3から、そうなったらしいが、この辺の設計方針が、
ブレイクした原因なのでは?


|

2007年6月 6日 (水)

NS2 on Ubuntu

1 ls
2 ifconfig
3 ls
4 cd /usr/src
5 ls
6 scp
7 scp -r ruo@ccz00.sfc.keio.ac.jp:nict/mkuserdomain .
8 ls
9 cd mkuserdomain/
10 ls
11 chmod 700 aptget.sh
12 cd /etc
13 ls
14 cd apt/
15 ls
16 vi sources.list
17 apt-get update
18 ls
19 cd /usr/src
20 l
21 scd mkuserdomain/
22 ls
23 cd mkuserdomain/
24 ls
25 ./aptget.sh
26 ls
27 cd /usr/rsc
28 ls
29 cd /usr/rsc
30 cd /usr/src
31 ls
32 mv /home/flare/ns-allinone-2.31.tar.gz ./
33 tar zxvf ns-allinone-2.31.tar.gz
34 cd ns-allinone-2.31/
35 ls
36 ./install
37 apt-get install tcl
38 apt-get install tcl*
39* apt-get updat
40 apt-get install tcl-tk*
41 apt-get install tcl*
42 ls
43 apt-cache search tcl*
44 apt-cache search tcl
45 apt-get install tcl8.4*
46 apt-get install tcl8.4
47 apt-get install tcl8.4-dev
48 apt-get install tcl8.4-doc
49 apt-cache search tk*
50 apt-cache search tk
51 apt-cache search tk | grep tcl
52 ./install
53 apt-get install tk*
54 apt-get install tk8.4.14
55 apt-cache search tk* | more
56 apt-cache search tk | more
57 apt-cache search tk8.4
58 apt-get install tk8.4
59 apt-get install tk8.4-dev
60 apt-get install tk8.4-doc
61 ./install
62 apt-get install g++
63 ./install
64 ls
65 cd bin/
66 ls
67 cd ..
68 ls
69 cd nam-1.13/
70 ls
71 cd bin/
72 ls
73 cd ..
74 ls
75 cd ..
76 ls
77 cd nam-1.13/
78 ls
79 cd bin
80 ls
81 cd ..
82 ls
83 cd ..
84 ls
85 cd tclcl-1.19/
86 ls
87 cd bin
88 ls
89 cd ..
90 ls
91 cd ..
92 ls
93 cd ns-2.31/
94 ls
95 cd bin
96 ls
97 cd NS
98 ls
99 updatedb
100 locate nam
101 locate nam | grep bin
102 nam
103 cd ..
104 ls
105 cd ..
106 ls
107 cd ..
108 ls
109 cd nam-1.13/
110 ./configure
111 make
112 apt-cache search X
113 apt-cache search X11
114 apt-cache search X11*
115 apt-get install X11*
116 apt-cache search X11 | more
117 apt-cache search x11*
118 apt-get install x11*
119 apt-cache search X11 | more
120 apt-get install x-dev
121 apt-cache search X11 | more
122 apt-get install x11-common xlibs-dev libx*
123 apt-cache search X11 | more
124 apt-get install x11-common xlibs-dev libx11-6 libx11-6-dbg libx11-data libx11-dev
125 make
126 make install
127 ls
128 cd bin/
129 ls
130 cd ..
131 ls
132 cd tcl
133 ls
134 nam
135 cd test
136 ls
137 cd ..
138 ls
139 cd ..
140 ls
141 cd ..
142 ls
143 cd tcl8.4.14/
144 ls
145 cd ..
146 ls
147 cd ns-2.31/
148 ls
149 cd ..
150 ls
151 ns
152 cd bin/
153 ls
154 cd ..
155 ls
156 cd nam-1.13/
157 nam
158 cd ..
159 lls
160 ls
161 cd ns-2.31/
162 ./configure
163 make
164 make install
165 ns
166 ls
167 history
168 history > out

|

netif XEN

割り込みハンドラ的なモノが2つある。。

[root@server xen-unstable]# grep -rin netif_be_start_xmit *
linux-2.6-xen-sparse/drivers/xen/netback/interface.c:107: dev->hard_start_xmit = netif_be_start_xmit;
linux-2.6-xen-sparse/drivers/xen/netback/common.h:77: /* Allow netif_be_start_xmit() to peek ahead in the rx request ring. */
linux-2.6-xen-sparse/drivers/xen/netback/common.h:119:int netif_be_start_xmit(struct sk_buff *skb, struct net_device *dev);
linux-2.6-xen-sparse/drivers/xen/netback/netback.c:142:int netif_be_start_xmit(struct sk_buff *skb, struct net_device *dev)
[root@sever xen-unstable]# grep -rin net_tx_action *
ChangeLog:25432:summary: split deallocation from net_tx_action
linux-2.6-xen-sparse/drivers/xen/netback/netback.c:55:static void net_tx_action(unsigned long unused);
linux-2.6-xen-sparse/drivers/xen/netback/netback.c:56:static DECLARE_TASKLET(net_tx_tasklet, net_tx_action, 0);
linux-2.6-xen-sparse/drivers/xen/netback/netback.c:439:inline static void net_tx_action_dealloc(void)
linux-2.6-xen-sparse/drivers/xen/netback/netback.c:480:static void net_tx_action(unsigned long unused)
linux-2.6-xen-sparse/drivers/xen/netback/netback.c:493: net_tx_action_dealloc();
linux-2.6-xen-sparse/net/core/dev.c:1506:static void net_tx_action(struct softirq_action *h)
linux-2.6-xen-sparse/net/core/dev.c:3317: open_softirq(NET_TX_SOFTIRQ, net_tx_action, NULL);

net_tx_actionは、dev.csで登録されている。

static int __init net_dev_init(void)
{

dev_boot_phase = 0;

open_softirq(NET_TX_SOFTIRQ, net_tx_action, NULL);
open_softirq(NET_RX_SOFTIRQ, net_rx_action, NULL);

hotcpu_notifier(dev_cpu_callback, 0);
dst_init();
dev_mcast_init();
rc = 0;

netif_be_start_xmit は、interface.cで登録されている。

netif_t *alloc_netif(domid_t domid, unsigned int handle, u8 be_mac[ETH_ALEN])
{

dev->hard_start_xmit = netif_be_start_xmit;
dev->get_stats = netif_be_get_stats;
dev->open = net_open;
dev->stop = net_close;
dev->features = NETIF_F_IP_CSUM;

netif構造体のメンバとして登録されるらしい。。

|

2007年6月 4日 (月)

LMAC verification

http://eprints.eemcs.utwente.nl/9447/01/lmac_verification.pdf

|

2007年6月 1日 (金)

model checking tutorial

http://www.loria.fr/~merz/papers/mc-tutorial.pdf

|

PRISM

http://www.cs.bham.ac.uk/~dxp/prism/

|

キャスト

struct iphdr *iph;
Broadcast message from root (pts/3) (Fri Jun 1 11:45:53 2007):
printk("NETFRONT: network_start_xmit \n");
The system is going down for reboot NOW!
iph = skb->nh.iph = (struct iphdr *)(skb->data);

ソケットバッファからIP構造体へ

|

2007年5月31日 (木)

XEN pdf

ウヒョー

http://www.cl.cam.ac.uk/research/srg/netos/papers/2004-oasis-ngio.pdf
http://www.atdot.net/~ko1/vimpl/w3ml.cgi/vimpl/msg/48/0/AIST_xen_intro_20061206_2.pdf

http://www.ylug.jp/download/hypercall_ylug_20061027.pdf
http://wiki.xensource.com/xenwiki/XenRoadMap?action=AttachFile&do=get&target=xenroad.pdf

http://people.inf.ethz.ch/troscoe/pubs/hotos07-hype.pdf
http://www.acsac.org/2006/papers/58.pdf

http://ds.informatik.uni-marburg.de/de/publications/pdf/Xen%20and%20the%20Art%20of%20Cluster%20Scheduling.pdf

http://www.cse.psu.edu/~bhuvan/teaching/spring06/papers/xen-net-opt.pdf

http://www.ertos.nicta.com.au/publications/papers/Heiser_UL_06.pdf

|

porting MINIX to xen

http://choices.cs.uiuc.edu/cache/Report.pdf

|

GNTTABOP_map_grant_ref

バックエンド側で使われる。

static void net_tx_action(unsigned long unused)
{

ret = HYPERVISOR_grant_table_op(
GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops);

netback.cの最初の方で定義される。
static gnttab_map_grant_ref_t tx_map_ops[MAX_PENDING_REQS];

構造体はコチラ grant_table.h

#define GNTTABOP_map_grant_ref 0
typedef struct gnttab_map_grant_ref {
/* IN parameters. */
uint64_t host_addr;
uint32_t flags; /* GNTMAP_* */
grant_ref_t ref;
domid_t dom;
/* OUT parameters. */
int16_t status; /* GNTST_* */
grant_handle_t handle;
uint64_t dev_bus_addr;
} gnttab_map_grant_ref_t;
DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t);

long
do_grant_table_op(
unsigned int cmd, XEN_GUEST_HANDLE(void) uop, unsigned int count)

XEN_GUEST_HANDLE(gnttab_map_grant_ref_t) map =
guest_handle_cast(uop, gnttab_map_grant_ref_t);
if ( unlikely(!guest_handle_okay(map, count)) )

cmdでスイッチして、キャストするらしい。。

|

2007年5月30日 (水)

grant table on netfront

NETFRONT: network_start_xmit

NETFRONT: gnttab_grant_foreign_access_ref / network_start_xmit /
NETFRONT: ref 10

RINGに何かPUSHする?

NETFRONT: np->xbdev->otherend_id 0
NETFRONT: tx->size 42
NETFRONT: tx->offset 3074

printk("NETFRONT: tx->size %d \n",tx->size);
printk("NETFRONT: tx->offset %d \n",tx->offset);

np->tx.req_prod_pvt = i + 1;
RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&np->tx, notify);

ソフトウェア割り込みをかける

NETFRONT: network_start_xmit irq 263
if (notify)
notify_remote_via_irq(np->irq);

network_tx_buf_gc(dev);


BINGO: notify_remote_via_irq / evtchn.c

network_tx_buf_gc(dev);呼び出し

NETFRONT: network_tx_buf_gc
NETFRONT: HOOK 0.5 np->tx.rsp_cons:0 prod:0
NETFRONT: HOOK 4
NETFRONT: HOOK 5
NETFRONT: HOOK 3
NETFRONT: HOOK 6

ソフトウェア割り込みがかかる

NETFRONT: netif_int irq 263

内部で、network_tx_buf_gc呼び出し

spin_lock_irqsave(&np->tx_lock, flags);
network_tx_buf_gc(dev);
spin_unlock_irqrestore(&np->tx_lock, flags);

今回は、forループの中に入る

NETFRONT: network_tx_buf_gc
NETFRONT: HOOK 0.5 np->tx.rsp_cons:0 prod:1
NETFRONT: Hook 1
NETFRONT: gnttab_end_foreign_access_ref / network_tx_buf_gc
NETFRONT: HOOK 4
NETFRONT: HOOK 5
NETFRONT: HOOK 3
NETFRONT: HOOK 6

再びソフトウェア割り込みがカカル

NETFRONT: netif_int irq 263
NETFRONT: network_tx_buf_gc
NETFRONT: HOOK 0.5 np->tx.rsp_cons:1 prod:1

NETFRONT: HOOK 4
NETFRONT: HOOK 5
NETFRONT: HOOK 3
NETFRONT: HOOK 6

|

network_tx_buf_gc

その1

static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
np->tx.req_prod_pvt = i + 1;
RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&np->tx, notify);

printk("NETFRONT: network_start_xmit irq %d \n",np->irq);

if (notify)
notify_remote_via_irq(np->irq);

network_tx_buf_gc(dev);

if (RING_FULL(&np->tx) ||
gnttab_empty_grant_references(&np->gref_tx_head)) {
np->tx_full = 1;
netif_stop_queue(dev);
}
}

ソフトウェア割り込みの直後に呼ばれる。


その2

static irqreturn_t netif_int(int irq, void *dev_id, struct pt_regs *ptregs)
{
struct net_device *dev = dev_id;
struct netfront_info *np = netdev_priv(dev);
unsigned long flags;

printk("NETFRONT: netif_int irq %d \n",irq);

spin_lock_irqsave(&np->tx_lock, flags);
network_tx_buf_gc(dev);
spin_unlock_irqrestore(&np->tx_lock, flags);

if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx) &&
(np->user_state == UST_OPEN))
netif_rx_schedule(dev);

return IRQ_HANDLED;
}

割り込みハンドラ内で呼ばれる。バックエンドからの応答でトリガされるのでは??

static void network_connect(struct net_device *dev)
{
np->backend_state = BEST_CONNECTED; notify_remote_via_irq(np->irq);
network_tx_buf_gc(dev);

if (np->user_state == UST_OPEN)
netif_start_queue(dev);

spin_unlock(&np->rx_lock);
spin_unlock_irq(&np->tx_lock);
}

初期化系の関数だと思いますが。。


|

grant table on netif

PINGを打つとこうなる。。

NETFRONT: network_start_xmit
NETFRONT: gnttab_grant_foreign_access_ref / network_start_xmit /
NETFRONT: ref 10
NETFRONT: np->xbdev->otherend_id 0
NETFRONT: tx->size 42
NETFRONT: tx->offset 3074

NETFRONT: network_start_xmit irq 263
BINGO: notify_remote_via_irq / evtchn.c

NETFRONT: network_tx_buf_gc
NETFRONT: HOOK 0.5 np->tx.rsp_cons:0 prod:0
NETFRONT: HOOK 4
NETFRONT: HOOK 5
NETFRONT: HOOK 3
NETFRONT: HOOK 6
NETFRONT: netif_int irq 263

NETFRONT: network_tx_buf_gc
NETFRONT: HOOK 0.5 np->tx.rsp_cons:0 prod:1
NETFRONT: Hook 1
NETFRONT: gnttab_end_foreign_access_ref / network_tx_buf_gc
NETFRONT: HOOK 4
NETFRONT: HOOK 5
NETFRONT: HOOK 3
NETFRONT: HOOK 6
NETFRONT: netif_int irq 263
NETFRONT: network_tx_buf_gc
NETFRONT: HOOK 0.5 np->tx.rsp_cons:1 prod:1
NETFRONT: HOOK 4
NETFRONT: HOOK 5
NETFRONT: HOOK 3
NETFRONT: HOOK 6

network_tx_buf_gcは2回呼ばれる。
一回目は、gnttab_end_foreign_access_ref しないで、
ソフトウェア割り込みをかける。

分岐は、IF文ではなく、for loopでするモヨウ。

printk("NETFRONT: HOOK 0.5 np->tx.rsp_cons:%d prod:%d \n",np->tx.rsp_cons,prod);

for (i = np->tx.rsp_cons; i != prod; i++) {
printk("NETFRONT: Hook 1 \n");

2回目は、prodが1になる。
ソケットバッファをリングバッファに入れてんのでせぃか?

|

2007年5月29日 (火)

xen grant table

グラントテーブル

非特権ドメインが、他のドメインのメモリにアクセスする仕組み。

Xenのmiscドキュメントから

ドメインA:ドメインU (ゲスト)
ドメインB:ドメイン0 (ホスト)

ドメインA (おそらくゲスト)
gnttab_grant_forein_accessする

そのまえに
ref = gnttab_claim_grant_reference(&np->gref_tx_head);
とかしたりシマス。

おそらく。。。リングバッファになんか入れて、
(ソフトウェア)割り込みをかける。

ドメインB (おそらくホスト)
多分、割り込みハンドラがトリガされる。

dev.cにこんなんがありますた
open_softirq(NET_TX_SOFTIRQ, net_tx_action, NULL);
open_softirq(NET_RX_SOFTIRQ, net_rx_action, NULL);

ハンドラの中で、テーブルをマップする。
ret = HYPERVISOR_grant_table_op(
GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops);

その後フロントエンドでは、このやうな関数が呼ばれるのですが、

NETFRONT: network_tx_buf_gc
NETFRONT: netif_int
NETFRONT: network_tx_buf_gc

おそらく、
マップした後、ホストからゲストへなんか通知があるのではなぃでせぅか???


|

network_start_xmit

static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
unsigned short id;
struct netfront_info *np = netdev_priv(dev);
netif_tx_request_t *tx;
RING_IDX i;
grant_ref_t ref;
unsigned long mfn;
int notify;

グラントテーブルの要求

tx = RING_GET_REQUEST(&np->tx, i);

tx->id = id;
ref = gnttab_claim_grant_reference(&np->gref_tx_head);
BUG_ON((signed short)ref < 0);
mfn = virt_to_mfn(skb->data);

npは、このような構造体

struct netfront_info
{
struct list_head list;
struct net_device *netdev;

struct net_device_stats stats;
unsigned int tx_full;

netif_tx_front_ring_t tx;
netif_rx_front_ring_t rx;

spinlock_t tx_lock;
spinlock_t rx_lock;

unsigned int handle;
unsigned int evtchn, irq;

/* What is the status of our connection to the remote backend? */
#define BEST_CLOSED 0
#define BEST_DISCONNECTED 1#define BEST_CONNECTED 2
unsigned int backend_state;

/* Is this interface open or closed (down or up)? */
#define UST_CLOSED 0
#define UST_OPEN 1
unsigned int user_state;

/* Receive-ring batched refills. */
#define RX_MIN_TARGET 8
#define RX_DFL_MIN_TARGET 64
#define RX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256)
int rx_min_target, rx_max_target, rx_target;
struct sk_buff_head rx_batch;

struct timer_list rx_refill_timer;

/*
* {tx,rx}_skbs store outstanding skbuffs. The first entry in each
* array is an index into a chain of free entries.
*/
struct sk_buff *tx_skbs[NET_TX_RING_SIZE+1];
struct sk_buff *rx_skbs[NET_RX_RING_SIZE+1];

#define TX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256)
grant_ref_t gref_tx_head;
grant_ref_t grant_tx_ref[NET_TX_RING_SIZE + 1];
grant_ref_t gref_rx_head;
grant_ref_t grant_rx_ref[NET_TX_RING_SIZE + 1];

struct xenbus_device *xbdev;
int tx_ring_ref;
int rx_ring_ref;
u8 mac[ETH_ALEN];

unsigned long rx_pfn_array[NET_RX_RING_SIZE];
multicall_entry_t rx_mcl[NET_RX_RING_SIZE+1];
mmu_update_t rx_mmu[NET_RX_RING_SIZE];
};

グラントテーブルの許可

gnttab_grant_foreign_access_ref(
ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly);

refは、この構造体だと思われる。

#define GNTTABOP_map_grant_ref 0
typedef struct gnttab_map_grant_ref {
/* IN parameters. */
uint64_t host_addr;
uint32_t flags; /* GNTMAP_* */
grant_ref_t ref;
domid_t dom;
/* OUT parameters. */
int16_t status; /* GNTST_* */
grant_handle_t handle;
uint64_t dev_bus_addr;
} gnttab_map_grant_ref_t;
DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t);

この後は、tx構造体をウメル

typedef struct netif_tx_request {
grant_ref_t gref; /* Reference to buffer page */
uint16_t offset; /* Offset within buffer page */
uint16_t flags; /* NETTXF_* */
uint16_t id; /* Echoed in response message. */
uint16_t size; /* Packet size in bytes. */
} netif_tx_request_t;


netfront_infoをリングバッファに入れて、notifyする?
RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&np->tx, notify);

|

2007年5月28日 (月)

gnttab_grant_foreign_access_ref

ドメインU
例えば、PINGを打ったときに呼ばれる。

static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
gnttab_grant_foreign_access_ref(
ref, np->xbdev->otherend_id, mfn, GNTMAP_readonly);

関数形は此方

void
gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid,
unsigned long frame, int readonly)
{
// printk("XENCORE: gnttab_grant_foreign_access_ref \n");

shared[ref].frame = frame;
shared[ref].domid = domid;
wmb();
shared[ref].flags = GTF_permit_access | (readonly ? GTF_readonly : 0);
}

grant_ref_t は。。コレか??

#define GNTTABOP_map_grant_ref 0
typedef struct gnttab_map_grant_ref {
/* IN parameters. */
uint64_t host_addr;
uint32_t flags; /* GNTMAP_* */
grant_ref_t ref;
domid_t dom;
/* OUT parameters. */
int16_t status; /* GNTST_* */
grant_handle_t handle;
uint64_t dev_bus_addr;
} gnttab_map_grant_ref_t;
DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t);

grant_table.hから

wmbとは。。書き出し用メモリバリア
なんかわからんが、シリアライズするらそうな

命令前のベンディングしていたメモリのストア操作を実行する。
命令後の命令に対して、命令前のメモリストア操作が完了していることを保障する。

|

2007年5月27日 (日)

grant table for netif

ping : domain U -> domain 0 -> outside

メモリ確保
map
NETBACK: net_tx_action

ret = HYPERVISOR_grant_table_op(
GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops);
BUG_ON(ret);

メモリ開放
unmap
NETBACK: net_tx_action_dealloc

ハイパーバイザー関数

long
do_grant_table_op(
unsigned int cmd, XEN_GUEST_HANDLE(void) uop, unsigned int count)

tx_map_ops
static gnttab_map_grant_ref_t tx_map_ops[MAX_PENDING_REQS]

マップしたメモリをどうしているかは不明
cmdでスイッチする。
switch ( cmd )
{
case GNTTABOP_map_grant_ref:


|

do_grant_table_op

long
do_grant_table_op(
unsigned int cmd, XEN_GUEST_HANDLE(void) uop, unsigned int count)
{
long rc;
struct domain *d = current->domain;

printk("GNTTAB: do_grant_table_op \n");

if ( count > 512 )
return -EINVAL;

LOCK_BIGLOCK(d);

sync_pagetable_state(d);

rc = -EFAULT;
switch ( cmd )
{
case GNTTABOP_map_grant_ref:
{
XEN_GUEST_HANDLE(gnttab_map_grant_ref_t) map =
guest_handle_cast(uop, gnttab_map_grant_ref_t);
if ( unlikely(!guest_handle_okay(map, count)) )
goto out;
rc = gnttab_map_grant_ref(map, count);
break;
}
case GNTTABOP_unmap_grant_ref:
{
XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t) unmap =
guest_handle_cast(uop, gnttab_unmap_grant_ref_t);
if ( unlikely(!guest_handle_okay(unmap, count)) )
goto out;
rc = gnttab_unmap_grant_ref(unmap, count);
break;
}
case GNTTABOP_setup_table:
{
rc = gnttab_setup_table(
guest_handle_cast(uop, gnttab_setup_table_t), count);
break;
} case GNTTABOP_transfer:
{
XEN_GUEST_HANDLE(gnttab_transfer_t) transfer =
guest_handle_cast(uop, gnttab_transfer_t);
if ( unlikely(!guest_handle_okay(transfer, count)) )
goto out;
rc = gnttab_transfer(transfer, count);
break;
}
default:
rc = -ENOSYS;
break;
}

out:
UNLOCK_BIGLOCK(d);

return rc;
}

|

2007年5月25日 (金)

モチーフ

http://www.kazusa.or.jp/workshop/genome2005/Data/ngoto-KDRI-genome2005.pdf
suffix tree

|

2007年5月24日 (木)

grant table vif

バックエンド側の挙動

static void net_rx_action(unsigned long unused)
{
ret = HYPERVISOR_grant_table_op(GNTTABOP_transfer, grant_rx_op,gop - grant_rx_op);
}


inline static void net_tx_action_dealloc(void)
{
ret = HYPERVISOR_grant_table_op(
GNTTABOP_unmap_grant_ref, tx_unmap_ops, gop - tx_unmap_ops);
}

static void net_tx_action(unsigned long unused)
{
ret = HYPERVISOR_grant_table_op(
GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops);
}


NETBACK net_tx_action
NETBACK: GNTTABOP_map_grant_ref / net_tx_action /
NETBACK net_tx_action
ant_ref / net_tx_action /
net_tx_action_dealloc
ant_ref / net_tx_action /

NETBACK: GNTTABOP_unmap_grant_ref / dealloc
n /
NETBACK: net_rx_action
rant_ref / dealloc
n /
NETBACK: GNTTABOP_transfer
_ref / dealloc
n /
NETBACK net_tx_action
er
_ref / dealloc
n /

NETBACK: GNTTABOP_map_grant_ref / net_tx_action /

NETBACK net_tx_action
ant_ref / net_tx_action /
net_tx_action_dealloc
ant_ref / net_tx_action /
NETBACK: GNTTABOP_unmap_grant_ref / dealloc
n /
NETBACK net_tx_action
grant_ref / dealloc
n /
NETBACK: GNTTABOP_map_grant_ref / net_tx_action /
NETBACK net_tx_action
ant_ref / net_tx_action /
net_tx_action_dealloc
ant_ref / net_tx_action /
NETBACK: GNTTABOP_unmap_grant_ref / dealloc
n /
NETBACK net_tx_action
grant_ref / dealloc
n /
NETBACK: GNTTABOP_map_grant_ref / net_tx_action /
NETBACK net_tx_action
ant_ref / net_tx_action /
net_tx_action_dealloc
ant_ref / net_tx_action /
NETBACK: GNTTABOP_unmap_grant_ref / dealloc
n /

|

モチーフ

配列データベースから頻出パターンを抽出する

PrefixSpan
http://www.ieice.org/iss/de/DEWS/proc/2004/paper/6-A/6-A-04.pdf
http://www.db.is.kyushu-u.ac.jp/seminar/20040120/sainoyokou.doc

マルコフ
http://www.bi.s.u-tokyo.ac.jp/japanese/schedule/16/files/Nakai_2004_8_10a.pdf

Boyer-Moore Method
http://www.hgc.jp/~tshibuya/classes/shibuya20040514.pdf

|

汎用レジスタ

AX(アキュムレータ) データの記憶。演算用

BX(ベースアドレス) アドレス指定用のポインタ

CX(カウンタ) そのものズバリ カウンター

DX(データ) データの記憶

 

|

モチーフ

http://www.bi.s.u-tokyo.ac.jp/japanese/schedule/16/files/Nakai_2004_8_10a.pdf

|

2007年5月23日 (水)

obfuscation

version 3

GEN_PROGS: PUSH CX
MOV BP,OFFSET THE_END + SMEGSIZE
MOV DI,OFFSET THE_END + SMEGSIZE + 45
MOV DX,OFFSET DEMO
MOV CX,DEMO_SIZE
MOV AX,100h
CALL POLYMORPH
MOV AH,5Bh
MOV DX,OFFSET F_NAME
XOR CX,CX
INT 21h
JNC CREATED_OK

version 4

gen_file_loop: push cx ;
mov bp,offset SMEG_END ; set up SMEG registers
mov di,offset SMEG_END+ENGINEDATASIZE
mov dx,offset carrier ;
mov cx,offset end_carrier - offset carrier
mov ax,100 ; COM files start exec @ 100
call SMEG ; encrypt the carrier file

ax: 復号ルーチンのスタートアドレス。 COMの場合は、100H。

dx: 復号したデータのスタートアドレス
cx: 復号したいデータの長さ

bp: ワークスペース用のメモリアドレス

di: 復号用のワークスペース?CXで長さを指定してある

|

2007年5月22日 (火)

HMM

配列が2、確率が3

状態配列
観測配列

遷移確率
観測確率
事前確率

分布
熱平衡分布

|

obfuscation

register I ワークスペースを指す
register II 復号ルーチンのスタートアドレス
register III 復号対象の長さ
register IV 復号対象の開始アドレス
register V 復号ワークスペース(register III)

|

グラフ

A random graph model for power law graphs
http://www.math.ucsd.edu/~fan/power.pdf

http://www.geocities.com/babalabo/Ariadne/AriadneJ.html

グラフ生成ツール
http://www.mpi-inf.mpg.de/~ajwani/graph_gen/
http://www.algorithmic-solutions.info/leda_manual/graph_gen.html


クリーク発見
http://www.math.tau.ac.il/~nogaa/PDFS/clique3.pdf

|

2007年5月17日 (木)

Xen grant table

grant table : ドメイン間でメモリを共有する仕組み。

モード1 (B->A) リード??
ドメインBがドメインAのメモリにアクセスする場合、(ドメインAがgrantする)

前処理
1 ドメインAがリファレンスと作成し、IDとともにドメインBに送る。
2 ドメインBはリファレンスを利用して granted (許可された)フレームをマップする。

3 ドメインBがメモリにアクセスする。

後処理
4 ドメインBがgrantedフレームのマップを解除する。
5 ドメインAがgrantを削除する。

モード2 (B->A) ライト??
ドメインAがドメインBのフレームの所有権転送をACCEPTする。
これは、ネットワークドライバのパケット転送に使われる。

1 ドメインAがaccept transfer grant referenceを作成し、ドメイ