From patchwork Tue Jun 8 15:48:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12307279 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECB17C47082 for ; Tue, 8 Jun 2021 15:57:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B45B160FEA for ; Tue, 8 Jun 2021 15:57:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B45B160FEA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ExMTcuC2eExa91nHIyekwxx45G3vSHgRpsKeqsUx3iI=; b=V9uIAABtXdtetc Pdq5gWPaao0EuEpWQxki6SCyBfr6xg3lI9r4Ig/9m28tJHI/tyNInjf8sEgpKnCmDNGMCHy/Umqis yWBADguvk3QFwtpvtazwEaCwEikfS/OSH+wlKSW5gLpEF3Z+FbEU+1Mkn3kf9RRQ3TzWyg7V+PH9b 7sindDW6hueRFoe7opWgqnJmNJjg2QhypDTdEbDX4RA34sp5coP6JDXe/+P7Is49K/lu6rKH02xzn xDzKDCl7rrmCG4xm2wQgicb/taWbdh4RKKr7C3Y5O+RnAXZbjb6Dpr/Y+knCZ3yXQy48U+j6t6+JM dQuRYghkL51SVCckTGhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqe4M-009OOs-3k; Tue, 08 Jun 2021 15:55:12 +0000 Received: from mail-wm1-f51.google.com ([209.85.128.51]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqe4E-009OMI-Ge for linux-arm-kernel@lists.infradead.org; Tue, 08 Jun 2021 15:55:04 +0000 Received: by mail-wm1-f51.google.com with SMTP id h11-20020a05600c350bb02901b59c28e8b4so1821883wmq.1 for ; Tue, 08 Jun 2021 08:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=C1jCjSpZgNu1sKbBk9Z8ZrCdwYEpbza43XiihxyO/yE=; b=YVCJA0HAF6zcoQljEQXQ/+8Srt82oR65IyobeNyeO5y/m18Qqi4RIsm9oHDlODF9lS zu431MizjTDk9b2k3KaWWZoMvurqIXeQ0yR7fLtsexQHacAro307b4uZxXhKi/IArmsq wTVrqQD/MbY5QxGYp0Fut2zcaGFZ7CSTo02UvhWH+/ycUqxdTXL5VV1Hu78y+peQagbJ R5JulGFyoqhJYf09regXQGYwJev0/OSPbKIWBlJ3anSzPJ8SKdvGWB/qkgJeyXmF6LBt iNWz/38JdJLNRutIJ+qJE6hcE6aTVlRun55KTHvLG8pyT1add9uAtshT44k/Yt635hEU 9q8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=C1jCjSpZgNu1sKbBk9Z8ZrCdwYEpbza43XiihxyO/yE=; b=GsIh5si4d2+jSOQKx7egyU5cyFHAOjTiVG/0oEzAlx1xOq8z/KHyr28E+Xhe6b0u7m V6mKeUGSnh5I9eXt0khkc6Qvdnss6KbZT9NT/2jUnIg5G6T0FShUCiQ9zPwUb784kD40 0Y0frQGgbM28DP/uH3wTxJ1Q7Y4BLDiGeTHraHbbmV3llmnAq8pRLeqs7k2RGh6m96j8 yLSDIcYTI5a2LWXaGbUD0ESqnOIAm12CUJaF7wfzrzGxwWa/cj2yvG0NKu1mVWp9Root wRcxfBXbu08e4spbQUaH5YapLH+nX+jRqMOCR0cse6/EdP+RAOS55Ri93nW961Kq1n76 DmPw== X-Gm-Message-State: AOAM530Z9z4BwdtNn+cSPbvgwjnDmArmwc1kaM0T9NO4aFQn9UQnGNqt UqGAWxyzOGU+BX9yoYqfNJXywQ== X-Google-Smtp-Source: ABdhPJzTKoQW6pZDrNtOKklfr6CHm5YnfNTU7QG7RonorQflw6aGjQRnHqaXJN0uACO8uwvZsD+KAw== X-Received: by 2002:a1c:cc17:: with SMTP id h23mr22321567wmb.129.1623167640560; Tue, 08 Jun 2021 08:54:00 -0700 (PDT) Received: from localhost.localdomain (adsl-84-226-111-173.adslplus.ch. [84.226.111.173]) by smtp.gmail.com with ESMTPSA id l31sm3314180wms.16.2021.06.08.08.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 08:53:59 -0700 (PDT) From: Jean-Philippe Brucker To: maz@kernel.org Cc: 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, alexandru.elisei@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, Jean-Philippe Brucker Subject: [RFC PATCH 0/5] KVM: arm64: Pass PSCI to userspace Date: Tue, 8 Jun 2021 17:48:01 +0200 Message-Id: <20210608154805.216869-1-jean-philippe@linaro.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_085502_580375_14119E0B X-CRM114-Status: GOOD ( 12.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 way the VMM can easily implement the PSCI CPU_SUSPEND function, which is mandatory from PSCI v0.2 onwards (even if it doesn't have a more useful implementation than WFI, natively available to the guest). Patch 4 lets userspace request any HVC that isn't handled by KVM, and patch 5 lets userspace request PSCI calls, disabling in-kernel PSCI handling. I'm focusing on the PSCI bits, but a complete prototype of vCPU hot-add for arm64 on Linux and QEMU, most of it from Salil and James, is available at [6]. [1] https://lore.kernel.org/kvmarm/82879258-46a7-a6e9-ee54-fc3692c1cdc3@arm.com/ [2] https://lore.kernel.org/linux-arm-kernel/20200625133757.22332-1-salil.mehta@huawei.com/ (Followed by KVM forum and Linaro Open discussions) [3] https://lore.kernel.org/linux-arm-kernel/f56cf420-affc-35f0-2355-801a924b8a35@arm.com/ [4] https://lore.kernel.org/kvm/bf7e83f1-c58e-8d65-edd0-d08f27b8b766@arm.com/ [5] https://lore.kernel.org/kvm/1569338454-26202-2-git-send-email-guoheyi@huawei.com/ [6] https://jpbrucker.net/git/linux/log/?h=cpuhp/devel https://jpbrucker.net/git/qemu/log/?h=cpuhp/devel Jean-Philippe Brucker (5): KVM: arm64: Replace power_off with mp_state in struct kvm_vcpu_arch KVM: arm64: Move WFI execution to check_vcpu_requests() KVM: arm64: Allow userspace to request WFI KVM: arm64: Pass hypercalls to userspace KVM: arm64: Pass PSCI calls to userspace Documentation/virt/kvm/api.rst | 46 +++++++++++++++---- Documentation/virt/kvm/arm/psci.rst | 1 + arch/arm64/include/asm/kvm_host.h | 10 +++- include/kvm/arm_hypercalls.h | 1 + include/kvm/arm_psci.h | 4 ++ include/uapi/linux/kvm.h | 3 ++ arch/arm64/kvm/arm.c | 71 +++++++++++++++++++++-------- arch/arm64/kvm/handle_exit.c | 3 +- arch/arm64/kvm/hypercalls.c | 28 +++++++++++- arch/arm64/kvm/psci.c | 69 ++++++++++++++-------------- 10 files changed, 170 insertions(+), 66 deletions(-)