Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp91830ybr; Fri, 22 May 2020 01:40:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz78jjteRIb9qh2vjKFhk4Pd8ZH5PgVf8anpwhqP+PYQul6ka6it2KoMfDF13gHhuLzkSua X-Received: by 2002:a17:906:1b43:: with SMTP id p3mr6620067ejg.265.1590136808241; Fri, 22 May 2020 01:40:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590136808; cv=none; d=google.com; s=arc-20160816; b=gPF4sxqIGxJ6smm/XJYlwr1sVlQqYkMeq1TvtIfTg8iXhqX8f7fOEqHVKU53kYw+oo gA2PIGPPPl5RbZynFK2X2nXBTdiOwrlPLtv1U5ADHv4raHhp9/hG+la4UlbWEmr+ndd3 BHc/KWjvJAMdPqEZ7bDY7NOhmck1x9mRVloBodxdbWX4EHRD+zGK3FtWZojgAOq1mi7K gTG0MRUymV65kaH/otiCsOwGk94XQ5PcVfsvArDiL1nXMBaLONJh0RTmiaBlEB4H9Iva x6hf9p/6V+T7Z22IY6Hz1IuYKNQUPMjmemrukLT6LN9xnpJc0x7Qv2A6KVS9YY8VOLa4 Feyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=4ltCCUaHLsUH6DunLBk4e6X+c4jMexSUQ5xVR/Igc1s=; b=u3ktY5B0GlwJnC/sTwpt6lp3sxrBYJcE6ltnxyihDeSvWB8RcysPQeReJml+MGlye9 q6KU/7X6xllupa62nWHTdPU9EmvOHruOgBOUDGbUHjUsCXf5tkuNbn9o9frwpQiKe9p5 shEL0QGlEs4dhDJ0gvoMi2ZYtMm7yrTCQjtHVBM3nootmuMqFSa9LEEbkb0MuLZWSHWe 2LmjJHITXNHO4peLfUb6/orFD+srPJw8CZCL+fBxKpIO4jCh/zgEXxBPMrohOnxftMPF LJONbkkFMFjVRPs+B0JeH2KyC5Z22j9zWBu7N93vNIBLXzYgrVadqO/94rjsChHUGO4v XLDg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v10si4401141edl.604.2020.05.22.01.39.45; Fri, 22 May 2020 01:40:08 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729695AbgEVIhy (ORCPT + 99 others); Fri, 22 May 2020 04:37:54 -0400 Received: from foss.arm.com ([217.140.110.172]:59296 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729672AbgEVIhx (ORCPT ); Fri, 22 May 2020 04:37:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C7F8855D; Fri, 22 May 2020 01:37:52 -0700 (PDT) Received: from entos-d05.shanghai.arm.com (entos-d05.shanghai.arm.com [10.169.40.35]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F34DC3F52E; Fri, 22 May 2020 01:37:46 -0700 (PDT) From: Jianyong Wu To: netdev@vger.kernel.org, yangbo.lu@nxp.com, john.stultz@linaro.org, tglx@linutronix.de, pbonzini@redhat.com, sean.j.christopherson@intel.com, maz@kernel.org, richardcochran@gmail.com, Mark.Rutland@arm.com, will@kernel.org, suzuki.poulose@arm.com, steven.price@arm.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Steve.Capper@arm.com, Kaly.Xin@arm.com, justin.he@arm.com, Wei.Chen@arm.com, jianyong.wu@arm.com, nd@arm.com Subject: [RFC PATCH v12 02/11] arm/arm64: KVM: Advertise KVM UID to guests via SMCCC Date: Fri, 22 May 2020 16:37:15 +0800 Message-Id: <20200522083724.38182-3-jianyong.wu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200522083724.38182-1-jianyong.wu@arm.com> References: <20200522083724.38182-1-jianyong.wu@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon We can advertise ourselves to guests as KVM and provide a basic features bitmap for discoverability of future hypervisor services. Cc: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Jianyong Wu --- virt/kvm/arm/hypercalls.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/virt/kvm/arm/hypercalls.c b/virt/kvm/arm/hypercalls.c index 550dfa3e53cd..db6dce3d0e23 100644 --- a/virt/kvm/arm/hypercalls.c +++ b/virt/kvm/arm/hypercalls.c @@ -12,13 +12,13 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) { u32 func_id = smccc_get_function(vcpu); - long val = SMCCC_RET_NOT_SUPPORTED; + u32 val[4] = {SMCCC_RET_NOT_SUPPORTED}; u32 feature; gpa_t gpa; switch (func_id) { case ARM_SMCCC_VERSION_FUNC_ID: - val = ARM_SMCCC_VERSION_1_1; + val[0] = ARM_SMCCC_VERSION_1_1; break; case ARM_SMCCC_ARCH_FEATURES_FUNC_ID: feature = smccc_get_arg1(vcpu); @@ -28,10 +28,10 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) case KVM_BP_HARDEN_UNKNOWN: break; case KVM_BP_HARDEN_WA_NEEDED: - val = SMCCC_RET_SUCCESS; + val[0] = SMCCC_RET_SUCCESS; break; case KVM_BP_HARDEN_NOT_REQUIRED: - val = SMCCC_RET_NOT_REQUIRED; + val[0] = SMCCC_RET_NOT_REQUIRED; break; } break; @@ -41,31 +41,40 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) case KVM_SSBD_UNKNOWN: break; case KVM_SSBD_KERNEL: - val = SMCCC_RET_SUCCESS; + val[0] = SMCCC_RET_SUCCESS; break; case KVM_SSBD_FORCE_ENABLE: case KVM_SSBD_MITIGATED: - val = SMCCC_RET_NOT_REQUIRED; + val[0] = SMCCC_RET_NOT_REQUIRED; break; } break; case ARM_SMCCC_HV_PV_TIME_FEATURES: - val = SMCCC_RET_SUCCESS; + val[0] = SMCCC_RET_SUCCESS; break; } break; case ARM_SMCCC_HV_PV_TIME_FEATURES: - val = kvm_hypercall_pv_features(vcpu); + val[0] = kvm_hypercall_pv_features(vcpu); break; case ARM_SMCCC_HV_PV_TIME_ST: gpa = kvm_init_stolen_time(vcpu); if (gpa != GPA_INVALID) - val = gpa; + val[0] = gpa; + break; + case ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID: + val[0] = ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_0; + val[1] = ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_1; + val[2] = ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_2; + 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); break; default: return kvm_psci_call(vcpu); } - smccc_set_retval(vcpu, val, 0, 0, 0); + smccc_set_retval(vcpu, val[0], val[1], val[2], val[3]); return 1; } -- 2.17.1