All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Verych <olecom@flower.upol.cz>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Andi Kleen <ak@muc.de>, Andrew Morton <akpm@linux-foundation.org>,
	Sam Ravnborg <sam@ravnborg.org>,
	olecom@flower.upol.cz
Subject: [pp] kbuild: lguest with private asm-offsets (and some bloat)
Date: Fri, 16 Feb 2007 16:55:27 +0100	[thread overview]
Message-ID: <20070216155527.GA14687@flower.upol.cz> (raw)
In-Reply-To: <20070213031044.GA17046@flower.upol.cz>

On Tue, Feb 13, 2007 at 04:10:44AM +0100, Oleg Verych wrote:
[]
> 
> Proposition will follow.
> 
[]

[patch proposition] kbuild: lguest with private asm-offsets

 * added some bloat to lguest's Makefile:
   - lguest doesn't rebuild, if not changed (due to FORCED implicit %o:%S),
   - support of kbuild's queit/nonquiet commands,
   - (hopefully) more readable and clear build process,
   - private asm-offsets,

 * some whitespace was killed,

 * needs "asm-offsets magic demystified, generalized".

Done on top of first lkml post of lguest.

pp-by: Oleg Verych
---
 arch/i386/kernel/asm-offsets.c |  23 +-----------------
 arch/i386/lguest/Makefile      |  40 +++++++++++++++++++++++++++++---
 arch/i386/lguest/asm-offsets.c |  31 +++++++++++++++++++++++++
 arch/i386/lguest/hypervisor.S  |   8 +++---
 
 4 files changed, 73 insertions(+), 29 deletions(-)

Index: linux-2.6.20/arch/i386/lguest/Makefile
===================================================================
--- linux-2.6.20.orig/arch/i386/lguest/Makefile	2007-02-16 15:32:51.665149000 +0100
+++ linux-2.6.20/arch/i386/lguest/Makefile	2007-02-16 16:16:48.525942500 +0100
@@ -1,2 +1,6 @@
+#
+# i386/lguest/Makefile
+#
+
 # Guest requires the paravirt_ops replacement and the bus driver.
 obj-$(CONFIG_LGUEST_GUEST) += lguest.o lguest_bus.o
@@ -7,4 +11,6 @@ lg-objs := core.o hypercalls.o page_tabl
 	segments.o io.o lguest_user.o
 
+asm-offsets-lg := $(objtree)/include/asm/asm-offsets-lg.h
+
 # We use top 4MB for guest traps page, then hypervisor. */
 HYPE_ADDR := (0xFFC00000+4096)
@@ -13,10 +19,36 @@ HYPE_DATA_SIZE := 1024
 CFLAGS += -DHYPE_ADDR="$(HYPE_ADDR)" -DHYPE_DATA_SIZE="$(HYPE_DATA_SIZE)"
 
+LD_HYPE_DATA := $(shell printf %\#x $$(($(HYPE_ADDR))))
+LD_HYPE_TEXT := $(shell printf %\#x $$(($(HYPE_ADDR)+$(HYPE_DATA_SIZE))))
+
+quiet_cmd_ld_hyber = LD [H]  $@
+      cmd_ld_hyber = $(LD) -static -Tdata=$(LD_HYPE_DATA) \
+				   -Ttext=$(LD_HYPE_TEXT) -o $@ $<
+cmd_objcopy = $(OBJCOPY) -O binary $@
+
+quiet_cmd_blob = BLOB    $@
+      cmd_blob = od -tx1 -An -v $< | sed -e 's/^ /0x/' \
+					 -e 's/$$/,/' -e 's/ /,0x/g' > $@
+quiet_cmd_offsets = GEN     $@
+      cmd_offsets = $(srctree)/scripts/mkCconstants $< $@
+
 $(obj)/core.o: $(obj)/hypervisor-blob.c
+
+$(obj)/hypervisor-blob.c: $(obj)/hypervisor-raw
+	$(call cmd,blob)
+
 # This links the hypervisor in the right place and turns it into a C array.
 $(obj)/hypervisor-raw: $(obj)/hypervisor.o
-	@$(LD) -static -Tdata=`printf %#x $$(($(HYPE_ADDR)))` -Ttext=`printf %#x $$(($(HYPE_ADDR)+$(HYPE_DATA_SIZE)))` -o $@ $< && $(OBJCOPY) -O binary $@
-$(obj)/hypervisor-blob.c: $(obj)/hypervisor-raw
-	@od -tx1 -An -v $< | sed -e 's/^ /0x/' -e 's/$$/,/' -e 's/ /,0x/g' > $@
+	$(call if_changed,ld_hyber)
+	$(call cmd,objcopy)
+
+$(obj)/hypervisor.o: $(src)/hypervisor.S $(asm-offsets-lg)
+	$(call if_changed_dep,as_o_S)
+
+$(asm-offsets-lg): $(obj)/asm-offsets.s
+	$(call cmd,offsets)
+
+$(obj)/asm-offsets.s: $(src)/asm-offsets.c
+	$(call if_changed_dep,cc_s_c)
 
-clean-files := hypervisor-blob.c hypervisor-raw
+clean-files := $(asm-offsets-lg) hypervisor-blob.c hypervisor-raw
Index: linux-2.6.20/arch/i386/lguest/asm-offsets.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.20/arch/i386/lguest/asm-offsets.c	2007-02-16 16:03:10.410813500 +0100
@@ -0,0 +1,31 @@
+/*
+ * lguest's "private"
+ */
+
+#include <linux/sched.h>
+#include <asm/lguest.h>
+#include "../lguest/lg.h"
+
+#define DEFINE(sym, val) \
+	asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+
+#define BLANK() asm volatile("\n->" : : )
+
+#define OFFSET(sym, str, mem) \
+	DEFINE(sym, offsetof(struct str, mem));
+
+void fell_lguest(void)
+{
+	BLANK();
+	OFFSET(LGUEST_DATA_irq_enabled, lguest_data, irq_enabled);
+	OFFSET(LGUEST_STATE_host_stackptr, lguest_state, host.stackptr);
+	OFFSET(LGUEST_STATE_host_pgdir, lguest_state, host.pgdir);
+	OFFSET(LGUEST_STATE_host_gdt, lguest_state, host.gdt);
+	OFFSET(LGUEST_STATE_host_idt, lguest_state, host.idt);
+	OFFSET(LGUEST_STATE_regs, lguest_state, regs);
+	OFFSET(LGUEST_STATE_gdt, lguest_state, gdt);
+	OFFSET(LGUEST_STATE_idt, lguest_state, idt);
+	OFFSET(LGUEST_STATE_gdt_table, lguest_state, gdt_table);
+	OFFSET(LGUEST_STATE_trapnum, lguest_state, regs.trapnum);
+	OFFSET(LGUEST_STATE_errcode, lguest_state, regs.errcode);
+}

Index: linux-2.6.20/arch/i386/kernel/asm-offsets.c
===================================================================
--- linux-2.6.20.orig/arch/i386/kernel/asm-offsets.c	2007-02-16 16:02:11.155110250 +0100
+++ linux-2.6.20/arch/i386/kernel/asm-offsets.c	2007-02-16 16:03:52.697456250 +0100
@@ -17,11 +17,7 @@
 #include <asm/elf.h>
 #include <asm/pda.h>
-#ifdef CONFIG_LGUEST_GUEST
-#include <asm/lguest.h>
-#include "../lguest/lg.h"
-#endif
 
 #define DEFINE(sym, val) \
-        asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+	asm volatile("\n->" #sym " %0 " #val : : "i" (val))
 
 #define BLANK() asm volatile("\n->" : : )
@@ -104,5 +100,5 @@ void foo(void)
 
 	BLANK();
- 	OFFSET(PDA_cpu, i386_pda, cpu_number);
+	OFFSET(PDA_cpu, i386_pda, cpu_number);
 	OFFSET(PDA_pcurrent, i386_pda, pcurrent);
 
@@ -116,18 +112,3 @@ void foo(void)
 	OFFSET(PARAVIRT_read_cr0, paravirt_ops, read_cr0);
 #endif
-
-#ifdef CONFIG_LGUEST_GUEST
-	BLANK();
-	OFFSET(LGUEST_DATA_irq_enabled, lguest_data, irq_enabled);
-	OFFSET(LGUEST_STATE_host_stackptr, lguest_state, host.stackptr);
-	OFFSET(LGUEST_STATE_host_pgdir, lguest_state, host.pgdir);
-	OFFSET(LGUEST_STATE_host_gdt, lguest_state, host.gdt);
-	OFFSET(LGUEST_STATE_host_idt, lguest_state, host.idt);
-	OFFSET(LGUEST_STATE_regs, lguest_state, regs);
-	OFFSET(LGUEST_STATE_gdt, lguest_state, gdt);
-	OFFSET(LGUEST_STATE_idt, lguest_state, idt);
-	OFFSET(LGUEST_STATE_gdt_table, lguest_state, gdt_table);
-	OFFSET(LGUEST_STATE_trapnum, lguest_state, regs.trapnum);
-	OFFSET(LGUEST_STATE_errcode, lguest_state, regs.errcode);
-#endif
 }
Index: linux-2.6.20/arch/i386/lguest/hypervisor.S
===================================================================
--- linux-2.6.20.orig/arch/i386/lguest/hypervisor.S	2007-02-16 16:09:02.620825250 +0100
+++ linux-2.6.20/arch/i386/lguest/hypervisor.S	2007-02-16 16:13:19.548882250 +0100
@@ -2,5 +2,5 @@
    Layout is: default_idt_entries (1k), then switch_to_guest entry point. */
 #include <linux/linkage.h>
-#include <asm/asm-offsets.h>
+#include <asm/asm-offsets-lg.h>
 #include "lg.h"
 
@@ -104,5 +104,5 @@ switch_to_guest:
 	popl	%es;							\
 	popl	%ss
-	
+
 /* Return to run_guest_once. */
 return_to_host:
@@ -151,5 +151,5 @@ deliver_to_host_with_errcode:
  .endr
 .endm
-	
+
 /* We intercept every interrupt, because we may need to switch back to
  * host.  Unfortunately we can't tell them apart except by entry
@@ -158,5 +158,5 @@ deliver_to_host_with_errcode:
 irq_stubs:
 .data
-default_idt_entries:	
+default_idt_entries:
 .text
 	IRQ_STUBS 0 1 return_to_host		/* First two traps */

  reply	other threads:[~2007-02-16 15:47 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-09  9:11 [PATCH 0/10] lguest Rusty Russell
2007-02-09  9:11 ` Rusty Russell
2007-02-09  9:14 ` [PATCH 1/10] lguest: Don't rely on last-linked fallthru when no paravirt handler Rusty Russell
2007-02-09  9:15   ` [PATCH 2/10] lguest: Export symbols for lguest as a module Rusty Russell
2007-02-09  9:32     ` Andi Kleen
2007-02-09 12:06       ` Rusty Russell
2007-02-09 13:58         ` Andi Kleen
2007-02-10 11:39           ` Rusty Russell
2007-02-09  9:17   ` [PATCH 3/10] lguest: Expose get_futex_key, get_key_refs and drop_key_refs Rusty Russell
2007-02-09  9:18   ` [PATCH 4/10] lguest: Initialize esp0 properly all the time Rusty Russell
2007-02-09  9:19     ` [PATCH 5/10] Make hvc_console.c compile on non-PowerPC Rusty Russell
2007-02-09  9:19       ` Rusty Russell
2007-02-09  9:20       ` [PATCH 6/10] lguest code: the little linux hypervisor Rusty Russell
2007-02-09  9:22         ` [PATCH 7/10] lguest: Simple lguest network driver Rusty Russell
2007-02-09  9:23           ` [PATCH 8/10] lguest: console driver Rusty Russell
2007-02-09  9:24             ` [PATCH 9/10] lguest: block driver Rusty Russell
2007-02-09  9:25               ` [PATCH 10/10] lguest: documentatation including example launcher Rusty Russell
2007-02-09  9:35         ` [PATCH 6/10] lguest code: the little linux hypervisor Andrew Morton
2007-02-09 11:00           ` Rusty Russell
2007-02-09 11:13             ` Zachary Amsden
2007-02-09 11:50               ` Andi Kleen
2007-02-09 11:54                 ` Zachary Amsden
2007-02-09 11:57                   ` Andi Kleen
2007-02-09 12:08                     ` Zachary Amsden
2007-02-09 22:29                 ` David Miller
2007-02-09 10:09         ` Andi Kleen
2007-02-09 12:39           ` Rusty Russell
2007-02-09 13:57             ` Andi Kleen
2007-02-09 15:01               ` Rusty Russell
2007-02-09 14:17             ` Sam Ravnborg
2007-02-09 15:23               ` Rusty Russell
2007-02-12 13:34                 ` [q] kbuild for private asm-offsets (Re: [PATCH 6/10] lguest code: the little linux hypervisor.) Oleg Verych
2007-02-12 17:24                   ` Andi Kleen
2007-02-12 21:41                   ` Sam Ravnborg
2007-02-12 23:41                   ` Rusty Russell
2007-02-13  3:10                     ` Oleg Verych
2007-02-13  3:10                       ` Oleg Verych
2007-02-16 15:55                       ` Oleg Verych [this message]
2007-02-16 15:59                         ` [pp] kbuild: asm-offsets generalized Oleg Verych
2007-02-16 18:56                           ` Sam Ravnborg
2007-02-16 21:56                             ` Oleg Verych
2007-02-17  4:43                               ` Rusty Russell
2007-02-17  5:33                                 ` Oleg Verych
2007-04-01 20:42                           ` Sam Ravnborg
2007-04-01 21:08                             ` Oleg Verych
2007-04-01 21:03                               ` Sam Ravnborg
2007-02-09 10:55       ` [PATCH 6a/10] lguest: Config and headers Rusty Russell
2007-02-09 10:56         ` [PATCH 6b/10] lguest: the host code (lg.ko) Rusty Russell
2007-02-09 10:57           ` [PATCH 6c/10] lguest: the guest code Rusty Russell
2007-02-09 10:58             ` [PATCH 6d/10] lguest: the Makefiles Rusty Russell
2007-02-09 17:06             ` [PATCH 6c/10] lguest: the guest code Len Brown
2007-02-09 17:14               ` James Morris
2007-02-09 17:49                 ` Len Brown
2007-02-09 23:48                   ` [PATCH 11/10] lguest: use disable_acpi() Rusty Russell
2007-02-09  9:31   ` [PATCH 1/10] lguest: Don't rely on last-linked fallthru when no paravirt handler Andi Kleen
2007-02-09 11:52     ` Rusty Russell
2007-02-09 20:49       ` Jeremy Fitzhardinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070216155527.GA14687@flower.upol.cz \
    --to=olecom@flower.upol.cz \
    --cc=ak@muc.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.