* [PATCH 1/3] kvm-tool: ARM: set interrupt priority mask in secondary boot path
@ 2012-12-05 16:32 Will Deacon
2012-12-05 16:32 ` [PATCH 2/3] kvm tools: arm: fixup pre-processor guards for kvm-cpu-arch.h Will Deacon
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Will Deacon @ 2012-12-05 16:32 UTC (permalink / raw)
To: kvm; +Cc: penberg, marc.zyngier, Marc Zyngier, Will Deacon
From: Marc Zyngier <Marc.Zyngier@arm.com>
A bug in the KVM GIC init code set the priority mask to the
highest possible value, while the reset value should be zero.
Now that the kernel bug is fixed, kvm-tool must properly configure
its GIC CPU interface in order to receive the boot IPI. Just set
the GICC_PMR register to the maximum value (0xff), and it "just works".
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
[will: added #define for PMR offset]
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
tools/kvm/arm/aarch32/smp-pen.S | 4 ++++
tools/kvm/arm/include/arm-common/gic.h | 3 +++
2 files changed, 7 insertions(+)
diff --git a/tools/kvm/arm/aarch32/smp-pen.S b/tools/kvm/arm/aarch32/smp-pen.S
index 0861171..1e63c95 100644
--- a/tools/kvm/arm/aarch32/smp-pen.S
+++ b/tools/kvm/arm/aarch32/smp-pen.S
@@ -17,6 +17,10 @@ smp_pen_start:
mov r1, #GIC_CPUI_CTLR_EN
str r1, [r0]
+ @ Set the priority mask to accept any interrupt
+ mov r1, #GIC_CPUI_PMR_MIN_PRIO
+ str r1, [r0, #GIC_CPUI_OFF_PMR]
+
@ Now wait for the primary to poke us
adr r0, smp_jump_addr
ldr r1, =AARCH32_SMP_BAD_MAGIC
diff --git a/tools/kvm/arm/include/arm-common/gic.h b/tools/kvm/arm/include/arm-common/gic.h
index d534174..d6a18e1 100644
--- a/tools/kvm/arm/include/arm-common/gic.h
+++ b/tools/kvm/arm/include/arm-common/gic.h
@@ -19,6 +19,9 @@
#define GIC_FDT_IRQ_PPI_CPU_MASK (0xff << GIC_FDT_IRQ_PPI_CPU_SHIFT)
#define GIC_CPUI_CTLR_EN (1 << 0)
+#define GIC_CPUI_PMR_MIN_PRIO 0xff
+
+#define GIC_CPUI_OFF_PMR 4
#define GIC_MAX_CPUS 8
#define GIC_MAX_IRQ 255
--
1.8.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] kvm tools: arm: fixup pre-processor guards for kvm-cpu-arch.h
2012-12-05 16:32 [PATCH 1/3] kvm-tool: ARM: set interrupt priority mask in secondary boot path Will Deacon
@ 2012-12-05 16:32 ` Will Deacon
2012-12-05 16:32 ` [PATCH 3/3] kvm tools: allow arch's to provide their own command-line options Will Deacon
2012-12-10 7:30 ` [PATCH 1/3] kvm-tool: ARM: set interrupt priority mask in secondary boot path Pekka Enberg
2 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2012-12-05 16:32 UTC (permalink / raw)
To: kvm; +Cc: penberg, marc.zyngier, Will Deacon
Cosmetic patch to correct the pre-processor guards for arm in
kvm-cpu-arch.h. It's not something to lose sleep over but I find it
incredibly irritating!
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
tools/kvm/arm/include/kvm/kvm-cpu-arch.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/kvm/arm/include/kvm/kvm-cpu-arch.h b/tools/kvm/arm/include/kvm/kvm-cpu-arch.h
index 351fbe6..f0aeca2 100644
--- a/tools/kvm/arm/include/kvm/kvm-cpu-arch.h
+++ b/tools/kvm/arm/include/kvm/kvm-cpu-arch.h
@@ -1,5 +1,5 @@
-#ifndef ARM_COMMON__KVM_CPU_ARCH_H
-#define ARM_COMMON__KVM_CPU_ARCH_H
+#ifndef KVM__KVM_CPU_ARCH_H
+#define KVM__KVM_CPU_ARCH_H
#include <linux/kvm.h>
#include <pthread.h>
@@ -43,4 +43,4 @@ static inline bool kvm_cpu__emulate_io(struct kvm *kvm, u16 port, void *data,
bool kvm_cpu__emulate_mmio(struct kvm *kvm, u64 phys_addr, u8 *data, u32 len,
u8 is_write);
-#endif /* ARM_COMMON__KVM_CPU_ARCH_H */
+#endif /* KVM__KVM_CPU_ARCH_H */
--
1.8.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] kvm tools: allow arch's to provide their own command-line options
2012-12-05 16:32 [PATCH 1/3] kvm-tool: ARM: set interrupt priority mask in secondary boot path Will Deacon
2012-12-05 16:32 ` [PATCH 2/3] kvm tools: arm: fixup pre-processor guards for kvm-cpu-arch.h Will Deacon
@ 2012-12-05 16:32 ` Will Deacon
2012-12-10 7:30 ` [PATCH 1/3] kvm-tool: ARM: set interrupt priority mask in secondary boot path Pekka Enberg
2 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2012-12-05 16:32 UTC (permalink / raw)
To: kvm; +Cc: penberg, marc.zyngier, Will Deacon
Currently, only x86 has architecture command-line options (for setting
the BIOS video mode) however this is likely to become more common in the
future.
This patch adds some simple macros and a struct definition to allow
architectures to augment the command-line options with private
definitions. The BIOS video mode option (--vidmode) is also migrated to
the new framework.
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
tools/kvm/arm/fdt.c | 4 ++--
tools/kvm/arm/include/kvm/kvm-config-arch.h | 7 +++++++
tools/kvm/builtin-run.c | 21 ++++++---------------
tools/kvm/include/kvm/kvm-config.h | 3 ++-
tools/kvm/include/kvm/kvm.h | 4 ++--
tools/kvm/include/kvm/parse-options.h | 3 +++
tools/kvm/kvm.c | 6 +++---
tools/kvm/powerpc/include/kvm/kvm-config-arch.h | 7 +++++++
tools/kvm/powerpc/kvm.c | 4 ++--
tools/kvm/x86/include/kvm/kvm-config-arch.h | 15 +++++++++++++++
tools/kvm/x86/kvm.c | 16 ++++++++++++++--
11 files changed, 63 insertions(+), 27 deletions(-)
create mode 100644 tools/kvm/arm/include/kvm/kvm-config-arch.h
create mode 100644 tools/kvm/powerpc/include/kvm/kvm-config-arch.h
create mode 100644 tools/kvm/x86/include/kvm/kvm-config-arch.h
diff --git a/tools/kvm/arm/fdt.c b/tools/kvm/arm/fdt.c
index 8e17d3c..c7f4b52 100644
--- a/tools/kvm/arm/fdt.c
+++ b/tools/kvm/arm/fdt.c
@@ -258,8 +258,8 @@ int load_flat_binary(struct kvm *kvm, int fd_kernel, int fd_initrd,
return true;
}
-bool load_bzimage(struct kvm *kvm, int fd_kernel,
- int fd_initrd, const char *kernel_cmdline, u16 vidmode)
+bool load_bzimage(struct kvm *kvm, int fd_kernel, int fd_initrd,
+ const char *kernel_cmdline)
{
/* To b or not to b? That is the zImage. */
return false;
diff --git a/tools/kvm/arm/include/kvm/kvm-config-arch.h b/tools/kvm/arm/include/kvm/kvm-config-arch.h
new file mode 100644
index 0000000..60f61de
--- /dev/null
+++ b/tools/kvm/arm/include/kvm/kvm-config-arch.h
@@ -0,0 +1,7 @@
+#ifndef KVM__KVM_CONFIG_ARCH_H
+#define KVM__KVM_CONFIG_ARCH_H
+
+struct kvm_config_arch {
+};
+
+#endif /* KVM__KVM_CONFIG_ARCH_H */
diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 96e68af..d0b876a 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -90,6 +90,10 @@ void kvm_run_set_wrapper_sandbox(void)
kvm_run_wrapper = KVM_RUN_SANDBOX;
}
+#ifndef OPT_ARCH_RUN
+#define OPT_ARCH_RUN(...)
+#endif
+
#define BUILD_OPTIONS(name, cfg, kvm) \
struct option name[] = { \
OPT_GROUP("Basic options:"), \
@@ -144,10 +148,6 @@ void kvm_run_set_wrapper_sandbox(void)
OPT_BOOLEAN('\0', "no-dhcp", &(cfg)->no_dhcp, "Disable kernel" \
" DHCP in rootfs mode"), \
\
- OPT_GROUP("BIOS options:"), \
- OPT_INTEGER('\0', "vidmode", &(cfg)->vidmode, \
- "Video mode"), \
- \
OPT_GROUP("Debug options:"), \
OPT_BOOLEAN('\0', "debug", &do_debug_print, \
"Enable debug messages"), \
@@ -159,6 +159,8 @@ void kvm_run_set_wrapper_sandbox(void)
"Enable MMIO debugging"), \
OPT_INTEGER('\0', "debug-iodelay", &(cfg)->debug_iodelay, \
"Delay IO by millisecond"), \
+ \
+ OPT_ARCH(RUN, cfg) \
OPT_END() \
};
@@ -598,17 +600,6 @@ static struct kvm *kvm_cmd_run_init(int argc, const char **argv)
if (!kvm->cfg.script)
kvm->cfg.script = DEFAULT_SCRIPT;
- if (!kvm->cfg.vidmode)
- kvm->cfg.vidmode = -1;
-
- /* vidmode should be either specified or set by default */
- if (kvm->cfg.vnc || kvm->cfg.sdl) {
- if (kvm->cfg.vidmode == -1)
- kvm->cfg.vidmode = 0x312;
- } else {
- kvm->cfg.vidmode = 0;
- }
-
if (!kvm->cfg.network)
kvm->cfg.network = DEFAULT_NETWORK;
diff --git a/tools/kvm/include/kvm/kvm-config.h b/tools/kvm/include/kvm/kvm-config.h
index df36a76..c66f481 100644
--- a/tools/kvm/include/kvm/kvm-config.h
+++ b/tools/kvm/include/kvm/kvm-config.h
@@ -2,6 +2,7 @@
#define KVM_CONFIG_H_
#include "kvm/disk-image.h"
+#include "kvm/kvm-config-arch.h"
#define DEFAULT_KVM_DEV "/dev/kvm"
#define DEFAULT_CONSOLE "serial"
@@ -17,6 +18,7 @@
#define MIN_RAM_SIZE_BYTE (MIN_RAM_SIZE_MB << MB_SHIFT)
struct kvm_config {
+ struct kvm_config_arch arch;
struct disk_image_params disk_image[MAX_DISK_IMAGES];
u64 ram_size;
u8 image_count;
@@ -25,7 +27,6 @@ struct kvm_config {
int active_console;
int debug_iodelay;
int nrcpus;
- int vidmode;
const char *kernel_cmdline;
const char *kernel_filename;
const char *vmlinux_filename;
diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h
index b54ac03..acb0818 100644
--- a/tools/kvm/include/kvm/kvm.h
+++ b/tools/kvm/include/kvm/kvm.h
@@ -78,7 +78,7 @@ void kvm__init_ram(struct kvm *kvm);
int kvm__exit(struct kvm *kvm);
bool kvm__load_firmware(struct kvm *kvm, const char *firmware_filename);
bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename,
- const char *initrd_filename, const char *kernel_cmdline, u16 vidmode);
+ const char *initrd_filename, const char *kernel_cmdline);
int kvm_timer__init(struct kvm *kvm);
int kvm_timer__exit(struct kvm *kvm);
void kvm__irq_line(struct kvm *kvm, int irq, int level);
@@ -109,7 +109,7 @@ void *guest_flat_to_host(struct kvm *kvm, u64 offset);
u64 host_to_guest_flat(struct kvm *kvm, void *ptr);
int load_flat_binary(struct kvm *kvm, int fd_kernel, int fd_initrd, const char *kernel_cmdline);
-bool load_bzimage(struct kvm *kvm, int fd_kernel, int fd_initrd, const char *kernel_cmdline, u16 vidmode);
+bool load_bzimage(struct kvm *kvm, int fd_kernel, int fd_initrd, const char *kernel_cmdline);
/*
* Debugging
diff --git a/tools/kvm/include/kvm/parse-options.h b/tools/kvm/include/kvm/parse-options.h
index cc188b9..09a5fca 100644
--- a/tools/kvm/include/kvm/parse-options.h
+++ b/tools/kvm/include/kvm/parse-options.h
@@ -191,6 +191,9 @@ struct option {
#define OPT_END() { .type = OPTION_END }
+#define OPT_ARCH(cmd, cfg) \
+ OPT_ARCH_##cmd(OPT_GROUP("Arch-specific options:"), &(cfg)->arch)
+
enum {
PARSE_OPT_HELP = -1,
PARSE_OPT_DONE,
diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c
index af19e37..3ea6339 100644
--- a/tools/kvm/kvm.c
+++ b/tools/kvm/kvm.c
@@ -303,7 +303,7 @@ int kvm__init(struct kvm *kvm)
if (!kvm->cfg.firmware_filename) {
if (!kvm__load_kernel(kvm, kvm->cfg.kernel_filename,
- kvm->cfg.initrd_filename, kvm->cfg.real_cmdline, kvm->cfg.vidmode))
+ kvm->cfg.initrd_filename, kvm->cfg.real_cmdline))
die("unable to load kernel %s", kvm->cfg.kernel_filename);
}
@@ -349,7 +349,7 @@ static bool initrd_check(int fd)
}
bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename,
- const char *initrd_filename, const char *kernel_cmdline, u16 vidmode)
+ const char *initrd_filename, const char *kernel_cmdline)
{
bool ret;
int fd_kernel = -1, fd_initrd = -1;
@@ -367,7 +367,7 @@ bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename,
die("%s is not an initrd", initrd_filename);
}
- ret = load_bzimage(kvm, fd_kernel, fd_initrd, kernel_cmdline, vidmode);
+ ret = load_bzimage(kvm, fd_kernel, fd_initrd, kernel_cmdline);
if (ret)
goto found_kernel;
diff --git a/tools/kvm/powerpc/include/kvm/kvm-config-arch.h b/tools/kvm/powerpc/include/kvm/kvm-config-arch.h
new file mode 100644
index 0000000..60f61de
--- /dev/null
+++ b/tools/kvm/powerpc/include/kvm/kvm-config-arch.h
@@ -0,0 +1,7 @@
+#ifndef KVM__KVM_CONFIG_ARCH_H
+#define KVM__KVM_CONFIG_ARCH_H
+
+struct kvm_config_arch {
+};
+
+#endif /* KVM__KVM_CONFIG_ARCH_H */
diff --git a/tools/kvm/powerpc/kvm.c b/tools/kvm/powerpc/kvm.c
index d8dfc01..dc9f89d 100644
--- a/tools/kvm/powerpc/kvm.c
+++ b/tools/kvm/powerpc/kvm.c
@@ -204,8 +204,8 @@ int load_flat_binary(struct kvm *kvm, int fd_kernel, int fd_initrd, const char *
return true;
}
-bool load_bzimage(struct kvm *kvm, int fd_kernel,
- int fd_initrd, const char *kernel_cmdline, u16 vidmode)
+bool load_bzimage(struct kvm *kvm, int fd_kernel, int fd_initrd,
+ const char *kernel_cmdline)
{
/* We don't support bzImages. */
return false;
diff --git a/tools/kvm/x86/include/kvm/kvm-config-arch.h b/tools/kvm/x86/include/kvm/kvm-config-arch.h
new file mode 100644
index 0000000..3eae8db
--- /dev/null
+++ b/tools/kvm/x86/include/kvm/kvm-config-arch.h
@@ -0,0 +1,15 @@
+#ifndef KVM__KVM_CONFIG_ARCH_H
+#define KVM__KVM_CONFIG_ARCH_H
+
+#include "kvm/parse-options.h"
+
+struct kvm_config_arch {
+ int vidmode;
+};
+
+#define OPT_ARCH_RUN(pfx, cfg) \
+ pfx, \
+ OPT_GROUP("BIOS options:"), \
+ OPT_INTEGER('\0', "vidmode", &(cfg)->vidmode, "Video mode"),
+
+#endif /* KVM__KVM_CONFIG_ARCH_H */
diff --git a/tools/kvm/x86/kvm.c b/tools/kvm/x86/kvm.c
index 9971ffd..687e6b7 100644
--- a/tools/kvm/x86/kvm.c
+++ b/tools/kvm/x86/kvm.c
@@ -235,8 +235,8 @@ int load_flat_binary(struct kvm *kvm, int fd_kernel, int fd_initrd, const char *
static const char *BZIMAGE_MAGIC = "HdrS";
-bool load_bzimage(struct kvm *kvm, int fd_kernel,
- int fd_initrd, const char *kernel_cmdline, u16 vidmode)
+bool load_bzimage(struct kvm *kvm, int fd_kernel, int fd_initrd,
+ const char *kernel_cmdline)
{
struct boot_params *kern_boot;
unsigned long setup_sects;
@@ -245,6 +245,7 @@ bool load_bzimage(struct kvm *kvm, int fd_kernel,
ssize_t setup_size;
void *p;
int nr;
+ u16 vidmode;
/*
* See Documentation/x86/boot.txt for details no bzImage on-disk and
@@ -293,6 +294,17 @@ bool load_bzimage(struct kvm *kvm, int fd_kernel,
memcpy(p, kernel_cmdline, cmdline_size - 1);
}
+ if (!kvm->cfg.arch.vidmode)
+ vidmode = -1;
+
+ /* vidmode should be either specified or set by default */
+ if (kvm->cfg.vnc || kvm->cfg.sdl) {
+ if (vidmode == -1)
+ vidmode = 0x312;
+ } else {
+ vidmode = 0;
+ }
+
kern_boot = guest_real_to_host(kvm, BOOT_LOADER_SELECTOR, 0x00);
kern_boot->hdr.cmd_line_ptr = BOOT_CMDLINE_OFFSET;
--
1.8.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] kvm-tool: ARM: set interrupt priority mask in secondary boot path
2012-12-05 16:32 [PATCH 1/3] kvm-tool: ARM: set interrupt priority mask in secondary boot path Will Deacon
2012-12-05 16:32 ` [PATCH 2/3] kvm tools: arm: fixup pre-processor guards for kvm-cpu-arch.h Will Deacon
2012-12-05 16:32 ` [PATCH 3/3] kvm tools: allow arch's to provide their own command-line options Will Deacon
@ 2012-12-10 7:30 ` Pekka Enberg
2 siblings, 0 replies; 4+ messages in thread
From: Pekka Enberg @ 2012-12-10 7:30 UTC (permalink / raw)
To: Will Deacon; +Cc: kvm, Marc Zyngier, Marc Zyngier
On Wed, 5 Dec 2012, Will Deacon wrote:
> From: Marc Zyngier <Marc.Zyngier@arm.com>
>
> A bug in the KVM GIC init code set the priority mask to the
> highest possible value, while the reset value should be zero.
>
> Now that the kernel bug is fixed, kvm-tool must properly configure
> its GIC CPU interface in order to receive the boot IPI. Just set
> the GICC_PMR register to the maximum value (0xff), and it "just works".
>
> Cc: Pekka Enberg <penberg@kernel.org>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> [will: added #define for PMR offset]
> Signed-off-by: Will Deacon <will.deacon@arm.com>
Applied all three patches, thanks Will!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-12-10 7:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-05 16:32 [PATCH 1/3] kvm-tool: ARM: set interrupt priority mask in secondary boot path Will Deacon
2012-12-05 16:32 ` [PATCH 2/3] kvm tools: arm: fixup pre-processor guards for kvm-cpu-arch.h Will Deacon
2012-12-05 16:32 ` [PATCH 3/3] kvm tools: allow arch's to provide their own command-line options Will Deacon
2012-12-10 7:30 ` [PATCH 1/3] kvm-tool: ARM: set interrupt priority mask in secondary boot path Pekka Enberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).