lguest: 2.6.21-mm1 update: lguest-remove-unnecessary-gdt-load.patch
Subsystems (3)
PATCH 1/3 lguest: 2.6.21-mm1 update: lguest-remove-unnecessary-gdt-load.patch
Andrew did a great job of merging in the PDA->percpu changes and lguest code for 2.6.21-mm1, but the load_gdt is now unnecessary.
--- drivers/lguest/lguest.c | 4 ---- 1 file changed, 4 deletions(-)
===================================================================
drivers/lguest/lguest.c +0 -4
@@ -409,9 +409,6 @@ static unsigned lguest_patch(u8 type, u1memcpy (insns, lguest_insns[type].start, insn_len);return insn_len; } - -/* From head.S */ -extern struct Xgt_desc_struct early_gdt_descr;__init void lguest_init (void ) {
@@ -468,7 +465,6 @@ __init void lguest_init(void)/* We use top of mem for initial pagetables. */ init_pg_tables_end =__pa (pg0); -load_gdt (&early_gdt_descr); asmvolatile ("mov %0, %%fs" : :"r" (__KERNEL_DS) :"memory" );reserve_top_address (lguest_data.reserve_mem);
PATCH 2/3 lguest: 2.6.21-mm1 update: lguest-magic-signature.patch
paravirt_probe() and its infrastructure proved as popular as it was pretty. In anticipation of its imminent demise, this switches lguest to use a magic string to identify a different entry point.
This is not the long-term solution: that will take a new bootloader rev and will hopefully be done in the next few months.
--- Documentation/lguest/lguest.c | 25 +++++++++++++++++++++---- drivers/lguest/lguest.c | 2 -- drivers/lguest/lguest_asm.S | 23 +++++++++-------------- 3 files changed, 30 insertions(+), 20 deletions(-)
===================================================================
Documentation/lguest/lguest.c +21 -4
@@ -96,6 +96,19 @@ static void *map_zeroed_pages(unsigned lreturn (void *)addr; } +/* Find magic string marking entry point, return entry point. */ +static unsigned long entry_point (void *start,void *end, +unsigned long page_offset) +{ +void *p; + +for (p = start; p < end; p++) +if (memcmp (p,"GenuineLguest" ,strlen ("GenuineLguest" )) ==0 ) +return (long )p +strlen ("GenuineLguest" ) + page_offset; + +err (1 ,"Is this image a genuine lguest?" ); +} +/* Returns the entry point */ static unsigned long map_elf (int elf_fd,const Elf32_Ehdr *ehdr,unsigned long *page_offset)
@@ -103,6 +116,7 @@ static unsigned long map_elf(int elf_fd,void *addr;Elf32_Phdr phdr[ehdr->e_phnum];unsigned int i; +unsigned long start =-1UL , end =0 ;/* Sanity checks. */ if (ehdr->e_type != ET_EXEC
@@ -131,6 +145,11 @@ static unsigned long map_elf(int elf_fd, *page_offset = phdr[i].p_vaddr - phdr[i].p_paddr; else if (*page_offset != phdr[i].p_vaddr - phdr[i].p_paddr) errx(1, "Page offset of section %i different", i); + +if (phdr[i].p_paddr < start) + start = phdr[i].p_paddr; +if (phdr[i].p_paddr + phdr[i].p_filesz > end) + end = phdr[i].p_paddr + phdr[i].p_filesz;/* We map everything private, writable. */ addr = mmap((void *)phdr[i].p_paddr,
@@ -143,8 +162,7 @@ static unsigned long map_elf(int elf_fd, i, addr, (void *)phdr[i].p_paddr); } -/* Entry is physical address: convert to virtual */ -return ehdr->e_entry + *page_offset; +return entry_point ((void *)start, (void *)end, *page_offset); }/* This is amazingly reliable. */
@@ -175,8 +193,7 @@ static unsigned long unpack_bzimage(intverbose ("Unpacked size %i addr %p\n" , len, img); *page_offset =intuit_page_offset (img, len); -/* Entry is physical address: convert to virtual */ -return (unsigned long )img + *page_offset; +return entry_point (img, img + len, *page_offset); }static unsigned long load_bzimage (int fd,unsigned long *page_offset)
===================================================================
drivers/lguest/lguest.c +0 -2
@@ -43,7 +43,6 @@ extern const char lgstart_popf[], lgend_extern const char lgstart_popf[], lgend_popf[];extern const char lgstart_pushf[], lgend_pushf[];extern const char lgstart_iret[], lgend_iret[]; -extern asmlinkage void lguest_maybe_init(void);extern void lguest_iret (void );struct lguest_data lguest_data = {
@@ -497,4 +496,3 @@ __init void lguest_init(void) pm_power_off = lguest_power_off;start_kernel (); } -paravirt_probe (lguest_maybe_init);
===================================================================
drivers/lguest/lguest_asm.S +9 -14
@@ -1,29 +1,24 @@ #include <linux/linkage.h> #include <linux/lguest.h> #include <asm/asm-offsets.h> +#include <asm/thread_info.h> /* FIXME: Once asm/processor-flags.h goes in, include that */ #define X86_EFLAGS_IF 0x00000200 /* - * This is where we begin: head.S notes that paging is already enabled (which - * doesn't happen in native boot) and calls the registered paravirt_probe - * functions one at a time. Ours is a simple assembler test for magic - * registers. If they're correct we jump to lguest_init. + * This is where we begin: we have a magic signature which the launcher looks + * for. The plan is that the Linux boot protocol will be extended with a + * "platform type" field which will guide us here from the normal entry point, + * but for the moment this suffices. * * We put it in .init.text will be discarded after boot. */ .section .init.text, "ax", @progbits -ENTRY(lguest_maybe_init) - cmpl $LGUEST_MAGIC_EBP, %ebp - jne out - cmpl $LGUEST_MAGIC_EDI, %edi - jne out - cmpl $LGUEST_MAGIC_ESI, %esi - jne out - je lguest_init -out: - ret +.ascii "GenuineLguest" + /* Set up initial stack. */ + movl $(init_thread_union+THREAD_SIZE),%esp + jmp lguest_init /* The templates for inline patching. */ #define LGUEST_PATCH(name, insns...) \
PATCH 3/3 lguest: 2.6.21-mm1 update: lguest-net-stats-inline.patch
Now inline net_device_stats is upstream, we can use it in the lguest net driver.
--- drivers/net/lguest_net.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
===================================================================
drivers/net/lguest_net.c +5 -15
@@ -38,8 +38,6 @@ struct lguestnet_info/* My peerid. */ unsigned int me; -struct net_device_stats stats; -/* Receive queue. */ struct sk_buff *skb[NUM_SKBS ];struct lguest_dma dma[NUM_SKBS ];
@@ -120,13 +118,13 @@ static void transfer_packet(struct net_dhcall (LHCALL_SEND_DMA ,peer_key (info,peernum),__pa (&dma),0 );if (dma.used_len != skb->len) { - info->stats.tx_carrier_errors++; + dev->stats.tx_carrier_errors++;pr_debug ("Bad xfer to peer %i: %i of %i (dma %p/%i)\n" , peernum, dma.used_len, skb->len, (void *)dma.addr[0 ], dma.len[0 ]); }else { - info->stats.tx_bytes += skb->len; - info->stats.tx_packets++; + dev->stats.tx_bytes += skb->len; + dev->stats.tx_packets++; } }
@@ -212,8 +210,8 @@ static irqreturn_t lguestnet_rcv(int irqpr_debug ("Receiving skb proto 0x%04x len %i type %i\n" ,ntohs (skb->protocol), skb->len, skb->pkt_type); - info->stats.rx_bytes += skb->len; - info->stats.rx_packets++; + dev->stats.rx_bytes += skb->len; + dev->stats.rx_packets++;netif_rx (skb); }return done ?IRQ_HANDLED :IRQ_NONE ;
@@ -258,13 +256,6 @@ static int lguestnet_close(struct net_defor (i =0 ; i <ARRAY_SIZE (info->dma); i++)dev_kfree_skb (info->skb[i]);return 0 ; -} - -static struct net_device_stats *lguestnet_get_stats (struct net_device *dev) -{ -struct lguestnet_info *info = dev->priv; - -return &info->stats; }static int lguestnet_probe (struct lguest_device *lgdev)
@@ -295,7 +286,6 @@ static int lguestnet_probe(struct lguest dev->open = lguestnet_open; dev->stop = lguestnet_close; dev->hard_start_xmit = lguestnet_start_xmit; - dev->get_stats = lguestnet_get_stats;/* Turning on/off promisc will call dev->set_multicast_list. * We don't actually support multicast yet */
PATCH 3/3 lguest: 2.6.21-mm1 update: lguest-net-stats-inline.patch
In reply to Rusty RussellNow inline net_device_stats is upstream, we can use it in the lguest net driver.
--- drivers/net/lguest_net.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
===================================================================
drivers/net/lguest_net.c +5 -15
@@ -38,8 +38,6 @@ struct lguestnet_info/* My peerid. */ unsigned int me; -struct net_device_stats stats; -/* Receive queue. */ struct sk_buff *skb[NUM_SKBS ];struct lguest_dma dma[NUM_SKBS ];
@@ -120,13 +118,13 @@ static void transfer_packet(struct net_dhcall (LHCALL_SEND_DMA ,peer_key (info,peernum),__pa (&dma),0 );if (dma.used_len != skb->len) { - info->stats.tx_carrier_errors++; + dev->stats.tx_carrier_errors++;pr_debug ("Bad xfer to peer %i: %i of %i (dma %p/%i)\n" , peernum, dma.used_len, skb->len, (void *)dma.addr[0 ], dma.len[0 ]); }else { - info->stats.tx_bytes += skb->len; - info->stats.tx_packets++; + dev->stats.tx_bytes += skb->len; + dev->stats.tx_packets++; } }
@@ -212,8 +210,8 @@ static irqreturn_t lguestnet_rcv(int irqpr_debug ("Receiving skb proto 0x%04x len %i type %i\n" ,ntohs (skb->protocol), skb->len, skb->pkt_type); - info->stats.rx_bytes += skb->len; - info->stats.rx_packets++; + dev->stats.rx_bytes += skb->len; + dev->stats.rx_packets++;netif_rx (skb); }return done ?IRQ_HANDLED :IRQ_NONE ;
@@ -258,13 +256,6 @@ static int lguestnet_close(struct net_defor (i =0 ; i <ARRAY_SIZE (info->dma); i++)dev_kfree_skb (info->skb[i]);return 0 ; -} - -static struct net_device_stats *lguestnet_get_stats (struct net_device *dev) -{ -struct lguestnet_info *info = dev->priv; - -return &info->stats; }static int lguestnet_probe (struct lguest_device *lgdev)
@@ -295,7 +286,6 @@ static int lguestnet_probe(struct lguest dev->open = lguestnet_open; dev->stop = lguestnet_close; dev->hard_start_xmit = lguestnet_start_xmit; - dev->get_stats = lguestnet_get_stats;/* Turning on/off promisc will call dev->set_multicast_list. * We don't actually support multicast yet */