From patchwork Fri Dec 20 14:30:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Murray X-Patchwork-Id: 182283 Delivered-To: patch@linaro.org Received: by 2002:a92:1f98:0:0:0:0:0 with SMTP id f24csp608066ilf; Fri, 20 Dec 2019 06:32:31 -0800 (PST) X-Google-Smtp-Source: APXvYqz4egb3bmXOuiDmLKK6LzcHHaQ/SzA3S6JX6pvaSZFkPX7FGUy3k9KTumuOYuu9sIUDVTeO X-Received: by 2002:a9d:61c4:: with SMTP id h4mr15910365otk.310.1576852351862; Fri, 20 Dec 2019 06:32:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576852351; cv=none; d=google.com; s=arc-20160816; b=fae7J6LUkE3AFV4dJN3CUgpC0j/EXFjFKh408Ef8b8PeMed1n1YgLVlE98KbDJ9veM yws8vQ5jSYA559Wja6mAL0PNLcsFmVy5HZbGCdGOWTB1c27hWaXVcc7GSOe8GEAqP2J/ GWQc83e2Qf1TSTh5woO5FfxNp7Jznmf7rD8RtxIpMUbJn+8GXk6pgaJuMH6CTr4ACGby 50EZXpaYlzLZvAJ2muZ4tERudvTI1yZ24KslT07fGpOvwzyj/ZYIglVYWQXeGAzYSAx4 XxfvXAsR1a50Y7eSWBXBGP8BYfovzZfId3oR2Z1luYmpIH1x4a/zyrEAeqxmVh8K276R BTuQ== 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=6TowpFpBYiy/I8Im0zP6he1uH+y6EKepLd+I8iR+MCg=; b=UjtdK4+MHRvY6UsrYHar7qtL3Q0Ar0gVLWjz9ZOrMmrOiZsoNmgyRAJjWSmDfda5iJ Puj/H3tU7ye+YP/pPv2enOw7TwbybodUYpJyHc/w3bfOtBIWmWhJlJMu7lombO7f+/1R //hQ57jWHKbp9XdT+UFuwDmL1UsvODexmLW9ZznmL/LEz7pd3+FmRue/7rZmwGMh3t0s jFDlXRi6lo+Ew8O54nzM68giDXDx+MXWjOQ66IwxhDycM4st6eUzcGALv0jp3rozG8iB ZK7vqk05Cddlj5dG5BE2PXdFkkdoS3GhdWb1um/d1h2MibxZZefjQF1pDeayeTx7x6ae ZgHQ== 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 w64si4972237oib.185.2019.12.20.06.32.25; Fri, 20 Dec 2019 06:32:31 -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 S1727866AbfLTOap (ORCPT + 27 others); Fri, 20 Dec 2019 09:30:45 -0500 Received: from foss.arm.com ([217.140.110.172]:51198 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727809AbfLTOaj (ORCPT ); Fri, 20 Dec 2019 09:30:39 -0500 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 DF45611D4; Fri, 20 Dec 2019 06:30:38 -0800 (PST) Received: from e119886-lin.cambridge.arm.com (unknown [10.37.6.20]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1120D3F718; Fri, 20 Dec 2019 06:30:36 -0800 (PST) From: Andrew Murray To: Marc Zyngier , Catalin Marinas , Will Deacon Cc: Sudeep Holla , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Rutland Subject: [PATCH v2 03/18] arm64: KVM: define SPE data structure for each vcpu Date: Fri, 20 Dec 2019 14:30:10 +0000 Message-Id: <20191220143025.33853-4-andrew.murray@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191220143025.33853-1-andrew.murray@arm.com> References: <20191220143025.33853-1-andrew.murray@arm.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sudeep Holla In order to support virtual SPE for guest, so define some basic structs. This features depends on host having hardware with SPE support. Since we can support this only on ARM64, add a separate config symbol for the same. Signed-off-by: Sudeep Holla [ Add irq_level, rename irq to irq_num for kvm_spe ] Signed-off-by: Andrew Murray --- arch/arm64/include/asm/kvm_host.h | 2 ++ arch/arm64/kvm/Kconfig | 7 +++++++ include/kvm/arm_spe.h | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 include/kvm/arm_spe.h -- 2.21.0 diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index c61260cf63c5..f5dcff912645 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -35,6 +35,7 @@ #include #include #include +#include #define KVM_MAX_VCPUS VGIC_V3_MAX_CPUS @@ -302,6 +303,7 @@ struct kvm_vcpu_arch { struct vgic_cpu vgic_cpu; struct arch_timer_cpu timer_cpu; struct kvm_pmu pmu; + struct kvm_spe spe; /* * Anything that is not used directly from assembly code goes diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig index a475c68cbfec..af5be2c57dcb 100644 --- a/arch/arm64/kvm/Kconfig +++ b/arch/arm64/kvm/Kconfig @@ -35,6 +35,7 @@ config KVM select HAVE_KVM_EVENTFD select HAVE_KVM_IRQFD select KVM_ARM_PMU if HW_PERF_EVENTS + select KVM_ARM_SPE if (HW_PERF_EVENTS && ARM_SPE_PMU) select HAVE_KVM_MSI select HAVE_KVM_IRQCHIP select HAVE_KVM_IRQ_ROUTING @@ -61,6 +62,12 @@ config KVM_ARM_PMU Adds support for a virtual Performance Monitoring Unit (PMU) in virtual machines. +config KVM_ARM_SPE + bool + ---help--- + Adds support for a virtual Statistical Profiling Extension(SPE) in + virtual machines. + config KVM_INDIRECT_VECTORS def_bool KVM && (HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS) diff --git a/include/kvm/arm_spe.h b/include/kvm/arm_spe.h new file mode 100644 index 000000000000..48d118fdb174 --- /dev/null +++ b/include/kvm/arm_spe.h @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2019 ARM Ltd. + */ + +#ifndef __ASM_ARM_KVM_SPE_H +#define __ASM_ARM_KVM_SPE_H + +#include +#include + +struct kvm_spe { + int irq_num; + bool ready; /* indicates that SPE KVM instance is ready for use */ + bool created; /* SPE KVM instance is created, may not be ready yet */ + bool irq_level; +}; + +#endif /* __ASM_ARM_KVM_SPE_H */