Skip to contentSkip to conversation

MIPS: remove support for trap and emulate KVM

PATCH In review Philippe Mathieu-Daudé 2 participants 3 messages Dec 21, 2022 – Dec 22, 2022 KVM

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 MIPS: remove support for trap and emulate KVM

From: Paolo Bonzini <[email protected]>

This support was limited to the Malta board, drop it. I do not have a machine that can run VZ KVM, so I am assuming that it works for -M malta as well.

---
Since Paolo's v1:

- Remove cpu_mips_kvm_um_phys_to_kseg0() declaration in "cpu.h"
- Remove unused KVM_KSEG0_BASE/KVM_KSEG2_BASE definitions
- Use USEG_LIMIT/KSEG0_BASE instead of magic values

       /* Check where the kernel has been linked */

- if (!(kernel_entry & 0x80000000ll)) {
- error_report("CONFIG_KVM_GUEST kernels are not supported");
+ if (kernel_entry <= USEG_LIMIT) {
+ error_report("Trap-and-Emul kernels (Linux CONFIG_KVM_GUEST)"
+ " are not supported");

- env->CP0_EBase = (cs->cpu_index & 0x3FF) | (int32_t)0x80000000;
+ env->CP0_EBase = KSEG0_BASE | (cs->cpu_index & 0x3FF);

---
 docs/about/deprecated.rst       |  9 -------
 docs/about/removed-features.rst |  9 +++++++
 hw/mips/malta.c                 | 46 +++++----------------------------
 target/mips/cpu.c               |  7 +----
 target/mips/cpu.h               |  3 ---
 target/mips/internal.h          |  3 ---
 target/mips/kvm.c               | 11 +-------
 target/mips/sysemu/addr.c       | 17 ------------
 target/mips/sysemu/physaddr.c   | 13 ----------
 9 files changed, 18 insertions(+), 100 deletions(-)
docs/about/deprecated.rst +0 -9
index 93affe3669..b28f50b22f 100644
@@ -199,15 +199,6 @@ deprecated.  Use ``sections`` instead.
 Member ``section-size`` in return value elements with meta-type ``uint64`` is
 deprecated.  Use ``sections`` instead.
 
-System accelerators
--------------------
-
-MIPS ``Trap-and-Emul`` KVM support (since 6.0)
-''''''''''''''''''''''''''''''''''''''''''''''
-
-The MIPS ``Trap-and-Emul`` KVM host and guest support has been removed
-from Linux upstream kernel, declare it deprecated.
-
 Host Architectures
 ------------------
 
docs/about/removed-features.rst +9 -0
index 63df9848fd..22b4b5d128 100644
@@ -617,6 +617,15 @@ x86 ``Icelake-Client`` CPU (removed in 7.1)
 There isn't ever Icelake Client CPU, it is some wrong and imaginary one.
 Use ``Icelake-Server`` instead.
 
+System accelerators
+-------------------
+
+MIPS "Trap-and-Emulate" KVM support (removed in 8.0)
+''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+The MIPS "Trap-and-Emulate" KVM host and guest support was removed
+from Linux in 2021, and is not supported anymore by QEMU either.
+
 System emulator machines
 ------------------------
 
hw/mips/malta.c +7 -39

90 lines not on this page · raw message

target/mips/cpu.c +1 -6
index 17bbcbf5ff..f8c8e0ba39 100644
@@ -291,12 +291,7 @@ static void mips_cpu_reset_hold(Object *obj)
     env->tlb->tlb_in_use = env->tlb->nb_tlb;
     env->CP0_Wired = 0;
     env->CP0_GlobalNumber = (cs->cpu_index & 0xFF) << CP0GN_VPId;
-    env->CP0_EBase = (cs->cpu_index & 0x3FF);
-    if (mips_um_ksegs_enabled()) {
-        env->CP0_EBase |= 0x40000000;
-    } else {
-        env->CP0_EBase |= (int32_t)0x80000000;
-    }
+    env->CP0_EBase = KSEG0_BASE | (cs->cpu_index & 0x3FF);
     if (env->CP0_Config3 & (1 << CP0C3_CMGCR)) {
         env->CP0_CMGCRBase = 0x1fbf8000 >> 4;
     }
target/mips/cpu.h +0 -3
index 0a085643a3..caf2b06911 100644
@@ -1296,11 +1296,8 @@ void cpu_set_exception_base(int vp_index, target_ulong address);
 uint64_t cpu_mips_kseg0_to_phys(void *opaque, uint64_t addr);
 uint64_t cpu_mips_phys_to_kseg0(void *opaque, uint64_t addr);
 
-uint64_t cpu_mips_kvm_um_phys_to_kseg0(void *opaque, uint64_t addr);
 uint64_t cpu_mips_kseg1_to_phys(void *opaque, uint64_t addr);
 uint64_t cpu_mips_phys_to_kseg1(void *opaque, uint64_t addr);
-bool mips_um_ksegs_enabled(void);
-void mips_um_ksegs_enable(void);
 
 #if !defined(CONFIG_USER_ONLY)
 
target/mips/internal.h +0 -3
index 57b312689a..4b0031d10d 100644
@@ -99,9 +99,6 @@ int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 #define KSEG2_BASE      ((target_ulong)(int32_t)0xC0000000UL)
 #define KSEG3_BASE      ((target_ulong)(int32_t)0xE0000000UL)
 
-#define KVM_KSEG0_BASE  ((target_ulong)(int32_t)0x40000000UL)
-#define KVM_KSEG2_BASE  ((target_ulong)(int32_t)0x60000000UL)
-
 #if !defined(CONFIG_USER_ONLY)
 
 enum {
target/mips/kvm.c +1 -10
index bcb8e06b2c..c14e8f550f 100644
@@ -1268,25 +1268,16 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
 
 int mips_kvm_type(MachineState *machine, const char *vm_type)
 {
-#if defined(KVM_CAP_MIPS_VZ) || defined(KVM_CAP_MIPS_TE)
+#if defined(KVM_CAP_MIPS_VZ)
     int r;
     KVMState *s = KVM_STATE(machine->accelerator);
-#endif
 
-#if defined(KVM_CAP_MIPS_VZ)
     r = kvm_check_extension(s, KVM_CAP_MIPS_VZ);
     if (r > 0) {
         return KVM_VM_MIPS_VZ;
     }
 #endif
 
-#if defined(KVM_CAP_MIPS_TE)
-    r = kvm_check_extension(s, KVM_CAP_MIPS_TE);
-    if (r > 0) {
-        return KVM_VM_MIPS_TE;
-    }
-#endif
-
     return -1;
 }
 
target/mips/sysemu/addr.c +0 -17
index 86f1c129c9..4f025be44a 100644
@@ -23,8 +23,6 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 
-static int mips_um_ksegs;
-
 uint64_t cpu_mips_kseg0_to_phys(void *opaque, uint64_t addr)
 {
     return addr & 0x1fffffffll;
@@ -35,11 +33,6 @@ uint64_t cpu_mips_phys_to_kseg0(void *opaque, uint64_t addr)
     return addr | ~0x7fffffffll;
 }
 
-uint64_t cpu_mips_kvm_um_phys_to_kseg0(void *opaque, uint64_t addr)
-{
-    return addr | 0x40000000ll;
-}
-
 uint64_t cpu_mips_kseg1_to_phys(void *opaque, uint64_t addr)
 {
     return addr & 0x1fffffffll;
@@ -49,13 +42,3 @@ uint64_t cpu_mips_phys_to_kseg1(void *opaque, uint64_t addr)
 {
     return (addr & 0x1fffffffll) | 0xffffffffa0000000ll;
 }
-
-bool mips_um_ksegs_enabled(void)
-{
-    return mips_um_ksegs;
-}
-
-void mips_um_ksegs_enable(void)
-{
-    mips_um_ksegs = 1;
-}
target/mips/sysemu/physaddr.c +0 -13
index 1918633aa1..2970df8a09 100644
@@ -130,19 +130,6 @@ int get_physical_address(CPUMIPSState *env, hwaddr *physical,
     /* effective address (modified for KVM T&E kernel segments) */
     target_ulong address = real_address;
 
-    if (mips_um_ksegs_enabled()) {
-        /* KVM T&E adds guest kernel segments in useg */
-        if (real_address >= KVM_KSEG0_BASE) {
-            if (real_address < KVM_KSEG2_BASE) {
-                /* kseg0 */
-                address += KSEG0_BASE - KVM_KSEG0_BASE;
-            } else if (real_address <= USEG_LIMIT) {
-                /* kseg2/3 */
-                address += KSEG2_BASE - KVM_KSEG2_BASE;
-            }
-        }
-    }
-
     if (address <= USEG_LIMIT) {
         /* useg */
         uint16_t segctl;
Signature · 1 line
2.38.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 24 lines · Philippe Mathieu-Daudé

From: Paolo Bonzini<[email protected]>

This support was limited to the Malta board, drop it. I do not have a machine that can run VZ KVM, so I am assuming that it works for -M malta as well.

---
Since Paolo's v1:

- Remove cpu_mips_kvm_um_phys_to_kseg0() declaration in "cpu.h"
- Remove unused KVM_KSEG0_BASE/KVM_KSEG2_BASE definitions
- Use USEG_LIMIT/KSEG0_BASE instead of magic values

        /* Check where the kernel has been linked */

- if (!(kernel_entry & 0x80000000ll)) {
- error_report("CONFIG_KVM_GUEST kernels are not supported");
+ if (kernel_entry <= USEG_LIMIT) {
+ error_report("Trap-and-Emul kernels (Linux CONFIG_KVM_GUEST)"
+ " are not supported");

- env->CP0_EBase = (cs->cpu_index & 0x3FF) | (int32_t)0x80000000;
+ env->CP0_EBase = KSEG0_BASE | (cs->cpu_index & 0x3FF);

Quoted 11 lines
---
  docs/about/deprecated.rst       |  9 -------
  docs/about/removed-features.rst |  9 +++++++
  hw/mips/malta.c                 | 46 +++++----------------------------
  target/mips/cpu.c               |  7 +----
  target/mips/cpu.h               |  3 ---
  target/mips/internal.h          |  3 ---
  target/mips/kvm.c               | 11 +-------
  target/mips/sysemu/addr.c       | 17 ------------
  target/mips/sysemu/physaddr.c   | 13 ----------
  9 files changed, 18 insertions(+), 100 deletions(-)

r~

#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 24 lines · Philippe Mathieu-Daudé

From: Paolo Bonzini <[email protected]>

This support was limited to the Malta board, drop it. I do not have a machine that can run VZ KVM, so I am assuming that it works for -M malta as well.

---
Since Paolo's v1:

- Remove cpu_mips_kvm_um_phys_to_kseg0() declaration in "cpu.h"
- Remove unused KVM_KSEG0_BASE/KVM_KSEG2_BASE definitions
- Use USEG_LIMIT/KSEG0_BASE instead of magic values

        /* Check where the kernel has been linked */

- if (!(kernel_entry & 0x80000000ll)) {
- error_report("CONFIG_KVM_GUEST kernels are not supported");
+ if (kernel_entry <= USEG_LIMIT) {
+ error_report("Trap-and-Emul kernels (Linux CONFIG_KVM_GUEST)"
+ " are not supported");

- env->CP0_EBase = (cs->cpu_index & 0x3FF) | (int32_t)0x80000000;
+ env->CP0_EBase = KSEG0_BASE | (cs->cpu_index & 0x3FF);

Quoted 11 lines
---
  docs/about/deprecated.rst       |  9 -------
  docs/about/removed-features.rst |  9 +++++++
  hw/mips/malta.c                 | 46 +++++----------------------------
  target/mips/cpu.c               |  7 +----
  target/mips/cpu.h               |  3 ---
  target/mips/internal.h          |  3 ---
  target/mips/kvm.c               | 11 +-------
  target/mips/sysemu/addr.c       | 17 ------------
  target/mips/sysemu/physaddr.c   | 13 ----------
  9 files changed, 18 insertions(+), 100 deletions(-)

Thanks, queued to mips-next.