Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp413413pxb; Mon, 25 Apr 2022 12:39:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6cP4ciy3OhfRMzfoZqI8/XPrS+xuSrtUusajP2Dsx0ZvSaicAtXgwFUKYxE79dFRnQwg/ X-Received: by 2002:a17:902:f544:b0:15c:fa6f:2630 with SMTP id h4-20020a170902f54400b0015cfa6f2630mr10259698plf.110.1650915557726; Mon, 25 Apr 2022 12:39:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650915557; cv=none; d=google.com; s=arc-20160816; b=Asb2ZWq9A6D42fqqQSiZGXXox9pDJnQKPLYEvebUyIAHUsTtaFefr1Fv+UOt9uvimn UCVu+uIlr5aRFdYguoKYpMAUy1UZ2LHTEBiWCkOy/MExVI+QODnGd6w6a9L4dGcqt93x Se2agYE80TCbNQDxZ4oy2iErdIzyCQdrndticax+T5Qz1XdA+D4cmm9is2WOu0htlUCo LMvC7qtmPjgyFO/PaCz9xa2h5IUp1MdyuyiORevNfi9kj3Y9xnHT38/Jrk4rHH5xfonu fWPPbPacMTNvLQU8F0c2Pw3GETIM8v+0P7QazZM/+1WPredhAGPEsxNQVRGrncnOQUGV S5yw== 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=ZcXMvreojsCQW2V+Q7kqKm5McoJxlL/FAyGsUU3wai8=; b=RTbhZSXwJAW20LEBRXVjNslUpEpZNBgQdMxTYMTglPtsRr4SSvHZ81MzLPnCuLinfj Y0k266OGXPzccW7lGYFcpUMc9GaSOE/Xsxsvcao6p0XTI8pb0pWpr3DRLjGxHJ5o/mp0 BFhKiEf8cBEfXtq1kGioP7w7J0yKmz+X+Ka+SENb+PyHlrgnx8+9TWNvRXziInWir7rq y+j9PhqvUPF3GLvZ9E8rBSgDzqQf8jC4IQFICB8I79iRn6N9iiGCczMwzVDu7n1PBVir 0Z7YVn/siPKIL83oNYgAjwUYjeNbrWy0m/EnnFsPPtXqA7hPuu4gUHnkwvTG7IM46sVZ TuDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=LZZM0dIU; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7-20020a656747000000b003ab22434b2asi5986063pgu.74.2022.04.25.12.39.00; Mon, 25 Apr 2022 12:39:17 -0700 (PDT) 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=@google.com header.s=20210112 header.b=LZZM0dIU; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238408AbiDYG0C (ORCPT + 99 others); Mon, 25 Apr 2022 02:26:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231742AbiDYGZx (ORCPT ); Mon, 25 Apr 2022 02:25:53 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A04F40E41 for ; Sun, 24 Apr 2022 23:22:51 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id r14-20020a9d750e000000b00605446d683eso10126680otk.10 for ; Sun, 24 Apr 2022 23:22:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZcXMvreojsCQW2V+Q7kqKm5McoJxlL/FAyGsUU3wai8=; b=LZZM0dIU0/e0VrjVUq0OmIiCB15M4oU/CVsRvxyC25hxvFBKX6RyuAPggfbHrZzpBf io7WmzcHu2czvAFU9ZTsBcET3aK5wPDShnqrHtgvNeuZAnvRFd+FMLN6uHoXyVc5ph0O q2TgeHqar+d+Dd8/TGsxyX5/8nRmAyw/p+QAnvohhUOZKS28g5gJpSHE/On1ertMmMaq JHTpnE4f/5G+TM84B7F1EM1EPYYw4cYlNGIdUpWPwgxYRzqkf4ahtXp3uJAkwXE4GCb/ RZ2lIVhnP4cf5hjZAFHVB32CkBA4cXteJDDmrCsPQgUfUOkIhPYsF2tByIIP+wK0y9aN G7mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZcXMvreojsCQW2V+Q7kqKm5McoJxlL/FAyGsUU3wai8=; b=qOG2E5Y5p+8kSToHmtpjhDpAIp89PrvcB0Q0hGFKnU7fMBRD4SzEPw6Cwx8r9AKAW8 iOKGjFBspc3xTh6RE5KtKi7hY0Kq/+Jn0UNrXzuj7B+vVs9QjIo0Hh2snVnZ5R5zgOTO o4qSwTx6Mp4FMJSpgm/vwiABaHhZ7H7Pw3e8Th4DhvWHnKghqOMPyEAummnp/lQ1v8Si Ms4izl5sRsVzVsRM33RvOyWLFoLhSkBLaGpqr8EWQ2LQ7Qy1xGfJnq6TzPBBs8r1ZSHv nJ8xhQB0CoLJSPJz1LrSllhTXbXERn0siKBBXHuxULcWb/O4yym7aNem8P4a12/tdWUr bBKw== X-Gm-Message-State: AOAM532qMHurbu6lUM3ui2CQswKiHlg/rjsXW6j6sA//alX0s/rIBIVT KZN9t2IlUO+IZaqh39t6bqvQhY0YnZ7LQUy3gY7+fQ== X-Received: by 2002:a05:6830:18d:b0:605:4cfb:19cd with SMTP id q13-20020a056830018d00b006054cfb19cdmr5773806ota.177.1650867770178; Sun, 24 Apr 2022 23:22:50 -0700 (PDT) MIME-Version: 1.0 References: <20220423000328.2103733-1-rananta@google.com> <20220423000328.2103733-5-rananta@google.com> In-Reply-To: <20220423000328.2103733-5-rananta@google.com> From: Reiji Watanabe Date: Sun, 24 Apr 2022 23:22:34 -0700 Message-ID: Subject: Re: [PATCH v6 4/9] KVM: arm64: Add vendor hypervisor firmware register To: Raghavendra Rao Ananta Cc: Marc Zyngier , Andrew Jones , James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Catalin Marinas , Will Deacon , Peter Shier , Ricardo Koller , Oliver Upton , Jing Zhang , Linux ARM , kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Hi Raghu, On Fri, Apr 22, 2022 at 5:03 PM Raghavendra Rao Ananta wrote: > > Introduce the firmware register to hold the vendor specific > hypervisor service calls (owner value 6) as a bitmap. The > bitmap represents the features that'll be enabled for the > guest, as configured by the user-space. Currently, this > includes support for KVM-vendor features along with > reading the UID, represented by bit-0, and Precision Time > Protocol (PTP), represented by bit-1. > > Signed-off-by: Raghavendra Rao Ananta > --- > arch/arm64/include/asm/kvm_host.h | 2 ++ > arch/arm64/include/uapi/asm/kvm.h | 4 ++++ > arch/arm64/kvm/hypercalls.c | 23 ++++++++++++++++++----- > include/kvm/arm_hypercalls.h | 2 ++ > 4 files changed, 26 insertions(+), 5 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 27d4b2a7970e..a025c2ba012a 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -106,10 +106,12 @@ struct kvm_arch_memory_slot { > * > * @std_bmap: Bitmap of standard secure service calls > * @std_hyp_bmap: Bitmap of standard hypervisor service calls > + * @vendor_hyp_bmap: Bitmap of vendor specific hypervisor service calls > */ > struct kvm_smccc_features { > unsigned long std_bmap; > unsigned long std_hyp_bmap; > + unsigned long vendor_hyp_bmap; > }; > > struct kvm_arch { > diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h > index 9eecc7ee8c14..e7d5ae222684 100644 > --- a/arch/arm64/include/uapi/asm/kvm.h > +++ b/arch/arm64/include/uapi/asm/kvm.h > @@ -344,6 +344,10 @@ struct kvm_arm_copy_mte_tags { > #define KVM_REG_ARM_STD_HYP_BMAP KVM_REG_ARM_FW_FEAT_BMAP_REG(1) > #define KVM_REG_ARM_STD_HYP_BIT_PV_TIME 0 > > +#define KVM_REG_ARM_VENDOR_HYP_BMAP KVM_REG_ARM_FW_FEAT_BMAP_REG(2) > +#define KVM_REG_ARM_VENDOR_HYP_BIT_FUNC_FEAT 0 > +#define KVM_REG_ARM_VENDOR_HYP_BIT_PTP 1 > + > /* Device Control API: ARM VGIC */ > #define KVM_DEV_ARM_VGIC_GRP_ADDR 0 > #define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1 > diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c > index f097bebdad39..76e626d0e699 100644 > --- a/arch/arm64/kvm/hypercalls.c > +++ b/arch/arm64/kvm/hypercalls.c > @@ -72,9 +72,6 @@ static bool kvm_hvc_call_default_allowed(struct kvm_vcpu *vcpu, u32 func_id) > */ > case ARM_SMCCC_VERSION_FUNC_ID: > case ARM_SMCCC_ARCH_FEATURES_FUNC_ID: > - case ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID: > - case ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID: > - case ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID: > return true; > default: > return kvm_psci_func_id_is_valid(vcpu, func_id); > @@ -97,6 +94,13 @@ static bool kvm_hvc_call_allowed(struct kvm_vcpu *vcpu, u32 func_id) > case ARM_SMCCC_HV_PV_TIME_ST: > return kvm_arm_fw_reg_feat_enabled(&smccc_feat->std_hyp_bmap, > KVM_REG_ARM_STD_HYP_BIT_PV_TIME); > + case ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID: > + case ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID: > + return kvm_arm_fw_reg_feat_enabled(&smccc_feat->vendor_hyp_bmap, > + KVM_REG_ARM_VENDOR_HYP_BIT_FUNC_FEAT); > + case ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID: > + return kvm_arm_fw_reg_feat_enabled(&smccc_feat->vendor_hyp_bmap, > + KVM_REG_ARM_VENDOR_HYP_BIT_PTP); > default: > return kvm_hvc_call_default_allowed(vcpu, func_id); > } > @@ -189,8 +193,7 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) > val[3] = ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_3; > break; > case ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID: > - val[0] = BIT(ARM_SMCCC_KVM_FUNC_FEATURES); > - val[0] |= BIT(ARM_SMCCC_KVM_FUNC_PTP); > + val[0] = smccc_feat->vendor_hyp_bmap; > break; > case ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID: > kvm_ptp_get_time(vcpu, val); > @@ -217,6 +220,7 @@ static const u64 kvm_arm_fw_reg_ids[] = { > KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3, > KVM_REG_ARM_STD_BMAP, > KVM_REG_ARM_STD_HYP_BMAP, > + KVM_REG_ARM_VENDOR_HYP_BMAP, > }; > > void kvm_arm_init_hypercalls(struct kvm *kvm) > @@ -225,6 +229,7 @@ void kvm_arm_init_hypercalls(struct kvm *kvm) > > smccc_feat->std_bmap = KVM_ARM_SMCCC_STD_FEATURES; > smccc_feat->std_hyp_bmap = KVM_ARM_SMCCC_STD_HYP_FEATURES; > + smccc_feat->vendor_hyp_bmap = KVM_ARM_SMCCC_VENDOR_HYP_FEATURES; > } > > int kvm_arm_get_fw_num_regs(struct kvm_vcpu *vcpu) > @@ -317,6 +322,9 @@ int kvm_arm_get_fw_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) > case KVM_REG_ARM_STD_HYP_BMAP: > val = READ_ONCE(smccc_feat->std_hyp_bmap); > break; > + case KVM_REG_ARM_VENDOR_HYP_BMAP: > + val = READ_ONCE(smccc_feat->vendor_hyp_bmap); > + break; > default: > return -ENOENT; > } > @@ -343,6 +351,10 @@ static int kvm_arm_set_fw_reg_bmap(struct kvm_vcpu *vcpu, u64 reg_id, u64 val) > fw_reg_bmap = &smccc_feat->std_hyp_bmap; > fw_reg_features = KVM_ARM_SMCCC_STD_HYP_FEATURES; > break; > + case KVM_REG_ARM_VENDOR_HYP_BMAP: > + fw_reg_bmap = &smccc_feat->vendor_hyp_bmap; > + fw_reg_features = KVM_ARM_SMCCC_VENDOR_HYP_FEATURES; > + break; > default: > return -ENOENT; > } > @@ -445,6 +457,7 @@ int kvm_arm_set_fw_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) > return 0; > case KVM_REG_ARM_STD_BMAP: > case KVM_REG_ARM_STD_HYP_BMAP: > + case KVM_REG_ARM_VENDOR_HYP_BMAP: > return kvm_arm_set_fw_reg_bmap(vcpu, reg->id, val); > default: > return -ENOENT; > diff --git a/include/kvm/arm_hypercalls.h b/include/kvm/arm_hypercalls.h > index aadd6ae3ab72..4ebfdd26e486 100644 > --- a/include/kvm/arm_hypercalls.h > +++ b/include/kvm/arm_hypercalls.h > @@ -9,9 +9,11 @@ > /* Last valid bits of the bitmapped firmware registers */ > #define KVM_REG_ARM_STD_BMAP_BIT_MAX 0 > #define KVM_REG_ARM_STD_HYP_BMAP_BIT_MAX 0 > +#define KVM_REG_ARM_VENDOR_HYP_BMAP_BIT_MAX 1 Nit: IMHO perhaps it might be more convenient to define the MAX macro in arch/arm64/include/uapi/asm/kvm.h like below for maintenance ? (The same comments are applied to other KVM_REG_ARM_*_BMAP_BIT_MAX) #define KVM_REG_ARM_VENDOR_HYP_BIT_MAX KVM_REG_ARM_VENDOR_HYP_BIT_PTP Thanks, Reiji > > #define KVM_ARM_SMCCC_STD_FEATURES GENMASK(KVM_REG_ARM_STD_BMAP_BIT_MAX, 0) > #define KVM_ARM_SMCCC_STD_HYP_FEATURES GENMASK(KVM_REG_ARM_STD_HYP_BMAP_BIT_MAX, 0) > +#define KVM_ARM_SMCCC_VENDOR_HYP_FEATURES GENMASK(KVM_REG_ARM_VENDOR_HYP_BMAP_BIT_MAX, 0) > > int kvm_hvc_call_handler(struct kvm_vcpu *vcpu); > > -- > 2.36.0.rc2.479.g8af0fa9b8e-goog >