Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4166934pxv; Mon, 19 Jul 2021 19:04:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaPyCJh/5dNwwSu3N60qU+7Bz5e4R1R6ft6qMypKhKohy5W/Cgi3B/ZNc0BVqlccwe3+Wt X-Received: by 2002:a5d:8c9a:: with SMTP id g26mr21207809ion.121.1626746651787; Mon, 19 Jul 2021 19:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626746651; cv=none; d=google.com; s=arc-20160816; b=jaz30TauvVLqG+FpH8WtZNtOUVbVS+SZoy+LaVfgA2x+OSdo5+GrkUjzjgQWVwVfO+ olEGOx09U5Devwav5aZwLLdzGu9Vu90q3RKwQNQZ8WBa+5ii4l1tykm5GrR7OkFO8+ua wHTqmCBhUOtYLL5hwjs0doR5Y+rIvwbf+RpHVDiwNUTsXx6vZ5B6Qhw7zKrC7ZhDgEXy ZBkK+YS2tlbyi/PFR6MnO0ECMHJnLMBYuS91yRW23eexvYCYzVewaWervKGV8pCwIX4v G17nfKU2ui3B2iTe109jg+xGGmtMMenknGKKIa8kuydvX6uO0pB+yrLyBy5wBNHtDpq2 LQMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=iwY647XqSBr0nhop6u+nJOZDJO2ojgmzAbMlPyzAP2A=; b=0WeUPWZnEFd41oVTb1ow9/CGo6oN9b+Z5frcgdyL4qx4PFYMMJcHvUf9UBotvKgXAy EnNRfHlu6fXdicAYAgpQ9yg0oM74cL4w0kB+0SMiVQskiYku8yywPZAQxGT+N/aMkIpY oIALDBpXsYtz6//Vw8X4v8GJKW+3NqnGvH7jkb693he4/AYRhrEHucI9kNwMSMrhsjuL eeHZqNMk6M248v0fHcD3o785ybGk69KuFAAgXHMrWuXdm2bjX3a2lrzRQ180nlxnJ07r 0mINw48eJQO50GS6br1PG6O2wgmvUqlEs96TgmumhgsatUHjVAb7kyajs6xntz4nylLj Ka4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=de4dSCIF; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si17524640ilu.69.2021.07.19.19.04.00; Mon, 19 Jul 2021 19:04:11 -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=@linaro.org header.s=google header.b=de4dSCIF; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242088AbhGSRoA (ORCPT + 99 others); Mon, 19 Jul 2021 13:44:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378937AbhGSR0d (ORCPT ); Mon, 19 Jul 2021 13:26:33 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 996D4C05BD3C for ; Mon, 19 Jul 2021 10:46:39 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id w14so25139898edc.8 for ; Mon, 19 Jul 2021 11:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=iwY647XqSBr0nhop6u+nJOZDJO2ojgmzAbMlPyzAP2A=; b=de4dSCIFeNoXczBGIJKhs+9cQ67ihAH384iDNj7/ghw8A521i45BAOlb9Wj5VrML2B ts5bNRNWddT+aI1DLJIMor+SL4/f3zNwEtrLVZsD2tjcjsRkzEr1TRxdDN0DwJUJ6pq2 vSViocJn6F9z759rRSS8/3I8kikyFNECOd2Jum/ADid6KfFaxXYT7kzrn3v/uD/drMMG QmB7VB6/FnvNvlUQU1yQ7RgVec5cXCMQW4i7ue70iiKVBvUrwW3xqoF7vRTo45xa+TQV ER89LXFuY7yD0DDbzZMfbrV5Of00o5bIHTQbJFYMZNcVBnBX+yL0g9CKq1SafiocuodB XvpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=iwY647XqSBr0nhop6u+nJOZDJO2ojgmzAbMlPyzAP2A=; b=M9+UpOSZ8MJpRbinHhXcoEcArPSrdglGCknd4JZHY7l7o3XnTSOWA8U0XGVmb/Nm5g xsQ0oFlD5D4HruDMaao1vgGhuiQYjI6N7p2W8Ii9/atfOKH4crQg/mHOFSLcehchL/M2 ia4S67CSX7COZmK1OarZyEecSZwht99vAkL+V0IHk6Y85K2d7NzcZM57OrU0ezPy16Ig pX4RmjLV9rMe9vbJOLUPnaiTW6TiZwwwP2+dCtk2gwR0VqfalWa+7nS47y2zyVmAk/H5 /kF3movUvswMlfGwbS9Se3XY0+dZ6i1NOtaM1r1/O6dbaSwNWxPJi27om1nek3JHIkLl 45Zw== X-Gm-Message-State: AOAM530el5mtwvX8/KG+QQYcUq7Act8zZKA9un30SVuH0JpPFLqMG+Se Ef7oB6i3NZiTSXMuEGsrg/sXJw== X-Received: by 2002:a05:6402:1592:: with SMTP id c18mr35924631edv.243.1626717749925; Mon, 19 Jul 2021 11:02:29 -0700 (PDT) Received: from myrica (adsl-84-226-111-173.adslplus.ch. [84.226.111.173]) by smtp.gmail.com with ESMTPSA id n14sm8178314edo.23.2021.07.19.11.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 11:02:29 -0700 (PDT) Date: Mon, 19 Jul 2021 20:02:06 +0200 From: Jean-Philippe Brucker To: Alexandru Elisei Cc: maz@kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, pbonzini@redhat.com, corbet@lwn.net, james.morse@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, lorenzo.pieralisi@arm.com, salil.mehta@huawei.com, shameerali.kolothum.thodi@huawei.com, jonathan.cameron@huawei.com Subject: Re: [RFC PATCH 0/5] KVM: arm64: Pass PSCI to userspace Message-ID: References: <20210608154805.216869-1-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alex, I'm not planning to resend this work at the moment, because it looks like vcpu hot-add will go a different way so I don't have a user. But I'll probably address the feedback so far and park it on some branch, in case anyone else needs it. On Mon, Jul 19, 2021 at 04:29:18PM +0100, Alexandru Elisei wrote: > 1. Why forwarding PSCI calls to userspace depend on enabling forwarding for other > HVC calls? As I understand from the patches, those handle distinct function IDs. The HVC cap from patch 4 enables returning from the VCPU_RUN ioctl with KVM_EXIT_HYPERCALL, for any HVC not handled by KVM. This one should definitely be improved, either by letting userspace choose the ranges of HVC it wants, or at least by reporting ranges reserved by KVM to userspace. The PSCI cap from patch 5 disables the in-kernel PSCI implementation. As a result those HVCs are forwarded to userspace. It was suggested that other users will want to handle HVC calls (SDEI for example [1]), hence splitting into two capabilities rather than just the PSCI cap. In v5.14 x86 added KVM_CAP_EXIT_HYPERCALL [2], which lets userspace receive specific hypercalls. We could reuse that and have PSCI be one bit of that capability's parameter. [1] https://lore.kernel.org/linux-arm-kernel/20170808164616.25949-12-james.morse@arm.com/ [2] https://lore.kernel.org/kvm/90778988e1ee01926ff9cac447aacb745f954c8c.1623174621.git.ashish.kalra@amd.com/ > 2. HVC call forwarding to userspace also forwards PSCI functions which are defined > in ARM DEN 0022D, but not (yet) implemented by KVM. What happens if KVM's PSCI > implementation gets support for one of those functions? How does userspace know > that now it also needs to enable PSCI call forwarding to be able to handle that > function? We forward the whole PSCI function range, so it's either KVM or userspace. If KVM manages PSCI and the guest calls an unimplemented function, that returns directly to the guest without going to userspace. The concern is valid for any other range, though. If userspace enables the HVC cap it receives function calls that at some point KVM might need to handle itself. So we need some negotiation between user and KVM about the specific HVC ranges that userspace can and will handle. > It looks to me like the boundary between the functions that are forwarded when HVC > call forwarding is enabled and the functions that are forwarded when PSCI call > forwarding is enabled is based on what Linux v5.13 handles. Have you considered > choosing this boundary based on something less arbitrary, like the function types > specified in ARM DEN 0028C, table 2-1? For PSCI I've used the range 0-0x1f as the boundary, which is reserved for PSCI by SMCCC (table 6-4 in that document). > > In my opinion, setting the MP state to HALTED looks like a sensible approach to > implementing PSCI_SUSPEND. I'll take a closer look at the patches after I get a > better understanding about what is going on. > > On 6/8/21 4:48 PM, Jean-Philippe Brucker wrote: > > Allow userspace to request handling PSCI calls from guests. Our goal is > > to enable a vCPU hot-add solution for Arm where the VMM presents > > possible resources to the guest at boot, and controls which vCPUs can be > > brought up by allowing or denying PSCI CPU_ON calls. Passing HVC and > > PSCI to userspace has been discussed on the list in the context of vCPU > > hot-add [1,2] but it can also be useful for implementing other SMCCC and > > vendor hypercalls [3,4,5]. > > > > Patches 1-3 allow userspace to request WFI to be executed in KVM. That > > I don't understand this. KVM, in kvm_vcpu_block(), does not execute an WFI. > PSCI_SUSPEND is documented as being indistinguishable from an WFI from the guest's > point of view, but it's implementation is not architecturally defined. Yes that was an oversimplification on my part Thanks, Jean