Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp817088ybl; Wed, 11 Dec 2019 07:58:52 -0800 (PST) X-Google-Smtp-Source: APXvYqxKYPRChMQpgi97xkDeuLfSkvWyFyZXcQCJjhvkBdvQEAX03jw5MRonmVQgTHURGuQ7cwLM X-Received: by 2002:a9d:6396:: with SMTP id w22mr2846619otk.364.1576079932414; Wed, 11 Dec 2019 07:58:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576079932; cv=none; d=google.com; s=arc-20160816; b=NgRH3dZ2+hoT5p1+Y9YfbHQPbAGInhdKZm/BfjUkKgWQlr0VhFQtrPvlPLZfbDDiE0 QUnkfgbeL9AeiYQs9rBeWQj2Dc77BVm9649G3LLLg1LqPhy3OGyP1WAI0co+cfZwNQkw i7yy1p+uM7roQ+Yy3s7lMukp0Pk8BUdahRztU27ust0PJnl4ZXK6RY4n20xF349WI0mn Wn3TgyRs6nyfzgvRjGMhFCuiB2QH/kdC+litKwK0j6K9OgatsLFLAHunwGDBI/Kbc6BF UnONlr9E4PFW8266m0wOT/7sglUzhLIlFj9CzoVfh+W8HvJFNbFQBK5Tcv8lxjQGq2f/ c1aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+obvFITCbm3Fc3eKbpbx8tX9L1JUnk8KpQt1le7Gt1o=; b=OcqUlZ1ook/J0F3obvRNbOdoK0KvyX5th9+v9jec2xuhSqrFKzIrj1b3lfIEFBEPVb iy5jIgSi82M5VhbUcMAlFp1dcp0rGGpb62qqjYgp2oCaRkyj9TuENUangTnqbXa+S3ob I6KO29AM3zQ28WVXlu8xIrEWcdONscTi5juqc85Ky9mlyQoR8e6CIcV+a+hsbztBD3LZ 3FyqaJhzjgXJjn58pUGDrxe+udVa3TYXHw8PGyZ9dH6V9fedYbh5L2wP4QUZ/ZY2vSY9 7yh4jyXKN5UQWi+C4d8t96J9blBHHhwbSxtt7EO2NtLpWut4PNDtk/1tYV/T9VZezV7q nvmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=huQjXJan; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1si1461718oic.225.2019.12.11.07.58.39; Wed, 11 Dec 2019 07:58:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=huQjXJan; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731773AbfLKPPY (ORCPT + 99 others); Wed, 11 Dec 2019 10:15:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:39832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731626AbfLKPOZ (ORCPT ); Wed, 11 Dec 2019 10:14:25 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CC5D824654; Wed, 11 Dec 2019 15:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077265; bh=gmWCkjQVPPfidX2Tuqq9EuA+KCH/LpIU+IvlQpr4yBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=huQjXJani21glAf/+jTdyd383AJFaC6ooZgfQMpnO46XSBUFMg79D01qmctvo61dA 73d+5abiwmaeVe0FsbvQ36Uspt3I6qICV+X2ZWZtM7ZB77r7kDuLFXpojGX3i47wWY Z4DaJ0A+E+OBPWGTMgjGgoQJ8HJyziiv9pnJ9WMk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Greg Kurz , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paul Mackerras Subject: [PATCH 5.3 078/105] KVM: PPC: Book3S HV: XIVE: Set kvm->arch.xive when VPs are allocated Date: Wed, 11 Dec 2019 16:06:07 +0100 Message-Id: <20191211150257.148152491@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150221.153659747@linuxfoundation.org> References: <20191211150221.153659747@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kurz commit e7d71c943040c23f2fd042033d319f56e84f845b upstream. If we cannot allocate the XIVE VPs in OPAL, the creation of a XIVE or XICS-on-XIVE device is aborted as expected, but we leave kvm->arch.xive set forever since the release method isn't called in this case. Any subsequent tentative to create a XIVE or XICS-on-XIVE for this VM will thus always fail (DoS). This is a problem for QEMU since it destroys and re-creates these devices when the VM is reset: the VM would be restricted to using the much slower emulated XIVE or XICS forever. As an alternative to adding rollback, do not assign kvm->arch.xive before making sure the XIVE VPs are allocated in OPAL. Cc: stable@vger.kernel.org # v5.2 Fixes: 5422e95103cf ("KVM: PPC: Book3S HV: XIVE: Replace the 'destroy' method by a 'release' method") Signed-off-by: Greg Kurz Reviewed-by: Cédric Le Goater Signed-off-by: Paul Mackerras Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kvm/book3s_xive.c | 11 +++++------ arch/powerpc/kvm/book3s_xive_native.c | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) --- a/arch/powerpc/kvm/book3s_xive.c +++ b/arch/powerpc/kvm/book3s_xive.c @@ -2005,6 +2005,10 @@ static int kvmppc_xive_create(struct kvm pr_devel("Creating xive for partition\n"); + /* Already there ? */ + if (kvm->arch.xive) + return -EEXIST; + xive = kvmppc_xive_get_device(kvm, type); if (!xive) return -ENOMEM; @@ -2014,12 +2018,6 @@ static int kvmppc_xive_create(struct kvm xive->kvm = kvm; mutex_init(&xive->lock); - /* Already there ? */ - if (kvm->arch.xive) - ret = -EEXIST; - else - kvm->arch.xive = xive; - /* We use the default queue size set by the host */ xive->q_order = xive_native_default_eq_shift(); if (xive->q_order < PAGE_SHIFT) @@ -2039,6 +2037,7 @@ static int kvmppc_xive_create(struct kvm if (ret) return ret; + kvm->arch.xive = xive; return 0; } --- a/arch/powerpc/kvm/book3s_xive_native.c +++ b/arch/powerpc/kvm/book3s_xive_native.c @@ -1095,7 +1095,6 @@ static int kvmppc_xive_native_create(str dev->private = xive; xive->dev = dev; xive->kvm = kvm; - kvm->arch.xive = xive; mutex_init(&xive->mapping_lock); mutex_init(&xive->lock); @@ -1116,6 +1115,7 @@ static int kvmppc_xive_native_create(str if (ret) return ret; + kvm->arch.xive = xive; return 0; }