From patchwork Tue Jul 18 16:58:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 108181 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp6194419qge; Tue, 18 Jul 2017 10:13:24 -0700 (PDT) X-Received: by 10.84.229.75 with SMTP id d11mr2808353pln.207.1500398003987; Tue, 18 Jul 2017 10:13:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500398003; cv=none; d=google.com; s=arc-20160816; b=Btpk/YCT45dGXKi8qb9gt/2OC/ZRbRjhDyJCtfoUwo6xxaNLGGjNFBSsmRSf0IgBcW 6D/Ueg7DQWj/AFF7aGnYdE4p/BvZblAOB68/y7VC+dhBO6bTwuCBJ43kBYxntkwwDRh2 BSR48aXPm/BZ7Fb6jMJ36KKBP1zII24XbqXm7r6gX3h1iU8gOKHGJ30wPJtkWFYx6v+E EeMuaXg+Y1z0zuliPYdUykk4X2HyR5tXKyzHMJMfsHczTyu1cQZ6yW10+9CoMG5C92/B CoK2CWZPvFFALdElvDnYLK7GlRa8HJsDjnlcjFI8gYHpXuZLg9ihGwkjc8yBL3M0VfbB mVnA== 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:dkim-signature:arc-authentication-results; bh=gS4ttO5+VUU0HPCLsGuyaKUxGqZs9JmugC2RyJAHZ70=; b=r7QpJAGWYUR0WU6ZggWVT00TrVnZFiHyO4SHi6Vm0SWDbMcuY1Z6lH5ShIUMCmvR1C 6EtiyH7LV+VSbhl98JQ4DIsIFu8YtPreNRzf97VdmXgiP3ma/okk++f/q91MzElQc/QE 7zcx3Wib3YoA8Vtp9mOxNHTkQHqgGbtAAzvDKDjBky5yqOhJexuzsbcTba0qvbsEkqXL 15ggeu5UBqYwv+AiB4VJ5pD/Gs01zyBdShs9os9EyO76PNYYv/iAPB+zWXUkqxjtnKp2 XMEBG2bLHPxR36soDbngMm7UYDSFoQ21d9fNNknG+AsGJChCTi7e7X6Y89kVAUX4pvLh 1ivA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=JuHNthdA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z192si2105468pgd.313.2017.07.18.10.13.23; Tue, 18 Jul 2017 10:13:23 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.b=JuHNthdA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752213AbdGRRNU (ORCPT + 25 others); Tue, 18 Jul 2017 13:13:20 -0400 Received: from mail-io0-f172.google.com ([209.85.223.172]:36215 "EHLO mail-io0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751661AbdGRQ7i (ORCPT ); Tue, 18 Jul 2017 12:59:38 -0400 Received: by mail-io0-f172.google.com with SMTP id z62so17063680ioi.3 for ; Tue, 18 Jul 2017 09:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gS4ttO5+VUU0HPCLsGuyaKUxGqZs9JmugC2RyJAHZ70=; b=JuHNthdA7Dpn2XClve7BZQJ/e32R9ockUOcLhDeHQSy/4+Ku0Yv/Rf1+ggX9GA6y8q ljXz2Hbo0XdbiPLOn4HA1oywLxusO02cRHGqg2YUhRT7e+dWiE+uPBf2itHfJ/zzoEvy +nma0oxKavrA79NstL4y3EVcy1ikfgoJ9G4hY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gS4ttO5+VUU0HPCLsGuyaKUxGqZs9JmugC2RyJAHZ70=; b=s38YdvEvtOLIJA9BGyS61UaSFmRUxftZm3MeXNwTP8O/VRvRIZmG/GvCy9OEyf5kNT l9BZSxIi2htQqP1hWSHsyeCxq0QxV3O2Ige+/hzuPcn0i8XjRTMkIzLxtMR7Ovuahs0H EmDA9xZktOogG4yEJOfI0v8vRU94/OcJE4E8aE4TieUTvMfiZJx7A9pll+JVQC39wNWN l7rwz/8oxiTPYHLlktUS8cS69Tta2nAfgs+beooHe5yCfz2apipUfp1+vIqq3A/KsEG6 LC34R1me8lavWVeBVokYLXljkqBZmprYzdNsIN/T9KJZ17kxZY59a7z82Cg+0mmqrGSH PyWg== X-Gm-Message-State: AIVw111c/DhyNAWtLFk+EWfX2crFYjn4oCSlCB9+Y1+THaS3dlAOKeFN 5J+tmCYnznHVpJLr X-Received: by 10.107.18.140 with SMTP id 12mr2502422ios.119.1500397177618; Tue, 18 Jul 2017 09:59:37 -0700 (PDT) Received: from node.jintackl-qv26972.kvmarm-pg0.wisc.cloudlab.us (c220g1-030822.wisc.cloudlab.us. [128.104.222.82]) by smtp.gmail.com with ESMTPSA id j96sm1413075ioo.49.2017.07.18.09.59.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 09:59:36 -0700 (PDT) From: Jintack Lim To: kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com Cc: corbet@lwn.net, pbonzini@redhat.com, rkrcmar@redhat.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, akpm@linux-foundation.org, mchehab@kernel.org, cov@codeaurora.org, daniel.lezcano@linaro.org, david.daney@cavium.com, mark.rutland@arm.com, suzuki.poulose@arm.com, stefan@hello-penguin.com, andy.gross@linaro.org, wcohen@redhat.com, ard.biesheuvel@linaro.org, shankerd@codeaurora.org, vladimir.murzin@arm.com, james.morse@arm.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jintack Lim Subject: [RFC PATCH v2 02/38] KVM: arm/arm64: Enable nested virtualization via command-line Date: Tue, 18 Jul 2017 11:58:28 -0500 Message-Id: <1500397144-16232-3-git-send-email-jintack.lim@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1500397144-16232-1-git-send-email-jintack.lim@linaro.org> References: <1500397144-16232-1-git-send-email-jintack.lim@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new kernel parameter(kvm-arm.nested) to enable KVM/ARM nested virtualization support. This kernel parameter on arm architecture is ignored since nested virtualization is not supported on arm. Note that this kernel parameter will not have any impact until nested virtualization support is completed. Just add this parameter first to use it when implementing nested virtualization support. Signed-off-by: Jintack Lim --- Documentation/admin-guide/kernel-parameters.txt | 4 ++++ arch/arm/include/asm/kvm_host.h | 4 ++++ arch/arm64/include/asm/kvm_host.h | 2 ++ arch/arm64/kvm/Makefile | 2 ++ arch/arm64/kvm/nested.c | 26 +++++++++++++++++++++++++ virt/kvm/arm/arm.c | 2 ++ 6 files changed, 40 insertions(+) create mode 100644 arch/arm64/kvm/nested.c -- 1.9.1 diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index aa8341e..8fb152d 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1841,6 +1841,10 @@ [KVM,ARM] Trap guest accesses to GICv3 common system registers + kvm-arm.nested= + [KVM,ARM] Allow nested virtualization in KVM/ARM. + Default is 0 (disabled) + kvm-intel.ept= [KVM,Intel] Disable extended page tables (virtualized MMU) support on capable Intel chips. Default is 1 (enabled) diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index 127e2dd..00b0f97 100644 --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h @@ -299,4 +299,8 @@ int kvm_arm_vcpu_arch_get_attr(struct kvm_vcpu *vcpu, int kvm_arm_vcpu_arch_has_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr); +static inline int __init kvmarm_nested_cfg(char *buf) +{ + return 0; +} #endif /* __ARM_KVM_HOST_H__ */ diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 0c4fd1f..dcc4df8 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -386,4 +386,6 @@ static inline void __cpu_init_stage2(void) "PARange is %d bits, unsupported configuration!", parange); } +int __init kvmarm_nested_cfg(char *buf); + #endif /* __ARM64_KVM_HOST_H__ */ diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile index 5d98100..f513047 100644 --- a/arch/arm64/kvm/Makefile +++ b/arch/arm64/kvm/Makefile @@ -35,3 +35,5 @@ kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/vgic/vgic-debug.o kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/irqchip.o kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/arch_timer.o kvm-$(CONFIG_KVM_ARM_PMU) += $(KVM)/arm/pmu.o + +kvm-$(CONFIG_KVM_ARM_HOST) += nested.o diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c new file mode 100644 index 0000000..79f38da --- /dev/null +++ b/arch/arm64/kvm/nested.c @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2017 - Columbia University and Linaro Ltd. + * Author: Jintack Lim + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include + +static bool nested_param; + +int __init kvmarm_nested_cfg(char *buf) +{ + return strtobool(buf, &nested_param); +} diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index a39a1e1..1c1c772 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -67,6 +67,8 @@ static DEFINE_PER_CPU(unsigned char, kvm_arm_hardware_enabled); +early_param("kvm-arm.nested", kvmarm_nested_cfg); + static void kvm_arm_set_running_vcpu(struct kvm_vcpu *vcpu) { BUG_ON(preemptible());