From patchwork Tue Mar 8 03:08:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 593816 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3F1FE140783 for ; Tue, 8 Mar 2016 14:26:59 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b=S5yzjTTl; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id CD8841A0D99 for ; Tue, 8 Mar 2016 14:26:58 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b=S5yzjTTl; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [103.22.144.67]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id E40151A011D for ; Tue, 8 Mar 2016 14:09:10 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b=S5yzjTTl; dkim-atps=neutral Received: by ozlabs.org (Postfix, from userid 1007) id 96B2A140C12; Tue, 8 Mar 2016 14:09:08 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1457406550; bh=63Hq5jCPB1uEq7yZ0GwELYcx6DJ/ftYlZQYActbtAGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S5yzjTTlRrxARaRNWdBxIUmCVSKzbOaiiKRrjamGnHWuvASs857hzdaX70F7lruOi FSYiW1E1UgnZPxbe4E0lwteGY65cTYf+WpmM4i5ykrBdc6pCKsZUmRFdTg0lzP2osC zmsLiuvuKVMq+ycagA8vn+nJWFxsP8ARhEnHnm8c= From: David Gibson To: paulus@samba.org, aik@ozlabs.ru, benh@kernel.crashing.org Subject: [RFCv2 10/25] powerpc/kvm: Add capability flag for hashed page table resizing Date: Tue, 8 Mar 2016 14:08:47 +1100 Message-Id: <1457406542-6210-11-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457406542-6210-1-git-send-email-david@gibson.dropbear.id.au> References: <1457406542-6210-1-git-send-email-david@gibson.dropbear.id.au> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , linuxppc-dev@lists.ozlabs.org, bharata@linux.vnet.ibm.com MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This adds a new powerpc-specific KVM_CAP_SPAPR_RESIZE_HPT capability to advertise whether KVM is capable of handling the PAPR extensions for resizing the hashed page table during guest runtime. At present, HPT resizing is possible with KVM PR without kernel modification, since the HPT is managed within qemu. It's not possible yet with KVM HV, because the HPT is managed by KVM. At present, qemu has to use other capabilities which (by accident) reveal whether PR or HV is in use to know if it can advertise HPT resizing capability to the guest. To avoid ambiguity with existing kernels, the encoding is a bit odd. 0 means "unknown" since that's what previous kernels will return 1 means "HPT resize possible if available if and only if the HPT is allocated in userspace, rather than in the kernel". In practice this is the same test as userspace already uses, but this makes it explicit. 2 will mean "HPT resize available and implemented in-kernel" For now we always return 1, but the intention is to return 2 once HPT resize is implemented for KVM HV. Signed-off-by: David Gibson --- arch/powerpc/kvm/powerpc.c | 3 +++ include/uapi/linux/kvm.h | 1 + 2 files changed, 4 insertions(+) diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 2f21ab7..a4250f1 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -572,6 +572,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) case KVM_CAP_PPC_GET_SMMU_INFO: r = 1; break; + case KVM_CAP_SPAPR_RESIZE_HPT: + r = 1; /* resize allowed only if HPT is outside kernel */ + break; #endif default: r = 0; diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 9da9051..7e7e0e3 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -850,6 +850,7 @@ struct kvm_ppc_smmu_info { #define KVM_CAP_IOEVENTFD_ANY_LENGTH 122 #define KVM_CAP_HYPERV_SYNIC 123 #define KVM_CAP_S390_RI 124 +#define KVM_CAP_SPAPR_RESIZE_HPT 125 #ifdef KVM_CAP_IRQ_ROUTING