From patchwork Thu Sep 27 06:50:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 10617315 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CC8714BD for ; Thu, 27 Sep 2018 06:51:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EA532AFD3 for ; Thu, 27 Sep 2018 06:51:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02AF52B03F; Thu, 27 Sep 2018 06:51:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A0AD82AFD4 for ; Thu, 27 Sep 2018 06:51:36 +0000 (UTC) Received: from localhost ([::1]:33993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Q9A-0007I2-0U for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Sep 2018 02:51:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Q81-0006Pk-27 for qemu-devel@nongnu.org; Thu, 27 Sep 2018 02:50:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Q80-0007KW-AU for qemu-devel@nongnu.org; Thu, 27 Sep 2018 02:50:24 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:37671) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Q80-0007K9-4C; Thu, 27 Sep 2018 02:50:24 -0400 Received: by mail-pf1-x441.google.com with SMTP id x26-v6so1175503pfn.4; Wed, 26 Sep 2018 23:50:24 -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=kcTuBNpogtj/a4qjZ/jT3yyOjdVaDjQqOrcRP5ONbSU=; b=I1We6phhFEpAnHT1X7U252UYIV1ju0XZFs8EFVmyNd2eD4ogrxalrgCbdPMJytY4yw PXVky0kDMLvwA92QIv4NugaYB34rRsZHN0vET568zMwcrpeRe3mbr3Q6FQEAuT8Z/D/1 Y4uQuGYMrPl0HS283qpxhc5bWrZ+Qx75AA4HZZj0NPQHYJ3e1zVoBfYhf5wCNLQfc3l7 yyt0pTxumzAFxa5J1C2XwbGKZubOZJZgDNhEtA+OdpWw8rU0tjlyKhOJASpsLyLmLm33 wpvmZUSRTIqB3TRt3lncVAxK8l3ZANe1/7L4RRsQflO9bm9NTcA9+mCw+5RlwmWEiZDS SDAg== 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=kcTuBNpogtj/a4qjZ/jT3yyOjdVaDjQqOrcRP5ONbSU=; b=TgWUePTI1aEg4mp0Vy6+cwcluScK6c8/HzYNPsXLty9MtinzZNCYds+4vNHxqejRt3 7kU36lniKZvCePEuTfXktQntID1y/8tZbeki53AhQCiti7Cm//xrCfpV+wXFsIb59Ty3 U8A48d18fpvTxomnI4NorxoS84mjAwS0zV0pjGDY7xUFuS7US7j5H2PtopE5zJ3PvGIE 7kpcj5MaARbqZ/t3m8133Mrlot87ABuizwgOHf8BLYYkDsMpjoC8znbBAR+vq424P4tI 2yU0dpuwZ0HD9WgHMEeWcZNBBFaH963LCcnPqfze9rZUpBybeQR0hPjQtKJ5ZHcOXIOi h8Mw== X-Gm-Message-State: ABuFfoilkVz/2QEcSobQspiEPl56bIzVCiVmxx/PVnnjedZRc8CBdNi8 YU2kpsbAZj+Of+AMaUa6N9Q= X-Google-Smtp-Source: ACcGV60g/MFJNboWFr+VOgg5ZDi0qA+U2/myfH4uBTHvpcBPAP8yOGnsipkhhoj2jkL4gVfrlz+nLA== X-Received: by 2002:a17:902:bcc3:: with SMTP id o3-v6mr9505568pls.202.1538031023244; Wed, 26 Sep 2018 23:50:23 -0700 (PDT) Received: from surajjs2.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id d18-v6sm1412561pfk.163.2018.09.26.23.50.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 23:50:22 -0700 (PDT) From: Suraj Jitindar Singh To: david@gibson.dropbear.id.au Date: Thu, 27 Sep 2018 16:50:08 +1000 Message-Id: <20180927065009.32154-2-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180927065009.32154-1-sjitindarsingh@gmail.com> References: <20180927065009.32154-1-sjitindarsingh@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [QEMU-PPC] [RFC 1/2] target/ppc: Add one reg id for ptcr X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: paulus@ozlabs.org, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, sjitindarsingh@gmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The ptcr (partition table control register) is used to store the address and size of the partition table. For nested kvm-hv we have a level 1 guest register the location of it's partition table with the hypervisor. Thus to support migration we need to be able to read this out of kvm and restore it post migration. Add the one reg id for the ptcr. Signed-off-by: Suraj Jitindar Singh --- linux-headers/asm-powerpc/kvm.h | 1 + target/ppc/translate_init.inc.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/linux-headers/asm-powerpc/kvm.h b/linux-headers/asm-powerpc/kvm.h index 1b32b56a03..8c876c166e 100644 --- a/linux-headers/asm-powerpc/kvm.h +++ b/linux-headers/asm-powerpc/kvm.h @@ -634,6 +634,7 @@ struct kvm_ppc_cpu_char { #define KVM_REG_PPC_DEC_EXPIRY (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbe) #define KVM_REG_PPC_ONLINE (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xbf) +#define KVM_REG_PPC_PTCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc0) /* Transactional Memory checkpointed state: * This is all GPRs, all VSX regs and a subset of SPRs diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c index 263e63cb03..487196800b 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -8197,11 +8197,11 @@ static void gen_spr_power9_mmu(CPUPPCState *env) { #if !defined(CONFIG_USER_ONLY) /* Partition Table Control */ - spr_register_hv(env, SPR_PTCR, "PTCR", - SPR_NOACCESS, SPR_NOACCESS, - SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_ptcr, - 0x00000000); + spr_register_kvm_hv(env, SPR_PTCR, "PTCR", + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, SPR_NOACCESS, + &spr_read_generic, &spr_write_ptcr, + KVM_REG_PPC_PTCR, 0x00000000); #endif } From patchwork Thu Sep 27 06:50:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 10617317 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63B98174A for ; Thu, 27 Sep 2018 06:53:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51B512AFF9 for ; Thu, 27 Sep 2018 06:53:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 439962B003; Thu, 27 Sep 2018 06:53:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A08CC2AFF9 for ; Thu, 27 Sep 2018 06:53:04 +0000 (UTC) Received: from localhost ([::1]:33997 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5QAa-0008A0-1f for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Sep 2018 02:53:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Q84-0006U6-KV for qemu-devel@nongnu.org; Thu, 27 Sep 2018 02:50:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Q83-0007M8-Hk for qemu-devel@nongnu.org; Thu, 27 Sep 2018 02:50:28 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:38790) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Q83-0007Lm-8Q; Thu, 27 Sep 2018 02:50:27 -0400 Received: by mail-pf1-x443.google.com with SMTP id x17-v6so1172357pfh.5; Wed, 26 Sep 2018 23:50:27 -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=62kCVV83Vv8L3BKAYS1yi9rr88vUq0dfZM7yq4BVEeE=; b=FlBRiXf++iNsscBALeWJ23jVgzLA44Wf+OzANHmjEZ3wJyXB03NdtcZ6owSYAGPQAK eAFDRnRtE2G0oK476RLTYLKa/ayLPHHSvq17kmJ6Dwpo3/xYHWbgBcGt3K/GN2l/iIqE 9QzgUR90sNI7jreYqgDaRbX8uLIZbl3NLQ1IxVP8xa8/Y+CAAVo9laQS6aQUPFM1tldn wbhA+daH/Er1exVV1n1J+fRWInTnewPF3/mIGGXX9XOgh9Z5a0fGyhwByuJrsIfHWe8g VTqZGP8S4OOlNR9c9wqpQ4k0J1hECE5MMmQslTaMCR5Qa+eo5rBTO03qeLejRIS5a5DL SpCA== 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=62kCVV83Vv8L3BKAYS1yi9rr88vUq0dfZM7yq4BVEeE=; b=LRXfBIpt0NayEheCJ5jDYGqSVDFseA2/1UsNhUbSc/L0b1OnNayNU+qsVjjcKr8Lri 1J9CNnww8aMTUiWNBRnIBqJJfMKFo8vQrN+fOvGfQyltUWf1g4Xg0d5lOYks3dq6Gwov nfDzY74l5cCykkFMYesJMmKpOOqUpuYiRIbIqw15AH5Gs65LNrL14oowkZX6/yiClKP/ 8C7catAdiXN1SyA0jsnYigGJpc7HtWwqx9O7STPk8F4Zj5bw/JXlUpy661jAxIEg/927 zrL6kLeNmSKyEkAhe7hT671vfV7bRadCtWhVRhvr4xNl4qMvl4j8WYHNGdyXrx0/+khK i+hA== X-Gm-Message-State: ABuFfoiTFV76FVZkvTombAfF54jAPIa7IDjM0c0r1iErBEbmbJ9AX2jk TfCz+DHY2SEy1VmT97OK2WU= X-Google-Smtp-Source: ACcGV620VDWUdO1zipWPlQTOHa9FrdSUa8DQA2uUvXrZXNvZIDlntIPWLOyrWr2pEVwNTkLJKA2aPQ== X-Received: by 2002:a17:902:8f93:: with SMTP id z19-v6mr9239847plo.263.1538031026336; Wed, 26 Sep 2018 23:50:26 -0700 (PDT) Received: from surajjs2.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id d18-v6sm1412561pfk.163.2018.09.26.23.50.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 23:50:25 -0700 (PDT) From: Suraj Jitindar Singh To: david@gibson.dropbear.id.au Date: Thu, 27 Sep 2018 16:50:09 +1000 Message-Id: <20180927065009.32154-3-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180927065009.32154-1-sjitindarsingh@gmail.com> References: <20180927065009.32154-1-sjitindarsingh@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [QEMU-PPC] [RFC 2/2] ppc/spapr_caps: Add SPAPR_CAP_NESTED_KVM_HV X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: paulus@ozlabs.org, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, sjitindarsingh@gmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add the spapr cap SPAPR_CAP_NESTED_KVM_HV to be used to control the availability of nested kvm-hv to the level 1 (L1) guest. Assuming a hypervisor with support enabled an L1 guest can be allowed to use the kvm-hv module (and thus run it's own kvm-hv guests) by setting: -machine pseries,cap-nested-hv=true or disabled with: -machine pseries,cap-netsed-hv=false Signed-off-by: Suraj Jitindar Singh --- hw/ppc/spapr.c | 2 ++ hw/ppc/spapr_caps.c | 29 +++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 5 ++++- linux-headers/linux/kvm.h | 1 + target/ppc/kvm.c | 12 ++++++++++++ target/ppc/kvm_ppc.h | 12 ++++++++++++ 6 files changed, 60 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 98868d893a..8ce97900e9 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1915,6 +1915,7 @@ static const VMStateDescription vmstate_spapr = { &vmstate_spapr_cap_sbbc, &vmstate_spapr_cap_ibs, &vmstate_spapr_irq_map, + &vmstate_spapr_cap_nested_kvm_hv, NULL } }; @@ -3886,6 +3887,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) smc->default_caps.caps[SPAPR_CAP_SBBC] = SPAPR_CAP_BROKEN; smc->default_caps.caps[SPAPR_CAP_IBS] = SPAPR_CAP_BROKEN; smc->default_caps.caps[SPAPR_CAP_HPT_MAXPAGESIZE] = 16; /* 64kiB */ + smc->default_caps.caps[SPAPR_CAP_NESTED_KVM_HV] = SPAPR_CAP_OFF; spapr_caps_add_properties(smc, &error_abort); smc->irq = &spapr_irq_xics; } diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index aa605cea91..e0bdec76be 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -368,6 +368,25 @@ static void cap_hpt_maxpagesize_cpu_apply(sPAPRMachineState *spapr, ppc_hash64_filter_pagesizes(cpu, spapr_pagesize_cb, &maxshift); } +static void cap_nested_kvm_hv_apply(sPAPRMachineState *spapr, + uint8_t val, Error **errp) +{ + if (val && tcg_enabled()) { + error_setg(errp, +"No Nested KVM-HV support in tcg, try cap-nested-hv=off"); + } else if (kvm_enabled()) { + if (kvmppc_has_cap_nested_kvm_hv()) { + if (kvmppc_set_cap_nested_kvm_hv(val) < 0) { + error_setg(errp, +"KVM implementation does not support selected cap-nested-hv value"); + } + } else if (val) { + error_setg(errp, +"KVM implementation does not support Nested KVM-HV, try cap-nested-hv=off"); + } + } +} + sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = { [SPAPR_CAP_HTM] = { .name = "htm", @@ -437,6 +456,15 @@ sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = { .apply = cap_hpt_maxpagesize_apply, .cpu_apply = cap_hpt_maxpagesize_cpu_apply, }, + [SPAPR_CAP_NESTED_KVM_HV] = { + .name = "nested-hv", + .description = "Allow Nested KVM-HV", + .index = SPAPR_CAP_NESTED_KVM_HV, + .get = spapr_cap_get_bool, + .set = spapr_cap_set_bool, + .type = "bool", + .apply = cap_nested_kvm_hv_apply, + }, }; static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, @@ -564,6 +592,7 @@ SPAPR_CAP_MIG_STATE(dfp, SPAPR_CAP_DFP); SPAPR_CAP_MIG_STATE(cfpc, SPAPR_CAP_CFPC); SPAPR_CAP_MIG_STATE(sbbc, SPAPR_CAP_SBBC); SPAPR_CAP_MIG_STATE(ibs, SPAPR_CAP_IBS); +SPAPR_CAP_MIG_STATE(nested_kvm_hv, SPAPR_CAP_NESTED_KVM_HV); void spapr_caps_init(sPAPRMachineState *spapr) { diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index ad4d7cfd97..bced85dd92 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -70,8 +70,10 @@ typedef enum { #define SPAPR_CAP_IBS 0x05 /* HPT Maximum Page Size (encoded as a shift) */ #define SPAPR_CAP_HPT_MAXPAGESIZE 0x06 +/* Nested KVM-HV */ +#define SPAPR_CAP_NESTED_KVM_HV 0x07 /* Num Caps */ -#define SPAPR_CAP_NUM (SPAPR_CAP_HPT_MAXPAGESIZE + 1) +#define SPAPR_CAP_NUM (SPAPR_CAP_NESTED_KVM_HV + 1) /* * Capability Values @@ -793,6 +795,7 @@ extern const VMStateDescription vmstate_spapr_cap_dfp; extern const VMStateDescription vmstate_spapr_cap_cfpc; extern const VMStateDescription vmstate_spapr_cap_sbbc; extern const VMStateDescription vmstate_spapr_cap_ibs; +extern const VMStateDescription vmstate_spapr_cap_nested_kvm_hv; static inline uint8_t spapr_get_cap(sPAPRMachineState *spapr, int cap) { diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 66790724f1..d49767ad25 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -951,6 +951,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_HYPERV_TLBFLUSH 155 #define KVM_CAP_S390_HPAGE_1M 156 #define KVM_CAP_NESTED_STATE 157 +#define KVM_CAP_PPC_NESTED_HV 160 #ifdef KVM_CAP_IRQ_ROUTING diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 30aeafa7de..f81327d6cd 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -91,6 +91,7 @@ static int cap_ppc_pvr_compat; static int cap_ppc_safe_cache; static int cap_ppc_safe_bounds_check; static int cap_ppc_safe_indirect_branch; +static int cap_ppc_nested_kvm_hv; static uint32_t debug_inst_opcode; @@ -150,6 +151,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_mmu_hash_v3 = kvm_vm_check_extension(s, KVM_CAP_PPC_MMU_HASH_V3); cap_resize_hpt = kvm_vm_check_extension(s, KVM_CAP_SPAPR_RESIZE_HPT); kvmppc_get_cpu_characteristics(s); + cap_ppc_nested_kvm_hv = kvm_vm_check_extension(s, KVM_CAP_PPC_NESTED_HV); /* * Note: setting it to false because there is not such capability * in KVM at this moment. @@ -2422,6 +2424,16 @@ int kvmppc_get_cap_safe_indirect_branch(void) return cap_ppc_safe_indirect_branch; } +bool kvmppc_has_cap_nested_kvm_hv(void) +{ + return !!cap_ppc_nested_kvm_hv; +} + +int kvmppc_set_cap_nested_kvm_hv(int enable) +{ + return kvm_vm_enable_cap(kvm_state, KVM_CAP_PPC_NESTED_HV, 0, enable); +} + bool kvmppc_has_cap_spapr_vfio(void) { return cap_spapr_vfio; diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index f696c6e498..bdfaa4e70a 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -62,6 +62,8 @@ bool kvmppc_has_cap_mmu_hash_v3(void); int kvmppc_get_cap_safe_cache(void); int kvmppc_get_cap_safe_bounds_check(void); int kvmppc_get_cap_safe_indirect_branch(void); +bool kvmppc_has_cap_nested_kvm_hv(void); +int kvmppc_set_cap_nested_kvm_hv(int enable); int kvmppc_enable_hwrng(void); int kvmppc_put_books_sregs(PowerPCCPU *cpu); PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void); @@ -320,6 +322,16 @@ static inline int kvmppc_get_cap_safe_indirect_branch(void) return 0; } +static inline bool kvmppc_has_cap_nested_kvm_hv(void) +{ + return false; +} + +static inline int kvmppc_set_cap_nested_kvm_hv(int enable) +{ + return -1; +} + static inline int kvmppc_enable_hwrng(void) { return -1;