diff mbox series

[V3,08/14] KVM: MIPS: Let indexed cacheops cause guest exit on Loongson-3

Message ID 1588500367-1056-9-git-send-email-chenhc@lemote.com (mailing list archive)
State New, archived
Headers show
Series KVM: MIPS: Add Loongson-3 support (Host Side) | expand

Commit Message

Huacai Chen May 3, 2020, 10:06 a.m. UTC
Loongson-3's indexed cache operations need a node-id in the address,
but in KVM guest the node-id may be incorrect. So, let indexed cache
operations cause guest exit on Loongson-3.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Co-developed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/mips/kvm/vz.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Aleksandar Markovic May 8, 2020, 10:55 a.m. UTC | #1
нед, 3. мај 2020. у 12:13 Huacai Chen <chenhc@lemote.com> је написао/ла:
>
> Loongson-3's indexed cache operations need a node-id in the address,
> but in KVM guest the node-id may be incorrect. So, let indexed cache
> operations cause guest exit on Loongson-3.
>
> Signed-off-by: Huacai Chen <chenhc@lemote.com>
> Co-developed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
>  arch/mips/kvm/vz.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/mips/kvm/vz.c b/arch/mips/kvm/vz.c
> index f9fbbc16..ab320f0 100644
> --- a/arch/mips/kvm/vz.c
> +++ b/arch/mips/kvm/vz.c
> @@ -2853,8 +2853,12 @@ static int kvm_vz_hardware_enable(void)
>         write_c0_guestctl0(MIPS_GCTL0_CP0 |
>                            (MIPS_GCTL0_AT_GUEST << MIPS_GCTL0_AT_SHIFT) |
>                            MIPS_GCTL0_CG | MIPS_GCTL0_CF);
> -       if (cpu_has_guestctl0ext)
> -               set_c0_guestctl0ext(MIPS_GCTL0EXT_CGI);
> +       if (cpu_has_guestctl0ext) {
> +               if (current_cpu_type() != CPU_LOONGSON64)
> +                       set_c0_guestctl0ext(MIPS_GCTL0EXT_CGI);
> +               else
> +                       clear_c0_guestctl0ext(MIPS_GCTL0EXT_CGI);
> +       }
>
>         if (cpu_has_guestid) {
>                 write_c0_guestctl1(0);
> --
> 2.7.0
>

Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
diff mbox series

Patch

diff --git a/arch/mips/kvm/vz.c b/arch/mips/kvm/vz.c
index f9fbbc16..ab320f0 100644
--- a/arch/mips/kvm/vz.c
+++ b/arch/mips/kvm/vz.c
@@ -2853,8 +2853,12 @@  static int kvm_vz_hardware_enable(void)
 	write_c0_guestctl0(MIPS_GCTL0_CP0 |
 			   (MIPS_GCTL0_AT_GUEST << MIPS_GCTL0_AT_SHIFT) |
 			   MIPS_GCTL0_CG | MIPS_GCTL0_CF);
-	if (cpu_has_guestctl0ext)
-		set_c0_guestctl0ext(MIPS_GCTL0EXT_CGI);
+	if (cpu_has_guestctl0ext) {
+		if (current_cpu_type() != CPU_LOONGSON64)
+			set_c0_guestctl0ext(MIPS_GCTL0EXT_CGI);
+		else
+			clear_c0_guestctl0ext(MIPS_GCTL0EXT_CGI);
+	}
 
 	if (cpu_has_guestid) {
 		write_c0_guestctl1(0);