Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1939866ybn; Thu, 26 Sep 2019 04:39:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPwjHPeZMnxMJYn5jN06+XN8ZoA0xXkcDlHyO78dG/sNqRbrXxEosy+Ktv91pKCMMKEaaM X-Received: by 2002:a50:918d:: with SMTP id g13mr3050804eda.64.1569497966543; Thu, 26 Sep 2019 04:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569497966; cv=none; d=google.com; s=arc-20160816; b=cVHICj/3oc/GTl/7g3oiZUWx0DA7TYgA4e4JsFb17YbpRIB7gg4BmvTyIhHoIrJwc+ ta8m8DPEanVoQjTmiUxqt9X5J06El7bRuioHHAaWyZJk3RSzIrh9/WNSMfgqTMzuvbbd BhpiXFT7EpiZvxEaCPB4RaOkC9Tx82q5+j/mbyAMAtJgDrbatibZQPTz+19P6IvUxVXt hpgoqnkJIfSq6iTJOmTdhEonUvoIdVzKrBSXQklpu6mpMV6MIIgHpV6s2k+N/zvsTOXU sAvHxSxh1grSKXWk/woWpXV1yT3SJ/e+pKy4H/44xveNIu15+h0HBzB7bYqFF9iX/BcE 5eyQ== 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 :message-id:in-reply-to:subject:cc:to:from:date; bh=G7cZCv9hGgd7y2JOYibnO/6r/Wj6iry1Hs4IY2s+0IY=; b=RHyj3dTxGn3yydhsuGAzsXOp154Gb71d1fWmdxxABz048n/FglqciMP0zUU9rbk4hP 3biBjozXAXL+HE6bPA4QpnWeXD3JJ7d+zFx17b4wVDrMJJHBP897TUAzduF7VnmPTEqp ySyya1JeVrMihlAMDp23We4TV8luQbYCQ4/Gr4Qxoc982PNLsmxcWTMUI+GS5/mH620P U8JWferhjDxuElktvQLSp++CCjC0zhNjL/CXl4x48/g4F0q2VEVmOwR/tzSYZH8+uhCM mMziKDul/Jbckzum5wiRej6DnIRXhwX82mtuImZ6aS0d+K3b23Fi4A/ZRmJ+TroqBgs5 1HkA== ARC-Authentication-Results: i=1; mx.google.com; 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 w55si1164062eda.15.2019.09.26.04.39.02; Thu, 26 Sep 2019 04:39:26 -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; 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 S1726203AbfIZLfa (ORCPT + 99 others); Thu, 26 Sep 2019 07:35:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:45870 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725955AbfIZLf3 (ORCPT ); Thu, 26 Sep 2019 07:35:29 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A6B0BACD9; Thu, 26 Sep 2019 11:35:27 +0000 (UTC) Date: Thu, 26 Sep 2019 13:35:04 +0200 (CEST) From: Miroslav Benes To: Thomas Gleixner cc: LKML , x86@kernel.org, Peter Zijlstra , Andy Lutomirski , Catalin Marinas , Will Deacon , Mark Rutland , Marc Zyngier , Paolo Bonzini , kvm@vger.kernel.org, linux-arch@vger.kernel.org, live-patching@vger.kernel.org Subject: Re: [RFC patch 14/15] workpending: Provide infrastructure for work before entering a guest In-Reply-To: <20190919150809.860645841@linutronix.de> Message-ID: References: <20190919150314.054351477@linutronix.de> <20190919150809.860645841@linutronix.de> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > --- a/include/linux/entry-common.h > +++ b/include/linux/entry-common.h [...] > +#define EXIT_TO_GUESTMODE_WORK \ > + (_TIF_NEED_RESCHED | _TIF_SIGPENDING | _TIF_NOTIFY_RESUME | \ > + ARCH_EXIT_TO_GUESTMODE_WORK) [...] > --- a/kernel/entry/common.c > +++ b/kernel/entry/common.c > > +int core_exit_to_guestmode_work(struct kvm *kvm, struct kvm_vcpu *vcpu, > + unsigned long ti_work) > +{ > + /* > + * Before returning to guest mode handle all pending work > + */ > + if (ti_work & _TIF_SIGPENDING) { > + vcpu->run->exit_reason = KVM_EXIT_INTR; > + vcpu->stat.signal_exits++; > + return -EINTR; > + } > + > + if (ti_work & _TIF_NEED_RESCHED) { > + srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); > + schedule(); > + vcpu->srcu_idx = srcu_read_lock(&kvm->srcu); > + } > + > + if (ti_work & _TIF_PATCH_PENDING) { > + srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); > + klp_update_patch_state(current); > + vcpu->srcu_idx = srcu_read_lock(&kvm->srcu); > + } If I am reading the code correctly, _TIF_PATCH_PENDING is not a part of EXIT_TO_GUESTMODE_WORK, so the handling code here would not be called on any arch as of now. I also think that _TIF_PATCH_PENDING must not be handled here generally. It could break consistency guarantees when live patching KVM (and we do that from time to time). Adding live-patching ML to CC. Miroslav > + if (ti_work & _TIF_NOTIFY_RESUME) { > + srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); > + clear_thread_flag(TIF_NOTIFY_RESUME); > + tracehook_notify_resume(NULL); > + vcpu->srcu_idx = srcu_read_lock(&kvm->srcu); > + } > + > + /* Any extra architecture specific work */ > + return arch_exit_to_guestmode_work(kvm, vcpu, ti_work); > +}