From patchwork Wed Nov 28 14:45:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10702889 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3656816B1 for ; Wed, 28 Nov 2018 15:32:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24C292D916 for ; Wed, 28 Nov 2018 15:32:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 195EA2D910; Wed, 28 Nov 2018 15:32:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7C9F42D8E6 for ; Wed, 28 Nov 2018 15:32:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=51qwyAka6J6Hyd3JLwPwbuv/V0987H6pQGTUDXMR3Gk=; b=SIUaMy+ooPBKIp rp5DDEEZB4he9/vJrLTgwFc0EBvQbnZl5i7DdU+PSOhMmdOKbF4M2D2pIeSYcJpZlvoA08TTPxXUM NsCznH3UJtFxZun0SjPaNRpAONq1Vm1rToUSXhJlp8dZVTulnuhGu6HqFh3AAPNn4DhWDoxBfD2Og YQ4oqlpbjdBQY95ipbnMHB18MdjQFunSfBJncHYEzHo2K2aFFe+zVYFN+LkYAHE8SWkOi3pHiiaL+ GP39BbQBSRFE6F5oxYBTPAFyBxx7zwCTno1yujE7aycQGpfZay9J9MWDVw2zG7sq7zJaSsH3Gu8+L /3EjASvtrvSLfI/crwSg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gS1p2-0005CE-ST; Wed, 28 Nov 2018 15:32:16 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gS1oG-0004Rw-78 for linux-arm-kernel@bombadil.infradead.org; Wed, 28 Nov 2018 15:31:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=WVh10En23vOrR4Ga0F2rxBpW996g7Uehgl16WH00bH4=; b=1D/UNXbZEZ1eF9xCZbP9KIDssB 2EjoQCTWCNMuXx2NjNsU5OjUYOwr2zO5mqBAZmYNfI78kWmV/BwA1n4Na3FsGmFzM1GhY9rHWsJ7u /w3Z42bqjUYnSgWiOz4lzoKHLLA6xGTz6CnQTDwMIKAAV3IKXSwdqrO0lDvwcnIBBFr+24VHxLHQq ar6cVx0IGqmFIIEhKYiynikBKIh7l2yeOeGVvToFEndL90JC+GA8v8XZbkUTJEH+dRM0KY9m6GXp0 n7m6i/OJdgxABZM/oBm298Zu0PU8ftcZzh/C0+P2xp03WjohCM/xy/5JaVBDYTY4wK5jUvekwd7Yo dtVIE6NA==; Received: from foss.arm.com ([217.140.101.70]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gS177-0006bC-4H for linux-arm-kernel@lists.infradead.org; Wed, 28 Nov 2018 14:46:54 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0108A3710; Wed, 28 Nov 2018 06:46:37 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.108]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7A7E33F5AF; Wed, 28 Nov 2018 06:46:35 -0800 (PST) From: Steven Price To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH 05/12] KVM: arm64: Implement PV_FEATURES call Date: Wed, 28 Nov 2018 14:45:20 +0000 Message-Id: <20181128144527.44710-6-steven.price@arm.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181128144527.44710-1-steven.price@arm.com> References: <20181128144527.44710-1-steven.price@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181128_094653_486146_9D0BFD0B X-CRM114-Status: GOOD ( 19.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Marc Zyngier , Catalin Marinas , Will Deacon , Christoffer Dall , Steven Price Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This provides a mechanism for querying which paravirtualized features are available in this hypervisor. Also add the header file which defines the ABI for the paravirtualized clock features we're about to add. Signed-off-by: Steven Price --- arch/arm64/include/asm/pvclock-abi.h | 32 ++++++++++++++++++++++++++++ include/kvm/arm_pv.h | 28 ++++++++++++++++++++++++ include/linux/arm-smccc.h | 1 + virt/kvm/arm/hypercalls.c | 9 ++++++++ 4 files changed, 70 insertions(+) create mode 100644 arch/arm64/include/asm/pvclock-abi.h create mode 100644 include/kvm/arm_pv.h diff --git a/arch/arm64/include/asm/pvclock-abi.h b/arch/arm64/include/asm/pvclock-abi.h new file mode 100644 index 000000000000..64ce041c8922 --- /dev/null +++ b/arch/arm64/include/asm/pvclock-abi.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2018 Arm Ltd. */ + +#ifndef __ASM_PVCLOCK_ABI_H +#define __ASM_PVCLOCK_ABI_H + +#include + +struct pvclock_vm_time_info { + __le32 revision; + __le32 attributes; + __le64 sequence_number; + __le64 scale_mult; + __le32 shift; + __le32 reserved; + __le64 native_freq; + __le64 pv_freq; + __le64 div_by_pv_freq_mult; +} __packed; + +struct pvclock_vcpu_stolen_time_info { + __le32 revision; + __le32 attributes; + __le64 stolen_time; + /* Structure must be 64 byte aligned, pad to that size */ + u8 padding[48]; +} __packed; + +#define PV_VM_TIME_NOT_SUPPORTED -1 +#define PV_VM_TIME_INVALID_PARAMETERS -2 + +#endif diff --git a/include/kvm/arm_pv.h b/include/kvm/arm_pv.h new file mode 100644 index 000000000000..19d2dafff31a --- /dev/null +++ b/include/kvm/arm_pv.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 + * Copyright (C) 2018 Arm Ltd. + */ + +#ifndef __KVM_ARM_PV_H +#define __KVM_ARM_PV_H + +#include + +#define ARM_SMCCC_HV_PV_FEATURES \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_64, \ + ARM_SMCCC_OWNER_HYP_STANDARD, \ + 0x20) + +#define ARM_SMCCC_HV_PV_TIME_LPT \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_64, \ + ARM_SMCCC_OWNER_HYP_STANDARD, \ + 0x21) + +#define ARM_SMCCC_HV_PV_TIME_ST \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_64, \ + ARM_SMCCC_OWNER_HYP_STANDARD, \ + 0x22) + +#endif /* __KVM_ARM_PV_H */ diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h index b047009e7a0a..4e0866cc48c0 100644 --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -54,6 +54,7 @@ #define ARM_SMCCC_OWNER_SIP 2 #define ARM_SMCCC_OWNER_OEM 3 #define ARM_SMCCC_OWNER_STANDARD 4 +#define ARM_SMCCC_OWNER_HYP_STANDARD 5 #define ARM_SMCCC_OWNER_TRUSTED_APP 48 #define ARM_SMCCC_OWNER_TRUSTED_APP_END 49 #define ARM_SMCCC_OWNER_TRUSTED_OS 50 diff --git a/virt/kvm/arm/hypercalls.c b/virt/kvm/arm/hypercalls.c index 153aa7642100..ba13b798f0f8 100644 --- a/virt/kvm/arm/hypercalls.c +++ b/virt/kvm/arm/hypercalls.c @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -40,6 +41,14 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) break; } break; + case ARM_SMCCC_HV_PV_FEATURES: + val = SMCCC_RET_SUCCESS; + break; + } + break; + case ARM_SMCCC_HV_PV_FEATURES: + feature = smccc_get_arg1(vcpu); + switch (feature) { } break; default: