Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp949989pxp; Wed, 16 Mar 2022 22:21:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5olbFiCquQ48+2juzTDDlDLJhkPFHc47UVOwWgUEFAP6HVMizBN5tArpGN0NDxzCXD43a X-Received: by 2002:a17:90a:9f89:b0:1bf:7ff7:4f62 with SMTP id o9-20020a17090a9f8900b001bf7ff74f62mr13917562pjp.207.1647494514943; Wed, 16 Mar 2022 22:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647494514; cv=none; d=google.com; s=arc-20160816; b=EciVLhXKSWXetvfYS2gJuwwOOdudJUPSYHqDwDlUAS45ivGC7graht/DB0h7P3qt5p eynd3q37I9CZXYyjIOS7ytStY3ERQUdR3O28pFwZSLW9G7JGcAzidzg/r+hJ3FWiFrW9 /gnWVBmutyzj+bGHT2RwZoEQFEpDMi25B7xGgRPz9swrKbimXUgmO0r7No6PlrByfQ1p mMAsixVtqpUwED3nz7YMNJP8jBILSsMqDFFztqNQHkBWeFjus1h17pkfote2VrG8wBi+ qaV4zdsZ2j+a+eCa+2nqgaFfRERuISrHtyfmh2LT0oFiT/wOx5nUVUabddP9hJuRgJuu ZVOA== 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=BWFI5h416BXkQSSoLp6it0M+QIIpZiht4kihVcXhZts=; b=dCEmAJhC9o3DFGy1ySItg8oAkJNGq4hhp8CcJ4AGTSRWlGMsTgU7dipml+9z8ucvMT zQ1jTcTP+r4/LxtiY9FbroHOmrG8rICizuRlRD6f10rheXIFjJSA2UyL34diKAw9Tp9r gbG7iRhTxrJ9YQf8f0EfXmqgWnUENdJRDwNC/wrPGetE6JkBe0PABob6VVkl8fClDJsp vVcpSXQeJnFhZEDzFkGBVjI/uqTlp5SjFUnB1W/eOMyxJf4zzAR0tencHUZ9DObMs+uM vsTF9fhWf6HRlQpk6bWY3rnWXktAIpqN4QUyuPqweKQapvzFE0YEd7pPmrp5VlriuZwP OLfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VZ2cAUX8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d184-20020a6336c1000000b003816043f010si1175665pga.517.2022.03.16.22.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:21:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VZ2cAUX8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E2FFA205969; Wed, 16 Mar 2022 21:26:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244193AbiCNTqo (ORCPT + 99 others); Mon, 14 Mar 2022 15:46:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244203AbiCNTqk (ORCPT ); Mon, 14 Mar 2022 15:46:40 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 496AC3DA78 for ; Mon, 14 Mar 2022 12:45:29 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id o12so11801879ilg.5 for ; Mon, 14 Mar 2022 12:45:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=BWFI5h416BXkQSSoLp6it0M+QIIpZiht4kihVcXhZts=; b=VZ2cAUX8Ar0g9XwlSwMUsAJFJ+x9WoBP8ZUB6v4eL265wgG+R7Yg+AHG6eBB9s36q+ acas52nuQwIOC2kAnffOOIPVbaZ9CsbEUqvZ9ubN/y27tiGvuGx7f55KXJCuPs5g4L0B Zvb0HwQblFcZjAHSFwulEWa84Nh7s+o1qSje5u9ZWBlI29Mxdd/h0T5AVmH3Ip/J/cEy Xo+rB9DWuAhQkC1vuQA0G75aFWpioKs+9NpJ380LPswDKkyS1ZPp/ovsKyUcA4nK5OHs 6A0Q1xlpuoF+4ZuF3LvkEBES9Z4bFPvPSacHgcHRgM4y8kaKq1fjZcfltW/52aCw2zLF tzDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=BWFI5h416BXkQSSoLp6it0M+QIIpZiht4kihVcXhZts=; b=EsDRN52DL8ism8wjKDh7JhYi4o2i+MwEG1EVGjIO9G4jFITzkO5+Adk1Et9yQ7+drJ 7/6l8pllm4bC6zA+rSSWFQULFb4jgZxygVhIVDCFOTn67bBLKQDaJgwT7h7CZXP1rUqE KNsqoN6klUmus88rH0Eqs/1fFRtKMSJ3M6zZw5PwbwNkaEMxMKVFgbhDktNV2IsnW5Qj HuaspPscy6ZA5IpF+D6UQefogu8IYVvdgskBAvRjFoYoU3zvr8aW3ti25nq0j/8QVBJ/ NueNRC2JIyiBxh1CXQU2k7nzEDqkhFIqyAe+gMnjSyrqCu3B65M1qHU9P1kHUtrR/1Lp Hg9Q== X-Gm-Message-State: AOAM531sztaM2ZBE3PGUj8qJdgDRBCL8IL2C0IAS3k7z6Gk0GwkJhpm4 aznND57/+1yNJJyjyrXpx7Tg9w== X-Received: by 2002:a05:6e02:1a2c:b0:2c7:89cb:6bc8 with SMTP id g12-20020a056e021a2c00b002c789cb6bc8mr11174471ile.236.1647287128338; Mon, 14 Mar 2022 12:45:28 -0700 (PDT) Received: from google.com (194.225.68.34.bc.googleusercontent.com. [34.68.225.194]) by smtp.gmail.com with ESMTPSA id c6-20020a056e020bc600b002c6731e7cb8sm9091010ilu.31.2022.03.14.12.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Mar 2022 12:45:27 -0700 (PDT) Date: Mon, 14 Mar 2022 19:45:24 +0000 From: Oliver Upton 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 , Reiji Watanabe , Jing Zhang , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v4 06/13] KVM: arm64: Add standard hypervisor firmware register Message-ID: References: <20220224172559.4170192-1-rananta@google.com> <20220224172559.4170192-7-rananta@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220224172559.4170192-7-rananta@google.com> X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 On Thu, Feb 24, 2022 at 05:25:52PM +0000, Raghavendra Rao Ananta wrote: > Introduce the firmware register to hold the standard hypervisor > service calls (owner value 5) 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 only for > Paravirtualized time, represented by bit-0. > > The register is also added to the kvm_arm_vm_scope_fw_regs[] list > as it maintains its state per-VM. > > 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/guest.c | 1 + > arch/arm64/kvm/hypercalls.c | 20 +++++++++++++++++++- > include/kvm/arm_hypercalls.h | 3 +++ > 5 files changed, 29 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 1909ced3208f..318148b69279 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -105,9 +105,11 @@ struct kvm_arch_memory_slot { > * struct kvm_hvc_desc: KVM ARM64 hypercall descriptor > * > * @hvc_std_bmap: Bitmap of standard secure service calls > + * @hvc_std_hyp_bmap: Bitmap of standard hypervisor service calls > */ > struct kvm_hvc_desc { > u64 hvc_std_bmap; > + u64 hvc_std_hyp_bmap; > }; > > struct kvm_arch { > diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h > index 2decc30d6b84..9a2caead7359 100644 > --- a/arch/arm64/include/uapi/asm/kvm.h > +++ b/arch/arm64/include/uapi/asm/kvm.h > @@ -295,6 +295,10 @@ struct kvm_arm_copy_mte_tags { > #define KVM_REG_ARM_STD_BIT_TRNG_V1_0 BIT(0) > #define KVM_REG_ARM_STD_BMAP_BIT_MAX 0 /* Last valid bit */ > > +#define KVM_REG_ARM_STD_HYP_BMAP KVM_REG_ARM_FW_BMAP_REG(1) > +#define KVM_REG_ARM_STD_HYP_BIT_PV_TIME BIT(0) > +#define KVM_REG_ARM_STD_HYP_BMAP_BIT_MAX 0 /* Last valid bit */ > + > /* SVE registers */ > #define KVM_REG_ARM64_SVE (0x15 << KVM_REG_ARM_COPROC_SHIFT) > > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c > index d66e6c742bbe..c42426d6137e 100644 > --- a/arch/arm64/kvm/guest.c > +++ b/arch/arm64/kvm/guest.c > @@ -66,6 +66,7 @@ static const u64 kvm_arm_vm_scope_fw_regs[] = { > KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1, > KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2, > KVM_REG_ARM_STD_BMAP, > + KVM_REG_ARM_STD_HYP_BMAP, > }; > > /** > diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c > index 48c126c3da72..ebc0cc26cf2e 100644 > --- a/arch/arm64/kvm/hypercalls.c > +++ b/arch/arm64/kvm/hypercalls.c > @@ -75,6 +75,10 @@ static bool kvm_hvc_call_supported(struct kvm_vcpu *vcpu, u32 func_id) > case ARM_SMCCC_TRNG_RND64: > return kvm_arm_fw_reg_feat_enabled(hvc_desc->hvc_std_bmap, > KVM_REG_ARM_STD_BIT_TRNG_V1_0); > + case ARM_SMCCC_HV_PV_TIME_FEATURES: > + case ARM_SMCCC_HV_PV_TIME_ST: > + return kvm_arm_fw_reg_feat_enabled(hvc_desc->hvc_std_hyp_bmap, > + KVM_REG_ARM_STD_HYP_BIT_PV_TIME); > default: > /* By default, allow the services that aren't listed here */ > return true; > @@ -83,6 +87,7 @@ static bool kvm_hvc_call_supported(struct kvm_vcpu *vcpu, u32 func_id) > > int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) > { > + struct kvm_hvc_desc *hvc_desc = &vcpu->kvm->arch.hvc_desc; > u32 func_id = smccc_get_function(vcpu); > u64 val[4] = {SMCCC_RET_NOT_SUPPORTED}; > u32 feature; > @@ -134,7 +139,10 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) > } > break; > case ARM_SMCCC_HV_PV_TIME_FEATURES: > - val[0] = SMCCC_RET_SUCCESS; > + if (kvm_arm_fw_reg_feat_enabled( > + hvc_desc->hvc_std_hyp_bmap, It is probably OK to keep this parameter on the line above (just stay under 100 characters a line). > + KVM_REG_ARM_STD_HYP_BIT_PV_TIME)) > + val[0] = SMCCC_RET_SUCCESS; > break; > } > break; > @@ -179,6 +187,7 @@ static const u64 kvm_arm_fw_reg_ids[] = { > KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1, > KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2, > KVM_REG_ARM_STD_BMAP, > + KVM_REG_ARM_STD_HYP_BMAP, > }; > > void kvm_arm_init_hypercalls(struct kvm *kvm) > @@ -186,6 +195,7 @@ void kvm_arm_init_hypercalls(struct kvm *kvm) > struct kvm_hvc_desc *hvc_desc = &kvm->arch.hvc_desc; > > hvc_desc->hvc_std_bmap = ARM_SMCCC_STD_FEATURES; > + hvc_desc->hvc_std_hyp_bmap = ARM_SMCCC_STD_HYP_FEATURES; > } > > int kvm_arm_get_fw_num_regs(struct kvm_vcpu *vcpu) > @@ -272,6 +282,9 @@ int kvm_arm_get_fw_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) > case KVM_REG_ARM_STD_BMAP: > val = READ_ONCE(hvc_desc->hvc_std_bmap); > break; > + case KVM_REG_ARM_STD_HYP_BMAP: > + val = READ_ONCE(hvc_desc->hvc_std_hyp_bmap); > + break; > default: > return -ENOENT; > } > @@ -294,6 +307,10 @@ static int kvm_arm_set_fw_reg_bmap(struct kvm_vcpu *vcpu, u64 reg_id, u64 val) > fw_reg_bmap = &hvc_desc->hvc_std_bmap; > fw_reg_features = ARM_SMCCC_STD_FEATURES; > break; > + case KVM_REG_ARM_STD_HYP_BMAP: > + fw_reg_bmap = &hvc_desc->hvc_std_hyp_bmap; > + fw_reg_features = ARM_SMCCC_STD_HYP_FEATURES; > + break; > default: > return -ENOENT; > } > @@ -398,6 +415,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: > 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 64d30b452809..a1cb6e839c74 100644 > --- a/include/kvm/arm_hypercalls.h > +++ b/include/kvm/arm_hypercalls.h > @@ -9,6 +9,9 @@ > #define ARM_SMCCC_STD_FEATURES \ > GENMASK_ULL(KVM_REG_ARM_STD_BMAP_BIT_MAX, 0) > > +#define ARM_SMCCC_STD_HYP_FEATURES \ > + GENMASK_ULL(KVM_REG_ARM_STD_HYP_BMAP_BIT_MAX, 0) > + > int kvm_hvc_call_handler(struct kvm_vcpu *vcpu); > > static inline u32 smccc_get_function(struct kvm_vcpu *vcpu) > -- > 2.35.1.473.g83b2b277ed-goog >