Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp787347rwb; Fri, 18 Nov 2022 08:14:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf7kV8J341FywX9bUOo0+I1sLFJDUA5IeZDynE+QBm+KV2HLlcYFUhPekwFvnzlmYtKsg9eI X-Received: by 2002:a17:90a:d816:b0:212:cd99:915c with SMTP id a22-20020a17090ad81600b00212cd99915cmr8529915pjv.38.1668788057121; Fri, 18 Nov 2022 08:14:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668788057; cv=none; d=google.com; s=arc-20160816; b=dm90DpHt1yND8agvfHqO1Mzw340ROktZgzYM1xw7l2vdyZcsygyQpujSn10l92ahG1 36+PvFjuzK65FELLLGTzlE4hbUsQ9LETmwiI398JNoV8Dsg6XhMn983YnGbviqNZK2n0 ZIWFbQiFVL3BlL10qPn8aDoRJRiiZ9fo9CmWbHYk85FrJw+YXE08aNsKP0c5qzk9Ql7E /0Qd1zAet4dADL0LKg18MSUjo5ctNkunj2n5nJbdXEFJkujD8bqLbtcHqUzo+ADN4jIW S+yxizgDzy7rwgC/SHkk+Mk4wNB6RgM3I1jhUM+LoZGCVuXzNcPT+78jYeHj/yWBaNYy nK7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ga0AJZ/1nPWVnzu6q6R0DZ5+Wz8o35kVUiCHn5LIXhs=; b=XjB9YI6DAS3t7TlWee51c+LG9hR4/FwgdSng5Xv3WxKfnLrK7exJhX0F/r9vUEbgw4 dRE/aILGgv5FNH164ShpZDKaHpvdoGVNPIr4aNJFc+AUtiOIs11pclL9YZttN3+k4bSW fTcAVkbqtRt/d/lQNVm00KhaTehHFZQwTLmhaNFrghzBpFXyGkChkw1njHVxZbefp6mL ExxsDp4iLaS0v5g9bdiKlgpNUmBLoUnwMeHZOhGt3MU7FF6vkH0EpgEnq9KMTb8N5v7R b6QVbnYQF3VvKklppcd6JZqyfyYgi5jw6oaJ60QhbSohUHcfXtg7J7CUDJ/g1qAIRDpT LBQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YAcGcNO7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g8-20020a1709026b4800b0018668e41784si3946312plt.13.2022.11.18.08.13.57; Fri, 18 Nov 2022 08:14:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YAcGcNO7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S242223AbiKRPAH (ORCPT + 91 others); Fri, 18 Nov 2022 10:00:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242211AbiKRO7t (ORCPT ); Fri, 18 Nov 2022 09:59:49 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A60B9ACAE; Fri, 18 Nov 2022 06:56:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 053D7B822F6; Fri, 18 Nov 2022 14:56:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49A0CC433C1; Fri, 18 Nov 2022 14:56:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668783404; bh=kQqNwIRTX/hMdAUkbPpnbCbz6J1Qz8mIuBGg79EWriQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YAcGcNO717vxcqR6gw7hPCPkskQj2wFxDzeuW9mROwlkdTfHvsj313IATnooRiuH7 tggG//xkOzUdbhHJi9RH5nUHr7JyjuEL8To04GZkGxQ+NqDdJYuK0xU8yvqQm2SnY5 Gv9xoQAQQwMXscRow5tS3mEG0waNLDXKKDfLUaCfkyCYxD/MDglLWUCFLE8+3Dp8iv 0mSr5zAFkl6F8Wv3JRf0R4kjtOsD7JHBNfgBGcKygeKngjWkZ4TPuc+YarzIdVBPqn 55sMg9/gLjLP2+8k17o7zmujzTy38yupQVAQHhdgtLRalXIq0dYP63UmSdSl8lUPu9 OZ4b8PrPzo3Mg== Date: Fri, 18 Nov 2022 14:56:38 +0000 From: Will Deacon To: Oliver Upton Cc: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Paolo Bonzini , Raghavendra Rao Ananta , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [RFC PATCH 2/3] KVM: arm64: Allow userspace to trap SMCCC sub-ranges Message-ID: <20221118145637.GC4624@willie-the-truck> References: <20221110015327.3389351-1-oliver.upton@linux.dev> <20221110015327.3389351-3-oliver.upton@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221110015327.3389351-3-oliver.upton@linux.dev> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey Oliver, On Thu, Nov 10, 2022 at 01:53:26AM +0000, Oliver Upton wrote: > As the SMCCC (and related specifications) march towards an > 'everything and the kitchen sink' interface for interacting with a > system, it is less likely that KVM will implement every supported > feature. > > Add a capability that allows userspace to trap hypercall ranges, > allowing the VMM to mix-and-match between calls handled in userspace vs. > KVM. > > Signed-off-by: Oliver Upton > --- > arch/arm64/include/asm/kvm_host.h | 5 ++++ > arch/arm64/include/uapi/asm/kvm.h | 15 ++++++++++ > arch/arm64/kvm/arm.c | 10 +++++++ > arch/arm64/kvm/hypercalls.c | 48 +++++++++++++++++++++++++++++++ > include/uapi/linux/kvm.h | 1 + > 5 files changed, 79 insertions(+) [...] > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index 6f0b56e7f8c7..6e8a222fc295 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -100,6 +100,13 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, > r = 0; > set_bit(KVM_ARCH_FLAG_SYSTEM_SUSPEND_ENABLED, &kvm->arch.flags); > break; > + case KVM_CAP_ARM_USER_HYPERCALLS: > + if (cap->args[0] & ~KVM_ARM_USER_HYPERCALL_FLAGS) > + return -EINVAL; Why not use KVM_CAP_EXIT_HYPERCALL for this? At some point during pKVM development, we used that to notify the VMM about memory being shared back from the guest but we eventually dropped it as the notification to userspace ended up not being needed: https://android-kvm.googlesource.com/linux/+/dbd2861832dfc4c8a3103214b3c212ee7ace1c44%5E%21/ https://android-kvm.googlesource.com/linux/+/2a3afc6da99c0e0cb62be1687153ee572903aa80%5E%21/ I'm not saying that what we did was necessarily better, but it seems a bit simpler and I figured it might be useful to point you to it. Will