Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4370250pxj; Tue, 8 Jun 2021 12:37:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7v9IueQnukJUmKnAxKrZ+Wxyi8BUYwmo+6M1Id94i11f/O3zkQ/wPbDgCf0Ydr35gxW/M X-Received: by 2002:a17:906:2f91:: with SMTP id w17mr25518487eji.443.1623181071334; Tue, 08 Jun 2021 12:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623181071; cv=none; d=google.com; s=arc-20160816; b=Iarl5omvnapaD5CjAkpxA4ZaBSKqqLe5liNOvBCs2EE5M3A+NBfZcTSVFq6KqSpSWD 6RdpU4Ei9m5UiAGLWvRUCekUZoYWpuLYFl1JJqDR03pukThipK3WY9QaN4PF7Zqtj/35 LZ/A1PKpjKbUzgnp0YK8IxYCV1mt6kfycBT5QMl3XQQ5OEh0ZyGrDjjjMfXDCYvhkYCr cvid3N++d7cCQH7jsg0pTizxH1W23J8SmXvG+BAf1DZYr13zv3fBVk9bGchyQgazfFPT CEgO+ZKZ2++xGWVYkmj+8DKt4Rnd85Fdc9qpp9JFtFND58T3MHDcSjBTc8U+TI80RCtC lqkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pT6WWs6unfY9hIpZXBt0HryJ+TaB6OiO/ceqEklqg5I=; b=MdUHzQEYxaVDZvk+d7eD+VVh0yiKVCvo/OWZVHZoTNXR7IMvuMKatAgVuqZ++Ew9gI 4K1OkX46royDp0QeIWYRMkEpPhqGNMJVXhYU8rCmBCZQ1pgpO+OouJB2cq9fpyubC+hy VM4chSxNwccqxUh8DKFJ5dkj9K73UapXfcitDfjeP7De85Tq6FakjR5QhvEC4nVaRpQq BAlqZ2meDsslFH5XZ37blyIxtIzPYvlyaY9WpXVxrsxTB4uOkJNxOnwaz7IFunnIhfg7 bz0rdVXN+7SFD4WBPWIK4sk04AyYBgXgRvJR3PQIdMACXfSKeb8u+0J2AHTpZI387riN A48A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sRZh3X13; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q18si574450edi.368.2021.06.08.12.37.28; Tue, 08 Jun 2021 12:37:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sRZh3X13; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239296AbhFHTfN (ORCPT + 99 others); Tue, 8 Jun 2021 15:35:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:40970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238799AbhFHTUF (ORCPT ); Tue, 8 Jun 2021 15:20:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0B41D61477; Tue, 8 Jun 2021 18:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623178348; bh=aEDxG6h29ivDTypq5aoukTCRXsGpyc6ZjU+N2yJn6Wk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sRZh3X13O175tBWps/jDGyeZgsgswnrSh6QR6LB4AMadXRdq6rbo1uiONywe0MjI8 OmS05qcJ9JCSYQYJW9u+i6XKyDqqQAGgvXPgnLxIxUiboUGU3SoMmK+O3nFVq+qtF1 D7wQGcv7bVTfZVZaLO94bROhSNFiWfNDs9Gkg9d8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zenghui Yu , Marc Zyngier Subject: [PATCH 5.12 155/161] KVM: arm64: Resolve all pending PC updates before immediate exit Date: Tue, 8 Jun 2021 20:28:05 +0200 Message-Id: <20210608175950.700983250@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175945.476074951@linuxfoundation.org> References: <20210608175945.476074951@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zenghui Yu commit e3e880bb1518eb10a4b4bb4344ed614d6856f190 upstream. Commit 26778aaa134a ("KVM: arm64: Commit pending PC adjustemnts before returning to userspace") fixed the PC updating issue by forcing an explicit synchronisation of the exception state on vcpu exit to userspace. However, we forgot to take into account the case where immediate_exit is set by userspace and KVM_RUN will exit immediately. Fix it by resolving all pending PC updates before returning to userspace. Since __kvm_adjust_pc() relies on a loaded vcpu context, I moved the immediate_exit checking right after vcpu_load(). We will get some overhead if immediate_exit is true (which should hopefully be rare). Fixes: 26778aaa134a ("KVM: arm64: Commit pending PC adjustemnts before returning to userspace") Signed-off-by: Zenghui Yu Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20210526141831.1662-1-yuzenghui@huawei.com Cc: stable@vger.kernel.org # 5.11 [yuz: stable-5.12.y backport] Signed-off-by: Zenghui Yu Reviewed-by: Marc Zyngier Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/arm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -715,11 +715,13 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_v return ret; } - if (run->immediate_exit) - return -EINTR; - vcpu_load(vcpu); + if (run->immediate_exit) { + ret = -EINTR; + goto out; + } + kvm_sigset_activate(vcpu); ret = 1; @@ -892,6 +894,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_v kvm_sigset_deactivate(vcpu); +out: /* * In the unlikely event that we are returning to userspace * with pending exceptions or PC adjustment, commit these