• 在ubuntu forums上看到的,如果这个分辨率不存在的话

    cvt 1024 768

    output:

    Modeline "1024x768_60.00"   63.50  1024 1072 1176 1328  768 771 775 798 -hsync +vsync

    xrandr --newmode "1024x768_60.00"   63.50  1024 1072 1176 1328  768 771 775 798 -hsync +vsync

    xrandr --addmode <yourmode> 1024x768_60.00

    <yourmode> 可以从xrandr中看到

    然后去display中就可以修改了

  • 当对手知道你的hash函数的代码实现的时候,他可以设计一个特定的input,让你的hash产生大量的collide。为了解决这个问题,可以用到universal hashing的方法。

    在算法开始时取hash函数,随机在已有的hash function family中取一个hash函数,当然这个family是需要满足universal hashing的条件的,然后就使用这个hash函数来做insert,query,delete的操作。

     

  •  

    by Scott Devine

    1.There is a miss in the TLB. The hardware will walk the shadow page table to find the mapping.

    (TLB 中cache的是从guest virtual address -> host machine address,host的cr3指向的是shadow page table的位置)

    2.One of two things can happen:

       •The required mapping is found in the page table and placed in the TLB. The instruction is restarted and all proceeds normally. Note that in this case the hardware does all the work.

      (在shadow page table中找到entry,放入TLB中)

       •The required mapping is not present. An page fault exception is generated by the hardware and trapped into the VMM. The VMM needs to translate the virtual address to a machine address. It starts by walking the  guest’s page table to determine the virtual to physical mapping. Note that the layout of the guest page table will be determined by the hardware being virtualized.

       (在shadow page table中直接到host machine address的mapping没有找到,trap进入VMM, 通过guest page table找到guest virtual address -> guest physical address)

    3.Once the VMM finds the guest mapping one of two things can happen:

       •The guest mapping is not present. In this case the guest expects a page fault exception. So the VMM must generate an exception on the virtual cpu state and resume executing on the first instruction of the guest exception handler. This is called a true page fault because the hardware page fault results in a guest visible page fault.

        (guest page table中mapping也没有,说明guest期望得到一个page fault, inject page fault在guest中,有guest处理)

       •If the guest mapping is present then the VMM must translate the physical page to a machine page. This is called a hidden page fault because the hardware fault is a fault that would not have occurred in non-virtualized system. In order to translate the physical page to machine page the VMM must look in a data structure that maps physical pages to machine pages. This data structure is defined by the VMM, for example PMap. The VMM might have perform further processing if there is no machine page backing the physical page or in other special circumstances. 

    (查找存储guest physical address -> host machine address的data structure,如果miss了,就添加)

    4.The virtual to machine translation is complete. The new translation is put into the shadow page table.

       (把这个新的mapping放入shadow page table)

    5.The VMM restarts the guest instruction that faulted. Now the hardware TLB refill mechanism will work.

    6.The hardware put the new mapping in the TLB and life goes on.

     

  • 1. Create a new virtual machine and choose its hypervisor as qemu.

    2. Name it "JOS"

    3. Configure the hard disk and memory

    4. virsh dumpxml JOS > jos.xml

    5. Edit the jos.xml like below

     1 <domain type='qemu'>
     2   <name>JOS</name>
     3   <uuid>8e7bb147-9da1-49e0-90b7-5011c54ae9a6</uuid>
     4   <memory>262144</memory>
     5   <currentMemory>262144</currentMemory>
     6   <vcpu>1</vcpu>
     7   <os>
     8     <type arch='i686' machine='pc'>hvm</type>
     9     <boot dev='hd'/>
    10   </os>
    11   <features>
    12     <acpi/>
    13     <apic/>
    14     <pae/>
    15   </features>
    16   <clock offset='utc'/>
    17   <on_poweroff>destroy</on_poweroff>
    18   <on_reboot>restart</on_reboot>
    19   <on_crash>restart</on_crash>
    20   <devices>
    21     <emulator>/home/guzhongshu/Project/Jos/qemu_wrapper.sh</emulator>
    22     <disk type='file' device='disk'>
    23       <source file='/home/guzhongshu/Project/Jos/obj/kern/bochs.img'/>
    24       <target dev='hda' bus='ide'/>
    25     </disk>
    26     <disk type='file' device='disk'>
    27       <source file='/home/guzhongshu/Project/Jos/obj/fs/fs.img'/>
    28       <target dev='hdb' bus='ide'/>
    29     </disk>
    30     <interface type='user'>
    31         <mac address='52:54:00:12:34:56'/>
    32         <model type='i82559er'/>
    33     </interface>
    34     <parallel type='stdio'>
    35       <target port='0'/>
    36     </parallel>
    37     <serial type='pty'>
    38       <target port='0'/>
    39     </serial>
    40     <console type='pty'>
    41       <target port='0'/>
    42     </console>
    43     <input type='mouse' bus='ps2'/>
    44     <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>
    45   </devices>
    46 </domain>


    6. virsh define jos.xml

    7. Add file qemu_wrapper.sh because some arguments can not be added in the xml. We need to use some trick.

    #!/bin/sh
      exec /usr/local/bin/qemu -redir tcp:8080::80 -redir tcp:4242::10000 "$@" -debug-e100 -pcap slirp.cap


  • After changing emulator to qemu, I find that the file flush in file system seems not work correctly. The data I wrote to disk lost after rebooting the machine. Finally I find that the dirty bit is not set in file_write because the address space of fs and user env is different. Copy the content of memory will only make the address of current env dirty. But the memory of fs is still clean. Add two lines after memmove in file_write

        for (i = 0; i < n; i += BLKSIZE)
            fsipc_dirty(fd->fd_file.id, offset + i);

    To send request to the file system server to mark the page dirty directly.

    Another thing to mention is that, it seems that *blk=*blk has no effect for the dirty bit. I Just map the page using syscall to modify its perm. Also please remember in the sys_map_page, you needs to modify the condition of returning invalid parameter. Add PTE_D to the reasonable parameter to perm.

     

  • Challenge! Implement interrupt-driven IDE disk access, with or without DMA. You can decide whether to move the device driver into the kernel, keep it in user space along with the file system, or even (if you really want to get into the micro-kernel spirit) move it into a separate environment of its own.

    We know that JOS is exokernel style operating system. To put ide driver into kernel space is not a graceful solution. But use upcall to dispatch them into user space needs more effort. It maybe resemble the way JOS to process the user page fault in the fork.

    I choose the easy style to move ide driver from user space to kernel. There are some points need to be take care.

    1.  JOS file system is not in kernel space. If we send read or write request from file system to ide driver, the address translation is needed. Read and write port's address is the address in the current context. I just map the page to the temp address in the current env's address space during the handling of the ide irq. But remember NOT to do this in the ide_{read,write} function because maybe the environment has yielded in the later time.

    2. After file system sends request, it needs to be blocked. But simply making it not runnable is not correct because we will return back from the system call. Return to a not runnable env is not possible. I choose to sleep the env and send signal from kernel to wake it up if the read and write operation has been completed. This is much more like the AIO model, but the advantage is that file system now is in user space, we just need to yield to other process and sleep.

    Or you can just make it not runnable when i/o and restore it to runnable if i/o complete.

    3. Write into disk needs to wait that disk is ready. Otherwise the write interrupt cannot be sent from disk.

    Future work

    1. Add an io server to process the request parallelly. More exokernel : - )

    2. Add an io scheduler to process requests in a more reasonable way.

     

  • when using windbg to analyze dump file, you need to first point the symbol table path by selecting file-> Symbol File Path

    SRV*$YOURPATH*http://msdl.microsoft.com/download/symbols

    It will download symbol table from microsoft

     

     

  • http://kapanka.com/2008/12/customizing-selenium-rc-to-take-command-line-args/

    I’ve written a few lines of code that you can use to pass a URL or the browser type you want to use from the command line, using Python.  At the bottom of your Python-based selenium test, you can replace the “if __name__ ==” part with the following code:

    if __name__ == "__main__":

    ### custom
    import sys, getopt
    global testurl, browser
    testurl = "http://127.0.0.1"
    browser = "*chrome"
    try:
    opts, args = getopt.getopt(sys.argv[1:], "", \
    ["url=","browser="])
    for opt, arg in opts:
    if opt in ("--url",):
    testurl = arg
    argument = opt + "=" + arg
    sys.argv.remove(argument)
    if opt in ("--browser",):
    browser = "*" + arg
    argument = opt + "=" + arg
    sys.argv.remove(argument)

    except:
    pass
    ### /custom

    unittest.main()

    and the setUp method with:

        def setUp(self):
    self.verificationErrors = []
    self.selenium = selenium("localhost", 4444, \
    browser, testurl)
    self.selenium.start()

    Then on the command line, you can go:

    python test_myTest.py --url=http://myurl.com --browser=iexplore

    I’m sure the code could be better, but I’m not that great with getopt.

    ~Spanky

  • http://www.codeproject.com/KB/system/VmDetect.aspx

    The Intel x86 provides two instructions to allow you to carry I/O operations, these instructions are the "IN" and "OUT" instructions. These two instructions are privileged instructions and cannot be used in a user-mode (while in protected mode) process unless the necessary privileges are enabled, so using them in normal cases will cause an exception of the type: "EXCEPTION_PRIV_INSTRUCTION".

    VMWare uses the "IN" instruction to read from a special port. This port does not effectively exist, however when VMWare is present, that port will be the interface between the virtual machine and VMWare.

    Here's the code:

       1 bool IsInsideVMWare()
       2 {
       3         bool rc = true;
       4         __try
       5         {
       6                 __asm
       7                 {
       8                         push   edx
       9                         push   ecx
      10                         push   ebx
      11
      12                         mov    eax, 'VMXh'
      13                         mov    ebx, 0 // any value but not the MAGIC VALUE
      14                         mov    ecx, 10 // get VMWare version
      15                         mov    edx, 'VX' // port number
      16
      17                         in     eax, dx // read port
      18                                        // on return EAX returns the VERSION
      19
      20                         cmp    ebx, 'VMXh' // is it a reply from VMWare?
      21
      22                         setz   [rc] // set return value
      23                         pop    ebx
      24                         pop    ecx
      25                         pop    edx
      26                 }
      27         }
      28   __except(EXCEPTION_EXECUTE_HANDLER)
      29   {
      30     rc = false;
      31   }
      32   return rc;
      33 }
    1. The program sets exception handlers (in case VMWare isn't present, we just discard its presence).
    2. Set up into the EAX register the magic number 0x564D5868 (or 'VMXh').
    3. Set EBX register to any value but the magic number.
    4. Set ECX register to the "function number" value. The value 10 means Get VMWare version, other codes means other functionality.
    5. Set into DX the magic port number 0x5658 (or 'VX'), this special port number allows interfacing with VMWare when it is present.
    6. Read from that port into EAX.
      1. When VMWare is not present, an exception will occur and we discard VMWare's presence.
      2. Otherwise, the code flow continues.
    7. EBX should now read the magic number value.
    8. If so, then VMWare is present.