Skip to contentSkip to conversation

Modify lguest32 to make room for lguest64

PATCH Applied Steven Rostedt 5 participants 38 messages Aug 9, 2007 – Aug 13, 2007

Subsystems (3)
lore
Share & tools
lore
#1 lore raw

PATCH 1/7 Move lg.h to the i386 specific lguest directory

In reply to Steven Rostedt

Make a i386 directory in the lguest directory, and move the lg.h into it. This will clear the way for other archs to have their own lg.h

---
 drivers/lguest/i386/lg.h |  300 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/lguest/lg.h      |  300 ----------------------------------------------
 2 files changed, 300 insertions(+), 300 deletions(-)
drivers/lguest/i386/lg.h new file +300 -0
new file mode 100644
index 0000000..64f0abe
@@ -0,0 +1,300 @@
+#ifndef _LGUEST_H
+#define _LGUEST_H
+
+#include <asm/desc.h>
+
+#define GDT_ENTRY_LGUEST_CS	10
+#define GDT_ENTRY_LGUEST_DS	11
+#define LGUEST_CS		(GDT_ENTRY_LGUEST_CS * 8)
+#define LGUEST_DS		(GDT_ENTRY_LGUEST_DS * 8)
+
+#ifndef __ASSEMBLY__
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/stringify.h>
+#include <linux/binfmts.h>
+#include <linux/futex.h>
+#include <linux/lguest.h>
+#include <linux/lguest_launcher.h>
+#include <linux/wait.h>
+#include <linux/err.h>
+#include <asm/semaphore.h>
+#include "irq_vectors.h"
+
+#define GUEST_PL 1
+
+struct lguest_regs
+{
+	/* Manually saved part. */
+	unsigned long ebx, ecx, edx;
+	unsigned long esi, edi, ebp;
+	unsigned long gs;
+	unsigned long eax;
+	unsigned long fs, ds, es;
+	unsigned long trapnum, errcode;
+	/* Trap pushed part */
+	unsigned long eip;
+	unsigned long cs;
+	unsigned long eflags;
+	unsigned long esp;
+	unsigned long ss;
+};
+
+void free_pagetables(void);
+int init_pagetables(struct page **switcher_page, unsigned int pages);
+
+/* Full 4G segment descriptors, suitable for CS and DS. */
+#define FULL_EXEC_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9b00})
+#define FULL_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9300})
+
+struct lguest_dma_info
+{
+	struct list_head list;
+	union futex_key key;
+	unsigned long dmas;
+	u16 next_dma;
+	u16 num_dmas;
+	u16 guestid;
+	u8 interrupt; 	/* 0 when not registered */
+};
+
+/*H:310 The page-table code owes a great debt of gratitude to Andi Kleen.  He
+ * reviewed the original code which used "u32" for all page table entries, and
+ * insisted that it would be far clearer with explicit typing.  I thought it
+ * was overkill, but he was right: it is much clearer than it was before.
+ *
+ * We have separate types for the Guest's ptes & pgds and the shadow ptes &
+ * pgds.  There's already a Linux type for these (pte_t and pgd_t) but they
+ * change depending on kernel config options (PAE). */
+
+/* Each entry is identical: lower 12 bits of flags and upper 20 bits for the
+ * "page frame number" (0 == first physical page, etc).  They are different
+ * types so the compiler will warn us if we mix them improperly. */
+typedef union {
+	struct { unsigned flags:12, pfn:20; };
+	struct { unsigned long val; } raw;
+} spgd_t;
+typedef union {
+	struct { unsigned flags:12, pfn:20; };
+	struct { unsigned long val; } raw;
+} spte_t;
+typedef union {
+	struct { unsigned flags:12, pfn:20; };
+	struct { unsigned long val; } raw;
+} gpgd_t;
+typedef union {
+	struct { unsigned flags:12, pfn:20; };
+	struct { unsigned long val; } raw;
+} gpte_t;
+
+/* We have two convenient macros to convert a "raw" value as handed to us by
+ * the Guest into the correct Guest PGD or PTE type. */
+#define mkgpte(_val) ((gpte_t){.raw.val = _val})
+#define mkgpgd(_val) ((gpgd_t){.raw.val = _val})
+/*:*/
+
+struct pgdir
+{
+	unsigned long cr3;
+	spgd_t *pgdir;
+};
+
+/* This is a guest-specific page (mapped ro) into the guest. */
+struct lguest_ro_state
+{
+	/* Host information we need to restore when we switch back. */
+	u32 host_cr3;
+	struct Xgt_desc_struct host_idt_desc;
+	struct Xgt_desc_struct host_gdt_desc;
+	u32 host_sp;
+
+	/* Fields which are used when guest is running. */
+	struct Xgt_desc_struct guest_idt_desc;
+	struct Xgt_desc_struct guest_gdt_desc;
+	struct i386_hw_tss guest_tss;
+	struct desc_struct guest_idt[IDT_ENTRIES];
+	struct desc_struct guest_gdt[GDT_ENTRIES];
+};
+
+/* We have two pages shared with guests, per cpu.  */
+struct lguest_pages
+{
+	/* This is the stack page mapped rw in guest */
+	char spare[PAGE_SIZE - sizeof(struct lguest_regs)];
+	struct lguest_regs regs;
+
+	/* This is the host state & guest descriptor page, ro in guest */
+	struct lguest_ro_state state;
+} __attribute__((aligned(PAGE_SIZE)));
+
+#define CHANGED_IDT		1
+#define CHANGED_GDT		2
+#define CHANGED_GDT_TLS		4 /* Actually a subset of CHANGED_GDT */
+#define CHANGED_ALL	        3
+
+/* The private info the thread maintains about the guest. */
+struct lguest
+{
+	/* At end of a page shared mapped over lguest_pages in guest.  */
+	unsigned long regs_page;
+	struct lguest_regs *regs;
+	struct lguest_data __user *lguest_data;
+	struct task_struct *tsk;
+	struct mm_struct *mm; 	/* == tsk->mm, but that becomes NULL on exit */
+	u16 guestid;
+	u32 pfn_limit;
+	u32 page_offset;
+	u32 cr2;
+	int halted;
+	int ts;
+	u32 next_hcall;
+	u32 esp1;
+	u8 ss1;
+
+	/* Do we need to stop what we're doing and return to userspace? */
+	int break_out;
+	wait_queue_head_t break_wq;
+
+	/* Bitmap of what has changed: see CHANGED_* above. */
+	int changed;
+	struct lguest_pages *last_pages;
+
+	/* We keep a small number of these. */
+	u32 pgdidx;
+	struct pgdir pgdirs[4];
+
+	/* Cached wakeup: we hold a reference to this task. */
+	struct task_struct *wake;
+
+	unsigned long noirq_start, noirq_end;
+	int dma_is_pending;
+	unsigned long pending_dma; /* struct lguest_dma */
+	unsigned long pending_key; /* address they're sending to */
+
+	unsigned int stack_pages;
+	u32 tsc_khz;
+
+	struct lguest_dma_info dma[LGUEST_MAX_DMA];
+
+	/* Dead? */
+	const char *dead;
+
+	/* The GDT entries copied into lguest_ro_state when running. */
+	struct desc_struct gdt[GDT_ENTRIES];
+
+	/* The IDT entries: some copied into lguest_ro_state when running. */
+	struct desc_struct idt[FIRST_EXTERNAL_VECTOR+LGUEST_IRQS];
+	struct desc_struct syscall_idt;
+
+	/* Virtual clock device */
+	struct hrtimer hrt;
+
+	/* Pending virtual interrupts */
+	DECLARE_BITMAP(irqs_pending, LGUEST_IRQS);
+};
+
+extern struct lguest lguests[];
+extern struct mutex lguest_lock;
+
+/* core.c: */
+u32 lgread_u32(struct lguest *lg, unsigned long addr);
+void lgwrite_u32(struct lguest *lg, unsigned long addr, u32 val);
+void lgread(struct lguest *lg, void *buf, unsigned long addr, unsigned len);
+void lgwrite(struct lguest *lg, unsigned long, const void *buf, unsigned len);
+int find_free_guest(void);
+int lguest_address_ok(const struct lguest *lg,
+		      unsigned long addr, unsigned long len);
+int run_guest(struct lguest *lg, unsigned long __user *user);
+
+
+/* interrupts_and_traps.c: */
+void maybe_do_interrupt(struct lguest *lg);
+int deliver_trap(struct lguest *lg, unsigned int num);
+void load_guest_idt_entry(struct lguest *lg, unsigned int i, u32 low, u32 hi);
+void guest_set_stack(struct lguest *lg, u32 seg, u32 esp, unsigned int pages);
+void pin_stack_pages(struct lguest *lg);
+void setup_default_idt_entries(struct lguest_ro_state *state,
+			       const unsigned long *def);
+void copy_traps(const struct lguest *lg, struct desc_struct *idt,
+		const unsigned long *def);
+void guest_set_clockevent(struct lguest *lg, unsigned long delta);
+void init_clockdev(struct lguest *lg);
+
+/* segments.c: */
+void setup_default_gdt_entries(struct lguest_ro_state *state);
+void setup_guest_gdt(struct lguest *lg);
+void load_guest_gdt(struct lguest *lg, unsigned long table, u32 num);
+void guest_load_tls(struct lguest *lg, unsigned long tls_array);
+void copy_gdt(const struct lguest *lg, struct desc_struct *gdt);
+void copy_gdt_tls(const struct lguest *lg, struct desc_struct *gdt);
+
+/* page_tables.c: */
+int init_guest_pagetable(struct lguest *lg, unsigned long pgtable);
+void free_guest_pagetable(struct lguest *lg);
+void guest_new_pagetable(struct lguest *lg, unsigned long pgtable);
+void guest_set_pmd(struct lguest *lg, unsigned long cr3, u32 i);
+void guest_pagetable_clear_all(struct lguest *lg);
+void guest_pagetable_flush_user(struct lguest *lg);
+void guest_set_pte(struct lguest *lg, unsigned long cr3,
+		   unsigned long vaddr, gpte_t val);
+void map_switcher_in_guest(struct lguest *lg, struct lguest_pages *pages);
+int demand_page(struct lguest *info, unsigned long cr2, int errcode);
+void pin_page(struct lguest *lg, unsigned long vaddr);
+
+/* lguest_user.c: */
+int lguest_device_init(void);
+void lguest_device_remove(void);
+
+/* io.c: */
+void lguest_io_init(void);
+int bind_dma(struct lguest *lg,
+	     unsigned long key, unsigned long udma, u16 numdmas, u8 interrupt);
+void send_dma(struct lguest *info, unsigned long key, unsigned long udma);
+void release_all_dma(struct lguest *lg);
+unsigned long get_dma_buffer(struct lguest *lg, unsigned long key,
+			     unsigned long *interrupt);
+
+/* hypercalls.c: */
+void do_hypercalls(struct lguest *lg);
+void write_timestamp(struct lguest *lg);
+
+/*L:035
+ * Let's step aside for the moment, to study one important routine that's used
+ * widely in the Host code.
+ *
+ * There are many cases where the Guest does something invalid, like pass crap
+ * to a hypercall.  Since only the Guest kernel can make hypercalls, it's quite
+ * acceptable to simply terminate the Guest and give the Launcher a nicely
+ * formatted reason.  It's also simpler for the Guest itself, which doesn't
+ * need to check most hypercalls for "success"; if you're still running, it
+ * succeeded.
+ *
+ * Once this is called, the Guest will never run again, so most Host code can
+ * call this then continue as if nothing had happened.  This means many
+ * functions don't have to explicitly return an error code, which keeps the
+ * code simple.
+ *
+ * It also means that this can be called more than once: only the first one is
+ * remembered.  The only trick is that we still need to kill the Guest even if
+ * we can't allocate memory to store the reason.  Linux has a neat way of
+ * packing error codes into invalid pointers, so we use that here.
+ *
+ * Like any macro which uses an "if", it is safely wrapped in a run-once "do {
+ * } while(0)".
+ */
+#define kill_guest(lg, fmt...)					\
+do {								\
+	if (!(lg)->dead) {					\
+		(lg)->dead = kasprintf(GFP_ATOMIC, fmt);	\
+		if (!(lg)->dead)				\
+			(lg)->dead = ERR_PTR(-ENOMEM);		\
+	}							\
+} while(0)
+/* (End of aside) :*/
+
+static inline unsigned long guest_pa(struct lguest *lg, unsigned long vaddr)
+{
+	return vaddr - lg->page_offset;
+}
+#endif	/* __ASSEMBLY__ */
+#endif	/* _LGUEST_H */
drivers/lguest/lg.h deleted +0 -300

300 lines not on this page · raw message

Signature · 3 lines
1.4.4.4

-- 
#3 lore raw

PATCH 2/7 Added generic lg.h in lguest directory.

In reply to Steven Rostedt

Add a generic lg.h file to call the architecture specific one.

---
 drivers/lguest/lg.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/lguest/lg.h new file +3 -0
new file mode 100644
index 0000000..4c4356e
@@ -0,0 +1,3 @@
+#ifdef CONFIG_X86_32
+#include "i386/lg.h"
+#endif
Signature · 3 lines
1.4.4.4

-- 
#13 lore raw

PATCH 3/7 Move the lguest files that are i386 specific

In reply to Steven Rostedt

Well, some may be merged with x86_64 later, but for now we move them out of the way. Later on we can start seeing how we can combine some of these files to be arch generic.

---
 drivers/lguest/Makefile                    |    7 +-
 drivers/lguest/core.c                      |  771 -------------------
 drivers/lguest/hypercalls.c                |  300 --------
 drivers/lguest/i386/Makefile               |    8 +
 drivers/lguest/i386/core.c                 |  771 +++++++++++++++++++
 drivers/lguest/i386/hypercalls.c           |  300 ++++++++
 drivers/lguest/i386/interrupts_and_traps.c |  440 +++++++++++
 drivers/lguest/i386/lguest.c               | 1097 ++++++++++++++++++++++++++++
 drivers/lguest/i386/lguest_asm.S           |   93 +++
 drivers/lguest/i386/lguest_user.c          |  382 ++++++++++
 drivers/lguest/i386/page_tables.c          |  680 +++++++++++++++++
 drivers/lguest/i386/segments.c             |  229 ++++++
 drivers/lguest/i386/switcher.S             |  347 +++++++++
 drivers/lguest/interrupts_and_traps.c      |  440 -----------
 drivers/lguest/lguest.c                    | 1097 ----------------------------
 drivers/lguest/lguest_asm.S                |   93 ---
 drivers/lguest/lguest_user.c               |  382 ----------
 drivers/lguest/page_tables.c               |  680 -----------------
 drivers/lguest/segments.c                  |  229 ------
 drivers/lguest/switcher.S                  |  347 ---------
 20 files changed, 4349 insertions(+), 4344 deletions(-)
drivers/lguest/Makefile +2 -5
index e504747..2de13eb 100644
@@ -1,10 +1,7 @@
 # Guest requires the paravirt_ops replacement and the bus driver.
-obj-$(CONFIG_LGUEST_GUEST) += lguest.o lguest_asm.o lguest_bus.o
+obj-$(CONFIG_LGUEST_GUEST) += lguest_bus.o
 
-# Host requires the other files, which can be a module.
-obj-$(CONFIG_LGUEST)	+= lg.o
-lg-y := core.o hypercalls.o page_tables.o interrupts_and_traps.o \
-	segments.o io.o lguest_user.o switcher.o
+obj-$(CONFIG_X86_32)	+= i386/
 
 Preparation Preparation!: PREFIX=P
 Guest: PREFIX=G
drivers/lguest/core.c deleted +0 -771

771 lines not on this page · raw message

drivers/lguest/hypercalls.c deleted +0 -300

300 lines not on this page · raw message

drivers/lguest/i386/Makefile new file +8 -0
new file mode 100644
index 0000000..1e8ae77
@@ -0,0 +1,8 @@
+# Guest requires the paravirt_ops replacement and the bus driver.
+obj-$(CONFIG_LGUEST_GUEST) += lguest.o lguest_asm.o
+
+# Host requires the other files, which can be a module.
+obj-$(CONFIG_LGUEST)	+= lg.o
+lg-y := core.o hypercalls.o page_tables.o interrupts_and_traps.o \
+	segments.o ../io.o lguest_user.o switcher.o
+
drivers/lguest/i386/core.c new file +771 -0

771 lines not on this page · raw message

drivers/lguest/i386/hypercalls.c new file +300 -0

300 lines not on this page · raw message

drivers/lguest/i386/interrupts_and_traps.c new file +440 -0

440 lines not on this page · raw message

drivers/lguest/i386/lguest.c new file +1097 -0

398 lines not on this page · raw message

drivers/lguest/i386/lguest_asm.S new file +93 -0

93 lines not on this page · raw message

drivers/lguest/i386/lguest_user.c new file +382 -0

382 lines not on this page · raw message

drivers/lguest/i386/page_tables.c new file +680 -0

680 lines not on this page · raw message

drivers/lguest/i386/segments.c new file +229 -0

229 lines not on this page · raw message

drivers/lguest/i386/switcher.S new file +347 -0

347 lines not on this page · raw message

drivers/lguest/interrupts_and_traps.c deleted +0 -440

440 lines not on this page · raw message

drivers/lguest/lguest.c deleted +0 -1097

1,097 lines not on this page · raw message

drivers/lguest/lguest_asm.S deleted +0 -93

93 lines not on this page · raw message

drivers/lguest/lguest_user.c deleted +0 -382

382 lines not on this page · raw message

drivers/lguest/page_tables.c deleted +0 -680

680 lines not on this page · raw message

drivers/lguest/segments.c deleted +0 -229

229 lines not on this page · raw message

drivers/lguest/switcher.S deleted +0 -347

347 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 3 lines
1.4.4.4

-- 

Part of the diff is not shown here. View the raw message.

#15 lore raw

PATCH 4/7 Moved the io struct up to the generic lg.h

In reply to Steven Rostedt

Move the io struct into the lg.h file since the io.c is generic to other architectures.

Also added a proper ifdef for the generic lg.h.

---
 drivers/lguest/i386/lg.h |   11 ++---------
 drivers/lguest/lg.h      |   16 ++++++++++++++++
 2 files changed, 18 insertions(+), 9 deletions(-)
drivers/lguest/i386/lg.h +2 -9
index 64f0abe..c5ea14c 100644
@@ -20,6 +20,8 @@
 #include <linux/err.h>
 #include <asm/semaphore.h>
 #include "irq_vectors.h"
+/* some files include this, some include the parent */
+#include "../lg.h"
 
 #define GUEST_PL 1
 
@@ -245,15 +247,6 @@ void pin_page(struct lguest *lg, unsigned long vaddr);
 int lguest_device_init(void);
 void lguest_device_remove(void);
 
-/* io.c: */
-void lguest_io_init(void);
-int bind_dma(struct lguest *lg,
-	     unsigned long key, unsigned long udma, u16 numdmas, u8 interrupt);
-void send_dma(struct lguest *info, unsigned long key, unsigned long udma);
-void release_all_dma(struct lguest *lg);
-unsigned long get_dma_buffer(struct lguest *lg, unsigned long key,
-			     unsigned long *interrupt);
-
 /* hypercalls.c: */
 void do_hypercalls(struct lguest *lg);
 void write_timestamp(struct lguest *lg);
drivers/lguest/lg.h +16 -0
index 4c4356e..3147bf6 100644
@@ -1,3 +1,19 @@
+#ifndef _LGUEST_LG_GENERIC
+#define _LGUEST_LG_GENERIC
+
+struct lguest;
+
+/* io.c: */
+void lguest_io_init(void);
+int bind_dma(struct lguest *lg,
+	     unsigned long key, unsigned long udma, u16 numdmas, u8 interrupt);
+void send_dma(struct lguest *info, unsigned long key, unsigned long udma);
+void release_all_dma(struct lguest *lg);
+unsigned long get_dma_buffer(struct lguest *lg, unsigned long key,
+			     unsigned long *interrupt);
+
 #ifdef CONFIG_X86_32
 #include "i386/lg.h"
 #endif
+
+#endif /* _LGUEST_LG_GENERIC */
Signature · 3 lines
1.4.4.4

-- 
#24 lore raw

PATCH 5/7 Change lguest launcher to use asm generic include

In reply to Steven Rostedt

Have the lguest launcher include e820.h via asm/e820.h instead of explicitly saying i386.

---
 Documentation/lguest/lguest.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/lguest/lguest.c +1 -1
index f791840..eb7a01c 100644
@@ -46,7 +46,7 @@ typedef uint32_t u32;
 typedef uint16_t u16;
 typedef uint8_t u8;
 #include "../../include/linux/lguest_launcher.h"
-#include "../../include/asm-i386/e820.h"
+#include "../../include/asm/e820.h"
 /*:*/
 
 #define PAGE_PRESENT 0x7 	/* Present, RW, Execute */
Signature · 3 lines
1.4.4.4

-- 
#30 lore raw

PATCH 6/7 Remove __pa() use in hvc_lguest

In reply to Steven Rostedt

The hvc_lguest uses __pa in the const initialization.
In some architectures, __pa() is not constant so this fails in compiles.

---
 drivers/char/hvc_lguest.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/char/hvc_lguest.c +7 -1
index feeccba..c7d7d4c 100644
@@ -42,7 +42,6 @@
  * use of physical address for the buffer itself. */
 static char inbuf[256];
 static struct lguest_dma cons_input = { .used_len = 0,
-					.addr[0] = __pa(inbuf),
 					.len[0] = sizeof(inbuf),
 					.len[1] = 0 };
 
@@ -114,6 +113,13 @@ static struct hv_ops lguest_cons = {
  * (0), and the struct hv_ops containing the put_chars() function. */
 static int __init cons_init(void)
 {
+	/*
+	 * We can't initialize using __pa in const declarations,
+	 * since __pa(inbuf) does not evaluate into a constant on
+	 * all architectures (namely x86_64).
+	 */
+	cons_input.addr[0] = __pa(inbuf);
+
 	if (strcmp(paravirt_ops.name, "lguest") != 0)
 		return 0;
 
Signature · 3 lines
1.4.4.4

-- 
#32 lore raw

PATCH 7/7 Move lguest_dma_info into generic lg.h

In reply to Steven Rostedt

The lguest_dma_info is also generic across architectures. Move it to the generic lg.h

---
 drivers/lguest/i386/lg.h |   11 -----------
 drivers/lguest/lg.h      |   11 +++++++++++
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/lguest/i386/lg.h +0 -11
index c5ea14c..ae83bd2 100644
@@ -49,17 +49,6 @@ int init_pagetables(struct page **switcher_page, unsigned int pages);
 #define FULL_EXEC_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9b00})
 #define FULL_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9300})
 
-struct lguest_dma_info
-{
-	struct list_head list;
-	union futex_key key;
-	unsigned long dmas;
-	u16 next_dma;
-	u16 num_dmas;
-	u16 guestid;
-	u8 interrupt; 	/* 0 when not registered */
-};
-
 /*H:310 The page-table code owes a great debt of gratitude to Andi Kleen.  He
  * reviewed the original code which used "u32" for all page table entries, and
  * insisted that it would be far clearer with explicit typing.  I thought it
drivers/lguest/lg.h +11 -0
index 3147bf6..6057e3c 100644
@@ -12,6 +12,17 @@ void release_all_dma(struct lguest *lg);
 unsigned long get_dma_buffer(struct lguest *lg, unsigned long key,
 			     unsigned long *interrupt);
 
+struct lguest_dma_info
+{
+	struct list_head list;
+	union futex_key key;
+	unsigned long dmas;
+	u16 next_dma;
+	u16 num_dmas;
+	u16 guestid;
+	u8 interrupt; 	/* 0 when not registered */
+};
+
 #ifdef CONFIG_X86_32
 #include "i386/lg.h"
 #endif
Signature · 3 lines
1.4.4.4

-- 
#0 lore raw

cover Modify lguest32 to make room for lguest64

Hi all,

I've been working on lguest64 and in order to do this, I had to move a lot of the i386 specific out of the way. Well, the lguest64 port is still not ready to display, but before Rusty makes too many changes I would like this in upstream so I don't have to keep repeating my changes :-)

So this patch series moves lguest32 out of the way for other archs.

-- Steve

#4 lore raw

PATCH 2/7 Added generic lg.h in lguest directory.

Add a generic lg.h file to call the architecture specific one.

---
 drivers/lguest/lg.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/lguest/lg.h new file +3 -0
new file mode 100644
index 0000000..4c4356e
@@ -0,0 +1,3 @@
+#ifdef CONFIG_X86_32
+#include "i386/lg.h"
+#endif
Signature · 3 lines
1.4.4.4

-- 
#25 lore raw

PATCH 5/7 Change lguest launcher to use asm generic include

In reply to Steven Rostedt

Have the lguest launcher include e820.h via asm/e820.h instead of explicitly saying i386.

---
 Documentation/lguest/lguest.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/lguest/lguest.c +1 -1
index f791840..eb7a01c 100644
@@ -46,7 +46,7 @@ typedef uint32_t u32;
 typedef uint16_t u16;
 typedef uint8_t u8;
 #include "../../include/linux/lguest_launcher.h"
-#include "../../include/asm-i386/e820.h"
+#include "../../include/asm/e820.h"
 /*:*/
 
 #define PAGE_PRESENT 0x7 	/* Present, RW, Execute */
Signature · 3 lines
1.4.4.4

-- 
#14 lore raw

PATCH 3/7 Move the lguest files that are i386 specific

In reply to Steven Rostedt

Well, some may be merged with x86_64 later, but for now we move them out of the way. Later on we can start seeing how we can combine some of these files to be arch generic.

---
 drivers/lguest/Makefile                    |    7 +-
 drivers/lguest/core.c                      |  771 -------------------
 drivers/lguest/hypercalls.c                |  300 --------
 drivers/lguest/i386/Makefile               |    8 +
 drivers/lguest/i386/core.c                 |  771 +++++++++++++++++++
 drivers/lguest/i386/hypercalls.c           |  300 ++++++++
 drivers/lguest/i386/interrupts_and_traps.c |  440 +++++++++++
 drivers/lguest/i386/lguest.c               | 1097 ++++++++++++++++++++++++++++
 drivers/lguest/i386/lguest_asm.S           |   93 +++
 drivers/lguest/i386/lguest_user.c          |  382 ++++++++++
 drivers/lguest/i386/page_tables.c          |  680 +++++++++++++++++
 drivers/lguest/i386/segments.c             |  229 ++++++
 drivers/lguest/i386/switcher.S             |  347 +++++++++
 drivers/lguest/interrupts_and_traps.c      |  440 -----------
 drivers/lguest/lguest.c                    | 1097 ----------------------------
 drivers/lguest/lguest_asm.S                |   93 ---
 drivers/lguest/lguest_user.c               |  382 ----------
 drivers/lguest/page_tables.c               |  680 -----------------
 drivers/lguest/segments.c                  |  229 ------
 drivers/lguest/switcher.S                  |  347 ---------
 20 files changed, 4349 insertions(+), 4344 deletions(-)
drivers/lguest/Makefile +2 -5
index e504747..2de13eb 100644
@@ -1,10 +1,7 @@
 # Guest requires the paravirt_ops replacement and the bus driver.
-obj-$(CONFIG_LGUEST_GUEST) += lguest.o lguest_asm.o lguest_bus.o
+obj-$(CONFIG_LGUEST_GUEST) += lguest_bus.o
 
-# Host requires the other files, which can be a module.
-obj-$(CONFIG_LGUEST)	+= lg.o
-lg-y := core.o hypercalls.o page_tables.o interrupts_and_traps.o \
-	segments.o io.o lguest_user.o switcher.o
+obj-$(CONFIG_X86_32)	+= i386/
 
 Preparation Preparation!: PREFIX=P
 Guest: PREFIX=G
drivers/lguest/core.c deleted +0 -771

771 lines not on this page · raw message

drivers/lguest/hypercalls.c deleted +0 -300

300 lines not on this page · raw message

drivers/lguest/i386/Makefile new file +8 -0
new file mode 100644
index 0000000..1e8ae77
@@ -0,0 +1,8 @@
+# Guest requires the paravirt_ops replacement and the bus driver.
+obj-$(CONFIG_LGUEST_GUEST) += lguest.o lguest_asm.o
+
+# Host requires the other files, which can be a module.
+obj-$(CONFIG_LGUEST)	+= lg.o
+lg-y := core.o hypercalls.o page_tables.o interrupts_and_traps.o \
+	segments.o ../io.o lguest_user.o switcher.o
+
drivers/lguest/i386/core.c new file +771 -0

771 lines not on this page · raw message

drivers/lguest/i386/hypercalls.c new file +300 -0

300 lines not on this page · raw message

drivers/lguest/i386/interrupts_and_traps.c new file +440 -0

440 lines not on this page · raw message

drivers/lguest/i386/lguest.c new file +1097 -0

398 lines not on this page · raw message

drivers/lguest/i386/lguest_asm.S new file +93 -0

93 lines not on this page · raw message

drivers/lguest/i386/lguest_user.c new file +382 -0

382 lines not on this page · raw message

drivers/lguest/i386/page_tables.c new file +680 -0

680 lines not on this page · raw message

drivers/lguest/i386/segments.c new file +229 -0

229 lines not on this page · raw message

drivers/lguest/i386/switcher.S new file +347 -0

347 lines not on this page · raw message

drivers/lguest/interrupts_and_traps.c deleted +0 -440

440 lines not on this page · raw message

drivers/lguest/lguest.c deleted +0 -1097

1,097 lines not on this page · raw message

drivers/lguest/lguest_asm.S deleted +0 -93

93 lines not on this page · raw message

drivers/lguest/lguest_user.c deleted +0 -382

382 lines not on this page · raw message

drivers/lguest/page_tables.c deleted +0 -680

680 lines not on this page · raw message

drivers/lguest/segments.c deleted +0 -229

229 lines not on this page · raw message

drivers/lguest/switcher.S deleted +0 -347

347 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 3 lines
1.4.4.4

-- 

Part of the diff is not shown here. View the raw message.

#33 lore raw

PATCH 7/7 Move lguest_dma_info into generic lg.h

In reply to Steven Rostedt

The lguest_dma_info is also generic across architectures. Move it to the generic lg.h

---
 drivers/lguest/i386/lg.h |   11 -----------
 drivers/lguest/lg.h      |   11 +++++++++++
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/lguest/i386/lg.h +0 -11
index c5ea14c..ae83bd2 100644
@@ -49,17 +49,6 @@ int init_pagetables(struct page **switcher_page, unsigned int pages);
 #define FULL_EXEC_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9b00})
 #define FULL_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9300})
 
-struct lguest_dma_info
-{
-	struct list_head list;
-	union futex_key key;
-	unsigned long dmas;
-	u16 next_dma;
-	u16 num_dmas;
-	u16 guestid;
-	u8 interrupt; 	/* 0 when not registered */
-};
-
 /*H:310 The page-table code owes a great debt of gratitude to Andi Kleen.  He
  * reviewed the original code which used "u32" for all page table entries, and
  * insisted that it would be far clearer with explicit typing.  I thought it
drivers/lguest/lg.h +11 -0
index 3147bf6..6057e3c 100644
@@ -12,6 +12,17 @@ void release_all_dma(struct lguest *lg);
 unsigned long get_dma_buffer(struct lguest *lg, unsigned long key,
 			     unsigned long *interrupt);
 
+struct lguest_dma_info
+{
+	struct list_head list;
+	union futex_key key;
+	unsigned long dmas;
+	u16 next_dma;
+	u16 num_dmas;
+	u16 guestid;
+	u8 interrupt; 	/* 0 when not registered */
+};
+
 #ifdef CONFIG_X86_32
 #include "i386/lg.h"
 #endif
Signature · 3 lines
1.4.4.4

-- 
#2 lore raw

PATCH 1/7 Move lg.h to the i386 specific lguest directory

In reply to Steven Rostedt

Make a i386 directory in the lguest directory, and move the lg.h into it. This will clear the way for other archs to have their own lg.h

---
 drivers/lguest/i386/lg.h |  300 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/lguest/lg.h      |  300 ----------------------------------------------
 2 files changed, 300 insertions(+), 300 deletions(-)
drivers/lguest/i386/lg.h new file +300 -0
new file mode 100644
index 0000000..64f0abe
@@ -0,0 +1,300 @@
+#ifndef _LGUEST_H
+#define _LGUEST_H
+
+#include <asm/desc.h>
+
+#define GDT_ENTRY_LGUEST_CS	10
+#define GDT_ENTRY_LGUEST_DS	11
+#define LGUEST_CS		(GDT_ENTRY_LGUEST_CS * 8)
+#define LGUEST_DS		(GDT_ENTRY_LGUEST_DS * 8)
+
+#ifndef __ASSEMBLY__
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/stringify.h>
+#include <linux/binfmts.h>
+#include <linux/futex.h>
+#include <linux/lguest.h>
+#include <linux/lguest_launcher.h>
+#include <linux/wait.h>
+#include <linux/err.h>
+#include <asm/semaphore.h>
+#include "irq_vectors.h"
+
+#define GUEST_PL 1
+
+struct lguest_regs
+{
+	/* Manually saved part. */
+	unsigned long ebx, ecx, edx;
+	unsigned long esi, edi, ebp;
+	unsigned long gs;
+	unsigned long eax;
+	unsigned long fs, ds, es;
+	unsigned long trapnum, errcode;
+	/* Trap pushed part */
+	unsigned long eip;
+	unsigned long cs;
+	unsigned long eflags;
+	unsigned long esp;
+	unsigned long ss;
+};
+
+void free_pagetables(void);
+int init_pagetables(struct page **switcher_page, unsigned int pages);
+
+/* Full 4G segment descriptors, suitable for CS and DS. */
+#define FULL_EXEC_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9b00})
+#define FULL_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9300})
+
+struct lguest_dma_info
+{
+	struct list_head list;
+	union futex_key key;
+	unsigned long dmas;
+	u16 next_dma;
+	u16 num_dmas;
+	u16 guestid;
+	u8 interrupt; 	/* 0 when not registered */
+};
+
+/*H:310 The page-table code owes a great debt of gratitude to Andi Kleen.  He
+ * reviewed the original code which used "u32" for all page table entries, and
+ * insisted that it would be far clearer with explicit typing.  I thought it
+ * was overkill, but he was right: it is much clearer than it was before.
+ *
+ * We have separate types for the Guest's ptes & pgds and the shadow ptes &
+ * pgds.  There's already a Linux type for these (pte_t and pgd_t) but they
+ * change depending on kernel config options (PAE). */
+
+/* Each entry is identical: lower 12 bits of flags and upper 20 bits for the
+ * "page frame number" (0 == first physical page, etc).  They are different
+ * types so the compiler will warn us if we mix them improperly. */
+typedef union {
+	struct { unsigned flags:12, pfn:20; };
+	struct { unsigned long val; } raw;
+} spgd_t;
+typedef union {
+	struct { unsigned flags:12, pfn:20; };
+	struct { unsigned long val; } raw;
+} spte_t;
+typedef union {
+	struct { unsigned flags:12, pfn:20; };
+	struct { unsigned long val; } raw;
+} gpgd_t;
+typedef union {
+	struct { unsigned flags:12, pfn:20; };
+	struct { unsigned long val; } raw;
+} gpte_t;
+
+/* We have two convenient macros to convert a "raw" value as handed to us by
+ * the Guest into the correct Guest PGD or PTE type. */
+#define mkgpte(_val) ((gpte_t){.raw.val = _val})
+#define mkgpgd(_val) ((gpgd_t){.raw.val = _val})
+/*:*/
+
+struct pgdir
+{
+	unsigned long cr3;
+	spgd_t *pgdir;
+};
+
+/* This is a guest-specific page (mapped ro) into the guest. */
+struct lguest_ro_state
+{
+	/* Host information we need to restore when we switch back. */
+	u32 host_cr3;
+	struct Xgt_desc_struct host_idt_desc;
+	struct Xgt_desc_struct host_gdt_desc;
+	u32 host_sp;
+
+	/* Fields which are used when guest is running. */
+	struct Xgt_desc_struct guest_idt_desc;
+	struct Xgt_desc_struct guest_gdt_desc;
+	struct i386_hw_tss guest_tss;
+	struct desc_struct guest_idt[IDT_ENTRIES];
+	struct desc_struct guest_gdt[GDT_ENTRIES];
+};
+
+/* We have two pages shared with guests, per cpu.  */
+struct lguest_pages
+{
+	/* This is the stack page mapped rw in guest */
+	char spare[PAGE_SIZE - sizeof(struct lguest_regs)];
+	struct lguest_regs regs;
+
+	/* This is the host state & guest descriptor page, ro in guest */
+	struct lguest_ro_state state;
+} __attribute__((aligned(PAGE_SIZE)));
+
+#define CHANGED_IDT		1
+#define CHANGED_GDT		2
+#define CHANGED_GDT_TLS		4 /* Actually a subset of CHANGED_GDT */
+#define CHANGED_ALL	        3
+
+/* The private info the thread maintains about the guest. */
+struct lguest
+{
+	/* At end of a page shared mapped over lguest_pages in guest.  */
+	unsigned long regs_page;
+	struct lguest_regs *regs;
+	struct lguest_data __user *lguest_data;
+	struct task_struct *tsk;
+	struct mm_struct *mm; 	/* == tsk->mm, but that becomes NULL on exit */
+	u16 guestid;
+	u32 pfn_limit;
+	u32 page_offset;
+	u32 cr2;
+	int halted;
+	int ts;
+	u32 next_hcall;
+	u32 esp1;
+	u8 ss1;
+
+	/* Do we need to stop what we're doing and return to userspace? */
+	int break_out;
+	wait_queue_head_t break_wq;
+
+	/* Bitmap of what has changed: see CHANGED_* above. */
+	int changed;
+	struct lguest_pages *last_pages;
+
+	/* We keep a small number of these. */
+	u32 pgdidx;
+	struct pgdir pgdirs[4];
+
+	/* Cached wakeup: we hold a reference to this task. */
+	struct task_struct *wake;
+
+	unsigned long noirq_start, noirq_end;
+	int dma_is_pending;
+	unsigned long pending_dma; /* struct lguest_dma */
+	unsigned long pending_key; /* address they're sending to */
+
+	unsigned int stack_pages;
+	u32 tsc_khz;
+
+	struct lguest_dma_info dma[LGUEST_MAX_DMA];
+
+	/* Dead? */
+	const char *dead;
+
+	/* The GDT entries copied into lguest_ro_state when running. */
+	struct desc_struct gdt[GDT_ENTRIES];
+
+	/* The IDT entries: some copied into lguest_ro_state when running. */
+	struct desc_struct idt[FIRST_EXTERNAL_VECTOR+LGUEST_IRQS];
+	struct desc_struct syscall_idt;
+
+	/* Virtual clock device */
+	struct hrtimer hrt;
+
+	/* Pending virtual interrupts */
+	DECLARE_BITMAP(irqs_pending, LGUEST_IRQS);
+};
+
+extern struct lguest lguests[];
+extern struct mutex lguest_lock;
+
+/* core.c: */
+u32 lgread_u32(struct lguest *lg, unsigned long addr);
+void lgwrite_u32(struct lguest *lg, unsigned long addr, u32 val);
+void lgread(struct lguest *lg, void *buf, unsigned long addr, unsigned len);
+void lgwrite(struct lguest *lg, unsigned long, const void *buf, unsigned len);
+int find_free_guest(void);
+int lguest_address_ok(const struct lguest *lg,
+		      unsigned long addr, unsigned long len);
+int run_guest(struct lguest *lg, unsigned long __user *user);
+
+
+/* interrupts_and_traps.c: */
+void maybe_do_interrupt(struct lguest *lg);
+int deliver_trap(struct lguest *lg, unsigned int num);
+void load_guest_idt_entry(struct lguest *lg, unsigned int i, u32 low, u32 hi);
+void guest_set_stack(struct lguest *lg, u32 seg, u32 esp, unsigned int pages);
+void pin_stack_pages(struct lguest *lg);
+void setup_default_idt_entries(struct lguest_ro_state *state,
+			       const unsigned long *def);
+void copy_traps(const struct lguest *lg, struct desc_struct *idt,
+		const unsigned long *def);
+void guest_set_clockevent(struct lguest *lg, unsigned long delta);
+void init_clockdev(struct lguest *lg);
+
+/* segments.c: */
+void setup_default_gdt_entries(struct lguest_ro_state *state);
+void setup_guest_gdt(struct lguest *lg);
+void load_guest_gdt(struct lguest *lg, unsigned long table, u32 num);
+void guest_load_tls(struct lguest *lg, unsigned long tls_array);
+void copy_gdt(const struct lguest *lg, struct desc_struct *gdt);
+void copy_gdt_tls(const struct lguest *lg, struct desc_struct *gdt);
+
+/* page_tables.c: */
+int init_guest_pagetable(struct lguest *lg, unsigned long pgtable);
+void free_guest_pagetable(struct lguest *lg);
+void guest_new_pagetable(struct lguest *lg, unsigned long pgtable);
+void guest_set_pmd(struct lguest *lg, unsigned long cr3, u32 i);
+void guest_pagetable_clear_all(struct lguest *lg);
+void guest_pagetable_flush_user(struct lguest *lg);
+void guest_set_pte(struct lguest *lg, unsigned long cr3,
+		   unsigned long vaddr, gpte_t val);
+void map_switcher_in_guest(struct lguest *lg, struct lguest_pages *pages);
+int demand_page(struct lguest *info, unsigned long cr2, int errcode);
+void pin_page(struct lguest *lg, unsigned long vaddr);
+
+/* lguest_user.c: */
+int lguest_device_init(void);
+void lguest_device_remove(void);
+
+/* io.c: */
+void lguest_io_init(void);
+int bind_dma(struct lguest *lg,
+	     unsigned long key, unsigned long udma, u16 numdmas, u8 interrupt);
+void send_dma(struct lguest *info, unsigned long key, unsigned long udma);
+void release_all_dma(struct lguest *lg);
+unsigned long get_dma_buffer(struct lguest *lg, unsigned long key,
+			     unsigned long *interrupt);
+
+/* hypercalls.c: */
+void do_hypercalls(struct lguest *lg);
+void write_timestamp(struct lguest *lg);
+
+/*L:035
+ * Let's step aside for the moment, to study one important routine that's used
+ * widely in the Host code.
+ *
+ * There are many cases where the Guest does something invalid, like pass crap
+ * to a hypercall.  Since only the Guest kernel can make hypercalls, it's quite
+ * acceptable to simply terminate the Guest and give the Launcher a nicely
+ * formatted reason.  It's also simpler for the Guest itself, which doesn't
+ * need to check most hypercalls for "success"; if you're still running, it
+ * succeeded.
+ *
+ * Once this is called, the Guest will never run again, so most Host code can
+ * call this then continue as if nothing had happened.  This means many
+ * functions don't have to explicitly return an error code, which keeps the
+ * code simple.
+ *
+ * It also means that this can be called more than once: only the first one is
+ * remembered.  The only trick is that we still need to kill the Guest even if
+ * we can't allocate memory to store the reason.  Linux has a neat way of
+ * packing error codes into invalid pointers, so we use that here.
+ *
+ * Like any macro which uses an "if", it is safely wrapped in a run-once "do {
+ * } while(0)".
+ */
+#define kill_guest(lg, fmt...)					\
+do {								\
+	if (!(lg)->dead) {					\
+		(lg)->dead = kasprintf(GFP_ATOMIC, fmt);	\
+		if (!(lg)->dead)				\
+			(lg)->dead = ERR_PTR(-ENOMEM);		\
+	}							\
+} while(0)
+/* (End of aside) :*/
+
+static inline unsigned long guest_pa(struct lguest *lg, unsigned long vaddr)
+{
+	return vaddr - lg->page_offset;
+}
+#endif	/* __ASSEMBLY__ */
+#endif	/* _LGUEST_H */
drivers/lguest/lg.h deleted +0 -300

300 lines not on this page · raw message

Signature · 3 lines
1.4.4.4

-- 
#31 lore raw

PATCH 6/7 Remove __pa() use in hvc_lguest

In reply to Steven Rostedt

The hvc_lguest uses __pa in the const initialization.
In some architectures, __pa() is not constant so this fails in compiles.

---
 drivers/char/hvc_lguest.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/char/hvc_lguest.c +7 -1
index feeccba..c7d7d4c 100644
@@ -42,7 +42,6 @@
  * use of physical address for the buffer itself. */
 static char inbuf[256];
 static struct lguest_dma cons_input = { .used_len = 0,
-					.addr[0] = __pa(inbuf),
 					.len[0] = sizeof(inbuf),
 					.len[1] = 0 };
 
@@ -114,6 +113,13 @@ static struct hv_ops lguest_cons = {
  * (0), and the struct hv_ops containing the put_chars() function. */
 static int __init cons_init(void)
 {
+	/*
+	 * We can't initialize using __pa in const declarations,
+	 * since __pa(inbuf) does not evaluate into a constant on
+	 * all architectures (namely x86_64).
+	 */
+	cons_input.addr[0] = __pa(inbuf);
+
 	if (strcmp(paravirt_ops.name, "lguest") != 0)
 		return 0;
 
Signature · 3 lines
1.4.4.4

-- 
#16 lore raw

PATCH 4/7 Moved the io struct up to the generic lg.h

In reply to Steven Rostedt

Move the io struct into the lg.h file since the io.c is generic to other architectures.

Also added a proper ifdef for the generic lg.h.

---
 drivers/lguest/i386/lg.h |   11 ++---------
 drivers/lguest/lg.h      |   16 ++++++++++++++++
 2 files changed, 18 insertions(+), 9 deletions(-)
drivers/lguest/i386/lg.h +2 -9
index 64f0abe..c5ea14c 100644
@@ -20,6 +20,8 @@
 #include <linux/err.h>
 #include <asm/semaphore.h>
 #include "irq_vectors.h"
+/* some files include this, some include the parent */
+#include "../lg.h"
 
 #define GUEST_PL 1
 
@@ -245,15 +247,6 @@ void pin_page(struct lguest *lg, unsigned long vaddr);
 int lguest_device_init(void);
 void lguest_device_remove(void);
 
-/* io.c: */
-void lguest_io_init(void);
-int bind_dma(struct lguest *lg,
-	     unsigned long key, unsigned long udma, u16 numdmas, u8 interrupt);
-void send_dma(struct lguest *info, unsigned long key, unsigned long udma);
-void release_all_dma(struct lguest *lg);
-unsigned long get_dma_buffer(struct lguest *lg, unsigned long key,
-			     unsigned long *interrupt);
-
 /* hypercalls.c: */
 void do_hypercalls(struct lguest *lg);
 void write_timestamp(struct lguest *lg);
drivers/lguest/lg.h +16 -0
index 4c4356e..3147bf6 100644
@@ -1,3 +1,19 @@
+#ifndef _LGUEST_LG_GENERIC
+#define _LGUEST_LG_GENERIC
+
+struct lguest;
+
+/* io.c: */
+void lguest_io_init(void);
+int bind_dma(struct lguest *lg,
+	     unsigned long key, unsigned long udma, u16 numdmas, u8 interrupt);
+void send_dma(struct lguest *info, unsigned long key, unsigned long udma);
+void release_all_dma(struct lguest *lg);
+unsigned long get_dma_buffer(struct lguest *lg, unsigned long key,
+			     unsigned long *interrupt);
+
 #ifdef CONFIG_X86_32
 #include "i386/lg.h"
 #endif
+
+#endif /* _LGUEST_LG_GENERIC */
Signature · 3 lines
1.4.4.4

-- 
#5 lore raw

Re: [PATCH 2/7] Added generic lg.h in lguest directory.

In reply to Steven Rostedt

drivers/lguest/lg.h line 3

Quoted 11 lines · Steven Rostedt

Add a generic lg.h file to call the architecture specific one.

drivers/lguest/lg.h new file +3 -0
new file mode 100644
index 0000000..4c4356e
@@ -0,0 +1,3 @@
+#ifdef CONFIG_X86_32
+#include "i386/lg.h"
+#endif

Wouldn't it be cleaner to do something like the asm/ includes? I understand that lguest now lives in drivers/ and so we don't put headers directly in asm-i386 , but we could come up with a similar thing here.

Signature · 5 lines
Glauber de Oliveira Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."
#6 lore raw

Re: [PATCH 2/7] Added generic lg.h in lguest directory.

In reply to Steven Rostedt

drivers/lguest/lg.h line 3

Quoted 11 lines · Steven Rostedt

Add a generic lg.h file to call the architecture specific one.

drivers/lguest/lg.h new file +3 -0
new file mode 100644
index 0000000..4c4356e
@@ -0,0 +1,3 @@
+#ifdef CONFIG_X86_32
+#include "i386/lg.h"
+#endif

Wouldn't it be cleaner to do something like the asm/ includes? I understand that lguest now lives in drivers/ and so we don't put headers directly in asm-i386 , but we could come up with a similar thing here.

Signature · 5 lines
Glauber de Oliveira Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."
#26 lore raw

Re: [PATCH 5/7] Change lguest launcher to use asm generic include

In reply to Steven Rostedt

Documentation/lguest/lguest.c typedef uint32_t u32; · line 49

Quoted 8 lines
Documentation/lguest/lguest.c +1 -1
@@ -46,7 +46,7 @@ typedef uint32_t u32;
 typedef uint16_t u16;
 typedef uint8_t u8;
 #include "../../include/linux/lguest_launcher.h"
-#include "../../include/asm-i386/e820.h"
+#include "../../include/asm/e820.h"

Couldn't we add the ../../../../../../../etc to the Makefile and avoid it here?

Signature · 5 lines
Glauber de Oliveira Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."
#27 lore raw

Re: [PATCH 5/7] Change lguest launcher to use asm generic include

In reply to Steven Rostedt

Documentation/lguest/lguest.c typedef uint32_t u32; · line 49

Quoted 8 lines
Documentation/lguest/lguest.c +1 -1
@@ -46,7 +46,7 @@ typedef uint32_t u32;
 typedef uint16_t u16;
 typedef uint8_t u8;
 #include "../../include/linux/lguest_launcher.h"
-#include "../../include/asm-i386/e820.h"
+#include "../../include/asm/e820.h"

Couldn't we add the ../../../../../../../etc to the Makefile and avoid it here?

Signature · 5 lines
Glauber de Oliveira Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."
#9 lore raw

Re: [PATCH 2/7] Added generic lg.h in lguest directory.

In reply to Steven Rostedt
Quoted 2 lines · On Wed, 08 Aug 2007 20:32:13 -0400 Steven Rostedt <[email protected]> wrote:

Add a generic lg.h file to call the architecture specific one.

Please combine this with the previous patch so that the tree will build at each step.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/virtualization

#10 lore raw

Re: [PATCH 2/7] Added generic lg.h in lguest directory.

In reply to Steven Rostedt
Quoted 2 lines · On Wed, 08 Aug 2007 20:32:13 -0400 Steven Rostedt <[email protected]> wrote:

Add a generic lg.h file to call the architecture specific one.

Please combine this with the previous patch so that the tree will build at each step.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#17 lore raw

Re: [PATCH 4/7] Moved the io struct up to the generic lg.h

In reply to Steven Rostedt

drivers/lguest/i386/lg.h line 24

Quoted 11 lines · On Wed, 08 Aug 2007 20:32:15 -0400 Steven Rostedt <[email protected]> wrote:
drivers/lguest/i386/lg.h +2 -0
index 64f0abe..c5ea14c 100644
@@ -20,6 +20,8 @@
 #include <linux/err.h>
 #include <asm/semaphore.h>
 #include "irq_vectors.h"
+/* some files include this, some include the parent */
+#include "../lg.h"

Surely everything should just include the parent which allows for easier consolidation over time. (as you are doing here)

drivers/lguest/lg.h line 2

Quoted 5 lines
drivers/lguest/lg.h +2 -0
@@ -1,3 +1,19 @@
+#ifndef _LGUEST_LG_GENERIC
+#define _LGUEST_LG_GENERIC

Maybe _LGUEST_LG_H? and the arch ones could use _LGUEST_I386_LG_H etc.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/virtualization

#18 lore raw

Re: [PATCH 4/7] Moved the io struct up to the generic lg.h

In reply to Steven Rostedt

drivers/lguest/i386/lg.h line 24

Quoted 11 lines · On Wed, 08 Aug 2007 20:32:15 -0400 Steven Rostedt <[email protected]> wrote:
drivers/lguest/i386/lg.h +2 -0
index 64f0abe..c5ea14c 100644
@@ -20,6 +20,8 @@
 #include <linux/err.h>
 #include <asm/semaphore.h>
 #include "irq_vectors.h"
+/* some files include this, some include the parent */
+#include "../lg.h"

Surely everything should just include the parent which allows for easier consolidation over time. (as you are doing here)

drivers/lguest/lg.h line 2

Quoted 5 lines
drivers/lguest/lg.h +2 -0
@@ -1,3 +1,19 @@
+#ifndef _LGUEST_LG_GENERIC
+#define _LGUEST_LG_GENERIC

Maybe _LGUEST_LG_H? and the arch ones could use _LGUEST_I386_LG_H etc.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#11 lore raw

Re: [PATCH 2/7] Added generic lg.h in lguest directory.

In reply to Stephen Rothwell

--

Quoted 7 lines · Stephen Rothwell
Quoted 2 lines · On Wed, 08 Aug 2007 20:32:13 -0400 Steven Rostedt <[email protected]> wrote:

Add a generic lg.h file to call the architecture specific one.

Please combine this with the previous patch so that the tree will build at each step.

Yeah, I wanted to do that, but git got confused when I did that, and did what I didn't want. That was, created a new file in the i386 directory, and diffed the one in this directory.

I'm really want to keep git knowing the history of the file on moving. I could just simply cat the two files instead. Would that be acceptible?

-- Steve

#12 lore raw

Re: [PATCH 2/7] Added generic lg.h in lguest directory.

In reply to Stephen Rothwell

--

Quoted 7 lines · Stephen Rothwell
Quoted 2 lines · On Wed, 08 Aug 2007 20:32:13 -0400 Steven Rostedt <[email protected]> wrote:

Add a generic lg.h file to call the architecture specific one.

Please combine this with the previous patch so that the tree will build at each step.

Yeah, I wanted to do that, but git got confused when I did that, and did what I didn't want. That was, created a new file in the i386 directory, and diffed the one in this directory.

I'm really want to keep git knowing the history of the file on moving. I could just simply cat the two files instead. Would that be acceptible?

-- Steve

#19 lore raw

Re: [PATCH 4/7] Moved the io struct up to the generic lg.h

In reply to Stephen Rothwell

--

Quoted 16 lines · Stephen Rothwell

drivers/lguest/i386/lg.h line 24

Quoted 11 lines · On Wed, 08 Aug 2007 20:32:15 -0400 Steven Rostedt <[email protected]> wrote:
drivers/lguest/i386/lg.h +2 -0
index 64f0abe..c5ea14c 100644
@@ -20,6 +20,8 @@
 #include <linux/err.h>
 #include <asm/semaphore.h>
 #include "irq_vectors.h"
+/* some files include this, some include the parent */
+#include "../lg.h"

Surely everything should just include the parent which allows for easier consolidation over time. (as you are doing here)

Yeah, that sounds better. This was my attempt at not modifing the i386/ stuff too much. But I can have those files change to do a "../lg.h" include. Again, doing the move plus change to keep things building. Hmm, I guess git can handle that.

Quoted 8 lines

drivers/lguest/lg.h line 2

Quoted 6 lines
drivers/lguest/lg.h +2 -0
@@ -1,3 +1,19 @@
+#ifndef _LGUEST_LG_GENERIC
+#define _LGUEST_LG_GENERIC

Maybe _LGUEST_LG_H? and the arch ones could use _LGUEST_I386_LG_H etc.

Noted. Will do in the next release.

Thanks,

-- Steve

#20 lore raw

Re: [PATCH 4/7] Moved the io struct up to the generic lg.h

In reply to Stephen Rothwell

--

Quoted 16 lines · Stephen Rothwell

drivers/lguest/i386/lg.h line 24

Quoted 11 lines · On Wed, 08 Aug 2007 20:32:15 -0400 Steven Rostedt <[email protected]> wrote:
drivers/lguest/i386/lg.h +2 -0
index 64f0abe..c5ea14c 100644
@@ -20,6 +20,8 @@
 #include <linux/err.h>
 #include <asm/semaphore.h>
 #include "irq_vectors.h"
+/* some files include this, some include the parent */
+#include "../lg.h"

Surely everything should just include the parent which allows for easier consolidation over time. (as you are doing here)

Yeah, that sounds better. This was my attempt at not modifing the i386/ stuff too much. But I can have those files change to do a "../lg.h" include. Again, doing the move plus change to keep things building. Hmm, I guess git can handle that.

Quoted 8 lines

drivers/lguest/lg.h line 2

Quoted 6 lines
drivers/lguest/lg.h +2 -0
@@ -1,3 +1,19 @@
+#ifndef _LGUEST_LG_GENERIC
+#define _LGUEST_LG_GENERIC

Maybe _LGUEST_LG_H? and the arch ones could use _LGUEST_I386_LG_H etc.

Noted. Will do in the next release.

Thanks,

-- Steve

#7 lore raw

Re: [PATCH 2/7] Added generic lg.h in lguest directory.

In reply to Glauber de Oliveira Costa
Quoted 17 lines · Glauber de Oliveira Costa

drivers/lguest/lg.h line 3

Quoted 11 lines · Steven Rostedt

Add a generic lg.h file to call the architecture specific one.

drivers/lguest/lg.h new file +3 -0
new file mode 100644
index 0000000..4c4356e
@@ -0,0 +1,3 @@
+#ifdef CONFIG_X86_32
+#include "i386/lg.h"
+#endif

Wouldn't it be cleaner to do something like the asm/ includes? I understand that lguest now lives in drivers/ and so we don't put headers directly in asm-i386 , but we could come up with a similar thing here.

Yeah, that would be much better, and I don't like having something in a header file including arch specific files like that. I target to get lguest going on non x86, so I would like to encourage anyone to think more than x86 when trying to seperate out something :)

IMHO we should avoid any header files with asm specific code in drivers/lguest - in a way I prefer having arch/<foo>/lguest to drivers/lguest/<arch>, would be more esthetically compliant with the include/asm-<arch> approach too, but thats not a big deal.

Cheers,
Jes

#8 lore raw

Re: [PATCH 2/7] Added generic lg.h in lguest directory.

In reply to Glauber de Oliveira Costa
Quoted 17 lines · Glauber de Oliveira Costa

drivers/lguest/lg.h line 3

Quoted 11 lines · Steven Rostedt

Add a generic lg.h file to call the architecture specific one.

drivers/lguest/lg.h new file +3 -0
new file mode 100644
index 0000000..4c4356e
@@ -0,0 +1,3 @@
+#ifdef CONFIG_X86_32
+#include "i386/lg.h"
+#endif

Wouldn't it be cleaner to do something like the asm/ includes? I understand that lguest now lives in drivers/ and so we don't put headers directly in asm-i386 , but we could come up with a similar thing here.

Yeah, that would be much better, and I don't like having something in a header file including arch specific files like that. I target to get lguest going on non x86, so I would like to encourage anyone to think more than x86 when trying to seperate out something :)

IMHO we should avoid any header files with asm specific code in drivers/lguest - in a way I prefer having arch/<foo>/lguest to drivers/lguest/<arch>, would be more esthetically compliant with the include/asm-<arch> approach too, but thats not a big deal.

Cheers,
Jes

#21 lore raw

Re: [PATCH 4/7] Moved the io struct up to the generic lg.h

In reply to Stephen Rothwell
Quoted 15 lines · Stephen Rothwell

drivers/lguest/i386/lg.h line 24

Quoted 10 lines · On Wed, 08 Aug 2007 20:32:15 -0400 Steven Rostedt <[email protected]> wrote:
drivers/lguest/i386/lg.h +2 -0
index 64f0abe..c5ea14c 100644
@@ -20,6 +20,8 @@
 #include <linux/err.h>
 #include <asm/semaphore.h>
 #include "irq_vectors.h"
+/* some files include this, some include the parent */
+#include "../lg.h"

Surely everything should just include the parent which allows for easier consolidation over time. (as you are doing here)

Whats wrong with introducing an include/asm-<arch>/lg.h and have the parent do #include <asm/lg.h> ? Seems much cleaner to me.

Cheers,
Jes

#22 lore raw

Re: [PATCH 4/7] Moved the io struct up to the generic lg.h

In reply to Stephen Rothwell
Quoted 15 lines · Stephen Rothwell

drivers/lguest/i386/lg.h line 24

Quoted 10 lines · On Wed, 08 Aug 2007 20:32:15 -0400 Steven Rostedt <[email protected]> wrote:
drivers/lguest/i386/lg.h +2 -0
index 64f0abe..c5ea14c 100644
@@ -20,6 +20,8 @@
 #include <linux/err.h>
 #include <asm/semaphore.h>
 #include "irq_vectors.h"
+/* some files include this, some include the parent */
+#include "../lg.h"

Surely everything should just include the parent which allows for easier consolidation over time. (as you are doing here)

Whats wrong with introducing an include/asm-<arch>/lg.h and have the parent do #include <asm/lg.h> ? Seems much cleaner to me.

Cheers,
Jes

#23 lore raw

Re: [PATCH 4/7] Moved the io struct up to the generic lg.h

--

Quoted 17 lines · Jes Sorensen
Quoted 15 lines · Stephen Rothwell

drivers/lguest/i386/lg.h line 24

Quoted 10 lines · On Wed, 08 Aug 2007 20:32:15 -0400 Steven Rostedt <[email protected]> wrote:
drivers/lguest/i386/lg.h +2 -0
index 64f0abe..c5ea14c 100644
@@ -20,6 +20,8 @@
 #include <linux/err.h>
 #include <asm/semaphore.h>
 #include "irq_vectors.h"
+/* some files include this, some include the parent */
+#include "../lg.h"

Surely everything should just include the parent which allows for easier consolidation over time. (as you are doing here)

Quoted 2 lines

Whats wrong with introducing an include/asm-<arch>/lg.h and have the parent do #include <asm/lg.h> ? Seems much cleaner to me.

Seems cleaner to me to! I think I'll do that.

Oh, wait! I did. ;-)

-- Steve

P.S. Sorry, couldn't resist.

#28 lore raw

Re: [PATCH 5/7] Change lguest launcher to use asm generic include

In reply to Steven Rostedt
Quoted 6 lines · Steven Rostedt

plain text document attachment (0005-Change-lguest-launcher-to-use-asm-generic-include-instead-of-explicitly.txt) Have the lguest launcher include e820.h via asm/e820.h instead of explicitly saying i386.

Applied, thanks,

Rusty.

#29 lore raw

Re: [PATCH 5/7] Change lguest launcher to use asm generic include

In reply to Steven Rostedt
Quoted 6 lines · Steven Rostedt

plain text document attachment (0005-Change-lguest-launcher-to-use-asm-generic-include-instead-of-explicitly.txt) Have the lguest launcher include e820.h via asm/e820.h instead of explicitly saying i386.

Applied, thanks,

Rusty.

#34 lore raw
In reply to Steven Rostedt
Quoted 10 lines · Steven Rostedt

Hi all,

I've been working on lguest64 and in order to do this, I had to move a lot of the i386 specific out of the way. Well, the lguest64 port is still not ready to display, but before Rusty makes too many changes I would like this in upstream so I don't have to keep repeating my changes :-)

So this patch series moves lguest32 out of the way for other archs.

Yeah, after some more thought I've not applied most of this. We really don't want to move everything then move it back; I prefer Jes' more cautious approach of moving a little bit at a time.

We really have three parts: (1) bits that are generic, (2) bits that should be generic but my implementation is naive, (3) bits that really are i386-specific.

Patches which move 2 to 1 are gratefully accepted: I realize a mass move is easier and this requires thought, but that's what we need.

Since I can't build a module over two directories, that seems to destroy the idea of an i386/ subdir. Instead I've done a patch which renames the *clearly* i386-specific things to i386_<name>, which at least works. I've pushed it into the repository http://lguest.ozlabs.org/patches/

Cheers,
Rusty.

#35 lore raw
In reply to Steven Rostedt
Quoted 10 lines · Steven Rostedt

Hi all,

I've been working on lguest64 and in order to do this, I had to move a lot of the i386 specific out of the way. Well, the lguest64 port is still not ready to display, but before Rusty makes too many changes I would like this in upstream so I don't have to keep repeating my changes :-)

So this patch series moves lguest32 out of the way for other archs.

Yeah, after some more thought I've not applied most of this. We really don't want to move everything then move it back; I prefer Jes' more cautious approach of moving a little bit at a time.

We really have three parts: (1) bits that are generic, (2) bits that should be generic but my implementation is naive, (3) bits that really are i386-specific.

Patches which move 2 to 1 are gratefully accepted: I realize a mass move is easier and this requires thought, but that's what we need.

Since I can't build a module over two directories, that seems to destroy the idea of an i386/ subdir. Instead I've done a patch which renames the *clearly* i386-specific things to i386_<name>, which at least works. I've pushed it into the repository http://lguest.ozlabs.org/patches/

Cheers,
Rusty.

#36 lore raw
Quoted 7 lines · Rusty Russell

Yeah, after some more thought I've not applied most of this. We really don't want to move everything then move it back; I prefer Jes' more cautious approach of moving a little bit at a time.

We really have three parts: (1) bits that are generic, (2) bits that should be generic but my implementation is naive, (3) bits that really are i386-specific.

I have actually been using Steven's patchset to do my work, but in a way it's a tool. Moving things out of the way in bulk and see whats missing kinda helps for that :)

Quoted 7 lines

Patches which move 2 to 1 are gratefully accepted: I realize a mass move is easier and this requires thought, but that's what we need.

Since I can't build a module over two directories, that seems to destroy the idea of an i386/ subdir. Instead I've done a patch which renames the *clearly* i386-specific things to i386_<name>, which at least works. I've pushed it into the repository http://lguest.ozlabs.org/patches/

That works - alternatively we could build two modules, lg and lg_<arch> and just have lg pull in the arch one as well? I'm not really biased, but I think it will get messy later once we add ia64 and x86_64 to the directory.

Cheers,
Jes

#37 lore raw
In reply to Rusty Russell
Quoted 4 lines · Rusty Russell

Since I can't build a module over two directories, that seems to destroy the idea of an i386/ subdir. Instead I've done a patch which renames the *clearly* i386-specific things to i386_<name>, which at least works. I've pushed it into the repository http://lguest.ozlabs.org/patches/

Rusty,

Looking at your patches, I am trying to figure out what they are against. There's a diff that includes a diff in that and I cannot see exactly whats in upstream and whats not.

Any chance you could post a set of seperate patches that are in the queue for Linus so one can quilt apply it or something like that?

Cheers,
Jes