Message ID | 1500397144-16232-18-git-send-email-jintack.lim@linaro.org |
---|---|
State | New |
Headers | show
Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp6188384qge; Tue, 18 Jul 2017 10:08:53 -0700 (PDT) X-Received: by 10.98.197.130 with SMTP id j124mr2653484pfg.117.1500397733157; Tue, 18 Jul 2017 10:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500397733; cv=none; d=google.com; s=arc-20160816; b=SmiA1yI0EwuA0+MkD6l9eY4BgXMaFaPQidsNKLbDDzEVdogRsROxJYPkdxqAv6J/q3 F57WG4DuWiJbwpq4MUlNwYe10G5R4BGDDaIkvfhaOK36C4evD+7meTkp+/lVyczxYvIy PVgNhy2Ra16pTw/kKx0wkXSYJIkAReezXz/3iSkdvoZztKFZvSdNBbgaZJDzzEk5Ep5O UMIrkZyqpxxVyfTVYz3yE/wx2p3SnSrCYAxe0G4PkvV2Lg6Bi49dxV3C/8PK0CiU6jZj Lm78zzJYAGRe0V6HfGyqDwK46TsaWWxd/SwMg8CRoNxumCUaiXgaEpKg0NZoktSU8RID C3lw== 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=SDxDsiNRGBAtNxVsRG2mqOMWzuz/FgyKHCtIVSKW+ks=; b=qeo7LuVqj3XrTjIRoKtzDo9ucjYYs45yf2E5SY/2Zfre4DGH+NMYrHX5O9VuyMkOlO 3OfLghdFPtwQDvsU6Guqz/KPLf261/zpqWhn/VS3c/AhBdHjlGbjhwZ80diFQC6PgoW8 HbGW9hsrhRaTv7xBdpfRrnVGcipNYDIWuC75/tRr1cEbymNBP+BAdZCm348JiJyHbKDT kEjj3ONS8Wj1tmts9u9mwtfiAIUPSqomiJzN2hbV6M7I9NpFtgUD1RZTEP4VYPEYQPZn pU/pfDGzR0opgHhJNR36rMXVRgknTfalXt1V3lEvhTMgT/1qErLFjrekRAjESwyX08JF vZzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=jNB88igg; 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: <linux-kernel-owner@vger.kernel.org> Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y14si2192844pgr.587.2017.07.18.10.08.52; Tue, 18 Jul 2017 10:08:53 -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=jNB88igg; 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 S1752459AbdGRRIt (ORCPT <rfc822;georgi.djakov@linaro.org> + 25 others); Tue, 18 Jul 2017 13:08:49 -0400 Received: from mail-io0-f179.google.com ([209.85.223.179]:35469 "EHLO mail-io0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751770AbdGRRAE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 18 Jul 2017 13:00:04 -0400 Received: by mail-io0-f179.google.com with SMTP id k71so16781597iod.2 for <linux-kernel@vger.kernel.org>; Tue, 18 Jul 2017 10:00:04 -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=SDxDsiNRGBAtNxVsRG2mqOMWzuz/FgyKHCtIVSKW+ks=; b=jNB88iggdZLnxpvJ/emN+rCk5jpRMVUjDtm5PTd2s4+LRNX2nt01hj+1jWG/vurkW9 q3XkAtzvIgPsLTQQ92qwNHFGYJB6GlQhWrdi6WjSSD9/m1Bb7pMWd/l5N73lCS99K9Eo VYO6ZFe6aR+fXyNnzTGWOkZQ8MGuAXQnPgfas= 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=SDxDsiNRGBAtNxVsRG2mqOMWzuz/FgyKHCtIVSKW+ks=; b=Q23gtbP1FcGXq9YSUrBi6lOnLGmtFMMqAFxacstu3wqF2KhHkR0A2PGqYto/WeGNUw vsiTx6tm83MEMQb06dg1PJbRJqXbBMZFI/ZdUxE3uBpk3ezuWr1CC5LcjWSF6kpsHuUP WLYi7y2rMYwdUu78NbFFeAdysdrEvKfTFh29E1/+pIVqZ1kzc7xkmTRYyPSY2ADq+JzB 6/CYNQlBCovbA2bhb266zwwy2Msew+ckR3m6HsShBX1uORuQ2uAvQLkZ9PTt+aEUSh65 J877U2+fXynY2aiWNGolQ32iBXD97gEC/D+s9XVEdXmypk6tOhmirDS7HiXG3WuVqFo0 VOOg== X-Gm-Message-State: AIVw113DoRmhH6i1yHB/BYEFeQYeyc+BNgMooStpH8q24U49x9Vzcsd+ fdMwM0cAOk6JpYe3 X-Received: by 10.107.1.68 with SMTP id 65mr2654843iob.174.1500397203952; Tue, 18 Jul 2017 10:00:03 -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.10.00.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 10:00:03 -0700 (PDT) From: Jintack Lim <jintack.lim@linaro.org> 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 Subject: [RFC PATCH v2 17/38] KVM: arm64: Trap EL1 VM register accesses in virtual EL2 Date: Tue, 18 Jul 2017 11:58:43 -0500 Message-Id: <1500397144-16232-18-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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org |
Series |
Nested Virtualization on KVM/ARM
|
expand
|
diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index 945e79c..ec91cd08 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -85,6 +85,8 @@ static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu) write_sysreg(1 << 30, fpexc32_el2); isb(); } + if (vcpu_mode_el2(vcpu)) + val |= HCR_TVM | HCR_TRVM; write_sysreg(val, hcr_el2); /* Trap on AArch32 cp15 c15 accesses (EL1 or EL0) */ write_sysreg(1 << 15, hstr_el2); diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 2b3ed70..d8b1d4b 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -121,7 +121,12 @@ static bool access_vm_reg(struct kvm_vcpu *vcpu, { bool was_enabled = vcpu_has_cache_enabled(vcpu); - BUG_ON(!p->is_write); + BUG_ON(!vcpu_mode_el2(vcpu) && !p->is_write); + + if (!p->is_write) { + p->regval = vcpu_sys_reg(vcpu, r->reg); + return true; + } if (!p->is_aarch32) { vcpu_sys_reg(vcpu, r->reg) = p->regval;