Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7733085ybl; Thu, 16 Jan 2020 04:50:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzPU8xwd03yjJdANMveVk6MeQkmq2WUr7d7K5zqHcr8PE2Fbj6DOgnOt5xepXZUxMJjOKUv X-Received: by 2002:a9d:7590:: with SMTP id s16mr1669965otk.89.1579179005291; Thu, 16 Jan 2020 04:50:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579179005; cv=none; d=google.com; s=arc-20160816; b=ykuHzcWma6kkw53lMgrIirzWJIQGY4jvlLicMI/Gj088Nh2L7zD3n4j8DaWZauPM+0 nQwHdjg9mvsWaq2i21m09LoLssQL27qaOdhnz3fdLBb5JxJRS946IKeCeV0+anjuJ4/+ MSGwISqBEJkKkkBwYjD/pFJSjcVHUI6mtkMsXrRABKI3haHxc0D7Ior6qXWDolmym9pz IHVjpRhG8KkaHeRWic21kl2eswOLzySz6Bx0rOys/M/VZoGO2LKDSrJtO1/Uokf3SmEf Rs5R+dVQKHXCogof+TKhG03Eenx5XkqkXE7XbrescwPV94/M3JfmPphnvi/cTthYNxNx gc0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=88g7L/leMAsIr+AFqiZriUlUX2yLN13drvgYRz03uV0=; b=P5mTxIv4JRqwnKhrfZmwJrTAt2CuQq4vWyx/ew8kyqRbW6whg6JEc7DhVBOXOkpt39 hIxeLfUcQzIhmOYFmGb9c1R6hCP8bkfD2Tvs0vf3TZgQSOH+ibGapxv9Eowr/gmfaBue SUi61l9fJSd/o8nfuMp72Uq+Teg310L0wzRd6LYDdxD5rHKKSmp2EqUO+i/pzR4wDOcg uG4+29w6EcSnmvqA5/1IOBNabjCZn8kiQFtmMfSFSpHvyqoQsBzPYHveuBkpedKj6GxL tBF2O17YRn/iRDWxJP91oerY4qLBXBs4Q2HJ7tu6MxbTwZ//jVezChqohHkOhcZMcNpW QZVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q66si10603268oig.65.2020.01.16.04.49.53; Thu, 16 Jan 2020 04:50:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726689AbgAPMrd (ORCPT + 99 others); Thu, 16 Jan 2020 07:47:33 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:9641 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726369AbgAPMq5 (ORCPT ); Thu, 16 Jan 2020 07:46:57 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id A6F3513CA90D6CF3A638; Thu, 16 Jan 2020 20:46:54 +0800 (CST) Received: from DESKTOP-1NISPDV.china.huawei.com (10.173.221.248) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Thu, 16 Jan 2020 20:46:47 +0800 From: Zengruan Ye To: , , , , , CC: , , , , , , , , , , , , , Subject: [PATCH v3 3/8] arm/arm64: KVM: Advertise KVM UID to guests via SMCCC Date: Thu, 16 Jan 2020 20:46:21 +0800 Message-ID: <20200116124626.1155-4-yezengruan@huawei.com> X-Mailer: git-send-email 2.23.0.windows.1 In-Reply-To: <20200116124626.1155-1-yezengruan@huawei.com> References: <20200116124626.1155-1-yezengruan@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.173.221.248] X-CFilter-Loop: Reflected 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. Signed-off-by: Will Deacon [yezengruan@huawei.com: rebased] --- virt/kvm/arm/hypercalls.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/virt/kvm/arm/hypercalls.c b/virt/kvm/arm/hypercalls.c index 550dfa3e53cd..bdbab9ef6d2d 100644 --- a/virt/kvm/arm/hypercalls.c +++ b/virt/kvm/arm/hypercalls.c @@ -12,26 +12,28 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) { u32 func_id = smccc_get_function(vcpu); - long val = SMCCC_RET_NOT_SUPPORTED; - u32 feature; + long val[4] = {}; + u32 option; gpa_t gpa; + val[0] = SMCCC_RET_NOT_SUPPORTED; + 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); - switch (feature) { + option = smccc_get_arg1(vcpu); + switch (option) { case ARM_SMCCC_ARCH_WORKAROUND_1: switch (kvm_arm_harden_branch_predictor()) { 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 +43,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.19.1