Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4786068ioa; Wed, 27 Apr 2022 11:05:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjX7g65XxvVyT0NAI6zKwt8dxMM2cAxpnWQHZMOwbqVgq93ztQeRHzNnQf4QU7izmO4AcO X-Received: by 2002:a17:902:a5cc:b0:158:9a2b:480e with SMTP id t12-20020a170902a5cc00b001589a2b480emr29799996plq.19.1651082703754; Wed, 27 Apr 2022 11:05:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651082703; cv=none; d=google.com; s=arc-20160816; b=nf6BOuCjVt4gJ6ufH7EgROzkwZtiGfKcTdL96Wivw/B7kfap+xY/iQ2tNlwV4xqBJ7 0Qs26c5KSwn47rmsNmYqp9nc+GR5AanJBsEjjqGblc0aPKlHBGGkEwdkP1zO49VhHy86 X8pH8R0UlJT7oe3F/aYrZ7K7GyudjApuWDtxQrcVuelmI5hMRUMB3/yqcH5fNtGSNj09 ElE8gtkucbaF2HCffj+qVNiBiQRiKlyvG/rii4RW7QVNvut2jgzIop2P0895M7PKHZ5/ 7gl0XrxRsCs3k6cflST1sPzAgKqM21YyziARvGYeqbtV4kGkG/Rg5sXA8+4+YcGkdYq3 WQ3w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NrnrIbR3L39VOrIgvRZkUaU80AMLT3lel5AFpVPIXhk=; b=MRFwL0uKsHYtUY3W49P4mSNIMZYL2IsTUcWu0BB18G2AjxYVJRiAwfmyU8PJyfL02D hvdfBHCXBa73lVPHPcuBjJItb8+85ffwKMRzsTPMkYKGhDUf0QyaTyq6ZbNkkH4/TkCv FXHnBQ5c3G7fKq+qZCzSZrqplkKcCiqnes6queiumLT/gnYo3r3WNj/X776d9GtVvYRF bPBUOGu6xyp1/YroEseGnKipq8wl3Vc1edgQAZrl+r+fG1DaLYD2if52FPpEI5m4UZN5 kmFw9hlrwY3m7sHvg/5zrmZmhzkeDJdlU0wSV0RYoXtRYG8oNJqNhn6p9zWkUn/3fnyK VhkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KNrIcW1T; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 71-20020a17090a09cd00b001bd14e01fb8si5750612pjo.166.2022.04.27.11.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 11:05:03 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KNrIcW1T; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 47D5D5F8C0; Wed, 27 Apr 2022 10:38:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244294AbiD0RlZ (ORCPT + 99 others); Wed, 27 Apr 2022 13:41:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244136AbiD0RlO (ORCPT ); Wed, 27 Apr 2022 13:41:14 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8C56B42492 for ; Wed, 27 Apr 2022 10:38:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651081081; 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=NrnrIbR3L39VOrIgvRZkUaU80AMLT3lel5AFpVPIXhk=; b=KNrIcW1ToEAnlVb86VPqqMW5Rw05Y+rd5IEO3EXK30zcbkJ3BiMftccl7yUNZReAOt7j1q 55tAACMpaPXUa9J1K67ztnCuvKIeKx5sdpaKgOw96gqe0olYZZrXYN6kjokNCm7ykCAr3c Y78wNB0cVnNjhshY4qTMsXMdfYEH2pQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-617-YckeZTk2M4S3Fq1wKK3kTA-1; Wed, 27 Apr 2022 13:38:00 -0400 X-MC-Unique: YckeZTk2M4S3Fq1wKK3kTA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9F925802812; Wed, 27 Apr 2022 17:37:59 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 773C4407DEC3; Wed, 27 Apr 2022 17:37:59 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: mlevitsk@redhat.com, seanjc@google.com, stable@vger.kernel.org Subject: [PATCH 3/3] KVM: x86: never write to memory from kvm_vcpu_check_block Date: Wed, 27 Apr 2022 13:37:58 -0400 Message-Id: <20220427173758.517087-4-pbonzini@redhat.com> In-Reply-To: <20220427173758.517087-1-pbonzini@redhat.com> References: <20220427173758.517087-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kvm_vcpu_check_block is called while not in TASK_RUNNING, and therefore cannot sleep. Writing to guest memory is therefore forbidden, but it can happen if kvm_check_nested_events causes a vmexit. Fortunately, all events that are caught by kvm_check_nested_events are also handled by kvm_vcpu_has_events through vendor callbacks such as kvm_x86_interrupt_allowed or kvm_x86_ops.nested_ops->has_events, so remove the call. Cc: stable@vger.kernel.org Reported-by: Maxim Levitsky Signed-off-by: Paolo Bonzini --- arch/x86/kvm/x86.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index d563812ca229..90b4f50b9a84 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10341,9 +10341,6 @@ static inline int vcpu_block(struct kvm_vcpu *vcpu) static inline bool kvm_vcpu_running(struct kvm_vcpu *vcpu) { - if (is_guest_mode(vcpu)) - kvm_check_nested_events(vcpu); - return (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE && !vcpu->arch.apf.halted); } -- 2.31.1