Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp7137006pxv; Fri, 30 Jul 2021 10:54:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8fbpIjUUlvbF2k231kOb7wJnEHXAnurPsGOEJ6MbmpW/G/lP021u2+BiTciLQWnKAcKW4 X-Received: by 2002:a17:906:f1c4:: with SMTP id gx4mr3718105ejb.410.1627667661689; Fri, 30 Jul 2021 10:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627667661; cv=none; d=google.com; s=arc-20160816; b=H6YwMu0tSVZ8isJVo6Chk+Kv8KAjN1sBLwGBiF521/mlbUEpzqHJsSLQtxpOzJl/5Q gmOGGLg4oMP1+rAL3eKgh3u8AJ1PPqPc0k0sIM0T3yw5uuLR6edecMJ7j6bDTeM3aYbe Jpm35nE5qfvwZ5Rtbxlk0NE99O6AdsSUlUnIj0TZs6+Vb0REZCxJhF6kBFDRVgITgpAV zgFhWoEmFj5rie8mZ8bPiCFntZt+h1sbD95EzNZXtIKp7hozwFqJMkAZqcAA5v7+xAdu hS3iDJXLO4VJokyc1rhpywnK7Da4NRhpE01qGrdvUNdF8N7jD+SlGR3rJBMSXJ7nNTOr oNqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=w74FCyABGqlKztmmT/szhNY9h5zAocpT2ax3CC8sfng=; b=Gi56+vziJyii5Ztwx/cT+EjHnaxTnrMGBtFLQMgx19xruLOWR4K0YERWjbNM8OnUHl flTf2b2pHOTpBw+bTP1JB6qw/Ntn50bnipAAOz0er2l3l8Y/6YIjk7XVsVYDlArbuMDl 6DS/IfrAnvZijZTQGs3gBzev0+gzjMWB6f8HUfc1wsosYPCtJfm4x6eoNU03eOyUE422 OxSw/FHr4qAEkUjXa2+bXoZ5Ka8Fq7JGeUJ3mKTXyAKzWWrTG9Y8JzcHRAk2FzfqwZO4 K1Aqk23TOd4wlTR9S1YGRRBo0TKS3VydF0WpdFd6xxV11vZkjf9ZwI4/vlJ7E0F1vnEn R4Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DMrMZW03; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gg11si2425211ejb.41.2021.07.30.10.53.57; Fri, 30 Jul 2021 10:54:21 -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=@google.com header.s=20161025 header.b=DMrMZW03; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230229AbhG3Rwg (ORCPT + 99 others); Fri, 30 Jul 2021 13:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbhG3Rwf (ORCPT ); Fri, 30 Jul 2021 13:52:35 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EBF6C0613C1 for ; Fri, 30 Jul 2021 10:52:30 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id u3so19438656lff.9 for ; Fri, 30 Jul 2021 10:52:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w74FCyABGqlKztmmT/szhNY9h5zAocpT2ax3CC8sfng=; b=DMrMZW03lBg/IWAb0IutYWMvCcEgS9xE5oJAt+jb+XBSyYmWnF1bbfCrZjz7dswIwD 3v09mJ2EWLLHzJdjDf1awDYZg7EXnIFc+cImRm3dt9ORzBzqc6NkD+G5XTaI0Zcen3XU 4cCh5vSyAZ7M/7ch8OPmEQSoGVBqGVkmlSuoAz2i+3aMHhE16KOplP7P7310dJvFMc7r 473AiUM6s5r/ikkrJBXsLg/dLLccX9P/NPC+CEdOheJvLrqF2WWEkzYeBpo55NGME49y 5MFHPpccGBKyttRw8SZHiN1GNbFcg1Rwcwr0J/jQi6dJrksfxK2UQM3qkKKIKTimvKSi 4mKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=w74FCyABGqlKztmmT/szhNY9h5zAocpT2ax3CC8sfng=; b=fcQEQiQ1RDj8zzlowbBz2ubqq7eew6rh5L2oHVm09gKcf7V+w82m4NoGQpMOsb9Exz wRIl+qCNoIiC+K95XWQya0M6pdcH4RJzYMLm6VwmD25Y8tS4f4v9EzAJby0qTswI3e2P iz/MaH2dVpm46wu06NVH8OmftuXKCWCZ6odMoL9TeL+z/0GyNUrjr5xkrq50pJR+c9wZ bJfvhYKX1BIEwsqttX5EP+ttXps17igyPSOpzyKWujCp4kfm0CA4MEyb5OEoEiw+8FVF qScSVrQ8Ntu6oWtFArjXGk6kUwKG9RuPljO90MFADvtVyslUcKe9ZpC+QjYmzvjWKokz BeRw== X-Gm-Message-State: AOAM5308icvBNh63Nnbff4j3gehDfvNo5eTpC3FKdYroYbxm6Xlfip6S CPAh8S2VTOk9KFPi1TkFYJHzHVkfsJj7Ewzk49J59/DBuSDCKQ== X-Received: by 2002:a05:6512:3d26:: with SMTP id d38mr2541587lfv.411.1627667548598; Fri, 30 Jul 2021 10:52:28 -0700 (PDT) MIME-Version: 1.0 References: <20210729220916.1672875-1-oupton@google.com> <20210729220916.1672875-4-oupton@google.com> <878s1o2l6j.wl-maz@kernel.org> In-Reply-To: From: Oliver Upton Date: Fri, 30 Jul 2021 10:52:17 -0700 Message-ID: Subject: Re: [PATCH v2 3/3] KVM: arm64: Use generic KVM xfer to guest work function To: Sean Christopherson Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Thomas Gleixner , Peter Zijlstra , Andy Lutomirski , linux-arm-kernel@lists.infradead.org, Peter Shier , Shakeel Butt , Guangyu Shi Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 30, 2021 at 9:56 AM Sean Christopherson wrote: > > On Fri, Jul 30, 2021, Oliver Upton wrote: > > > > On Fri, Jul 30, 2021 at 2:41 AM Marc Zyngier wrote: > > > > > > On Thu, 29 Jul 2021 23:09:16 +0100, Oliver Upton wrote: > > > > @@ -714,6 +715,13 @@ static bool vcpu_mode_is_bad_32bit(struct kvm_vcpu *vcpu) > > > > static_branch_unlikely(&arm64_mismatched_32bit_el0); > > > > } > > > > > > > > +static bool kvm_vcpu_exit_request(struct kvm_vcpu *vcpu) > > > > +{ > > > > + return kvm_request_pending(vcpu) || > > > > + need_new_vmid_gen(&vcpu->arch.hw_mmu->vmid) || > > > > + xfer_to_guest_mode_work_pending(); > > > > > > Here's what xfer_to_guest_mode_work_pending() says: > > > > > > > > > * Has to be invoked with interrupts disabled before the transition to > > > * guest mode. > > > > > > > > > At the point where you call this, we already are in guest mode, at > > > least in the KVM sense. > > > > I believe the comment is suggestive of guest mode in the hardware > > sense, not KVM's vcpu->mode designation. I got this from > > arch/x86/kvm/x86.c:vcpu_enter_guest() to infer the author's > > intentions. > > Yeah, the comment is referring to hardware guest mode. The intent is to verify > there is no work to be done before making the expensive world switch. There's > no meaningful interaction with vcpu->mode, on x86 it's simply more convenient > from a code perspective to throw it into kvm_vcpu_exit_request(). Yep, the same is true for ARM as well, doing it the way it appears in this patch allows for the recycling of the block to enable irqs and preemption. -- Thanks, Oliver