From nobody Sun Dec 14 06:15:25 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1593287574; cv=none; d=zohomail.com; s=zohoarc; b=iuUI9X2l+7WeMH7FXiIRNM293ekr8TSvIVSfkDx3nX1hJus72jdvhWvfubfcO0GXbtMd+gRnwNfYQ7FNZIRzeOOD2CB15XuoejPHsYbMvd+OUw+mGVDvgcpAEAAEOhRifmxMBZybMnnaoZCtnxIzwx3Zvxg1trNNxzpK3Vbn9XI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593287574; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Tps7nMTNDUkl/eAj1enISwY5nRsZq9itXUGQjMYdQXM=; b=K6u/SxMnIjTdB+elijE6SV9fRwMVqgwQH7f7WUkpZ66dajTtS4EvVZfIgJb2c4mK6z58O7wsDaherrY8jPvhYECkrweySit/flRqyB/PxwTbASjs2MbUJzqfVFKFxllZtuq/hfqZFl1vjQEHZzZxQ0nA829yCUCfSc76BNGJJxE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593287574020571.5308105275247; Sat, 27 Jun 2020 12:52:54 -0700 (PDT) Received: from localhost ([::1]:52564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpGse-0003tS-9a for importer@patchew.org; Sat, 27 Jun 2020 15:52:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpGrb-0002MK-VP for qemu-devel@nongnu.org; Sat, 27 Jun 2020 15:51:47 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]:38782) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jpGra-0003sy-DR for qemu-devel@nongnu.org; Sat, 27 Jun 2020 15:51:47 -0400 Received: by mail-ed1-x52e.google.com with SMTP id n2so456684edr.5 for ; Sat, 27 Jun 2020 12:51:46 -0700 (PDT) Received: from rtrkw774-lin.syrmia.com ([46.240.135.226]) by smtp.gmail.com with ESMTPSA id y11sm5298734ejw.63.2020.06.27.12.51.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jun 2020 12:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Tps7nMTNDUkl/eAj1enISwY5nRsZq9itXUGQjMYdQXM=; b=ekDlIumK/wO3tCGoOxnefGrmZGhDlHGEgCaJgQCU+M2uX6c9XiVTTcriio43eQvTd4 zVO9HDHl/jzeYWPVA1bmOp8fuF9sYClBhGo0C2sg+70KEkMZCdhrZDEubVI2XpKWYcYe Py1YUvyYLzAhfv2DftCY+CCZw1PzB4/7BignIQvjP8AYtL8v6unfHh58TmOuv2LOeVCR sUwQprO7rK74FFVQp51VC+Fhc0WTyV//ZwROdndh6kD7olbORgcqe9vvIYSIIGNY1wk6 e+pz+aGs9eZ7bHe9vmQliARzGkEzUum1f/LPnVON2bh/TON+jZarB26gPNvG6UxrNajr YwOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Tps7nMTNDUkl/eAj1enISwY5nRsZq9itXUGQjMYdQXM=; b=s1xVFjWjRjDy9QoTRrFzV+DgjETahU5Xm24d6Bihg+lDaD7nBdBN8jfN4a//8quQFp xeTtKRaZ7Lu9kEhbbSJVCOUnA8qil1tGwENBmeCjQmcpV/6064InZkmkvXAwWoMSV2/c 9i58/ou1pKOfvc6iitT8wYgd5BRjyY+D2uE17Bvk57ABTbIon+CP6NObRSQknLD8dLBK YtjouxNVmiVmGq1mck9XZ2WabdQtBKf82JkbvWSFuOHBycgWlFw99nfTBS9kTUvacT39 M404fGVl6tm7oHPyvPJUMM4agz2pivq2rxPba4dPC7bkXcdazqXWkqLAOhNbXpHHk17W WghA== X-Gm-Message-State: AOAM531LRQVL1enUhC0fPqDyD8Jdk8Kla3/qG19PZTJD5GGx84WB8XYX i4rYTc95MVmNyOUWFJoMiv7kUs6R X-Google-Smtp-Source: ABdhPJwbyd2Dw2lk7nO7/LWjnxYvdkOrlkzgJIWrNuakUPecF66zMgbpXUPeF1u1P65OXfLK0NZeEQ== X-Received: by 2002:a05:6402:17ee:: with SMTP id t14mr6591824edy.359.1593287504913; Sat, 27 Jun 2020 12:51:44 -0700 (PDT) From: Aleksandar Markovic To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL 1/6] hw/mips: Implement the kvm_type() hook in MachineClass Date: Sat, 27 Jun 2020 21:51:38 +0200 Message-Id: <1593287503-25197-2-git-send-email-aleksandar.qemu.devel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593287503-25197-1-git-send-email-aleksandar.qemu.devel@gmail.com> References: <1593287503-25197-1-git-send-email-aleksandar.qemu.devel@gmail.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=aleksandar.qemu.devel@gmail.com; helo=mail-ed1-x52e.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aleksandar.qemu.devel@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Huacai Chen MIPS has two types of KVM: TE & VZ, and TE is the default type. Now we can't create a VZ guest in QEMU because it lacks the kvm_type() hook in MachineClass. This patch add the the kvm_type() hook to support both of the two types. [AM: Added "if defined" guards.] Reviewed-by: Aleksandar Markovic Signed-off-by: Aleksandar Markovic Signed-off-by: Huacai Chen Co-developed-by: Jiaxun Yang Message-Id: <1592995531-32600-2-git-send-email-chenhc@lemote.com> --- target/mips/kvm_mips.h | 11 +++++++++++ target/mips/kvm.c | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/target/mips/kvm_mips.h b/target/mips/kvm_mips.h index 1e40147..171d53d 100644 --- a/target/mips/kvm_mips.h +++ b/target/mips/kvm_mips.h @@ -12,6 +12,8 @@ #ifndef KVM_MIPS_H #define KVM_MIPS_H =20 +#include "cpu.h" + /** * kvm_mips_reset_vcpu: * @cpu: MIPSCPU @@ -23,4 +25,13 @@ void kvm_mips_reset_vcpu(MIPSCPU *cpu); int kvm_mips_set_interrupt(MIPSCPU *cpu, int irq, int level); int kvm_mips_set_ipi_interrupt(MIPSCPU *cpu, int irq, int level); =20 +#ifdef CONFIG_KVM +int mips_kvm_type(MachineState *machine, const char *vm_type); +#else +static inline int mips_kvm_type(MachineState *machine, const char *vm_type) +{ + return 0; +} +#endif + #endif /* KVM_MIPS_H */ diff --git a/target/mips/kvm.c b/target/mips/kvm.c index 96cfa10..72637a1 100644 --- a/target/mips/kvm.c +++ b/target/mips/kvm.c @@ -21,10 +21,12 @@ #include "qemu/main-loop.h" #include "qemu/timer.h" #include "sysemu/kvm.h" +#include "sysemu/kvm_int.h" #include "sysemu/runstate.h" #include "sysemu/cpus.h" #include "kvm_mips.h" #include "exec/memattrs.h" +#include "hw/boards.h" =20 #define DEBUG_KVM 0 =20 @@ -1270,3 +1272,27 @@ int kvm_arch_msi_data_to_gsi(uint32_t data) { abort(); } + +int mips_kvm_type(MachineState *machine, const char *vm_type) +{ +#if defined(KVM_CAP_MIPS_VZ) || defined(KVM_CAP_MIPS_TE) + int r; + KVMState *s =3D KVM_STATE(machine->accelerator); +#endif + +#if defined(KVM_CAP_MIPS_VZ) + r =3D kvm_check_extension(s, KVM_CAP_MIPS_VZ); + if (r > 0) { + return KVM_VM_MIPS_VZ; + } +#endif + +#if defined(KVM_CAP_MIPS_TE) + r =3D kvm_check_extension(s, KVM_CAP_MIPS_TE); + if (r > 0) { + return KVM_VM_MIPS_TE; + } +#endif + + return -1; +} --=20 2.7.4