From nobody Wed May 15 19:29:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539238839416973.0038312886377; Wed, 10 Oct 2018 23:20:39 -0700 (PDT) Received: from localhost ([::1]:60749 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAUKs-0005M2-BC for importer@patchew.org; Thu, 11 Oct 2018 02:20:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAUGy-0002ve-PD for qemu-devel@nongnu.org; Thu, 11 Oct 2018 02:16:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAUGw-00066a-7A for qemu-devel@nongnu.org; Thu, 11 Oct 2018 02:16:36 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:44248) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gAUGu-00063x-Mf; Thu, 11 Oct 2018 02:16:32 -0400 Received: by mail-pg1-x544.google.com with SMTP id g2-v6so3643708pgu.11; Wed, 10 Oct 2018 23:16:24 -0700 (PDT) Received: from localhost.home.majoof.com ([221.121.149.195]) by smtp.gmail.com with ESMTPSA id q24-v6sm35836189pfi.165.2018.10.10.23.16.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Oct 2018 23:16:23 -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=rjlJv/I/lhfoAMKN0s87GePK5gOl2z7exI7yGmmAO9g=; b=SDuFe8PfsmN1NxP3QvW7mT2xCzFsF+o7Yn+xOl+OudHGbb1H6ChQ7dwmxCX2YcIbZm 7htPzyAZREnreCz7WzyFhygI60Lg93k9RsQYveZYBs+EeEipcyU/tZbLt9F7RjlNjgKx Wek6nzZjmDAA2c/tAVkwYEqO4ZMKZInXc5BOgtYcHGvyvw2h6RsX6CHeTzNlfiX9wF7d EDaw3Tsux2I/Qic1mNQ3KNdPBDlbjl0eMij3eETBaaUtEwNq6NpfaexRabTWHk4mLYD9 wAiv9EtSpQ/CW7sPFuL3aNGE75yTNg2khTUfIWjeCwDWo7WOj6I0WqNumBuu6Ld58Sc7 iZUA== 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=rjlJv/I/lhfoAMKN0s87GePK5gOl2z7exI7yGmmAO9g=; b=dVU8aCvvucwJN3BaQoNkGZTZR9jL7ER5+4ZQf4jXN/u2iBAbr8xjd4We3YtpfeQADk CwytLefuUeKM7IDCw4hiJkpzPc6ic4AiyUP1ZRnfLyRdyhWMKzKjx8VCcmiVRmtH+SdJ q++kCrfRX1o3FbMnoSMQqcnz2Hed839SgxJVfOqfk9uYIaYbZuT8OQAF5nh3oK61zHR/ SIeRfbJyvsJ3K4SbjdpoRVPLe05/ku3unCatvCodI010lL9cyT6xzyWLf+nBw6BbAD4S /iJRWdd6Mj3ld/q2N3V73ds3Lr+x/I0fCPZzI3phHrbhlzVdU1Rv2WqJbqW708meBxfC dQXg== X-Gm-Message-State: ABuFfojpeUUpZjde6AaBPDyCI2NCax4I/yXUe/TJs/7TVUK9KRhkFt0H c0SmLtyHM5V3Px+jXDQ7jC+WH7zS X-Google-Smtp-Source: ACcGV624GyJyOQBHglSlrVxAaEr1bxoR6sWkAopbe6PAHmYUYVr9PJeDjEd8QSIWyUDKythu6K0wcA== X-Received: by 2002:a63:700e:: with SMTP id l14-v6mr201501pgc.359.1539238583703; Wed, 10 Oct 2018 23:16:23 -0700 (PDT) From: Suraj Jitindar Singh To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Date: Thu, 11 Oct 2018 17:16:07 +1100 Message-Id: <20181011061609.11423-2-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20181011061609.11423-1-sjitindarsingh@gmail.com> References: <20181011061609.11423-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::544 Subject: [Qemu-devel] [QEMU-PPC] [PATCH V3 1/3] target/ppc: Update linux-headers for v4.19-rc7 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, Suraj Jitindar Singh , david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Suraj Jitindar Singh --- linux-headers/asm-powerpc/kvm.h | 1 + linux-headers/linux/kvm.h | 1 + 2 files changed, 2 insertions(+) diff --git a/linux-headers/asm-powerpc/kvm.h b/linux-headers/asm-powerpc/kv= m.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 { =20 #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) =20 /* Transactional Memory checkpointed state: * This is all GPRs, all VSX regs and a subset of SPRs 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 =20 #ifdef KVM_CAP_IRQ_ROUTING =20 --=20 2.13.6 From nobody Wed May 15 19:29:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539238723350101.47570021152308; Wed, 10 Oct 2018 23:18:43 -0700 (PDT) Received: from localhost ([::1]:60734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAUIu-0003wE-L7 for importer@patchew.org; Thu, 11 Oct 2018 02:18:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAUGy-0002vc-P1 for qemu-devel@nongnu.org; Thu, 11 Oct 2018 02:16:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAUGw-00066q-K4 for qemu-devel@nongnu.org; Thu, 11 Oct 2018 02:16:36 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:40916) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gAUGw-00064g-8A; Thu, 11 Oct 2018 02:16:34 -0400 Received: by mail-pf1-x443.google.com with SMTP id s5-v6so3850678pfj.7; Wed, 10 Oct 2018 23:16:27 -0700 (PDT) Received: from localhost.home.majoof.com ([221.121.149.195]) by smtp.gmail.com with ESMTPSA id q24-v6sm35836189pfi.165.2018.10.10.23.16.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Oct 2018 23:16:26 -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=8DvEWBr3raUmeMqztewRolsc0gaRb6C8z/Qj+BYp3wg=; b=JLbunTSdu6scFKIOAEVNp0XNhAY0eYlarpHdmIIPKHxi4M/Hz0u2zdZawufmnmf5/3 OTJWCAMgqO6JQHP/n/kHTN9uDGAWbEv1zxIFbqSsY7FTGOeyG8AfYFfjIau2VdzL9ptA /JAXdJQuhRLhELOQo84WucdCvOHW/FWnoWkZcY/+9X3A/2s3R9QVdlSbbHC5iwMGNtFJ psj+qEXgjsLOxl/GqQF7Uw6fJ3Nsw9NTKag5M6wbnVK8Q1FJQgsiiEByZkMGAGllwCst 2DtmeGvNR+tl/ojieB/7dswCDl73ZC1Q0iGp/fMRhMoenSVgGffl0Lmzw6XIfkuXiFRx aHyQ== 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=8DvEWBr3raUmeMqztewRolsc0gaRb6C8z/Qj+BYp3wg=; b=FIJDNjUL8h5HY5KC6zSfoZqOVmkuPkHtwqp0tFg6N9IEGzjNYXjAUONUpMzjEM671I wKW8BI8c7lvygXoZh2JYz5OHATR+0NDjje1sOgABjcVErxya+smy4AcG8VCBynnA1I38 +UBW80u98XLssnJjI+oIOqz9Dp7nksPecQAxjFli/sfPNmtwBidqsFG0MNMypqc/gX/h hrR2oeuZJoTT4rXkspGxWoptdQ3+OQX1y6TmRj0PmdLry6HLwnkzS+10ly/M1XSIxIWH KvpoMhzdBXZAisrcQ7DI+iyOAd8L8Qfrzb2OnrXZXZ4K1v+93Zw5PGW5wYRg2pb1A0s8 i7kg== X-Gm-Message-State: ABuFfojuDeDFWPAwmPxm9fK1Ll21xAM3+1R6mYUTPZoCohpT8qJD67dc qpR6WOE4diOl2QoIYMAUn6ssh96C X-Google-Smtp-Source: ACcGV63j9+XUAuBGm3VjE0m/H9ueyDgmzL1ngxRm/xfjuypqIWhal9JcBxTseLrmrar2gQ9fMZzbxQ== X-Received: by 2002:a63:fd58:: with SMTP id m24-v6mr250760pgj.132.1539238586765; Wed, 10 Oct 2018 23:16:26 -0700 (PDT) From: Suraj Jitindar Singh To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Date: Thu, 11 Oct 2018 17:16:08 +1100 Message-Id: <20181011061609.11423-3-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20181011061609.11423-1-sjitindarsingh@gmail.com> References: <20181011061609.11423-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] [PATCH V3 2/3] 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, Suraj Jitindar Singh , david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: David Gibson --- target/ppc/translate_init.inc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.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 } =20 --=20 2.13.6 From nobody Wed May 15 19:29:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539238725949744.1761933930808; Wed, 10 Oct 2018 23:18:45 -0700 (PDT) Received: from localhost ([::1]:60735 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAUIv-0003wh-QL for importer@patchew.org; Thu, 11 Oct 2018 02:18:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAUGy-0002vd-P5 for qemu-devel@nongnu.org; Thu, 11 Oct 2018 02:16:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAUGw-00066k-JJ for qemu-devel@nongnu.org; Thu, 11 Oct 2018 02:16:36 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:34899) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gAUGw-00065H-7S; Thu, 11 Oct 2018 02:16:34 -0400 Received: by mail-pg1-x543.google.com with SMTP id v133-v6so3660937pgb.2; Wed, 10 Oct 2018 23:16:30 -0700 (PDT) Received: from localhost.home.majoof.com ([221.121.149.195]) by smtp.gmail.com with ESMTPSA id q24-v6sm35836189pfi.165.2018.10.10.23.16.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Oct 2018 23:16:29 -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=zAcMBaR13bnEToxIF3PDKofu9NhQQs+D/b8OCFPF+YA=; b=Iy80hmKP8pmYcgNkmvkuUfkMzqKDuDaH5oarohtDYZr5MO6jc6YAUrhQjf020XcPV1 YnYu/8Aq8hpsh2hBRJPog73hXAMtwIxlzZqpHPsgtL+4cUk0DQlDlA1czm7PBOAXcvUv d2Wgz2ayFd6V0rfm9BYy9aiELnwp4D3nxuMF3xwTNflS3zreHRMExJHgawwpjXp4sbZH qAXIr5QA/QNF2v2r0UDrPBWXzDrBTpyZJb1T/bH+dcsmTFDXtzf/DEP+ppYgBi2vKcMH H+3dYyvOwvrruY6ffNytBh4PUOPBti/d7Dig1MNCL9aCmkvZGOAYiBmNp1jfZ5yp4eQ3 aINg== 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=zAcMBaR13bnEToxIF3PDKofu9NhQQs+D/b8OCFPF+YA=; b=Z55A6SklFx9ClANoeRxdIOPHjquNPZJUvO/c1csnJarc0dbjRxYTcPu3r+Ud75aJm2 qU09FsiEdreIR7VaGTFASyCiqWILOXLQ+MKAR3VT7A8BhB5N+EKYjQF+1KEphFKpuJoT bm0SL07Cppi6va5AksCjZSWGSFbW9to7k/eD53Fag+VVhtglxhse9eJ6DjqVPJrEj7fe 0FyRgL376x6jG4dUG7epXuFs4bRXGjdHET0zhQ7Asu1MsLOSnkJajoVbxRoFZjemJ1Bf 7aaX62mCzWwEafxI32rgQYzcp5liA10Mkw3gdM+UdF3A6DlMmgsGHe2kTTHz1pewqNwv vZmQ== X-Gm-Message-State: ABuFfoj0ZDWDgo7kRw09nDToZEdi8RPM9j73wp6FtSIuqNuazrPgbnok sh1iWhIK+gDQu7sQU3UbQVRzAah1 X-Google-Smtp-Source: ACcGV63JQ5i3KAw2rr1UNSwF/lkJJiAEAfMqdIGPZJKu+R3EFhDzQa2CDqywdKlX2hNnStMRXIaSPA== X-Received: by 2002:a62:3995:: with SMTP id u21-v6mr268390pfj.116.1539238589778; Wed, 10 Oct 2018 23:16:29 -0700 (PDT) From: Suraj Jitindar Singh To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Date: Thu, 11 Oct 2018 17:16:09 +1100 Message-Id: <20181011061609.11423-4-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20181011061609.11423-1-sjitindarsingh@gmail.com> References: <20181011061609.11423-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::543 Subject: [Qemu-devel] [QEMU-PPC] [PATCH V3 3/3] 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, Suraj Jitindar Singh , david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=3Dtrue or disabled with: -machine pseries,cap-nested-hv=3Dfalse Signed-off-by: Suraj Jitindar Singh --- hw/ppc/spapr.c | 2 ++ hw/ppc/spapr_caps.c | 32 ++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 5 ++++- target/ppc/kvm.c | 12 ++++++++++++ target/ppc/kvm_ppc.h | 12 ++++++++++++ 5 files changed, 62 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 =3D { &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] =3D SPAPR_CAP_BROKEN; smc->default_caps.caps[SPAPR_CAP_IBS] =3D SPAPR_CAP_BROKEN; smc->default_caps.caps[SPAPR_CAP_HPT_MAXPAGESIZE] =3D 16; /* 64kiB */ + smc->default_caps.caps[SPAPR_CAP_NESTED_KVM_HV] =3D SPAPR_CAP_OFF; spapr_caps_add_properties(smc, &error_abort); smc->irq =3D &spapr_irq_xics; } diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index aa605cea91..8e1d791c63 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -368,6 +368,28 @@ static void cap_hpt_maxpagesize_cpu_apply(sPAPRMachine= State *spapr, ppc_hash64_filter_pagesizes(cpu, spapr_pagesize_cb, &maxshift); } =20 +static void cap_nested_kvm_hv_apply(sPAPRMachineState *spapr, + uint8_t val, Error **errp) +{ + if (!val) { + /* capability disabled by default */ + return; + } + + if (tcg_enabled()) { + error_setg(errp, + "No Nested KVM-HV support in tcg, try cap-nested-hv=3Do= ff"); + } else if (kvm_enabled()) { + if (!kvmppc_has_cap_nested_kvm_hv()) { + error_setg(errp, +"KVM implementation does not support Nested KVM-HV, try cap-nested-hv=3Dof= f"); + } else if (kvmppc_enable_nested_kvm_hv() < 0) { + error_setg(errp, +"Error enabling cap-nested-hv with KVM, try cap-nested-hv=3Doff"); + } + } +} + sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] =3D { [SPAPR_CAP_HTM] =3D { .name =3D "htm", @@ -437,6 +459,15 @@ sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = =3D { .apply =3D cap_hpt_maxpagesize_apply, .cpu_apply =3D cap_hpt_maxpagesize_cpu_apply, }, + [SPAPR_CAP_NESTED_KVM_HV] =3D { + .name =3D "nested-hv", + .description =3D "Allow Nested KVM-HV", + .index =3D SPAPR_CAP_NESTED_KVM_HV, + .get =3D spapr_cap_get_bool, + .set =3D spapr_cap_set_bool, + .type =3D "bool", + .apply =3D cap_nested_kvm_hv_apply, + }, }; =20 static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, @@ -564,6 +595,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); =20 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) =20 /* * 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; =20 static inline uint8_t spapr_get_cap(sPAPRMachineState *spapr, int cap) { diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 30aeafa7de..8849180548 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; =20 static uint32_t debug_inst_opcode; =20 @@ -150,6 +151,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_mmu_hash_v3 =3D kvm_vm_check_extension(s, KVM_CAP_PPC_MMU_HASH_V3); cap_resize_hpt =3D kvm_vm_check_extension(s, KVM_CAP_SPAPR_RESIZE_HPT); kvmppc_get_cpu_characteristics(s); + cap_ppc_nested_kvm_hv =3D 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; } =20 +bool kvmppc_has_cap_nested_kvm_hv(void) +{ + return !!cap_ppc_nested_kvm_hv; +} + +int kvmppc_enable_nested_kvm_hv(void) +{ + return kvm_vm_enable_cap(kvm_state, KVM_CAP_PPC_NESTED_HV, 0); +} + 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..797271114e 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_enable_nested_kvm_hv(void); 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; } =20 +static inline bool kvmppc_has_cap_nested_kvm_hv(void) +{ + return false; +} + +static inline int kvmppc_enable_nested_kvm_hv(void) +{ + return -1; +} + static inline int kvmppc_enable_hwrng(void) { return -1; --=20 2.13.6