Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2084415ybp; Thu, 10 Oct 2019 01:55:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxUZ/5m4FDitTbMrFPtfYyhkiPfB+UXdzROFeN5Eiz1+pYHsLYM60bFOthJ80m9ww0do4UE X-Received: by 2002:aa7:dd18:: with SMTP id i24mr7200065edv.239.1570697716166; Thu, 10 Oct 2019 01:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697716; cv=none; d=google.com; s=arc-20160816; b=waKoMhaiJAOd1OAsSow/awvQkYtIhgE836yNDB/qKj1Svh9bHrsCZkcD/xjQ8mMrrQ jD/eNzP/8Kii19FrE9jTwL5NGUzvHhPqoYVtmiHpWh47LpIJF/3ufcy3koLFaf0J9G8e WpXa2tXn5X0DDkB8fFkQF/QP1wdlSuvaRhiTKfj4t/RD5SNcmCBjlol38TxcD3irlDcm cXef9JZK89yk5aJPvIe6uHcnkwQXyw6ZF8L07GvzLkzyiTDIXULDGpjkKscj5Kunuq6G wkgWOvQT81e7Y6Qgim6euSaM6YuOS5oqKr160Bga8H8Cm6OjYb2Ef7vcHN0bLdcs9Ps7 gIOA== 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=2+N9jbf4Zw6JXeyHlEw4QiHEApGKPbFWeWV/mwyEWOc=; b=H5mTGv32TY+9VJkDpQpdMCbNwnsJ7wNKkhlQoXegJq45RT4b1goVGN3E+bRWx/WCfG sWmADDo+GDUDLJniGNfr8Rql81u6KMDuGgAjEgoSN7ZOBOMpHVqQgwLJD4hqjhJckr5d /6f/11F1TTgwNlB981VMzNVuXgR9+IMjNqs52mUkZhzrrTVOTDzA/GdovwSSFeWMXdOw 18e7Tk4LIa2/A/XwMRmkBOoJQj3ons4taRsaf8l++ShG/EcpDYltd1a7YcaE36S0qi53 +NHT4zuUxs5UhBSgJPEAc/8MT/XHuO7SdSgyLAFWjSV6NtmMckZ6nngSXYlRy6z6qm+I 5rpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PEzbGtVO; 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 r17si2960019edx.257.2019.10.10.01.54.52; Thu, 10 Oct 2019 01:55:16 -0700 (PDT) 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=PEzbGtVO; 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 S2390006AbfJJIuk (ORCPT + 99 others); Thu, 10 Oct 2019 04:50:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:57668 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389549AbfJJIug (ORCPT ); Thu, 10 Oct 2019 04:50:36 -0400 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 4EC8920B7C; Thu, 10 Oct 2019 08:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570697435; bh=Wdc2jXh0Tp2BmFlAzEXnnIqAvNx2KOd//LP8av2dQx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PEzbGtVOYzs2lcu7oV6RRrc3lQnoDJ0TRmqKGU5XpBmxP2yDMXVHPSL/nOize/8VH 4q3vNV43G7kAaHwPnDva1I1LADow7Ev3t6E6v5b8sTt0/Y7D6JfONbX0bcys/++Yac Axwv7iR92G90Dx3rv11oDkz/41i+XVMFAN9vzOQk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Mackerras , Alexey Kardashevskiy Subject: [PATCH 4.14 06/61] KVM: PPC: Book3S HV: Dont lose pending doorbell request on migration on P9 Date: Thu, 10 Oct 2019 10:36:31 +0200 Message-Id: <20191010083453.052152882@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083449.500442342@linuxfoundation.org> References: <20191010083449.500442342@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: Paul Mackerras commit ff42df49e75f053a8a6b4c2533100cdcc23afe69 upstream. On POWER9, when userspace reads the value of the DPDES register on a vCPU, it is possible for 0 to be returned although there is a doorbell interrupt pending for the vCPU. This can lead to a doorbell interrupt being lost across migration. If the guest kernel uses doorbell interrupts for IPIs, then it could malfunction because of the lost interrupt. This happens because a newly-generated doorbell interrupt is signalled by setting vcpu->arch.doorbell_request to 1; the DPDES value in vcpu->arch.vcore->dpdes is not updated, because it can only be updated when holding the vcpu mutex, in order to avoid races. To fix this, we OR in vcpu->arch.doorbell_request when reading the DPDES value. Cc: stable@vger.kernel.org # v4.13+ Fixes: 579006944e0d ("KVM: PPC: Book3S HV: Virtualize doorbell facility on POWER9") Signed-off-by: Paul Mackerras Tested-by: Alexey Kardashevskiy Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kvm/book3s_hv.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -1356,7 +1356,14 @@ static int kvmppc_get_one_reg_hv(struct *val = get_reg_val(id, vcpu->arch.pspb); break; case KVM_REG_PPC_DPDES: - *val = get_reg_val(id, vcpu->arch.vcore->dpdes); + /* + * On POWER9, where we are emulating msgsndp etc., + * we return 1 bit for each vcpu, which can come from + * either vcore->dpdes or doorbell_request. + * On POWER8, doorbell_request is 0. + */ + *val = get_reg_val(id, vcpu->arch.vcore->dpdes | + vcpu->arch.doorbell_request); break; case KVM_REG_PPC_VTB: *val = get_reg_val(id, vcpu->arch.vcore->vtb);