Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lguest: update comments

Also removes a long-unused #define and an extraneous semicolon.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

+50 -39
+4 -8
Documentation/virtual/lguest/lguest.c
··· 51 51 #include <asm/bootparam.h> 52 52 #include "../../../include/linux/lguest_launcher.h" 53 53 /*L:110 54 - * We can ignore the 42 include files we need for this program, but I do want 54 + * We can ignore the 43 include files we need for this program, but I do want 55 55 * to draw attention to the use of kernel-style types. 56 56 * 57 57 * As Linus said, "C is a Spartan language, and so should your naming be." I ··· 65 65 typedef uint8_t u8; 66 66 /*:*/ 67 67 68 - #define PAGE_PRESENT 0x7 /* Present, RW, Execute */ 69 68 #define BRIDGE_PFX "bridge:" 70 69 #ifndef SIOCBRADDIF 71 70 #define SIOCBRADDIF 0x89a2 /* add interface to bridge */ ··· 1358 1359 * --sharenet=<name> option which opens or creates a named pipe. This can be 1359 1360 * used to send packets to another guest in a 1:1 manner. 1360 1361 * 1361 - * More sopisticated is to use one of the tools developed for project like UML 1362 + * More sophisticated is to use one of the tools developed for project like UML 1362 1363 * to do networking. 1363 1364 * 1364 1365 * Faster is to do virtio bonding in kernel. Doing this 1:1 would be ··· 1368 1369 * multiple inter-guest channels behind one interface, although it would 1369 1370 * require some manner of hotplugging new virtio channels. 1370 1371 * 1371 - * Finally, we could implement a virtio network switch in the kernel. 1372 + * Finally, we could use a virtio network switch in the kernel, ie. vhost. 1372 1373 :*/ 1373 1374 1374 1375 static u32 str2ip(const char *ipaddr) ··· 2005 2006 /* Tell the entry path not to try to reload segment registers. */ 2006 2007 boot->hdr.loadflags |= KEEP_SEGMENTS; 2007 2008 2008 - /* 2009 - * We tell the kernel to initialize the Guest: this returns the open 2010 - * /dev/lguest file descriptor. 2011 - */ 2009 + /* We tell the kernel to initialize the Guest. */ 2012 2010 tell_kernel(start); 2013 2011 2014 2012 /* Ensure that we terminate if a device-servicing child dies. */
+1
arch/x86/include/asm/lguest_hcall.h
··· 61 61 : "memory"); 62 62 return call; 63 63 } 64 + /*:*/ 64 65 65 66 /* Can't use our min() macro here: needs to be a constant */ 66 67 #define LGUEST_IRQS (NR_IRQS < 32 ? NR_IRQS: 32)
+15 -6
arch/x86/lguest/boot.c
··· 71 71 #include <asm/stackprotector.h> 72 72 #include <asm/reboot.h> /* for struct machine_ops */ 73 73 74 - /*G:010 Welcome to the Guest! 74 + /*G:010 75 + * Welcome to the Guest! 75 76 * 76 77 * The Guest in our tale is a simple creature: identical to the Host but 77 78 * behaving in simplified but equivalent ways. In particular, the Guest is the ··· 191 190 #endif 192 191 193 192 /*G:036 194 - * When lazy mode is turned off reset the per-cpu lazy mode variable and then 195 - * issue the do-nothing hypercall to flush any stored calls. 196 - :*/ 193 + * When lazy mode is turned off, we issue the do-nothing hypercall to 194 + * flush any stored calls, and call the generic helper to reset the 195 + * per-cpu lazy mode variable. 196 + */ 197 197 static void lguest_leave_lazy_mmu_mode(void) 198 198 { 199 199 hcall(LHCALL_FLUSH_ASYNC, 0, 0, 0, 0); 200 200 paravirt_leave_lazy_mmu(); 201 201 } 202 202 203 + /* 204 + * We also catch the end of context switch; we enter lazy mode for much of 205 + * that too, so again we need to flush here. 206 + * 207 + * (Technically, this is lazy CPU mode, and normally we're in lazy MMU 208 + * mode, but unlike Xen, lguest doesn't care about the difference). 209 + */ 203 210 static void lguest_end_context_switch(struct task_struct *next) 204 211 { 205 212 hcall(LHCALL_FLUSH_ASYNC, 0, 0, 0, 0); ··· 649 640 650 641 /* 651 642 * The Guest calls this after it has set a second-level entry (pte), ie. to map 652 - * a page into a process' address space. Wetell the Host the toplevel and 643 + * a page into a process' address space. We tell the Host the toplevel and 653 644 * address this corresponds to. The Guest uses one pagetable per process, so 654 645 * we need to tell the Host which one we're changing (mm->pgd). 655 646 */ ··· 1148 1139 static __init char *lguest_memory_setup(void) 1149 1140 { 1150 1141 /* 1151 - *The Linux bootloader header contains an "e820" memory map: the 1142 + * The Linux bootloader header contains an "e820" memory map: the 1152 1143 * Launcher populated the first entry with our memory limit. 1153 1144 */ 1154 1145 e820_add_region(boot_params.e820_map[0].addr,
+11 -7
arch/x86/lguest/i386_head.S
··· 6 6 #include <asm/processor-flags.h> 7 7 8 8 /*G:020 9 - * Our story starts with the kernel booting into startup_32 in 10 - * arch/x86/kernel/head_32.S. It expects a boot header, which is created by 11 - * the bootloader (the Launcher in our case). 9 + 10 + * Our story starts with the bzImage: booting starts at startup_32 in 11 + * arch/x86/boot/compressed/head_32.S. This merely uncompresses the real 12 + * kernel in place and then jumps into it: startup_32 in 13 + * arch/x86/kernel/head_32.S. Both routines expects a boot header in the %esi 14 + * register, which is created by the bootloader (the Launcher in our case). 12 15 * 13 16 * The startup_32 function does very little: it clears the uninitialized global 14 17 * C variables which we expect to be zero (ie. BSS) and then copies the boot 15 - * header and kernel command line somewhere safe. Finally it checks the 16 - * 'hardware_subarch' field. This was introduced in 2.6.24 for lguest and Xen: 17 - * if it's set to '1' (lguest's assigned number), then it calls us here. 18 + * header and kernel command line somewhere safe, and populates some initial 19 + * page tables. Finally it checks the 'hardware_subarch' field. This was 20 + * introduced in 2.6.24 for lguest and Xen: if it's set to '1' (lguest's 21 + * assigned number), then it calls us here. 18 22 * 19 23 * WARNING: be very careful here! We're running at addresses equal to physical 20 - * addesses (around 0), not above PAGE_OFFSET as most code expectes 24 + * addesses (around 0), not above PAGE_OFFSET as most code expects 21 25 * (eg. 0xC0000000). Jumps are relative, so they're OK, but we can't touch any 22 26 * data without remembering to subtract __PAGE_OFFSET! 23 27 *
+1 -1
drivers/lguest/core.c
··· 117 117 118 118 /* 119 119 * Now the Switcher is mapped at the right address, we can't fail! 120 - * Copy in the compiled-in Switcher code (from <arch>_switcher.S). 120 + * Copy in the compiled-in Switcher code (from x86/switcher_32.S). 121 121 */ 122 122 memcpy(switcher_vma->addr, start_switcher_text, 123 123 end_switcher_text - start_switcher_text);
+2 -2
drivers/lguest/interrupts_and_traps.c
··· 427 427 428 428 /* 429 429 * Direct traps also mean that we need to know whenever the Guest wants to use 430 - * a different kernel stack, so we can change the IDT entries to use that 431 - * stack. The IDT entries expect a virtual address, so unlike most addresses 430 + * a different kernel stack, so we can change the guest TSS to use that 431 + * stack. The TSS entries expect a virtual address, so unlike most addresses 432 432 * the Guest gives us, the "esp" (stack pointer) value here is virtual, not 433 433 * physical. 434 434 *
+10 -7
drivers/lguest/lguest_user.c
··· 1 - /*P:200 This contains all the /dev/lguest code, whereby the userspace launcher 2 - * controls and communicates with the Guest. For example, the first write will 3 - * tell us the Guest's memory layout and entry point. A read will run the 4 - * Guest until something happens, such as a signal or the Guest doing a NOTIFY 5 - * out to the Launcher. 1 + /*P:200 This contains all the /dev/lguest code, whereby the userspace 2 + * launcher controls and communicates with the Guest. For example, 3 + * the first write will tell us the Guest's memory layout and entry 4 + * point. A read will run the Guest until something happens, such as 5 + * a signal or the Guest doing a NOTIFY out to the Launcher. There is 6 + * also a way for the Launcher to attach eventfds to particular NOTIFY 7 + * values instead of returning from the read() call. 6 8 :*/ 7 9 #include <linux/uaccess.h> 8 10 #include <linux/miscdevice.h> ··· 359 357 goto free_eventfds; 360 358 361 359 /* 362 - * Initialize the Guest's shadow page tables, using the toplevel 363 - * address the Launcher gave us. This allocates memory, so can fail. 360 + * Initialize the Guest's shadow page tables. This allocates 361 + * memory, so can fail. 364 362 */ 365 363 err = init_guest_pagetable(lg); 366 364 if (err) ··· 518 516 .read = read, 519 517 .llseek = default_llseek, 520 518 }; 519 + /*:*/ 521 520 522 521 /* 523 522 * This is a textbook example of a "misc" character device. Populate a "struct
+2 -2
drivers/lguest/page_tables.c
··· 155 155 } 156 156 157 157 /* 158 - * These functions are just like the above two, except they access the Guest 158 + * These functions are just like the above, except they access the Guest 159 159 * page tables. Hence they return a Guest address. 160 160 */ 161 161 static unsigned long gpgd_addr(struct lg_cpu *cpu, unsigned long vaddr) ··· 195 195 #endif 196 196 /*:*/ 197 197 198 - /*M:014 198 + /*M:007 199 199 * get_pfn is slow: we could probably try to grab batches of pages here as 200 200 * an optimization (ie. pre-faulting). 201 201 :*/
+4 -6
drivers/lguest/x86/core.c
··· 272 272 unsigned int insnlen = 0, in = 0, shift = 0; 273 273 /* 274 274 * The eip contains the *virtual* address of the Guest's instruction: 275 - * guest_pa just subtracts the Guest's page_offset. 275 + * walk the Guest's page tables to find the "physical" address. 276 276 */ 277 277 unsigned long physaddr = guest_pa(cpu, cpu->regs->eip); 278 278 ··· 409 409 * These values mean a real interrupt occurred, in which case 410 410 * the Host handler has already been run. We just do a 411 411 * friendly check if another process should now be run, then 412 - * return to run the Guest again 412 + * return to run the Guest again. 413 413 */ 414 414 cond_resched(); 415 415 return; ··· 459 459 int i; 460 460 461 461 /* 462 - * Most of the i386/switcher.S doesn't care that it's been moved; on 462 + * Most of the x86/switcher_32.S doesn't care that it's been moved; on 463 463 * Intel, jumps are relative, and it doesn't access any references to 464 464 * external code or data. 465 465 * ··· 587 587 clear_cpu_cap(&boot_cpu_data, X86_FEATURE_PGE); 588 588 } 589 589 put_online_cpus(); 590 - }; 590 + } 591 591 /*:*/ 592 592 593 593 void __exit lguest_arch_host_fini(void) ··· 670 670 /*:*/ 671 671 672 672 /*L:030 673 - * lguest_arch_setup_regs() 674 - * 675 673 * Most of the Guest's registers are left alone: we used get_zeroed_page() to 676 674 * allocate the structure, so they will be 0. 677 675 */