Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp807421imm; Mon, 21 May 2018 14:52:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqcRmmN0OHRMuPwetoPKV+PtUEtwsxI0FkLJ3vseWDUHA0TAWs840kvkc6NxZOwqjEJ6G8a X-Received: by 2002:a65:4903:: with SMTP id p3-v6mr2075191pgs.84.1526939575537; Mon, 21 May 2018 14:52:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526939575; cv=none; d=google.com; s=arc-20160816; b=mHOFa9CS/a/BcR71A2An+jMvxjLVVokYKCXXGVRaTXpmrE3pt5islnIvVhlRFAX43A cSMA5U6XS72vtMjB29A7Nzf6pC+C82cjRa6rgcqZfZ9caH6SPn4iPnue2DXbnLLCSXKo BWyxXsBB6K5V6zsi0298yf2iMFjUbWDcoDddSJRCikaPPjpVSxTSbYY/5UWmeQlfJ5yZ QUChixOvdaScr4UrpWyaA4xh6aceGOyvFI/dq8xCTcFadWx7zvKVxu7rFxEvKmJASkhT N6vRj94zbC5EdMKWStryRZSOHXehSCQnBfDEay0nwUHqcbwU32yBgmZZH0SPzwP+SSPi jXEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=bDS+TF1/nhlp73HghaO3ZGqYo0mg2E/qPEEGu5uJl0c=; b=qrtbmKFRIVxguxsjNSg/z1aqCU6zYHXZcYXARaAr+ojxr0c4j4FxQROFFoqJ1Hnxes 7JbmGVUv4FLeXQ1FxYNBX5H1mAFDu792TZ4rGMMp9b+05K6Yi0DhZewZl1VGIcrFPtyb C7zBeUL4FER92nRohRWS6UJEd8ZoiW6QsUMESpxPfs0p4YqH377Nn+KcwL/Bgg4vsWvL cNkxkcEyClV0u+gosUTJdWAdtQKJv785ZoKouy0Ip9SARKXpiKTQDFM+sYeL5uSilZVX 0IXZWXYfIjmplYN8NpL6hMdDXceXKTAIy2anzDcye8plTtTRMlIjJrKzS/L55VQs+tV3 inig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lenLJOFe; 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 k16-v6si15566693pli.171.2018.05.21.14.52.40; Mon, 21 May 2018 14:52:55 -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=lenLJOFe; 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 S932186AbeEUVwI (ORCPT + 99 others); Mon, 21 May 2018 17:52:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:37616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754271AbeEUVWn (ORCPT ); Mon, 21 May 2018 17:22:43 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 1E97A2075C; Mon, 21 May 2018 21:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526937762; bh=B1xG94o2NTKhsvkR8GsxTphPI/3BbpAr2ug7QUfygk0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lenLJOFeiBT92WaDWJqmhB9R9kGdI3shicMVRvCBSbbMqCbX/g3AIWSf2vR9b/dbB zzXvpbmT5QGP6is6w3rwn8bDak7aELui+u+SxFaJhBedplPVEwm7QOJ6SYjPEhSDcj Ccc4AYBeyqOirXf6ew7oQrhMN7wKqdl6ZXGZK6Sk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Glauber , Andre Przywara , Christoffer Dall , Paolo Bonzini Subject: [PATCH 4.16 017/110] KVM: arm/arm64: VGIC/ITS save/restore: protect kvm_read_guest() calls Date: Mon, 21 May 2018 23:11:14 +0200 Message-Id: <20180521210505.413676620@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521210503.823249477@linuxfoundation.org> References: <20180521210503.823249477@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andre Przywara commit 711702b57cc3c50b84bd648de0f1ca0a378805be upstream. kvm_read_guest() will eventually look up in kvm_memslots(), which requires either to hold the kvm->slots_lock or to be inside a kvm->srcu critical section. In contrast to x86 and s390 we don't take the SRCU lock on every guest exit, so we have to do it individually for each kvm_read_guest() call. Use the newly introduced wrapper for that. Cc: Stable # 4.12+ Reported-by: Jan Glauber Signed-off-by: Andre Przywara Acked-by: Christoffer Dall Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- virt/kvm/arm/vgic/vgic-its.c | 4 ++-- virt/kvm/arm/vgic/vgic-v3.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -1896,7 +1896,7 @@ static int scan_its_table(struct vgic_it int next_offset; size_t byte_offset; - ret = kvm_read_guest(kvm, gpa, entry, esz); + ret = kvm_read_guest_lock(kvm, gpa, entry, esz); if (ret) return ret; @@ -2266,7 +2266,7 @@ static int vgic_its_restore_cte(struct v int ret; BUG_ON(esz > sizeof(val)); - ret = kvm_read_guest(kvm, gpa, &val, esz); + ret = kvm_read_guest_lock(kvm, gpa, &val, esz); if (ret) return ret; val = le64_to_cpu(val); --- a/virt/kvm/arm/vgic/vgic-v3.c +++ b/virt/kvm/arm/vgic/vgic-v3.c @@ -329,7 +329,7 @@ retry: bit_nr = irq->intid % BITS_PER_BYTE; ptr = pendbase + byte_offset; - ret = kvm_read_guest(kvm, ptr, &val, 1); + ret = kvm_read_guest_lock(kvm, ptr, &val, 1); if (ret) return ret; @@ -382,7 +382,7 @@ int vgic_v3_save_pending_tables(struct k ptr = pendbase + byte_offset; if (byte_offset != last_byte_offset) { - ret = kvm_read_guest(kvm, ptr, &val, 1); + ret = kvm_read_guest_lock(kvm, ptr, &val, 1); if (ret) return ret; last_byte_offset = byte_offset;