Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp964727ybn; Wed, 25 Sep 2019 10:13:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgHd+7zsW00u04zwl0CE28KKAxs5a0HaRGXlpbg1X2AwYvlajAb3BudhEg4QP90ZurpF0m X-Received: by 2002:a17:906:6994:: with SMTP id i20mr251556ejr.239.1569431607336; Wed, 25 Sep 2019 10:13:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569431607; cv=none; d=google.com; s=arc-20160816; b=ngMjuMPkFCtwSf/gsRc4lsa7Wx9465dawe1+EVuKaS0hpgKQNi0FWY4n2KqbOvrarf bXqOT9BxBJyzjA8654J7g6aUdsLKZvGnVxP0iVoNTEsyvAjUqFTeAk0TYp1Nuyx7cogK H7ccanae4D+HOV+XuGXwlblfRm1EzGwd7P5BIsZb+3phBu1Och+LF34gPrj26YA/a3AF SnF7zl5+2MHK6K+K5D/8vpmhDAX5au1LzYsPiOIwlByuHIOcinLEAT2KzpF9K2rEKc4B HnZxV5OSdCYVxfxukXQlZPVtQK5Ka4m0bAgZHbhzeDEDCdYieqPMNqRED4JAwVPNB+/w 4wRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=wHxKFWcJxwC+qrk1c8aG8YCetp2by199KIJsFbfVQ3I=; b=WIJTww31ahlUDe3Cyt2wYrgLHQgZZsU6FEygKKaSZ0mU3iX44u/kWra7ggH9OhiBkw oyBu2wlLTQYsFP9GjiZov+mq5UF3XEoi1lOpCM7JFI17woemTZScedCtXVRHK/PKTdht 9Zv1N4YEeLS3WvuGE94Nh06piUA27NCjhGZcfCLBkZCqDS/E3mnPe1ZucJv3ISQ3jQug 8JgbSq1Ty1UhQNLRwqBtwHvPW0R0Yu4vvw51ew0cTVxpQ4vDFGmPszGLy9GIV97XVjqF 8nfn6ikSQfcNDMvpvYfNlCMqn2TDp4vmEle3Qy8myNdxpZu/wvbXW1k4FIHaOXC7FLN0 79hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EcTmLIqM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gg17si57626ejb.294.2019.09.25.10.13.02; Wed, 25 Sep 2019 10:13:27 -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=EcTmLIqM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440408AbfIWSSE (ORCPT + 99 others); Mon, 23 Sep 2019 14:18:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:54826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438191AbfIWSSE (ORCPT ); Mon, 23 Sep 2019 14:18:04 -0400 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DBFDC21928 for ; Mon, 23 Sep 2019 18:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569262683; bh=KQ8YtMSUvBH+IEHZPN4F+9fUdawjUfYBpTtUWbWv5xA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=EcTmLIqMPZQJAyFQKFNsUCMcomj2YImlbE7UswNurg5uOjUS7B+ZrDdmYbbiZXoSj 7hMyu8oOOf7xnjv5MJ0jhjA717vnLvJOhZys2yHl4jCElJn2dFfYMbs+Ky4tAeStgw U3XBQmOfYiB7wqP6GXpDomgUvdOh8hhcEPuP3gEE= Received: by mail-wr1-f52.google.com with SMTP id l11so15063618wrx.5 for ; Mon, 23 Sep 2019 11:18:02 -0700 (PDT) X-Gm-Message-State: APjAAAUG/Ow9KAGX1VCKzP8FSh90f99MSf5mdP4R0FJTufpZdMt8wRsk BFRRVpPC5+zedEYKDNEBih6a6PcdJSxl5lk2Z5aIQw== X-Received: by 2002:a5d:4647:: with SMTP id j7mr578006wrs.106.1569262681278; Mon, 23 Sep 2019 11:18:01 -0700 (PDT) MIME-Version: 1.0 References: <20190919150314.054351477@linutronix.de> <20190919150809.860645841@linutronix.de> In-Reply-To: <20190919150809.860645841@linutronix.de> From: Andy Lutomirski Date: Mon, 23 Sep 2019 11:17:50 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC patch 14/15] workpending: Provide infrastructure for work before entering a guest To: Thomas Gleixner Cc: LKML , X86 ML , Peter Zijlstra , Andy Lutomirski , Catalin Marinas , Will Deacon , Mark Rutland , Marc Zyngier , Paolo Bonzini , kvm list , linux-arch 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 On Thu, Sep 19, 2019 at 8:09 AM Thomas Gleixner wrote: > > Entering a guest is similar to exiting to user space. Pending work like > handling signals, rescheduling, task work etc. needs to be handled before > that. > > Provide generic infrastructure to avoid duplication of the same handling code > all over the place. > > Update ARM64 struct kvm_vcpu_stat with a signal_exit member so the generic > code compiles. > > Signed-off-by: Thomas Gleixner > --- > arch/arm64/include/asm/kvm_host.h | 1 > include/linux/entry-common.h | 66 ++++++++++++++++++++++++++++++++++++++ > kernel/entry/common.c | 44 +++++++++++++++++++++++++ > 3 files changed, 111 insertions(+) > > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -409,6 +409,7 @@ struct kvm_vcpu_stat { > u64 wfi_exit_stat; > u64 mmio_exit_user; > u64 mmio_exit_kernel; > + u64 signal_exits; > u64 exits; > }; > > --- a/include/linux/entry-common.h > +++ b/include/linux/entry-common.h > @@ -255,4 +255,70 @@ static inline void arch_syscall_exit_tra > /* Common syscall exit function */ > void syscall_exit_to_usermode(struct pt_regs *regs, long syscall, long retval); > > +#if IS_ENABLED(CONFIG_KVM) > + > +#include > + > +#ifndef ARCH_EXIT_TO_GUESTMODE_WORK > +# define ARCH_EXIT_TO_GUESTMODE_WORK (0) > +#endif > + > +#define EXIT_TO_GUESTMODE_WORK \ > + (_TIF_NEED_RESCHED | _TIF_SIGPENDING | _TIF_NOTIFY_RESUME | \ > + ARCH_EXIT_TO_GUESTMODE_WORK) > + > +int core_exit_to_guestmode_work(struct kvm *kvm, struct kvm_vcpu *vcpu, > + unsigned long ti_work); > + > +/** > + * arch_exit_to_guestmode - Architecture specific exit to guest mode function > + * @kvm: Pointer to the guest instance > + * @vcpu: Pointer to current's VCPU data > + * @ti_work: Cached TIF flags gathered in exit_to_guestmode() > + * > + * Invoked from core_exit_to_guestmode_work(). Can be replaced by > + * architecture specific code. > + */ > +static inline int arch_exit_to_guestmode(struct kvm *kvm, struct kvm_vcpu *vcpu, > + unsigned long ti_work); Can you add a comment about whether IRQs are supposed to be off (I assume they are) and perhaps a lockdep assertion to verify it?