summaryrefslogtreecommitdiffstats
path: root/hw
diff options
context:
space:
mode:
authorJames Hogan2017-07-31 15:09:13 +0200
committerYongbok Kim2017-08-02 23:18:06 +0200
commitd3d93c6c1eb0d94d2f203ac272629e6ebfc468a7 (patch)
tree83d3af6e6b6e4805be622337ebf354b3681b95a5 /hw
parentmips: Improve segment defs for KVM T&E guests (diff)
downloadqemu-d3d93c6c1eb0d94d2f203ac272629e6ebfc468a7.tar.gz
qemu-d3d93c6c1eb0d94d2f203ac272629e6ebfc468a7.tar.xz
qemu-d3d93c6c1eb0d94d2f203ac272629e6ebfc468a7.zip
mips: Add KVM T&E segment support for TCG
MIPS KVM trap & emulate guest kernels have a different segment layout compared with traditional MIPS kernels, to allow both the user and kernel code to run from the user address segment without repeatedly trapping to KVM. QEMU currently supports this layout only for KVM, but its sometimes useful to be able to run these kernels in QEMU on a PC, so enable it for TCG too. This also paves the way for MIPS KVM VZ support (which uses the normal virtual memory layout) by abstracting whether user mode kernel segments are in use. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: James Hogan <james.hogan@imgtec.com> Cc: Yongbok Kim <yongbok.kim@imgtec.com> Cc: Aurelien Jarno <aurelien@aurel32.net> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: kvm@vger.kernel.org Reviewed-by: Richard Henderson <rth@twiddle.net> [Yongbok Kim: minor change] Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/mips/addr.c12
-rw-r--r--hw/mips/mips_malta.c17
2 files changed, 19 insertions, 10 deletions
diff --git a/hw/mips/addr.c b/hw/mips/addr.c
index e4e86b4a75..4da46e1731 100644
--- a/hw/mips/addr.c
+++ b/hw/mips/addr.c
@@ -24,6 +24,8 @@
#include "hw/hw.h"
#include "hw/mips/cpudevs.h"
+static int mips_um_ksegs;
+
uint64_t cpu_mips_kseg0_to_phys(void *opaque, uint64_t addr)
{
return addr & 0x1fffffffll;
@@ -38,3 +40,13 @@ uint64_t cpu_mips_kvm_um_phys_to_kseg0(void *opaque, uint64_t addr)
{
return addr | 0x40000000ll;
}
+
+bool mips_um_ksegs_enabled(void)
+{
+ return mips_um_ksegs;
+}
+
+void mips_um_ksegs_enable(void)
+{
+ mips_um_ksegs = 1;
+}
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index 9dcec27304..af678f5784 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -818,23 +818,20 @@ static int64_t load_kernel (void)
exit(1);
}
- /* Sanity check where the kernel has been linked */
- if (kvm_enabled()) {
- if (kernel_entry & 0x80000000ll) {
+ /* Check where the kernel has been linked */
+ if (kernel_entry & 0x80000000ll) {
+ if (kvm_enabled()) {
error_report("KVM guest kernels must be linked in useg. "
"Did you forget to enable CONFIG_KVM_GUEST?");
exit(1);
}
- xlate_to_kseg0 = cpu_mips_kvm_um_phys_to_kseg0;
+ xlate_to_kseg0 = cpu_mips_phys_to_kseg0;
} else {
- if (!(kernel_entry & 0x80000000ll)) {
- error_report("KVM guest kernels aren't supported with TCG. "
- "Did you unintentionally enable CONFIG_KVM_GUEST?");
- exit(1);
- }
+ /* if kernel entry is in useg it is probably a KVM T&E kernel */
+ mips_um_ksegs_enable();
- xlate_to_kseg0 = cpu_mips_phys_to_kseg0;
+ xlate_to_kseg0 = cpu_mips_kvm_um_phys_to_kseg0;
}
/* load initrd */