Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp461743ybt; Fri, 19 Jun 2020 06:08:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxySrJ3uOtWMLr3zEVgIRxlVpMMZzx2MZyBVsEh+skUW5QmZT1KMrm3psRI09r5o8Z+Pne7 X-Received: by 2002:a50:ec1a:: with SMTP id g26mr3118194edr.289.1592572082839; Fri, 19 Jun 2020 06:08:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592572082; cv=none; d=google.com; s=arc-20160816; b=eEDqXni51HhkEt4JJzy/Nh4TsWpbvfsxsFg/r9+xzD3nYEAoYvhB6bm3bwr5vEjPkI yaP2H1J1AA6g2ZzBiF9ZB/ULlf84OiMyMtJCjzBz8UYb1Xdj5iU6SHobHpB4ZRV+zG78 ou6jSfLSSRzl8y9tZcn4vgWvjNOk3FZJ8SYJD2a4HjU0I6/0kdvD46sgZfntEt4ihDKa pygoa34pGCNDXynEfCvck4RxrlDz1YIrn89g7lH/7Gph2WVaTA70QGW0sU0jwtTBIMIO QFTyic5GLyi5CDrGiSsv36fHAC/Vt7ygX4jPEe7QtOT/rPcXJ20px6k/Nx3n+SAuXy0L tUkA== 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=Ef5MNVVe4QChPFsp/eWobIdbzwXwsvA/r0jwkG5tms8=; b=gHEDTjTn6j/xJ0B2voTXUIgBQqgjeWrGMrPmU3N6LDtXC3AG0uSz4PSAMw/onkE5Ek jDE4HyAXBxZmJOkRkKIg5iXfoPZhqYswNBm1bRIfugZ8zlT8ncbsjWHCeiKPAYeD+FUX /E7YUaCxOH+LNbap4+ilgemE1oOSkjBVZb8JztKhBPUuvSbhxNQNCABZoCt7kRMwgT7U cUpS0IdlhMsQDRZ476z25szqJLpH/u2cbqyMWN0+pmX8Q/IYgQRgsASDQ+eFGvfqIZx7 x3zHz0TKr8M3SWJAoU6bCkCvrkbq8rXrb+D7V/k+hSjY3jAlEv/g9prcbAfZp4ajaRAR 9I2A== 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 o11si3810105edv.414.2020.06.19.06.07.40; Fri, 19 Jun 2020 06:08:02 -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 S1732860AbgFSNCL (ORCPT + 99 others); Fri, 19 Jun 2020 09:02:11 -0400 Received: from foss.arm.com ([217.140.110.172]:57414 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732861AbgFSNBy (ORCPT ); Fri, 19 Jun 2020 09:01:54 -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 1F1A3101E; Fri, 19 Jun 2020 06:01:53 -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 E605C3F6CF; Fri, 19 Jun 2020 06:01: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: [PATCH v13 2/9] arm/arm64: KVM: Advertise KVM UID to guests via SMCCC Date: Fri, 19 Jun 2020 21:01:13 +0800 Message-Id: <20200619130120.40556-3-jianyong.wu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200619130120.40556-1-jianyong.wu@arm.com> References: <20200619130120.40556-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 --- arch/arm64/kvm/hypercalls.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c index 550dfa3e53cd..db6dce3d0e23 100644 --- a/arch/arm64/kvm/hypercalls.c +++ b/arch/arm64/kvm/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