From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E99C2C433E0 for ; Thu, 11 Mar 2021 14:06:56 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6579264E59 for ; Thu, 11 Mar 2021 14:06:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6579264E59 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qeFrZEgTJsfW3xoJPJEwWRF88Uw7PcgjybvCxqCcBUg=; b=RMYB6ZWheaNE7nLIgA7ZN99Wl Md1S0fdYjfIabRwrzbr+Olptt8dfGLwEvwyA+/41WJbQA/bPJwXJMR4Yhx82LydAUohpcT7O9hU5p Z5JqjntFiIpFOZ6hzvS7E7it5Sdgh04BX+CuGOL/ZpzxiwR0EaxkkZHk4z20XvACKSMnAtiHyvn+o oPEskHzoqlZToX5kI0D198p2E+PHxGy0Nz5BGe4LfD9KyWd8GX9x5tFZ3MPerVw/YY4ab9OfdDG31 zUS5TIWTFtmApdp37tzKlkq3g/BMs13wjfyV/+U+hTQtelZ8GBlzvxWLs4gVPhn/++DFZUerVwKxO 6LcY8QFQQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKLwO-009Hhf-So; Thu, 11 Mar 2021 14:05:28 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKLwK-009Hh0-49 for linux-arm-kernel@lists.infradead.org; Thu, 11 Mar 2021 14:05:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615471519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=90Q2n6m6EwL+XSKkC/k2rK0sBsGWuNAH+8zbCxifFnw=; b=GwMNmUshxtzVS6p9up5uV1v8pHFR6mw3G6w5Oq1G8ryYaCh0U4ew1VRyYvQEYlJWkf6/5e R12xUzl3bPxpvNUk74TTwg08YJ6CUpWdUswKyjmrd9zbnHE1xzq/gb2oODD9+qe+tWhtxn P7M+xKE7rhzSBMhjwFI/UXYq1C/tDhQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-245-wnMcU4zAPBad_tREVJY_tA-1; Thu, 11 Mar 2021 09:05:16 -0500 X-MC-Unique: wnMcU4zAPBad_tREVJY_tA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 16DA0800D55; Thu, 11 Mar 2021 14:05:14 +0000 (UTC) Received: from [10.36.112.254] (ovpn-112-254.ams2.redhat.com [10.36.112.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3B3B12C15A; Thu, 11 Mar 2021 14:05:11 +0000 (UTC) Subject: Re: [PATCH v3 1/2] KVM: arm64: Reject VM creation when the default IPA size is unsupported To: Marc Zyngier , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: James Morse , Julien Thierry , Suzuki K Poulose , Will Deacon , Andrew Jones , Alexandru Elisei , kernel-team@android.com, stable@vger.kernel.org References: <20210311100016.3830038-1-maz@kernel.org> <20210311100016.3830038-2-maz@kernel.org> From: Auger Eric Message-ID: Date: Thu, 11 Mar 2021 15:05:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210311100016.3830038-2-maz@kernel.org> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210311_140524_317236_3EEF8E9B X-CRM114-Status: GOOD ( 35.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Marc, On 3/11/21 11:00 AM, Marc Zyngier wrote: > KVM/arm64 has forever used a 40bit default IPA space, partially > due to its 32bit heritage (where the only choice is 40bit). > > However, there are implementations in the wild that have a *cough* > much smaller *cough* IPA space, which leads to a misprogramming of > VTCR_EL2, and a guest that is stuck on its first memory access > if userspace dares to ask for the default IPA setting (which most > VMMs do). > > Instead, blundly reject the creation of such VM, as we can't > satisfy the requirements from userspace (with a one-off warning). > Also clarify the boot warning, and document that the VM creation > will fail when an unsupported IPA size is probided. > > Although this is an ABI change, it doesn't really change much > for userspace: > > - the guest couldn't run before this change, but no error was > returned. At least userspace knows what is happening. > > - a memory slot that was accepted because it did fit the default > IPA space now doesn't even get a chance to be registered. > > The other thing that is left doing is to convince userspace to > actually use the IPA space setting instead of relying on the > antiquated default. > > Fixes: 233a7cb23531 ("kvm: arm64: Allow tuning the physical address size for VM") > Signed-off-by: Marc Zyngier > Cc: stable@vger.kernel.org Reviewed-by: Eric Auger Thanks Eric > --- > Documentation/virt/kvm/api.rst | 3 +++ > arch/arm64/kvm/reset.c | 12 ++++++++---- > 2 files changed, 11 insertions(+), 4 deletions(-) > > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst > index 1a2b5210cdbf..38e327d4b479 100644 > --- a/Documentation/virt/kvm/api.rst > +++ b/Documentation/virt/kvm/api.rst > @@ -182,6 +182,9 @@ is dependent on the CPU capability and the kernel configuration. The limit can > be retrieved using KVM_CAP_ARM_VM_IPA_SIZE of the KVM_CHECK_EXTENSION > ioctl() at run-time. > > +Creation of the VM will fail if the requested IPA size (whether it is > +implicit or explicit) is unsupported on the host. > + > Please note that configuring the IPA size does not affect the capability > exposed by the guest CPUs in ID_AA64MMFR0_EL1[PARange]. It only affects > size of the address translated by the stage2 level (guest physical to > diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c > index 47f3f035f3ea..9d3d09a89894 100644 > --- a/arch/arm64/kvm/reset.c > +++ b/arch/arm64/kvm/reset.c > @@ -324,10 +324,9 @@ int kvm_set_ipa_limit(void) > } > > kvm_ipa_limit = id_aa64mmfr0_parange_to_phys_shift(parange); > - WARN(kvm_ipa_limit < KVM_PHYS_SHIFT, > - "KVM IPA Size Limit (%d bits) is smaller than default size\n", > - kvm_ipa_limit); > - kvm_info("IPA Size Limit: %d bits\n", kvm_ipa_limit); > + kvm_info("IPA Size Limit: %d bits%s\n", kvm_ipa_limit, > + ((kvm_ipa_limit < KVM_PHYS_SHIFT) ? > + " (Reduced IPA size, limited VM/VMM compatibility)" : "")); > > return 0; > } > @@ -356,6 +355,11 @@ int kvm_arm_setup_stage2(struct kvm *kvm, unsigned long type) > return -EINVAL; > } else { > phys_shift = KVM_PHYS_SHIFT; > + if (phys_shift > kvm_ipa_limit) { > + pr_warn_once("%s using unsupported default IPA limit, upgrade your VMM\n", > + current->comm); > + return -EINVAL; > + } > } > > mmfr0 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1); > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel